Lines Matching +full:micfil +full:- +full:audio

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"
291 /* MICFIL PDM */
345 [SOF_MICFIL_TOKENS] = {"MICFIL PDM tokens",
351 * sof_comp_alloc - allocate and initialize buffer for a new component
364 size_t ext_size = sizeof(swidget->uuid); in sof_comp_alloc()
366 /* only non-zero UUID is valid */ in sof_comp_alloc()
367 if (!guid_is_null(&swidget->uuid)) in sof_comp_alloc()
375 comp->hdr.size = total_size; in sof_comp_alloc()
376 comp->hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_COMP_NEW; in sof_comp_alloc()
377 comp->id = swidget->comp_id; in sof_comp_alloc()
378 comp->pipeline_id = index; in sof_comp_alloc()
379 comp->core = swidget->core; in sof_comp_alloc()
384 memcpy((u8 *)comp + *ipc_size, &swidget->uuid, ext_size); in sof_comp_alloc()
385 comp->ext_data_length = ext_size; in sof_comp_alloc()
395 dev_dbg(scomp->dev, " config: periods snk %d src %d fmt %d\n", in sof_dbg_comp_config()
396 config->periods_sink, config->periods_source, in sof_dbg_comp_config()
397 config->frame_fmt); in sof_dbg_comp_config()
402 struct snd_soc_component *scomp = swidget->scomp; in sof_ipc3_widget_setup_comp_host()
407 host = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id); in sof_ipc3_widget_setup_comp_host()
409 return -ENOMEM; in sof_ipc3_widget_setup_comp_host()
410 swidget->private = host; in sof_ipc3_widget_setup_comp_host()
413 host->comp.type = SOF_COMP_HOST; in sof_ipc3_widget_setup_comp_host()
414 host->config.hdr.size = sizeof(host->config); in sof_ipc3_widget_setup_comp_host()
416 if (swidget->id == snd_soc_dapm_aif_out) in sof_ipc3_widget_setup_comp_host()
417 host->direction = SOF_IPC_STREAM_CAPTURE; in sof_ipc3_widget_setup_comp_host()
419 host->direction = SOF_IPC_STREAM_PLAYBACK; in sof_ipc3_widget_setup_comp_host()
422 ret = sof_update_ipc_object(scomp, host, SOF_PCM_TOKENS, swidget->tuples, in sof_ipc3_widget_setup_comp_host()
423 swidget->num_tuples, sizeof(*host), 1); in sof_ipc3_widget_setup_comp_host()
428 ret = sof_update_ipc_object(scomp, &host->config, SOF_COMP_TOKENS, swidget->tuples, in sof_ipc3_widget_setup_comp_host()
429 swidget->num_tuples, sizeof(host->config), 1); in sof_ipc3_widget_setup_comp_host()
433 dev_dbg(scomp->dev, "loaded host %s\n", swidget->widget->name); in sof_ipc3_widget_setup_comp_host()
434 sof_dbg_comp_config(scomp, &host->config); in sof_ipc3_widget_setup_comp_host()
438 kfree(swidget->private); in sof_ipc3_widget_setup_comp_host()
439 swidget->private = NULL; in sof_ipc3_widget_setup_comp_host()
446 kfree(swidget->private); in sof_ipc3_widget_free_comp()
451 struct snd_soc_component *scomp = swidget->scomp; in sof_ipc3_widget_setup_comp_tone()
456 tone = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id); in sof_ipc3_widget_setup_comp_tone()
458 return -ENOMEM; in sof_ipc3_widget_setup_comp_tone()
460 swidget->private = tone; in sof_ipc3_widget_setup_comp_tone()
463 tone->comp.type = SOF_COMP_TONE; in sof_ipc3_widget_setup_comp_tone()
464 tone->config.hdr.size = sizeof(tone->config); in sof_ipc3_widget_setup_comp_tone()
467 ret = sof_update_ipc_object(scomp, &tone->config, SOF_COMP_TOKENS, swidget->tuples, in sof_ipc3_widget_setup_comp_tone()
468 swidget->num_tuples, sizeof(tone->config), 1); in sof_ipc3_widget_setup_comp_tone()
470 kfree(swidget->private); in sof_ipc3_widget_setup_comp_tone()
471 swidget->private = NULL; in sof_ipc3_widget_setup_comp_tone()
475 dev_dbg(scomp->dev, "tone %s: frequency %d amplitude %d\n", in sof_ipc3_widget_setup_comp_tone()
476 swidget->widget->name, tone->frequency, tone->amplitude); in sof_ipc3_widget_setup_comp_tone()
477 sof_dbg_comp_config(scomp, &tone->config); in sof_ipc3_widget_setup_comp_tone()
484 struct snd_soc_component *scomp = swidget->scomp; in sof_ipc3_widget_setup_comp_mixer()
489 mixer = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id); in sof_ipc3_widget_setup_comp_mixer()
491 return -ENOMEM; in sof_ipc3_widget_setup_comp_mixer()
493 swidget->private = mixer; in sof_ipc3_widget_setup_comp_mixer()
496 mixer->comp.type = SOF_COMP_MIXER; in sof_ipc3_widget_setup_comp_mixer()
497 mixer->config.hdr.size = sizeof(mixer->config); in sof_ipc3_widget_setup_comp_mixer()
500 ret = sof_update_ipc_object(scomp, &mixer->config, SOF_COMP_TOKENS, in sof_ipc3_widget_setup_comp_mixer()
501 swidget->tuples, swidget->num_tuples, in sof_ipc3_widget_setup_comp_mixer()
502 sizeof(mixer->config), 1); in sof_ipc3_widget_setup_comp_mixer()
504 kfree(swidget->private); in sof_ipc3_widget_setup_comp_mixer()
505 swidget->private = NULL; in sof_ipc3_widget_setup_comp_mixer()
510 dev_dbg(scomp->dev, "loaded mixer %s\n", swidget->widget->name); in sof_ipc3_widget_setup_comp_mixer()
511 sof_dbg_comp_config(scomp, &mixer->config); in sof_ipc3_widget_setup_comp_mixer()
518 struct snd_soc_component *scomp = swidget->scomp; in sof_ipc3_widget_setup_comp_pipeline()
519 struct snd_sof_pipeline *spipe = swidget->spipe; in sof_ipc3_widget_setup_comp_pipeline()
526 return -ENOMEM; in sof_ipc3_widget_setup_comp_pipeline()
529 pipeline->hdr.size = sizeof(*pipeline); in sof_ipc3_widget_setup_comp_pipeline()
530 pipeline->hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_PIPE_NEW; in sof_ipc3_widget_setup_comp_pipeline()
531 pipeline->pipeline_id = swidget->pipeline_id; in sof_ipc3_widget_setup_comp_pipeline()
532 pipeline->comp_id = swidget->comp_id; in sof_ipc3_widget_setup_comp_pipeline()
534 swidget->private = pipeline; in sof_ipc3_widget_setup_comp_pipeline()
537 comp_swidget = snd_sof_find_swidget(scomp, swidget->widget->sname); in sof_ipc3_widget_setup_comp_pipeline()
539 dev_err(scomp->dev, "scheduler %s refers to non existent widget %s\n", in sof_ipc3_widget_setup_comp_pipeline()
540 swidget->widget->name, swidget->widget->sname); in sof_ipc3_widget_setup_comp_pipeline()
541 ret = -EINVAL; in sof_ipc3_widget_setup_comp_pipeline()
545 pipeline->sched_id = comp_swidget->comp_id; in sof_ipc3_widget_setup_comp_pipeline()
548 ret = sof_update_ipc_object(scomp, pipeline, SOF_SCHED_TOKENS, swidget->tuples, in sof_ipc3_widget_setup_comp_pipeline()
549 swidget->num_tuples, sizeof(*pipeline), 1); in sof_ipc3_widget_setup_comp_pipeline()
554 ret = sof_update_ipc_object(scomp, swidget, SOF_PIPELINE_TOKENS, swidget->tuples, in sof_ipc3_widget_setup_comp_pipeline()
555 swidget->num_tuples, sizeof(*swidget), 1); in sof_ipc3_widget_setup_comp_pipeline()
560 pipeline->core = SOF_DSP_PRIMARY_CORE; in sof_ipc3_widget_setup_comp_pipeline()
563 swidget->dynamic_pipeline_widget = in sof_ipc3_widget_setup_comp_pipeline()
566 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()
567 swidget->widget->name, pipeline->period, pipeline->priority, in sof_ipc3_widget_setup_comp_pipeline()
568 pipeline->period_mips, pipeline->core, pipeline->frames_per_sched, in sof_ipc3_widget_setup_comp_pipeline()
569 swidget->dynamic_pipeline_widget); in sof_ipc3_widget_setup_comp_pipeline()
571 swidget->core = pipeline->core; in sof_ipc3_widget_setup_comp_pipeline()
572 spipe->core_mask |= BIT(pipeline->core); in sof_ipc3_widget_setup_comp_pipeline()
577 kfree(swidget->private); in sof_ipc3_widget_setup_comp_pipeline()
578 swidget->private = NULL; in sof_ipc3_widget_setup_comp_pipeline()
585 struct snd_soc_component *scomp = swidget->scomp; in sof_ipc3_widget_setup_comp_buffer()
591 return -ENOMEM; in sof_ipc3_widget_setup_comp_buffer()
593 swidget->private = buffer; in sof_ipc3_widget_setup_comp_buffer()
596 buffer->comp.hdr.size = sizeof(*buffer); in sof_ipc3_widget_setup_comp_buffer()
597 buffer->comp.hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_BUFFER_NEW; in sof_ipc3_widget_setup_comp_buffer()
598 buffer->comp.id = swidget->comp_id; in sof_ipc3_widget_setup_comp_buffer()
599 buffer->comp.type = SOF_COMP_BUFFER; in sof_ipc3_widget_setup_comp_buffer()
600 buffer->comp.pipeline_id = swidget->pipeline_id; in sof_ipc3_widget_setup_comp_buffer()
601 buffer->comp.core = swidget->core; in sof_ipc3_widget_setup_comp_buffer()
604 ret = sof_update_ipc_object(scomp, buffer, SOF_BUFFER_TOKENS, swidget->tuples, in sof_ipc3_widget_setup_comp_buffer()
605 swidget->num_tuples, sizeof(*buffer), 1); in sof_ipc3_widget_setup_comp_buffer()
607 kfree(swidget->private); in sof_ipc3_widget_setup_comp_buffer()
608 swidget->private = NULL; in sof_ipc3_widget_setup_comp_buffer()
612 dev_dbg(scomp->dev, "buffer %s: size %d caps 0x%x\n", in sof_ipc3_widget_setup_comp_buffer()
613 swidget->widget->name, buffer->size, buffer->caps); in sof_ipc3_widget_setup_comp_buffer()
620 struct snd_soc_component *scomp = swidget->scomp; in sof_ipc3_widget_setup_comp_src()
625 src = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id); in sof_ipc3_widget_setup_comp_src()
627 return -ENOMEM; in sof_ipc3_widget_setup_comp_src()
629 swidget->private = src; in sof_ipc3_widget_setup_comp_src()
632 src->comp.type = SOF_COMP_SRC; in sof_ipc3_widget_setup_comp_src()
633 src->config.hdr.size = sizeof(src->config); in sof_ipc3_widget_setup_comp_src()
636 ret = sof_update_ipc_object(scomp, src, SOF_SRC_TOKENS, swidget->tuples, in sof_ipc3_widget_setup_comp_src()
637 swidget->num_tuples, sizeof(*src), 1); in sof_ipc3_widget_setup_comp_src()
642 ret = sof_update_ipc_object(scomp, &src->config, SOF_COMP_TOKENS, in sof_ipc3_widget_setup_comp_src()
643 swidget->tuples, swidget->num_tuples, sizeof(src->config), 1); in sof_ipc3_widget_setup_comp_src()
647 dev_dbg(scomp->dev, "src %s: source rate %d sink rate %d\n", in sof_ipc3_widget_setup_comp_src()
648 swidget->widget->name, src->source_rate, src->sink_rate); in sof_ipc3_widget_setup_comp_src()
649 sof_dbg_comp_config(scomp, &src->config); in sof_ipc3_widget_setup_comp_src()
653 kfree(swidget->private); in sof_ipc3_widget_setup_comp_src()
654 swidget->private = NULL; in sof_ipc3_widget_setup_comp_src()
661 struct snd_soc_component *scomp = swidget->scomp; in sof_ipc3_widget_setup_comp_asrc()
666 asrc = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id); in sof_ipc3_widget_setup_comp_asrc()
668 return -ENOMEM; in sof_ipc3_widget_setup_comp_asrc()
670 swidget->private = asrc; in sof_ipc3_widget_setup_comp_asrc()
673 asrc->comp.type = SOF_COMP_ASRC; in sof_ipc3_widget_setup_comp_asrc()
674 asrc->config.hdr.size = sizeof(asrc->config); in sof_ipc3_widget_setup_comp_asrc()
677 ret = sof_update_ipc_object(scomp, asrc, SOF_ASRC_TOKENS, swidget->tuples, in sof_ipc3_widget_setup_comp_asrc()
678 swidget->num_tuples, sizeof(*asrc), 1); in sof_ipc3_widget_setup_comp_asrc()
683 ret = sof_update_ipc_object(scomp, &asrc->config, SOF_COMP_TOKENS, in sof_ipc3_widget_setup_comp_asrc()
684 swidget->tuples, swidget->num_tuples, sizeof(asrc->config), 1); in sof_ipc3_widget_setup_comp_asrc()
688 dev_dbg(scomp->dev, "asrc %s: source rate %d sink rate %d asynch %d operation %d\n", in sof_ipc3_widget_setup_comp_asrc()
689 swidget->widget->name, asrc->source_rate, asrc->sink_rate, in sof_ipc3_widget_setup_comp_asrc()
690 asrc->asynchronous_mode, asrc->operation_mode); in sof_ipc3_widget_setup_comp_asrc()
692 sof_dbg_comp_config(scomp, &asrc->config); in sof_ipc3_widget_setup_comp_asrc()
696 kfree(swidget->private); in sof_ipc3_widget_setup_comp_asrc()
697 swidget->private = NULL; in sof_ipc3_widget_setup_comp_asrc()
707 struct snd_soc_component *scomp = swidget->scomp; in sof_ipc3_widget_setup_comp_mux()
712 mux = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id); in sof_ipc3_widget_setup_comp_mux()
714 return -ENOMEM; in sof_ipc3_widget_setup_comp_mux()
716 swidget->private = mux; in sof_ipc3_widget_setup_comp_mux()
719 mux->comp.type = SOF_COMP_MUX; in sof_ipc3_widget_setup_comp_mux()
720 mux->config.hdr.size = sizeof(mux->config); in sof_ipc3_widget_setup_comp_mux()
723 ret = sof_update_ipc_object(scomp, &mux->config, SOF_COMP_TOKENS, in sof_ipc3_widget_setup_comp_mux()
724 swidget->tuples, swidget->num_tuples, sizeof(mux->config), 1); in sof_ipc3_widget_setup_comp_mux()
726 kfree(swidget->private); in sof_ipc3_widget_setup_comp_mux()
727 swidget->private = NULL; in sof_ipc3_widget_setup_comp_mux()
731 dev_dbg(scomp->dev, "loaded mux %s\n", swidget->widget->name); in sof_ipc3_widget_setup_comp_mux()
732 sof_dbg_comp_config(scomp, &mux->config); in sof_ipc3_widget_setup_comp_mux()
743 struct snd_soc_component *scomp = swidget->scomp; in sof_ipc3_widget_setup_comp_pga()
751 volume = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id); in sof_ipc3_widget_setup_comp_pga()
753 return -ENOMEM; in sof_ipc3_widget_setup_comp_pga()
755 swidget->private = volume; in sof_ipc3_widget_setup_comp_pga()
758 volume->comp.type = SOF_COMP_VOLUME; in sof_ipc3_widget_setup_comp_pga()
759 volume->config.hdr.size = sizeof(volume->config); in sof_ipc3_widget_setup_comp_pga()
762 ret = sof_update_ipc_object(scomp, volume, SOF_VOLUME_TOKENS, swidget->tuples, in sof_ipc3_widget_setup_comp_pga()
763 swidget->num_tuples, sizeof(*volume), 1); in sof_ipc3_widget_setup_comp_pga()
768 ret = sof_update_ipc_object(scomp, &volume->config, SOF_COMP_TOKENS, in sof_ipc3_widget_setup_comp_pga()
769 swidget->tuples, swidget->num_tuples, in sof_ipc3_widget_setup_comp_pga()
770 sizeof(volume->config), 1); in sof_ipc3_widget_setup_comp_pga()
774 dev_dbg(scomp->dev, "loaded PGA %s\n", swidget->widget->name); in sof_ipc3_widget_setup_comp_pga()
775 sof_dbg_comp_config(scomp, &volume->config); in sof_ipc3_widget_setup_comp_pga()
777 list_for_each_entry(scontrol, &sdev->kcontrol_list, list) { in sof_ipc3_widget_setup_comp_pga()
778 if (scontrol->comp_id == swidget->comp_id && in sof_ipc3_widget_setup_comp_pga()
779 scontrol->volume_table) { in sof_ipc3_widget_setup_comp_pga()
780 min_step = scontrol->min_volume_step; in sof_ipc3_widget_setup_comp_pga()
781 max_step = scontrol->max_volume_step; in sof_ipc3_widget_setup_comp_pga()
782 volume->min_value = scontrol->volume_table[min_step]; in sof_ipc3_widget_setup_comp_pga()
783 volume->max_value = scontrol->volume_table[max_step]; in sof_ipc3_widget_setup_comp_pga()
784 volume->channels = scontrol->num_channels; in sof_ipc3_widget_setup_comp_pga()
791 kfree(swidget->private); in sof_ipc3_widget_setup_comp_pga()
792 swidget->private = NULL; in sof_ipc3_widget_setup_comp_pga()
810 for (i = 0; i < widget->num_kcontrols; i++) { in sof_get_control_data()
811 kc = &widget->kcontrol_news[i]; in sof_get_control_data()
813 switch (widget->dobj.widget.kcontrol_type[i]) { in sof_get_control_data()
815 sm = (struct soc_mixer_control *)kc->private_value; in sof_get_control_data()
816 wdata[i].control = sm->dobj.private; in sof_get_control_data()
819 sbe = (struct soc_bytes_ext *)kc->private_value; in sof_get_control_data()
820 wdata[i].control = sbe->dobj.private; in sof_get_control_data()
823 se = (struct soc_enum *)kc->private_value; in sof_get_control_data()
824 wdata[i].control = se->dobj.private; in sof_get_control_data()
827 dev_err(scomp->dev, "Unknown kcontrol type %u in widget %s\n", in sof_get_control_data()
828 widget->dobj.widget.kcontrol_type[i], widget->name); in sof_get_control_data()
829 return -EINVAL; in sof_get_control_data()
833 dev_err(scomp->dev, "No scontrol for widget %s\n", widget->name); in sof_get_control_data()
834 return -EINVAL; in sof_get_control_data()
837 cdata = wdata[i].control->ipc_control_data; in sof_get_control_data()
839 if (widget->dobj.widget.kcontrol_type[i] == SND_SOC_TPLG_TYPE_BYTES) { in sof_get_control_data()
840 /* make sure data is valid - data can be updated at runtime */ in sof_get_control_data()
841 if (cdata->data->magic != SOF_ABI_MAGIC) in sof_get_control_data()
842 return -EINVAL; in sof_get_control_data()
844 wdata[i].pdata = cdata->data->data; in sof_get_control_data()
845 wdata[i].pdata_size = cdata->data->size; in sof_get_control_data()
848 wdata[i].pdata = cdata->chanv; in sof_get_control_data()
850 * wdata[i].control->size is calculated with struct_size in sof_get_control_data()
853 wdata[i].pdata_size = wdata[i].control->size - in sof_get_control_data()
860 switch (cdata->cmd) { in sof_get_control_data()
882 struct snd_soc_dapm_widget *widget = swidget->widget; in sof_process_load()
892 if (widget->num_kcontrols) { in sof_process_load()
893 wdata = kcalloc(widget->num_kcontrols, sizeof(*wdata), GFP_KERNEL); in sof_process_load()
895 return -ENOMEM; in sof_process_load()
907 ipc_size -= ipc_data_size; in sof_process_load()
911 process = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id); in sof_process_load()
913 ret = -ENOMEM; in sof_process_load()
917 swidget->private = process; in sof_process_load()
920 process->comp.type = type; in sof_process_load()
921 process->config.hdr.size = sizeof(process->config); in sof_process_load()
924 ret = sof_update_ipc_object(scomp, &process->config, SOF_COMP_TOKENS, in sof_process_load()
925 swidget->tuples, swidget->num_tuples, in sof_process_load()
926 sizeof(process->config), 1); in sof_process_load()
930 dev_dbg(scomp->dev, "loaded process %s\n", swidget->widget->name); in sof_process_load()
931 sof_dbg_comp_config(scomp, &process->config); in sof_process_load()
935 * get possible component controls - get size of all pdata, in sof_process_load()
939 for (i = 0; i < widget->num_kcontrols; i++) { in sof_process_load()
943 memcpy(&process->data[offset], wdata[i].pdata, in sof_process_load()
949 process->size = ipc_data_size; in sof_process_load()
955 kfree(swidget->private); in sof_process_load()
956 swidget->private = NULL; in sof_process_load()
975 * Processing Component Topology - can be "effect", "codec", or general
981 struct snd_soc_component *scomp = swidget->scomp; in sof_widget_update_ipc_comp_process()
986 config.comp.core = swidget->core; in sof_widget_update_ipc_comp_process()
989 ret = sof_update_ipc_object(scomp, &config, SOF_PROCESS_TOKENS, swidget->tuples, in sof_widget_update_ipc_comp_process()
990 swidget->num_tuples, sizeof(config), 1); in sof_widget_update_ipc_comp_process()
1001 struct sof_dai_private_data *private = dai->private; in sof_link_hda_load()
1006 memset(&config->hda, 0, sizeof(config->hda)); in sof_link_hda_load()
1007 config->hdr.size = size; in sof_link_hda_load()
1010 ret = sof_update_ipc_object(scomp, &config->hda, SOF_HDA_TOKENS, slink->tuples, in sof_link_hda_load()
1011 slink->num_tuples, size, 1); in sof_link_hda_load()
1015 dev_dbg(scomp->dev, "HDA config rate %d channels %d\n", in sof_link_hda_load()
1016 config->hda.rate, config->hda.channels); in sof_link_hda_load()
1018 config->hda.link_dma_ch = DMA_CHAN_INVALID; in sof_link_hda_load()
1020 dai->number_configs = 1; in sof_link_hda_load()
1021 dai->current_config = 0; in sof_link_hda_load()
1022 private->dai_config = kmemdup(config, size, GFP_KERNEL); in sof_link_hda_load()
1023 if (!private->dai_config) in sof_link_hda_load()
1024 return -ENOMEM; in sof_link_hda_load()
1033 config->format &= ~SOF_DAI_FMT_CLOCK_PROVIDER_MASK; in sof_dai_set_format()
1034 if (hw_config->bclk_provider == SND_SOC_TPLG_BCLK_CP) { in sof_dai_set_format()
1036 if (hw_config->fsync_provider == SND_SOC_TPLG_FSYNC_CP) in sof_dai_set_format()
1037 config->format |= SOF_DAI_FMT_CBP_CFP; in sof_dai_set_format()
1039 config->format |= SOF_DAI_FMT_CBP_CFC; in sof_dai_set_format()
1042 if (hw_config->fsync_provider == SND_SOC_TPLG_FSYNC_CP) in sof_dai_set_format()
1043 config->format |= SOF_DAI_FMT_CBC_CFP; in sof_dai_set_format()
1045 config->format |= SOF_DAI_FMT_CBC_CFC; in sof_dai_set_format()
1049 config->format &= ~SOF_DAI_FMT_INV_MASK; in sof_dai_set_format()
1050 if (hw_config->invert_bclk) { in sof_dai_set_format()
1051 if (hw_config->invert_fsync) in sof_dai_set_format()
1052 config->format |= SOF_DAI_FMT_IB_IF; in sof_dai_set_format()
1054 config->format |= SOF_DAI_FMT_IB_NF; in sof_dai_set_format()
1056 if (hw_config->invert_fsync) in sof_dai_set_format()
1057 config->format |= SOF_DAI_FMT_NB_IF; in sof_dai_set_format()
1059 config->format |= SOF_DAI_FMT_NB_NF; in sof_dai_set_format()
1066 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs; in sof_link_sai_load()
1067 struct sof_dai_private_data *private = dai->private; in sof_link_sai_load()
1075 memset(&config->sai, 0, sizeof(config->sai)); in sof_link_sai_load()
1076 config->hdr.size = size; in sof_link_sai_load()
1079 ret = sof_update_ipc_object(scomp, &config->sai, SOF_SAI_TOKENS, slink->tuples, in sof_link_sai_load()
1080 slink->num_tuples, size, 1); in sof_link_sai_load()
1084 config->sai.mclk_rate = le32_to_cpu(hw_config->mclk_rate); in sof_link_sai_load()
1085 config->sai.bclk_rate = le32_to_cpu(hw_config->bclk_rate); in sof_link_sai_load()
1086 config->sai.fsync_rate = le32_to_cpu(hw_config->fsync_rate); in sof_link_sai_load()
1087 config->sai.mclk_direction = hw_config->mclk_direction; in sof_link_sai_load()
1089 config->sai.tdm_slots = le32_to_cpu(hw_config->tdm_slots); in sof_link_sai_load()
1090 config->sai.tdm_slot_width = le32_to_cpu(hw_config->tdm_slot_width); in sof_link_sai_load()
1091 config->sai.rx_slots = le32_to_cpu(hw_config->rx_slots); in sof_link_sai_load()
1092 config->sai.tx_slots = le32_to_cpu(hw_config->tx_slots); in sof_link_sai_load()
1094 dev_info(scomp->dev, in sof_link_sai_load()
1096 config->dai_index, config->format, in sof_link_sai_load()
1097 config->sai.mclk_rate, config->sai.tdm_slot_width, in sof_link_sai_load()
1098 config->sai.tdm_slots, config->sai.mclk_id); in sof_link_sai_load()
1100 if (config->sai.tdm_slots < 1 || config->sai.tdm_slots > 8) { in sof_link_sai_load()
1101 dev_err(scomp->dev, "Invalid channel count for SAI%d\n", config->dai_index); in sof_link_sai_load()
1102 return -EINVAL; in sof_link_sai_load()
1105 dai->number_configs = 1; in sof_link_sai_load()
1106 dai->current_config = 0; in sof_link_sai_load()
1107 private->dai_config = kmemdup(config, size, GFP_KERNEL); in sof_link_sai_load()
1108 if (!private->dai_config) in sof_link_sai_load()
1109 return -ENOMEM; in sof_link_sai_load()
1117 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs; in sof_link_esai_load()
1118 struct sof_dai_private_data *private = dai->private; in sof_link_esai_load()
1126 memset(&config->esai, 0, sizeof(config->esai)); in sof_link_esai_load()
1127 config->hdr.size = size; in sof_link_esai_load()
1130 ret = sof_update_ipc_object(scomp, &config->esai, SOF_ESAI_TOKENS, slink->tuples, in sof_link_esai_load()
1131 slink->num_tuples, size, 1); in sof_link_esai_load()
1135 config->esai.mclk_rate = le32_to_cpu(hw_config->mclk_rate); in sof_link_esai_load()
1136 config->esai.bclk_rate = le32_to_cpu(hw_config->bclk_rate); in sof_link_esai_load()
1137 config->esai.fsync_rate = le32_to_cpu(hw_config->fsync_rate); in sof_link_esai_load()
1138 config->esai.mclk_direction = hw_config->mclk_direction; in sof_link_esai_load()
1139 config->esai.tdm_slots = le32_to_cpu(hw_config->tdm_slots); in sof_link_esai_load()
1140 config->esai.tdm_slot_width = le32_to_cpu(hw_config->tdm_slot_width); in sof_link_esai_load()
1141 config->esai.rx_slots = le32_to_cpu(hw_config->rx_slots); in sof_link_esai_load()
1142 config->esai.tx_slots = le32_to_cpu(hw_config->tx_slots); in sof_link_esai_load()
1144 dev_info(scomp->dev, in sof_link_esai_load()
1146 config->dai_index, config->format, in sof_link_esai_load()
1147 config->esai.mclk_rate, config->esai.tdm_slot_width, in sof_link_esai_load()
1148 config->esai.tdm_slots, config->esai.mclk_id); in sof_link_esai_load()
1150 if (config->esai.tdm_slots < 1 || config->esai.tdm_slots > 8) { in sof_link_esai_load()
1151 dev_err(scomp->dev, "Invalid channel count for ESAI%d\n", config->dai_index); in sof_link_esai_load()
1152 return -EINVAL; in sof_link_esai_load()
1155 dai->number_configs = 1; in sof_link_esai_load()
1156 dai->current_config = 0; in sof_link_esai_load()
1157 private->dai_config = kmemdup(config, size, GFP_KERNEL); in sof_link_esai_load()
1158 if (!private->dai_config) in sof_link_esai_load()
1159 return -ENOMEM; in sof_link_esai_load()
1167 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs; in sof_link_micfil_load()
1168 struct sof_dai_private_data *private = dai->private; in sof_link_micfil_load()
1175 config->hdr.size = size; in sof_link_micfil_load()
1177 /* parse the required set of MICFIL PDM tokens based on num_hw_cfgs */ in sof_link_micfil_load()
1178 ret = sof_update_ipc_object(scomp, &config->micfil, SOF_MICFIL_TOKENS, slink->tuples, in sof_link_micfil_load()
1179 slink->num_tuples, size, slink->num_hw_configs); in sof_link_micfil_load()
1183 dev_info(scomp->dev, "MICFIL PDM config dai_index %d channel %d rate %d\n", in sof_link_micfil_load()
1184 config->dai_index, config->micfil.pdm_ch, config->micfil.pdm_rate); in sof_link_micfil_load()
1186 dai->number_configs = 1; in sof_link_micfil_load()
1187 dai->current_config = 0; in sof_link_micfil_load()
1188 private->dai_config = kmemdup(config, size, GFP_KERNEL); in sof_link_micfil_load()
1189 if (!private->dai_config) in sof_link_micfil_load()
1190 return -ENOMEM; in sof_link_micfil_load()
1198 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs; in sof_link_acp_dmic_load()
1199 struct sof_dai_private_data *private = dai->private; in sof_link_acp_dmic_load()
1206 config->hdr.size = size; in sof_link_acp_dmic_load()
1209 ret = sof_update_ipc_object(scomp, &config->acpdmic, SOF_ACPDMIC_TOKENS, slink->tuples, in sof_link_acp_dmic_load()
1210 slink->num_tuples, size, slink->num_hw_configs); in sof_link_acp_dmic_load()
1214 dev_info(scomp->dev, "ACP_DMIC config ACP%d channel %d rate %d\n", in sof_link_acp_dmic_load()
1215 config->dai_index, config->acpdmic.pdm_ch, in sof_link_acp_dmic_load()
1216 config->acpdmic.pdm_rate); in sof_link_acp_dmic_load()
1218 dai->number_configs = 1; in sof_link_acp_dmic_load()
1219 dai->current_config = 0; in sof_link_acp_dmic_load()
1220 private->dai_config = kmemdup(config, size, GFP_KERNEL); in sof_link_acp_dmic_load()
1221 if (!private->dai_config) in sof_link_acp_dmic_load()
1222 return -ENOMEM; in sof_link_acp_dmic_load()
1230 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs; in sof_link_acp_bt_load()
1231 struct sof_dai_private_data *private = dai->private; in sof_link_acp_bt_load()
1239 memset(&config->acpbt, 0, sizeof(config->acpbt)); in sof_link_acp_bt_load()
1240 config->hdr.size = size; in sof_link_acp_bt_load()
1242 ret = sof_update_ipc_object(scomp, &config->acpbt, SOF_ACPI2S_TOKENS, slink->tuples, in sof_link_acp_bt_load()
1243 slink->num_tuples, size, slink->num_hw_configs); in sof_link_acp_bt_load()
1247 dev_info(scomp->dev, "ACP_BT config ACP%d channel %d rate %d tdm_mode %d\n", in sof_link_acp_bt_load()
1248 config->dai_index, config->acpbt.tdm_slots, in sof_link_acp_bt_load()
1249 config->acpbt.fsync_rate, config->acpbt.tdm_mode); in sof_link_acp_bt_load()
1251 dai->number_configs = 1; in sof_link_acp_bt_load()
1252 dai->current_config = 0; in sof_link_acp_bt_load()
1253 private->dai_config = kmemdup(config, size, GFP_KERNEL); in sof_link_acp_bt_load()
1254 if (!private->dai_config) in sof_link_acp_bt_load()
1255 return -ENOMEM; in sof_link_acp_bt_load()
1263 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs; in sof_link_acp_sp_load()
1264 struct sof_dai_private_data *private = dai->private; in sof_link_acp_sp_load()
1272 memset(&config->acpsp, 0, sizeof(config->acpsp)); in sof_link_acp_sp_load()
1273 config->hdr.size = size; in sof_link_acp_sp_load()
1275 ret = sof_update_ipc_object(scomp, &config->acpsp, SOF_ACPI2S_TOKENS, slink->tuples, in sof_link_acp_sp_load()
1276 slink->num_tuples, size, slink->num_hw_configs); in sof_link_acp_sp_load()
1281 dev_info(scomp->dev, "ACP_SP config ACP%d channel %d rate %d tdm_mode %d\n", in sof_link_acp_sp_load()
1282 config->dai_index, config->acpsp.tdm_slots, in sof_link_acp_sp_load()
1283 config->acpsp.fsync_rate, config->acpsp.tdm_mode); in sof_link_acp_sp_load()
1285 dai->number_configs = 1; in sof_link_acp_sp_load()
1286 dai->current_config = 0; in sof_link_acp_sp_load()
1287 private->dai_config = kmemdup(config, size, GFP_KERNEL); in sof_link_acp_sp_load()
1288 if (!private->dai_config) in sof_link_acp_sp_load()
1289 return -ENOMEM; in sof_link_acp_sp_load()
1297 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs; in sof_link_acp_hs_load()
1298 struct sof_dai_private_data *private = dai->private; in sof_link_acp_hs_load()
1306 memset(&config->acphs, 0, sizeof(config->acphs)); in sof_link_acp_hs_load()
1307 config->hdr.size = size; in sof_link_acp_hs_load()
1309 ret = sof_update_ipc_object(scomp, &config->acphs, SOF_ACPI2S_TOKENS, slink->tuples, in sof_link_acp_hs_load()
1310 slink->num_tuples, size, slink->num_hw_configs); in sof_link_acp_hs_load()
1314 dev_info(scomp->dev, "ACP_HS config ACP%d channel %d rate %d tdm_mode %d\n", in sof_link_acp_hs_load()
1315 config->dai_index, config->acphs.tdm_slots, in sof_link_acp_hs_load()
1316 config->acphs.fsync_rate, config->acphs.tdm_mode); in sof_link_acp_hs_load()
1318 dai->number_configs = 1; in sof_link_acp_hs_load()
1319 dai->current_config = 0; in sof_link_acp_hs_load()
1320 private->dai_config = kmemdup(config, size, GFP_KERNEL); in sof_link_acp_hs_load()
1321 if (!private->dai_config) in sof_link_acp_hs_load()
1322 return -ENOMEM; in sof_link_acp_hs_load()
1330 struct sof_dai_private_data *private = dai->private; in sof_link_acp_sdw_load()
1335 ret = sof_update_ipc_object(scomp, &config->acp_sdw, SOF_ACP_SDW_TOKENS, slink->tuples, in sof_link_acp_sdw_load()
1336 slink->num_tuples, size, slink->num_hw_configs); in sof_link_acp_sdw_load()
1341 config->hdr.size = size; in sof_link_acp_sdw_load()
1342 dev_dbg(scomp->dev, "ACP SDW config rate %d channels %d\n", in sof_link_acp_sdw_load()
1343 config->acp_sdw.rate, config->acp_sdw.channels); in sof_link_acp_sdw_load()
1346 dai->number_configs = 1; in sof_link_acp_sdw_load()
1347 dai->current_config = 0; in sof_link_acp_sdw_load()
1348 private->dai_config = kmemdup(config, size, GFP_KERNEL); in sof_link_acp_sdw_load()
1349 if (!private->dai_config) in sof_link_acp_sdw_load()
1350 return -ENOMEM; in sof_link_acp_sdw_load()
1358 struct sof_dai_private_data *private = dai->private; in sof_link_afe_load()
1362 config->hdr.size = size; in sof_link_afe_load()
1365 ret = sof_update_ipc_object(scomp, &config->afe, SOF_AFE_TOKENS, slink->tuples, in sof_link_afe_load()
1366 slink->num_tuples, size, slink->num_hw_configs); in sof_link_afe_load()
1370 dev_dbg(scomp->dev, "AFE config rate %d channels %d format:%d\n", in sof_link_afe_load()
1371 config->afe.rate, config->afe.channels, config->afe.format); in sof_link_afe_load()
1373 config->afe.stream_id = DMA_CHAN_INVALID; in sof_link_afe_load()
1375 dai->number_configs = 1; in sof_link_afe_load()
1376 dai->current_config = 0; in sof_link_afe_load()
1377 private->dai_config = kmemdup(config, size, GFP_KERNEL); in sof_link_afe_load()
1378 if (!private->dai_config) in sof_link_afe_load()
1379 return -ENOMEM; in sof_link_afe_load()
1388 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs; in sof_link_ssp_load()
1389 struct sof_dai_private_data *private = dai->private; in sof_link_ssp_load()
1397 ret = sof_update_ipc_object(scomp, &config->ssp, SOF_SSP_TOKENS, slink->tuples, in sof_link_ssp_load()
1398 slink->num_tuples, size, slink->num_hw_configs); in sof_link_ssp_load()
1403 for (i = 0; i < slink->num_hw_configs; i++) { in sof_link_ssp_load()
1404 if (le32_to_cpu(hw_config[i].id) == slink->default_hw_cfg_id) in sof_link_ssp_load()
1412 if (sdev->mclk_id_override) { in sof_link_ssp_load()
1413 dev_dbg(scomp->dev, "tplg: overriding topology mclk_id %d by quirk %d\n", in sof_link_ssp_load()
1414 config[i].ssp.mclk_id, sdev->mclk_id_quirk); in sof_link_ssp_load()
1415 config[i].ssp.mclk_id = sdev->mclk_id_quirk; in sof_link_ssp_load()
1428 …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()
1437 dev_err(scomp->dev, "Invalid fsync rate for SSP%d\n", config[i].dai_index); in sof_link_ssp_load()
1438 return -EINVAL; in sof_link_ssp_load()
1442 dev_err(scomp->dev, "Invalid channel count for SSP%d\n", in sof_link_ssp_load()
1444 return -EINVAL; in sof_link_ssp_load()
1448 dai->number_configs = slink->num_hw_configs; in sof_link_ssp_load()
1449 dai->current_config = current_config; in sof_link_ssp_load()
1450 private->dai_config = kmemdup(config, size * slink->num_hw_configs, GFP_KERNEL); in sof_link_ssp_load()
1451 if (!private->dai_config) in sof_link_ssp_load()
1452 return -ENOMEM; in sof_link_ssp_load()
1461 struct sof_dai_private_data *private = dai->private; in sof_link_dmic_load()
1462 struct sof_ipc_fw_ready *ready = &sdev->fw_ready; in sof_link_dmic_load()
1463 struct sof_ipc_fw_version *v = &ready->version; in sof_link_dmic_load()
1468 memset(&config->dmic, 0, sizeof(config->dmic)); in sof_link_dmic_load()
1471 ret = sof_update_ipc_object(scomp, &config->dmic, SOF_DMIC_TOKENS, slink->tuples, in sof_link_dmic_load()
1472 slink->num_tuples, size, slink->num_hw_configs); in sof_link_dmic_load()
1477 ret = sof_update_ipc_object(scomp, &config->dmic.pdm[0], SOF_DMIC_PDM_TOKENS, in sof_link_dmic_load()
1478 slink->tuples, slink->num_tuples, in sof_link_dmic_load()
1480 config->dmic.num_pdm_active); in sof_link_dmic_load()
1485 config->hdr.size = size; in sof_link_dmic_load()
1488 dev_dbg(scomp->dev, "tplg: config DMIC%d driver version %d\n", in sof_link_dmic_load()
1489 config->dai_index, config->dmic.driver_ipc_version); in sof_link_dmic_load()
1490 dev_dbg(scomp->dev, "pdmclk_min %d pdm_clkmax %d duty_min %d\n", in sof_link_dmic_load()
1491 config->dmic.pdmclk_min, config->dmic.pdmclk_max, in sof_link_dmic_load()
1492 config->dmic.duty_min); in sof_link_dmic_load()
1493 dev_dbg(scomp->dev, "duty_max %d fifo_fs %d num_pdms active %d\n", in sof_link_dmic_load()
1494 config->dmic.duty_max, config->dmic.fifo_fs, in sof_link_dmic_load()
1495 config->dmic.num_pdm_active); in sof_link_dmic_load()
1496 dev_dbg(scomp->dev, "fifo word length %d\n", config->dmic.fifo_bits); in sof_link_dmic_load()
1498 for (i = 0; i < config->dmic.num_pdm_active; i++) { in sof_link_dmic_load()
1499 dev_dbg(scomp->dev, "pdm %d mic a %d mic b %d\n", in sof_link_dmic_load()
1500 config->dmic.pdm[i].id, in sof_link_dmic_load()
1501 config->dmic.pdm[i].enable_mic_a, in sof_link_dmic_load()
1502 config->dmic.pdm[i].enable_mic_b); in sof_link_dmic_load()
1503 dev_dbg(scomp->dev, "pdm %d polarity a %d polarity b %d\n", in sof_link_dmic_load()
1504 config->dmic.pdm[i].id, in sof_link_dmic_load()
1505 config->dmic.pdm[i].polarity_mic_a, in sof_link_dmic_load()
1506 config->dmic.pdm[i].polarity_mic_b); in sof_link_dmic_load()
1507 dev_dbg(scomp->dev, "pdm %d clk_edge %d skew %d\n", in sof_link_dmic_load()
1508 config->dmic.pdm[i].id, in sof_link_dmic_load()
1509 config->dmic.pdm[i].clk_edge, in sof_link_dmic_load()
1510 config->dmic.pdm[i].skew); in sof_link_dmic_load()
1517 if (SOF_ABI_VER(v->major, v->minor, v->micro) < SOF_ABI_VER(3, 0, 1)) in sof_link_dmic_load()
1518 config->dmic.fifo_bits_b = config->dmic.fifo_bits; in sof_link_dmic_load()
1520 dai->number_configs = 1; in sof_link_dmic_load()
1521 dai->current_config = 0; in sof_link_dmic_load()
1522 private->dai_config = kmemdup(config, size, GFP_KERNEL); in sof_link_dmic_load()
1523 if (!private->dai_config) in sof_link_dmic_load()
1524 return -ENOMEM; in sof_link_dmic_load()
1532 struct sof_dai_private_data *private = dai->private; in sof_link_alh_load()
1537 ret = sof_update_ipc_object(scomp, &config->alh, SOF_ALH_TOKENS, slink->tuples, in sof_link_alh_load()
1538 slink->num_tuples, size, slink->num_hw_configs); in sof_link_alh_load()
1543 config->hdr.size = size; in sof_link_alh_load()
1546 dai->number_configs = 1; in sof_link_alh_load()
1547 dai->current_config = 0; in sof_link_alh_load()
1548 private->dai_config = kmemdup(config, size, GFP_KERNEL); in sof_link_alh_load()
1549 if (!private->dai_config) in sof_link_alh_load()
1550 return -ENOMEM; in sof_link_alh_load()
1557 struct snd_soc_component *scomp = swidget->scomp; in sof_ipc3_widget_setup_comp_dai()
1559 struct snd_sof_dai *dai = swidget->private; in sof_ipc3_widget_setup_comp_dai()
1569 return -ENOMEM; in sof_ipc3_widget_setup_comp_dai()
1571 dai->private = private; in sof_ipc3_widget_setup_comp_dai()
1573 private->comp_dai = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id); in sof_ipc3_widget_setup_comp_dai()
1574 if (!private->comp_dai) { in sof_ipc3_widget_setup_comp_dai()
1575 ret = -ENOMEM; in sof_ipc3_widget_setup_comp_dai()
1580 comp_dai = private->comp_dai; in sof_ipc3_widget_setup_comp_dai()
1581 comp_dai->comp.type = SOF_COMP_DAI; in sof_ipc3_widget_setup_comp_dai()
1582 comp_dai->config.hdr.size = sizeof(comp_dai->config); in sof_ipc3_widget_setup_comp_dai()
1585 ret = sof_update_ipc_object(scomp, comp_dai, SOF_DAI_TOKENS, swidget->tuples, in sof_ipc3_widget_setup_comp_dai()
1586 swidget->num_tuples, sizeof(*comp_dai), 1); in sof_ipc3_widget_setup_comp_dai()
1591 ret = sof_update_ipc_object(scomp, &comp_dai->config, SOF_COMP_TOKENS, in sof_ipc3_widget_setup_comp_dai()
1592 swidget->tuples, swidget->num_tuples, in sof_ipc3_widget_setup_comp_dai()
1593 sizeof(comp_dai->config), 1); in sof_ipc3_widget_setup_comp_dai()
1597 dev_dbg(scomp->dev, "dai %s: type %d index %d\n", in sof_ipc3_widget_setup_comp_dai()
1598 swidget->widget->name, comp_dai->type, comp_dai->dai_index); in sof_ipc3_widget_setup_comp_dai()
1599 sof_dbg_comp_config(scomp, &comp_dai->config); in sof_ipc3_widget_setup_comp_dai()
1602 list_for_each_entry(slink, &sdev->dai_link_list, list) { in sof_ipc3_widget_setup_comp_dai()
1606 if (strcmp(slink->link->name, dai->name)) in sof_ipc3_widget_setup_comp_dai()
1610 config = kcalloc(slink->num_hw_configs, sizeof(*config), GFP_KERNEL); in sof_ipc3_widget_setup_comp_dai()
1612 ret = -ENOMEM; in sof_ipc3_widget_setup_comp_dai()
1618 slink->tuples, slink->num_tuples, in sof_ipc3_widget_setup_comp_dai()
1623 for (i = 0; i < slink->num_hw_configs; i++) { in sof_ipc3_widget_setup_comp_dai()
1625 config[i].format = le32_to_cpu(slink->hw_configs[i].fmt); in sof_ipc3_widget_setup_comp_dai()
1627 config[i].dai_index = comp_dai->dai_index; in sof_ipc3_widget_setup_comp_dai()
1676 dev_err(scomp->dev, "failed to load config for dai %s\n", dai->name); in sof_ipc3_widget_setup_comp_dai()
1690 dai->private = NULL; in sof_ipc3_widget_setup_comp_dai()
1696 switch (swidget->id) { in sof_ipc3_widget_free_comp_dai()
1700 struct snd_sof_dai *dai = swidget->private; in sof_ipc3_widget_free_comp_dai()
1706 dai_data = dai->private; in sof_ipc3_widget_free_comp_dai()
1708 kfree(dai_data->comp_dai); in sof_ipc3_widget_free_comp_dai()
1709 kfree(dai_data->dai_config); in sof_ipc3_widget_free_comp_dai()
1727 connect.source_id = sroute->src_widget->comp_id; in sof_ipc3_route_setup()
1728 connect.sink_id = sroute->sink_widget->comp_id; in sof_ipc3_route_setup()
1730 dev_dbg(sdev->dev, "setting up route %s -> %s\n", in sof_ipc3_route_setup()
1731 sroute->src_widget->widget->name, in sof_ipc3_route_setup()
1732 sroute->sink_widget->widget->name); in sof_ipc3_route_setup()
1735 ret = sof_ipc_tx_message_no_reply(sdev->ipc, &connect, sizeof(connect)); in sof_ipc3_route_setup()
1737 dev_err(sdev->dev, "%s: route %s -> %s failed\n", __func__, in sof_ipc3_route_setup()
1738 sroute->src_widget->widget->name, sroute->sink_widget->widget->name); in sof_ipc3_route_setup()
1749 if (scontrol->max_size < (sizeof(*cdata) + sizeof(struct sof_abi_hdr))) { in sof_ipc3_control_load_bytes()
1750 dev_err(sdev->dev, "%s: insufficient size for a bytes control: %zu.\n", in sof_ipc3_control_load_bytes()
1751 __func__, scontrol->max_size); in sof_ipc3_control_load_bytes()
1752 return -EINVAL; in sof_ipc3_control_load_bytes()
1755 if (scontrol->priv_size > scontrol->max_size - sizeof(*cdata)) { in sof_ipc3_control_load_bytes()
1756 dev_err(sdev->dev, in sof_ipc3_control_load_bytes()
1758 scontrol->priv_size, scontrol->max_size - sizeof(*cdata)); in sof_ipc3_control_load_bytes()
1759 return -EINVAL; in sof_ipc3_control_load_bytes()
1762 scontrol->ipc_control_data = kzalloc(scontrol->max_size, GFP_KERNEL); in sof_ipc3_control_load_bytes()
1763 if (!scontrol->ipc_control_data) in sof_ipc3_control_load_bytes()
1764 return -ENOMEM; in sof_ipc3_control_load_bytes()
1766 scontrol->size = sizeof(struct sof_ipc_ctrl_data) + scontrol->priv_size; in sof_ipc3_control_load_bytes()
1768 cdata = scontrol->ipc_control_data; in sof_ipc3_control_load_bytes()
1769 cdata->cmd = SOF_CTRL_CMD_BINARY; in sof_ipc3_control_load_bytes()
1770 cdata->index = scontrol->index; in sof_ipc3_control_load_bytes()
1772 if (scontrol->priv_size > 0) { in sof_ipc3_control_load_bytes()
1773 memcpy(cdata->data, scontrol->priv, scontrol->priv_size); in sof_ipc3_control_load_bytes()
1774 kfree(scontrol->priv); in sof_ipc3_control_load_bytes()
1775 scontrol->priv = NULL; in sof_ipc3_control_load_bytes()
1777 if (cdata->data->magic != SOF_ABI_MAGIC) { in sof_ipc3_control_load_bytes()
1778 dev_err(sdev->dev, "Wrong ABI magic 0x%08x.\n", cdata->data->magic); in sof_ipc3_control_load_bytes()
1779 ret = -EINVAL; in sof_ipc3_control_load_bytes()
1783 if (SOF_ABI_VERSION_INCOMPATIBLE(SOF_ABI_VERSION, cdata->data->abi)) { in sof_ipc3_control_load_bytes()
1784 dev_err(sdev->dev, "Incompatible ABI version 0x%08x.\n", in sof_ipc3_control_load_bytes()
1785 cdata->data->abi); in sof_ipc3_control_load_bytes()
1786 ret = -EINVAL; in sof_ipc3_control_load_bytes()
1790 priv_size_check = cdata->data->size + sizeof(struct sof_abi_hdr); in sof_ipc3_control_load_bytes()
1791 if (priv_size_check != scontrol->priv_size) { in sof_ipc3_control_load_bytes()
1792 dev_err(sdev->dev, "Conflict in bytes (%zu) vs. priv size (%zu).\n", in sof_ipc3_control_load_bytes()
1793 priv_size_check, scontrol->priv_size); in sof_ipc3_control_load_bytes()
1794 ret = -EINVAL; in sof_ipc3_control_load_bytes()
1801 kfree(scontrol->ipc_control_data); in sof_ipc3_control_load_bytes()
1802 scontrol->ipc_control_data = NULL; in sof_ipc3_control_load_bytes()
1812 scontrol->size = struct_size(cdata, chanv, scontrol->num_channels); in sof_ipc3_control_load_volume()
1814 scontrol->ipc_control_data = kzalloc(scontrol->size, GFP_KERNEL); in sof_ipc3_control_load_volume()
1815 if (!scontrol->ipc_control_data) in sof_ipc3_control_load_volume()
1816 return -ENOMEM; in sof_ipc3_control_load_volume()
1818 cdata = scontrol->ipc_control_data; in sof_ipc3_control_load_volume()
1819 cdata->index = scontrol->index; in sof_ipc3_control_load_volume()
1822 if (scontrol->max == 1) { in sof_ipc3_control_load_volume()
1823 cdata->cmd = SOF_CTRL_CMD_SWITCH; in sof_ipc3_control_load_volume()
1827 cdata->cmd = SOF_CTRL_CMD_VOLUME; in sof_ipc3_control_load_volume()
1830 for (i = 0; i < scontrol->num_channels; i++) { in sof_ipc3_control_load_volume()
1831 cdata->chanv[i].channel = i; in sof_ipc3_control_load_volume()
1832 cdata->chanv[i].value = VOL_ZERO_DB; in sof_ipc3_control_load_volume()
1843 scontrol->size = struct_size(cdata, chanv, scontrol->num_channels); in sof_ipc3_control_load_enum()
1845 scontrol->ipc_control_data = kzalloc(scontrol->size, GFP_KERNEL); in sof_ipc3_control_load_enum()
1846 if (!scontrol->ipc_control_data) in sof_ipc3_control_load_enum()
1847 return -ENOMEM; in sof_ipc3_control_load_enum()
1849 cdata = scontrol->ipc_control_data; in sof_ipc3_control_load_enum()
1850 cdata->index = scontrol->index; in sof_ipc3_control_load_enum()
1851 cdata->cmd = SOF_CTRL_CMD_ENUM; in sof_ipc3_control_load_enum()
1858 switch (scontrol->info_type) { in sof_ipc3_control_setup()
1881 fcomp.id = scontrol->comp_id; in sof_ipc3_control_free()
1884 return sof_ipc_tx_message_no_reply(sdev->ipc, &fcomp, sizeof(fcomp)); in sof_ipc3_control_free()
1890 struct snd_soc_component *scomp = swidget->scomp; in sof_ipc3_keyword_detect_pcm_params()
1898 spcm = snd_sof_find_spcm_name(scomp, swidget->widget->sname); in sof_ipc3_keyword_detect_pcm_params()
1900 dev_err(scomp->dev, "Cannot find PCM for %s\n", swidget->widget->name); in sof_ipc3_keyword_detect_pcm_params()
1901 return -EINVAL; in sof_ipc3_keyword_detect_pcm_params()
1904 params = &spcm->params[dir]; in sof_ipc3_keyword_detect_pcm_params()
1910 pcm.comp_id = swidget->comp_id; in sof_ipc3_keyword_detect_pcm_params()
1931 return -EINVAL; in sof_ipc3_keyword_detect_pcm_params()
1935 ret = sof_ipc_tx_message_no_reply(sdev->ipc, &pcm, sizeof(pcm)); in sof_ipc3_keyword_detect_pcm_params()
1937 dev_err(scomp->dev, "%s: PCM params failed for %s\n", __func__, in sof_ipc3_keyword_detect_pcm_params()
1938 swidget->widget->name); in sof_ipc3_keyword_detect_pcm_params()
1946 struct snd_soc_component *scomp = swidget->scomp; in sof_ipc3_keyword_detect_trigger()
1954 stream.comp_id = swidget->comp_id; in sof_ipc3_keyword_detect_trigger()
1957 ret = sof_ipc_tx_message_no_reply(sdev->ipc, &stream, sizeof(stream)); in sof_ipc3_keyword_detect_trigger()
1959 dev_err(scomp->dev, "%s: Failed to trigger %s\n", __func__, swidget->widget->name); in sof_ipc3_keyword_detect_trigger()
1967 struct snd_sof_widget *swidget = w->dobj.private; in sof_ipc3_keyword_dapm_event()
1976 scomp = swidget->scomp; in sof_ipc3_keyword_dapm_event()
1978 dev_dbg(scomp->dev, "received event %d for widget %s\n", in sof_ipc3_keyword_dapm_event()
1979 event, w->name); in sof_ipc3_keyword_dapm_event()
1982 spcm = snd_sof_find_spcm_name(scomp, swidget->widget->sname); in sof_ipc3_keyword_dapm_event()
1984 dev_err(scomp->dev, "%s: Cannot find PCM for %s\n", __func__, in sof_ipc3_keyword_dapm_event()
1985 swidget->widget->name); in sof_ipc3_keyword_dapm_event()
1986 return -EINVAL; in sof_ipc3_keyword_dapm_event()
1992 if (spcm->stream[stream].suspend_ignored) { in sof_ipc3_keyword_dapm_event()
1993 dev_dbg(scomp->dev, "PRE_PMU event ignored, KWD pipeline is already RUNNING\n"); in sof_ipc3_keyword_dapm_event()
2000 dev_err(scomp->dev, "%s: Failed to set pcm params for widget %s\n", in sof_ipc3_keyword_dapm_event()
2001 __func__, swidget->widget->name); in sof_ipc3_keyword_dapm_event()
2008 dev_err(scomp->dev, "%s: Failed to trigger widget %s\n", __func__, in sof_ipc3_keyword_dapm_event()
2009 swidget->widget->name); in sof_ipc3_keyword_dapm_event()
2012 if (spcm->stream[stream].suspend_ignored) { in sof_ipc3_keyword_dapm_event()
2013 dev_dbg(scomp->dev, in sof_ipc3_keyword_dapm_event()
2021 dev_err(scomp->dev, "%s: Failed to trigger widget %s\n", __func__, in sof_ipc3_keyword_dapm_event()
2022 swidget->widget->name); in sof_ipc3_keyword_dapm_event()
2027 dev_err(scomp->dev, "%s: Failed to free PCM for widget %s\n", __func__, in sof_ipc3_keyword_dapm_event()
2028 swidget->widget->name); in sof_ipc3_keyword_dapm_event()
2051 if (swidget->id != snd_soc_dapm_effect) in sof_ipc3_widget_bind_event()
2054 ipc_comp = swidget->private; in sof_ipc3_widget_bind_event()
2055 if (ipc_comp && ipc_comp->type != SOF_COMP_KEYWORD_DETECT) in sof_ipc3_widget_bind_event()
2059 return snd_soc_tplg_widget_bind_event(swidget->widget, sof_kwd_events, in sof_ipc3_widget_bind_event()
2065 dev_err(scomp->dev, "Invalid event type %d for widget %s\n", event_type, in sof_ipc3_widget_bind_event()
2066 swidget->widget->name); in sof_ipc3_widget_bind_event()
2068 return -EINVAL; in sof_ipc3_widget_bind_event()
2076 dev_dbg(sdev->dev, "tplg: complete pipeline %s id %d\n", in sof_ipc3_complete_pipeline()
2077 swidget->widget->name, swidget->comp_id); in sof_ipc3_complete_pipeline()
2082 ready.comp_id = swidget->comp_id; in sof_ipc3_complete_pipeline()
2084 ret = sof_ipc_tx_message_no_reply(sdev->ipc, &ready, sizeof(ready)); in sof_ipc3_complete_pipeline()
2098 .id = swidget->comp_id, in sof_ipc3_widget_free()
2102 if (!swidget->private) in sof_ipc3_widget_free()
2105 switch (swidget->id) { in sof_ipc3_widget_free()
2119 ret = sof_ipc_tx_message_no_reply(sdev->ipc, &ipc_free, sizeof(ipc_free)); in sof_ipc3_widget_free()
2121 dev_err(sdev->dev, "failed to free widget %s\n", swidget->widget->name); in sof_ipc3_widget_free()
2129 struct sof_ipc_fw_version *v = &sdev->fw_ready.version; in sof_ipc3_dai_config()
2130 struct snd_sof_dai *dai = swidget->private; in sof_ipc3_dai_config()
2135 if (!dai || !dai->private) { in sof_ipc3_dai_config()
2136 dev_err(sdev->dev, "No private data for DAI %s\n", swidget->widget->name); in sof_ipc3_dai_config()
2137 return -EINVAL; in sof_ipc3_dai_config()
2140 private = dai->private; in sof_ipc3_dai_config()
2141 if (!private->dai_config) { in sof_ipc3_dai_config()
2142 dev_err(sdev->dev, "No config for DAI %s\n", dai->name); in sof_ipc3_dai_config()
2143 return -EINVAL; in sof_ipc3_dai_config()
2146 config = &private->dai_config[dai->current_config]; in sof_ipc3_dai_config()
2148 dev_err(sdev->dev, "Invalid current config for DAI %s\n", dai->name); in sof_ipc3_dai_config()
2149 return -EINVAL; in sof_ipc3_dai_config()
2152 switch (config->type) { in sof_ipc3_dai_config()
2158 if (v->abi_version < SOF_ABI_VER(3, 18, 0) && in sof_ipc3_dai_config()
2165 config->hda.link_dma_ch = data->dai_data; in sof_ipc3_dai_config()
2171 config->dai_index = data->dai_index; in sof_ipc3_dai_config()
2172 config->alh.stream_id = data->dai_data; in sof_ipc3_dai_config()
2201 config->flags &= ~SOF_DAI_CONFIG_FLAGS_CMD_MASK; in sof_ipc3_dai_config()
2202 config->flags |= flags; in sof_ipc3_dai_config()
2204 config->flags = flags; in sof_ipc3_dai_config()
2208 if (swidget->use_count > 0) { in sof_ipc3_dai_config()
2209 ret = sof_ipc_tx_message_no_reply(sdev->ipc, config, config->hdr.size); in sof_ipc3_dai_config()
2211 dev_err(sdev->dev, "Failed to set dai config for %s\n", dai->name); in sof_ipc3_dai_config()
2214 config->flags = SOF_DAI_CONFIG_FLAGS_NONE; in sof_ipc3_dai_config()
2224 if (!swidget->private) in sof_ipc3_widget_setup()
2227 switch (swidget->id) { in sof_ipc3_widget_setup()
2231 struct snd_sof_dai *dai = swidget->private; in sof_ipc3_widget_setup()
2232 struct sof_dai_private_data *dai_data = dai->private; in sof_ipc3_widget_setup()
2233 struct sof_ipc_comp *comp = &dai_data->comp_dai->comp; in sof_ipc3_widget_setup()
2235 ret = sof_ipc_tx_message_no_reply(sdev->ipc, dai_data->comp_dai, comp->hdr.size); in sof_ipc3_widget_setup()
2242 pipeline = swidget->private; in sof_ipc3_widget_setup()
2243 ret = sof_ipc_tx_message_no_reply(sdev->ipc, pipeline, sizeof(*pipeline)); in sof_ipc3_widget_setup()
2250 hdr = swidget->private; in sof_ipc3_widget_setup()
2251 ret = sof_ipc_tx_message_no_reply(sdev->ipc, swidget->private, hdr->size); in sof_ipc3_widget_setup()
2256 dev_err(sdev->dev, "Failed to setup widget %s\n", swidget->widget->name); in sof_ipc3_widget_setup()
2263 struct sof_ipc_fw_version *v = &sdev->fw_ready.version; in sof_ipc3_set_up_all_pipelines()
2269 list_for_each_entry(swidget, &sdev->widget_list, list) { in sof_ipc3_set_up_all_pipelines()
2271 if (!verify && swidget->dynamic_pipeline_widget) in sof_ipc3_set_up_all_pipelines()
2278 if (v->abi_version < SOF_ABI_VER(3, 19, 0) && in sof_ipc3_set_up_all_pipelines()
2279 swidget->id == snd_soc_dapm_scheduler) in sof_ipc3_set_up_all_pipelines()
2283 if (WIDGET_IS_DAI(swidget->id)) { in sof_ipc3_set_up_all_pipelines()
2284 struct snd_sof_dai *dai = swidget->private; in sof_ipc3_set_up_all_pipelines()
2288 if (!dai || !dai->private) in sof_ipc3_set_up_all_pipelines()
2290 private = dai->private; in sof_ipc3_set_up_all_pipelines()
2291 if (!private->dai_config) in sof_ipc3_set_up_all_pipelines()
2294 config = private->dai_config; in sof_ipc3_set_up_all_pipelines()
2301 if (config->type == SOF_DAI_INTEL_HDA) in sof_ipc3_set_up_all_pipelines()
2302 config->hda.link_dma_ch = DMA_CHAN_INVALID; in sof_ipc3_set_up_all_pipelines()
2311 list_for_each_entry(sroute, &sdev->route_list, list) { in sof_ipc3_set_up_all_pipelines()
2313 if (!verify && (sroute->src_widget->dynamic_pipeline_widget || in sof_ipc3_set_up_all_pipelines()
2314 sroute->sink_widget->dynamic_pipeline_widget)) in sof_ipc3_set_up_all_pipelines()
2321 if (sroute->src_widget->id != snd_soc_dapm_buffer && in sof_ipc3_set_up_all_pipelines()
2322 sroute->sink_widget->id != snd_soc_dapm_buffer) in sof_ipc3_set_up_all_pipelines()
2325 ret = sof_route_setup(sdev, sroute->src_widget->widget, in sof_ipc3_set_up_all_pipelines()
2326 sroute->sink_widget->widget); in sof_ipc3_set_up_all_pipelines()
2328 dev_err(sdev->dev, "%s: route set up failed\n", __func__); in sof_ipc3_set_up_all_pipelines()
2334 list_for_each_entry(swidget, &sdev->widget_list, list) { in sof_ipc3_set_up_all_pipelines()
2335 switch (swidget->id) { in sof_ipc3_set_up_all_pipelines()
2338 if (!verify && swidget->dynamic_pipeline_widget) in sof_ipc3_set_up_all_pipelines()
2341 if (v->abi_version < SOF_ABI_VER(3, 19, 0)) { in sof_ipc3_set_up_all_pipelines()
2347 swidget->spipe->complete = sof_ipc3_complete_pipeline(sdev, swidget); in sof_ipc3_set_up_all_pipelines()
2348 if (swidget->spipe->complete < 0) in sof_ipc3_set_up_all_pipelines()
2349 return swidget->spipe->complete; in sof_ipc3_set_up_all_pipelines()
2374 list_for_each_entry(spcm, &sdev->pcm_list, list) { in sof_tear_down_left_over_pipelines()
2376 struct snd_pcm_substream *substream = spcm->stream[dir].substream; in sof_tear_down_left_over_pipelines()
2378 if (!substream || !substream->runtime || spcm->stream[dir].suspend_ignored) in sof_tear_down_left_over_pipelines()
2381 if (spcm->stream[dir].list) { in sof_tear_down_left_over_pipelines()
2393 list_for_each_entry(swidget, &sdev->widget_list, list) in sof_tear_down_left_over_pipelines()
2394 if (WIDGET_IS_DAI(swidget->id) && swidget->use_count == 1) { in sof_tear_down_left_over_pipelines()
2406 struct sof_ipc_fw_version *v = &sdev->fw_ready.version; in sof_ipc3_free_widgets_in_list()
2410 list_for_each_entry(swidget, &sdev->widget_list, list) { in sof_ipc3_free_widgets_in_list()
2411 if (swidget->dynamic_pipeline_widget) { in sof_ipc3_free_widgets_in_list()
2417 if (!verify && !swidget->dynamic_pipeline_widget && in sof_ipc3_free_widgets_in_list()
2418 SOF_FW_VER(v->major, v->minor, v->micro) < SOF_FW_VER(2, 2, 0)) { in sof_ipc3_free_widgets_in_list()
2419 mutex_lock(&swidget->setup_mutex); in sof_ipc3_free_widgets_in_list()
2420 swidget->use_count = 0; in sof_ipc3_free_widgets_in_list()
2421 mutex_unlock(&swidget->setup_mutex); in sof_ipc3_free_widgets_in_list()
2422 if (swidget->spipe) in sof_ipc3_free_widgets_in_list()
2423 swidget->spipe->complete = 0; in sof_ipc3_free_widgets_in_list()
2427 if (include_scheduler && swidget->id != snd_soc_dapm_scheduler) in sof_ipc3_free_widgets_in_list()
2430 if (!include_scheduler && swidget->id == snd_soc_dapm_scheduler) in sof_ipc3_free_widgets_in_list()
2447 struct sof_ipc_fw_version *v = &sdev->fw_ready.version; in sof_ipc3_tear_down_all_pipelines()
2454 * This function is called during suspend and for one-time topology verification during in sof_ipc3_tear_down_all_pipelines()
2455 * first boot. In both cases, there is no need to protect swidget->use_count and in sof_ipc3_tear_down_all_pipelines()
2456 * sroute->setup because during suspend all running streams are suspended and during in sof_ipc3_tear_down_all_pipelines()
2476 if (!verify && (dyn_widgets || SOF_FW_VER(v->major, v->minor, v->micro) >= in sof_ipc3_tear_down_all_pipelines()
2480 dev_err(sdev->dev, "failed to tear down paused pipelines\n"); in sof_ipc3_tear_down_all_pipelines()
2485 list_for_each_entry(sroute, &sdev->route_list, list) in sof_ipc3_tear_down_all_pipelines()
2486 sroute->setup = false; in sof_ipc3_tear_down_all_pipelines()
2493 list_for_each_entry(swidget, &sdev->widget_list, list) { in sof_ipc3_tear_down_all_pipelines()
2494 if (swidget->use_count != 0) { in sof_ipc3_tear_down_all_pipelines()
2495 dev_err(sdev->dev, "%s: widget %s is still in use: count %d\n", in sof_ipc3_tear_down_all_pipelines()
2496 __func__, swidget->widget->name, swidget->use_count); in sof_ipc3_tear_down_all_pipelines()
2505 struct sof_dai_private_data *private = dai->private; in sof_ipc3_dai_get_param()
2507 if (!private || !private->dai_config) in sof_ipc3_dai_get_param()
2510 switch (private->dai_config->type) { in sof_ipc3_dai_get_param()
2514 return private->dai_config->ssp.mclk_rate; in sof_ipc3_dai_get_param()
2516 return private->dai_config->ssp.bclk_rate; in sof_ipc3_dai_get_param()
2518 return private->dai_config->ssp.tdm_slots; in sof_ipc3_dai_get_param()
2520 dev_err(sdev->dev, "invalid SSP param %d\n", param_type); in sof_ipc3_dai_get_param()
2526 dev_err(sdev->dev, "DAI type %d not supported yet!\n", private->dai_config->type); in sof_ipc3_dai_get_param()
2530 return -EINVAL; in sof_ipc3_dai_get_param()
2536 u32 size = le32_to_cpu(man->priv.size); in sof_ipc3_parse_manifest()
2541 dev_dbg(scomp->dev, "No topology ABI info\n"); in sof_ipc3_parse_manifest()
2546 dev_err(scomp->dev, "%s: Invalid topology ABI size: %u\n", in sof_ipc3_parse_manifest()
2548 return -EINVAL; in sof_ipc3_parse_manifest()
2551 dev_info(scomp->dev, in sof_ipc3_parse_manifest()
2553 man->priv.data[0], man->priv.data[1], man->priv.data[2], in sof_ipc3_parse_manifest()
2556 abi_version = SOF_ABI_VER(man->priv.data[0], man->priv.data[1], man->priv.data[2]); in sof_ipc3_parse_manifest()
2559 dev_err(scomp->dev, "%s: Incompatible topology ABI version\n", __func__); in sof_ipc3_parse_manifest()
2560 return -EINVAL; in sof_ipc3_parse_manifest()
2565 dev_err(scomp->dev, "%s: Topology ABI is more recent than kernel\n", __func__); in sof_ipc3_parse_manifest()
2566 return -EINVAL; in sof_ipc3_parse_manifest()
2574 if (link->no_pcm) in sof_ipc3_link_setup()
2584 link->trigger[SNDRV_PCM_STREAM_PLAYBACK] = SND_SOC_DPCM_TRIGGER_PRE; in sof_ipc3_link_setup()
2585 link->trigger[SNDRV_PCM_STREAM_CAPTURE] = SND_SOC_DPCM_TRIGGER_POST; in sof_ipc3_link_setup()