Skip to content

Commit 899d90b

Browse files
pmeerwjic23
authored andcommitted
iio: Add INT_TIME (integration time) channel info attribute
Integration time is in seconds; it controls the measurement time and influences the gain of a sensor. There are two typical ways that scaling is implemented in a device: 1) input amplifier, 2) reference to the ADC is changed. These both result in the accuracy of the ADC varying (by applying its sampling over a more relevant range). Integration time is a way of dealing with noise inherent in the analog sensor itself. In the case of a light sensor, a mixture of photon noise and device specific noise. Photon noise is dealt with by either improving the efficiency of the sensor, (more photons actually captured) which is not easily varied dynamically, or by integrating the measurement over a longer time period. Note that this can also be thought of as an averaging of a number of individual samples and is infact sometimes implemented this way. Altering integration time implies that the duration of a measurement changes, a fact the device's user may be interested in. Hence it makes sense to distinguish between integration time and simple scale. In some devices both types of control are present and whilst they will have similar effects on the amplitude of the reading, their effect on the noise of the measurements will differ considerably. Used by adjd_s311, tsl4531, tcs3472 The following drivers have similar controls (and could be adapted): * tsl2563 (integration time is controlled via CALIBSCALE among other things) * tsl2583 (has integration_time device_attr, but driver doesn't use channels yet) * tsl2x7x (has integration_time attr) Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net> Cc: Jon Brenner <jon.brenner@ams.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
1 parent b909459 commit 899d90b

4 files changed

Lines changed: 28 additions & 0 deletions

File tree

‎Documentation/ABI/testing/sysfs-bus-iio‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,3 +811,14 @@ Description:
811811
Writing '1' stores the current device configuration into
812812
on-chip EEPROM. After power-up or chip reset the device will
813813
automatically load the saved configuration.
814+
815+
What: /sys/.../iio:deviceX/in_intensity_red_integration_time
816+
What: /sys/.../iio:deviceX/in_intensity_green_integration_time
817+
What: /sys/.../iio:deviceX/in_intensity_blue_integration_time
818+
What: /sys/.../iio:deviceX/in_intensity_clear_integration_time
819+
What: /sys/.../iio:deviceX/in_illuminance_integration_time
820+
KernelVersion: 3.12
821+
Contact: linux-iio@vger.kernel.org
822+
Description:
823+
This attribute is used to get/set the integration time in
824+
seconds.

‎drivers/iio/industrialio-core.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ static const char * const iio_chan_info_postfix[] = {
101101
[IIO_CHAN_INFO_PHASE] = "phase",
102102
[IIO_CHAN_INFO_HARDWAREGAIN] = "hardwaregain",
103103
[IIO_CHAN_INFO_HYSTERESIS] = "hysteresis",
104+
[IIO_CHAN_INFO_INT_TIME] = "integration_time",
104105
};
105106

106107
const struct iio_chan_spec

‎include/linux/iio/iio.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ enum iio_chan_info_enum {
3636
IIO_CHAN_INFO_PHASE,
3737
IIO_CHAN_INFO_HARDWAREGAIN,
3838
IIO_CHAN_INFO_HYSTERESIS,
39+
IIO_CHAN_INFO_INT_TIME,
3940
};
4041

4142
enum iio_endian {

‎include/linux/iio/sysfs.h‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,21 @@ struct iio_const_attr {
100100
#define IIO_CONST_ATTR_SAMP_FREQ_AVAIL(_string) \
101101
IIO_CONST_ATTR(sampling_frequency_available, _string)
102102

103+
/**
104+
* IIO_DEV_ATTR_INT_TIME_AVAIL - list available integration times
105+
* @_show: output method for the attribute
106+
**/
107+
#define IIO_DEV_ATTR_INT_TIME_AVAIL(_show) \
108+
IIO_DEVICE_ATTR(integration_time_available, S_IRUGO, _show, NULL, 0)
109+
/**
110+
* IIO_CONST_ATTR_INT_TIME_AVAIL - list available integration times
111+
* @_string: frequency string for the attribute
112+
*
113+
* Constant version
114+
**/
115+
#define IIO_CONST_ATTR_INT_TIME_AVAIL(_string) \
116+
IIO_CONST_ATTR(integration_time_available, _string)
117+
103118
#define IIO_DEV_ATTR_TEMP_RAW(_show) \
104119
IIO_DEVICE_ATTR(in_temp_raw, S_IRUGO, _show, NULL, 0)
105120

0 commit comments

Comments
 (0)