mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 20:22:09 +00:00
USB fixes for 3.7-rc2
Here are the USB patches against your 3.7-rc1 tree. There are the usual UABI header file movements, and we finally are now able to remove the dbg() macro that is over 15 years old (that had to wait for after some other trees got merged into yours during the big 3.7-rc1 merge window.) Other than that, nothing major, just a number of bugfixes and new device ids. It turns out that almost all of the usb-serial drivers had bugs in how they were handling their internal data, leaking memory, hence all of those fixups. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) iEYEABECAAYFAlCBmLkACgkQMUfUDdst+yn8uACg2QF+GZm1DZvCjBHMSuiaNM3Q jxEAnA8LkdQWb0wr55RFiPQl/uB0rD0E =nNHn -----END PGP SIGNATURE----- Merge tag 'usb-3.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb Pull USB fixes from Greg Kroah-Hartman: "Here are the USB patches against your 3.7-rc1 tree. There are the usual UABI header file movements, and we finally are now able to remove the dbg() macro that is over 15 years old (that had to wait for after some other trees got merged into yours during the big 3.7-rc1 merge window.) Other than that, nothing major, just a number of bugfixes and new device ids. It turns out that almost all of the usb-serial drivers had bugs in how they were handling their internal data, leaking memory, hence all of those fixups. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>" * tag 'usb-3.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (42 commits) USB: option: add more ZTE devices USB: option: blacklist net interface on ZTE devices usb: host: xhci: New system added for Compliance Mode Patch on SN65LVPE502CP USB: io_ti: fix sysfs-attribute creation USB: iuu_phoenix: fix sysfs-attribute creation USB: spcp8x5: fix port-data memory leak USB: ssu100: fix port-data memory leak USB: ti_usb_3410_5052: fix port-data memory leak USB: oti6858: fix port-data memory leak USB: iuu_phoenix: fix port-data memory leak USB: kl5kusb105: fix port-data memory leak USB: io_ti: fix port-data memory leak USB: keyspan_pda: fix port-data memory leak USB: f81232: fix port-data memory leak USB: io_edgeport: fix port-data memory leak USB: kobil_sct: fix port-data memory leak USB: cypress_m8: fix port-data memory leak usb: acm: fix the computation of the number of data bits usb: Missing dma_mask in ehci-vt8500.c when probed from device-tree usb: Missing dma_mask in uhci-platform.c when probed from device-tree ...
This commit is contained in:
commit
42bf3e27e8
@ -7746,6 +7746,13 @@ W: http://www.ideasonboard.org/uvc/
|
||||
S: Maintained
|
||||
F: drivers/media/usb/uvc/
|
||||
|
||||
USB WEBCAM GADGET
|
||||
M: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
||||
L: linux-usb@vger.kernel.org
|
||||
S: Maintained
|
||||
F: drivers/usb/gadget/*uvc*.c
|
||||
F: drivers/usb/gadget/webcam.c
|
||||
|
||||
USB WIRELESS RNDIS DRIVER (rndis_wlan)
|
||||
M: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
|
||||
L: linux-wireless@vger.kernel.org
|
||||
|
@ -817,10 +817,6 @@ static const __u32 acm_tty_speed[] = {
|
||||
2500000, 3000000, 3500000, 4000000
|
||||
};
|
||||
|
||||
static const __u8 acm_tty_size[] = {
|
||||
5, 6, 7, 8
|
||||
};
|
||||
|
||||
static void acm_tty_set_termios(struct tty_struct *tty,
|
||||
struct ktermios *termios_old)
|
||||
{
|
||||
@ -834,7 +830,21 @@ static void acm_tty_set_termios(struct tty_struct *tty,
|
||||
newline.bParityType = termios->c_cflag & PARENB ?
|
||||
(termios->c_cflag & PARODD ? 1 : 2) +
|
||||
(termios->c_cflag & CMSPAR ? 2 : 0) : 0;
|
||||
newline.bDataBits = acm_tty_size[(termios->c_cflag & CSIZE) >> 4];
|
||||
switch (termios->c_cflag & CSIZE) {
|
||||
case CS5:
|
||||
newline.bDataBits = 5;
|
||||
break;
|
||||
case CS6:
|
||||
newline.bDataBits = 6;
|
||||
break;
|
||||
case CS7:
|
||||
newline.bDataBits = 7;
|
||||
break;
|
||||
case CS8:
|
||||
default:
|
||||
newline.bDataBits = 8;
|
||||
break;
|
||||
}
|
||||
/* FIXME: Needs to clear unsupported bits in the termios */
|
||||
acm->clocal = ((termios->c_cflag & CLOCAL) != 0);
|
||||
|
||||
@ -1233,7 +1243,7 @@ made_compressed_probe:
|
||||
|
||||
if (usb_endpoint_xfer_int(epwrite))
|
||||
usb_fill_int_urb(snd->urb, usb_dev,
|
||||
usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress),
|
||||
usb_sndintpipe(usb_dev, epwrite->bEndpointAddress),
|
||||
NULL, acm->writesize, acm_write_bulk, snd, epwrite->bInterval);
|
||||
else
|
||||
usb_fill_bulk_urb(snd->urb, usb_dev,
|
||||
|
@ -1348,6 +1348,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
|
||||
ret = -EFAULT;
|
||||
goto error;
|
||||
}
|
||||
uurb->buffer += u;
|
||||
}
|
||||
totlen -= u;
|
||||
}
|
||||
|
@ -367,6 +367,10 @@ static int usb_probe_interface(struct device *dev)
|
||||
intf->condition = USB_INTERFACE_UNBOUND;
|
||||
usb_cancel_queued_reset(intf);
|
||||
|
||||
/* If the LPM disable succeeded, balance the ref counts. */
|
||||
if (!lpm_disable_error)
|
||||
usb_unlocked_enable_lpm(udev);
|
||||
|
||||
/* Unbound interfaces are always runtime-PM-disabled and -suspended */
|
||||
if (driver->supports_autosuspend)
|
||||
pm_runtime_disable(dev);
|
||||
|
@ -3241,8 +3241,7 @@ static int usb_req_set_sel(struct usb_device *udev, enum usb3_link_state state)
|
||||
(state == USB3_LPM_U2 &&
|
||||
(u2_sel > USB3_LPM_MAX_U2_SEL_PEL ||
|
||||
u2_pel > USB3_LPM_MAX_U2_SEL_PEL))) {
|
||||
dev_dbg(&udev->dev, "Device-initiated %s disabled due "
|
||||
"to long SEL %llu ms or PEL %llu ms\n",
|
||||
dev_dbg(&udev->dev, "Device-initiated %s disabled due to long SEL %llu us or PEL %llu us\n",
|
||||
usb3_lpm_names[state], u1_sel, u1_pel);
|
||||
return -EINVAL;
|
||||
}
|
||||
@ -3319,16 +3318,6 @@ static int usb_set_device_initiated_lpm(struct usb_device *udev,
|
||||
}
|
||||
|
||||
if (enable) {
|
||||
/*
|
||||
* First, let the device know about the exit latencies
|
||||
* associated with the link state we're about to enable.
|
||||
*/
|
||||
ret = usb_req_set_sel(udev, state);
|
||||
if (ret < 0) {
|
||||
dev_warn(&udev->dev, "Set SEL for device-initiated "
|
||||
"%s failed.\n", usb3_lpm_names[state]);
|
||||
return -EBUSY;
|
||||
}
|
||||
/*
|
||||
* Now send the control transfer to enable device-initiated LPM
|
||||
* for either U1 or U2.
|
||||
@ -3414,7 +3403,28 @@ static int usb_set_lpm_timeout(struct usb_device *udev,
|
||||
static void usb_enable_link_state(struct usb_hcd *hcd, struct usb_device *udev,
|
||||
enum usb3_link_state state)
|
||||
{
|
||||
int timeout;
|
||||
int timeout, ret;
|
||||
__u8 u1_mel = udev->bos->ss_cap->bU1devExitLat;
|
||||
__le16 u2_mel = udev->bos->ss_cap->bU2DevExitLat;
|
||||
|
||||
/* If the device says it doesn't have *any* exit latency to come out of
|
||||
* U1 or U2, it's probably lying. Assume it doesn't implement that link
|
||||
* state.
|
||||
*/
|
||||
if ((state == USB3_LPM_U1 && u1_mel == 0) ||
|
||||
(state == USB3_LPM_U2 && u2_mel == 0))
|
||||
return;
|
||||
|
||||
/*
|
||||
* First, let the device know about the exit latencies
|
||||
* associated with the link state we're about to enable.
|
||||
*/
|
||||
ret = usb_req_set_sel(udev, state);
|
||||
if (ret < 0) {
|
||||
dev_warn(&udev->dev, "Set SEL for device-initiated %s failed.\n",
|
||||
usb3_lpm_names[state]);
|
||||
return;
|
||||
}
|
||||
|
||||
/* We allow the host controller to set the U1/U2 timeout internally
|
||||
* first, so that it can change its schedule to account for the
|
||||
|
@ -409,6 +409,10 @@ static void dwc3_core_exit(struct dwc3 *dwc)
|
||||
{
|
||||
dwc3_event_buffers_cleanup(dwc);
|
||||
dwc3_free_event_buffers(dwc);
|
||||
|
||||
usb_phy_shutdown(dwc->usb2_phy);
|
||||
usb_phy_shutdown(dwc->usb3_phy);
|
||||
|
||||
}
|
||||
|
||||
#define DWC3_ALIGN_MASK (16 - 1)
|
||||
|
@ -1904,7 +1904,7 @@ static void dwc3_stop_active_transfer(struct dwc3 *dwc, u32 epnum)
|
||||
ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, cmd, ¶ms);
|
||||
WARN_ON_ONCE(ret);
|
||||
dep->resource_index = 0;
|
||||
|
||||
dep->flags &= ~DWC3_EP_BUSY;
|
||||
udelay(100);
|
||||
}
|
||||
|
||||
|
@ -952,6 +952,7 @@ endif
|
||||
config USB_G_WEBCAM
|
||||
tristate "USB Webcam Gadget"
|
||||
depends on VIDEO_DEV
|
||||
select USB_LIBCOMPOSITE
|
||||
help
|
||||
The Webcam Gadget acts as a composite USB Audio and Video Class
|
||||
device. It provides a userspace API to process UVC control requests
|
||||
|
@ -2930,10 +2930,10 @@ static void vbus_work(struct work_struct *work)
|
||||
|
||||
/* Get the VBUS status from the transceiver */
|
||||
value = i2c_smbus_read_byte_data(udc->isp1301_i2c_client,
|
||||
ISP1301_I2C_OTG_CONTROL_2);
|
||||
ISP1301_I2C_INTERRUPT_SOURCE);
|
||||
|
||||
/* VBUS on or off? */
|
||||
if (value & OTG_B_SESS_VLD)
|
||||
if (value & INT_SESS_VLD)
|
||||
udc->vbus = 1;
|
||||
else
|
||||
udc->vbus = 0;
|
||||
|
@ -85,6 +85,8 @@ static const struct hc_driver vt8500_ehci_hc_driver = {
|
||||
.clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
|
||||
};
|
||||
|
||||
static u64 vt8500_ehci_dma_mask = DMA_BIT_MASK(32);
|
||||
|
||||
static int vt8500_ehci_drv_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct usb_hcd *hcd;
|
||||
@ -95,6 +97,14 @@ static int vt8500_ehci_drv_probe(struct platform_device *pdev)
|
||||
if (usb_disabled())
|
||||
return -ENODEV;
|
||||
|
||||
/*
|
||||
* Right now device-tree probed devices don't get dma_mask set.
|
||||
* Since shared usb code relies on it, set it here for now.
|
||||
* Once we have dma capability bindings this can go away.
|
||||
*/
|
||||
if (!pdev->dev.dma_mask)
|
||||
pdev->dev.dma_mask = &vt8500_ehci_dma_mask;
|
||||
|
||||
if (pdev->resource[1].flags != IORESOURCE_IRQ) {
|
||||
pr_debug("resource[1] is not IORESOURCE_IRQ");
|
||||
return -ENOMEM;
|
||||
|
@ -60,6 +60,7 @@ static const struct hc_driver uhci_platform_hc_driver = {
|
||||
.hub_control = uhci_hub_control,
|
||||
};
|
||||
|
||||
static u64 platform_uhci_dma_mask = DMA_BIT_MASK(32);
|
||||
|
||||
static int __devinit uhci_hcd_platform_probe(struct platform_device *pdev)
|
||||
{
|
||||
@ -71,6 +72,14 @@ static int __devinit uhci_hcd_platform_probe(struct platform_device *pdev)
|
||||
if (usb_disabled())
|
||||
return -ENODEV;
|
||||
|
||||
/*
|
||||
* Right now device-tree probed devices don't get dma_mask set.
|
||||
* Since shared usb code relies on it, set it here for now.
|
||||
* Once we have dma capability bindings this can go away.
|
||||
*/
|
||||
if (!pdev->dev.dma_mask)
|
||||
pdev->dev.dma_mask = &platform_uhci_dma_mask;
|
||||
|
||||
hcd = usb_create_hcd(&uhci_platform_hc_driver, &pdev->dev,
|
||||
pdev->name);
|
||||
if (!hcd)
|
||||
|
@ -479,7 +479,8 @@ static bool compliance_mode_recovery_timer_quirk_check(void)
|
||||
|
||||
if (strstr(dmi_product_name, "Z420") ||
|
||||
strstr(dmi_product_name, "Z620") ||
|
||||
strstr(dmi_product_name, "Z820"))
|
||||
strstr(dmi_product_name, "Z820") ||
|
||||
strstr(dmi_product_name, "Z1"))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -305,6 +305,12 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
|
||||
ret = IRQ_HANDLED;
|
||||
}
|
||||
|
||||
/* Drop spurious RX and TX if device is disconnected */
|
||||
if (musb->int_usb & MUSB_INTR_DISCONNECT) {
|
||||
musb->int_tx = 0;
|
||||
musb->int_rx = 0;
|
||||
}
|
||||
|
||||
if (musb->int_tx || musb->int_rx || musb->int_usb)
|
||||
ret |= musb_interrupt(musb);
|
||||
|
||||
|
@ -273,9 +273,9 @@ static irqreturn_t usbhs_interrupt(int irq, void *data)
|
||||
usbhs_write(priv, INTSTS0, ~irq_state.intsts0 & INTSTS0_MAGIC);
|
||||
usbhs_write(priv, INTSTS1, ~irq_state.intsts1 & INTSTS1_MAGIC);
|
||||
|
||||
usbhs_write(priv, BRDYSTS, 0);
|
||||
usbhs_write(priv, NRDYSTS, 0);
|
||||
usbhs_write(priv, BEMPSTS, 0);
|
||||
usbhs_write(priv, BRDYSTS, ~irq_state.brdysts);
|
||||
usbhs_write(priv, NRDYSTS, ~irq_state.nrdysts);
|
||||
usbhs_write(priv, BEMPSTS, ~irq_state.bempsts);
|
||||
|
||||
/*
|
||||
* call irq callback functions
|
||||
|
@ -54,7 +54,7 @@ struct usbhs_pipe_info {
|
||||
* pipe list
|
||||
*/
|
||||
#define __usbhs_for_each_pipe(start, pos, info, i) \
|
||||
for (i = start, pos = (info)->pipe; \
|
||||
for (i = start, pos = (info)->pipe + i; \
|
||||
i < (info)->size; \
|
||||
i++, pos = (info)->pipe + i)
|
||||
|
||||
|
@ -125,9 +125,6 @@ static inline int calc_divisor(int bps)
|
||||
|
||||
static int ark3116_attach(struct usb_serial *serial)
|
||||
{
|
||||
struct usb_serial_port *port = serial->port[0];
|
||||
struct ark3116_private *priv;
|
||||
|
||||
/* make sure we have our end-points */
|
||||
if ((serial->num_bulk_in == 0) ||
|
||||
(serial->num_bulk_out == 0) ||
|
||||
@ -142,8 +139,15 @@ static int ark3116_attach(struct usb_serial *serial)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
priv = kzalloc(sizeof(struct ark3116_private),
|
||||
GFP_KERNEL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ark3116_port_probe(struct usb_serial_port *port)
|
||||
{
|
||||
struct usb_serial *serial = port->serial;
|
||||
struct ark3116_private *priv;
|
||||
|
||||
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
@ -198,18 +202,15 @@ static int ark3116_attach(struct usb_serial *serial)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ark3116_release(struct usb_serial *serial)
|
||||
static int ark3116_port_remove(struct usb_serial_port *port)
|
||||
{
|
||||
struct usb_serial_port *port = serial->port[0];
|
||||
struct ark3116_private *priv = usb_get_serial_port_data(port);
|
||||
|
||||
/* device is closed, so URBs and DMA should be down */
|
||||
|
||||
usb_set_serial_port_data(port, NULL);
|
||||
|
||||
mutex_destroy(&priv->hw_lock);
|
||||
|
||||
kfree(priv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ark3116_init_termios(struct tty_struct *tty)
|
||||
@ -723,7 +724,8 @@ static struct usb_serial_driver ark3116_device = {
|
||||
.id_table = id_table,
|
||||
.num_ports = 1,
|
||||
.attach = ark3116_attach,
|
||||
.release = ark3116_release,
|
||||
.port_probe = ark3116_port_probe,
|
||||
.port_remove = ark3116_port_remove,
|
||||
.set_termios = ark3116_set_termios,
|
||||
.init_termios = ark3116_init_termios,
|
||||
.ioctl = ark3116_ioctl,
|
||||
|
@ -45,8 +45,8 @@
|
||||
#define DRIVER_DESC "USB Belkin Serial converter driver"
|
||||
|
||||
/* function prototypes for a Belkin USB Serial Adapter F5U103 */
|
||||
static int belkin_sa_startup(struct usb_serial *serial);
|
||||
static void belkin_sa_release(struct usb_serial *serial);
|
||||
static int belkin_sa_port_probe(struct usb_serial_port *port);
|
||||
static int belkin_sa_port_remove(struct usb_serial_port *port);
|
||||
static int belkin_sa_open(struct tty_struct *tty,
|
||||
struct usb_serial_port *port);
|
||||
static void belkin_sa_close(struct usb_serial_port *port);
|
||||
@ -88,8 +88,8 @@ static struct usb_serial_driver belkin_device = {
|
||||
.break_ctl = belkin_sa_break_ctl,
|
||||
.tiocmget = belkin_sa_tiocmget,
|
||||
.tiocmset = belkin_sa_tiocmset,
|
||||
.attach = belkin_sa_startup,
|
||||
.release = belkin_sa_release,
|
||||
.port_probe = belkin_sa_port_probe,
|
||||
.port_remove = belkin_sa_port_remove,
|
||||
};
|
||||
|
||||
static struct usb_serial_driver * const serial_drivers[] = {
|
||||
@ -118,17 +118,15 @@ struct belkin_sa_private {
|
||||
(c), BELKIN_SA_SET_REQUEST_TYPE, \
|
||||
(v), 0, NULL, 0, WDR_TIMEOUT)
|
||||
|
||||
/* do some startup allocations not currently performed by usb_serial_probe() */
|
||||
static int belkin_sa_startup(struct usb_serial *serial)
|
||||
static int belkin_sa_port_probe(struct usb_serial_port *port)
|
||||
{
|
||||
struct usb_device *dev = serial->dev;
|
||||
struct usb_device *dev = port->serial->dev;
|
||||
struct belkin_sa_private *priv;
|
||||
|
||||
/* allocate the private data structure */
|
||||
priv = kmalloc(sizeof(struct belkin_sa_private), GFP_KERNEL);
|
||||
if (!priv)
|
||||
return -1; /* error */
|
||||
/* set initial values for control structures */
|
||||
return -ENOMEM;
|
||||
|
||||
spin_lock_init(&priv->lock);
|
||||
priv->control_state = 0;
|
||||
priv->last_lsr = 0;
|
||||
@ -140,18 +138,19 @@ static int belkin_sa_startup(struct usb_serial *serial)
|
||||
le16_to_cpu(dev->descriptor.bcdDevice),
|
||||
priv->bad_flow_control);
|
||||
|
||||
init_waitqueue_head(&serial->port[0]->write_wait);
|
||||
usb_set_serial_port_data(serial->port[0], priv);
|
||||
usb_set_serial_port_data(port, priv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void belkin_sa_release(struct usb_serial *serial)
|
||||
static int belkin_sa_port_remove(struct usb_serial_port *port)
|
||||
{
|
||||
int i;
|
||||
struct belkin_sa_private *priv;
|
||||
|
||||
for (i = 0; i < serial->num_ports; ++i)
|
||||
kfree(usb_get_serial_port_data(serial->port[i]));
|
||||
priv = usb_get_serial_port_data(port);
|
||||
kfree(priv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int belkin_sa_open(struct tty_struct *tty,
|
||||
|
@ -162,7 +162,7 @@ static const struct usb_device_id id_table[] = {
|
||||
|
||||
MODULE_DEVICE_TABLE(usb, id_table);
|
||||
|
||||
struct cp210x_port_private {
|
||||
struct cp210x_serial_private {
|
||||
__u8 bInterfaceNumber;
|
||||
};
|
||||
|
||||
@ -276,7 +276,7 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request,
|
||||
unsigned int *data, int size)
|
||||
{
|
||||
struct usb_serial *serial = port->serial;
|
||||
struct cp210x_port_private *port_priv = usb_get_serial_port_data(port);
|
||||
struct cp210x_serial_private *spriv = usb_get_serial_data(serial);
|
||||
__le32 *buf;
|
||||
int result, i, length;
|
||||
|
||||
@ -292,7 +292,7 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request,
|
||||
/* Issue the request, attempting to read 'size' bytes */
|
||||
result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
|
||||
request, REQTYPE_INTERFACE_TO_HOST, 0x0000,
|
||||
port_priv->bInterfaceNumber, buf, size,
|
||||
spriv->bInterfaceNumber, buf, size,
|
||||
USB_CTRL_GET_TIMEOUT);
|
||||
|
||||
/* Convert data into an array of integers */
|
||||
@ -323,7 +323,7 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request,
|
||||
unsigned int *data, int size)
|
||||
{
|
||||
struct usb_serial *serial = port->serial;
|
||||
struct cp210x_port_private *port_priv = usb_get_serial_port_data(port);
|
||||
struct cp210x_serial_private *spriv = usb_get_serial_data(serial);
|
||||
__le32 *buf;
|
||||
int result, i, length;
|
||||
|
||||
@ -345,13 +345,13 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request,
|
||||
result = usb_control_msg(serial->dev,
|
||||
usb_sndctrlpipe(serial->dev, 0),
|
||||
request, REQTYPE_HOST_TO_INTERFACE, 0x0000,
|
||||
port_priv->bInterfaceNumber, buf, size,
|
||||
spriv->bInterfaceNumber, buf, size,
|
||||
USB_CTRL_SET_TIMEOUT);
|
||||
} else {
|
||||
result = usb_control_msg(serial->dev,
|
||||
usb_sndctrlpipe(serial->dev, 0),
|
||||
request, REQTYPE_HOST_TO_INTERFACE, data[0],
|
||||
port_priv->bInterfaceNumber, NULL, 0,
|
||||
spriv->bInterfaceNumber, NULL, 0,
|
||||
USB_CTRL_SET_TIMEOUT);
|
||||
}
|
||||
|
||||
@ -845,36 +845,30 @@ static void cp210x_break_ctl (struct tty_struct *tty, int break_state)
|
||||
|
||||
static int cp210x_startup(struct usb_serial *serial)
|
||||
{
|
||||
struct cp210x_port_private *port_priv;
|
||||
int i;
|
||||
struct usb_host_interface *cur_altsetting;
|
||||
struct cp210x_serial_private *spriv;
|
||||
|
||||
/* cp210x buffers behave strangely unless device is reset */
|
||||
usb_reset_device(serial->dev);
|
||||
|
||||
for (i = 0; i < serial->num_ports; i++) {
|
||||
port_priv = kzalloc(sizeof(*port_priv), GFP_KERNEL);
|
||||
if (!port_priv)
|
||||
return -ENOMEM;
|
||||
spriv = kzalloc(sizeof(*spriv), GFP_KERNEL);
|
||||
if (!spriv)
|
||||
return -ENOMEM;
|
||||
|
||||
port_priv->bInterfaceNumber =
|
||||
serial->interface->cur_altsetting->desc.bInterfaceNumber;
|
||||
cur_altsetting = serial->interface->cur_altsetting;
|
||||
spriv->bInterfaceNumber = cur_altsetting->desc.bInterfaceNumber;
|
||||
|
||||
usb_set_serial_port_data(serial->port[i], port_priv);
|
||||
}
|
||||
usb_set_serial_data(serial, spriv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void cp210x_release(struct usb_serial *serial)
|
||||
{
|
||||
struct cp210x_port_private *port_priv;
|
||||
int i;
|
||||
struct cp210x_serial_private *spriv;
|
||||
|
||||
for (i = 0; i < serial->num_ports; i++) {
|
||||
port_priv = usb_get_serial_port_data(serial->port[i]);
|
||||
kfree(port_priv);
|
||||
usb_set_serial_port_data(serial->port[i], NULL);
|
||||
}
|
||||
spriv = usb_get_serial_data(serial);
|
||||
kfree(spriv);
|
||||
}
|
||||
|
||||
module_usb_serial_driver(serial_drivers, id_table);
|
||||
|
@ -55,9 +55,9 @@
|
||||
#define CYBERJACK_PRODUCT_ID 0x0100
|
||||
|
||||
/* Function prototypes */
|
||||
static int cyberjack_startup(struct usb_serial *serial);
|
||||
static void cyberjack_disconnect(struct usb_serial *serial);
|
||||
static void cyberjack_release(struct usb_serial *serial);
|
||||
static int cyberjack_port_probe(struct usb_serial_port *port);
|
||||
static int cyberjack_port_remove(struct usb_serial_port *port);
|
||||
static int cyberjack_open(struct tty_struct *tty,
|
||||
struct usb_serial_port *port);
|
||||
static void cyberjack_close(struct usb_serial_port *port);
|
||||
@ -83,9 +83,9 @@ static struct usb_serial_driver cyberjack_device = {
|
||||
.description = "Reiner SCT Cyberjack USB card reader",
|
||||
.id_table = id_table,
|
||||
.num_ports = 1,
|
||||
.attach = cyberjack_startup,
|
||||
.disconnect = cyberjack_disconnect,
|
||||
.release = cyberjack_release,
|
||||
.port_probe = cyberjack_port_probe,
|
||||
.port_remove = cyberjack_port_remove,
|
||||
.open = cyberjack_open,
|
||||
.close = cyberjack_close,
|
||||
.write = cyberjack_write,
|
||||
@ -107,36 +107,35 @@ struct cyberjack_private {
|
||||
short wrsent; /* Data already sent */
|
||||
};
|
||||
|
||||
/* do some startup allocations not currently performed by usb_serial_probe() */
|
||||
static int cyberjack_startup(struct usb_serial *serial)
|
||||
static int cyberjack_port_probe(struct usb_serial_port *port)
|
||||
{
|
||||
struct cyberjack_private *priv;
|
||||
int i;
|
||||
int result;
|
||||
|
||||
/* allocate the private data structure */
|
||||
priv = kmalloc(sizeof(struct cyberjack_private), GFP_KERNEL);
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
/* set initial values */
|
||||
spin_lock_init(&priv->lock);
|
||||
priv->rdtodo = 0;
|
||||
priv->wrfilled = 0;
|
||||
priv->wrsent = 0;
|
||||
usb_set_serial_port_data(serial->port[0], priv);
|
||||
|
||||
init_waitqueue_head(&serial->port[0]->write_wait);
|
||||
usb_set_serial_port_data(port, priv);
|
||||
|
||||
for (i = 0; i < serial->num_ports; ++i) {
|
||||
int result;
|
||||
result = usb_submit_urb(serial->port[i]->interrupt_in_urb,
|
||||
GFP_KERNEL);
|
||||
if (result)
|
||||
dev_err(&serial->dev->dev,
|
||||
"usb_submit_urb(read int) failed\n");
|
||||
dev_dbg(&serial->dev->dev, "%s - usb_submit_urb(int urb)\n",
|
||||
__func__);
|
||||
}
|
||||
result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
|
||||
if (result)
|
||||
dev_err(&port->dev, "usb_submit_urb(read int) failed\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cyberjack_port_remove(struct usb_serial_port *port)
|
||||
{
|
||||
struct cyberjack_private *priv;
|
||||
|
||||
priv = usb_get_serial_port_data(port);
|
||||
kfree(priv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -149,16 +148,6 @@ static void cyberjack_disconnect(struct usb_serial *serial)
|
||||
usb_kill_urb(serial->port[i]->interrupt_in_urb);
|
||||
}
|
||||
|
||||
static void cyberjack_release(struct usb_serial *serial)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < serial->num_ports; ++i) {
|
||||
/* My special items, the standard routines free my urbs */
|
||||
kfree(usb_get_serial_port_data(serial->port[i]));
|
||||
}
|
||||
}
|
||||
|
||||
static int cyberjack_open(struct tty_struct *tty,
|
||||
struct usb_serial_port *port)
|
||||
{
|
||||
|
@ -123,10 +123,10 @@ struct cypress_private {
|
||||
};
|
||||
|
||||
/* function prototypes for the Cypress USB to serial device */
|
||||
static int cypress_earthmate_startup(struct usb_serial *serial);
|
||||
static int cypress_hidcom_startup(struct usb_serial *serial);
|
||||
static int cypress_ca42v2_startup(struct usb_serial *serial);
|
||||
static void cypress_release(struct usb_serial *serial);
|
||||
static int cypress_earthmate_port_probe(struct usb_serial_port *port);
|
||||
static int cypress_hidcom_port_probe(struct usb_serial_port *port);
|
||||
static int cypress_ca42v2_port_probe(struct usb_serial_port *port);
|
||||
static int cypress_port_remove(struct usb_serial_port *port);
|
||||
static int cypress_open(struct tty_struct *tty, struct usb_serial_port *port);
|
||||
static void cypress_close(struct usb_serial_port *port);
|
||||
static void cypress_dtr_rts(struct usb_serial_port *port, int on);
|
||||
@ -156,8 +156,8 @@ static struct usb_serial_driver cypress_earthmate_device = {
|
||||
.description = "DeLorme Earthmate USB",
|
||||
.id_table = id_table_earthmate,
|
||||
.num_ports = 1,
|
||||
.attach = cypress_earthmate_startup,
|
||||
.release = cypress_release,
|
||||
.port_probe = cypress_earthmate_port_probe,
|
||||
.port_remove = cypress_port_remove,
|
||||
.open = cypress_open,
|
||||
.close = cypress_close,
|
||||
.dtr_rts = cypress_dtr_rts,
|
||||
@ -182,8 +182,8 @@ static struct usb_serial_driver cypress_hidcom_device = {
|
||||
.description = "HID->COM RS232 Adapter",
|
||||
.id_table = id_table_cyphidcomrs232,
|
||||
.num_ports = 1,
|
||||
.attach = cypress_hidcom_startup,
|
||||
.release = cypress_release,
|
||||
.port_probe = cypress_hidcom_port_probe,
|
||||
.port_remove = cypress_port_remove,
|
||||
.open = cypress_open,
|
||||
.close = cypress_close,
|
||||
.dtr_rts = cypress_dtr_rts,
|
||||
@ -208,8 +208,8 @@ static struct usb_serial_driver cypress_ca42v2_device = {
|
||||
.description = "Nokia CA-42 V2 Adapter",
|
||||
.id_table = id_table_nokiaca42v2,
|
||||
.num_ports = 1,
|
||||
.attach = cypress_ca42v2_startup,
|
||||
.release = cypress_release,
|
||||
.port_probe = cypress_ca42v2_port_probe,
|
||||
.port_remove = cypress_port_remove,
|
||||
.open = cypress_open,
|
||||
.close = cypress_close,
|
||||
.dtr_rts = cypress_dtr_rts,
|
||||
@ -438,10 +438,10 @@ static void cypress_set_dead(struct usb_serial_port *port)
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
static int generic_startup(struct usb_serial *serial)
|
||||
static int cypress_generic_port_probe(struct usb_serial_port *port)
|
||||
{
|
||||
struct usb_serial *serial = port->serial;
|
||||
struct cypress_private *priv;
|
||||
struct usb_serial_port *port = serial->port[0];
|
||||
|
||||
priv = kzalloc(sizeof(struct cypress_private), GFP_KERNEL);
|
||||
if (!priv)
|
||||
@ -490,14 +490,16 @@ static int generic_startup(struct usb_serial *serial)
|
||||
}
|
||||
|
||||
|
||||
static int cypress_earthmate_startup(struct usb_serial *serial)
|
||||
static int cypress_earthmate_port_probe(struct usb_serial_port *port)
|
||||
{
|
||||
struct usb_serial *serial = port->serial;
|
||||
struct cypress_private *priv;
|
||||
struct usb_serial_port *port = serial->port[0];
|
||||
int ret;
|
||||
|
||||
if (generic_startup(serial)) {
|
||||
ret = cypress_generic_port_probe(port);
|
||||
if (ret) {
|
||||
dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__);
|
||||
return 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
priv = usb_get_serial_port_data(port);
|
||||
@ -518,57 +520,54 @@ static int cypress_earthmate_startup(struct usb_serial *serial)
|
||||
}
|
||||
|
||||
return 0;
|
||||
} /* cypress_earthmate_startup */
|
||||
}
|
||||
|
||||
|
||||
static int cypress_hidcom_startup(struct usb_serial *serial)
|
||||
static int cypress_hidcom_port_probe(struct usb_serial_port *port)
|
||||
{
|
||||
struct cypress_private *priv;
|
||||
struct usb_serial_port *port = serial->port[0];
|
||||
int ret;
|
||||
|
||||
if (generic_startup(serial)) {
|
||||
ret = cypress_generic_port_probe(port);
|
||||
if (ret) {
|
||||
dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__);
|
||||
return 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
priv = usb_get_serial_port_data(port);
|
||||
priv->chiptype = CT_CYPHIDCOM;
|
||||
|
||||
return 0;
|
||||
} /* cypress_hidcom_startup */
|
||||
}
|
||||
|
||||
|
||||
static int cypress_ca42v2_startup(struct usb_serial *serial)
|
||||
static int cypress_ca42v2_port_probe(struct usb_serial_port *port)
|
||||
{
|
||||
struct cypress_private *priv;
|
||||
struct usb_serial_port *port = serial->port[0];
|
||||
int ret;
|
||||
|
||||
if (generic_startup(serial)) {
|
||||
ret = cypress_generic_port_probe(port);
|
||||
if (ret) {
|
||||
dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__);
|
||||
return 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
priv = usb_get_serial_port_data(port);
|
||||
priv->chiptype = CT_CA42V2;
|
||||
|
||||
return 0;
|
||||
} /* cypress_ca42v2_startup */
|
||||
}
|
||||
|
||||
|
||||
static void cypress_release(struct usb_serial *serial)
|
||||
static int cypress_port_remove(struct usb_serial_port *port)
|
||||
{
|
||||
struct cypress_private *priv;
|
||||
|
||||
/* all open ports are closed at this point */
|
||||
priv = usb_get_serial_port_data(serial->port[0]);
|
||||
priv = usb_get_serial_port_data(port);
|
||||
|
||||
if (priv) {
|
||||
kfifo_free(&priv->write_fifo);
|
||||
kfree(priv);
|
||||
}
|
||||
kfifo_free(&priv->write_fifo);
|
||||
kfree(priv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int cypress_open(struct tty_struct *tty, struct usb_serial_port *port)
|
||||
{
|
||||
struct cypress_private *priv = usb_get_serial_port_data(port);
|
||||
|
@ -318,39 +318,30 @@ static int f81232_ioctl(struct tty_struct *tty,
|
||||
return -ENOIOCTLCMD;
|
||||
}
|
||||
|
||||
static int f81232_startup(struct usb_serial *serial)
|
||||
static int f81232_port_probe(struct usb_serial_port *port)
|
||||
{
|
||||
struct f81232_private *priv;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < serial->num_ports; ++i) {
|
||||
priv = kzalloc(sizeof(struct f81232_private), GFP_KERNEL);
|
||||
if (!priv)
|
||||
goto cleanup;
|
||||
spin_lock_init(&priv->lock);
|
||||
init_waitqueue_head(&priv->delta_msr_wait);
|
||||
usb_set_serial_port_data(serial->port[i], priv);
|
||||
}
|
||||
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
spin_lock_init(&priv->lock);
|
||||
init_waitqueue_head(&priv->delta_msr_wait);
|
||||
|
||||
usb_set_serial_port_data(port, priv);
|
||||
|
||||
return 0;
|
||||
|
||||
cleanup:
|
||||
for (--i; i >= 0; --i) {
|
||||
priv = usb_get_serial_port_data(serial->port[i]);
|
||||
kfree(priv);
|
||||
usb_set_serial_port_data(serial->port[i], NULL);
|
||||
}
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
static void f81232_release(struct usb_serial *serial)
|
||||
static int f81232_port_remove(struct usb_serial_port *port)
|
||||
{
|
||||
int i;
|
||||
struct f81232_private *priv;
|
||||
|
||||
for (i = 0; i < serial->num_ports; ++i) {
|
||||
priv = usb_get_serial_port_data(serial->port[i]);
|
||||
kfree(priv);
|
||||
}
|
||||
priv = usb_get_serial_port_data(port);
|
||||
kfree(priv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct usb_serial_driver f81232_device = {
|
||||
@ -373,8 +364,8 @@ static struct usb_serial_driver f81232_device = {
|
||||
.tiocmset = f81232_tiocmset,
|
||||
.process_read_urb = f81232_process_read_urb,
|
||||
.read_int_callback = f81232_read_int_callback,
|
||||
.attach = f81232_startup,
|
||||
.release = f81232_release,
|
||||
.port_probe = f81232_port_probe,
|
||||
.port_remove = f81232_port_remove,
|
||||
};
|
||||
|
||||
static struct usb_serial_driver * const serial_drivers[] = {
|
||||
|
@ -1405,11 +1405,10 @@ static void timeout_handler(unsigned long data)
|
||||
|
||||
|
||||
|
||||
static int garmin_attach(struct usb_serial *serial)
|
||||
static int garmin_port_probe(struct usb_serial_port *port)
|
||||
{
|
||||
int status = 0;
|
||||
struct usb_serial_port *port = serial->port[0];
|
||||
struct garmin_data *garmin_data_p = NULL;
|
||||
int status;
|
||||
struct garmin_data *garmin_data_p;
|
||||
|
||||
garmin_data_p = kzalloc(sizeof(struct garmin_data), GFP_KERNEL);
|
||||
if (garmin_data_p == NULL) {
|
||||
@ -1434,22 +1433,14 @@ static int garmin_attach(struct usb_serial *serial)
|
||||
}
|
||||
|
||||
|
||||
static void garmin_disconnect(struct usb_serial *serial)
|
||||
static int garmin_port_remove(struct usb_serial_port *port)
|
||||
{
|
||||
struct usb_serial_port *port = serial->port[0];
|
||||
struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
|
||||
|
||||
usb_kill_urb(port->interrupt_in_urb);
|
||||
del_timer_sync(&garmin_data_p->timer);
|
||||
}
|
||||
|
||||
|
||||
static void garmin_release(struct usb_serial *serial)
|
||||
{
|
||||
struct usb_serial_port *port = serial->port[0];
|
||||
struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
|
||||
|
||||
kfree(garmin_data_p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -1466,9 +1457,8 @@ static struct usb_serial_driver garmin_device = {
|
||||
.close = garmin_close,
|
||||
.throttle = garmin_throttle,
|
||||
.unthrottle = garmin_unthrottle,
|
||||
.attach = garmin_attach,
|
||||
.disconnect = garmin_disconnect,
|
||||
.release = garmin_release,
|
||||
.port_probe = garmin_port_probe,
|
||||
.port_remove = garmin_port_remove,
|
||||
.write = garmin_write,
|
||||
.write_room = garmin_write_room,
|
||||
.write_bulk_callback = garmin_write_bulk_callback,
|
||||
|
@ -225,6 +225,8 @@ static int edge_get_icount(struct tty_struct *tty,
|
||||
static int edge_startup(struct usb_serial *serial);
|
||||
static void edge_disconnect(struct usb_serial *serial);
|
||||
static void edge_release(struct usb_serial *serial);
|
||||
static int edge_port_probe(struct usb_serial_port *port);
|
||||
static int edge_port_remove(struct usb_serial_port *port);
|
||||
|
||||
#include "io_tables.h" /* all of the devices that this driver supports */
|
||||
|
||||
@ -2875,10 +2877,9 @@ static void load_application_firmware(struct edgeport_serial *edge_serial)
|
||||
static int edge_startup(struct usb_serial *serial)
|
||||
{
|
||||
struct edgeport_serial *edge_serial;
|
||||
struct edgeport_port *edge_port;
|
||||
struct usb_device *dev;
|
||||
struct device *ddev = &serial->dev->dev;
|
||||
int i, j;
|
||||
int i;
|
||||
int response;
|
||||
bool interrupt_in_found;
|
||||
bool bulk_in_found;
|
||||
@ -2961,25 +2962,6 @@ static int edge_startup(struct usb_serial *serial)
|
||||
/* we set up the pointers to the endpoints in the edge_open function,
|
||||
* as the structures aren't created yet. */
|
||||
|
||||
/* set up our port private structures */
|
||||
for (i = 0; i < serial->num_ports; ++i) {
|
||||
edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL);
|
||||
if (edge_port == NULL) {
|
||||
dev_err(ddev, "%s - Out of memory\n", __func__);
|
||||
for (j = 0; j < i; ++j) {
|
||||
kfree(usb_get_serial_port_data(serial->port[j]));
|
||||
usb_set_serial_port_data(serial->port[j],
|
||||
NULL);
|
||||
}
|
||||
usb_set_serial_data(serial, NULL);
|
||||
kfree(edge_serial);
|
||||
return -ENOMEM;
|
||||
}
|
||||
spin_lock_init(&edge_port->ep_lock);
|
||||
edge_port->port = serial->port[i];
|
||||
usb_set_serial_port_data(serial->port[i], edge_port);
|
||||
}
|
||||
|
||||
response = 0;
|
||||
|
||||
if (edge_serial->is_epic) {
|
||||
@ -3120,14 +3102,36 @@ static void edge_disconnect(struct usb_serial *serial)
|
||||
static void edge_release(struct usb_serial *serial)
|
||||
{
|
||||
struct edgeport_serial *edge_serial = usb_get_serial_data(serial);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < serial->num_ports; ++i)
|
||||
kfree(usb_get_serial_port_data(serial->port[i]));
|
||||
|
||||
kfree(edge_serial);
|
||||
}
|
||||
|
||||
static int edge_port_probe(struct usb_serial_port *port)
|
||||
{
|
||||
struct edgeport_port *edge_port;
|
||||
|
||||
edge_port = kzalloc(sizeof(*edge_port), GFP_KERNEL);
|
||||
if (!edge_port)
|
||||
return -ENOMEM;
|
||||
|
||||
spin_lock_init(&edge_port->ep_lock);
|
||||
edge_port->port = port;
|
||||
|
||||
usb_set_serial_port_data(port, edge_port);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int edge_port_remove(struct usb_serial_port *port)
|
||||
{
|
||||
struct edgeport_port *edge_port;
|
||||
|
||||
edge_port = usb_get_serial_port_data(port);
|
||||
kfree(edge_port);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
module_usb_serial_driver(serial_drivers, id_table_combined);
|
||||
|
||||
MODULE_AUTHOR(DRIVER_AUTHOR);
|
||||
|
@ -110,6 +110,8 @@ static struct usb_serial_driver edgeport_2port_device = {
|
||||
.attach = edge_startup,
|
||||
.disconnect = edge_disconnect,
|
||||
.release = edge_release,
|
||||
.port_probe = edge_port_probe,
|
||||
.port_remove = edge_port_remove,
|
||||
.ioctl = edge_ioctl,
|
||||
.set_termios = edge_set_termios,
|
||||
.tiocmget = edge_tiocmget,
|
||||
@ -139,6 +141,8 @@ static struct usb_serial_driver edgeport_4port_device = {
|
||||
.attach = edge_startup,
|
||||
.disconnect = edge_disconnect,
|
||||
.release = edge_release,
|
||||
.port_probe = edge_port_probe,
|
||||
.port_remove = edge_port_remove,
|
||||
.ioctl = edge_ioctl,
|
||||
.set_termios = edge_set_termios,
|
||||
.tiocmget = edge_tiocmget,
|
||||
@ -168,6 +172,8 @@ static struct usb_serial_driver edgeport_8port_device = {
|
||||
.attach = edge_startup,
|
||||
.disconnect = edge_disconnect,
|
||||
.release = edge_release,
|
||||
.port_probe = edge_port_probe,
|
||||
.port_remove = edge_port_remove,
|
||||
.ioctl = edge_ioctl,
|
||||
.set_termios = edge_set_termios,
|
||||
.tiocmget = edge_tiocmget,
|
||||
@ -197,6 +203,8 @@ static struct usb_serial_driver epic_device = {
|
||||
.attach = edge_startup,
|
||||
.disconnect = edge_disconnect,
|
||||
.release = edge_release,
|
||||
.port_probe = edge_port_probe,
|
||||
.port_remove = edge_port_remove,
|
||||
.ioctl = edge_ioctl,
|
||||
.set_termios = edge_set_termios,
|
||||
.tiocmget = edge_tiocmget,
|
||||
|
@ -2532,12 +2532,7 @@ static void edge_break(struct tty_struct *tty, int break_state)
|
||||
static int edge_startup(struct usb_serial *serial)
|
||||
{
|
||||
struct edgeport_serial *edge_serial;
|
||||
struct edgeport_port *edge_port;
|
||||
struct usb_device *dev;
|
||||
int status;
|
||||
int i;
|
||||
|
||||
dev = serial->dev;
|
||||
|
||||
/* create our private serial structure */
|
||||
edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL);
|
||||
@ -2555,40 +2550,7 @@ static int edge_startup(struct usb_serial *serial)
|
||||
return status;
|
||||
}
|
||||
|
||||
/* set up our port private structures */
|
||||
for (i = 0; i < serial->num_ports; ++i) {
|
||||
edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL);
|
||||
if (edge_port == NULL) {
|
||||
dev_err(&serial->dev->dev, "%s - Out of memory\n",
|
||||
__func__);
|
||||
goto cleanup;
|
||||
}
|
||||
spin_lock_init(&edge_port->ep_lock);
|
||||
if (kfifo_alloc(&edge_port->write_fifo, EDGE_OUT_BUF_SIZE,
|
||||
GFP_KERNEL)) {
|
||||
dev_err(&serial->dev->dev, "%s - Out of memory\n",
|
||||
__func__);
|
||||
kfree(edge_port);
|
||||
goto cleanup;
|
||||
}
|
||||
edge_port->port = serial->port[i];
|
||||
edge_port->edge_serial = edge_serial;
|
||||
usb_set_serial_port_data(serial->port[i], edge_port);
|
||||
edge_port->bUartMode = default_uart_mode;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
cleanup:
|
||||
for (--i; i >= 0; --i) {
|
||||
edge_port = usb_get_serial_port_data(serial->port[i]);
|
||||
kfifo_free(&edge_port->write_fifo);
|
||||
kfree(edge_port);
|
||||
usb_set_serial_port_data(serial->port[i], NULL);
|
||||
}
|
||||
kfree(edge_serial);
|
||||
usb_set_serial_data(serial, NULL);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
static void edge_disconnect(struct usb_serial *serial)
|
||||
@ -2597,17 +2559,54 @@ static void edge_disconnect(struct usb_serial *serial)
|
||||
|
||||
static void edge_release(struct usb_serial *serial)
|
||||
{
|
||||
int i;
|
||||
struct edgeport_port *edge_port;
|
||||
|
||||
for (i = 0; i < serial->num_ports; ++i) {
|
||||
edge_port = usb_get_serial_port_data(serial->port[i]);
|
||||
kfifo_free(&edge_port->write_fifo);
|
||||
kfree(edge_port);
|
||||
}
|
||||
kfree(usb_get_serial_data(serial));
|
||||
}
|
||||
|
||||
static int edge_port_probe(struct usb_serial_port *port)
|
||||
{
|
||||
struct edgeport_port *edge_port;
|
||||
int ret;
|
||||
|
||||
edge_port = kzalloc(sizeof(*edge_port), GFP_KERNEL);
|
||||
if (!edge_port)
|
||||
return -ENOMEM;
|
||||
|
||||
ret = kfifo_alloc(&edge_port->write_fifo, EDGE_OUT_BUF_SIZE,
|
||||
GFP_KERNEL);
|
||||
if (ret) {
|
||||
kfree(edge_port);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
spin_lock_init(&edge_port->ep_lock);
|
||||
edge_port->port = port;
|
||||
edge_port->edge_serial = usb_get_serial_data(port->serial);
|
||||
edge_port->bUartMode = default_uart_mode;
|
||||
|
||||
usb_set_serial_port_data(port, edge_port);
|
||||
|
||||
ret = edge_create_sysfs_attrs(port);
|
||||
if (ret) {
|
||||
kfifo_free(&edge_port->write_fifo);
|
||||
kfree(edge_port);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int edge_port_remove(struct usb_serial_port *port)
|
||||
{
|
||||
struct edgeport_port *edge_port;
|
||||
|
||||
edge_port = usb_get_serial_port_data(port);
|
||||
|
||||
edge_remove_sysfs_attrs(port);
|
||||
kfifo_free(&edge_port->write_fifo);
|
||||
kfree(edge_port);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Sysfs Attributes */
|
||||
|
||||
@ -2667,8 +2666,8 @@ static struct usb_serial_driver edgeport_1port_device = {
|
||||
.attach = edge_startup,
|
||||
.disconnect = edge_disconnect,
|
||||
.release = edge_release,
|
||||
.port_probe = edge_create_sysfs_attrs,
|
||||
.port_remove = edge_remove_sysfs_attrs,
|
||||
.port_probe = edge_port_probe,
|
||||
.port_remove = edge_port_remove,
|
||||
.ioctl = edge_ioctl,
|
||||
.set_termios = edge_set_termios,
|
||||
.tiocmget = edge_tiocmget,
|
||||
@ -2698,8 +2697,8 @@ static struct usb_serial_driver edgeport_2port_device = {
|
||||
.attach = edge_startup,
|
||||
.disconnect = edge_disconnect,
|
||||
.release = edge_release,
|
||||
.port_probe = edge_create_sysfs_attrs,
|
||||
.port_remove = edge_remove_sysfs_attrs,
|
||||
.port_probe = edge_port_probe,
|
||||
.port_remove = edge_port_remove,
|
||||
.ioctl = edge_ioctl,
|
||||
.set_termios = edge_set_termios,
|
||||
.tiocmget = edge_tiocmget,
|
||||
|
@ -53,6 +53,8 @@ static int iuu_cardout;
|
||||
static bool xmas;
|
||||
static int vcc_default = 5;
|
||||
|
||||
static int iuu_create_sysfs_attrs(struct usb_serial_port *port);
|
||||
static int iuu_remove_sysfs_attrs(struct usb_serial_port *port);
|
||||
static void read_rxcmd_callback(struct urb *urb);
|
||||
|
||||
struct iuu_private {
|
||||
@ -72,63 +74,55 @@ struct iuu_private {
|
||||
u32 clk;
|
||||
};
|
||||
|
||||
|
||||
static void iuu_free_buf(struct iuu_private *priv)
|
||||
{
|
||||
kfree(priv->buf);
|
||||
kfree(priv->writebuf);
|
||||
}
|
||||
|
||||
static int iuu_alloc_buf(struct usb_serial *serial, struct iuu_private *priv)
|
||||
{
|
||||
priv->buf = kzalloc(256, GFP_KERNEL);
|
||||
priv->writebuf = kzalloc(256, GFP_KERNEL);
|
||||
if (!priv->buf || !priv->writebuf) {
|
||||
iuu_free_buf(priv);
|
||||
dev_dbg(&serial->dev->dev, "%s problem allocation buffer\n", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
dev_dbg(&serial->dev->dev, "%s - Privates buffers allocation success\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int iuu_startup(struct usb_serial *serial)
|
||||
static int iuu_port_probe(struct usb_serial_port *port)
|
||||
{
|
||||
struct iuu_private *priv;
|
||||
int ret;
|
||||
|
||||
priv = kzalloc(sizeof(struct iuu_private), GFP_KERNEL);
|
||||
dev_dbg(&serial->dev->dev, "%s- priv allocation success\n", __func__);
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
if (iuu_alloc_buf(serial, priv)) {
|
||||
|
||||
priv->buf = kzalloc(256, GFP_KERNEL);
|
||||
if (!priv->buf) {
|
||||
kfree(priv);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
priv->writebuf = kzalloc(256, GFP_KERNEL);
|
||||
if (!priv->writebuf) {
|
||||
kfree(priv->buf);
|
||||
kfree(priv);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
priv->vcc = vcc_default;
|
||||
spin_lock_init(&priv->lock);
|
||||
init_waitqueue_head(&priv->delta_msr_wait);
|
||||
usb_set_serial_port_data(serial->port[0], priv);
|
||||
|
||||
usb_set_serial_port_data(port, priv);
|
||||
|
||||
ret = iuu_create_sysfs_attrs(port);
|
||||
if (ret) {
|
||||
kfree(priv->writebuf);
|
||||
kfree(priv->buf);
|
||||
kfree(priv);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Release function */
|
||||
static void iuu_release(struct usb_serial *serial)
|
||||
static int iuu_port_remove(struct usb_serial_port *port)
|
||||
{
|
||||
struct usb_serial_port *port = serial->port[0];
|
||||
struct iuu_private *priv = usb_get_serial_port_data(port);
|
||||
if (!port)
|
||||
return;
|
||||
|
||||
if (priv) {
|
||||
iuu_free_buf(priv);
|
||||
dev_dbg(&port->dev, "%s - I will free all\n", __func__);
|
||||
usb_set_serial_port_data(port, NULL);
|
||||
iuu_remove_sysfs_attrs(port);
|
||||
kfree(priv->writebuf);
|
||||
kfree(priv->buf);
|
||||
kfree(priv);
|
||||
|
||||
dev_dbg(&port->dev, "%s - priv is not anymore in port structure\n", __func__);
|
||||
kfree(priv);
|
||||
|
||||
dev_dbg(&port->dev, "%s priv is now kfree\n", __func__);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int iuu_tiocmset(struct tty_struct *tty,
|
||||
@ -1215,8 +1209,6 @@ static struct usb_serial_driver iuu_device = {
|
||||
.num_ports = 1,
|
||||
.bulk_in_size = 512,
|
||||
.bulk_out_size = 512,
|
||||
.port_probe = iuu_create_sysfs_attrs,
|
||||
.port_remove = iuu_remove_sysfs_attrs,
|
||||
.open = iuu_open,
|
||||
.close = iuu_close,
|
||||
.write = iuu_uart_write,
|
||||
@ -1225,8 +1217,8 @@ static struct usb_serial_driver iuu_device = {
|
||||
.tiocmset = iuu_tiocmset,
|
||||
.set_termios = iuu_set_termios,
|
||||
.init_termios = iuu_init_termios,
|
||||
.attach = iuu_startup,
|
||||
.release = iuu_release,
|
||||
.port_probe = iuu_port_probe,
|
||||
.port_remove = iuu_port_remove,
|
||||
};
|
||||
|
||||
static struct usb_serial_driver * const serial_drivers[] = {
|
||||
|
@ -713,29 +713,33 @@ MODULE_FIRMWARE("keyspan_pda/keyspan_pda.fw");
|
||||
MODULE_FIRMWARE("keyspan_pda/xircom_pgs.fw");
|
||||
#endif
|
||||
|
||||
static int keyspan_pda_startup(struct usb_serial *serial)
|
||||
static int keyspan_pda_port_probe(struct usb_serial_port *port)
|
||||
{
|
||||
|
||||
struct keyspan_pda_private *priv;
|
||||
|
||||
/* allocate the private data structures for all ports. Well, for all
|
||||
one ports. */
|
||||
|
||||
priv = kmalloc(sizeof(struct keyspan_pda_private), GFP_KERNEL);
|
||||
if (!priv)
|
||||
return 1; /* error */
|
||||
usb_set_serial_port_data(serial->port[0], priv);
|
||||
init_waitqueue_head(&serial->port[0]->write_wait);
|
||||
return -ENOMEM;
|
||||
|
||||
INIT_WORK(&priv->wakeup_work, keyspan_pda_wakeup_write);
|
||||
INIT_WORK(&priv->unthrottle_work, keyspan_pda_request_unthrottle);
|
||||
priv->serial = serial;
|
||||
priv->port = serial->port[0];
|
||||
priv->serial = port->serial;
|
||||
priv->port = port;
|
||||
|
||||
usb_set_serial_port_data(port, priv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void keyspan_pda_release(struct usb_serial *serial)
|
||||
static int keyspan_pda_port_remove(struct usb_serial_port *port)
|
||||
{
|
||||
kfree(usb_get_serial_port_data(serial->port[0]));
|
||||
struct keyspan_pda_private *priv;
|
||||
|
||||
priv = usb_get_serial_port_data(port);
|
||||
kfree(priv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef KEYSPAN
|
||||
@ -786,8 +790,8 @@ static struct usb_serial_driver keyspan_pda_device = {
|
||||
.break_ctl = keyspan_pda_break_ctl,
|
||||
.tiocmget = keyspan_pda_tiocmget,
|
||||
.tiocmset = keyspan_pda_tiocmset,
|
||||
.attach = keyspan_pda_startup,
|
||||
.release = keyspan_pda_release,
|
||||
.port_probe = keyspan_pda_port_probe,
|
||||
.port_remove = keyspan_pda_port_remove,
|
||||
};
|
||||
|
||||
static struct usb_serial_driver * const serial_drivers[] = {
|
||||
|
@ -60,8 +60,8 @@
|
||||
/*
|
||||
* Function prototypes
|
||||
*/
|
||||
static int klsi_105_startup(struct usb_serial *serial);
|
||||
static void klsi_105_release(struct usb_serial *serial);
|
||||
static int klsi_105_port_probe(struct usb_serial_port *port);
|
||||
static int klsi_105_port_remove(struct usb_serial_port *port);
|
||||
static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port);
|
||||
static void klsi_105_close(struct usb_serial_port *port);
|
||||
static void klsi_105_set_termios(struct tty_struct *tty,
|
||||
@ -99,8 +99,8 @@ static struct usb_serial_driver kl5kusb105d_device = {
|
||||
/*.break_ctl = klsi_105_break_ctl,*/
|
||||
.tiocmget = klsi_105_tiocmget,
|
||||
.tiocmset = klsi_105_tiocmset,
|
||||
.attach = klsi_105_startup,
|
||||
.release = klsi_105_release,
|
||||
.port_probe = klsi_105_port_probe,
|
||||
.port_remove = klsi_105_port_remove,
|
||||
.throttle = usb_serial_generic_throttle,
|
||||
.unthrottle = usb_serial_generic_unthrottle,
|
||||
.process_read_urb = klsi_105_process_read_urb,
|
||||
@ -223,60 +223,40 @@ static int klsi_105_get_line_state(struct usb_serial_port *port,
|
||||
* Driver's tty interface functions
|
||||
*/
|
||||
|
||||
static int klsi_105_startup(struct usb_serial *serial)
|
||||
static int klsi_105_port_probe(struct usb_serial_port *port)
|
||||
{
|
||||
struct klsi_105_private *priv;
|
||||
int i;
|
||||
|
||||
/* check if we support the product id (see keyspan.c)
|
||||
* FIXME
|
||||
*/
|
||||
priv = kmalloc(sizeof(*priv), GFP_KERNEL);
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
/* allocate the private data structure */
|
||||
for (i = 0; i < serial->num_ports; i++) {
|
||||
priv = kmalloc(sizeof(struct klsi_105_private),
|
||||
GFP_KERNEL);
|
||||
if (!priv) {
|
||||
dev_dbg(&serial->interface->dev,
|
||||
"%s - kmalloc for klsi_105_private failed.\n",
|
||||
__func__);
|
||||
i--;
|
||||
goto err_cleanup;
|
||||
}
|
||||
/* set initial values for control structures */
|
||||
priv->cfg.pktlen = 5;
|
||||
priv->cfg.baudrate = kl5kusb105a_sio_b9600;
|
||||
priv->cfg.databits = kl5kusb105a_dtb_8;
|
||||
priv->cfg.unknown1 = 0;
|
||||
priv->cfg.unknown2 = 1;
|
||||
/* set initial values for control structures */
|
||||
priv->cfg.pktlen = 5;
|
||||
priv->cfg.baudrate = kl5kusb105a_sio_b9600;
|
||||
priv->cfg.databits = kl5kusb105a_dtb_8;
|
||||
priv->cfg.unknown1 = 0;
|
||||
priv->cfg.unknown2 = 1;
|
||||
|
||||
priv->line_state = 0;
|
||||
priv->line_state = 0;
|
||||
|
||||
usb_set_serial_port_data(serial->port[i], priv);
|
||||
spin_lock_init(&priv->lock);
|
||||
|
||||
spin_lock_init(&priv->lock);
|
||||
/* priv->termios is left uninitialized until port opening */
|
||||
|
||||
/* priv->termios is left uninitialized until port opening */
|
||||
init_waitqueue_head(&serial->port[i]->write_wait);
|
||||
}
|
||||
usb_set_serial_port_data(port, priv);
|
||||
|
||||
return 0;
|
||||
|
||||
err_cleanup:
|
||||
for (; i >= 0; i--) {
|
||||
priv = usb_get_serial_port_data(serial->port[i]);
|
||||
kfree(priv);
|
||||
usb_set_serial_port_data(serial->port[i], NULL);
|
||||
}
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
static void klsi_105_release(struct usb_serial *serial)
|
||||
static int klsi_105_port_remove(struct usb_serial_port *port)
|
||||
{
|
||||
int i;
|
||||
struct klsi_105_private *priv;
|
||||
|
||||
for (i = 0; i < serial->num_ports; ++i)
|
||||
kfree(usb_get_serial_port_data(serial->port[i]));
|
||||
priv = usb_get_serial_port_data(port);
|
||||
kfree(priv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port)
|
||||
|
@ -54,8 +54,8 @@
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
static int kobil_startup(struct usb_serial *serial);
|
||||
static void kobil_release(struct usb_serial *serial);
|
||||
static int kobil_port_probe(struct usb_serial_port *probe);
|
||||
static int kobil_port_remove(struct usb_serial_port *probe);
|
||||
static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port);
|
||||
static void kobil_close(struct usb_serial_port *port);
|
||||
static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port,
|
||||
@ -89,8 +89,8 @@ static struct usb_serial_driver kobil_device = {
|
||||
.description = "KOBIL USB smart card terminal",
|
||||
.id_table = id_table,
|
||||
.num_ports = 1,
|
||||
.attach = kobil_startup,
|
||||
.release = kobil_release,
|
||||
.port_probe = kobil_port_probe,
|
||||
.port_remove = kobil_port_remove,
|
||||
.ioctl = kobil_ioctl,
|
||||
.set_termios = kobil_set_termios,
|
||||
.init_termios = kobil_init_termios,
|
||||
@ -117,9 +117,10 @@ struct kobil_private {
|
||||
};
|
||||
|
||||
|
||||
static int kobil_startup(struct usb_serial *serial)
|
||||
static int kobil_port_probe(struct usb_serial_port *port)
|
||||
{
|
||||
int i;
|
||||
struct usb_serial *serial = port->serial;
|
||||
struct kobil_private *priv;
|
||||
struct usb_device *pdev;
|
||||
struct usb_host_config *actconfig;
|
||||
@ -149,7 +150,7 @@ static int kobil_startup(struct usb_serial *serial)
|
||||
dev_dbg(&serial->dev->dev, "KOBIL KAAN SIM detected\n");
|
||||
break;
|
||||
}
|
||||
usb_set_serial_port_data(serial->port[0], priv);
|
||||
usb_set_serial_port_data(port, priv);
|
||||
|
||||
/* search for the necessary endpoints */
|
||||
pdev = serial->dev;
|
||||
@ -179,12 +180,14 @@ static int kobil_startup(struct usb_serial *serial)
|
||||
}
|
||||
|
||||
|
||||
static void kobil_release(struct usb_serial *serial)
|
||||
static int kobil_port_remove(struct usb_serial_port *port)
|
||||
{
|
||||
int i;
|
||||
struct kobil_private *priv;
|
||||
|
||||
for (i = 0; i < serial->num_ports; ++i)
|
||||
kfree(usb_get_serial_port_data(serial->port[i]));
|
||||
priv = usb_get_serial_port_data(port);
|
||||
kfree(priv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void kobil_init_termios(struct tty_struct *tty)
|
||||
|
@ -503,11 +503,19 @@ static const struct option_blacklist_info net_intf5_blacklist = {
|
||||
.reserved = BIT(5),
|
||||
};
|
||||
|
||||
static const struct option_blacklist_info net_intf6_blacklist = {
|
||||
.reserved = BIT(6),
|
||||
};
|
||||
|
||||
static const struct option_blacklist_info zte_mf626_blacklist = {
|
||||
.sendsetup = BIT(0) | BIT(1),
|
||||
.reserved = BIT(4),
|
||||
};
|
||||
|
||||
static const struct option_blacklist_info zte_1255_blacklist = {
|
||||
.reserved = BIT(3) | BIT(4),
|
||||
};
|
||||
|
||||
static const struct usb_device_id option_ids[] = {
|
||||
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
|
||||
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
|
||||
@ -853,13 +861,19 @@ static const struct usb_device_id option_ids[] = {
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0113, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf5_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0117, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0118, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0121, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0118, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf5_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0121, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf5_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0122, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0123, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0124, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0125, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0126, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0123, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf4_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0124, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf5_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0125, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf6_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0126, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf5_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0128, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0142, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0143, 0xff, 0xff, 0xff) },
|
||||
@ -872,7 +886,8 @@ static const struct usb_device_id option_ids[] = {
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0156, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0157, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf5_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0158, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0158, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf3_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0159, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0161, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0162, 0xff, 0xff, 0xff) },
|
||||
@ -880,13 +895,22 @@ static const struct usb_device_id option_ids[] = {
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf4_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0191, 0xff, 0xff, 0xff), /* ZTE EuFi890 */
|
||||
.driver_info = (kernel_ulong_t)&net_intf4_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0199, 0xff, 0xff, 0xff), /* ZTE MF820S */
|
||||
.driver_info = (kernel_ulong_t)&net_intf1_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0257, 0xff, 0xff, 0xff), /* ZTE MF821 */
|
||||
.driver_info = (kernel_ulong_t)&net_intf3_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0326, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf4_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf4_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf4_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf4_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1021, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf2_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1057, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1058, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1059, 0xff, 0xff, 0xff) },
|
||||
@ -1002,18 +1026,24 @@ static const struct usb_device_id option_ids[] = {
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1169, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1170, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1244, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1245, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1245, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf4_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1246, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1247, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1247, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf4_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1248, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1249, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1250, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1251, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1252, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1252, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf4_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1253, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1254, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1255, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1256, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1254, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf4_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1255, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&zte_1255_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1256, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf4_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1257, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1258, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1259, 0xff, 0xff, 0xff) },
|
||||
@ -1058,8 +1088,16 @@ static const struct usb_device_id option_ids[] = {
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1298, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1299, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1300, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1401, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf2_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1402, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf2_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1424, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf2_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1425, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf2_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1426, 0xff, 0xff, 0xff), /* ZTE MF91 */
|
||||
.driver_info = (kernel_ulong_t)&net_intf2_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2002, 0xff,
|
||||
0xff, 0xff), .driver_info = (kernel_ulong_t)&zte_k3765_z_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2003, 0xff, 0xff, 0xff) },
|
||||
@ -1071,15 +1109,21 @@ static const struct usb_device_id option_ids[] = {
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0070, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0073, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0094, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0130, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0133, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0141, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0130, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf1_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0133, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf3_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0141, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf5_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0147, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0152, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0168, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0168, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf4_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0170, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0176, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0178, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0176, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf3_blacklist },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0178, 0xff, 0xff, 0xff),
|
||||
.driver_info = (kernel_ulong_t)&net_intf3_blacklist },
|
||||
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH, 0xff, 0xff, 0xff) },
|
||||
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710, 0xff, 0xff, 0xff) },
|
||||
|
@ -137,8 +137,8 @@ static int oti6858_chars_in_buffer(struct tty_struct *tty);
|
||||
static int oti6858_tiocmget(struct tty_struct *tty);
|
||||
static int oti6858_tiocmset(struct tty_struct *tty,
|
||||
unsigned int set, unsigned int clear);
|
||||
static int oti6858_startup(struct usb_serial *serial);
|
||||
static void oti6858_release(struct usb_serial *serial);
|
||||
static int oti6858_port_probe(struct usb_serial_port *port);
|
||||
static int oti6858_port_remove(struct usb_serial_port *port);
|
||||
|
||||
/* device info */
|
||||
static struct usb_serial_driver oti6858_device = {
|
||||
@ -161,8 +161,8 @@ static struct usb_serial_driver oti6858_device = {
|
||||
.write_bulk_callback = oti6858_write_bulk_callback,
|
||||
.write_room = oti6858_write_room,
|
||||
.chars_in_buffer = oti6858_chars_in_buffer,
|
||||
.attach = oti6858_startup,
|
||||
.release = oti6858_release,
|
||||
.port_probe = oti6858_port_probe,
|
||||
.port_remove = oti6858_port_remove,
|
||||
};
|
||||
|
||||
static struct usb_serial_driver * const serial_drivers[] = {
|
||||
@ -331,36 +331,33 @@ static void send_data(struct work_struct *work)
|
||||
usb_serial_port_softint(port);
|
||||
}
|
||||
|
||||
static int oti6858_startup(struct usb_serial *serial)
|
||||
static int oti6858_port_probe(struct usb_serial_port *port)
|
||||
{
|
||||
struct usb_serial_port *port = serial->port[0];
|
||||
struct oti6858_private *priv;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < serial->num_ports; ++i) {
|
||||
priv = kzalloc(sizeof(struct oti6858_private), GFP_KERNEL);
|
||||
if (!priv)
|
||||
break;
|
||||
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
spin_lock_init(&priv->lock);
|
||||
init_waitqueue_head(&priv->intr_wait);
|
||||
/* INIT_WORK(&priv->setup_work, setup_line, serial->port[i]); */
|
||||
/* INIT_WORK(&priv->write_work, send_data, serial->port[i]); */
|
||||
priv->port = port;
|
||||
INIT_DELAYED_WORK(&priv->delayed_setup_work, setup_line);
|
||||
INIT_DELAYED_WORK(&priv->delayed_write_work, send_data);
|
||||
spin_lock_init(&priv->lock);
|
||||
init_waitqueue_head(&priv->intr_wait);
|
||||
priv->port = port;
|
||||
INIT_DELAYED_WORK(&priv->delayed_setup_work, setup_line);
|
||||
INIT_DELAYED_WORK(&priv->delayed_write_work, send_data);
|
||||
|
||||
usb_set_serial_port_data(serial->port[i], priv);
|
||||
}
|
||||
if (i == serial->num_ports)
|
||||
return 0;
|
||||
usb_set_serial_port_data(port, priv);
|
||||
|
||||
for (--i; i >= 0; --i) {
|
||||
priv = usb_get_serial_port_data(serial->port[i]);
|
||||
kfree(priv);
|
||||
usb_set_serial_port_data(serial->port[i], NULL);
|
||||
}
|
||||
return -ENOMEM;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int oti6858_port_remove(struct usb_serial_port *port)
|
||||
{
|
||||
struct oti6858_private *priv;
|
||||
|
||||
priv = usb_get_serial_port_data(port);
|
||||
kfree(priv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int oti6858_write(struct tty_struct *tty, struct usb_serial_port *port,
|
||||
@ -709,15 +706,6 @@ static int oti6858_ioctl(struct tty_struct *tty,
|
||||
return -ENOIOCTLCMD;
|
||||
}
|
||||
|
||||
|
||||
static void oti6858_release(struct usb_serial *serial)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < serial->num_ports; ++i)
|
||||
kfree(usb_get_serial_port_data(serial->port[i]));
|
||||
}
|
||||
|
||||
static void oti6858_read_int_callback(struct urb *urb)
|
||||
{
|
||||
struct usb_serial_port *port = urb->context;
|
||||
|
@ -133,12 +133,15 @@ enum pl2303_type {
|
||||
HX, /* HX version of the pl2303 chip */
|
||||
};
|
||||
|
||||
struct pl2303_serial_private {
|
||||
enum pl2303_type type;
|
||||
};
|
||||
|
||||
struct pl2303_private {
|
||||
spinlock_t lock;
|
||||
wait_queue_head_t delta_msr_wait;
|
||||
u8 line_control;
|
||||
u8 line_status;
|
||||
enum pl2303_type type;
|
||||
};
|
||||
|
||||
static int pl2303_vendor_read(__u16 value, __u16 index,
|
||||
@ -167,14 +170,19 @@ static int pl2303_vendor_write(__u16 value, __u16 index,
|
||||
|
||||
static int pl2303_startup(struct usb_serial *serial)
|
||||
{
|
||||
struct pl2303_private *priv;
|
||||
struct pl2303_serial_private *spriv;
|
||||
enum pl2303_type type = type_0;
|
||||
unsigned char *buf;
|
||||
int i;
|
||||
|
||||
spriv = kzalloc(sizeof(*spriv), GFP_KERNEL);
|
||||
if (!spriv)
|
||||
return -ENOMEM;
|
||||
|
||||
buf = kmalloc(10, GFP_KERNEL);
|
||||
if (buf == NULL)
|
||||
if (!buf) {
|
||||
kfree(spriv);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (serial->dev->descriptor.bDeviceClass == 0x02)
|
||||
type = type_0;
|
||||
@ -186,15 +194,8 @@ static int pl2303_startup(struct usb_serial *serial)
|
||||
type = type_1;
|
||||
dev_dbg(&serial->interface->dev, "device type: %d\n", type);
|
||||
|
||||
for (i = 0; i < serial->num_ports; ++i) {
|
||||
priv = kzalloc(sizeof(struct pl2303_private), GFP_KERNEL);
|
||||
if (!priv)
|
||||
goto cleanup;
|
||||
spin_lock_init(&priv->lock);
|
||||
init_waitqueue_head(&priv->delta_msr_wait);
|
||||
priv->type = type;
|
||||
usb_set_serial_port_data(serial->port[i], priv);
|
||||
}
|
||||
spriv->type = type;
|
||||
usb_set_serial_data(serial, spriv);
|
||||
|
||||
pl2303_vendor_read(0x8484, 0, serial, buf);
|
||||
pl2303_vendor_write(0x0404, 0, serial);
|
||||
@ -213,15 +214,40 @@ static int pl2303_startup(struct usb_serial *serial)
|
||||
|
||||
kfree(buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
kfree(buf);
|
||||
for (--i; i >= 0; --i) {
|
||||
priv = usb_get_serial_port_data(serial->port[i]);
|
||||
kfree(priv);
|
||||
usb_set_serial_port_data(serial->port[i], NULL);
|
||||
}
|
||||
return -ENOMEM;
|
||||
static void pl2303_release(struct usb_serial *serial)
|
||||
{
|
||||
struct pl2303_serial_private *spriv;
|
||||
|
||||
spriv = usb_get_serial_data(serial);
|
||||
kfree(spriv);
|
||||
}
|
||||
|
||||
static int pl2303_port_probe(struct usb_serial_port *port)
|
||||
{
|
||||
struct pl2303_private *priv;
|
||||
|
||||
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
spin_lock_init(&priv->lock);
|
||||
init_waitqueue_head(&priv->delta_msr_wait);
|
||||
|
||||
usb_set_serial_port_data(port, priv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pl2303_port_remove(struct usb_serial_port *port)
|
||||
{
|
||||
struct pl2303_private *priv;
|
||||
|
||||
priv = usb_get_serial_port_data(port);
|
||||
kfree(priv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_control_lines(struct usb_device *dev, u8 value)
|
||||
@ -240,6 +266,7 @@ static void pl2303_set_termios(struct tty_struct *tty,
|
||||
struct usb_serial_port *port, struct ktermios *old_termios)
|
||||
{
|
||||
struct usb_serial *serial = port->serial;
|
||||
struct pl2303_serial_private *spriv = usb_get_serial_data(serial);
|
||||
struct pl2303_private *priv = usb_get_serial_port_data(port);
|
||||
unsigned long flags;
|
||||
unsigned int cflag;
|
||||
@ -323,7 +350,7 @@ static void pl2303_set_termios(struct tty_struct *tty,
|
||||
}
|
||||
if (baud > 1228800) {
|
||||
/* type_0, type_1 only support up to 1228800 baud */
|
||||
if (priv->type != HX)
|
||||
if (spriv->type != HX)
|
||||
baud = 1228800;
|
||||
else if (baud > 6000000)
|
||||
baud = 6000000;
|
||||
@ -426,7 +453,7 @@ static void pl2303_set_termios(struct tty_struct *tty,
|
||||
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]);
|
||||
|
||||
if (cflag & CRTSCTS) {
|
||||
if (priv->type == HX)
|
||||
if (spriv->type == HX)
|
||||
pl2303_vendor_write(0x0, 0x61, serial);
|
||||
else
|
||||
pl2303_vendor_write(0x0, 0x41, serial);
|
||||
@ -468,10 +495,10 @@ static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port)
|
||||
{
|
||||
struct ktermios tmp_termios;
|
||||
struct usb_serial *serial = port->serial;
|
||||
struct pl2303_private *priv = usb_get_serial_port_data(port);
|
||||
struct pl2303_serial_private *spriv = usb_get_serial_data(serial);
|
||||
int result;
|
||||
|
||||
if (priv->type != HX) {
|
||||
if (spriv->type != HX) {
|
||||
usb_clear_halt(serial->dev, port->write_urb->pipe);
|
||||
usb_clear_halt(serial->dev, port->read_urb->pipe);
|
||||
} else {
|
||||
@ -655,17 +682,6 @@ static void pl2303_break_ctl(struct tty_struct *tty, int break_state)
|
||||
dev_err(&port->dev, "error sending break = %d\n", result);
|
||||
}
|
||||
|
||||
static void pl2303_release(struct usb_serial *serial)
|
||||
{
|
||||
int i;
|
||||
struct pl2303_private *priv;
|
||||
|
||||
for (i = 0; i < serial->num_ports; ++i) {
|
||||
priv = usb_get_serial_port_data(serial->port[i]);
|
||||
kfree(priv);
|
||||
}
|
||||
}
|
||||
|
||||
static void pl2303_update_line_status(struct usb_serial_port *port,
|
||||
unsigned char *data,
|
||||
unsigned int actual_length)
|
||||
@ -827,6 +843,8 @@ static struct usb_serial_driver pl2303_device = {
|
||||
.read_int_callback = pl2303_read_int_callback,
|
||||
.attach = pl2303_startup,
|
||||
.release = pl2303_release,
|
||||
.port_probe = pl2303_port_probe,
|
||||
.port_remove = pl2303_port_remove,
|
||||
};
|
||||
|
||||
static struct usb_serial_driver * const serial_drivers[] = {
|
||||
|
@ -157,13 +157,10 @@ struct spcp8x5_private {
|
||||
u8 line_status;
|
||||
};
|
||||
|
||||
/* desc : when device plug in,this function would be called.
|
||||
* thanks to usb_serial subsystem,then do almost every things for us. And what
|
||||
* we should do just alloc the buffer */
|
||||
static int spcp8x5_startup(struct usb_serial *serial)
|
||||
static int spcp8x5_port_probe(struct usb_serial_port *port)
|
||||
{
|
||||
struct usb_serial *serial = port->serial;
|
||||
struct spcp8x5_private *priv;
|
||||
int i;
|
||||
enum spcp8x5_type type = SPCP825_007_TYPE;
|
||||
u16 product = le16_to_cpu(serial->dev->descriptor.idProduct);
|
||||
|
||||
@ -180,34 +177,27 @@ static int spcp8x5_startup(struct usb_serial *serial)
|
||||
type = SPCP825_PHILIP_TYPE;
|
||||
dev_dbg(&serial->dev->dev, "device type = %d\n", (int)type);
|
||||
|
||||
for (i = 0; i < serial->num_ports; ++i) {
|
||||
priv = kzalloc(sizeof(struct spcp8x5_private), GFP_KERNEL);
|
||||
if (!priv)
|
||||
goto cleanup;
|
||||
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
spin_lock_init(&priv->lock);
|
||||
init_waitqueue_head(&priv->delta_msr_wait);
|
||||
priv->type = type;
|
||||
usb_set_serial_port_data(serial->port[i] , priv);
|
||||
}
|
||||
spin_lock_init(&priv->lock);
|
||||
init_waitqueue_head(&priv->delta_msr_wait);
|
||||
priv->type = type;
|
||||
|
||||
usb_set_serial_port_data(port , priv);
|
||||
|
||||
return 0;
|
||||
cleanup:
|
||||
for (--i; i >= 0; --i) {
|
||||
priv = usb_get_serial_port_data(serial->port[i]);
|
||||
kfree(priv);
|
||||
usb_set_serial_port_data(serial->port[i] , NULL);
|
||||
}
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* call when the device plug out. free all the memory alloced by probe */
|
||||
static void spcp8x5_release(struct usb_serial *serial)
|
||||
static int spcp8x5_port_remove(struct usb_serial_port *port)
|
||||
{
|
||||
int i;
|
||||
struct spcp8x5_private *priv;
|
||||
|
||||
for (i = 0; i < serial->num_ports; i++)
|
||||
kfree(usb_get_serial_port_data(serial->port[i]));
|
||||
priv = usb_get_serial_port_data(port);
|
||||
kfree(priv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* set the modem control line of the device.
|
||||
@ -649,8 +639,8 @@ static struct usb_serial_driver spcp8x5_device = {
|
||||
.ioctl = spcp8x5_ioctl,
|
||||
.tiocmget = spcp8x5_tiocmget,
|
||||
.tiocmset = spcp8x5_tiocmset,
|
||||
.attach = spcp8x5_startup,
|
||||
.release = spcp8x5_release,
|
||||
.port_probe = spcp8x5_port_probe,
|
||||
.port_remove = spcp8x5_port_remove,
|
||||
.process_read_urb = spcp8x5_process_read_urb,
|
||||
};
|
||||
|
||||
|
@ -67,13 +67,6 @@ struct ssu100_port_private {
|
||||
struct async_icount icount;
|
||||
};
|
||||
|
||||
static void ssu100_release(struct usb_serial *serial)
|
||||
{
|
||||
struct ssu100_port_private *priv = usb_get_serial_port_data(*serial->port);
|
||||
|
||||
kfree(priv);
|
||||
}
|
||||
|
||||
static inline int ssu100_control_msg(struct usb_device *dev,
|
||||
u8 request, u16 data, u16 index)
|
||||
{
|
||||
@ -441,22 +434,34 @@ static int ssu100_ioctl(struct tty_struct *tty,
|
||||
}
|
||||
|
||||
static int ssu100_attach(struct usb_serial *serial)
|
||||
{
|
||||
return ssu100_initdevice(serial->dev);
|
||||
}
|
||||
|
||||
static int ssu100_port_probe(struct usb_serial_port *port)
|
||||
{
|
||||
struct ssu100_port_private *priv;
|
||||
struct usb_serial_port *port = *serial->port;
|
||||
|
||||
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
|
||||
if (!priv) {
|
||||
dev_err(&port->dev, "%s- kmalloc(%Zd) failed.\n", __func__,
|
||||
sizeof(*priv));
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
spin_lock_init(&priv->status_lock);
|
||||
init_waitqueue_head(&priv->delta_msr_wait);
|
||||
|
||||
usb_set_serial_port_data(port, priv);
|
||||
|
||||
return ssu100_initdevice(serial->dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ssu100_port_remove(struct usb_serial_port *port)
|
||||
{
|
||||
struct ssu100_port_private *priv;
|
||||
|
||||
priv = usb_get_serial_port_data(port);
|
||||
kfree(priv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ssu100_tiocmget(struct tty_struct *tty)
|
||||
@ -647,7 +652,8 @@ static struct usb_serial_driver ssu100_device = {
|
||||
.open = ssu100_open,
|
||||
.close = ssu100_close,
|
||||
.attach = ssu100_attach,
|
||||
.release = ssu100_release,
|
||||
.port_probe = ssu100_port_probe,
|
||||
.port_remove = ssu100_port_remove,
|
||||
.dtr_rts = ssu100_dtr_rts,
|
||||
.process_read_urb = ssu100_process_read_urb,
|
||||
.tiocmget = ssu100_tiocmget,
|
||||
|
@ -97,6 +97,8 @@ struct ti_device {
|
||||
|
||||
static int ti_startup(struct usb_serial *serial);
|
||||
static void ti_release(struct usb_serial *serial);
|
||||
static int ti_port_probe(struct usb_serial_port *port);
|
||||
static int ti_port_remove(struct usb_serial_port *port);
|
||||
static int ti_open(struct tty_struct *tty, struct usb_serial_port *port);
|
||||
static void ti_close(struct usb_serial_port *port);
|
||||
static int ti_write(struct tty_struct *tty, struct usb_serial_port *port,
|
||||
@ -221,6 +223,8 @@ static struct usb_serial_driver ti_1port_device = {
|
||||
.num_ports = 1,
|
||||
.attach = ti_startup,
|
||||
.release = ti_release,
|
||||
.port_probe = ti_port_probe,
|
||||
.port_remove = ti_port_remove,
|
||||
.open = ti_open,
|
||||
.close = ti_close,
|
||||
.write = ti_write,
|
||||
@ -249,6 +253,8 @@ static struct usb_serial_driver ti_2port_device = {
|
||||
.num_ports = 2,
|
||||
.attach = ti_startup,
|
||||
.release = ti_release,
|
||||
.port_probe = ti_port_probe,
|
||||
.port_remove = ti_port_remove,
|
||||
.open = ti_open,
|
||||
.close = ti_close,
|
||||
.write = ti_write,
|
||||
@ -347,11 +353,8 @@ module_exit(ti_exit);
|
||||
static int ti_startup(struct usb_serial *serial)
|
||||
{
|
||||
struct ti_device *tdev;
|
||||
struct ti_port *tport;
|
||||
struct usb_device *dev = serial->dev;
|
||||
int status;
|
||||
int i;
|
||||
|
||||
|
||||
dev_dbg(&dev->dev,
|
||||
"%s - product 0x%4X, num configurations %d, configuration value %d",
|
||||
@ -399,42 +402,8 @@ static int ti_startup(struct usb_serial *serial)
|
||||
goto free_tdev;
|
||||
}
|
||||
|
||||
/* set up port structures */
|
||||
for (i = 0; i < serial->num_ports; ++i) {
|
||||
tport = kzalloc(sizeof(struct ti_port), GFP_KERNEL);
|
||||
if (tport == NULL) {
|
||||
dev_err(&dev->dev, "%s - out of memory\n", __func__);
|
||||
status = -ENOMEM;
|
||||
goto free_tports;
|
||||
}
|
||||
spin_lock_init(&tport->tp_lock);
|
||||
tport->tp_uart_base_addr = (i == 0 ?
|
||||
TI_UART1_BASE_ADDR : TI_UART2_BASE_ADDR);
|
||||
tport->tp_closing_wait = closing_wait;
|
||||
init_waitqueue_head(&tport->tp_msr_wait);
|
||||
init_waitqueue_head(&tport->tp_write_wait);
|
||||
if (kfifo_alloc(&tport->write_fifo, TI_WRITE_BUF_SIZE,
|
||||
GFP_KERNEL)) {
|
||||
dev_err(&dev->dev, "%s - out of memory\n", __func__);
|
||||
kfree(tport);
|
||||
status = -ENOMEM;
|
||||
goto free_tports;
|
||||
}
|
||||
tport->tp_port = serial->port[i];
|
||||
tport->tp_tdev = tdev;
|
||||
usb_set_serial_port_data(serial->port[i], tport);
|
||||
tport->tp_uart_mode = 0; /* default is RS232 */
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
free_tports:
|
||||
for (--i; i >= 0; --i) {
|
||||
tport = usb_get_serial_port_data(serial->port[i]);
|
||||
kfifo_free(&tport->write_fifo);
|
||||
kfree(tport);
|
||||
usb_set_serial_port_data(serial->port[i], NULL);
|
||||
}
|
||||
free_tdev:
|
||||
kfree(tdev);
|
||||
usb_set_serial_data(serial, NULL);
|
||||
@ -444,21 +413,50 @@ free_tdev:
|
||||
|
||||
static void ti_release(struct usb_serial *serial)
|
||||
{
|
||||
int i;
|
||||
struct ti_device *tdev = usb_get_serial_data(serial);
|
||||
struct ti_port *tport;
|
||||
|
||||
for (i = 0; i < serial->num_ports; ++i) {
|
||||
tport = usb_get_serial_port_data(serial->port[i]);
|
||||
if (tport) {
|
||||
kfifo_free(&tport->write_fifo);
|
||||
kfree(tport);
|
||||
}
|
||||
}
|
||||
|
||||
kfree(tdev);
|
||||
}
|
||||
|
||||
static int ti_port_probe(struct usb_serial_port *port)
|
||||
{
|
||||
struct ti_port *tport;
|
||||
|
||||
tport = kzalloc(sizeof(*tport), GFP_KERNEL);
|
||||
if (!tport)
|
||||
return -ENOMEM;
|
||||
|
||||
spin_lock_init(&tport->tp_lock);
|
||||
if (port == port->serial->port[0])
|
||||
tport->tp_uart_base_addr = TI_UART1_BASE_ADDR;
|
||||
else
|
||||
tport->tp_uart_base_addr = TI_UART2_BASE_ADDR;
|
||||
tport->tp_closing_wait = closing_wait;
|
||||
init_waitqueue_head(&tport->tp_msr_wait);
|
||||
init_waitqueue_head(&tport->tp_write_wait);
|
||||
if (kfifo_alloc(&tport->write_fifo, TI_WRITE_BUF_SIZE, GFP_KERNEL)) {
|
||||
kfree(tport);
|
||||
return -ENOMEM;
|
||||
}
|
||||
tport->tp_port = port;
|
||||
tport->tp_tdev = usb_get_serial_data(port->serial);
|
||||
tport->tp_uart_mode = 0; /* default is RS232 */
|
||||
|
||||
usb_set_serial_port_data(port, tport);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ti_port_remove(struct usb_serial_port *port)
|
||||
{
|
||||
struct ti_port *tport;
|
||||
|
||||
tport = usb_get_serial_port_data(port);
|
||||
kfifo_free(&tport->write_fifo);
|
||||
kfree(tport);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
|
||||
{
|
||||
|
@ -1778,17 +1778,6 @@ static inline int usb_translate_errors(int error_code)
|
||||
extern void usb_register_notify(struct notifier_block *nb);
|
||||
extern void usb_unregister_notify(struct notifier_block *nb);
|
||||
|
||||
#ifdef DEBUG
|
||||
#define dbg(format, arg...) \
|
||||
printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg)
|
||||
#else
|
||||
#define dbg(format, arg...) \
|
||||
do { \
|
||||
if (0) \
|
||||
printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
/* debugfs stuff */
|
||||
extern struct dentry *usb_debug_root;
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
header-y += audio.h
|
||||
header-y += cdc.h
|
||||
header-y += ch9.h
|
||||
header-y += ch11.h
|
||||
header-y += functionfs.h
|
||||
header-y += gadgetfs.h
|
||||
header-y += midi.h
|
||||
header-y += g_printer.h
|
||||
header-y += tmc.h
|
||||
header-y += video.h
|
@ -17,531 +17,11 @@
|
||||
* Types and defines in this file are either specific to version 1.0 of
|
||||
* this standard or common for newer versions.
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_USB_AUDIO_H
|
||||
#define __LINUX_USB_AUDIO_H
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <uapi/linux/usb/audio.h>
|
||||
|
||||
/* bInterfaceProtocol values to denote the version of the standard used */
|
||||
#define UAC_VERSION_1 0x00
|
||||
#define UAC_VERSION_2 0x20
|
||||
|
||||
/* A.2 Audio Interface Subclass Codes */
|
||||
#define USB_SUBCLASS_AUDIOCONTROL 0x01
|
||||
#define USB_SUBCLASS_AUDIOSTREAMING 0x02
|
||||
#define USB_SUBCLASS_MIDISTREAMING 0x03
|
||||
|
||||
/* A.5 Audio Class-Specific AC Interface Descriptor Subtypes */
|
||||
#define UAC_HEADER 0x01
|
||||
#define UAC_INPUT_TERMINAL 0x02
|
||||
#define UAC_OUTPUT_TERMINAL 0x03
|
||||
#define UAC_MIXER_UNIT 0x04
|
||||
#define UAC_SELECTOR_UNIT 0x05
|
||||
#define UAC_FEATURE_UNIT 0x06
|
||||
#define UAC1_PROCESSING_UNIT 0x07
|
||||
#define UAC1_EXTENSION_UNIT 0x08
|
||||
|
||||
/* A.6 Audio Class-Specific AS Interface Descriptor Subtypes */
|
||||
#define UAC_AS_GENERAL 0x01
|
||||
#define UAC_FORMAT_TYPE 0x02
|
||||
#define UAC_FORMAT_SPECIFIC 0x03
|
||||
|
||||
/* A.7 Processing Unit Process Types */
|
||||
#define UAC_PROCESS_UNDEFINED 0x00
|
||||
#define UAC_PROCESS_UP_DOWNMIX 0x01
|
||||
#define UAC_PROCESS_DOLBY_PROLOGIC 0x02
|
||||
#define UAC_PROCESS_STEREO_EXTENDER 0x03
|
||||
#define UAC_PROCESS_REVERB 0x04
|
||||
#define UAC_PROCESS_CHORUS 0x05
|
||||
#define UAC_PROCESS_DYN_RANGE_COMP 0x06
|
||||
|
||||
/* A.8 Audio Class-Specific Endpoint Descriptor Subtypes */
|
||||
#define UAC_EP_GENERAL 0x01
|
||||
|
||||
/* A.9 Audio Class-Specific Request Codes */
|
||||
#define UAC_SET_ 0x00
|
||||
#define UAC_GET_ 0x80
|
||||
|
||||
#define UAC__CUR 0x1
|
||||
#define UAC__MIN 0x2
|
||||
#define UAC__MAX 0x3
|
||||
#define UAC__RES 0x4
|
||||
#define UAC__MEM 0x5
|
||||
|
||||
#define UAC_SET_CUR (UAC_SET_ | UAC__CUR)
|
||||
#define UAC_GET_CUR (UAC_GET_ | UAC__CUR)
|
||||
#define UAC_SET_MIN (UAC_SET_ | UAC__MIN)
|
||||
#define UAC_GET_MIN (UAC_GET_ | UAC__MIN)
|
||||
#define UAC_SET_MAX (UAC_SET_ | UAC__MAX)
|
||||
#define UAC_GET_MAX (UAC_GET_ | UAC__MAX)
|
||||
#define UAC_SET_RES (UAC_SET_ | UAC__RES)
|
||||
#define UAC_GET_RES (UAC_GET_ | UAC__RES)
|
||||
#define UAC_SET_MEM (UAC_SET_ | UAC__MEM)
|
||||
#define UAC_GET_MEM (UAC_GET_ | UAC__MEM)
|
||||
|
||||
#define UAC_GET_STAT 0xff
|
||||
|
||||
/* A.10 Control Selector Codes */
|
||||
|
||||
/* A.10.1 Terminal Control Selectors */
|
||||
#define UAC_TERM_COPY_PROTECT 0x01
|
||||
|
||||
/* A.10.2 Feature Unit Control Selectors */
|
||||
#define UAC_FU_MUTE 0x01
|
||||
#define UAC_FU_VOLUME 0x02
|
||||
#define UAC_FU_BASS 0x03
|
||||
#define UAC_FU_MID 0x04
|
||||
#define UAC_FU_TREBLE 0x05
|
||||
#define UAC_FU_GRAPHIC_EQUALIZER 0x06
|
||||
#define UAC_FU_AUTOMATIC_GAIN 0x07
|
||||
#define UAC_FU_DELAY 0x08
|
||||
#define UAC_FU_BASS_BOOST 0x09
|
||||
#define UAC_FU_LOUDNESS 0x0a
|
||||
|
||||
#define UAC_CONTROL_BIT(CS) (1 << ((CS) - 1))
|
||||
|
||||
/* A.10.3.1 Up/Down-mix Processing Unit Controls Selectors */
|
||||
#define UAC_UD_ENABLE 0x01
|
||||
#define UAC_UD_MODE_SELECT 0x02
|
||||
|
||||
/* A.10.3.2 Dolby Prologic (tm) Processing Unit Controls Selectors */
|
||||
#define UAC_DP_ENABLE 0x01
|
||||
#define UAC_DP_MODE_SELECT 0x02
|
||||
|
||||
/* A.10.3.3 3D Stereo Extender Processing Unit Control Selectors */
|
||||
#define UAC_3D_ENABLE 0x01
|
||||
#define UAC_3D_SPACE 0x02
|
||||
|
||||
/* A.10.3.4 Reverberation Processing Unit Control Selectors */
|
||||
#define UAC_REVERB_ENABLE 0x01
|
||||
#define UAC_REVERB_LEVEL 0x02
|
||||
#define UAC_REVERB_TIME 0x03
|
||||
#define UAC_REVERB_FEEDBACK 0x04
|
||||
|
||||
/* A.10.3.5 Chorus Processing Unit Control Selectors */
|
||||
#define UAC_CHORUS_ENABLE 0x01
|
||||
#define UAC_CHORUS_LEVEL 0x02
|
||||
#define UAC_CHORUS_RATE 0x03
|
||||
#define UAC_CHORUS_DEPTH 0x04
|
||||
|
||||
/* A.10.3.6 Dynamic Range Compressor Unit Control Selectors */
|
||||
#define UAC_DCR_ENABLE 0x01
|
||||
#define UAC_DCR_RATE 0x02
|
||||
#define UAC_DCR_MAXAMPL 0x03
|
||||
#define UAC_DCR_THRESHOLD 0x04
|
||||
#define UAC_DCR_ATTACK_TIME 0x05
|
||||
#define UAC_DCR_RELEASE_TIME 0x06
|
||||
|
||||
/* A.10.4 Extension Unit Control Selectors */
|
||||
#define UAC_XU_ENABLE 0x01
|
||||
|
||||
/* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */
|
||||
#define UAC_MS_HEADER 0x01
|
||||
#define UAC_MIDI_IN_JACK 0x02
|
||||
#define UAC_MIDI_OUT_JACK 0x03
|
||||
|
||||
/* MIDI - A.1 MS Class-Specific Endpoint Descriptor Subtypes */
|
||||
#define UAC_MS_GENERAL 0x01
|
||||
|
||||
/* Terminals - 2.1 USB Terminal Types */
|
||||
#define UAC_TERMINAL_UNDEFINED 0x100
|
||||
#define UAC_TERMINAL_STREAMING 0x101
|
||||
#define UAC_TERMINAL_VENDOR_SPEC 0x1FF
|
||||
|
||||
/* Terminal Control Selectors */
|
||||
/* 4.3.2 Class-Specific AC Interface Descriptor */
|
||||
struct uac1_ac_header_descriptor {
|
||||
__u8 bLength; /* 8 + n */
|
||||
__u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
|
||||
__u8 bDescriptorSubtype; /* UAC_MS_HEADER */
|
||||
__le16 bcdADC; /* 0x0100 */
|
||||
__le16 wTotalLength; /* includes Unit and Terminal desc. */
|
||||
__u8 bInCollection; /* n */
|
||||
__u8 baInterfaceNr[]; /* [n] */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define UAC_DT_AC_HEADER_SIZE(n) (8 + (n))
|
||||
|
||||
/* As above, but more useful for defining your own descriptors: */
|
||||
#define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n) \
|
||||
struct uac1_ac_header_descriptor_##n { \
|
||||
__u8 bLength; \
|
||||
__u8 bDescriptorType; \
|
||||
__u8 bDescriptorSubtype; \
|
||||
__le16 bcdADC; \
|
||||
__le16 wTotalLength; \
|
||||
__u8 bInCollection; \
|
||||
__u8 baInterfaceNr[n]; \
|
||||
} __attribute__ ((packed))
|
||||
|
||||
/* 4.3.2.1 Input Terminal Descriptor */
|
||||
struct uac_input_terminal_descriptor {
|
||||
__u8 bLength; /* in bytes: 12 */
|
||||
__u8 bDescriptorType; /* CS_INTERFACE descriptor type */
|
||||
__u8 bDescriptorSubtype; /* INPUT_TERMINAL descriptor subtype */
|
||||
__u8 bTerminalID; /* Constant uniquely terminal ID */
|
||||
__le16 wTerminalType; /* USB Audio Terminal Types */
|
||||
__u8 bAssocTerminal; /* ID of the Output Terminal associated */
|
||||
__u8 bNrChannels; /* Number of logical output channels */
|
||||
__le16 wChannelConfig;
|
||||
__u8 iChannelNames;
|
||||
__u8 iTerminal;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define UAC_DT_INPUT_TERMINAL_SIZE 12
|
||||
|
||||
/* Terminals - 2.2 Input Terminal Types */
|
||||
#define UAC_INPUT_TERMINAL_UNDEFINED 0x200
|
||||
#define UAC_INPUT_TERMINAL_MICROPHONE 0x201
|
||||
#define UAC_INPUT_TERMINAL_DESKTOP_MICROPHONE 0x202
|
||||
#define UAC_INPUT_TERMINAL_PERSONAL_MICROPHONE 0x203
|
||||
#define UAC_INPUT_TERMINAL_OMNI_DIR_MICROPHONE 0x204
|
||||
#define UAC_INPUT_TERMINAL_MICROPHONE_ARRAY 0x205
|
||||
#define UAC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY 0x206
|
||||
|
||||
/* Terminals - control selectors */
|
||||
|
||||
#define UAC_TERMINAL_CS_COPY_PROTECT_CONTROL 0x01
|
||||
|
||||
/* 4.3.2.2 Output Terminal Descriptor */
|
||||
struct uac1_output_terminal_descriptor {
|
||||
__u8 bLength; /* in bytes: 9 */
|
||||
__u8 bDescriptorType; /* CS_INTERFACE descriptor type */
|
||||
__u8 bDescriptorSubtype; /* OUTPUT_TERMINAL descriptor subtype */
|
||||
__u8 bTerminalID; /* Constant uniquely terminal ID */
|
||||
__le16 wTerminalType; /* USB Audio Terminal Types */
|
||||
__u8 bAssocTerminal; /* ID of the Input Terminal associated */
|
||||
__u8 bSourceID; /* ID of the connected Unit or Terminal*/
|
||||
__u8 iTerminal;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define UAC_DT_OUTPUT_TERMINAL_SIZE 9
|
||||
|
||||
/* Terminals - 2.3 Output Terminal Types */
|
||||
#define UAC_OUTPUT_TERMINAL_UNDEFINED 0x300
|
||||
#define UAC_OUTPUT_TERMINAL_SPEAKER 0x301
|
||||
#define UAC_OUTPUT_TERMINAL_HEADPHONES 0x302
|
||||
#define UAC_OUTPUT_TERMINAL_HEAD_MOUNTED_DISPLAY_AUDIO 0x303
|
||||
#define UAC_OUTPUT_TERMINAL_DESKTOP_SPEAKER 0x304
|
||||
#define UAC_OUTPUT_TERMINAL_ROOM_SPEAKER 0x305
|
||||
#define UAC_OUTPUT_TERMINAL_COMMUNICATION_SPEAKER 0x306
|
||||
#define UAC_OUTPUT_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER 0x307
|
||||
|
||||
/* Set bControlSize = 2 as default setting */
|
||||
#define UAC_DT_FEATURE_UNIT_SIZE(ch) (7 + ((ch) + 1) * 2)
|
||||
|
||||
/* As above, but more useful for defining your own descriptors: */
|
||||
#define DECLARE_UAC_FEATURE_UNIT_DESCRIPTOR(ch) \
|
||||
struct uac_feature_unit_descriptor_##ch { \
|
||||
__u8 bLength; \
|
||||
__u8 bDescriptorType; \
|
||||
__u8 bDescriptorSubtype; \
|
||||
__u8 bUnitID; \
|
||||
__u8 bSourceID; \
|
||||
__u8 bControlSize; \
|
||||
__le16 bmaControls[ch + 1]; \
|
||||
__u8 iFeature; \
|
||||
} __attribute__ ((packed))
|
||||
|
||||
/* 4.3.2.3 Mixer Unit Descriptor */
|
||||
struct uac_mixer_unit_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubtype;
|
||||
__u8 bUnitID;
|
||||
__u8 bNrInPins;
|
||||
__u8 baSourceID[];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
static inline __u8 uac_mixer_unit_bNrChannels(struct uac_mixer_unit_descriptor *desc)
|
||||
{
|
||||
return desc->baSourceID[desc->bNrInPins];
|
||||
}
|
||||
|
||||
static inline __u32 uac_mixer_unit_wChannelConfig(struct uac_mixer_unit_descriptor *desc,
|
||||
int protocol)
|
||||
{
|
||||
if (protocol == UAC_VERSION_1)
|
||||
return (desc->baSourceID[desc->bNrInPins + 2] << 8) |
|
||||
desc->baSourceID[desc->bNrInPins + 1];
|
||||
else
|
||||
return (desc->baSourceID[desc->bNrInPins + 4] << 24) |
|
||||
(desc->baSourceID[desc->bNrInPins + 3] << 16) |
|
||||
(desc->baSourceID[desc->bNrInPins + 2] << 8) |
|
||||
(desc->baSourceID[desc->bNrInPins + 1]);
|
||||
}
|
||||
|
||||
static inline __u8 uac_mixer_unit_iChannelNames(struct uac_mixer_unit_descriptor *desc,
|
||||
int protocol)
|
||||
{
|
||||
return (protocol == UAC_VERSION_1) ?
|
||||
desc->baSourceID[desc->bNrInPins + 3] :
|
||||
desc->baSourceID[desc->bNrInPins + 5];
|
||||
}
|
||||
|
||||
static inline __u8 *uac_mixer_unit_bmControls(struct uac_mixer_unit_descriptor *desc,
|
||||
int protocol)
|
||||
{
|
||||
return (protocol == UAC_VERSION_1) ?
|
||||
&desc->baSourceID[desc->bNrInPins + 4] :
|
||||
&desc->baSourceID[desc->bNrInPins + 6];
|
||||
}
|
||||
|
||||
static inline __u8 uac_mixer_unit_iMixer(struct uac_mixer_unit_descriptor *desc)
|
||||
{
|
||||
__u8 *raw = (__u8 *) desc;
|
||||
return raw[desc->bLength - 1];
|
||||
}
|
||||
|
||||
/* 4.3.2.4 Selector Unit Descriptor */
|
||||
struct uac_selector_unit_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubtype;
|
||||
__u8 bUintID;
|
||||
__u8 bNrInPins;
|
||||
__u8 baSourceID[];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
static inline __u8 uac_selector_unit_iSelector(struct uac_selector_unit_descriptor *desc)
|
||||
{
|
||||
__u8 *raw = (__u8 *) desc;
|
||||
return raw[desc->bLength - 1];
|
||||
}
|
||||
|
||||
/* 4.3.2.5 Feature Unit Descriptor */
|
||||
struct uac_feature_unit_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubtype;
|
||||
__u8 bUnitID;
|
||||
__u8 bSourceID;
|
||||
__u8 bControlSize;
|
||||
__u8 bmaControls[0]; /* variable length */
|
||||
} __attribute__((packed));
|
||||
|
||||
static inline __u8 uac_feature_unit_iFeature(struct uac_feature_unit_descriptor *desc)
|
||||
{
|
||||
__u8 *raw = (__u8 *) desc;
|
||||
return raw[desc->bLength - 1];
|
||||
}
|
||||
|
||||
/* 4.3.2.6 Processing Unit Descriptors */
|
||||
struct uac_processing_unit_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubtype;
|
||||
__u8 bUnitID;
|
||||
__u16 wProcessType;
|
||||
__u8 bNrInPins;
|
||||
__u8 baSourceID[];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
static inline __u8 uac_processing_unit_bNrChannels(struct uac_processing_unit_descriptor *desc)
|
||||
{
|
||||
return desc->baSourceID[desc->bNrInPins];
|
||||
}
|
||||
|
||||
static inline __u32 uac_processing_unit_wChannelConfig(struct uac_processing_unit_descriptor *desc,
|
||||
int protocol)
|
||||
{
|
||||
if (protocol == UAC_VERSION_1)
|
||||
return (desc->baSourceID[desc->bNrInPins + 2] << 8) |
|
||||
desc->baSourceID[desc->bNrInPins + 1];
|
||||
else
|
||||
return (desc->baSourceID[desc->bNrInPins + 4] << 24) |
|
||||
(desc->baSourceID[desc->bNrInPins + 3] << 16) |
|
||||
(desc->baSourceID[desc->bNrInPins + 2] << 8) |
|
||||
(desc->baSourceID[desc->bNrInPins + 1]);
|
||||
}
|
||||
|
||||
static inline __u8 uac_processing_unit_iChannelNames(struct uac_processing_unit_descriptor *desc,
|
||||
int protocol)
|
||||
{
|
||||
return (protocol == UAC_VERSION_1) ?
|
||||
desc->baSourceID[desc->bNrInPins + 3] :
|
||||
desc->baSourceID[desc->bNrInPins + 5];
|
||||
}
|
||||
|
||||
static inline __u8 uac_processing_unit_bControlSize(struct uac_processing_unit_descriptor *desc,
|
||||
int protocol)
|
||||
{
|
||||
return (protocol == UAC_VERSION_1) ?
|
||||
desc->baSourceID[desc->bNrInPins + 4] :
|
||||
desc->baSourceID[desc->bNrInPins + 6];
|
||||
}
|
||||
|
||||
static inline __u8 *uac_processing_unit_bmControls(struct uac_processing_unit_descriptor *desc,
|
||||
int protocol)
|
||||
{
|
||||
return (protocol == UAC_VERSION_1) ?
|
||||
&desc->baSourceID[desc->bNrInPins + 5] :
|
||||
&desc->baSourceID[desc->bNrInPins + 7];
|
||||
}
|
||||
|
||||
static inline __u8 uac_processing_unit_iProcessing(struct uac_processing_unit_descriptor *desc,
|
||||
int protocol)
|
||||
{
|
||||
__u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
|
||||
return desc->baSourceID[desc->bNrInPins + control_size];
|
||||
}
|
||||
|
||||
static inline __u8 *uac_processing_unit_specific(struct uac_processing_unit_descriptor *desc,
|
||||
int protocol)
|
||||
{
|
||||
__u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
|
||||
return &desc->baSourceID[desc->bNrInPins + control_size + 1];
|
||||
}
|
||||
|
||||
/* 4.5.2 Class-Specific AS Interface Descriptor */
|
||||
struct uac1_as_header_descriptor {
|
||||
__u8 bLength; /* in bytes: 7 */
|
||||
__u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
|
||||
__u8 bDescriptorSubtype; /* AS_GENERAL */
|
||||
__u8 bTerminalLink; /* Terminal ID of connected Terminal */
|
||||
__u8 bDelay; /* Delay introduced by the data path */
|
||||
__le16 wFormatTag; /* The Audio Data Format */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define UAC_DT_AS_HEADER_SIZE 7
|
||||
|
||||
/* Formats - A.1.1 Audio Data Format Type I Codes */
|
||||
#define UAC_FORMAT_TYPE_I_UNDEFINED 0x0
|
||||
#define UAC_FORMAT_TYPE_I_PCM 0x1
|
||||
#define UAC_FORMAT_TYPE_I_PCM8 0x2
|
||||
#define UAC_FORMAT_TYPE_I_IEEE_FLOAT 0x3
|
||||
#define UAC_FORMAT_TYPE_I_ALAW 0x4
|
||||
#define UAC_FORMAT_TYPE_I_MULAW 0x5
|
||||
|
||||
struct uac_format_type_i_continuous_descriptor {
|
||||
__u8 bLength; /* in bytes: 8 + (ns * 3) */
|
||||
__u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
|
||||
__u8 bDescriptorSubtype; /* FORMAT_TYPE */
|
||||
__u8 bFormatType; /* FORMAT_TYPE_1 */
|
||||
__u8 bNrChannels; /* physical channels in the stream */
|
||||
__u8 bSubframeSize; /* */
|
||||
__u8 bBitResolution;
|
||||
__u8 bSamFreqType;
|
||||
__u8 tLowerSamFreq[3];
|
||||
__u8 tUpperSamFreq[3];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define UAC_FORMAT_TYPE_I_CONTINUOUS_DESC_SIZE 14
|
||||
|
||||
struct uac_format_type_i_discrete_descriptor {
|
||||
__u8 bLength; /* in bytes: 8 + (ns * 3) */
|
||||
__u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
|
||||
__u8 bDescriptorSubtype; /* FORMAT_TYPE */
|
||||
__u8 bFormatType; /* FORMAT_TYPE_1 */
|
||||
__u8 bNrChannels; /* physical channels in the stream */
|
||||
__u8 bSubframeSize; /* */
|
||||
__u8 bBitResolution;
|
||||
__u8 bSamFreqType;
|
||||
__u8 tSamFreq[][3];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(n) \
|
||||
struct uac_format_type_i_discrete_descriptor_##n { \
|
||||
__u8 bLength; \
|
||||
__u8 bDescriptorType; \
|
||||
__u8 bDescriptorSubtype; \
|
||||
__u8 bFormatType; \
|
||||
__u8 bNrChannels; \
|
||||
__u8 bSubframeSize; \
|
||||
__u8 bBitResolution; \
|
||||
__u8 bSamFreqType; \
|
||||
__u8 tSamFreq[n][3]; \
|
||||
} __attribute__ ((packed))
|
||||
|
||||
#define UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(n) (8 + (n * 3))
|
||||
|
||||
struct uac_format_type_i_ext_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubtype;
|
||||
__u8 bFormatType;
|
||||
__u8 bSubslotSize;
|
||||
__u8 bBitResolution;
|
||||
__u8 bHeaderLength;
|
||||
__u8 bControlSize;
|
||||
__u8 bSideBandProtocol;
|
||||
} __attribute__((packed));
|
||||
|
||||
/* Formats - Audio Data Format Type I Codes */
|
||||
|
||||
#define UAC_FORMAT_TYPE_II_MPEG 0x1001
|
||||
#define UAC_FORMAT_TYPE_II_AC3 0x1002
|
||||
|
||||
struct uac_format_type_ii_discrete_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubtype;
|
||||
__u8 bFormatType;
|
||||
__le16 wMaxBitRate;
|
||||
__le16 wSamplesPerFrame;
|
||||
__u8 bSamFreqType;
|
||||
__u8 tSamFreq[][3];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct uac_format_type_ii_ext_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubtype;
|
||||
__u8 bFormatType;
|
||||
__u16 wMaxBitRate;
|
||||
__u16 wSamplesPerFrame;
|
||||
__u8 bHeaderLength;
|
||||
__u8 bSideBandProtocol;
|
||||
} __attribute__((packed));
|
||||
|
||||
/* type III */
|
||||
#define UAC_FORMAT_TYPE_III_IEC1937_AC3 0x2001
|
||||
#define UAC_FORMAT_TYPE_III_IEC1937_MPEG1_LAYER1 0x2002
|
||||
#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_NOEXT 0x2003
|
||||
#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_EXT 0x2004
|
||||
#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER1_LS 0x2005
|
||||
#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER23_LS 0x2006
|
||||
|
||||
/* Formats - A.2 Format Type Codes */
|
||||
#define UAC_FORMAT_TYPE_UNDEFINED 0x0
|
||||
#define UAC_FORMAT_TYPE_I 0x1
|
||||
#define UAC_FORMAT_TYPE_II 0x2
|
||||
#define UAC_FORMAT_TYPE_III 0x3
|
||||
#define UAC_EXT_FORMAT_TYPE_I 0x81
|
||||
#define UAC_EXT_FORMAT_TYPE_II 0x82
|
||||
#define UAC_EXT_FORMAT_TYPE_III 0x83
|
||||
|
||||
struct uac_iso_endpoint_descriptor {
|
||||
__u8 bLength; /* in bytes: 7 */
|
||||
__u8 bDescriptorType; /* USB_DT_CS_ENDPOINT */
|
||||
__u8 bDescriptorSubtype; /* EP_GENERAL */
|
||||
__u8 bmAttributes;
|
||||
__u8 bLockDelayUnits;
|
||||
__le16 wLockDelay;
|
||||
} __attribute__((packed));
|
||||
#define UAC_ISO_ENDPOINT_DESC_SIZE 7
|
||||
|
||||
#define UAC_EP_CS_ATTR_SAMPLE_RATE 0x01
|
||||
#define UAC_EP_CS_ATTR_PITCH_CONTROL 0x02
|
||||
#define UAC_EP_CS_ATTR_FILL_MAX 0x80
|
||||
|
||||
/* status word format (3.7.1.1) */
|
||||
|
||||
#define UAC1_STATUS_TYPE_ORIG_MASK 0x0f
|
||||
#define UAC1_STATUS_TYPE_ORIG_AUDIO_CONTROL_IF 0x0
|
||||
#define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_IF 0x1
|
||||
#define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_EP 0x2
|
||||
|
||||
#define UAC1_STATUS_TYPE_IRQ_PENDING (1 << 7)
|
||||
#define UAC1_STATUS_TYPE_MEM_CHANGED (1 << 6)
|
||||
|
||||
struct uac1_status_word {
|
||||
__u8 bStatusType;
|
||||
__u8 bOriginator;
|
||||
} __attribute__((packed));
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
struct usb_audio_control {
|
||||
struct list_head list;
|
||||
@ -561,6 +41,4 @@ struct usb_audio_control_selector {
|
||||
struct usb_descriptor_header *desc;
|
||||
};
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#endif /* __LINUX_USB_AUDIO_H */
|
||||
|
@ -29,887 +29,11 @@
|
||||
* someone that the two other points are non-issues for that
|
||||
* particular descriptor type.
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_USB_CH9_H
|
||||
#define __LINUX_USB_CH9_H
|
||||
|
||||
#include <linux/types.h> /* __u8 etc */
|
||||
#include <asm/byteorder.h> /* le16_to_cpu */
|
||||
#include <uapi/linux/usb/ch9.h>
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* CONTROL REQUEST SUPPORT */
|
||||
|
||||
/*
|
||||
* USB directions
|
||||
*
|
||||
* This bit flag is used in endpoint descriptors' bEndpointAddress field.
|
||||
* It's also one of three fields in control requests bRequestType.
|
||||
*/
|
||||
#define USB_DIR_OUT 0 /* to device */
|
||||
#define USB_DIR_IN 0x80 /* to host */
|
||||
|
||||
/*
|
||||
* USB types, the second of three bRequestType fields
|
||||
*/
|
||||
#define USB_TYPE_MASK (0x03 << 5)
|
||||
#define USB_TYPE_STANDARD (0x00 << 5)
|
||||
#define USB_TYPE_CLASS (0x01 << 5)
|
||||
#define USB_TYPE_VENDOR (0x02 << 5)
|
||||
#define USB_TYPE_RESERVED (0x03 << 5)
|
||||
|
||||
/*
|
||||
* USB recipients, the third of three bRequestType fields
|
||||
*/
|
||||
#define USB_RECIP_MASK 0x1f
|
||||
#define USB_RECIP_DEVICE 0x00
|
||||
#define USB_RECIP_INTERFACE 0x01
|
||||
#define USB_RECIP_ENDPOINT 0x02
|
||||
#define USB_RECIP_OTHER 0x03
|
||||
/* From Wireless USB 1.0 */
|
||||
#define USB_RECIP_PORT 0x04
|
||||
#define USB_RECIP_RPIPE 0x05
|
||||
|
||||
/*
|
||||
* Standard requests, for the bRequest field of a SETUP packet.
|
||||
*
|
||||
* These are qualified by the bRequestType field, so that for example
|
||||
* TYPE_CLASS or TYPE_VENDOR specific feature flags could be retrieved
|
||||
* by a GET_STATUS request.
|
||||
*/
|
||||
#define USB_REQ_GET_STATUS 0x00
|
||||
#define USB_REQ_CLEAR_FEATURE 0x01
|
||||
#define USB_REQ_SET_FEATURE 0x03
|
||||
#define USB_REQ_SET_ADDRESS 0x05
|
||||
#define USB_REQ_GET_DESCRIPTOR 0x06
|
||||
#define USB_REQ_SET_DESCRIPTOR 0x07
|
||||
#define USB_REQ_GET_CONFIGURATION 0x08
|
||||
#define USB_REQ_SET_CONFIGURATION 0x09
|
||||
#define USB_REQ_GET_INTERFACE 0x0A
|
||||
#define USB_REQ_SET_INTERFACE 0x0B
|
||||
#define USB_REQ_SYNCH_FRAME 0x0C
|
||||
#define USB_REQ_SET_SEL 0x30
|
||||
#define USB_REQ_SET_ISOCH_DELAY 0x31
|
||||
|
||||
#define USB_REQ_SET_ENCRYPTION 0x0D /* Wireless USB */
|
||||
#define USB_REQ_GET_ENCRYPTION 0x0E
|
||||
#define USB_REQ_RPIPE_ABORT 0x0E
|
||||
#define USB_REQ_SET_HANDSHAKE 0x0F
|
||||
#define USB_REQ_RPIPE_RESET 0x0F
|
||||
#define USB_REQ_GET_HANDSHAKE 0x10
|
||||
#define USB_REQ_SET_CONNECTION 0x11
|
||||
#define USB_REQ_SET_SECURITY_DATA 0x12
|
||||
#define USB_REQ_GET_SECURITY_DATA 0x13
|
||||
#define USB_REQ_SET_WUSB_DATA 0x14
|
||||
#define USB_REQ_LOOPBACK_DATA_WRITE 0x15
|
||||
#define USB_REQ_LOOPBACK_DATA_READ 0x16
|
||||
#define USB_REQ_SET_INTERFACE_DS 0x17
|
||||
|
||||
/* The Link Power Management (LPM) ECN defines USB_REQ_TEST_AND_SET command,
|
||||
* used by hubs to put ports into a new L1 suspend state, except that it
|
||||
* forgot to define its number ...
|
||||
*/
|
||||
|
||||
/*
|
||||
* USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and
|
||||
* are read as a bit array returned by USB_REQ_GET_STATUS. (So there
|
||||
* are at most sixteen features of each type.) Hubs may also support a
|
||||
* new USB_REQ_TEST_AND_SET_FEATURE to put ports into L1 suspend.
|
||||
*/
|
||||
#define USB_DEVICE_SELF_POWERED 0 /* (read only) */
|
||||
#define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */
|
||||
#define USB_DEVICE_TEST_MODE 2 /* (wired high speed only) */
|
||||
#define USB_DEVICE_BATTERY 2 /* (wireless) */
|
||||
#define USB_DEVICE_B_HNP_ENABLE 3 /* (otg) dev may initiate HNP */
|
||||
#define USB_DEVICE_WUSB_DEVICE 3 /* (wireless)*/
|
||||
#define USB_DEVICE_A_HNP_SUPPORT 4 /* (otg) RH port supports HNP */
|
||||
#define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */
|
||||
#define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */
|
||||
|
||||
/*
|
||||
* Test Mode Selectors
|
||||
* See USB 2.0 spec Table 9-7
|
||||
*/
|
||||
#define TEST_J 1
|
||||
#define TEST_K 2
|
||||
#define TEST_SE0_NAK 3
|
||||
#define TEST_PACKET 4
|
||||
#define TEST_FORCE_EN 5
|
||||
|
||||
/*
|
||||
* New Feature Selectors as added by USB 3.0
|
||||
* See USB 3.0 spec Table 9-6
|
||||
*/
|
||||
#define USB_DEVICE_U1_ENABLE 48 /* dev may initiate U1 transition */
|
||||
#define USB_DEVICE_U2_ENABLE 49 /* dev may initiate U2 transition */
|
||||
#define USB_DEVICE_LTM_ENABLE 50 /* dev may send LTM */
|
||||
#define USB_INTRF_FUNC_SUSPEND 0 /* function suspend */
|
||||
|
||||
#define USB_INTR_FUNC_SUSPEND_OPT_MASK 0xFF00
|
||||
/*
|
||||
* Suspend Options, Table 9-7 USB 3.0 spec
|
||||
*/
|
||||
#define USB_INTRF_FUNC_SUSPEND_LP (1 << (8 + 0))
|
||||
#define USB_INTRF_FUNC_SUSPEND_RW (1 << (8 + 1))
|
||||
|
||||
#define USB_ENDPOINT_HALT 0 /* IN/OUT will STALL */
|
||||
|
||||
/* Bit array elements as returned by the USB_REQ_GET_STATUS request. */
|
||||
#define USB_DEV_STAT_U1_ENABLED 2 /* transition into U1 state */
|
||||
#define USB_DEV_STAT_U2_ENABLED 3 /* transition into U2 state */
|
||||
#define USB_DEV_STAT_LTM_ENABLED 4 /* Latency tolerance messages */
|
||||
|
||||
/**
|
||||
* struct usb_ctrlrequest - SETUP data for a USB device control request
|
||||
* @bRequestType: matches the USB bmRequestType field
|
||||
* @bRequest: matches the USB bRequest field
|
||||
* @wValue: matches the USB wValue field (le16 byte order)
|
||||
* @wIndex: matches the USB wIndex field (le16 byte order)
|
||||
* @wLength: matches the USB wLength field (le16 byte order)
|
||||
*
|
||||
* This structure is used to send control requests to a USB device. It matches
|
||||
* the different fields of the USB 2.0 Spec section 9.3, table 9-2. See the
|
||||
* USB spec for a fuller description of the different fields, and what they are
|
||||
* used for.
|
||||
*
|
||||
* Note that the driver for any interface can issue control requests.
|
||||
* For most devices, interfaces don't coordinate with each other, so
|
||||
* such requests may be made at any time.
|
||||
*/
|
||||
struct usb_ctrlrequest {
|
||||
__u8 bRequestType;
|
||||
__u8 bRequest;
|
||||
__le16 wValue;
|
||||
__le16 wIndex;
|
||||
__le16 wLength;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* STANDARD DESCRIPTORS ... as returned by GET_DESCRIPTOR, or
|
||||
* (rarely) accepted by SET_DESCRIPTOR.
|
||||
*
|
||||
* Note that all multi-byte values here are encoded in little endian
|
||||
* byte order "on the wire". Within the kernel and when exposed
|
||||
* through the Linux-USB APIs, they are not converted to cpu byte
|
||||
* order; it is the responsibility of the client code to do this.
|
||||
* The single exception is when device and configuration descriptors (but
|
||||
* not other descriptors) are read from usbfs (i.e. /proc/bus/usb/BBB/DDD);
|
||||
* in this case the fields are converted to host endianness by the kernel.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Descriptor types ... USB 2.0 spec table 9.5
|
||||
*/
|
||||
#define USB_DT_DEVICE 0x01
|
||||
#define USB_DT_CONFIG 0x02
|
||||
#define USB_DT_STRING 0x03
|
||||
#define USB_DT_INTERFACE 0x04
|
||||
#define USB_DT_ENDPOINT 0x05
|
||||
#define USB_DT_DEVICE_QUALIFIER 0x06
|
||||
#define USB_DT_OTHER_SPEED_CONFIG 0x07
|
||||
#define USB_DT_INTERFACE_POWER 0x08
|
||||
/* these are from a minor usb 2.0 revision (ECN) */
|
||||
#define USB_DT_OTG 0x09
|
||||
#define USB_DT_DEBUG 0x0a
|
||||
#define USB_DT_INTERFACE_ASSOCIATION 0x0b
|
||||
/* these are from the Wireless USB spec */
|
||||
#define USB_DT_SECURITY 0x0c
|
||||
#define USB_DT_KEY 0x0d
|
||||
#define USB_DT_ENCRYPTION_TYPE 0x0e
|
||||
#define USB_DT_BOS 0x0f
|
||||
#define USB_DT_DEVICE_CAPABILITY 0x10
|
||||
#define USB_DT_WIRELESS_ENDPOINT_COMP 0x11
|
||||
#define USB_DT_WIRE_ADAPTER 0x21
|
||||
#define USB_DT_RPIPE 0x22
|
||||
#define USB_DT_CS_RADIO_CONTROL 0x23
|
||||
/* From the T10 UAS specification */
|
||||
#define USB_DT_PIPE_USAGE 0x24
|
||||
/* From the USB 3.0 spec */
|
||||
#define USB_DT_SS_ENDPOINT_COMP 0x30
|
||||
|
||||
/* Conventional codes for class-specific descriptors. The convention is
|
||||
* defined in the USB "Common Class" Spec (3.11). Individual class specs
|
||||
* are authoritative for their usage, not the "common class" writeup.
|
||||
*/
|
||||
#define USB_DT_CS_DEVICE (USB_TYPE_CLASS | USB_DT_DEVICE)
|
||||
#define USB_DT_CS_CONFIG (USB_TYPE_CLASS | USB_DT_CONFIG)
|
||||
#define USB_DT_CS_STRING (USB_TYPE_CLASS | USB_DT_STRING)
|
||||
#define USB_DT_CS_INTERFACE (USB_TYPE_CLASS | USB_DT_INTERFACE)
|
||||
#define USB_DT_CS_ENDPOINT (USB_TYPE_CLASS | USB_DT_ENDPOINT)
|
||||
|
||||
/* All standard descriptors have these 2 fields at the beginning */
|
||||
struct usb_descriptor_header {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_DEVICE: Device descriptor */
|
||||
struct usb_device_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__le16 bcdUSB;
|
||||
__u8 bDeviceClass;
|
||||
__u8 bDeviceSubClass;
|
||||
__u8 bDeviceProtocol;
|
||||
__u8 bMaxPacketSize0;
|
||||
__le16 idVendor;
|
||||
__le16 idProduct;
|
||||
__le16 bcdDevice;
|
||||
__u8 iManufacturer;
|
||||
__u8 iProduct;
|
||||
__u8 iSerialNumber;
|
||||
__u8 bNumConfigurations;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define USB_DT_DEVICE_SIZE 18
|
||||
|
||||
|
||||
/*
|
||||
* Device and/or Interface Class codes
|
||||
* as found in bDeviceClass or bInterfaceClass
|
||||
* and defined by www.usb.org documents
|
||||
*/
|
||||
#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */
|
||||
#define USB_CLASS_AUDIO 1
|
||||
#define USB_CLASS_COMM 2
|
||||
#define USB_CLASS_HID 3
|
||||
#define USB_CLASS_PHYSICAL 5
|
||||
#define USB_CLASS_STILL_IMAGE 6
|
||||
#define USB_CLASS_PRINTER 7
|
||||
#define USB_CLASS_MASS_STORAGE 8
|
||||
#define USB_CLASS_HUB 9
|
||||
#define USB_CLASS_CDC_DATA 0x0a
|
||||
#define USB_CLASS_CSCID 0x0b /* chip+ smart card */
|
||||
#define USB_CLASS_CONTENT_SEC 0x0d /* content security */
|
||||
#define USB_CLASS_VIDEO 0x0e
|
||||
#define USB_CLASS_WIRELESS_CONTROLLER 0xe0
|
||||
#define USB_CLASS_MISC 0xef
|
||||
#define USB_CLASS_APP_SPEC 0xfe
|
||||
#define USB_CLASS_VENDOR_SPEC 0xff
|
||||
|
||||
#define USB_SUBCLASS_VENDOR_SPEC 0xff
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_CONFIG: Configuration descriptor information.
|
||||
*
|
||||
* USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the
|
||||
* descriptor type is different. Highspeed-capable devices can look
|
||||
* different depending on what speed they're currently running. Only
|
||||
* devices with a USB_DT_DEVICE_QUALIFIER have any OTHER_SPEED_CONFIG
|
||||
* descriptors.
|
||||
*/
|
||||
struct usb_config_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__le16 wTotalLength;
|
||||
__u8 bNumInterfaces;
|
||||
__u8 bConfigurationValue;
|
||||
__u8 iConfiguration;
|
||||
__u8 bmAttributes;
|
||||
__u8 bMaxPower;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define USB_DT_CONFIG_SIZE 9
|
||||
|
||||
/* from config descriptor bmAttributes */
|
||||
#define USB_CONFIG_ATT_ONE (1 << 7) /* must be set */
|
||||
#define USB_CONFIG_ATT_SELFPOWER (1 << 6) /* self powered */
|
||||
#define USB_CONFIG_ATT_WAKEUP (1 << 5) /* can wakeup */
|
||||
#define USB_CONFIG_ATT_BATTERY (1 << 4) /* battery powered */
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_STRING: String descriptor */
|
||||
struct usb_string_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__le16 wData[1]; /* UTF-16LE encoded */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* note that "string" zero is special, it holds language codes that
|
||||
* the device supports, not Unicode characters.
|
||||
*/
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_INTERFACE: Interface descriptor */
|
||||
struct usb_interface_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__u8 bInterfaceNumber;
|
||||
__u8 bAlternateSetting;
|
||||
__u8 bNumEndpoints;
|
||||
__u8 bInterfaceClass;
|
||||
__u8 bInterfaceSubClass;
|
||||
__u8 bInterfaceProtocol;
|
||||
__u8 iInterface;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define USB_DT_INTERFACE_SIZE 9
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_ENDPOINT: Endpoint descriptor */
|
||||
struct usb_endpoint_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__u8 bEndpointAddress;
|
||||
__u8 bmAttributes;
|
||||
__le16 wMaxPacketSize;
|
||||
__u8 bInterval;
|
||||
|
||||
/* NOTE: these two are _only_ in audio endpoints. */
|
||||
/* use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof. */
|
||||
__u8 bRefresh;
|
||||
__u8 bSynchAddress;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define USB_DT_ENDPOINT_SIZE 7
|
||||
#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
|
||||
|
||||
|
||||
/*
|
||||
* Endpoints
|
||||
*/
|
||||
#define USB_ENDPOINT_NUMBER_MASK 0x0f /* in bEndpointAddress */
|
||||
#define USB_ENDPOINT_DIR_MASK 0x80
|
||||
|
||||
#define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */
|
||||
#define USB_ENDPOINT_XFER_CONTROL 0
|
||||
#define USB_ENDPOINT_XFER_ISOC 1
|
||||
#define USB_ENDPOINT_XFER_BULK 2
|
||||
#define USB_ENDPOINT_XFER_INT 3
|
||||
#define USB_ENDPOINT_MAX_ADJUSTABLE 0x80
|
||||
|
||||
/* The USB 3.0 spec redefines bits 5:4 of bmAttributes as interrupt ep type. */
|
||||
#define USB_ENDPOINT_INTRTYPE 0x30
|
||||
#define USB_ENDPOINT_INTR_PERIODIC (0 << 4)
|
||||
#define USB_ENDPOINT_INTR_NOTIFICATION (1 << 4)
|
||||
|
||||
#define USB_ENDPOINT_SYNCTYPE 0x0c
|
||||
#define USB_ENDPOINT_SYNC_NONE (0 << 2)
|
||||
#define USB_ENDPOINT_SYNC_ASYNC (1 << 2)
|
||||
#define USB_ENDPOINT_SYNC_ADAPTIVE (2 << 2)
|
||||
#define USB_ENDPOINT_SYNC_SYNC (3 << 2)
|
||||
|
||||
#define USB_ENDPOINT_USAGE_MASK 0x30
|
||||
#define USB_ENDPOINT_USAGE_DATA 0x00
|
||||
#define USB_ENDPOINT_USAGE_FEEDBACK 0x10
|
||||
#define USB_ENDPOINT_USAGE_IMPLICIT_FB 0x20 /* Implicit feedback Data endpoint */
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* usb_endpoint_num - get the endpoint's number
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns @epd's number: 0 to 15.
|
||||
*/
|
||||
static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_type - get the endpoint's transfer type
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns one of USB_ENDPOINT_XFER_{CONTROL, ISOC, BULK, INT} according
|
||||
* to @epd's transfer type.
|
||||
*/
|
||||
static inline int usb_endpoint_type(const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_dir_in - check if the endpoint has IN direction
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns true if the endpoint is of type IN, otherwise it returns false.
|
||||
*/
|
||||
static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_dir_out - check if the endpoint has OUT direction
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns true if the endpoint is of type OUT, otherwise it returns false.
|
||||
*/
|
||||
static inline int usb_endpoint_dir_out(
|
||||
const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_xfer_bulk - check if the endpoint has bulk transfer type
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns true if the endpoint is of type bulk, otherwise it returns false.
|
||||
*/
|
||||
static inline int usb_endpoint_xfer_bulk(
|
||||
const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
|
||||
USB_ENDPOINT_XFER_BULK);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_xfer_control - check if the endpoint has control transfer type
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns true if the endpoint is of type control, otherwise it returns false.
|
||||
*/
|
||||
static inline int usb_endpoint_xfer_control(
|
||||
const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
|
||||
USB_ENDPOINT_XFER_CONTROL);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns true if the endpoint is of type interrupt, otherwise it returns
|
||||
* false.
|
||||
*/
|
||||
static inline int usb_endpoint_xfer_int(
|
||||
const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
|
||||
USB_ENDPOINT_XFER_INT);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_xfer_isoc - check if the endpoint has isochronous transfer type
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns true if the endpoint is of type isochronous, otherwise it returns
|
||||
* false.
|
||||
*/
|
||||
static inline int usb_endpoint_xfer_isoc(
|
||||
const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
|
||||
USB_ENDPOINT_XFER_ISOC);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_is_bulk_in - check if the endpoint is bulk IN
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns true if the endpoint has bulk transfer type and IN direction,
|
||||
* otherwise it returns false.
|
||||
*/
|
||||
static inline int usb_endpoint_is_bulk_in(
|
||||
const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_is_bulk_out - check if the endpoint is bulk OUT
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns true if the endpoint has bulk transfer type and OUT direction,
|
||||
* otherwise it returns false.
|
||||
*/
|
||||
static inline int usb_endpoint_is_bulk_out(
|
||||
const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_is_int_in - check if the endpoint is interrupt IN
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns true if the endpoint has interrupt transfer type and IN direction,
|
||||
* otherwise it returns false.
|
||||
*/
|
||||
static inline int usb_endpoint_is_int_in(
|
||||
const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_is_int_out - check if the endpoint is interrupt OUT
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns true if the endpoint has interrupt transfer type and OUT direction,
|
||||
* otherwise it returns false.
|
||||
*/
|
||||
static inline int usb_endpoint_is_int_out(
|
||||
const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_is_isoc_in - check if the endpoint is isochronous IN
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns true if the endpoint has isochronous transfer type and IN direction,
|
||||
* otherwise it returns false.
|
||||
*/
|
||||
static inline int usb_endpoint_is_isoc_in(
|
||||
const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_is_isoc_out - check if the endpoint is isochronous OUT
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns true if the endpoint has isochronous transfer type and OUT direction,
|
||||
* otherwise it returns false.
|
||||
*/
|
||||
static inline int usb_endpoint_is_isoc_out(
|
||||
const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_maxp - get endpoint's max packet size
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns @epd's max packet
|
||||
*/
|
||||
static inline int usb_endpoint_maxp(const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return __le16_to_cpu(epd->wMaxPacketSize);
|
||||
}
|
||||
|
||||
static inline int usb_endpoint_interrupt_type(
|
||||
const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return epd->bmAttributes & USB_ENDPOINT_INTRTYPE;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_SS_ENDPOINT_COMP: SuperSpeed Endpoint Companion descriptor */
|
||||
struct usb_ss_ep_comp_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__u8 bMaxBurst;
|
||||
__u8 bmAttributes;
|
||||
__le16 wBytesPerInterval;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define USB_DT_SS_EP_COMP_SIZE 6
|
||||
|
||||
/* Bits 4:0 of bmAttributes if this is a bulk endpoint */
|
||||
static inline int
|
||||
usb_ss_max_streams(const struct usb_ss_ep_comp_descriptor *comp)
|
||||
{
|
||||
int max_streams;
|
||||
|
||||
if (!comp)
|
||||
return 0;
|
||||
|
||||
max_streams = comp->bmAttributes & 0x1f;
|
||||
|
||||
if (!max_streams)
|
||||
return 0;
|
||||
|
||||
max_streams = 1 << max_streams;
|
||||
|
||||
return max_streams;
|
||||
}
|
||||
|
||||
/* Bits 1:0 of bmAttributes if this is an isoc endpoint */
|
||||
#define USB_SS_MULT(p) (1 + ((p) & 0x3))
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */
|
||||
struct usb_qualifier_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__le16 bcdUSB;
|
||||
__u8 bDeviceClass;
|
||||
__u8 bDeviceSubClass;
|
||||
__u8 bDeviceProtocol;
|
||||
__u8 bMaxPacketSize0;
|
||||
__u8 bNumConfigurations;
|
||||
__u8 bRESERVED;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_OTG (from OTG 1.0a supplement) */
|
||||
struct usb_otg_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__u8 bmAttributes; /* support for HNP, SRP, etc */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* from usb_otg_descriptor.bmAttributes */
|
||||
#define USB_OTG_SRP (1 << 0)
|
||||
#define USB_OTG_HNP (1 << 1) /* swap host/device roles */
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_DEBUG: for special highspeed devices, replacing serial console */
|
||||
struct usb_debug_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
/* bulk endpoints with 8 byte maxpacket */
|
||||
__u8 bDebugInEndpoint;
|
||||
__u8 bDebugOutEndpoint;
|
||||
} __attribute__((packed));
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_INTERFACE_ASSOCIATION: groups interfaces */
|
||||
struct usb_interface_assoc_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__u8 bFirstInterface;
|
||||
__u8 bInterfaceCount;
|
||||
__u8 bFunctionClass;
|
||||
__u8 bFunctionSubClass;
|
||||
__u8 bFunctionProtocol;
|
||||
__u8 iFunction;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_SECURITY: group of wireless security descriptors, including
|
||||
* encryption types available for setting up a CC/association.
|
||||
*/
|
||||
struct usb_security_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__le16 wTotalLength;
|
||||
__u8 bNumEncryptionTypes;
|
||||
} __attribute__((packed));
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_KEY: used with {GET,SET}_SECURITY_DATA; only public keys
|
||||
* may be retrieved.
|
||||
*/
|
||||
struct usb_key_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__u8 tTKID[3];
|
||||
__u8 bReserved;
|
||||
__u8 bKeyData[0];
|
||||
} __attribute__((packed));
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_ENCRYPTION_TYPE: bundled in DT_SECURITY groups */
|
||||
struct usb_encryption_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__u8 bEncryptionType;
|
||||
#define USB_ENC_TYPE_UNSECURE 0
|
||||
#define USB_ENC_TYPE_WIRED 1 /* non-wireless mode */
|
||||
#define USB_ENC_TYPE_CCM_1 2 /* aes128/cbc session */
|
||||
#define USB_ENC_TYPE_RSA_1 3 /* rsa3072/sha1 auth */
|
||||
__u8 bEncryptionValue; /* use in SET_ENCRYPTION */
|
||||
__u8 bAuthKeyIndex;
|
||||
} __attribute__((packed));
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_BOS: group of device-level capabilities */
|
||||
struct usb_bos_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__le16 wTotalLength;
|
||||
__u8 bNumDeviceCaps;
|
||||
} __attribute__((packed));
|
||||
|
||||
#define USB_DT_BOS_SIZE 5
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_DEVICE_CAPABILITY: grouped with BOS */
|
||||
struct usb_dev_cap_header {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDevCapabilityType;
|
||||
} __attribute__((packed));
|
||||
|
||||
#define USB_CAP_TYPE_WIRELESS_USB 1
|
||||
|
||||
struct usb_wireless_cap_descriptor { /* Ultra Wide Band */
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDevCapabilityType;
|
||||
|
||||
__u8 bmAttributes;
|
||||
#define USB_WIRELESS_P2P_DRD (1 << 1)
|
||||
#define USB_WIRELESS_BEACON_MASK (3 << 2)
|
||||
#define USB_WIRELESS_BEACON_SELF (1 << 2)
|
||||
#define USB_WIRELESS_BEACON_DIRECTED (2 << 2)
|
||||
#define USB_WIRELESS_BEACON_NONE (3 << 2)
|
||||
__le16 wPHYRates; /* bit rates, Mbps */
|
||||
#define USB_WIRELESS_PHY_53 (1 << 0) /* always set */
|
||||
#define USB_WIRELESS_PHY_80 (1 << 1)
|
||||
#define USB_WIRELESS_PHY_107 (1 << 2) /* always set */
|
||||
#define USB_WIRELESS_PHY_160 (1 << 3)
|
||||
#define USB_WIRELESS_PHY_200 (1 << 4) /* always set */
|
||||
#define USB_WIRELESS_PHY_320 (1 << 5)
|
||||
#define USB_WIRELESS_PHY_400 (1 << 6)
|
||||
#define USB_WIRELESS_PHY_480 (1 << 7)
|
||||
__u8 bmTFITXPowerInfo; /* TFI power levels */
|
||||
__u8 bmFFITXPowerInfo; /* FFI power levels */
|
||||
__le16 bmBandGroup;
|
||||
__u8 bReserved;
|
||||
} __attribute__((packed));
|
||||
|
||||
/* USB 2.0 Extension descriptor */
|
||||
#define USB_CAP_TYPE_EXT 2
|
||||
|
||||
struct usb_ext_cap_descriptor { /* Link Power Management */
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDevCapabilityType;
|
||||
__le32 bmAttributes;
|
||||
#define USB_LPM_SUPPORT (1 << 1) /* supports LPM */
|
||||
#define USB_BESL_SUPPORT (1 << 2) /* supports BESL */
|
||||
#define USB_BESL_BASELINE_VALID (1 << 3) /* Baseline BESL valid*/
|
||||
#define USB_BESL_DEEP_VALID (1 << 4) /* Deep BESL valid */
|
||||
#define USB_GET_BESL_BASELINE(p) (((p) & (0xf << 8)) >> 8)
|
||||
#define USB_GET_BESL_DEEP(p) (((p) & (0xf << 12)) >> 12)
|
||||
} __attribute__((packed));
|
||||
|
||||
#define USB_DT_USB_EXT_CAP_SIZE 7
|
||||
|
||||
/*
|
||||
* SuperSpeed USB Capability descriptor: Defines the set of SuperSpeed USB
|
||||
* specific device level capabilities
|
||||
*/
|
||||
#define USB_SS_CAP_TYPE 3
|
||||
struct usb_ss_cap_descriptor { /* Link Power Management */
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDevCapabilityType;
|
||||
__u8 bmAttributes;
|
||||
#define USB_LTM_SUPPORT (1 << 1) /* supports LTM */
|
||||
__le16 wSpeedSupported;
|
||||
#define USB_LOW_SPEED_OPERATION (1) /* Low speed operation */
|
||||
#define USB_FULL_SPEED_OPERATION (1 << 1) /* Full speed operation */
|
||||
#define USB_HIGH_SPEED_OPERATION (1 << 2) /* High speed operation */
|
||||
#define USB_5GBPS_OPERATION (1 << 3) /* Operation at 5Gbps */
|
||||
__u8 bFunctionalitySupport;
|
||||
__u8 bU1devExitLat;
|
||||
__le16 bU2DevExitLat;
|
||||
} __attribute__((packed));
|
||||
|
||||
#define USB_DT_USB_SS_CAP_SIZE 10
|
||||
|
||||
/*
|
||||
* Container ID Capability descriptor: Defines the instance unique ID used to
|
||||
* identify the instance across all operating modes
|
||||
*/
|
||||
#define CONTAINER_ID_TYPE 4
|
||||
struct usb_ss_container_id_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDevCapabilityType;
|
||||
__u8 bReserved;
|
||||
__u8 ContainerID[16]; /* 128-bit number */
|
||||
} __attribute__((packed));
|
||||
|
||||
#define USB_DT_USB_SS_CONTN_ID_SIZE 20
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_WIRELESS_ENDPOINT_COMP: companion descriptor associated with
|
||||
* each endpoint descriptor for a wireless device
|
||||
*/
|
||||
struct usb_wireless_ep_comp_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__u8 bMaxBurst;
|
||||
__u8 bMaxSequence;
|
||||
__le16 wMaxStreamDelay;
|
||||
__le16 wOverTheAirPacketSize;
|
||||
__u8 bOverTheAirInterval;
|
||||
__u8 bmCompAttributes;
|
||||
#define USB_ENDPOINT_SWITCH_MASK 0x03 /* in bmCompAttributes */
|
||||
#define USB_ENDPOINT_SWITCH_NO 0
|
||||
#define USB_ENDPOINT_SWITCH_SWITCH 1
|
||||
#define USB_ENDPOINT_SWITCH_SCALE 2
|
||||
} __attribute__((packed));
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_REQ_SET_HANDSHAKE is a four-way handshake used between a wireless
|
||||
* host and a device for connection set up, mutual authentication, and
|
||||
* exchanging short lived session keys. The handshake depends on a CC.
|
||||
*/
|
||||
struct usb_handshake {
|
||||
__u8 bMessageNumber;
|
||||
__u8 bStatus;
|
||||
__u8 tTKID[3];
|
||||
__u8 bReserved;
|
||||
__u8 CDID[16];
|
||||
__u8 nonce[16];
|
||||
__u8 MIC[8];
|
||||
} __attribute__((packed));
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_REQ_SET_CONNECTION modifies or revokes a connection context (CC).
|
||||
* A CC may also be set up using non-wireless secure channels (including
|
||||
* wired USB!), and some devices may support CCs with multiple hosts.
|
||||
*/
|
||||
struct usb_connection_context {
|
||||
__u8 CHID[16]; /* persistent host id */
|
||||
__u8 CDID[16]; /* device id (unique w/in host context) */
|
||||
__u8 CK[16]; /* connection key */
|
||||
} __attribute__((packed));
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB 2.0 defines three speeds, here's how Linux identifies them */
|
||||
|
||||
enum usb_device_speed {
|
||||
USB_SPEED_UNKNOWN = 0, /* enumerating */
|
||||
USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */
|
||||
USB_SPEED_HIGH, /* usb 2.0 */
|
||||
USB_SPEED_WIRELESS, /* wireless (usb 2.5) */
|
||||
USB_SPEED_SUPER, /* usb 3.0 */
|
||||
};
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
/**
|
||||
* usb_speed_string() - Returns human readable-name of the speed.
|
||||
@ -919,86 +43,4 @@ enum usb_device_speed {
|
||||
*/
|
||||
extern const char *usb_speed_string(enum usb_device_speed speed);
|
||||
|
||||
#endif
|
||||
|
||||
enum usb_device_state {
|
||||
/* NOTATTACHED isn't in the USB spec, and this state acts
|
||||
* the same as ATTACHED ... but it's clearer this way.
|
||||
*/
|
||||
USB_STATE_NOTATTACHED = 0,
|
||||
|
||||
/* chapter 9 and authentication (wireless) device states */
|
||||
USB_STATE_ATTACHED,
|
||||
USB_STATE_POWERED, /* wired */
|
||||
USB_STATE_RECONNECTING, /* auth */
|
||||
USB_STATE_UNAUTHENTICATED, /* auth */
|
||||
USB_STATE_DEFAULT, /* limited function */
|
||||
USB_STATE_ADDRESS,
|
||||
USB_STATE_CONFIGURED, /* most functions */
|
||||
|
||||
USB_STATE_SUSPENDED
|
||||
|
||||
/* NOTE: there are actually four different SUSPENDED
|
||||
* states, returning to POWERED, DEFAULT, ADDRESS, or
|
||||
* CONFIGURED respectively when SOF tokens flow again.
|
||||
* At this level there's no difference between L1 and L2
|
||||
* suspend states. (L2 being original USB 1.1 suspend.)
|
||||
*/
|
||||
};
|
||||
|
||||
enum usb3_link_state {
|
||||
USB3_LPM_U0 = 0,
|
||||
USB3_LPM_U1,
|
||||
USB3_LPM_U2,
|
||||
USB3_LPM_U3
|
||||
};
|
||||
|
||||
/*
|
||||
* A U1 timeout of 0x0 means the parent hub will reject any transitions to U1.
|
||||
* 0xff means the parent hub will accept transitions to U1, but will not
|
||||
* initiate a transition.
|
||||
*
|
||||
* A U1 timeout of 0x1 to 0x7F also causes the hub to initiate a transition to
|
||||
* U1 after that many microseconds. Timeouts of 0x80 to 0xFE are reserved
|
||||
* values.
|
||||
*
|
||||
* A U2 timeout of 0x0 means the parent hub will reject any transitions to U2.
|
||||
* 0xff means the parent hub will accept transitions to U2, but will not
|
||||
* initiate a transition.
|
||||
*
|
||||
* A U2 timeout of 0x1 to 0xFE also causes the hub to initiate a transition to
|
||||
* U2 after N*256 microseconds. Therefore a U2 timeout value of 0x1 means a U2
|
||||
* idle timer of 256 microseconds, 0x2 means 512 microseconds, 0xFE means
|
||||
* 65.024ms.
|
||||
*/
|
||||
#define USB3_LPM_DISABLED 0x0
|
||||
#define USB3_LPM_U1_MAX_TIMEOUT 0x7F
|
||||
#define USB3_LPM_U2_MAX_TIMEOUT 0xFE
|
||||
#define USB3_LPM_DEVICE_INITIATED 0xFF
|
||||
|
||||
struct usb_set_sel_req {
|
||||
__u8 u1_sel;
|
||||
__u8 u1_pel;
|
||||
__le16 u2_sel;
|
||||
__le16 u2_pel;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/*
|
||||
* The Set System Exit Latency control transfer provides one byte each for
|
||||
* U1 SEL and U1 PEL, so the max exit latency is 0xFF. U2 SEL and U2 PEL each
|
||||
* are two bytes long.
|
||||
*/
|
||||
#define USB3_LPM_MAX_U1_SEL_PEL 0xFF
|
||||
#define USB3_LPM_MAX_U2_SEL_PEL 0xFFFF
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* As per USB compliance update, a device that is actively drawing
|
||||
* more than 100mA from USB must report itself as bus-powered in
|
||||
* the GetStatus(DEVICE) call.
|
||||
* http://compliance.usb.org/index.asp?UpdateFile=Electrical&Format=Standard#34
|
||||
*/
|
||||
#define USB_SELF_POWER_VBUS_MAX_DRAW 100
|
||||
|
||||
#endif /* __LINUX_USB_CH9_H */
|
||||
|
@ -1,171 +1,8 @@
|
||||
#ifndef __LINUX_FUNCTIONFS_H__
|
||||
#define __LINUX_FUNCTIONFS_H__ 1
|
||||
|
||||
#include <uapi/linux/usb/functionfs.h>
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/ioctl.h>
|
||||
|
||||
#include <linux/usb/ch9.h>
|
||||
|
||||
|
||||
enum {
|
||||
FUNCTIONFS_DESCRIPTORS_MAGIC = 1,
|
||||
FUNCTIONFS_STRINGS_MAGIC = 2
|
||||
};
|
||||
|
||||
|
||||
#ifndef __KERNEL__
|
||||
|
||||
/* Descriptor of an non-audio endpoint */
|
||||
struct usb_endpoint_descriptor_no_audio {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__u8 bEndpointAddress;
|
||||
__u8 bmAttributes;
|
||||
__le16 wMaxPacketSize;
|
||||
__u8 bInterval;
|
||||
} __attribute__((packed));
|
||||
|
||||
|
||||
/*
|
||||
* All numbers must be in little endian order.
|
||||
*/
|
||||
|
||||
struct usb_functionfs_descs_head {
|
||||
__le32 magic;
|
||||
__le32 length;
|
||||
__le32 fs_count;
|
||||
__le32 hs_count;
|
||||
} __attribute__((packed));
|
||||
|
||||
/*
|
||||
* Descriptors format:
|
||||
*
|
||||
* | off | name | type | description |
|
||||
* |-----+-----------+--------------+--------------------------------------|
|
||||
* | 0 | magic | LE32 | FUNCTIONFS_{FS,HS}_DESCRIPTORS_MAGIC |
|
||||
* | 4 | length | LE32 | length of the whole data chunk |
|
||||
* | 8 | fs_count | LE32 | number of full-speed descriptors |
|
||||
* | 12 | hs_count | LE32 | number of high-speed descriptors |
|
||||
* | 16 | fs_descrs | Descriptor[] | list of full-speed descriptors |
|
||||
* | | hs_descrs | Descriptor[] | list of high-speed descriptors |
|
||||
*
|
||||
* descs are just valid USB descriptors and have the following format:
|
||||
*
|
||||
* | off | name | type | description |
|
||||
* |-----+-----------------+------+--------------------------|
|
||||
* | 0 | bLength | U8 | length of the descriptor |
|
||||
* | 1 | bDescriptorType | U8 | descriptor type |
|
||||
* | 2 | payload | | descriptor's payload |
|
||||
*/
|
||||
|
||||
struct usb_functionfs_strings_head {
|
||||
__le32 magic;
|
||||
__le32 length;
|
||||
__le32 str_count;
|
||||
__le32 lang_count;
|
||||
} __attribute__((packed));
|
||||
|
||||
/*
|
||||
* Strings format:
|
||||
*
|
||||
* | off | name | type | description |
|
||||
* |-----+------------+-----------------------+----------------------------|
|
||||
* | 0 | magic | LE32 | FUNCTIONFS_STRINGS_MAGIC |
|
||||
* | 4 | length | LE32 | length of the data chunk |
|
||||
* | 8 | str_count | LE32 | number of strings |
|
||||
* | 12 | lang_count | LE32 | number of languages |
|
||||
* | 16 | stringtab | StringTab[lang_count] | table of strings per lang |
|
||||
*
|
||||
* For each language there is one stringtab entry (ie. there are lang_count
|
||||
* stringtab entires). Each StringTab has following format:
|
||||
*
|
||||
* | off | name | type | description |
|
||||
* |-----+---------+-------------------+------------------------------------|
|
||||
* | 0 | lang | LE16 | language code |
|
||||
* | 2 | strings | String[str_count] | array of strings in given language |
|
||||
*
|
||||
* For each string there is one strings entry (ie. there are str_count
|
||||
* string entries). Each String is a NUL terminated string encoded in
|
||||
* UTF-8.
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Events are delivered on the ep0 file descriptor, when the user mode driver
|
||||
* reads from this file descriptor after writing the descriptors. Don't
|
||||
* stop polling this descriptor.
|
||||
*/
|
||||
|
||||
enum usb_functionfs_event_type {
|
||||
FUNCTIONFS_BIND,
|
||||
FUNCTIONFS_UNBIND,
|
||||
|
||||
FUNCTIONFS_ENABLE,
|
||||
FUNCTIONFS_DISABLE,
|
||||
|
||||
FUNCTIONFS_SETUP,
|
||||
|
||||
FUNCTIONFS_SUSPEND,
|
||||
FUNCTIONFS_RESUME
|
||||
};
|
||||
|
||||
/* NOTE: this structure must stay the same size and layout on
|
||||
* both 32-bit and 64-bit kernels.
|
||||
*/
|
||||
struct usb_functionfs_event {
|
||||
union {
|
||||
/* SETUP: packet; DATA phase i/o precedes next event
|
||||
*(setup.bmRequestType & USB_DIR_IN) flags direction */
|
||||
struct usb_ctrlrequest setup;
|
||||
} __attribute__((packed)) u;
|
||||
|
||||
/* enum usb_functionfs_event_type */
|
||||
__u8 type;
|
||||
__u8 _pad[3];
|
||||
} __attribute__((packed));
|
||||
|
||||
|
||||
/* Endpoint ioctls */
|
||||
/* The same as in gadgetfs */
|
||||
|
||||
/* IN transfers may be reported to the gadget driver as complete
|
||||
* when the fifo is loaded, before the host reads the data;
|
||||
* OUT transfers may be reported to the host's "client" driver as
|
||||
* complete when they're sitting in the FIFO unread.
|
||||
* THIS returns how many bytes are "unclaimed" in the endpoint fifo
|
||||
* (needed for precise fault handling, when the hardware allows it)
|
||||
*/
|
||||
#define FUNCTIONFS_FIFO_STATUS _IO('g', 1)
|
||||
|
||||
/* discards any unclaimed data in the fifo. */
|
||||
#define FUNCTIONFS_FIFO_FLUSH _IO('g', 2)
|
||||
|
||||
/* resets endpoint halt+toggle; used to implement set_interface.
|
||||
* some hardware (like pxa2xx) can't support this.
|
||||
*/
|
||||
#define FUNCTIONFS_CLEAR_HALT _IO('g', 3)
|
||||
|
||||
/* Specific for functionfs */
|
||||
|
||||
/*
|
||||
* Returns reverse mapping of an interface. Called on EP0. If there
|
||||
* is no such interface returns -EDOM. If function is not active
|
||||
* returns -ENODEV.
|
||||
*/
|
||||
#define FUNCTIONFS_INTERFACE_REVMAP _IO('g', 128)
|
||||
|
||||
/*
|
||||
* Returns real bEndpointAddress of an endpoint. If function is not
|
||||
* active returns -ENODEV.
|
||||
*/
|
||||
#define FUNCTIONFS_ENDPOINT_REVMAP _IO('g', 129)
|
||||
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
struct ffs_data;
|
||||
struct usb_composite_dev;
|
||||
@ -197,5 +34,3 @@ static void functionfs_release_dev_callback(struct ffs_data *ffs_data)
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1 +1,11 @@
|
||||
# UAPI Header export list
|
||||
header-y += audio.h
|
||||
header-y += cdc.h
|
||||
header-y += ch11.h
|
||||
header-y += ch9.h
|
||||
header-y += functionfs.h
|
||||
header-y += g_printer.h
|
||||
header-y += gadgetfs.h
|
||||
header-y += midi.h
|
||||
header-y += tmc.h
|
||||
header-y += video.h
|
||||
|
545
include/uapi/linux/usb/audio.h
Normal file
545
include/uapi/linux/usb/audio.h
Normal file
@ -0,0 +1,545 @@
|
||||
/*
|
||||
* <linux/usb/audio.h> -- USB Audio definitions.
|
||||
*
|
||||
* Copyright (C) 2006 Thumtronics Pty Ltd.
|
||||
* Developed for Thumtronics by Grey Innovation
|
||||
* Ben Williamson <ben.williamson@greyinnovation.com>
|
||||
*
|
||||
* This software is distributed under the terms of the GNU General Public
|
||||
* License ("GPL") version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This file holds USB constants and structures defined
|
||||
* by the USB Device Class Definition for Audio Devices.
|
||||
* Comments below reference relevant sections of that document:
|
||||
*
|
||||
* http://www.usb.org/developers/devclass_docs/audio10.pdf
|
||||
*
|
||||
* Types and defines in this file are either specific to version 1.0 of
|
||||
* this standard or common for newer versions.
|
||||
*/
|
||||
|
||||
#ifndef _UAPI__LINUX_USB_AUDIO_H
|
||||
#define _UAPI__LINUX_USB_AUDIO_H
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
/* bInterfaceProtocol values to denote the version of the standard used */
|
||||
#define UAC_VERSION_1 0x00
|
||||
#define UAC_VERSION_2 0x20
|
||||
|
||||
/* A.2 Audio Interface Subclass Codes */
|
||||
#define USB_SUBCLASS_AUDIOCONTROL 0x01
|
||||
#define USB_SUBCLASS_AUDIOSTREAMING 0x02
|
||||
#define USB_SUBCLASS_MIDISTREAMING 0x03
|
||||
|
||||
/* A.5 Audio Class-Specific AC Interface Descriptor Subtypes */
|
||||
#define UAC_HEADER 0x01
|
||||
#define UAC_INPUT_TERMINAL 0x02
|
||||
#define UAC_OUTPUT_TERMINAL 0x03
|
||||
#define UAC_MIXER_UNIT 0x04
|
||||
#define UAC_SELECTOR_UNIT 0x05
|
||||
#define UAC_FEATURE_UNIT 0x06
|
||||
#define UAC1_PROCESSING_UNIT 0x07
|
||||
#define UAC1_EXTENSION_UNIT 0x08
|
||||
|
||||
/* A.6 Audio Class-Specific AS Interface Descriptor Subtypes */
|
||||
#define UAC_AS_GENERAL 0x01
|
||||
#define UAC_FORMAT_TYPE 0x02
|
||||
#define UAC_FORMAT_SPECIFIC 0x03
|
||||
|
||||
/* A.7 Processing Unit Process Types */
|
||||
#define UAC_PROCESS_UNDEFINED 0x00
|
||||
#define UAC_PROCESS_UP_DOWNMIX 0x01
|
||||
#define UAC_PROCESS_DOLBY_PROLOGIC 0x02
|
||||
#define UAC_PROCESS_STEREO_EXTENDER 0x03
|
||||
#define UAC_PROCESS_REVERB 0x04
|
||||
#define UAC_PROCESS_CHORUS 0x05
|
||||
#define UAC_PROCESS_DYN_RANGE_COMP 0x06
|
||||
|
||||
/* A.8 Audio Class-Specific Endpoint Descriptor Subtypes */
|
||||
#define UAC_EP_GENERAL 0x01
|
||||
|
||||
/* A.9 Audio Class-Specific Request Codes */
|
||||
#define UAC_SET_ 0x00
|
||||
#define UAC_GET_ 0x80
|
||||
|
||||
#define UAC__CUR 0x1
|
||||
#define UAC__MIN 0x2
|
||||
#define UAC__MAX 0x3
|
||||
#define UAC__RES 0x4
|
||||
#define UAC__MEM 0x5
|
||||
|
||||
#define UAC_SET_CUR (UAC_SET_ | UAC__CUR)
|
||||
#define UAC_GET_CUR (UAC_GET_ | UAC__CUR)
|
||||
#define UAC_SET_MIN (UAC_SET_ | UAC__MIN)
|
||||
#define UAC_GET_MIN (UAC_GET_ | UAC__MIN)
|
||||
#define UAC_SET_MAX (UAC_SET_ | UAC__MAX)
|
||||
#define UAC_GET_MAX (UAC_GET_ | UAC__MAX)
|
||||
#define UAC_SET_RES (UAC_SET_ | UAC__RES)
|
||||
#define UAC_GET_RES (UAC_GET_ | UAC__RES)
|
||||
#define UAC_SET_MEM (UAC_SET_ | UAC__MEM)
|
||||
#define UAC_GET_MEM (UAC_GET_ | UAC__MEM)
|
||||
|
||||
#define UAC_GET_STAT 0xff
|
||||
|
||||
/* A.10 Control Selector Codes */
|
||||
|
||||
/* A.10.1 Terminal Control Selectors */
|
||||
#define UAC_TERM_COPY_PROTECT 0x01
|
||||
|
||||
/* A.10.2 Feature Unit Control Selectors */
|
||||
#define UAC_FU_MUTE 0x01
|
||||
#define UAC_FU_VOLUME 0x02
|
||||
#define UAC_FU_BASS 0x03
|
||||
#define UAC_FU_MID 0x04
|
||||
#define UAC_FU_TREBLE 0x05
|
||||
#define UAC_FU_GRAPHIC_EQUALIZER 0x06
|
||||
#define UAC_FU_AUTOMATIC_GAIN 0x07
|
||||
#define UAC_FU_DELAY 0x08
|
||||
#define UAC_FU_BASS_BOOST 0x09
|
||||
#define UAC_FU_LOUDNESS 0x0a
|
||||
|
||||
#define UAC_CONTROL_BIT(CS) (1 << ((CS) - 1))
|
||||
|
||||
/* A.10.3.1 Up/Down-mix Processing Unit Controls Selectors */
|
||||
#define UAC_UD_ENABLE 0x01
|
||||
#define UAC_UD_MODE_SELECT 0x02
|
||||
|
||||
/* A.10.3.2 Dolby Prologic (tm) Processing Unit Controls Selectors */
|
||||
#define UAC_DP_ENABLE 0x01
|
||||
#define UAC_DP_MODE_SELECT 0x02
|
||||
|
||||
/* A.10.3.3 3D Stereo Extender Processing Unit Control Selectors */
|
||||
#define UAC_3D_ENABLE 0x01
|
||||
#define UAC_3D_SPACE 0x02
|
||||
|
||||
/* A.10.3.4 Reverberation Processing Unit Control Selectors */
|
||||
#define UAC_REVERB_ENABLE 0x01
|
||||
#define UAC_REVERB_LEVEL 0x02
|
||||
#define UAC_REVERB_TIME 0x03
|
||||
#define UAC_REVERB_FEEDBACK 0x04
|
||||
|
||||
/* A.10.3.5 Chorus Processing Unit Control Selectors */
|
||||
#define UAC_CHORUS_ENABLE 0x01
|
||||
#define UAC_CHORUS_LEVEL 0x02
|
||||
#define UAC_CHORUS_RATE 0x03
|
||||
#define UAC_CHORUS_DEPTH 0x04
|
||||
|
||||
/* A.10.3.6 Dynamic Range Compressor Unit Control Selectors */
|
||||
#define UAC_DCR_ENABLE 0x01
|
||||
#define UAC_DCR_RATE 0x02
|
||||
#define UAC_DCR_MAXAMPL 0x03
|
||||
#define UAC_DCR_THRESHOLD 0x04
|
||||
#define UAC_DCR_ATTACK_TIME 0x05
|
||||
#define UAC_DCR_RELEASE_TIME 0x06
|
||||
|
||||
/* A.10.4 Extension Unit Control Selectors */
|
||||
#define UAC_XU_ENABLE 0x01
|
||||
|
||||
/* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */
|
||||
#define UAC_MS_HEADER 0x01
|
||||
#define UAC_MIDI_IN_JACK 0x02
|
||||
#define UAC_MIDI_OUT_JACK 0x03
|
||||
|
||||
/* MIDI - A.1 MS Class-Specific Endpoint Descriptor Subtypes */
|
||||
#define UAC_MS_GENERAL 0x01
|
||||
|
||||
/* Terminals - 2.1 USB Terminal Types */
|
||||
#define UAC_TERMINAL_UNDEFINED 0x100
|
||||
#define UAC_TERMINAL_STREAMING 0x101
|
||||
#define UAC_TERMINAL_VENDOR_SPEC 0x1FF
|
||||
|
||||
/* Terminal Control Selectors */
|
||||
/* 4.3.2 Class-Specific AC Interface Descriptor */
|
||||
struct uac1_ac_header_descriptor {
|
||||
__u8 bLength; /* 8 + n */
|
||||
__u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
|
||||
__u8 bDescriptorSubtype; /* UAC_MS_HEADER */
|
||||
__le16 bcdADC; /* 0x0100 */
|
||||
__le16 wTotalLength; /* includes Unit and Terminal desc. */
|
||||
__u8 bInCollection; /* n */
|
||||
__u8 baInterfaceNr[]; /* [n] */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define UAC_DT_AC_HEADER_SIZE(n) (8 + (n))
|
||||
|
||||
/* As above, but more useful for defining your own descriptors: */
|
||||
#define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n) \
|
||||
struct uac1_ac_header_descriptor_##n { \
|
||||
__u8 bLength; \
|
||||
__u8 bDescriptorType; \
|
||||
__u8 bDescriptorSubtype; \
|
||||
__le16 bcdADC; \
|
||||
__le16 wTotalLength; \
|
||||
__u8 bInCollection; \
|
||||
__u8 baInterfaceNr[n]; \
|
||||
} __attribute__ ((packed))
|
||||
|
||||
/* 4.3.2.1 Input Terminal Descriptor */
|
||||
struct uac_input_terminal_descriptor {
|
||||
__u8 bLength; /* in bytes: 12 */
|
||||
__u8 bDescriptorType; /* CS_INTERFACE descriptor type */
|
||||
__u8 bDescriptorSubtype; /* INPUT_TERMINAL descriptor subtype */
|
||||
__u8 bTerminalID; /* Constant uniquely terminal ID */
|
||||
__le16 wTerminalType; /* USB Audio Terminal Types */
|
||||
__u8 bAssocTerminal; /* ID of the Output Terminal associated */
|
||||
__u8 bNrChannels; /* Number of logical output channels */
|
||||
__le16 wChannelConfig;
|
||||
__u8 iChannelNames;
|
||||
__u8 iTerminal;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define UAC_DT_INPUT_TERMINAL_SIZE 12
|
||||
|
||||
/* Terminals - 2.2 Input Terminal Types */
|
||||
#define UAC_INPUT_TERMINAL_UNDEFINED 0x200
|
||||
#define UAC_INPUT_TERMINAL_MICROPHONE 0x201
|
||||
#define UAC_INPUT_TERMINAL_DESKTOP_MICROPHONE 0x202
|
||||
#define UAC_INPUT_TERMINAL_PERSONAL_MICROPHONE 0x203
|
||||
#define UAC_INPUT_TERMINAL_OMNI_DIR_MICROPHONE 0x204
|
||||
#define UAC_INPUT_TERMINAL_MICROPHONE_ARRAY 0x205
|
||||
#define UAC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY 0x206
|
||||
|
||||
/* Terminals - control selectors */
|
||||
|
||||
#define UAC_TERMINAL_CS_COPY_PROTECT_CONTROL 0x01
|
||||
|
||||
/* 4.3.2.2 Output Terminal Descriptor */
|
||||
struct uac1_output_terminal_descriptor {
|
||||
__u8 bLength; /* in bytes: 9 */
|
||||
__u8 bDescriptorType; /* CS_INTERFACE descriptor type */
|
||||
__u8 bDescriptorSubtype; /* OUTPUT_TERMINAL descriptor subtype */
|
||||
__u8 bTerminalID; /* Constant uniquely terminal ID */
|
||||
__le16 wTerminalType; /* USB Audio Terminal Types */
|
||||
__u8 bAssocTerminal; /* ID of the Input Terminal associated */
|
||||
__u8 bSourceID; /* ID of the connected Unit or Terminal*/
|
||||
__u8 iTerminal;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define UAC_DT_OUTPUT_TERMINAL_SIZE 9
|
||||
|
||||
/* Terminals - 2.3 Output Terminal Types */
|
||||
#define UAC_OUTPUT_TERMINAL_UNDEFINED 0x300
|
||||
#define UAC_OUTPUT_TERMINAL_SPEAKER 0x301
|
||||
#define UAC_OUTPUT_TERMINAL_HEADPHONES 0x302
|
||||
#define UAC_OUTPUT_TERMINAL_HEAD_MOUNTED_DISPLAY_AUDIO 0x303
|
||||
#define UAC_OUTPUT_TERMINAL_DESKTOP_SPEAKER 0x304
|
||||
#define UAC_OUTPUT_TERMINAL_ROOM_SPEAKER 0x305
|
||||
#define UAC_OUTPUT_TERMINAL_COMMUNICATION_SPEAKER 0x306
|
||||
#define UAC_OUTPUT_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER 0x307
|
||||
|
||||
/* Set bControlSize = 2 as default setting */
|
||||
#define UAC_DT_FEATURE_UNIT_SIZE(ch) (7 + ((ch) + 1) * 2)
|
||||
|
||||
/* As above, but more useful for defining your own descriptors: */
|
||||
#define DECLARE_UAC_FEATURE_UNIT_DESCRIPTOR(ch) \
|
||||
struct uac_feature_unit_descriptor_##ch { \
|
||||
__u8 bLength; \
|
||||
__u8 bDescriptorType; \
|
||||
__u8 bDescriptorSubtype; \
|
||||
__u8 bUnitID; \
|
||||
__u8 bSourceID; \
|
||||
__u8 bControlSize; \
|
||||
__le16 bmaControls[ch + 1]; \
|
||||
__u8 iFeature; \
|
||||
} __attribute__ ((packed))
|
||||
|
||||
/* 4.3.2.3 Mixer Unit Descriptor */
|
||||
struct uac_mixer_unit_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubtype;
|
||||
__u8 bUnitID;
|
||||
__u8 bNrInPins;
|
||||
__u8 baSourceID[];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
static inline __u8 uac_mixer_unit_bNrChannels(struct uac_mixer_unit_descriptor *desc)
|
||||
{
|
||||
return desc->baSourceID[desc->bNrInPins];
|
||||
}
|
||||
|
||||
static inline __u32 uac_mixer_unit_wChannelConfig(struct uac_mixer_unit_descriptor *desc,
|
||||
int protocol)
|
||||
{
|
||||
if (protocol == UAC_VERSION_1)
|
||||
return (desc->baSourceID[desc->bNrInPins + 2] << 8) |
|
||||
desc->baSourceID[desc->bNrInPins + 1];
|
||||
else
|
||||
return (desc->baSourceID[desc->bNrInPins + 4] << 24) |
|
||||
(desc->baSourceID[desc->bNrInPins + 3] << 16) |
|
||||
(desc->baSourceID[desc->bNrInPins + 2] << 8) |
|
||||
(desc->baSourceID[desc->bNrInPins + 1]);
|
||||
}
|
||||
|
||||
static inline __u8 uac_mixer_unit_iChannelNames(struct uac_mixer_unit_descriptor *desc,
|
||||
int protocol)
|
||||
{
|
||||
return (protocol == UAC_VERSION_1) ?
|
||||
desc->baSourceID[desc->bNrInPins + 3] :
|
||||
desc->baSourceID[desc->bNrInPins + 5];
|
||||
}
|
||||
|
||||
static inline __u8 *uac_mixer_unit_bmControls(struct uac_mixer_unit_descriptor *desc,
|
||||
int protocol)
|
||||
{
|
||||
return (protocol == UAC_VERSION_1) ?
|
||||
&desc->baSourceID[desc->bNrInPins + 4] :
|
||||
&desc->baSourceID[desc->bNrInPins + 6];
|
||||
}
|
||||
|
||||
static inline __u8 uac_mixer_unit_iMixer(struct uac_mixer_unit_descriptor *desc)
|
||||
{
|
||||
__u8 *raw = (__u8 *) desc;
|
||||
return raw[desc->bLength - 1];
|
||||
}
|
||||
|
||||
/* 4.3.2.4 Selector Unit Descriptor */
|
||||
struct uac_selector_unit_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubtype;
|
||||
__u8 bUintID;
|
||||
__u8 bNrInPins;
|
||||
__u8 baSourceID[];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
static inline __u8 uac_selector_unit_iSelector(struct uac_selector_unit_descriptor *desc)
|
||||
{
|
||||
__u8 *raw = (__u8 *) desc;
|
||||
return raw[desc->bLength - 1];
|
||||
}
|
||||
|
||||
/* 4.3.2.5 Feature Unit Descriptor */
|
||||
struct uac_feature_unit_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubtype;
|
||||
__u8 bUnitID;
|
||||
__u8 bSourceID;
|
||||
__u8 bControlSize;
|
||||
__u8 bmaControls[0]; /* variable length */
|
||||
} __attribute__((packed));
|
||||
|
||||
static inline __u8 uac_feature_unit_iFeature(struct uac_feature_unit_descriptor *desc)
|
||||
{
|
||||
__u8 *raw = (__u8 *) desc;
|
||||
return raw[desc->bLength - 1];
|
||||
}
|
||||
|
||||
/* 4.3.2.6 Processing Unit Descriptors */
|
||||
struct uac_processing_unit_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubtype;
|
||||
__u8 bUnitID;
|
||||
__u16 wProcessType;
|
||||
__u8 bNrInPins;
|
||||
__u8 baSourceID[];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
static inline __u8 uac_processing_unit_bNrChannels(struct uac_processing_unit_descriptor *desc)
|
||||
{
|
||||
return desc->baSourceID[desc->bNrInPins];
|
||||
}
|
||||
|
||||
static inline __u32 uac_processing_unit_wChannelConfig(struct uac_processing_unit_descriptor *desc,
|
||||
int protocol)
|
||||
{
|
||||
if (protocol == UAC_VERSION_1)
|
||||
return (desc->baSourceID[desc->bNrInPins + 2] << 8) |
|
||||
desc->baSourceID[desc->bNrInPins + 1];
|
||||
else
|
||||
return (desc->baSourceID[desc->bNrInPins + 4] << 24) |
|
||||
(desc->baSourceID[desc->bNrInPins + 3] << 16) |
|
||||
(desc->baSourceID[desc->bNrInPins + 2] << 8) |
|
||||
(desc->baSourceID[desc->bNrInPins + 1]);
|
||||
}
|
||||
|
||||
static inline __u8 uac_processing_unit_iChannelNames(struct uac_processing_unit_descriptor *desc,
|
||||
int protocol)
|
||||
{
|
||||
return (protocol == UAC_VERSION_1) ?
|
||||
desc->baSourceID[desc->bNrInPins + 3] :
|
||||
desc->baSourceID[desc->bNrInPins + 5];
|
||||
}
|
||||
|
||||
static inline __u8 uac_processing_unit_bControlSize(struct uac_processing_unit_descriptor *desc,
|
||||
int protocol)
|
||||
{
|
||||
return (protocol == UAC_VERSION_1) ?
|
||||
desc->baSourceID[desc->bNrInPins + 4] :
|
||||
desc->baSourceID[desc->bNrInPins + 6];
|
||||
}
|
||||
|
||||
static inline __u8 *uac_processing_unit_bmControls(struct uac_processing_unit_descriptor *desc,
|
||||
int protocol)
|
||||
{
|
||||
return (protocol == UAC_VERSION_1) ?
|
||||
&desc->baSourceID[desc->bNrInPins + 5] :
|
||||
&desc->baSourceID[desc->bNrInPins + 7];
|
||||
}
|
||||
|
||||
static inline __u8 uac_processing_unit_iProcessing(struct uac_processing_unit_descriptor *desc,
|
||||
int protocol)
|
||||
{
|
||||
__u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
|
||||
return desc->baSourceID[desc->bNrInPins + control_size];
|
||||
}
|
||||
|
||||
static inline __u8 *uac_processing_unit_specific(struct uac_processing_unit_descriptor *desc,
|
||||
int protocol)
|
||||
{
|
||||
__u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
|
||||
return &desc->baSourceID[desc->bNrInPins + control_size + 1];
|
||||
}
|
||||
|
||||
/* 4.5.2 Class-Specific AS Interface Descriptor */
|
||||
struct uac1_as_header_descriptor {
|
||||
__u8 bLength; /* in bytes: 7 */
|
||||
__u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
|
||||
__u8 bDescriptorSubtype; /* AS_GENERAL */
|
||||
__u8 bTerminalLink; /* Terminal ID of connected Terminal */
|
||||
__u8 bDelay; /* Delay introduced by the data path */
|
||||
__le16 wFormatTag; /* The Audio Data Format */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define UAC_DT_AS_HEADER_SIZE 7
|
||||
|
||||
/* Formats - A.1.1 Audio Data Format Type I Codes */
|
||||
#define UAC_FORMAT_TYPE_I_UNDEFINED 0x0
|
||||
#define UAC_FORMAT_TYPE_I_PCM 0x1
|
||||
#define UAC_FORMAT_TYPE_I_PCM8 0x2
|
||||
#define UAC_FORMAT_TYPE_I_IEEE_FLOAT 0x3
|
||||
#define UAC_FORMAT_TYPE_I_ALAW 0x4
|
||||
#define UAC_FORMAT_TYPE_I_MULAW 0x5
|
||||
|
||||
struct uac_format_type_i_continuous_descriptor {
|
||||
__u8 bLength; /* in bytes: 8 + (ns * 3) */
|
||||
__u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
|
||||
__u8 bDescriptorSubtype; /* FORMAT_TYPE */
|
||||
__u8 bFormatType; /* FORMAT_TYPE_1 */
|
||||
__u8 bNrChannels; /* physical channels in the stream */
|
||||
__u8 bSubframeSize; /* */
|
||||
__u8 bBitResolution;
|
||||
__u8 bSamFreqType;
|
||||
__u8 tLowerSamFreq[3];
|
||||
__u8 tUpperSamFreq[3];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define UAC_FORMAT_TYPE_I_CONTINUOUS_DESC_SIZE 14
|
||||
|
||||
struct uac_format_type_i_discrete_descriptor {
|
||||
__u8 bLength; /* in bytes: 8 + (ns * 3) */
|
||||
__u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
|
||||
__u8 bDescriptorSubtype; /* FORMAT_TYPE */
|
||||
__u8 bFormatType; /* FORMAT_TYPE_1 */
|
||||
__u8 bNrChannels; /* physical channels in the stream */
|
||||
__u8 bSubframeSize; /* */
|
||||
__u8 bBitResolution;
|
||||
__u8 bSamFreqType;
|
||||
__u8 tSamFreq[][3];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(n) \
|
||||
struct uac_format_type_i_discrete_descriptor_##n { \
|
||||
__u8 bLength; \
|
||||
__u8 bDescriptorType; \
|
||||
__u8 bDescriptorSubtype; \
|
||||
__u8 bFormatType; \
|
||||
__u8 bNrChannels; \
|
||||
__u8 bSubframeSize; \
|
||||
__u8 bBitResolution; \
|
||||
__u8 bSamFreqType; \
|
||||
__u8 tSamFreq[n][3]; \
|
||||
} __attribute__ ((packed))
|
||||
|
||||
#define UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(n) (8 + (n * 3))
|
||||
|
||||
struct uac_format_type_i_ext_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubtype;
|
||||
__u8 bFormatType;
|
||||
__u8 bSubslotSize;
|
||||
__u8 bBitResolution;
|
||||
__u8 bHeaderLength;
|
||||
__u8 bControlSize;
|
||||
__u8 bSideBandProtocol;
|
||||
} __attribute__((packed));
|
||||
|
||||
/* Formats - Audio Data Format Type I Codes */
|
||||
|
||||
#define UAC_FORMAT_TYPE_II_MPEG 0x1001
|
||||
#define UAC_FORMAT_TYPE_II_AC3 0x1002
|
||||
|
||||
struct uac_format_type_ii_discrete_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubtype;
|
||||
__u8 bFormatType;
|
||||
__le16 wMaxBitRate;
|
||||
__le16 wSamplesPerFrame;
|
||||
__u8 bSamFreqType;
|
||||
__u8 tSamFreq[][3];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct uac_format_type_ii_ext_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubtype;
|
||||
__u8 bFormatType;
|
||||
__u16 wMaxBitRate;
|
||||
__u16 wSamplesPerFrame;
|
||||
__u8 bHeaderLength;
|
||||
__u8 bSideBandProtocol;
|
||||
} __attribute__((packed));
|
||||
|
||||
/* type III */
|
||||
#define UAC_FORMAT_TYPE_III_IEC1937_AC3 0x2001
|
||||
#define UAC_FORMAT_TYPE_III_IEC1937_MPEG1_LAYER1 0x2002
|
||||
#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_NOEXT 0x2003
|
||||
#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_EXT 0x2004
|
||||
#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER1_LS 0x2005
|
||||
#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER23_LS 0x2006
|
||||
|
||||
/* Formats - A.2 Format Type Codes */
|
||||
#define UAC_FORMAT_TYPE_UNDEFINED 0x0
|
||||
#define UAC_FORMAT_TYPE_I 0x1
|
||||
#define UAC_FORMAT_TYPE_II 0x2
|
||||
#define UAC_FORMAT_TYPE_III 0x3
|
||||
#define UAC_EXT_FORMAT_TYPE_I 0x81
|
||||
#define UAC_EXT_FORMAT_TYPE_II 0x82
|
||||
#define UAC_EXT_FORMAT_TYPE_III 0x83
|
||||
|
||||
struct uac_iso_endpoint_descriptor {
|
||||
__u8 bLength; /* in bytes: 7 */
|
||||
__u8 bDescriptorType; /* USB_DT_CS_ENDPOINT */
|
||||
__u8 bDescriptorSubtype; /* EP_GENERAL */
|
||||
__u8 bmAttributes;
|
||||
__u8 bLockDelayUnits;
|
||||
__le16 wLockDelay;
|
||||
} __attribute__((packed));
|
||||
#define UAC_ISO_ENDPOINT_DESC_SIZE 7
|
||||
|
||||
#define UAC_EP_CS_ATTR_SAMPLE_RATE 0x01
|
||||
#define UAC_EP_CS_ATTR_PITCH_CONTROL 0x02
|
||||
#define UAC_EP_CS_ATTR_FILL_MAX 0x80
|
||||
|
||||
/* status word format (3.7.1.1) */
|
||||
|
||||
#define UAC1_STATUS_TYPE_ORIG_MASK 0x0f
|
||||
#define UAC1_STATUS_TYPE_ORIG_AUDIO_CONTROL_IF 0x0
|
||||
#define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_IF 0x1
|
||||
#define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_EP 0x2
|
||||
|
||||
#define UAC1_STATUS_TYPE_IRQ_PENDING (1 << 7)
|
||||
#define UAC1_STATUS_TYPE_MEM_CHANGED (1 << 6)
|
||||
|
||||
struct uac1_status_word {
|
||||
__u8 bStatusType;
|
||||
__u8 bOriginator;
|
||||
} __attribute__((packed));
|
||||
|
||||
|
||||
#endif /* _UAPI__LINUX_USB_AUDIO_H */
|
993
include/uapi/linux/usb/ch9.h
Normal file
993
include/uapi/linux/usb/ch9.h
Normal file
@ -0,0 +1,993 @@
|
||||
/*
|
||||
* This file holds USB constants and structures that are needed for
|
||||
* USB device APIs. These are used by the USB device model, which is
|
||||
* defined in chapter 9 of the USB 2.0 specification and in the
|
||||
* Wireless USB 1.0 (spread around). Linux has several APIs in C that
|
||||
* need these:
|
||||
*
|
||||
* - the master/host side Linux-USB kernel driver API;
|
||||
* - the "usbfs" user space API; and
|
||||
* - the Linux "gadget" slave/device/peripheral side driver API.
|
||||
*
|
||||
* USB 2.0 adds an additional "On The Go" (OTG) mode, which lets systems
|
||||
* act either as a USB master/host or as a USB slave/device. That means
|
||||
* the master and slave side APIs benefit from working well together.
|
||||
*
|
||||
* There's also "Wireless USB", using low power short range radios for
|
||||
* peripheral interconnection but otherwise building on the USB framework.
|
||||
*
|
||||
* Note all descriptors are declared '__attribute__((packed))' so that:
|
||||
*
|
||||
* [a] they never get padded, either internally (USB spec writers
|
||||
* probably handled that) or externally;
|
||||
*
|
||||
* [b] so that accessing bigger-than-a-bytes fields will never
|
||||
* generate bus errors on any platform, even when the location of
|
||||
* its descriptor inside a bundle isn't "naturally aligned", and
|
||||
*
|
||||
* [c] for consistency, removing all doubt even when it appears to
|
||||
* someone that the two other points are non-issues for that
|
||||
* particular descriptor type.
|
||||
*/
|
||||
|
||||
#ifndef _UAPI__LINUX_USB_CH9_H
|
||||
#define _UAPI__LINUX_USB_CH9_H
|
||||
|
||||
#include <linux/types.h> /* __u8 etc */
|
||||
#include <asm/byteorder.h> /* le16_to_cpu */
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* CONTROL REQUEST SUPPORT */
|
||||
|
||||
/*
|
||||
* USB directions
|
||||
*
|
||||
* This bit flag is used in endpoint descriptors' bEndpointAddress field.
|
||||
* It's also one of three fields in control requests bRequestType.
|
||||
*/
|
||||
#define USB_DIR_OUT 0 /* to device */
|
||||
#define USB_DIR_IN 0x80 /* to host */
|
||||
|
||||
/*
|
||||
* USB types, the second of three bRequestType fields
|
||||
*/
|
||||
#define USB_TYPE_MASK (0x03 << 5)
|
||||
#define USB_TYPE_STANDARD (0x00 << 5)
|
||||
#define USB_TYPE_CLASS (0x01 << 5)
|
||||
#define USB_TYPE_VENDOR (0x02 << 5)
|
||||
#define USB_TYPE_RESERVED (0x03 << 5)
|
||||
|
||||
/*
|
||||
* USB recipients, the third of three bRequestType fields
|
||||
*/
|
||||
#define USB_RECIP_MASK 0x1f
|
||||
#define USB_RECIP_DEVICE 0x00
|
||||
#define USB_RECIP_INTERFACE 0x01
|
||||
#define USB_RECIP_ENDPOINT 0x02
|
||||
#define USB_RECIP_OTHER 0x03
|
||||
/* From Wireless USB 1.0 */
|
||||
#define USB_RECIP_PORT 0x04
|
||||
#define USB_RECIP_RPIPE 0x05
|
||||
|
||||
/*
|
||||
* Standard requests, for the bRequest field of a SETUP packet.
|
||||
*
|
||||
* These are qualified by the bRequestType field, so that for example
|
||||
* TYPE_CLASS or TYPE_VENDOR specific feature flags could be retrieved
|
||||
* by a GET_STATUS request.
|
||||
*/
|
||||
#define USB_REQ_GET_STATUS 0x00
|
||||
#define USB_REQ_CLEAR_FEATURE 0x01
|
||||
#define USB_REQ_SET_FEATURE 0x03
|
||||
#define USB_REQ_SET_ADDRESS 0x05
|
||||
#define USB_REQ_GET_DESCRIPTOR 0x06
|
||||
#define USB_REQ_SET_DESCRIPTOR 0x07
|
||||
#define USB_REQ_GET_CONFIGURATION 0x08
|
||||
#define USB_REQ_SET_CONFIGURATION 0x09
|
||||
#define USB_REQ_GET_INTERFACE 0x0A
|
||||
#define USB_REQ_SET_INTERFACE 0x0B
|
||||
#define USB_REQ_SYNCH_FRAME 0x0C
|
||||
#define USB_REQ_SET_SEL 0x30
|
||||
#define USB_REQ_SET_ISOCH_DELAY 0x31
|
||||
|
||||
#define USB_REQ_SET_ENCRYPTION 0x0D /* Wireless USB */
|
||||
#define USB_REQ_GET_ENCRYPTION 0x0E
|
||||
#define USB_REQ_RPIPE_ABORT 0x0E
|
||||
#define USB_REQ_SET_HANDSHAKE 0x0F
|
||||
#define USB_REQ_RPIPE_RESET 0x0F
|
||||
#define USB_REQ_GET_HANDSHAKE 0x10
|
||||
#define USB_REQ_SET_CONNECTION 0x11
|
||||
#define USB_REQ_SET_SECURITY_DATA 0x12
|
||||
#define USB_REQ_GET_SECURITY_DATA 0x13
|
||||
#define USB_REQ_SET_WUSB_DATA 0x14
|
||||
#define USB_REQ_LOOPBACK_DATA_WRITE 0x15
|
||||
#define USB_REQ_LOOPBACK_DATA_READ 0x16
|
||||
#define USB_REQ_SET_INTERFACE_DS 0x17
|
||||
|
||||
/* The Link Power Management (LPM) ECN defines USB_REQ_TEST_AND_SET command,
|
||||
* used by hubs to put ports into a new L1 suspend state, except that it
|
||||
* forgot to define its number ...
|
||||
*/
|
||||
|
||||
/*
|
||||
* USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and
|
||||
* are read as a bit array returned by USB_REQ_GET_STATUS. (So there
|
||||
* are at most sixteen features of each type.) Hubs may also support a
|
||||
* new USB_REQ_TEST_AND_SET_FEATURE to put ports into L1 suspend.
|
||||
*/
|
||||
#define USB_DEVICE_SELF_POWERED 0 /* (read only) */
|
||||
#define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */
|
||||
#define USB_DEVICE_TEST_MODE 2 /* (wired high speed only) */
|
||||
#define USB_DEVICE_BATTERY 2 /* (wireless) */
|
||||
#define USB_DEVICE_B_HNP_ENABLE 3 /* (otg) dev may initiate HNP */
|
||||
#define USB_DEVICE_WUSB_DEVICE 3 /* (wireless)*/
|
||||
#define USB_DEVICE_A_HNP_SUPPORT 4 /* (otg) RH port supports HNP */
|
||||
#define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */
|
||||
#define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */
|
||||
|
||||
/*
|
||||
* Test Mode Selectors
|
||||
* See USB 2.0 spec Table 9-7
|
||||
*/
|
||||
#define TEST_J 1
|
||||
#define TEST_K 2
|
||||
#define TEST_SE0_NAK 3
|
||||
#define TEST_PACKET 4
|
||||
#define TEST_FORCE_EN 5
|
||||
|
||||
/*
|
||||
* New Feature Selectors as added by USB 3.0
|
||||
* See USB 3.0 spec Table 9-6
|
||||
*/
|
||||
#define USB_DEVICE_U1_ENABLE 48 /* dev may initiate U1 transition */
|
||||
#define USB_DEVICE_U2_ENABLE 49 /* dev may initiate U2 transition */
|
||||
#define USB_DEVICE_LTM_ENABLE 50 /* dev may send LTM */
|
||||
#define USB_INTRF_FUNC_SUSPEND 0 /* function suspend */
|
||||
|
||||
#define USB_INTR_FUNC_SUSPEND_OPT_MASK 0xFF00
|
||||
/*
|
||||
* Suspend Options, Table 9-7 USB 3.0 spec
|
||||
*/
|
||||
#define USB_INTRF_FUNC_SUSPEND_LP (1 << (8 + 0))
|
||||
#define USB_INTRF_FUNC_SUSPEND_RW (1 << (8 + 1))
|
||||
|
||||
#define USB_ENDPOINT_HALT 0 /* IN/OUT will STALL */
|
||||
|
||||
/* Bit array elements as returned by the USB_REQ_GET_STATUS request. */
|
||||
#define USB_DEV_STAT_U1_ENABLED 2 /* transition into U1 state */
|
||||
#define USB_DEV_STAT_U2_ENABLED 3 /* transition into U2 state */
|
||||
#define USB_DEV_STAT_LTM_ENABLED 4 /* Latency tolerance messages */
|
||||
|
||||
/**
|
||||
* struct usb_ctrlrequest - SETUP data for a USB device control request
|
||||
* @bRequestType: matches the USB bmRequestType field
|
||||
* @bRequest: matches the USB bRequest field
|
||||
* @wValue: matches the USB wValue field (le16 byte order)
|
||||
* @wIndex: matches the USB wIndex field (le16 byte order)
|
||||
* @wLength: matches the USB wLength field (le16 byte order)
|
||||
*
|
||||
* This structure is used to send control requests to a USB device. It matches
|
||||
* the different fields of the USB 2.0 Spec section 9.3, table 9-2. See the
|
||||
* USB spec for a fuller description of the different fields, and what they are
|
||||
* used for.
|
||||
*
|
||||
* Note that the driver for any interface can issue control requests.
|
||||
* For most devices, interfaces don't coordinate with each other, so
|
||||
* such requests may be made at any time.
|
||||
*/
|
||||
struct usb_ctrlrequest {
|
||||
__u8 bRequestType;
|
||||
__u8 bRequest;
|
||||
__le16 wValue;
|
||||
__le16 wIndex;
|
||||
__le16 wLength;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* STANDARD DESCRIPTORS ... as returned by GET_DESCRIPTOR, or
|
||||
* (rarely) accepted by SET_DESCRIPTOR.
|
||||
*
|
||||
* Note that all multi-byte values here are encoded in little endian
|
||||
* byte order "on the wire". Within the kernel and when exposed
|
||||
* through the Linux-USB APIs, they are not converted to cpu byte
|
||||
* order; it is the responsibility of the client code to do this.
|
||||
* The single exception is when device and configuration descriptors (but
|
||||
* not other descriptors) are read from usbfs (i.e. /proc/bus/usb/BBB/DDD);
|
||||
* in this case the fields are converted to host endianness by the kernel.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Descriptor types ... USB 2.0 spec table 9.5
|
||||
*/
|
||||
#define USB_DT_DEVICE 0x01
|
||||
#define USB_DT_CONFIG 0x02
|
||||
#define USB_DT_STRING 0x03
|
||||
#define USB_DT_INTERFACE 0x04
|
||||
#define USB_DT_ENDPOINT 0x05
|
||||
#define USB_DT_DEVICE_QUALIFIER 0x06
|
||||
#define USB_DT_OTHER_SPEED_CONFIG 0x07
|
||||
#define USB_DT_INTERFACE_POWER 0x08
|
||||
/* these are from a minor usb 2.0 revision (ECN) */
|
||||
#define USB_DT_OTG 0x09
|
||||
#define USB_DT_DEBUG 0x0a
|
||||
#define USB_DT_INTERFACE_ASSOCIATION 0x0b
|
||||
/* these are from the Wireless USB spec */
|
||||
#define USB_DT_SECURITY 0x0c
|
||||
#define USB_DT_KEY 0x0d
|
||||
#define USB_DT_ENCRYPTION_TYPE 0x0e
|
||||
#define USB_DT_BOS 0x0f
|
||||
#define USB_DT_DEVICE_CAPABILITY 0x10
|
||||
#define USB_DT_WIRELESS_ENDPOINT_COMP 0x11
|
||||
#define USB_DT_WIRE_ADAPTER 0x21
|
||||
#define USB_DT_RPIPE 0x22
|
||||
#define USB_DT_CS_RADIO_CONTROL 0x23
|
||||
/* From the T10 UAS specification */
|
||||
#define USB_DT_PIPE_USAGE 0x24
|
||||
/* From the USB 3.0 spec */
|
||||
#define USB_DT_SS_ENDPOINT_COMP 0x30
|
||||
|
||||
/* Conventional codes for class-specific descriptors. The convention is
|
||||
* defined in the USB "Common Class" Spec (3.11). Individual class specs
|
||||
* are authoritative for their usage, not the "common class" writeup.
|
||||
*/
|
||||
#define USB_DT_CS_DEVICE (USB_TYPE_CLASS | USB_DT_DEVICE)
|
||||
#define USB_DT_CS_CONFIG (USB_TYPE_CLASS | USB_DT_CONFIG)
|
||||
#define USB_DT_CS_STRING (USB_TYPE_CLASS | USB_DT_STRING)
|
||||
#define USB_DT_CS_INTERFACE (USB_TYPE_CLASS | USB_DT_INTERFACE)
|
||||
#define USB_DT_CS_ENDPOINT (USB_TYPE_CLASS | USB_DT_ENDPOINT)
|
||||
|
||||
/* All standard descriptors have these 2 fields at the beginning */
|
||||
struct usb_descriptor_header {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_DEVICE: Device descriptor */
|
||||
struct usb_device_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__le16 bcdUSB;
|
||||
__u8 bDeviceClass;
|
||||
__u8 bDeviceSubClass;
|
||||
__u8 bDeviceProtocol;
|
||||
__u8 bMaxPacketSize0;
|
||||
__le16 idVendor;
|
||||
__le16 idProduct;
|
||||
__le16 bcdDevice;
|
||||
__u8 iManufacturer;
|
||||
__u8 iProduct;
|
||||
__u8 iSerialNumber;
|
||||
__u8 bNumConfigurations;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define USB_DT_DEVICE_SIZE 18
|
||||
|
||||
|
||||
/*
|
||||
* Device and/or Interface Class codes
|
||||
* as found in bDeviceClass or bInterfaceClass
|
||||
* and defined by www.usb.org documents
|
||||
*/
|
||||
#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */
|
||||
#define USB_CLASS_AUDIO 1
|
||||
#define USB_CLASS_COMM 2
|
||||
#define USB_CLASS_HID 3
|
||||
#define USB_CLASS_PHYSICAL 5
|
||||
#define USB_CLASS_STILL_IMAGE 6
|
||||
#define USB_CLASS_PRINTER 7
|
||||
#define USB_CLASS_MASS_STORAGE 8
|
||||
#define USB_CLASS_HUB 9
|
||||
#define USB_CLASS_CDC_DATA 0x0a
|
||||
#define USB_CLASS_CSCID 0x0b /* chip+ smart card */
|
||||
#define USB_CLASS_CONTENT_SEC 0x0d /* content security */
|
||||
#define USB_CLASS_VIDEO 0x0e
|
||||
#define USB_CLASS_WIRELESS_CONTROLLER 0xe0
|
||||
#define USB_CLASS_MISC 0xef
|
||||
#define USB_CLASS_APP_SPEC 0xfe
|
||||
#define USB_CLASS_VENDOR_SPEC 0xff
|
||||
|
||||
#define USB_SUBCLASS_VENDOR_SPEC 0xff
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_CONFIG: Configuration descriptor information.
|
||||
*
|
||||
* USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the
|
||||
* descriptor type is different. Highspeed-capable devices can look
|
||||
* different depending on what speed they're currently running. Only
|
||||
* devices with a USB_DT_DEVICE_QUALIFIER have any OTHER_SPEED_CONFIG
|
||||
* descriptors.
|
||||
*/
|
||||
struct usb_config_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__le16 wTotalLength;
|
||||
__u8 bNumInterfaces;
|
||||
__u8 bConfigurationValue;
|
||||
__u8 iConfiguration;
|
||||
__u8 bmAttributes;
|
||||
__u8 bMaxPower;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define USB_DT_CONFIG_SIZE 9
|
||||
|
||||
/* from config descriptor bmAttributes */
|
||||
#define USB_CONFIG_ATT_ONE (1 << 7) /* must be set */
|
||||
#define USB_CONFIG_ATT_SELFPOWER (1 << 6) /* self powered */
|
||||
#define USB_CONFIG_ATT_WAKEUP (1 << 5) /* can wakeup */
|
||||
#define USB_CONFIG_ATT_BATTERY (1 << 4) /* battery powered */
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_STRING: String descriptor */
|
||||
struct usb_string_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__le16 wData[1]; /* UTF-16LE encoded */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* note that "string" zero is special, it holds language codes that
|
||||
* the device supports, not Unicode characters.
|
||||
*/
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_INTERFACE: Interface descriptor */
|
||||
struct usb_interface_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__u8 bInterfaceNumber;
|
||||
__u8 bAlternateSetting;
|
||||
__u8 bNumEndpoints;
|
||||
__u8 bInterfaceClass;
|
||||
__u8 bInterfaceSubClass;
|
||||
__u8 bInterfaceProtocol;
|
||||
__u8 iInterface;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define USB_DT_INTERFACE_SIZE 9
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_ENDPOINT: Endpoint descriptor */
|
||||
struct usb_endpoint_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__u8 bEndpointAddress;
|
||||
__u8 bmAttributes;
|
||||
__le16 wMaxPacketSize;
|
||||
__u8 bInterval;
|
||||
|
||||
/* NOTE: these two are _only_ in audio endpoints. */
|
||||
/* use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof. */
|
||||
__u8 bRefresh;
|
||||
__u8 bSynchAddress;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define USB_DT_ENDPOINT_SIZE 7
|
||||
#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
|
||||
|
||||
|
||||
/*
|
||||
* Endpoints
|
||||
*/
|
||||
#define USB_ENDPOINT_NUMBER_MASK 0x0f /* in bEndpointAddress */
|
||||
#define USB_ENDPOINT_DIR_MASK 0x80
|
||||
|
||||
#define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */
|
||||
#define USB_ENDPOINT_XFER_CONTROL 0
|
||||
#define USB_ENDPOINT_XFER_ISOC 1
|
||||
#define USB_ENDPOINT_XFER_BULK 2
|
||||
#define USB_ENDPOINT_XFER_INT 3
|
||||
#define USB_ENDPOINT_MAX_ADJUSTABLE 0x80
|
||||
|
||||
/* The USB 3.0 spec redefines bits 5:4 of bmAttributes as interrupt ep type. */
|
||||
#define USB_ENDPOINT_INTRTYPE 0x30
|
||||
#define USB_ENDPOINT_INTR_PERIODIC (0 << 4)
|
||||
#define USB_ENDPOINT_INTR_NOTIFICATION (1 << 4)
|
||||
|
||||
#define USB_ENDPOINT_SYNCTYPE 0x0c
|
||||
#define USB_ENDPOINT_SYNC_NONE (0 << 2)
|
||||
#define USB_ENDPOINT_SYNC_ASYNC (1 << 2)
|
||||
#define USB_ENDPOINT_SYNC_ADAPTIVE (2 << 2)
|
||||
#define USB_ENDPOINT_SYNC_SYNC (3 << 2)
|
||||
|
||||
#define USB_ENDPOINT_USAGE_MASK 0x30
|
||||
#define USB_ENDPOINT_USAGE_DATA 0x00
|
||||
#define USB_ENDPOINT_USAGE_FEEDBACK 0x10
|
||||
#define USB_ENDPOINT_USAGE_IMPLICIT_FB 0x20 /* Implicit feedback Data endpoint */
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* usb_endpoint_num - get the endpoint's number
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns @epd's number: 0 to 15.
|
||||
*/
|
||||
static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_type - get the endpoint's transfer type
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns one of USB_ENDPOINT_XFER_{CONTROL, ISOC, BULK, INT} according
|
||||
* to @epd's transfer type.
|
||||
*/
|
||||
static inline int usb_endpoint_type(const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_dir_in - check if the endpoint has IN direction
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns true if the endpoint is of type IN, otherwise it returns false.
|
||||
*/
|
||||
static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_dir_out - check if the endpoint has OUT direction
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns true if the endpoint is of type OUT, otherwise it returns false.
|
||||
*/
|
||||
static inline int usb_endpoint_dir_out(
|
||||
const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_xfer_bulk - check if the endpoint has bulk transfer type
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns true if the endpoint is of type bulk, otherwise it returns false.
|
||||
*/
|
||||
static inline int usb_endpoint_xfer_bulk(
|
||||
const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
|
||||
USB_ENDPOINT_XFER_BULK);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_xfer_control - check if the endpoint has control transfer type
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns true if the endpoint is of type control, otherwise it returns false.
|
||||
*/
|
||||
static inline int usb_endpoint_xfer_control(
|
||||
const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
|
||||
USB_ENDPOINT_XFER_CONTROL);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns true if the endpoint is of type interrupt, otherwise it returns
|
||||
* false.
|
||||
*/
|
||||
static inline int usb_endpoint_xfer_int(
|
||||
const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
|
||||
USB_ENDPOINT_XFER_INT);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_xfer_isoc - check if the endpoint has isochronous transfer type
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns true if the endpoint is of type isochronous, otherwise it returns
|
||||
* false.
|
||||
*/
|
||||
static inline int usb_endpoint_xfer_isoc(
|
||||
const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
|
||||
USB_ENDPOINT_XFER_ISOC);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_is_bulk_in - check if the endpoint is bulk IN
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns true if the endpoint has bulk transfer type and IN direction,
|
||||
* otherwise it returns false.
|
||||
*/
|
||||
static inline int usb_endpoint_is_bulk_in(
|
||||
const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_is_bulk_out - check if the endpoint is bulk OUT
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns true if the endpoint has bulk transfer type and OUT direction,
|
||||
* otherwise it returns false.
|
||||
*/
|
||||
static inline int usb_endpoint_is_bulk_out(
|
||||
const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_is_int_in - check if the endpoint is interrupt IN
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns true if the endpoint has interrupt transfer type and IN direction,
|
||||
* otherwise it returns false.
|
||||
*/
|
||||
static inline int usb_endpoint_is_int_in(
|
||||
const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_is_int_out - check if the endpoint is interrupt OUT
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns true if the endpoint has interrupt transfer type and OUT direction,
|
||||
* otherwise it returns false.
|
||||
*/
|
||||
static inline int usb_endpoint_is_int_out(
|
||||
const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_is_isoc_in - check if the endpoint is isochronous IN
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns true if the endpoint has isochronous transfer type and IN direction,
|
||||
* otherwise it returns false.
|
||||
*/
|
||||
static inline int usb_endpoint_is_isoc_in(
|
||||
const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_is_isoc_out - check if the endpoint is isochronous OUT
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns true if the endpoint has isochronous transfer type and OUT direction,
|
||||
* otherwise it returns false.
|
||||
*/
|
||||
static inline int usb_endpoint_is_isoc_out(
|
||||
const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_endpoint_maxp - get endpoint's max packet size
|
||||
* @epd: endpoint to be checked
|
||||
*
|
||||
* Returns @epd's max packet
|
||||
*/
|
||||
static inline int usb_endpoint_maxp(const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return __le16_to_cpu(epd->wMaxPacketSize);
|
||||
}
|
||||
|
||||
static inline int usb_endpoint_interrupt_type(
|
||||
const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return epd->bmAttributes & USB_ENDPOINT_INTRTYPE;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_SS_ENDPOINT_COMP: SuperSpeed Endpoint Companion descriptor */
|
||||
struct usb_ss_ep_comp_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__u8 bMaxBurst;
|
||||
__u8 bmAttributes;
|
||||
__le16 wBytesPerInterval;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define USB_DT_SS_EP_COMP_SIZE 6
|
||||
|
||||
/* Bits 4:0 of bmAttributes if this is a bulk endpoint */
|
||||
static inline int
|
||||
usb_ss_max_streams(const struct usb_ss_ep_comp_descriptor *comp)
|
||||
{
|
||||
int max_streams;
|
||||
|
||||
if (!comp)
|
||||
return 0;
|
||||
|
||||
max_streams = comp->bmAttributes & 0x1f;
|
||||
|
||||
if (!max_streams)
|
||||
return 0;
|
||||
|
||||
max_streams = 1 << max_streams;
|
||||
|
||||
return max_streams;
|
||||
}
|
||||
|
||||
/* Bits 1:0 of bmAttributes if this is an isoc endpoint */
|
||||
#define USB_SS_MULT(p) (1 + ((p) & 0x3))
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */
|
||||
struct usb_qualifier_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__le16 bcdUSB;
|
||||
__u8 bDeviceClass;
|
||||
__u8 bDeviceSubClass;
|
||||
__u8 bDeviceProtocol;
|
||||
__u8 bMaxPacketSize0;
|
||||
__u8 bNumConfigurations;
|
||||
__u8 bRESERVED;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_OTG (from OTG 1.0a supplement) */
|
||||
struct usb_otg_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__u8 bmAttributes; /* support for HNP, SRP, etc */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* from usb_otg_descriptor.bmAttributes */
|
||||
#define USB_OTG_SRP (1 << 0)
|
||||
#define USB_OTG_HNP (1 << 1) /* swap host/device roles */
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_DEBUG: for special highspeed devices, replacing serial console */
|
||||
struct usb_debug_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
/* bulk endpoints with 8 byte maxpacket */
|
||||
__u8 bDebugInEndpoint;
|
||||
__u8 bDebugOutEndpoint;
|
||||
} __attribute__((packed));
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_INTERFACE_ASSOCIATION: groups interfaces */
|
||||
struct usb_interface_assoc_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__u8 bFirstInterface;
|
||||
__u8 bInterfaceCount;
|
||||
__u8 bFunctionClass;
|
||||
__u8 bFunctionSubClass;
|
||||
__u8 bFunctionProtocol;
|
||||
__u8 iFunction;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_SECURITY: group of wireless security descriptors, including
|
||||
* encryption types available for setting up a CC/association.
|
||||
*/
|
||||
struct usb_security_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__le16 wTotalLength;
|
||||
__u8 bNumEncryptionTypes;
|
||||
} __attribute__((packed));
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_KEY: used with {GET,SET}_SECURITY_DATA; only public keys
|
||||
* may be retrieved.
|
||||
*/
|
||||
struct usb_key_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__u8 tTKID[3];
|
||||
__u8 bReserved;
|
||||
__u8 bKeyData[0];
|
||||
} __attribute__((packed));
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_ENCRYPTION_TYPE: bundled in DT_SECURITY groups */
|
||||
struct usb_encryption_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__u8 bEncryptionType;
|
||||
#define USB_ENC_TYPE_UNSECURE 0
|
||||
#define USB_ENC_TYPE_WIRED 1 /* non-wireless mode */
|
||||
#define USB_ENC_TYPE_CCM_1 2 /* aes128/cbc session */
|
||||
#define USB_ENC_TYPE_RSA_1 3 /* rsa3072/sha1 auth */
|
||||
__u8 bEncryptionValue; /* use in SET_ENCRYPTION */
|
||||
__u8 bAuthKeyIndex;
|
||||
} __attribute__((packed));
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_BOS: group of device-level capabilities */
|
||||
struct usb_bos_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__le16 wTotalLength;
|
||||
__u8 bNumDeviceCaps;
|
||||
} __attribute__((packed));
|
||||
|
||||
#define USB_DT_BOS_SIZE 5
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_DEVICE_CAPABILITY: grouped with BOS */
|
||||
struct usb_dev_cap_header {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDevCapabilityType;
|
||||
} __attribute__((packed));
|
||||
|
||||
#define USB_CAP_TYPE_WIRELESS_USB 1
|
||||
|
||||
struct usb_wireless_cap_descriptor { /* Ultra Wide Band */
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDevCapabilityType;
|
||||
|
||||
__u8 bmAttributes;
|
||||
#define USB_WIRELESS_P2P_DRD (1 << 1)
|
||||
#define USB_WIRELESS_BEACON_MASK (3 << 2)
|
||||
#define USB_WIRELESS_BEACON_SELF (1 << 2)
|
||||
#define USB_WIRELESS_BEACON_DIRECTED (2 << 2)
|
||||
#define USB_WIRELESS_BEACON_NONE (3 << 2)
|
||||
__le16 wPHYRates; /* bit rates, Mbps */
|
||||
#define USB_WIRELESS_PHY_53 (1 << 0) /* always set */
|
||||
#define USB_WIRELESS_PHY_80 (1 << 1)
|
||||
#define USB_WIRELESS_PHY_107 (1 << 2) /* always set */
|
||||
#define USB_WIRELESS_PHY_160 (1 << 3)
|
||||
#define USB_WIRELESS_PHY_200 (1 << 4) /* always set */
|
||||
#define USB_WIRELESS_PHY_320 (1 << 5)
|
||||
#define USB_WIRELESS_PHY_400 (1 << 6)
|
||||
#define USB_WIRELESS_PHY_480 (1 << 7)
|
||||
__u8 bmTFITXPowerInfo; /* TFI power levels */
|
||||
__u8 bmFFITXPowerInfo; /* FFI power levels */
|
||||
__le16 bmBandGroup;
|
||||
__u8 bReserved;
|
||||
} __attribute__((packed));
|
||||
|
||||
/* USB 2.0 Extension descriptor */
|
||||
#define USB_CAP_TYPE_EXT 2
|
||||
|
||||
struct usb_ext_cap_descriptor { /* Link Power Management */
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDevCapabilityType;
|
||||
__le32 bmAttributes;
|
||||
#define USB_LPM_SUPPORT (1 << 1) /* supports LPM */
|
||||
#define USB_BESL_SUPPORT (1 << 2) /* supports BESL */
|
||||
#define USB_BESL_BASELINE_VALID (1 << 3) /* Baseline BESL valid*/
|
||||
#define USB_BESL_DEEP_VALID (1 << 4) /* Deep BESL valid */
|
||||
#define USB_GET_BESL_BASELINE(p) (((p) & (0xf << 8)) >> 8)
|
||||
#define USB_GET_BESL_DEEP(p) (((p) & (0xf << 12)) >> 12)
|
||||
} __attribute__((packed));
|
||||
|
||||
#define USB_DT_USB_EXT_CAP_SIZE 7
|
||||
|
||||
/*
|
||||
* SuperSpeed USB Capability descriptor: Defines the set of SuperSpeed USB
|
||||
* specific device level capabilities
|
||||
*/
|
||||
#define USB_SS_CAP_TYPE 3
|
||||
struct usb_ss_cap_descriptor { /* Link Power Management */
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDevCapabilityType;
|
||||
__u8 bmAttributes;
|
||||
#define USB_LTM_SUPPORT (1 << 1) /* supports LTM */
|
||||
__le16 wSpeedSupported;
|
||||
#define USB_LOW_SPEED_OPERATION (1) /* Low speed operation */
|
||||
#define USB_FULL_SPEED_OPERATION (1 << 1) /* Full speed operation */
|
||||
#define USB_HIGH_SPEED_OPERATION (1 << 2) /* High speed operation */
|
||||
#define USB_5GBPS_OPERATION (1 << 3) /* Operation at 5Gbps */
|
||||
__u8 bFunctionalitySupport;
|
||||
__u8 bU1devExitLat;
|
||||
__le16 bU2DevExitLat;
|
||||
} __attribute__((packed));
|
||||
|
||||
#define USB_DT_USB_SS_CAP_SIZE 10
|
||||
|
||||
/*
|
||||
* Container ID Capability descriptor: Defines the instance unique ID used to
|
||||
* identify the instance across all operating modes
|
||||
*/
|
||||
#define CONTAINER_ID_TYPE 4
|
||||
struct usb_ss_container_id_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDevCapabilityType;
|
||||
__u8 bReserved;
|
||||
__u8 ContainerID[16]; /* 128-bit number */
|
||||
} __attribute__((packed));
|
||||
|
||||
#define USB_DT_USB_SS_CONTN_ID_SIZE 20
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_DT_WIRELESS_ENDPOINT_COMP: companion descriptor associated with
|
||||
* each endpoint descriptor for a wireless device
|
||||
*/
|
||||
struct usb_wireless_ep_comp_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__u8 bMaxBurst;
|
||||
__u8 bMaxSequence;
|
||||
__le16 wMaxStreamDelay;
|
||||
__le16 wOverTheAirPacketSize;
|
||||
__u8 bOverTheAirInterval;
|
||||
__u8 bmCompAttributes;
|
||||
#define USB_ENDPOINT_SWITCH_MASK 0x03 /* in bmCompAttributes */
|
||||
#define USB_ENDPOINT_SWITCH_NO 0
|
||||
#define USB_ENDPOINT_SWITCH_SWITCH 1
|
||||
#define USB_ENDPOINT_SWITCH_SCALE 2
|
||||
} __attribute__((packed));
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_REQ_SET_HANDSHAKE is a four-way handshake used between a wireless
|
||||
* host and a device for connection set up, mutual authentication, and
|
||||
* exchanging short lived session keys. The handshake depends on a CC.
|
||||
*/
|
||||
struct usb_handshake {
|
||||
__u8 bMessageNumber;
|
||||
__u8 bStatus;
|
||||
__u8 tTKID[3];
|
||||
__u8 bReserved;
|
||||
__u8 CDID[16];
|
||||
__u8 nonce[16];
|
||||
__u8 MIC[8];
|
||||
} __attribute__((packed));
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB_REQ_SET_CONNECTION modifies or revokes a connection context (CC).
|
||||
* A CC may also be set up using non-wireless secure channels (including
|
||||
* wired USB!), and some devices may support CCs with multiple hosts.
|
||||
*/
|
||||
struct usb_connection_context {
|
||||
__u8 CHID[16]; /* persistent host id */
|
||||
__u8 CDID[16]; /* device id (unique w/in host context) */
|
||||
__u8 CK[16]; /* connection key */
|
||||
} __attribute__((packed));
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* USB 2.0 defines three speeds, here's how Linux identifies them */
|
||||
|
||||
enum usb_device_speed {
|
||||
USB_SPEED_UNKNOWN = 0, /* enumerating */
|
||||
USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */
|
||||
USB_SPEED_HIGH, /* usb 2.0 */
|
||||
USB_SPEED_WIRELESS, /* wireless (usb 2.5) */
|
||||
USB_SPEED_SUPER, /* usb 3.0 */
|
||||
};
|
||||
|
||||
|
||||
enum usb_device_state {
|
||||
/* NOTATTACHED isn't in the USB spec, and this state acts
|
||||
* the same as ATTACHED ... but it's clearer this way.
|
||||
*/
|
||||
USB_STATE_NOTATTACHED = 0,
|
||||
|
||||
/* chapter 9 and authentication (wireless) device states */
|
||||
USB_STATE_ATTACHED,
|
||||
USB_STATE_POWERED, /* wired */
|
||||
USB_STATE_RECONNECTING, /* auth */
|
||||
USB_STATE_UNAUTHENTICATED, /* auth */
|
||||
USB_STATE_DEFAULT, /* limited function */
|
||||
USB_STATE_ADDRESS,
|
||||
USB_STATE_CONFIGURED, /* most functions */
|
||||
|
||||
USB_STATE_SUSPENDED
|
||||
|
||||
/* NOTE: there are actually four different SUSPENDED
|
||||
* states, returning to POWERED, DEFAULT, ADDRESS, or
|
||||
* CONFIGURED respectively when SOF tokens flow again.
|
||||
* At this level there's no difference between L1 and L2
|
||||
* suspend states. (L2 being original USB 1.1 suspend.)
|
||||
*/
|
||||
};
|
||||
|
||||
enum usb3_link_state {
|
||||
USB3_LPM_U0 = 0,
|
||||
USB3_LPM_U1,
|
||||
USB3_LPM_U2,
|
||||
USB3_LPM_U3
|
||||
};
|
||||
|
||||
/*
|
||||
* A U1 timeout of 0x0 means the parent hub will reject any transitions to U1.
|
||||
* 0xff means the parent hub will accept transitions to U1, but will not
|
||||
* initiate a transition.
|
||||
*
|
||||
* A U1 timeout of 0x1 to 0x7F also causes the hub to initiate a transition to
|
||||
* U1 after that many microseconds. Timeouts of 0x80 to 0xFE are reserved
|
||||
* values.
|
||||
*
|
||||
* A U2 timeout of 0x0 means the parent hub will reject any transitions to U2.
|
||||
* 0xff means the parent hub will accept transitions to U2, but will not
|
||||
* initiate a transition.
|
||||
*
|
||||
* A U2 timeout of 0x1 to 0xFE also causes the hub to initiate a transition to
|
||||
* U2 after N*256 microseconds. Therefore a U2 timeout value of 0x1 means a U2
|
||||
* idle timer of 256 microseconds, 0x2 means 512 microseconds, 0xFE means
|
||||
* 65.024ms.
|
||||
*/
|
||||
#define USB3_LPM_DISABLED 0x0
|
||||
#define USB3_LPM_U1_MAX_TIMEOUT 0x7F
|
||||
#define USB3_LPM_U2_MAX_TIMEOUT 0xFE
|
||||
#define USB3_LPM_DEVICE_INITIATED 0xFF
|
||||
|
||||
struct usb_set_sel_req {
|
||||
__u8 u1_sel;
|
||||
__u8 u1_pel;
|
||||
__le16 u2_sel;
|
||||
__le16 u2_pel;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/*
|
||||
* The Set System Exit Latency control transfer provides one byte each for
|
||||
* U1 SEL and U1 PEL, so the max exit latency is 0xFF. U2 SEL and U2 PEL each
|
||||
* are two bytes long.
|
||||
*/
|
||||
#define USB3_LPM_MAX_U1_SEL_PEL 0xFF
|
||||
#define USB3_LPM_MAX_U2_SEL_PEL 0xFFFF
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* As per USB compliance update, a device that is actively drawing
|
||||
* more than 100mA from USB must report itself as bus-powered in
|
||||
* the GetStatus(DEVICE) call.
|
||||
* http://compliance.usb.org/index.asp?UpdateFile=Electrical&Format=Standard#34
|
||||
*/
|
||||
#define USB_SELF_POWER_VBUS_MAX_DRAW 100
|
||||
|
||||
#endif /* _UAPI__LINUX_USB_CH9_H */
|
169
include/uapi/linux/usb/functionfs.h
Normal file
169
include/uapi/linux/usb/functionfs.h
Normal file
@ -0,0 +1,169 @@
|
||||
#ifndef _UAPI__LINUX_FUNCTIONFS_H__
|
||||
#define _UAPI__LINUX_FUNCTIONFS_H__
|
||||
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/ioctl.h>
|
||||
|
||||
#include <linux/usb/ch9.h>
|
||||
|
||||
|
||||
enum {
|
||||
FUNCTIONFS_DESCRIPTORS_MAGIC = 1,
|
||||
FUNCTIONFS_STRINGS_MAGIC = 2
|
||||
};
|
||||
|
||||
|
||||
#ifndef __KERNEL__
|
||||
|
||||
/* Descriptor of an non-audio endpoint */
|
||||
struct usb_endpoint_descriptor_no_audio {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
|
||||
__u8 bEndpointAddress;
|
||||
__u8 bmAttributes;
|
||||
__le16 wMaxPacketSize;
|
||||
__u8 bInterval;
|
||||
} __attribute__((packed));
|
||||
|
||||
|
||||
/*
|
||||
* All numbers must be in little endian order.
|
||||
*/
|
||||
|
||||
struct usb_functionfs_descs_head {
|
||||
__le32 magic;
|
||||
__le32 length;
|
||||
__le32 fs_count;
|
||||
__le32 hs_count;
|
||||
} __attribute__((packed));
|
||||
|
||||
/*
|
||||
* Descriptors format:
|
||||
*
|
||||
* | off | name | type | description |
|
||||
* |-----+-----------+--------------+--------------------------------------|
|
||||
* | 0 | magic | LE32 | FUNCTIONFS_{FS,HS}_DESCRIPTORS_MAGIC |
|
||||
* | 4 | length | LE32 | length of the whole data chunk |
|
||||
* | 8 | fs_count | LE32 | number of full-speed descriptors |
|
||||
* | 12 | hs_count | LE32 | number of high-speed descriptors |
|
||||
* | 16 | fs_descrs | Descriptor[] | list of full-speed descriptors |
|
||||
* | | hs_descrs | Descriptor[] | list of high-speed descriptors |
|
||||
*
|
||||
* descs are just valid USB descriptors and have the following format:
|
||||
*
|
||||
* | off | name | type | description |
|
||||
* |-----+-----------------+------+--------------------------|
|
||||
* | 0 | bLength | U8 | length of the descriptor |
|
||||
* | 1 | bDescriptorType | U8 | descriptor type |
|
||||
* | 2 | payload | | descriptor's payload |
|
||||
*/
|
||||
|
||||
struct usb_functionfs_strings_head {
|
||||
__le32 magic;
|
||||
__le32 length;
|
||||
__le32 str_count;
|
||||
__le32 lang_count;
|
||||
} __attribute__((packed));
|
||||
|
||||
/*
|
||||
* Strings format:
|
||||
*
|
||||
* | off | name | type | description |
|
||||
* |-----+------------+-----------------------+----------------------------|
|
||||
* | 0 | magic | LE32 | FUNCTIONFS_STRINGS_MAGIC |
|
||||
* | 4 | length | LE32 | length of the data chunk |
|
||||
* | 8 | str_count | LE32 | number of strings |
|
||||
* | 12 | lang_count | LE32 | number of languages |
|
||||
* | 16 | stringtab | StringTab[lang_count] | table of strings per lang |
|
||||
*
|
||||
* For each language there is one stringtab entry (ie. there are lang_count
|
||||
* stringtab entires). Each StringTab has following format:
|
||||
*
|
||||
* | off | name | type | description |
|
||||
* |-----+---------+-------------------+------------------------------------|
|
||||
* | 0 | lang | LE16 | language code |
|
||||
* | 2 | strings | String[str_count] | array of strings in given language |
|
||||
*
|
||||
* For each string there is one strings entry (ie. there are str_count
|
||||
* string entries). Each String is a NUL terminated string encoded in
|
||||
* UTF-8.
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Events are delivered on the ep0 file descriptor, when the user mode driver
|
||||
* reads from this file descriptor after writing the descriptors. Don't
|
||||
* stop polling this descriptor.
|
||||
*/
|
||||
|
||||
enum usb_functionfs_event_type {
|
||||
FUNCTIONFS_BIND,
|
||||
FUNCTIONFS_UNBIND,
|
||||
|
||||
FUNCTIONFS_ENABLE,
|
||||
FUNCTIONFS_DISABLE,
|
||||
|
||||
FUNCTIONFS_SETUP,
|
||||
|
||||
FUNCTIONFS_SUSPEND,
|
||||
FUNCTIONFS_RESUME
|
||||
};
|
||||
|
||||
/* NOTE: this structure must stay the same size and layout on
|
||||
* both 32-bit and 64-bit kernels.
|
||||
*/
|
||||
struct usb_functionfs_event {
|
||||
union {
|
||||
/* SETUP: packet; DATA phase i/o precedes next event
|
||||
*(setup.bmRequestType & USB_DIR_IN) flags direction */
|
||||
struct usb_ctrlrequest setup;
|
||||
} __attribute__((packed)) u;
|
||||
|
||||
/* enum usb_functionfs_event_type */
|
||||
__u8 type;
|
||||
__u8 _pad[3];
|
||||
} __attribute__((packed));
|
||||
|
||||
|
||||
/* Endpoint ioctls */
|
||||
/* The same as in gadgetfs */
|
||||
|
||||
/* IN transfers may be reported to the gadget driver as complete
|
||||
* when the fifo is loaded, before the host reads the data;
|
||||
* OUT transfers may be reported to the host's "client" driver as
|
||||
* complete when they're sitting in the FIFO unread.
|
||||
* THIS returns how many bytes are "unclaimed" in the endpoint fifo
|
||||
* (needed for precise fault handling, when the hardware allows it)
|
||||
*/
|
||||
#define FUNCTIONFS_FIFO_STATUS _IO('g', 1)
|
||||
|
||||
/* discards any unclaimed data in the fifo. */
|
||||
#define FUNCTIONFS_FIFO_FLUSH _IO('g', 2)
|
||||
|
||||
/* resets endpoint halt+toggle; used to implement set_interface.
|
||||
* some hardware (like pxa2xx) can't support this.
|
||||
*/
|
||||
#define FUNCTIONFS_CLEAR_HALT _IO('g', 3)
|
||||
|
||||
/* Specific for functionfs */
|
||||
|
||||
/*
|
||||
* Returns reverse mapping of an interface. Called on EP0. If there
|
||||
* is no such interface returns -EDOM. If function is not active
|
||||
* returns -ENODEV.
|
||||
*/
|
||||
#define FUNCTIONFS_INTERFACE_REVMAP _IO('g', 128)
|
||||
|
||||
/*
|
||||
* Returns real bEndpointAddress of an endpoint. If function is not
|
||||
* active returns -ENODEV.
|
||||
*/
|
||||
#define FUNCTIONFS_ENDPOINT_REVMAP _IO('g', 129)
|
||||
|
||||
|
||||
|
||||
#endif /* _UAPI__LINUX_FUNCTIONFS_H__ */
|
Loading…
Reference in New Issue
Block a user