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 /****************************************************************************/
330 confirm_resolution(struct usb_device *p)
332 u8 get0, get1, get2, get3, get4, get5, get6, get7;
336 GET(p, 0x0110, &get0);
337 GET(p, 0x0111, &get1);
338 GET(p, 0x0112, &get2);
339 GET(p, 0x0113, &get3);
340 GET(p, 0x0114, &get4);
341 GET(p, 0x0115, &get5);
342 GET(p, 0x0116, &get6);
343 GET(p, 0x0117, &get7);
344 JOT(8, "0x%03X, 0x%03X, "
348 get0, get1, get2, get3, get4, get5, get6, get7);
349 JOT(8, "....cf PAL_720x526: "
354 0x000, 0x000, 0x001, 0x000, 0x5A0, 0x005, 0x121, 0x001);
355 JOT(8, "....cf PAL_704x526: "
360 0x004, 0x000, 0x001, 0x000, 0x584, 0x005, 0x121, 0x001);
361 JOT(8, "....cf VGA_640x480: "
366 0x008, 0x000, 0x020, 0x000, 0x508, 0x005, 0x110, 0x001);
369 /****************************************************************************/
371 confirm_stream(struct usb_device *p)
378 GET(p, 0x0100, &igot); get2 = 0x80 & igot;
380 JOT(8, "confirm_stream: OK\n");
382 JOT(8, "confirm_stream: STUCK\n");
385 /****************************************************************************/
387 setup_stk(struct usb_device *p, bool ntsc)
395 while (0xFFF != stk1160configNTSC[i0].reg) {
396 SET(p, stk1160configNTSC[i0].reg, stk1160configNTSC[i0].set);
400 while (0xFFF != stk1160configPAL[i0].reg) {
401 SET(p, stk1160configPAL[i0].reg, stk1160configPAL[i0].set);
410 /****************************************************************************/
412 setup_saa(struct usb_device *p, bool ntsc)
420 while (0xFF != saa7113configNTSC[i0].reg) {
421 ir = write_saa(p, saa7113configNTSC[i0].reg,
422 saa7113configNTSC[i0].set);
426 while (0xFF != saa7113configPAL[i0].reg) {
427 ir = write_saa(p, saa7113configPAL[i0].reg,
428 saa7113configPAL[i0].set);
434 /****************************************************************************/
436 write_000(struct usb_device *p, u16 set2, u16 set0)
442 GET(p, 0x0002, &igot2);
443 GET(p, 0x0000, &igot0);
444 SET(p, 0x0002, set2);
445 SET(p, 0x0000, set0);
448 /****************************************************************************/
450 write_saa(struct usb_device *p, u16 reg0, u16 set0)
460 /****************************************************************************/
461 /*--------------------------------------------------------------------------*/
463 * REGISTER 500: SETTING VALUE TO 0x008B READS FROM VT1612A (?)
464 * REGISTER 500: SETTING VALUE TO 0x008C WRITES TO VT1612A
465 * REGISTER 502: LEAST SIGNIFICANT BYTE OF VALUE TO SET
466 * REGISTER 503: MOST SIGNIFICANT BYTE OF VALUE TO SET
467 * REGISTER 504: TARGET ADDRESS ON VT1612A
469 /*--------------------------------------------------------------------------*/
471 write_vt(struct usb_device *p, u16 reg0, u16 set0)
479 SET(p, 0x0504, reg0);
480 SET(p, 0x0500, 0x008B);
482 GET(p, 0x0502, &igot); got502 = (0xFF & igot);
483 GET(p, 0x0503, &igot); got503 = (0xFF & igot);
485 JOT(16, "write_vt(., 0x%04X, 0x%04X): was 0x%04X\n",
486 reg0, set0, ((got503 << 8) | got502));
488 set502 = (0x00FF & set0);
489 set503 = ((0xFF00 & set0) >> 8);
491 SET(p, 0x0504, reg0);
492 SET(p, 0x0502, set502);
493 SET(p, 0x0503, set503);
494 SET(p, 0x0500, 0x008C);
498 /****************************************************************************/
499 /*--------------------------------------------------------------------------*/
501 * REGISTER 500: SETTING VALUE TO 0x008B READS FROM VT1612A (?)
502 * REGISTER 500: SETTING VALUE TO 0x008C WRITES TO VT1612A
503 * REGISTER 502: LEAST SIGNIFICANT BYTE OF VALUE TO GET
504 * REGISTER 503: MOST SIGNIFICANT BYTE OF VALUE TO GET
505 * REGISTER 504: TARGET ADDRESS ON VT1612A
507 /*--------------------------------------------------------------------------*/
509 read_vt(struct usb_device *p, u16 reg0)
516 SET(p, 0x0504, reg0);
517 SET(p, 0x0500, 0x008B);
519 GET(p, 0x0502, &igot); got502 = (0xFF & igot);
520 GET(p, 0x0503, &igot); got503 = (0xFF & igot);
522 JOT(16, "read_vt(., 0x%04X): has 0x%04X\n", reg0, ((got503 << 8) | got502));
524 return (got503 << 8) | got502;
526 /****************************************************************************/
527 /*--------------------------------------------------------------------------*/
529 * THESE APPEAR TO HAVE NO EFFECT ON EITHER VIDEO OR AUDIO.
531 /*--------------------------------------------------------------------------*/
533 write_300(struct usb_device *p)
537 SET(p, 0x300, 0x0012);
538 SET(p, 0x350, 0x002D);
539 SET(p, 0x351, 0x0001);
540 SET(p, 0x352, 0x0000);
541 SET(p, 0x353, 0x0000);
542 SET(p, 0x300, 0x0080);
545 /****************************************************************************/
546 /*--------------------------------------------------------------------------*/
548 * NOTE: THE FOLLOWING IS NOT CHECKED:
549 * REGISTER 0x0F, WHICH IS INVOLVED IN CHROMINANCE AUTOMATIC GAIN CONTROL.
551 /*--------------------------------------------------------------------------*/
553 check_saa(struct usb_device *p, bool ntsc)
562 while (0xFF != saa7113configNTSC[i0].reg) {
563 if (0x0F == saa7113configNTSC[i0].reg) {
568 ir = read_saa(p, saa7113configNTSC[i0].reg);
569 if (ir != saa7113configNTSC[i0].set) {
570 SAY("SAA register 0x%02X has 0x%02X, "
572 saa7113configNTSC[i0].reg,
573 ir, saa7113configNTSC[i0].set);
579 while (0xFF != saa7113configPAL[i0].reg) {
580 if (0x0F == saa7113configPAL[i0].reg) {
585 ir = read_saa(p, saa7113configPAL[i0].reg);
586 if (ir != saa7113configPAL[i0].set) {
587 SAY("SAA register 0x%02X has 0x%02X, "
589 saa7113configPAL[i0].reg,
590 ir, saa7113configPAL[i0].set);
601 /****************************************************************************/
603 merit_saa(struct usb_device *p)
609 rc = read_saa(p, 0x1F);
610 if ((0 > rc) || (0x02 & rc))
615 /****************************************************************************/
617 ready_saa(struct usb_device *p)
620 const int max = 5, marktime = PATIENCE/5;
621 /*--------------------------------------------------------------------------*/
623 * RETURNS 0 FOR INTERLACED 50 Hz
624 * 1 FOR NON-INTERLACED 50 Hz
625 * 2 FOR INTERLACED 60 Hz
626 * 3 FOR NON-INTERLACED 60 Hz
628 /*--------------------------------------------------------------------------*/
633 rc = read_saa(p, 0x1F);
635 if (0 == (0x40 & rc))
637 if (1 == (0x01 & rc))
648 JOT(8, "hardware detects 60 Hz\n");
651 JOT(8, "hardware detects 50 Hz\n");
654 JOT(8, "hardware detects interlacing\n");
657 JOT(8, "hardware detects no interlacing\n");
662 /****************************************************************************/
663 /*--------------------------------------------------------------------------*/
665 * NOTE: THE FOLLOWING ARE NOT CHECKED:
666 * REGISTERS 0x000, 0x002: FUNCTIONALITY IS NOT KNOWN
667 * REGISTER 0x100: ACCEPT ALSO (0x80 | stk1160config....[.].set)
669 /*--------------------------------------------------------------------------*/
671 check_stk(struct usb_device *p, bool ntsc)
679 while (0xFFF != stk1160configNTSC[i0].reg) {
680 if (0x000 == stk1160configNTSC[i0].reg) {
683 if (0x002 == stk1160configNTSC[i0].reg) {
686 ir = read_stk(p, stk1160configNTSC[i0].reg);
687 if (0x100 == stk1160configNTSC[i0].reg) {
688 if ((ir != (0xFF & stk1160configNTSC[i0].set)) &&
689 (ir != (0x80 | (0xFF &
690 stk1160configNTSC[i0].set))) &&
692 stk1160configNTSC[i0].set)) {
693 SAY("STK register 0x%03X has 0x%02X, "
695 stk1160configNTSC[i0].reg,
696 ir, stk1160configNTSC[i0].set);
700 if ((ir != (0xFF & stk1160configNTSC[i0].set)) &&
701 (0xFFFF != stk1160configNTSC[i0].set)) {
702 SAY("STK register 0x%03X has 0x%02X, "
704 stk1160configNTSC[i0].reg,
705 ir, stk1160configNTSC[i0].set);
710 while (0xFFF != stk1160configPAL[i0].reg) {
711 if (0x000 == stk1160configPAL[i0].reg) {
714 if (0x002 == stk1160configPAL[i0].reg) {
717 ir = read_stk(p, stk1160configPAL[i0].reg);
718 if (0x100 == stk1160configPAL[i0].reg) {
719 if ((ir != (0xFF & stk1160configPAL[i0].set)) &&
720 (ir != (0x80 | (0xFF &
721 stk1160configPAL[i0].set))) &&
723 stk1160configPAL[i0].set)) {
724 SAY("STK register 0x%03X has 0x%02X, "
726 stk1160configPAL[i0].reg,
727 ir, stk1160configPAL[i0].set);
731 if ((ir != (0xFF & stk1160configPAL[i0].set)) &&
732 (0xFFFF != stk1160configPAL[i0].set)) {
733 SAY("STK register 0x%03X has 0x%02X, "
735 stk1160configPAL[i0].reg,
736 ir, stk1160configPAL[i0].set);
743 /****************************************************************************/
745 read_saa(struct usb_device *p, u16 reg0)
753 if (0 != wait_i2c(p))
756 GET(p, 0x0209, &igot);
759 /****************************************************************************/
761 read_stk(struct usb_device *p, u32 reg0)
771 /****************************************************************************/
772 /*--------------------------------------------------------------------------*/
774 * HARDWARE USERSPACE INPUT NUMBER PHYSICAL INPUT DRIVER input VALUE
776 * CVBS+S-VIDEO 0 or 1 CVBS 1
777 * FOUR-CVBS 0 or 1 CVBS1 1
778 * FOUR-CVBS 2 CVBS2 2
779 * FOUR-CVBS 3 CVBS3 3
780 * FOUR-CVBS 4 CVBS4 4
781 * CVBS+S-VIDEO 5 S-VIDEO 5
783 * WHEN 5==input THE ARGUMENT mode MUST ALSO BE SUPPLIED:
785 * mode 7 => GAIN TO BE SET EXPLICITLY USING REGISTER 0x05 (UNTESTED)
786 * mode 9 => USE AUTOMATIC GAIN CONTROL (DEFAULT)
789 /*---------------------------------------------------------------------------*/
791 select_input(struct usb_device *p, int input, int mode)
801 if (0 != write_saa(p, 0x02, 0x80)) {
802 SAY("ERROR: failed to set SAA register 0x02 for input %i\n",
805 SET(p, 0x0000, 0x0098);
806 SET(p, 0x0002, 0x0078);
810 if (0 != write_saa(p, 0x02, 0x80)) {
811 SAY("ERROR: failed to set SAA register 0x02 for input %i\n",
814 SET(p, 0x0000, 0x0090);
815 SET(p, 0x0002, 0x0078);
819 if (0 != write_saa(p, 0x02, 0x80)) {
820 SAY("ERROR: failed to set SAA register 0x02 for input %i\n",
823 SET(p, 0x0000, 0x0088);
824 SET(p, 0x0002, 0x0078);
828 if (0 != write_saa(p, 0x02, 0x80)) {
829 SAY("ERROR: failed to set SAA register 0x02 for input %i\n",
832 SET(p, 0x0000, 0x0080);
833 SET(p, 0x0002, 0x0078);
841 if (0 != write_saa(p, 0x02, 0x87)) {
842 SAY("ERROR: failed to set SAA register 0x02 "
843 "for input %i\n", input);
845 if (0 != write_saa(p, 0x05, 0xFF)) {
846 SAY("ERROR: failed to set SAA register 0x05 "
847 "for input %i\n", input);
852 if (0 != write_saa(p, 0x02, 0x89)) {
853 SAY("ERROR: failed to set SAA register 0x02 "
854 "for input %i\n", input);
856 if (0 != write_saa(p, 0x05, 0x00)) {
857 SAY("ERROR: failed to set SAA register 0x05 "
858 "for input %i\n", input);
863 SAY("MISTAKE: bad mode: %i\n", mode);
867 if (0 != write_saa(p, 0x04, 0x00)) {
868 SAY("ERROR: failed to set SAA register 0x04 for input %i\n",
871 if (0 != write_saa(p, 0x09, 0x80)) {
872 SAY("ERROR: failed to set SAA register 0x09 for input %i\n",
875 SET(p, 0x0002, 0x0093);
879 SAY("ERROR: bad input: %i\n", input);
883 ir = read_stk(p, 0x00);
884 JOT(8, "STK register 0x00 has 0x%02X\n", ir);
885 ir = read_saa(p, 0x02);
886 JOT(8, "SAA register 0x02 has 0x%02X\n", ir);
892 /****************************************************************************/
894 set_resolution(struct usb_device *p,
895 u16 set0, u16 set1, u16 set2, u16 set3)
897 u16 u0x0111, u0x0113, u0x0115, u0x0117;
901 u0x0111 = ((0xFF00 & set0) >> 8);
902 u0x0113 = ((0xFF00 & set1) >> 8);
903 u0x0115 = ((0xFF00 & set2) >> 8);
904 u0x0117 = ((0xFF00 & set3) >> 8);
906 SET(p, 0x0110, (0x00FF & set0));
907 SET(p, 0x0111, u0x0111);
908 SET(p, 0x0112, (0x00FF & set1));
909 SET(p, 0x0113, u0x0113);
910 SET(p, 0x0114, (0x00FF & set2));
911 SET(p, 0x0115, u0x0115);
912 SET(p, 0x0116, (0x00FF & set3));
913 SET(p, 0x0117, u0x0117);
917 /****************************************************************************/
919 start_100(struct usb_device *p)
921 u16 get116, get117, get0;
922 u8 igot116, igot117, igot;
926 GET(p, 0x0116, &igot116);
928 GET(p, 0x0117, &igot117);
930 SET(p, 0x0116, 0x0000);
931 SET(p, 0x0117, 0x0000);
933 GET(p, 0x0100, &igot);
935 SET(p, 0x0100, (0x80 | get0));
937 SET(p, 0x0116, get116);
938 SET(p, 0x0117, get117);
942 /****************************************************************************/
944 stop_100(struct usb_device *p)
951 GET(p, 0x0100, &igot);
953 SET(p, 0x0100, (0x7F & get0));
956 /****************************************************************************/
957 /*--------------------------------------------------------------------------*/
959 * FUNCTION wait_i2c() RETURNS 0 ON SUCCESS
961 /*--------------------------------------------------------------------------*/
963 wait_i2c(struct usb_device *p)
972 for (k = 0; k < max; k++) {
973 GET(p, 0x0201, &igot); get0 = igot;
990 /****************************************************************************/
991 /*****************************************************************************/
993 wakeup_device(struct usb_device *pusb_device)
997 return usb_control_msg(pusb_device, usb_sndctrlpipe(pusb_device, 0),
998 (u8)USB_REQ_SET_FEATURE,
999 (u8)(USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE),
1000 USB_DEVICE_REMOTE_WAKEUP,
1006 /*****************************************************************************/
1008 audio_setup(struct easycap *peasycap)
1010 struct usb_device *pusb_device;
1011 unsigned char buffer[1];
1013 /*---------------------------------------------------------------------------*/
1016 * THE MESSAGE OF TYPE (USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE)
1017 * CAUSES MUTING IF THE VALUE 0x0100 IS SENT.
1018 * TO ENABLE AUDIO THE VALUE 0x0200 MUST BE SENT.
1020 /*---------------------------------------------------------------------------*/
1021 const u8 request = 0x01;
1022 const u8 requesttype =
1023 (u8)(USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE);
1024 const u16 value_unmute = 0x0200;
1025 const u16 index = 0x0301;
1026 const u16 length = 1;
1028 if (NULL == peasycap)
1031 pusb_device = peasycap->pusb_device;
1032 if (NULL == pusb_device)
1035 JOM(8, "%02X %02X %02X %02X %02X %02X %02X %02X\n",
1036 requesttype, request,
1037 (0x00FF & value_unmute),
1038 (0xFF00 & value_unmute) >> 8,
1040 (0xFF00 & index) >> 8,
1042 (0xFF00 & length) >> 8);
1046 rc = usb_control_msg(pusb_device, usb_sndctrlpipe(pusb_device, 0),
1055 JOT(8, "0x%02X=buffer\n", *((u8 *) &buffer[0]));
1056 if (rc != (int)length) {
1059 SAY("usb_control_msg returned -EPIPE\n");
1063 SAY("ERROR: usb_control_msg returned %i\n", rc);
1068 /*--------------------------------------------------------------------------*/
1070 * REGISTER 500: SETTING VALUE TO 0x0094 RESETS AUDIO CONFIGURATION ???
1071 * REGISTER 506: ANALOGUE AUDIO ATTENTUATOR ???
1072 * FOR THE CVBS+S-VIDEO HARDWARE:
1073 * SETTING VALUE TO 0x0000 GIVES QUIET SOUND.
1074 * THE UPPER BYTE SEEMS TO HAVE NO EFFECT.
1075 * FOR THE FOUR-CVBS HARDWARE:
1076 * SETTING VALUE TO 0x0000 SEEMS TO HAVE NO EFFECT.
1077 * REGISTER 507: ANALOGUE AUDIO PREAMPLIFIER ON/OFF ???
1078 * FOR THE CVBS-S-VIDEO HARDWARE:
1079 * SETTING VALUE TO 0x0001 GIVES VERY LOUD, DISTORTED SOUND.
1080 * THE UPPER BYTE SEEMS TO HAVE NO EFFECT.
1082 /*--------------------------------------------------------------------------*/
1083 SET(pusb_device, 0x0500, 0x0094);
1084 SET(pusb_device, 0x0500, 0x008C);
1085 SET(pusb_device, 0x0506, 0x0001);
1086 SET(pusb_device, 0x0507, 0x0000);
1087 id1 = read_vt(pusb_device, 0x007C);
1088 id2 = read_vt(pusb_device, 0x007E);
1089 SAM("0x%04X:0x%04X is audio vendor id\n", id1, id2);
1090 /*---------------------------------------------------------------------------*/
1092 * SELECT AUDIO SOURCE "LINE IN" AND SET THE AUDIO GAIN.
1094 /*---------------------------------------------------------------------------*/
1095 if (0 != audio_gainset(pusb_device, peasycap->gain))
1096 SAY("ERROR: audio_gainset() failed\n");
1097 check_vt(pusb_device);
1100 /*****************************************************************************/
1102 check_vt(struct usb_device *pusb_device)
1108 igot = read_vt(pusb_device, 0x0002);
1110 SAY("ERROR: failed to read VT1612A register 0x02\n");
1112 SAY("register 0x%02X muted\n", 0x02);
1114 igot = read_vt(pusb_device, 0x000E);
1116 SAY("ERROR: failed to read VT1612A register 0x0E\n");
1118 SAY("register 0x%02X muted\n", 0x0E);
1120 igot = read_vt(pusb_device, 0x0010);
1122 SAY("ERROR: failed to read VT1612A register 0x10\n");
1124 SAY("register 0x%02X muted\n", 0x10);
1126 igot = read_vt(pusb_device, 0x0012);
1128 SAY("ERROR: failed to read VT1612A register 0x12\n");
1130 SAY("register 0x%02X muted\n", 0x12);
1132 igot = read_vt(pusb_device, 0x0014);
1134 SAY("ERROR: failed to read VT1612A register 0x14\n");
1136 SAY("register 0x%02X muted\n", 0x14);
1138 igot = read_vt(pusb_device, 0x0016);
1140 SAY("ERROR: failed to read VT1612A register 0x16\n");
1142 SAY("register 0x%02X muted\n", 0x16);
1144 igot = read_vt(pusb_device, 0x0018);
1146 SAY("ERROR: failed to read VT1612A register 0x18\n");
1148 SAY("register 0x%02X muted\n", 0x18);
1150 igot = read_vt(pusb_device, 0x001C);
1152 SAY("ERROR: failed to read VT1612A register 0x1C\n");
1154 SAY("register 0x%02X muted\n", 0x1C);
1158 /*****************************************************************************/
1159 /*---------------------------------------------------------------------------*/
1160 /* NOTE: THIS DOES INCREASE THE VOLUME DRAMATICALLY:
1161 * audio_gainset(pusb_device, 0x000F);
1163 * loud dB register 0x10 dB register 0x1C dB total
1172 /*---------------------------------------------------------------------------*/
1174 audio_gainset(struct usb_device *pusb_device, s8 loud)
1180 if (NULL == pusb_device)
1187 write_vt(pusb_device, 0x0002, 0x8000);
1188 /*---------------------------------------------------------------------------*/
1189 igot = read_vt(pusb_device, 0x000E);
1191 SAY("ERROR: failed to read VT1612A register 0x0E\n");
1194 mute = 0x8000 & ((unsigned int)igot);
1198 tmp = 0x01 | (0x001F & (((u8)(15 - loud)) << 1));
1202 JOT(8, "0x%04X=(mute|tmp) for VT1612A register 0x0E\n", mute | tmp);
1203 write_vt(pusb_device, 0x000E, (mute | tmp));
1204 /*---------------------------------------------------------------------------*/
1205 igot = read_vt(pusb_device, 0x0010);
1207 SAY("ERROR: failed to read VT1612A register 0x10\n");
1210 mute = 0x8000 & ((unsigned int)igot);
1213 JOT(8, "0x%04X=(mute|tmp|(tmp<<8)) for VT1612A register 0x10,...0x18\n",
1214 mute | tmp | (tmp << 8));
1215 write_vt(pusb_device, 0x0010, (mute | tmp | (tmp << 8)));
1216 write_vt(pusb_device, 0x0012, (mute | tmp | (tmp << 8)));
1217 write_vt(pusb_device, 0x0014, (mute | tmp | (tmp << 8)));
1218 write_vt(pusb_device, 0x0016, (mute | tmp | (tmp << 8)));
1219 write_vt(pusb_device, 0x0018, (mute | tmp | (tmp << 8)));
1220 /*---------------------------------------------------------------------------*/
1221 igot = read_vt(pusb_device, 0x001C);
1223 SAY("ERROR: failed to read VT1612A register 0x1C\n");
1226 mute = 0x8000 & ((unsigned int)igot);
1230 tmp = 0x000F & (u8)(loud - 16);
1234 JOT(8, "0x%04X=(mute|tmp|(tmp<<8)) for VT1612A register 0x1C\n",
1235 mute | tmp | (tmp << 8));
1236 write_vt(pusb_device, 0x001C, (mute | tmp | (tmp << 8)));
1237 write_vt(pusb_device, 0x001A, 0x0404);
1238 write_vt(pusb_device, 0x0002, 0x0000);
1241 /*****************************************************************************/
1243 audio_gainget(struct usb_device *pusb_device)
1247 if (NULL == pusb_device)
1249 igot = read_vt(pusb_device, 0x001C);
1251 SAY("ERROR: failed to read VT1612A register 0x1C\n");
1254 /*****************************************************************************/