All of lore.kernel.org
 help / color / mirror / Atom feed
* *NEW* ACPI driver to support App Hot Startup AKA PNP0C32
@ 2007-11-10  1:44 Ângelo Miguel Arrifano
  2007-11-10  3:21 ` Carlos Corbacho
  0 siblings, 1 reply; 9+ messages in thread
From: Ângelo Miguel Arrifano @ 2007-11-10  1:44 UTC (permalink / raw)
  To: linux-acpi

[-- Attachment #1: Type: text/plain, Size: 1380 bytes --]

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

Hello everyone,

I made a driver to allow booting into specific apps by pressing
hot buttons. This functionality is provided by PNP0C32 which all
Vista capable laptops should have.

If the laptop is turned off and a hot button is pressed, the
computer turns on and boots. This module gets a notification from
ACPI which button was pressed. Then the driver writes to the proc
fs which button was pressed allowing userspace apps to read that
files and behave accordingly. Proc files are also writable.

Eg:
ls /proc/acpi/hotstart/
DBTN  LVBN  MUBN  PIBN  QBTN  VOBN  WEBN

DBTN is DVD Button
WEBN is WWW Button

I've uploaded everything to my personal server (very bandwidth limited).
http://miknix.homelinux.com/hotstart/

It's also attached here, just in case my ISP might do the usual...

I did only test on my own laptop.
I hope you like it.
- -- 
Angelo Arrifano AKA MiKNiX
CSE Student at UBI, Portugal
Gentoo Linux AMD64 Arch Tester
miknix@gmail.com
http://miknix.homelinux.com
PGP Pubkey online

- - -
Abstainer, n.:
	A weak person who yields to the temptation of denying himself a
	pleasure.
		-- Ambrose Bierce, "The Devil's Dictionary"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFHNQ0NNahyoD2SuwsRAlvPAJ0XEB+iOVsHhZ6HsVQ+a2Jjqe9qfwCgnuO8
JOigajLDRR20vF8sNDeY2FY=
=Gwau
-----END PGP SIGNATURE-----

[-- Attachment #2: hotstart-001.tar.bz2 --]
[-- Type: application/x-bzip, Size: 4381 bytes --]

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

* Re: *NEW* ACPI driver to support App Hot Startup AKA PNP0C32
  2007-11-10  1:44 *NEW* ACPI driver to support App Hot Startup AKA PNP0C32 Ângelo Miguel Arrifano
@ 2007-11-10  3:21 ` Carlos Corbacho
  2007-11-12  0:05   ` Ângelo Miguel Arrifano
  0 siblings, 1 reply; 9+ messages in thread
From: Carlos Corbacho @ 2007-11-10  3:21 UTC (permalink / raw)
  To: Ângelo Miguel Arrifano; +Cc: linux-acpi

Ângelo,

On Saturday 10 November 2007 01:44:48 Ângelo Miguel Arrifano wrote:
> If the laptop is turned off and a hot button is pressed, the
> computer turns on and boots. This module gets a notification from
> ACPI which button was pressed. Then the driver writes to the proc
> fs which button was pressed allowing userspace apps to read that
> files and behave accordingly. Proc files are also writable.

Please use sysfs, not proc (even if you aren't considering submitting this 
upstream) - /proc/acpi is deprecated and going away (slowly but surely).

-Carlos
-- 
E-Mail: carlos@strangeworlds.co.uk
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D
-
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: *NEW* ACPI driver to support App Hot Startup AKA PNP0C32
  2007-11-12  0:05   ` Ângelo Miguel Arrifano
@ 2007-11-12  0:02     ` Carlos Corbacho
  2007-11-23 15:24       ` Ângelo Miguel Arrifano
  0 siblings, 1 reply; 9+ messages in thread
From: Carlos Corbacho @ 2007-11-12  0:02 UTC (permalink / raw)
  To: Ângelo Miguel Arrifano; +Cc: linux-acpi

Angelo,

On Monday 12 November 2007 00:05:34 Ângelo Miguel Arrifano wrote:
> Thanks! The driver is now using sysfs.
> What should I do to submit the driver properly to upstream?

See http://www.lesswatts.org/projects/acpi/submitting-patches.php

and

http://www.kernel.org/pub/linux/kernel/people/lenb/acpi/patches/README.ACPI

-Carlos
-- 
E-Mail: carlos@strangeworlds.co.uk
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D
-
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: *NEW* ACPI driver to support App Hot Startup AKA PNP0C32
  2007-11-10  3:21 ` Carlos Corbacho
@ 2007-11-12  0:05   ` Ângelo Miguel Arrifano
  2007-11-12  0:02     ` Carlos Corbacho
  0 siblings, 1 reply; 9+ messages in thread
From: Ângelo Miguel Arrifano @ 2007-11-12  0:05 UTC (permalink / raw)
  To: Carlos Corbacho; +Cc: linux-acpi

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

On Sat, 10 Nov 2007 03:21:21 +0000
Carlos Corbacho <carlos@strangeworlds.co.uk> wrote:

> Angelo,
> 
> On Saturday 10 November 2007 01:44:48 Angelo Miguel Arrifano wrote:
> > If the laptop is turned off and a hot button is pressed, the
> > computer turns on and boots. This module gets a notification from
> > ACPI which button was pressed. Then the driver writes to the proc
> > fs which button was pressed allowing userspace apps to read that
> > files and behave accordingly. Proc files are also writable.
> 
> Please use sysfs, not proc (even if you aren't considering submitting this 
> upstream) - /proc/acpi is deprecated and going away (slowly but surely).
> 
> -Carlos
> -- 
> E-Mail: carlos@strangeworlds.co.uk
> Web: strangeworlds.co.uk
> GPG Key ID: 0x23EE722D

Thanks! The driver is now using sysfs.
What should I do to submit the driver properly to upstream?

Best regards,
- -- 
Angelo Arrifano AKA MiKNiX
CSE Student at UBI, Portugal
Gentoo Linux AMD64 Arch Tester
miknix@gmail.com
http://miknix.homelinux.com
PGP Pubkey online

- - -
Boys, you have ALL been selected to LEAVE th' PLANET in 15 minutes!!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFHN5jONahyoD2SuwsRAnz4AKDlpmU8geaaR27s/gXX1KaE3/CFMACg4i9B
842nLwYkmvcH9FlmydSngjU=
=UtSO
-----END PGP SIGNATURE-----

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

* Re: *NEW* ACPI driver to support App Hot Startup AKA PNP0C32
  2007-11-12  0:02     ` Carlos Corbacho
@ 2007-11-23 15:24       ` Ângelo Miguel Arrifano
  2008-01-19 15:19         ` *NEW* ACPI driver to support App Hot Startup AKA PNP0C32 - please apply Ângelo Miguel Arrifano
  0 siblings, 1 reply; 9+ messages in thread
From: Ângelo Miguel Arrifano @ 2007-11-23 15:24 UTC (permalink / raw)
  To: linux-acpi

Hello all,

I opened a SF.net project to support devices found under PNP0C32.
These devices are known as Direct App Launch Buttons and are used on Vista Hotstart(TM) technology.
I believe most of Vista "ready" laptops have this.

The project aims to provide similar functionality to Vista Hotstart(TM) in linux.
You can read more at http://quickstart.sourceforge.net/

Greetings,
-- 
Angelo Arrifano AKA MiKNiX
CSE Student at UBI, Portugal
Gentoo Linux AMD64 Arch Tester
miknix@gmail.com
http://miknix.homelinux.com
PGP Pubkey online

- -

Q: How many Chuck Norris' does it take to change a light bulb?
A: None, Chuck Norris prefers to kill in the dark. 

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

