Changeset 06f9d8fb in mainline


Ignore:
Timestamp:
2011-05-30T20:02:17Z (13 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c3dafe1
Parents:
be8d907 (diff), 63862a0 (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 with usb/development

Location:
uspace
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/ehci-hcd/main.c

    rbe8d907 r06f9d8fb  
    7575}
    7676
    77         uintptr_t mem_reg_base = 0;
    78         size_t mem_reg_size = 0;
     77        uintptr_t reg_base = 0;
     78        size_t reg_size = 0;
    7979        int irq = 0;
    8080
    81         int ret =
    82             pci_get_my_registers(device, &mem_reg_base, &mem_reg_size, &irq);
     81        int ret = pci_get_my_registers(device, &reg_base, &reg_size, &irq);
    8382        CHECK_RET_RETURN(ret,
    8483            "Failed to get memory addresses for %" PRIun ": %s.\n",
    8584            device->handle, str_error(ret));
    8685        usb_log_info("Memory mapped regs at 0x%" PRIxn " (size %zu), IRQ %d.\n",
    87             mem_reg_base, mem_reg_size, irq);
     86            reg_base, reg_size, irq);
    8887
    89         ret = pci_disable_legacy(device);
     88        ret = pci_disable_legacy(device, reg_base, reg_size, irq);
    9089        CHECK_RET_RETURN(ret,
    9190            "Failed(%d) disable legacy USB: %s.\n", ret, str_error(ret));
  • uspace/drv/ehci-hcd/pci.c

    rbe8d907 r06f9d8fb  
    8787} while(0)
    8888
    89 static int pci_read32(ddf_dev_t *dev, int address, uint32_t *value)
     89static int pci_read32(const ddf_dev_t *dev, int address, uint32_t *value)
    9090{
    9191        PCI_READ(32);
    9292}
    93 static int pci_read16(ddf_dev_t *dev, int address, uint16_t *value)
     93static int pci_read16(const ddf_dev_t *dev, int address, uint16_t *value)
    9494{
    9595        PCI_READ(16);
    9696}
    97 static int pci_read8(ddf_dev_t *dev, int address, uint8_t *value)
     97static int pci_read8(const ddf_dev_t *dev, int address, uint8_t *value)
    9898{
    9999        PCI_READ(8);
     
    115115} while(0)
    116116
    117 static int pci_write32(ddf_dev_t *dev, int address, uint32_t value)
     117static int pci_write32(const ddf_dev_t *dev, int address, uint32_t value)
    118118{
    119119        PCI_WRITE(32);
    120120}
    121 static int pci_write16(ddf_dev_t *dev, int address, uint16_t value)
     121static int pci_write16(const ddf_dev_t *dev, int address, uint16_t value)
    122122{
    123123        PCI_WRITE(16);
    124124}
    125 static int pci_write8(ddf_dev_t *dev, int address, uint8_t value)
     125static int pci_write8(const ddf_dev_t *dev, int address, uint8_t value)
    126126{
    127127        PCI_WRITE(8);
     
    136136 * @return Error code.
    137137 */
    138 int pci_get_my_registers(ddf_dev_t *dev,
     138int pci_get_my_registers(const ddf_dev_t *dev,
    139139    uintptr_t *mem_reg_address, size_t *mem_reg_size, int *irq_no)
    140140{
     
    206206 * @return Error code.
    207207 */
    208 int pci_enable_interrupts(ddf_dev_t *device)
     208int pci_enable_interrupts(const ddf_dev_t *device)
    209209{
    210210        const int parent_phone =
     
    223223 * @return Error code.
    224224 */
    225 int pci_disable_legacy(ddf_dev_t *device)
     225int pci_disable_legacy(
     226    const ddf_dev_t *device, uintptr_t reg_base, size_t reg_size, int irq)
    226227{
    227228        assert(device);
     
    236237        } else (void)0
    237238
    238         uintptr_t reg_base = 0;
    239         size_t reg_size = 0;
    240         int irq = 0;
    241 
    242         int ret = pci_get_my_registers(device, &reg_base, &reg_size, &irq);
    243         CHECK_RET_RETURN(ret, "Failed(%d) to get EHCI registers.\n", ret);
    244 
    245         usb_log_info("EHCI: Memory registers:%p size: %zu irq:%d.\n",
    246             (void *) reg_base, reg_size, irq);
    247 
    248 
    249         /* map EHCI registers */
     239        /* Map EHCI registers */
    250240        void *regs = NULL;
    251         ret = pio_enable((void*)reg_base, reg_size, &regs);
     241        int ret = pio_enable((void*)reg_base, reg_size, &regs);
    252242        CHECK_RET_RETURN(ret, "Failed(%d) to map registers %p.\n",
    253243            ret, (void *) reg_base);
     
    316306                        CHECK_RET_RETURN(ret,
    317307                            "Failed(%d) zero USBLEGCTLSTS.\n", ret);
     308                        udelay(10);
    318309                        ret = pci_read32(
    319310                            device, eecp + USBLEGCTLSTS_OFFSET, &usblegctlsts);
     
    350341        usb_log_debug("USBCMD value: %x.\n", *usbcmd);
    351342        if (*usbcmd & USBCMD_RUN) {
    352                 *usbcmd = 0;
    353                 /* Wait until hc is halted */
    354                 while ((*usbsts & USBSTS_HALTED) != 0);
    355343                *usbsts = 0x3f; /* ack all interrupts */
    356344                *usbint = 0; /* disable all interrutps */
    357345                *usbconf = 0; /* relase control of RH ports */
     346
     347                *usbcmd = 0;
     348                /* Wait until hc is halted */
     349                while ((*usbsts & USBSTS_HALTED) == 0);
    358350                usb_log_info("EHCI turned off.\n");
    359351        } else {
  • uspace/drv/ehci-hcd/pci.h

    rbe8d907 r06f9d8fb  
    3838#include <ddf/driver.h>
    3939
    40 int pci_get_my_registers(ddf_dev_t *, uintptr_t *, size_t *, int *);
    41 int pci_enable_interrupts(ddf_dev_t *);
    42 int pci_disable_legacy(ddf_dev_t *);
     40int pci_get_my_registers(const ddf_dev_t *, uintptr_t *, size_t *, int *);
     41int pci_enable_interrupts(const ddf_dev_t *);
     42int pci_disable_legacy(const ddf_dev_t *, uintptr_t, size_t, int);
    4343
    4444#endif
  • uspace/drv/usbhid/generic/hiddev.c

    rbe8d907 r06f9d8fb  
    126126        }
    127127       
    128         /*! @todo This should probably be atomic. */
    129 //      if (usb_hid_report_ready()) {
    130 //              usb_log_debug2("Report ready, size: %zu\n",
    131 //                  hid_dev->input_report_size);
    132                
    133 //              usb_hid_report_received();
    134 //      } else {
    135 //              memset(buffer, 0, hid_dev->input_report_size);
    136 //      }
     128        /*! @todo This should probably be somehow atomic. */
    137129        memcpy(buffer, hid_dev->input_report,
    138130            hid_dev->input_report_size);
     
    140132        *event_nr = usb_hid_report_number(hid_dev);
    141133       
    142         // clear the buffer so that it will not be received twice
    143         //memset(hid_dev->input_report, 0, hid_dev->input_report_size);
    144        
    145         // note that we already received this report
    146 //      report_received = true;
    147134        usb_log_debug2("OK\n");
    148135       
     
    184171       
    185172        if (hid_dev->report_desc_size > size) {
    186                 return EINVAL;  // TODO: other error code
     173                return EINVAL;
    187174        }
    188175       
  • uspace/drv/usbhid/kbd/kbddev.c

    rbe8d907 r06f9d8fb  
    7272static const unsigned DEFAULT_ACTIVE_MODS = KM_NUM_LOCK;
    7373
    74 ///** Boot protocol report size (key part). */
    75 //static const size_t BOOTP_REPORT_SIZE = 6;
    76 
    77 ///** Boot protocol total report size. */
    78 //static const size_t BOOTP_BUFFER_SIZE = 8;
    79 
    80 ///** Boot protocol output report size. */
    81 //static const size_t BOOTP_BUFFER_OUT_SIZE = 1;
    82 
    83 ///** Boot protocol error key code. */
    84 //static const uint8_t BOOTP_ERROR_ROLLOVER = 1;
    8574static const uint8_t ERROR_ROLLOVER = 1;
    8675
     
    10594        .flags = 0
    10695};
    107 
    108 //static usb_endpoint_description_t hid_poll_endpoint_description = {
    109 //      .transfer_type = USB_TRANSFER_INTERRUPT,
    110 //      .direction = USB_DIRECTION_IN,
    111 //      .interface_class = USB_CLASS_HID,
    112 //      .flags = 0
    113 //};
    114 
    115 ///* Array of endpoints expected on the device, NULL terminated. */
    116 //usb_endpoint_description_t
    117 //    *usb_kbd_endpoints[USB_KBD_POLL_EP_COUNT + 1] = {
    118 //      &boot_poll_endpoint_description,
    119 //      &hid_poll_endpoint_description,
    120 //      NULL
    121 //};
    12296
    12397const char *HID_KBD_FUN_NAME = "keyboard";
     
    176150
    177151/*----------------------------------------------------------------------------*/
    178 
    179 //static void usb_kbd_process_keycodes(const uint8_t *key_codes, size_t count,
    180 //    uint8_t report_id, void *arg);
    181 
    182 //static const usb_hid_report_in_callbacks_t usb_kbd_parser_callbacks = {
    183 //      .keyboard = usb_kbd_process_keycodes
    184 //};
    185 
    186 /*----------------------------------------------------------------------------*/
    187152/* Keyboard layouts                                                           */
    188153/*----------------------------------------------------------------------------*/
     
    200165
    201166/*----------------------------------------------------------------------------*/
    202 /* Modifier constants                                                         */
    203 /*----------------------------------------------------------------------------*/
    204 /** Mapping of USB modifier key codes to generic modifier key codes. */
    205 //static const keycode_t usbhid_modifiers_keycodes[USB_HID_MOD_COUNT] = {
    206 //      KC_LCTRL,         /* USB_HID_MOD_LCTRL */
    207 //      KC_LSHIFT,        /* USB_HID_MOD_LSHIFT */
    208 //      KC_LALT,          /* USB_HID_MOD_LALT */
    209 //      0,                /* USB_HID_MOD_LGUI */
    210 //      KC_RCTRL,         /* USB_HID_MOD_RCTRL */
    211 //      KC_RSHIFT,        /* USB_HID_MOD_RSHIFT */
    212 //      KC_RALT,          /* USB_HID_MOD_RALT */
    213 //      0,                /* USB_HID_MOD_RGUI */
    214 //};
    215 
    216 //typedef enum usbhid_lock_code {
    217 //      USB_KBD_LOCK_NUM = 0x53,
    218 //      USB_KBD_LOCK_CAPS = 0x39,
    219 //      USB_KBD_LOCK_SCROLL = 0x47,
    220 //      USB_KBD_LOCK_COUNT = 3
    221 //} usbhid_lock_code;
    222 
    223 //static const usbhid_lock_code usbhid_lock_codes[USB_KBD_LOCK_COUNT] = {
    224 //      USB_KBD_LOCK_NUM,
    225 //      USB_KBD_LOCK_CAPS,
    226 //      USB_KBD_LOCK_SCROLL
    227 //};
    228 
    229 /*----------------------------------------------------------------------------*/
    230167/* IPC method handler                                                         */
    231168/*----------------------------------------------------------------------------*/
    232169
    233170static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *);
    234 //ddf_dev_ops_t keyboard_ops = {
    235 //      .default_handler = default_connection_handler
    236 //};
    237171
    238172/**
     
    301235                return;
    302236        }
    303                
     237
    304238        /* Reset the LED data. */
    305239        memset(kbd_dev->led_data, 0, kbd_dev->led_output_size * sizeof(int32_t));
     
    495429 */
    496430static void usb_kbd_check_key_changes(usb_hid_dev_t *hid_dev,
    497     usb_kbd_t *kbd_dev/*, const uint8_t *key_codes, size_t count*/)
     431    usb_kbd_t *kbd_dev)
    498432{
    499433        unsigned int key;
     
    567501        }
    568502       
    569 //      usb_log_debug("Old keys: ");
    570 //      for (i = 0; i < kbd_dev->key_count; ++i) {
    571 //              usb_log_debug("%d ", kbd_dev->keys_old[i]);
    572 //      }
    573 //      usb_log_debug("\n");
    574        
    575        
    576 //      usb_log_debug("New keys: ");
    577 //      for (i = 0; i < kbd_dev->key_count; ++i) {
    578 //              usb_log_debug("%d ", kbd_dev->keys[i]);
    579 //      }
    580 //      usb_log_debug("\n");
    581        
    582503        memcpy(kbd_dev->keys_old, kbd_dev->keys, kbd_dev->key_count * 4);
    583504       
     
    590511
    591512/*----------------------------------------------------------------------------*/
    592 /* Callbacks for parser                                                       */
    593 /*----------------------------------------------------------------------------*/
    594 /**
    595  * Callback function for the HID report parser.
    596  *
    597  * This function is called by the HID report parser with the parsed report.
    598  * The parsed report is used to check if any events occured (key was pressed or
    599  * released, modifier was pressed or released).
    600  *
    601  * @param key_codes Parsed keyboard report - codes of currently pressed keys
    602  *                  according to HID Usage Tables.
    603  * @param count Number of key codes in report (size of the report).
    604  * @param report_id
    605  * @param arg User-specified argument. Expects pointer to the keyboard device
    606  *            structure representing the keyboard.
    607  *
    608  * @sa usb_kbd_check_key_changes(), usb_kbd_check_modifier_changes()
    609  */
    610 //static void usb_kbd_process_keycodes(const uint8_t *key_codes, size_t count,
    611 //    uint8_t report_id, void *arg)
    612 //{
    613 //      if (arg == NULL) {
    614 //              usb_log_warning("Missing argument in callback "
    615 //                  "usbhid_process_keycodes().\n");
    616 //              return;
    617 //      }
    618        
    619 //      usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)arg;
    620        
    621 //      if (hid_dev->data == NULL) {
    622 //              usb_log_warning("Missing KBD device structure in callback.\n");
    623 //              return;
    624 //      }
    625        
    626 //      usb_kbd_t *kbd_dev = (usb_kbd_t *)hid_dev->data;
    627 
    628 //      usb_log_debug("Got keys from parser (report id: %u): %s\n",
    629 //          report_id, usb_debug_str_buffer(key_codes, count, 0));
    630        
    631 //      if (count != kbd_dev->key_count) {
    632 //              usb_log_warning("Number of received keycodes (%zu) differs from"
    633 //                  " expected (%zu).\n", count, kbd_dev->key_count);
    634 //              return;
    635 //      }
    636        
    637 //      ///usb_kbd_check_modifier_changes(kbd_dev, key_codes, count);
    638 //      usb_kbd_check_key_changes(hid_dev, kbd_dev, key_codes, count);
    639 //}
    640 
    641 /*----------------------------------------------------------------------------*/
    642513/* General kbd functions                                                      */
    643514/*----------------------------------------------------------------------------*/
     
    668539            "buffer %s\n", usb_debug_str_buffer(buffer, actual_size, 0));
    669540       
    670 //      int rc = usb_hid_boot_keyboard_input_report(buffer, actual_size,
    671 //          callbacks, kbd_dev);
    672541        usb_hid_report_path_t *path = usb_hid_report_path();
    673542        usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0);
    674         //usb_hid_report_path_set_report_id(path, 0);
    675543
    676544        uint8_t report_id;
     
    698566               
    699567                assert(i < kbd_dev->key_count);
    700 //              if (i == kbd_dev->key_count) {
    701 //                      break;
    702 //              }
    703568               
    704569                // save the key usage
    705                 /* TODO: maybe it's not good to save value, nor usage
    706                  *       as the value may be e.g. 1 for LEDs and usage may be
    707                  *       value of the LED. On the other hand, in case of normal
    708                  *       keys, the usage is more important and we must check
    709                  *       that. One possible solution: distinguish between those
    710                  *       two parts of the Report somehow.
    711                  */
    712570                if (field->value != 0) {
    713571                        kbd_dev->keys[i] = field->usage;
     
    896754                usb_log_warning("Error creating output report buffer.\n");
    897755                free(kbd_dev->keys);
    898                 return ENOMEM;  /* TODO: other error code */
     756                return ENOMEM;
    899757        }
    900758       
     
    951809       
    952810        // save the KBD device structure into the HID device structure
    953         //hid_dev->data = kbd_dev;
    954811        *data = kbd_dev;
    955812       
     
    1038895       
    1039896        if ((*kbd_dev)->repeat_mtx != NULL) {
    1040                 /* TODO: replace by some check and wait */
    1041                 assert(!fibril_mutex_is_locked((*kbd_dev)->repeat_mtx));
     897                //assert(!fibril_mutex_is_locked((*kbd_dev)->repeat_mtx));
     898                while (fibril_mutex_is_locked((*kbd_dev)->repeat_mtx)) {}
    1042899                free((*kbd_dev)->repeat_mtx);
    1043900        }
  • uspace/drv/usbhid/kbd/main.c

    rbe8d907 r06f9d8fb  
    131131                    "Could not add DDF function to class 'keyboard': %s.\n",
    132132                    str_error(rc));
    133                 // TODO: Can / should I destroy the DDF function?
    134133                ddf_fun_destroy(kbd_fun);
    135134                usb_kbd_free(&kbd_dev);
    136135                return rc;
    137136        }
    138        
    139         /*
    140          * Create new fibril for handling this keyboard
    141          */
    142         //fid_t fid = fibril_create(usb_kbd_fibril, kbd_dev);
    143137       
    144138        /* Start automated polling function.
     
    164158                return rc;
    165159        }
    166         //fibril_add_ready(fid);
    167160       
    168161        /*
  • uspace/drv/usbhid/mouse/mousedev.c

    rbe8d907 r06f9d8fb  
    394394       
    395395        fun->ops = &mouse->ops;
    396         fun->driver_data = mouse;   // TODO: maybe change to hid_dev->data
     396        fun->driver_data = mouse;
    397397
    398398        int rc = ddf_fun_bind(fun);
     
    432432         */
    433433        fun->ops = &mouse->ops;
    434         fun->driver_data = mouse;   // TODO: maybe change to hid_dev->data
     434        fun->driver_data = mouse;
    435435
    436436        rc = ddf_fun_bind(fun);
     
    488488       
    489489        // set handler for incoming calls
    490         // TODO: must be one for each subdriver!!
    491490        mouse_dev->ops.default_handler = default_connection_handler;
    492491       
    493492        // TODO: how to know if the device supports the request???
    494 //      usbhid_req_set_idle(&hid_dev->usb_dev->ctrl_pipe,
    495 //          hid_dev->usb_dev->interface_no, IDLE_RATE);
     493        usbhid_req_set_idle(&hid_dev->usb_dev->ctrl_pipe,
     494            hid_dev->usb_dev->interface_no, IDLE_RATE);
    496495       
    497496        int rc = usb_mouse_create_function(hid_dev, mouse_dev);
  • uspace/drv/usbhid/mouse/mousedev.h

    rbe8d907 r06f9d8fb  
    4545/** Container for USB mouse device. */
    4646typedef struct {
    47         ///** Polling interval in microseconds. */
    48         //suseconds_t poll_interval_us;
    4947        /** IPC phone to console (consumer). */
    5048        int mouse_phone;
  • uspace/drv/usbhid/multimedia/multimedia.c

    rbe8d907 r06f9d8fb  
    143143        assert(multim_dev != NULL);
    144144       
    145 //      usb_multimedia_t *multim_dev = (usb_multimedia_t *)hid_dev->data;
    146        
    147145        console_event_t ev;
    148146       
     
    173171        // hangup phone to the console
    174172        async_hangup((*multim_dev)->console_phone);
    175        
    176         // free all buffers
    177 //      if ((*multim_dev)->keys != NULL) {
    178 //              free((*multim_dev)->keys);
    179 //      }
    180 //      if ((*multim_dev)->keys_old != NULL) {
    181 //              free((*multim_dev)->keys_old);
    182 //      }
    183173
    184174        free(*multim_dev);
     
    245235        multim_dev->console_phone = -1;
    246236       
    247 //      usb_hid_report_path_t *path = usb_hid_report_path();
    248 //      usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_CONSUMER, 0);
    249        
    250 //      usb_hid_report_path_set_report_id(path, 1);
    251        
    252 //      multim_dev->key_count = usb_hid_report_size(
    253 //          hid_dev->report, 1, USB_HID_REPORT_TYPE_INPUT);
    254 
    255 //      usb_hid_report_path_free(path);
    256        
    257 //      usb_log_debug(NAME " Size of the input report: %zu\n",
    258 //          multim_dev->key_count);
    259        
    260 //      multim_dev->keys = (int32_t *)calloc(multim_dev->key_count,
    261 //          sizeof(int32_t));
    262        
    263 //      if (multim_dev->keys == NULL) {
    264 //              usb_log_fatal("No memory!\n");
    265 //              free(multim_dev);
    266 //              return ENOMEM;
    267 //      }
    268        
    269 //      multim_dev->keys_old =
    270 //              (int32_t *)calloc(multim_dev->key_count, sizeof(int32_t));
    271        
    272 //      if (multim_dev->keys_old == NULL) {
    273 //              usb_log_fatal("No memory!\n");
    274 //              free(multim_dev->keys);
    275 //              free(multim_dev);
    276 //              return ENOMEM;
    277 //      }
    278        
    279237        /*! @todo Autorepeat */
    280238       
     
    315273{
    316274        // TODO: checks
     275        if (hid_dev == NULL || data == NULL || buffer == NULL) {
     276                return false;
     277        }
    317278       
    318279        usb_log_debug(NAME " usb_lgtch_polling_callback(%p, %p, %zu)\n",
    319280            hid_dev, buffer, buffer_size);
    320        
    321         if (data == NULL) {
    322                 return EINVAL;  // TODO: other error code?
    323         }
    324281       
    325282        usb_multimedia_t *multim_dev = (usb_multimedia_t *)data;
     
    348305            | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    349306            USB_HID_REPORT_TYPE_INPUT);
    350        
    351 //      unsigned int key;
    352        
     307
    353308        /*! @todo Is this iterating OK if done multiple times?
    354309         *  @todo The parsing is not OK
  • uspace/drv/usbhid/subdrivers.c

    rbe8d907 r06f9d8fb  
    5858};
    5959
    60 //static usb_hid_subdriver_usage_t generic_hid_key_path[] = {
    61 //      {0, 0}
    62 //};
    63 
    6460const usb_hid_subdriver_mapping_t usb_hid_subdrivers[] = {
    6561        {
     
    10399                }
    104100        },
    105 //      {
    106 //              generic_hid_key_path,
    107 //              0,
    108 //              USB_HID_PATH_COMPARE_ANYWHERE,
    109 //              -1,
    110 //              -1,
    111 //              {
    112 //                      .init = usb_generic_hid_init,
    113 //                      .deinit = NULL,
    114 //                      .poll = usb_generic_hid_polling_callback,
    115 //                      .poll_end = NULL
    116 //              }
    117 //      },
    118101        {NULL, -1, 0, -1, -1, {NULL, NULL, NULL, NULL, NULL}}
    119102};
  • uspace/drv/usbhid/usbhid.c

    rbe8d907 r06f9d8fb  
    6363static const int USB_HID_MAX_SUBDRIVERS = 10;
    6464
    65 /** @todo What happens if this is not fibril local? */
    66 //static fibril_local bool report_number;
    67 
    6865/*----------------------------------------------------------------------------*/
    6966
     
    206203        }
    207204       
    208 //      if (mapping->report_id >= 0) {
    209 //              usb_hid_report_path_set_report_id(usage_path,
    210 //                  mapping->report_id);
    211 //      }
    212        
    213205        assert(hid_dev->report != NULL);
    214206       
    215207        usb_log_debug("Compare flags: %d\n", mapping->compare);
    216 //      size_t size = usb_hid_report_size(hid_dev->report, 0,
    217 //          USB_HID_REPORT_TYPE_INPUT);
    218 //      size_t size = 0;
    219208       
    220209        bool matches = false;
    221 
    222 //      usb_hid_report_description_t *report_des =
    223 //              usb_hid_report_find_description(hid_dev->report,
    224 //              mapping->report_id, USB_HID_REPORT_TYPE_INPUT);
    225210        uint8_t report_id = mapping->report_id;
    226211
    227         /*while(report_des != NULL)*/do {
    228 
    229 //              if((mapping->report_id) == 0 && (report_des->report_id != 0)) {
    230 //                      usb_hid_report_path_set_report_id(usage_path,
    231 //                              report_des->report_id);
    232 //              }
    233                                              
     212        do {
    234213                usb_log_debug("Trying report id %u\n", report_id);
    235214               
     
    247226
    248227                if (field != NULL) {
    249 //                      size++;
    250 //                      field = usb_hid_report_get_sibling(hid_dev->report,
    251 //                          field, usage_path, mapping->compare,
    252 //                          USB_HID_REPORT_TYPE_INPUT);
    253228                        matches = true;
    254229                        break;
     
    258233                    hid_dev->report, report_id,
    259234                    USB_HID_REPORT_TYPE_INPUT);
    260 
    261 //              if((mapping->report_id == 0) && (report_des->report_id != 0)) {
    262 //                      uint8_t report_id = usb_hid_get_next_report_id(
    263 //                              hid_dev->report, report_des->report_id,
    264 //                              USB_HID_REPORT_TYPE_INPUT);
    265 
    266 //                      if(report_id == 0) {
    267 //                              break;
    268 //                      }
    269 
    270 //                      report_des = usb_hid_report_find_description(
    271 //                              hid_dev->report, report_id,
    272 //                              USB_HID_REPORT_TYPE_INPUT);
    273 //              }
    274 //              else {
    275 //                      break;
    276 //              }
    277235        } while (!matches && report_id != 0);
    278236       
    279 //      usb_log_debug("Size of the input report: %zu\n", size);
    280237        usb_hid_report_path_free(usage_path);
    281238       
     
    423380       
    424381        uint8_t report_id = 0;
    425         size_t size;/* = usb_hid_report_byte_size(hid_dev->report, report_id,
    426             USB_HID_REPORT_TYPE_INPUT);*/
     382        size_t size;
    427383       
    428384        size_t max_size = 0;
     
    503459        rc = usb_hid_check_pipes(hid_dev, dev);
    504460        if (rc != EOK) {
    505                 //usb_hid_free(&hid_dev);
    506461                return rc;
    507462        }
     
    551506                            == USB_HID_GENERIC_POLL_EP_NO);
    552507                       
    553                         /* TODO: this has no meaning if the report descriptor
    554                                  is not parsed */
    555508                        usb_log_info("Falling back to generic HID driver.\n");
    556509                        rc = usb_hid_set_generic_hid_subdriver(hid_dev);
     
    563516                usb_log_debug("Subdriver count: %d\n",
    564517                    hid_dev->subdriver_count);
    565                 //usb_hid_free(&hid_dev);
    566518               
    567519        } else {
     
    619571        usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)arg;
    620572       
    621 //      int allocated = (hid_dev->input_report != NULL);
    622573        assert(hid_dev->input_report != NULL);
    623574        usb_log_debug("Max input report size: %zu, buffer size: %zu\n",
    624575            hid_dev->max_input_report_size, buffer_size);
    625         //assert(hid_dev->max_input_report_size >= buffer_size);
     576
    626577        if (hid_dev->max_input_report_size >= buffer_size) {
    627578                /*! @todo This should probably be atomic. */
     
    670621/*----------------------------------------------------------------------------*/
    671622
    672 //const char *usb_hid_get_function_name(const usb_hid_dev_t *hid_dev)
    673 //{
    674 //      switch (hid_dev->poll_pipe_index) {
    675 //      case USB_HID_KBD_POLL_EP_NO:
    676 //              return HID_KBD_FUN_NAME;
    677 //              break;
    678 //      case USB_HID_MOUSE_POLL_EP_NO:
    679 //              return HID_MOUSE_FUN_NAME;
    680 //              break;
    681 //      default:
    682 //              return HID_GENERIC_FUN_NAME;
    683 //      }
    684 //}
    685 
    686 /*----------------------------------------------------------------------------*/
    687 
    688 //const char *usb_hid_get_class_name(const usb_hid_dev_t *hid_dev)
    689 //{
    690 //      // this means that only boot protocol keyboards will be connected
    691 //      // to the console; there is probably no better way to do this
    692        
    693 //      switch (hid_dev->poll_pipe_index) {
    694 //      case USB_HID_KBD_POLL_EP_NO:
    695 //              return HID_KBD_CLASS_NAME;
    696 //              break;
    697 //      case USB_HID_MOUSE_POLL_EP_NO:
    698 //              return HID_MOUSE_CLASS_NAME;
    699 //              break;
    700 //      default:
    701 //              return HID_GENERIC_CLASS_NAME;
    702 //      }
    703 //}
    704 
    705 /*----------------------------------------------------------------------------*/
    706 
    707623void usb_hid_new_report(usb_hid_dev_t *hid_dev)
    708624{
     
    716632        return hid_dev->report_nr;
    717633}
    718 
    719 /*----------------------------------------------------------------------------*/
    720 
    721 //void usb_hid_report_received(void)
    722 //{
    723 //      ++report_number;
    724 //}
    725 
    726 /*----------------------------------------------------------------------------*/
    727 
    728 //bool usb_hid_report_ready(void)
    729 //{
    730 //      return !report_received;
    731 //}
    732634
    733635/*----------------------------------------------------------------------------*/
  • uspace/drv/usbhid/usbhid.h

    rbe8d907 r06f9d8fb  
    5555                                         bool reason);
    5656
    57 // TODO: add function and class name??
    5857typedef struct usb_hid_subdriver {     
    5958        /** Function to be called when initializing HID device. */
     
    126125     void *arg);
    127126
    128 //const char *usb_hid_get_function_name(const usb_hid_dev_t *hid_dev);
    129 
    130 //const char *usb_hid_get_class_name(const usb_hid_dev_t *hid_dev);
    131 
    132127void usb_hid_new_report(usb_hid_dev_t *hid_dev);
    133128
    134129int usb_hid_report_number(usb_hid_dev_t *hid_dev);
    135 
    136 //void usb_hid_report_received(void);
    137 
    138 //bool usb_hid_report_ready(void);
    139130
    140131void usb_hid_free(usb_hid_dev_t **hid_dev);
  • uspace/srv/hid/console/console.c

    rbe8d907 r06f9d8fb  
    768768       
    769769        int phone = fd_phone(fd);
     770        close(fd);
    770771        if (phone < 0) {
    771772                printf(NAME ": Failed to connect to input device\n");
     
    777778            handler, &hash);
    778779        if (rc != EOK) {
     780                async_hangup(phone);
    779781                printf(NAME ": " \
    780782                    "Failed to create callback from input device: %s.\n",
Note: See TracChangeset for help on using the changeset viewer.