summaryrefslogtreecommitdiffstats
path: root/src/fw-iso.c
diff options
context:
space:
mode:
authorGravatar Stefan Richter 2012-06-18 01:19:54 +0200
committerGravatar Stefan Richter 2012-06-18 01:53:32 +0200
commit5b4cffe9d7b515d807874da48c6a149edc37a99b (patch)
tree07aa5bc3df3617e8caeaae59ba2f68fa35e0619e /src/fw-iso.c
parentTweak raw1394_add_config_rom_descriptor() API, add documentation and test case (diff)
Add raw1394_read_cycle_timer_and_clock() API
This is an extension relative to raw1394_read_cycle_timer(). It lets the client choose a system clock other than CLOCK_REALTIME. Use case: http://subversion.ffado.org/ticket/242 The underlying ioctl supports reading the system clock with nanoseconds resolution. The new libraw1394 call sticks with microseconds resolution though. This makes transition from (or parallel use with) raw1394_read_cycle_timer() easier. Besides, the call itself takes longer than a microsecond, primarily due to a costly MMIO read (on many controllers even three or more MMIO reads). Unit tests with CLOCK_MONOTONIC and CLOCK_MONOTONIC_RAW are added to testlibraw as well. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'src/fw-iso.c')
-rw-r--r--src/fw-iso.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/fw-iso.c b/src/fw-iso.c
index 15fa233..9599299 100644
--- a/src/fw-iso.c
+++ b/src/fw-iso.c
@@ -648,8 +648,8 @@ void fw_iso_shutdown(fw_handle_t handle)
handle->iso.fd = -1;
}
-int fw_read_cycle_timer(fw_handle_t handle,
- u_int32_t *cycle_timer, u_int64_t *local_time)
+int fw_read_cycle_timer(fw_handle_t handle, u_int32_t *cycle_timer,
+ u_int64_t *local_time)
{
int err;
struct fw_cdev_get_cycle_timer ctr = { 0 };
@@ -661,3 +661,18 @@ int fw_read_cycle_timer(fw_handle_t handle,
}
return err;
}
+
+int fw_read_cycle_timer_and_clock(fw_handle_t handle, u_int32_t *cycle_timer,
+ u_int64_t *local_time, clockid_t clk_id)
+{
+ int err;
+ struct fw_cdev_get_cycle_timer2 ctr = {.clk_id = clk_id};
+
+ err = ioctl(handle->ioctl_fd, FW_CDEV_IOC_GET_CYCLE_TIMER2, &ctr);
+ if (!err) {
+ *cycle_timer = ctr.cycle_timer;
+ *local_time = ctr.tv_sec * 1000000ULL +
+ ctr.tv_nsec / 1000;
+ }
+ return err;
+}