Changeset 8f5b6561 in mainline


Ignore:
Timestamp:
2011-02-11T18:57:29Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
45c01a1, 67b6fc5, 6b1931b
Parents:
345ea18 (diff), b43bcf1 (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:

Merge better pipe initialization in HID driver

Location:
uspace
Files:
2 edited

Legend:

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

    r345ea18 r8f5b6561  
    4545#include <str_error.h>
    4646#include <fibril.h>
     47#include <usb/debug.h>
     48#include <usb/classes/classes.h>
    4749#include <usb/classes/hid.h>
    4850#include <usb/classes/hidparser.h>
     
    6163#define GUESSED_POLL_ENDPOINT 1
    6264
     65/** Keyboard polling endpoint description for boot protocol class. */
     66static usb_endpoint_description_t poll_endpoint_description = {
     67        .transfer_type = USB_TRANSFER_INTERRUPT,
     68        .direction = USB_DIRECTION_IN,
     69        .interface_class = USB_CLASS_HID,
     70        .interface_subclass = USB_HID_SUBCLASS_BOOT,
     71        .interface_protocol = USB_HID_PROTOCOL_KEYBOARD,
     72        .flags = 0
     73};
     74
    6375static void default_connection_handler(device_t *, ipc_callid_t, ipc_call_t *);
    6476static device_ops_t keyboard_ops = {
     
    330342        }
    331343       
     344        /*
     345         * Initialize the interrupt in endpoint.
     346         */
     347        usb_endpoint_mapping_t endpoint_mapping[1] = {
     348                {
     349                        .pipe = &kbd_dev->poll_pipe,
     350                        .description = &poll_endpoint_description
     351                }
     352        };
     353        rc = usb_endpoint_pipe_initialize_from_configuration(
     354            endpoint_mapping, 1,
     355            descriptors, config_desc.total_length,
     356            &kbd_dev->wire);
     357        if (rc != EOK) {
     358                usb_log_error("Failed to initialize poll pipe: %s.\n",
     359                    str_error(rc));
     360                return rc;
     361        }
     362        if (!endpoint_mapping[0].present) {
     363                usb_log_warning("Not accepting device, " \
     364                    "not boot-protocol keyboard.\n");
     365                return EREFUSED;
     366        }
     367
     368
     369
     370
    332371        kbd_dev->conf = (usb_hid_configuration_t *)calloc(1,
    333372            sizeof(usb_hid_configuration_t));
     
    337376        }
    338377       
    339         rc = usbkbd_parse_descriptors(descriptors, transferred, kbd_dev->conf);
     378        /*rc = usbkbd_parse_descriptors(descriptors, transferred, kbd_dev->conf);
    340379        free(descriptors);
    341380        if (rc != EOK) {
     
    344383        }
    345384
    346         // get and report descriptors
     385        // get and report descriptors*/
    347386        rc = usbkbd_get_report_descriptor(kbd_dev);
    348387        if (rc != EOK) {
     
    361400     *    as the endpoint for polling
    362401         */
    363        
     402
    364403        return EOK;
    365404}
     
    396435        if (rc != EOK) {
    397436                printf("Failed to initialize default control pipe: %s.\n",
    398                     str_error(rc));
    399                 goto error_leave;
    400         }
    401 
    402         rc = usb_endpoint_pipe_initialize(&kbd_dev->poll_pipe, &kbd_dev->wire,
    403             GUESSED_POLL_ENDPOINT, USB_TRANSFER_INTERRUPT, 8, USB_DIRECTION_IN);
    404         if (rc != EOK) {
    405                 printf("Failed to initialize interrupt in pipe: %s.\n",
    406437                    str_error(rc));
    407438                goto error_leave;
     
    418449        usb_endpoint_pipe_start_session(&kbd_dev->ctrl_pipe);
    419450        //usb_request_set_configuration(&kbd_dev->ctrl_pipe, 1);
    420         usbkbd_process_descriptors(kbd_dev);
     451        rc = usbkbd_process_descriptors(kbd_dev);
    421452        usb_endpoint_pipe_end_session(&kbd_dev->ctrl_pipe);
     453        if (rc != EOK) {
     454                goto error_leave;
     455        }
    422456
    423457        return kbd_dev;
     
    577611int main(int argc, char *argv[])
    578612{
     613        usb_log_enable(USB_LOG_LEVEL_INFO, "usbhid");
    579614        return driver_main(&kbd_driver);
    580615}
  • uspace/lib/usb/include/usb/classes/hid.h

    r345ea18 r8f5b6561  
    5050        USB_HIDREQ_SET_PROTOCOL = 11
    5151} usb_hid_request_t;
     52
     53/** USB/HID subclass constants. */
     54typedef enum {
     55        USB_HID_SUBCLASS_NONE = 0,
     56        USB_HID_SUBCLASS_BOOT = 1
     57} usb_hid_subclass_t;
    5258
    5359/** USB/HID interface protocols. */
Note: See TracChangeset for help on using the changeset viewer.