linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH v2 0/6] bttv: fix muting/unmuting on probing, first open and last close
@ 2013-03-10 21:53 Frank Schäfer
  2013-03-10 21:53 ` [RFC PATCH v2 1/6] bttv: audio_mux() use a local variable "gpio_mute" instead of modifying the function parameter "mute" Frank Schäfer
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Frank Schäfer @ 2013-03-10 21:53 UTC (permalink / raw)
  To: mchehab; +Cc: hverkuil, linux-media, Frank Schäfer

This patch series fixes some remaining issues with regards to device 
muting/unmuting on probing, first open and last close with the bttv driver.

The first 2 patches are preparatory patches, patches 3 to 6 the actual fixes.

Changes since v1:
- splitted patch 1 to 4 separate patches (patches 1-4)
- dropped patch 2 (mute on last close of the radio device node)
- added patches 5+6

Frank Schäfer (6):
  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: fix mute on last close of the video device node
  bttv: do not unmute the device before the first open
  bttv: avoid mute on last close when the radio device node is still
    open
  bttv: radio: apply mute settings on open

 drivers/media/pci/bt8xx/bttv-driver.c |   34 +++++++++++++++++++--------------
 1 Datei geändert, 20 Zeilen hinzugefügt(+), 14 Zeilen entfernt(-)

-- 
1.7.10.4


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

* [RFC PATCH v2 1/6] bttv: audio_mux() use a local variable "gpio_mute" instead of modifying the function parameter "mute"
  2013-03-10 21:53 [RFC PATCH v2 0/6] bttv: fix muting/unmuting on probing, first open and last close Frank Schäfer
@ 2013-03-10 21:53 ` Frank Schäfer
  2013-03-12 13:25   ` Hans Verkuil
  2013-03-10 21:53 ` [RFC PATCH v2 2/6] bttv: audio_mux(): do not change the value of the v4l2 mute control Frank Schäfer
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Frank Schäfer @ 2013-03-10 21:53 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] 10+ messages in thread

* [RFC PATCH v2 2/6] bttv: audio_mux(): do not change the value of the v4l2 mute control
  2013-03-10 21:53 [RFC PATCH v2 0/6] bttv: fix muting/unmuting on probing, first open and last close Frank Schäfer
  2013-03-10 21:53 ` [RFC PATCH v2 1/6] bttv: audio_mux() use a local variable "gpio_mute" instead of modifying the function parameter "mute" Frank Schäfer
@ 2013-03-10 21:53 ` Frank Schäfer
  2013-03-12 13:41   ` Hans Verkuil
  2013-03-10 21:53 ` [RFC PATCH v2 3/6] bttv: fix mute on last close of the video device node Frank Schäfer
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Frank Schäfer @ 2013-03-10 21:53 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] 10+ messages in thread

* [RFC PATCH v2 3/6] bttv: fix mute on last close of the video device node
  2013-03-10 21:53 [RFC PATCH v2 0/6] bttv: fix muting/unmuting on probing, first open and last close Frank Schäfer
  2013-03-10 21:53 ` [RFC PATCH v2 1/6] bttv: audio_mux() use a local variable "gpio_mute" instead of modifying the function parameter "mute" Frank Schäfer
  2013-03-10 21:53 ` [RFC PATCH v2 2/6] bttv: audio_mux(): do not change the value of the v4l2 mute control Frank Schäfer
@ 2013-03-10 21:53 ` Frank Schäfer
  2013-03-10 21:53 ` [RFC PATCH v2 4/6] bttv: do not unmute the device before the first open Frank Schäfer
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Frank Schäfer @ 2013-03-10 21:53 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 |    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 a082ab4..945ecd2 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -3124,7 +3124,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] 10+ messages in thread

* [RFC PATCH v2 4/6] bttv: do not unmute the device before the first open
  2013-03-10 21:53 [RFC PATCH v2 0/6] bttv: fix muting/unmuting on probing, first open and last close Frank Schäfer
                   ` (2 preceding siblings ...)
  2013-03-10 21:53 ` [RFC PATCH v2 3/6] bttv: fix mute on last close of the video device node Frank Schäfer
