All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 00/10] bttv: refactor audio_mux() and fix muting/unmuting
@ 2013-03-20 19:24 Frank Schäfer
  2013-03-20 19:24 ` [RFC PATCH 01/10] bttv: audio_mux(): use a local variable "gpio_mute" instead of modifying the function parameter "mute" Frank Schäfer
                   ` (9 more replies)
  0 siblings, 10 replies; 21+ messages in thread
From: Frank Schäfer @ 2013-03-20 19:24 UTC (permalink / raw)
  To: mchehab; +Cc: hverkuil, linux-media, Frank Schäfer

This patch series refactors function audio_mux() and fixes several issues 
related to muting/unmuting on probing, first open and last close.

Two thirds of the changes have already been sent as part of the RFC patch series
"bttv: fix muting/unmuting on probing, first open and last close" v1 and v2, 
the new patches 3-6 untagle the mute and input setting code as much as possible
as suggested by hans Verkuil.

Tested with a Hauppauge WinTV Theatre (model 37284, Rev B421).

Frank Schäfer (10):
  bttv: audio_mux(): use a local variable "gpio_mute" instead of
    modifying the function parameter "mute"
  bttv: audio_mux(): do not change the value of the v4l2 mute control
  bttv: do not save the audio input in audio_mux()
  bttv: rename field 'audio' in struct 'bttv' to 'audio_input'
  bttv: separate GPIO part from function audio_mux()
  bttv: untangle audio input and mute setting
  bttv: do not unmute the device before the first open
  bttv: apply mute settings on open
  bttv: fix mute on last close of the video device node
  bttv: avoid mute on last close when the radio device node is still
    open

 drivers/media/pci/bt8xx/bttv-cards.c  |    2 +-
 drivers/media/pci/bt8xx/bttv-driver.c |  101 ++++++++++++++++++---------------
 drivers/media/pci/bt8xx/bttvp.h       |    2 +-
 3 Dateien geändert, 57 Zeilen hinzugefügt(+), 48 Zeilen entfernt(-)

-- 
1.7.10.4


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [RFC PATCH 01/10] bttv: audio_mux(): use a local variable "gpio_mute" instead of modifying the function parameter "mute"
  2013-03-20 19:24 [RFC PATCH 00/10] bttv: refactor audio_mux() and fix muting/unmuting Frank Schäfer
@ 2013-03-20 19:24 ` Frank Schäfer
  2013-03-21 10:24   ` Hans Verkuil
  2013-03-20 19:24 ` [RFC PATCH 02/10] bttv: audio_mux(): do not change the value of the v4l2 mute control Frank Schäfer
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Frank Schäfer @ 2013-03-20 19:24 UTC (permalink / raw)
  To: mchehab; +Cc: hverkuil, linux-media, Frank Schäfer

Function audio_mux() actually deals with two types of mute: gpio mute and
subdevice muting.
This patch claryfies the meaning of these values, but mainly prepares the code for
the next patch.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
---
 drivers/media/pci/bt8xx/bttv-driver.c |    8 ++++----
 1 Datei geändert, 4 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index 8610b6a..a584d82 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -992,7 +992,7 @@ static char *audio_modes[] = {
 static int
 audio_mux(struct bttv *btv, int input, int mute)
 {
-	int gpio_val, signal;
+	int gpio_val, signal, mute_gpio;
 	struct v4l2_ctrl *ctrl;
 
 	gpio_inout(bttv_tvcards[btv->c.type].gpiomask,
@@ -1003,10 +1003,10 @@ audio_mux(struct bttv *btv, int input, int mute)
 	btv->audio = input;
 
 	/* automute */
-	mute = mute || (btv->opt_automute && (!signal || !btv->users)
+	mute_gpio = mute || (btv->opt_automute && (!signal || !btv->users)
 				&& !btv->has_radio_tuner);
 
-	if (mute)
+	if (mute_gpio)
 		gpio_val = bttv_tvcards[btv->c.type].gpiomute;
 	else
 		gpio_val = bttv_tvcards[btv->c.type].gpiomux[input];
@@ -1022,7 +1022,7 @@ audio_mux(struct bttv *btv, int input, int mute)
 	}
 
 	if (bttv_gpio)
-		bttv_gpio_tracking(btv, audio_modes[mute ? 4 : input]);
+		bttv_gpio_tracking(btv, audio_modes[mute_gpio ? 4 : input]);
 	if (in_interrupt())
 		return 0;
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [RFC PATCH 02/10] bttv: audio_mux(): do not change the value of the v4l2 mute control
  2013-03-20 19:24 [RFC PATCH 00/10] bttv: refactor audio_mux() and fix muting/unmuting Frank Schäfer
  2013-03-20 19:24 ` [RFC PATCH 01/10] bttv: audio_mux(): use a local variable "gpio_mute" instead of modifying the function parameter "mute" Frank Schäfer
@ 2013-03-20 19:24 ` Frank Schäfer
  2013-03-21 10:26   ` Hans Verkuil
  2013-03-20 19:24 ` [RFC PATCH 03/10] bttv: do not save the audio input in audio_mux() Frank Schäfer
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Frank Schäfer @ 2013-03-20 19:24 UTC (permalink / raw)
  To: mchehab; +Cc: hverkuil, linux-media, Frank Schäfer

There are cases where we want to call audio_mux() without changing the value of
the v4l2 mute control, for example
- mute mute on last close
- mute on device probing

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
---
 drivers/media/pci/bt8xx/bttv-driver.c |    8 ++++----
 1 Datei geändert, 4 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index a584d82..a082ab4 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -999,7 +999,6 @@ audio_mux(struct bttv *btv, int input, int mute)
 		   bttv_tvcards[btv->c.type].gpiomask);
 	signal = btread(BT848_DSTATUS) & BT848_DSTATUS_HLOC;
 
-	btv->mute = mute;
 	btv->audio = input;
 
 	/* automute */
@@ -1031,7 +1030,7 @@ audio_mux(struct bttv *btv, int input, int mute)
 
 		ctrl = v4l2_ctrl_find(btv->sd_msp34xx->ctrl_handler, V4L2_CID_AUDIO_MUTE);
 		if (ctrl)
-			v4l2_ctrl_s_ctrl(ctrl, btv->mute);
+			v4l2_ctrl_s_ctrl(ctrl, mute);
 
 		/* Note: the inputs tuner/radio/extern/intern are translated
 		   to msp routings. This assumes common behavior for all msp3400
@@ -1080,7 +1079,7 @@ audio_mux(struct bttv *btv, int input, int mute)
 		ctrl = v4l2_ctrl_find(btv->sd_tvaudio->ctrl_handler, V4L2_CID_AUDIO_MUTE);
 
 		if (ctrl)
-			v4l2_ctrl_s_ctrl(ctrl, btv->mute);
+			v4l2_ctrl_s_ctrl(ctrl, mute);
 		v4l2_subdev_call(btv->sd_tvaudio, audio, s_routing,
 				input, 0, 0);
 	}
@@ -1088,7 +1087,7 @@ audio_mux(struct bttv *btv, int input, int mute)
 		ctrl = v4l2_ctrl_find(btv->sd_tda7432->ctrl_handler, V4L2_CID_AUDIO_MUTE);
 
 		if (ctrl)
-			v4l2_ctrl_s_ctrl(ctrl, btv->mute);
+			v4l2_ctrl_s_ctrl(ctrl, mute);
 	}
 	return 0;
 }
@@ -1300,6 +1299,7 @@ static int bttv_s_ctrl(struct v4l2_ctrl *c)
 		break;
 	case V4L2_CID_AUDIO_MUTE:
 		audio_mute(btv, c->val);
+		btv->mute = c->val;
 		break;
 	case V4L2_CID_AUDIO_VOLUME:
 		btv->volume_gpio(btv, c->val);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [RFC PATCH 03/10] bttv: do not save the audio input in audio_mux()
  2013-03-20 19:24 [RFC PATCH 00/10] bttv: refactor audio_mux() and fix muting/unmuting Frank Schäfer
  2013-03-20 19:24 ` [RFC PATCH 01/10] bttv: audio_mux(): use a local variable "gpio_mute" instead of modifying the function parameter "mute" Frank Schäfer
  2013-03-20 19:24 ` [RFC PATCH 02/10] bttv: audio_mux(): do not change the value of the v4l2 mute control Frank Schäfer
@ 2013-03-20 19:24 ` Frank Schäfer
  2013-03-21 10:28   ` Hans Verkuil
  2013-03-20 19:24 ` [RFC PATCH 04/10] bttv: rename field 'audio' in struct 'bttv' to 'audio_input' Frank Schäfer
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Frank Schäfer @ 2013-03-20 19:24 UTC (permalink / raw)
  To: mchehab; +Cc: hverkuil, linux-media, Frank Schäfer

