Skip to contentSkip to conversation

ACPI: Platform driver to support App Hot Startup (PNP0C32)

PATCH In review Ângelo Miguel Arrifano 5 participants 18 messages Mar 14, 2008 – Aug 31, 2008 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: Platform driver to support App Hot Startup (PNP0C32)

Here is the patch made from the today linux-acpi tree.

Thanks,
Angelo Arrifano

drivers/acpi/Kconfig +8 -0
index f688c21..fb096ee 100644
@@ -196,6 +196,14 @@ config ACPI_THERMAL
 	  recommended that this option be enabled, as your processor(s)
 	  may be damaged without it.
 
+config ACPI_QUICKSTART
+	tristate "Quickstart"
+	default y
+	help
+	  This driver add support for ACPI Direct Application Launch
+	  also known as Hotstart(TM). Say yes here to have a entry in
+	  sysfs telling which button was used to turn on the system.
+
 config ACPI_NUMA
 	bool "NUMA support"
 	depends on NUMA
drivers/acpi/Makefile +1 -0
index f29812a..badb0a6 100644
@@ -62,3 +62,4 @@ obj-$(CONFIG_ACPI_HOTPLUG_MEMORY)	+= acpi_memhotplug.o
 obj-$(CONFIG_ACPI_PROCFS_POWER)	+= cm_sbs.o
 obj-$(CONFIG_ACPI_SBS)		+= sbs.o
 obj-$(CONFIG_ACPI_SBS)		+= sbshc.o
+obj-$(CONFIG_ACPI_QUICKSTART)	+= quickstart.o
drivers/acpi/quickstart.c new file +418 -0

418 lines not on this page · raw message

#1 lore raw

Hi, Angelo,

Quoted 4 lines · Ângelo Miguel Arrifano

Here is the patch made from the today linux-acpi tree.

Thanks,
Angelo Arrifano

we'd better add the change log here.
Some introductions about PNP0C32 device would be great.

Quoted 82 lines
drivers/acpi/Kconfig +8 -0
index f688c21..fb096ee 100644
@@ -196,6 +196,14 @@ config ACPI_THERMAL
          recommended that this option be enabled, as your
 processor(s)
          may be damaged without it.
 
+config ACPI_QUICKSTART
+       tristate "Quickstart"
+       default y
+       help
+         This driver add support for ACPI Direct Application Launch
+         also known as Hotstart(TM). Say yes here to have a entry in
+         sysfs telling which button was used to turn on the system.
+
 config ACPI_NUMA
        bool "NUMA support"

depends on NUMA

drivers/acpi/Makefile +0 -0
index f29812a..badb0a6 100644
@@ -62,3 +62,4 @@ obj-$(CONFIG_ACPI_HOTPLUG_MEMORY)     +=

acpi_memhotplug.o
obj-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o
obj-$(CONFIG_ACPI_SBS) += sbs.o
obj-$(CONFIG_ACPI_SBS) += sbshc.o

drivers/acpi/Makefile +1 -0
+obj-$(CONFIG_ACPI_QUICKSTART)  += quickstart.o
drivers/acpi/quickstart.c new file +11 -0
new file mode 100644
index 0000000..a4726f8
@@ -0,0 +1,418 @@
+/*
+ *  quickstart.c - ACPI Direct App Launch driver
+ *
+ *
+ *  Copyright (C) 2007 Angelo Arrifano <[email protected]>
+ *
+ *  Information gathered from disassebled dsdt and from here:
+ *  "http://download.microsoft.com/download/9/c/5/
+ *  9c5b2167-8017-4bae-9fde-d599bac8184a/DirAppLaunch_Vista.doc"
+ *
+ *  This program is free software; you can redistribute it and/or

modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *

+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA

02111-1307 USA
+ *
+ */

drivers/acpi/quickstart.c new file +18 -0
+
+#define QUICKSTART_VERSION "1.00"
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <acpi/acpi_drivers.h>
+#include <linux/platform_device.h>
+
+MODULE_AUTHOR("Angelo Arrifano");
+MODULE_DESCRIPTION("ACPI Direct App Launch driver");
+MODULE_LICENSE("GPL");
+
+static int enable_runtime_btns;
+module_param(enable_runtime_btns, int, 0);
+MODULE_PARM_DESC(enable_runtime_btns,
+                       "Enable reporting of runtime button presses
Quoted 1 line

(hotkeys).\n");

"enable_runtime_btns" is useless in this patch.

Quoted 179 lines
drivers/acpi/quickstart.c new file +34 -0
+
+#define QUICKSTART_ACPI_DEVICE_NAME   "quickstart"
+#define QUICKSTART_ACPI_CLASS         "quickstart"
+#define QUICKSTART_ACPI_HID           "PNP0C32"
+
+#define QUICKSTART_PF_DRIVER_NAME     "quickstart"
+#define QUICKSTART_PF_DEVICE_NAME     "quickstart"
+#define QUICKSTART_PF_DEVATTR_NAME    "pressed_button"
+
+#define QUICKSTART_MAX_BTN_NAME_LEN   16
+
+struct quickstart_btn_list {
+       char *name;
+       struct quickstart_btn_list *next;
+};
+
+static struct quickstart_driver_data {
+       struct quickstart_btn_list *btn_lst;
+       struct quickstart_btn_list *pressed;
+} quickstart_data = {
+       .btn_lst = NULL,
+       .pressed = NULL,
+};
+
+/*
+ * ACPI driver Structs
+ */
+
+struct quickstart_acpi {
+       struct acpi_device *device;
+       struct quickstart_btn_list *btn;
+};
+static int quickstart_acpi_add(struct acpi_device *device);
+static int quickstart_acpi_remove(struct acpi_device *device, int

type);

drivers/acpi/quickstart.c new file +44 -0
+static const struct acpi_device_id  quickstart_device_ids[] = {
+       {QUICKSTART_ACPI_HID, 0},
+       {"", 0},
+};
+
+static struct acpi_driver quickstart_acpi_driver = {
+       .name = "quickstart",
+       .class = QUICKSTART_ACPI_CLASS,
+       .ids = quickstart_device_ids,
+       .ops = {
+                       .add = quickstart_acpi_add,
+                       .remove = quickstart_acpi_remove,
+               },
+};
+
+/*
+ * Platform driver structs
+ */
+static ssize_t buttons_show(struct device *dev,
+                                       struct device_attribute *attr,
+                                       char *buf);
+static ssize_t pressed_button_show(struct device *dev,
+                                       struct device_attribute *attr,
+                                       char *buf);
+static ssize_t pressed_button_store(struct device *dev,
+                                       struct device_attribute *attr,
+                                        const char *buf,
+                                        size_t count);
+static DEVICE_ATTR(pressed_button, 0666, pressed_button_show,
+                                        pressed_button_store);
+static DEVICE_ATTR(buttons, 0444, buttons_show, NULL);
+static struct platform_device *pf_device;
+static struct platform_driver pf_driver = {
+       .driver = {
+               .name = QUICKSTART_PF_DRIVER_NAME,
+               .owner = THIS_MODULE,
+       }
+};
+
+/*
+ * Platform driver functions
+ */
+static ssize_t buttons_show(struct device *dev,
+                                        struct device_attribute

*attr,

drivers/acpi/quickstart.c new file +12 -0
+                                        char *buf)
+{
+       int count = 0;
+       char tmpbuf[QUICKSTART_MAX_BTN_NAME_LEN + 2];
+       struct quickstart_btn_list *ptr = quickstart_data.btn_lst;
+      
+       if(!ptr)
+               return snprintf(buf, PAGE_SIZE, "none");
+
+       while(ptr && (count < PAGE_SIZE)){
+               if(ptr->name){
+                       strncpy(tmpbuf, ptr->name,

QUICKSTART_MAX_BTN_NAME_LEN);

drivers/acpi/quickstart.c new file +17 -0
+                       strcat(tmpbuf, "\n");
+                       count += snprintf(buf + count,
+                                       PAGE_SIZE - count,
+                                       tmpbuf);
+               }
+               ptr = ptr->next;
+       }
+      
+       return count;
+}
+
+static ssize_t pressed_button_show(struct device *dev,
+                                       struct device_attribute *attr,
+                                       char *buf)
+{
+       return snprintf(buf, PAGE_SIZE, "%s\n",
+

(quickstart_data.pressed?quickstart_data.pressed->name:"none"));

drivers/acpi/quickstart.c new file +5 -0
+}
+
+
+static ssize_t pressed_button_store(struct device *dev,
+                                        struct device_attribute

*attr,
+ const char *buf, size_t
count)

drivers/acpi/quickstart.c new file +20 -0
+{
+       if(count < 2)
+               return -EINVAL;
+
+       if(strncasecmp(buf, "none", 4) != 0)
+               return -EINVAL;
+
+       quickstart_data.pressed = NULL;
+       return count;
+}
+
+/* Hotstart Helper functions */
+static int quickstart_btnlst_add(struct quickstart_btn_list **data)
+{
+       struct quickstart_btn_list **ptr = &quickstart_data.btn_lst;
+      
+       while(*ptr)
+               ptr = &((*ptr)->next);
+              
+       *ptr = kzalloc(sizeof(struct quickstart_btn_list),

GFP_KERNEL);

drivers/acpi/quickstart.c new file +30 -0
+       if(!*ptr){
+               *data = NULL;
+               return(-ENOMEM);
+       }
+       *data = *ptr;
+
+       return 0;
+}
+
+static void quickstart_btnlst_free(void)
+{
+       struct quickstart_btn_list *ptr = quickstart_data.btn_lst;
+       struct quickstart_btn_list *lptr = NULL;
+      
+       if(!ptr)
+               return;
+
+       while(ptr){
+               lptr = ptr;
+               ptr = ptr->next;
+               if(lptr->name)
+                       kfree(lptr->name);
+               kfree(lptr);
+       }
+      
+       return;
+}
+
+/* ACPI Driver functions */
+static void quickstart_acpi_notify(acpi_handle handle, u32 event,

void *data)

drivers/acpi/quickstart.c new file +8 -0
+{
+       struct quickstart_acpi *quickstart = data;
+
+       if (!quickstart)
+               return;
+
+       /* There will be two events:
+        * 0x02 - A quickstart button was pressed while device was
Quoted 4 lines

off/sleeping.
+ * 0x08 - A quickstart button was pressed while device was up.
*/
+ if((event|0x02) == event){

This is wrong.
If only two events are supported, it should be either 0x02 or 0x08. Checking bit 1 doesn't make sense here.

Quoted 7 lines
drivers/acpi/quickstart.c new file +3 -0
+               quickstart_data.pressed = quickstart->btn;
+               printk("quickstart: Quickbutton %s pressed.\n",
+

acpi_device_bid(quickstart->device));

drivers/acpi/quickstart.c new file +3 -0
+       }
+
+       if(enable_runtime_btns && (event|0x08) == event){

...

drivers/acpi/quickstart.c line 201

Quoted 9 lines
drivers/acpi/quickstart.c new file +2 -0
+               printk("quickstart: Hotkey %s pressed.\n",
+

acpi_device_bid(quickstart->device));

drivers/acpi/quickstart.c new file +5 -0
+       }
+
 
+       return;
+}
+

at least we should export a notification to user space in the notify handler.

drivers/acpi/quickstart.c line 240

Quoted 12 lines

+static void quickstart_acpi_raise_notify(struct quickstart_acpi *quickstart)

drivers/acpi/quickstart.c new file +10 -0
+{
+       acpi_status status;
+
+       /* TODO:
+        * We should receive a buffer telling the kind of button,
+        * eg: dvd, printer, www, ...
+        * but we dont care about it now. The important is to trigger
+        * pending notify events (The ones before booting). */
+       status = acpi_evaluate_object(quickstart->device->handle,
+                                       "GHID", NULL, NULL);

It's wrong as GHID returns a buffer.

Quoted 126 lines
drivers/acpi/quickstart.c new file +2 -0
+       if(ACPI_FAILURE(status))
+               printk("quickstart: Warning: GHID method failed,

events of pressed buttons may have been lost.\n");

drivers/acpi/quickstart.c new file +5 -0
+
+       return;
+}
+
+static int quickstart_acpi_config(struct quickstart_acpi *quickstart,

char *bid)

drivers/acpi/quickstart.c new file +29 -0
+{
+       int len = strlen(bid);
+       int ret;
+
+       /* Add button to list */
+       ret = quickstart_btnlst_add(&quickstart->btn);
+       if(ret)
+               return ret;
+      
+       quickstart->btn->name = kzalloc(len + 1, GFP_KERNEL);
+       if(!quickstart->btn->name){
+               quickstart_btnlst_free();
+               return -ENOMEM;
+       }
+       strcpy(quickstart->btn->name, bid);
+
+       return 0;
+}
+
+static int quickstart_acpi_add(struct acpi_device *device)
+{
+       int ret = 0;
+       acpi_status status = AE_OK;
+       struct quickstart_acpi *quickstart = NULL;     
+
+       if (!device)
+               return -EINVAL;
+
+       quickstart = kzalloc(sizeof(struct quickstart_acpi),

GFP_KERNEL);

drivers/acpi/quickstart.c new file +10 -0
+       if (!quickstart)
+               return -ENOMEM;
+
+       quickstart->device = device;
+       strcpy(acpi_device_name(device), QUICKSTART_ACPI_DEVICE_NAME);
+       strcpy(acpi_device_class(device), QUICKSTART_ACPI_CLASS);
+       acpi_driver_data(device) = quickstart;
+      
+       /* Add button to list and initialize some stuff */
+       ret = quickstart_acpi_config(quickstart,

acpi_device_bid(device));

drivers/acpi/quickstart.c new file +6 -0
+       if(ret)
+               goto fail_config;
+
+       status = acpi_install_notify_handler(device->handle,
+                                                ACPI_ALL_NOTIFY,
+

quickstart_acpi_notify, quickstart);

drivers/acpi/quickstart.c new file +2 -0
+       if(ACPI_FAILURE(status)){
+               printk("quickstart: Error installing notify handler

\n");

drivers/acpi/quickstart.c new file +5 -0
+               ret = -ENODEV;
+               goto fail_installnotify;
+       }      
+
+       /* Call device GHID method. This is a workaround to get a

notify
+ * event when hot button is pressed while laptop is powered
off.

drivers/acpi/quickstart.c new file +14 -0
+        * This works, even if the method fails. */
+       quickstart_acpi_raise_notify(quickstart);
+
+       return 0;
+
+fail_installnotify:
+fail_config:
+
+       kfree(quickstart);
+
+       return ret;
+}
+
+static int quickstart_acpi_remove(struct acpi_device *device, int

type)

drivers/acpi/quickstart.c new file +43 -0
+{
+       acpi_status status = 0;
+       struct quickstart_acpi *quickstart = NULL;
+
+       if (!device || !acpi_driver_data(device))
+               return -EINVAL;
+
+       quickstart = acpi_driver_data(device);
+
+       status = acpi_remove_notify_handler(device->handle,
+                                                ACPI_ALL_NOTIFY,
+                                           quickstart_acpi_notify);
+       if (ACPI_FAILURE(status))
+               printk("quickstart: Error removing notify handler\n");
+
+
+       kfree(quickstart);
+
+       return 0;
+}
+
+/* Module functions */
+
+static void quickstart_exit(void)
+{
+       device_remove_file(&pf_device->dev, &dev_attr_pressed_button);
+       device_remove_file(&pf_device->dev, &dev_attr_buttons);
+
+       platform_device_unregister(pf_device);
+
+       platform_driver_unregister(&pf_driver);
+
+       acpi_bus_unregister_driver(&quickstart_acpi_driver);
+      
+       quickstart_btnlst_free();
+
+       return;
+}
+
+static int __init quickstart_init(void)
+{
+       int ret;
+       acpi_status status = 0;

drivers/acpi/quickstart.c line 367

Quoted 10 lines
drivers/acpi/quickstart.c new file +10 -0
+
+       /* ACPI Check */
+       if(acpi_disabled)
+               return -ENODEV;
+
+       /* ACPI driver register */
+       status = acpi_bus_register_driver(&quickstart_acpi_driver);
+       if (!quickstart_data.btn_lst || status < 0)
+               return -ENODEV;
+

we should not register platform devices and sys attributes if no PNP0C32 device is available.
A simple way is to set a flag in the acpi driver's .add method which means PNP0C32 device is found.
And return -ENODEV if the flag is not set after acpi_bus_register_driver.

Quoted 4 lines
drivers/acpi/quickstart.c new file +4 -0
+       /* Platform driver register */
+       ret = platform_driver_register(&pf_driver);
+       if(ret)
+               goto fail_pfdrv_reg;

drivers/acpi/quickstart.c line 380

Quoted 10 lines
drivers/acpi/quickstart.c new file +9 -1
+ 
+       /* Platform device register */
+       pf_device = platform_device_alloc(QUICKSTART_PF_DEVICE_NAME,
-1);
+       if(!pf_device){
+               ret = -ENOMEM;
+               goto fail_pfdev_alloc;
+       }
+
+       ret = platform_device_register(pf_device);

kobject (f7808880): tried to init an initialized object, something is seriously wrong.
Pid: 1, comm: swapper Not tainted 2.6.25-rc6 #1

 [<c04dad4f>] kobject_init+0x29/0x53
 [<c05475fc>] device_initialize+0x1b/0x8b
 [<c054ab62>] platform_device_register+0xb/0x13
 [<c073dd50>] quickstart_init+0x5d/0xff
 [<c0725427>] kernel_init+0x12b/0x265
 [<c041eb8d>] schedule_tail+0x16/0x43
 [<c040481e>] ret_from_fork+0x6/0x1c
 [<c07252fc>] kernel_init+0x0/0x265
 [<c07252fc>] kernel_init+0x0/0x265
 [<c0405523>] kernel_thread_helper+0x7/0x10
 =======================

quickstart: ACPI Direct App Launch ver 1.00

platform_device_add should be called here.
I suspect the patch is not well tested.

Quoted 31 lines
drivers/acpi/quickstart.c new file +5 -0
+       if(ret)
+               goto fail_pfdev_reg;
+
+       /* Create device sysfs file */
+       ret = device_create_file(&pf_device->dev,

&dev_attr_pressed_button);

drivers/acpi/quickstart.c new file +8 -0
+       if(ret)
+               goto fail_dev_file;
+
+       ret = device_create_file(&pf_device->dev, &dev_attr_buttons);
+       if(ret)
+               goto fail_dev_file2;
+
+       printk("quickstart: ACPI Direct App Launch ver %s\n",

QUICKSTART_VERSION);

drivers/acpi/quickstart.c new file +2 -0
+       if(enable_runtime_btns)
+               printk("quickstart: Runtime button reporting is

enabled.");

drivers/acpi/quickstart.c new file +13 -0
+      
+       return 0;
+
+fail_dev_file2:
+       device_remove_file(&pf_device->dev, &dev_attr_pressed_button);
+
+fail_dev_file:
+       platform_device_del(pf_device);
+
+fail_pfdev_reg:
+       platform_device_put(pf_device);
+
+fail_pfdev_alloc:

drivers/acpi/quickstart.c line 418

Quoted 10 lines
drivers/acpi/quickstart.c new file +10 -0
+       platform_driver_unregister(&pf_driver);
+
+fail_pfdrv_reg:
+       acpi_bus_unregister_driver(&quickstart_acpi_driver);
+
+       return ret;
+}
+
+module_init(quickstart_init);
+module_exit(quickstart_exit);

There are some coding style problems. Please run checkpatch before submitting the patch.

thanks,
rui

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 9 lines · Rui

Hi, Angelo,

Quoted 4 lines · Ângelo Miguel Arrifano

Here is the patch made from the today linux-acpi tree.

Thanks,
Angelo Arrifano

we'd better add the change log here.
Some introductions about PNP0C32 device would be great.

Documentation (from README)
- -----------------------------------------------------------------
**********************************************************
* quickstart.c - ACPI Direct App Launch Driver for Linux *

*            Vista(TM) calls this Hotstart(TM)           *
*            http://quickstart.sourceforge.net           *

**********************************************************

WHAT IS IT?
<<The Windows Vista(TM) operating system provides built-in support for a fast system startup experience that boots or resumes directly into media or other applications.
This support, called direct application launch, is possible on PCs that are running Windows Vista by making simple changes to platform firmware and underlying platform wake circuitry.>>

* With the introduction of Vista Microsoft launched a new ACPI ?specification? to allow computers in sleep/off states to boot directly into multimedia applications by only pressing buttons.
* This driver provides support to these devices allowing userspace scripts to launch multimedia applications based on which button was pressed.

HOW IT WORKS:
* When the system boots, the driver receives an ACPI event telling which button was used to power the system on. Then, the driver exports this information to sysfs allowing userspace scripts to know the button name. This also applies to memory suspend and other power saving states.

EXAMPLE:
* File buttons shows a list of supported hot buttons.

  $ cat /sys/devices/platform/quickstart/buttons
  QBTN
  DBTN
  MUBN
  PIBN
  WEBN
  LVBN
  VOBN

* File pressed_button shows the hot button name used to power/resume the system. You can also write "none" to it to reset.

  $ cat /sys/devices/platform/quickstart/pressed_button
  none

WHAT FOR?
* Mobile and Media Center Linux distributors could use this to enrich their linux experience.
* It's easy to make an alternate init script that checks if some button was pressed and launch the appropriate application without having to load the entire system.

REFERENCES
* http://download.microsoft.com/download/9/c/5/9c5b2167-8017-4bae-9fde-d599bac8184a/DirAppLaunch_Vista.doc

CHANGELOG
- -----------------------------------------------------------------
* version 1.00-r1 2008/03/06
- Fixed Makefile for linux-2.6.24

* version 1.00 2008/03/03
- Little changes to support linux-2.6.23 and newer.
- Added example autostart scripts.
- Going stable, version bump.

* version 0.04 2007/11/17
- Added reporting of runtime key presses (hotkeys) for testing.

* version 0.03 2007/11/13
- Method GHID is now called under its device scope.
- Code cleanup.

* version 0.02 2007/11/12
- Project renamed to quickstart to prevent conflict with Microsoft trademark Hotstart(TM).
- Removed procfs support since /proc/acpi will be removed from kernel soon.
- Added sysfs support.
- Button states are now unified into a single attribute file which displays the button name used to power the system on.
- Added attribute file to show all suported buttons.
- Code cleanups.

* version 0.01 2007/11/10
- Detects button devices and creates proc entries to each device.
- Proc entries can be written.
- Workaround to raise device

PATCH
- -----------------------------------------------------------------

drivers/acpi/Kconfig +0 -0
index f688c21..fb096ee 100644

- --- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -196,6 +196,14 @@ config ACPI_THERMAL
recommended that this option be enabled, as your processor(s) may be damaged without it.

+config ACPI_QUICKSTART
+ tristate "Quickstart"
+ default y
+ help

+	  This driver add support for ACPI Direct Application Launch
+	  also known as Hotstart(TM). Say yes here to have a entry in
+	  sysfs telling which button was used to turn on the system.

+
config ACPI_NUMA
bool "NUMA support"
depends on NUMA

drivers/acpi/Makefile +0 -0
index f29812a..badb0a6 100644

- --- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -62,3 +62,4 @@ obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o
obj-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o
obj-$(CONFIG_ACPI_SBS) += sbs.o
obj-$(CONFIG_ACPI_SBS) += sbshc.o
+obj-$(CONFIG_ACPI_QUICKSTART) += quickstart.o

drivers/acpi/quickstart.c new file +0 -0
new file mode 100644
index 0000000..05c98f2

- --- /dev/null
+++ b/drivers/acpi/quickstart.c
@@ -0,0 +1,416 @@
+/*
+ * quickstart.c - ACPI Direct App Launch driver
+ *
+ *
+ * Copyright (C) 2007 Angelo Arrifano <[email protected]>
+ *

+ *  Information gathered from disassebled dsdt and from here:
+ *  "http://download.microsoft.com/download/9/c/5/
+ *  9c5b2167-8017-4bae-9fde-d599bac8184a/DirAppLaunch_Vista.doc"
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

+ *
+ */
+
+#define QUICKSTART_VERSION "1.01"
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <acpi/acpi_drivers.h>
+#include <linux/platform_device.h>
+
+MODULE_AUTHOR("Angelo Arrifano"); +MODULE_DESCRIPTION("ACPI Direct App Launch driver"); +MODULE_LICENSE("GPL");
+

+#define QUICKSTART_ACPI_DEVICE_NAME   "quickstart"
+#define QUICKSTART_ACPI_CLASS         "quickstart"
+#define QUICKSTART_ACPI_HID           "PNP0C32"
+
+#define QUICKSTART_PF_DRIVER_NAME     "quickstart"
+#define QUICKSTART_PF_DEVICE_NAME     "quickstart"
+#define QUICKSTART_PF_DEVATTR_NAME    "pressed_button"

+
+#define QUICKSTART_MAX_BTN_NAME_LEN 16
+
+/* There will be two events:
+ * 0x02 - A hot button was pressed while device was off/sleeping.
+ * 0x08 - A hot button was pressed while device was up. */
+#define QUICKSTART_EVENT_WAKE 0x02
+#define QUICKSTART_EVENT_RUNTIME 0x80
+
+struct quickstart_btn {
+ char *name;
+ struct quickstart_btn *next;
+};
+
+static struct quickstart_driver_data {
+ struct quickstart_btn *btn_lst;
+ struct quickstart_btn *pressed;
+} quickstart_data = {
+ .btn_lst = NULL,
+ .pressed = NULL,
+};
+
+/*
+ * ACPI driver Structs
+ */
+
+struct quickstart_acpi {
+ struct acpi_device *device;
+ struct quickstart_btn *btn;
+};
+static int quickstart_acpi_add(struct acpi_device *device);
+static int quickstart_acpi_remove(struct acpi_device *device, int type); +static const struct acpi_device_id quickstart_device_ids[] = {
+ {QUICKSTART_ACPI_HID, 0},
+ {"", 0},
+};
+
+static struct acpi_driver quickstart_acpi_driver = {
+ .name = "quickstart",
+ .class = QUICKSTART_ACPI_CLASS,
+ .ids = quickstart_device_ids,
+ .ops = {
+ .add = quickstart_acpi_add,
+ .remove = quickstart_acpi_remove,
+ },
+};
+
+/*
+ * Platform driver structs
+ */
+static ssize_t buttons_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf);
+static ssize_t pressed_button_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf);
+static ssize_t pressed_button_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf,
+ size_t count);
+static DEVICE_ATTR(pressed_button, 0666, pressed_button_show,
+ pressed_button_store);
+static DEVICE_ATTR(buttons, 0444, buttons_show, NULL);
+static struct platform_device *pf_device;
+static struct platform_driver pf_driver = {
+ .driver = {
+ .name = QUICKSTART_PF_DRIVER_NAME,
+ .owner = THIS_MODULE,
+ }
+};
+
+/*
+ * Platform driver functions
+ */
+static ssize_t buttons_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ int count = 0;
+ char tmpbuf[QUICKSTART_MAX_BTN_NAME_LEN + 2];
+ struct quickstart_btn *ptr = quickstart_data.btn_lst;
+
+ if (!ptr)
+ return snprintf(buf, PAGE_SIZE, "none");
+
+ while (ptr && (count < PAGE_SIZE)) {
+ if (ptr->name) {
+ strncpy(tmpbuf, ptr->name, QUICKSTART_MAX_BTN_NAME_LEN);
+ strcat(tmpbuf, "\n");
+ count += snprintf(buf + count,
+ PAGE_SIZE - count,
+ tmpbuf);
+ }
+ ptr = ptr->next;
+ }
+
+ return count;
+}
+
+static ssize_t pressed_button_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "%s\n",
+ (quickstart_data.pressed?quickstart_data.pressed->name:"none"));
+}
+
+
+static ssize_t pressed_button_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ if (count < 2)
+ return -EINVAL;
+
+ if (strncasecmp(buf, "none", 4) != 0)
+ return -EINVAL;
+
+ quickstart_data.pressed = NULL;
+ return count;
+}
+
+/* Hotstart Helper functions */
+static int quickstart_btnlst_add(struct quickstart_btn **data)
+{
+ struct quickstart_btn **ptr = &quickstart_data.btn_lst;
+
+ while (*ptr)
+ ptr = &((*ptr)->next);
+
+ *ptr = kzalloc(sizeof(struct quickstart_btn), GFP_KERNEL);
+ if (!*ptr) {
+ *data = NULL;
+ return(-ENOMEM);
+ }
+ *data = *ptr;
+
+ return 0;
+}
+
+static void quickstart_btnlst_free(void)
+{
+ struct quickstart_btn *ptr = quickstart_data.btn_lst;
+ struct quickstart_btn *lptr = NULL;
+
+ if (!ptr)
+ return;
+
+ while (ptr) {
+ lptr = ptr;
+ ptr = ptr->next;
+ kfree(lptr->name);
+ kfree(lptr);
+ }
+
+ return;
+}
+
+/* ACPI Driver functions */
+static void quickstart_acpi_notify(acpi_handle handle, u32 event, void *data) +{
+ struct quickstart_acpi *quickstart = data;
+
+ if (!quickstart)
+ return;
+
+ if (event == QUICKSTART_EVENT_WAKE) {
+ quickstart_data.pressed = quickstart->btn;
+ printk(KERN_ERR "quickstart: Quickbutton %s pressed.\n",
+ acpi_device_bid(quickstart->device));
+ } else if (event == QUICKSTART_EVENT_RUNTIME) {
+ printk(KERN_ERR "quickstart: Runtime button %s pressed.\n\t"
+ "please report on [email protected]",
+ acpi_device_bid(quickstart->device));
+ }
+
+ return;
+}
+
+static void quickstart_acpi_raise_notify(struct quickstart_acpi *quickstart) +{
+ acpi_status status;
+ struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+
+ if (!quickstart)
+ return;
+
+ /* This returns a buffer telling the button usage ID (useless),
+ * we dont care about it now. The important is to trigger
+ * pending notify events (The ones before booting). */
+ status = acpi_evaluate_object(quickstart->device->handle,
+ "GHID", NULL, &buffer);
+ if (ACPI_FAILURE(status) || !buffer.pointer) {
+ printk(KERN_ERR "quickstart: %s GHID method failed.\n",
+ quickstart->btn->name);
+ return;
+ }
+
+ kfree(buffer.pointer);
+ return;
+}
+
+static int quickstart_acpi_config(struct quickstart_acpi *quickstart, char *bid) +{
+ int len = strlen(bid);
+ int ret;
+
+ /* Add button to list */
+ ret = quickstart_btnlst_add(&quickstart->btn);
+ if (ret)
+ return ret;
+
+ quickstart->btn->name = kzalloc(len + 1, GFP_KERNEL);
+ if (!quickstart->btn->name) {
+ quickstart_btnlst_free();
+ return -ENOMEM;
+ }
+ strcpy(quickstart->btn->name, bid);
+
+ return 0;
+}
+
+static int quickstart_acpi_add(struct acpi_device *device)
+{
+ int ret = 0;
+ acpi_status status = AE_OK;
+ struct quickstart_acpi *quickstart = NULL;
+
+ if (!device)
+ return -EINVAL;
+
+ quickstart = kzalloc(sizeof(struct quickstart_acpi), GFP_KERNEL);
+ if (!quickstart)
+ return -ENOMEM;
+
+ quickstart->device = device;
+ strcpy(acpi_device_name(device), QUICKSTART_ACPI_DEVICE_NAME);
+ strcpy(acpi_device_class(device), QUICKSTART_ACPI_CLASS);
+ acpi_driver_data(device) = quickstart;
+
+ /* Add button to list and initialize some stuff */
+ ret = quickstart_acpi_config(quickstart, acpi_device_bid(device));
+ if (ret)
+ goto fail_config;
+
+ status = acpi_install_notify_handler(device->handle,
+ ACPI_ALL_NOTIFY,
+ quickstart_acpi_notify,
+ quickstart);
+ if (ACPI_FAILURE(status)) {
+ printk(KERN_ERR "quickstart: Notify handler install error\n");
+ ret = -ENODEV;
+ goto fail_installnotify;
+ }
+
+ quickstart_acpi_raise_notify(quickstart);
+
+ return 0;
+
+fail_installnotify:
+fail_config:
+
+ kfree(quickstart);
+
+ return ret;
+}
+
+static int quickstart_acpi_remove(struct acpi_device *device, int type) +{
+ acpi_status status = 0;
+ struct quickstart_acpi *quickstart = NULL;
+
+ if (!device || !acpi_driver_data(device))
+ return -EINVAL;
+
+ quickstart = acpi_driver_data(device);
+
+ status = acpi_remove_notify_handler(device->handle,
+ ACPI_ALL_NOTIFY,
+ quickstart_acpi_notify);
+ if (ACPI_FAILURE(status))
+ printk(KERN_ERR "quickstart: Error removing notify handler\n");
+
+
+ kfree(quickstart);
+
+ return 0;
+}
+
+/* Module functions */
+
+static void quickstart_exit(void)
+{
+ device_remove_file(&pf_device->dev, &dev_attr_pressed_button);
+ device_remove_file(&pf_device->dev, &dev_attr_buttons);
+
+ platform_device_unregister(pf_device);
+
+ platform_driver_unregister(&pf_driver);
+
+ acpi_bus_unregister_driver(&quickstart_acpi_driver);
+
+ quickstart_btnlst_free();
+
+ return;
+}
+
+static int __init quickstart_init(void)
+{
+ int ret;
+ acpi_status status = 0;
+
+ /* ACPI Check */
+ if (acpi_disabled)
+ return -ENODEV;
+
+ /* ACPI driver register */
+ status = acpi_bus_register_driver(&quickstart_acpi_driver);
+ if (!quickstart_data.btn_lst || status < 0)
+ return -ENODEV;
+
+ /* Platform driver register */
+ ret = platform_driver_register(&pf_driver);
+ if (ret)
+ goto fail_pfdrv_reg;
+
+ /* Platform device register */
+ pf_device = platform_device_alloc(QUICKSTART_PF_DEVICE_NAME, -1);
+ if (!pf_device) {
+ ret = -ENOMEM;
+ goto fail_pfdev_alloc;
+ }
+ ret = platform_device_register(pf_device);
+ if (ret)
+ goto fail_pfdev_reg;
+
+ /* Create device sysfs file */
+ ret = device_create_file(&pf_device->dev, &dev_attr_pressed_button);
+ if (ret)
+ goto fail_dev_file;
+
+ ret = device_create_file(&pf_device->dev, &dev_attr_buttons);
+ if (ret)
+ goto fail_dev_file2;
+
+ printk(KERN_ERR "quickstart: ACPI Direct App Launch ver %s\n",
+ QUICKSTART_VERSION);
+
+ return 0;
+
+fail_dev_file2:
+ device_remove_file(&pf_device->dev, &dev_attr_pressed_button);
+
+fail_dev_file:
+ platform_device_del(pf_device);
+
+fail_pfdev_reg:
+ platform_device_put(pf_device);
+
+fail_pfdev_alloc:
+ platform_driver_unregister(&pf_driver);
+
+fail_pfdrv_reg:
+ acpi_bus_unregister_driver(&quickstart_acpi_driver);
+
+ return ret;
+}
+
+module_init(quickstart_init);
+module_exit(quickstart_exit);

