1<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>struct usb_gadget</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="USB Gadget API for Linux"><link rel="up" href="core.html" title="Core Objects and Methods"><link rel="prev" href="API-usb-ep-fifo-flush.html" title="usb_ep_fifo_flush"><link rel="next" href="API-usb-ep-align-maybe.html" title="usb_ep_align_maybe"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">struct usb_gadget</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-usb-ep-fifo-flush.html">Prev</a> </td><th width="60%" align="center">Core Objects and Methods</th><td width="20%" align="right"> <a accesskey="n" href="API-usb-ep-align-maybe.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-struct-usb-gadget"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>struct usb_gadget — 2 represents a usb slave device 3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="programlisting"> 4struct usb_gadget { 5 struct work_struct work; 6 struct usb_udc * udc; 7 const struct usb_gadget_ops * ops; 8 struct usb_ep * ep0; 9 struct list_head ep_list; 10 enum usb_device_speed speed; 11 enum usb_device_speed max_speed; 12 enum usb_device_state state; 13 const char * name; 14 struct device dev; 15 unsigned out_epnum; 16 unsigned in_epnum; 17 struct usb_otg_caps * otg_caps; 18 unsigned sg_supported:1; 19 unsigned is_otg:1; 20 unsigned is_a_peripheral:1; 21 unsigned b_hnp_enable:1; 22 unsigned a_hnp_support:1; 23 unsigned a_alt_hnp_support:1; 24 unsigned quirk_ep_out_aligned_size:1; 25 unsigned is_selfpowered:1; 26 unsigned deactivated:1; 27 unsigned connected:1; 28}; </pre></div><div class="refsect1"><a name="id-1.5.9.18.5"></a><h2>Members</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term">work</span></dt><dd><p> 29 (internal use) Workqueue to be used for <code class="function">sysfs_notify</code> 30 </p></dd><dt><span class="term">udc</span></dt><dd><p> 31 struct usb_udc pointer for this gadget 32 </p></dd><dt><span class="term">ops</span></dt><dd><p> 33 Function pointers used to access hardware-specific operations. 34 </p></dd><dt><span class="term">ep0</span></dt><dd><p> 35 Endpoint zero, used when reading or writing responses to 36 driver <code class="function">setup</code> requests 37 </p></dd><dt><span class="term">ep_list</span></dt><dd><p> 38 List of other endpoints supported by the device. 39 </p></dd><dt><span class="term">speed</span></dt><dd><p> 40 Speed of current connection to USB host. 41 </p></dd><dt><span class="term">max_speed</span></dt><dd><p> 42 Maximal speed the UDC can handle. UDC must support this 43 and all slower speeds. 44 </p></dd><dt><span class="term">state</span></dt><dd><p> 45 the state we are now (attached, suspended, configured, etc) 46 </p></dd><dt><span class="term">name</span></dt><dd><p> 47 Identifies the controller hardware type. Used in diagnostics 48 and sometimes configuration. 49 </p></dd><dt><span class="term">dev</span></dt><dd><p> 50 Driver model state for this abstract device. 51 </p></dd><dt><span class="term">out_epnum</span></dt><dd><p> 52 last used out ep number 53 </p></dd><dt><span class="term">in_epnum</span></dt><dd><p> 54 last used in ep number 55 </p></dd><dt><span class="term">otg_caps</span></dt><dd><p> 56 OTG capabilities of this gadget. 57 </p></dd><dt><span class="term">sg_supported</span></dt><dd><p> 58 true if we can handle scatter-gather 59 </p></dd><dt><span class="term">is_otg</span></dt><dd><p> 60 True if the USB device port uses a Mini-AB jack, so that the 61 gadget driver must provide a USB OTG descriptor. 62 </p></dd><dt><span class="term">is_a_peripheral</span></dt><dd><p> 63 False unless is_otg, the <span class="quote">“<span class="quote">A</span>”</span> end of a USB cable 64 is in the Mini-AB jack, and HNP has been used to switch roles 65 so that the <span class="quote">“<span class="quote">A</span>”</span> device currently acts as A-Peripheral, not A-Host. 66 </p></dd><dt><span class="term">b_hnp_enable</span></dt><dd><p> 67 OTG device feature flag, indicating that the A-Host 68 enabled HNP support. 69 </p></dd><dt><span class="term">a_hnp_support</span></dt><dd><p> 70 OTG device feature flag, indicating that the A-Host 71 supports HNP at this port. 72 </p></dd><dt><span class="term">a_alt_hnp_support</span></dt><dd><p> 73 OTG device feature flag, indicating that the A-Host 74 only supports HNP on a different root port. 75 </p></dd><dt><span class="term">quirk_ep_out_aligned_size</span></dt><dd><p> 76 epout requires buffer size to be aligned to 77 MaxPacketSize. 78 </p></dd><dt><span class="term">is_selfpowered</span></dt><dd><p> 79 if the gadget is self-powered. 80 </p></dd><dt><span class="term">deactivated</span></dt><dd><p> 81 True if gadget is deactivated - in deactivated state it cannot 82 be connected. 83 </p></dd><dt><span class="term">connected</span></dt><dd><p> 84 True if gadget is connected. 85 </p></dd></dl></div></div><div class="refsect1"><a name="id-1.5.9.18.6"></a><h2>Description</h2><p> 86 Gadgets have a mostly-portable <span class="quote">“<span class="quote">gadget driver</span>”</span> implementing device 87 functions, handling all usb configurations and interfaces. Gadget 88 drivers talk to hardware-specific code indirectly, through ops vectors. 89 That insulates the gadget driver from hardware details, and packages 90 the hardware endpoints through generic i/o queues. The <span class="quote">“<span class="quote">usb_gadget</span>”</span> 91 and <span class="quote">“<span class="quote">usb_ep</span>”</span> interfaces provide that insulation from the hardware. 92 </p><p> 93 94 Except for the driver data, all fields in this structure are 95 read-only to the gadget driver. That driver data is part of the 96 <span class="quote">“<span class="quote">driver model</span>”</span> infrastructure in 2.6 (and later) kernels, and for 97 earlier systems is grouped in a similar structure that's not known 98 to the rest of the kernel. 99 </p><p> 100 101 Values of the three OTG device feature flags are updated before the 102 <code class="function">setup</code> call corresponding to USB_REQ_SET_CONFIGURATION, and before 103 driver <code class="function">suspend</code> calls. They are valid only when is_otg, and when the 104 device is acting as a B-Peripheral (so is_a_peripheral is false). 105</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-usb-ep-fifo-flush.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="core.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="API-usb-ep-align-maybe.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">usb_ep_fifo_flush</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span class="phrase">usb_ep_align_maybe</span></td></tr></table></div></body></html> 106