usb_generic.c (191824) | usb_generic.c (192499) |
---|---|
1/* $FreeBSD: head/sys/dev/usb/usb_generic.c 191824 2009-05-05 15:36:23Z thompsa $ */ | 1/* $FreeBSD: head/sys/dev/usb/usb_generic.c 192499 2009-05-21 00:04:17Z thompsa $ */ |
2/*- 3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. --- 218 unchanged lines hidden (view full) --- 228 usb2_config[1].callback = &ugen_write_clear_stall_callback; 229 usb2_config[1].usb_mode = USB_MODE_HOST; 230 231 usb2_config[0].type = ed->bmAttributes & UE_XFERTYPE; 232 usb2_config[0].endpoint = ed->bEndpointAddress & UE_ADDR; 233 usb2_config[0].direction = UE_DIR_TX; 234 usb2_config[0].interval = USB_DEFAULT_INTERVAL; 235 usb2_config[0].flags.proxy_buffer = 1; | 2/*- 3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. --- 218 unchanged lines hidden (view full) --- 228 usb2_config[1].callback = &ugen_write_clear_stall_callback; 229 usb2_config[1].usb_mode = USB_MODE_HOST; 230 231 usb2_config[0].type = ed->bmAttributes & UE_XFERTYPE; 232 usb2_config[0].endpoint = ed->bEndpointAddress & UE_ADDR; 233 usb2_config[0].direction = UE_DIR_TX; 234 usb2_config[0].interval = USB_DEFAULT_INTERVAL; 235 usb2_config[0].flags.proxy_buffer = 1; |
236 usb2_config[0].usb_mode = USB_MODE_MAX; /* both modes */ | 236 usb2_config[0].usb_mode = USB_MODE_DUAL; /* both modes */ |
237 238 switch (ed->bmAttributes & UE_XFERTYPE) { 239 case UE_INTERRUPT: 240 case UE_BULK: 241 if (f->flag_short) { 242 usb2_config[0].flags.force_short_xfer = 1; 243 } 244 usb2_config[0].callback = &ugen_default_write_callback; --- 51 unchanged lines hidden (view full) --- 296 usb2_config[1].callback = &ugen_read_clear_stall_callback; 297 usb2_config[1].usb_mode = USB_MODE_HOST; 298 299 usb2_config[0].type = ed->bmAttributes & UE_XFERTYPE; 300 usb2_config[0].endpoint = ed->bEndpointAddress & UE_ADDR; 301 usb2_config[0].direction = UE_DIR_RX; 302 usb2_config[0].interval = USB_DEFAULT_INTERVAL; 303 usb2_config[0].flags.proxy_buffer = 1; | 237 238 switch (ed->bmAttributes & UE_XFERTYPE) { 239 case UE_INTERRUPT: 240 case UE_BULK: 241 if (f->flag_short) { 242 usb2_config[0].flags.force_short_xfer = 1; 243 } 244 usb2_config[0].callback = &ugen_default_write_callback; --- 51 unchanged lines hidden (view full) --- 296 usb2_config[1].callback = &ugen_read_clear_stall_callback; 297 usb2_config[1].usb_mode = USB_MODE_HOST; 298 299 usb2_config[0].type = ed->bmAttributes & UE_XFERTYPE; 300 usb2_config[0].endpoint = ed->bEndpointAddress & UE_ADDR; 301 usb2_config[0].direction = UE_DIR_RX; 302 usb2_config[0].interval = USB_DEFAULT_INTERVAL; 303 usb2_config[0].flags.proxy_buffer = 1; |
304 usb2_config[0].usb_mode = USB_MODE_MAX; /* both modes */ | 304 usb2_config[0].usb_mode = USB_MODE_DUAL; /* both modes */ |
305 306 switch (ed->bmAttributes & UE_XFERTYPE) { 307 case UE_INTERRUPT: 308 case UE_BULK: 309 if (f->flag_short) { 310 usb2_config[0].flags.short_xfer_ok = 1; 311 } 312 usb2_config[0].timeout = f->timeout; --- 266 unchanged lines hidden (view full) --- 579 } 580} 581 582static int 583ugen_set_config(struct usb2_fifo *f, uint8_t index) 584{ 585 DPRINTFN(2, "index %u\n", index); 586 | 305 306 switch (ed->bmAttributes & UE_XFERTYPE) { 307 case UE_INTERRUPT: 308 case UE_BULK: 309 if (f->flag_short) { 310 usb2_config[0].flags.short_xfer_ok = 1; 311 } 312 usb2_config[0].timeout = f->timeout; --- 266 unchanged lines hidden (view full) --- 579 } 580} 581 582static int 583ugen_set_config(struct usb2_fifo *f, uint8_t index) 584{ 585 DPRINTFN(2, "index %u\n", index); 586 |
587 if (f->udev->flags.usb2_mode != USB_MODE_HOST) { | 587 if (f->udev->flags.usb_mode != USB_MODE_HOST) { |
588 /* not possible in device side mode */ 589 return (ENOTTY); 590 } 591 if (f->udev->curr_config_index == index) { 592 /* no change needed */ 593 return (0); 594 } 595 /* make sure all FIFO's are gone */ --- 14 unchanged lines hidden (view full) --- 610} 611 612static int 613ugen_set_interface(struct usb2_fifo *f, 614 uint8_t iface_index, uint8_t alt_index) 615{ 616 DPRINTFN(2, "%u, %u\n", iface_index, alt_index); 617 | 588 /* not possible in device side mode */ 589 return (ENOTTY); 590 } 591 if (f->udev->curr_config_index == index) { 592 /* no change needed */ 593 return (0); 594 } 595 /* make sure all FIFO's are gone */ --- 14 unchanged lines hidden (view full) --- 610} 611 612static int 613ugen_set_interface(struct usb2_fifo *f, 614 uint8_t iface_index, uint8_t alt_index) 615{ 616 DPRINTFN(2, "%u, %u\n", iface_index, alt_index); 617 |
618 if (f->udev->flags.usb2_mode != USB_MODE_HOST) { | 618 if (f->udev->flags.usb_mode != USB_MODE_HOST) { |
619 /* not possible in device side mode */ 620 return (ENOTTY); 621 } 622 /* make sure all FIFO's are gone */ 623 /* else there can be a deadlock */ 624 if (ugen_fs_uninit(f)) { 625 /* ignore any errors */ 626 DPRINTFN(6, "no FIFOs\n"); --- 189 unchanged lines hidden (view full) --- 816 di->udi_releaseNo = UGETW(udev->ddesc.bcdDevice); 817 di->udi_class = udev->ddesc.bDeviceClass; 818 di->udi_subclass = udev->ddesc.bDeviceSubClass; 819 di->udi_protocol = udev->ddesc.bDeviceProtocol; 820 di->udi_config_no = udev->curr_config_no; 821 di->udi_config_index = udev->curr_config_index; 822 di->udi_power = udev->flags.self_powered ? 0 : udev->power; 823 di->udi_speed = udev->speed; | 619 /* not possible in device side mode */ 620 return (ENOTTY); 621 } 622 /* make sure all FIFO's are gone */ 623 /* else there can be a deadlock */ 624 if (ugen_fs_uninit(f)) { 625 /* ignore any errors */ 626 DPRINTFN(6, "no FIFOs\n"); --- 189 unchanged lines hidden (view full) --- 816 di->udi_releaseNo = UGETW(udev->ddesc.bcdDevice); 817 di->udi_class = udev->ddesc.bDeviceClass; 818 di->udi_subclass = udev->ddesc.bDeviceSubClass; 819 di->udi_protocol = udev->ddesc.bDeviceProtocol; 820 di->udi_config_no = udev->curr_config_no; 821 di->udi_config_index = udev->curr_config_index; 822 di->udi_power = udev->flags.self_powered ? 0 : udev->power; 823 di->udi_speed = udev->speed; |
824 di->udi_mode = udev->flags.usb2_mode; | 824 di->udi_mode = udev->flags.usb_mode; |
825 di->udi_power_mode = udev->power_mode; 826 di->udi_suspended = udev->flags.peer_suspended; 827 828 hub = udev->parent_hub; 829 if (hub) { 830 di->udi_hubaddr = hub->address; 831 di->udi_hubindex = hub->device_index; 832 di->udi_hubport = udev->port_no; --- 627 unchanged lines hidden (view full) --- 1460 usb2_config[0].endpoint = ed->bEndpointAddress & UE_ADDR; 1461 usb2_config[0].direction = ed->bEndpointAddress & (UE_DIR_OUT | UE_DIR_IN); 1462 usb2_config[0].interval = USB_DEFAULT_INTERVAL; 1463 usb2_config[0].flags.proxy_buffer = 1; 1464 usb2_config[0].callback = &ugen_default_fs_callback; 1465 usb2_config[0].timeout = 0; /* no timeout */ 1466 usb2_config[0].frames = u.popen->max_frames; 1467 usb2_config[0].bufsize = u.popen->max_bufsize; | 825 di->udi_power_mode = udev->power_mode; 826 di->udi_suspended = udev->flags.peer_suspended; 827 828 hub = udev->parent_hub; 829 if (hub) { 830 di->udi_hubaddr = hub->address; 831 di->udi_hubindex = hub->device_index; 832 di->udi_hubport = udev->port_no; --- 627 unchanged lines hidden (view full) --- 1460 usb2_config[0].endpoint = ed->bEndpointAddress & UE_ADDR; 1461 usb2_config[0].direction = ed->bEndpointAddress & (UE_DIR_OUT | UE_DIR_IN); 1462 usb2_config[0].interval = USB_DEFAULT_INTERVAL; 1463 usb2_config[0].flags.proxy_buffer = 1; 1464 usb2_config[0].callback = &ugen_default_fs_callback; 1465 usb2_config[0].timeout = 0; /* no timeout */ 1466 usb2_config[0].frames = u.popen->max_frames; 1467 usb2_config[0].bufsize = u.popen->max_bufsize; |
1468 usb2_config[0].usb_mode = USB_MODE_MAX; /* both modes */ | 1468 usb2_config[0].usb_mode = USB_MODE_DUAL; /* both modes */ |
1469 1470 if (usb2_config[0].type == UE_CONTROL) { | 1469 1470 if (usb2_config[0].type == UE_CONTROL) { |
1471 if (f->udev->flags.usb2_mode != USB_MODE_HOST) { | 1471 if (f->udev->flags.usb_mode != USB_MODE_HOST) { |
1472 error = EINVAL; 1473 break; 1474 } 1475 } else { 1476 1477 isread = ((usb2_config[0].endpoint & 1478 (UE_DIR_IN | UE_DIR_OUT)) == UE_DIR_IN); 1479 | 1472 error = EINVAL; 1473 break; 1474 } 1475 } else { 1476 1477 isread = ((usb2_config[0].endpoint & 1478 (UE_DIR_IN | UE_DIR_OUT)) == UE_DIR_IN); 1479 |
1480 if (f->udev->flags.usb2_mode != USB_MODE_HOST) { | 1480 if (f->udev->flags.usb_mode != USB_MODE_HOST) { |
1481 isread = !isread; 1482 } 1483 /* check permissions */ 1484 if (isread) { 1485 if (!(fflags & FREAD)) { 1486 error = EPERM; 1487 break; 1488 } --- 36 unchanged lines hidden (view full) --- 1525 if (u.pstall->ep_index >= f->fs_ep_max) { 1526 error = EINVAL; 1527 break; 1528 } 1529 if (f->fs_xfer[u.pstall->ep_index] == NULL) { 1530 error = EINVAL; 1531 break; 1532 } | 1481 isread = !isread; 1482 } 1483 /* check permissions */ 1484 if (isread) { 1485 if (!(fflags & FREAD)) { 1486 error = EPERM; 1487 break; 1488 } --- 36 unchanged lines hidden (view full) --- 1525 if (u.pstall->ep_index >= f->fs_ep_max) { 1526 error = EINVAL; 1527 break; 1528 } 1529 if (f->fs_xfer[u.pstall->ep_index] == NULL) { 1530 error = EINVAL; 1531 break; 1532 } |
1533 if (f->udev->flags.usb2_mode != USB_MODE_HOST) { | 1533 if (f->udev->flags.usb_mode != USB_MODE_HOST) { |
1534 error = EINVAL; 1535 break; 1536 } 1537 mtx_lock(f->priv_mtx); 1538 error = usb2_transfer_pending(f->fs_xfer[u.pstall->ep_index]); 1539 mtx_unlock(f->priv_mtx); 1540 1541 if (error) { --- 645 unchanged lines hidden --- | 1534 error = EINVAL; 1535 break; 1536 } 1537 mtx_lock(f->priv_mtx); 1538 error = usb2_transfer_pending(f->fs_xfer[u.pstall->ep_index]); 1539 mtx_unlock(f->priv_mtx); 1540 1541 if (error) { --- 645 unchanged lines hidden --- |