Quoted 77 lines
Quoted 77 lines
drivers/acpi/Kconfig +8 -0
index f688c21..fb096ee 100644
@@ -196,6 +196,14 @@ config ACPI_THERMAL
          recommended that this option be enabled, as your
 processor(s)
          may be damaged without it.
 
+config ACPI_QUICKSTART
+       tristate "Quickstart"
+       default y
+       help
+         This driver add support for ACPI Direct Application Launch
+         also known as Hotstart(TM). Say yes here to have a entry in
+         sysfs telling which button was used to turn on the system.
+
 config ACPI_NUMA
        bool "NUMA support"

depends on NUMA

drivers/acpi/Makefile +0 -0
index f29812a..badb0a6 100644
@@ -62,3 +62,4 @@ obj-$(CONFIG_ACPI_HOTPLUG_MEMORY)     +=

acpi_memhotplug.o
obj-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o
obj-$(CONFIG_ACPI_SBS) += sbs.o
obj-$(CONFIG_ACPI_SBS) += sbshc.o

drivers/acpi/Makefile +1 -0
+obj-$(CONFIG_ACPI_QUICKSTART)  += quickstart.o
drivers/acpi/quickstart.c new file +11 -0
new file mode 100644
index 0000000..a4726f8
@@ -0,0 +1,418 @@
+/*
+ *  quickstart.c - ACPI Direct App Launch driver
+ *
+ *
+ *  Copyright (C) 2007 Angelo Arrifano <[email protected]>
+ *
+ *  Information gathered from disassebled dsdt and from here:
+ *  "http://download.microsoft.com/download/9/c/5/
+ *  9c5b2167-8017-4bae-9fde-d599bac8184a/DirAppLaunch_Vista.doc"
+ *
+ *  This program is free software; you can redistribute it and/or

modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *

+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA

02111-1307 USA
+ *
+ */

drivers/acpi/quickstart.c new file +12 -0
+
+#define QUICKSTART_VERSION "1.00"
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <acpi/acpi_drivers.h>
+#include <linux/platform_device.h>
+
+MODULE_AUTHOR("Angelo Arrifano");
+MODULE_DESCRIPTION("ACPI Direct App Launch driver");
Quoted 8 lines
Quoted 7 lines
drivers/acpi/quickstart.c new file +6 -0
+MODULE_LICENSE("GPL");
+
+static int enable_runtime_btns;
+module_param(enable_runtime_btns, int, 0);
+MODULE_PARM_DESC(enable_runtime_btns,
+                       "Enable reporting of runtime button presses

(hotkeys).\n");

"enable_runtime_btns" is useless in this patch.

FIXED on the patch above

Quoted 179 lines
Quoted 179 lines
drivers/acpi/quickstart.c new file +34 -0
+
+#define QUICKSTART_ACPI_DEVICE_NAME   "quickstart"
+#define QUICKSTART_ACPI_CLASS         "quickstart"
+#define QUICKSTART_ACPI_HID           "PNP0C32"
+
+#define QUICKSTART_PF_DRIVER_NAME     "quickstart"
+#define QUICKSTART_PF_DEVICE_NAME     "quickstart"
+#define QUICKSTART_PF_DEVATTR_NAME    "pressed_button"
+
+#define QUICKSTART_MAX_BTN_NAME_LEN   16
+
+struct quickstart_btn_list {
+       char *name;
+       struct quickstart_btn_list *next;
+};
+
+static struct quickstart_driver_data {
+       struct quickstart_btn_list *btn_lst;
+       struct quickstart_btn_list *pressed;
+} quickstart_data = {
+       .btn_lst = NULL,
+       .pressed = NULL,
+};
+
+/*
+ * ACPI driver Structs
+ */
+
+struct quickstart_acpi {
+       struct acpi_device *device;
+       struct quickstart_btn_list *btn;
+};
+static int quickstart_acpi_add(struct acpi_device *device);
+static int quickstart_acpi_remove(struct acpi_device *device, int

type);

drivers/acpi/quickstart.c new file +44 -0
+static const struct acpi_device_id  quickstart_device_ids[] = {
+       {QUICKSTART_ACPI_HID, 0},
+       {"", 0},
+};
+
+static struct acpi_driver quickstart_acpi_driver = {
+       .name = "quickstart",
+       .class = QUICKSTART_ACPI_CLASS,
+       .ids = quickstart_device_ids,
+       .ops = {
+                       .add = quickstart_acpi_add,
+                       .remove = quickstart_acpi_remove,
+               },
+};
+
+/*
+ * Platform driver structs
+ */
+static ssize_t buttons_show(struct device *dev,
+                                       struct device_attribute *attr,
+                                       char *buf);
+static ssize_t pressed_button_show(struct device *dev,
+                                       struct device_attribute *attr,
+                                       char *buf);
+static ssize_t pressed_button_store(struct device *dev,
+                                       struct device_attribute *attr,
+                                        const char *buf,
+                                        size_t count);
+static DEVICE_ATTR(pressed_button, 0666, pressed_button_show,
+                                        pressed_button_store);
+static DEVICE_ATTR(buttons, 0444, buttons_show, NULL);
+static struct platform_device *pf_device;
+static struct platform_driver pf_driver = {
+       .driver = {
+               .name = QUICKSTART_PF_DRIVER_NAME,
+               .owner = THIS_MODULE,
+       }
+};
+
+/*
+ * Platform driver functions
+ */
+static ssize_t buttons_show(struct device *dev,
+                                        struct device_attribute

*attr,

drivers/acpi/quickstart.c new file +12 -0
+                                        char *buf)
+{
+       int count = 0;
+       char tmpbuf[QUICKSTART_MAX_BTN_NAME_LEN + 2];
+       struct quickstart_btn_list *ptr = quickstart_data.btn_lst;
+      
+       if(!ptr)
+               return snprintf(buf, PAGE_SIZE, "none");
+
+       while(ptr && (count < PAGE_SIZE)){
+               if(ptr->name){
+                       strncpy(tmpbuf, ptr->name,

QUICKSTART_MAX_BTN_NAME_LEN);

drivers/acpi/quickstart.c new file +17 -0
+                       strcat(tmpbuf, "\n");
+                       count += snprintf(buf + count,
+                                       PAGE_SIZE - count,
+                                       tmpbuf);
+               }
+               ptr = ptr->next;
+       }
+      
+       return count;
+}
+
+static ssize_t pressed_button_show(struct device *dev,
+                                       struct device_attribute *attr,
+                                       char *buf)
+{
+       return snprintf(buf, PAGE_SIZE, "%s\n",
+

(quickstart_data.pressed?quickstart_data.pressed->name:"none"));

drivers/acpi/quickstart.c new file +5 -0
+}
+
+
+static ssize_t pressed_button_store(struct device *dev,
+                                        struct device_attribute

*attr,
+ const char *buf, size_t
count)

drivers/acpi/quickstart.c new file +20 -0
+{
+       if(count < 2)
+               return -EINVAL;
+
+       if(strncasecmp(buf, "none", 4) != 0)
+               return -EINVAL;
+
+       quickstart_data.pressed = NULL;
+       return count;
+}
+
+/* Hotstart Helper functions */
+static int quickstart_btnlst_add(struct quickstart_btn_list **data)
+{
+       struct quickstart_btn_list **ptr = &quickstart_data.btn_lst;
+      
+       while(*ptr)
+               ptr = &((*ptr)->next);
+              
+       *ptr = kzalloc(sizeof(struct quickstart_btn_list),

GFP_KERNEL);

drivers/acpi/quickstart.c new file +30 -0
+       if(!*ptr){
+               *data = NULL;
+               return(-ENOMEM);
+       }
+       *data = *ptr;
+
+       return 0;
+}
+
+static void quickstart_btnlst_free(void)
+{
+       struct quickstart_btn_list *ptr = quickstart_data.btn_lst;
+       struct quickstart_btn_list *lptr = NULL;
+      
+       if(!ptr)
+               return;
+
+       while(ptr){
+               lptr = ptr;
+               ptr = ptr->next;
+               if(lptr->name)
+                       kfree(lptr->name);
+               kfree(lptr);
+       }
+      
+       return;
+}
+
+/* ACPI Driver functions */
+static void quickstart_acpi_notify(acpi_handle handle, u32 event,

void *data)

drivers/acpi/quickstart.c new file +7 -0
+{
+       struct quickstart_acpi *quickstart = data;
+
+       if (!quickstart)
+               return;
+
+       /* There will be two events:
Quoted 8 lines
Quoted 5 lines

+ * 0x02 - A quickstart button was pressed while device was
off/sleeping.
+ * 0x08 - A quickstart button was pressed while device was up.
*/
+ if((event|0x02) == event){

This is wrong.
If only two events are supported, it should be either 0x02 or 0x08. Checking bit 1 doesn't make sense here.

FIXED on the patch above

Quoted 16 lines
Quoted 8 lines
drivers/acpi/quickstart.c new file +3 -0
+               quickstart_data.pressed = quickstart->btn;
+               printk("quickstart: Quickbutton %s pressed.\n",
+

acpi_device_bid(quickstart->device));

drivers/acpi/quickstart.c new file +3 -0
+       }
+
+       if(enable_runtime_btns && (event|0x08) == event){

...

Quoted 6 lines
drivers/acpi/quickstart.c new file +2 -0
+               printk("quickstart: Hotkey %s pressed.\n",
+

acpi_device_bid(quickstart->device));

drivers/acpi/quickstart.c new file +2 -0
+       }
+
Quoted 5 lines

drivers/acpi/quickstart.c

Quoted 3 lines
drivers/acpi/quickstart.c new file +3 -0
+       return;
+}
+

at least we should export a notification to user space in the notify handler.

According to the Microsoft paper, runtime hot button reporting is optional. And my laptop doesn't report them, so I don't have a way to test this..

Quoted 14 lines

drivers/acpi/quickstart.c

Quoted 13 lines

+static void quickstart_acpi_raise_notify(struct quickstart_acpi *quickstart)

drivers/acpi/quickstart.c new file +10 -0
+{
+       acpi_status status;
+
+       /* TODO:
+        * We should receive a buffer telling the kind of button,
+        * eg: dvd, printer, www, ...
+        * but we dont care about it now. The important is to trigger
+        * pending notify events (The ones before booting). */
+       status = acpi_evaluate_object(quickstart->device->handle,
+                                       "GHID", NULL, NULL);

It's wrong as GHID returns a buffer.

FIXED on the patch above
The returned buffer is a BYTE/WORD/DWORD with a decimal number telling the button usage ID.
IMHO, the button usage ID is useless.

Quoted 135 lines
Quoted 135 lines
drivers/acpi/quickstart.c new file +2 -0
+       if(ACPI_FAILURE(status))
+               printk("quickstart: Warning: GHID method failed,

events of pressed buttons may have been lost.\n");

drivers/acpi/quickstart.c new file +5 -0
+
+       return;
+}
+
+static int quickstart_acpi_config(struct quickstart_acpi *quickstart,

char *bid)

drivers/acpi/quickstart.c new file +29 -0
+{
+       int len = strlen(bid);
+       int ret;
+
+       /* Add button to list */
+       ret = quickstart_btnlst_add(&quickstart->btn);
+       if(ret)
+               return ret;
+      
+       quickstart->btn->name = kzalloc(len + 1, GFP_KERNEL);
+       if(!quickstart->btn->name){
+               quickstart_btnlst_free();
+               return -ENOMEM;
+       }
+       strcpy(quickstart->btn->name, bid);
+
+       return 0;
+}
+
+static int quickstart_acpi_add(struct acpi_device *device)
+{
+       int ret = 0;
+       acpi_status status = AE_OK;
+       struct quickstart_acpi *quickstart = NULL;     
+
+       if (!device)
+               return -EINVAL;
+
+       quickstart = kzalloc(sizeof(struct quickstart_acpi),

GFP_KERNEL);

drivers/acpi/quickstart.c new file +10 -0
+       if (!quickstart)
+               return -ENOMEM;
+
+       quickstart->device = device;
+       strcpy(acpi_device_name(device), QUICKSTART_ACPI_DEVICE_NAME);
+       strcpy(acpi_device_class(device), QUICKSTART_ACPI_CLASS);
+       acpi_driver_data(device) = quickstart;
+      
+       /* Add button to list and initialize some stuff */
+       ret = quickstart_acpi_config(quickstart,

acpi_device_bid(device));

drivers/acpi/quickstart.c new file +6 -0
+       if(ret)
+               goto fail_config;
+
+       status = acpi_install_notify_handler(device->handle,
+                                                ACPI_ALL_NOTIFY,
+

quickstart_acpi_notify, quickstart);

drivers/acpi/quickstart.c new file +2 -0
+       if(ACPI_FAILURE(status)){
+               printk("quickstart: Error installing notify handler

\n");

drivers/acpi/quickstart.c new file +5 -0
+               ret = -ENODEV;
+               goto fail_installnotify;
+       }      
+
+       /* Call device GHID method. This is a workaround to get a

notify
+ * event when hot button is pressed while laptop is powered
off.

drivers/acpi/quickstart.c new file +14 -0
+        * This works, even if the method fails. */
+       quickstart_acpi_raise_notify(quickstart);
+
+       return 0;
+
+fail_installnotify:
+fail_config:
+
+       kfree(quickstart);
+
+       return ret;
+}
+
+static int quickstart_acpi_remove(struct acpi_device *device, int

type)

drivers/acpi/quickstart.c new file +51 -0
+{
+       acpi_status status = 0;
+       struct quickstart_acpi *quickstart = NULL;
+
+       if (!device || !acpi_driver_data(device))
+               return -EINVAL;
+
+       quickstart = acpi_driver_data(device);
+
+       status = acpi_remove_notify_handler(device->handle,
+                                                ACPI_ALL_NOTIFY,
+                                           quickstart_acpi_notify);
+       if (ACPI_FAILURE(status))
+               printk("quickstart: Error removing notify handler\n");
+
+
+       kfree(quickstart);
+
+       return 0;
+}
+
+/* Module functions */
+
+static void quickstart_exit(void)
+{
+       device_remove_file(&pf_device->dev, &dev_attr_pressed_button);
+       device_remove_file(&pf_device->dev, &dev_attr_buttons);
+
+       platform_device_unregister(pf_device);
+
+       platform_driver_unregister(&pf_driver);
+
+       acpi_bus_unregister_driver(&quickstart_acpi_driver);
+      
+       quickstart_btnlst_free();
+
+       return;
+}
+
+static int __init quickstart_init(void)
+{
+       int ret;
+       acpi_status status = 0;
+
+       /* ACPI Check */
+       if(acpi_disabled)
+               return -ENODEV;
+
+       /* ACPI driver register */
+       status = acpi_bus_register_driver(&quickstart_acpi_driver);
+       if (!quickstart_data.btn_lst || status < 0)
Quoted 8 lines

drivers/acpi/quickstart.c

Quoted 2 lines
drivers/acpi/quickstart.c new file +2 -0
+               return -ENODEV;
+

we should not register platform devices and sys attributes if no PNP0C32 device is available.
A simple way is to set a flag in the acpi driver's .add method which means PNP0C32 device is found.
And return -ENODEV if the flag is not set after acpi_bus_register_driver.

That is exactly whats going on here.
acpi_bus_register_driver() is called with quickstart_data.btn_lst=NULL . If no devices are detected, the quickstart_data.btn_lst is not touched and continues to be null.
So we can consider quickstart_data.btn_lst as the flag you were talking.

Quoted 29 lines
Quoted 5 lines
drivers/acpi/quickstart.c new file +4 -0
+       /* Platform driver register */
+       ret = platform_driver_register(&pf_driver);
+       if(ret)
+               goto fail_pfdrv_reg;

drivers/acpi/quickstart.c

Quoted 10 lines
drivers/acpi/quickstart.c new file +9 -1
+ 
+       /* Platform device register */
+       pf_device = platform_device_alloc(QUICKSTART_PF_DEVICE_NAME,
-1);
+       if(!pf_device){
+               ret = -ENOMEM;
+               goto fail_pfdev_alloc;
+       }
+
+       ret = platform_device_register(pf_device);

kobject (f7808880): tried to init an initialized object, something is seriously wrong.
Pid: 1, comm: swapper Not tainted 2.6.25-rc6 #1

 [<c04dad4f>] kobject_init+0x29/0x53
 [<c05475fc>] device_initialize+0x1b/0x8b
 [<c054ab62>] platform_device_register+0xb/0x13
 [<c073dd50>] quickstart_init+0x5d/0xff
 [<c0725427>] kernel_init+0x12b/0x265
 [<c041eb8d>] schedule_tail+0x16/0x43
 [<c040481e>] ret_from_fork+0x6/0x1c
 [<c07252fc>] kernel_init+0x0/0x265
 [<c07252fc>] kernel_init+0x0/0x265
 [<c0405523>] kernel_thread_helper+0x7/0x10
 =======================
Quoted 4 lines

quickstart: ACPI Direct App Launch ver 1.00

platform_device_add should be called here.
I suspect the patch is not well tested.

I don't understand this one.
pf_device is initialized twice? How?

Quoted 36 lines
Quoted 36 lines
drivers/acpi/quickstart.c new file +5 -0
+       if(ret)
+               goto fail_pfdev_reg;
+
+       /* Create device sysfs file */
+       ret = device_create_file(&pf_device->dev,

&dev_attr_pressed_button);

drivers/acpi/quickstart.c new file +8 -0
+       if(ret)
+               goto fail_dev_file;
+
+       ret = device_create_file(&pf_device->dev, &dev_attr_buttons);
+       if(ret)
+               goto fail_dev_file2;
+
+       printk("quickstart: ACPI Direct App Launch ver %s\n",

QUICKSTART_VERSION);

drivers/acpi/quickstart.c new file +2 -0
+       if(enable_runtime_btns)
+               printk("quickstart: Runtime button reporting is

enabled.");

drivers/acpi/quickstart.c new file +17 -0
+      
+       return 0;
+
+fail_dev_file2:
+       device_remove_file(&pf_device->dev, &dev_attr_pressed_button);
+
+fail_dev_file:
+       platform_device_del(pf_device);
+
+fail_pfdev_reg:
+       platform_device_put(pf_device);
+
+fail_pfdev_alloc:
+       platform_driver_unregister(&pf_driver);
+
+fail_pfdrv_reg:
+       acpi_bus_unregister_driver(&quickstart_acpi_driver);
Quoted 8 lines

drivers/acpi/quickstart.c

Quoted 6 lines
drivers/acpi/quickstart.c new file +6 -0
+
+       return ret;
+}
+
+module_init(quickstart_init);
+module_exit(quickstart_exit);

There are some coding style problems. Please run checkpatch before submitting the patch.

FIXED on the patch above

Quoted 5 lines

thanks,
rui

Thanks,
- --
Angelo Arrifano AKA MiKNiX
CSE Student at UBI, Portugal
Gentoo Linux AMD64 Arch Tester
Linwizard Developer
http://miknix.homelinux.com
PGP Pubkey 0x3D92BB0B
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)

iD8DBQFH6o0rNahyoD2SuwsRAvhDAJ9NJoi5c5tEOHaj+wlRi9S4lEhHrwCfdyhr IAShcu6win9qeoSrhi6lYc8=
=7Uap
-----END PGP SIGNATURE-----
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 7 lines · Ângelo Miguel Arrifano

PATCH
- -----------------------------------------------------------------

drivers/acpi/Kconfig +1 -1
index f688c21..fb096ee 100644
- --- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig

drivers/acpi/Kconfig config ACPI_THERMAL · line 202

Quoted 7 lines
drivers/acpi/Kconfig +3 -0
@@ -196,6 +196,14 @@ config ACPI_THERMAL
          recommended that this option be enabled, as your
 processor(s)
          may be damaged without it.
 
+config ACPI_QUICKSTART
+       tristate "Quickstart"
+       default y

default m?

drivers/acpi/Kconfig config ACPI_THERMAL

Quoted 8 lines
drivers/acpi/Kconfig +8 -0
+
+static struct quickstart_driver_data {
+       struct quickstart_btn *btn_lst;
+       struct quickstart_btn *pressed;
+} quickstart_data = {
+       .btn_lst = NULL,
+       .pressed = NULL,
+};

They are NULL, you don't need initialize them.

Quoted 4 lines

+ * Platform driver structs
+ */

drivers/acpi/Kconfig +2 -0
+static ssize_t buttons_show(struct device *dev,
+                                       struct device_attribute *attr,

drivers/acpi/Kconfig

Quoted 10 lines
drivers/acpi/Kconfig +10 -0
+                                       char *buf);
+static ssize_t pressed_button_show(struct device *dev,
+                                       struct device_attribute *attr,
+                                       char *buf);
+static ssize_t pressed_button_store(struct device *dev,
+                                       struct device_attribute *attr,
+                                        const char *buf,
+                                        size_t count);
+static DEVICE_ATTR(pressed_button, 0666, pressed_button_show,
+                                        pressed_button_store);

this file can be changed by non-root?

Quoted 16 lines
drivers/acpi/Kconfig +2 -0
+static ssize_t buttons_show(struct device *dev,
+                                        struct device_attribute

*attr,

drivers/acpi/Kconfig +12 -0
+                                        char *buf)
+{
+       int count = 0;
+       char tmpbuf[QUICKSTART_MAX_BTN_NAME_LEN + 2];
+       struct quickstart_btn *ptr = quickstart_data.btn_lst;
+
+       if (!ptr)
+               return snprintf(buf, PAGE_SIZE, "none");
+
+       while (ptr && (count < PAGE_SIZE)) {
+               if (ptr->name) {
+                       strncpy(tmpbuf, ptr->name,

QUICKSTART_MAX_BTN_NAME_LEN);

drivers/acpi/Kconfig

Quoted 4 lines
drivers/acpi/Kconfig +4 -0
+                       strcat(tmpbuf, "\n");
+                       count += snprintf(buf + count,
+                                       PAGE_SIZE - count,
+                                       tmpbuf);

we could simplify:
snprintf(buf + count, PAGE_SIZE -count, "%s\n", ptr->name);

Quoted 30 lines
drivers/acpi/Kconfig +10 -0
+               }
+               ptr = ptr->next;
+       }
+
+       return count;
+}
 
+
 
+
+/* ACPI Driver functions */
+static void quickstart_acpi_notify(acpi_handle handle, u32 event,

void *data)

drivers/acpi/Kconfig +9 -0
+{
+       struct quickstart_acpi *quickstart = data;
+
+       if (!quickstart)
+               return;
+
+       if (event == QUICKSTART_EVENT_WAKE) {
+               quickstart_data.pressed = quickstart->btn;
+               printk(KERN_ERR "quickstart: Quickbutton %s

pressed.\n",
+
acpi_device_bid(quickstart->device));

drivers/acpi/Kconfig +2 -0
+       } else if (event == QUICKSTART_EVENT_RUNTIME) {
+               printk(KERN_ERR "quickstart: Runtime button %s

pressed.\n\t"

drivers/acpi/Kconfig +2 -0
+                      "please report on [email protected]",
+
Quoted 2 lines

acpi_device_bid(quickstart->device));
+ }

Please remove above printks. they are misleading, which isn't an error. please send an ACPI event to userspace in the notify, we need it for runtime.

Quoted 21 lines
drivers/acpi/Kconfig +4 -0
+       return;
+}
+
+static void quickstart_acpi_raise_notify(struct quickstart_acpi

*quickstart)

drivers/acpi/Kconfig +8 -0
+{
+       acpi_status status;
+       struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+
+       if (!quickstart)
+               return;
+
+       /* This returns a buffer telling the  button usage ID

(useless),

drivers/acpi/Kconfig +6 -0
+        * we dont care about it now. The important is to trigger
+        * pending notify events (The ones before booting). */
+       status = acpi_evaluate_object(quickstart->device->handle,
+                                       "GHID", NULL, &buffer);
+       if (ACPI_FAILURE(status) || !buffer.pointer) {
+               printk(KERN_ERR "quickstart: %s GHID method

failed.\n",

drivers/acpi/Kconfig

Quoted 3 lines
drivers/acpi/Kconfig +3 -0
+                      quickstart->btn->name);
+               return;
+       }

I'd suggest the GHID info should be exported to sysfs too. It's hard to judge what a button is just per its name. You know it but an inexperienced user doesn't.

Quoted 39 lines
drivers/acpi/Kconfig +15 -0
+       kfree(buffer.pointer);
+       return;
+}
+
 
+
+static int quickstart_acpi_add(struct acpi_device *device)
+{
+       int ret = 0;
+       acpi_status status = AE_OK;
+       struct quickstart_acpi *quickstart = NULL;
+
+       if (!device)
+               return -EINVAL;
+
+       quickstart = kzalloc(sizeof(struct quickstart_acpi),

GFP_KERNEL);

drivers/acpi/Kconfig +10 -0
+       if (!quickstart)
+               return -ENOMEM;
+
+       quickstart->device = device;
+       strcpy(acpi_device_name(device), QUICKSTART_ACPI_DEVICE_NAME);
+       strcpy(acpi_device_class(device), QUICKSTART_ACPI_CLASS);
+       acpi_driver_data(device) = quickstart;
+
+       /* Add button to list and initialize some stuff */
+       ret = quickstart_acpi_config(quickstart,

acpi_device_bid(device));

drivers/acpi/Kconfig +6 -0
+       if (ret)
+               goto fail_config;
+
+       status = acpi_install_notify_handler(device->handle,
+                                               ACPI_ALL_NOTIFY,
+

quickstart_acpi_notify,

drivers/acpi/Kconfig +3 -0
+                                               quickstart);
+       if (ACPI_FAILURE(status)) {
+               printk(KERN_ERR "quickstart: Notify handler install

error\n");

drivers/acpi/Kconfig

Quoted 2 lines
drivers/acpi/Kconfig +2 -0
+               ret = -ENODEV;
+               goto fail_installnotify;

memory is freed but it's still in the list.

Thanks,
Shaohua

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 30 lines · On Thu, 27 Mar 2008 10:30:13 +0800 Shaohua Li <[email protected]> wrote:
Quoted 7 lines · Ângelo Miguel Arrifano

PATCH
- -----------------------------------------------------------------

drivers/acpi/Kconfig +1 -1
index f688c21..fb096ee 100644
- --- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig

drivers/acpi/Kconfig config ACPI_THERMAL · line 202

Quoted 7 lines
drivers/acpi/Kconfig +3 -0
@@ -196,6 +196,14 @@ config ACPI_THERMAL
          recommended that this option be enabled, as your
 processor(s)
          may be damaged without it.
 
+config ACPI_QUICKSTART
+       tristate "Quickstart"
+       default y

default m?

drivers/acpi/Kconfig config ACPI_THERMAL

Quoted 8 lines
drivers/acpi/Kconfig +8 -0
+
+static struct quickstart_driver_data {
+       struct quickstart_btn *btn_lst;
+       struct quickstart_btn *pressed;
+} quickstart_data = {
+       .btn_lst = NULL,
+       .pressed = NULL,
+};

They are NULL, you don't need initialize them.

Quoted 15 lines
Quoted 4 lines

+ * Platform driver structs
+ */

drivers/acpi/Kconfig +2 -0
+static ssize_t buttons_show(struct device *dev,
+                                       struct device_attribute *attr,

drivers/acpi/Kconfig

Quoted 10 lines
drivers/acpi/Kconfig +10 -0
+                                       char *buf);
+static ssize_t pressed_button_show(struct device *dev,
+                                       struct device_attribute *attr,
+                                       char *buf);
+static ssize_t pressed_button_store(struct device *dev,
+                                       struct device_attribute *attr,
+                                        const char *buf,
+                                        size_t count);
+static DEVICE_ATTR(pressed_button, 0666, pressed_button_show,
+                                        pressed_button_store);

this file can be changed by non-root?

The only thing that writing to this file does is clearing the pressed button.
Is it a bad idea that can be changed by non-root?

Quoted 16 lines
Quoted 16 lines
drivers/acpi/Kconfig +2 -0
+static ssize_t buttons_show(struct device *dev,
+                                        struct device_attribute

*attr,

drivers/acpi/Kconfig +11 -0
+                                        char *buf)
+{
+       int count = 0;
+       char tmpbuf[QUICKSTART_MAX_BTN_NAME_LEN + 2];
+       struct quickstart_btn *ptr = quickstart_data.btn_lst;
+
+       if (!ptr)
+               return snprintf(buf, PAGE_SIZE, "none");
+
+       while (ptr && (count < PAGE_SIZE)) {
+               if (ptr->name) {
Quoted 8 lines

drivers/acpi/Kconfig

Quoted 6 lines

+ strncpy(tmpbuf, ptr->name,
QUICKSTART_MAX_BTN_NAME_LEN);

drivers/acpi/Kconfig +4 -0
+                       strcat(tmpbuf, "\n");
+                       count += snprintf(buf + count,
+                                       PAGE_SIZE - count,
+                                       tmpbuf);

we could simplify:
snprintf(buf + count, PAGE_SIZE -count, "%s\n", ptr->name);

:)

Quoted 27 lines
Quoted 27 lines
drivers/acpi/Kconfig +10 -0
+               }
+               ptr = ptr->next;
+       }
+
+       return count;
+}
 
+
 
+
+/* ACPI Driver functions */
+static void quickstart_acpi_notify(acpi_handle handle, u32 event,

void *data)

drivers/acpi/Kconfig +9 -0
+{
+       struct quickstart_acpi *quickstart = data;
+
+       if (!quickstart)
+               return;
+
+       if (event == QUICKSTART_EVENT_WAKE) {
+               quickstart_data.pressed = quickstart->btn;
+               printk(KERN_ERR "quickstart: Quickbutton %s

pressed.\n",
+
acpi_device_bid(quickstart->device));

drivers/acpi/Kconfig +2 -0
+       } else if (event == QUICKSTART_EVENT_RUNTIME) {
+               printk(KERN_ERR "quickstart: Runtime button %s
Quoted 8 lines
Quoted 5 lines

pressed.\n\t"

drivers/acpi/Kconfig +2 -0
+                      "please report on [email protected]",
+

acpi_device_bid(quickstart->device));
+ }

Please remove above printks. they are misleading, which isn't an error. please send an ACPI event to userspace in the notify, we need it for runtime.

According to the Microsoft paper, runtime hot button reporting is optional. My laptop doesn't report them and on the SF.net project page there was no reports of people with hardware supporting this.
Sorry, I don't have a way to test this..

Quoted 20 lines
Quoted 20 lines
drivers/acpi/Kconfig +4 -0
+       return;
+}
+
+static void quickstart_acpi_raise_notify(struct quickstart_acpi

*quickstart)

drivers/acpi/Kconfig +8 -0
+{
+       acpi_status status;
+       struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+
+       if (!quickstart)
+               return;
+
+       /* This returns a buffer telling the  button usage ID

(useless),

drivers/acpi/Kconfig +5 -0
+        * we dont care about it now. The important is to trigger
+        * pending notify events (The ones before booting). */
+       status = acpi_evaluate_object(quickstart->device->handle,
+                                       "GHID", NULL, &buffer);
+       if (ACPI_FAILURE(status) || !buffer.pointer) {
Quoted 8 lines

drivers/acpi/Kconfig

Quoted 5 lines

+ printk(KERN_ERR "quickstart: %s GHID method
failed.\n",

drivers/acpi/Kconfig +3 -0
+                      quickstart->btn->name);
+               return;
+       }

I'd suggest the GHID info should be exported to sysfs too. It's hard to judge what a button is just per its name. You know it but an inexperienced user doesn't.

I also would like to have a more descriptive information about the button but the returned buffer is a BYTE/WORD/DWORD with a decimal number telling the button usage ID.

Looking at my DSDT piece of code:

Method (GHID, 0, NotSerialized)
{
If (LEqual (HOTB, 0x05))

   {
      Notify (DBTN, 0x02)
      Store (0x00, HOTB)

}

Return (Buffer (0x01)

   {
      /* 0000 */    0x04

})
}

IMHO, a value like 0x04 for button usageID is totally useless..

Quoted 35 lines
Quoted 35 lines
drivers/acpi/Kconfig +15 -0
+       kfree(buffer.pointer);
+       return;
+}
+
 
+
+static int quickstart_acpi_add(struct acpi_device *device)
+{
+       int ret = 0;
+       acpi_status status = AE_OK;
+       struct quickstart_acpi *quickstart = NULL;
+
+       if (!device)
+               return -EINVAL;
+
+       quickstart = kzalloc(sizeof(struct quickstart_acpi),

GFP_KERNEL);

drivers/acpi/Kconfig +10 -0
+       if (!quickstart)
+               return -ENOMEM;
+
+       quickstart->device = device;
+       strcpy(acpi_device_name(device), QUICKSTART_ACPI_DEVICE_NAME);
+       strcpy(acpi_device_class(device), QUICKSTART_ACPI_CLASS);
+       acpi_driver_data(device) = quickstart;
+
+       /* Add button to list and initialize some stuff */
+       ret = quickstart_acpi_config(quickstart,

acpi_device_bid(device));

drivers/acpi/Kconfig +6 -0
+       if (ret)
+               goto fail_config;
+
+       status = acpi_install_notify_handler(device->handle,
+                                               ACPI_ALL_NOTIFY,
+
Quoted 8 lines

drivers/acpi/Kconfig

Quoted 7 lines

quickstart_acpi_notify,

drivers/acpi/Kconfig +3 -0
+                                               quickstart);
+       if (ACPI_FAILURE(status)) {
+               printk(KERN_ERR "quickstart: Notify handler install

error\n");

drivers/acpi/Kconfig +2 -0
+               ret = -ENODEV;
+               goto fail_installnotify;

memory is freed but it's still in the list.

I got it now, big mistake here.
I hope to have this fixed on the patch below

Quoted 4 lines

Thanks,
Shaohua

drivers/acpi/Kconfig +8 -0
index f688c21..fd65e36 100644
@@ -196,6 +196,14 @@ config ACPI_THERMAL
 	  recommended that this option be enabled, as your processor(s)
 	  may be damaged without it.
 
+config ACPI_QUICKSTART
+	tristate "Quickstart"
+	default m
+	help
+	  This driver add support for ACPI Direct Application Launch
+	  also known as Hotstart(TM). Say yes here to have a entry in
+	  sysfs telling which button was used to turn on the system.
+
 config ACPI_NUMA
 	bool "NUMA support"
 	depends on NUMA
drivers/acpi/Makefile +1 -0
index f29812a..badb0a6 100644
@@ -62,3 +62,4 @@ obj-$(CONFIG_ACPI_HOTPLUG_MEMORY)	+= acpi_memhotplug.o
 obj-$(CONFIG_ACPI_PROCFS_POWER)	+= cm_sbs.o
 obj-$(CONFIG_ACPI_SBS)		+= sbs.o
 obj-$(CONFIG_ACPI_SBS)		+= sbshc.o
+obj-$(CONFIG_ACPI_QUICKSTART)	+= quickstart.o
drivers/acpi/quickstart.c new file +427 -0

427 lines not on this page · raw message

Thanks all,

Signature · 10 lines
Angelo Arrifano AKA MiKNiX
CSE Student at UBI, Portugal
Gentoo Linux AMD64 Arch Tester
Linwizard Developer
http://miknix.homelinux.com
PGP Pubkey 0x3D92BB0B
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw
Quoted 49 lines · Ângelo Miguel Arrifano
Quoted 30 lines · On Thu, 27 Mar 2008 10:30:13 +0800 Shaohua Li <[email protected]> wrote:
Quoted 7 lines · Ângelo Miguel Arrifano

PATCH
- -----------------------------------------------------------------

drivers/acpi/Kconfig +1 -1
index f688c21..fb096ee 100644
- --- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig

drivers/acpi/Kconfig config ACPI_THERMAL · line 202

Quoted 7 lines
drivers/acpi/Kconfig +3 -0
@@ -196,6 +196,14 @@ config ACPI_THERMAL
          recommended that this option be enabled, as your
 processor(s)
          may be damaged without it.
 
+config ACPI_QUICKSTART
+       tristate "Quickstart"
+       default y

default m?

drivers/acpi/Kconfig config ACPI_THERMAL

Quoted 8 lines
drivers/acpi/Kconfig +8 -0
+
+static struct quickstart_driver_data {
+       struct quickstart_btn *btn_lst;
+       struct quickstart_btn *pressed;
+} quickstart_data = {
+       .btn_lst = NULL,
+       .pressed = NULL,
+};

They are NULL, you don't need initialize them.

Quoted 15 lines
Quoted 4 lines

+ * Platform driver structs
+ */

drivers/acpi/Kconfig +2 -0
+static ssize_t buttons_show(struct device *dev,
+                                       struct device_attribute *attr,

drivers/acpi/Kconfig

Quoted 10 lines
drivers/acpi/Kconfig +10 -0
+                                       char *buf);
+static ssize_t pressed_button_show(struct device *dev,
+                                       struct device_attribute *attr,
+                                       char *buf);
+static ssize_t pressed_button_store(struct device *dev,
+                                       struct device_attribute *attr,
+                                        const char *buf,
+                                        size_t count);
+static DEVICE_ATTR(pressed_button, 0666, pressed_button_show,
+                                        pressed_button_store);

this file can be changed by non-root?

Quoted 3 lines

The only thing that writing to this file does is clearing the pressed button.
Is it a bad idea that can be changed by non-root?

Just abnormal, eg. non-root can clear it but root might not read it (though it doesn't happen in current case but possible if runtime event support).

Quoted 27 lines
Quoted 18 lines
Quoted 18 lines
drivers/acpi/Kconfig +3 -0
+
+/* ACPI Driver functions */
+static void quickstart_acpi_notify(acpi_handle handle, u32 event,

void *data)

drivers/acpi/Kconfig +9 -0
+{
+       struct quickstart_acpi *quickstart = data;
+
+       if (!quickstart)
+               return;
+
+       if (event == QUICKSTART_EVENT_WAKE) {
+               quickstart_data.pressed = quickstart->btn;
+               printk(KERN_ERR "quickstart: Quickbutton %s

pressed.\n",
+
acpi_device_bid(quickstart->device));

drivers/acpi/Kconfig +2 -0
+       } else if (event == QUICKSTART_EVENT_RUNTIME) {
+               printk(KERN_ERR "quickstart: Runtime button %s
Quoted 8 lines
Quoted 5 lines

pressed.\n\t"

drivers/acpi/Kconfig +2 -0
+                      "please report on [email protected]",
+

acpi_device_bid(quickstart->device));
+ }

Please remove above printks. they are misleading, which isn't an error. please send an ACPI event to userspace in the notify, we need it for runtime.

Quoted 4 lines

According to the Microsoft paper, runtime hot button reporting is optional. My laptop doesn't report them and on the SF.net project page there was no reports of people with hardware supporting this.
Sorry, I don't have a way to test this..

Did you tried suspend/resume. From the doc, resume can send a notification too. Just calling acpi event eject routines, an event eject model can be well integrated into existing acpi daemons.

Quoted 25 lines
Quoted 4 lines
Quoted 1 line

+ }

I'd suggest the GHID info should be exported to sysfs too. It's hard to judge what a button is just per its name. You know it but an inexperienced user doesn't.

I also would like to have a more descriptive information about the button but the returned buffer is a BYTE/WORD/DWORD with a decimal number telling the button usage ID.

Looking at my DSDT piece of code:

Method (GHID, 0, NotSerialized)

{
   If (LEqual (HOTB, 0x05))
   {
      Notify (DBTN, 0x02)
      Store (0x00, HOTB)
   }

   Return (Buffer (0x01)
   {
      /* 0000 */    0x04
   })
}
Quoted 1 line

IMHO, a value like 0x04 for button usageID is totally useless..

Ok, I got it. Maybe we need tool to help user identify what purpose a button is, but sounds impossible till the button can trigger runtime event.

Thanks,
Shaohua

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 85 lines · On Fri, 28 Mar 2008 09:36:55 +0800 Shaohua Li <[email protected]> wrote:
Quoted 49 lines · Ângelo Miguel Arrifano
Quoted 30 lines · On Thu, 27 Mar 2008 10:30:13 +0800 Shaohua Li <[email protected]> wrote:
Quoted 7 lines · Ângelo Miguel Arrifano

PATCH
- -----------------------------------------------------------------

drivers/acpi/Kconfig +1 -1
index f688c21..fb096ee 100644
- --- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig

drivers/acpi/Kconfig config ACPI_THERMAL · line 202

Quoted 7 lines
drivers/acpi/Kconfig +3 -0
@@ -196,6 +196,14 @@ config ACPI_THERMAL
          recommended that this option be enabled, as your
 processor(s)
          may be damaged without it.
 
+config ACPI_QUICKSTART
+       tristate "Quickstart"
+       default y

default m?

drivers/acpi/Kconfig config ACPI_THERMAL

Quoted 8 lines
drivers/acpi/Kconfig +8 -0
+
+static struct quickstart_driver_data {
+       struct quickstart_btn *btn_lst;
+       struct quickstart_btn *pressed;
+} quickstart_data = {
+       .btn_lst = NULL,
+       .pressed = NULL,
+};

They are NULL, you don't need initialize them.

Quoted 15 lines
Quoted 4 lines

+ * Platform driver structs
+ */

drivers/acpi/Kconfig +2 -0
+static ssize_t buttons_show(struct device *dev,
+                                       struct device_attribute *attr,

drivers/acpi/Kconfig

Quoted 10 lines
drivers/acpi/Kconfig +10 -0
+                                       char *buf);
+static ssize_t pressed_button_show(struct device *dev,
+                                       struct device_attribute *attr,
+                                       char *buf);
+static ssize_t pressed_button_store(struct device *dev,
+                                       struct device_attribute *attr,
+                                        const char *buf,
+                                        size_t count);
+static DEVICE_ATTR(pressed_button, 0666, pressed_button_show,
+                                        pressed_button_store);

this file can be changed by non-root?

Quoted 3 lines

The only thing that writing to this file does is clearing the pressed button.
Is it a bad idea that can be changed by non-root?

Just abnormal, eg. non-root can clear it but root might not read it (though it doesn't happen in current case but possible if runtime event support).

Quoted 27 lines
Quoted 26 lines
Quoted 21 lines
drivers/acpi/Kconfig +3 -0
+
+/* ACPI Driver functions */
+static void quickstart_acpi_notify(acpi_handle handle, u32 event,

void *data)

drivers/acpi/Kconfig +9 -0
+{
+       struct quickstart_acpi *quickstart = data;
+
+       if (!quickstart)
+               return;
+
+       if (event == QUICKSTART_EVENT_WAKE) {
+               quickstart_data.pressed = quickstart->btn;
+               printk(KERN_ERR "quickstart: Quickbutton %s

pressed.\n",
+
acpi_device_bid(quickstart->device));

drivers/acpi/Kconfig +2 -0
+       } else if (event == QUICKSTART_EVENT_RUNTIME) {
+               printk(KERN_ERR "quickstart: Runtime button %s

pressed.\n\t"

drivers/acpi/Kconfig +2 -0
+                      "please report on [email protected]",
+
Quoted 2 lines

acpi_device_bid(quickstart->device));
+ }

Please remove above printks. they are misleading, which isn't an error. please send an ACPI event to userspace in the notify, we need it for runtime.

Quoted 7 lines
Quoted 4 lines

According to the Microsoft paper, runtime hot button reporting is optional. My laptop doesn't report them and on the SF.net project page there was no reports of people with hardware supporting this.
Sorry, I don't have a way to test this..

Did you tried suspend/resume. From the doc, resume can send a notification too. Just calling acpi event eject routines, an event eject model can be well integrated into existing acpi daemons.

Yes, suspend to mem works.
When the laptop is in suspend state, if DVD button is pressed the laptop resumes and the platform driver receives a notify. The driver then exports the button name to the sysfs pressed_button file.

Quoted 26 lines
Quoted 26 lines
Quoted 5 lines
Quoted 2 lines

+ }

I'd suggest the GHID info should be exported to sysfs too. It's hard to judge what a button is just per its name. You know it but an inexperienced user doesn't.

I also would like to have a more descriptive information about the button but the returned buffer is a BYTE/WORD/DWORD with a decimal number telling the button usage ID.

Looking at my DSDT piece of code:

Method (GHID, 0, NotSerialized)

{
   If (LEqual (HOTB, 0x05))
   {
      Notify (DBTN, 0x02)
      Store (0x00, HOTB)
   }

   Return (Buffer (0x01)
   {
      /* 0000 */    0x04
   })
}
Quoted 4 lines
Quoted 1 line

IMHO, a value like 0x04 for button usageID is totally useless..

Ok, I got it. Maybe we need tool to help user identify what purpose a button is, but sounds impossible till the button can trigger runtime event.

I've noticed that HP laptops have the same names for button
devices (at least dv6k, dv8k and tx series). Maybe other vendors do this as well? If this holds true, maybe building a vendor table for getting
button name -> description correspondence? .. just an idea ..

Quoted 4 lines

Thanks,
Shaohua

Thanks all,
- --
Angelo Arrifano AKA MiKNiX
CSE Student at UBI, Portugal
Gentoo Linux AMD64 Arch Tester
Linwizard Developer
http://miknix.homelinux.com
PGP Pubkey 0x3D92BB0B

- - -
Computers are like air conditioners. Both stop working, if you open windows.
-- Adam Heath
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)

iD8DBQFH7UlnNahyoD2SuwsRApPtAJ9GcFwvwuAgCyCnS87XaGI+nHAbYgCeM65K lvOIGf01TPFzAgqFbSoFJYY=
=vrGR
-----END PGP SIGNATURE-----
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw
Quoted 160 lines · On Fri, 28 Mar 2008 19:39:19 +0000 Ângelo Miguel Arrifano <[email protected]>…

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 85 lines · On Fri, 28 Mar 2008 09:36:55 +0800 Shaohua Li <[email protected]> wrote:
Quoted 49 lines · Ângelo Miguel Arrifano
Quoted 30 lines · On Thu, 27 Mar 2008 10:30:13 +0800 Shaohua Li <[email protected]> wrote:
Quoted 7 lines · Ângelo Miguel Arrifano

PATCH
- -----------------------------------------------------------------

drivers/acpi/Kconfig +1 -1
index f688c21..fb096ee 100644
- --- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig

drivers/acpi/Kconfig config ACPI_THERMAL · line 202

Quoted 7 lines
drivers/acpi/Kconfig +3 -0
@@ -196,6 +196,14 @@ config ACPI_THERMAL
          recommended that this option be enabled, as your
 processor(s)
          may be damaged without it.
 
+config ACPI_QUICKSTART
+       tristate "Quickstart"
+       default y

default m?

drivers/acpi/Kconfig config ACPI_THERMAL

Quoted 8 lines
drivers/acpi/Kconfig +8 -0
+
+static struct quickstart_driver_data {
+       struct quickstart_btn *btn_lst;
+       struct quickstart_btn *pressed;
+} quickstart_data = {
+       .btn_lst = NULL,
+       .pressed = NULL,
+};

They are NULL, you don't need initialize them.

Quoted 15 lines
Quoted 4 lines

+ * Platform driver structs
+ */

drivers/acpi/Kconfig +2 -0
+static ssize_t buttons_show(struct device *dev,
+                                       struct device_attribute *attr,

drivers/acpi/Kconfig

Quoted 10 lines
drivers/acpi/Kconfig +10 -0
+                                       char *buf);
+static ssize_t pressed_button_show(struct device *dev,
+                                       struct device_attribute *attr,
+                                       char *buf);
+static ssize_t pressed_button_store(struct device *dev,
+                                       struct device_attribute *attr,
+                                        const char *buf,
+                                        size_t count);
+static DEVICE_ATTR(pressed_button, 0666, pressed_button_show,
+                                        pressed_button_store);

this file can be changed by non-root?

Quoted 3 lines

The only thing that writing to this file does is clearing the pressed button.
Is it a bad idea that can be changed by non-root?

Just abnormal, eg. non-root can clear it but root might not read it (though it doesn't happen in current case but possible if runtime event support).

Quoted 27 lines
Quoted 26 lines
Quoted 21 lines
drivers/acpi/Kconfig +3 -0
+
+/* ACPI Driver functions */
+static void quickstart_acpi_notify(acpi_handle handle, u32 event,

void *data)

drivers/acpi/Kconfig +9 -0
+{
+       struct quickstart_acpi *quickstart = data;
+
+       if (!quickstart)
+               return;
+
+       if (event == QUICKSTART_EVENT_WAKE) {
+               quickstart_data.pressed = quickstart->btn;
+               printk(KERN_ERR "quickstart: Quickbutton %s

pressed.\n",
+
acpi_device_bid(quickstart->device));

drivers/acpi/Kconfig +2 -0
+       } else if (event == QUICKSTART_EVENT_RUNTIME) {
+               printk(KERN_ERR "quickstart: Runtime button %s

pressed.\n\t"

drivers/acpi/Kconfig +2 -0
+                      "please report on [email protected]",
+
Quoted 2 lines

acpi_device_bid(quickstart->device));
+ }

Please remove above printks. they are misleading, which isn't an error. please send an ACPI event to userspace in the notify, we need it for runtime.

Quoted 7 lines
Quoted 4 lines

According to the Microsoft paper, runtime hot button reporting is optional. My laptop doesn't report them and on the SF.net project page there was no reports of people with hardware supporting this.
Sorry, I don't have a way to test this..

Did you tried suspend/resume. From the doc, resume can send a notification too. Just calling acpi event eject routines, an event eject model can be well integrated into existing acpi daemons.

Yes, suspend to mem works.
When the laptop is in suspend state, if DVD button is pressed the laptop resumes and the platform driver receives a notify. The driver then exports the button name to the sysfs pressed_button file.

Quoted 26 lines
Quoted 26 lines
Quoted 5 lines
Quoted 2 lines

+ }

I'd suggest the GHID info should be exported to sysfs too. It's hard to judge what a button is just per its name. You know it but an inexperienced user doesn't.

I also would like to have a more descriptive information about the button but the returned buffer is a BYTE/WORD/DWORD with a decimal number telling the button usage ID.

Looking at my DSDT piece of code:

Method (GHID, 0, NotSerialized)

{
   If (LEqual (HOTB, 0x05))
   {
      Notify (DBTN, 0x02)
      Store (0x00, HOTB)
   }

   Return (Buffer (0x01)
   {
      /* 0000 */    0x04
   })
}
Quoted 4 lines
Quoted 1 line

IMHO, a value like 0x04 for button usageID is totally useless..

Ok, I got it. Maybe we need tool to help user identify what purpose a button is, but sounds impossible till the button can trigger runtime event.

I've noticed that HP laptops have the same names for button
devices (at least dv6k, dv8k and tx series). Maybe other vendors do this as well? If this holds true, maybe building a vendor table for getting
button name -> description correspondence? .. just an idea ..

Quoted 4 lines

Thanks,
Shaohua

Thanks all,
- --
Angelo Arrifano AKA MiKNiX
CSE Student at UBI, Portugal
Gentoo Linux AMD64 Arch Tester
Linwizard Developer
http://miknix.homelinux.com
PGP Pubkey 0x3D92BB0B

- - -
Computers are like air conditioners. Both stop working, if you open windows.
-- Adam Heath
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)

Quoted 4 lines

iD8DBQFH7UlnNahyoD2SuwsRApPtAJ9GcFwvwuAgCyCnS87XaGI+nHAbYgCeM65K lvOIGf01TPFzAgqFbSoFJYY=
=vrGR
-----END PGP SIGNATURE-----

Hello,

I have been testing the driver against latest trees. The driver still works without changes.
I would like to ask if, is this driver eligible for inclusion on the acpi-test branch?

Best regards,

Signature · 10 lines
Angelo Arrifano AKA MiKNiX
CSE Student at UBI, Portugal
Gentoo Linux AMD64 Arch Tester
Linwizard Developer
http://miknix.homelinux.com
PGP Pubkey 0x3D92BB0B
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#8 lore raw
Quoted 194 lines · Ângelo Miguel Arrifano
Quoted 13 lines · On Fri, 28 Mar 2008 19:39:19 +0000 Ângelo Miguel Arrifano <[email protected]>…

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 7 lines · On Fri, 28 Mar 2008 09:36:55 +0800 Shaohua Li <[email protected]> wrote:
Quoted 5 lines · Ângelo Miguel Arrifano
Quoted 2 lines · On Thu, 27 Mar 2008 10:30:13 +0800 Shaohua Li <[email protected]> wrote:

On Thu, 2008-03-27 at 01:51 +0800, Ângelo Miguel Arrifano

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

PATCH
-

-----------------------------------------------------------------

Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines

drivers/acpi/Kconfig config ACPI_THERMAL · line 202

Quoted 12 lines
drivers/acpi/Kconfig +4 -1
index f688c21..fb096ee 100644
- --- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -196,6 +196,14 @@ config ACPI_THERMAL
          recommended that this option be enabled, as your
 processor(s)
          may be damaged without it.
 
+config ACPI_QUICKSTART
+       tristate "Quickstart"
+       default y

default m?

drivers/acpi/Kconfig config ACPI_THERMAL

Quoted 8 lines
drivers/acpi/Kconfig +8 -0
+
+static struct quickstart_driver_data {
+       struct quickstart_btn *btn_lst;
+       struct quickstart_btn *pressed;
+} quickstart_data = {
+       .btn_lst = NULL,
+       .pressed = NULL,
+};

They are NULL, you don't need initialize them.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

drivers/acpi/Kconfig

Quoted 4 lines

+ * Platform driver structs
+ */

drivers/acpi/Kconfig +2 -0
+static ssize_t buttons_show(struct device *dev,
+                                       struct

device_attribute *attr,

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

drivers/acpi/Kconfig

Quoted 3 lines
drivers/acpi/Kconfig +3 -0
+                                       char *buf);
+static ssize_t pressed_button_show(struct device *dev,
+                                       struct

device_attribute *attr,

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

drivers/acpi/Kconfig

Quoted 3 lines
drivers/acpi/Kconfig +3 -0
+                                       char *buf);
+static ssize_t pressed_button_store(struct device *dev,
+                                       struct

device_attribute *attr,

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

drivers/acpi/Kconfig

Quoted 3 lines
drivers/acpi/Kconfig +3 -0
+                                        const char *buf,
+                                        size_t count);
+static DEVICE_ATTR(pressed_button, 0666,

pressed_button_show,

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+

pressed_button_store);

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 1 line

this file can be changed by non-root?

The only thing that writing to this file does is clearing the pressed button.
Is it a bad idea that can be changed by non-root?

Just abnormal, eg. non-root can clear it but root might not read

it

Quoted 1 line
Quoted 1 line

(though it doesn't happen in current case but possible if runtime

event

Quoted 5 lines
Quoted 5 lines

support).

Quoted 3 lines
Quoted 3 lines

drivers/acpi/Kconfig

Quoted 3 lines
drivers/acpi/Kconfig +3 -0
+
+/* ACPI Driver functions */
+static void quickstart_acpi_notify(acpi_handle handle, u32

event,

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

void *data)

drivers/acpi/Kconfig +6 -0
+{
+       struct quickstart_acpi *quickstart = data;
+
+       if (!quickstart)
+               return;
+
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/acpi/Kconfig

Quoted 8 lines
drivers/acpi/Kconfig +3 -0
+       if (event == QUICKSTART_EVENT_WAKE) {
+               quickstart_data.pressed = quickstart->btn;
+               printk(KERN_ERR "quickstart: Quickbutton %s

pressed.\n",
+
acpi_device_bid(quickstart->device));

drivers/acpi/Kconfig +2 -0
+       } else if (event == QUICKSTART_EVENT_RUNTIME) {
+               printk(KERN_ERR "quickstart: Runtime button

%s

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

pressed.\n\t"
+ "please report on

[email protected]",

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

+
acpi_device_bid(quickstart->device));
+ }

Please remove above printks. they are misleading, which isn't

an error.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

please send an ACPI event to userspace in the notify, we need

it for

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

runtime.

According to the Microsoft paper, runtime hot button reporting

is optional.

Quoted 1 line
Quoted 1 line
Quoted 1 line

My laptop doesn't report them and on the SF.net project page

there was no

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

reports of people with hardware supporting this.
Sorry, I don't have a way to test this..

Did you tried suspend/resume. From the doc, resume can send a notification too. Just calling acpi event eject routines, an event

eject

Quoted 4 lines
Quoted 1 line

model can be well integrated into existing acpi daemons.

Yes, suspend to mem works.
When the laptop is in suspend state, if DVD button is pressed the

laptop resumes

Quoted 1 line

and the platform driver receives a notify. The driver then exports

the

Quoted 5 lines

button name to the sysfs pressed_button file.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

+ }

I'd suggest the GHID info should be exported to sysfs too.

It's hard to

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

judge what a button is just per its name. You know it but an inexperienced user doesn't.

I also would like to have a more descriptive information about

the button but

Quoted 1 line
Quoted 1 line
Quoted 1 line

the returned buffer is a BYTE/WORD/DWORD with a decimal number

telling the button

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

usage ID.

Looking at my DSDT piece of code:

Method (GHID, 0, NotSerialized)

{
   If (LEqual (HOTB, 0x05))
   {
      Notify (DBTN, 0x02)
      Store (0x00, HOTB)
   }
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
   Return (Buffer (0x01)
   {
      /* 0000 */    0x04
   })
}

IMHO, a value like 0x04 for button usageID is totally useless..

Ok, I got it. Maybe we need tool to help user identify what

purpose a

Quoted 1 line
Quoted 1 line

button is, but sounds impossible till the button can trigger

runtime

Quoted 4 lines
Quoted 1 line

event.

I've noticed that HP laptops have the same names for button devices (at least dv6k, dv8k and tx series). Maybe other vendors do

this as well?

Quoted 17 lines

If this holds true, maybe building a vendor table for getting button name -> description correspondence? .. just an idea ..

Quoted 4 lines

Thanks,
Shaohua

Thanks all,
- --
Angelo Arrifano AKA MiKNiX
CSE Student at UBI, Portugal
Gentoo Linux AMD64 Arch Tester
Linwizard Developer
http://miknix.homelinux.com
PGP Pubkey 0x3D92BB0B

Quoted 2 lines

- - -
Computers are like air conditioners. Both stop working, if you open

windows.

Quoted 8 lines

-- Adam Heath
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)

iD8DBQFH7UlnNahyoD2SuwsRApPtAJ9GcFwvwuAgCyCnS87XaGI+nHAbYgCeM65K lvOIGf01TPFzAgqFbSoFJYY=
=vrGR
-----END PGP SIGNATURE-----

Quoted 7 lines

Hello,

I have been testing the driver against latest trees. The driver still works without changes.
I would like to ask if, is this driver eligible for inclusion on the acpi-test branch?

oops, sorry that we lost track of this patch, but it should be somewhere in Len's tree.
cc len. :)

thanks,
rui

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#9 lore raw
Quoted 9 lines · Zhang Rui
Quoted 6 lines

I have been testing the driver against latest trees. The driver still works without changes.
I would like to ask if, is this driver eligible for inclusion on the acpi-test branch?

oops, sorry that we lost track of this patch, but it should be somewhere in Len's tree.
cc len. :)

I don't think we have it anywhere. Best to resubmit it.

-Andi

#10 lore raw
Quoted 7 lines · On Tue, 26 Aug 2008 20:43:45 +0200 Andi Kleen <[email protected]> wrote:
Quoted 6 lines · Zhang Rui
Quoted 6 lines

I have been testing the driver against latest trees. The driver still works without changes.
I would like to ask if, is this driver eligible for inclusion on the acpi-test branch?

Quoted 8 lines
Quoted 3 lines

oops, sorry that we lost track of this patch, but it should be somewhere in Len's tree.
cc len. :)

I don't think we have it anywhere. Best to resubmit it.

-Andi

Ok thanks, here it is.
-Angelo

drivers/acpi/Kconfig +8 -0
index c52fca8..ed48a56 100644
@@ -199,6 +199,14 @@ config ACPI_THERMAL
 	  recommended that this option be enabled, as your processor(s)
 	  may be damaged without it.
 
+config ACPI_QUICKSTART
+	tristate "Quickstart"
+	default m
+	help
+	  This driver add support for ACPI Direct Application Launch
+	  also known as Hotstart(TM). Say yes here to have a entry in
+	  sysfs telling which button was used to turn on the system.
+
 config ACPI_NUMA
 	bool "NUMA support"
 	depends on NUMA
drivers/acpi/Makefile +1 -0
index 40b0fca..df74d57 100644
@@ -62,3 +62,4 @@ obj-$(CONFIG_ACPI_HOTPLUG_MEMORY)	+= acpi_memhotplug.o
 obj-$(CONFIG_ACPI_PROCFS_POWER)	+= cm_sbs.o
 obj-$(CONFIG_ACPI_SBS)		+= sbshc.o
 obj-$(CONFIG_ACPI_SBS)		+= sbs.o
+obj-$(CONFIG_ACPI_QUICKSTART)	+= quickstart.o
drivers/acpi/quickstart.c new file +427 -0

427 lines not on this page · raw message

#11 lore raw
Quoted 1 line

Ok thanks, here it is.

Please submit it with proper description and Signed-off-by lines. (see Documentation/SubmittingPatches)

-Andi

#12 lore raw
Quoted 6 lines · On Thu, 28 Aug 2008 15:08:05 +0200 Andi Kleen <[email protected]> wrote:
Quoted 1 line

Ok thanks, here it is.

Please submit it with proper description and Signed-off-by lines. (see Documentation/SubmittingPatches)

-Andi

Description:
With the introduction of Vista, Microsoft launched a new ACPI
?specification? to allow computers in sleep/off states to boot directly into multimedia applications by only pressing buttons.
This driver provides support to these devices allowing userspace
scripts to launch multimedia applications based on which button was used to turn on the system.

How it works:
When the system boots, the driver receives an ACPI event telling
which button was used to power the system on. Then, the driver exports this information to sysfs allowing userspace scripts to know the button name. This also applies to memory suspend and other power saving states.

Example:
* File buttons shows a list of supported hot buttons.

  $ cat /sys/devices/platform/quickstart/buttons
  QBTN
  DBTN
  MUBN
  PIBN
  WEBN
  LVBN
  VOBN

* File pressed_button shows the hot button name used to power/resume the system. You can also write "none" to it to reset.

  $ cat /sys/devices/platform/quickstart/pressed_button
  none

References:
* http://download.microsoft.com/download/9/c/5/9c5b2167-8017-4bae-9fde-d599bac8184a/DirAppLaunch_Vista.doc

----------------------------------------

drivers/acpi/Kconfig +8 -0
index c52fca8..ed48a56 100644
@@ -199,6 +199,14 @@ config ACPI_THERMAL
 	  recommended that this option be enabled, as your processor(s)
 	  may be damaged without it.
 
+config ACPI_QUICKSTART
+	tristate "Quickstart"
+	default m
+	help
+	  This driver add support for ACPI Direct Application Launch
+	  also known as Hotstart(TM). Say yes here to have a entry in
+	  sysfs telling which button was used to turn on the system.
+
 config ACPI_NUMA
 	bool "NUMA support"
 	depends on NUMA
drivers/acpi/Makefile +1 -0
index 40b0fca..df74d57 100644
@@ -62,3 +62,4 @@ obj-$(CONFIG_ACPI_HOTPLUG_MEMORY)	+= acpi_memhotplug.o
 obj-$(CONFIG_ACPI_PROCFS_POWER)	+= cm_sbs.o
 obj-$(CONFIG_ACPI_SBS)		+= sbshc.o
 obj-$(CONFIG_ACPI_SBS)		+= sbs.o
+obj-$(CONFIG_ACPI_QUICKSTART)	+= quickstart.o
drivers/acpi/quickstart.c new file +427 -0

427 lines not on this page · raw message

#13 lore raw
Quoted 9 lines · Ângelo Miguel Arrifano
Quoted 6 lines · On Thu, 28 Aug 2008 15:08:05 +0200 Andi Kleen <[email protected]> wrote:
Quoted 1 line

Ok thanks, here it is.

Please submit it with proper description and Signed-off-by lines. (see Documentation/SubmittingPatches)

-Andi

Quick review:

Need a title (one line description)

Best probably you run it through checkpatch.pl and fix the warnings and possibly also Lindent.

drivers/acpi/Kconfig config ACPI_THERMAL · line 204

Quoted 10 lines

index c52fca8..ed48a56 100644

drivers/acpi/Kconfig +3 -0
@@ -199,6 +199,14 @@ config ACPI_THERMAL
 	  recommended that this option be enabled, as your processor(s)
 	  may be damaged without it.
 
+config ACPI_QUICKSTART
+	tristate "Quickstart"
+	default m

Please remove the default m

Also I think the position is wrong, this should be further down with other misc ACPI drivers.

drivers/acpi/Kconfig config ACPI_THERMAL · line 208

Quoted 4 lines
drivers/acpi/Kconfig +4 -0
+
+#define QUICKSTART_PF_DRIVER_NAME     "quickstart"
+#define QUICKSTART_PF_DEVICE_NAME     "quickstart"
+#define QUICKSTART_PF_DEVATTR_NAME    "pressed_button"

I don't see the point of these defines. Can you just expand them please?

drivers/acpi/Kconfig config ACPI_THERMAL

Quoted 9 lines
drivers/acpi/Kconfig +9 -0
+
+/*
+ * ACPI driver Structs
+ */
+
+struct quickstart_acpi {
+	struct acpi_device *device;
+	struct quickstart_btn *btn;
+};

There should be a new line here.

drivers/acpi/Kconfig

Quoted 2 lines
drivers/acpi/Kconfig +2 -0
+static int quickstart_acpi_add(struct acpi_device *device);
+static int quickstart_acpi_remove(struct acpi_device *device, int type);

Standard practice is to reorder the file that forward declarations are not needed.

drivers/acpi/Kconfig

Quoted 8 lines
drivers/acpi/Kconfig +8 -0
+
+static struct acpi_driver quickstart_acpi_driver = {
+	.name = "quickstart",
+	.class = QUICKSTART_ACPI_CLASS,
+	.ids = quickstart_device_ids,
+	.ops = {
+			.add = quickstart_acpi_add,
+			.remove = quickstart_acpi_remove,

Unusual indentation.

Quoted 6 lines
drivers/acpi/Kconfig +6 -0
+		},
+};
+
+/*
+ * Platform driver structs
+ */

drivers/acpi/Kconfig

Quoted 10 lines
drivers/acpi/Kconfig +10 -0
+static ssize_t buttons_show(struct device *dev,
+					struct device_attribute *attr,
+					char *buf);
+static ssize_t pressed_button_show(struct device *dev,
+					struct device_attribute *attr,
+					char *buf);
+static ssize_t pressed_button_store(struct device *dev,
+					struct device_attribute *attr,
+					 const char *buf,
+					 size_t count);

See above for forward declarations.

Quoted 9 lines

+ */

drivers/acpi/Kconfig +8 -0
+static ssize_t buttons_show(struct device *dev,
+					 struct device_attribute *attr,
+					 char *buf)
+{
+	int count = 0;
+	struct quickstart_btn *ptr = quickstart_data.btn_lst;
+
+	if (!ptr)

drivers/acpi/Kconfig

Quoted 10 lines
drivers/acpi/Kconfig +10 -0
+		return snprintf(buf, PAGE_SIZE, "none");
+
+	while (ptr && (count < PAGE_SIZE)) {
+		if (ptr->name) {
+			count += snprintf(buf + count,
+					PAGE_SIZE - count,
+					"%s\n", ptr->name);
+		}
+		ptr = ptr->next;
+	}

Is it guaranteed that list is always shorter than PAGE_SIZE? PAGE_SIZE - count might go negative otherwise and snprintf will not handle that. Should be some proper limit.

drivers/acpi/Kconfig

Quoted 8 lines
drivers/acpi/Kconfig +8 -0
+
+
+static ssize_t pressed_button_store(struct device *dev,
+					 struct device_attribute *attr,
+					 const char *buf, size_t count)
+{
+	if (count < 2)
+		return -EINVAL;

Check is redundant.

Quoted 5 lines
drivers/acpi/Kconfig +5 -0
+
+	if (strncasecmp(buf, "none", 4) != 0)
+		return -EINVAL;
+
+	quickstart_data.pressed = NULL;

drivers/acpi/Kconfig

Quoted 10 lines
drivers/acpi/Kconfig +10 -0
+	return count;
+}
+
+/* Hotstart Helper functions */
+static int quickstart_btnlst_add(struct quickstart_btn **data)
+{
+	struct quickstart_btn **ptr = &quickstart_data.btn_lst;
+
+	while (*ptr)
+		ptr = &((*ptr)->next);

Would be all clearer if you used standard list.h lists.

drivers/acpi/Kconfig

Quoted 11 lines
drivers/acpi/Kconfig +10 -0
+	ret = quickstart_btnlst_add(&quickstart->btn);
+	if (ret)
+		return ret;
+
+	quickstart->btn->name = kzalloc(len + 1, GFP_KERNEL);
 
+	if (!quickstart->btn->name) {
+		quickstart_btnlst_free();
+		return -ENOMEM;
+	}
+	strcpy(quickstart->btn->name, bid);

Use kstrndup()

drivers/acpi/Kconfig

Quoted 10 lines
drivers/acpi/Kconfig +10 -0
+
+	platform_device_unregister(pf_device);
+
+	platform_driver_unregister(&pf_driver);
+
+	acpi_bus_unregister_driver(&quickstart_acpi_driver);
+
+	quickstart_btnlst_free();
+
+	return;

You have a lot of stray such returns; Remove them all.

Quoted 1 line

That should be at the bottom of the description.

-Andi

Signature · 5 lines
[email protected]
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#14 lore raw
In reply to Ângelo Miguel Arrifano

drivers/acpi/quickstart.c line 52

Quoted 3 lines · Ângelo Miguel Arrifano
drivers/acpi/quickstart.c new file +3 -0
+/* There will be two events:
+	 * 0x02 - A hot button was pressed while device was off/sleeping.
+	 * 0x08 - A hot button was pressed while device was up. */

Are you sure? The spec seems to say 0x80, not 0x08.

Quoted 1 line

+#define QUICKSTART_EVENT_RUNTIME 0x80

As you have here :)

Could you add an input device for runtime button notification? Use the GHID value as a scancode, then provide functions to do scancode->keycode mappings (see wistron_btns.c or hp_wmi.c for examples of this). That way, hal or whatever can be used to map them to machine-specific values.

Signature · 5 lines
Matthew Garrett | [email protected]
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#15 lore raw
Quoted 8 lines · On Thu, 28 Aug 2008 14:40:55 +0100 Matthew Garrett <[email protected]> wrote:

Review

Quoted 3 lines · Ângelo Miguel Arrifano
(quoted diff) +3 -0
+/* There will be two events:
+	 * 0x02 - A hot button was pressed while device was off/sleeping.
+	 * 0x08 - A hot button was pressed while device was up. */

Are you sure? The spec seems to say 0x80, not 0x08.

Quoted 11 lines
Quoted 1 line

+#define QUICKSTART_EVENT_RUNTIME 0x80

As you have here :)

Could you add an input device for runtime button notification? Use the GHID value as a scancode, then provide functions to do scancode->keycode mappings (see wistron_btns.c or hp_wmi.c for examples of this). That way, hal or whatever can be used to map them to machine-specific values.

Signature · 1 line
Matthew Garrett | [email protected]

Patch below includes proposed changes for runtime button notification. I could not fully test it since my laptop doesn't report runtime key presses.

NOTE: There are some inline comments in the patch below.

-- Thanks, Angelo Arrifano

drivers/acpi/Kconfig +8 -0
index c52fca8..ed48a56 100644
@@ -199,6 +199,14 @@ config ACPI_THERMAL
 	  recommended that this option be enabled, as your processor(s)
 	  may be damaged without it.
 
+config ACPI_QUICKSTART
+	tristate "Quickstart"
+	default m
+	help
+	  This driver add support for ACPI Direct Application Launch
+	  also known as Hotstart(TM). Say yes here to have a entry in
+	  sysfs telling which button was used to turn on the system.
+
 config ACPI_NUMA
 	bool "NUMA support"
 	depends on NUMA
drivers/acpi/Makefile +1 -0
index 40b0fca..df74d57 100644
@@ -62,3 +62,4 @@ obj-$(CONFIG_ACPI_HOTPLUG_MEMORY)	+= acpi_memhotplug.o
 obj-$(CONFIG_ACPI_PROCFS_POWER)	+= cm_sbs.o
 obj-$(CONFIG_ACPI_SBS)		+= sbshc.o
 obj-$(CONFIG_ACPI_SBS)		+= sbs.o
+obj-$(CONFIG_ACPI_QUICKSTART)	+= quickstart.o
drivers/acpi/quickstart.c new file +132 -0

132 lines not on this page · raw message

Added the button usage ID to the button list. The button usage ID is returned by the GHID method. Ex:

cat /sys/ . . . /buttons
1 QBTN
2 DBTN
3 MUBN
6 PIBN
4 WEBN
8 LVBN
7 VOBN

+ }
+ ptr = ptr->next;
+ }
+
+ return count;
+}
+
+static ssize_t pressed_button_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "%s\n",
+ (quickstart_data.pressed?quickstart_data.pressed->name:"none"));
+}
+
+
+static ssize_t pressed_button_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ if (count < 2)
+ return -EINVAL;
+
+ if (strncasecmp(buf, "none", 4) != 0)
+ return -EINVAL;
+
+ quickstart_data.pressed = NULL;
+ return count;
+}
+
+/* Hotstart Helper functions */
+static int quickstart_btnlst_add(struct quickstart_btn **data) +{
+ struct quickstart_btn **ptr = &quickstart_data.btn_lst;
+
+ while (*ptr)
+ ptr = &((*ptr)->next);
+
+ *ptr = kzalloc(sizeof(struct quickstart_btn), GFP_KERNEL);
+ if (!*ptr) {
+ *data = NULL;
+ return -ENOMEM;
+ }
+ *data = *ptr;
+
+ return 0;
+}
+
+static void quickstart_btnlst_del(struct quickstart_btn *data) +{
+ struct quickstart_btn **ptr = &quickstart_data.btn_lst;
+
+ if (!data)
+ return;
+
+ while (*ptr) {
+ if (*ptr == data) {
+ *ptr = (*ptr)->next;
+ kfree(data);
+ return;
+ }
+ ptr = &((*ptr)->next);
+ }
+
+ return;
+}
+
+static void quickstart_btnlst_free(void)
+{
+ struct quickstart_btn *ptr = quickstart_data.btn_lst;
+ struct quickstart_btn *lptr = NULL;
+
+ while (ptr) {
+ lptr = ptr;
+ ptr = ptr->next;
+ kfree(lptr->name);
+ kfree(lptr);
+ }
+
+ return;
+}
+
+/* ACPI Driver functions */
+static void quickstart_acpi_notify(acpi_handle handle, u32 event, void *data) +{
+ struct quickstart_acpi *quickstart = data;
+
+ if (!quickstart)
+ return;
+
+ if (event == QUICKSTART_EVENT_WAKE)
+ quickstart_data.pressed = quickstart->btn;
+ else if (event == QUICKSTART_EVENT_RUNTIME) {
+ input_report_key(quickstart_input, quickstart->btn->id, 1);
+ input_sync(quickstart_input);
+ input_report_key(quickstart_input, quickstart->btn->id, 0);
+ input_sync(quickstart_input);

The button usage ID is used as key code.

+ }
+ return;
+}
+
+static void quickstart_acpi_ghid(struct quickstart_acpi *quickstart) +{
+ acpi_status status;
+ struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+ unsigned int usageid = 0;
+
+ if (!quickstart)
+ return;
+
+ /* This returns a buffer telling the button usage ID,
+ * and triggers pending notify events (The ones before booting). */
+ status = acpi_evaluate_object(quickstart->device->handle,
+ "GHID", NULL, &buffer);
+ if (ACPI_FAILURE(status) || !buffer.pointer) {
+ printk(KERN_ERR "quickstart: %s GHID method failed.\n",
+ quickstart->btn->name);
+ return;
+ }

This _GHID method can return a BYTE, WORD or DWORD. I guess each vendor chooses which they like most. On my laptop, the returned buffer.length is 32.

Buffer dump:
QBTN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00
DBTN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00
MUBN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00
PIBN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00
WEBN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00
LVBN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00
VOBN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00

                                                                              +---------------------+

Does it return a QWORD?? Why is it at the end of the buffer?

+
+ if (buffer.length < 8)
+ return;
+
+ /* <<The GHID method can return a BYTE, WORD, or DWORD.
+ * The value must be encoded in little-endian byte
+ * order (least significant byte first).>> */
+ ACPI_MOVE_32_TO_32(&usageid, buffer.pointer + (buffer.length - 8));
+ quickstart->btn->id = usageid;

I need your help in here, I doubt this code runs for anyone but me.

+
+ kfree(buffer.pointer);
+}
+
+static int quickstart_acpi_config(struct quickstart_acpi *quickstart, char *bid) +{
+ int len = strlen(bid);
+ int ret;
+
+ /* Add button to list */
+ ret = quickstart_btnlst_add(&quickstart->btn);
+ if (ret)
+ return ret;
+
+ quickstart->btn->name = kzalloc(len + 1, GFP_KERNEL);
+ if (!quickstart->btn->name) {
+ quickstart_btnlst_free();
+ return -ENOMEM;
+ }
+ strcpy(quickstart->btn->name, bid);
+
+ return 0;
+}
+
+static int quickstart_acpi_add(struct acpi_device *device)
+{
+ int ret = 0;
+ acpi_status status = AE_OK;
+ struct quickstart_acpi *quickstart = NULL;
+
+ if (!device)
+ return -EINVAL;
+
+ quickstart = kzalloc(sizeof(struct quickstart_acpi), GFP_KERNEL);
+ if (!quickstart)
+ return -ENOMEM;
+
+ quickstart->device = device;
+ strcpy(acpi_device_name(device), QUICKSTART_ACPI_DEVICE_NAME);
+ strcpy(acpi_device_class(device), QUICKSTART_ACPI_CLASS);
+ acpi_driver_data(device) = quickstart;
+
+ /* Add button to list and initialize some stuff */
+ ret = quickstart_acpi_config(quickstart, acpi_device_bid(device));
+ if (ret)
+ goto fail_config;
+
+ status = acpi_install_notify_handler(device->handle,
+ ACPI_ALL_NOTIFY,
+ quickstart_acpi_notify,
+ quickstart);
+ if (ACPI_FAILURE(status)) {
+ printk(KERN_ERR "quickstart: Notify handler install error\n");
+ ret = -ENODEV;
+ goto fail_installnotify;
+ }
+
+ quickstart_acpi_ghid(quickstart);
+
+ return 0;
+
+fail_installnotify:
+ quickstart_btnlst_del(quickstart->btn);
+
+fail_config:
+
+ kfree(quickstart);
+
+ return ret;
+}
+
+static int quickstart_acpi_remove(struct acpi_device *device, int type) +{
+ acpi_status status = 0;
+ struct quickstart_acpi *quickstart = NULL;
+
+ if (!device || !acpi_driver_data(device))
+ return -EINVAL;
+
+ quickstart = acpi_driver_data(device);
+
+ status = acpi_remove_notify_handler(device->handle,
+ ACPI_ALL_NOTIFY,
+ quickstart_acpi_notify);
+ if (ACPI_FAILURE(status))
+ printk(KERN_ERR "quickstart: Error removing notify handler\n");
+
+
+ kfree(quickstart);
+
+ return 0;
+}
+
+/* Module functions */
+
+static void quickstart_exit(void)
+{
+ input_unregister_device(quickstart_input);
+ input_free_device(quickstart_input);
+
+ device_remove_file(&pf_device->dev, &dev_attr_pressed_button);
+ device_remove_file(&pf_device->dev, &dev_attr_buttons);
+
+ platform_device_unregister(pf_device);
+
+ platform_driver_unregister(&pf_driver);
+
+ acpi_bus_unregister_driver(&quickstart_acpi_driver);
+
+ quickstart_btnlst_free();
+
+ return;
+}
+
+static int __init quickstart_init_input(void)
+{
+ struct quickstart_btn **ptr = &quickstart_data.btn_lst;
+ int count;
+
+ quickstart_input = input_allocate_device();
+
+ if (!quickstart_input)
+ return -ENOMEM;
+
+ quickstart_input->name = "Quickstart ACPI Buttons";
+ quickstart_input->id.bustype = BUS_HOST;
+
+ while (*ptr) {
+ count++;
+ set_bit(EV_KEY, quickstart_input->evbit);
+ set_bit((*ptr)->id, quickstart_input->keybit);
+ ptr = &((*ptr)->next);
+ }
+
+ return input_register_device(quickstart_input);
+}
+
+static int __init quickstart_init(void)
+{
+ int ret;
+ acpi_status status = 0;
+
+ /* ACPI Check */
+ if (acpi_disabled)
+ return -ENODEV;
+
+ /* ACPI driver register */
+ status = acpi_bus_register_driver(&quickstart_acpi_driver);
+ if (status < 0)
+ return -ENODEV;
+
+ /* If existing bus with no devices */
+ if (!quickstart_data.btn_lst) {
+ ret = -ENODEV;
+ goto fail_pfdrv_reg;
+ }
+
+ /* Platform driver register */
+ ret = platform_driver_register(&pf_driver);
+ if (ret)
+ goto fail_pfdrv_reg;
+
+ /* Platform device register */
+ pf_device = platform_device_alloc(QUICKSTART_PF_DEVICE_NAME, -1);
+ if (!pf_device) {
+ ret = -ENOMEM;
+ goto fail_pfdev_alloc;
+ }
+ ret = platform_device_register(pf_device);
+ if (ret)
+ goto fail_pfdev_reg;
+
+ /* Create device sysfs file */
+ ret = device_create_file(&pf_device->dev, &dev_attr_pressed_button);
+ if (ret)
+ goto fail_dev_file;
+
+ ret = device_create_file(&pf_device->dev, &dev_attr_buttons);
+ if (ret)
+ goto fail_dev_file2;
+
+
+ /* Input device */
+ ret = quickstart_init_input();
+ if (ret)
+ goto fail_input;
+
+ printk(KERN_INFO "quickstart: ACPI Direct App Launch ver %s\n",
+ QUICKSTART_VERSION);
+
+ return 0;
+fail_input:
+ device_remove_file(&pf_device->dev, &dev_attr_buttons);
+
+fail_dev_file2:
+ device_remove_file(&pf_device->dev, &dev_attr_pressed_button);
+
+fail_dev_file:
+ platform_device_del(pf_device);
+
+fail_pfdev_reg:
+ platform_device_put(pf_device);
+
+fail_pfdev_alloc:
+ platform_driver_unregister(&pf_driver);
+
+fail_pfdrv_reg:
+ acpi_bus_unregister_driver(&quickstart_acpi_driver);
+
+ return ret;
+}
+
+module_init(quickstart_init);
+module_exit(quickstart_exit);
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#16 lore raw
Quoted 9 lines · Ângelo Miguel Arrifano

On Thu, 28 Aug 2008 14:40:55 +0100
Matthew Garrett <[email protected]> wrote:

(quoted diff) +5 -0
+	else if (event == QUICKSTART_EVENT_RUNTIME) {
+		input_report_key(quickstart_input, quickstart->btn->id, 1);
+		input_sync(quickstart_input);
+		input_report_key(quickstart_input, quickstart->btn->id, 0);
+		input_sync(quickstart_input);

The button usage ID is used as key code.

Right, that's probably not how you want to do it. Keycodes should be the things in include/linux/input.h. The problem you have is that there's no way of mapping the usage ID to the keycode without knowing the specific laptop layout. The right way of doing this is to use the usage ID as a scancode, and then implement the get and setkeycode functions. Userspace can then alter the keymap. Check the wistron_btns driver for an example of this.

Quoted 10 lines

Buffer dump:
QBTN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00
DBTN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00
MUBN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00
PIBN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00
WEBN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00
LVBN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00
VOBN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00

                                                                              +---------------------+

Does it return a QWORD?? Why is it at the end of the buffer?

This is the raw dump of what GHID returns? I'm not quite clear on what's going on here.

Quoted 7 lines
(quoted diff) +5 -0
+	/* <<The GHID method can return a BYTE, WORD, or DWORD.
+	 * The value must be encoded in little-endian byte
+	 * order (least significant byte first).>> */
+	ACPI_MOVE_32_TO_32(&usageid, buffer.pointer + (buffer.length - 8));
+	quickstart->btn->id = usageid;

I need your help in here, I doubt this code runs for anyone but me.

Right. For instance, GHID on another system I have here is just:

                        Method (GHID, 0, NotSerialized)
                        {
                            Acquire (MUT1, 0xFFFF)
                            And (MBTB, 0x02, Local0)
                            Release (MUT1)
                            If (Local0)
                            {
                                Notify (DAL2, 0x02)
                            }

                            Return (Buffer (One)
                            {
                                0x02
                            })

which doesn't look like your code would cope at all.

Signature · 5 lines
Matthew Garrett | [email protected]
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#17 lore raw
Quoted 30 lines · On Sun, 31 Aug 2008 23:00:38 +0100 Matthew Garrett <[email protected]> wrote:
Quoted 9 lines · Ângelo Miguel Arrifano

On Thu, 28 Aug 2008 14:40:55 +0100
Matthew Garrett <[email protected]> wrote:

(quoted diff) +5 -0
+	else if (event == QUICKSTART_EVENT_RUNTIME) {
+		input_report_key(quickstart_input, quickstart->btn->id, 1);
+		input_sync(quickstart_input);
+		input_report_key(quickstart_input, quickstart->btn->id, 0);
+		input_sync(quickstart_input);

The button usage ID is used as key code.

Right, that's probably not how you want to do it. Keycodes should be the things in include/linux/input.h. The problem you have is that there's no way of mapping the usage ID to the keycode without knowing the specific laptop layout. The right way of doing this is to use the usage ID as a scancode, and then implement the get and setkeycode functions. Userspace can then alter the keymap. Check the wistron_btns driver for an example of this.

Quoted 10 lines

Buffer dump:
QBTN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00
DBTN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00
MUBN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00
PIBN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00
WEBN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00
LVBN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00
VOBN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00

                                                                              +---------------------+

Does it return a QWORD?? Why is it at the end of the buffer?

Quoted 2 lines

This is the raw dump of what GHID returns? I'm not quite clear on what's going on here.

Yes, GHID returns a auto-allocated buffer of 32bytes.

For instance, the returned buffer for WEBN device is:
03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00

                                                                        /\

4 is the button usage ID (see bellow). I don't know why is in that place and why the rest of the garbage.

Quoted 26 lines
Quoted 8 lines
(quoted diff) +5 -0
+	/* <<The GHID method can return a BYTE, WORD, or DWORD.
+	 * The value must be encoded in little-endian byte
+	 * order (least significant byte first).>> */
+	ACPI_MOVE_32_TO_32(&usageid, buffer.pointer + (buffer.length - 8));
+	quickstart->btn->id = usageid;

I need your help in here, I doubt this code runs for anyone but me.

Right. For instance, GHID on another system I have here is just:

                        Method (GHID, 0, NotSerialized)
                        {
                            Acquire (MUT1, 0xFFFF)
                            And (MBTB, 0x02, Local0)
                            Release (MUT1)
                            If (Local0)
                            {
                                Notify (DAL2, 0x02)
                            }

                            Return (Buffer (One)
                            {
                                0x02
                            })
Quoted 1 line

which doesn't look like your code would cope at all.

The GHID method here is also similar:

           Method (GHID, 0, NotSerialized)
            {
                If (LEqual (HOTB, 0x10))
                {
                    Notify (WEBN, 0x02)
                    Store (Zero, HOTB)
                }

                Return (Buffer (One)
                {
                    /* 0000 */    0x04
                })
            }

Shouldn't GHID be returning a 1 byte buffer?

Quoted 3 lines
Signature · 2 lines
-- 
Matthew Garrett | [email protected]

Are you able to dump the returned buffer somewhere?

Thanks,
Angelo Arrifano
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html