Skip to contentSkip to conversation

eeepc-wmi: new driver for WMI based hotkeys on Eee PC laptops

PATCH Matthew Garrett 4 participants 12 messages Mar 19, 2010 – Mar 21, 2010 1 message not in the archive HID

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

(Cc:ing input)

Quoted 1 line · Yong Wang

Add a WMI driver for Eee PC laptops. Currently it only supports hotkeys.

Looks good.

Quoted 28 lines
(quoted diff) +28 -0
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/input.h>
+#include <acpi/acpi_bus.h>
+#include <acpi/acpi_drivers.h>
+
+MODULE_AUTHOR("Yong Wang <[email protected]>");
+MODULE_DESCRIPTION("Eee PC WMI Hotkey Driver");
+MODULE_LICENSE("GPL");
+
+#define EEEPC_WMI_EVENT_GUID	"ABBC0F72-8EA1-11D1-00A0-C90629100000"
+
+#define NOTIFY_BRNUP_MIN	0x11
+#define NOTIFY_BRNUP_MAX	0x1f
+#define NOTIFY_BRNDOWN_MIN	0x20
+#define NOTIFY_BRNDOWN_MAX	0x2e
+
+struct key_entry {
+	char type;
+	u8 code;
+	u16 keycode;
+};
+
+enum { KE_KEY, KE_END };
+
+static struct key_entry eeepc_wmi_keymap[] = {

Review

Quoted 10 lines
(quoted diff) +10 -0
+	/* Sleep already handled via generic ACPI code */
+	{KE_KEY, 0x5d, KEY_WLAN },
+	{KE_KEY, 0x32, KEY_MUTE },
+	{KE_KEY, 0x31, KEY_VOLUMEDOWN },
+	{KE_KEY, 0x30, KEY_VOLUMEUP },
+	{KE_KEY, NOTIFY_BRNDOWN_MIN, KEY_BRIGHTNESSDOWN },
+	{KE_KEY, NOTIFY_BRNUP_MIN, KEY_BRIGHTNESSUP },
+	{KE_KEY, 0xcc, KEY_SWITCHVIDEOMODE },
+	{KE_END, 0},
+};

This probably ought to use the new sparse keymap code. I know that there are drivers that are currently in the tree that don't, but it's probably preferable to avoid adding new ones.

Review

Quoted 4 lines
(quoted diff) +4 -0
+		if (code >= NOTIFY_BRNUP_MIN && code <= NOTIFY_BRNUP_MAX)
+			code = NOTIFY_BRNUP_MIN;
+		else if (code >= NOTIFY_BRNDOWN_MIN && code <= NOTIFY_BRNDOWN_MAX)
+			code = NOTIFY_BRNDOWN_MIN;

Do the brightness keys just send notifications, or do they actually change the brightness? If they actually change the brightness, we shouldn't send input events.

Other than that, looks good!

Signature · 1 line
Matthew Garrett | [email protected]
#2 lore raw
Quoted 5 lines · Matthew Garrett

This probably ought to use the new sparse keymap code. I know that there are drivers that are currently in the tree that don't, but it's probably preferable to avoid adding new ones.

OK, will take a look at the new interface and revise accordingly.

Quoted 9 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+		if (code >= NOTIFY_BRNUP_MIN && code <= NOTIFY_BRNUP_MAX)
+			code = NOTIFY_BRNUP_MIN;
+		else if (code >= NOTIFY_BRNDOWN_MIN && code <= NOTIFY_BRNDOWN_MAX)
+			code = NOTIFY_BRNDOWN_MIN;

Do the brightness keys just send notifications, or do they actually change the brightness? If they actually change the brightness, we shouldn't send input events.

Yes, hardware and bios change brightness by themselves without software intervention on my Eee PC 1005 when pressing the hotkeys.

Thanks for the review.

-Yong

#3 lore raw
Quoted 8 lines · Yong Wang
Quoted 5 lines · Matthew Garrett

This probably ought to use the new sparse keymap code. I know that there are drivers that are currently in the tree that don't, but it's probably preferable to avoid adding new ones.

OK, will take a look at the new interface and revise accordingly.

Wonderful, thanks.

Quoted 10 lines
Quoted 9 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+		if (code >= NOTIFY_BRNUP_MIN && code <= NOTIFY_BRNUP_MAX)
+			code = NOTIFY_BRNUP_MIN;
+		else if (code >= NOTIFY_BRNDOWN_MIN && code <= NOTIFY_BRNDOWN_MAX)
+			code = NOTIFY_BRNDOWN_MIN;

Do the brightness keys just send notifications, or do they actually change the brightness? If they actually change the brightness, we shouldn't send input events.

Quoted 2 lines

Yes, hardware and bios change brightness by themselves without software intervention on my Eee PC 1005 when pressing the hotkeys.

Ok. In that case, you shouldn't send input events. Once backlight control is implemented in the eee-wmi driver you can send notifications via that instead.

Signature · 1 line
Matthew Garrett | [email protected]
#4 lore raw
Quoted 12 lines · Matthew Garrett
Quoted 8 lines · Yong Wang
Quoted 5 lines · Matthew Garrett

