1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
3 // This file is provided under a dual BSD/GPLv2 license. When using or
4 // redistributing this file, you may do so under either license.
6 // Copyright(c) 2019 Intel Corporation. All rights reserved.
8 // Author: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
11 #include <linux/bitfield.h>
12 #include "sof-audio.h"
15 static int sof_kcontrol_setup(struct snd_sof_dev *sdev, struct snd_sof_control *scontrol)
19 /* reset readback offset for scontrol */
20 scontrol->readback_offset = 0;
22 ret = snd_sof_ipc_set_get_comp_data(scontrol, true);
24 dev_err(sdev->dev, "error: failed kcontrol value set for widget: %d\n",
30 static int sof_widget_kcontrol_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
32 struct snd_sof_control *scontrol;
35 /* set up all controls for the widget */
36 list_for_each_entry(scontrol, &sdev->kcontrol_list, list)
37 if (scontrol->comp_id == swidget->comp_id) {
38 /* set kcontrol data in DSP */
39 ret = sof_kcontrol_setup(sdev, scontrol);
41 dev_err(sdev->dev, "error: fail to set up kcontrols for widget %s\n",
42 swidget->widget->name);
47 * Read back the data from the DSP for static widgets. This is particularly
48 * useful for binary kcontrols associated with static pipeline widgets to
49 * initialize the data size to match that in the DSP.
51 if (swidget->dynamic_pipeline_widget)
54 ret = snd_sof_ipc_set_get_comp_data(scontrol, false);
56 dev_warn(sdev->dev, "Failed kcontrol get for control in widget %s\n",
57 swidget->widget->name);
63 static void sof_reset_route_setup_status(struct snd_sof_dev *sdev, struct snd_sof_widget *widget)
65 struct snd_sof_route *sroute;
67 list_for_each_entry(sroute, &sdev->route_list, list)
68 if (sroute->src_widget == widget || sroute->sink_widget == widget)
69 sroute->setup = false;
72 int sof_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
74 const struct sof_ipc_tplg_ops *tplg_ops = sdev->ipc->ops->tplg;
78 if (!swidget->private)
81 /* only free when use_count is 0 */
82 if (--swidget->use_count)
85 /* continue to disable core even if IPC fails */
86 if (tplg_ops->widget_free)
87 err = tplg_ops->widget_free(sdev, swidget);
90 * disable widget core. continue to route setup status and complete flag
91 * even if this fails and return the appropriate error
93 ret = snd_sof_dsp_core_put(sdev, swidget->core);
95 dev_err(sdev->dev, "error: failed to disable target core: %d for widget %s\n",
96 swidget->core, swidget->widget->name);
101 /* reset route setup status for all routes that contain this widget */
102 sof_reset_route_setup_status(sdev, swidget);
103 swidget->complete = 0;
106 * free the scheduler widget (same as pipe_widget) associated with the current swidget.
107 * skip for static pipelines
109 if (swidget->dynamic_pipeline_widget && swidget->id != snd_soc_dapm_scheduler) {
110 ret = sof_widget_free(sdev, swidget->pipe_widget);
116 dev_dbg(sdev->dev, "widget %s freed\n", swidget->widget->name);
120 EXPORT_SYMBOL(sof_widget_free);
122 int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
124 const struct sof_ipc_tplg_ops *tplg_ops = sdev->ipc->ops->tplg;
127 /* skip if there is no private data */
128 if (!swidget->private)
131 /* widget already set up */
132 if (++swidget->use_count > 1)
136 * The scheduler widget for a pipeline is not part of the connected DAPM
137 * widget list and it needs to be set up before the widgets in the pipeline
138 * are set up. The use_count for the scheduler widget is incremented for every
139 * widget in a given pipeline to ensure that it is freed only after the last
140 * widget in the pipeline is freed. Skip setting up scheduler widget for static pipelines.
142 if (swidget->dynamic_pipeline_widget && swidget->id != snd_soc_dapm_scheduler) {
143 if (!swidget->pipe_widget) {
144 dev_err(sdev->dev, "No scheduler widget set for %s\n",
145 swidget->widget->name);
150 ret = sof_widget_setup(sdev, swidget->pipe_widget);
155 /* enable widget core */
156 ret = snd_sof_dsp_core_get(sdev, swidget->core);
158 dev_err(sdev->dev, "error: failed to enable target core for widget %s\n",
159 swidget->widget->name);
160 goto pipe_widget_free;
163 /* setup widget in the DSP */
164 if (tplg_ops->widget_setup) {
165 ret = tplg_ops->widget_setup(sdev, swidget);
170 /* send config for DAI components */
171 if (WIDGET_IS_DAI(swidget->id)) {
172 unsigned int flags = SOF_DAI_CONFIG_FLAGS_NONE;
174 if (tplg_ops->dai_config) {
175 ret = tplg_ops->dai_config(sdev, swidget, flags, NULL);
181 /* restore kcontrols for widget */
182 ret = sof_widget_kcontrol_setup(sdev, swidget);
184 dev_err(sdev->dev, "error: failed to restore kcontrols for widget %s\n",
185 swidget->widget->name);
189 dev_dbg(sdev->dev, "widget %s setup complete\n", swidget->widget->name);
194 /* widget use_count and core ref_count will both be decremented by sof_widget_free() */
195 sof_widget_free(sdev, swidget);
197 snd_sof_dsp_core_put(sdev, swidget->core);
199 if (swidget->id != snd_soc_dapm_scheduler)
200 sof_widget_free(sdev, swidget->pipe_widget);
202 swidget->use_count--;
205 EXPORT_SYMBOL(sof_widget_setup);
207 static int sof_route_setup(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget *wsource,
208 struct snd_soc_dapm_widget *wsink)
210 const struct sof_ipc_tplg_ops *ipc_tplg_ops = sdev->ipc->ops->tplg;
211 struct snd_sof_widget *src_widget = wsource->dobj.private;
212 struct snd_sof_widget *sink_widget = wsink->dobj.private;
213 struct snd_sof_route *sroute;
214 bool route_found = false;
217 /* ignore routes involving virtual widgets in topology */
218 switch (src_widget->id) {
219 case snd_soc_dapm_out_drv:
220 case snd_soc_dapm_output:
221 case snd_soc_dapm_input:
227 switch (sink_widget->id) {
228 case snd_soc_dapm_out_drv:
229 case snd_soc_dapm_output:
230 case snd_soc_dapm_input:
236 /* find route matching source and sink widgets */
237 list_for_each_entry(sroute, &sdev->route_list, list)
238 if (sroute->src_widget == src_widget && sroute->sink_widget == sink_widget) {
244 dev_err(sdev->dev, "error: cannot find SOF route for source %s -> %s sink\n",
245 wsource->name, wsink->name);
249 /* nothing to do if route is already set up */
253 ret = ipc_tplg_ops->route_setup(sdev, sroute);
257 sroute->setup = true;
261 static int sof_setup_pipeline_connections(struct snd_sof_dev *sdev,
262 struct snd_soc_dapm_widget_list *list, int dir)
264 struct snd_soc_dapm_widget *widget;
265 struct snd_soc_dapm_path *p;
270 * Set up connections between widgets in the sink/source paths based on direction.
271 * Some non-SOF widgets exist in topology either for compatibility or for the
272 * purpose of connecting a pipeline from a host to a DAI in order to receive the DAPM
273 * events. But they are not handled by the firmware. So ignore them.
275 if (dir == SNDRV_PCM_STREAM_PLAYBACK) {
276 for_each_dapm_widgets(list, i, widget) {
277 if (!widget->dobj.private)
280 snd_soc_dapm_widget_for_each_sink_path(widget, p)
281 if (p->sink->dobj.private) {
282 ret = sof_route_setup(sdev, widget, p->sink);
288 for_each_dapm_widgets(list, i, widget) {
289 if (!widget->dobj.private)
292 snd_soc_dapm_widget_for_each_source_path(widget, p)
293 if (p->source->dobj.private) {
294 ret = sof_route_setup(sdev, p->source, widget);
304 int sof_widget_list_setup(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm, int dir)
306 const struct sof_ipc_tplg_ops *ipc_tplg_ops = sdev->ipc->ops->tplg;
307 struct snd_soc_dapm_widget_list *list = spcm->stream[dir].list;
308 struct snd_soc_dapm_widget *widget;
309 int i, ret, num_widgets;
311 /* nothing to set up */
315 /* set up widgets in the list */
316 for_each_dapm_widgets(list, num_widgets, widget) {
317 struct snd_sof_widget *swidget = widget->dobj.private;
322 /* set up the widget */
323 ret = sof_widget_setup(sdev, swidget);
329 * error in setting pipeline connections will result in route status being reset for
330 * routes that were successfully set up when the widgets are freed.
332 ret = sof_setup_pipeline_connections(sdev, list, dir);
336 /* complete pipelines */
337 for_each_dapm_widgets(list, i, widget) {
338 struct snd_sof_widget *swidget = widget->dobj.private;
339 struct snd_sof_widget *pipe_widget;
344 pipe_widget = swidget->pipe_widget;
346 dev_err(sdev->dev, "error: no pipeline widget found for %s\n",
347 swidget->widget->name);
352 if (pipe_widget->complete)
355 if (ipc_tplg_ops->pipeline_complete) {
356 pipe_widget->complete = ipc_tplg_ops->pipeline_complete(sdev, pipe_widget);
357 if (pipe_widget->complete < 0) {
358 ret = pipe_widget->complete;
367 /* free all widgets that have been set up successfully */
368 for_each_dapm_widgets(list, i, widget) {
369 struct snd_sof_widget *swidget = widget->dobj.private;
377 sof_widget_free(sdev, swidget);
383 int sof_widget_list_free(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm, int dir)
385 struct snd_soc_dapm_widget_list *list = spcm->stream[dir].list;
386 struct snd_soc_dapm_widget *widget;
390 /* nothing to free */
395 * Free widgets in the list. This can fail but continue freeing other widgets to keep
396 * use_counts balanced.
398 for_each_dapm_widgets(list, i, widget) {
399 struct snd_sof_widget *swidget = widget->dobj.private;
405 * free widget and its pipe_widget. Either of these can fail, but free as many as
406 * possible before freeing the list and returning the error.
408 ret = sof_widget_free(sdev, swidget);
413 snd_soc_dapm_dai_free_widgets(&list);
414 spcm->stream[dir].list = NULL;
420 * helper to determine if there are only D0i3 compatible
423 bool snd_sof_dsp_only_d0i3_compatible_stream_active(struct snd_sof_dev *sdev)
425 struct snd_pcm_substream *substream;
426 struct snd_sof_pcm *spcm;
427 bool d0i3_compatible_active = false;
430 list_for_each_entry(spcm, &sdev->pcm_list, list) {
431 for_each_pcm_streams(dir) {
432 substream = spcm->stream[dir].substream;
433 if (!substream || !substream->runtime)
437 * substream->runtime being not NULL indicates
438 * that the stream is open. No need to check the
441 if (!spcm->stream[dir].d0i3_compatible)
444 d0i3_compatible_active = true;
448 return d0i3_compatible_active;
450 EXPORT_SYMBOL(snd_sof_dsp_only_d0i3_compatible_stream_active);
452 bool snd_sof_stream_suspend_ignored(struct snd_sof_dev *sdev)
454 struct snd_sof_pcm *spcm;
456 list_for_each_entry(spcm, &sdev->pcm_list, list) {
457 if (spcm->stream[SNDRV_PCM_STREAM_PLAYBACK].suspend_ignored ||
458 spcm->stream[SNDRV_PCM_STREAM_CAPTURE].suspend_ignored)
465 int sof_set_hw_params_upon_resume(struct device *dev)
467 struct snd_sof_dev *sdev = dev_get_drvdata(dev);
468 struct snd_pcm_substream *substream;
469 struct snd_sof_pcm *spcm;
470 snd_pcm_state_t state;
474 * SOF requires hw_params to be set-up internally upon resume.
475 * So, set the flag to indicate this for those streams that
476 * have been suspended.
478 list_for_each_entry(spcm, &sdev->pcm_list, list) {
479 for_each_pcm_streams(dir) {
481 * do not reset hw_params upon resume for streams that
482 * were kept running during suspend
484 if (spcm->stream[dir].suspend_ignored)
487 substream = spcm->stream[dir].substream;
488 if (!substream || !substream->runtime)
491 state = substream->runtime->status->state;
492 if (state == SNDRV_PCM_STATE_SUSPENDED)
493 spcm->prepared[dir] = false;
497 /* set internal flag for BE */
498 return snd_sof_dsp_hw_params_upon_resume(sdev);
501 int sof_set_up_pipelines(struct snd_sof_dev *sdev, bool verify)
503 const struct sof_ipc_tplg_ops *ipc_tplg_ops = sdev->ipc->ops->tplg;
504 struct sof_ipc_fw_version *v = &sdev->fw_ready.version;
505 struct snd_sof_widget *swidget;
506 struct snd_sof_route *sroute;
509 /* restore pipeline components */
510 list_for_each_entry(swidget, &sdev->widget_list, list) {
511 /* only set up the widgets belonging to static pipelines */
512 if (!verify && swidget->dynamic_pipeline_widget)
516 * For older firmware, skip scheduler widgets in this loop,
517 * sof_widget_setup() will be called in the 'complete pipeline' loop
519 if (v->abi_version < SOF_ABI_VER(3, 19, 0) &&
520 swidget->id == snd_soc_dapm_scheduler)
523 /* update DAI config. The IPC will be sent in sof_widget_setup() */
524 if (WIDGET_IS_DAI(swidget->id)) {
525 struct snd_sof_dai *dai = swidget->private;
526 struct sof_dai_private_data *private = dai->private;
527 struct sof_ipc_dai_config *config;
529 if (!dai || !private || !private->dai_config)
532 config = private->dai_config;
534 * The link DMA channel would be invalidated for running
535 * streams but not for streams that were in the PAUSED
536 * state during suspend. So invalidate it here before setting
537 * the dai config in the DSP.
539 if (config->type == SOF_DAI_INTEL_HDA)
540 config->hda.link_dma_ch = DMA_CHAN_INVALID;
543 ret = sof_widget_setup(sdev, swidget);
548 /* restore pipeline connections */
549 list_for_each_entry(sroute, &sdev->route_list, list) {
551 /* only set up routes belonging to static pipelines */
552 if (!verify && (sroute->src_widget->dynamic_pipeline_widget ||
553 sroute->sink_widget->dynamic_pipeline_widget))
556 ret = ipc_tplg_ops->route_setup(sdev, sroute);
558 dev_err(sdev->dev, "%s: restore pipeline connections failed\n", __func__);
563 /* complete pipeline */
564 list_for_each_entry(swidget, &sdev->widget_list, list) {
565 switch (swidget->id) {
566 case snd_soc_dapm_scheduler:
567 /* only complete static pipelines */
568 if (!verify && swidget->dynamic_pipeline_widget)
571 if (v->abi_version < SOF_ABI_VER(3, 19, 0)) {
572 ret = sof_widget_setup(sdev, swidget);
577 if (ipc_tplg_ops->pipeline_complete) {
578 swidget->complete = ipc_tplg_ops->pipeline_complete(sdev, swidget);
579 if (swidget->complete < 0)
580 return swidget->complete;
591 int sof_pcm_stream_free(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream,
592 struct snd_sof_pcm *spcm, int dir, bool free_widget_list)
596 /* Send PCM_FREE IPC to reset pipeline */
597 ret = sof_pcm_dsp_pcm_free(substream, sdev, spcm);
602 ret = snd_sof_pcm_platform_hw_free(sdev, substream);
606 /* free widget list */
607 if (free_widget_list) {
608 ret = sof_widget_list_free(sdev, spcm, dir);
610 dev_err(sdev->dev, "failed to free widgets during suspend\n");
617 * Free the PCM, its associated widgets and set the prepared flag to false for all PCMs that
618 * did not get suspended(ex: paused streams) so the widgets can be set up again during resume.
620 static int sof_tear_down_left_over_pipelines(struct snd_sof_dev *sdev)
622 struct snd_sof_widget *swidget;
623 struct snd_sof_pcm *spcm;
627 * free all PCMs and their associated DAPM widgets if their connected DAPM widget
628 * list is not NULL. This should only be true for paused streams at this point.
629 * This is equivalent to the handling of FE DAI suspend trigger for running streams.
631 list_for_each_entry(spcm, &sdev->pcm_list, list)
632 for_each_pcm_streams(dir) {
633 struct snd_pcm_substream *substream = spcm->stream[dir].substream;
635 if (!substream || !substream->runtime)
638 if (spcm->stream[dir].list) {
639 ret = sof_pcm_stream_free(sdev, substream, spcm, dir, true);
646 * free any left over DAI widgets. This is equivalent to the handling of suspend trigger
647 * for the BE DAI for running streams.
649 list_for_each_entry(swidget, &sdev->widget_list, list)
650 if (WIDGET_IS_DAI(swidget->id) && swidget->use_count == 1) {
651 ret = sof_widget_free(sdev, swidget);
660 * For older firmware, this function doesn't free widgets for static pipelines during suspend.
661 * It only resets use_count for all widgets.
663 int sof_tear_down_pipelines(struct snd_sof_dev *sdev, bool verify)
665 struct sof_ipc_fw_version *v = &sdev->fw_ready.version;
666 struct snd_sof_widget *swidget;
667 struct snd_sof_route *sroute;
671 * This function is called during suspend and for one-time topology verification during
672 * first boot. In both cases, there is no need to protect swidget->use_count and
673 * sroute->setup because during suspend all running streams are suspended and during
674 * topology loading the sound card unavailable to open PCMs.
676 list_for_each_entry(swidget, &sdev->widget_list, list) {
677 if (swidget->dynamic_pipeline_widget)
680 /* Do not free widgets for static pipelines with FW ABI older than 3.19 */
681 if (!verify && !swidget->dynamic_pipeline_widget &&
682 v->abi_version < SOF_ABI_VER(3, 19, 0)) {
683 swidget->use_count = 0;
684 swidget->complete = 0;
688 ret = sof_widget_free(sdev, swidget);
694 * Tear down all pipelines associated with PCMs that did not get suspended
695 * and unset the prepare flag so that they can be set up again during resume.
696 * Skip this step for older firmware.
698 if (!verify && v->abi_version >= SOF_ABI_VER(3, 19, 0)) {
699 ret = sof_tear_down_left_over_pipelines(sdev);
701 dev_err(sdev->dev, "failed to tear down paused pipelines\n");
706 list_for_each_entry(sroute, &sdev->route_list, list)
707 sroute->setup = false;
713 * Generic object lookup APIs.
716 struct snd_sof_pcm *snd_sof_find_spcm_name(struct snd_soc_component *scomp,
719 struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
720 struct snd_sof_pcm *spcm;
722 list_for_each_entry(spcm, &sdev->pcm_list, list) {
723 /* match with PCM dai name */
724 if (strcmp(spcm->pcm.dai_name, name) == 0)
727 /* match with playback caps name if set */
728 if (*spcm->pcm.caps[0].name &&
729 !strcmp(spcm->pcm.caps[0].name, name))
732 /* match with capture caps name if set */
733 if (*spcm->pcm.caps[1].name &&
734 !strcmp(spcm->pcm.caps[1].name, name))
741 struct snd_sof_pcm *snd_sof_find_spcm_comp(struct snd_soc_component *scomp,
742 unsigned int comp_id,
745 struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
746 struct snd_sof_pcm *spcm;
749 list_for_each_entry(spcm, &sdev->pcm_list, list) {
750 for_each_pcm_streams(dir) {
751 if (spcm->stream[dir].comp_id == comp_id) {
761 struct snd_sof_widget *snd_sof_find_swidget(struct snd_soc_component *scomp,
764 struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
765 struct snd_sof_widget *swidget;
767 list_for_each_entry(swidget, &sdev->widget_list, list) {
768 if (strcmp(name, swidget->widget->name) == 0)
775 /* find widget by stream name and direction */
776 struct snd_sof_widget *
777 snd_sof_find_swidget_sname(struct snd_soc_component *scomp,
778 const char *pcm_name, int dir)
780 struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
781 struct snd_sof_widget *swidget;
782 enum snd_soc_dapm_type type;
784 if (dir == SNDRV_PCM_STREAM_PLAYBACK)
785 type = snd_soc_dapm_aif_in;
787 type = snd_soc_dapm_aif_out;
789 list_for_each_entry(swidget, &sdev->widget_list, list) {
790 if (!strcmp(pcm_name, swidget->widget->sname) &&
798 struct snd_sof_dai *snd_sof_find_dai(struct snd_soc_component *scomp,
801 struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
802 struct snd_sof_dai *dai;
804 list_for_each_entry(dai, &sdev->dai_list, list) {
805 if (dai->name && (strcmp(name, dai->name) == 0))
812 #define SOF_DAI_CLK_INTEL_SSP_MCLK 0
813 #define SOF_DAI_CLK_INTEL_SSP_BCLK 1
815 static int sof_dai_get_clk(struct snd_soc_pcm_runtime *rtd, int clk_type)
817 struct snd_soc_component *component =
818 snd_soc_rtdcom_lookup(rtd, SOF_AUDIO_PCM_DRV_NAME);
819 struct snd_sof_dai *dai =
820 snd_sof_find_dai(component, (char *)rtd->dai_link->name);
821 struct sof_dai_private_data *private = dai->private;
823 /* use the tplg configured mclk if existed */
824 if (!dai || !private || !private->dai_config)
827 switch (private->dai_config->type) {
828 case SOF_DAI_INTEL_SSP:
830 case SOF_DAI_CLK_INTEL_SSP_MCLK:
831 return private->dai_config->ssp.mclk_rate;
832 case SOF_DAI_CLK_INTEL_SSP_BCLK:
833 return private->dai_config->ssp.bclk_rate;
835 dev_err(rtd->dev, "fail to get SSP clk %d rate\n",
841 /* not yet implemented for platforms other than the above */
842 dev_err(rtd->dev, "DAI type %d not supported yet!\n",
843 private->dai_config->type);
849 * Helper to get SSP MCLK from a pcm_runtime.
850 * Return 0 if not exist.
852 int sof_dai_get_mclk(struct snd_soc_pcm_runtime *rtd)
854 return sof_dai_get_clk(rtd, SOF_DAI_CLK_INTEL_SSP_MCLK);
856 EXPORT_SYMBOL(sof_dai_get_mclk);
859 * Helper to get SSP BCLK from a pcm_runtime.
860 * Return 0 if not exist.
862 int sof_dai_get_bclk(struct snd_soc_pcm_runtime *rtd)
864 return sof_dai_get_clk(rtd, SOF_DAI_CLK_INTEL_SSP_BCLK);
866 EXPORT_SYMBOL(sof_dai_get_bclk);
869 * SOF Driver enumeration.
871 int sof_machine_check(struct snd_sof_dev *sdev)
873 struct snd_sof_pdata *sof_pdata = sdev->pdata;
874 const struct sof_dev_desc *desc = sof_pdata->desc;
875 struct snd_soc_acpi_mach *mach;
877 if (!IS_ENABLED(CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE)) {
880 mach = snd_sof_machine_select(sdev);
882 sof_pdata->machine = mach;
883 snd_sof_set_mach_params(mach, sdev);
887 if (!IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC)) {
888 dev_err(sdev->dev, "error: no matching ASoC machine driver found - aborting probe\n");
892 dev_warn(sdev->dev, "Force to use nocodec mode\n");
895 /* select nocodec mode */
896 dev_warn(sdev->dev, "Using nocodec machine driver\n");
897 mach = devm_kzalloc(sdev->dev, sizeof(*mach), GFP_KERNEL);
901 mach->drv_name = "sof-nocodec";
902 sof_pdata->tplg_filename = desc->nocodec_tplg_filename;
904 sof_pdata->machine = mach;
905 snd_sof_set_mach_params(mach, sdev);
909 EXPORT_SYMBOL(sof_machine_check);
911 int sof_machine_register(struct snd_sof_dev *sdev, void *pdata)
913 struct snd_sof_pdata *plat_data = pdata;
914 const char *drv_name;
918 drv_name = plat_data->machine->drv_name;
919 mach = plat_data->machine;
920 size = sizeof(*plat_data->machine);
922 /* register machine driver, pass machine info as pdata */
923 plat_data->pdev_mach =
924 platform_device_register_data(sdev->dev, drv_name,
925 PLATFORM_DEVID_NONE, mach, size);
926 if (IS_ERR(plat_data->pdev_mach))
927 return PTR_ERR(plat_data->pdev_mach);
929 dev_dbg(sdev->dev, "created machine %s\n",
930 dev_name(&plat_data->pdev_mach->dev));
934 EXPORT_SYMBOL(sof_machine_register);
936 void sof_machine_unregister(struct snd_sof_dev *sdev, void *pdata)
938 struct snd_sof_pdata *plat_data = pdata;
940 if (!IS_ERR_OR_NULL(plat_data->pdev_mach))
941 platform_device_unregister(plat_data->pdev_mach);
943 EXPORT_SYMBOL(sof_machine_unregister);