Lines Matching full:runtime

261 	if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_MMAP))  in hw_support_mmap()
288 &substream->runtime->hw_constraints; in constrain_mask_params()
324 &substream->runtime->hw_constraints; in constrain_interval_params()
360 &substream->runtime->hw_constraints; in constrain_params_by_rules()
533 params->info = substream->runtime->hw.info; in fixup_unreferenced_params()
601 static int period_to_usecs(struct snd_pcm_runtime *runtime) in period_to_usecs() argument
605 if (! runtime->rate) in period_to_usecs()
609 usecs = (750000 / runtime->rate) * runtime->period_size; in period_to_usecs()
610 usecs += ((750000 % runtime->rate) * runtime->period_size) / in period_to_usecs()
611 runtime->rate; in period_to_usecs()
620 if (substream->runtime->state != SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_set_state()
621 __snd_pcm_set_state(substream->runtime, state); in snd_pcm_set_state()
631 &substream->runtime->trigger_tstamp); in snd_pcm_timer_notify()
637 if (substream->runtime && substream->runtime->stop_operating) { in snd_pcm_sync_stop()
638 substream->runtime->stop_operating = false; in snd_pcm_sync_stop()
713 static int snd_pcm_buffer_access_lock(struct snd_pcm_runtime *runtime) in snd_pcm_buffer_access_lock() argument
715 if (!atomic_dec_unless_positive(&runtime->buffer_accessing)) in snd_pcm_buffer_access_lock()
717 mutex_lock(&runtime->buffer_mutex); in snd_pcm_buffer_access_lock()
722 static void snd_pcm_buffer_access_unlock(struct snd_pcm_runtime *runtime) in snd_pcm_buffer_access_unlock() argument
724 mutex_unlock(&runtime->buffer_mutex); in snd_pcm_buffer_access_unlock()
725 atomic_inc(&runtime->buffer_accessing); in snd_pcm_buffer_access_unlock()
737 struct snd_pcm_runtime *runtime; in snd_pcm_hw_params() local
744 runtime = substream->runtime; in snd_pcm_hw_params()
745 err = snd_pcm_buffer_access_lock(runtime); in snd_pcm_hw_params()
749 switch (runtime->state) { in snd_pcm_hw_params()
785 runtime->buffer_changed = err > 0; in snd_pcm_hw_params()
794 runtime->access = params_access(params); in snd_pcm_hw_params()
795 runtime->format = params_format(params); in snd_pcm_hw_params()
796 runtime->subformat = params_subformat(params); in snd_pcm_hw_params()
797 runtime->channels = params_channels(params); in snd_pcm_hw_params()
798 runtime->rate = params_rate(params); in snd_pcm_hw_params()
799 runtime->period_size = params_period_size(params); in snd_pcm_hw_params()
800 runtime->periods = params_periods(params); in snd_pcm_hw_params()
801 runtime->buffer_size = params_buffer_size(params); in snd_pcm_hw_params()
802 runtime->info = params->info; in snd_pcm_hw_params()
803 runtime->rate_num = params->rate_num; in snd_pcm_hw_params()
804 runtime->rate_den = params->rate_den; in snd_pcm_hw_params()
805 runtime->no_period_wakeup = in snd_pcm_hw_params()
809 bits = snd_pcm_format_physical_width(runtime->format); in snd_pcm_hw_params()
810 runtime->sample_bits = bits; in snd_pcm_hw_params()
811 bits *= runtime->channels; in snd_pcm_hw_params()
812 runtime->frame_bits = bits; in snd_pcm_hw_params()
818 runtime->byte_align = bits / 8; in snd_pcm_hw_params()
819 runtime->min_align = frames; in snd_pcm_hw_params()
822 runtime->tstamp_mode = SNDRV_PCM_TSTAMP_NONE; in snd_pcm_hw_params()
823 runtime->period_step = 1; in snd_pcm_hw_params()
824 runtime->control->avail_min = runtime->period_size; in snd_pcm_hw_params()
825 runtime->start_threshold = 1; in snd_pcm_hw_params()
826 runtime->stop_threshold = runtime->buffer_size; in snd_pcm_hw_params()
827 runtime->silence_threshold = 0; in snd_pcm_hw_params()
828 runtime->silence_size = 0; in snd_pcm_hw_params()
829 runtime->boundary = runtime->buffer_size; in snd_pcm_hw_params()
830 while (runtime->boundary * 2 <= LONG_MAX - runtime->buffer_size) in snd_pcm_hw_params()
831 runtime->boundary *= 2; in snd_pcm_hw_params()
834 if (runtime->dma_area && !substream->ops->copy) { in snd_pcm_hw_params()
835 size_t size = runtime->dma_bytes; in snd_pcm_hw_params()
837 if (runtime->info & SNDRV_PCM_INFO_MMAP) in snd_pcm_hw_params()
839 memset(runtime->dma_area, 0, size); in snd_pcm_hw_params()
847 usecs = period_to_usecs(runtime); in snd_pcm_hw_params()
865 snd_pcm_buffer_access_unlock(runtime); in snd_pcm_hw_params()
904 struct snd_pcm_runtime *runtime; in snd_pcm_hw_free() local
909 runtime = substream->runtime; in snd_pcm_hw_free()
910 result = snd_pcm_buffer_access_lock(runtime); in snd_pcm_hw_free()
914 switch (runtime->state) { in snd_pcm_hw_free()
931 snd_pcm_buffer_access_unlock(runtime); in snd_pcm_hw_free()
938 struct snd_pcm_runtime *runtime; in snd_pcm_sw_params() local
943 runtime = substream->runtime; in snd_pcm_sw_params()
945 if (runtime->state == SNDRV_PCM_STATE_OPEN) { in snd_pcm_sw_params()
959 if (params->silence_size >= runtime->boundary) { in snd_pcm_sw_params()
965 if (params->silence_threshold > runtime->buffer_size) in snd_pcm_sw_params()
970 runtime->tstamp_mode = params->tstamp_mode; in snd_pcm_sw_params()
972 runtime->tstamp_type = params->tstamp_type; in snd_pcm_sw_params()
973 runtime->period_step = params->period_step; in snd_pcm_sw_params()
974 runtime->control->avail_min = params->avail_min; in snd_pcm_sw_params()
975 runtime->start_threshold = params->start_threshold; in snd_pcm_sw_params()
976 runtime->stop_threshold = params->stop_threshold; in snd_pcm_sw_params()
977 runtime->silence_threshold = params->silence_threshold; in snd_pcm_sw_params()
978 runtime->silence_size = params->silence_size; in snd_pcm_sw_params()
979 params->boundary = runtime->boundary; in snd_pcm_sw_params()
982 runtime->silence_size > 0) in snd_pcm_sw_params()
984 err = snd_pcm_update_state(substream, runtime); in snd_pcm_sw_params()
1009 delay = snd_pcm_playback_hw_avail(substream->runtime); in snd_pcm_calc_delay()
1011 delay = snd_pcm_capture_avail(substream->runtime); in snd_pcm_calc_delay()
1012 return delay + substream->runtime->delay; in snd_pcm_calc_delay()
1018 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_status64() local
1023 &runtime->audio_tstamp_config); in snd_pcm_status64()
1026 if (runtime->audio_tstamp_config.type_requested == in snd_pcm_status64()
1028 if (runtime->hw.info & SNDRV_PCM_INFO_HAS_WALL_CLOCK) in snd_pcm_status64()
1029 runtime->audio_tstamp_config.type_requested = in snd_pcm_status64()
1032 runtime->audio_tstamp_config.type_requested = in snd_pcm_status64()
1034 runtime->audio_tstamp_report.valid = 0; in snd_pcm_status64()
1036 runtime->audio_tstamp_report.valid = 1; in snd_pcm_status64()
1038 status->state = runtime->state; in snd_pcm_status64()
1039 status->suspended_state = runtime->suspended_state; in snd_pcm_status64()
1042 status->trigger_tstamp_sec = runtime->trigger_tstamp.tv_sec; in snd_pcm_status64()
1043 status->trigger_tstamp_nsec = runtime->trigger_tstamp.tv_nsec; in snd_pcm_status64()
1046 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { in snd_pcm_status64()
1047 status->tstamp_sec = runtime->status->tstamp.tv_sec; in snd_pcm_status64()
1049 runtime->status->tstamp.tv_nsec; in snd_pcm_status64()
1051 runtime->driver_tstamp.tv_sec; in snd_pcm_status64()
1053 runtime->driver_tstamp.tv_nsec; in snd_pcm_status64()
1055 runtime->status->audio_tstamp.tv_sec; in snd_pcm_status64()
1057 runtime->status->audio_tstamp.tv_nsec; in snd_pcm_status64()
1058 if (runtime->audio_tstamp_report.valid == 1) in snd_pcm_status64()
1062 &runtime->audio_tstamp_report); in snd_pcm_status64()
1068 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { in snd_pcm_status64()
1071 snd_pcm_gettime(runtime, &tstamp); in snd_pcm_status64()
1077 status->appl_ptr = runtime->control->appl_ptr; in snd_pcm_status64()
1078 status->hw_ptr = runtime->status->hw_ptr; in snd_pcm_status64()
1082 status->avail_max = runtime->avail_max; in snd_pcm_status64()
1083 status->overrange = runtime->overrange; in snd_pcm_status64()
1084 runtime->avail_max = 0; in snd_pcm_status64()
1085 runtime->overrange = 0; in snd_pcm_status64()
1167 struct snd_pcm_runtime *runtime; in snd_pcm_channel_info() local
1171 runtime = substream->runtime; in snd_pcm_channel_info()
1173 if (runtime->state == SNDRV_PCM_STATE_OPEN) { in snd_pcm_channel_info()
1178 if (channel >= runtime->channels) in snd_pcm_channel_info()
1203 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_trigger_tstamp() local
1204 if (runtime->trigger_master == NULL) in snd_pcm_trigger_tstamp()
1206 if (runtime->trigger_master == substream) { in snd_pcm_trigger_tstamp()
1207 if (!runtime->trigger_tstamp_latched) in snd_pcm_trigger_tstamp()
1208 snd_pcm_gettime(runtime, &runtime->trigger_tstamp); in snd_pcm_trigger_tstamp()
1210 snd_pcm_trigger_tstamp(runtime->trigger_master); in snd_pcm_trigger_tstamp()
1211 runtime->trigger_tstamp = runtime->trigger_master->runtime->trigger_tstamp; in snd_pcm_trigger_tstamp()
1213 runtime->trigger_master = NULL; in snd_pcm_trigger_tstamp()
1246 mutex_lock_nested(&s->runtime->buffer_mutex, depth); in snd_pcm_action_group()
1279 mutex_unlock(&s1->runtime->buffer_mutex); in snd_pcm_action_group()
1416 res = snd_pcm_buffer_access_lock(substream->runtime); in snd_pcm_action_nonatomic()
1423 snd_pcm_buffer_access_unlock(substream->runtime); in snd_pcm_action_nonatomic()
1435 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_start() local
1436 if (runtime->state != SNDRV_PCM_STATE_PREPARED) in snd_pcm_pre_start()
1441 runtime->trigger_tstamp_latched = false; in snd_pcm_pre_start()
1442 runtime->trigger_master = substream; in snd_pcm_pre_start()
1451 if (substream->runtime->trigger_master != substream) in snd_pcm_do_start()
1456 __snd_pcm_set_state(substream->runtime, SNDRV_PCM_STATE_XRUN); in snd_pcm_do_start()
1463 if (substream->runtime->trigger_master == substream) { in snd_pcm_undo_start()
1465 substream->runtime->stop_operating = true; in snd_pcm_undo_start()
1472 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_start() local
1474 runtime->hw_ptr_jiffies = jiffies; in snd_pcm_post_start()
1475 runtime->hw_ptr_buffer_jiffies = (runtime->buffer_size * HZ) / in snd_pcm_post_start()
1476 runtime->rate; in snd_pcm_post_start()
1477 __snd_pcm_set_state(runtime, state); in snd_pcm_post_start()
1479 runtime->silence_size > 0) in snd_pcm_post_start()
1517 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_stop() local
1518 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_pre_stop()
1520 runtime->trigger_master = substream; in snd_pcm_pre_stop()
1527 if (substream->runtime->trigger_master == substream && in snd_pcm_do_stop()
1530 substream->runtime->stop_operating = true; in snd_pcm_do_stop()
1538 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_stop() local
1539 if (runtime->state != state) { in snd_pcm_post_stop()
1541 __snd_pcm_set_state(runtime, state); in snd_pcm_post_stop()
1544 wake_up(&runtime->sleep); in snd_pcm_post_stop()
1545 wake_up(&runtime->tsleep); in snd_pcm_post_stop()
1598 if (substream->runtime && snd_pcm_running(substream)) in snd_pcm_stop_xrun()
1613 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_pause() local
1614 if (!(runtime->info & SNDRV_PCM_INFO_PAUSE)) in snd_pcm_pre_pause()
1617 if (runtime->state != SNDRV_PCM_STATE_RUNNING) in snd_pcm_pre_pause()
1619 } else if (runtime->state != SNDRV_PCM_STATE_PAUSED) in snd_pcm_pre_pause()
1621 runtime->trigger_master = substream; in snd_pcm_pre_pause()
1628 if (substream->runtime->trigger_master != substream) in snd_pcm_do_pause()
1634 substream->runtime->hw_ptr_jiffies = jiffies - HZ * 1000; in snd_pcm_do_pause()
1644 if (substream->runtime->trigger_master == substream) in snd_pcm_undo_pause()
1654 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_pause() local
1657 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_PAUSED); in snd_pcm_post_pause()
1659 wake_up(&runtime->sleep); in snd_pcm_post_pause()
1660 wake_up(&runtime->tsleep); in snd_pcm_post_pause()
1662 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_RUNNING); in snd_pcm_post_pause()
1696 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_suspend() local
1697 switch (runtime->state) { in snd_pcm_pre_suspend()
1706 runtime->trigger_master = substream; in snd_pcm_pre_suspend()
1713 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_suspend() local
1714 if (runtime->trigger_master != substream) in snd_pcm_do_suspend()
1719 runtime->stop_operating = true; in snd_pcm_do_suspend()
1726 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_suspend() local
1728 runtime->suspended_state = runtime->state; in snd_pcm_post_suspend()
1729 runtime->status->suspended_state = runtime->suspended_state; in snd_pcm_post_suspend()
1730 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_SUSPENDED); in snd_pcm_post_suspend()
1732 wake_up(&runtime->sleep); in snd_pcm_post_suspend()
1733 wake_up(&runtime->tsleep); in snd_pcm_post_suspend()
1780 if (!substream->runtime) in snd_pcm_suspend_all()
1807 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_resume() local
1808 if (!(runtime->info & SNDRV_PCM_INFO_RESUME)) in snd_pcm_pre_resume()
1810 runtime->trigger_master = substream; in snd_pcm_pre_resume()
1817 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_resume() local
1818 if (runtime->trigger_master != substream) in snd_pcm_do_resume()
1821 if (runtime->suspended_state != SNDRV_PCM_STATE_RUNNING && in snd_pcm_do_resume()
1822 (runtime->suspended_state != SNDRV_PCM_STATE_DRAINING || in snd_pcm_do_resume()
1831 if (substream->runtime->trigger_master == substream && in snd_pcm_undo_resume()
1839 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_resume() local
1841 __snd_pcm_set_state(runtime, runtime->suspended_state); in snd_pcm_post_resume()
1874 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xrun() local
1878 switch (runtime->state) { in snd_pcm_xrun()
1900 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_reset() local
1901 switch (runtime->state) { in snd_pcm_pre_reset()
1915 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_reset() local
1920 runtime->hw_ptr_base = 0; in snd_pcm_do_reset()
1921 runtime->hw_ptr_interrupt = runtime->status->hw_ptr - in snd_pcm_do_reset()
1922 runtime->status->hw_ptr % runtime->period_size; in snd_pcm_do_reset()
1923 runtime->silence_start = runtime->status->hw_ptr; in snd_pcm_do_reset()
1924 runtime->silence_filled = 0; in snd_pcm_do_reset()
1932 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_reset() local
1934 runtime->control->appl_ptr = runtime->status->hw_ptr; in snd_pcm_post_reset()
1936 runtime->silence_size > 0) in snd_pcm_post_reset()
1960 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_prepare() local
1963 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_pre_prepare()
1964 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_pre_prepare()
1986 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_prepare() local
1987 runtime->control->appl_ptr = runtime->status->hw_ptr; in snd_pcm_post_prepare()
2015 switch (substream->runtime->state) { in snd_pcm_prepare()
2038 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_drain_init() local
2039 switch (runtime->state) { in snd_pcm_pre_drain_init()
2045 runtime->trigger_master = substream; in snd_pcm_pre_drain_init()
2052 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_drain_init() local
2054 switch (runtime->state) { in snd_pcm_do_drain_init()
2061 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_SETUP); in snd_pcm_do_drain_init()
2065 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_DRAINING); in snd_pcm_do_drain_init()
2068 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_SETUP); in snd_pcm_do_drain_init()
2075 if (runtime->state == SNDRV_PCM_STATE_RUNNING) { in snd_pcm_do_drain_init()
2078 new_state = snd_pcm_capture_avail(runtime) > 0 ? in snd_pcm_do_drain_init()
2085 if (runtime->state == SNDRV_PCM_STATE_DRAINING && in snd_pcm_do_drain_init()
2086 runtime->trigger_master == substream && in snd_pcm_do_drain_init()
2087 (runtime->hw.info & SNDRV_PCM_INFO_DRAIN_TRIGGER)) in snd_pcm_do_drain_init()
2116 struct snd_pcm_runtime *runtime; in snd_pcm_drain() local
2124 runtime = substream->runtime; in snd_pcm_drain()
2126 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_drain()
2137 if (runtime->state == SNDRV_PCM_STATE_PAUSED) in snd_pcm_drain()
2164 runtime = s->runtime; in snd_pcm_drain()
2165 if (runtime->state == SNDRV_PCM_STATE_DRAINING) { in snd_pcm_drain()
2166 to_check = runtime; in snd_pcm_drain()
2177 if (runtime->no_period_wakeup) in snd_pcm_drain()
2181 if (runtime->rate) { in snd_pcm_drain()
2182 long t = runtime->buffer_size * 1100 / runtime->rate; in snd_pcm_drain()
2192 if (s->runtime == to_check) { in snd_pcm_drain()
2204 if (substream->runtime->state == SNDRV_PCM_STATE_SUSPENDED) in snd_pcm_drain()
2229 struct snd_pcm_runtime *runtime; in snd_pcm_drop() local
2234 runtime = substream->runtime; in snd_pcm_drop()
2236 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_drop()
2237 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_drop()
2242 if (runtime->state == SNDRV_PCM_STATE_PAUSED) in snd_pcm_drop()
2246 /* runtime->control->appl_ptr = runtime->status->hw_ptr; */ in snd_pcm_drop()
2305 if (substream->runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_link()
2306 substream->runtime->state != substream1->runtime->state || in snd_pcm_link()
2534 static int snd_pcm_hw_constraint_subformats(struct snd_pcm_runtime *runtime, in snd_pcm_hw_constraint_subformats() argument
2537 return snd_pcm_hw_rule_add(runtime, cond, -1, in snd_pcm_hw_constraint_subformats()
2545 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_init() local
2546 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_constraints_init()
2563 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FORMAT, in snd_pcm_hw_constraints_init()
2568 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, in snd_pcm_hw_constraints_init()
2574 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, in snd_pcm_hw_constraints_init()
2579 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS, in snd_pcm_hw_constraints_init()
2584 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS, in snd_pcm_hw_constraints_init()
2589 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS, in snd_pcm_hw_constraints_init()
2594 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, in snd_pcm_hw_constraints_init()
2599 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, in snd_pcm_hw_constraints_init()
2604 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, in snd_pcm_hw_constraints_init()
2609 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIODS, in snd_pcm_hw_constraints_init()
2614 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, in snd_pcm_hw_constraints_init()
2619 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, in snd_pcm_hw_constraints_init()
2624 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, in snd_pcm_hw_constraints_init()
2629 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, in snd_pcm_hw_constraints_init()
2634 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, in snd_pcm_hw_constraints_init()
2639 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, in snd_pcm_hw_constraints_init()
2644 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, in snd_pcm_hw_constraints_init()
2649 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, in snd_pcm_hw_constraints_init()
2654 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_TIME, in snd_pcm_hw_constraints_init()
2659 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_TIME, in snd_pcm_hw_constraints_init()
2669 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_complete() local
2670 struct snd_pcm_hardware *hw = &runtime->hw; in snd_pcm_hw_constraints_complete()
2686 err = snd_pcm_hw_constraint_mask(runtime, SNDRV_PCM_HW_PARAM_ACCESS, mask); in snd_pcm_hw_constraints_complete()
2690 err = snd_pcm_hw_constraint_mask64(runtime, SNDRV_PCM_HW_PARAM_FORMAT, hw->formats); in snd_pcm_hw_constraints_complete()
2694 err = snd_pcm_hw_constraint_subformats(runtime, 0, &hw->subformats); in snd_pcm_hw_constraints_complete()
2698 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_CHANNELS, in snd_pcm_hw_constraints_complete()
2703 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_RATE, in snd_pcm_hw_constraints_complete()
2708 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, in snd_pcm_hw_constraints_complete()
2713 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIODS, in snd_pcm_hw_constraints_complete()
2718 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, in snd_pcm_hw_constraints_complete()
2723 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, in snd_pcm_hw_constraints_complete()
2730 if (runtime->dma_bytes) { in snd_pcm_hw_constraints_complete()
2731 …err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 0, runtime->dma_bytes… in snd_pcm_hw_constraints_complete()
2737 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, in snd_pcm_hw_constraints_complete()
2745 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE); in snd_pcm_hw_constraints_complete()
2764 if (substream->runtime->state != SNDRV_PCM_STATE_OPEN) in snd_pcm_release_substream()
2817 substream->runtime->hw.info |= SNDRV_PCM_INFO_EXPLICIT_SYNC; in snd_pcm_open_substream()
2968 switch (substream->runtime->state) { in do_pcm_hwsync()
2992 struct snd_pcm_runtime *runtime = substream->runtime; in forward_appl_ptr() local
3000 appl_ptr = runtime->control->appl_ptr + frames; in forward_appl_ptr()
3001 if (appl_ptr >= (snd_pcm_sframes_t)runtime->boundary) in forward_appl_ptr()
3002 appl_ptr -= runtime->boundary; in forward_appl_ptr()
3012 struct snd_pcm_runtime *runtime = substream->runtime; in rewind_appl_ptr() local
3020 appl_ptr = runtime->control->appl_ptr - frames; in rewind_appl_ptr()
3022 appl_ptr += runtime->boundary; in rewind_appl_ptr()
3093 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_sync_ptr() local
3104 status = runtime->status; in snd_pcm_sync_ptr()
3105 control = runtime->control; in snd_pcm_sync_ptr()
3168 static snd_pcm_uframes_t recalculate_boundary(struct snd_pcm_runtime *runtime) in recalculate_boundary() argument
3172 if (! runtime->buffer_size) in recalculate_boundary()
3174 boundary = runtime->buffer_size; in recalculate_boundary()
3175 while (boundary * 2 <= 0x7fffffffUL - runtime->buffer_size) in recalculate_boundary()
3183 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_ioctl_sync_ptr_compat() local
3192 if (snd_BUG_ON(!runtime)) in snd_pcm_ioctl_sync_ptr_compat()
3204 status = runtime->status; in snd_pcm_ioctl_sync_ptr_compat()
3205 control = runtime->control; in snd_pcm_ioctl_sync_ptr_compat()
3206 boundary = recalculate_boundary(runtime); in snd_pcm_ioctl_sync_ptr_compat()
3249 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_tstamp() local
3256 runtime->tstamp_type = arg; in snd_pcm_tstamp()
3264 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xferi_frames_ioctl() local
3267 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_xferi_frames_ioctl()
3286 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xfern_frames_ioctl() local
3290 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_xfern_frames_ioctl()
3292 if (runtime->channels > 128) in snd_pcm_xfern_frames_ioctl()
3299 bufs = memdup_user(xfern.bufs, sizeof(void *) * runtime->channels); in snd_pcm_xfern_frames_ioctl()
3354 if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_common_ioctl()
3485 if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_kernel_ioctl()
3522 struct snd_pcm_runtime *runtime; in snd_pcm_read() local
3529 runtime = substream->runtime; in snd_pcm_read()
3530 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_read()
3531 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_read()
3533 if (!frame_aligned(runtime, count)) in snd_pcm_read()
3535 count = bytes_to_frames(runtime, count); in snd_pcm_read()
3538 result = frames_to_bytes(runtime, result); in snd_pcm_read()
3547 struct snd_pcm_runtime *runtime; in snd_pcm_write() local
3554 runtime = substream->runtime; in snd_pcm_write()
3555 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_write()
3556 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_write()
3558 if (!frame_aligned(runtime, count)) in snd_pcm_write()
3560 count = bytes_to_frames(runtime, count); in snd_pcm_write()
3563 result = frames_to_bytes(runtime, result); in snd_pcm_write()
3571 struct snd_pcm_runtime *runtime; in snd_pcm_readv() local
3582 runtime = substream->runtime; in snd_pcm_readv()
3583 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_readv()
3584 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_readv()
3588 if (to->nr_segs > 1024 || to->nr_segs != runtime->channels) in snd_pcm_readv()
3590 if (!frame_aligned(runtime, iov->iov_len)) in snd_pcm_readv()
3592 frames = bytes_to_samples(runtime, iov->iov_len); in snd_pcm_readv()
3602 result = frames_to_bytes(runtime, result); in snd_pcm_readv()
3611 struct snd_pcm_runtime *runtime; in snd_pcm_writev() local
3622 runtime = substream->runtime; in snd_pcm_writev()
3623 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_writev()
3624 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_writev()
3628 if (from->nr_segs > 128 || from->nr_segs != runtime->channels || in snd_pcm_writev()
3629 !frame_aligned(runtime, iov->iov_len)) in snd_pcm_writev()
3631 frames = bytes_to_samples(runtime, iov->iov_len); in snd_pcm_writev()
3641 result = frames_to_bytes(runtime, result); in snd_pcm_writev()
3650 struct snd_pcm_runtime *runtime; in snd_pcm_poll() local
3664 runtime = substream->runtime; in snd_pcm_poll()
3665 if (runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_poll()
3668 poll_wait(file, &runtime->sleep, wait); in snd_pcm_poll()
3673 switch (runtime->state) { in snd_pcm_poll()
3677 if (avail >= runtime->control->avail_min) in snd_pcm_poll()
3710 struct snd_pcm_runtime *runtime; in snd_pcm_mmap_status_fault() local
3714 runtime = substream->runtime; in snd_pcm_mmap_status_fault()
3715 vmf->page = virt_to_page(runtime->status); in snd_pcm_mmap_status_fault()
3748 struct snd_pcm_runtime *runtime; in snd_pcm_mmap_control_fault() local
3752 runtime = substream->runtime; in snd_pcm_mmap_control_fault()
3753 vmf->page = virt_to_page(runtime->control); in snd_pcm_mmap_control_fault()
3784 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_EXPLICIT_SYNC) in pcm_status_mmap_allowed()
3791 (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_SYNC_APPLPTR)) in pcm_status_mmap_allowed()
3801 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_EXPLICIT_SYNC) in pcm_control_mmap_allowed()
3807 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_SYNC_APPLPTR) in pcm_control_mmap_allowed()
3837 struct snd_pcm_runtime *runtime; in snd_pcm_mmap_data_fault() local
3844 runtime = substream->runtime; in snd_pcm_mmap_data_fault()
3846 dma_bytes = PAGE_ALIGN(runtime->dma_bytes); in snd_pcm_mmap_data_fault()
3852 page = virt_to_page(runtime->dma_area + offset); in snd_pcm_mmap_data_fault()
3918 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_mmap_iomem() local
3921 return vm_iomap_memory(area, runtime->dma_addr, runtime->dma_bytes); in snd_pcm_lib_mmap_iomem()
3932 struct snd_pcm_runtime *runtime; in snd_pcm_mmap_data() local
3945 runtime = substream->runtime; in snd_pcm_mmap_data()
3946 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_mmap_data()
3948 if (!(runtime->info & SNDRV_PCM_INFO_MMAP)) in snd_pcm_mmap_data()
3950 if (runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED || in snd_pcm_mmap_data()
3951 runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) in snd_pcm_mmap_data()
3955 dma_bytes = PAGE_ALIGN(runtime->dma_bytes); in snd_pcm_mmap_data()
3983 if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_mmap()
4014 struct snd_pcm_runtime *runtime; in snd_pcm_fasync() local
4020 runtime = substream->runtime; in snd_pcm_fasync()
4021 if (runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_fasync()
4023 return snd_fasync_helper(fd, file, on, &runtime->fasync); in snd_pcm_fasync()
4158 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_get_unmapped_area() local
4163 return (unsigned long)runtime->status; in snd_pcm_get_unmapped_area()
4165 return (unsigned long)runtime->control; in snd_pcm_get_unmapped_area()
4167 return (unsigned long)runtime->dma_area + offset; in snd_pcm_get_unmapped_area()