Lines Matching refs:tu

1299 	struct snd_timer_user *tu = timeri->callback_data;  in snd_timer_user_interrupt()  local
1303 guard(spinlock)(&tu->qlock); in snd_timer_user_interrupt()
1304 if (tu->qused > 0) { in snd_timer_user_interrupt()
1305 prev = tu->qtail == 0 ? tu->queue_size - 1 : tu->qtail - 1; in snd_timer_user_interrupt()
1306 r = &tu->queue[prev]; in snd_timer_user_interrupt()
1312 if (tu->qused >= tu->queue_size) { in snd_timer_user_interrupt()
1313 tu->overrun++; in snd_timer_user_interrupt()
1315 r = &tu->queue[tu->qtail++]; in snd_timer_user_interrupt()
1316 tu->qtail %= tu->queue_size; in snd_timer_user_interrupt()
1319 tu->qused++; in snd_timer_user_interrupt()
1322 snd_kill_fasync(tu->fasync, SIGIO, POLL_IN); in snd_timer_user_interrupt()
1323 wake_up(&tu->qchange_sleep); in snd_timer_user_interrupt()
1326 static void snd_timer_user_append_to_tqueue(struct snd_timer_user *tu, in snd_timer_user_append_to_tqueue() argument
1329 if (tu->qused >= tu->queue_size) { in snd_timer_user_append_to_tqueue()
1330 tu->overrun++; in snd_timer_user_append_to_tqueue()
1332 memcpy(&tu->tqueue[tu->qtail++], tread, sizeof(*tread)); in snd_timer_user_append_to_tqueue()
1333 tu->qtail %= tu->queue_size; in snd_timer_user_append_to_tqueue()
1334 tu->qused++; in snd_timer_user_append_to_tqueue()
1343 struct snd_timer_user *tu = timeri->callback_data; in snd_timer_user_ccallback() local
1348 tu->tstamp = *tstamp; in snd_timer_user_ccallback()
1349 if ((tu->filter & (1 << event)) == 0 || !tu->tread) in snd_timer_user_ccallback()
1356 scoped_guard(spinlock_irqsave, &tu->qlock) in snd_timer_user_ccallback()
1357 snd_timer_user_append_to_tqueue(tu, &r1); in snd_timer_user_ccallback()
1358 snd_kill_fasync(tu->fasync, SIGIO, POLL_IN); in snd_timer_user_ccallback()
1359 wake_up(&tu->qchange_sleep); in snd_timer_user_ccallback()
1364 struct snd_timer_user *tu = timeri->callback_data; in snd_timer_user_disconnect() local
1366 tu->disconnected = true; in snd_timer_user_disconnect()
1367 wake_up(&tu->qchange_sleep); in snd_timer_user_disconnect()
1374 struct snd_timer_user *tu = timeri->callback_data; in snd_timer_user_tinterrupt() local
1381 scoped_guard(spinlock, &tu->qlock) { in snd_timer_user_tinterrupt()
1382 if ((tu->filter & ((1 << SNDRV_TIMER_EVENT_RESOLUTION) | in snd_timer_user_tinterrupt()
1385 if (tu->last_resolution != resolution || ticks > 0) { in snd_timer_user_tinterrupt()
1391 if ((tu->filter & (1 << SNDRV_TIMER_EVENT_RESOLUTION)) && in snd_timer_user_tinterrupt()
1392 tu->last_resolution != resolution) { in snd_timer_user_tinterrupt()
1397 snd_timer_user_append_to_tqueue(tu, &r1); in snd_timer_user_tinterrupt()
1398 tu->last_resolution = resolution; in snd_timer_user_tinterrupt()
1401 if ((tu->filter & (1 << SNDRV_TIMER_EVENT_TICK)) == 0) in snd_timer_user_tinterrupt()
1405 if (tu->qused > 0) { in snd_timer_user_tinterrupt()
1406 prev = tu->qtail == 0 ? tu->queue_size - 1 : tu->qtail - 1; in snd_timer_user_tinterrupt()
1407 r = &tu->tqueue[prev]; in snd_timer_user_tinterrupt()
1420 snd_timer_user_append_to_tqueue(tu, &r1); in snd_timer_user_tinterrupt()
1425 snd_kill_fasync(tu->fasync, SIGIO, POLL_IN); in snd_timer_user_tinterrupt()
1426 wake_up(&tu->qchange_sleep); in snd_timer_user_tinterrupt()
1429 static int realloc_user_queue(struct snd_timer_user *tu, int size) in realloc_user_queue() argument
1434 if (tu->tread) { in realloc_user_queue()
1444 guard(spinlock_irq)(&tu->qlock); in realloc_user_queue()
1445 kfree(tu->queue); in realloc_user_queue()
1446 kfree(tu->tqueue); in realloc_user_queue()
1447 tu->queue_size = size; in realloc_user_queue()
1448 tu->queue = queue; in realloc_user_queue()
1449 tu->tqueue = tqueue; in realloc_user_queue()
1450 tu->qhead = tu->qtail = tu->qused = 0; in realloc_user_queue()
1457 struct snd_timer_user *tu; in snd_timer_user_open() local
1464 tu = kzalloc(sizeof(*tu), GFP_KERNEL); in snd_timer_user_open()
1465 if (tu == NULL) in snd_timer_user_open()
1467 spin_lock_init(&tu->qlock); in snd_timer_user_open()
1468 init_waitqueue_head(&tu->qchange_sleep); in snd_timer_user_open()
1469 mutex_init(&tu->ioctl_lock); in snd_timer_user_open()
1470 tu->ticks = 1; in snd_timer_user_open()
1471 if (realloc_user_queue(tu, 128) < 0) { in snd_timer_user_open()
1472 kfree(tu); in snd_timer_user_open()
1475 file->private_data = tu; in snd_timer_user_open()
1481 struct snd_timer_user *tu; in snd_timer_user_release() local
1484 tu = file->private_data; in snd_timer_user_release()
1486 scoped_guard(mutex, &tu->ioctl_lock) { in snd_timer_user_release()
1487 if (tu->timeri) { in snd_timer_user_release()
1488 snd_timer_close(tu->timeri); in snd_timer_user_release()
1489 snd_timer_instance_free(tu->timeri); in snd_timer_user_release()
1492 snd_fasync_free(tu->fasync); in snd_timer_user_release()
1493 kfree(tu->queue); in snd_timer_user_release()
1494 kfree(tu->tqueue); in snd_timer_user_release()
1495 kfree(tu); in snd_timer_user_release()
1707 struct snd_timer_user *tu; in snd_timer_user_tselect() local
1712 tu = file->private_data; in snd_timer_user_tselect()
1713 if (tu->timeri) { in snd_timer_user_tselect()
1714 snd_timer_close(tu->timeri); in snd_timer_user_tselect()
1715 snd_timer_instance_free(tu->timeri); in snd_timer_user_tselect()
1716 tu->timeri = NULL; in snd_timer_user_tselect()
1725 tu->timeri = snd_timer_instance_new(str); in snd_timer_user_tselect()
1726 if (!tu->timeri) { in snd_timer_user_tselect()
1731 tu->timeri->flags |= SNDRV_TIMER_IFLG_FAST; in snd_timer_user_tselect()
1732 tu->timeri->callback = tu->tread in snd_timer_user_tselect()
1734 tu->timeri->ccallback = snd_timer_user_ccallback; in snd_timer_user_tselect()
1735 tu->timeri->callback_data = (void *)tu; in snd_timer_user_tselect()
1736 tu->timeri->disconnect = snd_timer_user_disconnect; in snd_timer_user_tselect()
1738 err = snd_timer_open(tu->timeri, &tselect.id, current->pid); in snd_timer_user_tselect()
1740 snd_timer_instance_free(tu->timeri); in snd_timer_user_tselect()
1741 tu->timeri = NULL; in snd_timer_user_tselect()
1751 struct snd_timer_user *tu; in snd_timer_user_info() local
1755 tu = file->private_data; in snd_timer_user_info()
1756 if (!tu->timeri) in snd_timer_user_info()
1758 t = tu->timeri->timer; in snd_timer_user_info()
1780 struct snd_timer_user *tu; in snd_timer_user_params() local
1785 tu = file->private_data; in snd_timer_user_params()
1786 if (!tu->timeri) in snd_timer_user_params()
1788 t = tu->timeri->timer; in snd_timer_user_params()
1802 resolution = snd_timer_resolution(tu->timeri); in snd_timer_user_params()
1831 snd_timer_stop(tu->timeri); in snd_timer_user_params()
1833 tu->timeri->flags &= ~(SNDRV_TIMER_IFLG_AUTO| in snd_timer_user_params()
1837 tu->timeri->flags |= SNDRV_TIMER_IFLG_AUTO; in snd_timer_user_params()
1839 tu->timeri->flags |= SNDRV_TIMER_IFLG_EXCLUSIVE; in snd_timer_user_params()
1841 tu->timeri->flags |= SNDRV_TIMER_IFLG_EARLY_EVENT; in snd_timer_user_params()
1844 (unsigned int)tu->queue_size != params.queue_size) { in snd_timer_user_params()
1845 err = realloc_user_queue(tu, params.queue_size); in snd_timer_user_params()
1849 scoped_guard(spinlock_irq, &tu->qlock) { in snd_timer_user_params()
1850 tu->qhead = tu->qtail = tu->qused = 0; in snd_timer_user_params()
1851 if (tu->timeri->flags & SNDRV_TIMER_IFLG_EARLY_EVENT) { in snd_timer_user_params()
1852 if (tu->tread) { in snd_timer_user_params()
1860 snd_timer_user_append_to_tqueue(tu, &tread); in snd_timer_user_params()
1862 struct snd_timer_read *r = &tu->queue[0]; in snd_timer_user_params()
1866 tu->qused++; in snd_timer_user_params()
1867 tu->qtail++; in snd_timer_user_params()
1870 tu->filter = params.filter; in snd_timer_user_params()
1871 tu->ticks = params.ticks; in snd_timer_user_params()
1883 struct snd_timer_user *tu; in snd_timer_user_status32() local
1886 tu = file->private_data; in snd_timer_user_status32()
1887 if (!tu->timeri) in snd_timer_user_status32()
1890 status.tstamp_sec = tu->tstamp.tv_sec; in snd_timer_user_status32()
1891 status.tstamp_nsec = tu->tstamp.tv_nsec; in snd_timer_user_status32()
1892 status.resolution = snd_timer_resolution(tu->timeri); in snd_timer_user_status32()
1893 status.lost = tu->timeri->lost; in snd_timer_user_status32()
1894 status.overrun = tu->overrun; in snd_timer_user_status32()
1895 scoped_guard(spinlock_irq, &tu->qlock) in snd_timer_user_status32()
1896 status.queue = tu->qused; in snd_timer_user_status32()
1905 struct snd_timer_user *tu; in snd_timer_user_status64() local
1908 tu = file->private_data; in snd_timer_user_status64()
1909 if (!tu->timeri) in snd_timer_user_status64()
1912 status.tstamp_sec = tu->tstamp.tv_sec; in snd_timer_user_status64()
1913 status.tstamp_nsec = tu->tstamp.tv_nsec; in snd_timer_user_status64()
1914 status.resolution = snd_timer_resolution(tu->timeri); in snd_timer_user_status64()
1915 status.lost = tu->timeri->lost; in snd_timer_user_status64()
1916 status.overrun = tu->overrun; in snd_timer_user_status64()
1917 scoped_guard(spinlock_irq, &tu->qlock) in snd_timer_user_status64()
1918 status.queue = tu->qused; in snd_timer_user_status64()
1927 struct snd_timer_user *tu; in snd_timer_user_start() local
1929 tu = file->private_data; in snd_timer_user_start()
1930 if (!tu->timeri) in snd_timer_user_start()
1932 snd_timer_stop(tu->timeri); in snd_timer_user_start()
1933 tu->timeri->lost = 0; in snd_timer_user_start()
1934 tu->last_resolution = 0; in snd_timer_user_start()
1935 err = snd_timer_start(tu->timeri, tu->ticks); in snd_timer_user_start()
1944 struct snd_timer_user *tu; in snd_timer_user_stop() local
1946 tu = file->private_data; in snd_timer_user_stop()
1947 if (!tu->timeri) in snd_timer_user_stop()
1949 err = snd_timer_stop(tu->timeri); in snd_timer_user_stop()
1958 struct snd_timer_user *tu; in snd_timer_user_continue() local
1960 tu = file->private_data; in snd_timer_user_continue()
1961 if (!tu->timeri) in snd_timer_user_continue()
1964 if (!(tu->timeri->flags & SNDRV_TIMER_IFLG_PAUSED)) in snd_timer_user_continue()
1966 tu->timeri->lost = 0; in snd_timer_user_continue()
1967 err = snd_timer_continue(tu->timeri); in snd_timer_user_continue()
1976 struct snd_timer_user *tu; in snd_timer_user_pause() local
1978 tu = file->private_data; in snd_timer_user_pause()
1979 if (!tu->timeri) in snd_timer_user_pause()
1981 err = snd_timer_pause(tu->timeri); in snd_timer_user_pause()
1987 static int snd_timer_user_tread(void __user *argp, struct snd_timer_user *tu, in snd_timer_user_tread() argument
1993 if (tu->timeri) /* too late */ in snd_timer_user_tread()
1998 old_tread = tu->tread; in snd_timer_user_tread()
2001 tu->tread = TREAD_FORMAT_NONE; in snd_timer_user_tread()
2004 tu->tread = TREAD_FORMAT_TIME64; in snd_timer_user_tread()
2006 tu->tread = TREAD_FORMAT_TIME32; in snd_timer_user_tread()
2008 if (tu->tread != old_tread && in snd_timer_user_tread()
2009 realloc_user_queue(tu, tu->queue_size) < 0) { in snd_timer_user_tread()
2010 tu->tread = old_tread; in snd_timer_user_tread()
2238 struct snd_timer_user *tu; in __snd_timer_user_ioctl() local
2242 tu = file->private_data; in __snd_timer_user_ioctl()
2250 return snd_timer_user_tread(argp, tu, cmd, compat); in __snd_timer_user_ioctl()
2288 struct snd_timer_user *tu = file->private_data; in snd_timer_user_ioctl() local
2290 guard(mutex)(&tu->ioctl_lock); in snd_timer_user_ioctl()
2296 struct snd_timer_user *tu; in snd_timer_user_fasync() local
2298 tu = file->private_data; in snd_timer_user_fasync()
2299 return snd_fasync_helper(fd, file, on, &tu->fasync); in snd_timer_user_fasync()
2307 struct snd_timer_user *tu; in snd_timer_user_read() local
2312 tu = file->private_data; in snd_timer_user_read()
2313 switch (tu->tread) { in snd_timer_user_read()
2328 mutex_lock(&tu->ioctl_lock); in snd_timer_user_read()
2329 spin_lock_irq(&tu->qlock); in snd_timer_user_read()
2331 while (!tu->qused) { in snd_timer_user_read()
2341 add_wait_queue(&tu->qchange_sleep, &wait); in snd_timer_user_read()
2343 spin_unlock_irq(&tu->qlock); in snd_timer_user_read()
2344 mutex_unlock(&tu->ioctl_lock); in snd_timer_user_read()
2346 mutex_lock(&tu->ioctl_lock); in snd_timer_user_read()
2347 spin_lock_irq(&tu->qlock); in snd_timer_user_read()
2349 remove_wait_queue(&tu->qchange_sleep, &wait); in snd_timer_user_read()
2351 if (tu->disconnected) { in snd_timer_user_read()
2361 qhead = tu->qhead++; in snd_timer_user_read()
2362 tu->qhead %= tu->queue_size; in snd_timer_user_read()
2363 tu->qused--; in snd_timer_user_read()
2364 spin_unlock_irq(&tu->qlock); in snd_timer_user_read()
2366 tread = &tu->tqueue[qhead]; in snd_timer_user_read()
2368 switch (tu->tread) { in snd_timer_user_read()
2387 if (copy_to_user(buffer, &tu->queue[qhead], in snd_timer_user_read()
2396 spin_lock_irq(&tu->qlock); in snd_timer_user_read()
2403 spin_unlock_irq(&tu->qlock); in snd_timer_user_read()
2404 mutex_unlock(&tu->ioctl_lock); in snd_timer_user_read()
2411 struct snd_timer_user *tu; in snd_timer_user_poll() local
2413 tu = file->private_data; in snd_timer_user_poll()
2415 poll_wait(file, &tu->qchange_sleep, wait); in snd_timer_user_poll()
2418 guard(spinlock_irq)(&tu->qlock); in snd_timer_user_poll()
2419 if (tu->qused) in snd_timer_user_poll()
2421 if (tu->disconnected) in snd_timer_user_poll()