* Re: *NEW* ACPI driver to support App Hot Startup AKA PNP0C32 - please apply
  2007-11-23 15:24       ` Ângelo Miguel Arrifano
@ 2008-01-19 15:19         ` Ângelo Miguel Arrifano
  2008-03-07  6:27           ` Zhang, Rui
  0 siblings, 1 reply; 9+ messages in thread
From: Ângelo Miguel Arrifano @ 2008-01-19 15:19 UTC (permalink / raw)
  To: lenb; +Cc: linux-acpi

[-- Attachment #1: Type: text/plain, Size: 1353 bytes --]

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

On Fri, 23 Nov 2007 15:24:46 +0000
Ângelo Miguel Arrifano <miknix@gmail.com> wrote:

> Hello all,
> 
> I opened a SF.net project to support devices found under PNP0C32.
> These devices are known as Direct App Launch Buttons and are used on Vista Hotstart(TM) technology.
> I believe most of Vista "ready" laptops have this.
> 
> The project aims to provide similar functionality to Vista Hotstart(TM) in linux.
> You can read more at http://quickstart.sourceforge.net/
> 
> Greetings,
> -- 
> Angelo Arrifano AKA MiKNiX
> CSE Student at UBI, Portugal
> Gentoo Linux AMD64 Arch Tester
> miknix@gmail.com
> http://miknix.homelinux.com
> PGP Pubkey online
> 
> - -
> 
> Q: How many Chuck Norris' does it take to change a light bulb?
> A: None, Chuck Norris prefers to kill in the dark. 

The project is running for some time now. During this time there
were no reports of people getting it trouble with it.

Attached is the patch.

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

iD8DBQFHkhUBNahyoD2SuwsRAn8gAJ4yj/kQl3RyAbBw3s9/2R04rEjFbQCfc1fC
/HlHqqB8B9my/vP67QMWrBM=
=nVRr
-----END PGP SIGNATURE-----

[-- Attachment #2: quickstart-20080119.diff --]
[-- Type: text/x-patch, Size: 11748 bytes --]

diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 95588c2..4b80085 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -195,6 +195,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
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 456446f..719506a 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -61,3 +61,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
diff --git a/drivers/acpi/quickstart.c b/drivers/acpi/quickstart.c
new file mode 100644
index 0000000..2f4707b
--- /dev/null
+++ b/drivers/acpi/quickstart.c
@@ -0,0 +1,418 @@
+/*
+ *  quickstart.c - ACPI Direct App Launch driver
+ *
+ *
+ *  Copyright (C) 2007 Angelo Arrifano <miknix@gmail.com>
+ *
+ *  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	"0.04"
+
+#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 (hotkeys).\n");
+
+#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);
+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_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);
+			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_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);
+	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)
+{
+	struct quickstart_acpi *quickstart = data;
+
+	if (!quickstart)
+		return;
+
+	/* There will be two events:
+	 * 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){
+		quickstart_data.pressed = quickstart->btn;
+		printk("quickstart: Quickbutton %s pressed.\n",
+					acpi_device_bid(quickstart->device));
+	}
+
+	if(enable_runtime_btns && (event|0x08) == event){
+		printk("quickstart: Hotkey %s pressed.\n",
+					acpi_device_bid(quickstart->device));
+	}
+	
+	return;
+}
+
+static void quickstart_acpi_raise_notify(struct quickstart_acpi *quickstart)
+{
+	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);
+	if(ACPI_FAILURE(status))
+		printk("quickstart: Warning: GHID method failed, events of pressed buttons may have been lost.\n");
+
+	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("quickstart: Error installing notify handler\n");
+		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.
+	 * 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)
+{
+	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 (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("quickstart: ACPI Hotstart button %s\n", QUICKSTART_VERSION);
+	if(enable_runtime_btns)
+		printk("quickstart: Runtime button reporting is enabled.");
+	
+	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);

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

* RE: *NEW* ACPI driver to support App Hot Startup AKA PNP0C32 - please apply
  2008-01-19 15:19         ` *NEW* ACPI driver to support App Hot Startup AKA PNP0C32 - please apply Ângelo Miguel Arrifano
@ 2008-03-07  6:27           ` Zhang, Rui
       [not found]             ` <20080307112505.7281ef4b.miknix@gmail.com>
  0 siblings, 1 reply; 9+ messages in thread
From: Zhang, Rui @ 2008-03-07  6:27 UTC (permalink / raw)
  To: Ângelo Miguel Arrifano, lenb; +Cc: linux-acpi

Hi, Angelo,

For a typical ACPI device driver, it usually works like this:
1. Register the ACPI device driver is the module_init
2. Enable the device, create the sys I/F in the drivers .add method.
3. Remove the device I/F in .remove method.
4. unregister the ACPI device driver in module_exit.

With your patch applied, the sys I/F will be created even if no PNP0C32 device exists in the ACPI namespace. IMO, moving this piece of code to the .add method will be much better.

BTW: please don't send a patch as an attachment, it's difficult for review. :)

Thanks,
rui

>-----Original Message-----
>From: linux-acpi-owner@vger.kernel.org
>[mailto:linux-acpi-owner@vger.kernel.org] On Behalf Of ?ngelo Miguel Arrifano
>Sent: Saturday, January 19, 2008 11:19 PM
>To: lenb@kernel.org
>Cc: linux-acpi@vger.kernel.org
>Subject: Re: *NEW* ACPI driver to support App Hot Startup AKA PNP0C32 - please
>apply
>
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>On Fri, 23 Nov 2007 15:24:46 +0000
>Ângelo Miguel Arrifano <miknix@gmail.com> wrote:
>
>> Hello all,
>>
>> I opened a SF.net project to support devices found under PNP0C32.
>> These devices are known as Direct App Launch Buttons and are used on Vista
>Hotstart(TM) technology.
>> I believe most of Vista "ready" laptops have this.
>>
>> The project aims to provide similar functionality to Vista Hotstart(TM) in
>linux.
>> You can read more at http://quickstart.sourceforge.net/
>>
>> Greetings,
>> --
>> Angelo Arrifano AKA MiKNiX
>> CSE Student at UBI, Portugal
>> Gentoo Linux AMD64 Arch Tester
>> miknix@gmail.com
>> http://miknix.homelinux.com
>> PGP Pubkey online
>>
>> - -
>>
>> Q: How many Chuck Norris' does it take to change a light bulb?
>> A: None, Chuck Norris prefers to kill in the dark.
>
>The project is running for some time now. During this time there
>were no reports of people getting it trouble with it.
>
>Attached is the patch.
>
>Thanks,
>- --
>Angelo Arrifano AKA MiKNiX
>CSE Student at UBI, Portugal
>Gentoo Linux AMD64 Arch Tester
>Linwizard Developer
>miknix@gmail.com
>http://miknix.homelinux.com
>PGP Pubkey 0x3D92BB0B
>-----BEGIN PGP SIGNATURE-----
>Version: GnuPG v2.0.7 (GNU/Linux)
>
>iD8DBQFHkhUBNahyoD2SuwsRAn8gAJ4yj/kQl3RyAbBw3s9/2R04rEjFbQCfc1fC
>/HlHqqB8B9my/vP67QMWrBM=
>=nVRr
>-----END PGP SIGNATURE-----
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: *NEW* ACPI driver to support App Hot Startup AKA PNP0C32 - please apply
       [not found]             ` <20080307112505.7281ef4b.miknix@gmail.com>
@ 2008-03-10  3:23               ` Zhang, Rui
       [not found]                 ` <20080310123625.a3c96d0a.miknix@gmail.com>
  0 siblings, 1 reply; 9+ messages in thread
From: Zhang, Rui @ 2008-03-10  3:23 UTC (permalink / raw)
  To: Ângelo Miguel Arrifano; +Cc: linux-acpi

As there is nothing private, add linux-acpi in the discussion. :)

On Fri, 2008-03-07 at 19:25 +0800, Ângelo Miguel Arrifano wrote:
> On Fri, 7 Mar 2008 14:27:13 +0800
> "Zhang, Rui" <rui.zhang@intel.com> wrote:
> 
> > Hi, Angelo,
> >
> > For a typical ACPI device driver, it usually works like this:
> > 1. Register the ACPI device driver is the module_init
> > 2. Enable the device, create the sys I/F in the drivers .add method.
> > 3. Remove the device I/F in .remove method.
> > 4. unregister the ACPI device driver in module_exit.
> >
> > With your patch applied, the sys I/F will be created even if no
> PNP0C32 device exists in the ACPI namespace. IMO, moving this piece of
> code to the .add method will be much better.
> 
> That's right, but the sys I/F being created are not in a per-device
> basis. I mean:
> 
> Suppose PNP0C32 has three devices:
> ABTN
> BBTN
> CBTN
You mean three devces with _HID(PNP0C32), or three devices enumerated
under a PNP0C32 device? could you please attach the acpidump output?
> The sys files are created for PNP0C32 and not for every [ABC]BTN
> device.
>  So, moving the
> sys I/F code into .add, AFAIK, will get the sys files created several
> times which is not
> the purpose.
.add method is called for each PNP0C32 device,not for each button.
so in this case, I think it will only create two sys files...
> 
> The sys files created are "buttons" and "pressed_button".
> "buttons" displays all devices (buttons) under PNP0C32 for, IMHO,
> easier enumeration by
> userspace; instead of having a file for each device.
> "pressed_buttons" displays the button used to turn on/resume the
> computer.
> 
> But you are still right, the driver loads successfully (although
> displaying "none" on "buttons" sys file) when no PNP0C32 is present as
> we can see on this user post which doesn't have PNP0C32 at all:
> http://sourceforge.net/forum/forum.php?thread_id=1959640&forum_id=754264
> 
> On the code below, shouldn't (status < 0) be true when no PNP0C32 is
> present?
> 
>         /* ACPI driver register */
>         status = acpi_bus_register_driver(&quickstart_acpi_driver);
>         if (status < 0)
>                 return -ENODEV;
> 
> This was supposed to exit with -ENODEV before creating sys I/F.
No, acpi_bus_register_driver returns 0 if no matched device is found, in
order to support device hotplug.

thanks,
rui

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

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

* Re: *NEW* ACPI driver to support App Hot Startup AKA PNP0C32 - please apply
       [not found]                   ` <823A93EED437D048963A3697DB0E35DE012DE3C1@pdsmsx414.ccr.corp.intel.com>
@ 2009-06-22 17:03                     ` Angelo Arrifano
  0 siblings, 0 replies; 9+ messages in thread
From: Angelo Arrifano @ 2009-06-22 17:03 UTC (permalink / raw)
  To: Zhang, Rui; +Cc: linux-acpi

Zhang, Rui wrote:
> Hah, I nearly missed this email.
> 
> Angelo,
> Can you please re-send the refreshed patch so that I can add the comments in-line?
> Better kick off a new thread with the title like "[PATCH] ACPI: ..."
> 
> BTW: please don't send it as an attachment. :)
> 
> Thanks
> rui
> 
>> -----Original Message-----
>> From: Ângelo Miguel Arrifano [mailto:miknix@gmail.com]
>> Sent: Monday, March 10, 2008 8:36 PM
>> To: Zhang, Rui
>> Cc: linux-acpi
>> Subject: Re: *NEW* ACPI driver to support App Hot Startup AKA PNP0C32 - please
>> apply
>>
>> On Mon, 10 Mar 2008 11:23:36 +0800
>> "Zhang, Rui" <rui.zhang@intel.com> wrote:
>>
>>> As there is nothing private, add linux-acpi in the discussion. :)
>> Ah, sorry. I was distracted.
>>> On Fri, 2008-03-07 at 19:25 +0800, Ângelo Miguel Arrifano wrote:
>>>> On Fri, 7 Mar 2008 14:27:13 +0800
>>>> "Zhang, Rui" <rui.zhang@intel.com> wrote:
>>>>
>>>>> Hi, Angelo,
>>>>>
>>>>> For a typical ACPI device driver, it usually works like this:
>>>>> 1. Register the ACPI device driver is the module_init
>>>>> 2. Enable the device, create the sys I/F in the drivers .add method.
>>>>> 3. Remove the device I/F in .remove method.
>>>>> 4. unregister the ACPI device driver in module_exit.
>>>>>
>>>>> With your patch applied, the sys I/F will be created even if no
>>>> PNP0C32 device exists in the ACPI namespace. IMO, moving this piece of
>>>> code to the .add method will be much better.
>>>>
>>>> That's right, but the sys I/F being created are not in a per-device
>>>> basis. I mean:
>>>>
>>>> Suppose PNP0C32 has three devices:
>>>> ABTN
>>>> BBTN
>>>> CBTN
>>> You mean three devices with _HID(PNP0C32), or three devices enumerated
>>> under a PNP0C32 device? could you please attach the acpidump output?
>> (...)
>>
>> Device (QBTN)
>> {
>>    Name (_HID, EisaId ("PNP0C32"))
>>    Name (_UID, 0x01)
>>    Method (_STA, 0, NotSerialized)
>>    {
>> 	If (LEqual (OSYS, 0x07D6))
>> 	{
>> 	    Return (0x0F)
>> 	}
>> 	Else
>> 	{
>> 	    Return (0x00)
>> 	}
>>    }
>>
>>    Method (GHID, 0, NotSerialized)
>>    {
>> 	If (LEqual (HOTB, 0x04))
>> 	{
>> 	    Notify (QBTN, 0x02)
>> 	    Store (0x00, HOTB)
>> 	}
>>
>> 	Return (Buffer (0x01)
>> 	{
>> 	    /* 0000 */    0x01
>> 	})
>>    }
>> }
>>
>>
>>
>> Device (DBTN)
>> {
>>    Name (_HID, EisaId ("PNP0C32"))
>>    Name (_UID, 0x02)
>>    Method (_STA, 0, NotSerialized)
>>    {
>> 	If (LEqual (OSYS, 0x07D6))
>> 	{
>> 	    Return (0x0F)
>> 	}
>> 	Else
>> 	{
>> 	    Return (0x00)
>> 	}
>>    }
>>
>>    Method (GHID, 0, NotSerialized)
>>    {
>> 	If (LEqual (HOTB, 0x05))
>> 	{
>> 	    Notify (DBTN, 0x02)
>> 	    Store (0x00, HOTB)
>> 	}
>>
>> 	Return (Buffer (0x01)
>> 	{
>> 	    /* 0000 */    0x02
>> 	})
>>    }
>> }
>>
>> (...)
>>
>> So the devices above are those whose I was referring as buttons.
>> The first one is the QuickPlay button the second DVD Button, etc..
>>
>>>> The sys files are created for PNP0C32 and not for every [ABC]BTN
>>>> device.
>>>>  So, moving the
>>>> sys I/F code into .add, AFAIK, will get the sys files created several
>>>> times which is not
>>>> the purpose.
>>> .add method is called for each PNP0C32 device,not for each button.
>>> so in this case, I think it will only create two sys files...
>> Yeah, but PNP0C32 devices are the buttons.
>>
>>>> The sys files created are "buttons" and "pressed_button".
>>>> "buttons" displays all devices (buttons) under PNP0C32 for, IMHO,
>>>> easier enumeration by
>>>> userspace; instead of having a file for each device.
>>>> "pressed_buttons" displays the button used to turn on/resume the
>>>> computer.
>>>>
>>>> But you are still right, the driver loads successfully (although
>>>> displaying "none" on "buttons" sys file) when no PNP0C32 is present as
>>>> we can see on this user post which doesn't have PNP0C32 at all:
>>>> http://sourceforge.net/forum/forum.php?thread_id=1959640&forum_id=754264
>>>>
>>>> On the code below, shouldn't (status < 0) be true when no PNP0C32 is
>>>> present?
>>>>
>>>>         /* ACPI driver register */
>>>>         status = acpi_bus_register_driver(&quickstart_acpi_driver);
>>>>         if (status < 0)
>>>>                 return -ENODEV;
>>>>
>>>> This was supposed to exit with -ENODEV before creating sys I/F.
>>> No, acpi_bus_register_driver returns 0 if no matched device is found, in
>>> order to support device hotplug.
>> Hum.. Then this patch should prevent the module to load if no devices are present.
>>
>> --- quickstart/quickstart.c     2008-03-06 00:23:20.000000000 +0000
>> +++ quickstart-101/quickstart.c 2008-03-10 12:27:15.223132836 +0000
>> @@ -362,7 +362,7 @@ static int __init quickstart_init(void)
>>
>>        /* ACPI driver register */
>>        status = acpi_bus_register_driver(&quickstart_acpi_driver);
>> -       if (status < 0)
>> +       if (!quickstart_data.btn_lst || status < 0)
>>                return -ENODEV;
>>
>>        /* Platform driver register */
>>
>>> thanks,
>>> rui
>>>
>> Best regards,
>> --
>> Angelo Arrifano AKA MiKNiX
>> CSE Student at UBI, Portugal
>> Gentoo Linux AMD64 Arch Tester
>> Linwizard Developer
>> http://miknix.homelinux.com
>> PGP Pubkey 0x3D92BB0B

Hello all,

I've been maintaining this driver, the latest tested tag is 2.6.28.
However, I lost track of what is happening in the Linux ACPI tree. It
seems it is moving towards ACPICA?

Is there any interest on including this small piece of code in the tree?

Best regards,

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

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

end of thread, other threads:[~2009-06-22 17:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-10  1:44 *NEW* ACPI driver to support App Hot Startup AKA PNP0C32 Ângelo Miguel Arrifano
2007-11-10  3:21 ` Carlos Corbacho
2007-11-12  0:05   ` Ângelo Miguel Arrifano
2007-11-12  0:02     ` Carlos Corbacho
2007-11-23 15:24       ` Ângelo Miguel Arrifano
2008-01-19 15:19         ` *NEW* ACPI driver to support App Hot Startup AKA PNP0C32 - please apply Ângelo Miguel Arrifano
2008-03-07  6:27           ` Zhang, Rui
     [not found]             ` <20080307112505.7281ef4b.miknix@gmail.com>
2008-03-10  3:23               ` Zhang, Rui
     [not found]                 ` <20080310123625.a3c96d0a.miknix@gmail.com>
     [not found]                   ` <823A93EED437D048963A3697DB0E35DE012DE3C1@pdsmsx414.ccr.corp.intel.com>
2009-06-22 17:03                     ` Angelo Arrifano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.