Lines Matching refs:tu

1328 	struct snd_timer_user *tu = timeri->callback_data;  in snd_timer_user_interrupt()  local
1332 spin_lock(&tu->qlock); in snd_timer_user_interrupt()
1333 if (tu->qused > 0) { in snd_timer_user_interrupt()
1334 prev = tu->qtail == 0 ? tu->queue_size - 1 : tu->qtail - 1; in snd_timer_user_interrupt()
1335 r = &tu->queue[prev]; in snd_timer_user_interrupt()
1341 if (tu->qused >= tu->queue_size) { in snd_timer_user_interrupt()
1342 tu->overrun++; in snd_timer_user_interrupt()
1344 r = &tu->queue[tu->qtail++]; in snd_timer_user_interrupt()
1345 tu->qtail %= tu->queue_size; in snd_timer_user_interrupt()
1348 tu->qused++; in snd_timer_user_interrupt()
1351 spin_unlock(&tu->qlock); in snd_timer_user_interrupt()
1352 snd_kill_fasync(tu->fasync, SIGIO, POLL_IN); in snd_timer_user_interrupt()
1353 wake_up(&tu->qchange_sleep); in snd_timer_user_interrupt()
1356 static void snd_timer_user_append_to_tqueue(struct snd_timer_user *tu, in snd_timer_user_append_to_tqueue() argument
1359 if (tu->qused >= tu->queue_size) { in snd_timer_user_append_to_tqueue()
1360 tu->overrun++; in snd_timer_user_append_to_tqueue()
1362 memcpy(&tu->tqueue[tu->qtail++], tread, sizeof(*tread)); in snd_timer_user_append_to_tqueue()
1363 tu->qtail %= tu->queue_size; in snd_timer_user_append_to_tqueue()
1364 tu->qused++; in snd_timer_user_append_to_tqueue()
1373 struct snd_timer_user *tu = timeri->callback_data; in snd_timer_user_ccallback() local
1379 tu->tstamp = *tstamp; in snd_timer_user_ccallback()
1380 if ((tu->filter & (1 << event)) == 0 || !tu->tread) in snd_timer_user_ccallback()
1387 spin_lock_irqsave(&tu->qlock, flags); in snd_timer_user_ccallback()
1388 snd_timer_user_append_to_tqueue(tu, &r1); in snd_timer_user_ccallback()
1389 spin_unlock_irqrestore(&tu->qlock, flags); in snd_timer_user_ccallback()
1390 snd_kill_fasync(tu->fasync, SIGIO, POLL_IN); in snd_timer_user_ccallback()
1391 wake_up(&tu->qchange_sleep); in snd_timer_user_ccallback()
1396 struct snd_timer_user *tu = timeri->callback_data; in snd_timer_user_disconnect() local
1398 tu->disconnected = true; in snd_timer_user_disconnect()
1399 wake_up(&tu->qchange_sleep); in snd_timer_user_disconnect()
1406 struct snd_timer_user *tu = timeri->callback_data; in snd_timer_user_tinterrupt() local
1413 spin_lock(&tu->qlock); in snd_timer_user_tinterrupt()
1414 if ((tu->filter & ((1 << SNDRV_TIMER_EVENT_RESOLUTION) | in snd_timer_user_tinterrupt()
1416 spin_unlock(&tu->qlock); in snd_timer_user_tinterrupt()
1419 if (tu->last_resolution != resolution || ticks > 0) { in snd_timer_user_tinterrupt()
1425 if ((tu->filter & (1 << SNDRV_TIMER_EVENT_RESOLUTION)) && in snd_timer_user_tinterrupt()
1426 tu->last_resolution != resolution) { in snd_timer_user_tinterrupt()
1431 snd_timer_user_append_to_tqueue(tu, &r1); in snd_timer_user_tinterrupt()
1432 tu->last_resolution = resolution; in snd_timer_user_tinterrupt()
1435 if ((tu->filter & (1 << SNDRV_TIMER_EVENT_TICK)) == 0) in snd_timer_user_tinterrupt()
1439 if (tu->qused > 0) { in snd_timer_user_tinterrupt()
1440 prev = tu->qtail == 0 ? tu->queue_size - 1 : tu->qtail - 1; in snd_timer_user_tinterrupt()
1441 r = &tu->tqueue[prev]; in snd_timer_user_tinterrupt()
1454 snd_timer_user_append_to_tqueue(tu, &r1); in snd_timer_user_tinterrupt()
1457 spin_unlock(&tu->qlock); in snd_timer_user_tinterrupt()
1460 snd_kill_fasync(tu->fasync, SIGIO, POLL_IN); in snd_timer_user_tinterrupt()
1461 wake_up(&tu->qchange_sleep); in snd_timer_user_tinterrupt()
1464 static int realloc_user_queue(struct snd_timer_user *tu, int size) in realloc_user_queue() argument
1469 if (tu->tread) { in realloc_user_queue()
1479 spin_lock_irq(&tu->qlock); in realloc_user_queue()
1480 kfree(tu->queue); in realloc_user_queue()
1481 kfree(tu->tqueue); in realloc_user_queue()
1482 tu->queue_size = size; in realloc_user_queue()
1483 tu->queue = queue; in realloc_user_queue()
1484 tu->tqueue = tqueue; in realloc_user_queue()
1485 tu->qhead = tu->qtail = tu->qused = 0; in realloc_user_queue()
1486 spin_unlock_irq(&tu->qlock); in realloc_user_queue()
1493 struct snd_timer_user *tu; in snd_timer_user_open() local
1500 tu = kzalloc(sizeof(*tu), GFP_KERNEL); in snd_timer_user_open()
1501 if (tu == NULL) in snd_timer_user_open()
1503 spin_lock_init(&tu->qlock); in snd_timer_user_open()
1504 init_waitqueue_head(&tu->qchange_sleep); in snd_timer_user_open()
1505 mutex_init(&tu->ioctl_lock); in snd_timer_user_open()
1506 tu->ticks = 1; in snd_timer_user_open()
1507 if (realloc_user_queue(tu, 128) < 0) { in snd_timer_user_open()
1508 kfree(tu); in snd_timer_user_open()
1511 file->private_data = tu; in snd_timer_user_open()
1517 struct snd_timer_user *tu; in snd_timer_user_release() local
1520 tu = file->private_data; in snd_timer_user_release()
1522 mutex_lock(&tu->ioctl_lock); in snd_timer_user_release()
1523 if (tu->timeri) { in snd_timer_user_release()
1524 snd_timer_close(tu->timeri); in snd_timer_user_release()
1525 snd_timer_instance_free(tu->timeri); in snd_timer_user_release()
1527 mutex_unlock(&tu->ioctl_lock); in snd_timer_user_release()
1528 snd_fasync_free(tu->fasync); in snd_timer_user_release()
1529 kfree(tu->queue); in snd_timer_user_release()
1530 kfree(tu->tqueue); in snd_timer_user_release()
1531 kfree(tu); in snd_timer_user_release()
1762 struct snd_timer_user *tu; in snd_timer_user_tselect() local
1767 tu = file->private_data; in snd_timer_user_tselect()
1768 if (tu->timeri) { in snd_timer_user_tselect()
1769 snd_timer_close(tu->timeri); in snd_timer_user_tselect()
1770 snd_timer_instance_free(tu->timeri); in snd_timer_user_tselect()
1771 tu->timeri = NULL; in snd_timer_user_tselect()
1780 tu->timeri = snd_timer_instance_new(str); in snd_timer_user_tselect()
1781 if (!tu->timeri) { in snd_timer_user_tselect()
1786 tu->timeri->flags |= SNDRV_TIMER_IFLG_FAST; in snd_timer_user_tselect()
1787 tu->timeri->callback = tu->tread in snd_timer_user_tselect()
1789 tu->timeri->ccallback = snd_timer_user_ccallback; in snd_timer_user_tselect()
1790 tu->timeri->callback_data = (void *)tu; in snd_timer_user_tselect()
1791 tu->timeri->disconnect = snd_timer_user_disconnect; in snd_timer_user_tselect()
1793 err = snd_timer_open(tu->timeri, &tselect.id, current->pid); in snd_timer_user_tselect()
1795 snd_timer_instance_free(tu->timeri); in snd_timer_user_tselect()
1796 tu->timeri = NULL; in snd_timer_user_tselect()
1806 struct snd_timer_user *tu; in snd_timer_user_info() local
1811 tu = file->private_data; in snd_timer_user_info()
1812 if (!tu->timeri) in snd_timer_user_info()
1814 t = tu->timeri->timer; in snd_timer_user_info()
1838 struct snd_timer_user *tu; in snd_timer_user_params() local
1843 tu = file->private_data; in snd_timer_user_params()
1844 if (!tu->timeri) in snd_timer_user_params()
1846 t = tu->timeri->timer; in snd_timer_user_params()
1860 resolution = snd_timer_resolution(tu->timeri); in snd_timer_user_params()
1889 snd_timer_stop(tu->timeri); in snd_timer_user_params()
1891 tu->timeri->flags &= ~(SNDRV_TIMER_IFLG_AUTO| in snd_timer_user_params()
1895 tu->timeri->flags |= SNDRV_TIMER_IFLG_AUTO; in snd_timer_user_params()
1897 tu->timeri->flags |= SNDRV_TIMER_IFLG_EXCLUSIVE; in snd_timer_user_params()
1899 tu->timeri->flags |= SNDRV_TIMER_IFLG_EARLY_EVENT; in snd_timer_user_params()
1902 (unsigned int)tu->queue_size != params.queue_size) { in snd_timer_user_params()
1903 err = realloc_user_queue(tu, params.queue_size); in snd_timer_user_params()
1907 spin_lock_irq(&tu->qlock); in snd_timer_user_params()
1908 tu->qhead = tu->qtail = tu->qused = 0; in snd_timer_user_params()
1909 if (tu->timeri->flags & SNDRV_TIMER_IFLG_EARLY_EVENT) { in snd_timer_user_params()
1910 if (tu->tread) { in snd_timer_user_params()
1917 snd_timer_user_append_to_tqueue(tu, &tread); in snd_timer_user_params()
1919 struct snd_timer_read *r = &tu->queue[0]; in snd_timer_user_params()
1922 tu->qused++; in snd_timer_user_params()
1923 tu->qtail++; in snd_timer_user_params()
1926 tu->filter = params.filter; in snd_timer_user_params()
1927 tu->ticks = params.ticks; in snd_timer_user_params()
1928 spin_unlock_irq(&tu->qlock); in snd_timer_user_params()
1939 struct snd_timer_user *tu; in snd_timer_user_status32() local
1942 tu = file->private_data; in snd_timer_user_status32()
1943 if (!tu->timeri) in snd_timer_user_status32()
1946 status.tstamp_sec = tu->tstamp.tv_sec; in snd_timer_user_status32()
1947 status.tstamp_nsec = tu->tstamp.tv_nsec; in snd_timer_user_status32()
1948 status.resolution = snd_timer_resolution(tu->timeri); in snd_timer_user_status32()
1949 status.lost = tu->timeri->lost; in snd_timer_user_status32()
1950 status.overrun = tu->overrun; in snd_timer_user_status32()
1951 spin_lock_irq(&tu->qlock); in snd_timer_user_status32()
1952 status.queue = tu->qused; in snd_timer_user_status32()
1953 spin_unlock_irq(&tu->qlock); in snd_timer_user_status32()
1962 struct snd_timer_user *tu; in snd_timer_user_status64() local
1965 tu = file->private_data; in snd_timer_user_status64()
1966 if (!tu->timeri) in snd_timer_user_status64()
1969 status.tstamp_sec = tu->tstamp.tv_sec; in snd_timer_user_status64()
1970 status.tstamp_nsec = tu->tstamp.tv_nsec; in snd_timer_user_status64()
1971 status.resolution = snd_timer_resolution(tu->timeri); in snd_timer_user_status64()
1972 status.lost = tu->timeri->lost; in snd_timer_user_status64()
1973 status.overrun = tu->overrun; in snd_timer_user_status64()
1974 spin_lock_irq(&tu->qlock); in snd_timer_user_status64()
1975 status.queue = tu->qused; in snd_timer_user_status64()
1976 spin_unlock_irq(&tu->qlock); in snd_timer_user_status64()
1985 struct snd_timer_user *tu; in snd_timer_user_start() local
1987 tu = file->private_data; in snd_timer_user_start()
1988 if (!tu->timeri) in snd_timer_user_start()
1990 snd_timer_stop(tu->timeri); in snd_timer_user_start()
1991 tu->timeri->lost = 0; in snd_timer_user_start()
1992 tu->last_resolution = 0; in snd_timer_user_start()
1993 err = snd_timer_start(tu->timeri, tu->ticks); in snd_timer_user_start()
2002 struct snd_timer_user *tu; in snd_timer_user_stop() local
2004 tu = file->private_data; in snd_timer_user_stop()
2005 if (!tu->timeri) in snd_timer_user_stop()
2007 err = snd_timer_stop(tu->timeri); in snd_timer_user_stop()
2016 struct snd_timer_user *tu; in snd_timer_user_continue() local
2018 tu = file->private_data; in snd_timer_user_continue()
2019 if (!tu->timeri) in snd_timer_user_continue()
2022 if (!(tu->timeri->flags & SNDRV_TIMER_IFLG_PAUSED)) in snd_timer_user_continue()
2024 tu->timeri->lost = 0; in snd_timer_user_continue()
2025 err = snd_timer_continue(tu->timeri); in snd_timer_user_continue()
2034 struct snd_timer_user *tu; in snd_timer_user_pause() local
2036 tu = file->private_data; in snd_timer_user_pause()
2037 if (!tu->timeri) in snd_timer_user_pause()
2039 err = snd_timer_pause(tu->timeri); in snd_timer_user_pause()
2045 static int snd_timer_user_tread(void __user *argp, struct snd_timer_user *tu, in snd_timer_user_tread() argument
2051 if (tu->timeri) /* too late */ in snd_timer_user_tread()
2056 old_tread = tu->tread; in snd_timer_user_tread()
2059 tu->tread = TREAD_FORMAT_NONE; in snd_timer_user_tread()
2062 tu->tread = TREAD_FORMAT_TIME64; in snd_timer_user_tread()
2064 tu->tread = TREAD_FORMAT_TIME32; in snd_timer_user_tread()
2066 if (tu->tread != old_tread && in snd_timer_user_tread()
2067 realloc_user_queue(tu, tu->queue_size) < 0) { in snd_timer_user_tread()
2068 tu->tread = old_tread; in snd_timer_user_tread()
2085 struct snd_timer_user *tu; in __snd_timer_user_ioctl() local
2089 tu = file->private_data; in __snd_timer_user_ioctl()
2097 return snd_timer_user_tread(argp, tu, cmd, compat); in __snd_timer_user_ioctl()
2133 struct snd_timer_user *tu = file->private_data; in snd_timer_user_ioctl() local
2136 mutex_lock(&tu->ioctl_lock); in snd_timer_user_ioctl()
2138 mutex_unlock(&tu->ioctl_lock); in snd_timer_user_ioctl()
2144 struct snd_timer_user *tu; in snd_timer_user_fasync() local
2146 tu = file->private_data; in snd_timer_user_fasync()
2147 return snd_fasync_helper(fd, file, on, &tu->fasync); in snd_timer_user_fasync()
2155 struct snd_timer_user *tu; in snd_timer_user_read() local
2160 tu = file->private_data; in snd_timer_user_read()
2161 switch (tu->tread) { in snd_timer_user_read()
2176 mutex_lock(&tu->ioctl_lock); in snd_timer_user_read()
2177 spin_lock_irq(&tu->qlock); in snd_timer_user_read()
2179 while (!tu->qused) { in snd_timer_user_read()
2189 add_wait_queue(&tu->qchange_sleep, &wait); in snd_timer_user_read()
2191 spin_unlock_irq(&tu->qlock); in snd_timer_user_read()
2192 mutex_unlock(&tu->ioctl_lock); in snd_timer_user_read()
2194 mutex_lock(&tu->ioctl_lock); in snd_timer_user_read()
2195 spin_lock_irq(&tu->qlock); in snd_timer_user_read()
2197 remove_wait_queue(&tu->qchange_sleep, &wait); in snd_timer_user_read()
2199 if (tu->disconnected) { in snd_timer_user_read()
2209 qhead = tu->qhead++; in snd_timer_user_read()
2210 tu->qhead %= tu->queue_size; in snd_timer_user_read()
2211 tu->qused--; in snd_timer_user_read()
2212 spin_unlock_irq(&tu->qlock); in snd_timer_user_read()
2214 tread = &tu->tqueue[qhead]; in snd_timer_user_read()
2216 switch (tu->tread) { in snd_timer_user_read()
2235 if (copy_to_user(buffer, &tu->queue[qhead], in snd_timer_user_read()
2244 spin_lock_irq(&tu->qlock); in snd_timer_user_read()
2251 spin_unlock_irq(&tu->qlock); in snd_timer_user_read()
2252 mutex_unlock(&tu->ioctl_lock); in snd_timer_user_read()
2259 struct snd_timer_user *tu; in snd_timer_user_poll() local
2261 tu = file->private_data; in snd_timer_user_poll()
2263 poll_wait(file, &tu->qchange_sleep, wait); in snd_timer_user_poll()
2266 spin_lock_irq(&tu->qlock); in snd_timer_user_poll()
2267 if (tu->qused) in snd_timer_user_poll()
2269 if (tu->disconnected) in snd_timer_user_poll()
2271 spin_unlock_irq(&tu->qlock); in snd_timer_user_poll()