mirror of
https://github.com/ukui/kernel.git
synced 2026-03-09 10:07:04 -07:00
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
@@ -32,6 +32,13 @@ Description:
|
||||
Description of the physical chip / device for device X.
|
||||
Typically a part number.
|
||||
|
||||
What: /sys/bus/iio/devices/iio:deviceX/timestamp_clock
|
||||
KernelVersion: 4.5
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
String identifying current posix clock used to timestamp
|
||||
buffered samples and events for device X.
|
||||
|
||||
What: /sys/bus/iio/devices/iio:deviceX/sampling_frequency
|
||||
What: /sys/bus/iio/devices/iio:deviceX/buffer/sampling_frequency
|
||||
What: /sys/bus/iio/devices/triggerX/sampling_frequency
|
||||
|
||||
@@ -594,7 +594,7 @@
|
||||
|
||||
irqreturn_t sensor_iio_pollfunc(int irq, void *p)
|
||||
{
|
||||
pf->timestamp = iio_get_time_ns();
|
||||
pf->timestamp = iio_get_time_ns((struct indio_dev *)p);
|
||||
return IRQ_WAKE_THREAD;
|
||||
}
|
||||
|
||||
|
||||
@@ -654,7 +654,7 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p)
|
||||
struct iio_poll_func *pf = p;
|
||||
struct iio_dev *indio_dev = pf->indio_dev;
|
||||
struct bma180_data *data = iio_priv(indio_dev);
|
||||
int64_t time_ns = iio_get_time_ns();
|
||||
s64 time_ns = iio_get_time_ns(indio_dev);
|
||||
int bit, ret, i = 0;
|
||||
|
||||
mutex_lock(&data->mutex);
|
||||
|
||||
@@ -901,7 +901,7 @@ static int __bmc150_accel_fifo_flush(struct iio_dev *indio_dev,
|
||||
*/
|
||||
if (!irq) {
|
||||
data->old_timestamp = data->timestamp;
|
||||
data->timestamp = iio_get_time_ns();
|
||||
data->timestamp = iio_get_time_ns(indio_dev);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1303,7 +1303,7 @@ static irqreturn_t bmc150_accel_irq_handler(int irq, void *private)
|
||||
int i;
|
||||
|
||||
data->old_timestamp = data->timestamp;
|
||||
data->timestamp = iio_get_time_ns();
|
||||
data->timestamp = iio_get_time_ns(indio_dev);
|
||||
|
||||
for (i = 0; i < BMC150_ACCEL_TRIGGERS; i++) {
|
||||
if (data->triggers[i].enabled) {
|
||||
|
||||
@@ -1129,7 +1129,7 @@ static irqreturn_t kxcjk1013_data_rdy_trig_poll(int irq, void *private)
|
||||
struct iio_dev *indio_dev = private;
|
||||
struct kxcjk1013_data *data = iio_priv(indio_dev);
|
||||
|
||||
data->timestamp = iio_get_time_ns();
|
||||
data->timestamp = iio_get_time_ns(indio_dev);
|
||||
|
||||
if (data->dready_trigger_on)
|
||||
iio_trigger_poll(data->dready_trig);
|
||||
|
||||
@@ -97,7 +97,8 @@ static irqreturn_t mma7455_trigger_handler(int irq, void *p)
|
||||
if (ret)
|
||||
goto done;
|
||||
|
||||
iio_push_to_buffers_with_timestamp(indio_dev, buf, iio_get_time_ns());
|
||||
iio_push_to_buffers_with_timestamp(indio_dev, buf,
|
||||
iio_get_time_ns(indio_dev));
|
||||
|
||||
done:
|
||||
iio_trigger_notify_done(indio_dev->trig);
|
||||
|
||||
@@ -917,7 +917,7 @@ static int mma8452_write_event_config(struct iio_dev *indio_dev,
|
||||
static void mma8452_transient_interrupt(struct iio_dev *indio_dev)
|
||||
{
|
||||
struct mma8452_data *data = iio_priv(indio_dev);
|
||||
s64 ts = iio_get_time_ns();
|
||||
s64 ts = iio_get_time_ns(indio_dev);
|
||||
int src;
|
||||
|
||||
src = i2c_smbus_read_byte_data(data->client, data->chip_info->ev_src);
|
||||
@@ -997,7 +997,7 @@ static irqreturn_t mma8452_trigger_handler(int irq, void *p)
|
||||
goto done;
|
||||
|
||||
iio_push_to_buffers_with_timestamp(indio_dev, buffer,
|
||||
iio_get_time_ns());
|
||||
iio_get_time_ns(indio_dev));
|
||||
|
||||
done:
|
||||
iio_trigger_notify_done(indio_dev->trig);
|
||||
|
||||
@@ -391,7 +391,7 @@ static irqreturn_t mma9551_event_handler(int irq, void *private)
|
||||
iio_push_event(indio_dev,
|
||||
IIO_MOD_EVENT_CODE(IIO_INCLI, 0, (mma_axis + 1),
|
||||
IIO_EV_TYPE_ROC, IIO_EV_DIR_RISING),
|
||||
iio_get_time_ns());
|
||||
iio_get_time_ns(indio_dev));
|
||||
|
||||
out:
|
||||
mutex_unlock(&data->mutex);
|
||||
|
||||
@@ -1001,7 +1001,7 @@ static irqreturn_t mma9553_irq_handler(int irq, void *private)
|
||||
struct iio_dev *indio_dev = private;
|
||||
struct mma9553_data *data = iio_priv(indio_dev);
|
||||
|
||||
data->timestamp = iio_get_time_ns();
|
||||
data->timestamp = iio_get_time_ns(indio_dev);
|
||||
/*
|
||||
* Since we only configure the interrupt pin when an
|
||||
* event is enabled, we are sure we have at least
|
||||
|
||||
@@ -115,7 +115,7 @@ static irqreturn_t ad7291_event_handler(int irq, void *private)
|
||||
u16 t_status, v_status;
|
||||
u16 command;
|
||||
int i;
|
||||
s64 timestamp = iio_get_time_ns();
|
||||
s64 timestamp = iio_get_time_ns(indio_dev);
|
||||
|
||||
if (ad7291_i2c_read(chip, AD7291_T_ALERT_STATUS, &t_status))
|
||||
return IRQ_HANDLED;
|
||||
|
||||
@@ -163,7 +163,7 @@ static irqreturn_t ad7298_trigger_handler(int irq, void *p)
|
||||
goto done;
|
||||
|
||||
iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf,
|
||||
iio_get_time_ns());
|
||||
iio_get_time_ns(indio_dev));
|
||||
|
||||
done:
|
||||
iio_trigger_notify_done(indio_dev->trig);
|
||||
|
||||
@@ -70,7 +70,7 @@ static irqreturn_t ad7476_trigger_handler(int irq, void *p)
|
||||
goto done;
|
||||
|
||||
iio_push_to_buffers_with_timestamp(indio_dev, st->data,
|
||||
iio_get_time_ns());
|
||||
iio_get_time_ns(indio_dev));
|
||||
done:
|
||||
iio_trigger_notify_done(indio_dev->trig);
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ static irqreturn_t ad7887_trigger_handler(int irq, void *p)
|
||||
goto done;
|
||||
|
||||
iio_push_to_buffers_with_timestamp(indio_dev, st->data,
|
||||
iio_get_time_ns());
|
||||
iio_get_time_ns(indio_dev));
|
||||
done:
|
||||
iio_trigger_notify_done(indio_dev->trig);
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ static irqreturn_t ad7923_trigger_handler(int irq, void *p)
|
||||
goto done;
|
||||
|
||||
iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf,
|
||||
iio_get_time_ns());
|
||||
iio_get_time_ns(indio_dev));
|
||||
|
||||
done:
|
||||
iio_trigger_notify_done(indio_dev->trig);
|
||||
|
||||
@@ -212,7 +212,7 @@ static irqreturn_t ad799x_trigger_handler(int irq, void *p)
|
||||
goto out;
|
||||
|
||||
iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf,
|
||||
iio_get_time_ns());
|
||||
iio_get_time_ns(indio_dev));
|
||||
out:
|
||||
iio_trigger_notify_done(indio_dev->trig);
|
||||
|
||||
@@ -502,7 +502,7 @@ static irqreturn_t ad799x_event_handler(int irq, void *private)
|
||||
(i >> 1),
|
||||
IIO_EV_TYPE_THRESH,
|
||||
IIO_EV_DIR_FALLING),
|
||||
iio_get_time_ns());
|
||||
iio_get_time_ns(indio_dev));
|
||||
}
|
||||
|
||||
done:
|
||||
|
||||
@@ -186,7 +186,7 @@ done:
|
||||
|
||||
if (!sample_invalid)
|
||||
iio_push_to_buffers_with_timestamp(indio_dev, data,
|
||||
iio_get_time_ns());
|
||||
iio_get_time_ns(indio_dev));
|
||||
iio_trigger_notify_done(indio_dev->trig);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
|
||||
@@ -400,7 +400,7 @@ static void hi8435_iio_push_event(struct iio_dev *idev, unsigned int val)
|
||||
iio_push_event(idev,
|
||||
IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, i,
|
||||
IIO_EV_TYPE_THRESH, dir),
|
||||
iio_get_time_ns());
|
||||
iio_get_time_ns(idev));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -465,7 +465,7 @@ static int ina2xx_work_buffer(struct iio_dev *indio_dev)
|
||||
s64 time_a, time_b;
|
||||
unsigned int alert;
|
||||
|
||||
time_a = iio_get_time_ns();
|
||||
time_a = iio_get_time_ns(indio_dev);
|
||||
|
||||
/*
|
||||
* Because the timer thread and the chip conversion clock
|
||||
@@ -504,7 +504,7 @@ static int ina2xx_work_buffer(struct iio_dev *indio_dev)
|
||||
data[i++] = val;
|
||||
}
|
||||
|
||||
time_b = iio_get_time_ns();
|
||||
time_b = iio_get_time_ns(indio_dev);
|
||||
|
||||
iio_push_to_buffers_with_timestamp(indio_dev,
|
||||
(unsigned int *)data, time_a);
|
||||
@@ -554,7 +554,7 @@ static int ina2xx_buffer_enable(struct iio_dev *indio_dev)
|
||||
dev_dbg(&indio_dev->dev, "Async readout mode: %d\n",
|
||||
chip->allow_async_readout);
|
||||
|
||||
chip->prev_ns = iio_get_time_ns();
|
||||
chip->prev_ns = iio_get_time_ns(indio_dev);
|
||||
|
||||
chip->task = kthread_run(ina2xx_capture_thread, (void *)indio_dev,
|
||||
"%s:%d-%uus", indio_dev->name, indio_dev->id,
|
||||
|
||||
@@ -788,7 +788,7 @@ static irqreturn_t max1363_event_handler(int irq, void *private)
|
||||
{
|
||||
struct iio_dev *indio_dev = private;
|
||||
struct max1363_state *st = iio_priv(indio_dev);
|
||||
s64 timestamp = iio_get_time_ns();
|
||||
s64 timestamp = iio_get_time_ns(indio_dev);
|
||||
unsigned long mask, loc;
|
||||
u8 rx;
|
||||
u8 tx[2] = { st->setupbyte,
|
||||
@@ -1506,7 +1506,8 @@ static irqreturn_t max1363_trigger_handler(int irq, void *p)
|
||||
if (b_sent < 0)
|
||||
goto done_free;
|
||||
|
||||
iio_push_to_buffers_with_timestamp(indio_dev, rxbuf, iio_get_time_ns());
|
||||
iio_push_to_buffers_with_timestamp(indio_dev, rxbuf,
|
||||
iio_get_time_ns(indio_dev));
|
||||
|
||||
done_free:
|
||||
kfree(rxbuf);
|
||||
|
||||
@@ -139,7 +139,8 @@ static irqreturn_t adc081c_trigger_handler(int irq, void *p)
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
buf[0] = ret;
|
||||
iio_push_to_buffers_with_timestamp(indio_dev, buf, iio_get_time_ns());
|
||||
iio_push_to_buffers_with_timestamp(indio_dev, buf,
|
||||
iio_get_time_ns(indio_dev));
|
||||
out:
|
||||
iio_trigger_notify_done(indio_dev->trig);
|
||||
return IRQ_HANDLED;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user