Commit 5eb4ff88 authored by Cezary Rojewski's avatar Cezary Rojewski Committed by Takashi Iwai

ALSA: hda: Add code_loading parameter to stream setup

AudioDSP firmware is the one who kicks SDxFIFOS calculation when a
stream is decoupled mode. During firmware bring up procedure, there is
no firmware running and the code-loading stream is always a decoupled
one. So, there is none to trigger the calculation and we end up with
false-positive timeout (-110) messages.
Signed-off-by: default avatarCezary Rojewski <cezary.rojewski@intel.com>
Acked-by: default avatarMark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20231006102857.749143-4-cezary.rojewski@intel.comSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 956b610c
...@@ -573,7 +573,7 @@ void snd_hdac_stream_release(struct hdac_stream *azx_dev); ...@@ -573,7 +573,7 @@ void snd_hdac_stream_release(struct hdac_stream *azx_dev);
struct hdac_stream *snd_hdac_get_stream(struct hdac_bus *bus, struct hdac_stream *snd_hdac_get_stream(struct hdac_bus *bus,
int dir, int stream_tag); int dir, int stream_tag);
int snd_hdac_stream_setup(struct hdac_stream *azx_dev); int snd_hdac_stream_setup(struct hdac_stream *azx_dev, bool code_loading);
void snd_hdac_stream_cleanup(struct hdac_stream *azx_dev); void snd_hdac_stream_cleanup(struct hdac_stream *azx_dev);
int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev); int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev);
int snd_hdac_stream_set_params(struct hdac_stream *azx_dev, int snd_hdac_stream_set_params(struct hdac_stream *azx_dev,
......
...@@ -60,7 +60,7 @@ struct hdac_ext_stream { ...@@ -60,7 +60,7 @@ struct hdac_ext_stream {
bool link_locked:1; bool link_locked:1;
bool link_prepared; bool link_prepared;
int (*host_setup)(struct hdac_stream *); int (*host_setup)(struct hdac_stream *, bool);
struct snd_pcm_substream *link_substream; struct snd_pcm_substream *link_substream;
}; };
...@@ -88,7 +88,7 @@ void snd_hdac_ext_stream_start(struct hdac_ext_stream *hext_stream); ...@@ -88,7 +88,7 @@ void snd_hdac_ext_stream_start(struct hdac_ext_stream *hext_stream);
void snd_hdac_ext_stream_clear(struct hdac_ext_stream *hext_stream); void snd_hdac_ext_stream_clear(struct hdac_ext_stream *hext_stream);
void snd_hdac_ext_stream_reset(struct hdac_ext_stream *hext_stream); void snd_hdac_ext_stream_reset(struct hdac_ext_stream *hext_stream);
int snd_hdac_ext_stream_setup(struct hdac_ext_stream *hext_stream, int fmt); int snd_hdac_ext_stream_setup(struct hdac_ext_stream *hext_stream, int fmt);
int snd_hdac_ext_host_stream_setup(struct hdac_ext_stream *hext_stream); int snd_hdac_ext_host_stream_setup(struct hdac_ext_stream *hext_stream, bool code_loading);
struct hdac_ext_link { struct hdac_ext_link {
struct hdac_bus *bus; struct hdac_bus *bus;
......
...@@ -21,12 +21,13 @@ ...@@ -21,12 +21,13 @@
/** /**
* snd_hdac_ext_host_stream_setup - Setup a HOST stream. * snd_hdac_ext_host_stream_setup - Setup a HOST stream.
* @hext_stream: HDAudio stream to set up. * @hext_stream: HDAudio stream to set up.
* @code_loading: Whether the stream is for PCM or code-loading.
* *
* Return: Zero on success or negative error code. * Return: Zero on success or negative error code.
*/ */
int snd_hdac_ext_host_stream_setup(struct hdac_ext_stream *hext_stream) int snd_hdac_ext_host_stream_setup(struct hdac_ext_stream *hext_stream, bool code_loading)
{ {
return hext_stream->host_setup(hdac_stream(hext_stream)); return hext_stream->host_setup(hdac_stream(hext_stream), code_loading);
} }
EXPORT_SYMBOL_GPL(snd_hdac_ext_host_stream_setup); EXPORT_SYMBOL_GPL(snd_hdac_ext_host_stream_setup);
...@@ -34,16 +35,17 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_host_stream_setup); ...@@ -34,16 +35,17 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_host_stream_setup);
* snd_hdac_apl_host_stream_setup - Setup a HOST stream following procedure * snd_hdac_apl_host_stream_setup - Setup a HOST stream following procedure
* recommended for ApolloLake devices. * recommended for ApolloLake devices.
* @hstream: HDAudio stream to set up. * @hstream: HDAudio stream to set up.
* @code_loading: Whether the stream is for PCM or code-loading.
* *
* Return: Zero on success or negative error code. * Return: Zero on success or negative error code.
*/ */
static int snd_hdac_apl_host_stream_setup(struct hdac_stream *hstream) static int snd_hdac_apl_host_stream_setup(struct hdac_stream *hstream, bool code_loading)
{ {
struct hdac_ext_stream *hext_stream = stream_to_hdac_ext_stream(hstream); struct hdac_ext_stream *hext_stream = stream_to_hdac_ext_stream(hstream);
int ret; int ret;
snd_hdac_ext_stream_decouple(hstream->bus, hext_stream, false); snd_hdac_ext_stream_decouple(hstream->bus, hext_stream, false);
ret = snd_hdac_stream_setup(hstream); ret = snd_hdac_stream_setup(hstream, code_loading);
snd_hdac_ext_stream_decouple(hstream->bus, hext_stream, true); snd_hdac_ext_stream_decouple(hstream->bus, hext_stream, true);
return ret; return ret;
...@@ -89,7 +91,7 @@ int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx, ...@@ -89,7 +91,7 @@ int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx,
int num_stream, int dir) int num_stream, int dir)
{ {
struct pci_dev *pci = to_pci_dev(bus->dev); struct pci_dev *pci = to_pci_dev(bus->dev);
int (*setup_op)(struct hdac_stream *); int (*setup_op)(struct hdac_stream *, bool);
int stream_tag = 0; int stream_tag = 0;
int i, tag, idx = start_idx; int i, tag, idx = start_idx;
......
...@@ -252,8 +252,9 @@ EXPORT_SYMBOL_GPL(snd_hdac_stream_reset); ...@@ -252,8 +252,9 @@ EXPORT_SYMBOL_GPL(snd_hdac_stream_reset);
/** /**
* snd_hdac_stream_setup - set up the SD for streaming * snd_hdac_stream_setup - set up the SD for streaming
* @azx_dev: HD-audio core stream to set up * @azx_dev: HD-audio core stream to set up
* @code_loading: Whether the stream is for PCM or code-loading.
*/ */
int snd_hdac_stream_setup(struct hdac_stream *azx_dev) int snd_hdac_stream_setup(struct hdac_stream *azx_dev, bool code_loading)
{ {
struct hdac_bus *bus = azx_dev->bus; struct hdac_bus *bus = azx_dev->bus;
struct snd_pcm_runtime *runtime; struct snd_pcm_runtime *runtime;
...@@ -302,13 +303,15 @@ int snd_hdac_stream_setup(struct hdac_stream *azx_dev) ...@@ -302,13 +303,15 @@ int snd_hdac_stream_setup(struct hdac_stream *azx_dev)
/* set the interrupt enable bits in the descriptor control register */ /* set the interrupt enable bits in the descriptor control register */
snd_hdac_stream_updatel(azx_dev, SD_CTL, 0, SD_INT_MASK); snd_hdac_stream_updatel(azx_dev, SD_CTL, 0, SD_INT_MASK);
if (!code_loading) {
/* Once SDxFMT is set, the controller programs SDxFIFOS to non-zero value. */ /* Once SDxFMT is set, the controller programs SDxFIFOS to non-zero value. */
ret = snd_hdac_stream_readw_poll(azx_dev, SD_FIFOSIZE, reg, reg & AZX_SD_FIFOSIZE_MASK, ret = snd_hdac_stream_readw_poll(azx_dev, SD_FIFOSIZE, reg,
3, 300); reg & AZX_SD_FIFOSIZE_MASK, 3, 300);
if (ret) if (ret)
dev_dbg(bus->dev, "polling SD_FIFOSIZE 0x%04x failed: %d\n", dev_dbg(bus->dev, "polling SD_FIFOSIZE 0x%04x failed: %d\n",
AZX_REG_SD_FIFOSIZE, ret); AZX_REG_SD_FIFOSIZE, ret);
azx_dev->fifo_size = snd_hdac_stream_readw(azx_dev, SD_FIFOSIZE); azx_dev->fifo_size = reg;
}
/* when LPIB delay correction gives a small negative value, /* when LPIB delay correction gives a small negative value,
* we ignore it; currently set the threshold statically to * we ignore it; currently set the threshold statically to
...@@ -953,7 +956,7 @@ int snd_hdac_dsp_prepare(struct hdac_stream *azx_dev, unsigned int format, ...@@ -953,7 +956,7 @@ int snd_hdac_dsp_prepare(struct hdac_stream *azx_dev, unsigned int format,
if (err < 0) if (err < 0)
goto error; goto error;
snd_hdac_stream_setup(azx_dev); snd_hdac_stream_setup(azx_dev, true);
snd_hdac_dsp_unlock(azx_dev); snd_hdac_dsp_unlock(azx_dev);
return azx_dev->stream_tag; return azx_dev->stream_tag;
......
...@@ -182,7 +182,7 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream) ...@@ -182,7 +182,7 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream)
if (err < 0) if (err < 0)
goto unlock; goto unlock;
snd_hdac_stream_setup(azx_stream(azx_dev)); snd_hdac_stream_setup(azx_stream(azx_dev), false);
stream_tag = azx_dev->core.stream_tag; stream_tag = azx_dev->core.stream_tag;
/* CA-IBG chips need the playback stream starting from 1 */ /* CA-IBG chips need the playback stream starting from 1 */
......
...@@ -625,7 +625,7 @@ static int avs_dai_fe_prepare(struct snd_pcm_substream *substream, struct snd_so ...@@ -625,7 +625,7 @@ static int avs_dai_fe_prepare(struct snd_pcm_substream *substream, struct snd_so
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = snd_hdac_ext_host_stream_setup(host_stream); ret = snd_hdac_ext_host_stream_setup(host_stream, false);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
...@@ -145,7 +145,7 @@ static int avs_probe_compr_set_params(struct snd_compr_stream *cstream, ...@@ -145,7 +145,7 @@ static int avs_probe_compr_set_params(struct snd_compr_stream *cstream,
ret = snd_hdac_stream_set_params(hdac_stream(host_stream), format_val); ret = snd_hdac_stream_set_params(hdac_stream(host_stream), format_val);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = snd_hdac_stream_setup(hdac_stream(host_stream)); ret = snd_hdac_stream_setup(hdac_stream(host_stream), false);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
...@@ -148,7 +148,7 @@ int skl_pcm_host_dma_prepare(struct device *dev, struct skl_pipe_params *params) ...@@ -148,7 +148,7 @@ int skl_pcm_host_dma_prepare(struct device *dev, struct skl_pipe_params *params)
if (err < 0) if (err < 0)
return err; return err;
err = snd_hdac_ext_host_stream_setup(stream); err = snd_hdac_ext_host_stream_setup(stream, false);
if (err < 0) if (err < 0)
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment