source: mainline/uspace/lib/usbdev/include/usb/dev/driver.h@ d7f7a4a

Last change on this file since d7f7a4a was d7f7a4a, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 3 years ago

Replace some license headers with SPDX identifier

Headers are replaced using tools/transorm-copyright.sh only
when it can be matched verbatim with the license header used
throughout most of the codebase.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*
2 * SPDX-FileCopyrightText: 2011 Vojtech Horky
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7/** @addtogroup libusbdev
8 * @{
9 */
10/** @file
11 * USB device driver framework.
12 */
13
14#ifndef LIBUSBDEV_DRIVER_H_
15#define LIBUSBDEV_DRIVER_H_
16
17#include <usb/dev/device.h>
18#include <usb/dev/pipes.h>
19
20/** USB driver ops. */
21typedef struct {
22 /** Callback when a new device was added to the system. */
23 errno_t (*device_add)(usb_device_t *);
24 /** Callback when a device is about to be removed from the system. */
25 errno_t (*device_remove)(usb_device_t *);
26 /** Callback when a device was removed from the system. */
27 errno_t (*device_gone)(usb_device_t *);
28 /** Callback asking the driver to online a specific function. */
29 errno_t (*function_online)(ddf_fun_t *);
30 /** Callback asking the driver to offline a specific function. */
31 errno_t (*function_offline)(ddf_fun_t *);
32} usb_driver_ops_t;
33
34/** USB driver structure. */
35typedef struct {
36 /** Driver name.
37 * This name is copied to the generic driver name and must be exactly
38 * the same as the directory name where the driver executable resides.
39 */
40 const char *name;
41 /** Expected endpoints description.
42 * This description shall exclude default control endpoint (pipe zero)
43 * and must be NULL terminated.
44 * When only control endpoint is expected, you may set NULL directly
45 * without creating one item array containing NULL.
46 *
47 * When the driver expect single interrupt in endpoint,
48 * the initialization may look like this:
49 *
50 * @code
51 * static usb_endpoint_description_t poll_endpoint_description = {
52 * .transfer_type = USB_TRANSFER_INTERRUPT,
53 * .direction = USB_DIRECTION_IN,
54 * .interface_class = USB_CLASS_HUB,
55 * .interface_subclass = 0,
56 * .interface_protocol = 0,
57 * .flags = 0
58 * };
59 *
60 * static usb_endpoint_description_t *hub_endpoints[] = {
61 * &poll_endpoint_description,
62 * NULL
63 * };
64 *
65 * static usb_driver_t hub_driver = {
66 * .endpoints = hub_endpoints,
67 * ...
68 * };
69 * @endcode
70 */
71 const usb_endpoint_description_t **endpoints;
72 /** Driver ops. */
73 const usb_driver_ops_t *ops;
74} usb_driver_t;
75
76int usb_driver_main(const usb_driver_t *);
77
78#endif
79/**
80 * @}
81 */
Note: See TracBrowser for help on using the repository browser.