Added raw1394_get_irm_id().
git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@35 53a565d1-3bb7-0310-b661-cf11e63c67ab
This commit is contained in:
parent
6ac98fd9fd
commit
1a91281532
1
NEWS
1
NEWS
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
Version 0.8:
|
Version 0.8:
|
||||||
|
|
||||||
|
- function to query isochronous resource manager ID
|
||||||
- functions for isochronous sending
|
- functions for isochronous sending
|
||||||
- new raw1394_reset_bus() function to reset the bus
|
- new raw1394_reset_bus() function to reset the bus
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,15 @@ int raw1394_loop_iterate(struct raw1394_handle *handle)
|
||||||
switch (req->type) {
|
switch (req->type) {
|
||||||
case RAW1394_REQ_BUS_RESET:
|
case RAW1394_REQ_BUS_RESET:
|
||||||
handle->generation = req->generation;
|
handle->generation = req->generation;
|
||||||
|
|
||||||
|
if (handle->protocol_version == 3) {
|
||||||
handle->num_of_nodes = req->misc & 0xffff;
|
handle->num_of_nodes = req->misc & 0xffff;
|
||||||
handle->local_id = req->misc >> 16;
|
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) {
|
if (handle->bus_reset_handler) {
|
||||||
retval = handle->bus_reset_handler(handle);
|
retval = handle->bus_reset_handler(handle);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#define RAW1394_DEVICE_MAJOR 171
|
#define RAW1394_DEVICE_MAJOR 171
|
||||||
#define RAW1394_DEVICE_NAME "raw1394"
|
#define RAW1394_DEVICE_NAME "raw1394"
|
||||||
|
|
||||||
#define RAW1394_KERNELAPI_VERSION 3
|
#define RAW1394_KERNELAPI_VERSION 4
|
||||||
|
|
||||||
/* state: opened */
|
/* state: opened */
|
||||||
#define RAW1394_REQ_INITIALIZE 1
|
#define RAW1394_REQ_INITIALIZE 1
|
||||||
|
@ -81,6 +81,7 @@ struct file_info {
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
|
|
||||||
enum { opened, initialized, connected } state;
|
enum { opened, initialized, connected } state;
|
||||||
|
unsigned int protocol_version;
|
||||||
|
|
||||||
struct hpsb_host *host;
|
struct hpsb_host *host;
|
||||||
|
|
||||||
|
|
19
src/main.c
19
src/main.c
|
@ -56,9 +56,17 @@ static unsigned int init_rawdevice(struct raw1394_handle *h)
|
||||||
CLEAR_REQ(req);
|
CLEAR_REQ(req);
|
||||||
req->type = RAW1394_REQ_INITIALIZE;
|
req->type = RAW1394_REQ_INITIALIZE;
|
||||||
req->misc = RAW1394_KERNELAPI_VERSION;
|
req->misc = RAW1394_KERNELAPI_VERSION;
|
||||||
|
h->protocol_version = RAW1394_KERNELAPI_VERSION;
|
||||||
|
|
||||||
if (write(h->fd, req, sizeof(*req)) < 0) return -1;
|
if (write(h->fd, req, sizeof(*req)) < 0) return -1;
|
||||||
if (read(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) {
|
if (req->error) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -125,6 +133,11 @@ nodeid_t raw1394_get_local_id(struct raw1394_handle *handle)
|
||||||
return handle->local_id;
|
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)
|
void *raw1394_get_userdata(struct raw1394_handle *handle)
|
||||||
{
|
{
|
||||||
return handle->userdata;
|
return handle->userdata;
|
||||||
|
@ -193,8 +206,14 @@ int raw1394_set_port(struct raw1394_handle *handle, int port)
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
case RAW1394_ERROR_NONE:
|
case RAW1394_ERROR_NONE:
|
||||||
|
if (handle->protocol_version == 3) {
|
||||||
handle->num_of_nodes = req->misc & 0xffff;
|
handle->num_of_nodes = req->misc & 0xffff;
|
||||||
handle->local_id = req->misc >> 16;
|
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;
|
return 0;
|
||||||
default:
|
default:
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
|
@ -40,6 +40,7 @@ void raw1394_set_userdata(raw1394handle_t handle, void *data);
|
||||||
|
|
||||||
unsigned int raw1394_get_generation(raw1394handle_t handle);
|
unsigned int raw1394_get_generation(raw1394handle_t handle);
|
||||||
nodeid_t raw1394_get_local_id(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. */
|
/* Get number of nodes on bus. */
|
||||||
int raw1394_get_nodecount(raw1394handle_t handle);
|
int raw1394_get_nodecount(raw1394handle_t handle);
|
||||||
|
|
|
@ -4,10 +4,12 @@
|
||||||
|
|
||||||
struct raw1394_handle {
|
struct raw1394_handle {
|
||||||
int fd;
|
int fd;
|
||||||
|
int protocol_version;
|
||||||
unsigned int generation;
|
unsigned int generation;
|
||||||
|
|
||||||
nodeid_t local_id;
|
nodeid_t local_id;
|
||||||
int num_of_nodes;
|
int num_of_nodes;
|
||||||
|
nodeid_t irm_id;
|
||||||
|
|
||||||
bus_reset_handler_t bus_reset_handler;
|
bus_reset_handler_t bus_reset_handler;
|
||||||
tag_handler_t tag_handler;
|
tag_handler_t tag_handler;
|
||||||
|
|
|
@ -107,9 +107,10 @@ int main(int argc, char **argv)
|
||||||
exit(1);
|
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_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");
|
printf("\ndoing transactions with custom tag handler\n");
|
||||||
std_handler = raw1394_set_tag_handler(handle, my_tag_handler);
|
std_handler = raw1394_set_tag_handler(handle, my_tag_handler);
|
||||||
|
|
Reference in New Issue