diff options
author | Abylay Ospan <aospan@netup.ru> | 2009-12-12 10:16:56 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-16 06:27:45 -0500 |
commit | 21508b9ad4bb1db788b5307ab2070f1c2602caf2 (patch) | |
tree | 797d812d0f0ac4459da3ad2f8de4a2f53ace9400 /drivers/media/video/cx23885 | |
parent | 30e8ca2cb0ffd270a5c17366254c83cfb533ad14 (diff) |
V4L/DVB (13676): configurable IRQ mode on NetUP Dual DVB-S2 CI; IRQ from CAM processing (CI interface works faster)
Signed-off-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx23885')
-rw-r--r-- | drivers/media/video/cx23885/cimax2.c | 107 |
1 files changed, 78 insertions, 29 deletions
diff --git a/drivers/media/video/cx23885/cimax2.c b/drivers/media/video/cx23885/cimax2.c index c04222ffb286..d4a9d2c5947c 100644 --- a/drivers/media/video/cx23885/cimax2.c +++ b/drivers/media/video/cx23885/cimax2.c | |||
@@ -53,6 +53,8 @@ | |||
53 | #define NETUP_CI_CTL 0x04 | 53 | #define NETUP_CI_CTL 0x04 |
54 | #define NETUP_CI_RD 1 | 54 | #define NETUP_CI_RD 1 |
55 | 55 | ||
56 | #define NETUP_IRQ_DETAM 0x1 | ||
57 | #define NETUP_IRQ_IRQAM 0x4 | ||
56 | 58 | ||
57 | static unsigned int ci_dbg; | 59 | static unsigned int ci_dbg; |
58 | module_param(ci_dbg, int, 0644); | 60 | module_param(ci_dbg, int, 0644); |
@@ -73,6 +75,9 @@ struct netup_ci_state { | |||
73 | int status; | 75 | int status; |
74 | struct work_struct work; | 76 | struct work_struct work; |
75 | void *priv; | 77 | void *priv; |
78 | u8 current_irq_mode; | ||
79 | int current_ci_flag; | ||
80 | unsigned long next_status_checked_time; | ||
76 | }; | 81 | }; |
77 | 82 | ||
78 | 83 | ||
@@ -169,24 +174,26 @@ int netup_ci_op_cam(struct dvb_ca_en50221 *en50221, int slot, | |||
169 | if (0 != slot) | 174 | if (0 != slot) |
170 | return -EINVAL; | 175 | return -EINVAL; |
171 | 176 | ||
172 | ret = netup_read_i2c(state->i2c_adap, state->ci_i2c_addr, | 177 | if (state->current_ci_flag != flag) { |
173 | 0, &store, 1); | 178 | ret = netup_read_i2c(state->i2c_adap, state->ci_i2c_addr, |
174 | if (ret != 0) | 179 | 0, &store, 1); |
175 | return ret; | 180 | if (ret != 0) |
181 | return ret; | ||
176 | 182 | ||
177 | store &= ~0x0c; | 183 | store &= ~0x0c; |
178 | store |= flag; | 184 | store |= flag; |
179 | 185 | ||
180 | ret = netup_write_i2c(state->i2c_adap, state->ci_i2c_addr, | 186 | ret = netup_write_i2c(state->i2c_adap, state->ci_i2c_addr, |
181 | 0, &store, 1); | 187 | 0, &store, 1); |
182 | if (ret != 0) | 188 | if (ret != 0) |
183 | return ret; | 189 | return ret; |
190 | }; | ||
191 | state->current_ci_flag = flag; | ||
184 | 192 | ||
185 | mutex_lock(&dev->gpio_lock); | 193 | mutex_lock(&dev->gpio_lock); |
186 | 194 | ||
187 | /* write addr */ | 195 | /* write addr */ |
188 | cx_write(MC417_OEN, NETUP_EN_ALL); | 196 | cx_write(MC417_OEN, NETUP_EN_ALL); |
189 | msleep(2); | ||
190 | cx_write(MC417_RWD, NETUP_CTRL_OFF | | 197 | cx_write(MC417_RWD, NETUP_CTRL_OFF | |
191 | NETUP_ADLO | (0xff & addr)); | 198 | NETUP_ADLO | (0xff & addr)); |
192 | cx_clear(MC417_RWD, NETUP_ADLO); | 199 | cx_clear(MC417_RWD, NETUP_ADLO); |
@@ -196,7 +203,6 @@ int netup_ci_op_cam(struct dvb_ca_en50221 *en50221, int slot, | |||
196 | 203 | ||
197 | if (read) { /* data in */ | 204 | if (read) { /* data in */ |
198 | cx_write(MC417_OEN, NETUP_EN_ALL | NETUP_DATA); | 205 | cx_write(MC417_OEN, NETUP_EN_ALL | NETUP_DATA); |
199 | msleep(2); | ||
200 | } else /* data out */ | 206 | } else /* data out */ |
201 | cx_write(MC417_RWD, NETUP_CTRL_OFF | data); | 207 | cx_write(MC417_RWD, NETUP_CTRL_OFF | data); |
202 | 208 | ||
@@ -213,8 +219,8 @@ int netup_ci_op_cam(struct dvb_ca_en50221 *en50221, int slot, | |||
213 | if (mem < 0) | 219 | if (mem < 0) |
214 | return -EREMOTEIO; | 220 | return -EREMOTEIO; |
215 | 221 | ||
216 | ci_dbg_print("%s: %s: addr=[0x%02x], %s=%x\n", __func__, | 222 | ci_dbg_print("%s: %s: chipaddr=[0x%x] addr=[0x%02x], %s=%x\n", __func__, |
217 | (read) ? "read" : "write", addr, | 223 | (read) ? "read" : "write", state->ci_i2c_addr, addr, |
218 | (flag == NETUP_CI_CTL) ? "ctl" : "mem", | 224 | (flag == NETUP_CI_CTL) ? "ctl" : "mem", |
219 | (read) ? mem : data); | 225 | (read) ? mem : data); |
220 | 226 | ||
@@ -283,14 +289,39 @@ int netup_ci_slot_shutdown(struct dvb_ca_en50221 *en50221, int slot) | |||
283 | return 0; | 289 | return 0; |
284 | } | 290 | } |
285 | 291 | ||
292 | int netup_ci_set_irq(struct dvb_ca_en50221 *en50221, u8 irq_mode) | ||
293 | { | ||
294 | struct netup_ci_state *state = en50221->data; | ||
295 | int ret; | ||
296 | |||
297 | if (irq_mode == state->current_irq_mode) | ||
298 | return 0; | ||
299 | |||
300 | ci_dbg_print("%s: chipaddr=[0x%x] setting ci IRQ to [0x%x] \n", | ||
301 | __func__, state->ci_i2c_addr, irq_mode); | ||
302 | ret = netup_write_i2c(state->i2c_adap, state->ci_i2c_addr, | ||
303 | 0x1b, &irq_mode, 1); | ||
304 | |||
305 | if (ret != 0) | ||
306 | return ret; | ||
307 | |||
308 | state->current_irq_mode = irq_mode; | ||
309 | |||
310 | return 0; | ||
311 | } | ||
312 | |||
286 | int netup_ci_slot_ts_ctl(struct dvb_ca_en50221 *en50221, int slot) | 313 | int netup_ci_slot_ts_ctl(struct dvb_ca_en50221 *en50221, int slot) |
287 | { | 314 | { |
288 | struct netup_ci_state *state = en50221->data; | 315 | struct netup_ci_state *state = en50221->data; |
289 | u8 buf = 0x60; | 316 | u8 buf; |
290 | 317 | ||
291 | if (0 != slot) | 318 | if (0 != slot) |
292 | return -EINVAL; | 319 | return -EINVAL; |
293 | 320 | ||
321 | netup_read_i2c(state->i2c_adap, state->ci_i2c_addr, | ||
322 | 0, &buf, 1); | ||
323 | buf |= 0x60; | ||
324 | |||
294 | return netup_write_i2c(state->i2c_adap, state->ci_i2c_addr, | 325 | return netup_write_i2c(state->i2c_adap, state->ci_i2c_addr, |
295 | 0, &buf, 1); | 326 | 0, &buf, 1); |
296 | } | 327 | } |
@@ -303,21 +334,35 @@ static void netup_read_ci_status(struct work_struct *work) | |||
303 | u8 buf[33]; | 334 | u8 buf[33]; |
304 | int ret; | 335 | int ret; |
305 | 336 | ||
306 | ret = netup_read_i2c(state->i2c_adap, state->ci_i2c_addr, | 337 | /* CAM module IRQ processing. fast operation */ |
307 | 0, &buf[0], 33); | 338 | dvb_ca_en50221_frda_irq(&state->ca, 0); |
308 | 339 | ||
309 | if (ret != 0) | 340 | /* CAM module INSERT/REMOVE processing. slow operation because of i2c |
310 | return; | 341 | * transfers */ |
342 | if (time_after(jiffies, state->next_status_checked_time) | ||
343 | || !state->status) { | ||
344 | ret = netup_read_i2c(state->i2c_adap, state->ci_i2c_addr, | ||
345 | 0, &buf[0], 33); | ||
346 | |||
347 | state->next_status_checked_time = jiffies | ||
348 | + msecs_to_jiffies(1000); | ||
349 | |||
350 | if (ret != 0) | ||
351 | return; | ||
311 | 352 | ||
312 | ci_dbg_print("%s: Slot Status Addr=[0x%04x], Reg=[0x%02x], data=%02x, " | 353 | ci_dbg_print("%s: Slot Status Addr=[0x%04x], " |
313 | "TS config = %02x\n", __func__, state->ci_i2c_addr, 0, buf[0], | 354 | "Reg=[0x%02x], data=%02x, " |
314 | buf[32]); | 355 | "TS config = %02x\n", __func__, |
356 | state->ci_i2c_addr, 0, buf[0], | ||
357 | buf[0]); | ||
315 | 358 | ||
316 | if (buf[0] & 1) | 359 | |
317 | state->status = DVB_CA_EN50221_POLL_CAM_PRESENT | | 360 | if (buf[0] & 1) |
318 | DVB_CA_EN50221_POLL_CAM_READY; | 361 | state->status = DVB_CA_EN50221_POLL_CAM_PRESENT | |
319 | else | 362 | DVB_CA_EN50221_POLL_CAM_READY; |
320 | state->status = 0; | 363 | else |
364 | state->status = 0; | ||
365 | }; | ||
321 | } | 366 | } |
322 | 367 | ||
323 | /* CI irq handler */ | 368 | /* CI irq handler */ |
@@ -347,6 +392,9 @@ int netup_poll_ci_slot_status(struct dvb_ca_en50221 *en50221, int slot, int open | |||
347 | if (0 != slot) | 392 | if (0 != slot) |
348 | return -EINVAL; | 393 | return -EINVAL; |
349 | 394 | ||
395 | netup_ci_set_irq(en50221, open ? (NETUP_IRQ_DETAM | NETUP_IRQ_IRQAM) | ||
396 | : NETUP_IRQ_DETAM); | ||
397 | |||
350 | return state->status; | 398 | return state->status; |
351 | } | 399 | } |
352 | 400 | ||
@@ -381,8 +429,8 @@ int netup_ci_init(struct cx23885_tsport *port) | |||
381 | 0x01, /* power on (use it like store place) */ | 429 | 0x01, /* power on (use it like store place) */ |
382 | 0x00, /* RFU */ | 430 | 0x00, /* RFU */ |
383 | 0x00, /* int status read only */ | 431 | 0x00, /* int status read only */ |
384 | 0x01, /* all int unmasked */ | 432 | NETUP_IRQ_IRQAM | NETUP_IRQ_DETAM, /* DETAM, IRQAM unmasked */ |
385 | 0x04, /* int config */ | 433 | 0x05, /* EXTINT=active-high, INT=push-pull */ |
386 | 0x00, /* USCG1 */ | 434 | 0x00, /* USCG1 */ |
387 | 0x04, /* ack active low */ | 435 | 0x04, /* ack active low */ |
388 | 0x00, /* LOCK = 0 */ | 436 | 0x00, /* LOCK = 0 */ |
@@ -422,6 +470,7 @@ int netup_ci_init(struct cx23885_tsport *port) | |||
422 | state->ca.poll_slot_status = netup_poll_ci_slot_status; | 470 | state->ca.poll_slot_status = netup_poll_ci_slot_status; |
423 | state->ca.data = state; | 471 | state->ca.data = state; |
424 | state->priv = port; | 472 | state->priv = port; |
473 | state->current_irq_mode = NETUP_IRQ_IRQAM | NETUP_IRQ_DETAM; | ||
425 | 474 | ||
426 | ret = netup_write_i2c(state->i2c_adap, state->ci_i2c_addr, | 475 | ret = netup_write_i2c(state->i2c_adap, state->ci_i2c_addr, |
427 | 0, &cimax_init[0], 34); | 476 | 0, &cimax_init[0], 34); |