Changeset c2be0e5 in mainline


Ignore:
Timestamp:
2011-04-02T18:56:57Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a8fa88d, ccbcd895
Parents:
2c617b0
Message:

OHCI bandwidth

Location:
uspace/drv/ohci
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/ohci/hc.c

    r2c617b0 rc2be0e5  
    7979        assert(instance);
    8080        int ret = EOK;
     81#define CHECK_RET_RETURN(ret, message...) \
     82if (ret != EOK) { \
     83        usb_log_error(message); \
     84        return ret; \
     85} else (void)0
    8186
    8287        ret = pio_enable((void*)regs, reg_size, (void**)&instance->registers);
    83         if (ret != EOK) {
    84                 usb_log_error("Failed to gain access to device registers.\n");
    85                 return ret;
    86         }
     88        CHECK_RET_RETURN(ret,
     89            "Failed(%d) to gain access to device registers: %s.\n",
     90            ret, str_error(ret));
     91
    8792        instance->ddf_instance = fun;
    8893        usb_device_keeper_init(&instance->manager);
     94        ret = bandwidth_init(&instance->bandwidth, BANDWIDTH_AVAILABLE_USB11,
     95            bandwidth_count_usb11);
     96        CHECK_RET_RETURN(ret, "Failed to initialize bandwidth allocator: %s.\n",
     97            ret, str_error(ret));
    8998
    9099        if (!interrupts) {
     
    185194        assert((instance->registers->command_status & CS_HCR) == 0);
    186195        /* hc is now in suspend state */
     196        /* TODO: init HCCA block */
     197        /* TODO: init queues */
     198        /* TODO: enable queues */
     199        /* TODO: enable interrupts */
     200        /* TODO: set periodic start to 90% */
    187201
    188202        instance->registers->control &= (C_HCFS_OPERATIONAL << C_HCFS_SHIFT);
  • uspace/drv/ohci/hc.h

    r2c617b0 rc2be0e5  
    4242#include <usb/usb.h>
    4343#include <usb/host/device_keeper.h>
     44#include <usb/host/bandwidth.h>
    4445#include <usbhc_iface.h>
    4546
     
    5455        ddf_fun_t *ddf_instance;
    5556        usb_device_keeper_t manager;
     57        bandwidth_t bandwidth;
    5658        fid_t interrupt_emulator;
    5759} hc_t;
  • uspace/drv/ohci/iface.c

    r2c617b0 rc2be0e5  
    151151    size_t max_packet_size, unsigned int interval)
    152152{
    153         UNSUPPORTED("register_endpoint");
    154 
    155         return ENOTSUP;
     153        assert(fun);
     154        hc_t *hc = fun_to_hc(fun);
     155        assert(hc);
     156        if (address == hc->rh.address)
     157                return EOK;
     158        const usb_speed_t speed =
     159                usb_device_keeper_get_speed(&hc->manager, address);
     160        const size_t size = max_packet_size;
     161        usb_log_debug("Register endpoint %d:%d %s %s(%d) %zu(%zu) %u.\n",
     162            address, endpoint, usb_str_transfer_type(transfer_type),
     163            usb_str_speed(speed), direction, size, max_packet_size, interval);
     164        return bandwidth_reserve(&hc->bandwidth, address, endpoint, direction,
     165            speed, transfer_type, max_packet_size, size, interval);
    156166}
    157167/*----------------------------------------------------------------------------*/
     
    168178    usb_endpoint_t endpoint, usb_direction_t direction)
    169179{
    170         UNSUPPORTED("unregister_endpoint");
     180        assert(fun);
     181        hc_t *hc = fun_to_hc(fun);
     182        assert(hc);
     183        usb_log_debug("Unregister endpoint %d:%d %d.\n",
     184            address, endpoint, direction);
     185        return bandwidth_release(&hc->bandwidth, address, endpoint, direction);
    171186
    172187        return ENOTSUP;
Note: See TracChangeset for help on using the changeset viewer.