1 # SPDX-License-Identifier: GPL-2.0
2 #
3 # USB Gadget support on a system involves
4 #    (a) a peripheral controller, and
5 #    (b) the gadget driver using it.
6 #
7 # NOTE:  Gadget support ** DOES NOT ** depend on host-side CONFIG_USB !!
8 #
9 #  - Host systems (like PCs) need CONFIG_USB (with "A" jacks).
10 #  - Peripherals (like PDAs) need CONFIG_USB_GADGET (with "B" jacks).
11 #  - Some systems have both kinds of controllers.
12 #
13 # With help from a special transceiver and a "Mini-AB" jack, systems with
14 # both kinds of controller can also support "USB On-the-Go" (CONFIG_USB_OTG).
15 #
16 # A Linux "Gadget Driver" talks to the USB Peripheral Controller
17 # driver through the abstract "gadget" API.  Some other operating
18 # systems call these "client" drivers, of which "class drivers"
19 # are a subset (implementing a USB device class specification).
20 # A gadget driver implements one or more USB functions using
21 # the peripheral hardware.
22 #
23 # Gadget drivers are hardware-neutral, or "platform independent",
24 # except that they sometimes must understand quirks or limitations
25 # of the particular controllers they work with.  For example, when
26 # a controller doesn't support alternate configurations or provide
27 # enough of the right types of endpoints, the gadget driver might
28 # not be able work with that controller, or might need to implement
29 # a less common variant of a device class protocol.
30 #
31 # The available choices each represent a single precomposed USB
32 # gadget configuration. In the device model, each option contains
33 # both the device instantiation as a child for a USB gadget
34 # controller, and the relevant drivers for each function declared
35 # by the device.
36 
37 menu "USB Gadget precomposed configurations"
38 
39 config USB_ZERO
40 	tristate "Gadget Zero (DEVELOPMENT)"
41 	select USB_LIBCOMPOSITE
42 	select USB_F_SS_LB
43 	help
44 	  Gadget Zero is a two-configuration device.  It either sinks and
45 	  sources bulk data; or it loops back a configurable number of
46 	  transfers.  It also implements control requests, for "chapter 9"
47 	  conformance.  The driver needs only two bulk-capable endpoints, so
48 	  it can work on top of most device-side usb controllers.  It's
49 	  useful for testing, and is also a working example showing how
50 	  USB "gadget drivers" can be written.
51 
52 	  Make this be the first driver you try using on top of any new
53 	  USB peripheral controller driver.  Then you can use host-side
54 	  test software, like the "usbtest" driver, to put your hardware
55 	  and its driver through a basic set of functional tests.
56 
57 	  Gadget Zero also works with the host-side "usb-skeleton" driver,
58 	  and with many kinds of host-side test software.  You may need
59 	  to tweak product and vendor IDs before host software knows about
60 	  this device, and arrange to select an appropriate configuration.
61 
62 	  Say "y" to link the driver statically, or "m" to build a
63 	  dynamically linked module called "g_zero".
64 
65 config USB_ZERO_HNPTEST
66 	bool "HNP Test Device"
67 	depends on USB_ZERO && USB_OTG
68 	help
69 	  You can configure this device to enumerate using the device
70 	  identifiers of the USB-OTG test device.  That means that when
71 	  this gadget connects to another OTG device, with this one using
72 	  the "B-Peripheral" role, that device will use HNP to let this
73 	  one serve as the USB host instead (in the "B-Host" role).
74 
75 config USB_AUDIO
76 	tristate "Audio Gadget"
77 	depends on SND
78 	select USB_LIBCOMPOSITE
79 	select SND_PCM
80 	select USB_F_UAC1 if (GADGET_UAC1 && !GADGET_UAC1_LEGACY)
81 	select USB_F_UAC1_LEGACY if (GADGET_UAC1 && GADGET_UAC1_LEGACY)
82 	select USB_F_UAC2 if !GADGET_UAC1
83 	select USB_U_AUDIO if (USB_F_UAC2 || USB_F_UAC1)
84 	help
85 	  This Gadget Audio driver is compatible with USB Audio Class
86 	  specification 2.0. It implements 1 AudioControl interface,
87 	  1 AudioStreaming Interface each for USB-OUT and USB-IN.
88 	  Number of channels, sample rate and sample size can be
89 	  specified as module parameters.
90 	  This driver doesn't expect any real Audio codec to be present
91 	  on the device - the audio streams are simply sinked to and
92 	  sourced from a virtual ALSA sound card created. The user-space
93 	  application may choose to do whatever it wants with the data
94 	  received from the USB Host and choose to provide whatever it
95 	  wants as audio data to the USB Host.
96 
97 	  Say "y" to link the driver statically, or "m" to build a
98 	  dynamically linked module called "g_audio".
99 
100 config GADGET_UAC1
101 	bool "UAC 1.0"
102 	depends on USB_AUDIO
103 	help
104 	  If you instead want older USB Audio Class specification 1.0 support
105 	  with similar driver capabilities.
106 
107 config GADGET_UAC1_LEGACY
108 	bool "UAC 1.0 (Legacy)"
109 	depends on GADGET_UAC1
110 	help
111 	  If you instead want legacy UAC Spec-1.0 driver that also has audio
112 	  paths hardwired to the Audio codec chip on-board and doesn't work
113 	  without one.
114 
115 config USB_ETH
116 	tristate "Ethernet Gadget (with CDC Ethernet support)"
117 	depends on NET
118 	select USB_LIBCOMPOSITE
119 	select USB_U_ETHER
120 	select USB_F_ECM
121 	select USB_F_SUBSET
122 	select CRC32
123 	help
124 	  This driver implements Ethernet style communication, in one of
125 	  several ways:
126 
127 	   - The "Communication Device Class" (CDC) Ethernet Control Model.
128 	     That protocol is often avoided with pure Ethernet adapters, in
129 	     favor of simpler vendor-specific hardware, but is widely
130 	     supported by firmware for smart network devices.
131 
132 	   - On hardware can't implement that protocol, a simple CDC subset
133 	     is used, placing fewer demands on USB.
134 
135 	   - CDC Ethernet Emulation Model (EEM) is a newer standard that has
136 	     a simpler interface that can be used by more USB hardware.
137 
138 	  RNDIS support is an additional option, more demanding than subset.
139 
140 	  Within the USB device, this gadget driver exposes a network device
141 	  "usbX", where X depends on what other networking devices you have.
142 	  Treat it like a two-node Ethernet link:  host, and gadget.
143 
144 	  The Linux-USB host-side "usbnet" driver interoperates with this
145 	  driver, so that deep I/O queues can be supported.  On 2.4 kernels,
146 	  use "CDCEther" instead, if you're using the CDC option. That CDC
147 	  mode should also interoperate with standard CDC Ethernet class
148 	  drivers on other host operating systems.
149 
150 	  Say "y" to link the driver statically, or "m" to build a
151 	  dynamically linked module called "g_ether".
152 
153 config USB_ETH_RNDIS
154 	bool "RNDIS support"
155 	depends on USB_ETH
156 	select USB_LIBCOMPOSITE
157 	select USB_F_RNDIS
158 	default y
159 	help
160 	   Microsoft Windows XP bundles the "Remote NDIS" (RNDIS) protocol,
161 	   and Microsoft provides redistributable binary RNDIS drivers for
162 	   older versions of Windows.
163 
164 	   If you say "y" here, the Ethernet gadget driver will try to provide
165 	   a second device configuration, supporting RNDIS to talk to such
166 	   Microsoft USB hosts.
167 
168 	   To make MS-Windows work with this, use Documentation/usb/linux.inf
169 	   as the "driver info file".  For versions of MS-Windows older than
170 	   XP, you'll need to download drivers from Microsoft's website; a URL
171 	   is given in comments found in that info file.
172 
173 config USB_ETH_EEM
174 	bool "Ethernet Emulation Model (EEM) support"
175 	depends on USB_ETH
176 	select USB_LIBCOMPOSITE
177 	select USB_F_EEM
178 	help
179 	  CDC EEM is a newer USB standard that is somewhat simpler than CDC ECM
180 	  and therefore can be supported by more hardware.  Technically ECM and
181 	  EEM are designed for different applications.  The ECM model extends
182 	  the network interface to the target (e.g. a USB cable modem), and the
183 	  EEM model is for mobile devices to communicate with hosts using
184 	  ethernet over USB.  For Linux gadgets, however, the interface with
185 	  the host is the same (a usbX device), so the differences are minimal.
186 
187 	  If you say "y" here, the Ethernet gadget driver will use the EEM
188 	  protocol rather than ECM.  If unsure, say "n".
189 
190 config USB_G_NCM
191 	tristate "Network Control Model (NCM) support"
192 	depends on NET
193 	select USB_LIBCOMPOSITE
194 	select USB_U_ETHER
195 	select USB_F_NCM
196 	select CRC32
197 	help
198 	  This driver implements USB CDC NCM subclass standard. NCM is
199 	  an advanced protocol for Ethernet encapsulation, allows grouping
200 	  of several ethernet frames into one USB transfer and different
201 	  alignment possibilities.
202 
203 	  Say "y" to link the driver statically, or "m" to build a
204 	  dynamically linked module called "g_ncm".
205 
206 config USB_GADGETFS
207 	tristate "Gadget Filesystem"
208 	help
209 	  This driver provides a filesystem based API that lets user mode
210 	  programs implement a single-configuration USB device, including
211 	  endpoint I/O and control requests that don't relate to enumeration.
212 	  All endpoints, transfer speeds, and transfer types supported by
213 	  the hardware are available, through read() and write() calls.
214 
215 	  Say "y" to link the driver statically, or "m" to build a
216 	  dynamically linked module called "gadgetfs".
217 
218 config USB_FUNCTIONFS
219 	tristate "Function Filesystem"
220 	select USB_LIBCOMPOSITE
221 	select USB_F_FS
222 	select USB_FUNCTIONFS_GENERIC if !(USB_FUNCTIONFS_ETH || USB_FUNCTIONFS_RNDIS)
223 	help
224 	  The Function Filesystem (FunctionFS) lets one create USB
225 	  composite functions in user space in the same way GadgetFS
226 	  lets one create USB gadgets in user space.  This allows creation
227 	  of composite gadgets such that some of the functions are
228 	  implemented in kernel space (for instance Ethernet, serial or
229 	  mass storage) and other are implemented in user space.
230 
231 	  If you say "y" or "m" here you will be able what kind of
232 	  configurations the gadget will provide.
233 
234 	  Say "y" to link the driver statically, or "m" to build
235 	  a dynamically linked module called "g_ffs".
236 
237 config USB_FUNCTIONFS_ETH
238 	bool "Include configuration with CDC ECM (Ethernet)"
239 	depends on USB_FUNCTIONFS && NET
240 	select USB_U_ETHER
241 	select USB_F_ECM
242 	select USB_F_SUBSET
243 	help
244 	  Include a configuration with CDC ECM function (Ethernet) and the
245 	  Function Filesystem.
246 
247 config USB_FUNCTIONFS_RNDIS
248 	bool "Include configuration with RNDIS (Ethernet)"
249 	depends on USB_FUNCTIONFS && NET
250 	select USB_U_ETHER
251 	select USB_F_RNDIS
252 	help
253 	  Include a configuration with RNDIS function (Ethernet) and the Filesystem.
254 
255 config USB_FUNCTIONFS_GENERIC
256 	bool "Include 'pure' configuration"
257 	depends on USB_FUNCTIONFS
258 	help
259 	  Include a configuration with the Function Filesystem alone with
260 	  no Ethernet interface.
261 
262 config USB_MASS_STORAGE
263 	tristate "Mass Storage Gadget"
264 	depends on BLOCK
265 	select USB_LIBCOMPOSITE
266 	select USB_F_MASS_STORAGE
267 	help
268 	  The Mass Storage Gadget acts as a USB Mass Storage disk drive.
269 	  As its storage repository it can use a regular file or a block
270 	  device (in much the same way as the "loop" device driver),
271 	  specified as a module parameter or sysfs option.
272 
273 	  This driver is a replacement for now removed File-backed
274 	  Storage Gadget (g_file_storage).
275 
276 	  Say "y" to link the driver statically, or "m" to build
277 	  a dynamically linked module called "g_mass_storage".
278 
279 config USB_GADGET_TARGET
280 	tristate "USB Gadget Target Fabric Module"
281 	depends on TARGET_CORE
282 	select USB_LIBCOMPOSITE
283 	select USB_F_TCM
284 	help
285 	  This fabric is an USB gadget. Two USB protocols are supported that is
286 	  BBB or BOT (Bulk Only Transport) and UAS (USB Attached SCSI). BOT is
287 	  advertised on alternative interface 0 (primary) and UAS is on
288 	  alternative interface 1. Both protocols can work on USB2.0 and USB3.0.
289 	  UAS utilizes the USB 3.0 feature called streams support.
290 
291 config USB_G_SERIAL
292 	tristate "Serial Gadget (with CDC ACM and CDC OBEX support)"
293 	depends on TTY
294 	select USB_U_SERIAL
295 	select USB_F_ACM
296 	select USB_F_SERIAL
297 	select USB_F_OBEX
298 	select USB_LIBCOMPOSITE
299 	help
300 	  The Serial Gadget talks to the Linux-USB generic serial driver.
301 	  This driver supports a CDC-ACM module option, which can be used
302 	  to interoperate with MS-Windows hosts or with the Linux-USB
303 	  "cdc-acm" driver.
304 
305 	  This driver also supports a CDC-OBEX option.  You will need a
306 	  user space OBEX server talking to /dev/ttyGS*, since the kernel
307 	  itself doesn't implement the OBEX protocol.
308 
309 	  Say "y" to link the driver statically, or "m" to build a
310 	  dynamically linked module called "g_serial".
311 
312 	  For more information, see Documentation/usb/gadget_serial.rst
313 	  which includes instructions and a "driver info file" needed to
314 	  make MS-Windows work with CDC ACM.
315 
316 config USB_MIDI_GADGET
317 	tristate "MIDI Gadget"
318 	depends on SND
319 	select USB_LIBCOMPOSITE
320 	select SND_RAWMIDI
321 	select USB_F_MIDI
322 	help
323 	  The MIDI Gadget acts as a USB Audio device, with one MIDI
324 	  input and one MIDI output. These MIDI jacks appear as
325 	  a sound "card" in the ALSA sound system. Other MIDI
326 	  connections can then be made on the gadget system, using
327 	  ALSA's aconnect utility etc.
328 
329 	  Say "y" to link the driver statically, or "m" to build a
330 	  dynamically linked module called "g_midi".
331 
332 config USB_G_PRINTER
333 	tristate "Printer Gadget"
334 	select USB_LIBCOMPOSITE
335 	select USB_F_PRINTER
336 	help
337 	  The Printer Gadget channels data between the USB host and a
338 	  userspace program driving the print engine. The user space
339 	  program reads and writes the device file /dev/g_printer to
340 	  receive or send printer data. It can use ioctl calls to
341 	  the device file to get or set printer status.
342 
343 	  Say "y" to link the driver statically, or "m" to build a
344 	  dynamically linked module called "g_printer".
345 
346 	  For more information, see Documentation/usb/gadget_printer.rst
347 	  which includes sample code for accessing the device file.
348 
349 if TTY
350 
351 config USB_CDC_COMPOSITE
352 	tristate "CDC Composite Device (Ethernet and ACM)"
353 	depends on NET
354 	select USB_LIBCOMPOSITE
355 	select USB_U_SERIAL
356 	select USB_U_ETHER
357 	select USB_F_ACM
358 	select USB_F_ECM
359 	help
360 	  This driver provides two functions in one configuration:
361 	  a CDC Ethernet (ECM) link, and a CDC ACM (serial port) link.
362 
363 	  This driver requires four bulk and two interrupt endpoints,
364 	  plus the ability to handle altsettings.  Not all peripheral
365 	  controllers are that capable.
366 
367 	  Say "y" to link the driver statically, or "m" to build a
368 	  dynamically linked module.
369 
370 config USB_G_NOKIA
371 	tristate "Nokia composite gadget"
372 	depends on PHONET
373 	depends on BLOCK
374 	select USB_LIBCOMPOSITE
375 	select USB_U_SERIAL
376 	select USB_U_ETHER
377 	select USB_F_ACM
378 	select USB_F_OBEX
379 	select USB_F_PHONET
380 	select USB_F_ECM
381 	select USB_F_MASS_STORAGE
382 	help
383 	  The Nokia composite gadget provides support for acm, obex
384 	  and phonet in only one composite gadget driver.
385 
386 	  It's only really useful for N900 hardware. If you're building
387 	  a kernel for N900, say Y or M here. If unsure, say N.
388 
389 config USB_G_ACM_MS
390 	tristate "CDC Composite Device (ACM and mass storage)"
391 	depends on BLOCK
392 	select USB_LIBCOMPOSITE
393 	select USB_U_SERIAL
394 	select USB_F_ACM
395 	select USB_F_MASS_STORAGE
396 	help
397 	  This driver provides two functions in one configuration:
398 	  a mass storage, and a CDC ACM (serial port) link.
399 
400 	  Say "y" to link the driver statically, or "m" to build a
401 	  dynamically linked module called "g_acm_ms".
402 
403 config USB_G_MULTI
404 	tristate "Multifunction Composite Gadget"
405 	depends on BLOCK && NET
406 	select USB_G_MULTI_CDC if !USB_G_MULTI_RNDIS
407 	select USB_LIBCOMPOSITE
408 	select USB_U_SERIAL
409 	select USB_U_ETHER
410 	select USB_F_ACM
411 	select USB_F_MASS_STORAGE
412 	help
413 	  The Multifunction Composite Gadget provides Ethernet (RNDIS
414 	  and/or CDC Ethernet), mass storage and ACM serial link
415 	  interfaces.
416 
417 	  You will be asked to choose which of the two configurations is
418 	  to be available in the gadget.  At least one configuration must
419 	  be chosen to make the gadget usable.  Selecting more than one
420 	  configuration will prevent Windows from automatically detecting
421 	  the gadget as a composite gadget, so an INF file will be needed to
422 	  use the gadget.
423 
424 	  Say "y" to link the driver statically, or "m" to build a
425 	  dynamically linked module called "g_multi".
426 
427 config USB_G_MULTI_RNDIS
428 	bool "RNDIS + CDC Serial + Storage configuration"
429 	depends on USB_G_MULTI
430 	select USB_F_RNDIS
431 	default y
432 	help
433 	  This option enables a configuration with RNDIS, CDC Serial and
434 	  Mass Storage functions available in the Multifunction Composite
435 	  Gadget.  This is the configuration dedicated for Windows since RNDIS
436 	  is Microsoft's protocol.
437 
438 	  If unsure, say "y".
439 
440 config USB_G_MULTI_CDC
441 	bool "CDC Ethernet + CDC Serial + Storage configuration"
442 	depends on USB_G_MULTI
443 	select USB_F_ECM
444 	help
445 	  This option enables a configuration with CDC Ethernet (ECM), CDC
446 	  Serial and Mass Storage functions available in the Multifunction
447 	  Composite Gadget.
448 
449 	  If unsure, say "y".
450 
451 endif # TTY
452 
453 config USB_G_HID
454 	tristate "HID Gadget"
455 	select USB_LIBCOMPOSITE
456 	select USB_F_HID
457 	help
458 	  The HID gadget driver provides generic emulation of USB
459 	  Human Interface Devices (HID).
460 
461 	  For more information, see Documentation/usb/gadget_hid.rst which
462 	  includes sample code for accessing the device files.
463 
464 	  Say "y" to link the driver statically, or "m" to build a
465 	  dynamically linked module called "g_hid".
466 
467 # Standalone / single function gadgets
468 config USB_G_DBGP
469 	tristate "EHCI Debug Device Gadget"
470 	depends on TTY
471 	select USB_LIBCOMPOSITE
472 	help
473 	  This gadget emulates an EHCI Debug device. This is useful when you want
474 	  to interact with an EHCI Debug Port.
475 
476 	  Say "y" to link the driver statically, or "m" to build a
477 	  dynamically linked module called "g_dbgp".
478 
479 if USB_G_DBGP
480 choice
481 	prompt "EHCI Debug Device mode"
482 	default USB_G_DBGP_SERIAL
483 
484 config USB_G_DBGP_PRINTK
485 	depends on USB_G_DBGP
486 	bool "printk"
487 	help
488 	  Directly printk() received data. No interaction.
489 
490 config USB_G_DBGP_SERIAL
491 	depends on USB_G_DBGP
492 	select USB_U_SERIAL
493 	bool "serial"
494 	help
495 	  Userland can interact using /dev/ttyGSxxx.
496 endchoice
497 endif
498 
499 # put drivers that need isochronous transfer support (for audio
500 # or video class gadget drivers), or specific hardware, here.
501 config USB_G_WEBCAM
502 	tristate "USB Webcam Gadget"
503 	depends on VIDEO_DEV
504 	select USB_LIBCOMPOSITE
505 	select VIDEOBUF2_DMA_SG
506 	select VIDEOBUF2_VMALLOC
507 	select USB_F_UVC
508 	help
509 	  The Webcam Gadget acts as a composite USB Audio and Video Class
510 	  device. It provides a userspace API to process UVC control requests
511 	  and stream video data to the host.
512 
513 	  Say "y" to link the driver statically, or "m" to build a
514 	  dynamically linked module called "g_webcam".
515 
516 config USB_RAW_GADGET
517 	tristate "USB Raw Gadget"
518 	help
519 	  USB Raw Gadget is a gadget driver that gives userspace low-level
520 	  control over the gadget's communication process.
521 
522 	  Like any other gadget driver, Raw Gadget implements USB devices via
523 	  the USB gadget API. Unlike most gadget drivers, Raw Gadget does not
524 	  implement any concrete USB functions itself but requires userspace
525 	  to do that.
526 
527 	  See Documentation/usb/raw-gadget.rst for details.
528 
529 	  Say "y" to link the driver statically, or "m" to build a
530 	  dynamically linked module called "raw_gadget".
531 
532 endmenu
533