mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-29 23:53:55 +08:00
899d90bdf4
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>
128 lines
3.9 KiB
C
128 lines
3.9 KiB
C
/* The industrial I/O core
|
|
*
|
|
*Copyright (c) 2008 Jonathan Cameron
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License version 2 as published by
|
|
* the Free Software Foundation.
|
|
*
|
|
* General attributes
|
|
*/
|
|
|
|
#ifndef _INDUSTRIAL_IO_SYSFS_H_
|
|
#define _INDUSTRIAL_IO_SYSFS_H_
|
|
|
|
struct iio_chan_spec;
|
|
|
|
/**
|
|
* struct iio_dev_attr - iio specific device attribute
|
|
* @dev_attr: underlying device attribute
|
|
* @address: associated register address
|
|
* @l: list head for maintaining list of dynamically created attrs.
|
|
*/
|
|
struct iio_dev_attr {
|
|
struct device_attribute dev_attr;
|
|
u64 address;
|
|
struct list_head l;
|
|
struct iio_chan_spec const *c;
|
|
};
|
|
|
|
#define to_iio_dev_attr(_dev_attr) \
|
|
container_of(_dev_attr, struct iio_dev_attr, dev_attr)
|
|
|
|
ssize_t iio_read_const_attr(struct device *dev,
|
|
struct device_attribute *attr,
|
|
char *len);
|
|
|
|
/**
|
|
* struct iio_const_attr - constant device specific attribute
|
|
* often used for things like available modes
|
|
* @string: attribute string
|
|
* @dev_attr: underlying device attribute
|
|
*/
|
|
struct iio_const_attr {
|
|
const char *string;
|
|
struct device_attribute dev_attr;
|
|
};
|
|
|
|
#define to_iio_const_attr(_dev_attr) \
|
|
container_of(_dev_attr, struct iio_const_attr, dev_attr)
|
|
|
|
/* Some attributes will be hard coded (device dependent) and not require an
|
|
address, in these cases pass a negative */
|
|
#define IIO_ATTR(_name, _mode, _show, _store, _addr) \
|
|
{ .dev_attr = __ATTR(_name, _mode, _show, _store), \
|
|
.address = _addr }
|
|
|
|
#define IIO_DEVICE_ATTR(_name, _mode, _show, _store, _addr) \
|
|
struct iio_dev_attr iio_dev_attr_##_name \
|
|
= IIO_ATTR(_name, _mode, _show, _store, _addr)
|
|
|
|
#define IIO_DEVICE_ATTR_NAMED(_vname, _name, _mode, _show, _store, _addr) \
|
|
struct iio_dev_attr iio_dev_attr_##_vname \
|
|
= IIO_ATTR(_name, _mode, _show, _store, _addr)
|
|
|
|
#define IIO_CONST_ATTR(_name, _string) \
|
|
struct iio_const_attr iio_const_attr_##_name \
|
|
= { .string = _string, \
|
|
.dev_attr = __ATTR(_name, S_IRUGO, iio_read_const_attr, NULL)}
|
|
|
|
#define IIO_CONST_ATTR_NAMED(_vname, _name, _string) \
|
|
struct iio_const_attr iio_const_attr_##_vname \
|
|
= { .string = _string, \
|
|
.dev_attr = __ATTR(_name, S_IRUGO, iio_read_const_attr, NULL)}
|
|
|
|
/* Generic attributes of onetype or another */
|
|
|
|
/**
|
|
* IIO_DEV_ATTR_SAMP_FREQ - sets any internal clock frequency
|
|
* @_mode: sysfs file mode/permissions
|
|
* @_show: output method for the attribute
|
|
* @_store: input method for the attribute
|
|
**/
|
|
#define IIO_DEV_ATTR_SAMP_FREQ(_mode, _show, _store) \
|
|
IIO_DEVICE_ATTR(sampling_frequency, _mode, _show, _store, 0)
|
|
|
|
/**
|
|
* IIO_DEV_ATTR_SAMP_FREQ_AVAIL - list available sampling frequencies
|
|
* @_show: output method for the attribute
|
|
*
|
|
* May be mode dependent on some devices
|
|
**/
|
|
#define IIO_DEV_ATTR_SAMP_FREQ_AVAIL(_show) \
|
|
IIO_DEVICE_ATTR(sampling_frequency_available, S_IRUGO, _show, NULL, 0)
|
|
/**
|
|
* IIO_CONST_ATTR_SAMP_FREQ_AVAIL - list available sampling frequencies
|
|
* @_string: frequency string for the attribute
|
|
*
|
|
* Constant version
|
|
**/
|
|
#define IIO_CONST_ATTR_SAMP_FREQ_AVAIL(_string) \
|
|
IIO_CONST_ATTR(sampling_frequency_available, _string)
|
|
|
|
/**
|
|
* IIO_DEV_ATTR_INT_TIME_AVAIL - list available integration times
|
|
* @_show: output method for the attribute
|
|
**/
|
|
#define IIO_DEV_ATTR_INT_TIME_AVAIL(_show) \
|
|
IIO_DEVICE_ATTR(integration_time_available, S_IRUGO, _show, NULL, 0)
|
|
/**
|
|
* IIO_CONST_ATTR_INT_TIME_AVAIL - list available integration times
|
|
* @_string: frequency string for the attribute
|
|
*
|
|
* Constant version
|
|
**/
|
|
#define IIO_CONST_ATTR_INT_TIME_AVAIL(_string) \
|
|
IIO_CONST_ATTR(integration_time_available, _string)
|
|
|
|
#define IIO_DEV_ATTR_TEMP_RAW(_show) \
|
|
IIO_DEVICE_ATTR(in_temp_raw, S_IRUGO, _show, NULL, 0)
|
|
|
|
#define IIO_CONST_ATTR_TEMP_OFFSET(_string) \
|
|
IIO_CONST_ATTR(in_temp_offset, _string)
|
|
|
|
#define IIO_CONST_ATTR_TEMP_SCALE(_string) \
|
|
IIO_CONST_ATTR(in_temp_scale, _string)
|
|
|
|
#endif /* _INDUSTRIAL_IO_SYSFS_H_ */
|