mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 02:53:36 +02:00
ASoC: Intel: avs: Store pointer to link_stream in dma_data
While the HDAudio codec driver expectations must be met - store valid pointer to HDAudio LINK stream in substream->runtime->private_data - the code is more readable and easier to maintain if dma_data stores pointers to both HOST and LINK stream. DAI BE operations can refer to the LINK stream with data->link_stream, similarly to how DAI FE operations access the HOST stream with data->host_stream. Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://lore.kernel.org/r/20240426095733.3946951-8-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
0f8843ca4f
commit
cdcb770a60
|
|
@ -23,13 +23,12 @@ struct avs_dma_data {
|
||||||
struct avs_tplg_path_template *template;
|
struct avs_tplg_path_template *template;
|
||||||
struct avs_path *path;
|
struct avs_path *path;
|
||||||
struct avs_dev *adev;
|
struct avs_dev *adev;
|
||||||
/*
|
|
||||||
* link stream is stored within substream's runtime
|
/* LINK-stream utilized in BE operations while HOST in FE ones. */
|
||||||
* private_data to fulfill the needs of codec BE path
|
union {
|
||||||
*
|
struct hdac_ext_stream *link_stream;
|
||||||
* host stream assigned
|
struct hdac_ext_stream *host_stream;
|
||||||
*/
|
};
|
||||||
struct hdac_ext_stream *host_stream;
|
|
||||||
|
|
||||||
struct snd_pcm_substream *substream;
|
struct snd_pcm_substream *substream;
|
||||||
};
|
};
|
||||||
|
|
@ -263,6 +262,7 @@ static int avs_dai_hda_be_startup(struct snd_pcm_substream *substream, struct sn
|
||||||
{
|
{
|
||||||
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
|
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
|
||||||
struct hdac_ext_stream *link_stream;
|
struct hdac_ext_stream *link_stream;
|
||||||
|
struct avs_dma_data *data;
|
||||||
struct hda_codec *codec;
|
struct hda_codec *codec;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
|
@ -278,18 +278,18 @@ static int avs_dai_hda_be_startup(struct snd_pcm_substream *substream, struct sn
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data = snd_soc_dai_get_dma_data(dai, substream);
|
||||||
|
data->link_stream = link_stream;
|
||||||
substream->runtime->private_data = link_stream;
|
substream->runtime->private_data = link_stream;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void avs_dai_hda_be_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
|
static void avs_dai_hda_be_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
|
||||||
{
|
{
|
||||||
struct hdac_ext_stream *link_stream;
|
struct avs_dma_data *data = snd_soc_dai_get_dma_data(dai, substream);
|
||||||
|
|
||||||
link_stream = substream->runtime->private_data;
|
snd_hdac_ext_stream_release(data->link_stream, HDAC_EXT_STREAM_TYPE_LINK);
|
||||||
snd_hdac_ext_stream_release(link_stream, HDAC_EXT_STREAM_TYPE_LINK);
|
|
||||||
substream->runtime->private_data = NULL;
|
substream->runtime->private_data = NULL;
|
||||||
|
|
||||||
avs_dai_shutdown(substream, dai);
|
avs_dai_shutdown(substream, dai);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -297,16 +297,13 @@ static int avs_dai_hda_be_hw_params(struct snd_pcm_substream *substream,
|
||||||
struct snd_pcm_hw_params *hw_params, struct snd_soc_dai *dai)
|
struct snd_pcm_hw_params *hw_params, struct snd_soc_dai *dai)
|
||||||
{
|
{
|
||||||
struct avs_dma_data *data;
|
struct avs_dma_data *data;
|
||||||
struct hdac_ext_stream *link_stream;
|
|
||||||
|
|
||||||
data = snd_soc_dai_get_dma_data(dai, substream);
|
data = snd_soc_dai_get_dma_data(dai, substream);
|
||||||
if (data->path)
|
if (data->path)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
link_stream = substream->runtime->private_data;
|
|
||||||
|
|
||||||
return avs_dai_be_hw_params(substream, hw_params, dai,
|
return avs_dai_be_hw_params(substream, hw_params, dai,
|
||||||
hdac_stream(link_stream)->stream_tag - 1);
|
hdac_stream(data->link_stream)->stream_tag - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int avs_dai_hda_be_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
|
static int avs_dai_hda_be_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
|
||||||
|
|
@ -323,7 +320,7 @@ static int avs_dai_hda_be_hw_free(struct snd_pcm_substream *substream, struct sn
|
||||||
if (!data->path)
|
if (!data->path)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
link_stream = substream->runtime->private_data;
|
link_stream = data->link_stream;
|
||||||
link_stream->link_prepared = false;
|
link_stream->link_prepared = false;
|
||||||
avs_path_free(data->path);
|
avs_path_free(data->path);
|
||||||
data->path = NULL;
|
data->path = NULL;
|
||||||
|
|
@ -347,13 +344,16 @@ static int avs_dai_hda_be_prepare(struct snd_pcm_substream *substream, struct sn
|
||||||
struct snd_soc_pcm_stream *stream_info;
|
struct snd_soc_pcm_stream *stream_info;
|
||||||
struct hdac_ext_stream *link_stream;
|
struct hdac_ext_stream *link_stream;
|
||||||
struct hdac_ext_link *link;
|
struct hdac_ext_link *link;
|
||||||
|
struct avs_dma_data *data;
|
||||||
struct hda_codec *codec;
|
struct hda_codec *codec;
|
||||||
struct hdac_bus *bus;
|
struct hdac_bus *bus;
|
||||||
unsigned int format_val;
|
unsigned int format_val;
|
||||||
unsigned int bits;
|
unsigned int bits;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
link_stream = runtime->private_data;
|
data = snd_soc_dai_get_dma_data(dai, substream);
|
||||||
|
link_stream = data->link_stream;
|
||||||
|
|
||||||
if (link_stream->link_prepared)
|
if (link_stream->link_prepared)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
@ -387,14 +387,12 @@ static int avs_dai_hda_be_trigger(struct snd_pcm_substream *substream, int cmd,
|
||||||
struct snd_soc_dai *dai)
|
struct snd_soc_dai *dai)
|
||||||
{
|
{
|
||||||
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
|
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
|
||||||
struct hdac_ext_stream *link_stream;
|
|
||||||
struct avs_dma_data *data;
|
struct avs_dma_data *data;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
dev_dbg(dai->dev, "entry %s cmd=%d\n", __func__, cmd);
|
dev_dbg(dai->dev, "entry %s cmd=%d\n", __func__, cmd);
|
||||||
|
|
||||||
data = snd_soc_dai_get_dma_data(dai, substream);
|
data = snd_soc_dai_get_dma_data(dai, substream);
|
||||||
link_stream = substream->runtime->private_data;
|
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case SNDRV_PCM_TRIGGER_RESUME:
|
case SNDRV_PCM_TRIGGER_RESUME:
|
||||||
|
|
@ -403,7 +401,7 @@ static int avs_dai_hda_be_trigger(struct snd_pcm_substream *substream, int cmd,
|
||||||
fallthrough;
|
fallthrough;
|
||||||
case SNDRV_PCM_TRIGGER_START:
|
case SNDRV_PCM_TRIGGER_START:
|
||||||
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
|
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
|
||||||
snd_hdac_ext_stream_start(link_stream);
|
snd_hdac_ext_stream_start(data->link_stream);
|
||||||
|
|
||||||
ret = avs_path_pause(data->path);
|
ret = avs_path_pause(data->path);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
|
@ -426,7 +424,7 @@ static int avs_dai_hda_be_trigger(struct snd_pcm_substream *substream, int cmd,
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
dev_err(dai->dev, "pause BE path failed: %d\n", ret);
|
dev_err(dai->dev, "pause BE path failed: %d\n", ret);
|
||||||
|
|
||||||
snd_hdac_ext_stream_clear(link_stream);
|
snd_hdac_ext_stream_clear(data->link_stream);
|
||||||
|
|
||||||
ret = avs_path_reset(data->path);
|
ret = avs_path_reset(data->path);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user