Changeset a9d67aa in mainline for uspace/drv/uhci-hcd/iface.c


Ignore:
Timestamp:
2011-04-09T17:15:28Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
97e7e8a
Parents:
5410c04 (diff), 77223f8 (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.
Message:

Refactoring: libusb, USBHC interface protocol

Highlights:

  • refactoring of libusb (not complete)
  • max packet size is not send during each transfer
  • reserving of default address is possible via endpoint registration
  • endpoint registration can send speed as well
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/iface.c

    r5410c04 ra9d67aa  
    7474            name, target.address, target.endpoint, size, ep->max_packet_size);
    7575
    76         assert(ep->speed ==
    77             usb_device_keeper_get_speed(&(*hc)->manager, target.address));
     76//      assert(ep->speed ==
     77//          usb_device_keeper_get_speed(&(*hc)->manager, target.address));
    7878//      assert(ep->max_packet_size == max_packet_size);
    7979//      assert(ep->transfer_type == USB_TRANSFER_CONTROL);
     
    198198/*----------------------------------------------------------------------------*/
    199199static int register_endpoint(
    200     ddf_fun_t *fun, usb_address_t address, usb_endpoint_t endpoint,
     200    ddf_fun_t *fun, usb_address_t address, usb_speed_t ep_speed,
     201    usb_endpoint_t endpoint,
    201202    usb_transfer_type_t transfer_type, usb_direction_t direction,
    202203    size_t max_packet_size, unsigned int interval)
     
    204205        hc_t *hc = fun_to_hc(fun);
    205206        assert(hc);
    206         const usb_speed_t speed =
    207             usb_device_keeper_get_speed(&hc->manager, address);
    208         const size_t size = max_packet_size;
     207        usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, address);
     208        if (speed >= USB_SPEED_MAX) {
     209                speed = ep_speed;
     210        }
     211        const size_t size =
     212            (transfer_type == USB_TRANSFER_INTERRUPT
     213            || transfer_type == USB_TRANSFER_ISOCHRONOUS) ?
     214            max_packet_size : 0;
    209215        int ret;
    210216
     
    240246        usb_log_debug("Unregister endpoint %d:%d %d.\n",
    241247            address, endpoint, direction);
     248        endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager,
     249            address, endpoint, direction, NULL);
     250        if (ep != NULL) {
     251                usb_device_keeper_del_ep(&hc->manager, address, ep);
     252        }
    242253        return usb_endpoint_manager_unregister_ep(&hc->ep_manager, address,
    243254            endpoint, direction);
     
    248259 * @param[in] fun DDF function that was called.
    249260 * @param[in] target USB device to write to.
    250  * @param[in] max_packet_size maximum size of data packet the device accepts
    251261 * @param[in] data Source of data.
    252262 * @param[in] size Size of data source.
     
    256266 */
    257267static int interrupt_out(
    258     ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data,
     268    ddf_fun_t *fun, usb_target_t target, void *data,
    259269    size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg)
    260270{
     
    277287 * @param[in] fun DDF function that was called.
    278288 * @param[in] target USB device to write to.
    279  * @param[in] max_packet_size maximum size of data packet the device accepts
    280289 * @param[out] data Data destination.
    281290 * @param[in] size Size of data source.
     
    285294 */
    286295static int interrupt_in(
    287     ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data,
     296    ddf_fun_t *fun, usb_target_t target, void *data,
    288297    size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg)
    289298{
     
    306315 * @param[in] fun DDF function that was called.
    307316 * @param[in] target USB device to write to.
    308  * @param[in] max_packet_size maximum size of data packet the device accepts
    309317 * @param[in] data Source of data.
    310318 * @param[in] size Size of data source.
     
    314322 */
    315323static int bulk_out(
    316     ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data,
     324    ddf_fun_t *fun, usb_target_t target, void *data,
    317325    size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg)
    318326{
     
    335343 * @param[in] fun DDF function that was called.
    336344 * @param[in] target USB device to write to.
    337  * @param[in] max_packet_size maximum size of data packet the device accepts
    338345 * @param[out] data Data destination.
    339346 * @param[in] size Size of data source.
     
    343350 */
    344351static int bulk_in(
    345     ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data,
     352    ddf_fun_t *fun, usb_target_t target, void *data,
    346353    size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg)
    347354{
     
    364371 * @param[in] fun DDF function that was called.
    365372 * @param[in] target USB device to write to.
    366  * @param[in] max_packet_size maximum size of data packet the device accepts.
    367373 * @param[in] setup_data Data to send with SETUP transfer.
    368374 * @param[in] setup_size Size of data to send with SETUP transfer (always 8B).
     
    374380 */
    375381static int control_write(
    376     ddf_fun_t *fun, usb_target_t target, size_t max_packet_size,
     382    ddf_fun_t *fun, usb_target_t target,
    377383    void *setup_data, size_t setup_size, void *data, size_t size,
    378384    usbhc_iface_transfer_out_callback_t callback, void *arg)
     
    398404 * @param[in] fun DDF function that was called.
    399405 * @param[in] target USB device to write to.
    400  * @param[in] max_packet_size maximum size of data packet the device accepts.
    401406 * @param[in] setup_data Data to send with SETUP packet.
    402407 * @param[in] setup_size Size of data to send with SETUP packet (should be 8B).
     
    408413 */
    409414static int control_read(
    410     ddf_fun_t *fun, usb_target_t target, size_t max_packet_size,
     415    ddf_fun_t *fun, usb_target_t target,
    411416    void *setup_data, size_t setup_size, void *data, size_t size,
    412417    usbhc_iface_transfer_in_callback_t callback, void *arg)
Note: See TracChangeset for help on using the changeset viewer.