Lines Matching +full:comp +full:- +full:int
1 // SPDX-License-Identifier: GPL-2.0-only
12 #include <sound/soc-acpi.h>
13 #include <sound/soc-topology.h>
26 (avs_tplg_vendor_array_at(array, le32_to_cpu((array)->size)))
33 * Returns 0 on success, -ENOENT if not found and error code otherwise.
35 static int
43 u32 tuples_size = le32_to_cpu(tuples->size); in avs_tplg_vendor_array_lookup()
46 return -EINVAL; in avs_tplg_vendor_array_lookup()
48 tuple = tuples->value; in avs_tplg_vendor_array_lookup()
49 if (le32_to_cpu(tuple->token) == token) { in avs_tplg_vendor_array_lookup()
54 block_size -= tuples_size; in avs_tplg_vendor_array_lookup()
59 return -ENOENT; in avs_tplg_vendor_array_lookup()
71 static int
75 u32 tuples_size = le32_to_cpu(tuples->size); in avs_tplg_vendor_array_lookup_next()
76 int ret; in avs_tplg_vendor_array_lookup_next()
79 return -EINVAL; in avs_tplg_vendor_array_lookup_next()
82 block_size -= tuples_size; in avs_tplg_vendor_array_lookup_next()
100 static int
104 int ret; in avs_tplg_vendor_entry_size()
107 if (ret == -ENOENT) { in avs_tplg_vendor_entry_size()
127 int (*parse)(struct snd_soc_component *comp, void *elem, void *object, u32 offset);
130 static int
131 avs_parse_uuid_token(struct snd_soc_component *comp, void *elem, void *object, u32 offset) in avs_parse_uuid_token() argument
136 guid_copy((guid_t *)val, (const guid_t *)&tuple->uuid); in avs_parse_uuid_token()
141 static int
142 avs_parse_bool_token(struct snd_soc_component *comp, void *elem, void *object, u32 offset) in avs_parse_bool_token() argument
147 *val = le32_to_cpu(tuple->value); in avs_parse_bool_token()
152 static int
153 avs_parse_byte_token(struct snd_soc_component *comp, void *elem, void *object, u32 offset) in avs_parse_byte_token() argument
158 *val = le32_to_cpu(tuple->value); in avs_parse_byte_token()
163 static int
164 avs_parse_short_token(struct snd_soc_component *comp, void *elem, void *object, u32 offset) in avs_parse_short_token() argument
169 *val = le32_to_cpu(tuple->value); in avs_parse_short_token()
174 static int
175 avs_parse_word_token(struct snd_soc_component *comp, void *elem, void *object, u32 offset) in avs_parse_word_token() argument
180 *val = le32_to_cpu(tuple->value); in avs_parse_word_token()
185 static int
186 avs_parse_string_token(struct snd_soc_component *comp, void *elem, void *object, u32 offset) in avs_parse_string_token() argument
191 snprintf(val, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, "%s", tuple->string); in avs_parse_string_token()
196 static int avs_parse_uuid_tokens(struct snd_soc_component *comp, void *object, in avs_parse_uuid_tokens() argument
197 const struct avs_tplg_token_parser *parsers, int count, in avs_parse_uuid_tokens()
201 int ret, i, j; in avs_parse_uuid_tokens()
204 for (i = 0; i < le32_to_cpu(tuples->num_elems); i++) { in avs_parse_uuid_tokens()
205 tuple = &tuples->uuid[i]; in avs_parse_uuid_tokens()
208 /* Ignore non-UUID tokens. */ in avs_parse_uuid_tokens()
210 parsers[j].token != le32_to_cpu(tuple->token)) in avs_parse_uuid_tokens()
213 ret = parsers[j].parse(comp, tuple, object, parsers[j].offset); in avs_parse_uuid_tokens()
222 static int avs_parse_string_tokens(struct snd_soc_component *comp, void *object, in avs_parse_string_tokens() argument
223 const struct avs_tplg_token_parser *parsers, int count, in avs_parse_string_tokens()
227 int ret, i, j; in avs_parse_string_tokens()
230 for (i = 0; i < le32_to_cpu(tuples->num_elems); i++) { in avs_parse_string_tokens()
231 tuple = &tuples->string[i]; in avs_parse_string_tokens()
234 /* Ignore non-string tokens. */ in avs_parse_string_tokens()
236 parsers[j].token != le32_to_cpu(tuple->token)) in avs_parse_string_tokens()
239 ret = parsers[j].parse(comp, tuple, object, parsers[j].offset); in avs_parse_string_tokens()
248 static int avs_parse_word_tokens(struct snd_soc_component *comp, void *object, in avs_parse_word_tokens() argument
249 const struct avs_tplg_token_parser *parsers, int count, in avs_parse_word_tokens()
253 int ret, i, j; in avs_parse_word_tokens()
256 for (i = 0; i < le32_to_cpu(tuples->num_elems); i++) { in avs_parse_word_tokens()
257 tuple = &tuples->value[i]; in avs_parse_word_tokens()
260 /* Ignore non-integer tokens. */ in avs_parse_word_tokens()
267 if (parsers[j].token != le32_to_cpu(tuple->token)) in avs_parse_word_tokens()
270 ret = parsers[j].parse(comp, tuple, object, parsers[j].offset); in avs_parse_word_tokens()
279 static int avs_parse_tokens(struct snd_soc_component *comp, void *object, in avs_parse_tokens() argument
281 struct snd_soc_tplg_vendor_array *tuples, int priv_size) in avs_parse_tokens()
283 int array_size, ret; in avs_parse_tokens()
286 array_size = le32_to_cpu(tuples->size); in avs_parse_tokens()
289 dev_err(comp->dev, "invalid array size 0x%x\n", array_size); in avs_parse_tokens()
290 return -EINVAL; in avs_parse_tokens()
294 priv_size -= array_size; in avs_parse_tokens()
296 dev_err(comp->dev, "invalid array size 0x%x\n", array_size); in avs_parse_tokens()
297 return -EINVAL; in avs_parse_tokens()
300 switch (le32_to_cpu(tuples->type)) { in avs_parse_tokens()
302 ret = avs_parse_uuid_tokens(comp, object, parsers, count, tuples); in avs_parse_tokens()
305 ret = avs_parse_string_tokens(comp, object, parsers, count, tuples); in avs_parse_tokens()
311 ret = avs_parse_word_tokens(comp, object, parsers, count, tuples); in avs_parse_tokens()
314 dev_err(comp->dev, "unknown token type %d\n", tuples->type); in avs_parse_tokens()
315 ret = -EINVAL; in avs_parse_tokens()
319 dev_err(comp->dev, "parsing %zu tokens of %d type failed: %d\n", in avs_parse_tokens()
320 count, tuples->type, ret); in avs_parse_tokens()
331 static int \
332 avs_parse_##name##_ptr(struct snd_soc_component *comp, void *elem, void *object, u32 offset) \
335 struct avs_soc_component *acomp = to_avs_soc_component(comp); \
339 idx = le32_to_cpu(tuple->value); \
340 if (idx >= acomp->tplg->num_##member) \
341 return -EINVAL; \
343 *val = &acomp->tplg->member[idx]; \
354 static int
355 parse_audio_format_bitfield(struct snd_soc_component *comp, void *elem, void *object, u32 offset) in parse_audio_format_bitfield() argument
362 audio_format->num_channels = le32_to_cpu(velem->value); in parse_audio_format_bitfield()
365 audio_format->valid_bit_depth = le32_to_cpu(velem->value); in parse_audio_format_bitfield()
368 audio_format->sample_type = le32_to_cpu(velem->value); in parse_audio_format_bitfield()
375 static int avs_ssp_sprint(char *buf, size_t size, const char *fmt, int port, int tdm) in avs_ssp_sprint()
378 int retsize; in avs_ssp_sprint()
386 retsize = scnprintf(buf, min_t(size_t, size, needle - fmt + 1), "%s", fmt); in avs_ssp_sprint()
387 retsize += scnprintf(buf + retsize, size - retsize, "%d", port); in avs_ssp_sprint()
389 retsize += scnprintf(buf + retsize, size - retsize, ":%d", tdm); in avs_ssp_sprint()
390 retsize += scnprintf(buf + retsize, size - retsize, "%s", needle + 2); in avs_ssp_sprint()
397 static int parse_link_formatted_string(struct snd_soc_component *comp, void *elem, in parse_link_formatted_string() argument
401 struct snd_soc_acpi_mach *mach = dev_get_platdata(comp->card->dev); in parse_link_formatted_string()
403 int ssp_port, tdm_slot; in parse_link_formatted_string()
406 * Dynamic naming - string formats, e.g.: ssp%d - supported only for in parse_link_formatted_string()
410 return avs_parse_string_token(comp, elem, object, offset); in parse_link_formatted_string()
414 return avs_parse_string_token(comp, elem, object, offset); in parse_link_formatted_string()
418 avs_ssp_sprint(val, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, tuple->string, ssp_port, tdm_slot); in parse_link_formatted_string()
423 static int
424 parse_dictionary_header(struct snd_soc_component *comp, in parse_dictionary_header() argument
431 /* Dictionary header consists of single tuple - entry count. */ in parse_dictionary_header()
432 tuple = tuples->value; in parse_dictionary_header()
433 if (le32_to_cpu(tuple->token) != num_entries_token) { in parse_dictionary_header()
434 dev_err(comp->dev, "invalid dictionary header, expected: %d\n", in parse_dictionary_header()
436 return -EINVAL; in parse_dictionary_header()
439 *num_entries = le32_to_cpu(tuple->value); in parse_dictionary_header()
440 *dict = devm_kcalloc(comp->card->dev, *num_entries, entry_size, GFP_KERNEL); in parse_dictionary_header()
442 return -ENOMEM; in parse_dictionary_header()
447 static int
448 parse_dictionary_entries(struct snd_soc_component *comp, in parse_dictionary_entries() argument
455 int i; in parse_dictionary_entries()
459 int ret; in parse_dictionary_entries()
466 ret = avs_parse_tokens(comp, pos, parsers, num_parsers, tuples, esize); in parse_dictionary_entries()
468 dev_err(comp->dev, "parse entry: %d of type: %d failed: %d\n", in parse_dictionary_entries()
474 block_size -= esize; in parse_dictionary_entries()
481 static int parse_dictionary(struct snd_soc_component *comp, in parse_dictionary() argument
487 int ret; in parse_dictionary()
489 ret = parse_dictionary_header(comp, tuples, dict, num_entries, in parse_dictionary()
494 block_size -= le32_to_cpu(tuples->size); in parse_dictionary()
498 return parse_dictionary_entries(comp, tuples, block_size, *dict, in parse_dictionary()
512 static int avs_tplg_parse_libraries(struct snd_soc_component *comp, in avs_tplg_parse_libraries() argument
515 struct avs_soc_component *acomp = to_avs_soc_component(comp); in avs_tplg_parse_libraries()
516 struct avs_tplg *tplg = acomp->tplg; in avs_tplg_parse_libraries()
518 return parse_dictionary(comp, tuples, block_size, (void **)&tplg->libs, in avs_tplg_parse_libraries()
519 &tplg->num_libs, sizeof(*tplg->libs), in avs_tplg_parse_libraries()
576 static int avs_tplg_parse_audio_formats(struct snd_soc_component *comp, in avs_tplg_parse_audio_formats() argument
580 struct avs_soc_component *acomp = to_avs_soc_component(comp); in avs_tplg_parse_audio_formats()
581 struct avs_tplg *tplg = acomp->tplg; in avs_tplg_parse_audio_formats()
583 return parse_dictionary(comp, tuples, block_size, (void **)&tplg->fmts, in avs_tplg_parse_audio_formats()
584 &tplg->num_fmts, sizeof(*tplg->fmts), in avs_tplg_parse_audio_formats()
617 static int avs_tplg_parse_modcfgs_base(struct snd_soc_component *comp, in avs_tplg_parse_modcfgs_base() argument
621 struct avs_soc_component *acomp = to_avs_soc_component(comp); in avs_tplg_parse_modcfgs_base()
622 struct avs_tplg *tplg = acomp->tplg; in avs_tplg_parse_modcfgs_base()
624 return parse_dictionary(comp, tuples, block_size, (void **)&tplg->modcfgs_base, in avs_tplg_parse_modcfgs_base()
625 &tplg->num_modcfgs_base, sizeof(*tplg->modcfgs_base), in avs_tplg_parse_modcfgs_base()
842 assign_copier_gtw_instance(struct snd_soc_component *comp, struct avs_tplg_modcfg_ext *cfg) in assign_copier_gtw_instance() argument
845 int ssp_port, tdm_slot; in assign_copier_gtw_instance()
847 if (!guid_equal(&cfg->type, &AVS_COPIER_MOD_UUID)) in assign_copier_gtw_instance()
850 /* Only I2S boards assign port instance in ->i2s_link_mask. */ in assign_copier_gtw_instance()
851 switch (cfg->copier.dma_type) { in assign_copier_gtw_instance()
860 if (cfg->copier.vindex.val) in assign_copier_gtw_instance()
863 mach = dev_get_platdata(comp->card->dev); in assign_copier_gtw_instance()
873 cfg->copier.vindex.i2s.instance = ssp_port; in assign_copier_gtw_instance()
874 cfg->copier.vindex.i2s.time_slot = tdm_slot; in assign_copier_gtw_instance()
877 static int avs_tplg_parse_modcfg_ext(struct snd_soc_component *comp, in avs_tplg_parse_modcfg_ext() argument
883 int ret; in avs_tplg_parse_modcfg_ext()
891 ret = avs_parse_tokens(comp, cfg, modcfg_ext_parsers, in avs_tplg_parse_modcfg_ext()
897 assign_copier_gtw_instance(comp, cfg); in avs_tplg_parse_modcfg_ext()
899 block_size -= esize; in avs_tplg_parse_modcfg_ext()
905 num_pins = cfg->generic.num_input_pins + cfg->generic.num_output_pins; in avs_tplg_parse_modcfg_ext()
907 return -EINVAL; in avs_tplg_parse_modcfg_ext()
909 pins = devm_kcalloc(comp->card->dev, num_pins, sizeof(*pins), GFP_KERNEL); in avs_tplg_parse_modcfg_ext()
911 return -ENOMEM; in avs_tplg_parse_modcfg_ext()
914 ret = parse_dictionary_entries(comp, tuples, block_size, in avs_tplg_parse_modcfg_ext()
921 cfg->generic.pin_fmts = pins; in avs_tplg_parse_modcfg_ext()
927 static int avs_tplg_parse_modcfgs_ext(struct snd_soc_component *comp, in avs_tplg_parse_modcfgs_ext() argument
931 struct avs_soc_component *acomp = to_avs_soc_component(comp); in avs_tplg_parse_modcfgs_ext()
932 struct avs_tplg *tplg = acomp->tplg; in avs_tplg_parse_modcfgs_ext()
933 int ret, i; in avs_tplg_parse_modcfgs_ext()
935 ret = parse_dictionary_header(comp, tuples, (void **)&tplg->modcfgs_ext, in avs_tplg_parse_modcfgs_ext()
936 &tplg->num_modcfgs_ext, in avs_tplg_parse_modcfgs_ext()
937 sizeof(*tplg->modcfgs_ext), in avs_tplg_parse_modcfgs_ext()
942 block_size -= le32_to_cpu(tuples->size); in avs_tplg_parse_modcfgs_ext()
946 for (i = 0; i < tplg->num_modcfgs_ext; i++) { in avs_tplg_parse_modcfgs_ext()
947 struct avs_tplg_modcfg_ext *cfg = &tplg->modcfgs_ext[i]; in avs_tplg_parse_modcfgs_ext()
955 ret = avs_tplg_parse_modcfg_ext(comp, cfg, tuples, esize); in avs_tplg_parse_modcfgs_ext()
959 block_size -= esize; in avs_tplg_parse_modcfgs_ext()
999 static int avs_tplg_parse_pplcfgs(struct snd_soc_component *comp, in avs_tplg_parse_pplcfgs() argument
1003 struct avs_soc_component *acomp = to_avs_soc_component(comp); in avs_tplg_parse_pplcfgs()
1004 struct avs_tplg *tplg = acomp->tplg; in avs_tplg_parse_pplcfgs()
1006 return parse_dictionary(comp, tuples, block_size, (void **)&tplg->pplcfgs, in avs_tplg_parse_pplcfgs()
1007 &tplg->num_pplcfgs, sizeof(*tplg->pplcfgs), in avs_tplg_parse_pplcfgs()
1064 static int avs_tplg_parse_bindings(struct snd_soc_component *comp, in avs_tplg_parse_bindings() argument
1068 struct avs_soc_component *acomp = to_avs_soc_component(comp); in avs_tplg_parse_bindings()
1069 struct avs_tplg *tplg = acomp->tplg; in avs_tplg_parse_bindings()
1071 return parse_dictionary(comp, tuples, block_size, (void **)&tplg->bindings, in avs_tplg_parse_bindings()
1072 &tplg->num_bindings, sizeof(*tplg->bindings), in avs_tplg_parse_bindings()
1139 avs_tplg_module_create(struct snd_soc_component *comp, struct avs_tplg_pipeline *owner, in avs_tplg_module_create() argument
1144 int ret; in avs_tplg_module_create()
1152 module = devm_kzalloc(comp->card->dev, sizeof(*module), GFP_KERNEL); in avs_tplg_module_create()
1154 return ERR_PTR(-ENOMEM); in avs_tplg_module_create()
1156 ret = avs_parse_tokens(comp, module, module_parsers, in avs_tplg_module_create()
1161 block_size -= esize; in avs_tplg_module_create()
1164 u32 num_config_ids = module->num_config_ids; in avs_tplg_module_create()
1168 return ERR_PTR(-EINVAL); in avs_tplg_module_create()
1170 config_ids = devm_kcalloc(comp->card->dev, num_config_ids, sizeof(*config_ids), in avs_tplg_module_create()
1173 return ERR_PTR(-ENOMEM); in avs_tplg_module_create()
1176 ret = parse_dictionary_entries(comp, tuples, block_size, in avs_tplg_module_create()
1184 module->config_ids = config_ids; in avs_tplg_module_create()
1187 module->owner = owner; in avs_tplg_module_create()
1188 INIT_LIST_HEAD(&module->node); in avs_tplg_module_create()
1218 .offset = 0, /* to treat pipeline->bindings as dictionary */
1224 avs_tplg_pipeline_create(struct snd_soc_component *comp, struct avs_tplg_path *owner, in avs_tplg_pipeline_create() argument
1229 int ret; in avs_tplg_pipeline_create()
1231 pipeline = devm_kzalloc(comp->card->dev, sizeof(*pipeline), GFP_KERNEL); in avs_tplg_pipeline_create()
1233 return ERR_PTR(-ENOMEM); in avs_tplg_pipeline_create()
1235 pipeline->owner = owner; in avs_tplg_pipeline_create()
1236 INIT_LIST_HEAD(&pipeline->mod_list); in avs_tplg_pipeline_create()
1242 ret = -EINVAL; in avs_tplg_pipeline_create()
1247 ret = avs_parse_tokens(comp, pipeline, pipeline_parsers, in avs_tplg_pipeline_create()
1252 block_size -= offset; in avs_tplg_pipeline_create()
1259 if (ret != -ENOENT) in avs_tplg_pipeline_create()
1263 if (pipeline->num_bindings) in avs_tplg_pipeline_create()
1264 return ERR_PTR(-EINVAL); in avs_tplg_pipeline_create()
1268 pipeline->bindings = devm_kcalloc(comp->card->dev, pipeline->num_bindings, in avs_tplg_pipeline_create()
1269 sizeof(*pipeline->bindings), GFP_KERNEL); in avs_tplg_pipeline_create()
1270 if (!pipeline->bindings) in avs_tplg_pipeline_create()
1271 return ERR_PTR(-ENOMEM); in avs_tplg_pipeline_create()
1276 block_size -= modblk_size; in avs_tplg_pipeline_create()
1286 module = avs_tplg_module_create(comp, pipeline, tuples, esize); in avs_tplg_pipeline_create()
1288 dev_err(comp->dev, "parse module failed: %ld\n", in avs_tplg_pipeline_create()
1293 list_add_tail(&module->node, &pipeline->mod_list); in avs_tplg_pipeline_create()
1294 modblk_size -= esize; in avs_tplg_pipeline_create()
1299 ret = parse_dictionary_entries(comp, tuples, block_size, pipeline->bindings, in avs_tplg_pipeline_create()
1300 pipeline->num_bindings, sizeof(*pipeline->bindings), in avs_tplg_pipeline_create()
1331 avs_tplg_path_create(struct snd_soc_component *comp, struct avs_tplg_path_template *owner, in avs_tplg_path_create() argument
1338 int ret; in avs_tplg_path_create()
1340 path = devm_kzalloc(comp->card->dev, sizeof(*path), GFP_KERNEL); in avs_tplg_path_create()
1342 return ERR_PTR(-ENOMEM); in avs_tplg_path_create()
1344 path->owner = owner; in avs_tplg_path_create()
1345 INIT_LIST_HEAD(&path->ppl_list); in avs_tplg_path_create()
1346 INIT_LIST_HEAD(&path->node); in avs_tplg_path_create()
1351 if (ret == -ENOENT) in avs_tplg_path_create()
1356 return ERR_PTR(-EINVAL); in avs_tplg_path_create()
1359 ret = avs_parse_tokens(comp, path, parsers, num_parsers, tuples, offset); in avs_tplg_path_create()
1363 block_size -= offset; in avs_tplg_path_create()
1373 pipeline = avs_tplg_pipeline_create(comp, path, tuples, esize); in avs_tplg_path_create()
1375 dev_err(comp->dev, "parse pipeline failed: %ld\n", in avs_tplg_path_create()
1380 list_add_tail(&pipeline->node, &path->ppl_list); in avs_tplg_path_create()
1381 block_size -= esize; in avs_tplg_path_create()
1397 static int parse_path_template(struct snd_soc_component *comp, in parse_path_template() argument
1405 int ret; in parse_path_template()
1414 ret = avs_parse_tokens(comp, template, tmpl_tokens, num_tmpl_tokens, tuples, offset); in parse_path_template()
1418 block_size -= offset; in parse_path_template()
1428 path = avs_tplg_path_create(comp, template, tuples, esize, path_tokens, in parse_path_template()
1431 dev_err(comp->dev, "parse path failed: %ld\n", PTR_ERR(path)); in parse_path_template()
1435 list_add_tail(&path->node, &template->path_list); in parse_path_template()
1436 block_size -= esize; in parse_path_template()
1444 avs_tplg_path_template_create(struct snd_soc_component *comp, struct avs_tplg *owner, in avs_tplg_path_template_create() argument
1448 int ret; in avs_tplg_path_template_create()
1450 template = devm_kzalloc(comp->card->dev, sizeof(*template), GFP_KERNEL); in avs_tplg_path_template_create()
1452 return ERR_PTR(-ENOMEM); in avs_tplg_path_template_create()
1454 template->owner = owner; /* Used to access component tplg is assigned to. */ in avs_tplg_path_template_create()
1455 INIT_LIST_HEAD(&template->path_list); in avs_tplg_path_template_create()
1456 INIT_LIST_HEAD(&template->node); in avs_tplg_path_template_create()
1458 ret = parse_path_template(comp, tuples, block_size, template, path_tmpl_parsers, in avs_tplg_path_template_create()
1488 static int avs_tplg_parse_initial_configs(struct snd_soc_component *comp, in avs_tplg_parse_initial_configs() argument
1492 struct avs_soc_component *acomp = to_avs_soc_component(comp); in avs_tplg_parse_initial_configs()
1493 struct avs_tplg *tplg = acomp->tplg; in avs_tplg_parse_initial_configs()
1494 int ret, i; in avs_tplg_parse_initial_configs()
1497 ret = parse_dictionary_header(comp, tuples, (void **)&tplg->init_configs, in avs_tplg_parse_initial_configs()
1498 &tplg->num_init_configs, in avs_tplg_parse_initial_configs()
1499 sizeof(*tplg->init_configs), in avs_tplg_parse_initial_configs()
1504 block_size -= le32_to_cpu(tuples->size); in avs_tplg_parse_initial_configs()
1508 for (i = 0; i < tplg->num_init_configs && block_size > 0; i++) { in avs_tplg_parse_initial_configs()
1509 struct avs_tplg_init_config *config = &tplg->init_configs[i]; in avs_tplg_parse_initial_configs()
1519 esize = le32_to_cpu(tuples->size) + le32_to_cpu(tmp->size); in avs_tplg_parse_initial_configs()
1521 ret = parse_dictionary_entries(comp, tuples, esize, config, 1, sizeof(*config), in avs_tplg_parse_initial_configs()
1526 block_size -= esize; in avs_tplg_parse_initial_configs()
1530 esize = config->length; in avs_tplg_parse_initial_configs()
1532 config->data = devm_kmemdup(comp->card->dev, init_config_data, esize, GFP_KERNEL); in avs_tplg_parse_initial_configs()
1533 if (!config->data) in avs_tplg_parse_initial_configs()
1534 return -ENOMEM; in avs_tplg_parse_initial_configs()
1537 block_size -= esize; in avs_tplg_parse_initial_configs()
1543 static int avs_route_load(struct snd_soc_component *comp, int index, in avs_route_load() argument
1546 struct snd_soc_acpi_mach *mach = dev_get_platdata(comp->card->dev); in avs_route_load()
1548 int ssp_port, tdm_slot; in avs_route_load()
1560 buf = devm_kzalloc(comp->card->dev, len, GFP_KERNEL); in avs_route_load()
1562 return -ENOMEM; in avs_route_load()
1563 avs_ssp_sprint(buf, len, route->source, ssp_port, tdm_slot); in avs_route_load()
1564 route->source = buf; in avs_route_load()
1566 buf = devm_kzalloc(comp->card->dev, len, GFP_KERNEL); in avs_route_load()
1568 return -ENOMEM; in avs_route_load()
1569 avs_ssp_sprint(buf, len, route->sink, ssp_port, tdm_slot); in avs_route_load()
1570 route->sink = buf; in avs_route_load()
1572 if (route->control) { in avs_route_load()
1573 buf = devm_kzalloc(comp->card->dev, len, GFP_KERNEL); in avs_route_load()
1575 return -ENOMEM; in avs_route_load()
1576 avs_ssp_sprint(buf, len, route->control, ssp_port, tdm_slot); in avs_route_load()
1577 route->control = buf; in avs_route_load()
1583 static int avs_widget_load(struct snd_soc_component *comp, int index, in avs_widget_load() argument
1589 struct avs_soc_component *acomp = to_avs_soc_component(comp); in avs_widget_load()
1591 int ssp_port, tdm_slot; in avs_widget_load()
1593 if (!le32_to_cpu(dw->priv.size)) in avs_widget_load()
1596 w->no_wname_in_kcontrol_name = true; in avs_widget_load()
1598 if (w->ignore_suspend && !AVS_S0IX_SUPPORTED) { in avs_widget_load()
1599 dev_info_once(comp->dev, "Device does not support S0IX, check BIOS settings\n"); in avs_widget_load()
1600 w->ignore_suspend = false; in avs_widget_load()
1603 tplg = acomp->tplg; in avs_widget_load()
1604 mach = dev_get_platdata(comp->card->dev); in avs_widget_load()
1611 /* size is based on possible %d -> SSP:TDM, where SSP and TDM < 10 + '\0' */ in avs_widget_load()
1612 size_t size = strlen(dw->name) + 2; in avs_widget_load()
1619 return -ENOMEM; in avs_widget_load()
1620 avs_ssp_sprint(buf, size, dw->name, ssp_port, tdm_slot); in avs_widget_load()
1621 kfree(w->name); in avs_widget_load()
1622 /* w->name is freed later by soc_tplg_dapm_widget_create() */ in avs_widget_load()
1623 w->name = buf; in avs_widget_load()
1627 template = avs_tplg_path_template_create(comp, tplg, dw->priv.array, in avs_widget_load()
1628 le32_to_cpu(dw->priv.size)); in avs_widget_load()
1630 dev_err(comp->dev, "widget %s load failed: %ld\n", dw->name, in avs_widget_load()
1635 w->priv = template; /* link path information to widget */ in avs_widget_load()
1636 list_add_tail(&template->node, &tplg->path_tmpl_list); in avs_widget_load()
1640 static int avs_widget_ready(struct snd_soc_component *comp, int index, in avs_widget_ready() argument
1644 struct avs_tplg_path_template *template = w->priv; in avs_widget_ready()
1646 template->w = w; in avs_widget_ready()
1650 static int avs_dai_load(struct snd_soc_component *comp, int index, in avs_dai_load() argument
1659 dai_drv->ops = &avs_dai_fe_ops; in avs_dai_load()
1660 dai_drv->capture.subformats = fe_subformats; in avs_dai_load()
1661 dai_drv->playback.subformats = fe_subformats; in avs_dai_load()
1667 static int avs_link_load(struct snd_soc_component *comp, int index, struct snd_soc_dai_link *link, in avs_link_load() argument
1670 if (link->ignore_suspend && !AVS_S0IX_SUPPORTED) { in avs_link_load()
1671 dev_info_once(comp->dev, "Device does not support S0IX, check BIOS settings\n"); in avs_link_load()
1672 link->ignore_suspend = false; in avs_link_load()
1675 if (!link->no_pcm) { in avs_link_load()
1677 link->nonatomic = true; in avs_link_load()
1680 link->trigger[0] = SND_SOC_DPCM_TRIGGER_PRE; in avs_link_load()
1681 link->trigger[1] = SND_SOC_DPCM_TRIGGER_PRE; in avs_link_load()
1684 link->dpcm_merged_format = 1; in avs_link_load()
1705 static int avs_manifest(struct snd_soc_component *comp, int index, in avs_manifest() argument
1708 struct snd_soc_tplg_vendor_array *tuples = manifest->priv.array; in avs_manifest()
1709 struct avs_soc_component *acomp = to_avs_soc_component(comp); in avs_manifest()
1710 size_t remaining = le32_to_cpu(manifest->priv.size); in avs_manifest()
1713 int ret; in avs_manifest()
1719 ret = -EINVAL; in avs_manifest()
1721 dev_err(comp->dev, "incorrect manifest format: %d\n", ret); in avs_manifest()
1726 ret = avs_parse_tokens(comp, acomp->tplg, manifest_parsers, in avs_manifest()
1731 remaining -= offset; in avs_manifest()
1737 dev_err(comp->dev, "audio formats lookup failed: %d\n", ret); in avs_manifest()
1742 ret = avs_tplg_parse_libraries(comp, tuples, offset); in avs_manifest()
1746 remaining -= offset; in avs_manifest()
1752 dev_err(comp->dev, "modcfgs_base lookup failed: %d\n", ret); in avs_manifest()
1757 ret = avs_tplg_parse_audio_formats(comp, tuples, offset); in avs_manifest()
1761 remaining -= offset; in avs_manifest()
1767 dev_err(comp->dev, "modcfgs_ext lookup failed: %d\n", ret); in avs_manifest()
1771 /* Module configs-base dictionary. */ in avs_manifest()
1772 ret = avs_tplg_parse_modcfgs_base(comp, tuples, offset); in avs_manifest()
1776 remaining -= offset; in avs_manifest()
1782 dev_err(comp->dev, "pplcfgs lookup failed: %d\n", ret); in avs_manifest()
1786 /* Module configs-ext dictionary. */ in avs_manifest()
1787 ret = avs_tplg_parse_modcfgs_ext(comp, tuples, offset); in avs_manifest()
1791 remaining -= offset; in avs_manifest()
1797 dev_err(comp->dev, "bindings lookup failed: %d\n", ret); in avs_manifest()
1802 ret = avs_tplg_parse_pplcfgs(comp, tuples, offset); in avs_manifest()
1806 remaining -= offset; in avs_manifest()
1812 dev_err(comp->dev, "condpath lookup failed: %d\n", ret); in avs_manifest()
1817 ret = avs_tplg_parse_bindings(comp, tuples, offset); in avs_manifest()
1821 remaining -= offset; in avs_manifest()
1826 if (ret == -ENOENT) { in avs_manifest()
1827 dev_dbg(comp->dev, "init config lookup failed: %d\n", ret); in avs_manifest()
1830 dev_err(comp->dev, "init config lookup failed: %d\n", ret); in avs_manifest()
1837 remaining -= offset; in avs_manifest()
1841 ret = avs_tplg_parse_initial_configs(comp, tuples, remaining); in avs_manifest()
1867 static int
1868 avs_control_load(struct snd_soc_component *comp, int index, struct snd_kcontrol_new *ctmpl, in avs_control_load() argument
1876 int ret; in avs_control_load()
1878 switch (le32_to_cpu(hdr->type)) { in avs_control_load()
1881 tuples = tmc->priv.array; in avs_control_load()
1882 block_size = le32_to_cpu(tmc->priv.size); in avs_control_load()
1885 return -EINVAL; in avs_control_load()
1888 ctl_data = devm_kzalloc(comp->card->dev, sizeof(*ctl_data), GFP_KERNEL); in avs_control_load()
1890 return -ENOMEM; in avs_control_load()
1892 ret = parse_dictionary_entries(comp, tuples, block_size, ctl_data, 1, sizeof(*ctl_data), in avs_control_load()
1898 mc = (struct soc_mixer_control *)ctmpl->private_value; in avs_control_load()
1899 mc->dobj.private = ctl_data; in avs_control_load()
1915 struct avs_tplg *avs_tplg_new(struct snd_soc_component *comp) in avs_tplg_new() argument
1919 tplg = devm_kzalloc(comp->card->dev, sizeof(*tplg), GFP_KERNEL); in avs_tplg_new()
1923 tplg->comp = comp; in avs_tplg_new()
1924 INIT_LIST_HEAD(&tplg->path_tmpl_list); in avs_tplg_new()
1929 int avs_load_topology(struct snd_soc_component *comp, const char *filename) in avs_load_topology() argument
1932 int ret; in avs_load_topology()
1934 ret = request_firmware(&fw, filename, comp->dev); in avs_load_topology()
1936 dev_err(comp->dev, "request topology \"%s\" failed: %d\n", filename, ret); in avs_load_topology()
1940 ret = snd_soc_tplg_component_load(comp, &avs_tplg_ops, fw); in avs_load_topology()
1942 dev_err(comp->dev, "load topology \"%s\" failed: %d\n", filename, ret); in avs_load_topology()
1948 int avs_remove_topology(struct snd_soc_component *comp) in avs_remove_topology() argument
1950 snd_soc_tplg_component_remove(comp); in avs_remove_topology()