Lines Matching defs:runtime

533 	struct snd_pcm_runtime *runtime = substream->runtime;
536 plugin = runtime->oss.plugin_first;
542 runtime->oss.plugin_first = runtime->oss.plugin_last = NULL;
548 struct snd_pcm_runtime *runtime = plugin->plug->runtime;
549 plugin->next = runtime->oss.plugin_first;
551 if (runtime->oss.plugin_first) {
552 runtime->oss.plugin_first->prev = plugin;
553 runtime->oss.plugin_first = plugin;
555 runtime->oss.plugin_last =
556 runtime->oss.plugin_first = plugin;
563 struct snd_pcm_runtime *runtime = plugin->plug->runtime;
565 plugin->prev = runtime->oss.plugin_last;
566 if (runtime->oss.plugin_last) {
567 runtime->oss.plugin_last->next = plugin;
568 runtime->oss.plugin_last = plugin;
570 runtime->oss.plugin_last =
571 runtime->oss.plugin_first = plugin;
579 struct snd_pcm_runtime *runtime = substream->runtime;
581 long bytes = frames_to_bytes(runtime, frames);
582 if (buffer_size == runtime->oss.buffer_bytes)
585 return runtime->oss.buffer_bytes * bytes / buffer_size;
588 u64 bsize = (u64)runtime->oss.buffer_bytes * (u64)bytes;
596 struct snd_pcm_runtime *runtime = substream->runtime;
598 if (buffer_size == runtime->oss.buffer_bytes)
599 return bytes_to_frames(runtime, bytes);
600 return bytes_to_frames(runtime, (buffer_size * bytes) / runtime->oss.buffer_bytes);
604 snd_pcm_uframes_t get_hw_ptr_period(struct snd_pcm_runtime *runtime)
606 return runtime->hw_ptr_interrupt;
681 struct snd_pcm_runtime *runtime = substream->runtime;
698 if (oss_buffer_size > runtime->oss.mmap_bytes)
699 oss_buffer_size = runtime->oss.mmap_bytes;
704 else if (runtime->oss.fragshift) {
705 oss_period_size = 1 << runtime->oss.fragshift;
716 if (runtime->oss.subdivision == 0) {
723 sd = runtime->oss.subdivision;
753 if (s > 0 && runtime->oss.maxfrags && s > runtime->oss.maxfrags)
754 s = runtime->oss.maxfrags;
774 runtime->oss.period_bytes = oss_period_size;
775 runtime->oss.period_frames = 1;
776 runtime->oss.periods = oss_periods;
818 static int lock_params(struct snd_pcm_runtime *runtime)
820 if (mutex_lock_interruptible(&runtime->oss.params_lock))
822 if (atomic_read(&runtime->oss.rw_ref)) {
823 mutex_unlock(&runtime->oss.params_lock);
829 static void unlock_params(struct snd_pcm_runtime *runtime)
831 mutex_unlock(&runtime->oss.params_lock);
836 struct snd_pcm_runtime *runtime = substream->runtime;
838 kvfree(runtime->oss.buffer);
839 runtime->oss.buffer = NULL;
848 struct snd_pcm_runtime *runtime = substream->runtime;
860 if (!runtime->oss.params)
893 err = choose_rate(substream, sparams, runtime->oss.rate);
898 runtime->oss.channels, NULL);
902 format = snd_pcm_oss_format_from(runtime->oss.format);
933 (__force int)snd_pcm_oss_format_from(runtime->oss.format), 0);
935 runtime->oss.channels, 0);
937 runtime->oss.rate, 0);
953 n = snd_pcm_plug_slave_size(substream, runtime->oss.period_bytes / oss_frame_size);
959 runtime->oss.periods, NULL);
981 if (runtime->oss.plugin_first) {
1000 if (runtime->oss.trigger) {
1003 sw_params->start_threshold = runtime->boundary;
1007 sw_params->stop_threshold = runtime->boundary;
1009 sw_params->stop_threshold = runtime->buffer_size;
1013 1 : runtime->period_size;
1020 frames = runtime->period_size + 16;
1021 if (frames > runtime->buffer_size)
1022 frames = runtime->buffer_size;
1033 runtime->oss.periods = params_periods(sparams);
1040 if (runtime->oss.plugin_first) {
1047 oss_buffer_size = array_size(oss_period_size, runtime->oss.periods);
1053 runtime->oss.period_bytes = oss_period_size;
1054 runtime->oss.buffer_bytes = oss_buffer_size;
1057 runtime->oss.period_bytes,
1058 runtime->oss.buffer_bytes);
1063 runtime->oss.format = snd_pcm_oss_format_to(params_format(params));
1064 runtime->oss.channels = params_channels(params);
1065 runtime->oss.rate = params_rate(params);
1067 kvfree(runtime->oss.buffer);
1068 runtime->oss.buffer = kvzalloc(runtime->oss.period_bytes, GFP_KERNEL);
1069 if (!runtime->oss.buffer) {
1074 runtime->oss.params = 0;
1075 runtime->oss.prepare = 1;
1076 runtime->oss.buffer_used = 0;
1077 if (runtime->dma_area)
1078 snd_pcm_format_set_silence(runtime->format, runtime->dma_area, bytes_to_samples(runtime, runtime->dma_bytes));
1080 runtime->oss.period_frames = snd_pcm_alsa_frames(substream, oss_period_size);
1096 struct snd_pcm_runtime *runtime = substream->runtime;
1100 if (!(mutex_trylock(&runtime->oss.params_lock)))
1102 } else if (mutex_lock_interruptible(&runtime->oss.params_lock))
1106 mutex_unlock(&runtime->oss.params_lock);
1121 if (substream->runtime->oss.params) {
1136 * runtime->oss.prepare is set or not
1141 struct snd_pcm_runtime *runtime = substream->runtime;
1149 runtime->oss.prepare = 0;
1150 runtime->oss.prev_hw_ptr_period = 0;
1151 runtime->oss.period_ptr = 0;
1152 runtime->oss.buffer_used = 0;
1159 struct snd_pcm_runtime *runtime;
1162 runtime = substream->runtime;
1163 if (runtime->oss.params) {
1168 if (runtime->oss.prepare) {
1169 if (mutex_lock_interruptible(&runtime->oss.params_lock))
1172 mutex_unlock(&runtime->oss.params_lock);
1182 struct snd_pcm_runtime *runtime;
1185 runtime = substream->runtime;
1186 if (runtime->oss.params) {
1191 if (runtime->oss.prepare) {
1201 struct snd_pcm_runtime *runtime;
1209 runtime = substream->runtime;
1210 if (*delay <= (snd_pcm_sframes_t)runtime->buffer_size)
1214 frames = (*delay - runtime->buffer_size) + runtime->period_size - 1;
1215 frames /= runtime->period_size;
1216 frames *= runtime->period_size;
1226 struct snd_pcm_runtime *runtime = substream->runtime;
1229 if (runtime->state == SNDRV_PCM_STATE_XRUN ||
1230 runtime->state == SNDRV_PCM_STATE_SUSPENDED) {
1234 runtime->state == SNDRV_PCM_STATE_XRUN ?
1241 mutex_unlock(&runtime->oss.params_lock);
1244 mutex_lock(&runtime->oss.params_lock);
1249 if (runtime->state == SNDRV_PCM_STATE_PREPARED)
1257 struct snd_pcm_runtime *runtime = substream->runtime;
1261 if (runtime->state == SNDRV_PCM_STATE_XRUN ||
1262 runtime->state == SNDRV_PCM_STATE_SUSPENDED) {
1266 runtime->state == SNDRV_PCM_STATE_XRUN ?
1272 } else if (runtime->state == SNDRV_PCM_STATE_SETUP) {
1280 mutex_unlock(&runtime->oss.params_lock);
1283 mutex_lock(&runtime->oss.params_lock);
1285 if (runtime->state == SNDRV_PCM_STATE_DRAINING) {
1301 struct snd_pcm_runtime *runtime = substream->runtime;
1304 if (runtime->state == SNDRV_PCM_STATE_XRUN ||
1305 runtime->state == SNDRV_PCM_STATE_SUSPENDED) {
1309 runtime->state == SNDRV_PCM_STATE_XRUN ?
1322 if (runtime->state == SNDRV_PCM_STATE_PREPARED)
1330 struct snd_pcm_runtime *runtime = substream->runtime;
1333 if (runtime->state == SNDRV_PCM_STATE_XRUN ||
1334 runtime->state == SNDRV_PCM_STATE_SUSPENDED) {
1338 runtime->state == SNDRV_PCM_STATE_XRUN ?
1344 } else if (runtime->state == SNDRV_PCM_STATE_SETUP) {
1359 struct snd_pcm_runtime *runtime = substream->runtime;
1362 if (runtime->oss.plugin_first) {
1364 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
1366 if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
1368 buf = runtime->oss.buffer;
1381 frames = bytes_to_frames(runtime, bytes);
1385 bytes = frames_to_bytes(runtime, frames1);
1394 struct snd_pcm_runtime *runtime = substream->runtime;
1399 atomic_inc(&runtime->oss.rw_ref);
1401 if (mutex_lock_interruptible(&runtime->oss.params_lock)) {
1408 if (bytes < runtime->oss.period_bytes || runtime->oss.buffer_used > 0) {
1410 if (tmp + runtime->oss.buffer_used > runtime->oss.period_bytes)
1411 tmp = runtime->oss.period_bytes - runtime->oss.buffer_used;
1413 if (copy_from_user(runtime->oss.buffer + runtime->oss.buffer_used, buf, tmp)) {
1418 runtime->oss.buffer_used += tmp;
1423 runtime->oss.buffer_used == runtime->oss.period_bytes) {
1424 tmp = snd_pcm_oss_write2(substream, runtime->oss.buffer + runtime->oss.period_ptr,
1425 runtime->oss.buffer_used - runtime->oss.period_ptr, 1);
1428 runtime->oss.bytes += tmp;
1429 runtime->oss.period_ptr += tmp;
1430 runtime->oss.period_ptr %= runtime->oss.period_bytes;
1431 if (runtime->oss.period_ptr == 0 ||
1432 runtime->oss.period_ptr == runtime->oss.buffer_used)
1433 runtime->oss.buffer_used = 0;
1442 runtime->oss.period_bytes, 0);
1445 runtime->oss.bytes += tmp;
1450 tmp != runtime->oss.period_bytes)
1454 mutex_unlock(&runtime->oss.params_lock);
1463 atomic_dec(&runtime->oss.rw_ref);
1469 struct snd_pcm_runtime *runtime = substream->runtime;
1473 if (runtime->oss.plugin_first) {
1475 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
1477 buf = runtime->oss.buffer;
1491 frames = bytes_to_frames(runtime, bytes);
1495 bytes = frames_to_bytes(runtime, frames1);
1504 struct snd_pcm_runtime *runtime = substream->runtime;
1509 atomic_inc(&runtime->oss.rw_ref);
1511 if (mutex_lock_interruptible(&runtime->oss.params_lock)) {
1518 if (bytes < runtime->oss.period_bytes || runtime->oss.buffer_used > 0) {
1519 if (runtime->oss.buffer_used == 0) {
1520 tmp = snd_pcm_oss_read2(substream, runtime->oss.buffer, runtime->oss.period_bytes, 1);
1523 runtime->oss.bytes += tmp;
1524 runtime->oss.period_ptr = tmp;
1525 runtime->oss.buffer_used = tmp;
1528 if ((size_t) tmp > runtime->oss.buffer_used)
1529 tmp = runtime->oss.buffer_used;
1530 if (copy_to_user(buf, runtime->oss.buffer + (runtime->oss.period_ptr - runtime->oss.buffer_used), tmp)) {
1537 runtime->oss.buffer_used -= tmp;
1540 runtime->oss.period_bytes, 0);
1543 runtime->oss.bytes += tmp;
1549 mutex_unlock(&runtime->oss.params_lock);
1558 atomic_dec(&runtime->oss.rw_ref);
1565 struct snd_pcm_runtime *runtime;
1572 runtime = substream->runtime;
1574 mutex_lock(&runtime->oss.params_lock);
1575 runtime->oss.prepare = 1;
1576 runtime->oss.buffer_used = 0;
1577 runtime->oss.prev_hw_ptr_period = 0;
1578 runtime->oss.period_ptr = 0;
1579 mutex_unlock(&runtime->oss.params_lock);
1603 struct snd_pcm_runtime *runtime;
1609 runtime = substream->runtime;
1611 add_wait_queue(&runtime->sleep, &wait);
1616 result = snd_pcm_oss_write2(substream, runtime->oss.buffer, size, 1);
1618 runtime->oss.buffer_used = 0;
1627 state = runtime->state;
1644 remove_wait_queue(&runtime->sleep, &wait);
1653 struct snd_pcm_runtime *runtime;
1660 runtime = substream->runtime;
1663 atomic_inc(&runtime->oss.rw_ref);
1664 if (mutex_lock_interruptible(&runtime->oss.params_lock)) {
1665 atomic_dec(&runtime->oss.rw_ref);
1671 format = snd_pcm_oss_format_from(runtime->oss.format);
1673 if (runtime->oss.buffer_used > 0) {
1677 size = (8 * (runtime->oss.period_bytes - runtime->oss.buffer_used) + 7) / width;
1679 runtime->oss.buffer + runtime->oss.buffer_used,
1681 err = snd_pcm_oss_sync1(substream, runtime->oss.period_bytes);
1684 } else if (runtime->oss.period_ptr > 0) {
1688 size = runtime->oss.period_bytes - runtime->oss.period_ptr;
1690 runtime->oss.buffer,
1700 size = runtime->control->appl_ptr % runtime->period_size;
1702 size = runtime->period_size - size;
1703 if (runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED)
1705 else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED)
1709 mutex_unlock(&runtime->oss.params_lock);
1710 atomic_dec(&runtime->oss.rw_ref);
1723 mutex_lock(&runtime->oss.params_lock);
1724 runtime->oss.prepare = 1;
1725 mutex_unlock(&runtime->oss.params_lock);
1733 runtime = substream->runtime;
1737 mutex_lock(&runtime->oss.params_lock);
1738 runtime->oss.buffer_used = 0;
1739 runtime->oss.prepare = 1;
1740 mutex_unlock(&runtime->oss.params_lock);
1751 struct snd_pcm_runtime *runtime;
1756 runtime = substream->runtime;
1761 err = lock_params(runtime);
1764 if (runtime->oss.rate != rate) {
1765 runtime->oss.params = 1;
1766 runtime->oss.rate = rate;
1768 unlock_params(runtime);
1781 return substream->runtime->oss.rate;
1793 struct snd_pcm_runtime *runtime;
1798 runtime = substream->runtime;
1799 err = lock_params(runtime);
1802 if (runtime->oss.channels != channels) {
1803 runtime->oss.params = 1;
1804 runtime->oss.channels = channels;
1806 unlock_params(runtime);
1819 return substream->runtime->oss.channels;
1830 return substream->runtime->oss.period_bytes;
1890 struct snd_pcm_runtime *runtime;
1893 runtime = substream->runtime;
1894 err = lock_params(runtime);
1897 if (runtime->oss.format != format) {
1898 runtime->oss.params = 1;
1899 runtime->oss.format = format;
1901 unlock_params(runtime);
1915 return substream->runtime->oss.format;
1920 struct snd_pcm_runtime *runtime;
1922 runtime = substream->runtime;
1924 subdivide = runtime->oss.subdivision;
1929 if (runtime->oss.subdivision || runtime->oss.fragshift)
1934 runtime->oss.subdivision = subdivide;
1935 runtime->oss.params = 1;
1945 struct snd_pcm_runtime *runtime;
1949 runtime = substream->runtime;
1950 err = lock_params(runtime);
1954 unlock_params(runtime);
1963 struct snd_pcm_runtime *runtime;
1966 runtime = substream->runtime;
1967 if (runtime->oss.subdivision || runtime->oss.fragshift)
1972 runtime->oss.fragshift = fragshift;
1973 runtime->oss.maxfrags = (val >> 16) & 0xffff;
1974 if (runtime->oss.fragshift < 4) /* < 16 */
1975 runtime->oss.fragshift = 4;
1976 if (runtime->oss.maxfrags < 2)
1977 runtime->oss.maxfrags = 2;
1978 runtime->oss.params = 1;
1988 struct snd_pcm_runtime *runtime;
1992 runtime = substream->runtime;
1993 err = lock_params(runtime);
1997 unlock_params(runtime);
2028 struct snd_pcm_runtime *runtime = substream->runtime;
2029 if (runtime->info & (SNDRV_PCM_INFO_BLOCK_TRANSFER|SNDRV_PCM_INFO_BATCH))
2052 struct snd_pcm_runtime *runtime = substream->runtime;
2054 appl_ptr = hw_ptr + runtime->buffer_size;
2055 appl_ptr %= runtime->boundary;
2056 runtime->control->appl_ptr = appl_ptr;
2061 struct snd_pcm_runtime *runtime;
2083 runtime = psubstream->runtime;
2085 if (mutex_lock_interruptible(&runtime->oss.params_lock))
2088 if (runtime->oss.trigger)
2092 get_hw_ptr_period(runtime));
2093 runtime->oss.trigger = 1;
2094 runtime->start_threshold = 1;
2097 if (!runtime->oss.trigger)
2099 runtime->oss.trigger = 0;
2100 runtime->start_threshold = runtime->boundary;
2102 runtime->oss.prepare = 1;
2105 mutex_unlock(&runtime->oss.params_lock);
2113 runtime = csubstream->runtime;
2115 if (mutex_lock_interruptible(&runtime->oss.params_lock))
2118 if (runtime->oss.trigger)
2120 runtime->oss.trigger = 1;
2121 runtime->start_threshold = 1;
2124 if (!runtime->oss.trigger)
2126 runtime->oss.trigger = 0;
2127 runtime->start_threshold = runtime->boundary;
2129 runtime->oss.prepare = 1;
2132 mutex_unlock(&runtime->oss.params_lock);
2149 if (psubstream && psubstream->runtime && psubstream->runtime->oss.trigger)
2151 if (csubstream && csubstream->runtime && csubstream->runtime->oss.trigger)
2159 struct snd_pcm_runtime *runtime;
2169 runtime = substream->runtime;
2170 if (runtime->oss.params || runtime->oss.prepare)
2183 struct snd_pcm_runtime *runtime;
2197 runtime = substream->runtime;
2198 if (runtime->oss.params || runtime->oss.prepare) {
2211 fixup = runtime->oss.buffer_used;
2215 fixup = -runtime->oss.buffer_used;
2219 info.ptr = snd_pcm_oss_bytes(substream, runtime->status->hw_ptr % runtime->buffer_size);
2222 delay = get_hw_ptr_period(runtime);
2223 n = delay - runtime->oss.prev_hw_ptr_period;
2225 n += runtime->boundary;
2226 info.blocks = n / runtime->period_size;
2227 runtime->oss.prev_hw_ptr_period = delay;
2230 info.bytes = snd_pcm_oss_bytes(substream, runtime->status->hw_ptr) & INT_MAX;
2235 info.blocks = (runtime->oss.buffer_bytes - delay - fixup) / runtime->oss.period_bytes;
2237 info.blocks = (delay + fixup) / runtime->oss.period_bytes;
2238 info.bytes = (runtime->oss.bytes - delay) & INT_MAX;
2241 info.blocks = delay / runtime->oss.period_bytes;
2242 info.bytes = (runtime->oss.bytes + delay) & INT_MAX;
2253 struct snd_pcm_runtime *runtime;
2264 runtime = substream->runtime;
2266 if (runtime->oss.params) {
2272 info.fragsize = runtime->oss.period_bytes;
2273 info.fragstotal = runtime->periods;
2274 if (runtime->oss.prepare) {
2276 info.bytes = runtime->oss.period_bytes * runtime->oss.periods;
2277 info.fragments = runtime->oss.periods;
2286 avail = runtime->buffer_size;
2290 avail = runtime->buffer_size - avail;
2291 fixup = -runtime->oss.buffer_used;
2295 fixup = runtime->oss.buffer_used;
2300 info.fragments = info.bytes / runtime->oss.period_bytes;
2359 struct snd_pcm_runtime *runtime;
2367 runtime = substream->runtime;
2368 runtime->oss.params = 1;
2369 runtime->oss.trigger = 1;
2370 runtime->oss.rate = 8000;
2371 mutex_init(&runtime->oss.params_lock);
2374 runtime->oss.format = AFMT_U8;
2377 runtime->oss.format = AFMT_S16_LE;
2380 runtime->oss.format = AFMT_MU_LAW;
2382 runtime->oss.channels = 1;
2383 runtime->oss.fragshift = 0;
2384 runtime->oss.maxfrags = 0;
2385 runtime->oss.subdivision = 0;
2387 atomic_set(&runtime->oss.rw_ref, 0);
2806 struct snd_pcm_runtime *runtime = substream->runtime;
2808 return runtime->oss.prev_hw_ptr_period !=
2809 get_hw_ptr_period(runtime);
2811 return snd_pcm_playback_avail(runtime) >=
2812 runtime->oss.period_frames;
2817 struct snd_pcm_runtime *runtime = substream->runtime;
2819 return runtime->oss.prev_hw_ptr_period !=
2820 get_hw_ptr_period(runtime);
2822 return snd_pcm_capture_avail(runtime) >=
2823 runtime->oss.period_frames;
2839 struct snd_pcm_runtime *runtime = psubstream->runtime;
2840 poll_wait(file, &runtime->sleep, wait);
2842 if (runtime->state != SNDRV_PCM_STATE_DRAINING &&
2843 (runtime->state != SNDRV_PCM_STATE_RUNNING ||
2849 struct snd_pcm_runtime *runtime = csubstream->runtime;
2851 poll_wait(file, &runtime->sleep, wait);
2853 ostate = runtime->state;
2858 if (ostate != SNDRV_PCM_STATE_RUNNING && runtime->oss.trigger) {
2862 runtime->oss.trigger = 0;
2874 struct snd_pcm_runtime *runtime;
2901 runtime = substream->runtime;
2902 if (!(runtime->info & SNDRV_PCM_INFO_MMAP_VALID))
2904 if (runtime->info & SNDRV_PCM_INFO_INTERLEAVED)
2905 runtime->access = SNDRV_PCM_ACCESS_MMAP_INTERLEAVED;
2909 if (runtime->oss.params) {
2919 if (runtime->oss.plugin_first != NULL)
2929 runtime->oss.mmap_bytes = area->vm_end - area->vm_start;
2930 runtime->silence_threshold = 0;
2931 runtime->silence_size = 0;
2934 runtime->oss.mmap_bytes);
2937 runtime->stop_threshold = runtime->boundary;