We can't and do not save the mute setting in function audio_mux(), so we
should also not save the input in this function for consistency.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
---
 drivers/media/pci/bt8xx/bttv-driver.c |   10 +++++-----
 1 Datei geändert, 5 Zeilen hinzugefügt(+), 5 Zeilen entfernt(-)

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index a082ab4..e01a8d8 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -999,8 +999,6 @@ audio_mux(struct bttv *btv, int input, int mute)
 		   bttv_tvcards[btv->c.type].gpiomask);
 	signal = btread(BT848_DSTATUS) & BT848_DSTATUS_HLOC;
 
-	btv->audio = input;
-
 	/* automute */
 	mute_gpio = mute || (btv->opt_automute && (!signal || !btv->users)
 				&& !btv->has_radio_tuner);
@@ -1197,8 +1195,9 @@ set_input(struct bttv *btv, unsigned int input, unsigned int norm)
 	} else {
 		video_mux(btv,input);
 	}
-	audio_input(btv, (btv->tuner_type != TUNER_ABSENT && input == 0) ?
-			 TVAUDIO_INPUT_TUNER : TVAUDIO_INPUT_EXTERN);
+	btv->audio = (btv->tuner_type != TUNER_ABSENT && input == 0) ?
+			 TVAUDIO_INPUT_TUNER : TVAUDIO_INPUT_EXTERN;
+	audio_input(btv, btv->audio);
 	set_tvnorm(btv, norm);
 }
 
@@ -1707,7 +1706,8 @@ static void radio_enable(struct bttv *btv)
 	if (!btv->has_radio_tuner) {
 		btv->has_radio_tuner = 1;
 		bttv_call_all(btv, tuner, s_radio);
-		audio_input(btv, TVAUDIO_INPUT_RADIO);
+		btv->audio = TVAUDIO_INPUT_RADIO;
+		audio_input(btv, btv->audio);
 	}
 }
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [RFC PATCH 04/10] bttv: rename field 'audio' in struct 'bttv' to 'audio_input'
  2013-03-20 19:24 [RFC PATCH 00/10] bttv: refactor audio_mux() and fix muting/unmuting Frank Schäfer
                   ` (2 preceding siblings ...)
  2013-03-20 19:24 ` [RFC PATCH 03/10] bttv: do not save the audio input in audio_mux() Frank Schäfer
@ 2013-03-20 19:24 ` Frank Schäfer
  2013-03-21 10:28   ` Hans Verkuil
  2013-03-20 19:24 ` [RFC PATCH 05/10] bttv: separate GPIO part from function audio_mux() Frank Schäfer
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Frank Schäfer @ 2013-03-20 19:24 UTC (permalink / raw)
  To: mchehab; +Cc: hverkuil, linux-media, Frank Schäfer

'audio_input' better describes the meaning of this field.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
---
 drivers/media/pci/bt8xx/bttv-cards.c  |    2 +-
 drivers/media/pci/bt8xx/bttv-driver.c |   12 ++++++------
 drivers/media/pci/bt8xx/bttvp.h       |    2 +-
 3 Dateien geändert, 8 Zeilen hinzugefügt(+), 8 Zeilen entfernt(-)

diff --git a/drivers/media/pci/bt8xx/bttv-cards.c b/drivers/media/pci/bt8xx/bttv-cards.c
index fa0faaa..b7dc921 100644
--- a/drivers/media/pci/bt8xx/bttv-cards.c
+++ b/drivers/media/pci/bt8xx/bttv-cards.c
@@ -3947,7 +3947,7 @@ static void avermedia_eeprom(struct bttv *btv)
 u32 bttv_tda9880_setnorm(struct bttv *btv, u32 gpiobits)
 {
 
-	if (btv->audio == TVAUDIO_INPUT_TUNER) {
+	if (btv->audio_input == TVAUDIO_INPUT_TUNER) {
 		if (bttv_tvnorms[btv->tvnorm].v4l2_id & V4L2_STD_MN)
 			gpiobits |= 0x10000;
 		else
diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index e01a8d8..81ee70d 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -1093,7 +1093,7 @@ audio_mux(struct bttv *btv, int input, int mute)
 static inline int
 audio_mute(struct bttv *btv, int mute)
 {
-	return audio_mux(btv, btv->audio, mute);
+	return audio_mux(btv, btv->audio_input, mute);
 }
 
 static inline int
@@ -1195,9 +1195,9 @@ set_input(struct bttv *btv, unsigned int input, unsigned int norm)
 	} else {
 		video_mux(btv,input);
 	}
-	btv->audio = (btv->tuner_type != TUNER_ABSENT && input == 0) ?
-			 TVAUDIO_INPUT_TUNER : TVAUDIO_INPUT_EXTERN;
-	audio_input(btv, btv->audio);
+	btv->audio_input = (btv->tuner_type != TUNER_ABSENT && input == 0) ?
+				TVAUDIO_INPUT_TUNER : TVAUDIO_INPUT_EXTERN;
+	audio_input(btv, btv->audio_input);
 	set_tvnorm(btv, norm);
 }
 
@@ -1706,8 +1706,8 @@ static void radio_enable(struct bttv *btv)
 	if (!btv->has_radio_tuner) {
 		btv->has_radio_tuner = 1;
 		bttv_call_all(btv, tuner, s_radio);
-		btv->audio = TVAUDIO_INPUT_RADIO;
-		audio_input(btv, btv->audio);
+		btv->audio_input = TVAUDIO_INPUT_RADIO;
+		audio_input(btv, btv->audio_input);
 	}
 }
 
diff --git a/drivers/media/pci/bt8xx/bttvp.h b/drivers/media/pci/bt8xx/bttvp.h
index e7910e0..9c1cc2c 100644
--- a/drivers/media/pci/bt8xx/bttvp.h
+++ b/drivers/media/pci/bt8xx/bttvp.h
@@ -423,7 +423,7 @@ struct bttv {
 
 	/* video state */
 	unsigned int input;
-	unsigned int audio;
+	unsigned int audio_input;
 	unsigned int mute;
 	unsigned long tv_freq;
 	unsigned int tvnorm;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [RFC PATCH 05/10] bttv: separate GPIO part from function audio_mux()
  2013-03-20 19:24 [RFC PATCH 00/10] bttv: refactor audio_mux() and fix muting/unmuting Frank Schäfer
                   ` (3 preceding siblings ...)
  2013-03-20 19:24 ` [RFC PATCH 04/10] bttv: rename field 'audio' in struct 'bttv' to 'audio_input' Frank Schäfer
@ 2013-03-20 19:24 ` Frank Schäfer
  2013-03-21 10:32   ` Hans Verkuil
  2013-03-20 19:24 ` [RFC PATCH 06/10] bttv: untangle audio input and mute setting Frank Schäfer
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Frank Schäfer @ 2013-03-20 19:24 UTC (permalink / raw)
  To: mchehab; +Cc: hverkuil, linux-media, Frank Schäfer

