From 49dda1ef90ab1c8b57634a06a35bbbacbe17604e Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Sun, 11 Jan 2009 22:46:48 +0100 Subject: [PATCH] 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 --- src/fw-iso.c | 16 +++++++++++++--- 1 file 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);