2000-06-14 11:01:42 -04:00
|
|
|
/*
|
|
|
|
* libraw1394 - library for raw access to the 1394 bus with the Linux subsystem.
|
|
|
|
*
|
2002-10-13 18:54:49 -04:00
|
|
|
* Copyright (C) 1999,2000,2001,2002 Andreas Bombe
|
2002-10-23 17:18:49 -04:00
|
|
|
* 2002 Manfred Weihs <weihs@ict.tuwien.ac.at>
|
|
|
|
* 2002 Christian Toegel <christian.toegel@gmx.at>
|
2000-06-14 11:01:42 -04:00
|
|
|
*
|
|
|
|
* This library is licensed under the GNU Lesser General Public License (LGPL),
|
|
|
|
* version 2.1 or later. See the file COPYING.LIB in the distribution for
|
|
|
|
* details.
|
2002-10-23 17:18:49 -04:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* Contributions:
|
|
|
|
*
|
|
|
|
* Manfred Weihs <weihs@ict.tuwien.ac.at>
|
|
|
|
* address range mapping
|
|
|
|
* Christian Toegel <christian.toegel@gmx.at>
|
|
|
|
* address range mapping
|
2000-06-14 11:01:42 -04:00
|
|
|
*/
|
1999-12-02 18:07:38 -05:00
|
|
|
|
2000-05-28 17:00:56 -04:00
|
|
|
#include <config.h>
|
1999-12-02 18:07:38 -05:00
|
|
|
#include <unistd.h>
|
2001-02-27 18:44:08 -05:00
|
|
|
#include <byteswap.h>
|
2008-03-27 12:48:02 -04:00
|
|
|
#include <errno.h>
|
1999-12-02 18:07:38 -05:00
|
|
|
|
|
|
|
#include "raw1394.h"
|
|
|
|
#include "kernel-raw1394.h"
|
|
|
|
#include "raw1394_private.h"
|
|
|
|
|
|
|
|
|
2008-04-23 20:44:36 -04:00
|
|
|
int ieee1394_loop_iterate(struct raw1394_handle *handle)
|
1999-12-02 18:07:38 -05:00
|
|
|
{
|
2003-07-22 10:54:19 -04:00
|
|
|
struct raw1394_request req;
|
2008-04-23 20:44:36 -04:00
|
|
|
ieee1394handle_t ihandle = handle->mode.ieee1394;
|
2000-02-04 18:20:17 -05:00
|
|
|
int retval = 0, channel;
|
1999-12-02 18:07:38 -05:00
|
|
|
|
2008-04-23 20:44:36 -04:00
|
|
|
while (read(ihandle->fd, &req, sizeof(req)) < 0) {
|
2008-03-27 12:48:02 -04:00
|
|
|
if (errno != EINTR) return -1;
|
1999-12-02 18:07:38 -05:00
|
|
|
}
|
|
|
|
|
2003-07-22 10:54:19 -04:00
|
|
|
switch (req.type) {
|
1999-12-02 18:07:38 -05:00
|
|
|
case RAW1394_REQ_BUS_RESET:
|
2008-04-23 20:44:36 -04:00
|
|
|
if (ihandle->protocol_version == 3) {
|
|
|
|
ihandle->num_of_nodes = req.misc & 0xffff;
|
|
|
|
ihandle->local_id = req.misc >> 16;
|
2000-08-07 20:29:08 -04:00
|
|
|
} else {
|
2008-04-23 20:44:36 -04:00
|
|
|
ihandle->num_of_nodes = req.misc & 0xff;
|
|
|
|
ihandle->irm_id = ((req.misc >> 8) & 0xff) | 0xffc0;
|
|
|
|
ihandle->local_id = req.misc >> 16;
|
2000-08-07 20:29:08 -04:00
|
|
|
}
|
1999-12-02 18:07:38 -05:00
|
|
|
|
2008-04-23 20:44:36 -04:00
|
|
|
if (ihandle->bus_reset_handler) {
|
|
|
|
retval = ihandle->bus_reset_handler(handle,
|
2003-07-22 10:54:19 -04:00
|
|
|
req.generation);
|
1999-12-02 18:07:38 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2000-03-15 22:40:52 -05:00
|
|
|
case RAW1394_REQ_FCP_REQUEST:
|
2008-04-23 20:44:36 -04:00
|
|
|
if (ihandle->fcp_handler) {
|
|
|
|
retval = ihandle->fcp_handler(handle, req.misc & 0xffff,
|
2003-07-22 10:54:19 -04:00
|
|
|
req.misc >> 16,
|
|
|
|
req.length,
|
2008-04-23 20:44:36 -04:00
|
|
|
(unsigned char *)ihandle->buffer);
|
2000-03-15 22:40:52 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-10-23 17:18:49 -04:00
|
|
|
case RAW1394_REQ_ARM:
|
2008-04-23 20:44:36 -04:00
|
|
|
if (ihandle->arm_tag_handler) {
|
|
|
|
retval = ihandle->arm_tag_handler(handle, req.tag,
|
2003-07-22 10:54:19 -04:00
|
|
|
(req.misc & (0xFF)),
|
|
|
|
((req.misc >> 16) & (0xFFFF)),
|
|
|
|
int2ptr(req.recvb));
|
2002-10-23 17:18:49 -04:00
|
|
|
}
|
|
|
|
break;
|
2002-11-18 02:40:21 -05:00
|
|
|
|
2002-10-23 17:18:49 -04:00
|
|
|
case RAW1394_REQ_ECHO:
|
2003-07-22 10:54:19 -04:00
|
|
|
retval=req.misc;
|
2002-10-23 17:18:49 -04:00
|
|
|
break;
|
2002-11-18 02:40:21 -05:00
|
|
|
|
|
|
|
case RAW1394_REQ_RAWISO_ACTIVITY:
|
2008-04-23 20:44:36 -04:00
|
|
|
retval = _ieee1394_iso_iterate(handle);
|
2002-11-18 02:40:21 -05:00
|
|
|
break;
|
|
|
|
|
1999-12-02 18:07:38 -05:00
|
|
|
default:
|
2008-04-23 20:44:36 -04:00
|
|
|
if (ihandle->tag_handler) {
|
|
|
|
retval = ihandle->tag_handler(handle, req.tag,
|
2003-07-22 10:54:19 -04:00
|
|
|
req.error);
|
1999-12-02 18:07:38 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bus_reset_handler_t raw1394_set_bus_reset_handler(struct raw1394_handle *handle,
|
|
|
|
bus_reset_handler_t new)
|
|
|
|
{
|
2008-04-23 20:44:36 -04:00
|
|
|
bus_reset_handler_t old;
|
|
|
|
if (handle && handle->is_fw) {
|
|
|
|
old = handle->mode.fw->bus_reset_handler;
|
|
|
|
handle->mode.fw->bus_reset_handler = new;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
old = handle->mode.ieee1394->bus_reset_handler;
|
|
|
|
handle->mode.ieee1394->bus_reset_handler = new;
|
|
|
|
}
|
|
|
|
return old;
|
1999-12-02 18:07:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
tag_handler_t raw1394_set_tag_handler(struct raw1394_handle *handle,
|
|
|
|
tag_handler_t new)
|
|
|
|
{
|
2008-04-23 20:44:36 -04:00
|
|
|
tag_handler_t old;
|
|
|
|
if (handle && handle->is_fw) {
|
|
|
|
old = handle->mode.fw->tag_handler;
|
|
|
|
handle->mode.fw->tag_handler = new;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
old = handle->mode.ieee1394->tag_handler;
|
|
|
|
handle->mode.ieee1394->tag_handler = new;
|
|
|
|
}
|
|
|
|
return old;
|
1999-12-02 18:07:38 -05:00
|
|
|
}
|
|
|
|
|
2002-10-23 17:18:49 -04:00
|
|
|
arm_tag_handler_t raw1394_set_arm_tag_handler(struct raw1394_handle *handle,
|
|
|
|
arm_tag_handler_t new)
|
|
|
|
{
|
2008-04-23 20:44:36 -04:00
|
|
|
arm_tag_handler_t old;
|
|
|
|
if (handle && handle->is_fw) {
|
|
|
|
old = handle->mode.fw->arm_tag_handler;
|
|
|
|
handle->mode.fw->arm_tag_handler = new;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
old = handle->mode.ieee1394->arm_tag_handler;
|
|
|
|
handle->mode.ieee1394->arm_tag_handler = new;
|
|
|
|
}
|
|
|
|
return old;
|
2003-01-05 23:08:00 -05:00
|
|
|
}
|
|
|
|
|
2000-03-15 22:40:52 -05:00
|
|
|
fcp_handler_t raw1394_set_fcp_handler(struct raw1394_handle *handle,
|
|
|
|
fcp_handler_t new)
|
|
|
|
{
|
2008-04-23 20:44:36 -04:00
|
|
|
fcp_handler_t old;
|
|
|
|
if (handle && handle->is_fw) {
|
|
|
|
old = handle->mode.fw->fcp_handler;
|
|
|
|
handle->mode.fw->fcp_handler = new;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
old = handle->mode.ieee1394->fcp_handler;
|
|
|
|
handle->mode.ieee1394->fcp_handler = new;
|
|
|
|
}
|
|
|
|
return old;
|
2000-03-15 22:40:52 -05:00
|
|
|
}
|