From 1a91281532f25b2109b02d5560d1c4605dd20183 Mon Sep 17 00:00:00 2001 From: aeb Date: Tue, 8 Aug 2000 00:29:08 +0000 Subject: [PATCH] Added raw1394_get_irm_id(). git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@35 53a565d1-3bb7-0310-b661-cf11e63c67ab --- NEWS | 1 + src/eventloop.c | 11 +++++++++-- src/kernel-raw1394.h | 3 ++- src/main.c | 23 +++++++++++++++++++++-- src/raw1394.h | 1 + src/raw1394_private.h | 2 ++ src/testlibraw.c | 5 +++-- 7 files changed, 39 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index 223a30c..0845ec7 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ Version 0.8: +- function to query isochronous resource manager ID - functions for isochronous sending - new raw1394_reset_bus() function to reset the bus diff --git a/src/eventloop.c b/src/eventloop.c index 5a47fc4..813acb4 100644 --- a/src/eventloop.c +++ b/src/eventloop.c @@ -28,8 +28,15 @@ int raw1394_loop_iterate(struct raw1394_handle *handle) switch (req->type) { case RAW1394_REQ_BUS_RESET: handle->generation = req->generation; - handle->num_of_nodes = req->misc & 0xffff; - handle->local_id = req->misc >> 16; + + if (handle->protocol_version == 3) { + handle->num_of_nodes = req->misc & 0xffff; + handle->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; + } if (handle->bus_reset_handler) { retval = handle->bus_reset_handler(handle); diff --git a/src/kernel-raw1394.h b/src/kernel-raw1394.h index 4f8b3f7..98c6298 100644 --- a/src/kernel-raw1394.h +++ b/src/kernel-raw1394.h @@ -4,7 +4,7 @@ #define RAW1394_DEVICE_MAJOR 171 #define RAW1394_DEVICE_NAME "raw1394" -#define RAW1394_KERNELAPI_VERSION 3 +#define RAW1394_KERNELAPI_VERSION 4 /* state: opened */ #define RAW1394_REQ_INITIALIZE 1 @@ -81,6 +81,7 @@ struct file_info { struct list_head list; enum { opened, initialized, connected } state; + unsigned int protocol_version; struct hpsb_host *host; diff --git a/src/main.c b/src/main.c index 2e6d99f..0fe887b 100644 --- a/src/main.c +++ b/src/main.c @@ -56,9 +56,17 @@ static unsigned int init_rawdevice(struct raw1394_handle *h) CLEAR_REQ(req); req->type = RAW1394_REQ_INITIALIZE; req->misc = RAW1394_KERNELAPI_VERSION; + h->protocol_version = RAW1394_KERNELAPI_VERSION; if (write(h->fd, req, sizeof(*req)) < 0) return -1; if (read(h->fd, req, sizeof(*req)) < 0) return -1; + + if (req->error == RAW1394_ERROR_COMPAT && req->misc == 3) { + h->protocol_version = 3; + if (write(h->fd, req, sizeof(*req)) < 0) return -1; + if (read(h->fd, req, sizeof(*req)) < 0) return -1; + } + if (req->error) { errno = 0; return -1; @@ -125,6 +133,11 @@ nodeid_t raw1394_get_local_id(struct raw1394_handle *handle) return handle->local_id; } +nodeid_t raw1394_get_irm_id(struct raw1394_handle *handle) +{ + return handle->irm_id; +} + void *raw1394_get_userdata(struct raw1394_handle *handle) { return handle->userdata; @@ -193,8 +206,14 @@ int raw1394_set_port(struct raw1394_handle *handle, int port) errno = EINVAL; return -1; case RAW1394_ERROR_NONE: - handle->num_of_nodes = req->misc & 0xffff; - handle->local_id = req->misc >> 16; + if (handle->protocol_version == 3) { + handle->num_of_nodes = req->misc & 0xffff; + handle->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; + } return 0; default: errno = 0; diff --git a/src/raw1394.h b/src/raw1394.h index d95217e..9c8fae6 100644 --- a/src/raw1394.h +++ b/src/raw1394.h @@ -40,6 +40,7 @@ void raw1394_set_userdata(raw1394handle_t handle, void *data); unsigned int raw1394_get_generation(raw1394handle_t handle); nodeid_t raw1394_get_local_id(raw1394handle_t handle); +nodeid_t raw1394_get_irm_id(raw1394handle_t handle); /* Get number of nodes on bus. */ int raw1394_get_nodecount(raw1394handle_t handle); diff --git a/src/raw1394_private.h b/src/raw1394_private.h index fed60c9..86688c7 100644 --- a/src/raw1394_private.h +++ b/src/raw1394_private.h @@ -4,10 +4,12 @@ struct raw1394_handle { int fd; + int protocol_version; unsigned int generation; nodeid_t local_id; int num_of_nodes; + nodeid_t irm_id; bus_reset_handler_t bus_reset_handler; tag_handler_t tag_handler; diff --git a/src/testlibraw.c b/src/testlibraw.c index 80dfb12..3f10b9a 100644 --- a/src/testlibraw.c +++ b/src/testlibraw.c @@ -107,9 +107,10 @@ int main(int argc, char **argv) exit(1); } - printf("using first card found: %d nodes on bus, local ID is %d\n", + printf("using first card found: %d nodes on bus, local ID is %d, IRM is %d\n", raw1394_get_nodecount(handle), - raw1394_get_local_id(handle) & 0x3f); + raw1394_get_local_id(handle) & 0x3f, + raw1394_get_irm_id(handle) & 0x3f); printf("\ndoing transactions with custom tag handler\n"); std_handler = raw1394_set_tag_handler(handle, my_tag_handler);