usb_generic.c (217265) | usb_generic.c (219100) |
---|---|
1/* $FreeBSD: head/sys/dev/usb/usb_generic.c 217265 2011-01-11 13:59:06Z jhb $ */ | 1/* $FreeBSD: head/sys/dev/usb/usb_generic.c 219100 2011-02-28 17:23:15Z hselasky $ */ |
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. --- 1382 unchanged lines hidden (view full) --- 1392 void *addr; 1393 } u; 1394 struct usb_endpoint *ep; 1395 struct usb_endpoint_descriptor *ed; 1396 int error = 0; 1397 uint8_t iface_index; 1398 uint8_t isread; 1399 uint8_t ep_index; | 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. --- 1382 unchanged lines hidden (view full) --- 1392 void *addr; 1393 } u; 1394 struct usb_endpoint *ep; 1395 struct usb_endpoint_descriptor *ed; 1396 int error = 0; 1397 uint8_t iface_index; 1398 uint8_t isread; 1399 uint8_t ep_index; |
1400 uint8_t pre_scale; |
|
1400 1401 u.addr = addr; 1402 1403 DPRINTFN(6, "cmd=0x%08lx\n", cmd); 1404 1405 switch (cmd) { 1406 case USB_FS_COMPLETE: 1407 mtx_lock(f->priv_mtx); --- 35 unchanged lines hidden (view full) --- 1443 } 1444 if (f->fs_xfer[u.popen->ep_index] != NULL) { 1445 error = EBUSY; 1446 break; 1447 } 1448 if (u.popen->max_bufsize > USB_FS_MAX_BUFSIZE) { 1449 u.popen->max_bufsize = USB_FS_MAX_BUFSIZE; 1450 } | 1401 1402 u.addr = addr; 1403 1404 DPRINTFN(6, "cmd=0x%08lx\n", cmd); 1405 1406 switch (cmd) { 1407 case USB_FS_COMPLETE: 1408 mtx_lock(f->priv_mtx); --- 35 unchanged lines hidden (view full) --- 1444 } 1445 if (f->fs_xfer[u.popen->ep_index] != NULL) { 1446 error = EBUSY; 1447 break; 1448 } 1449 if (u.popen->max_bufsize > USB_FS_MAX_BUFSIZE) { 1450 u.popen->max_bufsize = USB_FS_MAX_BUFSIZE; 1451 } |
1452 if (u.popen->max_frames & USB_FS_MAX_FRAMES_PRE_SCALE) { 1453 pre_scale = 1; 1454 u.popen->max_frames &= ~USB_FS_MAX_FRAMES_PRE_SCALE; 1455 } else { 1456 pre_scale = 0; 1457 } |
|
1451 if (u.popen->max_frames > USB_FS_MAX_FRAMES) { 1452 u.popen->max_frames = USB_FS_MAX_FRAMES; 1453 break; 1454 } 1455 if (u.popen->max_frames == 0) { 1456 error = EINVAL; 1457 break; 1458 } --- 4 unchanged lines hidden (view full) --- 1463 } 1464 ed = ep->edesc; 1465 if (ed == NULL) { 1466 error = ENXIO; 1467 break; 1468 } 1469 iface_index = ep->iface_index; 1470 | 1458 if (u.popen->max_frames > USB_FS_MAX_FRAMES) { 1459 u.popen->max_frames = USB_FS_MAX_FRAMES; 1460 break; 1461 } 1462 if (u.popen->max_frames == 0) { 1463 error = EINVAL; 1464 break; 1465 } --- 4 unchanged lines hidden (view full) --- 1470 } 1471 ed = ep->edesc; 1472 if (ed == NULL) { 1473 error = ENXIO; 1474 break; 1475 } 1476 iface_index = ep->iface_index; 1477 |
1471 bzero(usb_config, sizeof(usb_config)); | 1478 memset(usb_config, 0, sizeof(usb_config)); |
1472 1473 usb_config[0].type = ed->bmAttributes & UE_XFERTYPE; 1474 usb_config[0].endpoint = ed->bEndpointAddress & UE_ADDR; 1475 usb_config[0].direction = ed->bEndpointAddress & (UE_DIR_OUT | UE_DIR_IN); 1476 usb_config[0].interval = USB_DEFAULT_INTERVAL; 1477 usb_config[0].flags.proxy_buffer = 1; | 1479 1480 usb_config[0].type = ed->bmAttributes & UE_XFERTYPE; 1481 usb_config[0].endpoint = ed->bEndpointAddress & UE_ADDR; 1482 usb_config[0].direction = ed->bEndpointAddress & (UE_DIR_OUT | UE_DIR_IN); 1483 usb_config[0].interval = USB_DEFAULT_INTERVAL; 1484 usb_config[0].flags.proxy_buffer = 1; |
1485 if (pre_scale != 0) 1486 usb_config[0].flags.pre_scale_frames = 1; |
|
1478 usb_config[0].callback = &ugen_ctrl_fs_callback; 1479 usb_config[0].timeout = 0; /* no timeout */ 1480 usb_config[0].frames = u.popen->max_frames; 1481 usb_config[0].bufsize = u.popen->max_bufsize; 1482 usb_config[0].usb_mode = USB_MODE_DUAL; /* both modes */ 1483 1484 if (usb_config[0].type == UE_CONTROL) { 1485 if (f->udev->flags.usb_mode != USB_MODE_HOST) { --- 25 unchanged lines hidden (view full) --- 1511 f->fs_xfer + u.popen->ep_index, usb_config, 1, 1512 f, f->priv_mtx); 1513 if (error == 0) { 1514 /* update maximums */ 1515 u.popen->max_packet_length = 1516 f->fs_xfer[u.popen->ep_index]->max_frame_size; 1517 u.popen->max_bufsize = 1518 f->fs_xfer[u.popen->ep_index]->max_data_length; | 1487 usb_config[0].callback = &ugen_ctrl_fs_callback; 1488 usb_config[0].timeout = 0; /* no timeout */ 1489 usb_config[0].frames = u.popen->max_frames; 1490 usb_config[0].bufsize = u.popen->max_bufsize; 1491 usb_config[0].usb_mode = USB_MODE_DUAL; /* both modes */ 1492 1493 if (usb_config[0].type == UE_CONTROL) { 1494 if (f->udev->flags.usb_mode != USB_MODE_HOST) { --- 25 unchanged lines hidden (view full) --- 1520 f->fs_xfer + u.popen->ep_index, usb_config, 1, 1521 f, f->priv_mtx); 1522 if (error == 0) { 1523 /* update maximums */ 1524 u.popen->max_packet_length = 1525 f->fs_xfer[u.popen->ep_index]->max_frame_size; 1526 u.popen->max_bufsize = 1527 f->fs_xfer[u.popen->ep_index]->max_data_length; |
1528 /* update number of frames */ 1529 u.popen->max_frames = 1530 f->fs_xfer[u.popen->ep_index]->nframes; 1531 /* store index of endpoint */ |
|
1519 f->fs_xfer[u.popen->ep_index]->priv_fifo = 1520 ((uint8_t *)0) + u.popen->ep_index; 1521 } else { 1522 error = ENOMEM; 1523 } 1524 break; 1525 1526 case USB_FS_CLOSE: --- 710 unchanged lines hidden --- | 1532 f->fs_xfer[u.popen->ep_index]->priv_fifo = 1533 ((uint8_t *)0) + u.popen->ep_index; 1534 } else { 1535 error = ENOMEM; 1536 } 1537 break; 1538 1539 case USB_FS_CLOSE: --- 710 unchanged lines hidden --- |