Skip to content

Commit

Permalink
drivers: soundwire: Add new prepare op in struct sdw_intel_ops
Browse files Browse the repository at this point in the history
This is needed to handle the BE pipeline management in the SDW BE DAI
ops.

Signed-off-by: Ranjani Sridharan <[email protected]>
  • Loading branch information
ranj063 committed Dec 5, 2024
1 parent e141549 commit f2569fa
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 2 deletions.
32 changes: 30 additions & 2 deletions drivers/soundwire/intel_ace2x.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,34 @@ static int intel_params_stream(struct sdw_intel *sdw,
return -EIO;
}

static int intel_prepare_stream(struct sdw_intel *sdw,
struct snd_pcm_substream *substream,
struct snd_soc_dai *dai,
struct snd_pcm_hw_params *hw_params,
int link_id, int alh_stream_id)
{
struct sdw_intel_link_res *res = sdw->link_res;
struct sdw_intel_stream_params_data params_data;
int ret;

params_data.substream = substream;
params_data.dai = dai;
params_data.hw_params = hw_params;
params_data.link_id = link_id;
params_data.alh_stream_id = alh_stream_id;

if (res->ops && res->ops->params_stream && res->dev) {
ret = res->ops->params_stream(res->dev, &params_data);
if (ret < 0)
return ret;
}

if (res->ops && res->ops->prepare_stream && res->dev)
return res->ops->prepare_stream(res->dev, &params_data);

return -EIO;
}

static int intel_free_stream(struct sdw_intel *sdw,
struct snd_pcm_substream *substream,
struct snd_soc_dai *dai,
Expand Down Expand Up @@ -422,8 +450,8 @@ static int intel_prepare(struct snd_pcm_substream *substream,
}

/* Inform DSP about PDI stream number */
return intel_params_stream(sdw, substream, dai, hw_params, sdw->instance,
dai_runtime->pdi->intel_alh_id);
return intel_prepare_stream(sdw, substream, dai, hw_params, sdw->instance,
dai_runtime->pdi->intel_alh_id);
}

static int
Expand Down
2 changes: 2 additions & 0 deletions include/linux/soundwire/sdw_intel.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ struct sdw_intel_stream_free_data {
struct sdw_intel_ops {
int (*params_stream)(struct device *dev,
struct sdw_intel_stream_params_data *params_data);
int (*prepare_stream)(struct device *dev,
struct sdw_intel_stream_params_data *params_data);
int (*free_stream)(struct device *dev,
struct sdw_intel_stream_free_data *free_data);
int (*trigger)(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai);
Expand Down
18 changes: 18 additions & 0 deletions sound/soc/sof/intel/hda-dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,24 @@ int sdw_hda_dai_trigger(struct snd_pcm_substream *substream, int cmd,
}
EXPORT_SYMBOL_NS(sdw_hda_dai_trigger, SND_SOC_SOF_INTEL_HDA_COMMON);

int sdw_hda_dai_prepare(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params,
struct snd_soc_dai *cpu_dai, int link_id, int intel_alh_id)
{
struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(cpu_dai, substream->stream);
const struct hda_dai_widget_dma_ops *ops = hda_dai_get_ops(substream, cpu_dai);
int ret;

ret = sdw_hda_dai_hw_params(substream, params, cpu_dai, link_id, intel_alh_id);
if (ret < 0)
return ret;

if (ops && ops->set_up_be_pipeline)
return ops->set_up_be_pipeline(w, substream->stream);

return ret;
}
EXPORT_SYMBOL_NS(sdw_hda_dai_prepare, SND_SOC_SOF_INTEL_HDA_COMMON);

static int hda_dai_suspend(struct hdac_bus *bus)
{
struct snd_soc_pcm_runtime *rtd;
Expand Down
9 changes: 9 additions & 0 deletions sound/soc/sof/intel/hda.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ static int sdw_ace2x_params_stream(struct device *dev,
params_data->alh_stream_id);
}

static int sdw_ace2x_prepare_stream(struct device *dev,
struct sdw_intel_stream_params_data *params_data)
{
return sdw_hda_dai_prepare(params_data->substream, params_data->hw_params,
params_data->dai, params_data->link_id,
params_data->alh_stream_id);
}

static int sdw_ace2x_free_stream(struct device *dev,
struct sdw_intel_stream_free_data *free_data)
{
Expand All @@ -123,6 +131,7 @@ static int sdw_ace2x_trigger(struct snd_pcm_substream *substream, int cmd, struc

static struct sdw_intel_ops sdw_ace2x_callback = {
.params_stream = sdw_ace2x_params_stream,
.prepare_stream = sdw_ace2x_prepare_stream,
.free_stream = sdw_ace2x_free_stream,
.trigger = sdw_ace2x_trigger,
};
Expand Down
3 changes: 3 additions & 0 deletions sound/soc/sof/intel/hda.h
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,9 @@ int sdw_hda_dai_hw_free(struct snd_pcm_substream *substream,
int sdw_hda_dai_trigger(struct snd_pcm_substream *substream, int cmd,
struct snd_soc_dai *cpu_dai);

int sdw_hda_dai_prepare(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params,
struct snd_soc_dai *cpu_dai, int link_id, int intel_alh_id);

/* common dai driver */
extern struct snd_soc_dai_driver skl_dai[];
int hda_dsp_dais_suspend(struct snd_sof_dev *sdev);
Expand Down

0 comments on commit f2569fa

Please sign in to comment.