Changes in uspace/drv/usbhid/main.c [2899980:0484d92] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/main.c
r2899980 r0484d92 47 47 #include <usb/classes/hid.h> 48 48 #include <usb/classes/hidparser.h> 49 #include <usb/ devreq.h>49 #include <usb/request.h> 50 50 #include <usb/descriptor.h> 51 51 #include <io/console.h> … … 56 56 #include "layout.h" 57 57 58 #define BUFFER_SIZE 858 #define BUFFER_SIZE 32 59 59 #define NAME "usbhid" 60 60 … … 262 262 } 263 263 264 # if 0265 264 /* 266 265 * Kbd functions … … 281 280 282 281 // get the descriptor from the device 283 int rc = usb_drv_req_get_descriptor(kbd_dev->device->parent_phone, 284 kbd_dev->address, USB_REQUEST_TYPE_CLASS, USB_DESCTYPE_HID_REPORT, 285 0, i, kbd_dev->conf->interfaces[i].report_desc, length, 282 int rc = usb_request_get_descriptor(&kbd_dev->ctrl_pipe, 283 USB_REQUEST_TYPE_CLASS, USB_DESCTYPE_HID_REPORT, 284 i, 0, 285 kbd_dev->conf->interfaces[i].report_desc, length, 286 286 &actual_size); 287 287 … … 298 298 return EOK; 299 299 } 300 300 301 static int usbkbd_process_descriptors(usb_hid_dev_kbd_t *kbd_dev) 301 302 { … … 303 304 usb_standard_configuration_descriptor_t config_desc; 304 305 305 int rc = usb_drv_req_get_bare_configuration_descriptor( 306 kbd_dev->device->parent_phone, kbd_dev->address, 0, &config_desc); 306 int rc; 307 rc = usb_request_get_bare_configuration_descriptor(&kbd_dev->ctrl_pipe, 308 0, &config_desc); 307 309 308 310 if (rc != EOK) { … … 318 320 size_t transferred = 0; 319 321 // get full configuration descriptor 320 rc = usb_ drv_req_get_full_configuration_descriptor(321 kbd_dev->device->parent_phone, kbd_dev->address,0, descriptors,322 rc = usb_request_get_full_configuration_descriptor(&kbd_dev->ctrl_pipe, 323 0, descriptors, 322 324 config_desc.total_length, &transferred); 323 325 … … 363 365 return EOK; 364 366 } 365 #endif 367 366 368 static usb_hid_dev_kbd_t *usbkbd_init_device(device_t *dev) 367 369 { 370 int rc; 371 368 372 usb_hid_dev_kbd_t *kbd_dev = (usb_hid_dev_kbd_t *)calloc(1, 369 373 sizeof(usb_hid_dev_kbd_t)); … … 376 380 kbd_dev->device = dev; 377 381 378 // get phone to my HC and save it as my parent's phone379 // TODO: maybe not a good idea if DDF will use parent_phone380 int rc = kbd_dev->device->parent_phone = usb_drv_hc_connect_auto(dev, 0);381 if (rc < 0) {382 printf("Problem setting phone to HC.\n");383 goto error_leave;384 }385 386 rc = kbd_dev->address = usb_drv_get_my_address(dev->parent_phone, dev);387 if (rc < 0) {388 printf("Problem getting address of the device.\n");389 goto error_leave;390 }391 392 // doesn't matter now that we have no address393 // if (kbd_dev->address < 0) {394 // fprintf(stderr, NAME ": No device address!\n");395 // free(kbd_dev);396 // return NULL;397 // }398 399 /*400 * will need all descriptors:401 * 1) choose one configuration from configuration descriptors402 * (set it to the device)403 * 2) set endpoints from endpoint descriptors404 */405 406 407 // TODO: get descriptors, parse descriptors and save endpoints408 //usbkbd_process_descriptors(kbd_dev);409 usb_drv_req_set_configuration(410 kbd_dev->device->parent_phone, kbd_dev->address, 1);411 412 413 414 382 /* 415 383 * Initialize the backing connection to the host controller. … … 425 393 * Initialize device pipes. 426 394 */ 395 rc = usb_endpoint_pipe_initialize_default_control(&kbd_dev->ctrl_pipe, 396 &kbd_dev->wire); 397 if (rc != EOK) { 398 printf("Failed to initialize default control pipe: %s.\n", 399 str_error(rc)); 400 goto error_leave; 401 } 402 427 403 rc = usb_endpoint_pipe_initialize(&kbd_dev->poll_pipe, &kbd_dev->wire, 428 404 GUESSED_POLL_ENDPOINT, USB_TRANSFER_INTERRUPT, USB_DIRECTION_IN); … … 433 409 } 434 410 411 /* 412 * will need all descriptors: 413 * 1) choose one configuration from configuration descriptors 414 * (set it to the device) 415 * 2) set endpoints from endpoint descriptors 416 */ 417 418 // TODO: get descriptors, parse descriptors and save endpoints 419 usb_endpoint_pipe_start_session(&kbd_dev->ctrl_pipe); 420 usbkbd_process_descriptors(kbd_dev); 421 usb_endpoint_pipe_end_session(&kbd_dev->ctrl_pipe); 435 422 436 423 return kbd_dev; … … 470 457 471 458 while (true) { 472 async_usleep(1000 * 10 );459 async_usleep(1000 * 1000 * 2); 473 460 474 461 sess_rc = usb_endpoint_pipe_start_session(&kbd_dev->poll_pipe);
Note:
See TracChangeset
for help on using the changeset viewer.