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()
511 params->info = substream->runtime->hw.info; in fixup_unreferenced_params()
579 static int period_to_usecs(struct snd_pcm_runtime *runtime) in period_to_usecs() argument
583 if (! runtime->rate) in period_to_usecs()
587 usecs = (750000 / runtime->rate) * runtime->period_size; in period_to_usecs()
588 usecs += ((750000 % runtime->rate) * runtime->period_size) / in period_to_usecs()
589 runtime->rate; in period_to_usecs()
598 if (substream->runtime->state != SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_set_state()
599 __snd_pcm_set_state(substream->runtime, state); in snd_pcm_set_state()
609 &substream->runtime->trigger_tstamp); in snd_pcm_timer_notify()
615 if (substream->runtime && substream->runtime->stop_operating) { in snd_pcm_sync_stop()
616 substream->runtime->stop_operating = false; in snd_pcm_sync_stop()
691 static int snd_pcm_buffer_access_lock(struct snd_pcm_runtime *runtime) in snd_pcm_buffer_access_lock() argument
693 if (!atomic_dec_unless_positive(&runtime->buffer_accessing)) in snd_pcm_buffer_access_lock()
695 mutex_lock(&runtime->buffer_mutex); in snd_pcm_buffer_access_lock()
700 static void snd_pcm_buffer_access_unlock(struct snd_pcm_runtime *runtime) in snd_pcm_buffer_access_unlock() argument
702 mutex_unlock(&runtime->buffer_mutex); in snd_pcm_buffer_access_unlock()
703 atomic_inc(&runtime->buffer_accessing); in snd_pcm_buffer_access_unlock()
715 struct snd_pcm_runtime *runtime; in snd_pcm_hw_params() local
722 runtime = substream->runtime; in snd_pcm_hw_params()
723 err = snd_pcm_buffer_access_lock(runtime); in snd_pcm_hw_params()
727 switch (runtime->state) { in snd_pcm_hw_params()
763 runtime->buffer_changed = err > 0; in snd_pcm_hw_params()
772 runtime->access = params_access(params); in snd_pcm_hw_params()
773 runtime->format = params_format(params); in snd_pcm_hw_params()
774 runtime->subformat = params_subformat(params); in snd_pcm_hw_params()
775 runtime->channels = params_channels(params); in snd_pcm_hw_params()
776 runtime->rate = params_rate(params); in snd_pcm_hw_params()
777 runtime->period_size = params_period_size(params); in snd_pcm_hw_params()
778 runtime->periods = params_periods(params); in snd_pcm_hw_params()
779 runtime->buffer_size = params_buffer_size(params); in snd_pcm_hw_params()
780 runtime->info = params->info; in snd_pcm_hw_params()
781 runtime->rate_num = params->rate_num; in snd_pcm_hw_params()
782 runtime->rate_den = params->rate_den; in snd_pcm_hw_params()
783 runtime->no_period_wakeup = in snd_pcm_hw_params()
787 bits = snd_pcm_format_physical_width(runtime->format); in snd_pcm_hw_params()
788 runtime->sample_bits = bits; in snd_pcm_hw_params()
789 bits *= runtime->channels; in snd_pcm_hw_params()
790 runtime->frame_bits = bits; in snd_pcm_hw_params()
796 runtime->byte_align = bits / 8; in snd_pcm_hw_params()
797 runtime->min_align = frames; in snd_pcm_hw_params()
800 runtime->tstamp_mode = SNDRV_PCM_TSTAMP_NONE; in snd_pcm_hw_params()
801 runtime->period_step = 1; in snd_pcm_hw_params()
802 runtime->control->avail_min = runtime->period_size; in snd_pcm_hw_params()
803 runtime->start_threshold = 1; in snd_pcm_hw_params()
804 runtime->stop_threshold = runtime->buffer_size; in snd_pcm_hw_params()
805 runtime->silence_threshold = 0; in snd_pcm_hw_params()
806 runtime->silence_size = 0; in snd_pcm_hw_params()
807 runtime->boundary = runtime->buffer_size; in snd_pcm_hw_params()
808 while (runtime->boundary * 2 <= LONG_MAX - runtime->buffer_size) in snd_pcm_hw_params()
809 runtime->boundary *= 2; in snd_pcm_hw_params()
812 if (runtime->dma_area && !substream->ops->copy) { in snd_pcm_hw_params()
813 size_t size = runtime->dma_bytes; in snd_pcm_hw_params()
815 if (runtime->info & SNDRV_PCM_INFO_MMAP) in snd_pcm_hw_params()
817 memset(runtime->dma_area, 0, size); in snd_pcm_hw_params()
825 usecs = period_to_usecs(runtime); in snd_pcm_hw_params()
843 snd_pcm_buffer_access_unlock(runtime); in snd_pcm_hw_params()
882 struct snd_pcm_runtime *runtime; in snd_pcm_hw_free() local
887 runtime = substream->runtime; in snd_pcm_hw_free()
888 result = snd_pcm_buffer_access_lock(runtime); in snd_pcm_hw_free()
892 switch (runtime->state) { in snd_pcm_hw_free()
909 snd_pcm_buffer_access_unlock(runtime); in snd_pcm_hw_free()
916 struct snd_pcm_runtime *runtime; in snd_pcm_sw_params() local
921 runtime = substream->runtime; in snd_pcm_sw_params()
923 if (runtime->state == SNDRV_PCM_STATE_OPEN) { in snd_pcm_sw_params()
937 if (params->silence_size >= runtime->boundary) { in snd_pcm_sw_params()
943 if (params->silence_threshold > runtime->buffer_size) in snd_pcm_sw_params()
948 runtime->tstamp_mode = params->tstamp_mode; in snd_pcm_sw_params()
950 runtime->tstamp_type = params->tstamp_type; in snd_pcm_sw_params()
951 runtime->period_step = params->period_step; in snd_pcm_sw_params()
952 runtime->control->avail_min = params->avail_min; in snd_pcm_sw_params()
953 runtime->start_threshold = params->start_threshold; in snd_pcm_sw_params()
954 runtime->stop_threshold = params->stop_threshold; in snd_pcm_sw_params()
955 runtime->silence_threshold = params->silence_threshold; in snd_pcm_sw_params()
956 runtime->silence_size = params->silence_size; in snd_pcm_sw_params()
957 params->boundary = runtime->boundary; in snd_pcm_sw_params()
960 runtime->silence_size > 0) in snd_pcm_sw_params()
962 err = snd_pcm_update_state(substream, runtime); in snd_pcm_sw_params()
987 delay = snd_pcm_playback_hw_avail(substream->runtime); in snd_pcm_calc_delay()
989 delay = snd_pcm_capture_avail(substream->runtime); in snd_pcm_calc_delay()
990 return delay + substream->runtime->delay; in snd_pcm_calc_delay()
996 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_status64() local
1001 &runtime->audio_tstamp_config); in snd_pcm_status64()
1004 if (runtime->audio_tstamp_config.type_requested == in snd_pcm_status64()
1006 if (runtime->hw.info & SNDRV_PCM_INFO_HAS_WALL_CLOCK) in snd_pcm_status64()
1007 runtime->audio_tstamp_config.type_requested = in snd_pcm_status64()
1010 runtime->audio_tstamp_config.type_requested = in snd_pcm_status64()
1012 runtime->audio_tstamp_report.valid = 0; in snd_pcm_status64()
1014 runtime->audio_tstamp_report.valid = 1; in snd_pcm_status64()
1016 status->state = runtime->state; in snd_pcm_status64()
1017 status->suspended_state = runtime->suspended_state; in snd_pcm_status64()
1020 status->trigger_tstamp_sec = runtime->trigger_tstamp.tv_sec; in snd_pcm_status64()
1021 status->trigger_tstamp_nsec = runtime->trigger_tstamp.tv_nsec; in snd_pcm_status64()
1024 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { in snd_pcm_status64()
1025 status->tstamp_sec = runtime->status->tstamp.tv_sec; in snd_pcm_status64()
1027 runtime->status->tstamp.tv_nsec; in snd_pcm_status64()
1029 runtime->driver_tstamp.tv_sec; in snd_pcm_status64()
1031 runtime->driver_tstamp.tv_nsec; in snd_pcm_status64()
1033 runtime->status->audio_tstamp.tv_sec; in snd_pcm_status64()
1035 runtime->status->audio_tstamp.tv_nsec; in snd_pcm_status64()
1036 if (runtime->audio_tstamp_report.valid == 1) in snd_pcm_status64()
1040 &runtime->audio_tstamp_report); in snd_pcm_status64()
1046 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { in snd_pcm_status64()
1049 snd_pcm_gettime(runtime, &tstamp); in snd_pcm_status64()
1055 status->appl_ptr = runtime->control->appl_ptr; in snd_pcm_status64()
1056 status->hw_ptr = runtime->status->hw_ptr; in snd_pcm_status64()
1060 status->avail_max = runtime->avail_max; in snd_pcm_status64()
1061 status->overrange = runtime->overrange; in snd_pcm_status64()
1062 runtime->avail_max = 0; in snd_pcm_status64()
1063 runtime->overrange = 0; in snd_pcm_status64()
1145 struct snd_pcm_runtime *runtime; in snd_pcm_channel_info() local
1149 runtime = substream->runtime; in snd_pcm_channel_info()
1151 if (runtime->state == SNDRV_PCM_STATE_OPEN) { in snd_pcm_channel_info()
1156 if (channel >= runtime->channels) in snd_pcm_channel_info()
1181 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_trigger_tstamp() local
1182 if (runtime->trigger_master == NULL) in snd_pcm_trigger_tstamp()
1184 if (runtime->trigger_master == substream) { in snd_pcm_trigger_tstamp()
1185 if (!runtime->trigger_tstamp_latched) in snd_pcm_trigger_tstamp()
1186 snd_pcm_gettime(runtime, &runtime->trigger_tstamp); in snd_pcm_trigger_tstamp()
1188 snd_pcm_trigger_tstamp(runtime->trigger_master); in snd_pcm_trigger_tstamp()
1189 runtime->trigger_tstamp = runtime->trigger_master->runtime->trigger_tstamp; in snd_pcm_trigger_tstamp()
1191 runtime->trigger_master = NULL; in snd_pcm_trigger_tstamp()
1224 mutex_lock_nested(&s->runtime->buffer_mutex, depth); in snd_pcm_action_group()
1257 mutex_unlock(&s1->runtime->buffer_mutex); in snd_pcm_action_group()
1394 res = snd_pcm_buffer_access_lock(substream->runtime); in snd_pcm_action_nonatomic()
1401 snd_pcm_buffer_access_unlock(substream->runtime); in snd_pcm_action_nonatomic()
1413 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_start() local
1414 if (runtime->state != SNDRV_PCM_STATE_PREPARED) in snd_pcm_pre_start()
1419 runtime->trigger_tstamp_latched = false; in snd_pcm_pre_start()
1420 runtime->trigger_master = substream; in snd_pcm_pre_start()
1429 if (substream->runtime->trigger_master != substream) in snd_pcm_do_start()
1434 __snd_pcm_set_state(substream->runtime, SNDRV_PCM_STATE_XRUN); in snd_pcm_do_start()
1441 if (substream->runtime->trigger_master == substream) { in snd_pcm_undo_start()
1443 substream->runtime->stop_operating = true; in snd_pcm_undo_start()
1450 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_start() local
1452 runtime->hw_ptr_jiffies = jiffies; in snd_pcm_post_start()
1453 runtime->hw_ptr_buffer_jiffies = (runtime->buffer_size * HZ) / in snd_pcm_post_start()
1454 runtime->rate; in snd_pcm_post_start()
1455 __snd_pcm_set_state(runtime, state); in snd_pcm_post_start()
1457 runtime->silence_size > 0) in snd_pcm_post_start()
1495 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_stop() local
1496 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_pre_stop()
1498 runtime->trigger_master = substream; in snd_pcm_pre_stop()
1505 if (substream->runtime->trigger_master == substream && in snd_pcm_do_stop()
1508 substream->runtime->stop_operating = true; in snd_pcm_do_stop()
1516 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_stop() local
1517 if (runtime->state != state) { in snd_pcm_post_stop()
1519 __snd_pcm_set_state(runtime, state); in snd_pcm_post_stop()
1522 wake_up(&runtime->sleep); in snd_pcm_post_stop()
1523 wake_up(&runtime->tsleep); in snd_pcm_post_stop()
1576 if (substream->runtime && snd_pcm_running(substream)) in snd_pcm_stop_xrun()
1591 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_pause() local
1592 if (!(runtime->info & SNDRV_PCM_INFO_PAUSE)) in snd_pcm_pre_pause()
1595 if (runtime->state != SNDRV_PCM_STATE_RUNNING) in snd_pcm_pre_pause()
1597 } else if (runtime->state != SNDRV_PCM_STATE_PAUSED) in snd_pcm_pre_pause()
1599 runtime->trigger_master = substream; in snd_pcm_pre_pause()
1606 if (substream->runtime->trigger_master != substream) in snd_pcm_do_pause()
1612 substream->runtime->hw_ptr_jiffies = jiffies - HZ * 1000; in snd_pcm_do_pause()
1622 if (substream->runtime->trigger_master == substream) in snd_pcm_undo_pause()
1632 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_pause() local
1635 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_PAUSED); in snd_pcm_post_pause()
1637 wake_up(&runtime->sleep); in snd_pcm_post_pause()
1638 wake_up(&runtime->tsleep); in snd_pcm_post_pause()
1640 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_RUNNING); in snd_pcm_post_pause()
1674 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_suspend() local
1675 switch (runtime->state) { in snd_pcm_pre_suspend()
1684 runtime->trigger_master = substream; in snd_pcm_pre_suspend()
1691 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_suspend() local
1692 if (runtime->trigger_master != substream) in snd_pcm_do_suspend()
1697 runtime->stop_operating = true; in snd_pcm_do_suspend()
1704 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_suspend() local
1706 runtime->suspended_state = runtime->state; in snd_pcm_post_suspend()
1707 runtime->status->suspended_state = runtime->suspended_state; in snd_pcm_post_suspend()
1708 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_SUSPENDED); in snd_pcm_post_suspend()
1710 wake_up(&runtime->sleep); in snd_pcm_post_suspend()
1711 wake_up(&runtime->tsleep); in snd_pcm_post_suspend()
1758 if (!substream->runtime) in snd_pcm_suspend_all()
1785 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_resume() local
1786 if (runtime->state != SNDRV_PCM_STATE_SUSPENDED) in snd_pcm_pre_resume()
1788 if (!(runtime->info & SNDRV_PCM_INFO_RESUME)) in snd_pcm_pre_resume()
1790 runtime->trigger_master = substream; in snd_pcm_pre_resume()
1797 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_resume() local
1798 if (runtime->trigger_master != substream) in snd_pcm_do_resume()
1801 if (runtime->suspended_state != SNDRV_PCM_STATE_RUNNING && in snd_pcm_do_resume()
1802 (runtime->suspended_state != SNDRV_PCM_STATE_DRAINING || in snd_pcm_do_resume()
1811 if (substream->runtime->trigger_master == substream && in snd_pcm_undo_resume()
1819 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_resume() local
1821 __snd_pcm_set_state(runtime, runtime->suspended_state); in snd_pcm_post_resume()
1854 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xrun() local
1858 switch (runtime->state) { in snd_pcm_xrun()
1880 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_reset() local
1881 switch (runtime->state) { in snd_pcm_pre_reset()
1895 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_reset() local
1900 runtime->hw_ptr_base = 0; in snd_pcm_do_reset()
1901 runtime->hw_ptr_interrupt = runtime->status->hw_ptr - in snd_pcm_do_reset()
1902 runtime->status->hw_ptr % runtime->period_size; in snd_pcm_do_reset()
1903 runtime->silence_start = runtime->status->hw_ptr; in snd_pcm_do_reset()
1904 runtime->silence_filled = 0; in snd_pcm_do_reset()
1912 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_reset() local
1914 runtime->control->appl_ptr = runtime->status->hw_ptr; in snd_pcm_post_reset()
1916 runtime->silence_size > 0) in snd_pcm_post_reset()
1940 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_prepare() local
1943 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_pre_prepare()
1944 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_pre_prepare()
1966 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_prepare() local
1967 runtime->control->appl_ptr = runtime->status->hw_ptr; in snd_pcm_post_prepare()
1995 switch (substream->runtime->state) { in snd_pcm_prepare()
2018 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_drain_init() local
2019 switch (runtime->state) { in snd_pcm_pre_drain_init()
2025 runtime->trigger_master = substream; in snd_pcm_pre_drain_init()
2032 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_drain_init() local
2034 switch (runtime->state) { in snd_pcm_do_drain_init()
2041 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_SETUP); in snd_pcm_do_drain_init()
2045 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_DRAINING); in snd_pcm_do_drain_init()
2048 __snd_pcm_set_state(runtime, SNDRV_PCM_STATE_SETUP); in snd_pcm_do_drain_init()
2055 if (runtime->state == SNDRV_PCM_STATE_RUNNING) { in snd_pcm_do_drain_init()
2058 new_state = snd_pcm_capture_avail(runtime) > 0 ? in snd_pcm_do_drain_init()
2065 if (runtime->state == SNDRV_PCM_STATE_DRAINING && in snd_pcm_do_drain_init()
2066 runtime->trigger_master == substream && in snd_pcm_do_drain_init()
2067 (runtime->hw.info & SNDRV_PCM_INFO_DRAIN_TRIGGER)) in snd_pcm_do_drain_init()
2096 struct snd_pcm_runtime *runtime; in snd_pcm_drain() local
2104 runtime = substream->runtime; in snd_pcm_drain()
2106 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_drain()
2117 if (runtime->state == SNDRV_PCM_STATE_PAUSED) in snd_pcm_drain()
2144 runtime = s->runtime; in snd_pcm_drain()
2145 if (runtime->state == SNDRV_PCM_STATE_DRAINING) { in snd_pcm_drain()
2146 to_check = runtime; in snd_pcm_drain()
2157 if (runtime->no_period_wakeup) in snd_pcm_drain()
2161 if (runtime->rate) { in snd_pcm_drain()
2162 long t = runtime->buffer_size * 1100 / runtime->rate; in snd_pcm_drain()
2172 if (s->runtime == to_check) { in snd_pcm_drain()
2184 if (substream->runtime->state == SNDRV_PCM_STATE_SUSPENDED) in snd_pcm_drain()
2209 struct snd_pcm_runtime *runtime; in snd_pcm_drop() local
2214 runtime = substream->runtime; in snd_pcm_drop()
2216 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_drop()
2217 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_drop()
2222 if (runtime->state == SNDRV_PCM_STATE_PAUSED) in snd_pcm_drop()
2226 /* runtime->control->appl_ptr = runtime->status->hw_ptr; */ in snd_pcm_drop()
2285 if (substream->runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_link()
2286 substream->runtime->state != substream1->runtime->state || in snd_pcm_link()
2490 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_init() local
2491 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_constraints_init()
2508 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FORMAT, in snd_pcm_hw_constraints_init()
2513 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, in snd_pcm_hw_constraints_init()
2519 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, in snd_pcm_hw_constraints_init()
2524 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS, in snd_pcm_hw_constraints_init()
2529 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS, in snd_pcm_hw_constraints_init()
2534 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS, in snd_pcm_hw_constraints_init()
2539 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, in snd_pcm_hw_constraints_init()
2544 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, in snd_pcm_hw_constraints_init()
2549 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, in snd_pcm_hw_constraints_init()
2554 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIODS, in snd_pcm_hw_constraints_init()
2559 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, in snd_pcm_hw_constraints_init()
2564 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, in snd_pcm_hw_constraints_init()
2569 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, in snd_pcm_hw_constraints_init()
2574 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, in snd_pcm_hw_constraints_init()
2579 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, in snd_pcm_hw_constraints_init()
2584 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, in snd_pcm_hw_constraints_init()
2589 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, in snd_pcm_hw_constraints_init()
2594 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, in snd_pcm_hw_constraints_init()
2599 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_TIME, in snd_pcm_hw_constraints_init()
2604 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_TIME, in snd_pcm_hw_constraints_init()
2614 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_complete() local
2615 struct snd_pcm_hardware *hw = &runtime->hw; in snd_pcm_hw_constraints_complete()
2631 err = snd_pcm_hw_constraint_mask(runtime, SNDRV_PCM_HW_PARAM_ACCESS, mask); in snd_pcm_hw_constraints_complete()
2635 err = snd_pcm_hw_constraint_mask64(runtime, SNDRV_PCM_HW_PARAM_FORMAT, hw->formats); in snd_pcm_hw_constraints_complete()
2639 err = snd_pcm_hw_constraint_mask(runtime, SNDRV_PCM_HW_PARAM_SUBFORMAT, in snd_pcm_hw_constraints_complete()
2644 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_CHANNELS, in snd_pcm_hw_constraints_complete()
2649 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_RATE, in snd_pcm_hw_constraints_complete()
2654 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, in snd_pcm_hw_constraints_complete()
2659 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIODS, in snd_pcm_hw_constraints_complete()
2664 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, in snd_pcm_hw_constraints_complete()
2669 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, in snd_pcm_hw_constraints_complete()
2676 if (runtime->dma_bytes) { in snd_pcm_hw_constraints_complete()
2677 …err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 0, runtime->dma_bytes… in snd_pcm_hw_constraints_complete()
2683 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, in snd_pcm_hw_constraints_complete()
2691 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE); in snd_pcm_hw_constraints_complete()
2710 if (substream->runtime->state != SNDRV_PCM_STATE_OPEN) in snd_pcm_release_substream()
2763 substream->runtime->hw.info |= SNDRV_PCM_INFO_EXPLICIT_SYNC; in snd_pcm_open_substream()
2914 switch (substream->runtime->state) { in do_pcm_hwsync()
2938 struct snd_pcm_runtime *runtime = substream->runtime; in forward_appl_ptr() local
2946 appl_ptr = runtime->control->appl_ptr + frames; in forward_appl_ptr()
2947 if (appl_ptr >= (snd_pcm_sframes_t)runtime->boundary) in forward_appl_ptr()
2948 appl_ptr -= runtime->boundary; in forward_appl_ptr()
2958 struct snd_pcm_runtime *runtime = substream->runtime; in rewind_appl_ptr() local
2966 appl_ptr = runtime->control->appl_ptr - frames; in rewind_appl_ptr()
2968 appl_ptr += runtime->boundary; in rewind_appl_ptr()
3039 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_sync_ptr() local
3050 status = runtime->status; in snd_pcm_sync_ptr()
3051 control = runtime->control; in snd_pcm_sync_ptr()
3114 static snd_pcm_uframes_t recalculate_boundary(struct snd_pcm_runtime *runtime) in recalculate_boundary() argument
3118 if (! runtime->buffer_size) in recalculate_boundary()
3120 boundary = runtime->buffer_size; in recalculate_boundary()
3121 while (boundary * 2 <= 0x7fffffffUL - runtime->buffer_size) in recalculate_boundary()
3129 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_ioctl_sync_ptr_compat() local
3138 if (snd_BUG_ON(!runtime)) in snd_pcm_ioctl_sync_ptr_compat()
3150 status = runtime->status; in snd_pcm_ioctl_sync_ptr_compat()
3151 control = runtime->control; in snd_pcm_ioctl_sync_ptr_compat()
3152 boundary = recalculate_boundary(runtime); in snd_pcm_ioctl_sync_ptr_compat()
3195 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_tstamp() local
3202 runtime->tstamp_type = arg; in snd_pcm_tstamp()
3210 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xferi_frames_ioctl() local
3213 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_xferi_frames_ioctl()
3232 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xfern_frames_ioctl() local
3236 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_xfern_frames_ioctl()
3238 if (runtime->channels > 128) in snd_pcm_xfern_frames_ioctl()
3245 bufs = memdup_user(xfern.bufs, sizeof(void *) * runtime->channels); in snd_pcm_xfern_frames_ioctl()
3300 if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_common_ioctl()
3431 if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_kernel_ioctl()
3468 struct snd_pcm_runtime *runtime; in snd_pcm_read() local
3475 runtime = substream->runtime; in snd_pcm_read()
3476 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_read()
3477 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_read()
3479 if (!frame_aligned(runtime, count)) in snd_pcm_read()
3481 count = bytes_to_frames(runtime, count); in snd_pcm_read()
3484 result = frames_to_bytes(runtime, result); in snd_pcm_read()
3493 struct snd_pcm_runtime *runtime; in snd_pcm_write() local
3500 runtime = substream->runtime; in snd_pcm_write()
3501 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_write()
3502 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_write()
3504 if (!frame_aligned(runtime, count)) in snd_pcm_write()
3506 count = bytes_to_frames(runtime, count); in snd_pcm_write()
3509 result = frames_to_bytes(runtime, result); in snd_pcm_write()
3517 struct snd_pcm_runtime *runtime; in snd_pcm_readv() local
3528 runtime = substream->runtime; in snd_pcm_readv()
3529 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_readv()
3530 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_readv()
3534 if (to->nr_segs > 1024 || to->nr_segs != runtime->channels) in snd_pcm_readv()
3536 if (!frame_aligned(runtime, iov->iov_len)) in snd_pcm_readv()
3538 frames = bytes_to_samples(runtime, iov->iov_len); in snd_pcm_readv()
3548 result = frames_to_bytes(runtime, result); in snd_pcm_readv()
3557 struct snd_pcm_runtime *runtime; in snd_pcm_writev() local
3568 runtime = substream->runtime; in snd_pcm_writev()
3569 if (runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_writev()
3570 runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_writev()
3574 if (from->nr_segs > 128 || from->nr_segs != runtime->channels || in snd_pcm_writev()
3575 !frame_aligned(runtime, iov->iov_len)) in snd_pcm_writev()
3577 frames = bytes_to_samples(runtime, iov->iov_len); in snd_pcm_writev()
3587 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()
3656 struct snd_pcm_runtime *runtime; in snd_pcm_mmap_status_fault() local
3660 runtime = substream->runtime; in snd_pcm_mmap_status_fault()
3661 vmf->page = virt_to_page(runtime->status); in snd_pcm_mmap_status_fault()
3694 struct snd_pcm_runtime *runtime; in snd_pcm_mmap_control_fault() local
3698 runtime = substream->runtime; in snd_pcm_mmap_control_fault()
3699 vmf->page = virt_to_page(runtime->control); in snd_pcm_mmap_control_fault()
3730 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_EXPLICIT_SYNC) in pcm_status_mmap_allowed()
3737 (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_SYNC_APPLPTR)) in pcm_status_mmap_allowed()
3747 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_EXPLICIT_SYNC) in pcm_control_mmap_allowed()
3753 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_SYNC_APPLPTR) in pcm_control_mmap_allowed()
3783 struct snd_pcm_runtime *runtime; in snd_pcm_mmap_data_fault() local
3790 runtime = substream->runtime; in snd_pcm_mmap_data_fault()
3792 dma_bytes = PAGE_ALIGN(runtime->dma_bytes); in snd_pcm_mmap_data_fault()
3798 if (WARN_ON_ONCE(!runtime->dma_area)) in snd_pcm_mmap_data_fault()
3800 page = virt_to_page(runtime->dma_area + offset); in snd_pcm_mmap_data_fault()
3866 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_mmap_iomem() local
3869 return vm_iomap_memory(area, runtime->dma_addr, runtime->dma_bytes); in snd_pcm_lib_mmap_iomem()
3880 struct snd_pcm_runtime *runtime; in snd_pcm_mmap_data() local
3893 runtime = substream->runtime; in snd_pcm_mmap_data()
3894 if (runtime->state == SNDRV_PCM_STATE_OPEN) in snd_pcm_mmap_data()
3896 if (!(runtime->info & SNDRV_PCM_INFO_MMAP)) in snd_pcm_mmap_data()
3898 if (runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED || in snd_pcm_mmap_data()
3899 runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) in snd_pcm_mmap_data()
3903 dma_bytes = PAGE_ALIGN(runtime->dma_bytes); in snd_pcm_mmap_data()
3931 if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_mmap()
3962 struct snd_pcm_runtime *runtime; in snd_pcm_fasync() local
3968 runtime = substream->runtime; in snd_pcm_fasync()
3969 if (runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_fasync()
3971 return snd_fasync_helper(fd, file, on, &runtime->fasync); in snd_pcm_fasync()
4106 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_get_unmapped_area() local
4111 return (unsigned long)runtime->status; in snd_pcm_get_unmapped_area()
4113 return (unsigned long)runtime->control; in snd_pcm_get_unmapped_area()
4115 return (unsigned long)runtime->dma_area + offset; in snd_pcm_get_unmapped_area()