Lines Matching refs:tu
957 struct snd_timer_user *tu = ti->callback_data; in snd_timer_dev_disconnect() local
959 tu->disconnected = true; in snd_timer_dev_disconnect()
960 wake_up(&tu->qchange_sleep); in snd_timer_dev_disconnect()
1205 struct snd_timer_user *tu = timeri->callback_data; in snd_timer_user_interrupt() local
1209 spin_lock(&tu->qlock); in snd_timer_user_interrupt()
1210 if (tu->qused > 0) { in snd_timer_user_interrupt()
1211 prev = tu->qtail == 0 ? tu->queue_size - 1 : tu->qtail - 1; in snd_timer_user_interrupt()
1212 r = &tu->queue[prev]; in snd_timer_user_interrupt()
1218 if (tu->qused >= tu->queue_size) { in snd_timer_user_interrupt()
1219 tu->overrun++; in snd_timer_user_interrupt()
1221 r = &tu->queue[tu->qtail++]; in snd_timer_user_interrupt()
1222 tu->qtail %= tu->queue_size; in snd_timer_user_interrupt()
1225 tu->qused++; in snd_timer_user_interrupt()
1228 spin_unlock(&tu->qlock); in snd_timer_user_interrupt()
1229 kill_fasync(&tu->fasync, SIGIO, POLL_IN); in snd_timer_user_interrupt()
1230 wake_up(&tu->qchange_sleep); in snd_timer_user_interrupt()
1233 static void snd_timer_user_append_to_tqueue(struct snd_timer_user *tu, in snd_timer_user_append_to_tqueue() argument
1236 if (tu->qused >= tu->queue_size) { in snd_timer_user_append_to_tqueue()
1237 tu->overrun++; in snd_timer_user_append_to_tqueue()
1239 memcpy(&tu->tqueue[tu->qtail++], tread, sizeof(*tread)); in snd_timer_user_append_to_tqueue()
1240 tu->qtail %= tu->queue_size; in snd_timer_user_append_to_tqueue()
1241 tu->qused++; in snd_timer_user_append_to_tqueue()
1250 struct snd_timer_user *tu = timeri->callback_data; in snd_timer_user_ccallback() local
1256 tu->tstamp = *tstamp; in snd_timer_user_ccallback()
1257 if ((tu->filter & (1 << event)) == 0 || !tu->tread) in snd_timer_user_ccallback()
1263 spin_lock_irqsave(&tu->qlock, flags); in snd_timer_user_ccallback()
1264 snd_timer_user_append_to_tqueue(tu, &r1); in snd_timer_user_ccallback()
1265 spin_unlock_irqrestore(&tu->qlock, flags); in snd_timer_user_ccallback()
1266 kill_fasync(&tu->fasync, SIGIO, POLL_IN); in snd_timer_user_ccallback()
1267 wake_up(&tu->qchange_sleep); in snd_timer_user_ccallback()
1274 struct snd_timer_user *tu = timeri->callback_data; in snd_timer_user_tinterrupt() local
1280 spin_lock(&tu->qlock); in snd_timer_user_tinterrupt()
1281 if ((tu->filter & ((1 << SNDRV_TIMER_EVENT_RESOLUTION) | in snd_timer_user_tinterrupt()
1283 spin_unlock(&tu->qlock); in snd_timer_user_tinterrupt()
1286 if (tu->last_resolution != resolution || ticks > 0) { in snd_timer_user_tinterrupt()
1292 if ((tu->filter & (1 << SNDRV_TIMER_EVENT_RESOLUTION)) && in snd_timer_user_tinterrupt()
1293 tu->last_resolution != resolution) { in snd_timer_user_tinterrupt()
1298 snd_timer_user_append_to_tqueue(tu, &r1); in snd_timer_user_tinterrupt()
1299 tu->last_resolution = resolution; in snd_timer_user_tinterrupt()
1302 if ((tu->filter & (1 << SNDRV_TIMER_EVENT_TICK)) == 0) in snd_timer_user_tinterrupt()
1306 if (tu->qused > 0) { in snd_timer_user_tinterrupt()
1307 prev = tu->qtail == 0 ? tu->queue_size - 1 : tu->qtail - 1; in snd_timer_user_tinterrupt()
1308 r = &tu->tqueue[prev]; in snd_timer_user_tinterrupt()
1319 snd_timer_user_append_to_tqueue(tu, &r1); in snd_timer_user_tinterrupt()
1322 spin_unlock(&tu->qlock); in snd_timer_user_tinterrupt()
1325 kill_fasync(&tu->fasync, SIGIO, POLL_IN); in snd_timer_user_tinterrupt()
1326 wake_up(&tu->qchange_sleep); in snd_timer_user_tinterrupt()
1331 struct snd_timer_user *tu; in snd_timer_user_open() local
1338 tu = kzalloc(sizeof(*tu), GFP_KERNEL); in snd_timer_user_open()
1339 if (tu == NULL) in snd_timer_user_open()
1341 spin_lock_init(&tu->qlock); in snd_timer_user_open()
1342 init_waitqueue_head(&tu->qchange_sleep); in snd_timer_user_open()
1343 mutex_init(&tu->ioctl_lock); in snd_timer_user_open()
1344 tu->ticks = 1; in snd_timer_user_open()
1345 tu->queue_size = 128; in snd_timer_user_open()
1346 tu->queue = kmalloc(tu->queue_size * sizeof(struct snd_timer_read), in snd_timer_user_open()
1348 if (tu->queue == NULL) { in snd_timer_user_open()
1349 kfree(tu); in snd_timer_user_open()
1352 file->private_data = tu; in snd_timer_user_open()
1358 struct snd_timer_user *tu; in snd_timer_user_release() local
1361 tu = file->private_data; in snd_timer_user_release()
1363 mutex_lock(&tu->ioctl_lock); in snd_timer_user_release()
1364 if (tu->timeri) in snd_timer_user_release()
1365 snd_timer_close(tu->timeri); in snd_timer_user_release()
1366 mutex_unlock(&tu->ioctl_lock); in snd_timer_user_release()
1367 kfree(tu->queue); in snd_timer_user_release()
1368 kfree(tu->tqueue); in snd_timer_user_release()
1369 kfree(tu); in snd_timer_user_release()
1598 struct snd_timer_user *tu; in snd_timer_user_tselect() local
1603 tu = file->private_data; in snd_timer_user_tselect()
1604 if (tu->timeri) { in snd_timer_user_tselect()
1605 snd_timer_close(tu->timeri); in snd_timer_user_tselect()
1606 tu->timeri = NULL; in snd_timer_user_tselect()
1615 err = snd_timer_open(&tu->timeri, str, &tselect.id, current->pid); in snd_timer_user_tselect()
1619 tu->qhead = tu->qtail = tu->qused = 0; in snd_timer_user_tselect()
1620 kfree(tu->queue); in snd_timer_user_tselect()
1621 tu->queue = NULL; in snd_timer_user_tselect()
1622 kfree(tu->tqueue); in snd_timer_user_tselect()
1623 tu->tqueue = NULL; in snd_timer_user_tselect()
1624 if (tu->tread) { in snd_timer_user_tselect()
1625 tu->tqueue = kmalloc(tu->queue_size * sizeof(struct snd_timer_tread), in snd_timer_user_tselect()
1627 if (tu->tqueue == NULL) in snd_timer_user_tselect()
1630 tu->queue = kmalloc(tu->queue_size * sizeof(struct snd_timer_read), in snd_timer_user_tselect()
1632 if (tu->queue == NULL) in snd_timer_user_tselect()
1637 snd_timer_close(tu->timeri); in snd_timer_user_tselect()
1638 tu->timeri = NULL; in snd_timer_user_tselect()
1640 tu->timeri->flags |= SNDRV_TIMER_IFLG_FAST; in snd_timer_user_tselect()
1641 tu->timeri->callback = tu->tread in snd_timer_user_tselect()
1643 tu->timeri->ccallback = snd_timer_user_ccallback; in snd_timer_user_tselect()
1644 tu->timeri->callback_data = (void *)tu; in snd_timer_user_tselect()
1654 struct snd_timer_user *tu; in snd_timer_user_info() local
1659 tu = file->private_data; in snd_timer_user_info()
1660 if (!tu->timeri) in snd_timer_user_info()
1662 t = tu->timeri->timer; in snd_timer_user_info()
1684 struct snd_timer_user *tu; in snd_timer_user_params() local
1691 tu = file->private_data; in snd_timer_user_params()
1692 if (!tu->timeri) in snd_timer_user_params()
1694 t = tu->timeri->timer; in snd_timer_user_params()
1708 resolution = snd_timer_resolution(tu->timeri); in snd_timer_user_params()
1737 snd_timer_stop(tu->timeri); in snd_timer_user_params()
1739 tu->timeri->flags &= ~(SNDRV_TIMER_IFLG_AUTO| in snd_timer_user_params()
1743 tu->timeri->flags |= SNDRV_TIMER_IFLG_AUTO; in snd_timer_user_params()
1745 tu->timeri->flags |= SNDRV_TIMER_IFLG_EXCLUSIVE; in snd_timer_user_params()
1747 tu->timeri->flags |= SNDRV_TIMER_IFLG_EARLY_EVENT; in snd_timer_user_params()
1750 (unsigned int)tu->queue_size != params.queue_size) { in snd_timer_user_params()
1751 if (tu->tread) { in snd_timer_user_params()
1755 kfree(tu->tqueue); in snd_timer_user_params()
1756 tu->queue_size = params.queue_size; in snd_timer_user_params()
1757 tu->tqueue = ttr; in snd_timer_user_params()
1763 kfree(tu->queue); in snd_timer_user_params()
1764 tu->queue_size = params.queue_size; in snd_timer_user_params()
1765 tu->queue = tr; in snd_timer_user_params()
1769 tu->qhead = tu->qtail = tu->qused = 0; in snd_timer_user_params()
1770 if (tu->timeri->flags & SNDRV_TIMER_IFLG_EARLY_EVENT) { in snd_timer_user_params()
1771 if (tu->tread) { in snd_timer_user_params()
1778 snd_timer_user_append_to_tqueue(tu, &tread); in snd_timer_user_params()
1780 struct snd_timer_read *r = &tu->queue[0]; in snd_timer_user_params()
1783 tu->qused++; in snd_timer_user_params()
1784 tu->qtail++; in snd_timer_user_params()
1787 tu->filter = params.filter; in snd_timer_user_params()
1788 tu->ticks = params.ticks; in snd_timer_user_params()
1799 struct snd_timer_user *tu; in snd_timer_user_status() local
1802 tu = file->private_data; in snd_timer_user_status()
1803 if (!tu->timeri) in snd_timer_user_status()
1806 status.tstamp = tu->tstamp; in snd_timer_user_status()
1807 status.resolution = snd_timer_resolution(tu->timeri); in snd_timer_user_status()
1808 status.lost = tu->timeri->lost; in snd_timer_user_status()
1809 status.overrun = tu->overrun; in snd_timer_user_status()
1810 spin_lock_irq(&tu->qlock); in snd_timer_user_status()
1811 status.queue = tu->qused; in snd_timer_user_status()
1812 spin_unlock_irq(&tu->qlock); in snd_timer_user_status()
1821 struct snd_timer_user *tu; in snd_timer_user_start() local
1823 tu = file->private_data; in snd_timer_user_start()
1824 if (!tu->timeri) in snd_timer_user_start()
1826 snd_timer_stop(tu->timeri); in snd_timer_user_start()
1827 tu->timeri->lost = 0; in snd_timer_user_start()
1828 tu->last_resolution = 0; in snd_timer_user_start()
1829 return (err = snd_timer_start(tu->timeri, tu->ticks)) < 0 ? err : 0; in snd_timer_user_start()
1835 struct snd_timer_user *tu; in snd_timer_user_stop() local
1837 tu = file->private_data; in snd_timer_user_stop()
1838 if (!tu->timeri) in snd_timer_user_stop()
1840 return (err = snd_timer_stop(tu->timeri)) < 0 ? err : 0; in snd_timer_user_stop()
1846 struct snd_timer_user *tu; in snd_timer_user_continue() local
1848 tu = file->private_data; in snd_timer_user_continue()
1849 if (!tu->timeri) in snd_timer_user_continue()
1852 if (!(tu->timeri->flags & SNDRV_TIMER_IFLG_PAUSED)) in snd_timer_user_continue()
1854 tu->timeri->lost = 0; in snd_timer_user_continue()
1855 return (err = snd_timer_continue(tu->timeri)) < 0 ? err : 0; in snd_timer_user_continue()
1861 struct snd_timer_user *tu; in snd_timer_user_pause() local
1863 tu = file->private_data; in snd_timer_user_pause()
1864 if (!tu->timeri) in snd_timer_user_pause()
1866 return (err = snd_timer_pause(tu->timeri)) < 0 ? err : 0; in snd_timer_user_pause()
1879 struct snd_timer_user *tu; in __snd_timer_user_ioctl() local
1883 tu = file->private_data; in __snd_timer_user_ioctl()
1893 if (tu->timeri) /* too late */ in __snd_timer_user_ioctl()
1897 tu->tread = xarg ? 1 : 0; in __snd_timer_user_ioctl()
1933 struct snd_timer_user *tu = file->private_data; in snd_timer_user_ioctl() local
1936 mutex_lock(&tu->ioctl_lock); in snd_timer_user_ioctl()
1938 mutex_unlock(&tu->ioctl_lock); in snd_timer_user_ioctl()
1944 struct snd_timer_user *tu; in snd_timer_user_fasync() local
1946 tu = file->private_data; in snd_timer_user_fasync()
1947 return fasync_helper(fd, file, on, &tu->fasync); in snd_timer_user_fasync()
1953 struct snd_timer_user *tu; in snd_timer_user_read() local
1958 tu = file->private_data; in snd_timer_user_read()
1959 unit = tu->tread ? sizeof(struct snd_timer_tread) : sizeof(struct snd_timer_read); in snd_timer_user_read()
1960 mutex_lock(&tu->ioctl_lock); in snd_timer_user_read()
1961 spin_lock_irq(&tu->qlock); in snd_timer_user_read()
1963 while (!tu->qused) { in snd_timer_user_read()
1973 add_wait_queue(&tu->qchange_sleep, &wait); in snd_timer_user_read()
1975 spin_unlock_irq(&tu->qlock); in snd_timer_user_read()
1976 mutex_unlock(&tu->ioctl_lock); in snd_timer_user_read()
1978 mutex_lock(&tu->ioctl_lock); in snd_timer_user_read()
1979 spin_lock_irq(&tu->qlock); in snd_timer_user_read()
1981 remove_wait_queue(&tu->qchange_sleep, &wait); in snd_timer_user_read()
1983 if (tu->disconnected) { in snd_timer_user_read()
1993 qhead = tu->qhead++; in snd_timer_user_read()
1994 tu->qhead %= tu->queue_size; in snd_timer_user_read()
1995 tu->qused--; in snd_timer_user_read()
1996 spin_unlock_irq(&tu->qlock); in snd_timer_user_read()
1998 if (tu->tread) { in snd_timer_user_read()
1999 if (copy_to_user(buffer, &tu->tqueue[qhead], in snd_timer_user_read()
2003 if (copy_to_user(buffer, &tu->queue[qhead], in snd_timer_user_read()
2008 spin_lock_irq(&tu->qlock); in snd_timer_user_read()
2015 spin_unlock_irq(&tu->qlock); in snd_timer_user_read()
2016 mutex_unlock(&tu->ioctl_lock); in snd_timer_user_read()
2023 struct snd_timer_user *tu; in snd_timer_user_poll() local
2025 tu = file->private_data; in snd_timer_user_poll()
2027 poll_wait(file, &tu->qchange_sleep, wait); in snd_timer_user_poll()
2030 if (tu->qused) in snd_timer_user_poll()
2032 if (tu->disconnected) in snd_timer_user_poll()