Move the GPIO part of function audio_mux() to a separate function
audio_mux_gpio().
This prepares the code for the next patch which will separate mute and input
setting.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
---
 drivers/media/pci/bt8xx/bttv-driver.c |   18 ++++++++++++------
 1 Datei geändert, 12 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-)

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index 81ee70d..f1cb0db 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -989,11 +989,10 @@ static char *audio_modes[] = {
 	"audio: intern", "audio: mute"
 };
 
-static int
-audio_mux(struct bttv *btv, int input, int mute)
+static void
+audio_mux_gpio(struct bttv *btv, int input, int mute)
 {
 	int gpio_val, signal, mute_gpio;
-	struct v4l2_ctrl *ctrl;
 
 	gpio_inout(bttv_tvcards[btv->c.type].gpiomask,
 		   bttv_tvcards[btv->c.type].gpiomask);
@@ -1020,8 +1019,14 @@ audio_mux(struct bttv *btv, int input, int mute)
 
 	if (bttv_gpio)
 		bttv_gpio_tracking(btv, audio_modes[mute_gpio ? 4 : input]);
-	if (in_interrupt())
-		return 0;
+}
+
+static int
+audio_mux(struct bttv *btv, int input, int mute)
+{
+	struct v4l2_ctrl *ctrl;
+
+	audio_mux_gpio(btv, input, mute);
 
 	if (btv->sd_msp34xx) {
 		u32 in;
@@ -3846,7 +3851,8 @@ static irqreturn_t bttv_irq(int irq, void *dev_id)
 			bttv_irq_switch_video(btv);
 
 		if ((astat & BT848_INT_HLOCK)  &&  btv->opt_automute)
-			audio_mute(btv, btv->mute);  /* trigger automute */
+			/* trigger automute */
+			audio_mux_gpio(btv, btv->audio_input, btv->mute);
 
 		if (astat & (BT848_INT_SCERR|BT848_INT_OCERR)) {
 			pr_info("%d: %s%s @ %08x,",
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [RFC PATCH 06/10] bttv: untangle audio input and mute setting
  2013-03-20 19:24 [RFC PATCH 00/10] bttv: refactor audio_mux() and fix muting/unmuting Frank Schäfer
                   ` (4 preceding siblings ...)
  2013-03-20 19:24 ` [RFC PATCH 05/10] bttv: separate GPIO part from function audio_mux() Frank Schäfer
@ 2013-03-20 19:24 ` Frank Schäfer
  2013-03-21 10:37   ` Hans Verkuil
  2013-03-20 19:24 ` [RFC PATCH 07/10] bttv: do not unmute the device before the first open Frank Schäfer
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Frank Schäfer @ 2013-03-20 19:24 UTC (permalink / raw)
  To: mchehab; +Cc: hverkuil, linux-media, Frank Schäfer

Split function audio_mux():
move the mute setting part to function audio_mute() and the input setting part
to function audio_input().

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
---
 drivers/media/pci/bt8xx/bttv-driver.c |   51 ++++++++++++++++-----------------
 1 Datei geändert, 24 Zeilen hinzugefügt(+), 27 Zeilen entfernt(-)

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index f1cb0db..0df4a16 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -1022,18 +1022,37 @@ audio_mux_gpio(struct bttv *btv, int input, int mute)
 }
 
 static int
-audio_mux(struct bttv *btv, int input, int mute)
+audio_mute(struct bttv *btv, int mute)
 {
 	struct v4l2_ctrl *ctrl;
 
-	audio_mux_gpio(btv, input, mute);
+	audio_mux_gpio(btv, btv->audio_input, mute);
 
 	if (btv->sd_msp34xx) {
-		u32 in;
-
 		ctrl = v4l2_ctrl_find(btv->sd_msp34xx->ctrl_handler, V4L2_CID_AUDIO_MUTE);
 		if (ctrl)
 			v4l2_ctrl_s_ctrl(ctrl, mute);
+	}
+	if (btv->sd_tvaudio) {
+		ctrl = v4l2_ctrl_find(btv->sd_tvaudio->ctrl_handler, V4L2_CID_AUDIO_MUTE);
+		if (ctrl)
+			v4l2_ctrl_s_ctrl(ctrl, mute);
+	}
+	if (btv->sd_tda7432) {
+		ctrl = v4l2_ctrl_find(btv->sd_tda7432->ctrl_handler, V4L2_CID_AUDIO_MUTE);
+		if (ctrl)
+			v4l2_ctrl_s_ctrl(ctrl, mute);
+	}
+	return 0;
+}
+
+static int
+audio_input(struct bttv *btv, int input)
+{
+	audio_mux_gpio(btv, input, btv->mute);
+
+	if (btv->sd_msp34xx) {
+		u32 in;
 
 		/* Note: the inputs tuner/radio/extern/intern are translated
 		   to msp routings. This assumes common behavior for all msp3400
@@ -1079,34 +1098,12 @@ audio_mux(struct bttv *btv, int input, int mute)
 			       in, MSP_OUTPUT_DEFAULT, 0);
 	}
 	if (btv->sd_tvaudio) {
-		ctrl = v4l2_ctrl_find(btv->sd_tvaudio->ctrl_handler, V4L2_CID_AUDIO_MUTE);
-
-		if (ctrl)
-			v4l2_ctrl_s_ctrl(ctrl, mute);
 		v4l2_subdev_call(btv->sd_tvaudio, audio, s_routing,
-				input, 0, 0);
-	}
-	if (btv->sd_tda7432) {
-		ctrl = v4l2_ctrl_find(btv->sd_tda7432->ctrl_handler, V4L2_CID_AUDIO_MUTE);
-
-		if (ctrl)
-			v4l2_ctrl_s_ctrl(ctrl, mute);
+				 input, 0, 0);
 	}
 	return 0;
 }
 
-static inline int
-audio_mute(struct bttv *btv, int mute)
-{
-	return audio_mux(btv, btv->audio_input, mute);
-}
-
-static inline int
-audio_input(struct bttv *btv, int input)
-{
-	return audio_mux(btv, input, btv->mute);
-}
-
 static void
 bttv_crop_calc_limits(struct bttv_crop *c)
 {
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [RFC PATCH 07/10] bttv: do not unmute the device before the first open
  2013-03-20 19:24 [RFC PATCH 00/10] bttv: refactor audio_mux() and fix muting/unmuting Frank Schäfer
                   ` (5 preceding siblings ...)
  2013-03-20 19:24 ` [RFC PATCH 06/10] bttv: untangle audio input and mute setting Frank Schäfer
@ 2013-03-20 19:24 ` Frank Schäfer
  2013-03-21 10:38   ` Hans Verkuil
  2013-03-20 19:24 ` [RFC PATCH 08/10] bttv: apply mute settings on open Frank Schäfer
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Frank Schäfer @ 2013-03-20 19:24 UTC (permalink / raw)
  To: mchehab; +Cc: hverkuil, linux-media, Frank Schäfer

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
---
 drivers/media/pci/bt8xx/bttv-driver.c |    4 +++-
 1 Datei geändert, 3 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index 0df4a16..55eab61 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -4212,11 +4212,13 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
 	btv->std = V4L2_STD_PAL;
 	init_irqreg(btv);
 	v4l2_ctrl_handler_setup(hdl);
-
 	if (hdl->error) {
 		result = hdl->error;
 		goto fail2;
 	}
+	/* mute device */
+	audio_mute(btv, 1);
+
 	/* register video4linux + input */
 	if (!bttv_tvcards[btv->c.type].no_video) {
 		v4l2_ctrl_add_handler(&btv->radio_ctrl_handler, hdl,
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [RFC PATCH 08/10] bttv: apply mute settings on open
  2013-03-20 19:24 [RFC PATCH 00/10] bttv: refactor audio_mux() and fix muting/unmuting Frank Schäfer
                   ` (6 preceding siblings ...)
  2013-03-20 19:24 ` [RFC PATCH 07/10] bttv: do not unmute the device before the first open Frank Schäfer
@ 2013-03-20 19:24 ` Frank Schäfer
  2013-03-21 10:39   ` Hans Verkuil
  2013-03-20 19:24 ` [RFC PATCH 09/10] bttv: fix mute on last close of the video device node Frank Schäfer
  2013-03-20 19:24 ` [RFC PATCH 10/10] bttv: avoid mute on last close when the radio device node is still open Frank Schäfer
  9 siblings, 1 reply; 21+ messages in thread
From: Frank Schäfer @ 2013-03-20 19:24 UTC (permalink / raw)
  To: mchehab; +Cc: hverkuil, linux-media, Frank Schäfer

Previously, this has been done implicitly for video device nodes by calling
set_input() (which calls audio_input() and also modified the mute
setting).
Since input and mute setting are now untangled (as much as possible), we need to
apply the mute setting with an explicit call to audio_mute().
Also apply the mute setting when the radio device node gets opened.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
---
 drivers/media/pci/bt8xx/bttv-driver.c |    3 ++-
 1 Datei geändert, 2 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index 55eab61..2fb2168 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -3065,7 +3065,7 @@ static int bttv_open(struct file *file)
 			    fh, &btv->lock);
 	set_tvnorm(btv,btv->tvnorm);
 	set_input(btv, btv->input, btv->tvnorm);
-
+	audio_mute(btv, btv->mute);
 
 	/* The V4L2 spec requires one global set of cropping parameters
 	   which only change on request. These are stored in btv->crop[1].
@@ -3230,6 +3230,7 @@ static int radio_open(struct file *file)
 	v4l2_fh_init(&fh->fh, vdev);
 
 	btv->radio_user++;
+	audio_mute(btv, btv->mute);
 
 	v4l2_fh_add(&fh->fh);
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [RFC PATCH 09/10] bttv: fix mute on last close of the video device node
  2013-03-20 19:24 [RFC PATCH 00/10] bttv: refactor audio_mux() and fix muting/unmuting Frank Schäfer
                   ` (7 preceding siblings ...)
  2013-03-20 19:24 ` [RFC PATCH 08/10] bttv: apply mute settings on open Frank Schäfer
@ 2013-03-20 19:24 ` Frank Schäfer
  2013-03-21 10:56   ` Hans Verkuil
  2013-03-20 19:24 ` [RFC PATCH 10/10] bttv: avoid mute on last close when the radio device node is still open Frank Schäfer
  9 siblings, 1 reply; 21+ messages in thread
From: Frank Schäfer @ 2013-03-20 19:24 UTC (permalink / raw)
  To: mchehab; +Cc: hverkuil, linux-media, Frank Schäfer

Instead of applying the current mute setting on last device node close, always
mute the device.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
---
 drivers/media/pci/bt8xx/bttv-driver.c |    2 +-
 1 Datei geändert, 1 Zeile hinzugefügt(+), 1 Zeile entfernt(-)

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index 2fb2168..469ea06 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -3126,7 +3126,7 @@ static int bttv_release(struct file *file)
 	bttv_field_count(btv);
 
 	if (!btv->users)
-		audio_mute(btv, btv->mute);
+		audio_mute(btv, 1);
 
 	v4l2_fh_del(&fh->fh);
 	v4l2_fh_exit(&fh->fh);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [RFC PATCH 10/10] bttv: avoid mute on last close when the radio device node is still open
  2013-03-20 19:24 [RFC PATCH 00/10] bttv: refactor audio_mux() and fix muting/unmuting Frank Schäfer
                   ` (8 preceding siblings ...)
  2013-03-20 19:24 ` [RFC PATCH 09/10] bttv: fix mute on last close of the video device node Frank Schäfer
@ 2013-03-20 19:24 ` Frank Schäfer
  9 siblings, 0 replies; 21+ messages in thread
From: Frank Schäfer @ 2013-03-20 19:24 UTC (permalink / raw)
  To: mchehab; +Cc: hverkuil, linux-media, Frank Schäfer

In contrast to video devices, radio devices should not be muted on the last
close of the device node.
In cases where a device provides a video and a radio device node, tuner
ownership has to be taken into account.

The current code doesn't handle tuner ownership yet, so never mute the device if
the radio device node is still open.
Also add a comment about this issue.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
---
 drivers/media/pci/bt8xx/bttv-driver.c |    5 ++++-
 1 Datei geändert, 4 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index 469ea06..124abaf 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -3125,8 +3125,11 @@ static int bttv_release(struct file *file)
 	btv->users--;
 	bttv_field_count(btv);
 
-	if (!btv->users)
+	if (!btv->users && !btv->radio_user)
 		audio_mute(btv, 1);
+	/* FIXME: should also depend on tuner ownership ! */
+	/* NOTE as long as we don't handle the tuner ownership properly,
+	 * only mute the device if the radio device node isn't open. */
 
 	v4l2_fh_del(&fh->fh);
 	v4l2_fh_exit(&fh->fh);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [RFC PATCH 01/10] bttv: audio_mux(): use a local variable "gpio_mute" instead of modifying the function parameter "mute"
  2013-03-20 19:24 ` [RFC PATCH 01/10] bttv: audio_mux(): use a local variable "gpio_mute" instead of modifying the function parameter "mute" Frank Schäfer
@ 2013-03-21 10:24   ` Hans Verkuil
  0 siblings, 0 replies; 21+ messages in thread
From: Hans Verkuil @ 2013-03-21 10:24 UTC (permalink / raw)
  To: Frank Schäfer; +Cc: mchehab, linux-media

On Wed 20 March 2013 20:24:41 Frank Schäfer wrote:
> Function audio_mux() actually deals with two types of mute: gpio mute and
> subdevice muting.
> This patch claryfies the meaning of these values, but mainly prepares the code for
> the next patch.
> 
> Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Regards,

	Hans

> ---
>  drivers/media/pci/bt8xx/bttv-driver.c |    8 ++++----
>  1 Datei geändert, 4 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)
> 
> diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
> index 8610b6a..a584d82 100644
> --- a/drivers/media/pci/bt8xx/bttv-driver.c
> +++ b/drivers/media/pci/bt8xx/bttv-driver.c
> @@ -992,7 +992,7 @@ static char *audio_modes[] = {
>  static int
>  audio_mux(struct bttv *btv, int input, int mute)
>  {
> -	int gpio_val, signal;
> +	int gpio_val, signal, mute_gpio;
>  	struct v4l2_ctrl *ctrl;
>  
>  	gpio_inout(bttv_tvcards[btv->c.type].gpiomask,
> @@ -1003,10 +1003,10 @@ audio_mux(struct bttv *btv, int input, int mute)
>  	btv->audio = input;
>  
>  	/* automute */
> -	mute = mute || (btv->opt_automute && (!signal || !btv->users)
> +	mute_gpio = mute || (btv->opt_automute && (!signal || !btv->users)
>  				&& !btv->has_radio_tuner);
>  
> -	if (mute)
> +	if (mute_gpio)
>  		gpio_val = bttv_tvcards[btv->c.type].gpiomute;
>  	else
>  		gpio_val = bttv_tvcards[btv->c.type].gpiomux[input];
> @@ -1022,7 +1022,7 @@ audio_mux(struct bttv *btv, int input, int mute)
>  	}
>  
>  	if (bttv_gpio)
> -		bttv_gpio_tracking(btv, audio_modes[mute ? 4 : input]);
> +		bttv_gpio_tracking(btv, audio_modes[mute_gpio ? 4 : input]);
>  	if (in_interrupt())
>  		return 0;
>  
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC PATCH 02/10] bttv: audio_mux(): do not change the value of the v4l2 mute control
  2013-03-20 19:24 ` [RFC PATCH 02/10] bttv: audio_mux(): do not change the value of the v4l2 mute control Frank Schäfer
@ 2013-03-21 10:26   ` Hans Verkuil
  0 siblings, 0 replies; 21+ messages in thread
From: Hans Verkuil @ 2013-03-21 10:26 UTC (permalink / raw)
  To: Frank Schäfer; +Cc: mchehab, linux-media

On Wed 20 March 2013 20:24:42 Frank Schäfer wrote:
> There are cases where we want to call audio_mux() without changing the value of
> the v4l2 mute control, for example
> - mute mute on last close
> - mute on device probing

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Regards,

	Hans

> Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
> ---
>  drivers/media/pci/bt8xx/bttv-driver.c |    8 ++++----
>  1 Datei geändert, 4 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)
> 
> diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
> index a584d82..a082ab4 100644
> --- a/drivers/media/pci/bt8xx/bttv-driver.c
> +++ b/drivers/media/pci/bt8xx/bttv-driver.c
> @@ -999,7 +999,6 @@ audio_mux(struct bttv *btv, int input, int mute)
>  		   bttv_tvcards[btv->c.type].gpiomask);
>  	signal = btread(BT848_DSTATUS) & BT848_DSTATUS_HLOC;
>  
> -	btv->mute = mute;
>  	btv->audio = input;
>  
>  	/* automute */
> @@ -1031,7 +1030,7 @@ audio_mux(struct bttv *btv, int input, int mute)
>  
>  		ctrl = v4l2_ctrl_find(btv->sd_msp34xx->ctrl_handler, V4L2_CID_AUDIO_MUTE);
>  		if (ctrl)
> -			v4l2_ctrl_s_ctrl(ctrl, btv->mute);
> +			v4l2_ctrl_s_ctrl(ctrl, mute);
>  
>  		/* Note: the inputs tuner/radio/extern/intern are translated
>  		   to msp routings. This assumes common behavior for all msp3400
> @@ -1080,7 +1079,7 @@ audio_mux(struct bttv *btv, int input, int mute)
>  		ctrl = v4l2_ctrl_find(btv->sd_tvaudio->ctrl_handler, V4L2_CID_AUDIO_MUTE);
>  
>  		if (ctrl)
> -			v4l2_ctrl_s_ctrl(ctrl, btv->mute);
> +			v4l2_ctrl_s_ctrl(ctrl, mute);
>  		v4l2_subdev_call(btv->sd_tvaudio, audio, s_routing,
>  				input, 0, 0);
>  	}
> @@ -1088,7 +1087,7 @@ audio_mux(struct bttv *btv, int input, int mute)
>  		ctrl = v4l2_ctrl_find(btv->sd_tda7432->ctrl_handler, V4L2_CID_AUDIO_MUTE);
>  
>  		if (ctrl)
> -			v4l2_ctrl_s_ctrl(ctrl, btv->mute);
> +			v4l2_ctrl_s_ctrl(ctrl, mute);
>  	}
>  	return 0;
>  }
> @@ -1300,6 +1299,7 @@ static int bttv_s_ctrl(struct v4l2_ctrl *c)
>  		break;
>  	case V4L2_CID_AUDIO_MUTE:
>  		audio_mute(btv, c->val);
> +		btv->mute = c->val;
>  		break;
>  	case V4L2_CID_AUDIO_VOLUME:
>  		btv->volume_gpio(btv, c->val);
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC PATCH 03/10] bttv: do not save the audio input in audio_mux()
  2013-03-20 19:24 ` [RFC PATCH 03/10] bttv: do not save the audio input in audio_mux() Frank Schäfer
@ 2013-03-21 10:28   ` Hans Verkuil
  0 siblings, 0 replies; 21+ messages in thread
From: Hans Verkuil @ 2013-03-21 10:28 UTC (permalink / raw)
  To: Frank Schäfer; +Cc: mchehab, linux-media

On Wed 20 March 2013 20:24:43 Frank Schäfer wrote:
> We can't and do not save the mute setting in function audio_mux(), so we
> should also not save the input in this function for consistency.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Regards,

	Hans

> 
> Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
> ---
>  drivers/media/pci/bt8xx/bttv-driver.c |   10 +++++-----
>  1 Datei geändert, 5 Zeilen hinzugefügt(+), 5 Zeilen entfernt(-)
> 
> diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
> index a082ab4..e01a8d8 100644
> --- a/drivers/media/pci/bt8xx/bttv-driver.c
> +++ b/drivers/media/pci/bt8xx/bttv-driver.c
> @@ -999,8 +999,6 @@ audio_mux(struct bttv *btv, int input, int mute)
>  		   bttv_tvcards[btv->c.type].gpiomask);
>  	signal = btread(BT848_DSTATUS) & BT848_DSTATUS_HLOC;
>  
> -	btv->audio = input;
> -
>  	/* automute */
>  	mute_gpio = mute || (btv->opt_automute && (!signal || !btv->users)
>  				&& !btv->has_radio_tuner);
> @@ -1197,8 +1195,9 @@ set_input(struct bttv *btv, unsigned int input, unsigned int norm)
>  	} else {
>  		video_mux(btv,input);
>  	}
> -	audio_input(btv, (btv->tuner_type != TUNER_ABSENT && input == 0) ?
> -			 TVAUDIO_INPUT_TUNER : TVAUDIO_INPUT_EXTERN);
> +	btv->audio = (btv->tuner_type != TUNER_ABSENT && input == 0) ?
> +			 TVAUDIO_INPUT_TUNER : TVAUDIO_INPUT_EXTERN;
> +	audio_input(btv, btv->audio);
>  	set_tvnorm(btv, norm);
>  }
>  
> @@ -1707,7 +1706,8 @@ static void radio_enable(struct bttv *btv)
>  	if (!btv->has_radio_tuner) {
>  		btv->has_radio_tuner = 1;
>  		bttv_call_all(btv, tuner, s_radio);
> -		audio_input(btv, TVAUDIO_INPUT_RADIO);
> +		btv->audio = TVAUDIO_INPUT_RADIO;
> +		audio_input(btv, btv->audio);
>  	}
>  }
>  
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC PATCH 04/10] bttv: rename field 'audio' in struct 'bttv' to 'audio_input'
  2013-03-20 19:24 ` [RFC PATCH 04/10] bttv: rename field 'audio' in struct 'bttv' to 'audio_input' Frank Schäfer
@ 2013-03-21 10:28   ` Hans Verkuil
  0 siblings, 0 replies; 21+ messages in thread
