• Samu Onkalo's avatar
    lis3: scale output values to mg · 32496c76
    Samu Onkalo authored
    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: default avatarSamu Onkalo <samu.p.onkalo@nokia.com>
    Acked-by: default avatarÉric Piel <Eric.Piel@tremplin-utc.net>
    Cc: Pavel Machek <pavel@ucw.cz>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    32496c76
lis3lv02d.c 16 KB