Lines Matching refs:tu

1324 	struct snd_timer_user *tu = timeri->callback_data;  in snd_timer_user_interrupt()  local
1328 spin_lock(&tu->qlock); in snd_timer_user_interrupt()
1329 if (tu->qused > 0) { in snd_timer_user_interrupt()
1330 prev = tu->qtail == 0 ? tu->queue_size - 1 : tu->qtail - 1; in snd_timer_user_interrupt()
1331 r = &tu->queue[prev]; in snd_timer_user_interrupt()
1337 if (tu->qused >= tu->queue_size) { in snd_timer_user_interrupt()
1338 tu->overrun++; in snd_timer_user_interrupt()
1340 r = &tu->queue[tu->qtail++]; in snd_timer_user_interrupt()
1341 tu->qtail %= tu->queue_size; in snd_timer_user_interrupt()
1344 tu->qused++; in snd_timer_user_interrupt()
1347 spin_unlock(&tu->qlock); in snd_timer_user_interrupt()
1348 kill_fasync(&tu->fasync, SIGIO, POLL_IN); in snd_timer_user_interrupt()
1349 wake_up(&tu->qchange_sleep); in snd_timer_user_interrupt()
1352 static void snd_timer_user_append_to_tqueue(struct snd_timer_user *tu, in snd_timer_user_append_to_tqueue() argument
1355 if (tu->qused >= tu->queue_size) { in snd_timer_user_append_to_tqueue()
1356 tu->overrun++; in snd_timer_user_append_to_tqueue()
1358 memcpy(&tu->tqueue[tu->qtail++], tread, sizeof(*tread)); in snd_timer_user_append_to_tqueue()
1359 tu->qtail %= tu->queue_size; in snd_timer_user_append_to_tqueue()
1360 tu->qused++; in snd_timer_user_append_to_tqueue()
1369 struct snd_timer_user *tu = timeri->callback_data; in snd_timer_user_ccallback() local
1375 tu->tstamp = *tstamp; in snd_timer_user_ccallback()
1376 if ((tu->filter & (1 << event)) == 0 || !tu->tread) in snd_timer_user_ccallback()
1383 spin_lock_irqsave(&tu->qlock, flags); in snd_timer_user_ccallback()
1384 snd_timer_user_append_to_tqueue(tu, &r1); in snd_timer_user_ccallback()
1385 spin_unlock_irqrestore(&tu->qlock, flags); in snd_timer_user_ccallback()
1386 kill_fasync(&tu->fasync, SIGIO, POLL_IN); in snd_timer_user_ccallback()
1387 wake_up(&tu->qchange_sleep); in snd_timer_user_ccallback()
1392 struct snd_timer_user *tu = timeri->callback_data; in snd_timer_user_disconnect() local
1394 tu->disconnected = true; in snd_timer_user_disconnect()
1395 wake_up(&tu->qchange_sleep); in snd_timer_user_disconnect()
1402 struct snd_timer_user *tu = timeri->callback_data; in snd_timer_user_tinterrupt() local
1409 spin_lock(&tu->qlock); in snd_timer_user_tinterrupt()
1410 if ((tu->filter & ((1 << SNDRV_TIMER_EVENT_RESOLUTION) | in snd_timer_user_tinterrupt()
1412 spin_unlock(&tu->qlock); in snd_timer_user_tinterrupt()
1415 if (tu->last_resolution != resolution || ticks > 0) { in snd_timer_user_tinterrupt()
1421 if ((tu->filter & (1 << SNDRV_TIMER_EVENT_RESOLUTION)) && in snd_timer_user_tinterrupt()
1422 tu->last_resolution != resolution) { in snd_timer_user_tinterrupt()
1427 snd_timer_user_append_to_tqueue(tu, &r1); in snd_timer_user_tinterrupt()
1428 tu->last_resolution = resolution; in snd_timer_user_tinterrupt()
1431 if ((tu->filter & (1 << SNDRV_TIMER_EVENT_TICK)) == 0) in snd_timer_user_tinterrupt()
1435 if (tu->qused > 0) { in snd_timer_user_tinterrupt()
1436 prev = tu->qtail == 0 ? tu->queue_size - 1 : tu->qtail - 1; in snd_timer_user_tinterrupt()
1437 r = &tu->tqueue[prev]; in snd_timer_user_tinterrupt()
1450 snd_timer_user_append_to_tqueue(tu, &r1); in snd_timer_user_tinterrupt()
1453 spin_unlock(&tu->qlock); in snd_timer_user_tinterrupt()
1456 kill_fasync(&tu->fasync, SIGIO, POLL_IN); in snd_timer_user_tinterrupt()
1457 wake_up(&tu->qchange_sleep); in snd_timer_user_tinterrupt()
1460 static int realloc_user_queue(struct snd_timer_user *tu, int size) in realloc_user_queue() argument
1465 if (tu->tread) { in realloc_user_queue()
1475 spin_lock_irq(&tu->qlock); in realloc_user_queue()
1476 kfree(tu->queue); in realloc_user_queue()
1477 kfree(tu->tqueue); in realloc_user_queue()
1478 tu->queue_size = size; in realloc_user_queue()
1479 tu->queue = queue; in realloc_user_queue()
1480 tu->tqueue = tqueue; in realloc_user_queue()
1481 tu->qhead = tu->qtail = tu->qused = 0; in realloc_user_queue()
1482 spin_unlock_irq(&tu->qlock); in realloc_user_queue()
1489 struct snd_timer_user *tu; in snd_timer_user_open() local
1496 tu = kzalloc(sizeof(*tu), GFP_KERNEL); in snd_timer_user_open()
1497 if (tu == NULL) in snd_timer_user_open()
1499 spin_lock_init(&tu->qlock); in snd_timer_user_open()
1500 init_waitqueue_head(&tu->qchange_sleep); in snd_timer_user_open()
1501 mutex_init(&tu->ioctl_lock); in snd_timer_user_open()
1502 tu->ticks = 1; in snd_timer_user_open()
1503 if (realloc_user_queue(tu, 128) < 0) { in snd_timer_user_open()
1504 kfree(tu); in snd_timer_user_open()
1507 file->private_data = tu; in snd_timer_user_open()
1513 struct snd_timer_user *tu; in snd_timer_user_release() local
1516 tu = file->private_data; in snd_timer_user_release()
1518 mutex_lock(&tu->ioctl_lock); in snd_timer_user_release()
1519 if (tu->timeri) { in snd_timer_user_release()
1520 snd_timer_close(tu->timeri); in snd_timer_user_release()
1521 snd_timer_instance_free(tu->timeri); in snd_timer_user_release()
1523 mutex_unlock(&tu->ioctl_lock); in snd_timer_user_release()
1524 kfree(tu->queue); in snd_timer_user_release()
1525 kfree(tu->tqueue); in snd_timer_user_release()
1526 kfree(tu); in snd_timer_user_release()
1755 struct snd_timer_user *tu; in snd_timer_user_tselect() local
1760 tu = file->private_data; in snd_timer_user_tselect()
1761 if (tu->timeri) { in snd_timer_user_tselect()
1762 snd_timer_close(tu->timeri); in snd_timer_user_tselect()
1763 snd_timer_instance_free(tu->timeri); in snd_timer_user_tselect()
1764 tu->timeri = NULL; in snd_timer_user_tselect()
1773 tu->timeri = snd_timer_instance_new(str); in snd_timer_user_tselect()
1774 if (!tu->timeri) { in snd_timer_user_tselect()
1779 tu->timeri->flags |= SNDRV_TIMER_IFLG_FAST; in snd_timer_user_tselect()
1780 tu->timeri->callback = tu->tread in snd_timer_user_tselect()
1782 tu->timeri->ccallback = snd_timer_user_ccallback; in snd_timer_user_tselect()
1783 tu->timeri->callback_data = (void *)tu; in snd_timer_user_tselect()
1784 tu->timeri->disconnect = snd_timer_user_disconnect; in snd_timer_user_tselect()
1786 err = snd_timer_open(tu->timeri, &tselect.id, current->pid); in snd_timer_user_tselect()
1788 snd_timer_instance_free(tu->timeri); in snd_timer_user_tselect()
1789 tu->timeri = NULL; in snd_timer_user_tselect()
1799 struct snd_timer_user *tu; in snd_timer_user_info() local
1804 tu = file->private_data; in snd_timer_user_info()
1805 if (!tu->timeri) in snd_timer_user_info()
1807 t = tu->timeri->timer; in snd_timer_user_info()
1829 struct snd_timer_user *tu; in snd_timer_user_params() local
1834 tu = file->private_data; in snd_timer_user_params()
1835 if (!tu->timeri) in snd_timer_user_params()
1837 t = tu->timeri->timer; in snd_timer_user_params()
1851 resolution = snd_timer_resolution(tu->timeri); in snd_timer_user_params()
1880 snd_timer_stop(tu->timeri); in snd_timer_user_params()
1882 tu->timeri->flags &= ~(SNDRV_TIMER_IFLG_AUTO| in snd_timer_user_params()
1886 tu->timeri->flags |= SNDRV_TIMER_IFLG_AUTO; in snd_timer_user_params()
1888 tu->timeri->flags |= SNDRV_TIMER_IFLG_EXCLUSIVE; in snd_timer_user_params()
1890 tu->timeri->flags |= SNDRV_TIMER_IFLG_EARLY_EVENT; in snd_timer_user_params()
1893 (unsigned int)tu->queue_size != params.queue_size) { in snd_timer_user_params()
1894 err = realloc_user_queue(tu, params.queue_size); in snd_timer_user_params()
1898 spin_lock_irq(&tu->qlock); in snd_timer_user_params()
1899 tu->qhead = tu->qtail = tu->qused = 0; in snd_timer_user_params()
1900 if (tu->timeri->flags & SNDRV_TIMER_IFLG_EARLY_EVENT) { in snd_timer_user_params()
1901 if (tu->tread) { in snd_timer_user_params()
1908 snd_timer_user_append_to_tqueue(tu, &tread); in snd_timer_user_params()
1910 struct snd_timer_read *r = &tu->queue[0]; in snd_timer_user_params()
1913 tu->qused++; in snd_timer_user_params()
1914 tu->qtail++; in snd_timer_user_params()
1917 tu->filter = params.filter; in snd_timer_user_params()
1918 tu->ticks = params.ticks; in snd_timer_user_params()
1919 spin_unlock_irq(&tu->qlock); in snd_timer_user_params()
1930 struct snd_timer_user *tu; in snd_timer_user_status32() local
1933 tu = file->private_data; in snd_timer_user_status32()
1934 if (!tu->timeri) in snd_timer_user_status32()
1937 status.tstamp_sec = tu->tstamp.tv_sec; in snd_timer_user_status32()
1938 status.tstamp_nsec = tu->tstamp.tv_nsec; in snd_timer_user_status32()
1939 status.resolution = snd_timer_resolution(tu->timeri); in snd_timer_user_status32()
1940 status.lost = tu->timeri->lost; in snd_timer_user_status32()
1941 status.overrun = tu->overrun; in snd_timer_user_status32()
1942 spin_lock_irq(&tu->qlock); in snd_timer_user_status32()
1943 status.queue = tu->qused; in snd_timer_user_status32()
1944 spin_unlock_irq(&tu->qlock); in snd_timer_user_status32()
1953 struct snd_timer_user *tu; in snd_timer_user_status64() local
1956 tu = file->private_data; in snd_timer_user_status64()
1957 if (!tu->timeri) in snd_timer_user_status64()
1960 status.tstamp_sec = tu->tstamp.tv_sec; in snd_timer_user_status64()
1961 status.tstamp_nsec = tu->tstamp.tv_nsec; in snd_timer_user_status64()
1962 status.resolution = snd_timer_resolution(tu->timeri); in snd_timer_user_status64()
1963 status.lost = tu->timeri->lost; in snd_timer_user_status64()
1964 status.overrun = tu->overrun; in snd_timer_user_status64()
1965 spin_lock_irq(&tu->qlock); in snd_timer_user_status64()
1966 status.queue = tu->qused; in snd_timer_user_status64()
1967 spin_unlock_irq(&tu->qlock); in snd_timer_user_status64()
1976 struct snd_timer_user *tu; in snd_timer_user_start() local
1978 tu = file->private_data; in snd_timer_user_start()
1979 if (!tu->timeri) in snd_timer_user_start()
1981 snd_timer_stop(tu->timeri); in snd_timer_user_start()
1982 tu->timeri->lost = 0; in snd_timer_user_start()
1983 tu->last_resolution = 0; in snd_timer_user_start()
1984 err = snd_timer_start(tu->timeri, tu->ticks); in snd_timer_user_start()
1993 struct snd_timer_user *tu; in snd_timer_user_stop() local
1995 tu = file->private_data; in snd_timer_user_stop()
1996 if (!tu->timeri) in snd_timer_user_stop()
1998 err = snd_timer_stop(tu->timeri); in snd_timer_user_stop()
2007 struct snd_timer_user *tu; in snd_timer_user_continue() local
2009 tu = file->private_data; in snd_timer_user_continue()
2010 if (!tu->timeri) in snd_timer_user_continue()
2013 if (!(tu->timeri->flags & SNDRV_TIMER_IFLG_PAUSED)) in snd_timer_user_continue()
2015 tu->timeri->lost = 0; in snd_timer_user_continue()
2016 err = snd_timer_continue(tu->timeri); in snd_timer_user_continue()
2025 struct snd_timer_user *tu; in snd_timer_user_pause() local
2027 tu = file->private_data; in snd_timer_user_pause()
2028 if (!tu->timeri) in snd_timer_user_pause()
2030 err = snd_timer_pause(tu->timeri); in snd_timer_user_pause()
2036 static int snd_timer_user_tread(void __user *argp, struct snd_timer_user *tu, in snd_timer_user_tread() argument
2042 if (tu->timeri) /* too late */ in snd_timer_user_tread()
2047 old_tread = tu->tread; in snd_timer_user_tread()
2050 tu->tread = TREAD_FORMAT_NONE; in snd_timer_user_tread()
2053 tu->tread = TREAD_FORMAT_TIME64; in snd_timer_user_tread()
2055 tu->tread = TREAD_FORMAT_TIME32; in snd_timer_user_tread()
2057 if (tu->tread != old_tread && in snd_timer_user_tread()
2058 realloc_user_queue(tu, tu->queue_size) < 0) { in snd_timer_user_tread()
2059 tu->tread = old_tread; in snd_timer_user_tread()
2076 struct snd_timer_user *tu; in __snd_timer_user_ioctl() local
2080 tu = file->private_data; in __snd_timer_user_ioctl()
2088 return snd_timer_user_tread(argp, tu, cmd, compat); in __snd_timer_user_ioctl()
2124 struct snd_timer_user *tu = file->private_data; in snd_timer_user_ioctl() local
2127 mutex_lock(&tu->ioctl_lock); in snd_timer_user_ioctl()
2129 mutex_unlock(&tu->ioctl_lock); in snd_timer_user_ioctl()
2135 struct snd_timer_user *tu; in snd_timer_user_fasync() local
2137 tu = file->private_data; in snd_timer_user_fasync()
2138 return fasync_helper(fd, file, on, &tu->fasync); in snd_timer_user_fasync()
2146 struct snd_timer_user *tu; in snd_timer_user_read() local
2151 tu = file->private_data; in snd_timer_user_read()
2152 switch (tu->tread) { in snd_timer_user_read()
2167 mutex_lock(&tu->ioctl_lock); in snd_timer_user_read()
2168 spin_lock_irq(&tu->qlock); in snd_timer_user_read()
2170 while (!tu->qused) { in snd_timer_user_read()
2180 add_wait_queue(&tu->qchange_sleep, &wait); in snd_timer_user_read()
2182 spin_unlock_irq(&tu->qlock); in snd_timer_user_read()
2183 mutex_unlock(&tu->ioctl_lock); in snd_timer_user_read()
2185 mutex_lock(&tu->ioctl_lock); in snd_timer_user_read()
2186 spin_lock_irq(&tu->qlock); in snd_timer_user_read()
2188 remove_wait_queue(&tu->qchange_sleep, &wait); in snd_timer_user_read()
2190 if (tu->disconnected) { in snd_timer_user_read()
2200 qhead = tu->qhead++; in snd_timer_user_read()
2201 tu->qhead %= tu->queue_size; in snd_timer_user_read()
2202 tu->qused--; in snd_timer_user_read()
2203 spin_unlock_irq(&tu->qlock); in snd_timer_user_read()
2205 tread = &tu->tqueue[qhead]; in snd_timer_user_read()
2207 switch (tu->tread) { in snd_timer_user_read()
2226 if (copy_to_user(buffer, &tu->queue[qhead], in snd_timer_user_read()
2235 spin_lock_irq(&tu->qlock); in snd_timer_user_read()
2242 spin_unlock_irq(&tu->qlock); in snd_timer_user_read()
2243 mutex_unlock(&tu->ioctl_lock); in snd_timer_user_read()
2250 struct snd_timer_user *tu; in snd_timer_user_poll() local
2252 tu = file->private_data; in snd_timer_user_poll()
2254 poll_wait(file, &tu->qchange_sleep, wait); in snd_timer_user_poll()
2257 spin_lock_irq(&tu->qlock); in snd_timer_user_poll()
2258 if (tu->qused) in snd_timer_user_poll()
2260 if (tu->disconnected) in snd_timer_user_poll()
2262 spin_unlock_irq(&tu->qlock); in snd_timer_user_poll()