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

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

libusbdev: Sanitize headers.

Include what you use.
https://code.google.com/p/include-what-you-use/

  • Property mode set to 100644
File size: 4.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/** @addtogroup libusbdev
29 * @{
30 */
31/** @file
32 * USB pipes representation.
33 */
34#ifndef LIBUSBDEV_PIPES_H_
35#define LIBUSBDEV_PIPES_H_
36
37#include <usb/usb.h>
38#include <usb/descriptor.h>
39#include <usb_iface.h>
40
41#include <stdbool.h>
42#include <sys/types.h>
43
44#define CTRL_PIPE_MIN_PACKET_SIZE 8
45/** Abstraction of a logical connection to USB device endpoint.
46 * It encapsulates endpoint attributes (transfer type etc.).
47 * This endpoint must be bound with existing usb_device_connection_t
48 * (i.e. the wire to send data over).
49 */
50typedef struct {
51 /** Endpoint number. */
52 usb_endpoint_t endpoint_no;
53
54 /** Endpoint transfer type. */
55 usb_transfer_type_t transfer_type;
56
57 /** Endpoint direction. */
58 usb_direction_t direction;
59
60 /** Maximum packet size for the endpoint. */
61 size_t max_packet_size;
62
63 /** Whether to automatically reset halt on the endpoint.
64 * Valid only for control endpoint zero.
65 */
66 bool auto_reset_halt;
67
68 /** The connection used for sending the data. */
69 usb_dev_session_t *bus_session;
70} usb_pipe_t;
71
72/** Description of endpoint characteristics. */
73typedef struct {
74 /** Transfer type (e.g. control or interrupt). */
75 usb_transfer_type_t transfer_type;
76 /** Transfer direction (to or from a device). */
77 usb_direction_t direction;
78 /** Interface class this endpoint belongs to (-1 for any). */
79 int interface_class;
80 /** Interface subclass this endpoint belongs to (-1 for any). */
81 int interface_subclass;
82 /** Interface protocol this endpoint belongs to (-1 for any). */
83 int interface_protocol;
84 /** Extra endpoint flags. */
85 unsigned int flags;
86} usb_endpoint_description_t;
87
88/** Mapping of endpoint pipes and endpoint descriptions. */
89typedef struct {
90 /** Endpoint pipe. */
91 usb_pipe_t pipe;
92 /** Endpoint description. */
93 const usb_endpoint_description_t *description;
94 /** Interface number the endpoint must belong to (-1 for any). */
95 int interface_no;
96 /** Alternate interface setting to choose. */
97 int interface_setting;
98 /** Found descriptor fitting the description. */
99 const usb_standard_endpoint_descriptor_t *descriptor;
100 /** Interface descriptor the endpoint belongs to. */
101 const usb_standard_interface_descriptor_t *interface;
102 /** Whether the endpoint was actually found. */
103 bool present;
104} usb_endpoint_mapping_t;
105
106int usb_pipe_initialize(usb_pipe_t *, usb_endpoint_t, usb_transfer_type_t,
107 size_t, usb_direction_t, usb_dev_session_t *);
108int usb_pipe_initialize_default_control(usb_pipe_t *, usb_dev_session_t *);
109
110int usb_pipe_probe_default_control(usb_pipe_t *);
111int usb_pipe_initialize_from_configuration(usb_endpoint_mapping_t *,
112 size_t, const uint8_t *, size_t, usb_dev_session_t *);
113
114int usb_pipe_register(usb_pipe_t *, unsigned);
115int usb_pipe_unregister(usb_pipe_t *);
116
117int usb_pipe_read(usb_pipe_t *, void *, size_t, size_t *);
118int usb_pipe_write(usb_pipe_t *, const void *, size_t);
119
120int usb_pipe_control_read(usb_pipe_t *, const void *, size_t,
121 void *, size_t, size_t *);
122int usb_pipe_control_write(usb_pipe_t *, const void *, size_t,
123 const void *, size_t);
124
125#endif
126/**
127 * @}
128 */
Note: See TracBrowser for help on using the repository browser.