Skip to content

Commit c647f80

Browse files
committed
ALSA: hda - Allow multiple ADCs for mic mute LED controls
Instead of refusing, allow the configuration with the multiple ADCs (thus multiple capture switches) for enabling the mic mute LED. This has been done for Sigmatel/IDT codecs, and we treat the OR-ed values from all capture switches as the boolean condition. Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 184e302 commit c647f80

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

sound/pci/hda/hda_generic.c

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3922,7 +3922,7 @@ static void call_micmute_led_update(struct hda_codec *codec)
39223922
val = 0;
39233923
break;
39243924
case MICMUTE_LED_FOLLOW_CAPTURE:
3925-
val = spec->micmute_led.capture;
3925+
val = !!spec->micmute_led.capture;
39263926
break;
39273927
case MICMUTE_LED_FOLLOW_MUTE:
39283928
default:
@@ -3942,17 +3942,21 @@ static void update_micmute_led(struct hda_codec *codec,
39423942
struct snd_ctl_elem_value *ucontrol)
39433943
{
39443944
struct hda_gen_spec *spec = codec->spec;
3945+
unsigned int mask;
39453946

39463947
if (spec->micmute_led.old_hook)
39473948
spec->micmute_led.old_hook(codec, kcontrol, ucontrol);
39483949

39493950
if (!ucontrol)
39503951
return;
3951-
if (!strcmp("Capture Switch", ucontrol->id.name) &&
3952-
!ucontrol->id.index) {
3952+
mask = 1U << snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
3953+
if (!strcmp("Capture Switch", ucontrol->id.name)) {
39533954
/* TODO: How do I verify if it's a mono or stereo here? */
3954-
spec->micmute_led.capture = (ucontrol->value.integer.value[0] ||
3955-
ucontrol->value.integer.value[1]);
3955+
if (ucontrol->value.integer.value[0] ||
3956+
ucontrol->value.integer.value[1])
3957+
spec->micmute_led.capture |= mask;
3958+
else
3959+
spec->micmute_led.capture &= ~mask;
39563960
call_micmute_led_update(codec);
39573961
}
39583962
}
@@ -4008,25 +4012,17 @@ static const struct snd_kcontrol_new micmute_led_mode_ctl = {
40084012
* @hook: the callback for updating LED
40094013
*
40104014
* Called from the codec drivers for offering the mic mute LED controls.
4011-
* Only valid for a single ADC (or a single input). When established, it
4012-
* sets up cap_sync_hook and triggers the callback at each time when the
4013-
* capture mixer switch changes. The callback is supposed to update the LED
4014-
* accordingly.
4015+
* When established, it sets up cap_sync_hook and triggers the callback at
4016+
* each time when the capture mixer switch changes. The callback is supposed
4017+
* to update the LED accordingly.
40154018
*
4016-
* Returns 1 if the hook is established, 0 if skipped (no valid config), or
4017-
* a negative error code.
4019+
* Returns 0 if the hook is established or a negative error code.
40184020
*/
40194021
int snd_hda_gen_add_micmute_led(struct hda_codec *codec,
40204022
void (*hook)(struct hda_codec *))
40214023
{
40224024
struct hda_gen_spec *spec = codec->spec;
40234025

4024-
if (spec->num_adc_nids > 1 && !spec->dyn_adc_switch) {
4025-
codec_dbg(codec,
4026-
"Skipping micmute LED control due to several ADCs");
4027-
return 0;
4028-
}
4029-
40304026
spec->micmute_led.led_mode = MICMUTE_LED_FOLLOW_MUTE;
40314027
spec->micmute_led.capture = 0;
40324028
spec->micmute_led.led_value = 0;
@@ -4035,7 +4031,7 @@ int snd_hda_gen_add_micmute_led(struct hda_codec *codec,
40354031
spec->cap_sync_hook = update_micmute_led;
40364032
if (!snd_hda_gen_add_kctl(spec, NULL, &micmute_led_mode_ctl))
40374033
return -ENOMEM;
4038-
return 1;
4034+
return 0;
40394035
}
40404036
EXPORT_SYMBOL_GPL(snd_hda_gen_add_micmute_led);
40414037

0 commit comments

Comments
 (0)