Changes in uspace/drv/bus/usb/usbhid/kbd/kbddev.c [76fbd9a:2d1ba51] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhid/kbd/kbddev.c
r76fbd9a r2d1ba51 71 71 #include "../usbhid.h" 72 72 73 static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *); 74 static ddf_dev_ops_t kbdops = { .default_handler = default_connection_handler }; 75 73 /*----------------------------------------------------------------------------*/ 76 74 77 75 static const unsigned DEFAULT_ACTIVE_MODS = KM_NUM_LOCK; … … 88 86 static const unsigned int DEFAULT_REPEAT_DELAY = 50 * 1000; 89 87 90 88 /*----------------------------------------------------------------------------*/ 91 89 /** Keyboard polling endpoint description for boot protocol class. */ 92 90 const usb_endpoint_description_t usb_hid_kbd_poll_endpoint_description = { … … 103 101 104 102 static void usb_kbd_set_led(usb_hid_dev_t *hid_dev, usb_kbd_t *kbd_dev); 105 103 /*----------------------------------------------------------------------------*/ 106 104 static const uint8_t USB_KBD_BOOT_REPORT_DESCRIPTOR[] = { 107 105 0x05, 0x01, /* Usage Page (Generic Desktop), */ … … 138 136 0xC0 /* End Collection */ 139 137 }; 140 138 /*----------------------------------------------------------------------------*/ 141 139 typedef enum usb_kbd_flags { 142 140 USB_KBD_STATUS_UNINITIALIZED = 0, … … 144 142 USB_KBD_STATUS_TO_DESTROY = -1 145 143 } usb_kbd_flags; 146 144 /*----------------------------------------------------------------------------*/ 147 145 /* IPC method handler */ 148 146 /*----------------------------------------------------------------------------*/ 149 147 /** 150 148 * Default handler for IPC methods not handled by DDF. … … 189 187 break; 190 188 } 191 if (kbd_dev->c lient_sess == NULL) {192 kbd_dev->c lient_sess = sess;189 if (kbd_dev->console_sess == NULL) { 190 kbd_dev->console_sess = sess; 193 191 usb_log_debug("%s: OK\n", __FUNCTION__); 194 192 async_answer_0(icallid, EOK); … … 208 206 209 207 } 210 208 /*----------------------------------------------------------------------------*/ 211 209 /* Key processing functions */ 212 210 /*----------------------------------------------------------------------------*/ 213 211 /** 214 212 * Handles turning of LED lights on and off. … … 283 281 } 284 282 } 285 283 /*----------------------------------------------------------------------------*/ 286 284 /** Send key event. 287 285 * … … 294 292 { 295 293 usb_log_debug2("Sending kbdev event %d/%d to the console\n", type, key); 296 if (kbd_dev->c lient_sess == NULL) {294 if (kbd_dev->console_sess == NULL) { 297 295 usb_log_warning( 298 296 "Connection to console not ready, key discarded.\n"); … … 300 298 } 301 299 302 async_exch_t *exch = async_exchange_begin(kbd_dev->c lient_sess);300 async_exch_t *exch = async_exchange_begin(kbd_dev->console_sess); 303 301 if (exch != NULL) { 304 302 async_msg_2(exch, KBDEV_EVENT, type, key); … … 308 306 } 309 307 } 310 308 /*----------------------------------------------------------------------------*/ 311 309 static inline int usb_kbd_is_lock(unsigned int key_code) 312 310 { … … 315 313 || key_code == KC_CAPS_LOCK); 316 314 } 317 315 /*----------------------------------------------------------------------------*/ 318 316 static size_t find_in_array_int32(int32_t val, int32_t *arr, size_t arr_size) 319 317 { … … 326 324 return (size_t) -1; 327 325 } 328 326 /*----------------------------------------------------------------------------*/ 329 327 /** 330 328 * Checks if some keys were pressed or released and generates key events. … … 409 407 usb_log_debug2("Stored keys %s.\n", key_buffer); 410 408 } 411 409 /*----------------------------------------------------------------------------*/ 412 410 /* General kbd functions */ 413 411 /*----------------------------------------------------------------------------*/ 414 412 /** 415 413 * Processes data received from the device in form of report. … … 481 479 usb_kbd_check_key_changes(hid_dev, kbd_dev); 482 480 } 483 481 /*----------------------------------------------------------------------------*/ 484 482 /* HID/KBD structure manipulation */ 485 483 /*----------------------------------------------------------------------------*/ 486 484 static int usb_kbd_create_function(usb_kbd_t *kbd_dev) 487 485 { … … 501 499 /* Store the initialized HID device and HID ops 502 500 * to the DDF function. */ 503 fun->ops = &kbd ops;501 fun->ops = &kbd_dev->ops; 504 502 fun->driver_data = kbd_dev; 505 503 … … 537 535 return EOK; 538 536 } 539 537 /*----------------------------------------------------------------------------*/ 540 538 /* API functions */ 541 539 /*----------------------------------------------------------------------------*/ 542 540 /** 543 541 * Initialization of the USB/HID keyboard structure. … … 578 576 fibril_mutex_initialize(&kbd_dev->repeat_mtx); 579 577 kbd_dev->initialized = USB_KBD_STATUS_UNINITIALIZED; 578 kbd_dev->ops.default_handler = default_connection_handler; 580 579 581 580 /* Store link to HID device */ … … 701 700 return EOK; 702 701 } 703 702 /*----------------------------------------------------------------------------*/ 704 703 bool usb_kbd_polling_callback(usb_hid_dev_t *hid_dev, void *data) 705 704 { … … 715 714 return true; 716 715 } 717 716 /*----------------------------------------------------------------------------*/ 718 717 int usb_kbd_is_initialized(const usb_kbd_t *kbd_dev) 719 718 { 720 719 return (kbd_dev->initialized == USB_KBD_STATUS_INITIALIZED); 721 720 } 722 721 /*----------------------------------------------------------------------------*/ 723 722 int usb_kbd_is_ready_to_destroy(const usb_kbd_t *kbd_dev) 724 723 { 725 724 return (kbd_dev->initialized == USB_KBD_STATUS_TO_DESTROY); 726 725 } 727 726 /*----------------------------------------------------------------------------*/ 728 727 /** 729 728 * Properly destroys the USB/HID keyboard structure. … … 738 737 739 738 /* Hangup session to the console. */ 740 if (kbd_dev->c lient_sess)741 async_hangup(kbd_dev->c lient_sess);739 if (kbd_dev->console_sess) 740 async_hangup(kbd_dev->console_sess); 742 741 743 742 //assert(!fibril_mutex_is_locked((*kbd_dev)->repeat_mtx)); … … 766 765 free(kbd_dev); 767 766 } 768 767 /*----------------------------------------------------------------------------*/ 769 768 void usb_kbd_deinit(usb_hid_dev_t *hid_dev, void *data) 770 769 { … … 779 778 } 780 779 } 781 780 /*----------------------------------------------------------------------------*/ 782 781 int usb_kbd_set_boot_protocol(usb_hid_dev_t *hid_dev) 783 782 {
Note:
See TracChangeset
for help on using the changeset viewer.