Skip to content

Commit 7061561

Browse files
Hans Verkuilmchehab
authored andcommitted
V4L/DVB (3663): Fix msp3400c wait time and better audio mode fallbacks
- The wait time until the first time the audio mode was detected was 1+5=6 seconds instead of just 1 second (wrong statement order). msp3400c specific bug. - Implemented audio mode fallback for msp3400c/d just like the msp3400g does automatically. E.g. fallback to stereo if no second language exists, etc. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
1 parent dc555aa commit 7061561

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

‎drivers/media/video/msp3400-kthreads.c‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ static void msp3400c_set_audmode(struct i2c_client *client)
228228
char *modestr = (state->audmode >= 0 && state->audmode < 5) ?
229229
strmode[state->audmode] : "unknown";
230230
int src = 0; /* channel source: FM/AM, nicam or SCART */
231+
int audmode = state->audmode;
231232

232233
if (state->opmode == OPMODE_AUTOSELECT) {
233234
/* this method would break everything, let's make sure
@@ -239,11 +240,22 @@ static void msp3400c_set_audmode(struct i2c_client *client)
239240
return;
240241
}
241242

243+
/* If no second language is available, switch to the first language */
244+
if ((audmode == V4L2_TUNER_MODE_LANG2 ||
245+
audmode == V4L2_TUNER_MODE_LANG1_LANG2) &&
246+
!(state->rxsubchans & V4L2_TUNER_SUB_LANG2))
247+
audmode = V4L2_TUNER_MODE_LANG1;
248+
/* switch to stereo for stereo transmission, otherwise
249+
keep first language */
250+
if (audmode == V4L2_TUNER_MODE_LANG1 &&
251+
(state->rxsubchans & V4L2_TUNER_SUB_STEREO))
252+
audmode = V4L2_TUNER_MODE_STEREO;
253+
242254
/* switch demodulator */
243255
switch (state->mode) {
244256
case MSP_MODE_FM_TERRA:
245257
v4l_dbg(1, msp_debug, client, "FM set_audmode: %s\n", modestr);
246-
switch (state->audmode) {
258+
switch (audmode) {
247259
case V4L2_TUNER_MODE_STEREO:
248260
msp_write_dsp(client, 0x000e, 0x3001);
249261
break;
@@ -257,7 +269,7 @@ static void msp3400c_set_audmode(struct i2c_client *client)
257269
break;
258270
case MSP_MODE_FM_SAT:
259271
v4l_dbg(1, msp_debug, client, "SAT set_audmode: %s\n", modestr);
260-
switch (state->audmode) {
272+
switch (audmode) {
261273
case V4L2_TUNER_MODE_MONO:
262274
msp3400c_set_carrier(client, MSP_CARRIER(6.5), MSP_CARRIER(6.5));
263275
break;
@@ -296,7 +308,7 @@ static void msp3400c_set_audmode(struct i2c_client *client)
296308
}
297309

298310
/* switch audio */
299-
switch (state->audmode) {
311+
switch (audmode) {
300312
case V4L2_TUNER_MODE_STEREO:
301313
case V4L2_TUNER_MODE_LANG1_LANG2:
302314
src |= 0x0020;
@@ -314,10 +326,6 @@ static void msp3400c_set_audmode(struct i2c_client *client)
314326
src = 0x0030;
315327
break;
316328
case V4L2_TUNER_MODE_LANG1:
317-
/* switch to stereo for stereo transmission, otherwise
318-
keep first language */
319-
if (state->rxsubchans & V4L2_TUNER_SUB_STEREO)
320-
src |= 0x0020;
321329
break;
322330
case V4L2_TUNER_MODE_LANG2:
323331
src |= 0x0010;
@@ -612,9 +620,9 @@ int msp3400c_thread(void *data)
612620
if (msp_sleep(state, 1000))
613621
goto restart;
614622
while (state->watch_stereo) {
623+
watch_stereo(client);
615624
if (msp_sleep(state, 5000))
616625
goto restart;
617-
watch_stereo(client);
618626
}
619627
}
620628
v4l_dbg(1, msp_debug, client, "thread: exit\n");

0 commit comments

Comments
 (0)