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 * FUNCTION wait_i2c() RETURNS 0 ON SUCCESS
330 /*--------------------------------------------------------------------------*/
331 static int wait_i2c(struct usb_device
*p
)
341 for (k
= 0; k
< max
; k
++) {
342 GET(p
, 0x0201, &igot
); get0
= igot
;
357 /****************************************************************************/
358 int confirm_resolution(struct usb_device
*p
)
360 u8 get0
, get1
, get2
, get3
, get4
, get5
, get6
, get7
;
364 GET(p
, 0x0110, &get0
);
365 GET(p
, 0x0111, &get1
);
366 GET(p
, 0x0112, &get2
);
367 GET(p
, 0x0113, &get3
);
368 GET(p
, 0x0114, &get4
);
369 GET(p
, 0x0115, &get5
);
370 GET(p
, 0x0116, &get6
);
371 GET(p
, 0x0117, &get7
);
372 JOT(8, "0x%03X, 0x%03X, "
376 get0
, get1
, get2
, get3
, get4
, get5
, get6
, get7
);
377 JOT(8, "....cf PAL_720x526: "
382 0x000, 0x000, 0x001, 0x000, 0x5A0, 0x005, 0x121, 0x001);
383 JOT(8, "....cf PAL_704x526: "
388 0x004, 0x000, 0x001, 0x000, 0x584, 0x005, 0x121, 0x001);
389 JOT(8, "....cf VGA_640x480: "
394 0x008, 0x000, 0x020, 0x000, 0x508, 0x005, 0x110, 0x001);
397 /****************************************************************************/
398 int confirm_stream(struct usb_device
*p
)
405 GET(p
, 0x0100, &igot
); get2
= 0x80 & igot
;
407 JOT(8, "confirm_stream: OK\n");
409 JOT(8, "confirm_stream: STUCK\n");
412 /****************************************************************************/
413 int setup_stk(struct usb_device
*p
, bool ntsc
)
416 const struct stk1160config
*cfg
;
419 cfg
= (ntsc
) ? stk1160configNTSC
: stk1160configPAL
;
420 for (i
= 0; cfg
[i
].reg
!= 0xFFF; i
++)
421 SET(p
, cfg
[i
].reg
, cfg
[i
].set
);
427 /****************************************************************************/
428 int setup_saa(struct usb_device
*p
, bool ntsc
)
431 const struct saa7113config
*cfg
;
434 cfg
= (ntsc
) ? saa7113configNTSC
: saa7113configPAL
;
435 for (i
= 0; cfg
[i
].reg
!= 0xFF; i
++)
436 ir
= write_saa(p
, cfg
[i
].reg
, cfg
[i
].set
);
439 /****************************************************************************/
440 int write_000(struct usb_device
*p
, u16 set2
, u16 set0
)
446 GET(p
, 0x0002, &igot2
);
447 GET(p
, 0x0000, &igot0
);
448 SET(p
, 0x0002, set2
);
449 SET(p
, 0x0000, set0
);
452 /****************************************************************************/
453 int write_saa(struct usb_device
*p
, u16 reg0
, u16 set0
)
463 /****************************************************************************/
464 /*--------------------------------------------------------------------------*/
466 * REGISTER 500: SETTING VALUE TO 0x008B READS FROM VT1612A (?)
467 * REGISTER 500: SETTING VALUE TO 0x008C WRITES TO VT1612A
468 * REGISTER 502: LEAST SIGNIFICANT BYTE OF VALUE TO SET
469 * REGISTER 503: MOST SIGNIFICANT BYTE OF VALUE TO SET
470 * REGISTER 504: TARGET ADDRESS ON VT1612A
472 /*--------------------------------------------------------------------------*/
474 write_vt(struct usb_device
*p
, u16 reg0
, u16 set0
)
482 SET(p
, 0x0504, reg0
);
483 SET(p
, 0x0500, 0x008B);
485 GET(p
, 0x0502, &igot
); got502
= (0xFF & igot
);
486 GET(p
, 0x0503, &igot
); got503
= (0xFF & igot
);
488 JOT(16, "write_vt(., 0x%04X, 0x%04X): was 0x%04X\n",
489 reg0
, set0
, ((got503
<< 8) | got502
));
491 set502
= (0x00FF & set0
);
492 set503
= ((0xFF00 & set0
) >> 8);
494 SET(p
, 0x0504, reg0
);
495 SET(p
, 0x0502, set502
);
496 SET(p
, 0x0503, set503
);
497 SET(p
, 0x0500, 0x008C);
501 /****************************************************************************/
502 /*--------------------------------------------------------------------------*/
504 * REGISTER 500: SETTING VALUE TO 0x008B READS FROM VT1612A (?)
505 * REGISTER 500: SETTING VALUE TO 0x008C WRITES TO VT1612A
506 * REGISTER 502: LEAST SIGNIFICANT BYTE OF VALUE TO GET
507 * REGISTER 503: MOST SIGNIFICANT BYTE OF VALUE TO GET
508 * REGISTER 504: TARGET ADDRESS ON VT1612A
510 /*--------------------------------------------------------------------------*/
511 int read_vt(struct usb_device
*p
, u16 reg0
)
518 SET(p
, 0x0504, reg0
);
519 SET(p
, 0x0500, 0x008B);
521 GET(p
, 0x0502, &igot
); got502
= (0xFF & igot
);
522 GET(p
, 0x0503, &igot
); got503
= (0xFF & igot
);
524 JOT(16, "read_vt(., 0x%04X): has 0x%04X\n",
525 reg0
, ((got503
<< 8) | got502
));
527 return (got503
<< 8) | got502
;
529 /****************************************************************************/
530 /*--------------------------------------------------------------------------*/
532 * THESE APPEAR TO HAVE NO EFFECT ON EITHER VIDEO OR AUDIO.
534 /*--------------------------------------------------------------------------*/
535 int write_300(struct usb_device
*p
)
539 SET(p
, 0x300, 0x0012);
540 SET(p
, 0x350, 0x002D);
541 SET(p
, 0x351, 0x0001);
542 SET(p
, 0x352, 0x0000);
543 SET(p
, 0x353, 0x0000);
544 SET(p
, 0x300, 0x0080);
547 /****************************************************************************/
548 /*--------------------------------------------------------------------------*/
550 * NOTE: THE FOLLOWING IS NOT CHECKED:
551 * REGISTER 0x0F, WHICH IS INVOLVED IN CHROMINANCE AUTOMATIC GAIN CONTROL.
553 /*--------------------------------------------------------------------------*/
554 int check_saa(struct usb_device
*p
, bool ntsc
)
557 struct saa7113config
const *cfg
;
561 cfg
= (ntsc
) ? saa7113configNTSC
: saa7113configPAL
;
562 for (i
= 0; cfg
[i
].reg
!= 0xFF; i
++) {
563 if (0x0F == cfg
[i
].reg
)
565 ir
= read_saa(p
, cfg
[i
].reg
);
566 if (ir
!= cfg
[i
].set
) {
567 SAY("SAA register 0x%02X has 0x%02X, expected 0x%02X\n",
568 cfg
[i
].reg
, ir
, cfg
[i
].set
);
573 return (rc
< -8) ? rc
: 0;
575 /****************************************************************************/
576 int merit_saa(struct usb_device
*p
)
582 rc
= read_saa(p
, 0x1F);
583 return ((0 > rc
) || (0x02 & rc
)) ? 1 : 0;
585 /****************************************************************************/
586 int ready_saa(struct usb_device
*p
)
589 const int max
= 5, marktime
= PATIENCE
/5;
590 /*--------------------------------------------------------------------------*/
592 * RETURNS 0 FOR INTERLACED 50 Hz
593 * 1 FOR NON-INTERLACED 50 Hz
594 * 2 FOR INTERLACED 60 Hz
595 * 3 FOR NON-INTERLACED 60 Hz
597 /*--------------------------------------------------------------------------*/
602 rc
= read_saa(p
, 0x1F);
604 if (0 == (0x40 & rc
))
606 if (1 == (0x01 & rc
))
617 JOT(8, "hardware detects 60 Hz\n");
620 JOT(8, "hardware detects 50 Hz\n");
623 JOT(8, "hardware detects interlacing\n");
626 JOT(8, "hardware detects no interlacing\n");
631 /****************************************************************************/
632 /*--------------------------------------------------------------------------*/
634 * NOTE: THE FOLLOWING ARE NOT CHECKED:
635 * REGISTERS 0x000, 0x002: FUNCTIONALITY IS NOT KNOWN
636 * REGISTER 0x100: ACCEPT ALSO (0x80 | stk1160config....[.].set)
638 /*--------------------------------------------------------------------------*/
639 int check_stk(struct usb_device
*p
, bool ntsc
)
642 const struct stk1160config
*cfg
;
646 cfg
= (ntsc
) ? stk1160configNTSC
: stk1160configPAL
;
648 for (i
= 0; 0xFFF != cfg
[i
].reg
; i
++) {
649 if (0x000 == cfg
[i
].reg
|| 0x002 == cfg
[i
].reg
)
653 ir
= read_stk(p
, cfg
[i
].reg
);
654 if (0x100 == cfg
[i
].reg
) {
655 if ((ir
!= (0xFF & cfg
[i
].set
)) &&
656 (ir
!= (0x80 | (0xFF & cfg
[i
].set
))) &&
657 (0xFFFF != cfg
[i
].set
)) {
658 SAY("STK reg[0x%03X]=0x%02X expected 0x%02X\n",
659 cfg
[i
].reg
, ir
, cfg
[i
].set
);
663 if ((ir
!= (0xFF & cfg
[i
].set
)) && (0xFFFF != cfg
[i
].set
))
664 SAY("STK register 0x%03X has 0x%02X,expected 0x%02X\n",
665 cfg
[i
].reg
, ir
, cfg
[i
].set
);
669 /****************************************************************************/
670 int read_saa(struct usb_device
*p
, u16 reg0
)
678 if (0 != wait_i2c(p
))
681 GET(p
, 0x0209, &igot
);
684 /****************************************************************************/
685 int read_stk(struct usb_device
*p
, u32 reg0
)
695 /****************************************************************************/
696 /*--------------------------------------------------------------------------*/
698 * HARDWARE USERSPACE INPUT NUMBER PHYSICAL INPUT DRIVER input VALUE
700 * CVBS+S-VIDEO 0 or 1 CVBS 1
701 * FOUR-CVBS 0 or 1 CVBS1 1
702 * FOUR-CVBS 2 CVBS2 2
703 * FOUR-CVBS 3 CVBS3 3
704 * FOUR-CVBS 4 CVBS4 4
705 * CVBS+S-VIDEO 5 S-VIDEO 5
707 * WHEN 5==input THE ARGUMENT mode MUST ALSO BE SUPPLIED:
709 * mode 7 => GAIN TO BE SET EXPLICITLY USING REGISTER 0x05 (UNTESTED)
710 * mode 9 => USE AUTOMATIC GAIN CONTROL (DEFAULT)
713 /*---------------------------------------------------------------------------*/
715 select_input(struct usb_device
*p
, int input
, int mode
)
725 if (0 != write_saa(p
, 0x02, 0x80))
726 SAY("ERROR: failed to set SAA register 0x02 "
727 "for input %i\n", input
);
729 SET(p
, 0x0000, 0x0098);
730 SET(p
, 0x0002, 0x0078);
734 if (0 != write_saa(p
, 0x02, 0x80))
735 SAY("ERROR: failed to set SAA register 0x02 "
736 "for input %i\n", input
);
738 SET(p
, 0x0000, 0x0090);
739 SET(p
, 0x0002, 0x0078);
743 if (0 != write_saa(p
, 0x02, 0x80))
744 SAY("ERROR: failed to set SAA register 0x02 "
745 " for input %i\n", input
);
747 SET(p
, 0x0000, 0x0088);
748 SET(p
, 0x0002, 0x0078);
752 if (0 != write_saa(p
, 0x02, 0x80)) {
753 SAY("ERROR: failed to set SAA register 0x02 "
754 "for input %i\n", input
);
756 SET(p
, 0x0000, 0x0080);
757 SET(p
, 0x0002, 0x0078);
765 if (0 != write_saa(p
, 0x02, 0x87))
766 SAY("ERROR: failed to set SAA register 0x02 "
767 "for input %i\n", input
);
769 if (0 != write_saa(p
, 0x05, 0xFF))
770 SAY("ERROR: failed to set SAA register 0x05 "
771 "for input %i\n", input
);
776 if (0 != write_saa(p
, 0x02, 0x89))
777 SAY("ERROR: failed to set SAA register 0x02 "
778 "for input %i\n", input
);
780 if (0 != write_saa(p
, 0x05, 0x00))
781 SAY("ERROR: failed to set SAA register 0x05 "
782 "for input %i\n", input
);
787 SAY("MISTAKE: bad mode: %i\n", mode
);
791 if (0 != write_saa(p
, 0x04, 0x00))
792 SAY("ERROR: failed to set SAA register 0x04 "
793 "for input %i\n", input
);
795 if (0 != write_saa(p
, 0x09, 0x80))
796 SAY("ERROR: failed to set SAA register 0x09 "
797 "for input %i\n", input
);
799 SET(p
, 0x0002, 0x0093);
803 SAY("ERROR: bad input: %i\n", input
);
807 ir
= read_stk(p
, 0x00);
808 JOT(8, "STK register 0x00 has 0x%02X\n", ir
);
809 ir
= read_saa(p
, 0x02);
810 JOT(8, "SAA register 0x02 has 0x%02X\n", ir
);
816 /****************************************************************************/
817 int set_resolution(struct usb_device
*p
,
818 u16 set0
, u16 set1
, u16 set2
, u16 set3
)
820 u16 u0x0111
, u0x0113
, u0x0115
, u0x0117
;
824 u0x0111
= ((0xFF00 & set0
) >> 8);
825 u0x0113
= ((0xFF00 & set1
) >> 8);
826 u0x0115
= ((0xFF00 & set2
) >> 8);
827 u0x0117
= ((0xFF00 & set3
) >> 8);
829 SET(p
, 0x0110, (0x00FF & set0
));
830 SET(p
, 0x0111, u0x0111
);
831 SET(p
, 0x0112, (0x00FF & set1
));
832 SET(p
, 0x0113, u0x0113
);
833 SET(p
, 0x0114, (0x00FF & set2
));
834 SET(p
, 0x0115, u0x0115
);
835 SET(p
, 0x0116, (0x00FF & set3
));
836 SET(p
, 0x0117, u0x0117
);
840 /****************************************************************************/
841 int start_100(struct usb_device
*p
)
843 u16 get116
, get117
, get0
;
844 u8 igot116
, igot117
, igot
;
848 GET(p
, 0x0116, &igot116
);
850 GET(p
, 0x0117, &igot117
);
852 SET(p
, 0x0116, 0x0000);
853 SET(p
, 0x0117, 0x0000);
855 GET(p
, 0x0100, &igot
);
857 SET(p
, 0x0100, (0x80 | get0
));
859 SET(p
, 0x0116, get116
);
860 SET(p
, 0x0117, get117
);
864 /****************************************************************************/
865 int stop_100(struct usb_device
*p
)
872 GET(p
, 0x0100, &igot
);
874 SET(p
, 0x0100, (0x7F & get0
));
877 /****************************************************************************/
878 /****************************************************************************/
879 /*****************************************************************************/
880 int wakeup_device(struct usb_device
*pusb_device
)
884 return usb_control_msg(pusb_device
, usb_sndctrlpipe(pusb_device
, 0),
886 USB_DIR_OUT
| USB_TYPE_STANDARD
| USB_RECIP_DEVICE
,
887 USB_DEVICE_REMOTE_WAKEUP
,
890 /*****************************************************************************/
892 audio_setup(struct easycap
*peasycap
)
894 struct usb_device
*pusb_device
;
897 /*---------------------------------------------------------------------------*/
900 * THE MESSAGE OF TYPE (USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE)
901 * CAUSES MUTING IF THE VALUE 0x0100 IS SENT.
902 * TO ENABLE AUDIO THE VALUE 0x0200 MUST BE SENT.
904 /*---------------------------------------------------------------------------*/
905 const u8 request
= 0x01;
906 const u8 requesttype
= USB_DIR_OUT
|
909 const u16 value_unmute
= 0x0200;
910 const u16 index
= 0x0301;
911 const u16 length
= 1;
916 pusb_device
= peasycap
->pusb_device
;
920 JOM(8, "%02X %02X %02X %02X %02X %02X %02X %02X\n",
921 requesttype
, request
,
922 (0x00FF & value_unmute
),
923 (0xFF00 & value_unmute
) >> 8,
925 (0xFF00 & index
) >> 8,
927 (0xFF00 & length
) >> 8);
931 rc
= usb_control_msg(pusb_device
, usb_sndctrlpipe(pusb_device
, 0),
932 request
, requesttype
, value_unmute
,
933 index
, &buffer
[0], length
, 50000);
935 JOT(8, "0x%02X=buffer\n", buffer
[0]);
936 if (rc
!= (int)length
) {
939 SAY("usb_control_msg returned -EPIPE\n");
942 SAY("ERROR: usb_control_msg returned %i\n", rc
);
946 /*--------------------------------------------------------------------------*/
948 * REGISTER 500: SETTING VALUE TO 0x0094 RESETS AUDIO CONFIGURATION ???
949 * REGISTER 506: ANALOGUE AUDIO ATTENTUATOR ???
950 * FOR THE CVBS+S-VIDEO HARDWARE:
951 * SETTING VALUE TO 0x0000 GIVES QUIET SOUND.
952 * THE UPPER BYTE SEEMS TO HAVE NO EFFECT.
953 * FOR THE FOUR-CVBS HARDWARE:
954 * SETTING VALUE TO 0x0000 SEEMS TO HAVE NO EFFECT.
955 * REGISTER 507: ANALOGUE AUDIO PREAMPLIFIER ON/OFF ???
956 * FOR THE CVBS-S-VIDEO HARDWARE:
957 * SETTING VALUE TO 0x0001 GIVES VERY LOUD, DISTORTED SOUND.
958 * THE UPPER BYTE SEEMS TO HAVE NO EFFECT.
960 /*--------------------------------------------------------------------------*/
961 SET(pusb_device
, 0x0500, 0x0094);
962 SET(pusb_device
, 0x0500, 0x008C);
963 SET(pusb_device
, 0x0506, 0x0001);
964 SET(pusb_device
, 0x0507, 0x0000);
965 id1
= read_vt(pusb_device
, 0x007C);
966 id2
= read_vt(pusb_device
, 0x007E);
967 SAM("0x%04X:0x%04X is audio vendor id\n", id1
, id2
);
968 /*---------------------------------------------------------------------------*/
970 * SELECT AUDIO SOURCE "LINE IN" AND SET THE AUDIO GAIN.
972 /*---------------------------------------------------------------------------*/
973 if (0 != audio_gainset(pusb_device
, peasycap
->gain
))
974 SAY("ERROR: audio_gainset() failed\n");
975 check_vt(pusb_device
);
978 /*****************************************************************************/
979 int check_vt(struct usb_device
*pusb_device
)
985 igot
= read_vt(pusb_device
, 0x0002);
987 SAY("ERROR: failed to read VT1612A register 0x02\n");
989 SAY("register 0x%02X muted\n", 0x02);
991 igot
= read_vt(pusb_device
, 0x000E);
993 SAY("ERROR: failed to read VT1612A register 0x0E\n");
995 SAY("register 0x%02X muted\n", 0x0E);
997 igot
= read_vt(pusb_device
, 0x0010);
999 SAY("ERROR: failed to read VT1612A register 0x10\n");
1001 SAY("register 0x%02X muted\n", 0x10);
1003 igot
= read_vt(pusb_device
, 0x0012);
1005 SAY("ERROR: failed to read VT1612A register 0x12\n");
1007 SAY("register 0x%02X muted\n", 0x12);
1009 igot
= read_vt(pusb_device
, 0x0014);
1011 SAY("ERROR: failed to read VT1612A register 0x14\n");
1013 SAY("register 0x%02X muted\n", 0x14);
1015 igot
= read_vt(pusb_device
, 0x0016);
1017 SAY("ERROR: failed to read VT1612A register 0x16\n");
1019 SAY("register 0x%02X muted\n", 0x16);
1021 igot
= read_vt(pusb_device
, 0x0018);
1023 SAY("ERROR: failed to read VT1612A register 0x18\n");
1025 SAY("register 0x%02X muted\n", 0x18);
1027 igot
= read_vt(pusb_device
, 0x001C);
1029 SAY("ERROR: failed to read VT1612A register 0x1C\n");
1031 SAY("register 0x%02X muted\n", 0x1C);
1035 /*****************************************************************************/
1036 /*---------------------------------------------------------------------------*/
1037 /* NOTE: THIS DOES INCREASE THE VOLUME DRAMATICALLY:
1038 * audio_gainset(pusb_device, 0x000F);
1040 * loud dB register 0x10 dB register 0x1C dB total
1049 /*---------------------------------------------------------------------------*/
1050 int audio_gainset(struct usb_device
*pusb_device
, s8 loud
)
1063 write_vt(pusb_device
, 0x0002, 0x8000);
1064 /*---------------------------------------------------------------------------*/
1065 igot
= read_vt(pusb_device
, 0x000E);
1067 SAY("ERROR: failed to read VT1612A register 0x0E\n");
1070 mute
= 0x8000 & ((unsigned int)igot
);
1074 tmp
= 0x01 | (0x001F & (((u8
)(15 - loud
)) << 1));
1078 JOT(8, "0x%04X=(mute|tmp) for VT1612A register 0x0E\n", mute
| tmp
);
1079 write_vt(pusb_device
, 0x000E, (mute
| tmp
));
1080 /*---------------------------------------------------------------------------*/
1081 igot
= read_vt(pusb_device
, 0x0010);
1083 SAY("ERROR: failed to read VT1612A register 0x10\n");
1086 mute
= 0x8000 & ((unsigned int)igot
);
1089 JOT(8, "0x%04X=(mute|tmp|(tmp<<8)) for VT1612A register 0x10,...0x18\n",
1090 mute
| tmp
| (tmp
<< 8));
1091 write_vt(pusb_device
, 0x0010, (mute
| tmp
| (tmp
<< 8)));
1092 write_vt(pusb_device
, 0x0012, (mute
| tmp
| (tmp
<< 8)));
1093 write_vt(pusb_device
, 0x0014, (mute
| tmp
| (tmp
<< 8)));
1094 write_vt(pusb_device
, 0x0016, (mute
| tmp
| (tmp
<< 8)));
1095 write_vt(pusb_device
, 0x0018, (mute
| tmp
| (tmp
<< 8)));
1096 /*---------------------------------------------------------------------------*/
1097 igot
= read_vt(pusb_device
, 0x001C);
1099 SAY("ERROR: failed to read VT1612A register 0x1C\n");
1102 mute
= 0x8000 & ((unsigned int)igot
);
1106 tmp
= 0x000F & (u8
)(loud
- 16);
1110 JOT(8, "0x%04X=(mute|tmp|(tmp<<8)) for VT1612A register 0x1C\n",
1111 mute
| tmp
| (tmp
<< 8));
1112 write_vt(pusb_device
, 0x001C, (mute
| tmp
| (tmp
<< 8)));
1113 write_vt(pusb_device
, 0x001A, 0x0404);
1114 write_vt(pusb_device
, 0x0002, 0x0000);
1117 /*****************************************************************************/
1118 int audio_gainget(struct usb_device
*pusb_device
)
1124 igot
= read_vt(pusb_device
, 0x001C);
1126 SAY("ERROR: failed to read VT1612A register 0x1C\n");
1129 /*****************************************************************************/