@ 2013-03-10 21:53 ` Frank Schäfer
  2013-03-10 21:53 ` [RFC PATCH v2 5/6] bttv: avoid mute on last close when the radio device node is still open Frank Schäfer
  2013-03-10 21:53 ` [RFC PATCH v2 6/6] bttv: radio: apply mute settings on open Frank Schäfer
  5 siblings, 0 replies; 10+ messages in thread
From: Frank Schäfer @ 2013-03-10 21:53 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 |    8 +++++---
 1 Datei geändert, 5 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-)

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index 945ecd2..6432bfe 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -3062,8 +3062,7 @@ static int bttv_open(struct file *file)
 			    sizeof(struct bttv_buffer),
 			    fh, &btv->lock);
 	set_tvnorm(btv,btv->tvnorm);
-	set_input(btv, btv->input, btv->tvnorm);
-
+	set_input(btv, btv->input, btv->tvnorm); /* also (un)mutes audio */
 
 	/* The V4L2 spec requires one global set of cropping parameters
 	   which only change on request. These are stored in btv->crop[1].
@@ -4209,11 +4208,14 @@ 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] 10+ messages in thread

* [RFC PATCH v2 5/6] bttv: avoid mute on last close when the radio device node is still open
  2013-03-10 21:53 [RFC PATCH v2 0/6] bttv: fix muting/unmuting on probing, first open and last close Frank Schäfer
                   ` (3 preceding siblings ...)
  2013-03-10 21:53 ` [RFC PATCH v2 4/6] bttv: do not unmute the device before the first open Frank Schäfer
@ 2013-03-10 21:53 ` Frank Schäfer
  2013-03-10 21:53 ` [RFC PATCH v2 6/6] bttv: radio: apply mute settings on open Frank Schäfer
  5 siblings, 0 replies; 10+ messages in thread
From: Frank Schäfer @ 2013-03-10 21:53 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 |    6 ++++--
 1 Datei geändert, 4 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index 6432bfe..7459ad6 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -3114,7 +3114,6 @@ static int bttv_release(struct file *file)
 	}
 
 	/* free stuff */
-
 	videobuf_mmap_free(&fh->cap);
 	videobuf_mmap_free(&fh->vbi);
 	file->private_data = NULL;
@@ -3122,8 +3121,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] 10+ messages in thread

* [RFC PATCH v2 6/6] bttv: radio: apply mute settings on open
  2013-03-10 21:53 [RFC PATCH v2 0/6] bttv: fix muting/unmuting on probing, first open and last close Frank Schäfer
                   ` (4 preceding siblings ...)
  2013-03-10 21:53 ` [RFC PATCH v2 5/6] bttv: avoid mute on last close when the radio device node is still open Frank Schäfer
@ 2013-03-10 21:53 ` Frank Schäfer
  5 siblings, 0 replies; 10+ messages in thread
From: Frank Schäfer @ 2013-03-10 21:53 UTC (permalink / raw)
  To: mchehab; +Cc: hverkuil, linux-media, Frank Schäfer

In contrast to the video device node, radio_open() doesn't select an input
(which would also applies the mute setting).
Hence the device needs to be muted/unmuted with an explicit call to audio_mux()
in this function.

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

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index 7459ad6..5031b6e 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -3232,6 +3232,8 @@ static int radio_open(struct file *file)
 
 	v4l2_fh_add(&fh->fh);
 
+	audio_mute(btv, btv->mute);
+
 	return 0;
 }
 
-- 
1.7.10.4


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

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

On Sun 10 March 2013 22:53:49 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] 10+ messages in thread

