Commit 1c91d77e authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: sof: pcm: remove snd_pcm_ops

snd_pcm_ops is no longer needed.
Let's use component driver callback.
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/8736gbaf07.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 6702eed8
...@@ -19,12 +19,11 @@ ...@@ -19,12 +19,11 @@
#define DRV_NAME "sof-audio-component" #define DRV_NAME "sof-audio-component"
/* Create DMA buffer page table for DSP */ /* Create DMA buffer page table for DSP */
static int create_page_table(struct snd_pcm_substream *substream, static int create_page_table(struct snd_soc_component *component,
struct snd_pcm_substream *substream,
unsigned char *dma_area, size_t size) unsigned char *dma_area, size_t size)
{ {
struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_component *component =
snd_soc_rtdcom_lookup(rtd, DRV_NAME);
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component); struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
struct snd_sof_pcm *spcm; struct snd_sof_pcm *spcm;
struct snd_dma_buffer *dmab = snd_pcm_get_dma_buf(substream); struct snd_dma_buffer *dmab = snd_pcm_get_dma_buf(substream);
...@@ -95,13 +94,12 @@ void snd_sof_pcm_period_elapsed(struct snd_pcm_substream *substream) ...@@ -95,13 +94,12 @@ void snd_sof_pcm_period_elapsed(struct snd_pcm_substream *substream)
EXPORT_SYMBOL(snd_sof_pcm_period_elapsed); EXPORT_SYMBOL(snd_sof_pcm_period_elapsed);
/* this may get called several times by oss emulation */ /* this may get called several times by oss emulation */
static int sof_pcm_hw_params(struct snd_pcm_substream *substream, static int sof_pcm_hw_params(struct snd_soc_component *component,
struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params) struct snd_pcm_hw_params *params)
{ {
struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_soc_component *component =
snd_soc_rtdcom_lookup(rtd, DRV_NAME);
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component); struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
struct snd_sof_pcm *spcm; struct snd_sof_pcm *spcm;
struct sof_ipc_pcm_params pcm; struct sof_ipc_pcm_params pcm;
...@@ -135,7 +133,7 @@ static int sof_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -135,7 +133,7 @@ static int sof_pcm_hw_params(struct snd_pcm_substream *substream,
* ret == 0 means the buffer is not changed * ret == 0 means the buffer is not changed
* so no need to regenerate the page table * so no need to regenerate the page table
*/ */
ret = create_page_table(substream, runtime->dma_area, ret = create_page_table(component, substream, runtime->dma_area,
runtime->dma_bytes); runtime->dma_bytes);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -237,11 +235,10 @@ static int sof_pcm_dsp_pcm_free(struct snd_pcm_substream *substream, ...@@ -237,11 +235,10 @@ static int sof_pcm_dsp_pcm_free(struct snd_pcm_substream *substream,
return ret; return ret;
} }
static int sof_pcm_hw_free(struct snd_pcm_substream *substream) static int sof_pcm_hw_free(struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{ {
struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_component *component =
snd_soc_rtdcom_lookup(rtd, DRV_NAME);
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component); struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
struct snd_sof_pcm *spcm; struct snd_sof_pcm *spcm;
int ret, err = 0; int ret, err = 0;
...@@ -276,11 +273,10 @@ static int sof_pcm_hw_free(struct snd_pcm_substream *substream) ...@@ -276,11 +273,10 @@ static int sof_pcm_hw_free(struct snd_pcm_substream *substream)
return err; return err;
} }
static int sof_pcm_prepare(struct snd_pcm_substream *substream) static int sof_pcm_prepare(struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{ {
struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_component *component =
snd_soc_rtdcom_lookup(rtd, DRV_NAME);
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component); struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
struct snd_sof_pcm *spcm; struct snd_sof_pcm *spcm;
int ret; int ret;
...@@ -300,7 +296,8 @@ static int sof_pcm_prepare(struct snd_pcm_substream *substream) ...@@ -300,7 +296,8 @@ static int sof_pcm_prepare(struct snd_pcm_substream *substream)
substream->stream); substream->stream);
/* set hw_params */ /* set hw_params */
ret = sof_pcm_hw_params(substream, &spcm->params[substream->stream]); ret = sof_pcm_hw_params(component,
substream, &spcm->params[substream->stream]);
if (ret < 0) { if (ret < 0) {
dev_err(sdev->dev, "error: set pcm hw_params after resume\n"); dev_err(sdev->dev, "error: set pcm hw_params after resume\n");
return ret; return ret;
...@@ -313,11 +310,10 @@ static int sof_pcm_prepare(struct snd_pcm_substream *substream) ...@@ -313,11 +310,10 @@ static int sof_pcm_prepare(struct snd_pcm_substream *substream)
* FE dai link trigger actions are always executed in non-atomic context because * FE dai link trigger actions are always executed in non-atomic context because
* they involve IPC's. * they involve IPC's.
*/ */
static int sof_pcm_trigger(struct snd_pcm_substream *substream, int cmd) static int sof_pcm_trigger(struct snd_soc_component *component,
struct snd_pcm_substream *substream, int cmd)
{ {
struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_component *component =
snd_soc_rtdcom_lookup(rtd, DRV_NAME);
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component); struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
struct snd_sof_pcm *spcm; struct snd_sof_pcm *spcm;
struct sof_ipc_stream stream; struct sof_ipc_stream stream;
...@@ -351,7 +347,7 @@ static int sof_pcm_trigger(struct snd_pcm_substream *substream, int cmd) ...@@ -351,7 +347,7 @@ static int sof_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
break; break;
case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_RESUME:
/* set up hw_params */ /* set up hw_params */
ret = sof_pcm_prepare(substream); ret = sof_pcm_prepare(component, substream);
if (ret < 0) { if (ret < 0) {
dev_err(sdev->dev, dev_err(sdev->dev,
"error: failed to set up hw_params upon resume\n"); "error: failed to set up hw_params upon resume\n");
...@@ -395,11 +391,10 @@ static int sof_pcm_trigger(struct snd_pcm_substream *substream, int cmd) ...@@ -395,11 +391,10 @@ static int sof_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
return ret; return ret;
} }
static snd_pcm_uframes_t sof_pcm_pointer(struct snd_pcm_substream *substream) static snd_pcm_uframes_t sof_pcm_pointer(struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{ {
struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_component *component =
snd_soc_rtdcom_lookup(rtd, DRV_NAME);
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component); struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
struct snd_sof_pcm *spcm; struct snd_sof_pcm *spcm;
snd_pcm_uframes_t host, dai; snd_pcm_uframes_t host, dai;
...@@ -428,12 +423,22 @@ static snd_pcm_uframes_t sof_pcm_pointer(struct snd_pcm_substream *substream) ...@@ -428,12 +423,22 @@ static snd_pcm_uframes_t sof_pcm_pointer(struct snd_pcm_substream *substream)
return host; return host;
} }
static int sof_pcm_open(struct snd_pcm_substream *substream) #ifdef CONFIG_SND_DMA_SGBUF
static struct page *sof_pcm_page(struct snd_soc_component *component,
struct snd_pcm_substream *substream,
unsigned long offset)
{
return snd_pcm_sgbuf_ops_page(substream, offset);
}
#else
#define sof_pcm_page NULL
#endif /* CONFIG_SND_DMA_SGBUF */
static int sof_pcm_open(struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{ {
struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_soc_component *component =
snd_soc_rtdcom_lookup(rtd, DRV_NAME);
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component); struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
struct snd_sof_pcm *spcm; struct snd_sof_pcm *spcm;
struct snd_soc_tplg_stream_caps *caps; struct snd_soc_tplg_stream_caps *caps;
...@@ -505,11 +510,10 @@ static int sof_pcm_open(struct snd_pcm_substream *substream) ...@@ -505,11 +510,10 @@ static int sof_pcm_open(struct snd_pcm_substream *substream)
return ret; return ret;
} }
static int sof_pcm_close(struct snd_pcm_substream *substream) static int sof_pcm_close(struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{ {
struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_component *component =
snd_soc_rtdcom_lookup(rtd, DRV_NAME);
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component); struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
struct snd_sof_pcm *spcm; struct snd_sof_pcm *spcm;
int err; int err;
...@@ -538,27 +542,14 @@ static int sof_pcm_close(struct snd_pcm_substream *substream) ...@@ -538,27 +542,14 @@ static int sof_pcm_close(struct snd_pcm_substream *substream)
return 0; return 0;
} }
static struct snd_pcm_ops sof_pcm_ops = {
.open = sof_pcm_open,
.close = sof_pcm_close,
.ioctl = snd_pcm_lib_ioctl,
.hw_params = sof_pcm_hw_params,
.prepare = sof_pcm_prepare,
.hw_free = sof_pcm_hw_free,
.trigger = sof_pcm_trigger,
.pointer = sof_pcm_pointer,
.page = snd_pcm_sgbuf_ops_page,
};
/* /*
* Pre-allocate playback/capture audio buffer pages. * Pre-allocate playback/capture audio buffer pages.
* no need to explicitly release memory preallocated by sof_pcm_new in pcm_free * no need to explicitly release memory preallocated by sof_pcm_new in pcm_free
* snd_pcm_lib_preallocate_free_for_all() is called by the core. * snd_pcm_lib_preallocate_free_for_all() is called by the core.
*/ */
static int sof_pcm_new(struct snd_soc_pcm_runtime *rtd) static int sof_pcm_new(struct snd_soc_component *component,
struct snd_soc_pcm_runtime *rtd)
{ {
struct snd_soc_component *component =
snd_soc_rtdcom_lookup(rtd, DRV_NAME);
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component); struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
struct snd_sof_pcm *spcm; struct snd_sof_pcm *spcm;
struct snd_pcm *pcm = rtd->pcm; struct snd_pcm *pcm = rtd->pcm;
...@@ -752,11 +743,20 @@ void snd_sof_new_platform_drv(struct snd_sof_dev *sdev) ...@@ -752,11 +743,20 @@ void snd_sof_new_platform_drv(struct snd_sof_dev *sdev)
pd->name = "sof-audio-component"; pd->name = "sof-audio-component";
pd->probe = sof_pcm_probe; pd->probe = sof_pcm_probe;
pd->remove = sof_pcm_remove; pd->remove = sof_pcm_remove;
pd->ops = &sof_pcm_ops; pd->open = sof_pcm_open;
pd->close = sof_pcm_close;
pd->ioctl = snd_soc_pcm_lib_ioctl;
pd->hw_params = sof_pcm_hw_params;
pd->prepare = sof_pcm_prepare;
pd->hw_free = sof_pcm_hw_free;
pd->trigger = sof_pcm_trigger;
pd->pointer = sof_pcm_pointer;
pd->page = sof_pcm_page;
#if IS_ENABLED(CONFIG_SND_SOC_SOF_COMPRESS) #if IS_ENABLED(CONFIG_SND_SOC_SOF_COMPRESS)
pd->compr_ops = &sof_compressed_ops; pd->compr_ops = &sof_compressed_ops;
#endif #endif
pd->pcm_new = sof_pcm_new; pd->pcm_construct = sof_pcm_new;
pd->ignore_machine = drv_name; pd->ignore_machine = drv_name;
pd->be_hw_params_fixup = sof_pcm_dai_link_fixup; pd->be_hw_params_fixup = sof_pcm_dai_link_fixup;
pd->be_pcm_base = SOF_BE_PCM_BASE; pd->be_pcm_base = SOF_BE_PCM_BASE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment