Changeset 4e38d69 in mainline for uspace/drv/usbhid/main.c


Ignore:
Timestamp:
2011-02-11T15:05:40Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5842493
Parents:
1e64b250 (diff), 03197ffc (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:

Merged development/ changes

Warning: this merge breaks some things (the UHCI driver hangs due to
errors introduced in previous revisions).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhid/main.c

    r1e64b250 r4e38d69  
    4747#include <usb/classes/hid.h>
    4848#include <usb/classes/hidparser.h>
    49 #include <usb/devreq.h>
     49#include <usb/request.h>
    5050#include <usb/descriptor.h>
    5151#include <io/console.h>
     
    262262}
    263263
    264 # if 0
    265264/*
    266265 * Kbd functions
     
    281280               
    282281                // get the descriptor from the device
    283                 int rc = usb_drv_req_get_descriptor(kbd_dev->device->parent_phone,
    284                     kbd_dev->address, USB_REQUEST_TYPE_CLASS, USB_DESCTYPE_HID_REPORT,
    285                     0, i, kbd_dev->conf->interfaces[i].report_desc, length,
     282                int rc = usb_request_get_descriptor(&kbd_dev->ctrl_pipe,
     283                    USB_REQUEST_TYPE_CLASS, USB_DESCTYPE_HID_REPORT,
     284                    i, 0,
     285                    kbd_dev->conf->interfaces[i].report_desc, length,
    286286                    &actual_size);
    287287
     
    303303        usb_standard_configuration_descriptor_t config_desc;
    304304       
    305         int rc = usb_drv_req_get_bare_configuration_descriptor(
    306             kbd_dev->device->parent_phone, kbd_dev->address, 0, &config_desc);
     305        int rc;
     306        rc = usb_request_get_bare_configuration_descriptor(&kbd_dev->ctrl_pipe,
     307            0, &config_desc);
    307308       
    308309        if (rc != EOK) {
     
    318319        size_t transferred = 0;
    319320        // get full configuration descriptor
    320         rc = usb_drv_req_get_full_configuration_descriptor(
    321             kbd_dev->device->parent_phone, kbd_dev->address, 0, descriptors,
     321        rc = usb_request_get_full_configuration_descriptor(&kbd_dev->ctrl_pipe,
     322            0, descriptors,
    322323            config_desc.total_length, &transferred);
    323324       
     
    363364        return EOK;
    364365}
    365 #endif
     366
    366367static usb_hid_dev_kbd_t *usbkbd_init_device(device_t *dev)
    367368{
     369        int rc;
     370
    368371        usb_hid_dev_kbd_t *kbd_dev = (usb_hid_dev_kbd_t *)calloc(1,
    369372            sizeof(usb_hid_dev_kbd_t));
     
    376379        kbd_dev->device = dev;
    377380
    378         // get phone to my HC and save it as my parent's phone
    379         // TODO: maybe not a good idea if DDF will use parent_phone
    380         int rc = kbd_dev->device->parent_phone = usb_drv_hc_connect_auto(dev, 0);
    381         if (rc < 0) {
    382                 printf("Problem setting phone to HC.\n");
    383                 goto error_leave;
    384         }
    385 
    386         rc = kbd_dev->address = usb_drv_get_my_address(dev->parent_phone, dev);
    387         if (rc < 0) {
    388                 printf("Problem getting address of the device.\n");
    389                 goto error_leave;
    390         }
    391 
    392         // doesn't matter now that we have no address
    393 //      if (kbd_dev->address < 0) {
    394 //              fprintf(stderr, NAME ": No device address!\n");
    395 //              free(kbd_dev);
    396 //              return NULL;
    397 //      }
    398 
    399         /*
    400          * will need all descriptors:
    401          * 1) choose one configuration from configuration descriptors
    402          *    (set it to the device)
    403          * 2) set endpoints from endpoint descriptors
    404          */
    405 
    406 
    407         // TODO: get descriptors, parse descriptors and save endpoints
    408         //usbkbd_process_descriptors(kbd_dev);
    409         usb_drv_req_set_configuration(
    410           kbd_dev->device->parent_phone, kbd_dev->address, 1);
    411 
    412 
    413 
    414381        /*
    415382         * Initialize the backing connection to the host controller.
     
    425392         * Initialize device pipes.
    426393         */
     394        rc = usb_endpoint_pipe_initialize_default_control(&kbd_dev->ctrl_pipe,
     395            &kbd_dev->wire);
     396        if (rc != EOK) {
     397                printf("Failed to initialize default control pipe: %s.\n",
     398                    str_error(rc));
     399                goto error_leave;
     400        }
     401
    427402        rc = usb_endpoint_pipe_initialize(&kbd_dev->poll_pipe, &kbd_dev->wire,
    428403            GUESSED_POLL_ENDPOINT, USB_TRANSFER_INTERRUPT, USB_DIRECTION_IN);
     
    433408        }
    434409
     410        /*
     411         * will need all descriptors:
     412         * 1) choose one configuration from configuration descriptors
     413         *    (set it to the device)
     414         * 2) set endpoints from endpoint descriptors
     415         */
     416
     417        // TODO: get descriptors, parse descriptors and save endpoints
     418        usb_endpoint_pipe_start_session(&kbd_dev->ctrl_pipe);
     419        //usb_request_set_configuration(&kbd_dev->ctrl_pipe, 1);
     420        usbkbd_process_descriptors(kbd_dev);
     421        usb_endpoint_pipe_end_session(&kbd_dev->ctrl_pipe);
    435422
    436423        return kbd_dev;
Note: See TracChangeset for help on using the changeset viewer.