1 // SPDX-License-Identifier: GPL-2.0
2 /* Helper functions for Thinkpad LED control;
3 * to be included from codec driver
6 #if IS_ENABLED(CONFIG_THINKPAD_ACPI) && IS_REACHABLE(CONFIG_LEDS_TRIGGER_AUDIO)
8 #include <linux/acpi.h>
9 #include <linux/leds.h>
11 static void (*old_vmaster_hook
)(void *, int);
13 static bool is_thinkpad(struct hda_codec
*codec
)
15 return (codec
->core
.subsystem_id
>> 16 == 0x17aa) &&
16 (acpi_dev_found("LEN0068") || acpi_dev_found("LEN0268") ||
17 acpi_dev_found("IBM0068"));
20 static void update_tpacpi_mute_led(void *private_data
, int enabled
)
23 old_vmaster_hook(private_data
, enabled
);
25 ledtrig_audio_set(LED_AUDIO_MUTE
, enabled
? LED_OFF
: LED_ON
);
28 static void hda_fixup_thinkpad_acpi(struct hda_codec
*codec
,
29 const struct hda_fixup
*fix
, int action
)
31 struct hda_gen_spec
*spec
= codec
->spec
;
33 if (action
== HDA_FIXUP_ACT_PROBE
) {
34 if (!is_thinkpad(codec
))
36 old_vmaster_hook
= spec
->vmaster_mute
.hook
;
37 spec
->vmaster_mute
.hook
= update_tpacpi_mute_led
;
38 snd_hda_gen_fixup_micmute_led(codec
, fix
, action
);
42 #else /* CONFIG_THINKPAD_ACPI */
44 static void hda_fixup_thinkpad_acpi(struct hda_codec
*codec
,
45 const struct hda_fixup
*fix
, int action
)
49 #endif /* CONFIG_THINKPAD_ACPI */