bttv: refactor audio_mux() and fix muting/unmuting
Subsystems (2)
cover bttv: refactor audio_mux() and fix muting/unmuting
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(-)
Signature · 1 line
1.7.10.4
RFC PATCH 1/10 bttv: audio_mux(): use a local variable "gpio_mute" instead of modifying the function parameter "mute"
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.
--- drivers/media/pci/bt8xx/bttv-driver.c | 8 ++++----
1 Datei geändert, 4 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)
drivers/media/pci/bt8xx/bttv-driver.c +4 -4
@@ -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 ;
Signature · 1 line
1.7.10.4
Re: [RFC PATCH 01/10] bttv: audio_mux(): use a local variable "gpio_mute" instead of modifying the function parameter "mute"
Quoted 6 lines · 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 <[email protected]>
Regards,
Hans
Quoted 40 lines
--- drivers/media/pci/bt8xx/bttv-driver.c | 8 ++++----1 Datei geändert, 4 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)
drivers/media/pci/bt8xx/bttv-driver.c +4
-4@@ -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 ;
RFC PATCH 2/10 bttv: audio_mux(): do not change the value of the v4l2 mute control
In reply to Frank SchäferThere 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
--- drivers/media/pci/bt8xx/bttv-driver.c | 8 ++++----
1 Datei geändert, 4 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)
drivers/media/pci/bt8xx/bttv-driver.c +4 -4
@@ -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);
Signature · 1 line
1.7.10.4
Re: [RFC PATCH 02/10] bttv: audio_mux(): do not change the value of the v4l2 mute control
Quoted 4 lines · 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
Regards,
Hans
Quoted 53 lines
Signed-off-by Frank Schäfer <[email protected]>--- drivers/media/pci/bt8xx/bttv-driver.c | 8 ++++----1 Datei geändert, 4 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)
drivers/media/pci/bt8xx/bttv-driver.c +4
-4@@ -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);
RFC PATCH 3/10 bttv: do not save the audio input in audio_mux()
In reply to Frank SchäferWe 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.
--- drivers/media/pci/bt8xx/bttv-driver.c | 10 +++++-----
1 Datei geändert, 5 Zeilen hinzugefügt(+), 5 Zeilen entfernt(-)
drivers/media/pci/bt8xx/bttv-driver.c +5 -5
@@ -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); } }
Signature · 1 line
1.7.10.4
Re: [RFC PATCH 03/10] bttv: do not save the audio input in audio_mux()
Quoted 2 lines · 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.
Regards,
Hans
Quoted 42 lines
Signed-off-by Frank Schäfer <[email protected]>--- drivers/media/pci/bt8xx/bttv-driver.c | 10 +++++-----1 Datei geändert, 5 Zeilen hinzugefügt(+), 5 Zeilen entfernt(-)
drivers/media/pci/bt8xx/bttv-driver.c +5
-5@@ -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); } }
RFC PATCH 4/10 bttv: rename field 'audio' in struct 'bttv' to 'audio_input'
In reply to Frank Schäfer'audio_input' better describes the meaning of this field.
--- 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(-)
drivers/media/pci/bt8xx/bttv-cards.c +1 -1
@@ -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
drivers/media/pci/bt8xx/bttv-driver.c +6 -6
@@ -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); } }
drivers/media/pci/bt8xx/bttvp.h +1 -1
@@ -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;
Signature · 1 line
1.7.10.4
Re: [RFC PATCH 04/10] bttv: rename field 'audio' in struct 'bttv' to 'audio_input'
Quoted 1 line · On Wed 20 March 2013 20:24:44 Frank Schäfer wrote:
'
audio_input' better describes the meaning of this field.
Regards,
Hans
Quoted 71 lines
Signed-off-by Frank Schäfer <[email protected]>--- 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(-)
drivers/media/pci/bt8xx/bttv-cards.c +1
-1@@ -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 drivers/media/pci/bt8xx/bttv-driver.c +6
-6@@ -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); } }drivers/media/pci/bt8xx/bttvp.h +1
-1@@ -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;
RFC PATCH 5/10 bttv: separate GPIO part from function audio_mux()
In reply to Frank SchäferMove 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.
--- drivers/media/pci/bt8xx/bttv-driver.c | 18 ++++++++++++------
1 Datei geändert, 12 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-)
drivers/media/pci/bt8xx/bttv-driver.c +12 -6
@@ -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,",
Signature · 1 line
1.7.10.4
Re: [RFC PATCH 05/10] bttv: separate GPIO part from function audio_mux()
Quoted 4 lines · On Wed 20 March 2013 20:24:45 Frank Schäfer wrote:
Move the GPIO part of function
audio_mux()to a separate functionaudio_mux_gpio().
This prepares the code for the next patch which will separate mute and input setting.
Regards,
Hans
Quoted 51 lines
Signed-off-by Frank Schäfer <[email protected]>--- drivers/media/pci/bt8xx/bttv-driver.c | 18 ++++++++++++------1 Datei geändert, 12 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-)
drivers/media/pci/bt8xx/bttv-driver.c +12
-6@@ -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,",
RFC PATCH 6/10 bttv: untangle audio input and mute setting
In reply to Frank SchäferSplit function audio_mux():
move the mute setting part to function audio_mute() and the input setting part to function audio_input().
--- drivers/media/pci/bt8xx/bttv-driver.c | 51 ++++++++++++++++-----------------
1 Datei geändert, 24 Zeilen hinzugefügt(+), 27 Zeilen entfernt(-)
drivers/media/pci/bt8xx/bttv-driver.c +24 -27
@@ -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) {
Signature · 1 line
1.7.10.4
Re: [RFC PATCH 06/10] bttv: untangle audio input and mute setting
Quoted 3 lines · On Wed 20 March 2013 20:24:46 Frank Schäfer wrote:
Split function
audio_mux():
move the mute setting part to functionaudio_mute()and the input setting part to functionaudio_input().
Regards,
Hans
Quoted 88 lines
Signed-off-by Frank Schäfer <[email protected]>--- drivers/media/pci/bt8xx/bttv-driver.c | 51 ++++++++++++++++-----------------1 Datei geändert, 24 Zeilen hinzugefügt(+), 27 Zeilen entfernt(-)
drivers/media/pci/bt8xx/bttv-driver.c +24
-27@@ -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) {
RFC PATCH 7/10 bttv: do not unmute the device before the first open
In reply to Frank Schäfer--- drivers/media/pci/bt8xx/bttv-driver.c | 4 +++-
1 Datei geändert, 3 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)
drivers/media/pci/bt8xx/bttv-driver.c +3 -1
@@ -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,
Signature · 1 line
1.7.10.4
Re: [RFC PATCH 07/10] bttv: do not unmute the device before the first open
On Wed 20 March 2013 20:24:47 Frank Schäfer wrote:
Regards,
Hans
Quoted 25 lines
Signed-off-by Frank Schäfer <[email protected]>--- drivers/media/pci/bt8xx/bttv-driver.c | 4 +++-1 Datei geändert, 3 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)
drivers/media/pci/bt8xx/bttv-driver.c +3
-1@@ -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,
RFC PATCH 8/10 bttv: apply mute settings on open
In reply to Frank SchäferPreviously, 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.
--- drivers/media/pci/bt8xx/bttv-driver.c | 3 ++-
1 Datei geändert, 2 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)
drivers/media/pci/bt8xx/bttv-driver.c +2 -1
@@ -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);
Signature · 1 line
1.7.10.4
Re: [RFC PATCH 08/10] bttv: apply mute settings on open
Quoted 6 lines · 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 callsaudio_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 toaudio_mute().
Also apply the mute setting when the radio device node gets opened.
Regards,
Hans
Quoted 27 lines
Signed-off-by Frank Schäfer <[email protected]>--- drivers/media/pci/bt8xx/bttv-driver.c | 3 ++-1 Datei geändert, 2 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)
drivers/media/pci/bt8xx/bttv-driver.c +2
-1@@ -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);
RFC PATCH 9/10 bttv: fix mute on last close of the video device node
In reply to Frank SchäferInstead of applying the current mute setting on last device node close, always mute the device.
--- drivers/media/pci/bt8xx/bttv-driver.c | 2 +-
1 Datei geändert, 1 Zeile hinzugefügt(+), 1 Zeile entfernt(-)
drivers/media/pci/bt8xx/bttv-driver.c +1 -1
@@ -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);
Signature · 1 line
1.7.10.4
Re: [RFC PATCH 09/10] bttv: fix mute on last close of the video device node
Quoted 2 lines · 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
Quoted 19 lines
Signed-off-by Frank Schäfer <[email protected]>--- drivers/media/pci/bt8xx/bttv-driver.c | 2 +-1 Datei geändert, 1 Zeile hinzugefügt(+), 1 Zeile entfernt(-)
drivers/media/pci/bt8xx/bttv-driver.c +1
-1@@ -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);
Re: [RFC PATCH 09/10] bttv: fix mute on last close of the video device node
Am 21.03.2013 11:56, schrieb Hans Verkuil:
Quoted 7 lines · On Wed 20 March 2013 20:24:49 Frank Schäfer wrote:
Quoted 2 lines
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. ;)
Quoted 3 lines
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 !
Quoted 3 lines
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
Quoted 23 lines
Regards,
Hans
Quoted 19 lines
Signed-off-by Frank Schäfer <[email protected]>--- drivers/media/pci/bt8xx/bttv-driver.c | 2 +-1 Datei geändert, 1 Zeile hinzugefügt(+), 1 Zeile entfernt(-)
drivers/media/pci/bt8xx/bttv-driver.c +1
-1@@ -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);
RFC PATCH 10/10 bttv: avoid mute on last close when the radio device node is still open
In reply to Frank SchäferIn 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.
--- drivers/media/pci/bt8xx/bttv-driver.c | 5 ++++-
1 Datei geändert, 4 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)
drivers/media/pci/bt8xx/bttv-driver.c +4 -1
@@ -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);
Signature · 1 line
1.7.10.4