Changeset 90df90c in mainline


Ignore:
Timestamp:
2011-11-09T13:23:03Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
07b9cbae
Parents:
6f730278
Message:

usbhid: Rework usb_hid_check_pipes. Comment fixes.

Location:
uspace/drv/bus/usb/usbhid
Files:
2 edited

Legend:

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

    r6f730278 r90df90c  
    7373            usb_device_data_alloc(dev, sizeof(usb_hid_dev_t));
    7474        if (hid_dev == NULL) {
    75                 usb_log_error("Error while creating USB/HID device "
    76                     "structure.\n");
     75                usb_log_error("Failed to create USB/HID device structure.\n");
    7776                return ENOMEM;
    7877        }
     
    8786        usb_log_debug("USB/HID device structure initialized.\n");
    8887
    89         /*
    90          * 1) subdriver vytvori vlastnu ddf_fun, vlastne ddf_dev_ops, ktore da
    91          *    do nej.
    92          * 2) do tych ops do .interfaces[DEV_IFACE_USBHID (asi)] priradi
    93          *    vyplnenu strukturu usbhid_iface_t.
    94          * 3) klientska aplikacia - musi si rucne vytvorit telefon
    95          *    (devman_device_connect() - cesta k zariadeniu (/hw/pci0/...) az
    96          *    k tej fcii.
    97          *    pouzit usb/classes/hid/iface.h - prvy int je telefon
    98          */
    99 
    10088        /* Start automated polling function.
    10189         * This will create a separate fibril that will query the device
    102          * for the data continuously.
    103          */
     90         * for the data continuously. */
    10491       rc = usb_device_auto_poll(dev,
    10592           /* Index of the polling pipe. */
     
    135122static int usb_hid_device_rem(usb_device_t *dev)
    136123{
    137         // TODO: Stop device polling fibril
    138         // TODO: Stop autorepeat fibril
    139         // TODO: Call deinit
     124        // TODO: Stop device polling
     125        // TODO: Call deinit (stops autorepeat too)
    140126        return ENOTSUP;
    141127}
  • uspace/drv/bus/usb/usbhid/usbhid.c

    r6f730278 r90df90c  
    128128        return (hid_dev->usb_dev->descriptors.device.vendor_id
    129129            == mapping->vendor_id
    130             && hid_dev->usb_dev->descriptors.device.product_id 
     130            && hid_dev->usb_dev->descriptors.device.product_id
    131131            == mapping->product_id);
    132132}
     
    301301        assert(dev);
    302302
    303         if (dev->pipes[USB_HID_KBD_POLL_EP_NO].present) {
    304                 usb_log_debug("Found keyboard endpoint.\n");
    305                 // save the pipe index
    306                 hid_dev->poll_pipe_index = USB_HID_KBD_POLL_EP_NO;
    307         } else if (dev->pipes[USB_HID_MOUSE_POLL_EP_NO].present) {
    308                 usb_log_debug("Found mouse endpoint.\n");
    309                 // save the pipe index
    310                 hid_dev->poll_pipe_index = USB_HID_MOUSE_POLL_EP_NO;
    311         } else if (dev->pipes[USB_HID_GENERIC_POLL_EP_NO].present) {
    312                 usb_log_debug("Found generic HID endpoint.\n");
    313                 // save the pipe index
    314                 hid_dev->poll_pipe_index = USB_HID_GENERIC_POLL_EP_NO;
    315         } else {
    316                 usb_log_error("None of supported endpoints found - probably"
    317                     " not a supported device.\n");
    318                 return ENOTSUP;
    319         }
    320 
    321         return EOK;
     303        static const struct {
     304                unsigned ep_number;
     305                const char* description;
     306        } endpoints[] = {
     307                {USB_HID_KBD_POLL_EP_NO, "Keyboard endpoint"},
     308                {USB_HID_MOUSE_POLL_EP_NO, "Mouse endpoint"},
     309                {USB_HID_GENERIC_POLL_EP_NO, "Generic HID endpoint"},
     310        };
     311
     312        for (unsigned i = 0; i < sizeof(endpoints)/sizeof(endpoints[0]); ++i) {
     313                if (endpoints[i].ep_number >= dev->pipes_count) {
     314                        return EINVAL;
     315                }
     316                if (dev->pipes[endpoints[i].ep_number].present) {
     317                        usb_log_debug("Found: %s.\n", endpoints[i].description);
     318                        hid_dev->poll_pipe_index = endpoints[i].ep_number;
     319                        return EOK;
     320                }
     321        }
     322        return ENOTSUP;
    322323}
    323324
     
    395396        rc = usb_hid_process_report_descriptor(hid_dev->usb_dev,
    396397            &hid_dev->report, &hid_dev->report_desc, &hid_dev->report_desc_size);
     398
     399        /*
     400         * 1) subdriver vytvori vlastnu ddf_fun, vlastne ddf_dev_ops, ktore da
     401         *    do nej.
     402         * 2) do tych ops do .interfaces[DEV_IFACE_USBHID (asi)] priradi
     403         *    vyplnenu strukturu usbhid_iface_t.
     404         * 3) klientska aplikacia - musi si rucne vytvorit telefon
     405         *    (devman_device_connect() - cesta k zariadeniu (/hw/pci0/...) az
     406         *    k tej fcii.
     407         *    pouzit usb/classes/hid/iface.h - prvy int je telefon
     408         */
    397409
    398410        bool fallback = false;
Note: See TracChangeset for help on using the changeset viewer.