From: Andrey Panin on
On 286, 10 13, 2006 at 10:47:15 +0200, Burman Yan wrote:
> Hi, all.
>
> I'm new to the list so forgive me in advance for any netiquette mistakes I
> make.
>
> I wrote a driver for the accelerometer chip on HP nc6400 laptop (I think
> the same chip is present on
> other NCxxxx models). This driver uses ACPI interface present in the bios
> and behaves pretty much like
> hdaps. This is a fully functional version - tested on 2.6.17 and 2.6.18
> (not 2.6.19-rc1 since I have a
> problem with that kernel on my laptop). It applies on 2.6.19-rc1 as well
> though. I would like your
> remarks and suggestions on this. Also, should I mail this patch to a kernel
> maintainer? I could not find a maintainer that looks like the address for
> this patch. The closest one is the lm_sensors maintainer, but
> that's probably wrong.

Some comments:

1. Use hard tabs instead of 8 spaces;
2. C++ comments are tolerated, but not welcomed;
3. You missed Signed-off-by: line.


diff -Nrubp linux-2.6.18.orig/drivers/hwmon/Kconfig linux-2.6.18.mdps/drivers/hwmon/Kconfig
--- linux-2.6.18.orig/drivers/hwmon/Kconfig 2006-10-11 14:20:08.000000000 +0200
+++ linux-2.6.18.mdps/drivers/hwmon/Kconfig 2006-10-13 08:52:42.000000000 +0200
@@ -507,6 +507,22 @@ config SENSORS_HDAPS
Say Y here if you have an applicable laptop and want to experience
the awesome power of hdaps.

