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.
23 #include <linux/init.h>
24 #include <linux/module.h>
25 #include <linux/slab.h>
26 #include <linux/delay.h>
27 #include <linux/i2c.h>
28 #include <linux/usb.h>
29 #include <media/tuner.h>
30 #include <media/tveeprom.h>
31 #include <media/v4l2-common.h>
32 #include <media/v4l2-chip-ident.h>
34 #include <media/cx25840.h>
35 #include "dvb-usb-ids.h"
41 static int tuner
= -1;
42 module_param(tuner
, int, 0444);
43 MODULE_PARM_DESC(tuner
, "tuner type");
45 static int transfer_mode
= 1;
46 module_param(transfer_mode
, int, 0444);
47 MODULE_PARM_DESC(transfer_mode
, "transfer mode (1-ISO or 0-BULK)");
49 static unsigned int disable_ir
;
50 module_param(disable_ir
, int, 0444);
51 MODULE_PARM_DESC(disable_ir
, "disable infrared remote support");
53 /* Bitmask marking allocated devices from 0 to CX231XX_MAXBOARDS */
54 static unsigned long cx231xx_devused
;
57 * Reset sequences for analog/digital modes
60 static struct cx231xx_reg_seq RDE250_XCV_TUNER
[] = {
70 struct cx231xx_board cx231xx_boards
[] = {
71 [CX231XX_BOARD_UNKNOWN
] = {
72 .name
= "Unknown CX231xx video grabber",
73 .tuner_type
= TUNER_ABSENT
,
75 .type
= CX231XX_VMUX_TELEVISION
,
76 .vmux
= CX231XX_VIN_3_1
,
77 .amux
= CX231XX_AMUX_VIDEO
,
80 .type
= CX231XX_VMUX_COMPOSITE1
,
81 .vmux
= CX231XX_VIN_2_1
,
82 .amux
= CX231XX_AMUX_LINE_IN
,
85 .type
= CX231XX_VMUX_SVIDEO
,
86 .vmux
= CX231XX_VIN_1_1
|
87 (CX231XX_VIN_1_2
<< 8) |
89 .amux
= CX231XX_AMUX_LINE_IN
,
94 [CX231XX_BOARD_CNXT_CARRAERA
] = {
95 .name
= "Conexant Hybrid TV - CARRAERA",
96 .tuner_type
= TUNER_XC5000
,
98 .tuner_gpio
= RDE250_XCV_TUNER
,
99 .tuner_sif_gpio
= 0x05,
100 .tuner_scl_gpio
= 0x1a,
101 .tuner_sda_gpio
= 0x1b,
102 .decoder
= CX231XX_AVDECODER
,
103 .output_mode
= OUT_MODE_VIP11
,
104 .demod_xfer_mode
= 0,
105 .ctl_pin_status_mask
= 0xFFFFFFC4,
106 .agc_analog_digital_select_gpio
= 0x0c,
107 .gpio_pin_status_mask
= 0x4001000,
108 .tuner_i2c_master
= 1,
109 .demod_i2c_master
= 2,
112 .norm
= V4L2_STD_PAL
,
115 .type
= CX231XX_VMUX_TELEVISION
,
116 .vmux
= CX231XX_VIN_3_1
,
117 .amux
= CX231XX_AMUX_VIDEO
,
120 .type
= CX231XX_VMUX_COMPOSITE1
,
121 .vmux
= CX231XX_VIN_2_1
,
122 .amux
= CX231XX_AMUX_LINE_IN
,
125 .type
= CX231XX_VMUX_SVIDEO
,
126 .vmux
= CX231XX_VIN_1_1
|
127 (CX231XX_VIN_1_2
<< 8) |
129 .amux
= CX231XX_AMUX_LINE_IN
,
134 [CX231XX_BOARD_CNXT_SHELBY
] = {
135 .name
= "Conexant Hybrid TV - SHELBY",
136 .tuner_type
= TUNER_XC5000
,
138 .tuner_gpio
= RDE250_XCV_TUNER
,
139 .tuner_sif_gpio
= 0x05,
140 .tuner_scl_gpio
= 0x1a,
141 .tuner_sda_gpio
= 0x1b,
142 .decoder
= CX231XX_AVDECODER
,
143 .output_mode
= OUT_MODE_VIP11
,
144 .demod_xfer_mode
= 0,
145 .ctl_pin_status_mask
= 0xFFFFFFC4,
146 .agc_analog_digital_select_gpio
= 0x0c,
147 .gpio_pin_status_mask
= 0x4001000,
148 .tuner_i2c_master
= 1,
149 .demod_i2c_master
= 2,
152 .norm
= V4L2_STD_NTSC
,
155 .type
= CX231XX_VMUX_TELEVISION
,
156 .vmux
= CX231XX_VIN_3_1
,
157 .amux
= CX231XX_AMUX_VIDEO
,
160 .type
= CX231XX_VMUX_COMPOSITE1
,
161 .vmux
= CX231XX_VIN_2_1
,
162 .amux
= CX231XX_AMUX_LINE_IN
,
165 .type
= CX231XX_VMUX_SVIDEO
,
166 .vmux
= CX231XX_VIN_1_1
|
167 (CX231XX_VIN_1_2
<< 8) |
169 .amux
= CX231XX_AMUX_LINE_IN
,
174 [CX231XX_BOARD_CNXT_RDE_253S
] = {
175 .name
= "Conexant Hybrid TV - RDE253S",
176 .tuner_type
= TUNER_NXP_TDA18271
,
178 .tuner_gpio
= RDE250_XCV_TUNER
,
179 .tuner_sif_gpio
= 0x05,
180 .tuner_scl_gpio
= 0x1a,
181 .tuner_sda_gpio
= 0x1b,
182 .decoder
= CX231XX_AVDECODER
,
183 .output_mode
= OUT_MODE_VIP11
,
184 .demod_xfer_mode
= 0,
185 .ctl_pin_status_mask
= 0xFFFFFFC4,
186 .agc_analog_digital_select_gpio
= 0x1c,
187 .gpio_pin_status_mask
= 0x4001000,
188 .tuner_i2c_master
= 1,
189 .demod_i2c_master
= 2,
192 .norm
= V4L2_STD_PAL
,
195 .type
= CX231XX_VMUX_TELEVISION
,
196 .vmux
= CX231XX_VIN_3_1
,
197 .amux
= CX231XX_AMUX_VIDEO
,
200 .type
= CX231XX_VMUX_COMPOSITE1
,
201 .vmux
= CX231XX_VIN_2_1
,
202 .amux
= CX231XX_AMUX_LINE_IN
,
205 .type
= CX231XX_VMUX_SVIDEO
,
206 .vmux
= CX231XX_VIN_1_1
|
207 (CX231XX_VIN_1_2
<< 8) |
209 .amux
= CX231XX_AMUX_LINE_IN
,
215 [CX231XX_BOARD_CNXT_RDU_253S
] = {
216 .name
= "Conexant Hybrid TV - RDU253S",
217 .tuner_type
= TUNER_NXP_TDA18271
,
219 .tuner_gpio
= RDE250_XCV_TUNER
,
220 .tuner_sif_gpio
= 0x05,
221 .tuner_scl_gpio
= 0x1a,
222 .tuner_sda_gpio
= 0x1b,
223 .decoder
= CX231XX_AVDECODER
,
224 .output_mode
= OUT_MODE_VIP11
,
225 .demod_xfer_mode
= 0,
226 .ctl_pin_status_mask
= 0xFFFFFFC4,
227 .agc_analog_digital_select_gpio
= 0x1c,
228 .gpio_pin_status_mask
= 0x4001000,
229 .tuner_i2c_master
= 1,
230 .demod_i2c_master
= 2,
233 .norm
= V4L2_STD_PAL
,
236 .type
= CX231XX_VMUX_TELEVISION
,
237 .vmux
= CX231XX_VIN_3_1
,
238 .amux
= CX231XX_AMUX_VIDEO
,
241 .type
= CX231XX_VMUX_COMPOSITE1
,
242 .vmux
= CX231XX_VIN_2_1
,
243 .amux
= CX231XX_AMUX_LINE_IN
,
246 .type
= CX231XX_VMUX_SVIDEO
,
247 .vmux
= CX231XX_VIN_1_1
|
248 (CX231XX_VIN_1_2
<< 8) |
250 .amux
= CX231XX_AMUX_LINE_IN
,
255 [CX231XX_BOARD_CNXT_VIDEO_GRABBER
] = {
256 .name
= "Conexant VIDEO GRABBER",
257 .tuner_type
= TUNER_ABSENT
,
258 .decoder
= CX231XX_AVDECODER
,
259 .output_mode
= OUT_MODE_VIP11
,
260 .ctl_pin_status_mask
= 0xFFFFFFC4,
261 .agc_analog_digital_select_gpio
= 0x1c,
262 .gpio_pin_status_mask
= 0x4001000,
263 .norm
= V4L2_STD_PAL
,
266 .dont_use_port_3
= 1,
267 /* Actually, it has a 417, but it isn't working correctly.
268 * So set to 0 for now until someone can manage to get this
269 * to work reliably. */
273 .type
= CX231XX_VMUX_COMPOSITE1
,
274 .vmux
= CX231XX_VIN_2_1
,
275 .amux
= CX231XX_AMUX_LINE_IN
,
278 .type
= CX231XX_VMUX_SVIDEO
,
279 .vmux
= CX231XX_VIN_1_1
|
280 (CX231XX_VIN_1_2
<< 8) |
282 .amux
= CX231XX_AMUX_LINE_IN
,
287 [CX231XX_BOARD_CNXT_RDE_250
] = {
288 .name
= "Conexant Hybrid TV - rde 250",
289 .tuner_type
= TUNER_XC5000
,
291 .tuner_gpio
= RDE250_XCV_TUNER
,
292 .tuner_sif_gpio
= 0x05,
293 .tuner_scl_gpio
= 0x1a,
294 .tuner_sda_gpio
= 0x1b,
295 .decoder
= CX231XX_AVDECODER
,
296 .output_mode
= OUT_MODE_VIP11
,
297 .demod_xfer_mode
= 0,
298 .ctl_pin_status_mask
= 0xFFFFFFC4,
299 .agc_analog_digital_select_gpio
= 0x0c,
300 .gpio_pin_status_mask
= 0x4001000,
301 .tuner_i2c_master
= 1,
302 .demod_i2c_master
= 2,
305 .norm
= V4L2_STD_PAL
,
308 .type
= CX231XX_VMUX_TELEVISION
,
309 .vmux
= CX231XX_VIN_2_1
,
310 .amux
= CX231XX_AMUX_VIDEO
,
315 [CX231XX_BOARD_CNXT_RDU_250
] = {
316 .name
= "Conexant Hybrid TV - RDU 250",
317 .tuner_type
= TUNER_XC5000
,
319 .tuner_gpio
= RDE250_XCV_TUNER
,
320 .tuner_sif_gpio
= 0x05,
321 .tuner_scl_gpio
= 0x1a,
322 .tuner_sda_gpio
= 0x1b,
323 .decoder
= CX231XX_AVDECODER
,
324 .output_mode
= OUT_MODE_VIP11
,
325 .demod_xfer_mode
= 0,
326 .ctl_pin_status_mask
= 0xFFFFFFC4,
327 .agc_analog_digital_select_gpio
= 0x0c,
328 .gpio_pin_status_mask
= 0x4001000,
329 .tuner_i2c_master
= 1,
330 .demod_i2c_master
= 2,
333 .norm
= V4L2_STD_NTSC
,
336 .type
= CX231XX_VMUX_TELEVISION
,
337 .vmux
= CX231XX_VIN_2_1
,
338 .amux
= CX231XX_AMUX_VIDEO
,
343 [CX231XX_BOARD_HAUPPAUGE_EXETER
] = {
344 .name
= "Hauppauge EXETER",
345 .tuner_type
= TUNER_NXP_TDA18271
,
347 .tuner_gpio
= RDE250_XCV_TUNER
,
348 .tuner_sif_gpio
= 0x05,
349 .tuner_scl_gpio
= 0x1a,
350 .tuner_sda_gpio
= 0x1b,
351 .decoder
= CX231XX_AVDECODER
,
352 .output_mode
= OUT_MODE_VIP11
,
353 .demod_xfer_mode
= 0,
354 .ctl_pin_status_mask
= 0xFFFFFFC4,
355 .agc_analog_digital_select_gpio
= 0x0c,
356 .gpio_pin_status_mask
= 0x4001000,
357 .tuner_i2c_master
= 1,
358 .demod_i2c_master
= 2,
361 .norm
= V4L2_STD_NTSC
,
364 .type
= CX231XX_VMUX_TELEVISION
,
365 .vmux
= CX231XX_VIN_3_1
,
366 .amux
= CX231XX_AMUX_VIDEO
,
369 .type
= CX231XX_VMUX_COMPOSITE1
,
370 .vmux
= CX231XX_VIN_2_1
,
371 .amux
= CX231XX_AMUX_LINE_IN
,
374 .type
= CX231XX_VMUX_SVIDEO
,
375 .vmux
= CX231XX_VIN_1_1
|
376 (CX231XX_VIN_1_2
<< 8) |
378 .amux
= CX231XX_AMUX_LINE_IN
,
382 [CX231XX_BOARD_HAUPPAUGE_USBLIVE2
] = {
383 .name
= "Hauppauge USB Live 2",
384 .tuner_type
= TUNER_ABSENT
,
385 .decoder
= CX231XX_AVDECODER
,
386 .output_mode
= OUT_MODE_VIP11
,
387 .demod_xfer_mode
= 0,
388 .ctl_pin_status_mask
= 0xFFFFFFC4,
389 .agc_analog_digital_select_gpio
= 0x0c,
390 .gpio_pin_status_mask
= 0x4001000,
391 .norm
= V4L2_STD_NTSC
,
394 .dont_use_port_3
= 1,
396 .type
= CX231XX_VMUX_COMPOSITE1
,
397 .vmux
= CX231XX_VIN_2_1
,
398 .amux
= CX231XX_AMUX_LINE_IN
,
401 .type
= CX231XX_VMUX_SVIDEO
,
402 .vmux
= CX231XX_VIN_1_1
|
403 (CX231XX_VIN_1_2
<< 8) |
405 .amux
= CX231XX_AMUX_LINE_IN
,
409 [CX231XX_BOARD_KWORLD_UB430_USB_HYBRID
] = {
410 .name
= "Kworld UB430 USB Hybrid",
411 .tuner_type
= TUNER_NXP_TDA18271
,
413 .decoder
= CX231XX_AVDECODER
,
414 .output_mode
= OUT_MODE_VIP11
,
415 .demod_xfer_mode
= 0,
416 .ctl_pin_status_mask
= 0xFFFFFFC4,
417 .agc_analog_digital_select_gpio
= 0x11, /* According with PV cxPolaris.inf file */
418 .tuner_sif_gpio
= -1,
419 .tuner_scl_gpio
= -1,
420 .tuner_sda_gpio
= -1,
421 .gpio_pin_status_mask
= 0x4001000,
422 .tuner_i2c_master
= 2,
423 .demod_i2c_master
= 1,
427 .norm
= V4L2_STD_PAL_M
,
429 .type
= CX231XX_VMUX_TELEVISION
,
430 .vmux
= CX231XX_VIN_3_1
,
431 .amux
= CX231XX_AMUX_VIDEO
,
434 .type
= CX231XX_VMUX_COMPOSITE1
,
435 .vmux
= CX231XX_VIN_2_1
,
436 .amux
= CX231XX_AMUX_LINE_IN
,
439 .type
= CX231XX_VMUX_SVIDEO
,
440 .vmux
= CX231XX_VIN_1_1
|
441 (CX231XX_VIN_1_2
<< 8) |
443 .amux
= CX231XX_AMUX_LINE_IN
,
447 [CX231XX_BOARD_PV_PLAYTV_USB_HYBRID
] = {
448 .name
= "Pixelview PlayTV USB Hybrid",
449 .tuner_type
= TUNER_NXP_TDA18271
,
451 .decoder
= CX231XX_AVDECODER
,
452 .output_mode
= OUT_MODE_VIP11
,
453 .demod_xfer_mode
= 0,
454 .ctl_pin_status_mask
= 0xFFFFFFC4,
455 .agc_analog_digital_select_gpio
= 0x00, /* According with PV cxPolaris.inf file */
456 .tuner_sif_gpio
= -1,
457 .tuner_scl_gpio
= -1,
458 .tuner_sda_gpio
= -1,
459 .gpio_pin_status_mask
= 0x4001000,
460 .tuner_i2c_master
= 2,
461 .demod_i2c_master
= 1,
463 .rc_map_name
= RC_MAP_PIXELVIEW_002T
,
466 .norm
= V4L2_STD_PAL_M
,
468 .type
= CX231XX_VMUX_TELEVISION
,
469 .vmux
= CX231XX_VIN_3_1
,
470 .amux
= CX231XX_AMUX_VIDEO
,
473 .type
= CX231XX_VMUX_COMPOSITE1
,
474 .vmux
= CX231XX_VIN_2_1
,
475 .amux
= CX231XX_AMUX_LINE_IN
,
478 .type
= CX231XX_VMUX_SVIDEO
,
479 .vmux
= CX231XX_VIN_1_1
|
480 (CX231XX_VIN_1_2
<< 8) |
482 .amux
= CX231XX_AMUX_LINE_IN
,
486 [CX231XX_BOARD_PV_XCAPTURE_USB
] = {
487 .name
= "Pixelview Xcapture USB",
488 .tuner_type
= TUNER_ABSENT
,
489 .decoder
= CX231XX_AVDECODER
,
490 .output_mode
= OUT_MODE_VIP11
,
491 .demod_xfer_mode
= 0,
492 .ctl_pin_status_mask
= 0xFFFFFFC4,
493 .agc_analog_digital_select_gpio
= 0x0c,
494 .gpio_pin_status_mask
= 0x4001000,
495 .norm
= V4L2_STD_NTSC
,
498 .dont_use_port_3
= 1,
501 .type
= CX231XX_VMUX_COMPOSITE1
,
502 .vmux
= CX231XX_VIN_2_1
,
503 .amux
= CX231XX_AMUX_LINE_IN
,
506 .type
= CX231XX_VMUX_SVIDEO
,
507 .vmux
= CX231XX_VIN_1_1
|
508 (CX231XX_VIN_1_2
<< 8) |
510 .amux
= CX231XX_AMUX_LINE_IN
,
516 [CX231XX_BOARD_ICONBIT_U100
] = {
517 .name
= "Iconbit Analog Stick U100 FM",
518 .tuner_type
= TUNER_ABSENT
,
519 .decoder
= CX231XX_AVDECODER
,
520 .output_mode
= OUT_MODE_VIP11
,
521 .demod_xfer_mode
= 0,
522 .ctl_pin_status_mask
= 0xFFFFFFC4,
523 .agc_analog_digital_select_gpio
= 0x1C,
524 .gpio_pin_status_mask
= 0x4001000,
527 .type
= CX231XX_VMUX_COMPOSITE1
,
528 .vmux
= CX231XX_VIN_2_1
,
529 .amux
= CX231XX_AMUX_LINE_IN
,
532 .type
= CX231XX_VMUX_SVIDEO
,
533 .vmux
= CX231XX_VIN_1_1
|
534 (CX231XX_VIN_1_2
<< 8) |
536 .amux
= CX231XX_AMUX_LINE_IN
,
540 [CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL
] = {
541 .name
= "Hauppauge WinTV USB2 FM (PAL)",
542 .tuner_type
= TUNER_NXP_TDA18271
,
544 .tuner_gpio
= RDE250_XCV_TUNER
,
545 .tuner_sif_gpio
= 0x05,
546 .tuner_scl_gpio
= 0x1a,
547 .tuner_sda_gpio
= 0x1b,
548 .decoder
= CX231XX_AVDECODER
,
549 .output_mode
= OUT_MODE_VIP11
,
550 .ctl_pin_status_mask
= 0xFFFFFFC4,
551 .agc_analog_digital_select_gpio
= 0x0c,
552 .gpio_pin_status_mask
= 0x4001000,
553 .tuner_i2c_master
= 1,
554 .norm
= V4L2_STD_PAL
,
557 .type
= CX231XX_VMUX_TELEVISION
,
558 .vmux
= CX231XX_VIN_3_1
,
559 .amux
= CX231XX_AMUX_VIDEO
,
562 .type
= CX231XX_VMUX_COMPOSITE1
,
563 .vmux
= CX231XX_VIN_2_1
,
564 .amux
= CX231XX_AMUX_LINE_IN
,
567 .type
= CX231XX_VMUX_SVIDEO
,
568 .vmux
= CX231XX_VIN_1_1
|
569 (CX231XX_VIN_1_2
<< 8) |
571 .amux
= CX231XX_AMUX_LINE_IN
,
575 [CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC
] = {
576 .name
= "Hauppauge WinTV USB2 FM (NTSC)",
577 .tuner_type
= TUNER_NXP_TDA18271
,
579 .tuner_gpio
= RDE250_XCV_TUNER
,
580 .tuner_sif_gpio
= 0x05,
581 .tuner_scl_gpio
= 0x1a,
582 .tuner_sda_gpio
= 0x1b,
583 .decoder
= CX231XX_AVDECODER
,
584 .output_mode
= OUT_MODE_VIP11
,
585 .ctl_pin_status_mask
= 0xFFFFFFC4,
586 .agc_analog_digital_select_gpio
= 0x0c,
587 .gpio_pin_status_mask
= 0x4001000,
588 .tuner_i2c_master
= 1,
589 .norm
= V4L2_STD_NTSC
,
592 .type
= CX231XX_VMUX_TELEVISION
,
593 .vmux
= CX231XX_VIN_3_1
,
594 .amux
= CX231XX_AMUX_VIDEO
,
597 .type
= CX231XX_VMUX_COMPOSITE1
,
598 .vmux
= CX231XX_VIN_2_1
,
599 .amux
= CX231XX_AMUX_LINE_IN
,
602 .type
= CX231XX_VMUX_SVIDEO
,
603 .vmux
= CX231XX_VIN_1_1
|
604 (CX231XX_VIN_1_2
<< 8) |
606 .amux
= CX231XX_AMUX_LINE_IN
,
610 [CX231XX_BOARD_ELGATO_VIDEO_CAPTURE_V2
] = {
611 .name
= "Elgato Video Capture V2",
612 .tuner_type
= TUNER_ABSENT
,
613 .decoder
= CX231XX_AVDECODER
,
614 .output_mode
= OUT_MODE_VIP11
,
615 .demod_xfer_mode
= 0,
616 .ctl_pin_status_mask
= 0xFFFFFFC4,
617 .agc_analog_digital_select_gpio
= 0x0c,
618 .gpio_pin_status_mask
= 0x4001000,
619 .norm
= V4L2_STD_NTSC
,
622 .dont_use_port_3
= 1,
624 .type
= CX231XX_VMUX_COMPOSITE1
,
625 .vmux
= CX231XX_VIN_2_1
,
626 .amux
= CX231XX_AMUX_LINE_IN
,
629 .type
= CX231XX_VMUX_SVIDEO
,
630 .vmux
= CX231XX_VIN_1_1
|
631 (CX231XX_VIN_1_2
<< 8) |
633 .amux
= CX231XX_AMUX_LINE_IN
,
638 const unsigned int cx231xx_bcount
= ARRAY_SIZE(cx231xx_boards
);
640 /* table of devices that work with this driver */
641 struct usb_device_id cx231xx_id_table
[] = {
642 {USB_DEVICE(0x0572, 0x5A3C),
643 .driver_info
= CX231XX_BOARD_UNKNOWN
},
644 {USB_DEVICE(0x0572, 0x58A2),
645 .driver_info
= CX231XX_BOARD_CNXT_CARRAERA
},
646 {USB_DEVICE(0x0572, 0x58A1),
647 .driver_info
= CX231XX_BOARD_CNXT_SHELBY
},
648 {USB_DEVICE(0x0572, 0x58A4),
649 .driver_info
= CX231XX_BOARD_CNXT_RDE_253S
},
650 {USB_DEVICE(0x0572, 0x58A5),
651 .driver_info
= CX231XX_BOARD_CNXT_RDU_253S
},
652 {USB_DEVICE(0x0572, 0x58A6),
653 .driver_info
= CX231XX_BOARD_CNXT_VIDEO_GRABBER
},
654 {USB_DEVICE(0x0572, 0x589E),
655 .driver_info
= CX231XX_BOARD_CNXT_RDE_250
},
656 {USB_DEVICE(0x0572, 0x58A0),
657 .driver_info
= CX231XX_BOARD_CNXT_RDU_250
},
658 {USB_DEVICE(0x2040, 0xb110),
659 .driver_info
= CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL
},
660 {USB_DEVICE(0x2040, 0xb111),
661 .driver_info
= CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC
},
662 {USB_DEVICE(0x2040, 0xb120),
663 .driver_info
= CX231XX_BOARD_HAUPPAUGE_EXETER
},
664 {USB_DEVICE(0x2040, 0xb140),
665 .driver_info
= CX231XX_BOARD_HAUPPAUGE_EXETER
},
666 {USB_DEVICE(0x2040, 0xc200),
667 .driver_info
= CX231XX_BOARD_HAUPPAUGE_USBLIVE2
},
668 {USB_DEVICE_VER(USB_VID_PIXELVIEW
, USB_PID_PIXELVIEW_SBTVD
, 0x4000, 0x4001),
669 .driver_info
= CX231XX_BOARD_PV_PLAYTV_USB_HYBRID
},
670 {USB_DEVICE(USB_VID_PIXELVIEW
, 0x5014),
671 .driver_info
= CX231XX_BOARD_PV_XCAPTURE_USB
},
672 {USB_DEVICE(0x1b80, 0xe424),
673 .driver_info
= CX231XX_BOARD_KWORLD_UB430_USB_HYBRID
},
674 {USB_DEVICE(0x1f4d, 0x0237),
675 .driver_info
= CX231XX_BOARD_ICONBIT_U100
},
676 {USB_DEVICE(0x0fd9, 0x0037),
677 .driver_info
= CX231XX_BOARD_ELGATO_VIDEO_CAPTURE_V2
},
681 MODULE_DEVICE_TABLE(usb
, cx231xx_id_table
);
683 /* cx231xx_tuner_callback
684 * will be used to reset XC5000 tuner using GPIO pin
687 int cx231xx_tuner_callback(void *ptr
, int component
, int command
, int arg
)
690 struct cx231xx
*dev
= ptr
;
692 if (dev
->tuner_type
== TUNER_XC5000
) {
693 if (command
== XC5000_TUNER_RESET
) {
695 ("Tuner CB: RESET: cmd %d : tuner type %d \n",
696 command
, dev
->tuner_type
);
697 cx231xx_set_gpio_value(dev
, dev
->board
.tuner_gpio
->bit
,
700 cx231xx_set_gpio_value(dev
, dev
->board
.tuner_gpio
->bit
,
703 cx231xx_set_gpio_value(dev
, dev
->board
.tuner_gpio
->bit
,
707 } else if (dev
->tuner_type
== TUNER_NXP_TDA18271
) {
709 case TDA18271_CALLBACK_CMD_AGC_ENABLE
:
710 if (dev
->model
== CX231XX_BOARD_PV_PLAYTV_USB_HYBRID
)
711 rc
= cx231xx_set_agc_analog_digital_mux_select(dev
, arg
);
720 EXPORT_SYMBOL_GPL(cx231xx_tuner_callback
);
722 static void cx231xx_reset_out(struct cx231xx
*dev
)
724 cx231xx_set_gpio_value(dev
, CX23417_RESET
, 1);
726 cx231xx_set_gpio_value(dev
, CX23417_RESET
, 0);
728 cx231xx_set_gpio_value(dev
, CX23417_RESET
, 1);
731 static void cx231xx_enable_OSC(struct cx231xx
*dev
)
733 cx231xx_set_gpio_value(dev
, CX23417_OSC_EN
, 1);
736 static void cx231xx_sleep_s5h1432(struct cx231xx
*dev
)
738 cx231xx_set_gpio_value(dev
, SLEEP_S5H1432
, 0);
741 static inline void cx231xx_set_model(struct cx231xx
*dev
)
743 dev
->board
= cx231xx_boards
[dev
->model
];
746 /* Since cx231xx_pre_card_setup() requires a proper dev->model,
747 * this won't work for boards with generic PCI IDs
749 void cx231xx_pre_card_setup(struct cx231xx
*dev
)
752 cx231xx_set_model(dev
);
754 cx231xx_info("Identified as %s (card=%d)\n",
755 dev
->board
.name
, dev
->model
);
757 /* set the direction for GPIO pins */
758 if (dev
->board
.tuner_gpio
) {
759 cx231xx_set_gpio_direction(dev
, dev
->board
.tuner_gpio
->bit
, 1);
760 cx231xx_set_gpio_value(dev
, dev
->board
.tuner_gpio
->bit
, 1);
762 if (dev
->board
.tuner_sif_gpio
>= 0)
763 cx231xx_set_gpio_direction(dev
, dev
->board
.tuner_sif_gpio
, 1);
765 /* request some modules if any required */
767 /* set the mode to Analog mode initially */
768 cx231xx_set_mode(dev
, CX231XX_ANALOG_MODE
);
771 /* cx231xx_set_mode(dev, CX231XX_SUSPEND); */
775 static void cx231xx_config_tuner(struct cx231xx
*dev
)
777 struct tuner_setup tun_setup
;
778 struct v4l2_frequency f
;
780 if (dev
->tuner_type
== TUNER_ABSENT
)
783 tun_setup
.mode_mask
= T_ANALOG_TV
| T_RADIO
;
784 tun_setup
.type
= dev
->tuner_type
;
785 tun_setup
.addr
= dev
->tuner_addr
;
786 tun_setup
.tuner_callback
= cx231xx_tuner_callback
;
788 tuner_call(dev
, tuner
, s_type_addr
, &tun_setup
);
791 if (tun_setup
.type
== TUNER_XC5000
) {
792 static struct xc2028_ctrl ctrl
= {
793 .fname
= XC5000_DEFAULT_FIRMWARE
,
797 struct v4l2_priv_tun_config cfg
= {
798 .tuner
= dev
->tuner_type
,
801 tuner_call(dev
, tuner
, s_config
, &cfg
);
804 /* configure tuner */
806 f
.type
= V4L2_TUNER_ANALOG_TV
;
807 f
.frequency
= 9076; /* just a magic number */
808 dev
->ctl_freq
= f
.frequency
;
809 call_all(dev
, tuner
, s_frequency
, &f
);
813 void cx231xx_card_setup(struct cx231xx
*dev
)
816 cx231xx_set_model(dev
);
818 dev
->tuner_type
= cx231xx_boards
[dev
->model
].tuner_type
;
819 if (cx231xx_boards
[dev
->model
].tuner_addr
)
820 dev
->tuner_addr
= cx231xx_boards
[dev
->model
].tuner_addr
;
822 /* request some modules */
823 if (dev
->board
.decoder
== CX231XX_AVDECODER
) {
824 dev
->sd_cx25840
= v4l2_i2c_new_subdev(&dev
->v4l2_dev
,
825 &dev
->i2c_bus
[0].i2c_adap
,
826 "cx25840", 0x88 >> 1, NULL
);
827 if (dev
->sd_cx25840
== NULL
)
828 cx231xx_info("cx25840 subdev registration failure\n");
829 cx25840_call(dev
, core
, load_fw
);
833 /* Initialize the tuner */
834 if (dev
->board
.tuner_type
!= TUNER_ABSENT
) {
835 dev
->sd_tuner
= v4l2_i2c_new_subdev(&dev
->v4l2_dev
,
836 &dev
->i2c_bus
[dev
->board
.tuner_i2c_master
].i2c_adap
,
838 dev
->tuner_addr
, NULL
);
839 if (dev
->sd_tuner
== NULL
)
840 cx231xx_info("tuner subdev registration failure\n");
842 cx231xx_config_tuner(dev
);
848 * inits registers with sane defaults
850 int cx231xx_config(struct cx231xx
*dev
)
852 /* TBD need to add cx231xx specific code */
858 * cx231xx_config_i2c()
859 * configure i2c attached devices
861 void cx231xx_config_i2c(struct cx231xx
*dev
)
863 /* u32 input = INPUT(dev->video_input)->vmux; */
865 call_all(dev
, video
, s_stream
, 1);
869 * cx231xx_realease_resources()
870 * unregisters the v4l2,i2c and usb devices
871 * called when the device gets disconected or at module unload
873 void cx231xx_release_resources(struct cx231xx
*dev
)
875 cx231xx_release_analog_resources(dev
);
877 cx231xx_remove_from_devlist(dev
);
879 cx231xx_ir_exit(dev
);
881 /* Release I2C buses */
882 cx231xx_dev_uninit(dev
);
884 /* delete v4l2 device */
885 v4l2_device_unregister(&dev
->v4l2_dev
);
887 usb_put_dev(dev
->udev
);
889 /* Mark device as unused */
890 clear_bit(dev
->devno
, &cx231xx_devused
);
892 kfree(dev
->video_mode
.alt_max_pkt_size
);
893 kfree(dev
->vbi_mode
.alt_max_pkt_size
);
894 kfree(dev
->sliced_cc_mode
.alt_max_pkt_size
);
895 kfree(dev
->ts1_mode
.alt_max_pkt_size
);
901 * allocates and inits the device structs, registers i2c bus and v4l device
903 static int cx231xx_init_dev(struct cx231xx
*dev
, struct usb_device
*udev
,
906 int retval
= -ENOMEM
;
908 unsigned int maxh
, maxw
;
911 mutex_init(&dev
->lock
);
912 mutex_init(&dev
->ctrl_urb_lock
);
913 mutex_init(&dev
->gpio_i2c_lock
);
914 mutex_init(&dev
->i2c_lock
);
916 spin_lock_init(&dev
->video_mode
.slock
);
917 spin_lock_init(&dev
->vbi_mode
.slock
);
918 spin_lock_init(&dev
->sliced_cc_mode
.slock
);
920 init_waitqueue_head(&dev
->open
);
921 init_waitqueue_head(&dev
->wait_frame
);
922 init_waitqueue_head(&dev
->wait_stream
);
924 dev
->cx231xx_read_ctrl_reg
= cx231xx_read_ctrl_reg
;
925 dev
->cx231xx_write_ctrl_reg
= cx231xx_write_ctrl_reg
;
926 dev
->cx231xx_send_usb_command
= cx231xx_send_usb_command
;
927 dev
->cx231xx_gpio_i2c_read
= cx231xx_gpio_i2c_read
;
928 dev
->cx231xx_gpio_i2c_write
= cx231xx_gpio_i2c_write
;
930 /* Query cx231xx to find what pcb config it is related to */
931 initialize_cx231xx(dev
);
933 /*To workaround error number=-71 on EP0 for VideoGrabber,
935 if (dev
->model
== CX231XX_BOARD_CNXT_VIDEO_GRABBER
||
936 dev
->model
== CX231XX_BOARD_HAUPPAUGE_USBLIVE2
) {
937 cx231xx_set_alt_setting(dev
, INDEX_VIDEO
, 3);
938 cx231xx_set_alt_setting(dev
, INDEX_VANC
, 1);
940 /* Cx231xx pre card setup */
941 cx231xx_pre_card_setup(dev
);
943 errCode
= cx231xx_config(dev
);
945 cx231xx_errdev("error configuring device\n");
949 /* set default norm */
950 dev
->norm
= dev
->board
.norm
;
952 /* register i2c bus */
953 errCode
= cx231xx_dev_init(dev
);
955 cx231xx_dev_uninit(dev
);
956 cx231xx_errdev("%s: cx231xx_i2c_register - errCode [%d]!\n",
961 /* Do board specific init */
962 cx231xx_card_setup(dev
);
964 /* configure the device */
965 cx231xx_config_i2c(dev
);
967 maxw
= norm_maxw(dev
);
968 maxh
= norm_maxh(dev
);
970 /* set default image size */
974 dev
->video_input
= 0;
976 errCode
= cx231xx_config(dev
);
978 cx231xx_errdev("%s: cx231xx_config - errCode [%d]!\n",
983 /* init video dma queues */
984 INIT_LIST_HEAD(&dev
->video_mode
.vidq
.active
);
985 INIT_LIST_HEAD(&dev
->video_mode
.vidq
.queued
);
987 /* init vbi dma queues */
988 INIT_LIST_HEAD(&dev
->vbi_mode
.vidq
.active
);
989 INIT_LIST_HEAD(&dev
->vbi_mode
.vidq
.queued
);
991 /* Reset other chips required if they are tied up with GPIO pins */
992 cx231xx_add_into_devlist(dev
);
994 if (dev
->board
.has_417
) {
995 printk(KERN_INFO
"attach 417 %d\n", dev
->model
);
996 if (cx231xx_417_register(dev
) < 0) {
998 "%s() Failed to register 417 on VID_B\n",
1003 retval
= cx231xx_register_analog_devices(dev
);
1005 cx231xx_release_resources(dev
);
1009 cx231xx_ir_init(dev
);
1011 cx231xx_init_extension(dev
);
1016 #if defined(CONFIG_MODULES) && defined(MODULE)
1017 static void request_module_async(struct work_struct
*work
)
1019 struct cx231xx
*dev
= container_of(work
,
1020 struct cx231xx
, request_module_wk
);
1022 if (dev
->has_alsa_audio
)
1023 request_module("cx231xx-alsa");
1025 if (dev
->board
.has_dvb
)
1026 request_module("cx231xx-dvb");
1030 static void request_modules(struct cx231xx
*dev
)
1032 INIT_WORK(&dev
->request_module_wk
, request_module_async
);
1033 schedule_work(&dev
->request_module_wk
);
1036 static void flush_request_modules(struct cx231xx
*dev
)
1038 flush_work(&dev
->request_module_wk
);
1041 #define request_modules(dev)
1042 #define flush_request_modules(dev)
1043 #endif /* CONFIG_MODULES */
1046 * cx231xx_usb_probe()
1047 * checks for supported devices
1049 static int cx231xx_usb_probe(struct usb_interface
*interface
,
1050 const struct usb_device_id
*id
)
1052 struct usb_device
*udev
;
1053 struct usb_interface
*uif
;
1054 struct cx231xx
*dev
= NULL
;
1055 int retval
= -ENODEV
;
1057 int i
, isoc_pipe
= 0;
1059 struct usb_interface_assoc_descriptor
*assoc_desc
;
1061 udev
= usb_get_dev(interface_to_usbdev(interface
));
1062 ifnum
= interface
->altsetting
[0].desc
.bInterfaceNumber
;
1065 * Interface number 0 - IR interface (handled by mceusb driver)
1066 * Interface number 1 - AV interface (handled by this driver)
1071 /* Check to see next free device and mark as used */
1073 nr
= find_first_zero_bit(&cx231xx_devused
, CX231XX_MAXBOARDS
);
1074 if (nr
>= CX231XX_MAXBOARDS
) {
1075 /* No free device slots */
1076 cx231xx_err(DRIVER_NAME
": Supports only %i devices.\n",
1080 } while (test_and_set_bit(nr
, &cx231xx_devused
));
1082 /* allocate memory for our device state and initialize it */
1083 dev
= kzalloc(sizeof(*dev
), GFP_KERNEL
);
1085 cx231xx_err(DRIVER_NAME
": out of memory!\n");
1086 clear_bit(nr
, &cx231xx_devused
);
1090 snprintf(dev
->name
, 29, "cx231xx #%d", nr
);
1092 dev
->model
= id
->driver_info
;
1093 dev
->video_mode
.alt
= -1;
1095 dev
->interface_count
++;
1096 /* reset gpio dir and value */
1099 dev
->xc_fw_load_done
= 0;
1100 dev
->has_alsa_audio
= 1;
1101 dev
->power_mode
= -1;
1102 atomic_set(&dev
->devlist_count
, 0);
1104 /* 0 - vbi ; 1 -sliced cc mode */
1105 dev
->vbi_or_sliced_cc_mode
= 0;
1107 /* get maximum no.of IAD interfaces */
1108 assoc_desc
= udev
->actconfig
->intf_assoc
[0];
1109 dev
->max_iad_interface_count
= assoc_desc
->bInterfaceCount
;
1111 /* init CIR module TBD */
1113 /*mode_tv: digital=1 or analog=0*/
1116 dev
->USE_ISO
= transfer_mode
;
1118 switch (udev
->speed
) {
1122 case USB_SPEED_UNKNOWN
:
1123 case USB_SPEED_FULL
:
1126 case USB_SPEED_HIGH
:
1133 cx231xx_info("New device %s %s @ %s Mbps "
1134 "(%04x:%04x) with %d interfaces\n",
1135 udev
->manufacturer
? udev
->manufacturer
: "",
1136 udev
->product
? udev
->product
: "",
1138 le16_to_cpu(udev
->descriptor
.idVendor
),
1139 le16_to_cpu(udev
->descriptor
.idProduct
),
1140 dev
->max_iad_interface_count
);
1142 /* increment interface count */
1143 dev
->interface_count
++;
1145 /* get device number */
1148 assoc_desc
= udev
->actconfig
->intf_assoc
[0];
1149 if (assoc_desc
->bFirstInterface
!= ifnum
) {
1150 cx231xx_err(DRIVER_NAME
": Not found "
1151 "matching IAD interface\n");
1152 clear_bit(dev
->devno
, &cx231xx_devused
);
1158 cx231xx_info("registering interface %d\n", ifnum
);
1160 /* save our data pointer in this interface device */
1161 usb_set_intfdata(interface
, dev
);
1164 * AV device initialization - only done at the last interface
1167 /* Create v4l2 device */
1168 retval
= v4l2_device_register(&interface
->dev
, &dev
->v4l2_dev
);
1170 cx231xx_errdev("v4l2_device_register failed\n");
1171 clear_bit(dev
->devno
, &cx231xx_devused
);
1176 /* allocate device struct */
1177 retval
= cx231xx_init_dev(dev
, udev
, nr
);
1179 clear_bit(dev
->devno
, &cx231xx_devused
);
1180 v4l2_device_unregister(&dev
->v4l2_dev
);
1183 usb_set_intfdata(interface
, NULL
);
1188 /* compute alternate max packet sizes for video */
1189 uif
= udev
->actconfig
->interface
[dev
->current_pcb_config
.
1190 hs_config_info
[0].interface_info
.video_index
+ 1];
1192 dev
->video_mode
.end_point_addr
= le16_to_cpu(uif
->altsetting
[0].
1193 endpoint
[isoc_pipe
].desc
.bEndpointAddress
);
1195 dev
->video_mode
.num_alt
= uif
->num_altsetting
;
1196 cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n",
1197 dev
->video_mode
.end_point_addr
,
1198 dev
->video_mode
.num_alt
);
1199 dev
->video_mode
.alt_max_pkt_size
=
1200 kmalloc(32 * dev
->video_mode
.num_alt
, GFP_KERNEL
);
1202 if (dev
->video_mode
.alt_max_pkt_size
== NULL
) {
1203 cx231xx_errdev("out of memory!\n");
1204 clear_bit(dev
->devno
, &cx231xx_devused
);
1205 v4l2_device_unregister(&dev
->v4l2_dev
);
1211 for (i
= 0; i
< dev
->video_mode
.num_alt
; i
++) {
1212 u16 tmp
= le16_to_cpu(uif
->altsetting
[i
].endpoint
[isoc_pipe
].
1213 desc
.wMaxPacketSize
);
1214 dev
->video_mode
.alt_max_pkt_size
[i
] =
1215 (tmp
& 0x07ff) * (((tmp
& 0x1800) >> 11) + 1);
1216 cx231xx_info("Alternate setting %i, max size= %i\n", i
,
1217 dev
->video_mode
.alt_max_pkt_size
[i
]);
1220 /* compute alternate max packet sizes for vbi */
1221 uif
= udev
->actconfig
->interface
[dev
->current_pcb_config
.
1222 hs_config_info
[0].interface_info
.
1225 dev
->vbi_mode
.end_point_addr
=
1226 le16_to_cpu(uif
->altsetting
[0].endpoint
[isoc_pipe
].desc
.
1229 dev
->vbi_mode
.num_alt
= uif
->num_altsetting
;
1230 cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n",
1231 dev
->vbi_mode
.end_point_addr
,
1232 dev
->vbi_mode
.num_alt
);
1233 dev
->vbi_mode
.alt_max_pkt_size
=
1234 kmalloc(32 * dev
->vbi_mode
.num_alt
, GFP_KERNEL
);
1236 if (dev
->vbi_mode
.alt_max_pkt_size
== NULL
) {
1237 cx231xx_errdev("out of memory!\n");
1238 clear_bit(dev
->devno
, &cx231xx_devused
);
1239 v4l2_device_unregister(&dev
->v4l2_dev
);
1245 for (i
= 0; i
< dev
->vbi_mode
.num_alt
; i
++) {
1247 le16_to_cpu(uif
->altsetting
[i
].endpoint
[isoc_pipe
].
1248 desc
.wMaxPacketSize
);
1249 dev
->vbi_mode
.alt_max_pkt_size
[i
] =
1250 (tmp
& 0x07ff) * (((tmp
& 0x1800) >> 11) + 1);
1251 cx231xx_info("Alternate setting %i, max size= %i\n", i
,
1252 dev
->vbi_mode
.alt_max_pkt_size
[i
]);
1255 /* compute alternate max packet sizes for sliced CC */
1256 uif
= udev
->actconfig
->interface
[dev
->current_pcb_config
.
1257 hs_config_info
[0].interface_info
.
1260 dev
->sliced_cc_mode
.end_point_addr
=
1261 le16_to_cpu(uif
->altsetting
[0].endpoint
[isoc_pipe
].desc
.
1264 dev
->sliced_cc_mode
.num_alt
= uif
->num_altsetting
;
1265 cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n",
1266 dev
->sliced_cc_mode
.end_point_addr
,
1267 dev
->sliced_cc_mode
.num_alt
);
1268 dev
->sliced_cc_mode
.alt_max_pkt_size
=
1269 kmalloc(32 * dev
->sliced_cc_mode
.num_alt
, GFP_KERNEL
);
1271 if (dev
->sliced_cc_mode
.alt_max_pkt_size
== NULL
) {
1272 cx231xx_errdev("out of memory!\n");
1273 clear_bit(dev
->devno
, &cx231xx_devused
);
1274 v4l2_device_unregister(&dev
->v4l2_dev
);
1280 for (i
= 0; i
< dev
->sliced_cc_mode
.num_alt
; i
++) {
1281 u16 tmp
= le16_to_cpu(uif
->altsetting
[i
].endpoint
[isoc_pipe
].
1282 desc
.wMaxPacketSize
);
1283 dev
->sliced_cc_mode
.alt_max_pkt_size
[i
] =
1284 (tmp
& 0x07ff) * (((tmp
& 0x1800) >> 11) + 1);
1285 cx231xx_info("Alternate setting %i, max size= %i\n", i
,
1286 dev
->sliced_cc_mode
.alt_max_pkt_size
[i
]);
1289 if (dev
->current_pcb_config
.ts1_source
!= 0xff) {
1290 /* compute alternate max packet sizes for TS1 */
1291 uif
= udev
->actconfig
->interface
[dev
->current_pcb_config
.
1296 dev
->ts1_mode
.end_point_addr
=
1297 le16_to_cpu(uif
->altsetting
[0].endpoint
[isoc_pipe
].
1298 desc
.bEndpointAddress
);
1300 dev
->ts1_mode
.num_alt
= uif
->num_altsetting
;
1301 cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n",
1302 dev
->ts1_mode
.end_point_addr
,
1303 dev
->ts1_mode
.num_alt
);
1304 dev
->ts1_mode
.alt_max_pkt_size
=
1305 kmalloc(32 * dev
->ts1_mode
.num_alt
, GFP_KERNEL
);
1307 if (dev
->ts1_mode
.alt_max_pkt_size
== NULL
) {
1308 cx231xx_errdev("out of memory!\n");
1309 clear_bit(dev
->devno
, &cx231xx_devused
);
1310 v4l2_device_unregister(&dev
->v4l2_dev
);
1316 for (i
= 0; i
< dev
->ts1_mode
.num_alt
; i
++) {
1317 u16 tmp
= le16_to_cpu(uif
->altsetting
[i
].
1318 endpoint
[isoc_pipe
].desc
.
1320 dev
->ts1_mode
.alt_max_pkt_size
[i
] =
1321 (tmp
& 0x07ff) * (((tmp
& 0x1800) >> 11) + 1);
1322 cx231xx_info("Alternate setting %i, max size= %i\n", i
,
1323 dev
->ts1_mode
.alt_max_pkt_size
[i
]);
1327 if (dev
->model
== CX231XX_BOARD_CNXT_VIDEO_GRABBER
) {
1328 cx231xx_enable_OSC(dev
);
1329 cx231xx_reset_out(dev
);
1330 cx231xx_set_alt_setting(dev
, INDEX_VIDEO
, 3);
1333 if (dev
->model
== CX231XX_BOARD_CNXT_RDE_253S
)
1334 cx231xx_sleep_s5h1432(dev
);
1336 /* load other modules required */
1337 request_modules(dev
);
1343 * cx231xx_usb_disconnect()
1344 * called when the device gets diconencted
1345 * video device will be unregistered on v4l2_close in case it is still open
1347 static void cx231xx_usb_disconnect(struct usb_interface
*interface
)
1349 struct cx231xx
*dev
;
1351 dev
= usb_get_intfdata(interface
);
1352 usb_set_intfdata(interface
, NULL
);
1360 dev
->state
|= DEV_DISCONNECTED
;
1362 flush_request_modules(dev
);
1364 /* wait until all current v4l2 io is finished then deallocate
1366 mutex_lock(&dev
->lock
);
1368 wake_up_interruptible_all(&dev
->open
);
1372 ("device %s is open! Deregistration and memory "
1373 "deallocation are deferred on close.\n",
1374 video_device_node_name(dev
->vdev
));
1376 /* Even having users, it is safe to remove the RC i2c driver */
1377 cx231xx_ir_exit(dev
);
1380 cx231xx_uninit_isoc(dev
);
1382 cx231xx_uninit_bulk(dev
);
1383 wake_up_interruptible(&dev
->wait_frame
);
1384 wake_up_interruptible(&dev
->wait_stream
);
1388 cx231xx_close_extension(dev
);
1390 mutex_unlock(&dev
->lock
);
1393 cx231xx_release_resources(dev
);
1396 static struct usb_driver cx231xx_usb_driver
= {
1398 .probe
= cx231xx_usb_probe
,
1399 .disconnect
= cx231xx_usb_disconnect
,
1400 .id_table
= cx231xx_id_table
,
1403 module_usb_driver(cx231xx_usb_driver
);