Apple Motion Sensor driver
PATCH 1/1 Apple Motion Sensor driver
Hi,
This driver adds support for the Apple Motion Sensor (AMS) as found in 2005 revisions of Apple PowerBooks and iBooks. It implements both the PMU and I²C variants. The I²C driver and mouse emulation is based on code by Stelian Pop <[email protected]>, while the PMU driver has been developped by Michael Hanselmann <[email protected]>. HD parking support will be added later.
Various people contributed fixes to this driver, including Aristeu Sergio Rozanski Filho <[email protected]> and Jean Delvare <[email protected]>.
This patch lived for a while in the -mm tree but was dropped by Andrew in 2.6.18-mm1 because of some conflicting changes he was send at the time. Things have settled down since then, I merged all the bits and pieces and rediffed against the latest git.
This driver should be quite mature to go directly into the input tree. If not, Andrew please pick it up again.
Thanks.
---
b/drivers/hwmon/ams/Makefile | 8 + b/drivers/hwmon/ams/ams-core.c | 265 +++++++++++++++++++++++++++++++++++ b/drivers/hwmon/ams/ams-i2c.c | 299 ++++++++++++++++++++++++++++++++++++++++ b/drivers/hwmon/ams/ams-mouse.c | 147 +++++++++++++++++++ b/drivers/hwmon/ams/ams-pmu.c | 207 +++++++++++++++++++++++++++ b/drivers/hwmon/ams/ams.h | 72 +++++++++ drivers/hwmon/Kconfig | 25 +++ drivers/hwmon/Makefile | 1 8 files changed, 1024 insertions(+)
drivers/hwmon/Kconfig +25 -0
@@ -106,6 +106,31 @@ config SENSORS_K8TEMP This driver can also be built as a module. If so, the module will be called k8temp. +config SENSORS_AMS + tristate "Apple Motion Sensor driver" + depends on HWMON && PPC_PMAC && !PPC64 && INPUT && ((ADB_PMU && I2C = y) || (ADB_PMU && !I2C) || I2C) && EXPERIMENTAL + help + Support for the motion sensor included in PowerBooks. Includes + implementations for PMU and I2C. + + This driver can also be built as a module. If so, the module + will be called ams. + +config SENSORS_AMS_PMU + bool "PMU variant" + depends on SENSORS_AMS && ADB_PMU + default y + help + PMU variant of motion sensor, found in late 2005 PowerBooks. + +config SENSORS_AMS_I2C + bool "I2C variant" + depends on SENSORS_AMS && I2C + default y + help + I2C variant of motion sensor, found in early 2005 PowerBooks and + iBooks. + config SENSORS_ASB100 tristate "Asus ASB100 Bach" depends on HWMON && I2C && EXPERIMENTAL
drivers/hwmon/Makefile +1 -0
@@ -18,6 +18,7 @@ obj-$(CONFIG_SENSORS_ADM1026) += adm1026 obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o +obj-$(CONFIG_SENSORS_AMS) += ams/ obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o obj-$(CONFIG_SENSORS_DS1621) += ds1621.o obj-$(CONFIG_SENSORS_F71805F) += f71805f.o
drivers/hwmon/ams/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# +# Makefile for Apple Motion Sensor driver +# + +ams-y := ams-core.o ams-mouse.o +ams-$(CONFIG_SENSORS_AMS_PMU) += ams-pmu.o +ams-$(CONFIG_SENSORS_AMS_I2C) += ams-i2c.o +obj-$(CONFIG_SENSORS_AMS) += ams.o
drivers/hwmon/ams/ams-core.c new file +265 -0
265 lines not on this page · raw message
drivers/hwmon/ams/ams-i2c.c new file +299 -0
299 lines not on this page · raw message
drivers/hwmon/ams/ams-mouse.c new file +147 -0
147 lines not on this page · raw message
drivers/hwmon/ams/ams-pmu.c new file +207 -0
207 lines not on this page · raw message
drivers/hwmon/ams/ams.h new file +72 -0
72 lines not on this page · raw message
Signature · 1 line
Stelian Pop <[email protected]>
Quoted 3 lines · Stelian Pop
This driver adds support for the Apple Motion Sensor (AMS) as found in 2005 revisions of Apple PowerBooks and iBooks. It implements both the PMU and I²C variants.
I've modified my driver to use an accelerometer class. Do you want the code?
Thanks,
Michael
Quoted 6 lines · Michael Hanselmann
Quoted 3 lines · Stelian Pop
This driver adds support for the Apple Motion Sensor (AMS) as found in 2005 revisions of Apple PowerBooks and iBooks. It implements both the PMU and I²C variants.
I've modified my driver to use an accelerometer class.
Hmmm, I didn't know such a thing existed.
Quoted 1 line
Do you want the code?
Just make sure it gets submitted upstream so it gets no lost.
I don't have a particular use for the accelerometer myself, I was just digging thru the pile of my local patches and I noticed that all the work (mine, yours and others) on the ams device seemed on its way to be lost, since nobody picked up the patch.
But if you're still actively working on it and plan to submit it later, that's perfectly ok with me.
Stelian.
Signature · 1 line
Stelian Pop <[email protected]>
Quoted 3 lines · Stelian Pop
Quoted 1 line
I've modified my driver to use an accelerometer class.
Hmmm, I didn't know such a thing existed.
Yes, I wanted to keep a low profile because it would involve several drivers. So I wanted to work out the basic class with Nicolas, whom I added to Cc: and who's written the accelerator driver for the MacBooks, and then contact the other maintainers. The idea was to have something concrete, not just a concept to discuss.
But since Nicolas is really busy since months, I'd say the submitted code can go in. I'll then make a patch which adds the class.
Quoted 1 line
I don't have a particular use for the accelerometer myself,
So do I, at least without the harddisk protection.
Quoted 3 lines
I was just digging thru the pile of my local patches and I noticed that all the work (mine, yours and others) on the ams device seemed on its way to be lost, since nobody picked up the patch.
Yeah, I was waiting for Nicolas' answer again, so it got stuck here, too.
Greets,
Michael
Le dimanche 12 novembre 2006 à 09:37 +0100, Michael Hanselmann a écrit :
[...]
Quoted 2 lines
But since Nicolas is really busy since months, I'd say the submitted code can go in. I'll then make a patch which adds the class.
Ok, cool, let's get it in then.
Who picks it up ? Jean ? Andrew ?
Thanks.
Signature · 1 line
Stelian Pop <[email protected]>
Stelian,
Quoted 9 lines · Stelian Pop
Le dimanche 12 novembre 2006 à 09:37 +0100, Michael Hanselmann a écrit :
[...]Quoted 2 lines
But since Nicolas is really busy since months, I'd say the submitted code can go in. I'll then make a patch which adds the class.
Ok, cool, let's get it in then.
Who picks it up ? Jean ? Andrew ?
Depends to the answer to my question elsewhere in this thread. If we decide that the accelerometer class and drivers belong to hwmon, I'll take the patch (well it'll need to be submitted and reviewed first anyway.) But if we decide that they belong to the input subsystem, I'd rather let Dmitry handle it.
Thanks,
Signature · 1 line
Jean Delvare
Quoted 11 lines · Jean Delvare
Stelian,
Quoted 8 lines · Stelian Pop
Le dimanche 12 novembre 2006 à 09:37 +0100, Michael Hanselmann a écrit :
[...]Quoted 2 lines
But since Nicolas is really busy since months, I'd say the submitted code can go in. I'll then make a patch which adds the class.
Ok, cool, let's get it in then.
Quoted 8 lines
Quoted 1 line
Who picks it up ? Jean ? Andrew ?
Depends to the answer to my question elsewhere in this thread. If we decide that the accelerometer class and drivers belong to hwmon, I'll take the patch (well it'll need to be submitted and reviewed first anyway.) But if we decide that they belong to the input subsystem, I'd rather let Dmitry handle it.
I think you should pick it up. I consider presence of an input device there as secondary to its main purpose of monitoring box state. It's like DVB and video drivers - I don't insist on moving them into drivers/input just because some of them have remote controls ;)
Signature · 1 line
Dmitry
Hi Stelian,
On 11/11/06, Stelian Pop <[email protected]> wrote:
+
drivers/hwmon/ams/ams-mouse.c line 91
Quoted 13 lines
drivers/hwmon/ams/ams-mouse.c new file +13
-0+if (input_register_device (ams_info.idev)) { +input_free_device (ams_info.idev); + ams_info.idev =NULL ; +return ; + } + + ams_info.kthread =kthread_run (ams_mouse_kthread,NULL ,"kams" ); +if (IS_ERR (ams_info.kthread)) { +input_unregister_device (ams_info.idev); + ams_info.idev =NULL ; +return ; + } +}
Please consider implementing ams_mouse_start() and ams_mouse_stop() methods for input_dev and start/stop polling thread there - there is no reason to report input events when noone listens to them.
Signature · 1 line
Dmitry
Quoted 14 lines · Dmitry Torokhov
Hi Stelian,
On 11/11/06, Stelian Pop <[email protected]> wrote:
+
Quoted 9 lines
(quoted diff) +9
-0+ if (input_register_device(ams_info.idev)) { + input_free_device(ams_info.idev); + ams_info.idev = NULL; + return; + } + + ams_info.kthread = kthread_run(ams_mouse_kthread, NULL, "kams"); + if (IS_ERR(ams_info.kthread)) { + input_unregister_device(ams_info.idev);
Quoted 8 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ ams_info.idev = NULL; + return; + } +}Please consider implementing
ams_mouse_start()andams_mouse_stop()methods forinput_devand start/stop polling thread there - there is no reason to report input events when noone listens to them.
I suppose you talk about input_dev->open() and close() ?
Modified patch below:
---
This driver adds support for the Apple Motion Sensor (AMS) as found in 2005 revisions of Apple PowerBooks and iBooks. It implements both the PMU and I²C variants. The I²C driver and mouse emulation is based on code by Stelian Pop <[email protected]>, while the PMU driver has been developped by Michael Hanselmann <[email protected]>. HD parking support will be added later.
Various people contributed fixes to this driver, including Aristeu Sergio Rozanski Filho <[email protected]> and Jean Delvare <[email protected]>.
---
Kconfig | 25 ++++ Makefile | 1 ams/Makefile | 8 + ams/ams-core.c | 265 +++++++++++++++++++++++++++++++++++++++++++++++++ ams/ams-i2c.c | 299 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ams/ams-mouse.c | 152 ++++++++++++++++++++++++++++ ams/ams-pmu.c | 207 ++++++++++++++++++++++++++++++++++++++ ams/ams.h | 72 +++++++++++++ 8 files changed, 1029 insertions(+)
drivers/hwmon/Kconfig +25 -0
@@ -106,6 +106,31 @@ config SENSORS_K8TEMP This driver can also be built as a module. If so, the module will be called k8temp. +config SENSORS_AMS + tristate "Apple Motion Sensor driver" + depends on HWMON && PPC_PMAC && !PPC64 && INPUT && ((ADB_PMU && I2C = y) || (ADB_PMU && !I2C) || I2C) && EXPERIMENTAL + help + Support for the motion sensor included in PowerBooks. Includes + implementations for PMU and I2C. + + This driver can also be built as a module. If so, the module + will be called ams. + +config SENSORS_AMS_PMU + bool "PMU variant" + depends on SENSORS_AMS && ADB_PMU + default y + help + PMU variant of motion sensor, found in late 2005 PowerBooks. + +config SENSORS_AMS_I2C + bool "I2C variant" + depends on SENSORS_AMS && I2C + default y + help + I2C variant of motion sensor, found in early 2005 PowerBooks and + iBooks. + config SENSORS_ASB100 tristate "Asus ASB100 Bach" depends on HWMON && I2C && EXPERIMENTAL
drivers/hwmon/Makefile +1 -0
@@ -18,6 +18,7 @@ obj-$(CONFIG_SENSORS_ADM1025) += adm1025 obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o +obj-$(CONFIG_SENSORS_AMS) += ams/ obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o obj-$(CONFIG_SENSORS_DS1621) += ds1621.o obj-$(CONFIG_SENSORS_F71805F) += f71805f.o
drivers/hwmon/ams/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# +# Makefile for Apple Motion Sensor driver +# + +ams-y := ams-core.o ams-mouse.o +ams-$(CONFIG_SENSORS_AMS_PMU) += ams-pmu.o +ams-$(CONFIG_SENSORS_AMS_I2C) += ams-i2c.o +obj-$(CONFIG_SENSORS_AMS) += ams.o
drivers/hwmon/ams/ams-core.c new file +265 -0
265 lines not on this page · raw message
drivers/hwmon/ams/ams-i2c.c new file +299 -0
299 lines not on this page · raw message
drivers/hwmon/ams/ams-mouse.c new file +152 -0
152 lines not on this page · raw message
drivers/hwmon/ams/ams-pmu.c new file +207 -0
207 lines not on this page · raw message
drivers/hwmon/ams/ams.h new file +72 -0
72 lines not on this page · raw message
Signature · 1 line
Stelian Pop <[email protected]>
Quoted 24 lines · Stelian Pop
Quoted 14 lines · Dmitry Torokhov
Hi Stelian,
On 11/11/06, Stelian Pop <[email protected]> wrote:
+
Quoted 9 lines
drivers/hwmon/ams/ams-mouse.c new file +9
-0+if (input_register_device (ams_info.idev)) { +input_free_device (ams_info.idev); + ams_info.idev =NULL ; +return ; + } + + ams_info.kthread =kthread_run (ams_mouse_kthread,NULL ,"kams" ); +if (IS_ERR (ams_info.kthread)) { +input_unregister_device (ams_info.idev);Quoted 8 lines
drivers/hwmon/ams/ams-mouse.c line 97
Quoted 4 lines
drivers/hwmon/ams/ams-mouse.c new file +4
-0+ ams_info.idev =NULL ; +return ; + } +}Please consider implementing
ams_mouse_start()andams_mouse_stop()methods forinput_devand start/stop polling thread there - there is no reason to report input events when noone listens to them.
Quoted 2 lines
I suppose you talk about
input_dev->open()andclose()?
Yep.
drivers/hwmon/ams/ams-mouse.c line 54
Quoted 7 lines
drivers/hwmon/ams/ams-mouse.c new file +7
-0+ +static int ams_mouse_open (struct input_dev *dev) +{ + ams_info.kthread =kthread_run (ams_mouse_kthread,NULL ,"kams" ); +return IS_ERR (ams_info.kthread) ? -ENODEV :0 ; +} +
Is there a reason why you reporting -ENODEV instead of real error code from kthread_run()?
Signature · 1 line
Dmitry
Quoted 4 lines · Dmitry Torokhov
Quoted 1 line
+ return
IS_ERR(ams_info.kthread)?-ENODEV: 0;Is there a reason why you reporting
-ENODEVinstead of real error code fromkthread_run()?
Euh... :)
Here it comes again:
---
This driver adds support for the Apple Motion Sensor (AMS) as found in 2005 revisions of Apple PowerBooks and iBooks. It implements both the PMU and I²C variants. The I²C driver and mouse emulation is based on code by Stelian Pop <[email protected]>, while the PMU driver has been developped by Michael Hanselmann <[email protected]>. HD parking support will be added later.
Various people contributed fixes to this driver, including Aristeu Sergio Rozanski Filho <[email protected]> and Jean Delvare <[email protected]>.
Kconfig | 25 ++++ Makefile | 1 ams/Makefile | 8 + ams/ams-core.c | 265 +++++++++++++++++++++++++++++++++++++++++++++++++ ams/ams-i2c.c | 299 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ams/ams-mouse.c | 152 ++++++++++++++++++++++++++++ ams/ams-pmu.c | 207 ++++++++++++++++++++++++++++++++++++++ ams/ams.h | 72 +++++++++++++ 8 files changed, 1029 insertions(+)
drivers/hwmon/Kconfig +25 -0
@@ -106,6 +106,31 @@ config SENSORS_K8TEMP This driver can also be built as a module. If so, the module will be called k8temp. +config SENSORS_AMS + tristate "Apple Motion Sensor driver" + depends on HWMON && PPC_PMAC && !PPC64 && INPUT && ((ADB_PMU && I2C = y) || (ADB_PMU && !I2C) || I2C) && EXPERIMENTAL + help + Support for the motion sensor included in PowerBooks. Includes + implementations for PMU and I2C. + + This driver can also be built as a module. If so, the module + will be called ams. + +config SENSORS_AMS_PMU + bool "PMU variant" + depends on SENSORS_AMS && ADB_PMU + default y + help + PMU variant of motion sensor, found in late 2005 PowerBooks. + +config SENSORS_AMS_I2C + bool "I2C variant" + depends on SENSORS_AMS && I2C + default y + help + I2C variant of motion sensor, found in early 2005 PowerBooks and + iBooks. + config SENSORS_ASB100 tristate "Asus ASB100 Bach" depends on HWMON && I2C && EXPERIMENTAL
drivers/hwmon/Makefile +1 -0
@@ -18,6 +18,7 @@ obj-$(CONFIG_SENSORS_ADM1025) += adm1025 obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o +obj-$(CONFIG_SENSORS_AMS) += ams/ obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o obj-$(CONFIG_SENSORS_DS1621) += ds1621.o obj-$(CONFIG_SENSORS_F71805F) += f71805f.o
drivers/hwmon/ams/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# +# Makefile for Apple Motion Sensor driver +# + +ams-y := ams-core.o ams-mouse.o +ams-$(CONFIG_SENSORS_AMS_PMU) += ams-pmu.o +ams-$(CONFIG_SENSORS_AMS_I2C) += ams-i2c.o +obj-$(CONFIG_SENSORS_AMS) += ams.o
drivers/hwmon/ams/ams-core.c new file +265 -0
265 lines not on this page · raw message
drivers/hwmon/ams/ams-i2c.c new file +299 -0
299 lines not on this page · raw message
drivers/hwmon/ams/ams-mouse.c new file +152 -0
152 lines not on this page · raw message
drivers/hwmon/ams/ams-pmu.c new file +207 -0
207 lines not on this page · raw message
drivers/hwmon/ams/ams.h new file +72 -0
72 lines not on this page · raw message
Signature · 1 line
Stelian Pop <[email protected]>
drivers/hwmon/ams/ams-mouse.c line 37
Quoted 4 lines · Stelian Pop
drivers/hwmon/ams/ams-mouse.c new file +3
-0+input_report_abs (ams_info.idev,ABS_X , x - ams_info.xcalib); +input_report_abs (ams_info.idev,ABS_Y , y - ams_info.ycalib); +input_report_abs (ams_info.idev,ABS_Z , z - ams_info.zcalib);
Sorry about chiming in so late. When I tried to use this with neverball, ams_info.xcalib - x (and similar for the others) was more useful because of the way things are oriented. If I tilt my powerbook to the left then with this original code the mouse cursor moves to the right which is contrary to what neverball expects.
Not sure if we want to change this or not, it sort of boils down to a userspace issue and we could just patch neverball to have a direction inversion :)
johannes
Quoted 12 lines · Johannes Berg
drivers/hwmon/ams/ams-mouse.c line 37
Quoted 4 lines · Stelian Pop
drivers/hwmon/ams/ams-mouse.c new file +3
-0+input_report_abs (ams_info.idev,ABS_X , x - ams_info.xcalib); +input_report_abs (ams_info.idev,ABS_Y , y - ams_info.ycalib); +input_report_abs (ams_info.idev,ABS_Z , z - ams_info.zcalib);Sorry about chiming in so late. When I tried to use this with neverball, ams_info.xcalib - x (and similar for the others) was more useful because of the way things are oriented. If I tilt my powerbook to the left then with this original code the mouse cursor moves to the right which is contrary to what neverball expects.
Quoted 3 lines
Not sure if we want to change this or not, it sort of boils down to a userspace issue and we could just patch neverball to have a direction inversion :)
For what it's worth, the hdaps driver offers a parameter to invert the axes at the driver level. It sounds sane to me, as ideally we should be able to detect it from the hardware, and user-space should not need to care about hardware specific details.
Signature · 1 line
Jean Delvare
Quoted 2 lines · Jean Delvare
For what it's worth, the hdaps driver offers a parameter to invert the axes at the driver level.
Ah ok.
Quoted 3 lines
It sounds sane to me, as ideally we should be
able to detect it from the hardware, and user-space should not need to care about hardware specific details.
Yeah well I figured we'd just put the parameter into userspace instead :)
Thing is, there's simply no clear standard for accelerometer input devices. If the left side of my input device (read powerbook here) is lower, does the mouse cursor 'fall' with gravity, or does it 'float' up? Neverball apparently expects it to fall with gravity.
johannes
Quoted 2 lines · Johannes Berg
Yeah well I figured we'd just put the parameter into userspace instead :)
Most games have such an option already. I remember Quake 3 to have one. Shouldn't be too hard to implement for the Open Source games and I also think this belongs into userspace, mainly because the interpretation of the input might differ.
Greets,
Michael
Quoted 4 lines · Johannes Berg
Thing is, there's simply no clear standard for accelerometer input devices. If the left side of my input device (read powerbook here) is lower, does the mouse cursor 'fall' with gravity, or does it 'float' up? Neverball apparently expects it to fall with gravity.
So let's make neverball happy ! Hacker productivity depends on it :)
The latest incarnation of ams I posted somewhere in this thread adds an invert option like done in hdaps. I haven't switched the data on the Z axis though, not sure if it makes any sense to do it.
Signature · 1 line
Stelian Pop <[email protected]>
Quoted 11 lines · Stelian Pop
Quoted 4 lines · Dmitry Torokhov
Quoted 1 line
+ return
IS_ERR(ams_info.kthread)?-ENODEV: 0;Is there a reason why you reporting
-ENODEVinstead of real error code fromkthread_run()?Euh... :)
Here it comes again:
Great :) Now I wonder if I may ask you to change name of the module option from "mouse" to "joystick" (HP driver uses this name as well) because its functionality is closer to a joystick than a mouse.
Otherwise you can have my Acked-by for the input part.
Signature · 1 line
Dmitry
Robert Love
Acked-byQuoted 5 lines · Dmitry Torokhov
Great :) Now I wonder if I may ask you to change name of the module option from "mouse" to "joystick" (HP driver uses this name as well) because its functionality is closer to a joystick than a mouse.
Otherwise you can have my Acked-by for the input part.
Me too.
Robert
Quoted 8 lines · Dmitry Torokhov
Quoted 7 lines · Stelian Pop
Quoted 4 lines · Dmitry Torokhov
Quoted 1 line
+ return
IS_ERR(ams_info.kthread)?-ENODEV: 0;Is there a reason why you reporting
-ENODEVinstead of real error code fromkthread_run()?
Quoted 8 lines
Quoted 4 lines
Euh... :)
Here it comes again:
Great :) Now I wonder if I may ask you to change name of the module option from "mouse" to "joystick" (HP driver uses this name as well) because its functionality is closer to a joystick than a mouse.
Ok. I've changed the module parameter to 'joystick' and all references to 'mouse' (ams-mouse.c, and internal functions names etc) to 'input'.
I've also added a 'invert' option to invert the X/Y axis data like the hdaps driver does.
The latest version is below.
Thanks,
Stelian.
---
This driver adds support for the Apple Motion Sensor (AMS) as found in 2005 revisions of Apple PowerBooks and iBooks. It implements both the PMU and I²C variants. The I²C driver and mouse emulation is based on code by Stelian Pop <[email protected]>, while the PMU driver has been developped by Michael Hanselmann <[email protected]>. HD parking support will be added later.
Various people contributed fixes to this driver, including Aristeu Sergio Rozanski Filho <[email protected]> and Jean Delvare <[email protected]>.
---
drivers/hwmon/Kconfig | 25 +++ drivers/hwmon/Makefile | 1 drivers/hwmon/ams/Makefile | 8 + drivers/hwmon/ams/ams-core.c | 265 ++++++++++++++++++++++++++++++++++++ drivers/hwmon/ams/ams-i2c.c | 299 +++++++++++++++++++++++++++++++++++++++++ drivers/hwmon/ams/ams-input.c | 160 ++++++++++++++++++++++ drivers/hwmon/ams/ams-pmu.c | 207 ++++++++++++++++++++++++++++ drivers/hwmon/ams/ams.h | 72 ++++++++++ 8 files changed, 1037 insertions(+), 0 deletions(-)
drivers/hwmon/Kconfig +25 -0
@@ -106,6 +106,31 @@ config SENSORS_K8TEMP This driver can also be built as a module. If so, the module will be called k8temp. +config SENSORS_AMS + tristate "Apple Motion Sensor driver" + depends on HWMON && PPC_PMAC && !PPC64 && INPUT && ((ADB_PMU && I2C = y) || (ADB_PMU && !I2C) || I2C) && EXPERIMENTAL + help + Support for the motion sensor included in PowerBooks. Includes + implementations for PMU and I2C. + + This driver can also be built as a module. If so, the module + will be called ams. + +config SENSORS_AMS_PMU + bool "PMU variant" + depends on SENSORS_AMS && ADB_PMU + default y + help + PMU variant of motion sensor, found in late 2005 PowerBooks. + +config SENSORS_AMS_I2C + bool "I2C variant" + depends on SENSORS_AMS && I2C + default y + help + I2C variant of motion sensor, found in early 2005 PowerBooks and + iBooks. + config SENSORS_ASB100 tristate "Asus ASB100 Bach" depends on HWMON && I2C && EXPERIMENTAL
drivers/hwmon/Makefile +1 -0
@@ -18,6 +18,7 @@ obj-$(CONFIG_SENSORS_ADM1025) += adm1025 obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o +obj-$(CONFIG_SENSORS_AMS) += ams/ obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o obj-$(CONFIG_SENSORS_DS1621) += ds1621.o obj-$(CONFIG_SENSORS_F71805F) += f71805f.o
drivers/hwmon/ams/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# +# Makefile for Apple Motion Sensor driver +# + +ams-y := ams-core.o ams-input.o +ams-$(CONFIG_SENSORS_AMS_PMU) += ams-pmu.o +ams-$(CONFIG_SENSORS_AMS_I2C) += ams-i2c.o +obj-$(CONFIG_SENSORS_AMS) += ams.o
drivers/hwmon/ams/ams-core.c new file +265 -0
265 lines not on this page · raw message
drivers/hwmon/ams/ams-i2c.c new file +299 -0
299 lines not on this page · raw message
drivers/hwmon/ams/ams-input.c new file +160 -0
160 lines not on this page · raw message
drivers/hwmon/ams/ams-pmu.c new file +207 -0
207 lines not on this page · raw message
drivers/hwmon/ams/ams.h new file +72 -0
72 lines not on this page · raw message
Signature · 1 line
Stelian Pop <[email protected]>
Quoted 4 lines
The fact that the accelerometer offers a (low res) joystick emulation is only a nice hack and I'm not even sure somebody (except Johannes) will find an use for it.
Heh. Well I think it's fun once a while :)
drivers/hwmon/ams/ams-input.c line 45
Quoted 8 lines · Stelian Pop
drivers/hwmon/ams/ams-input.c new file +7
-0+ x -= ams_info.xcalib; + y -= ams_info.ycalib; + z -= ams_info.zcalib; + +input_report_abs (ams_info.idev,ABS_X , invert ? -x : x); +input_report_abs (ams_info.idev,ABS_Y , invert ? -y : y); +input_report_abs (ams_info.idev,ABS_Z , z - ams_info.zcalib);
You're double-calibrating z now, which is surely not what was intended.
johannes
Quoted 10 lines · Johannes Berg
Review
Quoted 8 lines
(quoted diff) +7
-0+ x -= ams_info.xcalib; + y -= ams_info.ycalib; + z -= ams_info.zcalib; + + input_report_abs(ams_info.idev, ABS_X, invert ? -x : x); + input_report_abs(ams_info.idev, ABS_Y, invert ? -y : y); + input_report_abs(ams_info.idev, ABS_Z, z - ams_info.zcalib);You're double-calibrating z now, which is surely not what was intended.
Oh well, I guess it's time to get some sleep.
Here comes the updated version.
Thanks.
Stelian.
---
This driver adds support for the Apple Motion Sensor (AMS) as found in 2005 revisions of Apple PowerBooks and iBooks. It implements both the PMU and I²C variants. The I²C driver and mouse emulation is based on code by Stelian Pop <[email protected]>, while the PMU driver has been developped by Michael Hanselmann <[email protected]>. HD parking support will be added later.
Various people contributed fixes to this driver, including Aristeu Sergio Rozanski Filho <[email protected]> and Jean Delvare <[email protected]>.
---
drivers/hwmon/Kconfig | 25 +++ drivers/hwmon/Makefile | 1 drivers/hwmon/ams/Makefile | 8 + drivers/hwmon/ams/ams-core.c | 265 ++++++++++++++++++++++++++++++++++++ drivers/hwmon/ams/ams-i2c.c | 299 +++++++++++++++++++++++++++++++++++++++++ drivers/hwmon/ams/ams-input.c | 160 ++++++++++++++++++++++ drivers/hwmon/ams/ams-pmu.c | 207 ++++++++++++++++++++++++++++ drivers/hwmon/ams/ams.h | 72 ++++++++++ 8 files changed, 1037 insertions(+), 0 deletions(-)
drivers/hwmon/Kconfig +25 -0
@@ -106,6 +106,31 @@ config SENSORS_K8TEMP This driver can also be built as a module. If so, the module will be called k8temp. +config SENSORS_AMS + tristate "Apple Motion Sensor driver" + depends on HWMON && PPC_PMAC && !PPC64 && INPUT && ((ADB_PMU && I2C = y) || (ADB_PMU && !I2C) || I2C) && EXPERIMENTAL + help + Support for the motion sensor included in PowerBooks. Includes + implementations for PMU and I2C. + + This driver can also be built as a module. If so, the module + will be called ams. + +config SENSORS_AMS_PMU + bool "PMU variant" + depends on SENSORS_AMS && ADB_PMU + default y + help + PMU variant of motion sensor, found in late 2005 PowerBooks. + +config SENSORS_AMS_I2C + bool "I2C variant" + depends on SENSORS_AMS && I2C + default y + help + I2C variant of motion sensor, found in early 2005 PowerBooks and + iBooks. + config SENSORS_ASB100 tristate "Asus ASB100 Bach" depends on HWMON && I2C && EXPERIMENTAL
drivers/hwmon/Makefile +1 -0
@@ -18,6 +18,7 @@ obj-$(CONFIG_SENSORS_ADM1025) += adm1025 obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o +obj-$(CONFIG_SENSORS_AMS) += ams/ obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o obj-$(CONFIG_SENSORS_DS1621) += ds1621.o obj-$(CONFIG_SENSORS_F71805F) += f71805f.o
drivers/hwmon/ams/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# +# Makefile for Apple Motion Sensor driver +# + +ams-y := ams-core.o ams-input.o +ams-$(CONFIG_SENSORS_AMS_PMU) += ams-pmu.o +ams-$(CONFIG_SENSORS_AMS_I2C) += ams-i2c.o +obj-$(CONFIG_SENSORS_AMS) += ams.o
drivers/hwmon/ams/ams-core.c new file +265 -0
265 lines not on this page · raw message
drivers/hwmon/ams/ams-i2c.c new file +299 -0
299 lines not on this page · raw message
drivers/hwmon/ams/ams-input.c new file +160 -0
160 lines not on this page · raw message
drivers/hwmon/ams/ams-pmu.c new file +207 -0
207 lines not on this page · raw message
drivers/hwmon/ams/ams.h new file +72 -0
72 lines not on this page · raw message
Signature · 1 line
Stelian Pop <[email protected]>
Hi Stelian,
Quoted 20 lines · Stelian Pop
This driver adds support for the Apple Motion Sensor (AMS) as found in 2005 revisions of Apple PowerBooks and iBooks. It implements both the PMU and I²C variants. The I²C driver and mouse emulation is based on code by Stelian Pop <[email protected]>, while the PMU driver has been developped by Michael Hanselmann <[email protected]>. HD parking support will be added later.
Various people contributed fixes to this driver, including Aristeu Sergio Rozanski Filho <[email protected]> and Jean Delvare <[email protected]>.
This patch lived for a while in the -mm tree but was dropped by Andrew in 2.6.18-mm1 because of some conflicting changes he was send at the time. Things have settled down since then, I merged all the bits and pieces and rediffed against the latest git.
This driver should be quite mature to go directly into the input tree. If not, Andrew please pick it up again.
(...)
Quoted 9 lines
b/drivers/hwmon/ams/Makefile | 8 + b/drivers/hwmon/ams/ams-core.c | 265 +++++++++++++++++++++++++++++++++++ b/drivers/hwmon/ams/ams-i2c.c | 299 ++++++++++++++++++++++++++++++++++++++++ b/drivers/hwmon/ams/ams-mouse.c | 147 +++++++++++++++++++ b/drivers/hwmon/ams/ams-pmu.c | 207 +++++++++++++++++++++++++++ b/drivers/hwmon/ams/ams.h | 72 +++++++++ drivers/hwmon/Kconfig | 25 +++ drivers/hwmon/Makefile | 1 8 files changed, 1024 insertions(+)
There's some confusion here. On the one hand, you placed your driver in the hwmon directory, and integrated it in the Hardware Monitoring menu. But on the other hand you seem to think that the input tree is the natural merge path for this patch. Isn't it strange?
This raises the question of what these drivers (ams, hdaps...) really are, and where they really belong. The hdaps driver is very different from all other driver in the hwmon directory. Maybe they would be better located in drivers/input/accel? This is an open question, I really don't know.
(Side note: you could use the -p1 parameter of diffstat for better results.)
Signature · 1 line
Jean Delvare
Quoted 5 lines · Jean Delvare
This raises the question of what these drivers (ams, hdaps...) really are, and where they really belong. The hdaps driver is very different from all other driver in the hwmon directory. Maybe they would be better located in
drivers/input/accel? This is an open question, I really don't know.
I'd vote for the accelerometer class (whatever that thing is! please cc hdaps-devel with such stuff) and all accelerometer drives being in drivers/input/accel, yes.
Signature · 4 lines
"One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh
Quoted 33 lines · Jean Delvare
Hi Stelian,
Quoted 20 lines · Stelian Pop
This driver adds support for the Apple Motion Sensor (AMS) as found in 2005 revisions of Apple PowerBooks and iBooks. It implements both the PMU and I²C variants. The I²C driver and mouse emulation is based on code by Stelian Pop <[email protected]>, while the PMU driver has been developped by Michael Hanselmann <[email protected]>. HD parking support will be added later.
Various people contributed fixes to this driver, including Aristeu Sergio Rozanski Filho <[email protected]> and Jean Delvare <[email protected]>.
This patch lived for a while in the -mm tree but was dropped by Andrew in 2.6.18-mm1 because of some conflicting changes he was send at the time. Things have settled down since then, I merged all the bits and pieces and rediffed against the latest git.
This driver should be quite mature to go directly into the input tree. If not, Andrew please pick it up again.
(...)
Quoted 9 lines
b/drivers/hwmon/ams/Makefile | 8 + b/drivers/hwmon/ams/ams-core.c | 265 +++++++++++++++++++++++++++++++++++ b/drivers/hwmon/ams/ams-i2c.c | 299 ++++++++++++++++++++++++++++++++++++++++ b/drivers/hwmon/ams/ams-mouse.c | 147 +++++++++++++++++++ b/drivers/hwmon/ams/ams-pmu.c | 207 +++++++++++++++++++++++++++ b/drivers/hwmon/ams/ams.h | 72 +++++++++ drivers/hwmon/Kconfig | 25 +++ drivers/hwmon/Makefile | 1 8 files changed, 1024 insertions(+)
Quoted 4 lines
There's some confusion here. On the one hand, you placed your driver in the hwmon directory, and integrated it in the Hardware Monitoring menu. But on the other hand you seem to think that the input tree is the natural merge path for this patch. Isn't it strange?
This is because I got myself confused when writing that sentence (minutes ago I was sending a patch for the appletouch driver, targeted at the input tree).
I do believe that the proper place for ams is the hardware monitoring section (even if the missing HD parking APIs makes it not very useful right now).
The fact that the accelerometer offers a (low res) joystick emulation is only a nice hack and I'm not even sure somebody (except Johannes) will find an use for it.
Signature · 1 line
Stelian Pop <[email protected]>
Quoted 7 lines · Stelian Pop
I do believe that the proper place for ams is the hardware monitoring section (even if the missing HD parking APIs makes it not very useful right now).
The fact that the accelerometer offers a (low res) joystick emulation is only a nice hack and I'm not even sure somebody (except Johannes) will find an use for it.
Sort of. Some accelerometers actually act more as input devices than as monitoring devices. E.g. HDAPS has no intelligence whatsoever about what is happening (it doesn't to any sort of threshold detection, unlike Apple's motion sensing stuff), but it can give you reasonable resolution at a maximum sample rate of 500Hz (I don't recommend getting it to go that fast, though) for two axis, with configurable running-averaging. Looks a lot more like a joystick to me than a hardware monitoring sensor.
It's just a matter of PoV, and one can easily make a case for accelerometers
to live in either hwmon or input. As long as they're all in one place :-)
Signature · 4 lines
"One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh