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>
15 static struct snd_soc_card sof_nocodec_card
= {
16 .name
= "nocodec", /* the sof- prefix is added by the core */
20 static int sof_nocodec_bes_setup(struct device
*dev
,
21 const struct snd_sof_dsp_ops
*ops
,
22 struct snd_soc_dai_link
*links
,
23 int link_num
, struct snd_soc_card
*card
)
25 struct snd_soc_dai_link_component
*dlc
;
28 if (!ops
|| !links
|| !card
)
31 /* set up BE dai_links */
32 for (i
= 0; i
< link_num
; i
++) {
33 dlc
= devm_kzalloc(dev
, 3 * sizeof(*dlc
), GFP_KERNEL
);
37 links
[i
].name
= devm_kasprintf(dev
, GFP_KERNEL
,
42 links
[i
].cpus
= &dlc
[0];
43 links
[i
].codecs
= &dlc
[1];
44 links
[i
].platforms
= &dlc
[2];
46 links
[i
].num_cpus
= 1;
47 links
[i
].num_codecs
= 1;
48 links
[i
].num_platforms
= 1;
52 links
[i
].cpus
->dai_name
= ops
->drv
[i
].name
;
53 links
[i
].platforms
->name
= dev_name(dev
);
54 links
[i
].codecs
->dai_name
= "snd-soc-dummy-dai";
55 links
[i
].codecs
->name
= "snd-soc-dummy";
56 if (ops
->drv
[i
].playback
.channels_min
)
57 links
[i
].dpcm_playback
= 1;
58 if (ops
->drv
[i
].capture
.channels_min
)
59 links
[i
].dpcm_capture
= 1;
62 card
->dai_link
= links
;
63 card
->num_links
= link_num
;
68 int sof_nocodec_setup(struct device
*dev
,
69 const struct snd_sof_dsp_ops
*ops
)
71 struct snd_soc_dai_link
*links
;
73 /* create dummy BE dai_links */
74 links
= devm_kzalloc(dev
, sizeof(struct snd_soc_dai_link
) *
75 ops
->num_drv
, GFP_KERNEL
);
79 return sof_nocodec_bes_setup(dev
, ops
, links
, ops
->num_drv
,
82 EXPORT_SYMBOL(sof_nocodec_setup
);
84 static int sof_nocodec_probe(struct platform_device
*pdev
)
86 struct snd_soc_card
*card
= &sof_nocodec_card
;
88 card
->dev
= &pdev
->dev
;
90 return devm_snd_soc_register_card(&pdev
->dev
, card
);
93 static int sof_nocodec_remove(struct platform_device
*pdev
)
98 static struct platform_driver sof_nocodec_audio
= {
99 .probe
= sof_nocodec_probe
,
100 .remove
= sof_nocodec_remove
,
102 .name
= "sof-nocodec",
103 .pm
= &snd_soc_pm_ops
,
106 module_platform_driver(sof_nocodec_audio
)
108 MODULE_DESCRIPTION("ASoC sof nocodec");
109 MODULE_AUTHOR("Liam Girdwood");
110 MODULE_LICENSE("Dual BSD/GPL");
111 MODULE_ALIAS("platform:sof-nocodec");