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 /* Actually, it has a 417, but it isn't working correctly.
267 * So set to 0 for now until someone can manage to get this
268 * to work reliably. */
272 .type
= CX231XX_VMUX_COMPOSITE1
,
273 .vmux
= CX231XX_VIN_2_1
,
274 .amux
= CX231XX_AMUX_LINE_IN
,
277 .type
= CX231XX_VMUX_SVIDEO
,
278 .vmux
= CX231XX_VIN_1_1
|
279 (CX231XX_VIN_1_2
<< 8) |
281 .amux
= CX231XX_AMUX_LINE_IN
,
286 [CX231XX_BOARD_CNXT_RDE_250
] = {
287 .name
= "Conexant Hybrid TV - rde 250",
288 .tuner_type
= TUNER_XC5000
,
290 .tuner_gpio
= RDE250_XCV_TUNER
,
291 .tuner_sif_gpio
= 0x05,
292 .tuner_scl_gpio
= 0x1a,
293 .tuner_sda_gpio
= 0x1b,
294 .decoder
= CX231XX_AVDECODER
,
295 .output_mode
= OUT_MODE_VIP11
,
296 .demod_xfer_mode
= 0,
297 .ctl_pin_status_mask
= 0xFFFFFFC4,
298 .agc_analog_digital_select_gpio
= 0x0c,
299 .gpio_pin_status_mask
= 0x4001000,
300 .tuner_i2c_master
= 1,
301 .demod_i2c_master
= 2,
304 .norm
= V4L2_STD_PAL
,
307 .type
= CX231XX_VMUX_TELEVISION
,
308 .vmux
= CX231XX_VIN_2_1
,
309 .amux
= CX231XX_AMUX_VIDEO
,
314 [CX231XX_BOARD_CNXT_RDU_250
] = {
315 .name
= "Conexant Hybrid TV - RDU 250",
316 .tuner_type
= TUNER_XC5000
,
318 .tuner_gpio
= RDE250_XCV_TUNER
,
319 .tuner_sif_gpio
= 0x05,
320 .tuner_scl_gpio
= 0x1a,
321 .tuner_sda_gpio
= 0x1b,
322 .decoder
= CX231XX_AVDECODER
,
323 .output_mode
= OUT_MODE_VIP11
,
324 .demod_xfer_mode
= 0,
325 .ctl_pin_status_mask
= 0xFFFFFFC4,
326 .agc_analog_digital_select_gpio
= 0x0c,
327 .gpio_pin_status_mask
= 0x4001000,
328 .tuner_i2c_master
= 1,
329 .demod_i2c_master
= 2,
332 .norm
= V4L2_STD_NTSC
,
335 .type
= CX231XX_VMUX_TELEVISION
,
336 .vmux
= CX231XX_VIN_2_1
,
337 .amux
= CX231XX_AMUX_VIDEO
,
342 [CX231XX_BOARD_HAUPPAUGE_EXETER
] = {
343 .name
= "Hauppauge EXETER",
344 .tuner_type
= TUNER_NXP_TDA18271
,
346 .tuner_gpio
= RDE250_XCV_TUNER
,
347 .tuner_sif_gpio
= 0x05,
348 .tuner_scl_gpio
= 0x1a,
349 .tuner_sda_gpio
= 0x1b,
350 .decoder
= CX231XX_AVDECODER
,
351 .output_mode
= OUT_MODE_VIP11
,
352 .demod_xfer_mode
= 0,
353 .ctl_pin_status_mask
= 0xFFFFFFC4,
354 .agc_analog_digital_select_gpio
= 0x0c,
355 .gpio_pin_status_mask
= 0x4001000,
356 .tuner_i2c_master
= 1,
357 .demod_i2c_master
= 2,
360 .norm
= V4L2_STD_NTSC
,
363 .type
= CX231XX_VMUX_TELEVISION
,
364 .vmux
= CX231XX_VIN_3_1
,
365 .amux
= CX231XX_AMUX_VIDEO
,
368 .type
= CX231XX_VMUX_COMPOSITE1
,
369 .vmux
= CX231XX_VIN_2_1
,
370 .amux
= CX231XX_AMUX_LINE_IN
,
373 .type
= CX231XX_VMUX_SVIDEO
,
374 .vmux
= CX231XX_VIN_1_1
|
375 (CX231XX_VIN_1_2
<< 8) |
377 .amux
= CX231XX_AMUX_LINE_IN
,
381 [CX231XX_BOARD_HAUPPAUGE_USBLIVE2
] = {
382 .name
= "Hauppauge USB Live 2",
383 .tuner_type
= TUNER_ABSENT
,
384 .decoder
= CX231XX_AVDECODER
,
385 .output_mode
= OUT_MODE_VIP11
,
386 .demod_xfer_mode
= 0,
387 .ctl_pin_status_mask
= 0xFFFFFFC4,
388 .agc_analog_digital_select_gpio
= 0x0c,
389 .gpio_pin_status_mask
= 0x4001000,
390 .norm
= V4L2_STD_NTSC
,
393 .dont_use_port_3
= 1,
395 .type
= CX231XX_VMUX_COMPOSITE1
,
396 .vmux
= CX231XX_VIN_2_1
,
397 .amux
= CX231XX_AMUX_LINE_IN
,
400 .type
= CX231XX_VMUX_SVIDEO
,
401 .vmux
= CX231XX_VIN_1_1
|
402 (CX231XX_VIN_1_2
<< 8) |
404 .amux
= CX231XX_AMUX_LINE_IN
,
408 [CX231XX_BOARD_KWORLD_UB430_USB_HYBRID
] = {
409 .name
= "Kworld UB430 USB Hybrid",
410 .tuner_type
= TUNER_NXP_TDA18271
,
412 .decoder
= CX231XX_AVDECODER
,
413 .output_mode
= OUT_MODE_VIP11
,
414 .demod_xfer_mode
= 0,
415 .ctl_pin_status_mask
= 0xFFFFFFC4,
416 .agc_analog_digital_select_gpio
= 0x11, /* According with PV cxPolaris.inf file */
417 .tuner_sif_gpio
= -1,
418 .tuner_scl_gpio
= -1,
419 .tuner_sda_gpio
= -1,
420 .gpio_pin_status_mask
= 0x4001000,
421 .tuner_i2c_master
= 2,
422 .demod_i2c_master
= 1,
426 .norm
= V4L2_STD_PAL_M
,
428 .type
= CX231XX_VMUX_TELEVISION
,
429 .vmux
= CX231XX_VIN_3_1
,
430 .amux
= CX231XX_AMUX_VIDEO
,
433 .type
= CX231XX_VMUX_COMPOSITE1
,
434 .vmux
= CX231XX_VIN_2_1
,
435 .amux
= CX231XX_AMUX_LINE_IN
,
438 .type
= CX231XX_VMUX_SVIDEO
,
439 .vmux
= CX231XX_VIN_1_1
|
440 (CX231XX_VIN_1_2
<< 8) |
442 .amux
= CX231XX_AMUX_LINE_IN
,
446 [CX231XX_BOARD_PV_PLAYTV_USB_HYBRID
] = {
447 .name
= "Pixelview PlayTV USB Hybrid",
448 .tuner_type
= TUNER_NXP_TDA18271
,
450 .decoder
= CX231XX_AVDECODER
,
451 .output_mode
= OUT_MODE_VIP11
,
452 .demod_xfer_mode
= 0,
453 .ctl_pin_status_mask
= 0xFFFFFFC4,
454 .agc_analog_digital_select_gpio
= 0x00, /* According with PV cxPolaris.inf file */
455 .tuner_sif_gpio
= -1,
456 .tuner_scl_gpio
= -1,
457 .tuner_sda_gpio
= -1,
458 .gpio_pin_status_mask
= 0x4001000,
459 .tuner_i2c_master
= 2,
460 .demod_i2c_master
= 1,
462 .rc_map_name
= RC_MAP_PIXELVIEW_002T
,
465 .norm
= V4L2_STD_PAL_M
,
467 .type
= CX231XX_VMUX_TELEVISION
,
468 .vmux
= CX231XX_VIN_3_1
,
469 .amux
= CX231XX_AMUX_VIDEO
,
472 .type
= CX231XX_VMUX_COMPOSITE1
,
473 .vmux
= CX231XX_VIN_2_1
,
474 .amux
= CX231XX_AMUX_LINE_IN
,
477 .type
= CX231XX_VMUX_SVIDEO
,
478 .vmux
= CX231XX_VIN_1_1
|
479 (CX231XX_VIN_1_2
<< 8) |
481 .amux
= CX231XX_AMUX_LINE_IN
,
485 [CX231XX_BOARD_PV_XCAPTURE_USB
] = {
486 .name
= "Pixelview Xcapture USB",
487 .tuner_type
= TUNER_ABSENT
,
488 .decoder
= CX231XX_AVDECODER
,
489 .output_mode
= OUT_MODE_VIP11
,
490 .demod_xfer_mode
= 0,
491 .ctl_pin_status_mask
= 0xFFFFFFC4,
492 .agc_analog_digital_select_gpio
= 0x0c,
493 .gpio_pin_status_mask
= 0x4001000,
494 .norm
= V4L2_STD_NTSC
,
497 .dont_use_port_3
= 1,
500 .type
= CX231XX_VMUX_COMPOSITE1
,
501 .vmux
= CX231XX_VIN_2_1
,
502 .amux
= CX231XX_AMUX_LINE_IN
,
505 .type
= CX231XX_VMUX_SVIDEO
,
506 .vmux
= CX231XX_VIN_1_1
|
507 (CX231XX_VIN_1_2
<< 8) |
509 .amux
= CX231XX_AMUX_LINE_IN
,
515 [CX231XX_BOARD_ICONBIT_U100
] = {
516 .name
= "Iconbit Analog Stick U100 FM",
517 .tuner_type
= TUNER_ABSENT
,
518 .decoder
= CX231XX_AVDECODER
,
519 .output_mode
= OUT_MODE_VIP11
,
520 .demod_xfer_mode
= 0,
521 .ctl_pin_status_mask
= 0xFFFFFFC4,
522 .agc_analog_digital_select_gpio
= 0x1C,
523 .gpio_pin_status_mask
= 0x4001000,
526 .type
= CX231XX_VMUX_COMPOSITE1
,
527 .vmux
= CX231XX_VIN_2_1
,
528 .amux
= CX231XX_AMUX_LINE_IN
,
531 .type
= CX231XX_VMUX_SVIDEO
,
532 .vmux
= CX231XX_VIN_1_1
|
533 (CX231XX_VIN_1_2
<< 8) |
535 .amux
= CX231XX_AMUX_LINE_IN
,
539 [CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL
] = {
540 .name
= "Hauppauge WinTV USB2 FM (PAL)",
541 .tuner_type
= TUNER_NXP_TDA18271
,
543 .tuner_gpio
= RDE250_XCV_TUNER
,
544 .tuner_sif_gpio
= 0x05,
545 .tuner_scl_gpio
= 0x1a,
546 .tuner_sda_gpio
= 0x1b,
547 .decoder
= CX231XX_AVDECODER
,
548 .output_mode
= OUT_MODE_VIP11
,
549 .ctl_pin_status_mask
= 0xFFFFFFC4,
550 .agc_analog_digital_select_gpio
= 0x0c,
551 .gpio_pin_status_mask
= 0x4001000,
552 .tuner_i2c_master
= 1,
553 .norm
= V4L2_STD_PAL
,
556 .type
= CX231XX_VMUX_TELEVISION
,
557 .vmux
= CX231XX_VIN_3_1
,
558 .amux
= CX231XX_AMUX_VIDEO
,
561 .type
= CX231XX_VMUX_COMPOSITE1
,
562 .vmux
= CX231XX_VIN_2_1
,
563 .amux
= CX231XX_AMUX_LINE_IN
,
566 .type
= CX231XX_VMUX_SVIDEO
,
567 .vmux
= CX231XX_VIN_1_1
|
568 (CX231XX_VIN_1_2
<< 8) |
570 .amux
= CX231XX_AMUX_LINE_IN
,
574 [CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC
] = {
575 .name
= "Hauppauge WinTV USB2 FM (NTSC)",
576 .tuner_type
= TUNER_NXP_TDA18271
,
578 .tuner_gpio
= RDE250_XCV_TUNER
,
579 .tuner_sif_gpio
= 0x05,
580 .tuner_scl_gpio
= 0x1a,
581 .tuner_sda_gpio
= 0x1b,
582 .decoder
= CX231XX_AVDECODER
,
583 .output_mode
= OUT_MODE_VIP11
,
584 .ctl_pin_status_mask
= 0xFFFFFFC4,
585 .agc_analog_digital_select_gpio
= 0x0c,
586 .gpio_pin_status_mask
= 0x4001000,
587 .tuner_i2c_master
= 1,
588 .norm
= V4L2_STD_NTSC
,
591 .type
= CX231XX_VMUX_TELEVISION
,
592 .vmux
= CX231XX_VIN_3_1
,
593 .amux
= CX231XX_AMUX_VIDEO
,
596 .type
= CX231XX_VMUX_COMPOSITE1
,
597 .vmux
= CX231XX_VIN_2_1
,
598 .amux
= CX231XX_AMUX_LINE_IN
,
601 .type
= CX231XX_VMUX_SVIDEO
,
602 .vmux
= CX231XX_VIN_1_1
|
603 (CX231XX_VIN_1_2
<< 8) |
605 .amux
= CX231XX_AMUX_LINE_IN
,
609 [CX231XX_BOARD_ELGATO_VIDEO_CAPTURE_V2
] = {
610 .name
= "Elgato Video Capture V2",
611 .tuner_type
= TUNER_ABSENT
,
612 .decoder
= CX231XX_AVDECODER
,
613 .output_mode
= OUT_MODE_VIP11
,
614 .demod_xfer_mode
= 0,
615 .ctl_pin_status_mask
= 0xFFFFFFC4,
616 .agc_analog_digital_select_gpio
= 0x0c,
617 .gpio_pin_status_mask
= 0x4001000,
618 .norm
= V4L2_STD_NTSC
,
621 .dont_use_port_3
= 1,
623 .type
= CX231XX_VMUX_COMPOSITE1
,
624 .vmux
= CX231XX_VIN_2_1
,
625 .amux
= CX231XX_AMUX_LINE_IN
,
628 .type
= CX231XX_VMUX_SVIDEO
,
629 .vmux
= CX231XX_VIN_1_1
|
630 (CX231XX_VIN_1_2
<< 8) |
632 .amux
= CX231XX_AMUX_LINE_IN
,
637 const unsigned int cx231xx_bcount
= ARRAY_SIZE(cx231xx_boards
);
639 /* table of devices that work with this driver */
640 struct usb_device_id cx231xx_id_table
[] = {
641 {USB_DEVICE(0x0572, 0x5A3C),
642 .driver_info
= CX231XX_BOARD_UNKNOWN
},
643 {USB_DEVICE(0x0572, 0x58A2),
644 .driver_info
= CX231XX_BOARD_CNXT_CARRAERA
},
645 {USB_DEVICE(0x0572, 0x58A1),
646 .driver_info
= CX231XX_BOARD_CNXT_SHELBY
},
647 {USB_DEVICE(0x0572, 0x58A4),
648 .driver_info
= CX231XX_BOARD_CNXT_RDE_253S
},
649 {USB_DEVICE(0x0572, 0x58A5),
650 .driver_info
= CX231XX_BOARD_CNXT_RDU_253S
},
651 {USB_DEVICE(0x0572, 0x58A6),
652 .driver_info
= CX231XX_BOARD_CNXT_VIDEO_GRABBER
},
653 {USB_DEVICE(0x0572, 0x589E),
654 .driver_info
= CX231XX_BOARD_CNXT_RDE_250
},
655 {USB_DEVICE(0x0572, 0x58A0),
656 .driver_info
= CX231XX_BOARD_CNXT_RDU_250
},
657 {USB_DEVICE(0x2040, 0xb110),
658 .driver_info
= CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL
},
659 {USB_DEVICE(0x2040, 0xb111),
660 .driver_info
= CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC
},
661 {USB_DEVICE(0x2040, 0xb120),
662 .driver_info
= CX231XX_BOARD_HAUPPAUGE_EXETER
},
663 {USB_DEVICE(0x2040, 0xb140),
664 .driver_info
= CX231XX_BOARD_HAUPPAUGE_EXETER
},
665 {USB_DEVICE(0x2040, 0xc200),
666 .driver_info
= CX231XX_BOARD_HAUPPAUGE_USBLIVE2
},
667 {USB_DEVICE_VER(USB_VID_PIXELVIEW
, USB_PID_PIXELVIEW_SBTVD
, 0x4000, 0x4001),
668 .driver_info
= CX231XX_BOARD_PV_PLAYTV_USB_HYBRID
},
669 {USB_DEVICE(USB_VID_PIXELVIEW
, 0x5014),
670 .driver_info
= CX231XX_BOARD_PV_XCAPTURE_USB
},
671 {USB_DEVICE(0x1b80, 0xe424),
672 .driver_info
= CX231XX_BOARD_KWORLD_UB430_USB_HYBRID
},
673 {USB_DEVICE(0x1f4d, 0x0237),
674 .driver_info
= CX231XX_BOARD_ICONBIT_U100
},
675 {USB_DEVICE(0x0fd9, 0x0037),
676 .driver_info
= CX231XX_BOARD_ELGATO_VIDEO_CAPTURE_V2
},
680 MODULE_DEVICE_TABLE(usb
, cx231xx_id_table
);
682 /* cx231xx_tuner_callback
683 * will be used to reset XC5000 tuner using GPIO pin
686 int cx231xx_tuner_callback(void *ptr
, int component
, int command
, int arg
)
689 struct cx231xx
*dev
= ptr
;
691 if (dev
->tuner_type
== TUNER_XC5000
) {
692 if (command
== XC5000_TUNER_RESET
) {
694 ("Tuner CB: RESET: cmd %d : tuner type %d \n",
695 command
, dev
->tuner_type
);
696 cx231xx_set_gpio_value(dev
, dev
->board
.tuner_gpio
->bit
,
699 cx231xx_set_gpio_value(dev
, dev
->board
.tuner_gpio
->bit
,
702 cx231xx_set_gpio_value(dev
, dev
->board
.tuner_gpio
->bit
,
706 } else if (dev
->tuner_type
== TUNER_NXP_TDA18271
) {
708 case TDA18271_CALLBACK_CMD_AGC_ENABLE
:
709 if (dev
->model
== CX231XX_BOARD_PV_PLAYTV_USB_HYBRID
)
710 rc
= cx231xx_set_agc_analog_digital_mux_select(dev
, arg
);
719 EXPORT_SYMBOL_GPL(cx231xx_tuner_callback
);
721 static void cx231xx_reset_out(struct cx231xx
*dev
)
723 cx231xx_set_gpio_value(dev
, CX23417_RESET
, 1);
725 cx231xx_set_gpio_value(dev
, CX23417_RESET
, 0);
727 cx231xx_set_gpio_value(dev
, CX23417_RESET
, 1);
730 static void cx231xx_enable_OSC(struct cx231xx
*dev
)
732 cx231xx_set_gpio_value(dev
, CX23417_OSC_EN
, 1);
735 static void cx231xx_sleep_s5h1432(struct cx231xx
*dev
)
737 cx231xx_set_gpio_value(dev
, SLEEP_S5H1432
, 0);
740 static inline void cx231xx_set_model(struct cx231xx
*dev
)
742 dev
->board
= cx231xx_boards
[dev
->model
];
745 /* Since cx231xx_pre_card_setup() requires a proper dev->model,
746 * this won't work for boards with generic PCI IDs
748 void cx231xx_pre_card_setup(struct cx231xx
*dev
)
751 cx231xx_set_model(dev
);
753 cx231xx_info("Identified as %s (card=%d)\n",
754 dev
->board
.name
, dev
->model
);
756 /* set the direction for GPIO pins */
757 if (dev
->board
.tuner_gpio
) {
758 cx231xx_set_gpio_direction(dev
, dev
->board
.tuner_gpio
->bit
, 1);
759 cx231xx_set_gpio_value(dev
, dev
->board
.tuner_gpio
->bit
, 1);
761 if (dev
->board
.tuner_sif_gpio
>= 0)
762 cx231xx_set_gpio_direction(dev
, dev
->board
.tuner_sif_gpio
, 1);
764 /* request some modules if any required */
766 /* set the mode to Analog mode initially */
767 cx231xx_set_mode(dev
, CX231XX_ANALOG_MODE
);
770 /* cx231xx_set_mode(dev, CX231XX_SUSPEND); */
774 static void cx231xx_config_tuner(struct cx231xx
*dev
)
776 struct tuner_setup tun_setup
;
777 struct v4l2_frequency f
;
779 if (dev
->tuner_type
== TUNER_ABSENT
)
782 tun_setup
.mode_mask
= T_ANALOG_TV
| T_RADIO
;
783 tun_setup
.type
= dev
->tuner_type
;
784 tun_setup
.addr
= dev
->tuner_addr
;
785 tun_setup
.tuner_callback
= cx231xx_tuner_callback
;
787 tuner_call(dev
, tuner
, s_type_addr
, &tun_setup
);
790 if (tun_setup
.type
== TUNER_XC5000
) {
791 static struct xc2028_ctrl ctrl
= {
792 .fname
= XC5000_DEFAULT_FIRMWARE
,
796 struct v4l2_priv_tun_config cfg
= {
797 .tuner
= dev
->tuner_type
,
800 tuner_call(dev
, tuner
, s_config
, &cfg
);
803 /* configure tuner */
805 f
.type
= V4L2_TUNER_ANALOG_TV
;
806 f
.frequency
= 9076; /* just a magic number */
807 dev
->ctl_freq
= f
.frequency
;
808 call_all(dev
, tuner
, s_frequency
, &f
);
812 void cx231xx_card_setup(struct cx231xx
*dev
)
815 cx231xx_set_model(dev
);
817 dev
->tuner_type
= cx231xx_boards
[dev
->model
].tuner_type
;
818 if (cx231xx_boards
[dev
->model
].tuner_addr
)
819 dev
->tuner_addr
= cx231xx_boards
[dev
->model
].tuner_addr
;
821 /* request some modules */
822 if (dev
->board
.decoder
== CX231XX_AVDECODER
) {
823 dev
->sd_cx25840
= v4l2_i2c_new_subdev(&dev
->v4l2_dev
,
824 &dev
->i2c_bus
[0].i2c_adap
,
825 "cx25840", 0x88 >> 1, NULL
);
826 if (dev
->sd_cx25840
== NULL
)
827 cx231xx_info("cx25840 subdev registration failure\n");
828 cx25840_call(dev
, core
, load_fw
);
832 /* Initialize the tuner */
833 if (dev
->board
.tuner_type
!= TUNER_ABSENT
) {
834 dev
->sd_tuner
= v4l2_i2c_new_subdev(&dev
->v4l2_dev
,
835 &dev
->i2c_bus
[dev
->board
.tuner_i2c_master
].i2c_adap
,
837 dev
->tuner_addr
, NULL
);
838 if (dev
->sd_tuner
== NULL
)
839 cx231xx_info("tuner subdev registration failure\n");
841 cx231xx_config_tuner(dev
);
847 * inits registers with sane defaults
849 int cx231xx_config(struct cx231xx
*dev
)
851 /* TBD need to add cx231xx specific code */
857 * cx231xx_config_i2c()
858 * configure i2c attached devices
860 void cx231xx_config_i2c(struct cx231xx
*dev
)
862 /* u32 input = INPUT(dev->video_input)->vmux; */
864 call_all(dev
, video
, s_stream
, 1);
868 * cx231xx_realease_resources()
869 * unregisters the v4l2,i2c and usb devices
870 * called when the device gets disconected or at module unload
872 void cx231xx_release_resources(struct cx231xx
*dev
)
874 cx231xx_release_analog_resources(dev
);
876 cx231xx_remove_from_devlist(dev
);
878 cx231xx_ir_exit(dev
);
880 /* Release I2C buses */
881 cx231xx_dev_uninit(dev
);
883 /* delete v4l2 device */
884 v4l2_device_unregister(&dev
->v4l2_dev
);
886 usb_put_dev(dev
->udev
);
888 /* Mark device as unused */
889 clear_bit(dev
->devno
, &cx231xx_devused
);
891 kfree(dev
->video_mode
.alt_max_pkt_size
);
892 kfree(dev
->vbi_mode
.alt_max_pkt_size
);
893 kfree(dev
->sliced_cc_mode
.alt_max_pkt_size
);
894 kfree(dev
->ts1_mode
.alt_max_pkt_size
);
900 * allocates and inits the device structs, registers i2c bus and v4l device
902 static int cx231xx_init_dev(struct cx231xx
*dev
, struct usb_device
*udev
,
905 int retval
= -ENOMEM
;
907 unsigned int maxh
, maxw
;
910 mutex_init(&dev
->lock
);
911 mutex_init(&dev
->ctrl_urb_lock
);
912 mutex_init(&dev
->gpio_i2c_lock
);
913 mutex_init(&dev
->i2c_lock
);
915 spin_lock_init(&dev
->video_mode
.slock
);
916 spin_lock_init(&dev
->vbi_mode
.slock
);
917 spin_lock_init(&dev
->sliced_cc_mode
.slock
);
919 init_waitqueue_head(&dev
->open
);
920 init_waitqueue_head(&dev
->wait_frame
);
921 init_waitqueue_head(&dev
->wait_stream
);
923 dev
->cx231xx_read_ctrl_reg
= cx231xx_read_ctrl_reg
;
924 dev
->cx231xx_write_ctrl_reg
= cx231xx_write_ctrl_reg
;
925 dev
->cx231xx_send_usb_command
= cx231xx_send_usb_command
;
926 dev
->cx231xx_gpio_i2c_read
= cx231xx_gpio_i2c_read
;
927 dev
->cx231xx_gpio_i2c_write
= cx231xx_gpio_i2c_write
;
929 /* Query cx231xx to find what pcb config it is related to */
930 initialize_cx231xx(dev
);
932 /*To workaround error number=-71 on EP0 for VideoGrabber,
934 if (dev
->model
== CX231XX_BOARD_CNXT_VIDEO_GRABBER
||
935 dev
->model
== CX231XX_BOARD_HAUPPAUGE_USBLIVE2
) {
936 cx231xx_set_alt_setting(dev
, INDEX_VIDEO
, 3);
937 cx231xx_set_alt_setting(dev
, INDEX_VANC
, 1);
939 /* Cx231xx pre card setup */
940 cx231xx_pre_card_setup(dev
);
942 errCode
= cx231xx_config(dev
);
944 cx231xx_errdev("error configuring device\n");
948 /* set default norm */
949 dev
->norm
= dev
->board
.norm
;
951 /* register i2c bus */
952 errCode
= cx231xx_dev_init(dev
);
954 cx231xx_dev_uninit(dev
);
955 cx231xx_errdev("%s: cx231xx_i2c_register - errCode [%d]!\n",
960 /* Do board specific init */
961 cx231xx_card_setup(dev
);
963 /* configure the device */
964 cx231xx_config_i2c(dev
);
966 maxw
= norm_maxw(dev
);
967 maxh
= norm_maxh(dev
);
969 /* set default image size */
973 dev
->video_input
= 0;
975 errCode
= cx231xx_config(dev
);
977 cx231xx_errdev("%s: cx231xx_config - errCode [%d]!\n",
982 /* init video dma queues */
983 INIT_LIST_HEAD(&dev
->video_mode
.vidq
.active
);
984 INIT_LIST_HEAD(&dev
->video_mode
.vidq
.queued
);
986 /* init vbi dma queues */
987 INIT_LIST_HEAD(&dev
->vbi_mode
.vidq
.active
);
988 INIT_LIST_HEAD(&dev
->vbi_mode
.vidq
.queued
);
990 /* Reset other chips required if they are tied up with GPIO pins */
991 cx231xx_add_into_devlist(dev
);
993 if (dev
->board
.has_417
) {
994 printk(KERN_INFO
"attach 417 %d\n", dev
->model
);
995 if (cx231xx_417_register(dev
) < 0) {
997 "%s() Failed to register 417 on VID_B\n",
1002 retval
= cx231xx_register_analog_devices(dev
);
1004 cx231xx_release_resources(dev
);
1008 cx231xx_ir_init(dev
);
1010 cx231xx_init_extension(dev
);
1015 #if defined(CONFIG_MODULES) && defined(MODULE)
1016 static void request_module_async(struct work_struct
*work
)
1018 struct cx231xx
*dev
= container_of(work
,
1019 struct cx231xx
, request_module_wk
);
1021 if (dev
->has_alsa_audio
)
1022 request_module("cx231xx-alsa");
1024 if (dev
->board
.has_dvb
)
1025 request_module("cx231xx-dvb");
1029 static void request_modules(struct cx231xx
*dev
)
1031 INIT_WORK(&dev
->request_module_wk
, request_module_async
);
1032 schedule_work(&dev
->request_module_wk
);
1035 static void flush_request_modules(struct cx231xx
*dev
)
1037 flush_work(&dev
->request_module_wk
);
1040 #define request_modules(dev)
1041 #define flush_request_modules(dev)
1042 #endif /* CONFIG_MODULES */
1045 * cx231xx_usb_probe()
1046 * checks for supported devices
1048 static int cx231xx_usb_probe(struct usb_interface
*interface
,
1049 const struct usb_device_id
*id
)
1051 struct usb_device
*udev
;
1052 struct usb_interface
*uif
;
1053 struct cx231xx
*dev
= NULL
;
1054 int retval
= -ENODEV
;
1056 int i
, isoc_pipe
= 0;
1058 struct usb_interface_assoc_descriptor
*assoc_desc
;
1060 udev
= usb_get_dev(interface_to_usbdev(interface
));
1061 ifnum
= interface
->altsetting
[0].desc
.bInterfaceNumber
;
1064 * Interface number 0 - IR interface (handled by mceusb driver)
1065 * Interface number 1 - AV interface (handled by this driver)
1070 /* Check to see next free device and mark as used */
1072 nr
= find_first_zero_bit(&cx231xx_devused
, CX231XX_MAXBOARDS
);
1073 if (nr
>= CX231XX_MAXBOARDS
) {
1074 /* No free device slots */
1075 cx231xx_err(DRIVER_NAME
": Supports only %i devices.\n",
1079 } while (test_and_set_bit(nr
, &cx231xx_devused
));
1081 /* allocate memory for our device state and initialize it */
1082 dev
= kzalloc(sizeof(*dev
), GFP_KERNEL
);
1084 cx231xx_err(DRIVER_NAME
": out of memory!\n");
1085 clear_bit(nr
, &cx231xx_devused
);
1089 snprintf(dev
->name
, 29, "cx231xx #%d", nr
);
1091 dev
->model
= id
->driver_info
;
1092 dev
->video_mode
.alt
= -1;
1094 dev
->interface_count
++;
1095 /* reset gpio dir and value */
1098 dev
->xc_fw_load_done
= 0;
1099 dev
->has_alsa_audio
= 1;
1100 dev
->power_mode
= -1;
1101 atomic_set(&dev
->devlist_count
, 0);
1103 /* 0 - vbi ; 1 -sliced cc mode */
1104 dev
->vbi_or_sliced_cc_mode
= 0;
1106 /* get maximum no.of IAD interfaces */
1107 assoc_desc
= udev
->actconfig
->intf_assoc
[0];
1108 dev
->max_iad_interface_count
= assoc_desc
->bInterfaceCount
;
1110 /* init CIR module TBD */
1112 /*mode_tv: digital=1 or analog=0*/
1115 dev
->USE_ISO
= transfer_mode
;
1117 switch (udev
->speed
) {
1121 case USB_SPEED_UNKNOWN
:
1122 case USB_SPEED_FULL
:
1125 case USB_SPEED_HIGH
:
1132 cx231xx_info("New device %s %s @ %s Mbps "
1133 "(%04x:%04x) with %d interfaces\n",
1134 udev
->manufacturer
? udev
->manufacturer
: "",
1135 udev
->product
? udev
->product
: "",
1137 le16_to_cpu(udev
->descriptor
.idVendor
),
1138 le16_to_cpu(udev
->descriptor
.idProduct
),
1139 dev
->max_iad_interface_count
);
1141 /* increment interface count */
1142 dev
->interface_count
++;
1144 /* get device number */
1147 assoc_desc
= udev
->actconfig
->intf_assoc
[0];
1148 if (assoc_desc
->bFirstInterface
!= ifnum
) {
1149 cx231xx_err(DRIVER_NAME
": Not found "
1150 "matching IAD interface\n");
1151 clear_bit(dev
->devno
, &cx231xx_devused
);
1157 cx231xx_info("registering interface %d\n", ifnum
);
1159 /* save our data pointer in this interface device */
1160 usb_set_intfdata(interface
, dev
);
1163 * AV device initialization - only done at the last interface
1166 /* Create v4l2 device */
1167 retval
= v4l2_device_register(&interface
->dev
, &dev
->v4l2_dev
);
1169 cx231xx_errdev("v4l2_device_register failed\n");
1170 clear_bit(dev
->devno
, &cx231xx_devused
);
1175 /* allocate device struct */
1176 retval
= cx231xx_init_dev(dev
, udev
, nr
);
1178 clear_bit(dev
->devno
, &cx231xx_devused
);
1179 v4l2_device_unregister(&dev
->v4l2_dev
);
1182 usb_set_intfdata(interface
, NULL
);
1187 /* compute alternate max packet sizes for video */
1188 uif
= udev
->actconfig
->interface
[dev
->current_pcb_config
.
1189 hs_config_info
[0].interface_info
.video_index
+ 1];
1191 dev
->video_mode
.end_point_addr
= le16_to_cpu(uif
->altsetting
[0].
1192 endpoint
[isoc_pipe
].desc
.bEndpointAddress
);
1194 dev
->video_mode
.num_alt
= uif
->num_altsetting
;
1195 cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n",
1196 dev
->video_mode
.end_point_addr
,
1197 dev
->video_mode
.num_alt
);
1198 dev
->video_mode
.alt_max_pkt_size
=
1199 kmalloc(32 * dev
->video_mode
.num_alt
, GFP_KERNEL
);
1201 if (dev
->video_mode
.alt_max_pkt_size
== NULL
) {
1202 cx231xx_errdev("out of memory!\n");
1203 clear_bit(dev
->devno
, &cx231xx_devused
);
1204 v4l2_device_unregister(&dev
->v4l2_dev
);
1210 for (i
= 0; i
< dev
->video_mode
.num_alt
; i
++) {
1211 u16 tmp
= le16_to_cpu(uif
->altsetting
[i
].endpoint
[isoc_pipe
].
1212 desc
.wMaxPacketSize
);
1213 dev
->video_mode
.alt_max_pkt_size
[i
] =
1214 (tmp
& 0x07ff) * (((tmp
& 0x1800) >> 11) + 1);
1215 cx231xx_info("Alternate setting %i, max size= %i\n", i
,
1216 dev
->video_mode
.alt_max_pkt_size
[i
]);
1219 /* compute alternate max packet sizes for vbi */
1220 uif
= udev
->actconfig
->interface
[dev
->current_pcb_config
.
1221 hs_config_info
[0].interface_info
.
1224 dev
->vbi_mode
.end_point_addr
=
1225 le16_to_cpu(uif
->altsetting
[0].endpoint
[isoc_pipe
].desc
.
1228 dev
->vbi_mode
.num_alt
= uif
->num_altsetting
;
1229 cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n",
1230 dev
->vbi_mode
.end_point_addr
,
1231 dev
->vbi_mode
.num_alt
);
1232 dev
->vbi_mode
.alt_max_pkt_size
=
1233 kmalloc(32 * dev
->vbi_mode
.num_alt
, GFP_KERNEL
);
1235 if (dev
->vbi_mode
.alt_max_pkt_size
== NULL
) {
1236 cx231xx_errdev("out of memory!\n");
1237 clear_bit(dev
->devno
, &cx231xx_devused
);
1238 v4l2_device_unregister(&dev
->v4l2_dev
);
1244 for (i
= 0; i
< dev
->vbi_mode
.num_alt
; i
++) {
1246 le16_to_cpu(uif
->altsetting
[i
].endpoint
[isoc_pipe
].
1247 desc
.wMaxPacketSize
);
1248 dev
->vbi_mode
.alt_max_pkt_size
[i
] =
1249 (tmp
& 0x07ff) * (((tmp
& 0x1800) >> 11) + 1);
1250 cx231xx_info("Alternate setting %i, max size= %i\n", i
,
1251 dev
->vbi_mode
.alt_max_pkt_size
[i
]);
1254 /* compute alternate max packet sizes for sliced CC */
1255 uif
= udev
->actconfig
->interface
[dev
->current_pcb_config
.
1256 hs_config_info
[0].interface_info
.
1259 dev
->sliced_cc_mode
.end_point_addr
=
1260 le16_to_cpu(uif
->altsetting
[0].endpoint
[isoc_pipe
].desc
.
1263 dev
->sliced_cc_mode
.num_alt
= uif
->num_altsetting
;
1264 cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n",
1265 dev
->sliced_cc_mode
.end_point_addr
,
1266 dev
->sliced_cc_mode
.num_alt
);
1267 dev
->sliced_cc_mode
.alt_max_pkt_size
=
1268 kmalloc(32 * dev
->sliced_cc_mode
.num_alt
, GFP_KERNEL
);
1270 if (dev
->sliced_cc_mode
.alt_max_pkt_size
== NULL
) {
1271 cx231xx_errdev("out of memory!\n");
1272 clear_bit(dev
->devno
, &cx231xx_devused
);
1273 v4l2_device_unregister(&dev
->v4l2_dev
);
1279 for (i
= 0; i
< dev
->sliced_cc_mode
.num_alt
; i
++) {
1280 u16 tmp
= le16_to_cpu(uif
->altsetting
[i
].endpoint
[isoc_pipe
].
1281 desc
.wMaxPacketSize
);
1282 dev
->sliced_cc_mode
.alt_max_pkt_size
[i
] =
1283 (tmp
& 0x07ff) * (((tmp
& 0x1800) >> 11) + 1);
1284 cx231xx_info("Alternate setting %i, max size= %i\n", i
,
1285 dev
->sliced_cc_mode
.alt_max_pkt_size
[i
]);
1288 if (dev
->current_pcb_config
.ts1_source
!= 0xff) {
1289 /* compute alternate max packet sizes for TS1 */
1290 uif
= udev
->actconfig
->interface
[dev
->current_pcb_config
.
1295 dev
->ts1_mode
.end_point_addr
=
1296 le16_to_cpu(uif
->altsetting
[0].endpoint
[isoc_pipe
].
1297 desc
.bEndpointAddress
);
1299 dev
->ts1_mode
.num_alt
= uif
->num_altsetting
;
1300 cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n",
1301 dev
->ts1_mode
.end_point_addr
,
1302 dev
->ts1_mode
.num_alt
);
1303 dev
->ts1_mode
.alt_max_pkt_size
=
1304 kmalloc(32 * dev
->ts1_mode
.num_alt
, GFP_KERNEL
);
1306 if (dev
->ts1_mode
.alt_max_pkt_size
== NULL
) {
1307 cx231xx_errdev("out of memory!\n");
1308 clear_bit(dev
->devno
, &cx231xx_devused
);
1309 v4l2_device_unregister(&dev
->v4l2_dev
);
1315 for (i
= 0; i
< dev
->ts1_mode
.num_alt
; i
++) {
1316 u16 tmp
= le16_to_cpu(uif
->altsetting
[i
].
1317 endpoint
[isoc_pipe
].desc
.
1319 dev
->ts1_mode
.alt_max_pkt_size
[i
] =
1320 (tmp
& 0x07ff) * (((tmp
& 0x1800) >> 11) + 1);
1321 cx231xx_info("Alternate setting %i, max size= %i\n", i
,
1322 dev
->ts1_mode
.alt_max_pkt_size
[i
]);
1326 if (dev
->model
== CX231XX_BOARD_CNXT_VIDEO_GRABBER
) {
1327 cx231xx_enable_OSC(dev
);
1328 cx231xx_reset_out(dev
);
1329 cx231xx_set_alt_setting(dev
, INDEX_VIDEO
, 3);
1332 if (dev
->model
== CX231XX_BOARD_CNXT_RDE_253S
)
1333 cx231xx_sleep_s5h1432(dev
);
1335 /* load other modules required */
1336 request_modules(dev
);
1342 * cx231xx_usb_disconnect()
1343 * called when the device gets diconencted
1344 * video device will be unregistered on v4l2_close in case it is still open
1346 static void cx231xx_usb_disconnect(struct usb_interface
*interface
)
1348 struct cx231xx
*dev
;
1350 dev
= usb_get_intfdata(interface
);
1351 usb_set_intfdata(interface
, NULL
);
1359 dev
->state
|= DEV_DISCONNECTED
;
1361 flush_request_modules(dev
);
1363 /* wait until all current v4l2 io is finished then deallocate
1365 mutex_lock(&dev
->lock
);
1367 wake_up_interruptible_all(&dev
->open
);
1371 ("device %s is open! Deregistration and memory "
1372 "deallocation are deferred on close.\n",
1373 video_device_node_name(dev
->vdev
));
1375 /* Even having users, it is safe to remove the RC i2c driver */
1376 cx231xx_ir_exit(dev
);
1379 cx231xx_uninit_isoc(dev
);
1381 cx231xx_uninit_bulk(dev
);
1382 wake_up_interruptible(&dev
->wait_frame
);
1383 wake_up_interruptible(&dev
->wait_stream
);
1387 cx231xx_close_extension(dev
);
1389 mutex_unlock(&dev
->lock
);
1392 cx231xx_release_resources(dev
);
1395 static struct usb_driver cx231xx_usb_driver
= {
1397 .probe
= cx231xx_usb_probe
,
1398 .disconnect
= cx231xx_usb_disconnect
,
1399 .id_table
= cx231xx_id_table
,
1402 module_usb_driver(cx231xx_usb_driver
);