Commit 2eb606db authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

V4L/DVB (3709): Improve line-in handling

- improve handling of the EXTERN input: don't start an unnecessary carrier scan
- improve the LOG_STATUS output
- ensure that a carrier scan is started again when switching back to the tuner.
- set correct prescale for L-NICAM
Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 0ead0918
...@@ -674,22 +674,31 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -674,22 +674,31 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
int sc1_out = rt->output & 0xf; int sc1_out = rt->output & 0xf;
int sc2_out = (rt->output >> 4) & 0xf; int sc2_out = (rt->output >> 4) & 0xf;
u16 val, reg; u16 val, reg;
int i;
int extern_input = 1;
if (state->routing.input == rt->input && if (state->routing.input == rt->input &&
state->routing.output == rt->output) state->routing.output == rt->output)
break; break;
state->routing = *rt; state->routing = *rt;
/* check if the tuner input is used */
for (i = 0; i < 5; i++) {
if (((rt->input >> (4 + i * 4)) & 0xf) == 0)
extern_input = 0;
}
if (extern_input)
state->mode = MSP_MODE_EXTERN;
else
state->mode = MSP_MODE_AM_DETECT;
msp_set_scart(client, sc_in, 0); msp_set_scart(client, sc_in, 0);
msp_set_scart(client, sc1_out, 1); msp_set_scart(client, sc1_out, 1);
msp_set_scart(client, sc2_out, 2); msp_set_scart(client, sc2_out, 2);
msp_set_audmode(client); msp_set_audmode(client);
reg = (state->opmode == OPMODE_AUTOSELECT) ? 0x30 : 0xbb; reg = (state->opmode == OPMODE_AUTOSELECT) ? 0x30 : 0xbb;
val = msp_read_dem(client, reg); val = msp_read_dem(client, reg);
if (tuner != ((val >> 8) & 1)) { msp_write_dem(client, reg, (val & ~0x100) | (tuner << 8));
msp_write_dem(client, reg, (val & ~0x100) | (tuner << 8)); /* wake thread when a new input is chosen */
/* wake thread when a new tuner input is chosen */ msp_wake_thread(client);
msp_wake_thread(client);
}
break; break;
} }
...@@ -794,7 +803,9 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -794,7 +803,9 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
case MSP_MODE_EXTERN: p = "External input"; break; case MSP_MODE_EXTERN: p = "External input"; break;
default: p = "unknown"; break; default: p = "unknown"; break;
} }
if (state->opmode == OPMODE_MANUAL) { if (state->mode == MSP_MODE_EXTERN) {
v4l_info(client, "Mode: %s\n", p);
} else if (state->opmode == OPMODE_MANUAL) {
v4l_info(client, "Mode: %s (%s%s)\n", p, v4l_info(client, "Mode: %s (%s%s)\n", p,
(state->rxsubchans & V4L2_TUNER_SUB_STEREO) ? "stereo" : "mono", (state->rxsubchans & V4L2_TUNER_SUB_STEREO) ? "stereo" : "mono",
(state->rxsubchans & V4L2_TUNER_SUB_LANG2) ? ", dual" : ""); (state->rxsubchans & V4L2_TUNER_SUB_LANG2) ? ", dual" : "");
......
...@@ -244,19 +244,21 @@ static void msp3400c_set_audmode(struct i2c_client *client) ...@@ -244,19 +244,21 @@ static void msp3400c_set_audmode(struct i2c_client *client)
the hardware does not support SAP. So the rxsubchans combination the hardware does not support SAP. So the rxsubchans combination
of STEREO | LANG2 does not occur. */ of STEREO | LANG2 does not occur. */
/* switch to mono if only mono is available */ if (state->mode != MSP_MODE_EXTERN) {
if (state->rxsubchans == V4L2_TUNER_SUB_MONO) /* switch to mono if only mono is available */
audmode = V4L2_TUNER_MODE_MONO; if (state->rxsubchans == V4L2_TUNER_SUB_MONO)
/* if bilingual */ audmode = V4L2_TUNER_MODE_MONO;
else if (state->rxsubchans & V4L2_TUNER_SUB_LANG2) { /* if bilingual */
/* and mono or stereo, then fallback to lang1 */ else if (state->rxsubchans & V4L2_TUNER_SUB_LANG2) {
if (audmode == V4L2_TUNER_MODE_MONO || /* and mono or stereo, then fallback to lang1 */
audmode == V4L2_TUNER_MODE_STEREO) if (audmode == V4L2_TUNER_MODE_MONO ||
audmode = V4L2_TUNER_MODE_LANG1; audmode == V4L2_TUNER_MODE_STEREO)
audmode = V4L2_TUNER_MODE_LANG1;
}
/* if stereo, and audmode is not mono, then switch to stereo */
else if (audmode != V4L2_TUNER_MODE_MONO)
audmode = V4L2_TUNER_MODE_STEREO;
} }
/* if stereo, and audmode is not mono, then switch to stereo */
else if (audmode != V4L2_TUNER_MODE_MONO)
audmode = V4L2_TUNER_MODE_STEREO;
/* switch demodulator */ /* switch demodulator */
switch (state->mode) { switch (state->mode) {
...@@ -481,6 +483,7 @@ int msp3400c_thread(void *data) ...@@ -481,6 +483,7 @@ int msp3400c_thread(void *data)
/* no carrier scan, just unmute */ /* no carrier scan, just unmute */
v4l_dbg(1, msp_debug, client, "thread: no carrier scan\n"); v4l_dbg(1, msp_debug, client, "thread: no carrier scan\n");
state->scan_in_progress = 0; state->scan_in_progress = 0;
state->rxsubchans = V4L2_TUNER_SUB_STEREO;
msp_set_audio(client); msp_set_audio(client);
continue; continue;
} }
...@@ -947,6 +950,14 @@ int msp34xxg_thread(void *data) ...@@ -947,6 +950,14 @@ int msp34xxg_thread(void *data)
if (kthread_should_stop()) if (kthread_should_stop())
break; break;
if (state->mode == MSP_MODE_EXTERN) {
/* no carrier scan needed, just unmute */
v4l_dbg(1, msp_debug, client, "thread: no carrier scan\n");
state->scan_in_progress = 0;
msp_set_audio(client);
continue;
}
/* setup the chip*/ /* setup the chip*/
msp34xxg_reset(client); msp34xxg_reset(client);
state->std = state->radio ? 0x40 : msp_standard; state->std = state->radio ? 0x40 : msp_standard;
...@@ -978,6 +989,11 @@ int msp34xxg_thread(void *data) ...@@ -978,6 +989,11 @@ int msp34xxg_thread(void *data)
v4l_dbg(1, msp_debug, client, "detected standard: %s (0x%04x)\n", v4l_dbg(1, msp_debug, client, "detected standard: %s (0x%04x)\n",
msp_standard_std_name(state->std), state->std); msp_standard_std_name(state->std), state->std);
if (state->std == 9) {
/* AM NICAM mode */
msp_write_dsp(client, 0x0e, 0x7c00);
}
/* unmute: dispatch sound to scart output, set scart volume */ /* unmute: dispatch sound to scart output, set scart volume */
msp_set_audio(client); msp_set_audio(client);
......
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