From: Hans Verkuil @ 2013-03-21 10:28 UTC (permalink / raw)
  To: Frank Schäfer; +Cc: mchehab, linux-media

On Wed 20 March 2013 20:24:44 Frank Schäfer wrote:
> 'audio_input' better describes the meaning of this field.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Regards,

	Hans

> Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
> ---
>  drivers/media/pci/bt8xx/bttv-cards.c  |    2 +-
>  drivers/media/pci/bt8xx/bttv-driver.c |   12 ++++++------
>  drivers/media/pci/bt8xx/bttvp.h       |    2 +-
>  3 Dateien geändert, 8 Zeilen hinzugefügt(+), 8 Zeilen entfernt(-)
> 
> diff --git a/drivers/media/pci/bt8xx/bttv-cards.c b/drivers/media/pci/bt8xx/bttv-cards.c
> index fa0faaa..b7dc921 100644
> --- a/drivers/media/pci/bt8xx/bttv-cards.c
> +++ b/drivers/media/pci/bt8xx/bttv-cards.c
> @@ -3947,7 +3947,7 @@ static void avermedia_eeprom(struct bttv *btv)
>  u32 bttv_tda9880_setnorm(struct bttv *btv, u32 gpiobits)
>  {
>  
> -	if (btv->audio == TVAUDIO_INPUT_TUNER) {
> +	if (btv->audio_input == TVAUDIO_INPUT_TUNER) {
>  		if (bttv_tvnorms[btv->tvnorm].v4l2_id & V4L2_STD_MN)
>  			gpiobits |= 0x10000;
>  		else
> diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
> index e01a8d8..81ee70d 100644
> --- a/drivers/media/pci/bt8xx/bttv-driver.c
> +++ b/drivers/media/pci/bt8xx/bttv-driver.c
> @@ -1093,7 +1093,7 @@ audio_mux(struct bttv *btv, int input, int mute)
>  static inline int
>  audio_mute(struct bttv *btv, int mute)
>  {
> -	return audio_mux(btv, btv->audio, mute);
> +	return audio_mux(btv, btv->audio_input, mute);
>  }
>  
>  static inline int
> @@ -1195,9 +1195,9 @@ set_input(struct bttv *btv, unsigned int input, unsigned int norm)
>  	} else {
>  		video_mux(btv,input);
>  	}
> -	btv->audio = (btv->tuner_type != TUNER_ABSENT && input == 0) ?
> -			 TVAUDIO_INPUT_TUNER : TVAUDIO_INPUT_EXTERN;
> -	audio_input(btv, btv->audio);
> +	btv->audio_input = (btv->tuner_type != TUNER_ABSENT && input == 0) ?
> +				TVAUDIO_INPUT_TUNER : TVAUDIO_INPUT_EXTERN;
> +	audio_input(btv, btv->audio_input);
>  	set_tvnorm(btv, norm);
>  }
>  
> @@ -1706,8 +1706,8 @@ static void radio_enable(struct bttv *btv)
>  	if (!btv->has_radio_tuner) {
>  		btv->has_radio_tuner = 1;
>  		bttv_call_all(btv, tuner, s_radio);
> -		btv->audio = TVAUDIO_INPUT_RADIO;
> -		audio_input(btv, btv->audio);
> +		btv->audio_input = TVAUDIO_INPUT_RADIO;
> +		audio_input(btv, btv->audio_input);
>  	}
>  }
>  
> diff --git a/drivers/media/pci/bt8xx/bttvp.h b/drivers/media/pci/bt8xx/bttvp.h
> index e7910e0..9c1cc2c 100644
> --- a/drivers/media/pci/bt8xx/bttvp.h
> +++ b/drivers/media/pci/bt8xx/bttvp.h
> @@ -423,7 +423,7 @@ struct bttv {
>  
>  	/* video state */
>  	unsigned int input;
> -	unsigned int audio;
> +	unsigned int audio_input;
>  	unsigned int mute;
>  	unsigned long tv_freq;
>  	unsigned int tvnorm;
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC PATCH 05/10] bttv: separate GPIO part from function audio_mux()
  2013-03-20 19:24 ` [RFC PATCH 05/10] bttv: separate GPIO part from function audio_mux() Frank Schäfer
@ 2013-03-21 10:32   ` Hans Verkuil
  0 siblings, 0 replies; 21+ messages in thread
