1 // SPDX-License-Identifier: GPL-2.0-or-later
3 cx231xx-cards.c - driver for Conexant Cx23100/101/102
4 USB video capture devices
6 Copyright (C) 2008 <srinivasa.deevi at conexant dot com>
12 #include <linux/init.h>
13 #include <linux/module.h>
14 #include <linux/slab.h>
15 #include <linux/delay.h>
16 #include <linux/i2c.h>
17 #include <media/tuner.h>
18 #include <media/tveeprom.h>
19 #include <media/v4l2-common.h>
21 #include <media/drv-intf/cx25840.h>
22 #include <media/dvb-usb-ids.h>
27 static int tuner
= -1;
28 module_param(tuner
, int, 0444);
29 MODULE_PARM_DESC(tuner
, "tuner type");
31 static int transfer_mode
= 1;
32 module_param(transfer_mode
, int, 0444);
33 MODULE_PARM_DESC(transfer_mode
, "transfer mode (1-ISO or 0-BULK)");
35 static unsigned int disable_ir
;
36 module_param(disable_ir
, int, 0444);
37 MODULE_PARM_DESC(disable_ir
, "disable infrared remote support");
39 /* Bitmask marking allocated devices from 0 to CX231XX_MAXBOARDS */
40 static unsigned long cx231xx_devused
;
43 * Reset sequences for analog/digital modes
46 static struct cx231xx_reg_seq RDE250_XCV_TUNER
[] = {
56 struct cx231xx_board cx231xx_boards
[] = {
57 [CX231XX_BOARD_UNKNOWN
] = {
58 .name
= "Unknown CX231xx video grabber",
59 .tuner_type
= TUNER_ABSENT
,
61 .type
= CX231XX_VMUX_TELEVISION
,
62 .vmux
= CX231XX_VIN_3_1
,
63 .amux
= CX231XX_AMUX_VIDEO
,
66 .type
= CX231XX_VMUX_COMPOSITE1
,
67 .vmux
= CX231XX_VIN_2_1
,
68 .amux
= CX231XX_AMUX_LINE_IN
,
71 .type
= CX231XX_VMUX_SVIDEO
,
72 .vmux
= CX231XX_VIN_1_1
|
73 (CX231XX_VIN_1_2
<< 8) |
75 .amux
= CX231XX_AMUX_LINE_IN
,
80 [CX231XX_BOARD_CNXT_CARRAERA
] = {
81 .name
= "Conexant Hybrid TV - CARRAERA",
82 .tuner_type
= TUNER_XC5000
,
84 .tuner_gpio
= RDE250_XCV_TUNER
,
85 .tuner_sif_gpio
= 0x05,
86 .tuner_scl_gpio
= 0x1a,
87 .tuner_sda_gpio
= 0x1b,
88 .decoder
= CX231XX_AVDECODER
,
89 .output_mode
= OUT_MODE_VIP11
,
91 .ctl_pin_status_mask
= 0xFFFFFFC4,
92 .agc_analog_digital_select_gpio
= 0x0c,
93 .gpio_pin_status_mask
= 0x4001000,
94 .tuner_i2c_master
= I2C_1_MUX_3
,
95 .demod_i2c_master
= I2C_2
,
101 .type
= CX231XX_VMUX_TELEVISION
,
102 .vmux
= CX231XX_VIN_3_1
,
103 .amux
= CX231XX_AMUX_VIDEO
,
106 .type
= CX231XX_VMUX_COMPOSITE1
,
107 .vmux
= CX231XX_VIN_2_1
,
108 .amux
= CX231XX_AMUX_LINE_IN
,
111 .type
= CX231XX_VMUX_SVIDEO
,
112 .vmux
= CX231XX_VIN_1_1
|
113 (CX231XX_VIN_1_2
<< 8) |
115 .amux
= CX231XX_AMUX_LINE_IN
,
120 [CX231XX_BOARD_CNXT_SHELBY
] = {
121 .name
= "Conexant Hybrid TV - SHELBY",
122 .tuner_type
= TUNER_XC5000
,
124 .tuner_gpio
= RDE250_XCV_TUNER
,
125 .tuner_sif_gpio
= 0x05,
126 .tuner_scl_gpio
= 0x1a,
127 .tuner_sda_gpio
= 0x1b,
128 .decoder
= CX231XX_AVDECODER
,
129 .output_mode
= OUT_MODE_VIP11
,
130 .demod_xfer_mode
= 0,
131 .ctl_pin_status_mask
= 0xFFFFFFC4,
132 .agc_analog_digital_select_gpio
= 0x0c,
133 .gpio_pin_status_mask
= 0x4001000,
134 .tuner_i2c_master
= I2C_1_MUX_3
,
135 .demod_i2c_master
= I2C_2
,
138 .norm
= V4L2_STD_NTSC
,
141 .type
= CX231XX_VMUX_TELEVISION
,
142 .vmux
= CX231XX_VIN_3_1
,
143 .amux
= CX231XX_AMUX_VIDEO
,
146 .type
= CX231XX_VMUX_COMPOSITE1
,
147 .vmux
= CX231XX_VIN_2_1
,
148 .amux
= CX231XX_AMUX_LINE_IN
,
151 .type
= CX231XX_VMUX_SVIDEO
,
152 .vmux
= CX231XX_VIN_1_1
|
153 (CX231XX_VIN_1_2
<< 8) |
155 .amux
= CX231XX_AMUX_LINE_IN
,
160 [CX231XX_BOARD_CNXT_RDE_253S
] = {
161 .name
= "Conexant Hybrid TV - RDE253S",
162 .tuner_type
= TUNER_NXP_TDA18271
,
164 .tuner_gpio
= RDE250_XCV_TUNER
,
165 .tuner_sif_gpio
= 0x05,
166 .tuner_scl_gpio
= 0x1a,
167 .tuner_sda_gpio
= 0x1b,
168 .decoder
= CX231XX_AVDECODER
,
169 .output_mode
= OUT_MODE_VIP11
,
170 .demod_xfer_mode
= 0,
171 .ctl_pin_status_mask
= 0xFFFFFFC4,
172 .agc_analog_digital_select_gpio
= 0x1c,
173 .gpio_pin_status_mask
= 0x4001000,
174 .tuner_i2c_master
= I2C_1_MUX_3
,
175 .demod_i2c_master
= I2C_2
,
178 .norm
= V4L2_STD_PAL
,
181 .type
= CX231XX_VMUX_TELEVISION
,
182 .vmux
= CX231XX_VIN_3_1
,
183 .amux
= CX231XX_AMUX_VIDEO
,
186 .type
= CX231XX_VMUX_COMPOSITE1
,
187 .vmux
= CX231XX_VIN_2_1
,
188 .amux
= CX231XX_AMUX_LINE_IN
,
191 .type
= CX231XX_VMUX_SVIDEO
,
192 .vmux
= CX231XX_VIN_1_1
|
193 (CX231XX_VIN_1_2
<< 8) |
195 .amux
= CX231XX_AMUX_LINE_IN
,
201 [CX231XX_BOARD_CNXT_RDU_253S
] = {
202 .name
= "Conexant Hybrid TV - RDU253S",
203 .tuner_type
= TUNER_NXP_TDA18271
,
205 .tuner_gpio
= RDE250_XCV_TUNER
,
206 .tuner_sif_gpio
= 0x05,
207 .tuner_scl_gpio
= 0x1a,
208 .tuner_sda_gpio
= 0x1b,
209 .decoder
= CX231XX_AVDECODER
,
210 .output_mode
= OUT_MODE_VIP11
,
211 .demod_xfer_mode
= 0,
212 .ctl_pin_status_mask
= 0xFFFFFFC4,
213 .agc_analog_digital_select_gpio
= 0x1c,
214 .gpio_pin_status_mask
= 0x4001000,
215 .tuner_i2c_master
= I2C_1_MUX_3
,
216 .demod_i2c_master
= I2C_2
,
219 .norm
= V4L2_STD_PAL
,
222 .type
= CX231XX_VMUX_TELEVISION
,
223 .vmux
= CX231XX_VIN_3_1
,
224 .amux
= CX231XX_AMUX_VIDEO
,
227 .type
= CX231XX_VMUX_COMPOSITE1
,
228 .vmux
= CX231XX_VIN_2_1
,
229 .amux
= CX231XX_AMUX_LINE_IN
,
232 .type
= CX231XX_VMUX_SVIDEO
,
233 .vmux
= CX231XX_VIN_1_1
|
234 (CX231XX_VIN_1_2
<< 8) |
236 .amux
= CX231XX_AMUX_LINE_IN
,
241 [CX231XX_BOARD_CNXT_VIDEO_GRABBER
] = {
242 .name
= "Conexant VIDEO GRABBER",
243 .tuner_type
= TUNER_ABSENT
,
244 .decoder
= CX231XX_AVDECODER
,
245 .output_mode
= OUT_MODE_VIP11
,
246 .ctl_pin_status_mask
= 0xFFFFFFC4,
247 .agc_analog_digital_select_gpio
= 0x1c,
248 .gpio_pin_status_mask
= 0x4001000,
249 .norm
= V4L2_STD_PAL
,
252 /* Actually, it has a 417, but it isn't working correctly.
253 * So set to 0 for now until someone can manage to get this
254 * to work reliably. */
258 .type
= CX231XX_VMUX_COMPOSITE1
,
259 .vmux
= CX231XX_VIN_2_1
,
260 .amux
= CX231XX_AMUX_LINE_IN
,
263 .type
= CX231XX_VMUX_SVIDEO
,
264 .vmux
= CX231XX_VIN_1_1
|
265 (CX231XX_VIN_1_2
<< 8) |
267 .amux
= CX231XX_AMUX_LINE_IN
,
272 [CX231XX_BOARD_CNXT_RDE_250
] = {
273 .name
= "Conexant Hybrid TV - rde 250",
274 .tuner_type
= TUNER_XC5000
,
276 .tuner_gpio
= RDE250_XCV_TUNER
,
277 .tuner_sif_gpio
= 0x05,
278 .tuner_scl_gpio
= 0x1a,
279 .tuner_sda_gpio
= 0x1b,
280 .decoder
= CX231XX_AVDECODER
,
281 .output_mode
= OUT_MODE_VIP11
,
282 .demod_xfer_mode
= 0,
283 .ctl_pin_status_mask
= 0xFFFFFFC4,
284 .agc_analog_digital_select_gpio
= 0x0c,
285 .gpio_pin_status_mask
= 0x4001000,
286 .tuner_i2c_master
= I2C_1_MUX_3
,
287 .demod_i2c_master
= I2C_2
,
290 .norm
= V4L2_STD_PAL
,
293 .type
= CX231XX_VMUX_TELEVISION
,
294 .vmux
= CX231XX_VIN_2_1
,
295 .amux
= CX231XX_AMUX_VIDEO
,
300 [CX231XX_BOARD_CNXT_RDU_250
] = {
301 .name
= "Conexant Hybrid TV - RDU 250",
302 .tuner_type
= TUNER_XC5000
,
304 .tuner_gpio
= RDE250_XCV_TUNER
,
305 .tuner_sif_gpio
= 0x05,
306 .tuner_scl_gpio
= 0x1a,
307 .tuner_sda_gpio
= 0x1b,
308 .decoder
= CX231XX_AVDECODER
,
309 .output_mode
= OUT_MODE_VIP11
,
310 .demod_xfer_mode
= 0,
311 .ctl_pin_status_mask
= 0xFFFFFFC4,
312 .agc_analog_digital_select_gpio
= 0x0c,
313 .gpio_pin_status_mask
= 0x4001000,
314 .tuner_i2c_master
= I2C_1_MUX_3
,
315 .demod_i2c_master
= I2C_2
,
318 .norm
= V4L2_STD_NTSC
,
321 .type
= CX231XX_VMUX_TELEVISION
,
322 .vmux
= CX231XX_VIN_2_1
,
323 .amux
= CX231XX_AMUX_VIDEO
,
328 [CX231XX_BOARD_HAUPPAUGE_EXETER
] = {
329 .name
= "Hauppauge EXETER",
330 .tuner_type
= TUNER_NXP_TDA18271
,
332 .tuner_gpio
= RDE250_XCV_TUNER
,
333 .tuner_sif_gpio
= 0x05,
334 .tuner_scl_gpio
= 0x1a,
335 .tuner_sda_gpio
= 0x1b,
336 .decoder
= CX231XX_AVDECODER
,
337 .output_mode
= OUT_MODE_VIP11
,
338 .demod_xfer_mode
= 0,
339 .ctl_pin_status_mask
= 0xFFFFFFC4,
340 .agc_analog_digital_select_gpio
= 0x0c,
341 .gpio_pin_status_mask
= 0x4001000,
342 .tuner_i2c_master
= I2C_1_MUX_1
,
343 .demod_i2c_master
= I2C_1_MUX_1
,
346 .norm
= V4L2_STD_NTSC
,
349 .type
= CX231XX_VMUX_TELEVISION
,
350 .vmux
= CX231XX_VIN_3_1
,
351 .amux
= CX231XX_AMUX_VIDEO
,
354 .type
= CX231XX_VMUX_COMPOSITE1
,
355 .vmux
= CX231XX_VIN_2_1
,
356 .amux
= CX231XX_AMUX_LINE_IN
,
359 .type
= CX231XX_VMUX_SVIDEO
,
360 .vmux
= CX231XX_VIN_1_1
|
361 (CX231XX_VIN_1_2
<< 8) |
363 .amux
= CX231XX_AMUX_LINE_IN
,
367 [CX231XX_BOARD_HAUPPAUGE_USBLIVE2
] = {
368 .name
= "Hauppauge USB Live 2",
369 .tuner_type
= TUNER_ABSENT
,
370 .decoder
= CX231XX_AVDECODER
,
371 .output_mode
= OUT_MODE_VIP11
,
372 .demod_xfer_mode
= 0,
373 .ctl_pin_status_mask
= 0xFFFFFFC4,
374 .agc_analog_digital_select_gpio
= 0x0c,
375 .gpio_pin_status_mask
= 0x4001000,
376 .norm
= V4L2_STD_NTSC
,
380 .type
= CX231XX_VMUX_COMPOSITE1
,
381 .vmux
= CX231XX_VIN_2_1
,
382 .amux
= CX231XX_AMUX_LINE_IN
,
385 .type
= CX231XX_VMUX_SVIDEO
,
386 .vmux
= CX231XX_VIN_1_1
|
387 (CX231XX_VIN_1_2
<< 8) |
389 .amux
= CX231XX_AMUX_LINE_IN
,
393 [CX231XX_BOARD_KWORLD_UB430_USB_HYBRID
] = {
394 .name
= "Kworld UB430 USB Hybrid",
395 .tuner_type
= TUNER_NXP_TDA18271
,
397 .decoder
= CX231XX_AVDECODER
,
398 .output_mode
= OUT_MODE_VIP11
,
399 .demod_xfer_mode
= 0,
400 .ctl_pin_status_mask
= 0xFFFFFFC4,
401 .agc_analog_digital_select_gpio
= 0x11, /* According with PV cxPolaris.inf file */
402 .tuner_sif_gpio
= -1,
403 .tuner_scl_gpio
= -1,
404 .tuner_sda_gpio
= -1,
405 .gpio_pin_status_mask
= 0x4001000,
406 .tuner_i2c_master
= I2C_2
,
407 .demod_i2c_master
= I2C_1_MUX_3
,
408 .ir_i2c_master
= I2C_2
,
411 .norm
= V4L2_STD_PAL_M
,
413 .type
= CX231XX_VMUX_TELEVISION
,
414 .vmux
= CX231XX_VIN_3_1
,
415 .amux
= CX231XX_AMUX_VIDEO
,
418 .type
= CX231XX_VMUX_COMPOSITE1
,
419 .vmux
= CX231XX_VIN_2_1
,
420 .amux
= CX231XX_AMUX_LINE_IN
,
423 .type
= CX231XX_VMUX_SVIDEO
,
424 .vmux
= CX231XX_VIN_1_1
|
425 (CX231XX_VIN_1_2
<< 8) |
427 .amux
= CX231XX_AMUX_LINE_IN
,
431 [CX231XX_BOARD_KWORLD_UB445_USB_HYBRID
] = {
432 .name
= "Kworld UB445 USB Hybrid",
433 .tuner_type
= TUNER_NXP_TDA18271
,
435 .decoder
= CX231XX_AVDECODER
,
436 .output_mode
= OUT_MODE_VIP11
,
437 .demod_xfer_mode
= 0,
438 .ctl_pin_status_mask
= 0xFFFFFFC4,
439 .agc_analog_digital_select_gpio
= 0x11, /* According with PV cxPolaris.inf file */
440 .tuner_sif_gpio
= -1,
441 .tuner_scl_gpio
= -1,
442 .tuner_sda_gpio
= -1,
443 .gpio_pin_status_mask
= 0x4001000,
444 .tuner_i2c_master
= I2C_2
,
445 .demod_i2c_master
= I2C_1_MUX_3
,
446 .ir_i2c_master
= I2C_2
,
449 .norm
= V4L2_STD_NTSC_M
,
451 .type
= CX231XX_VMUX_TELEVISION
,
452 .vmux
= CX231XX_VIN_3_1
,
453 .amux
= CX231XX_AMUX_VIDEO
,
456 .type
= CX231XX_VMUX_COMPOSITE1
,
457 .vmux
= CX231XX_VIN_2_1
,
458 .amux
= CX231XX_AMUX_LINE_IN
,
461 .type
= CX231XX_VMUX_SVIDEO
,
462 .vmux
= CX231XX_VIN_1_1
|
463 (CX231XX_VIN_1_2
<< 8) |
465 .amux
= CX231XX_AMUX_LINE_IN
,
469 [CX231XX_BOARD_PV_PLAYTV_USB_HYBRID
] = {
470 .name
= "Pixelview PlayTV USB Hybrid",
471 .tuner_type
= TUNER_NXP_TDA18271
,
473 .decoder
= CX231XX_AVDECODER
,
474 .output_mode
= OUT_MODE_VIP11
,
475 .demod_xfer_mode
= 0,
476 .ctl_pin_status_mask
= 0xFFFFFFC4,
477 .agc_analog_digital_select_gpio
= 0x1c,
478 .tuner_sif_gpio
= -1,
479 .tuner_scl_gpio
= -1,
480 .tuner_sda_gpio
= -1,
481 .gpio_pin_status_mask
= 0x4001000,
482 .tuner_i2c_master
= I2C_2
,
483 .demod_i2c_master
= I2C_1_MUX_3
,
484 .ir_i2c_master
= I2C_2
,
485 .rc_map_name
= RC_MAP_PIXELVIEW_002T
,
488 .norm
= V4L2_STD_PAL_M
,
490 .type
= CX231XX_VMUX_TELEVISION
,
491 .vmux
= CX231XX_VIN_3_1
,
492 .amux
= CX231XX_AMUX_VIDEO
,
495 .type
= CX231XX_VMUX_COMPOSITE1
,
496 .vmux
= CX231XX_VIN_2_1
,
497 .amux
= CX231XX_AMUX_LINE_IN
,
500 .type
= CX231XX_VMUX_SVIDEO
,
501 .vmux
= CX231XX_VIN_1_1
|
502 (CX231XX_VIN_1_2
<< 8) |
504 .amux
= CX231XX_AMUX_LINE_IN
,
508 [CX231XX_BOARD_PV_XCAPTURE_USB
] = {
509 .name
= "Pixelview Xcapture USB",
510 .tuner_type
= TUNER_ABSENT
,
511 .decoder
= CX231XX_AVDECODER
,
512 .output_mode
= OUT_MODE_VIP11
,
513 .demod_xfer_mode
= 0,
514 .ctl_pin_status_mask
= 0xFFFFFFC4,
515 .agc_analog_digital_select_gpio
= 0x0c,
516 .gpio_pin_status_mask
= 0x4001000,
517 .norm
= V4L2_STD_NTSC
,
522 .type
= CX231XX_VMUX_COMPOSITE1
,
523 .vmux
= CX231XX_VIN_2_1
,
524 .amux
= CX231XX_AMUX_LINE_IN
,
527 .type
= CX231XX_VMUX_SVIDEO
,
528 .vmux
= CX231XX_VIN_1_1
|
529 (CX231XX_VIN_1_2
<< 8) |
531 .amux
= CX231XX_AMUX_LINE_IN
,
537 [CX231XX_BOARD_ICONBIT_U100
] = {
538 .name
= "Iconbit Analog Stick U100 FM",
539 .tuner_type
= TUNER_ABSENT
,
540 .decoder
= CX231XX_AVDECODER
,
541 .output_mode
= OUT_MODE_VIP11
,
542 .demod_xfer_mode
= 0,
543 .ctl_pin_status_mask
= 0xFFFFFFC4,
544 .agc_analog_digital_select_gpio
= 0x1C,
545 .gpio_pin_status_mask
= 0x4001000,
548 .type
= CX231XX_VMUX_COMPOSITE1
,
549 .vmux
= CX231XX_VIN_2_1
,
550 .amux
= CX231XX_AMUX_LINE_IN
,
553 .type
= CX231XX_VMUX_SVIDEO
,
554 .vmux
= CX231XX_VIN_1_1
|
555 (CX231XX_VIN_1_2
<< 8) |
557 .amux
= CX231XX_AMUX_LINE_IN
,
561 [CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL
] = {
562 .name
= "Hauppauge WinTV USB2 FM (PAL)",
563 .tuner_type
= TUNER_NXP_TDA18271
,
565 .tuner_gpio
= RDE250_XCV_TUNER
,
566 .tuner_sif_gpio
= 0x05,
567 .tuner_scl_gpio
= 0x1a,
568 .tuner_sda_gpio
= 0x1b,
569 .decoder
= CX231XX_AVDECODER
,
570 .output_mode
= OUT_MODE_VIP11
,
571 .ctl_pin_status_mask
= 0xFFFFFFC4,
572 .agc_analog_digital_select_gpio
= 0x0c,
573 .gpio_pin_status_mask
= 0x4001000,
574 .tuner_i2c_master
= I2C_1_MUX_3
,
575 .norm
= V4L2_STD_PAL
,
578 .type
= CX231XX_VMUX_TELEVISION
,
579 .vmux
= CX231XX_VIN_3_1
,
580 .amux
= CX231XX_AMUX_VIDEO
,
583 .type
= CX231XX_VMUX_COMPOSITE1
,
584 .vmux
= CX231XX_VIN_2_1
,
585 .amux
= CX231XX_AMUX_LINE_IN
,
588 .type
= CX231XX_VMUX_SVIDEO
,
589 .vmux
= CX231XX_VIN_1_1
|
590 (CX231XX_VIN_1_2
<< 8) |
592 .amux
= CX231XX_AMUX_LINE_IN
,
596 [CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC
] = {
597 .name
= "Hauppauge WinTV USB2 FM (NTSC)",
598 .tuner_type
= TUNER_NXP_TDA18271
,
600 .tuner_gpio
= RDE250_XCV_TUNER
,
601 .tuner_sif_gpio
= 0x05,
602 .tuner_scl_gpio
= 0x1a,
603 .tuner_sda_gpio
= 0x1b,
604 .decoder
= CX231XX_AVDECODER
,
605 .output_mode
= OUT_MODE_VIP11
,
606 .ctl_pin_status_mask
= 0xFFFFFFC4,
607 .agc_analog_digital_select_gpio
= 0x0c,
608 .gpio_pin_status_mask
= 0x4001000,
609 .tuner_i2c_master
= I2C_1_MUX_3
,
610 .norm
= V4L2_STD_NTSC
,
613 .type
= CX231XX_VMUX_TELEVISION
,
614 .vmux
= CX231XX_VIN_3_1
,
615 .amux
= CX231XX_AMUX_VIDEO
,
618 .type
= CX231XX_VMUX_COMPOSITE1
,
619 .vmux
= CX231XX_VIN_2_1
,
620 .amux
= CX231XX_AMUX_LINE_IN
,
623 .type
= CX231XX_VMUX_SVIDEO
,
624 .vmux
= CX231XX_VIN_1_1
|
625 (CX231XX_VIN_1_2
<< 8) |
627 .amux
= CX231XX_AMUX_LINE_IN
,
631 [CX231XX_BOARD_ELGATO_VIDEO_CAPTURE_V2
] = {
632 .name
= "Elgato Video Capture V2",
633 .tuner_type
= TUNER_ABSENT
,
634 .decoder
= CX231XX_AVDECODER
,
635 .output_mode
= OUT_MODE_VIP11
,
636 .demod_xfer_mode
= 0,
637 .ctl_pin_status_mask
= 0xFFFFFFC4,
638 .agc_analog_digital_select_gpio
= 0x0c,
639 .gpio_pin_status_mask
= 0x4001000,
640 .norm
= V4L2_STD_NTSC
,
644 .type
= CX231XX_VMUX_COMPOSITE1
,
645 .vmux
= CX231XX_VIN_2_1
,
646 .amux
= CX231XX_AMUX_LINE_IN
,
649 .type
= CX231XX_VMUX_SVIDEO
,
650 .vmux
= CX231XX_VIN_1_1
|
651 (CX231XX_VIN_1_2
<< 8) |
653 .amux
= CX231XX_AMUX_LINE_IN
,
657 [CX231XX_BOARD_OTG102
] = {
658 .name
= "Geniatech OTG102",
659 .tuner_type
= TUNER_ABSENT
,
660 .decoder
= CX231XX_AVDECODER
,
661 .output_mode
= OUT_MODE_VIP11
,
662 .ctl_pin_status_mask
= 0xFFFFFFC4,
663 .agc_analog_digital_select_gpio
= 0x0c,
664 /* According with PV CxPlrCAP.inf file */
665 .gpio_pin_status_mask
= 0x4001000,
666 .norm
= V4L2_STD_NTSC
,
670 /* This board is believed to have a hardware encoding chip
671 * supporting mpeg1/2/4, but as the 417 is apparently not
672 * working for the reference board it is not here either. */
675 .type
= CX231XX_VMUX_COMPOSITE1
,
676 .vmux
= CX231XX_VIN_2_1
,
677 .amux
= CX231XX_AMUX_LINE_IN
,
680 .type
= CX231XX_VMUX_SVIDEO
,
681 .vmux
= CX231XX_VIN_1_1
|
682 (CX231XX_VIN_1_2
<< 8) |
684 .amux
= CX231XX_AMUX_LINE_IN
,
689 [CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx
] = {
690 .name
= "Hauppauge WinTV 930C-HD (1113xx) / HVR-900H (111xxx) / PCTV QuatroStick 521e",
691 .tuner_type
= TUNER_NXP_TDA18271
,
693 .tuner_gpio
= RDE250_XCV_TUNER
,
694 .tuner_sif_gpio
= 0x05,
695 .tuner_scl_gpio
= 0x1a,
696 .tuner_sda_gpio
= 0x1b,
697 .decoder
= CX231XX_AVDECODER
,
698 .output_mode
= OUT_MODE_VIP11
,
699 .demod_xfer_mode
= 0,
700 .ctl_pin_status_mask
= 0xFFFFFFC4,
701 .agc_analog_digital_select_gpio
= 0x0c,
702 .gpio_pin_status_mask
= 0x4001000,
703 .tuner_i2c_master
= I2C_1_MUX_3
,
704 .demod_i2c_master
= I2C_1_MUX_3
,
706 .demod_addr
= 0x64, /* 0xc8 >> 1 */
707 .norm
= V4L2_STD_PAL
,
710 .type
= CX231XX_VMUX_TELEVISION
,
711 .vmux
= CX231XX_VIN_3_1
,
712 .amux
= CX231XX_AMUX_VIDEO
,
715 .type
= CX231XX_VMUX_COMPOSITE1
,
716 .vmux
= CX231XX_VIN_2_1
,
717 .amux
= CX231XX_AMUX_LINE_IN
,
720 .type
= CX231XX_VMUX_SVIDEO
,
721 .vmux
= CX231XX_VIN_1_1
|
722 (CX231XX_VIN_1_2
<< 8) |
724 .amux
= CX231XX_AMUX_LINE_IN
,
728 [CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx
] = {
729 .name
= "Hauppauge WinTV 930C-HD (1114xx) / HVR-901H (1114xx) / PCTV QuatroStick 522e",
730 .tuner_type
= TUNER_ABSENT
,
732 .tuner_gpio
= RDE250_XCV_TUNER
,
733 .tuner_sif_gpio
= 0x05,
734 .tuner_scl_gpio
= 0x1a,
735 .tuner_sda_gpio
= 0x1b,
736 .decoder
= CX231XX_AVDECODER
,
737 .output_mode
= OUT_MODE_VIP11
,
738 .demod_xfer_mode
= 0,
739 .ctl_pin_status_mask
= 0xFFFFFFC4,
740 .agc_analog_digital_select_gpio
= 0x0c,
741 .gpio_pin_status_mask
= 0x4001000,
742 .tuner_i2c_master
= I2C_1_MUX_3
,
743 .demod_i2c_master
= I2C_1_MUX_3
,
745 .demod_addr
= 0x64, /* 0xc8 >> 1 */
746 .norm
= V4L2_STD_PAL
,
749 .type
= CX231XX_VMUX_TELEVISION
,
750 .vmux
= CX231XX_VIN_3_1
,
751 .amux
= CX231XX_AMUX_VIDEO
,
754 .type
= CX231XX_VMUX_COMPOSITE1
,
755 .vmux
= CX231XX_VIN_2_1
,
756 .amux
= CX231XX_AMUX_LINE_IN
,
759 .type
= CX231XX_VMUX_SVIDEO
,
760 .vmux
= CX231XX_VIN_1_1
|
761 (CX231XX_VIN_1_2
<< 8) |
763 .amux
= CX231XX_AMUX_LINE_IN
,
767 [CX231XX_BOARD_HAUPPAUGE_955Q
] = {
768 .name
= "Hauppauge WinTV-HVR-955Q (111401)",
769 .tuner_type
= TUNER_ABSENT
,
771 .tuner_gpio
= RDE250_XCV_TUNER
,
772 .tuner_sif_gpio
= 0x05,
773 .tuner_scl_gpio
= 0x1a,
774 .tuner_sda_gpio
= 0x1b,
775 .decoder
= CX231XX_AVDECODER
,
776 .output_mode
= OUT_MODE_VIP11
,
777 .demod_xfer_mode
= 0,
778 .ctl_pin_status_mask
= 0xFFFFFFC4,
779 .agc_analog_digital_select_gpio
= 0x0c,
780 .gpio_pin_status_mask
= 0x4001000,
781 .tuner_i2c_master
= I2C_1_MUX_3
,
782 .demod_i2c_master
= I2C_1_MUX_3
,
784 .demod_addr
= 0x59, /* 0xb2 >> 1 */
785 .norm
= V4L2_STD_NTSC
,
788 .type
= CX231XX_VMUX_TELEVISION
,
789 .vmux
= CX231XX_VIN_3_1
,
790 .amux
= CX231XX_AMUX_VIDEO
,
793 .type
= CX231XX_VMUX_COMPOSITE1
,
794 .vmux
= CX231XX_VIN_2_1
,
795 .amux
= CX231XX_AMUX_LINE_IN
,
798 .type
= CX231XX_VMUX_SVIDEO
,
799 .vmux
= CX231XX_VIN_1_1
|
800 (CX231XX_VIN_1_2
<< 8) |
802 .amux
= CX231XX_AMUX_LINE_IN
,
806 [CX231XX_BOARD_TERRATEC_GRABBY
] = {
807 .name
= "Terratec Grabby",
808 .tuner_type
= TUNER_ABSENT
,
809 .decoder
= CX231XX_AVDECODER
,
810 .output_mode
= OUT_MODE_VIP11
,
811 .demod_xfer_mode
= 0,
812 .ctl_pin_status_mask
= 0xFFFFFFC4,
813 .agc_analog_digital_select_gpio
= 0x0c,
814 .gpio_pin_status_mask
= 0x4001000,
815 .norm
= V4L2_STD_PAL
,
819 .type
= CX231XX_VMUX_COMPOSITE1
,
820 .vmux
= CX231XX_VIN_2_1
,
821 .amux
= CX231XX_AMUX_LINE_IN
,
824 .type
= CX231XX_VMUX_SVIDEO
,
825 .vmux
= CX231XX_VIN_1_1
|
826 (CX231XX_VIN_1_2
<< 8) |
828 .amux
= CX231XX_AMUX_LINE_IN
,
832 [CX231XX_BOARD_EVROMEDIA_FULL_HYBRID_FULLHD
] = {
833 .name
= "Evromedia USB Full Hybrid Full HD",
834 .tuner_type
= TUNER_ABSENT
,
835 .demod_addr
= 0x64, /* 0xc8 >> 1 */
836 .demod_i2c_master
= I2C_1_MUX_3
,
838 .decoder
= CX231XX_AVDECODER
,
839 .norm
= V4L2_STD_PAL
,
840 .output_mode
= OUT_MODE_VIP11
,
841 .tuner_addr
= 0x60, /* 0xc0 >> 1 */
842 .tuner_i2c_master
= I2C_2
,
844 .type
= CX231XX_VMUX_TELEVISION
,
846 .amux
= CX231XX_AMUX_VIDEO
,
848 .type
= CX231XX_VMUX_COMPOSITE1
,
849 .vmux
= CX231XX_VIN_2_1
,
850 .amux
= CX231XX_AMUX_LINE_IN
,
852 .type
= CX231XX_VMUX_SVIDEO
,
853 .vmux
= CX231XX_VIN_1_1
|
854 (CX231XX_VIN_1_2
<< 8) |
856 .amux
= CX231XX_AMUX_LINE_IN
,
859 [CX231XX_BOARD_ASTROMETA_T2HYBRID
] = {
860 .name
= "Astrometa T2hybrid",
861 .tuner_type
= TUNER_ABSENT
,
863 .decoder
= CX231XX_AVDECODER
,
864 .output_mode
= OUT_MODE_VIP11
,
865 .agc_analog_digital_select_gpio
= 0x01,
866 .ctl_pin_status_mask
= 0xffffffc4,
867 .demod_addr
= 0x18, /* 0x30 >> 1 */
868 .demod_i2c_master
= I2C_1_MUX_1
,
869 .gpio_pin_status_mask
= 0xa,
870 .norm
= V4L2_STD_NTSC
,
871 .tuner_addr
= 0x3a, /* 0x74 >> 1 */
872 .tuner_i2c_master
= I2C_1_MUX_3
,
873 .tuner_scl_gpio
= 0x1a,
874 .tuner_sda_gpio
= 0x1b,
875 .tuner_sif_gpio
= 0x05,
877 .type
= CX231XX_VMUX_TELEVISION
,
878 .vmux
= CX231XX_VIN_1_1
,
879 .amux
= CX231XX_AMUX_VIDEO
,
881 .type
= CX231XX_VMUX_COMPOSITE1
,
882 .vmux
= CX231XX_VIN_2_1
,
883 .amux
= CX231XX_AMUX_LINE_IN
,
887 [CX231XX_BOARD_THE_IMAGING_SOURCE_DFG_USB2_PRO
] = {
888 .name
= "The Imaging Source DFG/USB2pro",
889 .tuner_type
= TUNER_ABSENT
,
890 .decoder
= CX231XX_AVDECODER
,
891 .output_mode
= OUT_MODE_VIP11
,
892 .demod_xfer_mode
= 0,
893 .ctl_pin_status_mask
= 0xFFFFFFC4,
894 .agc_analog_digital_select_gpio
= 0x0c,
895 .gpio_pin_status_mask
= 0x4001000,
896 .norm
= V4L2_STD_PAL
,
900 .type
= CX231XX_VMUX_COMPOSITE1
,
901 .vmux
= CX231XX_VIN_1_1
,
902 .amux
= CX231XX_AMUX_LINE_IN
,
905 .type
= CX231XX_VMUX_SVIDEO
,
906 .vmux
= CX231XX_VIN_2_1
|
907 (CX231XX_VIN_2_2
<< 8) |
909 .amux
= CX231XX_AMUX_LINE_IN
,
913 [CX231XX_BOARD_HAUPPAUGE_935C
] = {
914 .name
= "Hauppauge WinTV-HVR-935C",
915 .tuner_type
= TUNER_ABSENT
,
917 .tuner_gpio
= RDE250_XCV_TUNER
,
918 .tuner_sif_gpio
= 0x05,
919 .tuner_scl_gpio
= 0x1a,
920 .tuner_sda_gpio
= 0x1b,
921 .decoder
= CX231XX_AVDECODER
,
922 .output_mode
= OUT_MODE_VIP11
,
923 .demod_xfer_mode
= 0,
924 .ctl_pin_status_mask
= 0xFFFFFFC4,
925 .agc_analog_digital_select_gpio
= 0x0c,
926 .gpio_pin_status_mask
= 0x4001000,
927 .tuner_i2c_master
= I2C_1_MUX_3
,
928 .demod_i2c_master
= I2C_1_MUX_3
,
930 .demod_addr
= 0x64, /* 0xc8 >> 1 */
931 .norm
= V4L2_STD_PAL
,
934 .type
= CX231XX_VMUX_TELEVISION
,
935 .vmux
= CX231XX_VIN_3_1
,
936 .amux
= CX231XX_AMUX_VIDEO
,
939 .type
= CX231XX_VMUX_COMPOSITE1
,
940 .vmux
= CX231XX_VIN_2_1
,
941 .amux
= CX231XX_AMUX_LINE_IN
,
944 .type
= CX231XX_VMUX_SVIDEO
,
945 .vmux
= CX231XX_VIN_1_1
|
946 (CX231XX_VIN_1_2
<< 8) |
948 .amux
= CX231XX_AMUX_LINE_IN
,
952 [CX231XX_BOARD_HAUPPAUGE_975
] = {
953 .name
= "Hauppauge WinTV-HVR-975",
954 .tuner_type
= TUNER_ABSENT
,
956 .tuner_gpio
= RDE250_XCV_TUNER
,
957 .tuner_sif_gpio
= 0x05,
958 .tuner_scl_gpio
= 0x1a,
959 .tuner_sda_gpio
= 0x1b,
960 .decoder
= CX231XX_AVDECODER
,
961 .output_mode
= OUT_MODE_VIP11
,
962 .demod_xfer_mode
= 0,
963 .ctl_pin_status_mask
= 0xFFFFFFC4,
964 .agc_analog_digital_select_gpio
= 0x0c,
965 .gpio_pin_status_mask
= 0x4001000,
966 .tuner_i2c_master
= I2C_1_MUX_3
,
967 .demod_i2c_master
= I2C_1_MUX_3
,
969 .demod_addr
= 0x59, /* 0xb2 >> 1 */
970 .demod_addr2
= 0x64, /* 0xc8 >> 1 */
971 .norm
= V4L2_STD_ALL
,
974 .type
= CX231XX_VMUX_TELEVISION
,
975 .vmux
= CX231XX_VIN_3_1
,
976 .amux
= CX231XX_AMUX_VIDEO
,
979 .type
= CX231XX_VMUX_COMPOSITE1
,
980 .vmux
= CX231XX_VIN_2_1
,
981 .amux
= CX231XX_AMUX_LINE_IN
,
984 .type
= CX231XX_VMUX_SVIDEO
,
985 .vmux
= CX231XX_VIN_1_1
|
986 (CX231XX_VIN_1_2
<< 8) |
988 .amux
= CX231XX_AMUX_LINE_IN
,
993 const unsigned int cx231xx_bcount
= ARRAY_SIZE(cx231xx_boards
);
995 /* table of devices that work with this driver */
996 struct usb_device_id cx231xx_id_table
[] = {
997 {USB_DEVICE(0x1D19, 0x6109),
998 .driver_info
= CX231XX_BOARD_PV_XCAPTURE_USB
},
999 {USB_DEVICE(0x0572, 0x5A3C),
1000 .driver_info
= CX231XX_BOARD_UNKNOWN
},
1001 {USB_DEVICE(0x0572, 0x58A2),
1002 .driver_info
= CX231XX_BOARD_CNXT_CARRAERA
},
1003 {USB_DEVICE(0x0572, 0x58A1),
1004 .driver_info
= CX231XX_BOARD_CNXT_SHELBY
},
1005 {USB_DEVICE(0x0572, 0x58A4),
1006 .driver_info
= CX231XX_BOARD_CNXT_RDE_253S
},
1007 {USB_DEVICE(0x0572, 0x58A5),
1008 .driver_info
= CX231XX_BOARD_CNXT_RDU_253S
},
1009 {USB_DEVICE(0x0572, 0x58A6),
1010 .driver_info
= CX231XX_BOARD_CNXT_VIDEO_GRABBER
},
1011 {USB_DEVICE(0x0572, 0x589E),
1012 .driver_info
= CX231XX_BOARD_CNXT_RDE_250
},
1013 {USB_DEVICE(0x0572, 0x58A0),
1014 .driver_info
= CX231XX_BOARD_CNXT_RDU_250
},
1015 /* AverMedia DVD EZMaker 7 */
1016 {USB_DEVICE(0x07ca, 0xc039),
1017 .driver_info
= CX231XX_BOARD_CNXT_VIDEO_GRABBER
},
1018 {USB_DEVICE(0x2040, 0xb110),
1019 .driver_info
= CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL
},
1020 {USB_DEVICE(0x2040, 0xb111),
1021 .driver_info
= CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC
},
1022 {USB_DEVICE(0x2040, 0xb120),
1023 .driver_info
= CX231XX_BOARD_HAUPPAUGE_EXETER
},
1024 {USB_DEVICE(0x2040, 0xb123),
1025 .driver_info
= CX231XX_BOARD_HAUPPAUGE_955Q
},
1026 {USB_DEVICE(0x2040, 0xb124),
1027 .driver_info
= CX231XX_BOARD_HAUPPAUGE_955Q
},
1028 {USB_DEVICE(0x2040, 0xb151),
1029 .driver_info
= CX231XX_BOARD_HAUPPAUGE_935C
},
1030 {USB_DEVICE(0x2040, 0xb150),
1031 .driver_info
= CX231XX_BOARD_HAUPPAUGE_975
},
1032 {USB_DEVICE(0x2040, 0xb130),
1033 .driver_info
= CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx
},
1034 {USB_DEVICE(0x2040, 0xb131),
1035 .driver_info
= CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx
},
1036 /* Hauppauge WinTV-HVR-900-H */
1037 {USB_DEVICE(0x2040, 0xb138),
1038 .driver_info
= CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx
},
1039 /* Hauppauge WinTV-HVR-901-H */
1040 {USB_DEVICE(0x2040, 0xb139),
1041 .driver_info
= CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx
},
1042 {USB_DEVICE(0x2040, 0xb140),
1043 .driver_info
= CX231XX_BOARD_HAUPPAUGE_EXETER
},
1044 {USB_DEVICE(0x2040, 0xc200),
1045 .driver_info
= CX231XX_BOARD_HAUPPAUGE_USBLIVE2
},
1046 /* PCTV QuatroStick 521e */
1047 {USB_DEVICE(0x2013, 0x0259),
1048 .driver_info
= CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx
},
1049 /* PCTV QuatroStick 522e */
1050 {USB_DEVICE(0x2013, 0x025e),
1051 .driver_info
= CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx
},
1052 {USB_DEVICE_VER(USB_VID_PIXELVIEW
, USB_PID_PIXELVIEW_SBTVD
, 0x4000, 0x4001),
1053 .driver_info
= CX231XX_BOARD_PV_PLAYTV_USB_HYBRID
},
1054 {USB_DEVICE(USB_VID_PIXELVIEW
, 0x5014),
1055 .driver_info
= CX231XX_BOARD_PV_XCAPTURE_USB
},
1056 {USB_DEVICE(0x1b80, 0xe424),
1057 .driver_info
= CX231XX_BOARD_KWORLD_UB430_USB_HYBRID
},
1058 {USB_DEVICE(0x1b80, 0xe421),
1059 .driver_info
= CX231XX_BOARD_KWORLD_UB445_USB_HYBRID
},
1060 {USB_DEVICE(0x1f4d, 0x0237),
1061 .driver_info
= CX231XX_BOARD_ICONBIT_U100
},
1062 {USB_DEVICE(0x0fd9, 0x0037),
1063 .driver_info
= CX231XX_BOARD_ELGATO_VIDEO_CAPTURE_V2
},
1064 {USB_DEVICE(0x1f4d, 0x0102),
1065 .driver_info
= CX231XX_BOARD_OTG102
},
1066 {USB_DEVICE(USB_VID_TERRATEC
, 0x00a6),
1067 .driver_info
= CX231XX_BOARD_TERRATEC_GRABBY
},
1068 {USB_DEVICE(0x1b80, 0xd3b2),
1069 .driver_info
= CX231XX_BOARD_EVROMEDIA_FULL_HYBRID_FULLHD
},
1070 {USB_DEVICE(0x15f4, 0x0135),
1071 .driver_info
= CX231XX_BOARD_ASTROMETA_T2HYBRID
},
1072 {USB_DEVICE(0x199e, 0x8002),
1073 .driver_info
= CX231XX_BOARD_THE_IMAGING_SOURCE_DFG_USB2_PRO
},
1077 MODULE_DEVICE_TABLE(usb
, cx231xx_id_table
);
1079 /* cx231xx_tuner_callback
1080 * will be used to reset XC5000 tuner using GPIO pin
1083 int cx231xx_tuner_callback(void *ptr
, int component
, int command
, int arg
)
1086 struct cx231xx
*dev
= ptr
;
1088 if (dev
->tuner_type
== TUNER_XC5000
) {
1089 if (command
== XC5000_TUNER_RESET
) {
1091 "Tuner CB: RESET: cmd %d : tuner type %d\n",
1092 command
, dev
->tuner_type
);
1093 cx231xx_set_gpio_value(dev
, dev
->board
.tuner_gpio
->bit
,
1096 cx231xx_set_gpio_value(dev
, dev
->board
.tuner_gpio
->bit
,
1099 cx231xx_set_gpio_value(dev
, dev
->board
.tuner_gpio
->bit
,
1103 } else if (dev
->tuner_type
== TUNER_NXP_TDA18271
) {
1105 case TDA18271_CALLBACK_CMD_AGC_ENABLE
:
1106 if (dev
->model
== CX231XX_BOARD_PV_PLAYTV_USB_HYBRID
)
1107 rc
= cx231xx_set_agc_analog_digital_mux_select(dev
, arg
);
1116 EXPORT_SYMBOL_GPL(cx231xx_tuner_callback
);
1118 static void cx231xx_reset_out(struct cx231xx
*dev
)
1120 cx231xx_set_gpio_value(dev
, CX23417_RESET
, 1);
1122 cx231xx_set_gpio_value(dev
, CX23417_RESET
, 0);
1124 cx231xx_set_gpio_value(dev
, CX23417_RESET
, 1);
1127 static void cx231xx_enable_OSC(struct cx231xx
*dev
)
1129 cx231xx_set_gpio_value(dev
, CX23417_OSC_EN
, 1);
1132 static void cx231xx_sleep_s5h1432(struct cx231xx
*dev
)
1134 cx231xx_set_gpio_value(dev
, SLEEP_S5H1432
, 0);
1137 static inline void cx231xx_set_model(struct cx231xx
*dev
)
1139 dev
->board
= cx231xx_boards
[dev
->model
];
1142 /* Since cx231xx_pre_card_setup() requires a proper dev->model,
1143 * this won't work for boards with generic PCI IDs
1145 void cx231xx_pre_card_setup(struct cx231xx
*dev
)
1147 dev_info(dev
->dev
, "Identified as %s (card=%d)\n",
1148 dev
->board
.name
, dev
->model
);
1150 if (CX231XX_BOARD_ASTROMETA_T2HYBRID
== dev
->model
) {
1151 /* turn on demodulator chip */
1152 cx231xx_set_gpio_value(dev
, 0x03, 0x01);
1155 /* set the direction for GPIO pins */
1156 if (dev
->board
.tuner_gpio
) {
1157 cx231xx_set_gpio_direction(dev
, dev
->board
.tuner_gpio
->bit
, 1);
1158 cx231xx_set_gpio_value(dev
, dev
->board
.tuner_gpio
->bit
, 1);
1160 if (dev
->board
.tuner_sif_gpio
>= 0)
1161 cx231xx_set_gpio_direction(dev
, dev
->board
.tuner_sif_gpio
, 1);
1163 /* request some modules if any required */
1165 /* set the mode to Analog mode initially */
1166 cx231xx_set_mode(dev
, CX231XX_ANALOG_MODE
);
1169 /* cx231xx_set_mode(dev, CX231XX_SUSPEND); */
1173 static void cx231xx_config_tuner(struct cx231xx
*dev
)
1175 struct tuner_setup tun_setup
;
1176 struct v4l2_frequency f
;
1178 if (dev
->tuner_type
== TUNER_ABSENT
)
1181 tun_setup
.mode_mask
= T_ANALOG_TV
| T_RADIO
;
1182 tun_setup
.type
= dev
->tuner_type
;
1183 tun_setup
.addr
= dev
->tuner_addr
;
1184 tun_setup
.tuner_callback
= cx231xx_tuner_callback
;
1186 tuner_call(dev
, tuner
, s_type_addr
, &tun_setup
);
1189 if (tun_setup
.type
== TUNER_XC5000
) {
1190 static struct xc2028_ctrl ctrl
= {
1191 .fname
= XC5000_DEFAULT_FIRMWARE
,
1195 struct v4l2_priv_tun_config cfg
= {
1196 .tuner
= dev
->tuner_type
,
1199 tuner_call(dev
, tuner
, s_config
, &cfg
);
1202 /* configure tuner */
1204 f
.type
= V4L2_TUNER_ANALOG_TV
;
1205 f
.frequency
= 9076; /* just a magic number */
1206 dev
->ctl_freq
= f
.frequency
;
1207 call_all(dev
, tuner
, s_frequency
, &f
);
1211 static int read_eeprom(struct cx231xx
*dev
, struct i2c_client
*client
,
1212 u8
*eedata
, int len
)
1215 u8 start_offset
= 0;
1217 u8
*eedata_cur
= eedata
;
1219 struct i2c_msg msg_write
= { .addr
= client
->addr
, .flags
= 0,
1220 .buf
= &start_offset
, .len
= 1 };
1221 struct i2c_msg msg_read
= { .addr
= client
->addr
, .flags
= I2C_M_RD
};
1223 /* start reading at offset 0 */
1224 ret
= i2c_transfer(client
->adapter
, &msg_write
, 1);
1226 dev_err(dev
->dev
, "Can't read eeprom\n");
1230 while (len_todo
> 0) {
1231 msg_read
.len
= (len_todo
> 64) ? 64 : len_todo
;
1232 msg_read
.buf
= eedata_cur
;
1234 ret
= i2c_transfer(client
->adapter
, &msg_read
, 1);
1236 dev_err(dev
->dev
, "Can't read eeprom\n");
1239 eedata_cur
+= msg_read
.len
;
1240 len_todo
-= msg_read
.len
;
1243 for (i
= 0; i
+ 15 < len
; i
+= 16)
1244 dev_dbg(dev
->dev
, "i2c eeprom %02x: %*ph\n",
1250 void cx231xx_card_setup(struct cx231xx
*dev
)
1253 cx231xx_set_model(dev
);
1255 dev
->tuner_type
= cx231xx_boards
[dev
->model
].tuner_type
;
1256 if (cx231xx_boards
[dev
->model
].tuner_addr
)
1257 dev
->tuner_addr
= cx231xx_boards
[dev
->model
].tuner_addr
;
1259 /* request some modules */
1260 if (dev
->board
.decoder
== CX231XX_AVDECODER
) {
1261 dev
->sd_cx25840
= v4l2_i2c_new_subdev(&dev
->v4l2_dev
,
1262 cx231xx_get_i2c_adap(dev
, I2C_0
),
1263 "cx25840", 0x88 >> 1, NULL
);
1264 if (dev
->sd_cx25840
== NULL
)
1266 "cx25840 subdev registration failure\n");
1267 cx25840_call(dev
, core
, load_fw
);
1271 /* Initialize the tuner */
1272 if (dev
->board
.tuner_type
!= TUNER_ABSENT
) {
1273 struct i2c_adapter
*tuner_i2c
= cx231xx_get_i2c_adap(dev
,
1274 dev
->board
.tuner_i2c_master
);
1275 dev
->sd_tuner
= v4l2_i2c_new_subdev(&dev
->v4l2_dev
,
1278 dev
->tuner_addr
, NULL
);
1279 if (dev
->sd_tuner
== NULL
)
1281 "tuner subdev registration failure\n");
1283 cx231xx_config_tuner(dev
);
1286 switch (dev
->model
) {
1287 case CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx
:
1288 case CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx
:
1289 case CX231XX_BOARD_HAUPPAUGE_955Q
:
1290 case CX231XX_BOARD_HAUPPAUGE_935C
:
1291 case CX231XX_BOARD_HAUPPAUGE_975
:
1294 struct tveeprom tvee
;
1296 struct i2c_client client
;
1298 struct eeprom
*e
= kzalloc(sizeof(*e
), GFP_KERNEL
);
1302 "failed to allocate memory to read eeprom\n");
1305 e
->client
.adapter
= cx231xx_get_i2c_adap(dev
, I2C_1_MUX_1
);
1306 e
->client
.addr
= 0xa0 >> 1;
1308 read_eeprom(dev
, &e
->client
, e
->eeprom
, sizeof(e
->eeprom
));
1309 tveeprom_hauppauge_analog(&e
->tvee
, e
->eeprom
+ 0xc0);
1319 * inits registers with sane defaults
1321 int cx231xx_config(struct cx231xx
*dev
)
1323 /* TBD need to add cx231xx specific code */
1329 * cx231xx_config_i2c()
1330 * configure i2c attached devices
1332 void cx231xx_config_i2c(struct cx231xx
*dev
)
1334 /* u32 input = INPUT(dev->video_input)->vmux; */
1336 call_all(dev
, video
, s_stream
, 1);
1339 static void cx231xx_unregister_media_device(struct cx231xx
*dev
)
1341 #ifdef CONFIG_MEDIA_CONTROLLER
1342 if (dev
->media_dev
) {
1343 media_device_unregister(dev
->media_dev
);
1344 media_device_cleanup(dev
->media_dev
);
1345 kfree(dev
->media_dev
);
1346 dev
->media_dev
= NULL
;
1352 * cx231xx_realease_resources()
1353 * unregisters the v4l2,i2c and usb devices
1354 * called when the device gets disconnected or at module unload
1356 void cx231xx_release_resources(struct cx231xx
*dev
)
1358 cx231xx_ir_exit(dev
);
1360 cx231xx_release_analog_resources(dev
);
1362 cx231xx_remove_from_devlist(dev
);
1364 /* Release I2C buses */
1365 cx231xx_dev_uninit(dev
);
1367 /* delete v4l2 device */
1368 v4l2_device_unregister(&dev
->v4l2_dev
);
1370 cx231xx_unregister_media_device(dev
);
1372 usb_put_dev(dev
->udev
);
1374 /* Mark device as unused */
1375 clear_bit(dev
->devno
, &cx231xx_devused
);
1378 static int cx231xx_media_device_init(struct cx231xx
*dev
,
1379 struct usb_device
*udev
)
1381 #ifdef CONFIG_MEDIA_CONTROLLER
1382 struct media_device
*mdev
;
1384 mdev
= kzalloc(sizeof(*mdev
), GFP_KERNEL
);
1388 media_device_usb_init(mdev
, udev
, dev
->board
.name
);
1390 dev
->media_dev
= mdev
;
1396 * cx231xx_init_dev()
1397 * allocates and inits the device structs, registers i2c bus and v4l device
1399 static int cx231xx_init_dev(struct cx231xx
*dev
, struct usb_device
*udev
,
1402 int retval
= -ENOMEM
;
1403 unsigned int maxh
, maxw
;
1406 mutex_init(&dev
->lock
);
1407 mutex_init(&dev
->ctrl_urb_lock
);
1408 mutex_init(&dev
->gpio_i2c_lock
);
1409 mutex_init(&dev
->i2c_lock
);
1411 spin_lock_init(&dev
->video_mode
.slock
);
1412 spin_lock_init(&dev
->vbi_mode
.slock
);
1413 spin_lock_init(&dev
->sliced_cc_mode
.slock
);
1415 init_waitqueue_head(&dev
->open
);
1416 init_waitqueue_head(&dev
->wait_frame
);
1417 init_waitqueue_head(&dev
->wait_stream
);
1419 dev
->cx231xx_read_ctrl_reg
= cx231xx_read_ctrl_reg
;
1420 dev
->cx231xx_write_ctrl_reg
= cx231xx_write_ctrl_reg
;
1421 dev
->cx231xx_send_usb_command
= cx231xx_send_usb_command
;
1422 dev
->cx231xx_gpio_i2c_read
= cx231xx_gpio_i2c_read
;
1423 dev
->cx231xx_gpio_i2c_write
= cx231xx_gpio_i2c_write
;
1425 /* Query cx231xx to find what pcb config it is related to */
1426 retval
= initialize_cx231xx(dev
);
1428 dev_err(dev
->dev
, "Failed to read PCB config\n");
1432 /*To workaround error number=-71 on EP0 for VideoGrabber,
1433 need set alt here.*/
1434 if (dev
->model
== CX231XX_BOARD_CNXT_VIDEO_GRABBER
||
1435 dev
->model
== CX231XX_BOARD_HAUPPAUGE_USBLIVE2
) {
1436 cx231xx_set_alt_setting(dev
, INDEX_VIDEO
, 3);
1437 cx231xx_set_alt_setting(dev
, INDEX_VANC
, 1);
1439 /* Cx231xx pre card setup */
1440 cx231xx_pre_card_setup(dev
);
1442 retval
= cx231xx_config(dev
);
1444 dev_err(dev
->dev
, "error configuring device\n");
1448 /* set default norm */
1449 dev
->norm
= dev
->board
.norm
;
1451 /* register i2c bus */
1452 retval
= cx231xx_dev_init(dev
);
1455 "%s: cx231xx_i2c_register - errCode [%d]!\n",
1460 /* Do board specific init */
1461 cx231xx_card_setup(dev
);
1463 /* configure the device */
1464 cx231xx_config_i2c(dev
);
1466 maxw
= norm_maxw(dev
);
1467 maxh
= norm_maxh(dev
);
1469 /* set default image size */
1472 dev
->interlaced
= 0;
1473 dev
->video_input
= 0;
1475 retval
= cx231xx_config(dev
);
1477 dev_err(dev
->dev
, "%s: cx231xx_config - errCode [%d]!\n",
1482 /* init video dma queue */
1483 INIT_LIST_HEAD(&dev
->video_mode
.vidq
.active
);
1485 /* init vbi dma queue */
1486 INIT_LIST_HEAD(&dev
->vbi_mode
.vidq
.active
);
1488 /* Reset other chips required if they are tied up with GPIO pins */
1489 cx231xx_add_into_devlist(dev
);
1491 if (dev
->board
.has_417
) {
1492 dev_info(dev
->dev
, "attach 417 %d\n", dev
->model
);
1493 if (cx231xx_417_register(dev
) < 0) {
1495 "%s() Failed to register 417 on VID_B\n",
1500 retval
= cx231xx_register_analog_devices(dev
);
1504 cx231xx_ir_init(dev
);
1506 cx231xx_init_extension(dev
);
1510 cx231xx_unregister_media_device(dev
);
1511 cx231xx_release_analog_resources(dev
);
1512 cx231xx_remove_from_devlist(dev
);
1514 cx231xx_dev_uninit(dev
);
1518 #if defined(CONFIG_MODULES) && defined(MODULE)
1519 static void request_module_async(struct work_struct
*work
)
1521 struct cx231xx
*dev
= container_of(work
,
1522 struct cx231xx
, request_module_wk
);
1524 if (dev
->has_alsa_audio
)
1525 request_module("cx231xx-alsa");
1527 if (dev
->board
.has_dvb
)
1528 request_module("cx231xx-dvb");
1532 static void request_modules(struct cx231xx
*dev
)
1534 INIT_WORK(&dev
->request_module_wk
, request_module_async
);
1535 schedule_work(&dev
->request_module_wk
);
1538 static void flush_request_modules(struct cx231xx
*dev
)
1540 flush_work(&dev
->request_module_wk
);
1543 #define request_modules(dev)
1544 #define flush_request_modules(dev)
1545 #endif /* CONFIG_MODULES */
1547 static int cx231xx_init_v4l2(struct cx231xx
*dev
,
1548 struct usb_device
*udev
,
1549 struct usb_interface
*interface
,
1552 struct usb_interface
*uif
;
1557 /* compute alternate max packet sizes for video */
1558 idx
= dev
->current_pcb_config
.hs_config_info
[0].interface_info
.video_index
+ 1;
1559 if (idx
>= dev
->max_iad_interface_count
) {
1561 "Video PCB interface #%d doesn't exist\n", idx
);
1565 uif
= udev
->actconfig
->interface
[idx
];
1567 if (uif
->altsetting
[0].desc
.bNumEndpoints
< isoc_pipe
+ 1)
1570 dev
->video_mode
.end_point_addr
= uif
->altsetting
[0].endpoint
[isoc_pipe
].desc
.bEndpointAddress
;
1571 dev
->video_mode
.num_alt
= uif
->num_altsetting
;
1574 "video EndPoint Addr 0x%x, Alternate settings: %i\n",
1575 dev
->video_mode
.end_point_addr
,
1576 dev
->video_mode
.num_alt
);
1578 dev
->video_mode
.alt_max_pkt_size
= devm_kmalloc_array(&udev
->dev
, 32, dev
->video_mode
.num_alt
, GFP_KERNEL
);
1579 if (dev
->video_mode
.alt_max_pkt_size
== NULL
)
1582 for (i
= 0; i
< dev
->video_mode
.num_alt
; i
++) {
1585 if (uif
->altsetting
[i
].desc
.bNumEndpoints
< isoc_pipe
+ 1)
1588 tmp
= le16_to_cpu(uif
->altsetting
[i
].endpoint
[isoc_pipe
].desc
.wMaxPacketSize
);
1589 dev
->video_mode
.alt_max_pkt_size
[i
] = (tmp
& 0x07ff) * (((tmp
& 0x1800) >> 11) + 1);
1591 "Alternate setting %i, max size= %i\n", i
,
1592 dev
->video_mode
.alt_max_pkt_size
[i
]);
1597 idx
= dev
->current_pcb_config
.hs_config_info
[0].interface_info
.vanc_index
+ 1;
1598 if (idx
>= dev
->max_iad_interface_count
) {
1600 "VBI PCB interface #%d doesn't exist\n", idx
);
1603 uif
= udev
->actconfig
->interface
[idx
];
1605 if (uif
->altsetting
[0].desc
.bNumEndpoints
< isoc_pipe
+ 1)
1608 dev
->vbi_mode
.end_point_addr
=
1609 uif
->altsetting
[0].endpoint
[isoc_pipe
].desc
.
1612 dev
->vbi_mode
.num_alt
= uif
->num_altsetting
;
1614 "VBI EndPoint Addr 0x%x, Alternate settings: %i\n",
1615 dev
->vbi_mode
.end_point_addr
,
1616 dev
->vbi_mode
.num_alt
);
1618 /* compute alternate max packet sizes for vbi */
1619 dev
->vbi_mode
.alt_max_pkt_size
= devm_kmalloc_array(&udev
->dev
, 32, dev
->vbi_mode
.num_alt
, GFP_KERNEL
);
1620 if (dev
->vbi_mode
.alt_max_pkt_size
== NULL
)
1623 for (i
= 0; i
< dev
->vbi_mode
.num_alt
; i
++) {
1626 if (uif
->altsetting
[i
].desc
.bNumEndpoints
< isoc_pipe
+ 1)
1629 tmp
= le16_to_cpu(uif
->altsetting
[i
].endpoint
[isoc_pipe
].
1630 desc
.wMaxPacketSize
);
1631 dev
->vbi_mode
.alt_max_pkt_size
[i
] =
1632 (tmp
& 0x07ff) * (((tmp
& 0x1800) >> 11) + 1);
1634 "Alternate setting %i, max size= %i\n", i
,
1635 dev
->vbi_mode
.alt_max_pkt_size
[i
]);
1638 /* Sliced CC VBI init */
1640 /* compute alternate max packet sizes for sliced CC */
1641 idx
= dev
->current_pcb_config
.hs_config_info
[0].interface_info
.hanc_index
+ 1;
1642 if (idx
>= dev
->max_iad_interface_count
) {
1644 "Sliced CC PCB interface #%d doesn't exist\n", idx
);
1647 uif
= udev
->actconfig
->interface
[idx
];
1649 if (uif
->altsetting
[0].desc
.bNumEndpoints
< isoc_pipe
+ 1)
1652 dev
->sliced_cc_mode
.end_point_addr
=
1653 uif
->altsetting
[0].endpoint
[isoc_pipe
].desc
.
1656 dev
->sliced_cc_mode
.num_alt
= uif
->num_altsetting
;
1658 "sliced CC EndPoint Addr 0x%x, Alternate settings: %i\n",
1659 dev
->sliced_cc_mode
.end_point_addr
,
1660 dev
->sliced_cc_mode
.num_alt
);
1661 dev
->sliced_cc_mode
.alt_max_pkt_size
= devm_kmalloc_array(&udev
->dev
, 32, dev
->sliced_cc_mode
.num_alt
, GFP_KERNEL
);
1662 if (dev
->sliced_cc_mode
.alt_max_pkt_size
== NULL
)
1665 for (i
= 0; i
< dev
->sliced_cc_mode
.num_alt
; i
++) {
1668 if (uif
->altsetting
[i
].desc
.bNumEndpoints
< isoc_pipe
+ 1)
1671 tmp
= le16_to_cpu(uif
->altsetting
[i
].endpoint
[isoc_pipe
].
1672 desc
.wMaxPacketSize
);
1673 dev
->sliced_cc_mode
.alt_max_pkt_size
[i
] =
1674 (tmp
& 0x07ff) * (((tmp
& 0x1800) >> 11) + 1);
1676 "Alternate setting %i, max size= %i\n", i
,
1677 dev
->sliced_cc_mode
.alt_max_pkt_size
[i
]);
1684 * cx231xx_usb_probe()
1685 * checks for supported devices
1687 static int cx231xx_usb_probe(struct usb_interface
*interface
,
1688 const struct usb_device_id
*id
)
1690 struct usb_device
*udev
;
1691 struct device
*d
= &interface
->dev
;
1692 struct usb_interface
*uif
;
1693 struct cx231xx
*dev
= NULL
;
1694 int retval
= -ENODEV
;
1696 int i
, isoc_pipe
= 0;
1699 struct usb_interface_assoc_descriptor
*assoc_desc
;
1701 ifnum
= interface
->altsetting
[0].desc
.bInterfaceNumber
;
1704 * Interface number 0 - IR interface (handled by mceusb driver)
1705 * Interface number 1 - AV interface (handled by this driver)
1710 /* Check to see next free device and mark as used */
1712 nr
= find_first_zero_bit(&cx231xx_devused
, CX231XX_MAXBOARDS
);
1713 if (nr
>= CX231XX_MAXBOARDS
) {
1714 /* No free device slots */
1716 "Supports only %i devices.\n",
1720 } while (test_and_set_bit(nr
, &cx231xx_devused
));
1722 udev
= usb_get_dev(interface_to_usbdev(interface
));
1724 /* allocate memory for our device state and initialize it */
1725 dev
= devm_kzalloc(&udev
->dev
, sizeof(*dev
), GFP_KERNEL
);
1731 snprintf(dev
->name
, 29, "cx231xx #%d", nr
);
1733 dev
->model
= id
->driver_info
;
1734 dev
->video_mode
.alt
= -1;
1737 cx231xx_set_model(dev
);
1739 dev
->interface_count
++;
1740 /* reset gpio dir and value */
1743 dev
->xc_fw_load_done
= 0;
1744 dev
->has_alsa_audio
= 1;
1745 dev
->power_mode
= -1;
1746 atomic_set(&dev
->devlist_count
, 0);
1748 /* 0 - vbi ; 1 -sliced cc mode */
1749 dev
->vbi_or_sliced_cc_mode
= 0;
1751 /* get maximum no.of IAD interfaces */
1752 dev
->max_iad_interface_count
= udev
->config
->desc
.bNumInterfaces
;
1754 /* init CIR module TBD */
1756 /*mode_tv: digital=1 or analog=0*/
1759 dev
->USE_ISO
= transfer_mode
;
1761 switch (udev
->speed
) {
1765 case USB_SPEED_UNKNOWN
:
1766 case USB_SPEED_FULL
:
1769 case USB_SPEED_HIGH
:
1777 "New device %s %s @ %s Mbps (%04x:%04x) with %d interfaces\n",
1778 udev
->manufacturer
? udev
->manufacturer
: "",
1779 udev
->product
? udev
->product
: "",
1781 le16_to_cpu(udev
->descriptor
.idVendor
),
1782 le16_to_cpu(udev
->descriptor
.idProduct
),
1783 dev
->max_iad_interface_count
);
1785 /* increment interface count */
1786 dev
->interface_count
++;
1788 /* get device number */
1791 assoc_desc
= udev
->actconfig
->intf_assoc
[0];
1792 if (!assoc_desc
|| assoc_desc
->bFirstInterface
!= ifnum
) {
1793 dev_err(d
, "Not found matching IAD interface\n");
1798 dev_dbg(d
, "registering interface %d\n", ifnum
);
1800 /* save our data pointer in this interface device */
1801 usb_set_intfdata(interface
, dev
);
1803 /* Initialize the media controller */
1804 retval
= cx231xx_media_device_init(dev
, udev
);
1806 dev_err(d
, "cx231xx_media_device_init failed\n");
1807 goto err_media_init
;
1810 /* Create v4l2 device */
1811 #ifdef CONFIG_MEDIA_CONTROLLER
1812 dev
->v4l2_dev
.mdev
= dev
->media_dev
;
1814 retval
= v4l2_device_register(&interface
->dev
, &dev
->v4l2_dev
);
1816 dev_err(d
, "v4l2_device_register failed\n");
1820 /* allocate device struct */
1821 retval
= cx231xx_init_dev(dev
, udev
, nr
);
1825 retval
= cx231xx_init_v4l2(dev
, udev
, interface
, isoc_pipe
);
1829 if (dev
->current_pcb_config
.ts1_source
!= 0xff) {
1830 /* compute alternate max packet sizes for TS1 */
1831 idx
= dev
->current_pcb_config
.hs_config_info
[0].interface_info
.ts1_index
+ 1;
1832 if (idx
>= dev
->max_iad_interface_count
) {
1833 dev_err(d
, "TS1 PCB interface #%d doesn't exist\n",
1838 uif
= udev
->actconfig
->interface
[idx
];
1840 if (uif
->altsetting
[0].desc
.bNumEndpoints
< isoc_pipe
+ 1) {
1845 dev
->ts1_mode
.end_point_addr
=
1846 uif
->altsetting
[0].endpoint
[isoc_pipe
].
1847 desc
.bEndpointAddress
;
1849 dev
->ts1_mode
.num_alt
= uif
->num_altsetting
;
1851 "TS EndPoint Addr 0x%x, Alternate settings: %i\n",
1852 dev
->ts1_mode
.end_point_addr
,
1853 dev
->ts1_mode
.num_alt
);
1855 dev
->ts1_mode
.alt_max_pkt_size
= devm_kmalloc_array(&udev
->dev
, 32, dev
->ts1_mode
.num_alt
, GFP_KERNEL
);
1856 if (dev
->ts1_mode
.alt_max_pkt_size
== NULL
) {
1861 for (i
= 0; i
< dev
->ts1_mode
.num_alt
; i
++) {
1864 if (uif
->altsetting
[i
].desc
.bNumEndpoints
< isoc_pipe
+ 1) {
1869 tmp
= le16_to_cpu(uif
->altsetting
[i
].
1870 endpoint
[isoc_pipe
].desc
.
1872 dev
->ts1_mode
.alt_max_pkt_size
[i
] =
1873 (tmp
& 0x07ff) * (((tmp
& 0x1800) >> 11) + 1);
1874 dev_dbg(d
, "Alternate setting %i, max size= %i\n",
1875 i
, dev
->ts1_mode
.alt_max_pkt_size
[i
]);
1879 if (dev
->model
== CX231XX_BOARD_CNXT_VIDEO_GRABBER
) {
1880 cx231xx_enable_OSC(dev
);
1881 cx231xx_reset_out(dev
);
1882 cx231xx_set_alt_setting(dev
, INDEX_VIDEO
, 3);
1885 if (dev
->model
== CX231XX_BOARD_CNXT_RDE_253S
)
1886 cx231xx_sleep_s5h1432(dev
);
1888 /* load other modules required */
1889 request_modules(dev
);
1891 #ifdef CONFIG_MEDIA_CONTROLLER
1892 /* Init entities at the Media Controller */
1893 cx231xx_v4l2_create_entities(dev
);
1895 retval
= v4l2_mc_create_media_graph(dev
->media_dev
);
1897 retval
= media_device_register(dev
->media_dev
);
1900 cx231xx_release_resources(dev
);
1904 /* cx231xx_uninit_dev: */
1905 cx231xx_close_extension(dev
);
1906 cx231xx_ir_exit(dev
);
1907 cx231xx_release_analog_resources(dev
);
1908 cx231xx_417_unregister(dev
);
1909 cx231xx_remove_from_devlist(dev
);
1910 cx231xx_dev_uninit(dev
);
1912 v4l2_device_unregister(&dev
->v4l2_dev
);
1914 cx231xx_unregister_media_device(dev
);
1916 usb_set_intfdata(interface
, NULL
);
1919 clear_bit(nr
, &cx231xx_devused
);
1924 * cx231xx_usb_disconnect()
1925 * called when the device gets disconnected
1926 * video device will be unregistered on v4l2_close in case it is still open
1928 static void cx231xx_usb_disconnect(struct usb_interface
*interface
)
1930 struct cx231xx
*dev
;
1932 dev
= usb_get_intfdata(interface
);
1933 usb_set_intfdata(interface
, NULL
);
1941 dev
->state
|= DEV_DISCONNECTED
;
1943 flush_request_modules(dev
);
1945 /* wait until all current v4l2 io is finished then deallocate
1947 mutex_lock(&dev
->lock
);
1949 wake_up_interruptible_all(&dev
->open
);
1953 "device %s is open! Deregistration and memory deallocation are deferred on close.\n",
1954 video_device_node_name(&dev
->vdev
));
1956 /* Even having users, it is safe to remove the RC i2c driver */
1957 cx231xx_ir_exit(dev
);
1960 cx231xx_uninit_isoc(dev
);
1962 cx231xx_uninit_bulk(dev
);
1963 wake_up_interruptible(&dev
->wait_frame
);
1964 wake_up_interruptible(&dev
->wait_stream
);
1968 cx231xx_close_extension(dev
);
1970 mutex_unlock(&dev
->lock
);
1973 cx231xx_release_resources(dev
);
1976 static struct usb_driver cx231xx_usb_driver
= {
1978 .probe
= cx231xx_usb_probe
,
1979 .disconnect
= cx231xx_usb_disconnect
,
1980 .id_table
= cx231xx_id_table
,
1983 module_usb_driver(cx231xx_usb_driver
);