summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Clemens Ladisch 2011-02-24 17:34:10 +0100
committerGravatar Stefan Richter 2011-02-25 19:45:49 +0100
commit793b7639cfebc23b1e97bdec5946138e4c73bda2 (patch)
tree2193ac7743157684a72c1ce88351e8dc89e8f858
parentdo not delay iso packet queueing (diff)
fix start_on_cycle on firewire-core
Libraw1394 uses raw1394's convention of cycle numbers always being less than one second, i.e., in the range 0..7999. Firewire-core uses raw cycle numbers as used by the hardware, i.e., with several additional bits for the seconds. This was correctly handled when presenting timestamps returned by the kernel to the application, but the application's start_on_cycle value was passed directly to the kernel. To fix this, do the same calculations that ohci1394 did internally, i.e., interpret the start_on_cycle value as relative to the current seconds value of the cycle timer. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to '')
-rw-r--r--src/fw-iso.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/fw-iso.c b/src/fw-iso.c
index ce1a891..d44a945 100644
--- a/src/fw-iso.c
+++ b/src/fw-iso.c
@@ -21,6 +21,34 @@
#include "fw.h"
#include "raw1394_private.h"
+static int calculate_start_cycle(fw_handle_t handle)
+{
+ int cycle;
+ u_int32_t cycle_timer;
+ u_int64_t local_time;
+
+ cycle = handle->iso.start_on_cycle;
+ if (cycle < 0)
+ return cycle;
+
+ /* libraw1394's cycle is always mod 8000 */
+ cycle &= 0x1fff;
+
+ /* get the seconds from the current value of the cycle timer */
+ if (fw_read_cycle_timer(handle, &cycle_timer, &local_time) != 0)
+ return cycle;
+ cycle += (cycle_timer & 0xfe000000) >> 12;
+
+ /*
+ * For compatibility with raw1394, add one second
+ * "to give some extra time for DMA to start".
+ * TODO: are there still races due to cycle rollover?
+ */
+ cycle += 1 << 13;
+
+ return cycle & 0x7fff;
+}
+
static int
queue_packet(fw_handle_t handle,
unsigned int length, unsigned int header_length,
@@ -140,7 +168,7 @@ int fw_iso_xmit_start(raw1394handle_t handle, int start_on_cycle,
if (fwhandle->iso.prebuffer <= fwhandle->iso.packet_count) {
start_iso.sync = 0; /* unused */
start_iso.tags = 0; /* unused */
- start_iso.cycle = start_on_cycle;
+ start_iso.cycle = calculate_start_cycle(fwhandle);
start_iso.handle = fwhandle->iso.kernel_handle;
retval = ioctl(fwhandle->iso.fd,
@@ -258,7 +286,8 @@ int fw_iso_recv_start(fw_handle_t handle, int start_on_cycle,
queue_recv_packets(handle);
- start_iso.cycle = start_on_cycle;
+ handle->iso.start_on_cycle = start_on_cycle;
+ start_iso.cycle = calculate_start_cycle(handle);
start_iso.tags =
tag_mask == -1 ? FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS : tag_mask;
/* sync is documented as 'not used' */
@@ -353,7 +382,7 @@ int fw_iso_xmit_write(raw1394handle_t handle, unsigned char *data,
fwhandle->iso.packet_count >= fwhandle->iso.prebuffer) {
/* Set this to 0 to indicate that we're running. */
fwhandle->iso.prebuffer = 0;
- start_iso.cycle = fwhandle->iso.start_on_cycle;
+ start_iso.cycle = calculate_start_cycle(fwhandle);
start_iso.handle = fwhandle->iso.kernel_handle;
retval = ioctl(fwhandle->iso.fd,
='deletions'>-1/+41 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@104 53a565d1-3bb7-0310-b661-cf11e63c67ab 2003-02-22Updates for new rawiso ioctl interface.Gravatar bencollins 3-37/+125 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@103 53a565d1-3bb7-0310-b661-cf11e63c67ab 2003-01-15add iso_xmit_sync() and iso_xmit_write(); clean up iso handling a bitGravatar dmaas 5-39/+161 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@102 53a565d1-3bb7-0310-b661-cf11e63c67ab 2003-01-15implement tag matching for rawiso receptionGravatar dmaas 3-4/+12 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@101 53a565d1-3bb7-0310-b661-cf11e63c67ab 2003-01-06back out previous commit - don't drop the legacy API just yetGravatar dmaas 6-173/+130 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@100 53a565d1-3bb7-0310-b661-cf11e63c67ab 2003-01-05emulate legacy ISO reception API on top of new rawiso APIGravatar dmaas 7-131/+174 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@99 53a565d1-3bb7-0310-b661-cf11e63c67ab 2002-12-24update iso API for multi-channel reception and new packet buffer layoutGravatar dmaas 4-123/+236 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@98 53a565d1-3bb7-0310-b661-cf11e63c67ab 2002-12-20oops, irq_interval needs to be signedGravatar anonymous 1-1/+1 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@97 53a565d1-3bb7-0310-b661-cf11e63c67ab 2002-12-20dmaas - renamed exported arm definitions into the raw1394_ namespace; ↵Gravatar anonymous 3-124/+48 brought kernel-raw1394.h back in sync with the kernel version git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@96 53a565d1-3bb7-0310-b661-cf11e63c67ab 2002-12-16rawiso updates:Gravatar dmaas 3-18/+25 - changed return type of rawiso xmit/recv handlers from int to enum raw1394_iso_disposition - added an ioctl (RAW1394_ISO_QUEUE_ACTIVITY) to force an ISO_ACTIVITY event into the queue. This is needed for handling RAW1394_ISO_DEFER, to kick us out of the next read() instead of sleeping forever. - removed references to "8-byte" isochronous header - this is an OHCI-specific implementation detail git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@95 53a565d1-3bb7-0310-b661-cf11e63c67ab 2002-11-18fix cplusplus extern C blockGravatar ddennedy 1-4/+4 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@94 53a565d1-3bb7-0310-b661-cf11e63c67ab 2002-11-18merged rawiso branchGravatar ddennedy 7-6/+488 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@93 53a565d1-3bb7-0310-b661-cf11e63c67ab