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 /****************************************************************************/
43 #define GET(X, Y, Z) do { \
46 __rc = regget(X, Y, Z, sizeof(u8)); \
48 JOT(8, ":-(%i\n", __LINE__); return __rc; \
52 #define SET(X, Y, Z) do { \
54 __rc = regset(X, Y, Z); \
56 JOT(8, ":-(%i\n", __LINE__); return __rc; \
60 /*--------------------------------------------------------------------------*/
61 static const struct stk1160config
{
64 } stk1160configPAL
[256] = {
84 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
88 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
97 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
105 /*--------------------------------------------------------------------------*/
106 static const struct stk1160config stk1160configNTSC
[256] = {
126 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
130 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
139 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
147 /*--------------------------------------------------------------------------*/
148 static const struct saa7113config
{
151 } saa7113configPAL
[256] = {
161 {0x0A, SAA_0A_DEFAULT
},
162 {0x0B, SAA_0B_DEFAULT
},
163 {0x0C, SAA_0C_DEFAULT
},
164 {0x0D, SAA_0D_DEFAULT
},
204 /*--------------------------------------------------------------------------*/
205 static const struct saa7113config saa7113configNTSC
[256] = {
215 {0x0A, SAA_0A_DEFAULT
},
216 {0x0B, SAA_0B_DEFAULT
},
217 {0x0C, SAA_0C_DEFAULT
},
218 {0x0D, SAA_0D_DEFAULT
},
259 static int regget(struct usb_device
*pusb_device
,
260 u16 index
, void *reg
, int reg_size
)
267 rc
= usb_control_msg(pusb_device
, usb_rcvctrlpipe(pusb_device
, 0),
269 (USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
),
271 index
, reg
, reg_size
, 50000);
276 static int regset(struct usb_device
*pusb_device
, u16 index
, u16 value
)
283 rc
= usb_control_msg(pusb_device
, usb_sndctrlpipe(pusb_device
, 0),
285 (USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
),
286 value
, index
, NULL
, 0, 500);
291 if (easycap_readback
) {
293 rc
= regget(pusb_device
, index
, &igot
, sizeof(igot
));
310 JOT(8, "unexpected 0x%02X "
311 "for STK register 0x%03X\n",
316 if ((0xFF & value
) != igot
)
317 JOT(8, "unexpected 0x%02X != 0x%02X "
318 "for STK register 0x%03X\n",
326 /*****************************************************************************/
328 /****************************************************************************/
329 int confirm_resolution(struct usb_device
*p
)
331 u8 get0
, get1
, get2
, get3
, get4
, get5
, get6
, get7
;
335 GET(p
, 0x0110, &get0
);
336 GET(p
, 0x0111, &get1
);
337 GET(p
, 0x0112, &get2
);
338 GET(p
, 0x0113, &get3
);
339 GET(p
, 0x0114, &get4
);
340 GET(p
, 0x0115, &get5
);
341 GET(p
, 0x0116, &get6
);
342 GET(p
, 0x0117, &get7
);
343 JOT(8, "0x%03X, 0x%03X, "
347 get0
, get1
, get2
, get3
, get4
, get5
, get6
, get7
);
348 JOT(8, "....cf PAL_720x526: "
353 0x000, 0x000, 0x001, 0x000, 0x5A0, 0x005, 0x121, 0x001);
354 JOT(8, "....cf PAL_704x526: "
359 0x004, 0x000, 0x001, 0x000, 0x584, 0x005, 0x121, 0x001);
360 JOT(8, "....cf VGA_640x480: "
365 0x008, 0x000, 0x020, 0x000, 0x508, 0x005, 0x110, 0x001);
368 /****************************************************************************/
369 int confirm_stream(struct usb_device
*p
)
376 GET(p
, 0x0100, &igot
); get2
= 0x80 & igot
;
378 JOT(8, "confirm_stream: OK\n");
380 JOT(8, "confirm_stream: STUCK\n");
383 /****************************************************************************/
384 int setup_stk(struct usb_device
*p
, bool ntsc
)
392 while (0xFFF != stk1160configNTSC
[i0
].reg
) {
393 SET(p
, stk1160configNTSC
[i0
].reg
,
394 stk1160configNTSC
[i0
].set
);
398 while (0xFFF != stk1160configPAL
[i0
].reg
) {
399 SET(p
, stk1160configPAL
[i0
].reg
,
400 stk1160configPAL
[i0
].set
);
409 /****************************************************************************/
410 int setup_saa(struct usb_device
*p
, bool ntsc
)
418 while (0xFF != saa7113configNTSC
[i0
].reg
) {
419 ir
= write_saa(p
, saa7113configNTSC
[i0
].reg
,
420 saa7113configNTSC
[i0
].set
);
424 while (0xFF != saa7113configPAL
[i0
].reg
) {
425 ir
= write_saa(p
, saa7113configPAL
[i0
].reg
,
426 saa7113configPAL
[i0
].set
);
432 /****************************************************************************/
433 int write_000(struct usb_device
*p
, u16 set2
, u16 set0
)
439 GET(p
, 0x0002, &igot2
);
440 GET(p
, 0x0000, &igot0
);
441 SET(p
, 0x0002, set2
);
442 SET(p
, 0x0000, set0
);
445 /****************************************************************************/
446 int write_saa(struct usb_device
*p
, u16 reg0
, u16 set0
)
456 /****************************************************************************/
457 /*--------------------------------------------------------------------------*/
459 * REGISTER 500: SETTING VALUE TO 0x008B READS FROM VT1612A (?)
460 * REGISTER 500: SETTING VALUE TO 0x008C WRITES TO VT1612A
461 * REGISTER 502: LEAST SIGNIFICANT BYTE OF VALUE TO SET
462 * REGISTER 503: MOST SIGNIFICANT BYTE OF VALUE TO SET
463 * REGISTER 504: TARGET ADDRESS ON VT1612A
465 /*--------------------------------------------------------------------------*/
467 write_vt(struct usb_device
*p
, u16 reg0
, u16 set0
)
475 SET(p
, 0x0504, reg0
);
476 SET(p
, 0x0500, 0x008B);
478 GET(p
, 0x0502, &igot
); got502
= (0xFF & igot
);
479 GET(p
, 0x0503, &igot
); got503
= (0xFF & igot
);
481 JOT(16, "write_vt(., 0x%04X, 0x%04X): was 0x%04X\n",
482 reg0
, set0
, ((got503
<< 8) | got502
));
484 set502
= (0x00FF & set0
);
485 set503
= ((0xFF00 & set0
) >> 8);
487 SET(p
, 0x0504, reg0
);
488 SET(p
, 0x0502, set502
);
489 SET(p
, 0x0503, set503
);
490 SET(p
, 0x0500, 0x008C);
494 /****************************************************************************/
495 /*--------------------------------------------------------------------------*/
497 * REGISTER 500: SETTING VALUE TO 0x008B READS FROM VT1612A (?)
498 * REGISTER 500: SETTING VALUE TO 0x008C WRITES TO VT1612A
499 * REGISTER 502: LEAST SIGNIFICANT BYTE OF VALUE TO GET
500 * REGISTER 503: MOST SIGNIFICANT BYTE OF VALUE TO GET
501 * REGISTER 504: TARGET ADDRESS ON VT1612A
503 /*--------------------------------------------------------------------------*/
504 int read_vt(struct usb_device
*p
, u16 reg0
)
511 SET(p
, 0x0504, reg0
);
512 SET(p
, 0x0500, 0x008B);
514 GET(p
, 0x0502, &igot
); got502
= (0xFF & igot
);
515 GET(p
, 0x0503, &igot
); got503
= (0xFF & igot
);
517 JOT(16, "read_vt(., 0x%04X): has 0x%04X\n",
518 reg0
, ((got503
<< 8) | got502
));
520 return (got503
<< 8) | got502
;
522 /****************************************************************************/
523 /*--------------------------------------------------------------------------*/
525 * THESE APPEAR TO HAVE NO EFFECT ON EITHER VIDEO OR AUDIO.
527 /*--------------------------------------------------------------------------*/
528 int write_300(struct usb_device
*p
)
532 SET(p
, 0x300, 0x0012);
533 SET(p
, 0x350, 0x002D);
534 SET(p
, 0x351, 0x0001);
535 SET(p
, 0x352, 0x0000);
536 SET(p
, 0x353, 0x0000);
537 SET(p
, 0x300, 0x0080);
540 /****************************************************************************/
541 /*--------------------------------------------------------------------------*/
543 * NOTE: THE FOLLOWING IS NOT CHECKED:
544 * REGISTER 0x0F, WHICH IS INVOLVED IN CHROMINANCE AUTOMATIC GAIN CONTROL.
546 /*--------------------------------------------------------------------------*/
547 int check_saa(struct usb_device
*p
, bool ntsc
)
556 while (0xFF != saa7113configNTSC
[i0
].reg
) {
557 if (0x0F == saa7113configNTSC
[i0
].reg
) {
562 ir
= read_saa(p
, saa7113configNTSC
[i0
].reg
);
563 if (ir
!= saa7113configNTSC
[i0
].set
) {
564 SAY("SAA register 0x%02X has 0x%02X, "
566 saa7113configNTSC
[i0
].reg
,
567 ir
, saa7113configNTSC
[i0
].set
);
573 while (0xFF != saa7113configPAL
[i0
].reg
) {
574 if (0x0F == saa7113configPAL
[i0
].reg
) {
579 ir
= read_saa(p
, saa7113configPAL
[i0
].reg
);
580 if (ir
!= saa7113configPAL
[i0
].set
) {
581 SAY("SAA register 0x%02X has 0x%02X, "
583 saa7113configPAL
[i0
].reg
,
584 ir
, saa7113configPAL
[i0
].set
);
595 /****************************************************************************/
596 int merit_saa(struct usb_device
*p
)
602 rc
= read_saa(p
, 0x1F);
603 return ((0 > rc
) || (0x02 & rc
)) ? 1 : 0;
605 /****************************************************************************/
606 int ready_saa(struct usb_device
*p
)
609 const int max
= 5, marktime
= PATIENCE
/5;
610 /*--------------------------------------------------------------------------*/
612 * RETURNS 0 FOR INTERLACED 50 Hz
613 * 1 FOR NON-INTERLACED 50 Hz
614 * 2 FOR INTERLACED 60 Hz
615 * 3 FOR NON-INTERLACED 60 Hz
617 /*--------------------------------------------------------------------------*/
622 rc
= read_saa(p
, 0x1F);
624 if (0 == (0x40 & rc
))
626 if (1 == (0x01 & rc
))
637 JOT(8, "hardware detects 60 Hz\n");
640 JOT(8, "hardware detects 50 Hz\n");
643 JOT(8, "hardware detects interlacing\n");
646 JOT(8, "hardware detects no interlacing\n");
651 /****************************************************************************/
652 /*--------------------------------------------------------------------------*/
654 * NOTE: THE FOLLOWING ARE NOT CHECKED:
655 * REGISTERS 0x000, 0x002: FUNCTIONALITY IS NOT KNOWN
656 * REGISTER 0x100: ACCEPT ALSO (0x80 | stk1160config....[.].set)
658 /*--------------------------------------------------------------------------*/
659 int check_stk(struct usb_device
*p
, bool ntsc
)
667 while (0xFFF != stk1160configNTSC
[i0
].reg
) {
668 if (0x000 == stk1160configNTSC
[i0
].reg
) {
671 if (0x002 == stk1160configNTSC
[i0
].reg
) {
674 ir
= read_stk(p
, stk1160configNTSC
[i0
].reg
);
675 if (0x100 == stk1160configNTSC
[i0
].reg
) {
676 if ((ir
!= (0xFF & stk1160configNTSC
[i0
].set
)) &&
677 (ir
!= (0x80 | (0xFF & stk1160configNTSC
[i0
].set
))) &&
678 (0xFFFF != stk1160configNTSC
[i0
].set
)) {
679 SAY("STK register 0x%03X has 0x%02X, "
681 stk1160configNTSC
[i0
].reg
,
682 ir
, stk1160configNTSC
[i0
].set
);
686 if ((ir
!= (0xFF & stk1160configNTSC
[i0
].set
)) &&
687 (0xFFFF != stk1160configNTSC
[i0
].set
)) {
688 SAY("STK register 0x%03X has 0x%02X, "
690 stk1160configNTSC
[i0
].reg
,
691 ir
, stk1160configNTSC
[i0
].set
);
696 while (0xFFF != stk1160configPAL
[i0
].reg
) {
697 if (0x000 == stk1160configPAL
[i0
].reg
) {
700 if (0x002 == stk1160configPAL
[i0
].reg
) {
703 ir
= read_stk(p
, stk1160configPAL
[i0
].reg
);
704 if (0x100 == stk1160configPAL
[i0
].reg
) {
705 if ((ir
!= (0xFF & stk1160configPAL
[i0
].set
)) &&
706 (ir
!= (0x80 | (0xFF &
707 stk1160configPAL
[i0
].set
))) &&
709 stk1160configPAL
[i0
].set
)) {
710 SAY("STK register 0x%03X has 0x%02X, "
712 stk1160configPAL
[i0
].reg
,
713 ir
, stk1160configPAL
[i0
].set
);
717 if ((ir
!= (0xFF & stk1160configPAL
[i0
].set
)) &&
718 (0xFFFF != stk1160configPAL
[i0
].set
)) {
719 SAY("STK register 0x%03X has 0x%02X, "
721 stk1160configPAL
[i0
].reg
,
722 ir
, stk1160configPAL
[i0
].set
);
729 /****************************************************************************/
730 int read_saa(struct usb_device
*p
, u16 reg0
)
738 if (0 != wait_i2c(p
))
741 GET(p
, 0x0209, &igot
);
744 /****************************************************************************/
745 int read_stk(struct usb_device
*p
, u32 reg0
)
755 /****************************************************************************/
756 /*--------------------------------------------------------------------------*/
758 * HARDWARE USERSPACE INPUT NUMBER PHYSICAL INPUT DRIVER input VALUE
760 * CVBS+S-VIDEO 0 or 1 CVBS 1
761 * FOUR-CVBS 0 or 1 CVBS1 1
762 * FOUR-CVBS 2 CVBS2 2
763 * FOUR-CVBS 3 CVBS3 3
764 * FOUR-CVBS 4 CVBS4 4
765 * CVBS+S-VIDEO 5 S-VIDEO 5
767 * WHEN 5==input THE ARGUMENT mode MUST ALSO BE SUPPLIED:
769 * mode 7 => GAIN TO BE SET EXPLICITLY USING REGISTER 0x05 (UNTESTED)
770 * mode 9 => USE AUTOMATIC GAIN CONTROL (DEFAULT)
773 /*---------------------------------------------------------------------------*/
775 select_input(struct usb_device
*p
, int input
, int mode
)
785 if (0 != write_saa(p
, 0x02, 0x80))
786 SAY("ERROR: failed to set SAA register 0x02 "
787 "for input %i\n", input
);
789 SET(p
, 0x0000, 0x0098);
790 SET(p
, 0x0002, 0x0078);
794 if (0 != write_saa(p
, 0x02, 0x80))
795 SAY("ERROR: failed to set SAA register 0x02 "
796 "for input %i\n", input
);
798 SET(p
, 0x0000, 0x0090);
799 SET(p
, 0x0002, 0x0078);
803 if (0 != write_saa(p
, 0x02, 0x80))
804 SAY("ERROR: failed to set SAA register 0x02 "
805 " for input %i\n", input
);
807 SET(p
, 0x0000, 0x0088);
808 SET(p
, 0x0002, 0x0078);
812 if (0 != write_saa(p
, 0x02, 0x80)) {
813 SAY("ERROR: failed to set SAA register 0x02 "
814 "for input %i\n", input
);
816 SET(p
, 0x0000, 0x0080);
817 SET(p
, 0x0002, 0x0078);
825 if (0 != write_saa(p
, 0x02, 0x87))
826 SAY("ERROR: failed to set SAA register 0x02 "
827 "for input %i\n", input
);
829 if (0 != write_saa(p
, 0x05, 0xFF))
830 SAY("ERROR: failed to set SAA register 0x05 "
831 "for input %i\n", input
);
836 if (0 != write_saa(p
, 0x02, 0x89))
837 SAY("ERROR: failed to set SAA register 0x02 "
838 "for input %i\n", input
);
840 if (0 != write_saa(p
, 0x05, 0x00))
841 SAY("ERROR: failed to set SAA register 0x05 "
842 "for input %i\n", input
);
847 SAY("MISTAKE: bad mode: %i\n", mode
);
851 if (0 != write_saa(p
, 0x04, 0x00))
852 SAY("ERROR: failed to set SAA register 0x04 "
853 "for input %i\n", input
);
855 if (0 != write_saa(p
, 0x09, 0x80))
856 SAY("ERROR: failed to set SAA register 0x09 "
857 "for input %i\n", input
);
859 SET(p
, 0x0002, 0x0093);
863 SAY("ERROR: bad input: %i\n", input
);
867 ir
= read_stk(p
, 0x00);
868 JOT(8, "STK register 0x00 has 0x%02X\n", ir
);
869 ir
= read_saa(p
, 0x02);
870 JOT(8, "SAA register 0x02 has 0x%02X\n", ir
);
876 /****************************************************************************/
877 int set_resolution(struct usb_device
*p
,
878 u16 set0
, u16 set1
, u16 set2
, u16 set3
)
880 u16 u0x0111
, u0x0113
, u0x0115
, u0x0117
;
884 u0x0111
= ((0xFF00 & set0
) >> 8);
885 u0x0113
= ((0xFF00 & set1
) >> 8);
886 u0x0115
= ((0xFF00 & set2
) >> 8);
887 u0x0117
= ((0xFF00 & set3
) >> 8);
889 SET(p
, 0x0110, (0x00FF & set0
));
890 SET(p
, 0x0111, u0x0111
);
891 SET(p
, 0x0112, (0x00FF & set1
));
892 SET(p
, 0x0113, u0x0113
);
893 SET(p
, 0x0114, (0x00FF & set2
));
894 SET(p
, 0x0115, u0x0115
);
895 SET(p
, 0x0116, (0x00FF & set3
));
896 SET(p
, 0x0117, u0x0117
);
900 /****************************************************************************/
901 int start_100(struct usb_device
*p
)
903 u16 get116
, get117
, get0
;
904 u8 igot116
, igot117
, igot
;
908 GET(p
, 0x0116, &igot116
);
910 GET(p
, 0x0117, &igot117
);
912 SET(p
, 0x0116, 0x0000);
913 SET(p
, 0x0117, 0x0000);
915 GET(p
, 0x0100, &igot
);
917 SET(p
, 0x0100, (0x80 | get0
));
919 SET(p
, 0x0116, get116
);
920 SET(p
, 0x0117, get117
);
924 /****************************************************************************/
925 int stop_100(struct usb_device
*p
)
932 GET(p
, 0x0100, &igot
);
934 SET(p
, 0x0100, (0x7F & get0
));
937 /****************************************************************************/
938 /*--------------------------------------------------------------------------*/
940 * FUNCTION wait_i2c() RETURNS 0 ON SUCCESS
942 /*--------------------------------------------------------------------------*/
943 int wait_i2c(struct usb_device
*p
)
953 for (k
= 0; k
< max
; k
++) {
954 GET(p
, 0x0201, &igot
); get0
= igot
;
968 /****************************************************************************/
969 /*****************************************************************************/
970 int wakeup_device(struct usb_device
*pusb_device
)
974 return usb_control_msg(pusb_device
, usb_sndctrlpipe(pusb_device
, 0),
976 USB_DIR_OUT
| USB_TYPE_STANDARD
| USB_RECIP_DEVICE
,
977 USB_DEVICE_REMOTE_WAKEUP
,
980 /*****************************************************************************/
982 audio_setup(struct easycap
*peasycap
)
984 struct usb_device
*pusb_device
;
987 /*---------------------------------------------------------------------------*/
990 * THE MESSAGE OF TYPE (USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE)
991 * CAUSES MUTING IF THE VALUE 0x0100 IS SENT.
992 * TO ENABLE AUDIO THE VALUE 0x0200 MUST BE SENT.
994 /*---------------------------------------------------------------------------*/
995 const u8 request
= 0x01;
996 const u8 requesttype
= USB_DIR_OUT
|
999 const u16 value_unmute
= 0x0200;
1000 const u16 index
= 0x0301;
1001 const u16 length
= 1;
1003 if (NULL
== peasycap
)
1006 pusb_device
= peasycap
->pusb_device
;
1007 if (NULL
== pusb_device
)
1010 JOM(8, "%02X %02X %02X %02X %02X %02X %02X %02X\n",
1011 requesttype
, request
,
1012 (0x00FF & value_unmute
),
1013 (0xFF00 & value_unmute
) >> 8,
1015 (0xFF00 & index
) >> 8,
1017 (0xFF00 & length
) >> 8);
1021 rc
= usb_control_msg(pusb_device
, usb_sndctrlpipe(pusb_device
, 0),
1022 request
, requesttype
, value_unmute
,
1023 index
, &buffer
[0], length
, 50000);
1025 JOT(8, "0x%02X=buffer\n", buffer
[0]);
1026 if (rc
!= (int)length
) {
1029 SAY("usb_control_msg returned -EPIPE\n");
1032 SAY("ERROR: usb_control_msg returned %i\n", rc
);
1036 /*--------------------------------------------------------------------------*/
1038 * REGISTER 500: SETTING VALUE TO 0x0094 RESETS AUDIO CONFIGURATION ???
1039 * REGISTER 506: ANALOGUE AUDIO ATTENTUATOR ???
1040 * FOR THE CVBS+S-VIDEO HARDWARE:
1041 * SETTING VALUE TO 0x0000 GIVES QUIET SOUND.
1042 * THE UPPER BYTE SEEMS TO HAVE NO EFFECT.
1043 * FOR THE FOUR-CVBS HARDWARE:
1044 * SETTING VALUE TO 0x0000 SEEMS TO HAVE NO EFFECT.
1045 * REGISTER 507: ANALOGUE AUDIO PREAMPLIFIER ON/OFF ???
1046 * FOR THE CVBS-S-VIDEO HARDWARE:
1047 * SETTING VALUE TO 0x0001 GIVES VERY LOUD, DISTORTED SOUND.
1048 * THE UPPER BYTE SEEMS TO HAVE NO EFFECT.
1050 /*--------------------------------------------------------------------------*/
1051 SET(pusb_device
, 0x0500, 0x0094);
1052 SET(pusb_device
, 0x0500, 0x008C);
1053 SET(pusb_device
, 0x0506, 0x0001);
1054 SET(pusb_device
, 0x0507, 0x0000);
1055 id1
= read_vt(pusb_device
, 0x007C);
1056 id2
= read_vt(pusb_device
, 0x007E);
1057 SAM("0x%04X:0x%04X is audio vendor id\n", id1
, id2
);
1058 /*---------------------------------------------------------------------------*/
1060 * SELECT AUDIO SOURCE "LINE IN" AND SET THE AUDIO GAIN.
1062 /*---------------------------------------------------------------------------*/
1063 if (0 != audio_gainset(pusb_device
, peasycap
->gain
))
1064 SAY("ERROR: audio_gainset() failed\n");
1065 check_vt(pusb_device
);
1068 /*****************************************************************************/
1069 int check_vt(struct usb_device
*pusb_device
)
1075 igot
= read_vt(pusb_device
, 0x0002);
1077 SAY("ERROR: failed to read VT1612A register 0x02\n");
1079 SAY("register 0x%02X muted\n", 0x02);
1081 igot
= read_vt(pusb_device
, 0x000E);
1083 SAY("ERROR: failed to read VT1612A register 0x0E\n");
1085 SAY("register 0x%02X muted\n", 0x0E);
1087 igot
= read_vt(pusb_device
, 0x0010);
1089 SAY("ERROR: failed to read VT1612A register 0x10\n");
1091 SAY("register 0x%02X muted\n", 0x10);
1093 igot
= read_vt(pusb_device
, 0x0012);
1095 SAY("ERROR: failed to read VT1612A register 0x12\n");
1097 SAY("register 0x%02X muted\n", 0x12);
1099 igot
= read_vt(pusb_device
, 0x0014);
1101 SAY("ERROR: failed to read VT1612A register 0x14\n");
1103 SAY("register 0x%02X muted\n", 0x14);
1105 igot
= read_vt(pusb_device
, 0x0016);
1107 SAY("ERROR: failed to read VT1612A register 0x16\n");
1109 SAY("register 0x%02X muted\n", 0x16);
1111 igot
= read_vt(pusb_device
, 0x0018);
1113 SAY("ERROR: failed to read VT1612A register 0x18\n");
1115 SAY("register 0x%02X muted\n", 0x18);
1117 igot
= read_vt(pusb_device
, 0x001C);
1119 SAY("ERROR: failed to read VT1612A register 0x1C\n");
1121 SAY("register 0x%02X muted\n", 0x1C);
1125 /*****************************************************************************/
1126 /*---------------------------------------------------------------------------*/
1127 /* NOTE: THIS DOES INCREASE THE VOLUME DRAMATICALLY:
1128 * audio_gainset(pusb_device, 0x000F);
1130 * loud dB register 0x10 dB register 0x1C dB total
1139 /*---------------------------------------------------------------------------*/
1140 int audio_gainset(struct usb_device
*pusb_device
, s8 loud
)
1146 if (NULL
== pusb_device
)
1153 write_vt(pusb_device
, 0x0002, 0x8000);
1154 /*---------------------------------------------------------------------------*/
1155 igot
= read_vt(pusb_device
, 0x000E);
1157 SAY("ERROR: failed to read VT1612A register 0x0E\n");
1160 mute
= 0x8000 & ((unsigned int)igot
);
1164 tmp
= 0x01 | (0x001F & (((u8
)(15 - loud
)) << 1));
1168 JOT(8, "0x%04X=(mute|tmp) for VT1612A register 0x0E\n", mute
| tmp
);
1169 write_vt(pusb_device
, 0x000E, (mute
| tmp
));
1170 /*---------------------------------------------------------------------------*/
1171 igot
= read_vt(pusb_device
, 0x0010);
1173 SAY("ERROR: failed to read VT1612A register 0x10\n");
1176 mute
= 0x8000 & ((unsigned int)igot
);
1179 JOT(8, "0x%04X=(mute|tmp|(tmp<<8)) for VT1612A register 0x10,...0x18\n",
1180 mute
| tmp
| (tmp
<< 8));
1181 write_vt(pusb_device
, 0x0010, (mute
| tmp
| (tmp
<< 8)));
1182 write_vt(pusb_device
, 0x0012, (mute
| tmp
| (tmp
<< 8)));
1183 write_vt(pusb_device
, 0x0014, (mute
| tmp
| (tmp
<< 8)));
1184 write_vt(pusb_device
, 0x0016, (mute
| tmp
| (tmp
<< 8)));
1185 write_vt(pusb_device
, 0x0018, (mute
| tmp
| (tmp
<< 8)));
1186 /*---------------------------------------------------------------------------*/
1187 igot
= read_vt(pusb_device
, 0x001C);
1189 SAY("ERROR: failed to read VT1612A register 0x1C\n");
1192 mute
= 0x8000 & ((unsigned int)igot
);
1196 tmp
= 0x000F & (u8
)(loud
- 16);
1200 JOT(8, "0x%04X=(mute|tmp|(tmp<<8)) for VT1612A register 0x1C\n",
1201 mute
| tmp
| (tmp
<< 8));
1202 write_vt(pusb_device
, 0x001C, (mute
| tmp
| (tmp
<< 8)));
1203 write_vt(pusb_device
, 0x001A, 0x0404);
1204 write_vt(pusb_device
, 0x0002, 0x0000);
1207 /*****************************************************************************/
1208 int audio_gainget(struct usb_device
*pusb_device
)
1212 if (NULL
== pusb_device
)
1214 igot
= read_vt(pusb_device
, 0x001C);
1216 SAY("ERROR: failed to read VT1612A register 0x1C\n");
1219 /*****************************************************************************/