Lines Matching refs:runtime

541 	struct snd_pcm_runtime *runtime = substream->runtime;  in snd_pcm_oss_plugin_clear()  local
544 plugin = runtime->oss.plugin_first; in snd_pcm_oss_plugin_clear()
550 runtime->oss.plugin_first = runtime->oss.plugin_last = NULL; in snd_pcm_oss_plugin_clear()
556 struct snd_pcm_runtime *runtime = plugin->plug->runtime; in snd_pcm_plugin_insert() local
557 plugin->next = runtime->oss.plugin_first; in snd_pcm_plugin_insert()
559 if (runtime->oss.plugin_first) { in snd_pcm_plugin_insert()
560 runtime->oss.plugin_first->prev = plugin; in snd_pcm_plugin_insert()
561 runtime->oss.plugin_first = plugin; in snd_pcm_plugin_insert()
563 runtime->oss.plugin_last = in snd_pcm_plugin_insert()
564 runtime->oss.plugin_first = plugin; in snd_pcm_plugin_insert()
571 struct snd_pcm_runtime *runtime = plugin->plug->runtime; in snd_pcm_plugin_append() local
573 plugin->prev = runtime->oss.plugin_last; in snd_pcm_plugin_append()
574 if (runtime->oss.plugin_last) { in snd_pcm_plugin_append()
575 runtime->oss.plugin_last->next = plugin; in snd_pcm_plugin_append()
576 runtime->oss.plugin_last = plugin; in snd_pcm_plugin_append()
578 runtime->oss.plugin_last = in snd_pcm_plugin_append()
579 runtime->oss.plugin_first = plugin; in snd_pcm_plugin_append()
587 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_oss_bytes() local
589 long bytes = frames_to_bytes(runtime, frames); in snd_pcm_oss_bytes()
590 if (buffer_size == runtime->oss.buffer_bytes) in snd_pcm_oss_bytes()
593 return runtime->oss.buffer_bytes * bytes / buffer_size; in snd_pcm_oss_bytes()
596 u64 bsize = (u64)runtime->oss.buffer_bytes * (u64)bytes; in snd_pcm_oss_bytes()
604 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_alsa_frames() local
606 if (buffer_size == runtime->oss.buffer_bytes) in snd_pcm_alsa_frames()
607 return bytes_to_frames(runtime, bytes); in snd_pcm_alsa_frames()
608 return bytes_to_frames(runtime, (buffer_size * bytes) / runtime->oss.buffer_bytes); in snd_pcm_alsa_frames()
612 snd_pcm_uframes_t get_hw_ptr_period(struct snd_pcm_runtime *runtime) in get_hw_ptr_period() argument
614 return runtime->hw_ptr_interrupt; in get_hw_ptr_period()
689 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_oss_period_size() local
706 if (oss_buffer_size > runtime->oss.mmap_bytes) in snd_pcm_oss_period_size()
707 oss_buffer_size = runtime->oss.mmap_bytes; in snd_pcm_oss_period_size()
712 else if (runtime->oss.fragshift) { in snd_pcm_oss_period_size()
713 oss_period_size = 1 << runtime->oss.fragshift; in snd_pcm_oss_period_size()
724 if (runtime->oss.subdivision == 0) { in snd_pcm_oss_period_size()
731 sd = runtime->oss.subdivision; in snd_pcm_oss_period_size()
761 if (s > 0 && runtime->oss.maxfrags && s > runtime->oss.maxfrags) in snd_pcm_oss_period_size()
762 s = runtime->oss.maxfrags; in snd_pcm_oss_period_size()
777 runtime->oss.period_bytes = oss_period_size; in snd_pcm_oss_period_size()
778 runtime->oss.period_frames = 1; in snd_pcm_oss_period_size()
779 runtime->oss.periods = oss_periods; in snd_pcm_oss_period_size()
824 static int lock_params(struct snd_pcm_runtime *runtime) in lock_params() argument
826 if (mutex_lock_interruptible(&runtime->oss.params_lock)) in lock_params()
828 if (atomic_read(&runtime->oss.rw_ref)) { in lock_params()
829 mutex_unlock(&runtime->oss.params_lock); in lock_params()
835 static void unlock_params(struct snd_pcm_runtime *runtime) in unlock_params() argument
837 mutex_unlock(&runtime->oss.params_lock); in unlock_params()
843 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_oss_change_params_locked() local
855 if (!runtime->oss.params) in snd_pcm_oss_change_params_locked()
888 err = choose_rate(substream, sparams, runtime->oss.rate); in snd_pcm_oss_change_params_locked()
893 runtime->oss.channels, NULL); in snd_pcm_oss_change_params_locked()
897 format = snd_pcm_oss_format_from(runtime->oss.format); in snd_pcm_oss_change_params_locked()
928 (__force int)snd_pcm_oss_format_from(runtime->oss.format), 0); in snd_pcm_oss_change_params_locked()
930 runtime->oss.channels, 0); in snd_pcm_oss_change_params_locked()
932 runtime->oss.rate, 0); in snd_pcm_oss_change_params_locked()
948 n = snd_pcm_plug_slave_size(substream, runtime->oss.period_bytes / oss_frame_size); in snd_pcm_oss_change_params_locked()
954 runtime->oss.periods, NULL); in snd_pcm_oss_change_params_locked()
978 if (runtime->oss.plugin_first) { in snd_pcm_oss_change_params_locked()
1000 if (runtime->oss.trigger) { in snd_pcm_oss_change_params_locked()
1003 sw_params->start_threshold = runtime->boundary; in snd_pcm_oss_change_params_locked()
1007 sw_params->stop_threshold = runtime->boundary; in snd_pcm_oss_change_params_locked()
1009 sw_params->stop_threshold = runtime->buffer_size; in snd_pcm_oss_change_params_locked()
1013 1 : runtime->period_size; in snd_pcm_oss_change_params_locked()
1020 frames = runtime->period_size + 16; in snd_pcm_oss_change_params_locked()
1021 if (frames > runtime->buffer_size) in snd_pcm_oss_change_params_locked()
1022 frames = runtime->buffer_size; in snd_pcm_oss_change_params_locked()
1033 runtime->oss.periods = params_periods(sparams); in snd_pcm_oss_change_params_locked()
1040 if (runtime->oss.plugin_first) { in snd_pcm_oss_change_params_locked()
1048 oss_buffer_size = oss_period_size * runtime->oss.periods; in snd_pcm_oss_change_params_locked()
1054 runtime->oss.period_bytes = oss_period_size; in snd_pcm_oss_change_params_locked()
1055 runtime->oss.buffer_bytes = oss_buffer_size; in snd_pcm_oss_change_params_locked()
1058 runtime->oss.period_bytes, in snd_pcm_oss_change_params_locked()
1059 runtime->oss.buffer_bytes); in snd_pcm_oss_change_params_locked()
1064 runtime->oss.format = snd_pcm_oss_format_to(params_format(params)); in snd_pcm_oss_change_params_locked()
1065 runtime->oss.channels = params_channels(params); in snd_pcm_oss_change_params_locked()
1066 runtime->oss.rate = params_rate(params); in snd_pcm_oss_change_params_locked()
1068 kvfree(runtime->oss.buffer); in snd_pcm_oss_change_params_locked()
1069 runtime->oss.buffer = kvzalloc(runtime->oss.period_bytes, GFP_KERNEL); in snd_pcm_oss_change_params_locked()
1070 if (!runtime->oss.buffer) { in snd_pcm_oss_change_params_locked()
1075 runtime->oss.params = 0; in snd_pcm_oss_change_params_locked()
1076 runtime->oss.prepare = 1; in snd_pcm_oss_change_params_locked()
1077 runtime->oss.buffer_used = 0; in snd_pcm_oss_change_params_locked()
1078 if (runtime->dma_area) in snd_pcm_oss_change_params_locked()
1079 …snd_pcm_format_set_silence(runtime->format, runtime->dma_area, bytes_to_samples(runtime, runtime->… in snd_pcm_oss_change_params_locked()
1081 runtime->oss.period_frames = snd_pcm_alsa_frames(substream, oss_period_size); in snd_pcm_oss_change_params_locked()
1095 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_oss_change_params() local
1099 if (!(mutex_trylock(&runtime->oss.params_lock))) in snd_pcm_oss_change_params()
1101 } else if (mutex_lock_interruptible(&runtime->oss.params_lock)) in snd_pcm_oss_change_params()
1105 mutex_unlock(&runtime->oss.params_lock); in snd_pcm_oss_change_params()
1120 if (substream->runtime->oss.params) { in snd_pcm_oss_get_active_substream()
1140 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_oss_prepare() local
1148 runtime->oss.prepare = 0; in snd_pcm_oss_prepare()
1149 runtime->oss.prev_hw_ptr_period = 0; in snd_pcm_oss_prepare()
1150 runtime->oss.period_ptr = 0; in snd_pcm_oss_prepare()
1151 runtime->oss.buffer_used = 0; in snd_pcm_oss_prepare()
1158 struct snd_pcm_runtime *runtime; in snd_pcm_oss_make_ready() local
1161 runtime = substream->runtime; in snd_pcm_oss_make_ready()
1162 if (runtime->oss.params) { in snd_pcm_oss_make_ready()
1167 if (runtime->oss.prepare) { in snd_pcm_oss_make_ready()
1168 if (mutex_lock_interruptible(&runtime->oss.params_lock)) in snd_pcm_oss_make_ready()
1171 mutex_unlock(&runtime->oss.params_lock); in snd_pcm_oss_make_ready()
1181 struct snd_pcm_runtime *runtime; in snd_pcm_oss_make_ready_locked() local
1184 runtime = substream->runtime; in snd_pcm_oss_make_ready_locked()
1185 if (runtime->oss.params) { in snd_pcm_oss_make_ready_locked()
1190 if (runtime->oss.prepare) { in snd_pcm_oss_make_ready_locked()
1200 struct snd_pcm_runtime *runtime; in snd_pcm_oss_capture_position_fixup() local
1208 runtime = substream->runtime; in snd_pcm_oss_capture_position_fixup()
1209 if (*delay <= (snd_pcm_sframes_t)runtime->buffer_size) in snd_pcm_oss_capture_position_fixup()
1213 frames = (*delay - runtime->buffer_size) + runtime->period_size - 1; in snd_pcm_oss_capture_position_fixup()
1214 frames /= runtime->period_size; in snd_pcm_oss_capture_position_fixup()
1215 frames *= runtime->period_size; in snd_pcm_oss_capture_position_fixup()
1225 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_oss_write3() local
1228 if (runtime->status->state == SNDRV_PCM_STATE_XRUN || in snd_pcm_oss_write3()
1229 runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) { in snd_pcm_oss_write3()
1233 runtime->status->state == SNDRV_PCM_STATE_XRUN ? in snd_pcm_oss_write3()
1240 mutex_unlock(&runtime->oss.params_lock); in snd_pcm_oss_write3()
1243 mutex_lock(&runtime->oss.params_lock); in snd_pcm_oss_write3()
1248 if (runtime->status->state == SNDRV_PCM_STATE_PREPARED) in snd_pcm_oss_write3()
1256 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_oss_read3() local
1260 if (runtime->status->state == SNDRV_PCM_STATE_XRUN || in snd_pcm_oss_read3()
1261 runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) { in snd_pcm_oss_read3()
1265 runtime->status->state == SNDRV_PCM_STATE_XRUN ? in snd_pcm_oss_read3()
1271 } else if (runtime->status->state == SNDRV_PCM_STATE_SETUP) { in snd_pcm_oss_read3()
1279 mutex_unlock(&runtime->oss.params_lock); in snd_pcm_oss_read3()
1282 mutex_lock(&runtime->oss.params_lock); in snd_pcm_oss_read3()
1284 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) { in snd_pcm_oss_read3()
1300 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_oss_writev3() local
1303 if (runtime->status->state == SNDRV_PCM_STATE_XRUN || in snd_pcm_oss_writev3()
1304 runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) { in snd_pcm_oss_writev3()
1308 runtime->status->state == SNDRV_PCM_STATE_XRUN ? in snd_pcm_oss_writev3()
1321 if (runtime->status->state == SNDRV_PCM_STATE_PREPARED) in snd_pcm_oss_writev3()
1329 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_oss_readv3() local
1332 if (runtime->status->state == SNDRV_PCM_STATE_XRUN || in snd_pcm_oss_readv3()
1333 runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) { in snd_pcm_oss_readv3()
1337 runtime->status->state == SNDRV_PCM_STATE_XRUN ? in snd_pcm_oss_readv3()
1343 } else if (runtime->status->state == SNDRV_PCM_STATE_SETUP) { in snd_pcm_oss_readv3()
1358 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_oss_write2() local
1361 if (runtime->oss.plugin_first) { in snd_pcm_oss_write2()
1363 …size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_fo… in snd_pcm_oss_write2()
1365 if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes)) in snd_pcm_oss_write2()
1367 buf = runtime->oss.buffer; in snd_pcm_oss_write2()
1380 frames = bytes_to_frames(runtime, bytes); in snd_pcm_oss_write2()
1384 bytes = frames_to_bytes(runtime, frames1); in snd_pcm_oss_write2()
1393 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_oss_write1() local
1398 atomic_inc(&runtime->oss.rw_ref); in snd_pcm_oss_write1()
1400 if (mutex_lock_interruptible(&runtime->oss.params_lock)) { in snd_pcm_oss_write1()
1407 if (bytes < runtime->oss.period_bytes || runtime->oss.buffer_used > 0) { in snd_pcm_oss_write1()
1409 if (tmp + runtime->oss.buffer_used > runtime->oss.period_bytes) in snd_pcm_oss_write1()
1410 tmp = runtime->oss.period_bytes - runtime->oss.buffer_used; in snd_pcm_oss_write1()
1412 if (copy_from_user(runtime->oss.buffer + runtime->oss.buffer_used, buf, tmp)) { in snd_pcm_oss_write1()
1417 runtime->oss.buffer_used += tmp; in snd_pcm_oss_write1()
1422 runtime->oss.buffer_used == runtime->oss.period_bytes) { in snd_pcm_oss_write1()
1423 tmp = snd_pcm_oss_write2(substream, runtime->oss.buffer + runtime->oss.period_ptr, in snd_pcm_oss_write1()
1424 runtime->oss.buffer_used - runtime->oss.period_ptr, 1); in snd_pcm_oss_write1()
1427 runtime->oss.bytes += tmp; in snd_pcm_oss_write1()
1428 runtime->oss.period_ptr += tmp; in snd_pcm_oss_write1()
1429 runtime->oss.period_ptr %= runtime->oss.period_bytes; in snd_pcm_oss_write1()
1430 if (runtime->oss.period_ptr == 0 || in snd_pcm_oss_write1()
1431 runtime->oss.period_ptr == runtime->oss.buffer_used) in snd_pcm_oss_write1()
1432 runtime->oss.buffer_used = 0; in snd_pcm_oss_write1()
1441 runtime->oss.period_bytes, 0); in snd_pcm_oss_write1()
1444 runtime->oss.bytes += tmp; in snd_pcm_oss_write1()
1449 tmp != runtime->oss.period_bytes) in snd_pcm_oss_write1()
1453 mutex_unlock(&runtime->oss.params_lock); in snd_pcm_oss_write1()
1462 atomic_dec(&runtime->oss.rw_ref); in snd_pcm_oss_write1()
1468 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_oss_read2() local
1472 if (runtime->oss.plugin_first) { in snd_pcm_oss_read2()
1474 …size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_form… in snd_pcm_oss_read2()
1476 buf = runtime->oss.buffer; in snd_pcm_oss_read2()
1490 frames = bytes_to_frames(runtime, bytes); in snd_pcm_oss_read2()
1494 bytes = frames_to_bytes(runtime, frames1); in snd_pcm_oss_read2()
1503 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_oss_read1() local
1508 atomic_inc(&runtime->oss.rw_ref); in snd_pcm_oss_read1()
1510 if (mutex_lock_interruptible(&runtime->oss.params_lock)) { in snd_pcm_oss_read1()
1517 if (bytes < runtime->oss.period_bytes || runtime->oss.buffer_used > 0) { in snd_pcm_oss_read1()
1518 if (runtime->oss.buffer_used == 0) { in snd_pcm_oss_read1()
1519 tmp = snd_pcm_oss_read2(substream, runtime->oss.buffer, runtime->oss.period_bytes, 1); in snd_pcm_oss_read1()
1522 runtime->oss.bytes += tmp; in snd_pcm_oss_read1()
1523 runtime->oss.period_ptr = tmp; in snd_pcm_oss_read1()
1524 runtime->oss.buffer_used = tmp; in snd_pcm_oss_read1()
1527 if ((size_t) tmp > runtime->oss.buffer_used) in snd_pcm_oss_read1()
1528 tmp = runtime->oss.buffer_used; in snd_pcm_oss_read1()
1529 …if (copy_to_user(buf, runtime->oss.buffer + (runtime->oss.period_ptr - runtime->oss.buffer_used), … in snd_pcm_oss_read1()
1536 runtime->oss.buffer_used -= tmp; in snd_pcm_oss_read1()
1539 runtime->oss.period_bytes, 0); in snd_pcm_oss_read1()
1542 runtime->oss.bytes += tmp; in snd_pcm_oss_read1()
1548 mutex_unlock(&runtime->oss.params_lock); in snd_pcm_oss_read1()
1557 atomic_dec(&runtime->oss.rw_ref); in snd_pcm_oss_read1()
1564 struct snd_pcm_runtime *runtime; in snd_pcm_oss_reset() local
1571 runtime = substream->runtime; in snd_pcm_oss_reset()
1573 mutex_lock(&runtime->oss.params_lock); in snd_pcm_oss_reset()
1574 runtime->oss.prepare = 1; in snd_pcm_oss_reset()
1575 runtime->oss.buffer_used = 0; in snd_pcm_oss_reset()
1576 runtime->oss.prev_hw_ptr_period = 0; in snd_pcm_oss_reset()
1577 runtime->oss.period_ptr = 0; in snd_pcm_oss_reset()
1578 mutex_unlock(&runtime->oss.params_lock); in snd_pcm_oss_reset()
1602 struct snd_pcm_runtime *runtime; in snd_pcm_oss_sync1() local
1608 runtime = substream->runtime; in snd_pcm_oss_sync1()
1610 add_wait_queue(&runtime->sleep, &wait); in snd_pcm_oss_sync1()
1615 result = snd_pcm_oss_write2(substream, runtime->oss.buffer, size, 1); in snd_pcm_oss_sync1()
1617 runtime->oss.buffer_used = 0; in snd_pcm_oss_sync1()
1626 state = runtime->status->state; in snd_pcm_oss_sync1()
1644 remove_wait_queue(&runtime->sleep, &wait); in snd_pcm_oss_sync1()
1653 struct snd_pcm_runtime *runtime; in snd_pcm_oss_sync() local
1660 runtime = substream->runtime; in snd_pcm_oss_sync()
1666 atomic_inc(&runtime->oss.rw_ref); in snd_pcm_oss_sync()
1667 if (mutex_lock_interruptible(&runtime->oss.params_lock)) { in snd_pcm_oss_sync()
1668 atomic_dec(&runtime->oss.rw_ref); in snd_pcm_oss_sync()
1671 format = snd_pcm_oss_format_from(runtime->oss.format); in snd_pcm_oss_sync()
1673 if (runtime->oss.buffer_used > 0) { in snd_pcm_oss_sync()
1677 size = (8 * (runtime->oss.period_bytes - runtime->oss.buffer_used) + 7) / width; in snd_pcm_oss_sync()
1679 runtime->oss.buffer + runtime->oss.buffer_used, in snd_pcm_oss_sync()
1681 err = snd_pcm_oss_sync1(substream, runtime->oss.period_bytes); in snd_pcm_oss_sync()
1684 } else if (runtime->oss.period_ptr > 0) { in snd_pcm_oss_sync()
1688 size = runtime->oss.period_bytes - runtime->oss.period_ptr; in snd_pcm_oss_sync()
1690 runtime->oss.buffer, in snd_pcm_oss_sync()
1700 size = runtime->control->appl_ptr % runtime->period_size; in snd_pcm_oss_sync()
1702 size = runtime->period_size - size; in snd_pcm_oss_sync()
1703 if (runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED) in snd_pcm_oss_sync()
1705 else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) in snd_pcm_oss_sync()
1709 mutex_unlock(&runtime->oss.params_lock); in snd_pcm_oss_sync()
1710 atomic_dec(&runtime->oss.rw_ref); in snd_pcm_oss_sync()
1723 mutex_lock(&runtime->oss.params_lock); in snd_pcm_oss_sync()
1724 runtime->oss.prepare = 1; in snd_pcm_oss_sync()
1725 mutex_unlock(&runtime->oss.params_lock); in snd_pcm_oss_sync()
1733 runtime = substream->runtime; in snd_pcm_oss_sync()
1737 mutex_lock(&runtime->oss.params_lock); in snd_pcm_oss_sync()
1738 runtime->oss.buffer_used = 0; in snd_pcm_oss_sync()
1739 runtime->oss.prepare = 1; in snd_pcm_oss_sync()
1740 mutex_unlock(&runtime->oss.params_lock); in snd_pcm_oss_sync()
1751 struct snd_pcm_runtime *runtime; in snd_pcm_oss_set_rate() local
1756 runtime = substream->runtime; in snd_pcm_oss_set_rate()
1761 err = lock_params(runtime); in snd_pcm_oss_set_rate()
1764 if (runtime->oss.rate != rate) { in snd_pcm_oss_set_rate()
1765 runtime->oss.params = 1; in snd_pcm_oss_set_rate()
1766 runtime->oss.rate = rate; in snd_pcm_oss_set_rate()
1768 unlock_params(runtime); in snd_pcm_oss_set_rate()
1781 return substream->runtime->oss.rate; in snd_pcm_oss_get_rate()
1793 struct snd_pcm_runtime *runtime; in snd_pcm_oss_set_channels() local
1798 runtime = substream->runtime; in snd_pcm_oss_set_channels()
1799 err = lock_params(runtime); in snd_pcm_oss_set_channels()
1802 if (runtime->oss.channels != channels) { in snd_pcm_oss_set_channels()
1803 runtime->oss.params = 1; in snd_pcm_oss_set_channels()
1804 runtime->oss.channels = channels; in snd_pcm_oss_set_channels()
1806 unlock_params(runtime); in snd_pcm_oss_set_channels()
1819 return substream->runtime->oss.channels; in snd_pcm_oss_get_channels()
1830 return substream->runtime->oss.period_bytes; in snd_pcm_oss_get_block_size()
1892 struct snd_pcm_runtime *runtime; in snd_pcm_oss_set_format() local
1895 runtime = substream->runtime; in snd_pcm_oss_set_format()
1896 err = lock_params(runtime); in snd_pcm_oss_set_format()
1899 if (runtime->oss.format != format) { in snd_pcm_oss_set_format()
1900 runtime->oss.params = 1; in snd_pcm_oss_set_format()
1901 runtime->oss.format = format; in snd_pcm_oss_set_format()
1903 unlock_params(runtime); in snd_pcm_oss_set_format()
1917 return substream->runtime->oss.format; in snd_pcm_oss_get_format()
1922 struct snd_pcm_runtime *runtime; in snd_pcm_oss_set_subdivide1() local
1924 runtime = substream->runtime; in snd_pcm_oss_set_subdivide1()
1926 subdivide = runtime->oss.subdivision; in snd_pcm_oss_set_subdivide1()
1931 if (runtime->oss.subdivision || runtime->oss.fragshift) in snd_pcm_oss_set_subdivide1()
1936 runtime->oss.subdivision = subdivide; in snd_pcm_oss_set_subdivide1()
1937 runtime->oss.params = 1; in snd_pcm_oss_set_subdivide1()
1947 struct snd_pcm_runtime *runtime; in snd_pcm_oss_set_subdivide() local
1951 runtime = substream->runtime; in snd_pcm_oss_set_subdivide()
1952 err = lock_params(runtime); in snd_pcm_oss_set_subdivide()
1956 unlock_params(runtime); in snd_pcm_oss_set_subdivide()
1965 struct snd_pcm_runtime *runtime; in snd_pcm_oss_set_fragment1() local
1968 runtime = substream->runtime; in snd_pcm_oss_set_fragment1()
1969 if (runtime->oss.subdivision || runtime->oss.fragshift) in snd_pcm_oss_set_fragment1()
1974 runtime->oss.fragshift = fragshift; in snd_pcm_oss_set_fragment1()
1975 runtime->oss.maxfrags = (val >> 16) & 0xffff; in snd_pcm_oss_set_fragment1()
1976 if (runtime->oss.fragshift < 4) /* < 16 */ in snd_pcm_oss_set_fragment1()
1977 runtime->oss.fragshift = 4; in snd_pcm_oss_set_fragment1()
1978 if (runtime->oss.maxfrags < 2) in snd_pcm_oss_set_fragment1()
1979 runtime->oss.maxfrags = 2; in snd_pcm_oss_set_fragment1()
1980 runtime->oss.params = 1; in snd_pcm_oss_set_fragment1()
1990 struct snd_pcm_runtime *runtime; in snd_pcm_oss_set_fragment() local
1994 runtime = substream->runtime; in snd_pcm_oss_set_fragment()
1995 err = lock_params(runtime); in snd_pcm_oss_set_fragment()
1999 unlock_params(runtime); in snd_pcm_oss_set_fragment()
2030 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_oss_get_caps1() local
2031 if (runtime->info & (SNDRV_PCM_INFO_BLOCK_TRANSFER|SNDRV_PCM_INFO_BATCH)) in snd_pcm_oss_get_caps1()
2054 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_oss_simulate_fill() local
2056 appl_ptr = hw_ptr + runtime->buffer_size; in snd_pcm_oss_simulate_fill()
2057 appl_ptr %= runtime->boundary; in snd_pcm_oss_simulate_fill()
2058 runtime->control->appl_ptr = appl_ptr; in snd_pcm_oss_simulate_fill()
2063 struct snd_pcm_runtime *runtime; in snd_pcm_oss_set_trigger() local
2085 runtime = psubstream->runtime; in snd_pcm_oss_set_trigger()
2087 if (mutex_lock_interruptible(&runtime->oss.params_lock)) in snd_pcm_oss_set_trigger()
2090 if (runtime->oss.trigger) in snd_pcm_oss_set_trigger()
2094 get_hw_ptr_period(runtime)); in snd_pcm_oss_set_trigger()
2095 runtime->oss.trigger = 1; in snd_pcm_oss_set_trigger()
2096 runtime->start_threshold = 1; in snd_pcm_oss_set_trigger()
2099 if (!runtime->oss.trigger) in snd_pcm_oss_set_trigger()
2101 runtime->oss.trigger = 0; in snd_pcm_oss_set_trigger()
2102 runtime->start_threshold = runtime->boundary; in snd_pcm_oss_set_trigger()
2104 runtime->oss.prepare = 1; in snd_pcm_oss_set_trigger()
2107 mutex_unlock(&runtime->oss.params_lock); in snd_pcm_oss_set_trigger()
2115 runtime = csubstream->runtime; in snd_pcm_oss_set_trigger()
2117 if (mutex_lock_interruptible(&runtime->oss.params_lock)) in snd_pcm_oss_set_trigger()
2120 if (runtime->oss.trigger) in snd_pcm_oss_set_trigger()
2122 runtime->oss.trigger = 1; in snd_pcm_oss_set_trigger()
2123 runtime->start_threshold = 1; in snd_pcm_oss_set_trigger()
2126 if (!runtime->oss.trigger) in snd_pcm_oss_set_trigger()
2128 runtime->oss.trigger = 0; in snd_pcm_oss_set_trigger()
2129 runtime->start_threshold = runtime->boundary; in snd_pcm_oss_set_trigger()
2131 runtime->oss.prepare = 1; in snd_pcm_oss_set_trigger()
2134 mutex_unlock(&runtime->oss.params_lock); in snd_pcm_oss_set_trigger()
2151 if (psubstream && psubstream->runtime && psubstream->runtime->oss.trigger) in snd_pcm_oss_get_trigger()
2153 if (csubstream && csubstream->runtime && csubstream->runtime->oss.trigger) in snd_pcm_oss_get_trigger()
2161 struct snd_pcm_runtime *runtime; in snd_pcm_oss_get_odelay() local
2171 runtime = substream->runtime; in snd_pcm_oss_get_odelay()
2172 if (runtime->oss.params || runtime->oss.prepare) in snd_pcm_oss_get_odelay()
2185 struct snd_pcm_runtime *runtime; in snd_pcm_oss_get_ptr() local
2199 runtime = substream->runtime; in snd_pcm_oss_get_ptr()
2200 if (runtime->oss.params || runtime->oss.prepare) { in snd_pcm_oss_get_ptr()
2213 fixup = runtime->oss.buffer_used; in snd_pcm_oss_get_ptr()
2217 fixup = -runtime->oss.buffer_used; in snd_pcm_oss_get_ptr()
2221 info.ptr = snd_pcm_oss_bytes(substream, runtime->status->hw_ptr % runtime->buffer_size); in snd_pcm_oss_get_ptr()
2224 delay = get_hw_ptr_period(runtime); in snd_pcm_oss_get_ptr()
2225 n = delay - runtime->oss.prev_hw_ptr_period; in snd_pcm_oss_get_ptr()
2227 n += runtime->boundary; in snd_pcm_oss_get_ptr()
2228 info.blocks = n / runtime->period_size; in snd_pcm_oss_get_ptr()
2229 runtime->oss.prev_hw_ptr_period = delay; in snd_pcm_oss_get_ptr()
2232 info.bytes = snd_pcm_oss_bytes(substream, runtime->status->hw_ptr) & INT_MAX; in snd_pcm_oss_get_ptr()
2237 info.blocks = (runtime->oss.buffer_bytes - delay - fixup) / runtime->oss.period_bytes; in snd_pcm_oss_get_ptr()
2239 info.blocks = (delay + fixup) / runtime->oss.period_bytes; in snd_pcm_oss_get_ptr()
2240 info.bytes = (runtime->oss.bytes - delay) & INT_MAX; in snd_pcm_oss_get_ptr()
2243 info.blocks = delay / runtime->oss.period_bytes; in snd_pcm_oss_get_ptr()
2244 info.bytes = (runtime->oss.bytes + delay) & INT_MAX; in snd_pcm_oss_get_ptr()
2255 struct snd_pcm_runtime *runtime; in snd_pcm_oss_get_space() local
2266 runtime = substream->runtime; in snd_pcm_oss_get_space()
2268 if (runtime->oss.params) { in snd_pcm_oss_get_space()
2274 info.fragsize = runtime->oss.period_bytes; in snd_pcm_oss_get_space()
2275 info.fragstotal = runtime->periods; in snd_pcm_oss_get_space()
2276 if (runtime->oss.prepare) { in snd_pcm_oss_get_space()
2278 info.bytes = runtime->oss.period_bytes * runtime->oss.periods; in snd_pcm_oss_get_space()
2279 info.fragments = runtime->oss.periods; in snd_pcm_oss_get_space()
2288 avail = runtime->buffer_size; in snd_pcm_oss_get_space()
2292 avail = runtime->buffer_size - avail; in snd_pcm_oss_get_space()
2293 fixup = -runtime->oss.buffer_used; in snd_pcm_oss_get_space()
2297 fixup = runtime->oss.buffer_used; in snd_pcm_oss_get_space()
2302 info.fragments = info.bytes / runtime->oss.period_bytes; in snd_pcm_oss_get_space()
2354 struct snd_pcm_runtime *runtime; in snd_pcm_oss_release_substream() local
2355 runtime = substream->runtime; in snd_pcm_oss_release_substream()
2356 kvfree(runtime->oss.buffer); in snd_pcm_oss_release_substream()
2357 runtime->oss.buffer = NULL; in snd_pcm_oss_release_substream()
2368 struct snd_pcm_runtime *runtime; in snd_pcm_oss_init_substream() local
2376 runtime = substream->runtime; in snd_pcm_oss_init_substream()
2377 runtime->oss.params = 1; in snd_pcm_oss_init_substream()
2378 runtime->oss.trigger = 1; in snd_pcm_oss_init_substream()
2379 runtime->oss.rate = 8000; in snd_pcm_oss_init_substream()
2380 mutex_init(&runtime->oss.params_lock); in snd_pcm_oss_init_substream()
2383 runtime->oss.format = AFMT_U8; in snd_pcm_oss_init_substream()
2386 runtime->oss.format = AFMT_S16_LE; in snd_pcm_oss_init_substream()
2389 runtime->oss.format = AFMT_MU_LAW; in snd_pcm_oss_init_substream()
2391 runtime->oss.channels = 1; in snd_pcm_oss_init_substream()
2392 runtime->oss.fragshift = 0; in snd_pcm_oss_init_substream()
2393 runtime->oss.maxfrags = 0; in snd_pcm_oss_init_substream()
2394 runtime->oss.subdivision = 0; in snd_pcm_oss_init_substream()
2396 atomic_set(&runtime->oss.rw_ref, 0); in snd_pcm_oss_init_substream()
2815 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_oss_playback_ready() local
2817 return runtime->oss.prev_hw_ptr_period != in snd_pcm_oss_playback_ready()
2818 get_hw_ptr_period(runtime); in snd_pcm_oss_playback_ready()
2820 return snd_pcm_playback_avail(runtime) >= in snd_pcm_oss_playback_ready()
2821 runtime->oss.period_frames; in snd_pcm_oss_playback_ready()
2826 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_oss_capture_ready() local
2828 return runtime->oss.prev_hw_ptr_period != in snd_pcm_oss_capture_ready()
2829 get_hw_ptr_period(runtime); in snd_pcm_oss_capture_ready()
2831 return snd_pcm_capture_avail(runtime) >= in snd_pcm_oss_capture_ready()
2832 runtime->oss.period_frames; in snd_pcm_oss_capture_ready()
2848 struct snd_pcm_runtime *runtime = psubstream->runtime; in snd_pcm_oss_poll() local
2849 poll_wait(file, &runtime->sleep, wait); in snd_pcm_oss_poll()
2851 if (runtime->status->state != SNDRV_PCM_STATE_DRAINING && in snd_pcm_oss_poll()
2852 (runtime->status->state != SNDRV_PCM_STATE_RUNNING || in snd_pcm_oss_poll()
2858 struct snd_pcm_runtime *runtime = csubstream->runtime; in snd_pcm_oss_poll() local
2860 poll_wait(file, &runtime->sleep, wait); in snd_pcm_oss_poll()
2862 ostate = runtime->status->state; in snd_pcm_oss_poll()
2867 if (ostate != SNDRV_PCM_STATE_RUNNING && runtime->oss.trigger) { in snd_pcm_oss_poll()
2871 runtime->oss.trigger = 0; in snd_pcm_oss_poll()
2883 struct snd_pcm_runtime *runtime; in snd_pcm_oss_mmap() local
2910 runtime = substream->runtime; in snd_pcm_oss_mmap()
2911 if (!(runtime->info & SNDRV_PCM_INFO_MMAP_VALID)) in snd_pcm_oss_mmap()
2913 if (runtime->info & SNDRV_PCM_INFO_INTERLEAVED) in snd_pcm_oss_mmap()
2914 runtime->access = SNDRV_PCM_ACCESS_MMAP_INTERLEAVED; in snd_pcm_oss_mmap()
2918 if (runtime->oss.params) { in snd_pcm_oss_mmap()
2928 if (runtime->oss.plugin_first != NULL) in snd_pcm_oss_mmap()
2938 runtime->oss.mmap_bytes = area->vm_end - area->vm_start; in snd_pcm_oss_mmap()
2939 runtime->silence_threshold = 0; in snd_pcm_oss_mmap()
2940 runtime->silence_size = 0; in snd_pcm_oss_mmap()
2943 runtime->oss.mmap_bytes); in snd_pcm_oss_mmap()
2946 runtime->stop_threshold = runtime->boundary; in snd_pcm_oss_mmap()