Changeset 4e732f1a in mainline


Ignore:
Timestamp:
2014-01-24T02:10:16Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
42de21a
Parents:
3de7a62
Message:

usb: Add support for multiple packets per microframe.

Location:
uspace
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ehci/hw_struct/queue_head.c

    r3de7a62 r4e732f1a  
    7979        }
    8080
    81         // TODO Fix 'multi' 1 packet should be safe. Probably won't work
    82         // without enabling parking mode in async schedule
    8381        // TODO Figure out how to correctly use CMASK and SMASK for LS/FS
    8482        // INT transfers. Current values are just guesses
    85         /* Setting TT stuff on HS endpoints is OK, the fields are ignored */
     83        /* Setting TT stuff on HS endpoints is OK, the fields are ignored,
     84         * and so is setting multi on async (should be 1 anyway)*/
    8685        EHCI_MEM32_WR(instance->ep_cap,
    87             QH_EP_CAP_MULTI_SET(1) |
     86            QH_EP_CAP_MULTI_SET(ep->packets) |
    8887            QH_EP_CAP_TT_PORT_SET(ep->tt.port) |
    8988            QH_EP_CAP_TT_ADDR_SET(ep->tt.address) |
  • uspace/drv/bus/usb/ehci/hw_struct/queue_head.h

    r3de7a62 r4e732f1a  
    3939#include <usb/host/endpoint.h>
    4040
     41#include "../utils/malloc32.h"
    4142#include "link_pointer.h"
    4243#include "mem_access.h"
  • uspace/drv/bus/usb/ohci/hw_struct/endpoint_descriptor.c

    r3de7a62 r4e732f1a  
    6363{
    6464        assert(instance);
    65         memset(instance, 0, sizeof(ed_t));
     65        memset(instance, 0, sizeof(*instance));
    6666
    6767        if (ep == NULL) {
  • uspace/lib/drv/generic/remote_usb.c

    r3de7a62 r4e732f1a  
    161161}
    162162
     163int static_assert[sizeof(sysarg_t) >= 4 ? 1 : -1];
     164typedef union {
     165        uint8_t arr[sizeof(sysarg_t)];
     166        sysarg_t arg;
     167} pack8_t;
     168
    163169int usb_register_endpoint(async_exch_t *exch, usb_endpoint_t endpoint,
    164170    usb_transfer_type_t type, usb_direction_t direction,
    165     size_t mps, unsigned interval)
    166 {
    167         if (!exch)
    168                 return EBADMEM;
    169 #define _PACK2(high, low) (((high & 0xffff) << 16) | (low & 0xffff))
     171    size_t mps, unsigned packets, unsigned interval)
     172{
     173        if (!exch)
     174                return EBADMEM;
     175        pack8_t pack;
     176        pack.arr[0] = type;
     177        pack.arr[1] = direction;
     178        pack.arr[2] = interval;
     179        pack.arr[3] = packets;
    170180
    171181        return async_req_4_0(exch, DEV_IFACE_ID(USB_DEV_IFACE),
    172             IPC_M_USB_REGISTER_ENDPOINT, endpoint,
    173             _PACK2(type, direction), _PACK2(mps, interval));
    174 
    175 #undef _PACK2
     182            IPC_M_USB_REGISTER_ENDPOINT, endpoint, pack.arg, mps);
     183
    176184}
    177185
     
    408416        }
    409417
    410 #define _INIT_FROM_HIGH_DATA2(type, var, arg_no) \
    411         type var = (type) (DEV_IPC_GET_ARG##arg_no(*call) >> 16)
    412 #define _INIT_FROM_LOW_DATA2(type, var, arg_no) \
    413         type var = (type) (DEV_IPC_GET_ARG##arg_no(*call) & 0xffff)
    414 
    415418        const usb_endpoint_t endpoint = DEV_IPC_GET_ARG1(*call);
    416 
    417         _INIT_FROM_HIGH_DATA2(usb_transfer_type_t, transfer_type, 2);
    418         _INIT_FROM_LOW_DATA2(usb_direction_t, direction, 2);
    419 
    420         _INIT_FROM_HIGH_DATA2(size_t, max_packet_size, 3);
    421         _INIT_FROM_LOW_DATA2(unsigned int, interval, 3);
    422 
    423 #undef _INIT_FROM_HIGH_DATA2
    424 #undef _INIT_FROM_LOW_DATA2
     419        const pack8_t pack = { .arg = DEV_IPC_GET_ARG2(*call)};
     420        const size_t max_packet_size = DEV_IPC_GET_ARG3(*call);
     421
     422        const usb_transfer_type_t transfer_type = pack.arr[0];
     423        const usb_direction_t direction = pack.arr[1];
     424        unsigned packets = pack.arr[2];
     425        unsigned interval = pack.arr[3];
    425426
    426427        const int ret = usb_iface->register_endpoint(fun, endpoint,
    427             transfer_type, direction, max_packet_size, interval);
     428            transfer_type, direction, max_packet_size, packets, interval);
    428429
    429430        async_answer_0(callid, ret);
  • uspace/lib/drv/include/usb_iface.h

    r3de7a62 r4e732f1a  
    5858
    5959int usb_register_endpoint(async_exch_t *, usb_endpoint_t, usb_transfer_type_t,
    60     usb_direction_t, size_t, unsigned);
     60    usb_direction_t, size_t, unsigned, unsigned);
    6161int usb_unregister_endpoint(async_exch_t *, usb_endpoint_t, usb_direction_t);
    6262int usb_read(async_exch_t *, usb_endpoint_t, uint64_t, void *, size_t, size_t *);
     
    8181
    8282        int (*register_endpoint)(ddf_fun_t *, usb_endpoint_t,
    83             usb_transfer_type_t, usb_direction_t, size_t, unsigned);
     83            usb_transfer_type_t, usb_direction_t, size_t, unsigned, unsigned);
    8484        int (*unregister_endpoint)(ddf_fun_t *, usb_endpoint_t,
    8585            usb_direction_t);
  • uspace/lib/usb/include/usb/descriptor.h

    r3de7a62 r4e732f1a  
    197197         */
    198198        uint8_t attributes;
    199         /** Maximum packet size. */
     199        /** Maximum packet size.
     200         * Lower 10 bits represent the actuall size
     201         * Bits 11,12 specify addtional transfer opportunitities for
     202         * HS INT and ISO transfers. */
    200203        uint16_t max_packet_size;
     204#define ED_MPS_PACKET_SIZE_MASK  0x3ff
     205#define ED_MPS_PACKET_SIZE_GET(value) \
     206        ((value) & ED_MPS_PACKET_SIZE_MASK)
     207#define ED_MPS_TRANS_OPPORTUNITIES_GET(value) \
     208        ((((value) >> 10) & 0x3) + 1)
    201209        /** Polling interval in milliseconds.
    202210         * Ignored for bulk and control endpoints.
  • uspace/lib/usbdev/include/usb/dev/pipes.h

    r3de7a62 r4e732f1a  
    6161        size_t max_packet_size;
    6262
     63        /** Number of packets per frame/uframe.
     64         * Only valid for HS INT and ISO transfers. All others should set to 1*/
     65        unsigned packets;
     66
    6367        /** Whether to automatically reset halt on the endpoint.
    6468         * Valid only for control endpoint zero.
     
    105109
    106110int usb_pipe_initialize(usb_pipe_t *, usb_endpoint_t, usb_transfer_type_t,
    107     size_t, usb_direction_t, usb_dev_session_t *);
     111    size_t, usb_direction_t, unsigned, usb_dev_session_t *);
    108112int usb_pipe_initialize_default_control(usb_pipe_t *, usb_dev_session_t *);
    109113
  • uspace/lib/usbdev/src/pipes.c

    r3de7a62 r4e732f1a  
    254254int usb_pipe_initialize(usb_pipe_t *pipe, usb_endpoint_t endpoint_no,
    255255    usb_transfer_type_t transfer_type, size_t max_packet_size,
    256     usb_direction_t direction, usb_dev_session_t *bus_session)
     256    usb_direction_t direction, unsigned packets, usb_dev_session_t *bus_session)
    257257{
    258258        assert(pipe);
     
    260260        pipe->endpoint_no = endpoint_no;
    261261        pipe->transfer_type = transfer_type;
     262        pipe->packets = packets;
    262263        pipe->max_packet_size = max_packet_size;
    263264        pipe->direction = direction;
     
    279280
    280281        const int rc = usb_pipe_initialize(pipe, 0, USB_TRANSFER_CONTROL,
    281             CTRL_PIPE_MIN_PACKET_SIZE, USB_DIRECTION_BOTH, bus_session);
     282            CTRL_PIPE_MIN_PACKET_SIZE, USB_DIRECTION_BOTH, 1, bus_session);
    282283
    283284        pipe->auto_reset_halt = true;
     
    301302        const int ret = usb_register_endpoint(exch, pipe->endpoint_no,
    302303            pipe->transfer_type, pipe->direction, pipe->max_packet_size,
    303             interval);
     304            pipe->packets, interval);
    304305        async_exchange_end(exch);
    305306        return ret;
  • uspace/lib/usbdev/src/pipesinit.c

    r3de7a62 r4e732f1a  
    196196        int rc = usb_pipe_initialize(&ep_mapping->pipe,
    197197            ep_no, description.transfer_type,
    198             uint16_usb2host(endpoint_desc->max_packet_size),
    199             description.direction, bus_session);
     198            ED_MPS_PACKET_SIZE_GET(
     199                uint16_usb2host(endpoint_desc->max_packet_size)),
     200            description.direction,
     201            ED_MPS_TRANS_OPPORTUNITIES_GET(
     202                uint16_usb2host(endpoint_desc->max_packet_size)), bus_session);
    200203        if (rc != EOK) {
    201204                return rc;
  • uspace/lib/usbhost/include/usb/host/endpoint.h

    r3de7a62 r4e732f1a  
    5757        /** Maximum size of data packets. */
    5858        size_t max_packet_size;
     59        /** Additional opportunities per uframe */
     60        unsigned packets;
    5961        /** Necessary bandwidth. */
    6062        size_t bandwidth;
     
    8587endpoint_t * endpoint_create(usb_address_t address, usb_endpoint_t endpoint,
    8688    usb_direction_t direction, usb_transfer_type_t type, usb_speed_t speed,
    87     size_t max_packet_size, size_t bw, usb_address_t tt_address,
    88     unsigned tt_port);
     89    size_t max_packet_size, unsigned packets, size_t bw,
     90    usb_address_t tt_address, unsigned tt_port);
    8991void endpoint_destroy(endpoint_t *instance);
    9092
  • uspace/lib/usbhost/include/usb/host/hcd.h

    r3de7a62 r4e732f1a  
    109109
    110110int hcd_add_ep(hcd_t *hcd, usb_target_t target, usb_direction_t dir,
    111     usb_transfer_type_t type, size_t max_packet_size, size_t size,
    112     usb_address_t tt_address, unsigned tt_port);
     111    usb_transfer_type_t type, size_t max_packet_size, unsigned packets,
     112    size_t size, usb_address_t tt_address, unsigned tt_port);
    113113
    114114int hcd_remove_ep(hcd_t *hcd, usb_target_t target, usb_direction_t dir);
  • uspace/lib/usbhost/include/usb/host/usb_bus.h

    r3de7a62 r4e732f1a  
    9797int usb_bus_add_ep(usb_bus_t *instance,
    9898    usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction,
    99     usb_transfer_type_t type, size_t max_packet_size, size_t data_size,
    100     ep_add_callback_t callback, void *arg, usb_address_t tt_address,
    101     unsigned tt_port);
     99    usb_transfer_type_t type, size_t max_packet_size, unsigned packets,
     100    size_t data_size, ep_add_callback_t callback, void *arg,
     101    usb_address_t tt_address, unsigned tt_port);
    102102
    103103int usb_bus_remove_ep(usb_bus_t *instance,
  • uspace/lib/usbhost/src/ddf_helpers.c

    r3de7a62 r4e732f1a  
    110110    ddf_fun_t *fun, usb_endpoint_t endpoint,
    111111    usb_transfer_type_t transfer_type, usb_direction_t direction,
    112     size_t max_packet_size, unsigned interval)
     112    size_t max_packet_size, unsigned packets, unsigned interval)
    113113{
    114114        assert(fun);
     
    126126
    127127        return hcd_add_ep(hcd, target, direction, transfer_type,
    128             max_packet_size, size, dev->tt_address, dev->port);
     128            max_packet_size, packets, size, dev->tt_address, dev->port);
    129129}
    130130
     
    491491        ret = hcd_add_ep(hcd,
    492492            default_target, USB_DIRECTION_BOTH, USB_TRANSFER_CONTROL,
    493             CTRL_PIPE_MIN_PACKET_SIZE, CTRL_PIPE_MIN_PACKET_SIZE,
     493            CTRL_PIPE_MIN_PACKET_SIZE, CTRL_PIPE_MIN_PACKET_SIZE, 1,
    494494            tt_address, port);
    495495
     
    517517        /* Register EP on the new address */
    518518        ret = hcd_add_ep(hcd, target, USB_DIRECTION_BOTH, USB_TRANSFER_CONTROL,
    519             desc.max_packet_size, desc.max_packet_size, tt_address, port);
     519            ED_MPS_PACKET_SIZE_GET(uint16_usb2host(desc.max_packet_size)),
     520            ED_MPS_TRANS_OPPORTUNITIES_GET(uint16_usb2host(desc.max_packet_size)),
     521            ED_MPS_PACKET_SIZE_GET(uint16_usb2host(desc.max_packet_size)),
     522            tt_address, port);
    520523        if (ret != EOK) {
    521524                hcd_remove_ep(hcd, default_target, USB_DIRECTION_BOTH);
  • uspace/lib/usbhost/src/endpoint.c

    r3de7a62 r4e732f1a  
    5050endpoint_t * endpoint_create(usb_address_t address, usb_endpoint_t endpoint,
    5151    usb_direction_t direction, usb_transfer_type_t type, usb_speed_t speed,
    52     size_t max_packet_size, size_t bw, usb_address_t tt_address, unsigned tt_p)
     52    size_t max_packet_size, unsigned packets, size_t bw,
     53    usb_address_t tt_address, unsigned tt_p)
    5354{
    5455        endpoint_t *instance = malloc(sizeof(endpoint_t));
     
    6061                instance->speed = speed;
    6162                instance->max_packet_size = max_packet_size;
     63                instance->packets = packets;
    6264                instance->bandwidth = bw;
    6365                instance->toggle = 0;
  • uspace/lib/usbhost/src/hcd.c

    r3de7a62 r4e732f1a  
    132132
    133133int hcd_add_ep(hcd_t *hcd, usb_target_t target, usb_direction_t dir,
    134     usb_transfer_type_t type, size_t max_packet_size, size_t size,
    135     usb_address_t tt_address, unsigned tt_port)
     134    usb_transfer_type_t type, size_t max_packet_size, unsigned packets,
     135    size_t size, usb_address_t tt_address, unsigned tt_port)
    136136{
    137137        assert(hcd);
    138138        return usb_bus_add_ep(&hcd->bus, target.address,
    139             target.endpoint, dir, type, max_packet_size, size, register_helper,
    140             hcd, tt_address, tt_port);
     139            target.endpoint, dir, type, max_packet_size, packets, size,
     140            register_helper, hcd, tt_address, tt_port);
    141141}
    142142
  • uspace/lib/usbhost/src/usb_bus.c

    r3de7a62 r4e732f1a  
    301301int usb_bus_add_ep(usb_bus_t *instance,
    302302    usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction,
    303     usb_transfer_type_t type, size_t max_packet_size, size_t data_size,
    304     ep_add_callback_t callback, void *arg, usb_address_t tt_address,
    305     unsigned tt_port)
     303    usb_transfer_type_t type, size_t max_packet_size, unsigned packets,
     304    size_t data_size, ep_add_callback_t callback, void *arg,
     305    usb_address_t tt_address, unsigned tt_port)
    306306{
    307307        assert(instance);
     
    337337
    338338        ep = endpoint_create(address, endpoint, direction, type, speed,
    339             max_packet_size, bw, tt_address, tt_port);
     339            max_packet_size, packets, bw, tt_address, tt_port);
    340340        if (!ep) {
    341341                fibril_mutex_unlock(&instance->guard);
Note: See TracChangeset for help on using the changeset viewer.