iio:core: timestamping clock selection support
Adds a new per-device sysfs attribute "current_timestamp_clock" to allow userspace to select a particular POSIX clock for buffered samples and events timestamping. Following clocks, as listed in clock_gettime(2), are supported: CLOCK_REALTIME, CLOCK_MONOTONIC, CLOCK_MONOTONIC_RAW, CLOCK_REALTIME_COARSE, CLOCK_MONOTONIC_COARSE, CLOCK_BOOTTIME and CLOCK_TAI. Signed-off-by: Gregor Boirie <gregor.boirie@parrot.com> Acked-by: Sanchayan Maity <maitysanchayan@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:

committed by
Jonathan Cameron

parent
eaaa7ec71b
commit
bc2b7dab62
@@ -312,13 +312,8 @@ static inline bool iio_channel_has_info(const struct iio_chan_spec *chan,
|
||||
}, \
|
||||
}
|
||||
|
||||
/**
|
||||
* iio_get_time_ns() - utility function to get a time stamp for events etc
|
||||
**/
|
||||
static inline s64 iio_get_time_ns(void)
|
||||
{
|
||||
return ktime_get_real_ns();
|
||||
}
|
||||
s64 iio_get_time_ns(const struct iio_dev *indio_dev);
|
||||
unsigned int iio_get_time_res(const struct iio_dev *indio_dev);
|
||||
|
||||
/* Device operating modes */
|
||||
#define INDIO_DIRECT_MODE 0x01
|
||||
@@ -497,6 +492,7 @@ struct iio_buffer_setup_ops {
|
||||
* @chan_attr_group: [INTERN] group for all attrs in base directory
|
||||
* @name: [DRIVER] name of the device.
|
||||
* @info: [DRIVER] callbacks and constant info from driver
|
||||
* @clock_id: [INTERN] timestamping clock posix identifier
|
||||
* @info_exist_lock: [INTERN] lock to prevent use during removal
|
||||
* @setup_ops: [DRIVER] callbacks to call before and after buffer
|
||||
* enable/disable
|
||||
@@ -537,6 +533,7 @@ struct iio_dev {
|
||||
struct attribute_group chan_attr_group;
|
||||
const char *name;
|
||||
const struct iio_info *info;
|
||||
clockid_t clock_id;
|
||||
struct mutex info_exist_lock;
|
||||
const struct iio_buffer_setup_ops *setup_ops;
|
||||
struct cdev chrdev;
|
||||
@@ -565,7 +562,7 @@ extern struct bus_type iio_bus_type;
|
||||
|
||||
/**
|
||||
* iio_device_put() - reference counted deallocation of struct device
|
||||
* @indio_dev: IIO device structure containing the device
|
||||
* @indio_dev: IIO device structure containing the device
|
||||
**/
|
||||
static inline void iio_device_put(struct iio_dev *indio_dev)
|
||||
{
|
||||
@@ -573,6 +570,15 @@ static inline void iio_device_put(struct iio_dev *indio_dev)
|
||||
put_device(&indio_dev->dev);
|
||||
}
|
||||
|
||||
/**
|
||||
* iio_device_get_clock() - Retrieve current timestamping clock for the device
|
||||
* @indio_dev: IIO device structure containing the device
|
||||
*/
|
||||
static inline clockid_t iio_device_get_clock(const struct iio_dev *indio_dev)
|
||||
{
|
||||
return indio_dev->clock_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* dev_to_iio_dev() - Get IIO device struct from a device struct
|
||||
* @dev: The device embedded in the IIO device
|
||||
|
Reference in New Issue
Block a user