Unverified Commit 16750684 authored by Mark Brown's avatar Mark Brown
Browse files

ASoC: SOF: Intel: HDaudio cleanups

Merge series from Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>:

This is the part1 of my HDaudio cleanups, before the addition of
to-be-announced HDaudio extensions.

The patchset includes more consistent use of read/write/update
helpers, removal of useless waits, structure members and programming
sequences, removal of confusing sharing of private_data between FE and
BE.

Additional patches are coming to split the controller, codec and
multi-link management functionality in well-identified files.

Pierre-Louis Bossart (16):
  ASoC: SOF: ops: fallback to mmio in helpers
  ASoC: SOF: Intel: use mmio fallback for all platforms
  ASoC: SOF: ops: add readb/writeb helpers
  ASoC: SOF: ops: add snd_sof_dsp_updateb() helper
  ASoC: SOF: Intel: hda-dsp: use SOF helpers for consistency
  ASoC: SOF: Intel: hda-dai: start removing the use of
    runtime->private_data in BE
  ASoC: SOF: Intel: hda-dai: use component_get_drvdata to find hdac_bus
  ASoC: SOF: Intel: hda-dai: remove useless members in hda_pipe_params
  ASoC: SOF: Intel: hda-ctrl: remove useless sleep
  ASoC: SOF: Intel: hda: always do a full reset
  ASoC: SOF: Intel: hda: remove useless check on GCTL
  ASoC: SOF: Intel: hda-stream: use SOF helpers for consistency
  ASoC: SOF: Intel: hda-stream: rename CL_SD_CTL registers as SD_CTL
  ASoC: SOF: Intel: hda: use SOF helper for consistency
  ASoC: SOF: Intel: hda-stream: use snd_sof_dsp_updateb() helper
  ASoC: SOF: Intel: hda-stream: use readb/writeb for stream registers

 sound/soc/sof/intel/bdw.c            |  6 +---
 sound/soc/sof/intel/byt.c            | 12 ++-----
 sound/soc/sof/intel/hda-common-ops.c |  6 +---
 sound/soc/sof/intel/hda-ctrl.c       | 41 ++++++++--------------
 sound/soc/sof/intel/hda-dai.c        | 31 +++++++----------
 sound/soc/sof/intel/hda-dsp.c        | 12 ++++---
 sound/soc/sof/intel/hda-loader-skl.c | 30 ++++++++--------
 sound/soc/sof/intel/hda-loader.c     |  4 +--
 sound/soc/sof/intel/hda-stream.c     | 47 ++++++++++++-------------
 sound/soc/sof/intel/hda.c            |  5 ++-
 sound/soc/sof/intel/hda.h            | 25 +++++++-------
 sound/soc/sof/intel/pci-tng.c        |  6 +---
 sound/soc/sof/ops.h                  | 51 ++++++++++++++++++++--------
 sound/soc/sof/sof-priv.h             |  4 +++
 14 files changed, 136 insertions(+), 144 deletions(-)

