summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorthompsa <thompsa@FreeBSD.org>2009-02-24 03:43:05 +0000
committerthompsa <thompsa@FreeBSD.org>2009-02-24 03:43:05 +0000
commitf1a1841fd46d19db9e9c9715c72e7253c6821208 (patch)
treef4792f6be15577c3da25ef086c5ab15d262ccb99 /lib
parent8041f6f6948e9212d22713bd2c0c2bec494e144c (diff)
downloadFreeBSD-src-f1a1841fd46d19db9e9c9715c72e7253c6821208.zip
FreeBSD-src-f1a1841fd46d19db9e9c9715c72e7253c6821208.tar.gz
MFp4 //depot/projects/usb@157974
Add support for setting and getting the USB template value through libusb20 and usbconfig. Submitted by: Hans Petter Selasky
Diffstat (limited to 'lib')
-rw-r--r--lib/libusb20/libusb20.324
-rw-r--r--lib/libusb20/libusb20.c17
-rw-r--r--lib/libusb20/libusb20_int.h4
-rw-r--r--lib/libusb20/libusb20_ugen20.c14
4 files changed, 59 insertions, 0 deletions
diff --git a/lib/libusb20/libusb20.3 b/lib/libusb20/libusb20.3
index 8b7639a..3fe8642 100644
--- a/lib/libusb20/libusb20.3
+++ b/lib/libusb20/libusb20.3
@@ -698,6 +698,30 @@ returned.
.
.Sh USB BACKEND OPERATIONS
.
+.Fn libusb20_be_get_template pbackend ptemp
+This function will return the currently selected global USB device
+side mode template into the integer pointer
+.Fa ptemp .
+This function returns zero on success else a LIBUSB20_ERROR value is
+returned.
+.
+.Pp
+.
+.Fn libusb20_be_set_template pbackend temp
+This function will set the global USB device side mode template to
+.Fa temp .
+The new template is not activated until after the next USB
+enumeration.
+The template number decides how the USB device will present itself to
+the USB Host, like Mass Storage Device, USB Ethernet Device. Also see
+the
+.Xr usb2_template 4
+module.
+This function returns zero on success else a LIBUSB20_ERROR value is
+returned.
+.
+.Pp
+.
.Fn libusb20_be_get_dev_quirk pbackend index pquirk
This function will return the device quirk according to
.Fa index
diff --git a/lib/libusb20/libusb20.c b/lib/libusb20/libusb20.c
index 814bd26..52c447d 100644
--- a/lib/libusb20/libusb20.c
+++ b/lib/libusb20/libusb20.c
@@ -1165,6 +1165,23 @@ libusb20_be_get_perm(struct libusb20_backend *pbe, mode_t *mode)
return (pbe->methods->root_get_perm(pbe, mode));
}
+int
+libusb20_be_set_template(struct libusb20_backend *pbe, int temp)
+{
+ return (pbe->methods->root_set_template(pbe, temp));
+}
+
+int
+libusb20_be_get_template(struct libusb20_backend *pbe, int *ptemp)
+{
+ int temp;
+
+ if (ptemp == NULL)
+ ptemp = &temp;
+
+ return (pbe->methods->root_get_template(pbe, ptemp));
+}
+
struct libusb20_device *
libusb20_be_device_foreach(struct libusb20_backend *pbe, struct libusb20_device *pdev)
{
diff --git a/lib/libusb20/libusb20_int.h b/lib/libusb20/libusb20_int.h
index 5e89bfe..b65aac0 100644
--- a/lib/libusb20/libusb20_int.h
+++ b/lib/libusb20/libusb20_int.h
@@ -70,6 +70,8 @@ typedef int (libusb20_root_get_perm_t)(struct libusb20_backend *pbe, mode_t *mod
typedef int (libusb20_root_set_owner_t)(struct libusb20_backend *pbe, uid_t user, gid_t group);
typedef int (libusb20_root_set_perm_t)(struct libusb20_backend *pbe, mode_t mode);
typedef void (libusb20_exit_backend_t)(struct libusb20_backend *pbe);
+typedef int (libusb20_root_set_template_t)(struct libusb20_backend *pbe, int temp);
+typedef int (libusb20_root_get_template_t)(struct libusb20_backend *pbe, int *ptemp);
#define LIBUSB20_DEFINE(n,field) \
libusb20_##field##_t *field;
@@ -105,6 +107,8 @@ typedef void (libusb20_exit_backend_t)(struct libusb20_backend *pbe);
m(n, root_get_owner) \
m(n, root_set_perm) \
m(n, root_get_perm) \
+ m(n, root_set_template) \
+ m(n, root_get_template) \
/* mandatory device methods */ \
m(n, open_device) \
m(n, close_device) \
diff --git a/lib/libusb20/libusb20_ugen20.c b/lib/libusb20/libusb20_ugen20.c
index 7bfe2ce..17a54ea 100644
--- a/lib/libusb20/libusb20_ugen20.c
+++ b/lib/libusb20/libusb20_ugen20.c
@@ -72,6 +72,8 @@ static libusb20_root_set_owner_t ugen20_root_set_owner;
static libusb20_root_get_owner_t ugen20_root_get_owner;
static libusb20_root_set_perm_t ugen20_root_set_perm;
static libusb20_root_get_perm_t ugen20_root_get_perm;
+static libusb20_root_set_template_t ugen20_root_set_template;
+static libusb20_root_get_template_t ugen20_root_get_template;
const struct libusb20_backend_methods libusb20_ugen20_backend = {
LIBUSB20_BACKEND(LIBUSB20_DECLARE, ugen20)
@@ -1179,3 +1181,15 @@ ugen20_root_get_perm(struct libusb20_backend *pbe, mode_t *mode)
return (ugen20_be_do_perm(USB_GET_ROOT_PERM, 0, 0, 0, 0,
NULL, NULL, mode));
}
+
+static int
+ugen20_root_set_template(struct libusb20_backend *pbe, int temp)
+{
+ return (ugen20_be_ioctl(USB_SET_TEMPLATE, &temp));
+}
+
+static int
+ugen20_root_get_template(struct libusb20_backend *pbe, int *ptemp)
+{
+ return (ugen20_be_ioctl(USB_GET_TEMPLATE, ptemp));
+}
OpenPOWER on IntegriCloud