aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lis3lv02d.h
diff options
context:
space:
mode:
authorSamu Onkalo <samu.p.onkalo@nokia.com>2009-12-14 21:01:46 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-15 11:53:36 -0500
commit32496c76b777752ba84b125bebfb0cc498f5602c (patch)
tree199a2e71fca6e19c5b7075965856a8934c7b9db6 /drivers/hwmon/lis3lv02d.h
parenta253aaef60a37bddfa84846353edeb62a6acf5b3 (diff)
lis3: scale output values to mg
Report output values as 1/1000 of earth gravity. Output values from lis3 can be read from sysfs position entry and from input device. Input device can be accessed as event device and as joystick device. Joystick device can be in two modes. Meaning of the output values varies from case to case depending on the chip type and configuration (scale). Only joystick interface in JS_CORR_BROKEN mode returned somehow similar output values in different configurations. Joystick device is in that state by default in case of lis3. Position sysfs entry, input event device and raw joystick device have been little bit broken since meaning of the output values has been varied between 12 and 8 bit devices. Applications which relayed on those methods failed if the chip is different than the expected one. This patch converts output values to mean similar thing in different configurations. Both 8 and 12 bit devices reports now same acceleration values. If somebody implements full scale support to the driver, output values will still mean the same. Scaling factor and input device range must be updated in that case. Joystick interface in JS_CORR_BROKEN mode is not touched by this patch. All other interfaces have different scale after this change. For 12 bit device scaling factor is 0.977 which keeps scaled and unscaled values are quite close to each others. For 8 bit device, scaled values are 18 times bigger than unscaled values. Signed-off-by: Samu Onkalo <samu.p.onkalo@nokia.com> Acked-by: Éric Piel <Eric.Piel@tremplin-utc.net> Cc: Pavel Machek <pavel@ucw.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/hwmon/lis3lv02d.h')
-rw-r--r--drivers/hwmon/lis3lv02d.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/hwmon/lis3lv02d.h b/drivers/hwmon/lis3lv02d.h
index f73c78603732..e6a01f44709b 100644
--- a/drivers/hwmon/lis3lv02d.h
+++ b/drivers/hwmon/lis3lv02d.h
@@ -214,6 +214,10 @@ struct lis3lv02d {
214 s16 (*read_data) (struct lis3lv02d *lis3, int reg); 214 s16 (*read_data) (struct lis3lv02d *lis3, int reg);
215 int mdps_max_val; 215 int mdps_max_val;
216 int pwron_delay; 216 int pwron_delay;
217 int scale; /*
218 * relationship between 1 LBS and mG
219 * (1/1000th of earth gravity)
220 */
217 221
218 struct input_polled_dev *idev; /* input device */ 222 struct input_polled_dev *idev; /* input device */
219 struct platform_device *pdev; /* platform device */ 223 struct platform_device *pdev; /* platform device */