Index: stable/11/sys/dev/usb/template/usb_template_audio.c =================================================================== --- stable/11/sys/dev/usb/template/usb_template_audio.c (revision 332573) +++ stable/11/sys/dev/usb/template/usb_template_audio.c (revision 332574) @@ -1,399 +1,399 @@ /* $FreeBSD$ */ /*- * Copyright (c) 2010 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 contains the USB template for an USB Audio Device. */ #ifdef USB_GLOBAL_INCLUDE_FILE #include USB_GLOBAL_INCLUDE_FILE #else #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #endif /* USB_GLOBAL_INCLUDE_FILE */ enum { INDEX_AUDIO_LANG, INDEX_AUDIO_MIXER, INDEX_AUDIO_RECORD, INDEX_AUDIO_PLAYBACK, INDEX_AUDIO_PRODUCT, INDEX_AUDIO_MAX, }; #define STRING_AUDIO_PRODUCT \ "A\0u\0d\0i\0o\0 \0T\0e\0s\0t\0 \0D\0e\0v\0i\0c\0e" #define STRING_AUDIO_MIXER \ "M\0i\0x\0e\0r\0 \0i\0n\0t\0e\0r\0f\0a\0c\0e" #define STRING_AUDIO_RECORD \ "R\0e\0c\0o\0r\0d\0 \0i\0n\0t\0e\0r\0f\0a\0c\0e" #define STRING_AUDIO_PLAYBACK \ "P\0l\0a\0y\0b\0a\0c\0k\0 \0i\0n\0t\0e\0r\0f\0a\0c\0e" /* make the real string descriptors */ USB_MAKE_STRING_DESC(STRING_AUDIO_MIXER, string_audio_mixer); USB_MAKE_STRING_DESC(STRING_AUDIO_RECORD, string_audio_record); USB_MAKE_STRING_DESC(STRING_AUDIO_PLAYBACK, string_audio_playback); USB_MAKE_STRING_DESC(STRING_AUDIO_PRODUCT, string_audio_product); /* prototypes */ /* * Audio Mixer description structures * * Some of the audio descriptors were dumped * from a Creative Labs USB audio device. */ static const uint8_t audio_raw_desc_0[] = { 0x0a, 0x24, 0x01, 0x00, 0x01, 0xa9, 0x00, 0x02, 0x01, 0x02 }; static const uint8_t audio_raw_desc_1[] = { 0x0c, 0x24, 0x02, 0x01, 0x01, 0x01, 0x00, 0x02, 0x03, 0x00, 0x00, 0x00 }; static const uint8_t audio_raw_desc_2[] = { 0x0c, 0x24, 0x02, 0x02, 0x01, 0x02, 0x00, 0x02, 0x03, 0x00, 0x00, 0x00 }; static const uint8_t audio_raw_desc_3[] = { 0x0c, 0x24, 0x02, 0x03, 0x03, 0x06, 0x00, 0x02, 0x03, 0x00, 0x00, 0x00 }; static const uint8_t audio_raw_desc_4[] = { 0x0c, 0x24, 0x02, 0x04, 0x05, 0x06, 0x00, 0x02, 0x03, 0x00, 0x00, 0x00 }; static const uint8_t audio_raw_desc_5[] = { 0x09, 0x24, 0x03, 0x05, 0x05, 0x06, 0x00, 0x01, 0x00 }; static const uint8_t audio_raw_desc_6[] = { 0x09, 0x24, 0x03, 0x06, 0x01, 0x03, 0x00, 0x09, 0x00 }; static const uint8_t audio_raw_desc_7[] = { 0x09, 0x24, 0x03, 0x07, 0x01, 0x01, 0x00, 0x08, 0x00 }; static const uint8_t audio_raw_desc_8[] = { 0x09, 0x24, 0x05, 0x08, 0x03, 0x0a, 0x0b, 0x0c, 0x00 }; static const uint8_t audio_raw_desc_9[] = { 0x0a, 0x24, 0x06, 0x09, 0x0f, 0x01, 0x01, 0x02, 0x02, 0x00 }; static const uint8_t audio_raw_desc_10[] = { 0x0a, 0x24, 0x06, 0x0a, 0x02, 0x01, 0x43, 0x00, 0x00, 0x00 }; static const uint8_t audio_raw_desc_11[] = { 0x0a, 0x24, 0x06, 0x0b, 0x03, 0x01, 0x01, 0x02, 0x02, 0x00 }; static const uint8_t audio_raw_desc_12[] = { 0x0a, 0x24, 0x06, 0x0c, 0x04, 0x01, 0x01, 0x00, 0x00, 0x00 }; static const uint8_t audio_raw_desc_13[] = { 0x0a, 0x24, 0x06, 0x0d, 0x02, 0x01, 0x03, 0x00, 0x00, 0x00 }; static const uint8_t audio_raw_desc_14[] = { 0x0a, 0x24, 0x06, 0x0e, 0x03, 0x01, 0x01, 0x02, 0x02, 0x00 }; static const uint8_t audio_raw_desc_15[] = { 0x0f, 0x24, 0x04, 0x0f, 0x03, 0x01, 0x0d, 0x0e, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00 }; static const void *audio_raw_iface_0_desc[] = { audio_raw_desc_0, audio_raw_desc_1, audio_raw_desc_2, audio_raw_desc_3, audio_raw_desc_4, audio_raw_desc_5, audio_raw_desc_6, audio_raw_desc_7, audio_raw_desc_8, audio_raw_desc_9, audio_raw_desc_10, audio_raw_desc_11, audio_raw_desc_12, audio_raw_desc_13, audio_raw_desc_14, audio_raw_desc_15, NULL, }; static const struct usb_temp_interface_desc audio_iface_0 = { .ppEndpoints = NULL, /* no endpoints */ .ppRawDesc = audio_raw_iface_0_desc, - .bInterfaceClass = 1, - .bInterfaceSubClass = 1, + .bInterfaceClass = UICLASS_AUDIO, + .bInterfaceSubClass = UISUBCLASS_AUDIOCONTROL, .bInterfaceProtocol = 0, .iInterface = INDEX_AUDIO_MIXER, }; static const uint8_t audio_raw_desc_20[] = { 0x07, 0x24, 0x01, 0x01, 0x03, 0x01, 0x00 }; static const uint8_t audio_raw_desc_21[] = { 0x0b, 0x24, 0x02, 0x01, 0x02, 0x02, 0x10, 0x01, /* 48kHz */ 0x80, 0xbb, 0x00 }; static const uint8_t audio_raw_desc_22[] = { 0x07, 0x25, 0x01, 0x00, 0x01, 0x04, 0x00 }; static const void *audio_raw_iface_1_desc[] = { audio_raw_desc_20, audio_raw_desc_21, NULL, }; static const void *audio_raw_ep_1_desc[] = { audio_raw_desc_22, NULL, }; static const struct usb_temp_packet_size audio_isoc_mps = { .mps[USB_SPEED_FULL] = 0xC8, .mps[USB_SPEED_HIGH] = 0xC8, }; static const struct usb_temp_interval audio_isoc_interval = { .bInterval[USB_SPEED_FULL] = 1, /* 1:1 */ .bInterval[USB_SPEED_HIGH] = 4, /* 1:8 */ }; static const struct usb_temp_endpoint_desc audio_isoc_out_ep = { .ppRawDesc = audio_raw_ep_1_desc, .pPacketSize = &audio_isoc_mps, .pIntervals = &audio_isoc_interval, .bEndpointAddress = UE_DIR_OUT, .bmAttributes = UE_ISOCHRONOUS | UE_ISO_ADAPT, }; static const struct usb_temp_endpoint_desc *audio_iface_1_ep[] = { &audio_isoc_out_ep, NULL, }; static const struct usb_temp_interface_desc audio_iface_1_alt_0 = { .ppEndpoints = NULL, /* no endpoints */ .ppRawDesc = NULL, /* no raw descriptors */ - .bInterfaceClass = 1, - .bInterfaceSubClass = 2, + .bInterfaceClass = UICLASS_AUDIO, + .bInterfaceSubClass = UISUBCLASS_AUDIOSTREAM, .bInterfaceProtocol = 0, .iInterface = INDEX_AUDIO_PLAYBACK, }; static const struct usb_temp_interface_desc audio_iface_1_alt_1 = { .ppEndpoints = audio_iface_1_ep, .ppRawDesc = audio_raw_iface_1_desc, - .bInterfaceClass = 1, - .bInterfaceSubClass = 2, + .bInterfaceClass = UICLASS_AUDIO, + .bInterfaceSubClass = UISUBCLASS_AUDIOSTREAM, .bInterfaceProtocol = 0, .iInterface = INDEX_AUDIO_PLAYBACK, .isAltInterface = 1, /* this is an alternate setting */ }; static const uint8_t audio_raw_desc_30[] = { 0x07, 0x24, 0x01, 0x07, 0x01, 0x01, 0x00 }; static const uint8_t audio_raw_desc_31[] = { 0x0b, 0x24, 0x02, 0x01, 0x02, 0x02, 0x10, 0x01, /* 48kHz */ 0x80, 0xbb, 0x00 }; static const uint8_t audio_raw_desc_32[] = { 0x07, 0x25, 0x01, 0x01, 0x00, 0x00, 0x00 }; static const void *audio_raw_iface_2_desc[] = { audio_raw_desc_30, audio_raw_desc_31, NULL, }; static const void *audio_raw_ep_2_desc[] = { audio_raw_desc_32, NULL, }; static const struct usb_temp_endpoint_desc audio_isoc_in_ep = { .ppRawDesc = audio_raw_ep_2_desc, .pPacketSize = &audio_isoc_mps, .pIntervals = &audio_isoc_interval, .bEndpointAddress = UE_DIR_IN, .bmAttributes = UE_ISOCHRONOUS | UE_ISO_ADAPT, }; static const struct usb_temp_endpoint_desc *audio_iface_2_ep[] = { &audio_isoc_in_ep, NULL, }; static const struct usb_temp_interface_desc audio_iface_2_alt_0 = { .ppEndpoints = NULL, /* no endpoints */ .ppRawDesc = NULL, /* no raw descriptors */ - .bInterfaceClass = 1, - .bInterfaceSubClass = 2, + .bInterfaceClass = UICLASS_AUDIO, + .bInterfaceSubClass = UISUBCLASS_AUDIOSTREAM, .bInterfaceProtocol = 0, .iInterface = INDEX_AUDIO_RECORD, }; static const struct usb_temp_interface_desc audio_iface_2_alt_1 = { .ppEndpoints = audio_iface_2_ep, .ppRawDesc = audio_raw_iface_2_desc, - .bInterfaceClass = 1, - .bInterfaceSubClass = 2, + .bInterfaceClass = UICLASS_AUDIO, + .bInterfaceSubClass = UISUBCLASS_AUDIOSTREAM, .bInterfaceProtocol = 0, .iInterface = INDEX_AUDIO_RECORD, .isAltInterface = 1, /* this is an alternate setting */ }; static const struct usb_temp_interface_desc *audio_interfaces[] = { &audio_iface_0, &audio_iface_1_alt_0, &audio_iface_1_alt_1, &audio_iface_2_alt_0, &audio_iface_2_alt_1, NULL, }; static const struct usb_temp_config_desc audio_config_desc = { .ppIfaceDesc = audio_interfaces, .bmAttributes = UC_BUS_POWERED, .bMaxPower = 25, /* 50 mA */ .iConfiguration = INDEX_AUDIO_PRODUCT, }; static const struct usb_temp_config_desc *audio_configs[] = { &audio_config_desc, NULL, }; static usb_temp_get_string_desc_t audio_get_string_desc; const struct usb_temp_device_desc usb_template_audio = { .getStringDesc = &audio_get_string_desc, .ppConfigDesc = audio_configs, .idVendor = USB_TEMPLATE_VENDOR, .idProduct = 0x000A, .bcdDevice = 0x0100, .bDeviceClass = UDCLASS_COMM, .bDeviceSubClass = 0, .bDeviceProtocol = 0, .iManufacturer = 0, .iProduct = INDEX_AUDIO_PRODUCT, .iSerialNumber = 0, }; /*------------------------------------------------------------------------* * audio_get_string_desc * * Return values: * NULL: Failure. No such string. * Else: Success. Pointer to string descriptor is returned. *------------------------------------------------------------------------*/ static const void * audio_get_string_desc(uint16_t lang_id, uint8_t string_index) { static const void *ptr[INDEX_AUDIO_MAX] = { [INDEX_AUDIO_LANG] = &usb_string_lang_en, [INDEX_AUDIO_MIXER] = &string_audio_mixer, [INDEX_AUDIO_RECORD] = &string_audio_record, [INDEX_AUDIO_PLAYBACK] = &string_audio_playback, [INDEX_AUDIO_PRODUCT] = &string_audio_product, }; if (string_index == 0) { return (&usb_string_lang_en); } if (lang_id != 0x0409) { return (NULL); } if (string_index < INDEX_AUDIO_MAX) { return (ptr[string_index]); } return (NULL); } Index: stable/11/sys/dev/usb/template/usb_template_kbd.c =================================================================== --- stable/11/sys/dev/usb/template/usb_template_kbd.c (revision 332573) +++ stable/11/sys/dev/usb/template/usb_template_kbd.c (revision 332574) @@ -1,220 +1,220 @@ /* $FreeBSD$ */ /*- * Copyright (c) 2010 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 contains the USB template for an USB Keyboard Device. */ #ifdef USB_GLOBAL_INCLUDE_FILE #include USB_GLOBAL_INCLUDE_FILE #else #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #endif /* USB_GLOBAL_INCLUDE_FILE */ enum { INDEX_LANG, INDEX_KEYBOARD, INDEX_PRODUCT, INDEX_MAX, }; #define STRING_PRODUCT \ "K\0e\0y\0b\0o\0a\0r\0d\0 \0T\0e\0s\0t\0 \0D\0e\0v\0i\0c\0e" #define STRING_KEYBOARD \ "K\0e\0y\0b\0o\0a\0r\0d\0 \0i\0n\0t\0e\0r\0f\0a\0c\0e" /* make the real string descriptors */ USB_MAKE_STRING_DESC(STRING_KEYBOARD, string_keyboard); USB_MAKE_STRING_DESC(STRING_PRODUCT, string_product); /* prototypes */ static const struct usb_temp_packet_size keyboard_intr_mps = { .mps[USB_SPEED_LOW] = 16, .mps[USB_SPEED_FULL] = 16, .mps[USB_SPEED_HIGH] = 16, }; static const struct usb_temp_interval keyboard_intr_interval = { .bInterval[USB_SPEED_LOW] = 2, /* 2 ms */ .bInterval[USB_SPEED_FULL] = 2, /* 2 ms */ .bInterval[USB_SPEED_HIGH] = 5, /* 2 ms */ }; /* The following HID descriptor was dumped from a HP keyboard. */ static uint8_t keyboard_hid_descriptor[] = { 0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x05, 0x07, 0x19, 0xe0, 0x29, 0xe7, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x81, 0x02, 0x95, 0x01, 0x75, 0x08, 0x81, 0x01, 0x95, 0x03, 0x75, 0x01, 0x05, 0x08, 0x19, 0x01, 0x29, 0x03, 0x91, 0x02, 0x95, 0x05, 0x75, 0x01, 0x91, 0x01, 0x95, 0x06, 0x75, 0x08, 0x15, 0x00, 0x26, 0xff, 0x00, 0x05, 0x07, 0x19, 0x00, 0x2a, 0xff, 0x00, 0x81, 0x00, 0xc0 }; static const struct usb_temp_endpoint_desc keyboard_ep_0 = { .ppRawDesc = NULL, /* no raw descriptors */ .pPacketSize = &keyboard_intr_mps, .pIntervals = &keyboard_intr_interval, .bEndpointAddress = UE_DIR_IN, .bmAttributes = UE_INTERRUPT, }; static const struct usb_temp_endpoint_desc *keyboard_endpoints[] = { &keyboard_ep_0, NULL, }; static const uint8_t keyboard_raw_desc[] = { 0x09, 0x21, 0x10, 0x01, 0x00, 0x01, 0x22, sizeof(keyboard_hid_descriptor), 0x00 }; static const void *keyboard_iface_0_desc[] = { keyboard_raw_desc, NULL, }; static const struct usb_temp_interface_desc keyboard_iface_0 = { .ppRawDesc = keyboard_iface_0_desc, .ppEndpoints = keyboard_endpoints, - .bInterfaceClass = 3, - .bInterfaceSubClass = 1, - .bInterfaceProtocol = 1, + .bInterfaceClass = UICLASS_HID, + .bInterfaceSubClass = UISUBCLASS_BOOT, + .bInterfaceProtocol = UIPROTO_BOOT_KEYBOARD, .iInterface = INDEX_KEYBOARD, }; static const struct usb_temp_interface_desc *keyboard_interfaces[] = { &keyboard_iface_0, NULL, }; static const struct usb_temp_config_desc keyboard_config_desc = { .ppIfaceDesc = keyboard_interfaces, .bmAttributes = UC_BUS_POWERED, .bMaxPower = 25, /* 50 mA */ .iConfiguration = INDEX_PRODUCT, }; static const struct usb_temp_config_desc *keyboard_configs[] = { &keyboard_config_desc, NULL, }; static usb_temp_get_string_desc_t keyboard_get_string_desc; static usb_temp_get_vendor_desc_t keyboard_get_vendor_desc; const struct usb_temp_device_desc usb_template_kbd = { .getStringDesc = &keyboard_get_string_desc, .getVendorDesc = &keyboard_get_vendor_desc, .ppConfigDesc = keyboard_configs, .idVendor = USB_TEMPLATE_VENDOR, .idProduct = 0x00CB, .bcdDevice = 0x0100, .bDeviceClass = UDCLASS_COMM, .bDeviceSubClass = 0, .bDeviceProtocol = 0, .iManufacturer = 0, .iProduct = INDEX_PRODUCT, .iSerialNumber = 0, }; /*------------------------------------------------------------------------* * keyboard_get_vendor_desc * * Return values: * NULL: Failure. No such vendor descriptor. * Else: Success. Pointer to vendor descriptor is returned. *------------------------------------------------------------------------*/ static const void * keyboard_get_vendor_desc(const struct usb_device_request *req, uint16_t *plen) { if ((req->bmRequestType == 0x81) && (req->bRequest == 0x06) && (req->wValue[0] == 0x00) && (req->wValue[1] == 0x22) && (req->wIndex[1] == 0) && (req->wIndex[0] == 0)) { *plen = sizeof(keyboard_hid_descriptor); return (keyboard_hid_descriptor); } return (NULL); } /*------------------------------------------------------------------------* * keyboard_get_string_desc * * Return values: * NULL: Failure. No such string. * Else: Success. Pointer to string descriptor is returned. *------------------------------------------------------------------------*/ static const void * keyboard_get_string_desc(uint16_t lang_id, uint8_t string_index) { static const void *ptr[INDEX_MAX] = { [INDEX_LANG] = &usb_string_lang_en, [INDEX_KEYBOARD] = &string_keyboard, [INDEX_PRODUCT] = &string_product, }; if (string_index == 0) { return (&usb_string_lang_en); } if (lang_id != 0x0409) { return (NULL); } if (string_index < INDEX_MAX) { return (ptr[string_index]); } return (NULL); } Index: stable/11/sys/dev/usb/template/usb_template_midi.c =================================================================== --- stable/11/sys/dev/usb/template/usb_template_midi.c (revision 332573) +++ stable/11/sys/dev/usb/template/usb_template_midi.c (revision 332574) @@ -1,240 +1,240 @@ /* $FreeBSD$ */ /*- * Copyright (c) 2015 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 contains the USB template for an USB MIDI Device. */ #ifdef USB_GLOBAL_INCLUDE_FILE #include USB_GLOBAL_INCLUDE_FILE #else #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #endif /* USB_GLOBAL_INCLUDE_FILE */ enum { INDEX_MIDI_LANG, INDEX_MIDI_IF, INDEX_MIDI_PRODUCT, INDEX_MIDI_MAX, }; #define STRING_MIDI_PRODUCT \ "M\0I\0D\0I\0 \0T\0e\0s\0t\0 \0D\0e\0v\0i\0c\0e" #define STRING_MIDI_IF \ "M\0I\0D\0I\0 \0i\0n\0t\0e\0r\0f\0a\0c\0e" /* make the real string descriptors */ USB_MAKE_STRING_DESC(STRING_MIDI_IF, string_midi_if); USB_MAKE_STRING_DESC(STRING_MIDI_PRODUCT, string_midi_product); /* prototypes */ static const uint8_t midi_desc_raw_0[9] = { 0x09, 0x24, 0x01, 0x00, 0x01, 0x09, 0x00, 0x01, 0x01 }; static const void *midi_descs_0[] = { &midi_desc_raw_0, NULL }; static const struct usb_temp_interface_desc midi_iface_0 = { .ppEndpoints = NULL, /* no endpoints */ .ppRawDesc = midi_descs_0, - .bInterfaceClass = 1, - .bInterfaceSubClass = 1, + .bInterfaceClass = UICLASS_AUDIO, + .bInterfaceSubClass = UISUBCLASS_AUDIOCONTROL, .bInterfaceProtocol = 0, .iInterface = INDEX_MIDI_IF, }; static const struct usb_temp_packet_size midi_mps = { .mps[USB_SPEED_LOW] = 8, .mps[USB_SPEED_FULL] = 64, .mps[USB_SPEED_HIGH] = 512, }; static const uint8_t midi_desc_raw_7[5] = { 0x05, 0x25, 0x01, 0x01, 0x01 }; static const void *midi_descs_2[] = { &midi_desc_raw_7, NULL }; static const struct usb_temp_endpoint_desc midi_bulk_out_ep = { .ppRawDesc = midi_descs_2, .pPacketSize = &midi_mps, .bEndpointAddress = UE_DIR_OUT, .bmAttributes = UE_BULK, }; static const uint8_t midi_desc_raw_6[5] = { 0x05, 0x25, 0x01, 0x01, 0x03, }; static const void *midi_descs_3[] = { &midi_desc_raw_6, NULL }; static const struct usb_temp_endpoint_desc midi_bulk_in_ep = { .ppRawDesc = midi_descs_3, .pPacketSize = &midi_mps, .bEndpointAddress = UE_DIR_IN, .bmAttributes = UE_BULK, }; static const struct usb_temp_endpoint_desc *midi_iface_1_ep[] = { &midi_bulk_out_ep, &midi_bulk_in_ep, NULL, }; static const uint8_t midi_desc_raw_1[7] = { 0x07, 0x24, 0x01, 0x00, 0x01, /* wTotalLength: */ 0x41, 0x00 }; static const uint8_t midi_desc_raw_2[6] = { 0x06, 0x24, 0x02, 0x01, 0x01, 0x00 }; static const uint8_t midi_desc_raw_3[6] = { 0x06, 0x24, 0x02, 0x02, 0x02, 0x00 }; static const uint8_t midi_desc_raw_4[9] = { 0x09, 0x24, 0x03, 0x01, 0x03, 0x01, 0x02, 0x01, 0x00 }; static const uint8_t midi_desc_raw_5[9] = { 0x09, 0x24, 0x03, 0x02, 0x04, 0x01, 0x01, 0x01, 0x00 }; static const void *midi_descs_1[] = { &midi_desc_raw_1, &midi_desc_raw_2, &midi_desc_raw_3, &midi_desc_raw_4, &midi_desc_raw_5, NULL }; static const struct usb_temp_interface_desc midi_iface_1 = { .ppRawDesc = midi_descs_1, .ppEndpoints = midi_iface_1_ep, - .bInterfaceClass = 0x01, /* MIDI */ - .bInterfaceSubClass = 3, /* MIDI streaming */ + .bInterfaceClass = UICLASS_AUDIO, + .bInterfaceSubClass = UISUBCLASS_MIDISTREAM, .bInterfaceProtocol = 0, .iInterface = INDEX_MIDI_IF, }; static const struct usb_temp_interface_desc *midi_interfaces[] = { &midi_iface_0, &midi_iface_1, NULL, }; static const struct usb_temp_config_desc midi_config_desc = { .ppIfaceDesc = midi_interfaces, .bmAttributes = UC_BUS_POWERED, .bMaxPower = 25, /* 50 mA */ .iConfiguration = INDEX_MIDI_PRODUCT, }; static const struct usb_temp_config_desc *midi_configs[] = { &midi_config_desc, NULL, }; static usb_temp_get_string_desc_t midi_get_string_desc; const struct usb_temp_device_desc usb_template_midi = { .getStringDesc = &midi_get_string_desc, .ppConfigDesc = midi_configs, .idVendor = USB_TEMPLATE_VENDOR, .idProduct = 0x00BB, .bcdDevice = 0x0100, .bDeviceClass = 0, .bDeviceSubClass = 0, .bDeviceProtocol = 0, .iManufacturer = 0, .iProduct = INDEX_MIDI_PRODUCT, .iSerialNumber = 0, }; /*------------------------------------------------------------------------* * midi_get_string_desc * * Return values: * NULL: Failure. No such string. * Else: Success. Pointer to string descriptor is returned. *------------------------------------------------------------------------*/ static const void * midi_get_string_desc(uint16_t lang_id, uint8_t string_index) { static const void *ptr[INDEX_MIDI_MAX] = { [INDEX_MIDI_LANG] = &usb_string_lang_en, [INDEX_MIDI_IF] = &string_midi_if, [INDEX_MIDI_PRODUCT] = &string_midi_product, }; if (string_index == 0) { return (&usb_string_lang_en); } if (lang_id != 0x0409) { return (NULL); } if (string_index < INDEX_MIDI_MAX) { return (ptr[string_index]); } return (NULL); } Index: stable/11/sys/dev/usb/template/usb_template_modem.c =================================================================== --- stable/11/sys/dev/usb/template/usb_template_modem.c (revision 332573) +++ stable/11/sys/dev/usb/template/usb_template_modem.c (revision 332574) @@ -1,248 +1,248 @@ /* $FreeBSD$ */ /*- * Copyright (c) 2010 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 contains the USB template for an USB Modem Device. */ #ifdef USB_GLOBAL_INCLUDE_FILE #include USB_GLOBAL_INCLUDE_FILE #else #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #endif /* USB_GLOBAL_INCLUDE_FILE */ enum { INDEX_LANG, INDEX_MODEM, INDEX_PRODUCT, INDEX_MAX, }; #define STRING_PRODUCT \ "M\0o\0d\0e\0m\0 \0T\0e\0s\0t\0 \0D\0e\0v\0i\0c\0e" #define STRING_MODEM \ "M\0o\0d\0e\0m\0 \0i\0n\0t\0e\0r\0f\0a\0c\0e" /* make the real string descriptors */ USB_MAKE_STRING_DESC(STRING_MODEM, string_modem); USB_MAKE_STRING_DESC(STRING_PRODUCT, string_product); #define MODEM_IFACE_0 0 #define MODEM_IFACE_1 1 /* prototypes */ static const struct usb_temp_packet_size modem_bulk_mps = { .mps[USB_SPEED_LOW] = 8, .mps[USB_SPEED_FULL] = 64, .mps[USB_SPEED_HIGH] = 512, }; static const struct usb_temp_packet_size modem_intr_mps = { .mps[USB_SPEED_LOW] = 8, .mps[USB_SPEED_FULL] = 8, .mps[USB_SPEED_HIGH] = 8, }; static const struct usb_temp_interval modem_intr_interval = { .bInterval[USB_SPEED_LOW] = 8, /* 8ms */ .bInterval[USB_SPEED_FULL] = 8, /* 8ms */ .bInterval[USB_SPEED_HIGH] = 7, /* 8ms */ }; static const struct usb_temp_endpoint_desc modem_ep_0 = { .pPacketSize = &modem_intr_mps, .pIntervals = &modem_intr_interval, .bEndpointAddress = UE_DIR_IN, .bmAttributes = UE_INTERRUPT, }; static const struct usb_temp_endpoint_desc modem_ep_1 = { .pPacketSize = &modem_bulk_mps, .bEndpointAddress = UE_DIR_OUT, .bmAttributes = UE_BULK, }; static const struct usb_temp_endpoint_desc modem_ep_2 = { .pPacketSize = &modem_bulk_mps, .bEndpointAddress = UE_DIR_IN, .bmAttributes = UE_BULK, }; static const struct usb_temp_endpoint_desc *modem_iface_0_ep[] = { &modem_ep_0, NULL, }; static const struct usb_temp_endpoint_desc *modem_iface_1_ep[] = { &modem_ep_1, &modem_ep_2, NULL, }; static const uint8_t modem_raw_desc_0[] = { 0x05, 0x24, 0x00, 0x10, 0x01 }; static const uint8_t modem_raw_desc_1[] = { 0x05, 0x24, 0x06, MODEM_IFACE_0, MODEM_IFACE_1 }; static const uint8_t modem_raw_desc_2[] = { 0x05, 0x24, 0x01, 0x03, MODEM_IFACE_1 }; static const uint8_t modem_raw_desc_3[] = { 0x04, 0x24, 0x02, 0x07 }; static const void *modem_iface_0_desc[] = { &modem_raw_desc_0, &modem_raw_desc_1, &modem_raw_desc_2, &modem_raw_desc_3, NULL, }; static const struct usb_temp_interface_desc modem_iface_0 = { .ppRawDesc = modem_iface_0_desc, .ppEndpoints = modem_iface_0_ep, - .bInterfaceClass = 2, - .bInterfaceSubClass = 2, - .bInterfaceProtocol = 1, + .bInterfaceClass = UICLASS_CDC, + .bInterfaceSubClass = UISUBCLASS_ABSTRACT_CONTROL_MODEL, + .bInterfaceProtocol = UIPROTO_CDC_AT, .iInterface = INDEX_MODEM, }; static const struct usb_temp_interface_desc modem_iface_1 = { .ppEndpoints = modem_iface_1_ep, - .bInterfaceClass = 10, - .bInterfaceSubClass = 0, - .bInterfaceProtocol = 0, + .bInterfaceClass = UICLASS_CDC_DATA, + .bInterfaceSubClass = UISUBCLASS_DATA, + .bInterfaceProtocol = UIPROTO_CDC_NONE, .iInterface = INDEX_MODEM, }; static const struct usb_temp_interface_desc *modem_interfaces[] = { &modem_iface_0, &modem_iface_1, NULL, }; static const struct usb_temp_config_desc modem_config_desc = { .ppIfaceDesc = modem_interfaces, .bmAttributes = UC_BUS_POWERED, .bMaxPower = 25, /* 50 mA */ .iConfiguration = INDEX_PRODUCT, }; static const struct usb_temp_config_desc *modem_configs[] = { &modem_config_desc, NULL, }; static usb_temp_get_string_desc_t modem_get_string_desc; static usb_temp_get_vendor_desc_t modem_get_vendor_desc; const struct usb_temp_device_desc usb_template_modem = { .getStringDesc = &modem_get_string_desc, .getVendorDesc = &modem_get_vendor_desc, .ppConfigDesc = modem_configs, .idVendor = USB_TEMPLATE_VENDOR, .idProduct = 0x000E, .bcdDevice = 0x0100, .bDeviceClass = UDCLASS_COMM, .bDeviceSubClass = 0, .bDeviceProtocol = 0, .iManufacturer = 0, .iProduct = INDEX_PRODUCT, .iSerialNumber = 0, }; /*------------------------------------------------------------------------* * modem_get_vendor_desc * * Return values: * NULL: Failure. No such vendor descriptor. * Else: Success. Pointer to vendor descriptor is returned. *------------------------------------------------------------------------*/ static const void * modem_get_vendor_desc(const struct usb_device_request *req, uint16_t *plen) { return (NULL); } /*------------------------------------------------------------------------* * modem_get_string_desc * * Return values: * NULL: Failure. No such string. * Else: Success. Pointer to string descriptor is returned. *------------------------------------------------------------------------*/ static const void * modem_get_string_desc(uint16_t lang_id, uint8_t string_index) { static const void *ptr[INDEX_MAX] = { [INDEX_LANG] = &usb_string_lang_en, [INDEX_MODEM] = &string_modem, [INDEX_PRODUCT] = &string_product, }; if (string_index == 0) { return (&usb_string_lang_en); } if (lang_id != 0x0409) { return (NULL); } if (string_index < INDEX_MAX) { return (ptr[string_index]); } return (NULL); } Index: stable/11/sys/dev/usb/template/usb_template_mouse.c =================================================================== --- stable/11/sys/dev/usb/template/usb_template_mouse.c (revision 332573) +++ stable/11/sys/dev/usb/template/usb_template_mouse.c (revision 332574) @@ -1,218 +1,218 @@ /* $FreeBSD$ */ /*- * Copyright (c) 2010 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 contains the USB template for an USB Mouse Device. */ #ifdef USB_GLOBAL_INCLUDE_FILE #include USB_GLOBAL_INCLUDE_FILE #else #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #endif /* USB_GLOBAL_INCLUDE_FILE */ enum { INDEX_LANG, INDEX_MOUSE, INDEX_PRODUCT, INDEX_MAX, }; #define STRING_PRODUCT \ "M\0o\0u\0s\0e\0 \0T\0e\0s\0t\0 \0D\0e\0v\0i\0c\0e" #define STRING_MOUSE \ "M\0o\0u\0s\0e\0 \0i\0n\0t\0e\0r\0f\0a\0c\0e" /* make the real string descriptors */ USB_MAKE_STRING_DESC(STRING_MOUSE, string_mouse); USB_MAKE_STRING_DESC(STRING_PRODUCT, string_product); /* prototypes */ /* The following HID descriptor was dumped from a HP mouse. */ static uint8_t mouse_hid_descriptor[] = { 0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x09, 0x01, 0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x03, 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75, 0x01, 0x81, 0x02, 0x95, 0x05, 0x81, 0x03, 0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 0x09, 0x38, 0x15, 0x81, 0x25, 0x7f, 0x75, 0x08, 0x95, 0x03, 0x81, 0x06, 0xc0, 0xc0 }; static const struct usb_temp_packet_size mouse_intr_mps = { .mps[USB_SPEED_LOW] = 8, .mps[USB_SPEED_FULL] = 8, .mps[USB_SPEED_HIGH] = 8, }; static const struct usb_temp_interval mouse_intr_interval = { .bInterval[USB_SPEED_LOW] = 2, /* 2ms */ .bInterval[USB_SPEED_FULL] = 2, /* 2ms */ .bInterval[USB_SPEED_HIGH] = 5, /* 2ms */ }; static const struct usb_temp_endpoint_desc mouse_ep_0 = { .ppRawDesc = NULL, /* no raw descriptors */ .pPacketSize = &mouse_intr_mps, .pIntervals = &mouse_intr_interval, .bEndpointAddress = UE_DIR_IN, .bmAttributes = UE_INTERRUPT, }; static const struct usb_temp_endpoint_desc *mouse_endpoints[] = { &mouse_ep_0, NULL, }; static const uint8_t mouse_raw_desc[] = { 0x09, 0x21, 0x10, 0x01, 0x00, 0x01, 0x22, sizeof(mouse_hid_descriptor), 0x00 }; static const void *mouse_iface_0_desc[] = { mouse_raw_desc, NULL, }; static const struct usb_temp_interface_desc mouse_iface_0 = { .ppRawDesc = mouse_iface_0_desc, .ppEndpoints = mouse_endpoints, - .bInterfaceClass = 3, - .bInterfaceSubClass = 1, - .bInterfaceProtocol = 2, + .bInterfaceClass = UICLASS_HID, + .bInterfaceSubClass = UISUBCLASS_BOOT, + .bInterfaceProtocol = UIPROTO_MOUSE, .iInterface = INDEX_MOUSE, }; static const struct usb_temp_interface_desc *mouse_interfaces[] = { &mouse_iface_0, NULL, }; static const struct usb_temp_config_desc mouse_config_desc = { .ppIfaceDesc = mouse_interfaces, .bmAttributes = UC_BUS_POWERED, .bMaxPower = 25, /* 50 mA */ .iConfiguration = INDEX_PRODUCT, }; static const struct usb_temp_config_desc *mouse_configs[] = { &mouse_config_desc, NULL, }; static usb_temp_get_string_desc_t mouse_get_string_desc; static usb_temp_get_vendor_desc_t mouse_get_vendor_desc; const struct usb_temp_device_desc usb_template_mouse = { .getStringDesc = &mouse_get_string_desc, .getVendorDesc = &mouse_get_vendor_desc, .ppConfigDesc = mouse_configs, .idVendor = USB_TEMPLATE_VENDOR, .idProduct = 0x00AE, .bcdDevice = 0x0100, .bDeviceClass = UDCLASS_COMM, .bDeviceSubClass = 0, .bDeviceProtocol = 0, .iManufacturer = 0, .iProduct = INDEX_PRODUCT, .iSerialNumber = 0, }; /*------------------------------------------------------------------------* * mouse_get_vendor_desc * * Return values: * NULL: Failure. No such vendor descriptor. * Else: Success. Pointer to vendor descriptor is returned. *------------------------------------------------------------------------*/ static const void * mouse_get_vendor_desc(const struct usb_device_request *req, uint16_t *plen) { if ((req->bmRequestType == 0x81) && (req->bRequest == 0x06) && (req->wValue[0] == 0x00) && (req->wValue[1] == 0x22) && (req->wIndex[1] == 0) && (req->wIndex[0] == 0)) { *plen = sizeof(mouse_hid_descriptor); return (mouse_hid_descriptor); } return (NULL); } /*------------------------------------------------------------------------* * mouse_get_string_desc * * Return values: * NULL: Failure. No such string. * Else: Success. Pointer to string descriptor is returned. *------------------------------------------------------------------------*/ static const void * mouse_get_string_desc(uint16_t lang_id, uint8_t string_index) { static const void *ptr[INDEX_MAX] = { [INDEX_LANG] = &usb_string_lang_en, [INDEX_MOUSE] = &string_mouse, [INDEX_PRODUCT] = &string_product, }; if (string_index == 0) { return (&usb_string_lang_en); } if (lang_id != 0x0409) { return (NULL); } if (string_index < INDEX_MAX) { return (ptr[string_index]); } return (NULL); } Index: stable/11/sys/dev/usb/template/usb_template_phone.c =================================================================== --- stable/11/sys/dev/usb/template/usb_template_phone.c (revision 332573) +++ stable/11/sys/dev/usb/template/usb_template_phone.c (revision 332574) @@ -1,419 +1,419 @@ /* $FreeBSD$ */ /*- * Copyright (c) 2014 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 contains the USB template for an USB phone device. */ #ifdef USB_GLOBAL_INCLUDE_FILE #include USB_GLOBAL_INCLUDE_FILE #else #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #endif /* USB_GLOBAL_INCLUDE_FILE */ enum { INDEX_PHONE_LANG, INDEX_PHONE_MIXER, INDEX_PHONE_RECORD, INDEX_PHONE_PLAYBACK, INDEX_PHONE_PRODUCT, INDEX_PHONE_HID, INDEX_PHONE_MAX, }; #define STRING_PHONE_PRODUCT \ "U\0S\0B\0 \0P\0h\0o\0n\0e\0 \0D\0e\0v\0i\0c\0e" #define STRING_PHONE_MIXER \ "M\0i\0x\0e\0r\0 \0i\0n\0t\0e\0r\0f\0a\0c\0e" #define STRING_PHONE_RECORD \ "R\0e\0c\0o\0r\0d\0 \0i\0n\0t\0e\0r\0f\0a\0c\0e" #define STRING_PHONE_PLAYBACK \ "P\0l\0a\0y\0b\0a\0c\0k\0 \0i\0n\0t\0e\0r\0f\0a\0c\0e" #define STRING_PHONE_HID \ "H\0I\0D\0 \0i\0n\0t\0e\0r\0f\0a\0c\0e" /* make the real string descriptors */ USB_MAKE_STRING_DESC(STRING_PHONE_MIXER, string_phone_mixer); USB_MAKE_STRING_DESC(STRING_PHONE_RECORD, string_phone_record); USB_MAKE_STRING_DESC(STRING_PHONE_PLAYBACK, string_phone_playback); USB_MAKE_STRING_DESC(STRING_PHONE_PRODUCT, string_phone_product); USB_MAKE_STRING_DESC(STRING_PHONE_HID, string_phone_hid); /* prototypes */ /* * Phone Mixer description structures * * Some of the phone descriptors were dumped from no longer in * production Yealink VOIP USB phone adapter: */ static uint8_t phone_hid_descriptor[] = { 0x05, 0x0b, 0x09, 0x01, 0xa1, 0x01, 0x05, 0x09, 0x19, 0x01, 0x29, 0x3f, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x80, 0x81, 0x00, 0x05, 0x08, 0x19, 0x01, 0x29, 0x10, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x80, 0x91, 0x00, 0xc0 }; static const uint8_t phone_raw_desc_0[] = { 0x0a, 0x24, 0x01, 0x00, 0x01, 0x4a, 0x00, 0x02, 0x01, 0x02 }; static const uint8_t phone_raw_desc_1[] = { 0x0c, 0x24, 0x02, 0x01, 0x01, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }; static const uint8_t phone_raw_desc_2[] = { 0x0c, 0x24, 0x02, 0x02, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }; static const uint8_t phone_raw_desc_3[] = { 0x09, 0x24, 0x03, 0x03, 0x01, 0x03, 0x00, 0x06, 0x00 }; static const uint8_t phone_raw_desc_4[] = { 0x09, 0x24, 0x03, 0x04, 0x01, 0x01, 0x00, 0x05, 0x00 }; static const uint8_t phone_raw_desc_5[] = { 0x0b, 0x24, 0x06, 0x05, 0x01, 0x02, 0x03, 0x00, 0x03, 0x00, 0x00 }; static const uint8_t phone_raw_desc_6[] = { 0x0b, 0x24, 0x06, 0x06, 0x02, 0x02, 0x03, 0x00, 0x03, 0x00, 0x00 }; static const void *phone_raw_iface_0_desc[] = { phone_raw_desc_0, phone_raw_desc_1, phone_raw_desc_2, phone_raw_desc_3, phone_raw_desc_4, phone_raw_desc_5, phone_raw_desc_6, NULL, }; static const struct usb_temp_interface_desc phone_iface_0 = { .ppEndpoints = NULL, /* no endpoints */ .ppRawDesc = phone_raw_iface_0_desc, - .bInterfaceClass = 1, - .bInterfaceSubClass = 1, + .bInterfaceClass = UICLASS_AUDIO, + .bInterfaceSubClass = UISUBCLASS_AUDIOCONTROL, .bInterfaceProtocol = 0, .iInterface = INDEX_PHONE_MIXER, }; static const uint8_t phone_raw_desc_20[] = { 0x07, 0x24, 0x01, 0x04, 0x01, 0x01, 0x00 }; static const uint8_t phone_raw_desc_21[] = { 0x0b, 0x24, 0x02, 0x01, 0x01, 0x02, 0x10, 0x01, /* 8kHz */ 0x40, 0x1f, 0x00 }; static const uint8_t phone_raw_desc_22[] = { 0x07, 0x25, 0x01, 0x00, 0x00, 0x00, 0x00 }; static const void *phone_raw_iface_1_desc[] = { phone_raw_desc_20, phone_raw_desc_21, NULL, }; static const void *phone_raw_ep_1_desc[] = { phone_raw_desc_22, NULL, }; static const struct usb_temp_packet_size phone_isoc_mps = { .mps[USB_SPEED_FULL] = 0x10, .mps[USB_SPEED_HIGH] = 0x10, }; static const struct usb_temp_interval phone_isoc_interval = { .bInterval[USB_SPEED_FULL] = 1, /* 1:1 */ .bInterval[USB_SPEED_HIGH] = 4, /* 1:8 */ }; static const struct usb_temp_endpoint_desc phone_isoc_in_ep = { .ppRawDesc = phone_raw_ep_1_desc, .pPacketSize = &phone_isoc_mps, .pIntervals = &phone_isoc_interval, .bEndpointAddress = UE_DIR_IN, .bmAttributes = UE_ISOCHRONOUS, }; static const struct usb_temp_endpoint_desc *phone_iface_1_ep[] = { &phone_isoc_in_ep, NULL, }; static const struct usb_temp_interface_desc phone_iface_1_alt_0 = { .ppEndpoints = NULL, /* no endpoints */ .ppRawDesc = NULL, /* no raw descriptors */ - .bInterfaceClass = 1, - .bInterfaceSubClass = 2, + .bInterfaceClass = UICLASS_AUDIO, + .bInterfaceSubClass = UISUBCLASS_AUDIOSTREAM, .bInterfaceProtocol = 0, .iInterface = INDEX_PHONE_PLAYBACK, }; static const struct usb_temp_interface_desc phone_iface_1_alt_1 = { .ppEndpoints = phone_iface_1_ep, .ppRawDesc = phone_raw_iface_1_desc, - .bInterfaceClass = 1, - .bInterfaceSubClass = 2, + .bInterfaceClass = UICLASS_AUDIO, + .bInterfaceSubClass = UISUBCLASS_AUDIOSTREAM, .bInterfaceProtocol = 0, .iInterface = INDEX_PHONE_PLAYBACK, .isAltInterface = 1, /* this is an alternate setting */ }; static const uint8_t phone_raw_desc_30[] = { 0x07, 0x24, 0x01, 0x02, 0x01, 0x01, 0x00 }; static const uint8_t phone_raw_desc_31[] = { 0x0b, 0x24, 0x02, 0x01, 0x01, 0x02, 0x10, 0x01, /* 8kHz */ 0x40, 0x1f, 0x00 }; static const uint8_t phone_raw_desc_32[] = { 0x07, 0x25, 0x01, 0x00, 0x00, 0x00, 0x00 }; static const void *phone_raw_iface_2_desc[] = { phone_raw_desc_30, phone_raw_desc_31, NULL, }; static const void *phone_raw_ep_2_desc[] = { phone_raw_desc_32, NULL, }; static const struct usb_temp_endpoint_desc phone_isoc_out_ep = { .ppRawDesc = phone_raw_ep_2_desc, .pPacketSize = &phone_isoc_mps, .pIntervals = &phone_isoc_interval, .bEndpointAddress = UE_DIR_OUT, .bmAttributes = UE_ISOCHRONOUS, }; static const struct usb_temp_endpoint_desc *phone_iface_2_ep[] = { &phone_isoc_out_ep, NULL, }; static const struct usb_temp_interface_desc phone_iface_2_alt_0 = { .ppEndpoints = NULL, /* no endpoints */ .ppRawDesc = NULL, /* no raw descriptors */ - .bInterfaceClass = 1, - .bInterfaceSubClass = 2, + .bInterfaceClass = UICLASS_AUDIO, + .bInterfaceSubClass = UISUBCLASS_AUDIOSTREAM, .bInterfaceProtocol = 0, .iInterface = INDEX_PHONE_RECORD, }; static const struct usb_temp_interface_desc phone_iface_2_alt_1 = { .ppEndpoints = phone_iface_2_ep, .ppRawDesc = phone_raw_iface_2_desc, - .bInterfaceClass = 1, - .bInterfaceSubClass = 2, + .bInterfaceClass = UICLASS_AUDIO, + .bInterfaceSubClass = UISUBCLASS_AUDIOSTREAM, .bInterfaceProtocol = 0, .iInterface = INDEX_PHONE_RECORD, .isAltInterface = 1, /* this is an alternate setting */ }; static const uint8_t phone_hid_raw_desc_0[] = { 0x09, 0x21, 0x00, 0x01, 0x00, 0x01, 0x22, sizeof(phone_hid_descriptor), 0x00 }; static const void *phone_hid_desc_0[] = { phone_hid_raw_desc_0, NULL, }; static const struct usb_temp_packet_size phone_hid_mps = { .mps[USB_SPEED_FULL] = 0x10, .mps[USB_SPEED_HIGH] = 0x10, }; static const struct usb_temp_interval phone_hid_interval = { .bInterval[USB_SPEED_FULL] = 2, /* 2ms */ .bInterval[USB_SPEED_HIGH] = 2, /* 2ms */ }; static const struct usb_temp_endpoint_desc phone_hid_in_ep = { .pPacketSize = &phone_hid_mps, .pIntervals = &phone_hid_interval, .bEndpointAddress = UE_DIR_IN, .bmAttributes = UE_INTERRUPT, }; static const struct usb_temp_endpoint_desc *phone_iface_3_ep[] = { &phone_hid_in_ep, NULL, }; static const struct usb_temp_interface_desc phone_iface_3 = { .ppEndpoints = phone_iface_3_ep, .ppRawDesc = phone_hid_desc_0, - .bInterfaceClass = 3, + .bInterfaceClass = UICLASS_HID, .bInterfaceSubClass = 0, .bInterfaceProtocol = 0, .iInterface = INDEX_PHONE_HID, }; static const struct usb_temp_interface_desc *phone_interfaces[] = { &phone_iface_0, &phone_iface_1_alt_0, &phone_iface_1_alt_1, &phone_iface_2_alt_0, &phone_iface_2_alt_1, &phone_iface_3, NULL, }; static const struct usb_temp_config_desc phone_config_desc = { .ppIfaceDesc = phone_interfaces, .bmAttributes = UC_BUS_POWERED, .bMaxPower = 25, /* 50 mA */ .iConfiguration = INDEX_PHONE_PRODUCT, }; static const struct usb_temp_config_desc *phone_configs[] = { &phone_config_desc, NULL, }; static usb_temp_get_string_desc_t phone_get_string_desc; static usb_temp_get_vendor_desc_t phone_get_vendor_desc; const struct usb_temp_device_desc usb_template_phone = { .getStringDesc = &phone_get_string_desc, .getVendorDesc = &phone_get_vendor_desc, .ppConfigDesc = phone_configs, .idVendor = USB_TEMPLATE_VENDOR, .idProduct = 0xb001, .bcdDevice = 0x0100, .bDeviceClass = UDCLASS_IN_INTERFACE, .bDeviceSubClass = 0, .bDeviceProtocol = 0, .iManufacturer = 0, .iProduct = INDEX_PHONE_PRODUCT, .iSerialNumber = 0, }; /*------------------------------------------------------------------------* * phone_get_vendor_desc * * Return values: * NULL: Failure. No such vendor descriptor. * Else: Success. Pointer to vendor descriptor is returned. *------------------------------------------------------------------------*/ static const void * phone_get_vendor_desc(const struct usb_device_request *req, uint16_t *plen) { if ((req->bmRequestType == 0x81) && (req->bRequest == 0x06) && (req->wValue[0] == 0x00) && (req->wValue[1] == 0x22) && (req->wIndex[1] == 0) && (req->wIndex[0] == 3 /* iface */)) { *plen = sizeof(phone_hid_descriptor); return (phone_hid_descriptor); } return (NULL); } /*------------------------------------------------------------------------* * phone_get_string_desc * * Return values: * NULL: Failure. No such string. * Else: Success. Pointer to string descriptor is returned. *------------------------------------------------------------------------*/ static const void * phone_get_string_desc(uint16_t lang_id, uint8_t string_index) { static const void *ptr[INDEX_PHONE_MAX] = { [INDEX_PHONE_LANG] = &usb_string_lang_en, [INDEX_PHONE_MIXER] = &string_phone_mixer, [INDEX_PHONE_RECORD] = &string_phone_record, [INDEX_PHONE_PLAYBACK] = &string_phone_playback, [INDEX_PHONE_PRODUCT] = &string_phone_product, [INDEX_PHONE_HID] = &string_phone_hid, }; if (string_index == 0) { return (&usb_string_lang_en); } if (lang_id != 0x0409) { return (NULL); } if (string_index < INDEX_PHONE_MAX) { return (ptr[string_index]); } return (NULL); } Index: stable/11/sys/dev/usb/template/usb_template_serialnet.c =================================================================== --- stable/11/sys/dev/usb/template/usb_template_serialnet.c (revision 332573) +++ stable/11/sys/dev/usb/template/usb_template_serialnet.c (revision 332574) @@ -1,387 +1,387 @@ /*- * Copyright (c) 2015 Ruslan Bukin * All rights reserved. * * This software was developed by SRI International and the University of * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) * ("CTSRD"), as part of the DARPA CRASH research programme. * * 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 contains the USB template for USB Networking and Serial */ #include __FBSDID("$FreeBSD$"); #ifdef USB_GLOBAL_INCLUDE_FILE #include USB_GLOBAL_INCLUDE_FILE #else #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #endif /* USB_GLOBAL_INCLUDE_FILE */ #define MODEM_IFACE_0 0 #define MODEM_IFACE_1 1 enum { STRING_LANG_INDEX, STRING_MODEM_INDEX, STRING_ETH_MAC_INDEX, STRING_ETH_CONTROL_INDEX, STRING_ETH_DATA_INDEX, STRING_ETH_CONFIG_INDEX, STRING_CONFIG_INDEX, STRING_VENDOR_INDEX, STRING_PRODUCT_INDEX, STRING_SERIAL_INDEX, STRING_MAX, }; #define STRING_MODEM \ "U\0S\0B\0 \0M\0o\0d\0e\0m\0 \0I\0n\0t\0e\0r\0f\0a\0c\0e" #define STRING_ETH_MAC \ "2\0A\0002\0003\0004\0005\0006\0007\08\09\0A\0B" #define STRING_ETH_CONTROL \ "U\0S\0B\0 \0E\0t\0h\0e\0r\0n\0e\0t\0 " \ "\0C\0o\0m\0m\0 \0I\0n\0t\0e\0r\0f\0a\0c\0e" #define STRING_ETH_DATA \ "U\0S\0B\0 \0E\0t\0h\0e\0r\0n\0e\0t\0 \0D\0a\0t\0a\0 " \ "\0I\0n\0t\0e\0r\0f\0a\0c\0e" #define STRING_CONFIG \ "D\0e\0f\0a\0u\0l\0t\0 \0c\0o\0n\0f\0i\0g\0u\0r\0a\0t\0i\0o\0n" #define STRING_VENDOR \ "T\0h\0e\0 \0F\0r\0e\0e\0B\0S\0D\0 \0P\0r\0o\0j\0e\0c\0t" #define STRING_PRODUCT \ "S\0E\0R\0I\0A\0L\0N\0E\0T" #define STRING_SERIAL \ "J\0a\0n\0u\0a\0r\0y\0 \0002\0000\0001\0005" /* make the real string descriptors */ USB_MAKE_STRING_DESC(STRING_MODEM, string_modem); USB_MAKE_STRING_DESC(STRING_ETH_MAC, string_eth_mac); USB_MAKE_STRING_DESC(STRING_ETH_CONTROL, string_eth_control); USB_MAKE_STRING_DESC(STRING_ETH_DATA, string_eth_data); USB_MAKE_STRING_DESC(STRING_CONFIG, string_serialnet_config); USB_MAKE_STRING_DESC(STRING_VENDOR, string_serialnet_vendor); USB_MAKE_STRING_DESC(STRING_PRODUCT, string_serialnet_product); USB_MAKE_STRING_DESC(STRING_SERIAL, string_serialnet_serial); /* prototypes */ static usb_temp_get_string_desc_t serialnet_get_string_desc; static const struct usb_cdc_union_descriptor eth_union_desc = { .bLength = sizeof(eth_union_desc), .bDescriptorType = UDESC_CS_INTERFACE, .bDescriptorSubtype = UDESCSUB_CDC_UNION, .bMasterInterface = 0, /* this is automatically updated */ .bSlaveInterface[0] = 1, /* this is automatically updated */ }; static const struct usb_cdc_header_descriptor eth_header_desc = { .bLength = sizeof(eth_header_desc), .bDescriptorType = UDESC_CS_INTERFACE, .bDescriptorSubtype = UDESCSUB_CDC_HEADER, .bcdCDC[0] = 0x10, .bcdCDC[1] = 0x01, }; static const struct usb_cdc_ethernet_descriptor eth_enf_desc = { .bLength = sizeof(eth_enf_desc), .bDescriptorType = UDESC_CS_INTERFACE, .bDescriptorSubtype = UDESCSUB_CDC_ENF, .iMacAddress = STRING_ETH_MAC_INDEX, .bmEthernetStatistics = {0, 0, 0, 0}, .wMaxSegmentSize = {0xEA, 0x05},/* 1514 bytes */ .wNumberMCFilters = {0, 0}, .bNumberPowerFilters = 0, }; static const void *eth_control_if_desc[] = { ð_union_desc, ð_header_desc, ð_enf_desc, NULL, }; static const struct usb_temp_packet_size bulk_mps = { .mps[USB_SPEED_FULL] = 64, .mps[USB_SPEED_HIGH] = 512, }; static const struct usb_temp_packet_size intr_mps = { .mps[USB_SPEED_FULL] = 8, .mps[USB_SPEED_HIGH] = 8, }; static const struct usb_temp_endpoint_desc bulk_in_ep = { .pPacketSize = &bulk_mps, #ifdef USB_HIP_IN_EP_0 .bEndpointAddress = USB_HIP_IN_EP_0, #else .bEndpointAddress = UE_DIR_IN, #endif .bmAttributes = UE_BULK, }; static const struct usb_temp_endpoint_desc bulk_out_ep = { .pPacketSize = &bulk_mps, #ifdef USB_HIP_OUT_EP_0 .bEndpointAddress = USB_HIP_OUT_EP_0, #else .bEndpointAddress = UE_DIR_OUT, #endif .bmAttributes = UE_BULK, }; static const struct usb_temp_endpoint_desc intr_in_ep = { .pPacketSize = &intr_mps, .bEndpointAddress = UE_DIR_IN, .bmAttributes = UE_INTERRUPT, }; static const struct usb_temp_endpoint_desc *eth_intr_endpoints[] = { &intr_in_ep, NULL, }; static const struct usb_temp_interface_desc eth_control_interface = { .ppEndpoints = eth_intr_endpoints, .ppRawDesc = eth_control_if_desc, .bInterfaceClass = UICLASS_CDC, .bInterfaceSubClass = UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL, - .bInterfaceProtocol = 0, + .bInterfaceProtocol = UIPROTO_CDC_NONE, .iInterface = STRING_ETH_CONTROL_INDEX, }; static const struct usb_temp_endpoint_desc *eth_data_endpoints[] = { &bulk_in_ep, &bulk_out_ep, NULL, }; static const struct usb_temp_interface_desc eth_data_null_interface = { .ppEndpoints = NULL, /* no endpoints */ .bInterfaceClass = UICLASS_CDC_DATA, - .bInterfaceSubClass = 0, + .bInterfaceSubClass = UISUBCLASS_DATA, .bInterfaceProtocol = 0, .iInterface = STRING_ETH_DATA_INDEX, }; static const struct usb_temp_interface_desc eth_data_interface = { .ppEndpoints = eth_data_endpoints, .bInterfaceClass = UICLASS_CDC_DATA, .bInterfaceSubClass = UISUBCLASS_DATA, .bInterfaceProtocol = 0, .iInterface = STRING_ETH_DATA_INDEX, .isAltInterface = 1, /* this is an alternate setting */ }; static const struct usb_temp_packet_size modem_bulk_mps = { .mps[USB_SPEED_LOW] = 8, .mps[USB_SPEED_FULL] = 64, .mps[USB_SPEED_HIGH] = 512, }; static const struct usb_temp_packet_size modem_intr_mps = { .mps[USB_SPEED_LOW] = 8, .mps[USB_SPEED_FULL] = 8, .mps[USB_SPEED_HIGH] = 8, }; static const struct usb_temp_interval modem_intr_interval = { .bInterval[USB_SPEED_LOW] = 8, /* 8ms */ .bInterval[USB_SPEED_FULL] = 8, /* 8ms */ .bInterval[USB_SPEED_HIGH] = 7, /* 8ms */ }; static const struct usb_temp_endpoint_desc modem_ep_0 = { .pPacketSize = &modem_intr_mps, .pIntervals = &modem_intr_interval, .bEndpointAddress = UE_DIR_IN, .bmAttributes = UE_INTERRUPT, }; static const struct usb_temp_endpoint_desc modem_ep_1 = { .pPacketSize = &modem_bulk_mps, .bEndpointAddress = UE_DIR_OUT, .bmAttributes = UE_BULK, }; static const struct usb_temp_endpoint_desc modem_ep_2 = { .pPacketSize = &modem_bulk_mps, .bEndpointAddress = UE_DIR_IN, .bmAttributes = UE_BULK, }; static const struct usb_temp_endpoint_desc *modem_iface_0_ep[] = { &modem_ep_0, NULL, }; static const struct usb_temp_endpoint_desc *modem_iface_1_ep[] = { &modem_ep_1, &modem_ep_2, NULL, }; static const uint8_t modem_raw_desc_0[] = { 0x05, 0x24, 0x00, 0x10, 0x01 }; static const uint8_t modem_raw_desc_1[] = { 0x05, 0x24, 0x06, MODEM_IFACE_0, MODEM_IFACE_1 }; static const uint8_t modem_raw_desc_2[] = { 0x05, 0x24, 0x01, 0x03, MODEM_IFACE_1 }; static const uint8_t modem_raw_desc_3[] = { 0x04, 0x24, 0x02, 0x07 }; static const void *modem_iface_0_desc[] = { &modem_raw_desc_0, &modem_raw_desc_1, &modem_raw_desc_2, &modem_raw_desc_3, NULL, }; static const struct usb_temp_interface_desc modem_iface_0 = { .ppRawDesc = modem_iface_0_desc, .ppEndpoints = modem_iface_0_ep, - .bInterfaceClass = 2, - .bInterfaceSubClass = 2, - .bInterfaceProtocol = 1, + .bInterfaceClass = UICLASS_CDC, + .bInterfaceSubClass = UISUBCLASS_ABSTRACT_CONTROL_MODEL, + .bInterfaceProtocol = UIPROTO_CDC_AT, .iInterface = STRING_MODEM_INDEX, }; static const struct usb_temp_interface_desc modem_iface_1 = { .ppEndpoints = modem_iface_1_ep, - .bInterfaceClass = 10, - .bInterfaceSubClass = 0, + .bInterfaceClass = UICLASS_CDC_DATA, + .bInterfaceSubClass = UISUBCLASS_DATA, .bInterfaceProtocol = 0, .iInterface = STRING_MODEM_INDEX, }; static const struct usb_temp_interface_desc *serialnet_interfaces[] = { &modem_iface_0, &modem_iface_1, ð_control_interface, ð_data_null_interface, ð_data_interface, NULL, }; static const struct usb_temp_config_desc serialnet_config_desc = { .ppIfaceDesc = serialnet_interfaces, .bmAttributes = UC_BUS_POWERED, .bMaxPower = 25, /* 50 mA */ .iConfiguration = STRING_CONFIG_INDEX, }; static const struct usb_temp_config_desc *serialnet_configs[] = { &serialnet_config_desc, NULL, }; const struct usb_temp_device_desc usb_template_serialnet = { .getStringDesc = &serialnet_get_string_desc, .ppConfigDesc = serialnet_configs, .idVendor = USB_TEMPLATE_VENDOR, .idProduct = 0x0001, .bcdDevice = 0x0100, .bDeviceClass = UDCLASS_COMM, .bDeviceSubClass = 0, .bDeviceProtocol = 0, .iManufacturer = STRING_VENDOR_INDEX, .iProduct = STRING_PRODUCT_INDEX, .iSerialNumber = STRING_SERIAL_INDEX, }; /*------------------------------------------------------------------------* * serialnet_get_string_desc * * Return values: * NULL: Failure. No such string. * Else: Success. Pointer to string descriptor is returned. *------------------------------------------------------------------------*/ static const void * serialnet_get_string_desc(uint16_t lang_id, uint8_t string_index) { static const void *ptr[STRING_MAX] = { [STRING_LANG_INDEX] = &usb_string_lang_en, [STRING_MODEM_INDEX] = &string_modem, [STRING_ETH_MAC_INDEX] = &string_eth_mac, [STRING_ETH_CONTROL_INDEX] = &string_eth_control, [STRING_ETH_DATA_INDEX] = &string_eth_data, [STRING_CONFIG_INDEX] = &string_serialnet_config, [STRING_VENDOR_INDEX] = &string_serialnet_vendor, [STRING_PRODUCT_INDEX] = &string_serialnet_product, [STRING_SERIAL_INDEX] = &string_serialnet_serial, }; if (string_index == 0) { return (&usb_string_lang_en); } if (lang_id != 0x0409) { return (NULL); } if (string_index < STRING_MAX) { return (ptr[string_index]); } return (NULL); } Index: stable/11 =================================================================== --- stable/11 (revision 332573) +++ stable/11 (revision 332574) Property changes on: stable/11 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r324626