source: mainline/uspace/lib/usbdev/include/usb/dev/request.h@ 095bddfc

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 095bddfc was 095bddfc, checked in by Jan Vesely <jano.vesely@…>, 14 years ago

libusbdev, usbmid: Minor changes.

  • Property mode set to 100644
File size: 5.4 KB
Line 
1/*
2 * Copyright (c) 2011 Vojtech Horky
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 libusbdev
30 * @{
31 */
32/** @file
33 * Standard USB requests.
34 */
35#ifndef LIBUSBDEV_REQUEST_H_
36#define LIBUSBDEV_REQUEST_H_
37
38#include <sys/types.h>
39#include <l18n/langs.h>
40#include <usb/usb.h>
41#include <usb/dev/pipes.h>
42#include <usb/descriptor.h>
43
44/** USB device status - device is self powered (opposed to bus powered). */
45#define USB_DEVICE_STATUS_SELF_POWERED ((uint16_t)(1 << 0))
46
47/** USB device status - remote wake-up signaling is enabled. */
48#define USB_DEVICE_STATUS_REMOTE_WAKEUP ((uint16_t)(1 << 1))
49
50/** USB endpoint status - endpoint is halted (stalled). */
51#define USB_ENDPOINT_STATUS_HALTED ((uint16_t)(1 << 0))
52
53/** USB feature selector - endpoint halt (stall). */
54#define USB_FEATURE_SELECTOR_ENDPOINT_HALT (0)
55
56/** USB feature selector - device remote wake-up. */
57#define USB_FEATURE_SELECTOR_REMOTE_WAKEUP (1)
58
59/** Standard device request. */
60typedef enum {
61 USB_DEVREQ_GET_STATUS = 0,
62 USB_DEVREQ_CLEAR_FEATURE = 1,
63 USB_DEVREQ_SET_FEATURE = 3,
64 USB_DEVREQ_SET_ADDRESS = 5,
65 USB_DEVREQ_GET_DESCRIPTOR = 6,
66 USB_DEVREQ_SET_DESCRIPTOR = 7,
67 USB_DEVREQ_GET_CONFIGURATION = 8,
68 USB_DEVREQ_SET_CONFIGURATION = 9,
69 USB_DEVREQ_GET_INTERFACE = 10,
70 USB_DEVREQ_SET_INTERFACE = 11,
71 USB_DEVREQ_SYNCH_FRAME = 12,
72 USB_DEVREQ_LAST_STD
73} usb_stddevreq_t;
74
75/** Device request setup packet.
76 * The setup packet describes the request.
77 */
78typedef struct {
79 /** Request type.
80 * The type combines transfer direction, request type and
81 * intended recipient.
82 */
83 uint8_t request_type;
84#define SETUP_REQUEST_TYPE_DEVICE_TO_HOST (1 << 7)
85
86 /** Request identification. */
87 uint8_t request;
88 /** Main parameter to the request. */
89 union {
90 uint16_t value;
91 /* FIXME: add #ifdefs according to host endianness */
92 struct {
93 uint8_t value_low;
94 uint8_t value_high;
95 };
96 };
97 /** Auxiliary parameter to the request.
98 * Typically, it is offset to something.
99 */
100 uint16_t index;
101 /** Length of extra data. */
102 uint16_t length;
103} __attribute__ ((packed)) usb_device_request_setup_packet_t;
104
105int usb_control_request_set(usb_pipe_t *,
106 usb_request_type_t, usb_request_recipient_t, uint8_t,
107 uint16_t, uint16_t, void *, size_t);
108
109int usb_control_request_get(usb_pipe_t *,
110 usb_request_type_t, usb_request_recipient_t, uint8_t,
111 uint16_t, uint16_t, void *, size_t, size_t *);
112
113int usb_request_get_status(usb_pipe_t *, usb_request_recipient_t,
114 uint16_t, uint16_t *);
115int usb_request_clear_feature(usb_pipe_t *, usb_request_type_t,
116 usb_request_recipient_t, uint16_t, uint16_t);
117int usb_request_set_feature(usb_pipe_t *, usb_request_type_t,
118 usb_request_recipient_t, uint16_t, uint16_t);
119int usb_request_get_descriptor(usb_pipe_t *, usb_request_type_t,
120 usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void *, size_t,
121 size_t *);
122int usb_request_get_descriptor_alloc(usb_pipe_t *, usb_request_type_t,
123 usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void **, size_t *);
124int usb_request_get_device_descriptor(usb_pipe_t *,
125 usb_standard_device_descriptor_t *);
126int usb_request_get_bare_configuration_descriptor(usb_pipe_t *, int,
127 usb_standard_configuration_descriptor_t *);
128int usb_request_get_full_configuration_descriptor(usb_pipe_t *, int,
129 void *, size_t, size_t *);
130int usb_request_get_full_configuration_descriptor_alloc(usb_pipe_t *,
131 int, void **, size_t *);
132int usb_request_set_descriptor(usb_pipe_t *, usb_request_type_t,
133 usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void *, size_t);
134
135int usb_request_get_configuration(usb_pipe_t *, uint8_t *);
136int usb_request_set_configuration(usb_pipe_t *, uint8_t);
137int usb_request_get_interface(usb_pipe_t *, uint8_t, uint8_t *);
138int usb_request_set_interface(usb_pipe_t *, uint8_t, uint8_t);
139
140int usb_request_get_supported_languages(usb_pipe_t *,
141 l18_win_locales_t **, size_t *);
142int usb_request_get_string(usb_pipe_t *, size_t, l18_win_locales_t,
143 char **);
144
145int usb_request_clear_endpoint_halt(usb_pipe_t *, uint16_t);
146int usb_pipe_clear_halt(usb_pipe_t *, usb_pipe_t *);
147int usb_request_get_endpoint_status(usb_pipe_t *, usb_pipe_t *, uint16_t *);
148
149#endif
150/**
151 * @}
152 */
Note: See TracBrowser for help on using the repository browser.