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 /*--------------------------------------------------------------------------*/
44 static const struct stk1160config
{
47 } stk1160configPAL
[256] = {
67 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
71 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
80 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
88 /*--------------------------------------------------------------------------*/
89 static const struct stk1160config stk1160configNTSC
[256] = {
109 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
113 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
122 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
130 /*--------------------------------------------------------------------------*/
131 static const struct saa7113config
{
134 } saa7113configPAL
[256] = {
144 {0x0A, SAA_0A_DEFAULT
},
145 {0x0B, SAA_0B_DEFAULT
},
146 {0x0C, SAA_0C_DEFAULT
},
147 {0x0D, SAA_0D_DEFAULT
},
187 /*--------------------------------------------------------------------------*/
188 static const struct saa7113config saa7113configNTSC
[256] = {
198 {0x0A, SAA_0A_DEFAULT
},
199 {0x0B, SAA_0B_DEFAULT
},
200 {0x0C, SAA_0C_DEFAULT
},
201 {0x0D, SAA_0D_DEFAULT
},
241 /*--------------------------------------------------------------------------*/
243 /****************************************************************************/
245 confirm_resolution(struct usb_device
*p
)
247 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, "
263 get0
, get1
, get2
, get3
, get4
, get5
, get6
, get7
);
264 JOT(8, "....cf PAL_720x526: "
269 0x000, 0x000, 0x001, 0x000, 0x5A0, 0x005, 0x121, 0x001);
270 JOT(8, "....cf PAL_704x526: "
275 0x004, 0x000, 0x001, 0x000, 0x584, 0x005, 0x121, 0x001);
276 JOT(8, "....cf VGA_640x480: "
281 0x008, 0x000, 0x020, 0x000, 0x508, 0x005, 0x110, 0x001);
284 /****************************************************************************/
286 confirm_stream(struct usb_device
*p
)
293 GET(p
, 0x0100, &igot
); get2
= 0x80 & igot
;
295 JOT(8, "confirm_stream: OK\n");
297 JOT(8, "confirm_stream: STUCK\n");
300 /****************************************************************************/
302 setup_stk(struct usb_device
*p
, bool ntsc
)
310 while (0xFFF != stk1160configNTSC
[i0
].reg
) {
311 SET(p
, stk1160configNTSC
[i0
].reg
, stk1160configNTSC
[i0
].set
);
315 while (0xFFF != stk1160configPAL
[i0
].reg
) {
316 SET(p
, stk1160configPAL
[i0
].reg
, stk1160configPAL
[i0
].set
);
325 /****************************************************************************/
327 setup_saa(struct usb_device
*p
, bool ntsc
)
335 while (0xFF != saa7113configNTSC
[i0
].reg
) {
336 ir
= write_saa(p
, saa7113configNTSC
[i0
].reg
,
337 saa7113configNTSC
[i0
].set
);
341 while (0xFF != saa7113configPAL
[i0
].reg
) {
342 ir
= write_saa(p
, saa7113configPAL
[i0
].reg
,
343 saa7113configPAL
[i0
].set
);
349 /****************************************************************************/
351 write_000(struct usb_device
*p
, u16 set2
, u16 set0
)
357 GET(p
, 0x0002, &igot2
);
358 GET(p
, 0x0000, &igot0
);
359 SET(p
, 0x0002, set2
);
360 SET(p
, 0x0000, set0
);
363 /****************************************************************************/
365 write_saa(struct usb_device
*p
, u16 reg0
, u16 set0
)
375 /****************************************************************************/
376 /*--------------------------------------------------------------------------*/
378 * REGISTER 500: SETTING VALUE TO 0x008B READS FROM VT1612A (?)
379 * REGISTER 500: SETTING VALUE TO 0x008C WRITES TO VT1612A
380 * REGISTER 502: LEAST SIGNIFICANT BYTE OF VALUE TO SET
381 * REGISTER 503: MOST SIGNIFICANT BYTE OF VALUE TO SET
382 * REGISTER 504: TARGET ADDRESS ON VT1612A
384 /*--------------------------------------------------------------------------*/
386 write_vt(struct usb_device
*p
, u16 reg0
, u16 set0
)
394 SET(p
, 0x0504, reg0
);
395 SET(p
, 0x0500, 0x008B);
397 GET(p
, 0x0502, &igot
); got502
= (0xFF & igot
);
398 GET(p
, 0x0503, &igot
); got503
= (0xFF & igot
);
400 JOT(16, "write_vt(., 0x%04X, 0x%04X): was 0x%04X\n",
401 reg0
, set0
, ((got503
<< 8) | got502
));
403 set502
= (0x00FF & set0
);
404 set503
= ((0xFF00 & set0
) >> 8);
406 SET(p
, 0x0504, reg0
);
407 SET(p
, 0x0502, set502
);
408 SET(p
, 0x0503, set503
);
409 SET(p
, 0x0500, 0x008C);
413 /****************************************************************************/
414 /*--------------------------------------------------------------------------*/
416 * REGISTER 500: SETTING VALUE TO 0x008B READS FROM VT1612A (?)
417 * REGISTER 500: SETTING VALUE TO 0x008C WRITES TO VT1612A
418 * REGISTER 502: LEAST SIGNIFICANT BYTE OF VALUE TO GET
419 * REGISTER 503: MOST SIGNIFICANT BYTE OF VALUE TO GET
420 * REGISTER 504: TARGET ADDRESS ON VT1612A
422 /*--------------------------------------------------------------------------*/
424 read_vt(struct usb_device
*p
, u16 reg0
)
431 SET(p
, 0x0504, reg0
);
432 SET(p
, 0x0500, 0x008B);
434 GET(p
, 0x0502, &igot
); got502
= (0xFF & igot
);
435 GET(p
, 0x0503, &igot
); got503
= (0xFF & igot
);
437 JOT(16, "read_vt(., 0x%04X): has 0x%04X\n", reg0
, ((got503
<< 8) | got502
));
439 return (got503
<< 8) | got502
;
441 /****************************************************************************/
442 /*--------------------------------------------------------------------------*/
444 * THESE APPEAR TO HAVE NO EFFECT ON EITHER VIDEO OR AUDIO.
446 /*--------------------------------------------------------------------------*/
448 write_300(struct usb_device
*p
)
452 SET(p
, 0x300, 0x0012);
453 SET(p
, 0x350, 0x002D);
454 SET(p
, 0x351, 0x0001);
455 SET(p
, 0x352, 0x0000);
456 SET(p
, 0x353, 0x0000);
457 SET(p
, 0x300, 0x0080);
460 /****************************************************************************/
461 /*--------------------------------------------------------------------------*/
463 * NOTE: THE FOLLOWING IS NOT CHECKED:
464 * REGISTER 0x0F, WHICH IS INVOLVED IN CHROMINANCE AUTOMATIC GAIN CONTROL.
466 /*--------------------------------------------------------------------------*/
468 check_saa(struct usb_device
*p
, bool ntsc
)
477 while (0xFF != saa7113configNTSC
[i0
].reg
) {
478 if (0x0F == saa7113configNTSC
[i0
].reg
) {
483 ir
= read_saa(p
, saa7113configNTSC
[i0
].reg
);
484 if (ir
!= saa7113configNTSC
[i0
].set
) {
485 SAY("SAA register 0x%02X has 0x%02X, "
487 saa7113configNTSC
[i0
].reg
,
488 ir
, saa7113configNTSC
[i0
].set
);
494 while (0xFF != saa7113configPAL
[i0
].reg
) {
495 if (0x0F == saa7113configPAL
[i0
].reg
) {
500 ir
= read_saa(p
, saa7113configPAL
[i0
].reg
);
501 if (ir
!= saa7113configPAL
[i0
].set
) {
502 SAY("SAA register 0x%02X has 0x%02X, "
504 saa7113configPAL
[i0
].reg
,
505 ir
, saa7113configPAL
[i0
].set
);
516 /****************************************************************************/
518 merit_saa(struct usb_device
*p
)
524 rc
= read_saa(p
, 0x1F);
525 if ((0 > rc
) || (0x02 & rc
))
530 /****************************************************************************/
532 ready_saa(struct usb_device
*p
)
535 const int max
= 5, marktime
= PATIENCE
/5;
536 /*--------------------------------------------------------------------------*/
538 * RETURNS 0 FOR INTERLACED 50 Hz
539 * 1 FOR NON-INTERLACED 50 Hz
540 * 2 FOR INTERLACED 60 Hz
541 * 3 FOR NON-INTERLACED 60 Hz
543 /*--------------------------------------------------------------------------*/
548 rc
= read_saa(p
, 0x1F);
550 if (0 == (0x40 & rc
))
552 if (1 == (0x01 & rc
))
563 JOT(8, "hardware detects 60 Hz\n");
566 JOT(8, "hardware detects 50 Hz\n");
569 JOT(8, "hardware detects interlacing\n");
572 JOT(8, "hardware detects no interlacing\n");
577 /****************************************************************************/
578 /*--------------------------------------------------------------------------*/
580 * NOTE: THE FOLLOWING ARE NOT CHECKED:
581 * REGISTERS 0x000, 0x002: FUNCTIONALITY IS NOT KNOWN
582 * REGISTER 0x100: ACCEPT ALSO (0x80 | stk1160config....[.].set)
584 /*--------------------------------------------------------------------------*/
586 check_stk(struct usb_device
*p
, bool ntsc
)
594 while (0xFFF != stk1160configNTSC
[i0
].reg
) {
595 if (0x000 == stk1160configNTSC
[i0
].reg
) {
598 if (0x002 == stk1160configNTSC
[i0
].reg
) {
601 ir
= read_stk(p
, stk1160configNTSC
[i0
].reg
);
602 if (0x100 == stk1160configNTSC
[i0
].reg
) {
603 if ((ir
!= (0xFF & stk1160configNTSC
[i0
].set
)) &&
604 (ir
!= (0x80 | (0xFF &
605 stk1160configNTSC
[i0
].set
))) &&
607 stk1160configNTSC
[i0
].set
)) {
608 SAY("STK register 0x%03X has 0x%02X, "
610 stk1160configNTSC
[i0
].reg
,
611 ir
, stk1160configNTSC
[i0
].set
);
615 if ((ir
!= (0xFF & stk1160configNTSC
[i0
].set
)) &&
616 (0xFFFF != stk1160configNTSC
[i0
].set
)) {
617 SAY("STK register 0x%03X has 0x%02X, "
619 stk1160configNTSC
[i0
].reg
,
620 ir
, stk1160configNTSC
[i0
].set
);
625 while (0xFFF != stk1160configPAL
[i0
].reg
) {
626 if (0x000 == stk1160configPAL
[i0
].reg
) {
629 if (0x002 == stk1160configPAL
[i0
].reg
) {
632 ir
= read_stk(p
, stk1160configPAL
[i0
].reg
);
633 if (0x100 == stk1160configPAL
[i0
].reg
) {
634 if ((ir
!= (0xFF & stk1160configPAL
[i0
].set
)) &&
635 (ir
!= (0x80 | (0xFF &
636 stk1160configPAL
[i0
].set
))) &&
638 stk1160configPAL
[i0
].set
)) {
639 SAY("STK register 0x%03X has 0x%02X, "
641 stk1160configPAL
[i0
].reg
,
642 ir
, stk1160configPAL
[i0
].set
);
646 if ((ir
!= (0xFF & stk1160configPAL
[i0
].set
)) &&
647 (0xFFFF != stk1160configPAL
[i0
].set
)) {
648 SAY("STK register 0x%03X has 0x%02X, "
650 stk1160configPAL
[i0
].reg
,
651 ir
, stk1160configPAL
[i0
].set
);
658 /****************************************************************************/
660 read_saa(struct usb_device
*p
, u16 reg0
)
668 if (0 != wait_i2c(p
))
671 GET(p
, 0x0209, &igot
);
674 /****************************************************************************/
676 read_stk(struct usb_device
*p
, u32 reg0
)
686 /****************************************************************************/
687 /*--------------------------------------------------------------------------*/
689 * HARDWARE USERSPACE INPUT NUMBER PHYSICAL INPUT DRIVER input VALUE
691 * CVBS+S-VIDEO 0 or 1 CVBS 1
692 * FOUR-CVBS 0 or 1 CVBS1 1
693 * FOUR-CVBS 2 CVBS2 2
694 * FOUR-CVBS 3 CVBS3 3
695 * FOUR-CVBS 4 CVBS4 4
696 * CVBS+S-VIDEO 5 S-VIDEO 5
698 * WHEN 5==input THE ARGUMENT mode MUST ALSO BE SUPPLIED:
700 * mode 7 => GAIN TO BE SET EXPLICITLY USING REGISTER 0x05 (UNTESTED)
701 * mode 9 => USE AUTOMATIC GAIN CONTROL (DEFAULT)
704 /*---------------------------------------------------------------------------*/
706 select_input(struct usb_device
*p
, int input
, int mode
)
716 if (0 != write_saa(p
, 0x02, 0x80)) {
717 SAY("ERROR: failed to set SAA register 0x02 for input %i\n",
720 SET(p
, 0x0000, 0x0098);
721 SET(p
, 0x0002, 0x0078);
725 if (0 != write_saa(p
, 0x02, 0x80)) {
726 SAY("ERROR: failed to set SAA register 0x02 for input %i\n",
729 SET(p
, 0x0000, 0x0090);
730 SET(p
, 0x0002, 0x0078);
734 if (0 != write_saa(p
, 0x02, 0x80)) {
735 SAY("ERROR: failed to set SAA register 0x02 for input %i\n",
738 SET(p
, 0x0000, 0x0088);
739 SET(p
, 0x0002, 0x0078);
743 if (0 != write_saa(p
, 0x02, 0x80)) {
744 SAY("ERROR: failed to set SAA register 0x02 for input %i\n",
747 SET(p
, 0x0000, 0x0080);
748 SET(p
, 0x0002, 0x0078);
756 if (0 != write_saa(p
, 0x02, 0x87)) {
757 SAY("ERROR: failed to set SAA register 0x02 "
758 "for input %i\n", input
);
760 if (0 != write_saa(p
, 0x05, 0xFF)) {
761 SAY("ERROR: failed to set SAA register 0x05 "
762 "for input %i\n", input
);
767 if (0 != write_saa(p
, 0x02, 0x89)) {
768 SAY("ERROR: failed to set SAA register 0x02 "
769 "for input %i\n", input
);
771 if (0 != write_saa(p
, 0x05, 0x00)) {
772 SAY("ERROR: failed to set SAA register 0x05 "
773 "for input %i\n", input
);
778 SAY("MISTAKE: bad mode: %i\n", mode
);
782 if (0 != write_saa(p
, 0x04, 0x00)) {
783 SAY("ERROR: failed to set SAA register 0x04 for input %i\n",
786 if (0 != write_saa(p
, 0x09, 0x80)) {
787 SAY("ERROR: failed to set SAA register 0x09 for input %i\n",
790 SET(p
, 0x0002, 0x0093);
794 SAY("ERROR: bad input: %i\n", input
);
798 ir
= read_stk(p
, 0x00);
799 JOT(8, "STK register 0x00 has 0x%02X\n", ir
);
800 ir
= read_saa(p
, 0x02);
801 JOT(8, "SAA register 0x02 has 0x%02X\n", ir
);
807 /****************************************************************************/
809 set_resolution(struct usb_device
*p
,
810 u16 set0
, u16 set1
, u16 set2
, u16 set3
)
812 u16 u0x0111
, u0x0113
, u0x0115
, u0x0117
;
816 u0x0111
= ((0xFF00 & set0
) >> 8);
817 u0x0113
= ((0xFF00 & set1
) >> 8);
818 u0x0115
= ((0xFF00 & set2
) >> 8);
819 u0x0117
= ((0xFF00 & set3
) >> 8);
821 SET(p
, 0x0110, (0x00FF & set0
));
822 SET(p
, 0x0111, u0x0111
);
823 SET(p
, 0x0112, (0x00FF & set1
));
824 SET(p
, 0x0113, u0x0113
);
825 SET(p
, 0x0114, (0x00FF & set2
));
826 SET(p
, 0x0115, u0x0115
);
827 SET(p
, 0x0116, (0x00FF & set3
));
828 SET(p
, 0x0117, u0x0117
);
832 /****************************************************************************/
834 start_100(struct usb_device
*p
)
836 u16 get116
, get117
, get0
;
837 u8 igot116
, igot117
, igot
;
841 GET(p
, 0x0116, &igot116
);
843 GET(p
, 0x0117, &igot117
);
845 SET(p
, 0x0116, 0x0000);
846 SET(p
, 0x0117, 0x0000);
848 GET(p
, 0x0100, &igot
);
850 SET(p
, 0x0100, (0x80 | get0
));
852 SET(p
, 0x0116, get116
);
853 SET(p
, 0x0117, get117
);
857 /****************************************************************************/
859 stop_100(struct usb_device
*p
)
866 GET(p
, 0x0100, &igot
);
868 SET(p
, 0x0100, (0x7F & get0
));
871 /****************************************************************************/
872 /*--------------------------------------------------------------------------*/
874 * FUNCTION wait_i2c() RETURNS 0 ON SUCCESS
876 /*--------------------------------------------------------------------------*/
878 wait_i2c(struct usb_device
*p
)
887 for (k
= 0; k
< max
; k
++) {
888 GET(p
, 0x0201, &igot
); get0
= igot
;
905 /****************************************************************************/
907 regset(struct usb_device
*pusb_device
, u16 index
, u16 value
)
915 rc0
= usb_control_msg(pusb_device
, usb_sndctrlpipe(pusb_device
, 0),
917 (u8
)(USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
),
927 rc1
= usb_control_msg(pusb_device
, usb_rcvctrlpipe(pusb_device
, 0),
929 (u8
)(USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
),
950 if (0 != (0xFF & igot
)) {
951 JOT(8, "unexpected 0x%02X for STK register 0x%03X\n",
957 if ((0xFF & value
) != (0xFF & igot
)) {
958 JOT(8, "unexpected 0x%02X != 0x%02X "
959 "for STK register 0x%03X\n",
965 #endif /* ! NOREADBACK*/
967 return (0 > rc0
) ? rc0
: rc1
;
969 /*****************************************************************************/
971 regget(struct usb_device
*pusb_device
, u16 index
, void *pvoid
)
977 ir
= usb_control_msg(pusb_device
, usb_rcvctrlpipe(pusb_device
, 0),
979 (u8
)(USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
),
987 /*****************************************************************************/
989 wakeup_device(struct usb_device
*pusb_device
)
993 return usb_control_msg(pusb_device
, usb_sndctrlpipe(pusb_device
, 0),
994 (u8
)USB_REQ_SET_FEATURE
,
995 (u8
)(USB_DIR_OUT
| USB_TYPE_STANDARD
| USB_RECIP_DEVICE
),
996 USB_DEVICE_REMOTE_WAKEUP
,
1002 /*****************************************************************************/
1004 audio_setup(struct easycap
*peasycap
)
1006 struct usb_device
*pusb_device
;
1007 unsigned char buffer
[1];
1009 /*---------------------------------------------------------------------------*/
1012 * THE MESSAGE OF TYPE (USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE)
1013 * CAUSES MUTING IF THE VALUE 0x0100 IS SENT.
1014 * TO ENABLE AUDIO THE VALUE 0x0200 MUST BE SENT.
1016 /*---------------------------------------------------------------------------*/
1017 const u8 request
= 0x01;
1018 const u8 requesttype
=
1019 (u8
)(USB_DIR_OUT
| USB_TYPE_CLASS
| USB_RECIP_INTERFACE
);
1020 const u16 value_unmute
= 0x0200;
1021 const u16 index
= 0x0301;
1022 const u16 length
= 1;
1024 if (NULL
== peasycap
)
1027 pusb_device
= peasycap
->pusb_device
;
1028 if (NULL
== pusb_device
)
1031 JOM(8, "%02X %02X %02X %02X %02X %02X %02X %02X\n",
1032 requesttype
, request
,
1033 (0x00FF & value_unmute
),
1034 (0xFF00 & value_unmute
) >> 8,
1036 (0xFF00 & index
) >> 8,
1038 (0xFF00 & length
) >> 8);
1042 rc
= usb_control_msg(pusb_device
, usb_sndctrlpipe(pusb_device
, 0),
1051 JOT(8, "0x%02X=buffer\n", *((u8
*) &buffer
[0]));
1052 if (rc
!= (int)length
) {
1055 SAY("usb_control_msg returned -EPIPE\n");
1059 SAY("ERROR: usb_control_msg returned %i\n", rc
);
1064 /*--------------------------------------------------------------------------*/
1066 * REGISTER 500: SETTING VALUE TO 0x0094 RESETS AUDIO CONFIGURATION ???
1067 * REGISTER 506: ANALOGUE AUDIO ATTENTUATOR ???
1068 * FOR THE CVBS+S-VIDEO HARDWARE:
1069 * SETTING VALUE TO 0x0000 GIVES QUIET SOUND.
1070 * THE UPPER BYTE SEEMS TO HAVE NO EFFECT.
1071 * FOR THE FOUR-CVBS HARDWARE:
1072 * SETTING VALUE TO 0x0000 SEEMS TO HAVE NO EFFECT.
1073 * REGISTER 507: ANALOGUE AUDIO PREAMPLIFIER ON/OFF ???
1074 * FOR THE CVBS-S-VIDEO HARDWARE:
1075 * SETTING VALUE TO 0x0001 GIVES VERY LOUD, DISTORTED SOUND.
1076 * THE UPPER BYTE SEEMS TO HAVE NO EFFECT.
1078 /*--------------------------------------------------------------------------*/
1079 SET(pusb_device
, 0x0500, 0x0094);
1080 SET(pusb_device
, 0x0500, 0x008C);
1081 SET(pusb_device
, 0x0506, 0x0001);
1082 SET(pusb_device
, 0x0507, 0x0000);
1083 id1
= read_vt(pusb_device
, 0x007C);
1084 id2
= read_vt(pusb_device
, 0x007E);
1085 SAM("0x%04X:0x%04X is audio vendor id\n", id1
, id2
);
1086 /*---------------------------------------------------------------------------*/
1088 * SELECT AUDIO SOURCE "LINE IN" AND SET THE AUDIO GAIN.
1090 /*---------------------------------------------------------------------------*/
1091 if (0 != audio_gainset(pusb_device
, peasycap
->gain
))
1092 SAY("ERROR: audio_gainset() failed\n");
1093 check_vt(pusb_device
);
1096 /*****************************************************************************/
1098 check_vt(struct usb_device
*pusb_device
)
1104 igot
= read_vt(pusb_device
, 0x0002);
1106 SAY("ERROR: failed to read VT1612A register 0x02\n");
1108 SAY("register 0x%02X muted\n", 0x02);
1110 igot
= read_vt(pusb_device
, 0x000E);
1112 SAY("ERROR: failed to read VT1612A register 0x0E\n");
1114 SAY("register 0x%02X muted\n", 0x0E);
1116 igot
= read_vt(pusb_device
, 0x0010);
1118 SAY("ERROR: failed to read VT1612A register 0x10\n");
1120 SAY("register 0x%02X muted\n", 0x10);
1122 igot
= read_vt(pusb_device
, 0x0012);
1124 SAY("ERROR: failed to read VT1612A register 0x12\n");
1126 SAY("register 0x%02X muted\n", 0x12);
1128 igot
= read_vt(pusb_device
, 0x0014);
1130 SAY("ERROR: failed to read VT1612A register 0x14\n");
1132 SAY("register 0x%02X muted\n", 0x14);
1134 igot
= read_vt(pusb_device
, 0x0016);
1136 SAY("ERROR: failed to read VT1612A register 0x16\n");
1138 SAY("register 0x%02X muted\n", 0x16);
1140 igot
= read_vt(pusb_device
, 0x0018);
1142 SAY("ERROR: failed to read VT1612A register 0x18\n");
1144 SAY("register 0x%02X muted\n", 0x18);
1146 igot
= read_vt(pusb_device
, 0x001C);
1148 SAY("ERROR: failed to read VT1612A register 0x1C\n");
1150 SAY("register 0x%02X muted\n", 0x1C);
1154 /*****************************************************************************/
1155 /*---------------------------------------------------------------------------*/
1156 /* NOTE: THIS DOES INCREASE THE VOLUME DRAMATICALLY:
1157 * audio_gainset(pusb_device, 0x000F);
1159 * loud dB register 0x10 dB register 0x1C dB total
1168 /*---------------------------------------------------------------------------*/
1170 audio_gainset(struct usb_device
*pusb_device
, s8 loud
)
1176 if (NULL
== pusb_device
)
1183 write_vt(pusb_device
, 0x0002, 0x8000);
1184 /*---------------------------------------------------------------------------*/
1185 igot
= read_vt(pusb_device
, 0x000E);
1187 SAY("ERROR: failed to read VT1612A register 0x0E\n");
1190 mute
= 0x8000 & ((unsigned int)igot
);
1194 tmp
= 0x01 | (0x001F & (((u8
)(15 - loud
)) << 1));
1198 JOT(8, "0x%04X=(mute|tmp) for VT1612A register 0x0E\n", mute
| tmp
);
1199 write_vt(pusb_device
, 0x000E, (mute
| tmp
));
1200 /*---------------------------------------------------------------------------*/
1201 igot
= read_vt(pusb_device
, 0x0010);
1203 SAY("ERROR: failed to read VT1612A register 0x10\n");
1206 mute
= 0x8000 & ((unsigned int)igot
);
1209 JOT(8, "0x%04X=(mute|tmp|(tmp<<8)) for VT1612A register 0x10,...0x18\n",
1210 mute
| tmp
| (tmp
<< 8));
1211 write_vt(pusb_device
, 0x0010, (mute
| tmp
| (tmp
<< 8)));
1212 write_vt(pusb_device
, 0x0012, (mute
| tmp
| (tmp
<< 8)));
1213 write_vt(pusb_device
, 0x0014, (mute
| tmp
| (tmp
<< 8)));
1214 write_vt(pusb_device
, 0x0016, (mute
| tmp
| (tmp
<< 8)));
1215 write_vt(pusb_device
, 0x0018, (mute
| tmp
| (tmp
<< 8)));
1216 /*---------------------------------------------------------------------------*/
1217 igot
= read_vt(pusb_device
, 0x001C);
1219 SAY("ERROR: failed to read VT1612A register 0x1C\n");
1222 mute
= 0x8000 & ((unsigned int)igot
);
1226 tmp
= 0x000F & (u8
)(loud
- 16);
1230 JOT(8, "0x%04X=(mute|tmp|(tmp<<8)) for VT1612A register 0x1C\n",
1231 mute
| tmp
| (tmp
<< 8));
1232 write_vt(pusb_device
, 0x001C, (mute
| tmp
| (tmp
<< 8)));
1233 write_vt(pusb_device
, 0x001A, 0x0404);
1234 write_vt(pusb_device
, 0x0002, 0x0000);
1237 /*****************************************************************************/
1239 audio_gainget(struct usb_device
*pusb_device
)
1243 if (NULL
== pusb_device
)
1245 igot
= read_vt(pusb_device
, 0x001C);
1247 SAY("ERROR: failed to read VT1612A register 0x1C\n");
1250 /*****************************************************************************/