* Re: [RFC PATCH v2 2/6] bttv: audio_mux(): do not change the value of the v4l2 mute control
  2013-03-10 21:53 ` [RFC PATCH v2 2/6] bttv: audio_mux(): do not change the value of the v4l2 mute control Frank Schäfer
@ 2013-03-12 13:41   ` Hans Verkuil
  2013-03-15 17:38     ` Frank Schäfer
  0 siblings, 1 reply; 10+ messages in thread
From: Hans Verkuil @ 2013-03-12 13:41 UTC (permalink / raw)
  To: Frank Schäfer; +Cc: mchehab, linux-media

On Sun 10 March 2013 22:53:50 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
> 
> Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>


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

I think it might be a good idea to take this one step further: pull the
btv->audio assignment out of audio_mux as well. In other words, audio_mux
no longer changes the bttv state.

I also think that the audio_mute and audio_input functions should be
removed, just let the code call audio_mux directly. I think that is more
transparent and one less intermediate call.

A next step would be to untangle the audio routing code and mute code
from audio_mux: that's probably the core of all the confusion. The code
relating to the input selection should be put in a separate function that
is called only when you really want to switch inputs.

I'm not sure if you want to spend time on that last step, if not, then just
do the first two suggestions and I'll test the result. But without really
going to the core of the problem (one function mixing up muting and input
selection) it remains hard to prove correctness of the code. If you have
some time, then it would be very nice if this mess can be resolved once and
for all.

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 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] 10+ messages in thread

* Re: [RFC PATCH v2 2/6] bttv: audio_mux(): do not change the value of the v4l2 mute control
  2013-03-12 13:41   ` Hans Verkuil
@ 2013-03-15 17:38     ` Frank Schäfer
  0 siblings, 0 replies; 10+ messages in thread
From: Frank Schäfer @ 2013-03-15 17:38 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Hi Hans,

thank you for reviewing and sorry for the delayed reply !

Am 12.03.2013 14:41, schrieb Hans Verkuil:
> On Sun 10 March 2013 22:53:50 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
>>
>> Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
>
> Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
>
> I think it might be a good idea to take this one step further: pull the
> btv->audio assignment out of audio_mux as well. In other words, audio_mux
> no longer changes the bttv state.

Yes, that should be easy to do.

> I also think that the audio_mute and audio_input functions should be
> removed, just let the code call audio_mux directly. I think that is more
> transparent and one less intermediate call.

OTOH I think they improve readability.
Anyway, this will become obsolete with the next step you're suggesting:

> A next step would be to untangle the audio routing code and mute code
> from audio_mux: that's probably the core of all the confusion. The code
> relating to the input selection should be put in a separate function that
> is called only when you really want to switch inputs.

Yeah, it would be nice if we could do that, but I'm not sure if it's
entirely possible.
Mute + automute and the selected input seem to be coupled via gpio
settings. See the first third
of function audio_mux().
I will have to take a deeper look into the code to see if splitting the
function really makes sense...

> I'm not sure if you want to spend time on that last step, if not, then just
> do the first two suggestions and I'll test the result. But without really
> going to the core of the problem (one function mixing up muting and input
> selection) it remains hard to prove correctness of the code. If you have
> some time, then it would be very nice if this mess can be resolved once and
> for all.

I've put it on my TODO list, but I'm not sure if I'll find some time for
it this weekend.

Regards,
Frank

> 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 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] 10+ messages in thread

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

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-10 21:53 [RFC PATCH v2 0/6] bttv: fix muting/unmuting on probing, first open and last close Frank Schäfer
2013-03-10 21:53 ` [RFC PATCH v2 1/6] bttv: audio_mux() use a local variable "gpio_mute" instead of modifying the function parameter "mute" Frank Schäfer
2013-03-12 13:25   ` Hans Verkuil
2013-03-10 21:53 ` [RFC PATCH v2 2/6] bttv: audio_mux(): do not change the value of the v4l2 mute control Frank Schäfer
2013-03-12 13:41   ` Hans Verkuil
2013-03-15 17:38     ` Frank Schäfer
2013-03-10 21:53 ` [RFC PATCH v2 3/6] bttv: fix mute on last close of the video device node Frank Schäfer
2013-03-10 21:53 ` [RFC PATCH v2 4/6] bttv: do not unmute the device before the first open Frank Schäfer
2013-03-10 21:53 ` [RFC PATCH v2 5/6] bttv: avoid mute on last close when the radio device node is still open Frank Schäfer
2013-03-10 21:53 ` [RFC PATCH v2 6/6] bttv: radio: apply mute settings on open Frank Schäfer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).