Unverified Commit 2c7c9630 authored by Takashi Iwai's avatar Takashi Iwai Committed by Mark Brown
Browse files

ASoC: siu_pcm: Use managed buffer allocation



Clean up the driver with the new managed buffer allocation API.
The hw_params and hw_free callbacks became superfluous (the rest were
only debug prints) and got dropped.

Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20191210142614.19405-10-tiwai@suse.de


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 55df47f2
Loading
Loading
Loading
Loading
+1 −38
Original line number Diff line number Diff line
@@ -281,41 +281,6 @@ static int siu_pcm_stmread_stop(struct siu_port *port_info)
	return 0;
}

static int siu_pcm_hw_params(struct snd_soc_component *component,
			     struct snd_pcm_substream *ss,
			     struct snd_pcm_hw_params *hw_params)
{
	struct siu_info *info = siu_i2s_data;
	struct device *dev = ss->pcm->card->dev;
	int ret;

	dev_dbg(dev, "%s: port=%d\n", __func__, info->port_id);

	ret = snd_pcm_lib_malloc_pages(ss, params_buffer_bytes(hw_params));
	if (ret < 0)
		dev_err(dev, "snd_pcm_lib_malloc_pages() failed\n");

	return ret;
}

static int siu_pcm_hw_free(struct snd_soc_component *component,
			   struct snd_pcm_substream *ss)
{
	struct siu_info *info = siu_i2s_data;
	struct siu_port	*port_info = siu_port_info(ss);
	struct device *dev = ss->pcm->card->dev;
	struct siu_stream *siu_stream;

	if (ss->stream == SNDRV_PCM_STREAM_PLAYBACK)
		siu_stream = &port_info->playback;
	else
		siu_stream = &port_info->capture;

	dev_dbg(dev, "%s: port=%d\n", __func__, info->port_id);

	return snd_pcm_lib_free_pages(ss);
}

static bool filter(struct dma_chan *chan, void *slave)
{
	struct sh_dmae_slave *param = slave;
@@ -548,7 +513,7 @@ static int siu_pcm_new(struct snd_soc_component *component,
		if (ret < 0)
			return ret;

		snd_pcm_lib_preallocate_pages_for_all(pcm,
		snd_pcm_set_managed_buffer_all(pcm,
				SNDRV_DMA_TYPE_DEV, card->dev,
				SIU_BUFFER_BYTES_MAX, SIU_BUFFER_BYTES_MAX);

@@ -584,8 +549,6 @@ struct const snd_soc_component_driver siu_component = {
	.open		= siu_pcm_open,
	.close		= siu_pcm_close,
	.ioctl		= snd_soc_pcm_lib_ioctl,
	.hw_params	= siu_pcm_hw_params,
	.hw_free	= siu_pcm_hw_free,
	.prepare	= siu_pcm_prepare,
	.trigger	= siu_pcm_trigger,
	.pointer	= siu_pcm_pointer_dma,