diff options
author | Takashi Iwai <tiwai@suse.de> | 2020-06-18 08:44:09 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2020-06-18 09:02:12 +0200 |
commit | 25156136f87d803115e05c8f16f3c0cc6341447d (patch) | |
tree | 30ad67a84ad8bc8e8a5cabf6f5bd1a4419478cb1 | |
parent | 489c3e69a470f69a759d95d5f72c3ad908a4cb4e (diff) | |
download | hda-emu-25156136f87d803115e05c8f16f3c0cc6341447d.tar.gz |
Enable and add support for CONFIG_SND_HDA_GENERIC_LEDS
The LED audio trigger wrappers are improved to notify the changes.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | include/codec_config.h | 1 | ||||
-rw-r--r-- | include/linux/device.h | 3 | ||||
-rw-r--r-- | snd-wrapper.c | 20 |
3 files changed, 23 insertions, 1 deletions
diff --git a/include/codec_config.h b/include/codec_config.h index 7948bf1..2042f0c 100644 --- a/include/codec_config.h +++ b/include/codec_config.h @@ -9,6 +9,7 @@ #define CONFIG_SND_DEBUG_VERBOSE #define CONFIG_SND_HDA_GENERIC +#define CONFIG_SND_HDA_GENERIC_LEDS #define CONFIG_SND_HDA_HWDEP #define CONFIG_SND_HDA_INPUT_JACK #define CONFIG_SND_HDA_INPUT_BEEP diff --git a/include/linux/device.h b/include/linux/device.h index 2375202..37e2210 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -115,4 +115,7 @@ struct device_attribute { #define DEVICE_ATTR_RO(_name) \ struct device_attribute dev_attr_##_name = __ATTR_RO(_name) +#define devm_kmalloc(dev, size, gfp) kmalloc(size, gfp) +#define devm_kzalloc(dev, size, gfp) kzalloc(size, gfp) + #endif /* __LINUX_DEVICE_H */ diff --git a/snd-wrapper.c b/snd-wrapper.c index 1bb7fd3..a93ede2 100644 --- a/snd-wrapper.c +++ b/snd-wrapper.c @@ -911,18 +911,36 @@ void pm_runtime_forbid(struct device *dev) check_resume(dev); } +static enum led_brightness led_states[2]; +static char *led_names[2] = { "mute", "micmute" }; +static struct led_classdev *led_devs[2]; + enum led_brightness ledtrig_audio_get(enum led_audio type) { - return LED_OFF; + return led_states[type]; } void ledtrig_audio_set(enum led_audio type, enum led_brightness state) { + led_states[type] = state; + hda_log(HDA_LOG_INFO, "LED state %s = %d\n", led_names[type], state); + if (led_devs[type]) + led_devs[type]->brightness_set_blocking(led_devs[type], state); } int devm_led_classdev_register_ext(struct device *parent, struct led_classdev *led_cdev, struct led_init_data *init_data) { + if (!strcmp(led_cdev->name, "hda::mute")) { + led_devs[LED_AUDIO_MUTE] = led_cdev; + } else if (!strcmp(led_cdev->name, "hda::micmute")) { + led_devs[LED_AUDIO_MICMUTE] = led_cdev; + } else { + hda_log(HDA_LOG_ERR, "Invalid LED cdev name %s\n", led_cdev->name); + return -EINVAL; + } + led_cdev->dev = calloc(sizeof(struct device), 1); + led_cdev->dev->parent = parent; return 0; } |