LIS3LV02Dx Accelerometer driver
Subsystems (2)
PATCH 1/1 LIS3LV02Dx Accelerometer driver
LIS3LV02Dx Accelerometer driver
This adds a driver to the accelerometer sensor found in several HP laptops (under the commercial names of "HP Mobile Data Protection System 3D" and "HP 3D driveguard"). It tries to have more or less the same interfaces as the hdaps and other accelerometer drivers: in sysfs and as a joystick.
This driver was first written by Yan Burman. Eric Piel has updated it and slimed it up (including the removal of an interface to access to the free-fall feature of the sensor because it is not reliable enough for now). Pavel Machek removed few more features and switched locking from semaphore to mutex.
Several people have contributed to the database of the axes.
---
This should fix the locking and all the comments from Andrew. Relative to 2.6.27-git10.
MAINTAINERS | 5 linux/Documentation/hwmon/lis3lv02d | 49 +++ linux/drivers/hwmon/Kconfig | 19 + linux/drivers/hwmon/Makefile | 1 linux/drivers/hwmon/lis3lv02d.c | 582 ++++++++++++++++++++++++++++++++++++ linux/drivers/hwmon/lis3lv02d.h | 149 +++++++++ 6 files changed, 805 insertions(+)
drivers/hwmon/Kconfig +19 -0
@@ -825,6 +825,25 @@ Say Y here if you have an applicable laptop and want to experience the awesome power of hdaps. +config SENSORS_LIS3LV02D + tristate "STMicroeletronics LIS3LV02Dx three-axis digital accelerometer" + depends on ACPI && INPUT + default n + help + This driver provides support for the LIS3LV02Dx accelerometer. In + particular, it can be found in a number of HP laptops, which have the + "Mobile Data Protection System 3D" or "3D DriveGuard" feature. On such + systems the driver should load automatically (via ACPI). The + accelerometer might also be found in other systems, connected via SPI + or I²C. The accelerometer data is readable via + /sys/devices/platform/lis3lv02d. + + This driver also provides an absolute input class device, allowing + the laptop to act as a pinball machine-esque joystick. + + This driver can also be built as a module. If so, the module + will be called lis3lv02d. + config SENSORS_APPLESMC tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)" depends on INPUT && X86
drivers/hwmon/Makefile +1 -0
@@ -48,6 +48,7 @@ obj-$(CONFIG_SENSORS_IBMPEX) += ibmpex.o obj-$(CONFIG_SENSORS_IT87) += it87.o obj-$(CONFIG_SENSORS_K8TEMP) += k8temp.o +obj-$(CONFIG_SENSORS_LIS3LV02D) += lis3lv02d.o obj-$(CONFIG_SENSORS_LM63) += lm63.o obj-$(CONFIG_SENSORS_LM70) += lm70.o obj-$(CONFIG_SENSORS_LM75) += lm75.o
drivers/hwmon/lis3lv02d.c +582 -0
582 lines not on this page · raw message
drivers/hwmon/lis3lv02d.h +149 -0
149 lines not on this page · raw message
Documentation/hwmon/lis3lv02d +49 -0
49 lines not on this page · raw message
MAINTAINERS +5 -0
@@ -2638,6 +2638,11 @@ M: [email protected] S: Maintained +LIS3LV02D ACCELEROMETER DRIVER +P: Eric Piel +M: [email protected] +S: Maintained + LM83 HARDWARE MONITOR DRIVER P: Jean Delvare M: [email protected]
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Pavel Machek schreef:
Quoted 5 lines
This driver was first written by Yan Burman. Eric Piel has updated it and slimed it up (including the removal of an interface to access to the free-fall feature of the sensor because it is not reliable enough for now). Pavel Machek removed few more features and switched locking from semaphore to mutex.
I wa planning to update the patch this evening, but Pavel beat me at it. Thanks.
See you,
Eric
PATCH 1/1 LIS3LV02D: Conform to the new ACPI API
In reply to Pavel MachekACPI API has been updated to allow 64bit return values in acpi_evaluate_integer(). Update also the lis3lv02d driver so that it works with 2.6.28-rc1.
--- drivers/hwmon/lis3lv02d.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/hwmon/lis3lv02d.c +0 -0
@@ -112,7 +112,7 @@ static acpi_status lis3lv02d_acpi_read(acpi_handle
handle, int reg, u8 *ret)
{
union acpi_object arg0 = { ACPI_TYPE_INTEGER }; struct acpi_object_list args = { 1, &arg0 };
- unsigned long lret;
+ unsigned long long lret;
acpi_status status;
arg0.integer.value = reg;
@@ -132,7 +132,7 @@ static acpi_status lis3lv02d_acpi_read(acpi_handle handle, int reg, u8 *ret)
*/
static acpi_status lis3lv02d_acpi_write(acpi_handle handle, int reg, u8
val)
{
- unsigned long ret; /* Not used when writting */
+ unsigned long long ret; /* Not used when writting */
union acpi_object in_obj[2];
struct acpi_object_list args = { 2, in_obj };
Signature · 1 line
1.6.0.2
Quoted 28 lines · On Wed, 22 Oct 2008 17:44:59 +0200 Pavel Machek <[email protected]> wrote:
LIS3LV02Dx Accelerometer driver
This adds a driver to the accelerometer sensor found in several HP laptops (under the commercial names of "HP Mobile Data Protection System 3D" and "HP 3D driveguard"). It tries to have more or less the same interfaces as the hdaps and other accelerometer drivers: in sysfs and as a joystick.
This driver was first written by Yan Burman. Eric Piel has updated it and slimed it up (including the removal of an interface to access to the free-fall feature of the sensor because it is not reliable enough for now). Pavel Machek removed few more features and switched locking from semaphore to mutex.
Several people have contributed to the database of the axes.
...
drivers/hwmon/lis3lv02d.c +6
-0+/* joystick device poll interval in milliseconds */ +#define MDPS_POLL_INTERVAL 50 +static int lis3lv02d_joystick_kthread (void *data) +{ +int x, y, z; +
drivers/hwmon/lis3lv02d.c line 289
Quoted 10 lines
drivers/hwmon/lis3lv02d.c +10
-0+while (!kthread_should_stop ()) { +lis3lv02d_get_xyz (adev.device->handle, &x, &y, &z); +input_report_abs (adev.idev,ABS_X , x - adev.xcalib); +input_report_abs (adev.idev,ABS_Y , y - adev.ycalib); +input_report_abs (adev.idev,ABS_Z , z - adev.zcalib); + +input_sync (adev.idev); + +try_to_freeze (); +msleep_interruptible (MDPS_POLL_INTERVAL );
You'll have the powertop police on your tail.
Is there no alternative?
Quoted 4 lines
drivers/hwmon/lis3lv02d.c +4
-0+ } + +return 0 ; +}
Hi!
Thanks for taking the patch...
Quoted 22 lines
Quoted 9 lines
drivers/hwmon/lis3lv02d.c +6
-0+/* joystick device poll interval in milliseconds */ +#define MDPS_POLL_INTERVAL 50 +static int lis3lv02d_joystick_kthread (void *data) +{ +int x, y, z; +drivers/hwmon/lis3lv02d.c line 289
Quoted 10 lines
drivers/hwmon/lis3lv02d.c +10
-0+while (!kthread_should_stop ()) { +lis3lv02d_get_xyz (adev.device->handle, &x, &y, &z); +input_report_abs (adev.idev,ABS_X , x - adev.xcalib); +input_report_abs (adev.idev,ABS_Y , y - adev.ycalib); +input_report_abs (adev.idev,ABS_Z , z - adev.zcalib); + +input_sync (adev.idev); + +try_to_freeze (); +msleep_interruptible (MDPS_POLL_INTERVAL );You'll have the powertop police on your tail.
Quoted 1 line
Is there no alternative?
No, I do not think so. The device is noisy enough that it will "always" generate a change -- even when sittig on the desktop quietly. We could switch to interrupt mode but it would just give us iterrupts at 40Hz.
For harddisk protection it _might_ be possible to do something clever with threshold comparator on the chip, but... we are not even using the comparator for now.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html