From 32496c76b777752ba84b125bebfb0cc498f5602c Mon Sep 17 00:00:00 2001 From: Samu Onkalo Date: Mon, 14 Dec 2009 18:01:46 -0800 Subject: lis3: scale output values to mg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Acked-by: Éric Piel Cc: Pavel Machek Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/hwmon/lis3lv02d.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/hwmon/lis3lv02d.h') diff --git a/drivers/hwmon/lis3lv02d.h b/drivers/hwmon/lis3lv02d.h index f73c7860373..e6a01f44709 100644 --- a/drivers/hwmon/lis3lv02d.h +++ b/drivers/hwmon/lis3lv02d.h @@ -214,6 +214,10 @@ struct lis3lv02d { s16 (*read_data) (struct lis3lv02d *lis3, int reg); int mdps_max_val; int pwron_delay; + int scale; /* + * relationship between 1 LBS and mG + * (1/1000th of earth gravity) + */ struct input_polled_dev *idev; /* input device */ struct platform_device *pdev; /* platform device */ -- cgit v1.2.3-70-g09d2