2 cx231xx-cards.c - driver for Conexant Cx23100/101/102
3 USB video capture devices
5 Copyright (C) 2008 <srinivasa.deevi at conexant dot com>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <linux/init.h>
25 #include <linux/module.h>
26 #include <linux/slab.h>
27 #include <linux/delay.h>
28 #include <linux/i2c.h>
29 #include <media/tuner.h>
30 #include <media/tveeprom.h>
31 #include <media/v4l2-common.h>
33 #include <media/drv-intf/cx25840.h>
34 #include <media/dvb-usb-ids.h>
39 static int tuner
= -1;
40 module_param(tuner
, int, 0444);
41 MODULE_PARM_DESC(tuner
, "tuner type");
43 static int transfer_mode
= 1;
44 module_param(transfer_mode
, int, 0444);
45 MODULE_PARM_DESC(transfer_mode
, "transfer mode (1-ISO or 0-BULK)");
47 static unsigned int disable_ir
;
48 module_param(disable_ir
, int, 0444);
49 MODULE_PARM_DESC(disable_ir
, "disable infrared remote support");
51 /* Bitmask marking allocated devices from 0 to CX231XX_MAXBOARDS */
52 static unsigned long cx231xx_devused
;
55 * Reset sequences for analog/digital modes
58 static struct cx231xx_reg_seq RDE250_XCV_TUNER
[] = {
68 struct cx231xx_board cx231xx_boards
[] = {
69 [CX231XX_BOARD_UNKNOWN
] = {
70 .name
= "Unknown CX231xx video grabber",
71 .tuner_type
= TUNER_ABSENT
,
73 .type
= CX231XX_VMUX_TELEVISION
,
74 .vmux
= CX231XX_VIN_3_1
,
75 .amux
= CX231XX_AMUX_VIDEO
,
78 .type
= CX231XX_VMUX_COMPOSITE1
,
79 .vmux
= CX231XX_VIN_2_1
,
80 .amux
= CX231XX_AMUX_LINE_IN
,
83 .type
= CX231XX_VMUX_SVIDEO
,
84 .vmux
= CX231XX_VIN_1_1
|
85 (CX231XX_VIN_1_2
<< 8) |
87 .amux
= CX231XX_AMUX_LINE_IN
,
92 [CX231XX_BOARD_CNXT_CARRAERA
] = {
93 .name
= "Conexant Hybrid TV - CARRAERA",
94 .tuner_type
= TUNER_XC5000
,
96 .tuner_gpio
= RDE250_XCV_TUNER
,
97 .tuner_sif_gpio
= 0x05,
98 .tuner_scl_gpio
= 0x1a,
99 .tuner_sda_gpio
= 0x1b,
100 .decoder
= CX231XX_AVDECODER
,
101 .output_mode
= OUT_MODE_VIP11
,
102 .demod_xfer_mode
= 0,
103 .ctl_pin_status_mask
= 0xFFFFFFC4,
104 .agc_analog_digital_select_gpio
= 0x0c,
105 .gpio_pin_status_mask
= 0x4001000,
106 .tuner_i2c_master
= I2C_1_MUX_3
,
107 .demod_i2c_master
= I2C_2
,
110 .norm
= V4L2_STD_PAL
,
113 .type
= CX231XX_VMUX_TELEVISION
,
114 .vmux
= CX231XX_VIN_3_1
,
115 .amux
= CX231XX_AMUX_VIDEO
,
118 .type
= CX231XX_VMUX_COMPOSITE1
,
119 .vmux
= CX231XX_VIN_2_1
,
120 .amux
= CX231XX_AMUX_LINE_IN
,
123 .type
= CX231XX_VMUX_SVIDEO
,
124 .vmux
= CX231XX_VIN_1_1
|
125 (CX231XX_VIN_1_2
<< 8) |
127 .amux
= CX231XX_AMUX_LINE_IN
,
132 [CX231XX_BOARD_CNXT_SHELBY
] = {
133 .name
= "Conexant Hybrid TV - SHELBY",
134 .tuner_type
= TUNER_XC5000
,
136 .tuner_gpio
= RDE250_XCV_TUNER
,
137 .tuner_sif_gpio
= 0x05,
138 .tuner_scl_gpio
= 0x1a,
139 .tuner_sda_gpio
= 0x1b,
140 .decoder
= CX231XX_AVDECODER
,
141 .output_mode
= OUT_MODE_VIP11
,
142 .demod_xfer_mode
= 0,
143 .ctl_pin_status_mask
= 0xFFFFFFC4,
144 .agc_analog_digital_select_gpio
= 0x0c,
145 .gpio_pin_status_mask
= 0x4001000,
146 .tuner_i2c_master
= I2C_1_MUX_3
,
147 .demod_i2c_master
= I2C_2
,
150 .norm
= V4L2_STD_NTSC
,
153 .type
= CX231XX_VMUX_TELEVISION
,
154 .vmux
= CX231XX_VIN_3_1
,
155 .amux
= CX231XX_AMUX_VIDEO
,
158 .type
= CX231XX_VMUX_COMPOSITE1
,
159 .vmux
= CX231XX_VIN_2_1
,
160 .amux
= CX231XX_AMUX_LINE_IN
,
163 .type
= CX231XX_VMUX_SVIDEO
,
164 .vmux
= CX231XX_VIN_1_1
|
165 (CX231XX_VIN_1_2
<< 8) |
167 .amux
= CX231XX_AMUX_LINE_IN
,
172 [CX231XX_BOARD_CNXT_RDE_253S
] = {
173 .name
= "Conexant Hybrid TV - RDE253S",
174 .tuner_type
= TUNER_NXP_TDA18271
,
176 .tuner_gpio
= RDE250_XCV_TUNER
,
177 .tuner_sif_gpio
= 0x05,
178 .tuner_scl_gpio
= 0x1a,
179 .tuner_sda_gpio
= 0x1b,
180 .decoder
= CX231XX_AVDECODER
,
181 .output_mode
= OUT_MODE_VIP11
,
182 .demod_xfer_mode
= 0,
183 .ctl_pin_status_mask
= 0xFFFFFFC4,
184 .agc_analog_digital_select_gpio
= 0x1c,
185 .gpio_pin_status_mask
= 0x4001000,
186 .tuner_i2c_master
= I2C_1_MUX_3
,
187 .demod_i2c_master
= I2C_2
,
190 .norm
= V4L2_STD_PAL
,
193 .type
= CX231XX_VMUX_TELEVISION
,
194 .vmux
= CX231XX_VIN_3_1
,
195 .amux
= CX231XX_AMUX_VIDEO
,
198 .type
= CX231XX_VMUX_COMPOSITE1
,
199 .vmux
= CX231XX_VIN_2_1
,
200 .amux
= CX231XX_AMUX_LINE_IN
,
203 .type
= CX231XX_VMUX_SVIDEO
,
204 .vmux
= CX231XX_VIN_1_1
|
205 (CX231XX_VIN_1_2
<< 8) |
207 .amux
= CX231XX_AMUX_LINE_IN
,
213 [CX231XX_BOARD_CNXT_RDU_253S
] = {
214 .name
= "Conexant Hybrid TV - RDU253S",
215 .tuner_type
= TUNER_NXP_TDA18271
,
217 .tuner_gpio
= RDE250_XCV_TUNER
,
218 .tuner_sif_gpio
= 0x05,
219 .tuner_scl_gpio
= 0x1a,
220 .tuner_sda_gpio
= 0x1b,
221 .decoder
= CX231XX_AVDECODER
,
222 .output_mode
= OUT_MODE_VIP11
,
223 .demod_xfer_mode
= 0,
224 .ctl_pin_status_mask
= 0xFFFFFFC4,
225 .agc_analog_digital_select_gpio
= 0x1c,
226 .gpio_pin_status_mask
= 0x4001000,
227 .tuner_i2c_master
= I2C_1_MUX_3
,
228 .demod_i2c_master
= I2C_2
,
231 .norm
= V4L2_STD_PAL
,
234 .type
= CX231XX_VMUX_TELEVISION
,
235 .vmux
= CX231XX_VIN_3_1
,
236 .amux
= CX231XX_AMUX_VIDEO
,
239 .type
= CX231XX_VMUX_COMPOSITE1
,
240 .vmux
= CX231XX_VIN_2_1
,
241 .amux
= CX231XX_AMUX_LINE_IN
,
244 .type
= CX231XX_VMUX_SVIDEO
,
245 .vmux
= CX231XX_VIN_1_1
|
246 (CX231XX_VIN_1_2
<< 8) |
248 .amux
= CX231XX_AMUX_LINE_IN
,
253 [CX231XX_BOARD_CNXT_VIDEO_GRABBER
] = {
254 .name
= "Conexant VIDEO GRABBER",
255 .tuner_type
= TUNER_ABSENT
,
256 .decoder
= CX231XX_AVDECODER
,
257 .output_mode
= OUT_MODE_VIP11
,
258 .ctl_pin_status_mask
= 0xFFFFFFC4,
259 .agc_analog_digital_select_gpio
= 0x1c,
260 .gpio_pin_status_mask
= 0x4001000,
261 .norm
= V4L2_STD_PAL
,
264 /* Actually, it has a 417, but it isn't working correctly.
265 * So set to 0 for now until someone can manage to get this
266 * to work reliably. */
270 .type
= CX231XX_VMUX_COMPOSITE1
,
271 .vmux
= CX231XX_VIN_2_1
,
272 .amux
= CX231XX_AMUX_LINE_IN
,
275 .type
= CX231XX_VMUX_SVIDEO
,
276 .vmux
= CX231XX_VIN_1_1
|
277 (CX231XX_VIN_1_2
<< 8) |
279 .amux
= CX231XX_AMUX_LINE_IN
,
284 [CX231XX_BOARD_CNXT_RDE_250
] = {
285 .name
= "Conexant Hybrid TV - rde 250",
286 .tuner_type
= TUNER_XC5000
,
288 .tuner_gpio
= RDE250_XCV_TUNER
,
289 .tuner_sif_gpio
= 0x05,
290 .tuner_scl_gpio
= 0x1a,
291 .tuner_sda_gpio
= 0x1b,
292 .decoder
= CX231XX_AVDECODER
,
293 .output_mode
= OUT_MODE_VIP11
,
294 .demod_xfer_mode
= 0,
295 .ctl_pin_status_mask
= 0xFFFFFFC4,
296 .agc_analog_digital_select_gpio
= 0x0c,
297 .gpio_pin_status_mask
= 0x4001000,
298 .tuner_i2c_master
= I2C_1_MUX_3
,
299 .demod_i2c_master
= I2C_2
,
302 .norm
= V4L2_STD_PAL
,
305 .type
= CX231XX_VMUX_TELEVISION
,
306 .vmux
= CX231XX_VIN_2_1
,
307 .amux
= CX231XX_AMUX_VIDEO
,
312 [CX231XX_BOARD_CNXT_RDU_250
] = {
313 .name
= "Conexant Hybrid TV - RDU 250",
314 .tuner_type
= TUNER_XC5000
,
316 .tuner_gpio
= RDE250_XCV_TUNER
,
317 .tuner_sif_gpio
= 0x05,
318 .tuner_scl_gpio
= 0x1a,
319 .tuner_sda_gpio
= 0x1b,
320 .decoder
= CX231XX_AVDECODER
,
321 .output_mode
= OUT_MODE_VIP11
,
322 .demod_xfer_mode
= 0,
323 .ctl_pin_status_mask
= 0xFFFFFFC4,
324 .agc_analog_digital_select_gpio
= 0x0c,
325 .gpio_pin_status_mask
= 0x4001000,
326 .tuner_i2c_master
= I2C_1_MUX_3
,
327 .demod_i2c_master
= I2C_2
,
330 .norm
= V4L2_STD_NTSC
,
333 .type
= CX231XX_VMUX_TELEVISION
,
334 .vmux
= CX231XX_VIN_2_1
,
335 .amux
= CX231XX_AMUX_VIDEO
,
340 [CX231XX_BOARD_HAUPPAUGE_EXETER
] = {
341 .name
= "Hauppauge EXETER",
342 .tuner_type
= TUNER_NXP_TDA18271
,
344 .tuner_gpio
= RDE250_XCV_TUNER
,
345 .tuner_sif_gpio
= 0x05,
346 .tuner_scl_gpio
= 0x1a,
347 .tuner_sda_gpio
= 0x1b,
348 .decoder
= CX231XX_AVDECODER
,
349 .output_mode
= OUT_MODE_VIP11
,
350 .demod_xfer_mode
= 0,
351 .ctl_pin_status_mask
= 0xFFFFFFC4,
352 .agc_analog_digital_select_gpio
= 0x0c,
353 .gpio_pin_status_mask
= 0x4001000,
354 .tuner_i2c_master
= I2C_1_MUX_1
,
355 .demod_i2c_master
= I2C_1_MUX_1
,
358 .norm
= V4L2_STD_NTSC
,
361 .type
= CX231XX_VMUX_TELEVISION
,
362 .vmux
= CX231XX_VIN_3_1
,
363 .amux
= CX231XX_AMUX_VIDEO
,
366 .type
= CX231XX_VMUX_COMPOSITE1
,
367 .vmux
= CX231XX_VIN_2_1
,
368 .amux
= CX231XX_AMUX_LINE_IN
,
371 .type
= CX231XX_VMUX_SVIDEO
,
372 .vmux
= CX231XX_VIN_1_1
|
373 (CX231XX_VIN_1_2
<< 8) |
375 .amux
= CX231XX_AMUX_LINE_IN
,
379 [CX231XX_BOARD_HAUPPAUGE_USBLIVE2
] = {
380 .name
= "Hauppauge USB Live 2",
381 .tuner_type
= TUNER_ABSENT
,
382 .decoder
= CX231XX_AVDECODER
,
383 .output_mode
= OUT_MODE_VIP11
,
384 .demod_xfer_mode
= 0,
385 .ctl_pin_status_mask
= 0xFFFFFFC4,
386 .agc_analog_digital_select_gpio
= 0x0c,
387 .gpio_pin_status_mask
= 0x4001000,
388 .norm
= V4L2_STD_NTSC
,
392 .type
= CX231XX_VMUX_COMPOSITE1
,
393 .vmux
= CX231XX_VIN_2_1
,
394 .amux
= CX231XX_AMUX_LINE_IN
,
397 .type
= CX231XX_VMUX_SVIDEO
,
398 .vmux
= CX231XX_VIN_1_1
|
399 (CX231XX_VIN_1_2
<< 8) |
401 .amux
= CX231XX_AMUX_LINE_IN
,
405 [CX231XX_BOARD_KWORLD_UB430_USB_HYBRID
] = {
406 .name
= "Kworld UB430 USB Hybrid",
407 .tuner_type
= TUNER_NXP_TDA18271
,
409 .decoder
= CX231XX_AVDECODER
,
410 .output_mode
= OUT_MODE_VIP11
,
411 .demod_xfer_mode
= 0,
412 .ctl_pin_status_mask
= 0xFFFFFFC4,
413 .agc_analog_digital_select_gpio
= 0x11, /* According with PV cxPolaris.inf file */
414 .tuner_sif_gpio
= -1,
415 .tuner_scl_gpio
= -1,
416 .tuner_sda_gpio
= -1,
417 .gpio_pin_status_mask
= 0x4001000,
418 .tuner_i2c_master
= I2C_2
,
419 .demod_i2c_master
= I2C_1_MUX_3
,
420 .ir_i2c_master
= I2C_2
,
423 .norm
= V4L2_STD_PAL_M
,
425 .type
= CX231XX_VMUX_TELEVISION
,
426 .vmux
= CX231XX_VIN_3_1
,
427 .amux
= CX231XX_AMUX_VIDEO
,
430 .type
= CX231XX_VMUX_COMPOSITE1
,
431 .vmux
= CX231XX_VIN_2_1
,
432 .amux
= CX231XX_AMUX_LINE_IN
,
435 .type
= CX231XX_VMUX_SVIDEO
,
436 .vmux
= CX231XX_VIN_1_1
|
437 (CX231XX_VIN_1_2
<< 8) |
439 .amux
= CX231XX_AMUX_LINE_IN
,
443 [CX231XX_BOARD_KWORLD_UB445_USB_HYBRID
] = {
444 .name
= "Kworld UB445 USB Hybrid",
445 .tuner_type
= TUNER_NXP_TDA18271
,
447 .decoder
= CX231XX_AVDECODER
,
448 .output_mode
= OUT_MODE_VIP11
,
449 .demod_xfer_mode
= 0,
450 .ctl_pin_status_mask
= 0xFFFFFFC4,
451 .agc_analog_digital_select_gpio
= 0x11, /* According with PV cxPolaris.inf file */
452 .tuner_sif_gpio
= -1,
453 .tuner_scl_gpio
= -1,
454 .tuner_sda_gpio
= -1,
455 .gpio_pin_status_mask
= 0x4001000,
456 .tuner_i2c_master
= I2C_2
,
457 .demod_i2c_master
= I2C_1_MUX_3
,
458 .ir_i2c_master
= I2C_2
,
461 .norm
= V4L2_STD_NTSC_M
,
463 .type
= CX231XX_VMUX_TELEVISION
,
464 .vmux
= CX231XX_VIN_3_1
,
465 .amux
= CX231XX_AMUX_VIDEO
,
468 .type
= CX231XX_VMUX_COMPOSITE1
,
469 .vmux
= CX231XX_VIN_2_1
,
470 .amux
= CX231XX_AMUX_LINE_IN
,
473 .type
= CX231XX_VMUX_SVIDEO
,
474 .vmux
= CX231XX_VIN_1_1
|
475 (CX231XX_VIN_1_2
<< 8) |
477 .amux
= CX231XX_AMUX_LINE_IN
,
481 [CX231XX_BOARD_PV_PLAYTV_USB_HYBRID
] = {
482 .name
= "Pixelview PlayTV USB Hybrid",
483 .tuner_type
= TUNER_NXP_TDA18271
,
485 .decoder
= CX231XX_AVDECODER
,
486 .output_mode
= OUT_MODE_VIP11
,
487 .demod_xfer_mode
= 0,
488 .ctl_pin_status_mask
= 0xFFFFFFC4,
489 .agc_analog_digital_select_gpio
= 0x1c,
490 .tuner_sif_gpio
= -1,
491 .tuner_scl_gpio
= -1,
492 .tuner_sda_gpio
= -1,
493 .gpio_pin_status_mask
= 0x4001000,
494 .tuner_i2c_master
= I2C_2
,
495 .demod_i2c_master
= I2C_1_MUX_3
,
496 .ir_i2c_master
= I2C_2
,
497 .rc_map_name
= RC_MAP_PIXELVIEW_002T
,
500 .norm
= V4L2_STD_PAL_M
,
502 .type
= CX231XX_VMUX_TELEVISION
,
503 .vmux
= CX231XX_VIN_3_1
,
504 .amux
= CX231XX_AMUX_VIDEO
,
507 .type
= CX231XX_VMUX_COMPOSITE1
,
508 .vmux
= CX231XX_VIN_2_1
,
509 .amux
= CX231XX_AMUX_LINE_IN
,
512 .type
= CX231XX_VMUX_SVIDEO
,
513 .vmux
= CX231XX_VIN_1_1
|
514 (CX231XX_VIN_1_2
<< 8) |
516 .amux
= CX231XX_AMUX_LINE_IN
,
520 [CX231XX_BOARD_PV_XCAPTURE_USB
] = {
521 .name
= "Pixelview Xcapture USB",
522 .tuner_type
= TUNER_ABSENT
,
523 .decoder
= CX231XX_AVDECODER
,
524 .output_mode
= OUT_MODE_VIP11
,
525 .demod_xfer_mode
= 0,
526 .ctl_pin_status_mask
= 0xFFFFFFC4,
527 .agc_analog_digital_select_gpio
= 0x0c,
528 .gpio_pin_status_mask
= 0x4001000,
529 .norm
= V4L2_STD_NTSC
,
534 .type
= CX231XX_VMUX_COMPOSITE1
,
535 .vmux
= CX231XX_VIN_2_1
,
536 .amux
= CX231XX_AMUX_LINE_IN
,
539 .type
= CX231XX_VMUX_SVIDEO
,
540 .vmux
= CX231XX_VIN_1_1
|
541 (CX231XX_VIN_1_2
<< 8) |
543 .amux
= CX231XX_AMUX_LINE_IN
,
549 [CX231XX_BOARD_ICONBIT_U100
] = {
550 .name
= "Iconbit Analog Stick U100 FM",
551 .tuner_type
= TUNER_ABSENT
,
552 .decoder
= CX231XX_AVDECODER
,
553 .output_mode
= OUT_MODE_VIP11
,
554 .demod_xfer_mode
= 0,
555 .ctl_pin_status_mask
= 0xFFFFFFC4,
556 .agc_analog_digital_select_gpio
= 0x1C,
557 .gpio_pin_status_mask
= 0x4001000,
560 .type
= CX231XX_VMUX_COMPOSITE1
,
561 .vmux
= CX231XX_VIN_2_1
,
562 .amux
= CX231XX_AMUX_LINE_IN
,
565 .type
= CX231XX_VMUX_SVIDEO
,
566 .vmux
= CX231XX_VIN_1_1
|
567 (CX231XX_VIN_1_2
<< 8) |
569 .amux
= CX231XX_AMUX_LINE_IN
,
573 [CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL
] = {
574 .name
= "Hauppauge WinTV USB2 FM (PAL)",
575 .tuner_type
= TUNER_NXP_TDA18271
,
577 .tuner_gpio
= RDE250_XCV_TUNER
,
578 .tuner_sif_gpio
= 0x05,
579 .tuner_scl_gpio
= 0x1a,
580 .tuner_sda_gpio
= 0x1b,
581 .decoder
= CX231XX_AVDECODER
,
582 .output_mode
= OUT_MODE_VIP11
,
583 .ctl_pin_status_mask
= 0xFFFFFFC4,
584 .agc_analog_digital_select_gpio
= 0x0c,
585 .gpio_pin_status_mask
= 0x4001000,
586 .tuner_i2c_master
= I2C_1_MUX_3
,
587 .norm
= V4L2_STD_PAL
,
590 .type
= CX231XX_VMUX_TELEVISION
,
591 .vmux
= CX231XX_VIN_3_1
,
592 .amux
= CX231XX_AMUX_VIDEO
,
595 .type
= CX231XX_VMUX_COMPOSITE1
,
596 .vmux
= CX231XX_VIN_2_1
,
597 .amux
= CX231XX_AMUX_LINE_IN
,
600 .type
= CX231XX_VMUX_SVIDEO
,
601 .vmux
= CX231XX_VIN_1_1
|
602 (CX231XX_VIN_1_2
<< 8) |
604 .amux
= CX231XX_AMUX_LINE_IN
,
608 [CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC
] = {
609 .name
= "Hauppauge WinTV USB2 FM (NTSC)",
610 .tuner_type
= TUNER_NXP_TDA18271
,
612 .tuner_gpio
= RDE250_XCV_TUNER
,
613 .tuner_sif_gpio
= 0x05,
614 .tuner_scl_gpio
= 0x1a,
615 .tuner_sda_gpio
= 0x1b,
616 .decoder
= CX231XX_AVDECODER
,
617 .output_mode
= OUT_MODE_VIP11
,
618 .ctl_pin_status_mask
= 0xFFFFFFC4,
619 .agc_analog_digital_select_gpio
= 0x0c,
620 .gpio_pin_status_mask
= 0x4001000,
621 .tuner_i2c_master
= I2C_1_MUX_3
,
622 .norm
= V4L2_STD_NTSC
,
625 .type
= CX231XX_VMUX_TELEVISION
,
626 .vmux
= CX231XX_VIN_3_1
,
627 .amux
= CX231XX_AMUX_VIDEO
,
630 .type
= CX231XX_VMUX_COMPOSITE1
,
631 .vmux
= CX231XX_VIN_2_1
,
632 .amux
= CX231XX_AMUX_LINE_IN
,
635 .type
= CX231XX_VMUX_SVIDEO
,
636 .vmux
= CX231XX_VIN_1_1
|
637 (CX231XX_VIN_1_2
<< 8) |
639 .amux
= CX231XX_AMUX_LINE_IN
,
643 [CX231XX_BOARD_ELGATO_VIDEO_CAPTURE_V2
] = {
644 .name
= "Elgato Video Capture V2",
645 .tuner_type
= TUNER_ABSENT
,
646 .decoder
= CX231XX_AVDECODER
,
647 .output_mode
= OUT_MODE_VIP11
,
648 .demod_xfer_mode
= 0,
649 .ctl_pin_status_mask
= 0xFFFFFFC4,
650 .agc_analog_digital_select_gpio
= 0x0c,
651 .gpio_pin_status_mask
= 0x4001000,
652 .norm
= V4L2_STD_NTSC
,
656 .type
= CX231XX_VMUX_COMPOSITE1
,
657 .vmux
= CX231XX_VIN_2_1
,
658 .amux
= CX231XX_AMUX_LINE_IN
,
661 .type
= CX231XX_VMUX_SVIDEO
,
662 .vmux
= CX231XX_VIN_1_1
|
663 (CX231XX_VIN_1_2
<< 8) |
665 .amux
= CX231XX_AMUX_LINE_IN
,
669 [CX231XX_BOARD_OTG102
] = {
670 .name
= "Geniatech OTG102",
671 .tuner_type
= TUNER_ABSENT
,
672 .decoder
= CX231XX_AVDECODER
,
673 .output_mode
= OUT_MODE_VIP11
,
674 .ctl_pin_status_mask
= 0xFFFFFFC4,
675 .agc_analog_digital_select_gpio
= 0x0c,
676 /* According with PV CxPlrCAP.inf file */
677 .gpio_pin_status_mask
= 0x4001000,
678 .norm
= V4L2_STD_NTSC
,
682 /* This board is believed to have a hardware encoding chip
683 * supporting mpeg1/2/4, but as the 417 is apparently not
684 * working for the reference board it is not here either. */
687 .type
= CX231XX_VMUX_COMPOSITE1
,
688 .vmux
= CX231XX_VIN_2_1
,
689 .amux
= CX231XX_AMUX_LINE_IN
,
692 .type
= CX231XX_VMUX_SVIDEO
,
693 .vmux
= CX231XX_VIN_1_1
|
694 (CX231XX_VIN_1_2
<< 8) |
696 .amux
= CX231XX_AMUX_LINE_IN
,
701 [CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx
] = {
702 .name
= "Hauppauge WinTV 930C-HD (1113xx) / HVR-900H (111xxx) / PCTV QuatroStick 521e",
703 .tuner_type
= TUNER_NXP_TDA18271
,
705 .tuner_gpio
= RDE250_XCV_TUNER
,
706 .tuner_sif_gpio
= 0x05,
707 .tuner_scl_gpio
= 0x1a,
708 .tuner_sda_gpio
= 0x1b,
709 .decoder
= CX231XX_AVDECODER
,
710 .output_mode
= OUT_MODE_VIP11
,
711 .demod_xfer_mode
= 0,
712 .ctl_pin_status_mask
= 0xFFFFFFC4,
713 .agc_analog_digital_select_gpio
= 0x0c,
714 .gpio_pin_status_mask
= 0x4001000,
715 .tuner_i2c_master
= I2C_1_MUX_3
,
716 .demod_i2c_master
= I2C_1_MUX_3
,
718 .demod_addr
= 0x64, /* 0xc8 >> 1 */
719 .norm
= V4L2_STD_PAL
,
722 .type
= CX231XX_VMUX_TELEVISION
,
723 .vmux
= CX231XX_VIN_3_1
,
724 .amux
= CX231XX_AMUX_VIDEO
,
727 .type
= CX231XX_VMUX_COMPOSITE1
,
728 .vmux
= CX231XX_VIN_2_1
,
729 .amux
= CX231XX_AMUX_LINE_IN
,
732 .type
= CX231XX_VMUX_SVIDEO
,
733 .vmux
= CX231XX_VIN_1_1
|
734 (CX231XX_VIN_1_2
<< 8) |
736 .amux
= CX231XX_AMUX_LINE_IN
,
740 [CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx
] = {
741 .name
= "Hauppauge WinTV 930C-HD (1114xx) / HVR-901H (1114xx) / PCTV QuatroStick 522e",
742 .tuner_type
= TUNER_ABSENT
,
744 .tuner_gpio
= RDE250_XCV_TUNER
,
745 .tuner_sif_gpio
= 0x05,
746 .tuner_scl_gpio
= 0x1a,
747 .tuner_sda_gpio
= 0x1b,
748 .decoder
= CX231XX_AVDECODER
,
749 .output_mode
= OUT_MODE_VIP11
,
750 .demod_xfer_mode
= 0,
751 .ctl_pin_status_mask
= 0xFFFFFFC4,
752 .agc_analog_digital_select_gpio
= 0x0c,
753 .gpio_pin_status_mask
= 0x4001000,
754 .tuner_i2c_master
= I2C_1_MUX_3
,
755 .demod_i2c_master
= I2C_1_MUX_3
,
757 .demod_addr
= 0x64, /* 0xc8 >> 1 */
758 .norm
= V4L2_STD_PAL
,
761 .type
= CX231XX_VMUX_TELEVISION
,
762 .vmux
= CX231XX_VIN_3_1
,
763 .amux
= CX231XX_AMUX_VIDEO
,
766 .type
= CX231XX_VMUX_COMPOSITE1
,
767 .vmux
= CX231XX_VIN_2_1
,
768 .amux
= CX231XX_AMUX_LINE_IN
,
771 .type
= CX231XX_VMUX_SVIDEO
,
772 .vmux
= CX231XX_VIN_1_1
|
773 (CX231XX_VIN_1_2
<< 8) |
775 .amux
= CX231XX_AMUX_LINE_IN
,
779 [CX231XX_BOARD_HAUPPAUGE_955Q
] = {
780 .name
= "Hauppauge WinTV-HVR-955Q (111401)",
781 .tuner_type
= TUNER_ABSENT
,
783 .tuner_gpio
= RDE250_XCV_TUNER
,
784 .tuner_sif_gpio
= 0x05,
785 .tuner_scl_gpio
= 0x1a,
786 .tuner_sda_gpio
= 0x1b,
787 .decoder
= CX231XX_AVDECODER
,
788 .output_mode
= OUT_MODE_VIP11
,
789 .demod_xfer_mode
= 0,
790 .ctl_pin_status_mask
= 0xFFFFFFC4,
791 .agc_analog_digital_select_gpio
= 0x0c,
792 .gpio_pin_status_mask
= 0x4001000,
793 .tuner_i2c_master
= I2C_1_MUX_3
,
794 .demod_i2c_master
= I2C_1_MUX_3
,
796 .demod_addr
= 0x59, /* 0xb2 >> 1 */
797 .norm
= V4L2_STD_NTSC
,
800 .type
= CX231XX_VMUX_TELEVISION
,
801 .vmux
= CX231XX_VIN_3_1
,
802 .amux
= CX231XX_AMUX_VIDEO
,
805 .type
= CX231XX_VMUX_COMPOSITE1
,
806 .vmux
= CX231XX_VIN_2_1
,
807 .amux
= CX231XX_AMUX_LINE_IN
,
810 .type
= CX231XX_VMUX_SVIDEO
,
811 .vmux
= CX231XX_VIN_1_1
|
812 (CX231XX_VIN_1_2
<< 8) |
814 .amux
= CX231XX_AMUX_LINE_IN
,
818 [CX231XX_BOARD_TERRATEC_GRABBY
] = {
819 .name
= "Terratec Grabby",
820 .tuner_type
= TUNER_ABSENT
,
821 .decoder
= CX231XX_AVDECODER
,
822 .output_mode
= OUT_MODE_VIP11
,
823 .demod_xfer_mode
= 0,
824 .ctl_pin_status_mask
= 0xFFFFFFC4,
825 .agc_analog_digital_select_gpio
= 0x0c,
826 .gpio_pin_status_mask
= 0x4001000,
827 .norm
= V4L2_STD_PAL
,
831 .type
= CX231XX_VMUX_COMPOSITE1
,
832 .vmux
= CX231XX_VIN_2_1
,
833 .amux
= CX231XX_AMUX_LINE_IN
,
836 .type
= CX231XX_VMUX_SVIDEO
,
837 .vmux
= CX231XX_VIN_1_1
|
838 (CX231XX_VIN_1_2
<< 8) |
840 .amux
= CX231XX_AMUX_LINE_IN
,
844 [CX231XX_BOARD_EVROMEDIA_FULL_HYBRID_FULLHD
] = {
845 .name
= "Evromedia USB Full Hybrid Full HD",
846 .tuner_type
= TUNER_ABSENT
,
847 .demod_addr
= 0x64, /* 0xc8 >> 1 */
848 .demod_i2c_master
= I2C_1_MUX_3
,
850 .decoder
= CX231XX_AVDECODER
,
851 .norm
= V4L2_STD_PAL
,
852 .output_mode
= OUT_MODE_VIP11
,
853 .tuner_addr
= 0x60, /* 0xc0 >> 1 */
854 .tuner_i2c_master
= I2C_2
,
856 .type
= CX231XX_VMUX_TELEVISION
,
858 .amux
= CX231XX_AMUX_VIDEO
,
860 .type
= CX231XX_VMUX_COMPOSITE1
,
861 .vmux
= CX231XX_VIN_2_1
,
862 .amux
= CX231XX_AMUX_LINE_IN
,
864 .type
= CX231XX_VMUX_SVIDEO
,
865 .vmux
= CX231XX_VIN_1_1
|
866 (CX231XX_VIN_1_2
<< 8) |
868 .amux
= CX231XX_AMUX_LINE_IN
,
871 [CX231XX_BOARD_ASTROMETA_T2HYBRID
] = {
872 .name
= "Astrometa T2hybrid",
873 .tuner_type
= TUNER_ABSENT
,
875 .decoder
= CX231XX_AVDECODER
,
876 .output_mode
= OUT_MODE_VIP11
,
877 .agc_analog_digital_select_gpio
= 0x01,
878 .ctl_pin_status_mask
= 0xffffffc4,
879 .demod_addr
= 0x18, /* 0x30 >> 1 */
880 .demod_i2c_master
= I2C_1_MUX_1
,
881 .gpio_pin_status_mask
= 0xa,
882 .norm
= V4L2_STD_NTSC
,
883 .tuner_addr
= 0x3a, /* 0x74 >> 1 */
884 .tuner_i2c_master
= I2C_1_MUX_3
,
885 .tuner_scl_gpio
= 0x1a,
886 .tuner_sda_gpio
= 0x1b,
887 .tuner_sif_gpio
= 0x05,
889 .type
= CX231XX_VMUX_TELEVISION
,
890 .vmux
= CX231XX_VIN_1_1
,
891 .amux
= CX231XX_AMUX_VIDEO
,
893 .type
= CX231XX_VMUX_COMPOSITE1
,
894 .vmux
= CX231XX_VIN_2_1
,
895 .amux
= CX231XX_AMUX_LINE_IN
,
899 [CX231XX_BOARD_THE_IMAGING_SOURCE_DFG_USB2_PRO
] = {
900 .name
= "The Imaging Source DFG/USB2pro",
901 .tuner_type
= TUNER_ABSENT
,
902 .decoder
= CX231XX_AVDECODER
,
903 .output_mode
= OUT_MODE_VIP11
,
904 .demod_xfer_mode
= 0,
905 .ctl_pin_status_mask
= 0xFFFFFFC4,
906 .agc_analog_digital_select_gpio
= 0x0c,
907 .gpio_pin_status_mask
= 0x4001000,
908 .norm
= V4L2_STD_PAL
,
912 .type
= CX231XX_VMUX_COMPOSITE1
,
913 .vmux
= CX231XX_VIN_1_1
,
914 .amux
= CX231XX_AMUX_LINE_IN
,
917 .type
= CX231XX_VMUX_SVIDEO
,
918 .vmux
= CX231XX_VIN_2_1
|
919 (CX231XX_VIN_2_2
<< 8) |
921 .amux
= CX231XX_AMUX_LINE_IN
,
925 [CX231XX_BOARD_HAUPPAUGE_935C
] = {
926 .name
= "Hauppauge WinTV-HVR-935C",
927 .tuner_type
= TUNER_ABSENT
,
929 .tuner_gpio
= RDE250_XCV_TUNER
,
930 .tuner_sif_gpio
= 0x05,
931 .tuner_scl_gpio
= 0x1a,
932 .tuner_sda_gpio
= 0x1b,
933 .decoder
= CX231XX_AVDECODER
,
934 .output_mode
= OUT_MODE_VIP11
,
935 .demod_xfer_mode
= 0,
936 .ctl_pin_status_mask
= 0xFFFFFFC4,
937 .agc_analog_digital_select_gpio
= 0x0c,
938 .gpio_pin_status_mask
= 0x4001000,
939 .tuner_i2c_master
= I2C_1_MUX_3
,
940 .demod_i2c_master
= I2C_1_MUX_3
,
942 .demod_addr
= 0x64, /* 0xc8 >> 1 */
943 .norm
= V4L2_STD_PAL
,
946 .type
= CX231XX_VMUX_TELEVISION
,
947 .vmux
= CX231XX_VIN_3_1
,
948 .amux
= CX231XX_AMUX_VIDEO
,
951 .type
= CX231XX_VMUX_COMPOSITE1
,
952 .vmux
= CX231XX_VIN_2_1
,
953 .amux
= CX231XX_AMUX_LINE_IN
,
956 .type
= CX231XX_VMUX_SVIDEO
,
957 .vmux
= CX231XX_VIN_1_1
|
958 (CX231XX_VIN_1_2
<< 8) |
960 .amux
= CX231XX_AMUX_LINE_IN
,
964 [CX231XX_BOARD_HAUPPAUGE_975
] = {
965 .name
= "Hauppauge WinTV-HVR-975",
966 .tuner_type
= TUNER_ABSENT
,
968 .tuner_gpio
= RDE250_XCV_TUNER
,
969 .tuner_sif_gpio
= 0x05,
970 .tuner_scl_gpio
= 0x1a,
971 .tuner_sda_gpio
= 0x1b,
972 .decoder
= CX231XX_AVDECODER
,
973 .output_mode
= OUT_MODE_VIP11
,
974 .demod_xfer_mode
= 0,
975 .ctl_pin_status_mask
= 0xFFFFFFC4,
976 .agc_analog_digital_select_gpio
= 0x0c,
977 .gpio_pin_status_mask
= 0x4001000,
978 .tuner_i2c_master
= I2C_1_MUX_3
,
979 .demod_i2c_master
= I2C_1_MUX_3
,
981 .demod_addr
= 0x59, /* 0xb2 >> 1 */
982 .demod_addr2
= 0x64, /* 0xc8 >> 1 */
983 .norm
= V4L2_STD_ALL
,
986 .type
= CX231XX_VMUX_TELEVISION
,
987 .vmux
= CX231XX_VIN_3_1
,
988 .amux
= CX231XX_AMUX_VIDEO
,
991 .type
= CX231XX_VMUX_COMPOSITE1
,
992 .vmux
= CX231XX_VIN_2_1
,
993 .amux
= CX231XX_AMUX_LINE_IN
,
996 .type
= CX231XX_VMUX_SVIDEO
,
997 .vmux
= CX231XX_VIN_1_1
|
998 (CX231XX_VIN_1_2
<< 8) |
1000 .amux
= CX231XX_AMUX_LINE_IN
,
1005 const unsigned int cx231xx_bcount
= ARRAY_SIZE(cx231xx_boards
);
1007 /* table of devices that work with this driver */
1008 struct usb_device_id cx231xx_id_table
[] = {
1009 {USB_DEVICE(0x1D19, 0x6109),
1010 .driver_info
= CX231XX_BOARD_PV_XCAPTURE_USB
},
1011 {USB_DEVICE(0x0572, 0x5A3C),
1012 .driver_info
= CX231XX_BOARD_UNKNOWN
},
1013 {USB_DEVICE(0x0572, 0x58A2),
1014 .driver_info
= CX231XX_BOARD_CNXT_CARRAERA
},
1015 {USB_DEVICE(0x0572, 0x58A1),
1016 .driver_info
= CX231XX_BOARD_CNXT_SHELBY
},
1017 {USB_DEVICE(0x0572, 0x58A4),
1018 .driver_info
= CX231XX_BOARD_CNXT_RDE_253S
},
1019 {USB_DEVICE(0x0572, 0x58A5),
1020 .driver_info
= CX231XX_BOARD_CNXT_RDU_253S
},
1021 {USB_DEVICE(0x0572, 0x58A6),
1022 .driver_info
= CX231XX_BOARD_CNXT_VIDEO_GRABBER
},
1023 {USB_DEVICE(0x0572, 0x589E),
1024 .driver_info
= CX231XX_BOARD_CNXT_RDE_250
},
1025 {USB_DEVICE(0x0572, 0x58A0),
1026 .driver_info
= CX231XX_BOARD_CNXT_RDU_250
},
1027 /* AverMedia DVD EZMaker 7 */
1028 {USB_DEVICE(0x07ca, 0xc039),
1029 .driver_info
= CX231XX_BOARD_CNXT_VIDEO_GRABBER
},
1030 {USB_DEVICE(0x2040, 0xb110),
1031 .driver_info
= CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL
},
1032 {USB_DEVICE(0x2040, 0xb111),
1033 .driver_info
= CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC
},
1034 {USB_DEVICE(0x2040, 0xb120),
1035 .driver_info
= CX231XX_BOARD_HAUPPAUGE_EXETER
},
1036 {USB_DEVICE(0x2040, 0xb123),
1037 .driver_info
= CX231XX_BOARD_HAUPPAUGE_955Q
},
1038 {USB_DEVICE(0x2040, 0xb151),
1039 .driver_info
= CX231XX_BOARD_HAUPPAUGE_935C
},
1040 {USB_DEVICE(0x2040, 0xb150),
1041 .driver_info
= CX231XX_BOARD_HAUPPAUGE_975
},
1042 {USB_DEVICE(0x2040, 0xb130),
1043 .driver_info
= CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx
},
1044 {USB_DEVICE(0x2040, 0xb131),
1045 .driver_info
= CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx
},
1046 /* Hauppauge WinTV-HVR-900-H */
1047 {USB_DEVICE(0x2040, 0xb138),
1048 .driver_info
= CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx
},
1049 /* Hauppauge WinTV-HVR-901-H */
1050 {USB_DEVICE(0x2040, 0xb139),
1051 .driver_info
= CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx
},
1052 {USB_DEVICE(0x2040, 0xb140),
1053 .driver_info
= CX231XX_BOARD_HAUPPAUGE_EXETER
},
1054 {USB_DEVICE(0x2040, 0xc200),
1055 .driver_info
= CX231XX_BOARD_HAUPPAUGE_USBLIVE2
},
1056 /* PCTV QuatroStick 521e */
1057 {USB_DEVICE(0x2013, 0x0259),
1058 .driver_info
= CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx
},
1059 /* PCTV QuatroStick 522e */
1060 {USB_DEVICE(0x2013, 0x025e),
1061 .driver_info
= CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx
},
1062 {USB_DEVICE_VER(USB_VID_PIXELVIEW
, USB_PID_PIXELVIEW_SBTVD
, 0x4000, 0x4001),
1063 .driver_info
= CX231XX_BOARD_PV_PLAYTV_USB_HYBRID
},
1064 {USB_DEVICE(USB_VID_PIXELVIEW
, 0x5014),
1065 .driver_info
= CX231XX_BOARD_PV_XCAPTURE_USB
},
1066 {USB_DEVICE(0x1b80, 0xe424),
1067 .driver_info
= CX231XX_BOARD_KWORLD_UB430_USB_HYBRID
},
1068 {USB_DEVICE(0x1b80, 0xe421),
1069 .driver_info
= CX231XX_BOARD_KWORLD_UB445_USB_HYBRID
},
1070 {USB_DEVICE(0x1f4d, 0x0237),
1071 .driver_info
= CX231XX_BOARD_ICONBIT_U100
},
1072 {USB_DEVICE(0x0fd9, 0x0037),
1073 .driver_info
= CX231XX_BOARD_ELGATO_VIDEO_CAPTURE_V2
},
1074 {USB_DEVICE(0x1f4d, 0x0102),
1075 .driver_info
= CX231XX_BOARD_OTG102
},
1076 {USB_DEVICE(USB_VID_TERRATEC
, 0x00a6),
1077 .driver_info
= CX231XX_BOARD_TERRATEC_GRABBY
},
1078 {USB_DEVICE(0x1b80, 0xd3b2),
1079 .driver_info
= CX231XX_BOARD_EVROMEDIA_FULL_HYBRID_FULLHD
},
1080 {USB_DEVICE(0x15f4, 0x0135),
1081 .driver_info
= CX231XX_BOARD_ASTROMETA_T2HYBRID
},
1082 {USB_DEVICE(0x199e, 0x8002),
1083 .driver_info
= CX231XX_BOARD_THE_IMAGING_SOURCE_DFG_USB2_PRO
},
1087 MODULE_DEVICE_TABLE(usb
, cx231xx_id_table
);
1089 /* cx231xx_tuner_callback
1090 * will be used to reset XC5000 tuner using GPIO pin
1093 int cx231xx_tuner_callback(void *ptr
, int component
, int command
, int arg
)
1096 struct cx231xx
*dev
= ptr
;
1098 if (dev
->tuner_type
== TUNER_XC5000
) {
1099 if (command
== XC5000_TUNER_RESET
) {
1101 "Tuner CB: RESET: cmd %d : tuner type %d\n",
1102 command
, dev
->tuner_type
);
1103 cx231xx_set_gpio_value(dev
, dev
->board
.tuner_gpio
->bit
,
1106 cx231xx_set_gpio_value(dev
, dev
->board
.tuner_gpio
->bit
,
1109 cx231xx_set_gpio_value(dev
, dev
->board
.tuner_gpio
->bit
,
1113 } else if (dev
->tuner_type
== TUNER_NXP_TDA18271
) {
1115 case TDA18271_CALLBACK_CMD_AGC_ENABLE
:
1116 if (dev
->model
== CX231XX_BOARD_PV_PLAYTV_USB_HYBRID
)
1117 rc
= cx231xx_set_agc_analog_digital_mux_select(dev
, arg
);
1126 EXPORT_SYMBOL_GPL(cx231xx_tuner_callback
);
1128 static void cx231xx_reset_out(struct cx231xx
*dev
)
1130 cx231xx_set_gpio_value(dev
, CX23417_RESET
, 1);
1132 cx231xx_set_gpio_value(dev
, CX23417_RESET
, 0);
1134 cx231xx_set_gpio_value(dev
, CX23417_RESET
, 1);
1137 static void cx231xx_enable_OSC(struct cx231xx
*dev
)
1139 cx231xx_set_gpio_value(dev
, CX23417_OSC_EN
, 1);
1142 static void cx231xx_sleep_s5h1432(struct cx231xx
*dev
)
1144 cx231xx_set_gpio_value(dev
, SLEEP_S5H1432
, 0);
1147 static inline void cx231xx_set_model(struct cx231xx
*dev
)
1149 dev
->board
= cx231xx_boards
[dev
->model
];
1152 /* Since cx231xx_pre_card_setup() requires a proper dev->model,
1153 * this won't work for boards with generic PCI IDs
1155 void cx231xx_pre_card_setup(struct cx231xx
*dev
)
1157 dev_info(dev
->dev
, "Identified as %s (card=%d)\n",
1158 dev
->board
.name
, dev
->model
);
1160 if (CX231XX_BOARD_ASTROMETA_T2HYBRID
== dev
->model
) {
1161 /* turn on demodulator chip */
1162 cx231xx_set_gpio_value(dev
, 0x03, 0x01);
1165 /* set the direction for GPIO pins */
1166 if (dev
->board
.tuner_gpio
) {
1167 cx231xx_set_gpio_direction(dev
, dev
->board
.tuner_gpio
->bit
, 1);
1168 cx231xx_set_gpio_value(dev
, dev
->board
.tuner_gpio
->bit
, 1);
1170 if (dev
->board
.tuner_sif_gpio
>= 0)
1171 cx231xx_set_gpio_direction(dev
, dev
->board
.tuner_sif_gpio
, 1);
1173 /* request some modules if any required */
1175 /* set the mode to Analog mode initially */
1176 cx231xx_set_mode(dev
, CX231XX_ANALOG_MODE
);
1179 /* cx231xx_set_mode(dev, CX231XX_SUSPEND); */
1183 static void cx231xx_config_tuner(struct cx231xx
*dev
)
1185 struct tuner_setup tun_setup
;
1186 struct v4l2_frequency f
;
1188 if (dev
->tuner_type
== TUNER_ABSENT
)
1191 tun_setup
.mode_mask
= T_ANALOG_TV
| T_RADIO
;
1192 tun_setup
.type
= dev
->tuner_type
;
1193 tun_setup
.addr
= dev
->tuner_addr
;
1194 tun_setup
.tuner_callback
= cx231xx_tuner_callback
;
1196 tuner_call(dev
, tuner
, s_type_addr
, &tun_setup
);
1199 if (tun_setup
.type
== TUNER_XC5000
) {
1200 static struct xc2028_ctrl ctrl
= {
1201 .fname
= XC5000_DEFAULT_FIRMWARE
,
1205 struct v4l2_priv_tun_config cfg
= {
1206 .tuner
= dev
->tuner_type
,
1209 tuner_call(dev
, tuner
, s_config
, &cfg
);
1212 /* configure tuner */
1214 f
.type
= V4L2_TUNER_ANALOG_TV
;
1215 f
.frequency
= 9076; /* just a magic number */
1216 dev
->ctl_freq
= f
.frequency
;
1217 call_all(dev
, tuner
, s_frequency
, &f
);
1221 static int read_eeprom(struct cx231xx
*dev
, struct i2c_client
*client
,
1222 u8
*eedata
, int len
)
1225 u8 start_offset
= 0;
1227 u8
*eedata_cur
= eedata
;
1229 struct i2c_msg msg_write
= { .addr
= client
->addr
, .flags
= 0,
1230 .buf
= &start_offset
, .len
= 1 };
1231 struct i2c_msg msg_read
= { .addr
= client
->addr
, .flags
= I2C_M_RD
};
1233 /* start reading at offset 0 */
1234 ret
= i2c_transfer(client
->adapter
, &msg_write
, 1);
1236 dev_err(dev
->dev
, "Can't read eeprom\n");
1240 while (len_todo
> 0) {
1241 msg_read
.len
= (len_todo
> 64) ? 64 : len_todo
;
1242 msg_read
.buf
= eedata_cur
;
1244 ret
= i2c_transfer(client
->adapter
, &msg_read
, 1);
1246 dev_err(dev
->dev
, "Can't read eeprom\n");
1249 eedata_cur
+= msg_read
.len
;
1250 len_todo
-= msg_read
.len
;
1253 for (i
= 0; i
+ 15 < len
; i
+= 16)
1254 dev_dbg(dev
->dev
, "i2c eeprom %02x: %*ph\n",
1260 void cx231xx_card_setup(struct cx231xx
*dev
)
1263 cx231xx_set_model(dev
);
1265 dev
->tuner_type
= cx231xx_boards
[dev
->model
].tuner_type
;
1266 if (cx231xx_boards
[dev
->model
].tuner_addr
)
1267 dev
->tuner_addr
= cx231xx_boards
[dev
->model
].tuner_addr
;
1269 /* request some modules */
1270 if (dev
->board
.decoder
== CX231XX_AVDECODER
) {
1271 dev
->sd_cx25840
= v4l2_i2c_new_subdev(&dev
->v4l2_dev
,
1272 cx231xx_get_i2c_adap(dev
, I2C_0
),
1273 "cx25840", 0x88 >> 1, NULL
);
1274 if (dev
->sd_cx25840
== NULL
)
1276 "cx25840 subdev registration failure\n");
1277 cx25840_call(dev
, core
, load_fw
);
1281 /* Initialize the tuner */
1282 if (dev
->board
.tuner_type
!= TUNER_ABSENT
) {
1283 struct i2c_adapter
*tuner_i2c
= cx231xx_get_i2c_adap(dev
,
1284 dev
->board
.tuner_i2c_master
);
1285 dev
->sd_tuner
= v4l2_i2c_new_subdev(&dev
->v4l2_dev
,
1288 dev
->tuner_addr
, NULL
);
1289 if (dev
->sd_tuner
== NULL
)
1291 "tuner subdev registration failure\n");
1293 cx231xx_config_tuner(dev
);
1296 switch (dev
->model
) {
1297 case CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx
:
1298 case CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx
:
1299 case CX231XX_BOARD_HAUPPAUGE_955Q
:
1300 case CX231XX_BOARD_HAUPPAUGE_935C
:
1301 case CX231XX_BOARD_HAUPPAUGE_975
:
1304 struct tveeprom tvee
;
1306 struct i2c_client client
;
1308 struct eeprom
*e
= kzalloc(sizeof(*e
), GFP_KERNEL
);
1312 "failed to allocate memory to read eeprom\n");
1315 e
->client
.adapter
= cx231xx_get_i2c_adap(dev
, I2C_1_MUX_1
);
1316 e
->client
.addr
= 0xa0 >> 1;
1318 read_eeprom(dev
, &e
->client
, e
->eeprom
, sizeof(e
->eeprom
));
1319 tveeprom_hauppauge_analog(&e
->tvee
, e
->eeprom
+ 0xc0);
1329 * inits registers with sane defaults
1331 int cx231xx_config(struct cx231xx
*dev
)
1333 /* TBD need to add cx231xx specific code */
1339 * cx231xx_config_i2c()
1340 * configure i2c attached devices
1342 void cx231xx_config_i2c(struct cx231xx
*dev
)
1344 /* u32 input = INPUT(dev->video_input)->vmux; */
1346 call_all(dev
, video
, s_stream
, 1);
1349 static void cx231xx_unregister_media_device(struct cx231xx
*dev
)
1351 #ifdef CONFIG_MEDIA_CONTROLLER
1352 if (dev
->media_dev
) {
1353 media_device_unregister(dev
->media_dev
);
1354 media_device_cleanup(dev
->media_dev
);
1355 kfree(dev
->media_dev
);
1356 dev
->media_dev
= NULL
;
1362 * cx231xx_realease_resources()
1363 * unregisters the v4l2,i2c and usb devices
1364 * called when the device gets disconected or at module unload
1366 void cx231xx_release_resources(struct cx231xx
*dev
)
1368 cx231xx_ir_exit(dev
);
1370 cx231xx_release_analog_resources(dev
);
1372 cx231xx_remove_from_devlist(dev
);
1374 /* Release I2C buses */
1375 cx231xx_dev_uninit(dev
);
1377 /* delete v4l2 device */
1378 v4l2_device_unregister(&dev
->v4l2_dev
);
1380 cx231xx_unregister_media_device(dev
);
1382 usb_put_dev(dev
->udev
);
1384 /* Mark device as unused */
1385 clear_bit(dev
->devno
, &cx231xx_devused
);
1388 static int cx231xx_media_device_init(struct cx231xx
*dev
,
1389 struct usb_device
*udev
)
1391 #ifdef CONFIG_MEDIA_CONTROLLER
1392 struct media_device
*mdev
;
1394 mdev
= kzalloc(sizeof(*mdev
), GFP_KERNEL
);
1398 media_device_usb_init(mdev
, udev
, dev
->board
.name
);
1400 dev
->media_dev
= mdev
;
1406 * cx231xx_init_dev()
1407 * allocates and inits the device structs, registers i2c bus and v4l device
1409 static int cx231xx_init_dev(struct cx231xx
*dev
, struct usb_device
*udev
,
1412 int retval
= -ENOMEM
;
1413 unsigned int maxh
, maxw
;
1416 mutex_init(&dev
->lock
);
1417 mutex_init(&dev
->ctrl_urb_lock
);
1418 mutex_init(&dev
->gpio_i2c_lock
);
1419 mutex_init(&dev
->i2c_lock
);
1421 spin_lock_init(&dev
->video_mode
.slock
);
1422 spin_lock_init(&dev
->vbi_mode
.slock
);
1423 spin_lock_init(&dev
->sliced_cc_mode
.slock
);
1425 init_waitqueue_head(&dev
->open
);
1426 init_waitqueue_head(&dev
->wait_frame
);
1427 init_waitqueue_head(&dev
->wait_stream
);
1429 dev
->cx231xx_read_ctrl_reg
= cx231xx_read_ctrl_reg
;
1430 dev
->cx231xx_write_ctrl_reg
= cx231xx_write_ctrl_reg
;
1431 dev
->cx231xx_send_usb_command
= cx231xx_send_usb_command
;
1432 dev
->cx231xx_gpio_i2c_read
= cx231xx_gpio_i2c_read
;
1433 dev
->cx231xx_gpio_i2c_write
= cx231xx_gpio_i2c_write
;
1435 /* Query cx231xx to find what pcb config it is related to */
1436 retval
= initialize_cx231xx(dev
);
1438 dev_err(dev
->dev
, "Failed to read PCB config\n");
1442 /*To workaround error number=-71 on EP0 for VideoGrabber,
1443 need set alt here.*/
1444 if (dev
->model
== CX231XX_BOARD_CNXT_VIDEO_GRABBER
||
1445 dev
->model
== CX231XX_BOARD_HAUPPAUGE_USBLIVE2
) {
1446 cx231xx_set_alt_setting(dev
, INDEX_VIDEO
, 3);
1447 cx231xx_set_alt_setting(dev
, INDEX_VANC
, 1);
1449 /* Cx231xx pre card setup */
1450 cx231xx_pre_card_setup(dev
);
1452 retval
= cx231xx_config(dev
);
1454 dev_err(dev
->dev
, "error configuring device\n");
1458 /* set default norm */
1459 dev
->norm
= dev
->board
.norm
;
1461 /* register i2c bus */
1462 retval
= cx231xx_dev_init(dev
);
1465 "%s: cx231xx_i2c_register - errCode [%d]!\n",
1470 /* Do board specific init */
1471 cx231xx_card_setup(dev
);
1473 /* configure the device */
1474 cx231xx_config_i2c(dev
);
1476 maxw
= norm_maxw(dev
);
1477 maxh
= norm_maxh(dev
);
1479 /* set default image size */
1482 dev
->interlaced
= 0;
1483 dev
->video_input
= 0;
1485 retval
= cx231xx_config(dev
);
1487 dev_err(dev
->dev
, "%s: cx231xx_config - errCode [%d]!\n",
1492 /* init video dma queues */
1493 INIT_LIST_HEAD(&dev
->video_mode
.vidq
.active
);
1494 INIT_LIST_HEAD(&dev
->video_mode
.vidq
.queued
);
1496 /* init vbi dma queues */
1497 INIT_LIST_HEAD(&dev
->vbi_mode
.vidq
.active
);
1498 INIT_LIST_HEAD(&dev
->vbi_mode
.vidq
.queued
);
1500 /* Reset other chips required if they are tied up with GPIO pins */
1501 cx231xx_add_into_devlist(dev
);
1503 if (dev
->board
.has_417
) {
1504 dev_info(dev
->dev
, "attach 417 %d\n", dev
->model
);
1505 if (cx231xx_417_register(dev
) < 0) {
1507 "%s() Failed to register 417 on VID_B\n",
1512 retval
= cx231xx_register_analog_devices(dev
);
1516 cx231xx_ir_init(dev
);
1518 cx231xx_init_extension(dev
);
1522 cx231xx_unregister_media_device(dev
);
1523 cx231xx_release_analog_resources(dev
);
1524 cx231xx_remove_from_devlist(dev
);
1526 cx231xx_dev_uninit(dev
);
1530 #if defined(CONFIG_MODULES) && defined(MODULE)
1531 static void request_module_async(struct work_struct
*work
)
1533 struct cx231xx
*dev
= container_of(work
,
1534 struct cx231xx
, request_module_wk
);
1536 if (dev
->has_alsa_audio
)
1537 request_module("cx231xx-alsa");
1539 if (dev
->board
.has_dvb
)
1540 request_module("cx231xx-dvb");
1544 static void request_modules(struct cx231xx
*dev
)
1546 INIT_WORK(&dev
->request_module_wk
, request_module_async
);
1547 schedule_work(&dev
->request_module_wk
);
1550 static void flush_request_modules(struct cx231xx
*dev
)
1552 flush_work(&dev
->request_module_wk
);
1555 #define request_modules(dev)
1556 #define flush_request_modules(dev)
1557 #endif /* CONFIG_MODULES */
1559 static int cx231xx_init_v4l2(struct cx231xx
*dev
,
1560 struct usb_device
*udev
,
1561 struct usb_interface
*interface
,
1564 struct usb_interface
*uif
;
1569 /* compute alternate max packet sizes for video */
1570 idx
= dev
->current_pcb_config
.hs_config_info
[0].interface_info
.video_index
+ 1;
1571 if (idx
>= dev
->max_iad_interface_count
) {
1573 "Video PCB interface #%d doesn't exist\n", idx
);
1577 uif
= udev
->actconfig
->interface
[idx
];
1579 if (uif
->altsetting
[0].desc
.bNumEndpoints
< isoc_pipe
+ 1)
1582 dev
->video_mode
.end_point_addr
= uif
->altsetting
[0].endpoint
[isoc_pipe
].desc
.bEndpointAddress
;
1583 dev
->video_mode
.num_alt
= uif
->num_altsetting
;
1586 "video EndPoint Addr 0x%x, Alternate settings: %i\n",
1587 dev
->video_mode
.end_point_addr
,
1588 dev
->video_mode
.num_alt
);
1590 dev
->video_mode
.alt_max_pkt_size
= devm_kmalloc_array(&udev
->dev
, 32, dev
->video_mode
.num_alt
, GFP_KERNEL
);
1591 if (dev
->video_mode
.alt_max_pkt_size
== NULL
)
1594 for (i
= 0; i
< dev
->video_mode
.num_alt
; i
++) {
1597 if (uif
->altsetting
[i
].desc
.bNumEndpoints
< isoc_pipe
+ 1)
1600 tmp
= le16_to_cpu(uif
->altsetting
[i
].endpoint
[isoc_pipe
].desc
.wMaxPacketSize
);
1601 dev
->video_mode
.alt_max_pkt_size
[i
] = (tmp
& 0x07ff) * (((tmp
& 0x1800) >> 11) + 1);
1603 "Alternate setting %i, max size= %i\n", i
,
1604 dev
->video_mode
.alt_max_pkt_size
[i
]);
1609 idx
= dev
->current_pcb_config
.hs_config_info
[0].interface_info
.vanc_index
+ 1;
1610 if (idx
>= dev
->max_iad_interface_count
) {
1612 "VBI PCB interface #%d doesn't exist\n", idx
);
1615 uif
= udev
->actconfig
->interface
[idx
];
1617 if (uif
->altsetting
[0].desc
.bNumEndpoints
< isoc_pipe
+ 1)
1620 dev
->vbi_mode
.end_point_addr
=
1621 uif
->altsetting
[0].endpoint
[isoc_pipe
].desc
.
1624 dev
->vbi_mode
.num_alt
= uif
->num_altsetting
;
1626 "VBI EndPoint Addr 0x%x, Alternate settings: %i\n",
1627 dev
->vbi_mode
.end_point_addr
,
1628 dev
->vbi_mode
.num_alt
);
1630 /* compute alternate max packet sizes for vbi */
1631 dev
->vbi_mode
.alt_max_pkt_size
= devm_kmalloc_array(&udev
->dev
, 32, dev
->vbi_mode
.num_alt
, GFP_KERNEL
);
1632 if (dev
->vbi_mode
.alt_max_pkt_size
== NULL
)
1635 for (i
= 0; i
< dev
->vbi_mode
.num_alt
; i
++) {
1638 if (uif
->altsetting
[i
].desc
.bNumEndpoints
< isoc_pipe
+ 1)
1641 tmp
= le16_to_cpu(uif
->altsetting
[i
].endpoint
[isoc_pipe
].
1642 desc
.wMaxPacketSize
);
1643 dev
->vbi_mode
.alt_max_pkt_size
[i
] =
1644 (tmp
& 0x07ff) * (((tmp
& 0x1800) >> 11) + 1);
1646 "Alternate setting %i, max size= %i\n", i
,
1647 dev
->vbi_mode
.alt_max_pkt_size
[i
]);
1650 /* Sliced CC VBI init */
1652 /* compute alternate max packet sizes for sliced CC */
1653 idx
= dev
->current_pcb_config
.hs_config_info
[0].interface_info
.hanc_index
+ 1;
1654 if (idx
>= dev
->max_iad_interface_count
) {
1656 "Sliced CC PCB interface #%d doesn't exist\n", idx
);
1659 uif
= udev
->actconfig
->interface
[idx
];
1661 if (uif
->altsetting
[0].desc
.bNumEndpoints
< isoc_pipe
+ 1)
1664 dev
->sliced_cc_mode
.end_point_addr
=
1665 uif
->altsetting
[0].endpoint
[isoc_pipe
].desc
.
1668 dev
->sliced_cc_mode
.num_alt
= uif
->num_altsetting
;
1670 "sliced CC EndPoint Addr 0x%x, Alternate settings: %i\n",
1671 dev
->sliced_cc_mode
.end_point_addr
,
1672 dev
->sliced_cc_mode
.num_alt
);
1673 dev
->sliced_cc_mode
.alt_max_pkt_size
= devm_kmalloc_array(&udev
->dev
, 32, dev
->sliced_cc_mode
.num_alt
, GFP_KERNEL
);
1674 if (dev
->sliced_cc_mode
.alt_max_pkt_size
== NULL
)
1677 for (i
= 0; i
< dev
->sliced_cc_mode
.num_alt
; i
++) {
1680 if (uif
->altsetting
[i
].desc
.bNumEndpoints
< isoc_pipe
+ 1)
1683 tmp
= le16_to_cpu(uif
->altsetting
[i
].endpoint
[isoc_pipe
].
1684 desc
.wMaxPacketSize
);
1685 dev
->sliced_cc_mode
.alt_max_pkt_size
[i
] =
1686 (tmp
& 0x07ff) * (((tmp
& 0x1800) >> 11) + 1);
1688 "Alternate setting %i, max size= %i\n", i
,
1689 dev
->sliced_cc_mode
.alt_max_pkt_size
[i
]);
1696 * cx231xx_usb_probe()
1697 * checks for supported devices
1699 static int cx231xx_usb_probe(struct usb_interface
*interface
,
1700 const struct usb_device_id
*id
)
1702 struct usb_device
*udev
;
1703 struct device
*d
= &interface
->dev
;
1704 struct usb_interface
*uif
;
1705 struct cx231xx
*dev
= NULL
;
1706 int retval
= -ENODEV
;
1708 int i
, isoc_pipe
= 0;
1711 struct usb_interface_assoc_descriptor
*assoc_desc
;
1713 ifnum
= interface
->altsetting
[0].desc
.bInterfaceNumber
;
1716 * Interface number 0 - IR interface (handled by mceusb driver)
1717 * Interface number 1 - AV interface (handled by this driver)
1722 /* Check to see next free device and mark as used */
1724 nr
= find_first_zero_bit(&cx231xx_devused
, CX231XX_MAXBOARDS
);
1725 if (nr
>= CX231XX_MAXBOARDS
) {
1726 /* No free device slots */
1728 "Supports only %i devices.\n",
1732 } while (test_and_set_bit(nr
, &cx231xx_devused
));
1734 udev
= usb_get_dev(interface_to_usbdev(interface
));
1736 /* allocate memory for our device state and initialize it */
1737 dev
= devm_kzalloc(&udev
->dev
, sizeof(*dev
), GFP_KERNEL
);
1743 snprintf(dev
->name
, 29, "cx231xx #%d", nr
);
1745 dev
->model
= id
->driver_info
;
1746 dev
->video_mode
.alt
= -1;
1749 cx231xx_set_model(dev
);
1751 dev
->interface_count
++;
1752 /* reset gpio dir and value */
1755 dev
->xc_fw_load_done
= 0;
1756 dev
->has_alsa_audio
= 1;
1757 dev
->power_mode
= -1;
1758 atomic_set(&dev
->devlist_count
, 0);
1760 /* 0 - vbi ; 1 -sliced cc mode */
1761 dev
->vbi_or_sliced_cc_mode
= 0;
1763 /* get maximum no.of IAD interfaces */
1764 dev
->max_iad_interface_count
= udev
->config
->desc
.bNumInterfaces
;
1766 /* init CIR module TBD */
1768 /*mode_tv: digital=1 or analog=0*/
1771 dev
->USE_ISO
= transfer_mode
;
1773 switch (udev
->speed
) {
1777 case USB_SPEED_UNKNOWN
:
1778 case USB_SPEED_FULL
:
1781 case USB_SPEED_HIGH
:
1789 "New device %s %s @ %s Mbps (%04x:%04x) with %d interfaces\n",
1790 udev
->manufacturer
? udev
->manufacturer
: "",
1791 udev
->product
? udev
->product
: "",
1793 le16_to_cpu(udev
->descriptor
.idVendor
),
1794 le16_to_cpu(udev
->descriptor
.idProduct
),
1795 dev
->max_iad_interface_count
);
1797 /* increment interface count */
1798 dev
->interface_count
++;
1800 /* get device number */
1803 assoc_desc
= udev
->actconfig
->intf_assoc
[0];
1804 if (!assoc_desc
|| assoc_desc
->bFirstInterface
!= ifnum
) {
1805 dev_err(d
, "Not found matching IAD interface\n");
1810 dev_dbg(d
, "registering interface %d\n", ifnum
);
1812 /* save our data pointer in this interface device */
1813 usb_set_intfdata(interface
, dev
);
1815 /* Initialize the media controller */
1816 retval
= cx231xx_media_device_init(dev
, udev
);
1818 dev_err(d
, "cx231xx_media_device_init failed\n");
1819 goto err_media_init
;
1822 /* Create v4l2 device */
1823 #ifdef CONFIG_MEDIA_CONTROLLER
1824 dev
->v4l2_dev
.mdev
= dev
->media_dev
;
1826 retval
= v4l2_device_register(&interface
->dev
, &dev
->v4l2_dev
);
1828 dev_err(d
, "v4l2_device_register failed\n");
1832 /* allocate device struct */
1833 retval
= cx231xx_init_dev(dev
, udev
, nr
);
1837 retval
= cx231xx_init_v4l2(dev
, udev
, interface
, isoc_pipe
);
1841 if (dev
->current_pcb_config
.ts1_source
!= 0xff) {
1842 /* compute alternate max packet sizes for TS1 */
1843 idx
= dev
->current_pcb_config
.hs_config_info
[0].interface_info
.ts1_index
+ 1;
1844 if (idx
>= dev
->max_iad_interface_count
) {
1845 dev_err(d
, "TS1 PCB interface #%d doesn't exist\n",
1850 uif
= udev
->actconfig
->interface
[idx
];
1852 if (uif
->altsetting
[0].desc
.bNumEndpoints
< isoc_pipe
+ 1) {
1857 dev
->ts1_mode
.end_point_addr
=
1858 uif
->altsetting
[0].endpoint
[isoc_pipe
].
1859 desc
.bEndpointAddress
;
1861 dev
->ts1_mode
.num_alt
= uif
->num_altsetting
;
1863 "TS EndPoint Addr 0x%x, Alternate settings: %i\n",
1864 dev
->ts1_mode
.end_point_addr
,
1865 dev
->ts1_mode
.num_alt
);
1867 dev
->ts1_mode
.alt_max_pkt_size
= devm_kmalloc_array(&udev
->dev
, 32, dev
->ts1_mode
.num_alt
, GFP_KERNEL
);
1868 if (dev
->ts1_mode
.alt_max_pkt_size
== NULL
) {
1873 for (i
= 0; i
< dev
->ts1_mode
.num_alt
; i
++) {
1876 if (uif
->altsetting
[i
].desc
.bNumEndpoints
< isoc_pipe
+ 1) {
1881 tmp
= le16_to_cpu(uif
->altsetting
[i
].
1882 endpoint
[isoc_pipe
].desc
.
1884 dev
->ts1_mode
.alt_max_pkt_size
[i
] =
1885 (tmp
& 0x07ff) * (((tmp
& 0x1800) >> 11) + 1);
1886 dev_dbg(d
, "Alternate setting %i, max size= %i\n",
1887 i
, dev
->ts1_mode
.alt_max_pkt_size
[i
]);
1891 if (dev
->model
== CX231XX_BOARD_CNXT_VIDEO_GRABBER
) {
1892 cx231xx_enable_OSC(dev
);
1893 cx231xx_reset_out(dev
);
1894 cx231xx_set_alt_setting(dev
, INDEX_VIDEO
, 3);
1897 if (dev
->model
== CX231XX_BOARD_CNXT_RDE_253S
)
1898 cx231xx_sleep_s5h1432(dev
);
1900 /* load other modules required */
1901 request_modules(dev
);
1903 #ifdef CONFIG_MEDIA_CONTROLLER
1904 /* Init entities at the Media Controller */
1905 cx231xx_v4l2_create_entities(dev
);
1907 retval
= v4l2_mc_create_media_graph(dev
->media_dev
);
1909 retval
= media_device_register(dev
->media_dev
);
1912 cx231xx_release_resources(dev
);
1916 /* cx231xx_uninit_dev: */
1917 cx231xx_close_extension(dev
);
1918 cx231xx_ir_exit(dev
);
1919 cx231xx_release_analog_resources(dev
);
1920 cx231xx_417_unregister(dev
);
1921 cx231xx_remove_from_devlist(dev
);
1922 cx231xx_dev_uninit(dev
);
1924 v4l2_device_unregister(&dev
->v4l2_dev
);
1926 cx231xx_unregister_media_device(dev
);
1928 usb_set_intfdata(interface
, NULL
);
1931 clear_bit(nr
, &cx231xx_devused
);
1936 * cx231xx_usb_disconnect()
1937 * called when the device gets diconencted
1938 * video device will be unregistered on v4l2_close in case it is still open
1940 static void cx231xx_usb_disconnect(struct usb_interface
*interface
)
1942 struct cx231xx
*dev
;
1944 dev
= usb_get_intfdata(interface
);
1945 usb_set_intfdata(interface
, NULL
);
1953 dev
->state
|= DEV_DISCONNECTED
;
1955 flush_request_modules(dev
);
1957 /* wait until all current v4l2 io is finished then deallocate
1959 mutex_lock(&dev
->lock
);
1961 wake_up_interruptible_all(&dev
->open
);
1965 "device %s is open! Deregistration and memory deallocation are deferred on close.\n",
1966 video_device_node_name(&dev
->vdev
));
1968 /* Even having users, it is safe to remove the RC i2c driver */
1969 cx231xx_ir_exit(dev
);
1972 cx231xx_uninit_isoc(dev
);
1974 cx231xx_uninit_bulk(dev
);
1975 wake_up_interruptible(&dev
->wait_frame
);
1976 wake_up_interruptible(&dev
->wait_stream
);
1980 cx231xx_close_extension(dev
);
1982 mutex_unlock(&dev
->lock
);
1985 cx231xx_release_resources(dev
);
1988 static struct usb_driver cx231xx_usb_driver
= {
1990 .probe
= cx231xx_usb_probe
,
1991 .disconnect
= cx231xx_usb_disconnect
,
1992 .id_table
= cx231xx_id_table
,
1995 module_usb_driver(cx231xx_usb_driver
);