From: Stephen Horvath <s.horvath@outlook.com.au>
To: Lee Jones <lee@kernel.org>, Benson Leung <bleung@chromium.org>,
Guenter Roeck <groeck@chromium.org>,
Tzung-Bi Shih <tzungbi@kernel.org>,
chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org
Cc: Stephen Horvath <s.horvath@outlook.com.au>
Subject: [PATCH 2/2] platform/chrome: cros_kbd_led_backlight: Remove obsolete commands (EC_CMD_PWM_*_KEYBOARD_BACKLIGHT)
Date: Fri, 22 Mar 2024 20:27:59 +1000 [thread overview]
Message-ID: <SY4P282MB3063D447DA09D35F5FBD4721C5312@SY4P282MB3063.AUSP282.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <20240322102800.1322022-1-s.horvath@outlook.com.au>
EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT and EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT
are marked as obsolete in `cros_ec_commands.h`, this patch removes the
usage of these commands from the driver.
The max brightness value is now set to `EC_PWM_MAX_DUTY` (65535) when
running on the EC, as this is the maximum value that the EC can accept.
Signed-off-by: Stephen Horvath <s.horvath@outlook.com.au>
---
.../platform/chrome/cros_kbd_led_backlight.c | 37 +++++++++++++------
1 file changed, 25 insertions(+), 12 deletions(-)
diff --git a/drivers/platform/chrome/cros_kbd_led_backlight.c b/drivers/platform/chrome/cros_kbd_led_backlight.c
index 06e9a57536af..bc021437e8b1 100644
--- a/drivers/platform/chrome/cros_kbd_led_backlight.c
+++ b/drivers/platform/chrome/cros_kbd_led_backlight.c
@@ -47,10 +47,10 @@ struct keyboard_led_drvdata {
enum led_brightness max_brightness;
};
-#define KEYBOARD_BACKLIGHT_MAX 100
-
#ifdef CONFIG_ACPI
+#define ACPI_KEYBOARD_BACKLIGHT_MAX 100
+
/* Keyboard LED ACPI Device must be defined in firmware */
#define ACPI_KEYBOARD_BACKLIGHT_DEVICE "\\_SB.KBLT"
#define ACPI_KEYBOARD_BACKLIGHT_READ ACPI_KEYBOARD_BACKLIGHT_DEVICE ".KBQC"
@@ -114,7 +114,7 @@ static const struct keyboard_led_drvdata keyboard_led_drvdata_acpi = {
.init = keyboard_led_init_acpi,
.brightness_set = keyboard_led_set_brightness_acpi,
.brightness_get = keyboard_led_get_brightness_acpi,
- .max_brightness = KEYBOARD_BACKLIGHT_MAX,
+ .max_brightness = ACPI_KEYBOARD_BACKLIGHT_MAX,
};
#endif /* CONFIG_ACPI */
@@ -127,18 +127,22 @@ keyboard_led_set_brightness_ec_pwm(struct led_classdev *cdev,
{
struct {
struct cros_ec_command msg;
- struct ec_params_pwm_set_keyboard_backlight params;
+ struct ec_params_pwm_set_duty params;
} __packed buf;
- struct ec_params_pwm_set_keyboard_backlight *params = &buf.params;
+ struct ec_params_pwm_set_duty *params = &buf.params;
struct cros_ec_command *msg = &buf.msg;
struct keyboard_led *keyboard_led = container_of(cdev, struct keyboard_led, cdev);
memset(&buf, 0, sizeof(buf));
- msg->command = EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT;
+ msg->version = 0;
+ msg->command = EC_CMD_PWM_SET_DUTY;
+ msg->insize = 0;
msg->outsize = sizeof(*params);
- params->percent = brightness;
+ params->duty = brightness;
+ params->pwm_type = EC_PWM_TYPE_KB_LIGHT;
+ params->index = 0;
return cros_ec_cmd_xfer_status(keyboard_led->ec, msg);
}
@@ -148,23 +152,32 @@ keyboard_led_get_brightness_ec_pwm(struct led_classdev *cdev)
{
struct {
struct cros_ec_command msg;
- struct ec_response_pwm_get_keyboard_backlight resp;
+ union {
+ struct ec_params_pwm_get_duty params;
+ struct ec_response_pwm_get_duty resp;
+ };
} __packed buf;
- struct ec_response_pwm_get_keyboard_backlight *resp = &buf.resp;
+ struct ec_params_pwm_get_duty *params = &buf.params;
+ struct ec_response_pwm_get_duty *resp = &buf.resp;
struct cros_ec_command *msg = &buf.msg;
struct keyboard_led *keyboard_led = container_of(cdev, struct keyboard_led, cdev);
int ret;
memset(&buf, 0, sizeof(buf));
- msg->command = EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT;
+ msg->version = 0;
+ msg->command = EC_CMD_PWM_GET_DUTY;
msg->insize = sizeof(*resp);
+ msg->outsize = sizeof(*params);
+
+ params->pwm_type = EC_PWM_TYPE_KB_LIGHT;
+ params->index = 0;
ret = cros_ec_cmd_xfer_status(keyboard_led->ec, msg);
if (ret < 0)
return ret;
- return resp->percent;
+ return resp->duty;
}
static int keyboard_led_init_ec_pwm(struct platform_device *pdev)
@@ -186,7 +199,7 @@ static const __maybe_unused struct keyboard_led_drvdata keyboard_led_drvdata_ec_
.init = keyboard_led_init_ec_pwm,
.brightness_set_blocking = keyboard_led_set_brightness_ec_pwm,
.brightness_get = keyboard_led_get_brightness_ec_pwm,
- .max_brightness = KEYBOARD_BACKLIGHT_MAX,
+ .max_brightness = EC_PWM_MAX_DUTY,
};
#else /* IS_ENABLED(CONFIG_CROS_EC) */
--
2.43.0
next prev parent reply other threads:[~2024-03-22 10:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20240322102800.1322022-1-s.horvath@outlook.com.au>
2024-03-22 10:27 ` [PATCH 1/2] platform/chrome: cros_kbd_led_backlight: Automatically enable keyboard backlight control if feature present in EC Stephen Horvath
2024-03-25 3:24 ` Tzung-Bi Shih
2024-03-25 4:27 ` Stephen Horvath
2024-03-22 10:27 ` Stephen Horvath [this message]
2024-03-25 18:45 ` [PATCH 2/2] platform/chrome: cros_kbd_led_backlight: Remove obsolete commands (EC_CMD_PWM_*_KEYBOARD_BACKLIGHT) Brian Norris
2024-03-26 0:30 ` Stephen Horvath
2024-03-26 0:39 ` Brian Norris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=SY4P282MB3063D447DA09D35F5FBD4721C5312@SY4P282MB3063.AUSP282.PROD.OUTLOOK.COM \
--to=s.horvath@outlook.com.au \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=groeck@chromium.org \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tzungbi@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox