Add DSP topology management for SKL
Subsystems (3)
v4 cover Add DSP topology management for SKL
The SKL driver does not code DSP topology in driver. With this series the ASoC topology framework is used to parse the topology information to create widgets, controls and route map for the FW topology.
It adds routines for SKL DSP module configuration, compute resources for modules, initialize and bind the pipe modules. It uses the SKL IPC library added earlier to send IPC for initialize the module, bind/unbind modules.
Last patch in this series removes the unused dais.
changes in v4:
- rename resource allocators and add resource deallocator
- remove bind_unbind and add in callng fn
- fix some 80char warns
- some minor cleanup at odd places
changes in v3:
- removeno/less logic wrappers
- remove most of debug prints, few kept
- use asoc widget list macros instead of using list_for_xxx
- fix one instance of no empty line between two functions
- fix tplg event ID > 255
- add more comments for locking, usage of widget list and few other places, fixed few error prints, add file name etc
changes in v2:
- add more explanation in changelog and code
- add explanation of MCPS
- fix whitespace issues
- remove skl widget check on event handler as it is redundant
- add switch for depth
- add else for direction based code
- remove cast for NHLT blob query
- make debug prints to error
- remove dump info
- clean some debug prints
Jeeja KP (5):
ASoC: Intel: Skylake: Add pipe and modules handlers
ASoC: Intel: Skylake: Add module configuration helpers
ASoC: Intel: Skylake: Initialize and load DSP controls
ASoC: Intel: Skylake: Add DSP support and enable it
ASoC: Intel: Skylake: Initialize NHLT table
Vinod Koul (3):
ASoC: Intel: Skylake: add DSP platform widget event handlers
ASoC: Intel: Skylake: Add FE and BE hw_params handling
ASoC: Intel: Skylake: Add topology core init and handlers
sound/soc/intel/Kconfig | 1 + sound/soc/intel/skylake/Makefile | 3 +- sound/soc/intel/skylake/skl-pcm.c | 141 ++- sound/soc/intel/skylake/skl-topology.c | 1238 ++++++++++++++++++++++++++ sound/soc/intel/skylake/skl-topology.h | 28 + sound/soc/intel/skylake/skl-tplg-interface.h | 80 ++ sound/soc/intel/skylake/skl.c | 29 +- sound/soc/intel/skylake/skl.h | 11 + 8 files changed, 1495 insertions(+), 36 deletions(-) create mode 100644 sound/soc/intel/skylake/skl-topology.c
Signature · 1 line
2.4.3
PATCH v4 1/8 ASoC: Intel: Skylake: Add pipe and modules handlers
From: Jeeja KP <[email protected]>
SKL driver needs to instantiate pipelines and modules in the DSP. The topology in the DSP is modelled as DAPM graph with a PGA representing a module instance and mixer representing a pipeline for a group of modules along with the mixer itself.
Here we start adding building block for handling these. We add resource checks (memory/compute) for pipelines, find the modules in a pipeline, init modules in a pipe and lastly bind/unbind modules in a pipe These will be used by pipe event handlers in subsequent patches
--- sound/soc/intel/skylake/Makefile | 3 +- sound/soc/intel/skylake/skl-topology.c | 187 +++++++++++++++++++++++++++++++++ sound/soc/intel/skylake/skl-topology.h | 10 ++ sound/soc/intel/skylake/skl.h | 11 ++ 4 files changed, 210 insertions(+), 1 deletion(-) create mode 100644 sound/soc/intel/skylake/skl-topology.c
sound/soc/intel/skylake/Makefile +2 -1
@@ -1,4 +1,5 @@ -snd-soc-skl-objs := skl.o skl-pcm.o skl-nhlt.o skl-messages.o +snd-soc-skl-objs := skl.o skl-pcm.o skl-nhlt.o skl-messages.o \ +skl-topology.o obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl.o
sound/soc/intel/skylake/skl-topology.c new file +187 -0
187 lines not on this page · raw message
sound/soc/intel/skylake/skl-topology.h +10 -0
@@ -263,6 +263,16 @@ struct skl_module_cfg {struct skl_specific_cfg formats_config; }; +struct skl_pipeline { +struct skl_pipe *pipe; +struct list_head node; +}; + +struct skl_dapm_path_list { +struct snd_soc_dapm_path *dapm_path; +struct list_head node; +}; +int skl_create_pipeline (struct skl_sst *ctx,struct skl_pipe *pipe);int skl_run_pipe (struct skl_sst *ctx,struct skl_pipe *pipe);
sound/soc/intel/skylake/skl.h +11 -0
@@ -48,6 +48,13 @@#define AZX_REG_VS_SDXEFIFOS_XBASE 0x1094#define AZX_REG_VS_SDXEFIFOS_XINTERVAL 0x20 +struct skl_dsp_resource { +u32 max_mcps; +u32 max_mem; +u32 mcps; +u32 mem; +}; +struct skl {struct hdac_ext_bus ebus;struct pci_dev *pci;
@@ -57,6 +64,10 @@ struct skl {void __iomem *nhlt;/* nhlt ptr */ struct skl_sst *skl_sst;/* sst skl ctx */ + +struct skl_dsp_resource resource; +struct list_head ppl_list; +struct list_head dapm_path_list; };#define skl_to_ebus (s) (&(s)->ebus)
Signature · 1 line
2.4.3
Mark Brown
maintainerApplied "ASoC: Intel: Skylake: Add pipe and modules handlers" to the asoc tree
The patch
ASoC: Intel: Skylake: Add pipe and modules handlers
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
e4e2d2f45284f620eeb9eea25570838b2a42c968Mon Sep 17 00:00:00 2001
From: Jeeja KP <[email protected]>
Date: Wed, 7 Oct 2015 11:31:52 +0100
Subject: [PATCH] ASoC: Intel: Skylake: Add pipe and modules handlers
SKL driver needs to instantiate pipelines and modules in the DSP. The topology in the DSP is modelled as DAPM graph with a PGA representing a module instance and mixer representing a pipeline for a group of modules along with the mixer itself.
Here we start adding building block for handling these. We add resource checks (memory/compute) for pipelines, find the modules in a pipeline, init modules in a pipe and lastly bind/unbind modules in a pipe These will be used by pipe event handlers in subsequent patches
--- sound/soc/intel/skylake/Makefile | 3 +- sound/soc/intel/skylake/skl-topology.c | 187 +++++++++++++++++++++++++++++++++ sound/soc/intel/skylake/skl-topology.h | 10 ++ sound/soc/intel/skylake/skl.h | 11 ++ 4 files changed, 210 insertions(+), 1 deletion(-) create mode 100644 sound/soc/intel/skylake/skl-topology.c
sound/soc/intel/skylake/Makefile +2 -1
@@ -1,4 +1,5 @@ -snd-soc-skl-objs := skl.o skl-pcm.o skl-nhlt.o skl-messages.o +snd-soc-skl-objs := skl.o skl-pcm.o skl-nhlt.o skl-messages.o \ +skl-topology.o obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl.o
sound/soc/intel/skylake/skl-topology.c new file +187 -0
187 lines not on this page · raw message
sound/soc/intel/skylake/skl-topology.h +10 -0
@@ -263,6 +263,16 @@ struct skl_module_cfg {struct skl_specific_cfg formats_config; }; +struct skl_pipeline { +struct skl_pipe *pipe; +struct list_head node; +}; + +struct skl_dapm_path_list { +struct snd_soc_dapm_path *dapm_path; +struct list_head node; +}; +int skl_create_pipeline (struct skl_sst *ctx,struct skl_pipe *pipe);int skl_run_pipe (struct skl_sst *ctx,struct skl_pipe *pipe);
sound/soc/intel/skylake/skl.h +11 -0
@@ -48,6 +48,13 @@#define AZX_REG_VS_SDXEFIFOS_XBASE 0x1094#define AZX_REG_VS_SDXEFIFOS_XINTERVAL 0x20 +struct skl_dsp_resource { +u32 max_mcps; +u32 max_mem; +u32 mcps; +u32 mem; +}; +struct skl {struct hdac_ext_bus ebus;struct pci_dev *pci;
@@ -57,6 +64,10 @@ struct skl {void __iomem *nhlt;/* nhlt ptr */ struct skl_sst *skl_sst;/* sst skl ctx */ + +struct skl_dsp_resource resource; +struct list_head ppl_list; +struct list_head dapm_path_list; };#define skl_to_ebus (s) (&(s)->ebus)
Signature · 1 line
2.5.0
PATCH v4 2/8 ASoC: Intel: Skylake: Add module configuration helpers
In reply to Vinod KoulFrom: Jeeja KP <[email protected]>
To configure a module, driver needs to send input and output PCM params for a module in DSP. The FE PCM params come from hw_params ie from user, for a BE they also come from hw_params but from BE-link fixups.
So based on PCM params required driver has to find a converter module (src/updown/format) and then do the conversion and calculate PCM params in these pipelines In this patch we add the helper modules which allow driver to do these calculations.
--- sound/soc/intel/skylake/skl-topology.c | 140 +++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+)
sound/soc/intel/skylake/skl-topology.c +140 -0
@@ -27,6 +27,10 @@#include "skl.h" #include "skl-tplg-interface.h" +#define SKL_CH_FIXUP_MASK (1 << 0) +#define SKL_RATE_FIXUP_MASK (1 << 1) +#define SKL_FMT_FIXUP_MASK (1 << 2) +/* * SKL DSP driver modelling uses only few DAPM widgets so for rest we will * ignore. This helpers checks if the SKL driver handles this widget type
@@ -119,6 +123,137 @@ skl_tplg_free_pipe_mem(struct skl *skl, struct skl_module_cfg *mconfig) skl->resource.mem -= mconfig->pipe->memory_pages; } + +static void skl_dump_mconfig (struct skl_sst *ctx, +struct skl_module_cfg *mcfg) +{ +dev_dbg (ctx->dev,"Dumping config\n" ); +dev_dbg (ctx->dev,"Input Format:\n" ); +dev_dbg (ctx->dev,"channels = %d\n" , mcfg->in_fmt.channels); +dev_dbg (ctx->dev,"s_freq = %d\n" , mcfg->in_fmt.s_freq); +dev_dbg (ctx->dev,"ch_cfg = %d\n" , mcfg->in_fmt.ch_cfg); +dev_dbg (ctx->dev,"valid bit depth = %d\n" , + mcfg->in_fmt.valid_bit_depth); +dev_dbg (ctx->dev,"Output Format:\n" ); +dev_dbg (ctx->dev,"channels = %d\n" , mcfg->out_fmt.channels); +dev_dbg (ctx->dev,"s_freq = %d\n" , mcfg->out_fmt.s_freq); +dev_dbg (ctx->dev,"valid bit depth = %d\n" , + mcfg->out_fmt.valid_bit_depth); +dev_dbg (ctx->dev,"ch_cfg = %d\n" , mcfg->out_fmt.ch_cfg); +} + +static void skl_tplg_update_params (struct skl_module_fmt *fmt, +struct skl_pipe_params *params,int fixup) +{ +if (fixup &SKL_RATE_FIXUP_MASK ) + fmt->s_freq = params->s_freq; +if (fixup &SKL_CH_FIXUP_MASK ) + fmt->channels = params->ch; +if (fixup &SKL_FMT_FIXUP_MASK ) + fmt->valid_bit_depth = params->s_fmt; +} + +/* +* A pipeline may have modules which impact the pcm parameters, like SRC, +* channel converter, format converter. +* We need to calculate the output params by applying the 'fixup' +* Topology will tell driver which type of fixup is to be applied by +* supplying the fixup mask, so based on that we calculate the output +* +* Now In FE the pcm hw_params is source/target format. Same is applicable +* for BE with its hw_params invoked. +* here based on FE, BE pipeline and direction we calculate the input and +* outfix and then apply that for a module +*/ +static void skl_tplg_update_params_fixup (struct skl_module_cfg *m_cfg, +struct skl_pipe_params *params,bool is_fe) +{ +int in_fixup, out_fixup; +struct skl_module_fmt *in_fmt, *out_fmt; + + in_fmt = &m_cfg->in_fmt; + out_fmt = &m_cfg->out_fmt; + +if (params->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { +if (is_fe) { + in_fixup = m_cfg->params_fixup; + out_fixup = (~m_cfg->converter) & + m_cfg->params_fixup; + }else { + out_fixup = m_cfg->params_fixup; + in_fixup = (~m_cfg->converter) & + m_cfg->params_fixup; + } + }else { +if (is_fe) { + out_fixup = m_cfg->params_fixup; + in_fixup = (~m_cfg->converter) & + m_cfg->params_fixup; + }else { + in_fixup = m_cfg->params_fixup; + out_fixup = (~m_cfg->converter) & + m_cfg->params_fixup; + } + } + +skl_tplg_update_params (in_fmt, params, in_fixup); +skl_tplg_update_params (out_fmt, params, out_fixup); +} + +/* +* A module needs input and output buffers, which are dependent upon pcm +* params, so once we have calculate params, we need buffer calculation as +* well. +*/ +static void skl_tplg_update_buffer_size (struct skl_sst *ctx, +struct skl_module_cfg *mcfg) +{ +int multiplier =1 ; + +if (mcfg->m_type ==SKL_MODULE_TYPE_SRCINT ) + multiplier =5 ; + + mcfg->ibs = (mcfg->in_fmt.s_freq /1000 ) * + (mcfg->in_fmt.channels) * + (mcfg->in_fmt.bit_depth >>3 ) * + multiplier; + + mcfg->obs = (mcfg->out_fmt.s_freq /1000 ) * + (mcfg->out_fmt.channels) * + (mcfg->out_fmt.bit_depth >>3 ) * + multiplier; +} + +static void skl_tplg_update_module_params (struct snd_soc_dapm_widget *w, +struct skl_sst *ctx) +{ +struct skl_module_cfg *m_cfg = w->priv; +struct skl_pipe_params *params = m_cfg->pipe->p_params; +int p_conn_type = m_cfg->pipe->conn_type; +bool is_fe; + +if (!m_cfg->params_fixup) +return ; + +dev_dbg (ctx->dev,"Mconfig for widget=%s BEFORE updation\n" , + w->name); + +skl_dump_mconfig (ctx, m_cfg); + +if (p_conn_type ==SKL_PIPE_CONN_TYPE_FE ) + is_fe = true; +else + is_fe = false; + +skl_tplg_update_params_fixup (m_cfg, params, is_fe); +skl_tplg_update_buffer_size (ctx, m_cfg); + +dev_dbg (ctx->dev,"Mconfig for widget=%s AFTER updation\n" , + w->name); + +skl_dump_mconfig (ctx, m_cfg); +} +/* * A pipe can have multiple modules, each of them will be a DAPM widget as * well. While managing a pipeline we need to get the list of all the
@@ -178,6 +313,11 @@ skl_tplg_init_pipe_modules(struct skl *skl, struct skl_pipe *pipe)if (!skl_tplg_alloc_pipe_mcps (skl, mconfig))return -ENOMEM ; +/* +* apply fix/conversion to module params based on +* FE/BE params +*/ +skl_tplg_update_module_params (w, ctx); ret =skl_init_module (ctx, mconfig,NULL );if (ret <0 )return ret;
Signature · 1 line
2.4.3
Mark Brown
maintainerApplied "ASoC: Intel: Skylake: Add module configuration helpers" to the asoc tree
The patch
ASoC: Intel: Skylake: Add module configuration helpers
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
f7590d4f1565b0d609d25113c37b9bea8a13e9f7Mon Sep 17 00:00:00 2001
From: Jeeja KP <[email protected]>
Date: Wed, 7 Oct 2015 11:31:53 +0100
Subject: [PATCH] ASoC: Intel: Skylake: Add module configuration helpers
To configure a module, driver needs to send input and output PCM params for a module in DSP. The FE PCM params come from hw_params ie from user, for a BE they also come from hw_params but from BE-link fixups.
So based on PCM params required driver has to find a converter module (src/updown/format) and then do the conversion and calculate PCM params in these pipelines In this patch we add the helper modules which allow driver to do these calculations.
--- sound/soc/intel/skylake/skl-topology.c | 140 +++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+)
sound/soc/intel/skylake/skl-topology.c +140 -0
@@ -27,6 +27,10 @@#include "skl.h" #include "skl-tplg-interface.h" +#define SKL_CH_FIXUP_MASK (1 << 0) +#define SKL_RATE_FIXUP_MASK (1 << 1) +#define SKL_FMT_FIXUP_MASK (1 << 2) +/* * SKL DSP driver modelling uses only few DAPM widgets so for rest we will * ignore. This helpers checks if the SKL driver handles this widget type
@@ -119,6 +123,137 @@ skl_tplg_free_pipe_mem(struct skl *skl, struct skl_module_cfg *mconfig) skl->resource.mem -= mconfig->pipe->memory_pages; } + +static void skl_dump_mconfig (struct skl_sst *ctx, +struct skl_module_cfg *mcfg) +{ +dev_dbg (ctx->dev,"Dumping config\n" ); +dev_dbg (ctx->dev,"Input Format:\n" ); +dev_dbg (ctx->dev,"channels = %d\n" , mcfg->in_fmt.channels); +dev_dbg (ctx->dev,"s_freq = %d\n" , mcfg->in_fmt.s_freq); +dev_dbg (ctx->dev,"ch_cfg = %d\n" , mcfg->in_fmt.ch_cfg); +dev_dbg (ctx->dev,"valid bit depth = %d\n" , + mcfg->in_fmt.valid_bit_depth); +dev_dbg (ctx->dev,"Output Format:\n" ); +dev_dbg (ctx->dev,"channels = %d\n" , mcfg->out_fmt.channels); +dev_dbg (ctx->dev,"s_freq = %d\n" , mcfg->out_fmt.s_freq); +dev_dbg (ctx->dev,"valid bit depth = %d\n" , + mcfg->out_fmt.valid_bit_depth); +dev_dbg (ctx->dev,"ch_cfg = %d\n" , mcfg->out_fmt.ch_cfg); +} + +static void skl_tplg_update_params (struct skl_module_fmt *fmt, +struct skl_pipe_params *params,int fixup) +{ +if (fixup &SKL_RATE_FIXUP_MASK ) + fmt->s_freq = params->s_freq; +if (fixup &SKL_CH_FIXUP_MASK ) + fmt->channels = params->ch; +if (fixup &SKL_FMT_FIXUP_MASK ) + fmt->valid_bit_depth = params->s_fmt; +} + +/* +* A pipeline may have modules which impact the pcm parameters, like SRC, +* channel converter, format converter. +* We need to calculate the output params by applying the 'fixup' +* Topology will tell driver which type of fixup is to be applied by +* supplying the fixup mask, so based on that we calculate the output +* +* Now In FE the pcm hw_params is source/target format. Same is applicable +* for BE with its hw_params invoked. +* here based on FE, BE pipeline and direction we calculate the input and +* outfix and then apply that for a module +*/ +static void skl_tplg_update_params_fixup (struct skl_module_cfg *m_cfg, +struct skl_pipe_params *params,bool is_fe) +{ +int in_fixup, out_fixup; +struct skl_module_fmt *in_fmt, *out_fmt; + + in_fmt = &m_cfg->in_fmt; + out_fmt = &m_cfg->out_fmt; + +if (params->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { +if (is_fe) { + in_fixup = m_cfg->params_fixup; + out_fixup = (~m_cfg->converter) & + m_cfg->params_fixup; + }else { + out_fixup = m_cfg->params_fixup; + in_fixup = (~m_cfg->converter) & + m_cfg->params_fixup; + } + }else { +if (is_fe) { + out_fixup = m_cfg->params_fixup; + in_fixup = (~m_cfg->converter) & + m_cfg->params_fixup; + }else { + in_fixup = m_cfg->params_fixup; + out_fixup = (~m_cfg->converter) & + m_cfg->params_fixup; + } + } + +skl_tplg_update_params (in_fmt, params, in_fixup); +skl_tplg_update_params (out_fmt, params, out_fixup); +} + +/* +* A module needs input and output buffers, which are dependent upon pcm +* params, so once we have calculate params, we need buffer calculation as +* well. +*/ +static void skl_tplg_update_buffer_size (struct skl_sst *ctx, +struct skl_module_cfg *mcfg) +{ +int multiplier =1 ; + +if (mcfg->m_type ==SKL_MODULE_TYPE_SRCINT ) + multiplier =5 ; + + mcfg->ibs = (mcfg->in_fmt.s_freq /1000 ) * + (mcfg->in_fmt.channels) * + (mcfg->in_fmt.bit_depth >>3 ) * + multiplier; + + mcfg->obs = (mcfg->out_fmt.s_freq /1000 ) * + (mcfg->out_fmt.channels) * + (mcfg->out_fmt.bit_depth >>3 ) * + multiplier; +} + +static void skl_tplg_update_module_params (struct snd_soc_dapm_widget *w, +struct skl_sst *ctx) +{ +struct skl_module_cfg *m_cfg = w->priv; +struct skl_pipe_params *params = m_cfg->pipe->p_params; +int p_conn_type = m_cfg->pipe->conn_type; +bool is_fe; + +if (!m_cfg->params_fixup) +return ; + +dev_dbg (ctx->dev,"Mconfig for widget=%s BEFORE updation\n" , + w->name); + +skl_dump_mconfig (ctx, m_cfg); + +if (p_conn_type ==SKL_PIPE_CONN_TYPE_FE ) + is_fe = true; +else + is_fe = false; + +skl_tplg_update_params_fixup (m_cfg, params, is_fe); +skl_tplg_update_buffer_size (ctx, m_cfg); + +dev_dbg (ctx->dev,"Mconfig for widget=%s AFTER updation\n" , + w->name); + +skl_dump_mconfig (ctx, m_cfg); +} +/* * A pipe can have multiple modules, each of them will be a DAPM widget as * well. While managing a pipeline we need to get the list of all the
@@ -178,6 +313,11 @@ skl_tplg_init_pipe_modules(struct skl *skl, struct skl_pipe *pipe)if (!skl_tplg_alloc_pipe_mcps (skl, mconfig))return -ENOMEM ; +/* +* apply fix/conversion to module params based on +* FE/BE params +*/ +skl_tplg_update_module_params (w, ctx); ret =skl_init_module (ctx, mconfig,NULL );if (ret <0 )return ret;
Signature · 1 line
2.5.0
PATCH v4 3/8 ASoC: Intel: Skylake: add DSP platform widget event handlers
In reply to Vinod KoulThe Skylake driver topology model tries to model the firmware rule for pipeline and module creation.
The creation rule is:
- Create Pipe
- Add modules to Pipe
- Connect the modules (bind)
- Start the pipes
Similarly destroy rule is:
- Stop the pipe
- Disconnect it (unbind)
- Delete the pipe
In driver we use Mixer, as there will always be ONE mixer in a pipeline to model a pipe. The modules in pipe are modelled as PGA widgets. The DAPM sequencing rules (mixer and then PGA) are used to create the sequence DSP expects as depicted above, and then widget handlers for PMU and PMD events help in that.
This patch adds widget event handlers for PRE/POST PMU and PRE/POST PMD event for mixer and pga modules. These event handlers invoke pipeline creation, destroy, module creation, module bind, unbind and pipeline bind unbind
Event handler sequencing is implement to target the DSP FW sequence expectations to enable path from source to sink pipe for Playback/Capture.
--- sound/soc/intel/skylake/skl-topology.c | 448 +++++++++++++++++++++++++++++++++ sound/soc/intel/skylake/skl-topology.h | 7 + 2 files changed, 455 insertions(+)
sound/soc/intel/skylake/skl-topology.c +448 -0
@@ -325,3 +325,451 @@ skl_tplg_init_pipe_modules(struct skl *skl, struct skl_pipe *pipe)return 0 ; } + +/* +* Mixer module represents a pipeline. So in the Pre-PMU event of mixer we +* need create the pipeline. So we do following: +* - check the resources +* - Create the pipeline +* - Initialize the modules in pipeline +* - finally bind all modules together +*/ +static int skl_tplg_mixer_dapm_pre_pmu_event (struct snd_soc_dapm_widget *w, +struct skl *skl) +{ +int ret; +struct skl_module_cfg *mconfig = w->priv; +struct skl_pipe_module *w_module; +struct skl_pipe *s_pipe = mconfig->pipe; +struct skl_module_cfg *src_module =NULL , *dst_module; +struct skl_sst *ctx = skl->skl_sst; + +/* check resource available */ +if (!skl_tplg_alloc_pipe_mcps (skl, mconfig)) +return -EBUSY ; + +if (!skl_tplg_alloc_pipe_mem (skl, mconfig)) +return -ENOMEM ; + +/* +* Create a list of modules for pipe. +* This list contains modules from source to sink +*/ + ret =skl_create_pipeline (ctx, mconfig->pipe); +if (ret <0 ) +return ret; + +/* +* we create a w_list of all widgets in that pipe. This list is not +* freed on PMD event as widgets within a pipe are static. This +* saves us cycles to get widgets in pipe every time. +* +* So if we have already initialized all the widgets of a pipeline +* we skip, so check for list_empty and create the list if empty +*/ +if (list_empty (&s_pipe->w_list)) { + ret =skl_tplg_alloc_pipe_widget (ctx->dev, w, s_pipe); +if (ret <0 ) +return ret; + } + +/* Init all pipe modules from source to sink */ + ret =skl_tplg_init_pipe_modules (skl, s_pipe); +if (ret <0 ) +return ret; + +/* Bind modules from source to sink */ +list_for_each_entry (w_module, &s_pipe->w_list, node) { + dst_module = w_module->w->priv; + +if (src_module ==NULL ) { + src_module = dst_module; +continue ; + } + + ret =skl_bind_modules (ctx, src_module, dst_module); +if (ret <0 ) +return ret; + + src_module = dst_module; + } + +return 0 ; +} + +/* +* A PGA represents a module in a pipeline. So in the Pre-PMU event of PGA +* we need to do following: +* - Bind to sink pipeline +* Since the sink pipes can be running and we don't get mixer event on +* connect for already running mixer, we need to find the sink pipes +* here and bind to them. This way dynamic connect works. +* - Start sink pipeline, if not running +* - Then run current pipe +*/ +static int skl_tplg_pga_dapm_pre_pmu_event (struct snd_soc_dapm_widget *w, +struct skl *skl) +{ +struct snd_soc_dapm_path *p; +struct skl_dapm_path_list *path_list; +struct snd_soc_dapm_widget *source, *sink; +struct skl_module_cfg *src_mconfig, *sink_mconfig; +struct skl_sst *ctx = skl->skl_sst; +int ret =0 ; + + source = w; + src_mconfig = source->priv; + +/* +* find which sink it is connected to, bind with the sink, +* if sink is not started, start sink pipe first, then start +* this pipe +*/ +snd_soc_dapm_widget_for_each_source_path (w, p) { +if (!p->connect) +continue ; + +dev_dbg (ctx->dev,"%s: src widget=%s\n" , __func__, w->name); +dev_dbg (ctx->dev,"%s: sink widget=%s\n" , __func__, p->sink->name); + +/* +* here we will check widgets in sink pipelines, so that +* can be any widgets type and we are only interested if +* they are ones used for SKL so check that first +*/ +if ((p->sink->priv !=NULL ) && +is_skl_dsp_widget_type (p->sink)) { + + sink = p->sink; + src_mconfig = source->priv; + sink_mconfig = sink->priv; + +/* Bind source to sink, mixin is always source */ + ret =skl_bind_modules (ctx, src_mconfig, sink_mconfig); +if (ret) +return ret; + +/* Start sinks pipe first */ +if (sink_mconfig->pipe->state !=SKL_PIPE_STARTED ) { + ret =skl_run_pipe (ctx, sink_mconfig->pipe); +if (ret) +return ret; + } + + path_list =kzalloc ( +sizeof (struct skl_dapm_path_list ), +GFP_KERNEL ); +if (path_list ==NULL ) +return -ENOMEM ; + +/* Add connected path to one global list */ + path_list->dapm_path = p; +list_add_tail (&path_list->node, &skl->dapm_path_list); +break ; + } + } + +/* Start source pipe last after starting all sinks */ + ret =skl_run_pipe (ctx, src_mconfig->pipe); +if (ret) +return ret; + +return 0 ; +} + +/* +* in the Post-PMU event of mixer we need to do following: +* - Check if this pipe is running +* - if not, then +* - bind this pipeline to its source pipeline +* if source pipe is already running, this means it is a dynamic +* connection and we need to bind only to that pipe +* - start this pipeline +*/ +static int skl_tplg_mixer_dapm_post_pmu_event (struct snd_soc_dapm_widget *w, +struct skl *skl) +{ +int ret =0 ; +struct snd_soc_dapm_path *p; +struct snd_soc_dapm_widget *source, *sink; +struct skl_module_cfg *src_mconfig, *sink_mconfig; +struct skl_sst *ctx = skl->skl_sst; +int src_pipe_started =0 ; + + sink = w; + sink_mconfig = sink->priv; + +/* +* If source pipe is already started, that means source is driving +* one more sink before this sink got connected, Since source is +* started, bind this sink to source and start this pipe. +*/ +snd_soc_dapm_widget_for_each_sink_path (w, p) { +if (!p->connect) +continue ; + +dev_dbg (ctx->dev,"sink widget=%s\n" , w->name); +dev_dbg (ctx->dev,"src widget=%s\n" , p->source->name); + +/* +* here we will check widgets in sink pipelines, so that +* can be any widgets type and we are only interested if +* they are ones used for SKL so check that first +*/ +if ((p->source->priv !=NULL ) && +is_skl_dsp_widget_type (p->source)) { + source = p->source; + src_mconfig = source->priv; + sink_mconfig = sink->priv; + src_pipe_started =1 ; + +/* +* check pipe state, then no need to bind or start +* the pipe +*/ +if (src_mconfig->pipe->state !=SKL_PIPE_STARTED ) + src_pipe_started =0 ; + } + } + +if (src_pipe_started) { + ret =skl_bind_modules (ctx, src_mconfig, sink_mconfig); +if (ret) +return ret; + + ret =skl_run_pipe (ctx, sink_mconfig->pipe); + } + +return ret; +} + +/* +* in the Pre-PMD event of mixer we need to do following: +* - Stop the pipe +* - find the source connections and remove that from dapm_path_list +* - unbind with source pipelines if still connected +*/ +static int skl_tplg_mixer_dapm_pre_pmd_event (struct snd_soc_dapm_widget *w, +struct skl *skl) +{ +struct snd_soc_dapm_widget *source, *sink; +struct skl_module_cfg *src_mconfig, *sink_mconfig; +int ret =0 , path_found =0 ; +struct skl_dapm_path_list *path_list, *tmp_list; +struct skl_sst *ctx = skl->skl_sst; + + sink = w; + sink_mconfig = sink->priv; + +/* Stop the pipe */ + ret =skl_stop_pipe (ctx, sink_mconfig->pipe); +if (ret) +return ret; + +/* +* This list, dapm_path_list handling here does not need any locks +* as we are under dapm lock while handling widget events. +* List can be manipulated safely only under dapm widgets handler +* routines +*/ +list_for_each_entry_safe (path_list, tmp_list, + &skl->dapm_path_list, node) { +if (path_list->dapm_path->sink == sink) { +dev_dbg (ctx->dev,"Path found = %s\n" , + path_list->dapm_path->name); + source = path_list->dapm_path->source; + src_mconfig = source->priv; + path_found =1 ; + +list_del (&path_list->node); +kfree (path_list); +break ; + } + } + +/* +* If path_found == 1, that means pmd for source pipe has +* not occurred, source is connected to some other sink. +* so its responsibility of sink to unbind itself from source. +*/ +if (path_found) { + ret =skl_stop_pipe (ctx, src_mconfig->pipe); +if (ret <0 ) +return ret; + + ret =skl_unbind_modules (ctx, src_mconfig, sink_mconfig); + } + +return ret; +} + +/* +* in the Post-PMD event of mixer we need to do following: +* - Free the mcps used +* - Free the mem used +* - Unbind the modules within the pipeline +* - Delete the pipeline (modules are not required to be explicitly +* deleted, pipeline delete is enough here +*/ +static int skl_tplg_mixer_dapm_post_pmd_event (struct snd_soc_dapm_widget *w, +struct skl *skl) +{ +struct skl_module_cfg *mconfig = w->priv; +struct skl_pipe_module *w_module; +struct skl_module_cfg *src_module =NULL , *dst_module; +struct skl_sst *ctx = skl->skl_sst; +struct skl_pipe *s_pipe = mconfig->pipe; +int ret =0 ; + +skl_tplg_free_pipe_mcps (skl, mconfig); + +list_for_each_entry (w_module, &s_pipe->w_list, node) { + dst_module = w_module->w->priv; + +if (src_module ==NULL ) { + src_module = dst_module; +continue ; + } + + ret =skl_unbind_modules (ctx, src_module, dst_module); +if (ret <0 ) +return ret; + + src_module = dst_module; + } + + ret =skl_delete_pipe (ctx, mconfig->pipe); +skl_tplg_free_pipe_mem (skl, mconfig); + +return ret; +} + +/* +* in the Post-PMD event of PGA we need to do following: +* - Free the mcps used +* - Stop the pipeline +* - In source pipe is connected, unbind with source pipelines +*/ +static int skl_tplg_pga_dapm_post_pmd_event (struct snd_soc_dapm_widget *w, +struct skl *skl) +{ +struct snd_soc_dapm_widget *source, *sink; +struct skl_module_cfg *src_mconfig, *sink_mconfig; +int ret =0 , path_found =0 ; +struct skl_dapm_path_list *path_list, *tmp_path_list; +struct skl_sst *ctx = skl->skl_sst; + + source = w; + src_mconfig = source->priv; + +skl_tplg_free_pipe_mcps (skl, src_mconfig); +/* Stop the pipe since this is a mixin module */ + ret =skl_stop_pipe (ctx, src_mconfig->pipe); +if (ret) +return ret; + +list_for_each_entry_safe (path_list, tmp_path_list, &skl->dapm_path_list, node) { +if (path_list->dapm_path->source == source) { +dev_dbg (ctx->dev,"Path found = %s\n" , + path_list->dapm_path->name); + sink = path_list->dapm_path->sink; + sink_mconfig = sink->priv; + path_found =1 ; + +list_del (&path_list->node); +kfree (path_list); +break ; + } + } + +/* +* This is a connector and if path is found that means +* unbind between source and sink has not happened yet +*/ +if (path_found) { + ret =skl_stop_pipe (ctx, src_mconfig->pipe); +if (ret <0 ) +return ret; + + ret =skl_unbind_modules (ctx, src_mconfig, sink_mconfig); + } + +return ret; +} + +/* +* In modelling, we assume there will be ONLY one mixer in a pipeline. If +* mixer is not required then it is treated as static mixer aka vmixer with +* a hard path to source module +* So we don't need to check if source is started or not as hard path puts +* dependency on each other +*/ +static int skl_tplg_vmixer_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *k,int event) +{ +struct snd_soc_dapm_context *dapm = w->dapm; +struct skl *skl =get_skl_ctx (dapm->dev); + +switch (event) { +case SND_SOC_DAPM_PRE_PMU : +return skl_tplg_mixer_dapm_pre_pmu_event (w, skl); + +case SND_SOC_DAPM_POST_PMD : +return skl_tplg_mixer_dapm_post_pmd_event (w, skl); + } + +return 0 ; +} + +/* +* In modelling, we assume there will be ONLY one mixer in a pipeline. If a +* second one is required that is created as another pipe entity. +* The mixer is responsible for pipe management and represent a pipeline +* instance +*/ +static int skl_tplg_mixer_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *k,int event) +{ +struct snd_soc_dapm_context *dapm = w->dapm; +struct skl *skl =get_skl_ctx (dapm->dev); + +switch (event) { +case SND_SOC_DAPM_PRE_PMU : +return skl_tplg_mixer_dapm_pre_pmu_event (w, skl); + +case SND_SOC_DAPM_POST_PMU : +return skl_tplg_mixer_dapm_post_pmu_event (w, skl); + +case SND_SOC_DAPM_PRE_PMD : +return skl_tplg_mixer_dapm_pre_pmd_event (w, skl); + +case SND_SOC_DAPM_POST_PMD : +return skl_tplg_mixer_dapm_post_pmd_event (w, skl); + } + +return 0 ; +} + +/* +* In modelling, we assumed rest of the modules in pipeline are PGA. But we +* are interested in last PGA (leaf PGA) in a pipeline to disconnect with +* the sink when it is running (two FE to one BE or one FE to two BE) +* scenarios +*/ +static int skl_tplg_pga_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *k,int event) + +{ +struct snd_soc_dapm_context *dapm = w->dapm; +struct skl *skl =get_skl_ctx (dapm->dev); + +switch (event) { +case SND_SOC_DAPM_PRE_PMU : +return skl_tplg_pga_dapm_pre_pmu_event (w, skl); + +case SND_SOC_DAPM_POST_PMD : +return skl_tplg_pga_dapm_post_pmd_event (w, skl); + } + +return 0 ; +}
sound/soc/intel/skylake/skl-topology.h +7 -0
@@ -273,6 +273,13 @@ struct skl_dapm_path_list {struct list_head node; }; +static inline struct skl *get_skl_ctx (struct device *dev) +{ +struct hdac_ext_bus *ebus =dev_get_drvdata (dev); + +return ebus_to_skl (ebus); +} +int skl_create_pipeline (struct skl_sst *ctx,struct skl_pipe *pipe);int skl_run_pipe (struct skl_sst *ctx,struct skl_pipe *pipe);
Signature · 1 line
2.4.3
Mark Brown
maintainerApplied "ASoC: Intel: Skylake: add DSP platform widget event handlers" to the asoc tree
The patch
ASoC: Intel: Skylake: add DSP platform widget event handlers
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
d93f8e550f44ed1f54285f77f40f7962a3f25267Mon Sep 17 00:00:00 2001
From: Vinod Koul <[email protected]>
Date: Wed, 7 Oct 2015 11:31:54 +0100
Subject: [PATCH] ASoC: Intel: Skylake: add DSP platform widget event handlers
The Skylake driver topology model tries to model the firmware rule for pipeline and module creation.
The creation rule is:
- Create Pipe
- Add modules to Pipe
- Connect the modules (bind)
- Start the pipes
Similarly destroy rule is:
- Stop the pipe
- Disconnect it (unbind)
- Delete the pipe
In driver we use Mixer, as there will always be ONE mixer in a pipeline to model a pipe. The modules in pipe are modelled as PGA widgets. The DAPM sequencing rules (mixer and then PGA) are used to create the sequence DSP expects as depicted above, and then widget handlers for PMU and PMD events help in that.
This patch adds widget event handlers for PRE/POST PMU and PRE/POST PMD event for mixer and pga modules. These event handlers invoke pipeline creation, destroy, module creation, module bind, unbind and pipeline bind unbind
Event handler sequencing is implement to target the DSP FW sequence expectations to enable path from source to sink pipe for Playback/Capture.
--- sound/soc/intel/skylake/skl-topology.c | 448 +++++++++++++++++++++++++++++++++ sound/soc/intel/skylake/skl-topology.h | 7 + 2 files changed, 455 insertions(+)
sound/soc/intel/skylake/skl-topology.c +448 -0
@@ -325,3 +325,451 @@ skl_tplg_init_pipe_modules(struct skl *skl, struct skl_pipe *pipe)return 0 ; } + +/* +* Mixer module represents a pipeline. So in the Pre-PMU event of mixer we +* need create the pipeline. So we do following: +* - check the resources +* - Create the pipeline +* - Initialize the modules in pipeline +* - finally bind all modules together +*/ +static int skl_tplg_mixer_dapm_pre_pmu_event (struct snd_soc_dapm_widget *w, +struct skl *skl) +{ +int ret; +struct skl_module_cfg *mconfig = w->priv; +struct skl_pipe_module *w_module; +struct skl_pipe *s_pipe = mconfig->pipe; +struct skl_module_cfg *src_module =NULL , *dst_module; +struct skl_sst *ctx = skl->skl_sst; + +/* check resource available */ +if (!skl_tplg_alloc_pipe_mcps (skl, mconfig)) +return -EBUSY ; + +if (!skl_tplg_alloc_pipe_mem (skl, mconfig)) +return -ENOMEM ; + +/* +* Create a list of modules for pipe. +* This list contains modules from source to sink +*/ + ret =skl_create_pipeline (ctx, mconfig->pipe); +if (ret <0 ) +return ret; + +/* +* we create a w_list of all widgets in that pipe. This list is not +* freed on PMD event as widgets within a pipe are static. This +* saves us cycles to get widgets in pipe every time. +* +* So if we have already initialized all the widgets of a pipeline +* we skip, so check for list_empty and create the list if empty +*/ +if (list_empty (&s_pipe->w_list)) { + ret =skl_tplg_alloc_pipe_widget (ctx->dev, w, s_pipe); +if (ret <0 ) +return ret; + } + +/* Init all pipe modules from source to sink */ + ret =skl_tplg_init_pipe_modules (skl, s_pipe); +if (ret <0 ) +return ret; + +/* Bind modules from source to sink */ +list_for_each_entry (w_module, &s_pipe->w_list, node) { + dst_module = w_module->w->priv; + +if (src_module ==NULL ) { + src_module = dst_module; +continue ; + } + + ret =skl_bind_modules (ctx, src_module, dst_module); +if (ret <0 ) +return ret; + + src_module = dst_module; + } + +return 0 ; +} + +/* +* A PGA represents a module in a pipeline. So in the Pre-PMU event of PGA +* we need to do following: +* - Bind to sink pipeline +* Since the sink pipes can be running and we don't get mixer event on +* connect for already running mixer, we need to find the sink pipes +* here and bind to them. This way dynamic connect works. +* - Start sink pipeline, if not running +* - Then run current pipe +*/ +static int skl_tplg_pga_dapm_pre_pmu_event (struct snd_soc_dapm_widget *w, +struct skl *skl) +{ +struct snd_soc_dapm_path *p; +struct skl_dapm_path_list *path_list; +struct snd_soc_dapm_widget *source, *sink; +struct skl_module_cfg *src_mconfig, *sink_mconfig; +struct skl_sst *ctx = skl->skl_sst; +int ret =0 ; + + source = w; + src_mconfig = source->priv; + +/* +* find which sink it is connected to, bind with the sink, +* if sink is not started, start sink pipe first, then start +* this pipe +*/ +snd_soc_dapm_widget_for_each_source_path (w, p) { +if (!p->connect) +continue ; + +dev_dbg (ctx->dev,"%s: src widget=%s\n" , __func__, w->name); +dev_dbg (ctx->dev,"%s: sink widget=%s\n" , __func__, p->sink->name); + +/* +* here we will check widgets in sink pipelines, so that +* can be any widgets type and we are only interested if +* they are ones used for SKL so check that first +*/ +if ((p->sink->priv !=NULL ) && +is_skl_dsp_widget_type (p->sink)) { + + sink = p->sink; + src_mconfig = source->priv; + sink_mconfig = sink->priv; + +/* Bind source to sink, mixin is always source */ + ret =skl_bind_modules (ctx, src_mconfig, sink_mconfig); +if (ret) +return ret; + +/* Start sinks pipe first */ +if (sink_mconfig->pipe->state !=SKL_PIPE_STARTED ) { + ret =skl_run_pipe (ctx, sink_mconfig->pipe); +if (ret) +return ret; + } + + path_list =kzalloc ( +sizeof (struct skl_dapm_path_list ), +GFP_KERNEL ); +if (path_list ==NULL ) +return -ENOMEM ; + +/* Add connected path to one global list */ + path_list->dapm_path = p; +list_add_tail (&path_list->node, &skl->dapm_path_list); +break ; + } + } + +/* Start source pipe last after starting all sinks */ + ret =skl_run_pipe (ctx, src_mconfig->pipe); +if (ret) +return ret; + +return 0 ; +} + +/* +* in the Post-PMU event of mixer we need to do following: +* - Check if this pipe is running +* - if not, then +* - bind this pipeline to its source pipeline +* if source pipe is already running, this means it is a dynamic +* connection and we need to bind only to that pipe +* - start this pipeline +*/ +static int skl_tplg_mixer_dapm_post_pmu_event (struct snd_soc_dapm_widget *w, +struct skl *skl) +{ +int ret =0 ; +struct snd_soc_dapm_path *p; +struct snd_soc_dapm_widget *source, *sink; +struct skl_module_cfg *src_mconfig, *sink_mconfig; +struct skl_sst *ctx = skl->skl_sst; +int src_pipe_started =0 ; + + sink = w; + sink_mconfig = sink->priv; + +/* +* If source pipe is already started, that means source is driving +* one more sink before this sink got connected, Since source is +* started, bind this sink to source and start this pipe. +*/ +snd_soc_dapm_widget_for_each_sink_path (w, p) { +if (!p->connect) +continue ; + +dev_dbg (ctx->dev,"sink widget=%s\n" , w->name); +dev_dbg (ctx->dev,"src widget=%s\n" , p->source->name); + +/* +* here we will check widgets in sink pipelines, so that +* can be any widgets type and we are only interested if +* they are ones used for SKL so check that first +*/ +if ((p->source->priv !=NULL ) && +is_skl_dsp_widget_type (p->source)) { + source = p->source; + src_mconfig = source->priv; + sink_mconfig = sink->priv; + src_pipe_started =1 ; + +/* +* check pipe state, then no need to bind or start +* the pipe +*/ +if (src_mconfig->pipe->state !=SKL_PIPE_STARTED ) + src_pipe_started =0 ; + } + } + +if (src_pipe_started) { + ret =skl_bind_modules (ctx, src_mconfig, sink_mconfig); +if (ret) +return ret; + + ret =skl_run_pipe (ctx, sink_mconfig->pipe); + } + +return ret; +} + +/* +* in the Pre-PMD event of mixer we need to do following: +* - Stop the pipe +* - find the source connections and remove that from dapm_path_list +* - unbind with source pipelines if still connected +*/ +static int skl_tplg_mixer_dapm_pre_pmd_event (struct snd_soc_dapm_widget *w, +struct skl *skl) +{ +struct snd_soc_dapm_widget *source, *sink; +struct skl_module_cfg *src_mconfig, *sink_mconfig; +int ret =0 , path_found =0 ; +struct skl_dapm_path_list *path_list, *tmp_list; +struct skl_sst *ctx = skl->skl_sst; + + sink = w; + sink_mconfig = sink->priv; + +/* Stop the pipe */ + ret =skl_stop_pipe (ctx, sink_mconfig->pipe); +if (ret) +return ret; + +/* +* This list, dapm_path_list handling here does not need any locks +* as we are under dapm lock while handling widget events. +* List can be manipulated safely only under dapm widgets handler +* routines +*/ +list_for_each_entry_safe (path_list, tmp_list, + &skl->dapm_path_list, node) { +if (path_list->dapm_path->sink == sink) { +dev_dbg (ctx->dev,"Path found = %s\n" , + path_list->dapm_path->name); + source = path_list->dapm_path->source; + src_mconfig = source->priv; + path_found =1 ; + +list_del (&path_list->node); +kfree (path_list); +break ; + } + } + +/* +* If path_found == 1, that means pmd for source pipe has +* not occurred, source is connected to some other sink. +* so its responsibility of sink to unbind itself from source. +*/ +if (path_found) { + ret =skl_stop_pipe (ctx, src_mconfig->pipe); +if (ret <0 ) +return ret; + + ret =skl_unbind_modules (ctx, src_mconfig, sink_mconfig); + } + +return ret; +} + +/* +* in the Post-PMD event of mixer we need to do following: +* - Free the mcps used +* - Free the mem used +* - Unbind the modules within the pipeline +* - Delete the pipeline (modules are not required to be explicitly +* deleted, pipeline delete is enough here +*/ +static int skl_tplg_mixer_dapm_post_pmd_event (struct snd_soc_dapm_widget *w, +struct skl *skl) +{ +struct skl_module_cfg *mconfig = w->priv; +struct skl_pipe_module *w_module; +struct skl_module_cfg *src_module =NULL , *dst_module; +struct skl_sst *ctx = skl->skl_sst; +struct skl_pipe *s_pipe = mconfig->pipe; +int ret =0 ; + +skl_tplg_free_pipe_mcps (skl, mconfig); + +list_for_each_entry (w_module, &s_pipe->w_list, node) { + dst_module = w_module->w->priv; + +if (src_module ==NULL ) { + src_module = dst_module; +continue ; + } + + ret =skl_unbind_modules (ctx, src_module, dst_module); +if (ret <0 ) +return ret; + + src_module = dst_module; + } + + ret =skl_delete_pipe (ctx, mconfig->pipe); +skl_tplg_free_pipe_mem (skl, mconfig); + +return ret; +} + +/* +* in the Post-PMD event of PGA we need to do following: +* - Free the mcps used +* - Stop the pipeline +* - In source pipe is connected, unbind with source pipelines +*/ +static int skl_tplg_pga_dapm_post_pmd_event (struct snd_soc_dapm_widget *w, +struct skl *skl) +{ +struct snd_soc_dapm_widget *source, *sink; +struct skl_module_cfg *src_mconfig, *sink_mconfig; +int ret =0 , path_found =0 ; +struct skl_dapm_path_list *path_list, *tmp_path_list; +struct skl_sst *ctx = skl->skl_sst; + + source = w; + src_mconfig = source->priv; + +skl_tplg_free_pipe_mcps (skl, src_mconfig); +/* Stop the pipe since this is a mixin module */ + ret =skl_stop_pipe (ctx, src_mconfig->pipe); +if (ret) +return ret; + +list_for_each_entry_safe (path_list, tmp_path_list, &skl->dapm_path_list, node) { +if (path_list->dapm_path->source == source) { +dev_dbg (ctx->dev,"Path found = %s\n" , + path_list->dapm_path->name); + sink = path_list->dapm_path->sink; + sink_mconfig = sink->priv; + path_found =1 ; + +list_del (&path_list->node); +kfree (path_list); +break ; + } + } + +/* +* This is a connector and if path is found that means +* unbind between source and sink has not happened yet +*/ +if (path_found) { + ret =skl_stop_pipe (ctx, src_mconfig->pipe); +if (ret <0 ) +return ret; + + ret =skl_unbind_modules (ctx, src_mconfig, sink_mconfig); + } + +return ret; +} + +/* +* In modelling, we assume there will be ONLY one mixer in a pipeline. If +* mixer is not required then it is treated as static mixer aka vmixer with +* a hard path to source module +* So we don't need to check if source is started or not as hard path puts +* dependency on each other +*/ +static int skl_tplg_vmixer_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *k,int event) +{ +struct snd_soc_dapm_context *dapm = w->dapm; +struct skl *skl =get_skl_ctx (dapm->dev); + +switch (event) { +case SND_SOC_DAPM_PRE_PMU : +return skl_tplg_mixer_dapm_pre_pmu_event (w, skl); + +case SND_SOC_DAPM_POST_PMD : +return skl_tplg_mixer_dapm_post_pmd_event (w, skl); + } + +return 0 ; +} + +/* +* In modelling, we assume there will be ONLY one mixer in a pipeline. If a +* second one is required that is created as another pipe entity. +* The mixer is responsible for pipe management and represent a pipeline +* instance +*/ +static int skl_tplg_mixer_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *k,int event) +{ +struct snd_soc_dapm_context *dapm = w->dapm; +struct skl *skl =get_skl_ctx (dapm->dev); + +switch (event) { +case SND_SOC_DAPM_PRE_PMU : +return skl_tplg_mixer_dapm_pre_pmu_event (w, skl); + +case SND_SOC_DAPM_POST_PMU : +return skl_tplg_mixer_dapm_post_pmu_event (w, skl); + +case SND_SOC_DAPM_PRE_PMD : +return skl_tplg_mixer_dapm_pre_pmd_event (w, skl); + +case SND_SOC_DAPM_POST_PMD : +return skl_tplg_mixer_dapm_post_pmd_event (w, skl); + } + +return 0 ; +} + +/* +* In modelling, we assumed rest of the modules in pipeline are PGA. But we +* are interested in last PGA (leaf PGA) in a pipeline to disconnect with +* the sink when it is running (two FE to one BE or one FE to two BE) +* scenarios +*/ +static int skl_tplg_pga_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *k,int event) + +{ +struct snd_soc_dapm_context *dapm = w->dapm; +struct skl *skl =get_skl_ctx (dapm->dev); + +switch (event) { +case SND_SOC_DAPM_PRE_PMU : +return skl_tplg_pga_dapm_pre_pmu_event (w, skl); + +case SND_SOC_DAPM_POST_PMD : +return skl_tplg_pga_dapm_post_pmd_event (w, skl); + } + +return 0 ; +}
sound/soc/intel/skylake/skl-topology.h +7 -0
@@ -273,6 +273,13 @@ struct skl_dapm_path_list {struct list_head node; }; +static inline struct skl *get_skl_ctx (struct device *dev) +{ +struct hdac_ext_bus *ebus =dev_get_drvdata (dev); + +return ebus_to_skl (ebus); +} +int skl_create_pipeline (struct skl_sst *ctx,struct skl_pipe *pipe);int skl_run_pipe (struct skl_sst *ctx,struct skl_pipe *pipe);
Signature · 1 line
2.5.0
PATCH v4 4/8 ASoC: Intel: Skylake: Add FE and BE hw_params handling
In reply to Vinod KoulFor FE and BE, the PCM parameters come from FE and BE hw_params values passed. For a FE we convert the FE params to DSP expected module format and pass to DSP. For a BE we need to find the gateway settings (i2s/PDM) to be applied. These are queried from NHLT table and applied.
Further for BE based on direction the settings are applied as either source or destination parameters.
These helpers here allow the format to be calculated and queried as per firmware format.
--- sound/soc/intel/skylake/skl-topology.c | 238 +++++++++++++++++++++++++++++++++ sound/soc/intel/skylake/skl-topology.h | 12 ++ 2 files changed, 250 insertions(+)
sound/soc/intel/skylake/skl-topology.c +238 -0
@@ -773,3 +773,241 @@ static int skl_tplg_pga_event(struct snd_soc_dapm_widget *w,return 0 ; } + +/* +* The FE params are passed by hw_params of the DAI. +* On hw_params, the params are stored in Gateway module of the FE and we +* need to calculate the format in DSP module configuration, that +* conversion is done here +*/ +int skl_tplg_update_pipe_params (struct device *dev, +struct skl_module_cfg *mconfig, +struct skl_pipe_params *params) +{ +struct skl_pipe *pipe = mconfig->pipe; +struct skl_module_fmt *format =NULL ; + +memcpy (pipe->p_params, params,sizeof (*params)); + +if (params->stream ==SNDRV_PCM_STREAM_PLAYBACK ) + format = &mconfig->in_fmt; +else + format = &mconfig->out_fmt; + +/* set the hw_params */ + format->s_freq = params->s_freq; + format->channels = params->ch; + format->valid_bit_depth =skl_get_bit_depth (params->s_fmt); + +/* +* 16 bit is 16 bit container whereas 24 bit is in 32 bit +* container so update bit depth accordingly +*/ +switch (format->valid_bit_depth) { +case SKL_DEPTH_16BIT : + format->bit_depth = format->valid_bit_depth; +break ; + +case SKL_DEPTH_24BIT : + format->bit_depth =SKL_DEPTH_32BIT ; +break ; + +default : +dev_err (dev,"Invalid bit depth %x for pipe\n" , + format->valid_bit_depth); +return -EINVAL ; + } + +if (params->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { + mconfig->ibs = (format->s_freq /1000 ) * + (format->channels) * + (format->bit_depth >>3 ); + }else { + mconfig->obs = (format->s_freq /1000 ) * + (format->channels) * + (format->bit_depth >>3 ); + } + +return 0 ; +} + +/* +* Query the module config for the FE DAI +* This is used to find the hw_params set for that DAI and apply to FE +* pipeline +*/ +struct skl_module_cfg * +skl_tplg_fe_get_cpr_module (struct snd_soc_dai *dai,int stream) +{ +struct snd_soc_dapm_widget *w; +struct snd_soc_dapm_path *p =NULL ; + +if (stream ==SNDRV_PCM_STREAM_PLAYBACK ) { + w = dai->playback_widget; +snd_soc_dapm_widget_for_each_source_path (w, p) { +if (p->connect && p->sink->power && +is_skl_dsp_widget_type (p->sink)) +continue ; + +if (p->sink->priv) { +dev_dbg (dai->dev,"set params for %s\n" , + p->sink->name); +return p->sink->priv; + } + } + }else { + w = dai->capture_widget; +snd_soc_dapm_widget_for_each_sink_path (w, p) { +if (p->connect && p->source->power && +is_skl_dsp_widget_type (p->source)) +continue ; + +if (p->source->priv) { +dev_dbg (dai->dev,"set params for %s\n" , + p->source->name); +return p->source->priv; + } + } + } + +return NULL ; +} + +static u8 skl_tplg_be_link_type (int dev_type) +{ +int ret; + +switch (dev_type) { +case SKL_DEVICE_BT : + ret =NHLT_LINK_SSP ; +break ; + +case SKL_DEVICE_DMIC : + ret =NHLT_LINK_DMIC ; +break ; + +case SKL_DEVICE_I2S : + ret =NHLT_LINK_SSP ; +break ; + +case SKL_DEVICE_HDALINK : + ret =NHLT_LINK_HDA ; +break ; + +default : + ret =NHLT_LINK_INVALID ; +break ; + } + +return ret; +} + +/* +* Fill the BE gateway parameters +* The BE gateway expects a blob of parameters which are kept in the ACPI +* NHLT blob, so query the blob for interface type (i2s/pdm) and instance. +* The port can have multiple settings so pick based on the PCM +* parameters +*/ +static int skl_tplg_be_fill_pipe_params (struct snd_soc_dai *dai, +struct skl_module_cfg *mconfig, +struct skl_pipe_params *params) +{ +struct skl_pipe *pipe = mconfig->pipe; +struct nhlt_specific_cfg *cfg; +struct skl *skl =get_skl_ctx (dai->dev); +int link_type =skl_tplg_be_link_type (mconfig->dev_type); + +memcpy (pipe->p_params, params,sizeof (*params)); + +/* update the blob based on virtual bus_id*/ + cfg =skl_get_ep_blob (skl, mconfig->vbus_id, link_type, + params->s_fmt, params->ch, + params->s_freq, params->stream); +if (cfg) { + mconfig->formats_config.caps_size = cfg->size; +memcpy (mconfig->formats_config.caps, &cfg->caps, cfg->size); + }else { +dev_err (dai->dev,"Blob NULL for id %x type %d dirn %d\n" , + mconfig->vbus_id, link_type, + params->stream); +dev_err (dai->dev,"PCM: ch %d, freq %d, fmt %d\n" , + params->ch, params->s_freq, params->s_fmt); +return -EINVAL ; + } + +return 0 ; +} + +static int skl_tplg_be_set_src_pipe_params (struct snd_soc_dai *dai, +struct snd_soc_dapm_widget *w, +struct skl_pipe_params *params) +{ +struct snd_soc_dapm_path *p; + +snd_soc_dapm_widget_for_each_sink_path (w, p) { +if (p->connect &&is_skl_dsp_widget_type (p->source) && + p->source->priv) { + +if (!p->source->power) +return skl_tplg_be_fill_pipe_params ( + dai, p->source->priv, + params); +else +return -EBUSY ; + }else { +return skl_tplg_be_set_src_pipe_params ( + dai, p->source, params); + } + } + +return -EIO ; +} + +static int skl_tplg_be_set_sink_pipe_params (struct snd_soc_dai *dai, +struct snd_soc_dapm_widget *w,struct skl_pipe_params *params) +{ +struct snd_soc_dapm_path *p =NULL ; + +snd_soc_dapm_widget_for_each_source_path (w, p) { +if (p->connect &&is_skl_dsp_widget_type (p->sink) && + p->sink->priv) { + +if (!p->sink->power) +return skl_tplg_be_fill_pipe_params ( + dai, p->sink->priv, params); +else +return -EBUSY ; + + }else { +return skl_tplg_be_set_sink_pipe_params ( + dai, p->sink, params); + } + } + +return -EIO ; +} + +/* +* BE hw_params can be a source parameters (capture) or sink parameters +* (playback). Based on sink and source we need to either find the source +* list or the sink list and set the pipeline parameters +*/ +int skl_tplg_be_update_params (struct snd_soc_dai *dai, +struct skl_pipe_params *params) +{ +struct snd_soc_dapm_widget *w; + +if (params->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { + w = dai->playback_widget; + +return skl_tplg_be_set_src_pipe_params (dai, w, params); + + }else { + w = dai->capture_widget; + +return skl_tplg_be_set_sink_pipe_params (dai, w, params); + } + +return 0 ; +}
sound/soc/intel/skylake/skl-topology.h +12 -0
@@ -280,6 +280,18 @@ static inline struct skl *get_skl_ctx(struct device *dev)return ebus_to_skl (ebus); } +int skl_tplg_be_update_params (struct snd_soc_dai *dai, +struct skl_pipe_params *params); +void skl_tplg_set_be_dmic_config (struct snd_soc_dai *dai, +struct skl_pipe_params *params,int stream); +int skl_tplg_init (struct snd_soc_platform *platform, +struct hdac_ext_bus *ebus); +struct skl_module_cfg *skl_tplg_fe_get_cpr_module ( +struct snd_soc_dai *dai,int stream); +int skl_tplg_update_pipe_params (struct device *dev, +struct skl_module_cfg *mconfig,struct skl_pipe_params *params); + +int skl_create_pipeline (struct skl_sst *ctx,struct skl_pipe *pipe);int skl_run_pipe (struct skl_sst *ctx,struct skl_pipe *pipe);
Signature · 1 line
2.4.3
Mark Brown
maintainerApplied "ASoC: Intel: Skylake: Add FE and BE hw_params handling" to the asoc tree
The patch
ASoC: Intel: Skylake: Add FE and BE hw_params handling
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
cfb0a87383c6c2827f108ecee3471ef981876b38Mon Sep 17 00:00:00 2001
From: Vinod Koul <[email protected]>
Date: Wed, 7 Oct 2015 11:31:55 +0100
Subject: [PATCH] ASoC: Intel: Skylake: Add FE and BE hw_params handling
For FE and BE, the PCM parameters come from FE and BE hw_params values passed. For a FE we convert the FE params to DSP expected module format and pass to DSP. For a BE we need to find the gateway settings (i2s/PDM) to be applied. These are queried from NHLT table and applied.
Further for BE based on direction the settings are applied as either source or destination parameters.
These helpers here allow the format to be calculated and queried as per firmware format.
--- sound/soc/intel/skylake/skl-topology.c | 238 +++++++++++++++++++++++++++++++++ sound/soc/intel/skylake/skl-topology.h | 12 ++ 2 files changed, 250 insertions(+)
sound/soc/intel/skylake/skl-topology.c +238 -0
@@ -773,3 +773,241 @@ static int skl_tplg_pga_event(struct snd_soc_dapm_widget *w,return 0 ; } + +/* +* The FE params are passed by hw_params of the DAI. +* On hw_params, the params are stored in Gateway module of the FE and we +* need to calculate the format in DSP module configuration, that +* conversion is done here +*/ +int skl_tplg_update_pipe_params (struct device *dev, +struct skl_module_cfg *mconfig, +struct skl_pipe_params *params) +{ +struct skl_pipe *pipe = mconfig->pipe; +struct skl_module_fmt *format =NULL ; + +memcpy (pipe->p_params, params,sizeof (*params)); + +if (params->stream ==SNDRV_PCM_STREAM_PLAYBACK ) + format = &mconfig->in_fmt; +else + format = &mconfig->out_fmt; + +/* set the hw_params */ + format->s_freq = params->s_freq; + format->channels = params->ch; + format->valid_bit_depth =skl_get_bit_depth (params->s_fmt); + +/* +* 16 bit is 16 bit container whereas 24 bit is in 32 bit +* container so update bit depth accordingly +*/ +switch (format->valid_bit_depth) { +case SKL_DEPTH_16BIT : + format->bit_depth = format->valid_bit_depth; +break ; + +case SKL_DEPTH_24BIT : + format->bit_depth =SKL_DEPTH_32BIT ; +break ; + +default : +dev_err (dev,"Invalid bit depth %x for pipe\n" , + format->valid_bit_depth); +return -EINVAL ; + } + +if (params->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { + mconfig->ibs = (format->s_freq /1000 ) * + (format->channels) * + (format->bit_depth >>3 ); + }else { + mconfig->obs = (format->s_freq /1000 ) * + (format->channels) * + (format->bit_depth >>3 ); + } + +return 0 ; +} + +/* +* Query the module config for the FE DAI +* This is used to find the hw_params set for that DAI and apply to FE +* pipeline +*/ +struct skl_module_cfg * +skl_tplg_fe_get_cpr_module (struct snd_soc_dai *dai,int stream) +{ +struct snd_soc_dapm_widget *w; +struct snd_soc_dapm_path *p =NULL ; + +if (stream ==SNDRV_PCM_STREAM_PLAYBACK ) { + w = dai->playback_widget; +snd_soc_dapm_widget_for_each_source_path (w, p) { +if (p->connect && p->sink->power && +is_skl_dsp_widget_type (p->sink)) +continue ; + +if (p->sink->priv) { +dev_dbg (dai->dev,"set params for %s\n" , + p->sink->name); +return p->sink->priv; + } + } + }else { + w = dai->capture_widget; +snd_soc_dapm_widget_for_each_sink_path (w, p) { +if (p->connect && p->source->power && +is_skl_dsp_widget_type (p->source)) +continue ; + +if (p->source->priv) { +dev_dbg (dai->dev,"set params for %s\n" , + p->source->name); +return p->source->priv; + } + } + } + +return NULL ; +} + +static u8 skl_tplg_be_link_type (int dev_type) +{ +int ret; + +switch (dev_type) { +case SKL_DEVICE_BT : + ret =NHLT_LINK_SSP ; +break ; + +case SKL_DEVICE_DMIC : + ret =NHLT_LINK_DMIC ; +break ; + +case SKL_DEVICE_I2S : + ret =NHLT_LINK_SSP ; +break ; + +case SKL_DEVICE_HDALINK : + ret =NHLT_LINK_HDA ; +break ; + +default : + ret =NHLT_LINK_INVALID ; +break ; + } + +return ret; +} + +/* +* Fill the BE gateway parameters +* The BE gateway expects a blob of parameters which are kept in the ACPI +* NHLT blob, so query the blob for interface type (i2s/pdm) and instance. +* The port can have multiple settings so pick based on the PCM +* parameters +*/ +static int skl_tplg_be_fill_pipe_params (struct snd_soc_dai *dai, +struct skl_module_cfg *mconfig, +struct skl_pipe_params *params) +{ +struct skl_pipe *pipe = mconfig->pipe; +struct nhlt_specific_cfg *cfg; +struct skl *skl =get_skl_ctx (dai->dev); +int link_type =skl_tplg_be_link_type (mconfig->dev_type); + +memcpy (pipe->p_params, params,sizeof (*params)); + +/* update the blob based on virtual bus_id*/ + cfg =skl_get_ep_blob (skl, mconfig->vbus_id, link_type, + params->s_fmt, params->ch, + params->s_freq, params->stream); +if (cfg) { + mconfig->formats_config.caps_size = cfg->size; +memcpy (mconfig->formats_config.caps, &cfg->caps, cfg->size); + }else { +dev_err (dai->dev,"Blob NULL for id %x type %d dirn %d\n" , + mconfig->vbus_id, link_type, + params->stream); +dev_err (dai->dev,"PCM: ch %d, freq %d, fmt %d\n" , + params->ch, params->s_freq, params->s_fmt); +return -EINVAL ; + } + +return 0 ; +} + +static int skl_tplg_be_set_src_pipe_params (struct snd_soc_dai *dai, +struct snd_soc_dapm_widget *w, +struct skl_pipe_params *params) +{ +struct snd_soc_dapm_path *p; + +snd_soc_dapm_widget_for_each_sink_path (w, p) { +if (p->connect &&is_skl_dsp_widget_type (p->source) && + p->source->priv) { + +if (!p->source->power) +return skl_tplg_be_fill_pipe_params ( + dai, p->source->priv, + params); +else +return -EBUSY ; + }else { +return skl_tplg_be_set_src_pipe_params ( + dai, p->source, params); + } + } + +return -EIO ; +} + +static int skl_tplg_be_set_sink_pipe_params (struct snd_soc_dai *dai, +struct snd_soc_dapm_widget *w,struct skl_pipe_params *params) +{ +struct snd_soc_dapm_path *p =NULL ; + +snd_soc_dapm_widget_for_each_source_path (w, p) { +if (p->connect &&is_skl_dsp_widget_type (p->sink) && + p->sink->priv) { + +if (!p->sink->power) +return skl_tplg_be_fill_pipe_params ( + dai, p->sink->priv, params); +else +return -EBUSY ; + + }else { +return skl_tplg_be_set_sink_pipe_params ( + dai, p->sink, params); + } + } + +return -EIO ; +} + +/* +* BE hw_params can be a source parameters (capture) or sink parameters +* (playback). Based on sink and source we need to either find the source +* list or the sink list and set the pipeline parameters +*/ +int skl_tplg_be_update_params (struct snd_soc_dai *dai, +struct skl_pipe_params *params) +{ +struct snd_soc_dapm_widget *w; + +if (params->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { + w = dai->playback_widget; + +return skl_tplg_be_set_src_pipe_params (dai, w, params); + + }else { + w = dai->capture_widget; + +return skl_tplg_be_set_sink_pipe_params (dai, w, params); + } + +return 0 ; +}
sound/soc/intel/skylake/skl-topology.h +12 -0
@@ -280,6 +280,18 @@ static inline struct skl *get_skl_ctx(struct device *dev)return ebus_to_skl (ebus); } +int skl_tplg_be_update_params (struct snd_soc_dai *dai, +struct skl_pipe_params *params); +void skl_tplg_set_be_dmic_config (struct snd_soc_dai *dai, +struct skl_pipe_params *params,int stream); +int skl_tplg_init (struct snd_soc_platform *platform, +struct hdac_ext_bus *ebus); +struct skl_module_cfg *skl_tplg_fe_get_cpr_module ( +struct snd_soc_dai *dai,int stream); +int skl_tplg_update_pipe_params (struct device *dev, +struct skl_module_cfg *mconfig,struct skl_pipe_params *params); + +int skl_create_pipeline (struct skl_sst *ctx,struct skl_pipe *pipe);int skl_run_pipe (struct skl_sst *ctx,struct skl_pipe *pipe);
Signature · 1 line
2.5.0
PATCH v4 5/8 ASoC: Intel: Skylake: Add topology core init and handlers
In reply to Vinod KoulThe SKL driver does not code DSP topology in driver. It uses the newly added ASoC topology core to parse the topology information (controls, widgets and map) from topology binary.
Each topology element passed private data which contains information that driver used to identify the module instance within firmware and send IPCs for that module to DSP firmware along with parameters.
This patch adds init routine to invoke topology load and callback for topology creation.
--- sound/soc/intel/Kconfig | 1 + sound/soc/intel/skylake/skl-topology.c | 218 +++++++++++++++++++++++++++ sound/soc/intel/skylake/skl-topology.h | 1 - sound/soc/intel/skylake/skl-tplg-interface.h | 80 ++++++++++ 4 files changed, 299 insertions(+), 1 deletion(-)
sound/soc/intel/Kconfig +1 -0
@@ -138,4 +138,5 @@ config SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH config SND_SOC_INTEL_SKYLAKE tristate select SND_HDA_EXT_CORE + select SND_SOC_TOPOLOGY select SND_SOC_INTEL_SST
sound/soc/intel/skylake/skl-topology.c +218 -0
221 lines not on this page · raw message
sound/soc/intel/skylake/skl-topology.h +0 -1
@@ -291,7 +291,6 @@ struct skl_module_cfg *skl_tplg_fe_get_cpr_module(int skl_tplg_update_pipe_params (struct device *dev,struct skl_module_cfg *mconfig,struct skl_pipe_params *params); -int skl_create_pipeline (struct skl_sst *ctx,struct skl_pipe *pipe);int skl_run_pipe (struct skl_sst *ctx,struct skl_pipe *pipe);
sound/soc/intel/skylake/skl-tplg-interface.h +80 -0
90 lines not on this page · raw message
Signature · 1 line
2.4.3
Mark Brown
maintainerRe: [PATCH v4 5/8] ASoC: Intel: Skylake: Add topology core init and handlers
sound/soc/intel/skylake/skl-topology.c int skl_tplg_be_update_params(struct snd_soc_dai *dai, · line 1178
Quoted 5 lines · Vinod Koul
sound/soc/intel/skylake/skl-topology.c +5
-0+bind_event: +if (tplg_w->event_type ==0 ) { +dev_info (bus->dev,"ASoC: No event handler required\n" ); +return 0 ; + }
This looks like it'll be excessively noisy... why does the user care?
Re: [PATCH v4 5/8] ASoC: Intel: Skylake: Add topology core init and handlers
Quoted 9 lines · Mark Brown
sound/soc/intel/skylake/skl-topology.c int skl_tplg_be_update_params(struct snd_soc_dai *dai, · line 1178
Quoted 5 lines · Vinod Koul
sound/soc/intel/skylake/skl-topology.c +5
-0+bind_event: +if (tplg_w->event_type ==0 ) { +dev_info (bus->dev,"ASoC: No event handler required\n" ); +return 0 ; + }This looks like it'll be excessively noisy... why does the user care?
Right. I will move to debug..
Thanks
Signature · 1 line
~Vinod
PATCH v4 6/8 ASoC: Intel: Skylake: Initialize and load DSP controls
In reply to Vinod KoulFrom: Jeeja KP <[email protected]>
Initialize and creates DSP controls if processing pipe capability is supported by HW. Updates the dma_id, hw_params to module param to be used when DSP module has to be configured.
--- sound/soc/intel/skylake/skl-pcm.c | 141 ++++++++++++++++++++++++++------- sound/soc/intel/skylake/skl-topology.c | 39 +++++---- 2 files changed, 136 insertions(+), 44 deletions(-)
sound/soc/intel/skylake/skl-pcm.c +113 -28
@@ -24,6 +24,7 @@#include <sound/pcm_params.h> #include <sound/soc.h> #include "skl.h" +#include "skl-topology.h" #define HDA_MONO 1#define HDA_STEREO 2
@@ -214,6 +215,8 @@ static int skl_pcm_hw_params(struct snd_pcm_substream *substream,struct hdac_ext_bus *ebus =dev_get_drvdata (dai->dev);struct hdac_ext_stream *stream =get_hdac_ext_stream (substream);struct snd_pcm_runtime *runtime = substream->runtime; +struct skl_pipe_params p_params = {0 }; +struct skl_module_cfg *m_cfg;int ret, dma_id;dev_dbg (dai->dev,"%s: %s\n" , __func__, dai->name);
@@ -228,6 +231,16 @@ static int skl_pcm_hw_params(struct snd_pcm_substream *substream, dma_id =hdac_stream (stream)->stream_tag -1 ;dev_dbg (dai->dev,"dma_id=%d\n" , dma_id); + 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.host_dma_id = dma_id; + p_params.stream = substream->stream; + + m_cfg =skl_tplg_fe_get_cpr_module (dai, p_params.stream); +if (m_cfg) +skl_tplg_update_pipe_params (dai->dev, m_cfg, &p_params); +return 0 ; }
@@ -268,6 +281,46 @@ static int skl_pcm_hw_free(struct snd_pcm_substream *substream,return skl_substream_free_pages (ebus_to_hbus (ebus), substream); } +static int skl_be_hw_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params, +struct snd_soc_dai *dai) +{ +struct skl_pipe_params p_params = {0 }; + + 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; +skl_tplg_be_update_params (dai, &p_params); + +return 0 ; +} + +static int skl_pcm_trigger (struct snd_pcm_substream *substream,int cmd, +struct snd_soc_dai *dai) +{ +struct skl *skl =get_skl_ctx (dai->dev); +struct skl_sst *ctx = skl->skl_sst; +struct skl_module_cfg *mconfig; + + mconfig =skl_tplg_fe_get_cpr_module (dai, substream->stream); +if (!mconfig) +return -EIO ; + +switch (cmd) { +case SNDRV_PCM_TRIGGER_PAUSE_RELEASE : +case SNDRV_PCM_TRIGGER_RESUME : +return skl_run_pipe (ctx, mconfig->pipe); + +case SNDRV_PCM_TRIGGER_PAUSE_PUSH : +case SNDRV_PCM_TRIGGER_SUSPEND : +return skl_stop_pipe (ctx, mconfig->pipe); + +default : +return 0 ; + } +} +static int skl_link_hw_params (struct snd_pcm_substream *substream,struct snd_pcm_hw_params *params,struct snd_soc_dai *dai)
@@ -277,9 +330,8 @@ static int skl_link_hw_params(struct snd_pcm_substream *substream,struct snd_soc_pcm_runtime *rtd =snd_pcm_substream_chip (substream);struct skl_dma_params *dma_params;struct snd_soc_dai *codec_dai = rtd->codec_dai; -int dma_id; +struct skl_pipe_params p_params = {0 }; -pr_debug ("%s\n" , __func__); link_dev =snd_hdac_ext_stream_assign (ebus, substream,HDAC_EXT_STREAM_TYPE_LINK );if (!link_dev)
@@ -293,7 +345,14 @@ static int skl_link_hw_params(struct snd_pcm_substream *substream,if (dma_params) dma_params->stream_tag =hdac_stream (link_dev)->stream_tag;snd_soc_dai_set_dma_data (codec_dai, substream, (void *)dma_params); - dma_id =hdac_stream (link_dev)->stream_tag -1 ; + + 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_dma_id =hdac_stream (link_dev)->stream_tag -1 ; + +skl_tplg_be_update_params (dai, &p_params);return 0 ; }
@@ -308,27 +367,12 @@ static int skl_link_pcm_prepare(struct snd_pcm_substream *substream,unsigned int format_val =0 ;struct skl_dma_params *dma_params;struct snd_soc_dai *codec_dai = rtd->codec_dai; -struct snd_pcm_hw_params *params; -struct snd_interval *channels, *rate;struct hdac_ext_link *link; -dev_dbg (dai->dev,"%s: %s\n" , __func__, dai->name);if (link_dev->link_prepared) {dev_dbg (dai->dev,"already stream is prepared - returning\n" );return 0 ; } - params =devm_kzalloc (dai->dev,sizeof (*params),GFP_KERNEL ); -if (params ==NULL ) -return -ENOMEM ; - - channels =hw_param_interval (params,SNDRV_PCM_HW_PARAM_CHANNELS ); - channels->min = channels->max = substream->runtime->channels; - rate =hw_param_interval (params,SNDRV_PCM_HW_PARAM_RATE ); - rate->min = rate->max = substream->runtime->rate; -snd_mask_set (¶ms->masks[SNDRV_PCM_HW_PARAM_FORMAT - -SNDRV_PCM_HW_PARAM_FIRST_MASK ], - substream->runtime->format); - dma_params = (struct skl_dma_params *)snd_soc_dai_get_dma_data (codec_dai, substream);
@@ -399,13 +443,13 @@ static int skl_link_hw_free(struct snd_pcm_substream *substream,return 0 ; } -static int skl_hda_be_startup (struct snd_pcm_substream *substream, +static int skl_be_startup (struct snd_pcm_substream *substream,struct snd_soc_dai *dai) {return pm_runtime_get_sync (dai->dev); } -static void skl_hda_be_shutdown (struct snd_pcm_substream *substream, +static void skl_be_shutdown (struct snd_pcm_substream *substream,struct snd_soc_dai *dai) {pm_runtime_mark_last_busy (dai->dev);
@@ -418,20 +462,28 @@ static struct snd_soc_dai_ops skl_pcm_dai_ops = { .prepare = skl_pcm_prepare, .hw_params = skl_pcm_hw_params, .hw_free = skl_pcm_hw_free, + .trigger = skl_pcm_trigger, };static struct snd_soc_dai_ops skl_dmic_dai_ops = { - .startup = skl_hda_be_startup, - .shutdown = skl_hda_be_shutdown, + .startup = skl_be_startup, + .hw_params = skl_be_hw_params, + .shutdown = skl_be_shutdown, +}; + +static struct snd_soc_dai_ops skl_be_ssp_dai_ops = { + .startup = skl_be_startup, + .hw_params = skl_be_hw_params, + .shutdown = skl_be_shutdown, };static struct snd_soc_dai_ops skl_link_dai_ops = { - .startup = skl_hda_be_startup, + .startup = skl_be_startup, .prepare = skl_link_pcm_prepare, .hw_params = skl_link_hw_params, .hw_free = skl_link_hw_free, .trigger = skl_link_pcm_trigger, - .shutdown = skl_hda_be_shutdown, + .shutdown = skl_be_shutdown, };static struct snd_soc_dai_driver skl_platform_dai[] = {
@@ -488,6 +540,24 @@ static struct snd_soc_dai_driver skl_platform_dai[] = { },/* BE CPU Dais */ { + .name = "SSP0 Pin", + .ops = &skl_be_ssp_dai_ops, + .playback = { + .stream_name = "ssp0 Tx", + .channels_min = HDA_STEREO, + .channels_max = HDA_STEREO, + .rates = SNDRV_PCM_RATE_48000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + }, + .capture = { + .stream_name = "ssp0 Rx", + .channels_min = HDA_STEREO, + .channels_max = HDA_STEREO, + .rates = SNDRV_PCM_RATE_48000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + }, +}, +{ .name = "iDisp Pin", .ops = &skl_link_dai_ops, .playback = {
@@ -544,7 +614,7 @@ static int skl_platform_open(struct snd_pcm_substream *substream)return 0 ; } -static int skl_pcm_trigger (struct snd_pcm_substream *substream, +static int skl_coupled_trigger (struct snd_pcm_substream *substream,int cmd) {struct hdac_ext_bus *ebus =get_bus_ctx (substream);
@@ -618,7 +688,7 @@ static int skl_pcm_trigger(struct snd_pcm_substream *substream,return 0 ; } -static int skl_dsp_trigger (struct snd_pcm_substream *substream, +static int skl_decoupled_trigger (struct snd_pcm_substream *substream,int cmd) {struct hdac_ext_bus *ebus =get_bus_ctx (substream);
@@ -675,9 +745,9 @@ static int skl_platform_pcm_trigger(struct snd_pcm_substream *substream,struct hdac_ext_bus *ebus =get_bus_ctx (substream);if (ebus->ppcap) -return skl_dsp_trigger (substream, cmd); +return skl_decoupled_trigger (substream, cmd);else -return skl_pcm_trigger (substream, cmd); +return skl_coupled_trigger (substream, cmd); }/* calculate runtime delay from LPIB */
@@ -844,7 +914,17 @@ static int skl_pcm_new(struct snd_soc_pcm_runtime *rtd)return retval; } +static int skl_platform_soc_probe (struct snd_soc_platform *platform) +{ +struct hdac_ext_bus *ebus =dev_get_drvdata (platform->dev); + +if (ebus->ppcap) +return skl_tplg_init (platform, ebus); + +return 0 ; +}static struct snd_soc_platform_driver skl_platform_drv = { + .probe = skl_platform_soc_probe, .ops = &skl_platform_ops, .pcm_new = skl_pcm_new, .pcm_free = skl_pcm_free,
@@ -857,6 +937,11 @@ static const struct snd_soc_component_driver skl_component = {int skl_platform_register (struct device *dev) {int ret; +struct hdac_ext_bus *ebus =dev_get_drvdata (dev); +struct skl *skl =ebus_to_skl (ebus); + +INIT_LIST_HEAD (&skl->ppl_list); +INIT_LIST_HEAD (&skl->dapm_path_list); ret =snd_soc_register_platform (dev, &skl_platform_drv);if (ret) {
sound/soc/intel/skylake/skl-topology.c +23 -16
@@ -1089,8 +1089,8 @@ static struct skl_pipe *skl_tplg_add_pipe(struct device *dev,* FW expects like ids, resource values, formats etc */ static int skl_tplg_widget_load (struct snd_soc_component *cmpnt, -struct snd_soc_dapm_widget *w, -struct snd_soc_tplg_dapm_widget *tplg_w) +struct snd_soc_dapm_widget *w, +struct snd_soc_tplg_dapm_widget *tplg_w) {int ret;struct hdac_ext_bus *ebus =snd_soc_component_get_drvdata (cmpnt);
@@ -1098,7 +1098,8 @@ static int skl_tplg_widget_load(struct snd_soc_component *cmpnt,struct hdac_bus *bus =ebus_to_hbus (ebus);struct skl_module_cfg *mconfig;struct skl_pipe *pipe; -struct skl_dfw_module *dfw_config = (struct skl_dfw_module *)tplg_w->priv.data; +struct skl_dfw_module *dfw_config = + (struct skl_dfw_module *)tplg_w->priv.data;if (!tplg_w->priv.size) goto bind_event;
@@ -1121,12 +1122,14 @@ static int skl_tplg_widget_load(struct snd_soc_component *cmpnt, mconfig->in_fmt.channels = dfw_config->in_fmt.channels; mconfig->in_fmt.s_freq = dfw_config->in_fmt.freq; mconfig->in_fmt.bit_depth = dfw_config->in_fmt.bit_depth; - mconfig->in_fmt.valid_bit_depth = dfw_config->in_fmt.valid_bit_depth; + mconfig->in_fmt.valid_bit_depth = + dfw_config->in_fmt.valid_bit_depth; mconfig->in_fmt.ch_cfg = dfw_config->in_fmt.ch_cfg; mconfig->out_fmt.channels = dfw_config->out_fmt.channels; mconfig->out_fmt.s_freq = dfw_config->out_fmt.freq; mconfig->out_fmt.bit_depth = dfw_config->out_fmt.bit_depth; - mconfig->out_fmt.valid_bit_depth = dfw_config->out_fmt.valid_bit_depth; + mconfig->out_fmt.valid_bit_depth = + dfw_config->out_fmt.valid_bit_depth; mconfig->out_fmt.ch_cfg = dfw_config->out_fmt.ch_cfg; mconfig->params_fixup = dfw_config->params_fixup; mconfig->converter = dfw_config->converter;
@@ -1142,15 +1145,17 @@ static int skl_tplg_widget_load(struct snd_soc_component *cmpnt, mconfig->time_slot = dfw_config->time_slot; mconfig->formats_config.caps_size = dfw_config->caps.caps_size; - mconfig->m_in_pin =devm_kzalloc (bus->dev, (mconfig->max_in_queue) * -sizeof (*mconfig->m_in_pin), -GFP_KERNEL ); + mconfig->m_in_pin =devm_kzalloc (bus->dev, + (mconfig->max_in_queue) * +sizeof (*mconfig->m_in_pin), +GFP_KERNEL );if (!mconfig->m_in_pin)return -ENOMEM ; - mconfig->m_out_pin =devm_kzalloc (bus->dev, (mconfig->max_in_queue) * -sizeof (*mconfig->m_out_pin), -GFP_KERNEL ); + mconfig->m_out_pin =devm_kzalloc (bus->dev, + (mconfig->max_in_queue) * +sizeof (*mconfig->m_out_pin), +GFP_KERNEL );if (!mconfig->m_out_pin)return -ENOMEM ;
@@ -1163,13 +1168,13 @@ static int skl_tplg_widget_load(struct snd_soc_component *cmpnt, goto bind_event; mconfig->formats_config.caps = (u32 *)devm_kzalloc (bus->dev, - mconfig->formats_config.caps_size,GFP_KERNEL ); + mconfig->formats_config.caps_size,GFP_KERNEL );if (mconfig->formats_config.caps ==NULL )return -ENOMEM ;memcpy (mconfig->formats_config.caps, dfw_config->caps.caps, - dfw_config->caps.caps_size); + dfw_config->caps.caps_size); bind_event:if (tplg_w->event_type ==0 ) {
@@ -1178,7 +1183,8 @@ bind_event: } ret =snd_soc_tplg_widget_bind_event (w, skl_tplg_widget_ops, -ARRAY_SIZE (skl_tplg_widget_ops), tplg_w->event_type); +ARRAY_SIZE (skl_tplg_widget_ops), + tplg_w->event_type);if (ret) { dev_err(bus->dev, "%s: No matching event handlers found for %d\n",
@@ -1209,7 +1215,7 @@ int skl_tplg_init(struct snd_soc_platform *platform, struct hdac_ext_bus *ebus) ret =request_firmware (&fw,"dfw_sst.bin" , bus->dev);if (ret <0 ) { -dev_err (bus->dev,"config firmware %s request failed with %d\n" , +dev_err (bus->dev,"tplg fw %s load failed with %d\n" ,"dfw_sst.bin" , ret);return ret; }
@@ -1218,7 +1224,8 @@ int skl_tplg_init(struct snd_soc_platform *platform, struct hdac_ext_bus *ebus)* The complete tplg for SKL is loaded as index 0, we don't use * any other index */ - ret =snd_soc_tplg_component_load (&platform->component, &skl_tplg_ops, fw,0 ); + ret =snd_soc_tplg_component_load (&platform->component, + &skl_tplg_ops, fw,0 );if (ret <0 ) {dev_err (bus->dev,"tplg component load failed%d\n" , ret);return -EINVAL ;
Signature · 1 line
2.4.3
Mark Brown
maintainerApplied "ASoC: Intel: Skylake: Initialize and load DSP controls" to the asoc tree
The patch
ASoC: Intel: Skylake: Initialize and load DSP controls
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
b663a8c5c9c043c47e5e0eea9f9c77ea88fbe67aMon Sep 17 00:00:00 2001
From: Jeeja KP <[email protected]>
Date: Wed, 7 Oct 2015 11:31:57 +0100
Subject: [PATCH] ASoC: Intel: Skylake: Initialize and load DSP controls
Initialize and creates DSP controls if processing pipe capability is supported by HW. Updates the dma_id, hw_params to module param to be used when DSP module has to be configured.
--- sound/soc/intel/skylake/skl-pcm.c | 141 ++++++++++++++++++++++++++------- sound/soc/intel/skylake/skl-topology.c | 39 +++++---- 2 files changed, 136 insertions(+), 44 deletions(-)
sound/soc/intel/skylake/skl-pcm.c +113 -28
@@ -24,6 +24,7 @@#include <sound/pcm_params.h> #include <sound/soc.h> #include "skl.h" +#include "skl-topology.h" #define HDA_MONO 1#define HDA_STEREO 2
@@ -214,6 +215,8 @@ static int skl_pcm_hw_params(struct snd_pcm_substream *substream,struct hdac_ext_bus *ebus =dev_get_drvdata (dai->dev);struct hdac_ext_stream *stream =get_hdac_ext_stream (substream);struct snd_pcm_runtime *runtime = substream->runtime; +struct skl_pipe_params p_params = {0 }; +struct skl_module_cfg *m_cfg;int ret, dma_id;dev_dbg (dai->dev,"%s: %s\n" , __func__, dai->name);
@@ -228,6 +231,16 @@ static int skl_pcm_hw_params(struct snd_pcm_substream *substream, dma_id =hdac_stream (stream)->stream_tag -1 ;dev_dbg (dai->dev,"dma_id=%d\n" , dma_id); + 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.host_dma_id = dma_id; + p_params.stream = substream->stream; + + m_cfg =skl_tplg_fe_get_cpr_module (dai, p_params.stream); +if (m_cfg) +skl_tplg_update_pipe_params (dai->dev, m_cfg, &p_params); +return 0 ; }
@@ -268,6 +281,46 @@ static int skl_pcm_hw_free(struct snd_pcm_substream *substream,return skl_substream_free_pages (ebus_to_hbus (ebus), substream); } +static int skl_be_hw_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params, +struct snd_soc_dai *dai) +{ +struct skl_pipe_params p_params = {0 }; + + 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; +skl_tplg_be_update_params (dai, &p_params); + +return 0 ; +} + +static int skl_pcm_trigger (struct snd_pcm_substream *substream,int cmd, +struct snd_soc_dai *dai) +{ +struct skl *skl =get_skl_ctx (dai->dev); +struct skl_sst *ctx = skl->skl_sst; +struct skl_module_cfg *mconfig; + + mconfig =skl_tplg_fe_get_cpr_module (dai, substream->stream); +if (!mconfig) +return -EIO ; + +switch (cmd) { +case SNDRV_PCM_TRIGGER_PAUSE_RELEASE : +case SNDRV_PCM_TRIGGER_RESUME : +return skl_run_pipe (ctx, mconfig->pipe); + +case SNDRV_PCM_TRIGGER_PAUSE_PUSH : +case SNDRV_PCM_TRIGGER_SUSPEND : +return skl_stop_pipe (ctx, mconfig->pipe); + +default : +return 0 ; + } +} +static int skl_link_hw_params (struct snd_pcm_substream *substream,struct snd_pcm_hw_params *params,struct snd_soc_dai *dai)
@@ -277,9 +330,8 @@ static int skl_link_hw_params(struct snd_pcm_substream *substream,struct snd_soc_pcm_runtime *rtd =snd_pcm_substream_chip (substream);struct skl_dma_params *dma_params;struct snd_soc_dai *codec_dai = rtd->codec_dai; -int dma_id; +struct skl_pipe_params p_params = {0 }; -pr_debug ("%s\n" , __func__); link_dev =snd_hdac_ext_stream_assign (ebus, substream,HDAC_EXT_STREAM_TYPE_LINK );if (!link_dev)
@@ -293,7 +345,14 @@ static int skl_link_hw_params(struct snd_pcm_substream *substream,if (dma_params) dma_params->stream_tag =hdac_stream (link_dev)->stream_tag;snd_soc_dai_set_dma_data (codec_dai, substream, (void *)dma_params); - dma_id =hdac_stream (link_dev)->stream_tag -1 ; + + 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_dma_id =hdac_stream (link_dev)->stream_tag -1 ; + +skl_tplg_be_update_params (dai, &p_params);return 0 ; }
@@ -308,27 +367,12 @@ static int skl_link_pcm_prepare(struct snd_pcm_substream *substream,unsigned int format_val =0 ;struct skl_dma_params *dma_params;struct snd_soc_dai *codec_dai = rtd->codec_dai; -struct snd_pcm_hw_params *params; -struct snd_interval *channels, *rate;struct hdac_ext_link *link; -dev_dbg (dai->dev,"%s: %s\n" , __func__, dai->name);if (link_dev->link_prepared) {dev_dbg (dai->dev,"already stream is prepared - returning\n" );return 0 ; } - params =devm_kzalloc (dai->dev,sizeof (*params),GFP_KERNEL ); -if (params ==NULL ) -return -ENOMEM ; - - channels =hw_param_interval (params,SNDRV_PCM_HW_PARAM_CHANNELS ); - channels->min = channels->max = substream->runtime->channels; - rate =hw_param_interval (params,SNDRV_PCM_HW_PARAM_RATE ); - rate->min = rate->max = substream->runtime->rate; -snd_mask_set (¶ms->masks[SNDRV_PCM_HW_PARAM_FORMAT - -SNDRV_PCM_HW_PARAM_FIRST_MASK ], - substream->runtime->format); - dma_params = (struct skl_dma_params *)snd_soc_dai_get_dma_data (codec_dai, substream);
@@ -399,13 +443,13 @@ static int skl_link_hw_free(struct snd_pcm_substream *substream,return 0 ; } -static int skl_hda_be_startup (struct snd_pcm_substream *substream, +static int skl_be_startup (struct snd_pcm_substream *substream,struct snd_soc_dai *dai) {return pm_runtime_get_sync (dai->dev); } -static void skl_hda_be_shutdown (struct snd_pcm_substream *substream, +static void skl_be_shutdown (struct snd_pcm_substream *substream,struct snd_soc_dai *dai) {pm_runtime_mark_last_busy (dai->dev);
@@ -418,20 +462,28 @@ static struct snd_soc_dai_ops skl_pcm_dai_ops = { .prepare = skl_pcm_prepare, .hw_params = skl_pcm_hw_params, .hw_free = skl_pcm_hw_free, + .trigger = skl_pcm_trigger, };static struct snd_soc_dai_ops skl_dmic_dai_ops = { - .startup = skl_hda_be_startup, - .shutdown = skl_hda_be_shutdown, + .startup = skl_be_startup, + .hw_params = skl_be_hw_params, + .shutdown = skl_be_shutdown, +}; + +static struct snd_soc_dai_ops skl_be_ssp_dai_ops = { + .startup = skl_be_startup, + .hw_params = skl_be_hw_params, + .shutdown = skl_be_shutdown, };static struct snd_soc_dai_ops skl_link_dai_ops = { - .startup = skl_hda_be_startup, + .startup = skl_be_startup, .prepare = skl_link_pcm_prepare, .hw_params = skl_link_hw_params, .hw_free = skl_link_hw_free, .trigger = skl_link_pcm_trigger, - .shutdown = skl_hda_be_shutdown, + .shutdown = skl_be_shutdown, };static struct snd_soc_dai_driver skl_platform_dai[] = {
@@ -488,6 +540,24 @@ static struct snd_soc_dai_driver skl_platform_dai[] = { },/* BE CPU Dais */ { + .name = "SSP0 Pin", + .ops = &skl_be_ssp_dai_ops, + .playback = { + .stream_name = "ssp0 Tx", + .channels_min = HDA_STEREO, + .channels_max = HDA_STEREO, + .rates = SNDRV_PCM_RATE_48000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + }, + .capture = { + .stream_name = "ssp0 Rx", + .channels_min = HDA_STEREO, + .channels_max = HDA_STEREO, + .rates = SNDRV_PCM_RATE_48000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + }, +}, +{ .name = "iDisp Pin", .ops = &skl_link_dai_ops, .playback = {
@@ -544,7 +614,7 @@ static int skl_platform_open(struct snd_pcm_substream *substream)return 0 ; } -static int skl_pcm_trigger (struct snd_pcm_substream *substream, +static int skl_coupled_trigger (struct snd_pcm_substream *substream,int cmd) {struct hdac_ext_bus *ebus =get_bus_ctx (substream);
@@ -618,7 +688,7 @@ static int skl_pcm_trigger(struct snd_pcm_substream *substream,return 0 ; } -static int skl_dsp_trigger (struct snd_pcm_substream *substream, +static int skl_decoupled_trigger (struct snd_pcm_substream *substream,int cmd) {struct hdac_ext_bus *ebus =get_bus_ctx (substream);
@@ -675,9 +745,9 @@ static int skl_platform_pcm_trigger(struct snd_pcm_substream *substream,struct hdac_ext_bus *ebus =get_bus_ctx (substream);if (ebus->ppcap) -return skl_dsp_trigger (substream, cmd); +return skl_decoupled_trigger (substream, cmd);else -return skl_pcm_trigger (substream, cmd); +return skl_coupled_trigger (substream, cmd); }/* calculate runtime delay from LPIB */
@@ -844,7 +914,17 @@ static int skl_pcm_new(struct snd_soc_pcm_runtime *rtd)return retval; } +static int skl_platform_soc_probe (struct snd_soc_platform *platform) +{ +struct hdac_ext_bus *ebus =dev_get_drvdata (platform->dev); + +if (ebus->ppcap) +return skl_tplg_init (platform, ebus); + +return 0 ; +}static struct snd_soc_platform_driver skl_platform_drv = { + .probe = skl_platform_soc_probe, .ops = &skl_platform_ops, .pcm_new = skl_pcm_new, .pcm_free = skl_pcm_free,
@@ -857,6 +937,11 @@ static const struct snd_soc_component_driver skl_component = {int skl_platform_register (struct device *dev) {int ret; +struct hdac_ext_bus *ebus =dev_get_drvdata (dev); +struct skl *skl =ebus_to_skl (ebus); + +INIT_LIST_HEAD (&skl->ppl_list); +INIT_LIST_HEAD (&skl->dapm_path_list); ret =snd_soc_register_platform (dev, &skl_platform_drv);if (ret) {
sound/soc/intel/skylake/skl-topology.c +23 -16
@@ -1089,8 +1089,8 @@ static struct skl_pipe *skl_tplg_add_pipe(struct device *dev,* FW expects like ids, resource values, formats etc */ static int skl_tplg_widget_load (struct snd_soc_component *cmpnt, -struct snd_soc_dapm_widget *w, -struct snd_soc_tplg_dapm_widget *tplg_w) +struct snd_soc_dapm_widget *w, +struct snd_soc_tplg_dapm_widget *tplg_w) {int ret;struct hdac_ext_bus *ebus =snd_soc_component_get_drvdata (cmpnt);
@@ -1098,7 +1098,8 @@ static int skl_tplg_widget_load(struct snd_soc_component *cmpnt,struct hdac_bus *bus =ebus_to_hbus (ebus);struct skl_module_cfg *mconfig;struct skl_pipe *pipe; -struct skl_dfw_module *dfw_config = (struct skl_dfw_module *)tplg_w->priv.data; +struct skl_dfw_module *dfw_config = + (struct skl_dfw_module *)tplg_w->priv.data;if (!tplg_w->priv.size) goto bind_event;
@@ -1121,12 +1122,14 @@ static int skl_tplg_widget_load(struct snd_soc_component *cmpnt, mconfig->in_fmt.channels = dfw_config->in_fmt.channels; mconfig->in_fmt.s_freq = dfw_config->in_fmt.freq; mconfig->in_fmt.bit_depth = dfw_config->in_fmt.bit_depth; - mconfig->in_fmt.valid_bit_depth = dfw_config->in_fmt.valid_bit_depth; + mconfig->in_fmt.valid_bit_depth = + dfw_config->in_fmt.valid_bit_depth; mconfig->in_fmt.ch_cfg = dfw_config->in_fmt.ch_cfg; mconfig->out_fmt.channels = dfw_config->out_fmt.channels; mconfig->out_fmt.s_freq = dfw_config->out_fmt.freq; mconfig->out_fmt.bit_depth = dfw_config->out_fmt.bit_depth; - mconfig->out_fmt.valid_bit_depth = dfw_config->out_fmt.valid_bit_depth; + mconfig->out_fmt.valid_bit_depth = + dfw_config->out_fmt.valid_bit_depth; mconfig->out_fmt.ch_cfg = dfw_config->out_fmt.ch_cfg; mconfig->params_fixup = dfw_config->params_fixup; mconfig->converter = dfw_config->converter;
@@ -1142,15 +1145,17 @@ static int skl_tplg_widget_load(struct snd_soc_component *cmpnt, mconfig->time_slot = dfw_config->time_slot; mconfig->formats_config.caps_size = dfw_config->caps.caps_size; - mconfig->m_in_pin =devm_kzalloc (bus->dev, (mconfig->max_in_queue) * -sizeof (*mconfig->m_in_pin), -GFP_KERNEL ); + mconfig->m_in_pin =devm_kzalloc (bus->dev, + (mconfig->max_in_queue) * +sizeof (*mconfig->m_in_pin), +GFP_KERNEL );if (!mconfig->m_in_pin)return -ENOMEM ; - mconfig->m_out_pin =devm_kzalloc (bus->dev, (mconfig->max_in_queue) * -sizeof (*mconfig->m_out_pin), -GFP_KERNEL ); + mconfig->m_out_pin =devm_kzalloc (bus->dev, + (mconfig->max_in_queue) * +sizeof (*mconfig->m_out_pin), +GFP_KERNEL );if (!mconfig->m_out_pin)return -ENOMEM ;
@@ -1163,13 +1168,13 @@ static int skl_tplg_widget_load(struct snd_soc_component *cmpnt, goto bind_event; mconfig->formats_config.caps = (u32 *)devm_kzalloc (bus->dev, - mconfig->formats_config.caps_size,GFP_KERNEL ); + mconfig->formats_config.caps_size,GFP_KERNEL );if (mconfig->formats_config.caps ==NULL )return -ENOMEM ;memcpy (mconfig->formats_config.caps, dfw_config->caps.caps, - dfw_config->caps.caps_size); + dfw_config->caps.caps_size); bind_event:if (tplg_w->event_type ==0 ) {
@@ -1178,7 +1183,8 @@ bind_event: } ret =snd_soc_tplg_widget_bind_event (w, skl_tplg_widget_ops, -ARRAY_SIZE (skl_tplg_widget_ops), tplg_w->event_type); +ARRAY_SIZE (skl_tplg_widget_ops), + tplg_w->event_type);if (ret) { dev_err(bus->dev, "%s: No matching event handlers found for %d\n",
@@ -1209,7 +1215,7 @@ int skl_tplg_init(struct snd_soc_platform *platform, struct hdac_ext_bus *ebus) ret =request_firmware (&fw,"dfw_sst.bin" , bus->dev);if (ret <0 ) { -dev_err (bus->dev,"config firmware %s request failed with %d\n" , +dev_err (bus->dev,"tplg fw %s load failed with %d\n" ,"dfw_sst.bin" , ret);return ret; }
@@ -1218,7 +1224,8 @@ int skl_tplg_init(struct snd_soc_platform *platform, struct hdac_ext_bus *ebus)* The complete tplg for SKL is loaded as index 0, we don't use * any other index */ - ret =snd_soc_tplg_component_load (&platform->component, &skl_tplg_ops, fw,0 ); + ret =snd_soc_tplg_component_load (&platform->component, + &skl_tplg_ops, fw,0 );if (ret <0 ) {dev_err (bus->dev,"tplg component load failed%d\n" , ret);return -EINVAL ;
Signature · 1 line
2.5.0
PATCH v4 7/8 ASoC: Intel: Skylake: Add DSP support and enable it
In reply to Vinod KoulFrom: Jeeja KP <[email protected]>
If processing pipe capability is supported, add DSP support. Adds initialization/free/suspend/resume DSP functionality.
--- sound/soc/intel/skylake/skl.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)
sound/soc/intel/skylake/skl.c +17 -7
@@ -166,11 +166,16 @@ static int skl_runtime_suspend(struct device *dev)struct pci_dev *pci =to_pci_dev (dev);struct hdac_ext_bus *ebus =pci_get_drvdata (pci);struct hdac_bus *bus =ebus_to_hbus (ebus); +struct skl *skl =ebus_to_skl (ebus); +int ret;dev_dbg (bus->dev,"in %s\n" , __func__);/* enable controller wake up event */ snd_hdac_chip_updatew (bus,WAKEEN ,0 ,STATESTS_INT_MASK ); + ret =skl_suspend_dsp (skl); +if (ret <0 ) +return ret;snd_hdac_bus_stop_chip (bus);snd_hdac_bus_enter_link_reset (bus);
@@ -183,7 +188,7 @@ static int skl_runtime_resume(struct device *dev)struct pci_dev *pci =to_pci_dev (dev);struct hdac_ext_bus *ebus =pci_get_drvdata (pci);struct hdac_bus *bus =ebus_to_hbus (ebus); -struct skl *hda =ebus_to_skl (ebus); +struct skl *skl =ebus_to_skl (ebus);int status;dev_dbg (bus->dev,"in %s\n" , __func__);
@@ -191,12 +196,12 @@ static int skl_runtime_resume(struct device *dev)/* Read STATESTS before controller reset */ status =snd_hdac_chip_readw (bus,STATESTS ); -skl_init_pci (hda); +skl_init_pci (skl);snd_hdac_bus_init_chip (bus, true);/* disable controller Wake Up event */ snd_hdac_chip_updatew (bus,WAKEEN ,STATESTS_INT_MASK ,0 ); - return 0; + return skl_resume_dsp(skl); }#endif /* CONFIG_PM */
@@ -457,17 +462,19 @@ static int skl_probe(struct pci_dev *pci,/* check if dsp is there */ if (ebus->ppcap) { -/* TODO register with dsp IPC */ -dev_dbg (bus->dev,"Register dsp\n" ); + err =skl_init_dsp (skl); +if (err <0 ) { +dev_dbg (bus->dev,"error failed to register dsp\n" ); + goto out_free; + } } -if (ebus->mlcap)snd_hdac_ext_bus_get_ml_capabilities (ebus);/* create device for soc dmic */ err =skl_dmic_device_register (skl);if (err <0 ) - goto out_free; + goto out_dsp_free;/* register platform dai and controls */ err =skl_platform_register (bus->dev);
@@ -491,6 +498,8 @@ out_unregister:skl_platform_unregister (bus->dev); out_dmic_free:skl_dmic_device_unregister (skl); +out_dsp_free: +skl_free_dsp (skl); out_free: skl->init_failed =1 ;skl_free (ebus);
@@ -507,6 +516,7 @@ static void skl_remove(struct pci_dev *pci)pm_runtime_get_noresume (&pci->dev);pci_dev_put (pci);skl_platform_unregister (&pci->dev); +skl_free_dsp (skl);skl_dmic_device_unregister (skl);skl_free (ebus);dev_set_drvdata (&pci->dev,NULL );
Signature · 1 line
2.4.3
PATCH v4 8/8 ASoC: Intel: Skylake: Initialize NHLT table
In reply to Vinod KoulFrom: Jeeja KP <[email protected]>
Load and Initialize Non HDA Link Table in Skylake driver to get platform configuration.
--- sound/soc/intel/skylake/skl.c | 5 +++++ 1 file changed, 5 insertions(+)
sound/soc/intel/skylake/skl.c +5 -0
@@ -458,6 +458,11 @@ static int skl_probe(struct pci_dev *pci,if (err <0 ) goto out_free; + skl->nhlt =skl_nhlt_init (bus->dev); + +if (skl->nhlt ==NULL ) + goto out_free; +pci_set_drvdata (skl->pci, ebus);/* check if dsp is there */
Signature · 1 line
2.4.3