Changeset 90df90c in mainline for uspace/drv/bus/usb/usbhid/usbhid.c


Ignore:
Timestamp:
2011-11-09T13:23:03Z (12 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.