Commit 72075789 authored by Tomas Winkler's avatar Tomas Winkler Committed by Greg Kroah-Hartman

staging/easycap: add first level indetnation for easycap_low.c

Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Reviewed-by: default avatarDan Carpenter <error27@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 1b3909e5
...@@ -326,136 +326,132 @@ static int regset(struct usb_device *pusb_device, u16 index, u16 value) ...@@ -326,136 +326,132 @@ static int regset(struct usb_device *pusb_device, u16 index, u16 value)
/*****************************************************************************/ /*****************************************************************************/
/****************************************************************************/ /****************************************************************************/
int int confirm_resolution(struct usb_device *p)
confirm_resolution(struct usb_device *p)
{ {
u8 get0, get1, get2, get3, get4, get5, get6, get7; u8 get0, get1, get2, get3, get4, get5, get6, get7;
if (NULL == p) if (NULL == p)
return -ENODEV; return -ENODEV;
GET(p, 0x0110, &get0); GET(p, 0x0110, &get0);
GET(p, 0x0111, &get1); GET(p, 0x0111, &get1);
GET(p, 0x0112, &get2); GET(p, 0x0112, &get2);
GET(p, 0x0113, &get3); GET(p, 0x0113, &get3);
GET(p, 0x0114, &get4); GET(p, 0x0114, &get4);
GET(p, 0x0115, &get5); GET(p, 0x0115, &get5);
GET(p, 0x0116, &get6); GET(p, 0x0116, &get6);
GET(p, 0x0117, &get7); GET(p, 0x0117, &get7);
JOT(8, "0x%03X, 0x%03X, " JOT(8, "0x%03X, 0x%03X, "
"0x%03X, 0x%03X, " "0x%03X, 0x%03X, "
"0x%03X, 0x%03X, " "0x%03X, 0x%03X, "
"0x%03X, 0x%03X\n", "0x%03X, 0x%03X\n",
get0, get1, get2, get3, get4, get5, get6, get7); get0, get1, get2, get3, get4, get5, get6, get7);
JOT(8, "....cf PAL_720x526: " JOT(8, "....cf PAL_720x526: "
"0x%03X, 0x%03X, " "0x%03X, 0x%03X, "
"0x%03X, 0x%03X, " "0x%03X, 0x%03X, "
"0x%03X, 0x%03X, " "0x%03X, 0x%03X, "
"0x%03X, 0x%03X\n", "0x%03X, 0x%03X\n",
0x000, 0x000, 0x001, 0x000, 0x5A0, 0x005, 0x121, 0x001); 0x000, 0x000, 0x001, 0x000, 0x5A0, 0x005, 0x121, 0x001);
JOT(8, "....cf PAL_704x526: " JOT(8, "....cf PAL_704x526: "
"0x%03X, 0x%03X, " "0x%03X, 0x%03X, "
"0x%03X, 0x%03X, " "0x%03X, 0x%03X, "
"0x%03X, 0x%03X, " "0x%03X, 0x%03X, "
"0x%03X, 0x%03X\n", "0x%03X, 0x%03X\n",
0x004, 0x000, 0x001, 0x000, 0x584, 0x005, 0x121, 0x001); 0x004, 0x000, 0x001, 0x000, 0x584, 0x005, 0x121, 0x001);
JOT(8, "....cf VGA_640x480: " JOT(8, "....cf VGA_640x480: "
"0x%03X, 0x%03X, " "0x%03X, 0x%03X, "
"0x%03X, 0x%03X, " "0x%03X, 0x%03X, "
"0x%03X, 0x%03X, " "0x%03X, 0x%03X, "
"0x%03X, 0x%03X\n", "0x%03X, 0x%03X\n",
0x008, 0x000, 0x020, 0x000, 0x508, 0x005, 0x110, 0x001); 0x008, 0x000, 0x020, 0x000, 0x508, 0x005, 0x110, 0x001);
return 0; return 0;
} }
/****************************************************************************/ /****************************************************************************/
int int confirm_stream(struct usb_device *p)
confirm_stream(struct usb_device *p)
{ {
u16 get2; u16 get2;
u8 igot; u8 igot;
if (NULL == p) if (NULL == p)
return -ENODEV; return -ENODEV;
GET(p, 0x0100, &igot); get2 = 0x80 & igot; GET(p, 0x0100, &igot); get2 = 0x80 & igot;
if (0x80 == get2) if (0x80 == get2)
JOT(8, "confirm_stream: OK\n"); JOT(8, "confirm_stream: OK\n");
else else
JOT(8, "confirm_stream: STUCK\n"); JOT(8, "confirm_stream: STUCK\n");
return 0; return 0;
} }
/****************************************************************************/ /****************************************************************************/
int int setup_stk(struct usb_device *p, bool ntsc)
setup_stk(struct usb_device *p, bool ntsc)
{ {
int i0; int i0;
if (NULL == p) if (NULL == p)
return -ENODEV; return -ENODEV;
i0 = 0; i0 = 0;
if (true == ntsc) { if (true == ntsc) {
while (0xFFF != stk1160configNTSC[i0].reg) { while (0xFFF != stk1160configNTSC[i0].reg) {
SET(p, stk1160configNTSC[i0].reg, stk1160configNTSC[i0].set); SET(p, stk1160configNTSC[i0].reg,
i0++; stk1160configNTSC[i0].set);
} i0++;
} else { }
while (0xFFF != stk1160configPAL[i0].reg) { } else {
SET(p, stk1160configPAL[i0].reg, stk1160configPAL[i0].set); while (0xFFF != stk1160configPAL[i0].reg) {
i0++; SET(p, stk1160configPAL[i0].reg,
stk1160configPAL[i0].set);
i0++;
}
} }
}
write_300(p); write_300(p);
return 0; return 0;
} }
/****************************************************************************/ /****************************************************************************/
int int setup_saa(struct usb_device *p, bool ntsc)
setup_saa(struct usb_device *p, bool ntsc)
{ {
int i0, ir; int i0, ir;
if (NULL == p) if (NULL == p)
return -ENODEV; return -ENODEV;
i0 = 0; i0 = 0;
if (true == ntsc) { if (true == ntsc) {
while (0xFF != saa7113configNTSC[i0].reg) { while (0xFF != saa7113configNTSC[i0].reg) {
ir = write_saa(p, saa7113configNTSC[i0].reg, ir = write_saa(p, saa7113configNTSC[i0].reg,
saa7113configNTSC[i0].set); saa7113configNTSC[i0].set);
i0++; i0++;
} }
} else { } else {
while (0xFF != saa7113configPAL[i0].reg) { while (0xFF != saa7113configPAL[i0].reg) {
ir = write_saa(p, saa7113configPAL[i0].reg, ir = write_saa(p, saa7113configPAL[i0].reg,
saa7113configPAL[i0].set); saa7113configPAL[i0].set);
i0++; i0++;
}
} }
} return 0;
return 0;
} }
/****************************************************************************/ /****************************************************************************/
int int write_000(struct usb_device *p, u16 set2, u16 set0)
write_000(struct usb_device *p, u16 set2, u16 set0)
{ {
u8 igot0, igot2; u8 igot0, igot2;
if (NULL == p) if (NULL == p)
return -ENODEV; return -ENODEV;
GET(p, 0x0002, &igot2); GET(p, 0x0002, &igot2);
GET(p, 0x0000, &igot0); GET(p, 0x0000, &igot0);
SET(p, 0x0002, set2); SET(p, 0x0002, set2);
SET(p, 0x0000, set0); SET(p, 0x0000, set0);
return 0; return 0;
} }
/****************************************************************************/ /****************************************************************************/
int int write_saa(struct usb_device *p, u16 reg0, u16 set0)
write_saa(struct usb_device *p, u16 reg0, u16 set0)
{ {
if (NULL == p) if (NULL == p)
return -ENODEV; return -ENODEV;
SET(p, 0x200, 0x00); SET(p, 0x200, 0x00);
SET(p, 0x204, reg0); SET(p, 0x204, reg0);
SET(p, 0x205, set0); SET(p, 0x205, set0);
SET(p, 0x200, 0x01); SET(p, 0x200, 0x01);
return wait_i2c(p); return wait_i2c(p);
} }
/****************************************************************************/ /****************************************************************************/
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
...@@ -470,30 +466,30 @@ return wait_i2c(p); ...@@ -470,30 +466,30 @@ return wait_i2c(p);
int int
write_vt(struct usb_device *p, u16 reg0, u16 set0) write_vt(struct usb_device *p, u16 reg0, u16 set0)
{ {
u8 igot; u8 igot;
u16 got502, got503; u16 got502, got503;
u16 set502, set503; u16 set502, set503;
if (NULL == p) if (NULL == p)
return -ENODEV; return -ENODEV;
SET(p, 0x0504, reg0); SET(p, 0x0504, reg0);
SET(p, 0x0500, 0x008B); SET(p, 0x0500, 0x008B);
GET(p, 0x0502, &igot); got502 = (0xFF & igot); GET(p, 0x0502, &igot); got502 = (0xFF & igot);
GET(p, 0x0503, &igot); got503 = (0xFF & igot); GET(p, 0x0503, &igot); got503 = (0xFF & igot);
JOT(16, "write_vt(., 0x%04X, 0x%04X): was 0x%04X\n", JOT(16, "write_vt(., 0x%04X, 0x%04X): was 0x%04X\n",
reg0, set0, ((got503 << 8) | got502)); reg0, set0, ((got503 << 8) | got502));
set502 = (0x00FF & set0); set502 = (0x00FF & set0);
set503 = ((0xFF00 & set0) >> 8); set503 = ((0xFF00 & set0) >> 8);
SET(p, 0x0504, reg0); SET(p, 0x0504, reg0);
SET(p, 0x0502, set502); SET(p, 0x0502, set502);
SET(p, 0x0503, set503); SET(p, 0x0503, set503);
SET(p, 0x0500, 0x008C); SET(p, 0x0500, 0x008C);
return 0; return 0;
} }
/****************************************************************************/ /****************************************************************************/
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
...@@ -505,23 +501,23 @@ return 0; ...@@ -505,23 +501,23 @@ return 0;
* REGISTER 504: TARGET ADDRESS ON VT1612A * REGISTER 504: TARGET ADDRESS ON VT1612A
*/ */
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
int int read_vt(struct usb_device *p, u16 reg0)
read_vt(struct usb_device *p, u16 reg0)
{ {
u8 igot; u8 igot;
u16 got502, got503; u16 got502, got503;
if (NULL == p) if (NULL == p)
return -ENODEV; return -ENODEV;
SET(p, 0x0504, reg0); SET(p, 0x0504, reg0);
SET(p, 0x0500, 0x008B); SET(p, 0x0500, 0x008B);
GET(p, 0x0502, &igot); got502 = (0xFF & igot); GET(p, 0x0502, &igot); got502 = (0xFF & igot);
GET(p, 0x0503, &igot); got503 = (0xFF & igot); GET(p, 0x0503, &igot); got503 = (0xFF & igot);
JOT(16, "read_vt(., 0x%04X): has 0x%04X\n", reg0, ((got503 << 8) | got502)); JOT(16, "read_vt(., 0x%04X): has 0x%04X\n",
reg0, ((got503 << 8) | got502));
return (got503 << 8) | got502; return (got503 << 8) | got502;
} }
/****************************************************************************/ /****************************************************************************/
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
...@@ -529,18 +525,17 @@ return (got503 << 8) | got502; ...@@ -529,18 +525,17 @@ return (got503 << 8) | got502;
* THESE APPEAR TO HAVE NO EFFECT ON EITHER VIDEO OR AUDIO. * THESE APPEAR TO HAVE NO EFFECT ON EITHER VIDEO OR AUDIO.
*/ */
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
int int write_300(struct usb_device *p)
write_300(struct usb_device *p)
{ {
if (NULL == p) if (NULL == p)
return -ENODEV; return -ENODEV;
SET(p, 0x300, 0x0012); SET(p, 0x300, 0x0012);
SET(p, 0x350, 0x002D); SET(p, 0x350, 0x002D);
SET(p, 0x351, 0x0001); SET(p, 0x351, 0x0001);
SET(p, 0x352, 0x0000); SET(p, 0x352, 0x0000);
SET(p, 0x353, 0x0000); SET(p, 0x353, 0x0000);
SET(p, 0x300, 0x0080); SET(p, 0x300, 0x0080);
return 0; return 0;
} }
/****************************************************************************/ /****************************************************************************/
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
...@@ -549,75 +544,72 @@ return 0; ...@@ -549,75 +544,72 @@ return 0;
* REGISTER 0x0F, WHICH IS INVOLVED IN CHROMINANCE AUTOMATIC GAIN CONTROL. * REGISTER 0x0F, WHICH IS INVOLVED IN CHROMINANCE AUTOMATIC GAIN CONTROL.
*/ */
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
int int check_saa(struct usb_device *p, bool ntsc)
check_saa(struct usb_device *p, bool ntsc)
{ {
int i0, ir, rc; int i0, ir, rc;
if (NULL == p)
return -ENODEV;
i0 = 0;
rc = 0;
if (true == ntsc) {
while (0xFF != saa7113configNTSC[i0].reg) {
if (0x0F == saa7113configNTSC[i0].reg) {
i0++;
continue;
}
ir = read_saa(p, saa7113configNTSC[i0].reg); if (NULL == p)
if (ir != saa7113configNTSC[i0].set) { return -ENODEV;
SAY("SAA register 0x%02X has 0x%02X, " i0 = 0;
rc = 0;
if (true == ntsc) {
while (0xFF != saa7113configNTSC[i0].reg) {
if (0x0F == saa7113configNTSC[i0].reg) {
i0++;
continue;
}
ir = read_saa(p, saa7113configNTSC[i0].reg);
if (ir != saa7113configNTSC[i0].set) {
SAY("SAA register 0x%02X has 0x%02X, "
"expected 0x%02X\n", "expected 0x%02X\n",
saa7113configNTSC[i0].reg, saa7113configNTSC[i0].reg,
ir, saa7113configNTSC[i0].set); ir, saa7113configNTSC[i0].set);
rc--; rc--;
} }
i0++;
}
} else {
while (0xFF != saa7113configPAL[i0].reg) {
if (0x0F == saa7113configPAL[i0].reg) {
i0++; i0++;
continue;
} }
} else {
while (0xFF != saa7113configPAL[i0].reg) {
if (0x0F == saa7113configPAL[i0].reg) {
i0++;
continue;
}
ir = read_saa(p, saa7113configPAL[i0].reg); ir = read_saa(p, saa7113configPAL[i0].reg);
if (ir != saa7113configPAL[i0].set) { if (ir != saa7113configPAL[i0].set) {
SAY("SAA register 0x%02X has 0x%02X, " SAY("SAA register 0x%02X has 0x%02X, "
"expected 0x%02X\n", "expected 0x%02X\n",
saa7113configPAL[i0].reg, saa7113configPAL[i0].reg,
ir, saa7113configPAL[i0].set); ir, saa7113configPAL[i0].set);
rc--; rc--;
}
i0++;
} }
i0++;
} }
} if (-8 > rc)
if (-8 > rc) return rc;
return rc; else
else return 0;
return 0;
} }
/****************************************************************************/ /****************************************************************************/
int int merit_saa(struct usb_device *p)
merit_saa(struct usb_device *p)
{ {
int rc; int rc;
if (NULL == p) if (NULL == p)
return -ENODEV; return -ENODEV;
rc = read_saa(p, 0x1F); rc = read_saa(p, 0x1F);
if ((0 > rc) || (0x02 & rc)) if ((0 > rc) || (0x02 & rc))
return 1 ; return 1 ;
else else
return 0; return 0;
} }
/****************************************************************************/ /****************************************************************************/
int int ready_saa(struct usb_device *p)
ready_saa(struct usb_device *p)
{ {
int j, rc, rate; int j, rc, rate;
const int max = 5, marktime = PATIENCE/5; const int max = 5, marktime = PATIENCE/5;
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/* /*
* RETURNS 0 FOR INTERLACED 50 Hz * RETURNS 0 FOR INTERLACED 50 Hz
...@@ -626,38 +618,38 @@ const int max = 5, marktime = PATIENCE/5; ...@@ -626,38 +618,38 @@ const int max = 5, marktime = PATIENCE/5;
* 3 FOR NON-INTERLACED 60 Hz * 3 FOR NON-INTERLACED 60 Hz
*/ */
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
if (NULL == p) if (NULL == p)
return -ENODEV; return -ENODEV;
j = 0; j = 0;
while (max > j) { while (max > j) {
rc = read_saa(p, 0x1F); rc = read_saa(p, 0x1F);
if (0 <= rc) { if (0 <= rc) {
if (0 == (0x40 & rc)) if (0 == (0x40 & rc))
break; break;
if (1 == (0x01 & rc)) if (1 == (0x01 & rc))
break; break;
} }
msleep(marktime); msleep(marktime);
j++; j++;
}
if (max == j)
return -1;
else {
if (0x20 & rc) {
rate = 2;
JOT(8, "hardware detects 60 Hz\n");
} else {
rate = 0;
JOT(8, "hardware detects 50 Hz\n");
} }
if (0x80 & rc) if (max == j)
JOT(8, "hardware detects interlacing\n"); return -1;
else { else {
rate++; if (0x20 & rc) {
JOT(8, "hardware detects no interlacing\n"); rate = 2;
JOT(8, "hardware detects 60 Hz\n");
} else {
rate = 0;
JOT(8, "hardware detects 50 Hz\n");
}
if (0x80 & rc)
JOT(8, "hardware detects interlacing\n");
else {
rate++;
JOT(8, "hardware detects no interlacing\n");
}
} }
} return 0;
return 0;
} }
/****************************************************************************/ /****************************************************************************/
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
...@@ -667,106 +659,101 @@ return 0; ...@@ -667,106 +659,101 @@ return 0;
* REGISTER 0x100: ACCEPT ALSO (0x80 | stk1160config....[.].set) * REGISTER 0x100: ACCEPT ALSO (0x80 | stk1160config....[.].set)
*/ */
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
int int check_stk(struct usb_device *p, bool ntsc)
check_stk(struct usb_device *p, bool ntsc)
{ {
int i0, ir; int i0, ir;
if (NULL == p) if (NULL == p)
return -ENODEV; return -ENODEV;
i0 = 0; i0 = 0;
if (true == ntsc) { if (true == ntsc) {
while (0xFFF != stk1160configNTSC[i0].reg) { while (0xFFF != stk1160configNTSC[i0].reg) {
if (0x000 == stk1160configNTSC[i0].reg) { if (0x000 == stk1160configNTSC[i0].reg) {
i0++; continue; i0++; continue;
} }
if (0x002 == stk1160configNTSC[i0].reg) { if (0x002 == stk1160configNTSC[i0].reg) {
i0++; continue; i0++; continue;
} }
ir = read_stk(p, stk1160configNTSC[i0].reg); ir = read_stk(p, stk1160configNTSC[i0].reg);
if (0x100 == stk1160configNTSC[i0].reg) { if (0x100 == stk1160configNTSC[i0].reg) {
if ((ir != (0xFF & stk1160configNTSC[i0].set)) && if ((ir != (0xFF & stk1160configNTSC[i0].set)) &&
(ir != (0x80 | (0xFF & (ir != (0x80 | (0xFF & stk1160configNTSC[i0].set))) &&
stk1160configNTSC[i0].set))) && (0xFFFF != stk1160configNTSC[i0].set)) {
(0xFFFF != SAY("STK register 0x%03X has 0x%02X, "
stk1160configNTSC[i0].set)) {
SAY("STK register 0x%03X has 0x%02X, "
"expected 0x%02X\n", "expected 0x%02X\n",
stk1160configNTSC[i0].reg, stk1160configNTSC[i0].reg,
ir, stk1160configNTSC[i0].set); ir, stk1160configNTSC[i0].set);
}
i0++; continue;
} }
i0++; continue; if ((ir != (0xFF & stk1160configNTSC[i0].set)) &&
} (0xFFFF != stk1160configNTSC[i0].set)) {
if ((ir != (0xFF & stk1160configNTSC[i0].set)) && SAY("STK register 0x%03X has 0x%02X, "
(0xFFFF != stk1160configNTSC[i0].set)) {
SAY("STK register 0x%03X has 0x%02X, "
"expected 0x%02X\n", "expected 0x%02X\n",
stk1160configNTSC[i0].reg, stk1160configNTSC[i0].reg,
ir, stk1160configNTSC[i0].set); ir, stk1160configNTSC[i0].set);
}
i0++;
} }
i0++; } else {
} while (0xFFF != stk1160configPAL[i0].reg) {
} else { if (0x000 == stk1160configPAL[i0].reg) {
while (0xFFF != stk1160configPAL[i0].reg) { i0++; continue;
if (0x000 == stk1160configPAL[i0].reg) { }
i0++; continue; if (0x002 == stk1160configPAL[i0].reg) {
} i0++; continue;
if (0x002 == stk1160configPAL[i0].reg) { }
i0++; continue; ir = read_stk(p, stk1160configPAL[i0].reg);
} if (0x100 == stk1160configPAL[i0].reg) {
ir = read_stk(p, stk1160configPAL[i0].reg); if ((ir != (0xFF & stk1160configPAL[i0].set)) &&
if (0x100 == stk1160configPAL[i0].reg) { (ir != (0x80 | (0xFF &
if ((ir != (0xFF & stk1160configPAL[i0].set)) && stk1160configPAL[i0].set))) &&
(ir != (0x80 | (0xFF & (0xFFFF !=
stk1160configPAL[i0].set))) && stk1160configPAL[i0].set)) {
(0xFFFF != SAY("STK register 0x%03X has 0x%02X, "
stk1160configPAL[i0].set)) {
SAY("STK register 0x%03X has 0x%02X, "
"expected 0x%02X\n", "expected 0x%02X\n",
stk1160configPAL[i0].reg, stk1160configPAL[i0].reg,
ir, stk1160configPAL[i0].set); ir, stk1160configPAL[i0].set);
}
i0++; continue;
} }
i0++; continue; if ((ir != (0xFF & stk1160configPAL[i0].set)) &&
} (0xFFFF != stk1160configPAL[i0].set)) {
if ((ir != (0xFF & stk1160configPAL[i0].set)) && SAY("STK register 0x%03X has 0x%02X, "
(0xFFFF != stk1160configPAL[i0].set)) {
SAY("STK register 0x%03X has 0x%02X, "
"expected 0x%02X\n", "expected 0x%02X\n",
stk1160configPAL[i0].reg, stk1160configPAL[i0].reg,
ir, stk1160configPAL[i0].set); ir, stk1160configPAL[i0].set);
}
i0++;
} }
i0++;
} }
} return 0;
return 0;
} }
/****************************************************************************/ /****************************************************************************/
int int read_saa(struct usb_device *p, u16 reg0)
read_saa(struct usb_device *p, u16 reg0)
{ {
u8 igot; u8 igot;
if (NULL == p) if (NULL == p)
return -ENODEV; return -ENODEV;
SET(p, 0x208, reg0); SET(p, 0x208, reg0);
SET(p, 0x200, 0x20); SET(p, 0x200, 0x20);
if (0 != wait_i2c(p)) if (0 != wait_i2c(p))
return -1; return -1;
igot = 0; igot = 0;
GET(p, 0x0209, &igot); GET(p, 0x0209, &igot);
return igot; return igot;
} }
/****************************************************************************/ /****************************************************************************/
int int read_stk(struct usb_device *p, u32 reg0)
read_stk(struct usb_device *p, u32 reg0)
{ {
u8 igot; u8 igot;
if (NULL == p) if (NULL == p)
return -ENODEV; return -ENODEV;
igot = 0; igot = 0;
GET(p, reg0, &igot); GET(p, reg0, &igot);
return igot; return igot;
} }
/****************************************************************************/ /****************************************************************************/
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
...@@ -790,168 +777,165 @@ return igot; ...@@ -790,168 +777,165 @@ return igot;
int int
select_input(struct usb_device *p, int input, int mode) select_input(struct usb_device *p, int input, int mode)
{ {
int ir; int ir;
if (NULL == p) if (NULL == p)
return -ENODEV; return -ENODEV;
stop_100(p); stop_100(p);
switch (input) { switch (input) {
case 0: case 0:
case 1: { case 1: {
if (0 != write_saa(p, 0x02, 0x80)) { if (0 != write_saa(p, 0x02, 0x80)) {
SAY("ERROR: failed to set SAA register 0x02 for input %i\n",
input);
}
SET(p, 0x0000, 0x0098);
SET(p, 0x0002, 0x0078);
break;
}
case 2: {
if (0 != write_saa(p, 0x02, 0x80)) {
SAY("ERROR: failed to set SAA register 0x02 for input %i\n",
input);
}
SET(p, 0x0000, 0x0090);
SET(p, 0x0002, 0x0078);
break;
}
case 3: {
if (0 != write_saa(p, 0x02, 0x80)) {
SAY("ERROR: failed to set SAA register 0x02 for input %i\n",
input);
}
SET(p, 0x0000, 0x0088);
SET(p, 0x0002, 0x0078);
break;
}
case 4: {
if (0 != write_saa(p, 0x02, 0x80)) {
SAY("ERROR: failed to set SAA register 0x02 for input %i\n",
input);
}
SET(p, 0x0000, 0x0080);
SET(p, 0x0002, 0x0078);
break;
}
case 5: {
if (9 != mode)
mode = 7;
switch (mode) {
case 7: {
if (0 != write_saa(p, 0x02, 0x87)) {
SAY("ERROR: failed to set SAA register 0x02 " SAY("ERROR: failed to set SAA register 0x02 "
"for input %i\n", input); "for input %i\n", input);
} }
if (0 != write_saa(p, 0x05, 0xFF)) { SET(p, 0x0000, 0x0098);
SAY("ERROR: failed to set SAA register 0x05 " SET(p, 0x0002, 0x0078);
break;
}
case 2: {
if (0 != write_saa(p, 0x02, 0x80)) {
SAY("ERROR: failed to set SAA register 0x02 "
"for input %i\n", input); "for input %i\n", input);
} }
SET(p, 0x0000, 0x0090);
SET(p, 0x0002, 0x0078);
break;
}
case 3: {
if (0 != write_saa(p, 0x02, 0x80)) {
SAY("ERROR: failed to set SAA register 0x02 "
" for input %i\n", input);
}
SET(p, 0x0000, 0x0088);
SET(p, 0x0002, 0x0078);
break; break;
} }
case 9: { case 4: {
if (0 != write_saa(p, 0x02, 0x89)) { if (0 != write_saa(p, 0x02, 0x80)) {
SAY("ERROR: failed to set SAA register 0x02 " SAY("ERROR: failed to set SAA register 0x02 "
"for input %i\n", input); "for input %i\n", input);
} }
if (0 != write_saa(p, 0x05, 0x00)) { SET(p, 0x0000, 0x0080);
SAY("ERROR: failed to set SAA register 0x05 " SET(p, 0x0002, 0x0078);
break;
}
case 5: {
if (9 != mode)
mode = 7;
switch (mode) {
case 7: {
if (0 != write_saa(p, 0x02, 0x87)) {
SAY("ERROR: failed to set SAA register 0x02 "
"for input %i\n", input);
}
if (0 != write_saa(p, 0x05, 0xFF)) {
SAY("ERROR: failed to set SAA register 0x05 "
"for input %i\n", input); "for input %i\n", input);
}
break;
} }
break; case 9: {
if (0 != write_saa(p, 0x02, 0x89)) {
SAY("ERROR: failed to set SAA register 0x02 "
"for input %i\n", input);
}
if (0 != write_saa(p, 0x05, 0x00)) {
SAY("ERROR: failed to set SAA register 0x05 "
"for input %i\n", input);
}
break;
}
default: {
SAY("MISTAKE: bad mode: %i\n", mode);
return -1;
}
}
if (0 != write_saa(p, 0x04, 0x00)) {
SAY("ERROR: failed to set SAA register 0x04 "
"for input %i\n", input);
}
if (0 != write_saa(p, 0x09, 0x80)) {
SAY("ERROR: failed to set SAA register 0x09 "
"for input %i\n", input);
}
SET(p, 0x0002, 0x0093);
break;
} }
default: { default: {
SAY("MISTAKE: bad mode: %i\n", mode); SAY("ERROR: bad input: %i\n", input);
return -1; return -1;
} }
} }
if (0 != write_saa(p, 0x04, 0x00)) { ir = read_stk(p, 0x00);
SAY("ERROR: failed to set SAA register 0x04 for input %i\n", JOT(8, "STK register 0x00 has 0x%02X\n", ir);
input); ir = read_saa(p, 0x02);
} JOT(8, "SAA register 0x02 has 0x%02X\n", ir);
if (0 != write_saa(p, 0x09, 0x80)) {
SAY("ERROR: failed to set SAA register 0x09 for input %i\n",
input);
}
SET(p, 0x0002, 0x0093);
break;
}
default: {
SAY("ERROR: bad input: %i\n", input);
return -1;
}
}
ir = read_stk(p, 0x00);
JOT(8, "STK register 0x00 has 0x%02X\n", ir);
ir = read_saa(p, 0x02);
JOT(8, "SAA register 0x02 has 0x%02X\n", ir);
start_100(p); start_100(p);
return 0; return 0;
} }
/****************************************************************************/ /****************************************************************************/
int int set_resolution(struct usb_device *p,
set_resolution(struct usb_device *p, u16 set0, u16 set1, u16 set2, u16 set3)
u16 set0, u16 set1, u16 set2, u16 set3)
{ {
u16 u0x0111, u0x0113, u0x0115, u0x0117; u16 u0x0111, u0x0113, u0x0115, u0x0117;
if (NULL == p) if (NULL == p)
return -ENODEV; return -ENODEV;
u0x0111 = ((0xFF00 & set0) >> 8); u0x0111 = ((0xFF00 & set0) >> 8);
u0x0113 = ((0xFF00 & set1) >> 8); u0x0113 = ((0xFF00 & set1) >> 8);
u0x0115 = ((0xFF00 & set2) >> 8); u0x0115 = ((0xFF00 & set2) >> 8);
u0x0117 = ((0xFF00 & set3) >> 8); u0x0117 = ((0xFF00 & set3) >> 8);
SET(p, 0x0110, (0x00FF & set0)); SET(p, 0x0110, (0x00FF & set0));
SET(p, 0x0111, u0x0111); SET(p, 0x0111, u0x0111);
SET(p, 0x0112, (0x00FF & set1)); SET(p, 0x0112, (0x00FF & set1));
SET(p, 0x0113, u0x0113); SET(p, 0x0113, u0x0113);
SET(p, 0x0114, (0x00FF & set2)); SET(p, 0x0114, (0x00FF & set2));
SET(p, 0x0115, u0x0115); SET(p, 0x0115, u0x0115);
SET(p, 0x0116, (0x00FF & set3)); SET(p, 0x0116, (0x00FF & set3));
SET(p, 0x0117, u0x0117); SET(p, 0x0117, u0x0117);
return 0; return 0;
} }
/****************************************************************************/ /****************************************************************************/
int int start_100(struct usb_device *p)
start_100(struct usb_device *p)
{ {
u16 get116, get117, get0; u16 get116, get117, get0;
u8 igot116, igot117, igot; u8 igot116, igot117, igot;
if (NULL == p) if (NULL == p)
return -ENODEV; return -ENODEV;
GET(p, 0x0116, &igot116); GET(p, 0x0116, &igot116);
get116 = igot116; get116 = igot116;
GET(p, 0x0117, &igot117); GET(p, 0x0117, &igot117);
get117 = igot117; get117 = igot117;
SET(p, 0x0116, 0x0000); SET(p, 0x0116, 0x0000);
SET(p, 0x0117, 0x0000); SET(p, 0x0117, 0x0000);
GET(p, 0x0100, &igot); GET(p, 0x0100, &igot);
get0 = igot; get0 = igot;
SET(p, 0x0100, (0x80 | get0)); SET(p, 0x0100, (0x80 | get0));
SET(p, 0x0116, get116); SET(p, 0x0116, get116);
SET(p, 0x0117, get117); SET(p, 0x0117, get117);
return 0; return 0;
} }
/****************************************************************************/ /****************************************************************************/
int int stop_100(struct usb_device *p)
stop_100(struct usb_device *p)
{ {
u16 get0; u16 get0;
u8 igot; u8 igot;
if (NULL == p) if (NULL == p)
return -ENODEV; return -ENODEV;
GET(p, 0x0100, &igot); GET(p, 0x0100, &igot);
get0 = igot; get0 = igot;
SET(p, 0x0100, (0x7F & get0)); SET(p, 0x0100, (0x7F & get0));
return 0; return 0;
} }
/****************************************************************************/ /****************************************************************************/
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
...@@ -959,57 +943,55 @@ return 0; ...@@ -959,57 +943,55 @@ return 0;
* FUNCTION wait_i2c() RETURNS 0 ON SUCCESS * FUNCTION wait_i2c() RETURNS 0 ON SUCCESS
*/ */
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
int int wait_i2c(struct usb_device *p)
wait_i2c(struct usb_device *p)
{ {
u16 get0; u16 get0;
u8 igot; u8 igot;
const int max = 2; const int max = 2;
int k; int k;
if (NULL == p) if (NULL == p)
return -ENODEV; return -ENODEV;
for (k = 0; k < max; k++) { for (k = 0; k < max; k++) {
GET(p, 0x0201, &igot); get0 = igot; GET(p, 0x0201, &igot); get0 = igot;
switch (get0) { switch (get0) {
case 0x04: case 0x04:
case 0x01: { case 0x01: {
return 0; return 0;
} }
case 0x00: { case 0x00: {
msleep(20); msleep(20);
continue; continue;
} }
default: { default: {
return get0 - 1; return get0 - 1;
} }
}
} }
} return -1;
return -1;
} }
/****************************************************************************/ /****************************************************************************/
/*****************************************************************************/ /*****************************************************************************/
int int wakeup_device(struct usb_device *pusb_device)
wakeup_device(struct usb_device *pusb_device)
{ {
if (!pusb_device) if (!pusb_device)
return -ENODEV; return -ENODEV;
return usb_control_msg(pusb_device, usb_sndctrlpipe(pusb_device, 0), return usb_control_msg(pusb_device, usb_sndctrlpipe(pusb_device, 0),
(u8)USB_REQ_SET_FEATURE, (u8)USB_REQ_SET_FEATURE,
(u8)(USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE), USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
USB_DEVICE_REMOTE_WAKEUP, USB_DEVICE_REMOTE_WAKEUP,
(u16)0, (u16)0,
(void *) NULL, (void *) NULL,
(u16)0, (u16)0,
(int)50000); (int)50000);
} }
/*****************************************************************************/ /*****************************************************************************/
int int
audio_setup(struct easycap *peasycap) audio_setup(struct easycap *peasycap)
{ {
struct usb_device *pusb_device; struct usb_device *pusb_device;
unsigned char buffer[1]; unsigned char buffer[1];
int rc, id1, id2; int rc, id1, id2;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* /*
* IMPORTANT: * IMPORTANT:
...@@ -1018,53 +1000,54 @@ int rc, id1, id2; ...@@ -1018,53 +1000,54 @@ int rc, id1, id2;
* TO ENABLE AUDIO THE VALUE 0x0200 MUST BE SENT. * TO ENABLE AUDIO THE VALUE 0x0200 MUST BE SENT.
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
const u8 request = 0x01; const u8 request = 0x01;
const u8 requesttype = const u8 requesttype = USB_DIR_OUT |
(u8)(USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE); USB_TYPE_CLASS |
const u16 value_unmute = 0x0200; USB_RECIP_INTERFACE;
const u16 index = 0x0301; const u16 value_unmute = 0x0200;
const u16 length = 1; const u16 index = 0x0301;
const u16 length = 1;
if (NULL == peasycap)
return -EFAULT; if (NULL == peasycap)
return -EFAULT;
pusb_device = peasycap->pusb_device;
if (NULL == pusb_device) pusb_device = peasycap->pusb_device;
return -ENODEV; if (NULL == pusb_device)
return -ENODEV;
JOM(8, "%02X %02X %02X %02X %02X %02X %02X %02X\n",
requesttype, request,
(0x00FF & value_unmute),
(0xFF00 & value_unmute) >> 8,
(0x00FF & index),
(0xFF00 & index) >> 8,
(0x00FF & length),
(0xFF00 & length) >> 8);
buffer[0] = 0x01;
rc = usb_control_msg(pusb_device, usb_sndctrlpipe(pusb_device, 0),
(u8)request,
(u8)requesttype,
(u16)value_unmute,
(u16)index,
(void *)&buffer[0],
(u16)length,
(int)50000);
JOT(8, "0x%02X=buffer\n", *((u8 *) &buffer[0])); JOM(8, "%02X %02X %02X %02X %02X %02X %02X %02X\n",
if (rc != (int)length) { requesttype, request,
switch (rc) { (0x00FF & value_unmute),
case -EPIPE: { (0xFF00 & value_unmute) >> 8,
SAY("usb_control_msg returned -EPIPE\n"); (0x00FF & index),
break; (0xFF00 & index) >> 8,
} (0x00FF & length),
default: { (0xFF00 & length) >> 8);
SAY("ERROR: usb_control_msg returned %i\n", rc);
break; buffer[0] = 0x01;
}
rc = usb_control_msg(pusb_device, usb_sndctrlpipe(pusb_device, 0),
(u8)request,
(u8)requesttype,
(u16)value_unmute,
(u16)index,
(void *)&buffer[0],
(u16)length,
(int)50000);
JOT(8, "0x%02X=buffer\n", *((u8 *) &buffer[0]));
if (rc != (int)length) {
switch (rc) {
case -EPIPE: {
SAY("usb_control_msg returned -EPIPE\n");
break;
}
default: {
SAY("ERROR: usb_control_msg returned %i\n", rc);
break;
}
}
} }
}
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/* /*
* REGISTER 500: SETTING VALUE TO 0x0094 RESETS AUDIO CONFIGURATION ??? * REGISTER 500: SETTING VALUE TO 0x0094 RESETS AUDIO CONFIGURATION ???
...@@ -1080,80 +1063,79 @@ if (rc != (int)length) { ...@@ -1080,80 +1063,79 @@ if (rc != (int)length) {
* THE UPPER BYTE SEEMS TO HAVE NO EFFECT. * THE UPPER BYTE SEEMS TO HAVE NO EFFECT.
*/ */
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
SET(pusb_device, 0x0500, 0x0094); SET(pusb_device, 0x0500, 0x0094);
SET(pusb_device, 0x0500, 0x008C); SET(pusb_device, 0x0500, 0x008C);
SET(pusb_device, 0x0506, 0x0001); SET(pusb_device, 0x0506, 0x0001);
SET(pusb_device, 0x0507, 0x0000); SET(pusb_device, 0x0507, 0x0000);
id1 = read_vt(pusb_device, 0x007C); id1 = read_vt(pusb_device, 0x007C);
id2 = read_vt(pusb_device, 0x007E); id2 = read_vt(pusb_device, 0x007E);
SAM("0x%04X:0x%04X is audio vendor id\n", id1, id2); SAM("0x%04X:0x%04X is audio vendor id\n", id1, id2);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* /*
* SELECT AUDIO SOURCE "LINE IN" AND SET THE AUDIO GAIN. * SELECT AUDIO SOURCE "LINE IN" AND SET THE AUDIO GAIN.
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
if (0 != audio_gainset(pusb_device, peasycap->gain)) if (0 != audio_gainset(pusb_device, peasycap->gain))
SAY("ERROR: audio_gainset() failed\n"); SAY("ERROR: audio_gainset() failed\n");
check_vt(pusb_device); check_vt(pusb_device);
return 0; return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
int int check_vt(struct usb_device *pusb_device)
check_vt(struct usb_device *pusb_device)
{ {
int igot; int igot;
if (!pusb_device) if (!pusb_device)
return -ENODEV; return -ENODEV;
igot = read_vt(pusb_device, 0x0002); igot = read_vt(pusb_device, 0x0002);
if (0 > igot) if (0 > igot)
SAY("ERROR: failed to read VT1612A register 0x02\n"); SAY("ERROR: failed to read VT1612A register 0x02\n");
if (0x8000 & igot) if (0x8000 & igot)
SAY("register 0x%02X muted\n", 0x02); SAY("register 0x%02X muted\n", 0x02);
igot = read_vt(pusb_device, 0x000E); igot = read_vt(pusb_device, 0x000E);
if (0 > igot) if (0 > igot)
SAY("ERROR: failed to read VT1612A register 0x0E\n"); SAY("ERROR: failed to read VT1612A register 0x0E\n");
if (0x8000 & igot) if (0x8000 & igot)
SAY("register 0x%02X muted\n", 0x0E); SAY("register 0x%02X muted\n", 0x0E);
igot = read_vt(pusb_device, 0x0010); igot = read_vt(pusb_device, 0x0010);
if (0 > igot) if (0 > igot)
SAY("ERROR: failed to read VT1612A register 0x10\n"); SAY("ERROR: failed to read VT1612A register 0x10\n");
if (0x8000 & igot) if (0x8000 & igot)
SAY("register 0x%02X muted\n", 0x10); SAY("register 0x%02X muted\n", 0x10);
igot = read_vt(pusb_device, 0x0012); igot = read_vt(pusb_device, 0x0012);
if (0 > igot) if (0 > igot)
SAY("ERROR: failed to read VT1612A register 0x12\n"); SAY("ERROR: failed to read VT1612A register 0x12\n");
if (0x8000 & igot) if (0x8000 & igot)
SAY("register 0x%02X muted\n", 0x12); SAY("register 0x%02X muted\n", 0x12);
igot = read_vt(pusb_device, 0x0014); igot = read_vt(pusb_device, 0x0014);
if (0 > igot) if (0 > igot)
SAY("ERROR: failed to read VT1612A register 0x14\n"); SAY("ERROR: failed to read VT1612A register 0x14\n");
if (0x8000 & igot) if (0x8000 & igot)
SAY("register 0x%02X muted\n", 0x14); SAY("register 0x%02X muted\n", 0x14);
igot = read_vt(pusb_device, 0x0016); igot = read_vt(pusb_device, 0x0016);
if (0 > igot) if (0 > igot)
SAY("ERROR: failed to read VT1612A register 0x16\n"); SAY("ERROR: failed to read VT1612A register 0x16\n");
if (0x8000 & igot) if (0x8000 & igot)
SAY("register 0x%02X muted\n", 0x16); SAY("register 0x%02X muted\n", 0x16);
igot = read_vt(pusb_device, 0x0018); igot = read_vt(pusb_device, 0x0018);
if (0 > igot) if (0 > igot)
SAY("ERROR: failed to read VT1612A register 0x18\n"); SAY("ERROR: failed to read VT1612A register 0x18\n");
if (0x8000 & igot) if (0x8000 & igot)
SAY("register 0x%02X muted\n", 0x18); SAY("register 0x%02X muted\n", 0x18);
igot = read_vt(pusb_device, 0x001C); igot = read_vt(pusb_device, 0x001C);
if (0 > igot) if (0 > igot)
SAY("ERROR: failed to read VT1612A register 0x1C\n"); SAY("ERROR: failed to read VT1612A register 0x1C\n");
if (0x8000 & igot) if (0x8000 & igot)
SAY("register 0x%02X muted\n", 0x1C); SAY("register 0x%02X muted\n", 0x1C);
return 0; return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
...@@ -1170,85 +1152,83 @@ return 0; ...@@ -1170,85 +1152,83 @@ return 0;
* 31 12.0 22.5 34.5 * 31 12.0 22.5 34.5
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int audio_gainset(struct usb_device *pusb_device, s8 loud)
audio_gainset(struct usb_device *pusb_device, s8 loud)
{ {
int igot; int igot;
u8 tmp; u8 tmp;
u16 mute; u16 mute;
if (NULL == pusb_device) if (NULL == pusb_device)
return -ENODEV; return -ENODEV;
if (0 > loud) if (0 > loud)
loud = 0; loud = 0;
if (31 < loud) if (31 < loud)
loud = 31; loud = 31;
write_vt(pusb_device, 0x0002, 0x8000); write_vt(pusb_device, 0x0002, 0x8000);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
igot = read_vt(pusb_device, 0x000E); igot = read_vt(pusb_device, 0x000E);
if (0 > igot) { if (0 > igot) {
SAY("ERROR: failed to read VT1612A register 0x0E\n"); SAY("ERROR: failed to read VT1612A register 0x0E\n");
mute = 0x0000; mute = 0x0000;
} else } else
mute = 0x8000 & ((unsigned int)igot); mute = 0x8000 & ((unsigned int)igot);
mute = 0; mute = 0;
if (16 > loud) if (16 > loud)
tmp = 0x01 | (0x001F & (((u8)(15 - loud)) << 1)); tmp = 0x01 | (0x001F & (((u8)(15 - loud)) << 1));
else else
tmp = 0; tmp = 0;
JOT(8, "0x%04X=(mute|tmp) for VT1612A register 0x0E\n", mute | tmp); JOT(8, "0x%04X=(mute|tmp) for VT1612A register 0x0E\n", mute | tmp);
write_vt(pusb_device, 0x000E, (mute | tmp)); write_vt(pusb_device, 0x000E, (mute | tmp));
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
igot = read_vt(pusb_device, 0x0010); igot = read_vt(pusb_device, 0x0010);
if (0 > igot) { if (0 > igot) {
SAY("ERROR: failed to read VT1612A register 0x10\n"); SAY("ERROR: failed to read VT1612A register 0x10\n");
mute = 0x0000; mute = 0x0000;
} else } else
mute = 0x8000 & ((unsigned int)igot); mute = 0x8000 & ((unsigned int)igot);
mute = 0; mute = 0;
JOT(8, "0x%04X=(mute|tmp|(tmp<<8)) for VT1612A register 0x10,...0x18\n", JOT(8, "0x%04X=(mute|tmp|(tmp<<8)) for VT1612A register 0x10,...0x18\n",
mute | tmp | (tmp << 8)); mute | tmp | (tmp << 8));
write_vt(pusb_device, 0x0010, (mute | tmp | (tmp << 8))); write_vt(pusb_device, 0x0010, (mute | tmp | (tmp << 8)));
write_vt(pusb_device, 0x0012, (mute | tmp | (tmp << 8))); write_vt(pusb_device, 0x0012, (mute | tmp | (tmp << 8)));
write_vt(pusb_device, 0x0014, (mute | tmp | (tmp << 8))); write_vt(pusb_device, 0x0014, (mute | tmp | (tmp << 8)));
write_vt(pusb_device, 0x0016, (mute | tmp | (tmp << 8))); write_vt(pusb_device, 0x0016, (mute | tmp | (tmp << 8)));
write_vt(pusb_device, 0x0018, (mute | tmp | (tmp << 8))); write_vt(pusb_device, 0x0018, (mute | tmp | (tmp << 8)));
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
igot = read_vt(pusb_device, 0x001C); igot = read_vt(pusb_device, 0x001C);
if (0 > igot) { if (0 > igot) {
SAY("ERROR: failed to read VT1612A register 0x1C\n"); SAY("ERROR: failed to read VT1612A register 0x1C\n");
mute = 0x0000; mute = 0x0000;
} else } else
mute = 0x8000 & ((unsigned int)igot); mute = 0x8000 & ((unsigned int)igot);
mute = 0; mute = 0;
if (16 <= loud) if (16 <= loud)
tmp = 0x000F & (u8)(loud - 16); tmp = 0x000F & (u8)(loud - 16);
else else
tmp = 0; tmp = 0;
JOT(8, "0x%04X=(mute|tmp|(tmp<<8)) for VT1612A register 0x1C\n", JOT(8, "0x%04X=(mute|tmp|(tmp<<8)) for VT1612A register 0x1C\n",
mute | tmp | (tmp << 8)); mute | tmp | (tmp << 8));
write_vt(pusb_device, 0x001C, (mute | tmp | (tmp << 8))); write_vt(pusb_device, 0x001C, (mute | tmp | (tmp << 8)));
write_vt(pusb_device, 0x001A, 0x0404); write_vt(pusb_device, 0x001A, 0x0404);
write_vt(pusb_device, 0x0002, 0x0000); write_vt(pusb_device, 0x0002, 0x0000);
return 0; return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
int int audio_gainget(struct usb_device *pusb_device)
audio_gainget(struct usb_device *pusb_device)
{ {
int igot; int igot;
if (NULL == pusb_device) if (NULL == pusb_device)
return -ENODEV; return -ENODEV;
igot = read_vt(pusb_device, 0x001C); igot = read_vt(pusb_device, 0x001C);
if (0 > igot) if (0 > igot)
SAY("ERROR: failed to read VT1612A register 0x1C\n"); SAY("ERROR: failed to read VT1612A register 0x1C\n");
return igot; return igot;
} }
/*****************************************************************************/ /*****************************************************************************/
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment