public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/02] Initial work to let ACPI buttons work over INPUT layer
@ 2008-11-29 20:34 Daniel Oliveira Nascimento
  2008-12-10  9:26 ` Timo Hoenig
  2008-12-19 16:34 ` Fwd: " Daniel Nascimento
  0 siblings, 2 replies; 11+ messages in thread
From: Daniel Oliveira Nascimento @ 2008-11-29 20:34 UTC (permalink / raw)
  To: linux-acpi, Nicolas Trangez

Updated work of Nicolas Trangez to support INPUT layer in
asus-laptop driver in git branch.

Initial discussion can be found here:
http://article.gmane.org/gmane.linux.acpi.acpi4asus.user/217

---
 drivers/misc/asus-laptop.c |  183 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 182 insertions(+), 1 deletions(-)

diff --git a/drivers/misc/asus-laptop.c b/drivers/misc/asus-laptop.c
index 8fb8b35..46db3b0 100644
--- a/drivers/misc/asus-laptop.c
+++ b/drivers/misc/asus-laptop.c
@@ -24,6 +24,7 @@
  *  http://sourceforge.net/projects/acpi4asus/
  *
  *  Credits:
+ *  Nicolas Trangez  - Initial work to let ACPI buttons work over INPUT layer
  *  Pontus Fuchs   - Helper functions, cleanup
  *  Johann Wiesner - Small compile fixes
  *  John Belmonte  - ACPI code for Toshiba laptop was a good starting point.
@@ -46,6 +47,8 @@
 #include <acpi/acpi_drivers.h>
 #include <acpi/acpi_bus.h>
 #include <asm/uaccess.h>
+#include <linux/input.h>
+#include <linux/pci_ids.h>
 
 #define ASUS_LAPTOP_VERSION "0.42"
 
@@ -250,6 +253,12 @@ ASUS_LED(rled, "record");
 ASUS_LED(pled, "phone");
 ASUS_LED(gled, "gaming");
 
+/* Input layer variables */
+static u16 *hotk_keycode_map;
+static int hotk_keycode_map_size;
+static struct input_dev *asus_hotk_inputdev;
+static int asus_hotk_inputdev_registered;
+
 /*
  * This function evaluates an ACPI method, given an int as parameter, the
  * method is searched within the scope of the handle, can be NULL. The output
@@ -722,6 +731,8 @@ static ssize_t store_gps(struct device *dev, struct device_attribute *attr,
 
 static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
 {
+	int keycode;
+
 	/* TODO Find a better way to handle events count. */
 	if (!hotk)
 		return;
@@ -738,7 +749,28 @@ static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
 		lcd_blank(FB_BLANK_POWERDOWN);
 	}
 
-	acpi_bus_generate_proc_event(hotk->device, event,
+	if (event < hotk_keycode_map_size) {
+		keycode = hotk_keycode_map[event];
+		printk("Keycode: %04x (%d)\n", keycode, keycode);
+	} else {
+		keycode = KEY_UNKNOWN;
+		printk("Scancode %d out of keymap\n", event);
+	}
+
+	if (keycode != KEY_RESERVED) {
+		input_report_key(asus_hotk_inputdev, keycode, 1);
+		if (keycode == KEY_UNKNOWN)
+			input_event(asus_hotk_inputdev, EV_MSC, MSC_SCAN, event);
+		input_sync(asus_hotk_inputdev);
+
+		input_report_key(asus_hotk_inputdev, keycode, 0);
+		if (keycode == KEY_UNKNOWN)
+			input_event(asus_hotk_inputdev, EV_MSC, MSC_SCAN, event);
+		input_sync(asus_hotk_inputdev);
+	}
+
+	if (keycode == KEY_RESERVED || keycode == KEY_UNKNOWN)
+		acpi_bus_generate_proc_event(hotk->device, event,
 				hotk->event_count[event % 128]++);
 
 	return;
@@ -1071,6 +1103,16 @@ static int asus_hotk_remove(struct acpi_device *device, int type)
 	return 0;
 }
 
+static void asus_hotk_exit(void)
+{
+	if (asus_hotk_inputdev) {
+		if (asus_hotk_inputdev_registered)
+			input_unregister_device(asus_hotk_inputdev);
+		else
+			input_free_device(asus_hotk_inputdev);
+	}
+}
+
 static void asus_backlight_exit(void)
 {
 	if (asus_backlight_device)
@@ -1095,6 +1137,7 @@ static void __exit asus_laptop_exit(void)
 {
 	asus_backlight_exit();
 	asus_led_exit();
+	asus_hotk_exit();
 
 	acpi_bus_unregister_driver(&asus_hotk_driver);
 	sysfs_remove_group(&asuspf_device->dev.kobj, &asuspf_attribute_group);
@@ -1102,6 +1145,138 @@ static void __exit asus_laptop_exit(void)
 	platform_driver_unregister(&asuspf_driver);
 }
 
+static int asus_hotk_init(void)
+{
+	int ret, i;
+
+	static u16 keycode_map_1[] __initdata = {
+		KEY_UNKNOWN, /* 0 */
+		KEY_UNKNOWN, /* 1 */
+		KEY_UNKNOWN, /* 2 */
+		KEY_UNKNOWN, /* 3 */
+		KEY_UNKNOWN, /* 4 */
+		KEY_UNKNOWN, /* 5 */
+		KEY_UNKNOWN, /* 6 */
+		KEY_UNKNOWN, /* 7 */
+		KEY_UNKNOWN, /* 8 */
+		KEY_UNKNOWN, /* 9 */
+		KEY_UNKNOWN, /* 10 */
+		KEY_UNKNOWN, /* 11 */
+		KEY_UNKNOWN, /* 12 */
+		KEY_UNKNOWN, /* 13 */
+		KEY_UNKNOWN, /* 14 */
+		KEY_UNKNOWN, /* 15 */
+		KEY_UNKNOWN, /* 16 */
+		KEY_UNKNOWN, /* 17 */
+		KEY_UNKNOWN, /* 18 */
+		KEY_UNKNOWN, /* 19 */
+		KEY_UNKNOWN, /* 20 */
+		KEY_UNKNOWN, /* 21 */
+		KEY_UNKNOWN, /* 22 */
+		KEY_UNKNOWN, /* 23 */
+		KEY_UNKNOWN, /* 24 */
+		KEY_UNKNOWN, /* 25 */
+		KEY_UNKNOWN, /* 26 */
+		KEY_UNKNOWN, /* 27 */
+		KEY_UNKNOWN, /* 28 */
+		KEY_UNKNOWN, /* 29 */
+		KEY_UNKNOWN, /* 30 */
+		KEY_UNKNOWN, /* 31 */
+		KEY_UNKNOWN, /* 32 */
+		KEY_UNKNOWN, /* 33 */
+		KEY_UNKNOWN, /* 34 */
+		KEY_UNKNOWN, /* 35 */
+		KEY_UNKNOWN, /* 36 */
+		KEY_UNKNOWN, /* 37 */
+		KEY_UNKNOWN, /* 38 */
+		KEY_UNKNOWN, /* 39 */
+		KEY_UNKNOWN, /* 40 */
+		KEY_UNKNOWN, /* 41 */
+		KEY_UNKNOWN, /* 42 */
+		KEY_UNKNOWN, /* 43 */
+		KEY_UNKNOWN, /* 44 */
+		KEY_UNKNOWN, /* 45 */
+		KEY_UNKNOWN, /* 46 */
+		KEY_UNKNOWN, /* 47 */
+		KEY_UNKNOWN, /* 48 */
+		KEY_UNKNOWN, /* 49 */
+		KEY_UNKNOWN, /* 50 */
+		KEY_UNKNOWN, /* 51 */
+		KEY_UNKNOWN, /* 52 */
+		KEY_UNKNOWN, /* 53 */
+		KEY_UNKNOWN, /* 54 */
+		KEY_UNKNOWN, /* 55 */
+		KEY_UNKNOWN, /* 56 */
+		KEY_UNKNOWN, /* 57 */
+		KEY_UNKNOWN, /* 58 */
+		KEY_UNKNOWN, /* 59 */
+		KEY_UNKNOWN, /* 60 */
+		KEY_UNKNOWN, /* 61 */
+		KEY_UNKNOWN, /* 62 */
+		KEY_UNKNOWN, /* 63 */
+		KEY_PREVIOUSSONG, /* 64 */
+		KEY_NEXTSONG, /* 65 */
+		KEY_UNKNOWN, /* 66 */
+		KEY_STOP, /* 67 */
+		KEY_UNKNOWN, /* 68 */
+		KEY_PLAYPAUSE, /* 69 */
+		KEY_UNKNOWN, /* 70 */
+	};
+
+#define ASUS_HOTK_MAP_LEN       ARRAY_SIZE(keycode_map_1)
+#define ASUS_HOTK_MAP_SIZE      sizeof(keycode_map_1)
+#define ASUS_HOTK_MAP_TYPESIZE  sizeof(keycode_map_1[0])
+
+	/* Always use first keymap. TODO make this model-specific */
+	hotk_keycode_map = kmalloc(ASUS_HOTK_MAP_SIZE, GFP_KERNEL);
+	hotk_keycode_map_size = ASUS_HOTK_MAP_LEN;
+	if (!hotk_keycode_map) {
+		printk(ASUS_ERR "failed to allocate memory for keymap\n");
+		return -ENOMEM;
+	}
+	printk(ASUS_NOTICE "using keycode_map_1\n");
+	memcpy(hotk_keycode_map, &keycode_map_1, ASUS_HOTK_MAP_SIZE);
+	/* TODO make sure no ACPI events are sent on known keycodes */
+
+	asus_hotk_inputdev = input_allocate_device();
+	if (!asus_hotk_inputdev) {
+		printk(ASUS_ERR "unable to allocate input device\n");
+		return -ENOMEM;
+	}
+	asus_hotk_inputdev->name = "Asus Extra Buttons";
+	asus_hotk_inputdev->phys = ASUS_HOTK_FILE "/input0";
+	asus_hotk_inputdev->id.bustype = BUS_HOST;
+	asus_hotk_inputdev->id.vendor = PCI_VENDOR_ID_ASUSTEK;
+	/* TODO
+	asus_hotk_inputdev->id.product =
+	asus_hotk_inputdev->id.version =
+	*/
+
+	set_bit(EV_KEY, asus_hotk_inputdev->evbit);
+	set_bit(EV_MSC, asus_hotk_inputdev->evbit);
+	set_bit(MSC_SCAN, asus_hotk_inputdev->mscbit);
+	asus_hotk_inputdev->keycodesize = ASUS_HOTK_MAP_TYPESIZE;
+	asus_hotk_inputdev->keycodemax = ASUS_HOTK_MAP_LEN;
+	asus_hotk_inputdev->keycode = hotk_keycode_map;
+	for (i = 0; i < ASUS_HOTK_MAP_LEN; i++) {
+		if (hotk_keycode_map[i] != KEY_RESERVED) {
+			set_bit(hotk_keycode_map[i], asus_hotk_inputdev->keybit);
+		} /*else {
+			if (i < sizeof(hotk_reserved_mask)*8)
+				hotk_reserved_mask |= 1 << i;
+		}*/
+	}
+
+	ret = input_register_device(asus_hotk_inputdev);
+	if (ret < 0) {
+		printk(ASUS_ERR "unable to register input device\n");
+		return ret;
+	}
+	asus_hotk_inputdev_registered = 1;
+
+	return 0;
+}
+
 static int asus_backlight_init(struct device *dev)
 {
 	struct backlight_device *bd;
@@ -1208,6 +1383,10 @@ static int __init asus_laptop_init(void)
 
 	dev = acpi_get_physical_device(hotk->device->handle);
 
+ 	result = asus_hotk_init();
+	if (result)
+		goto fail_hotk;
+
 	if (!acpi_video_backlight_support()) {
 		result = asus_backlight_init(dev);
 		if (result)
@@ -1259,6 +1438,8 @@ static int __init asus_laptop_init(void)
 
       fail_backlight:
 
+      fail_hotk:
+
 	return result;
 }
 
-- 
1.5.6

\0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 01/02] Initial work to let ACPI buttons work over INPUT layer
  2008-11-29 20:34 [PATCH 01/02] Initial work to let ACPI buttons work over INPUT layer Daniel Oliveira Nascimento
@ 2008-12-10  9:26 ` Timo Hoenig
  2008-12-10 10:31   ` Corentin Chary
  2008-12-19 16:34 ` Fwd: " Daniel Nascimento
  1 sibling, 1 reply; 11+ messages in thread
From: Timo Hoenig @ 2008-12-10  9:26 UTC (permalink / raw)
  To: dnascimento, corentincj, sziwan; +Cc: linux-acpi, Nicolas Trangez

Hi!

On Sat, 2008-11-29 at 18:34 -0200, Daniel Oliveira Nascimento wrote:

> Updated work of Nicolas Trangez to support INPUT layer in
> asus-laptop driver in git branch.
> 
> Initial discussion can be found here:
> http://article.gmane.org/gmane.linux.acpi.acpi4asus.user/217

Daniel, Nicolas, thanks for the two patches.

I've been testing your patches on two systems (c.f.
https://bugzilla.novell.com/show_bug.cgi?id=448004 ) and confirm that
they just work fine.

Has there been any response regarding an mainline inclusion?  I'm just
following linux-acpi.  At least there didn't see any response.

Adding Corentin and Karol to CC.

Thanks,

   Timo


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 01/02] Initial work to let ACPI buttons work over INPUT layer
  2008-12-10  9:26 ` Timo Hoenig
@ 2008-12-10 10:31   ` Corentin Chary
  2008-12-10 10:45     ` Timo Hoenig
  0 siblings, 1 reply; 11+ messages in thread
From: Corentin Chary @ 2008-12-10 10:31 UTC (permalink / raw)
  To: Timo Hoenig; +Cc: dnascimento, corentincj, sziwan, linux-acpi, Nicolas Trangez

On Wednesday 10 December 2008 10:26:05 Timo Hoenig wrote:
> Hi!
>
> On Sat, 2008-11-29 at 18:34 -0200, Daniel Oliveira Nascimento wrote:
> > Updated work of Nicolas Trangez to support INPUT layer in
> > asus-laptop driver in git branch.
> >
> > Initial discussion can be found here:
> > http://article.gmane.org/gmane.linux.acpi.acpi4asus.user/217
>
> Daniel, Nicolas, thanks for the two patches.
>
> I've been testing your patches on two systems (c.f.
> https://bugzilla.novell.com/show_bug.cgi?id=448004 ) and confirm that
> they just work fine.
>
> Has there been any response regarding an mainline inclusion?  I'm just
> following linux-acpi.  At least there didn't see any response.

For mainline inclusion you should:
- CC Len Brown when sending the patch
- Maybe send only the final patch and give credits to Nicolas in the changelog, 
but not sure.

Anyway thanks for the patchs :)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 01/02] Initial work to let ACPI buttons work over INPUT layer
  2008-12-10 10:31   ` Corentin Chary
@ 2008-12-10 10:45     ` Timo Hoenig
  0 siblings, 0 replies; 11+ messages in thread
From: Timo Hoenig @ 2008-12-10 10:45 UTC (permalink / raw)
  To: Corentin Chary
  Cc: dnascimento, corentincj, sziwan, linux-acpi, Nicolas Trangez

Hi!

On Wed, 2008-12-10 at 11:31 +0100, Corentin Chary wrote:
> F

> or mainline inclusion you should:
> - CC Len Brown when sending the patch
> - Maybe send only the final patch and give credits to Nicolas in the
> changelog, but not sure.
> 
> Anyway thanks for the patchs :)

Daniel, Nicolas, would you mind to do so?

Feel free to add a

    Tested-by: Timo Hoenig <thoenig@suse.de>

tag to the patch.

Thanks!

   Timo


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Fwd: [PATCH 01/02] Initial work to let ACPI buttons work over INPUT layer
  2008-11-29 20:34 [PATCH 01/02] Initial work to let ACPI buttons work over INPUT layer Daniel Oliveira Nascimento
  2008-12-10  9:26 ` Timo Hoenig
@ 2008-12-19 16:34 ` Daniel Nascimento
  2009-01-07 11:38   ` Timo Hoenig
  1 sibling, 1 reply; 11+ messages in thread
From: Daniel Nascimento @ 2008-12-19 16:34 UTC (permalink / raw)
  To: lenb, Nicolas Trangez, corentincj, sziwan, Timo Hoenig,
	linux-acpi

Please apply this patch in mainstream. The code was tested by Timo
Hoenig and more info can be found this list and here:
https://bugzilla.novell.com/show_bug.cgi?id=448004


---------- Forwarded message ----------
From: Daniel Oliveira Nascimento <dnascimento@gmail.com>
Date: 2008/11/29
Subject: [PATCH 01/02] Initial work to let ACPI buttons work over INPUT layer
To: linux-acpi@vger.kernel.org, Nicolas Trangez <ikke@nicolast.be>


Updated work of Nicolas Trangez to support INPUT layer in
asus-laptop driver in git branch.

Initial discussion can be found here:
http://article.gmane.org/gmane.linux.acpi.acpi4asus.user/217

---
 drivers/misc/asus-laptop.c |  183 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 182 insertions(+), 1 deletions(-)

diff --git a/drivers/misc/asus-laptop.c b/drivers/misc/asus-laptop.c
index 8fb8b35..46db3b0 100644
--- a/drivers/misc/asus-laptop.c
+++ b/drivers/misc/asus-laptop.c
@@ -24,6 +24,7 @@
 *  http://sourceforge.net/projects/acpi4asus/
 *
 *  Credits:
+ *  Nicolas Trangez  - Initial work to let ACPI buttons work over INPUT layer
 *  Pontus Fuchs   - Helper functions, cleanup
 *  Johann Wiesner - Small compile fixes
 *  John Belmonte  - ACPI code for Toshiba laptop was a good starting point.
@@ -46,6 +47,8 @@
 #include <acpi/acpi_drivers.h>
 #include <acpi/acpi_bus.h>
 #include <asm/uaccess.h>
+#include <linux/input.h>
+#include <linux/pci_ids.h>

 #define ASUS_LAPTOP_VERSION "0.42"

@@ -250,6 +253,12 @@ ASUS_LED(rled, "record");
 ASUS_LED(pled, "phone");
 ASUS_LED(gled, "gaming");

+/* Input layer variables */
+static u16 *hotk_keycode_map;
+static int hotk_keycode_map_size;
+static struct input_dev *asus_hotk_inputdev;
+static int asus_hotk_inputdev_registered;
+
 /*
 * This function evaluates an ACPI method, given an int as parameter, the
 * method is searched within the scope of the handle, can be NULL. The output
@@ -722,6 +731,8 @@ static ssize_t store_gps(struct device *dev,
struct device_attribute *attr,

 static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
 {
+       int keycode;
+
       /* TODO Find a better way to handle events count. */
       if (!hotk)
               return;
@@ -738,7 +749,28 @@ static void asus_hotk_notify(acpi_handle handle,
u32 event, void *data)
               lcd_blank(FB_BLANK_POWERDOWN);
       }

-       acpi_bus_generate_proc_event(hotk->device, event,
+       if (event < hotk_keycode_map_size) {
+               keycode = hotk_keycode_map[event];
+               printk("Keycode: %04x (%d)\n", keycode, keycode);
+       } else {
+               keycode = KEY_UNKNOWN;
+               printk("Scancode %d out of keymap\n", event);
+       }
+
+       if (keycode != KEY_RESERVED) {
+               input_report_key(asus_hotk_inputdev, keycode, 1);
+               if (keycode == KEY_UNKNOWN)
+                       input_event(asus_hotk_inputdev, EV_MSC,
MSC_SCAN, event);
+               input_sync(asus_hotk_inputdev);
+
+               input_report_key(asus_hotk_inputdev, keycode, 0);
+               if (keycode == KEY_UNKNOWN)
+                       input_event(asus_hotk_inputdev, EV_MSC,
MSC_SCAN, event);
+               input_sync(asus_hotk_inputdev);
+       }
+
+       if (keycode == KEY_RESERVED || keycode == KEY_UNKNOWN)
+               acpi_bus_generate_proc_event(hotk->device, event,
                               hotk->event_count[event % 128]++);

       return;
@@ -1071,6 +1103,16 @@ static int asus_hotk_remove(struct acpi_device
*device, int type)
       return 0;
 }

+static void asus_hotk_exit(void)
+{
+       if (asus_hotk_inputdev) {
+               if (asus_hotk_inputdev_registered)
+                       input_unregister_device(asus_hotk_inputdev);
+               else
+                       input_free_device(asus_hotk_inputdev);
+       }
+}
+
 static void asus_backlight_exit(void)
 {
       if (asus_backlight_device)
@@ -1095,6 +1137,7 @@ static void __exit asus_laptop_exit(void)
 {
       asus_backlight_exit();
       asus_led_exit();
+       asus_hotk_exit();

       acpi_bus_unregister_driver(&asus_hotk_driver);
       sysfs_remove_group(&asuspf_device->dev.kobj, &asuspf_attribute_group);
@@ -1102,6 +1145,138 @@ static void __exit asus_laptop_exit(void)
       platform_driver_unregister(&asuspf_driver);
 }

+static int asus_hotk_init(void)
+{
+       int ret, i;
+
+       static u16 keycode_map_1[] __initdata = {
+               KEY_UNKNOWN, /* 0 */
+               KEY_UNKNOWN, /* 1 */
+               KEY_UNKNOWN, /* 2 */
+               KEY_UNKNOWN, /* 3 */
+               KEY_UNKNOWN, /* 4 */
+               KEY_UNKNOWN, /* 5 */
+               KEY_UNKNOWN, /* 6 */
+               KEY_UNKNOWN, /* 7 */
+               KEY_UNKNOWN, /* 8 */
+               KEY_UNKNOWN, /* 9 */
+               KEY_UNKNOWN, /* 10 */
+               KEY_UNKNOWN, /* 11 */
+               KEY_UNKNOWN, /* 12 */
+               KEY_UNKNOWN, /* 13 */
+               KEY_UNKNOWN, /* 14 */
+               KEY_UNKNOWN, /* 15 */
+               KEY_UNKNOWN, /* 16 */
+               KEY_UNKNOWN, /* 17 */
+               KEY_UNKNOWN, /* 18 */
+               KEY_UNKNOWN, /* 19 */
+               KEY_UNKNOWN, /* 20 */
+               KEY_UNKNOWN, /* 21 */
+               KEY_UNKNOWN, /* 22 */
+               KEY_UNKNOWN, /* 23 */
+               KEY_UNKNOWN, /* 24 */
+               KEY_UNKNOWN, /* 25 */
+               KEY_UNKNOWN, /* 26 */
+               KEY_UNKNOWN, /* 27 */
+               KEY_UNKNOWN, /* 28 */
+               KEY_UNKNOWN, /* 29 */
+               KEY_UNKNOWN, /* 30 */
+               KEY_UNKNOWN, /* 31 */
+               KEY_UNKNOWN, /* 32 */
+               KEY_UNKNOWN, /* 33 */
+               KEY_UNKNOWN, /* 34 */
+               KEY_UNKNOWN, /* 35 */
+               KEY_UNKNOWN, /* 36 */
+               KEY_UNKNOWN, /* 37 */
+               KEY_UNKNOWN, /* 38 */
+               KEY_UNKNOWN, /* 39 */
+               KEY_UNKNOWN, /* 40 */
+               KEY_UNKNOWN, /* 41 */
+               KEY_UNKNOWN, /* 42 */
+               KEY_UNKNOWN, /* 43 */
+               KEY_UNKNOWN, /* 44 */
+               KEY_UNKNOWN, /* 45 */
+               KEY_UNKNOWN, /* 46 */
+               KEY_UNKNOWN, /* 47 */
+               KEY_UNKNOWN, /* 48 */
+               KEY_UNKNOWN, /* 49 */
+               KEY_UNKNOWN, /* 50 */
+               KEY_UNKNOWN, /* 51 */
+               KEY_UNKNOWN, /* 52 */
+               KEY_UNKNOWN, /* 53 */
+               KEY_UNKNOWN, /* 54 */
+               KEY_UNKNOWN, /* 55 */
+               KEY_UNKNOWN, /* 56 */
+               KEY_UNKNOWN, /* 57 */
+               KEY_UNKNOWN, /* 58 */
+               KEY_UNKNOWN, /* 59 */
+               KEY_UNKNOWN, /* 60 */
+               KEY_UNKNOWN, /* 61 */
+               KEY_UNKNOWN, /* 62 */
+               KEY_UNKNOWN, /* 63 */
+               KEY_PREVIOUSSONG, /* 64 */
+               KEY_NEXTSONG, /* 65 */
+               KEY_UNKNOWN, /* 66 */
+               KEY_STOP, /* 67 */
+               KEY_UNKNOWN, /* 68 */
+               KEY_PLAYPAUSE, /* 69 */
+               KEY_UNKNOWN, /* 70 */
+       };
+
+#define ASUS_HOTK_MAP_LEN       ARRAY_SIZE(keycode_map_1)
+#define ASUS_HOTK_MAP_SIZE      sizeof(keycode_map_1)
+#define ASUS_HOTK_MAP_TYPESIZE  sizeof(keycode_map_1[0])
+
+       /* Always use first keymap. TODO make this model-specific */
+       hotk_keycode_map = kmalloc(ASUS_HOTK_MAP_SIZE, GFP_KERNEL);
+       hotk_keycode_map_size = ASUS_HOTK_MAP_LEN;
+       if (!hotk_keycode_map) {
+               printk(ASUS_ERR "failed to allocate memory for keymap\n");
+               return -ENOMEM;
+       }
+       printk(ASUS_NOTICE "using keycode_map_1\n");
+       memcpy(hotk_keycode_map, &keycode_map_1, ASUS_HOTK_MAP_SIZE);
+       /* TODO make sure no ACPI events are sent on known keycodes */
+
+       asus_hotk_inputdev = input_allocate_device();
+       if (!asus_hotk_inputdev) {
+               printk(ASUS_ERR "unable to allocate input device\n");
+               return -ENOMEM;
+       }
+       asus_hotk_inputdev->name = "Asus Extra Buttons";
+       asus_hotk_inputdev->phys = ASUS_HOTK_FILE "/input0";
+       asus_hotk_inputdev->id.bustype = BUS_HOST;
+       asus_hotk_inputdev->id.vendor = PCI_VENDOR_ID_ASUSTEK;
+       /* TODO
+       asus_hotk_inputdev->id.product =
+       asus_hotk_inputdev->id.version =
+       */
+
+       set_bit(EV_KEY, asus_hotk_inputdev->evbit);
+       set_bit(EV_MSC, asus_hotk_inputdev->evbit);
+       set_bit(MSC_SCAN, asus_hotk_inputdev->mscbit);
+       asus_hotk_inputdev->keycodesize = ASUS_HOTK_MAP_TYPESIZE;
+       asus_hotk_inputdev->keycodemax = ASUS_HOTK_MAP_LEN;
+       asus_hotk_inputdev->keycode = hotk_keycode_map;
+       for (i = 0; i < ASUS_HOTK_MAP_LEN; i++) {
+               if (hotk_keycode_map[i] != KEY_RESERVED) {
+                       set_bit(hotk_keycode_map[i],
asus_hotk_inputdev->keybit);
+               } /*else {
+                       if (i < sizeof(hotk_reserved_mask)*8)
+                               hotk_reserved_mask |= 1 << i;
+               }*/
+       }
+
+       ret = input_register_device(asus_hotk_inputdev);
+       if (ret < 0) {
+               printk(ASUS_ERR "unable to register input device\n");
+               return ret;
+       }
+       asus_hotk_inputdev_registered = 1;
+
+       return 0;
+}
+
 static int asus_backlight_init(struct device *dev)
 {
       struct backlight_device *bd;
@@ -1208,6 +1383,10 @@ static int __init asus_laptop_init(void)

       dev = acpi_get_physical_device(hotk->device->handle);

+       result = asus_hotk_init();
+       if (result)
+               goto fail_hotk;
+
       if (!acpi_video_backlight_support()) {
               result = asus_backlight_init(dev);
               if (result)
@@ -1259,6 +1438,8 @@ static int __init asus_laptop_init(void)

      fail_backlight:

+      fail_hotk:
+
       return result;
 }

--
1.5.6

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: Fwd: [PATCH 01/02] Initial work to let ACPI buttons work over INPUT layer
  2008-12-19 16:34 ` Fwd: " Daniel Nascimento
@ 2009-01-07 11:38   ` Timo Hoenig
  2009-01-12 11:59     ` Corentin Chary
  0 siblings, 1 reply; 11+ messages in thread
From: Timo Hoenig @ 2009-01-07 11:38 UTC (permalink / raw)
  To: lenb; +Cc: Nicolas Trangez, corentincj, sziwan, linux-acpi,
	Daniel Nascimento

Hi Len, Corentin,

On Fri, 2008-12-19 at 14:34 -0200, Daniel Nascimento wrote:

> Please apply this patch in mainstream.

Would you mind having a look at the Daniel's and Nicolas' patches?

This is sitting here now for quite some time without any obvious reason
why it shouldn't be merged for 2.6.29.

Thanks,

   Timo


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Fwd: [PATCH 01/02] Initial work to let ACPI buttons work over INPUT layer
  2009-01-07 11:38   ` Timo Hoenig
@ 2009-01-12 11:59     ` Corentin Chary
  2009-01-12 12:00       ` Corentin Chary
  0 siblings, 1 reply; 11+ messages in thread
From: Corentin Chary @ 2009-01-12 11:59 UTC (permalink / raw)
  To: Timo Hoenig; +Cc: lenb, Nicolas Trangez, sziwan, linux-acpi, Daniel Nascimento

On Wed, Jan 7, 2009 at 12:38 PM, Timo Hoenig <thoenig@nouse.net> wrote:
> Hi Len, Corentin,
>
> On Fri, 2008-12-19 at 14:34 -0200, Daniel Nascimento wrote:
>
>> Please apply this patch in mainstream.
>
> Would you mind having a look at the Daniel's and Nicolas' patches?
>
> This is sitting here now for quite some time without any obvious reason
> why it shouldn't be merged for 2.6.29.
>
> Thanks,
>
>   Timo
>
>

Hi,
Sorry, I completly miss this mail.
I don't think this patch is ok, things should be done in cleaner way,
like it's eeepc-laptop.
Daniel, Nicolas, can you try to do that ?
If you don't have the time, just tell me and I'll try to find the time
to do it ASAP.
Thanks


-- 
Corentin Chary
http://xf.iksaif.net

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Fwd: [PATCH 01/02] Initial work to let ACPI buttons work over INPUT layer
  2009-01-12 11:59     ` Corentin Chary
@ 2009-01-12 12:00       ` Corentin Chary
  2009-01-14  9:57         ` Corentin Chary
  0 siblings, 1 reply; 11+ messages in thread
From: Corentin Chary @ 2009-01-12 12:00 UTC (permalink / raw)
  To: Timo Hoenig; +Cc: lenb, Nicolas Trangez, sziwan, linux-acpi, Daniel Nascimento

> I don't think this patch is ok, things should be done in cleaner way,
> like it's eeepc-laptop.
Sorry : like it's done in eeepc-laptop.

Take a look at struct eeepc_keymap and eeepc_hotk_notitfy().


-- 
Corentin Chary
http://xf.iksaif.net

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Fwd: [PATCH 01/02] Initial work to let ACPI buttons work over INPUT layer
  2009-01-12 12:00       ` Corentin Chary
@ 2009-01-14  9:57         ` Corentin Chary
  2009-01-14 12:05           ` Daniel Nascimento
  2009-01-15 12:31           ` Fabien Crespel
  0 siblings, 2 replies; 11+ messages in thread
From: Corentin Chary @ 2009-01-14  9:57 UTC (permalink / raw)
  To: Timo Hoenig
  Cc: Nicolas Trangez, sziwan, linux-acpi, Daniel Nascimento,
	acpi4asus-user

