Changeset 5079242 in mainline


Ignore:
Timestamp:
2011-03-06T00:15:00Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
40a5d40
Parents:
eae83aa (diff), d20f211 (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:

Development branch changes

Location:
uspace
Files:
6 edited

Legend:

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

    reae83aa r5079242  
    143143/*----------------------------------------------------------------------------*/
    144144
     145int usbhid_req_set_idle(usbhid_dev_t *hid_dev, uint8_t duration)
     146{
     147        if (hid_dev == NULL) {
     148                usb_log_error("usbhid_req_set_idle(): no HID device "
     149                    "structure given.\n");
     150                return EINVAL;
     151        }
     152       
     153        /*
     154         * No need for checking other parameters, as they are checked in
     155         * the called function (usb_control_request_set()).
     156         */
     157       
     158        int rc, sess_rc;
     159       
     160        sess_rc = usb_endpoint_pipe_start_session(&hid_dev->ctrl_pipe);
     161        if (sess_rc != EOK) {
     162                usb_log_warning("Failed to start a session: %s.\n",
     163                    str_error(sess_rc));
     164                return sess_rc;
     165        }
     166
     167        usb_log_debug("Sending Set_Idle request to the device ("
     168            "duration: %u, iface: %d).\n", duration, hid_dev->iface);
     169       
     170        uint16_t value = duration << 8;
     171       
     172        rc = usb_control_request_set(&hid_dev->ctrl_pipe,
     173            USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE,
     174            USB_HIDREQ_SET_IDLE, value, hid_dev->iface, NULL, 0);
     175
     176        sess_rc = usb_endpoint_pipe_end_session(&hid_dev->ctrl_pipe);
     177
     178        if (rc != EOK) {
     179                usb_log_warning("Error sending output report to the keyboard: "
     180                    "%s.\n", str_error(rc));
     181                return rc;
     182        }
     183
     184        if (sess_rc != EOK) {
     185                usb_log_warning("Error closing session: %s.\n",
     186                    str_error(sess_rc));
     187                return sess_rc;
     188        }
     189       
     190        return EOK;
     191}
     192
     193/*----------------------------------------------------------------------------*/
     194
    145195/**
    146196 * @}
  • uspace/drv/usbhid/hidreq.h

    reae83aa r5079242  
    5050int usbhid_req_set_protocol(usbhid_dev_t *hid_dev, usb_hid_protocol_t protocol);
    5151
     52int usbhid_req_set_idle(usbhid_dev_t *hid_dev, uint8_t duration);
     53
    5254/*----------------------------------------------------------------------------*/
    5355
  • uspace/drv/usbhid/kbddev.c

    reae83aa r5079242  
    3838#include <str_error.h>
    3939#include <fibril.h>
     40#include <stdio.h>
    4041
    4142#include <io/keycode.h>
     
    6263static const size_t BOOTP_BUFFER_SIZE = 8;
    6364static const size_t BOOTP_BUFFER_OUT_SIZE = 1;
     65static const uint8_t IDLE_RATE = 0;
    6466
    6567/** Keyboard polling endpoint description for boot protocol class. */
     
    149151        uint8_t buffer[BOOTP_BUFFER_OUT_SIZE];
    150152        int rc= 0;
    151         unsigned i;
    152153       
    153154        memset(buffer, 0, BOOTP_BUFFER_OUT_SIZE);
     
    177178        }
    178179       
    179         // TODO: REFACTOR!!!
    180        
    181         usb_log_debug("Output report buffer: ");
    182         for (i = 0; i < BOOTP_BUFFER_OUT_SIZE; ++i) {
    183                 usb_log_debug("0x%x ", buffer[i]);
    184         }
    185         usb_log_debug("\n");
     180        usb_log_debug("Output report buffer: %s\n",
     181            usb_debug_str_buffer(buffer, BOOTP_BUFFER_OUT_SIZE, 0));
    186182       
    187183        uint16_t value = 0;
     
    228224
    229225        if (mod_mask != 0) {
    230                 usb_log_debug2("\n\nChanging mods and lock keys\n");
    231                 usb_log_debug2("\nmods before: 0x%x\n", kbd_dev->mods);
    232                 usb_log_debug2("\nLock keys before:0x%x\n\n",
    233                     kbd_dev->lock_keys);
    234                
    235226                if (type == KEY_PRESS) {
    236                         usb_log_debug2("\nKey pressed.\n");
    237227                        /*
    238228                         * Only change lock state on transition from released
     
    247237                        usbhid_kbd_set_led(kbd_dev);
    248238                } else {
    249                         usb_log_debug2("\nKey released.\n");
    250239                        kbd_dev->lock_keys = kbd_dev->lock_keys & ~mod_mask;
    251240                }
    252241        }
    253242
    254         usb_log_debug2("\n\nmods after: 0x%x\n", kbd_dev->mods);
    255         usb_log_debug2("\nLock keys after: 0x%x\n\n", kbd_dev->lock_keys);
    256        
    257243        if (key == KC_CAPS_LOCK || key == KC_NUM_LOCK || key == KC_SCROLL_LOCK) {
    258244                // do not send anything to the console, this is our business
     
    281267        ev.key = key;
    282268        ev.mods = kbd_dev->mods;
    283        
    284         if (ev.mods & KM_NUM_LOCK) {
    285                 usb_log_debug("\n\nNum Lock turned on.\n\n");
    286         }
    287269
    288270        ev.c = layout[active_layout]->parse_ev(&ev);
     
    389371                }
    390372        }
     373//      // report all currently pressed keys
     374//      for (i = 0; i < kbd_dev->keycode_count; ++i) {
     375//              if (key_codes[i] != 0) {
     376//                      key = usbhid_parse_scancode(key_codes[i]);
     377//                      usb_log_debug2("\nKey pressed: %d (keycode: %d)\n", key,
     378//                          key_codes[i]);
     379//                      usbhid_kbd_push_ev(kbd_dev, KEY_PRESS, key);
     380//              }
     381//      }
    391382       
    392383        memcpy(kbd_dev->keycodes, key_codes, kbd_dev->keycode_count);
    393        
    394         usb_log_debug2("\nNew stored keycodes: ");
    395         for (i = 0; i < kbd_dev->keycode_count; ++i) {
    396                 usb_log_debug2("%d ", kbd_dev->keycodes[i]);
    397         }
     384
     385        usb_log_debug("New stored keycodes: %s\n",
     386            usb_debug_str_buffer(kbd_dev->keycodes, kbd_dev->keycode_count, 0));
    398387}
    399388
     
    410399                return;
    411400        }
    412 
    413         usb_log_debug2("Got keys from parser: ");
    414         unsigned i;
    415         for (i = 0; i < count; ++i) {
    416                 usb_log_debug2("%d ", key_codes[i]);
    417         }
    418         usb_log_debug2("\n");
    419401       
    420402        usbhid_kbd_t *kbd_dev = (usbhid_kbd_t *)arg;
    421403        assert(kbd_dev != NULL);
     404
     405        usb_log_debug("Got keys from parser: %s\n",
     406            usb_debug_str_buffer(key_codes, kbd_dev->keycode_count, 0));
    422407       
    423408        if (count != kbd_dev->keycode_count) {
     
    444429        callbacks->keyboard = usbhid_kbd_process_keycodes;
    445430
    446         //usb_hid_parse_report(kbd_dev->parser, buffer, actual_size, callbacks,
    447         //    NULL);
    448         /*usb_log_debug2("Calling usb_hid_boot_keyboard_input_report() with size"
    449             " %zu\n", actual_size);*/
    450         //dump_buffer("bufffer: ", buffer, actual_size);
     431        usb_log_debug("Calling usb_hid_boot_keyboard_input_report() with "
     432            "buffer %s\n", usb_debug_str_buffer(buffer, actual_size, 0));
    451433       
    452434        int rc = usb_hid_boot_keyboard_input_report(buffer, actual_size,
     
    559541         * Set boot protocol.
    560542         * Set LEDs according to initial setup.
     543         * Set Idle rate
    561544         */
    562545        assert(kbd_dev->hid_dev != NULL);
     
    565548       
    566549        usbhid_kbd_set_led(kbd_dev);
     550       
     551        usbhid_req_set_idle(kbd_dev->hid_dev, IDLE_RATE);
    567552       
    568553        kbd_dev->initialized = 1;
     
    634619                usbhid_kbd_process_data(kbd_dev, buffer, actual_size);
    635620               
    636                 async_usleep(kbd_dev->hid_dev->poll_interval);
     621                // disabled for now, no reason to sleep
     622                //async_usleep(kbd_dev->hid_dev->poll_interval);
    637623        }
    638624
  • uspace/drv/usbhid/main.c

    reae83aa r5079242  
    8080int main(int argc, char *argv[])
    8181{
    82         usb_log_enable(USB_LOG_LEVEL_INFO, NAME);
     82        usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
    8383        return ddf_driver_main(&kbd_driver);
    8484}
  • uspace/lib/usb/include/usb/debug.h

    reae83aa r5079242  
    7979        usb_log_printf(USB_LOG_LEVEL_DEBUG2, format, ##__VA_ARGS__)
    8080
    81 const char *usb_debug_str_buffer(uint8_t *, size_t, size_t);
     81const char *usb_debug_str_buffer(const uint8_t *, size_t, size_t);
    8282
    8383
  • uspace/lib/usb/src/debug.c

    reae83aa r5079242  
    281281 * @return Dumped buffer as a static (but fibril local) string.
    282282 */
    283 const char *usb_debug_str_buffer(uint8_t *buffer, size_t size,
     283const char *usb_debug_str_buffer(const uint8_t *buffer, size_t size,
    284284    size_t dumped_size)
    285285{
Note: See TracChangeset for help on using the changeset viewer.