Changeset 5079242 in mainline
- Timestamp:
- 2011-03-06T00:15:00Z (14 years ago)
- 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. - Location:
- uspace
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/hidreq.c
reae83aa r5079242 143 143 /*----------------------------------------------------------------------------*/ 144 144 145 int 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 145 195 /** 146 196 * @} -
uspace/drv/usbhid/hidreq.h
reae83aa r5079242 50 50 int usbhid_req_set_protocol(usbhid_dev_t *hid_dev, usb_hid_protocol_t protocol); 51 51 52 int usbhid_req_set_idle(usbhid_dev_t *hid_dev, uint8_t duration); 53 52 54 /*----------------------------------------------------------------------------*/ 53 55 -
uspace/drv/usbhid/kbddev.c
reae83aa r5079242 38 38 #include <str_error.h> 39 39 #include <fibril.h> 40 #include <stdio.h> 40 41 41 42 #include <io/keycode.h> … … 62 63 static const size_t BOOTP_BUFFER_SIZE = 8; 63 64 static const size_t BOOTP_BUFFER_OUT_SIZE = 1; 65 static const uint8_t IDLE_RATE = 0; 64 66 65 67 /** Keyboard polling endpoint description for boot protocol class. */ … … 149 151 uint8_t buffer[BOOTP_BUFFER_OUT_SIZE]; 150 152 int rc= 0; 151 unsigned i;152 153 153 154 memset(buffer, 0, BOOTP_BUFFER_OUT_SIZE); … … 177 178 } 178 179 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)); 186 182 187 183 uint16_t value = 0; … … 228 224 229 225 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 235 226 if (type == KEY_PRESS) { 236 usb_log_debug2("\nKey pressed.\n");237 227 /* 238 228 * Only change lock state on transition from released … … 247 237 usbhid_kbd_set_led(kbd_dev); 248 238 } else { 249 usb_log_debug2("\nKey released.\n");250 239 kbd_dev->lock_keys = kbd_dev->lock_keys & ~mod_mask; 251 240 } 252 241 } 253 242 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 257 243 if (key == KC_CAPS_LOCK || key == KC_NUM_LOCK || key == KC_SCROLL_LOCK) { 258 244 // do not send anything to the console, this is our business … … 281 267 ev.key = key; 282 268 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 }287 269 288 270 ev.c = layout[active_layout]->parse_ev(&ev); … … 389 371 } 390 372 } 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 // } 391 382 392 383 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)); 398 387 } 399 388 … … 410 399 return; 411 400 } 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");419 401 420 402 usbhid_kbd_t *kbd_dev = (usbhid_kbd_t *)arg; 421 403 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)); 422 407 423 408 if (count != kbd_dev->keycode_count) { … … 444 429 callbacks->keyboard = usbhid_kbd_process_keycodes; 445 430 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)); 451 433 452 434 int rc = usb_hid_boot_keyboard_input_report(buffer, actual_size, … … 559 541 * Set boot protocol. 560 542 * Set LEDs according to initial setup. 543 * Set Idle rate 561 544 */ 562 545 assert(kbd_dev->hid_dev != NULL); … … 565 548 566 549 usbhid_kbd_set_led(kbd_dev); 550 551 usbhid_req_set_idle(kbd_dev->hid_dev, IDLE_RATE); 567 552 568 553 kbd_dev->initialized = 1; … … 634 619 usbhid_kbd_process_data(kbd_dev, buffer, actual_size); 635 620 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); 637 623 } 638 624 -
uspace/drv/usbhid/main.c
reae83aa r5079242 80 80 int main(int argc, char *argv[]) 81 81 { 82 usb_log_enable(USB_LOG_LEVEL_ INFO, NAME);82 usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME); 83 83 return ddf_driver_main(&kbd_driver); 84 84 } -
uspace/lib/usb/include/usb/debug.h
reae83aa r5079242 79 79 usb_log_printf(USB_LOG_LEVEL_DEBUG2, format, ##__VA_ARGS__) 80 80 81 const char *usb_debug_str_buffer( uint8_t *, size_t, size_t);81 const char *usb_debug_str_buffer(const uint8_t *, size_t, size_t); 82 82 83 83 -
uspace/lib/usb/src/debug.c
reae83aa r5079242 281 281 * @return Dumped buffer as a static (but fibril local) string. 282 282 */ 283 const char *usb_debug_str_buffer( uint8_t *buffer, size_t size,283 const char *usb_debug_str_buffer(const uint8_t *buffer, size_t size, 284 284 size_t dumped_size) 285 285 {
Note:
See TracChangeset
for help on using the changeset viewer.