source: mainline/uspace/drv/usbhid/usbhid.h@ 65c3794

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 65c3794 was 65c3794, checked in by Matus Dekanek <smekideki@…>, 15 years ago

change from lelian: USB hid subdriver receives parsed report from HID core
uhci root hub: change message level from info to debug

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