linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2.6.15.3 1/1] ACPI: Atlas ACPI driver
@ 2006-02-20  2:13 jayakumar.acpi
  2006-02-20 10:26 ` Matthew Garrett
  0 siblings, 1 reply; 22+ messages in thread
From: jayakumar.acpi @ 2006-02-20  2:13 UTC (permalink / raw)
  To: linux-acpi, linux-kernel

Hi Len, ACPI, and kernel folk,

Appended is my patch adding an ACPI driver for Atlas boards. I've
done this patch against 2.6.15.3. 

Please let me know if it looks okay so far and if you have any feedback 
or suggestions.

Thanks,
Jaya Kumar

Signed-off-by: Jaya Kumar <jayakumar.acpi@gmail.com>

---

 MAINTAINERS               |    5 
 drivers/acpi/Kconfig      |   11 +
 drivers/acpi/Makefile     |    1 
 drivers/acpi/atlas_acpi.c |  279 ++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 296 insertions(+)

---

diff -X linux-2.6.15.3/Documentation/dontdiff -uprN linux-2.6.15.3-vanilla/drivers/acpi/atlas_acpi.c linux-2.6.15.3/drivers/acpi/atlas_acpi.c
--- linux-2.6.15.3-vanilla/drivers/acpi/atlas_acpi.c	1970-01-01 07:30:00.000000000 +0730
+++ linux-2.6.15.3/drivers/acpi/atlas_acpi.c	2006-02-20 10:00:19.000000000 +0800
@@ -0,0 +1,279 @@
+/*
+ *  atlas_acpi.c - Atlas Wallmount Touchscreen ACPI Extras
+ *
+ *  Copyright (C) 2006 Jaya Kumar
+ *  Based on Toshiba ACPI by John Belmonte and ASUS ACPI
+ *  This work was sponsored by CIS(M) Sdn Bhd.
+ *
+ *  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
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/proc_fs.h>
+#include <asm/uaccess.h>
+#include <acpi/acpi_drivers.h>
+
+#define PROC_ATLAS				"atlas"
+#define ACPI_ATLAS_NAME 			"Atlas ACPI"
+#define ACPI_ATLAS_CLASS			"Atlas"
+#define ACPI_ATLAS_BUTTON_HID			"ASIM0000"
+#define ACPI_ATLAS_BRIGHTNESS_HID		"ACPILCD00"
+
+struct atlas_device {
+	struct acpi_device *dev;
+	u8 brightness;
+	u8 max_brightness;
+};
+
+static struct proc_dir_entry *atlas_proc_dir;
+static struct atlas_device *atlas_dev;
+
+/* based on acpi_memory_powerdown_device */
+static int atlas_set_brightness(struct acpi_device *device, u16 value)
+{
+	acpi_status status;
+	struct acpi_object_list arg_list; 
+	union acpi_object arg;
+
+	arg_list.count = 1;
+	arg_list.pointer = &arg;
+	arg.type = ACPI_TYPE_INTEGER;
+	arg.integer.value = value;
+	status = acpi_evaluate_object(device->handle, "_BCM", &arg_list, NULL);
+	if (ACPI_FAILURE(status)) {
+		printk(KERN_ERR "%s:  ACPI set failed\n", __FUNCTION__);
+		return -ENODEV;
+	} 
+
+	return status ;
+}
+	
+/* based on ibm_get_table_from_acpi */
+static int acpi_read_max_brightness(struct acpi_device *device)
+{
+	union acpi_object *package;
+	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+	acpi_status status;
+	union acpi_object *obj = NULL;
+ 
+	status = acpi_evaluate_object(device->handle, "_BCL", NULL, &buffer);
+	if (ACPI_FAILURE(status)) {
+		printk(KERN_ERR "%s:  ACPI evaluation failed\n", __FUNCTION__);
+		return -ENODEV;
+	} 
+
+	package = (union acpi_object *) buffer.pointer;
+	obj = &(package->package.elements[0]);
+	return obj->integer.value;
+}
+	
+/* based on drivers/usb/media/vicam.c:vicam_write_proc_gain */
+static int atlas_write_proc_lcd(struct file *file, const char *buffer,
+				unsigned long count, void *data)
+{
+	u16 gtmp;
+	char kbuf[8];
+	struct atlas_device *dev = (struct atlas_device *) data;
+
+	if (count > 4)
+		return -EINVAL;
+
+	if (copy_from_user(kbuf, buffer, count))
+		return -EFAULT;
+
+	gtmp = (u16) simple_strtoul(kbuf, NULL, 10);
+	if (gtmp > dev->max_brightness)
+		return -EINVAL;
+
+	atlas_set_brightness(dev->dev, gtmp);
+	dev->brightness = gtmp;
+
+	return count;
+}
+
+/* based on drivers/mca/mca-proc.c:get_mca_machine_info */
+static int atlas_read_proc_lcd(char* page, char **start, off_t off,
+					int count, int *eof, void *data)
+{
+	struct atlas_device *dev = (struct atlas_device *) data;
+	int len;
+	
+	len = sprintf(page,	"brightness:              %d\n"
+				"brightness_levels:     0,%d\n",
+				dev->brightness,dev->max_brightness);
+
+	if (len <= off + count) 
+		*eof = 1;
+	*start = page + off;
+	len -= off;
+	if (len > count) 
+		len = count;
+	if (len < 0) 
+		len = 0;
+	return len;
+}
+
+/* button handling code */
+static acpi_status acpi_atlas_button_setup(acpi_handle region_handle,
+		    u32 function, void *handler_context, void **return_context)
+{
+	*return_context = 
+		(function != ACPI_REGION_DEACTIVATE) ?  handler_context : NULL;
+
+	return AE_OK;
+}
+
+static acpi_status acpi_atlas_button_handler(u32 function,
+		      acpi_physical_address address,
+		      u32 bit_width, acpi_integer * value,
+		      void *handler_context, void *region_context)
+{
+	acpi_status status;
+	struct acpi_device *dev;
+
+	dev = (struct acpi_device *) handler_context;
+	if (function == ACPI_WRITE)
+		status = acpi_bus_generate_event(dev, 0x80, address);
+	else {
+		printk(KERN_WARNING "atlas: shrugged on unexpected function"
+			":function=%x,address=%x,value=%x\n",
+			function, (u32)address, (u32)*value);
+		status = -EINVAL;
+	}
+
+	return status ;
+}
+
+static int atlas_acpi_button_add(struct acpi_device *device)
+{
+
+	/* hookup button handler */
+	return acpi_install_address_space_handler(device->handle,
+				0x81, &acpi_atlas_button_handler,
+				&acpi_atlas_button_setup, device);
+}
+
+static int atlas_acpi_lcd_add(struct acpi_device *device)
+{
+	acpi_status status;
+	struct proc_dir_entry *proc;
+
+	atlas_dev = (struct atlas_device *) 
+			kmalloc(sizeof(struct atlas_device), GFP_KERNEL);
+	if (!atlas_dev)
+		return -ENOMEM;
+
+	/* get max brightness for /proc read use */
+	atlas_dev->max_brightness = acpi_read_max_brightness(device);
+	atlas_dev->dev = device;
+	acpi_driver_data(device) = atlas_dev;
+
+	/* setup proc entry to set and get lcd brightness */
+	proc = create_proc_read_entry("lcd", S_IFREG | S_IRUGO | S_IWUSR,
+			atlas_proc_dir, atlas_read_proc_lcd, atlas_dev);
+	if (!proc) {
+		printk(KERN_ERR "atlas: couldn't alloc proc entry\n");
+		kfree(atlas_dev);
+		status = -ENOMEM;
+	} else {
+		proc->owner = THIS_MODULE;
+		proc->write_proc = atlas_write_proc_lcd;
+		status = AE_OK;
+	}
+	return status ;
+}
+
+static int atlas_acpi_add(struct acpi_device *device)
+{
+
+	if (!strcmp(acpi_device_hid(device), ACPI_ATLAS_BUTTON_HID))
+		return atlas_acpi_button_add(device);
+	else 
+		return atlas_acpi_lcd_add(device);
+}
+
+static int atlas_acpi_remove(struct acpi_device *device, int type)
+{
+	acpi_status status;
+	
+	if (!device || !acpi_driver_data(device))
+		return -EINVAL;
+
+	if (!strcmp(acpi_device_hid(device), ACPI_ATLAS_BUTTON_HID)) {
+		status = acpi_remove_address_space_handler(device->handle,
+				0x81, &acpi_atlas_button_handler);
+		if (ACPI_FAILURE(status))
+			printk(KERN_ERR 
+				"Atlas: Error removing addr spc handler\n");
+	} else {
+		if (atlas_proc_dir)
+			remove_proc_entry("lcd", atlas_proc_dir);
+
+		kfree(atlas_dev);
+		status = AE_OK;
+	}
+
+	return status;
+}
+
+static struct acpi_driver atlas_acpi_driver = {
+	.name 	= ACPI_ATLAS_NAME,
+	.class 	= ACPI_ATLAS_CLASS,
+	.ids 	= ACPI_ATLAS_BUTTON_HID "," ACPI_ATLAS_BRIGHTNESS_HID,
+	.ops = {
+		.add = atlas_acpi_add,
+		.remove = atlas_acpi_remove,
+		},
+};
+
+static int __init atlas_acpi_init(void)
+{
+	int result;
+
+	atlas_proc_dir = proc_mkdir(PROC_ATLAS, acpi_root_dir);
+	if (!atlas_proc_dir) {
+		printk(KERN_ERR "Atlas ACPI: Unable to create /proc dir\n");
+		return -ENODEV;
+	}
+	atlas_proc_dir->owner = THIS_MODULE;
+
+	result = acpi_bus_register_driver(&atlas_acpi_driver);
+	if (result < 0) {
+		printk(KERN_ERR "Atlas ACPI: Unable to register driver\n");
+		remove_proc_entry(PROC_ATLAS, acpi_root_dir);
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
+static void __exit atlas_acpi_exit(void)
+{
+	acpi_bus_unregister_driver(&atlas_acpi_driver);
+	if (atlas_proc_dir) 
+		remove_proc_entry(PROC_ATLAS, acpi_root_dir);
+}
+
+module_init(atlas_acpi_init);
+module_exit(atlas_acpi_exit);
+
+MODULE_AUTHOR("Jaya Kumar");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Atlas ACPI");
+MODULE_SUPPORTED_DEVICE("Atlas ACPI");
diff -X linux-2.6.15.3/Documentation/dontdiff -uprN linux-2.6.15.3-vanilla/drivers/acpi/Kconfig linux-2.6.15.3/drivers/acpi/Kconfig
--- linux-2.6.15.3-vanilla/drivers/acpi/Kconfig	2006-02-19 13:31:11.000000000 +0800
+++ linux-2.6.15.3/drivers/acpi/Kconfig	2006-02-19 19:29:04.000000000 +0800
@@ -194,6 +194,17 @@ config ACPI_ASUS
           something works not quite as expected, please use the mailing list
           available on the above page (acpi4asus-user@lists.sourceforge.net)
           
+config ACPI_ATLAS
+        tristate "Atlas Wallmount Touchscreen Extras"
+	depends on X86
+	default n
+	---help---
+	  This driver is intended for Atlas wallmount touchscreens. 
+	  The button events will show up in /proc/acpi/events and the lcd
+	  brightness control is at /proc/acpi/atlas/lcd
+
+	  If you have an Atlas wallmount touchscreen, say Y or M here.
+         
 config ACPI_IBM
 	tristate "IBM ThinkPad Laptop Extras"
 	depends on X86
diff -X linux-2.6.15.3/Documentation/dontdiff -uprN linux-2.6.15.3-vanilla/drivers/acpi/Makefile linux-2.6.15.3/drivers/acpi/Makefile
--- linux-2.6.15.3-vanilla/drivers/acpi/Makefile	2006-02-19 13:31:11.000000000 +0800
+++ linux-2.6.15.3/drivers/acpi/Makefile	2006-02-19 14:23:59.000000000 +0800
@@ -53,6 +53,7 @@ obj-$(CONFIG_ACPI_SYSTEM)	+= system.o ev
 obj-$(CONFIG_ACPI_DEBUG)	+= debug.o
 obj-$(CONFIG_ACPI_NUMA)		+= numa.o
 obj-$(CONFIG_ACPI_ASUS)		+= asus_acpi.o
+obj-$(CONFIG_ACPI_ATLAS)	+= atlas_acpi.o
 obj-$(CONFIG_ACPI_IBM)		+= ibm_acpi.o
 obj-$(CONFIG_ACPI_TOSHIBA)	+= toshiba_acpi.o
 obj-y				+= scan.o motherboard.o
diff -X linux-2.6.15.3/Documentation/dontdiff -uprN linux-2.6.15.3-vanilla/MAINTAINERS linux-2.6.15.3/MAINTAINERS
--- linux-2.6.15.3-vanilla/MAINTAINERS	2006-02-19 13:30:48.000000000 +0800
+++ linux-2.6.15.3/MAINTAINERS	2006-02-20 09:44:12.000000000 +0800
@@ -366,6 +366,11 @@ M:	ecashin@coraid.com
 W:	http://www.coraid.com/support/linux
 S:	Supported
 
+ATLAS ACPI EXTRAS DRIVER
+P:	Jaya Kumar
+M:	jayakumar.acpi@gmail.com
+S:	Maintained
+
 ATM
 P:	Chas Williams
 M:	chas@cmf.nrl.navy.mil

^ permalink raw reply	[flat|nested] 22+ messages in thread
* RE: [PATCH 2.6.15.3 1/1] ACPI: Atlas ACPI driver
@ 2006-02-20  8:26 Yu, Luming
  2006-02-20  8:37 ` Jaya Kumar
  0 siblings, 1 reply; 22+ messages in thread