Hi,
Just done a patch based on eeepc-laptop.
You can get it there:
http://git.iksaif.net/?p=acpi4asus.git;a=shortlog;h=refs/heads/asus-laptop-input
I didn't test it yet, I'll only have my laptops this weekend.
Could you test it please ?
Thanks

-- 
Corentin Chary
http://xf.iksaif.net

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Fwd: [PATCH 01/02] Initial work to let ACPI buttons work over INPUT layer
  2009-01-14  9:57         ` Corentin Chary
@ 2009-01-14 12:05           ` Daniel Nascimento
  2009-01-15 12:31           ` Fabien Crespel
  1 sibling, 0 replies; 11+ messages in thread
From: Daniel Nascimento @ 2009-01-14 12:05 UTC (permalink / raw)
  To: Corentin Chary
  Cc: Timo Hoenig, Nicolas Trangez, sziwan, linux-acpi, acpi4asus-user

Hi,

I tested your patch now with my asus m51sn and suse kernel 2.6.27, it worked.

Thanks,
Daniel Oliveira Nascimento

2009/1/14 Corentin Chary <corentin.chary@gmail.com>:
> Hi,
> Just done a patch based on eeepc-laptop.
> You can get it there:
> http://git.iksaif.net/?p=acpi4asus.git;a=shortlog;h=refs/heads/asus-laptop-input
> I didn't test it yet, I'll only have my laptops this weekend.
> Could you test it please ?
> Thanks
>
> --
> Corentin Chary
> http://xf.iksaif.net
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Fwd: [PATCH 01/02] Initial work to let ACPI buttons work over INPUT layer
  2009-01-14  9:57         ` Corentin Chary
  2009-01-14 12:05           ` Daniel Nascimento
@ 2009-01-15 12:31           ` Fabien Crespel
  1 sibling, 0 replies; 11+ messages in thread
