Lines Matching full:runtime
260 if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_MMAP)) in hw_support_mmap()
287 &substream->runtime->hw_constraints; in constrain_mask_params()
323 &substream->runtime->hw_constraints; in constrain_interval_params()
359 &substream->runtime->hw_constraints; in constrain_params_by_rules()
528 params->info = substream->runtime->hw.info; in fixup_unreferenced_params()
600 static int period_to_usecs(struct snd_pcm_runtime *runtime) in period_to_usecs() argument
604 if (! runtime->rate) in period_to_usecs()
608 usecs = (750000 / runtime->rate) * runtime->period_size; in period_to_usecs()
609 usecs += ((750000 % runtime->rate) * runtime->period_size) / in period_to_usecs()
610 runtime->rate; in period_to_usecs()
619 if (substream->runtime->state != SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_set_state()
620 __snd_pcm_set_state(substream->runtime, state); in snd_pcm_set_state()
629 &substream->runtime->trigger_tstamp); in snd_pcm_timer_notify()
635 if (substream->runtime && substream->runtime->stop_operating) { in snd_pcm_sync_stop()
636 substream->runtime->stop_operating = false; in snd_pcm_sync_stop()
711 static int snd_pcm_buffer_access_lock(struct snd_pcm_runtime *runtime) in snd_pcm_buffer_access_lock() argument
713 if (!atomic_dec_unless_positive(&runtime->buffer_accessing)) in snd_pcm_buffer_access_lock()
715 mutex_lock(&runtime->buffer_mutex); in snd_pcm_buffer_access_lock()
720 static void snd_pcm_buffer_access_unlock(struct snd_pcm_runtime *runtime) in snd_pcm_buffer_access_unlock() argument
722 mutex_unlock(&runtime->buffer_mutex); in snd_pcm_buffer_access_unlock()
723 atomic_inc(&runtime->buffer_accessing); in snd_pcm_buffer_access_unlock()
735 struct snd_pcm_runtime *runtime; in snd_pcm_hw_params() local
742 runtime = substream->runtime; in snd_pcm_hw_params()
743 err = snd_pcm_buffer_access_lock(runtime); in snd_pcm_hw_params()
747 switch (runtime->state) { in snd_pcm_hw_params()
783 runtime->buffer_changed = err > 0; in snd_pcm_hw_params()
792 runtime->access = params_access(params); in snd_pcm_hw_params()
793 runtime->format = params_format(params); in snd_pcm_hw_params()
794 runtime->subformat = params_subformat(params); in snd_pcm_hw_params()
795 runtime->channels = params_channels(params); in snd_pcm_hw_params()
796 runtime->rate = params_rate(params); in snd_pcm_hw_params()
797 runtime->period_size = params_period_size(params); in snd_pcm_hw_params()
798 runtime->periods = params_periods(params); in snd_pcm_hw_params()
799 runtime->buffer_size = params_buffer_size(params); in snd_pcm_hw_params()
800 runtime->info = params->info; in snd_pcm_hw_params()
801 runtime->rate_num = params->rate_num; in snd_pcm_hw_params()
802 runtime->rate_den = params->rate_den; in snd_pcm_hw_params()
803 runtime->no_period_wakeup = in snd_pcm_hw_params()
807 bits = snd_pcm_format_physical_width(runtime->format); in snd_pcm_hw_params()
808 runtime->sample_bits = bits; in snd_pcm_hw_params()
809 bits *= runtime->channels; in snd_pcm_hw_params()
810 runtime->frame_bits = bits; in snd_pcm_hw_params()
816 runtime->byte_align = bits / 8; in snd_pcm_hw_params()
817 runtime->min_align = frames; in snd_pcm_hw_params()
820 runtime->tstamp_mode = SNDRV_PCM_TSTAMP_NONE; in snd_pcm_hw_params()
821 runtime->period_step = 1; in snd_pcm_hw_params()
822 runtime->control->avail_min = runtime->period_size; in snd_pcm_hw_params()
823 runtime->start_threshold = 1; in snd_pcm_hw_params()
824 runtime->stop_threshold = runtime->buffer_size; in snd_pcm_hw_params()
825 runtime->silence_threshold = 0; in snd_pcm_hw_params()
826 runtime->silence_size = 0; in snd_pcm_hw_params()
827 runtime->boundary = runtime->buffer_size; in snd_pcm_hw_params()
828 while (runtime->boundary * 2 <= LONG_MAX - runtime->buffer_size) in snd_pcm_hw_params()
829 runtime->boundary *= 2; in snd_pcm_hw_params()
832 if (runtime->dma_area && !substream->ops->copy) { in snd_pcm_hw_params()
833 size_t size = runtime->dma_bytes; in snd_pcm_hw_params()
835 if (runtime->info & SNDRV_PCM_INFO_MMAP) in snd_pcm_hw_params()
837 memset(runtime->dma_area, 0, size); in snd_pcm_hw_params()
845 usecs = period_to_usecs(runtime); in snd_pcm_hw_params()
863 snd_pcm_buffer_access_unlock(runtime); in snd_pcm_hw_params()
900 struct snd_pcm_runtime *runtime; in snd_pcm_hw_free() local
905 runtime = substream->runtime; in snd_pcm_hw_free()
906 result = snd_pcm_buffer_access_lock(runtime); in snd_pcm_hw_free()
910 switch (runtime->state) { in snd_pcm_hw_free()
927 snd_pcm_buffer_access_unlock(runtime); in snd_pcm_hw_free()
934 struct snd_pcm_runtime *runtime; in snd_pcm_sw_params() local
939 runtime = substream->runtime; in snd_pcm_sw_params()
941 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_sw_params()
953 if (params->silence_size >= runtime->boundary) { in snd_pcm_sw_params()
959 if (params->silence_threshold > runtime->buffer_size) in snd_pcm_sw_params()
964 runtime->tstamp_mode = params->tstamp_mode; in snd_pcm_sw_params()
966 runtime->tstamp_type = params->tstamp_type; in snd_pcm_sw_params()
967 runtime->period_step = params->period_step; in snd_pcm_sw_params()
968 runtime->control->avail_min = params->avail_min; in snd_pcm_sw_params()
969 runtime->start_threshold = params->start_threshold; in snd_pcm_sw_params()
970 runtime->stop_threshold = params->stop_threshold; in snd_pcm_sw_params()
971 runtime->silence_threshold = params->silence_threshold; in snd_pcm_sw_params()
972 runtime->silence_size = params->silence_size; in snd_pcm_sw_params()
973 params->boundary = runtime->boundary; in snd_pcm_sw_params()
976 runtime->silence_size > 0) in snd_pcm_sw_params()
978 err = snd_pcm_update_state(substream, runtime); in snd_pcm_sw_params()
1003 delay = snd_pcm_playback_hw_avail(substream->runtime); in snd_pcm_calc_delay()
1005 delay = snd_pcm_capture_avail(substream->runtime); in snd_pcm_calc_delay()
1006 return delay + substream->runtime->delay; in snd_pcm_calc_delay()
1012 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_status64() local
1017 &runtime->audio_tstamp_config); in snd_pcm_status64()
1020 if (runtime->audio_tstamp_config.type_requested == in snd_pcm_status64()
1022 if (runtime->hw.info & SNDRV_PCM_INFO_HAS_WALL_CLOCK) in snd_pcm_status64()
1023 runtime->audio_tstamp_config.type_requested = in snd_pcm_status64()
1026 runtime->audio_tstamp_config.type_requested = in snd_pcm_status64()
1028 runtime->audio_tstamp_report.valid = 0; in snd_pcm_status64()
1030 runtime->audio_tstamp_report.valid = 1; in snd_pcm_status64()
1032 status->state = runtime->state; in snd_pcm_status64()
1033 status->suspended_state = runtime->suspended_state; in snd_pcm_status64()
1036 status->trigger_tstamp_sec = runtime->trigger_tstamp.tv_sec; in snd_pcm_status64()
1037 status->trigger_tstamp_nsec = runtime->trigger_tstamp.tv_nsec; in snd_pcm_status64()
1040 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { in snd_pcm_status64()
1041 status->tstamp_sec = runtime->status->tstamp.tv_sec; in snd_pcm_status64()
1043 runtime->status->tstamp.tv_nsec; in snd_pcm_status64()
1045 runtime->driver_tstamp.tv_sec; in snd_pcm_status64()
1047 runtime->driver_tstamp.tv_nsec; in snd_pcm_status64()
1049 runtime->status->audio_tstamp.tv_sec; in snd_pcm_status64()
1051 runtime->status->audio_tstamp.tv_nsec; in snd_pcm_status64()
1052 if (runtime->audio_tstamp_report.valid == 1) in snd_pcm_status64()
1056 &runtime->audio_tstamp_report); in snd_pcm_status64()
1062 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { in snd_pcm_status64()
1065 snd_pcm_gettime(runtime, &tstamp); in snd_pcm_status64()
1071 status->appl_ptr = runtime->control->appl_ptr; in snd_pcm_status64()
1072 status->hw_ptr = runtime->status->hw_ptr; in snd_pcm_status64()
1076 status->avail_max = runtime->avail_max; in snd_pcm_status64()
1077 status->overrange = runtime->overrange; in snd_pcm_status64()
1078 runtime->avail_max = 0; in snd_pcm_status64()
1079 runtime->overrange = 0; in snd_pcm_status64()
1159 struct snd_pcm_runtime *runtime; in snd_pcm_channel_info() local
1163 runtime = substream->runtime; in snd_pcm_channel_info()
1165 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_channel_info()
1168 if (channel >= runtime->channels) in snd_pcm_channel_info()
1193 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_trigger_tstamp() local
1194 if (runtime->trigger_master == NULL) in snd_pcm_trigger_tstamp()
1196 if (runtime->trigger_master == substream) { in snd_pcm_trigger_tstamp()
1197 if (!runtime->trigger_tstamp_latched) in snd_pcm_trigger_tstamp()
1198 snd_pcm_gettime(runtime, &runtime->trigger_tstamp); in snd_pcm_trigger_tstamp()
1200 snd_pcm_trigger_tstamp(runtime->trigger_master); in snd_pcm_trigger_tstamp()
1201 runtime->trigger_tstamp = runtime->trigger_master->runtime->trigger_tstamp; in snd_pcm_trigger_tstamp()
1203 runtime->trigger_master = NULL; in snd_pcm_trigger_tstamp()
1236 mutex_lock_nested(&s->runtime->buffer_mutex, depth); in snd_pcm_action_group()
1269 mutex_unlock(&s1->runtime->buffer_mutex); in snd_pcm_action_group()
1402 res = snd_pcm_buffer_access_lock(substream->runtime); in snd_pcm_action_nonatomic()
1409 snd_pcm_buffer_access_unlock(substream->runtime); in snd_pcm_action_nonatomic()
1419 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_start() local
1420 if (runtime->state != SNDRV_PCM_STATE_PREPARED) in snd_pcm_pre_start()
1425 runtime->trigger_tstamp_latched = false; in snd_pcm_pre_start()
1426 runtime->trigger_master = substream; in snd_pcm_pre_start()
1435 if (substream->runtime->trigger_master != substream) in snd_pcm_do_start()
1440 __snd_pcm_set_state(substream->runtime, SNDRV_PCM_STATE_XRUN); in snd_pcm_do_start()
1447 if (substream->runtime->trigger_master == substream) { in snd_pcm_undo_start()
1449 substream->runtime->stop_operating = true; in snd_pcm_undo_start()
1456 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_start() local
1458 runtime->hw_ptr_jiffies = jiffies; in snd_pcm_post_start()
1459 runtime->hw_ptr_buffer_jiffies = (runtime->buffer_size * HZ) / in snd_pcm_post_start()
1460 runtime->rate; in snd_pcm_post_start()
1461 __snd_pcm_set_state(runtime, state); in snd_pcm_post_start()
1463 runtime->silence_size > 0) in snd_pcm_post_start()
1501 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_stop() local
1502 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_pre_stop()
1504 runtime->trigger_master = substream; in snd_pcm_pre_stop()
1511 if (substream->runtime->trigger_master == substream && in snd_pcm_do_stop()
1514 substream->runtime->stop_operating = true; in snd_pcm_do_stop()
1522 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_stop() local
1523 if (runtime->state != state) { in snd_pcm_post_stop()
1525 __snd_pcm_set_state(runtime, state); in snd_pcm_post_stop()
1528 wake_up(&runtime->sleep); in snd_pcm_post_stop()
1529 wake_up(&runtime->tsleep); in snd_pcm_post_stop()
1580 if (substream->runtime && snd_pcm_running(substream)) in snd_pcm_stop_xrun()
1594 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_pause() local
1595 if (!(runtime->info & SNDRV_PCM_INFO_PAUSE)) in snd_pcm_pre_pause()
1598 if (runtime->state != SNDRV_PCM_STATE_RUNNING) in snd_pcm_pre_pause()
1600 } else if (runtime->state != SNDRV_PCM_STATE_PAUSED) in snd_pcm_pre_pause()
1602 runtime->trigger_master = substream; in snd_pcm_pre_pause()
1609 if (substream->runtime->trigger_master != substream) in snd_pcm_do_pause()
1615 substream->runtime->hw_ptr_jiffies = jiffies - HZ * 1000; in snd_pcm_do_pause()
1625 if (substream->runtime->trigger_master == substream) in snd_pcm_undo_pause()
1635 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_pause() local
1638 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_PAUSED); in snd_pcm_post_pause()
1640 wake_up(&runtime->sleep); in snd_pcm_post_pause()
1641 wake_up(&runtime->tsleep); in snd_pcm_post_pause()
1643 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_RUNNING); in snd_pcm_post_pause()
1677 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_suspend() local
1678 switch (runtime->state) { in snd_pcm_pre_suspend()
1687 runtime->trigger_master = substream; in snd_pcm_pre_suspend()
1694 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_suspend() local
1695 if (runtime->trigger_master != substream) in snd_pcm_do_suspend()
1700 runtime->stop_operating = true; in snd_pcm_do_suspend()
1707 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_suspend() local
1709 runtime->suspended_state = runtime->state; in snd_pcm_post_suspend()
1710 runtime->status->suspended_state = runtime->suspended_state; in snd_pcm_post_suspend()
1711 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_SUSPENDED); in snd_pcm_post_suspend()
1713 wake_up(&runtime->sleep); in snd_pcm_post_suspend()
1714 wake_up(&runtime->tsleep); in snd_pcm_post_suspend()
1756 if (!substream->runtime) in snd_pcm_suspend_all()
1783 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_resume() local
1784 if (runtime->state != SNDRV_PCM_STATE_SUSPENDED) in snd_pcm_pre_resume()
1786 if (!(runtime->info & SNDRV_PCM_INFO_RESUME)) in snd_pcm_pre_resume()
1788 runtime->trigger_master = substream; in snd_pcm_pre_resume()
1795 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_resume() local
1796 if (runtime->trigger_master != substream) in snd_pcm_do_resume()
1799 if (runtime->suspended_state != SNDRV_PCM_STATE_RUNNING && in snd_pcm_do_resume()
1800 (runtime->suspended_state != SNDRV_PCM_STATE_DRAINING || in snd_pcm_do_resume()
1809 if (substream->runtime->trigger_master == substream && in snd_pcm_undo_resume()
1817 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_resume() local
1819 __snd_pcm_set_state(runtime, runtime->suspended_state); in snd_pcm_post_resume()
1852 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xrun() local
1855 switch (runtime->state) { in snd_pcm_xrun()
1873 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_reset() local
1874 switch (runtime->state) { in snd_pcm_pre_reset()
1888 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_reset() local
1893 runtime->hw_ptr_base = 0; in snd_pcm_do_reset()
1894 runtime->hw_ptr_interrupt = runtime->status->hw_ptr - in snd_pcm_do_reset()
1895 runtime->status->hw_ptr % runtime->period_size; in snd_pcm_do_reset()
1896 runtime->silence_start = runtime->status->hw_ptr; in snd_pcm_do_reset()
1897 runtime->silence_filled = 0; in snd_pcm_do_reset()
1904 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_reset() local
1906 runtime->control->appl_ptr = runtime->status->hw_ptr; in snd_pcm_post_reset()
1908 runtime->silence_size > 0) in snd_pcm_post_reset()
1931 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_prepare() local
1934 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_pre_prepare()
1935 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_pre_prepare()
1957 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_prepare() local
1958 runtime->control->appl_ptr = runtime->status->hw_ptr; in snd_pcm_post_prepare()
1986 switch (substream->runtime->state) { in snd_pcm_prepare()
2009 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_drain_init() local
2010 switch (runtime->state) { in snd_pcm_pre_drain_init()
2016 runtime->trigger_master = substream; in snd_pcm_pre_drain_init()
2023 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_drain_init() local
2025 switch (runtime->state) { in snd_pcm_do_drain_init()
2032 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_SETUP); in snd_pcm_do_drain_init()
2036 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_DRAINING); in snd_pcm_do_drain_init()
2039 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_SETUP); in snd_pcm_do_drain_init()
2046 if (runtime->state == SNDRV_PCM_STATE_RUNNING) { in snd_pcm_do_drain_init()
2049 new_state = snd_pcm_capture_avail(runtime) > 0 ? in snd_pcm_do_drain_init()
2056 if (runtime->state == SNDRV_PCM_STATE_DRAINING && in snd_pcm_do_drain_init()
2057 runtime->trigger_master == substream && in snd_pcm_do_drain_init()
2058 (runtime->hw.info & SNDRV_PCM_INFO_DRAIN_TRIGGER)) in snd_pcm_do_drain_init()
2087 struct snd_pcm_runtime *runtime; in snd_pcm_drain() local
2095 runtime = substream->runtime; in snd_pcm_drain()
2097 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_drain()
2108 if (runtime->state == SNDRV_PCM_STATE_PAUSED) in snd_pcm_drain()
2135 runtime = s->runtime; in snd_pcm_drain()
2136 if (runtime->state == SNDRV_PCM_STATE_DRAINING) { in snd_pcm_drain()
2137 to_check = runtime; in snd_pcm_drain()
2148 if (runtime->no_period_wakeup) in snd_pcm_drain()
2152 if (runtime->rate) { in snd_pcm_drain()
2153 long t = runtime->buffer_size * 1100 / runtime->rate; in snd_pcm_drain()
2163 if (s->runtime == to_check) { in snd_pcm_drain()
2175 if (substream->runtime->state == SNDRV_PCM_STATE_SUSPENDED) in snd_pcm_drain()
2200 struct snd_pcm_runtime *runtime; in snd_pcm_drop() local
2205 runtime = substream->runtime; in snd_pcm_drop()
2207 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_drop()
2208 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_drop()
2213 if (runtime->state == SNDRV_PCM_STATE_PAUSED) in snd_pcm_drop()
2217 /* runtime->control->appl_ptr = runtime->status->hw_ptr; */ in snd_pcm_drop()
2270 if (substream->runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_link()
2271 substream->runtime->state != substream1->runtime->state || in snd_pcm_link()
2487 static int snd_pcm_hw_constraint_subformats(struct snd_pcm_runtime *runtime, in snd_pcm_hw_constraint_subformats() argument
2490 return snd_pcm_hw_rule_add(runtime, cond, -1, in snd_pcm_hw_constraint_subformats()
2498 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_init() local
2499 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_constraints_init()
2516 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FORMAT, in snd_pcm_hw_constraints_init()
2521 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, in snd_pcm_hw_constraints_init()
2527 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, in snd_pcm_hw_constraints_init()
2532 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS, in snd_pcm_hw_constraints_init()
2537 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS, in snd_pcm_hw_constraints_init()
2542 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS, in snd_pcm_hw_constraints_init()
2547 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, in snd_pcm_hw_constraints_init()
2552 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, in snd_pcm_hw_constraints_init()
2557 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, in snd_pcm_hw_constraints_init()
2562 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIODS, in snd_pcm_hw_constraints_init()
2567 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, in snd_pcm_hw_constraints_init()
2572 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, in snd_pcm_hw_constraints_init()
2577 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, in snd_pcm_hw_constraints_init()
2582 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, in snd_pcm_hw_constraints_init()
2587 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, in snd_pcm_hw_constraints_init()
2592 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, in snd_pcm_hw_constraints_init()
2597 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, in snd_pcm_hw_constraints_init()
2602 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, in snd_pcm_hw_constraints_init()
2607 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_TIME, in snd_pcm_hw_constraints_init()
2612 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_TIME, in snd_pcm_hw_constraints_init()
2622 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_complete() local
2623 struct snd_pcm_hardware *hw = &runtime->hw; in snd_pcm_hw_constraints_complete()
2639 err = snd_pcm_hw_constraint_mask(runtime, SNDRV_PCM_HW_PARAM_ACCESS, mask); in snd_pcm_hw_constraints_complete()
2643 err = snd_pcm_hw_constraint_mask64(runtime, SNDRV_PCM_HW_PARAM_FORMAT, hw->formats); in snd_pcm_hw_constraints_complete()
2647 err = snd_pcm_hw_constraint_subformats(runtime, 0, &hw->subformats); in snd_pcm_hw_constraints_complete()
2651 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_CHANNELS, in snd_pcm_hw_constraints_complete()
2656 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_RATE, in snd_pcm_hw_constraints_complete()
2661 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, in snd_pcm_hw_constraints_complete()
2666 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIODS, in snd_pcm_hw_constraints_complete()
2671 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, in snd_pcm_hw_constraints_complete()
2676 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, in snd_pcm_hw_constraints_complete()
2683 if (runtime->dma_bytes) { in snd_pcm_hw_constraints_complete()
2684 …err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 0, runtime->dma_bytes… in snd_pcm_hw_constraints_complete()
2690 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, in snd_pcm_hw_constraints_complete()
2698 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE); in snd_pcm_hw_constraints_complete()
2717 if (substream->runtime->state != SNDRV_PCM_STATE_OPEN) in snd_pcm_release_substream()
2770 substream->runtime->hw.info |= SNDRV_PCM_INFO_EXPLICIT_SYNC; in snd_pcm_open_substream()
2921 switch (substream->runtime->state) { in do_pcm_hwsync()
2945 struct snd_pcm_runtime *runtime = substream->runtime; in forward_appl_ptr() local
2953 appl_ptr = runtime->control->appl_ptr + frames; in forward_appl_ptr()
2954 if (appl_ptr >= (snd_pcm_sframes_t)runtime->boundary) in forward_appl_ptr()
2955 appl_ptr -= runtime->boundary; in forward_appl_ptr()
2965 struct snd_pcm_runtime *runtime = substream->runtime; in rewind_appl_ptr() local
2973 appl_ptr = runtime->control->appl_ptr - frames; in rewind_appl_ptr()
2975 appl_ptr += runtime->boundary; in rewind_appl_ptr()
3046 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_sync_ptr() local
3057 status = runtime->status; in snd_pcm_sync_ptr()
3058 control = runtime->control; in snd_pcm_sync_ptr()
3119 static snd_pcm_uframes_t recalculate_boundary(struct snd_pcm_runtime *runtime) in recalculate_boundary() argument
3123 if (! runtime->buffer_size) in recalculate_boundary()
3125 boundary = runtime->buffer_size; in recalculate_boundary()
3126 while (boundary * 2 <= 0x7fffffffUL - runtime->buffer_size) in recalculate_boundary()
3134 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_ioctl_sync_ptr_compat() local
3143 if (snd_BUG_ON(!runtime)) in snd_pcm_ioctl_sync_ptr_compat()
3155 status = runtime->status; in snd_pcm_ioctl_sync_ptr_compat()
3156 control = runtime->control; in snd_pcm_ioctl_sync_ptr_compat()
3157 boundary = recalculate_boundary(runtime); in snd_pcm_ioctl_sync_ptr_compat()
3198 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_tstamp() local
3205 runtime->tstamp_type = arg; in snd_pcm_tstamp()
3213 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xferi_frames_ioctl() local
3216 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_xferi_frames_ioctl()
3235 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xfern_frames_ioctl() local
3239 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_xfern_frames_ioctl()
3241 if (runtime->channels > 128) in snd_pcm_xfern_frames_ioctl()
3248 bufs = memdup_user(xfern.bufs, sizeof(void *) * runtime->channels); in snd_pcm_xfern_frames_ioctl()
3302 if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_common_ioctl()
3433 if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_kernel_ioctl()
3470 struct snd_pcm_runtime *runtime; in snd_pcm_read() local
3477 runtime = substream->runtime; in snd_pcm_read()
3478 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_read()
3479 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_read()
3481 if (!frame_aligned(runtime, count)) in snd_pcm_read()
3483 count = bytes_to_frames(runtime, count); in snd_pcm_read()
3486 result = frames_to_bytes(runtime, result); in snd_pcm_read()
3495 struct snd_pcm_runtime *runtime; in snd_pcm_write() local
3502 runtime = substream->runtime; in snd_pcm_write()
3503 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_write()
3504 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_write()
3506 if (!frame_aligned(runtime, count)) in snd_pcm_write()
3508 count = bytes_to_frames(runtime, count); in snd_pcm_write()
3511 result = frames_to_bytes(runtime, result); in snd_pcm_write()
3519 struct snd_pcm_runtime *runtime; in snd_pcm_readv() local
3530 runtime = substream->runtime; in snd_pcm_readv()
3531 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_readv()
3532 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_readv()
3536 if (to->nr_segs > 1024 || to->nr_segs != runtime->channels) in snd_pcm_readv()
3538 if (!frame_aligned(runtime, iov->iov_len)) in snd_pcm_readv()
3540 frames = bytes_to_samples(runtime, iov->iov_len); in snd_pcm_readv()
3550 result = frames_to_bytes(runtime, result); in snd_pcm_readv()
3558 struct snd_pcm_runtime *runtime; in snd_pcm_writev() local
3569 runtime = substream->runtime; in snd_pcm_writev()
3570 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_writev()
3571 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_writev()
3575 if (from->nr_segs > 128 || from->nr_segs != runtime->channels || in snd_pcm_writev()
3576 !frame_aligned(runtime, iov->iov_len)) in snd_pcm_writev()
3578 frames = bytes_to_samples(runtime, iov->iov_len); in snd_pcm_writev()
3588 result = frames_to_bytes(runtime, result); in snd_pcm_writev()
3596 struct snd_pcm_runtime *runtime; in snd_pcm_poll() local
3610 runtime = substream->runtime; in snd_pcm_poll()
3611 if (runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_poll()
3614 poll_wait(file, &runtime->sleep, wait); in snd_pcm_poll()
3619 switch (runtime->state) { in snd_pcm_poll()
3623 if (avail >= runtime->control->avail_min) in snd_pcm_poll()
3655 struct snd_pcm_runtime *runtime; in snd_pcm_mmap_status_fault() local
3659 runtime = substream->runtime; in snd_pcm_mmap_status_fault()
3660 vmf->page = virt_to_page(runtime->status); in snd_pcm_mmap_status_fault()
3693 struct snd_pcm_runtime *runtime; in snd_pcm_mmap_control_fault() local
3697 runtime = substream->runtime; in snd_pcm_mmap_control_fault()
3698 vmf->page = virt_to_page(runtime->control); in snd_pcm_mmap_control_fault()
3729 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_EXPLICIT_SYNC) in pcm_status_mmap_allowed()
3736 (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_SYNC_APPLPTR)) in pcm_status_mmap_allowed()
3746 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_EXPLICIT_SYNC) in pcm_control_mmap_allowed()
3752 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_SYNC_APPLPTR) in pcm_control_mmap_allowed()
3782 struct snd_pcm_runtime *runtime; in snd_pcm_mmap_data_fault() local
3789 runtime = substream->runtime; in snd_pcm_mmap_data_fault()
3791 dma_bytes = PAGE_ALIGN(runtime->dma_bytes); in snd_pcm_mmap_data_fault()
3797 page = virt_to_page(runtime->dma_area + offset); in snd_pcm_mmap_data_fault()
3863 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_mmap_iomem() local
3866 return vm_iomap_memory(area, runtime->dma_addr, runtime->dma_bytes); in snd_pcm_lib_mmap_iomem()
3877 struct snd_pcm_runtime *runtime; in snd_pcm_mmap_data() local
3890 runtime = substream->runtime; in snd_pcm_mmap_data()
3891 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_mmap_data()
3893 if (!(runtime->info & SNDRV_PCM_INFO_MMAP)) in snd_pcm_mmap_data()
3895 if (runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED || in snd_pcm_mmap_data()
3896 runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) in snd_pcm_mmap_data()
3900 dma_bytes = PAGE_ALIGN(runtime->dma_bytes); in snd_pcm_mmap_data()
3928 if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_mmap()
3959 struct snd_pcm_runtime *runtime; in snd_pcm_fasync() local
3965 runtime = substream->runtime; in snd_pcm_fasync()
3966 if (runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_fasync()
3968 return snd_fasync_helper(fd, file, on, &runtime->fasync); in snd_pcm_fasync()
4091 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_get_unmapped_area() local
4096 return (unsigned long)runtime->status; in snd_pcm_get_unmapped_area()
4098 return (unsigned long)runtime->control; in snd_pcm_get_unmapped_area()
4100 return (unsigned long)runtime->dma_area + offset; in snd_pcm_get_unmapped_area()