Lines Matching refs: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()
529 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()
630 &substream->runtime->trigger_tstamp); in snd_pcm_timer_notify()
636 if (substream->runtime && substream->runtime->stop_operating) { in snd_pcm_sync_stop()
637 substream->runtime->stop_operating = false; in snd_pcm_sync_stop()
712 static int snd_pcm_buffer_access_lock(struct snd_pcm_runtime *runtime) in snd_pcm_buffer_access_lock() argument
714 if (!atomic_dec_unless_positive(&runtime->buffer_accessing)) in snd_pcm_buffer_access_lock()
716 mutex_lock(&runtime->buffer_mutex); in snd_pcm_buffer_access_lock()
721 static void snd_pcm_buffer_access_unlock(struct snd_pcm_runtime *runtime) in snd_pcm_buffer_access_unlock() argument
723 mutex_unlock(&runtime->buffer_mutex); in snd_pcm_buffer_access_unlock()
724 atomic_inc(&runtime->buffer_accessing); in snd_pcm_buffer_access_unlock()
728 void snd_pcm_runtime_buffer_set_silence(struct snd_pcm_runtime *runtime) in snd_pcm_runtime_buffer_set_silence() argument
730 snd_pcm_buffer_access_lock(runtime); in snd_pcm_runtime_buffer_set_silence()
731 if (runtime->dma_area) in snd_pcm_runtime_buffer_set_silence()
732 snd_pcm_format_set_silence(runtime->format, runtime->dma_area, in snd_pcm_runtime_buffer_set_silence()
733 bytes_to_samples(runtime, runtime->dma_bytes)); in snd_pcm_runtime_buffer_set_silence()
734 snd_pcm_buffer_access_unlock(runtime); in snd_pcm_runtime_buffer_set_silence()
747 struct snd_pcm_runtime *runtime; in snd_pcm_hw_params() local
754 runtime = substream->runtime; in snd_pcm_hw_params()
755 err = snd_pcm_buffer_access_lock(runtime); in snd_pcm_hw_params()
759 switch (runtime->state) { in snd_pcm_hw_params()
795 runtime->buffer_changed = err > 0; in snd_pcm_hw_params()
804 runtime->access = params_access(params); in snd_pcm_hw_params()
805 runtime->format = params_format(params); in snd_pcm_hw_params()
806 runtime->subformat = params_subformat(params); in snd_pcm_hw_params()
807 runtime->channels = params_channels(params); in snd_pcm_hw_params()
808 runtime->rate = params_rate(params); in snd_pcm_hw_params()
809 runtime->period_size = params_period_size(params); in snd_pcm_hw_params()
810 runtime->periods = params_periods(params); in snd_pcm_hw_params()
811 runtime->buffer_size = params_buffer_size(params); in snd_pcm_hw_params()
812 runtime->info = params->info; in snd_pcm_hw_params()
813 runtime->rate_num = params->rate_num; in snd_pcm_hw_params()
814 runtime->rate_den = params->rate_den; in snd_pcm_hw_params()
815 runtime->no_period_wakeup = in snd_pcm_hw_params()
819 bits = snd_pcm_format_physical_width(runtime->format); in snd_pcm_hw_params()
820 runtime->sample_bits = bits; in snd_pcm_hw_params()
821 bits *= runtime->channels; in snd_pcm_hw_params()
822 runtime->frame_bits = bits; in snd_pcm_hw_params()
828 runtime->byte_align = bits / 8; in snd_pcm_hw_params()
829 runtime->min_align = frames; in snd_pcm_hw_params()
832 runtime->tstamp_mode = SNDRV_PCM_TSTAMP_NONE; in snd_pcm_hw_params()
833 runtime->period_step = 1; in snd_pcm_hw_params()
834 runtime->control->avail_min = runtime->period_size; in snd_pcm_hw_params()
835 runtime->start_threshold = 1; in snd_pcm_hw_params()
836 runtime->stop_threshold = runtime->buffer_size; in snd_pcm_hw_params()
837 runtime->silence_threshold = 0; in snd_pcm_hw_params()
838 runtime->silence_size = 0; in snd_pcm_hw_params()
839 runtime->boundary = runtime->buffer_size; in snd_pcm_hw_params()
840 while (runtime->boundary * 2 <= LONG_MAX - runtime->buffer_size) in snd_pcm_hw_params()
841 runtime->boundary *= 2; in snd_pcm_hw_params()
844 if (runtime->dma_area && !substream->ops->copy) { in snd_pcm_hw_params()
845 size_t size = runtime->dma_bytes; in snd_pcm_hw_params()
847 if (runtime->info & SNDRV_PCM_INFO_MMAP) in snd_pcm_hw_params()
849 memset(runtime->dma_area, 0, size); in snd_pcm_hw_params()
857 usecs = period_to_usecs(runtime); in snd_pcm_hw_params()
875 snd_pcm_buffer_access_unlock(runtime); in snd_pcm_hw_params()
912 struct snd_pcm_runtime *runtime; in snd_pcm_hw_free() local
917 runtime = substream->runtime; in snd_pcm_hw_free()
918 result = snd_pcm_buffer_access_lock(runtime); in snd_pcm_hw_free()
922 switch (runtime->state) { in snd_pcm_hw_free()
939 snd_pcm_buffer_access_unlock(runtime); in snd_pcm_hw_free()
946 struct snd_pcm_runtime *runtime; in snd_pcm_sw_params() local
951 runtime = substream->runtime; in snd_pcm_sw_params()
953 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_sw_params()
965 if (params->silence_size >= runtime->boundary) { in snd_pcm_sw_params()
971 if (params->silence_threshold > runtime->buffer_size) in snd_pcm_sw_params()
976 runtime->tstamp_mode = params->tstamp_mode; in snd_pcm_sw_params()
978 runtime->tstamp_type = params->tstamp_type; in snd_pcm_sw_params()
979 runtime->period_step = params->period_step; in snd_pcm_sw_params()
980 runtime->control->avail_min = params->avail_min; in snd_pcm_sw_params()
981 runtime->start_threshold = params->start_threshold; in snd_pcm_sw_params()
982 runtime->stop_threshold = params->stop_threshold; in snd_pcm_sw_params()
983 runtime->silence_threshold = params->silence_threshold; in snd_pcm_sw_params()
984 runtime->silence_size = params->silence_size; in snd_pcm_sw_params()
985 params->boundary = runtime->boundary; in snd_pcm_sw_params()
988 runtime->silence_size > 0) in snd_pcm_sw_params()
990 err = snd_pcm_update_state(substream, runtime); in snd_pcm_sw_params()
1015 delay = snd_pcm_playback_hw_avail(substream->runtime); in snd_pcm_calc_delay()
1017 delay = snd_pcm_capture_avail(substream->runtime); in snd_pcm_calc_delay()
1018 return delay + substream->runtime->delay; in snd_pcm_calc_delay()
1024 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_status64() local
1029 &runtime->audio_tstamp_config); in snd_pcm_status64()
1032 if (runtime->audio_tstamp_config.type_requested == in snd_pcm_status64()
1034 if (runtime->hw.info & SNDRV_PCM_INFO_HAS_WALL_CLOCK) in snd_pcm_status64()
1035 runtime->audio_tstamp_config.type_requested = in snd_pcm_status64()
1038 runtime->audio_tstamp_config.type_requested = in snd_pcm_status64()
1040 runtime->audio_tstamp_report.valid = 0; in snd_pcm_status64()
1042 runtime->audio_tstamp_report.valid = 1; in snd_pcm_status64()
1044 status->state = runtime->state; in snd_pcm_status64()
1045 status->suspended_state = runtime->suspended_state; in snd_pcm_status64()
1048 status->trigger_tstamp_sec = runtime->trigger_tstamp.tv_sec; in snd_pcm_status64()
1049 status->trigger_tstamp_nsec = runtime->trigger_tstamp.tv_nsec; in snd_pcm_status64()
1052 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { in snd_pcm_status64()
1053 status->tstamp_sec = runtime->status->tstamp.tv_sec; in snd_pcm_status64()
1055 runtime->status->tstamp.tv_nsec; in snd_pcm_status64()
1057 runtime->driver_tstamp.tv_sec; in snd_pcm_status64()
1059 runtime->driver_tstamp.tv_nsec; in snd_pcm_status64()
1061 runtime->status->audio_tstamp.tv_sec; in snd_pcm_status64()
1063 runtime->status->audio_tstamp.tv_nsec; in snd_pcm_status64()
1064 if (runtime->audio_tstamp_report.valid == 1) in snd_pcm_status64()
1068 &runtime->audio_tstamp_report); in snd_pcm_status64()
1074 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { in snd_pcm_status64()
1077 snd_pcm_gettime(runtime, &tstamp); in snd_pcm_status64()
1083 status->appl_ptr = runtime->control->appl_ptr; in snd_pcm_status64()
1084 status->hw_ptr = runtime->status->hw_ptr; in snd_pcm_status64()
1088 status->avail_max = runtime->avail_max; in snd_pcm_status64()
1089 status->overrange = runtime->overrange; in snd_pcm_status64()
1090 runtime->avail_max = 0; in snd_pcm_status64()
1091 runtime->overrange = 0; in snd_pcm_status64()
1171 struct snd_pcm_runtime *runtime; in snd_pcm_channel_info() local
1175 runtime = substream->runtime; in snd_pcm_channel_info()
1177 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_channel_info()
1180 if (channel >= runtime->channels) in snd_pcm_channel_info()
1205 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_trigger_tstamp() local
1206 if (runtime->trigger_master == NULL) in snd_pcm_trigger_tstamp()
1208 if (runtime->trigger_master == substream) { in snd_pcm_trigger_tstamp()
1209 if (!runtime->trigger_tstamp_latched) in snd_pcm_trigger_tstamp()
1210 snd_pcm_gettime(runtime, &runtime->trigger_tstamp); in snd_pcm_trigger_tstamp()
1212 snd_pcm_trigger_tstamp(runtime->trigger_master); in snd_pcm_trigger_tstamp()
1213 runtime->trigger_tstamp = runtime->trigger_master->runtime->trigger_tstamp; in snd_pcm_trigger_tstamp()
1215 runtime->trigger_master = NULL; in snd_pcm_trigger_tstamp()
1248 mutex_lock_nested(&s->runtime->buffer_mutex, depth); in snd_pcm_action_group()
1281 mutex_unlock(&s1->runtime->buffer_mutex); in snd_pcm_action_group()
1414 res = snd_pcm_buffer_access_lock(substream->runtime); in snd_pcm_action_nonatomic()
1421 snd_pcm_buffer_access_unlock(substream->runtime); in snd_pcm_action_nonatomic()
1431 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_start() local
1432 if (runtime->state != SNDRV_PCM_STATE_PREPARED) in snd_pcm_pre_start()
1437 runtime->trigger_tstamp_latched = false; in snd_pcm_pre_start()
1438 runtime->trigger_master = substream; in snd_pcm_pre_start()
1447 if (substream->runtime->trigger_master != substream) in snd_pcm_do_start()
1452 __snd_pcm_set_state(substream->runtime, SNDRV_PCM_STATE_XRUN); in snd_pcm_do_start()
1459 if (substream->runtime->trigger_master == substream) { in snd_pcm_undo_start()
1461 substream->runtime->stop_operating = true; in snd_pcm_undo_start()
1468 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_start() local
1470 runtime->hw_ptr_jiffies = jiffies; in snd_pcm_post_start()
1471 runtime->hw_ptr_buffer_jiffies = (runtime->buffer_size * HZ) / in snd_pcm_post_start()
1472 runtime->rate; in snd_pcm_post_start()
1473 __snd_pcm_set_state(runtime, state); in snd_pcm_post_start()
1475 runtime->silence_size > 0) in snd_pcm_post_start()
1513 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_stop() local
1514 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_pre_stop()
1516 runtime->trigger_master = substream; in snd_pcm_pre_stop()
1523 if (substream->runtime->trigger_master == substream && in snd_pcm_do_stop()
1526 substream->runtime->stop_operating = true; in snd_pcm_do_stop()
1534 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_stop() local
1535 if (runtime->state != state) { in snd_pcm_post_stop()
1537 __snd_pcm_set_state(runtime, state); in snd_pcm_post_stop()
1540 wake_up(&runtime->sleep); in snd_pcm_post_stop()
1541 wake_up(&runtime->tsleep); in snd_pcm_post_stop()
1592 if (substream->runtime && snd_pcm_running(substream)) in snd_pcm_stop_xrun()
1606 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_pause() local
1607 if (!(runtime->info & SNDRV_PCM_INFO_PAUSE)) in snd_pcm_pre_pause()
1610 if (runtime->state != SNDRV_PCM_STATE_RUNNING) in snd_pcm_pre_pause()
1612 } else if (runtime->state != SNDRV_PCM_STATE_PAUSED) in snd_pcm_pre_pause()
1614 runtime->trigger_master = substream; in snd_pcm_pre_pause()
1621 if (substream->runtime->trigger_master != substream) in snd_pcm_do_pause()
1627 substream->runtime->hw_ptr_jiffies = jiffies - HZ * 1000; in snd_pcm_do_pause()
1637 if (substream->runtime->trigger_master == substream) in snd_pcm_undo_pause()
1647 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_pause() local
1650 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_PAUSED); in snd_pcm_post_pause()
1652 wake_up(&runtime->sleep); in snd_pcm_post_pause()
1653 wake_up(&runtime->tsleep); in snd_pcm_post_pause()
1655 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_RUNNING); in snd_pcm_post_pause()
1689 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_suspend() local
1690 switch (runtime->state) { in snd_pcm_pre_suspend()
1699 runtime->trigger_master = substream; in snd_pcm_pre_suspend()
1706 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_suspend() local
1707 if (runtime->trigger_master != substream) in snd_pcm_do_suspend()
1712 runtime->stop_operating = true; in snd_pcm_do_suspend()
1719 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_suspend() local
1721 runtime->suspended_state = runtime->state; in snd_pcm_post_suspend()
1722 runtime->status->suspended_state = runtime->suspended_state; in snd_pcm_post_suspend()
1723 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_SUSPENDED); in snd_pcm_post_suspend()
1725 wake_up(&runtime->sleep); in snd_pcm_post_suspend()
1726 wake_up(&runtime->tsleep); in snd_pcm_post_suspend()
1768 if (!substream->runtime) in snd_pcm_suspend_all()
1795 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_resume() local
1796 if (runtime->state != SNDRV_PCM_STATE_SUSPENDED) in snd_pcm_pre_resume()
1798 if (!(runtime->info & SNDRV_PCM_INFO_RESUME)) in snd_pcm_pre_resume()
1800 runtime->trigger_master = substream; in snd_pcm_pre_resume()
1807 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_resume() local
1808 if (runtime->trigger_master != substream) in snd_pcm_do_resume()
1811 if (runtime->suspended_state != SNDRV_PCM_STATE_RUNNING && in snd_pcm_do_resume()
1812 (runtime->suspended_state != SNDRV_PCM_STATE_DRAINING || in snd_pcm_do_resume()
1821 if (substream->runtime->trigger_master == substream && in snd_pcm_undo_resume()
1829 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_resume() local
1831 __snd_pcm_set_state(runtime, runtime->suspended_state); in snd_pcm_post_resume()
1864 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xrun() local
1867 switch (runtime->state) { in snd_pcm_xrun()
1885 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_reset() local
1886 switch (runtime->state) { in snd_pcm_pre_reset()
1900 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_reset() local
1905 runtime->hw_ptr_base = 0; in snd_pcm_do_reset()
1906 runtime->hw_ptr_interrupt = runtime->status->hw_ptr - in snd_pcm_do_reset()
1907 runtime->status->hw_ptr % runtime->period_size; in snd_pcm_do_reset()
1908 runtime->silence_start = runtime->status->hw_ptr; in snd_pcm_do_reset()
1909 runtime->silence_filled = 0; in snd_pcm_do_reset()
1916 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_reset() local
1918 runtime->control->appl_ptr = runtime->status->hw_ptr; in snd_pcm_post_reset()
1920 runtime->silence_size > 0) in snd_pcm_post_reset()
1943 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_prepare() local
1946 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_pre_prepare()
1947 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_pre_prepare()
1969 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_prepare() local
1970 runtime->control->appl_ptr = runtime->status->hw_ptr; in snd_pcm_post_prepare()
1998 switch (substream->runtime->state) { in snd_pcm_prepare()
2021 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_drain_init() local
2022 switch (runtime->state) { in snd_pcm_pre_drain_init()
2028 runtime->trigger_master = substream; in snd_pcm_pre_drain_init()
2035 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_drain_init() local
2037 switch (runtime->state) { in snd_pcm_do_drain_init()
2044 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_SETUP); in snd_pcm_do_drain_init()
2048 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_DRAINING); in snd_pcm_do_drain_init()
2051 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_SETUP); in snd_pcm_do_drain_init()
2058 if (runtime->state == SNDRV_PCM_STATE_RUNNING) { in snd_pcm_do_drain_init()
2061 new_state = snd_pcm_capture_avail(runtime) > 0 ? in snd_pcm_do_drain_init()
2068 if (runtime->state == SNDRV_PCM_STATE_DRAINING && in snd_pcm_do_drain_init()
2069 runtime->trigger_master == substream && in snd_pcm_do_drain_init()
2070 (runtime->hw.info & SNDRV_PCM_INFO_DRAIN_TRIGGER)) in snd_pcm_do_drain_init()
2099 struct snd_pcm_runtime *runtime; in snd_pcm_drain() local
2107 runtime = substream->runtime; in snd_pcm_drain()
2109 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_drain()
2120 if (runtime->state == SNDRV_PCM_STATE_PAUSED) in snd_pcm_drain()
2147 runtime = s->runtime; in snd_pcm_drain()
2148 if (runtime->state == SNDRV_PCM_STATE_DRAINING) { in snd_pcm_drain()
2149 to_check = runtime; in snd_pcm_drain()
2160 if (runtime->no_period_wakeup) in snd_pcm_drain()
2164 if (runtime->rate) { in snd_pcm_drain()
2165 long t = runtime->buffer_size * 1100 / runtime->rate; in snd_pcm_drain()
2175 if (s->runtime == to_check) { in snd_pcm_drain()
2187 if (substream->runtime->state == SNDRV_PCM_STATE_SUSPENDED) in snd_pcm_drain()
2212 struct snd_pcm_runtime *runtime; in snd_pcm_drop() local
2217 runtime = substream->runtime; in snd_pcm_drop()
2219 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_drop()
2220 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_drop()
2225 if (runtime->state == SNDRV_PCM_STATE_PAUSED) in snd_pcm_drop()
2282 if (substream->runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_link()
2283 substream->runtime->state != substream1->runtime->state || in snd_pcm_link()
2499 static int snd_pcm_hw_constraint_subformats(struct snd_pcm_runtime *runtime, in snd_pcm_hw_constraint_subformats() argument
2502 return snd_pcm_hw_rule_add(runtime, cond, -1, in snd_pcm_hw_constraint_subformats()
2510 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_init() local
2511 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_constraints_init()
2528 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FORMAT, in snd_pcm_hw_constraints_init()
2533 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, in snd_pcm_hw_constraints_init()
2539 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, in snd_pcm_hw_constraints_init()
2544 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS, in snd_pcm_hw_constraints_init()
2549 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS, in snd_pcm_hw_constraints_init()
2554 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS, in snd_pcm_hw_constraints_init()
2559 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, in snd_pcm_hw_constraints_init()
2564 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, in snd_pcm_hw_constraints_init()
2569 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, in snd_pcm_hw_constraints_init()
2574 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIODS, in snd_pcm_hw_constraints_init()
2579 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, in snd_pcm_hw_constraints_init()
2584 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, in snd_pcm_hw_constraints_init()
2589 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, in snd_pcm_hw_constraints_init()
2594 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, in snd_pcm_hw_constraints_init()
2599 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, in snd_pcm_hw_constraints_init()
2604 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, in snd_pcm_hw_constraints_init()
2609 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, in snd_pcm_hw_constraints_init()
2614 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, in snd_pcm_hw_constraints_init()
2619 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_TIME, in snd_pcm_hw_constraints_init()
2624 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_TIME, in snd_pcm_hw_constraints_init()
2634 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_complete() local
2635 struct snd_pcm_hardware *hw = &runtime->hw; in snd_pcm_hw_constraints_complete()
2651 err = snd_pcm_hw_constraint_mask(runtime, SNDRV_PCM_HW_PARAM_ACCESS, mask); in snd_pcm_hw_constraints_complete()
2655 err = snd_pcm_hw_constraint_mask64(runtime, SNDRV_PCM_HW_PARAM_FORMAT, hw->formats); in snd_pcm_hw_constraints_complete()
2659 err = snd_pcm_hw_constraint_subformats(runtime, 0, &hw->subformats); in snd_pcm_hw_constraints_complete()
2663 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_CHANNELS, in snd_pcm_hw_constraints_complete()
2668 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_RATE, in snd_pcm_hw_constraints_complete()
2673 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, in snd_pcm_hw_constraints_complete()
2678 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIODS, in snd_pcm_hw_constraints_complete()
2683 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, in snd_pcm_hw_constraints_complete()
2688 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, in snd_pcm_hw_constraints_complete()
2695 if (runtime->dma_bytes) { in snd_pcm_hw_constraints_complete()
2696 …err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 0, runtime->dma_bytes… in snd_pcm_hw_constraints_complete()
2702 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, in snd_pcm_hw_constraints_complete()
2710 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE); in snd_pcm_hw_constraints_complete()
2729 if (substream->runtime->state != SNDRV_PCM_STATE_OPEN) in snd_pcm_release_substream()
2782 substream->runtime->hw.info |= SNDRV_PCM_INFO_EXPLICIT_SYNC; in snd_pcm_open_substream()
2933 switch (substream->runtime->state) { in do_pcm_hwsync()
2957 struct snd_pcm_runtime *runtime = substream->runtime; in forward_appl_ptr() local
2965 appl_ptr = runtime->control->appl_ptr + frames; in forward_appl_ptr()
2966 if (appl_ptr >= (snd_pcm_sframes_t)runtime->boundary) in forward_appl_ptr()
2967 appl_ptr -= runtime->boundary; in forward_appl_ptr()
2977 struct snd_pcm_runtime *runtime = substream->runtime; in rewind_appl_ptr() local
2985 appl_ptr = runtime->control->appl_ptr - frames; in rewind_appl_ptr()
2987 appl_ptr += runtime->boundary; in rewind_appl_ptr()
3098 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_sync_ptr() local
3108 status = runtime->status; in snd_pcm_sync_ptr()
3109 control = runtime->control; in snd_pcm_sync_ptr()
3167 static snd_pcm_uframes_t recalculate_boundary(struct snd_pcm_runtime *runtime) in recalculate_boundary() argument
3173 if (! runtime->buffer_size) in recalculate_boundary()
3176 border = 0x7fffffffUL - runtime->buffer_size; in recalculate_boundary()
3177 if (runtime->buffer_size > border) in recalculate_boundary()
3178 return runtime->buffer_size; in recalculate_boundary()
3180 order = __fls(border) - __fls(runtime->buffer_size); in recalculate_boundary()
3181 boundary = runtime->buffer_size << order; in recalculate_boundary()
3192 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_ioctl_sync_ptr_compat() local
3201 if (snd_BUG_ON(!runtime)) in snd_pcm_ioctl_sync_ptr_compat()
3211 status = runtime->status; in snd_pcm_ioctl_sync_ptr_compat()
3212 control = runtime->control; in snd_pcm_ioctl_sync_ptr_compat()
3213 boundary = recalculate_boundary(runtime); in snd_pcm_ioctl_sync_ptr_compat()
3246 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_tstamp() local
3253 runtime->tstamp_type = arg; in snd_pcm_tstamp()
3261 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xferi_frames_ioctl() local
3264 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_xferi_frames_ioctl()
3283 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xfern_frames_ioctl() local
3287 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_xfern_frames_ioctl()
3289 if (runtime->channels > 128) in snd_pcm_xfern_frames_ioctl()
3296 bufs = memdup_array_user(xfern.bufs, runtime->channels, sizeof(void *)); in snd_pcm_xfern_frames_ioctl()
3350 if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_common_ioctl()
3481 if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_kernel_ioctl()
3518 struct snd_pcm_runtime *runtime; in snd_pcm_read() local
3525 runtime = substream->runtime; in snd_pcm_read()
3526 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_read()
3527 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_read()
3529 if (!frame_aligned(runtime, count)) in snd_pcm_read()
3531 count = bytes_to_frames(runtime, count); in snd_pcm_read()
3534 result = frames_to_bytes(runtime, result); in snd_pcm_read()
3543 struct snd_pcm_runtime *runtime; in snd_pcm_write() local
3550 runtime = substream->runtime; in snd_pcm_write()
3551 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_write()
3552 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_write()
3554 if (!frame_aligned(runtime, count)) in snd_pcm_write()
3556 count = bytes_to_frames(runtime, count); in snd_pcm_write()
3559 result = frames_to_bytes(runtime, result); in snd_pcm_write()
3567 struct snd_pcm_runtime *runtime; in snd_pcm_readv() local
3578 runtime = substream->runtime; in snd_pcm_readv()
3579 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_readv()
3580 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_readv()
3584 if (to->nr_segs > 1024 || to->nr_segs != runtime->channels) in snd_pcm_readv()
3586 if (!frame_aligned(runtime, iov->iov_len)) in snd_pcm_readv()
3588 frames = bytes_to_samples(runtime, iov->iov_len); in snd_pcm_readv()
3598 result = frames_to_bytes(runtime, result); in snd_pcm_readv()
3606 struct snd_pcm_runtime *runtime; in snd_pcm_writev() local
3617 runtime = substream->runtime; in snd_pcm_writev()
3618 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_writev()
3619 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_writev()
3623 if (from->nr_segs > 128 || from->nr_segs != runtime->channels || in snd_pcm_writev()
3624 !frame_aligned(runtime, iov->iov_len)) in snd_pcm_writev()
3626 frames = bytes_to_samples(runtime, iov->iov_len); in snd_pcm_writev()
3636 result = frames_to_bytes(runtime, result); in snd_pcm_writev()
3644 struct snd_pcm_runtime *runtime; in snd_pcm_poll() local
3658 runtime = substream->runtime; in snd_pcm_poll()
3659 if (runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_poll()
3662 poll_wait(file, &runtime->sleep, wait); in snd_pcm_poll()
3667 switch (runtime->state) { in snd_pcm_poll()
3671 if (avail >= runtime->control->avail_min) in snd_pcm_poll()
3703 struct snd_pcm_runtime *runtime; in snd_pcm_mmap_status_fault() local
3707 runtime = substream->runtime; in snd_pcm_mmap_status_fault()
3708 vmf->page = virt_to_page(runtime->status); in snd_pcm_mmap_status_fault()
3741 struct snd_pcm_runtime *runtime; in snd_pcm_mmap_control_fault() local
3745 runtime = substream->runtime; in snd_pcm_mmap_control_fault()
3746 vmf->page = virt_to_page(runtime->control); in snd_pcm_mmap_control_fault()
3777 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_EXPLICIT_SYNC) in pcm_status_mmap_allowed()
3784 (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_SYNC_APPLPTR)) in pcm_status_mmap_allowed()
3794 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_EXPLICIT_SYNC) in pcm_control_mmap_allowed()
3800 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_SYNC_APPLPTR) in pcm_control_mmap_allowed()
3850 struct snd_pcm_runtime *runtime; in snd_pcm_mmap_data_fault() local
3857 runtime = substream->runtime; in snd_pcm_mmap_data_fault()
3859 dma_bytes = PAGE_ALIGN(runtime->dma_bytes); in snd_pcm_mmap_data_fault()
3865 if (WARN_ON_ONCE(!runtime->dma_area)) in snd_pcm_mmap_data_fault()
3867 page = virt_to_page(runtime->dma_area + offset); in snd_pcm_mmap_data_fault()
3933 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_mmap_iomem() local
3936 return vm_iomap_memory(area, runtime->dma_addr, runtime->dma_bytes); in snd_pcm_lib_mmap_iomem()
3947 struct snd_pcm_runtime *runtime; in snd_pcm_mmap_data() local
3960 runtime = substream->runtime; in snd_pcm_mmap_data()
3961 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_mmap_data()
3963 if (!(runtime->info & SNDRV_PCM_INFO_MMAP)) in snd_pcm_mmap_data()
3965 if (runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED || in snd_pcm_mmap_data()
3966 runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) in snd_pcm_mmap_data()
3970 dma_bytes = PAGE_ALIGN(runtime->dma_bytes); in snd_pcm_mmap_data()
3998 if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_mmap()
4029 struct snd_pcm_runtime *runtime; in snd_pcm_fasync() local
4035 runtime = substream->runtime; in snd_pcm_fasync()
4036 if (runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_fasync()
4038 return snd_fasync_helper(fd, file, on, &runtime->fasync); in snd_pcm_fasync()
4161 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_get_unmapped_area() local
4166 return (unsigned long)runtime->status; in snd_pcm_get_unmapped_area()
4168 return (unsigned long)runtime->control; in snd_pcm_get_unmapped_area()
4170 return (unsigned long)runtime->dma_area + offset; in snd_pcm_get_unmapped_area()