2000-03-15 22:40:52 -05:00
|
|
|
|
2000-05-28 17:00:56 -04:00
|
|
|
#include <config.h>
|
2000-03-15 22:40:52 -05:00
|
|
|
#include <errno.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "raw1394.h"
|
|
|
|
#include "kernel-raw1394.h"
|
|
|
|
#include "raw1394_private.h"
|
|
|
|
|
2000-03-16 17:22:05 -05:00
|
|
|
static int do_fcp_listen(struct raw1394_handle *handle, int startstop)
|
2000-03-15 22:40:52 -05:00
|
|
|
{
|
|
|
|
struct sync_cb_data sd = { 0, 0 };
|
|
|
|
struct raw1394_reqhandle rh = { (req_callback_t)_raw1394_sync_cb, &sd };
|
|
|
|
int err;
|
|
|
|
struct raw1394_request *req = &handle->req;
|
|
|
|
|
|
|
|
CLEAR_REQ(req);
|
|
|
|
req->type = RAW1394_REQ_FCP_LISTEN;
|
|
|
|
req->generation = handle->generation;
|
2000-03-16 17:22:05 -05:00
|
|
|
req->misc = startstop;
|
2000-03-15 22:40:52 -05:00
|
|
|
req->tag = (unsigned long)&rh;
|
2000-05-28 17:00:56 -04:00
|
|
|
req->recvb = (kptr_t)handle->buffer;
|
2000-03-15 22:40:52 -05:00
|
|
|
req->length = 512;
|
|
|
|
|
|
|
|
err = write(handle->fd, req, sizeof(*req));
|
|
|
|
while (!sd.done) {
|
|
|
|
if (err < 0) return err;
|
|
|
|
err = raw1394_loop_iterate(handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (sd.errcode) {
|
|
|
|
case RAW1394_ERROR_ALREADY:
|
|
|
|
errno = EALREADY;
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
case RAW1394_ERROR_INVALID_ARG:
|
|
|
|
errno = EINVAL;
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
default:
|
|
|
|
errno = 0;
|
|
|
|
return sd.errcode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int raw1394_start_fcp_listen(struct raw1394_handle *handle)
|
|
|
|
{
|
2000-03-16 17:22:05 -05:00
|
|
|
return do_fcp_listen(handle, 1);
|
2000-03-15 22:40:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int raw1394_stop_fcp_listen(struct raw1394_handle *handle)
|
|
|
|
{
|
2000-03-16 17:22:05 -05:00
|
|
|
return do_fcp_listen(handle, 0);
|
2000-03-15 22:40:52 -05:00
|
|
|
}
|