summaryrefslogtreecommitdiffstats
path: root/lib/libusb/libusb20_int.h
diff options
context:
space:
mode:
authorthompsa <thompsa@FreeBSD.org>2009-03-09 17:09:46 +0000
committerthompsa <thompsa@FreeBSD.org>2009-03-09 17:09:46 +0000
commitb95f7329df6e4c18574c02802a132848e5955244 (patch)
tree1a660dc6369df9725d748f63f8b5222d3a420a1c /lib/libusb/libusb20_int.h
parent4aa75fa98d0391c03bb764e4ef26baa6e4f0d6d8 (diff)
downloadFreeBSD-src-b95f7329df6e4c18574c02802a132848e5955244.zip
FreeBSD-src-b95f7329df6e4c18574c02802a132848e5955244.tar.gz
libusb20 is now installed as libusb, remove the version number from the
directory name.
Diffstat (limited to 'lib/libusb/libusb20_int.h')
-rw-r--r--lib/libusb/libusb20_int.h228
1 files changed, 228 insertions, 0 deletions
diff --git a/lib/libusb/libusb20_int.h b/lib/libusb/libusb20_int.h
new file mode 100644
index 0000000..494aa6d
--- /dev/null
+++ b/lib/libusb/libusb20_int.h
@@ -0,0 +1,228 @@
+/* $FreeBSD$ */
+/*-
+ * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * This file describes internal structures.
+ */
+
+#ifndef _LIBUSB20_INT_H_
+#define _LIBUSB20_INT_H_
+
+struct libusb20_device;
+struct libusb20_backend;
+struct libusb20_transfer;
+struct libusb20_quirk;
+
+union libusb20_session_data {
+ unsigned long session_data;
+ struct timespec tv;
+ uint32_t plugtime;
+};
+
+/* USB backend specific */
+typedef const char *(libusb20_get_backend_name_t)(void);
+typedef int (libusb20_root_get_dev_quirk_t)(struct libusb20_backend *pbe, uint16_t index, struct libusb20_quirk *pq);
+typedef int (libusb20_root_get_quirk_name_t)(struct libusb20_backend *pbe, uint16_t index, struct libusb20_quirk *pq);
+typedef int (libusb20_root_add_dev_quirk_t)(struct libusb20_backend *pbe, struct libusb20_quirk *pq);
+typedef int (libusb20_root_remove_dev_quirk_t)(struct libusb20_backend *pbe, struct libusb20_quirk *pq);
+typedef int (libusb20_close_device_t)(struct libusb20_device *pdev);
+typedef int (libusb20_dev_get_info_t)(struct libusb20_device *pdev, struct usb2_device_info *pinfo);
+typedef int (libusb20_dev_get_iface_desc_t)(struct libusb20_device *pdev, uint8_t iface_index, char *buf, uint8_t len);
+typedef int (libusb20_init_backend_t)(struct libusb20_backend *pbe);
+typedef int (libusb20_open_device_t)(struct libusb20_device *pdev, uint16_t transfer_count_max);
+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;
+
+#define LIBUSB20_DECLARE(n,field) \
+ /* .field = */ n##_##field,
+
+#define LIBUSB20_BACKEND(m,n) \
+ /* description of this backend */ \
+ m(n, get_backend_name) \
+ /* optional backend methods */ \
+ m(n, init_backend) \
+ m(n, exit_backend) \
+ m(n, dev_get_info) \
+ m(n, dev_get_iface_desc) \
+ m(n, root_get_dev_quirk) \
+ m(n, root_get_quirk_name) \
+ m(n, root_add_dev_quirk) \
+ m(n, root_remove_dev_quirk) \
+ m(n, root_set_template) \
+ m(n, root_get_template) \
+ /* mandatory device methods */ \
+ m(n, open_device) \
+ m(n, close_device) \
+
+struct libusb20_backend_methods {
+ LIBUSB20_BACKEND(LIBUSB20_DEFINE,)
+};
+
+/* USB dummy methods */
+typedef int (libusb20_dummy_int_t)(void);
+typedef void (libusb20_dummy_void_t)(void);
+
+/* USB device specific */
+typedef int (libusb20_claim_interface_t)(struct libusb20_device *pdev, uint8_t iface_index);
+typedef int (libusb20_detach_kernel_driver_t)(struct libusb20_device *pdev, uint8_t iface_index);
+typedef int (libusb20_do_request_sync_t)(struct libusb20_device *pdev, struct LIBUSB20_CONTROL_SETUP_DECODED *setup, void *data, uint16_t *pactlen, uint32_t timeout, uint8_t flags);
+typedef int (libusb20_get_config_desc_full_t)(struct libusb20_device *pdev, uint8_t **ppbuf, uint16_t *plen, uint8_t index);
+typedef int (libusb20_get_config_index_t)(struct libusb20_device *pdev, uint8_t *pindex);
+typedef int (libusb20_kernel_driver_active_t)(struct libusb20_device *pdev, uint8_t iface_index);
+typedef int (libusb20_process_t)(struct libusb20_device *pdev);
+typedef int (libusb20_release_interface_t)(struct libusb20_device *pdev, uint8_t iface_index);
+typedef int (libusb20_reset_device_t)(struct libusb20_device *pdev);
+typedef int (libusb20_set_power_mode_t)(struct libusb20_device *pdev, uint8_t power_mode);
+typedef int (libusb20_get_power_mode_t)(struct libusb20_device *pdev, uint8_t *power_mode);
+typedef int (libusb20_set_alt_index_t)(struct libusb20_device *pdev, uint8_t iface_index, uint8_t alt_index);
+typedef int (libusb20_set_config_index_t)(struct libusb20_device *pdev, uint8_t index);
+
+/* USB transfer specific */
+typedef int (libusb20_tr_open_t)(struct libusb20_transfer *xfer, uint32_t MaxBufSize, uint32_t MaxFrameCount, uint8_t ep_no);
+typedef int (libusb20_tr_close_t)(struct libusb20_transfer *xfer);
+typedef int (libusb20_tr_clear_stall_sync_t)(struct libusb20_transfer *xfer);
+typedef void (libusb20_tr_submit_t)(struct libusb20_transfer *xfer);
+typedef void (libusb20_tr_cancel_async_t)(struct libusb20_transfer *xfer);
+
+#define LIBUSB20_DEVICE(m,n) \
+ m(n, claim_interface) \
+ m(n, detach_kernel_driver) \
+ m(n, do_request_sync) \
+ m(n, get_config_desc_full) \
+ m(n, get_config_index) \
+ m(n, kernel_driver_active) \
+ m(n, process) \
+ m(n, release_interface) \
+ m(n, reset_device) \
+ m(n, set_power_mode) \
+ m(n, get_power_mode) \
+ m(n, set_alt_index) \
+ m(n, set_config_index) \
+ m(n, tr_cancel_async) \
+ m(n, tr_clear_stall_sync) \
+ m(n, tr_close) \
+ m(n, tr_open) \
+ m(n, tr_submit) \
+
+struct libusb20_device_methods {
+ LIBUSB20_DEVICE(LIBUSB20_DEFINE,)
+};
+
+struct libusb20_backend {
+ TAILQ_HEAD(, libusb20_device) usb_devs;
+ const struct libusb20_backend_methods *methods;
+};
+
+struct libusb20_transfer {
+ struct libusb20_device *pdev; /* the USB device we belong to */
+ libusb20_tr_callback_t *callback;
+ void *priv_sc0; /* private client data */
+ void *priv_sc1; /* private client data */
+ /*
+ * Pointer to a list of buffer pointers:
+ */
+ void **ppBuffer;
+ /*
+ * Pointer to frame lengths, which are updated to actual length
+ * after the USB transfer completes:
+ */
+ uint32_t *pLength;
+ uint32_t maxTotalLength;
+ uint32_t maxFrames; /* total number of frames */
+ uint32_t nFrames; /* total number of frames */
+ uint32_t aFrames; /* actual number of frames */
+ uint32_t timeout;
+ /* isochronous completion time in milliseconds */
+ uint16_t timeComplete;
+ uint16_t trIndex;
+ uint16_t maxPacketLen;
+ uint8_t flags; /* see LIBUSB20_TRANSFER_XXX */
+ uint8_t status; /* see LIBUSB20_TRANSFER_XXX */
+ uint8_t is_opened;
+ uint8_t is_pending;
+ uint8_t is_cancel;
+ uint8_t is_draining;
+ uint8_t is_restart;
+};
+
+struct libusb20_device {
+
+ /* device descriptor */
+ struct LIBUSB20_DEVICE_DESC_DECODED ddesc;
+
+ /* device timestamp */
+ union libusb20_session_data session_data;
+
+ /* our device entry */
+ TAILQ_ENTRY(libusb20_device) dev_entry;
+
+ /* device methods */
+ const struct libusb20_device_methods *methods;
+
+ /* backend methods */
+ const struct libusb20_backend_methods *beMethods;
+
+ /* list of USB transfers */
+ struct libusb20_transfer *pTransfer;
+
+ /* private backend data */
+ void *privBeData;
+
+ /* libUSB v0.1 compat data */
+ void *priv01Data;
+
+ /* claimed interfaces */
+ uint32_t claimed_interfaces;
+
+ /* device file handle */
+ int file;
+
+ /* device file handle (control transfers only) */
+ int file_ctrl;
+
+ /* debugging level */
+ int debug;
+
+ /* number of USB transfers */
+ uint16_t nTransfer;
+
+ uint8_t bus_number;
+ uint8_t device_address;
+ uint8_t usb_mode;
+ uint8_t usb_speed;
+ uint8_t is_opened;
+
+ char usb_desc[96];
+};
+
+extern const struct libusb20_backend_methods libusb20_ugen20_backend;
+extern const struct libusb20_backend_methods libusb20_linux_backend;
+
+#endif /* _LIBUSB20_INT_H_ */
OpenPOWER on IntegriCloud