summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Dan Dennedy 2008-04-23 17:44:36 -0700
committerGravatar Dan Dennedy 2008-04-23 17:44:36 -0700
commit0ea462ae9895ca903c8d3134910c06e1869560c4 (patch)
treec1b72a170cfca14c1b9cccd552e5cadc249bd483 /src
parentFix configure.ac missing fi after initial merge. (diff)
First cut at integrating juju
This is currently working with legacy ieee1394 and tools/testlibraw.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am7
-rw-r--r--src/arm.c8
-rw-r--r--src/dispatch.c545
-rw-r--r--src/errors.c7
-rw-r--r--src/eventloop.c136
-rw-r--r--src/fcp.c13
-rw-r--r--src/iso.c195
-rw-r--r--src/main.c69
-rw-r--r--src/raw1394.h96
-rw-r--r--src/raw1394_private.h162
-rw-r--r--src/readwrite.c83
11 files changed, 905 insertions, 416 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 16b6add..56a0950 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,7 +17,12 @@ libraw1394_la_SOURCES = \
version.c \
kernel-raw1394.h \
raw1394_private.h \
- ieee1394-ioctl.h
+ ieee1394-ioctl.h \
+ dispatch.c \
+ ../juju/raw1394.c \
+ ../juju/raw1394-iso.c \
+ ../juju.h
+
# headers to be installed
pkginclude_HEADERS = raw1394.h csr.h ieee1394.h
diff --git a/src/arm.c b/src/arm.c
index d87e326..c523c00 100644
--- a/src/arm.c
+++ b/src/arm.c
@@ -43,7 +43,7 @@
* returnvalue: 0 ... success
* <0 ... failure
*/
-int raw1394_arm_register(struct raw1394_handle *handle, nodeaddr_t start,
+int ieee1394_arm_register(struct ieee1394_handle *handle, nodeaddr_t start,
size_t length, byte_t *initial_value,
octlet_t arm_tag, arm_options_t access_rights,
arm_options_t notification_options,
@@ -79,7 +79,7 @@ int raw1394_arm_register(struct raw1394_handle *handle, nodeaddr_t start,
* returnvalue: 0 ... success
* <0 ... failure
*/
-int raw1394_arm_unregister (struct raw1394_handle *handle, nodeaddr_t start)
+int ieee1394_arm_unregister (struct ieee1394_handle *handle, nodeaddr_t start)
{
int retval;
struct raw1394_request req;
@@ -105,7 +105,7 @@ int raw1394_arm_unregister (struct raw1394_handle *handle, nodeaddr_t start)
* returnvalue: 0 ... success
* <0 ... failure, and errno - error code
*/
-int raw1394_arm_set_buf (struct raw1394_handle *handle, nodeaddr_t start,
+int ieee1394_arm_set_buf (struct ieee1394_handle *handle, nodeaddr_t start,
size_t length, void *buf)
{
struct raw1394_request req;
@@ -135,7 +135,7 @@ int raw1394_arm_set_buf (struct raw1394_handle *handle, nodeaddr_t start,
* returnvalue: 0 ... success
* <0 ... failure, and errno - error code
*/
-int raw1394_arm_get_buf (struct raw1394_handle *handle, nodeaddr_t start,
+int ieee1394_arm_get_buf (struct ieee1394_handle *handle, nodeaddr_t start,
size_t length, void *buf)
{
struct raw1394_request req;
diff --git a/src/dispatch.c b/src/dispatch.c
new file mode 100644
index 0000000..cb68ef8
--- /dev/null
+++ b/src/dispatch.c
@@ -0,0 +1,545 @@
+/*
+ * libraw1394 - library for raw access to the 1394 bus with the Linux subsystem.
+ *
+ * Copyright (C) 2008 Dan Dennedy <dan@dennedy.org>
+ *
+ * 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.
+ */
+
+#include <config.h>
+
+#include "raw1394.h"
+#include "csr.h"
+#include "kernel-raw1394.h"
+#include "raw1394_private.h"
+#include "../juju/juju.h"
+
+int raw1394_errcode_to_errno(raw1394_errcode_t errcode)
+{
+ return ieee1394_errcode_to_errno(errcode);
+}
+
+raw1394handle_t raw1394_new_handle(void)
+{
+ ieee1394handle_t ieee1394_handle = ieee1394_new_handle();
+ fw_handle_t fw_handle = NULL;
+ raw1394handle_t handle = NULL;
+
+ if (ieee1394_handle) {
+ struct raw1394_portinfo port;
+ if (ieee1394_get_port_info(ieee1394_handle, &port, 1) < 1) {
+ ieee1394_destroy_handle(ieee1394_handle);
+ ieee1394_handle = NULL;
+ fw_handle = fw_new_handle();
+ }
+ }
+ else {
+ fw_handle = fw_new_handle();
+ }
+ if (ieee1394_handle || fw_handle) {
+ handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle));
+ if (ieee1394_handle && handle) {
+ handle->is_fw = 0;
+ handle->mode.ieee1394 = ieee1394_handle;
+ }
+ else if (handle) {
+ handle->is_fw = 1;
+ handle->mode.fw = fw_handle;
+ }
+ }
+ return handle;
+}
+
+void raw1394_destroy_handle(raw1394handle_t handle)
+{
+ if (handle && handle->is_fw)
+ fw_destroy_handle(handle->mode.fw);
+ else
+ ieee1394_destroy_handle(handle->mode.ieee1394);;
+}
+
+raw1394handle_t raw1394_new_handle_on_port(int port)
+{
+ ieee1394handle_t ieee1394_handle = ieee1394_new_handle_on_port(port);
+ fw_handle_t fw_handle = NULL;
+ raw1394handle_t handle = NULL;
+
+ if (ieee1394_handle) {
+ handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle));
+ if (handle) {
+ handle->is_fw = 0;
+ handle->mode.ieee1394 = ieee1394_handle;
+ }
+ }
+ else if (fw_handle = fw_new_handle_on_port(port)) {
+ handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle));
+ if (handle) {
+ handle->is_fw = 1;
+ handle->mode.fw = fw_handle;
+ }
+ }
+ return handle;
+}
+
+int raw1394_busreset_notify (raw1394handle_t handle, int off_on_switch)
+{
+ if (handle && handle->is_fw)
+ return fw_busreset_notify(handle->mode.fw, off_on_switch);
+ else
+ return ieee1394_busreset_notify(handle->mode.ieee1394, off_on_switch);
+}
+
+int raw1394_get_fd(raw1394handle_t handle)
+{
+ if (handle && handle->is_fw)
+ return fw_get_fd(handle->mode.fw);
+ else
+ return ieee1394_get_fd(handle->mode.ieee1394);
+}
+
+nodeid_t raw1394_get_local_id(raw1394handle_t handle)
+{
+ if (handle && handle->is_fw)
+ return fw_get_local_id(handle->mode.fw);
+ else
+ return ieee1394_get_local_id(handle->mode.ieee1394);
+}
+
+nodeid_t raw1394_get_irm_id(raw1394handle_t handle)
+{
+ if (handle && handle->is_fw)
+ return fw_get_irm_id(handle->mode.fw);
+ else
+ return ieee1394_get_irm_id(handle->mode.ieee1394);
+}
+
+int raw1394_get_nodecount(raw1394handle_t handle)
+{
+ if (handle && handle->is_fw)
+ return fw_get_nodecount(handle->mode.fw);
+ else
+ return ieee1394_get_nodecount(handle->mode.ieee1394);
+}
+
+int raw1394_get_port_info(raw1394handle_t handle, struct raw1394_portinfo *pinf,
+ int maxports)
+{
+ if (handle && handle->is_fw)
+ return fw_get_port_info(handle->mode.fw, pinf, maxports);
+ else
+ return ieee1394_get_port_info(handle->mode.ieee1394, pinf, maxports);
+}
+
+int raw1394_set_port(raw1394handle_t handle, int port)
+{
+ if (handle && handle->is_fw)
+ return fw_set_port(handle->mode.fw, port);
+ else
+ return ieee1394_set_port(handle->mode.ieee1394, port);
+}
+
+int raw1394_reset_bus_new(raw1394handle_t handle, int type)
+{
+ if (handle && handle->is_fw)
+ return fw_reset_bus_new(handle->mode.fw, type);
+ else
+ return ieee1394_reset_bus_new(handle->mode.ieee1394, type);
+}
+
+int raw1394_loop_iterate(raw1394handle_t handle)
+{
+ if (handle && handle->is_fw)
+ return fw_loop_iterate(handle);
+ else
+ return ieee1394_loop_iterate(handle);
+}
+
+int raw1394_arm_register(raw1394handle_t handle, nodeaddr_t start,
+ size_t length, byte_t *initial_value,
+ octlet_t arm_tag, arm_options_t access_rights,
+ arm_options_t notification_options,
+ arm_options_t client_transactions)
+{
+ if (handle && handle->is_fw)
+ return fw_arm_register(handle->mode.fw, start, length, initial_value,
+ arm_tag, access_rights, notification_options, client_transactions);
+ else
+ return ieee1394_arm_register(handle->mode.ieee1394, start, length,
+ initial_value, arm_tag, access_rights, notification_options,
+ client_transactions);
+}
+
+int raw1394_arm_unregister(raw1394handle_t handle, nodeaddr_t start)
+{
+ if (handle && handle->is_fw)
+ return fw_arm_unregister(handle->mode.fw, start);
+ else
+ return ieee1394_arm_unregister(handle->mode.ieee1394, start);
+}
+
+int raw1394_arm_set_buf (raw1394handle_t handle, nodeaddr_t start,
+ size_t length, void *buf)
+{
+ if (handle && handle->is_fw)
+ return fw_arm_set_buf(handle->mode.fw, start, length, buf);
+ else
+ return ieee1394_arm_set_buf(handle->mode.ieee1394, start, length, buf);
+}
+
+int raw1394_arm_get_buf (raw1394handle_t handle, nodeaddr_t start,
+ size_t length, void *buf)
+{
+ if (handle && handle->is_fw)
+ return fw_arm_get_buf(handle->mode.fw, start, length, buf);
+ else
+ return ieee1394_arm_get_buf(handle->mode.ieee1394, start, length, buf);
+}
+
+int raw1394_echo_request(raw1394handle_t handle, quadlet_t data)
+{
+ if (handle && handle->is_fw)
+ return fw_echo_request(handle->mode.fw, data);
+ else
+ return ieee1394_echo_request(handle->mode.ieee1394, data);
+}
+
+int raw1394_wake_up(raw1394handle_t handle)
+{
+ if (handle && handle->is_fw)
+ return fw_wake_up(handle->mode.fw);
+ else
+ return ieee1394_wake_up(handle->mode.ieee1394);
+}
+
+int raw1394_phy_packet_write (raw1394handle_t handle, quadlet_t data)
+{
+ if (handle && handle->is_fw)
+ return fw_phy_packet_write(handle->mode.fw, data);
+ else
+ return ieee1394_phy_packet_write(handle, data);
+}
+
+int raw1394_start_phy_packet_write(raw1394handle_t handle,
+ quadlet_t data, unsigned long tag)
+{
+ if (handle && handle->is_fw)
+ return fw_start_phy_packet_write(handle->mode.fw, data, tag);
+ else
+ return ieee1394_start_phy_packet_write(handle->mode.ieee1394, data, tag);
+}
+
+int raw1394_start_read(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr,
+ size_t length, quadlet_t *buffer, unsigned long tag)
+{
+ if (handle && handle->is_fw)
+ return fw_start_read(handle->mode.fw, node, addr, length, buffer, tag);
+ else
+ return ieee1394_start_read(handle->mode.ieee1394, node, addr, length, buffer, tag);
+}
+
+int raw1394_start_write(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr,
+ size_t length, quadlet_t *data, unsigned long tag)
+{
+ if (handle && handle->is_fw)
+ return fw_start_write(handle->mode.fw, node, addr, length, data, tag);
+ else
+ return ieee1394_start_write(handle->mode.ieee1394, node, addr, length, data, tag);
+}
+
+int raw1394_start_lock(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr,
+ unsigned int extcode, quadlet_t data, quadlet_t arg,
+ quadlet_t *result, unsigned long tag)
+{
+ if (handle && handle->is_fw)
+ return fw_start_lock(handle->mode.fw, node, addr, extcode, data, arg, result, tag);
+ else
+ return ieee1394_start_lock(handle->mode.ieee1394, node, addr, extcode, data, arg, result, tag);
+}
+
+int raw1394_start_lock64(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr,
+ unsigned int extcode, octlet_t data, octlet_t arg,
+ octlet_t *result, unsigned long tag)
+{
+ if (handle && handle->is_fw)
+ return fw_start_lock64(handle->mode.fw, node, addr, extcode, data, arg, result, tag);
+ else
+ return ieee1394_start_lock64(handle->mode.ieee1394, node, addr, extcode, data, arg, result, tag);
+}
+
+int raw1394_start_async_stream(raw1394handle_t handle, unsigned int channel,
+ unsigned int tag, unsigned int sy,
+ unsigned int speed, size_t length, quadlet_t *data,
+ unsigned long rawtag)
+{
+ if (handle && handle->is_fw)
+ return fw_start_async_stream(handle->mode.fw, channel, tag, sy, speed, length, data, rawtag);
+ else
+ return ieee1394_start_async_stream(handle->mode.ieee1394, channel, tag, sy, speed, length, data, rawtag);
+}
+
+int raw1394_start_async_send(raw1394handle_t handle,
+ size_t length, size_t header_length,
+ unsigned int expect_response,
+ quadlet_t *data, unsigned long rawtag)
+{
+ if (handle && handle->is_fw)
+ return fw_start_async_send(handle->mode.fw, length, header_length,
+ expect_response, data, rawtag);
+ else
+ return ieee1394_start_async_send(handle->mode.ieee1394, length,
+ header_length, expect_response, data, rawtag);
+}
+
+int raw1394_read(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr,
+ size_t length, quadlet_t *buffer)
+{
+ if (handle && handle->is_fw)
+ return fw_read(handle, node, addr, length, buffer);
+ else
+ return ieee1394_read(handle, node, addr, length, buffer);
+}
+
+int raw1394_write(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr,
+ size_t length, quadlet_t *data)
+{
+ if (handle && handle->is_fw)
+ return fw_write(handle, node, addr, length, data);
+ else
+ return ieee1394_write(handle, node, addr, length, data);
+}
+
+int raw1394_lock(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr,
+ unsigned int extcode, quadlet_t data, quadlet_t arg,
+ quadlet_t *result)
+{
+ if (handle && handle->is_fw)
+ return fw_lock(handle, node, addr, extcode, data, arg, result);
+ else
+ return ieee1394_lock(handle, node, addr, extcode, data, arg, result);
+}
+
+int raw1394_lock64(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr,
+ unsigned int extcode, octlet_t data, octlet_t arg,
+ octlet_t *result)
+{
+ if (handle && handle->is_fw)
+ return fw_lock64(handle, node, addr, extcode, data, arg, result);
+ else
+ return ieee1394_lock64(handle, node, addr, extcode, data, arg, result);
+}
+
+int raw1394_async_stream(raw1394handle_t handle, unsigned int channel,
+ unsigned int tag, unsigned int sy, unsigned int speed,
+ size_t length, quadlet_t *data)
+{
+ if (handle && handle->is_fw)
+ return fw_async_stream(handle->mode.fw, channel, tag, sy, speed, length, data);
+ else
+ return ieee1394_async_stream(handle, channel, tag, sy, speed, length, data);
+}
+
+int raw1394_async_send(raw1394handle_t handle,
+ size_t length, size_t header_length,
+ unsigned int expect_response,
+ quadlet_t *data)
+{
+ if (handle && handle->is_fw)
+ return fw_async_send(handle->mode.fw, length, header_length,
+ expect_response, data);
+ else
+ return ieee1394_async_send(handle, length, header_length,
+ expect_response, data);
+}
+
+int raw1394_start_fcp_listen(raw1394handle_t handle)
+{
+ if (handle && handle->is_fw)
+ return fw_start_fcp_listen(handle->mode.fw);
+ else
+ return ieee1394_start_fcp_listen(handle);
+}
+
+int raw1394_stop_fcp_listen(raw1394handle_t handle)
+{
+ if (handle && handle->is_fw)
+ return fw_stop_fcp_listen(handle->mode.fw);
+ else
+ return ieee1394_stop_fcp_listen(handle);
+}
+
+int raw1394_update_config_rom(raw1394handle_t handle, const quadlet_t
+ *new_rom, size_t size, unsigned char rom_version)
+{
+ if (handle && handle->is_fw)
+ return fw_update_config_rom(handle->mode.fw, new_rom, size, rom_version);
+ else
+ return ieee1394_update_config_rom(handle->mode.ieee1394,
+ new_rom, size, rom_version);
+}
+
+int raw1394_get_config_rom(raw1394handle_t handle, quadlet_t *buffer,
+ size_t buffersize, size_t *rom_size, unsigned char *rom_version)
+{
+ if (handle && handle->is_fw)
+ return fw_get_config_rom(handle->mode.fw, buffer, buffersize,
+ rom_size, rom_version);
+ else
+ return ieee1394_get_config_rom(handle->mode.ieee1394, buffer,
+ buffersize, rom_size, rom_version);
+}
+
+int raw1394_bandwidth_modify (raw1394handle_t handle, unsigned int bandwidth,
+ enum raw1394_modify_mode mode)
+{
+ if (handle && handle->is_fw)
+ return fw_bandwidth_modify(handle, bandwidth, mode);
+ else
+ return ieee1394_bandwidth_modify(handle, bandwidth, mode);
+}
+
+int raw1394_channel_modify (raw1394handle_t handle, unsigned int channel,
+ enum raw1394_modify_mode mode)
+{
+ if (handle && handle->is_fw)
+ return fw_channel_modify(handle, channel, mode);
+ else
+ return ieee1394_channel_modify(handle, channel, mode);
+}
+
+int raw1394_iso_xmit_init(raw1394handle_t handle,
+ raw1394_iso_xmit_handler_t handler,
+ unsigned int buf_packets,
+ unsigned int max_packet_size,
+ unsigned char channel,
+ enum raw1394_iso_speed speed,
+ int irq_interval)
+{
+ if (handle && handle->is_fw)
+ return fw_iso_xmit_init(handle->mode.fw, handler, buf_packets,
+ max_packet_size, channel, speed, irq_interval);
+ else
+ return ieee1394_iso_xmit_init(handle->mode.ieee1394, handler, buf_packets,
+ max_packet_size, channel, speed, irq_interval);
+}
+
+int raw1394_iso_recv_init(raw1394handle_t handle,
+ raw1394_iso_recv_handler_t handler,
+ unsigned int buf_packets,
+ unsigned int max_packet_size,
+ unsigned char channel,
+ enum raw1394_iso_dma_recv_mode mode,
+ int irq_interval)
+{
+ if (handle && handle->is_fw)
+ return fw_iso_recv_init(handle->mode.fw, handler, buf_packets,
+ max_packet_size, channel, mode, irq_interval);
+ else
+ return ieee1394_iso_recv_init(handle->mode.ieee1394, handler, buf_packets,
+ max_packet_size, channel, mode, irq_interval);
+}
+
+int raw1394_iso_multichannel_recv_init(raw1394handle_t handle,
+ raw1394_iso_recv_handler_t handler,
+ unsigned int buf_packets,
+ unsigned int max_packet_size,
+ int irq_interval)
+{
+ if (handle && handle->is_fw)
+ return fw_iso_multichannel_recv_init(handle->mode.fw, handler, buf_packets,
+ max_packet_size, irq_interval);
+ else
+ return ieee1394_iso_multichannel_recv_init(handle->mode.ieee1394, handler,
+ buf_packets, max_packet_size, irq_interval);
+}
+
+int raw1394_iso_recv_listen_channel(raw1394handle_t handle,
+ unsigned char channel)
+{
+ if (handle && handle->is_fw)
+ return fw_iso_recv_listen_channel(handle->mode.fw, channel);
+ else
+ return ieee1394_iso_recv_listen_channel(handle->mode.ieee1394, channel);
+}
+
+int raw1394_iso_recv_unlisten_channel(raw1394handle_t handle,
+ unsigned char channel)
+{
+ if (handle && handle->is_fw)
+ return fw_iso_recv_unlisten_channel(handle->mode.fw, channel);
+ else
+ return ieee1394_iso_recv_unlisten_channel(handle->mode.ieee1394, channel);
+}
+
+int raw1394_iso_recv_set_channel_mask(raw1394handle_t handle, u_int64_t mask)
+{
+ if (handle && handle->is_fw)
+ return fw_iso_recv_set_channel_mask(handle->mode.fw, mask);
+ else
+ return ieee1394_iso_recv_set_channel_mask(handle->mode.ieee1394, mask);
+}
+
+int raw1394_iso_xmit_start(raw1394handle_t handle, int start_on_cycle,
+ int prebuffer_packets)
+{
+ if (handle && handle->is_fw)
+ return fw_iso_xmit_start(handle,
+ start_on_cycle, prebuffer_packets);
+ else
+ return ieee1394_iso_xmit_start(handle->mode.ieee1394,
+ start_on_cycle, prebuffer_packets);
+}
+
+int raw1394_iso_recv_start(raw1394handle_t handle, int start_on_cycle,
+ int tag_mask, int sync)
+{
+ if (handle && handle->is_fw)
+ return fw_iso_recv_start(handle->mode.fw,
+ start_on_cycle, tag_mask, sync);
+ else
+ return ieee1394_iso_recv_start(handle->mode.ieee1394,
+ start_on_cycle, tag_mask, sync);
+}
+
+int raw1394_iso_xmit_write(raw1394handle_t handle, unsigned char *data,
+ unsigned int len, unsigned char tag,
+ unsigned char sy)
+{
+ if (handle && handle->is_fw)
+ return fw_iso_xmit_write(handle, data, len, tag, sy);
+ else
+ return ieee1394_iso_xmit_write(handle, data, len, tag, sy);
+}
+
+int raw1394_iso_xmit_sync(raw1394handle_t handle)
+{
+ if (handle && handle->is_fw)
+ return fw_iso_xmit_sync(handle);
+ else
+ return ieee1394_iso_xmit_sync(handle->mode.ieee1394);
+}
+
+int raw1394_iso_recv_flush(raw1394handle_t handle)
+{
+ if (handle && handle->is_fw)
+ return fw_iso_recv_flush(handle->mode.fw);
+ else
+ return ieee1394_iso_recv_flush(handle->mode.ieee1394);
+}
+
+void raw1394_iso_stop(raw1394handle_t handle)
+{
+ if (handle && handle->is_fw)
+ fw_iso_stop(handle->mode.fw);
+ else
+ ieee1394_iso_stop(handle->mode.ieee1394);
+}
+
+void raw1394_iso_shutdown(raw1394handle_t handle)
+{
+ if (handle && handle->is_fw)
+ fw_iso_shutdown(handle->mode.fw);
+ else
+ ieee1394_iso_shutdown(handle->mode.ieee1394);
+}
diff --git a/src/errors.c b/src/errors.c
index 63db73d..e69c131 100644
--- a/src/errors.c
+++ b/src/errors.c
@@ -19,10 +19,13 @@
raw1394_errcode_t raw1394_get_errcode(struct raw1394_handle *handle)
{
- return handle->err;
+ if (handle && handle->is_fw)
+ return handle->mode.fw->err;
+ else
+ return handle->mode.ieee1394->err;
}
-int raw1394_errcode_to_errno(raw1394_errcode_t errcode)
+int ieee1394_errcode_to_errno(raw1394_errcode_t errcode)
{
static const int ack2errno[16] = {
0xdead, /* invalid ack code */
diff --git a/src/eventloop.c b/src/eventloop.c
index 4a027b2..78e581a 100644
--- a/src/eventloop.c
+++ b/src/eventloop.c
@@ -28,57 +28,45 @@
#include "raw1394_private.h"
-int raw1394_loop_iterate(struct raw1394_handle *handle)
+int ieee1394_loop_iterate(struct raw1394_handle *handle)
{
struct raw1394_request req;
+ ieee1394handle_t ihandle = handle->mode.ieee1394;
int retval = 0, channel;
- while (read(handle->fd, &req, sizeof(req)) < 0) {
+ while (read(ihandle->fd, &req, sizeof(req)) < 0) {
if (errno != EINTR) return -1;
}
switch (req.type) {
case RAW1394_REQ_BUS_RESET:
- if (handle->protocol_version == 3) {
- handle->num_of_nodes = req.misc & 0xffff;
- handle->local_id = req.misc >> 16;
+ if (ihandle->protocol_version == 3) {
+ ihandle->num_of_nodes = req.misc & 0xffff;
+ ihandle->local_id = req.misc >> 16;
} else {
- handle->num_of_nodes = req.misc & 0xff;
- handle->irm_id = ((req.misc >> 8) & 0xff) | 0xffc0;
- handle->local_id = req.misc >> 16;
+ ihandle->num_of_nodes = req.misc & 0xff;
+ ihandle->irm_id = ((req.misc >> 8) & 0xff) | 0xffc0;
+ ihandle->local_id = req.misc >> 16;
}
- if (handle->bus_reset_handler) {
- retval = handle->bus_reset_handler(handle,
+ if (ihandle->bus_reset_handler) {
+ retval = ihandle->bus_reset_handler(handle,
req.generation);
}
break;
- case RAW1394_REQ_ISO_RECEIVE:
- channel = (handle->buffer[0] >> 8) & 0x3f;
-#ifndef WORDS_BIGENDIAN
- handle->buffer[0] = bswap_32(handle->buffer[0]);
-#endif
-
- if (handle->iso_handler[channel]) {
- retval = handle->iso_handler[channel](handle, channel,
- req.length,
- handle->buffer);
- }
- break;
-
case RAW1394_REQ_FCP_REQUEST:
- if (handle->fcp_handler) {
- retval = handle->fcp_handler(handle, req.misc & 0xffff,
+ if (ihandle->fcp_handler) {
+ retval = ihandle->fcp_handler(handle, req.misc & 0xffff,
req.misc >> 16,
req.length,
- (unsigned char *)handle->buffer);
+ (unsigned char *)ihandle->buffer);
}
break;
case RAW1394_REQ_ARM:
- if (handle->arm_tag_handler) {
- retval = handle->arm_tag_handler(handle, req.tag,
+ if (ihandle->arm_tag_handler) {
+ retval = ihandle->arm_tag_handler(handle, req.tag,
(req.misc & (0xFF)),
((req.misc >> 16) & (0xFFFF)),
int2ptr(req.recvb));
@@ -90,12 +78,12 @@ int raw1394_loop_iterate(struct raw1394_handle *handle)
break;
case RAW1394_REQ_RAWISO_ACTIVITY:
- retval = _raw1394_iso_iterate(handle);
+ retval = _ieee1394_iso_iterate(handle);
break;
default:
- if (handle->tag_handler) {
- retval = handle->tag_handler(handle, req.tag,
+ if (ihandle->tag_handler) {
+ retval = ihandle->tag_handler(handle, req.tag,
req.error);
}
break;
@@ -108,65 +96,59 @@ int raw1394_loop_iterate(struct raw1394_handle *handle)
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;
+ 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;
}
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;
+ 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;
}
arm_tag_handler_t raw1394_set_arm_tag_handler(struct raw1394_handle *handle,
arm_tag_handler_t new)
{
- arm_tag_handler_t old;
-
- old = handle->arm_tag_handler;
- handle->arm_tag_handler = new;
-
- return old;
-}
-
-
-iso_handler_t raw1394_set_iso_handler(struct raw1394_handle *handle,
- unsigned int channel, iso_handler_t new)
-{
- 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;
- }
-
- if (handle->iso_handler[channel] != NULL) {
- return (iso_handler_t)-1;
- }
-
- handle->iso_handler[channel] = new;
- return NULL;
+ 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;
}
fcp_handler_t raw1394_set_fcp_handler(struct raw1394_handle *handle,
fcp_handler_t new)
{
- fcp_handler_t old;
-
- old = handle->fcp_handler;
- handle->fcp_handler = new;
-
- return old;
+ 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;
}
diff --git a/src/fcp.c b/src/fcp.c
index 79939be..36c909c 100644
--- a/src/fcp.c
+++ b/src/fcp.c
@@ -19,6 +19,7 @@
static int do_fcp_listen(struct raw1394_handle *handle, int startstop)
{
+ ieee1394handle_t ihandle = handle->mode.ieee1394;
struct sync_cb_data sd = { 0, 0 };
struct raw1394_reqhandle rh = { (req_callback_t)_raw1394_sync_cb, &sd };
int err;
@@ -26,16 +27,16 @@ static int do_fcp_listen(struct raw1394_handle *handle, int startstop)
CLEAR_REQ(&req);
req.type = RAW1394_REQ_FCP_LISTEN;
- req.generation = handle->generation;
+ req.generation = ihandle->generation;
req.misc = startstop;
req.tag = ptr2int(&rh);
- req.recvb = ptr2int(handle->buffer);
+ req.recvb = ptr2int(ihandle->buffer);
req.length = 512;
- err = write(handle->fd, &req, sizeof(req));
+ err = write(ihandle->fd, &req, sizeof(req));
while (!sd.done) {
if (err < 0) return err;
- err = raw1394_loop_iterate(handle);
+ err = ieee1394_loop_iterate(handle);
}
switch (sd.errcode) {
@@ -54,12 +55,12 @@ static int do_fcp_listen(struct raw1394_handle *handle, int startstop)
}
-int raw1394_start_fcp_listen(struct raw1394_handle *handle)
+int ieee1394_start_fcp_listen(struct raw1394_handle *handle)
{
return do_fcp_listen(handle, 1);
}
-int raw1394_stop_fcp_listen(struct raw1394_handle *handle)
+int ieee1394_stop_fcp_listen(struct raw1394_handle *handle)
{
return do_fcp_listen(handle, 0);
}
diff --git a/src/iso.c b/src/iso.c
index a16196a..9b62ac1 100644
--- a/src/iso.c
+++ b/src/iso.c
@@ -34,71 +34,8 @@ static inline int increment_and_wrap(int x, int n)
return x;
}
-/* old ISO API - kept for backwards compatibility */
-
-static int do_iso_listen(struct raw1394_handle *handle, int channel)
-{
- struct sync_cb_data sd = { 0, 0 };
- struct raw1394_reqhandle rh = { (req_callback_t)_raw1394_sync_cb, &sd };
- int err;
- struct raw1394_request req;
-
- CLEAR_REQ(&req);
- req.type = RAW1394_REQ_ISO_LISTEN;
- req.generation = handle->generation;
- req.misc = channel;
- req.tag = ptr2int(&rh);
- req.recvb = ptr2int(handle->buffer);
- req.length = HBUF_SIZE;
-
- 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_iso_rcv(struct raw1394_handle *handle, unsigned int channel)
-{
- if (channel > 63) {
- errno = EINVAL;
- return -1;
- }
-
- return do_iso_listen(handle, channel);
-}
-
-int raw1394_stop_iso_rcv(struct raw1394_handle *handle, unsigned int channel)
-{
- if (channel > 63) {
- errno = EINVAL;
- return -1;
- }
-
- return do_iso_listen(handle, ~channel);
-}
-
-
-
-/* new ISO API */
-
-
/* reset the dropped counter each time it is seen */
-static unsigned int _raw1394_iso_dropped(raw1394handle_t handle)
+static unsigned int _iso_dropped(ieee1394handle_t handle)
{
unsigned int retval = handle->iso_packets_dropped;
handle->iso_packets_dropped = 0;
@@ -107,7 +44,7 @@ static unsigned int _raw1394_iso_dropped(raw1394handle_t handle)
/* common code for iso_xmit_init and iso_recv_init */
-static int do_iso_init(raw1394handle_t handle,
+static int do_iso_init(ieee1394handle_t handle,
unsigned int buf_packets,
unsigned int max_packet_size,
int channel,
@@ -185,7 +122,7 @@ static int do_iso_init(raw1394handle_t handle,
return 0;
}
-int raw1394_iso_xmit_init(raw1394handle_t handle,
+int ieee1394_iso_xmit_init(ieee1394handle_t handle,
raw1394_iso_xmit_handler_t handler,
unsigned int buf_packets,
unsigned int max_packet_size,
@@ -204,12 +141,12 @@ int raw1394_iso_xmit_init(raw1394handle_t handle,
return 0;
}
-int raw1394_iso_recv_init(raw1394handle_t handle,
+int ieee1394_iso_recv_init(ieee1394handle_t handle,
raw1394_iso_recv_handler_t handler,
unsigned int buf_packets,
unsigned int max_packet_size,
unsigned char channel,
- enum raw1394_iso_dma_recv_mode mode,
+ enum raw1394_iso_dma_recv_mode mode,
int irq_interval)
{
/* any speed will work */
@@ -222,7 +159,7 @@ int raw1394_iso_recv_init(raw1394handle_t handle,
return 0;
}
-int raw1394_iso_multichannel_recv_init(raw1394handle_t handle,
+int ieee1394_iso_multichannel_recv_init(ieee1394handle_t handle,
raw1394_iso_recv_handler_t handler,
unsigned int buf_packets,
unsigned int max_packet_size,
@@ -239,7 +176,7 @@ int raw1394_iso_multichannel_recv_init(raw1394handle_t handle,
return 0;
}
-int raw1394_iso_recv_listen_channel(raw1394handle_t handle, unsigned char channel)
+int ieee1394_iso_recv_listen_channel(ieee1394handle_t handle, unsigned char channel)
{
if (handle->iso_mode != ISO_RECV) {
errno = EINVAL;
@@ -249,7 +186,7 @@ int raw1394_iso_recv_listen_channel(raw1394handle_t handle, unsigned char channe
return ioctl(handle->fd, RAW1394_IOC_ISO_RECV_LISTEN_CHANNEL, channel);
}
-int raw1394_iso_recv_unlisten_channel(raw1394handle_t handle, unsigned char channel)
+int ieee1394_iso_recv_unlisten_channel(ieee1394handle_t handle, unsigned char channel)
{
if (handle->iso_mode != ISO_RECV) {
errno = EINVAL;
@@ -259,7 +196,7 @@ int raw1394_iso_recv_unlisten_channel(raw1394handle_t handle, unsigned char chan
return ioctl(handle->fd, RAW1394_IOC_ISO_RECV_UNLISTEN_CHANNEL, channel);
}
-int raw1394_iso_recv_flush(raw1394handle_t handle)
+int ieee1394_iso_recv_flush(ieee1394handle_t handle)
{
if (handle->iso_mode != ISO_RECV) {
errno = EINVAL;
@@ -269,7 +206,7 @@ int raw1394_iso_recv_flush(raw1394handle_t handle)
return ioctl(handle->fd, RAW1394_IOC_ISO_RECV_FLUSH, 0);
}
-int raw1394_iso_recv_set_channel_mask(raw1394handle_t handle, u_int64_t mask)
+int ieee1394_iso_recv_set_channel_mask(ieee1394handle_t handle, u_int64_t mask)
{
if (handle->iso_mode != ISO_RECV) {
errno = EINVAL;
@@ -279,7 +216,7 @@ int raw1394_iso_recv_set_channel_mask(raw1394handle_t handle, u_int64_t mask)
return ioctl(handle->fd, RAW1394_IOC_ISO_RECV_SET_CHANNEL_MASK, (void*) &mask);
}
-int raw1394_iso_recv_start(raw1394handle_t handle, int start_on_cycle, int tag_mask, int sync)
+int ieee1394_iso_recv_start(ieee1394handle_t handle, int start_on_cycle, int tag_mask, int sync)
{
int args[3];
@@ -299,14 +236,15 @@ int raw1394_iso_recv_start(raw1394handle_t handle, int start_on_cycle, int tag_m
return 0;
}
-static int _raw1394_iso_xmit_queue_packets(raw1394handle_t handle)
+static int _iso_xmit_queue_packets(raw1394handle_t handle)
{
- struct raw1394_iso_status *stat = &handle->iso_status;
+ ieee1394handle_t ihandle = handle->mode.ieee1394;
+ struct raw1394_iso_status *stat = &ihandle->iso_status;
struct raw1394_iso_packets packets;
int retval = -1;
int stop_sync = 0;
- if(handle->iso_mode != ISO_XMIT) {
+ if(ihandle->iso_mode != ISO_XMIT) {
errno = EINVAL;
goto out;
}
@@ -317,7 +255,7 @@ static int _raw1394_iso_xmit_queue_packets(raw1394handle_t handle)
/* we could potentially send up to stat->n_packets packets */
packets.n_packets = 0;
- packets.infos = handle->iso_packet_infos;
+ packets.infos = ihandle->iso_packet_infos;
if(packets.infos == NULL)
goto out;
@@ -327,27 +265,27 @@ static int _raw1394_iso_xmit_queue_packets(raw1394handle_t handle)
struct raw1394_iso_packet_info *info = &packets.infos[packets.n_packets];
- info->offset = handle->iso_buf_stride * handle->next_packet;
+ info->offset = ihandle->iso_buf_stride * ihandle->next_packet;
/* call handler */
- disp = handle->iso_xmit_handler(handle,
- handle->iso_buffer + info->offset,
+ disp = ihandle->iso_xmit_handler(handle,
+ ihandle->iso_buffer + info->offset,
&len,
&info->tag, &info->sy,
stat->xmit_cycle,
- _raw1394_iso_dropped(handle));
+ _iso_dropped(ihandle));
info->len = len;
/* advance packet cursors and cycle counter */
stat->n_packets--;
- handle->next_packet = increment_and_wrap(handle->next_packet, stat->config.buf_packets);
+ ihandle->next_packet = increment_and_wrap(ihandle->next_packet, stat->config.buf_packets);
if(stat->xmit_cycle != -1)
stat->xmit_cycle = increment_and_wrap(stat->xmit_cycle, 8000);
packets.n_packets++;
if(disp == RAW1394_ISO_DEFER) {
/* queue an event so that we don't hang in the next read() */
- if(ioctl(handle->fd, RAW1394_IOC_ISO_QUEUE_ACTIVITY, 0))
+ if(ioctl(ihandle->fd, RAW1394_IOC_ISO_QUEUE_ACTIVITY, 0))
goto out_produce;
break;
} else if(disp == RAW1394_ISO_AGAIN) {
@@ -355,14 +293,14 @@ static int _raw1394_iso_xmit_queue_packets(raw1394handle_t handle)
packets.n_packets--;
/* queue an event so that we don't hang in the next read() */
- if(ioctl(handle->fd, RAW1394_IOC_ISO_QUEUE_ACTIVITY, 0))
+ if(ioctl(ihandle->fd, RAW1394_IOC_ISO_QUEUE_ACTIVITY, 0))
goto out_produce;
break;
} else if(disp == RAW1394_ISO_STOP) {
stop_sync = 1;
break;
} else if(disp == RAW1394_ISO_STOP_NOSYNC) {
- raw1394_iso_stop(handle);
+ ieee1394_iso_stop(ihandle);
break;
} else if(disp == RAW1394_ISO_ERROR) {
goto out_produce;
@@ -374,68 +312,69 @@ static int _raw1394_iso_xmit_queue_packets(raw1394handle_t handle)
out_produce:
if(packets.n_packets > 0) {
- if(ioctl(handle->fd, RAW1394_IOC_ISO_XMIT_PACKETS, &packets))
+ if(ioctl(ihandle->fd, RAW1394_IOC_ISO_XMIT_PACKETS, &packets))
retval = -1;
}
out:
if(stop_sync) {
- if(raw1394_iso_xmit_sync(handle))
+ if(ieee1394_iso_xmit_sync(ihandle))
return -1;
- raw1394_iso_stop(handle);
+ ieee1394_iso_stop(ihandle);
}
return retval;
}
-int raw1394_iso_xmit_write(raw1394handle_t handle, unsigned char *data, unsigned int len,
+int ieee1394_iso_xmit_write(raw1394handle_t handle, unsigned char *data, unsigned int len,
unsigned char tag, unsigned char sy)
{
- struct raw1394_iso_status *stat = &handle->iso_status;
+ ieee1394handle_t ihandle = handle->mode.ieee1394;
+ struct raw1394_iso_status *stat = &ihandle->iso_status;
struct raw1394_iso_packets packets;
struct raw1394_iso_packet_info info;
- if(handle->iso_mode != ISO_XMIT || handle->iso_xmit_handler != NULL) {
+ if(ihandle->iso_mode != ISO_XMIT || ihandle->iso_xmit_handler != NULL) {
errno = EINVAL;
return -1;
}
/* wait until buffer space is available */
- while(handle->iso_status.n_packets <= 1) {
+ while(ihandle->iso_status.n_packets <= 1) {
/* if the file descriptor has been set non-blocking,
return immediately */
- if(fcntl(handle->fd, F_GETFL) & O_NONBLOCK) {
+ if(fcntl(ihandle->fd, F_GETFL) & O_NONBLOCK) {
errno = EAGAIN;
return -1;
}
- if(raw1394_loop_iterate(handle)) {
+ if(ieee1394_loop_iterate(handle)) {
return -1;
}
}
/* copy the data to the packet buffer */
- info.offset = handle->next_packet * handle->iso_buf_stride;
+ info.offset = ihandle->next_packet * ihandle->iso_buf_stride;
info.len = len;
info.tag = tag;
info.sy = sy;
- memcpy(handle->iso_buffer + info.offset, data, len);
+ memcpy(ihandle->iso_buffer + info.offset, data, len);
packets.n_packets = 1;
packets.infos = &info;
- if(ioctl(handle->fd, RAW1394_IOC_ISO_XMIT_PACKETS, &packets))
+ if(ioctl(ihandle->fd, RAW1394_IOC_ISO_XMIT_PACKETS, &packets))
return -1;
stat->n_packets--;
- handle->next_packet = increment_and_wrap(handle->next_packet, stat->config.buf_packets);
+ ihandle->next_packet = increment_and_wrap(ihandle->next_packet, stat->config.buf_packets);
if(stat->xmit_cycle != -1)
stat->xmit_cycle = increment_and_wrap(stat->xmit_cycle, 8000);
return 0;
}
-int raw1394_iso_xmit_start(raw1394handle_t handle, int start_on_cycle, int prebuffer_packets)
+int ieee1394_iso_xmit_start(ieee1394handle_t handle, int start_on_cycle, int prebuffer_packets)
{
int args[2];
@@ -454,7 +393,7 @@ int raw1394_iso_xmit_start(raw1394handle_t handle, int start_on_cycle, int prebu
return 0;
}
-int raw1394_iso_xmit_sync(raw1394handle_t handle)
+int ieee1394_iso_xmit_sync(ieee1394handle_t handle)
{
if(handle->iso_mode != ISO_XMIT) {
errno = EINVAL;
@@ -463,7 +402,7 @@ int raw1394_iso_xmit_sync(raw1394handle_t handle)
return ioctl(handle->fd, RAW1394_IOC_ISO_XMIT_SYNC, 0);
}
-void raw1394_iso_stop(raw1394handle_t handle)
+void ieee1394_iso_stop(ieee1394handle_t handle)
{
if(handle->iso_mode == ISO_INACTIVE) {
return;
@@ -473,7 +412,7 @@ void raw1394_iso_stop(raw1394handle_t handle)
handle->iso_state = ISO_STOP;
}
-void raw1394_iso_shutdown(raw1394handle_t handle)
+void ieee1394_iso_shutdown(ieee1394handle_t handle)
{
if(handle->iso_buffer) {
munmap(handle->iso_buffer, handle->iso_status.config.data_buf_size);
@@ -481,7 +420,7 @@ void raw1394_iso_shutdown(raw1394handle_t handle)
}
if(handle->iso_mode != ISO_INACTIVE) {
- raw1394_iso_stop(handle);
+ ieee1394_iso_stop(handle);
ioctl(handle->fd, RAW1394_IOC_ISO_SHUTDOWN, 0);
}
@@ -498,7 +437,7 @@ void raw1394_iso_shutdown(raw1394handle_t handle)
handle->iso_mode = ISO_INACTIVE;
}
-int raw1394_read_cycle_timer(raw1394handle_t handle,
+int ieee1394_read_cycle_timer(ieee1394handle_t handle,
u_int32_t *cycle_timer, u_int64_t *local_time)
{
int err;
@@ -512,25 +451,26 @@ int raw1394_read_cycle_timer(raw1394handle_t handle,
return err;
}
-static int _raw1394_iso_recv_packets(raw1394handle_t handle)
+static int _iso_recv_packets(raw1394handle_t handle)
{
- struct raw1394_iso_status *stat = &handle->iso_status;
+ ieee1394handle_t ihandle = handle->mode.ieee1394;
+ struct raw1394_iso_status *stat = &ihandle->iso_status;
struct raw1394_iso_packets packets;
int retval = -1, packets_done = 0;
- if(handle->iso_mode != ISO_RECV) {
+ if(ihandle->iso_mode != ISO_RECV) {
errno = EINVAL;
return -1;
}
/* ask the kernel to fill an array with packet info structs */
packets.n_packets = stat->n_packets;
- packets.infos = handle->iso_packet_infos;
+ packets.infos = ihandle->iso_packet_infos;
if(packets.infos == NULL)
goto out;
- if(ioctl(handle->fd, RAW1394_IOC_ISO_RECV_PACKETS, &packets) < 0)
+ if(ioctl(ihandle->fd, RAW1394_IOC_ISO_RECV_PACKETS, &packets) < 0)
goto out;
while(stat->n_packets > 0) {
@@ -540,12 +480,12 @@ static int _raw1394_iso_recv_packets(raw1394handle_t handle)
info = &packets.infos[packets_done];
/* call handler */
- disp = handle->iso_recv_handler(handle,
- handle->iso_buffer + info->offset,
+ disp = ihandle->iso_recv_handler(handle,
+ ihandle->iso_buffer + info->offset,
info->len, info->channel,
info->tag, info->sy,
info->cycle,
- _raw1394_iso_dropped(handle));
+ _iso_dropped(ihandle));
/* advance packet cursors */
stat->n_packets--;
@@ -553,11 +493,11 @@ static int _raw1394_iso_recv_packets(raw1394handle_t handle)
if(disp == RAW1394_ISO_DEFER) {
/* queue an event so that we don't hang in the next read() */
- if(ioctl(handle->fd, RAW1394_IOC_ISO_QUEUE_ACTIVITY, 0))
+ if(ioctl(ihandle->fd, RAW1394_IOC_ISO_QUEUE_ACTIVITY, 0))
goto out_consume;
break;
} else if(disp == RAW1394_ISO_STOP || disp == RAW1394_ISO_STOP_NOSYNC) {
- raw1394_iso_stop(handle);
+ ieee1394_iso_stop(ihandle);
break;
} else if(disp == RAW1394_ISO_ERROR) {
goto out_consume;
@@ -569,7 +509,7 @@ static int _raw1394_iso_recv_packets(raw1394handle_t handle)
out_consume:
if(packets_done > 0) {
- if(ioctl(handle->fd, RAW1394_IOC_ISO_RECV_RELEASE_PACKETS, packets_done))
+ if(ioctl(ihandle->fd, RAW1394_IOC_ISO_RECV_RELEASE_PACKETS, packets_done))
retval = -1;
}
out:
@@ -577,29 +517,30 @@ out:
}
/* run the ISO state machine; called from raw1394_loop_iterate() */
-int _raw1394_iso_iterate(raw1394handle_t handle)
+int _ieee1394_iso_iterate(raw1394handle_t handle)
{
+ ieee1394handle_t ihandle = handle->mode.ieee1394;
int err;
- if(handle->iso_mode == ISO_INACTIVE)
+ if(ihandle->iso_mode == ISO_INACTIVE)
return 0;
- err = ioctl(handle->fd, RAW1394_IOC_ISO_GET_STATUS, &handle->iso_status);
+ err = ioctl(ihandle->fd, RAW1394_IOC_ISO_GET_STATUS, &ihandle->iso_status);
if(err != 0)
return err;
- handle->iso_packets_dropped += handle->iso_status.overflows;
+ ihandle->iso_packets_dropped += ihandle->iso_status.overflows;
- if(handle->iso_state == ISO_GO) {
- if(handle->iso_mode == ISO_XMIT) {
- if(handle->iso_xmit_handler) {
- return _raw1394_iso_xmit_queue_packets(handle);
+ if(ihandle->iso_state == ISO_GO) {
+ if(ihandle->iso_mode == ISO_XMIT) {
+ if(ihandle->iso_xmit_handler) {
+ return _iso_xmit_queue_packets(handle);
}
}
- if(handle->iso_mode == ISO_RECV) {
- if(handle->iso_recv_handler) {
- return _raw1394_iso_recv_packets(handle);
+ if(ihandle->iso_mode == ISO_RECV) {
+ if(ihandle->iso_recv_handler) {
+ return _iso_recv_packets(handle);
}
}
}
diff --git a/src/main.c b/src/main.c
index a14fa97..01b715a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -84,7 +84,7 @@ int _raw1394_sync_cb(struct raw1394_handle *unused, struct sync_cb_data *data,
-static unsigned int init_rawdevice(struct raw1394_handle *h)
+static unsigned int init_rawdevice(struct ieee1394_handle *h)
{
struct raw1394_request req;
@@ -112,12 +112,12 @@ static unsigned int init_rawdevice(struct raw1394_handle *h)
}
-struct raw1394_handle *raw1394_new_handle(void)
+struct ieee1394_handle *ieee1394_new_handle(void)
{
- struct raw1394_handle *handle;
+ struct ieee1394_handle *handle;
const char *defaultDevice = "/dev/raw1394";
- handle = malloc(sizeof(struct raw1394_handle));
+ handle = malloc(sizeof(struct ieee1394_handle));
if (!handle) {
errno = ENOMEM;
return NULL;
@@ -154,65 +154,76 @@ struct raw1394_handle *raw1394_new_handle(void)
handle->bus_reset_handler = bus_reset_default;
handle->tag_handler = tag_handler_default;
handle->arm_tag_handler = arm_tag_handler_default;
- memset(handle->iso_handler, 0, sizeof(handle->iso_handler));
handle->iso_buffer = NULL;
handle->iso_mode = ISO_INACTIVE;
handle->iso_packet_infos = NULL;
return handle;
}
-void raw1394_destroy_handle(struct raw1394_handle *handle)
+void ieee1394_destroy_handle(struct ieee1394_handle *handle)
{
if (handle) {
if(handle->iso_mode != ISO_INACTIVE) {
- raw1394_iso_shutdown(handle);
+ ieee1394_iso_shutdown(handle);
}
close(handle->fd);
free(handle);
}
}
-int raw1394_get_fd(struct raw1394_handle *handle)
+int ieee1394_get_fd(struct ieee1394_handle *handle)
{
return handle->fd;
}
unsigned int raw1394_get_generation(struct raw1394_handle *handle)
{
- return handle->generation;
+ if (handle && handle->is_fw)
+ return handle->mode.fw->generation;
+ else
+ return handle->mode.ieee1394->generation;
}
void raw1394_update_generation(struct raw1394_handle *handle, unsigned int gen)
{
- handle->generation = gen;
+ if (handle && handle->is_fw)
+ handle->mode.fw->generation = gen;
+ else
+ handle->mode.ieee1394->generation = gen;
}
-int raw1394_get_nodecount(struct raw1394_handle *handle)
+int ieee1394_get_nodecount(struct ieee1394_handle *handle)
{
return handle->num_of_nodes;
}
-nodeid_t raw1394_get_local_id(struct raw1394_handle *handle)
+nodeid_t ieee1394_get_local_id(struct ieee1394_handle *handle)
{
return handle->local_id;
}
-nodeid_t raw1394_get_irm_id(struct raw1394_handle *handle)
+nodeid_t ieee1394_get_irm_id(struct ieee1394_handle *handle)
{
return handle->irm_id;
}
void raw1394_set_userdata(struct raw1394_handle *handle, void *data)
{
- handle->userdata = data;
+ if (handle && handle->is_fw)
+ handle->mode.fw->userdata = data;
+ else
+ handle->mode.ieee1394->userdata = data;
}
void *raw1394_get_userdata(struct raw1394_handle *handle)
{
- return handle->userdata;
+ if (handle && handle->is_fw)
+ return handle->mode.fw->userdata;
+ else
+ return handle->mode.ieee1394->userdata;
}
-int raw1394_get_port_info(struct raw1394_handle *handle,
+int ieee1394_get_port_info(struct ieee1394_handle *handle,
struct raw1394_portinfo *pinf, int maxports)
{
int num;
@@ -248,7 +259,7 @@ int raw1394_get_port_info(struct raw1394_handle *handle,
}
-int raw1394_set_port(struct raw1394_handle *handle, int port)
+int ieee1394_set_port(struct ieee1394_handle *handle, int port)
{
struct raw1394_request req;
@@ -286,23 +297,23 @@ int raw1394_set_port(struct raw1394_handle *handle, int port)
}
}
-raw1394handle_t raw1394_new_handle_on_port(int port)
+ieee1394handle_t ieee1394_new_handle_on_port(int port)
{
- raw1394handle_t handle = raw1394_new_handle();
+ ieee1394handle_t handle = ieee1394_new_handle();
if (!handle)
return NULL;
tryagain:
- if (raw1394_get_port_info(handle, NULL, 0) < 0) {
- raw1394_destroy_handle(handle);
+ if (ieee1394_get_port_info(handle, NULL, 0) < 0) {
+ ieee1394_destroy_handle(handle);
return NULL;
}
- if (raw1394_set_port(handle, port)) {
+ if (ieee1394_set_port(handle, port)) {
if (errno == ESTALE || errno == EINTR) {
goto tryagain;
} else {
- raw1394_destroy_handle(handle);
+ ieee1394_destroy_handle(handle);
return NULL;
}
}
@@ -310,7 +321,7 @@ tryagain:
return handle;
}
-int raw1394_reset_bus_new(struct raw1394_handle *handle, int type)
+int ieee1394_reset_bus_new(struct ieee1394_handle *handle, int type)
{
struct raw1394_request req;
@@ -331,7 +342,7 @@ int raw1394_reset_bus(struct raw1394_handle *handle)
return raw1394_reset_bus_new (handle, RAW1394_LONG_RESET);
}
-int raw1394_busreset_notify (struct raw1394_handle *handle,
+int ieee1394_busreset_notify (struct ieee1394_handle *handle,
int off_on_switch)
{
struct raw1394_request req;
@@ -347,7 +358,7 @@ int raw1394_busreset_notify (struct raw1394_handle *handle,
return 0; /* success */
}
-int raw1394_update_config_rom(raw1394handle_t handle, const quadlet_t
+int ieee1394_update_config_rom(ieee1394handle_t handle, const quadlet_t
*new_rom, size_t size, unsigned char rom_version)
{
struct raw1394_request req;
@@ -366,7 +377,7 @@ int raw1394_update_config_rom(raw1394handle_t handle, const quadlet_t
return status;
}
-int raw1394_get_config_rom(raw1394handle_t handle, quadlet_t *buffer,
+int ieee1394_get_config_rom(ieee1394handle_t handle, quadlet_t *buffer,
size_t buffersize, size_t *rom_size, unsigned char *rom_version)
{
struct raw1394_request req;
@@ -386,7 +397,7 @@ int raw1394_get_config_rom(raw1394handle_t handle, quadlet_t *buffer,
return status;
}
-int raw1394_bandwidth_modify (raw1394handle_t handle, unsigned int bandwidth,
+int ieee1394_bandwidth_modify (raw1394handle_t handle, unsigned int bandwidth,
enum raw1394_modify_mode mode)
{
quadlet_t buffer, compare, swap, new;
@@ -447,7 +458,7 @@ int raw1394_bandwidth_modify (raw1394handle_t handle, unsigned int bandwidth,
return 0;
}
-int raw1394_channel_modify (raw1394handle_t handle, unsigned int channel,
+int ieee1394_channel_modify (raw1394handle_t handle, unsigned int channel,
enum raw1394_modify_mode mode)
{
quadlet_t buffer;
diff --git a/src/raw1394.h b/src/raw1394.h
index 89e601f..d59b1b2 100644
--- a/src/raw1394.h
+++ b/src/raw1394.h
@@ -3,6 +3,7 @@
*
* Copyright (C) 1999-2004 Andreas Bombe, Dan Maas, Manfred Weihs, and
* Christian Toegel
+ * Copyright (C) 2008 Dan Dennedy <dan@dennedy.org>
*
* 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
@@ -1215,101 +1216,6 @@ raw1394_channel_modify (raw1394handle_t handle, unsigned int channel,
enum raw1394_modify_mode mode);
-/**
- * iso_handler_t - DEPRECATED
- * @handle: libraw1394 handle
- *
- * DEPRECATED
- **/
-typedef int (*iso_handler_t)(raw1394handle_t, int channel, size_t length,
- quadlet_t *data);
-
-/**
- * raw1394_set_iso_handler - set isochronous packet handler (DEPRECATED)
- * @handle: libraw1394 handle
- * @new_h: pointer to new handler
- *
- * DEPRECATED
- *
- * Sets the handler to be called when an isochronous packet is received to
- * @new_h and returns the old handler. The default handler does nothing.
- *
- * In order to actually get iso packet events, receiving on a specific channel
- * first has to be enabled with raw1394_start_iso_rcv() and can be stopped again
- * with raw1394_stop_iso_rcv().
- **/
-iso_handler_t raw1394_set_iso_handler(raw1394handle_t handle,
- unsigned int channel,
- iso_handler_t new_h)
-__attribute__ ((deprecated));
-
-/**
- * raw1394_start_iso_rcv - enable isochronous receiving (DEPRECATED)
- * @handle: libraw1394 handle
- * @channel: channel number to start receiving on
- *
- * DEPRECATED
- *
- * Enables the reception of isochronous packets in @channel on @handle.
- * Isochronous packets are then passed to the callback specified with
- * raw1394_set_iso_handler().
- **/
-int raw1394_start_iso_rcv(raw1394handle_t handle, unsigned int channel)
-__attribute__ ((deprecated));
-
-/**
- * raw1394_stop_iso_rcv - stop isochronous receiving (DEPRECATED)
- * @handle: libraw1394 handle
- * @channel: channel to stop receiving on
- *
- * DEPRECATED
- *
- * Stops the reception of isochronous packets in @channel on @handle.
- **/
-int raw1394_stop_iso_rcv(raw1394handle_t handle, unsigned int channel)
-__attribute__ ((deprecated));
-
-/**
- * raw1394_start_iso_write - initiate an isochronous packet write (DEPRECATED)
- * @handle: libraw1394 handle
- * @channel: channel number on which to send on
- * @tag: data to be put into packet's tag field
- * @sy: data to be put into packet's sy field
- * @speed: speed at which to send
- * @length: amount of data to send
- * @data: pointer to data to send
- * @rawtag: data to identify the request to completion handler
- *
- * DEPRECATED
- *
- * This function starts the specified isochronous packet transmission and
- * returns %0 for success and a negative number for an error, in which case
- * errno will be set.
- *
- * When the send completes, a raw1394_loop_iterate() will call the tag handler
- * and pass it the tag and error code of the transaction. @tag should therefore
- * be set to something that uniquely identifies this transaction (e.g. a struct
- * pointer casted to unsigned long).
- *
- * Isochronous packets are automatically
- **/
-int raw1394_start_iso_write(raw1394handle_t handle, unsigned int channel,
- unsigned int tag, unsigned int sy,
- unsigned int speed, size_t length, quadlet_t *data,
- unsigned long rawtag)
-__attribute__ ((deprecated));
-
-/**
- * raw1394_iso_write - DEPRECATED
- * @handle: libraw1394 handle
- *
- * DEPRECATED
- **/
-int raw1394_iso_write(raw1394handle_t handle, unsigned int channel,
- unsigned int tag, unsigned int sy, unsigned int speed,
- size_t length, quadlet_t *data)
-__attribute__ ((deprecated));
-
#ifdef __cplusplus
}
#endif
diff --git a/src/raw1394_private.h b/src/raw1394_private.h
index 8eb2c76..3f50740 100644
--- a/src/raw1394_private.h
+++ b/src/raw1394_private.h
@@ -1,28 +1,31 @@
-
#ifndef _RAW1394_PRIVATE_H
#define _RAW1394_PRIVATE_H
+#include "raw1394.h"
+#include "csr.h"
+#include "../juju/juju.h"
+#include "kernel-raw1394.h"
+
#define HBUF_SIZE 8192
#define ARM_REC_LENGTH 4096
#define MAXIMUM_BANDWIDTH 4915
-struct raw1394_handle {
- int fd;
- int protocol_version;
- unsigned int generation;
+struct ieee1394_handle {
+ int fd;
+ int protocol_version;
+ unsigned int generation;
- nodeid_t local_id;
- int num_of_nodes;
- nodeid_t irm_id;
+ nodeid_t local_id;
+ int num_of_nodes;
+ nodeid_t irm_id;
- raw1394_errcode_t err;
- void *userdata;
+ raw1394_errcode_t err;
+ void *userdata;
- bus_reset_handler_t bus_reset_handler;
- tag_handler_t tag_handler;
- arm_tag_handler_t arm_tag_handler;
- fcp_handler_t fcp_handler;
- iso_handler_t iso_handler[64];
+ bus_reset_handler_t bus_reset_handler;
+ tag_handler_t tag_handler;
+ arm_tag_handler_t arm_tag_handler;
+ fcp_handler_t fcp_handler;
/* new ISO API */
@@ -46,10 +49,20 @@ struct raw1394_handle {
quadlet_t buffer[HBUF_SIZE/4]; /* 2048 */
void *iso_packet_infos; /* actually a struct raw1394_iso_packet_info* */
};
+typedef struct ieee1394_handle *ieee1394handle_t;
+// typedef struct fw_handle *fw_handle_t;
+
+struct raw1394_handle {
+ int is_fw;
+ union {
+ ieee1394handle_t ieee1394;
+ fw_handle_t fw;
+ } mode;
+};
struct sync_cb_data {
- int done;
- int errcode;
+ int done;
+ int errcode;
};
int _raw1394_sync_cb(struct raw1394_handle*, struct sync_cb_data*, int);
@@ -65,4 +78,119 @@ int _raw1394_iso_iterate(raw1394handle_t handle);
#define ptr2int(x) ((__u64)x)
#endif
+
+int ieee1394_arm_register(struct ieee1394_handle *handle, nodeaddr_t start,
+ size_t length, byte_t *initial_value,
+ octlet_t arm_tag, arm_options_t access_rights,
+ arm_options_t notification_options,
+ arm_options_t client_transactions);
+int ieee1394_arm_unregister (struct ieee1394_handle *handle, nodeaddr_t start);
+int ieee1394_arm_set_buf (struct ieee1394_handle *handle, nodeaddr_t start,
+ size_t length, void *buf);
+int ieee1394_arm_get_buf (struct ieee1394_handle *handle, nodeaddr_t start,
+ size_t length, void *buf);
+int ieee1394_errcode_to_errno(raw1394_errcode_t errcode);
+int ieee1394_loop_iterate(struct raw1394_handle *handle);
+int ieee1394_start_fcp_listen(struct raw1394_handle *handle);
+int ieee1394_stop_fcp_listen(struct raw1394_handle *handle);
+struct ieee1394_handle *ieee1394_new_handle(void);
+void ieee1394_destroy_handle(struct ieee1394_handle *handle);
+int ieee1394_get_fd(struct ieee1394_handle *handle);
+int ieee1394_get_nodecount(struct ieee1394_handle *handle);
+nodeid_t ieee1394_get_local_id(struct ieee1394_handle *handle);
+nodeid_t ieee1394_get_irm_id(struct ieee1394_handle *handle);
+int ieee1394_get_port_info(struct ieee1394_handle *handle,
+ struct raw1394_portinfo *pinf, int maxports);
+int ieee1394_set_port(struct ieee1394_handle *handle, int port);
+ieee1394handle_t ieee1394_new_handle_on_port(int port);
+int ieee1394_reset_bus_new(struct ieee1394_handle *handle, int type);
+int ieee1394_busreset_notify (struct ieee1394_handle *handle,
+ int off_on_switch);
+int ieee1394_update_config_rom(ieee1394handle_t handle, const quadlet_t
+ *new_rom, size_t size, unsigned char rom_version);
+int ieee1394_get_config_rom(ieee1394handle_t handle, quadlet_t *buffer,
+ size_t buffersize, size_t *rom_size, unsigned char *rom_version);
+int ieee1394_bandwidth_modify (raw1394handle_t handle, unsigned int bandwidth,
+ enum raw1394_modify_mode mode);
+int ieee1394_channel_modify (raw1394handle_t handle, unsigned int channel,
+ enum raw1394_modify_mode mode);
+int ieee1394_start_read(struct ieee1394_handle *handle, nodeid_t node,
+ nodeaddr_t addr, size_t length, quadlet_t *buffer,
+ unsigned long tag);
+int ieee1394_start_write(struct ieee1394_handle *handle, nodeid_t node,
+ nodeaddr_t addr, size_t length, quadlet_t *data,
+ unsigned long tag);
+int ieee1394_start_lock(struct ieee1394_handle *handle, nodeid_t node,
+ nodeaddr_t addr, unsigned int extcode, quadlet_t data,
+ quadlet_t arg, quadlet_t *result, unsigned long tag);
+int ieee1394_start_lock64(struct ieee1394_handle *handle, nodeid_t node,
+ nodeaddr_t addr, unsigned int extcode, octlet_t data,
+ octlet_t arg, octlet_t *result, unsigned long tag);
+int ieee1394_start_async_stream(struct ieee1394_handle *handle,
+ unsigned int channel,
+ unsigned int tag, unsigned int sy,
+ unsigned int speed, size_t length, quadlet_t *data,
+ unsigned long rawtag);
+int ieee1394_start_async_send(struct ieee1394_handle *handle,
+ size_t length, size_t header_length, unsigned int expect_response,
+ quadlet_t *data, unsigned long rawtag);
+int ieee1394_read(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr,
+ size_t length, quadlet_t *buffer);
+int ieee1394_write(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr,
+ size_t length, quadlet_t *data);
+int ieee1394_lock(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr,
+ unsigned int extcode, quadlet_t data, quadlet_t arg,
+ quadlet_t *result);
+int ieee1394_lock64(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr,
+ unsigned int extcode, octlet_t data, octlet_t arg,
+ octlet_t *result);
+int ieee1394_async_stream(struct raw1394_handle *handle, unsigned int channel,
+ unsigned int tag, unsigned int sy, unsigned int speed,
+ size_t length, quadlet_t *data);
+int ieee1394_async_send(struct raw1394_handle *handle ,
+ size_t length, size_t header_length, unsigned int expect_response,
+ quadlet_t *data);
+int ieee1394_start_phy_packet_write(struct ieee1394_handle *handle,
+ quadlet_t data, unsigned long tag);
+int ieee1394_phy_packet_write (struct raw1394_handle *handle, quadlet_t data);
+int ieee1394_echo_request(struct ieee1394_handle *handle, quadlet_t data);
+int ieee1394_wake_up(ieee1394handle_t handle);
+const char *ieee1394_get_libversion();
+
+int ieee1394_iso_xmit_init(ieee1394handle_t handle,
+ raw1394_iso_xmit_handler_t handler,
+ unsigned int buf_packets,
+ unsigned int max_packet_size,
+ unsigned char channel,
+ enum raw1394_iso_speed speed,
+ int irq_interval);
+int ieee1394_iso_recv_init(ieee1394handle_t handle,
+ raw1394_iso_recv_handler_t handler,
+ unsigned int buf_packets,
+ unsigned int max_packet_size,
+ unsigned char channel,
+ enum raw1394_iso_dma_recv_mode mode,
+ int irq_interval);
+int ieee1394_iso_multichannel_recv_init(ieee1394handle_t handle,
+ raw1394_iso_recv_handler_t handler,
+ unsigned int buf_packets,
+ unsigned int max_packet_size,
+ int irq_interval);
+int ieee1394_iso_recv_listen_channel(ieee1394handle_t handle, unsigned char channel);
+int ieee1394_iso_recv_unlisten_channel(ieee1394handle_t handle, unsigned char channel);
+int ieee1394_iso_recv_flush(ieee1394handle_t handle);
+int ieee1394_iso_recv_set_channel_mask(ieee1394handle_t handle, u_int64_t mask);
+int ieee1394_iso_recv_start(ieee1394handle_t handle, int start_on_cycle, int tag_mask, int sync);
+int ieee1394_iso_xmit_write(raw1394handle_t handle, unsigned char *data, unsigned int len,
+ unsigned char tag, unsigned char sy);
+int ieee1394_iso_xmit_start(ieee1394handle_t handle, int start_on_cycle, int prebuffer_packets);
+int ieee1394_iso_xmit_sync(ieee1394handle_t handle);
+void ieee1394_iso_stop(ieee1394handle_t handle);
+void ieee1394_iso_shutdown(ieee1394handle_t handle);
+int ieee1394_read_cycle_timer(ieee1394handle_t handle,
+ u_int32_t *cycle_timer, u_int64_t *local_time);
+int _ieee1394_iso_iterate(raw1394handle_t handle);
+
+
+
#endif /* _RAW1394_PRIVATE_H */
diff --git a/src/readwrite.c b/src/readwrite.c
index 2ad147c..e86f70b 100644
--- a/src/readwrite.c
+++ b/src/readwrite.c
@@ -40,7 +40,7 @@
#endif
-int raw1394_start_read(struct raw1394_handle *handle, nodeid_t node,
+int ieee1394_start_read(struct ieee1394_handle *handle, nodeid_t node,
nodeaddr_t addr, size_t length, quadlet_t *buffer,
unsigned long tag)
{
@@ -60,7 +60,7 @@ int raw1394_start_read(struct raw1394_handle *handle, nodeid_t node,
}
-int raw1394_start_write(struct raw1394_handle *handle, nodeid_t node,
+int ieee1394_start_write(struct ieee1394_handle *handle, nodeid_t node,
nodeaddr_t addr, size_t length, quadlet_t *data,
unsigned long tag)
{
@@ -80,7 +80,7 @@ int raw1394_start_write(struct raw1394_handle *handle, nodeid_t node,
}
-int raw1394_start_lock(struct raw1394_handle *handle, nodeid_t node,
+int ieee1394_start_lock(struct ieee1394_handle *handle, nodeid_t node,
nodeaddr_t addr, unsigned int extcode, quadlet_t data,
quadlet_t arg, quadlet_t *result, unsigned long tag)
{
@@ -118,7 +118,7 @@ int raw1394_start_lock(struct raw1394_handle *handle, nodeid_t node,
return (int)write(handle->fd, &req, sizeof(req));
}
-int raw1394_start_lock64(struct raw1394_handle *handle, nodeid_t node,
+int ieee1394_start_lock64(struct ieee1394_handle *handle, nodeid_t node,
nodeaddr_t addr, unsigned int extcode, octlet_t data,
octlet_t arg, octlet_t *result, unsigned long tag)
{
@@ -158,28 +158,7 @@ int raw1394_start_lock64(struct raw1394_handle *handle, nodeid_t node,
}
-int raw1394_start_iso_write(struct raw1394_handle *handle, unsigned int channel,
- unsigned int tag, unsigned int sy,
- unsigned int speed, size_t length, quadlet_t *data,
- unsigned long rawtag)
-{
- struct raw1394_request req;
-
- CLEAR_REQ(&req);
-
- req.type = RAW1394_REQ_ISO_SEND;
- req.generation = handle->generation;
- req.tag = rawtag;
-
- req.address = ((__u64)channel << 48) | speed;
- req.misc = (tag << 16) | sy;
- req.length = length;
- req.sendb = ptr2int(data);
-
- return (int)write(handle->fd, &req, sizeof(req));
-}
-
-int raw1394_start_async_stream(struct raw1394_handle *handle,
+int ieee1394_start_async_stream(struct ieee1394_handle *handle,
unsigned int channel,
unsigned int tag, unsigned int sy,
unsigned int speed, size_t length, quadlet_t *data,
@@ -201,7 +180,7 @@ int raw1394_start_async_stream(struct raw1394_handle *handle,
return (int)write(handle->fd, &req, sizeof(req));
}
-int raw1394_start_async_send(struct raw1394_handle *handle,
+int ieee1394_start_async_send(struct ieee1394_handle *handle,
size_t length, size_t header_length, unsigned int expect_response,
quadlet_t *data, unsigned long rawtag)
{
@@ -232,19 +211,19 @@ int raw1394_start_async_send(struct raw1394_handle *handle,
if (err < 0) return err; \
err = raw1394_loop_iterate(handle); \
} \
- handle->err = sd.errcode; \
+ handle->mode.ieee1394->err = sd.errcode; \
errno = raw1394_errcode_to_errno(sd.errcode);
#define SYNCFUNC_BODY \
SYNCFUNC_BODY_WO_RETURN \
return (errno ? -1 : 0)
-int raw1394_read(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr,
+int ieee1394_read(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr,
size_t length, quadlet_t *buffer)
{
SYNCFUNC_VARS;
- err = raw1394_start_read(handle, node, addr, length, buffer,
+ err = ieee1394_start_read(handle->mode.ieee1394, node, addr, length, buffer,
(unsigned long)&rh);
SYNCFUNC_BODY_WO_RETURN;
@@ -255,24 +234,24 @@ int raw1394_read(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr,
return (errno ? -1 : 0);
}
-int raw1394_write(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr,
+int ieee1394_write(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr,
size_t length, quadlet_t *data)
{
SYNCFUNC_VARS;
- err = raw1394_start_write(handle, node, addr, length, data,
+ err = ieee1394_start_write(handle->mode.ieee1394, node, addr, length, data,
(unsigned long)&rh);
SYNCFUNC_BODY;
}
-int raw1394_lock(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr,
+int ieee1394_lock(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr,
unsigned int extcode, quadlet_t data, quadlet_t arg,
quadlet_t *result)
{
SYNCFUNC_VARS;
- err = raw1394_start_lock(handle, node, addr, extcode, data, arg, result,
+ err = ieee1394_start_lock(handle->mode.ieee1394, node, addr, extcode, data, arg, result,
(unsigned long)&rh);
SYNCFUNC_BODY_WO_RETURN;
@@ -283,50 +262,38 @@ int raw1394_lock(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr,
return (errno ? -1 : 0);
}
-int raw1394_lock64(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr,
+int ieee1394_lock64(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr,
unsigned int extcode, octlet_t data, octlet_t arg,
octlet_t *result)
{
SYNCFUNC_VARS;
- err = raw1394_start_lock64(handle, node, addr, extcode, data, arg, result,
+ err = ieee1394_start_lock64(handle->mode.ieee1394, node, addr, extcode, data, arg, result,
(unsigned long)&rh);
SYNCFUNC_BODY;
}
-int raw1394_iso_write(struct raw1394_handle *handle, unsigned int channel,
- unsigned int tag, unsigned int sy, unsigned int speed,
- size_t length, quadlet_t *data)
-{
- SYNCFUNC_VARS;
-
- err = raw1394_start_iso_write(handle, channel, tag, sy, speed, length,
- data, (unsigned long)&rh);
-
- SYNCFUNC_BODY;
-}
-
-int raw1394_async_stream(struct raw1394_handle *handle, unsigned int channel,
+int ieee1394_async_stream(struct raw1394_handle *handle, unsigned int channel,
unsigned int tag, unsigned int sy, unsigned int speed,
size_t length, quadlet_t *data)
{
SYNCFUNC_VARS;
- err = raw1394_start_async_stream(handle, channel, tag, sy, speed, length,
+ err = ieee1394_start_async_stream(handle->mode.ieee1394, channel, tag, sy, speed, length,
data, (unsigned long)&rh);
SYNCFUNC_BODY;
}
-int raw1394_async_send(struct raw1394_handle *handle ,
+int ieee1394_async_send(struct raw1394_handle *handle ,
size_t length, size_t header_length, unsigned int expect_response,
quadlet_t *data)
{
SYNCFUNC_VARS;
- err = raw1394_start_async_send(handle, length, header_length, expect_response,
+ err = ieee1394_start_async_send(handle->mode.ieee1394, length, header_length, expect_response,
data, (unsigned long)&rh);
SYNCFUNC_BODY;
@@ -334,7 +301,7 @@ int raw1394_async_send(struct raw1394_handle *handle ,
-int raw1394_start_phy_packet_write(struct raw1394_handle *handle,
+int ieee1394_start_phy_packet_write(struct ieee1394_handle *handle,
quadlet_t data, unsigned long tag)
{
struct raw1394_request req;
@@ -350,16 +317,16 @@ int raw1394_start_phy_packet_write(struct raw1394_handle *handle,
return (int)write(handle->fd, &req, sizeof(req));
}
-int raw1394_phy_packet_write (struct raw1394_handle *handle, quadlet_t data)
+int ieee1394_phy_packet_write (struct raw1394_handle *handle, quadlet_t data)
{
SYNCFUNC_VARS;
- err = raw1394_start_phy_packet_write(handle, data, (unsigned long)&rh);
+ err = ieee1394_start_phy_packet_write(handle->mode.ieee1394, data, (unsigned long)&rh);
SYNCFUNC_BODY; /* return 0 on success */
}
-int raw1394_echo_request(struct raw1394_handle *handle, quadlet_t data)
+int ieee1394_echo_request(struct ieee1394_handle *handle, quadlet_t data)
{
struct raw1394_request req;
int retval=0;
@@ -376,9 +343,9 @@ int raw1394_echo_request(struct raw1394_handle *handle, quadlet_t data)
return -1;
}
-int raw1394_wake_up(raw1394handle_t handle)
+int ieee1394_wake_up(ieee1394handle_t handle)
{
- return raw1394_echo_request(handle, 0);
+ return ieee1394_echo_request(handle, 0);
}
#undef SYNCFUNC_VARS