source: mainline/uspace/lib/usbdev/include/usb/dev/pipes.h@ 7871c69

Last change on this file since 7871c69 was d7f7a4a, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 4 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: 3.3 KB
Line 
1/*
2 * SPDX-FileCopyrightText: 2011 Vojtech Horky
3 * SPDX-FileCopyrightText: 2018 Ondrej Hlavaty
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7/** @addtogroup libusbdev
8 * @{
9 */
10/** @file
11 * USB pipes representation.
12 */
13#ifndef LIBUSBDEV_PIPES_H_
14#define LIBUSBDEV_PIPES_H_
15
16#include <usb/usb.h>
17#include <usb/descriptor.h>
18#include <usb_iface.h>
19
20#include <stdbool.h>
21#include <stddef.h>
22#include <stdint.h>
23
24#define CTRL_PIPE_MIN_PACKET_SIZE 8
25
26/** Abstraction of a logical connection to USB device endpoint.
27 * It contains some vital information about the pipe.
28 * This endpoint must be bound with existing usb_device_connection_t
29 * (i.e. the wire to send data over).
30 */
31typedef struct {
32 /** Pipe description received from HC */
33 usb_pipe_desc_t desc;
34
35 /** Whether to automatically reset halt on the endpoint.
36 * Valid only for control endpoint zero.
37 */
38 bool auto_reset_halt;
39 /** The connection used for sending the data. */
40 usb_dev_session_t *bus_session;
41} usb_pipe_t;
42
43/** Description of endpoint characteristics. */
44typedef struct {
45 /** Transfer type (e.g. control or interrupt). */
46 usb_transfer_type_t transfer_type;
47 /** Transfer direction (to or from a device). */
48 usb_direction_t direction;
49 /** Interface class this endpoint belongs to (-1 for any). */
50 int interface_class;
51 /** Interface subclass this endpoint belongs to (-1 for any). */
52 int interface_subclass;
53 /** Interface protocol this endpoint belongs to (-1 for any). */
54 int interface_protocol;
55 /** Extra endpoint flags. */
56 unsigned int flags;
57} usb_endpoint_description_t;
58
59/** Mapping of endpoint pipes and endpoint descriptions. */
60typedef struct {
61 /** Endpoint pipe. */
62 usb_pipe_t pipe;
63 /** Endpoint description. */
64 const usb_endpoint_description_t *description;
65 /** Interface number the endpoint must belong to (-1 for any). */
66 int interface_no;
67 /** Alternate interface setting to choose. */
68 int interface_setting;
69 /** Found descriptor fitting the description. */
70 const usb_standard_endpoint_descriptor_t *descriptor;
71 /** Relevant superspeed companion descriptor. */
72 const usb_superspeed_endpoint_companion_descriptor_t
73 *companion_descriptor;
74 /** Interface descriptor the endpoint belongs to. */
75 const usb_standard_interface_descriptor_t *interface;
76 /** Whether the endpoint was actually found. */
77 bool present;
78} usb_endpoint_mapping_t;
79
80errno_t usb_pipe_initialize(usb_pipe_t *, usb_dev_session_t *);
81errno_t usb_pipe_initialize_default_control(usb_pipe_t *, usb_dev_session_t *);
82
83errno_t usb_pipe_initialize_from_configuration(usb_endpoint_mapping_t *,
84 size_t, const uint8_t *, size_t, usb_dev_session_t *);
85
86errno_t usb_pipe_register(usb_pipe_t *,
87 const usb_standard_endpoint_descriptor_t *,
88 const usb_superspeed_endpoint_companion_descriptor_t *);
89errno_t usb_pipe_unregister(usb_pipe_t *);
90
91errno_t usb_pipe_read(usb_pipe_t *, void *, size_t, size_t *);
92errno_t usb_pipe_write(usb_pipe_t *, const void *, size_t);
93
94errno_t usb_pipe_read_dma(usb_pipe_t *, void *, void *, size_t, size_t *);
95errno_t usb_pipe_write_dma(usb_pipe_t *, void *, void *, size_t);
96
97errno_t usb_pipe_control_read(usb_pipe_t *, const void *, size_t,
98 void *, size_t, size_t *);
99errno_t usb_pipe_control_write(usb_pipe_t *, const void *, size_t,
100 const void *, size_t);
101
102void *usb_pipe_alloc_buffer(usb_pipe_t *, size_t);
103void usb_pipe_free_buffer(usb_pipe_t *, void *);
104#endif
105/**
106 * @}
107 */
Note: See TracBrowser for help on using the repository browser.