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

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

libusbdev: Remove unused mutex.

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