Skip to content

Commit

Permalink
V4L/DVB (3402): Fix handling of VIDIOC_G_TUNER audmode in msp3400
Browse files Browse the repository at this point in the history
- Fix handling of VIDIOC_G_TUNER audmode in msp3400: audmode
is only changed by the user with S_TUNER, never by the driver.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Jan 23, 2006
1 parent b639f9d commit 53a7240
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 30 deletions.
21 changes: 5 additions & 16 deletions drivers/media/video/msp3400-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,6 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
}
if (scart) {
state->rxsubchans = V4L2_TUNER_SUB_STEREO;
state->audmode = V4L2_TUNER_MODE_STEREO;
msp_set_scart(client, scart, 0);
msp_write_dsp(client, 0x000d, 0x1900);
if (state->opmode != OPMODE_AUTOSELECT)
Expand Down Expand Up @@ -831,11 +830,8 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
return -EINVAL;
}

msp_any_detect_stereo(client);
if (state->audmode == V4L2_TUNER_MODE_STEREO) {
a->capability = V4L2_AUDCAP_STEREO;
}

a->capability = V4L2_AUDCAP_STEREO;
a->mode = 0; /* TODO: add support for AVL */
break;
}

Expand Down Expand Up @@ -865,15 +861,9 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
}
if (scart) {
state->rxsubchans = V4L2_TUNER_SUB_STEREO;
state->audmode = V4L2_TUNER_MODE_STEREO;
msp_set_scart(client, scart, 0);
msp_write_dsp(client, 0x000d, 0x1900);
}
if (sarg->capability == V4L2_AUDCAP_STEREO) {
state->audmode = V4L2_TUNER_MODE_STEREO;
} else {
state->audmode &= ~V4L2_TUNER_MODE_STEREO;
}
msp_any_set_audmode(client, state->audmode);
msp_wake_thread(client);
break;
Expand All @@ -898,11 +888,10 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
{
struct v4l2_tuner *vt = (struct v4l2_tuner *)arg;

if (state->radio)
if (state->radio) /* TODO: add mono/stereo support for radio */
break;
/* only set audmode */
if (vt->audmode != -1 && vt->audmode != 0)
msp_any_set_audmode(client, vt->audmode);
msp_any_set_audmode(client, vt->audmode);
break;
}

Expand All @@ -927,7 +916,6 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
return -EINVAL;
}
break;

}

case VIDIOC_S_AUDOUT:
Expand Down Expand Up @@ -1094,6 +1082,7 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind)

memset(state, 0, sizeof(*state));
state->v4l2_std = V4L2_STD_NTSC;
state->audmode = V4L2_TUNER_MODE_STEREO;
state->volume = 58880; /* 0db gain */
state->balance = 32768; /* 0db gain */
state->bass = 32768;
Expand Down
25 changes: 11 additions & 14 deletions drivers/media/video/msp3400-kthreads.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ void msp3400c_setmode(struct i2c_client *client, int type)

v4l_dbg(1, msp_debug, client, "setmode: %d\n", type);
state->mode = type;
state->audmode = V4L2_TUNER_MODE_MONO;
state->rxsubchans = V4L2_TUNER_SUB_MONO;

msp_write_dem(client, 0x00bb, msp3400c_init_data[type].ad_cv);
Expand Down Expand Up @@ -210,7 +209,7 @@ void msp3400c_setmode(struct i2c_client *client, int type)
}

/* turn on/off nicam + stereo */
void msp3400c_setstereo(struct i2c_client *client, int mode)
void msp3400c_setstereo(struct i2c_client *client, int audmode)
{
static char *strmode[] = { "mono", "stereo", "lang2", "lang1" };
struct msp_state *state = i2c_get_clientdata(client);
Expand All @@ -222,16 +221,16 @@ void msp3400c_setstereo(struct i2c_client *client, int mode)
* it's never called
*/
v4l_dbg(1, msp_debug, client, "setstereo called with mode=%d instead of set_source (ignored)\n",
mode);
audmode);
return;
}

/* switch demodulator */
switch (state->mode) {
case MSP_MODE_FM_TERRA:
v4l_dbg(1, msp_debug, client, "FM setstereo: %s\n", strmode[mode]);
v4l_dbg(1, msp_debug, client, "FM setstereo: %s\n", strmode[audmode]);
msp3400c_setcarrier(client, state->second, state->main);
switch (mode) {
switch (audmode) {
case V4L2_TUNER_MODE_STEREO:
msp_write_dsp(client, 0x000e, 0x3001);
break;
Expand All @@ -243,8 +242,8 @@ void msp3400c_setstereo(struct i2c_client *client, int mode)
}
break;
case MSP_MODE_FM_SAT:
v4l_dbg(1, msp_debug, client, "SAT setstereo: %s\n", strmode[mode]);
switch (mode) {
v4l_dbg(1, msp_debug, client, "SAT setstereo: %s\n", strmode[audmode]);
switch (audmode) {
case V4L2_TUNER_MODE_MONO:
msp3400c_setcarrier(client, MSP_CARRIER(6.5), MSP_CARRIER(6.5));
break;
Expand All @@ -262,29 +261,29 @@ void msp3400c_setstereo(struct i2c_client *client, int mode)
case MSP_MODE_FM_NICAM1:
case MSP_MODE_FM_NICAM2:
case MSP_MODE_AM_NICAM:
v4l_dbg(1, msp_debug, client, "NICAM setstereo: %s\n",strmode[mode]);
v4l_dbg(1, msp_debug, client, "NICAM setstereo: %s\n",strmode[audmode]);
msp3400c_setcarrier(client,state->second,state->main);
if (state->nicam_on)
nicam=0x0100;
break;
case MSP_MODE_BTSC:
v4l_dbg(1, msp_debug, client, "BTSC setstereo: %s\n",strmode[mode]);
v4l_dbg(1, msp_debug, client, "BTSC setstereo: %s\n",strmode[audmode]);
nicam=0x0300;
break;
case MSP_MODE_EXTERN:
v4l_dbg(1, msp_debug, client, "extern setstereo: %s\n",strmode[mode]);
v4l_dbg(1, msp_debug, client, "extern setstereo: %s\n",strmode[audmode]);
nicam = 0x0200;
break;
case MSP_MODE_FM_RADIO:
v4l_dbg(1, msp_debug, client, "FM-Radio setstereo: %s\n",strmode[mode]);
v4l_dbg(1, msp_debug, client, "FM-Radio setstereo: %s\n",strmode[audmode]);
break;
default:
v4l_dbg(1, msp_debug, client, "mono setstereo\n");
return;
}

/* switch audio */
switch (mode) {
switch (audmode) {
case V4L2_TUNER_MODE_STEREO:
src = 0x0020 | nicam;
break;
Expand Down Expand Up @@ -759,7 +758,6 @@ int msp3410d_thread(void *data)
case 0x0040: /* FM radio */
state->mode = MSP_MODE_FM_RADIO;
state->rxsubchans = V4L2_TUNER_SUB_STEREO;
state->audmode = V4L2_TUNER_MODE_STEREO;
state->nicam_on = 0;
state->watch_stereo = 0;
/* not needed in theory if we have radio, but
Expand All @@ -779,7 +777,6 @@ int msp3410d_thread(void *data)
case 0x0005:
state->mode = MSP_MODE_FM_TERRA;
state->rxsubchans = V4L2_TUNER_SUB_MONO;
state->audmode = V4L2_TUNER_MODE_MONO;
state->nicam_on = 0;
state->watch_stereo = 1;
break;
Expand Down

0 comments on commit 53a7240

Please sign in to comment.