summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Kristian Høgsberg 2007-04-02 17:33:07 -0400
committerGravatar Kristian Høgsberg 2007-04-02 17:33:07 -0400
commitd9b43daf480496babdacdf9e1562397fbdac1330 (patch)
tree3114945008849af48258fa1dbe69d14c9b7bf87e
parentDecode iso headers properly. (diff)
More work on iso receive; handle payload wrapping.
-rw-r--r--juju/juju.h1
-rw-r--r--juju/raw1394-iso.c43
2 files changed, 28 insertions, 16 deletions
diff --git a/juju/juju.h b/juju/juju.h
index 882a131..f3c44e9 100644
--- a/juju/juju.h
+++ b/juju/juju.h
@@ -124,6 +124,7 @@ struct raw1394_handle {
int packet_index;
int packet_phase;
int packet_tail;
+ int packet_count;
int buf_packets;
int max_packet_size;
enum raw1394_iso_dma_recv_mode recv_mode;
diff --git a/juju/raw1394-iso.c b/juju/raw1394-iso.c
index b65faf7..e957787 100644
--- a/juju/raw1394-iso.c
+++ b/juju/raw1394-iso.c
@@ -60,6 +60,7 @@ refill_xmit_buffer(raw1394handle_t handle, struct fw_cdev_queue_iso *queue_iso)
data += handle->iso.max_packet_size;
handle->iso.packet_index++;
+ handle->iso.packet_count++;
handle->iso.packet_phase++;
if (handle->iso.packet_index == handle->iso.buf_packets) {
@@ -123,11 +124,11 @@ int raw1394_iso_xmit_start(raw1394handle_t handle, int start_on_cycle,
static int
queue_recv_packets(raw1394handle_t handle)
{
- int i;
struct fw_cdev_queue_iso queue_iso;
struct fw_cdev_iso_packet *p = handle->iso.packets;
unsigned int len;
unsigned char *data, *buffer;
+ int i;
buffer = handle->iso.buffer +
handle->iso.packet_index * handle->iso.max_packet_size;
@@ -143,17 +144,22 @@ queue_recv_packets(raw1394handle_t handle)
data += handle->iso.max_packet_size;
handle->iso.packet_index++;
+ handle->iso.packet_count++;
handle->iso.packet_phase++;
- if (handle->iso.packet_index == handle->iso.buf_packets)
- handle->iso.packet_index = 0;
if (handle->iso.packet_phase == handle->iso.irq_interval)
handle->iso.packet_phase = 0;
+ if (handle->iso.packet_index == handle->iso.buf_packets) {
+ handle->iso.packet_index = 0;
+ /* We can't handle wrapping payloads, so we need to
+ * break in this case.*/
+ i++;
+ break;
+ }
}
queue_iso.packets = ptr_to_u64(handle->iso.packets);
- queue_iso.size =
- handle->iso.irq_interval * sizeof handle->iso.packets[0];
+ queue_iso.size = i * sizeof handle->iso.packets[0];
queue_iso.data = ptr_to_u64(buffer);
len = ioctl(handle->iso.fd, FW_CDEV_IOC_QUEUE_ISO, &queue_iso);
@@ -187,22 +193,23 @@ flush_recv_packets(raw1394handle_t handle,
channel = (header >> 8) & 0x3f;
sy = header & 0x0f;
- fprintf(stderr,
- "header: %08x, len=%d, channel=%d, tag=%d, sy=%d, packet_tail=0x%x\n",
- header, len, channel, tag, sy, handle->iso.packet_tail);
-
d = handle->iso.recv_handler(handle, data, len, channel,
tag, sy, cycle, dropped);
data += handle->iso.max_packet_size;
cycle++;
- }
- handle->iso.packet_tail += interrupt->header_length / 4;
- if (handle->iso.packet_tail >= handle->iso.buf_packets)
- handle->iso.packet_tail -= handle->iso.buf_packets;
+ handle->iso.packet_tail++;
+ handle->iso.packet_count--;
+ if (handle->iso.packet_tail == handle->iso.buf_packets) {
+ handle->iso.packet_tail = 0;
+ data = handle->iso.buffer;
+ }
+ }
- queue_recv_packets(handle);
+ while (handle->iso.packet_count + handle->iso.irq_interval <=
+ handle->iso.buf_packets)
+ queue_recv_packets(handle);
return 0;
}
@@ -212,7 +219,7 @@ int raw1394_iso_recv_start(raw1394handle_t handle, int start_on_cycle,
{
struct fw_cdev_start_iso start_iso;
- while (handle->iso.packet_index + handle->iso.irq_interval <
+ while (handle->iso.packet_count + handle->iso.irq_interval <=
handle->iso.buf_packets)
queue_recv_packets(handle);
@@ -298,7 +305,6 @@ iso_init(raw1394handle_t handle, int type,
unsigned char channel,
enum raw1394_iso_speed speed,
int irq_interval)
-
{
struct fw_cdev_create_iso_context create;
struct epoll_event ep;
@@ -321,6 +327,7 @@ iso_init(raw1394handle_t handle, int type,
handle->iso.packet_index = 0;
handle->iso.packet_phase = 0;
handle->iso.packet_tail = 0;
+ handle->iso.packet_count = 0;
handle->iso.queue_iso.size = 0;
handle->iso.packets =
malloc(handle->iso.irq_interval * sizeof handle->iso.packets[0]);
@@ -441,6 +448,10 @@ int raw1394_iso_recv_set_channel_mask(raw1394handle_t handle, u_int64_t mask)
void raw1394_iso_stop(raw1394handle_t handle)
{
ioctl(handle->iso.fd, FW_CDEV_IOC_STOP_ISO);
+ handle->iso.packet_index = 0;
+ handle->iso.packet_tail = 0;
+ handle->iso.packet_phase = 0;
+ handle->iso.packet_count = 0;
}
void raw1394_iso_shutdown(raw1394handle_t handle)
2fce9f8dd90949315d789a6546dfacd0?s=13&d=retro' width='13' height='13' alt='Gravatar' /> bencollins 1-4/+0 the svn log is more than verbose enough for info seekers. git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@110 53a565d1-3bb7-0310-b661-cf11e63c67ab 2003-07-13Fix compiler warnings.Gravatar bencollins 4-12/+22 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@109 53a565d1-3bb7-0310-b661-cf11e63c67ab 2003-07-13Updates from 0.10.0 release.Gravatar bencollins 4-5/+14 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@108 53a565d1-3bb7-0310-b661-cf11e63c67ab 2003-04-23add libtoolize to bootstrapGravatar ddennedy 1-1/+10 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@107 53a565d1-3bb7-0310-b661-cf11e63c67ab 2003-04-21added Dan Maas' rawiso docsGravatar ddennedy 1-32/+295 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@106 53a565d1-3bb7-0310-b661-cf11e63c67ab 2003-04-07new_handle_on_port() error path fix from Jim RadfordGravatar dmaas 1-1/+3 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@105 53a565d1-3bb7-0310-b661-cf11e63c67ab 2003-03-26add raw1394_new_handle_on_port() convenience functionGravatar dmaas 2-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