Lines Matching refs:runtime

266 	if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_MMAP))  in hw_support_mmap()
293 &substream->runtime->hw_constraints; in constrain_mask_params()
329 &substream->runtime->hw_constraints; in constrain_interval_params()
365 &substream->runtime->hw_constraints; in constrain_params_by_rules()
534 params->info = substream->runtime->hw.info; in fixup_unreferenced_params()
606 static int period_to_usecs(struct snd_pcm_runtime *runtime) in period_to_usecs() argument
610 if (! runtime->rate) in period_to_usecs()
614 usecs = (750000 / runtime->rate) * runtime->period_size; in period_to_usecs()
615 usecs += ((750000 % runtime->rate) * runtime->period_size) / in period_to_usecs()
616 runtime->rate; in period_to_usecs()
625 if (substream->runtime->state != SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_set_state()
626 __snd_pcm_set_state(substream->runtime, state); in snd_pcm_set_state()
635 &substream->runtime->trigger_tstamp); in snd_pcm_timer_notify()
641 if (substream->runtime && substream->runtime->stop_operating) { in snd_pcm_sync_stop()
642 substream->runtime->stop_operating = false; in snd_pcm_sync_stop()
717 static int snd_pcm_buffer_access_lock(struct snd_pcm_runtime *runtime) in snd_pcm_buffer_access_lock() argument
719 if (!atomic_dec_unless_positive(&runtime->buffer_accessing)) in snd_pcm_buffer_access_lock()
721 mutex_lock(&runtime->buffer_mutex); in snd_pcm_buffer_access_lock()
726 static void snd_pcm_buffer_access_unlock(struct snd_pcm_runtime *runtime) in snd_pcm_buffer_access_unlock() argument
728 mutex_unlock(&runtime->buffer_mutex); in snd_pcm_buffer_access_unlock()
729 atomic_inc(&runtime->buffer_accessing); in snd_pcm_buffer_access_unlock()
733 int snd_pcm_runtime_buffer_set_silence(struct snd_pcm_runtime *runtime) in snd_pcm_runtime_buffer_set_silence() argument
737 err = snd_pcm_buffer_access_lock(runtime); in snd_pcm_runtime_buffer_set_silence()
740 if (runtime->dma_area) in snd_pcm_runtime_buffer_set_silence()
741 snd_pcm_format_set_silence(runtime->format, runtime->dma_area, in snd_pcm_runtime_buffer_set_silence()
742 bytes_to_samples(runtime, runtime->dma_bytes)); in snd_pcm_runtime_buffer_set_silence()
743 snd_pcm_buffer_access_unlock(runtime); in snd_pcm_runtime_buffer_set_silence()
757 struct snd_pcm_runtime *runtime; in snd_pcm_hw_params() local
764 runtime = substream->runtime; in snd_pcm_hw_params()
765 err = snd_pcm_buffer_access_lock(runtime); in snd_pcm_hw_params()
769 switch (runtime->state) { in snd_pcm_hw_params()
805 runtime->buffer_changed = err > 0; in snd_pcm_hw_params()
814 runtime->access = params_access(params); in snd_pcm_hw_params()
815 runtime->format = params_format(params); in snd_pcm_hw_params()
816 runtime->subformat = params_subformat(params); in snd_pcm_hw_params()
817 runtime->channels = params_channels(params); in snd_pcm_hw_params()
818 runtime->rate = params_rate(params); in snd_pcm_hw_params()
819 runtime->period_size = params_period_size(params); in snd_pcm_hw_params()
820 runtime->periods = params_periods(params); in snd_pcm_hw_params()
821 runtime->buffer_size = params_buffer_size(params); in snd_pcm_hw_params()
822 runtime->info = params->info; in snd_pcm_hw_params()
823 runtime->rate_num = params->rate_num; in snd_pcm_hw_params()
824 runtime->rate_den = params->rate_den; in snd_pcm_hw_params()
825 runtime->no_period_wakeup = in snd_pcm_hw_params()
829 bits = snd_pcm_format_physical_width(runtime->format); in snd_pcm_hw_params()
830 runtime->sample_bits = bits; in snd_pcm_hw_params()
831 bits *= runtime->channels; in snd_pcm_hw_params()
832 runtime->frame_bits = bits; in snd_pcm_hw_params()
838 runtime->byte_align = bits / 8; in snd_pcm_hw_params()
839 runtime->min_align = frames; in snd_pcm_hw_params()
842 runtime->tstamp_mode = SNDRV_PCM_TSTAMP_NONE; in snd_pcm_hw_params()
843 runtime->period_step = 1; in snd_pcm_hw_params()
844 runtime->control->avail_min = runtime->period_size; in snd_pcm_hw_params()
845 runtime->start_threshold = 1; in snd_pcm_hw_params()
846 runtime->stop_threshold = runtime->buffer_size; in snd_pcm_hw_params()
847 runtime->silence_threshold = 0; in snd_pcm_hw_params()
848 runtime->silence_size = 0; in snd_pcm_hw_params()
849 runtime->boundary = runtime->buffer_size; in snd_pcm_hw_params()
850 while (runtime->boundary * 2 <= LONG_MAX - runtime->buffer_size) in snd_pcm_hw_params()
851 runtime->boundary *= 2; in snd_pcm_hw_params()
854 if (runtime->dma_area && !substream->ops->copy) { in snd_pcm_hw_params()
855 size_t size = runtime->dma_bytes; in snd_pcm_hw_params()
857 if (runtime->info & SNDRV_PCM_INFO_MMAP) in snd_pcm_hw_params()
859 memset(runtime->dma_area, 0, size); in snd_pcm_hw_params()
867 usecs = period_to_usecs(runtime); in snd_pcm_hw_params()
885 snd_pcm_buffer_access_unlock(runtime); in snd_pcm_hw_params()
922 struct snd_pcm_runtime *runtime; in snd_pcm_hw_free() local
927 runtime = substream->runtime; in snd_pcm_hw_free()
928 result = snd_pcm_buffer_access_lock(runtime); in snd_pcm_hw_free()
932 switch (runtime->state) { in snd_pcm_hw_free()
949 snd_pcm_buffer_access_unlock(runtime); in snd_pcm_hw_free()
956 struct snd_pcm_runtime *runtime; in snd_pcm_sw_params() local
961 runtime = substream->runtime; in snd_pcm_sw_params()
963 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_sw_params()
975 if (params->silence_size >= runtime->boundary) { in snd_pcm_sw_params()
981 if (params->silence_threshold > runtime->buffer_size) in snd_pcm_sw_params()
986 runtime->tstamp_mode = params->tstamp_mode; in snd_pcm_sw_params()
988 runtime->tstamp_type = params->tstamp_type; in snd_pcm_sw_params()
989 runtime->period_step = params->period_step; in snd_pcm_sw_params()
990 runtime->control->avail_min = params->avail_min; in snd_pcm_sw_params()
991 runtime->start_threshold = params->start_threshold; in snd_pcm_sw_params()
992 runtime->stop_threshold = params->stop_threshold; in snd_pcm_sw_params()
993 runtime->silence_threshold = params->silence_threshold; in snd_pcm_sw_params()
994 runtime->silence_size = params->silence_size; in snd_pcm_sw_params()
995 params->boundary = runtime->boundary; in snd_pcm_sw_params()
998 runtime->silence_size > 0) in snd_pcm_sw_params()
1000 err = snd_pcm_update_state(substream, runtime); in snd_pcm_sw_params()
1025 delay = snd_pcm_playback_hw_avail(substream->runtime); in snd_pcm_calc_delay()
1027 delay = snd_pcm_capture_avail(substream->runtime); in snd_pcm_calc_delay()
1028 return delay + substream->runtime->delay; in snd_pcm_calc_delay()
1034 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_status64() local
1039 &runtime->audio_tstamp_config); in snd_pcm_status64()
1042 if (runtime->audio_tstamp_config.type_requested == in snd_pcm_status64()
1044 if (runtime->hw.info & SNDRV_PCM_INFO_HAS_WALL_CLOCK) in snd_pcm_status64()
1045 runtime->audio_tstamp_config.type_requested = in snd_pcm_status64()
1048 runtime->audio_tstamp_config.type_requested = in snd_pcm_status64()
1050 runtime->audio_tstamp_report.valid = 0; in snd_pcm_status64()
1052 runtime->audio_tstamp_report.valid = 1; in snd_pcm_status64()
1054 status->state = runtime->state; in snd_pcm_status64()
1055 status->suspended_state = runtime->suspended_state; in snd_pcm_status64()
1058 status->trigger_tstamp_sec = runtime->trigger_tstamp.tv_sec; in snd_pcm_status64()
1059 status->trigger_tstamp_nsec = runtime->trigger_tstamp.tv_nsec; in snd_pcm_status64()
1062 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { in snd_pcm_status64()
1063 status->tstamp_sec = runtime->status->tstamp.tv_sec; in snd_pcm_status64()
1065 runtime->status->tstamp.tv_nsec; in snd_pcm_status64()
1067 runtime->driver_tstamp.tv_sec; in snd_pcm_status64()
1069 runtime->driver_tstamp.tv_nsec; in snd_pcm_status64()
1071 runtime->status->audio_tstamp.tv_sec; in snd_pcm_status64()
1073 runtime->status->audio_tstamp.tv_nsec; in snd_pcm_status64()
1074 if (runtime->audio_tstamp_report.valid == 1) in snd_pcm_status64()
1078 &runtime->audio_tstamp_report); in snd_pcm_status64()
1084 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { in snd_pcm_status64()
1087 snd_pcm_gettime(runtime, &tstamp); in snd_pcm_status64()
1093 status->appl_ptr = runtime->control->appl_ptr; in snd_pcm_status64()
1094 status->hw_ptr = runtime->status->hw_ptr; in snd_pcm_status64()
1098 status->avail_max = runtime->avail_max; in snd_pcm_status64()
1099 status->overrange = runtime->overrange; in snd_pcm_status64()
1100 runtime->avail_max = 0; in snd_pcm_status64()
1101 runtime->overrange = 0; in snd_pcm_status64()
1181 struct snd_pcm_runtime *runtime; in snd_pcm_channel_info() local
1185 runtime = substream->runtime; in snd_pcm_channel_info()
1187 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_channel_info()
1190 if (channel >= runtime->channels) in snd_pcm_channel_info()
1215 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_trigger_tstamp() local
1216 if (runtime->trigger_master == NULL) in snd_pcm_trigger_tstamp()
1218 if (runtime->trigger_master == substream) { in snd_pcm_trigger_tstamp()
1219 if (!runtime->trigger_tstamp_latched) in snd_pcm_trigger_tstamp()
1220 snd_pcm_gettime(runtime, &runtime->trigger_tstamp); in snd_pcm_trigger_tstamp()
1222 snd_pcm_trigger_tstamp(runtime->trigger_master); in snd_pcm_trigger_tstamp()
1223 runtime->trigger_tstamp = runtime->trigger_master->runtime->trigger_tstamp; in snd_pcm_trigger_tstamp()
1225 runtime->trigger_master = NULL; in snd_pcm_trigger_tstamp()
1258 mutex_lock_nested(&s->runtime->buffer_mutex, depth); in snd_pcm_action_group()
1291 mutex_unlock(&s1->runtime->buffer_mutex); in snd_pcm_action_group()
1424 res = snd_pcm_buffer_access_lock(substream->runtime); in snd_pcm_action_nonatomic()
1431 snd_pcm_buffer_access_unlock(substream->runtime); in snd_pcm_action_nonatomic()
1441 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_start() local
1442 if (runtime->state != SNDRV_PCM_STATE_PREPARED) in snd_pcm_pre_start()
1447 runtime->trigger_tstamp_latched = false; in snd_pcm_pre_start()
1448 runtime->trigger_master = substream; in snd_pcm_pre_start()
1457 if (substream->runtime->trigger_master != substream) in snd_pcm_do_start()
1462 __snd_pcm_set_state(substream->runtime, SNDRV_PCM_STATE_XRUN); in snd_pcm_do_start()
1469 if (substream->runtime->trigger_master == substream) { in snd_pcm_undo_start()
1471 substream->runtime->stop_operating = true; in snd_pcm_undo_start()
1478 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_start() local
1480 runtime->hw_ptr_jiffies = jiffies; in snd_pcm_post_start()
1481 runtime->hw_ptr_buffer_jiffies = (runtime->buffer_size * HZ) / in snd_pcm_post_start()
1482 runtime->rate; in snd_pcm_post_start()
1483 __snd_pcm_set_state(runtime, state); in snd_pcm_post_start()
1485 runtime->silence_size > 0) in snd_pcm_post_start()
1523 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_stop() local
1524 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_pre_stop()
1526 runtime->trigger_master = substream; in snd_pcm_pre_stop()
1533 if (substream->runtime->trigger_master == substream && in snd_pcm_do_stop()
1536 substream->runtime->stop_operating = true; in snd_pcm_do_stop()
1544 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_stop() local
1545 if (runtime->state != state) { in snd_pcm_post_stop()
1547 __snd_pcm_set_state(runtime, state); in snd_pcm_post_stop()
1550 wake_up(&runtime->sleep); in snd_pcm_post_stop()
1551 wake_up(&runtime->tsleep); in snd_pcm_post_stop()
1602 if (substream->runtime && snd_pcm_running(substream)) in snd_pcm_stop_xrun()
1616 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_pause() local
1617 if (!(runtime->info & SNDRV_PCM_INFO_PAUSE)) in snd_pcm_pre_pause()
1620 if (runtime->state != SNDRV_PCM_STATE_RUNNING) in snd_pcm_pre_pause()
1622 } else if (runtime->state != SNDRV_PCM_STATE_PAUSED) in snd_pcm_pre_pause()
1624 runtime->trigger_master = substream; in snd_pcm_pre_pause()
1631 if (substream->runtime->trigger_master != substream) in snd_pcm_do_pause()
1637 substream->runtime->hw_ptr_jiffies = jiffies - HZ * 1000; in snd_pcm_do_pause()
1647 if (substream->runtime->trigger_master == substream) in snd_pcm_undo_pause()
1657 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_pause() local
1660 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_PAUSED); in snd_pcm_post_pause()
1662 wake_up(&runtime->sleep); in snd_pcm_post_pause()
1663 wake_up(&runtime->tsleep); in snd_pcm_post_pause()
1665 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_RUNNING); in snd_pcm_post_pause()
1699 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_suspend() local
1700 switch (runtime->state) { in snd_pcm_pre_suspend()
1709 runtime->trigger_master = substream; in snd_pcm_pre_suspend()
1716 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_suspend() local
1717 if (runtime->trigger_master != substream) in snd_pcm_do_suspend()
1722 runtime->stop_operating = true; in snd_pcm_do_suspend()
1729 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_suspend() local
1731 runtime->suspended_state = runtime->state; in snd_pcm_post_suspend()
1732 runtime->status->suspended_state = runtime->suspended_state; in snd_pcm_post_suspend()
1733 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_SUSPENDED); in snd_pcm_post_suspend()
1735 wake_up(&runtime->sleep); in snd_pcm_post_suspend()
1736 wake_up(&runtime->tsleep); in snd_pcm_post_suspend()
1778 if (!substream->runtime) in snd_pcm_suspend_all()
1805 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_resume() local
1806 if (runtime->state != SNDRV_PCM_STATE_SUSPENDED) in snd_pcm_pre_resume()
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
1877 switch (runtime->state) { in snd_pcm_xrun()
1895 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_reset() local
1896 switch (runtime->state) { in snd_pcm_pre_reset()
1910 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_reset() local
1915 runtime->hw_ptr_base = 0; in snd_pcm_do_reset()
1916 runtime->hw_ptr_interrupt = runtime->status->hw_ptr - in snd_pcm_do_reset()
1917 runtime->status->hw_ptr % runtime->period_size; in snd_pcm_do_reset()
1918 runtime->silence_start = runtime->status->hw_ptr; in snd_pcm_do_reset()
1919 runtime->silence_filled = 0; in snd_pcm_do_reset()
1926 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_reset() local
1928 runtime->control->appl_ptr = runtime->status->hw_ptr; in snd_pcm_post_reset()
1930 runtime->silence_size > 0) in snd_pcm_post_reset()
1953 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_prepare() local
1956 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_pre_prepare()
1957 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_pre_prepare()
1979 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_prepare() local
1980 runtime->control->appl_ptr = runtime->status->hw_ptr; in snd_pcm_post_prepare()
2008 switch (substream->runtime->state) { in snd_pcm_prepare()
2031 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_drain_init() local
2032 switch (runtime->state) { in snd_pcm_pre_drain_init()
2038 runtime->trigger_master = substream; in snd_pcm_pre_drain_init()
2045 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_drain_init() local
2047 switch (runtime->state) { in snd_pcm_do_drain_init()
2054 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_SETUP); in snd_pcm_do_drain_init()
2058 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_DRAINING); in snd_pcm_do_drain_init()
2061 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_SETUP); in snd_pcm_do_drain_init()
2068 if (runtime->state == SNDRV_PCM_STATE_RUNNING) { in snd_pcm_do_drain_init()
2071 new_state = snd_pcm_capture_avail(runtime) > 0 ? in snd_pcm_do_drain_init()
2078 if (runtime->state == SNDRV_PCM_STATE_DRAINING && in snd_pcm_do_drain_init()
2079 runtime->trigger_master == substream && in snd_pcm_do_drain_init()
2080 (runtime->hw.info & SNDRV_PCM_INFO_DRAIN_TRIGGER)) in snd_pcm_do_drain_init()
2109 struct snd_pcm_runtime *runtime; in snd_pcm_drain() local
2117 runtime = substream->runtime; in snd_pcm_drain()
2119 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_drain()
2130 if (runtime->state == SNDRV_PCM_STATE_PAUSED) in snd_pcm_drain()
2161 runtime = s->runtime; in snd_pcm_drain()
2162 if (runtime->state == SNDRV_PCM_STATE_DRAINING) { in snd_pcm_drain()
2163 to_check = runtime; in snd_pcm_drain()
2198 if (s->runtime == to_check) { in snd_pcm_drain()
2210 if (substream->runtime->state == SNDRV_PCM_STATE_SUSPENDED) in snd_pcm_drain()
2235 struct snd_pcm_runtime *runtime; in snd_pcm_drop() local
2240 runtime = substream->runtime; in snd_pcm_drop()
2242 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_drop()
2243 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_drop()
2248 if (runtime->state == SNDRV_PCM_STATE_PAUSED) 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()
2522 static int snd_pcm_hw_constraint_subformats(struct snd_pcm_runtime *runtime, in snd_pcm_hw_constraint_subformats() argument
2525 return snd_pcm_hw_rule_add(runtime, cond, -1, in snd_pcm_hw_constraint_subformats()
2533 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_init() local
2534 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_constraints_init()
2551 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FORMAT, in snd_pcm_hw_constraints_init()
2556 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, in snd_pcm_hw_constraints_init()
2562 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, in snd_pcm_hw_constraints_init()
2567 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS, in snd_pcm_hw_constraints_init()
2572 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS, in snd_pcm_hw_constraints_init()
2577 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS, in snd_pcm_hw_constraints_init()
2582 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, in snd_pcm_hw_constraints_init()
2587 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, in snd_pcm_hw_constraints_init()
2592 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, in snd_pcm_hw_constraints_init()
2597 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIODS, in snd_pcm_hw_constraints_init()
2602 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, in snd_pcm_hw_constraints_init()
2607 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, in snd_pcm_hw_constraints_init()
2612 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, in snd_pcm_hw_constraints_init()
2617 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, in snd_pcm_hw_constraints_init()
2622 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, in snd_pcm_hw_constraints_init()
2627 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, in snd_pcm_hw_constraints_init()
2632 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, in snd_pcm_hw_constraints_init()
2637 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, in snd_pcm_hw_constraints_init()
2642 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_TIME, in snd_pcm_hw_constraints_init()
2647 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_TIME, in snd_pcm_hw_constraints_init()
2657 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_complete() local
2658 struct snd_pcm_hardware *hw = &runtime->hw; in snd_pcm_hw_constraints_complete()
2674 err = snd_pcm_hw_constraint_mask(runtime, SNDRV_PCM_HW_PARAM_ACCESS, mask); in snd_pcm_hw_constraints_complete()
2678 err = snd_pcm_hw_constraint_mask64(runtime, SNDRV_PCM_HW_PARAM_FORMAT, hw->formats); in snd_pcm_hw_constraints_complete()
2682 err = snd_pcm_hw_constraint_subformats(runtime, 0, &hw->subformats); in snd_pcm_hw_constraints_complete()
2686 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_CHANNELS, in snd_pcm_hw_constraints_complete()
2691 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_RATE, in snd_pcm_hw_constraints_complete()
2696 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, in snd_pcm_hw_constraints_complete()
2701 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIODS, in snd_pcm_hw_constraints_complete()
2706 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, in snd_pcm_hw_constraints_complete()
2711 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, in snd_pcm_hw_constraints_complete()
2718 if (runtime->dma_bytes) { in snd_pcm_hw_constraints_complete()
2719 …err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 0, runtime->dma_bytes… in snd_pcm_hw_constraints_complete()
2725 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, in snd_pcm_hw_constraints_complete()
2733 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE); in snd_pcm_hw_constraints_complete()
2752 if (substream->runtime->state != SNDRV_PCM_STATE_OPEN) in snd_pcm_release_substream()
2805 substream->runtime->hw.info |= SNDRV_PCM_INFO_EXPLICIT_SYNC; in snd_pcm_open_substream()
2956 switch (substream->runtime->state) { in do_pcm_hwsync()
2980 struct snd_pcm_runtime *runtime = substream->runtime; in forward_appl_ptr() local
2988 appl_ptr = runtime->control->appl_ptr + frames; in forward_appl_ptr()
2989 if (appl_ptr >= (snd_pcm_sframes_t)runtime->boundary) in forward_appl_ptr()
2990 appl_ptr -= runtime->boundary; in forward_appl_ptr()
3000 struct snd_pcm_runtime *runtime = substream->runtime; in rewind_appl_ptr() local
3008 appl_ptr = runtime->control->appl_ptr - frames; in rewind_appl_ptr()
3010 appl_ptr += runtime->boundary; in rewind_appl_ptr()
3121 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_sync_ptr() local
3131 status = runtime->status; in snd_pcm_sync_ptr()
3132 control = runtime->control; in snd_pcm_sync_ptr()
3190 static snd_pcm_uframes_t recalculate_boundary(struct snd_pcm_runtime *runtime) in recalculate_boundary() argument
3196 if (! runtime->buffer_size) in recalculate_boundary()
3199 border = 0x7fffffffUL - runtime->buffer_size; in recalculate_boundary()
3200 if (runtime->buffer_size > border) in recalculate_boundary()
3201 return runtime->buffer_size; in recalculate_boundary()
3203 order = __fls(border) - __fls(runtime->buffer_size); in recalculate_boundary()
3204 boundary = runtime->buffer_size << order; in recalculate_boundary()
3215 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_ioctl_sync_ptr_compat() local
3224 if (snd_BUG_ON(!runtime)) in snd_pcm_ioctl_sync_ptr_compat()
3234 status = runtime->status; in snd_pcm_ioctl_sync_ptr_compat()
3235 control = runtime->control; in snd_pcm_ioctl_sync_ptr_compat()
3236 boundary = recalculate_boundary(runtime); in snd_pcm_ioctl_sync_ptr_compat()
3269 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_tstamp() local
3276 runtime->tstamp_type = arg; in snd_pcm_tstamp()
3284 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xferi_frames_ioctl() local
3287 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_xferi_frames_ioctl()
3306 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xfern_frames_ioctl() local
3310 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_xfern_frames_ioctl()
3312 if (runtime->channels > 128) in snd_pcm_xfern_frames_ioctl()
3319 bufs = memdup_array_user(xfern.bufs, runtime->channels, sizeof(void *)); in snd_pcm_xfern_frames_ioctl()
3373 if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_common_ioctl()
3504 if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_kernel_ioctl()
3541 struct snd_pcm_runtime *runtime; in snd_pcm_read() local
3548 runtime = substream->runtime; in snd_pcm_read()
3549 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_read()
3550 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_read()
3552 if (!frame_aligned(runtime, count)) in snd_pcm_read()
3554 count = bytes_to_frames(runtime, count); in snd_pcm_read()
3557 result = frames_to_bytes(runtime, result); in snd_pcm_read()
3566 struct snd_pcm_runtime *runtime; in snd_pcm_write() local
3573 runtime = substream->runtime; in snd_pcm_write()
3574 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_write()
3575 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_write()
3577 if (!frame_aligned(runtime, count)) in snd_pcm_write()
3579 count = bytes_to_frames(runtime, count); in snd_pcm_write()
3582 result = frames_to_bytes(runtime, result); in snd_pcm_write()
3590 struct snd_pcm_runtime *runtime; in snd_pcm_readv() local
3600 runtime = substream->runtime; in snd_pcm_readv()
3601 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_readv()
3602 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_readv()
3606 if (to->nr_segs > 1024 || to->nr_segs != runtime->channels) in snd_pcm_readv()
3608 if (!frame_aligned(runtime, iov->iov_len)) in snd_pcm_readv()
3610 frames = bytes_to_samples(runtime, iov->iov_len); in snd_pcm_readv()
3622 result = frames_to_bytes(runtime, result); in snd_pcm_readv()
3630 struct snd_pcm_runtime *runtime; in snd_pcm_writev() local
3640 runtime = substream->runtime; in snd_pcm_writev()
3641 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_writev()
3642 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_writev()
3646 if (from->nr_segs > 128 || from->nr_segs != runtime->channels || in snd_pcm_writev()
3647 !frame_aligned(runtime, iov->iov_len)) in snd_pcm_writev()
3649 frames = bytes_to_samples(runtime, iov->iov_len); in snd_pcm_writev()
3661 result = frames_to_bytes(runtime, result); in snd_pcm_writev()
3669 struct snd_pcm_runtime *runtime; in snd_pcm_poll() local
3683 runtime = substream->runtime; in snd_pcm_poll()
3684 if (runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_poll()
3687 poll_wait(file, &runtime->sleep, wait); in snd_pcm_poll()
3692 switch (runtime->state) { in snd_pcm_poll()
3696 if (avail >= runtime->control->avail_min) in snd_pcm_poll()
3728 struct snd_pcm_runtime *runtime; in snd_pcm_mmap_status_fault() local
3732 runtime = substream->runtime; in snd_pcm_mmap_status_fault()
3733 vmf->page = virt_to_page(runtime->status); in snd_pcm_mmap_status_fault()
3766 struct snd_pcm_runtime *runtime; in snd_pcm_mmap_control_fault() local
3770 runtime = substream->runtime; in snd_pcm_mmap_control_fault()
3771 vmf->page = virt_to_page(runtime->control); in snd_pcm_mmap_control_fault()
3802 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_EXPLICIT_SYNC) in pcm_status_mmap_allowed()
3809 (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_SYNC_APPLPTR)) in pcm_status_mmap_allowed()
3819 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_EXPLICIT_SYNC) in pcm_control_mmap_allowed()
3825 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_SYNC_APPLPTR) in pcm_control_mmap_allowed()
3875 struct snd_pcm_runtime *runtime; in snd_pcm_mmap_data_fault() local
3882 runtime = substream->runtime; in snd_pcm_mmap_data_fault()
3884 dma_bytes = PAGE_ALIGN(runtime->dma_bytes); in snd_pcm_mmap_data_fault()
3890 if (WARN_ON_ONCE(!runtime->dma_area)) in snd_pcm_mmap_data_fault()
3892 page = virt_to_page(runtime->dma_area + offset); in snd_pcm_mmap_data_fault()
3958 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_mmap_iomem() local
3961 return vm_iomap_memory(area, runtime->dma_addr, runtime->dma_bytes); in snd_pcm_lib_mmap_iomem()
3972 struct snd_pcm_runtime *runtime; in snd_pcm_mmap_data() local
3985 runtime = substream->runtime; in snd_pcm_mmap_data()
3986 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_mmap_data()
3988 if (!(runtime->info & SNDRV_PCM_INFO_MMAP)) in snd_pcm_mmap_data()
3990 if (runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED || in snd_pcm_mmap_data()
3991 runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) in snd_pcm_mmap_data()
3995 dma_bytes = PAGE_ALIGN(runtime->dma_bytes); in snd_pcm_mmap_data()
4023 if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_mmap()
4054 struct snd_pcm_runtime *runtime; in snd_pcm_fasync() local
4060 runtime = substream->runtime; in snd_pcm_fasync()
4061 if (runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_fasync()
4063 return snd_fasync_helper(fd, file, on, &runtime->fasync); in snd_pcm_fasync()
4186 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_get_unmapped_area() local
4191 return (unsigned long)runtime->status; in snd_pcm_get_unmapped_area()
4193 return (unsigned long)runtime->control; in snd_pcm_get_unmapped_area()
4195 return (unsigned long)runtime->dma_area + offset; in snd_pcm_get_unmapped_area()