Lines Matching +full:pdm +full:- +full:fmt
1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
12 #include "sof-priv.h"
13 #include "sof-audio.h"
14 #include "ipc3-priv.h"
232 * DMIC PDM Tokens
234 * as it increments the index while parsing the array of pdm tokens
322 [SOF_DMIC_PDM_TOKENS] = {"DMIC PDM tokens", dmic_pdm_tokens, ARRAY_SIZE(dmic_pdm_tokens)},
331 * sof_comp_alloc - allocate and initialize buffer for a new component
344 size_t ext_size = sizeof(swidget->uuid); in sof_comp_alloc()
346 /* only non-zero UUID is valid */ in sof_comp_alloc()
347 if (!guid_is_null(&swidget->uuid)) in sof_comp_alloc()
355 comp->hdr.size = total_size; in sof_comp_alloc()
356 comp->hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_COMP_NEW; in sof_comp_alloc()
357 comp->id = swidget->comp_id; in sof_comp_alloc()
358 comp->pipeline_id = index; in sof_comp_alloc()
359 comp->core = swidget->core; in sof_comp_alloc()
364 memcpy((u8 *)comp + *ipc_size, &swidget->uuid, ext_size); in sof_comp_alloc()
365 comp->ext_data_length = ext_size; in sof_comp_alloc()
375 dev_dbg(scomp->dev, " config: periods snk %d src %d fmt %d\n", in sof_dbg_comp_config()
376 config->periods_sink, config->periods_source, in sof_dbg_comp_config()
377 config->frame_fmt); in sof_dbg_comp_config()
382 struct snd_soc_component *scomp = swidget->scomp; in sof_ipc3_widget_setup_comp_host()
387 host = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id); in sof_ipc3_widget_setup_comp_host()
389 return -ENOMEM; in sof_ipc3_widget_setup_comp_host()
390 swidget->private = host; in sof_ipc3_widget_setup_comp_host()
393 host->comp.type = SOF_COMP_HOST; in sof_ipc3_widget_setup_comp_host()
394 host->config.hdr.size = sizeof(host->config); in sof_ipc3_widget_setup_comp_host()
396 if (swidget->id == snd_soc_dapm_aif_out) in sof_ipc3_widget_setup_comp_host()
397 host->direction = SOF_IPC_STREAM_CAPTURE; in sof_ipc3_widget_setup_comp_host()
399 host->direction = SOF_IPC_STREAM_PLAYBACK; in sof_ipc3_widget_setup_comp_host()
402 ret = sof_update_ipc_object(scomp, host, SOF_PCM_TOKENS, swidget->tuples, in sof_ipc3_widget_setup_comp_host()
403 swidget->num_tuples, sizeof(*host), 1); in sof_ipc3_widget_setup_comp_host()
408 ret = sof_update_ipc_object(scomp, &host->config, SOF_COMP_TOKENS, swidget->tuples, in sof_ipc3_widget_setup_comp_host()
409 swidget->num_tuples, sizeof(host->config), 1); in sof_ipc3_widget_setup_comp_host()
413 dev_dbg(scomp->dev, "loaded host %s\n", swidget->widget->name); in sof_ipc3_widget_setup_comp_host()
414 sof_dbg_comp_config(scomp, &host->config); in sof_ipc3_widget_setup_comp_host()
418 kfree(swidget->private); in sof_ipc3_widget_setup_comp_host()
419 swidget->private = NULL; in sof_ipc3_widget_setup_comp_host()
426 kfree(swidget->private); in sof_ipc3_widget_free_comp()
431 struct snd_soc_component *scomp = swidget->scomp; in sof_ipc3_widget_setup_comp_tone()
436 tone = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id); in sof_ipc3_widget_setup_comp_tone()
438 return -ENOMEM; in sof_ipc3_widget_setup_comp_tone()
440 swidget->private = tone; in sof_ipc3_widget_setup_comp_tone()
443 tone->comp.type = SOF_COMP_TONE; in sof_ipc3_widget_setup_comp_tone()
444 tone->config.hdr.size = sizeof(tone->config); in sof_ipc3_widget_setup_comp_tone()
447 ret = sof_update_ipc_object(scomp, &tone->config, SOF_COMP_TOKENS, swidget->tuples, in sof_ipc3_widget_setup_comp_tone()
448 swidget->num_tuples, sizeof(tone->config), 1); in sof_ipc3_widget_setup_comp_tone()
450 kfree(swidget->private); in sof_ipc3_widget_setup_comp_tone()
451 swidget->private = NULL; in sof_ipc3_widget_setup_comp_tone()
455 dev_dbg(scomp->dev, "tone %s: frequency %d amplitude %d\n", in sof_ipc3_widget_setup_comp_tone()
456 swidget->widget->name, tone->frequency, tone->amplitude); in sof_ipc3_widget_setup_comp_tone()
457 sof_dbg_comp_config(scomp, &tone->config); in sof_ipc3_widget_setup_comp_tone()
464 struct snd_soc_component *scomp = swidget->scomp; in sof_ipc3_widget_setup_comp_mixer()
469 mixer = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id); in sof_ipc3_widget_setup_comp_mixer()
471 return -ENOMEM; in sof_ipc3_widget_setup_comp_mixer()
473 swidget->private = mixer; in sof_ipc3_widget_setup_comp_mixer()
476 mixer->comp.type = SOF_COMP_MIXER; in sof_ipc3_widget_setup_comp_mixer()
477 mixer->config.hdr.size = sizeof(mixer->config); in sof_ipc3_widget_setup_comp_mixer()
480 ret = sof_update_ipc_object(scomp, &mixer->config, SOF_COMP_TOKENS, in sof_ipc3_widget_setup_comp_mixer()
481 swidget->tuples, swidget->num_tuples, in sof_ipc3_widget_setup_comp_mixer()
482 sizeof(mixer->config), 1); in sof_ipc3_widget_setup_comp_mixer()
484 kfree(swidget->private); in sof_ipc3_widget_setup_comp_mixer()
485 swidget->private = NULL; in sof_ipc3_widget_setup_comp_mixer()
490 dev_dbg(scomp->dev, "loaded mixer %s\n", swidget->widget->name); in sof_ipc3_widget_setup_comp_mixer()
491 sof_dbg_comp_config(scomp, &mixer->config); in sof_ipc3_widget_setup_comp_mixer()
498 struct snd_soc_component *scomp = swidget->scomp; in sof_ipc3_widget_setup_comp_pipeline()
499 struct snd_sof_pipeline *spipe = swidget->spipe; in sof_ipc3_widget_setup_comp_pipeline()
506 return -ENOMEM; in sof_ipc3_widget_setup_comp_pipeline()
509 pipeline->hdr.size = sizeof(*pipeline); in sof_ipc3_widget_setup_comp_pipeline()
510 pipeline->hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_PIPE_NEW; in sof_ipc3_widget_setup_comp_pipeline()
511 pipeline->pipeline_id = swidget->pipeline_id; in sof_ipc3_widget_setup_comp_pipeline()
512 pipeline->comp_id = swidget->comp_id; in sof_ipc3_widget_setup_comp_pipeline()
514 swidget->private = pipeline; in sof_ipc3_widget_setup_comp_pipeline()
517 comp_swidget = snd_sof_find_swidget(scomp, swidget->widget->sname); in sof_ipc3_widget_setup_comp_pipeline()
519 dev_err(scomp->dev, "scheduler %s refers to non existent widget %s\n", in sof_ipc3_widget_setup_comp_pipeline()
520 swidget->widget->name, swidget->widget->sname); in sof_ipc3_widget_setup_comp_pipeline()
521 ret = -EINVAL; in sof_ipc3_widget_setup_comp_pipeline()
525 pipeline->sched_id = comp_swidget->comp_id; in sof_ipc3_widget_setup_comp_pipeline()
528 ret = sof_update_ipc_object(scomp, pipeline, SOF_SCHED_TOKENS, swidget->tuples, in sof_ipc3_widget_setup_comp_pipeline()
529 swidget->num_tuples, sizeof(*pipeline), 1); in sof_ipc3_widget_setup_comp_pipeline()
534 ret = sof_update_ipc_object(scomp, swidget, SOF_PIPELINE_TOKENS, swidget->tuples, in sof_ipc3_widget_setup_comp_pipeline()
535 swidget->num_tuples, sizeof(*swidget), 1); in sof_ipc3_widget_setup_comp_pipeline()
540 pipeline->core = SOF_DSP_PRIMARY_CORE; in sof_ipc3_widget_setup_comp_pipeline()
543 swidget->dynamic_pipeline_widget = in sof_ipc3_widget_setup_comp_pipeline()
546 dev_dbg(scomp->dev, "pipeline %s: period %d pri %d mips %d core %d frames %d dynamic %d\n", in sof_ipc3_widget_setup_comp_pipeline()
547 swidget->widget->name, pipeline->period, pipeline->priority, in sof_ipc3_widget_setup_comp_pipeline()
548 pipeline->period_mips, pipeline->core, pipeline->frames_per_sched, in sof_ipc3_widget_setup_comp_pipeline()
549 swidget->dynamic_pipeline_widget); in sof_ipc3_widget_setup_comp_pipeline()
551 swidget->core = pipeline->core; in sof_ipc3_widget_setup_comp_pipeline()
552 spipe->core_mask |= BIT(pipeline->core); in sof_ipc3_widget_setup_comp_pipeline()
557 kfree(swidget->private); in sof_ipc3_widget_setup_comp_pipeline()
558 swidget->private = NULL; in sof_ipc3_widget_setup_comp_pipeline()
565 struct snd_soc_component *scomp = swidget->scomp; in sof_ipc3_widget_setup_comp_buffer()
571 return -ENOMEM; in sof_ipc3_widget_setup_comp_buffer()
573 swidget->private = buffer; in sof_ipc3_widget_setup_comp_buffer()
576 buffer->comp.hdr.size = sizeof(*buffer); in sof_ipc3_widget_setup_comp_buffer()
577 buffer->comp.hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_BUFFER_NEW; in sof_ipc3_widget_setup_comp_buffer()
578 buffer->comp.id = swidget->comp_id; in sof_ipc3_widget_setup_comp_buffer()
579 buffer->comp.type = SOF_COMP_BUFFER; in sof_ipc3_widget_setup_comp_buffer()
580 buffer->comp.pipeline_id = swidget->pipeline_id; in sof_ipc3_widget_setup_comp_buffer()
581 buffer->comp.core = swidget->core; in sof_ipc3_widget_setup_comp_buffer()
584 ret = sof_update_ipc_object(scomp, buffer, SOF_BUFFER_TOKENS, swidget->tuples, in sof_ipc3_widget_setup_comp_buffer()
585 swidget->num_tuples, sizeof(*buffer), 1); in sof_ipc3_widget_setup_comp_buffer()
587 kfree(swidget->private); in sof_ipc3_widget_setup_comp_buffer()
588 swidget->private = NULL; in sof_ipc3_widget_setup_comp_buffer()
592 dev_dbg(scomp->dev, "buffer %s: size %d caps 0x%x\n", in sof_ipc3_widget_setup_comp_buffer()
593 swidget->widget->name, buffer->size, buffer->caps); in sof_ipc3_widget_setup_comp_buffer()
600 struct snd_soc_component *scomp = swidget->scomp; in sof_ipc3_widget_setup_comp_src()
605 src = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id); in sof_ipc3_widget_setup_comp_src()
607 return -ENOMEM; in sof_ipc3_widget_setup_comp_src()
609 swidget->private = src; in sof_ipc3_widget_setup_comp_src()
612 src->comp.type = SOF_COMP_SRC; in sof_ipc3_widget_setup_comp_src()
613 src->config.hdr.size = sizeof(src->config); in sof_ipc3_widget_setup_comp_src()
616 ret = sof_update_ipc_object(scomp, src, SOF_SRC_TOKENS, swidget->tuples, in sof_ipc3_widget_setup_comp_src()
617 swidget->num_tuples, sizeof(*src), 1); in sof_ipc3_widget_setup_comp_src()
622 ret = sof_update_ipc_object(scomp, &src->config, SOF_COMP_TOKENS, in sof_ipc3_widget_setup_comp_src()
623 swidget->tuples, swidget->num_tuples, sizeof(src->config), 1); in sof_ipc3_widget_setup_comp_src()
627 dev_dbg(scomp->dev, "src %s: source rate %d sink rate %d\n", in sof_ipc3_widget_setup_comp_src()
628 swidget->widget->name, src->source_rate, src->sink_rate); in sof_ipc3_widget_setup_comp_src()
629 sof_dbg_comp_config(scomp, &src->config); in sof_ipc3_widget_setup_comp_src()
633 kfree(swidget->private); in sof_ipc3_widget_setup_comp_src()
634 swidget->private = NULL; in sof_ipc3_widget_setup_comp_src()
641 struct snd_soc_component *scomp = swidget->scomp; in sof_ipc3_widget_setup_comp_asrc()
646 asrc = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id); in sof_ipc3_widget_setup_comp_asrc()
648 return -ENOMEM; in sof_ipc3_widget_setup_comp_asrc()
650 swidget->private = asrc; in sof_ipc3_widget_setup_comp_asrc()
653 asrc->comp.type = SOF_COMP_ASRC; in sof_ipc3_widget_setup_comp_asrc()
654 asrc->config.hdr.size = sizeof(asrc->config); in sof_ipc3_widget_setup_comp_asrc()
657 ret = sof_update_ipc_object(scomp, asrc, SOF_ASRC_TOKENS, swidget->tuples, in sof_ipc3_widget_setup_comp_asrc()
658 swidget->num_tuples, sizeof(*asrc), 1); in sof_ipc3_widget_setup_comp_asrc()
663 ret = sof_update_ipc_object(scomp, &asrc->config, SOF_COMP_TOKENS, in sof_ipc3_widget_setup_comp_asrc()
664 swidget->tuples, swidget->num_tuples, sizeof(asrc->config), 1); in sof_ipc3_widget_setup_comp_asrc()
668 dev_dbg(scomp->dev, "asrc %s: source rate %d sink rate %d asynch %d operation %d\n", in sof_ipc3_widget_setup_comp_asrc()
669 swidget->widget->name, asrc->source_rate, asrc->sink_rate, in sof_ipc3_widget_setup_comp_asrc()
670 asrc->asynchronous_mode, asrc->operation_mode); in sof_ipc3_widget_setup_comp_asrc()
672 sof_dbg_comp_config(scomp, &asrc->config); in sof_ipc3_widget_setup_comp_asrc()
676 kfree(swidget->private); in sof_ipc3_widget_setup_comp_asrc()
677 swidget->private = NULL; in sof_ipc3_widget_setup_comp_asrc()
687 struct snd_soc_component *scomp = swidget->scomp; in sof_ipc3_widget_setup_comp_mux()
692 mux = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id); in sof_ipc3_widget_setup_comp_mux()
694 return -ENOMEM; in sof_ipc3_widget_setup_comp_mux()
696 swidget->private = mux; in sof_ipc3_widget_setup_comp_mux()
699 mux->comp.type = SOF_COMP_MUX; in sof_ipc3_widget_setup_comp_mux()
700 mux->config.hdr.size = sizeof(mux->config); in sof_ipc3_widget_setup_comp_mux()
703 ret = sof_update_ipc_object(scomp, &mux->config, SOF_COMP_TOKENS, in sof_ipc3_widget_setup_comp_mux()
704 swidget->tuples, swidget->num_tuples, sizeof(mux->config), 1); in sof_ipc3_widget_setup_comp_mux()
706 kfree(swidget->private); in sof_ipc3_widget_setup_comp_mux()
707 swidget->private = NULL; in sof_ipc3_widget_setup_comp_mux()
711 dev_dbg(scomp->dev, "loaded mux %s\n", swidget->widget->name); in sof_ipc3_widget_setup_comp_mux()
712 sof_dbg_comp_config(scomp, &mux->config); in sof_ipc3_widget_setup_comp_mux()
723 struct snd_soc_component *scomp = swidget->scomp; in sof_ipc3_widget_setup_comp_pga()
731 volume = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id); in sof_ipc3_widget_setup_comp_pga()
733 return -ENOMEM; in sof_ipc3_widget_setup_comp_pga()
735 swidget->private = volume; in sof_ipc3_widget_setup_comp_pga()
738 volume->comp.type = SOF_COMP_VOLUME; in sof_ipc3_widget_setup_comp_pga()
739 volume->config.hdr.size = sizeof(volume->config); in sof_ipc3_widget_setup_comp_pga()
742 ret = sof_update_ipc_object(scomp, volume, SOF_VOLUME_TOKENS, swidget->tuples, in sof_ipc3_widget_setup_comp_pga()
743 swidget->num_tuples, sizeof(*volume), 1); in sof_ipc3_widget_setup_comp_pga()
748 ret = sof_update_ipc_object(scomp, &volume->config, SOF_COMP_TOKENS, in sof_ipc3_widget_setup_comp_pga()
749 swidget->tuples, swidget->num_tuples, in sof_ipc3_widget_setup_comp_pga()
750 sizeof(volume->config), 1); in sof_ipc3_widget_setup_comp_pga()
754 dev_dbg(scomp->dev, "loaded PGA %s\n", swidget->widget->name); in sof_ipc3_widget_setup_comp_pga()
755 sof_dbg_comp_config(scomp, &volume->config); in sof_ipc3_widget_setup_comp_pga()
757 list_for_each_entry(scontrol, &sdev->kcontrol_list, list) { in sof_ipc3_widget_setup_comp_pga()
758 if (scontrol->comp_id == swidget->comp_id && in sof_ipc3_widget_setup_comp_pga()
759 scontrol->volume_table) { in sof_ipc3_widget_setup_comp_pga()
760 min_step = scontrol->min_volume_step; in sof_ipc3_widget_setup_comp_pga()
761 max_step = scontrol->max_volume_step; in sof_ipc3_widget_setup_comp_pga()
762 volume->min_value = scontrol->volume_table[min_step]; in sof_ipc3_widget_setup_comp_pga()
763 volume->max_value = scontrol->volume_table[max_step]; in sof_ipc3_widget_setup_comp_pga()
764 volume->channels = scontrol->num_channels; in sof_ipc3_widget_setup_comp_pga()
771 kfree(swidget->private); in sof_ipc3_widget_setup_comp_pga()
772 swidget->private = NULL; in sof_ipc3_widget_setup_comp_pga()
790 for (i = 0; i < widget->num_kcontrols; i++) { in sof_get_control_data()
791 kc = &widget->kcontrol_news[i]; in sof_get_control_data()
793 switch (widget->dobj.widget.kcontrol_type[i]) { in sof_get_control_data()
795 sm = (struct soc_mixer_control *)kc->private_value; in sof_get_control_data()
796 wdata[i].control = sm->dobj.private; in sof_get_control_data()
799 sbe = (struct soc_bytes_ext *)kc->private_value; in sof_get_control_data()
800 wdata[i].control = sbe->dobj.private; in sof_get_control_data()
803 se = (struct soc_enum *)kc->private_value; in sof_get_control_data()
804 wdata[i].control = se->dobj.private; in sof_get_control_data()
807 dev_err(scomp->dev, "Unknown kcontrol type %u in widget %s\n", in sof_get_control_data()
808 widget->dobj.widget.kcontrol_type[i], widget->name); in sof_get_control_data()
809 return -EINVAL; in sof_get_control_data()
813 dev_err(scomp->dev, "No scontrol for widget %s\n", widget->name); in sof_get_control_data()
814 return -EINVAL; in sof_get_control_data()
817 cdata = wdata[i].control->ipc_control_data; in sof_get_control_data()
819 if (widget->dobj.widget.kcontrol_type[i] == SND_SOC_TPLG_TYPE_BYTES) { in sof_get_control_data()
820 /* make sure data is valid - data can be updated at runtime */ in sof_get_control_data()
821 if (cdata->data->magic != SOF_ABI_MAGIC) in sof_get_control_data()
822 return -EINVAL; in sof_get_control_data()
824 wdata[i].pdata = cdata->data->data; in sof_get_control_data()
825 wdata[i].pdata_size = cdata->data->size; in sof_get_control_data()
828 wdata[i].pdata = cdata->chanv; in sof_get_control_data()
830 * wdata[i].control->size is calculated with struct_size in sof_get_control_data()
833 wdata[i].pdata_size = wdata[i].control->size - in sof_get_control_data()
840 switch (cdata->cmd) { in sof_get_control_data()
862 struct snd_soc_dapm_widget *widget = swidget->widget; in sof_process_load()
872 if (widget->num_kcontrols) { in sof_process_load()
873 wdata = kcalloc(widget->num_kcontrols, sizeof(*wdata), GFP_KERNEL); in sof_process_load()
875 return -ENOMEM; in sof_process_load()
887 ipc_size -= ipc_data_size; in sof_process_load()
891 process = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id); in sof_process_load()
893 ret = -ENOMEM; in sof_process_load()
897 swidget->private = process; in sof_process_load()
900 process->comp.type = type; in sof_process_load()
901 process->config.hdr.size = sizeof(process->config); in sof_process_load()
904 ret = sof_update_ipc_object(scomp, &process->config, SOF_COMP_TOKENS, in sof_process_load()
905 swidget->tuples, swidget->num_tuples, in sof_process_load()
906 sizeof(process->config), 1); in sof_process_load()
910 dev_dbg(scomp->dev, "loaded process %s\n", swidget->widget->name); in sof_process_load()
911 sof_dbg_comp_config(scomp, &process->config); in sof_process_load()
915 * get possible component controls - get size of all pdata, in sof_process_load()
919 for (i = 0; i < widget->num_kcontrols; i++) { in sof_process_load()
923 memcpy(&process->data[offset], wdata[i].pdata, in sof_process_load()
929 process->size = ipc_data_size; in sof_process_load()
935 kfree(swidget->private); in sof_process_load()
936 swidget->private = NULL; in sof_process_load()
955 * Processing Component Topology - can be "effect", "codec", or general
961 struct snd_soc_component *scomp = swidget->scomp; in sof_widget_update_ipc_comp_process()
966 config.comp.core = swidget->core; in sof_widget_update_ipc_comp_process()
969 ret = sof_update_ipc_object(scomp, &config, SOF_PROCESS_TOKENS, swidget->tuples, in sof_widget_update_ipc_comp_process()
970 swidget->num_tuples, sizeof(config), 1); in sof_widget_update_ipc_comp_process()
981 struct sof_dai_private_data *private = dai->private; in sof_link_hda_load()
986 memset(&config->hda, 0, sizeof(config->hda)); in sof_link_hda_load()
987 config->hdr.size = size; in sof_link_hda_load()
990 ret = sof_update_ipc_object(scomp, &config->hda, SOF_HDA_TOKENS, slink->tuples, in sof_link_hda_load()
991 slink->num_tuples, size, 1); in sof_link_hda_load()
995 dev_dbg(scomp->dev, "HDA config rate %d channels %d\n", in sof_link_hda_load()
996 config->hda.rate, config->hda.channels); in sof_link_hda_load()
998 config->hda.link_dma_ch = DMA_CHAN_INVALID; in sof_link_hda_load()
1000 dai->number_configs = 1; in sof_link_hda_load()
1001 dai->current_config = 0; in sof_link_hda_load()
1002 private->dai_config = kmemdup(config, size, GFP_KERNEL); in sof_link_hda_load()
1003 if (!private->dai_config) in sof_link_hda_load()
1004 return -ENOMEM; in sof_link_hda_load()
1013 config->format &= ~SOF_DAI_FMT_CLOCK_PROVIDER_MASK; in sof_dai_set_format()
1014 if (hw_config->bclk_provider == SND_SOC_TPLG_BCLK_CP) { in sof_dai_set_format()
1016 if (hw_config->fsync_provider == SND_SOC_TPLG_FSYNC_CP) in sof_dai_set_format()
1017 config->format |= SOF_DAI_FMT_CBP_CFP; in sof_dai_set_format()
1019 config->format |= SOF_DAI_FMT_CBP_CFC; in sof_dai_set_format()
1022 if (hw_config->fsync_provider == SND_SOC_TPLG_FSYNC_CP) in sof_dai_set_format()
1023 config->format |= SOF_DAI_FMT_CBC_CFP; in sof_dai_set_format()
1025 config->format |= SOF_DAI_FMT_CBC_CFC; in sof_dai_set_format()
1029 config->format &= ~SOF_DAI_FMT_INV_MASK; in sof_dai_set_format()
1030 if (hw_config->invert_bclk) { in sof_dai_set_format()
1031 if (hw_config->invert_fsync) in sof_dai_set_format()
1032 config->format |= SOF_DAI_FMT_IB_IF; in sof_dai_set_format()
1034 config->format |= SOF_DAI_FMT_IB_NF; in sof_dai_set_format()
1036 if (hw_config->invert_fsync) in sof_dai_set_format()
1037 config->format |= SOF_DAI_FMT_NB_IF; in sof_dai_set_format()
1039 config->format |= SOF_DAI_FMT_NB_NF; in sof_dai_set_format()
1046 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs; in sof_link_sai_load()
1047 struct sof_dai_private_data *private = dai->private; in sof_link_sai_load()
1055 memset(&config->sai, 0, sizeof(config->sai)); in sof_link_sai_load()
1056 config->hdr.size = size; in sof_link_sai_load()
1059 ret = sof_update_ipc_object(scomp, &config->sai, SOF_SAI_TOKENS, slink->tuples, in sof_link_sai_load()
1060 slink->num_tuples, size, 1); in sof_link_sai_load()
1064 config->sai.mclk_rate = le32_to_cpu(hw_config->mclk_rate); in sof_link_sai_load()
1065 config->sai.bclk_rate = le32_to_cpu(hw_config->bclk_rate); in sof_link_sai_load()
1066 config->sai.fsync_rate = le32_to_cpu(hw_config->fsync_rate); in sof_link_sai_load()
1067 config->sai.mclk_direction = hw_config->mclk_direction; in sof_link_sai_load()
1069 config->sai.tdm_slots = le32_to_cpu(hw_config->tdm_slots); in sof_link_sai_load()
1070 config->sai.tdm_slot_width = le32_to_cpu(hw_config->tdm_slot_width); in sof_link_sai_load()
1071 config->sai.rx_slots = le32_to_cpu(hw_config->rx_slots); in sof_link_sai_load()
1072 config->sai.tx_slots = le32_to_cpu(hw_config->tx_slots); in sof_link_sai_load()
1074 dev_info(scomp->dev, in sof_link_sai_load()
1075 "tplg: config SAI%d fmt 0x%x mclk %d width %d slots %d mclk id %d\n", in sof_link_sai_load()
1076 config->dai_index, config->format, in sof_link_sai_load()
1077 config->sai.mclk_rate, config->sai.tdm_slot_width, in sof_link_sai_load()
1078 config->sai.tdm_slots, config->sai.mclk_id); in sof_link_sai_load()
1080 if (config->sai.tdm_slots < 1 || config->sai.tdm_slots > 8) { in sof_link_sai_load()
1081 dev_err(scomp->dev, "Invalid channel count for SAI%d\n", config->dai_index); in sof_link_sai_load()
1082 return -EINVAL; in sof_link_sai_load()
1085 dai->number_configs = 1; in sof_link_sai_load()
1086 dai->current_config = 0; in sof_link_sai_load()
1087 private->dai_config = kmemdup(config, size, GFP_KERNEL); in sof_link_sai_load()
1088 if (!private->dai_config) in sof_link_sai_load()
1089 return -ENOMEM; in sof_link_sai_load()
1097 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs; in sof_link_esai_load()
1098 struct sof_dai_private_data *private = dai->private; in sof_link_esai_load()
1106 memset(&config->esai, 0, sizeof(config->esai)); in sof_link_esai_load()
1107 config->hdr.size = size; in sof_link_esai_load()
1110 ret = sof_update_ipc_object(scomp, &config->esai, SOF_ESAI_TOKENS, slink->tuples, in sof_link_esai_load()
1111 slink->num_tuples, size, 1); in sof_link_esai_load()
1115 config->esai.mclk_rate = le32_to_cpu(hw_config->mclk_rate); in sof_link_esai_load()
1116 config->esai.bclk_rate = le32_to_cpu(hw_config->bclk_rate); in sof_link_esai_load()
1117 config->esai.fsync_rate = le32_to_cpu(hw_config->fsync_rate); in sof_link_esai_load()
1118 config->esai.mclk_direction = hw_config->mclk_direction; in sof_link_esai_load()
1119 config->esai.tdm_slots = le32_to_cpu(hw_config->tdm_slots); in sof_link_esai_load()
1120 config->esai.tdm_slot_width = le32_to_cpu(hw_config->tdm_slot_width); in sof_link_esai_load()
1121 config->esai.rx_slots = le32_to_cpu(hw_config->rx_slots); in sof_link_esai_load()
1122 config->esai.tx_slots = le32_to_cpu(hw_config->tx_slots); in sof_link_esai_load()
1124 dev_info(scomp->dev, in sof_link_esai_load()
1125 "tplg: config ESAI%d fmt 0x%x mclk %d width %d slots %d mclk id %d\n", in sof_link_esai_load()
1126 config->dai_index, config->format, in sof_link_esai_load()
1127 config->esai.mclk_rate, config->esai.tdm_slot_width, in sof_link_esai_load()
1128 config->esai.tdm_slots, config->esai.mclk_id); in sof_link_esai_load()
1130 if (config->esai.tdm_slots < 1 || config->esai.tdm_slots > 8) { in sof_link_esai_load()
1131 dev_err(scomp->dev, "Invalid channel count for ESAI%d\n", config->dai_index); in sof_link_esai_load()
1132 return -EINVAL; in sof_link_esai_load()
1135 dai->number_configs = 1; in sof_link_esai_load()
1136 dai->current_config = 0; in sof_link_esai_load()
1137 private->dai_config = kmemdup(config, size, GFP_KERNEL); in sof_link_esai_load()
1138 if (!private->dai_config) in sof_link_esai_load()
1139 return -ENOMEM; in sof_link_esai_load()
1147 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs; in sof_link_acp_dmic_load()
1148 struct sof_dai_private_data *private = dai->private; in sof_link_acp_dmic_load()
1155 config->hdr.size = size; in sof_link_acp_dmic_load()
1158 ret = sof_update_ipc_object(scomp, &config->acpdmic, SOF_ACPDMIC_TOKENS, slink->tuples, in sof_link_acp_dmic_load()
1159 slink->num_tuples, size, slink->num_hw_configs); in sof_link_acp_dmic_load()
1163 dev_info(scomp->dev, "ACP_DMIC config ACP%d channel %d rate %d\n", in sof_link_acp_dmic_load()
1164 config->dai_index, config->acpdmic.pdm_ch, in sof_link_acp_dmic_load()
1165 config->acpdmic.pdm_rate); in sof_link_acp_dmic_load()
1167 dai->number_configs = 1; in sof_link_acp_dmic_load()
1168 dai->current_config = 0; in sof_link_acp_dmic_load()
1169 private->dai_config = kmemdup(config, size, GFP_KERNEL); in sof_link_acp_dmic_load()
1170 if (!private->dai_config) in sof_link_acp_dmic_load()
1171 return -ENOMEM; in sof_link_acp_dmic_load()
1179 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs; in sof_link_acp_bt_load()
1180 struct sof_dai_private_data *private = dai->private; in sof_link_acp_bt_load()
1187 memset(&config->acpbt, 0, sizeof(config->acpbt)); in sof_link_acp_bt_load()
1188 config->hdr.size = size; in sof_link_acp_bt_load()
1190 config->acpbt.fsync_rate = le32_to_cpu(hw_config->fsync_rate); in sof_link_acp_bt_load()
1191 config->acpbt.tdm_slots = le32_to_cpu(hw_config->tdm_slots); in sof_link_acp_bt_load()
1193 dev_info(scomp->dev, "ACP_BT config ACP%d channel %d rate %d\n", in sof_link_acp_bt_load()
1194 config->dai_index, config->acpbt.tdm_slots, in sof_link_acp_bt_load()
1195 config->acpbt.fsync_rate); in sof_link_acp_bt_load()
1197 dai->number_configs = 1; in sof_link_acp_bt_load()
1198 dai->current_config = 0; in sof_link_acp_bt_load()
1199 private->dai_config = kmemdup(config, size, GFP_KERNEL); in sof_link_acp_bt_load()
1200 if (!private->dai_config) in sof_link_acp_bt_load()
1201 return -ENOMEM; in sof_link_acp_bt_load()
1209 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs; in sof_link_acp_sp_load()
1210 struct sof_dai_private_data *private = dai->private; in sof_link_acp_sp_load()
1218 memset(&config->acpsp, 0, sizeof(config->acpsp)); in sof_link_acp_sp_load()
1219 config->hdr.size = size; in sof_link_acp_sp_load()
1221 ret = sof_update_ipc_object(scomp, &config->acpsp, SOF_ACPI2S_TOKENS, slink->tuples, in sof_link_acp_sp_load()
1222 slink->num_tuples, size, slink->num_hw_configs); in sof_link_acp_sp_load()
1227 dev_info(scomp->dev, "ACP_SP config ACP%d channel %d rate %d tdm_mode %d\n", in sof_link_acp_sp_load()
1228 config->dai_index, config->acpsp.tdm_slots, in sof_link_acp_sp_load()
1229 config->acpsp.fsync_rate, config->acpsp.tdm_mode); in sof_link_acp_sp_load()
1231 dai->number_configs = 1; in sof_link_acp_sp_load()
1232 dai->current_config = 0; in sof_link_acp_sp_load()
1233 private->dai_config = kmemdup(config, size, GFP_KERNEL); in sof_link_acp_sp_load()
1234 if (!private->dai_config) in sof_link_acp_sp_load()
1235 return -ENOMEM; in sof_link_acp_sp_load()
1243 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs; in sof_link_acp_hs_load()
1244 struct sof_dai_private_data *private = dai->private; in sof_link_acp_hs_load()
1252 memset(&config->acphs, 0, sizeof(config->acphs)); in sof_link_acp_hs_load()
1253 config->hdr.size = size; in sof_link_acp_hs_load()
1255 ret = sof_update_ipc_object(scomp, &config->acphs, SOF_ACPI2S_TOKENS, slink->tuples, in sof_link_acp_hs_load()
1256 slink->num_tuples, size, slink->num_hw_configs); in sof_link_acp_hs_load()
1260 dev_info(scomp->dev, "ACP_HS config ACP%d channel %d rate %d tdm_mode %d\n", in sof_link_acp_hs_load()
1261 config->dai_index, config->acphs.tdm_slots, in sof_link_acp_hs_load()
1262 config->acphs.fsync_rate, config->acphs.tdm_mode); in sof_link_acp_hs_load()
1264 dai->number_configs = 1; in sof_link_acp_hs_load()
1265 dai->current_config = 0; in sof_link_acp_hs_load()
1266 private->dai_config = kmemdup(config, size, GFP_KERNEL); in sof_link_acp_hs_load()
1267 if (!private->dai_config) in sof_link_acp_hs_load()
1268 return -ENOMEM; in sof_link_acp_hs_load()
1276 struct sof_dai_private_data *private = dai->private; in sof_link_afe_load()
1280 config->hdr.size = size; in sof_link_afe_load()
1283 ret = sof_update_ipc_object(scomp, &config->afe, SOF_AFE_TOKENS, slink->tuples, in sof_link_afe_load()
1284 slink->num_tuples, size, slink->num_hw_configs); in sof_link_afe_load()
1288 dev_dbg(scomp->dev, "AFE config rate %d channels %d format:%d\n", in sof_link_afe_load()
1289 config->afe.rate, config->afe.channels, config->afe.format); in sof_link_afe_load()
1291 config->afe.stream_id = DMA_CHAN_INVALID; in sof_link_afe_load()
1293 dai->number_configs = 1; in sof_link_afe_load()
1294 dai->current_config = 0; in sof_link_afe_load()
1295 private->dai_config = kmemdup(config, size, GFP_KERNEL); in sof_link_afe_load()
1296 if (!private->dai_config) in sof_link_afe_load()
1297 return -ENOMEM; in sof_link_afe_load()
1306 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs; in sof_link_ssp_load()
1307 struct sof_dai_private_data *private = dai->private; in sof_link_ssp_load()
1315 ret = sof_update_ipc_object(scomp, &config->ssp, SOF_SSP_TOKENS, slink->tuples, in sof_link_ssp_load()
1316 slink->num_tuples, size, slink->num_hw_configs); in sof_link_ssp_load()
1321 for (i = 0; i < slink->num_hw_configs; i++) { in sof_link_ssp_load()
1322 if (le32_to_cpu(hw_config[i].id) == slink->default_hw_cfg_id) in sof_link_ssp_load()
1330 if (sdev->mclk_id_override) { in sof_link_ssp_load()
1331 dev_dbg(scomp->dev, "tplg: overriding topology mclk_id %d by quirk %d\n", in sof_link_ssp_load()
1332 config[i].ssp.mclk_id, sdev->mclk_id_quirk); in sof_link_ssp_load()
1333 config[i].ssp.mclk_id = sdev->mclk_id_quirk; in sof_link_ssp_load()
1346 …dev_dbg(scomp->dev, "tplg: config SSP%d fmt %#x mclk %d bclk %d fclk %d width (%d)%d slots %d mclk… in sof_link_ssp_load()
1355 dev_err(scomp->dev, "Invalid fsync rate for SSP%d\n", config[i].dai_index); in sof_link_ssp_load()
1356 return -EINVAL; in sof_link_ssp_load()
1360 dev_err(scomp->dev, "Invalid channel count for SSP%d\n", in sof_link_ssp_load()
1362 return -EINVAL; in sof_link_ssp_load()
1366 dai->number_configs = slink->num_hw_configs; in sof_link_ssp_load()
1367 dai->current_config = current_config; in sof_link_ssp_load()
1368 private->dai_config = kmemdup(config, size * slink->num_hw_configs, GFP_KERNEL); in sof_link_ssp_load()
1369 if (!private->dai_config) in sof_link_ssp_load()
1370 return -ENOMEM; in sof_link_ssp_load()
1379 struct sof_dai_private_data *private = dai->private; in sof_link_dmic_load()
1380 struct sof_ipc_fw_ready *ready = &sdev->fw_ready; in sof_link_dmic_load()
1381 struct sof_ipc_fw_version *v = &ready->version; in sof_link_dmic_load()
1386 memset(&config->dmic, 0, sizeof(config->dmic)); in sof_link_dmic_load()
1389 ret = sof_update_ipc_object(scomp, &config->dmic, SOF_DMIC_TOKENS, slink->tuples, in sof_link_dmic_load()
1390 slink->num_tuples, size, slink->num_hw_configs); in sof_link_dmic_load()
1394 /* parse the required set of DMIC PDM tokens based on number of active PDM's */ in sof_link_dmic_load()
1395 ret = sof_update_ipc_object(scomp, &config->dmic.pdm[0], SOF_DMIC_PDM_TOKENS, in sof_link_dmic_load()
1396 slink->tuples, slink->num_tuples, in sof_link_dmic_load()
1398 config->dmic.num_pdm_active); in sof_link_dmic_load()
1403 config->hdr.size = size; in sof_link_dmic_load()
1406 dev_dbg(scomp->dev, "tplg: config DMIC%d driver version %d\n", in sof_link_dmic_load()
1407 config->dai_index, config->dmic.driver_ipc_version); in sof_link_dmic_load()
1408 dev_dbg(scomp->dev, "pdmclk_min %d pdm_clkmax %d duty_min %d\n", in sof_link_dmic_load()
1409 config->dmic.pdmclk_min, config->dmic.pdmclk_max, in sof_link_dmic_load()
1410 config->dmic.duty_min); in sof_link_dmic_load()
1411 dev_dbg(scomp->dev, "duty_max %d fifo_fs %d num_pdms active %d\n", in sof_link_dmic_load()
1412 config->dmic.duty_max, config->dmic.fifo_fs, in sof_link_dmic_load()
1413 config->dmic.num_pdm_active); in sof_link_dmic_load()
1414 dev_dbg(scomp->dev, "fifo word length %d\n", config->dmic.fifo_bits); in sof_link_dmic_load()
1416 for (i = 0; i < config->dmic.num_pdm_active; i++) { in sof_link_dmic_load()
1417 dev_dbg(scomp->dev, "pdm %d mic a %d mic b %d\n", in sof_link_dmic_load()
1418 config->dmic.pdm[i].id, in sof_link_dmic_load()
1419 config->dmic.pdm[i].enable_mic_a, in sof_link_dmic_load()
1420 config->dmic.pdm[i].enable_mic_b); in sof_link_dmic_load()
1421 dev_dbg(scomp->dev, "pdm %d polarity a %d polarity b %d\n", in sof_link_dmic_load()
1422 config->dmic.pdm[i].id, in sof_link_dmic_load()
1423 config->dmic.pdm[i].polarity_mic_a, in sof_link_dmic_load()
1424 config->dmic.pdm[i].polarity_mic_b); in sof_link_dmic_load()
1425 dev_dbg(scomp->dev, "pdm %d clk_edge %d skew %d\n", in sof_link_dmic_load()
1426 config->dmic.pdm[i].id, in sof_link_dmic_load()
1427 config->dmic.pdm[i].clk_edge, in sof_link_dmic_load()
1428 config->dmic.pdm[i].skew); in sof_link_dmic_load()
1435 if (SOF_ABI_VER(v->major, v->minor, v->micro) < SOF_ABI_VER(3, 0, 1)) in sof_link_dmic_load()
1436 config->dmic.fifo_bits_b = config->dmic.fifo_bits; in sof_link_dmic_load()
1438 dai->number_configs = 1; in sof_link_dmic_load()
1439 dai->current_config = 0; in sof_link_dmic_load()
1440 private->dai_config = kmemdup(config, size, GFP_KERNEL); in sof_link_dmic_load()
1441 if (!private->dai_config) in sof_link_dmic_load()
1442 return -ENOMEM; in sof_link_dmic_load()
1450 struct sof_dai_private_data *private = dai->private; in sof_link_alh_load()
1455 ret = sof_update_ipc_object(scomp, &config->alh, SOF_ALH_TOKENS, slink->tuples, in sof_link_alh_load()
1456 slink->num_tuples, size, slink->num_hw_configs); in sof_link_alh_load()
1461 config->hdr.size = size; in sof_link_alh_load()
1464 dai->number_configs = 1; in sof_link_alh_load()
1465 dai->current_config = 0; in sof_link_alh_load()
1466 private->dai_config = kmemdup(config, size, GFP_KERNEL); in sof_link_alh_load()
1467 if (!private->dai_config) in sof_link_alh_load()
1468 return -ENOMEM; in sof_link_alh_load()
1475 struct snd_soc_component *scomp = swidget->scomp; in sof_ipc3_widget_setup_comp_dai()
1477 struct snd_sof_dai *dai = swidget->private; in sof_ipc3_widget_setup_comp_dai()
1487 return -ENOMEM; in sof_ipc3_widget_setup_comp_dai()
1489 dai->private = private; in sof_ipc3_widget_setup_comp_dai()
1491 private->comp_dai = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id); in sof_ipc3_widget_setup_comp_dai()
1492 if (!private->comp_dai) { in sof_ipc3_widget_setup_comp_dai()
1493 ret = -ENOMEM; in sof_ipc3_widget_setup_comp_dai()
1498 comp_dai = private->comp_dai; in sof_ipc3_widget_setup_comp_dai()
1499 comp_dai->comp.type = SOF_COMP_DAI; in sof_ipc3_widget_setup_comp_dai()
1500 comp_dai->config.hdr.size = sizeof(comp_dai->config); in sof_ipc3_widget_setup_comp_dai()
1503 ret = sof_update_ipc_object(scomp, comp_dai, SOF_DAI_TOKENS, swidget->tuples, in sof_ipc3_widget_setup_comp_dai()
1504 swidget->num_tuples, sizeof(*comp_dai), 1); in sof_ipc3_widget_setup_comp_dai()
1509 ret = sof_update_ipc_object(scomp, &comp_dai->config, SOF_COMP_TOKENS, in sof_ipc3_widget_setup_comp_dai()
1510 swidget->tuples, swidget->num_tuples, in sof_ipc3_widget_setup_comp_dai()
1511 sizeof(comp_dai->config), 1); in sof_ipc3_widget_setup_comp_dai()
1516 if (comp_dai->type == SOF_DAI_INTEL_ALH) { in sof_ipc3_widget_setup_comp_dai()
1517 if (comp_dai->dai_index < INTEL_ALH_DAI_INDEX_BASE) { in sof_ipc3_widget_setup_comp_dai()
1518 dev_err(sdev->dev, in sof_ipc3_widget_setup_comp_dai()
1520 comp_dai->dai_index, INTEL_ALH_DAI_INDEX_BASE); in sof_ipc3_widget_setup_comp_dai()
1521 ret = -EINVAL; in sof_ipc3_widget_setup_comp_dai()
1524 comp_dai->dai_index -= INTEL_ALH_DAI_INDEX_BASE; in sof_ipc3_widget_setup_comp_dai()
1527 dev_dbg(scomp->dev, "dai %s: type %d index %d\n", in sof_ipc3_widget_setup_comp_dai()
1528 swidget->widget->name, comp_dai->type, comp_dai->dai_index); in sof_ipc3_widget_setup_comp_dai()
1529 sof_dbg_comp_config(scomp, &comp_dai->config); in sof_ipc3_widget_setup_comp_dai()
1532 list_for_each_entry(slink, &sdev->dai_link_list, list) { in sof_ipc3_widget_setup_comp_dai()
1536 if (strcmp(slink->link->name, dai->name)) in sof_ipc3_widget_setup_comp_dai()
1540 config = kcalloc(slink->num_hw_configs, sizeof(*config), GFP_KERNEL); in sof_ipc3_widget_setup_comp_dai()
1542 ret = -ENOMEM; in sof_ipc3_widget_setup_comp_dai()
1548 slink->tuples, slink->num_tuples, in sof_ipc3_widget_setup_comp_dai()
1553 for (i = 0; i < slink->num_hw_configs; i++) { in sof_ipc3_widget_setup_comp_dai()
1555 config[i].format = le32_to_cpu(slink->hw_configs[i].fmt); in sof_ipc3_widget_setup_comp_dai()
1557 config[i].dai_index = comp_dai->dai_index; in sof_ipc3_widget_setup_comp_dai()
1600 dev_err(scomp->dev, "failed to load config for dai %s\n", dai->name); in sof_ipc3_widget_setup_comp_dai()
1614 dai->private = NULL; in sof_ipc3_widget_setup_comp_dai()
1620 switch (swidget->id) { in sof_ipc3_widget_free_comp_dai()
1624 struct snd_sof_dai *dai = swidget->private; in sof_ipc3_widget_free_comp_dai()
1630 dai_data = dai->private; in sof_ipc3_widget_free_comp_dai()
1632 kfree(dai_data->comp_dai); in sof_ipc3_widget_free_comp_dai()
1633 kfree(dai_data->dai_config); in sof_ipc3_widget_free_comp_dai()
1651 connect.source_id = sroute->src_widget->comp_id; in sof_ipc3_route_setup()
1652 connect.sink_id = sroute->sink_widget->comp_id; in sof_ipc3_route_setup()
1654 dev_dbg(sdev->dev, "setting up route %s -> %s\n", in sof_ipc3_route_setup()
1655 sroute->src_widget->widget->name, in sof_ipc3_route_setup()
1656 sroute->sink_widget->widget->name); in sof_ipc3_route_setup()
1659 ret = sof_ipc_tx_message_no_reply(sdev->ipc, &connect, sizeof(connect)); in sof_ipc3_route_setup()
1661 dev_err(sdev->dev, "%s: route %s -> %s failed\n", __func__, in sof_ipc3_route_setup()
1662 sroute->src_widget->widget->name, sroute->sink_widget->widget->name); in sof_ipc3_route_setup()
1673 if (scontrol->max_size < (sizeof(*cdata) + sizeof(struct sof_abi_hdr))) { in sof_ipc3_control_load_bytes()
1674 dev_err(sdev->dev, "%s: insufficient size for a bytes control: %zu.\n", in sof_ipc3_control_load_bytes()
1675 __func__, scontrol->max_size); in sof_ipc3_control_load_bytes()
1676 return -EINVAL; in sof_ipc3_control_load_bytes()
1679 if (scontrol->priv_size > scontrol->max_size - sizeof(*cdata)) { in sof_ipc3_control_load_bytes()
1680 dev_err(sdev->dev, in sof_ipc3_control_load_bytes()
1682 scontrol->priv_size, scontrol->max_size - sizeof(*cdata)); in sof_ipc3_control_load_bytes()
1683 return -EINVAL; in sof_ipc3_control_load_bytes()
1686 scontrol->ipc_control_data = kzalloc(scontrol->max_size, GFP_KERNEL); in sof_ipc3_control_load_bytes()
1687 if (!scontrol->ipc_control_data) in sof_ipc3_control_load_bytes()
1688 return -ENOMEM; in sof_ipc3_control_load_bytes()
1690 scontrol->size = sizeof(struct sof_ipc_ctrl_data) + scontrol->priv_size; in sof_ipc3_control_load_bytes()
1692 cdata = scontrol->ipc_control_data; in sof_ipc3_control_load_bytes()
1693 cdata->cmd = SOF_CTRL_CMD_BINARY; in sof_ipc3_control_load_bytes()
1694 cdata->index = scontrol->index; in sof_ipc3_control_load_bytes()
1696 if (scontrol->priv_size > 0) { in sof_ipc3_control_load_bytes()
1697 memcpy(cdata->data, scontrol->priv, scontrol->priv_size); in sof_ipc3_control_load_bytes()
1698 kfree(scontrol->priv); in sof_ipc3_control_load_bytes()
1699 scontrol->priv = NULL; in sof_ipc3_control_load_bytes()
1701 if (cdata->data->magic != SOF_ABI_MAGIC) { in sof_ipc3_control_load_bytes()
1702 dev_err(sdev->dev, "Wrong ABI magic 0x%08x.\n", cdata->data->magic); in sof_ipc3_control_load_bytes()
1703 ret = -EINVAL; in sof_ipc3_control_load_bytes()
1707 if (SOF_ABI_VERSION_INCOMPATIBLE(SOF_ABI_VERSION, cdata->data->abi)) { in sof_ipc3_control_load_bytes()
1708 dev_err(sdev->dev, "Incompatible ABI version 0x%08x.\n", in sof_ipc3_control_load_bytes()
1709 cdata->data->abi); in sof_ipc3_control_load_bytes()
1710 ret = -EINVAL; in sof_ipc3_control_load_bytes()
1714 priv_size_check = cdata->data->size + sizeof(struct sof_abi_hdr); in sof_ipc3_control_load_bytes()
1715 if (priv_size_check != scontrol->priv_size) { in sof_ipc3_control_load_bytes()
1716 dev_err(sdev->dev, "Conflict in bytes (%zu) vs. priv size (%zu).\n", in sof_ipc3_control_load_bytes()
1717 priv_size_check, scontrol->priv_size); in sof_ipc3_control_load_bytes()
1718 ret = -EINVAL; in sof_ipc3_control_load_bytes()
1725 kfree(scontrol->ipc_control_data); in sof_ipc3_control_load_bytes()
1726 scontrol->ipc_control_data = NULL; in sof_ipc3_control_load_bytes()
1736 scontrol->size = struct_size(cdata, chanv, scontrol->num_channels); in sof_ipc3_control_load_volume()
1738 scontrol->ipc_control_data = kzalloc(scontrol->size, GFP_KERNEL); in sof_ipc3_control_load_volume()
1739 if (!scontrol->ipc_control_data) in sof_ipc3_control_load_volume()
1740 return -ENOMEM; in sof_ipc3_control_load_volume()
1742 cdata = scontrol->ipc_control_data; in sof_ipc3_control_load_volume()
1743 cdata->index = scontrol->index; in sof_ipc3_control_load_volume()
1746 if (scontrol->max == 1) { in sof_ipc3_control_load_volume()
1747 cdata->cmd = SOF_CTRL_CMD_SWITCH; in sof_ipc3_control_load_volume()
1751 cdata->cmd = SOF_CTRL_CMD_VOLUME; in sof_ipc3_control_load_volume()
1754 for (i = 0; i < scontrol->num_channels; i++) { in sof_ipc3_control_load_volume()
1755 cdata->chanv[i].channel = i; in sof_ipc3_control_load_volume()
1756 cdata->chanv[i].value = VOL_ZERO_DB; in sof_ipc3_control_load_volume()
1767 scontrol->size = struct_size(cdata, chanv, scontrol->num_channels); in sof_ipc3_control_load_enum()
1769 scontrol->ipc_control_data = kzalloc(scontrol->size, GFP_KERNEL); in sof_ipc3_control_load_enum()
1770 if (!scontrol->ipc_control_data) in sof_ipc3_control_load_enum()
1771 return -ENOMEM; in sof_ipc3_control_load_enum()
1773 cdata = scontrol->ipc_control_data; in sof_ipc3_control_load_enum()
1774 cdata->index = scontrol->index; in sof_ipc3_control_load_enum()
1775 cdata->cmd = SOF_CTRL_CMD_ENUM; in sof_ipc3_control_load_enum()
1782 switch (scontrol->info_type) { in sof_ipc3_control_setup()
1805 fcomp.id = scontrol->comp_id; in sof_ipc3_control_free()
1808 return sof_ipc_tx_message_no_reply(sdev->ipc, &fcomp, sizeof(fcomp)); in sof_ipc3_control_free()
1814 struct snd_soc_component *scomp = swidget->scomp; in sof_ipc3_keyword_detect_pcm_params()
1822 spcm = snd_sof_find_spcm_name(scomp, swidget->widget->sname); in sof_ipc3_keyword_detect_pcm_params()
1824 dev_err(scomp->dev, "Cannot find PCM for %s\n", swidget->widget->name); in sof_ipc3_keyword_detect_pcm_params()
1825 return -EINVAL; in sof_ipc3_keyword_detect_pcm_params()
1828 params = &spcm->params[dir]; in sof_ipc3_keyword_detect_pcm_params()
1834 pcm.comp_id = swidget->comp_id; in sof_ipc3_keyword_detect_pcm_params()
1855 return -EINVAL; in sof_ipc3_keyword_detect_pcm_params()
1859 ret = sof_ipc_tx_message_no_reply(sdev->ipc, &pcm, sizeof(pcm)); in sof_ipc3_keyword_detect_pcm_params()
1861 dev_err(scomp->dev, "%s: PCM params failed for %s\n", __func__, in sof_ipc3_keyword_detect_pcm_params()
1862 swidget->widget->name); in sof_ipc3_keyword_detect_pcm_params()
1870 struct snd_soc_component *scomp = swidget->scomp; in sof_ipc3_keyword_detect_trigger()
1878 stream.comp_id = swidget->comp_id; in sof_ipc3_keyword_detect_trigger()
1881 ret = sof_ipc_tx_message_no_reply(sdev->ipc, &stream, sizeof(stream)); in sof_ipc3_keyword_detect_trigger()
1883 dev_err(scomp->dev, "%s: Failed to trigger %s\n", __func__, swidget->widget->name); in sof_ipc3_keyword_detect_trigger()
1891 struct snd_sof_widget *swidget = w->dobj.private; in sof_ipc3_keyword_dapm_event()
1900 scomp = swidget->scomp; in sof_ipc3_keyword_dapm_event()
1902 dev_dbg(scomp->dev, "received event %d for widget %s\n", in sof_ipc3_keyword_dapm_event()
1903 event, w->name); in sof_ipc3_keyword_dapm_event()
1906 spcm = snd_sof_find_spcm_name(scomp, swidget->widget->sname); in sof_ipc3_keyword_dapm_event()
1908 dev_err(scomp->dev, "%s: Cannot find PCM for %s\n", __func__, in sof_ipc3_keyword_dapm_event()
1909 swidget->widget->name); in sof_ipc3_keyword_dapm_event()
1910 return -EINVAL; in sof_ipc3_keyword_dapm_event()
1916 if (spcm->stream[stream].suspend_ignored) { in sof_ipc3_keyword_dapm_event()
1917 dev_dbg(scomp->dev, "PRE_PMU event ignored, KWD pipeline is already RUNNING\n"); in sof_ipc3_keyword_dapm_event()
1924 dev_err(scomp->dev, "%s: Failed to set pcm params for widget %s\n", in sof_ipc3_keyword_dapm_event()
1925 __func__, swidget->widget->name); in sof_ipc3_keyword_dapm_event()
1932 dev_err(scomp->dev, "%s: Failed to trigger widget %s\n", __func__, in sof_ipc3_keyword_dapm_event()
1933 swidget->widget->name); in sof_ipc3_keyword_dapm_event()
1936 if (spcm->stream[stream].suspend_ignored) { in sof_ipc3_keyword_dapm_event()
1937 dev_dbg(scomp->dev, in sof_ipc3_keyword_dapm_event()
1945 dev_err(scomp->dev, "%s: Failed to trigger widget %s\n", __func__, in sof_ipc3_keyword_dapm_event()
1946 swidget->widget->name); in sof_ipc3_keyword_dapm_event()
1951 dev_err(scomp->dev, "%s: Failed to free PCM for widget %s\n", __func__, in sof_ipc3_keyword_dapm_event()
1952 swidget->widget->name); in sof_ipc3_keyword_dapm_event()
1975 if (swidget->id != snd_soc_dapm_effect) in sof_ipc3_widget_bind_event()
1978 ipc_comp = swidget->private; in sof_ipc3_widget_bind_event()
1979 if (ipc_comp && ipc_comp->type != SOF_COMP_KEYWORD_DETECT) in sof_ipc3_widget_bind_event()
1983 return snd_soc_tplg_widget_bind_event(swidget->widget, sof_kwd_events, in sof_ipc3_widget_bind_event()
1989 dev_err(scomp->dev, "Invalid event type %d for widget %s\n", event_type, in sof_ipc3_widget_bind_event()
1990 swidget->widget->name); in sof_ipc3_widget_bind_event()
1992 return -EINVAL; in sof_ipc3_widget_bind_event()
2000 dev_dbg(sdev->dev, "tplg: complete pipeline %s id %d\n", in sof_ipc3_complete_pipeline()
2001 swidget->widget->name, swidget->comp_id); in sof_ipc3_complete_pipeline()
2006 ready.comp_id = swidget->comp_id; in sof_ipc3_complete_pipeline()
2008 ret = sof_ipc_tx_message_no_reply(sdev->ipc, &ready, sizeof(ready)); in sof_ipc3_complete_pipeline()
2022 .id = swidget->comp_id, in sof_ipc3_widget_free()
2026 if (!swidget->private) in sof_ipc3_widget_free()
2029 switch (swidget->id) { in sof_ipc3_widget_free()
2043 ret = sof_ipc_tx_message_no_reply(sdev->ipc, &ipc_free, sizeof(ipc_free)); in sof_ipc3_widget_free()
2045 dev_err(sdev->dev, "failed to free widget %s\n", swidget->widget->name); in sof_ipc3_widget_free()
2053 struct sof_ipc_fw_version *v = &sdev->fw_ready.version; in sof_ipc3_dai_config()
2054 struct snd_sof_dai *dai = swidget->private; in sof_ipc3_dai_config()
2059 if (!dai || !dai->private) { in sof_ipc3_dai_config()
2060 dev_err(sdev->dev, "No private data for DAI %s\n", swidget->widget->name); in sof_ipc3_dai_config()
2061 return -EINVAL; in sof_ipc3_dai_config()
2064 private = dai->private; in sof_ipc3_dai_config()
2065 if (!private->dai_config) { in sof_ipc3_dai_config()
2066 dev_err(sdev->dev, "No config for DAI %s\n", dai->name); in sof_ipc3_dai_config()
2067 return -EINVAL; in sof_ipc3_dai_config()
2070 config = &private->dai_config[dai->current_config]; in sof_ipc3_dai_config()
2072 dev_err(sdev->dev, "Invalid current config for DAI %s\n", dai->name); in sof_ipc3_dai_config()
2073 return -EINVAL; in sof_ipc3_dai_config()
2076 switch (config->type) { in sof_ipc3_dai_config()
2082 if (v->abi_version < SOF_ABI_VER(3, 18, 0) && in sof_ipc3_dai_config()
2089 config->hda.link_dma_ch = data->dai_data; in sof_ipc3_dai_config()
2096 if (data->dai_index < INTEL_ALH_DAI_INDEX_BASE) { in sof_ipc3_dai_config()
2097 dev_err(sdev->dev, in sof_ipc3_dai_config()
2099 config->dai_index, INTEL_ALH_DAI_INDEX_BASE); in sof_ipc3_dai_config()
2100 return -EINVAL; in sof_ipc3_dai_config()
2102 config->dai_index = data->dai_index - INTEL_ALH_DAI_INDEX_BASE; in sof_ipc3_dai_config()
2104 config->alh.stream_id = data->dai_data; in sof_ipc3_dai_config()
2133 config->flags &= ~SOF_DAI_CONFIG_FLAGS_CMD_MASK; in sof_ipc3_dai_config()
2134 config->flags |= flags; in sof_ipc3_dai_config()
2136 config->flags = flags; in sof_ipc3_dai_config()
2140 if (swidget->use_count > 0) { in sof_ipc3_dai_config()
2141 ret = sof_ipc_tx_message_no_reply(sdev->ipc, config, config->hdr.size); in sof_ipc3_dai_config()
2143 dev_err(sdev->dev, "Failed to set dai config for %s\n", dai->name); in sof_ipc3_dai_config()
2146 config->flags = SOF_DAI_CONFIG_FLAGS_NONE; in sof_ipc3_dai_config()
2156 if (!swidget->private) in sof_ipc3_widget_setup()
2159 switch (swidget->id) { in sof_ipc3_widget_setup()
2163 struct snd_sof_dai *dai = swidget->private; in sof_ipc3_widget_setup()
2164 struct sof_dai_private_data *dai_data = dai->private; in sof_ipc3_widget_setup()
2165 struct sof_ipc_comp *comp = &dai_data->comp_dai->comp; in sof_ipc3_widget_setup()
2167 ret = sof_ipc_tx_message_no_reply(sdev->ipc, dai_data->comp_dai, comp->hdr.size); in sof_ipc3_widget_setup()
2174 pipeline = swidget->private; in sof_ipc3_widget_setup()
2175 ret = sof_ipc_tx_message_no_reply(sdev->ipc, pipeline, sizeof(*pipeline)); in sof_ipc3_widget_setup()
2182 hdr = swidget->private; in sof_ipc3_widget_setup()
2183 ret = sof_ipc_tx_message_no_reply(sdev->ipc, swidget->private, hdr->size); in sof_ipc3_widget_setup()
2188 dev_err(sdev->dev, "Failed to setup widget %s\n", swidget->widget->name); in sof_ipc3_widget_setup()
2195 struct sof_ipc_fw_version *v = &sdev->fw_ready.version; in sof_ipc3_set_up_all_pipelines()
2201 list_for_each_entry(swidget, &sdev->widget_list, list) { in sof_ipc3_set_up_all_pipelines()
2203 if (!verify && swidget->dynamic_pipeline_widget) in sof_ipc3_set_up_all_pipelines()
2210 if (v->abi_version < SOF_ABI_VER(3, 19, 0) && in sof_ipc3_set_up_all_pipelines()
2211 swidget->id == snd_soc_dapm_scheduler) in sof_ipc3_set_up_all_pipelines()
2215 if (WIDGET_IS_DAI(swidget->id)) { in sof_ipc3_set_up_all_pipelines()
2216 struct snd_sof_dai *dai = swidget->private; in sof_ipc3_set_up_all_pipelines()
2220 if (!dai || !dai->private) in sof_ipc3_set_up_all_pipelines()
2222 private = dai->private; in sof_ipc3_set_up_all_pipelines()
2223 if (!private->dai_config) in sof_ipc3_set_up_all_pipelines()
2226 config = private->dai_config; in sof_ipc3_set_up_all_pipelines()
2233 if (config->type == SOF_DAI_INTEL_HDA) in sof_ipc3_set_up_all_pipelines()
2234 config->hda.link_dma_ch = DMA_CHAN_INVALID; in sof_ipc3_set_up_all_pipelines()
2243 list_for_each_entry(sroute, &sdev->route_list, list) { in sof_ipc3_set_up_all_pipelines()
2245 if (!verify && (sroute->src_widget->dynamic_pipeline_widget || in sof_ipc3_set_up_all_pipelines()
2246 sroute->sink_widget->dynamic_pipeline_widget)) in sof_ipc3_set_up_all_pipelines()
2253 if (sroute->src_widget->id != snd_soc_dapm_buffer && in sof_ipc3_set_up_all_pipelines()
2254 sroute->sink_widget->id != snd_soc_dapm_buffer) in sof_ipc3_set_up_all_pipelines()
2257 ret = sof_route_setup(sdev, sroute->src_widget->widget, in sof_ipc3_set_up_all_pipelines()
2258 sroute->sink_widget->widget); in sof_ipc3_set_up_all_pipelines()
2260 dev_err(sdev->dev, "%s: route set up failed\n", __func__); in sof_ipc3_set_up_all_pipelines()
2266 list_for_each_entry(swidget, &sdev->widget_list, list) { in sof_ipc3_set_up_all_pipelines()
2267 switch (swidget->id) { in sof_ipc3_set_up_all_pipelines()
2270 if (!verify && swidget->dynamic_pipeline_widget) in sof_ipc3_set_up_all_pipelines()
2273 if (v->abi_version < SOF_ABI_VER(3, 19, 0)) { in sof_ipc3_set_up_all_pipelines()
2279 swidget->spipe->complete = sof_ipc3_complete_pipeline(sdev, swidget); in sof_ipc3_set_up_all_pipelines()
2280 if (swidget->spipe->complete < 0) in sof_ipc3_set_up_all_pipelines()
2281 return swidget->spipe->complete; in sof_ipc3_set_up_all_pipelines()
2306 list_for_each_entry(spcm, &sdev->pcm_list, list) { in sof_tear_down_left_over_pipelines()
2308 struct snd_pcm_substream *substream = spcm->stream[dir].substream; in sof_tear_down_left_over_pipelines()
2310 if (!substream || !substream->runtime || spcm->stream[dir].suspend_ignored) in sof_tear_down_left_over_pipelines()
2313 if (spcm->stream[dir].list) { in sof_tear_down_left_over_pipelines()
2325 list_for_each_entry(swidget, &sdev->widget_list, list) in sof_tear_down_left_over_pipelines()
2326 if (WIDGET_IS_DAI(swidget->id) && swidget->use_count == 1) { in sof_tear_down_left_over_pipelines()
2338 struct sof_ipc_fw_version *v = &sdev->fw_ready.version; in sof_ipc3_free_widgets_in_list()
2342 list_for_each_entry(swidget, &sdev->widget_list, list) { in sof_ipc3_free_widgets_in_list()
2343 if (swidget->dynamic_pipeline_widget) { in sof_ipc3_free_widgets_in_list()
2349 if (!verify && !swidget->dynamic_pipeline_widget && in sof_ipc3_free_widgets_in_list()
2350 SOF_FW_VER(v->major, v->minor, v->micro) < SOF_FW_VER(2, 2, 0)) { in sof_ipc3_free_widgets_in_list()
2351 mutex_lock(&swidget->setup_mutex); in sof_ipc3_free_widgets_in_list()
2352 swidget->use_count = 0; in sof_ipc3_free_widgets_in_list()
2353 mutex_unlock(&swidget->setup_mutex); in sof_ipc3_free_widgets_in_list()
2354 if (swidget->spipe) in sof_ipc3_free_widgets_in_list()
2355 swidget->spipe->complete = 0; in sof_ipc3_free_widgets_in_list()
2359 if (include_scheduler && swidget->id != snd_soc_dapm_scheduler) in sof_ipc3_free_widgets_in_list()
2362 if (!include_scheduler && swidget->id == snd_soc_dapm_scheduler) in sof_ipc3_free_widgets_in_list()
2379 struct sof_ipc_fw_version *v = &sdev->fw_ready.version; in sof_ipc3_tear_down_all_pipelines()
2386 * This function is called during suspend and for one-time topology verification during in sof_ipc3_tear_down_all_pipelines()
2387 * first boot. In both cases, there is no need to protect swidget->use_count and in sof_ipc3_tear_down_all_pipelines()
2388 * sroute->setup because during suspend all running streams are suspended and during in sof_ipc3_tear_down_all_pipelines()
2408 if (!verify && (dyn_widgets || SOF_FW_VER(v->major, v->minor, v->micro) >= in sof_ipc3_tear_down_all_pipelines()
2412 dev_err(sdev->dev, "failed to tear down paused pipelines\n"); in sof_ipc3_tear_down_all_pipelines()
2417 list_for_each_entry(sroute, &sdev->route_list, list) in sof_ipc3_tear_down_all_pipelines()
2418 sroute->setup = false; in sof_ipc3_tear_down_all_pipelines()
2425 list_for_each_entry(swidget, &sdev->widget_list, list) { in sof_ipc3_tear_down_all_pipelines()
2426 if (swidget->use_count != 0) { in sof_ipc3_tear_down_all_pipelines()
2427 dev_err(sdev->dev, "%s: widget %s is still in use: count %d\n", in sof_ipc3_tear_down_all_pipelines()
2428 __func__, swidget->widget->name, swidget->use_count); in sof_ipc3_tear_down_all_pipelines()
2437 struct sof_dai_private_data *private = dai->private; in sof_ipc3_dai_get_clk()
2439 if (!private || !private->dai_config) in sof_ipc3_dai_get_clk()
2442 switch (private->dai_config->type) { in sof_ipc3_dai_get_clk()
2446 return private->dai_config->ssp.mclk_rate; in sof_ipc3_dai_get_clk()
2448 return private->dai_config->ssp.bclk_rate; in sof_ipc3_dai_get_clk()
2452 dev_err(sdev->dev, "fail to get SSP clk %d rate\n", clk_type); in sof_ipc3_dai_get_clk()
2456 dev_err(sdev->dev, "DAI type %d not supported yet!\n", private->dai_config->type); in sof_ipc3_dai_get_clk()
2460 return -EINVAL; in sof_ipc3_dai_get_clk()
2466 u32 size = le32_to_cpu(man->priv.size); in sof_ipc3_parse_manifest()
2471 dev_dbg(scomp->dev, "No topology ABI info\n"); in sof_ipc3_parse_manifest()
2476 dev_err(scomp->dev, "%s: Invalid topology ABI size: %u\n", in sof_ipc3_parse_manifest()
2478 return -EINVAL; in sof_ipc3_parse_manifest()
2481 dev_info(scomp->dev, in sof_ipc3_parse_manifest()
2483 man->priv.data[0], man->priv.data[1], man->priv.data[2], in sof_ipc3_parse_manifest()
2486 abi_version = SOF_ABI_VER(man->priv.data[0], man->priv.data[1], man->priv.data[2]); in sof_ipc3_parse_manifest()
2489 dev_err(scomp->dev, "%s: Incompatible topology ABI version\n", __func__); in sof_ipc3_parse_manifest()
2490 return -EINVAL; in sof_ipc3_parse_manifest()
2495 dev_err(scomp->dev, "%s: Topology ABI is more recent than kernel\n", __func__); in sof_ipc3_parse_manifest()
2496 return -EINVAL; in sof_ipc3_parse_manifest()
2504 if (link->no_pcm) in sof_ipc3_link_setup()
2514 link->trigger[SNDRV_PCM_STREAM_PLAYBACK] = SND_SOC_DPCM_TRIGGER_PRE; in sof_ipc3_link_setup()
2515 link->trigger[SNDRV_PCM_STREAM_CAPTURE] = SND_SOC_DPCM_TRIGGER_POST; in sof_ipc3_link_setup()