Commit a7856647 authored by Gerd Knorr's avatar Gerd Knorr Committed by Linus Torvalds

[PATCH] v4l: bttv i2c audio update

This patch updates the i2c audio chip modules.  It improves the support
for tda9874x chips.  There are some bugfixes.  It also has alot of small
cleanups: switch some modules to new initialization, declare lots of
functions static, ...  which make the patch a bit large.
parent 713194bd
...@@ -24,6 +24,12 @@ ...@@ -24,6 +24,12 @@
#ifndef I2C_DRIVERID_TDA7432 #ifndef I2C_DRIVERID_TDA7432
# define I2C_DRIVERID_TDA7432 I2C_DRIVERID_EXP0+6 # define I2C_DRIVERID_TDA7432 I2C_DRIVERID_EXP0+6
#endif #endif
#ifndef I2C_DRIVERID_TDA9874A #ifndef I2C_DRIVERID_TDA9874
# define I2C_DRIVERID_TDA9874A I2C_DRIVERID_EXP0+7 # define I2C_DRIVERID_TDA9874 I2C_DRIVERID_EXP0+7
#endif #endif
/* algorithms */
#ifndef I2C_ALGO_SAA7134
# define I2C_ALGO_SAA7134 0x090000
#endif
...@@ -97,6 +97,7 @@ struct msp3400c { ...@@ -97,6 +97,7 @@ struct msp3400c {
int nicam_on; int nicam_on;
int acb; int acb;
int main, second; /* sound carrier */ int main, second; /* sound carrier */
int input;
int muted; int muted;
int left, right; /* volume */ int left, right; /* volume */
...@@ -462,6 +463,8 @@ static void msp3400c_setmode(struct i2c_client *client, int type) ...@@ -462,6 +463,8 @@ static void msp3400c_setmode(struct i2c_client *client, int type)
/* turn on/off nicam + stereo */ /* turn on/off nicam + stereo */
static void msp3400c_setstereo(struct i2c_client *client, int mode) static void msp3400c_setstereo(struct i2c_client *client, int mode)
{ {
static char *strmode[] = { "0", "mono", "stereo", "3",
"lang1", "5", "6", "7", "lang2" };
struct msp3400c *msp = client->data; struct msp3400c *msp = client->data;
int nicam=0; /* channel source: FM/AM or nicam */ int nicam=0; /* channel source: FM/AM or nicam */
int src=0; int src=0;
...@@ -469,7 +472,7 @@ static void msp3400c_setstereo(struct i2c_client *client, int mode) ...@@ -469,7 +472,7 @@ static void msp3400c_setstereo(struct i2c_client *client, int mode)
/* switch demodulator */ /* switch demodulator */
switch (msp->mode) { switch (msp->mode) {
case MSP_MODE_FM_TERRA: case MSP_MODE_FM_TERRA:
dprintk("msp3400: FM setstereo: %d\n",mode); dprintk("msp3400: FM setstereo: %s\n",strmode[mode]);
msp3400c_setcarrier(client,msp->second,msp->main); msp3400c_setcarrier(client,msp->second,msp->main);
switch (mode) { switch (mode) {
case VIDEO_SOUND_STEREO: case VIDEO_SOUND_STEREO:
...@@ -483,7 +486,7 @@ static void msp3400c_setstereo(struct i2c_client *client, int mode) ...@@ -483,7 +486,7 @@ static void msp3400c_setstereo(struct i2c_client *client, int mode)
} }
break; break;
case MSP_MODE_FM_SAT: case MSP_MODE_FM_SAT:
dprintk("msp3400: SAT setstereo: %d\n",mode); dprintk("msp3400: SAT setstereo: %s\n",strmode[mode]);
switch (mode) { switch (mode) {
case VIDEO_SOUND_MONO: case VIDEO_SOUND_MONO:
msp3400c_setcarrier(client, MSP_CARRIER(6.5), MSP_CARRIER(6.5)); msp3400c_setcarrier(client, MSP_CARRIER(6.5), MSP_CARRIER(6.5));
...@@ -502,21 +505,21 @@ static void msp3400c_setstereo(struct i2c_client *client, int mode) ...@@ -502,21 +505,21 @@ static void msp3400c_setstereo(struct i2c_client *client, int mode)
case MSP_MODE_FM_NICAM1: case MSP_MODE_FM_NICAM1:
case MSP_MODE_FM_NICAM2: case MSP_MODE_FM_NICAM2:
case MSP_MODE_AM_NICAM: case MSP_MODE_AM_NICAM:
dprintk("msp3400: NICAM setstereo: %d\n",mode); dprintk("msp3400: NICAM setstereo: %s\n",strmode[mode]);
msp3400c_setcarrier(client,msp->second,msp->main); msp3400c_setcarrier(client,msp->second,msp->main);
if (msp->nicam_on) if (msp->nicam_on)
nicam=0x0100; nicam=0x0100;
break; break;
case MSP_MODE_BTSC: case MSP_MODE_BTSC:
dprintk("msp3400: BTSC setstereo: %d\n",mode); dprintk("msp3400: BTSC setstereo: %s\n",strmode[mode]);
nicam=0x0300; nicam=0x0300;
break; break;
case MSP_MODE_EXTERN: case MSP_MODE_EXTERN:
dprintk("msp3400: extern setstereo: %d\n", mode); dprintk("msp3400: extern setstereo: %s\n",strmode[mode]);
nicam = 0x0200; nicam = 0x0200;
break; break;
case MSP_MODE_FM_RADIO: case MSP_MODE_FM_RADIO:
dprintk("msp3400: FM-Radio setstereo: %d\n", mode); dprintk("msp3400: FM-Radio setstereo: %s\n",strmode[mode]);
break; break;
default: default:
dprintk("msp3400: mono setstereo\n"); dprintk("msp3400: mono setstereo\n");
...@@ -627,7 +630,7 @@ autodetect_stereo(struct i2c_client *client) ...@@ -627,7 +630,7 @@ autodetect_stereo(struct i2c_client *client)
switch (msp->mode) { switch (msp->mode) {
case MSP_MODE_FM_TERRA: case MSP_MODE_FM_TERRA:
val = msp3400c_read(client, I2C_MSP3400C_DFP, 0x18); val = msp3400c_read(client, I2C_MSP3400C_DFP, 0x18);
if (val > 32768) if (val > 32767)
val -= 65536; val -= 65536;
dprintk("msp34xx: stereo detect register: %d\n",val); dprintk("msp34xx: stereo detect register: %d\n",val);
...@@ -822,7 +825,7 @@ static int msp3400c_thread(void *data) ...@@ -822,7 +825,7 @@ static int msp3400c_thread(void *data)
msp->restart = 0; msp->restart = 0;
val = msp3400c_read(client, I2C_MSP3400C_DFP, 0x1b); val = msp3400c_read(client, I2C_MSP3400C_DFP, 0x1b);
if (val > 32768) if (val > 32767)
val -= 65536; val -= 65536;
if (val1 < val) if (val1 < val)
val1 = val, max1 = this; val1 = val, max1 = this;
...@@ -859,7 +862,7 @@ static int msp3400c_thread(void *data) ...@@ -859,7 +862,7 @@ static int msp3400c_thread(void *data)
goto restart; goto restart;
val = msp3400c_read(client, I2C_MSP3400C_DFP, 0x1b); val = msp3400c_read(client, I2C_MSP3400C_DFP, 0x1b);
if (val > 32768) if (val > 32767)
val -= 65536; val -= 65536;
if (val2 < val) if (val2 < val)
val2 = val, max2 = this; val2 = val, max2 = this;
...@@ -1221,6 +1224,7 @@ static struct i2c_driver driver = { ...@@ -1221,6 +1224,7 @@ static struct i2c_driver driver = {
static struct i2c_client client_template = static struct i2c_client client_template =
{ {
name: "(unset)", name: "(unset)",
flags: I2C_CLIENT_ALLOW_USE,
driver: &driver, driver: &driver,
}; };
...@@ -1253,6 +1257,7 @@ static int msp_attach(struct i2c_adapter *adap, int addr, ...@@ -1253,6 +1257,7 @@ static int msp_attach(struct i2c_adapter *adap, int addr,
msp->right = 65535; msp->right = 65535;
msp->bass = 32768; msp->bass = 32768;
msp->treble = 32768; msp->treble = 32768;
msp->input = -1;
for (i = 0; i < DFP_COUNT; i++) for (i = 0; i < DFP_COUNT; i++)
msp->dfp_regs[i] = -1; msp->dfp_regs[i] = -1;
...@@ -1391,6 +1396,9 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -1391,6 +1396,9 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
- IN1 is often used for external input - IN1 is often used for external input
- Hauppauge uses IN2 for the radio */ - Hauppauge uses IN2 for the radio */
dprintk(KERN_DEBUG "msp34xx: AUDC_SET_INPUT(%d)\n",*sarg); dprintk(KERN_DEBUG "msp34xx: AUDC_SET_INPUT(%d)\n",*sarg);
if (*sarg == msp->input)
break;
msp->input = *sarg;
switch (*sarg) { switch (*sarg) {
case AUDIO_RADIO: case AUDIO_RADIO:
msp->mode = MSP_MODE_FM_RADIO; msp->mode = MSP_MODE_FM_RADIO;
...@@ -1420,6 +1428,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -1420,6 +1428,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
break; break;
case AUDC_SET_RADIO: case AUDC_SET_RADIO:
dprintk(KERN_DEBUG "msp34xx: AUDC_SET_RADIO\n");
msp->norm = VIDEO_MODE_RADIO; msp->norm = VIDEO_MODE_RADIO;
msp->watch_stereo=0; msp->watch_stereo=0;
del_timer(&msp->wake_stereo); del_timer(&msp->wake_stereo);
...@@ -1471,6 +1480,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -1471,6 +1480,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
{ {
struct video_audio *va = arg; struct video_audio *va = arg;
dprintk(KERN_DEBUG "msp34xx: VIDIOCGAUDIO\n");
va->flags |= VIDEO_AUDIO_VOLUME | va->flags |= VIDEO_AUDIO_VOLUME |
VIDEO_AUDIO_BASS | VIDEO_AUDIO_BASS |
VIDEO_AUDIO_TREBLE | VIDEO_AUDIO_TREBLE |
...@@ -1497,6 +1507,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -1497,6 +1507,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
{ {
struct video_audio *va = arg; struct video_audio *va = arg;
dprintk(KERN_DEBUG "msp34xx: VIDIOCSAUDIO\n");
msp->muted = (va->flags & VIDEO_AUDIO_MUTE); msp->muted = (va->flags & VIDEO_AUDIO_MUTE);
msp->left = (MIN(65536 - va->balance,32768) * msp->left = (MIN(65536 - va->balance,32768) *
va->volume) / 32768; va->volume) / 32768;
...@@ -1520,6 +1531,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -1520,6 +1531,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
{ {
struct video_channel *vc = arg; struct video_channel *vc = arg;
dprintk(KERN_DEBUG "msp34xx: VIDIOCSCHAN\n");
dprintk("msp34xx: switching to TV mode\n"); dprintk("msp34xx: switching to TV mode\n");
msp->norm = vc->norm; msp->norm = vc->norm;
break; break;
...@@ -1527,6 +1539,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -1527,6 +1539,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
case VIDIOCSFREQ: case VIDIOCSFREQ:
{ {
/* new channel -- kick audio carrier scan */ /* new channel -- kick audio carrier scan */
dprintk(KERN_DEBUG "msp34xx: VIDIOCSFREQ\n");
msp_wake_thread(client); msp_wake_thread(client);
break; break;
} }
...@@ -1540,13 +1553,13 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -1540,13 +1553,13 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
int msp3400_init_module(void) static int msp3400_init_module(void)
{ {
i2c_add_driver(&driver); i2c_add_driver(&driver);
return 0; return 0;
} }
void msp3400_cleanup_module(void) static void msp3400_cleanup_module(void)
{ {
i2c_del_driver(&driver); i2c_del_driver(&driver);
} }
......
...@@ -518,7 +518,7 @@ static struct i2c_client client_template = ...@@ -518,7 +518,7 @@ static struct i2c_client client_template =
&driver &driver
}; };
int tda7432_init(void) static int tda7432_init(void)
{ {
if ( (loudness < 0) || (loudness > 15) ) if ( (loudness < 0) || (loudness > 15) )
...@@ -531,7 +531,7 @@ int tda7432_init(void) ...@@ -531,7 +531,7 @@ int tda7432_init(void)
return 0; return 0;
} }
void tda7432_fini(void) static void tda7432_fini(void)
{ {
i2c_del_driver(&driver); i2c_del_driver(&driver);
} }
......
...@@ -147,6 +147,24 @@ static int tda9875_read(struct i2c_client *client) ...@@ -147,6 +147,24 @@ static int tda9875_read(struct i2c_client *client)
} }
#endif #endif
static int i2c_read_register(struct i2c_adapter *adap, int addr, int reg)
{
unsigned char write[1];
unsigned char read[1];
struct i2c_msg msgs[2] = {
{ addr, 0, 1, write },
{ addr, I2C_M_RD, 1, read }
};
write[0] = reg;
if (2 != i2c_transfer(adap,msgs,2)) {
printk(KERN_WARNING "tda9875: I/O error (read2)\n");
return -1;
}
dprintk("tda9875: chip_read2: reg%d=0x%x\n",reg,read[0]);
return read[0];
}
static void tda9875_set(struct i2c_client *client) static void tda9875_set(struct i2c_client *client)
{ {
struct tda9875 *tda = client->data; struct tda9875 *tda = client->data;
...@@ -215,6 +233,22 @@ static void do_tda9875_init(struct i2c_client *client) ...@@ -215,6 +233,22 @@ static void do_tda9875_init(struct i2c_client *client)
* i2c interface functions * * i2c interface functions *
* *********************** */ * *********************** */
static int tda9875_checkit(struct i2c_adapter *adap, int addr)
{
int dic,rev;
dic=i2c_read_register(adap,addr,254);
rev=i2c_read_register(adap,addr,255);
if(dic==0 || dic==2) { // tda9875 and tda9875A
printk("tda9875: TDA9875%s Rev.%d detected at 0x%x\n",
dic==0?"":"A", rev,addr<<1);
return 1;
}
printk("tda9875: no such chip at 0x%x (dic=0x%x rev=0x%x)\n",addr<<1,dic,rev);
return(0);
}
static int tda9875_attach(struct i2c_adapter *adap, int addr, static int tda9875_attach(struct i2c_adapter *adap, int addr,
unsigned short flags, int kind) unsigned short flags, int kind)
{ {
...@@ -232,6 +266,11 @@ static int tda9875_attach(struct i2c_adapter *adap, int addr, ...@@ -232,6 +266,11 @@ static int tda9875_attach(struct i2c_adapter *adap, int addr,
client->adapter = adap; client->adapter = adap;
client->addr = addr; client->addr = addr;
client->data = t; client->data = t;
if(!tda9875_checkit(adap,addr)) {
kfree(t);
return 1;
}
do_tda9875_init(client); do_tda9875_init(client);
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
...@@ -375,22 +414,19 @@ static struct i2c_client client_template = ...@@ -375,22 +414,19 @@ static struct i2c_client client_template =
&driver &driver
}; };
#ifdef MODULE static int tda9875_init(void)
int init_module(void)
#else
int tda9875_init(void)
#endif
{ {
i2c_add_driver(&driver); i2c_add_driver(&driver);
return 0; return 0;
} }
#ifdef MODULE static void tda9875_fini(void)
void cleanup_module(void)
{ {
i2c_del_driver(&driver); i2c_del_driver(&driver);
} }
#endif
module_init(tda9875_init);
module_exit(tda9875_fini);
/* /*
* Local variables: * Local variables:
......
...@@ -120,14 +120,17 @@ struct CHIPSTATE { ...@@ -120,14 +120,17 @@ struct CHIPSTATE {
/* current settings */ /* current settings */
__u16 left,right,treble,bass,mode; __u16 left,right,treble,bass,mode;
int prevmode; int prevmode;
int norm;
/* thread */ /* thread */
struct task_struct *thread; struct task_struct *thread;
struct semaphore *notify; struct semaphore *notify;
wait_queue_head_t wq; wait_queue_head_t wq;
struct timer_list wt; struct timer_list wt;
int done; int done;
int watch_stereo;
}; };
#define VIDEO_MODE_RADIO 16 /* norm magic for radio mode */
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
/* i2c addresses */ /* i2c addresses */
...@@ -139,7 +142,7 @@ static unsigned short normal_i2c[] = { ...@@ -139,7 +142,7 @@ static unsigned short normal_i2c[] = {
I2C_TDA9840 >> 1, I2C_TDA9840 >> 1,
I2C_TDA985x_L >> 1, I2C_TDA985x_L >> 1,
I2C_TDA985x_H >> 1, I2C_TDA985x_H >> 1,
I2C_TDA9874A >> 1, I2C_TDA9874 >> 1,
I2C_PIC16C54 >> 1, I2C_PIC16C54 >> 1,
I2C_CLIENT_END }; I2C_CLIENT_END };
static unsigned short normal_i2c_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; static unsigned short normal_i2c_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
...@@ -296,9 +299,9 @@ static int chip_thread(void *data) ...@@ -296,9 +299,9 @@ static int chip_thread(void *data)
dprintk("%s: thread wakeup\n", chip->c.name); dprintk("%s: thread wakeup\n", chip->c.name);
if (chip->done || signal_pending(current)) if (chip->done || signal_pending(current))
break; break;
if (0 != chip->mode) /* don't do anything for radio or if mode != auto */
/* don't do anything if mode != auto */ if (chip->norm == VIDEO_MODE_RADIO || chip->mode != 0)
continue; continue;
/* have a look what's going on */ /* have a look what's going on */
...@@ -316,7 +319,7 @@ static int chip_thread(void *data) ...@@ -316,7 +319,7 @@ static int chip_thread(void *data)
return 0; return 0;
} }
void generic_checkmode(struct CHIPSTATE *chip) static void generic_checkmode(struct CHIPSTATE *chip)
{ {
struct CHIPDESC *desc = chiplist + chip->type; struct CHIPDESC *desc = chiplist + chip->type;
int mode = desc->getmode(chip); int mode = desc->getmode(chip);
...@@ -327,12 +330,12 @@ void generic_checkmode(struct CHIPSTATE *chip) ...@@ -327,12 +330,12 @@ void generic_checkmode(struct CHIPSTATE *chip)
dprintk("%s: thread checkmode\n", chip->c.name); dprintk("%s: thread checkmode\n", chip->c.name);
chip->prevmode = mode; chip->prevmode = mode;
if (mode & VIDEO_SOUND_LANG1) if (mode & VIDEO_SOUND_STEREO)
desc->setmode(chip,VIDEO_SOUND_STEREO);
else if (mode & VIDEO_SOUND_LANG1)
desc->setmode(chip,VIDEO_SOUND_LANG1); desc->setmode(chip,VIDEO_SOUND_LANG1);
else if (mode & VIDEO_SOUND_LANG2) else if (mode & VIDEO_SOUND_LANG2)
desc->setmode(chip,VIDEO_SOUND_LANG2); desc->setmode(chip,VIDEO_SOUND_LANG2);
else if (mode & VIDEO_SOUND_STEREO)
desc->setmode(chip,VIDEO_SOUND_STEREO);
else else
desc->setmode(chip,VIDEO_SOUND_MONO); desc->setmode(chip,VIDEO_SOUND_MONO);
} }
...@@ -360,7 +363,7 @@ void generic_checkmode(struct CHIPSTATE *chip) ...@@ -360,7 +363,7 @@ void generic_checkmode(struct CHIPSTATE *chip)
#define TDA9840_TEST_INT1SN 0x1 /* Integration time 0.5s when set */ #define TDA9840_TEST_INT1SN 0x1 /* Integration time 0.5s when set */
#define TDA9840_TEST_INTFU 0x02 /* Disables integrator function */ #define TDA9840_TEST_INTFU 0x02 /* Disables integrator function */
int tda9840_getmode(struct CHIPSTATE *chip) static int tda9840_getmode(struct CHIPSTATE *chip)
{ {
int val, mode; int val, mode;
...@@ -376,7 +379,7 @@ int tda9840_getmode(struct CHIPSTATE *chip) ...@@ -376,7 +379,7 @@ int tda9840_getmode(struct CHIPSTATE *chip)
return mode; return mode;
} }
void tda9840_setmode(struct CHIPSTATE *chip, int mode) static void tda9840_setmode(struct CHIPSTATE *chip, int mode)
{ {
int update = 1; int update = 1;
int t = chip->shadow.bytes[TDA9840_SW + 1] & ~0x7e; int t = chip->shadow.bytes[TDA9840_SW + 1] & ~0x7e;
...@@ -502,11 +505,11 @@ void tda9840_setmode(struct CHIPSTATE *chip, int mode) ...@@ -502,11 +505,11 @@ void tda9840_setmode(struct CHIPSTATE *chip, int mode)
* -10% (0x2), nominal (0x3), +10% (0x6), +20% (0x5), +30% (0x4) */ * -10% (0x2), nominal (0x3), +10% (0x6), +20% (0x5), +30% (0x4) */
#define TDA985x_ADJ 1<<7 /* Stereo adjust on/off (wideband and spectral */ #define TDA985x_ADJ 1<<7 /* Stereo adjust on/off (wideband and spectral */
int tda9855_volume(int val) { return val/0x2e8+0x27; } static int tda9855_volume(int val) { return val/0x2e8+0x27; }
int tda9855_bass(int val) { return val/0xccc+0x06; } static int tda9855_bass(int val) { return val/0xccc+0x06; }
int tda9855_treble(int val) { return (val/0x1c71+0x3)<<1; } static int tda9855_treble(int val) { return (val/0x1c71+0x3)<<1; }
int tda985x_getmode(struct CHIPSTATE *chip) static int tda985x_getmode(struct CHIPSTATE *chip)
{ {
int mode; int mode;
...@@ -517,7 +520,7 @@ int tda985x_getmode(struct CHIPSTATE *chip) ...@@ -517,7 +520,7 @@ int tda985x_getmode(struct CHIPSTATE *chip)
return mode | VIDEO_SOUND_MONO; return mode | VIDEO_SOUND_MONO;
} }
void tda985x_setmode(struct CHIPSTATE *chip, int mode) static void tda985x_setmode(struct CHIPSTATE *chip, int mode)
{ {
int update = 1; int update = 1;
int c6 = chip->shadow.bytes[TDA985x_C6+1] & 0x3f; int c6 = chip->shadow.bytes[TDA985x_C6+1] & 0x3f;
...@@ -657,7 +660,7 @@ void tda985x_setmode(struct CHIPSTATE *chip, int mode) ...@@ -657,7 +660,7 @@ void tda985x_setmode(struct CHIPSTATE *chip, int mode)
#define TDA9873_STEREO 2 /* Stereo sound is identified */ #define TDA9873_STEREO 2 /* Stereo sound is identified */
#define TDA9873_DUAL 4 /* Dual sound is identified */ #define TDA9873_DUAL 4 /* Dual sound is identified */
int tda9873_getmode(struct CHIPSTATE *chip) static int tda9873_getmode(struct CHIPSTATE *chip)
{ {
int val,mode; int val,mode;
...@@ -672,7 +675,7 @@ int tda9873_getmode(struct CHIPSTATE *chip) ...@@ -672,7 +675,7 @@ int tda9873_getmode(struct CHIPSTATE *chip)
return mode; return mode;
} }
void tda9873_setmode(struct CHIPSTATE *chip, int mode) static void tda9873_setmode(struct CHIPSTATE *chip, int mode)
{ {
int sw_data = chip->shadow.bytes[TDA9873_SW+1] & ~ TDA9873_TR_MASK; int sw_data = chip->shadow.bytes[TDA9873_SW+1] & ~ TDA9873_TR_MASK;
/* int adj_data = chip->shadow.bytes[TDA9873_AD+1] ; */ /* int adj_data = chip->shadow.bytes[TDA9873_AD+1] ; */
...@@ -708,7 +711,7 @@ void tda9873_setmode(struct CHIPSTATE *chip, int mode) ...@@ -708,7 +711,7 @@ void tda9873_setmode(struct CHIPSTATE *chip, int mode)
mode, sw_data); mode, sw_data);
} }
int tda9873_checkit(struct CHIPSTATE *chip) static int tda9873_checkit(struct CHIPSTATE *chip)
{ {
int rc; int rc;
...@@ -719,10 +722,10 @@ int tda9873_checkit(struct CHIPSTATE *chip) ...@@ -719,10 +722,10 @@ int tda9873_checkit(struct CHIPSTATE *chip)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
/* audio chip description - defines+functions for tda9874a */ /* audio chip description - defines+functions for tda9874h and tda9874a */
/* Dariusz Kowalewski <darekk@automex.pl> */ /* Dariusz Kowalewski <darekk@automex.pl> */
/* Subaddresses for TDA9874A (slave rx) */ /* Subaddresses for TDA9874H and TDA9874A (slave rx) */
#define TDA9874A_AGCGR 0x00 /* AGC gain */ #define TDA9874A_AGCGR 0x00 /* AGC gain */
#define TDA9874A_GCONR 0x01 /* general config */ #define TDA9874A_GCONR 0x01 /* general config */
#define TDA9874A_MSR 0x02 /* monitor select */ #define TDA9874A_MSR 0x02 /* monitor select */
...@@ -747,10 +750,10 @@ int tda9873_checkit(struct CHIPSTATE *chip) ...@@ -747,10 +750,10 @@ int tda9873_checkit(struct CHIPSTATE *chip)
#define TDA9874A_DAICONR 0x15 /* digital audio interface config */ #define TDA9874A_DAICONR 0x15 /* digital audio interface config */
#define TDA9874A_I2SOSR 0x16 /* I2S-bus output select */ #define TDA9874A_I2SOSR 0x16 /* I2S-bus output select */
#define TDA9874A_I2SOLAR 0x17 /* I2S-bus output level adj. */ #define TDA9874A_I2SOLAR 0x17 /* I2S-bus output level adj. */
#define TDA9874A_MDACOSR 0x18 /* mono DAC output select */ #define TDA9874A_MDACOSR 0x18 /* mono DAC output select (tda9874a) */
#define TDA9874A_ESP 0xFF /* easy standard progr. */ #define TDA9874A_ESP 0xFF /* easy standard progr. (tda9874a) */
/* Subaddresses for TDA9874A (slave tx) */ /* Subaddresses for TDA9874H and TDA9874A (slave tx) */
#define TDA9874A_DSR 0x00 /* device status */ #define TDA9874A_DSR 0x00 /* device status */
#define TDA9874A_NSR 0x01 /* NICAM status */ #define TDA9874A_NSR 0x01 /* NICAM status */
#define TDA9874A_NECR 0x02 /* NICAM error count */ #define TDA9874A_NECR 0x02 /* NICAM error count */
...@@ -767,37 +770,91 @@ int tda9873_checkit(struct CHIPSTATE *chip) ...@@ -767,37 +770,91 @@ int tda9873_checkit(struct CHIPSTATE *chip)
static int tda9874a_mode = 1; /* 0: A2, 1: NICAM */ static int tda9874a_mode = 1; /* 0: A2, 1: NICAM */
static int tda9874a_GCONR = 0xc0; /* default config. input pin: SIFSEL=0 */ static int tda9874a_GCONR = 0xc0; /* default config. input pin: SIFSEL=0 */
static int tda9874a_NCONR = 0x01; /* default NICAM config.: AMSEL=0,AMUTE=1 */
static int tda9874a_ESP = 0x07; /* default standard: NICAM D/K */ static int tda9874a_ESP = 0x07; /* default standard: NICAM D/K */
static int tda9874a_dic = -1; /* device id. code */
/* insmod options for tda9874a */ /* insmod options for tda9874a */
static int tda9874a_SIF = -1; static int tda9874a_SIF = -1;
static int tda9874a_AMSEL = -1;
static int tda9874a_STD = -1; static int tda9874a_STD = -1;
MODULE_PARM(tda9874a_SIF,"i"); MODULE_PARM(tda9874a_SIF,"i");
MODULE_PARM(tda9874a_AMSEL,"i");
MODULE_PARM(tda9874a_STD,"i"); MODULE_PARM(tda9874a_STD,"i");
/*
* initialization table for tda9874 decoder:
* - carrier 1 freq. registers (3 bytes)
* - carrier 2 freq. registers (3 bytes)
* - demudulator config register
* - FM de-emphasis register (slow identification mode)
* Note: frequency registers must be written in single i2c transfer.
*/
static struct tda9874a_MODES {
char *name;
audiocmd cmd;
} tda9874a_modelist[9] = {
{ "A2, B/G",
{ 9, { TDA9874A_C1FRA, 0x72,0x95,0x55, 0x77,0xA0,0x00, 0x00,0x00 }} },
{ "A2, M (Korea)",
{ 9, { TDA9874A_C1FRA, 0x5D,0xC0,0x00, 0x62,0x6A,0xAA, 0x20,0x22 }} },
{ "A2, D/K (1)",
{ 9, { TDA9874A_C1FRA, 0x87,0x6A,0xAA, 0x82,0x60,0x00, 0x00,0x00 }} },
{ "A2, D/K (2)",
{ 9, { TDA9874A_C1FRA, 0x87,0x6A,0xAA, 0x8C,0x75,0x55, 0x00,0x00 }} },
{ "A2, D/K (3)",
{ 9, { TDA9874A_C1FRA, 0x87,0x6A,0xAA, 0x77,0xA0,0x00, 0x00,0x00 }} },
{ "NICAM, I",
{ 9, { TDA9874A_C1FRA, 0x7D,0x00,0x00, 0x88,0x8A,0xAA, 0x08,0x33 }} },
{ "NICAM, B/G",
{ 9, { TDA9874A_C1FRA, 0x72,0x95,0x55, 0x79,0xEA,0xAA, 0x08,0x33 }} },
{ "NICAM, D/K", /* default */
{ 9, { TDA9874A_C1FRA, 0x87,0x6A,0xAA, 0x79,0xEA,0xAA, 0x08,0x33 }} },
{ "NICAM, L",
{ 9, { TDA9874A_C1FRA, 0x87,0x6A,0xAA, 0x79,0xEA,0xAA, 0x09,0x33 }} }
};
static int tda9874a_setup(struct CHIPSTATE *chip) static int tda9874a_setup(struct CHIPSTATE *chip)
{ {
chip_write(chip, TDA9874A_AGCGR, 0x00); /* 0 dB */ chip_write(chip, TDA9874A_AGCGR, 0x00); /* 0 dB */
chip_write(chip, TDA9874A_GCONR, tda9874a_GCONR); chip_write(chip, TDA9874A_GCONR, tda9874a_GCONR);
chip_write(chip, TDA9874A_MSR, (tda9874a_mode) ? 0x03:0x02); chip_write(chip, TDA9874A_MSR, (tda9874a_mode) ? 0x03:0x02);
chip_write(chip, TDA9874A_FMMR, 0x80); if(tda9874a_dic == 0x11) {
chip_write(chip, TDA9874A_FMMR, 0x80);
} else { /* dic == 0x07 */
chip_cmd(chip,"tda9874_modelist",&tda9874a_modelist[tda9874a_STD].cmd);
chip_write(chip, TDA9874A_FMMR, 0x00);
}
chip_write(chip, TDA9874A_C1OLAR, 0x00); /* 0 dB */ chip_write(chip, TDA9874A_C1OLAR, 0x00); /* 0 dB */
chip_write(chip, TDA9874A_C2OLAR, 0x00); /* 0 dB */ chip_write(chip, TDA9874A_C2OLAR, 0x00); /* 0 dB */
chip_write(chip, TDA9874A_NCONR, 0x00); /* not 0x04 as doc. table 10 says! */ chip_write(chip, TDA9874A_NCONR, tda9874a_NCONR);
chip_write(chip, TDA9874A_NOLAR, 0x00); /* 0 dB */ chip_write(chip, TDA9874A_NOLAR, 0x00); /* 0 dB */
chip_write(chip, TDA9874A_AMCONR, 0xf9); /* Note: If signal quality is poor you may want to change NICAM */
chip_write(chip, TDA9874A_SDACOSR, (tda9874a_mode) ? 0x81:0x80); /* 0x81 */ /* error limit registers (NLELR and NUELR) to some greater values. */
chip_write(chip, TDA9874A_AOSR, 0x80); /* Then the sound would remain stereo, but won't be so clear. */
chip_write(chip, TDA9874A_MDACOSR, (tda9874a_mode) ? 0x82:0x80); chip_write(chip, TDA9874A_NLELR, 0x14); /* default */
chip_write(chip, TDA9874A_ESP, tda9874a_ESP); chip_write(chip, TDA9874A_NUELR, 0x50); /* default */
if(tda9874a_dic == 0x11) {
chip_write(chip, TDA9874A_AMCONR, 0xf9);
chip_write(chip, TDA9874A_SDACOSR, (tda9874a_mode) ? 0x81:0x80);
chip_write(chip, TDA9874A_AOSR, 0x80);
chip_write(chip, TDA9874A_MDACOSR, (tda9874a_mode) ? 0x82:0x80);
chip_write(chip, TDA9874A_ESP, tda9874a_ESP);
} else { /* dic == 0x07 */
chip_write(chip, TDA9874A_AMCONR, 0xfb);
chip_write(chip, TDA9874A_SDACOSR, (tda9874a_mode) ? 0x81:0x80);
chip_write(chip, TDA9874A_AOSR, 0x00); // or 0x10
}
dprintk("tda9874a_setup(): %s [0x%02X].\n",
tda9874a_modelist[tda9874a_STD].name,tda9874a_STD);
return 1; return 1;
} }
int tda9874a_getmode(struct CHIPSTATE *chip) static int tda9874a_getmode(struct CHIPSTATE *chip)
{ {
int dsr,nsr,mode; int dsr,nsr,mode;
int necr; /* just for debugging */
mode = VIDEO_SOUND_MONO; mode = VIDEO_SOUND_MONO;
...@@ -805,55 +862,125 @@ int tda9874a_getmode(struct CHIPSTATE *chip) ...@@ -805,55 +862,125 @@ int tda9874a_getmode(struct CHIPSTATE *chip)
return mode; return mode;
if(-1 == (nsr = chip_read2(chip,TDA9874A_NSR))) if(-1 == (nsr = chip_read2(chip,TDA9874A_NSR)))
return mode; return mode;
if(-1 == (necr = chip_read2(chip,TDA9874A_NECR)))
return mode;
/* need to store dsr/nsr somewhere */
chip->shadow.bytes[MAXREGS-2] = dsr;
chip->shadow.bytes[MAXREGS-1] = nsr;
if(tda9874a_mode) { if(tda9874a_mode) {
/* check also DSR.RSSF and DSR.AMSTAT bits? */ /* Note: DSR.RSSF and DSR.AMSTAT bits are also checked.
if(nsr & 0x02) /* NSR.S/MB */ * If NICAM auto-muting is enabled, DSR.AMSTAT=1 indicates
* that sound has (temporarily) switched from NICAM to
* mono FM (or AM) on 1st sound carrier due to high NICAM bit
* error count. So in fact there is no stereo in this case :-(
* But changing the mode to VIDEO_SOUND_MONO would switch
* external 4052 multiplexer in audio_hook().
*/
#if 0
if((nsr & 0x02) && !(dsr & 0x10)) /* NSR.S/MB=1 and DSR.AMSTAT=0 */
mode |= VIDEO_SOUND_STEREO;
#else
if(nsr & 0x02) /* NSR.S/MB=1 */
mode |= VIDEO_SOUND_STEREO; mode |= VIDEO_SOUND_STEREO;
if(nsr & 0x01) /* NSR.D/SB */ #endif
if(nsr & 0x01) /* NSR.D/SB=1 */
mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
} else { } else {
if(dsr & 0x02) /* DSR.IDSTE */ if(dsr & 0x02) /* DSR.IDSTE=1 */
mode |= VIDEO_SOUND_STEREO; mode |= VIDEO_SOUND_STEREO;
if(dsr & 0x04) /* DSR.IDDUA */ if(dsr & 0x04) /* DSR.IDDUA=1 */
mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
} }
dprintk("tda9874a_getmode(): DSR=0x%X, NSR=0x%X, return: %d.\n", dprintk("tda9874a_getmode(): DSR=0x%X, NSR=0x%X, NECR=0x%X, return: %d.\n",
dsr, nsr, mode); dsr, nsr, necr, mode);
return mode; return mode;
} }
void tda9874a_setmode(struct CHIPSTATE *chip, int mode) static void tda9874a_setmode(struct CHIPSTATE *chip, int mode)
{ {
int aosr=0x80,mdacosr=0x82; /* Disable/enable NICAM auto-muting (based on DSR.RSSF status bit). */
/* If auto-muting is disabled, we can hear a signal of degrading quality. */
/* note: TDA9874A has auto-select function for audio output */ if(tda9874a_mode) {
switch(mode) { if(chip->shadow.bytes[MAXREGS-2] & 0x20) /* DSR.RSSF=1 */
case VIDEO_SOUND_MONO: tda9874a_NCONR &= 0xfe; /* enable */
case VIDEO_SOUND_STEREO: else
break; tda9874a_NCONR |= 0x01; /* disable */
case VIDEO_SOUND_LANG1: chip_write(chip, TDA9874A_NCONR, tda9874a_NCONR);
aosr = 0x80; /* dual A/A */
mdacosr = (tda9874a_mode) ? 0x82:0x80;
break;
case VIDEO_SOUND_LANG2:
aosr = 0xa0; /* dual B/B */
mdacosr = (tda9874a_mode) ? 0x83:0x81;
break;
default:
chip->mode = 0;
return;
} }
chip_write(chip, TDA9874A_AOSR, aosr); /* Note: TDA9874A supports automatic FM dematrixing (FMMR register)
chip_write(chip, TDA9874A_MDACOSR, mdacosr); * and has auto-select function for audio output (AOSR register).
* Old TDA9874H doesn't support these features.
* TDA9874A also has additional mono output pin (OUTM), which
* on same (all?) tv-cards is not used, anyway (as well as MONOIN).
*/
if(tda9874a_dic == 0x11) {
int aosr = 0x80;
int mdacosr = (tda9874a_mode) ? 0x82:0x80;
switch(mode) {
case VIDEO_SOUND_MONO:
case VIDEO_SOUND_STEREO:
break;
case VIDEO_SOUND_LANG1:
aosr = 0x80; /* auto-select, dual A/A */
mdacosr = (tda9874a_mode) ? 0x82:0x80;
break;
case VIDEO_SOUND_LANG2:
aosr = 0xa0; /* auto-select, dual B/B */
mdacosr = (tda9874a_mode) ? 0x83:0x81;
break;
default:
chip->mode = 0;
return;
}
chip_write(chip, TDA9874A_AOSR, aosr);
chip_write(chip, TDA9874A_MDACOSR, mdacosr);
dprintk("tda9874a_setmode(): req. mode %d; AOSR=0x%X, MDACOSR=0x%X.\n",
mode, aosr, mdacosr);
} else { /* dic == 0x07 */
int fmmr,aosr;
switch(mode) {
case VIDEO_SOUND_MONO:
fmmr = 0x00; /* mono */
aosr = 0x10; /* A/A */
break;
case VIDEO_SOUND_STEREO:
if(tda9874a_mode) {
fmmr = 0x00;
aosr = 0x00; /* handled by NICAM auto-mute */
} else {
fmmr = (tda9874a_ESP == 1) ? 0x05 : 0x04; /* stereo */
aosr = 0x00;
}
break;
case VIDEO_SOUND_LANG1:
fmmr = 0x02; /* dual */
aosr = 0x10; /* dual A/A */
break;
case VIDEO_SOUND_LANG2:
fmmr = 0x02; /* dual */
aosr = 0x20; /* dual B/B */
break;
default:
chip->mode = 0;
return;
}
chip_write(chip, TDA9874A_FMMR, fmmr);
chip_write(chip, TDA9874A_AOSR, aosr);
dprintk("tda9874a_setmode(): req. mode %d; AOSR=0x%X, MDACOSR=0x%X.\n", dprintk("tda9874a_setmode(): req. mode %d; FMMR=0x%X, AOSR=0x%X.\n",
mode, aosr, mdacosr); mode, fmmr, aosr);
}
} }
int tda9874a_checkit(struct CHIPSTATE *chip) static int tda9874a_checkit(struct CHIPSTATE *chip)
{ {
int dic,sic; /* device id. and software id. codes */ int dic,sic; /* device id. and software id. codes */
...@@ -864,10 +991,15 @@ int tda9874a_checkit(struct CHIPSTATE *chip) ...@@ -864,10 +991,15 @@ int tda9874a_checkit(struct CHIPSTATE *chip)
dprintk("tda9874a_checkit(): DIC=0x%X, SIC=0x%X.\n", dic, sic); dprintk("tda9874a_checkit(): DIC=0x%X, SIC=0x%X.\n", dic, sic);
return((dic & 0xff) == 0x11); if((dic == 0x11)||(dic == 0x07)) {
dprintk("tvaudio: found tda9874%s.\n",(dic == 0x11) ? "a (new)":"h (old)");
tda9874a_dic = dic; /* remember device id. */
return 1;
}
return 0; /* not found */
} }
int tda9874a_initialize(struct CHIPSTATE *chip) static int tda9874a_initialize(struct CHIPSTATE *chip)
{ {
if(tda9874a_SIF != -1) { if(tda9874a_SIF != -1) {
if(tda9874a_SIF == 1) if(tda9874a_SIF == 1)
...@@ -887,6 +1019,15 @@ int tda9874a_initialize(struct CHIPSTATE *chip) ...@@ -887,6 +1019,15 @@ int tda9874a_initialize(struct CHIPSTATE *chip)
} }
} }
if(tda9874a_AMSEL != -1) {
if(tda9874a_AMSEL == 0)
tda9874a_NCONR = 0x01; /* auto-mute: analog mono input */
else if(tda9874a_AMSEL == 1)
tda9874a_NCONR = 0x05; /* auto-mute: 1st carrier FM or AM */
else
printk(KERN_WARNING "tda9874a: AMSEL parameter must be 0 or 1.\n");
}
tda9874a_setup(chip); tda9874a_setup(chip);
return 0; return 0;
...@@ -915,8 +1056,8 @@ int tda9874a_initialize(struct CHIPSTATE *chip) ...@@ -915,8 +1056,8 @@ int tda9874a_initialize(struct CHIPSTATE *chip)
#define TEA6420_S_SE 0x04 /* stereo E */ #define TEA6420_S_SE 0x04 /* stereo E */
#define TEA6420_S_GMU 0x05 /* general mute */ #define TEA6420_S_GMU 0x05 /* general mute */
int tea6300_shift10(int val) { return val >> 10; } static int tea6300_shift10(int val) { return val >> 10; }
int tea6300_shift12(int val) { return val >> 12; } static int tea6300_shift12(int val) { return val >> 12; }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
...@@ -931,8 +1072,8 @@ int tea6300_shift12(int val) { return val >> 12; } ...@@ -931,8 +1072,8 @@ int tea6300_shift12(int val) { return val >> 12; }
#define TDA8425_S1_OFF 0xEE /* audio off (mute on) */ #define TDA8425_S1_OFF 0xEE /* audio off (mute on) */
#define TDA8425_S1_ON 0xCE /* audio on (mute off) - "linear stereo" mode */ #define TDA8425_S1_ON 0xCE /* audio on (mute off) - "linear stereo" mode */
int tda8425_shift10(int val) { return val >> 10 | 0xc0; } static int tda8425_shift10(int val) { return val >> 10 | 0xc0; }
int tda8425_shift12(int val) { return val >> 12 | 0xf0; } static int tda8425_shift12(int val) { return val >> 12 | 0xf0; }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
...@@ -1015,13 +1156,13 @@ static struct CHIPDESC chiplist[] = { ...@@ -1015,13 +1156,13 @@ static struct CHIPDESC chiplist[] = {
}, },
{ {
name: "tda9874a", name: "tda9874h/a",
id: I2C_DRIVERID_TDA9874A, id: I2C_DRIVERID_TDA9874,
checkit: tda9874a_checkit, checkit: tda9874a_checkit,
initialize: tda9874a_initialize, initialize: tda9874a_initialize,
insmodopt: &tda9874a, insmodopt: &tda9874a,
addr_lo: I2C_TDA9874A >> 1, addr_lo: I2C_TDA9874 >> 1,
addr_hi: I2C_TDA9874A >> 1, addr_hi: I2C_TDA9874 >> 1,
getmode: tda9874a_getmode, getmode: tda9874a_getmode,
setmode: tda9874a_setmode, setmode: tda9874a_setmode,
...@@ -1160,7 +1301,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr, ...@@ -1160,7 +1301,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr,
chip->c.data = chip; chip->c.data = chip;
/* find description for the chip */ /* find description for the chip */
dprintk("tvaudio: chip @ addr=0x%x\n", addr<<1); dprintk("tvaudio: chip found @ i2c-addr=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;
...@@ -1175,7 +1316,8 @@ static int chip_attach(struct i2c_adapter *adap, int addr, ...@@ -1175,7 +1316,8 @@ static int chip_attach(struct i2c_adapter *adap, int addr,
dprintk("tvaudio: no matching chip description found\n"); dprintk("tvaudio: no matching chip description found\n");
return -EIO; return -EIO;
} }
dprintk("tvaudio: %s matches:%s%s%s\n",desc->name, printk("tvaudio: found %s\n",desc->name);
dprintk("tvaudio: matches:%s%s%s.\n",
(desc->flags & CHIP_HAS_VOLUME) ? " volume" : "", (desc->flags & CHIP_HAS_VOLUME) ? " volume" : "",
(desc->flags & CHIP_HAS_BASSTREBLE) ? " bass/treble" : "", (desc->flags & CHIP_HAS_BASSTREBLE) ? " bass/treble" : "",
(desc->flags & CHIP_HAS_INPUTSEL) ? " audiomux" : ""); (desc->flags & CHIP_HAS_INPUTSEL) ? " audiomux" : "");
...@@ -1272,6 +1414,14 @@ static int chip_command(struct i2c_client *client, ...@@ -1272,6 +1414,14 @@ static int chip_command(struct i2c_client *client,
chip_write_masked(chip,desc->inputreg,desc->inputmap[*sarg],desc->inputmask); chip_write_masked(chip,desc->inputreg,desc->inputmap[*sarg],desc->inputmask);
} }
break; break;
case AUDC_SET_RADIO:
dprintk(KERN_DEBUG "tvaudio: AUDC_SET_RADIO\n");
chip->norm = VIDEO_MODE_RADIO;
chip->watch_stereo = 0;
/* del_timer(&chip->wt); */
break;
/* --- 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... */
...@@ -1290,10 +1440,12 @@ static int chip_command(struct i2c_client *client, ...@@ -1290,10 +1440,12 @@ static int chip_command(struct i2c_client *client,
va->bass = chip->bass; va->bass = chip->bass;
va->treble = chip->treble; va->treble = chip->treble;
} }
if (desc->getmode) if (chip->norm != VIDEO_MODE_RADIO) {
va->mode = desc->getmode(chip); if (desc->getmode)
else va->mode = desc->getmode(chip);
va->mode = VIDEO_SOUND_MONO; else
va->mode = VIDEO_SOUND_MONO;
}
break; break;
} }
...@@ -1316,11 +1468,21 @@ static int chip_command(struct i2c_client *client, ...@@ -1316,11 +1468,21 @@ static int chip_command(struct i2c_client *client,
chip_write(chip,desc->treblereg,desc->treblefunc(chip->treble)); chip_write(chip,desc->treblereg,desc->treblefunc(chip->treble));
} }
if (desc->setmode && va->mode) { if (desc->setmode && va->mode) {
chip->watch_stereo = 0;
/* del_timer(&chip->wt); */
chip->mode = va->mode; chip->mode = va->mode;
desc->setmode(chip,va->mode); desc->setmode(chip,va->mode);
} }
break; break;
} }
case VIDIOCSCHAN:
{
struct video_channel *vc = arg;
dprintk(KERN_DEBUG "tvaudio: VIDIOCSCHAN\n");
chip->norm = vc->norm;
break;
}
case VIDIOCSFREQ: case VIDIOCSFREQ:
{ {
chip->mode = 0; /* automatic */ chip->mode = 0; /* automatic */
...@@ -1339,7 +1501,7 @@ static int chip_command(struct i2c_client *client, ...@@ -1339,7 +1501,7 @@ static int chip_command(struct i2c_client *client,
static struct i2c_driver driver = { static struct i2c_driver driver = {
name: "generic i2c audio driver", name: "generic i2c audio driver",
id: I2C_DRIVERID_TVAUDIO, /* FIXME */ 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,
...@@ -1349,10 +1511,11 @@ static struct i2c_driver driver = { ...@@ -1349,10 +1511,11 @@ static struct i2c_driver driver = {
static struct i2c_client client_template = static struct i2c_client client_template =
{ {
name: "(unset)", name: "(unset)",
flags: I2C_CLIENT_ALLOW_USE,
driver: &driver, driver: &driver,
}; };
int audiochip_init_module(void) static int 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: TV audio decoder + audio/video mux driver\n");
...@@ -1364,7 +1527,7 @@ int audiochip_init_module(void) ...@@ -1364,7 +1527,7 @@ int audiochip_init_module(void)
return 0; return 0;
} }
void audiochip_cleanup_module(void) static void audiochip_cleanup_module(void)
{ {
i2c_del_driver(&driver); i2c_del_driver(&driver);
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#define I2C_TDA9840 0x84 #define I2C_TDA9840 0x84
#define I2C_TDA985x_L 0xb4 /* also used by 9873 */ #define I2C_TDA985x_L 0xb4 /* also used by 9873 */
#define I2C_TDA985x_H 0xb6 #define I2C_TDA985x_H 0xb6
#define I2C_TDA9874A 0xb0 /* also used by 9875 */ #define I2C_TDA9874 0xb0 /* also used by 9875 */
#define I2C_TEA6300 0x80 #define I2C_TEA6300 0x80
#define I2C_TEA6420 0x98 #define I2C_TEA6420 0x98
......
...@@ -8,8 +8,9 @@ ...@@ -8,8 +8,9 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/videodev.h> #include <linux/videodev.h>
#include <asm/semaphore.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kdev_t.h>
#include <asm/semaphore.h>
#include <linux/sound.h> #include <linux/sound.h>
#include <linux/soundcard.h> #include <linux/soundcard.h>
...@@ -320,7 +321,7 @@ static int tvmixer_clients(struct i2c_client *client) ...@@ -320,7 +321,7 @@ static int tvmixer_clients(struct i2c_client *client)
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
int tvmixer_init_module(void) static int tvmixer_init_module(void)
{ {
int i; int i;
...@@ -330,7 +331,7 @@ int tvmixer_init_module(void) ...@@ -330,7 +331,7 @@ int tvmixer_init_module(void)
return 0; return 0;
} }
void tvmixer_cleanup_module(void) static void tvmixer_cleanup_module(void)
{ {
int i; int i;
......
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