[arch-commits] CVS update of extra/kernels/kernel26ck (2 files)

Tom Killian tom at archlinux.org
Wed Jul 25 10:00:29 UTC 2007


    Date: Wednesday, July 25, 2007 @ 06:00:29
  Author: tom
    Path: /home/cvs-extra/extra/kernels/kernel26ck

   Added: mactel-linux-2.6.22.patch (1.1) squashfs3.2-patch.bz2 (1.1)

upgpkg: kernel26ck 2.6.22.1.ck1-2 The last ever ck release. All the best, Con, it's been a pleasure


---------------------------+
 mactel-linux-2.6.22.patch |  861 ++++++++++++++++++++++++++++++++++++++++++++
 squashfs3.2-patch.bz2     |    <<Binary file>>
 2 files changed, 862 insertions(+)


Index: extra/kernels/kernel26ck/mactel-linux-2.6.22.patch
diff -u /dev/null extra/kernels/kernel26ck/mactel-linux-2.6.22.patch:1.1
--- /dev/null	Wed Jul 25 06:00:28 2007
+++ extra/kernels/kernel26ck/mactel-linux-2.6.22.patch	Wed Jul 25 06:00:28 2007
@@ -0,0 +1,861 @@
+Apple IR patch.
+
+From: James McKenzie <macmini at madingley.org>
+
+
+---
+
+ drivers/input/misc/Kconfig   |    5 +
+ drivers/input/misc/Makefile  |    1 
+ drivers/input/misc/appleir.c |  379 ++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 385 insertions(+), 0 deletions(-)
+
+diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
+index 842a7b4..00d43d0 100644
+--- a/drivers/input/misc/Kconfig
++++ b/drivers/input/misc/Kconfig
+@@ -113,6 +113,10 @@ config INPUT_ATI_REMOTE2
+ 	  To compile this driver as a module, choose M here: the module will be
+ 	  called ati_remote2.
+ 
++config USB_APPLEIR
++	tristate "Apple Mac Mini USB IR receiver (built in)"
++	depends on USB && INPUT
++
+ config INPUT_KEYSPAN_REMOTE
+ 	tristate "Keyspan DMR USB remote control (EXPERIMENTAL)"
+ 	depends on EXPERIMENTAL
+@@ -190,3 +194,4 @@ config HP_SDC_RTC
+ 	  of the HP SDC controller.
+ 
+ endif
++ 	
+diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
+index 8b2f779..ca41877 100644
+--- a/drivers/input/misc/Makefile
++++ b/drivers/input/misc/Makefile
+@@ -14,6 +14,7 @@ obj-$(CONFIG_INPUT_WISTRON_BTNS)	+= wistron_btns.o
+ obj-$(CONFIG_INPUT_ATLAS_BTNS)		+= atlas_btns.o
+ obj-$(CONFIG_INPUT_ATI_REMOTE)		+= ati_remote.o
+ obj-$(CONFIG_INPUT_ATI_REMOTE2)		+= ati_remote2.o
++obj-$(CONFIG_USB_APPLEIR)		+= appleir.o
+ obj-$(CONFIG_INPUT_KEYSPAN_REMOTE)	+= keyspan_remote.o
+ obj-$(CONFIG_INPUT_POWERMATE)		+= powermate.o
+ obj-$(CONFIG_INPUT_YEALINK)		+= yealink.o
+diff --git a/drivers/input/misc/appleir.c b/drivers/input/misc/appleir.c
+new file mode 100644
+index 0000000..170cee6
+--- /dev/null
++++ b/drivers/input/misc/appleir.c
+@@ -0,0 +1,379 @@
++/*
++ * drivers/usb/input/appleir.c - driver for Apple Intel-based Macs IR Receiver
++ *
++ * Copyright (C) 2006 James McKenzie <macmini at madingley.org>
++ *
++ * This program is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License v2 as published by the
++ * Free Software Foundation.
++ *
++ * 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.,
++ * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
++ */
++
++#include <linux/kernel.h>
++#include <linux/slab.h>
++#include <linux/input.h>
++#include <linux/module.h>
++#include <linux/init.h>
++#include <linux/usb.h>
++#include <linux/usb/input.h>
++#include <linux/mutex.h>
++#include <asm/unaligned.h>
++#include <asm/byteorder.h>
++
++#define DRIVER_VERSION "v1.2"
++#define DRIVER_AUTHOR "James McKenzie"
++#define DRIVER_DESC "USB Apple MacIntel IR Receiver driver"
++#define DRIVER_LICENSE "GPL"
++
++MODULE_AUTHOR(DRIVER_AUTHOR);
++MODULE_DESCRIPTION(DRIVER_DESC);
++MODULE_LICENSE(DRIVER_LICENSE);
++
++#define USB_VENDOR_ID_APPLE	0x05ac
++#define USB_DEVICE_ID_APPLE_IR  0x8240
++
++#define URB_SIZE 32
++
++#define MAX_KEYS 8
++#define MAX_KEYS_MASK (MAX_KEYS - 1)
++
++static int debug = 1;
++
++struct appleir {
++	struct input_dev *dev;
++	uint8_t *data;
++	dma_addr_t dma_buf;
++	struct usb_device *usbdev;
++	struct urb *urb;
++	struct timer_list key_up_timer;
++	int current_key;
++	char phys[32];
++};
++
++
++static struct usb_device_id appleir_ids[] = {
++	{ 
++		USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IR),
++		.driver_info = 0
++	},
++	{}
++};
++
++MODULE_DEVICE_TABLE(usb, appleir_ids);
++
++/*
++ * Devices report the following, where XX depends on the remote and/or the
++ * receiver (at least 2a, 83, ca, ee have been reported as possible values, it
++ * looks like it is remote control dependent).
++ * The fifth byte's LSB also depends on the hardware.
++ * 25 87 ee XX 0a/0b  	+
++ * 25 87 ee XX 0c/0d  	-
++ * 25 87 ee XX 09/08	<<
++ * 25 87 ee XX 06/07	>>
++ * 25 87 ee XX 05/04	>"
++ * 25 87 ee 83 03/02	menu
++ * 26 00 00 00 00	for key repeat
++ *
++ * Thomas Glanzmann also observes the following event sometimes sent after a key
++ * is released, which I interpret as a flat battery message:
++ * 25 87 e0 ca 06	flat battery
++ */
++
++static int keymap[MAX_KEYS] = {
++	KEY_RESERVED, KEY_MENU,
++	KEY_PLAYPAUSE, KEY_NEXTSONG,
++	KEY_PREVIOUSSONG, KEY_VOLUMEUP,
++	KEY_VOLUMEDOWN, KEY_RESERVED
++};
++
++static void dump_packet(struct appleir *appleir, char *msg,
++							uint8_t * data, int len)
++{
++	int i;
++
++	printk(KERN_ERR "appleir: %s (%d bytes)", msg, len);
++
++	for (i = 0; i < len; ++i) {
++		printk(" %02x", data[i]);
++	}
++
++	printk("\n");
++}
++
++
++static void key_up(struct appleir *appleir, int key)
++{
++	if (debug)
++		printk (KERN_DEBUG "key %d up\n", key);
++
++	input_report_key(appleir->dev, key, 0);
++	input_sync(appleir->dev);
++}
++
++static void key_down(struct appleir *appleir, int key)
++{
++	if (debug)
++		printk (KERN_DEBUG "key %d down\n", key);
++
++	input_report_key(appleir->dev, key, 1);
++	input_sync(appleir->dev);
++}
++
++static void battery_flat(struct appleir *appleir)
++{
++	printk(KERN_WARNING "appleir: possible flat battery?\n");
++}
++
++static void key_up_tick(unsigned long data)
++{
++	struct appleir *apple_ir = (struct appleir*)data;
++
++	if (apple_ir->current_key) {
++		key_up(apple_ir, apple_ir->current_key);
++		apple_ir->current_key = 0;
++	}
++}
++
++static void parse_data(struct appleir *apple_ir, uint8_t *data, int len)
++{
++	static const uint8_t keydown[] = { 0x25, 0x87, 0xee };
++	static const uint8_t keyrepeat[] = { 0x26, 0x00, 0x00, 0x00, 0x00 };
++	static const uint8_t flatbattery[] = { 0x25, 0x87, 0xe0 };
++
++	if (debug)
++		dump_packet(apple_ir, "received", data, len);
++
++	if (len != 5)
++		return;
++
++	if (!memcmp(data, keydown, sizeof(keydown))) {
++		/* 
++		 * If we already have a key down, take it up before marking
++		 * this one down.
++		 */
++		if (apple_ir->current_key)
++			key_up(apple_ir, apple_ir->current_key);
++		apple_ir->current_key = keymap[(data[4] >> 1) & MAX_KEYS_MASK];
++
++		key_down(apple_ir, apple_ir->current_key);
++
++		/*
++		 * Remote doesn't do key up, either pull them up, in the test
++		 * above, or here set a timer which pulls them up after 1/8 s
++		 */
++		mod_timer(&apple_ir->key_up_timer, jiffies + HZ / 8);
++
++		return;
++	}
++
++	if (!memcmp(data, keyrepeat, sizeof(keyrepeat))) {
++		key_down(apple_ir, apple_ir->current_key);
++
++		/*
++		 * Remote doesn't do key up, either pull them up, in the test
++		 * above, or here set a timer which pulls them up after 1/8 s
++		 */
++		mod_timer(&apple_ir->key_up_timer, jiffies + HZ / 8);
++		return;
++	}
++
++	if (!memcmp(data, flatbattery, sizeof(flatbattery))) {
++		battery_flat(apple_ir);
++		/* Fall through */
++	}
++
++	dump_packet(apple_ir, "unknown packet", data, len);
++}
++
++static void appleir_urb(struct urb *urb)
++{
++	struct appleir *appleir = urb->context;
++	int retval;
++
++	switch (urb->status) {
++	case 0:
++		parse_data(appleir, urb->transfer_buffer, urb->actual_length);
++		break;
++	case -ECONNRESET:
++	case -ENOENT:
++	case -ESHUTDOWN:
++		/* this urb is terminated, clean up */
++		dbg("%s - urb shutting down with status: %d",
++						__FUNCTION__, urb->status);
++		return;
++	default:
++		dbg("%s - nonzero urb status received: %d",
++						__FUNCTION__, urb->status);
++	}
++
++	retval = usb_submit_urb(urb, GFP_ATOMIC);
++	if (retval)
++		err("%s - usb_submit_urb failed with result %d",
++						__FUNCTION__, retval);
++}
++
++
++static int appleir_open(struct input_dev *dev)
++{
++	struct appleir *appleir = dev->private;
++
++	if (usb_submit_urb(appleir->urb, GFP_KERNEL))
++		return -EIO;
++
++	return 0;
++}
++
++static void appleir_close(struct input_dev *dev)
++{
++	struct appleir *appleir = dev->private;
++	usb_kill_urb(appleir->urb);
++	del_timer_sync(&appleir->key_up_timer);
++}
++
++static int appleir_probe(struct usb_interface *intf,
++						const struct usb_device_id *id)
++{
++	struct usb_device *dev = interface_to_usbdev(intf);
++	struct usb_endpoint_descriptor *endpoint;
++	struct appleir *appleir = NULL;
++	struct input_dev *input_dev;
++	int i;
++	int ret = -ENOMEM;
++
++	appleir = kzalloc(sizeof(struct appleir), GFP_KERNEL);
++	if (!appleir)
++		goto fail;
++
++	memset(appleir, 0, sizeof(struct appleir));
++
++	appleir->data =
++	    usb_buffer_alloc(dev, URB_SIZE, GFP_KERNEL, &appleir->dma_buf);
++	if (!appleir->data)
++		goto fail_appleir;
++
++	appleir->urb = usb_alloc_urb(0, GFP_KERNEL);
++	if (!appleir->urb)
++		goto fail_buffer;
++
++	appleir->usbdev = dev;
++
++	input_dev = input_allocate_device();
++	if (!input_dev)
++		goto fail_urb;
++
++	appleir->dev = input_dev;
++
++	if (usb_make_path(dev, appleir->phys, sizeof(appleir->phys)) < 0)
++		goto fail_input_device;
++
++	strlcpy(appleir->phys, "/input0", sizeof(appleir->phys));
++
++	input_dev->name = "Apple MacIntel infrared remote control driver";
++	input_dev->phys = appleir->phys;
++	usb_to_input_id(dev, &input_dev->id);
++	input_dev->cdev.dev = &intf->dev;
++	input_dev->private = appleir;
++
++	input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
++	input_dev->ledbit[0] = 0;
++
++	for (i = 0; i < MAX_KEYS; i++) {
++		set_bit(keymap[i], input_dev->keybit);
++	}
++
++	clear_bit(0, input_dev->keybit);
++
++	input_dev->open = appleir_open;
++	input_dev->close = appleir_close;
++
++	endpoint = &intf->cur_altsetting->endpoint[0].desc;
++
++	usb_fill_int_urb(appleir->urb, dev,
++				usb_rcvintpipe(dev, endpoint->bEndpointAddress),
++				appleir->data, 8,
++				appleir_urb, appleir, endpoint->bInterval);
++
++	appleir->urb->transfer_dma = appleir->dma_buf;
++	appleir->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
++
++	usb_set_intfdata(intf, appleir);
++
++	init_timer(&appleir->key_up_timer);
++
++	appleir->key_up_timer.function = key_up_tick;
++	appleir->key_up_timer.data = (unsigned long) appleir;
++
++	ret = input_register_device(appleir->dev);
++	if (ret < 0)
++		goto fail_timer;
++
++	return 0;
++
++fail_timer:
++	del_timer_sync(&appleir->key_up_timer);
++
++fail_input_device:
++	input_free_device(appleir->dev);
++
++fail_urb:
++	usb_free_urb(appleir->urb);
++
++fail_buffer:
++	usb_buffer_free(dev, URB_SIZE, appleir->data, appleir->dma_buf);
++
++fail_appleir:
++	kfree(appleir);
++
++fail:
++	return ret;
++}
++
++static void appleir_disconnect(struct usb_interface *intf)
++{
++	struct appleir *appleir = usb_get_intfdata(intf);
++
++	usb_set_intfdata(intf, NULL);
++	if (appleir) {
++		input_unregister_device(appleir->dev);
++		del_timer_sync(&appleir->key_up_timer);
++		usb_kill_urb(appleir->urb);
++		usb_free_urb(appleir->urb);
++		usb_buffer_free(interface_to_usbdev(intf), URB_SIZE,
++					appleir->data, appleir->dma_buf);
++		kfree(appleir);
++	}
++}
++
++static struct usb_driver appleir_driver = {
++	.name = "appleir",
++	.probe = appleir_probe,
++	.disconnect = appleir_disconnect,
++	.id_table = appleir_ids,
++};
++
++static int __init appleir_init(void)
++{
++	int retval;
++	retval = usb_register(&appleir_driver);
++	if (retval)
++		goto out;
++	info(DRIVER_VERSION ":" DRIVER_DESC);
++      out:
++	return retval;
++}
++
++static void __exit appleir_exit(void)
++{
++	usb_deregister(&appleir_driver);
++}
++
++module_init(appleir_init);
++module_exit(appleir_exit);
+From: Nicolas Boichat <nicolas at boichat.ch>
+
+
+---
+
+ drivers/hwmon/applesmc.c |  316 +++++++++++++++++++++++++++++++++++++++++++---
+ 1 files changed, 293 insertions(+), 23 deletions(-)
+
+diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
+index fd1281f..e523851 100644
+--- a/drivers/hwmon/applesmc.c
++++ b/drivers/hwmon/applesmc.c
+@@ -39,14 +39,20 @@
+ #include <linux/leds.h>
+ #include <linux/hwmon.h>
+ #include <linux/workqueue.h>
++#include <linux/interrupt.h>
+ 
+ /* data port used by Apple SMC */
+ #define APPLESMC_DATA_PORT	0x300
+ /* command/status port used by Apple SMC */
+ #define APPLESMC_CMD_PORT	0x304
++/* status port used by Apple SMC to get which interrupt type just happened */
++#define APPLESMC_INT_PORT	0x31f
+ 
+ #define APPLESMC_NR_PORTS	32 /* 0x300-0x31f */
+ 
++/* Defined in ACPI DSDT table, should we read it from there? */
++#define APPLESMC_IRQ		6
++
+ #define APPLESMC_MAX_DATA_LENGTH 32
+ 
+ #define APPLESMC_STATUS_MASK	0x0f
+@@ -57,6 +63,8 @@
+ 
+ #define KEY_COUNT_KEY		"#KEY" /* r-o ui32 */
+ 
++#define INTERRUPT_OK_KEY	"NTOK" /* w-o ui8 */
++
+ #define LIGHT_SENSOR_LEFT_KEY	"ALV0" /* r-o {alv (6 bytes) */
+ #define LIGHT_SENSOR_RIGHT_KEY	"ALV1" /* r-o {alv (6 bytes) */
+ #define BACKLIGHT_KEY 		"LKSB" /* w-o {lkb (2 bytes) */
+@@ -68,6 +76,19 @@
+ #define MOTION_SENSOR_Z_KEY	"MO_Z" /* r-o sp78 (2 bytes) */
+ #define MOTION_SENSOR_KEY	"MOCN" /* r/w ui16 */
+ 
++/* 
++ * Interrupt controls.
++ * If the norm of the position (sqrt(MO_X^2+MO_Y^2+MO_Z^2)) is smaller than
++ * MOLT (free fall), or bigger than MOHT (high acceleration) for longer than the
++ * value of MOLD (or MOHD), SMC will trigger an interrupt.
++ */
++#define MOTION_LOW_NORM			"MOLT" /* r/w sp78 (2 bytes) */
++#define MOTION_HIGH_NORM		"MOHT" /* r/w sp78 (2 bytes) */
++#define MOTION_LOW_NORM_INTERVAL	"MOLD" /* r/w ui8 */
++#define MOTION_HIGH_NORM_INTERVAL	"MOHD" /* r/w ui8 */
++
++#define MSDW_KEY		"MSDW" /* r/w flag (1 byte) */
++
+ #define FANS_COUNT		"FNum" /* r-o ui8 */
+ #define FANS_MANUAL		"FS! " /* r-w ui16 */
+ #define FAN_ACTUAL_SPEED	"F0Ac" /* r-o fpe2 (2 bytes) */
+@@ -348,12 +369,79 @@ static int applesmc_read_motion_sensor(int index, s16* value)
+ }
+ 
+ /*
++ * applesmc_init_check_key_value - checks if a given key contains the bytes in 
++ * buffer, if not, writes these bytes.
++ * In case of failure retry every INIT_WAIT_MSECS msec, and timeout if it
++ * waited more than INIT_TIMEOUT_MSECS in total.
++ * Returns zero on success or a negative error on failure. Callers must
++ * hold applesmc_lock.
++ */
++static int applesmc_init_check_key_value(const char* key, u8* buffer, u8 len) 
++{
++	int total, ret, i, compare;
++	u8 rdbuffer[APPLESMC_MAX_DATA_LENGTH];
++
++	if (len > APPLESMC_MAX_DATA_LENGTH) {
++		printk(KERN_ERR "applesmc_init_check_key_value: cannot "
++					"read/write more than %d bytes",
++					APPLESMC_MAX_DATA_LENGTH);
++		return -EINVAL;
++	}
++
++	for (total = INIT_TIMEOUT_MSECS; total > 0; total -= INIT_WAIT_MSECS) {
++		if (!(ret = applesmc_read_key(key, rdbuffer, len))) {
++			compare = 1;
++			for (i = 0; i < len; i++) {
++				if (rdbuffer[i] != buffer[i]) {
++					compare = 0;
++					break;
++				}
++			}
++
++			if (compare) {
++				return 0;
++			}			
++		}
++		ret = applesmc_write_key(key, buffer, len);
++		msleep(INIT_WAIT_MSECS);
++	}
++
++	if (ret)
++		return ret;
++	else
++		return -EIO;
++}
++
++irqreturn_t applesmc_irq_handler(int irq, void *dev_id)
++{
++	u8 int_type = inb(APPLESMC_INT_PORT);
++
++	switch (int_type) {
++	case 0x60:
++		printk("applesmc: received a free fall interrupt\n");
++		break;
++	case 0x6f:
++		printk("applesmc: received a high acceleration interrupt\n");
++		break;
++	case 0x80:
++		printk("applesmc: received a shock interrupt\n");
++		break;
++	default:
++		printk("applesmc: received an unknown interrupt %x\n", int_type);
++	}		
++
++	return IRQ_HANDLED;
++}
++
++/*
+  * applesmc_device_init - initialize the accelerometer.  Returns zero on success
+  * and negative error code on failure.  Can sleep.
+  */
+ static int applesmc_device_init(void)
+ {
+-	int total, ret = -ENXIO;
++	int total;
++	int ret = -ENXIO;
++	int ret1, ret2;
+ 	u8 buffer[2];
+ 
+ 	if (!applesmc_accelerometer)
+@@ -361,32 +449,79 @@ static int applesmc_device_init(void)
+ 
+ 	mutex_lock(&applesmc_lock);
+ 
++	/* Accept interrupts */
++	buffer[0] = 0x01;
+ 	for (total = INIT_TIMEOUT_MSECS; total > 0; total -= INIT_WAIT_MSECS) {
+-		if (debug)
+-			printk(KERN_DEBUG "applesmc try %d\n", total);
+-		if (!applesmc_read_key(MOTION_SENSOR_KEY, buffer, 2) &&
+-				(buffer[0] != 0x00 || buffer[1] != 0x00)) {
+-			if (total == INIT_TIMEOUT_MSECS) {
+-				printk(KERN_DEBUG "applesmc: device has"
+-						" already been initialized"
+-						" (0x%02x, 0x%02x).\n",
+-						buffer[0], buffer[1]);
+-			} else {
+-				printk(KERN_DEBUG "applesmc: device"
+-						" successfully initialized"
+-						" (0x%02x, 0x%02x).\n",
+-						buffer[0], buffer[1]);
+-			}
+-			ret = 0;
+-			goto out;
+-		}
+-		buffer[0] = 0xe0;
+-		buffer[1] = 0x00;
+-		applesmc_write_key(MOTION_SENSOR_KEY, buffer, 2);
++		ret1 = applesmc_write_key(INTERRUPT_OK_KEY, buffer, 1);
++		msleep(INIT_WAIT_MSECS);
++
++		if (!ret1)
++			break;
++	}
++	if (ret1)
++		printk(KERN_WARNING "applesmc: Cannot set NTOK key, "
++					"will not receive interrupts.\n");
++
++	/* Setup interrupt controls. */
++	buffer[0] = 20; /* 20 msecs */
++	ret1 = applesmc_init_check_key_value(MOTION_LOW_NORM_INTERVAL,
++								buffer, 1);
++
++	buffer[0] = 20; /* 20 msecs */
++	ret2 = applesmc_init_check_key_value(MOTION_HIGH_NORM_INTERVAL,
++								buffer, 1);
++
++	if (ret1 || ret2) {
++		printk(KERN_WARNING "applesmc: Cannot set motion sensor "
++					"interrupt interval, might not receive "
++					"some interrupts.");	
++	}
++
++	buffer[0] = 0x00;
++	buffer[1] = 0x60;
++	ret1 = applesmc_init_check_key_value(MOTION_LOW_NORM, buffer, 2);
++
++	buffer[0] = 0x01;
++	buffer[1] = 0xc0;
++	ret2 = applesmc_init_check_key_value(MOTION_HIGH_NORM, buffer, 2);
++
++	if (ret1 || ret2) {
++		printk(KERN_WARNING "applesmc: Cannot set motion sensor "
++				"min/max norm parameters, "
++				"might not receive some interrupts.");	
++	}
++
++	/* Mysterious key. */
++	buffer[0] = 0x01;
++	for (total = INIT_TIMEOUT_MSECS; total > 0; total -= INIT_WAIT_MSECS) {
++		ret1 = applesmc_write_key(MSDW_KEY, buffer, 1);
+ 		msleep(INIT_WAIT_MSECS);
++
++		if (!ret1)
++			break;
++	}
++	if (ret1)
++		printk(KERN_WARNING "applesmc: Cannot set MSDW key\n");
++
++	/* Initialize the device. */
++	buffer[0] = 0xe0;
++	buffer[1] = 0xf8;
++	if (applesmc_init_check_key_value(MOTION_SENSOR_KEY, buffer, 2)) {
++		printk(KERN_WARNING "applesmc: failed to init "
++							"the accelerometer\n");
++		goto out;
+ 	}
+ 
+-	printk(KERN_WARNING "applesmc: failed to init the device\n");
++	ret1 = request_irq(APPLESMC_IRQ, applesmc_irq_handler, IRQF_DISABLED,
++						"applesmc_irq_handler", NULL);
++
++	if (ret1) {
++		printk(KERN_WARNING "applesmc: cannot setup irq handler\n");
++	}
++
++	printk(KERN_DEBUG "applesmc: accelerometer "
++						"successfully initialized.\n");
++	ret = 0;
+ 
+ out:
+ 	mutex_unlock(&applesmc_lock);
+@@ -431,9 +566,16 @@ static int applesmc_resume(struct platform_device *dev)
+ 	return applesmc_device_init();
+ }
+ 
++static int applesmc_remove(struct platform_device *dev)
++{
++	free_irq(6, NULL);
++	return 0;
++}
++
+ static struct platform_driver applesmc_driver = {
+ 	.probe = applesmc_probe,
+ 	.resume = applesmc_resume,
++	.remove = applesmc_remove,
+ 	.driver	= {
+ 		.name = "applesmc",
+ 		.owner = THIS_MODULE,
+@@ -913,6 +1055,122 @@ static ssize_t applesmc_key_at_index_store(struct device *dev,
+ 	return count;
+ }
+ 
++static ssize_t applesmc_accelerometer_show(struct device *dev,
++				struct device_attribute *attr, char *sysfsbuf)
++{
++	int ret;
++	unsigned int value = 0;
++	u8 buffer[2];
++	char* key;
++	int length;
++	struct sensor_device_attribute_2 *sensor_attr =
++						to_sensor_dev_attr_2(attr);
++
++	switch(sensor_attr->index) {
++	case 0:
++		key = MOTION_LOW_NORM_INTERVAL;
++		length = 1;
++		break;
++	case 1:
++		key = MOTION_HIGH_NORM_INTERVAL;
++		length = 1;
++		break;
++	case 2:
++		key = MOTION_LOW_NORM;
++		length = 2;
++		break;
++	case 3:
++		key = MOTION_HIGH_NORM;
++		length = 2;
++		break;
++	default:
++		printk("Invalid index for applesmc_accelerometer_show");
++		return -EINVAL;
++	}
++
++	mutex_lock(&applesmc_lock);
++
++	ret = applesmc_read_key(key, buffer, length);
++	if (length == 2)
++		value = ((unsigned int)buffer[0] << 8) | buffer[1];
++	else if (length == 1)
++		value = buffer[0];
++	else {
++		printk("Invalid length for applesmc_param_show");
++		ret = -EINVAL;
++	}
++
++	mutex_unlock(&applesmc_lock);
++	if (ret)
++		return ret;
++	else
++		return snprintf(sysfsbuf, PAGE_SIZE, "%u\n", value);
++}
++
++static ssize_t applesmc_accelerometer_store(struct device *dev,
++					struct device_attribute *attr,
++					const char *sysfsbuf, size_t count)
++{
++	int ret;
++	u32 value;
++	u8 buffer[2];
++	char* key;
++	int length;
++	struct sensor_device_attribute_2 *sensor_attr =
++						to_sensor_dev_attr_2(attr);
++
++	switch(sensor_attr->index) {
++	case 0:
++		key = MOTION_LOW_NORM_INTERVAL;
++		length = 1;
++		break;
++	case 1:
++		key = MOTION_HIGH_NORM_INTERVAL;
++		length = 1;
++		break;
++	case 2:
++		key = MOTION_LOW_NORM;
++		length = 2;
++		break;
++	case 3:
++		key = MOTION_HIGH_NORM;
++		length = 2;
++		break;
++	default:
++		printk("Invalid index for applesmc_accelerometer_show");
++		return -EINVAL;
++	}
++
++	value = simple_strtoul(sysfsbuf, NULL, 10);
++
++	if (length == 2) {
++		if (value > 0xffff)
++			return -EINVAL;
++
++		buffer[0] = (value >> 8) & 0xff;
++		buffer[1] = value & 0xff;
++	} else if (length == 1) {
++		if (value > 0xff)
++			return -EINVAL;
++
++		buffer[0] = value & 0xff;
++	} else {
++		printk("Invalid length for applesmc_param_store");
++		return -EINVAL;
++	}
++
++	mutex_lock(&applesmc_lock);
++
++	ret = applesmc_write_key(key, buffer, length);
++
++	mutex_unlock(&applesmc_lock);
++
++	if (ret)
++		return ret;
++	else
++		return count;
++}
++
+ static struct led_classdev applesmc_backlight = {
+ 	.name			= "smc:kbd_backlight",
+ 	.default_trigger	= "nand-disk",
+@@ -924,10 +1182,22 @@ static DEVICE_ATTR(name, 0444, applesmc_name_show, NULL);
+ static DEVICE_ATTR(position, 0444, applesmc_position_show, NULL);
+ static DEVICE_ATTR(calibrate, 0644,
+ 			applesmc_calibrate_show, applesmc_calibrate_store);
++static SENSOR_DEVICE_ATTR(low_norm_trigger_interval, 0644,
++		applesmc_accelerometer_show, applesmc_accelerometer_store, 0);
++static SENSOR_DEVICE_ATTR(high_norm_trigger_interval, 0644,
++		applesmc_accelerometer_show, applesmc_accelerometer_store, 1);
++static SENSOR_DEVICE_ATTR(low_norm_trigger, 0644,
++		applesmc_accelerometer_show, applesmc_accelerometer_store, 2);
++static SENSOR_DEVICE_ATTR(high_norm_trigger, 0644,
++		applesmc_accelerometer_show, applesmc_accelerometer_store, 3);
+ 
+ static struct attribute *accelerometer_attributes[] = {
+ 	&dev_attr_position.attr,
+ 	&dev_attr_calibrate.attr,
++	&sensor_dev_attr_low_norm_trigger.dev_attr.attr,
++	&sensor_dev_attr_high_norm_trigger.dev_attr.attr,
++	&sensor_dev_attr_low_norm_trigger_interval.dev_attr.attr,
++	&sensor_dev_attr_high_norm_trigger_interval.dev_attr.attr,
+ 	NULL
+ };
+ 
+Appletouch driver ATP_THRESHOLD fix.
+
+From: Ortwin Glück <odi at odi.ch>
+
+
+---
+
+ drivers/input/mouse/appletouch.c |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c
+index e321526..c26af96 100644
+--- a/drivers/input/mouse/appletouch.c
++++ b/drivers/input/mouse/appletouch.c
+@@ -127,7 +127,7 @@ MODULE_DEVICE_TABLE (usb, atp_table);
+  * Threshold for the touchpad sensors. Any change less than ATP_THRESHOLD is
+  * ignored.
+  */
+-#define ATP_THRESHOLD	 5
++#define ATP_THRESHOLD	 3
+ 
+ /* MacBook Pro (Geyser 3 & 4) initialization constants */
+ #define ATP_GEYSER3_MODE_READ_REQUEST_ID 1
+ 
Index: extra/kernels/kernel26ck/squashfs3.2-patch.bz2
<<Binary file>>




More information about the arch-commits mailing list