| .. | .. | 
|---|
|  | 1 | +// SPDX-License-Identifier: GPL-2.0-only | 
|---|
| 1 | 2 | /* | 
|---|
| 2 | 3 | *  skl-topology.c - Implements Platform component ALSA controls/widget | 
|---|
| 3 | 4 | *  handlers. | 
|---|
| .. | .. | 
|---|
| 5 | 6 | *  Copyright (C) 2014-2015 Intel Corp | 
|---|
| 6 | 7 | *  Author: Jeeja KP <jeeja.kp@intel.com> | 
|---|
| 7 | 8 | *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 
|---|
| 8 |  | - * | 
|---|
| 9 |  | - * This program is free software; you can redistribute it and/or modify | 
|---|
| 10 |  | - * it under the terms of the GNU General Public License as version 2, as | 
|---|
| 11 |  | - * published by the Free Software Foundation. | 
|---|
| 12 |  | - * | 
|---|
| 13 |  | - * This program is distributed in the hope that it will be useful, but | 
|---|
| 14 |  | - * WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 15 |  | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
|---|
| 16 |  | - * General Public License for more details. | 
|---|
| 17 | 9 | */ | 
|---|
| 18 | 10 |  | 
|---|
| 19 | 11 | #include <linux/slab.h> | 
|---|
| 20 | 12 | #include <linux/types.h> | 
|---|
| 21 | 13 | #include <linux/firmware.h> | 
|---|
| 22 | 14 | #include <linux/uuid.h> | 
|---|
|  | 15 | +#include <sound/intel-nhlt.h> | 
|---|
| 23 | 16 | #include <sound/soc.h> | 
|---|
|  | 17 | +#include <sound/soc-acpi.h> | 
|---|
| 24 | 18 | #include <sound/soc-topology.h> | 
|---|
| 25 | 19 | #include <uapi/sound/snd_sst_tokens.h> | 
|---|
| 26 | 20 | #include <uapi/sound/skl-tplg-interface.h> | 
|---|
| .. | .. | 
|---|
| 53 | 47 | #define CHECK_HW_PARAMS(ch, freq, bps, prm_ch, prm_freq, prm_bps) \ | 
|---|
| 54 | 48 | ((ch == prm_ch) && (bps == prm_bps) && (freq == prm_freq)) | 
|---|
| 55 | 49 |  | 
|---|
| 56 |  | -void skl_tplg_d0i3_get(struct skl *skl, enum d0i3_capability caps) | 
|---|
|  | 50 | +void skl_tplg_d0i3_get(struct skl_dev *skl, enum d0i3_capability caps) | 
|---|
| 57 | 51 | { | 
|---|
| 58 |  | -	struct skl_d0i3_data *d0i3 =  &skl->skl_sst->d0i3; | 
|---|
|  | 52 | +	struct skl_d0i3_data *d0i3 =  &skl->d0i3; | 
|---|
| 59 | 53 |  | 
|---|
| 60 | 54 | switch (caps) { | 
|---|
| 61 | 55 | case SKL_D0I3_NONE: | 
|---|
| .. | .. | 
|---|
| 72 | 66 | } | 
|---|
| 73 | 67 | } | 
|---|
| 74 | 68 |  | 
|---|
| 75 |  | -void skl_tplg_d0i3_put(struct skl *skl, enum d0i3_capability caps) | 
|---|
|  | 69 | +void skl_tplg_d0i3_put(struct skl_dev *skl, enum d0i3_capability caps) | 
|---|
| 76 | 70 | { | 
|---|
| 77 |  | -	struct skl_d0i3_data *d0i3 =  &skl->skl_sst->d0i3; | 
|---|
|  | 71 | +	struct skl_d0i3_data *d0i3 =  &skl->d0i3; | 
|---|
| 78 | 72 |  | 
|---|
| 79 | 73 | switch (caps) { | 
|---|
| 80 | 74 | case SKL_D0I3_NONE: | 
|---|
| .. | .. | 
|---|
| 117 | 111 | } | 
|---|
| 118 | 112 | } | 
|---|
| 119 | 113 |  | 
|---|
| 120 |  | -/* | 
|---|
| 121 |  | - * Each pipelines needs memory to be allocated. Check if we have free memory | 
|---|
| 122 |  | - * from available pool. | 
|---|
| 123 |  | - */ | 
|---|
| 124 |  | -static bool skl_is_pipe_mem_avail(struct skl *skl, | 
|---|
| 125 |  | -				struct skl_module_cfg *mconfig) | 
|---|
|  | 114 | +static void skl_dump_mconfig(struct skl_dev *skl, struct skl_module_cfg *mcfg) | 
|---|
| 126 | 115 | { | 
|---|
| 127 |  | -	struct skl_sst *ctx = skl->skl_sst; | 
|---|
|  | 116 | +	struct skl_module_iface *iface = &mcfg->module->formats[mcfg->fmt_idx]; | 
|---|
| 128 | 117 |  | 
|---|
| 129 |  | -	if (skl->resource.mem + mconfig->pipe->memory_pages > | 
|---|
| 130 |  | -				skl->resource.max_mem) { | 
|---|
| 131 |  | -		dev_err(ctx->dev, | 
|---|
| 132 |  | -				"%s: module_id %d instance %d\n", __func__, | 
|---|
| 133 |  | -				mconfig->id.module_id, | 
|---|
| 134 |  | -				mconfig->id.instance_id); | 
|---|
| 135 |  | -		dev_err(ctx->dev, | 
|---|
| 136 |  | -				"exceeds ppl memory available %d mem %d\n", | 
|---|
| 137 |  | -				skl->resource.max_mem, skl->resource.mem); | 
|---|
| 138 |  | -		return false; | 
|---|
| 139 |  | -	} else { | 
|---|
| 140 |  | -		return true; | 
|---|
| 141 |  | -	} | 
|---|
| 142 |  | -} | 
|---|
| 143 |  | - | 
|---|
| 144 |  | -/* | 
|---|
| 145 |  | - * Add the mem to the mem pool. This is freed when pipe is deleted. | 
|---|
| 146 |  | - * Note: DSP does actual memory management we only keep track for complete | 
|---|
| 147 |  | - * pool | 
|---|
| 148 |  | - */ | 
|---|
| 149 |  | -static void skl_tplg_alloc_pipe_mem(struct skl *skl, | 
|---|
| 150 |  | -				struct skl_module_cfg *mconfig) | 
|---|
| 151 |  | -{ | 
|---|
| 152 |  | -	skl->resource.mem += mconfig->pipe->memory_pages; | 
|---|
| 153 |  | -} | 
|---|
| 154 |  | - | 
|---|
| 155 |  | -/* | 
|---|
| 156 |  | - * Pipeline needs needs DSP CPU resources for computation, this is | 
|---|
| 157 |  | - * quantified in MCPS (Million Clocks Per Second) required for module/pipe | 
|---|
| 158 |  | - * | 
|---|
| 159 |  | - * Each pipelines needs mcps to be allocated. Check if we have mcps for this | 
|---|
| 160 |  | - * pipe. | 
|---|
| 161 |  | - */ | 
|---|
| 162 |  | - | 
|---|
| 163 |  | -static bool skl_is_pipe_mcps_avail(struct skl *skl, | 
|---|
| 164 |  | -				struct skl_module_cfg *mconfig) | 
|---|
| 165 |  | -{ | 
|---|
| 166 |  | -	struct skl_sst *ctx = skl->skl_sst; | 
|---|
| 167 |  | -	u8 res_idx = mconfig->res_idx; | 
|---|
| 168 |  | -	struct skl_module_res *res = &mconfig->module->resources[res_idx]; | 
|---|
| 169 |  | - | 
|---|
| 170 |  | -	if (skl->resource.mcps + res->cps > skl->resource.max_mcps) { | 
|---|
| 171 |  | -		dev_err(ctx->dev, | 
|---|
| 172 |  | -			"%s: module_id %d instance %d\n", __func__, | 
|---|
| 173 |  | -			mconfig->id.module_id, mconfig->id.instance_id); | 
|---|
| 174 |  | -		dev_err(ctx->dev, | 
|---|
| 175 |  | -			"exceeds ppl mcps available %d > mem %d\n", | 
|---|
| 176 |  | -			skl->resource.max_mcps, skl->resource.mcps); | 
|---|
| 177 |  | -		return false; | 
|---|
| 178 |  | -	} else { | 
|---|
| 179 |  | -		return true; | 
|---|
| 180 |  | -	} | 
|---|
| 181 |  | -} | 
|---|
| 182 |  | - | 
|---|
| 183 |  | -static void skl_tplg_alloc_pipe_mcps(struct skl *skl, | 
|---|
| 184 |  | -				struct skl_module_cfg *mconfig) | 
|---|
| 185 |  | -{ | 
|---|
| 186 |  | -	u8 res_idx = mconfig->res_idx; | 
|---|
| 187 |  | -	struct skl_module_res *res = &mconfig->module->resources[res_idx]; | 
|---|
| 188 |  | - | 
|---|
| 189 |  | -	skl->resource.mcps += res->cps; | 
|---|
| 190 |  | -} | 
|---|
| 191 |  | - | 
|---|
| 192 |  | -/* | 
|---|
| 193 |  | - * Free the mcps when tearing down | 
|---|
| 194 |  | - */ | 
|---|
| 195 |  | -static void | 
|---|
| 196 |  | -skl_tplg_free_pipe_mcps(struct skl *skl, struct skl_module_cfg *mconfig) | 
|---|
| 197 |  | -{ | 
|---|
| 198 |  | -	u8 res_idx = mconfig->res_idx; | 
|---|
| 199 |  | -	struct skl_module_res *res = &mconfig->module->resources[res_idx]; | 
|---|
| 200 |  | - | 
|---|
| 201 |  | -	skl->resource.mcps -= res->cps; | 
|---|
| 202 |  | -} | 
|---|
| 203 |  | - | 
|---|
| 204 |  | -/* | 
|---|
| 205 |  | - * Free the memory when tearing down | 
|---|
| 206 |  | - */ | 
|---|
| 207 |  | -static void | 
|---|
| 208 |  | -skl_tplg_free_pipe_mem(struct skl *skl, struct skl_module_cfg *mconfig) | 
|---|
| 209 |  | -{ | 
|---|
| 210 |  | -	skl->resource.mem -= mconfig->pipe->memory_pages; | 
|---|
| 211 |  | -} | 
|---|
| 212 |  | - | 
|---|
| 213 |  | - | 
|---|
| 214 |  | -static void skl_dump_mconfig(struct skl_sst *ctx, | 
|---|
| 215 |  | -					struct skl_module_cfg *mcfg) | 
|---|
| 216 |  | -{ | 
|---|
| 217 |  | -	struct skl_module_iface *iface = &mcfg->module->formats[0]; | 
|---|
| 218 |  | - | 
|---|
| 219 |  | -	dev_dbg(ctx->dev, "Dumping config\n"); | 
|---|
| 220 |  | -	dev_dbg(ctx->dev, "Input Format:\n"); | 
|---|
| 221 |  | -	dev_dbg(ctx->dev, "channels = %d\n", iface->inputs[0].fmt.channels); | 
|---|
| 222 |  | -	dev_dbg(ctx->dev, "s_freq = %d\n", iface->inputs[0].fmt.s_freq); | 
|---|
| 223 |  | -	dev_dbg(ctx->dev, "ch_cfg = %d\n", iface->inputs[0].fmt.ch_cfg); | 
|---|
| 224 |  | -	dev_dbg(ctx->dev, "valid bit depth = %d\n", | 
|---|
|  | 118 | +	dev_dbg(skl->dev, "Dumping config\n"); | 
|---|
|  | 119 | +	dev_dbg(skl->dev, "Input Format:\n"); | 
|---|
|  | 120 | +	dev_dbg(skl->dev, "channels = %d\n", iface->inputs[0].fmt.channels); | 
|---|
|  | 121 | +	dev_dbg(skl->dev, "s_freq = %d\n", iface->inputs[0].fmt.s_freq); | 
|---|
|  | 122 | +	dev_dbg(skl->dev, "ch_cfg = %d\n", iface->inputs[0].fmt.ch_cfg); | 
|---|
|  | 123 | +	dev_dbg(skl->dev, "valid bit depth = %d\n", | 
|---|
| 225 | 124 | iface->inputs[0].fmt.valid_bit_depth); | 
|---|
| 226 |  | -	dev_dbg(ctx->dev, "Output Format:\n"); | 
|---|
| 227 |  | -	dev_dbg(ctx->dev, "channels = %d\n", iface->outputs[0].fmt.channels); | 
|---|
| 228 |  | -	dev_dbg(ctx->dev, "s_freq = %d\n", iface->outputs[0].fmt.s_freq); | 
|---|
| 229 |  | -	dev_dbg(ctx->dev, "valid bit depth = %d\n", | 
|---|
|  | 125 | +	dev_dbg(skl->dev, "Output Format:\n"); | 
|---|
|  | 126 | +	dev_dbg(skl->dev, "channels = %d\n", iface->outputs[0].fmt.channels); | 
|---|
|  | 127 | +	dev_dbg(skl->dev, "s_freq = %d\n", iface->outputs[0].fmt.s_freq); | 
|---|
|  | 128 | +	dev_dbg(skl->dev, "valid bit depth = %d\n", | 
|---|
| 230 | 129 | iface->outputs[0].fmt.valid_bit_depth); | 
|---|
| 231 |  | -	dev_dbg(ctx->dev, "ch_cfg = %d\n", iface->outputs[0].fmt.ch_cfg); | 
|---|
|  | 130 | +	dev_dbg(skl->dev, "ch_cfg = %d\n", iface->outputs[0].fmt.ch_cfg); | 
|---|
| 232 | 131 | } | 
|---|
| 233 | 132 |  | 
|---|
| 234 | 133 | static void skl_tplg_update_chmap(struct skl_module_fmt *fmt, int chs) | 
|---|
| .. | .. | 
|---|
| 296 | 195 | struct skl_module_fmt *in_fmt, *out_fmt; | 
|---|
| 297 | 196 |  | 
|---|
| 298 | 197 | /* Fixups will be applied to pin 0 only */ | 
|---|
| 299 |  | -	in_fmt = &m_cfg->module->formats[0].inputs[0].fmt; | 
|---|
| 300 |  | -	out_fmt = &m_cfg->module->formats[0].outputs[0].fmt; | 
|---|
|  | 198 | +	in_fmt = &m_cfg->module->formats[m_cfg->fmt_idx].inputs[0].fmt; | 
|---|
|  | 199 | +	out_fmt = &m_cfg->module->formats[m_cfg->fmt_idx].outputs[0].fmt; | 
|---|
| 301 | 200 |  | 
|---|
| 302 | 201 | if (params->stream == SNDRV_PCM_STREAM_PLAYBACK) { | 
|---|
| 303 | 202 | if (is_fe) { | 
|---|
| .. | .. | 
|---|
| 330 | 229 | * params, so once we have calculate params, we need buffer calculation as | 
|---|
| 331 | 230 | * well. | 
|---|
| 332 | 231 | */ | 
|---|
| 333 |  | -static void skl_tplg_update_buffer_size(struct skl_sst *ctx, | 
|---|
|  | 232 | +static void skl_tplg_update_buffer_size(struct skl_dev *skl, | 
|---|
| 334 | 233 | struct skl_module_cfg *mcfg) | 
|---|
| 335 | 234 | { | 
|---|
| 336 | 235 | int multiplier = 1; | 
|---|
| .. | .. | 
|---|
| 340 | 239 | /* Since fixups is applied to pin 0 only, ibs, obs needs | 
|---|
| 341 | 240 | * change for pin 0 only | 
|---|
| 342 | 241 | */ | 
|---|
| 343 |  | -	res = &mcfg->module->resources[0]; | 
|---|
| 344 |  | -	in_fmt = &mcfg->module->formats[0].inputs[0].fmt; | 
|---|
| 345 |  | -	out_fmt = &mcfg->module->formats[0].outputs[0].fmt; | 
|---|
|  | 242 | +	res = &mcfg->module->resources[mcfg->res_idx]; | 
|---|
|  | 243 | +	in_fmt = &mcfg->module->formats[mcfg->fmt_idx].inputs[0].fmt; | 
|---|
|  | 244 | +	out_fmt = &mcfg->module->formats[mcfg->fmt_idx].outputs[0].fmt; | 
|---|
| 346 | 245 |  | 
|---|
| 347 | 246 | if (mcfg->m_type == SKL_MODULE_TYPE_SRCINT) | 
|---|
| 348 | 247 | multiplier = 5; | 
|---|
| .. | .. | 
|---|
| 382 | 281 | } | 
|---|
| 383 | 282 |  | 
|---|
| 384 | 283 | static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w, | 
|---|
| 385 |  | -						struct skl_sst *ctx) | 
|---|
|  | 284 | +						struct skl_dev *skl) | 
|---|
| 386 | 285 | { | 
|---|
| 387 | 286 | struct skl_module_cfg *m_cfg = w->priv; | 
|---|
| 388 | 287 | int link_type, dir; | 
|---|
| 389 | 288 | u32 ch, s_freq, s_fmt; | 
|---|
| 390 | 289 | struct nhlt_specific_cfg *cfg; | 
|---|
| 391 |  | -	struct skl *skl = get_skl_ctx(ctx->dev); | 
|---|
| 392 | 290 | u8 dev_type = skl_tplg_be_dev_type(m_cfg->dev_type); | 
|---|
| 393 | 291 | int fmt_idx = m_cfg->fmt_idx; | 
|---|
| 394 | 292 | struct skl_module_iface *m_iface = &m_cfg->module->formats[fmt_idx]; | 
|---|
| .. | .. | 
|---|
| 397 | 295 | if (m_cfg->formats_config.caps_size > 0) | 
|---|
| 398 | 296 | return 0; | 
|---|
| 399 | 297 |  | 
|---|
| 400 |  | -	dev_dbg(ctx->dev, "Applying default cfg blob\n"); | 
|---|
|  | 298 | +	dev_dbg(skl->dev, "Applying default cfg blob\n"); | 
|---|
| 401 | 299 | switch (m_cfg->dev_type) { | 
|---|
| 402 | 300 | case SKL_DEVICE_DMIC: | 
|---|
| 403 | 301 | link_type = NHLT_LINK_DMIC; | 
|---|
| .. | .. | 
|---|
| 433 | 331 | m_cfg->formats_config.caps_size = cfg->size; | 
|---|
| 434 | 332 | m_cfg->formats_config.caps = (u32 *) &cfg->caps; | 
|---|
| 435 | 333 | } else { | 
|---|
| 436 |  | -		dev_err(ctx->dev, "Blob NULL for id %x type %d dirn %d\n", | 
|---|
|  | 334 | +		dev_err(skl->dev, "Blob NULL for id %x type %d dirn %d\n", | 
|---|
| 437 | 335 | m_cfg->vbus_id, link_type, dir); | 
|---|
| 438 |  | -		dev_err(ctx->dev, "PCM: ch %d, freq %d, fmt %d\n", | 
|---|
|  | 336 | +		dev_err(skl->dev, "PCM: ch %d, freq %d, fmt %d\n", | 
|---|
| 439 | 337 | ch, s_freq, s_fmt); | 
|---|
| 440 | 338 | return -EIO; | 
|---|
| 441 | 339 | } | 
|---|
| .. | .. | 
|---|
| 444 | 342 | } | 
|---|
| 445 | 343 |  | 
|---|
| 446 | 344 | static void skl_tplg_update_module_params(struct snd_soc_dapm_widget *w, | 
|---|
| 447 |  | -							struct skl_sst *ctx) | 
|---|
|  | 345 | +							struct skl_dev *skl) | 
|---|
| 448 | 346 | { | 
|---|
| 449 | 347 | struct skl_module_cfg *m_cfg = w->priv; | 
|---|
| 450 | 348 | struct skl_pipe_params *params = m_cfg->pipe->p_params; | 
|---|
| .. | .. | 
|---|
| 454 | 352 | if (!m_cfg->params_fixup) | 
|---|
| 455 | 353 | return; | 
|---|
| 456 | 354 |  | 
|---|
| 457 |  | -	dev_dbg(ctx->dev, "Mconfig for widget=%s BEFORE updation\n", | 
|---|
|  | 355 | +	dev_dbg(skl->dev, "Mconfig for widget=%s BEFORE updation\n", | 
|---|
| 458 | 356 | w->name); | 
|---|
| 459 | 357 |  | 
|---|
| 460 |  | -	skl_dump_mconfig(ctx, m_cfg); | 
|---|
|  | 358 | +	skl_dump_mconfig(skl, m_cfg); | 
|---|
| 461 | 359 |  | 
|---|
| 462 | 360 | if (p_conn_type == SKL_PIPE_CONN_TYPE_FE) | 
|---|
| 463 | 361 | is_fe = true; | 
|---|
| .. | .. | 
|---|
| 465 | 363 | is_fe = false; | 
|---|
| 466 | 364 |  | 
|---|
| 467 | 365 | skl_tplg_update_params_fixup(m_cfg, params, is_fe); | 
|---|
| 468 |  | -	skl_tplg_update_buffer_size(ctx, m_cfg); | 
|---|
|  | 366 | +	skl_tplg_update_buffer_size(skl, m_cfg); | 
|---|
| 469 | 367 |  | 
|---|
| 470 |  | -	dev_dbg(ctx->dev, "Mconfig for widget=%s AFTER updation\n", | 
|---|
|  | 368 | +	dev_dbg(skl->dev, "Mconfig for widget=%s AFTER updation\n", | 
|---|
| 471 | 369 | w->name); | 
|---|
| 472 | 370 |  | 
|---|
| 473 |  | -	skl_dump_mconfig(ctx, m_cfg); | 
|---|
|  | 371 | +	skl_dump_mconfig(skl, m_cfg); | 
|---|
| 474 | 372 | } | 
|---|
| 475 | 373 |  | 
|---|
| 476 | 374 | /* | 
|---|
| .. | .. | 
|---|
| 479 | 377 | * set module params will be done after module is initialised. | 
|---|
| 480 | 378 | */ | 
|---|
| 481 | 379 | static int skl_tplg_set_module_params(struct snd_soc_dapm_widget *w, | 
|---|
| 482 |  | -						struct skl_sst *ctx) | 
|---|
|  | 380 | +						struct skl_dev *skl) | 
|---|
| 483 | 381 | { | 
|---|
| 484 | 382 | int i, ret; | 
|---|
| 485 | 383 | struct skl_module_cfg *mconfig = w->priv; | 
|---|
| .. | .. | 
|---|
| 491 | 389 | if (mconfig->formats_config.caps_size > 0 && | 
|---|
| 492 | 390 | mconfig->formats_config.set_params == SKL_PARAM_SET) { | 
|---|
| 493 | 391 | sp_cfg = &mconfig->formats_config; | 
|---|
| 494 |  | -		ret = skl_set_module_params(ctx, sp_cfg->caps, | 
|---|
|  | 392 | +		ret = skl_set_module_params(skl, sp_cfg->caps, | 
|---|
| 495 | 393 | sp_cfg->caps_size, | 
|---|
| 496 | 394 | sp_cfg->param_id, mconfig); | 
|---|
| 497 | 395 | if (ret < 0) | 
|---|
| .. | .. | 
|---|
| 505 | 403 | bc = (struct skl_algo_data *)sb->dobj.private; | 
|---|
| 506 | 404 |  | 
|---|
| 507 | 405 | if (bc->set_params == SKL_PARAM_SET) { | 
|---|
| 508 |  | -				ret = skl_set_module_params(ctx, | 
|---|
|  | 406 | +				ret = skl_set_module_params(skl, | 
|---|
| 509 | 407 | (u32 *)bc->params, bc->size, | 
|---|
| 510 | 408 | bc->param_id, mconfig); | 
|---|
| 511 | 409 | if (ret < 0) | 
|---|
| .. | .. | 
|---|
| 550 | 448 | return 0; | 
|---|
| 551 | 449 | } | 
|---|
| 552 | 450 |  | 
|---|
| 553 |  | -static int skl_tplg_module_prepare(struct skl_sst *ctx, struct skl_pipe *pipe, | 
|---|
|  | 451 | +static int skl_tplg_module_prepare(struct skl_dev *skl, struct skl_pipe *pipe, | 
|---|
| 554 | 452 | struct snd_soc_dapm_widget *w, struct skl_module_cfg *mcfg) | 
|---|
| 555 | 453 | { | 
|---|
| 556 | 454 | switch (mcfg->dev_type) { | 
|---|
| 557 | 455 | case SKL_DEVICE_HDAHOST: | 
|---|
| 558 |  | -		return skl_pcm_host_dma_prepare(ctx->dev, pipe->p_params); | 
|---|
|  | 456 | +		return skl_pcm_host_dma_prepare(skl->dev, pipe->p_params); | 
|---|
| 559 | 457 |  | 
|---|
| 560 | 458 | case SKL_DEVICE_HDALINK: | 
|---|
| 561 |  | -		return skl_pcm_link_dma_prepare(ctx->dev, pipe->p_params); | 
|---|
|  | 459 | +		return skl_pcm_link_dma_prepare(skl->dev, pipe->p_params); | 
|---|
| 562 | 460 | } | 
|---|
| 563 | 461 |  | 
|---|
| 564 | 462 | return 0; | 
|---|
| .. | .. | 
|---|
| 570 | 468 | * skl_init_module() routine, so invoke that for all modules in a pipeline | 
|---|
| 571 | 469 | */ | 
|---|
| 572 | 470 | static int | 
|---|
| 573 |  | -skl_tplg_init_pipe_modules(struct skl *skl, struct skl_pipe *pipe) | 
|---|
|  | 471 | +skl_tplg_init_pipe_modules(struct skl_dev *skl, struct skl_pipe *pipe) | 
|---|
| 574 | 472 | { | 
|---|
| 575 | 473 | struct skl_pipe_module *w_module; | 
|---|
| 576 | 474 | struct snd_soc_dapm_widget *w; | 
|---|
| 577 | 475 | struct skl_module_cfg *mconfig; | 
|---|
| 578 |  | -	struct skl_sst *ctx = skl->skl_sst; | 
|---|
| 579 | 476 | u8 cfg_idx; | 
|---|
| 580 | 477 | int ret = 0; | 
|---|
| 581 | 478 |  | 
|---|
| 582 | 479 | list_for_each_entry(w_module, &pipe->w_list, node) { | 
|---|
| 583 |  | -		uuid_le *uuid_mod; | 
|---|
|  | 480 | +		guid_t *uuid_mod; | 
|---|
| 584 | 481 | w = w_module->w; | 
|---|
| 585 | 482 | mconfig = w->priv; | 
|---|
| 586 | 483 |  | 
|---|
| 587 | 484 | /* check if module ids are populated */ | 
|---|
| 588 | 485 | if (mconfig->id.module_id < 0) { | 
|---|
| 589 |  | -			dev_err(skl->skl_sst->dev, | 
|---|
|  | 486 | +			dev_err(skl->dev, | 
|---|
| 590 | 487 | "module %pUL id not populated\n", | 
|---|
| 591 |  | -					(uuid_le *)mconfig->guid); | 
|---|
|  | 488 | +					(guid_t *)mconfig->guid); | 
|---|
| 592 | 489 | return -EIO; | 
|---|
| 593 | 490 | } | 
|---|
| 594 | 491 |  | 
|---|
| .. | .. | 
|---|
| 596 | 493 | mconfig->fmt_idx = mconfig->mod_cfg[cfg_idx].fmt_idx; | 
|---|
| 597 | 494 | mconfig->res_idx = mconfig->mod_cfg[cfg_idx].res_idx; | 
|---|
| 598 | 495 |  | 
|---|
| 599 |  | -		/* check resource available */ | 
|---|
| 600 |  | -		if (!skl_is_pipe_mcps_avail(skl, mconfig)) | 
|---|
| 601 |  | -			return -ENOMEM; | 
|---|
| 602 |  | - | 
|---|
| 603 |  | -		if (mconfig->module->loadable && ctx->dsp->fw_ops.load_mod) { | 
|---|
| 604 |  | -			ret = ctx->dsp->fw_ops.load_mod(ctx->dsp, | 
|---|
|  | 496 | +		if (mconfig->module->loadable && skl->dsp->fw_ops.load_mod) { | 
|---|
|  | 497 | +			ret = skl->dsp->fw_ops.load_mod(skl->dsp, | 
|---|
| 605 | 498 | mconfig->id.module_id, mconfig->guid); | 
|---|
| 606 | 499 | if (ret < 0) | 
|---|
| 607 | 500 | return ret; | 
|---|
| .. | .. | 
|---|
| 610 | 503 | } | 
|---|
| 611 | 504 |  | 
|---|
| 612 | 505 | /* prepare the DMA if the module is gateway cpr */ | 
|---|
| 613 |  | -		ret = skl_tplg_module_prepare(ctx, pipe, w, mconfig); | 
|---|
|  | 506 | +		ret = skl_tplg_module_prepare(skl, pipe, w, mconfig); | 
|---|
| 614 | 507 | if (ret < 0) | 
|---|
| 615 | 508 | return ret; | 
|---|
| 616 | 509 |  | 
|---|
| 617 | 510 | /* update blob if blob is null for be with default value */ | 
|---|
| 618 |  | -		skl_tplg_update_be_blob(w, ctx); | 
|---|
|  | 511 | +		skl_tplg_update_be_blob(w, skl); | 
|---|
| 619 | 512 |  | 
|---|
| 620 | 513 | /* | 
|---|
| 621 | 514 | * apply fix/conversion to module params based on | 
|---|
| 622 | 515 | * FE/BE params | 
|---|
| 623 | 516 | */ | 
|---|
| 624 |  | -		skl_tplg_update_module_params(w, ctx); | 
|---|
| 625 |  | -		uuid_mod = (uuid_le *)mconfig->guid; | 
|---|
| 626 |  | -		mconfig->id.pvt_id = skl_get_pvt_id(ctx, uuid_mod, | 
|---|
|  | 517 | +		skl_tplg_update_module_params(w, skl); | 
|---|
|  | 518 | +		uuid_mod = (guid_t *)mconfig->guid; | 
|---|
|  | 519 | +		mconfig->id.pvt_id = skl_get_pvt_id(skl, uuid_mod, | 
|---|
| 627 | 520 | mconfig->id.instance_id); | 
|---|
| 628 | 521 | if (mconfig->id.pvt_id < 0) | 
|---|
| 629 | 522 | return ret; | 
|---|
| 630 | 523 | skl_tplg_set_module_init_data(w); | 
|---|
| 631 | 524 |  | 
|---|
| 632 |  | -		ret = skl_dsp_get_core(ctx->dsp, mconfig->core_id); | 
|---|
|  | 525 | +		ret = skl_dsp_get_core(skl->dsp, mconfig->core_id); | 
|---|
| 633 | 526 | if (ret < 0) { | 
|---|
| 634 |  | -			dev_err(ctx->dev, "Failed to wake up core %d ret=%d\n", | 
|---|
|  | 527 | +			dev_err(skl->dev, "Failed to wake up core %d ret=%d\n", | 
|---|
| 635 | 528 | mconfig->core_id, ret); | 
|---|
| 636 | 529 | return ret; | 
|---|
| 637 | 530 | } | 
|---|
| 638 | 531 |  | 
|---|
| 639 |  | -		ret = skl_init_module(ctx, mconfig); | 
|---|
|  | 532 | +		ret = skl_init_module(skl, mconfig); | 
|---|
| 640 | 533 | if (ret < 0) { | 
|---|
| 641 |  | -			skl_put_pvt_id(ctx, uuid_mod, &mconfig->id.pvt_id); | 
|---|
|  | 534 | +			skl_put_pvt_id(skl, uuid_mod, &mconfig->id.pvt_id); | 
|---|
| 642 | 535 | goto err; | 
|---|
| 643 | 536 | } | 
|---|
| 644 |  | -		skl_tplg_alloc_pipe_mcps(skl, mconfig); | 
|---|
| 645 |  | -		ret = skl_tplg_set_module_params(w, ctx); | 
|---|
|  | 537 | + | 
|---|
|  | 538 | +		ret = skl_tplg_set_module_params(w, skl); | 
|---|
| 646 | 539 | if (ret < 0) | 
|---|
| 647 | 540 | goto err; | 
|---|
| 648 | 541 | } | 
|---|
| 649 | 542 |  | 
|---|
| 650 | 543 | return 0; | 
|---|
| 651 | 544 | err: | 
|---|
| 652 |  | -	skl_dsp_put_core(ctx->dsp, mconfig->core_id); | 
|---|
|  | 545 | +	skl_dsp_put_core(skl->dsp, mconfig->core_id); | 
|---|
| 653 | 546 | return ret; | 
|---|
| 654 | 547 | } | 
|---|
| 655 | 548 |  | 
|---|
| 656 |  | -static int skl_tplg_unload_pipe_modules(struct skl_sst *ctx, | 
|---|
|  | 549 | +static int skl_tplg_unload_pipe_modules(struct skl_dev *skl, | 
|---|
| 657 | 550 | struct skl_pipe *pipe) | 
|---|
| 658 | 551 | { | 
|---|
| 659 | 552 | int ret = 0; | 
|---|
| 660 |  | -	struct skl_pipe_module *w_module = NULL; | 
|---|
| 661 |  | -	struct skl_module_cfg *mconfig = NULL; | 
|---|
|  | 553 | +	struct skl_pipe_module *w_module; | 
|---|
|  | 554 | +	struct skl_module_cfg *mconfig; | 
|---|
| 662 | 555 |  | 
|---|
| 663 | 556 | list_for_each_entry(w_module, &pipe->w_list, node) { | 
|---|
| 664 |  | -		uuid_le *uuid_mod; | 
|---|
|  | 557 | +		guid_t *uuid_mod; | 
|---|
| 665 | 558 | mconfig  = w_module->w->priv; | 
|---|
| 666 |  | -		uuid_mod = (uuid_le *)mconfig->guid; | 
|---|
|  | 559 | +		uuid_mod = (guid_t *)mconfig->guid; | 
|---|
| 667 | 560 |  | 
|---|
| 668 |  | -		if (mconfig->module->loadable && ctx->dsp->fw_ops.unload_mod && | 
|---|
|  | 561 | +		if (mconfig->module->loadable && skl->dsp->fw_ops.unload_mod && | 
|---|
| 669 | 562 | mconfig->m_state > SKL_MODULE_UNINIT) { | 
|---|
| 670 |  | -			ret = ctx->dsp->fw_ops.unload_mod(ctx->dsp, | 
|---|
|  | 563 | +			ret = skl->dsp->fw_ops.unload_mod(skl->dsp, | 
|---|
| 671 | 564 | mconfig->id.module_id); | 
|---|
| 672 | 565 | if (ret < 0) | 
|---|
| 673 | 566 | return -EIO; | 
|---|
| 674 | 567 | } | 
|---|
| 675 |  | -		skl_put_pvt_id(ctx, uuid_mod, &mconfig->id.pvt_id); | 
|---|
|  | 568 | +		skl_put_pvt_id(skl, uuid_mod, &mconfig->id.pvt_id); | 
|---|
| 676 | 569 |  | 
|---|
| 677 |  | -		ret = skl_dsp_put_core(ctx->dsp, mconfig->core_id); | 
|---|
|  | 570 | +		ret = skl_dsp_put_core(skl->dsp, mconfig->core_id); | 
|---|
| 678 | 571 | if (ret < 0) { | 
|---|
| 679 | 572 | /* don't return; continue with other modules */ | 
|---|
| 680 |  | -			dev_err(ctx->dev, "Failed to sleep core %d ret=%d\n", | 
|---|
|  | 573 | +			dev_err(skl->dev, "Failed to sleep core %d ret=%d\n", | 
|---|
| 681 | 574 | mconfig->core_id, ret); | 
|---|
| 682 | 575 | } | 
|---|
| 683 | 576 | } | 
|---|
| 684 | 577 |  | 
|---|
| 685 | 578 | /* no modules to unload in this path, so return */ | 
|---|
| 686 | 579 | return ret; | 
|---|
|  | 580 | +} | 
|---|
|  | 581 | + | 
|---|
|  | 582 | +static bool skl_tplg_is_multi_fmt(struct skl_dev *skl, struct skl_pipe *pipe) | 
|---|
|  | 583 | +{ | 
|---|
|  | 584 | +	struct skl_pipe_fmt *cur_fmt; | 
|---|
|  | 585 | +	struct skl_pipe_fmt *next_fmt; | 
|---|
|  | 586 | +	int i; | 
|---|
|  | 587 | + | 
|---|
|  | 588 | +	if (pipe->nr_cfgs <= 1) | 
|---|
|  | 589 | +		return false; | 
|---|
|  | 590 | + | 
|---|
|  | 591 | +	if (pipe->conn_type != SKL_PIPE_CONN_TYPE_FE) | 
|---|
|  | 592 | +		return true; | 
|---|
|  | 593 | + | 
|---|
|  | 594 | +	for (i = 0; i < pipe->nr_cfgs - 1; i++) { | 
|---|
|  | 595 | +		if (pipe->direction == SNDRV_PCM_STREAM_PLAYBACK) { | 
|---|
|  | 596 | +			cur_fmt = &pipe->configs[i].out_fmt; | 
|---|
|  | 597 | +			next_fmt = &pipe->configs[i + 1].out_fmt; | 
|---|
|  | 598 | +		} else { | 
|---|
|  | 599 | +			cur_fmt = &pipe->configs[i].in_fmt; | 
|---|
|  | 600 | +			next_fmt = &pipe->configs[i + 1].in_fmt; | 
|---|
|  | 601 | +		} | 
|---|
|  | 602 | + | 
|---|
|  | 603 | +		if (!CHECK_HW_PARAMS(cur_fmt->channels, cur_fmt->freq, | 
|---|
|  | 604 | +				     cur_fmt->bps, | 
|---|
|  | 605 | +				     next_fmt->channels, | 
|---|
|  | 606 | +				     next_fmt->freq, | 
|---|
|  | 607 | +				     next_fmt->bps)) | 
|---|
|  | 608 | +			return true; | 
|---|
|  | 609 | +	} | 
|---|
|  | 610 | + | 
|---|
|  | 611 | +	return false; | 
|---|
| 687 | 612 | } | 
|---|
| 688 | 613 |  | 
|---|
| 689 | 614 | /* | 
|---|
| .. | .. | 
|---|
| 694 | 619 | * 0th configuratation by default for such pipes. | 
|---|
| 695 | 620 | */ | 
|---|
| 696 | 621 | static int | 
|---|
| 697 |  | -skl_tplg_get_pipe_config(struct skl *skl, struct skl_module_cfg *mconfig) | 
|---|
|  | 622 | +skl_tplg_get_pipe_config(struct skl_dev *skl, struct skl_module_cfg *mconfig) | 
|---|
| 698 | 623 | { | 
|---|
| 699 |  | -	struct skl_sst *ctx = skl->skl_sst; | 
|---|
| 700 | 624 | struct skl_pipe *pipe = mconfig->pipe; | 
|---|
| 701 | 625 | struct skl_pipe_params *params = pipe->p_params; | 
|---|
| 702 | 626 | struct skl_path_config *pconfig = &pipe->configs[0]; | 
|---|
| .. | .. | 
|---|
| 709 | 633 | return 0; | 
|---|
| 710 | 634 | } | 
|---|
| 711 | 635 |  | 
|---|
|  | 636 | +	if (skl_tplg_is_multi_fmt(skl, pipe)) { | 
|---|
|  | 637 | +		pipe->cur_config_idx = pipe->pipe_config_idx; | 
|---|
|  | 638 | +		pipe->memory_pages = pconfig->mem_pages; | 
|---|
|  | 639 | +		dev_dbg(skl->dev, "found pipe config idx:%d\n", | 
|---|
|  | 640 | +			pipe->cur_config_idx); | 
|---|
|  | 641 | +		return 0; | 
|---|
|  | 642 | +	} | 
|---|
|  | 643 | + | 
|---|
| 712 | 644 | if (pipe->conn_type == SKL_PIPE_CONN_TYPE_NONE) { | 
|---|
| 713 |  | -		dev_dbg(ctx->dev, "No conn_type detected, take 0th config\n"); | 
|---|
|  | 645 | +		dev_dbg(skl->dev, "No conn_type detected, take 0th config\n"); | 
|---|
| 714 | 646 | pipe->cur_config_idx = 0; | 
|---|
| 715 | 647 | pipe->memory_pages = pconfig->mem_pages; | 
|---|
| 716 | 648 |  | 
|---|
| .. | .. | 
|---|
| 734 | 666 | fmt->channels, fmt->freq, fmt->bps)) { | 
|---|
| 735 | 667 | pipe->cur_config_idx = i; | 
|---|
| 736 | 668 | pipe->memory_pages = pconfig->mem_pages; | 
|---|
| 737 |  | -			dev_dbg(ctx->dev, "Using pipe config: %d\n", i); | 
|---|
|  | 669 | +			dev_dbg(skl->dev, "Using pipe config: %d\n", i); | 
|---|
| 738 | 670 |  | 
|---|
| 739 | 671 | return 0; | 
|---|
| 740 | 672 | } | 
|---|
| 741 | 673 | } | 
|---|
| 742 | 674 |  | 
|---|
| 743 |  | -	dev_err(ctx->dev, "Invalid pipe config: %d %d %d for pipe: %d\n", | 
|---|
|  | 675 | +	dev_err(skl->dev, "Invalid pipe config: %d %d %d for pipe: %d\n", | 
|---|
| 744 | 676 | params->ch, params->s_freq, params->s_fmt, pipe->ppl_id); | 
|---|
| 745 | 677 | return -EINVAL; | 
|---|
| 746 | 678 | } | 
|---|
| .. | .. | 
|---|
| 748 | 680 | /* | 
|---|
| 749 | 681 | * Mixer module represents a pipeline. So in the Pre-PMU event of mixer we | 
|---|
| 750 | 682 | * need create the pipeline. So we do following: | 
|---|
| 751 |  | - *   - check the resources | 
|---|
| 752 | 683 | *   - Create the pipeline | 
|---|
| 753 | 684 | *   - Initialize the modules in pipeline | 
|---|
| 754 | 685 | *   - finally bind all modules together | 
|---|
| 755 | 686 | */ | 
|---|
| 756 | 687 | static int skl_tplg_mixer_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w, | 
|---|
| 757 |  | -							struct skl *skl) | 
|---|
|  | 688 | +							struct skl_dev *skl) | 
|---|
| 758 | 689 | { | 
|---|
| 759 | 690 | int ret; | 
|---|
| 760 | 691 | struct skl_module_cfg *mconfig = w->priv; | 
|---|
| 761 | 692 | struct skl_pipe_module *w_module; | 
|---|
| 762 | 693 | struct skl_pipe *s_pipe = mconfig->pipe; | 
|---|
| 763 | 694 | struct skl_module_cfg *src_module = NULL, *dst_module, *module; | 
|---|
| 764 |  | -	struct skl_sst *ctx = skl->skl_sst; | 
|---|
| 765 | 695 | struct skl_module_deferred_bind *modules; | 
|---|
| 766 | 696 |  | 
|---|
| 767 | 697 | ret = skl_tplg_get_pipe_config(skl, mconfig); | 
|---|
| 768 | 698 | if (ret < 0) | 
|---|
| 769 | 699 | return ret; | 
|---|
| 770 | 700 |  | 
|---|
| 771 |  | -	/* check resource available */ | 
|---|
| 772 |  | -	if (!skl_is_pipe_mcps_avail(skl, mconfig)) | 
|---|
| 773 |  | -		return -EBUSY; | 
|---|
| 774 |  | - | 
|---|
| 775 |  | -	if (!skl_is_pipe_mem_avail(skl, mconfig)) | 
|---|
| 776 |  | -		return -ENOMEM; | 
|---|
| 777 |  | - | 
|---|
| 778 | 701 | /* | 
|---|
| 779 | 702 | * Create a list of modules for pipe. | 
|---|
| 780 | 703 | * This list contains modules from source to sink | 
|---|
| 781 | 704 | */ | 
|---|
| 782 |  | -	ret = skl_create_pipeline(ctx, mconfig->pipe); | 
|---|
|  | 705 | +	ret = skl_create_pipeline(skl, mconfig->pipe); | 
|---|
| 783 | 706 | if (ret < 0) | 
|---|
| 784 | 707 | return ret; | 
|---|
| 785 |  | - | 
|---|
| 786 |  | -	skl_tplg_alloc_pipe_mem(skl, mconfig); | 
|---|
| 787 |  | -	skl_tplg_alloc_pipe_mcps(skl, mconfig); | 
|---|
| 788 | 708 |  | 
|---|
| 789 | 709 | /* Init all pipe modules from source to sink */ | 
|---|
| 790 | 710 | ret = skl_tplg_init_pipe_modules(skl, s_pipe); | 
|---|
| .. | .. | 
|---|
| 800 | 720 | continue; | 
|---|
| 801 | 721 | } | 
|---|
| 802 | 722 |  | 
|---|
| 803 |  | -		ret = skl_bind_modules(ctx, src_module, dst_module); | 
|---|
|  | 723 | +		ret = skl_bind_modules(skl, src_module, dst_module); | 
|---|
| 804 | 724 | if (ret < 0) | 
|---|
| 805 | 725 | return ret; | 
|---|
| 806 | 726 |  | 
|---|
| .. | .. | 
|---|
| 818 | 738 | list_for_each_entry(modules, &skl->bind_list, node) { | 
|---|
| 819 | 739 | module = w_module->w->priv; | 
|---|
| 820 | 740 | if (modules->dst == module) | 
|---|
| 821 |  | -				skl_bind_modules(ctx, modules->src, | 
|---|
|  | 741 | +				skl_bind_modules(skl, modules->src, | 
|---|
| 822 | 742 | modules->dst); | 
|---|
| 823 | 743 | } | 
|---|
| 824 | 744 | } | 
|---|
| .. | .. | 
|---|
| 826 | 746 | return 0; | 
|---|
| 827 | 747 | } | 
|---|
| 828 | 748 |  | 
|---|
| 829 |  | -static int skl_fill_sink_instance_id(struct skl_sst *ctx, u32 *params, | 
|---|
|  | 749 | +static int skl_fill_sink_instance_id(struct skl_dev *skl, u32 *params, | 
|---|
| 830 | 750 | int size, struct skl_module_cfg *mcfg) | 
|---|
| 831 | 751 | { | 
|---|
| 832 | 752 | int i, pvt_id; | 
|---|
| .. | .. | 
|---|
| 837 | 757 | struct skl_mod_inst_map *inst = kpb_params->u.map; | 
|---|
| 838 | 758 |  | 
|---|
| 839 | 759 | for (i = 0; i < kpb_params->num_modules; i++) { | 
|---|
| 840 |  | -			pvt_id = skl_get_pvt_instance_id_map(ctx, inst->mod_id, | 
|---|
|  | 760 | +			pvt_id = skl_get_pvt_instance_id_map(skl, inst->mod_id, | 
|---|
| 841 | 761 | inst->inst_id); | 
|---|
| 842 | 762 | if (pvt_id < 0) | 
|---|
| 843 | 763 | return -EINVAL; | 
|---|
| .. | .. | 
|---|
| 857 | 777 | * send params after binding | 
|---|
| 858 | 778 | */ | 
|---|
| 859 | 779 | static int skl_tplg_set_module_bind_params(struct snd_soc_dapm_widget *w, | 
|---|
| 860 |  | -			struct skl_module_cfg *mcfg, struct skl_sst *ctx) | 
|---|
|  | 780 | +			struct skl_module_cfg *mcfg, struct skl_dev *skl) | 
|---|
| 861 | 781 | { | 
|---|
| 862 | 782 | int i, ret; | 
|---|
| 863 | 783 | struct skl_module_cfg *mconfig = w->priv; | 
|---|
| .. | .. | 
|---|
| 884 | 804 | if (mconfig->formats_config.caps_size > 0 && | 
|---|
| 885 | 805 | mconfig->formats_config.set_params == SKL_PARAM_BIND) { | 
|---|
| 886 | 806 | sp_cfg = &mconfig->formats_config; | 
|---|
| 887 |  | -		ret = skl_set_module_params(ctx, sp_cfg->caps, | 
|---|
|  | 807 | +		ret = skl_set_module_params(skl, sp_cfg->caps, | 
|---|
| 888 | 808 | sp_cfg->caps_size, | 
|---|
| 889 | 809 | sp_cfg->param_id, mconfig); | 
|---|
| 890 | 810 | if (ret < 0) | 
|---|
| .. | .. | 
|---|
| 898 | 818 | bc = (struct skl_algo_data *)sb->dobj.private; | 
|---|
| 899 | 819 |  | 
|---|
| 900 | 820 | if (bc->set_params == SKL_PARAM_BIND) { | 
|---|
| 901 |  | -				params = kzalloc(bc->max, GFP_KERNEL); | 
|---|
|  | 821 | +				params = kmemdup(bc->params, bc->max, GFP_KERNEL); | 
|---|
| 902 | 822 | if (!params) | 
|---|
| 903 | 823 | return -ENOMEM; | 
|---|
| 904 | 824 |  | 
|---|
| 905 |  | -				memcpy(params, bc->params, bc->max); | 
|---|
| 906 |  | -				skl_fill_sink_instance_id(ctx, params, bc->max, | 
|---|
|  | 825 | +				skl_fill_sink_instance_id(skl, params, bc->max, | 
|---|
| 907 | 826 | mconfig); | 
|---|
| 908 | 827 |  | 
|---|
| 909 |  | -				ret = skl_set_module_params(ctx, params, | 
|---|
|  | 828 | +				ret = skl_set_module_params(skl, params, | 
|---|
| 910 | 829 | bc->max, bc->param_id, mconfig); | 
|---|
| 911 | 830 | kfree(params); | 
|---|
| 912 | 831 |  | 
|---|
| .. | .. | 
|---|
| 919 | 838 | return 0; | 
|---|
| 920 | 839 | } | 
|---|
| 921 | 840 |  | 
|---|
| 922 |  | -static int skl_get_module_id(struct skl_sst *ctx, uuid_le *uuid) | 
|---|
|  | 841 | +static int skl_get_module_id(struct skl_dev *skl, guid_t *uuid) | 
|---|
| 923 | 842 | { | 
|---|
| 924 | 843 | struct uuid_module *module; | 
|---|
| 925 | 844 |  | 
|---|
| 926 |  | -	list_for_each_entry(module, &ctx->uuid_list, list) { | 
|---|
| 927 |  | -		if (uuid_le_cmp(*uuid, module->uuid) == 0) | 
|---|
|  | 845 | +	list_for_each_entry(module, &skl->uuid_list, list) { | 
|---|
|  | 846 | +		if (guid_equal(uuid, &module->uuid)) | 
|---|
| 928 | 847 | return module->id; | 
|---|
| 929 | 848 | } | 
|---|
| 930 | 849 |  | 
|---|
| 931 | 850 | return -EINVAL; | 
|---|
| 932 | 851 | } | 
|---|
| 933 | 852 |  | 
|---|
| 934 |  | -static int skl_tplg_find_moduleid_from_uuid(struct skl *skl, | 
|---|
|  | 853 | +static int skl_tplg_find_moduleid_from_uuid(struct skl_dev *skl, | 
|---|
| 935 | 854 | const struct snd_kcontrol_new *k) | 
|---|
| 936 | 855 | { | 
|---|
| 937 | 856 | struct soc_bytes_ext *sb = (void *) k->private_value; | 
|---|
| .. | .. | 
|---|
| 942 | 861 |  | 
|---|
| 943 | 862 | if (bc->set_params == SKL_PARAM_BIND && bc->max) { | 
|---|
| 944 | 863 | uuid_params = (struct skl_kpb_params *)bc->params; | 
|---|
| 945 |  | -		size = uuid_params->num_modules * | 
|---|
| 946 |  | -			sizeof(struct skl_mod_inst_map) + | 
|---|
| 947 |  | -			sizeof(uuid_params->num_modules); | 
|---|
|  | 864 | +		size = struct_size(params, u.map, uuid_params->num_modules); | 
|---|
| 948 | 865 |  | 
|---|
| 949 | 866 | params = devm_kzalloc(bus->dev, size, GFP_KERNEL); | 
|---|
| 950 | 867 | if (!params) | 
|---|
| .. | .. | 
|---|
| 953 | 870 | params->num_modules = uuid_params->num_modules; | 
|---|
| 954 | 871 |  | 
|---|
| 955 | 872 | for (i = 0; i < uuid_params->num_modules; i++) { | 
|---|
| 956 |  | -			module_id = skl_get_module_id(skl->skl_sst, | 
|---|
|  | 873 | +			module_id = skl_get_module_id(skl, | 
|---|
| 957 | 874 | &uuid_params->u.map_uuid[i].mod_uuid); | 
|---|
| 958 | 875 | if (module_id < 0) { | 
|---|
| 959 | 876 | devm_kfree(bus->dev, params); | 
|---|
| .. | .. | 
|---|
| 977 | 894 | * Retrieve the module id from UUID mentioned in the | 
|---|
| 978 | 895 | * post bind params | 
|---|
| 979 | 896 | */ | 
|---|
| 980 |  | -void skl_tplg_add_moduleid_in_bind_params(struct skl *skl, | 
|---|
|  | 897 | +void skl_tplg_add_moduleid_in_bind_params(struct skl_dev *skl, | 
|---|
| 981 | 898 | struct snd_soc_dapm_widget *w) | 
|---|
| 982 | 899 | { | 
|---|
| 983 | 900 | struct skl_module_cfg *mconfig = w->priv; | 
|---|
| .. | .. | 
|---|
| 996 | 913 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) && | 
|---|
| 997 | 914 | (skl_tplg_find_moduleid_from_uuid(skl, | 
|---|
| 998 | 915 | &w->kcontrol_news[i]) < 0)) | 
|---|
| 999 |  | -			dev_err(skl->skl_sst->dev, | 
|---|
|  | 916 | +			dev_err(skl->dev, | 
|---|
| 1000 | 917 | "%s: invalid kpb post bind params\n", | 
|---|
| 1001 | 918 | __func__); | 
|---|
| 1002 | 919 | } | 
|---|
| 1003 | 920 |  | 
|---|
| 1004 |  | -static int skl_tplg_module_add_deferred_bind(struct skl *skl, | 
|---|
|  | 921 | +static int skl_tplg_module_add_deferred_bind(struct skl_dev *skl, | 
|---|
| 1005 | 922 | struct skl_module_cfg *src, struct skl_module_cfg *dst) | 
|---|
| 1006 | 923 | { | 
|---|
| 1007 | 924 | struct skl_module_deferred_bind *m_list, *modules; | 
|---|
| .. | .. | 
|---|
| 1039 | 956 | } | 
|---|
| 1040 | 957 |  | 
|---|
| 1041 | 958 | static int skl_tplg_bind_sinks(struct snd_soc_dapm_widget *w, | 
|---|
| 1042 |  | -				struct skl *skl, | 
|---|
|  | 959 | +				struct skl_dev *skl, | 
|---|
| 1043 | 960 | struct snd_soc_dapm_widget *src_w, | 
|---|
| 1044 | 961 | struct skl_module_cfg *src_mconfig) | 
|---|
| 1045 | 962 | { | 
|---|
| 1046 | 963 | struct snd_soc_dapm_path *p; | 
|---|
| 1047 | 964 | struct snd_soc_dapm_widget *sink = NULL, *next_sink = NULL; | 
|---|
| 1048 | 965 | struct skl_module_cfg *sink_mconfig; | 
|---|
| 1049 |  | -	struct skl_sst *ctx = skl->skl_sst; | 
|---|
| 1050 | 966 | int ret; | 
|---|
| 1051 | 967 |  | 
|---|
| 1052 | 968 | snd_soc_dapm_widget_for_each_sink_path(w, p) { | 
|---|
| 1053 | 969 | if (!p->connect) | 
|---|
| 1054 | 970 | continue; | 
|---|
| 1055 | 971 |  | 
|---|
| 1056 |  | -		dev_dbg(ctx->dev, "%s: src widget=%s\n", __func__, w->name); | 
|---|
| 1057 |  | -		dev_dbg(ctx->dev, "%s: sink widget=%s\n", __func__, p->sink->name); | 
|---|
|  | 972 | +		dev_dbg(skl->dev, | 
|---|
|  | 973 | +			"%s: src widget=%s\n", __func__, w->name); | 
|---|
|  | 974 | +		dev_dbg(skl->dev, | 
|---|
|  | 975 | +			"%s: sink widget=%s\n", __func__, p->sink->name); | 
|---|
| 1058 | 976 |  | 
|---|
| 1059 | 977 | next_sink = p->sink; | 
|---|
| 1060 | 978 |  | 
|---|
| 1061 |  | -		if (!is_skl_dsp_widget_type(p->sink, ctx->dev)) | 
|---|
|  | 979 | +		if (!is_skl_dsp_widget_type(p->sink, skl->dev)) | 
|---|
| 1062 | 980 | return skl_tplg_bind_sinks(p->sink, skl, src_w, src_mconfig); | 
|---|
| 1063 | 981 |  | 
|---|
| 1064 | 982 | /* | 
|---|
| .. | .. | 
|---|
| 1067 | 985 | * they are ones used for SKL so check that first | 
|---|
| 1068 | 986 | */ | 
|---|
| 1069 | 987 | if ((p->sink->priv != NULL) && | 
|---|
| 1070 |  | -				is_skl_dsp_widget_type(p->sink, ctx->dev)) { | 
|---|
|  | 988 | +				is_skl_dsp_widget_type(p->sink, skl->dev)) { | 
|---|
| 1071 | 989 |  | 
|---|
| 1072 | 990 | sink = p->sink; | 
|---|
| 1073 | 991 | sink_mconfig = sink->priv; | 
|---|
| .. | .. | 
|---|
| 1099 | 1017 | continue; | 
|---|
| 1100 | 1018 |  | 
|---|
| 1101 | 1019 | /* Bind source to sink, mixin is always source */ | 
|---|
| 1102 |  | -			ret = skl_bind_modules(ctx, src_mconfig, sink_mconfig); | 
|---|
|  | 1020 | +			ret = skl_bind_modules(skl, src_mconfig, sink_mconfig); | 
|---|
| 1103 | 1021 | if (ret) | 
|---|
| 1104 | 1022 | return ret; | 
|---|
| 1105 | 1023 |  | 
|---|
| 1106 | 1024 | /* set module params after bind */ | 
|---|
| 1107 |  | -			skl_tplg_set_module_bind_params(src_w, src_mconfig, ctx); | 
|---|
| 1108 |  | -			skl_tplg_set_module_bind_params(sink, sink_mconfig, ctx); | 
|---|
|  | 1025 | +			skl_tplg_set_module_bind_params(src_w, | 
|---|
|  | 1026 | +					src_mconfig, skl); | 
|---|
|  | 1027 | +			skl_tplg_set_module_bind_params(sink, | 
|---|
|  | 1028 | +					sink_mconfig, skl); | 
|---|
| 1109 | 1029 |  | 
|---|
| 1110 | 1030 | /* Start sinks pipe first */ | 
|---|
| 1111 | 1031 | if (sink_mconfig->pipe->state != SKL_PIPE_STARTED) { | 
|---|
| 1112 | 1032 | if (sink_mconfig->pipe->conn_type != | 
|---|
| 1113 | 1033 | SKL_PIPE_CONN_TYPE_FE) | 
|---|
| 1114 |  | -					ret = skl_run_pipe(ctx, | 
|---|
|  | 1034 | +					ret = skl_run_pipe(skl, | 
|---|
| 1115 | 1035 | sink_mconfig->pipe); | 
|---|
| 1116 | 1036 | if (ret) | 
|---|
| 1117 | 1037 | return ret; | 
|---|
| .. | .. | 
|---|
| 1136 | 1056 | *   - Then run current pipe | 
|---|
| 1137 | 1057 | */ | 
|---|
| 1138 | 1058 | static int skl_tplg_pga_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w, | 
|---|
| 1139 |  | -								struct skl *skl) | 
|---|
|  | 1059 | +							struct skl_dev *skl) | 
|---|
| 1140 | 1060 | { | 
|---|
| 1141 | 1061 | struct skl_module_cfg *src_mconfig; | 
|---|
| 1142 |  | -	struct skl_sst *ctx = skl->skl_sst; | 
|---|
| 1143 | 1062 | int ret = 0; | 
|---|
| 1144 | 1063 |  | 
|---|
| 1145 | 1064 | src_mconfig = w->priv; | 
|---|
| .. | .. | 
|---|
| 1155 | 1074 |  | 
|---|
| 1156 | 1075 | /* Start source pipe last after starting all sinks */ | 
|---|
| 1157 | 1076 | if (src_mconfig->pipe->conn_type != SKL_PIPE_CONN_TYPE_FE) | 
|---|
| 1158 |  | -		return skl_run_pipe(ctx, src_mconfig->pipe); | 
|---|
|  | 1077 | +		return skl_run_pipe(skl, src_mconfig->pipe); | 
|---|
| 1159 | 1078 |  | 
|---|
| 1160 | 1079 | return 0; | 
|---|
| 1161 | 1080 | } | 
|---|
| 1162 | 1081 |  | 
|---|
| 1163 | 1082 | static struct snd_soc_dapm_widget *skl_get_src_dsp_widget( | 
|---|
| 1164 |  | -		struct snd_soc_dapm_widget *w, struct skl *skl) | 
|---|
|  | 1083 | +		struct snd_soc_dapm_widget *w, struct skl_dev *skl) | 
|---|
| 1165 | 1084 | { | 
|---|
| 1166 | 1085 | struct snd_soc_dapm_path *p; | 
|---|
| 1167 | 1086 | struct snd_soc_dapm_widget *src_w = NULL; | 
|---|
| 1168 |  | -	struct skl_sst *ctx = skl->skl_sst; | 
|---|
| 1169 | 1087 |  | 
|---|
| 1170 | 1088 | snd_soc_dapm_widget_for_each_source_path(w, p) { | 
|---|
| 1171 | 1089 | src_w = p->source; | 
|---|
| 1172 | 1090 | if (!p->connect) | 
|---|
| 1173 | 1091 | continue; | 
|---|
| 1174 | 1092 |  | 
|---|
| 1175 |  | -		dev_dbg(ctx->dev, "sink widget=%s\n", w->name); | 
|---|
| 1176 |  | -		dev_dbg(ctx->dev, "src widget=%s\n", p->source->name); | 
|---|
|  | 1093 | +		dev_dbg(skl->dev, "sink widget=%s\n", w->name); | 
|---|
|  | 1094 | +		dev_dbg(skl->dev, "src widget=%s\n", p->source->name); | 
|---|
| 1177 | 1095 |  | 
|---|
| 1178 | 1096 | /* | 
|---|
| 1179 | 1097 | * here we will check widgets in sink pipelines, so that can | 
|---|
| .. | .. | 
|---|
| 1181 | 1099 | * ones used for SKL so check that first | 
|---|
| 1182 | 1100 | */ | 
|---|
| 1183 | 1101 | if ((p->source->priv != NULL) && | 
|---|
| 1184 |  | -				is_skl_dsp_widget_type(p->source, ctx->dev)) { | 
|---|
|  | 1102 | +				is_skl_dsp_widget_type(p->source, skl->dev)) { | 
|---|
| 1185 | 1103 | return p->source; | 
|---|
| 1186 | 1104 | } | 
|---|
| 1187 | 1105 | } | 
|---|
| .. | .. | 
|---|
| 1202 | 1120 | *	- start this pipeline | 
|---|
| 1203 | 1121 | */ | 
|---|
| 1204 | 1122 | static int skl_tplg_mixer_dapm_post_pmu_event(struct snd_soc_dapm_widget *w, | 
|---|
| 1205 |  | -							struct skl *skl) | 
|---|
|  | 1123 | +							struct skl_dev *skl) | 
|---|
| 1206 | 1124 | { | 
|---|
| 1207 | 1125 | int ret = 0; | 
|---|
| 1208 | 1126 | struct snd_soc_dapm_widget *source, *sink; | 
|---|
| 1209 | 1127 | struct skl_module_cfg *src_mconfig, *sink_mconfig; | 
|---|
| 1210 |  | -	struct skl_sst *ctx = skl->skl_sst; | 
|---|
| 1211 | 1128 | int src_pipe_started = 0; | 
|---|
| 1212 | 1129 |  | 
|---|
| 1213 | 1130 | sink = w; | 
|---|
| .. | .. | 
|---|
| 1233 | 1150 | } | 
|---|
| 1234 | 1151 |  | 
|---|
| 1235 | 1152 | if (src_pipe_started) { | 
|---|
| 1236 |  | -		ret = skl_bind_modules(ctx, src_mconfig, sink_mconfig); | 
|---|
|  | 1153 | +		ret = skl_bind_modules(skl, src_mconfig, sink_mconfig); | 
|---|
| 1237 | 1154 | if (ret) | 
|---|
| 1238 | 1155 | return ret; | 
|---|
| 1239 | 1156 |  | 
|---|
| 1240 | 1157 | /* set module params after bind */ | 
|---|
| 1241 |  | -		skl_tplg_set_module_bind_params(source, src_mconfig, ctx); | 
|---|
| 1242 |  | -		skl_tplg_set_module_bind_params(sink, sink_mconfig, ctx); | 
|---|
|  | 1158 | +		skl_tplg_set_module_bind_params(source, src_mconfig, skl); | 
|---|
|  | 1159 | +		skl_tplg_set_module_bind_params(sink, sink_mconfig, skl); | 
|---|
| 1243 | 1160 |  | 
|---|
| 1244 | 1161 | if (sink_mconfig->pipe->conn_type != SKL_PIPE_CONN_TYPE_FE) | 
|---|
| 1245 |  | -			ret = skl_run_pipe(ctx, sink_mconfig->pipe); | 
|---|
|  | 1162 | +			ret = skl_run_pipe(skl, sink_mconfig->pipe); | 
|---|
| 1246 | 1163 | } | 
|---|
| 1247 | 1164 |  | 
|---|
| 1248 | 1165 | return ret; | 
|---|
| .. | .. | 
|---|
| 1255 | 1172 | *   - unbind with source pipelines if still connected | 
|---|
| 1256 | 1173 | */ | 
|---|
| 1257 | 1174 | static int skl_tplg_mixer_dapm_pre_pmd_event(struct snd_soc_dapm_widget *w, | 
|---|
| 1258 |  | -							struct skl *skl) | 
|---|
|  | 1175 | +							struct skl_dev *skl) | 
|---|
| 1259 | 1176 | { | 
|---|
| 1260 | 1177 | struct skl_module_cfg *src_mconfig, *sink_mconfig; | 
|---|
| 1261 | 1178 | int ret = 0, i; | 
|---|
| 1262 |  | -	struct skl_sst *ctx = skl->skl_sst; | 
|---|
| 1263 | 1179 |  | 
|---|
| 1264 | 1180 | sink_mconfig = w->priv; | 
|---|
| 1265 | 1181 |  | 
|---|
| 1266 | 1182 | /* Stop the pipe */ | 
|---|
| 1267 |  | -	ret = skl_stop_pipe(ctx, sink_mconfig->pipe); | 
|---|
|  | 1183 | +	ret = skl_stop_pipe(skl, sink_mconfig->pipe); | 
|---|
| 1268 | 1184 | if (ret) | 
|---|
| 1269 | 1185 | return ret; | 
|---|
| 1270 | 1186 |  | 
|---|
| .. | .. | 
|---|
| 1274 | 1190 | if (!src_mconfig) | 
|---|
| 1275 | 1191 | continue; | 
|---|
| 1276 | 1192 |  | 
|---|
| 1277 |  | -			ret = skl_unbind_modules(ctx, | 
|---|
|  | 1193 | +			ret = skl_unbind_modules(skl, | 
|---|
| 1278 | 1194 | src_mconfig, sink_mconfig); | 
|---|
| 1279 | 1195 | } | 
|---|
| 1280 | 1196 | } | 
|---|
| .. | .. | 
|---|
| 1284 | 1200 |  | 
|---|
| 1285 | 1201 | /* | 
|---|
| 1286 | 1202 | * in the Post-PMD event of mixer we need to do following: | 
|---|
| 1287 |  | - *   - Free the mcps used | 
|---|
| 1288 |  | - *   - Free the mem used | 
|---|
| 1289 | 1203 | *   - Unbind the modules within the pipeline | 
|---|
| 1290 | 1204 | *   - Delete the pipeline (modules are not required to be explicitly | 
|---|
| 1291 | 1205 | *     deleted, pipeline delete is enough here | 
|---|
| 1292 | 1206 | */ | 
|---|
| 1293 | 1207 | static int skl_tplg_mixer_dapm_post_pmd_event(struct snd_soc_dapm_widget *w, | 
|---|
| 1294 |  | -							struct skl *skl) | 
|---|
|  | 1208 | +							struct skl_dev *skl) | 
|---|
| 1295 | 1209 | { | 
|---|
| 1296 | 1210 | struct skl_module_cfg *mconfig = w->priv; | 
|---|
| 1297 | 1211 | struct skl_pipe_module *w_module; | 
|---|
| 1298 | 1212 | struct skl_module_cfg *src_module = NULL, *dst_module; | 
|---|
| 1299 |  | -	struct skl_sst *ctx = skl->skl_sst; | 
|---|
| 1300 | 1213 | struct skl_pipe *s_pipe = mconfig->pipe; | 
|---|
| 1301 | 1214 | struct skl_module_deferred_bind *modules, *tmp; | 
|---|
| 1302 | 1215 |  | 
|---|
| 1303 | 1216 | if (s_pipe->state == SKL_PIPE_INVALID) | 
|---|
| 1304 | 1217 | return -EINVAL; | 
|---|
| 1305 |  | - | 
|---|
| 1306 |  | -	skl_tplg_free_pipe_mcps(skl, mconfig); | 
|---|
| 1307 |  | -	skl_tplg_free_pipe_mem(skl, mconfig); | 
|---|
| 1308 | 1218 |  | 
|---|
| 1309 | 1219 | list_for_each_entry(w_module, &s_pipe->w_list, node) { | 
|---|
| 1310 | 1220 | if (list_empty(&skl->bind_list)) | 
|---|
| .. | .. | 
|---|
| 1318 | 1228 | * modules from deferred bind list. | 
|---|
| 1319 | 1229 | */ | 
|---|
| 1320 | 1230 | if (modules->dst == src_module) { | 
|---|
| 1321 |  | -				skl_unbind_modules(ctx, modules->src, | 
|---|
|  | 1231 | +				skl_unbind_modules(skl, modules->src, | 
|---|
| 1322 | 1232 | modules->dst); | 
|---|
| 1323 | 1233 | } | 
|---|
| 1324 | 1234 |  | 
|---|
| .. | .. | 
|---|
| 1338 | 1248 | list_for_each_entry(w_module, &s_pipe->w_list, node) { | 
|---|
| 1339 | 1249 | dst_module = w_module->w->priv; | 
|---|
| 1340 | 1250 |  | 
|---|
| 1341 |  | -		if (mconfig->m_state >= SKL_MODULE_INIT_DONE) | 
|---|
| 1342 |  | -			skl_tplg_free_pipe_mcps(skl, dst_module); | 
|---|
| 1343 | 1251 | if (src_module == NULL) { | 
|---|
| 1344 | 1252 | src_module = dst_module; | 
|---|
| 1345 | 1253 | continue; | 
|---|
| 1346 | 1254 | } | 
|---|
| 1347 | 1255 |  | 
|---|
| 1348 |  | -		skl_unbind_modules(ctx, src_module, dst_module); | 
|---|
|  | 1256 | +		skl_unbind_modules(skl, src_module, dst_module); | 
|---|
| 1349 | 1257 | src_module = dst_module; | 
|---|
| 1350 | 1258 | } | 
|---|
| 1351 | 1259 |  | 
|---|
| 1352 |  | -	skl_delete_pipe(ctx, mconfig->pipe); | 
|---|
|  | 1260 | +	skl_delete_pipe(skl, mconfig->pipe); | 
|---|
| 1353 | 1261 |  | 
|---|
| 1354 | 1262 | list_for_each_entry(w_module, &s_pipe->w_list, node) { | 
|---|
| 1355 | 1263 | src_module = w_module->w->priv; | 
|---|
| 1356 | 1264 | src_module->m_state = SKL_MODULE_UNINIT; | 
|---|
| 1357 | 1265 | } | 
|---|
| 1358 | 1266 |  | 
|---|
| 1359 |  | -	return skl_tplg_unload_pipe_modules(ctx, s_pipe); | 
|---|
|  | 1267 | +	return skl_tplg_unload_pipe_modules(skl, s_pipe); | 
|---|
| 1360 | 1268 | } | 
|---|
| 1361 | 1269 |  | 
|---|
| 1362 | 1270 | /* | 
|---|
| 1363 | 1271 | * in the Post-PMD event of PGA we need to do following: | 
|---|
| 1364 |  | - *   - Free the mcps used | 
|---|
| 1365 | 1272 | *   - Stop the pipeline | 
|---|
| 1366 | 1273 | *   - In source pipe is connected, unbind with source pipelines | 
|---|
| 1367 | 1274 | */ | 
|---|
| 1368 | 1275 | static int skl_tplg_pga_dapm_post_pmd_event(struct snd_soc_dapm_widget *w, | 
|---|
| 1369 |  | -								struct skl *skl) | 
|---|
|  | 1276 | +							struct skl_dev *skl) | 
|---|
| 1370 | 1277 | { | 
|---|
| 1371 | 1278 | struct skl_module_cfg *src_mconfig, *sink_mconfig; | 
|---|
| 1372 | 1279 | int ret = 0, i; | 
|---|
| 1373 |  | -	struct skl_sst *ctx = skl->skl_sst; | 
|---|
| 1374 | 1280 |  | 
|---|
| 1375 | 1281 | src_mconfig = w->priv; | 
|---|
| 1376 | 1282 |  | 
|---|
| 1377 | 1283 | /* Stop the pipe since this is a mixin module */ | 
|---|
| 1378 |  | -	ret = skl_stop_pipe(ctx, src_mconfig->pipe); | 
|---|
|  | 1284 | +	ret = skl_stop_pipe(skl, src_mconfig->pipe); | 
|---|
| 1379 | 1285 | if (ret) | 
|---|
| 1380 | 1286 | return ret; | 
|---|
| 1381 | 1287 |  | 
|---|
| .. | .. | 
|---|
| 1388 | 1294 | * This is a connecter and if path is found that means | 
|---|
| 1389 | 1295 | * unbind between source and sink has not happened yet | 
|---|
| 1390 | 1296 | */ | 
|---|
| 1391 |  | -			ret = skl_unbind_modules(ctx, src_mconfig, | 
|---|
|  | 1297 | +			ret = skl_unbind_modules(skl, src_mconfig, | 
|---|
| 1392 | 1298 | sink_mconfig); | 
|---|
| 1393 | 1299 | } | 
|---|
| 1394 | 1300 | } | 
|---|
| .. | .. | 
|---|
| 1406 | 1312 | struct snd_kcontrol *k, int event) | 
|---|
| 1407 | 1313 | { | 
|---|
| 1408 | 1314 | struct snd_soc_dapm_context *dapm = w->dapm; | 
|---|
| 1409 |  | -	struct skl *skl = get_skl_ctx(dapm->dev); | 
|---|
|  | 1315 | +	struct skl_dev *skl = get_skl_ctx(dapm->dev); | 
|---|
| 1410 | 1316 |  | 
|---|
| 1411 | 1317 | switch (event) { | 
|---|
| 1412 | 1318 | case SND_SOC_DAPM_PRE_PMU: | 
|---|
| .. | .. | 
|---|
| 1436 | 1342 |  | 
|---|
| 1437 | 1343 | { | 
|---|
| 1438 | 1344 | struct snd_soc_dapm_context *dapm = w->dapm; | 
|---|
| 1439 |  | -	struct skl *skl = get_skl_ctx(dapm->dev); | 
|---|
|  | 1345 | +	struct skl_dev *skl = get_skl_ctx(dapm->dev); | 
|---|
| 1440 | 1346 |  | 
|---|
| 1441 | 1347 | switch (event) { | 
|---|
| 1442 | 1348 | case SND_SOC_DAPM_PRE_PMU: | 
|---|
| .. | .. | 
|---|
| 1449 | 1355 | return 0; | 
|---|
| 1450 | 1356 | } | 
|---|
| 1451 | 1357 |  | 
|---|
|  | 1358 | +static int skl_tplg_multi_config_set_get(struct snd_kcontrol *kcontrol, | 
|---|
|  | 1359 | +					 struct snd_ctl_elem_value *ucontrol, | 
|---|
|  | 1360 | +					 bool is_set) | 
|---|
|  | 1361 | +{ | 
|---|
|  | 1362 | +	struct snd_soc_component *component = | 
|---|
|  | 1363 | +		snd_soc_kcontrol_component(kcontrol); | 
|---|
|  | 1364 | +	struct hdac_bus *bus = snd_soc_component_get_drvdata(component); | 
|---|
|  | 1365 | +	struct skl_dev *skl = bus_to_skl(bus); | 
|---|
|  | 1366 | +	struct skl_pipeline *ppl; | 
|---|
|  | 1367 | +	struct skl_pipe *pipe = NULL; | 
|---|
|  | 1368 | +	struct soc_enum *ec = (struct soc_enum *)kcontrol->private_value; | 
|---|
|  | 1369 | +	u32 *pipe_id; | 
|---|
|  | 1370 | + | 
|---|
|  | 1371 | +	if (!ec) | 
|---|
|  | 1372 | +		return -EINVAL; | 
|---|
|  | 1373 | + | 
|---|
|  | 1374 | +	if (is_set && ucontrol->value.enumerated.item[0] > ec->items) | 
|---|
|  | 1375 | +		return -EINVAL; | 
|---|
|  | 1376 | + | 
|---|
|  | 1377 | +	pipe_id = ec->dobj.private; | 
|---|
|  | 1378 | + | 
|---|
|  | 1379 | +	list_for_each_entry(ppl, &skl->ppl_list, node) { | 
|---|
|  | 1380 | +		if (ppl->pipe->ppl_id == *pipe_id) { | 
|---|
|  | 1381 | +			pipe = ppl->pipe; | 
|---|
|  | 1382 | +			break; | 
|---|
|  | 1383 | +		} | 
|---|
|  | 1384 | +	} | 
|---|
|  | 1385 | +	if (!pipe) | 
|---|
|  | 1386 | +		return -EIO; | 
|---|
|  | 1387 | + | 
|---|
|  | 1388 | +	if (is_set) | 
|---|
|  | 1389 | +		pipe->pipe_config_idx = ucontrol->value.enumerated.item[0]; | 
|---|
|  | 1390 | +	else | 
|---|
|  | 1391 | +		ucontrol->value.enumerated.item[0]  =  pipe->pipe_config_idx; | 
|---|
|  | 1392 | + | 
|---|
|  | 1393 | +	return 0; | 
|---|
|  | 1394 | +} | 
|---|
|  | 1395 | + | 
|---|
|  | 1396 | +static int skl_tplg_multi_config_get(struct snd_kcontrol *kcontrol, | 
|---|
|  | 1397 | +				     struct snd_ctl_elem_value *ucontrol) | 
|---|
|  | 1398 | +{ | 
|---|
|  | 1399 | +	return skl_tplg_multi_config_set_get(kcontrol, ucontrol, false); | 
|---|
|  | 1400 | +} | 
|---|
|  | 1401 | + | 
|---|
|  | 1402 | +static int skl_tplg_multi_config_set(struct snd_kcontrol *kcontrol, | 
|---|
|  | 1403 | +				     struct snd_ctl_elem_value *ucontrol) | 
|---|
|  | 1404 | +{ | 
|---|
|  | 1405 | +	return skl_tplg_multi_config_set_get(kcontrol, ucontrol, true); | 
|---|
|  | 1406 | +} | 
|---|
|  | 1407 | + | 
|---|
|  | 1408 | +static int skl_tplg_multi_config_get_dmic(struct snd_kcontrol *kcontrol, | 
|---|
|  | 1409 | +					  struct snd_ctl_elem_value *ucontrol) | 
|---|
|  | 1410 | +{ | 
|---|
|  | 1411 | +	return skl_tplg_multi_config_set_get(kcontrol, ucontrol, false); | 
|---|
|  | 1412 | +} | 
|---|
|  | 1413 | + | 
|---|
|  | 1414 | +static int skl_tplg_multi_config_set_dmic(struct snd_kcontrol *kcontrol, | 
|---|
|  | 1415 | +					  struct snd_ctl_elem_value *ucontrol) | 
|---|
|  | 1416 | +{ | 
|---|
|  | 1417 | +	return skl_tplg_multi_config_set_get(kcontrol, ucontrol, true); | 
|---|
|  | 1418 | +} | 
|---|
|  | 1419 | + | 
|---|
| 1452 | 1420 | static int skl_tplg_tlv_control_get(struct snd_kcontrol *kcontrol, | 
|---|
| 1453 | 1421 | unsigned int __user *data, unsigned int size) | 
|---|
| 1454 | 1422 | { | 
|---|
| .. | .. | 
|---|
| 1457 | 1425 | struct skl_algo_data *bc = (struct skl_algo_data *)sb->dobj.private; | 
|---|
| 1458 | 1426 | struct snd_soc_dapm_widget *w = snd_soc_dapm_kcontrol_widget(kcontrol); | 
|---|
| 1459 | 1427 | struct skl_module_cfg *mconfig = w->priv; | 
|---|
| 1460 |  | -	struct skl *skl = get_skl_ctx(w->dapm->dev); | 
|---|
|  | 1428 | +	struct skl_dev *skl = get_skl_ctx(w->dapm->dev); | 
|---|
| 1461 | 1429 |  | 
|---|
| 1462 | 1430 | if (w->power) | 
|---|
| 1463 |  | -		skl_get_module_params(skl->skl_sst, (u32 *)bc->params, | 
|---|
|  | 1431 | +		skl_get_module_params(skl, (u32 *)bc->params, | 
|---|
| 1464 | 1432 | bc->size, bc->param_id, mconfig); | 
|---|
| 1465 | 1433 |  | 
|---|
| 1466 | 1434 | /* decrement size for TLV header */ | 
|---|
| .. | .. | 
|---|
| 1492 | 1460 | struct soc_bytes_ext *sb = | 
|---|
| 1493 | 1461 | (struct soc_bytes_ext *)kcontrol->private_value; | 
|---|
| 1494 | 1462 | struct skl_algo_data *ac = (struct skl_algo_data *)sb->dobj.private; | 
|---|
| 1495 |  | -	struct skl *skl = get_skl_ctx(w->dapm->dev); | 
|---|
|  | 1463 | +	struct skl_dev *skl = get_skl_ctx(w->dapm->dev); | 
|---|
| 1496 | 1464 |  | 
|---|
| 1497 | 1465 | if (ac->params) { | 
|---|
| 1498 | 1466 | if (size > ac->max) | 
|---|
| 1499 | 1467 | return -EINVAL; | 
|---|
| 1500 |  | - | 
|---|
| 1501 | 1468 | ac->size = size; | 
|---|
| 1502 |  | -		/* | 
|---|
| 1503 |  | -		 * if the param_is is of type Vendor, firmware expects actual | 
|---|
| 1504 |  | -		 * parameter id and size from the control. | 
|---|
| 1505 |  | -		 */ | 
|---|
| 1506 |  | -		if (ac->param_id == SKL_PARAM_VENDOR_ID) { | 
|---|
| 1507 |  | -			if (copy_from_user(ac->params, data, size)) | 
|---|
| 1508 |  | -				return -EFAULT; | 
|---|
| 1509 |  | -		} else { | 
|---|
| 1510 |  | -			if (copy_from_user(ac->params, | 
|---|
| 1511 |  | -					   data + 2, size)) | 
|---|
| 1512 |  | -				return -EFAULT; | 
|---|
| 1513 |  | -		} | 
|---|
|  | 1469 | + | 
|---|
|  | 1470 | +		if (copy_from_user(ac->params, data, size)) | 
|---|
|  | 1471 | +			return -EFAULT; | 
|---|
| 1514 | 1472 |  | 
|---|
| 1515 | 1473 | if (w->power) | 
|---|
| 1516 |  | -			return skl_set_module_params(skl->skl_sst, | 
|---|
|  | 1474 | +			return skl_set_module_params(skl, | 
|---|
| 1517 | 1475 | (u32 *)ac->params, ac->size, | 
|---|
| 1518 | 1476 | ac->param_id, mconfig); | 
|---|
| 1519 | 1477 | } | 
|---|
| .. | .. | 
|---|
| 1673 | 1631 | struct skl_module_cfg *mconfig, | 
|---|
| 1674 | 1632 | struct skl_pipe_params *params) | 
|---|
| 1675 | 1633 | { | 
|---|
| 1676 |  | -	struct skl_module_res *res = &mconfig->module->resources[0]; | 
|---|
| 1677 |  | -	struct skl *skl = get_skl_ctx(dev); | 
|---|
|  | 1634 | +	struct skl_module_res *res; | 
|---|
|  | 1635 | +	struct skl_dev *skl = get_skl_ctx(dev); | 
|---|
| 1678 | 1636 | struct skl_module_fmt *format = NULL; | 
|---|
| 1679 | 1637 | u8 cfg_idx = mconfig->pipe->cur_config_idx; | 
|---|
| 1680 | 1638 |  | 
|---|
|  | 1639 | +	res = &mconfig->module->resources[mconfig->res_idx]; | 
|---|
| 1681 | 1640 | skl_tplg_fill_dma_id(mconfig, params); | 
|---|
| 1682 | 1641 | mconfig->fmt_idx = mconfig->mod_cfg[cfg_idx].fmt_idx; | 
|---|
| 1683 | 1642 | mconfig->res_idx = mconfig->mod_cfg[cfg_idx].res_idx; | 
|---|
| .. | .. | 
|---|
| 1686 | 1645 | return 0; | 
|---|
| 1687 | 1646 |  | 
|---|
| 1688 | 1647 | if (params->stream == SNDRV_PCM_STREAM_PLAYBACK) | 
|---|
| 1689 |  | -		format = &mconfig->module->formats[0].inputs[0].fmt; | 
|---|
|  | 1648 | +		format = &mconfig->module->formats[mconfig->fmt_idx].inputs[0].fmt; | 
|---|
| 1690 | 1649 | else | 
|---|
| 1691 |  | -		format = &mconfig->module->formats[0].outputs[0].fmt; | 
|---|
|  | 1650 | +		format = &mconfig->module->formats[mconfig->fmt_idx].outputs[0].fmt; | 
|---|
| 1692 | 1651 |  | 
|---|
| 1693 | 1652 | /* set the hw_params */ | 
|---|
| 1694 | 1653 | format->s_freq = params->s_freq; | 
|---|
| .. | .. | 
|---|
| 1871 | 1830 | struct skl_pipe_params *params) | 
|---|
| 1872 | 1831 | { | 
|---|
| 1873 | 1832 | struct nhlt_specific_cfg *cfg; | 
|---|
| 1874 |  | -	struct skl *skl = get_skl_ctx(dai->dev); | 
|---|
|  | 1833 | +	struct skl_dev *skl = get_skl_ctx(dai->dev); | 
|---|
| 1875 | 1834 | int link_type = skl_tplg_be_link_type(mconfig->dev_type); | 
|---|
| 1876 | 1835 | u8 dev_type = skl_tplg_be_dev_type(mconfig->dev_type); | 
|---|
| 1877 | 1836 |  | 
|---|
| .. | .. | 
|---|
| 1929 | 1888 | static int skl_tplg_be_set_sink_pipe_params(struct snd_soc_dai *dai, | 
|---|
| 1930 | 1889 | struct snd_soc_dapm_widget *w, struct skl_pipe_params *params) | 
|---|
| 1931 | 1890 | { | 
|---|
| 1932 |  | -	struct snd_soc_dapm_path *p = NULL; | 
|---|
|  | 1891 | +	struct snd_soc_dapm_path *p; | 
|---|
| 1933 | 1892 | int ret = -EIO; | 
|---|
| 1934 | 1893 |  | 
|---|
| 1935 | 1894 | snd_soc_dapm_widget_for_each_sink_path(w, p) { | 
|---|
| .. | .. | 
|---|
| 1992 | 1951 | .get = skl_tplg_mic_control_get, | 
|---|
| 1993 | 1952 | .put = skl_tplg_mic_control_set, | 
|---|
| 1994 | 1953 | }, | 
|---|
|  | 1954 | +	{ | 
|---|
|  | 1955 | +		.id = SKL_CONTROL_TYPE_MULTI_IO_SELECT, | 
|---|
|  | 1956 | +		.get = skl_tplg_multi_config_get, | 
|---|
|  | 1957 | +		.put = skl_tplg_multi_config_set, | 
|---|
|  | 1958 | +	}, | 
|---|
|  | 1959 | +	{ | 
|---|
|  | 1960 | +		.id = SKL_CONTROL_TYPE_MULTI_IO_SELECT_DMIC, | 
|---|
|  | 1961 | +		.get = skl_tplg_multi_config_get_dmic, | 
|---|
|  | 1962 | +		.put = skl_tplg_multi_config_set_dmic, | 
|---|
|  | 1963 | +	} | 
|---|
| 1995 | 1964 | }; | 
|---|
| 1996 | 1965 |  | 
|---|
| 1997 | 1966 | static int skl_tplg_fill_pipe_cfg(struct device *dev, | 
|---|
| .. | .. | 
|---|
| 2085 | 2054 | * Return an existing pipe if the pipe already exists. | 
|---|
| 2086 | 2055 | */ | 
|---|
| 2087 | 2056 | static int skl_tplg_add_pipe(struct device *dev, | 
|---|
| 2088 |  | -		struct skl_module_cfg *mconfig, struct skl *skl, | 
|---|
|  | 2057 | +		struct skl_module_cfg *mconfig, struct skl_dev *skl, | 
|---|
| 2089 | 2058 | struct snd_soc_tplg_vendor_value_elem *tkn_elem) | 
|---|
| 2090 | 2059 | { | 
|---|
| 2091 | 2060 | struct skl_pipeline *ppl; | 
|---|
| .. | .. | 
|---|
| 2124 | 2093 | return 0; | 
|---|
| 2125 | 2094 | } | 
|---|
| 2126 | 2095 |  | 
|---|
| 2127 |  | -static int skl_tplg_get_uuid(struct device *dev, u8 *guid, | 
|---|
|  | 2096 | +static int skl_tplg_get_uuid(struct device *dev, guid_t *guid, | 
|---|
| 2128 | 2097 | struct snd_soc_tplg_vendor_uuid_elem *uuid_tkn) | 
|---|
| 2129 | 2098 | { | 
|---|
| 2130 | 2099 | if (uuid_tkn->token == SKL_TKN_UUID) { | 
|---|
| 2131 |  | -		memcpy(guid, &uuid_tkn->uuid, 16); | 
|---|
|  | 2100 | +		import_guid(guid, uuid_tkn->uuid); | 
|---|
| 2132 | 2101 | return 0; | 
|---|
| 2133 | 2102 | } | 
|---|
| 2134 | 2103 |  | 
|---|
| .. | .. | 
|---|
| 2154 | 2123 | break; | 
|---|
| 2155 | 2124 |  | 
|---|
| 2156 | 2125 | case SKL_TKN_UUID: | 
|---|
| 2157 |  | -		ret = skl_tplg_get_uuid(dev, m_pin[pin_index].id.mod_uuid.b, | 
|---|
|  | 2126 | +		ret = skl_tplg_get_uuid(dev, &m_pin[pin_index].id.mod_uuid, | 
|---|
| 2158 | 2127 | (struct snd_soc_tplg_vendor_uuid_elem *)tkn_elem); | 
|---|
| 2159 | 2128 | if (ret < 0) | 
|---|
| 2160 | 2129 | return ret; | 
|---|
| .. | .. | 
|---|
| 2345 | 2314 | return -EINVAL; | 
|---|
| 2346 | 2315 |  | 
|---|
| 2347 | 2316 | switch (tkn_elem->token) { | 
|---|
| 2348 |  | -	case SKL_TKN_MM_U32_CPS: | 
|---|
| 2349 |  | -		res->cps = tkn_elem->value; | 
|---|
| 2350 |  | -		break; | 
|---|
| 2351 |  | - | 
|---|
| 2352 | 2317 | case SKL_TKN_MM_U32_DMA_SIZE: | 
|---|
| 2353 | 2318 | res->dma_buffer_size = tkn_elem->value; | 
|---|
| 2354 | 2319 | break; | 
|---|
| .. | .. | 
|---|
| 2369 | 2334 | res->ibs = tkn_elem->value; | 
|---|
| 2370 | 2335 | break; | 
|---|
| 2371 | 2336 |  | 
|---|
| 2372 |  | -	case SKL_TKN_U32_MAX_MCPS: | 
|---|
| 2373 |  | -		res->cps = tkn_elem->value; | 
|---|
| 2374 |  | -		break; | 
|---|
| 2375 |  | - | 
|---|
| 2376 | 2337 | case SKL_TKN_MM_U32_RES_PIN_ID: | 
|---|
| 2377 | 2338 | case SKL_TKN_MM_U32_PIN_BUF: | 
|---|
| 2378 | 2339 | ret = skl_tplg_manifest_pin_res_tkn(dev, tkn_elem, res, | 
|---|
| 2379 | 2340 | pin_idx, dir); | 
|---|
| 2380 | 2341 | if (ret < 0) | 
|---|
| 2381 | 2342 | return ret; | 
|---|
|  | 2343 | +		break; | 
|---|
|  | 2344 | + | 
|---|
|  | 2345 | +	case SKL_TKN_MM_U32_CPS: | 
|---|
|  | 2346 | +	case SKL_TKN_U32_MAX_MCPS: | 
|---|
|  | 2347 | +		/* ignore unused tokens */ | 
|---|
| 2382 | 2348 | break; | 
|---|
| 2383 | 2349 |  | 
|---|
| 2384 | 2350 | default: | 
|---|
| .. | .. | 
|---|
| 2396 | 2362 | */ | 
|---|
| 2397 | 2363 | static int skl_tplg_get_token(struct device *dev, | 
|---|
| 2398 | 2364 | struct snd_soc_tplg_vendor_value_elem *tkn_elem, | 
|---|
| 2399 |  | -		struct skl *skl, struct skl_module_cfg *mconfig) | 
|---|
|  | 2365 | +		struct skl_dev *skl, struct skl_module_cfg *mconfig) | 
|---|
| 2400 | 2366 | { | 
|---|
| 2401 | 2367 | int tkn_count = 0; | 
|---|
| 2402 | 2368 | int ret; | 
|---|
| .. | .. | 
|---|
| 2646 | 2612 | * module private data | 
|---|
| 2647 | 2613 | */ | 
|---|
| 2648 | 2614 | static int skl_tplg_get_tokens(struct device *dev, | 
|---|
| 2649 |  | -		char *pvt_data,	struct skl *skl, | 
|---|
|  | 2615 | +		char *pvt_data,	struct skl_dev *skl, | 
|---|
| 2650 | 2616 | struct skl_module_cfg *mconfig, int block_size) | 
|---|
| 2651 | 2617 | { | 
|---|
| 2652 | 2618 | struct snd_soc_tplg_vendor_array *array; | 
|---|
| .. | .. | 
|---|
| 2670 | 2636 |  | 
|---|
| 2671 | 2637 | case SND_SOC_TPLG_TUPLE_TYPE_UUID: | 
|---|
| 2672 | 2638 | if (is_module_guid) { | 
|---|
| 2673 |  | -				ret = skl_tplg_get_uuid(dev, mconfig->guid, | 
|---|
|  | 2639 | +				ret = skl_tplg_get_uuid(dev, (guid_t *)mconfig->guid, | 
|---|
| 2674 | 2640 | array->uuid); | 
|---|
| 2675 | 2641 | is_module_guid = false; | 
|---|
| 2676 | 2642 | } else { | 
|---|
| .. | .. | 
|---|
| 2742 | 2708 | * Otherwise we create a new instance and add into driver list | 
|---|
| 2743 | 2709 | */ | 
|---|
| 2744 | 2710 | static int skl_tplg_add_pipe_v4(struct device *dev, | 
|---|
| 2745 |  | -				struct skl_module_cfg *mconfig, struct skl *skl, | 
|---|
| 2746 |  | -				struct skl_dfw_v4_pipe *dfw_pipe) | 
|---|
|  | 2711 | +			struct skl_module_cfg *mconfig, struct skl_dev *skl, | 
|---|
|  | 2712 | +			struct skl_dfw_v4_pipe *dfw_pipe) | 
|---|
| 2747 | 2713 | { | 
|---|
| 2748 | 2714 | struct skl_pipeline *ppl; | 
|---|
| 2749 | 2715 | struct skl_pipe *pipe; | 
|---|
| .. | .. | 
|---|
| 2819 | 2785 | } | 
|---|
| 2820 | 2786 |  | 
|---|
| 2821 | 2787 | static int skl_tplg_get_pvt_data_v4(struct snd_soc_tplg_dapm_widget *tplg_w, | 
|---|
| 2822 |  | -				    struct skl *skl, struct device *dev, | 
|---|
|  | 2788 | +				    struct skl_dev *skl, struct device *dev, | 
|---|
| 2823 | 2789 | struct skl_module_cfg *mconfig) | 
|---|
| 2824 | 2790 | { | 
|---|
| 2825 | 2791 | struct skl_dfw_v4_module *dfw = | 
|---|
| .. | .. | 
|---|
| 2833 | 2799 | return ret; | 
|---|
| 2834 | 2800 | mconfig->id.module_id = -1; | 
|---|
| 2835 | 2801 | mconfig->id.instance_id = dfw->instance_id; | 
|---|
| 2836 |  | -	mconfig->module->resources[0].cps = dfw->max_mcps; | 
|---|
|  | 2802 | +	mconfig->module->resources[0].cpc = dfw->max_mcps / 1000; | 
|---|
| 2837 | 2803 | mconfig->module->resources[0].ibs = dfw->ibs; | 
|---|
| 2838 | 2804 | mconfig->module->resources[0].obs = dfw->obs; | 
|---|
| 2839 | 2805 | mconfig->core_id = dfw->core_id; | 
|---|
| .. | .. | 
|---|
| 2901 | 2867 | * for the type and size of the suceeding data block. | 
|---|
| 2902 | 2868 | */ | 
|---|
| 2903 | 2869 | static int skl_tplg_get_pvt_data(struct snd_soc_tplg_dapm_widget *tplg_w, | 
|---|
| 2904 |  | -				struct skl *skl, struct device *dev, | 
|---|
|  | 2870 | +				struct skl_dev *skl, struct device *dev, | 
|---|
| 2905 | 2871 | struct skl_module_cfg *mconfig) | 
|---|
| 2906 | 2872 | { | 
|---|
| 2907 | 2873 | struct snd_soc_tplg_vendor_array *array; | 
|---|
| 2908 |  | -	int num_blocks, block_size = 0, block_type, off = 0; | 
|---|
|  | 2874 | +	int num_blocks, block_size, block_type, off = 0; | 
|---|
| 2909 | 2875 | char *data; | 
|---|
| 2910 | 2876 | int ret; | 
|---|
| 2911 | 2877 |  | 
|---|
| .. | .. | 
|---|
| 2996 | 2962 | } | 
|---|
| 2997 | 2963 | } | 
|---|
| 2998 | 2964 |  | 
|---|
| 2999 |  | -void skl_cleanup_resources(struct skl *skl) | 
|---|
|  | 2965 | +void skl_cleanup_resources(struct skl_dev *skl) | 
|---|
| 3000 | 2966 | { | 
|---|
| 3001 |  | -	struct skl_sst *ctx = skl->skl_sst; | 
|---|
| 3002 | 2967 | struct snd_soc_component *soc_component = skl->component; | 
|---|
| 3003 | 2968 | struct snd_soc_dapm_widget *w; | 
|---|
| 3004 | 2969 | struct snd_soc_card *card; | 
|---|
| .. | .. | 
|---|
| 3010 | 2975 | if (!card || !card->instantiated) | 
|---|
| 3011 | 2976 | return; | 
|---|
| 3012 | 2977 |  | 
|---|
| 3013 |  | -	skl->resource.mem = 0; | 
|---|
| 3014 |  | -	skl->resource.mcps = 0; | 
|---|
| 3015 |  | - | 
|---|
| 3016 | 2978 | list_for_each_entry(w, &card->widgets, list) { | 
|---|
| 3017 |  | -		if (is_skl_dsp_widget_type(w, ctx->dev) && w->priv != NULL) | 
|---|
|  | 2979 | +		if (is_skl_dsp_widget_type(w, skl->dev) && w->priv != NULL) | 
|---|
| 3018 | 2980 | skl_clear_pin_config(soc_component, w); | 
|---|
| 3019 | 2981 | } | 
|---|
| 3020 | 2982 |  | 
|---|
| 3021 |  | -	skl_clear_module_cnt(ctx->dsp); | 
|---|
|  | 2983 | +	skl_clear_module_cnt(skl->dsp); | 
|---|
| 3022 | 2984 | } | 
|---|
| 3023 | 2985 |  | 
|---|
| 3024 | 2986 | /* | 
|---|
| .. | .. | 
|---|
| 3034 | 2996 | { | 
|---|
| 3035 | 2997 | int ret; | 
|---|
| 3036 | 2998 | struct hdac_bus *bus = snd_soc_component_get_drvdata(cmpnt); | 
|---|
| 3037 |  | -	struct skl *skl = bus_to_skl(bus); | 
|---|
|  | 2999 | +	struct skl_dev *skl = bus_to_skl(bus); | 
|---|
| 3038 | 3000 | struct skl_module_cfg *mconfig; | 
|---|
| 3039 | 3001 |  | 
|---|
| 3040 | 3002 | if (!tplg_w->priv.size) | 
|---|
| .. | .. | 
|---|
| 3104 | 3066 | ac->size = dfw_ac->max; | 
|---|
| 3105 | 3067 |  | 
|---|
| 3106 | 3068 | if (ac->max) { | 
|---|
| 3107 |  | -		ac->params = (char *) devm_kzalloc(dev, ac->max, GFP_KERNEL); | 
|---|
|  | 3069 | +		ac->params = devm_kzalloc(dev, ac->max, GFP_KERNEL); | 
|---|
| 3108 | 3070 | if (!ac->params) | 
|---|
| 3109 | 3071 | return -ENOMEM; | 
|---|
| 3110 | 3072 |  | 
|---|
| .. | .. | 
|---|
| 3159 | 3121 | case SND_SOC_TPLG_CTL_ENUM: | 
|---|
| 3160 | 3122 | tplg_ec = container_of(hdr, | 
|---|
| 3161 | 3123 | struct snd_soc_tplg_enum_control, hdr); | 
|---|
| 3162 |  | -		if (kctl->access & SNDRV_CTL_ELEM_ACCESS_READWRITE) { | 
|---|
|  | 3124 | +		if (kctl->access & SNDRV_CTL_ELEM_ACCESS_READ) { | 
|---|
| 3163 | 3125 | se = (struct soc_enum *)kctl->private_value; | 
|---|
| 3164 | 3126 | if (tplg_ec->priv.size) | 
|---|
| 3165 |  | -				return skl_init_enum_data(bus->dev, se, | 
|---|
| 3166 |  | -						tplg_ec); | 
|---|
|  | 3127 | +				skl_init_enum_data(bus->dev, se, tplg_ec); | 
|---|
| 3167 | 3128 | } | 
|---|
|  | 3129 | + | 
|---|
|  | 3130 | +		/* | 
|---|
|  | 3131 | +		 * now that the control initializations are done, remove | 
|---|
|  | 3132 | +		 * write permission for the DMIC configuration enums to | 
|---|
|  | 3133 | +		 * avoid conflicts between NHLT settings and user interaction | 
|---|
|  | 3134 | +		 */ | 
|---|
|  | 3135 | + | 
|---|
|  | 3136 | +		if (hdr->ops.get == SKL_CONTROL_TYPE_MULTI_IO_SELECT_DMIC) | 
|---|
|  | 3137 | +			kctl->access = SNDRV_CTL_ELEM_ACCESS_READ; | 
|---|
|  | 3138 | + | 
|---|
| 3168 | 3139 | break; | 
|---|
| 3169 | 3140 |  | 
|---|
| 3170 | 3141 | default: | 
|---|
| .. | .. | 
|---|
| 3178 | 3149 |  | 
|---|
| 3179 | 3150 | static int skl_tplg_fill_str_mfest_tkn(struct device *dev, | 
|---|
| 3180 | 3151 | struct snd_soc_tplg_vendor_string_elem *str_elem, | 
|---|
| 3181 |  | -		struct skl *skl) | 
|---|
|  | 3152 | +		struct skl_dev *skl) | 
|---|
| 3182 | 3153 | { | 
|---|
| 3183 | 3154 | int tkn_count = 0; | 
|---|
| 3184 | 3155 | static int ref_count; | 
|---|
| 3185 | 3156 |  | 
|---|
| 3186 | 3157 | switch (str_elem->token) { | 
|---|
| 3187 | 3158 | case SKL_TKN_STR_LIB_NAME: | 
|---|
| 3188 |  | -		if (ref_count > skl->skl_sst->lib_count - 1) { | 
|---|
|  | 3159 | +		if (ref_count > skl->lib_count - 1) { | 
|---|
| 3189 | 3160 | ref_count = 0; | 
|---|
| 3190 | 3161 | return -EINVAL; | 
|---|
| 3191 | 3162 | } | 
|---|
| 3192 | 3163 |  | 
|---|
| 3193 |  | -		strncpy(skl->skl_sst->lib_info[ref_count].name, | 
|---|
|  | 3164 | +		strncpy(skl->lib_info[ref_count].name, | 
|---|
| 3194 | 3165 | str_elem->string, | 
|---|
| 3195 |  | -			ARRAY_SIZE(skl->skl_sst->lib_info[ref_count].name)); | 
|---|
|  | 3166 | +			ARRAY_SIZE(skl->lib_info[ref_count].name)); | 
|---|
| 3196 | 3167 | ref_count++; | 
|---|
| 3197 | 3168 | break; | 
|---|
| 3198 | 3169 |  | 
|---|
| .. | .. | 
|---|
| 3207 | 3178 |  | 
|---|
| 3208 | 3179 | static int skl_tplg_get_str_tkn(struct device *dev, | 
|---|
| 3209 | 3180 | struct snd_soc_tplg_vendor_array *array, | 
|---|
| 3210 |  | -		struct skl *skl) | 
|---|
|  | 3181 | +		struct skl_dev *skl) | 
|---|
| 3211 | 3182 | { | 
|---|
| 3212 | 3183 | int tkn_count = 0, ret; | 
|---|
| 3213 | 3184 | struct snd_soc_tplg_vendor_string_elem *str_elem; | 
|---|
| .. | .. | 
|---|
| 3314 | 3285 |  | 
|---|
| 3315 | 3286 | static int skl_tplg_get_int_tkn(struct device *dev, | 
|---|
| 3316 | 3287 | struct snd_soc_tplg_vendor_value_elem *tkn_elem, | 
|---|
| 3317 |  | -		struct skl *skl) | 
|---|
|  | 3288 | +		struct skl_dev *skl) | 
|---|
| 3318 | 3289 | { | 
|---|
| 3319 |  | -	int tkn_count = 0, ret, size; | 
|---|
|  | 3290 | +	int tkn_count = 0, ret; | 
|---|
| 3320 | 3291 | static int mod_idx, res_val_idx, intf_val_idx, dir, pin_idx; | 
|---|
| 3321 | 3292 | struct skl_module_res *res = NULL; | 
|---|
| 3322 | 3293 | struct skl_module_iface *fmt = NULL; | 
|---|
| .. | .. | 
|---|
| 3324 | 3295 | static struct skl_astate_param *astate_table; | 
|---|
| 3325 | 3296 | static int astate_cfg_idx, count; | 
|---|
| 3326 | 3297 | int i; | 
|---|
|  | 3298 | +	size_t size; | 
|---|
| 3327 | 3299 |  | 
|---|
| 3328 | 3300 | if (skl->modules) { | 
|---|
| 3329 | 3301 | mod = skl->modules[mod_idx]; | 
|---|
| .. | .. | 
|---|
| 3333 | 3305 |  | 
|---|
| 3334 | 3306 | switch (tkn_elem->token) { | 
|---|
| 3335 | 3307 | case SKL_TKN_U32_LIB_COUNT: | 
|---|
| 3336 |  | -		skl->skl_sst->lib_count = tkn_elem->value; | 
|---|
|  | 3308 | +		skl->lib_count = tkn_elem->value; | 
|---|
| 3337 | 3309 | break; | 
|---|
| 3338 | 3310 |  | 
|---|
| 3339 | 3311 | case SKL_TKN_U8_NUM_MOD: | 
|---|
| .. | .. | 
|---|
| 3367 | 3339 | return -EINVAL; | 
|---|
| 3368 | 3340 | } | 
|---|
| 3369 | 3341 |  | 
|---|
| 3370 |  | -		size = tkn_elem->value * sizeof(struct skl_astate_param) + | 
|---|
| 3371 |  | -				sizeof(count); | 
|---|
|  | 3342 | +		size = struct_size(skl->cfg.astate_cfg, astate_table, | 
|---|
|  | 3343 | +				   tkn_elem->value); | 
|---|
| 3372 | 3344 | skl->cfg.astate_cfg = devm_kzalloc(dev, size, GFP_KERNEL); | 
|---|
| 3373 | 3345 | if (!skl->cfg.astate_cfg) | 
|---|
| 3374 | 3346 | return -ENOMEM; | 
|---|
| .. | .. | 
|---|
| 3479 | 3451 | return tkn_count; | 
|---|
| 3480 | 3452 | } | 
|---|
| 3481 | 3453 |  | 
|---|
| 3482 |  | -static int skl_tplg_get_manifest_uuid(struct device *dev, | 
|---|
| 3483 |  | -				struct skl *skl, | 
|---|
| 3484 |  | -				struct snd_soc_tplg_vendor_uuid_elem *uuid_tkn) | 
|---|
| 3485 |  | -{ | 
|---|
| 3486 |  | -	static int ref_count; | 
|---|
| 3487 |  | -	struct skl_module *mod; | 
|---|
| 3488 |  | - | 
|---|
| 3489 |  | -	if (uuid_tkn->token == SKL_TKN_UUID) { | 
|---|
| 3490 |  | -		mod = skl->modules[ref_count]; | 
|---|
| 3491 |  | -		memcpy(&mod->uuid, &uuid_tkn->uuid, sizeof(uuid_tkn->uuid)); | 
|---|
| 3492 |  | -		ref_count++; | 
|---|
| 3493 |  | -	} else { | 
|---|
| 3494 |  | -		dev_err(dev, "Not an UUID token tkn %d\n", uuid_tkn->token); | 
|---|
| 3495 |  | -		return -EINVAL; | 
|---|
| 3496 |  | -	} | 
|---|
| 3497 |  | - | 
|---|
| 3498 |  | -	return 0; | 
|---|
| 3499 |  | -} | 
|---|
| 3500 |  | - | 
|---|
| 3501 | 3454 | /* | 
|---|
| 3502 | 3455 | * Fill the manifest structure by parsing the tokens based on the | 
|---|
| 3503 | 3456 | * type. | 
|---|
| 3504 | 3457 | */ | 
|---|
| 3505 | 3458 | static int skl_tplg_get_manifest_tkn(struct device *dev, | 
|---|
| 3506 |  | -		char *pvt_data, struct skl *skl, | 
|---|
|  | 3459 | +		char *pvt_data, struct skl_dev *skl, | 
|---|
| 3507 | 3460 | int block_size) | 
|---|
| 3508 | 3461 | { | 
|---|
| 3509 | 3462 | int tkn_count = 0, ret; | 
|---|
| 3510 | 3463 | int off = 0, tuple_size = 0; | 
|---|
|  | 3464 | +	u8 uuid_index = 0; | 
|---|
| 3511 | 3465 | struct snd_soc_tplg_vendor_array *array; | 
|---|
| 3512 | 3466 | struct snd_soc_tplg_vendor_value_elem *tkn_elem; | 
|---|
| 3513 | 3467 |  | 
|---|
| .. | .. | 
|---|
| 3530 | 3484 | continue; | 
|---|
| 3531 | 3485 |  | 
|---|
| 3532 | 3486 | case SND_SOC_TPLG_TUPLE_TYPE_UUID: | 
|---|
| 3533 |  | -			ret = skl_tplg_get_manifest_uuid(dev, skl, array->uuid); | 
|---|
| 3534 |  | -			if (ret < 0) | 
|---|
| 3535 |  | -				return ret; | 
|---|
|  | 3487 | +			if (array->uuid->token != SKL_TKN_UUID) { | 
|---|
|  | 3488 | +				dev_err(dev, "Not an UUID token: %d\n", | 
|---|
|  | 3489 | +					array->uuid->token); | 
|---|
|  | 3490 | +				return -EINVAL; | 
|---|
|  | 3491 | +			} | 
|---|
|  | 3492 | +			if (uuid_index >= skl->nr_modules) { | 
|---|
|  | 3493 | +				dev_err(dev, "Too many UUID tokens\n"); | 
|---|
|  | 3494 | +				return -EINVAL; | 
|---|
|  | 3495 | +			} | 
|---|
|  | 3496 | +			import_guid(&skl->modules[uuid_index++]->uuid, | 
|---|
|  | 3497 | +				    array->uuid->uuid); | 
|---|
| 3536 | 3498 |  | 
|---|
| 3537 | 3499 | tuple_size += sizeof(*array->uuid); | 
|---|
| 3538 | 3500 | continue; | 
|---|
| .. | .. | 
|---|
| 3564 | 3526 | * preceded by descriptors for type and size of data block. | 
|---|
| 3565 | 3527 | */ | 
|---|
| 3566 | 3528 | static int skl_tplg_get_manifest_data(struct snd_soc_tplg_manifest *manifest, | 
|---|
| 3567 |  | -			struct device *dev, struct skl *skl) | 
|---|
|  | 3529 | +			struct device *dev, struct skl_dev *skl) | 
|---|
| 3568 | 3530 | { | 
|---|
| 3569 | 3531 | struct snd_soc_tplg_vendor_array *array; | 
|---|
| 3570 | 3532 | int num_blocks, block_size = 0, block_type, off = 0; | 
|---|
| .. | .. | 
|---|
| 3626 | 3588 | struct snd_soc_tplg_manifest *manifest) | 
|---|
| 3627 | 3589 | { | 
|---|
| 3628 | 3590 | struct hdac_bus *bus = snd_soc_component_get_drvdata(cmpnt); | 
|---|
| 3629 |  | -	struct skl *skl = bus_to_skl(bus); | 
|---|
|  | 3591 | +	struct skl_dev *skl = bus_to_skl(bus); | 
|---|
| 3630 | 3592 |  | 
|---|
| 3631 | 3593 | /* proceed only if we have private data defined */ | 
|---|
| 3632 | 3594 | if (manifest->priv.size == 0) | 
|---|
| .. | .. | 
|---|
| 3634 | 3596 |  | 
|---|
| 3635 | 3597 | skl_tplg_get_manifest_data(manifest, bus->dev, skl); | 
|---|
| 3636 | 3598 |  | 
|---|
| 3637 |  | -	if (skl->skl_sst->lib_count > SKL_MAX_LIB) { | 
|---|
|  | 3599 | +	if (skl->lib_count > SKL_MAX_LIB) { | 
|---|
| 3638 | 3600 | dev_err(bus->dev, "Exceeding max Library count. Got:%d\n", | 
|---|
| 3639 |  | -					skl->skl_sst->lib_count); | 
|---|
|  | 3601 | +					skl->lib_count); | 
|---|
| 3640 | 3602 | return  -EINVAL; | 
|---|
| 3641 | 3603 | } | 
|---|
| 3642 | 3604 |  | 
|---|
| 3643 | 3605 | return 0; | 
|---|
|  | 3606 | +} | 
|---|
|  | 3607 | + | 
|---|
|  | 3608 | +static void skl_tplg_complete(struct snd_soc_component *component) | 
|---|
|  | 3609 | +{ | 
|---|
|  | 3610 | +	struct snd_soc_dobj *dobj; | 
|---|
|  | 3611 | +	struct snd_soc_acpi_mach *mach = | 
|---|
|  | 3612 | +		dev_get_platdata(component->card->dev); | 
|---|
|  | 3613 | +	int i; | 
|---|
|  | 3614 | + | 
|---|
|  | 3615 | +	list_for_each_entry(dobj, &component->dobj_list, list) { | 
|---|
|  | 3616 | +		struct snd_kcontrol *kcontrol = dobj->control.kcontrol; | 
|---|
|  | 3617 | +		struct soc_enum *se; | 
|---|
|  | 3618 | +		char **texts; | 
|---|
|  | 3619 | +		char chan_text[4]; | 
|---|
|  | 3620 | + | 
|---|
|  | 3621 | +		if (dobj->type != SND_SOC_DOBJ_ENUM || !kcontrol || | 
|---|
|  | 3622 | +		    kcontrol->put != skl_tplg_multi_config_set_dmic) | 
|---|
|  | 3623 | +			continue; | 
|---|
|  | 3624 | + | 
|---|
|  | 3625 | +		se = (struct soc_enum *)kcontrol->private_value; | 
|---|
|  | 3626 | +		texts = dobj->control.dtexts; | 
|---|
|  | 3627 | +		sprintf(chan_text, "c%d", mach->mach_params.dmic_num); | 
|---|
|  | 3628 | + | 
|---|
|  | 3629 | +		for (i = 0; i < se->items; i++) { | 
|---|
|  | 3630 | +			struct snd_ctl_elem_value val = {}; | 
|---|
|  | 3631 | + | 
|---|
|  | 3632 | +			if (strstr(texts[i], chan_text)) { | 
|---|
|  | 3633 | +				val.value.enumerated.item[0] = i; | 
|---|
|  | 3634 | +				kcontrol->put(kcontrol, &val); | 
|---|
|  | 3635 | +			} | 
|---|
|  | 3636 | +		} | 
|---|
|  | 3637 | +	} | 
|---|
| 3644 | 3638 | } | 
|---|
| 3645 | 3639 |  | 
|---|
| 3646 | 3640 | static struct snd_soc_tplg_ops skl_tplg_ops  = { | 
|---|
| .. | .. | 
|---|
| 3652 | 3646 | .io_ops_count = ARRAY_SIZE(skl_tplg_kcontrol_ops), | 
|---|
| 3653 | 3647 | .manifest = skl_manifest_load, | 
|---|
| 3654 | 3648 | .dai_load = skl_dai_load, | 
|---|
|  | 3649 | +	.complete = skl_tplg_complete, | 
|---|
| 3655 | 3650 | }; | 
|---|
| 3656 | 3651 |  | 
|---|
| 3657 | 3652 | /* | 
|---|
| .. | .. | 
|---|
| 3685 | 3680 | return 0; | 
|---|
| 3686 | 3681 | } | 
|---|
| 3687 | 3682 |  | 
|---|
| 3688 |  | -static void skl_tplg_set_pipe_type(struct skl *skl, struct skl_pipe *pipe) | 
|---|
|  | 3683 | +static void skl_tplg_set_pipe_type(struct skl_dev *skl, struct skl_pipe *pipe) | 
|---|
| 3689 | 3684 | { | 
|---|
| 3690 | 3685 | struct skl_pipe_module *w_module; | 
|---|
| 3691 | 3686 | struct snd_soc_dapm_widget *w; | 
|---|
| .. | .. | 
|---|
| 3708 | 3703 | pipe->passthru = false; | 
|---|
| 3709 | 3704 | } | 
|---|
| 3710 | 3705 |  | 
|---|
| 3711 |  | -/* This will be read from topology manifest, currently defined here */ | 
|---|
| 3712 |  | -#define SKL_MAX_MCPS 30000000 | 
|---|
| 3713 |  | -#define SKL_FW_MAX_MEM 1000000 | 
|---|
| 3714 |  | - | 
|---|
| 3715 | 3706 | /* | 
|---|
| 3716 | 3707 | * SKL topology init routine | 
|---|
| 3717 | 3708 | */ | 
|---|
| .. | .. | 
|---|
| 3719 | 3710 | { | 
|---|
| 3720 | 3711 | int ret; | 
|---|
| 3721 | 3712 | const struct firmware *fw; | 
|---|
| 3722 |  | -	struct skl *skl = bus_to_skl(bus); | 
|---|
|  | 3713 | +	struct skl_dev *skl = bus_to_skl(bus); | 
|---|
| 3723 | 3714 | struct skl_pipeline *ppl; | 
|---|
| 3724 | 3715 |  | 
|---|
| 3725 | 3716 | ret = request_firmware(&fw, skl->tplg_name, bus->dev); | 
|---|
| 3726 | 3717 | if (ret < 0) { | 
|---|
| 3727 |  | -		dev_info(bus->dev, "tplg fw %s load failed with %d, falling back to dfw_sst.bin", | 
|---|
| 3728 |  | -				skl->tplg_name, ret); | 
|---|
|  | 3718 | +		char alt_tplg_name[64]; | 
|---|
|  | 3719 | + | 
|---|
|  | 3720 | +		snprintf(alt_tplg_name, sizeof(alt_tplg_name), "%s-tplg.bin", | 
|---|
|  | 3721 | +			 skl->mach->drv_name); | 
|---|
|  | 3722 | +		dev_info(bus->dev, "tplg fw %s load failed with %d, trying alternative tplg name %s", | 
|---|
|  | 3723 | +			 skl->tplg_name, ret, alt_tplg_name); | 
|---|
|  | 3724 | + | 
|---|
|  | 3725 | +		ret = request_firmware(&fw, alt_tplg_name, bus->dev); | 
|---|
|  | 3726 | +		if (!ret) | 
|---|
|  | 3727 | +			goto component_load; | 
|---|
|  | 3728 | + | 
|---|
|  | 3729 | +		dev_info(bus->dev, "tplg %s failed with %d, falling back to dfw_sst.bin", | 
|---|
|  | 3730 | +			 alt_tplg_name, ret); | 
|---|
|  | 3731 | + | 
|---|
| 3729 | 3732 | ret = request_firmware(&fw, "dfw_sst.bin", bus->dev); | 
|---|
| 3730 | 3733 | if (ret < 0) { | 
|---|
| 3731 | 3734 | dev_err(bus->dev, "Fallback tplg fw %s load failed with %d\n", | 
|---|
| .. | .. | 
|---|
| 3734 | 3737 | } | 
|---|
| 3735 | 3738 | } | 
|---|
| 3736 | 3739 |  | 
|---|
|  | 3740 | +component_load: | 
|---|
|  | 3741 | + | 
|---|
| 3737 | 3742 | /* | 
|---|
| 3738 | 3743 | * The complete tplg for SKL is loaded as index 0, we don't use | 
|---|
| 3739 | 3744 | * any other index | 
|---|
| 3740 | 3745 | */ | 
|---|
| 3741 |  | -	ret = snd_soc_tplg_component_load(component, | 
|---|
| 3742 |  | -					&skl_tplg_ops, fw, 0); | 
|---|
|  | 3746 | +	ret = snd_soc_tplg_component_load(component, &skl_tplg_ops, fw, 0); | 
|---|
| 3743 | 3747 | if (ret < 0) { | 
|---|
| 3744 | 3748 | dev_err(bus->dev, "tplg component load failed%d\n", ret); | 
|---|
| 3745 |  | -		release_firmware(fw); | 
|---|
| 3746 |  | -		return -EINVAL; | 
|---|
|  | 3749 | +		goto err; | 
|---|
| 3747 | 3750 | } | 
|---|
| 3748 | 3751 |  | 
|---|
| 3749 |  | -	skl->resource.max_mcps = SKL_MAX_MCPS; | 
|---|
| 3750 |  | -	skl->resource.max_mem = SKL_FW_MAX_MEM; | 
|---|
| 3751 |  | - | 
|---|
| 3752 |  | -	skl->tplg = fw; | 
|---|
| 3753 | 3752 | ret = skl_tplg_create_pipe_widget_list(component); | 
|---|
| 3754 |  | -	if (ret < 0) | 
|---|
| 3755 |  | -		return ret; | 
|---|
|  | 3753 | +	if (ret < 0) { | 
|---|
|  | 3754 | +		dev_err(bus->dev, "tplg create pipe widget list failed%d\n", | 
|---|
|  | 3755 | +				ret); | 
|---|
|  | 3756 | +		goto err; | 
|---|
|  | 3757 | +	} | 
|---|
| 3756 | 3758 |  | 
|---|
| 3757 | 3759 | list_for_each_entry(ppl, &skl->ppl_list, node) | 
|---|
| 3758 | 3760 | skl_tplg_set_pipe_type(skl, ppl->pipe); | 
|---|
| 3759 | 3761 |  | 
|---|
| 3760 |  | -	return 0; | 
|---|
|  | 3762 | +err: | 
|---|
|  | 3763 | +	release_firmware(fw); | 
|---|
|  | 3764 | +	return ret; | 
|---|
|  | 3765 | +} | 
|---|
|  | 3766 | + | 
|---|
|  | 3767 | +void skl_tplg_exit(struct snd_soc_component *component, struct hdac_bus *bus) | 
|---|
|  | 3768 | +{ | 
|---|
|  | 3769 | +	struct skl_dev *skl = bus_to_skl(bus); | 
|---|
|  | 3770 | +	struct skl_pipeline *ppl, *tmp; | 
|---|
|  | 3771 | + | 
|---|
|  | 3772 | +	list_for_each_entry_safe(ppl, tmp, &skl->ppl_list, node) | 
|---|
|  | 3773 | +		list_del(&ppl->node); | 
|---|
|  | 3774 | + | 
|---|
|  | 3775 | +	/* clean up topology */ | 
|---|
|  | 3776 | +	snd_soc_tplg_component_remove(component, SND_SOC_TPLG_INDEX_ALL); | 
|---|
| 3761 | 3777 | } | 
|---|