Changeset 0475e13 in mainline
- Timestamp:
- 2011-02-25T10:40:14Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3a1aa20
- Parents:
- 54e682f
- Location:
- uspace
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/main.c
r54e682f r0475e13 162 162 static int active_layout = 0; 163 163 164 static void usbkbd_req_set_report(usb_hid_dev_kbd_t *kbd_dev, uint 8_t *buffer,165 size_t buf_size)164 static void usbkbd_req_set_report(usb_hid_dev_kbd_t *kbd_dev, uint16_t iface, 165 usb_hid_report_type_t type, uint8_t *buffer, size_t buf_size) 166 166 { 167 167 int rc, sess_rc; … … 175 175 176 176 usb_log_debug("Sending Set_Report request to the device.\n"); 177 // TODO: determine what interface to use!! (now set to 1)177 178 178 rc = usb_control_request_set(&kbd_dev->ctrl_pipe, 179 179 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, 180 USB_HIDREQ_SET_REPORT, USB_HID_REPORT_TYPE_OUTPUT, 181 1, buffer, buf_size); 180 USB_HIDREQ_SET_REPORT, type, iface, buffer, buf_size); 181 182 sess_rc = usb_endpoint_pipe_end_session(&kbd_dev->ctrl_pipe); 183 184 if (rc != EOK) { 185 usb_log_warning("Error sending output report to the keyboard: " 186 "%s.\n", str_error(rc)); 187 return; 188 } 189 190 if (sess_rc != EOK) { 191 usb_log_warning("Error closing session: %s.\n", 192 str_error(sess_rc)); 193 return; 194 } 195 } 196 197 static void usbkbd_req_set_protocol(usb_hid_dev_kbd_t *kbd_dev, uint16_t iface, 198 usb_hid_protocol_t protocol) 199 { 200 int rc, sess_rc; 201 202 sess_rc = usb_endpoint_pipe_start_session(&kbd_dev->ctrl_pipe); 203 if (sess_rc != EOK) { 204 usb_log_warning("Failed to start a session: %s.\n", 205 str_error(sess_rc)); 206 return; 207 } 208 209 usb_log_debug("Sending Set_Protocol request to the device.\n"); 210 211 rc = usb_control_request_set(&kbd_dev->ctrl_pipe, 212 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, 213 USB_HIDREQ_SET_PROTOCOL, protocol, iface, NULL, 0); 182 214 183 215 sess_rc = usb_endpoint_pipe_end_session(&kbd_dev->ctrl_pipe); … … 225 257 } 226 258 227 usbkbd_req_set_report(kbd_dev, buffer, BUFFER_SIZE); 259 // TODO: determine what interface to use!! (now set to 1) 260 usbkbd_req_set_report(kbd_dev, 1, USB_HID_REPORT_TYPE_OUTPUT, buffer, 261 BUFFER_SIZE); 228 262 } 229 263 … … 565 599 } 566 600 567 568 569 570 601 kbd_dev->conf = (usb_hid_configuration_t *)calloc(1, 571 602 sizeof(usb_hid_configuration_t)); … … 671 702 usb_endpoint_pipe_end_session(&kbd_dev->ctrl_pipe); 672 703 704 // set boot protocol 705 usbkbd_req_set_protocol(kbd_dev, 1, USB_HID_PROTOCOL_BOOT); 706 673 707 return kbd_dev; 674 708 … … 760 794 return -1; 761 795 } 762 763 ddf_dev_t *dev = (ddf_dev_t *)arg; 764 765 // initialize device (get and process descriptors, get address, etc.) 796 797 usb_hid_dev_kbd_t *kbd_dev = (usb_hid_dev_kbd_t *)arg; 798 799 usbkbd_poll_keyboard(kbd_dev); 800 801 return EOK; 802 } 803 804 static int usbkbd_add_device(ddf_dev_t *dev) 805 { 806 /* 807 * Create default function. 808 */ 809 // FIXME - check for errors 810 ddf_fun_t *kbd_fun = ddf_fun_create(dev, fun_exposed, "keyboard"); 811 assert(kbd_fun != NULL); 812 kbd_fun->ops = &keyboard_ops; 813 814 int rc = ddf_fun_bind(kbd_fun); 815 assert(rc == EOK); 816 rc = ddf_fun_add_to_class(kbd_fun, "keyboard"); 817 assert(rc == EOK); 818 819 /* 820 * Initialize device (get and process descriptors, get address, etc.) 821 */ 766 822 usb_hid_dev_kbd_t *kbd_dev = usbkbd_init_device(dev); 767 823 if (kbd_dev == NULL) { … … 770 826 } 771 827 772 usbkbd_poll_keyboard(kbd_dev);773 774 return EOK;775 }776 777 static int usbkbd_add_device(ddf_dev_t *dev)778 {779 /* For now, fail immediately. */780 //return ENOTSUP;781 782 /*783 * When everything is okay, connect to "our" HC.784 *785 * Not supported yet, skip..786 */787 // int phone = usb_drv_hc_connect_auto(dev, 0);788 // if (phone < 0) {789 // /*790 // * Connecting to HC failed, roll-back and announce791 // * failure.792 // */793 // return phone;794 // }795 796 // dev->parent_phone = phone;797 798 /*799 * Create default function.800 */801 // FIXME - check for errors802 ddf_fun_t *kbd_fun = ddf_fun_create(dev, fun_exposed, "keyboard");803 assert(kbd_fun != NULL);804 kbd_fun->ops = &keyboard_ops;805 806 int rc = ddf_fun_bind(kbd_fun);807 assert(rc == EOK);808 rc = ddf_fun_add_to_class(kbd_fun, "keyboard");809 assert(rc == EOK);810 811 828 /* 812 829 * Create new fibril for handling this keyboard 813 830 */ 814 fid_t fid = fibril_create(usbkbd_fibril_device, dev);831 fid_t fid = fibril_create(usbkbd_fibril_device, kbd_dev); 815 832 if (fid == 0) { 816 833 usb_log_error("Failed to start fibril for HID device\n"); -
uspace/lib/usb/include/usb/classes/hid.h
r54e682f r0475e13 57 57 } usb_hid_report_type_t; 58 58 59 typedef enum { 60 USB_HID_PROTOCOL_BOOT = 0, 61 USB_HID_PROTOCOL_REPORT = 1 62 } usb_hid_protocol_t; 63 59 64 /** USB/HID subclass constants. */ 60 65 typedef enum { … … 68 73 USB_HID_PROTOCOL_KEYBOARD = 1, 69 74 USB_HID_PROTOCOL_MOUSE = 2 70 } usb_hid_ protocol_t;75 } usb_hid_iface_protocol_t; 71 76 72 77 /** Part of standard USB HID descriptor specifying one class descriptor.
Note:
See TracChangeset
for help on using the changeset viewer.