Commit 3ed0b880 authored by Koba Ko's avatar Koba Ko Committed by Hans de Goede

platform/x86: dell-laptop: Register ctl-led for speaker-mute

Some platforms have the speaker-mute led and
current driver doesn't control it.

If the platform support the control of speaker-mute led, register it
Signed-off-by: default avatarKoba Ko <koba.ko@canonical.com>
Link: https://lore.kernel.org/r/20230308062414.1048913-1-koba.ko@canonical.comReviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent 39e2ba64
...@@ -97,6 +97,7 @@ static struct rfkill *bluetooth_rfkill; ...@@ -97,6 +97,7 @@ static struct rfkill *bluetooth_rfkill;
static struct rfkill *wwan_rfkill; static struct rfkill *wwan_rfkill;
static bool force_rfkill; static bool force_rfkill;
static bool micmute_led_registered; static bool micmute_led_registered;
static bool mute_led_registered;
module_param(force_rfkill, bool, 0444); module_param(force_rfkill, bool, 0444);
MODULE_PARM_DESC(force_rfkill, "enable rfkill on non whitelisted models"); MODULE_PARM_DESC(force_rfkill, "enable rfkill on non whitelisted models");
...@@ -2177,6 +2178,34 @@ static struct led_classdev micmute_led_cdev = { ...@@ -2177,6 +2178,34 @@ static struct led_classdev micmute_led_cdev = {
.default_trigger = "audio-micmute", .default_trigger = "audio-micmute",
}; };
static int mute_led_set(struct led_classdev *led_cdev,
enum led_brightness brightness)
{
struct calling_interface_buffer buffer;
struct calling_interface_token *token;
int state = brightness != LED_OFF;
if (state == 0)
token = dell_smbios_find_token(GLOBAL_MUTE_DISABLE);
else
token = dell_smbios_find_token(GLOBAL_MUTE_ENABLE);
if (!token)
return -ENODEV;
dell_fill_request(&buffer, token->location, token->value, 0, 0);
dell_send_request(&buffer, CLASS_TOKEN_WRITE, SELECT_TOKEN_STD);
return 0;
}
static struct led_classdev mute_led_cdev = {
.name = "platform::mute",
.max_brightness = 1,
.brightness_set_blocking = mute_led_set,
.default_trigger = "audio-mute",
};
static int __init dell_init(void) static int __init dell_init(void)
{ {
struct calling_interface_token *token; struct calling_interface_token *token;
...@@ -2230,6 +2259,15 @@ static int __init dell_init(void) ...@@ -2230,6 +2259,15 @@ static int __init dell_init(void)
micmute_led_registered = true; micmute_led_registered = true;
} }
if (dell_smbios_find_token(GLOBAL_MUTE_DISABLE) &&
dell_smbios_find_token(GLOBAL_MUTE_ENABLE)) {
mute_led_cdev.brightness = ledtrig_audio_get(LED_AUDIO_MUTE);
ret = led_classdev_register(&platform_device->dev, &mute_led_cdev);
if (ret < 0)
goto fail_backlight;
mute_led_registered = true;
}
if (acpi_video_get_backlight_type() != acpi_backlight_vendor) if (acpi_video_get_backlight_type() != acpi_backlight_vendor)
return 0; return 0;
...@@ -2277,6 +2315,8 @@ static int __init dell_init(void) ...@@ -2277,6 +2315,8 @@ static int __init dell_init(void)
fail_backlight: fail_backlight:
if (micmute_led_registered) if (micmute_led_registered)
led_classdev_unregister(&micmute_led_cdev); led_classdev_unregister(&micmute_led_cdev);
if (mute_led_registered)
led_classdev_unregister(&mute_led_cdev);
fail_led: fail_led:
dell_cleanup_rfkill(); dell_cleanup_rfkill();
fail_rfkill: fail_rfkill:
...@@ -2299,6 +2339,8 @@ static void __exit dell_exit(void) ...@@ -2299,6 +2339,8 @@ static void __exit dell_exit(void)
backlight_device_unregister(dell_backlight_device); backlight_device_unregister(dell_backlight_device);
if (micmute_led_registered) if (micmute_led_registered)
led_classdev_unregister(&micmute_led_cdev); led_classdev_unregister(&micmute_led_cdev);
if (mute_led_registered)
led_classdev_unregister(&mute_led_cdev);
dell_cleanup_rfkill(); dell_cleanup_rfkill();
if (platform_device) { if (platform_device) {
platform_device_unregister(platform_device); platform_device_unregister(platform_device);
......
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#define KBD_LED_AUTO_100_TOKEN 0x02F6 #define KBD_LED_AUTO_100_TOKEN 0x02F6
#define GLOBAL_MIC_MUTE_ENABLE 0x0364 #define GLOBAL_MIC_MUTE_ENABLE 0x0364
#define GLOBAL_MIC_MUTE_DISABLE 0x0365 #define GLOBAL_MIC_MUTE_DISABLE 0x0365
#define GLOBAL_MUTE_ENABLE 0x058C
#define GLOBAL_MUTE_DISABLE 0x058D
struct notifier_block; struct notifier_block;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment