~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/soc/sof/nocodec.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
  2 //
  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.
  5 //
  6 // Copyright(c) 2018 Intel Corporation
  7 //
  8 // Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
  9 //
 10 
 11 #include <linux/module.h>
 12 #include <sound/sof.h>
 13 #include "sof-audio.h"
 14 #include "sof-priv.h"
 15 
 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",
 19         .owner = THIS_MODULE
 20 };
 21 
 22 static int sof_nocodec_bes_setup(struct device *dev,
 23                                  struct snd_soc_dai_driver *drv,
 24                                  struct snd_soc_dai_link *links,
 25                                  int link_num, struct snd_soc_card *card)
 26 {
 27         struct snd_soc_dai_link_component *dlc;
 28         int i;
 29 
 30         if (!drv || !links || !card)
 31                 return -EINVAL;
 32 
 33         /* set up BE dai_links */
 34         for (i = 0; i < link_num; i++) {
 35                 dlc = devm_kcalloc(dev, 2, sizeof(*dlc), GFP_KERNEL);
 36                 if (!dlc)
 37                         return -ENOMEM;
 38 
 39                 links[i].name = devm_kasprintf(dev, GFP_KERNEL,
 40                                                "NoCodec-%d", i);
 41                 if (!links[i].name)
 42                         return -ENOMEM;
 43 
 44                 links[i].stream_name = links[i].name;
 45 
 46                 links[i].cpus = &dlc[0];
 47                 links[i].codecs = &snd_soc_dummy_dlc;
 48                 links[i].platforms = &dlc[1];
 49 
 50                 links[i].num_cpus = 1;
 51                 links[i].num_codecs = 1;
 52                 links[i].num_platforms = 1;
 53 
 54                 links[i].id = i;
 55                 links[i].no_pcm = 1;
 56                 links[i].cpus->dai_name = drv[i].name;
 57                 links[i].platforms->name = dev_name(dev->parent);
 58                 if (drv[i].playback.channels_min)
 59                         links[i].dpcm_playback = 1;
 60                 if (drv[i].capture.channels_min)
 61                         links[i].dpcm_capture = 1;
 62 
 63                 links[i].be_hw_params_fixup = sof_pcm_dai_link_fixup;
 64         }
 65 
 66         card->dai_link = links;
 67         card->num_links = link_num;
 68 
 69         return 0;
 70 }
 71 
 72 static int sof_nocodec_setup(struct device *dev,
 73                              u32 num_dai_drivers,
 74                              struct snd_soc_dai_driver *dai_drivers)
 75 {
 76         struct snd_soc_dai_link *links;
 77 
 78         /* create dummy BE dai_links */
 79         links = devm_kcalloc(dev, num_dai_drivers, sizeof(struct snd_soc_dai_link), GFP_KERNEL);
 80         if (!links)
 81                 return -ENOMEM;
 82 
 83         return sof_nocodec_bes_setup(dev, dai_drivers, links, num_dai_drivers, &sof_nocodec_card);
 84 }
 85 
 86 static int sof_nocodec_probe(struct platform_device *pdev)
 87 {
 88         struct snd_soc_card *card = &sof_nocodec_card;
 89         struct snd_soc_acpi_mach *mach;
 90         int ret;
 91 
 92         card->dev = &pdev->dev;
 93         card->topology_shortname_created = true;
 94         mach = pdev->dev.platform_data;
 95 
 96         ret = sof_nocodec_setup(card->dev, mach->mach_params.num_dai_drivers,
 97                                 mach->mach_params.dai_drivers);
 98         if (ret < 0)
 99                 return ret;
100 
101         return devm_snd_soc_register_card(&pdev->dev, card);
102 }
103 
104 static struct platform_driver sof_nocodec_audio = {
105         .probe = sof_nocodec_probe,
106         .driver = {
107                 .name = "sof-nocodec",
108                 .pm = &snd_soc_pm_ops,
109         },
110 };
111 module_platform_driver(sof_nocodec_audio)
112 
113 MODULE_LICENSE("Dual BSD/GPL");
114 MODULE_DESCRIPTION("ASoC sof nocodec");
115 MODULE_AUTHOR("Liam Girdwood");
116 MODULE_ALIAS("platform:sof-nocodec");
117 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php