Commit 18fc59e2 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab Committed by Linus Torvalds

[PATCH] v4l: TVaudio cleanup and better debug messages

- adds the adapter number + i2c address to printk msgs.
- Some CodingStyle cleanups.
Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@brturbo.com.br>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent dc75fc1b
...@@ -46,7 +46,17 @@ MODULE_AUTHOR("Eric Sandeen, Steve VanDeBogart, Greg Alexander, Gerd Knorr"); ...@@ -46,7 +46,17 @@ MODULE_AUTHOR("Eric Sandeen, Steve VanDeBogart, Greg Alexander, Gerd Knorr");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
#define UNSET (-1U) #define UNSET (-1U)
#define dprintk if (debug) printk
#define tvaudio_info(fmt, arg...) do {\
printk(KERN_INFO "tvaudio %d-%04x: " fmt, \
chip->c.adapter->nr, chip->c.addr , ##arg); } while (0)
#define tvaudio_warn(fmt, arg...) do {\
printk(KERN_WARNING "tvaudio %d-%04x: " fmt, \
chip->c.adapter->nr, chip->c.addr , ##arg); } while (0)
#define tvaudio_dbg(fmt, arg...) do {\
if (debug) \
printk(KERN_INFO "tvaudio %d-%04x: " fmt, \
chip->c.adapter->nr, chip->c.addr , ##arg); } while (0)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
/* our structs */ /* our structs */
...@@ -162,23 +172,24 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val) ...@@ -162,23 +172,24 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val)
unsigned char buffer[2]; unsigned char buffer[2];
if (-1 == subaddr) { if (-1 == subaddr) {
dprintk("%s: chip_write: 0x%x\n", chip->c.name, val); tvaudio_dbg("%s: chip_write: 0x%x\n",
chip->c.name, val);
chip->shadow.bytes[1] = val; chip->shadow.bytes[1] = val;
buffer[0] = val; buffer[0] = val;
if (1 != i2c_master_send(&chip->c,buffer,1)) { if (1 != i2c_master_send(&chip->c,buffer,1)) {
printk(KERN_WARNING "%s: I/O error (write 0x%x)\n", tvaudio_warn("%s: I/O error (write 0x%x)\n",
chip->c.name, val); chip->c.name, val);
return -1; return -1;
} }
} else { } else {
dprintk("%s: chip_write: reg%d=0x%x\n", tvaudio_dbg("%s: chip_write: reg%d=0x%x\n",
chip->c.name, subaddr, val); chip->c.name, subaddr, val);
chip->shadow.bytes[subaddr+1] = val; chip->shadow.bytes[subaddr+1] = val;
buffer[0] = subaddr; buffer[0] = subaddr;
buffer[1] = val; buffer[1] = val;
if (2 != i2c_master_send(&chip->c,buffer,2)) { if (2 != i2c_master_send(&chip->c,buffer,2)) {
printk(KERN_WARNING "%s: I/O error (write reg%d=0x%x)\n", tvaudio_warn("%s: I/O error (write reg%d=0x%x)\n",
chip->c.name, subaddr, val); chip->c.name, subaddr, val);
return -1; return -1;
} }
} }
...@@ -202,29 +213,30 @@ static int chip_read(struct CHIPSTATE *chip) ...@@ -202,29 +213,30 @@ static int chip_read(struct CHIPSTATE *chip)
unsigned char buffer; unsigned char buffer;
if (1 != i2c_master_recv(&chip->c,&buffer,1)) { if (1 != i2c_master_recv(&chip->c,&buffer,1)) {
printk(KERN_WARNING "%s: I/O error (read)\n", chip->c.name); tvaudio_warn("%s: I/O error (read)\n",
chip->c.name);
return -1; return -1;
} }
dprintk("%s: chip_read: 0x%x\n", chip->c.name, buffer); tvaudio_dbg("%s: chip_read: 0x%x\n",chip->c.name,buffer);
return buffer; return buffer;
} }
static int chip_read2(struct CHIPSTATE *chip, int subaddr) static int chip_read2(struct CHIPSTATE *chip, int subaddr)
{ {
unsigned char write[1]; unsigned char write[1];
unsigned char read[1]; unsigned char read[1];
struct i2c_msg msgs[2] = { struct i2c_msg msgs[2] = {
{ chip->c.addr, 0, 1, write }, { chip->c.addr, 0, 1, write },
{ chip->c.addr, I2C_M_RD, 1, read } { chip->c.addr, I2C_M_RD, 1, read }
}; };
write[0] = subaddr; write[0] = subaddr;
if (2 != i2c_transfer(chip->c.adapter,msgs,2)) { if (2 != i2c_transfer(chip->c.adapter,msgs,2)) {
printk(KERN_WARNING "%s: I/O error (read2)\n", chip->c.name); tvaudio_warn("%s: I/O error (read2)\n", chip->c.name);
return -1; return -1;
} }
dprintk("%s: chip_read2: reg%d=0x%x\n", tvaudio_dbg("%s: chip_read2: reg%d=0x%x\n",
chip->c.name, subaddr, read[0]); chip->c.name,subaddr,read[0]);
return read[0]; return read[0];
} }
...@@ -236,17 +248,19 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd) ...@@ -236,17 +248,19 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd)
return 0; return 0;
/* update our shadow register set; print bytes if (debug > 0) */ /* update our shadow register set; print bytes if (debug > 0) */
dprintk("%s: chip_cmd(%s): reg=%d, data:", tvaudio_dbg("%s: chip_cmd(%s): reg=%d, data:",
chip->c.name, name, cmd->bytes[0]); chip->c.name,name,cmd->bytes[0]);
for (i = 1; i < cmd->count; i++) { for (i = 1; i < cmd->count; i++) {
dprintk(" 0x%x",cmd->bytes[i]); if (debug)
printk(" 0x%x",cmd->bytes[i]);
chip->shadow.bytes[i+cmd->bytes[0]] = cmd->bytes[i]; chip->shadow.bytes[i+cmd->bytes[0]] = cmd->bytes[i];
} }
dprintk("\n"); if (debug)
printk("\n");
/* send data to the chip */ /* send data to the chip */
if (cmd->count != i2c_master_send(&chip->c,cmd->bytes,cmd->count)) { if (cmd->count != i2c_master_send(&chip->c,cmd->bytes,cmd->count)) {
printk(KERN_WARNING "%s: I/O error (%s)\n", chip->c.name, name); tvaudio_warn("%s: I/O error (%s)\n", chip->c.name, name);
return -1; return -1;
} }
return 0; return 0;
...@@ -261,19 +275,19 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd) ...@@ -261,19 +275,19 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd)
static void chip_thread_wake(unsigned long data) static void chip_thread_wake(unsigned long data)
{ {
struct CHIPSTATE *chip = (struct CHIPSTATE*)data; struct CHIPSTATE *chip = (struct CHIPSTATE*)data;
wake_up_interruptible(&chip->wq); wake_up_interruptible(&chip->wq);
} }
static int chip_thread(void *data) static int chip_thread(void *data)
{ {
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
struct CHIPSTATE *chip = data; struct CHIPSTATE *chip = data;
struct CHIPDESC *desc = chiplist + chip->type; struct CHIPDESC *desc = chiplist + chip->type;
daemonize("%s", chip->c.name); daemonize("%s", chip->c.name);
allow_signal(SIGTERM); allow_signal(SIGTERM);
dprintk("%s: thread started\n", chip->c.name); tvaudio_dbg("%s: thread started\n", chip->c.name);
for (;;) { for (;;) {
add_wait_queue(&chip->wq, &wait); add_wait_queue(&chip->wq, &wait);
...@@ -285,7 +299,7 @@ static int chip_thread(void *data) ...@@ -285,7 +299,7 @@ static int chip_thread(void *data)
try_to_freeze(); try_to_freeze();
if (chip->done || signal_pending(current)) if (chip->done || signal_pending(current))
break; break;
dprintk("%s: thread wakeup\n", chip->c.name); tvaudio_dbg("%s: thread wakeup\n", chip->c.name);
/* don't do anything for radio or if mode != auto */ /* don't do anything for radio or if mode != auto */
if (chip->norm == VIDEO_MODE_RADIO || chip->mode != 0) if (chip->norm == VIDEO_MODE_RADIO || chip->mode != 0)
...@@ -298,8 +312,8 @@ static int chip_thread(void *data) ...@@ -298,8 +312,8 @@ static int chip_thread(void *data)
mod_timer(&chip->wt, jiffies+2*HZ); mod_timer(&chip->wt, jiffies+2*HZ);
} }
dprintk("%s: thread exiting\n", chip->c.name); tvaudio_dbg("%s: thread exiting\n", chip->c.name);
complete_and_exit(&chip->texit, 0); complete_and_exit(&chip->texit, 0);
return 0; return 0;
} }
...@@ -309,9 +323,9 @@ static void generic_checkmode(struct CHIPSTATE *chip) ...@@ -309,9 +323,9 @@ static void generic_checkmode(struct CHIPSTATE *chip)
int mode = desc->getmode(chip); int mode = desc->getmode(chip);
if (mode == chip->prevmode) if (mode == chip->prevmode)
return; return;
dprintk("%s: thread checkmode\n", chip->c.name); tvaudio_dbg("%s: thread checkmode\n", chip->c.name);
chip->prevmode = mode; chip->prevmode = mode;
if (mode & VIDEO_SOUND_STEREO) if (mode & VIDEO_SOUND_STEREO)
...@@ -358,8 +372,8 @@ static int tda9840_getmode(struct CHIPSTATE *chip) ...@@ -358,8 +372,8 @@ static int tda9840_getmode(struct CHIPSTATE *chip)
if (val & TDA9840_ST_STEREO) if (val & TDA9840_ST_STEREO)
mode |= VIDEO_SOUND_STEREO; mode |= VIDEO_SOUND_STEREO;
dprintk ("tda9840_getmode(): raw chip read: %d, return: %d\n", tvaudio_dbg ("tda9840_getmode(): raw chip read: %d, return: %d\n",
val, mode); val, mode);
return mode; return mode;
} }
...@@ -654,8 +668,8 @@ static int tda9873_getmode(struct CHIPSTATE *chip) ...@@ -654,8 +668,8 @@ static int tda9873_getmode(struct CHIPSTATE *chip)
mode |= VIDEO_SOUND_STEREO; mode |= VIDEO_SOUND_STEREO;
if (val & TDA9873_DUAL) if (val & TDA9873_DUAL)
mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
dprintk ("tda9873_getmode(): raw chip read: %d, return: %d\n", tvaudio_dbg ("tda9873_getmode(): raw chip read: %d, return: %d\n",
val, mode); val, mode);
return mode; return mode;
} }
...@@ -665,12 +679,12 @@ static void tda9873_setmode(struct CHIPSTATE *chip, int mode) ...@@ -665,12 +679,12 @@ static void tda9873_setmode(struct CHIPSTATE *chip, int mode)
/* int adj_data = chip->shadow.bytes[TDA9873_AD+1] ; */ /* int adj_data = chip->shadow.bytes[TDA9873_AD+1] ; */
if ((sw_data & TDA9873_INP_MASK) != TDA9873_INTERNAL) { if ((sw_data & TDA9873_INP_MASK) != TDA9873_INTERNAL) {
dprintk("tda9873_setmode(): external input\n"); tvaudio_dbg("tda9873_setmode(): external input\n");
return; return;
} }
dprintk("tda9873_setmode(): chip->shadow.bytes[%d] = %d\n", TDA9873_SW+1, chip->shadow.bytes[TDA9873_SW+1]); tvaudio_dbg("tda9873_setmode(): chip->shadow.bytes[%d] = %d\n", TDA9873_SW+1, chip->shadow.bytes[TDA9873_SW+1]);
dprintk("tda9873_setmode(): sw_data = %d\n", sw_data); tvaudio_dbg("tda9873_setmode(): sw_data = %d\n", sw_data);
switch (mode) { switch (mode) {
case VIDEO_SOUND_MONO: case VIDEO_SOUND_MONO:
...@@ -691,7 +705,7 @@ static void tda9873_setmode(struct CHIPSTATE *chip, int mode) ...@@ -691,7 +705,7 @@ static void tda9873_setmode(struct CHIPSTATE *chip, int mode)
} }
chip_write(chip, TDA9873_SW, sw_data); chip_write(chip, TDA9873_SW, sw_data);
dprintk("tda9873_setmode(): req. mode %d; chip_write: %d\n", tvaudio_dbg("tda9873_setmode(): req. mode %d; chip_write: %d\n",
mode, sw_data); mode, sw_data);
} }
...@@ -828,9 +842,9 @@ static int tda9874a_setup(struct CHIPSTATE *chip) ...@@ -828,9 +842,9 @@ static int tda9874a_setup(struct CHIPSTATE *chip)
} else { /* dic == 0x07 */ } else { /* dic == 0x07 */
chip_write(chip, TDA9874A_AMCONR, 0xfb); chip_write(chip, TDA9874A_AMCONR, 0xfb);
chip_write(chip, TDA9874A_SDACOSR, (tda9874a_mode) ? 0x81:0x80); chip_write(chip, TDA9874A_SDACOSR, (tda9874a_mode) ? 0x81:0x80);
chip_write(chip, TDA9874A_AOSR, 0x00); // or 0x10 chip_write(chip, TDA9874A_AOSR, 0x00); /* or 0x10 */
} }
dprintk("tda9874a_setup(): %s [0x%02X].\n", tvaudio_dbg("tda9874a_setup(): %s [0x%02X].\n",
tda9874a_modelist[tda9874a_STD].name,tda9874a_STD); tda9874a_modelist[tda9874a_STD].name,tda9874a_STD);
return 1; return 1;
} }
...@@ -873,7 +887,7 @@ static int tda9874a_getmode(struct CHIPSTATE *chip) ...@@ -873,7 +887,7 @@ static int tda9874a_getmode(struct CHIPSTATE *chip)
mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
} }
dprintk("tda9874a_getmode(): DSR=0x%X, NSR=0x%X, NECR=0x%X, return: %d.\n", tvaudio_dbg("tda9874a_getmode(): DSR=0x%X, NSR=0x%X, NECR=0x%X, return: %d.\n",
dsr, nsr, necr, mode); dsr, nsr, necr, mode);
return mode; return mode;
} }
...@@ -919,7 +933,7 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode) ...@@ -919,7 +933,7 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode)
chip_write(chip, TDA9874A_AOSR, aosr); chip_write(chip, TDA9874A_AOSR, aosr);
chip_write(chip, TDA9874A_MDACOSR, mdacosr); chip_write(chip, TDA9874A_MDACOSR, mdacosr);
dprintk("tda9874a_setmode(): req. mode %d; AOSR=0x%X, MDACOSR=0x%X.\n", tvaudio_dbg("tda9874a_setmode(): req. mode %d; AOSR=0x%X, MDACOSR=0x%X.\n",
mode, aosr, mdacosr); mode, aosr, mdacosr);
} else { /* dic == 0x07 */ } else { /* dic == 0x07 */
...@@ -954,7 +968,7 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode) ...@@ -954,7 +968,7 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode)
chip_write(chip, TDA9874A_FMMR, fmmr); chip_write(chip, TDA9874A_FMMR, fmmr);
chip_write(chip, TDA9874A_AOSR, aosr); chip_write(chip, TDA9874A_AOSR, aosr);
dprintk("tda9874a_setmode(): req. mode %d; FMMR=0x%X, AOSR=0x%X.\n", tvaudio_dbg("tda9874a_setmode(): req. mode %d; FMMR=0x%X, AOSR=0x%X.\n",
mode, fmmr, aosr); mode, fmmr, aosr);
} }
} }
...@@ -968,10 +982,10 @@ static int tda9874a_checkit(struct CHIPSTATE *chip) ...@@ -968,10 +982,10 @@ static int tda9874a_checkit(struct CHIPSTATE *chip)
if(-1 == (sic = chip_read2(chip,TDA9874A_SIC))) if(-1 == (sic = chip_read2(chip,TDA9874A_SIC)))
return 0; return 0;
dprintk("tda9874a_checkit(): DIC=0x%X, SIC=0x%X.\n", dic, sic); tvaudio_dbg("tda9874a_checkit(): DIC=0x%X, SIC=0x%X.\n", dic, sic);
if((dic == 0x11)||(dic == 0x07)) { if((dic == 0x11)||(dic == 0x07)) {
printk("tvaudio: found tda9874%s.\n", (dic == 0x11) ? "a":"h"); tvaudio_info("found tda9874%s.\n", (dic == 0x11) ? "a":"h");
tda9874a_dic = dic; /* remember device id. */ tda9874a_dic = dic; /* remember device id. */
return 1; return 1;
} }
...@@ -1146,7 +1160,7 @@ static void tda8425_setmode(struct CHIPSTATE *chip, int mode) ...@@ -1146,7 +1160,7 @@ static void tda8425_setmode(struct CHIPSTATE *chip, int mode)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
/* audio chip descriptions - defines+functions for TA8874Z */ /* audio chip descriptions - defines+functions for TA8874Z */
// write 1st byte /* write 1st byte */
#define TA8874Z_LED_STE 0x80 #define TA8874Z_LED_STE 0x80
#define TA8874Z_LED_BIL 0x40 #define TA8874Z_LED_BIL 0x40
#define TA8874Z_LED_EXT 0x20 #define TA8874Z_LED_EXT 0x20
...@@ -1156,21 +1170,22 @@ static void tda8425_setmode(struct CHIPSTATE *chip, int mode) ...@@ -1156,21 +1170,22 @@ static void tda8425_setmode(struct CHIPSTATE *chip, int mode)
#define TA8874Z_MODE_SUB 0x02 #define TA8874Z_MODE_SUB 0x02
#define TA8874Z_MODE_MAIN 0x01 #define TA8874Z_MODE_MAIN 0x01
// write 2nd byte /* write 2nd byte */
//#define TA8874Z_TI 0x80 // test mode /*#define TA8874Z_TI 0x80 */ /* test mode */
#define TA8874Z_SEPARATION 0x3f #define TA8874Z_SEPARATION 0x3f
#define TA8874Z_SEPARATION_DEFAULT 0x10 #define TA8874Z_SEPARATION_DEFAULT 0x10
// read /* read */
#define TA8874Z_B1 0x80 #define TA8874Z_B1 0x80
#define TA8874Z_B0 0x40 #define TA8874Z_B0 0x40
#define TA8874Z_CHAG_FLAG 0x20 #define TA8874Z_CHAG_FLAG 0x20
// B1 B0 /*
// mono L H * B1 B0
// stereo L L * mono L H
// BIL H L * stereo L L
* BIL H L
*/
static int ta8874z_getmode(struct CHIPSTATE *chip) static int ta8874z_getmode(struct CHIPSTATE *chip)
{ {
int val, mode; int val, mode;
...@@ -1182,7 +1197,7 @@ static int ta8874z_getmode(struct CHIPSTATE *chip) ...@@ -1182,7 +1197,7 @@ static int ta8874z_getmode(struct CHIPSTATE *chip)
}else if (!(val & TA8874Z_B0)){ }else if (!(val & TA8874Z_B0)){
mode |= VIDEO_SOUND_STEREO; mode |= VIDEO_SOUND_STEREO;
} }
//dprintk ("ta8874z_getmode(): raw chip read: 0x%02x, return: 0x%02x\n", val, mode); /* tvaudio_dbg ("ta8874z_getmode(): raw chip read: 0x%02x, return: 0x%02x\n", val, mode); */
return mode; return mode;
} }
...@@ -1195,7 +1210,7 @@ static void ta8874z_setmode(struct CHIPSTATE *chip, int mode) ...@@ -1195,7 +1210,7 @@ static void ta8874z_setmode(struct CHIPSTATE *chip, int mode)
{ {
int update = 1; int update = 1;
audiocmd *t = NULL; audiocmd *t = NULL;
dprintk("ta8874z_setmode(): mode: 0x%02x\n", mode); tvaudio_dbg("ta8874z_setmode(): mode: 0x%02x\n", mode);
switch(mode){ switch(mode){
case VIDEO_SOUND_MONO: case VIDEO_SOUND_MONO:
...@@ -1235,11 +1250,11 @@ static int tda9850 = 1; ...@@ -1235,11 +1250,11 @@ static int tda9850 = 1;
static int tda9855 = 1; static int tda9855 = 1;
static int tda9873 = 1; static int tda9873 = 1;
static int tda9874a = 1; static int tda9874a = 1;
static int tea6300 = 0; // address clash with msp34xx static int tea6300 = 0; /* address clash with msp34xx */
static int tea6320 = 0; // address clash with msp34xx static int tea6320 = 0; /* address clash with msp34xx */
static int tea6420 = 1; static int tea6420 = 1;
static int pic16c54 = 1; static int pic16c54 = 1;
static int ta8874z = 0; // address clash with tda9840 static int ta8874z = 0; /* address clash with tda9840 */
module_param(tda8425, int, 0444); module_param(tda8425, int, 0444);
module_param(tda9840, int, 0444); module_param(tda9840, int, 0444);
...@@ -1441,7 +1456,7 @@ static struct CHIPDESC chiplist[] = { ...@@ -1441,7 +1456,7 @@ static struct CHIPDESC chiplist[] = {
{ {
.name = "ta8874z", .name = "ta8874z",
.id = -1, .id = -1,
//.id = I2C_DRIVERID_TA8874Z, /*.id = I2C_DRIVERID_TA8874Z, */
.checkit = ta8874z_checkit, .checkit = ta8874z_checkit,
.insmodopt = &ta8874z, .insmodopt = &ta8874z,
.addr_lo = I2C_TDA9840 >> 1, .addr_lo = I2C_TDA9840 >> 1,
...@@ -1476,7 +1491,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -1476,7 +1491,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind)
i2c_set_clientdata(&chip->c, chip); i2c_set_clientdata(&chip->c, chip);
/* find description for the chip */ /* find description for the chip */
dprintk("tvaudio: chip found @ i2c-addr=0x%x\n", addr<<1); tvaudio_dbg("chip found @ 0x%x\n", addr<<1);
for (desc = chiplist; desc->name != NULL; desc++) { for (desc = chiplist; desc->name != NULL; desc++) {
if (0 == *(desc->insmodopt)) if (0 == *(desc->insmodopt))
continue; continue;
...@@ -1488,17 +1503,19 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -1488,17 +1503,19 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind)
break; break;
} }
if (desc->name == NULL) { if (desc->name == NULL) {
dprintk("tvaudio: no matching chip description found\n"); tvaudio_dbg("no matching chip description found\n");
return -EIO; return -EIO;
} }
printk("tvaudio: found %s @ 0x%x\n", desc->name, addr<<1); tvaudio_info("%s found @ 0x%x (%s)\n", desc->name, addr<<1, adap->name);
dprintk("tvaudio: matches:%s%s%s.\n", if (desc->flags) {
(desc->flags & CHIP_HAS_VOLUME) ? " volume" : "", tvaudio_dbg("matches:%s%s%s.\n",
(desc->flags & CHIP_HAS_BASSTREBLE) ? " bass/treble" : "", (desc->flags & CHIP_HAS_VOLUME) ? " volume" : "",
(desc->flags & CHIP_HAS_INPUTSEL) ? " audiomux" : ""); (desc->flags & CHIP_HAS_BASSTREBLE) ? " bass/treble" : "",
(desc->flags & CHIP_HAS_INPUTSEL) ? " audiomux" : "");
}
/* fill required data structures */ /* fill required data structures */
strcpy(chip->c.name, desc->name); strcpy(chip->c.name,desc->name);
chip->type = desc-chiplist; chip->type = desc-chiplist;
chip->shadow.count = desc->registers+1; chip->shadow.count = desc->registers+1;
chip->prevmode = -1; chip->prevmode = -1;
...@@ -1534,7 +1551,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -1534,7 +1551,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind)
init_completion(&chip->texit); init_completion(&chip->texit);
chip->tpid = kernel_thread(chip_thread,(void *)chip,0); chip->tpid = kernel_thread(chip_thread,(void *)chip,0);
if (chip->tpid < 0) if (chip->tpid < 0)
printk(KERN_WARNING "%s: kernel_thread() failed\n", tvaudio_warn("%s: kernel_thread() failed\n",
chip->c.name); chip->c.name);
wake_up_interruptible(&chip->wq); wake_up_interruptible(&chip->wq);
} }
...@@ -1545,7 +1562,7 @@ static int chip_probe(struct i2c_adapter *adap) ...@@ -1545,7 +1562,7 @@ static int chip_probe(struct i2c_adapter *adap)
{ {
/* don't attach on saa7146 based cards, /* don't attach on saa7146 based cards,
because dedicated drivers are used */ because dedicated drivers are used */
if (adap->id == I2C_HW_SAA7146) if ((adap->id == I2C_HW_SAA7146))
return 0; return 0;
#ifdef I2C_CLASS_TV_ANALOG #ifdef I2C_CLASS_TV_ANALOG
if (adap->class & I2C_CLASS_TV_ANALOG) if (adap->class & I2C_CLASS_TV_ANALOG)
...@@ -1584,11 +1601,11 @@ static int chip_detach(struct i2c_client *client) ...@@ -1584,11 +1601,11 @@ static int chip_detach(struct i2c_client *client)
static int chip_command(struct i2c_client *client, static int chip_command(struct i2c_client *client,
unsigned int cmd, void *arg) unsigned int cmd, void *arg)
{ {
__u16 *sarg = arg; __u16 *sarg = arg;
struct CHIPSTATE *chip = i2c_get_clientdata(client); struct CHIPSTATE *chip = i2c_get_clientdata(client);
struct CHIPDESC *desc = chiplist + chip->type; struct CHIPDESC *desc = chiplist + chip->type;
dprintk("%s: chip_command 0x%x\n", chip->c.name, cmd); tvaudio_dbg("%s: chip_command 0x%x\n",chip->c.name,cmd);
switch (cmd) { switch (cmd) {
case AUDC_SET_INPUT: case AUDC_SET_INPUT:
...@@ -1601,7 +1618,6 @@ static int chip_command(struct i2c_client *client, ...@@ -1601,7 +1618,6 @@ static int chip_command(struct i2c_client *client,
break; break;
case AUDC_SET_RADIO: case AUDC_SET_RADIO:
dprintk(KERN_DEBUG "tvaudio: AUDC_SET_RADIO\n");
chip->norm = VIDEO_MODE_RADIO; chip->norm = VIDEO_MODE_RADIO;
chip->watch_stereo = 0; chip->watch_stereo = 0;
/* del_timer(&chip->wt); */ /* del_timer(&chip->wt); */
...@@ -1609,7 +1625,7 @@ static int chip_command(struct i2c_client *client, ...@@ -1609,7 +1625,7 @@ static int chip_command(struct i2c_client *client,
/* --- v4l ioctls --- */ /* --- v4l ioctls --- */
/* take care: bttv does userspace copying, we'll get a /* take care: bttv does userspace copying, we'll get a
kernel pointer here... */ kernel pointer here... */
case VIDIOCGAUDIO: case VIDIOCGAUDIO:
{ {
struct video_audio *va = arg; struct video_audio *va = arg;
...@@ -1643,9 +1659,9 @@ static int chip_command(struct i2c_client *client, ...@@ -1643,9 +1659,9 @@ static int chip_command(struct i2c_client *client,
if (desc->flags & CHIP_HAS_VOLUME) { if (desc->flags & CHIP_HAS_VOLUME) {
chip->left = (min(65536 - va->balance,32768) * chip->left = (min(65536 - va->balance,32768) *
va->volume) / 32768; va->volume) / 32768;
chip->right = (min(va->balance,(__u16)32768) * chip->right = (min(va->balance,(__u16)32768) *
va->volume) / 32768; va->volume) / 32768;
chip_write(chip,desc->leftreg,desc->volfunc(chip->left)); chip_write(chip,desc->leftreg,desc->volfunc(chip->left));
chip_write(chip,desc->rightreg,desc->volfunc(chip->right)); chip_write(chip,desc->rightreg,desc->volfunc(chip->right));
} }
...@@ -1667,17 +1683,16 @@ static int chip_command(struct i2c_client *client, ...@@ -1667,17 +1683,16 @@ static int chip_command(struct i2c_client *client,
{ {
struct video_channel *vc = arg; struct video_channel *vc = arg;
dprintk(KERN_DEBUG "tvaudio: VIDIOCSCHAN\n");
chip->norm = vc->norm; chip->norm = vc->norm;
break; break;
} }
case VIDIOCSFREQ: case VIDIOCSFREQ:
{ {
chip->mode = 0; /* automatic */ chip->mode = 0; /* automatic */
if (desc->checkmode) { if (desc->checkmode) {
desc->setmode(chip,VIDEO_SOUND_MONO); desc->setmode(chip,VIDEO_SOUND_MONO);
if (chip->prevmode != VIDEO_SOUND_MONO) if (chip->prevmode != VIDEO_SOUND_MONO)
chip->prevmode = -1; /* reset previous mode */ chip->prevmode = -1; /* reset previous mode */
mod_timer(&chip->wt, jiffies+2*HZ); mod_timer(&chip->wt, jiffies+2*HZ);
/* the thread will call checkmode() later */ /* the thread will call checkmode() later */
} }
...@@ -1689,29 +1704,32 @@ static int chip_command(struct i2c_client *client, ...@@ -1689,29 +1704,32 @@ static int chip_command(struct i2c_client *client,
static struct i2c_driver driver = { static struct i2c_driver driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "generic i2c audio driver", .name = "generic i2c audio driver",
.id = I2C_DRIVERID_TVAUDIO, .id = I2C_DRIVERID_TVAUDIO,
.flags = I2C_DF_NOTIFY, .flags = I2C_DF_NOTIFY,
.attach_adapter = chip_probe, .attach_adapter = chip_probe,
.detach_client = chip_detach, .detach_client = chip_detach,
.command = chip_command, .command = chip_command,
}; };
static struct i2c_client client_template = static struct i2c_client client_template =
{ {
.name = "(unset)", .name = "(unset)",
.flags = I2C_CLIENT_ALLOW_USE, .flags = I2C_CLIENT_ALLOW_USE,
.driver = &driver, .driver = &driver,
}; };
static int __init audiochip_init_module(void) static int __init audiochip_init_module(void)
{ {
struct CHIPDESC *desc; struct CHIPDESC *desc;
printk(KERN_INFO "tvaudio: TV audio decoder + audio/video mux driver\n");
printk(KERN_INFO "tvaudio: known chips: "); if (debug) {
for (desc = chiplist; desc->name != NULL; desc++) printk(KERN_INFO "tvaudio: TV audio decoder + audio/video mux driver\n");
printk("%s%s", (desc == chiplist) ? "" : ",",desc->name); printk(KERN_INFO "tvaudio: known chips: ");
printk("\n"); for (desc = chiplist; desc->name != NULL; desc++)
printk("%s%s", (desc == chiplist) ? "" : ", ", desc->name);
printk("\n");
}
return i2c_add_driver(&driver); return i2c_add_driver(&driver);
} }
......
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