summaryrefslogtreecommitdiffstats
path: root/tools
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 /tools
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 'tools')
-rw-r--r--tools/testlibraw.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/tools/testlibraw.c b/tools/testlibraw.c
index 8fe8b26..b322a5d 100644
--- a/tools/testlibraw.c
+++ b/tools/testlibraw.c
@@ -194,12 +194,33 @@ read_cycle_timer(raw1394handle_t handle)
perror("\n - raw1394_read_cycle_timer failed with error");
return;
}
-
printf("\n - cycle timer: %d seconds, %d cycles, %d sub-cycles\n",
ct >> 25, (ct >> 12) & 0x1fff, ct & 0xfff);
seconds = local_time / 1000000;
- printf(" local time: %lld us = %s",
+ printf(" local time from CLOCK_REALTIME: %lld us = %s",
(unsigned long long)local_time, ctime(&seconds));
+
+ retval = raw1394_read_cycle_timer_and_clock(handle, &ct, &local_time,
+ CLOCK_MONOTONIC);
+ if (retval < 0) {
+ perror("\n raw1394_read_cycle_timer_and_clock failed with error");
+ return;
+ }
+ printf(" cycle timer: %d seconds, %d cycles, %d sub-cycles\n",
+ ct >> 25, (ct >> 12) & 0x1fff, ct & 0xfff);
+ printf(" local time from CLOCK_MONOTONIC: %lld us\n",
+ (unsigned long long)local_time);
+
+ retval = raw1394_read_cycle_timer_and_clock(handle, &ct, &local_time,
+ CLOCK_MONOTONIC_RAW);
+ if (retval < 0) {
+ perror("\n raw1394_read_cycle_timer_and_clock failed with error");
+ return;
+ }
+ printf(" cycle timer: %d seconds, %d cycles, %d sub-cycles\n",
+ ct >> 25, (ct >> 12) & 0x1fff, ct & 0xfff);
+ printf(" local time from CLOCK_MONOTONIC_RAW: %lld us\n",
+ (unsigned long long)local_time);
}
int test_card(int card)