HDA patch_via.c: Change VT1708S & VT1702 hp mode controls
PATCH 8/31 HDA patch_via.c: Change VT1708S & VT1702 hp mode controls
[ALSA] HDA VIA: Change VT1708S & VT1702 hp mode controls
For VT1708S and VT1702, deactivate "Headphone Playback Volume" and "Headphone Playback Mute" control if "Independent HP" mode is OFF. and rename VT1702 "Independent HP" text.
sound/pci/hda/patch_via.c +34 -5
@@ -566,9 +566,26 @@unsigned int pinsel =snd_hda_codec_read (codec, nid,0 ,AC_VERB_GET_CONNECT_SEL ,0x00 ); +static int hp_ctl_initialized =-1 ; ucontrol->value.enumerated.item[0 ] = pinsel; - +/* update HP controls on first time */ +if ((spec->codec_type ==VT1708S + || spec->codec_type ==VT1702 ) + && hp_ctl_initialized ==-1 ) { +struct snd_card *card = codec->bus->card; +struct snd_kcontrol *kctl; +/* deactive hp volume & switch in independent mode */ +list_for_each_entry (kctl, &card->controls, list) +if (spec->hp_independent_mode + && (strcmp (kctl->id.name, +"Headphone Playback Volume" ) ==0 + ||strcmp (kctl->id.name, +"Headphone Playback Switch" ) ==0 )) + kctl->vd[0 ].access |= +SNDRV_CTL_ELEM_ACCESS_INACTIVE ; + hp_ctl_initialized =1 ; + }return 0 ; }
@@ -3342,11 +3359,13 @@static int vt1702_auto_create_hp_ctls (struct via_spec *spec,hda_nid_t pin) { -int err; - +int err, i; +struct hda_input_mux *imux; +static const char *texts[] = {"ON (need reboot)" , +"OFF (need reboot)" , +NULL };if (!pin)return 0 ; - spec->multiout.hp_nid =0x1D ; err = via_add_control(spec, VIA_CTL_WIDGET_VOL,
@@ -3361,8 +3380,18 @@if (err <0 )return err; -create_hp_imux (spec); + imux = &spec->private_imux[1 ]; +/* for hp mode select */ + i =0 ; +while (texts[i] !=NULL ) { + imux->items[imux->num_items].label = texts[i]; + imux->items[imux->num_items].index = i; + imux->num_items++; + i++; + } + + spec->hp_mux = &spec->private_imux[1 ];return 0 ; }
At Mon, 5 Oct 2009 22:25:15 +0800,
Quoted 9 lines · Li Bo
[ALSA] HDA VIA: Change VT1708S & VT1702 hp mode controls
For VT1708S and VT1702, deactivate "Headphone Playback Volume" and "Headphone Playback Mute" control if "Independent HP" mode is OFF. and rename VT1702 "Independent HP" text.
Signed-off-by Lydia Wang <[email protected]>
sound/pci/hda/patch_via.c line 3366
Quoted 10 lines
sound/pci/hda/patch_via.c +5
-2@@ -3342,11 +3359,13 @@static int vt1702_auto_create_hp_ctls (struct via_spec *spec,hda_nid_t pin) { -int err; - +int err, i; +struct hda_input_mux *imux; +static const char *texts[] = {"ON (need reboot)" , +"OFF (need reboot)" , +NULL };
These texts look very strange...
Takashi
Hi, Takashi
When independent hp switches from
on -> off: hp volume/switch is deactivated
off -> hp volume switch is activatedThese 2 actions are one-shot setup, so we put "need reboot" to remind user that hp volume/switch update will only take effect after reboot.
Quoted 27 lines · Takashi Iwai
At Mon, 5 Oct 2009 22:25:15 +0800,
Quoted 9 lines · Li Bo
[ALSA] HDA VIA: Change VT1708S & VT1702 hp mode controls
For VT1708S and VT1702, deactivate "Headphone Playback Volume" and "Headphone Playback Mute" control if "Independent HP" mode is OFF. and rename VT1702 "Independent HP" text.
Signed-off-by Lydia Wang <[email protected]>sound/pci/hda/patch_via.c line 3366
Quoted 10 lines
sound/pci/hda/patch_via.c +5
-2@@ -3342,11 +3359,13 @@ static int vt1702_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) { - int err; - + int err, i; + struct hda_input_mux *imux; + static const char *texts[] = { "ON (need reboot)", + "OFF (need reboot)", + NULL};These texts look very strange...
Takashi
At Tue, 6 Oct 2009 12:44:28 +0800,
Quoted 7 lines · Li Bo
Hi, Takashi
When independent hp switches fromon -> off: hp volume/switch is deactivated off -> hp volume switch is activatedThese 2 actions are one-shot setup, so we put "need reboot" to remind user that hp volume/switch update will only take effect after reboot.
First off, you don't have to "reboot" at all :)
And, the activation/deactivation can be done on the fly, so it's no more "one-shot" action (if implemented properly).
Takashi
Quoted 27 lines · Takashi Iwai
Quoted 25 lines
At Mon, 5 Oct 2009 22:25:15 +0800,
Quoted 9 lines · Li Bo
[ALSA] HDA VIA: Change VT1708S & VT1702 hp mode controls
For VT1708S and VT1702, deactivate "Headphone Playback Volume" and "Headphone Playback Mute" control if "Independent HP" mode is OFF. and rename VT1702 "Independent HP" text.
Signed-off-by Lydia Wang <[email protected]>sound/pci/hda/patch_via.c line 3366
Quoted 10 lines
sound/pci/hda/patch_via.c +5
-2@@ -3342,11 +3359,13 @@ static int vt1702_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) { - int err; - + int err, i; + struct hda_input_mux *imux; + static const char *texts[] = { "ON (need reboot)", + "OFF (need reboot)", + NULL};These texts look very strange...
Quoted 3 lines
Quoted 2 lines
Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 12 lines · Takashi Iwai
At Tue, 6 Oct 2009 12:44:28 +0800,
Quoted 7 lines · Li Bo
Hi, Takashi
When independent hp switches from
on -> off: hp volume/switch is deactivated
off -> hp volume switch is activated
These 2 actions are one-shot setup, so we put "need reboot" to remind user that hp volume/switch update will only take effect after reboot.First off, you don't have to "reboot" at all :)
I also want to kick that "reboot" off:)
Quoted 6 lines
And, the activation/deactivation can be done on the fly, so it's no more "one-shot" action (if implemented properly).
Takashi
You mean just act/deact on via_independent_hp_put? I'll try and update this, thank you!
Quoted 31 lines
Quoted 30 lines · Takashi Iwai
Quoted 27 lines
At Mon, 5 Oct 2009 22:25:15 +0800,
Quoted 9 lines · Li Bo
[ALSA] HDA VIA: Change VT1708S & VT1702 hp mode controls
For VT1708S and VT1702, deactivate "Headphone Playback Volume" and "Headphone Playback Mute" control if "Independent HP" mode is OFF. and rename VT1702 "Independent HP" text.
Signed-off-by Lydia Wang <[email protected]>sound/pci/hda/patch_via.c line 3366
Quoted 10 lines
sound/pci/hda/patch_via.c +5
-2@@ -3342,11 +3359,13 @@ static int vt1702_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) { - int err; - + int err, i; + struct hda_input_mux *imux; + static const char *texts[] = { "ON (need reboot)", + "OFF (need reboot)", + NULL};These texts look very strange...
Takashi
Quoted 20 lines · Li Bo
Quoted 12 lines · Takashi Iwai
At Tue, 6 Oct 2009 12:44:28 +0800,
Quoted 7 lines · Li Bo
Hi, Takashi
When independent hp switches from
on -> off: hp volume/switch is deactivated
off -> hp volume switch is activated
These 2 actions are one-shot setup, so we put "need reboot" to remind user that hp volume/switch update will only take effect after reboot.First off, you don't have to "reboot" at all :)
I also want to kick that "reboot" off:)
Quoted 4 lines
And, the activation/deactivation can be done on the fly, so it's no more "one-shot" action (if implemented properly).
Quoted 6 lines
Quoted 2 lines
Takashi
You mean just act/deact on
via_independent_hp_put? I'll try and update this, thank you!
Sorry I don't know how to activate/deactivate on the fly. I toggle access' SNDRV_CTL_ELEM_ACCESS_INACTIVE bit in via_independent_hp_put, but in alsamixer it cannot reflect the change unless restart it. Please give some help.
Quoted 32 lines
Quoted 31 lines
Quoted 30 lines · Takashi Iwai
Quoted 27 lines
At Mon, 5 Oct 2009 22:25:15 +0800,
Quoted 9 lines · Li Bo
[ALSA] HDA VIA: Change VT1708S & VT1702 hp mode controls
For VT1708S and VT1702, deactivate "Headphone Playback Volume" and "Headphone Playback Mute" control if "Independent HP" mode is OFF. and rename VT1702 "Independent HP" text.
Signed-off-by Lydia Wang <[email protected]>sound/pci/hda/patch_via.c line 3366
Quoted 10 lines
sound/pci/hda/patch_via.c +5
-2@@ -3342,11 +3359,13 @@ static int vt1702_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) { - int err; - + int err, i; + struct hda_input_mux *imux; + static const char *texts[] = { "ON (need reboot)", + "OFF (need reboot)", + NULL};These texts look very strange...
Takashi
At Wed, 7 Oct 2009 01:42:50 +0800,
Quoted 25 lines · Li Bo
Quoted 23 lines · Li Bo
Quoted 12 lines · Takashi Iwai
At Tue, 6 Oct 2009 12:44:28 +0800,
Quoted 7 lines · Li Bo
Hi, Takashi
When independent hp switches from
on -> off: hp volume/switch is deactivated
off -> hp volume switch is activated
These 2 actions are one-shot setup, so we put "need reboot" to remind user that hp volume/switch update will only take effect after reboot.First off, you don't have to "reboot" at all :)
I also want to kick that "reboot" off:)
Quoted 6 lines
And, the activation/deactivation can be done on the fly, so it's no more "one-shot" action (if implemented properly).
Takashi
Quoted 7 lines
Quoted 3 lines
You mean just act/deact on
via_independent_hp_put? I'll try and update this, thank you!Sorry I don't know how to activate/deactivate on the fly. I toggle access'
SNDRV_CTL_ELEM_ACCESS_INACTIVEbit invia_independent_hp_put, but in alsamixer it cannot reflect the change unless restart it. Please give some help.
You simply need to notify the control elements you changed via snd_ctl_notify().
Then the mixer app will update the status as well.
Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 35 lines · Takashi Iwai
At Wed, 7 Oct 2009 01:42:50 +0800,
Quoted 25 lines · Li Bo
Quoted 23 lines · Li Bo
Quoted 12 lines · Takashi Iwai
At Tue, 6 Oct 2009 12:44:28 +0800,
Quoted 7 lines · Li Bo
Hi, Takashi
When independent hp switches from
on -> off: hp volume/switch is deactivated
off -> hp volume switch is activated
These 2 actions are one-shot setup, so we put "need reboot" to remind user that hp volume/switch update will only take effect after reboot.First off, you don't have to "reboot" at all :)
I also want to kick that "reboot" off:)
Quoted 6 lines
And, the activation/deactivation can be done on the fly, so it's no more "one-shot" action (if implemented properly).
Takashi
Quoted 7 lines
Quoted 3 lines
You mean just act/deact on
via_independent_hp_put? I'll try and update this, thank you!Sorry I don't know how to activate/deactivate on the fly. I toggle access'
SNDRV_CTL_ELEM_ACCESS_INACTIVEbit invia_independent_hp_put, but in alsamixer it cannot reflect the change unless restart it. Please give some help.
Quoted 7 lines
You simply need to notify the control elements you changed via
snd_ctl_notify().
Then the mixer app will update the status as well.Takashi
I add snd_ctl_notify after access update, but test with results that:
- alsamixer (v1.0.21) will gray/de-grayed the control only after
restart the application
- gnome-volume-control will just ignore the access bit and display
the control as usual.
Maybe we have to backward to snd_ctl_remove implementation.
At Wed, 7 Oct 2009 14:01:51 +0800,
Quoted 42 lines · Li Bo
Quoted 40 lines · Takashi Iwai
At Wed, 7 Oct 2009 01:42:50 +0800,
Quoted 25 lines · Li Bo
Quoted 23 lines · Li Bo
Quoted 12 lines · Takashi Iwai
At Tue, 6 Oct 2009 12:44:28 +0800,
Quoted 7 lines · Li Bo
Hi, Takashi
When independent hp switches from
on -> off: hp volume/switch is deactivated
off -> hp volume switch is activated
These 2 actions are one-shot setup, so we put "need reboot" to remind user that hp volume/switch update will only take effect after reboot.First off, you don't have to "reboot" at all :)
I also want to kick that "reboot" off:)
Quoted 6 lines
And, the activation/deactivation can be done on the fly, so it's no more "one-shot" action (if implemented properly).
Takashi
Quoted 7 lines
Quoted 3 lines
You mean just act/deact on
via_independent_hp_put? I'll try and update this, thank you!Sorry I don't know how to activate/deactivate on the fly. I toggle access'
SNDRV_CTL_ELEM_ACCESS_INACTIVEbit invia_independent_hp_put, but in alsamixer it cannot reflect the change unless restart it. Please give some help.You simply need to notify the control elements you changed via
snd_ctl_notify().
Then the mixer app will update the status as well.
Quoted 6 lines
Quoted 2 lines
Takashi
I add
snd_ctl_notifyafter access update, but test with results that:
- alsamixer (v1.0.21) will gray/de-grayed the control only after
restart the application
Hm, strange. Are you sure that it's notified?
Quoted 2 lines
- gnome-volume-control will just ignore the access bit and display
the control as usual.
Then it's a bug of gnome-volume-control (maybe in gstreamer).
Quoted 1 line
Maybe we have to backward to
snd_ctl_removeimplementation.
No, removing is a really bad interface. If the control notification is done properly, it's just a matter of application side.
When the control is inactive, you can't change the value, so it's anyway safe in the driver perspective.
thanks,
Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 63 lines · Takashi Iwai
At Wed, 7 Oct 2009 14:01:51 +0800,
Quoted 42 lines · Li Bo
Quoted 40 lines · Takashi Iwai
At Wed, 7 Oct 2009 01:42:50 +0800,
Quoted 25 lines · Li Bo
Quoted 23 lines · Li Bo
Quoted 12 lines · Takashi Iwai
At Tue, 6 Oct 2009 12:44:28 +0800,
Quoted 7 lines · Li Bo
Hi, Takashi
When independent hp switches from
on -> off: hp volume/switch is deactivated
off -> hp volume switch is activated
These 2 actions are one-shot setup, so we put "need reboot" to remind user that hp volume/switch update will only take effect after reboot.First off, you don't have to "reboot" at all :)
I also want to kick that "reboot" off:)
Quoted 6 lines
And, the activation/deactivation can be done on the fly, so it's no more "one-shot" action (if implemented properly).
Takashi
Quoted 7 lines
Quoted 3 lines
You mean just act/deact on
via_independent_hp_put? I'll try and update this, thank you!Sorry I don't know how to activate/deactivate on the fly. I toggle access'
SNDRV_CTL_ELEM_ACCESS_INACTIVEbit invia_independent_hp_put, but in alsamixer it cannot reflect the change unless restart it. Please give some help.You simply need to notify the control elements you changed via
snd_ctl_notify().
Then the mixer app will update the status as well.Quoted 6 lines
Quoted 2 lines
Takashi
I add
snd_ctl_notifyafter access update, but test with results that:
- alsamixer (v1.0.21) will gray/de-grayed the control only after restart the applicationHm, strange. Are you sure that it's notified?
Quoted 2 lines
- gnome-volume-control will just ignore the access bit and display the control as usual.
Then it's a bug of gnome-volume-control (maybe in gstreamer).
Quoted 1 line
Maybe we have to backward to
snd_ctl_removeimplementation.No, removing is a really bad interface. If the control notification is done properly, it's just a matter of application side.
Quoted 8 lines
When the control is inactive, you can't change the value, so it's anyway safe in the driver perspective.
thanks,
Takashi
OK, I'll remove "need reboot" text and update access bit on the run. Following will be update patch
[ALSA] HDA VIA: Change VT1708S & VT1702 hp mode controls
For VT1708S and VT1702, deactivate "Headphone Playback Volume" and "Headphone Playback Mute" control if "Independent HP" mode is OFF. and rename VT1702 "Independent HP" text.
--- sound/pci/hda/patch_via.c | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-)
sound/pci/hda/patch_via.c +34 -4
@@ -572,6 +572,18 @@return 0 ; } +static void activate_ctl (struct hda_codec *codec,const char *name,int active) +{ +struct snd_kcontrol *ctl =snd_hda_find_mixer_ctl (codec, name); +if (ctl) { + ctl->vd[0 ].access &=SNDRV_CTL_ELEM_ACCESS_INACTIVE ; + ctl->vd[0 ].access |= active + ?0 :SNDRV_CTL_ELEM_ACCESS_INACTIVE ; +snd_ctl_notify (codec->bus->card, +SNDRV_CTL_EVENT_MASK_VALUE , &ctl->id); + } +} +static int via_independent_hp_put (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {
@@ -620,6 +632,14 @@ spec->multiout.hp_nid, 0, 0, 0); +/* update HP volume/swtich active state */ +if (spec->codec_type ==VT1708S + || spec->codec_type ==VT1702 ) { +activate_ctl (codec,"Headphone Playback Volume" , + spec->hp_independent_mode); +activate_ctl (codec,"Headphone Playback Switch" , + spec->hp_independent_mode); + }return 0 ; }
@@ -3342,11 +3362,11 @@static int vt1702_auto_create_hp_ctls (struct via_spec *spec,hda_nid_t pin) { -int err; - +int err, i; +struct hda_input_mux *imux; +static const char *texts[] = {"ON" ,"OFF" ,NULL };if (!pin)return 0 ; - spec->multiout.hp_nid =0x1D ; err = via_add_control(spec, VIA_CTL_WIDGET_VOL,
@@ -3361,8 +3381,18 @@if (err <0 )return err; -create_hp_imux (spec); + imux = &spec->private_imux[1 ]; +/* for hp mode select */ + i =0 ; +while (texts[i] !=NULL ) { + imux->items[imux->num_items].label = texts[i]; + imux->items[imux->num_items].index = i; + imux->num_items++; + i++; + } + + spec->hp_mux = &spec->private_imux[1 ];return 0 ; }