Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: bu27034: Add a read only HARDWAREGAIN

The ROHM BU27034 light sensor has two data channels for measuring
different frequencies of light. The result from these channels is
combined into Lux value while the raw channel values are reported via
intensity channels.

Both of the intensity channels have adjustable gain setting which
impacts the scale of the raw channels. Eg, doubling the gain will double
the values read from the raw channels, which halves the scale value. The
integration time can also be set for the sensor. This does also have an
impact to the scale of the intensity channels because increasing the
integration time will also increase the values reported via the raw
channels.

Impact of integration time to the scale and the fact that the scale value
does not start from '1', can make it hard for a human reader to compute the
gain values based on the scale.

Add read-only HARDWAREGAIN to help debugging.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/ec349847cc994f3bd632e99b408a31e7c70581d0.1720176341.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Matti Vaittinen and committed by
Jonathan Cameron
06342d3f eb13959e

+14 -1
+14 -1
drivers/iio/light/rohm-bu27034.c
··· 148 148 .type = IIO_INTENSITY, \ 149 149 .channel = BU27034_CHAN_##_name, \ 150 150 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ 151 - BIT(IIO_CHAN_INFO_SCALE), \ 151 + BIT(IIO_CHAN_INFO_SCALE) | \ 152 + BIT(IIO_CHAN_INFO_HARDWAREGAIN), \ 152 153 .info_mask_separate_available = BIT(IIO_CHAN_INFO_SCALE), \ 153 154 .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME), \ 154 155 .info_mask_shared_by_all_available = \ ··· 990 989 991 990 return IIO_VAL_INT_PLUS_MICRO; 992 991 992 + case IIO_CHAN_INFO_HARDWAREGAIN: 993 + ret = bu27034_get_gain(data, chan->channel, val); 994 + if (ret) 995 + return ret; 996 + 997 + return IIO_VAL_INT; 998 + 993 999 case IIO_CHAN_INFO_SCALE: 994 1000 return bu27034_get_scale(data, chan->channel, val, val2); 995 1001 ··· 1041 1033 struct iio_chan_spec const *chan, 1042 1034 long mask) 1043 1035 { 1036 + struct bu27034_data *data = iio_priv(indio_dev); 1044 1037 1045 1038 switch (mask) { 1046 1039 case IIO_CHAN_INFO_SCALE: 1047 1040 return IIO_VAL_INT_PLUS_NANO; 1048 1041 case IIO_CHAN_INFO_INT_TIME: 1049 1042 return IIO_VAL_INT_PLUS_MICRO; 1043 + case IIO_CHAN_INFO_HARDWAREGAIN: 1044 + dev_dbg(data->dev, 1045 + "HARDWAREGAIN is read-only, use scale to set\n"); 1046 + return -EINVAL; 1050 1047 default: 1051 1048 return -EINVAL; 1052 1049 }