1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 cx231xx-pcb-config.c - driver for Conexant
4 Cx23100/101/102 USB video capture devices
5
6 Copyright (C) 2008 <srinivasa.deevi at conexant dot com>
7
8 */
9
10 #include "cx231xx.h"
11 #include "cx231xx-conf-reg.h"
12
13 static unsigned int pcb_debug;
14 module_param(pcb_debug, int, 0644);
15 MODULE_PARM_DESC(pcb_debug, "enable pcb config debug messages [video]");
16
17 /******************************************************************************/
18
19 static struct pcb_config cx231xx_Scenario[] = {
20 {
21 INDEX_SELFPOWER_DIGITAL_ONLY, /* index */
22 USB_SELF_POWER, /* power_type */
23 0, /* speed , not decide yet */
24 MOD_DIGITAL, /* mode */
25 SOURCE_TS_BDA, /* ts1_source, digital tv only */
26 NOT_SUPPORTED, /* ts2_source */
27 NOT_SUPPORTED, /* analog source */
28
29 0, /* digital_index */
30 0, /* analog index */
31 0, /* dif_index */
32 0, /* external_index */
33
34 1, /* only one configuration */
35 {
36 {
37 0, /* config index */
38 {
39 0, /* interrupt ep index */
40 1, /* ts1 index */
41 NOT_SUPPORTED, /* TS2 index */
42 NOT_SUPPORTED, /* AUDIO */
43 NOT_SUPPORTED, /* VIDEO */
44 NOT_SUPPORTED, /* VANC */
45 NOT_SUPPORTED, /* HANC */
46 NOT_SUPPORTED /* ir_index */
47 }
48 ,
49 }
50 ,
51 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
52 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
53 NOT_SUPPORTED}
54 }
55 ,
56 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
57 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
58 NOT_SUPPORTED}
59 }
60 }
61 ,
62 /* full-speed config */
63 {
64 {
65 0, /* config index */
66 {
67 0, /* interrupt ep index */
68 1, /* ts1 index */
69 NOT_SUPPORTED, /* TS2 index */
70 NOT_SUPPORTED, /* AUDIO */
71 NOT_SUPPORTED, /* VIDEO */
72 NOT_SUPPORTED, /* VANC */
73 NOT_SUPPORTED, /* HANC */
74 NOT_SUPPORTED /* ir_index */
75 }
76 }
77 ,
78 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
79 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
80 NOT_SUPPORTED}
81 }
82 ,
83 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
84 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
85 NOT_SUPPORTED}
86 }
87 }
88 }
89 ,
90
91 {
92 INDEX_SELFPOWER_DUAL_DIGITAL, /* index */
93 USB_SELF_POWER, /* power_type */
94 0, /* speed , not decide yet */
95 MOD_DIGITAL, /* mode */
96 SOURCE_TS_BDA, /* ts1_source, digital tv only */
97 0, /* ts2_source,need update from register */
98 NOT_SUPPORTED, /* analog source */
99 0, /* digital_index */
100 0, /* analog index */
101 0, /* dif_index */
102 0, /* external_index */
103
104 1, /* only one configuration */
105 {
106 {
107 0, /* config index */
108 {
109 0, /* interrupt ep index */
110 1, /* ts1 index */
111 2, /* TS2 index */
112 NOT_SUPPORTED, /* AUDIO */
113 NOT_SUPPORTED, /* VIDEO */
114 NOT_SUPPORTED, /* VANC */
115 NOT_SUPPORTED, /* HANC */
116 NOT_SUPPORTED /* ir_index */
117 }
118 }
119 ,
120 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
121 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
122 NOT_SUPPORTED}
123 }
124 ,
125 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
126 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
127 NOT_SUPPORTED}
128 }
129 }
130 ,
131 /* full-speed */
132 {
133 {
134 0, /* config index */
135 {
136 0, /* interrupt ep index */
137 1, /* ts1 index */
138 2, /* TS2 index */
139 NOT_SUPPORTED, /* AUDIO */
140 NOT_SUPPORTED, /* VIDEO */
141 NOT_SUPPORTED, /* VANC */
142 NOT_SUPPORTED, /* HANC */
143 NOT_SUPPORTED /* ir_index */
144 }
145 }
146 ,
147 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
148 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
149 NOT_SUPPORTED}
150 }
151 ,
152 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
153 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
154 NOT_SUPPORTED}
155 }
156 }
157 }
158 ,
159
160 {
161 INDEX_SELFPOWER_ANALOG_ONLY, /* index */
162 USB_SELF_POWER, /* power_type */
163 0, /* speed , not decide yet */
164 MOD_ANALOG | MOD_DIF | MOD_EXTERNAL, /* mode ,analog tv only */
165 NOT_SUPPORTED, /* ts1_source, NOT SUPPORT */
166 NOT_SUPPORTED, /* ts2_source,NOT SUPPORT */
167 0, /* analog source, need update */
168
169 0, /* digital_index */
170 0, /* analog index */
171 0, /* dif_index */
172 0, /* external_index */
173
174 1, /* only one configuration */
175 {
176 {
177 0, /* config index */
178 {
179 0, /* interrupt ep index */
180 NOT_SUPPORTED, /* ts1 index */
181 NOT_SUPPORTED, /* TS2 index */
182 1, /* AUDIO */
183 2, /* VIDEO */
184 3, /* VANC */
185 4, /* HANC */
186 NOT_SUPPORTED /* ir_index */
187 }
188 }
189 ,
190 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
191 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
192 NOT_SUPPORTED}
193 }
194 ,
195 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
196 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
197 NOT_SUPPORTED}
198 }
199 }
200 ,
201 /* full-speed */
202 {
203 {
204 0, /* config index */
205 {
206 0, /* interrupt ep index */
207 NOT_SUPPORTED, /* ts1 index */
208 NOT_SUPPORTED, /* TS2 index */
209 1, /* AUDIO */
210 2, /* VIDEO */
211 NOT_SUPPORTED, /* VANC */
212 NOT_SUPPORTED, /* HANC */
213 NOT_SUPPORTED /* ir_index */
214 }
215 }
216 ,
217 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
218 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
219 NOT_SUPPORTED}
220 }
221 ,
222 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
223 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
224 NOT_SUPPORTED}
225 }
226 }
227 }
228 ,
229
230 {
231 INDEX_SELFPOWER_DUAL, /* index */
232 USB_SELF_POWER, /* power_type */
233 0, /* speed , not decide yet */
234 /* mode ,analog tv and digital path */
235 MOD_ANALOG | MOD_DIF | MOD_DIGITAL | MOD_EXTERNAL,
236 0, /* ts1_source,will update in register */
237 NOT_SUPPORTED, /* ts2_source,NOT SUPPORT */
238 0, /* analog source need update */
239 0, /* digital_index */
240 0, /* analog index */
241 0, /* dif_index */
242 0, /* external_index */
243 1, /* only one configuration */
244 {
245 {
246 0, /* config index */
247 {
248 0, /* interrupt ep index */
249 1, /* ts1 index */
250 NOT_SUPPORTED, /* TS2 index */
251 2, /* AUDIO */
252 3, /* VIDEO */
253 4, /* VANC */
254 5, /* HANC */
255 NOT_SUPPORTED /* ir_index */
256 }
257 }
258 ,
259 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
260 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
261 NOT_SUPPORTED}
262 }
263 ,
264 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
265 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
266 NOT_SUPPORTED}
267 }
268 }
269 ,
270 /* full-speed */
271 {
272 {
273 0, /* config index */
274 {
275 0, /* interrupt ep index */
276 1, /* ts1 index */
277 NOT_SUPPORTED, /* TS2 index */
278 2, /* AUDIO */
279 3, /* VIDEO */
280 NOT_SUPPORTED, /* VANC */
281 NOT_SUPPORTED, /* HANC */
282 NOT_SUPPORTED /* ir_index */
283 }
284 }
285 ,
286 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
287 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
288 NOT_SUPPORTED}
289 }
290 ,
291 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
292 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
293 NOT_SUPPORTED}
294 }
295 }
296 }
297 ,
298
299 {
300 INDEX_SELFPOWER_TRIPLE, /* index */
301 USB_SELF_POWER, /* power_type */
302 0, /* speed , not decide yet */
303 /* mode ,analog tv and digital path */
304 MOD_ANALOG | MOD_DIF | MOD_DIGITAL | MOD_EXTERNAL,
305 0, /* ts1_source, update in register */
306 0, /* ts2_source,update in register */
307 0, /* analog source, need update */
308
309 0, /* digital_index */
310 0, /* analog index */
311 0, /* dif_index */
312 0, /* external_index */
313 1, /* only one configuration */
314 {
315 {
316 0, /* config index */
317 {
318 0, /* interrupt ep index */
319 1, /* ts1 index */
320 2, /* TS2 index */
321 3, /* AUDIO */
322 4, /* VIDEO */
323 5, /* VANC */
324 6, /* HANC */
325 NOT_SUPPORTED /* ir_index */
326 }
327 }
328 ,
329 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
330 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
331 NOT_SUPPORTED}
332 }
333 ,
334 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
335 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
336 NOT_SUPPORTED}
337 }
338 }
339 ,
340 /* full-speed */
341 {
342 {
343 0, /* config index */
344 {
345 0, /* interrupt ep index */
346 1, /* ts1 index */
347 2, /* TS2 index */
348 3, /* AUDIO */
349 4, /* VIDEO */
350 NOT_SUPPORTED, /* VANC */
351 NOT_SUPPORTED, /* HANC */
352 NOT_SUPPORTED /* ir_index */
353 }
354 }
355 ,
356 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
357 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
358 NOT_SUPPORTED}
359 }
360 ,
361 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
362 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
363 NOT_SUPPORTED}
364 }
365 }
366 }
367 ,
368
369 {
370 INDEX_SELFPOWER_COMPRESSOR, /* index */
371 USB_SELF_POWER, /* power_type */
372 0, /* speed , not decide yet */
373 /* mode ,analog tv AND DIGITAL path */
374 MOD_ANALOG | MOD_DIF | MOD_DIGITAL | MOD_EXTERNAL,
375 NOT_SUPPORTED, /* ts1_source, disable */
376 SOURCE_TS_BDA, /* ts2_source */
377 0, /* analog source,need update */
378 0, /* digital_index */
379 0, /* analog index */
380 0, /* dif_index */
381 0, /* external_index */
382 1, /* only one configuration */
383 {
384 {
385 0, /* config index */
386 {
387 0, /* interrupt ep index */
388 NOT_SUPPORTED, /* ts1 index */
389 1, /* TS2 index */
390 2, /* AUDIO */
391 3, /* VIDEO */
392 4, /* VANC */
393 5, /* HANC */
394 NOT_SUPPORTED /* ir_index */
395 }
396 }
397 ,
398 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
399 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
400 NOT_SUPPORTED}
401 }
402 ,
403 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
404 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
405 NOT_SUPPORTED}
406 }
407 }
408 ,
409 /* full-speed */
410 {
411 {
412 0, /* config index */
413 {
414 0, /* interrupt ep index */
415 NOT_SUPPORTED, /* ts1 index */
416 1, /* TS2 index */
417 2, /* AUDIO */
418 3, /* VIDEO */
419 NOT_SUPPORTED, /* VANC */
420 NOT_SUPPORTED, /* HANC */
421 NOT_SUPPORTED /* ir_index */
422 }
423 }
424 ,
425 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
426 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
427 NOT_SUPPORTED}
428 }
429 ,
430 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
431 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
432 NOT_SUPPORTED}
433 }
434 }
435 }
436 ,
437
438 {
439 INDEX_BUSPOWER_DIGITAL_ONLY, /* index */
440 USB_BUS_POWER, /* power_type */
441 0, /* speed , not decide yet */
442 MOD_DIGITAL, /* mode ,analog tv AND DIGITAL path */
443 SOURCE_TS_BDA, /* ts1_source, disable */
444 NOT_SUPPORTED, /* ts2_source */
445 NOT_SUPPORTED, /* analog source */
446
447 0, /* digital_index */
448 0, /* analog index */
449 0, /* dif_index */
450 0, /* external_index */
451
452 1, /* only one configuration */
453 {
454 {
455 0, /* config index */
456 {
457 0, /* interrupt ep index = 2 */
458 1, /* ts1 index */
459 NOT_SUPPORTED, /* TS2 index */
460 NOT_SUPPORTED, /* AUDIO */
461 NOT_SUPPORTED, /* VIDEO */
462 NOT_SUPPORTED, /* VANC */
463 NOT_SUPPORTED, /* HANC */
464 NOT_SUPPORTED /* ir_index */
465 }
466 }
467 ,
468 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
469 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
470 NOT_SUPPORTED}
471 }
472 ,
473 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
474 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
475 NOT_SUPPORTED}
476 }
477 }
478 ,
479 /* full-speed */
480 {
481 {
482 0, /* config index */
483 {
484 0, /* interrupt ep index = 2 */
485 1, /* ts1 index */
486 NOT_SUPPORTED, /* TS2 index */
487 NOT_SUPPORTED, /* AUDIO */
488 NOT_SUPPORTED, /* VIDEO */
489 NOT_SUPPORTED, /* VANC */
490 NOT_SUPPORTED, /* HANC */
491 NOT_SUPPORTED /* ir_index */
492 }
493 }
494 ,
495 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
496 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
497 NOT_SUPPORTED}
498 }
499 ,
500 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
501 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
502 NOT_SUPPORTED}
503 }
504 }
505 }
506 ,
507 {
508 INDEX_BUSPOWER_ANALOG_ONLY, /* index */
509 USB_BUS_POWER, /* power_type */
510 0, /* speed , not decide yet */
511 MOD_ANALOG, /* mode ,analog tv AND DIGITAL path */
512 NOT_SUPPORTED, /* ts1_source, disable */
513 NOT_SUPPORTED, /* ts2_source */
514 SOURCE_ANALOG, /* analog source--analog */
515 0, /* digital_index */
516 0, /* analog index */
517 0, /* dif_index */
518 0, /* external_index */
519 1, /* only one configuration */
520 {
521 {
522 0, /* config index */
523 {
524 0, /* interrupt ep index */
525 NOT_SUPPORTED, /* ts1 index */
526 NOT_SUPPORTED, /* TS2 index */
527 1, /* AUDIO */
528 2, /* VIDEO */
529 3, /* VANC */
530 4, /* HANC */
531 NOT_SUPPORTED /* ir_index */
532 }
533 }
534 ,
535 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
536 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
537 NOT_SUPPORTED}
538 }
539 ,
540 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
541 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
542 NOT_SUPPORTED}
543 }
544 }
545 ,
546 { /* full-speed */
547 {
548 0, /* config index */
549 {
550 0, /* interrupt ep index */
551 NOT_SUPPORTED, /* ts1 index */
552 NOT_SUPPORTED, /* TS2 index */
553 1, /* AUDIO */
554 2, /* VIDEO */
555 NOT_SUPPORTED, /* VANC */
556 NOT_SUPPORTED, /* HANC */
557 NOT_SUPPORTED /* ir_index */
558 }
559 }
560 ,
561 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
562 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
563 NOT_SUPPORTED}
564 }
565 ,
566 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
567 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
568 NOT_SUPPORTED}
569 }
570 }
571 }
572 ,
573 {
574 INDEX_BUSPOWER_DIF_ONLY, /* index */
575 USB_BUS_POWER, /* power_type */
576 0, /* speed , not decide yet */
577 /* mode ,analog tv AND DIGITAL path */
578 MOD_DIF | MOD_ANALOG | MOD_DIGITAL | MOD_EXTERNAL,
579 SOURCE_TS_BDA, /* ts1_source, disable */
580 NOT_SUPPORTED, /* ts2_source */
581 SOURCE_DIF | SOURCE_ANALOG | SOURCE_EXTERNAL, /* analog source, dif */
582 0, /* digital_index */
583 0, /* analog index */
584 0, /* dif_index */
585 0, /* external_index */
586 1, /* only one configuration */
587 {
588 {
589 0, /* config index */
590 {
591 0, /* interrupt ep index */
592 1, /* ts1 index */
593 NOT_SUPPORTED, /* TS2 index */
594 2, /* AUDIO */
595 3, /* VIDEO */
596 4, /* VANC */
597 5, /* HANC */
598 NOT_SUPPORTED /* ir_index */
599 }
600 }
601 ,
602 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
603 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
604 NOT_SUPPORTED}
605 }
606 ,
607 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
608 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
609 NOT_SUPPORTED}
610 }
611 }
612 ,
613 { /* full speed */
614 {
615 0, /* config index */
616 {
617 0, /* interrupt ep index */
618 1, /* ts1 index */
619 NOT_SUPPORTED, /* TS2 index */
620 2, /* AUDIO */
621 3, /* VIDEO */
622 NOT_SUPPORTED, /* VANC */
623 NOT_SUPPORTED, /* HANC */
624 NOT_SUPPORTED /* ir_index */
625 }
626 }
627 ,
628 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
629 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
630 NOT_SUPPORTED}
631 }
632 ,
633 {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
634 NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED,
635 NOT_SUPPORTED}
636 }
637 }
638 }
639 ,
640
641 };
642
643 /*****************************************************************/
644
initialize_cx231xx(struct cx231xx * dev)645 int initialize_cx231xx(struct cx231xx *dev)
646 {
647 int retval;
648 u32 config_info = 0;
649 struct pcb_config *p_pcb_info;
650 u8 usb_speed = 1; /* from register,1--HS, 0--FS */
651 u8 data[4] = { 0, 0, 0, 0 };
652 u32 ts1_source = 0;
653 u32 ts2_source = 0;
654 u32 analog_source = 0;
655 u8 _current_scenario_idx = 0xff;
656
657 ts1_source = SOURCE_TS_BDA;
658 ts2_source = SOURCE_TS_BDA;
659
660 /* read board config register to find out which
661 pcb config it is related to */
662 retval = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, BOARD_CFG_STAT,
663 data, 4);
664 if (retval < 0)
665 return retval;
666
667 config_info = le32_to_cpu(*((__le32 *)data));
668 usb_speed = (u8) (config_info & 0x1);
669
670 /* Verify this device belongs to Bus power or Self power device */
671 if (config_info & BUS_POWER) { /* bus-power */
672 switch (config_info & BUSPOWER_MASK) {
673 case TS1_PORT | BUS_POWER:
674 cx231xx_Scenario[INDEX_BUSPOWER_DIGITAL_ONLY].speed =
675 usb_speed;
676 p_pcb_info =
677 &cx231xx_Scenario[INDEX_BUSPOWER_DIGITAL_ONLY];
678 _current_scenario_idx = INDEX_BUSPOWER_DIGITAL_ONLY;
679 break;
680 case AVDEC_ENABLE | BUS_POWER:
681 cx231xx_Scenario[INDEX_BUSPOWER_ANALOG_ONLY].speed =
682 usb_speed;
683 p_pcb_info =
684 &cx231xx_Scenario[INDEX_BUSPOWER_ANALOG_ONLY];
685 _current_scenario_idx = INDEX_BUSPOWER_ANALOG_ONLY;
686 break;
687 case AVDEC_ENABLE | BUS_POWER | TS1_PORT:
688 cx231xx_Scenario[INDEX_BUSPOWER_DIF_ONLY].speed =
689 usb_speed;
690 p_pcb_info = &cx231xx_Scenario[INDEX_BUSPOWER_DIF_ONLY];
691 _current_scenario_idx = INDEX_BUSPOWER_DIF_ONLY;
692 break;
693 default:
694 dev_err(dev->dev,
695 "bad config in buspower!!!!\nconfig_info=%x\n",
696 config_info & BUSPOWER_MASK);
697 return 1;
698 }
699 } else { /* self-power */
700
701 switch (config_info & SELFPOWER_MASK) {
702 case TS1_PORT | SELF_POWER:
703 cx231xx_Scenario[INDEX_SELFPOWER_DIGITAL_ONLY].speed =
704 usb_speed;
705 p_pcb_info =
706 &cx231xx_Scenario[INDEX_SELFPOWER_DIGITAL_ONLY];
707 _current_scenario_idx = INDEX_SELFPOWER_DIGITAL_ONLY;
708 break;
709 case TS1_TS2_PORT | SELF_POWER:
710 cx231xx_Scenario[INDEX_SELFPOWER_DUAL_DIGITAL].speed =
711 usb_speed;
712 cx231xx_Scenario[INDEX_SELFPOWER_DUAL_DIGITAL].
713 ts2_source = ts2_source;
714 p_pcb_info =
715 &cx231xx_Scenario[INDEX_SELFPOWER_DUAL_DIGITAL];
716 _current_scenario_idx = INDEX_SELFPOWER_DUAL_DIGITAL;
717 break;
718 case AVDEC_ENABLE | SELF_POWER:
719 cx231xx_Scenario[INDEX_SELFPOWER_ANALOG_ONLY].speed =
720 usb_speed;
721 cx231xx_Scenario[INDEX_SELFPOWER_ANALOG_ONLY].
722 analog_source = analog_source;
723 p_pcb_info =
724 &cx231xx_Scenario[INDEX_SELFPOWER_ANALOG_ONLY];
725 _current_scenario_idx = INDEX_SELFPOWER_ANALOG_ONLY;
726 break;
727 case AVDEC_ENABLE | TS1_PORT | SELF_POWER:
728 cx231xx_Scenario[INDEX_SELFPOWER_DUAL].speed =
729 usb_speed;
730 cx231xx_Scenario[INDEX_SELFPOWER_DUAL].ts1_source =
731 ts1_source;
732 cx231xx_Scenario[INDEX_SELFPOWER_DUAL].analog_source =
733 analog_source;
734 p_pcb_info = &cx231xx_Scenario[INDEX_SELFPOWER_DUAL];
735 _current_scenario_idx = INDEX_SELFPOWER_DUAL;
736 break;
737 case AVDEC_ENABLE | TS1_TS2_PORT | SELF_POWER:
738 cx231xx_Scenario[INDEX_SELFPOWER_TRIPLE].speed =
739 usb_speed;
740 cx231xx_Scenario[INDEX_SELFPOWER_TRIPLE].ts1_source =
741 ts1_source;
742 cx231xx_Scenario[INDEX_SELFPOWER_TRIPLE].ts2_source =
743 ts2_source;
744 cx231xx_Scenario[INDEX_SELFPOWER_TRIPLE].analog_source =
745 analog_source;
746 p_pcb_info = &cx231xx_Scenario[INDEX_SELFPOWER_TRIPLE];
747 _current_scenario_idx = INDEX_SELFPOWER_TRIPLE;
748 break;
749 case AVDEC_ENABLE | TS1VIP_TS2_PORT | SELF_POWER:
750 cx231xx_Scenario[INDEX_SELFPOWER_COMPRESSOR].speed =
751 usb_speed;
752 cx231xx_Scenario[INDEX_SELFPOWER_COMPRESSOR].
753 analog_source = analog_source;
754 p_pcb_info =
755 &cx231xx_Scenario[INDEX_SELFPOWER_COMPRESSOR];
756 _current_scenario_idx = INDEX_SELFPOWER_COMPRESSOR;
757 break;
758 default:
759 dev_err(dev->dev,
760 "bad scenario!!!!!\nconfig_info=%x\n",
761 config_info & SELFPOWER_MASK);
762 return -ENODEV;
763 }
764 }
765
766 dev->current_scenario_idx = _current_scenario_idx;
767
768 memcpy(&dev->current_pcb_config, p_pcb_info,
769 sizeof(struct pcb_config));
770
771 if (pcb_debug) {
772 dev_info(dev->dev,
773 "SC(0x00) register = 0x%x\n", config_info);
774 dev_info(dev->dev,
775 "scenario %d\n",
776 (dev->current_pcb_config.index) + 1);
777 dev_info(dev->dev,
778 "type=%x\n",
779 dev->current_pcb_config.type);
780 dev_info(dev->dev,
781 "mode=%x\n",
782 dev->current_pcb_config.mode);
783 dev_info(dev->dev,
784 "speed=%x\n",
785 dev->current_pcb_config.speed);
786 dev_info(dev->dev,
787 "ts1_source=%x\n",
788 dev->current_pcb_config.ts1_source);
789 dev_info(dev->dev,
790 "ts2_source=%x\n",
791 dev->current_pcb_config.ts2_source);
792 dev_info(dev->dev,
793 "analog_source=%x\n",
794 dev->current_pcb_config.analog_source);
795 }
796
797 return 0;
798 }
799