aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/hp_accel.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2010-10-01 17:14:25 -0400
committerGuenter Roeck <guenter.roeck@ericsson.com>2010-10-25 17:11:20 -0400
commit2ee321440e3a594dcdd9981e68e5e302447047a2 (patch)
treec2dde23d160339ff713f9fd12f7922cca0c8c6d3 /drivers/hwmon/hp_accel.c
parent37394050b5be0fe87f96ed8848f11c3c2cd4d556 (diff)
hwmon: (lis3) add axes module parameter for custom axis-mapping
The axis-mapping of lis3dev device on many (rather most) HP machines doesn't follow the standard. When each new model appears, users need to adjust again. Testing this requires the rebuild of kernel, thus it's not trivial for end-users. This patch adds a module parameter "axes" to allow a custom axis-mapping without patching and recompiling the kernel driver. User can pass the parameter such as axes=3,2,1. Also it can be changed via sysfs. Signed-off-by: Takashi Iwai <tiwai@suse.de> Acked-by: Eric Piel <eric.piel@tremplin-utc.net> Cc: Jean Delvare <khali@linux-fr.org> Cc: Guenter Roeck <guenter.roeck@ericsson.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Diffstat (limited to 'drivers/hwmon/hp_accel.c')
-rw-r--r--drivers/hwmon/hp_accel.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/drivers/hwmon/hp_accel.c b/drivers/hwmon/hp_accel.c
index c5cd3db78c9..a56a78412fc 100644
--- a/drivers/hwmon/hp_accel.c
+++ b/drivers/hwmon/hp_accel.c
@@ -146,7 +146,7 @@ int lis3lv02d_acpi_write(struct lis3lv02d *lis3, int reg, u8 val)
146 146
147static int lis3lv02d_dmi_matched(const struct dmi_system_id *dmi) 147static int lis3lv02d_dmi_matched(const struct dmi_system_id *dmi)
148{ 148{
149 lis3_dev.ac = *((struct axis_conversion *)dmi->driver_data); 149 lis3_dev.ac = *((union axis_conversion *)dmi->driver_data);
150 printk(KERN_INFO DRIVER_NAME ": hardware type %s found.\n", dmi->ident); 150 printk(KERN_INFO DRIVER_NAME ": hardware type %s found.\n", dmi->ident);
151 151
152 return 1; 152 return 1;
@@ -154,16 +154,19 @@ static int lis3lv02d_dmi_matched(const struct dmi_system_id *dmi)
154 154
155/* Represents, for each axis seen by userspace, the corresponding hw axis (+1). 155/* Represents, for each axis seen by userspace, the corresponding hw axis (+1).
156 * If the value is negative, the opposite of the hw value is used. */ 156 * If the value is negative, the opposite of the hw value is used. */
157static struct axis_conversion lis3lv02d_axis_normal = {1, 2, 3}; 157#define DEFINE_CONV(name, x, y, z) \
158static struct axis_conversion lis3lv02d_axis_y_inverted = {1, -2, 3}; 158 static union axis_conversion lis3lv02d_axis_##name = \
159static struct axis_conversion lis3lv02d_axis_x_inverted = {-1, 2, 3}; 159 { .as_array = { x, y, z } }
160static struct axis_conversion lis3lv02d_axis_z_inverted = {1, 2, -3}; 160DEFINE_CONV(normal, 1, 2, 3);
161static struct axis_conversion lis3lv02d_axis_xy_swap = {2, 1, 3}; 161DEFINE_CONV(y_inverted, 1, -2, 3);
162static struct axis_conversion lis3lv02d_axis_xy_rotated_left = {-2, 1, 3}; 162DEFINE_CONV(x_inverted, -1, 2, 3);
163static struct axis_conversion lis3lv02d_axis_xy_rotated_left_usd = {-2, 1, -3}; 163DEFINE_CONV(z_inverted, 1, 2, -3);
164static struct axis_conversion lis3lv02d_axis_xy_swap_inverted = {-2, -1, 3}; 164DEFINE_CONV(xy_swap, 2, 1, 3);
165static struct axis_conversion lis3lv02d_axis_xy_rotated_right = {2, -1, 3}; 165DEFINE_CONV(xy_rotated_left, -2, 1, 3);
166static struct axis_conversion lis3lv02d_axis_xy_swap_yz_inverted = {2, -1, -3}; 166DEFINE_CONV(xy_rotated_left_usd, -2, 1, -3);
167DEFINE_CONV(xy_swap_inverted, -2, -1, 3);
168DEFINE_CONV(xy_rotated_right, 2, -1, 3);
169DEFINE_CONV(xy_swap_yz_inverted, 2, -1, -3);
167 170
168#define AXIS_DMI_MATCH(_ident, _name, _axis) { \ 171#define AXIS_DMI_MATCH(_ident, _name, _axis) { \
169 .ident = _ident, \ 172 .ident = _ident, \
@@ -299,7 +302,10 @@ static int lis3lv02d_add(struct acpi_device *device)
299 lis3lv02d_enum_resources(device); 302 lis3lv02d_enum_resources(device);
300 303
301 /* If possible use a "standard" axes order */ 304 /* If possible use a "standard" axes order */
302 if (dmi_check_system(lis3lv02d_dmi_ids) == 0) { 305 if (lis3_dev.ac.x && lis3_dev.ac.y && lis3_dev.ac.z) {
306 printk(KERN_INFO DRIVER_NAME ": Using custom axes %d,%d,%d\n",
307 lis3_dev.ac.x, lis3_dev.ac.y, lis3_dev.ac.z);
308 } else if (dmi_check_system(lis3lv02d_dmi_ids) == 0) {
303 printk(KERN_INFO DRIVER_NAME ": laptop model unknown, " 309 printk(KERN_INFO DRIVER_NAME ": laptop model unknown, "
304 "using default axes configuration\n"); 310 "using default axes configuration\n");
305 lis3_dev.ac = lis3lv02d_axis_normal; 311 lis3_dev.ac = lis3lv02d_axis_normal;