+config SENSORS_MDPS
+ tristate "HP Mobile Data Protection System 3D (mdps)"
+ depends on ACPI && HWMON && INPUT && X86
+ default n
+ help
+ This driver provides support for the HP Mobile Data Protection
+ System 3D (mdps), which is an accelerometer. Only HP nc6400 is supported
+ right now, but it may work on other models as well. The
+ accelerometer data is readable via /proc/drivers/mdps.
+
+ 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 mdps.
+
config HWMON_DEBUG_CHIP
bool "Hardware Monitoring Chip debugging messages"
depends on HWMON
diff -Nrubp linux-2.6.18.orig/drivers/hwmon/Makefile linux-2.6.18.mdps/drivers/hwmon/Makefile
--- linux-2.6.18.orig/drivers/hwmon/Makefile 2006-10-11 14:20:08.000000000 +0200
+++ linux-2.6.18.mdps/drivers/hwmon/Makefile 2006-10-13 10:14:10.000000000 +0200
@@ -26,6 +26,7 @@ obj-$(CONFIG_SENSORS_FSCPOS) += fscpos.o
obj-$(CONFIG_SENSORS_GL518SM) += gl518sm.o
obj-$(CONFIG_SENSORS_GL520SM) += gl520sm.o
obj-$(CONFIG_SENSORS_HDAPS) += hdaps.o
+obj-$(CONFIG_SENSORS_MDPS) += mdps.o
obj-$(CONFIG_SENSORS_IT87) += it87.o
obj-$(CONFIG_SENSORS_LM63) += lm63.o
obj-$(CONFIG_SENSORS_LM70) += lm70.o
diff -Nrubp linux-2.6.18.orig/drivers/hwmon/mdps.c linux-2.6.18.mdps/drivers/hwmon/mdps.c
--- linux-2.6.18.orig/drivers/hwmon/mdps.c 1970-01-01 02:00:00.000000000 +0200
+++ linux-2.6.18.mdps/drivers/hwmon/mdps.c 2006-10-13 10:13:49.000000000 +0200
@@ -0,0 +1,700 @@
+/*
+ * mdps.c - HP Mobile Data Protection System 3D ACPI driver
+ *
+ * Copyright (C) 2006 Yan Burman
+ *
+ * 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/init.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+#include <linux/input.h>
+#include <linux/kthread.h>
+#include <linux/delay.h>
+
+#include <acpi/acpi_drivers.h>
+#include <acpi/acnamesp.h>
+
+#include <asm/uaccess.h>
+
+#define VERSION "0.1"
+
+MODULE_DESCRIPTION("HP three-axis digital accelerometer ACPI driver");
+MODULE_AUTHOR("Yan Burman (yan_952(a)hotmail.com)");
+MODULE_VERSION(VERSION);
+MODULE_LICENSE("GPL");
+
+#define DRIVER_NAME "mdps"
+#define ACPI_MDPS_CLASS "accelerometer"
+#define ACPI_MDPS_ID "HPQ0004"
+
+#define MDPS_PROC_ROOT "driver/mdps"
+
+// The actual chip is STMicroelectronics LIS3LV02DL or LIS3LV02DQ
+
+#define MDPS_WHO_AM_I 0x0F //r 00111010
+#define MDPS_OFFSET_X 0x16 //rw
+#define MDPS_OFFSET_Y 0x17 //rw
+#define MDPS_OFFSET_Z 0x18 //rw
+#define MDPS_GAIN_X 0x19 //rw
+#define MDPS_GAIN_Y 0x1A //rw
+#define MDPS_GAIN_Z 0x1B //rw
+#define MDPS_CTRL_REG1 0x20 //rw 00000111
+#define MDPS_CTRL_REG2 0x21 //rw 00000000
+#define MDPS_CTRL_REG3 0x22 //rw 00001000
+#define MDPS_HP_FILTER RESET 0x23 //r
+#define MDPS_STATUS_REG 0x27 //rw 00000000
+#define MDPS_OUTX_L 0x28 //r
+#define MDPS_OUTX_H 0x29 //r
+#define MDPS_OUTY_L 0x2A //r
+#define MDPS_OUTY_H 0x2B //r
+#define MDPS_OUTZ_L 0x2C //r
+#define MDPS_OUTZ_H 0x2D //r
+#define MDPS_FF_WU_CFG 0x30 //rw 00000000
+#define MDPS_FF_WU_SRC 0x31 //rw 00000000
+#define MDPS_FF_WU_ACK 0x32 //r
+#define MDPS_FF_WU_THS_L 0x34 //rw 00000000
+#define MDPS_FF_WU_THS_H 0x35 //rw 00000000
+#define MDPS_FF_WU_DURATION 0x36 //rw 00000000
+#define MDPS_DD_CFG 0x38 //rw 00000000
+#define MDPS_DD_SRC 0x39 //rw 00000000
+#define MDPS_DD_ACK 0x3A //r
+#define MDPS_DD_THSI_L 0x3C //rw 00000000
+#define MDPS_DD_THSI_H 0x3D //rw 00000000
+#define MDPS_DD_THSE_L 0x3E //rw 00000000
+#define MDPS_DD_THSE_H 0x3F //rw 00000000
+
+#define MDPS_ID 0x3A
+
+// mouse device poll interval in milliseconds
+#define MDPS_POLL_INTERVAL 30
+
+static unsigned int mouse;
+module_param(mouse, bool, 0);
+MODULE_PARM_DESC(mouse, "Enable the input class device on mod
From: Dave Jones on
On Fri, Oct 13, 2006 at 12:06:40PM +0200, Jesper Juhl wrote:

> > + accelerometer data is readable via /proc/drivers/mdps.
>
> I believe it would be better to use sysfs. Procfs is cluttered enough
> as it is and there's not much will to clutter it further.

Better yet, would be to use the same interface the hdaps driver uses
so that userspace written for one accelerometer works with any hardware.
Having to cope with a dozen different drivers who export in different
places is just silly.

Dave

--
http://www.codemonkey.org.uk
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Arjan van de Ven on

> That would probably mean that there is a need for single interface.

yes please

> Making
> all accelerometers
> export to /sys/devices/platform/hdaps sounds wrong to me. It should be a
> neutral place then.

well.... breaking stuff for no reason other than "but it sounds like HIS
name" is I thing bad. Yes the name is unfortunate, but if you can use
the interface... why not? Just because the name isn't perfect everyone
should change over, including keeping compatibility mess etc etc?
That needs a stronger reason than "it sounds like his name" to me...

Now if the interface itself isn't good enough, that's a different matter
of course; but from what I read so far that's not really the case.

Greetings,
Arjan van de Ven

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Alan Cox on
Ar Gwe, 2006-10-13 am 11:50 -0400, ysgrifennodd Dave Jones:
> Better yet, would be to use the same interface the hdaps driver uses
> so that userspace written for one accelerometer works with any hardware.
> Having to cope with a dozen different drivers who export in different
> places is just silly.

Agreed. We already have an interface layer for reporting multiple
dimensions of motion control - the joystick interface. I think we really
ought to use that with some way to spot that its HDAPS etc so drivers
can decide to use it for its intended purpose (eg a different device
name scheme). The joystick compatibility would also mean it can "just
work" if you tell games to use the device.

Alan
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Alan Cox on
Ar Gwe, 2006-10-13 am 20:59 +0200, ysgrifennodd Burman Yan:
> I guess it may be a good idea after all to change the sysfs file it to hdaps
> for now.

Perhaps it would be better to provide a new they all provide which
indicates 2 v 3 dimensions and also provides a scaled data source so
that you don't get confusion or have to adjust the daemon for each user.

If HDAPS is an IBM^WLeonovo mark thats another reason the final generic
file shouldn't be called HDAPS

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/