From: Yu, Luming @ 2006-02-20  8:26 UTC (permalink / raw)
  To: jayakumar.acpi, linux-acpi, linux-kernel

I found _BCM, _BCL ... which are reserved methods for
ACPI video extension device. If the vendor follows
ACPI video extension spec, this proposed driver is
NOT needed. Because, we do have acpi video driver
in kernel today.  Could you please show me acpidump 
output?

Thanks,
Luming

>Hi Len, ACPI, and kernel folk,
>
>Appended is my patch adding an ACPI driver for Atlas boards. I've
>done this patch against 2.6.15.3. 
>
>Please let me know if it looks okay so far and if you have any 
>feedback 
>or suggestions.
>
>Thanks,
>Jaya Kumar
>
>Signed-off-by: Jaya Kumar <jayakumar.acpi@gmail.com>
>
>---
>
> MAINTAINERS               |    5 
> drivers/acpi/Kconfig      |   11 +
> drivers/acpi/Makefile     |    1 
> drivers/acpi/atlas_acpi.c |  279 
>++++++++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 296 insertions(+)
>
>---
>
>diff -X linux-2.6.15.3/Documentation/dontdiff -uprN 
>linux-2.6.15.3-vanilla/drivers/acpi/atlas_acpi.c 
>linux-2.6.15.3/drivers/acpi/atlas_acpi.c
>--- linux-2.6.15.3-vanilla/drivers/acpi/atlas_acpi.c	
>1970-01-01 07:30:00.000000000 +0730
>+++ linux-2.6.15.3/drivers/acpi/atlas_acpi.c	2006-02-20 
>10:00:19.000000000 +0800
>@@ -0,0 +1,279 @@
>+/*
>+ *  atlas_acpi.c - Atlas Wallmount Touchscreen ACPI Extras
>+ *
>+ *  Copyright (C) 2006 Jaya Kumar
>+ *  Based on Toshiba ACPI by John Belmonte and ASUS ACPI
>+ *  This work was sponsored by CIS(M) Sdn Bhd.
>+ *
>+ *  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
>+ *
>+ */
>+
>+#include <linux/kernel.h>
>+#include <linux/module.h>
>+#include <linux/init.h>
>+#include <linux/types.h>
>+#include <linux/proc_fs.h>
>+#include <asm/uaccess.h>
>+#include <acpi/acpi_drivers.h>
>+
>+#define PROC_ATLAS				"atlas"
>+#define ACPI_ATLAS_NAME 			"Atlas ACPI"
>+#define ACPI_ATLAS_CLASS			"Atlas"
>+#define ACPI_ATLAS_BUTTON_HID			"ASIM0000"
>+#define ACPI_ATLAS_BRIGHTNESS_HID		"ACPILCD00"
>+
>+struct atlas_device {
>+	struct acpi_device *dev;
>+	u8 brightness;
>+	u8 max_brightness;
>+};
>+
>+static struct proc_dir_entry *atlas_proc_dir;
>+static struct atlas_device *atlas_dev;
>+
>+/* based on acpi_memory_powerdown_device */
>+static int atlas_set_brightness(struct acpi_device *device, u16 value)
>+{
>+	acpi_status status;
>+	struct acpi_object_list arg_list; 
>+	union acpi_object arg;
>+
>+	arg_list.count = 1;
>+	arg_list.pointer = &arg;
>+	arg.type = ACPI_TYPE_INTEGER;
>+	arg.integer.value = value;
>+	status = acpi_evaluate_object(device->handle, "_BCM", 
>&arg_list, NULL);
>+	if (ACPI_FAILURE(status)) {
>+		printk(KERN_ERR "%s:  ACPI set failed\n", __FUNCTION__);
>+		return -ENODEV;
>+	} 
>+
>+	return status ;
>+}
>+	
>+/* based on ibm_get_table_from_acpi */
>+static int acpi_read_max_brightness(struct acpi_device *device)
>+{
>+	union acpi_object *package;
>+	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
>+	acpi_status status;
>+	union acpi_object *obj = NULL;
>+ 
>+	status = acpi_evaluate_object(device->handle, "_BCL", 
>NULL, &buffer);
>+	if (ACPI_FAILURE(status)) {
>+		printk(KERN_ERR "%s:  ACPI evaluation 
>failed\n", __FUNCTION__);
>+		return -ENODEV;
>+	} 
>+
>+	package = (union acpi_object *) buffer.pointer;
>+	obj = &(package->package.elements[0]);
>+	return obj->integer.value;
>+}
>+	
>+/* based on drivers/usb/media/vicam.c:vicam_write_proc_gain */
>+static int atlas_write_proc_lcd(struct file *file, const char *buffer,
>+				unsigned long count, void *data)
>+{
>+	u16 gtmp;
>+	char kbuf[8];
>+	struct atlas_device *dev = (struct atlas_device *) data;
>+
>+	if (count > 4)
>+		return -EINVAL;
>+
>+	if (copy_from_user(kbuf, buffer, count))
>+		return -EFAULT;
>+
>+	gtmp = (u16) simple_strtoul(kbuf, NULL, 10);
>+	if (gtmp > dev->max_brightness)
>+		return -EINVAL;
>+
>+	atlas_set_brightness(dev->dev, gtmp);
>+	dev->brightness = gtmp;
>+
>+	return count;
>+}
>+
>+/* based on drivers/mca/mca-proc.c:get_mca_machine_info */
>+static int atlas_read_proc_lcd(char* page, char **start, off_t off,
>+					int count, int *eof, void *data)
>+{
>+	struct atlas_device *dev = (struct atlas_device *) data;
>+	int len;
>+	
>+	len = sprintf(page,	"brightness:              %d\n"
>+				"brightness_levels:     0,%d\n",
>+				dev->brightness,dev->max_brightness);
>+
>+	if (len <= off + count) 
>+		*eof = 1;
>+	*start = page + off;
>+	len -= off;
>+	if (len > count) 
>+		len = count;
>+	if (len < 0) 
>+		len = 0;
>+	return len;
>+}
>+
>+/* button handling code */
>+static acpi_status acpi_atlas_button_setup(acpi_handle region_handle,
>+		    u32 function, void *handler_context, void 
>**return_context)
>+{
>+	*return_context = 
>+		(function != ACPI_REGION_DEACTIVATE) ?  
>handler_context : NULL;
>+
>+	return AE_OK;
>+}
>+
>+static acpi_status acpi_atlas_button_handler(u32 function,
>+		      acpi_physical_address address,
>+		      u32 bit_width, acpi_integer * value,
>+		      void *handler_context, void *region_context)
>+{
>+	acpi_status status;
>+	struct acpi_device *dev;
>+
>+	dev = (struct acpi_device *) handler_context;
>+	if (function == ACPI_WRITE)
>+		status = acpi_bus_generate_event(dev, 0x80, address);
>+	else {
>+		printk(KERN_WARNING "atlas: shrugged on 
>unexpected function"
>+			":function=%x,address=%x,value=%x\n",
>+			function, (u32)address, (u32)*value);
>+		status = -EINVAL;
>+	}
>+
>+	return status ;
>+}
>+
>+static int atlas_acpi_button_add(struct acpi_device *device)
>+{
>+
>+	/* hookup button handler */
>+	return acpi_install_address_space_handler(device->handle,
>+				0x81, &acpi_atlas_button_handler,
>+				&acpi_atlas_button_setup, device);
>+}
>+
>+static int atlas_acpi_lcd_add(struct acpi_device *device)
>+{
>+	acpi_status status;
>+	struct proc_dir_entry *proc;
>+
>+	atlas_dev = (struct atlas_device *) 
>+			kmalloc(sizeof(struct atlas_device), 
>GFP_KERNEL);
>+	if (!atlas_dev)
>+		return -ENOMEM;
>+
>+	/* get max brightness for /proc read use */
>+	atlas_dev->max_brightness = acpi_read_max_brightness(device);
>+	atlas_dev->dev = device;
>+	acpi_driver_data(device) = atlas_dev;
>+
>+	/* setup proc entry to set and get lcd brightness */
>+	proc = create_proc_read_entry("lcd", S_IFREG | S_IRUGO 
>| S_IWUSR,
>+			atlas_proc_dir, atlas_read_proc_lcd, atlas_dev);
>+	if (!proc) {
>+		printk(KERN_ERR "atlas: couldn't alloc proc entry\n");
>+		kfree(atlas_dev);
>+		status = -ENOMEM;
>+	} else {
>+		proc->owner = THIS_MODULE;
>+		proc->write_proc = atlas_write_proc_lcd;
>+		status = AE_OK;
>+	}
>+	return status ;
>+}
>+
>+static int atlas_acpi_add(struct acpi_device *device)
>+{
>+
>+	if (!strcmp(acpi_device_hid(device), ACPI_ATLAS_BUTTON_HID))
>+		return atlas_acpi_button_add(device);
>+	else 
>+		return atlas_acpi_lcd_add(device);
>+}
>+
>+static int atlas_acpi_remove(struct acpi_device *device, int type)
>+{
>+	acpi_status status;
>+	
>+	if (!device || !acpi_driver_data(device))
>+		return -EINVAL;
>+
>+	if (!strcmp(acpi_device_hid(device), ACPI_ATLAS_BUTTON_HID)) {
>+		status = 
>acpi_remove_address_space_handler(device->handle,
>+				0x81, &acpi_atlas_button_handler);
>+		if (ACPI_FAILURE(status))
>+			printk(KERN_ERR 
>+				"Atlas: Error removing addr spc 
>handler\n");
>+	} else {
>+		if (atlas_proc_dir)
>+			remove_proc_entry("lcd", atlas_proc_dir);
>+
>+		kfree(atlas_dev);
>+		status = AE_OK;
>+	}
>+
>+	return status;
>+}
>+
>+static struct acpi_driver atlas_acpi_driver = {
>+	.name 	= ACPI_ATLAS_NAME,
>+	.class 	= ACPI_ATLAS_CLASS,
>+	.ids 	= ACPI_ATLAS_BUTTON_HID "," ACPI_ATLAS_BRIGHTNESS_HID,
>+	.ops = {
>+		.add = atlas_acpi_add,
>+		.remove = atlas_acpi_remove,
>+		},
>+};
>+
>+static int __init atlas_acpi_init(void)
>+{
>+	int result;
>+
>+	atlas_proc_dir = proc_mkdir(PROC_ATLAS, acpi_root_dir);
>+	if (!atlas_proc_dir) {
>+		printk(KERN_ERR "Atlas ACPI: Unable to create 
>/proc dir\n");
>+		return -ENODEV;
>+	}
>+	atlas_proc_dir->owner = THIS_MODULE;
>+
>+	result = acpi_bus_register_driver(&atlas_acpi_driver);
>+	if (result < 0) {
>+		printk(KERN_ERR "Atlas ACPI: Unable to register 
>driver\n");
>+		remove_proc_entry(PROC_ATLAS, acpi_root_dir);
>+		return -ENODEV;
>+	}
>+
>+	return 0;
>+}
>+
>+static void __exit atlas_acpi_exit(void)
>+{
>+	acpi_bus_unregister_driver(&atlas_acpi_driver);
>+	if (atlas_proc_dir) 
>+		remove_proc_entry(PROC_ATLAS, acpi_root_dir);
>+}
>+
>+module_init(atlas_acpi_init);
>+module_exit(atlas_acpi_exit);
>+
>+MODULE_AUTHOR("Jaya Kumar");
>+MODULE_LICENSE("GPL");
>+MODULE_DESCRIPTION("Atlas ACPI");
>+MODULE_SUPPORTED_DEVICE("Atlas ACPI");
>diff -X linux-2.6.15.3/Documentation/dontdiff -uprN 
>linux-2.6.15.3-vanilla/drivers/acpi/Kconfig 
>linux-2.6.15.3/drivers/acpi/Kconfig
>--- linux-2.6.15.3-vanilla/drivers/acpi/Kconfig	
>2006-02-19 13:31:11.000000000 +0800
>+++ linux-2.6.15.3/drivers/acpi/Kconfig	2006-02-19 
>19:29:04.000000000 +0800
>@@ -194,6 +194,17 @@ config ACPI_ASUS
>           something works not quite as expected, please use 
>the mailing list
>           available on the above page 
>(acpi4asus-user@lists.sourceforge.net)
>           
>+config ACPI_ATLAS
>+        tristate "Atlas Wallmount Touchscreen Extras"
>+	depends on X86
>+	default n
>+	---help---
>+	  This driver is intended for Atlas wallmount touchscreens. 
>+	  The button events will show up in /proc/acpi/events 
>and the lcd
>+	  brightness control is at /proc/acpi/atlas/lcd
>+
>+	  If you have an Atlas wallmount touchscreen, say Y or M here.
>+         
> config ACPI_IBM
> 	tristate "IBM ThinkPad Laptop Extras"
> 	depends on X86
>diff -X linux-2.6.15.3/Documentation/dontdiff -uprN 
>linux-2.6.15.3-vanilla/drivers/acpi/Makefile 
>linux-2.6.15.3/drivers/acpi/Makefile
>--- linux-2.6.15.3-vanilla/drivers/acpi/Makefile	
>2006-02-19 13:31:11.000000000 +0800
>+++ linux-2.6.15.3/drivers/acpi/Makefile	2006-02-19 
>14:23:59.000000000 +0800
>@@ -53,6 +53,7 @@ obj-$(CONFIG_ACPI_SYSTEM)	+= system.o ev
> obj-$(CONFIG_ACPI_DEBUG)	+= debug.o
> obj-$(CONFIG_ACPI_NUMA)		+= numa.o
> obj-$(CONFIG_ACPI_ASUS)		+= asus_acpi.o
>+obj-$(CONFIG_ACPI_ATLAS)	+= atlas_acpi.o
> obj-$(CONFIG_ACPI_IBM)		+= ibm_acpi.o
> obj-$(CONFIG_ACPI_TOSHIBA)	+= toshiba_acpi.o
> obj-y				+= scan.o motherboard.o
>diff -X linux-2.6.15.3/Documentation/dontdiff -uprN 
>linux-2.6.15.3-vanilla/MAINTAINERS linux-2.6.15.3/MAINTAINERS
>--- linux-2.6.15.3-vanilla/MAINTAINERS	2006-02-19 
>13:30:48.000000000 +0800
>+++ linux-2.6.15.3/MAINTAINERS	2006-02-20 09:44:12.000000000 +0800
>@@ -366,6 +366,11 @@ M:	ecashin@coraid.com
> W:	http://www.coraid.com/support/linux
> S:	Supported
> 
>+ATLAS ACPI EXTRAS DRIVER
>+P:	Jaya Kumar
>+M:	jayakumar.acpi@gmail.com
>+S:	Maintained
>+
> ATM
> P:	Chas Williams
> M:	chas@cmf.nrl.navy.mil
>-
>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] 22+ messages in thread
[parent not found: <AcY1+QTZumb9d6e3RHms9ocp4LswwgAtmORQ>]
* RE: [PATCH 2.6.15.3 1/1] ACPI: Atlas ACPI driver
@ 2006-03-06 13:50 Yu, Luming
  2006-03-07  1:50 ` Jaya Kumar
  0 siblings, 1 reply; 22+ messages in thread
From: Yu, Luming @ 2006-03-06 13:50 UTC (permalink / raw)
  To: Jaya Kumar; +Cc: linux-acpi, linux-kernel


>On 2/21/06, Yu, Luming <luming.yu@intel.com> wrote:
>> It would be better if you can merge this stuff with acpi 
>video driver.
>> If you look at video.c, there is NO HID definition for video device.
>> we rely on acpi_video_bus_match to recoginize video device in ACPI
>> namespace.
>
>I took a quick look and I think Atlas might be ugly. The current acpi
>video driver, as you pointed out, looks for well known required nodes,
>specifically _DOD,_DOS,_ROM,.... None of these nodes are provided on
>Atlas. From looking at the DSDT, all I see are _BCL and _BCM. It
>doesn't even have _BQC. So, from a quick look at the existing video
>driver, I see a couple of problems that I need advice on:
>
>- is it ok if I add a _BCM check in acpi_video_bus_match. i think this
>is not a problem.

Yes, it's ok, i think.

>- acpi_video_bus_check fails out if no _DOS,_ROM,_GPD,_SPD,_VPO. this
>check fails on Atlas because it doesn't have any of those

These check might be too strict. To face reality, it might need 
be more loose, because it depends on platform vendor to implement
acpi video extension.

>capabilities. The video driver does check for _BCM in
>video_device_find_cap but that's at a much later stage. Do you want me
>to do something like if (acpi_video_bus_check() &&
>acpi_video_output_device_exceptions_detect() )... or do you want me to
>do something cleaner and move the whole _BCM detection earlier in the
>process?

moving it earlier might better.
 
>- acpi_video_bus_get_devices will only call video_bus_get_one_device
>if the device node has children. In Atlas, the "Video Bus", (ie: LCD
>device in the DSDT I pasted before) has no children, at least as found
>by scan.c, so we won't get to get_one_device(). What do you think I
>should do about this?

Please resend me the acpidump, it's somehow dropped from my mailbox.

>
>I have a suspicion that for boards like this where ACPI support isn't
>so complete, we should just use board specific drivers rather than
>mangling the mainstream video driver code. What do you think?

that is the last resort, if you can prove video.c or hotkey.c is NOT 
capable to handle . We do need to make things as generic as possible
in this area, otherwise, I cannot imagine how they can be maintained .
That's the reason why I'm thinking about to propose a ACPI hotkey spec.
Do you have idea for that?

Thanks,
Luming
 


^ permalink raw reply	[flat|nested] 22+ messages in thread
* RE: [PATCH 2.6.15.3 1/1] ACPI: Atlas ACPI driver
@ 2006-03-07  8:52 Yu, Luming
  2006-03-07 16:09 ` Jaya Kumar
  0 siblings, 1 reply; 22+ messages in thread
From: Yu, Luming @ 2006-03-07  8:52 UTC (permalink / raw)
  To: Jaya Kumar; +Cc: linux-acpi, linux-kernel

>I've added it as an attachment here. Please let me know if you get it.
>
I just found this:
            Device (SVG)
                Device (LCD)
It looks too simple to fit video.c.

But it is quite easy to implement in hotkey.c.
Because it has dedicated device with HID and , 
well-known method name.

Ideally, you can enable this jus like this:
http://bugzilla.kernel.org/attachment.cgi?id=6843&action=view

Note, the latest hotkey.c need patch at
http://bugzilla.kernel.org/show_bug.cgi?id=5749


Thanks,
Luming

^ permalink raw reply	[flat|nested] 22+ messages in thread
* RE: [PATCH 2.6.15.3 1/1] ACPI: Atlas ACPI driver
@ 2006-03-08  6:17 Yu, Luming
  2006-03-08  7:11 ` Jaya Kumar
  0 siblings, 1 reply; 22+ messages in thread
From: Yu, Luming @ 2006-03-08  6:17 UTC (permalink / raw)
  To: Jaya Kumar; +Cc: linux-acpi, linux-kernel


>> I just found this:
>>             Device (SVG)
>>                 Device (LCD)
>> It looks too simple to fit video.c.
>
>I'm sorry but I'm confused. Do you mean that I shouldn't try to
>support the brightness using the default video driver (ie: leave it as
>a board specific driver because the board's ACPI implementation for
>video support is insufficient) or did you mean that it will be easy
>and simple to fit in video.c?

I think video.c is NOT a right solution for your problem.

>
>> But it is quite easy to implement in hotkey.c.
>> Because it has dedicated device with HID and ,
>> well-known method name.
>>
>
>I'm confused by hotkey here. I'm not sure how hotkey is involved here.

hotkey.c provide a generic way to register well-known acpi device, and
well-known methods that are mostly related to hotkey. 

>The Atlas board has no  keys physically. It has buttons which are

No differences between buttons and keys to me.

>hooked up using the ASIM HID and that is what I am trying to support
>since those physically exist on the board. Can you help me understand
>how hotkey is involved in this?

You have dedicated ACPI device and method for brightness control.
So hotkey.c is the right place for support Device LCD.

As for Device ASIM, I don't understand this code in your patch,
Care to explain. It looks strange to me.

+static acpi_status acpi_atlas_button_handler(u32 function,
+		      acpi_physical_address address,
+		      u32 bit_width, acpi_integer * value,
+		      void *handler_context, void *region_context)
+{
+	acpi_status status;
+	struct acpi_device *dev;
+
+	dev = (struct acpi_device *) handler_context;
+	if (function == ACPI_WRITE)
+		status = acpi_bus_generate_event(dev, 0x80, address);
+	else {
+		printk(KERN_WARNING "atlas: shrugged on unexpected
function"
+			":function=%x,address=%x,value=%x\n",
+			function, (u32)address, (u32)*value);
+		status = -EINVAL;
+	}
+
+	return status ;
+}
+
+static int atlas_acpi_button_add(struct acpi_device *device)
+{
+
+	/* hookup button handler */
+	return acpi_install_address_space_handler(device->handle,
+				0x81, &acpi_atlas_button_handler,
+				&acpi_atlas_button_setup, device);
+}
+

^ permalink raw reply	[flat|nested] 22+ messages in thread
* RE: [PATCH 2.6.15.3 1/1] ACPI: Atlas ACPI driver
@ 2006-03-08  7:44 Yu, Luming
  2006-03-08  8:53 ` Jaya Kumar
  2006-03-13  6:38 ` Jaya Kumar
  0 siblings, 2 replies; 22+ messages in thread
From: Yu, Luming @ 2006-03-08  7:44 UTC (permalink / raw)
  To: Jaya Kumar; +Cc: linux-acpi, linux-kernel

>I hope what I've explained above makes sense. To reiterate, if you
>want me to do something with respect to hotkey, I still don't
>understand how and where hotkey is involved. Perhaps you could help me
>by elaborating further.

I know this user-defined region needs address space handler, but your
address space handler below  is so weird that make me doubt
the correctness.  The example of address space handler is:
ec.c : acpi_ec_space_handler

I suggest LCD support in hotkey.c like:
http://bugzilla.kernel.org/attachment.cgi?id=6843&action=view

Implement device ASIM  in a separate driver to support user-defined
address space handler.

Config userspace acpi daemon to respond events by evoking
LCD._BCM with command:
	echo -n xx > /sys/hotkey/brightness.

If you do these, then the only specific thing would be ASIM.

Thanks,
Luming 

^ permalink raw reply	[flat|nested] 22+ messages in thread
* RE: [PATCH 2.6.15.3 1/1] ACPI: Atlas ACPI driver
@ 2006-03-13 13:16 Yu, Luming
  0 siblings, 0 replies; 22+ messages in thread
From: Yu, Luming @ 2006-03-13 13:16 UTC (permalink / raw)
  To: Jaya Kumar; +Cc: linux-acpi, linux-kernel

>On 3/8/06, Yu, Luming <luming.yu@intel.com> wrote:
>> I suggest LCD support in hotkey.c like:
>> http://bugzilla.kernel.org/attachment.cgi?id=6843&action=view
>>
>> Config userspace acpi daemon to respond events by evoking
>> LCD._BCM with command:
>>        echo -n xx > /sys/hotkey/brightness.
>>
>
>A quick question here. I took a look at your patch adding hotkeylib. I
>see brightness_show/store callbacks and I think they end up calling 
>write_acpi_int to do the actual method eval.

Yes.  But there are some restricts with write_acpi_int that only
takes single integer parameter, and write_acpi_int2 that fits aml
method of taking Package as argument.  

>
>So I assume my action_method has got to be "_BCM". I don't have a poll
>method but it looks like I'll need to put something in there since you
>check for it. Atlas has a _BCL. I guess I'll just use that.

Yes. poll_method is for query the status/current value.
For example, to query current brightness value.
 
>
>+       if(!poll_handle || !poll_method || !action_handle || 
>!action_method)
>+               goto do_fail;
>
>From what I can tell, it looks like I have to use ACPILCD00 as my HID
>in this hotkey code. Right? So basically, it'd be something like:
>        {
>                .ids = "ACPILCD00",
>                .name = "brightness",
>                .poll_method = "_BCL",
>                .action_method = "_BCM",
>                .min = 1,
>                .max = 31,
>                .id = 10001,
>        },

I think this is ok.

>
>So if I get that working, is that what you are saying is the right way
>to do brightness support for limited devices like Atlas? I guess it
>feels kind of odd to me because it's an LCD device rather than a
>hotkey device. But afaict it looks like doing that will work fine and
>have the added benefit of not creating any new /proc entries. So let
>me know if I understood you correctly.

Yes.  You are right.

>
>By the way, I just applied your sequence of patches from
>http://bugzilla.kernel.org/show_bug.cgi?id=5749 to my tree. You know,
>if it's okay with you, I'll post the full diff from below to your bug
>report so that the next person doesn't have to cherrypick.

Thanks for doing that.

>
>wget "http://bugzilla.kernel.org/attachment.cgi?id=6839&action=view"
>wget "http://bugzilla.kernel.org/attachment.cgi?id=6840&action=view"
>wget "http://bugzilla.kernel.org/attachment.cgi?id=6841&action=view"
>wget "http://bugzilla.kernel.org/attachment.cgi?id=6842&action=view"
>wget "http://bugzilla.kernel.org/attachment.cgi?id=6843&action=view"
>wget "http://bugzilla.kernel.org/attachment.cgi?id=7061&action=view"
>wget "http://bugzilla.kernel.org/attachment.cgi?id=7060&action=view"
>
>Thanks,
>jayakumar

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

end of thread, other threads:[~2006-03-13 13:16 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-20  2:13 [PATCH 2.6.15.3 1/1] ACPI: Atlas ACPI driver jayakumar.acpi
2006-02-20 10:26 ` Matthew Garrett
2006-02-20 10:49   ` Jaya Kumar
2006-02-20 11:01     ` Matthew Garrett
2006-02-20 11:17       ` Henrik Brix Andersen
2006-02-21  0:02         ` Matthew Garrett
2006-02-20 11:25       ` Jaya Kumar
2006-02-20 11:28         ` Matthew Garrett
  -- strict thread matches above, loose matches on Subject: below --
2006-02-20  8:26 Yu, Luming
2006-02-20  8:37 ` Jaya Kumar
     [not found] <AcY1+QTZumb9d6e3RHms9ocp4LswwgAtmORQ>
2006-02-21  6:34 ` Yu, Luming
2006-03-03  8:16   ` Jaya Kumar
2006-03-06 13:50 Yu, Luming
2006-03-07  1:50 ` Jaya Kumar
2006-03-07  8:52 Yu, Luming
2006-03-07 16:09 ` Jaya Kumar
2006-03-08  6:17 Yu, Luming
2006-03-08  7:11 ` Jaya Kumar
2006-03-08  7:44 Yu, Luming
2006-03-08  8:53 ` Jaya Kumar
2006-03-13  6:38 ` Jaya Kumar
2006-03-13 13:16 Yu, Luming

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).