Greg Kroah-Hartman | c81c8b6 | 2008-03-06 21:30:23 -0800 | [diff] [blame^] | 1 | #include "firesat-ci.h" |
| 2 | #include "firesat.h" |
| 3 | #include "avc_api.h" |
| 4 | |
| 5 | #include <linux/dvb/ca.h> |
| 6 | #include <dvbdev.h> |
| 7 | /* |
| 8 | static int firesat_ca_do_ioctl(struct inode *inode, struct file *file, unsigned int cmd, void *parg) { |
| 9 | //struct firesat *firesat = (struct firesat*)((struct dvb_device*)file->private_data)->priv; |
| 10 | int err; |
| 11 | |
| 12 | // printk(KERN_INFO "%s: ioctl %d\n",__func__,cmd); |
| 13 | |
| 14 | switch(cmd) { |
| 15 | case CA_RESET: |
| 16 | // TODO: Needs to be implemented with new AVC Vendor commands |
| 17 | break; |
| 18 | case CA_GET_CAP: { |
| 19 | ca_caps_t *cap=(ca_caps_t*)parg; |
| 20 | cap->slot_num = 1; |
| 21 | cap->slot_type = CA_CI_LINK; |
| 22 | cap->descr_num = 1; |
| 23 | cap->descr_type = CA_DSS; |
| 24 | |
| 25 | err = 0; |
| 26 | break; |
| 27 | } |
| 28 | case CA_GET_SLOT_INFO: { |
| 29 | ca_slot_info_t *slot=(ca_slot_info_t*)parg; |
| 30 | if(slot->num == 0) { |
| 31 | slot->type = CA_CI | CA_CI_LINK | CA_DESCR; |
| 32 | slot->flags = CA_CI_MODULE_PRESENT | CA_CI_MODULE_READY; |
| 33 | } else { |
| 34 | slot->type = 0; |
| 35 | slot->flags = 0; |
| 36 | } |
| 37 | err = 0; |
| 38 | break; |
| 39 | } |
| 40 | default: |
| 41 | err=-EINVAL; |
| 42 | } |
| 43 | return err; |
| 44 | } |
| 45 | */ |
| 46 | |
| 47 | static int firesat_ca_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { |
| 48 | //return dvb_usercopy(inode, file, cmd, arg, firesat_ca_do_ioctl); |
| 49 | return dvb_generic_ioctl(inode, file, cmd, arg); |
| 50 | } |
| 51 | |
| 52 | static int firesat_ca_io_open(struct inode *inode, struct file *file) { |
| 53 | printk(KERN_INFO "%s!\n",__func__); |
| 54 | return dvb_generic_open(inode, file); |
| 55 | } |
| 56 | |
| 57 | static int firesat_ca_io_release(struct inode *inode, struct file *file) { |
| 58 | printk(KERN_INFO "%s!\n",__func__); |
| 59 | return dvb_generic_release(inode, file); |
| 60 | } |
| 61 | |
| 62 | static unsigned int firesat_ca_io_poll(struct file *file, poll_table *wait) { |
| 63 | // printk(KERN_INFO "%s!\n",__func__); |
| 64 | return POLLIN; |
| 65 | } |
| 66 | |
| 67 | static struct file_operations firesat_ca_fops = { |
| 68 | .owner = THIS_MODULE, |
| 69 | .read = NULL, // There is no low level read anymore |
| 70 | .write = NULL, // There is no low level write anymore |
| 71 | .ioctl = firesat_ca_ioctl, |
| 72 | .open = firesat_ca_io_open, |
| 73 | .release = firesat_ca_io_release, |
| 74 | .poll = firesat_ca_io_poll, |
| 75 | }; |
| 76 | |
| 77 | static struct dvb_device firesat_ca = { |
| 78 | .priv = NULL, |
| 79 | .users = 1, |
| 80 | .readers = 1, |
| 81 | .writers = 1, |
| 82 | .fops = &firesat_ca_fops, |
| 83 | }; |
| 84 | |
| 85 | int firesat_ca_init(struct firesat *firesat) { |
| 86 | int ret = dvb_register_device(firesat->adapter, &firesat->cadev, &firesat_ca, firesat, DVB_DEVICE_CA); |
| 87 | if(ret) return ret; |
| 88 | |
| 89 | // avoid unnecessary delays, we're not talking to the CI yet anyways |
| 90 | return 0; |
| 91 | } |
| 92 | |
| 93 | void firesat_ca_release(struct firesat *firesat) { |
| 94 | dvb_unregister_device(firesat->cadev); |
| 95 | } |