diff options
| author | 2002-10-23 21:18:49 +0000 | |
|---|---|---|
| committer | 2002-10-23 21:18:49 +0000 | |
| commit | 915a20a96f6fb81249f140a114b94f2b1502149d (patch) | |
| tree | 78511c7186615b5d3473bd72f9b513ba5d9e00e1 /src/readwrite.c | |
| parent | configure.ac: (diff) | |
merged weihs branch
git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@84 53a565d1-3bb7-0310-b661-cf11e63c67ab
Diffstat (limited to 'src/readwrite.c')
| -rw-r--r-- | src/readwrite.c | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/src/readwrite.c b/src/readwrite.c index bb918d4..4573137 100644 --- a/src/readwrite.c +++ b/src/readwrite.c @@ -2,15 +2,29 @@ * libraw1394 - library for raw access to the 1394 bus with the Linux subsystem. * * Copyright (C) 1999,2000,2001,2002 Andreas Bombe + * 2002 Christian Toegel <christian.toegel@gmx.at> + * 2002 Manfred Weihs <weihs@ict.tuwien.ac.at> * * 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. + * + * + * Contributions: + * + * Christian Toegel <christian.toegel@gmx.at> + * lock64 request + * transmit physical packet + * raw1394_echo_request, raw1394_wake_up (interrupt blocking wait) + * + * Manfred Weihs <weihs@ict.tuwien.ac.at> + * raw1394_start_async_send, raw1394_async_send */ #include <config.h> #include <unistd.h> #include <errno.h> +#include <string.h> #include "raw1394.h" #include "kernel-raw1394.h" @@ -150,6 +164,44 @@ int raw1394_start_lock(struct raw1394_handle *handle, nodeid_t node, req->length = 8; break; } + return (int)write(handle->fd, req, sizeof(*req)); +} + +int raw1394_start_lock64(struct raw1394_handle *handle, nodeid_t node, + nodeaddr_t addr, unsigned int extcode, octlet_t data, + octlet_t arg, octlet_t *result, unsigned long tag) +{ + struct raw1394_request *req = &handle->req; + octlet_t sendbuf[2]; + + if ((extcode > 7) || (extcode == 0)) { + errno = EINVAL; + return -1; + } + + CLEAR_REQ(req); + + req->type = RAW1394_REQ_LOCK64; + req->generation = handle->generation; + req->tag = tag; + + req->address = ((__u64)node << 48) | addr; + req->sendb = ptr2int(sendbuf); + req->recvb = ptr2int(result); + req->misc = extcode; + + switch (extcode) { + case 3: /* EXTCODE_FETCH_ADD */ + case 4: /* EXTCODE_LITTLE_ADD */ + sendbuf[0] = data; + req->length = 8; + break; + default: + sendbuf[0] = arg; + sendbuf[1] = data; + req->length = 16; + break; + } return (int)write(handle->fd, req, sizeof(*req)); } @@ -197,6 +249,25 @@ int raw1394_start_iso_write(struct raw1394_handle *handle, unsigned int channel, return (int)write(handle->fd, req, sizeof(*req)); } +int raw1394_start_async_send(struct raw1394_handle *handle, + size_t length, size_t header_length, unsigned int expect_response, + quadlet_t *data, unsigned long rawtag) +{ + struct raw1394_request *req = &handle->req; + + CLEAR_REQ(req); + + req->type = RAW1394_REQ_ASYNC_SEND; + req->generation = handle->generation; + req->tag = rawtag; + + req->length = length; + req->misc = (expect_response << 16) | (header_length & 0xffff); + req->sendb = ptr2int(data); + + return (int)write(handle->fd, req, sizeof(*req)); +} + #define SYNCFUNC_VARS \ struct sync_cb_data sd = { 0, 0 }; \ @@ -247,6 +318,19 @@ int raw1394_lock(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr, SYNCFUNC_BODY; } +int raw1394_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, + (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) @@ -259,5 +343,66 @@ int raw1394_iso_write(struct raw1394_handle *handle, unsigned int channel, SYNCFUNC_BODY; } +int raw1394_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, + data, (unsigned long)&rh); + + SYNCFUNC_BODY; +} + + + +int raw1394_start_phy_packet_write(struct raw1394_handle *handle, + quadlet_t data, unsigned long tag) +{ + struct raw1394_request *req = &handle->req; + + CLEAR_REQ(req); + + req->type = RAW1394_REQ_PHYPACKET; + req->generation = handle->generation; + req->tag = tag; + + req->sendb = data; + + return (int)write(handle->fd, req, sizeof(*req)); +} + +int raw1394_phy_packet_write (struct raw1394_handle *handle, quadlet_t data) +{ + SYNCFUNC_VARS; + + err = raw1394_start_phy_packet_write(handle, data, (unsigned long)&rh); + + SYNCFUNC_BODY; /* return 0 on success */ +} + +int raw1394_echo_request(struct raw1394_handle *handle, quadlet_t data) +{ + struct raw1394_request *req = &handle->req; + int retval=0; + + CLEAR_REQ(req); + + req->type = RAW1394_REQ_ECHO; + req->misc = data; + + retval = (int)write(handle->fd, req, sizeof(*req)); + if (retval == sizeof(*req)) { + return 0; /* succcess */ + } + return -1; +} + +int raw1394_wake_up(raw1394handle_t handle) +{ + return raw1394_echo_request(handle, 0); +} + #undef SYNCFUNC_VARS #undef SYNCFUNC_BODY |
