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>
33 #include <media/cx25840.h>
34 #include "dvb-usb-ids.h"
40 static int tuner
= -1;
41 module_param(tuner
, int, 0444);
42 MODULE_PARM_DESC(tuner
, "tuner type");
44 static int transfer_mode
= 1;
45 module_param(transfer_mode
, int, 0444);
46 MODULE_PARM_DESC(transfer_mode
, "transfer mode (1-ISO or 0-BULK)");
48 static unsigned int disable_ir
;
49 module_param(disable_ir
, int, 0444);
50 MODULE_PARM_DESC(disable_ir
, "disable infrared remote support");
52 /* Bitmask marking allocated devices from 0 to CX231XX_MAXBOARDS */
53 static unsigned long cx231xx_devused
;
56 * Reset sequences for analog/digital modes
59 static struct cx231xx_reg_seq RDE250_XCV_TUNER
[] = {
69 struct cx231xx_board cx231xx_boards
[] = {
70 [CX231XX_BOARD_UNKNOWN
] = {
71 .name
= "Unknown CX231xx video grabber",
72 .tuner_type
= TUNER_ABSENT
,
74 .type
= CX231XX_VMUX_TELEVISION
,
75 .vmux
= CX231XX_VIN_3_1
,
76 .amux
= CX231XX_AMUX_VIDEO
,
79 .type
= CX231XX_VMUX_COMPOSITE1
,
80 .vmux
= CX231XX_VIN_2_1
,
81 .amux
= CX231XX_AMUX_LINE_IN
,
84 .type
= CX231XX_VMUX_SVIDEO
,
85 .vmux
= CX231XX_VIN_1_1
|
86 (CX231XX_VIN_1_2
<< 8) |
88 .amux
= CX231XX_AMUX_LINE_IN
,
93 [CX231XX_BOARD_CNXT_CARRAERA
] = {
94 .name
= "Conexant Hybrid TV - CARRAERA",
95 .tuner_type
= TUNER_XC5000
,
97 .tuner_gpio
= RDE250_XCV_TUNER
,
98 .tuner_sif_gpio
= 0x05,
99 .tuner_scl_gpio
= 0x1a,
100 .tuner_sda_gpio
= 0x1b,
101 .decoder
= CX231XX_AVDECODER
,
102 .output_mode
= OUT_MODE_VIP11
,
103 .demod_xfer_mode
= 0,
104 .ctl_pin_status_mask
= 0xFFFFFFC4,
105 .agc_analog_digital_select_gpio
= 0x0c,
106 .gpio_pin_status_mask
= 0x4001000,
107 .tuner_i2c_master
= 1,
108 .demod_i2c_master
= 2,
111 .norm
= V4L2_STD_PAL
,
114 .type
= CX231XX_VMUX_TELEVISION
,
115 .vmux
= CX231XX_VIN_3_1
,
116 .amux
= CX231XX_AMUX_VIDEO
,
119 .type
= CX231XX_VMUX_COMPOSITE1
,
120 .vmux
= CX231XX_VIN_2_1
,
121 .amux
= CX231XX_AMUX_LINE_IN
,
124 .type
= CX231XX_VMUX_SVIDEO
,
125 .vmux
= CX231XX_VIN_1_1
|
126 (CX231XX_VIN_1_2
<< 8) |
128 .amux
= CX231XX_AMUX_LINE_IN
,
133 [CX231XX_BOARD_CNXT_SHELBY
] = {
134 .name
= "Conexant Hybrid TV - SHELBY",
135 .tuner_type
= TUNER_XC5000
,
137 .tuner_gpio
= RDE250_XCV_TUNER
,
138 .tuner_sif_gpio
= 0x05,
139 .tuner_scl_gpio
= 0x1a,
140 .tuner_sda_gpio
= 0x1b,
141 .decoder
= CX231XX_AVDECODER
,
142 .output_mode
= OUT_MODE_VIP11
,
143 .demod_xfer_mode
= 0,
144 .ctl_pin_status_mask
= 0xFFFFFFC4,
145 .agc_analog_digital_select_gpio
= 0x0c,
146 .gpio_pin_status_mask
= 0x4001000,
147 .tuner_i2c_master
= 1,
148 .demod_i2c_master
= 2,
151 .norm
= V4L2_STD_NTSC
,
154 .type
= CX231XX_VMUX_TELEVISION
,
155 .vmux
= CX231XX_VIN_3_1
,
156 .amux
= CX231XX_AMUX_VIDEO
,
159 .type
= CX231XX_VMUX_COMPOSITE1
,
160 .vmux
= CX231XX_VIN_2_1
,
161 .amux
= CX231XX_AMUX_LINE_IN
,
164 .type
= CX231XX_VMUX_SVIDEO
,
165 .vmux
= CX231XX_VIN_1_1
|
166 (CX231XX_VIN_1_2
<< 8) |
168 .amux
= CX231XX_AMUX_LINE_IN
,
173 [CX231XX_BOARD_CNXT_RDE_253S
] = {
174 .name
= "Conexant Hybrid TV - RDE253S",
175 .tuner_type
= TUNER_NXP_TDA18271
,
177 .tuner_gpio
= RDE250_XCV_TUNER
,
178 .tuner_sif_gpio
= 0x05,
179 .tuner_scl_gpio
= 0x1a,
180 .tuner_sda_gpio
= 0x1b,
181 .decoder
= CX231XX_AVDECODER
,
182 .output_mode
= OUT_MODE_VIP11
,
183 .demod_xfer_mode
= 0,
184 .ctl_pin_status_mask
= 0xFFFFFFC4,
185 .agc_analog_digital_select_gpio
= 0x1c,
186 .gpio_pin_status_mask
= 0x4001000,
187 .tuner_i2c_master
= 1,
188 .demod_i2c_master
= 2,
191 .norm
= V4L2_STD_PAL
,
194 .type
= CX231XX_VMUX_TELEVISION
,
195 .vmux
= CX231XX_VIN_3_1
,
196 .amux
= CX231XX_AMUX_VIDEO
,
199 .type
= CX231XX_VMUX_COMPOSITE1
,
200 .vmux
= CX231XX_VIN_2_1
,
201 .amux
= CX231XX_AMUX_LINE_IN
,
204 .type
= CX231XX_VMUX_SVIDEO
,
205 .vmux
= CX231XX_VIN_1_1
|
206 (CX231XX_VIN_1_2
<< 8) |
208 .amux
= CX231XX_AMUX_LINE_IN
,
214 [CX231XX_BOARD_CNXT_RDU_253S
] = {
215 .name
= "Conexant Hybrid TV - RDU253S",
216 .tuner_type
= TUNER_NXP_TDA18271
,
218 .tuner_gpio
= RDE250_XCV_TUNER
,
219 .tuner_sif_gpio
= 0x05,
220 .tuner_scl_gpio
= 0x1a,
221 .tuner_sda_gpio
= 0x1b,
222 .decoder
= CX231XX_AVDECODER
,
223 .output_mode
= OUT_MODE_VIP11
,
224 .demod_xfer_mode
= 0,
225 .ctl_pin_status_mask
= 0xFFFFFFC4,
226 .agc_analog_digital_select_gpio
= 0x1c,
227 .gpio_pin_status_mask
= 0x4001000,
228 .tuner_i2c_master
= 1,
229 .demod_i2c_master
= 2,
232 .norm
= V4L2_STD_PAL
,
235 .type
= CX231XX_VMUX_TELEVISION
,
236 .vmux
= CX231XX_VIN_3_1
,
237 .amux
= CX231XX_AMUX_VIDEO
,
240 .type
= CX231XX_VMUX_COMPOSITE1
,
241 .vmux
= CX231XX_VIN_2_1
,
242 .amux
= CX231XX_AMUX_LINE_IN
,
245 .type
= CX231XX_VMUX_SVIDEO
,
246 .vmux
= CX231XX_VIN_1_1
|
247 (CX231XX_VIN_1_2
<< 8) |
249 .amux
= CX231XX_AMUX_LINE_IN
,
254 [CX231XX_BOARD_CNXT_VIDEO_GRABBER
] = {
255 .name
= "Conexant VIDEO GRABBER",
256 .tuner_type
= TUNER_ABSENT
,
257 .decoder
= CX231XX_AVDECODER
,
258 .output_mode
= OUT_MODE_VIP11
,
259 .ctl_pin_status_mask
= 0xFFFFFFC4,
260 .agc_analog_digital_select_gpio
= 0x1c,
261 .gpio_pin_status_mask
= 0x4001000,
262 .norm
= V4L2_STD_PAL
,
265 .dont_use_port_3
= 1,
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_KWORLD_UB445_USB_HYBRID
] = {
447 .name
= "Kworld UB445 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
= 0x11, /* 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,
464 .norm
= V4L2_STD_NTSC_M
,
466 .type
= CX231XX_VMUX_TELEVISION
,
467 .vmux
= CX231XX_VIN_3_1
,
468 .amux
= CX231XX_AMUX_VIDEO
,
471 .type
= CX231XX_VMUX_COMPOSITE1
,
472 .vmux
= CX231XX_VIN_2_1
,
473 .amux
= CX231XX_AMUX_LINE_IN
,
476 .type
= CX231XX_VMUX_SVIDEO
,
477 .vmux
= CX231XX_VIN_1_1
|
478 (CX231XX_VIN_1_2
<< 8) |
480 .amux
= CX231XX_AMUX_LINE_IN
,
484 [CX231XX_BOARD_PV_PLAYTV_USB_HYBRID
] = {
485 .name
= "Pixelview PlayTV USB Hybrid",
486 .tuner_type
= TUNER_NXP_TDA18271
,
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
= 0x00, /* According with PV cxPolaris.inf file */
493 .tuner_sif_gpio
= -1,
494 .tuner_scl_gpio
= -1,
495 .tuner_sda_gpio
= -1,
496 .gpio_pin_status_mask
= 0x4001000,
497 .tuner_i2c_master
= 2,
498 .demod_i2c_master
= 1,
500 .rc_map_name
= RC_MAP_PIXELVIEW_002T
,
503 .norm
= V4L2_STD_PAL_M
,
505 .type
= CX231XX_VMUX_TELEVISION
,
506 .vmux
= CX231XX_VIN_3_1
,
507 .amux
= CX231XX_AMUX_VIDEO
,
510 .type
= CX231XX_VMUX_COMPOSITE1
,
511 .vmux
= CX231XX_VIN_2_1
,
512 .amux
= CX231XX_AMUX_LINE_IN
,
515 .type
= CX231XX_VMUX_SVIDEO
,
516 .vmux
= CX231XX_VIN_1_1
|
517 (CX231XX_VIN_1_2
<< 8) |
519 .amux
= CX231XX_AMUX_LINE_IN
,
523 [CX231XX_BOARD_PV_XCAPTURE_USB
] = {
524 .name
= "Pixelview Xcapture USB",
525 .tuner_type
= TUNER_ABSENT
,
526 .decoder
= CX231XX_AVDECODER
,
527 .output_mode
= OUT_MODE_VIP11
,
528 .demod_xfer_mode
= 0,
529 .ctl_pin_status_mask
= 0xFFFFFFC4,
530 .agc_analog_digital_select_gpio
= 0x0c,
531 .gpio_pin_status_mask
= 0x4001000,
532 .norm
= V4L2_STD_NTSC
,
535 .dont_use_port_3
= 1,
538 .type
= CX231XX_VMUX_COMPOSITE1
,
539 .vmux
= CX231XX_VIN_2_1
,
540 .amux
= CX231XX_AMUX_LINE_IN
,
543 .type
= CX231XX_VMUX_SVIDEO
,
544 .vmux
= CX231XX_VIN_1_1
|
545 (CX231XX_VIN_1_2
<< 8) |
547 .amux
= CX231XX_AMUX_LINE_IN
,
553 [CX231XX_BOARD_ICONBIT_U100
] = {
554 .name
= "Iconbit Analog Stick U100 FM",
555 .tuner_type
= TUNER_ABSENT
,
556 .decoder
= CX231XX_AVDECODER
,
557 .output_mode
= OUT_MODE_VIP11
,
558 .demod_xfer_mode
= 0,
559 .ctl_pin_status_mask
= 0xFFFFFFC4,
560 .agc_analog_digital_select_gpio
= 0x1C,
561 .gpio_pin_status_mask
= 0x4001000,
564 .type
= CX231XX_VMUX_COMPOSITE1
,
565 .vmux
= CX231XX_VIN_2_1
,
566 .amux
= CX231XX_AMUX_LINE_IN
,
569 .type
= CX231XX_VMUX_SVIDEO
,
570 .vmux
= CX231XX_VIN_1_1
|
571 (CX231XX_VIN_1_2
<< 8) |
573 .amux
= CX231XX_AMUX_LINE_IN
,
577 [CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL
] = {
578 .name
= "Hauppauge WinTV USB2 FM (PAL)",
579 .tuner_type
= TUNER_NXP_TDA18271
,
581 .tuner_gpio
= RDE250_XCV_TUNER
,
582 .tuner_sif_gpio
= 0x05,
583 .tuner_scl_gpio
= 0x1a,
584 .tuner_sda_gpio
= 0x1b,
585 .decoder
= CX231XX_AVDECODER
,
586 .output_mode
= OUT_MODE_VIP11
,
587 .ctl_pin_status_mask
= 0xFFFFFFC4,
588 .agc_analog_digital_select_gpio
= 0x0c,
589 .gpio_pin_status_mask
= 0x4001000,
590 .tuner_i2c_master
= 1,
591 .norm
= V4L2_STD_PAL
,
594 .type
= CX231XX_VMUX_TELEVISION
,
595 .vmux
= CX231XX_VIN_3_1
,
596 .amux
= CX231XX_AMUX_VIDEO
,
599 .type
= CX231XX_VMUX_COMPOSITE1
,
600 .vmux
= CX231XX_VIN_2_1
,
601 .amux
= CX231XX_AMUX_LINE_IN
,
604 .type
= CX231XX_VMUX_SVIDEO
,
605 .vmux
= CX231XX_VIN_1_1
|
606 (CX231XX_VIN_1_2
<< 8) |
608 .amux
= CX231XX_AMUX_LINE_IN
,
612 [CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC
] = {
613 .name
= "Hauppauge WinTV USB2 FM (NTSC)",
614 .tuner_type
= TUNER_NXP_TDA18271
,
616 .tuner_gpio
= RDE250_XCV_TUNER
,
617 .tuner_sif_gpio
= 0x05,
618 .tuner_scl_gpio
= 0x1a,
619 .tuner_sda_gpio
= 0x1b,
620 .decoder
= CX231XX_AVDECODER
,
621 .output_mode
= OUT_MODE_VIP11
,
622 .ctl_pin_status_mask
= 0xFFFFFFC4,
623 .agc_analog_digital_select_gpio
= 0x0c,
624 .gpio_pin_status_mask
= 0x4001000,
625 .tuner_i2c_master
= 1,
626 .norm
= V4L2_STD_NTSC
,
629 .type
= CX231XX_VMUX_TELEVISION
,
630 .vmux
= CX231XX_VIN_3_1
,
631 .amux
= CX231XX_AMUX_VIDEO
,
634 .type
= CX231XX_VMUX_COMPOSITE1
,
635 .vmux
= CX231XX_VIN_2_1
,
636 .amux
= CX231XX_AMUX_LINE_IN
,
639 .type
= CX231XX_VMUX_SVIDEO
,
640 .vmux
= CX231XX_VIN_1_1
|
641 (CX231XX_VIN_1_2
<< 8) |
643 .amux
= CX231XX_AMUX_LINE_IN
,
647 [CX231XX_BOARD_ELGATO_VIDEO_CAPTURE_V2
] = {
648 .name
= "Elgato Video Capture V2",
649 .tuner_type
= TUNER_ABSENT
,
650 .decoder
= CX231XX_AVDECODER
,
651 .output_mode
= OUT_MODE_VIP11
,
652 .demod_xfer_mode
= 0,
653 .ctl_pin_status_mask
= 0xFFFFFFC4,
654 .agc_analog_digital_select_gpio
= 0x0c,
655 .gpio_pin_status_mask
= 0x4001000,
656 .norm
= V4L2_STD_NTSC
,
659 .dont_use_port_3
= 1,
661 .type
= CX231XX_VMUX_COMPOSITE1
,
662 .vmux
= CX231XX_VIN_2_1
,
663 .amux
= CX231XX_AMUX_LINE_IN
,
666 .type
= CX231XX_VMUX_SVIDEO
,
667 .vmux
= CX231XX_VIN_1_1
|
668 (CX231XX_VIN_1_2
<< 8) |
670 .amux
= CX231XX_AMUX_LINE_IN
,
674 [CX231XX_BOARD_OTG102
] = {
675 .name
= "Geniatech OTG102",
676 .tuner_type
= TUNER_ABSENT
,
677 .decoder
= CX231XX_AVDECODER
,
678 .output_mode
= OUT_MODE_VIP11
,
679 .ctl_pin_status_mask
= 0xFFFFFFC4,
680 .agc_analog_digital_select_gpio
= 0x0c,
681 /* According with PV CxPlrCAP.inf file */
682 .gpio_pin_status_mask
= 0x4001000,
683 .norm
= V4L2_STD_NTSC
,
686 .dont_use_port_3
= 1,
688 /* This board is believed to have a hardware encoding chip
689 * supporting mpeg1/2/4, but as the 417 is apparently not
690 * working for the reference board it is not here either. */
693 .type
= CX231XX_VMUX_COMPOSITE1
,
694 .vmux
= CX231XX_VIN_2_1
,
695 .amux
= CX231XX_AMUX_LINE_IN
,
698 .type
= CX231XX_VMUX_SVIDEO
,
699 .vmux
= CX231XX_VIN_1_1
|
700 (CX231XX_VIN_1_2
<< 8) |
702 .amux
= CX231XX_AMUX_LINE_IN
,
708 const unsigned int cx231xx_bcount
= ARRAY_SIZE(cx231xx_boards
);
710 /* table of devices that work with this driver */
711 struct usb_device_id cx231xx_id_table
[] = {
712 {USB_DEVICE(0x1D19, 0x6109),
713 .driver_info
= CX231XX_BOARD_PV_XCAPTURE_USB
},
714 {USB_DEVICE(0x0572, 0x5A3C),
715 .driver_info
= CX231XX_BOARD_UNKNOWN
},
716 {USB_DEVICE(0x0572, 0x58A2),
717 .driver_info
= CX231XX_BOARD_CNXT_CARRAERA
},
718 {USB_DEVICE(0x0572, 0x58A1),
719 .driver_info
= CX231XX_BOARD_CNXT_SHELBY
},
720 {USB_DEVICE(0x0572, 0x58A4),
721 .driver_info
= CX231XX_BOARD_CNXT_RDE_253S
},
722 {USB_DEVICE(0x0572, 0x58A5),
723 .driver_info
= CX231XX_BOARD_CNXT_RDU_253S
},
724 {USB_DEVICE(0x0572, 0x58A6),
725 .driver_info
= CX231XX_BOARD_CNXT_VIDEO_GRABBER
},
726 {USB_DEVICE(0x0572, 0x589E),
727 .driver_info
= CX231XX_BOARD_CNXT_RDE_250
},
728 {USB_DEVICE(0x0572, 0x58A0),
729 .driver_info
= CX231XX_BOARD_CNXT_RDU_250
},
730 {USB_DEVICE(0x2040, 0xb110),
731 .driver_info
= CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL
},
732 {USB_DEVICE(0x2040, 0xb111),
733 .driver_info
= CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC
},
734 {USB_DEVICE(0x2040, 0xb120),
735 .driver_info
= CX231XX_BOARD_HAUPPAUGE_EXETER
},
736 {USB_DEVICE(0x2040, 0xb140),
737 .driver_info
= CX231XX_BOARD_HAUPPAUGE_EXETER
},
738 {USB_DEVICE(0x2040, 0xc200),
739 .driver_info
= CX231XX_BOARD_HAUPPAUGE_USBLIVE2
},
740 {USB_DEVICE_VER(USB_VID_PIXELVIEW
, USB_PID_PIXELVIEW_SBTVD
, 0x4000, 0x4001),
741 .driver_info
= CX231XX_BOARD_PV_PLAYTV_USB_HYBRID
},
742 {USB_DEVICE(USB_VID_PIXELVIEW
, 0x5014),
743 .driver_info
= CX231XX_BOARD_PV_XCAPTURE_USB
},
744 {USB_DEVICE(0x1b80, 0xe424),
745 .driver_info
= CX231XX_BOARD_KWORLD_UB430_USB_HYBRID
},
746 {USB_DEVICE(0x1b80, 0xe421),
747 .driver_info
= CX231XX_BOARD_KWORLD_UB445_USB_HYBRID
},
748 {USB_DEVICE(0x1f4d, 0x0237),
749 .driver_info
= CX231XX_BOARD_ICONBIT_U100
},
750 {USB_DEVICE(0x0fd9, 0x0037),
751 .driver_info
= CX231XX_BOARD_ELGATO_VIDEO_CAPTURE_V2
},
752 {USB_DEVICE(0x1f4d, 0x0102),
753 .driver_info
= CX231XX_BOARD_OTG102
},
757 MODULE_DEVICE_TABLE(usb
, cx231xx_id_table
);
759 /* cx231xx_tuner_callback
760 * will be used to reset XC5000 tuner using GPIO pin
763 int cx231xx_tuner_callback(void *ptr
, int component
, int command
, int arg
)
766 struct cx231xx
*dev
= ptr
;
768 if (dev
->tuner_type
== TUNER_XC5000
) {
769 if (command
== XC5000_TUNER_RESET
) {
771 ("Tuner CB: RESET: cmd %d : tuner type %d \n",
772 command
, dev
->tuner_type
);
773 cx231xx_set_gpio_value(dev
, dev
->board
.tuner_gpio
->bit
,
776 cx231xx_set_gpio_value(dev
, dev
->board
.tuner_gpio
->bit
,
779 cx231xx_set_gpio_value(dev
, dev
->board
.tuner_gpio
->bit
,
783 } else if (dev
->tuner_type
== TUNER_NXP_TDA18271
) {
785 case TDA18271_CALLBACK_CMD_AGC_ENABLE
:
786 if (dev
->model
== CX231XX_BOARD_PV_PLAYTV_USB_HYBRID
)
787 rc
= cx231xx_set_agc_analog_digital_mux_select(dev
, arg
);
796 EXPORT_SYMBOL_GPL(cx231xx_tuner_callback
);
798 static void cx231xx_reset_out(struct cx231xx
*dev
)
800 cx231xx_set_gpio_value(dev
, CX23417_RESET
, 1);
802 cx231xx_set_gpio_value(dev
, CX23417_RESET
, 0);
804 cx231xx_set_gpio_value(dev
, CX23417_RESET
, 1);
807 static void cx231xx_enable_OSC(struct cx231xx
*dev
)
809 cx231xx_set_gpio_value(dev
, CX23417_OSC_EN
, 1);
812 static void cx231xx_sleep_s5h1432(struct cx231xx
*dev
)
814 cx231xx_set_gpio_value(dev
, SLEEP_S5H1432
, 0);
817 static inline void cx231xx_set_model(struct cx231xx
*dev
)
819 dev
->board
= cx231xx_boards
[dev
->model
];
822 /* Since cx231xx_pre_card_setup() requires a proper dev->model,
823 * this won't work for boards with generic PCI IDs
825 void cx231xx_pre_card_setup(struct cx231xx
*dev
)
828 cx231xx_set_model(dev
);
830 cx231xx_info("Identified as %s (card=%d)\n",
831 dev
->board
.name
, dev
->model
);
833 /* set the direction for GPIO pins */
834 if (dev
->board
.tuner_gpio
) {
835 cx231xx_set_gpio_direction(dev
, dev
->board
.tuner_gpio
->bit
, 1);
836 cx231xx_set_gpio_value(dev
, dev
->board
.tuner_gpio
->bit
, 1);
838 if (dev
->board
.tuner_sif_gpio
>= 0)
839 cx231xx_set_gpio_direction(dev
, dev
->board
.tuner_sif_gpio
, 1);
841 /* request some modules if any required */
843 /* set the mode to Analog mode initially */
844 cx231xx_set_mode(dev
, CX231XX_ANALOG_MODE
);
847 /* cx231xx_set_mode(dev, CX231XX_SUSPEND); */
851 static void cx231xx_config_tuner(struct cx231xx
*dev
)
853 struct tuner_setup tun_setup
;
854 struct v4l2_frequency f
;
856 if (dev
->tuner_type
== TUNER_ABSENT
)
859 tun_setup
.mode_mask
= T_ANALOG_TV
| T_RADIO
;
860 tun_setup
.type
= dev
->tuner_type
;
861 tun_setup
.addr
= dev
->tuner_addr
;
862 tun_setup
.tuner_callback
= cx231xx_tuner_callback
;
864 tuner_call(dev
, tuner
, s_type_addr
, &tun_setup
);
867 if (tun_setup
.type
== TUNER_XC5000
) {
868 static struct xc2028_ctrl ctrl
= {
869 .fname
= XC5000_DEFAULT_FIRMWARE
,
873 struct v4l2_priv_tun_config cfg
= {
874 .tuner
= dev
->tuner_type
,
877 tuner_call(dev
, tuner
, s_config
, &cfg
);
880 /* configure tuner */
882 f
.type
= V4L2_TUNER_ANALOG_TV
;
883 f
.frequency
= 9076; /* just a magic number */
884 dev
->ctl_freq
= f
.frequency
;
885 call_all(dev
, tuner
, s_frequency
, &f
);
889 void cx231xx_card_setup(struct cx231xx
*dev
)
892 cx231xx_set_model(dev
);
894 dev
->tuner_type
= cx231xx_boards
[dev
->model
].tuner_type
;
895 if (cx231xx_boards
[dev
->model
].tuner_addr
)
896 dev
->tuner_addr
= cx231xx_boards
[dev
->model
].tuner_addr
;
898 /* request some modules */
899 if (dev
->board
.decoder
== CX231XX_AVDECODER
) {
900 dev
->sd_cx25840
= v4l2_i2c_new_subdev(&dev
->v4l2_dev
,
901 &dev
->i2c_bus
[0].i2c_adap
,
902 "cx25840", 0x88 >> 1, NULL
);
903 if (dev
->sd_cx25840
== NULL
)
904 cx231xx_info("cx25840 subdev registration failure\n");
905 cx25840_call(dev
, core
, load_fw
);
909 /* Initialize the tuner */
910 if (dev
->board
.tuner_type
!= TUNER_ABSENT
) {
911 dev
->sd_tuner
= v4l2_i2c_new_subdev(&dev
->v4l2_dev
,
912 &dev
->i2c_bus
[dev
->board
.tuner_i2c_master
].i2c_adap
,
914 dev
->tuner_addr
, NULL
);
915 if (dev
->sd_tuner
== NULL
)
916 cx231xx_info("tuner subdev registration failure\n");
918 cx231xx_config_tuner(dev
);
924 * inits registers with sane defaults
926 int cx231xx_config(struct cx231xx
*dev
)
928 /* TBD need to add cx231xx specific code */
934 * cx231xx_config_i2c()
935 * configure i2c attached devices
937 void cx231xx_config_i2c(struct cx231xx
*dev
)
939 /* u32 input = INPUT(dev->video_input)->vmux; */
941 call_all(dev
, video
, s_stream
, 1);
945 * cx231xx_realease_resources()
946 * unregisters the v4l2,i2c and usb devices
947 * called when the device gets disconected or at module unload
949 void cx231xx_release_resources(struct cx231xx
*dev
)
951 cx231xx_release_analog_resources(dev
);
953 cx231xx_remove_from_devlist(dev
);
955 cx231xx_ir_exit(dev
);
957 /* Release I2C buses */
958 cx231xx_dev_uninit(dev
);
960 /* delete v4l2 device */
961 v4l2_device_unregister(&dev
->v4l2_dev
);
963 usb_put_dev(dev
->udev
);
965 /* Mark device as unused */
966 clear_bit(dev
->devno
, &cx231xx_devused
);
968 kfree(dev
->video_mode
.alt_max_pkt_size
);
969 kfree(dev
->vbi_mode
.alt_max_pkt_size
);
970 kfree(dev
->sliced_cc_mode
.alt_max_pkt_size
);
971 kfree(dev
->ts1_mode
.alt_max_pkt_size
);
977 * allocates and inits the device structs, registers i2c bus and v4l device
979 static int cx231xx_init_dev(struct cx231xx
*dev
, struct usb_device
*udev
,
982 int retval
= -ENOMEM
;
983 unsigned int maxh
, maxw
;
986 mutex_init(&dev
->lock
);
987 mutex_init(&dev
->ctrl_urb_lock
);
988 mutex_init(&dev
->gpio_i2c_lock
);
989 mutex_init(&dev
->i2c_lock
);
991 spin_lock_init(&dev
->video_mode
.slock
);
992 spin_lock_init(&dev
->vbi_mode
.slock
);
993 spin_lock_init(&dev
->sliced_cc_mode
.slock
);
995 init_waitqueue_head(&dev
->open
);
996 init_waitqueue_head(&dev
->wait_frame
);
997 init_waitqueue_head(&dev
->wait_stream
);
999 dev
->cx231xx_read_ctrl_reg
= cx231xx_read_ctrl_reg
;
1000 dev
->cx231xx_write_ctrl_reg
= cx231xx_write_ctrl_reg
;
1001 dev
->cx231xx_send_usb_command
= cx231xx_send_usb_command
;
1002 dev
->cx231xx_gpio_i2c_read
= cx231xx_gpio_i2c_read
;
1003 dev
->cx231xx_gpio_i2c_write
= cx231xx_gpio_i2c_write
;
1005 /* Query cx231xx to find what pcb config it is related to */
1006 initialize_cx231xx(dev
);
1008 /*To workaround error number=-71 on EP0 for VideoGrabber,
1009 need set alt here.*/
1010 if (dev
->model
== CX231XX_BOARD_CNXT_VIDEO_GRABBER
||
1011 dev
->model
== CX231XX_BOARD_HAUPPAUGE_USBLIVE2
) {
1012 cx231xx_set_alt_setting(dev
, INDEX_VIDEO
, 3);
1013 cx231xx_set_alt_setting(dev
, INDEX_VANC
, 1);
1015 /* Cx231xx pre card setup */
1016 cx231xx_pre_card_setup(dev
);
1018 retval
= cx231xx_config(dev
);
1020 cx231xx_errdev("error configuring device\n");
1024 /* set default norm */
1025 dev
->norm
= dev
->board
.norm
;
1027 /* register i2c bus */
1028 retval
= cx231xx_dev_init(dev
);
1030 cx231xx_errdev("%s: cx231xx_i2c_register - errCode [%d]!\n",
1035 /* Do board specific init */
1036 cx231xx_card_setup(dev
);
1038 /* configure the device */
1039 cx231xx_config_i2c(dev
);
1041 maxw
= norm_maxw(dev
);
1042 maxh
= norm_maxh(dev
);
1044 /* set default image size */
1047 dev
->interlaced
= 0;
1048 dev
->video_input
= 0;
1050 retval
= cx231xx_config(dev
);
1052 cx231xx_errdev("%s: cx231xx_config - errCode [%d]!\n",
1057 /* init video dma queues */
1058 INIT_LIST_HEAD(&dev
->video_mode
.vidq
.active
);
1059 INIT_LIST_HEAD(&dev
->video_mode
.vidq
.queued
);
1061 /* init vbi dma queues */
1062 INIT_LIST_HEAD(&dev
->vbi_mode
.vidq
.active
);
1063 INIT_LIST_HEAD(&dev
->vbi_mode
.vidq
.queued
);
1065 /* Reset other chips required if they are tied up with GPIO pins */
1066 cx231xx_add_into_devlist(dev
);
1068 if (dev
->board
.has_417
) {
1069 printk(KERN_INFO
"attach 417 %d\n", dev
->model
);
1070 if (cx231xx_417_register(dev
) < 0) {
1072 "%s() Failed to register 417 on VID_B\n",
1077 retval
= cx231xx_register_analog_devices(dev
);
1079 cx231xx_release_analog_resources(dev
);
1083 cx231xx_ir_init(dev
);
1085 cx231xx_init_extension(dev
);
1089 cx231xx_remove_from_devlist(dev
);
1091 cx231xx_dev_uninit(dev
);
1095 #if defined(CONFIG_MODULES) && defined(MODULE)
1096 static void request_module_async(struct work_struct
*work
)
1098 struct cx231xx
*dev
= container_of(work
,
1099 struct cx231xx
, request_module_wk
);
1101 if (dev
->has_alsa_audio
)
1102 request_module("cx231xx-alsa");
1104 if (dev
->board
.has_dvb
)
1105 request_module("cx231xx-dvb");
1109 static void request_modules(struct cx231xx
*dev
)
1111 INIT_WORK(&dev
->request_module_wk
, request_module_async
);
1112 schedule_work(&dev
->request_module_wk
);
1115 static void flush_request_modules(struct cx231xx
*dev
)
1117 flush_work(&dev
->request_module_wk
);
1120 #define request_modules(dev)
1121 #define flush_request_modules(dev)
1122 #endif /* CONFIG_MODULES */
1125 * cx231xx_usb_probe()
1126 * checks for supported devices
1128 static int cx231xx_usb_probe(struct usb_interface
*interface
,
1129 const struct usb_device_id
*id
)
1131 struct usb_device
*udev
;
1132 struct usb_interface
*uif
;
1133 struct cx231xx
*dev
= NULL
;
1134 int retval
= -ENODEV
;
1136 int i
, isoc_pipe
= 0;
1138 struct usb_interface_assoc_descriptor
*assoc_desc
;
1140 ifnum
= interface
->altsetting
[0].desc
.bInterfaceNumber
;
1143 * Interface number 0 - IR interface (handled by mceusb driver)
1144 * Interface number 1 - AV interface (handled by this driver)
1149 /* Check to see next free device and mark as used */
1151 nr
= find_first_zero_bit(&cx231xx_devused
, CX231XX_MAXBOARDS
);
1152 if (nr
>= CX231XX_MAXBOARDS
) {
1153 /* No free device slots */
1154 cx231xx_err(DRIVER_NAME
": Supports only %i devices.\n",
1158 } while (test_and_set_bit(nr
, &cx231xx_devused
));
1160 /* allocate memory for our device state and initialize it */
1161 dev
= kzalloc(sizeof(*dev
), GFP_KERNEL
);
1163 cx231xx_err(DRIVER_NAME
": out of memory!\n");
1164 clear_bit(nr
, &cx231xx_devused
);
1168 udev
= usb_get_dev(interface_to_usbdev(interface
));
1170 snprintf(dev
->name
, 29, "cx231xx #%d", nr
);
1172 dev
->model
= id
->driver_info
;
1173 dev
->video_mode
.alt
= -1;
1175 dev
->interface_count
++;
1176 /* reset gpio dir and value */
1179 dev
->xc_fw_load_done
= 0;
1180 dev
->has_alsa_audio
= 1;
1181 dev
->power_mode
= -1;
1182 atomic_set(&dev
->devlist_count
, 0);
1184 /* 0 - vbi ; 1 -sliced cc mode */
1185 dev
->vbi_or_sliced_cc_mode
= 0;
1187 /* get maximum no.of IAD interfaces */
1188 assoc_desc
= udev
->actconfig
->intf_assoc
[0];
1189 dev
->max_iad_interface_count
= assoc_desc
->bInterfaceCount
;
1191 /* init CIR module TBD */
1193 /*mode_tv: digital=1 or analog=0*/
1196 dev
->USE_ISO
= transfer_mode
;
1198 switch (udev
->speed
) {
1202 case USB_SPEED_UNKNOWN
:
1203 case USB_SPEED_FULL
:
1206 case USB_SPEED_HIGH
:
1213 cx231xx_info("New device %s %s @ %s Mbps "
1214 "(%04x:%04x) with %d interfaces\n",
1215 udev
->manufacturer
? udev
->manufacturer
: "",
1216 udev
->product
? udev
->product
: "",
1218 le16_to_cpu(udev
->descriptor
.idVendor
),
1219 le16_to_cpu(udev
->descriptor
.idProduct
),
1220 dev
->max_iad_interface_count
);
1222 /* increment interface count */
1223 dev
->interface_count
++;
1225 /* get device number */
1228 assoc_desc
= udev
->actconfig
->intf_assoc
[0];
1229 if (assoc_desc
->bFirstInterface
!= ifnum
) {
1230 cx231xx_err(DRIVER_NAME
": Not found "
1231 "matching IAD interface\n");
1236 cx231xx_info("registering interface %d\n", ifnum
);
1238 /* save our data pointer in this interface device */
1239 usb_set_intfdata(interface
, dev
);
1242 * AV device initialization - only done at the last interface
1245 /* Create v4l2 device */
1246 retval
= v4l2_device_register(&interface
->dev
, &dev
->v4l2_dev
);
1248 cx231xx_errdev("v4l2_device_register failed\n");
1252 /* allocate device struct */
1253 retval
= cx231xx_init_dev(dev
, udev
, nr
);
1257 /* compute alternate max packet sizes for video */
1258 uif
= udev
->actconfig
->interface
[dev
->current_pcb_config
.
1259 hs_config_info
[0].interface_info
.video_index
+ 1];
1261 dev
->video_mode
.end_point_addr
= uif
->altsetting
[0].
1262 endpoint
[isoc_pipe
].desc
.bEndpointAddress
;
1264 dev
->video_mode
.num_alt
= uif
->num_altsetting
;
1265 cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n",
1266 dev
->video_mode
.end_point_addr
,
1267 dev
->video_mode
.num_alt
);
1268 dev
->video_mode
.alt_max_pkt_size
=
1269 kmalloc(32 * dev
->video_mode
.num_alt
, GFP_KERNEL
);
1271 if (dev
->video_mode
.alt_max_pkt_size
== NULL
) {
1272 cx231xx_errdev("out of memory!\n");
1277 for (i
= 0; i
< dev
->video_mode
.num_alt
; i
++) {
1278 u16 tmp
= le16_to_cpu(uif
->altsetting
[i
].endpoint
[isoc_pipe
].
1279 desc
.wMaxPacketSize
);
1280 dev
->video_mode
.alt_max_pkt_size
[i
] =
1281 (tmp
& 0x07ff) * (((tmp
& 0x1800) >> 11) + 1);
1282 cx231xx_info("Alternate setting %i, max size= %i\n", i
,
1283 dev
->video_mode
.alt_max_pkt_size
[i
]);
1286 /* compute alternate max packet sizes for vbi */
1287 uif
= udev
->actconfig
->interface
[dev
->current_pcb_config
.
1288 hs_config_info
[0].interface_info
.
1291 dev
->vbi_mode
.end_point_addr
=
1292 uif
->altsetting
[0].endpoint
[isoc_pipe
].desc
.
1295 dev
->vbi_mode
.num_alt
= uif
->num_altsetting
;
1296 cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n",
1297 dev
->vbi_mode
.end_point_addr
,
1298 dev
->vbi_mode
.num_alt
);
1299 dev
->vbi_mode
.alt_max_pkt_size
=
1300 kmalloc(32 * dev
->vbi_mode
.num_alt
, GFP_KERNEL
);
1302 if (dev
->vbi_mode
.alt_max_pkt_size
== NULL
) {
1303 cx231xx_errdev("out of memory!\n");
1308 for (i
= 0; i
< dev
->vbi_mode
.num_alt
; i
++) {
1310 le16_to_cpu(uif
->altsetting
[i
].endpoint
[isoc_pipe
].
1311 desc
.wMaxPacketSize
);
1312 dev
->vbi_mode
.alt_max_pkt_size
[i
] =
1313 (tmp
& 0x07ff) * (((tmp
& 0x1800) >> 11) + 1);
1314 cx231xx_info("Alternate setting %i, max size= %i\n", i
,
1315 dev
->vbi_mode
.alt_max_pkt_size
[i
]);
1318 /* compute alternate max packet sizes for sliced CC */
1319 uif
= udev
->actconfig
->interface
[dev
->current_pcb_config
.
1320 hs_config_info
[0].interface_info
.
1323 dev
->sliced_cc_mode
.end_point_addr
=
1324 uif
->altsetting
[0].endpoint
[isoc_pipe
].desc
.
1327 dev
->sliced_cc_mode
.num_alt
= uif
->num_altsetting
;
1328 cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n",
1329 dev
->sliced_cc_mode
.end_point_addr
,
1330 dev
->sliced_cc_mode
.num_alt
);
1331 dev
->sliced_cc_mode
.alt_max_pkt_size
=
1332 kmalloc(32 * dev
->sliced_cc_mode
.num_alt
, GFP_KERNEL
);
1334 if (dev
->sliced_cc_mode
.alt_max_pkt_size
== NULL
) {
1335 cx231xx_errdev("out of memory!\n");
1337 goto err_sliced_cc_alt
;
1340 for (i
= 0; i
< dev
->sliced_cc_mode
.num_alt
; i
++) {
1341 u16 tmp
= le16_to_cpu(uif
->altsetting
[i
].endpoint
[isoc_pipe
].
1342 desc
.wMaxPacketSize
);
1343 dev
->sliced_cc_mode
.alt_max_pkt_size
[i
] =
1344 (tmp
& 0x07ff) * (((tmp
& 0x1800) >> 11) + 1);
1345 cx231xx_info("Alternate setting %i, max size= %i\n", i
,
1346 dev
->sliced_cc_mode
.alt_max_pkt_size
[i
]);
1349 if (dev
->current_pcb_config
.ts1_source
!= 0xff) {
1350 /* compute alternate max packet sizes for TS1 */
1351 uif
= udev
->actconfig
->interface
[dev
->current_pcb_config
.
1356 dev
->ts1_mode
.end_point_addr
=
1357 uif
->altsetting
[0].endpoint
[isoc_pipe
].
1358 desc
.bEndpointAddress
;
1360 dev
->ts1_mode
.num_alt
= uif
->num_altsetting
;
1361 cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n",
1362 dev
->ts1_mode
.end_point_addr
,
1363 dev
->ts1_mode
.num_alt
);
1364 dev
->ts1_mode
.alt_max_pkt_size
=
1365 kmalloc(32 * dev
->ts1_mode
.num_alt
, GFP_KERNEL
);
1367 if (dev
->ts1_mode
.alt_max_pkt_size
== NULL
) {
1368 cx231xx_errdev("out of memory!\n");
1373 for (i
= 0; i
< dev
->ts1_mode
.num_alt
; i
++) {
1374 u16 tmp
= le16_to_cpu(uif
->altsetting
[i
].
1375 endpoint
[isoc_pipe
].desc
.
1377 dev
->ts1_mode
.alt_max_pkt_size
[i
] =
1378 (tmp
& 0x07ff) * (((tmp
& 0x1800) >> 11) + 1);
1379 cx231xx_info("Alternate setting %i, max size= %i\n", i
,
1380 dev
->ts1_mode
.alt_max_pkt_size
[i
]);
1384 if (dev
->model
== CX231XX_BOARD_CNXT_VIDEO_GRABBER
) {
1385 cx231xx_enable_OSC(dev
);
1386 cx231xx_reset_out(dev
);
1387 cx231xx_set_alt_setting(dev
, INDEX_VIDEO
, 3);
1390 if (dev
->model
== CX231XX_BOARD_CNXT_RDE_253S
)
1391 cx231xx_sleep_s5h1432(dev
);
1393 /* load other modules required */
1394 request_modules(dev
);
1398 kfree(dev
->sliced_cc_mode
.alt_max_pkt_size
);
1400 kfree(dev
->vbi_mode
.alt_max_pkt_size
);
1402 kfree(dev
->video_mode
.alt_max_pkt_size
);
1404 /* cx231xx_uninit_dev: */
1405 cx231xx_close_extension(dev
);
1406 cx231xx_ir_exit(dev
);
1407 cx231xx_release_analog_resources(dev
);
1408 cx231xx_417_unregister(dev
);
1409 cx231xx_remove_from_devlist(dev
);
1410 cx231xx_dev_uninit(dev
);
1412 v4l2_device_unregister(&dev
->v4l2_dev
);
1414 usb_set_intfdata(interface
, NULL
);
1417 clear_bit(dev
->devno
, &cx231xx_devused
);
1423 * cx231xx_usb_disconnect()
1424 * called when the device gets diconencted
1425 * video device will be unregistered on v4l2_close in case it is still open
1427 static void cx231xx_usb_disconnect(struct usb_interface
*interface
)
1429 struct cx231xx
*dev
;
1431 dev
= usb_get_intfdata(interface
);
1432 usb_set_intfdata(interface
, NULL
);
1440 dev
->state
|= DEV_DISCONNECTED
;
1442 flush_request_modules(dev
);
1444 /* wait until all current v4l2 io is finished then deallocate
1446 mutex_lock(&dev
->lock
);
1448 wake_up_interruptible_all(&dev
->open
);
1452 ("device %s is open! Deregistration and memory "
1453 "deallocation are deferred on close.\n",
1454 video_device_node_name(dev
->vdev
));
1456 /* Even having users, it is safe to remove the RC i2c driver */
1457 cx231xx_ir_exit(dev
);
1460 cx231xx_uninit_isoc(dev
);
1462 cx231xx_uninit_bulk(dev
);
1463 wake_up_interruptible(&dev
->wait_frame
);
1464 wake_up_interruptible(&dev
->wait_stream
);
1468 cx231xx_close_extension(dev
);
1470 mutex_unlock(&dev
->lock
);
1473 cx231xx_release_resources(dev
);
1476 static struct usb_driver cx231xx_usb_driver
= {
1478 .probe
= cx231xx_usb_probe
,
1479 .disconnect
= cx231xx_usb_disconnect
,
1480 .id_table
= cx231xx_id_table
,
1483 module_usb_driver(cx231xx_usb_driver
);