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) 2018 Intel Corporation. All rights reserved.
8 // Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
11 #include <linux/module.h>
12 #include <sound/sof.h>
13 #include "sof-audio.h"
16 static struct snd_soc_card sof_nocodec_card
= {
17 .name
= "nocodec", /* the sof- prefix is added by the core */
18 .topology_shortname
= "sof-nocodec",
22 static int sof_nocodec_bes_setup(struct device
*dev
,
23 const struct snd_sof_dsp_ops
*ops
,
24 struct snd_soc_dai_link
*links
,
25 int link_num
, struct snd_soc_card
*card
,
26 int (*pcm_dai_link_fixup
)(struct snd_soc_pcm_runtime
*rtd
,
27 struct snd_pcm_hw_params
*params
))
29 struct snd_soc_dai_link_component
*dlc
;
32 if (!ops
|| !links
|| !card
)
35 /* set up BE dai_links */
36 for (i
= 0; i
< link_num
; i
++) {
37 dlc
= devm_kzalloc(dev
, 3 * sizeof(*dlc
), GFP_KERNEL
);
41 links
[i
].name
= devm_kasprintf(dev
, GFP_KERNEL
,
46 links
[i
].stream_name
= links
[i
].name
;
48 links
[i
].cpus
= &dlc
[0];
49 links
[i
].codecs
= &dlc
[1];
50 links
[i
].platforms
= &dlc
[2];
52 links
[i
].num_cpus
= 1;
53 links
[i
].num_codecs
= 1;
54 links
[i
].num_platforms
= 1;
58 links
[i
].cpus
->dai_name
= ops
->drv
[i
].name
;
59 links
[i
].platforms
->name
= dev_name(dev
);
60 links
[i
].codecs
->dai_name
= "snd-soc-dummy-dai";
61 links
[i
].codecs
->name
= "snd-soc-dummy";
62 if (ops
->drv
[i
].playback
.channels_min
)
63 links
[i
].dpcm_playback
= 1;
64 if (ops
->drv
[i
].capture
.channels_min
)
65 links
[i
].dpcm_capture
= 1;
67 links
[i
].be_hw_params_fixup
= pcm_dai_link_fixup
;
70 card
->dai_link
= links
;
71 card
->num_links
= link_num
;
76 int sof_nocodec_setup(struct device
*dev
, const struct snd_sof_dsp_ops
*ops
,
77 int (*pcm_dai_link_fixup
)(struct snd_soc_pcm_runtime
*rtd
,
78 struct snd_pcm_hw_params
*params
))
80 struct snd_soc_dai_link
*links
;
82 /* create dummy BE dai_links */
83 links
= devm_kzalloc(dev
, sizeof(struct snd_soc_dai_link
) *
84 ops
->num_drv
, GFP_KERNEL
);
88 return sof_nocodec_bes_setup(dev
, ops
, links
, ops
->num_drv
,
89 &sof_nocodec_card
, pcm_dai_link_fixup
);
91 EXPORT_SYMBOL(sof_nocodec_setup
);
93 static int sof_nocodec_probe(struct platform_device
*pdev
)
95 struct snd_soc_card
*card
= &sof_nocodec_card
;
97 card
->dev
= &pdev
->dev
;
98 card
->topology_shortname_created
= true;
100 return devm_snd_soc_register_card(&pdev
->dev
, card
);
103 static int sof_nocodec_remove(struct platform_device
*pdev
)
108 static struct platform_driver sof_nocodec_audio
= {
109 .probe
= sof_nocodec_probe
,
110 .remove
= sof_nocodec_remove
,
112 .name
= "sof-nocodec",
113 .pm
= &snd_soc_pm_ops
,
116 module_platform_driver(sof_nocodec_audio
)
118 MODULE_DESCRIPTION("ASoC sof nocodec");
119 MODULE_AUTHOR("Liam Girdwood");
120 MODULE_LICENSE("Dual BSD/GPL");
121 MODULE_ALIAS("platform:sof-nocodec");