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