Linux USB Programming

Source: Internet
Author: User

LInux USB Architecture

you can see that a USB system requires 4 drivers: USB device driver (mainly written in this section) , USB Host Controller driver , Gadget Drive , UDC Drive .

There are 4 main features of USB:

Massstorage: High-capacity storage, such as hard disk, USB drive.

Usb-hid: Human Interface Device, mouse, keyboard.

RNDIS: Network card.

Cdc-acm:u turn the serial port.

USB Descriptor:

The USB driver is located between the different kernel subsystem and the USB host controller, and the USB core provides the USB driver with a software interface for accessing and controlling the USB hardware, so that the USB device driver does not have to consider the USB hardware controller.

From the view, a USB driver is corresponding to an interface, so a device may have multiple drivers.

USB bus driver and device Drive Structural Body

a USB drive uses struct Usb_driver to describe (each bus has driver this structure):

In the list of devices in the usb_device_id as follows:

Populating the above ip_table requires defining a usb_device (Vend,prod) that defines a USB device through Usb_device

Above is a definition of one, the following macro is defined as a class of

Registration drive:

Device Structural Body

Configuration Descriptor: To Configure the structure body:

L inux Kernel usage Struct Usb_host_config to describe a USB Configuration :

Configuration Descriptor struct Body:

Interface Descriptor: interface Structure Body:

L Inux kernel uses a struct usb_interface to describe the USB interface:

interface Setting structure body

The settings and configuration are different:

a Configuration contains one or more Interface

a Interface contains one or more Set

Here is an example:

L Inux kernel uses the struct usb_host_interface to describe the USB interface settings:

interface Descriptor Structure Body

Endpoint Descriptor: End Structure Body

L Inux kernel uses a struct usb_host_endpoint to describe the USB endpoint:

endpoint Descriptor Structure Body

L inux Kernel usage struct Usb_endpoint_decriptor to the USB descriptor. Endpoint Descriptor to describe

URB:

USB request block is a USB device driver used to describe the communication with the USB device basic carrier and core data structure, very similar to the network device driver in the SK_BUFF structure, is the USB host and device Communication "Radio wave."

The process of URB processing is as follows:

1. USB device driver creates and initializes a urb that accesses a specific endpoint of a specific USB device, and presented to the USB core;

2. USB Core submits the URB to the USB host controller driver;

3. the USB Host Controller driver accesses the USB device according to the information described by the URB.

4. When the device access is finished, the USB host controller driver notifies the USB device driver.

Process One

Create URB:

Initialize URB:

Process Two

process Three, process four:



From for notes (Wiz)

Linux USB Programming

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.