45#ifdef USB_GLOBAL_INCLUDE_FILE
46#include USB_GLOBAL_INCLUDE_FILE
48#include <sys/stdint.h>
49#include <sys/stddef.h>
54#include <sys/kernel.h>
56#include <sys/module.h>
59#include <sys/condvar.h>
60#include <sys/sysctl.h>
62#include <sys/unistd.h>
63#include <sys/callout.h>
64#include <sys/malloc.h>
76#define MTP_BREQUEST 0x08
88#define MTP_DEFAULT_VENDOR_ID USB_TEMPLATE_VENDOR
89#define MTP_DEFAULT_PRODUCT_ID 0x27e2
90#define MTP_DEFAULT_INTERFACE "USB MTP Interface"
91#define MTP_DEFAULT_CONFIGURATION "Default Config"
92#define MTP_DEFAULT_MANUFACTURER USB_TEMPLATE_MANUFACTURER
93#define MTP_DEFAULT_PRODUCT "USB MTP"
94#define MTP_DEFAULT_SERIAL_NUMBER "June 2008"
121#ifdef USB_HIP_OUT_EP_0
122 .bEndpointAddress = USB_HIP_OUT_EP_0,
137#ifdef USB_HIP_IN_EP_0
138 .bEndpointAddress = USB_HIP_IN_EP_0,
156 .bInterfaceProtocol = 1,
185 .bDeviceSubClass = 0,
186 .bDeviceProtocol = 0,
202 static const uint8_t dummy_desc[0x28] = {
203 0x28, 0, 0, 0, 0, 1, 4, 0,
204 1, 0, 0, 0, 0, 0, 0, 0,
205 0, 1, 0x4D, 0x54, 0x50, 0, 0, 0,
206 0, 0, 0, 0, 0, 0, 0, 0,
207 0, 0, 0, 0, 0, 0, 0, 0,
212 (
req->wValue[1] == 0) && (
req->wIndex[1] == 0) &&
213 ((
req->wIndex[0] == 4) || (
req->wIndex[0] == 5))) {
242 static const uint8_t dummy_desc[0x12] = {
243 0x12, 0x03, 0x4D, 0x00, 0x53, 0x00, 0x46, 0x00,
244 0x54, 0x00, 0x31, 0x00, 0x30, 0x00, 0x30, 0x00,
248 if (string_index == 0xEE) {
255 if (string_index == 0) {
258 if (lang_id != 0x0409) {
262 return (ptr[string_index]);
270 struct sysctl_oid *parent;
284 snprintf(parent_name,
sizeof(parent_name),
"%d",
USB_TEMP_MTP);
288 SYSCTL_STATIC_CHILDREN(_hw_usb_templates), OID_AUTO,
289 parent_name, CTLFLAG_RW | CTLFLAG_MPSAFE,
290 0,
"USB Media Transfer Protocol device side template");
291 SYSCTL_ADD_U16(&
mtp_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
292 "vendor_id", CTLFLAG_RWTUN,
294 SYSCTL_ADD_U16(&
mtp_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
295 "product_id", CTLFLAG_RWTUN,
298 SYSCTL_ADD_PROC(&
mtp_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
299 "interface", CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
301 "A",
"Interface string");
302 SYSCTL_ADD_PROC(&
mtp_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
303 "configuration", CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
305 "A",
"Configuration string");
307 SYSCTL_ADD_PROC(&
mtp_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
308 "manufacturer", CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
310 "A",
"Manufacturer string");
311 SYSCTL_ADD_PROC(&
mtp_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
312 "product", CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
314 "A",
"Product string");
315 SYSCTL_ADD_PROC(&
mtp_ctx_list, SYSCTL_CHILDREN(parent), OID_AUTO,
316 "serial_number", CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
318 "A",
"Serial number string");
const struct usb_temp_interface_desc ** ppIfaceDesc
usb_temp_get_string_desc_t * getStringDesc
const struct usb_temp_packet_size * pPacketSize
const struct usb_temp_endpoint_desc ** ppEndpoints
uint16_t mps[USB_SPEED_MAX]
#define UT_READ_VENDOR_DEVICE
const struct usb_string_lang usb_string_lang_en
int usb_temp_sysctl(SYSCTL_HANDLER_ARGS)
const void *() usb_temp_get_vendor_desc_t(const struct usb_device_request *req, uint16_t *plen)
const void *() usb_temp_get_string_desc_t(uint16_t lang_id, uint8_t string_index)
static const struct usb_temp_config_desc mtp_config_desc
static usb_temp_get_string_desc_t mtp_get_string_desc
static const struct usb_temp_interface_desc mtp_data_interface
static struct usb_string_descriptor mtp_interface
#define MTP_DEFAULT_CONFIGURATION
struct usb_temp_device_desc usb_template_mtp
#define MTP_DEFAULT_MANUFACTURER
static struct usb_string_descriptor mtp_manufacturer
#define MTP_DEFAULT_PRODUCT_ID
static const struct usb_temp_endpoint_desc * mtp_data_endpoints[]
static const struct usb_temp_packet_size bulk_mps
SYSUNINIT(mtp_uninit, SI_SUB_LOCK, SI_ORDER_FIRST, mtp_uninit, NULL)
static struct sysctl_ctx_list mtp_ctx_list
static void mtp_uninit(void *arg __unused)
static const struct usb_temp_endpoint_desc bulk_out_ep
static const struct usb_temp_endpoint_desc bulk_in_ep
static struct usb_string_descriptor mtp_product
static const struct usb_temp_packet_size intr_mps
static const struct usb_temp_config_desc * mtp_configs[]
SYSINIT(mtp_init, SI_SUB_LOCK, SI_ORDER_FIRST, mtp_init, NULL)
static const struct usb_temp_endpoint_desc intr_in_ep
@ MTP_SERIAL_NUMBER_INDEX
@ MTP_CONFIGURATION_INDEX
static void mtp_init(void *arg __unused)
#define MTP_DEFAULT_INTERFACE
static usb_temp_get_vendor_desc_t mtp_get_vendor_desc
static struct usb_string_descriptor mtp_serial_number
static struct usb_string_descriptor mtp_configuration
#define MTP_DEFAULT_SERIAL_NUMBER
#define MTP_DEFAULT_VENDOR_ID
#define MTP_DEFAULT_PRODUCT
static const struct usb_temp_interface_desc * mtp_interfaces[]
uint8_t usb_make_str_desc(void *ptr, uint16_t max_len, const char *s)