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 /****************************************************************************/
41 #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;
251 GET(p, 0x0110, &get0);
252 GET(p, 0x0111, &get1);
253 GET(p, 0x0112, &get2);
254 GET(p, 0x0113, &get3);
255 GET(p, 0x0114, &get4);
256 GET(p, 0x0115, &get5);
257 GET(p, 0x0116, &get6);
258 GET(p, 0x0117, &get7);
259 JOT(8, "0x%03X, 0x%03X, " \
262 "0x%03X, 0x%03X\n", \
263 get0, get1, get2, get3, get4, get5, get6, get7);
264 JOT(8, "....cf PAL_720x526: " \
268 "0x%03X, 0x%03X\n", \
269 0x000, 0x000, 0x001, 0x000, 0x5A0, 0x005, 0x121, 0x001);
270 JOT(8, "....cf PAL_704x526: " \
274 "0x%03X, 0x%03X\n", \
275 0x004, 0x000, 0x001, 0x000, 0x584, 0x005, 0x121, 0x001);
276 JOT(8, "....cf VGA_640x480: " \
280 "0x%03X, 0x%03X\n", \
281 0x008, 0x000, 0x020, 0x000, 0x508, 0x005, 0x110, 0x001);
284 /****************************************************************************/
286 confirm_stream(struct usb_device *p)
291 GET(p, 0x0100, &igot); get2 = 0x80 & igot;
293 JOT(8, "confirm_stream: OK\n");
295 JOT(8, "confirm_stream: STUCK\n");
298 /****************************************************************************/
300 setup_stk(struct usb_device *p, bool ntsc)
306 while (0xFFF != stk1160configNTSC[i0].reg) {
307 SET(p, stk1160configNTSC[i0].reg, stk1160configNTSC[i0].set);
311 while (0xFFF != stk1160configPAL[i0].reg) {
312 SET(p, stk1160configPAL[i0].reg, stk1160configPAL[i0].set);
321 /****************************************************************************/
323 setup_saa(struct usb_device *p, bool ntsc)
329 while (0xFF != saa7113configNTSC[i0].reg) {
330 ir = write_saa(p, saa7113configNTSC[i0].reg, \
331 saa7113configNTSC[i0].set);
335 while (0xFF != saa7113configPAL[i0].reg) {
336 ir = write_saa(p, saa7113configPAL[i0].reg, \
337 saa7113configPAL[i0].set);
343 /****************************************************************************/
345 write_000(struct usb_device *p, __u16 set2, __u16 set0)
349 GET(p, 0x0002, &igot2);
350 GET(p, 0x0000, &igot0);
351 SET(p, 0x0002, set2);
352 SET(p, 0x0000, set0);
355 /****************************************************************************/
357 write_saa(struct usb_device *p, __u16 reg0, __u16 set0)
365 /****************************************************************************/
366 /*--------------------------------------------------------------------------*/
368 * REGISTER 500: SETTING VALUE TO 0x008B READS FROM VT1612A (?)
369 * REGISTER 500: SETTING VALUE TO 0x008C WRITES TO VT1612A
370 * REGISTER 502: LEAST SIGNIFICANT BYTE OF VALUE TO SET
371 * REGISTER 503: MOST SIGNIFICANT BYTE OF VALUE TO SET
372 * REGISTER 504: TARGET ADDRESS ON VT1612A
374 /*--------------------------------------------------------------------------*/
376 write_vt(struct usb_device *p, __u16 reg0, __u16 set0)
379 __u16 got502, got503;
380 __u16 set502, set503;
382 SET(p, 0x0504, reg0);
383 SET(p, 0x0500, 0x008B);
385 GET(p, 0x0502, &igot); got502 = (0xFF & igot);
386 GET(p, 0x0503, &igot); got503 = (0xFF & igot);
388 JOT(16, "write_vt(., 0x%04X, 0x%04X): was 0x%04X\n", \
389 reg0, set0, ((got503 << 8) | got502));
391 set502 = (0x00FF & set0);
392 set503 = ((0xFF00 & set0) >> 8);
394 SET(p, 0x0504, reg0);
395 SET(p, 0x0502, set502);
396 SET(p, 0x0503, set503);
397 SET(p, 0x0500, 0x008C);
401 /****************************************************************************/
402 /*--------------------------------------------------------------------------*/
404 * REGISTER 500: SETTING VALUE TO 0x008B READS FROM VT1612A (?)
405 * REGISTER 500: SETTING VALUE TO 0x008C WRITES TO VT1612A
406 * REGISTER 502: LEAST SIGNIFICANT BYTE OF VALUE TO GET
407 * REGISTER 503: MOST SIGNIFICANT BYTE OF VALUE TO GET
408 * REGISTER 504: TARGET ADDRESS ON VT1612A
410 /*--------------------------------------------------------------------------*/
412 read_vt(struct usb_device *p, __u16 reg0)
415 __u16 got502, got503;
417 SET(p, 0x0504, reg0);
418 SET(p, 0x0500, 0x008B);
420 GET(p, 0x0502, &igot); got502 = (0xFF & igot);
421 GET(p, 0x0503, &igot); got503 = (0xFF & igot);
423 JOT(16, "read_vt(., 0x%04X): has 0x%04X\n", reg0, ((got503 << 8) | got502));
425 return (got503 << 8) | got502;
427 /****************************************************************************/
428 /*--------------------------------------------------------------------------*/
430 * THESE APPEAR TO HAVE NO EFFECT ON EITHER VIDEO OR AUDIO.
432 /*--------------------------------------------------------------------------*/
434 write_300(struct usb_device *p)
436 SET(p, 0x300, 0x0012);
437 SET(p, 0x350, 0x002D);
438 SET(p, 0x351, 0x0001);
439 SET(p, 0x352, 0x0000);
440 SET(p, 0x353, 0x0000);
441 SET(p, 0x300, 0x0080);
444 /****************************************************************************/
445 /*--------------------------------------------------------------------------*/
447 * NOTE: THE FOLLOWING IS NOT CHECKED:
448 * REGISTER 0x0F, WHICH IS INVOLVED IN CHROMINANCE AUTOMATIC GAIN CONTROL.
450 /*--------------------------------------------------------------------------*/
452 check_saa(struct usb_device *p, bool ntsc)
459 while (0xFF != saa7113configNTSC[i0].reg) {
460 if (0x0F == saa7113configNTSC[i0].reg) {
465 ir = read_saa(p, saa7113configNTSC[i0].reg);
466 if (ir != saa7113configNTSC[i0].set) {
467 SAY("SAA register 0x%02X has 0x%02X, " \
468 "expected 0x%02X\n", \
469 saa7113configNTSC[i0].reg, \
470 ir, saa7113configNTSC[i0].set);
476 while (0xFF != saa7113configPAL[i0].reg) {
477 if (0x0F == saa7113configPAL[i0].reg) {
482 ir = read_saa(p, saa7113configPAL[i0].reg);
483 if (ir != saa7113configPAL[i0].set) {
484 SAY("SAA register 0x%02X has 0x%02X, " \
485 "expected 0x%02X\n", \
486 saa7113configPAL[i0].reg, \
487 ir, saa7113configPAL[i0].set);
498 /****************************************************************************/
500 merit_saa(struct usb_device *p)
504 rc = read_saa(p, 0x1F);
505 if ((0 > rc) || (0x02 & rc))
510 /****************************************************************************/
512 ready_saa(struct usb_device *p)
515 const int max = 5, marktime = PATIENCE/5;
516 /*--------------------------------------------------------------------------*/
518 * RETURNS 0 FOR INTERLACED 50 Hz
519 * 1 FOR NON-INTERLACED 50 Hz
520 * 2 FOR INTERLACED 60 Hz
521 * 3 FOR NON-INTERLACED 60 Hz
523 /*--------------------------------------------------------------------------*/
526 rc = read_saa(p, 0x1F);
528 if (0 == (0x40 & rc))
530 if (1 == (0x01 & rc))
541 JOT(8, "hardware detects 60 Hz\n");
544 JOT(8, "hardware detects 50 Hz\n");
547 JOT(8, "hardware detects interlacing\n");
550 JOT(8, "hardware detects no interlacing\n");
555 /****************************************************************************/
556 /*--------------------------------------------------------------------------*/
558 * NOTE: THE FOLLOWING ARE NOT CHECKED:
559 * REGISTERS 0x000, 0x002: FUNCTIONALITY IS NOT KNOWN
560 * REGISTER 0x100: ACCEPT ALSO (0x80 | stk1160config....[.].set)
562 /*--------------------------------------------------------------------------*/
564 check_stk(struct usb_device *p, bool ntsc)
570 while (0xFFF != stk1160configNTSC[i0].reg) {
571 if (0x000 == stk1160configNTSC[i0].reg) {
574 if (0x002 == stk1160configNTSC[i0].reg) {
577 ir = read_stk(p, stk1160configNTSC[i0].reg);
578 if (0x100 == stk1160configNTSC[i0].reg) {
579 if ((ir != (0xFF & stk1160configNTSC[i0].set)) && \
580 (ir != (0x80 | (0xFF & \
581 stk1160configNTSC[i0].set))) && \
583 stk1160configNTSC[i0].set)) {
584 SAY("STK register 0x%03X has 0x%02X, " \
585 "expected 0x%02X\n", \
586 stk1160configNTSC[i0].reg, \
587 ir, stk1160configNTSC[i0].set);
591 if ((ir != (0xFF & stk1160configNTSC[i0].set)) && \
592 (0xFFFF != stk1160configNTSC[i0].set)) {
593 SAY("STK register 0x%03X has 0x%02X, " \
594 "expected 0x%02X\n", \
595 stk1160configNTSC[i0].reg, \
596 ir, stk1160configNTSC[i0].set);
601 while (0xFFF != stk1160configPAL[i0].reg) {
602 if (0x000 == stk1160configPAL[i0].reg) {
605 if (0x002 == stk1160configPAL[i0].reg) {
608 ir = read_stk(p, stk1160configPAL[i0].reg);
609 if (0x100 == stk1160configPAL[i0].reg) {
610 if ((ir != (0xFF & stk1160configPAL[i0].set)) && \
611 (ir != (0x80 | (0xFF & \
612 stk1160configPAL[i0].set))) && \
614 stk1160configPAL[i0].set)) {
615 SAY("STK register 0x%03X has 0x%02X, " \
616 "expected 0x%02X\n", \
617 stk1160configPAL[i0].reg, \
618 ir, stk1160configPAL[i0].set);
622 if ((ir != (0xFF & stk1160configPAL[i0].set)) && \
623 (0xFFFF != stk1160configPAL[i0].set)) {
624 SAY("STK register 0x%03X has 0x%02X, " \
625 "expected 0x%02X\n", \
626 stk1160configPAL[i0].reg, \
627 ir, stk1160configPAL[i0].set);
634 /****************************************************************************/
636 read_saa(struct usb_device *p, __u16 reg0)
642 if (0 != wait_i2c(p))
645 GET(p, 0x0209, &igot);
648 /****************************************************************************/
650 read_stk(struct usb_device *p, __u32 reg0)
658 /****************************************************************************/
659 /*--------------------------------------------------------------------------*/
661 * HARDWARE USERSPACE INPUT NUMBER PHYSICAL INPUT DRIVER input VALUE
663 * CVBS+S-VIDEO 0 or 1 CVBS 1
664 * FOUR-CVBS 0 or 1 CVBS1 1
665 * FOUR-CVBS 2 CVBS2 2
666 * FOUR-CVBS 3 CVBS3 3
667 * FOUR-CVBS 4 CVBS4 4
668 * CVBS+S-VIDEO 5 S-VIDEO 5
670 * WHEN 5==input THE ARGUMENT mode MUST ALSO BE SUPPLIED:
672 * mode 7 => GAIN TO BE SET EXPLICITLY USING REGISTER 0x05 (UNTESTED)
673 * mode 9 => USE AUTOMATIC GAIN CONTROL (DEFAULT)
676 /*---------------------------------------------------------------------------*/
678 select_input(struct usb_device *p, int input, int mode)
686 if (0 != write_saa(p, 0x02, 0x80)) {
687 SAY("ERROR: failed to set SAA register 0x02 for input %i\n", \
690 SET(p, 0x0000, 0x0098);
691 SET(p, 0x0002, 0x0078);
695 if (0 != write_saa(p, 0x02, 0x80)) {
696 SAY("ERROR: failed to set SAA register 0x02 for input %i\n", \
699 SET(p, 0x0000, 0x0090);
700 SET(p, 0x0002, 0x0078);
704 if (0 != write_saa(p, 0x02, 0x80)) {
705 SAY("ERROR: failed to set SAA register 0x02 for input %i\n", \
708 SET(p, 0x0000, 0x0088);
709 SET(p, 0x0002, 0x0078);
713 if (0 != write_saa(p, 0x02, 0x80)) {
714 SAY("ERROR: failed to set SAA register 0x02 for input %i\n", \
717 SET(p, 0x0000, 0x0080);
718 SET(p, 0x0002, 0x0078);
726 if (0 != write_saa(p, 0x02, 0x87)) {
727 SAY("ERROR: failed to set SAA register 0x02 " \
728 "for input %i\n", input);
730 if (0 != write_saa(p, 0x05, 0xFF)) {
731 SAY("ERROR: failed to set SAA register 0x05 " \
732 "for input %i\n", input);
737 if (0 != write_saa(p, 0x02, 0x89)) {
738 SAY("ERROR: failed to set SAA register 0x02 " \
739 "for input %i\n", input);
741 if (0 != write_saa(p, 0x05, 0x00)) {
742 SAY("ERROR: failed to set SAA register 0x05 " \
743 "for input %i\n", input);
748 SAY("MISTAKE: bad mode: %i\n", mode);
752 if (0 != write_saa(p, 0x04, 0x00)) {
753 SAY("ERROR: failed to set SAA register 0x04 for input %i\n", \
756 if (0 != write_saa(p, 0x09, 0x80)) {
757 SAY("ERROR: failed to set SAA register 0x09 for input %i\n", \
760 SET(p, 0x0002, 0x0093);
764 SAY("ERROR: bad input: %i\n", input);
768 ir = read_stk(p, 0x00);
769 JOT(8, "STK register 0x00 has 0x%02X\n", ir);
770 ir = read_saa(p, 0x02);
771 JOT(8, "SAA register 0x02 has 0x%02X\n", ir);
777 /****************************************************************************/
779 set_resolution(struct usb_device *p, \
780 __u16 set0, __u16 set1, __u16 set2, __u16 set3)
782 __u16 u0x0111, u0x0113, u0x0115, u0x0117;
784 u0x0111 = ((0xFF00 & set0) >> 8);
785 u0x0113 = ((0xFF00 & set1) >> 8);
786 u0x0115 = ((0xFF00 & set2) >> 8);
787 u0x0117 = ((0xFF00 & set3) >> 8);
789 SET(p, 0x0110, (0x00FF & set0));
790 SET(p, 0x0111, u0x0111);
791 SET(p, 0x0112, (0x00FF & set1));
792 SET(p, 0x0113, u0x0113);
793 SET(p, 0x0114, (0x00FF & set2));
794 SET(p, 0x0115, u0x0115);
795 SET(p, 0x0116, (0x00FF & set3));
796 SET(p, 0x0117, u0x0117);
800 /****************************************************************************/
802 start_100(struct usb_device *p)
804 __u16 get116, get117, get0;
805 __u8 igot116, igot117, igot;
807 GET(p, 0x0116, &igot116);
809 GET(p, 0x0117, &igot117);
811 SET(p, 0x0116, 0x0000);
812 SET(p, 0x0117, 0x0000);
814 GET(p, 0x0100, &igot);
816 SET(p, 0x0100, (0x80 | get0));
818 SET(p, 0x0116, get116);
819 SET(p, 0x0117, get117);
823 /****************************************************************************/
825 stop_100(struct usb_device *p)
830 GET(p, 0x0100, &igot);
832 SET(p, 0x0100, (0x7F & get0));
835 /****************************************************************************/
836 /*--------------------------------------------------------------------------*/
838 * FUNCTION wait_i2c() RETURNS 0 ON SUCCESS
840 /*--------------------------------------------------------------------------*/
842 wait_i2c(struct usb_device *p)
849 for (k = 0; k < max; k++) {
850 GET(p, 0x0201, &igot); get0 = igot;
867 /****************************************************************************/
869 regset(struct usb_device *pusb_device, __u16 index, __u16 value)
878 rc0 = usb_control_msg(pusb_device, usb_sndctrlpipe(pusb_device, 0), \
880 (__u8)(USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE), \
887 #if defined(NOREADBACK)
890 rc1 = usb_control_msg(pusb_device, usb_rcvctrlpipe(pusb_device, 0), \
892 (__u8)(USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE), \
896 (__u16)sizeof(__u16), \
913 if (0 != (0xFF & igot)) {
914 JOT(8, "unexpected 0x%02X for STK register 0x%03X\n", \
920 if ((0xFF & value) != (0xFF & igot)) {
921 JOT(8, "unexpected 0x%02X != 0x%02X " \
922 "for STK register 0x%03X\n", \
928 #endif /* ! NOREADBACK*/
930 return (0 > rc0) ? rc0 : rc1;
932 /*****************************************************************************/
934 regget(struct usb_device *pusb_device, __u16 index, void *pvoid)
941 ir = usb_control_msg(pusb_device, usb_rcvctrlpipe(pusb_device, 0), \
943 (__u8)(USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE), \
951 /*****************************************************************************/
953 wakeup_device(struct usb_device *pusb_device)
955 return usb_control_msg(pusb_device, usb_sndctrlpipe(pusb_device, 0), \
956 (__u8)USB_REQ_SET_FEATURE, \
957 (__u8)(USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE), \
958 USB_DEVICE_REMOTE_WAKEUP, \
964 /*****************************************************************************/
966 audio_setup(struct easycap *peasycap)
968 struct usb_device *pusb_device;
969 unsigned char buffer[1];
971 /*---------------------------------------------------------------------------*/
974 * THE MESSAGE OF TYPE (USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE)
975 * CAUSES MUTING IF THE VALUE 0x0100 IS SENT.
976 * TO ENABLE AUDIO THE VALUE 0x0200 MUST BE SENT.
978 /*---------------------------------------------------------------------------*/
979 const __u8 request = 0x01;
980 const __u8 requesttype = \
981 (__u8)(USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE);
982 const __u16 value_unmute = 0x0200;
983 const __u16 index = 0x0301;
984 const __u16 length = 1;
986 if (NULL == peasycap)
989 pusb_device = peasycap->pusb_device;
990 if (NULL == pusb_device)
993 JOM(8, "%02X %02X %02X %02X %02X %02X %02X %02X\n", \
994 requesttype, request, \
995 (0x00FF & value_unmute), \
996 (0xFF00 & value_unmute) >> 8, \
998 (0xFF00 & index) >> 8, \
1000 (0xFF00 & length) >> 8);
1004 rc = usb_control_msg(pusb_device, usb_sndctrlpipe(pusb_device, 0), \
1006 (__u8)requesttype, \
1007 (__u16)value_unmute, \
1009 (void *)&buffer[0], \
1013 JOT(8, "0x%02X=buffer\n", *((__u8 *) &buffer[0]));
1014 if (rc != (int)length)
1015 SAY("ERROR: usb_control_msg returned %i\n", rc);
1017 /*--------------------------------------------------------------------------*/
1019 * REGISTER 500: SETTING VALUE TO 0x0094 RESETS AUDIO CONFIGURATION ???
1020 * REGISTER 506: ANALOGUE AUDIO ATTENTUATOR ???
1021 * FOR THE CVBS+S-VIDEO HARDWARE:
1022 * SETTING VALUE TO 0x0000 GIVES QUIET SOUND.
1023 * THE UPPER BYTE SEEMS TO HAVE NO EFFECT.
1024 * FOR THE FOUR-CVBS HARDWARE:
1025 * SETTING VALUE TO 0x0000 SEEMS TO HAVE NO EFFECT.
1026 * REGISTER 507: ANALOGUE AUDIO PREAMPLIFIER ON/OFF ???
1027 * FOR THE CVBS-S-VIDEO HARDWARE:
1028 * SETTING VALUE TO 0x0001 GIVES VERY LOUD, DISTORTED SOUND.
1029 * THE UPPER BYTE SEEMS TO HAVE NO EFFECT.
1031 /*--------------------------------------------------------------------------*/
1032 SET(pusb_device, 0x0500, 0x0094);
1033 SET(pusb_device, 0x0500, 0x008C);
1034 SET(pusb_device, 0x0506, 0x0001);
1035 SET(pusb_device, 0x0507, 0x0000);
1036 id1 = read_vt(pusb_device, 0x007C);
1037 id2 = read_vt(pusb_device, 0x007E);
1038 SAM("0x%04X:0x%04X is audio vendor id\n", id1, id2);
1039 /*---------------------------------------------------------------------------*/
1041 * SELECT AUDIO SOURCE "LINE IN" AND SET THE AUDIO GAIN.
1043 /*---------------------------------------------------------------------------*/
1048 if (0 != audio_gainset(pusb_device, (__s8)gain))
1049 SAY("ERROR: audio_gainset() failed\n");
1050 check_vt(pusb_device);
1053 /*****************************************************************************/
1055 check_vt(struct usb_device *pusb_device)
1059 igot = read_vt(pusb_device, 0x0002);
1061 SAY("ERROR: failed to read VT1612A register 0x02\n");
1063 SAY("register 0x%02X muted\n", 0x02);
1065 igot = read_vt(pusb_device, 0x000E);
1067 SAY("ERROR: failed to read VT1612A register 0x0E\n");
1069 SAY("register 0x%02X muted\n", 0x0E);
1071 igot = read_vt(pusb_device, 0x0010);
1073 SAY("ERROR: failed to read VT1612A register 0x10\n");
1075 SAY("register 0x%02X muted\n", 0x10);
1077 igot = read_vt(pusb_device, 0x0012);
1079 SAY("ERROR: failed to read VT1612A register 0x12\n");
1081 SAY("register 0x%02X muted\n", 0x12);
1083 igot = read_vt(pusb_device, 0x0014);
1085 SAY("ERROR: failed to read VT1612A register 0x14\n");
1087 SAY("register 0x%02X muted\n", 0x14);
1089 igot = read_vt(pusb_device, 0x0016);
1091 SAY("ERROR: failed to read VT1612A register 0x16\n");
1093 SAY("register 0x%02X muted\n", 0x16);
1095 igot = read_vt(pusb_device, 0x0018);
1097 SAY("ERROR: failed to read VT1612A register 0x18\n");
1099 SAY("register 0x%02X muted\n", 0x18);
1101 igot = read_vt(pusb_device, 0x001C);
1103 SAY("ERROR: failed to read VT1612A register 0x1C\n");
1105 SAY("register 0x%02X muted\n", 0x1C);
1109 /*****************************************************************************/
1110 /*---------------------------------------------------------------------------*/
1111 /* NOTE: THIS DOES INCREASE THE VOLUME DRAMATICALLY:
1112 * audio_gainset(pusb_device, 0x000F);
1114 * loud dB register 0x10 dB register 0x1C dB total
1123 /*---------------------------------------------------------------------------*/
1125 audio_gainset(struct usb_device *pusb_device, __s8 loud)
1131 if ((struct usb_device *)NULL == pusb_device)
1138 write_vt(pusb_device, 0x0002, 0x8000);
1139 /*---------------------------------------------------------------------------*/
1140 igot = read_vt(pusb_device, 0x000E);
1142 SAY("ERROR: failed to read VT1612A register 0x0E\n");
1145 mute = 0x8000 & ((unsigned int)igot);
1149 u8 = 0x01 | (0x001F & (((__u8)(15 - loud)) << 1));
1153 JOT(8, "0x%04X=(mute|u8) for VT1612A register 0x0E\n", mute | u8);
1154 write_vt(pusb_device, 0x000E, (mute | u8));
1155 /*---------------------------------------------------------------------------*/
1156 igot = read_vt(pusb_device, 0x0010);
1158 SAY("ERROR: failed to read VT1612A register 0x10\n");
1161 mute = 0x8000 & ((unsigned int)igot);
1164 JOT(8, "0x%04X=(mute|u8|(u8<<8)) for VT1612A register 0x10,...0x18\n", \
1165 mute | u8 | (u8 << 8));
1166 write_vt(pusb_device, 0x0010, (mute | u8 | (u8 << 8)));
1167 write_vt(pusb_device, 0x0012, (mute | u8 | (u8 << 8)));
1168 write_vt(pusb_device, 0x0014, (mute | u8 | (u8 << 8)));
1169 write_vt(pusb_device, 0x0016, (mute | u8 | (u8 << 8)));
1170 write_vt(pusb_device, 0x0018, (mute | u8 | (u8 << 8)));
1171 /*---------------------------------------------------------------------------*/
1172 igot = read_vt(pusb_device, 0x001C);
1174 SAY("ERROR: failed to read VT1612A register 0x1C\n");
1177 mute = 0x8000 & ((unsigned int)igot);
1181 u8 = 0x000F & (__u8)(loud - 16);
1185 JOT(8, "0x%04X=(mute|u8|(u8<<8)) for VT1612A register 0x1C\n", \
1186 mute | u8 | (u8 << 8));
1187 write_vt(pusb_device, 0x001C, (mute | u8 | (u8 << 8)));
1188 write_vt(pusb_device, 0x001A, 0x0404);
1189 write_vt(pusb_device, 0x0002, 0x0000);
1192 /*****************************************************************************/
1194 audio_gainget(struct usb_device *pusb_device)
1198 if (NULL == pusb_device)
1200 igot = read_vt(pusb_device, 0x001C);
1202 SAY("ERROR: failed to read VT1612A register 0x1C\n");
1205 /*****************************************************************************/