linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/11] Fix sony_acpi_resume call
  2007-01-07 17:54   ` [PATCH 2/11] Avoid dimness on resume malattia
@ 2007-01-07 17:54     ` malattia
  0 siblings, 0 replies; 17+ messages in thread
From: malattia @ 2007-01-07 17:54 UTC (permalink / raw)
  To: lenb; +Cc: linux-acpi, Andrew Morton

From: Andrew Morton <akpm@osdl.org>

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Mattia Dongili <malattia@linux.it>
---
 drivers/acpi/sony_acpi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/acpi/sony_acpi.c b/drivers/acpi/sony_acpi.c
index beb56b9..f323c2c 100644
--- a/drivers/acpi/sony_acpi.c
+++ b/drivers/acpi/sony_acpi.c
@@ -233,7 +233,7 @@ static int sony_acpi_write(struct file *file, const char __user *buffer,
 	return count;
 }
 
-static int sony_acpi_resume(struct acpi_device *device, int state)
+static int sony_acpi_resume(struct acpi_device *device)
 {
 	struct sony_acpi_value *item;
 
-- 
1.4.4.2


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

* [PATCH 0/11] sony_acpi: prepare for prime time (resend)
@ 2007-01-13 22:04 malattia
  2007-01-13 22:04 ` [PATCH 1/11] SNC device support for Sony Vaios malattia
  2007-01-15  9:01 ` [PATCH 0/11] sony_acpi: prepare for prime time (resend) Luming Yu
  0 siblings, 2 replies; 17+ messages in thread
From: malattia @ 2007-01-13 22:04 UTC (permalink / raw)
  To: lenb; +Cc: linux-acpi

Hello again,

as said the following patchset starts to take care of sony_acpi:
1 to 7	are currently in -mm
8 to 10	are my local changes to make sony_acpi make some more interesting
	things on recent vaios
11	initializes the real brightness value in the backlight props (should
	this go in the backlight class itself?) and fixes the error exit path
	for the backlight_device registration

will follow shortly with a patch that makes sony_acpi a platform device driver.

-- 
mattia
:wq

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

* [PATCH 1/11] SNC device support for Sony Vaios
  2007-01-13 22:04 [PATCH 0/11] sony_acpi: prepare for prime time (resend) malattia
@ 2007-01-13 22:04 ` malattia
  2007-01-13 22:04   ` [PATCH 2/11] Avoid dimness on resume malattia
  2007-01-15  9:01 ` [PATCH 0/11] sony_acpi: prepare for prime time (resend) Luming Yu
  1 sibling, 1 reply; 17+ messages in thread
From: malattia @ 2007-01-13 22:04 UTC (permalink / raw)
  To: lenb; +Cc: linux-acpi, Stelian Pop

From: Stelian Pop <stelian@popies.net>

From: Bjorn Helgaas <bjorn.helgaas@hp.com>

  Even though the devices claimed by sony_acpi.c can not be hot-plugged, the
  driver registration infrastructure allows the .add() and .remove() methods
  to be called at any time while the driver is registered.  So remove __init
  and __exit from them.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
DESC
acpi/sony: Add FN hotkey support
EDESC
From: Matthew Garrett <mjg59@srcf.ucam.org>

in -mm only

[UBUNTU:acpi/sony] Add FN hotkey support
Source URL of Patch:
http://www.kernel.org/git/?p=linux/kernel/git/bcollins/ubuntu-dapper.git;a=commitdiff;h=7a9b49cba4919e8506604629db03add8e0b85767

Signed-off-by: Ben Collins <bcollins@ubuntu.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Mattia Dongili <malattia@linux.it>
---
 Documentation/acpi/sony_acpi.txt |   87 +++++++++
 drivers/acpi/Kconfig             |   14 ++
 drivers/acpi/Makefile            |    1 +
 drivers/acpi/sony_acpi.c         |  397 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 499 insertions(+), 0 deletions(-)

diff --git a/Documentation/acpi/sony_acpi.txt b/Documentation/acpi/sony_acpi.txt
new file mode 100644
index 0000000..35a04be
--- /dev/null
+++ b/Documentation/acpi/sony_acpi.txt
@@ -0,0 +1,87 @@
+ACPI Sony Notebook Control Driver (SNC) Readme
+----------------------------------------------
+	Copyright (C) 2004- 2005 Stelian Pop <stelian@popies.net>
+
+This mini-driver drives the ACPI SNC device present in the
+ACPI BIOS of the Sony Vaio laptops.
+
+It gives access to some extra laptop functionalities. In
+its current form, this driver is mainly useful for controlling the
+screen brightness, but it may do more in the future.
+
+You should probably start by trying the sonypi driver, and try
+sony_acpi only if sonypi doesn't work for you.
+
+Usage:
+------
+
+Loading the sony_acpi module will create a /proc/acpi/sony/
+directory populated with a couple of files.
+
+You then read/write integer values from/to those files by using
+standard UNIX tools.
+
+The files are:
+	brightness		current screen brightness
+	brightness_default	screen brightness which will be set
+				when the laptop will be rebooted
+	cdpower			power on/off the internal CD drive
+
+Note that some files may be missing if they are not supported
+by your particular laptop model.
+
+Example usage:
+	# echo "1" > /proc/acpi/sony/brightness
+sets the lowest screen brightness,
+	# echo "8" > /proc/acpi/sony/brightness
+sets the highest screen brightness,
+	# cat /proc/acpi/sony/brightness
+retrieves the current screen brightness.
+
+Development:
+------------
+
+If you want to help with the development of this driver (and
+you are not afraid of any side effects doing strange things with
+your ACPI BIOS could have on your laptop), load the driver and
+pass the option 'debug=1'.
+
+REPEAT: DON'T DO THIS IF YOU DON'T LIKE RISKY BUSINESS.
+
+In your kernel logs you will find the list of all ACPI methods
+the SNC device has on your laptop. You can see the GBRT/SBRT methods
+used to get/set the brightness, but there are others.
+
+I HAVE NO IDEA WHAT THOSE METHODS DO.
+
+The sony_acpi driver creates, for some of those methods (the most
+current ones found on several Vaio models), an entry under
+/proc/acpi/sony/, just like the 'brightness' one. You can create
+other entries corresponding to your own laptop methods by further
+editing the source (see the 'sony_acpi_values' table, and add a new
+structure to this table with your get/set method names).
+
+Your mission, should you accept it, is to try finding out what
+those entries are for, by reading/writing random values from/to those
+files and find out what is the impact on your laptop.
+
+Should you find anything interesting, please report it back to me,
+I will not disavow all knowledge of your actions :)
+
+Bugs/Limitations:
+-----------------
+
+* This driver is not based on official documentation from Sony
+  (because there is none), so there is no guarantee this driver
+  will work at all, or do the right thing. Although this hasn't
+  happened to me, this driver could do very bad things to your
+  laptop, including permanent damage.
+
+* The sony_acpi and sonypi drivers do not interact at all. In the
+  future, sonypi could use sony_acpi to do (part of) its business.
+
+* spicctrl, which is the userspace tool used to communicate with the
+  sonypi driver (through /dev/sonypi) does not try to use the
+  sony_acpi driver. In the future, spicctrl could try sonypi first,
+  and if it isn't present, try sony_acpi instead.
+
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index b4b725f..e064482 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -261,6 +261,20 @@ config ACPI_TOSHIBA
 	  If you have a legacy free Toshiba laptop (such as the Libretto L1
 	  series), say Y.
 
+config ACPI_SONY
+	tristate "Sony Laptop Extras"
+	depends on X86 && ACPI
+	default m
+	  ---help---
+	  This mini-driver drives the ACPI SNC device present in the
+	  ACPI BIOS of the Sony Vaio laptops.
+
+	  It gives access to some extra laptop functionalities. In
+	  its current form, the only thing this driver does is letting
+	  the user set or query the screen brightness.
+
+	  Read <file:Documentation/acpi/sony_acpi.txt> for more information.
+
 config ACPI_CUSTOM_DSDT
 	bool "Include Custom DSDT"
 	depends on !STANDALONE
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 25f91a4..db45518 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -54,6 +54,7 @@ obj-$(CONFIG_ACPI_THERMAL)	+= thermal.o
 obj-$(CONFIG_ACPI_SYSTEM)	+= system.o event.o
 obj-$(CONFIG_ACPI_DEBUG)	+= debug.o
 obj-$(CONFIG_ACPI_NUMA)		+= numa.o
+obj-$(CONFIG_ACPI_SONY)		+= sony_acpi.o
 obj-$(CONFIG_ACPI_ASUS)		+= asus_acpi.o
 obj-$(CONFIG_ACPI_IBM)		+= ibm_acpi.o
 obj-$(CONFIG_ACPI_TOSHIBA)	+= toshiba_acpi.o
diff --git a/drivers/acpi/sony_acpi.c b/drivers/acpi/sony_acpi.c
new file mode 100644
index 0000000..e23522a
--- /dev/null
+++ b/drivers/acpi/sony_acpi.c
@@ -0,0 +1,397 @@
+/*
+ * ACPI Sony Notebook Control Driver (SNC)
+ *
+ * Copyright (C) 2004-2005 Stelian Pop <stelian@popies.net>
+ *
+ * Parts of this driver inspired from asus_acpi.c and ibm_acpi.c
+ * which are copyrighted by their respective authors.
+ *
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <acpi/acpi_drivers.h>
+#include <acpi/acpi_bus.h>
+#include <asm/uaccess.h>
+
+#define ACPI_SNC_CLASS		"sony"
+#define ACPI_SNC_HID		"SNY5001"
+#define ACPI_SNC_DRIVER_NAME	"ACPI Sony Notebook Control Driver v0.2"
+
+#define LOG_PFX			KERN_WARNING "sony_acpi: "
+
+MODULE_AUTHOR("Stelian Pop");
+MODULE_DESCRIPTION(ACPI_SNC_DRIVER_NAME);
+MODULE_LICENSE("GPL");
+
+static int debug;
+module_param(debug, int, 0);
+MODULE_PARM_DESC(debug, "set this to 1 (and RTFM) if you want to help "
+			"the development of this driver");
+
+static int sony_acpi_add (struct acpi_device *device);
+static int sony_acpi_remove (struct acpi_device *device, int type);
+
+static struct acpi_driver sony_acpi_driver = {
+	.name	= ACPI_SNC_DRIVER_NAME,
+	.class	= ACPI_SNC_CLASS,
+	.ids	= ACPI_SNC_HID,
+	.ops	= {
+			.add	= sony_acpi_add,
+			.remove	= sony_acpi_remove,
+		  },
+};
+
+static acpi_handle sony_acpi_handle;
+static struct proc_dir_entry *sony_acpi_dir;
+
+static struct sony_acpi_value {
+	char			*name;	 /* name of the entry */
+	struct proc_dir_entry 	*proc;	 /* /proc entry */
+	char			*acpiget;/* name of the ACPI get function */
+	char			*acpiset;/* name of the ACPI get function */
+	int 			min;	 /* minimum allowed value or -1 */
+	int			max;	 /* maximum allowed value or -1 */
+	int			debug;	 /* active only in debug mode ? */
+} sony_acpi_values[] = {
+	{
+		.name		= "brightness",
+		.acpiget	= "GBRT",
+		.acpiset	= "SBRT",
+		.min		= 1,
+		.max		= 8,
+		.debug		= 0,
+	},
+	{
+		.name		= "brightness_default",
+		.acpiget	= "GPBR",
+		.acpiset	= "SPBR",
+		.min		= 1,
+		.max		= 8,
+		.debug		= 0,
+	},
+	{
+		.name           = "fnkey",
+		.acpiget        = "GHKE",
+		.debug          = 0,
+	},
+	{
+		.name		= "cdpower",
+		.acpiget	= "GCDP",
+		.acpiset	= "SCDP",
+		.min		= -1,
+		.max		= -1,
+		.debug		= 0,
+	},
+	{
+		.name		= "PID",
+		.acpiget	= "GPID",
+		.debug		= 1,
+	},
+	{
+		.name		= "CTR",
+		.acpiget	= "GCTR",
+		.acpiset	= "SCTR",
+		.min		= -1,
+		.max		= -1,
+		.debug		= 1,
+	},
+	{
+		.name		= "PCR",
+		.acpiget	= "GPCR",
+		.acpiset	= "SPCR",
+		.min		= -1,
+		.max		= -1,
+		.debug		= 1,
+	},
+	{
+		.name		= "CMI",
+		.acpiget	= "GCMI",
+		.acpiset	= "SCMI",
+		.min		= -1,
+		.max		= -1,
+		.debug		= 1,
+	},
+	{
+		.name		= NULL,
+	}
+};
+
+static int acpi_callgetfunc(acpi_handle handle, char *name, int *result)
+{
+	struct acpi_buffer output;
+	union acpi_object out_obj;
+	acpi_status status;
+
+	output.length = sizeof(out_obj);
+	output.pointer = &out_obj;
+
+	status = acpi_evaluate_object(handle, name, NULL, &output);
+	if ((status == AE_OK) && (out_obj.type == ACPI_TYPE_INTEGER)) {
+		*result = out_obj.integer.value;
+		return 0;
+	}
+
+	printk(LOG_PFX "acpi_callreadfunc failed\n");
+
+	return -1;
+}
+
+static int acpi_callsetfunc(acpi_handle handle, char *name, int value,
+			    int *result)
+{
+	struct acpi_object_list params;
+	union acpi_object in_obj;
+	struct acpi_buffer output;
+	union acpi_object out_obj;
+	acpi_status status;
+
+	params.count = 1;
+	params.pointer = &in_obj;
+	in_obj.type = ACPI_TYPE_INTEGER;
+	in_obj.integer.value = value;
+
+	output.length = sizeof(out_obj);
+	output.pointer = &out_obj;
+
+	status = acpi_evaluate_object(handle, name, &params, &output);
+	if (status == AE_OK) {
+		if (result != NULL) {
+			if (out_obj.type != ACPI_TYPE_INTEGER) {
+				printk(LOG_PFX "acpi_evaluate_object bad "
+				       "return type\n");
+				return -1;
+			}
+			*result = out_obj.integer.value;
+		}
+		return 0;
+	}
+
+	printk(LOG_PFX "acpi_evaluate_object failed\n");
+
+	return -1;
+}
+
+static int parse_buffer(const char __user *buffer, unsigned long count,
+			int *val) {
+	char s[32];
+	int ret;
+
+	if (count > 31)
+		return -EINVAL;
+	if (copy_from_user(s, buffer, count))
+		return -EFAULT;
+	s[count] = '\0';
+	ret = simple_strtoul(s, NULL, 10);
+	*val = ret;
+	return 0;
+}
+
+static int sony_acpi_read(char* page, char** start, off_t off, int count,
+			  int* eof, void *data)
+{
+	struct sony_acpi_value *item = data;
+	int value;
+
+	if (!item->acpiget)
+		return -EIO;
+
+	if (acpi_callgetfunc(sony_acpi_handle, item->acpiget, &value) < 0)
+		return -EIO;
+
+	return sprintf(page, "%d\n", value);
+}
+
+static int sony_acpi_write(struct file *file, const char __user *buffer,
+			   unsigned long count, void *data)
+{
+	struct sony_acpi_value *item = data;
+	int result;
+	int value;
+
+	if (!item->acpiset)
+		return -EIO;
+
+	if ((result = parse_buffer(buffer, count, &value)) < 0)
+		return result;
+
+	if (item->min != -1 && value < item->min)
+		return -EINVAL;
+	if (item->max != -1 && value > item->max)
+		return -EINVAL;
+
+	if (acpi_callsetfunc(sony_acpi_handle, item->acpiset, value, NULL) < 0)
+		return -EIO;
+
+	return count;
+}
+
+static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)
+{
+	printk(LOG_PFX "sony_acpi_notify\n");
+}
+
+static acpi_status sony_walk_callback(acpi_handle handle, u32 level,
+				      void *context, void **return_value)
+{
+	struct acpi_namespace_node *node;
+	union acpi_operand_object *operand;
+
+	node = (struct acpi_namespace_node *) handle;
+	operand = (union acpi_operand_object *) node->object;
+
+	printk(LOG_PFX "method: name: %4.4s, args %X\n", node->name.ascii,
+	       (u32) operand->method.param_count);
+
+	return AE_OK;
+}
+
+static int sony_acpi_add(struct acpi_device *device)
+{
+	acpi_status status;
+	int result;
+	struct sony_acpi_value *item;
+
+	sony_acpi_handle = device->handle;
+
+	acpi_driver_data(device) = NULL;
+	acpi_device_dir(device) = sony_acpi_dir;
+
+	if (debug) {
+		status = acpi_walk_namespace(ACPI_TYPE_METHOD, sony_acpi_handle,
+					     1, sony_walk_callback, NULL, NULL);
+		if (ACPI_FAILURE(status)) {
+			printk(LOG_PFX "unable to walk acpi resources\n");
+			result = -ENODEV;
+			goto outwalk;
+		}
+
+		status = acpi_install_notify_handler(sony_acpi_handle,
+						     ACPI_DEVICE_NOTIFY,
+						     sony_acpi_notify,
+						     NULL);
+		if (ACPI_FAILURE(status)) {
+			printk(LOG_PFX "unable to install notify handler\n");
+			result = -ENODEV;
+			goto outnotify;
+		}
+	}
+
+	for (item = sony_acpi_values; item->name; ++item) {
+		acpi_handle handle;
+
+		if (!debug && item->debug)
+			continue;
+
+		if (item->acpiget &&
+		    ACPI_FAILURE(acpi_get_handle(sony_acpi_handle,
+		    		 item->acpiget, &handle)))
+		    	continue;
+
+		if (item->acpiset &&
+		    ACPI_FAILURE(acpi_get_handle(sony_acpi_handle,
+		    		 item->acpiset, &handle)))
+		    	continue;
+
+		item->proc = create_proc_entry(item->name, 0600,
+					       acpi_device_dir(device));
+		if (!item->proc) {
+			printk(LOG_PFX "unable to create proc entry\n");
+			result = -EIO;
+			goto outproc;
+		}
+
+		item->proc->read_proc = sony_acpi_read;
+		item->proc->write_proc = sony_acpi_write;
+		item->proc->data = item;
+		item->proc->owner = THIS_MODULE;
+	}
+
+	printk(KERN_INFO ACPI_SNC_DRIVER_NAME " successfully installed\n");
+
+	return 0;
+
+outproc:
+	if (debug) {
+		status = acpi_remove_notify_handler(sony_acpi_handle,
+						    ACPI_DEVICE_NOTIFY,
+						    sony_acpi_notify);
+		if (ACPI_FAILURE(status))
+			printk(LOG_PFX "unable to remove notify handler\n");
+	}
+outnotify:
+	for (item = sony_acpi_values; item->name; ++item)
+		if (item->proc)
+			remove_proc_entry(item->name, acpi_device_dir(device));
+outwalk:
+	return result;
+}
+
+
+static int sony_acpi_remove(struct acpi_device *device, int type)
+{
+	acpi_status status;
+	struct sony_acpi_value *item;
+
+	if (debug) {
+		status = acpi_remove_notify_handler(sony_acpi_handle,
+						    ACPI_DEVICE_NOTIFY,
+						    sony_acpi_notify);
+		if (ACPI_FAILURE(status))
+			printk(LOG_PFX "unable to remove notify handler\n");
+	}
+
+	for (item = sony_acpi_values; item->name; ++item)
+		if (item->proc)
+			remove_proc_entry(item->name, acpi_device_dir(device));
+
+	printk(KERN_INFO ACPI_SNC_DRIVER_NAME " successfully removed\n");
+
+	return 0;
+}
+
+static int __init sony_acpi_init(void)
+{
+	int result;
+
+	sony_acpi_dir = proc_mkdir("sony", acpi_root_dir);
+	if (!sony_acpi_dir) {
+		printk(LOG_PFX "unable to create /proc entry\n");
+		return -ENODEV;
+	}
+	sony_acpi_dir->owner = THIS_MODULE;
+
+	result = acpi_bus_register_driver(&sony_acpi_driver);
+	if (result < 0) {
+		remove_proc_entry("sony", acpi_root_dir);
+		return -ENODEV;
+	}
+	return 0;
+}
+
+
+static void __exit sony_acpi_exit(void)
+{
+	acpi_bus_unregister_driver(&sony_acpi_driver);
+	remove_proc_entry("sony", acpi_root_dir);
+}
+
+module_init(sony_acpi_init);
+module_exit(sony_acpi_exit);
-- 
1.4.4.2


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

* [PATCH 2/11] Avoid dimness on resume.
  2007-01-13 22:04 ` [PATCH 1/11] SNC device support for Sony Vaios malattia
@ 2007-01-13 22:04   ` malattia
  2007-01-13 22:04     ` [PATCH 3/11] Fix sony_acpi_resume call malattia
  0 siblings, 1 reply; 17+ messages in thread
From: malattia @ 2007-01-13 22:04 UTC (permalink / raw)
  To: lenb; +Cc: linux-acpi, Andrew Morton

From: Andrew Morton <akpm@osdl.org>

Doesn't work.

Cc: Stelian Pop <stelian@popies.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Mattia Dongili <malattia@linux.it>
---
 drivers/acpi/sony_acpi.c |   49 +++++++++++++++++++++++++++++++--------------
 1 files changed, 34 insertions(+), 15 deletions(-)

diff --git a/drivers/acpi/sony_acpi.c b/drivers/acpi/sony_acpi.c
index e23522a..beb56b9 100644
--- a/drivers/acpi/sony_acpi.c
+++ b/drivers/acpi/sony_acpi.c
@@ -46,19 +46,6 @@ module_param(debug, int, 0);
 MODULE_PARM_DESC(debug, "set this to 1 (and RTFM) if you want to help "
 			"the development of this driver");
 
-static int sony_acpi_add (struct acpi_device *device);
-static int sony_acpi_remove (struct acpi_device *device, int type);
-
-static struct acpi_driver sony_acpi_driver = {
-	.name	= ACPI_SNC_DRIVER_NAME,
-	.class	= ACPI_SNC_CLASS,
-	.ids	= ACPI_SNC_HID,
-	.ops	= {
-			.add	= sony_acpi_add,
-			.remove	= sony_acpi_remove,
-		  },
-};
-
 static acpi_handle sony_acpi_handle;
 static struct proc_dir_entry *sony_acpi_dir;
 
@@ -69,6 +56,8 @@ static struct sony_acpi_value {
 	char			*acpiset;/* name of the ACPI get function */
 	int 			min;	 /* minimum allowed value or -1 */
 	int			max;	 /* maximum allowed value or -1 */
+	int			value;	 /* current setting */
+	int			valid;	 /* Has ever been set */
 	int			debug;	 /* active only in debug mode ? */
 } sony_acpi_values[] = {
 	{
@@ -239,10 +228,30 @@ static int sony_acpi_write(struct file *file, const char __user *buffer,
 
 	if (acpi_callsetfunc(sony_acpi_handle, item->acpiset, value, NULL) < 0)
 		return -EIO;
-
+	item->value = value;
+	item->valid = 1;
 	return count;
 }
 
+static int sony_acpi_resume(struct acpi_device *device, int state)
+{
+	struct sony_acpi_value *item;
+
+	for (item = sony_acpi_values; item->name; item++) {
+		int ret;
+
+		if (!item->valid)
+			continue;
+		ret = acpi_callsetfunc(sony_acpi_handle, item->acpiset,
+					item->value, NULL);
+		if (ret < 0) {
+			printk("%s: %d\n", __FUNCTION__, ret);
+			break;
+		}
+	}
+	return 0;
+}
+
 static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)
 {
 	printk(LOG_PFX "sony_acpi_notify\n");
@@ -344,7 +353,6 @@ outwalk:
 	return result;
 }
 
-
 static int sony_acpi_remove(struct acpi_device *device, int type)
 {
 	acpi_status status;
@@ -367,6 +375,17 @@ static int sony_acpi_remove(struct acpi_device *device, int type)
 	return 0;
 }
 
+static struct acpi_driver sony_acpi_driver = {
+	.name	= ACPI_SNC_DRIVER_NAME,
+	.class	= ACPI_SNC_CLASS,
+	.ids	= ACPI_SNC_HID,
+	.ops	= {
+			.add	= sony_acpi_add,
+			.remove	= sony_acpi_remove,
+			.resume = sony_acpi_resume,
+		  },
+};
+
 static int __init sony_acpi_init(void)
 {
 	int result;
-- 
1.4.4.2


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

* [PATCH 3/11] Fix sony_acpi_resume call
  2007-01-13 22:04   ` [PATCH 2/11] Avoid dimness on resume malattia
@ 2007-01-13 22:04     ` malattia
  2007-01-13 22:04       ` [PATCH 4/11] Add backlight support to the sony_acpi malattia
  0 siblings, 1 reply; 17+ messages in thread
From: malattia @ 2007-01-13 22:04 UTC (permalink / raw)
  To: lenb; +Cc: linux-acpi, Andrew Morton

From: Andrew Morton <akpm@osdl.org>

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Mattia Dongili <malattia@linux.it>
---
 drivers/acpi/sony_acpi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/acpi/sony_acpi.c b/drivers/acpi/sony_acpi.c
index beb56b9..f323c2c 100644
--- a/drivers/acpi/sony_acpi.c
+++ b/drivers/acpi/sony_acpi.c
@@ -233,7 +233,7 @@ static int sony_acpi_write(struct file *file, const char __user *buffer,
 	return count;
 }
 
-static int sony_acpi_resume(struct acpi_device *device, int state)
+static int sony_acpi_resume(struct acpi_device *device)
 {
 	struct sony_acpi_value *item;
 
-- 
1.4.4.2


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

* [PATCH 4/11] Add backlight support to the sony_acpi
  2007-01-13 22:04     ` [PATCH 3/11] Fix sony_acpi_resume call malattia
@ 2007-01-13 22:04       ` malattia
  2007-01-13 22:04         ` [PATCH 5/11] Add backlight support to the sony_acpi v2 malattia
  0 siblings, 1 reply; 17+ messages in thread
From: malattia @ 2007-01-13 22:04 UTC (permalink / raw)
  To: lenb; +Cc: linux-acpi, Alessandro Guido

From: Alessandro Guido <alessandro.guido@gmail.com>

Make the sony_acpi use the backlight subsystem to adjust brightness value
instead of using the /proc/sony/brightness file.  (Other settings will
still have a /proc/sony/...  entry)

Signed-off-by: Alessandro Guido <alessandro.guido@gmail.com>
Cc: Stelian Pop <stelian@popies.net>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Mattia Dongili <malattia@linux.it>
---
 drivers/acpi/Kconfig     |    1 +
 drivers/acpi/sony_acpi.c |   59 ++++++++++++++++++++++++++++++++++++---------
 2 files changed, 48 insertions(+), 12 deletions(-)

diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index e064482..cbd8727 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -264,6 +264,7 @@ config ACPI_TOSHIBA
 config ACPI_SONY
 	tristate "Sony Laptop Extras"
 	depends on X86 && ACPI
+	select BACKLIGHT_CLASS_DEVICE
 	default m
 	  ---help---
 	  This mini-driver drives the ACPI SNC device present in the
diff --git a/drivers/acpi/sony_acpi.c b/drivers/acpi/sony_acpi.c
index f323c2c..d509468 100644
--- a/drivers/acpi/sony_acpi.c
+++ b/drivers/acpi/sony_acpi.c
@@ -27,13 +27,19 @@
 #include <linux/moduleparam.h>
 #include <linux/init.h>
 #include <linux/types.h>
+#include <linux/backlight.h>
+#include <linux/err.h>
 #include <acpi/acpi_drivers.h>
 #include <acpi/acpi_bus.h>
 #include <asm/uaccess.h>
 
 #define ACPI_SNC_CLASS		"sony"
 #define ACPI_SNC_HID		"SNY5001"
-#define ACPI_SNC_DRIVER_NAME	"ACPI Sony Notebook Control Driver v0.2"
+#define ACPI_SNC_DRIVER_NAME	"ACPI Sony Notebook Control Driver v0.3"
+
+/* the device uses 1-based values, while the backlight subsystem uses
+   0-based values */
+#define SONY_MAX_BRIGHTNESS	8
 
 #define LOG_PFX			KERN_WARNING "sony_acpi: "
 
@@ -49,6 +55,16 @@ MODULE_PARM_DESC(debug, "set this to 1 (and RTFM) if you want to help "
 static acpi_handle sony_acpi_handle;
 static struct proc_dir_entry *sony_acpi_dir;
 
+static int sony_backlight_update_status(struct backlight_device *bd);
+static int sony_backlight_get_brightness(struct backlight_device *bd);
+static struct backlight_device *sony_backlight_device;
+static struct backlight_properties sony_backlight_properties = {
+	.owner		= THIS_MODULE,
+	.update_status	= sony_backlight_update_status,
+	.get_brightness	= sony_backlight_get_brightness,
+	.max_brightness	= SONY_MAX_BRIGHTNESS - 1,
+};
+
 static struct sony_acpi_value {
 	char			*name;	 /* name of the entry */
 	struct proc_dir_entry 	*proc;	 /* /proc entry */
@@ -61,19 +77,11 @@ static struct sony_acpi_value {
 	int			debug;	 /* active only in debug mode ? */
 } sony_acpi_values[] = {
 	{
-		.name		= "brightness",
-		.acpiget	= "GBRT",
-		.acpiset	= "SBRT",
-		.min		= 1,
-		.max		= 8,
-		.debug		= 0,
-	},
-	{
 		.name		= "brightness_default",
 		.acpiget	= "GPBR",
 		.acpiset	= "SPBR",
 		.min		= 1,
-		.max		= 8,
+		.max		= SONY_MAX_BRIGHTNESS,
 		.debug		= 0,
 	},
 	{
@@ -276,6 +284,7 @@ static int sony_acpi_add(struct acpi_device *device)
 {
 	acpi_status status;
 	int result;
+	acpi_handle handle;
 	struct sony_acpi_value *item;
 
 	sony_acpi_handle = device->handle;
@@ -303,9 +312,15 @@ static int sony_acpi_add(struct acpi_device *device)
 		}
 	}
 
-	for (item = sony_acpi_values; item->name; ++item) {
-		acpi_handle handle;
+	if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle, "GBRT", &handle))) {
+		sony_backlight_device = backlight_device_register("sony", NULL,
+					&sony_backlight_properties);
+	        if (IS_ERR(sony_backlight_device)) {
+        	        printk(LOG_PFX "unable to register backlight device\n");
+		}
+	}
 
+	for (item = sony_acpi_values; item->name; ++item) {
 		if (!debug && item->debug)
 			continue;
 
@@ -358,6 +373,9 @@ static int sony_acpi_remove(struct acpi_device *device, int type)
 	acpi_status status;
 	struct sony_acpi_value *item;
 
+	if (sony_backlight_device)
+		backlight_device_unregister(sony_backlight_device);
+
 	if (debug) {
 		status = acpi_remove_notify_handler(sony_acpi_handle,
 						    ACPI_DEVICE_NOTIFY,
@@ -375,6 +393,23 @@ static int sony_acpi_remove(struct acpi_device *device, int type)
 	return 0;
 }
 
+static int sony_backlight_update_status(struct backlight_device *bd)
+{
+	return acpi_callsetfunc(sony_acpi_handle, "SBRT",
+				bd->props->brightness + 1,
+				NULL);
+}
+
+static int sony_backlight_get_brightness(struct backlight_device *bd)
+{
+	int value;
+
+	if (acpi_callgetfunc(sony_acpi_handle, "GBRT", &value))
+		return 0;
+	/* brightness levels are 1-based, while backlight ones are 0-based */
+	return value - 1;
+}
+
 static struct acpi_driver sony_acpi_driver = {
 	.name	= ACPI_SNC_DRIVER_NAME,
 	.class	= ACPI_SNC_CLASS,
-- 
1.4.4.2


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

* [PATCH 5/11] Add backlight support to the sony_acpi v2
  2007-01-13 22:04       ` [PATCH 4/11] Add backlight support to the sony_acpi malattia
@ 2007-01-13 22:04         ` malattia
  2007-01-13 22:04           ` [PATCH 6/11] Video sysfs support take 2 malattia
  0 siblings, 1 reply; 17+ messages in thread
From: malattia @ 2007-01-13 22:04 UTC (permalink / raw)
  To: lenb; +Cc: linux-acpi, Alessandro Guido

From: Alessandro Guido <alessandro.guido@gmail.com>

Enable the sony_acpi driver to use the backlight subsysyem for adjusting
the monitor brightness.  Old way of changing the brightness will be still
available for compatibility with existing tools.

Signed-off-by: Alessandro Guido <alessandro.guido@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Mattia Dongili <malattia@linux.it>
---
 drivers/acpi/sony_acpi.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/acpi/sony_acpi.c b/drivers/acpi/sony_acpi.c
index d509468..fd7d55a 100644
--- a/drivers/acpi/sony_acpi.c
+++ b/drivers/acpi/sony_acpi.c
@@ -77,6 +77,14 @@ static struct sony_acpi_value {
 	int			debug;	 /* active only in debug mode ? */
 } sony_acpi_values[] = {
 	{
+		.name		= "brightness",
+		.acpiget	= "GBRT",
+		.acpiset	= "SBRT",
+		.min		= 1,
+		.max		= SONY_MAX_BRIGHTNESS,
+		.debug		= 0,
+	},
+	{
 		.name		= "brightness_default",
 		.acpiget	= "GPBR",
 		.acpiset	= "SPBR",
-- 
1.4.4.2


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

* [PATCH 6/11] Video sysfs support take 2
  2007-01-13 22:04         ` [PATCH 5/11] Add backlight support to the sony_acpi v2 malattia
@ 2007-01-13 22:04           ` malattia
  2007-01-13 22:04             ` [PATCH 7/11] Add acpi_bus_generate event malattia
  0 siblings, 1 reply; 17+ messages in thread
From: malattia @ 2007-01-13 22:04 UTC (permalink / raw)
  To: lenb; +Cc: linux-acpi, Andrew Morton

From: Andrew Morton <akpm@osdl.org>

add dev argument for backlight_device_register

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Mattia Dongili <malattia@linux.it>
---
 drivers/acpi/sony_acpi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/acpi/sony_acpi.c b/drivers/acpi/sony_acpi.c
index fd7d55a..195895c 100644
--- a/drivers/acpi/sony_acpi.c
+++ b/drivers/acpi/sony_acpi.c
@@ -322,7 +322,7 @@ static int sony_acpi_add(struct acpi_device *device)
 
 	if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle, "GBRT", &handle))) {
 		sony_backlight_device = backlight_device_register("sony", NULL,
-					&sony_backlight_properties);
+					NULL, &sony_backlight_properties);
 	        if (IS_ERR(sony_backlight_device)) {
         	        printk(LOG_PFX "unable to register backlight device\n");
 		}
-- 
1.4.4.2


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

* [PATCH 7/11] Add acpi_bus_generate event
  2007-01-13 22:04           ` [PATCH 6/11] Video sysfs support take 2 malattia
@ 2007-01-13 22:04             ` malattia
  2007-01-13 22:04               ` [PATCH 8/11] Allow easier debugging for the unknown SNC methods malattia
  0 siblings, 1 reply; 17+ messages in thread
From: malattia @ 2007-01-13 22:04 UTC (permalink / raw)
  To: lenb; +Cc: linux-acpi, Stelian Pop

From: Stelian Pop <stelian@popies.net>

Added acpi_bus_generate event for forwarding Fn-keys pressed to acpi subsystem,
and made correspondent necessary changes for this to work.

Signed-off-by: Nilton Volpato <nilton.volpato@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Mattia Dongili <malattia@linux.it>
---
 drivers/acpi/sony_acpi.c |   53 ++++++++++++++++++++++++---------------------
 1 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/drivers/acpi/sony_acpi.c b/drivers/acpi/sony_acpi.c
index 195895c..138f2b6 100644
--- a/drivers/acpi/sony_acpi.c
+++ b/drivers/acpi/sony_acpi.c
@@ -54,6 +54,7 @@ MODULE_PARM_DESC(debug, "set this to 1 (and RTFM) if you want to help "
 
 static acpi_handle sony_acpi_handle;
 static struct proc_dir_entry *sony_acpi_dir;
+static struct acpi_device *sony_acpi_acpi_device = NULL;
 
 static int sony_backlight_update_status(struct backlight_device *bd);
 static int sony_backlight_get_brightness(struct backlight_device *bd);
@@ -270,7 +271,9 @@ static int sony_acpi_resume(struct acpi_device *device)
 
 static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)
 {
-	printk(LOG_PFX "sony_acpi_notify\n");
+	if (debug)
+		printk(LOG_PFX "sony_acpi_notify, event: %d\n", event);
+	acpi_bus_generate_event(sony_acpi_acpi_device, 1, event);
 }
 
 static acpi_status sony_walk_callback(acpi_handle handle, u32 level,
@@ -295,6 +298,8 @@ static int sony_acpi_add(struct acpi_device *device)
 	acpi_handle handle;
 	struct sony_acpi_value *item;
 
+	sony_acpi_acpi_device = device;
+
 	sony_acpi_handle = device->handle;
 
 	acpi_driver_data(device) = NULL;
@@ -308,16 +313,16 @@ static int sony_acpi_add(struct acpi_device *device)
 			result = -ENODEV;
 			goto outwalk;
 		}
+	}
 
-		status = acpi_install_notify_handler(sony_acpi_handle,
-						     ACPI_DEVICE_NOTIFY,
-						     sony_acpi_notify,
-						     NULL);
-		if (ACPI_FAILURE(status)) {
-			printk(LOG_PFX "unable to install notify handler\n");
-			result = -ENODEV;
-			goto outnotify;
-		}
+	status = acpi_install_notify_handler(sony_acpi_handle,
+					     ACPI_DEVICE_NOTIFY,
+					     sony_acpi_notify,
+					     NULL);
+	if (ACPI_FAILURE(status)) {
+		printk(LOG_PFX "unable to install notify handler\n");
+		result = -ENODEV;
+		goto outnotify;
 	}
 
 	if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle, "GBRT", &handle))) {
@@ -342,7 +347,7 @@ static int sony_acpi_add(struct acpi_device *device)
 		    		 item->acpiset, &handle)))
 		    	continue;
 
-		item->proc = create_proc_entry(item->name, 0600,
+		item->proc = create_proc_entry(item->name, 0666,
 					       acpi_device_dir(device));
 		if (!item->proc) {
 			printk(LOG_PFX "unable to create proc entry\n");
@@ -361,13 +366,11 @@ static int sony_acpi_add(struct acpi_device *device)
 	return 0;
 
 outproc:
-	if (debug) {
-		status = acpi_remove_notify_handler(sony_acpi_handle,
-						    ACPI_DEVICE_NOTIFY,
-						    sony_acpi_notify);
-		if (ACPI_FAILURE(status))
-			printk(LOG_PFX "unable to remove notify handler\n");
-	}
+	status = acpi_remove_notify_handler(sony_acpi_handle,
+					    ACPI_DEVICE_NOTIFY,
+					    sony_acpi_notify);
+	if (ACPI_FAILURE(status))
+		printk(LOG_PFX "unable to remove notify handler\n");
 outnotify:
 	for (item = sony_acpi_values; item->name; ++item)
 		if (item->proc)
@@ -384,13 +387,13 @@ static int sony_acpi_remove(struct acpi_device *device, int type)
 	if (sony_backlight_device)
 		backlight_device_unregister(sony_backlight_device);
 
-	if (debug) {
-		status = acpi_remove_notify_handler(sony_acpi_handle,
-						    ACPI_DEVICE_NOTIFY,
-						    sony_acpi_notify);
-		if (ACPI_FAILURE(status))
-			printk(LOG_PFX "unable to remove notify handler\n");
-	}
+	sony_acpi_acpi_device = NULL;
+
+	status = acpi_remove_notify_handler(sony_acpi_handle,
+					    ACPI_DEVICE_NOTIFY,
+					    sony_acpi_notify);
+	if (ACPI_FAILURE(status))
+		printk(LOG_PFX "unable to remove notify handler\n");
 
 	for (item = sony_acpi_values; item->name; ++item)
 		if (item->proc)
-- 
1.4.4.2


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

* [PATCH 8/11] Allow easier debugging for the unknown SNC methods.
  2007-01-13 22:04             ` [PATCH 7/11] Add acpi_bus_generate event malattia
@ 2007-01-13 22:04               ` malattia
  2007-01-13 22:04                 ` [PATCH 9/11] Add lanpower and audiopower controls malattia
  0 siblings, 1 reply; 17+ messages in thread
From: malattia @ 2007-01-13 22:04 UTC (permalink / raw)
  To: lenb; +Cc: linux-acpi, Mattia Dongili

From: Mattia Dongili <malattia@linux.it>

Allow the existence of a setter method without a getter and viceversa,
additionaly set /proc file permissions reflecting it.
Fix also the error exit path.

Signed-off-by: Mattia Dongili <malattia@linux.it>
---
 drivers/acpi/sony_acpi.c |   30 +++++++++++++++++++++---------
 1 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/drivers/acpi/sony_acpi.c b/drivers/acpi/sony_acpi.c
index 138f2b6..69122ad 100644
--- a/drivers/acpi/sony_acpi.c
+++ b/drivers/acpi/sony_acpi.c
@@ -296,6 +296,7 @@ static int sony_acpi_add(struct acpi_device *device)
 	acpi_status status;
 	int result;
 	acpi_handle handle;
+	mode_t proc_file_mode;
 	struct sony_acpi_value *item;
 
 	sony_acpi_acpi_device = device;
@@ -334,20 +335,31 @@ static int sony_acpi_add(struct acpi_device *device)
 	}
 
 	for (item = sony_acpi_values; item->name; ++item) {
+		proc_file_mode = 0;
+
 		if (!debug && item->debug)
 			continue;
 
 		if (item->acpiget &&
-		    ACPI_FAILURE(acpi_get_handle(sony_acpi_handle,
+		    ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle,
 		    		 item->acpiget, &handle)))
-		    	continue;
+			proc_file_mode = S_IRUSR;
+		else
+			printk(LOG_PFX "unable to get ACPI handle for %s (get)\n",
+					item->name);
 
 		if (item->acpiset &&
-		    ACPI_FAILURE(acpi_get_handle(sony_acpi_handle,
+		    ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle,
 		    		 item->acpiset, &handle)))
-		    	continue;
+			proc_file_mode |= S_IWUSR;
+		else
+			printk(LOG_PFX "unable to get ACPI handle for %s (set)\n",
+					item->name);
+
+		if (proc_file_mode == 0)
+			continue;
 
-		item->proc = create_proc_entry(item->name, 0666,
+		item->proc = create_proc_entry(item->name, proc_file_mode,
 					       acpi_device_dir(device));
 		if (!item->proc) {
 			printk(LOG_PFX "unable to create proc entry\n");
@@ -366,15 +378,15 @@ static int sony_acpi_add(struct acpi_device *device)
 	return 0;
 
 outproc:
+	for (item = sony_acpi_values; item->name; ++item)
+		if (item->proc)
+			remove_proc_entry(item->name, acpi_device_dir(device));
+outnotify:
 	status = acpi_remove_notify_handler(sony_acpi_handle,
 					    ACPI_DEVICE_NOTIFY,
 					    sony_acpi_notify);
 	if (ACPI_FAILURE(status))
 		printk(LOG_PFX "unable to remove notify handler\n");
-outnotify:
-	for (item = sony_acpi_values; item->name; ++item)
-		if (item->proc)
-			remove_proc_entry(item->name, acpi_device_dir(device));
 outwalk:
 	return result;
 }
-- 
1.4.4.2


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

* [PATCH 9/11] Add lanpower and audiopower controls
  2007-01-13 22:04               ` [PATCH 8/11] Allow easier debugging for the unknown SNC methods malattia
@ 2007-01-13 22:04                 ` malattia
  2007-01-13 22:04                   ` [PATCH 10/11] Allow multiple sony_acpi_values for the same .name malattia
  0 siblings, 1 reply; 17+ messages in thread
From: malattia @ 2007-01-13 22:04 UTC (permalink / raw)
  To: lenb; +Cc: linux-acpi, Mattia Dongili

From: Mattia Dongili <malattia@linux.it>

audiopower works well on my SZ72B so it's not marked has "debug" while lanpower
has at least one report of not resuming power happily so morked as "debug"

Signed-off-by: Mattia Dongili <malattia@linux.it>
---
 drivers/acpi/sony_acpi.c |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/sony_acpi.c b/drivers/acpi/sony_acpi.c
index 69122ad..1f7dca3 100644
--- a/drivers/acpi/sony_acpi.c
+++ b/drivers/acpi/sony_acpi.c
@@ -102,11 +102,27 @@ static struct sony_acpi_value {
 		.name		= "cdpower",
 		.acpiget	= "GCDP",
 		.acpiset	= "SCDP",
-		.min		= -1,
-		.max		= -1,
+		.min		= 0,
+		.max		= 1,
 		.debug		= 0,
 	},
 	{
+		.name           = "audiopower",
+		.acpiget        = "GAZP",
+		.acpiset        = "AZPW",
+		.min            = 0,
+		.max            = 1,
+		.debug          = 0,
+	},
+	{
+		.name           = "lanpower",
+		.acpiget        = "GLNP",
+		.acpiset        = "LNPW",
+		.min            = 0,
+		.max            = 1,
+		.debug          = 1,
+	},
+	{
 		.name		= "PID",
 		.acpiget	= "GPID",
 		.debug		= 1,
-- 
1.4.4.2


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

* [PATCH 10/11] Allow multiple sony_acpi_values for the same .name
  2007-01-13 22:04                 ` [PATCH 9/11] Add lanpower and audiopower controls malattia
@ 2007-01-13 22:04                   ` malattia
  2007-01-13 22:04                     ` [PATCH 11/11] Fix sony_acpi backlight registration and unregistration malattia
  0 siblings, 1 reply; 17+ messages in thread
From: malattia @ 2007-01-13 22:04 UTC (permalink / raw)
  To: lenb; +Cc: linux-acpi, Mattia Dongili

From: Mattia Dongili <malattia@linux.it>

The acpi handles are kept _only_ if both the requested .acpiget and .acpiset
are available in the DSDT.
Currently only the SCDP/CDPW dualism is known.

Signed-off-by: Mattia Dongili <malattia@linux.it>
---
 drivers/acpi/sony_acpi.c |   44 +++++++++++++++++++++++++-------------------
 1 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/drivers/acpi/sony_acpi.c b/drivers/acpi/sony_acpi.c
index 1f7dca3..c65f589 100644
--- a/drivers/acpi/sony_acpi.c
+++ b/drivers/acpi/sony_acpi.c
@@ -68,7 +68,7 @@ static struct backlight_properties sony_backlight_properties = {
 
 static struct sony_acpi_value {
 	char			*name;	 /* name of the entry */
-	struct proc_dir_entry 	*proc;	 /* /proc entry */
+	struct proc_dir_entry	*proc;	 /* /proc entry */
 	char			*acpiget;/* name of the ACPI get function */
 	char			*acpiset;/* name of the ACPI get function */
 	int 			min;	 /* minimum allowed value or -1 */
@@ -78,6 +78,7 @@ static struct sony_acpi_value {
 	int			debug;	 /* active only in debug mode ? */
 } sony_acpi_values[] = {
 	{
+		/* for backward compatibility only */
 		.name		= "brightness",
 		.acpiget	= "GBRT",
 		.acpiset	= "SBRT",
@@ -107,6 +108,14 @@ static struct sony_acpi_value {
 		.debug		= 0,
 	},
 	{
+		.name		= "cdpower",
+		.acpiget	= "GCDP",
+		.acpiset	= "CDPW",
+		.min		= 0,
+		.max		= 1,
+		.debug		= 0,
+	},
+	{
 		.name           = "audiopower",
 		.acpiget        = "GAZP",
 		.acpiset        = "AZPW",
@@ -356,27 +365,24 @@ static int sony_acpi_add(struct acpi_device *device)
 		if (!debug && item->debug)
 			continue;
 
-		if (item->acpiget &&
-		    ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle,
-		    		 item->acpiget, &handle)))
-			proc_file_mode = S_IRUSR;
-		else
-			printk(LOG_PFX "unable to get ACPI handle for %s (get)\n",
-					item->name);
-
-		if (item->acpiset &&
-		    ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle,
-		    		 item->acpiset, &handle)))
-			proc_file_mode |= S_IWUSR;
-		else
-			printk(LOG_PFX "unable to get ACPI handle for %s (set)\n",
-					item->name);
+		if (item->acpiget) {
+			if (ACPI_FAILURE(acpi_get_handle(sony_acpi_handle,
+							item->acpiget, &handle)))
+				continue;
 
-		if (proc_file_mode == 0)
-			continue;
+			proc_file_mode |= S_IRUSR;
+		}
+
+		if (item->acpiset) {
+			if (ACPI_FAILURE(acpi_get_handle(sony_acpi_handle,
+							item->acpiset, &handle)))
+				continue;
+
+			proc_file_mode |= S_IWUSR;
+		}
 
 		item->proc = create_proc_entry(item->name, proc_file_mode,
-					       acpi_device_dir(device));
+				acpi_device_dir(device));
 		if (!item->proc) {
 			printk(LOG_PFX "unable to create proc entry\n");
 			result = -EIO;
-- 
1.4.4.2


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

* [PATCH 11/11] Fix sony_acpi backlight registration and unregistration
  2007-01-13 22:04                   ` [PATCH 10/11] Allow multiple sony_acpi_values for the same .name malattia
@ 2007-01-13 22:04                     ` malattia
  0 siblings, 0 replies; 17+ messages in thread
From: malattia @ 2007-01-13 22:04 UTC (permalink / raw)
  To: lenb; +Cc: linux-acpi, Mattia Dongili

From: Mattia Dongili <malattia@linux.it>

Initialize the current brightness if the driver registration
was successful and unregister the driver in the error exit path.

Signed-off-by: Mattia Dongili <malattia@linux.it>
---
 drivers/acpi/sony_acpi.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/acpi/sony_acpi.c b/drivers/acpi/sony_acpi.c
index c65f589..c01d98d 100644
--- a/drivers/acpi/sony_acpi.c
+++ b/drivers/acpi/sony_acpi.c
@@ -354,9 +354,14 @@ static int sony_acpi_add(struct acpi_device *device)
 	if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle, "GBRT", &handle))) {
 		sony_backlight_device = backlight_device_register("sony", NULL,
 					NULL, &sony_backlight_properties);
+
 	        if (IS_ERR(sony_backlight_device)) {
         	        printk(LOG_PFX "unable to register backlight device\n");
+			sony_backlight_device = NULL;
 		}
+		else
+			sony_backlight_properties.brightness =
+				sony_backlight_get_brightness(sony_backlight_device);
 	}
 
 	for (item = sony_acpi_values; item->name; ++item) {
@@ -400,6 +405,9 @@ static int sony_acpi_add(struct acpi_device *device)
 	return 0;
 
 outproc:
+	if (sony_backlight_device)
+		backlight_device_unregister(sony_backlight_device);
+
 	for (item = sony_acpi_values; item->name; ++item)
 		if (item->proc)
 			remove_proc_entry(item->name, acpi_device_dir(device));
-- 
1.4.4.2


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

* Re: [PATCH 0/11] sony_acpi: prepare for prime time (resend)
  2007-01-13 22:04 [PATCH 0/11] sony_acpi: prepare for prime time (resend) malattia
  2007-01-13 22:04 ` [PATCH 1/11] SNC device support for Sony Vaios malattia
@ 2007-01-15  9:01 ` Luming Yu
  2007-01-15 19:12   ` Mattia Dongili
  1 sibling, 1 reply; 17+ messages in thread
From: Luming Yu @ 2007-01-15  9:01 UTC (permalink / raw)
  To: malattia@linux.it; +Cc: lenb, linux-acpi

Patch series is not clean against 2.6.20-rc5.

patch -p1 < ../malattia_sony/1_snc_device_support_for_sony_va
io.patch
patching file Documentation/acpi/sony_acpi.txt
patching file drivers/acpi/Kconfig
Hunk #1 succeeded at 252 with fuzz 2 (offset -9 lines).
patching file drivers/acpi/Makefile
Hunk #1 FAILED at 54.
1 out of 1 hunk FAILED -- saving rejects to file drivers/acpi/Makefile.rej
patching file drivers/acpi/sony_acpi.c


patch -p1 < ../malattia_sony/2_avoid_dimness_on_resume.patch
patching file drivers/acpi/sony_acpi.c
Hunk #1 succeeded at 46 with fuzz 2.
Hunk #2 FAILED at 56.
Hunk #3 FAILED at 228.
Hunk #4 succeeded at 353 with fuzz 1.
Hunk #5 succeeded at 375 with fuzz 1.
2 out of 5 hunks FAILED -- saving rejects to file drivers/acpi/sony_acpi.c.rej

patch -p1 < ../malattia_sony/3_fix_sony_acpi_resume_call.patc
h
patching file drivers/acpi/sony_acpi.c
Hunk #1 FAILED at 233.
1 out of 1 hunk FAILED -- saving rejects to file drivers/acpi/sony_acpi.c.rej

patch -p1 < ../malattia_sony/4_add_backlight_support_to_the_s
ony_acpi.patch
patching file drivers/acpi/Kconfig
Hunk #1 FAILED at 264.
1 out of 1 hunk FAILED -- saving rejects to file drivers/acpi/Kconfig.rej
patching file drivers/acpi/sony_acpi.c
Hunk #2 succeeded at 55 with fuzz 2.
Hunk #3 FAILED at 77.
Hunk #4 FAILED at 284.
Hunk #5 FAILED at 312.
Hunk #6 FAILED at 373.
Hunk #7 succeeded at 371 with fuzz 2 (offset -22 lines).
4 out of 7 hunks FAILED -- saving rejects to file drivers/acpi/sony_acpi.c.re




On 1/13/07, malattia@linux.it <malattia@linux.it> wrote:
> Hello again,
>
> as said the following patchset starts to take care of sony_acpi:
> 1 to 7  are currently in -mm
> 8 to 10 are my local changes to make sony_acpi make some more interesting
>         things on recent vaios
> 11      initializes the real brightness value in the backlight props (should
>         this go in the backlight class itself?) and fixes the error exit path
>         for the backlight_device registration
>
> will follow shortly with a patch that makes sony_acpi a platform device driver.
>
> --
> mattia
> :wq
> -
> 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] 17+ messages in thread

* Re: [PATCH 0/11] sony_acpi: prepare for prime time (resend)
  2007-01-15  9:01 ` [PATCH 0/11] sony_acpi: prepare for prime time (resend) Luming Yu
@ 2007-01-15 19:12   ` Mattia Dongili
  2007-01-17  5:50     ` Luming Yu
  0 siblings, 1 reply; 17+ messages in thread
From: Mattia Dongili @ 2007-01-15 19:12 UTC (permalink / raw)
  To: Luming Yu; +Cc: lenb, linux-acpi

Hello and sorry for the delay

On Mon, Jan 15, 2007 at 04:01:14AM -0500, Luming Yu wrote:
> Patch series is not clean against 2.6.20-rc5.
> 
> patch -p1 < ../malattia_sony/1_snc_device_support_for_sony_va
> io.patch
> patching file Documentation/acpi/sony_acpi.txt
> patching file drivers/acpi/Kconfig
> Hunk #1 succeeded at 252 with fuzz 2 (offset -9 lines).
> patching file drivers/acpi/Makefile
> Hunk #1 FAILED at 54.
> 1 out of 1 hunk FAILED -- saving rejects to file drivers/acpi/Makefile.rej
> patching file drivers/acpi/sony_acpi.c
...

uh. I'm developing on the acpi tree test branch, however I just tried
the patches on a freshly unpacked/patched .20-rc5 and the patches apply
without any reject.

# for i in ../*.patch ; do patch -p1 < $i ; done
patching file Documentation/acpi/sony_acpi.txt
patching file drivers/acpi/Kconfig
Hunk #1 succeeded at 252 (offset -9 lines).
patching file drivers/acpi/Makefile
Hunk #1 succeeded at 53 (offset -1 lines).
patching file drivers/acpi/sony_acpi.c
patching file drivers/acpi/sony_acpi.c
patching file drivers/acpi/sony_acpi.c
patching file drivers/acpi/Kconfig
Hunk #1 succeeded at 255 (offset -9 lines).
patching file drivers/acpi/sony_acpi.c
patching file drivers/acpi/sony_acpi.c
patching file drivers/acpi/sony_acpi.c
patching file drivers/acpi/sony_acpi.c
patching file drivers/acpi/sony_acpi.c
patching file drivers/acpi/sony_acpi.c
patching file drivers/acpi/sony_acpi.c
patching file drivers/acpi/sony_acpi.c

> patch -p1 < ../malattia_sony/2_avoid_dimness_on_resume.patch
> patching file drivers/acpi/sony_acpi.c
> Hunk #1 succeeded at 46 with fuzz 2.
> Hunk #2 FAILED at 56.
> Hunk #3 FAILED at 228.
> Hunk #4 succeeded at 353 with fuzz 1.
> Hunk #5 succeeded at 375 with fuzz 1.
> 2 out of 5 hunks FAILED -- saving rejects to file 
> drivers/acpi/sony_acpi.c.rej

The really strange thing is that since the sony_acpi.c file doesn't
exist in mainline and is created in the first patch, at least the
patches on it shouldn't fail... :)

hummm... could you retry with a fresh tree?
-- 
mattia
:wq!

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

* Re: [PATCH 0/11] sony_acpi: prepare for prime time (resend)
  2007-01-15 19:12   ` Mattia Dongili
@ 2007-01-17  5:50     ` Luming Yu
  2007-01-17  9:34       ` Mattia Dongili
  0 siblings, 1 reply; 17+ messages in thread
From: Luming Yu @ 2007-01-17  5:50 UTC (permalink / raw)
  To: Mattia Dongili; +Cc: lenb, linux-acpi

On 1/15/07, Mattia Dongili <malattia@linux.it> wrote:
> Hello and sorry for the delay
>
> On Mon, Jan 15, 2007 at 04:01:14AM -0500, Luming Yu wrote:
> > Patch series is not clean against 2.6.20-rc5.
> >
> > patch -p1 < ../malattia_sony/1_snc_device_support_for_sony_va
> > io.patch
> > patching file Documentation/acpi/sony_acpi.txt
> > patching file drivers/acpi/Kconfig
> > Hunk #1 succeeded at 252 with fuzz 2 (offset -9 lines).
> > patching file drivers/acpi/Makefile
> > Hunk #1 FAILED at 54.
> > 1 out of 1 hunk FAILED -- saving rejects to file drivers/acpi/Makefile.rej
> > patching file drivers/acpi/sony_acpi.c
> ...
>
> uh. I'm developing on the acpi tree test branch, however I just tried
> the patches on a freshly unpacked/patched .20-rc5 and the patches apply
> without any reject.

I was using linus's linux-2.6 git tree.
Then, I tried the patch series on a fresh unpacked 2.6.20-rc5.
I still got :

#  patch -p1 < ../malattia_sony/1_snc_device_support_for_sony_vaio.patch
patching file Documentation/acpi/sony_acpi.txt
patching file drivers/acpi/Kconfig
Hunk #1 succeeded at 252 with fuzz 2 (offset -9 lines).
patching file drivers/acpi/Makefile
Hunk #1 FAILED at 54.
1 out of 1 hunk FAILED -- saving rejects to file drivers/acpi/Makefile.rej
patching file drivers/acpi/sony_acpi.c

patch -p1 < ../malattia_sony/2_avoid_dimness_on_resume.patch
patching file drivers/acpi/sony_acpi.c
Hunk #1 succeeded at 46 with fuzz 2.
Hunk #2 FAILED at 56.
Hunk #3 FAILED at 228.
Hunk #4 succeeded at 353 with fuzz 1.
Hunk #5 succeeded at 375 with fuzz 1.
2 out of 5 hunks FAILED -- saving rejects to file drivers/acpi/sony_acpi.c.rej

Is 2_avoid_dimness_on_resume.patch a right patch, or in right order?

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

* Re: [PATCH 0/11] sony_acpi: prepare for prime time (resend)
  2007-01-17  5:50     ` Luming Yu
@ 2007-01-17  9:34       ` Mattia Dongili
  0 siblings, 0 replies; 17+ messages in thread
From: Mattia Dongili @ 2007-01-17  9:34 UTC (permalink / raw)
  To: Luming Yu; +Cc: lenb, linux-acpi

On Wed, January 17, 2007 6:50 am, Luming Yu said:
> On 1/15/07, Mattia Dongili <malattia@linux.it> wrote:
>> Hello and sorry for the delay
>>
>> On Mon, Jan 15, 2007 at 04:01:14AM -0500, Luming Yu wrote:
>> > Patch series is not clean against 2.6.20-rc5.
>> >
>> > patch -p1 < ../malattia_sony/1_snc_device_support_for_sony_va
>> > io.patch
>> > patching file Documentation/acpi/sony_acpi.txt
>> > patching file drivers/acpi/Kconfig
>> > Hunk #1 succeeded at 252 with fuzz 2 (offset -9 lines).
>> > patching file drivers/acpi/Makefile
>> > Hunk #1 FAILED at 54.
>> > 1 out of 1 hunk FAILED -- saving rejects to file
>> drivers/acpi/Makefile.rej
>> > patching file drivers/acpi/sony_acpi.c
>> ...
>>
>> uh. I'm developing on the acpi tree test branch, however I just tried
>> the patches on a freshly unpacked/patched .20-rc5 and the patches apply
>> without any reject.
>
> I was using linus's linux-2.6 git tree.
> Then, I tried the patch series on a fresh unpacked 2.6.20-rc5.
> I still got :
>
> #  patch -p1 < ../malattia_sony/1_snc_device_support_for_sony_vaio.patch
> patching file Documentation/acpi/sony_acpi.txt
> patching file drivers/acpi/Kconfig
> Hunk #1 succeeded at 252 with fuzz 2 (offset -9 lines).
> patching file drivers/acpi/Makefile
> Hunk #1 FAILED at 54.
> 1 out of 1 hunk FAILED -- saving rejects to file drivers/acpi/Makefile.rej
> patching file drivers/acpi/sony_acpi.c

can you show the contents of the rejects on Makefile? and also the next
one with the second patch on sony_acpi.c?

> patch -p1 < ../malattia_sony/2_avoid_dimness_on_resume.patch
> patching file drivers/acpi/sony_acpi.c
> Hunk #1 succeeded at 46 with fuzz 2.
> Hunk #2 FAILED at 56.
> Hunk #3 FAILED at 228.
> Hunk #4 succeeded at 353 with fuzz 1.
> Hunk #5 succeeded at 375 with fuzz 1.
> 2 out of 5 hunks FAILED -- saving rejects to file
> drivers/acpi/sony_acpi.c.rej
>
> Is 2_avoid_dimness_on_resume.patch a right patch, or in right order?

yes, this is how I have the patches as created by git-format-patch:

0001-SNC-device-support-for-Sony-Vaios.txt
0002-Avoid-dimness-on-resume.txt
0003-Fix-sony_acpi_resume-call.txt
0004-Add-backlight-support-to-the-sony_acpi.txt
0005-Add-backlight-support-to-the-sony_acpi-v2.txt
0006-Video-sysfs-support-take-2.txt
0007-Add-acpi_bus_generate-event.txt
0008-Allow-easier-debugging-for-the-unknown-SNC-methods.txt
0009-Add-lanpower-and-audiopower-controls.txt
0010-Allow-multiple-sony_acpi_values-for-the-same-.name.txt
0011-Fix-sony_acpi-backlight-registration-and-unregistration.txt

don't know, I put them all here, if useful:
http://oioio.altervista.org/linux/to_len.tar.gz

-- 
mattia
:wq!



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

end of thread, other threads:[~2007-01-17  9:58 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-13 22:04 [PATCH 0/11] sony_acpi: prepare for prime time (resend) malattia
2007-01-13 22:04 ` [PATCH 1/11] SNC device support for Sony Vaios malattia
2007-01-13 22:04   ` [PATCH 2/11] Avoid dimness on resume malattia
2007-01-13 22:04     ` [PATCH 3/11] Fix sony_acpi_resume call malattia
2007-01-13 22:04       ` [PATCH 4/11] Add backlight support to the sony_acpi malattia
2007-01-13 22:04         ` [PATCH 5/11] Add backlight support to the sony_acpi v2 malattia
2007-01-13 22:04           ` [PATCH 6/11] Video sysfs support take 2 malattia
2007-01-13 22:04             ` [PATCH 7/11] Add acpi_bus_generate event malattia
2007-01-13 22:04               ` [PATCH 8/11] Allow easier debugging for the unknown SNC methods malattia
2007-01-13 22:04                 ` [PATCH 9/11] Add lanpower and audiopower controls malattia
2007-01-13 22:04                   ` [PATCH 10/11] Allow multiple sony_acpi_values for the same .name malattia
2007-01-13 22:04                     ` [PATCH 11/11] Fix sony_acpi backlight registration and unregistration malattia
2007-01-15  9:01 ` [PATCH 0/11] sony_acpi: prepare for prime time (resend) Luming Yu
2007-01-15 19:12   ` Mattia Dongili
2007-01-17  5:50     ` Luming Yu
2007-01-17  9:34       ` Mattia Dongili
  -- strict thread matches above, loose matches on Subject: below --
2007-01-07 17:54 [PATCH 0/11] sony_acpi: getting in shape for prime time malattia
2007-01-07 17:54 ` [PATCH 1/11] SNC device support for Sony Vaios malattia
2007-01-07 17:54   ` [PATCH 2/11] Avoid dimness on resume malattia
2007-01-07 17:54     ` [PATCH 3/11] Fix sony_acpi_resume call malattia

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).