aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2009-01-11 22:46:48 +0100
committerStefan Richter <stefanr@s5r6.in-berlin.de>2009-05-30 10:17:43 +0200
commit49dda1ef90ab1c8b57634a06a35bbbacbe17604e (patch)
tree7f5c21d1baf0c54272bd9751189ae7c306146c45
parentc58e16442b16f85d76808209c4aa7c37adc62de4 (diff)
downloadlibraw1394-49dda1ef90ab1c8b57634a06a35bbbacbe17604e.tar.gz
Iso reception: Use packet timestamps in juju ABI v2
In the firewire-cdev ABI v1, the kernel exported only the timestamp of interrupt packets. libraw1394 estimated the cycle of all packets between interrupt packets by continuously incrementing the cycle. In v2 of the ABI, we can obtain an accurate timestamp of each packet as provided by the OHCI controller. AFAIU, this is also what you got from raw1394/ ohci1394. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
-rw-r--r--src/fw-iso.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/fw-iso.c b/src/fw-iso.c
index e7618b5..e49ad3d 100644
--- a/src/fw-iso.c
+++ b/src/fw-iso.c
@@ -141,12 +141,17 @@ int fw_iso_xmit_start(raw1394handle_t handle, int start_on_cycle,
return 0;
}
+static inline int recv_header_length(fw_handle_t handle)
+{
+ return handle->abi_version >= 2 ? 8 : 4;
+}
+
static int
queue_recv_packets(fw_handle_t handle)
{
while (handle->iso.packet_count <= handle->iso.buf_packets)
- queue_packet(handle, handle->iso.max_packet_size, 4, 0, 0);
-
+ queue_packet(handle, handle->iso.max_packet_size,
+ recv_header_length(handle), 0, 0);
return 0;
}
@@ -159,9 +164,11 @@ flush_recv_packets(raw1394handle_t handle,
quadlet_t header, *p, *end;
unsigned int len, cycle, dropped;
unsigned char channel, tag, sy;
+ int header_has_timestamp;
p = interrupt->header;
end = (void *) interrupt->header + interrupt->header_length;
+ header_has_timestamp = fwhandle->abi_version >= 2;
cycle = interrupt->cycle;
dropped = 0;
d = RAW1394_ISO_OK;
@@ -173,6 +180,9 @@ flush_recv_packets(raw1394handle_t handle,
channel = (header >> 8) & 0x3f;
sy = header & 0x0f;
+ if (header_has_timestamp)
+ cycle = be32_to_cpu(*p++) & 0x1fff;
+
d = fwhandle->iso.recv_handler(handle, fwhandle->iso.tail, len,
channel, tag, sy, cycle, dropped);
if (d != RAW1394_ISO_OK)
@@ -420,7 +430,7 @@ iso_init(fw_handle_t handle, int type,
create.type = type;
create.channel = channel;
create.speed = speed;
- create.header_size = 4;
+ create.header_size = recv_header_length(handle);
retval = ioctl(handle->iso.fd,
FW_CDEV_IOC_CREATE_ISO_CONTEXT, &create);