diff --git a/Makefile.am b/Makefile.am index 21df527..443c9ed 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ # process this file with automake to create a Makefile.in -SUBDIRS = $(LIB_SUBDIR) tools doc debian +SUBDIRS = src tools doc debian DIST_SUBDIRS = src juju pkgconfigdir = @libdir@/pkgconfig diff --git a/configure.ac b/configure.ac index a8de663..933dfc7 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ # process this file with autoconf to get a configure script -AC_INIT(libraw1394, 1.3.0) +AC_INIT(libraw1394, 2.0.0) AC_CONFIG_SRCDIR(src/raw1394.h) AM_CONFIG_HEADER(config.h) @@ -16,9 +16,9 @@ AC_C_CONST AC_C_BIGENDIAN # set the libtool so version numbers -lt_major=10 +lt_major=11 lt_revision=0 -lt_age=2 +lt_age=3 AC_SUBST(lt_major) AC_SUBST(lt_revision) @@ -30,15 +30,11 @@ if test x$with_valgrind = xyes ; then AC_CHECK_HEADERS(valgrind/valgrind.h) fi -AC_ARG_WITH(juju-dir,[ --with-juju-dir= Path to juju include files]) -if ! test -z "$with_juju_dir" ; then - JUJU_DIR="$with_juju_dir" - LIB_SUBDIR=juju - AC_SUBST(JUJU_DIR) -else - LIB_SUBDIR=src +AC_ARG_WITH(fw-dir,[ --with-fw-dir= Path to kernel firewire headers]) +if ! test -z "$with_fw_dir" ; then + FW_DIR="$with_fw_dir" + AC_SUBST(FW_DIR) fi -AC_SUBST(LIB_SUBDIR) AC_ARG_WITH(fw-device-prefix, [ --with-fw-device-prefix= Prefix of firewire device file names (default "fw").], diff --git a/juju/Makefile.am b/juju/Makefile.am index 6fd6a5e..af7501a 100644 --- a/juju/Makefile.am +++ b/juju/Makefile.am @@ -1,6 +1,6 @@ lib_LTLIBRARIES = libraw1394.la -INCLUDES = -I$(JUJU_DIR) +INCLUDES = -I$(FW_DIR) libraw1394_la_LDFLAGS = -version-info @lt_major@:@lt_revision@:@lt_age@ libraw1394_la_SOURCES = raw1394.c raw1394-iso.c juju.h diff --git a/juju/juju.h b/juju/juju.h index 8746ac2..fc0eba1 100644 --- a/juju/juju.h +++ b/juju/juju.h @@ -52,6 +52,8 @@ cpu_to_be32(__u32 q) #define MAX_PORTS 16 +struct fw_handle; + struct epoll_closure { int (*func)(raw1394handle_t handle, struct epoll_closure *closure, __uint32_t events); @@ -84,12 +86,12 @@ struct request_closure { struct allocation; -struct raw1394_handle { +struct fw_handle { struct port ports[MAX_PORTS]; int port_count; int err; int generation; - void *user_data; + void *userdata; int notify_bus_reset; bus_reset_handler_t bus_reset_handler; @@ -137,5 +139,119 @@ struct raw1394_handle { char buffer[BUFFER_SIZE]; }; +typedef struct fw_handle *fw_handle_t; + +int fw_loop_iterate(raw1394handle_t handle); +fw_handle_t fw_new_handle(void); +void fw_destroy_handle(fw_handle_t handle); +fw_handle_t fw_new_handle_on_port(int port); +int fw_busreset_notify (fw_handle_t handle, int off_on_switch); +int fw_get_fd(fw_handle_t handle); +nodeid_t fw_get_local_id(fw_handle_t handle); +nodeid_t fw_get_irm_id(fw_handle_t handle); +int fw_get_nodecount(fw_handle_t handle); +int fw_get_port_info(fw_handle_t handle, struct raw1394_portinfo *pinf, + int maxports); +int fw_set_port(fw_handle_t handle, int port); +int fw_reset_bus_new(fw_handle_t handle, int type); +int fw_arm_register(fw_handle_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); +int fw_arm_unregister(fw_handle_t handle, nodeaddr_t start); +int fw_arm_set_buf(fw_handle_t handle, nodeaddr_t start, + size_t length, void *buf); +int fw_arm_get_buf(fw_handle_t handle, nodeaddr_t start, + size_t length, void *buf); +int fw_echo_request(fw_handle_t handle, quadlet_t data); +int fw_wake_up(fw_handle_t handle); +int fw_phy_packet_write (fw_handle_t handle, quadlet_t data); +int fw_start_phy_packet_write(fw_handle_t handle, + quadlet_t data, unsigned long tag); +int fw_start_read(fw_handle_t handle, nodeid_t node, nodeaddr_t addr, + size_t length, quadlet_t *buffer, unsigned long tag); +int fw_start_write(fw_handle_t handle, nodeid_t node, nodeaddr_t addr, + size_t length, quadlet_t *data, unsigned long tag); +int fw_start_lock(fw_handle_t handle, nodeid_t node, nodeaddr_t addr, + unsigned int extcode, quadlet_t data, quadlet_t arg, + quadlet_t *result, unsigned long tag); +int fw_start_lock64(fw_handle_t handle, nodeid_t node, nodeaddr_t addr, + unsigned int extcode, octlet_t data, octlet_t arg, + octlet_t *result, unsigned long tag); +int fw_start_async_stream(fw_handle_t handle, unsigned int channel, + unsigned int tag, unsigned int sy, + unsigned int speed, size_t length, quadlet_t *data, + unsigned long rawtag); +int fw_start_async_send(fw_handle_t handle, + size_t length, size_t header_length, + unsigned int expect_response, + quadlet_t *data, unsigned long rawtag); +int fw_read(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, + size_t length, quadlet_t *buffer); +int fw_write(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, + size_t length, quadlet_t *data); +int fw_lock(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, + unsigned int extcode, quadlet_t data, quadlet_t arg, + quadlet_t *result); +int fw_lock64(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, + unsigned int extcode, octlet_t data, octlet_t arg, + octlet_t *result); +int fw_async_stream(fw_handle_t handle, unsigned int channel, + unsigned int tag, unsigned int sy, unsigned int speed, + size_t length, quadlet_t *data); +int fw_async_send(fw_handle_t handle, + size_t length, size_t header_length, + unsigned int expect_response, + quadlet_t *data); +int fw_start_fcp_listen(fw_handle_t handle); +int fw_stop_fcp_listen(fw_handle_t handle); +int fw_update_config_rom(fw_handle_t handle, const quadlet_t *new_rom, + size_t size, unsigned char rom_version); +int fw_get_config_rom(fw_handle_t handle, quadlet_t *buffer, + size_t buffersize, size_t *rom_size, + unsigned char *rom_version); +int fw_bandwidth_modify (raw1394handle_t handle, + unsigned int bandwidth, + enum raw1394_modify_mode mode); +int fw_channel_modify (raw1394handle_t handle, + unsigned int channel, + enum raw1394_modify_mode mode); + +int fw_iso_xmit_start(raw1394handle_t handle, int start_on_cycle, + int prebuffer_packets); +int fw_iso_recv_start(fw_handle_t handle, int start_on_cycle, + int tag_mask, int sync); +int fw_iso_xmit_write(raw1394handle_t handle, unsigned char *data, + unsigned int len, unsigned char tag, + unsigned char sy); +int fw_iso_xmit_sync(raw1394handle_t handle); +int fw_iso_recv_flush(fw_handle_t handle); +int fw_iso_xmit_init(fw_handle_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 fw_iso_recv_init(fw_handle_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 fw_iso_multichannel_recv_init(fw_handle_t handle, + raw1394_iso_recv_handler_t handler, + unsigned int buf_packets, + unsigned int max_packet_size, + int irq_interval); +int fw_iso_recv_listen_channel(fw_handle_t handle, + unsigned char channel); +int fw_iso_recv_unlisten_channel(fw_handle_t handle, + unsigned char channel); +int fw_iso_recv_set_channel_mask(fw_handle_t handle, u_int64_t mask); +void fw_iso_stop(fw_handle_t handle); +void fw_iso_shutdown(fw_handle_t handle); #endif diff --git a/juju/raw1394-iso.c b/juju/raw1394-iso.c index ae8aaad..c02f0e3 100644 --- a/juju/raw1394-iso.c +++ b/juju/raw1394-iso.c @@ -29,9 +29,10 @@ #include #include "juju.h" +#include "../src/raw1394_private.h" static int -queue_packet(raw1394handle_t handle, +queue_packet(fw_handle_t handle, unsigned int length, unsigned int header_length, unsigned char tag, unsigned char sy) { @@ -80,21 +81,22 @@ queue_packet(raw1394handle_t handle, static int queue_xmit_packets(raw1394handle_t handle, int limit) { + fw_handle_t fwhandle = handle->mode.fw; enum raw1394_iso_disposition d; unsigned char tag, sy; int len, cycle, dropped; - if (handle->iso.xmit_handler == NULL) + if (fwhandle->iso.xmit_handler == NULL) return 0; - while (handle->iso.packet_count < limit) { + while (fwhandle->iso.packet_count < limit) { - d = handle->iso.xmit_handler(handle, handle->iso.head, + d = fwhandle->iso.xmit_handler(handle, fwhandle->iso.head, &len, &tag, &sy, cycle, dropped); switch (d) { case RAW1394_ISO_OK: - queue_packet(handle, len, 0, tag, sy); + queue_packet(fwhandle, len, 0, tag, sy); break; case RAW1394_ISO_DEFER: case RAW1394_ISO_AGAIN: @@ -103,7 +105,7 @@ queue_xmit_packets(raw1394handle_t handle, int limit) case RAW1394_ISO_ERROR: return -1; case RAW1394_ISO_STOP: - raw1394_iso_stop(handle); + fw_iso_stop(fwhandle); return 0; } } @@ -111,35 +113,36 @@ queue_xmit_packets(raw1394handle_t handle, int limit) return 0; } -int raw1394_iso_xmit_start(raw1394handle_t handle, int start_on_cycle, +int fw_iso_xmit_start(raw1394handle_t handle, int start_on_cycle, int prebuffer_packets) { + fw_handle_t fwhandle = handle->mode.fw; struct fw_cdev_start_iso start_iso; int retval; if (prebuffer_packets == -1) - prebuffer_packets = handle->iso.irq_interval; + prebuffer_packets = fwhandle->iso.irq_interval; - handle->iso.prebuffer = prebuffer_packets; - handle->iso.start_on_cycle = start_on_cycle; + fwhandle->iso.prebuffer = prebuffer_packets; + fwhandle->iso.start_on_cycle = start_on_cycle; queue_xmit_packets(handle, prebuffer_packets); - if (handle->iso.prebuffer <= handle->iso.packet_count) { + if (fwhandle->iso.prebuffer <= fwhandle->iso.packet_count) { start_iso.cycle = start_on_cycle; start_iso.handle = 0; - retval = ioctl(handle->iso.fd, + retval = ioctl(fwhandle->iso.fd, FW_CDEV_IOC_START_ISO, &start_iso); if (retval < 0) return retval; } - return queue_xmit_packets(handle, handle->iso.buf_packets); + return queue_xmit_packets(handle, fwhandle->iso.buf_packets); } static int -queue_recv_packets(raw1394handle_t handle) +queue_recv_packets(fw_handle_t handle) { while (handle->iso.packet_count <= handle->iso.buf_packets) queue_packet(handle, handle->iso.max_packet_size, 4, 0, 0); @@ -151,6 +154,7 @@ static enum raw1394_iso_disposition flush_recv_packets(raw1394handle_t handle, struct fw_cdev_event_iso_interrupt *interrupt) { + fw_handle_t fwhandle = handle->mode.fw; enum raw1394_iso_disposition d; quadlet_t header, *p, *end; unsigned int len, cycle, dropped; @@ -169,7 +173,7 @@ flush_recv_packets(raw1394handle_t handle, channel = (header >> 8) & 0x3f; sy = header & 0x0f; - d = handle->iso.recv_handler(handle, handle->iso.tail, len, + d = fwhandle->iso.recv_handler(handle, fwhandle->iso.tail, len, channel, tag, sy, cycle, dropped); if (d != RAW1394_ISO_OK) /* FIXME: we need to save the headers so we @@ -177,11 +181,11 @@ flush_recv_packets(raw1394handle_t handle, break; cycle++; - handle->iso.tail += handle->iso.max_packet_size; - handle->iso.packet_count--; + fwhandle->iso.tail += fwhandle->iso.max_packet_size; + fwhandle->iso.packet_count--; - if (handle->iso.tail + handle->iso.max_packet_size > handle->iso.buffer_end) - handle->iso.tail = handle->iso.buffer; + if (fwhandle->iso.tail + fwhandle->iso.max_packet_size > fwhandle->iso.buffer_end) + fwhandle->iso.tail = fwhandle->iso.buffer; } switch (d) { @@ -194,16 +198,16 @@ flush_recv_packets(raw1394handle_t handle, return -1; case RAW1394_ISO_STOP: - raw1394_iso_stop(handle); + fw_iso_stop(fwhandle); return 0; } - queue_recv_packets(handle); + queue_recv_packets(fwhandle); return 0; } -int raw1394_iso_recv_start(raw1394handle_t handle, int start_on_cycle, +int fw_iso_recv_start(fw_handle_t handle, int start_on_cycle, int tag_mask, int sync) { struct fw_cdev_start_iso start_iso; @@ -223,21 +227,22 @@ int raw1394_iso_recv_start(raw1394handle_t handle, int start_on_cycle, static int handle_iso_event(raw1394handle_t handle, struct epoll_closure *closure, __uint32_t events) { + fw_handle_t fwhandle = handle->mode.fw; struct fw_cdev_event_iso_interrupt *interrupt; int len; - len = read(handle->iso.fd, handle->buffer, sizeof handle->buffer); + len = read(fwhandle->iso.fd, fwhandle->buffer, sizeof fwhandle->buffer); if (len < 0) return -1; - interrupt = (struct fw_cdev_event_iso_interrupt *) handle->buffer; + interrupt = (struct fw_cdev_event_iso_interrupt *) fwhandle->buffer; if (interrupt->type != FW_CDEV_EVENT_ISO_INTERRUPT) return 0; - switch (handle->iso.type) { + switch (fwhandle->iso.type) { case FW_CDEV_ISO_CONTEXT_TRANSMIT: - handle->iso.packet_count -= handle->iso.irq_interval; - return queue_xmit_packets(handle, handle->iso.buf_packets); + fwhandle->iso.packet_count -= fwhandle->iso.irq_interval; + return queue_xmit_packets(handle, fwhandle->iso.buf_packets); case FW_CDEV_ISO_CONTEXT_RECEIVE: return flush_recv_packets(handle, interrupt); default: @@ -246,38 +251,39 @@ static int handle_iso_event(raw1394handle_t handle, } } -int raw1394_iso_xmit_write(raw1394handle_t handle, unsigned char *data, +int fw_iso_xmit_write(raw1394handle_t handle, unsigned char *data, unsigned int len, unsigned char tag, unsigned char sy) { + fw_handle_t fwhandle = handle->mode.fw; struct fw_cdev_queue_iso queue_iso; struct fw_cdev_start_iso start_iso; struct fw_cdev_iso_packet *p; - if (len > handle->iso.max_packet_size) { + if (len > fwhandle->iso.max_packet_size) { errno = EINVAL; return -1; } /* Block until we have space for another packet. */ - while (handle->iso.packet_count + handle->iso.irq_interval > - handle->iso.buf_packets) - raw1394_loop_iterate(handle); + while (fwhandle->iso.packet_count + fwhandle->iso.irq_interval > + fwhandle->iso.buf_packets) + fw_loop_iterate(handle); - memcpy(handle->iso.head, data, len); - if (queue_packet(handle, len, 0, tag, sy) < 0) + memcpy(fwhandle->iso.head, data, len); + if (queue_packet(fwhandle, len, 0, tag, sy) < 0) return -1; /* Start the streaming if it's not already running and if * we've buffered up enough packets. */ - if (handle->iso.prebuffer > 0 && - handle->iso.packet_count >= handle->iso.prebuffer) { + if (fwhandle->iso.prebuffer > 0 && + fwhandle->iso.packet_count >= fwhandle->iso.prebuffer) { /* Set this to 0 to indicate that we're running. */ - handle->iso.prebuffer = 0; - start_iso.cycle = handle->iso.start_on_cycle; + fwhandle->iso.prebuffer = 0; + start_iso.cycle = fwhandle->iso.start_on_cycle; start_iso.handle = 0; - len = ioctl(handle->iso.fd, + len = ioctl(fwhandle->iso.fd, FW_CDEV_IOC_START_ISO, &start_iso); if (len < 0) return len; @@ -286,8 +292,9 @@ int raw1394_iso_xmit_write(raw1394handle_t handle, unsigned char *data, return 0; } -int raw1394_iso_xmit_sync(raw1394handle_t handle) +int fw_iso_xmit_sync(raw1394handle_t handle) { + fw_handle_t fwhandle = handle->mode.fw; struct fw_cdev_iso_packet skip; struct fw_cdev_queue_iso queue_iso; int len; @@ -298,29 +305,29 @@ int raw1394_iso_xmit_sync(raw1394handle_t handle) queue_iso.data = 0; queue_iso.handle = 0; - len = ioctl(handle->iso.fd, FW_CDEV_IOC_QUEUE_ISO, &queue_iso); + len = ioctl(fwhandle->iso.fd, FW_CDEV_IOC_QUEUE_ISO, &queue_iso); if (len < 0) return -1; /* Now that we've queued the skip packet, we'll get an * interrupt when the transmit buffer is flushed, so all we do * here is wait. */ - while (handle->iso.packet_count > 0) - raw1394_loop_iterate(handle); + while (fwhandle->iso.packet_count > 0) + fw_loop_iterate(handle); /* The iso mainloop thinks that interrutps indicate another * irq_interval number of packets was sent, so the skip * interrupt makes it go out of whack. We just reset it. */ - handle->iso.head = handle->iso.buffer; - handle->iso.tail = handle->iso.buffer; - handle->iso.first_payload = handle->iso.buffer; - handle->iso.packet_phase = 0; - handle->iso.packet_count = 0; + fwhandle->iso.head = fwhandle->iso.buffer; + fwhandle->iso.tail = fwhandle->iso.buffer; + fwhandle->iso.first_payload = fwhandle->iso.buffer; + fwhandle->iso.packet_phase = 0; + fwhandle->iso.packet_count = 0; return 0; } -int raw1394_iso_recv_flush(raw1394handle_t handle) +int fw_iso_recv_flush(fw_handle_t handle) { /* FIXME: huh, we'll need kernel support here... */ @@ -340,7 +347,7 @@ round_to_power_of_two(unsigned int value) } static int -iso_init(raw1394handle_t handle, int type, +iso_init(fw_handle_t handle, int type, raw1394_iso_xmit_handler_t xmit_handler, raw1394_iso_recv_handler_t recv_handler, unsigned int buf_packets, @@ -438,7 +445,7 @@ iso_init(raw1394handle_t handle, int type, return 0; } -int raw1394_iso_xmit_init(raw1394handle_t handle, +int fw_iso_xmit_init(fw_handle_t handle, raw1394_iso_xmit_handler_t handler, unsigned int buf_packets, unsigned int max_packet_size, @@ -451,7 +458,7 @@ int raw1394_iso_xmit_init(raw1394handle_t handle, channel, speed, irq_interval); } -int raw1394_iso_recv_init(raw1394handle_t handle, +int fw_iso_recv_init(fw_handle_t handle, raw1394_iso_recv_handler_t handler, unsigned int buf_packets, unsigned int max_packet_size, @@ -464,7 +471,7 @@ int raw1394_iso_recv_init(raw1394handle_t handle, channel, 0, irq_interval); } -int raw1394_iso_multichannel_recv_init(raw1394handle_t handle, +int fw_iso_multichannel_recv_init(fw_handle_t handle, raw1394_iso_recv_handler_t handler, unsigned int buf_packets, unsigned int max_packet_size, @@ -475,7 +482,7 @@ int raw1394_iso_multichannel_recv_init(raw1394handle_t handle, return -1; } -int raw1394_iso_recv_listen_channel(raw1394handle_t handle, +int fw_iso_recv_listen_channel(fw_handle_t handle, unsigned char channel) { /* FIXME: multichannel */ @@ -483,7 +490,7 @@ int raw1394_iso_recv_listen_channel(raw1394handle_t handle, return -1; } -int raw1394_iso_recv_unlisten_channel(raw1394handle_t handle, +int fw_iso_recv_unlisten_channel(fw_handle_t handle, unsigned char channel) { /* FIXME: multichannel */ @@ -491,14 +498,14 @@ int raw1394_iso_recv_unlisten_channel(raw1394handle_t handle, return -1; } -int raw1394_iso_recv_set_channel_mask(raw1394handle_t handle, u_int64_t mask) +int fw_iso_recv_set_channel_mask(fw_handle_t handle, u_int64_t mask) { /* FIXME: multichannel */ errno = ENOSYS; return -1; } -void raw1394_iso_stop(raw1394handle_t handle) +void fw_iso_stop(fw_handle_t handle) { struct fw_cdev_stop_iso stop_iso; @@ -512,7 +519,7 @@ void raw1394_iso_stop(raw1394handle_t handle) handle->iso.packet_count = 0; } -void raw1394_iso_shutdown(raw1394handle_t handle) +void fw_iso_shutdown(fw_handle_t handle) { munmap(handle->iso.buffer, handle->iso.buf_packets * handle->iso.max_packet_size); diff --git a/juju/raw1394.c b/juju/raw1394.c index 7f73b3b..73c8705 100644 --- a/juju/raw1394.c +++ b/juju/raw1394.c @@ -1,6 +1,6 @@ /* -*- c-basic-offset: 8 -*- * - * raw1394.c -- Emulation of the raw1394 API on the juju stack + * raw1394.c -- Emulation of the raw1394 API on the fw stack * * Copyright (C) 2007 Kristian Hoegsberg * @@ -32,15 +32,10 @@ #include /* for ntohl and htonl */ #include "juju.h" - -raw1394_errcode_t -raw1394_get_errcode(raw1394handle_t handle) -{ - return handle->err; -} +#include "../src/raw1394_private.h" int -raw1394_errcode_to_errno(raw1394_errcode_t errcode) +fw_errcode_to_errno(raw1394_errcode_t errcode) { switch (errcode) { @@ -67,17 +62,17 @@ raw1394_errcode_to_errno(raw1394_errcode_t errcode) } static int -juju_to_raw1394_errcode(int rcode) +fw_to_raw1394_errcode(int rcode) { - /* Best effort matching juju extended rcodes to raw1394 err + /* Best effort matching fw extended rcodes to raw1394 err * code. Since the raw1394 errcode decoding are macros we try - * to convert the juju rcodes to something that looks enough + * to convert the fw rcodes to something that looks enough * like the raw1394 errcodes that we retain ABI compatibility. * * Juju rcodes less than 0x10 are standard ieee1394 rcodes, * which we map to a raw1394 errcode by or'ing in an * ACK_COMPLETE ack code in the upper 16 bits. Errors - * internal to raw1394 are negative values, but juju encodes + * internal to raw1394 are negative values, but fw encodes * these errors as rcodes greater than or equal to 0x10. In * this case, we just the negated value, which will look like * an raw1394 internal error code. */ @@ -115,15 +110,15 @@ default_arm_tag_handler(raw1394handle_t handle, unsigned long arm_tag, } static int -default_bus_reset_handler(struct raw1394_handle *handle, unsigned int gen) +default_bus_reset_handler(raw1394handle_t handle, unsigned int gen) { - raw1394_update_generation(handle, gen); + handle->mode.fw->generation = gen; return 0; } static int -scan_devices(raw1394handle_t handle) +scan_devices(fw_handle_t handle) { DIR *dir; struct dirent *de; @@ -185,14 +180,14 @@ handle_echo_pipe(raw1394handle_t handle, { quadlet_t value; - if (read(handle->pipe_fds[0], &value, sizeof value) < 0) + if (read(handle->mode.fw->pipe_fds[0], &value, sizeof value) < 0) return -1; return value; } static int -handle_lost_device(raw1394handle_t handle, int i) +handle_lost_device(fw_handle_t handle, int i) { int phy_id; @@ -225,13 +220,13 @@ handle_fcp_request(raw1394handle_t handle, struct address_closure *ac, response.length = 0; response.data = 0; - if (handle->fcp_handler == NULL) + if (handle->mode.fw->fcp_handler == NULL) response.rcode = RCODE_ADDRESS_ERROR; if (request->tcode >= TCODE_WRITE_RESPONSE) response.rcode = RCODE_CONFLICT_ERROR; - if (ioctl(handle->devices[i].fd, + if (ioctl(handle->mode.fw->devices[i].fd, FW_CDEV_IOC_SEND_RESPONSE, &response) < 0) return -1; @@ -240,8 +235,8 @@ handle_fcp_request(raw1394handle_t handle, struct address_closure *ac, is_response = request->offset >= CSR_REGISTER_BASE + CSR_FCP_RESPONSE; - return handle->fcp_handler(handle, - handle->devices[i].node_id, + return handle->mode.fw->fcp_handler(handle, + handle->mode.fw->devices[i].node_id, is_response, request->length, (unsigned char *) request->data); @@ -251,6 +246,7 @@ static int handle_device_event(raw1394handle_t handle, struct epoll_closure *ec, __uint32_t events) { + fw_handle_t fwhandle = handle->mode.fw; union fw_cdev_event *u; struct device *device = (struct device *) ec; struct address_closure *ac; @@ -259,31 +255,31 @@ handle_device_event(raw1394handle_t handle, int len, phy_id; int i; - i = device - handle->devices; + i = device - fwhandle->devices; if (events == EPOLLHUP) - return handle_lost_device(handle, i); + return handle_lost_device(fwhandle, i); - len = read(handle->devices[i].fd, - handle->buffer, sizeof handle->buffer); + len = read(fwhandle->devices[i].fd, + fwhandle->buffer, sizeof fwhandle->buffer); if (len < 0) return -1; - u = (void *) handle->buffer; + u = (void *) fwhandle->buffer; switch (u->common.type) { case FW_CDEV_EVENT_BUS_RESET: /* Clear old entry, unless it's been overwritten. */ - phy_id = handle->devices[i].node_id & 0x3f; - if (handle->nodes[phy_id] == i) - handle->nodes[phy_id] = -1; - handle->nodes[u->bus_reset.node_id & 0x3f] = i; - handle->devices[i].node_id = u->bus_reset.node_id; - handle->devices[i].generation = u->bus_reset.generation; + phy_id = fwhandle->devices[i].node_id & 0x3f; + if (fwhandle->nodes[phy_id] == i) + fwhandle->nodes[phy_id] = -1; + fwhandle->nodes[u->bus_reset.node_id & 0x3f] = i; + fwhandle->devices[i].node_id = u->bus_reset.node_id; + fwhandle->devices[i].generation = u->bus_reset.generation; if (u->bus_reset.node_id != u->bus_reset.local_node_id) return 0; - memcpy(&handle->reset, &u->bus_reset, sizeof handle->reset); - return handle->bus_reset_handler(handle, + memcpy(&fwhandle->reset, &u->bus_reset, sizeof fwhandle->reset); + return fwhandle->bus_reset_handler(handle, u->bus_reset.generation); case FW_CDEV_EVENT_RESPONSE: @@ -292,9 +288,9 @@ handle_device_event(raw1394handle_t handle, if (rc->data != NULL) memcpy(rc->data, u->response.data, rc->length); - errcode = juju_to_raw1394_errcode(u->response.rcode); + errcode = fw_to_raw1394_errcode(u->response.rcode); - return handle->tag_handler(handle, rc->tag, errcode); + return fwhandle->tag_handler(handle, rc->tag, errcode); case FW_CDEV_EVENT_REQUEST: ac = u64_to_ptr(u->request.closure); @@ -311,6 +307,7 @@ static int handle_inotify(raw1394handle_t handle, struct epoll_closure *ec, __uint32_t events) { + fw_handle_t fwhandle = handle->mode.fw; struct inotify_event *event; char filename[32]; struct fw_cdev_get_info info; @@ -318,8 +315,8 @@ handle_inotify(raw1394handle_t handle, struct epoll_closure *ec, struct epoll_event ep; int i, len, fd, phy_id; - event = (struct inotify_event *) handle->buffer; - len = read(handle->inotify_fd, event, BUFFER_SIZE); + event = (struct inotify_event *) fwhandle->buffer; + len = read(fwhandle->inotify_fd, event, BUFFER_SIZE); if (!(event->mask & IN_CREATE)) return -1; if (strncmp(event->name, @@ -354,7 +351,7 @@ handle_inotify(raw1394handle_t handle, struct epoll_closure *ec, } for (i = 0; i < MAX_DEVICES; i++) - if (handle->devices[i].node_id == -1) + if (fwhandle->devices[i].node_id == -1) break; if (i == MAX_DEVICES) { close(fd); @@ -362,16 +359,16 @@ handle_inotify(raw1394handle_t handle, struct epoll_closure *ec, } phy_id = reset.node_id & 0x3f; - handle->nodes[phy_id] = i; - handle->devices[i].node_id = reset.node_id; - handle->devices[i].generation = reset.generation; - handle->devices[i].fd = fd; - strncpy(handle->devices[i].filename, filename, - sizeof handle->devices[i].filename); - handle->devices[i].closure.func = handle_device_event; + fwhandle->nodes[phy_id] = i; + fwhandle->devices[i].node_id = reset.node_id; + fwhandle->devices[i].generation = reset.generation; + fwhandle->devices[i].fd = fd; + strncpy(fwhandle->devices[i].filename, filename, + sizeof fwhandle->devices[i].filename); + fwhandle->devices[i].closure.func = handle_device_event; ep.events = EPOLLIN; - ep.data.ptr = &handle->devices[i].closure; - if (epoll_ctl(handle->epoll_fd, EPOLL_CTL_ADD, fd, &ep) < 0) { + ep.data.ptr = &fwhandle->devices[i].closure; + if (epoll_ctl(fwhandle->epoll_fd, EPOLL_CTL_ADD, fd, &ep) < 0) { close(fd); return -1; } @@ -379,13 +376,13 @@ handle_inotify(raw1394handle_t handle, struct epoll_closure *ec, return 0; } -int raw1394_loop_iterate(raw1394handle_t handle) +int fw_loop_iterate(raw1394handle_t handle) { int i, count, retval = 0; struct epoll_closure *closure; struct epoll_event ep[32]; - count = epoll_wait(handle->epoll_fd, ep, ARRAY_LENGTH(ep), -1); + count = epoll_wait(handle->mode.fw->epoll_fd, ep, ARRAY_LENGTH(ep), -1); if (count < 0) return -1; @@ -396,14 +393,14 @@ int raw1394_loop_iterate(raw1394handle_t handle) /* It looks like we have to add this work-around to get epoll * to recompute the POLLIN status of the epoll_fd. */ - epoll_wait(handle->epoll_fd, ep, ARRAY_LENGTH(ep), 0); + epoll_wait(handle->mode.fw->epoll_fd, ep, ARRAY_LENGTH(ep), 0); return retval; } -raw1394handle_t raw1394_new_handle(void) +fw_handle_t fw_new_handle(void) { - raw1394handle_t handle; + fw_handle_t handle; struct epoll_event ep; int i; @@ -469,7 +466,7 @@ raw1394handle_t raw1394_new_handle(void) return NULL; } -void raw1394_destroy_handle(raw1394handle_t handle) +void fw_destroy_handle(fw_handle_t handle) { int i; @@ -491,58 +488,48 @@ void raw1394_destroy_handle(raw1394handle_t handle) return; } -raw1394handle_t raw1394_new_handle_on_port(int port) +fw_handle_t fw_new_handle_on_port(int port) { - raw1394handle_t handle; + fw_handle_t handle; - handle = raw1394_new_handle(); + handle = fw_new_handle(); if (handle == NULL) return NULL; - if (raw1394_set_port(handle, port) < 0) + if (fw_set_port(handle, port) < 0) return NULL; return handle; } -int raw1394_busreset_notify (raw1394handle_t handle, int off_on_switch) +int fw_busreset_notify (fw_handle_t handle, int off_on_switch) { handle->notify_bus_reset = off_on_switch; return 0; } -int raw1394_get_fd(raw1394handle_t handle) +int fw_get_fd(fw_handle_t handle) { return handle->epoll_fd; } -void raw1394_set_userdata(raw1394handle_t handle, void *data) -{ - handle->user_data = data; -} - -void *raw1394_get_userdata(raw1394handle_t handle) -{ - return handle->user_data; -} - -nodeid_t raw1394_get_local_id(raw1394handle_t handle) +nodeid_t fw_get_local_id(fw_handle_t handle) { return handle->reset.local_node_id; } -nodeid_t raw1394_get_irm_id(raw1394handle_t handle) +nodeid_t fw_get_irm_id(fw_handle_t handle) { return handle->reset.irm_node_id; } -int raw1394_get_nodecount(raw1394handle_t handle) +int fw_get_nodecount(fw_handle_t handle) { return (handle->reset.root_node_id & 0x3f) + 1; } -int raw1394_get_port_info(raw1394handle_t handle, +int fw_get_port_info(fw_handle_t handle, struct raw1394_portinfo *pinf, int maxports) { @@ -560,7 +547,7 @@ int raw1394_get_port_info(raw1394handle_t handle, return handle->port_count; } -int raw1394_set_port(raw1394handle_t handle, int port) +int fw_set_port(fw_handle_t handle, int port) { struct fw_cdev_get_info get_info; struct fw_cdev_event_bus_reset reset; @@ -637,12 +624,7 @@ int raw1394_set_port(raw1394handle_t handle, int port) return 0; } -int raw1394_reset_bus(raw1394handle_t handle) -{ - return raw1394_reset_bus_new(handle, RAW1394_LONG_RESET); -} - -int raw1394_reset_bus_new(raw1394handle_t handle, int type) +int fw_reset_bus_new(fw_handle_t handle, int type) { struct fw_cdev_initiate_bus_reset initiate; @@ -659,56 +641,6 @@ int raw1394_reset_bus_new(raw1394handle_t handle, int type) FW_CDEV_IOC_INITIATE_BUS_RESET, &initiate); } -bus_reset_handler_t raw1394_set_bus_reset_handler(raw1394handle_t handle, - bus_reset_handler_t new_h) -{ - bus_reset_handler_t old_h = handle->bus_reset_handler; - - handle->bus_reset_handler = new_h; - - return old_h; -} - -unsigned int raw1394_get_generation(raw1394handle_t handle) -{ - return handle->generation; -} - -void raw1394_update_generation(raw1394handle_t handle, unsigned int generation) -{ - handle->generation = generation; -} - -tag_handler_t -raw1394_set_tag_handler(raw1394handle_t handle, tag_handler_t new_h) -{ - tag_handler_t old_h = handle->tag_handler; - - handle->tag_handler = new_h; - - return old_h; -} - -arm_tag_handler_t -raw1394_set_arm_tag_handler(raw1394handle_t handle, arm_tag_handler_t new_h) -{ - arm_tag_handler_t old_h = handle->arm_tag_handler; - - handle->arm_tag_handler = new_h; - - return old_h; -} - -fcp_handler_t -raw1394_set_fcp_handler(raw1394handle_t handle, fcp_handler_t new_h) -{ - fcp_handler_t old_h = handle->fcp_handler; - - handle->fcp_handler = new_h; - - return old_h; -} - struct request_response_block { struct raw1394_arm_request_response request_response; struct raw1394_arm_request request; @@ -734,6 +666,7 @@ static int handle_arm_request(raw1394handle_t handle, struct address_closure *ac, struct fw_cdev_event_request *request, int i) { + fw_handle_t fwhandle = handle->mode.fw; struct allocation *allocation = (struct allocation *) ac; struct request_response_block *rrb; struct fw_cdev_send_response response; @@ -785,7 +718,7 @@ handle_arm_request(raw1394handle_t handle, struct address_closure *ac, response.rcode = RCODE_TYPE_ERROR; response.length = 0; response.data = 0; - if (ioctl(handle->devices[i].fd, + if (ioctl(fwhandle->devices[i].fd, FW_CDEV_IOC_SEND_RESPONSE, &response) < 0) return -1; } else if (!(allocation->client_transactions & type)) { @@ -795,7 +728,7 @@ handle_arm_request(raw1394handle_t handle, struct address_closure *ac, else if (type == RAW1394_ARM_LOCK) /* FIXME: do lock ops here */; - if (ioctl(handle->devices[i].fd, + if (ioctl(fwhandle->devices[i].fd, FW_CDEV_IOC_SEND_RESPONSE, &response) < 0) return -1; } @@ -808,8 +741,8 @@ handle_arm_request(raw1394handle_t handle, struct address_closure *ac, rrb->request_response.request = &rrb->request; rrb->request_response.response = &rrb->response; - rrb->request.destination_nodeid = handle->reset.local_node_id; - rrb->request.source_nodeid = handle->devices[i].node_id; + rrb->request.destination_nodeid = fwhandle->reset.local_node_id; + rrb->request.source_nodeid = fwhandle->devices[i].node_id; rrb->request.destination_offset = request->offset; rrb->request.tlabel = 0; if (request->tcode < 0x10) { @@ -819,7 +752,7 @@ handle_arm_request(raw1394handle_t handle, struct address_closure *ac, rrb->request.tcode = TCODE_LOCK_REQUEST; rrb->request.extended_transaction_code = request->tcode - 0x10; } - rrb->request.generation = handle->reset.generation; + rrb->request.generation = fwhandle->reset.generation; rrb->request.buffer_length = in_length; memcpy(rrb->request.buffer, request->data, in_length); @@ -828,13 +761,13 @@ handle_arm_request(raw1394handle_t handle, struct address_closure *ac, memcpy(rrb->response.buffer, allocation->data + offset, response.length); - return handle->arm_tag_handler(handle, allocation->tag, type, + return fwhandle->arm_tag_handler(handle, allocation->tag, type, request->length, &rrb->request_response); } int -raw1394_arm_register(raw1394handle_t handle, nodeaddr_t start, +fw_arm_register(fw_handle_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, @@ -877,7 +810,7 @@ raw1394_arm_register(raw1394handle_t handle, nodeaddr_t start, } static struct allocation * -lookup_allocation(raw1394handle_t handle, nodeaddr_t start, int delete) +lookup_allocation(fw_handle_t handle, nodeaddr_t start, int delete) { struct allocation *a, **prev; @@ -895,7 +828,7 @@ lookup_allocation(raw1394handle_t handle, nodeaddr_t start, int delete) } int -raw1394_arm_unregister(raw1394handle_t handle, nodeaddr_t start) +fw_arm_unregister(fw_handle_t handle, nodeaddr_t start) { struct fw_cdev_deallocate request; struct allocation *allocation; @@ -913,7 +846,7 @@ raw1394_arm_unregister(raw1394handle_t handle, nodeaddr_t start) } int -raw1394_arm_set_buf(raw1394handle_t handle, nodeaddr_t start, +fw_arm_set_buf(fw_handle_t handle, nodeaddr_t start, size_t length, void *buf) { struct allocation *allocation; @@ -930,7 +863,7 @@ raw1394_arm_set_buf(raw1394handle_t handle, nodeaddr_t start, } int -raw1394_arm_get_buf(raw1394handle_t handle, nodeaddr_t start, +fw_arm_get_buf(fw_handle_t handle, nodeaddr_t start, size_t length, void *buf) { struct allocation *allocation; @@ -947,24 +880,24 @@ raw1394_arm_get_buf(raw1394handle_t handle, nodeaddr_t start, } int -raw1394_echo_request(raw1394handle_t handle, quadlet_t data) +fw_echo_request(fw_handle_t handle, quadlet_t data) { return write(handle->pipe_fds[1], &data, sizeof data); } -int raw1394_wake_up(raw1394handle_t handle) +int fw_wake_up(fw_handle_t handle) { - return raw1394_echo_request(handle, 0); + return fw_echo_request(handle, 0); } -int raw1394_phy_packet_write (raw1394handle_t handle, quadlet_t data) +int fw_phy_packet_write (fw_handle_t handle, quadlet_t data) { errno = ENOSYS; return -1; } int -raw1394_start_phy_packet_write(raw1394handle_t handle, +fw_start_phy_packet_write(fw_handle_t handle, quadlet_t data, unsigned long tag) { errno = ENOSYS; @@ -972,7 +905,7 @@ raw1394_start_phy_packet_write(raw1394handle_t handle, } static int -send_request(raw1394handle_t handle, int tcode, +send_request(fw_handle_t handle, int tcode, nodeid_t node, nodeaddr_t addr, size_t length, void *in, void *out, unsigned long tag) { @@ -982,27 +915,27 @@ send_request(raw1394handle_t handle, int tcode, if (node > handle->reset.root_node_id) { handle->err = -RCODE_NO_ACK; - errno = raw1394_errcode_to_errno(handle->err); + errno = fw_errcode_to_errno(handle->err); return -1; } i = handle->nodes[node & 0x3f]; if (i == -1) { handle->err = -RCODE_NO_ACK; - errno = raw1394_errcode_to_errno(handle->err); + errno = fw_errcode_to_errno(handle->err); return -1; } if (handle->generation != handle->devices[i].generation) { handle->err = -RCODE_GENERATION; - errno = raw1394_errcode_to_errno(handle->err); + errno = fw_errcode_to_errno(handle->err); return -1; } closure = malloc(sizeof *closure); if (closure == NULL) { handle->err = -RCODE_SEND_ERROR; - errno = raw1394_errcode_to_errno(handle->err); + errno = fw_errcode_to_errno(handle->err); return -1; } @@ -1022,7 +955,7 @@ send_request(raw1394handle_t handle, int tcode, } int -raw1394_start_read(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, +fw_start_read(fw_handle_t handle, nodeid_t node, nodeaddr_t addr, size_t length, quadlet_t *buffer, unsigned long tag) { int tcode; @@ -1037,7 +970,7 @@ raw1394_start_read(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, } int -raw1394_start_write(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, +fw_start_write(fw_handle_t handle, nodeid_t node, nodeaddr_t addr, size_t length, quadlet_t *data, unsigned long tag) { int tcode; @@ -1098,7 +1031,7 @@ setup_lock64(int extcode, octlet_t data, octlet_t arg, octlet_t *buffer) } int -raw1394_start_lock(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, +fw_start_lock(fw_handle_t handle, nodeid_t node, nodeaddr_t addr, unsigned int extcode, quadlet_t data, quadlet_t arg, quadlet_t *result, unsigned long tag) { @@ -1114,7 +1047,7 @@ raw1394_start_lock(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, } int -raw1394_start_lock64(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, +fw_start_lock64(fw_handle_t handle, nodeid_t node, nodeaddr_t addr, unsigned int extcode, octlet_t data, octlet_t arg, octlet_t *result, unsigned long tag) { @@ -1130,7 +1063,7 @@ raw1394_start_lock64(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, } int -raw1394_start_async_stream(raw1394handle_t handle, unsigned int channel, +fw_start_async_stream(fw_handle_t handle, unsigned int channel, unsigned int tag, unsigned int sy, unsigned int speed, size_t length, quadlet_t *data, unsigned long rawtag) @@ -1141,7 +1074,7 @@ raw1394_start_async_stream(raw1394handle_t handle, unsigned int channel, int -raw1394_start_async_send(raw1394handle_t handle, +fw_start_async_send(fw_handle_t handle, size_t length, size_t header_length, unsigned int expect_response, quadlet_t *data, unsigned long rawtag) @@ -1171,6 +1104,7 @@ send_request_sync(raw1394handle_t handle, int tcode, nodeid_t node, nodeaddr_t addr, size_t length, void *in, void *out) { + fw_handle_t fwhandle = handle->mode.fw; struct raw1394_reqhandle reqhandle; struct sync_data sd = { 0, 0 }; int err; @@ -1178,23 +1112,23 @@ send_request_sync(raw1394handle_t handle, int tcode, reqhandle.callback = sync_callback; reqhandle.data = &sd; - err = send_request(handle, tcode, node, addr, + err = send_request(fwhandle, tcode, node, addr, length, in, out, (unsigned long) &reqhandle); while (!sd.done) { if (err < 0) return err; - err = raw1394_loop_iterate(handle); + err = fw_loop_iterate(handle); } - handle->err = sd.err; - errno = raw1394_errcode_to_errno(sd.err); + fwhandle->err = sd.err; + errno = fw_errcode_to_errno(sd.err); return (errno ? -1 : 0); } int -raw1394_read(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, +fw_read(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, size_t length, quadlet_t *buffer) { int tcode; @@ -1209,7 +1143,7 @@ raw1394_read(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, } int -raw1394_write(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, +fw_write(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, size_t length, quadlet_t *data) { int tcode; @@ -1224,7 +1158,7 @@ raw1394_write(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, } int -raw1394_lock(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, +fw_lock(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, unsigned int extcode, quadlet_t data, quadlet_t arg, quadlet_t *result) { @@ -1240,7 +1174,7 @@ raw1394_lock(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, } int -raw1394_lock64(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, +fw_lock64(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, unsigned int extcode, octlet_t data, octlet_t arg, octlet_t *result) { @@ -1256,7 +1190,7 @@ raw1394_lock64(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, } int -raw1394_async_stream(raw1394handle_t handle, unsigned int channel, +fw_async_stream(fw_handle_t handle, unsigned int channel, unsigned int tag, unsigned int sy, unsigned int speed, size_t length, quadlet_t *data) { @@ -1265,7 +1199,7 @@ raw1394_async_stream(raw1394handle_t handle, unsigned int channel, } int -raw1394_async_send(raw1394handle_t handle, +fw_async_send(fw_handle_t handle, size_t length, size_t header_length, unsigned int expect_response, quadlet_t *data) @@ -1275,7 +1209,7 @@ raw1394_async_send(raw1394handle_t handle, } int -raw1394_start_fcp_listen(raw1394handle_t handle) +fw_start_fcp_listen(fw_handle_t handle) { struct fw_cdev_allocate request; struct address_closure *closure; @@ -1298,7 +1232,7 @@ raw1394_start_fcp_listen(raw1394handle_t handle) } int -raw1394_stop_fcp_listen(raw1394handle_t handle) +fw_stop_fcp_listen(fw_handle_t handle) { struct fw_cdev_deallocate request; @@ -1307,21 +1241,15 @@ raw1394_stop_fcp_listen(raw1394handle_t handle) return ioctl(handle->local_fd, FW_CDEV_IOC_DEALLOCATE, &request); } -const char * -raw1394_get_libversion(void) -{ - return VERSION " (Juju)"; -} - int -raw1394_update_config_rom(raw1394handle_t handle, const quadlet_t *new_rom, +fw_update_config_rom(fw_handle_t handle, const quadlet_t *new_rom, size_t size, unsigned char rom_version) { return -1; } int -raw1394_get_config_rom(raw1394handle_t handle, quadlet_t *buffer, +fw_get_config_rom(fw_handle_t handle, quadlet_t *buffer, size_t buffersize, size_t *rom_size, unsigned char *rom_version) { @@ -1346,13 +1274,13 @@ raw1394_get_config_rom(raw1394handle_t handle, quadlet_t *buffer, #define MAXIMUM_BANDWIDTH 4915 int -raw1394_bandwidth_modify (raw1394handle_t handle, +fw_bandwidth_modify (raw1394handle_t handle, unsigned int bandwidth, enum raw1394_modify_mode mode) { - quadlet_t buffer, compare, swap; + quadlet_t buffer, compare, swap; nodeaddr_t addr; - int result; + int result; if (bandwidth == 0) return 0; @@ -1392,7 +1320,7 @@ raw1394_bandwidth_modify (raw1394handle_t handle, } int -raw1394_channel_modify (raw1394handle_t handle, +fw_channel_modify (raw1394handle_t handle, unsigned int channel, enum raw1394_modify_mode mode) { 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 + * + * 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 + +#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 * * 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 diff --git a/tools/Makefile.am b/tools/Makefile.am index 5be1b6f..29b250e 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -2,4 +2,4 @@ MAINTAINERCLEANFILES = Makefile.in # testlibraw bin_PROGRAMS = testlibraw sendiso dumpiso -LDADD = ../$(LIB_SUBDIR)/libraw1394.la +LDADD = ../src/libraw1394.la