Changed iso rcv handling to separate handlers per channel.
git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@6 53a565d1-3bb7-0310-b661-cf11e63c67ab
This commit is contained in:
parent
7ba9a46969
commit
9eb8df1247
|
@ -4,6 +4,7 @@ AC_INIT(Makefile.am)
|
||||||
AM_INIT_AUTOMAKE(libraw1394, 0.4)
|
AM_INIT_AUTOMAKE(libraw1394, 0.4)
|
||||||
|
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
|
AC_PROG_RANLIB
|
||||||
AM_PROG_LIBTOOL
|
AM_PROG_LIBTOOL
|
||||||
|
|
||||||
AC_OUTPUT([ Makefile src/Makefile ])
|
AC_OUTPUT([ Makefile src/Makefile ])
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
lib_LTLIBRARIES = libraw1394.la
|
lib_LTLIBRARIES = libraw1394.la
|
||||||
|
|
||||||
libraw1394_la_LDFLAGS = -version-info 1:0:1
|
libraw1394_la_LDFLAGS = -version-info 2:0:0
|
||||||
|
|
||||||
libraw1394_la_SOURCES = \
|
libraw1394_la_SOURCES = \
|
||||||
main.c \
|
main.c \
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
int raw1394_loop_iterate(struct raw1394_handle *handle)
|
int raw1394_loop_iterate(struct raw1394_handle *handle)
|
||||||
{
|
{
|
||||||
struct raw1394_request *req = &handle->req;
|
struct raw1394_request *req = &handle->req;
|
||||||
int retval = 0;
|
int retval = 0, channel;
|
||||||
|
|
||||||
if (read(handle->fd, req, sizeof(*req)) < 0) {
|
if (read(handle->fd, req, sizeof(*req)) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -27,11 +27,12 @@ int raw1394_loop_iterate(struct raw1394_handle *handle)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RAW1394_REQ_ISO_RECEIVE:
|
case RAW1394_REQ_ISO_RECEIVE:
|
||||||
if (handle->iso_handler) {
|
channel = (handle->buffer[0] >> 8) & 0x3f;
|
||||||
retval = handle->iso_handler(handle,
|
|
||||||
(handle->buffer[0] >> 8)
|
if (handle->iso_handler[channel]) {
|
||||||
& 0x3f, req->length,
|
retval = handle->iso_handler[channel](handle, channel,
|
||||||
handle->buffer);
|
req->length,
|
||||||
|
handle->buffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -70,12 +71,22 @@ tag_handler_t raw1394_set_tag_handler(struct raw1394_handle *handle,
|
||||||
}
|
}
|
||||||
|
|
||||||
iso_handler_t raw1394_set_iso_handler(struct raw1394_handle *handle,
|
iso_handler_t raw1394_set_iso_handler(struct raw1394_handle *handle,
|
||||||
iso_handler_t new)
|
unsigned int channel, iso_handler_t new)
|
||||||
{
|
{
|
||||||
iso_handler_t old;
|
if (channel >= 64) {
|
||||||
|
return (iso_handler_t)-1;
|
||||||
|
}
|
||||||
|
|
||||||
old = handle->iso_handler;
|
if (new == NULL) {
|
||||||
handle->iso_handler = new;
|
iso_handler_t old = handle->iso_handler[channel];
|
||||||
|
handle->iso_handler[channel] = NULL;
|
||||||
|
return old;
|
||||||
|
}
|
||||||
|
|
||||||
return old;
|
if (handle->iso_handler[channel] != NULL) {
|
||||||
|
return (iso_handler_t)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
handle->iso_handler[channel] = new;
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,12 +27,6 @@ static int tag_handler_default(struct raw1394_handle *handle, unsigned long tag,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int iso_handler_default(struct raw1394_handle *handle, int channel,
|
|
||||||
size_t length, quadlet_t *data)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int _raw1394_sync_cb(struct raw1394_handle *unused, struct sync_cb_data *data,
|
int _raw1394_sync_cb(struct raw1394_handle *unused, struct sync_cb_data *data,
|
||||||
int error)
|
int error)
|
||||||
{
|
{
|
||||||
|
@ -88,7 +82,7 @@ struct raw1394_handle *raw1394_get_handle(void)
|
||||||
|
|
||||||
handle->bus_reset_handler = bus_reset_default;
|
handle->bus_reset_handler = bus_reset_default;
|
||||||
handle->tag_handler = tag_handler_default;
|
handle->tag_handler = tag_handler_default;
|
||||||
handle->iso_handler = iso_handler_default;
|
memset(handle->iso_handler, 0, sizeof(handle->iso_handler));
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,13 +90,18 @@ tag_handler_t raw1394_set_tag_handler(raw1394handle_t handle,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the handler that will be called when an iso packet arrives (data points
|
* Set the handler that will be called when an iso packet arrives (data points
|
||||||
* to the iso packet header). The default action is to do nothing. Returns old
|
* to the iso packet header). The default action is to do nothing.
|
||||||
* handler.
|
*
|
||||||
|
* Handlers have to be set separately for each channel, it is not possible to
|
||||||
|
* set a handler when there is already one set for that channel. Handlers can
|
||||||
|
* be cleared by passing NULL for "new" parameter, in that case the old handler
|
||||||
|
* will be returned. Otherwise the return value is NULL for success and -1 for
|
||||||
|
* failure.
|
||||||
*/
|
*/
|
||||||
typedef int (*iso_handler_t)(raw1394handle_t, int channel, size_t length,
|
typedef int (*iso_handler_t)(raw1394handle_t, int channel, size_t length,
|
||||||
quadlet_t *data);
|
quadlet_t *data);
|
||||||
iso_handler_t raw1394_set_iso_handler(raw1394handle_t handle,
|
iso_handler_t raw1394_set_iso_handler(raw1394handle_t handle,
|
||||||
iso_handler_t new);
|
unsigned int channel, iso_handler_t new);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -11,7 +11,7 @@ struct raw1394_handle {
|
||||||
|
|
||||||
bus_reset_handler_t bus_reset_handler;
|
bus_reset_handler_t bus_reset_handler;
|
||||||
tag_handler_t tag_handler;
|
tag_handler_t tag_handler;
|
||||||
iso_handler_t iso_handler;
|
iso_handler_t iso_handler[64];
|
||||||
|
|
||||||
struct raw1394_request req;
|
struct raw1394_request req;
|
||||||
quadlet_t buffer[2048];
|
quadlet_t buffer[2048];
|
||||||
|
|
Reference in New Issue