OSDN Git Service

iio: light: ltrf216a: Add raw attribute
authorShreeya Patel <shreeya.patel@collabora.com>
Fri, 12 Aug 2022 10:04:24 +0000 (15:34 +0530)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Tue, 30 Aug 2022 17:35:38 +0000 (18:35 +0100)
commitf5ffeca5086fef68765f3c1dbc9a12183833adf0
tree2bca064814ab43fdae9f7e9d575015f72145a381
parentc682c96334cb790930c814e58e33d5e0df600a63
iio: light: ltrf216a: Add raw attribute

Add IIO_CHAN_INFO_RAW to the mask to be able to read raw values
from the light sensor.

The userspace code for brightness control in steam deck uses the
in_illuminance_input value through sysfs and multiplies it
with a constant stored in BIOS at factory calibration time.

The downstream driver for LTRF216A that we have been using
has incorrect formula for LUX calculation which we corrected
in the upstreamed driver.

Now to be able to use the upstreamed driver, we need to add some
magic in userspace so that the brightness control works like before
even with the updated LUX formula.

Hence, we need the raw data to calculate a constant that can be
added in userspace code.

Downstream driver LUX formula :-
(greendata*8*LTRF216A_WIN_FAC) / (data->als_gain_fac*data->int_time_fac*10)

Upstreamed driver LUX formula :-
(greendata*45*LTRF216A_WIN_FAC) / (data->als_gain_fac*data->int_time_fac)

greendata is the ALS_DATA which we would like to get through sysfs using
the raw attribute.

Signed-off-by: Shreeya Patel <shreeya.patel@collabora.com>
Link: https://lore.kernel.org/r/20220812100424.529425-1-shreeya.patel@collabora.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/light/ltrf216a.c