public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Marton Balint <cus@fazekas.hu>
To: linux-media@vger.kernel.org
Cc: mchehab@infradead.org
Subject: [PATCH 2 of 3] cx88: audio thread: if stereo detection is hw supported don't do it manually
Date: Wed, 01 Apr 2009 00:01:52 +0200	[thread overview]
Message-ID: <d2cbecf047e8f45f49f2.1238536912@roadrunner.athome> (raw)
In-Reply-To: <patchbomb.1238536910@roadrunner.athome>

# HG changeset patch
# User Marton Balint <cus@fazekas.hu>
# Date 1238462516 -7200
# Node ID d2cbecf047e8f45f49f20bd19b95dfd86c134e33
# Parent  32593e0b3a9253e4f3d2cb415cb3143136f61504
cx88: audio thread: if stereo detection is hw supported don't do it manually

From: Marton Balint <cus@fazekas.hu>

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.

Priority: normal

Signed-off-by: Marton Balint <cus@fazekas.hu>

diff -r 32593e0b3a92 -r d2cbecf047e8 linux/drivers/media/video/cx88/cx88-tvaudio.c
--- a/linux/drivers/media/video/cx88/cx88-tvaudio.c	Tue Mar 31 03:08:15 2009 +0200
+++ b/linux/drivers/media/video/cx88/cx88-tvaudio.c	Tue Mar 31 03:21:56 2009 +0200
@@ -998,24 +998,39 @@
 			break;
 		try_to_freeze();
 
-		/* just monitor the audio status for now ... */
-		memset(&t, 0, sizeof(t));
-		cx88_get_stereo(core, &t);
+		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;
 
-		if (UNSET != core->audiomode_manual)
-			/* manually set, don't do anything. */
-			continue;
+			/* just monitor the audio status for now ... */
+			memset(&t, 0, sizeof(t));
+			cx88_get_stereo(core, &t);
 
-		/* 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;
+			if (UNSET != core->audiomode_manual)
+				/* manually set, don't do anything. */
+				continue;
 
-		/* automatically switch to best available mode */
-		cx88_set_stereo(core, mode, 0);
+			/* 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");

  parent reply	other threads:[~2009-03-31 22:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-31 22:01 [PATCH 0 of 3] cx88: add stereo/sap detection for A2 Marton Balint
2009-03-31 22:01 ` [PATCH 1 of 3] cx88: Add support for stereo and sap " Marton Balint
2009-04-05 22:02   ` Mauro Carvalho Chehab
2009-04-06  0:36     ` Marton Balint
2009-04-06  1:23       ` Mauro Carvalho Chehab
2009-03-31 22:01 ` Marton Balint [this message]
2009-03-31 22:01 ` [PATCH 3 of 3] cx88: avoid reprogramming every audio register on A2 stereo/mono change Marton Balint

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d2cbecf047e8f45f49f2.1238536912@roadrunner.athome \
    --to=cus@fazekas.hu \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox