1 /*****************************************************************************
7 *****************************************************************************/
10 * Copyright (C) 2010 R.M. Thomas <rmthomas@sciolus.org>
13 * This is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * The software is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this software; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 /*****************************************************************************/
30 * ACKNOWLEGEMENTS AND REFERENCES
31 * ------------------------------
32 * This driver makes use of register information contained in the Syntek
33 * Semicon DC-1125 driver hosted at
34 * http://sourceforge.net/projects/syntekdriver/.
35 * Particularly useful has been a patch to the latter driver provided by
36 * Ivor Hewitt in January 2009. The NTSC implementation is taken from the
39 /****************************************************************************/
42 #include "easycap_debug.h"
44 /*--------------------------------------------------------------------------*/
45 const struct stk1160config
{ int reg
; int set
; } stk1160configPAL
[256] = {
65 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
69 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
78 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
86 /*--------------------------------------------------------------------------*/
87 const struct stk1160config stk1160configNTSC
[256] = {
107 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
111 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
120 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
128 /*--------------------------------------------------------------------------*/
129 const struct saa7113config
{ int reg
; int set
; } saa7113configPAL
[256] = {
131 #if defined(ANTIALIAS)
143 {0x0A, SAA_0A_DEFAULT
},
144 {0x0B, SAA_0B_DEFAULT
},
145 {0x0C, SAA_0C_DEFAULT
},
146 {0x0D, SAA_0D_DEFAULT
},
186 /*--------------------------------------------------------------------------*/
187 const struct saa7113config saa7113configNTSC
[256] = {
189 #if defined(ANTIALIAS)
201 {0x0A, SAA_0A_DEFAULT
},
202 {0x0B, SAA_0B_DEFAULT
},
203 {0x0C, SAA_0C_DEFAULT
},
204 {0x0D, SAA_0D_DEFAULT
},
244 /*--------------------------------------------------------------------------*/
246 /****************************************************************************/
248 confirm_resolution(struct usb_device
*p
)
250 __u8 get0
, get1
, get2
, get3
, get4
, get5
, get6
, get7
;
254 GET(p
, 0x0110, &get0
);
255 GET(p
, 0x0111, &get1
);
256 GET(p
, 0x0112, &get2
);
257 GET(p
, 0x0113, &get3
);
258 GET(p
, 0x0114, &get4
);
259 GET(p
, 0x0115, &get5
);
260 GET(p
, 0x0116, &get6
);
261 GET(p
, 0x0117, &get7
);
262 JOT(8, "0x%03X, 0x%03X, " \
265 "0x%03X, 0x%03X\n", \
266 get0
, get1
, get2
, get3
, get4
, get5
, get6
, get7
);
267 JOT(8, "....cf PAL_720x526: " \
271 "0x%03X, 0x%03X\n", \
272 0x000, 0x000, 0x001, 0x000, 0x5A0, 0x005, 0x121, 0x001);
273 JOT(8, "....cf PAL_704x526: " \
277 "0x%03X, 0x%03X\n", \
278 0x004, 0x000, 0x001, 0x000, 0x584, 0x005, 0x121, 0x001);
279 JOT(8, "....cf VGA_640x480: " \
283 "0x%03X, 0x%03X\n", \
284 0x008, 0x000, 0x020, 0x000, 0x508, 0x005, 0x110, 0x001);
287 /****************************************************************************/
289 confirm_stream(struct usb_device
*p
)
296 GET(p
, 0x0100, &igot
); get2
= 0x80 & igot
;
298 JOT(8, "confirm_stream: OK\n");
300 JOT(8, "confirm_stream: STUCK\n");
303 /****************************************************************************/
305 setup_stk(struct usb_device
*p
, bool ntsc
)
313 while (0xFFF != stk1160configNTSC
[i0
].reg
) {
314 SET(p
, stk1160configNTSC
[i0
].reg
, stk1160configNTSC
[i0
].set
);
318 while (0xFFF != stk1160configPAL
[i0
].reg
) {
319 SET(p
, stk1160configPAL
[i0
].reg
, stk1160configPAL
[i0
].set
);
328 /****************************************************************************/
330 setup_saa(struct usb_device
*p
, bool ntsc
)
338 while (0xFF != saa7113configNTSC
[i0
].reg
) {
339 ir
= write_saa(p
, saa7113configNTSC
[i0
].reg
, \
340 saa7113configNTSC
[i0
].set
);
344 while (0xFF != saa7113configPAL
[i0
].reg
) {
345 ir
= write_saa(p
, saa7113configPAL
[i0
].reg
, \
346 saa7113configPAL
[i0
].set
);
352 /****************************************************************************/
354 write_000(struct usb_device
*p
, __u16 set2
, __u16 set0
)
360 GET(p
, 0x0002, &igot2
);
361 GET(p
, 0x0000, &igot0
);
362 SET(p
, 0x0002, set2
);
363 SET(p
, 0x0000, set0
);
366 /****************************************************************************/
368 write_saa(struct usb_device
*p
, __u16 reg0
, __u16 set0
)
378 /****************************************************************************/
379 /*--------------------------------------------------------------------------*/
381 * REGISTER 500: SETTING VALUE TO 0x008B READS FROM VT1612A (?)
382 * REGISTER 500: SETTING VALUE TO 0x008C WRITES TO VT1612A
383 * REGISTER 502: LEAST SIGNIFICANT BYTE OF VALUE TO SET
384 * REGISTER 503: MOST SIGNIFICANT BYTE OF VALUE TO SET
385 * REGISTER 504: TARGET ADDRESS ON VT1612A
387 /*--------------------------------------------------------------------------*/
389 write_vt(struct usb_device
*p
, __u16 reg0
, __u16 set0
)
392 __u16 got502
, got503
;
393 __u16 set502
, set503
;
397 SET(p
, 0x0504, reg0
);
398 SET(p
, 0x0500, 0x008B);
400 GET(p
, 0x0502, &igot
); got502
= (0xFF & igot
);
401 GET(p
, 0x0503, &igot
); got503
= (0xFF & igot
);
403 JOT(16, "write_vt(., 0x%04X, 0x%04X): was 0x%04X\n", \
404 reg0
, set0
, ((got503
<< 8) | got502
));
406 set502
= (0x00FF & set0
);
407 set503
= ((0xFF00 & set0
) >> 8);
409 SET(p
, 0x0504, reg0
);
410 SET(p
, 0x0502, set502
);
411 SET(p
, 0x0503, set503
);
412 SET(p
, 0x0500, 0x008C);
416 /****************************************************************************/
417 /*--------------------------------------------------------------------------*/
419 * REGISTER 500: SETTING VALUE TO 0x008B READS FROM VT1612A (?)
420 * REGISTER 500: SETTING VALUE TO 0x008C WRITES TO VT1612A
421 * REGISTER 502: LEAST SIGNIFICANT BYTE OF VALUE TO GET
422 * REGISTER 503: MOST SIGNIFICANT BYTE OF VALUE TO GET
423 * REGISTER 504: TARGET ADDRESS ON VT1612A
425 /*--------------------------------------------------------------------------*/
427 read_vt(struct usb_device
*p
, __u16 reg0
)
430 __u16 got502
, got503
;
434 SET(p
, 0x0504, reg0
);
435 SET(p
, 0x0500, 0x008B);
437 GET(p
, 0x0502, &igot
); got502
= (0xFF & igot
);
438 GET(p
, 0x0503, &igot
); got503
= (0xFF & igot
);
440 JOT(16, "read_vt(., 0x%04X): has 0x%04X\n", reg0
, ((got503
<< 8) | got502
));
442 return (got503
<< 8) | got502
;
444 /****************************************************************************/
445 /*--------------------------------------------------------------------------*/
447 * THESE APPEAR TO HAVE NO EFFECT ON EITHER VIDEO OR AUDIO.
449 /*--------------------------------------------------------------------------*/
451 write_300(struct usb_device
*p
)
455 SET(p
, 0x300, 0x0012);
456 SET(p
, 0x350, 0x002D);
457 SET(p
, 0x351, 0x0001);
458 SET(p
, 0x352, 0x0000);
459 SET(p
, 0x353, 0x0000);
460 SET(p
, 0x300, 0x0080);
463 /****************************************************************************/
464 /*--------------------------------------------------------------------------*/
466 * NOTE: THE FOLLOWING IS NOT CHECKED:
467 * REGISTER 0x0F, WHICH IS INVOLVED IN CHROMINANCE AUTOMATIC GAIN CONTROL.
469 /*--------------------------------------------------------------------------*/
471 check_saa(struct usb_device
*p
, bool ntsc
)
480 while (0xFF != saa7113configNTSC
[i0
].reg
) {
481 if (0x0F == saa7113configNTSC
[i0
].reg
) {
486 ir
= read_saa(p
, saa7113configNTSC
[i0
].reg
);
487 if (ir
!= saa7113configNTSC
[i0
].set
) {
488 SAY("SAA register 0x%02X has 0x%02X, " \
489 "expected 0x%02X\n", \
490 saa7113configNTSC
[i0
].reg
, \
491 ir
, saa7113configNTSC
[i0
].set
);
497 while (0xFF != saa7113configPAL
[i0
].reg
) {
498 if (0x0F == saa7113configPAL
[i0
].reg
) {
503 ir
= read_saa(p
, saa7113configPAL
[i0
].reg
);
504 if (ir
!= saa7113configPAL
[i0
].set
) {
505 SAY("SAA register 0x%02X has 0x%02X, " \
506 "expected 0x%02X\n", \
507 saa7113configPAL
[i0
].reg
, \
508 ir
, saa7113configPAL
[i0
].set
);
519 /****************************************************************************/
521 merit_saa(struct usb_device
*p
)
527 rc
= read_saa(p
, 0x1F);
528 if ((0 > rc
) || (0x02 & rc
))
533 /****************************************************************************/
535 ready_saa(struct usb_device
*p
)
538 const int max
= 5, marktime
= PATIENCE
/5;
539 /*--------------------------------------------------------------------------*/
541 * RETURNS 0 FOR INTERLACED 50 Hz
542 * 1 FOR NON-INTERLACED 50 Hz
543 * 2 FOR INTERLACED 60 Hz
544 * 3 FOR NON-INTERLACED 60 Hz
546 /*--------------------------------------------------------------------------*/
551 rc
= read_saa(p
, 0x1F);
553 if (0 == (0x40 & rc
))
555 if (1 == (0x01 & rc
))
566 JOT(8, "hardware detects 60 Hz\n");
569 JOT(8, "hardware detects 50 Hz\n");
572 JOT(8, "hardware detects interlacing\n");
575 JOT(8, "hardware detects no interlacing\n");
580 /****************************************************************************/
581 /*--------------------------------------------------------------------------*/
583 * NOTE: THE FOLLOWING ARE NOT CHECKED:
584 * REGISTERS 0x000, 0x002: FUNCTIONALITY IS NOT KNOWN
585 * REGISTER 0x100: ACCEPT ALSO (0x80 | stk1160config....[.].set)
587 /*--------------------------------------------------------------------------*/
589 check_stk(struct usb_device
*p
, bool ntsc
)
597 while (0xFFF != stk1160configNTSC
[i0
].reg
) {
598 if (0x000 == stk1160configNTSC
[i0
].reg
) {
601 if (0x002 == stk1160configNTSC
[i0
].reg
) {
604 ir
= read_stk(p
, stk1160configNTSC
[i0
].reg
);
605 if (0x100 == stk1160configNTSC
[i0
].reg
) {
606 if ((ir
!= (0xFF & stk1160configNTSC
[i0
].set
)) && \
607 (ir
!= (0x80 | (0xFF & \
608 stk1160configNTSC
[i0
].set
))) && \
610 stk1160configNTSC
[i0
].set
)) {
611 SAY("STK register 0x%03X has 0x%02X, " \
612 "expected 0x%02X\n", \
613 stk1160configNTSC
[i0
].reg
, \
614 ir
, stk1160configNTSC
[i0
].set
);
618 if ((ir
!= (0xFF & stk1160configNTSC
[i0
].set
)) && \
619 (0xFFFF != stk1160configNTSC
[i0
].set
)) {
620 SAY("STK register 0x%03X has 0x%02X, " \
621 "expected 0x%02X\n", \
622 stk1160configNTSC
[i0
].reg
, \
623 ir
, stk1160configNTSC
[i0
].set
);
628 while (0xFFF != stk1160configPAL
[i0
].reg
) {
629 if (0x000 == stk1160configPAL
[i0
].reg
) {
632 if (0x002 == stk1160configPAL
[i0
].reg
) {
635 ir
= read_stk(p
, stk1160configPAL
[i0
].reg
);
636 if (0x100 == stk1160configPAL
[i0
].reg
) {
637 if ((ir
!= (0xFF & stk1160configPAL
[i0
].set
)) && \
638 (ir
!= (0x80 | (0xFF & \
639 stk1160configPAL
[i0
].set
))) && \
641 stk1160configPAL
[i0
].set
)) {
642 SAY("STK register 0x%03X has 0x%02X, " \
643 "expected 0x%02X\n", \
644 stk1160configPAL
[i0
].reg
, \
645 ir
, stk1160configPAL
[i0
].set
);
649 if ((ir
!= (0xFF & stk1160configPAL
[i0
].set
)) && \
650 (0xFFFF != stk1160configPAL
[i0
].set
)) {
651 SAY("STK register 0x%03X has 0x%02X, " \
652 "expected 0x%02X\n", \
653 stk1160configPAL
[i0
].reg
, \
654 ir
, stk1160configPAL
[i0
].set
);
661 /****************************************************************************/
663 read_saa(struct usb_device
*p
, __u16 reg0
)
671 if (0 != wait_i2c(p
))
674 GET(p
, 0x0209, &igot
);
677 /****************************************************************************/
679 read_stk(struct usb_device
*p
, __u32 reg0
)
689 /****************************************************************************/
690 /*--------------------------------------------------------------------------*/
692 * HARDWARE USERSPACE INPUT NUMBER PHYSICAL INPUT DRIVER input VALUE
694 * CVBS+S-VIDEO 0 or 1 CVBS 1
695 * FOUR-CVBS 0 or 1 CVBS1 1
696 * FOUR-CVBS 2 CVBS2 2
697 * FOUR-CVBS 3 CVBS3 3
698 * FOUR-CVBS 4 CVBS4 4
699 * CVBS+S-VIDEO 5 S-VIDEO 5
701 * WHEN 5==input THE ARGUMENT mode MUST ALSO BE SUPPLIED:
703 * mode 7 => GAIN TO BE SET EXPLICITLY USING REGISTER 0x05 (UNTESTED)
704 * mode 9 => USE AUTOMATIC GAIN CONTROL (DEFAULT)
707 /*---------------------------------------------------------------------------*/
709 select_input(struct usb_device
*p
, int input
, int mode
)
719 if (0 != write_saa(p
, 0x02, 0x80)) {
720 SAY("ERROR: failed to set SAA register 0x02 for input %i\n", \
723 SET(p
, 0x0000, 0x0098);
724 SET(p
, 0x0002, 0x0078);
728 if (0 != write_saa(p
, 0x02, 0x80)) {
729 SAY("ERROR: failed to set SAA register 0x02 for input %i\n", \
732 SET(p
, 0x0000, 0x0090);
733 SET(p
, 0x0002, 0x0078);
737 if (0 != write_saa(p
, 0x02, 0x80)) {
738 SAY("ERROR: failed to set SAA register 0x02 for input %i\n", \
741 SET(p
, 0x0000, 0x0088);
742 SET(p
, 0x0002, 0x0078);
746 if (0 != write_saa(p
, 0x02, 0x80)) {
747 SAY("ERROR: failed to set SAA register 0x02 for input %i\n", \
750 SET(p
, 0x0000, 0x0080);
751 SET(p
, 0x0002, 0x0078);
759 if (0 != write_saa(p
, 0x02, 0x87)) {
760 SAY("ERROR: failed to set SAA register 0x02 " \
761 "for input %i\n", input
);
763 if (0 != write_saa(p
, 0x05, 0xFF)) {
764 SAY("ERROR: failed to set SAA register 0x05 " \
765 "for input %i\n", input
);
770 if (0 != write_saa(p
, 0x02, 0x89)) {
771 SAY("ERROR: failed to set SAA register 0x02 " \
772 "for input %i\n", input
);
774 if (0 != write_saa(p
, 0x05, 0x00)) {
775 SAY("ERROR: failed to set SAA register 0x05 " \
776 "for input %i\n", input
);
781 SAY("MISTAKE: bad mode: %i\n", mode
);
785 if (0 != write_saa(p
, 0x04, 0x00)) {
786 SAY("ERROR: failed to set SAA register 0x04 for input %i\n", \
789 if (0 != write_saa(p
, 0x09, 0x80)) {
790 SAY("ERROR: failed to set SAA register 0x09 for input %i\n", \
793 SET(p
, 0x0002, 0x0093);
797 SAY("ERROR: bad input: %i\n", input
);
801 ir
= read_stk(p
, 0x00);
802 JOT(8, "STK register 0x00 has 0x%02X\n", ir
);
803 ir
= read_saa(p
, 0x02);
804 JOT(8, "SAA register 0x02 has 0x%02X\n", ir
);
810 /****************************************************************************/
812 set_resolution(struct usb_device
*p
, \
813 __u16 set0
, __u16 set1
, __u16 set2
, __u16 set3
)
815 __u16 u0x0111
, u0x0113
, u0x0115
, u0x0117
;
819 u0x0111
= ((0xFF00 & set0
) >> 8);
820 u0x0113
= ((0xFF00 & set1
) >> 8);
821 u0x0115
= ((0xFF00 & set2
) >> 8);
822 u0x0117
= ((0xFF00 & set3
) >> 8);
824 SET(p
, 0x0110, (0x00FF & set0
));
825 SET(p
, 0x0111, u0x0111
);
826 SET(p
, 0x0112, (0x00FF & set1
));
827 SET(p
, 0x0113, u0x0113
);
828 SET(p
, 0x0114, (0x00FF & set2
));
829 SET(p
, 0x0115, u0x0115
);
830 SET(p
, 0x0116, (0x00FF & set3
));
831 SET(p
, 0x0117, u0x0117
);
835 /****************************************************************************/
837 start_100(struct usb_device
*p
)
839 __u16 get116
, get117
, get0
;
840 __u8 igot116
, igot117
, igot
;
844 GET(p
, 0x0116, &igot116
);
846 GET(p
, 0x0117, &igot117
);
848 SET(p
, 0x0116, 0x0000);
849 SET(p
, 0x0117, 0x0000);
851 GET(p
, 0x0100, &igot
);
853 SET(p
, 0x0100, (0x80 | get0
));
855 SET(p
, 0x0116, get116
);
856 SET(p
, 0x0117, get117
);
860 /****************************************************************************/
862 stop_100(struct usb_device
*p
)
869 GET(p
, 0x0100, &igot
);
871 SET(p
, 0x0100, (0x7F & get0
));
874 /****************************************************************************/
875 /*--------------------------------------------------------------------------*/
877 * FUNCTION wait_i2c() RETURNS 0 ON SUCCESS
879 /*--------------------------------------------------------------------------*/
881 wait_i2c(struct usb_device
*p
)
890 for (k
= 0; k
< max
; k
++) {
891 GET(p
, 0x0201, &igot
); get0
= igot
;
908 /****************************************************************************/
910 regset(struct usb_device
*pusb_device
, __u16 index
, __u16 value
)
918 rc0
= usb_control_msg(pusb_device
, usb_sndctrlpipe(pusb_device
, 0), \
920 (__u8
)(USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
), \
927 #if defined(NOREADBACK)
930 rc1
= usb_control_msg(pusb_device
, usb_rcvctrlpipe(pusb_device
, 0), \
932 (__u8
)(USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
), \
936 (__u16
)sizeof(__u16
), \
953 if (0 != (0xFF & igot
)) {
954 JOT(8, "unexpected 0x%02X for STK register 0x%03X\n", \
960 if ((0xFF & value
) != (0xFF & igot
)) {
961 JOT(8, "unexpected 0x%02X != 0x%02X " \
962 "for STK register 0x%03X\n", \
968 #endif /* ! NOREADBACK*/
970 return (0 > rc0
) ? rc0
: rc1
;
972 /*****************************************************************************/
974 regget(struct usb_device
*pusb_device
, __u16 index
, void *pvoid
)
980 ir
= usb_control_msg(pusb_device
, usb_rcvctrlpipe(pusb_device
, 0), \
982 (__u8
)(USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
), \
990 /*****************************************************************************/
992 wakeup_device(struct usb_device
*pusb_device
)
996 return usb_control_msg(pusb_device
, usb_sndctrlpipe(pusb_device
, 0), \
997 (__u8
)USB_REQ_SET_FEATURE
, \
998 (__u8
)(USB_DIR_OUT
| USB_TYPE_STANDARD
| USB_RECIP_DEVICE
), \
999 USB_DEVICE_REMOTE_WAKEUP
, \
1005 /*****************************************************************************/
1007 audio_setup(struct easycap
*peasycap
)
1009 struct usb_device
*pusb_device
;
1010 unsigned char buffer
[1];
1012 /*---------------------------------------------------------------------------*/
1015 * THE MESSAGE OF TYPE (USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE)
1016 * CAUSES MUTING IF THE VALUE 0x0100 IS SENT.
1017 * TO ENABLE AUDIO THE VALUE 0x0200 MUST BE SENT.
1019 /*---------------------------------------------------------------------------*/
1020 const __u8 request
= 0x01;
1021 const __u8 requesttype
= \
1022 (__u8
)(USB_DIR_OUT
| USB_TYPE_CLASS
| USB_RECIP_INTERFACE
);
1023 const __u16 value_unmute
= 0x0200;
1024 const __u16 index
= 0x0301;
1025 const __u16 length
= 1;
1027 if (NULL
== peasycap
)
1030 pusb_device
= peasycap
->pusb_device
;
1031 if (NULL
== pusb_device
)
1034 JOM(8, "%02X %02X %02X %02X %02X %02X %02X %02X\n", \
1035 requesttype
, request
, \
1036 (0x00FF & value_unmute
), \
1037 (0xFF00 & value_unmute
) >> 8, \
1039 (0xFF00 & index
) >> 8, \
1040 (0x00FF & length
), \
1041 (0xFF00 & length
) >> 8);
1045 rc
= usb_control_msg(pusb_device
, usb_sndctrlpipe(pusb_device
, 0), \
1047 (__u8
)requesttype
, \
1048 (__u16
)value_unmute
, \
1050 (void *)&buffer
[0], \
1054 JOT(8, "0x%02X=buffer\n", *((__u8
*) &buffer
[0]));
1055 if (rc
!= (int)length
)
1056 SAY("ERROR: usb_control_msg returned %i\n", rc
);
1058 /*--------------------------------------------------------------------------*/
1060 * REGISTER 500: SETTING VALUE TO 0x0094 RESETS AUDIO CONFIGURATION ???
1061 * REGISTER 506: ANALOGUE AUDIO ATTENTUATOR ???
1062 * FOR THE CVBS+S-VIDEO HARDWARE:
1063 * SETTING VALUE TO 0x0000 GIVES QUIET SOUND.
1064 * THE UPPER BYTE SEEMS TO HAVE NO EFFECT.
1065 * FOR THE FOUR-CVBS HARDWARE:
1066 * SETTING VALUE TO 0x0000 SEEMS TO HAVE NO EFFECT.
1067 * REGISTER 507: ANALOGUE AUDIO PREAMPLIFIER ON/OFF ???
1068 * FOR THE CVBS-S-VIDEO HARDWARE:
1069 * SETTING VALUE TO 0x0001 GIVES VERY LOUD, DISTORTED SOUND.
1070 * THE UPPER BYTE SEEMS TO HAVE NO EFFECT.
1072 /*--------------------------------------------------------------------------*/
1073 SET(pusb_device
, 0x0500, 0x0094);
1074 SET(pusb_device
, 0x0500, 0x008C);
1075 SET(pusb_device
, 0x0506, 0x0001);
1076 SET(pusb_device
, 0x0507, 0x0000);
1077 id1
= read_vt(pusb_device
, 0x007C);
1078 id2
= read_vt(pusb_device
, 0x007E);
1079 SAM("0x%04X:0x%04X is audio vendor id\n", id1
, id2
);
1080 /*---------------------------------------------------------------------------*/
1082 * SELECT AUDIO SOURCE "LINE IN" AND SET THE AUDIO GAIN.
1084 /*---------------------------------------------------------------------------*/
1085 if (31 < easycap_gain
)
1087 if (0 > easycap_gain
)
1089 if (0 != audio_gainset(pusb_device
, (__s8
)easycap_gain
))
1090 SAY("ERROR: audio_gainset() failed\n");
1091 check_vt(pusb_device
);
1094 /*****************************************************************************/
1096 check_vt(struct usb_device
*pusb_device
)
1102 igot
= read_vt(pusb_device
, 0x0002);
1104 SAY("ERROR: failed to read VT1612A register 0x02\n");
1106 SAY("register 0x%02X muted\n", 0x02);
1108 igot
= read_vt(pusb_device
, 0x000E);
1110 SAY("ERROR: failed to read VT1612A register 0x0E\n");
1112 SAY("register 0x%02X muted\n", 0x0E);
1114 igot
= read_vt(pusb_device
, 0x0010);
1116 SAY("ERROR: failed to read VT1612A register 0x10\n");
1118 SAY("register 0x%02X muted\n", 0x10);
1120 igot
= read_vt(pusb_device
, 0x0012);
1122 SAY("ERROR: failed to read VT1612A register 0x12\n");
1124 SAY("register 0x%02X muted\n", 0x12);
1126 igot
= read_vt(pusb_device
, 0x0014);
1128 SAY("ERROR: failed to read VT1612A register 0x14\n");
1130 SAY("register 0x%02X muted\n", 0x14);
1132 igot
= read_vt(pusb_device
, 0x0016);
1134 SAY("ERROR: failed to read VT1612A register 0x16\n");
1136 SAY("register 0x%02X muted\n", 0x16);
1138 igot
= read_vt(pusb_device
, 0x0018);
1140 SAY("ERROR: failed to read VT1612A register 0x18\n");
1142 SAY("register 0x%02X muted\n", 0x18);
1144 igot
= read_vt(pusb_device
, 0x001C);
1146 SAY("ERROR: failed to read VT1612A register 0x1C\n");
1148 SAY("register 0x%02X muted\n", 0x1C);
1152 /*****************************************************************************/
1153 /*---------------------------------------------------------------------------*/
1154 /* NOTE: THIS DOES INCREASE THE VOLUME DRAMATICALLY:
1155 * audio_gainset(pusb_device, 0x000F);
1157 * loud dB register 0x10 dB register 0x1C dB total
1166 /*---------------------------------------------------------------------------*/
1168 audio_gainset(struct usb_device
*pusb_device
, __s8 loud
)
1174 if (NULL
== pusb_device
)
1181 write_vt(pusb_device
, 0x0002, 0x8000);
1182 /*---------------------------------------------------------------------------*/
1183 igot
= read_vt(pusb_device
, 0x000E);
1185 SAY("ERROR: failed to read VT1612A register 0x0E\n");
1188 mute
= 0x8000 & ((unsigned int)igot
);
1192 u8
= 0x01 | (0x001F & (((__u8
)(15 - loud
)) << 1));
1196 JOT(8, "0x%04X=(mute|u8) for VT1612A register 0x0E\n", mute
| u8
);
1197 write_vt(pusb_device
, 0x000E, (mute
| u8
));
1198 /*---------------------------------------------------------------------------*/
1199 igot
= read_vt(pusb_device
, 0x0010);
1201 SAY("ERROR: failed to read VT1612A register 0x10\n");
1204 mute
= 0x8000 & ((unsigned int)igot
);
1207 JOT(8, "0x%04X=(mute|u8|(u8<<8)) for VT1612A register 0x10,...0x18\n", \
1208 mute
| u8
| (u8
<< 8));
1209 write_vt(pusb_device
, 0x0010, (mute
| u8
| (u8
<< 8)));
1210 write_vt(pusb_device
, 0x0012, (mute
| u8
| (u8
<< 8)));
1211 write_vt(pusb_device
, 0x0014, (mute
| u8
| (u8
<< 8)));
1212 write_vt(pusb_device
, 0x0016, (mute
| u8
| (u8
<< 8)));
1213 write_vt(pusb_device
, 0x0018, (mute
| u8
| (u8
<< 8)));
1214 /*---------------------------------------------------------------------------*/
1215 igot
= read_vt(pusb_device
, 0x001C);
1217 SAY("ERROR: failed to read VT1612A register 0x1C\n");
1220 mute
= 0x8000 & ((unsigned int)igot
);
1224 u8
= 0x000F & (__u8
)(loud
- 16);
1228 JOT(8, "0x%04X=(mute|u8|(u8<<8)) for VT1612A register 0x1C\n", \
1229 mute
| u8
| (u8
<< 8));
1230 write_vt(pusb_device
, 0x001C, (mute
| u8
| (u8
<< 8)));
1231 write_vt(pusb_device
, 0x001A, 0x0404);
1232 write_vt(pusb_device
, 0x0002, 0x0000);
1235 /*****************************************************************************/
1237 audio_gainget(struct usb_device
*pusb_device
)
1241 if (NULL
== pusb_device
)
1243 igot
= read_vt(pusb_device
, 0x001C);
1245 SAY("ERROR: failed to read VT1612A register 0x1C\n");
1248 /*****************************************************************************/