From: Fabien Crespel @ 2009-01-15 12:31 UTC (permalink / raw)
  To: Corentin Chary
  Cc: Timo Hoenig, Nicolas Trangez, sziwan, linux-acpi,
	Daniel Nascimento, acpi4asus-user

Corentin Chary wrote:
> Hi,
> Just done a patch based on eeepc-laptop.
> You can get it there:
> http://git.iksaif.net/?p=acpi4asus.git;a=shortlog;h=refs/heads/asus-laptop-input
> I didn't test it yet, I'll only have my laptops this weekend.
> Could you test it please ?
> Thanks
> 

Hello,

I haven't tested this patch, but there is a mistake in the keymap here:

{KE_KEY, 0x7D, KEY_BLUETOOTH}, /* Bluetooth up */
{KE_KEY, 0x7E, KEY_BLUETOOTH}, /* Bluetooth down */

These are not keys, they are notifications that occur *after* the bluetooth state
is changed by the firmware (by pressing the bluetooth key on some models, for
example). Therefore, they should not be reported to the input layer.

There is also a 0x88 scancode for the radio key on some models. On Windows, this
key cycles through radio states: WLAN + BT => WLAN => BT => None. AFAIK there is
no equivalent on Linux yet for such a key... What would be best to do to support it?

- Fabien.


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2009-01-15 12:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-29 20:34 [PATCH 01/02] Initial work to let ACPI buttons work over INPUT layer Daniel Oliveira Nascimento
2008-12-10  9:26 ` Timo Hoenig
2008-12-10 10:31   ` Corentin Chary
2008-12-10 10:45     ` Timo Hoenig
2008-12-19 16:34 ` Fwd: " Daniel Nascimento
2009-01-07 11:38   ` Timo Hoenig
2009-01-12 11:59     ` Corentin Chary
2009-01-12 12:00       ` Corentin Chary
2009-01-14  9:57         ` Corentin Chary
2009-01-14 12:05           ` Daniel Nascimento
2009-01-15 12:31           ` Fabien Crespel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox