@@ -3922,7 +3922,7 @@ static void call_micmute_led_update(struct hda_codec *codec)
3922
3922
val = 0 ;
3923
3923
break ;
3924
3924
case MICMUTE_LED_FOLLOW_CAPTURE :
3925
- val = spec -> micmute_led .capture ;
3925
+ val = !! spec -> micmute_led .capture ;
3926
3926
break ;
3927
3927
case MICMUTE_LED_FOLLOW_MUTE :
3928
3928
default :
@@ -3942,17 +3942,21 @@ static void update_micmute_led(struct hda_codec *codec,
3942
3942
struct snd_ctl_elem_value * ucontrol )
3943
3943
{
3944
3944
struct hda_gen_spec * spec = codec -> spec ;
3945
+ unsigned int mask ;
3945
3946
3946
3947
if (spec -> micmute_led .old_hook )
3947
3948
spec -> micmute_led .old_hook (codec , kcontrol , ucontrol );
3948
3949
3949
3950
if (!ucontrol )
3950
3951
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 ) ) {
3953
3954
/* 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 ;
3956
3960
call_micmute_led_update (codec );
3957
3961
}
3958
3962
}
@@ -4008,25 +4012,17 @@ static const struct snd_kcontrol_new micmute_led_mode_ctl = {
4008
4012
* @hook: the callback for updating LED
4009
4013
*
4010
4014
* 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.
4015
4018
*
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.
4018
4020
*/
4019
4021
int snd_hda_gen_add_micmute_led (struct hda_codec * codec ,
4020
4022
void (* hook )(struct hda_codec * ))
4021
4023
{
4022
4024
struct hda_gen_spec * spec = codec -> spec ;
4023
4025
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
-
4030
4026
spec -> micmute_led .led_mode = MICMUTE_LED_FOLLOW_MUTE ;
4031
4027
spec -> micmute_led .capture = 0 ;
4032
4028
spec -> micmute_led .led_value = 0 ;
@@ -4035,7 +4031,7 @@ int snd_hda_gen_add_micmute_led(struct hda_codec *codec,
4035
4031
spec -> cap_sync_hook = update_micmute_led ;
4036
4032
if (!snd_hda_gen_add_kctl (spec , NULL , & micmute_led_mode_ctl ))
4037
4033
return - ENOMEM ;
4038
- return 1 ;
4034
+ return 0 ;
4039
4035
}
4040
4036
EXPORT_SYMBOL_GPL (snd_hda_gen_add_micmute_led );
4041
4037
0 commit comments