[alsa-devel] [PATCH 5/6] ESI W192M : Add text Line in/Mic for selecting input gain state
From: Clément Guedez klem.dev@gmail.com
Add text Line in/Mic for selecting input gain state in mixer for ESI W192M.
Signed-off-by: Clément Guedez klem.dev@gmail.com
diff --git a/sound/pci/ice1712/wtm.c b/sound/pci/ice1712/wtm.c index c7ffafa..a6e7afa 100644 --- a/sound/pci/ice1712/wtm.c +++ b/sound/pci/ice1712/wtm.c @@ -339,8 +339,14 @@ static int stac9460_adc_vol_put(struct snd_kcontrol *kcontrol, /* * MIC / LINE switch fonction */ +static int stac9460_mic_sw_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + static const char * const texts[2] = { "Line In", "Mic" }; + + return snd_ctl_enum_info(uinfo, 1, 2, texts); +}
-#define stac9460_mic_sw_info snd_ctl_boolean_mono_info
static int stac9460_mic_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) @@ -354,7 +360,7 @@ static int stac9460_mic_sw_get(struct snd_kcontrol *kcontrol, val = stac9460_get(ice, STAC946X_GENERAL_PURPOSE); else val = stac9460_2_get(ice, STAC946X_GENERAL_PURPOSE); - ucontrol->value.integer.value[0] = ~val>>7 & 0x1; + ucontrol->value.enumerated.item[0] = (val >> 7) & 0x1; return 0; }
@@ -370,7 +376,7 @@ static int stac9460_mic_sw_put(struct snd_kcontrol *kcontrol, old = stac9460_get(ice, STAC946X_GENERAL_PURPOSE); else old = stac9460_2_get(ice, STAC946X_GENERAL_PURPOSE); - new = (~ucontrol->value.integer.value[0] << 7 & 0x80) | (old & ~0x80); + new = (ucontrol->value.enumerated.item[0] << 7 & 0x80) | (old & ~0x80); change = (new != old); if (change) { if (id == 0)
At Mon, 16 Mar 2015 01:20:54 +0100, klem.dev@gmail.com wrote:
From: Clément Guedez klem.dev@gmail.com
Add text Line in/Mic for selecting input gain state in mixer for ESI W192M.
What I meant is to change control name "Line Switch" to a different suffix (oh, anyway there is a typo in the original code, it's written as "switch", not "Switch"...)
The type of control element is identified by a string name rule in some levels. When a control is named as "XXX Switch", it's taken as a boolean control. For enum control, we usually take "Enum" suffix so that alsa-lib simple mixer interface can recognize it as an enumerated control.
(Hm, it's not mentioned in Documentation/sound/alsa/ControlNames.txt. An update is needed...)
Takashi
Signed-off-by: Clément Guedez klem.dev@gmail.com
diff --git a/sound/pci/ice1712/wtm.c b/sound/pci/ice1712/wtm.c index c7ffafa..a6e7afa 100644 --- a/sound/pci/ice1712/wtm.c +++ b/sound/pci/ice1712/wtm.c @@ -339,8 +339,14 @@ static int stac9460_adc_vol_put(struct snd_kcontrol *kcontrol, /*
- MIC / LINE switch fonction
*/ +static int stac9460_mic_sw_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
+{
- static const char * const texts[2] = { "Line In", "Mic" };
- return snd_ctl_enum_info(uinfo, 1, 2, texts);
+}
-#define stac9460_mic_sw_info snd_ctl_boolean_mono_info
static int stac9460_mic_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) @@ -354,7 +360,7 @@ static int stac9460_mic_sw_get(struct snd_kcontrol *kcontrol, val = stac9460_get(ice, STAC946X_GENERAL_PURPOSE); else val = stac9460_2_get(ice, STAC946X_GENERAL_PURPOSE);
- ucontrol->value.integer.value[0] = ~val>>7 & 0x1;
- ucontrol->value.enumerated.item[0] = (val >> 7) & 0x1; return 0;
}
@@ -370,7 +376,7 @@ static int stac9460_mic_sw_put(struct snd_kcontrol *kcontrol, old = stac9460_get(ice, STAC946X_GENERAL_PURPOSE); else old = stac9460_2_get(ice, STAC946X_GENERAL_PURPOSE);
- new = (~ucontrol->value.integer.value[0] << 7 & 0x80) | (old & ~0x80);
- new = (ucontrol->value.enumerated.item[0] << 7 & 0x80) | (old & ~0x80); change = (new != old); if (change) { if (id == 0)
-- 2.1.4
Ok, I was not aware of this mechanism.
In fact this is a boolean control to activate the input gain amplifier for microphone signal or to deactivate it for standard line signal. I use the enum to have choice value more explicit than on/off or true/false, for the end user. Also there will never be more value than those two.
So I chould change the control name to "Mic/Line Input Enum" and keep the enum for values, more than name it "Input Gain Switch" and use boolean ?
Thanks
2015-03-16 8:51 GMT+01:00 Takashi Iwai tiwai@suse.de:
At Mon, 16 Mar 2015 01:20:54 +0100, klem.dev@gmail.com wrote:
From: Clément Guedez klem.dev@gmail.com
Add text Line in/Mic for selecting input gain state in mixer for ESI
W192M.
What I meant is to change control name "Line Switch" to a different suffix (oh, anyway there is a typo in the original code, it's written as "switch", not "Switch"...)
The type of control element is identified by a string name rule in some levels. When a control is named as "XXX Switch", it's taken as a boolean control. For enum control, we usually take "Enum" suffix so that alsa-lib simple mixer interface can recognize it as an enumerated control.
(Hm, it's not mentioned in Documentation/sound/alsa/ControlNames.txt. An update is needed...)
Takashi
Signed-off-by: Clément Guedez klem.dev@gmail.com
diff --git a/sound/pci/ice1712/wtm.c b/sound/pci/ice1712/wtm.c index c7ffafa..a6e7afa 100644 --- a/sound/pci/ice1712/wtm.c +++ b/sound/pci/ice1712/wtm.c @@ -339,8 +339,14 @@ static int stac9460_adc_vol_put(struct snd_kcontrol
*kcontrol,
/*
- MIC / LINE switch fonction
*/ +static int stac9460_mic_sw_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
+{
static const char * const texts[2] = { "Line In", "Mic" };
return snd_ctl_enum_info(uinfo, 1, 2, texts);
+}
-#define stac9460_mic_sw_info snd_ctl_boolean_mono_info
static int stac9460_mic_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) @@ -354,7 +360,7 @@ static int stac9460_mic_sw_get(struct snd_kcontrol
*kcontrol,
val = stac9460_get(ice, STAC946X_GENERAL_PURPOSE); else val = stac9460_2_get(ice, STAC946X_GENERAL_PURPOSE);
ucontrol->value.integer.value[0] = ~val>>7 & 0x1;
ucontrol->value.enumerated.item[0] = (val >> 7) & 0x1; return 0;
}
@@ -370,7 +376,7 @@ static int stac9460_mic_sw_put(struct snd_kcontrol
*kcontrol,
old = stac9460_get(ice, STAC946X_GENERAL_PURPOSE); else old = stac9460_2_get(ice, STAC946X_GENERAL_PURPOSE);
new = (~ucontrol->value.integer.value[0] << 7 & 0x80) | (old &
~0x80);
new = (ucontrol->value.enumerated.item[0] << 7 & 0x80) | (old &
~0x80);
change = (new != old); if (change) { if (id == 0)
-- 2.1.4
At Mon, 16 Mar 2015 15:54:43 +0100, Clément Guedez wrote:
Ok, I was not aware of this mechanism.
In fact this is a boolean control to activate the input gain amplifier for microphone signal or to deactivate it for standard line signal. I use the enum to have choice value more explicit than on/off or true/false, for the end user. Also there will never be more value than those two.
So I chould change the control name to "Mic/Line Input Enum" and keep the enum for values, more than name it "Input Gain Switch" and use boolean ?
Right.
Takashi
participants (3)
-
Clément Guedez
-
klem.dev@gmail.com
-
Takashi Iwai