1999-12-02 18:07:38 -05:00
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "raw1394.h"
|
|
|
|
#include "kernel-raw1394.h"
|
|
|
|
#include "raw1394_private.h"
|
|
|
|
|
|
|
|
|
|
|
|
int raw1394_loop_iterate(struct raw1394_handle *handle)
|
|
|
|
{
|
|
|
|
struct raw1394_request *req = &handle->req;
|
2000-02-04 18:20:17 -05:00
|
|
|
int retval = 0, channel;
|
1999-12-02 18:07:38 -05:00
|
|
|
|
|
|
|
if (read(handle->fd, req, sizeof(*req)) < 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (req->type) {
|
|
|
|
case RAW1394_REQ_BUS_RESET:
|
|
|
|
handle->generation = req->generation;
|
|
|
|
handle->num_of_nodes = req->misc & 0xffff;
|
|
|
|
handle->local_id = req->misc >> 16;
|
|
|
|
|
|
|
|
if (handle->bus_reset_handler) {
|
|
|
|
retval = handle->bus_reset_handler(handle);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RAW1394_REQ_ISO_RECEIVE:
|
2000-02-04 18:20:17 -05:00
|
|
|
channel = (handle->buffer[0] >> 8) & 0x3f;
|
|
|
|
|
|
|
|
if (handle->iso_handler[channel]) {
|
|
|
|
retval = handle->iso_handler[channel](handle, channel,
|
|
|
|
req->length,
|
|
|
|
handle->buffer);
|
1999-12-02 18:07:38 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (handle->tag_handler) {
|
|
|
|
retval = handle->tag_handler(handle, req->tag,
|
|
|
|
req->error);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bus_reset_handler_t raw1394_set_bus_reset_handler(struct raw1394_handle *handle,
|
|
|
|
bus_reset_handler_t new)
|
|
|
|
{
|
|
|
|
bus_reset_handler_t old;
|
|
|
|
|
|
|
|
old = handle->bus_reset_handler;
|
|
|
|
handle->bus_reset_handler = new;
|
|
|
|
|
|
|
|
return old;
|
|
|
|
}
|
|
|
|
|
|
|
|
tag_handler_t raw1394_set_tag_handler(struct raw1394_handle *handle,
|
|
|
|
tag_handler_t new)
|
|
|
|
{
|
|
|
|
tag_handler_t old;
|
|
|
|
|
|
|
|
old = handle->tag_handler;
|
|
|
|
handle->tag_handler = new;
|
|
|
|
|
|
|
|
return old;
|
|
|
|
}
|
|
|
|
|
|
|
|
iso_handler_t raw1394_set_iso_handler(struct raw1394_handle *handle,
|
2000-02-04 18:20:17 -05:00
|
|
|
unsigned int channel, iso_handler_t new)
|
1999-12-02 18:07:38 -05:00
|
|
|
{
|
2000-02-04 18:20:17 -05:00
|
|
|
if (channel >= 64) {
|
|
|
|
return (iso_handler_t)-1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (new == NULL) {
|
|
|
|
iso_handler_t old = handle->iso_handler[channel];
|
|
|
|
handle->iso_handler[channel] = NULL;
|
|
|
|
return old;
|
|
|
|
}
|
1999-12-02 18:07:38 -05:00
|
|
|
|
2000-02-04 18:20:17 -05:00
|
|
|
if (handle->iso_handler[channel] != NULL) {
|
|
|
|
return (iso_handler_t)-1;
|
|
|
|
}
|
1999-12-02 18:07:38 -05:00
|
|
|
|
2000-02-04 18:20:17 -05:00
|
|
|
handle->iso_handler[channel] = new;
|
|
|
|
return NULL;
|
1999-12-02 18:07:38 -05:00
|
|
|
}
|