diff options
author | Manu Abraham <abraham.manu@gmail.com> | 2009-12-04 03:11:14 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-01-17 08:55:34 -0500 |
commit | 6053240f5cc914d40ac9c7afe15008bf3e46359c (patch) | |
tree | 5a7cdd5b07c43722945f9cb7e57b527eb732169d /drivers/media/dvb | |
parent | c9a750c909cbde15ecd0f8545f48e051bfee6271 (diff) |
V4L/DVB (13743): [Mantis CA] Use DVB_CA Tuple parser
Signed-off-by: Manu Abraham <manu@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r-- | drivers/media/dvb/mantis/mantis_ca.c | 129 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/mantis_common.h | 2 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/mantis_hif.c | 10 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/mantis_link.h | 9 |
4 files changed, 80 insertions, 70 deletions
diff --git a/drivers/media/dvb/mantis/mantis_ca.c b/drivers/media/dvb/mantis/mantis_ca.c index e6de3c9d3ce4..4be61ca02c20 100644 --- a/drivers/media/dvb/mantis/mantis_ca.c +++ b/drivers/media/dvb/mantis/mantis_ca.c | |||
@@ -22,96 +22,104 @@ | |||
22 | #include "mantis_link.h" | 22 | #include "mantis_link.h" |
23 | #include "mantis_hif.h" | 23 | #include "mantis_hif.h" |
24 | 24 | ||
25 | 25 | static int mantis_ca_read_attr_mem(struct dvb_ca_en50221 *en50221, int slot, int addr) | |
26 | static int mantis_ca_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long parg) | ||
27 | { | 26 | { |
28 | return 0; | 27 | struct mantis_ca *ca = en50221->data; |
28 | |||
29 | if (slot != 0) | ||
30 | return -EINVAL; | ||
31 | |||
32 | return mantis_hif_read_mem(ca, addr); | ||
29 | } | 33 | } |
30 | 34 | ||
31 | static int mantis_ca_open(struct inode *inode, struct file *file) | 35 | static int mantis_ca_write_attr_mem(struct dvb_ca_en50221 *en50221, int slot, int addr, u8 data) |
32 | { | 36 | { |
33 | return 0; | 37 | struct mantis_ca *ca = en50221->data; |
38 | |||
39 | if (slot != 0) | ||
40 | return -EINVAL; | ||
41 | |||
42 | return mantis_hif_write_mem(ca, addr, data); | ||
34 | } | 43 | } |
35 | 44 | ||
36 | static int mantis_ca_release(struct inode *inode, struct file *file) | 45 | static int mantis_ca_read_cam_ctl(struct dvb_ca_en50221 *en50221, int slot, u8 addr) |
37 | { | 46 | { |
38 | return 0; | 47 | struct mantis_ca *ca = en50221->data; |
48 | |||
49 | if (slot != 0) | ||
50 | return -EINVAL; | ||
51 | |||
52 | return mantis_hif_read_iom(ca, addr); | ||
39 | } | 53 | } |
40 | 54 | ||
41 | static ssize_t mantis_ca_read(struct file *file, char __user *buffer, size_t count, loff_t *ofset) | 55 | static int mantis_ca_write_cam_ctl(struct dvb_ca_en50221 *en50221, int slot, u8 addr, u8 data) |
42 | { | 56 | { |
43 | struct dvb_device *dvbdev = file->private_data; | 57 | struct mantis_ca *ca = en50221->data; |
44 | struct mantis_ca *ca = dvbdev->priv; | ||
45 | 58 | ||
46 | int status; | 59 | if (slot != 0) |
60 | return -EINVAL; | ||
47 | 61 | ||
48 | return 0; | 62 | return mantis_hif_write_iom(ca, addr, data); |
49 | error: | ||
50 | return status; | ||
51 | } | 63 | } |
52 | 64 | ||
53 | static ssize_t mantis_ca_write(struct file *file, const char __user *buffer, size_t count, loff_t *offset) | 65 | static int mantis_ca_slot_reset(struct dvb_ca_en50221 *en50221, int slot) |
54 | { | 66 | { |
55 | struct dvb_device *dvbdev = file->private_data; | 67 | return 0; |
56 | struct mantis_ca *ca = dvbdev->priv; | 68 | } |
57 | 69 | ||
58 | int status; | 70 | static int mantis_ca_slot_shutdown(struct dvb_ca_en50221 *en50221, int slot) |
71 | { | ||
72 | return 0; | ||
73 | } | ||
59 | 74 | ||
75 | static int mantis_ts_control(struct dvb_ca_en50221 *en50221, int slot) | ||
76 | { | ||
60 | return 0; | 77 | return 0; |
61 | error: | ||
62 | return status; | ||
63 | } | 78 | } |
64 | 79 | ||
65 | static struct file_operations mantis_fops = { | 80 | static int mantis_slot_status(struct dvb_ca_en50221 *en50221, int slot, int open) |
66 | .owner = THIS_MODULE, | ||
67 | .ioctl = mantis_ca_ioctl, | ||
68 | .open = mantis_ca_open, | ||
69 | .release = mantis_ca_release, | ||
70 | .read = mantis_ca_read, | ||
71 | .write = mantis_ca_write, | ||
72 | }; | ||
73 | |||
74 | static struct dvb_device mantis_ca = { | ||
75 | .priv = NULL, | ||
76 | .users = 1, | ||
77 | .readers = 1, | ||
78 | .writers = 1, | ||
79 | .fops = &mantis_fops, | ||
80 | }; | ||
81 | |||
82 | struct dvb_device *mantis_ca_init(struct mantis_pci *mantis) | ||
83 | { | 81 | { |
84 | int ret; | 82 | return 0; |
83 | } | ||
85 | 84 | ||
86 | struct dvb_device *dvbdev; | 85 | int mantis_ca_init(struct mantis_pci *mantis) |
86 | { | ||
87 | struct dvb_adapter *dvb_adapter = &mantis->dvb_adapter; | 87 | struct dvb_adapter *dvb_adapter = &mantis->dvb_adapter; |
88 | struct mantis_ca *ca; | 88 | struct mantis_ca *ca; |
89 | int ca_flags = 0, result; | ||
89 | 90 | ||
90 | if (!(ca = kzalloc(sizeof (struct mantis_ca), GFP_KERNEL))) { | 91 | if (!(ca = kzalloc(sizeof (struct mantis_ca), GFP_KERNEL))) { |
91 | dprintk(verbose, MANTIS_ERROR, 1, "Out of memory!, exiting .."); | 92 | dprintk(verbose, MANTIS_ERROR, 1, "Out of memory!, exiting .."); |
92 | return NULL; | 93 | result = -ENOMEM; |
94 | goto err; | ||
93 | } | 95 | } |
94 | 96 | ||
95 | ca->ca_priv = mantis; | 97 | ca->ca_priv = mantis; |
96 | 98 | mantis->mantis_ca = ca; | |
97 | dprintk(verbose, MANTIS_ERROR, 0, "CA: Registering Mantis Adapter(%d) Slot(0)\n", mantis->num); | 99 | |
98 | if (dvb_register_device(dvb_adapter, &dvbdev, &mantis_ca, ca, DVB_DEVICE_CA) == 0) { | 100 | /* register CA interface */ |
99 | ca->ca_dev = dvbdev; | 101 | ca->en50221.owner = THIS_MODULE; |
100 | mantis->mantis_ca = ca; | 102 | ca->en50221.read_attribute_mem = mantis_ca_read_attr_mem; |
101 | mantis_evmgr_init(ca); | 103 | ca->en50221.write_attribute_mem = mantis_ca_write_attr_mem; |
102 | return ca->ca_dev; | 104 | ca->en50221.read_cam_control = mantis_ca_read_cam_ctl; |
105 | ca->en50221.write_cam_control = mantis_ca_write_cam_ctl; | ||
106 | ca->en50221.slot_reset = mantis_ca_slot_reset; | ||
107 | ca->en50221.slot_shutdown = mantis_ca_slot_shutdown; | ||
108 | ca->en50221.slot_ts_enable = mantis_ts_control; | ||
109 | ca->en50221.poll_slot_status = mantis_slot_status; | ||
110 | ca->en50221.data = ca; | ||
111 | |||
112 | dprintk(verbose, MANTIS_ERROR, 1, "Registering EN50221 device"); | ||
113 | if ((result = dvb_ca_en50221_init(dvb_adapter, &ca->en50221, ca_flags, 1)) != 0) { | ||
114 | dprintk(verbose, MANTIS_ERROR, 1, "EN50221: Initialization failed"); | ||
115 | goto err; | ||
103 | } | 116 | } |
117 | dprintk(verbose, MANTIS_ERROR, 1, "Registered EN50221 device"); | ||
118 | mantis_evmgr_init(ca); | ||
104 | return 0; | 119 | return 0; |
105 | 120 | err: | |
106 | error: | 121 | kfree(ca); |
107 | if (ca != NULL) { | 122 | return result; |
108 | dprintk(verbose, MANTIS_ERROR, 1, "Error .."); | ||
109 | if (ca->ca_dev != NULL) | ||
110 | dvb_unregister_device(ca->ca_dev); | ||
111 | |||
112 | kfree(ca); | ||
113 | } | ||
114 | return NULL; | ||
115 | } | 123 | } |
116 | 124 | ||
117 | void mantis_ca_exit(struct mantis_pci *mantis) | 125 | void mantis_ca_exit(struct mantis_pci *mantis) |
@@ -119,9 +127,8 @@ void mantis_ca_exit(struct mantis_pci *mantis) | |||
119 | struct mantis_ca *ca = mantis->mantis_ca; | 127 | struct mantis_ca *ca = mantis->mantis_ca; |
120 | 128 | ||
121 | mantis_evmgr_exit(ca); | 129 | mantis_evmgr_exit(ca); |
122 | dprintk(verbose, MANTIS_ERROR, 0, "CA: Unregister Mantis Adapter(%d) Slot(0)\n", mantis->num); | 130 | dprintk(verbose, MANTIS_ERROR, 1, "Unregistering EN50221 device"); |
123 | if (ca->ca_dev) | 131 | dvb_ca_en50221_release(&ca->en50221); |
124 | dvb_unregister_device(ca->ca_dev); | ||
125 | 132 | ||
126 | kfree(ca); | 133 | kfree(ca); |
127 | } | 134 | } |
diff --git a/drivers/media/dvb/mantis/mantis_common.h b/drivers/media/dvb/mantis/mantis_common.h index 7f1cfad74883..0aa4001dea9c 100644 --- a/drivers/media/dvb/mantis/mantis_common.h +++ b/drivers/media/dvb/mantis/mantis_common.h | |||
@@ -151,7 +151,7 @@ extern int mantis_dvb_exit(struct mantis_pci *mantis); | |||
151 | extern void mantis_dma_xfer(unsigned long data); | 151 | extern void mantis_dma_xfer(unsigned long data); |
152 | extern void gpio_set_bits(struct mantis_pci *mantis, u32 bitpos, u8 value); | 152 | extern void gpio_set_bits(struct mantis_pci *mantis, u32 bitpos, u8 value); |
153 | 153 | ||
154 | extern struct dvb_device *mantis_ca_init(struct mantis_pci *mantis); | 154 | extern int mantis_ca_init(struct mantis_pci *mantis); |
155 | extern void mantis_ca_exit(struct mantis_pci *mantis); | 155 | extern void mantis_ca_exit(struct mantis_pci *mantis); |
156 | 156 | ||
157 | 157 | ||
diff --git a/drivers/media/dvb/mantis/mantis_hif.c b/drivers/media/dvb/mantis/mantis_hif.c index 42aedf7a0147..6a1ea96c16d9 100644 --- a/drivers/media/dvb/mantis/mantis_hif.c +++ b/drivers/media/dvb/mantis/mantis_hif.c | |||
@@ -111,10 +111,10 @@ int mantis_hif_write_mem(struct mantis_ca *ca, u32 addr, u8 data) | |||
111 | return 0; | 111 | return 0; |
112 | } | 112 | } |
113 | 113 | ||
114 | int mantis_hif_read_iom(struct mantis_ca *ca, u32 addr, u32 count, u32 *data) | 114 | int mantis_hif_read_iom(struct mantis_ca *ca, u32 addr) |
115 | { | 115 | { |
116 | struct mantis_pci *mantis = ca->ca_priv; | 116 | struct mantis_pci *mantis = ca->ca_priv; |
117 | u32 hif_addr = 0; | 117 | u32 data, hif_addr = 0; |
118 | 118 | ||
119 | hif_addr &= ~MANTIS_GPIF_PCMCIAREG; | 119 | hif_addr &= ~MANTIS_GPIF_PCMCIAREG; |
120 | hif_addr |= MANTIS_GPIF_HIFRDWRN; | 120 | hif_addr |= MANTIS_GPIF_HIFRDWRN; |
@@ -131,14 +131,14 @@ int mantis_hif_read_iom(struct mantis_ca *ca, u32 addr, u32 count, u32 *data) | |||
131 | } | 131 | } |
132 | udelay(50); | 132 | udelay(50); |
133 | ca->hif_job_queue &= ~MANTIS_HIF_IOMRD; | 133 | ca->hif_job_queue &= ~MANTIS_HIF_IOMRD; |
134 | *data = mmread(MANTIS_GPIF_HIFDIN); | 134 | data = mmread(MANTIS_GPIF_HIFDIN); |
135 | hif_addr |= MANTIS_GPIF_PCMCIAREG; | 135 | hif_addr |= MANTIS_GPIF_PCMCIAREG; |
136 | mmwrite(hif_addr, MANTIS_GPIF_HIFADDR); | 136 | mmwrite(hif_addr, MANTIS_GPIF_HIFADDR); |
137 | 137 | ||
138 | return 0; | 138 | return data; |
139 | } | 139 | } |
140 | 140 | ||
141 | int mantis_hif_write_iom(struct mantis_ca *ca, u32 addr, u32 data) | 141 | int mantis_hif_write_iom(struct mantis_ca *ca, u32 addr, u8 data) |
142 | { | 142 | { |
143 | struct mantis_pci *mantis = ca->ca_priv; | 143 | struct mantis_pci *mantis = ca->ca_priv; |
144 | u32 hif_addr = 0; | 144 | u32 hif_addr = 0; |
diff --git a/drivers/media/dvb/mantis/mantis_link.h b/drivers/media/dvb/mantis/mantis_link.h index 478900ea184d..23ff2d6aadbc 100644 --- a/drivers/media/dvb/mantis/mantis_link.h +++ b/drivers/media/dvb/mantis/mantis_link.h | |||
@@ -22,6 +22,7 @@ | |||
22 | #define __MANTIS_LINK_H | 22 | #define __MANTIS_LINK_H |
23 | 23 | ||
24 | #include <linux/workqueue.h> | 24 | #include <linux/workqueue.h> |
25 | #include "dvb_ca_en50221.h" | ||
25 | 26 | ||
26 | enum mantis_sbuf_status { | 27 | enum mantis_sbuf_status { |
27 | MANTIS_SBUF_DATA_AVAIL = 1, | 28 | MANTIS_SBUF_DATA_AVAIL = 1, |
@@ -56,8 +57,10 @@ struct mantis_ca { | |||
56 | 57 | ||
57 | enum mantis_slot_state slot_state; | 58 | enum mantis_slot_state slot_state; |
58 | 59 | ||
59 | struct dvb_device *ca_dev; | 60 | // struct dvb_device *ca_dev; |
60 | void *ca_priv; | 61 | void *ca_priv; |
62 | |||
63 | struct dvb_ca_en50221 en50221; | ||
61 | }; | 64 | }; |
62 | 65 | ||
63 | /* CA */ | 66 | /* CA */ |
@@ -73,7 +76,7 @@ extern int mantis_hif_init(struct mantis_ca *ca); | |||
73 | extern void mantis_hif_exit(struct mantis_ca *ca); | 76 | extern void mantis_hif_exit(struct mantis_ca *ca); |
74 | extern int mantis_hif_read_mem(struct mantis_ca *ca, u32 addr); | 77 | extern int mantis_hif_read_mem(struct mantis_ca *ca, u32 addr); |
75 | extern int mantis_hif_write_mem(struct mantis_ca *ca, u32 addr, u8 data); | 78 | extern int mantis_hif_write_mem(struct mantis_ca *ca, u32 addr, u8 data); |
76 | extern int mantis_hif_read_iom(struct mantis_ca *ca, u32 addr, u32 count, u32 *data); | 79 | extern int mantis_hif_read_iom(struct mantis_ca *ca, u32 addr); |
77 | extern int mantis_hif_write_iom(struct mantis_ca *ca, u32 addr, u32 data); | 80 | extern int mantis_hif_write_iom(struct mantis_ca *ca, u32 addr, u8 data); |
78 | 81 | ||
79 | #endif // __MANTIS_LINK_H | 82 | #endif // __MANTIS_LINK_H |