[alsa-devel] [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.
Signed-off-by: Lydia Wang lydiawang@viatech.com.cn
Index: sound-2.6/sound/pci/hda/patch_via.c =================================================================== --- sound-2.6.orig/sound/pci/hda/patch_via.c 2009-10-05 15:09:18.000000000 +0800 +++ sound-2.6/sound/pci/hda/patch_via.c 2009-10-05 15:09:33.000000000 +0800 @@ -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, Li Bo wrote:
[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 lydiawang@viatech.com.cn @@ -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 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.
On Mon, Oct 5, 2009 at 11:04 PM, Takashi Iwai tiwai@suse.de wrote:
At Mon, 5 Oct 2009 22:25:15 +0800, Li Bo wrote:
[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 lydiawang@viatech.com.cn @@ -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, Li Bo wrote:
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 :)
And, the activation/deactivation can be done on the fly, so it's no more "one-shot" action (if implemented properly).
Takashi
On Mon, Oct 5, 2009 at 11:04 PM, Takashi Iwai tiwai@suse.de wrote:
At Mon, 5 Oct 2009 22:25:15 +0800, Li Bo wrote:
[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 lydiawang@viatech.com.cn @@ -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

On Tue, Oct 6, 2009 at 1:47 PM, Takashi Iwai tiwai@suse.de wrote:
At Tue, 6 Oct 2009 12:44:28 +0800, Li Bo wrote:
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:)
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!
On Mon, Oct 5, 2009 at 11:04 PM, Takashi Iwai tiwai@suse.de wrote:
At Mon, 5 Oct 2009 22:25:15 +0800, Li Bo wrote:
[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 lydiawang@viatech.com.cn @@ -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

On Tue, Oct 6, 2009 at 11:55 PM, Li Bo liboat@gmail.com wrote:
On Tue, Oct 6, 2009 at 1:47 PM, Takashi Iwai tiwai@suse.de wrote:
At Tue, 6 Oct 2009 12:44:28 +0800, Li Bo wrote:
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:)
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!
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.
On Mon, Oct 5, 2009 at 11:04 PM, Takashi Iwai tiwai@suse.de wrote:
At Mon, 5 Oct 2009 22:25:15 +0800, Li Bo wrote:
[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 lydiawang@viatech.com.cn @@ -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, Li Bo wrote:
On Tue, Oct 6, 2009 at 11:55 PM, Li Bo liboat@gmail.com wrote:
On Tue, Oct 6, 2009 at 1:47 PM, Takashi Iwai tiwai@suse.de wrote:
At Tue, 6 Oct 2009 12:44:28 +0800, Li Bo wrote:
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:)
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!
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.
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

On Wed, Oct 7, 2009 at 2:03 AM, Takashi Iwai tiwai@suse.de wrote:
At Wed, 7 Oct 2009 01:42:50 +0800, Li Bo wrote:
On Tue, Oct 6, 2009 at 11:55 PM, Li Bo liboat@gmail.com wrote:
On Tue, Oct 6, 2009 at 1:47 PM, Takashi Iwai tiwai@suse.de wrote:
At Tue, 6 Oct 2009 12:44:28 +0800, Li Bo wrote:
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:)
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!
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.
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, Li Bo wrote:
On Wed, Oct 7, 2009 at 2:03 AM, Takashi Iwai tiwai@suse.de wrote:
At Wed, 7 Oct 2009 01:42:50 +0800, Li Bo wrote:
On Tue, Oct 6, 2009 at 11:55 PM, Li Bo liboat@gmail.com wrote:
On Tue, Oct 6, 2009 at 1:47 PM, Takashi Iwai tiwai@suse.de wrote:
At Tue, 6 Oct 2009 12:44:28 +0800, Li Bo wrote:
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:)
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!
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.
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
Hm, strange. Are you sure that it's notified?
- 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).
Maybe we have to backward to snd_ctl_remove implementation.
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

On Wed, Oct 7, 2009 at 2:59 PM, Takashi Iwai tiwai@suse.de wrote:
At Wed, 7 Oct 2009 14:01:51 +0800, Li Bo wrote:
On Wed, Oct 7, 2009 at 2:03 AM, Takashi Iwai tiwai@suse.de wrote:
At Wed, 7 Oct 2009 01:42:50 +0800, Li Bo wrote:
On Tue, Oct 6, 2009 at 11:55 PM, Li Bo liboat@gmail.com wrote:
On Tue, Oct 6, 2009 at 1:47 PM, Takashi Iwai tiwai@suse.de wrote:
At Tue, 6 Oct 2009 12:44:28 +0800, Li Bo wrote: > > 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:)
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!
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.
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
Hm, strange. Are you sure that it's notified?
- 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).
Maybe we have to backward to snd_ctl_remove implementation.
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
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.
Signed-off-by: Lydia Wang lydiawang@viatech.com.cn
--- sound/pci/hda/patch_via.c | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-)
--- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -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; }
participants (2)
-
Li Bo
-
Takashi Iwai