From: Hans Verkuil @ 2013-03-21 10:32 UTC (permalink / raw)
  To: Frank Schäfer; +Cc: mchehab, linux-media

On Wed 20 March 2013 20:24:45 Frank Schäfer wrote:
> Move the GPIO part of function audio_mux() to a separate function
> audio_mux_gpio().
> This prepares the code for the next patch which will separate mute and input
> setting.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Regards,

	Hans

> Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
> ---
>  drivers/media/pci/bt8xx/bttv-driver.c |   18 ++++++++++++------
>  1 Datei geändert, 12 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-)
> 
> diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
> index 81ee70d..f1cb0db 100644
> --- a/drivers/media/pci/bt8xx/bttv-driver.c
> +++ b/drivers/media/pci/bt8xx/bttv-driver.c
> @@ -989,11 +989,10 @@ static char *audio_modes[] = {
>  	"audio: intern", "audio: mute"
>  };
>  
> -static int
> -audio_mux(struct bttv *btv, int input, int mute)
> +static void
> +audio_mux_gpio(struct bttv *btv, int input, int mute)
>  {
>  	int gpio_val, signal, mute_gpio;
> -	struct v4l2_ctrl *ctrl;
>  
>  	gpio_inout(bttv_tvcards[btv->c.type].gpiomask,
>  		   bttv_tvcards[btv->c.type].gpiomask);
> @@ -1020,8 +1019,14 @@ audio_mux(struct bttv *btv, int input, int mute)
>  
>  	if (bttv_gpio)
>  		bttv_gpio_tracking(btv, audio_modes[mute_gpio ? 4 : input]);
> -	if (in_interrupt())
> -		return 0;
> +}
> +
> +static int
> +audio_mux(struct bttv *btv, int input, int mute)
> +{
> +	struct v4l2_ctrl *ctrl;
> +
> +	audio_mux_gpio(btv, input, mute);
>  
>  	if (btv->sd_msp34xx) {
>  		u32 in;
> @@ -3846,7 +3851,8 @@ static irqreturn_t bttv_irq(int irq, void *dev_id)
>  			bttv_irq_switch_video(btv);
>  
>  		if ((astat & BT848_INT_HLOCK)  &&  btv->opt_automute)
> -			audio_mute(btv, btv->mute);  /* trigger automute */
> +			/* trigger automute */
> +			audio_mux_gpio(btv, btv->audio_input, btv->mute);
>  
>  		if (astat & (BT848_INT_SCERR|BT848_INT_OCERR)) {
>  			pr_info("%d: %s%s @ %08x,",
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC PATCH 06/10] bttv: untangle audio input and mute setting
  2013-03-20 19:24 ` [RFC PATCH 06/10] bttv: untangle audio input and mute setting Frank Schäfer
@ 2013-03-21 10:37   ` Hans Verkuil
  0 siblings, 0 replies; 21+ messages in thread
From: Hans Verkuil @ 2013-03-21 10:37 UTC (permalink / raw)
  To: Frank Schäfer; +Cc: mchehab, linux-media

On Wed 20 March 2013 20:24:46 Frank Schäfer wrote:
> Split function audio_mux():
> move the mute setting part to function audio_mute() and the input setting part
> to function audio_input().

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Regards,

	Hans

> Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
> ---
>  drivers/media/pci/bt8xx/bttv-driver.c |   51 ++++++++++++++++-----------------
>  1 Datei geändert, 24 Zeilen hinzugefügt(+), 27 Zeilen entfernt(-)
> 
> diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
> index f1cb0db..0df4a16 100644
> --- a/drivers/media/pci/bt8xx/bttv-driver.c
> +++ b/drivers/media/pci/bt8xx/bttv-driver.c
> @@ -1022,18 +1022,37 @@ audio_mux_gpio(struct bttv *btv, int input, int mute)
>  }
>  
>  static int
> -audio_mux(struct bttv *btv, int input, int mute)
> +audio_mute(struct bttv *btv, int mute)
>  {
>  	struct v4l2_ctrl *ctrl;
>  
> -	audio_mux_gpio(btv, input, mute);
> +	audio_mux_gpio(btv, btv->audio_input, mute);
>  
>  	if (btv->sd_msp34xx) {
> -		u32 in;
> -
>  		ctrl = v4l2_ctrl_find(btv->sd_msp34xx->ctrl_handler, V4L2_CID_AUDIO_MUTE);
>  		if (ctrl)
>  			v4l2_ctrl_s_ctrl(ctrl, mute);
> +	}
> +	if (btv->sd_tvaudio) {
> +		ctrl = v4l2_ctrl_find(btv->sd_tvaudio->ctrl_handler, V4L2_CID_AUDIO_MUTE);
> +		if (ctrl)
> +			v4l2_ctrl_s_ctrl(ctrl, mute);
> +	}
> +	if (btv->sd_tda7432) {
> +		ctrl = v4l2_ctrl_find(btv->sd_tda7432->ctrl_handler, V4L2_CID_AUDIO_MUTE);
> +		if (ctrl)
> +			v4l2_ctrl_s_ctrl(ctrl, mute);
> +	}
> +	return 0;
> +}
> +
> +static int
> +audio_input(struct bttv *btv, int input)
> +{
> +	audio_mux_gpio(btv, input, btv->mute);
> +
> +	if (btv->sd_msp34xx) {
> +		u32 in;
>  
>  		/* Note: the inputs tuner/radio/extern/intern are translated
>  		   to msp routings. This assumes common behavior for all msp3400
> @@ -1079,34 +1098,12 @@ audio_mux(struct bttv *btv, int input, int mute)
>  			       in, MSP_OUTPUT_DEFAULT, 0);
>  	}
>  	if (btv->sd_tvaudio) {
> -		ctrl = v4l2_ctrl_find(btv->sd_tvaudio->ctrl_handler, V4L2_CID_AUDIO_MUTE);
> -
> -		if (ctrl)
> -			v4l2_ctrl_s_ctrl(ctrl, mute);
>  		v4l2_subdev_call(btv->sd_tvaudio, audio, s_routing,
> -				input, 0, 0);
> -	}
> -	if (btv->sd_tda7432) {
> -		ctrl = v4l2_ctrl_find(btv->sd_tda7432->ctrl_handler, V4L2_CID_AUDIO_MUTE);
> -
> -		if (ctrl)
> -			v4l2_ctrl_s_ctrl(ctrl, mute);
> +				 input, 0, 0);
>  	}
>  	return 0;
>  }
>  
> -static inline int
> -audio_mute(struct bttv *btv, int mute)
> -{
> -	return audio_mux(btv, btv->audio_input, mute);
> -}
> -
> -static inline int
> -audio_input(struct bttv *btv, int input)
> -{
> -	return audio_mux(btv, input, btv->mute);
> -}
> -
>  static void
>  bttv_crop_calc_limits(struct bttv_crop *c)
>  {
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC PATCH 07/10] bttv: do not unmute the device before the first open
  2013-03-20 19:24 ` [RFC PATCH 07/10] bttv: do not unmute the device before the first open Frank Schäfer
@ 2013-03-21 10:38   ` Hans Verkuil
  0 siblings, 0 replies; 21+ messages in thread
From: Hans Verkuil @ 2013-03-21 10:38 UTC (permalink / raw)
  To: Frank Schäfer; +Cc: mchehab, linux-media

On Wed 20 March 2013 20:24:47 Frank Schäfer wrote:

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Regards,

	Hans

> Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
> ---
>  drivers/media/pci/bt8xx/bttv-driver.c |    4 +++-
>  1 Datei geändert, 3 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)
> 
> diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
> index 0df4a16..55eab61 100644
> --- a/drivers/media/pci/bt8xx/bttv-driver.c
> +++ b/drivers/media/pci/bt8xx/bttv-driver.c
> @@ -4212,11 +4212,13 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
>  	btv->std = V4L2_STD_PAL;
>  	init_irqreg(btv);
>  	v4l2_ctrl_handler_setup(hdl);
> -
>  	if (hdl->error) {
>  		result = hdl->error;
>  		goto fail2;
>  	}
> +	/* mute device */
> +	audio_mute(btv, 1);
> +
>  	/* register video4linux + input */
>  	if (!bttv_tvcards[btv->c.type].no_video) {
>  		v4l2_ctrl_add_handler(&btv->radio_ctrl_handler, hdl,
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC PATCH 08/10] bttv: apply mute settings on open
  2013-03-20 19:24 ` [RFC PATCH 08/10] bttv: apply mute settings on open Frank Schäfer
@ 2013-03-21 10:39   ` Hans Verkuil
  0 siblings, 0 replies; 21+ messages in thread
From: Hans Verkuil @ 2013-03-21 10:39 UTC (permalink / raw)
  To: Frank Schäfer; +Cc: mchehab, linux-media

On Wed 20 March 2013 20:24:48 Frank Schäfer wrote:
> Previously, this has been done implicitly for video device nodes by calling
> set_input() (which calls audio_input() and also modified the mute
> setting).
> Since input and mute setting are now untangled (as much as possible), we need to
> apply the mute setting with an explicit call to audio_mute().
> Also apply the mute setting when the radio device node gets opened.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Regards,

	Hans

> Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
> ---
>  drivers/media/pci/bt8xx/bttv-driver.c |    3 ++-
>  1 Datei geändert, 2 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)
> 
> diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
> index 55eab61..2fb2168 100644
> --- a/drivers/media/pci/bt8xx/bttv-driver.c
> +++ b/drivers/media/pci/bt8xx/bttv-driver.c
> @@ -3065,7 +3065,7 @@ static int bttv_open(struct file *file)
>  			    fh, &btv->lock);
>  	set_tvnorm(btv,btv->tvnorm);
>  	set_input(btv, btv->input, btv->tvnorm);
> -
> +	audio_mute(btv, btv->mute);
>  
>  	/* The V4L2 spec requires one global set of cropping parameters
>  	   which only change on request. These are stored in btv->crop[1].
> @@ -3230,6 +3230,7 @@ static int radio_open(struct file *file)
>  	v4l2_fh_init(&fh->fh, vdev);
>  
>  	btv->radio_user++;
> +	audio_mute(btv, btv->mute);
>  
>  	v4l2_fh_add(&fh->fh);
>  
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC PATCH 09/10] bttv: fix mute on last close of the video device node
  2013-03-20 19:24 ` [RFC PATCH 09/10] bttv: fix mute on last close of the video device node Frank Schäfer
@ 2013-03-21 10:56   ` Hans Verkuil
  2013-03-21 17:44     ` Frank Schäfer
  0 siblings, 1 reply; 21+ messages in thread
From: Hans Verkuil @ 2013-03-21 10:56 UTC (permalink / raw)
  To: Frank Schäfer; +Cc: mchehab, linux-media

On Wed 20 March 2013 20:24:49 Frank Schäfer wrote:
> Instead of applying the current mute setting on last device node close, always
> mute the device.

I am very pleased with the preceding 8 patches. That does exactly what I had
in mind. For this patch and the next (I would have combined those two into one
patch BTW) I want to do some testing first. Unfortunately due to travel I will
not have access to bttv hardware for the next 10 days or so.

One thing I am considering is adding some basic tuner-ownership functionality
to the v4l2 core. Without that I don't think we can ever get this working as
it should.

It might be an idea to make a pull request for the first 8 patches some time
next week. That's all good stuff and it makes the code much easier to
understand.

Regards,

	Hans

> Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
> ---
>  drivers/media/pci/bt8xx/bttv-driver.c |    2 +-
>  1 Datei geändert, 1 Zeile hinzugefügt(+), 1 Zeile entfernt(-)
> 
> diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
> index 2fb2168..469ea06 100644
> --- a/drivers/media/pci/bt8xx/bttv-driver.c
> +++ b/drivers/media/pci/bt8xx/bttv-driver.c
> @@ -3126,7 +3126,7 @@ static int bttv_release(struct file *file)
>  	bttv_field_count(btv);
>  
>  	if (!btv->users)
> -		audio_mute(btv, btv->mute);
> +		audio_mute(btv, 1);
>  
>  	v4l2_fh_del(&fh->fh);
>  	v4l2_fh_exit(&fh->fh);
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC PATCH 09/10] bttv: fix mute on last close of the video device node
  2013-03-21 10:56   ` Hans Verkuil
@ 2013-03-21 17:44     ` Frank Schäfer
  0 siblings, 0 replies; 21+ messages in thread
From: Frank Schäfer @ 2013-03-21 17:44 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Am 21.03.2013 11:56, schrieb Hans Verkuil:
> On Wed 20 March 2013 20:24:49 Frank Schäfer wrote:
>> Instead of applying the current mute setting on last device node close, always
>> mute the device.
> I am very pleased with the preceding 8 patches. That does exactly what I had
> in mind. For this patch and the next (I would have combined those two into one
> patch BTW) I want to do some testing first. Unfortunately due to travel I will
> not have access to bttv hardware for the next 10 days or so.

No problem, I don't think this is high priority stuff. ;)

> One thing I am considering is adding some basic tuner-ownership functionality
> to the v4l2 core. Without that I don't think we can ever get this working as
> it should.

Sounds good !

> It might be an idea to make a pull request for the first 8 patches some time
> next week. That's all good stuff and it makes the code much easier to
> understand.

Ok, I will resend the first 8 patches witch you ACK added and RFC removed.
Please drop me a message when you have tested the last two patches and
want me to take further actions.

Thanks for reviewing !

Regards,
Frank

> Regards,
>
> 	Hans
>
>> Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
>> ---
>>  drivers/media/pci/bt8xx/bttv-driver.c |    2 +-
>>  1 Datei geändert, 1 Zeile hinzugefügt(+), 1 Zeile entfernt(-)
>>
>> diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
>> index 2fb2168..469ea06 100644
>> --- a/drivers/media/pci/bt8xx/bttv-driver.c
>> +++ b/drivers/media/pci/bt8xx/bttv-driver.c
>> @@ -3126,7 +3126,7 @@ static int bttv_release(struct file *file)
>>  	bttv_field_count(btv);
>>  
>>  	if (!btv->users)
>> -		audio_mute(btv, btv->mute);
>> +		audio_mute(btv, 1);
>>  
>>  	v4l2_fh_del(&fh->fh);
>>  	v4l2_fh_exit(&fh->fh);
>>


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2013-03-21 17:43 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-20 19:24 [RFC PATCH 00/10] bttv: refactor audio_mux() and fix muting/unmuting Frank Schäfer
2013-03-20 19:24 ` [RFC PATCH 01/10] bttv: audio_mux(): use a local variable "gpio_mute" instead of modifying the function parameter "mute" Frank Schäfer
2013-03-21 10:24   ` Hans Verkuil
2013-03-20 19:24 ` [RFC PATCH 02/10] bttv: audio_mux(): do not change the value of the v4l2 mute control Frank Schäfer
2013-03-21 10:26   ` Hans Verkuil
2013-03-20 19:24 ` [RFC PATCH 03/10] bttv: do not save the audio input in audio_mux() Frank Schäfer
2013-03-21 10:28   ` Hans Verkuil
2013-03-20 19:24 ` [RFC PATCH 04/10] bttv: rename field 'audio' in struct 'bttv' to 'audio_input' Frank Schäfer
2013-03-21 10:28   ` Hans Verkuil
2013-03-20 19:24 ` [RFC PATCH 05/10] bttv: separate GPIO part from function audio_mux() Frank Schäfer
2013-03-21 10:32   ` Hans Verkuil
2013-03-20 19:24 ` [RFC PATCH 06/10] bttv: untangle audio input and mute setting Frank Schäfer
2013-03-21 10:37   ` Hans Verkuil
2013-03-20 19:24 ` [RFC PATCH 07/10] bttv: do not unmute the device before the first open Frank Schäfer
2013-03-21 10:38   ` Hans Verkuil
2013-03-20 19:24 ` [RFC PATCH 08/10] bttv: apply mute settings on open Frank Schäfer
2013-03-21 10:39   ` Hans Verkuil
2013-03-20 19:24 ` [RFC PATCH 09/10] bttv: fix mute on last close of the video device node Frank Schäfer
2013-03-21 10:56   ` Hans Verkuil
2013-03-21 17:44     ` Frank Schäfer
2013-03-20 19:24 ` [RFC PATCH 10/10] bttv: avoid mute on last close when the radio device node is still open Frank Schäfer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.