aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/mantis/mantis_ca.c
diff options
context:
space:
mode:
authorManu Abraham <abraham.manu@gmail.com>2009-12-04 03:41:11 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-01-17 08:55:42 -0500
commitb3b961448f702339444036f94252ff2ba7a99feb (patch)
treef31007bb892091072fa97f43f5666105b1ea8f33 /drivers/media/dvb/mantis/mantis_ca.c
parentadd206368462434ba97e8fe4de98e5d47ffdb0a0 (diff)
V4L/DVB (13795): [Mantis/Hopper] Code overhaul, add Hopper devices into the PCI ID list
Signed-off-by: Manu Abraham <manu@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/mantis/mantis_ca.c')
-rw-r--r--drivers/media/dvb/mantis/mantis_ca.c69
1 files changed, 44 insertions, 25 deletions
diff --git a/drivers/media/dvb/mantis/mantis_ca.c b/drivers/media/dvb/mantis/mantis_ca.c
index 7aa27e0703b..4151cba35e7 100644
--- a/drivers/media/dvb/mantis/mantis_ca.c
+++ b/drivers/media/dvb/mantis/mantis_ca.c
@@ -18,16 +18,30 @@
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/ 19*/
20 20
21#include <asm/irq.h>
22#include <linux/signal.h>
23#include <linux/sched.h>
24#include <linux/interrupt.h>
25
26#include "dmxdev.h"
27#include "dvbdev.h"
28#include "dvb_demux.h"
29#include "dvb_frontend.h"
30#include "dvb_net.h"
31
21#include "mantis_common.h" 32#include "mantis_common.h"
22#include "mantis_link.h" 33#include "mantis_link.h"
23#include "mantis_hif.h" 34#include "mantis_hif.h"
35#include "mantis_reg.h"
36
37#include "mantis_ca.h"
24 38
25static int mantis_ca_read_attr_mem(struct dvb_ca_en50221 *en50221, int slot, int addr) 39static int mantis_ca_read_attr_mem(struct dvb_ca_en50221 *en50221, int slot, int addr)
26{ 40{
27 struct mantis_ca *ca = en50221->data; 41 struct mantis_ca *ca = en50221->data;
28 struct mantis_pci *mantis = ca->ca_priv; 42 struct mantis_pci *mantis = ca->ca_priv;
29 43
30 dprintk(verbose, MANTIS_DEBUG, 1, "Slot(%d): Request Attribute Mem Read", slot); 44 dprintk(MANTIS_DEBUG, 1, "Slot(%d): Request Attribute Mem Read", slot);
31 45
32 if (slot != 0) 46 if (slot != 0)
33 return -EINVAL; 47 return -EINVAL;
@@ -40,7 +54,7 @@ static int mantis_ca_write_attr_mem(struct dvb_ca_en50221 *en50221, int slot, in
40 struct mantis_ca *ca = en50221->data; 54 struct mantis_ca *ca = en50221->data;
41 struct mantis_pci *mantis = ca->ca_priv; 55 struct mantis_pci *mantis = ca->ca_priv;
42 56
43 dprintk(verbose, MANTIS_DEBUG, 1, "Slot(%d): Request Attribute Mem Write", slot); 57 dprintk(MANTIS_DEBUG, 1, "Slot(%d): Request Attribute Mem Write", slot);
44 58
45 if (slot != 0) 59 if (slot != 0)
46 return -EINVAL; 60 return -EINVAL;
@@ -53,7 +67,7 @@ static int mantis_ca_read_cam_ctl(struct dvb_ca_en50221 *en50221, int slot, u8 a
53 struct mantis_ca *ca = en50221->data; 67 struct mantis_ca *ca = en50221->data;
54 struct mantis_pci *mantis = ca->ca_priv; 68 struct mantis_pci *mantis = ca->ca_priv;
55 69
56 dprintk(verbose, MANTIS_DEBUG, 1, "Slot(%d): Request CAM control Read", slot); 70 dprintk(MANTIS_DEBUG, 1, "Slot(%d): Request CAM control Read", slot);
57 71
58 if (slot != 0) 72 if (slot != 0)
59 return -EINVAL; 73 return -EINVAL;
@@ -66,7 +80,7 @@ static int mantis_ca_write_cam_ctl(struct dvb_ca_en50221 *en50221, int slot, u8
66 struct mantis_ca *ca = en50221->data; 80 struct mantis_ca *ca = en50221->data;
67 struct mantis_pci *mantis = ca->ca_priv; 81 struct mantis_pci *mantis = ca->ca_priv;
68 82
69 dprintk(verbose, MANTIS_DEBUG, 1, "Slot(%d): Request CAM control Write", slot); 83 dprintk(MANTIS_DEBUG, 1, "Slot(%d): Request CAM control Write", slot);
70 84
71 if (slot != 0) 85 if (slot != 0)
72 return -EINVAL; 86 return -EINVAL;
@@ -79,7 +93,7 @@ static int mantis_ca_slot_reset(struct dvb_ca_en50221 *en50221, int slot)
79 struct mantis_ca *ca = en50221->data; 93 struct mantis_ca *ca = en50221->data;
80 struct mantis_pci *mantis = ca->ca_priv; 94 struct mantis_pci *mantis = ca->ca_priv;
81 95
82 dprintk(verbose, MANTIS_DEBUG, 1, "Slot(%d): Slot RESET", slot); 96 dprintk(MANTIS_DEBUG, 1, "Slot(%d): Slot RESET", slot);
83 udelay(500); /* Wait.. */ 97 udelay(500); /* Wait.. */
84 mmwrite(0xda, MANTIS_PCMCIA_RESET); /* Leading edge assert */ 98 mmwrite(0xda, MANTIS_PCMCIA_RESET); /* Leading edge assert */
85 udelay(500); 99 udelay(500);
@@ -95,7 +109,7 @@ static int mantis_ca_slot_shutdown(struct dvb_ca_en50221 *en50221, int slot)
95 struct mantis_ca *ca = en50221->data; 109 struct mantis_ca *ca = en50221->data;
96 struct mantis_pci *mantis = ca->ca_priv; 110 struct mantis_pci *mantis = ca->ca_priv;
97 111
98 dprintk(verbose, MANTIS_DEBUG, 1, "Slot(%d): Slot shutdown", slot); 112 dprintk(MANTIS_DEBUG, 1, "Slot(%d): Slot shutdown", slot);
99 113
100 return 0; 114 return 0;
101} 115}
@@ -105,8 +119,8 @@ static int mantis_ts_control(struct dvb_ca_en50221 *en50221, int slot)
105 struct mantis_ca *ca = en50221->data; 119 struct mantis_ca *ca = en50221->data;
106 struct mantis_pci *mantis = ca->ca_priv; 120 struct mantis_pci *mantis = ca->ca_priv;
107 121
108 dprintk(verbose, MANTIS_DEBUG, 1, "Slot(%d): TS control", slot); 122 dprintk(MANTIS_DEBUG, 1, "Slot(%d): TS control", slot);
109 mantis_set_direction(mantis, 1); /* Enable TS through CAM */ 123// mantis_set_direction(mantis, 1); /* Enable TS through CAM */
110 124
111 return 0; 125 return 0;
112} 126}
@@ -116,13 +130,13 @@ static int mantis_slot_status(struct dvb_ca_en50221 *en50221, int slot, int open
116 struct mantis_ca *ca = en50221->data; 130 struct mantis_ca *ca = en50221->data;
117 struct mantis_pci *mantis = ca->ca_priv; 131 struct mantis_pci *mantis = ca->ca_priv;
118 132
119 dprintk(verbose, MANTIS_DEBUG, 1, "Slot(%d): Poll Slot status", slot); 133 dprintk(MANTIS_DEBUG, 1, "Slot(%d): Poll Slot status", slot);
120 134
121 if (ca->slot_state == MODULE_INSERTED) { 135 if (ca->slot_state == MODULE_INSERTED) {
122 dprintk(verbose, MANTIS_DEBUG, 1, "CA Module present and ready"); 136 dprintk(MANTIS_DEBUG, 1, "CA Module present and ready");
123 return DVB_CA_EN50221_POLL_CAM_PRESENT | DVB_CA_EN50221_POLL_CAM_READY; 137 return DVB_CA_EN50221_POLL_CAM_PRESENT | DVB_CA_EN50221_POLL_CAM_READY;
124 } else { 138 } else {
125 dprintk(verbose, MANTIS_DEBUG, 1, "CA Module not present or not ready"); 139 dprintk(MANTIS_DEBUG, 1, "CA Module not present or not ready");
126 } 140 }
127 141
128 return 0; 142 return 0;
@@ -130,20 +144,21 @@ static int mantis_slot_status(struct dvb_ca_en50221 *en50221, int slot, int open
130 144
131int mantis_ca_init(struct mantis_pci *mantis) 145int mantis_ca_init(struct mantis_pci *mantis)
132{ 146{
133 struct dvb_adapter *dvb_adapter = &mantis->dvb_adapter; 147 struct dvb_adapter *dvb_adapter = &mantis->dvb_adapter;
134 struct mantis_ca *ca; 148 struct mantis_ca *ca;
135 int ca_flags = 0, result; 149 int ca_flags = 0, result;
136 150
137 dprintk(verbose, MANTIS_DEBUG, 1, "Initializing Mantis CA"); 151 dprintk(MANTIS_DEBUG, 1, "Initializing Mantis CA");
138 if (!(ca = kzalloc(sizeof (struct mantis_ca), GFP_KERNEL))) { 152 ca = kzalloc(sizeof (struct mantis_ca), GFP_KERNEL);
139 dprintk(verbose, MANTIS_ERROR, 1, "Out of memory!, exiting .."); 153 if (!ca) {
154 dprintk(MANTIS_ERROR, 1, "Out of memory!, exiting ..");
140 result = -ENOMEM; 155 result = -ENOMEM;
141 goto err; 156 goto err;
142 } 157 }
143 158
144 ca->ca_priv = mantis; 159 ca->ca_priv = mantis;
145 mantis->mantis_ca = ca; 160 mantis->mantis_ca = ca;
146 ca_flags = DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE; 161 ca_flags = DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE;
147 /* register CA interface */ 162 /* register CA interface */
148 ca->en50221.owner = THIS_MODULE; 163 ca->en50221.owner = THIS_MODULE;
149 ca->en50221.read_attribute_mem = mantis_ca_read_attr_mem; 164 ca->en50221.read_attribute_mem = mantis_ca_read_attr_mem;
@@ -162,28 +177,32 @@ int mantis_ca_init(struct mantis_pci *mantis)
162 init_waitqueue_head(&ca->hif_opdone_wq); 177 init_waitqueue_head(&ca->hif_opdone_wq);
163 init_waitqueue_head(&ca->hif_write_wq); 178 init_waitqueue_head(&ca->hif_write_wq);
164 179
165 dprintk(verbose, MANTIS_ERROR, 1, "Registering EN50221 device"); 180 dprintk(MANTIS_ERROR, 1, "Registering EN50221 device");
166 if ((result = dvb_ca_en50221_init(dvb_adapter, &ca->en50221, ca_flags, 1)) != 0) { 181 result = dvb_ca_en50221_init(dvb_adapter, &ca->en50221, ca_flags, 1);
167 dprintk(verbose, MANTIS_ERROR, 1, "EN50221: Initialization failed"); 182 if (result != 0) {
183 dprintk(MANTIS_ERROR, 1, "EN50221: Initialization failed <%d>", result);
168 goto err; 184 goto err;
169 } 185 }
170 dprintk(verbose, MANTIS_ERROR, 1, "Registered EN50221 device"); 186 dprintk(MANTIS_ERROR, 1, "Registered EN50221 device");
171 mantis_evmgr_init(ca); 187 mantis_evmgr_init(ca);
172 return 0; 188 return 0;
173err: 189err:
174 kfree(ca); 190 kfree(ca);
175 return result; 191 return result;
176} 192}
193EXPORT_SYMBOL_GPL(mantis_ca_init);
177 194
178void mantis_ca_exit(struct mantis_pci *mantis) 195void mantis_ca_exit(struct mantis_pci *mantis)
179{ 196{
180 struct mantis_ca *ca = mantis->mantis_ca; 197 struct mantis_ca *ca = mantis->mantis_ca;
181 198
182 dprintk(verbose, MANTIS_DEBUG, 1, "Mantis CA exit"); 199 dprintk(MANTIS_DEBUG, 1, "Mantis CA exit");
183 200
184 mantis_evmgr_exit(ca); 201 mantis_evmgr_exit(ca);
185 dprintk(verbose, MANTIS_ERROR, 1, "Unregistering EN50221 device"); 202 dprintk(MANTIS_ERROR, 1, "Unregistering EN50221 device");
186 dvb_ca_en50221_release(&ca->en50221); 203 if (ca)
204 dvb_ca_en50221_release(&ca->en50221);
187 205
188 kfree(ca); 206 kfree(ca);
189} 207}
208EXPORT_SYMBOL_GPL(mantis_ca_exit);