Changeset a6567ed in mainline
- Timestamp:
- 2011-03-02T18:54:49Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 820aba32
- Parents:
- d70e0a3c
- Location:
- uspace/drv/usbmouse
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbmouse/init.c
rd70e0a3c ra6567ed 36 36 #include "mouse.h" 37 37 #include <usb/debug.h> 38 #include <usb/classes/classes.h> 38 39 #include <usb/classes/hid.h> 39 40 #include <usb/request.h> 40 41 #include <errno.h> 41 42 42 #if 043 43 /** Mouse polling endpoint description for boot protocol subclass. */ 44 44 static usb_endpoint_description_t poll_endpoint_description = { … … 50 50 .flags = 0 51 51 }; 52 #endif 52 53 /** Initialize poll pipe. 54 * 55 * Expects that session is already started on control pipe zero. 56 * 57 * @param mouse Mouse device. 58 * @param my_interface Interface number. 59 * @return Error code. 60 */ 61 static int intialize_poll_pipe(usb_mouse_t *mouse, int my_interface) 62 { 63 assert(usb_endpoint_pipe_is_session_started(&mouse->ctrl_pipe)); 64 65 int rc; 66 67 void *config_descriptor; 68 size_t config_descriptor_size; 69 70 rc = usb_request_get_full_configuration_descriptor_alloc( 71 &mouse->ctrl_pipe, 0, &config_descriptor, &config_descriptor_size); 72 if (rc != EOK) { 73 return rc; 74 } 75 76 usb_endpoint_mapping_t endpoint_mapping[1] = { 77 { 78 .pipe = &mouse->poll_pipe, 79 .description = &poll_endpoint_description, 80 .interface_no = my_interface 81 } 82 }; 83 84 rc = usb_endpoint_pipe_initialize_from_configuration(endpoint_mapping, 85 1, config_descriptor, config_descriptor_size, &mouse->wire); 86 if (rc != EOK) { 87 return rc; 88 } 89 90 if (!endpoint_mapping[0].present) { 91 return ENOENT; 92 } 93 94 return EOK; 95 } 53 96 54 97 … … 76 119 } 77 120 78 /* FIXME: initialize to the proper endpoint. */ 79 rc = usb_endpoint_pipe_initialize(&mouse->poll_pipe, &mouse->wire, 80 1, USB_TRANSFER_INTERRUPT, 8, USB_DIRECTION_IN); 121 rc = usb_endpoint_pipe_start_session(&mouse->ctrl_pipe); 122 if (rc != EOK) { 123 goto leave; 124 } 125 126 rc = intialize_poll_pipe(mouse, usb_device_get_assigned_interface(dev)); 127 128 /* We can ignore error here. */ 129 usb_endpoint_pipe_end_session(&mouse->ctrl_pipe); 130 81 131 if (rc != EOK) { 82 132 goto leave; -
uspace/drv/usbmouse/mouse.c
rd70e0a3c ra6567ed 46 46 assert(mouse); 47 47 48 size_t buffer_size = mouse->poll_pipe.max_packet_size; 49 50 if (buffer_size < 4) { 51 usb_log_error("Weird mouse, results will be skewed.\n"); 52 buffer_size = 4; 53 } 54 55 uint8_t *buffer = malloc(buffer_size); 56 if (buffer == NULL) { 57 usb_log_error("Out of memory, poll fibril aborted.\n"); 58 return ENOMEM; 59 } 60 48 61 while (true) { 49 62 async_usleep(10 * 1000); 50 63 51 uint8_t buffer[8];52 64 size_t actual_size; 53 65 … … 55 67 usb_endpoint_pipe_start_session(&mouse->poll_pipe); 56 68 57 usb_endpoint_pipe_read(&mouse->poll_pipe, buffer, 8, &actual_size); 69 usb_endpoint_pipe_read(&mouse->poll_pipe, 70 buffer, buffer_size, &actual_size); 58 71 59 72 usb_endpoint_pipe_end_session(&mouse->poll_pipe);
Note:
See TracChangeset
for help on using the changeset viewer.