Linux Audio

Check our new training course

Loading...
v6.2
 1// SPDX-License-Identifier: GPL-2.0
 2/* Helper functions for Thinkpad LED control;
 3 * to be included from codec driver
 4 */
 5
 6#if IS_ENABLED(CONFIG_THINKPAD_ACPI)
 7
 8#include <linux/acpi.h>
 9#include <linux/leds.h>
10
 
 
11static bool is_thinkpad(struct hda_codec *codec)
12{
13	return (codec->core.subsystem_id >> 16 == 0x17aa) &&
14	       (acpi_dev_found("LEN0068") || acpi_dev_found("LEN0268") ||
15		acpi_dev_found("IBM0068"));
16}
17
 
 
 
 
 
 
 
 
18static void hda_fixup_thinkpad_acpi(struct hda_codec *codec,
19				    const struct hda_fixup *fix, int action)
20{
21	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
 
 
22		if (!is_thinkpad(codec))
23			return;
24		snd_hda_gen_add_mute_led_cdev(codec, NULL);
25		snd_hda_gen_add_micmute_led_cdev(codec, NULL);
 
26	}
27}
28
29#else /* CONFIG_THINKPAD_ACPI */
30
31static void hda_fixup_thinkpad_acpi(struct hda_codec *codec,
32				    const struct hda_fixup *fix, int action)
33{
34}
35
36#endif /* CONFIG_THINKPAD_ACPI */
v5.4
 1// SPDX-License-Identifier: GPL-2.0
 2/* Helper functions for Thinkpad LED control;
 3 * to be included from codec driver
 4 */
 5
 6#if IS_ENABLED(CONFIG_THINKPAD_ACPI) && IS_REACHABLE(CONFIG_LEDS_TRIGGER_AUDIO)
 7
 8#include <linux/acpi.h>
 9#include <linux/leds.h>
10
11static void (*old_vmaster_hook)(void *, int);
12
13static bool is_thinkpad(struct hda_codec *codec)
14{
15	return (codec->core.subsystem_id >> 16 == 0x17aa) &&
16	       (acpi_dev_found("LEN0068") || acpi_dev_found("LEN0268") ||
17		acpi_dev_found("IBM0068"));
18}
19
20static void update_tpacpi_mute_led(void *private_data, int enabled)
21{
22	if (old_vmaster_hook)
23		old_vmaster_hook(private_data, enabled);
24
25	ledtrig_audio_set(LED_AUDIO_MUTE, enabled ? LED_OFF : LED_ON);
26}
27
28static void hda_fixup_thinkpad_acpi(struct hda_codec *codec,
29				    const struct hda_fixup *fix, int action)
30{
31	struct hda_gen_spec *spec = codec->spec;
32
33	if (action == HDA_FIXUP_ACT_PROBE) {
34		if (!is_thinkpad(codec))
35			return;
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);
39	}
40}
41
42#else /* CONFIG_THINKPAD_ACPI */
43
44static void hda_fixup_thinkpad_acpi(struct hda_codec *codec,
45				    const struct hda_fixup *fix, int action)
46{
47}
48
49#endif /* CONFIG_THINKPAD_ACPI */