Changeset df6ded8 in mainline for uspace/lib/usb/include/usb/usb.h


Ignore:
Timestamp:
2018-02-28T16:37:50Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1b20da0
Parents:
f5e5f73 (diff), b2dca8de (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Jakub Jermar <jakub@…> (2018-02-28 16:06:42)
git-committer:
Jakub Jermar <jakub@…> (2018-02-28 16:37:50)
Message:

Merge github.com:helenos-xhci-team/helenos

This commit merges support for USB 3 and generally refactors, fixes,
extends and cleans up the existing USB framework.

Notable additions and features:

  • new host controller driver has been implemented to control various xHC models (among others, NEC Renesas uPD720200)
  • isochronous data transfer mode
  • support for explicit USB device removal
  • USB tablet driver
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/include/usb/usb.h

    rf5e5f73 rdf6ded8  
    11/*
    22 * Copyright (c) 2010 Vojtech Horky
     3 * Copyright (c) 2018 Ondrej Hlavaty, Michal Staruch
    34 * All rights reserved.
    45 *
     
    3940#include <stdint.h>
    4041#include <types/common.h>
    41 #include <usb_iface.h>
     42#include <usbhc_iface.h>
    4243
    4344/** Convert 16bit value from native (host) endianness to USB endianness. */
     
    5354#define uint32_usb2host(n) uint32_t_le2host((n))
    5455
    55 const char * usb_str_transfer_type(usb_transfer_type_t t);
    56 const char * usb_str_transfer_type_short(usb_transfer_type_t t);
     56const char *usb_str_transfer_type(usb_transfer_type_t);
     57const char *usb_str_transfer_type_short(usb_transfer_type_t);
    5758
    5859const char *usb_str_direction(usb_direction_t);
     
    6162{
    6263        return (s == USB_SPEED_FULL) || (s == USB_SPEED_LOW);
     64}
     65
     66static inline bool usb_speed_is_valid(const usb_speed_t s)
     67{
     68        return (s >= USB_SPEED_LOW) && (s < USB_SPEED_MAX);
    6369}
    6470
     
    97103static inline bool usb_address_is_valid(usb_address_t a)
    98104{
    99         return (a >= USB_ADDRESS_DEFAULT) && (a <= USB11_ADDRESS_MAX);
     105        return a <= USB11_ADDRESS_MAX;
    100106}
    101107
     
    103109#define USB_ENDPOINT_DEFAULT_CONTROL 0
    104110
    105 /** Maximum endpoint number in USB 1.1. */
    106 #define USB11_ENDPOINT_MAX 16
     111/** Maximum endpoint number in USB */
     112#define USB_ENDPOINT_MAX 16
     113
     114/** There might be two directions for every endpoint number (except 0) */
     115#define USB_ENDPOINT_COUNT (2 * USB_ENDPOINT_MAX)
    107116
    108117/** Check USB endpoint for allowed values.
     
    115124static inline bool usb_endpoint_is_valid(usb_endpoint_t ep)
    116125{
    117         return (ep >= USB_ENDPOINT_DEFAULT_CONTROL) &&
    118             (ep < USB11_ENDPOINT_MAX);
     126        return ep < USB_ENDPOINT_MAX;
    119127}
    120128
    121 /** Check USB target for allowed values (address and endpoint).
     129/**
     130 * Check USB target for allowed values (address, endpoint, stream).
    122131 *
    123132 * @param target.
    124133 * @return True, if values are wihtin limits, false otherwise.
    125134 */
    126 static inline bool usb_target_is_valid(usb_target_t target)
     135static inline bool usb_target_is_valid(const usb_target_t *target)
    127136{
    128         return usb_address_is_valid(target.address) &&
    129             usb_endpoint_is_valid(target.endpoint);
     137        return usb_address_is_valid(target->address) &&
     138            usb_endpoint_is_valid(target->endpoint);
     139
     140        // A 16-bit Stream ID is always valid.
    130141}
    131142
     
    136147 * @return Whether @p a and @p b points to the same pipe on the same device.
    137148 */
    138 static inline int usb_target_same(usb_target_t a, usb_target_t b)
     149static inline bool usb_target_same(usb_target_t a, usb_target_t b)
    139150{
    140         return (a.address == b.address)
    141             && (a.endpoint == b.endpoint);
     151        return (a.address == b.address) && (a.endpoint == b.endpoint);
    142152}
    143 
    144 /** General handle type.
    145  * Used by various USB functions as opaque handle.
    146  */
    147 typedef sysarg_t usb_handle_t;
    148153
    149154/** USB packet identifier. */
     
    161166        USB_PID_SETUP = _MAKE_PID(3, 1),
    162167
    163         USB_PID_DATA0 = _MAKE_PID(0 ,3),
    164         USB_PID_DATA1 = _MAKE_PID(2 ,3),
     168        USB_PID_DATA0 = _MAKE_PID(0, 3),
     169        USB_PID_DATA1 = _MAKE_PID(2, 3),
    165170
    166         USB_PID_ACK = _MAKE_PID(0 ,2),
    167         USB_PID_NAK = _MAKE_PID(2 ,2),
    168         USB_PID_STALL = _MAKE_PID(3 ,2),
     171        USB_PID_ACK = _MAKE_PID(0, 2),
     172        USB_PID_NAK = _MAKE_PID(2, 2),
     173        USB_PID_STALL = _MAKE_PID(3, 2),
    169174
    170         USB_PID_PRE = _MAKE_PID(3 ,0),
     175        USB_PID_PRE = _MAKE_PID(3, 0),
    171176        /* USB_PID_ = _MAKE_PID( ,), */
    172177#undef _MAKE_PID
Note: See TracChangeset for help on using the changeset viewer.