Back to home page

OSCL-LXR

 
 

    


0001 # SPDX-License-Identifier: GPL-2.0
0002 #
0003 # USB Gadget support on a system involves
0004 #    (a) a peripheral controller, and
0005 #    (b) the gadget driver using it.
0006 #
0007 # NOTE:  Gadget support ** DOES NOT ** depend on host-side CONFIG_USB !!
0008 #
0009 #  - Host systems (like PCs) need CONFIG_USB (with "A" jacks).
0010 #  - Peripherals (like PDAs) need CONFIG_USB_GADGET (with "B" jacks).
0011 #  - Some systems have both kinds of controllers.
0012 #
0013 # With help from a special transceiver and a "Mini-AB" jack, systems with
0014 # both kinds of controller can also support "USB On-the-Go" (CONFIG_USB_OTG).
0015 #
0016 
0017 menuconfig USB_GADGET
0018         tristate "USB Gadget Support"
0019         select USB_COMMON
0020         select NLS
0021         help
0022            USB is a host/device protocol, organized with one host (such as a
0023            PC) controlling up to 127 peripheral devices.
0024            The USB hardware is asymmetric, which makes it easier to set up:
0025            you can't connect a "to-the-host" connector to a peripheral.
0026 
0027            Linux can run in the host, or in the peripheral.  In both cases
0028            you need a low level bus controller driver, and some software
0029            talking to it.  Peripheral controllers are often discrete silicon,
0030            or are integrated with the CPU in a microcontroller.  The more
0031            familiar host side controllers have names like "EHCI", "OHCI",
0032            or "UHCI", and are usually integrated into southbridges on PC
0033            motherboards.
0034 
0035            Enable this configuration option if you want to run Linux inside
0036            a USB peripheral device.  Configure one hardware driver for your
0037            peripheral/device side bus controller, and a "gadget driver" for
0038            your peripheral protocol.  (If you use modular gadget drivers,
0039            you may configure more than one.)
0040 
0041            If in doubt, say "N" and don't enable these drivers; most people
0042            don't have this kind of hardware (except maybe inside Linux PDAs).
0043 
0044            For more information, see <http://www.linux-usb.org/gadget> and
0045            the kernel documentation for this API.
0046 
0047 if USB_GADGET
0048 
0049 config USB_GADGET_DEBUG
0050         bool "Debugging messages (DEVELOPMENT)"
0051         depends on DEBUG_KERNEL
0052         help
0053            Many controller and gadget drivers will print some debugging
0054            messages if you use this option to ask for those messages.
0055 
0056            Avoid enabling these messages, even if you're actively
0057            debugging such a driver.  Many drivers will emit so many
0058            messages that the driver timings are affected, which will
0059            either create new failure modes or remove the one you're
0060            trying to track down.  Never enable these messages for a
0061            production build.
0062 
0063 config USB_GADGET_VERBOSE
0064         bool "Verbose debugging Messages (DEVELOPMENT)"
0065         depends on USB_GADGET_DEBUG
0066         help
0067            Many controller and gadget drivers will print verbose debugging
0068            messages if you use this option to ask for those messages.
0069 
0070            Avoid enabling these messages, even if you're actively
0071            debugging such a driver.  Many drivers will emit so many
0072            messages that the driver timings are affected, which will
0073            either create new failure modes or remove the one you're
0074            trying to track down.  Never enable these messages for a
0075            production build.
0076 
0077 config USB_GADGET_DEBUG_FILES
0078         bool "Debugging information files (DEVELOPMENT)"
0079         depends on PROC_FS
0080         help
0081            Some of the drivers in the "gadget" framework can expose
0082            debugging information in files such as /proc/driver/udc
0083            (for a peripheral controller).  The information in these
0084            files may help when you're troubleshooting or bringing up a
0085            driver on a new board.   Enable these files by choosing "Y"
0086            here.  If in doubt, or to conserve kernel memory, say "N".
0087 
0088 config USB_GADGET_DEBUG_FS
0089         bool "Debugging information files in debugfs (DEVELOPMENT)"
0090         depends on DEBUG_FS
0091         help
0092            Some of the drivers in the "gadget" framework can expose
0093            debugging information in files under /sys/kernel/debug/.
0094            The information in these files may help when you're
0095            troubleshooting or bringing up a driver on a new board.
0096            Enable these files by choosing "Y" here.  If in doubt, or
0097            to conserve kernel memory, say "N".
0098 
0099 config USB_GADGET_VBUS_DRAW
0100         int "Maximum VBUS Power usage (2-500 mA)"
0101         range 2 500
0102         default 2
0103         help
0104            Some devices need to draw power from USB when they are
0105            configured, perhaps to operate circuitry or to recharge
0106            batteries.  This is in addition to any local power supply,
0107            such as an AC adapter or batteries.
0108 
0109            Enter the maximum power your device draws through USB, in
0110            milliAmperes.  The permitted range of values is 2 - 500 mA;
0111            0 mA would be legal, but can make some hosts misbehave.
0112 
0113            This value will be used except for system-specific gadget
0114            drivers that have more specific information.
0115 
0116 config USB_GADGET_STORAGE_NUM_BUFFERS
0117         int "Number of storage pipeline buffers"
0118         range 2 256
0119         default 2
0120         help
0121            Usually 2 buffers are enough to establish a good buffering
0122            pipeline. The number may be increased in order to compensate
0123            for a bursty VFS behaviour. For instance there may be CPU wake up
0124            latencies that makes the VFS to appear bursty in a system with
0125            an CPU on-demand governor. Especially if DMA is doing IO to
0126            offload the CPU. In this case the CPU will go into power
0127            save often and spin up occasionally to move data within VFS.
0128            If selecting USB_GADGET_DEBUG_FILES this value may be set by
0129            a module parameter as well.
0130            If unsure, say 2.
0131 
0132 config U_SERIAL_CONSOLE
0133         bool "Serial gadget console support"
0134         depends on USB_U_SERIAL
0135         help
0136            It supports the serial gadget can be used as a console.
0137 
0138 source "drivers/usb/gadget/udc/Kconfig"
0139 
0140 #
0141 # USB Gadget Drivers
0142 #
0143 
0144 # composite based drivers
0145 config USB_LIBCOMPOSITE
0146         tristate
0147         select CONFIGFS_FS
0148         depends on USB_GADGET
0149 
0150 config USB_F_ACM
0151         tristate
0152 
0153 config USB_F_SS_LB
0154         tristate
0155 
0156 config USB_U_SERIAL
0157         tristate
0158 
0159 config USB_U_ETHER
0160         tristate
0161 
0162 config USB_U_AUDIO
0163         tristate
0164 
0165 config USB_F_SERIAL
0166         tristate
0167 
0168 config USB_F_OBEX
0169         tristate
0170 
0171 config USB_F_NCM
0172         tristate
0173 
0174 config USB_F_ECM
0175         tristate
0176 
0177 config USB_F_PHONET
0178         tristate
0179 
0180 config USB_F_EEM
0181         tristate
0182 
0183 config USB_F_SUBSET
0184         tristate
0185 
0186 config USB_F_RNDIS
0187         tristate
0188 
0189 config USB_F_MASS_STORAGE
0190         tristate
0191 
0192 config USB_F_FS
0193         tristate
0194 
0195 config USB_F_UAC1
0196         tristate
0197 
0198 config USB_F_UAC1_LEGACY
0199         tristate
0200 
0201 config USB_F_UAC2
0202         tristate
0203 
0204 config USB_F_UVC
0205         tristate
0206 
0207 config USB_F_MIDI
0208         tristate
0209 
0210 config USB_F_HID
0211         tristate
0212 
0213 config USB_F_PRINTER
0214         tristate
0215 
0216 config USB_F_TCM
0217         tristate
0218 
0219 # this first set of drivers all depend on bulk-capable hardware.
0220 
0221 config USB_CONFIGFS
0222         tristate "USB Gadget functions configurable through configfs"
0223         select USB_LIBCOMPOSITE
0224         help
0225           A Linux USB "gadget" can be set up through configfs.
0226           If this is the case, the USB functions (which from the host's
0227           perspective are seen as interfaces) and configurations are
0228           specified simply by creating appropriate directories in configfs.
0229           Associating functions with configurations is done by creating
0230           appropriate symbolic links.
0231           For more information see Documentation/usb/gadget_configfs.rst.
0232 
0233 config USB_CONFIGFS_SERIAL
0234         bool "Generic serial bulk in/out"
0235         depends on USB_CONFIGFS
0236         depends on TTY
0237         select USB_U_SERIAL
0238         select USB_F_SERIAL
0239         help
0240           The function talks to the Linux-USB generic serial driver.
0241 
0242 config USB_CONFIGFS_ACM
0243         bool "Abstract Control Model (CDC ACM)"
0244         depends on USB_CONFIGFS
0245         depends on TTY
0246         select USB_U_SERIAL
0247         select USB_F_ACM
0248         help
0249           ACM serial link.  This function can be used to interoperate with
0250           MS-Windows hosts or with the Linux-USB "cdc-acm" driver.
0251 
0252 config USB_CONFIGFS_OBEX
0253         bool "Object Exchange Model (CDC OBEX)"
0254         depends on USB_CONFIGFS
0255         depends on TTY
0256         select USB_U_SERIAL
0257         select USB_F_OBEX
0258         help
0259           You will need a user space OBEX server talking to /dev/ttyGS*,
0260           since the kernel itself doesn't implement the OBEX protocol.
0261 
0262 config USB_CONFIGFS_NCM
0263         bool "Network Control Model (CDC NCM)"
0264         depends on USB_CONFIGFS
0265         depends on NET
0266         select USB_U_ETHER
0267         select USB_F_NCM
0268         select CRC32
0269         help
0270           NCM is an advanced protocol for Ethernet encapsulation, allows
0271           grouping of several ethernet frames into one USB transfer and
0272           different alignment possibilities.
0273 
0274 config USB_CONFIGFS_ECM
0275         bool "Ethernet Control Model (CDC ECM)"
0276         depends on USB_CONFIGFS
0277         depends on NET
0278         select USB_U_ETHER
0279         select USB_F_ECM
0280         help
0281           The "Communication Device Class" (CDC) Ethernet Control Model.
0282           That protocol is often avoided with pure Ethernet adapters, in
0283           favor of simpler vendor-specific hardware, but is widely
0284           supported by firmware for smart network devices.
0285 
0286 config USB_CONFIGFS_ECM_SUBSET
0287         bool "Ethernet Control Model (CDC ECM) subset"
0288         depends on USB_CONFIGFS
0289         depends on NET
0290         select USB_U_ETHER
0291         select USB_F_SUBSET
0292         help
0293           On hardware that can't implement the full protocol,
0294           a simple CDC subset is used, placing fewer demands on USB.
0295 
0296 config USB_CONFIGFS_RNDIS
0297         bool "RNDIS"
0298         depends on USB_CONFIGFS
0299         depends on NET
0300         select USB_U_ETHER
0301         select USB_F_RNDIS
0302         help
0303            Microsoft Windows XP bundles the "Remote NDIS" (RNDIS) protocol,
0304            and Microsoft provides redistributable binary RNDIS drivers for
0305            older versions of Windows.
0306 
0307            To make MS-Windows work with this, use Documentation/usb/linux.inf
0308            as the "driver info file".  For versions of MS-Windows older than
0309            XP, you'll need to download drivers from Microsoft's website; a URL
0310            is given in comments found in that info file.
0311 
0312 config USB_CONFIGFS_EEM
0313         bool "Ethernet Emulation Model (EEM)"
0314         depends on USB_CONFIGFS
0315         depends on NET
0316         select USB_U_ETHER
0317         select USB_F_EEM
0318         select CRC32
0319         help
0320           CDC EEM is a newer USB standard that is somewhat simpler than CDC ECM
0321           and therefore can be supported by more hardware.  Technically ECM and
0322           EEM are designed for different applications.  The ECM model extends
0323           the network interface to the target (e.g. a USB cable modem), and the
0324           EEM model is for mobile devices to communicate with hosts using
0325           ethernet over USB.  For Linux gadgets, however, the interface with
0326           the host is the same (a usbX device), so the differences are minimal.
0327 
0328 config USB_CONFIGFS_PHONET
0329         bool "Phonet protocol"
0330         depends on USB_CONFIGFS
0331         depends on NET
0332         depends on PHONET
0333         select USB_U_ETHER
0334         select USB_F_PHONET
0335         help
0336           The Phonet protocol implementation for USB device.
0337 
0338 config USB_CONFIGFS_MASS_STORAGE
0339         bool "Mass storage"
0340         depends on USB_CONFIGFS
0341         depends on BLOCK
0342         select USB_F_MASS_STORAGE
0343         help
0344           The Mass Storage Gadget acts as a USB Mass Storage disk drive.
0345           As its storage repository it can use a regular file or a block
0346           device (in much the same way as the "loop" device driver),
0347           specified as a module parameter or sysfs option.
0348 
0349 config USB_CONFIGFS_F_LB_SS
0350         bool "Loopback and sourcesink function (for testing)"
0351         depends on USB_CONFIGFS
0352         select USB_F_SS_LB
0353         help
0354           Loopback function loops back a configurable number of transfers.
0355           Sourcesink function either sinks and sources bulk data.
0356           It also implements control requests, for "chapter 9" conformance.
0357           Make this be the first driver you try using on top of any new
0358           USB peripheral controller driver.  Then you can use host-side
0359           test software, like the "usbtest" driver, to put your hardware
0360           and its driver through a basic set of functional tests.
0361 
0362 config USB_CONFIGFS_F_FS
0363         bool "Function filesystem (FunctionFS)"
0364         depends on USB_CONFIGFS
0365         select USB_F_FS
0366         help
0367           The Function Filesystem (FunctionFS) lets one create USB
0368           composite functions in user space in the same way GadgetFS
0369           lets one create USB gadgets in user space.  This allows creation
0370           of composite gadgets such that some of the functions are
0371           implemented in kernel space (for instance Ethernet, serial or
0372           mass storage) and other are implemented in user space.
0373 
0374 config USB_CONFIGFS_F_UAC1
0375         bool "Audio Class 1.0"
0376         depends on USB_CONFIGFS
0377         depends on SND
0378         select USB_LIBCOMPOSITE
0379         select SND_PCM
0380         select USB_U_AUDIO
0381         select USB_F_UAC1
0382         help
0383           This Audio function implements 1 AudioControl interface,
0384           1 AudioStreaming Interface each for USB-OUT and USB-IN.
0385           This driver doesn't expect any real Audio codec to be present
0386           on the device - the audio streams are simply sinked to and
0387           sourced from a virtual ALSA sound card created. The user-space
0388           application may choose to do whatever it wants with the data
0389           received from the USB Host and choose to provide whatever it
0390           wants as audio data to the USB Host.
0391 
0392 config USB_CONFIGFS_F_UAC1_LEGACY
0393         bool "Audio Class 1.0 (legacy implementation)"
0394         depends on USB_CONFIGFS
0395         depends on SND
0396         select USB_LIBCOMPOSITE
0397         select SND_PCM
0398         select USB_F_UAC1_LEGACY
0399         help
0400           This Audio function implements 1 AudioControl interface,
0401           1 AudioStreaming Interface each for USB-OUT and USB-IN.
0402           This is a legacy driver and requires a real Audio codec
0403           to be present on the device.
0404 
0405 config USB_CONFIGFS_F_UAC2
0406         bool "Audio Class 2.0"
0407         depends on USB_CONFIGFS
0408         depends on SND
0409         select USB_LIBCOMPOSITE
0410         select SND_PCM
0411         select USB_U_AUDIO
0412         select USB_F_UAC2
0413         help
0414           This Audio function is compatible with USB Audio Class
0415           specification 2.0. It implements 1 AudioControl interface,
0416           1 AudioStreaming Interface each for USB-OUT and USB-IN.
0417           This driver doesn't expect any real Audio codec to be present
0418           on the device - the audio streams are simply sinked to and
0419           sourced from a virtual ALSA sound card created. The user-space
0420           application may choose to do whatever it wants with the data
0421           received from the USB Host and choose to provide whatever it
0422           wants as audio data to the USB Host.
0423 
0424 config USB_CONFIGFS_F_MIDI
0425         bool "MIDI function"
0426         depends on USB_CONFIGFS
0427         depends on SND
0428         select USB_LIBCOMPOSITE
0429         select SND_RAWMIDI
0430         select USB_F_MIDI
0431         help
0432           The MIDI Function acts as a USB Audio device, with one MIDI
0433           input and one MIDI output. These MIDI jacks appear as
0434           a sound "card" in the ALSA sound system. Other MIDI
0435           connections can then be made on the gadget system, using
0436           ALSA's aconnect utility etc.
0437 
0438 config USB_CONFIGFS_F_HID
0439         bool "HID function"
0440         depends on USB_CONFIGFS
0441         select USB_F_HID
0442         help
0443           The HID function driver provides generic emulation of USB
0444           Human Interface Devices (HID).
0445 
0446           For more information, see Documentation/usb/gadget_hid.rst.
0447 
0448 config USB_CONFIGFS_F_UVC
0449         bool "USB Webcam function"
0450         depends on USB_CONFIGFS
0451         depends on VIDEO_DEV
0452         depends on VIDEO_DEV
0453         select VIDEOBUF2_DMA_SG
0454         select VIDEOBUF2_VMALLOC
0455         select USB_F_UVC
0456         help
0457           The Webcam function acts as a composite USB Audio and Video Class
0458           device. It provides a userspace API to process UVC control requests
0459           and stream video data to the host.
0460 
0461 config USB_CONFIGFS_F_PRINTER
0462         bool "Printer function"
0463         select USB_F_PRINTER
0464         depends on USB_CONFIGFS
0465         help
0466           The Printer function channels data between the USB host and a
0467           userspace program driving the print engine. The user space
0468           program reads and writes the device file /dev/g_printer<X> to
0469           receive or send printer data. It can use ioctl calls to
0470           the device file to get or set printer status.
0471 
0472           For more information, see Documentation/usb/gadget_printer.rst
0473           which includes sample code for accessing the device file.
0474 
0475 config USB_CONFIGFS_F_TCM
0476         bool "USB Gadget Target Fabric"
0477         depends on TARGET_CORE
0478         depends on USB_CONFIGFS
0479         select USB_LIBCOMPOSITE
0480         select USB_F_TCM
0481         help
0482           This fabric is a USB gadget component. Two USB protocols are
0483           supported that is BBB or BOT (Bulk Only Transport) and UAS
0484           (USB Attached SCSI). BOT is advertised on alternative
0485           interface 0 (primary) and UAS is on alternative interface 1.
0486           Both protocols can work on USB2.0 and USB3.0.
0487           UAS utilizes the USB 3.0 feature called streams support.
0488 
0489 source "drivers/usb/gadget/legacy/Kconfig"
0490 
0491 endif # USB_GADGET