From 083d6f8c81e9a2bd5f71633fb38acda35fb8240c Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Tue, 31 Mar 2009 19:01:52 -0300 Subject: V4L/DVB (11395): cx88: audio thread: if stereo detection is hw supported don't do it manually The sole purpose of the audio thread is to detect if stereo transmission is available, and if it is, then switch to stereo mode (and switch back, if it's no longer available). This manual autodetection is useful for some audio standards (e.g. A2) where cx88_get_stereo CAN detect stereo sound, but the cx2388x chip CANNOT auto-detect stereo sound. However, for other audio standards, the cx2388x chip CAN auto-detect the stereo sound, so the manual autodetection in the audio thread is not needed. In fact, it can cause serious problems because for some of these audio standards, cx88_get_stereo CANNOT detect the presence of stereo sound. Besides that, if the hardware automatically detects stereo/mono sound, you cannot set core->audiomode_current to the real current audio mode on channel change. With this patch, the manual autodetection is only used if audiomode_current is known after a channel change (because of the initial mono mode), and hardware-based stereo autodetecion is not applicable for the current audio standard. Signed-off-by: Marton Balint Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/cx88/cx88-tvaudio.c | 51 +++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 18 deletions(-) (limited to 'drivers/media/video/cx88') diff --git a/drivers/media/video/cx88/cx88-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c index f9501eb..0a8699f 100644 --- a/drivers/media/video/cx88/cx88-tvaudio.c +++ b/drivers/media/video/cx88/cx88-tvaudio.c @@ -976,24 +976,39 @@ int cx88_audio_thread(void *data) break; try_to_freeze(); - /* just monitor the audio status for now ... */ - memset(&t, 0, sizeof(t)); - cx88_get_stereo(core, &t); - - if (UNSET != core->audiomode_manual) - /* manually set, don't do anything. */ - continue; - - /* monitor signal */ - if (t.rxsubchans & V4L2_TUNER_SUB_STEREO) - mode = V4L2_TUNER_MODE_STEREO; - else - mode = V4L2_TUNER_MODE_MONO; - if (mode == core->audiomode_current) - continue; - - /* automatically switch to best available mode */ - cx88_set_stereo(core, mode, 0); + switch (core->tvaudio) { + case WW_BG: + case WW_DK: + case WW_M: + case WW_I: + case WW_L: + if (core->use_nicam) + goto hw_autodetect; + + /* just monitor the audio status for now ... */ + memset(&t, 0, sizeof(t)); + cx88_get_stereo(core, &t); + + if (UNSET != core->audiomode_manual) + /* manually set, don't do anything. */ + continue; + + /* monitor signal and set stereo if available */ + if (t.rxsubchans & V4L2_TUNER_SUB_STEREO) + mode = V4L2_TUNER_MODE_STEREO; + else + mode = V4L2_TUNER_MODE_MONO; + if (mode == core->audiomode_current) + continue; + /* automatically switch to best available mode */ + cx88_set_stereo(core, mode, 0); + break; + default: +hw_autodetect: + /* stereo autodetection is supported by hardware so + we don't need to do it manually. Do nothing. */ + break; + } } dprintk("cx88: tvaudio thread exiting\n"); -- cgit v1.1