--
2.34.1
parents 94e19f49 3d824ceb
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -575,11 +575,7 @@ static struct snd_sof_dsp_ops sof_bdw_ops = {
	.run            = bdw_run,
	.reset          = bdw_reset,

	/* Register IO */
	.write		= sof_io_write,
	.read		= sof_io_read,
	.write64	= sof_io_write64,
	.read64		= sof_io_read64,
	/* Register IO uses direct mmio */

	/* Block IO */
	.block_read	= sof_block_read,
+2 −10
Original line number Diff line number Diff line
@@ -225,11 +225,7 @@ static struct snd_sof_dsp_ops sof_byt_ops = {
	.run		= atom_run,
	.reset		= atom_reset,

	/* Register IO */
	.write		= sof_io_write,
	.read		= sof_io_read,
	.write64	= sof_io_write64,
	.read64		= sof_io_read64,
	/* Register IO uses direct mmio */

	/* Block IO */
	.block_read	= sof_block_read,
@@ -304,11 +300,7 @@ static struct snd_sof_dsp_ops sof_cht_ops = {
	.run		= atom_run,
	.reset		= atom_reset,

	/* Register IO */
	.write		= sof_io_write,
	.read		= sof_io_read,
	.write64	= sof_io_write64,
	.read64		= sof_io_read64,
	/* Register IO uses direct mmio */

	/* Block IO */
	.block_read	= sof_block_read,
+1 −5
Original line number Diff line number Diff line
@@ -19,11 +19,7 @@ struct snd_sof_dsp_ops sof_hda_common_ops = {
	.probe		= hda_dsp_probe,
	.remove		= hda_dsp_remove,

	/* Register IO */
	.write		= sof_io_write,
	.read		= sof_io_read,
	.write64	= sof_io_write64,
	.read64		= sof_io_read64,
	/* Register IO uses direct mmio */

	/* Block IO */
	.block_read	= sof_block_read,
+14 −27
Original line number Diff line number Diff line
@@ -182,7 +182,7 @@ int hda_dsp_ctrl_clock_power_gating(struct snd_sof_dev *sdev, bool enable)
	return 0;
}

int hda_dsp_ctrl_init_chip(struct snd_sof_dev *sdev, bool full_reset)
int hda_dsp_ctrl_init_chip(struct snd_sof_dev *sdev)
{
	struct hdac_bus *bus = sof_to_bus(sdev);
#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
@@ -199,7 +199,6 @@ int hda_dsp_ctrl_init_chip(struct snd_sof_dev *sdev, bool full_reset)
#endif
	hda_dsp_ctrl_misc_clock_gating(sdev, false);

	if (full_reset) {
	/* reset HDA controller */
	ret = hda_dsp_ctrl_link_reset(sdev, true);
	if (ret < 0) {
@@ -207,8 +206,6 @@ int hda_dsp_ctrl_init_chip(struct snd_sof_dev *sdev, bool full_reset)
		goto err;
	}

		usleep_range(500, 1000);

	/* exit HDA controller reset */
	ret = hda_dsp_ctrl_link_reset(sdev, false);
	if (ret < 0) {
@@ -216,17 +213,7 @@ int hda_dsp_ctrl_init_chip(struct snd_sof_dev *sdev, bool full_reset)
		goto err;
	}

		usleep_range(1000, 1200);
	}

#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
	/* check to see if controller is ready */
	if (!snd_hdac_chip_readb(bus, GCTL)) {
		dev_dbg(bus->dev, "controller not ready!\n");
		ret = -EBUSY;
		goto err;
	}

	/* Accept unsolicited responses */
	snd_hdac_chip_updatel(bus, GCTL, AZX_GCTL_UNSOL, AZX_GCTL_UNSOL);

@@ -247,7 +234,7 @@ int hda_dsp_ctrl_init_chip(struct snd_sof_dev *sdev, bool full_reset)
	list_for_each_entry(stream, &bus->stream_list, list) {
		sd_offset = SOF_STREAM_SD_OFFSET(stream);
		snd_sof_dsp_write(sdev, HDA_DSP_HDA_BAR,
				  sd_offset + SOF_HDA_ADSP_REG_CL_SD_STS,
				  sd_offset + SOF_HDA_ADSP_REG_SD_STS,
				  SOF_HDA_CL_DMA_SD_INT_MASK);
	}

@@ -313,7 +300,7 @@ void hda_dsp_ctrl_stop_chip(struct snd_sof_dev *sdev)
		sd_offset = SOF_STREAM_SD_OFFSET(stream);
		snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR,
					sd_offset +
					SOF_HDA_ADSP_REG_CL_SD_CTL,
					SOF_HDA_ADSP_REG_SD_CTL,
					SOF_HDA_CL_DMA_SD_INT_MASK,
					0);
	}
@@ -331,7 +318,7 @@ void hda_dsp_ctrl_stop_chip(struct snd_sof_dev *sdev)
	list_for_each_entry(stream, &bus->stream_list, list) {
		sd_offset = SOF_STREAM_SD_OFFSET(stream);
		snd_sof_dsp_write(sdev, HDA_DSP_HDA_BAR,
				  sd_offset + SOF_HDA_ADSP_REG_CL_SD_STS,
				  sd_offset + SOF_HDA_ADSP_REG_SD_STS,
				  SOF_HDA_CL_DMA_SD_INT_MASK);
	}

+13 −18
Original line number Diff line number Diff line
@@ -32,11 +32,8 @@ MODULE_PARM_DESC(sof_use_tplg_nhlt, "SOF topology nhlt override");
struct hda_pipe_params {
	u32 ch;
	u32 s_freq;
	u32 s_fmt;
	u8 linktype;
	snd_pcm_format_t format;
	int link_index;
	int stream;
	unsigned int link_bps;
};

@@ -138,12 +135,12 @@ hda_link_stream_assign(struct hdac_bus *bus,
}

static int hda_link_dma_cleanup(struct snd_pcm_substream *substream,
				struct hdac_stream *hstream,
				struct hdac_ext_stream *hext_stream,
				struct snd_soc_dai *cpu_dai,
				struct snd_soc_dai *codec_dai,
				bool trigger_suspend_stop)
{
	struct hdac_ext_stream *hext_stream = snd_soc_dai_get_dma_data(cpu_dai, substream);
	struct hdac_stream *hstream = &hext_stream->hstream;
	struct hdac_bus *bus = hstream->bus;
	struct sof_intel_hda_stream *hda_stream;
	struct hdac_ext_link *hlink;
@@ -207,14 +204,17 @@ static int hda_link_dma_params(struct hdac_ext_stream *hext_stream,
static int hda_link_dma_hw_params(struct snd_pcm_substream *substream,
				  struct snd_pcm_hw_params *params)
{
	struct hdac_stream *hstream = substream->runtime->private_data;
	struct hdac_ext_stream *hext_stream;
	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
	struct hda_pipe_params p_params = {0};
	struct hdac_bus *bus = hstream->bus;
	struct hdac_ext_stream *hext_stream;
	struct hdac_ext_link *hlink;
	struct snd_sof_dev *sdev;
	struct hdac_bus *bus;

	sdev = snd_soc_component_get_drvdata(cpu_dai->component);
	bus = sof_to_bus(sdev);

	hext_stream = snd_soc_dai_get_dma_data(cpu_dai, substream);
	if (!hext_stream) {
@@ -232,10 +232,8 @@ static int hda_link_dma_hw_params(struct snd_pcm_substream *substream,
	/* set the hdac_stream in the codec dai */
	snd_soc_dai_set_stream(codec_dai, hdac_stream(hext_stream), substream->stream);

	p_params.s_fmt = snd_pcm_format_width(params_format(params));
	p_params.ch = params_channels(params);
	p_params.s_freq = params_rate(params);
	p_params.stream = substream->stream;
	p_params.link_index = hlink->index;
	p_params.format = params_format(params);

@@ -257,7 +255,6 @@ static int hda_link_dma_prepare(struct snd_pcm_substream *substream)

static int hda_link_dma_trigger(struct snd_pcm_substream *substream, int cmd)
{
	struct hdac_stream *hstream = substream->runtime->private_data;
	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
@@ -274,7 +271,7 @@ static int hda_link_dma_trigger(struct snd_pcm_substream *substream, int cmd)
		break;
	case SNDRV_PCM_TRIGGER_SUSPEND:
	case SNDRV_PCM_TRIGGER_STOP:
		ret = hda_link_dma_cleanup(substream, hstream, cpu_dai, codec_dai, true);
		ret = hda_link_dma_cleanup(substream, hext_stream, cpu_dai, codec_dai, true);
		if (ret < 0)
			return ret;

@@ -291,7 +288,6 @@ static int hda_link_dma_trigger(struct snd_pcm_substream *substream, int cmd)

static int hda_link_dma_hw_free(struct snd_pcm_substream *substream)
{
	struct hdac_stream *hstream = substream->runtime->private_data;
	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
@@ -301,7 +297,7 @@ static int hda_link_dma_hw_free(struct snd_pcm_substream *substream)
	if (!hext_stream)
		return 0;

	return hda_link_dma_cleanup(substream, hstream, cpu_dai, codec_dai, false);
	return hda_link_dma_cleanup(substream, hext_stream, cpu_dai, codec_dai, false);
}

static int hda_dai_widget_update(struct snd_soc_dapm_widget *w,
@@ -458,14 +454,12 @@ static int ipc4_hda_dai_trigger(struct snd_pcm_substream *substream,
	struct snd_sof_widget *swidget;
	struct snd_soc_dapm_widget *w;
	struct snd_soc_dai *codec_dai;
	struct hdac_stream *hstream;
	struct snd_soc_dai *cpu_dai;
	int ret;

	dev_dbg(dai->dev, "cmd=%d dai %s direction %d\n", cmd,
		dai->name, substream->stream);

	hstream = substream->runtime->private_data;
	rtd = asoc_substream_to_rtd(substream);
	cpu_dai = asoc_rtd_to_cpu(rtd, 0);
	codec_dai = asoc_rtd_to_codec(rtd, 0);
@@ -500,7 +494,7 @@ static int ipc4_hda_dai_trigger(struct snd_pcm_substream *substream,

		pipeline->state = SOF_IPC4_PIPE_RESET;

		ret = hda_link_dma_cleanup(substream, hstream, cpu_dai, codec_dai, false);
		ret = hda_link_dma_cleanup(substream, hext_stream, cpu_dai, codec_dai, false);
		if (ret < 0) {
			dev_err(sdev->dev, "%s: failed to clean up link DMA\n", __func__);
			return ret;
@@ -575,7 +569,8 @@ static int hda_dai_suspend(struct hdac_bus *bus)
			cpu_dai = asoc_rtd_to_cpu(rtd, 0);
			codec_dai = asoc_rtd_to_codec(rtd, 0);

			ret = hda_link_dma_cleanup(hext_stream->link_substream, s,
			ret = hda_link_dma_cleanup(hext_stream->link_substream,
						   hext_stream,
						   cpu_dai, codec_dai, false);
			if (ret < 0)
				return ret;
Loading