Changeset 5da7199 in mainline for uspace/drv/bus/usb/usbhid/kbd/kbddev.c
- Timestamp:
- 2011-09-09T17:18:06Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3781092, b7c33b0
- Parents:
- c69646f8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhid/kbd/kbddev.c
rc69646f8 r5da7199 43 43 #include <ipc/kbdev.h> 44 44 #include <async.h> 45 #include <async_obsolete.h>46 45 #include <fibril.h> 47 46 #include <fibril_synch.h> … … 70 69 71 70 #include "../usbhid.h" 72 73 // FIXME: remove this header74 #include <abi/ipc/methods.h>75 71 76 72 /*----------------------------------------------------------------------------*/ … … 167 163 * 168 164 * Currently recognizes only one method (IPC_M_CONNECT_TO_ME), in which case it 169 * assumes the caller is the console and thus it stores IPC phone to it for165 * assumes the caller is the console and thus it stores IPC session to it for 170 166 * later use by the driver to notify about key events. 171 167 * … … 178 174 { 179 175 sysarg_t method = IPC_GET_IMETHOD(*icall); 180 int callback; 181 182 usb_kbd_t *kbd_dev = (usb_kbd_t *)fun->driver_data; 176 177 usb_kbd_t *kbd_dev = (usb_kbd_t *) fun->driver_data; 183 178 if (kbd_dev == NULL) { 184 179 usb_log_debug("default_connection_handler: " … … 187 182 return; 188 183 } 189 190 switch (method) { 191 case IPC_M_CONNECT_TO_ME: 192 callback = IPC_GET_ARG5(*icall); 193 194 if (kbd_dev->console_phone != -1) { 184 185 async_sess_t *sess = 186 async_callback_receive_start(EXCHANGE_SERIALIZE, icall); 187 if (sess != NULL) { 188 if (kbd_dev->console_sess == NULL) { 189 kbd_dev->console_sess = sess; 190 usb_log_debug("default_connection_handler: OK\n"); 191 async_answer_0(icallid, EOK); 192 } else { 195 193 usb_log_debug("default_connection_handler: " 196 "console phonealready set\n");194 "console session already set\n"); 197 195 async_answer_0(icallid, ELIMIT); 198 return; 199 } 200 201 kbd_dev->console_phone = callback; 202 203 usb_log_debug("default_connection_handler: OK\n"); 204 async_answer_0(icallid, EOK); 205 break; 206 case KBDEV_SET_IND: 207 kbd_dev->mods = IPC_GET_ARG1(*icall); 208 usb_kbd_set_led(kbd_dev->hid_dev, kbd_dev); 209 async_answer_0(icallid, EOK); 210 break; 211 default: 212 usb_log_debug("default_connection_handler: Wrong function.\n"); 213 async_answer_0(icallid, EINVAL); 214 break; 196 } 197 } else { 198 switch (method) { 199 case KBDEV_SET_IND: 200 kbd_dev->mods = IPC_GET_ARG1(*icall); 201 usb_kbd_set_led(kbd_dev->hid_dev, kbd_dev); 202 async_answer_0(icallid, EOK); 203 break; 204 default: 205 usb_log_debug("default_connection_handler: Wrong function.\n"); 206 async_answer_0(icallid, EINVAL); 207 break; 208 } 215 209 } 216 210 } … … 301 295 { 302 296 usb_log_debug2("Sending kbdev event %d/%d to the console\n", type, key); 303 if (kbd_dev->console_ phone < 0) {297 if (kbd_dev->console_sess == NULL) { 304 298 usb_log_warning( 305 299 "Connection to console not ready, key discarded.\n"); … … 307 301 } 308 302 309 async_obsolete_msg_2(kbd_dev->console_phone, KBDEV_EVENT, type, key); 303 async_exch_t *exch = async_exchange_begin(kbd_dev->console_sess); 304 async_msg_2(exch, KBDEV_EVENT, type, key); 305 async_exchange_end(exch); 310 306 } 311 307 … … 510 506 } 511 507 512 kbd_dev->console_ phone = -1;508 kbd_dev->console_sess = NULL; 513 509 kbd_dev->initialized = USB_KBD_STATUS_UNINITIALIZED; 514 510 … … 785 781 } 786 782 787 // hangup phoneto the console788 async_ obsolete_hangup(kbd_dev->console_phone);783 // hangup session to the console 784 async_hangup(kbd_dev->console_sess); 789 785 790 786 if (kbd_dev->repeat_mtx != NULL) {
Note:
See TracChangeset
for help on using the changeset viewer.