Changeset df6ded8 in mainline for uspace/drv/nic/ar9271/ath_usb.c


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/drv/nic/ar9271/ath_usb.c

    rf5e5f73 rdf6ded8  
    11/*
    22 * Copyright (c) 2015 Jan Kolarik
     3 * Copyright (c) 2018 Ondrej Hlavaty
    34 * All rights reserved.
    45 *
     
    5960 *
    6061 */
    61 errno_t ath_usb_init(ath_t *ath, usb_device_t *usb_device)
     62errno_t ath_usb_init(ath_t *ath, usb_device_t *usb_device, const usb_endpoint_description_t **endpoints)
    6263{
    6364        ath_usb_t *ath_usb = malloc(sizeof(ath_usb_t));
     
    7071        ath_usb->usb_device = usb_device;
    7172       
    72         /* TODO: Assign by iterating over pipes. */
    73         ath_usb->output_data_pipe_number = 0;
    74         ath_usb->input_data_pipe_number = 1;
    75         ath_usb->input_ctrl_pipe_number = 2;
    76         ath_usb->output_ctrl_pipe_number = 3;
     73        int rc;
     74
     75#define _MAP_EP(target, ep_no) do {\
     76        usb_endpoint_mapping_t *epm = usb_device_get_mapped_ep_desc(usb_device, endpoints[ep_no]);\
     77        if (!epm || !epm->present) {\
     78                usb_log_error("Failed to map endpoint: " #ep_no ".");\
     79                rc = ENOENT;\
     80                goto err_ath_usb;\
     81        }\
     82        target = &epm->pipe;\
     83        } while (0);
     84
     85        _MAP_EP(ath_usb->output_data_pipe, 0);
     86        _MAP_EP(ath_usb->input_data_pipe, 1);
     87        _MAP_EP(ath_usb->input_ctrl_pipe, 2);
     88        _MAP_EP(ath_usb->output_ctrl_pipe, 3);
     89
     90#undef _MAP_EP
    7791       
    7892        ath->ctrl_response_length = 64;
     
    8397       
    8498        return EOK;
     99err_ath_usb:
     100        free(ath_usb);
     101        return rc;
    85102}
    86103
     
    98115{
    99116        ath_usb_t *ath_usb = (ath_usb_t *) ath->specific_data;
    100         usb_pipe_t *pipe = &usb_device_get_mapped_ep(
    101             ath_usb->usb_device, ath_usb->output_ctrl_pipe_number)->pipe;
    102        
    103         return usb_pipe_write(pipe, buffer, buffer_size);
     117        return usb_pipe_write(ath_usb->output_ctrl_pipe, buffer, buffer_size);
    104118}
    105119
     
    118132{
    119133        ath_usb_t *ath_usb = (ath_usb_t *) ath->specific_data;
    120         usb_pipe_t *pipe = &usb_device_get_mapped_ep(
    121             ath_usb->usb_device, ath_usb->input_ctrl_pipe_number)->pipe;
    122        
    123         return usb_pipe_read(pipe, buffer, buffer_size, transferred_size);
     134        return usb_pipe_read(ath_usb->input_ctrl_pipe, buffer, buffer_size, transferred_size);
    124135}
    125136
     
    148159       
    149160        ath_usb_t *ath_usb = (ath_usb_t *) ath->specific_data;
    150         usb_pipe_t *pipe = &usb_device_get_mapped_ep(
    151             ath_usb->usb_device, ath_usb->output_data_pipe_number)->pipe;
    152        
    153         errno_t ret_val = usb_pipe_write(pipe, complete_buffer,
    154             complete_buffer_size);
     161        const errno_t ret_val = usb_pipe_write(ath_usb->output_data_pipe,
     162            complete_buffer, complete_buffer_size);
    155163       
    156164        free(complete_buffer);
     
    173181{
    174182        ath_usb_t *ath_usb = (ath_usb_t *) ath->specific_data;
    175         usb_pipe_t *pipe = &usb_device_get_mapped_ep(
    176             ath_usb->usb_device, ath_usb->input_data_pipe_number)->pipe;
    177        
    178         return usb_pipe_read(pipe, buffer, buffer_size, transferred_size);
     183        return usb_pipe_read(ath_usb->input_data_pipe, buffer, buffer_size, transferred_size);
    179184}
Note: See TracChangeset for help on using the changeset viewer.