1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><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 unsigned sg_supported:1; 18 unsigned is_otg:1; 19 unsigned is_a_peripheral:1; 20 unsigned b_hnp_enable:1; 21 unsigned a_hnp_support:1; 22 unsigned a_alt_hnp_support:1; 23 unsigned quirk_ep_out_aligned_size:1; 24 unsigned is_selfpowered:1; 25}; </pre></div><div class="refsect1"><a name="idp1124068516"></a><h2>Members</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term">work</span></dt><dd><p> 26 (internal use) Workqueue to be used for <code class="function">sysfs_notify</code> 27 </p></dd><dt><span class="term">udc</span></dt><dd><p> 28 struct usb_udc pointer for this gadget 29 </p></dd><dt><span class="term">ops</span></dt><dd><p> 30 Function pointers used to access hardware-specific operations. 31 </p></dd><dt><span class="term">ep0</span></dt><dd><p> 32 Endpoint zero, used when reading or writing responses to 33 driver <code class="function">setup</code> requests 34 </p></dd><dt><span class="term">ep_list</span></dt><dd><p> 35 List of other endpoints supported by the device. 36 </p></dd><dt><span class="term">speed</span></dt><dd><p> 37 Speed of current connection to USB host. 38 </p></dd><dt><span class="term">max_speed</span></dt><dd><p> 39 Maximal speed the UDC can handle. UDC must support this 40 and all slower speeds. 41 </p></dd><dt><span class="term">state</span></dt><dd><p> 42 the state we are now (attached, suspended, configured, etc) 43 </p></dd><dt><span class="term">name</span></dt><dd><p> 44 Identifies the controller hardware type. Used in diagnostics 45 and sometimes configuration. 46 </p></dd><dt><span class="term">dev</span></dt><dd><p> 47 Driver model state for this abstract device. 48 </p></dd><dt><span class="term">out_epnum</span></dt><dd><p> 49 last used out ep number 50 </p></dd><dt><span class="term">in_epnum</span></dt><dd><p> 51 last used in ep number 52 </p></dd><dt><span class="term">sg_supported</span></dt><dd><p> 53 true if we can handle scatter-gather 54 </p></dd><dt><span class="term">is_otg</span></dt><dd><p> 55 True if the USB device port uses a Mini-AB jack, so that the 56 gadget driver must provide a USB OTG descriptor. 57 </p></dd><dt><span class="term">is_a_peripheral</span></dt><dd><p> 58 False unless is_otg, the <span class="quote">“<span class="quote">A</span>”</span> end of a USB cable 59 is in the Mini-AB jack, and HNP has been used to switch roles 60 so that the <span class="quote">“<span class="quote">A</span>”</span> device currently acts as A-Peripheral, not A-Host. 61 </p></dd><dt><span class="term">b_hnp_enable</span></dt><dd><p> 62 OTG device feature flag, indicating that the A-Host 63 enabled HNP support. 64 </p></dd><dt><span class="term">a_hnp_support</span></dt><dd><p> 65 OTG device feature flag, indicating that the A-Host 66 supports HNP at this port. 67 </p></dd><dt><span class="term">a_alt_hnp_support</span></dt><dd><p> 68 OTG device feature flag, indicating that the A-Host 69 only supports HNP on a different root port. 70 </p></dd><dt><span class="term">quirk_ep_out_aligned_size</span></dt><dd><p> 71 epout requires buffer size to be aligned to 72 MaxPacketSize. 73 </p></dd><dt><span class="term">is_selfpowered</span></dt><dd><p> 74 if the gadget is self-powered. 75 </p></dd></dl></div></div><div class="refsect1"><a name="idp1124084580"></a><h2>Description</h2><p> 76 Gadgets have a mostly-portable <span class="quote">“<span class="quote">gadget driver</span>”</span> implementing device 77 functions, handling all usb configurations and interfaces. Gadget 78 drivers talk to hardware-specific code indirectly, through ops vectors. 79 That insulates the gadget driver from hardware details, and packages 80 the hardware endpoints through generic i/o queues. The <span class="quote">“<span class="quote">usb_gadget</span>”</span> 81 and <span class="quote">“<span class="quote">usb_ep</span>”</span> interfaces provide that insulation from the hardware. 82 </p><p> 83 84 Except for the driver data, all fields in this structure are 85 read-only to the gadget driver. That driver data is part of the 86 <span class="quote">“<span class="quote">driver model</span>”</span> infrastructure in 2.6 (and later) kernels, and for 87 earlier systems is grouped in a similar structure that's not known 88 to the rest of the kernel. 89 </p><p> 90 91 Values of the three OTG device feature flags are updated before the 92 <code class="function">setup</code> call corresponding to USB_REQ_SET_CONFIGURATION, and before 93 driver <code class="function">suspend</code> calls. They are valid only when is_otg, and when the 94 device is acting as a B-Peripheral (so is_a_peripheral is false). 95</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> 96