This probably ought to use the new sparse keymap code. I know that there are drivers that are currently in the tree that don't, but it's probably preferable to avoid adding new ones.

OK, will take a look at the new interface and revise accordingly.

Wonderful, thanks.

You are welcome.

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+		if (code >= NOTIFY_BRNUP_MIN && code <= NOTIFY_BRNUP_MAX)
+			code = NOTIFY_BRNUP_MIN;
+		else if (code >= NOTIFY_BRNDOWN_MIN && code <= NOTIFY_BRNDOWN_MAX)
+			code = NOTIFY_BRNDOWN_MIN;

Do the brightness keys just send notifications, or do they actually change the brightness? If they actually change the brightness, we shouldn't send input events.

Quoted 7 lines
Quoted 2 lines

Yes, hardware and bios change brightness by themselves without software intervention on my Eee PC 1005 when pressing the hotkeys.

Ok. In that case, you shouldn't send input events. Once backlight control is implemented in the eee-wmi driver you can send notifications via that instead.

Got it. Backlight is on my TODO list and I plan to add those features incrementally so that people could starting playing with it asap since I've only got a 1005 and I am not sure how it works on other make and models. Make sense?

-Yong

#5 lore raw
In reply to Matthew Garrett
Quoted 11 lines · Matthew Garrett
Quoted 11 lines
Quoted 10 lines

Review

Quoted 5 lines
(quoted diff) +4 -0
+		if (code >= NOTIFY_BRNUP_MIN && code <= NOTIFY_BRNUP_MAX)
+			code = NOTIFY_BRNUP_MIN;
+		else if (code >= NOTIFY_BRNDOWN_MIN && code <= NOTIFY_BRNDOWN_MAX)
+			code = NOTIFY_BRNDOWN_MIN;

Do the brightness keys just send notifications, or do they actually change the brightness? If they actually change the brightness, we shouldn't send input events.

Quoted 7 lines
Quoted 2 lines

Yes, hardware and bios change brightness by themselves without software intervention on my Eee PC 1005 when pressing the hotkeys.

Ok. In that case, you shouldn't send input events. Once backlight control is implemented in the eee-wmi driver you can send notifications via that instead.

One question just popped off the top my head. What if there is a power applet that wants to display a slider field at the bottom of the screen showing the current brightness real time whenever users press brightness hotkeys? Shouldn't it listen to the standard input events translated by X into standard XF86 keysyms? Or shall it listen to the ACPI backlight events? If so, it is the ACPI LCD event when using acpi backlight driver. But what if those vendor specific backlight drivers are used?

Thanks
-Yong

#6 lore raw
Quoted 28 lines · Yong Wang
Quoted 11 lines · Matthew Garrett
Quoted 11 lines
Quoted 10 lines

Review

Quoted 5 lines
(quoted diff) +4 -0
+		if (code >= NOTIFY_BRNUP_MIN && code <= NOTIFY_BRNUP_MAX)
+			code = NOTIFY_BRNUP_MIN;
+		else if (code >= NOTIFY_BRNDOWN_MIN && code <= NOTIFY_BRNDOWN_MAX)
+			code = NOTIFY_BRNDOWN_MIN;

Do the brightness keys just send notifications, or do they actually change the brightness? If they actually change the brightness, we shouldn't send input events.

Quoted 7 lines
Quoted 2 lines

Yes, hardware and bios change brightness by themselves without software intervention on my Eee PC 1005 when pressing the hotkeys.

Ok. In that case, you shouldn't send input events. Once backlight control is implemented in the eee-wmi driver you can send notifications via that instead.

One question just popped off the top my head. What if there is a power applet that wants to display a slider field at the bottom of the screen showing the current brightness real time whenever users press brightness hotkeys? Shouldn't it listen to the standard input events translated by X into standard XF86 keysyms? Or shall it listen to the ACPI backlight events? If so, it is the ACPI LCD event when using acpi backlight driver. But what if those vendor specific backlight drivers are used?

Quoted 3 lines

Thanks
-Yong
--

You may select/poll for the sysfs file actual_brightness. It will return POLLPRI. Basically, backlight devices end up calling sysfs_notify that will allow sysfs_poll to work. Read the comments about sysfs_poll at fs/sysfs/file.c.

You should either use backlight_force_update in your driver or let the user update it writing to the brightness file. In your case, I'd say you should use backlight_force_update and give BACKLIGHT_UPDATE_HOTKEY as the reason.

Regards,
Cascardo.

#7 lore raw
Quoted 19 lines · On Sat, Mar 20, 2010 at 09:20:50AM -0300, [email protected] wrote:
Quoted 9 lines · Yong Wang

One question just popped off the top my head. What if there is a power applet that wants to display a slider field at the bottom of the screen showing the current brightness real time whenever users press brightness hotkeys? Shouldn't it listen to the standard input events translated by X into standard XF86 keysyms? Or shall it listen to the ACPI backlight events? If so, it is the ACPI LCD event when using acpi backlight driver. But what if those vendor specific backlight drivers are used?

