aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2011-06-24 11:14:09 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2011-06-24 11:14:09 +0000
commit2485d8a793b882e77fe7be4dc1a034390c96abbb (patch)
tree9880fbd33f8a6cbdcce3e25ce3d8a0726fbaf728
parentecd9e552d0671a9bb49d3193527f04b5e04e9632 (diff)
downloadsrc-2485d8a793b882e77fe7be4dc1a034390c96abbb.tar.gz
src-2485d8a793b882e77fe7be4dc1a034390c96abbb.zip
- Add two new API's to libusb20 which can be used to retrive information
about the parent USB device: - libusb20_dev_get_parent_address - libusb20_dev_get_parent_port - Rename libusb20_compat01.c into libusb01.c MFC after: 3 days
Notes
Notes: svn path=/head/; revision=223495
-rw-r--r--lib/libusb/Makefile4
-rw-r--r--lib/libusb/libusb01.c (renamed from lib/libusb/libusb20_compat01.c)0
-rw-r--r--lib/libusb/libusb20.323
-rw-r--r--lib/libusb/libusb20.c12
-rw-r--r--lib/libusb/libusb20.h2
-rw-r--r--lib/libusb/libusb20_int.h2
-rw-r--r--lib/libusb/libusb20_ugen20.c5
7 files changed, 47 insertions, 1 deletions
diff --git a/lib/libusb/Makefile b/lib/libusb/Makefile
index debbfa285656..f438cff3dec2 100644
--- a/lib/libusb/Makefile
+++ b/lib/libusb/Makefile
@@ -22,7 +22,7 @@ MLINKS+= libusb.3 usb.3
# libusb 0.1 compat
INCS+= usb.h
-SRCS+= libusb20_compat01.c
+SRCS+= libusb01.c
# libusb 1.0 compat
INCS+= libusb.h
@@ -184,6 +184,8 @@ MLINKS += libusb20.3 libusb20_dev_get_device_desc.3
MLINKS += libusb20.3 libusb20_dev_alloc_config.3
MLINKS += libusb20.3 libusb20_dev_alloc.3
MLINKS += libusb20.3 libusb20_dev_get_address.3
+MLINKS += libusb20.3 libusb20_dev_get_parent_address.3
+MLINKS += libusb20.3 libusb20_dev_get_parent_port.3
MLINKS += libusb20.3 libusb20_dev_get_bus_number.3
MLINKS += libusb20.3 libusb20_dev_get_mode.3
MLINKS += libusb20.3 libusb20_dev_get_speed.3
diff --git a/lib/libusb/libusb20_compat01.c b/lib/libusb/libusb01.c
index 4124ef6fbcd5..4124ef6fbcd5 100644
--- a/lib/libusb/libusb20_compat01.c
+++ b/lib/libusb/libusb01.c
diff --git a/lib/libusb/libusb20.3 b/lib/libusb/libusb20.3
index 93dfe18cf5be..042f8853657f 100644
--- a/lib/libusb/libusb20.3
+++ b/lib/libusb/libusb20.3
@@ -159,6 +159,10 @@ USB access library (libusb -lusb)
.Ft uint8_t
.Fn libusb20_dev_get_address "struct libusb20_device *pdev"
.Ft uint8_t
+.Fn libusb20_dev_get_parent_address "struct libusb20_device *pdev"
+.Ft uint8_t
+.Fn libusb20_dev_get_parent_port "struct libusb20_device *pdev"
+.Ft uint8_t
.Fn libusb20_dev_get_bus_number "struct libusb20_device *pdev"
.Ft uint8_t
.Fn libusb20_dev_get_mode "struct libusb20_device *pdev"
@@ -756,12 +760,31 @@ is an internal function to allocate a new USB device.
.Fn libusb20_dev_get_address
returns the internal and not necessarily the real
hardware address of the given USB device.
+Valid addresses start at one.
+.
+.Pp
+.
+.Fn libusb20_dev_get_parent_address
+returns the internal and not necessarily the real hardware address of
+the given parent USB HUB device.
+This value is zero for the root HUB which usually has a device address
+equal to one.
+Valid addresses start at one.
+.
+.Pp
+.
+.Fn libusb20_dev_get_parent_port
+returns the port number on the parent USB HUB device.
+This value is zero for the root HUB which usually has a device address
+equal to one.
+Valid port numbers start at one.
.
.Pp
.
.Fn libusb20_dev_get_bus_number
returns the internal bus number which the given USB
device belongs to.
+Valid bus numbers start at zero.
.
.Pp
.
diff --git a/lib/libusb/libusb20.c b/lib/libusb/libusb20.c
index bcaa1e47ff13..716f5403529d 100644
--- a/lib/libusb/libusb20.c
+++ b/lib/libusb/libusb20.c
@@ -1057,6 +1057,18 @@ libusb20_dev_get_address(struct libusb20_device *pdev)
}
uint8_t
+libusb20_dev_get_parent_address(struct libusb20_device *pdev)
+{
+ return (pdev->parent_address);
+}
+
+uint8_t
+libusb20_dev_get_parent_port(struct libusb20_device *pdev)
+{
+ return (pdev->parent_port);
+}
+
+uint8_t
libusb20_dev_get_bus_number(struct libusb20_device *pdev)
{
return (pdev->bus_number);
diff --git a/lib/libusb/libusb20.h b/lib/libusb/libusb20.h
index 958a379ed254..22a2899bbd80 100644
--- a/lib/libusb/libusb20.h
+++ b/lib/libusb/libusb20.h
@@ -262,6 +262,8 @@ struct LIBUSB20_DEVICE_DESC_DECODED *libusb20_dev_get_device_desc(struct libusb2
struct libusb20_config *libusb20_dev_alloc_config(struct libusb20_device *pdev, uint8_t config_index);
struct libusb20_device *libusb20_dev_alloc(void);
uint8_t libusb20_dev_get_address(struct libusb20_device *pdev);
+uint8_t libusb20_dev_get_parent_address(struct libusb20_device *pdev);
+uint8_t libusb20_dev_get_parent_port(struct libusb20_device *pdev);
uint8_t libusb20_dev_get_bus_number(struct libusb20_device *pdev);
uint8_t libusb20_dev_get_mode(struct libusb20_device *pdev);
uint8_t libusb20_dev_get_speed(struct libusb20_device *pdev);
diff --git a/lib/libusb/libusb20_int.h b/lib/libusb/libusb20_int.h
index 2ecfb4770a39..bef4d02737c5 100644
--- a/lib/libusb/libusb20_int.h
+++ b/lib/libusb/libusb20_int.h
@@ -226,6 +226,8 @@ struct libusb20_device {
uint8_t usb_mode;
uint8_t usb_speed;
uint8_t is_opened;
+ uint8_t parent_address;
+ uint8_t parent_port;
char usb_desc[96];
};
diff --git a/lib/libusb/libusb20_ugen20.c b/lib/libusb/libusb20_ugen20.c
index 933d7286b679..307ed96d2274 100644
--- a/lib/libusb/libusb20_ugen20.c
+++ b/lib/libusb/libusb20_ugen20.c
@@ -195,6 +195,11 @@ ugen20_enumerate(struct libusb20_device *pdev, const char *id)
break;
}
+ /* get parent HUB index and port */
+
+ pdev->parent_address = devinfo.udi_hubindex;
+ pdev->parent_port = devinfo.udi_hubport;
+
/* generate a nice description for printout */
snprintf(pdev->usb_desc, sizeof(pdev->usb_desc),