Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 820d9bc in mainline


Ignore:
Timestamp:
2017-11-22T13:54:05Z (4 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master
Children:
d42ba37
Parents:
64fea02
Message:

usb: move toggle resetting to libusbhost

Location:
uspace/lib
Files:
4 edited

Legend:

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

    r64fea02 r820d9bc  
    113113static_assert(sizeof(usb_device_request_setup_packet_t) == USB_SETUP_PACKET_SIZE);
    114114
    115 /** How many toggles need to be reset */
    116 typedef enum {
    117         RESET_NONE,
    118         RESET_EP,
    119         RESET_ALL
    120 } toggle_reset_mode_t;
    121 
    122 toggle_reset_mode_t usb_request_get_toggle_reset_mode(
    123     const usb_device_request_setup_packet_t *request);
    124 
    125115#define GET_DEVICE_DESC(size) \
    126116{ \
  • uspace/lib/usb/src/usb.c

    r64fea02 r820d9bc  
    119119}
    120120
    121 /** Check setup packet data for signs of toggle reset.
    122  *
    123  * @param[in] requst Setup requst data.
    124  *
    125  * @retval -1 No endpoints need reset.
    126  * @retval 0 All endpoints need reset.
    127  * @retval >0 Specified endpoint needs reset.
    128  *
    129  */
    130 toggle_reset_mode_t usb_request_get_toggle_reset_mode(
    131     const usb_device_request_setup_packet_t *request)
    132 {
    133         assert(request);
    134         switch (request->request)
    135         {
    136         /* Clear Feature ENPOINT_STALL */
    137         case USB_DEVREQ_CLEAR_FEATURE: /*resets only cleared ep */
    138                 /* 0x2 ( HOST to device | STANDART | TO ENPOINT) */
    139                 if ((request->request_type == 0x2) &&
    140                     (request->value == USB_FEATURE_ENDPOINT_HALT))
    141                         return RESET_EP;
    142                 break;
    143         case USB_DEVREQ_SET_CONFIGURATION:
    144         case USB_DEVREQ_SET_INTERFACE:
    145                 /* Recipient must be device, this resets all endpoints,
    146                  * In fact there should be no endpoints but EP 0 registered
    147                  * as different interfaces use different endpoints,
    148                  * unless you're changing configuration or alternative
    149                  * interface of an already setup device. */
    150                 if (!(request->request_type & SETUP_REQUEST_TYPE_DEVICE_TO_HOST))
    151                         return RESET_ALL;
    152                 break;
    153         default:
    154                 break;
    155         }
    156 
    157         return RESET_NONE;
    158 }
    159 
    160121/**
    161122 * @}
  • uspace/lib/usbhost/include/usb/host/hcd.h

    r64fea02 r820d9bc  
    112112    const char *);
    113113
     114/** How many toggles need to be reset */
     115typedef enum {
     116        RESET_NONE,
     117        RESET_EP,
     118        RESET_ALL
     119} toggle_reset_mode_t;
     120
    114121#endif
    115122
  • uspace/lib/usbhost/src/hcd.c

    r64fea02 r820d9bc  
    147147}
    148148
     149/** Check setup packet data for signs of toggle reset.
     150 *
     151 * @param[in] requst Setup requst data.
     152 *
     153 * @retval -1 No endpoints need reset.
     154 * @retval 0 All endpoints need reset.
     155 * @retval >0 Specified endpoint needs reset.
     156 *
     157 */
     158static toggle_reset_mode_t hcd_get_request_toggle_reset_mode(
     159    const usb_device_request_setup_packet_t *request)
     160{
     161        assert(request);
     162        switch (request->request)
     163        {
     164        /* Clear Feature ENPOINT_STALL */
     165        case USB_DEVREQ_CLEAR_FEATURE: /*resets only cleared ep */
     166                /* 0x2 ( HOST to device | STANDART | TO ENPOINT) */
     167                if ((request->request_type == 0x2) &&
     168                    (request->value == USB_FEATURE_ENDPOINT_HALT))
     169                        return RESET_EP;
     170                break;
     171        case USB_DEVREQ_SET_CONFIGURATION:
     172        case USB_DEVREQ_SET_INTERFACE:
     173                /* Recipient must be device, this resets all endpoints,
     174                 * In fact there should be no endpoints but EP 0 registered
     175                 * as different interfaces use different endpoints,
     176                 * unless you're changing configuration or alternative
     177                 * interface of an already setup device. */
     178                if (!(request->request_type & SETUP_REQUEST_TYPE_DEVICE_TO_HOST))
     179                        return RESET_ALL;
     180                break;
     181        default:
     182                break;
     183        }
     184
     185        return RESET_NONE;
     186}
     187
    149188/** Prepare generic usb_transfer_batch and schedule it.
    150189 * @param hcd Host controller driver.
     
    207246        if (ep->transfer_type == USB_TRANSFER_CONTROL)
    208247                batch->toggle_reset_mode
    209                         = usb_request_get_toggle_reset_mode(&batch->setup.packet);
     248                        = hcd_get_request_toggle_reset_mode(&batch->setup.packet);
    210249
    211250        const int ret = hcd->ops.schedule(hcd, batch);
Note: See TracChangeset for help on using the changeset viewer.