Lines Matching refs:runtime

47 	struct snd_pcm_runtime *runtime = substream->runtime;  in snd_pcm_playback_silence()  local
51 if (runtime->silence_size < runtime->boundary) { in snd_pcm_playback_silence()
53 snd_pcm_uframes_t appl_ptr = READ_ONCE(runtime->control->appl_ptr); in snd_pcm_playback_silence()
54 if (runtime->silence_start != appl_ptr) { in snd_pcm_playback_silence()
55 n = appl_ptr - runtime->silence_start; in snd_pcm_playback_silence()
57 n += runtime->boundary; in snd_pcm_playback_silence()
58 if ((snd_pcm_uframes_t)n < runtime->silence_filled) in snd_pcm_playback_silence()
59 runtime->silence_filled -= n; in snd_pcm_playback_silence()
61 runtime->silence_filled = 0; in snd_pcm_playback_silence()
62 runtime->silence_start = appl_ptr; in snd_pcm_playback_silence()
64 if (runtime->silence_filled >= runtime->buffer_size) in snd_pcm_playback_silence()
66 noise_dist = snd_pcm_playback_hw_avail(runtime) + runtime->silence_filled; in snd_pcm_playback_silence()
67 if (noise_dist >= (snd_pcm_sframes_t) runtime->silence_threshold) in snd_pcm_playback_silence()
69 frames = runtime->silence_threshold - noise_dist; in snd_pcm_playback_silence()
70 if (frames > runtime->silence_size) in snd_pcm_playback_silence()
71 frames = runtime->silence_size; in snd_pcm_playback_silence()
74 snd_pcm_sframes_t avail = snd_pcm_playback_hw_avail(runtime); in snd_pcm_playback_silence()
75 if (avail > runtime->buffer_size) in snd_pcm_playback_silence()
76 avail = runtime->buffer_size; in snd_pcm_playback_silence()
77 runtime->silence_filled = avail > 0 ? avail : 0; in snd_pcm_playback_silence()
78 runtime->silence_start = (runtime->status->hw_ptr + in snd_pcm_playback_silence()
79 runtime->silence_filled) % in snd_pcm_playback_silence()
80 runtime->boundary; in snd_pcm_playback_silence()
82 ofs = runtime->status->hw_ptr; in snd_pcm_playback_silence()
85 frames += runtime->boundary; in snd_pcm_playback_silence()
86 runtime->silence_filled -= frames; in snd_pcm_playback_silence()
87 if ((snd_pcm_sframes_t)runtime->silence_filled < 0) { in snd_pcm_playback_silence()
88 runtime->silence_filled = 0; in snd_pcm_playback_silence()
89 runtime->silence_start = new_hw_ptr; in snd_pcm_playback_silence()
91 runtime->silence_start = ofs; in snd_pcm_playback_silence()
94 frames = runtime->buffer_size - runtime->silence_filled; in snd_pcm_playback_silence()
96 if (snd_BUG_ON(frames > runtime->buffer_size)) in snd_pcm_playback_silence()
100 ofs = runtime->silence_start % runtime->buffer_size; in snd_pcm_playback_silence()
102 transfer = ofs + frames > runtime->buffer_size ? runtime->buffer_size - ofs : frames; in snd_pcm_playback_silence()
105 runtime->silence_filled += transfer; in snd_pcm_playback_silence()
144 struct snd_pcm_runtime *runtime = substream->runtime; in __snd_pcm_xrun() local
147 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) in __snd_pcm_xrun()
148 snd_pcm_gettime(runtime, (struct timespec *)&runtime->status->tstamp); in __snd_pcm_xrun()
176 struct snd_pcm_runtime *runtime) in snd_pcm_update_state() argument
181 if (avail > runtime->avail_max) in snd_pcm_update_state()
182 runtime->avail_max = avail; in snd_pcm_update_state()
183 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) { in snd_pcm_update_state()
184 if (avail >= runtime->buffer_size) { in snd_pcm_update_state()
189 if (avail >= runtime->stop_threshold) { in snd_pcm_update_state()
194 if (runtime->twake) { in snd_pcm_update_state()
195 if (avail >= runtime->twake) in snd_pcm_update_state()
196 wake_up(&runtime->tsleep); in snd_pcm_update_state()
197 } else if (avail >= runtime->control->avail_min) in snd_pcm_update_state()
198 wake_up(&runtime->sleep); in snd_pcm_update_state()
206 struct snd_pcm_runtime *runtime = substream->runtime; in update_audio_tstamp() local
210 if (runtime->tstamp_mode != SNDRV_PCM_TSTAMP_ENABLE) in update_audio_tstamp()
214 (runtime->audio_tstamp_report.actual_type == in update_audio_tstamp()
222 audio_frames = runtime->hw_ptr_wrap + runtime->status->hw_ptr; in update_audio_tstamp()
224 if (runtime->audio_tstamp_config.report_delay) { in update_audio_tstamp()
226 audio_frames -= runtime->delay; in update_audio_tstamp()
228 audio_frames += runtime->delay; in update_audio_tstamp()
231 runtime->rate); in update_audio_tstamp()
234 if (!timespec_equal(&runtime->status->audio_tstamp, audio_tstamp)) { in update_audio_tstamp()
235 runtime->status->audio_tstamp = *audio_tstamp; in update_audio_tstamp()
236 runtime->status->tstamp = *curr_tstamp; in update_audio_tstamp()
243 snd_pcm_gettime(substream->runtime, (struct timespec *)&driver_tstamp); in update_audio_tstamp()
244 runtime->driver_tstamp = driver_tstamp; in update_audio_tstamp()
250 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_update_hw_ptr0() local
260 old_hw_ptr = runtime->status->hw_ptr; in snd_pcm_update_hw_ptr0()
270 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { in snd_pcm_update_hw_ptr0()
272 (runtime->audio_tstamp_config.type_requested != SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT)) { in snd_pcm_update_hw_ptr0()
275 &runtime->audio_tstamp_config, in snd_pcm_update_hw_ptr0()
276 &runtime->audio_tstamp_report); in snd_pcm_update_hw_ptr0()
279 if (runtime->audio_tstamp_report.actual_type == SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT) in snd_pcm_update_hw_ptr0()
280 snd_pcm_gettime(runtime, (struct timespec *)&curr_tstamp); in snd_pcm_update_hw_ptr0()
282 snd_pcm_gettime(runtime, (struct timespec *)&curr_tstamp); in snd_pcm_update_hw_ptr0()
289 if (pos >= runtime->buffer_size) { in snd_pcm_update_hw_ptr0()
295 name, pos, runtime->buffer_size, in snd_pcm_update_hw_ptr0()
296 runtime->period_size); in snd_pcm_update_hw_ptr0()
300 pos -= pos % runtime->min_align; in snd_pcm_update_hw_ptr0()
302 hw_base = runtime->hw_ptr_base; in snd_pcm_update_hw_ptr0()
307 delta = runtime->hw_ptr_interrupt + runtime->period_size; in snd_pcm_update_hw_ptr0()
310 hdelta = curr_jiffies - runtime->hw_ptr_jiffies; in snd_pcm_update_hw_ptr0()
311 if (hdelta > runtime->hw_ptr_buffer_jiffies/2 + 1) { in snd_pcm_update_hw_ptr0()
312 hw_base += runtime->buffer_size; in snd_pcm_update_hw_ptr0()
313 if (hw_base >= runtime->boundary) { in snd_pcm_update_hw_ptr0()
325 hw_base += runtime->buffer_size; in snd_pcm_update_hw_ptr0()
326 if (hw_base >= runtime->boundary) { in snd_pcm_update_hw_ptr0()
335 delta += runtime->boundary; in snd_pcm_update_hw_ptr0()
337 if (runtime->no_period_wakeup) { in snd_pcm_update_hw_ptr0()
343 jdelta = curr_jiffies - runtime->hw_ptr_jiffies; in snd_pcm_update_hw_ptr0()
344 if (jdelta < runtime->hw_ptr_buffer_jiffies / 2) in snd_pcm_update_hw_ptr0()
346 hdelta = jdelta - delta * HZ / runtime->rate; in snd_pcm_update_hw_ptr0()
347 xrun_threshold = runtime->hw_ptr_buffer_jiffies / 2 + 1; in snd_pcm_update_hw_ptr0()
349 delta += runtime->buffer_size; in snd_pcm_update_hw_ptr0()
350 hw_base += runtime->buffer_size; in snd_pcm_update_hw_ptr0()
351 if (hw_base >= runtime->boundary) { in snd_pcm_update_hw_ptr0()
356 hdelta -= runtime->hw_ptr_buffer_jiffies; in snd_pcm_update_hw_ptr0()
362 if (delta >= runtime->buffer_size + runtime->period_size) { in snd_pcm_update_hw_ptr0()
378 if (runtime->hw.info & SNDRV_PCM_INFO_BATCH) in snd_pcm_update_hw_ptr0()
381 if (hdelta < runtime->delay) in snd_pcm_update_hw_ptr0()
383 hdelta -= runtime->delay; in snd_pcm_update_hw_ptr0()
384 jdelta = curr_jiffies - runtime->hw_ptr_jiffies; in snd_pcm_update_hw_ptr0()
385 if (((hdelta * HZ) / runtime->rate) > jdelta + HZ/100) { in snd_pcm_update_hw_ptr0()
387 (((runtime->period_size * HZ) / runtime->rate) in snd_pcm_update_hw_ptr0()
395 new_hw_ptr += runtime->period_size; in snd_pcm_update_hw_ptr0()
396 if (new_hw_ptr >= runtime->boundary) { in snd_pcm_update_hw_ptr0()
397 new_hw_ptr -= runtime->boundary; in snd_pcm_update_hw_ptr0()
406 (long)runtime->period_size, jdelta, in snd_pcm_update_hw_ptr0()
407 ((hdelta * HZ) / runtime->rate), hw_base, in snd_pcm_update_hw_ptr0()
412 hw_base = new_hw_ptr - (new_hw_ptr % runtime->buffer_size); in snd_pcm_update_hw_ptr0()
415 if (delta > runtime->period_size + runtime->period_size / 2) { in snd_pcm_update_hw_ptr0()
425 if (runtime->status->hw_ptr == new_hw_ptr) { in snd_pcm_update_hw_ptr0()
431 runtime->silence_size > 0) in snd_pcm_update_hw_ptr0()
435 delta = new_hw_ptr - runtime->hw_ptr_interrupt; in snd_pcm_update_hw_ptr0()
437 delta += runtime->boundary; in snd_pcm_update_hw_ptr0()
438 delta -= (snd_pcm_uframes_t)delta % runtime->period_size; in snd_pcm_update_hw_ptr0()
439 runtime->hw_ptr_interrupt += delta; in snd_pcm_update_hw_ptr0()
440 if (runtime->hw_ptr_interrupt >= runtime->boundary) in snd_pcm_update_hw_ptr0()
441 runtime->hw_ptr_interrupt -= runtime->boundary; in snd_pcm_update_hw_ptr0()
443 runtime->hw_ptr_base = hw_base; in snd_pcm_update_hw_ptr0()
444 runtime->status->hw_ptr = new_hw_ptr; in snd_pcm_update_hw_ptr0()
445 runtime->hw_ptr_jiffies = curr_jiffies; in snd_pcm_update_hw_ptr0()
448 runtime->hw_ptr_wrap += runtime->boundary; in snd_pcm_update_hw_ptr0()
453 return snd_pcm_update_state(substream, runtime); in snd_pcm_update_hw_ptr0()
489 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_set_sync() local
491 runtime->sync.id32[0] = substream->pcm->card->number; in snd_pcm_set_sync()
492 runtime->sync.id32[1] = -1; in snd_pcm_set_sync()
493 runtime->sync.id32[2] = -1; in snd_pcm_set_sync()
494 runtime->sync.id32[3] = -1; in snd_pcm_set_sync()
1108 int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsigned int cond, in snd_pcm_hw_rule_add() argument
1113 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_rule_add()
1162 int snd_pcm_hw_constraint_mask(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, in snd_pcm_hw_constraint_mask() argument
1165 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_constraint_mask()
1184 int snd_pcm_hw_constraint_mask64(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, in snd_pcm_hw_constraint_mask64() argument
1187 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_constraint_mask64()
1208 int snd_pcm_hw_constraint_integer(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var) in snd_pcm_hw_constraint_integer() argument
1210 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_constraint_integer()
1227 int snd_pcm_hw_constraint_minmax(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, in snd_pcm_hw_constraint_minmax() argument
1230 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_constraint_minmax()
1259 int snd_pcm_hw_constraint_list(struct snd_pcm_runtime *runtime, in snd_pcm_hw_constraint_list() argument
1264 return snd_pcm_hw_rule_add(runtime, cond, var, in snd_pcm_hw_constraint_list()
1290 int snd_pcm_hw_constraint_ranges(struct snd_pcm_runtime *runtime, in snd_pcm_hw_constraint_ranges() argument
1295 return snd_pcm_hw_rule_add(runtime, cond, var, in snd_pcm_hw_constraint_ranges()
1325 int snd_pcm_hw_constraint_ratnums(struct snd_pcm_runtime *runtime, in snd_pcm_hw_constraint_ratnums() argument
1330 return snd_pcm_hw_rule_add(runtime, cond, var, in snd_pcm_hw_constraint_ratnums()
1359 int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, in snd_pcm_hw_constraint_ratdens() argument
1364 return snd_pcm_hw_rule_add(runtime, cond, var, in snd_pcm_hw_constraint_ratdens()
1403 int snd_pcm_hw_constraint_msbits(struct snd_pcm_runtime *runtime, in snd_pcm_hw_constraint_msbits() argument
1409 return snd_pcm_hw_rule_add(runtime, cond, -1, in snd_pcm_hw_constraint_msbits()
1432 int snd_pcm_hw_constraint_step(struct snd_pcm_runtime *runtime, in snd_pcm_hw_constraint_step() argument
1437 return snd_pcm_hw_rule_add(runtime, cond, var, in snd_pcm_hw_constraint_step()
1463 int snd_pcm_hw_constraint_pow2(struct snd_pcm_runtime *runtime, in snd_pcm_hw_constraint_pow2() argument
1467 return snd_pcm_hw_rule_add(runtime, cond, var, in snd_pcm_hw_constraint_pow2()
1490 int snd_pcm_hw_rule_noresample(struct snd_pcm_runtime *runtime, in snd_pcm_hw_rule_noresample() argument
1493 return snd_pcm_hw_rule_add(runtime, SNDRV_PCM_HW_PARAMS_NORESAMPLE, in snd_pcm_hw_rule_noresample()
1675 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_ioctl_reset() local
1680 runtime->status->hw_ptr %= runtime->buffer_size; in snd_pcm_lib_ioctl_reset()
1682 runtime->status->hw_ptr = 0; in snd_pcm_lib_ioctl_reset()
1683 runtime->hw_ptr_wrap = 0; in snd_pcm_lib_ioctl_reset()
1693 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_ioctl_channel_info() local
1695 if (!(runtime->info & SNDRV_PCM_INFO_MMAP)) { in snd_pcm_lib_ioctl_channel_info()
1699 width = snd_pcm_format_physical_width(runtime->format); in snd_pcm_lib_ioctl_channel_info()
1703 switch (runtime->access) { in snd_pcm_lib_ioctl_channel_info()
1707 info->step = runtime->channels * width; in snd_pcm_lib_ioctl_channel_info()
1712 size_t size = runtime->dma_bytes / runtime->channels; in snd_pcm_lib_ioctl_channel_info()
1732 params->fifo_size = substream->runtime->hw.fifo_size; in snd_pcm_lib_ioctl_fifo_size()
1733 if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_FIFO_IN_FRAMES)) { in snd_pcm_lib_ioctl_fifo_size()
1782 struct snd_pcm_runtime *runtime; in snd_pcm_period_elapsed() local
1791 runtime = substream->runtime; in snd_pcm_period_elapsed()
1802 kill_fasync(&runtime->fasync, SIGIO, POLL_IN); in snd_pcm_period_elapsed()
1817 struct snd_pcm_runtime *runtime = substream->runtime; in wait_for_avail() local
1826 add_wait_queue(&runtime->tsleep, &wait); in wait_for_avail()
1828 if (runtime->no_period_wakeup) in wait_for_avail()
1837 if (runtime->rate) { in wait_for_avail()
1838 long t = runtime->period_size * 2 / in wait_for_avail()
1839 runtime->rate; in wait_for_avail()
1860 if (avail >= runtime->twake) in wait_for_avail()
1868 switch (runtime->status->state) { in wait_for_avail()
1899 remove_wait_queue(&runtime->tsleep, &wait); in wait_for_avail()
1912 static void *get_dma_ptr(struct snd_pcm_runtime *runtime, in get_dma_ptr() argument
1915 return runtime->dma_area + hwoff + in get_dma_ptr()
1916 channel * (runtime->dma_bytes / runtime->channels); in get_dma_ptr()
1924 if (copy_from_user(get_dma_ptr(substream->runtime, channel, hwoff), in default_write_copy()
1935 memcpy(get_dma_ptr(substream->runtime, channel, hwoff), buf, bytes); in default_write_copy_kernel()
1946 struct snd_pcm_runtime *runtime = substream->runtime; in fill_silence() local
1954 snd_pcm_format_set_silence(runtime->format, in fill_silence()
1955 get_dma_ptr(runtime, channel, hwoff), in fill_silence()
1956 bytes_to_samples(runtime, bytes)); in fill_silence()
1966 get_dma_ptr(substream->runtime, channel, hwoff), in default_read_copy()
1977 memcpy(buf, get_dma_ptr(substream->runtime, channel, hwoff), bytes); in default_read_copy_kernel()
1990 struct snd_pcm_runtime *runtime = substream->runtime; in interleaved_copy() local
1993 hwoff = frames_to_bytes(runtime, hwoff); in interleaved_copy()
1994 off = frames_to_bytes(runtime, off); in interleaved_copy()
1995 frames = frames_to_bytes(runtime, frames); in interleaved_copy()
2008 struct snd_pcm_runtime *runtime = substream->runtime; in noninterleaved_copy() local
2009 int channels = runtime->channels; in noninterleaved_copy()
2017 off = samples_to_bytes(runtime, off); in noninterleaved_copy()
2018 frames = samples_to_bytes(runtime, frames); in noninterleaved_copy()
2019 hwoff = samples_to_bytes(runtime, hwoff); in noninterleaved_copy()
2038 if (substream->runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED || in fill_silence_frames()
2039 substream->runtime->access == SNDRV_PCM_ACCESS_MMAP_INTERLEAVED) in fill_silence_frames()
2050 struct snd_pcm_runtime *runtime; in pcm_sanity_check() local
2053 runtime = substream->runtime; in pcm_sanity_check()
2054 if (snd_BUG_ON(!substream->ops->copy_user && !runtime->dma_area)) in pcm_sanity_check()
2056 if (runtime->status->state == SNDRV_PCM_STATE_OPEN) in pcm_sanity_check()
2061 static int pcm_accessible_state(struct snd_pcm_runtime *runtime) in pcm_accessible_state() argument
2063 switch (runtime->status->state) { in pcm_accessible_state()
2083 struct snd_pcm_runtime *runtime = substream->runtime; in pcm_lib_apply_appl_ptr() local
2084 snd_pcm_uframes_t old_appl_ptr = runtime->control->appl_ptr; in pcm_lib_apply_appl_ptr()
2090 runtime->control->appl_ptr = appl_ptr; in pcm_lib_apply_appl_ptr()
2094 runtime->control->appl_ptr = old_appl_ptr; in pcm_lib_apply_appl_ptr()
2109 struct snd_pcm_runtime *runtime = substream->runtime; in __snd_pcm_lib_xfer() local
2125 if (runtime->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED && in __snd_pcm_lib_xfer()
2126 runtime->channels > 1) in __snd_pcm_lib_xfer()
2130 if (runtime->access != SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) in __snd_pcm_lib_xfer()
2160 err = pcm_accessible_state(runtime); in __snd_pcm_lib_xfer()
2164 runtime->twake = runtime->control->avail_min ? : 1; in __snd_pcm_lib_xfer()
2165 if (runtime->status->state == SNDRV_PCM_STATE_RUNNING) in __snd_pcm_lib_xfer()
2173 runtime->status->state == SNDRV_PCM_STATE_PREPARED && in __snd_pcm_lib_xfer()
2174 size >= runtime->start_threshold) { in __snd_pcm_lib_xfer()
2187 runtime->status->state == SNDRV_PCM_STATE_DRAINING) { in __snd_pcm_lib_xfer()
2195 runtime->twake = min_t(snd_pcm_uframes_t, size, in __snd_pcm_lib_xfer()
2196 runtime->control->avail_min ? : 1); in __snd_pcm_lib_xfer()
2204 appl_ptr = READ_ONCE(runtime->control->appl_ptr); in __snd_pcm_lib_xfer()
2205 appl_ofs = appl_ptr % runtime->buffer_size; in __snd_pcm_lib_xfer()
2206 cont = runtime->buffer_size - appl_ofs; in __snd_pcm_lib_xfer()
2219 err = pcm_accessible_state(runtime); in __snd_pcm_lib_xfer()
2223 if (appl_ptr >= runtime->boundary) in __snd_pcm_lib_xfer()
2224 appl_ptr -= runtime->boundary; in __snd_pcm_lib_xfer()
2234 runtime->status->state == SNDRV_PCM_STATE_PREPARED && in __snd_pcm_lib_xfer()
2235 snd_pcm_playback_hw_avail(runtime) >= (snd_pcm_sframes_t)runtime->start_threshold) { in __snd_pcm_lib_xfer()
2242 runtime->twake = 0; in __snd_pcm_lib_xfer()
2244 snd_pcm_update_state(substream, runtime); in __snd_pcm_lib_xfer()
2336 if (!substream->runtime) in pcm_chmap_ctl_get()
2340 if (map->channels == substream->runtime->channels && in pcm_chmap_ctl_get()