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()
145 struct snd_pcm_runtime *runtime = substream->runtime; in __snd_pcm_xrun() local
148 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { in __snd_pcm_xrun()
151 snd_pcm_gettime(runtime, &tstamp); in __snd_pcm_xrun()
152 runtime->status->tstamp.tv_sec = tstamp.tv_sec; in __snd_pcm_xrun()
153 runtime->status->tstamp.tv_nsec = tstamp.tv_nsec; in __snd_pcm_xrun()
182 struct snd_pcm_runtime *runtime) in snd_pcm_update_state() argument
187 if (avail > runtime->avail_max) in snd_pcm_update_state()
188 runtime->avail_max = avail; in snd_pcm_update_state()
189 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) { in snd_pcm_update_state()
190 if (avail >= runtime->buffer_size) { in snd_pcm_update_state()
195 if (avail >= runtime->stop_threshold) { in snd_pcm_update_state()
200 if (runtime->twake) { in snd_pcm_update_state()
201 if (avail >= runtime->twake) in snd_pcm_update_state()
202 wake_up(&runtime->tsleep); in snd_pcm_update_state()
203 } else if (avail >= runtime->control->avail_min) in snd_pcm_update_state()
204 wake_up(&runtime->sleep); in snd_pcm_update_state()
212 struct snd_pcm_runtime *runtime = substream->runtime; in update_audio_tstamp() local
216 if (runtime->tstamp_mode != SNDRV_PCM_TSTAMP_ENABLE) in update_audio_tstamp()
220 (runtime->audio_tstamp_report.actual_type == in update_audio_tstamp()
228 audio_frames = runtime->hw_ptr_wrap + runtime->status->hw_ptr; in update_audio_tstamp()
230 if (runtime->audio_tstamp_config.report_delay) { in update_audio_tstamp()
232 audio_frames -= runtime->delay; in update_audio_tstamp()
234 audio_frames += runtime->delay; in update_audio_tstamp()
237 runtime->rate); in update_audio_tstamp()
241 if (runtime->status->audio_tstamp.tv_sec != audio_tstamp->tv_sec || in update_audio_tstamp()
242 runtime->status->audio_tstamp.tv_nsec != audio_tstamp->tv_nsec) { in update_audio_tstamp()
243 runtime->status->audio_tstamp.tv_sec = audio_tstamp->tv_sec; in update_audio_tstamp()
244 runtime->status->audio_tstamp.tv_nsec = audio_tstamp->tv_nsec; in update_audio_tstamp()
245 runtime->status->tstamp.tv_sec = curr_tstamp->tv_sec; in update_audio_tstamp()
246 runtime->status->tstamp.tv_nsec = curr_tstamp->tv_nsec; in update_audio_tstamp()
254 snd_pcm_gettime(substream->runtime, &driver_tstamp); in update_audio_tstamp()
255 runtime->driver_tstamp = driver_tstamp; in update_audio_tstamp()
261 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_update_hw_ptr0() local
271 old_hw_ptr = runtime->status->hw_ptr; in snd_pcm_update_hw_ptr0()
281 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { in snd_pcm_update_hw_ptr0()
283 (runtime->audio_tstamp_config.type_requested != SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT)) { in snd_pcm_update_hw_ptr0()
286 &runtime->audio_tstamp_config, in snd_pcm_update_hw_ptr0()
287 &runtime->audio_tstamp_report); in snd_pcm_update_hw_ptr0()
290 if (runtime->audio_tstamp_report.actual_type == SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT) in snd_pcm_update_hw_ptr0()
291 snd_pcm_gettime(runtime, &curr_tstamp); in snd_pcm_update_hw_ptr0()
293 snd_pcm_gettime(runtime, &curr_tstamp); in snd_pcm_update_hw_ptr0()
300 if (pos >= runtime->buffer_size) { in snd_pcm_update_hw_ptr0()
306 name, pos, runtime->buffer_size, in snd_pcm_update_hw_ptr0()
307 runtime->period_size); in snd_pcm_update_hw_ptr0()
311 pos -= pos % runtime->min_align; in snd_pcm_update_hw_ptr0()
313 hw_base = runtime->hw_ptr_base; in snd_pcm_update_hw_ptr0()
318 delta = runtime->hw_ptr_interrupt + runtime->period_size; in snd_pcm_update_hw_ptr0()
321 hdelta = curr_jiffies - runtime->hw_ptr_jiffies; in snd_pcm_update_hw_ptr0()
322 if (hdelta > runtime->hw_ptr_buffer_jiffies/2 + 1) { in snd_pcm_update_hw_ptr0()
323 hw_base += runtime->buffer_size; in snd_pcm_update_hw_ptr0()
324 if (hw_base >= runtime->boundary) { in snd_pcm_update_hw_ptr0()
336 hw_base += runtime->buffer_size; in snd_pcm_update_hw_ptr0()
337 if (hw_base >= runtime->boundary) { in snd_pcm_update_hw_ptr0()
346 delta += runtime->boundary; in snd_pcm_update_hw_ptr0()
348 if (runtime->no_period_wakeup) { in snd_pcm_update_hw_ptr0()
354 jdelta = curr_jiffies - runtime->hw_ptr_jiffies; in snd_pcm_update_hw_ptr0()
355 if (jdelta < runtime->hw_ptr_buffer_jiffies / 2) in snd_pcm_update_hw_ptr0()
357 hdelta = jdelta - delta * HZ / runtime->rate; in snd_pcm_update_hw_ptr0()
358 xrun_threshold = runtime->hw_ptr_buffer_jiffies / 2 + 1; in snd_pcm_update_hw_ptr0()
360 delta += runtime->buffer_size; in snd_pcm_update_hw_ptr0()
361 hw_base += runtime->buffer_size; in snd_pcm_update_hw_ptr0()
362 if (hw_base >= runtime->boundary) { in snd_pcm_update_hw_ptr0()
367 hdelta -= runtime->hw_ptr_buffer_jiffies; in snd_pcm_update_hw_ptr0()
373 if (delta >= runtime->buffer_size + runtime->period_size) { in snd_pcm_update_hw_ptr0()
389 if (runtime->hw.info & SNDRV_PCM_INFO_BATCH) in snd_pcm_update_hw_ptr0()
392 if (hdelta < runtime->delay) in snd_pcm_update_hw_ptr0()
394 hdelta -= runtime->delay; in snd_pcm_update_hw_ptr0()
395 jdelta = curr_jiffies - runtime->hw_ptr_jiffies; in snd_pcm_update_hw_ptr0()
396 if (((hdelta * HZ) / runtime->rate) > jdelta + HZ/100) { in snd_pcm_update_hw_ptr0()
398 (((runtime->period_size * HZ) / runtime->rate) in snd_pcm_update_hw_ptr0()
406 new_hw_ptr += runtime->period_size; in snd_pcm_update_hw_ptr0()
407 if (new_hw_ptr >= runtime->boundary) { in snd_pcm_update_hw_ptr0()
408 new_hw_ptr -= runtime->boundary; in snd_pcm_update_hw_ptr0()
417 (long)runtime->period_size, jdelta, in snd_pcm_update_hw_ptr0()
418 ((hdelta * HZ) / runtime->rate), hw_base, in snd_pcm_update_hw_ptr0()
423 hw_base = new_hw_ptr - (new_hw_ptr % runtime->buffer_size); in snd_pcm_update_hw_ptr0()
426 if (delta > runtime->period_size + runtime->period_size / 2) { in snd_pcm_update_hw_ptr0()
436 if (runtime->status->hw_ptr == new_hw_ptr) { in snd_pcm_update_hw_ptr0()
437 runtime->hw_ptr_jiffies = curr_jiffies; in snd_pcm_update_hw_ptr0()
443 runtime->silence_size > 0) in snd_pcm_update_hw_ptr0()
447 delta = new_hw_ptr - runtime->hw_ptr_interrupt; in snd_pcm_update_hw_ptr0()
449 delta += runtime->boundary; in snd_pcm_update_hw_ptr0()
450 delta -= (snd_pcm_uframes_t)delta % runtime->period_size; in snd_pcm_update_hw_ptr0()
451 runtime->hw_ptr_interrupt += delta; in snd_pcm_update_hw_ptr0()
452 if (runtime->hw_ptr_interrupt >= runtime->boundary) in snd_pcm_update_hw_ptr0()
453 runtime->hw_ptr_interrupt -= runtime->boundary; in snd_pcm_update_hw_ptr0()
455 runtime->hw_ptr_base = hw_base; in snd_pcm_update_hw_ptr0()
456 runtime->status->hw_ptr = new_hw_ptr; in snd_pcm_update_hw_ptr0()
457 runtime->hw_ptr_jiffies = curr_jiffies; in snd_pcm_update_hw_ptr0()
460 runtime->hw_ptr_wrap += runtime->boundary; in snd_pcm_update_hw_ptr0()
465 return snd_pcm_update_state(substream, runtime); in snd_pcm_update_hw_ptr0()
501 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_set_sync() local
503 runtime->sync.id32[0] = substream->pcm->card->number; in snd_pcm_set_sync()
504 runtime->sync.id32[1] = -1; in snd_pcm_set_sync()
505 runtime->sync.id32[2] = -1; in snd_pcm_set_sync()
506 runtime->sync.id32[3] = -1; in snd_pcm_set_sync()
1120 int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsigned int cond, in snd_pcm_hw_rule_add() argument
1125 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_rule_add()
1174 int snd_pcm_hw_constraint_mask(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, in snd_pcm_hw_constraint_mask() argument
1177 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_constraint_mask()
1196 int snd_pcm_hw_constraint_mask64(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, in snd_pcm_hw_constraint_mask64() argument
1199 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_constraint_mask64()
1220 int snd_pcm_hw_constraint_integer(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var) in snd_pcm_hw_constraint_integer() argument
1222 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_constraint_integer()
1239 int snd_pcm_hw_constraint_minmax(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, in snd_pcm_hw_constraint_minmax() argument
1242 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_constraint_minmax()
1271 int snd_pcm_hw_constraint_list(struct snd_pcm_runtime *runtime, in snd_pcm_hw_constraint_list() argument
1276 return snd_pcm_hw_rule_add(runtime, cond, var, in snd_pcm_hw_constraint_list()
1302 int snd_pcm_hw_constraint_ranges(struct snd_pcm_runtime *runtime, in snd_pcm_hw_constraint_ranges() argument
1307 return snd_pcm_hw_rule_add(runtime, cond, var, in snd_pcm_hw_constraint_ranges()
1337 int snd_pcm_hw_constraint_ratnums(struct snd_pcm_runtime *runtime, in snd_pcm_hw_constraint_ratnums() argument
1342 return snd_pcm_hw_rule_add(runtime, cond, var, in snd_pcm_hw_constraint_ratnums()
1371 int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, in snd_pcm_hw_constraint_ratdens() argument
1376 return snd_pcm_hw_rule_add(runtime, cond, var, in snd_pcm_hw_constraint_ratdens()
1415 int snd_pcm_hw_constraint_msbits(struct snd_pcm_runtime *runtime, in snd_pcm_hw_constraint_msbits() argument
1421 return snd_pcm_hw_rule_add(runtime, cond, -1, in snd_pcm_hw_constraint_msbits()
1444 int snd_pcm_hw_constraint_step(struct snd_pcm_runtime *runtime, in snd_pcm_hw_constraint_step() argument
1449 return snd_pcm_hw_rule_add(runtime, cond, var, in snd_pcm_hw_constraint_step()
1475 int snd_pcm_hw_constraint_pow2(struct snd_pcm_runtime *runtime, in snd_pcm_hw_constraint_pow2() argument
1479 return snd_pcm_hw_rule_add(runtime, cond, var, in snd_pcm_hw_constraint_pow2()
1502 int snd_pcm_hw_rule_noresample(struct snd_pcm_runtime *runtime, in snd_pcm_hw_rule_noresample() argument
1505 return snd_pcm_hw_rule_add(runtime, SNDRV_PCM_HW_PARAMS_NORESAMPLE, in snd_pcm_hw_rule_noresample()
1687 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_ioctl_reset() local
1692 runtime->status->hw_ptr %= runtime->buffer_size; in snd_pcm_lib_ioctl_reset()
1694 runtime->status->hw_ptr = 0; in snd_pcm_lib_ioctl_reset()
1695 runtime->hw_ptr_wrap = 0; in snd_pcm_lib_ioctl_reset()
1705 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_ioctl_channel_info() local
1707 if (!(runtime->info & SNDRV_PCM_INFO_MMAP)) { in snd_pcm_lib_ioctl_channel_info()
1711 width = snd_pcm_format_physical_width(runtime->format); in snd_pcm_lib_ioctl_channel_info()
1715 switch (runtime->access) { in snd_pcm_lib_ioctl_channel_info()
1719 info->step = runtime->channels * width; in snd_pcm_lib_ioctl_channel_info()
1724 size_t size = runtime->dma_bytes / runtime->channels; in snd_pcm_lib_ioctl_channel_info()
1744 params->fifo_size = substream->runtime->hw.fifo_size; in snd_pcm_lib_ioctl_fifo_size()
1745 if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_FIFO_IN_FRAMES)) { in snd_pcm_lib_ioctl_fifo_size()
1810 struct snd_pcm_runtime *runtime; in snd_pcm_period_elapsed_under_stream_lock() local
1814 runtime = substream->runtime; in snd_pcm_period_elapsed_under_stream_lock()
1825 kill_fasync(&runtime->fasync, SIGIO, POLL_IN); in snd_pcm_period_elapsed_under_stream_lock()
1863 struct snd_pcm_runtime *runtime = substream->runtime; in wait_for_avail() local
1872 add_wait_queue(&runtime->tsleep, &wait); in wait_for_avail()
1874 if (runtime->no_period_wakeup) in wait_for_avail()
1883 if (runtime->rate) { in wait_for_avail()
1884 long t = runtime->period_size * 2 / in wait_for_avail()
1885 runtime->rate; in wait_for_avail()
1906 if (avail >= runtime->twake) in wait_for_avail()
1914 switch (runtime->status->state) { in wait_for_avail()
1945 remove_wait_queue(&runtime->tsleep, &wait); in wait_for_avail()
1958 static void *get_dma_ptr(struct snd_pcm_runtime *runtime, in get_dma_ptr() argument
1961 return runtime->dma_area + hwoff + in get_dma_ptr()
1962 channel * (runtime->dma_bytes / runtime->channels); in get_dma_ptr()
1970 if (copy_from_user(get_dma_ptr(substream->runtime, channel, hwoff), in default_write_copy()
1981 memcpy(get_dma_ptr(substream->runtime, channel, hwoff), buf, bytes); in default_write_copy_kernel()
1992 struct snd_pcm_runtime *runtime = substream->runtime; in fill_silence() local
2000 snd_pcm_format_set_silence(runtime->format, in fill_silence()
2001 get_dma_ptr(runtime, channel, hwoff), in fill_silence()
2002 bytes_to_samples(runtime, bytes)); in fill_silence()
2012 get_dma_ptr(substream->runtime, channel, hwoff), in default_read_copy()
2023 memcpy(buf, get_dma_ptr(substream->runtime, channel, hwoff), bytes); in default_read_copy_kernel()
2036 struct snd_pcm_runtime *runtime = substream->runtime; in interleaved_copy() local
2039 hwoff = frames_to_bytes(runtime, hwoff); in interleaved_copy()
2040 off = frames_to_bytes(runtime, off); in interleaved_copy()
2041 frames = frames_to_bytes(runtime, frames); in interleaved_copy()
2054 struct snd_pcm_runtime *runtime = substream->runtime; in noninterleaved_copy() local
2055 int channels = runtime->channels; in noninterleaved_copy()
2063 off = samples_to_bytes(runtime, off); in noninterleaved_copy()
2064 frames = samples_to_bytes(runtime, frames); in noninterleaved_copy()
2065 hwoff = samples_to_bytes(runtime, hwoff); in noninterleaved_copy()
2084 if (substream->runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED || in fill_silence_frames()
2085 substream->runtime->access == SNDRV_PCM_ACCESS_MMAP_INTERLEAVED) in fill_silence_frames()
2096 struct snd_pcm_runtime *runtime; in pcm_sanity_check() local
2099 runtime = substream->runtime; in pcm_sanity_check()
2100 if (snd_BUG_ON(!substream->ops->copy_user && !runtime->dma_area)) in pcm_sanity_check()
2102 if (runtime->status->state == SNDRV_PCM_STATE_OPEN) in pcm_sanity_check()
2107 static int pcm_accessible_state(struct snd_pcm_runtime *runtime) in pcm_accessible_state() argument
2109 switch (runtime->status->state) { in pcm_accessible_state()
2129 struct snd_pcm_runtime *runtime = substream->runtime; in pcm_lib_apply_appl_ptr() local
2130 snd_pcm_uframes_t old_appl_ptr = runtime->control->appl_ptr; in pcm_lib_apply_appl_ptr()
2136 runtime->control->appl_ptr = appl_ptr; in pcm_lib_apply_appl_ptr()
2140 runtime->control->appl_ptr = old_appl_ptr; in pcm_lib_apply_appl_ptr()
2155 struct snd_pcm_runtime *runtime = substream->runtime; in __snd_pcm_lib_xfer() local
2171 if (runtime->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED && in __snd_pcm_lib_xfer()
2172 runtime->channels > 1) in __snd_pcm_lib_xfer()
2176 if (runtime->access != SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) in __snd_pcm_lib_xfer()
2206 err = pcm_accessible_state(runtime); in __snd_pcm_lib_xfer()
2210 runtime->twake = runtime->control->avail_min ? : 1; in __snd_pcm_lib_xfer()
2211 if (runtime->status->state == SNDRV_PCM_STATE_RUNNING) in __snd_pcm_lib_xfer()
2219 runtime->status->state == SNDRV_PCM_STATE_PREPARED && in __snd_pcm_lib_xfer()
2220 size >= runtime->start_threshold) { in __snd_pcm_lib_xfer()
2233 runtime->status->state == SNDRV_PCM_STATE_DRAINING) { in __snd_pcm_lib_xfer()
2241 runtime->twake = min_t(snd_pcm_uframes_t, size, in __snd_pcm_lib_xfer()
2242 runtime->control->avail_min ? : 1); in __snd_pcm_lib_xfer()
2250 appl_ptr = READ_ONCE(runtime->control->appl_ptr); in __snd_pcm_lib_xfer()
2251 appl_ofs = appl_ptr % runtime->buffer_size; in __snd_pcm_lib_xfer()
2252 cont = runtime->buffer_size - appl_ofs; in __snd_pcm_lib_xfer()
2269 err = pcm_accessible_state(runtime); in __snd_pcm_lib_xfer()
2273 if (appl_ptr >= runtime->boundary) in __snd_pcm_lib_xfer()
2274 appl_ptr -= runtime->boundary; in __snd_pcm_lib_xfer()
2284 runtime->status->state == SNDRV_PCM_STATE_PREPARED && in __snd_pcm_lib_xfer()
2285 snd_pcm_playback_hw_avail(runtime) >= (snd_pcm_sframes_t)runtime->start_threshold) { in __snd_pcm_lib_xfer()
2292 runtime->twake = 0; in __snd_pcm_lib_xfer()
2294 snd_pcm_update_state(substream, runtime); in __snd_pcm_lib_xfer()
2385 if (!substream->runtime) in pcm_chmap_ctl_get()
2389 if (map->channels == substream->runtime->channels && in pcm_chmap_ctl_get()