Unverified Commit 7be10cef authored by Mark Brown's avatar Mark Brown
Browse files

ASoC: soc-pcm: tidyup soc_pcm_pointer()'s delay update method

Merge series from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:

	Current soc_pcm_pointer() is checking runtime->delay,
	but it might be updated silently by component's .point callback.
	It is strange and difficult to find/know the issue.  This patch
	adds .delay callback for component, and solve the issue.
parents 679de7b6 dd894f4c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -148,6 +148,8 @@ struct snd_soc_component_driver {
		    struct vm_area_struct *vma);
	int (*ack)(struct snd_soc_component *component,
		   struct snd_pcm_substream *substream);
	snd_pcm_sframes_t (*delay)(struct snd_soc_component *component,
				   struct snd_pcm_substream *substream);

	const struct snd_compress_ops *compress_ops;

@@ -505,5 +507,7 @@ int snd_soc_pcm_component_pm_runtime_get(struct snd_soc_pcm_runtime *rtd,
void snd_soc_pcm_component_pm_runtime_put(struct snd_soc_pcm_runtime *rtd,
					  void *stream, int rollback);
int snd_soc_pcm_component_ack(struct snd_pcm_substream *substream);
void snd_soc_pcm_component_delay(struct snd_pcm_substream *substream,
				 snd_pcm_sframes_t *cpu_delay, snd_pcm_sframes_t *codec_delay);

#endif /* __SOC_COMPONENT_H */
+2 −2
Original line number Diff line number Diff line
@@ -208,8 +208,6 @@ int snd_soc_dai_startup(struct snd_soc_dai *dai,
			struct snd_pcm_substream *substream);
void snd_soc_dai_shutdown(struct snd_soc_dai *dai,
			  struct snd_pcm_substream *substream, int rollback);
snd_pcm_sframes_t snd_soc_dai_delay(struct snd_soc_dai *dai,
				    struct snd_pcm_substream *substream);
void snd_soc_dai_suspend(struct snd_soc_dai *dai);
void snd_soc_dai_resume(struct snd_soc_dai *dai);
int snd_soc_dai_compress_new(struct snd_soc_dai *dai,
@@ -238,6 +236,8 @@ int snd_soc_pcm_dai_trigger(struct snd_pcm_substream *substream, int cmd,
			    int rollback);
int snd_soc_pcm_dai_bespoke_trigger(struct snd_pcm_substream *substream,
				    int cmd);
void snd_soc_pcm_dai_delay(struct snd_pcm_substream *substream,
			   snd_pcm_sframes_t *cpu_delay, snd_pcm_sframes_t *codec_delay);

int snd_soc_dai_compr_startup(struct snd_soc_dai *dai,
			      struct snd_compr_stream *cstream);
+14 −1
Original line number Diff line number Diff line
@@ -1003,6 +1003,7 @@ static snd_pcm_uframes_t acp_dma_pointer(struct snd_soc_component *component,

	struct snd_pcm_runtime *runtime = substream->runtime;
	struct audio_substream_data *rtd = runtime->private_data;
	struct audio_drv_data *adata = dev_get_drvdata(component->dev);

	if (!rtd)
		return -EINVAL;
@@ -1023,7 +1024,7 @@ static snd_pcm_uframes_t acp_dma_pointer(struct snd_soc_component *component,
		}
		if (bytescount > 0) {
			delay = do_div(bytescount, period_bytes);
			runtime->delay = bytes_to_frames(runtime, delay);
			adata->delay += bytes_to_frames(runtime, delay);
		}
	} else {
		buffersize = frames_to_bytes(runtime, runtime->buffer_size);
@@ -1035,6 +1036,17 @@ static snd_pcm_uframes_t acp_dma_pointer(struct snd_soc_component *component,
	return bytes_to_frames(runtime, pos);
}

static snd_pcm_sframes_t acp_dma_delay(struct snd_soc_component *component,
				       struct snd_pcm_substream *substream)
{
	struct audio_drv_data *adata = dev_get_drvdata(component->dev);
	snd_pcm_sframes_t delay = adata->delay;

	adata->delay = 0;

	return delay;
}

static int acp_dma_prepare(struct snd_soc_component *component,
			   struct snd_pcm_substream *substream)
{
@@ -1198,6 +1210,7 @@ static const struct snd_soc_component_driver acp_asoc_platform = {
	.hw_params	= acp_dma_hw_params,
	.trigger	= acp_dma_trigger,
	.pointer	= acp_dma_pointer,
	.delay		= acp_dma_delay,
	.prepare	= acp_dma_prepare,
	.pcm_construct	= acp_dma_new,
};
+1 −0
Original line number Diff line number Diff line
@@ -151,6 +151,7 @@ struct audio_drv_data {
	struct snd_pcm_substream *capture_i2sbt_stream;
	void __iomem *acp_mmio;
	u32 asic_type;
	snd_pcm_sframes_t delay;
};

/*
+13 −1
Original line number Diff line number Diff line
@@ -653,10 +653,21 @@ static snd_pcm_uframes_t sst_soc_pointer(struct snd_soc_component *component,
		dev_err(rtd->dev, "sst: error code = %d\n", ret_val);
		return ret_val;
	}
	substream->runtime->delay = str_info->pcm_delay;
	return str_info->buffer_ptr;
}

static snd_pcm_sframes_t sst_soc_delay(struct snd_soc_component *component,
				       struct snd_pcm_substream *substream)
{
	struct sst_runtime_stream *stream = substream->runtime->private_data;
	struct pcm_stream_info *str_info = &stream->stream_info;

	if (sst_get_stream_status(stream) == SST_PLATFORM_INIT)
		return 0;

	return str_info->pcm_delay;
}

static int sst_soc_pcm_new(struct snd_soc_component *component,
			   struct snd_soc_pcm_runtime *rtd)
{
@@ -695,6 +706,7 @@ static const struct snd_soc_component_driver sst_soc_platform_drv = {
	.open		= sst_soc_open,
	.trigger	= sst_soc_trigger,
	.pointer	= sst_soc_pointer,
	.delay		= sst_soc_delay,
	.compress_ops	= &sst_platform_compress_ops,
	.pcm_construct	= sst_soc_pcm_new,
};
Loading