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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 9162b27 was 6b433a8, checked in by Salmelu <salmelu@…>, 8 years ago

Isochronous transfers - endpoint initialization

  • Property mode set to 100644
File size: 4.4 KB
RevLine 
[6865243c]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 */
[160b75e]28/** @addtogroup libusbdev
[6865243c]29 * @{
30 */
31/** @file
[d714945]32 * USB pipes representation.
[6865243c]33 */
[7d521e24]34#ifndef LIBUSBDEV_PIPES_H_
35#define LIBUSBDEV_PIPES_H_
[6865243c]36
[1a38701]37#include <usb/usb.h>
38#include <usb/descriptor.h>
[8582076]39#include <usb_iface.h>
[6865243c]40
[c01987c]41#include <stdbool.h>
[8d2dd7f2]42#include <stddef.h>
43#include <stdint.h>
[c01987c]44
[c804484]45#define CTRL_PIPE_MIN_PACKET_SIZE 8
[a6add7a]46/** Abstraction of a logical connection to USB device endpoint.
[bdb23c63]47 * It encapsulates endpoint attributes (transfer type etc.).
[6865243c]48 * This endpoint must be bound with existing usb_device_connection_t
49 * (i.e. the wire to send data over).
50 */
51typedef struct {
[816f5f4]52 /** Endpoint description */
53 usb_endpoint_desc_t desc;
[fa0f53b]54 /** Whether to automatically reset halt on the endpoint.
55 * Valid only for control endpoint zero.
56 */
57 bool auto_reset_halt;
[d93f5afb]58 /** The connection used for sending the data. */
[8582076]59 usb_dev_session_t *bus_session;
[a372663]60} usb_pipe_t;
[6865243c]61
[93ef8f6]62/** Description of endpoint characteristics. */
63typedef struct {
64 /** Transfer type (e.g. control or interrupt). */
65 usb_transfer_type_t transfer_type;
66 /** Transfer direction (to or from a device). */
67 usb_direction_t direction;
68 /** Interface class this endpoint belongs to (-1 for any). */
69 int interface_class;
70 /** Interface subclass this endpoint belongs to (-1 for any). */
71 int interface_subclass;
[1110ebd]72 /** Interface protocol this endpoint belongs to (-1 for any). */
[93ef8f6]73 int interface_protocol;
74 /** Extra endpoint flags. */
75 unsigned int flags;
76} usb_endpoint_description_t;
77
78/** Mapping of endpoint pipes and endpoint descriptions. */
79typedef struct {
80 /** Endpoint pipe. */
[b77931d]81 usb_pipe_t pipe;
[93ef8f6]82 /** Endpoint description. */
83 const usb_endpoint_description_t *description;
[18cb870]84 /** Interface number the endpoint must belong to (-1 for any). */
[6105fc0]85 int interface_no;
[159b91f4]86 /** Alternate interface setting to choose. */
87 int interface_setting;
[93ef8f6]88 /** Found descriptor fitting the description. */
[b77931d]89 const usb_standard_endpoint_descriptor_t *descriptor;
[ec700c7]90 /** Relevant superspeed companion descriptor. */
91 const usb_superspeed_endpoint_companion_descriptor_t *companion_descriptor;
[a6add7a]92 /** Interface descriptor the endpoint belongs to. */
[b77931d]93 const usb_standard_interface_descriptor_t *interface;
[93ef8f6]94 /** Whether the endpoint was actually found. */
95 bool present;
96} usb_endpoint_mapping_t;
[6865243c]97
[d93f5afb]98int usb_pipe_initialize(usb_pipe_t *, usb_endpoint_t, usb_transfer_type_t,
[6b433a8]99 size_t, usb_direction_t, unsigned, unsigned, unsigned, unsigned, unsigned, usb_dev_session_t *);
[d93f5afb]100int usb_pipe_initialize_default_control(usb_pipe_t *, usb_dev_session_t *);
[bd575647]101
[3954a63b]102int usb_pipe_probe_default_control(usb_pipe_t *);
103int usb_pipe_initialize_from_configuration(usb_endpoint_mapping_t *,
[d93f5afb]104 size_t, const uint8_t *, size_t, usb_dev_session_t *);
[c804484]105
[bd575647]106int usb_pipe_register(usb_pipe_t *, unsigned);
107int usb_pipe_unregister(usb_pipe_t *);
[6865243c]108
[3954a63b]109int usb_pipe_read(usb_pipe_t *, void *, size_t, size_t *);
[b4292e7]110int usb_pipe_write(usb_pipe_t *, const void *, size_t);
[6865243c]111
[7a05ced0]112int usb_pipe_control_read(usb_pipe_t *, const void *, size_t,
[6865243c]113 void *, size_t, size_t *);
[3875af65]114int usb_pipe_control_write(usb_pipe_t *, const void *, size_t,
115 const void *, size_t);
[6865243c]116
117#endif
118/**
119 * @}
120 */
Note: See TracBrowser for help on using the repository browser.