Lines Matching +full:hw +full:- +full:settle +full:- +full:time
1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
22 #include "../sof-audio.h"
27 #define SDnFMT_MULT(x) (((x) - 1) << 11)
28 #define SDnFMT_DIV(x) (((x) - 1) << 8)
42 static int hda_force_pause_support = -1;
45 "Pause support: -1: Use default, 0: Disable, 1: Enable (default -1)");
75 dev_warn(sdev->dev, "can't find div rate %d using 48kHz\n", in hda_dsp_get_mult_div()
95 dev_warn(sdev->dev, "can't find %d bits using 16bit\n", in hda_dsp_get_bits()
106 struct hdac_stream *hstream = substream->runtime->private_data; in hda_dsp_pcm_hw_params()
108 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_pcm_hw_params()
112 hstream->substream = substream; in hda_dsp_pcm_hw_params()
114 dmab = substream->runtime->dma_buffer_p; in hda_dsp_pcm_hw_params()
120 if (!sdev->dspless_mode_selected) { in hda_dsp_pcm_hw_params()
124 hstream->format_val = rate | bits | (params_channels(params) - 1); in hda_dsp_pcm_hw_params()
127 hstream->bufsize = params_buffer_bytes(params); in hda_dsp_pcm_hw_params()
128 hstream->period_bytes = params_period_bytes(params); in hda_dsp_pcm_hw_params()
129 hstream->no_period_wakeup = in hda_dsp_pcm_hw_params()
130 (params->info & SNDRV_PCM_INFO_NO_PERIOD_WAKEUP) && in hda_dsp_pcm_hw_params()
131 (params->flags & SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP); in hda_dsp_pcm_hw_params()
135 dev_err(sdev->dev, "error: hdac prepare failed: %d\n", ret); in hda_dsp_pcm_hw_params()
146 platform_params->no_ipc_position = hda->no_ipc_position; in hda_dsp_pcm_hw_params()
148 platform_params->stream_tag = hstream->stream_tag; in hda_dsp_pcm_hw_params()
157 struct hdac_stream *hstream = substream->runtime->private_data; in hda_dsp_pcm_ack()
158 struct snd_pcm_runtime *runtime = substream->runtime; in hda_dsp_pcm_ack()
162 appl_pos = frames_to_bytes(runtime, runtime->control->appl_ptr); in hda_dsp_pcm_ack()
163 buf_size = frames_to_bytes(runtime, runtime->buffer_size); in hda_dsp_pcm_ack()
171 sof_io_write(sdev, hstream->spib_addr, spib); in hda_dsp_pcm_ack()
180 struct hdac_stream *hstream = substream->runtime->private_data; in hda_dsp_pcm_trigger()
191 struct snd_soc_component *scomp = sdev->component; in hda_dsp_pcm_pointer()
192 struct hdac_stream *hstream = substream->runtime->private_data; in hda_dsp_pcm_pointer()
193 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_pcm_pointer()
199 dev_warn_ratelimited(sdev->dev, "warn: can't find PCM with DAI ID %d\n", in hda_dsp_pcm_pointer()
200 rtd->dai_link->id); in hda_dsp_pcm_pointer()
204 if (hda && !hda->no_ipc_position) { in hda_dsp_pcm_pointer()
206 pos = spcm->stream[substream->stream].posn.host_posn; in hda_dsp_pcm_pointer()
210 pos = hda_dsp_stream_get_position(hstream, substream->stream, true); in hda_dsp_pcm_pointer()
212 pos = bytes_to_frames(substream->runtime, pos); in hda_dsp_pcm_pointer()
223 struct snd_pcm_runtime *runtime = substream->runtime; in hda_dsp_pcm_open()
224 struct snd_soc_component *scomp = sdev->component; in hda_dsp_pcm_open()
227 int direction = substream->stream; in hda_dsp_pcm_open()
232 dev_err(sdev->dev, "error: can't find PCM with DAI ID %d\n", rtd->dai_link->id); in hda_dsp_pcm_open()
233 return -EINVAL; in hda_dsp_pcm_open()
241 runtime->hw.info |= SNDRV_PCM_INFO_NO_REWINDS | SNDRV_PCM_INFO_SYNC_APPLPTR; in hda_dsp_pcm_open()
248 runtime->hw.info &= ~SNDRV_PCM_INFO_PAUSE; in hda_dsp_pcm_open()
256 (hda_force_pause_support == -1 && in hda_dsp_pcm_open()
257 !spcm->stream[substream->stream].pause_supported)) in hda_dsp_pcm_open()
258 runtime->hw.info &= ~SNDRV_PCM_INFO_PAUSE; in hda_dsp_pcm_open()
262 spcm->stream[substream->stream].d0i3_compatible) in hda_dsp_pcm_open()
267 dev_err(sdev->dev, "error: no stream available\n"); in hda_dsp_pcm_open()
268 return -ENODEV; in hda_dsp_pcm_open()
272 snd_pcm_hw_constraint_step(substream->runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 4); in hda_dsp_pcm_open()
275 snd_pcm_hw_constraint_integer(substream->runtime, in hda_dsp_pcm_open()
279 if (runtime->hw.periods_max > HDA_DSP_MAX_BDL_ENTRIES) in hda_dsp_pcm_open()
281 runtime->hw.periods_min, in hda_dsp_pcm_open()
285 if (sdev->dspless_mode_selected) in hda_dsp_pcm_open()
286 snd_pcm_hw_constraint_mask64(substream->runtime, SNDRV_PCM_HW_PARAM_FORMAT, in hda_dsp_pcm_open()
299 * We need to add headroom of max 10ms as the firmware needs time to in hda_dsp_pcm_open()
300 * settle to the 1ms pacing and initially it can run faster for few in hda_dsp_pcm_open()
305 if (spcm->stream[direction].dsp_max_burst_size_in_ms) { in hda_dsp_pcm_open()
306 unsigned int period_time = spcm->stream[direction].dsp_max_burst_size_in_ms; in hda_dsp_pcm_open()
309 * add headroom over the maximum burst size to cover the time in hda_dsp_pcm_open()
310 * needed for the DMA pace to settle. in hda_dsp_pcm_open()
311 * Limit the headroom time to HDA_MAX_PERIOD_TIME_HEADROOM in hda_dsp_pcm_open()
315 snd_pcm_hw_constraint_minmax(substream->runtime, in hda_dsp_pcm_open()
322 substream->runtime->private_data = &dsp_stream->hstream; in hda_dsp_pcm_open()
328 dsp_stream->pplcllpl = 0; in hda_dsp_pcm_open()
329 dsp_stream->pplcllpu = 0; in hda_dsp_pcm_open()
338 struct hdac_stream *hstream = substream->runtime->private_data; in hda_dsp_pcm_close()
339 int direction = substream->stream; in hda_dsp_pcm_close()
342 ret = hda_dsp_stream_put(sdev, direction, hstream->stream_tag); in hda_dsp_pcm_close()
345 dev_dbg(sdev->dev, "stream %s not opened!\n", substream->name); in hda_dsp_pcm_close()
346 return -ENODEV; in hda_dsp_pcm_close()
350 substream->runtime->private_data = NULL; in hda_dsp_pcm_close()