Lines Matching refs:u
700 struct usbin *u = &as->usbin; in usbin_stop() local
705 u->flags &= ~FLG_RUNNING; in usbin_stop()
706 i = u->flags; in usbin_stop()
712 i = u->flags; in usbin_stop()
716 usb_unlink_urb(&u->durb[0].urb); in usbin_stop()
718 usb_unlink_urb(&u->durb[1].urb); in usbin_stop()
720 usb_unlink_urb(&u->surb[0].urb); in usbin_stop()
722 usb_unlink_urb(&u->surb[1].urb); in usbin_stop()
727 if (u->durb[0].urb.transfer_buffer) in usbin_stop()
728 kfree(u->durb[0].urb.transfer_buffer); in usbin_stop()
729 if (u->durb[1].urb.transfer_buffer) in usbin_stop()
730 kfree(u->durb[1].urb.transfer_buffer); in usbin_stop()
731 if (u->surb[0].urb.transfer_buffer) in usbin_stop()
732 kfree(u->surb[0].urb.transfer_buffer); in usbin_stop()
733 if (u->surb[1].urb.transfer_buffer) in usbin_stop()
734 kfree(u->surb[1].urb.transfer_buffer); in usbin_stop()
735 u->durb[0].urb.transfer_buffer = u->durb[1].urb.transfer_buffer = in usbin_stop()
736 u->surb[0].urb.transfer_buffer = u->surb[1].urb.transfer_buffer = NULL; in usbin_stop()
746 struct usbin *u = &as->usbin; in usbin_disc() local
751 u->flags &= ~(FLG_RUNNING | FLG_CONNECTED); in usbin_disc()
902 static void usbin_convert(struct usbin *u, unsigned char *buffer, unsigned int samples) in usbin_convert() argument
905 unsigned int ufmtb = AFMT_SAMPLEBYTES(u->format); in usbin_convert()
906 unsigned int dfmtb = AFMT_SAMPLEBYTES(u->dma.format); in usbin_convert()
915 conversion(buffer, u->format, tmp, u->dma.format, scnt); in usbin_convert()
916 dmabuf_copyin(&u->dma, tmp, scnt * dfmtb); in usbin_convert()
922 static int usbin_prepare_desc(struct usbin *u, struct urb *urb) in usbin_prepare_desc() argument
926 maxsize = ((u->freqmax + 0x3fff) * AFMT_SAMPLEBYTES(u->format)) >> 14; in usbin_prepare_desc()
939 static int usbin_retire_desc(struct usbin *u, struct urb *urb) in usbin_retire_desc() argument
944 ufmtb = AFMT_SAMPLEBYTES(u->format); in usbin_retire_desc()
945 dfmtb = AFMT_SAMPLEBYTES(u->dma.format); in usbin_retire_desc()
956 if (!u->dma.mapped) { in usbin_retire_desc()
957 dmafree = u->dma.dmasize - u->dma.count; in usbin_retire_desc()
964 u->dma.count += cnt; in usbin_retire_desc()
965 if (u->format == u->dma.format) { in usbin_retire_desc()
968 dmabuf_copyin(&u->dma, cp, cnt); in usbin_retire_desc()
971 dprintk((KERN_DEBUG "usbaudio: sample format conversion %x != %x\n", u->format, u->dma.format)); in usbin_retire_desc()
972 usbin_convert(u, cp, scnt); in usbin_retire_desc()
976 u->dma.error++; in usbin_retire_desc()
977 if (u->dma.count >= (signed)u->dma.fragsize) in usbin_retire_desc()
978 wake_up(&u->dma.wait); in usbin_retire_desc()
985 struct usbin *u = &as->usbin; in usbin_completed() local
991 …EBUG "usbin_completed: status %d errcnt %d flags 0x%x\n", urb->status, urb->error_count, u->flags); in usbin_completed()
993 if (urb == &u->durb[0].urb) in usbin_completed()
995 else if (urb == &u->durb[1].urb) in usbin_completed()
1003 if (!usbin_retire_desc(u, urb) && in usbin_completed()
1004 u->flags & FLG_RUNNING && in usbin_completed()
1005 !usbin_prepare_desc(u, urb) && in usbin_completed()
1007 u->flags |= mask; in usbin_completed()
1009 u->flags &= ~(mask | FLG_RUNNING); in usbin_completed()
1010 wake_up(&u->dma.wait); in usbin_completed()
1019 static int usbin_sync_prepare_desc(struct usbin *u, struct urb *urb) in usbin_sync_prepare_desc() argument
1027 cp[0] = u->freqn; in usbin_sync_prepare_desc()
1028 cp[1] = u->freqn >> 8; in usbin_sync_prepare_desc()
1029 cp[2] = u->freqn >> 16; in usbin_sync_prepare_desc()
1037 static int usbin_sync_retire_desc(struct usbin *u, struct urb *urb) in usbin_sync_retire_desc() argument
1050 struct usbin *u = &as->usbin; in usbin_sync_completed() local
1056 …"usbin_sync_completed: status %d errcnt %d flags 0x%x\n", urb->status, urb->error_count, u->flags); in usbin_sync_completed()
1058 if (urb == &u->surb[0].urb) in usbin_sync_completed()
1060 else if (urb == &u->surb[1].urb) in usbin_sync_completed()
1068 if (!usbin_sync_retire_desc(u, urb) && in usbin_sync_completed()
1069 u->flags & FLG_RUNNING && in usbin_sync_completed()
1070 !usbin_sync_prepare_desc(u, urb) && in usbin_sync_completed()
1072 u->flags |= mask; in usbin_sync_completed()
1074 u->flags &= ~(mask | FLG_RUNNING); in usbin_sync_completed()
1075 wake_up(&u->dma.wait); in usbin_sync_completed()
1084 struct usbin *u = &as->usbin; in usbin_start() local
1091 dev->devnum, u->format, u->dma.format, u->dma.srate); in usbin_start()
1095 if (!(u->flags & FLG_CONNECTED)) { in usbin_start()
1099 if (!(u->flags & FLG_RUNNING)) { in usbin_start()
1101 u->freqn = ((u->dma.srate << 11) + 62) / 125; /* this will overflow at approx 2MSPS */ in usbin_start()
1102 u->freqmax = u->freqn + (u->freqn >> 2); in usbin_start()
1103 u->phase = 0; in usbin_start()
1104 maxsze = ((u->freqmax + 0x3fff) * AFMT_SAMPLEBYTES(u->format)) >> 14; in usbin_start()
1106 if (u->durb[0].urb.transfer_buffer) in usbin_start()
1107 kfree(u->durb[0].urb.transfer_buffer); in usbin_start()
1108 u->durb[0].urb.transfer_buffer = kmalloc(bufsz, GFP_KERNEL); in usbin_start()
1109 u->durb[0].urb.transfer_buffer_length = bufsz; in usbin_start()
1110 if (u->durb[1].urb.transfer_buffer) in usbin_start()
1111 kfree(u->durb[1].urb.transfer_buffer); in usbin_start()
1112 u->durb[1].urb.transfer_buffer = kmalloc(bufsz, GFP_KERNEL); in usbin_start()
1113 u->durb[1].urb.transfer_buffer_length = bufsz; in usbin_start()
1114 if (u->syncpipe) { in usbin_start()
1115 if (u->surb[0].urb.transfer_buffer) in usbin_start()
1116 kfree(u->surb[0].urb.transfer_buffer); in usbin_start()
1117 u->surb[0].urb.transfer_buffer = kmalloc(3*SYNCFRAMES, GFP_KERNEL); in usbin_start()
1118 u->surb[0].urb.transfer_buffer_length = 3*SYNCFRAMES; in usbin_start()
1119 if (u->surb[1].urb.transfer_buffer) in usbin_start()
1120 kfree(u->surb[1].urb.transfer_buffer); in usbin_start()
1121 u->surb[1].urb.transfer_buffer = kmalloc(3*SYNCFRAMES, GFP_KERNEL); in usbin_start()
1122 u->surb[1].urb.transfer_buffer_length = 3*SYNCFRAMES; in usbin_start()
1124 if (!u->durb[0].urb.transfer_buffer || !u->durb[1].urb.transfer_buffer || in usbin_start()
1125 (u->syncpipe && (!u->surb[0].urb.transfer_buffer || !u->surb[1].urb.transfer_buffer))) { in usbin_start()
1131 if (u->dma.count >= u->dma.dmasize && !u->dma.mapped) { in usbin_start()
1135 u->flags |= FLG_RUNNING; in usbin_start()
1136 if (!(u->flags & FLG_URB0RUNNING)) { in usbin_start()
1137 urb = &u->durb[0].urb; in usbin_start()
1139 urb->pipe = u->datapipe; in usbin_start()
1144 if (!usbin_prepare_desc(u, urb) && !usb_submit_urb(urb)) in usbin_start()
1145 u->flags |= FLG_URB0RUNNING; in usbin_start()
1147 u->flags &= ~FLG_RUNNING; in usbin_start()
1149 if (u->flags & FLG_RUNNING && !(u->flags & FLG_URB1RUNNING)) { in usbin_start()
1150 urb = &u->durb[1].urb; in usbin_start()
1152 urb->pipe = u->datapipe; in usbin_start()
1157 if (!usbin_prepare_desc(u, urb) && !usb_submit_urb(urb)) in usbin_start()
1158 u->flags |= FLG_URB1RUNNING; in usbin_start()
1160 u->flags &= ~FLG_RUNNING; in usbin_start()
1162 if (u->syncpipe) { in usbin_start()
1163 if (u->flags & FLG_RUNNING && !(u->flags & FLG_SYNC0RUNNING)) { in usbin_start()
1164 urb = &u->surb[0].urb; in usbin_start()
1166 urb->pipe = u->syncpipe; in usbin_start()
1172 if (!usbin_sync_prepare_desc(u, urb) && !usb_submit_urb(urb)) in usbin_start()
1173 u->flags |= FLG_SYNC0RUNNING; in usbin_start()
1175 u->flags &= ~FLG_RUNNING; in usbin_start()
1177 if (u->flags & FLG_RUNNING && !(u->flags & FLG_SYNC1RUNNING)) { in usbin_start()
1178 urb = &u->surb[1].urb; in usbin_start()
1180 urb->pipe = u->syncpipe; in usbin_start()
1186 if (!usbin_sync_prepare_desc(u, urb) && !usb_submit_urb(urb)) in usbin_start()
1187 u->flags |= FLG_SYNC1RUNNING; in usbin_start()
1189 u->flags &= ~FLG_RUNNING; in usbin_start()
1198 struct usbout *u = &as->usbout; in usbout_stop() local
1203 u->flags &= ~FLG_RUNNING; in usbout_stop()
1204 i = u->flags; in usbout_stop()
1210 i = u->flags; in usbout_stop()
1214 usb_unlink_urb(&u->durb[0].urb); in usbout_stop()
1216 usb_unlink_urb(&u->durb[1].urb); in usbout_stop()
1218 usb_unlink_urb(&u->surb[0].urb); in usbout_stop()
1220 usb_unlink_urb(&u->surb[1].urb); in usbout_stop()
1225 if (u->durb[0].urb.transfer_buffer) in usbout_stop()
1226 kfree(u->durb[0].urb.transfer_buffer); in usbout_stop()
1227 if (u->durb[1].urb.transfer_buffer) in usbout_stop()
1228 kfree(u->durb[1].urb.transfer_buffer); in usbout_stop()
1229 if (u->surb[0].urb.transfer_buffer) in usbout_stop()
1230 kfree(u->surb[0].urb.transfer_buffer); in usbout_stop()
1231 if (u->surb[1].urb.transfer_buffer) in usbout_stop()
1232 kfree(u->surb[1].urb.transfer_buffer); in usbout_stop()
1233 u->durb[0].urb.transfer_buffer = u->durb[1].urb.transfer_buffer = in usbout_stop()
1234 u->surb[0].urb.transfer_buffer = u->surb[1].urb.transfer_buffer = NULL; in usbout_stop()
1244 struct usbout *u = &as->usbout; in usbout_disc() local
1248 u->flags &= ~(FLG_RUNNING | FLG_CONNECTED); in usbout_disc()
1253 static void usbout_convert(struct usbout *u, unsigned char *buffer, unsigned int samples) in usbout_convert() argument
1257 unsigned int ufmtb = AFMT_SAMPLEBYTES(u->format); in usbout_convert()
1258 unsigned int dfmtb = AFMT_SAMPLEBYTES(u->dma.format); in usbout_convert()
1266 dmabuf_copyout(&u->dma, tmp, scnt * dfmtb); in usbout_convert()
1267 conversion(tmp, u->dma.format, buffer, u->format, scnt); in usbout_convert()
1273 static int usbout_prepare_desc(struct usbout *u, struct urb *urb) in usbout_prepare_desc() argument
1278 ufmtb = AFMT_SAMPLEBYTES(u->format); in usbout_prepare_desc()
1279 dfmtb = AFMT_SAMPLEBYTES(u->dma.format); in usbout_prepare_desc()
1282 u->phase = (u->phase & 0x3fff) + u->freqm; in usbout_prepare_desc()
1283 scnt = u->phase >> 14; in usbout_prepare_desc()
1289 if (!u->dma.mapped) { in usbout_prepare_desc()
1290 if (cnt > u->dma.count) { in usbout_prepare_desc()
1291 scnt = u->dma.count / dfmtb; in usbout_prepare_desc()
1295 u->dma.count -= cnt; in usbout_prepare_desc()
1297 u->dma.count += cnt; in usbout_prepare_desc()
1298 if (u->format == u->dma.format) { in usbout_prepare_desc()
1300 dmabuf_copyout(&u->dma, cp, cnt); in usbout_prepare_desc()
1303 usbout_convert(u, cp, scnt); in usbout_prepare_desc()
1311 u->dma.error++; in usbout_prepare_desc()
1312 if (u->dma.mapped) { in usbout_prepare_desc()
1313 if (u->dma.count >= (signed)u->dma.fragsize) in usbout_prepare_desc()
1314 wake_up(&u->dma.wait); in usbout_prepare_desc()
1316 if ((signed)u->dma.dmasize >= u->dma.count + (signed)u->dma.fragsize) in usbout_prepare_desc()
1317 wake_up(&u->dma.wait); in usbout_prepare_desc()
1325 static int usbout_retire_desc(struct usbout *u, struct urb *urb) in usbout_retire_desc() argument
1341 struct usbout *u = &as->usbout; in usbout_completed() local
1347 …BUG "usbout_completed: status %d errcnt %d flags 0x%x\n", urb->status, urb->error_count, u->flags); in usbout_completed()
1349 if (urb == &u->durb[0].urb) in usbout_completed()
1351 else if (urb == &u->durb[1].urb) in usbout_completed()
1359 if (!usbout_retire_desc(u, urb) && in usbout_completed()
1360 u->flags & FLG_RUNNING && in usbout_completed()
1361 !usbout_prepare_desc(u, urb) && in usbout_completed()
1363 u->flags |= mask; in usbout_completed()
1365 u->flags &= ~(mask | FLG_RUNNING); in usbout_completed()
1366 wake_up(&u->dma.wait); in usbout_completed()
1372 static int usbout_sync_prepare_desc(struct usbout *u, struct urb *urb) in usbout_sync_prepare_desc() argument
1386 static int usbout_sync_retire_desc(struct usbout *u, struct urb *urb) in usbout_sync_retire_desc() argument
1401 if (my_abs(f - u->freqn) > (u->freqn >> 3) || f > u->freqmax) { in usbout_sync_retire_desc()
1402 …RNING "usbout_sync_retire_desc: requested frequency %u (nominal %u) out of range!\n", f, u->freqn); in usbout_sync_retire_desc()
1405 u->freqm = f; in usbout_sync_retire_desc()
1413 struct usbout *u = &as->usbout; in usbout_sync_completed() local
1419 …usbout_sync_completed: status %d errcnt %d flags 0x%x\n", urb->status, urb->error_count, u->flags); in usbout_sync_completed()
1421 if (urb == &u->surb[0].urb) in usbout_sync_completed()
1423 else if (urb == &u->surb[1].urb) in usbout_sync_completed()
1431 if (!usbout_sync_retire_desc(u, urb) && in usbout_sync_completed()
1432 u->flags & FLG_RUNNING && in usbout_sync_completed()
1433 !usbout_sync_prepare_desc(u, urb) && in usbout_sync_completed()
1435 u->flags |= mask; in usbout_sync_completed()
1437 u->flags &= ~(mask | FLG_RUNNING); in usbout_sync_completed()
1438 wake_up(&u->dma.wait); in usbout_sync_completed()
1447 struct usbout *u = &as->usbout; in usbout_start() local
1454 dev->devnum, u->format, u->dma.format, u->dma.srate); in usbout_start()
1458 if (!(u->flags & FLG_CONNECTED)) { in usbout_start()
1462 if (!(u->flags & FLG_RUNNING)) { in usbout_start()
1464 u->freqn = u->freqm = ((u->dma.srate << 11) + 62) / 125; /* this will overflow at approx 2MSPS */ in usbout_start()
1465 u->freqmax = u->freqn + (u->freqn >> 2); in usbout_start()
1466 u->phase = 0; in usbout_start()
1467 maxsze = ((u->freqmax + 0x3fff) * AFMT_SAMPLEBYTES(u->format)) >>14; in usbout_start()
1470 if (u->durb[0].urb.transfer_buffer) in usbout_start()
1471 kfree(u->durb[0].urb.transfer_buffer); in usbout_start()
1472 u->durb[0].urb.transfer_buffer = kmalloc(bufsz, GFP_KERNEL); in usbout_start()
1473 u->durb[0].urb.transfer_buffer_length = bufsz; in usbout_start()
1474 if (u->durb[1].urb.transfer_buffer) in usbout_start()
1475 kfree(u->durb[1].urb.transfer_buffer); in usbout_start()
1476 u->durb[1].urb.transfer_buffer = kmalloc(bufsz, GFP_KERNEL); in usbout_start()
1477 u->durb[1].urb.transfer_buffer_length = bufsz; in usbout_start()
1478 if (u->syncpipe) { in usbout_start()
1479 if (u->surb[0].urb.transfer_buffer) in usbout_start()
1480 kfree(u->surb[0].urb.transfer_buffer); in usbout_start()
1481 u->surb[0].urb.transfer_buffer = kmalloc(3*SYNCFRAMES, GFP_KERNEL); in usbout_start()
1482 u->surb[0].urb.transfer_buffer_length = 3*SYNCFRAMES; in usbout_start()
1483 if (u->surb[1].urb.transfer_buffer) in usbout_start()
1484 kfree(u->surb[1].urb.transfer_buffer); in usbout_start()
1485 u->surb[1].urb.transfer_buffer = kmalloc(3*SYNCFRAMES, GFP_KERNEL); in usbout_start()
1486 u->surb[1].urb.transfer_buffer_length = 3*SYNCFRAMES; in usbout_start()
1488 if (!u->durb[0].urb.transfer_buffer || !u->durb[1].urb.transfer_buffer || in usbout_start()
1489 (u->syncpipe && (!u->surb[0].urb.transfer_buffer || !u->surb[1].urb.transfer_buffer))) { in usbout_start()
1495 if (u->dma.count <= 0 && !u->dma.mapped) { in usbout_start()
1499 u->flags |= FLG_RUNNING; in usbout_start()
1500 if (!(u->flags & FLG_URB0RUNNING)) { in usbout_start()
1501 urb = &u->durb[0].urb; in usbout_start()
1503 urb->pipe = u->datapipe; in usbout_start()
1508 if (!usbout_prepare_desc(u, urb) && !usb_submit_urb(urb)) in usbout_start()
1509 u->flags |= FLG_URB0RUNNING; in usbout_start()
1511 u->flags &= ~FLG_RUNNING; in usbout_start()
1513 if (u->flags & FLG_RUNNING && !(u->flags & FLG_URB1RUNNING)) { in usbout_start()
1514 urb = &u->durb[1].urb; in usbout_start()
1516 urb->pipe = u->datapipe; in usbout_start()
1521 if (!usbout_prepare_desc(u, urb) && !usb_submit_urb(urb)) in usbout_start()
1522 u->flags |= FLG_URB1RUNNING; in usbout_start()
1524 u->flags &= ~FLG_RUNNING; in usbout_start()
1526 if (u->syncpipe) { in usbout_start()
1527 if (u->flags & FLG_RUNNING && !(u->flags & FLG_SYNC0RUNNING)) { in usbout_start()
1528 urb = &u->surb[0].urb; in usbout_start()
1530 urb->pipe = u->syncpipe; in usbout_start()
1536 if (!usbout_sync_prepare_desc(u, urb) && !usb_submit_urb(urb)) in usbout_start()
1537 u->flags |= FLG_SYNC0RUNNING; in usbout_start()
1539 u->flags &= ~FLG_RUNNING; in usbout_start()
1541 if (u->flags & FLG_RUNNING && !(u->flags & FLG_SYNC1RUNNING)) { in usbout_start()
1542 urb = &u->surb[1].urb; in usbout_start()
1544 urb->pipe = u->syncpipe; in usbout_start()
1550 if (!usbout_sync_prepare_desc(u, urb) && !usb_submit_urb(urb)) in usbout_start()
1551 u->flags |= FLG_SYNC1RUNNING; in usbout_start()
1553 u->flags &= ~FLG_RUNNING; in usbout_start()
1661 struct usbin *u = &as->usbin; in set_format_in() local
1662 struct dmabuf *d = &u->dma; in set_format_in()
1668 if (u->interface < 0 || u->interface >= config->bNumInterfaces) in set_format_in()
1670 iface = &config->interface[u->interface]; in set_format_in()
1680 u->format = fmt->format; in set_format_in()
1681 u->datapipe = usb_rcvisocpipe(dev, alts->endpoint[0].bEndpointAddress & 0xf); in set_format_in()
1682 u->syncpipe = u->syncinterval = 0; in set_format_in()
1689 dev->devnum, u->interface, fmt->altsetting); in set_format_in()
1691 u->syncpipe = usb_sndisocpipe(dev, alts->endpoint[1].bEndpointAddress & 0xf); in set_format_in()
1692 u->syncinterval = alts->endpoint[1].bRefresh; in set_format_in()
1702 dev->devnum, u->interface, fmt->altsetting); in set_format_in()
1707 ep = usb_pipeendpoint(u->datapipe) | (u->datapipe & USB_DIR_IN); in set_format_in()
1714 ret, dev->devnum, u->interface, ep, d->srate); in set_format_in()
1726 ret, dev->devnum, u->interface, ep, d->srate); in set_format_in()
1732 ret, dev->devnum, u->interface, ep); in set_format_in()
1736 …dev->devnum, u->interface, fmt->altsetting, d->srate, data[0] | (data[1] << 8) | (data[2] << 16))); in set_format_in()
1739 …dprintk((KERN_DEBUG "usbaudio: set_format_in: USB format 0x%x, DMA format 0x%x srate %u\n", u->for… in set_format_in()
1749 struct usbout *u = &as->usbout; in set_format_out() local
1750 struct dmabuf *d = &u->dma; in set_format_out()
1756 if (u->interface < 0 || u->interface >= config->bNumInterfaces) in set_format_out()
1758 iface = &config->interface[u->interface]; in set_format_out()
1767 u->format = fmt->format; in set_format_out()
1769 u->datapipe = usb_sndisocpipe(dev, alts->endpoint[0].bEndpointAddress & 0xf); in set_format_out()
1770 u->syncpipe = u->syncinterval = 0; in set_format_out()
1784 dev->devnum, u->interface, fmt->altsetting); in set_format_out()
1786 u->syncpipe = usb_rcvisocpipe(dev, alts->endpoint[1].bEndpointAddress & 0xf); in set_format_out()
1787 u->syncinterval = alts->endpoint[1].bRefresh; in set_format_out()
1795 if (usb_set_interface(dev, u->interface, fmt->altsetting) < 0) { in set_format_out()
1797 dev->devnum, u->interface, fmt->altsetting); in set_format_out()
1802 ep = usb_pipeendpoint(u->datapipe) | (u->datapipe & USB_DIR_IN); in set_format_out()
1809 ret, dev->devnum, u->interface, ep, d->srate); in set_format_out()
1821 ret, dev->devnum, u->interface, ep, d->srate); in set_format_out()
1827 ret, dev->devnum, u->interface, ep); in set_format_out()
1831 …dev->devnum, u->interface, fmt->altsetting, d->srate, data[0] | (data[1] << 8) | (data[2] << 16))); in set_format_out()
1834 …dprintk((KERN_DEBUG "usbaudio: set_format_out: USB format 0x%x, DMA format 0x%x srate %u\n", u->fo… in set_format_out()
3270 unsigned int u; in getvolchannel() local
3294 …u = ffs(state->mixchmask & (SOUND_MASK_LINE | SOUND_MASK_CD | SOUND_MASK_LINE1 | SOUND_MASK_LINE2 … in getvolchannel()
3296 return u-1; in getvolchannel()