source: mainline/uspace/drv/hid/usbhid/usbhid.h@ 9af56b6

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 9af56b6 was e0a5d4c, checked in by Ondřej Hlavatý <aearsis@…>, 7 years ago

usb: update copyrights

The data was generated by a script, guided manually. If you feel your
name is missing somewhere, please add it!

The semi-automated process was roughly:

1) Changes per file and author (limited to our team) were counted
2) Trivial numbers were thrown away
3) Authors were sorted by lines added to file
4) All previous copyrights were replaced by the newly generated one
5) Hunks changing only year were discarded

It seems that a lot of my copyrights were added. It is due to me being
both sticking my nose everywhere and lazy to update the copyright right
away :)

  • Property mode set to 100644
File size: 4.5 KB
Line 
1/*
2 * Copyright (c) 2011 Lubos Slovak
3 * Copyright (c) 2018 Petr Manek
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/** @addtogroup drvusbhid
31 * @{
32 */
33/** @file
34 * USB HID driver API.
35 */
36
37#ifndef USB_HID_USBHID_H_
38#define USB_HID_USBHID_H_
39
40#include <stdint.h>
41
42#include <usb/hid/hidparser.h>
43#include <ddf/driver.h>
44#include <usb/dev/pipes.h>
45#include <usb/dev/driver.h>
46#include <usb/dev/poll.h>
47#include <usb/hid/hid.h>
48#include <stdbool.h>
49
50typedef struct usb_hid_dev usb_hid_dev_t;
51typedef struct usb_hid_subdriver usb_hid_subdriver_t;
52
53/** Subdriver initialization callback.
54 *
55 * @param dev Backing USB HID device.
56 * @param data Custom subdriver data (pointer where to store them).
57 * @return Error code.
58 */
59typedef errno_t (*usb_hid_driver_init_t)(usb_hid_dev_t *dev, void **data);
60
61/** Subdriver deinitialization callback.
62 *
63 * @param dev Backing USB HID device.
64 * @param data Custom subdriver data.
65 */
66typedef void (*usb_hid_driver_deinit_t)(usb_hid_dev_t *dev, void *data);
67
68/** Subdriver callback on data from device.
69 *
70 * @param dev Backing USB HID device.
71 * @param data Custom subdriver data.
72 * @return Whether to continue polling (typically true always).
73 */
74typedef bool (*usb_hid_driver_poll_t)(usb_hid_dev_t *dev, void *data);
75
76/** Subdriver callback after communication with the device ceased.
77 *
78 * @param dev Backing USB HID device.
79 * @param data Custom subdriver data.
80 * @param ended_due_to_errors Whether communication ended due to errors in
81 * communication (true) or deliberately by driver (false).
82 */
83typedef void (*usb_hid_driver_poll_ended_t)(usb_hid_dev_t *dev, void *data,
84 bool ended_due_to_errors);
85
86struct usb_hid_subdriver {
87 /** Function to be called when initializing HID device. */
88 usb_hid_driver_init_t init;
89 /** Function to be called when destroying the HID device structure. */
90 usb_hid_driver_deinit_t deinit;
91 /** Function to be called when data arrives from the device. */
92 usb_hid_driver_poll_t poll;
93 /** Function to be called when polling ends. */
94 usb_hid_driver_poll_ended_t poll_end;
95 /** Arbitrary data needed by the subdriver. */
96 void *data;
97};
98
99
100/**
101 * Structure for holding general HID device data.
102 */
103struct usb_hid_dev {
104 /** Structure holding generic USB device information. */
105 usb_device_t *usb_dev;
106
107 /** Endpont mapping of the polling pipe. */
108 usb_endpoint_mapping_t *poll_pipe_mapping;
109
110 /** Device polling structure. */
111 usb_polling_t polling;
112
113 /** Subdrivers. */
114 usb_hid_subdriver_t *subdrivers;
115
116 /** Number of subdrivers. */
117 unsigned subdriver_count;
118
119 /** Report descriptor. */
120 uint8_t *report_desc;
121
122 /** Report descriptor size. */
123 size_t report_desc_size;
124
125 /** HID Report parser. */
126 usb_hid_report_t report;
127
128 uint8_t report_id;
129
130 uint8_t *input_report;
131
132 size_t input_report_size;
133 size_t max_input_report_size;
134
135 int report_nr;
136 volatile bool running;
137};
138
139extern const usb_endpoint_description_t *usb_hid_endpoints[];
140
141errno_t usb_hid_init(usb_hid_dev_t *hid_dev, usb_device_t *dev);
142
143void usb_hid_deinit(usb_hid_dev_t *hid_dev);
144
145void usb_hid_new_report(usb_hid_dev_t *hid_dev);
146
147int usb_hid_report_number(const usb_hid_dev_t *hid_dev);
148
149#endif /* USB_HID_USBHID_H_ */
150
151/**
152 * @}
153 */
Note: See TracBrowser for help on using the repository browser.