Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 6: Device Drivers


camera only enabled, or both enabled. The bandwidth requirements of the device may differ
according to the interface selected.

❑ And finally, each interface may have one or moreend pointsthat are controlled by a driver. There
are situations in which a driver controls all end points of a device but each end point may require
a different driver. In our example above, theend points are the imaging video unit and the
microphone. Another common example of a device with two different end points is a USB key-
board that integrates a USB hub to permit the connection of other devices (a hub is ultimately a
special kind of USB device).

All USB devices are classified in categories; this is reflected in the fact that the source code for the indi-
vidual drivers is kept separate in the kernel sources.drivers/usb/contains a number of subdirectories
with the following contents:


❑ imagefor graphics and video devices such as digital cameras, scanners, and the like.
❑ inputfor input and output devices for communication with computer users. Classic represen-
tatives of this category include not only keyboards and mice but also touch screens, data gloves,
and the like.

❑ mediafor the numerous multimedia devices that have come to the fore in the last few years.

❑ netfor network cards that are attached to the computer by means of USB and are therefore often
referred to asadaptersthat bridge the gap between Ethernet and USB.

❑ storagefor all mass storage devices such as hard disks and the like.

❑ classincludes all drivers support devices of one of the standard classes defined for USB.

❑ corecontains drivers for host adapters to which a USB chain is attached.

Roughly speaking, the driver sources originate from the following three areas:standard devicessuch as
keyboards, mice, and the like that can always be supported by the same driver, regardless of device
vendor;proprietaryhardware such as MP3 players and other gadgets that require special drivers; and
drivers forhost adaptersthat are attached to the rest of the system via a different bus system (typically
PCI) and that establish the connection (also physical) to the USB device chain.


The USB standard defines four different transfer modes, each of which must be explicitly catered for by
the kernel.


❑ Control transferinvolves the transfer of control information needed (primarily) for the initial con-
figuration of a device. This type of communication must be safe and reliable but requires only
a narrow bandwidth. The various control commands are transferred by means of pre-defined
tokens whose symbolic names such asGET_STATUS,SET_INTERFACE, and so on have been defined
and documented in the USB standard. In the kernel sources they can all be found in<usb.h>,
where they are prefixed withUSQ_REQ_— to prevent namespace problems — and declared as
pre-processor constants. The standard mandates a minimum set of commands that all devices
must understand. However, vendors are free to add further device-specific commands that must
be used and understood by their own drivers.
❑ Bulk transferssend individual data packets that can take up the full bus bandwidth. In this
mode, data transfer takes place with the security guaranteed by the bus; in other words, data
Free download pdf