* [PATCH 0/2] hid-asus: reset the backlight brightness level on resume
@ 2023-11-17 1:15 Luke D. Jones
2023-11-17 1:15 ` [PATCH 1/2] hid-asus: add const to read-only outgoing usb buffer Luke D. Jones
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Luke D. Jones @ 2023-11-17 1:15 UTC (permalink / raw)
To: jikos; +Cc: benjamin.tissoires, linux-input, linux-kernel, benato.denis96
From: Denis Benato <benato.denis96@gmail.com>
I have noticed that in my Asus device RC71L the keyboard backlight is LEDs brightness of two RGB rings around two joysticks of this handheld device.
The firmware on this device (and other devices from the same manufacturer) restores a default brightness level (that is full brightness for my device and off for some others) after resuming from sleep; that means sysfs will report a wrong brightness level and requires human intervention to restore the desired brightness.
I have fixed aforementioned problems with this patch I am submitting.
This patch (composed of two distinct patches) compiles without warnings on both gcc and clang and also improves a function signature and constant-correctness of the kernel driver.
Denis Benato (2):
hid-asus: add const to read-only outgoing usb buffer
hid-asus: reset the backlight brightness level on resume
drivers/hid/hid-asus.c | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
--
2.42.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] hid-asus: add const to read-only outgoing usb buffer
2023-11-17 1:15 [PATCH 0/2] hid-asus: reset the backlight brightness level on resume Luke D. Jones
@ 2023-11-17 1:15 ` Luke D. Jones
2023-11-17 1:15 ` [PATCH 2/2] hid-asus: reset the backlight brightness level on resume Luke D. Jones
2023-11-17 19:51 ` [PATCH 0/2] " Denis Benato
2 siblings, 0 replies; 7+ messages in thread
From: Luke D. Jones @ 2023-11-17 1:15 UTC (permalink / raw)
To: jikos; +Cc: benjamin.tissoires, linux-input, linux-kernel, benato.denis96
From: Denis Benato <benato.denis96@gmail.com>
In the function asus_kbd_set_report the parameter buf is read-only
as it gets copied in a memory portion suitable for USB transfer,
but the parameter is not marked as const: add the missing const and mark
const immutable buffers passed to that function.
Signed-off-by: Denis Benato <benato.denis96@gmail.com>
---
drivers/hid/hid-asus.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index fd61dba88233..b70673a929a1 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -381,7 +381,7 @@ static int asus_raw_event(struct hid_device *hdev,
return 0;
}
-static int asus_kbd_set_report(struct hid_device *hdev, u8 *buf, size_t buf_size)
+static int asus_kbd_set_report(struct hid_device *hdev, const u8 *buf, size_t buf_size)
{
unsigned char *dmabuf;
int ret;
@@ -404,7 +404,7 @@ static int asus_kbd_set_report(struct hid_device *hdev, u8 *buf, size_t buf_size
static int asus_kbd_init(struct hid_device *hdev)
{
- u8 buf[] = { FEATURE_KBD_REPORT_ID, 0x41, 0x53, 0x55, 0x53, 0x20, 0x54,
+ const u8 buf[] = { FEATURE_KBD_REPORT_ID, 0x41, 0x53, 0x55, 0x53, 0x20, 0x54,
0x65, 0x63, 0x68, 0x2e, 0x49, 0x6e, 0x63, 0x2e, 0x00 };
int ret;
@@ -418,7 +418,7 @@ static int asus_kbd_init(struct hid_device *hdev)
static int asus_kbd_get_functions(struct hid_device *hdev,
unsigned char *kbd_func)
{
- u8 buf[] = { FEATURE_KBD_REPORT_ID, 0x05, 0x20, 0x31, 0x00, 0x08 };
+ const u8 buf[] = { FEATURE_KBD_REPORT_ID, 0x05, 0x20, 0x31, 0x00, 0x08 };
u8 *readbuf;
int ret;
@@ -449,7 +449,7 @@ static int asus_kbd_get_functions(struct hid_device *hdev,
static int rog_nkey_led_init(struct hid_device *hdev)
{
- u8 buf_init_start[] = { FEATURE_KBD_LED_REPORT_ID1, 0xB9 };
+ const u8 buf_init_start[] = { FEATURE_KBD_LED_REPORT_ID1, 0xB9 };
u8 buf_init2[] = { FEATURE_KBD_LED_REPORT_ID1, 0x41, 0x53, 0x55, 0x53, 0x20,
0x54, 0x65, 0x63, 0x68, 0x2e, 0x49, 0x6e, 0x63, 0x2e, 0x00 };
u8 buf_init3[] = { FEATURE_KBD_LED_REPORT_ID1,
--
2.42.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] hid-asus: reset the backlight brightness level on resume
2023-11-17 1:15 [PATCH 0/2] hid-asus: reset the backlight brightness level on resume Luke D. Jones
2023-11-17 1:15 ` [PATCH 1/2] hid-asus: add const to read-only outgoing usb buffer Luke D. Jones
@ 2023-11-17 1:15 ` Luke D. Jones
2023-11-17 19:51 ` [PATCH 0/2] " Denis Benato
2 siblings, 0 replies; 7+ messages in thread
From: Luke D. Jones @ 2023-11-17 1:15 UTC (permalink / raw)
To: jikos; +Cc: benjamin.tissoires, linux-input, linux-kernel, benato.denis96
From: Denis Benato <benato.denis96@gmail.com>
Some devices managed by this driver automatically set brightness to 0
before entering a suspended state and reset it back to a default
brightness level after the resume:
this has the effect of having the kernel report wrong brightness
status after a sleep, and on some devices (like the Asus RC71L) that
brightness is the intensity of LEDs directly facing the user.
Fix the above issue by setting back brightness to the level it had
before entering a sleep state.
Signed-off-by: Denis Benato <benato.denis96@gmail.com>
---
drivers/hid/hid-asus.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index b70673a929a1..78cdfb8b9a7a 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -1000,6 +1000,24 @@ static int asus_start_multitouch(struct hid_device *hdev)
return 0;
}
+static int __maybe_unused asus_resume(struct hid_device *hdev) {
+ struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
+ int ret = 0;
+
+ if (drvdata->kbd_backlight) {
+ const u8 buf[] = { FEATURE_KBD_REPORT_ID, 0xba, 0xc5, 0xc4,
+ drvdata->kbd_backlight->cdev.brightness };
+ ret = asus_kbd_set_report(hdev, buf, sizeof(buf));
+ if (ret < 0) {
+ hid_err(hdev, "Asus failed to set keyboard backlight: %d\n", ret);
+ goto asus_resume_err;
+ }
+ }
+
+asus_resume_err:
+ return ret;
+}
+
static int __maybe_unused asus_reset_resume(struct hid_device *hdev)
{
struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
@@ -1294,6 +1312,7 @@ static struct hid_driver asus_driver = {
.input_configured = asus_input_configured,
#ifdef CONFIG_PM
.reset_resume = asus_reset_resume,
+ .resume = asus_resume,
#endif
.event = asus_event,
.raw_event = asus_raw_event
--
2.42.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] hid-asus: reset the backlight brightness level on resume
2023-11-17 1:15 [PATCH 0/2] hid-asus: reset the backlight brightness level on resume Luke D. Jones
2023-11-17 1:15 ` [PATCH 1/2] hid-asus: add const to read-only outgoing usb buffer Luke D. Jones
2023-11-17 1:15 ` [PATCH 2/2] hid-asus: reset the backlight brightness level on resume Luke D. Jones
@ 2023-11-17 19:51 ` Denis Benato
2023-11-21 8:52 ` Jiri Kosina
2 siblings, 1 reply; 7+ messages in thread
From: Denis Benato @ 2023-11-17 19:51 UTC (permalink / raw)
To: Luke D. Jones, jikos; +Cc: benjamin.tissoires, linux-input, linux-kernel
> From: Denis Benato <benato.denis96@gmail.com>
I want to express my gratitude toward Luke for his guidance and his help in submitting this fix.
I confirm those patches were sent in my behalf.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] hid-asus: reset the backlight brightness level on resume
2023-11-17 19:51 ` [PATCH 0/2] " Denis Benato
@ 2023-11-21 8:52 ` Jiri Kosina
2023-11-21 19:35 ` Luke Jones
0 siblings, 1 reply; 7+ messages in thread
From: Jiri Kosina @ 2023-11-21 8:52 UTC (permalink / raw)
To: Denis Benato; +Cc: Luke D. Jones, benjamin.tissoires, linux-input, linux-kernel
On Fri, 17 Nov 2023, Denis Benato wrote:
> > From: Denis Benato <benato.denis96@gmail.com>
>
> I want to express my gratitude toward Luke for his guidance and his help
> in submitting this fix.
>
> I confirm those patches were sent in my behalf.
Luke, as you were in the supply chain of the patches, could you please
provide Signed-off-by: tags so that I can add them into the chain?
Thanks,
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] hid-asus: reset the backlight brightness level on resume
2023-11-21 8:52 ` Jiri Kosina
@ 2023-11-21 19:35 ` Luke Jones
2023-11-22 10:25 ` Jiri Kosina
0 siblings, 1 reply; 7+ messages in thread
From: Luke Jones @ 2023-11-21 19:35 UTC (permalink / raw)
To: Jiri Kosina; +Cc: Denis Benato, benjamin.tissoires, linux-input, linux-kernel
On Tue, Nov 21 2023 at 09:52:11 AM +01:00:00, Jiri Kosina
<jikos@kernel.org> wrote:
> On Fri, 17 Nov 2023, Denis Benato wrote:
>
>> > From: Denis Benato <benato.denis96@gmail.com>
>>
>> I want to express my gratitude toward Luke for his guidance and his
>> help
>> in submitting this fix.
>>
>> I confirm those patches were sent in my behalf.
>
> Luke, as you were in the supply chain of the patches, could you please
> provide Signed-off-by: tags so that I can add them into the chain?
Signed-off-by: Luke D. Jones <luke@ljones.dev>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] hid-asus: reset the backlight brightness level on resume
2023-11-21 19:35 ` Luke Jones
@ 2023-11-22 10:25 ` Jiri Kosina
0 siblings, 0 replies; 7+ messages in thread
From: Jiri Kosina @ 2023-11-22 10:25 UTC (permalink / raw)
To: Luke Jones; +Cc: Denis Benato, benjamin.tissoires, linux-input, linux-kernel
On Wed, 22 Nov 2023, Luke Jones wrote:
> >> I want to express my gratitude toward Luke for his guidance and his help
> >> in submitting this fix.
> >>
> >> I confirm those patches were sent in my behalf.
> >
> > Luke, as you were in the supply chain of the patches, could you please
> > provide Signed-off-by: tags so that I can add them into the chain?
>
> Signed-off-by: Luke D. Jones <luke@ljones.dev>
Applied, thanks.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-11-22 10:25 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-17 1:15 [PATCH 0/2] hid-asus: reset the backlight brightness level on resume Luke D. Jones
2023-11-17 1:15 ` [PATCH 1/2] hid-asus: add const to read-only outgoing usb buffer Luke D. Jones
2023-11-17 1:15 ` [PATCH 2/2] hid-asus: reset the backlight brightness level on resume Luke D. Jones
2023-11-17 19:51 ` [PATCH 0/2] " Denis Benato
2023-11-21 8:52 ` Jiri Kosina
2023-11-21 19:35 ` Luke Jones
2023-11-22 10:25 ` Jiri Kosina
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).