Quoted 3 lines

Thanks
-Yong
--

You may select/poll for the sysfs file actual_brightness. It will return POLLPRI. Basically, backlight devices end up calling sysfs_notify that will allow sysfs_poll to work. Read the comments about sysfs_poll at fs/sysfs/file.c.

Quoted 5 lines

You should either use backlight_force_update in your driver or let the user update it writing to the brightness file. In your case, I'd say you should use backlight_force_update and give BACKLIGHT_UPDATE_HOTKEY as the reason.

Oh, I see. Thank for clarifying, Cascardo.

-Yong

#8 lore raw
Quoted 10 lines
Quoted 5 lines

You should either use backlight_force_update in your driver or let the user update it writing to the brightness file. In your case, I'd say you should use backlight_force_update and give BACKLIGHT_UPDATE_HOTKEY as the reason.

Oh, I see. Thank for clarifying, Cascardo.

-Yong

Hi Yong,

You can check how eeepc-laptop work for backlight stuff.
I think you should also remove all the NOTIFY_BRNDOWN_* code. It's still in eeepc-laptop for backward compatibility, but it should not be i newer drivers.

Anyway, most of the time the backlight will be handled by the acpi/video.ko driver which will
send events itself.

I will update this page soon
http://dev.iksaif.net/projects/acpi4asus/wiki/Eeepc-wmi .

Do you want this driver to be part of acpi4asus project ? It would allow to share the same git tree / bugtracker / wiki. I can give you access to all that stuff quickly. I think it would be easier for users if we merge into one single project.

Thanks for you work.

Signature · 2 lines
Corentin Chary
http://xf.iksaif.net
#9 lore raw
Quoted 12 lines · Corentin Chary

Hi Yong,

You can check how eeepc-laptop work for backlight stuff.
I think you should also remove all the NOTIFY_BRNDOWN_* code. It's still in eeepc-laptop for backward compatibility, but it should not be i newer drivers.

Anyway, most of the time the backlight will be handled by the acpi/video.ko driver which will
send events itself.

Thanks for the info. I will take a look.

Quoted 3 lines

I will update this page soon
http://dev.iksaif.net/projects/acpi4asus/wiki/Eeepc-wmi .

Yeah, I actually passed by this wiki page last week and I read the "how to help" section. I cannot donate hardware so I wrote the driver;-)

Quoted 5 lines

Do you want this driver to be part of acpi4asus project ? It would allow to share the same git tree / bugtracker / wiki. I can give you access to all that stuff quickly. I think it would be easier for users if we merge into one single project.

I have no problem. What is the relationship between acpi4asus and platform x86 drivers? Will Matthew merge your tree?

Thanks
-Yong

#10 lore raw
Quoted 23 lines · Yong Wang
Quoted 12 lines · Corentin Chary

Hi Yong,

You can check how eeepc-laptop work for backlight stuff.
I think you should also remove all the NOTIFY_BRNDOWN_* code. It's still in eeepc-laptop for backward compatibility, but it should not be i newer drivers.

Anyway, most of the time the backlight will be handled by the acpi/video.ko driver which will
send events itself.

Thanks for the info. I will take a look.

Quoted 3 lines

I will update this page soon
http://dev.iksaif.net/projects/acpi4asus/wiki/Eeepc-wmi .

Yeah, I actually passed by this wiki page last week and I read the "how to help" section. I cannot donate hardware so I wrote the driver;-)

Quoted 8 lines
Quoted 5 lines

Do you want this driver to be part of acpi4asus project ? It would allow to share the same git tree / bugtracker / wiki. I can give you access to all that stuff quickly. I think it would be easier for users if we merge into one single project.

I have no problem. What is the relationship between acpi4asus and platform x86 drivers? Will Matthew merge your tree?

Yep Matthew will merge my tree. Platform x86 subsystem is young, so it only happened once, but I think
he will continue to do so. Do you want a write access to acpi4asus tree, or do you want me to merge your tree ?

Signature · 2 lines
Corentin Chary
http://xf.iksaif.net
#11 lore raw
Quoted 6 lines · Corentin Chary

Yep Matthew will merge my tree. Platform x86 subsystem is young, so it only happened once, but I think
he will continue to do so. Do you want a write access to acpi4asus tree, or do you want me to merge your tree ?

I don't have a public tree and I don't think I need write access to your tree. I will continue to send out patches when I have time to work on it. You can pick them up into your tree if you think they look ok to you. Is that OK?

Thanks
-Yong

#12 lore raw
Quoted 8 lines · Yong Wang
Quoted 6 lines · Corentin Chary

Yep Matthew will merge my tree. Platform x86 subsystem is young, so it only happened once, but I think
he will continue to do so. Do you want a write access to acpi4asus tree, or do you want me to merge your tree ?

Quoted 8 lines

I don't have a public tree and I don't think I need write access to your tree. I will continue to send out patches when I have time to work on it. You can pick them up into your tree if you think they look ok to you. Is that OK?

Thanks
-Yong

Yep,

Signature · 2 lines
Corentin Chary
http://xf.iksaif.net