Changeset 1c6c4092 in mainline
- Timestamp:
- 2011-03-01T16:39:31Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0f31e2b, 494eaf7
- Parents:
- 27270db
- Location:
- uspace/drv/usbhid
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/hiddev.c
r27270db r1c6c4092 270 270 /*----------------------------------------------------------------------------*/ 271 271 272 void usbhid_dev_free(usbhid_dev_t **hid_dev) 273 { 274 if (hid_dev == NULL || *hid_dev == NULL) { 275 return; 276 } 277 278 // free the report descriptor 279 if ((*hid_dev)->report_desc != NULL) { 280 free((*hid_dev)->report_desc); 281 } 282 // destroy the parser 283 if ((*hid_dev)->parser != NULL) { 284 usb_hid_free_report_parser((*hid_dev)->parser); 285 } 286 287 // TODO: cleanup pipes 288 289 free(*hid_dev); 290 *hid_dev = NULL; 291 } 292 293 /*----------------------------------------------------------------------------*/ 294 272 295 int usbhid_dev_init(usbhid_dev_t *hid_dev, ddf_dev_t *dev, 273 296 usb_endpoint_description_t *poll_ep_desc) -
uspace/drv/usbhid/hiddev.h
r27270db r1c6c4092 69 69 usbhid_dev_t *usbhid_dev_new(void); 70 70 71 void usbhid_dev_free(usbhid_dev_t **hid_dev); 72 71 73 int usbhid_dev_init(usbhid_dev_t *hid_dev, ddf_dev_t *dev, 72 74 usb_endpoint_description_t *poll_ep_desc); -
uspace/drv/usbhid/kbddev.c
r27270db r1c6c4092 41 41 #include <io/keycode.h> 42 42 #include <ipc/kbd.h> 43 #include <async.h> 43 44 44 45 #include <usb/usb.h> … … 253 254 usb_log_debug2("\n\nmods after: 0x%x\n", kbd_dev->mods); 254 255 usb_log_debug2("\nLock keys after: 0x%x\n\n", kbd_dev->lock_keys); 256 257 if (key = KC_CAPS_LOCK || key == KC_NUM_LOCK || key == KC_SCROLL_LOCK) { 258 // do not send anything to the console, this is our business 259 return; 260 } 255 261 256 262 if (type == KEY_PRESS && (kbd_dev->mods & KM_LCTRL) && key == KC_F1) { … … 453 459 /*----------------------------------------------------------------------------*/ 454 460 455 static usbhid_kbd_t *usbhid_kbd_new( )461 static usbhid_kbd_t *usbhid_kbd_new(void) 456 462 { 457 463 usbhid_kbd_t *kbd_dev = … … 475 481 476 482 return kbd_dev; 483 } 484 485 /*----------------------------------------------------------------------------*/ 486 487 static void usbhid_kbd_free(usbhid_kbd_t **kbd_dev) 488 { 489 if (kbd_dev == NULL || *kbd_dev == NULL) { 490 return; 491 } 492 493 // hangup phone to the console 494 async_hangup((*kbd_dev)->console_phone); 495 496 if ((*kbd_dev)->hid_dev != NULL) { 497 usbhid_dev_free(&(*kbd_dev)->hid_dev); 498 assert((*kbd_dev)->hid_dev == NULL); 499 } 500 501 free(*kbd_dev); 502 *kbd_dev = NULL; 477 503 } 478 504 … … 623 649 624 650 usbhid_kbd_poll(kbd_dev); 651 652 // at the end, properly destroy the KBD structure 653 usbhid_kbd_free(&kbd_dev); 654 assert(kbd_dev == NULL); 625 655 626 656 return EOK; … … 645 675 * Initialize device (get and process descriptors, get address, etc.) 646 676 */ 647 usb_log_info("Initializing USB HID/KBD device...\n");677 usb_log_info("Initializing USB/HID KBD device...\n"); 648 678 649 679 usbhid_kbd_t *kbd_dev = usbhid_kbd_new(); 650 680 if (kbd_dev == NULL) { 651 usb_log_error("Error while creating USB HID/KBD device "681 usb_log_error("Error while creating USB/HID KBD device " 652 682 "structure.\n"); 653 683 ddf_fun_destroy(kbd_fun); … … 658 688 659 689 if (rc != EOK) { 660 usb_log_error("Failed to initialize USB HID/KBD device.\n");690 usb_log_error("Failed to initialize USB/HID KBD device.\n"); 661 691 ddf_fun_destroy(kbd_fun); 692 usbhid_kbd_free(&kbd_dev); 662 693 return rc; 663 694 } 664 695 665 usb_log_info("USB/ KBD device structure initialized.\n");696 usb_log_info("USB/HID KBD device structure initialized.\n"); 666 697 667 698 /* … … 675 706 if (rc != EOK) { 676 707 usb_log_error("Could not bind DDF function.\n"); 708 // TODO: Can / should I destroy the DDF function? 709 ddf_fun_destroy(kbd_fun); 710 usbhid_kbd_free(&kbd_dev); 677 711 return rc; 678 712 } … … 682 716 usb_log_error("Could not add DDF function to class 'keyboard'" 683 717 "\n"); 718 // TODO: Can / should I destroy the DDF function? 719 ddf_fun_destroy(kbd_fun); 720 usbhid_kbd_free(&kbd_dev); 684 721 return rc; 685 722 } … … 690 727 fid_t fid = fibril_create(usbhid_kbd_fibril, kbd_dev); 691 728 if (fid == 0) { 692 usb_log_error("Failed to start fibril for HID device\n");729 usb_log_error("Failed to start fibril for KBD device\n"); 693 730 return ENOMEM; 694 731 } -
uspace/drv/usbhid/main.c
r27270db r1c6c4092 40 40 #include <errno.h> 41 41 42 //#include <ipc/driver.h>43 //#include <ipc/kbd.h>44 //#include <io/keycode.h>45 //#include <io/console.h>46 //#include <str_error.h>47 48 //#include <usb/classes/classes.h>49 //#include <usb/classes/hid.h>50 //#include <usb/classes/hidparser.h>51 //#include <usb/request.h>52 //#include <usb/descriptor.h>53 //#include <io/console.h>54 //#include <stdint.h>55 //#include <usb/dp.h>56 57 42 #include "kbddev.h" 58 43 … … 65 50 static int usbhid_add_device(ddf_dev_t *dev) 66 51 { 52 usb_log_debug("usbhid_add_device()\n"); 53 67 54 int rc = usbhid_kbd_try_add_device(dev); 68 55
Note:
See TracChangeset
for help on using the changeset viewer.