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

TOMOYO Linux Cross Reference
Linux/sound/soc/intel/avs/boards/i2s_test.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 //
  3 // Copyright(c) 2021-2022 Intel Corporation
  4 //
  5 // Authors: Cezary Rojewski <cezary.rojewski@intel.com>
  6 //          Amadeusz Slawinski <amadeuszx.slawinski@linux.intel.com>
  7 //
  8 
  9 #include <linux/module.h>
 10 #include <sound/pcm.h>
 11 #include <sound/pcm_params.h>
 12 #include <sound/soc.h>
 13 #include <sound/soc-acpi.h>
 14 #include <sound/soc-dapm.h>
 15 #include "../utils.h"
 16 
 17 static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port,
 18                                int tdm_slot, struct snd_soc_dai_link **dai_link)
 19 {
 20         struct snd_soc_dai_link_component *platform;
 21         struct snd_soc_dai_link *dl;
 22 
 23         dl = devm_kzalloc(dev, sizeof(*dl), GFP_KERNEL);
 24         platform = devm_kzalloc(dev, sizeof(*platform), GFP_KERNEL);
 25         if (!dl || !platform)
 26                 return -ENOMEM;
 27 
 28         platform->name = platform_name;
 29 
 30         dl->name = devm_kasprintf(dev, GFP_KERNEL,
 31                                   AVS_STRING_FMT("SSP", "-Codec", ssp_port, tdm_slot));
 32         dl->cpus = devm_kzalloc(dev, sizeof(*dl->cpus), GFP_KERNEL);
 33         if (!dl->name || !dl->cpus)
 34                 return -ENOMEM;
 35 
 36         dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
 37                                             AVS_STRING_FMT("SSP", " Pin", ssp_port, tdm_slot));
 38         dl->codecs = &snd_soc_dummy_dlc;
 39         if (!dl->cpus->dai_name || !dl->codecs->name || !dl->codecs->dai_name)
 40                 return -ENOMEM;
 41 
 42         dl->num_cpus = 1;
 43         dl->num_codecs = 1;
 44         dl->platforms = platform;
 45         dl->num_platforms = 1;
 46         dl->id = 0;
 47         dl->nonatomic = 1;
 48         dl->no_pcm = 1;
 49         dl->dpcm_capture = 1;
 50         dl->dpcm_playback = 1;
 51 
 52         *dai_link = dl;
 53 
 54         return 0;
 55 }
 56 
 57 static int avs_i2s_test_probe(struct platform_device *pdev)
 58 {
 59         struct snd_soc_dai_link *dai_link;
 60         struct snd_soc_acpi_mach *mach;
 61         struct snd_soc_card *card;
 62         struct device *dev = &pdev->dev;
 63         const char *pname;
 64         int ssp_port, tdm_slot, ret;
 65 
 66         mach = dev_get_platdata(dev);
 67         pname = mach->mach_params.platform;
 68 
 69         if (!avs_mach_singular_ssp(mach)) {
 70                 dev_err(dev, "Invalid SSP configuration\n");
 71                 return -EINVAL;
 72         }
 73         ssp_port = avs_mach_ssp_port(mach);
 74 
 75         if (!avs_mach_singular_tdm(mach, ssp_port)) {
 76                 dev_err(dev, "Invalid TDM configuration\n");
 77                 return -EINVAL;
 78         }
 79         tdm_slot = avs_mach_ssp_tdm(mach, ssp_port);
 80 
 81         card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
 82         if (!card)
 83                 return -ENOMEM;
 84 
 85         card->name = devm_kasprintf(dev, GFP_KERNEL,
 86                                     AVS_STRING_FMT("ssp", "-loopback", ssp_port, tdm_slot));
 87         if (!card->name)
 88                 return -ENOMEM;
 89 
 90         ret = avs_create_dai_link(dev, pname, ssp_port, tdm_slot, &dai_link);
 91         if (ret) {
 92                 dev_err(dev, "Failed to create dai link: %d\n", ret);
 93                 return ret;
 94         }
 95 
 96         card->dev = dev;
 97         card->owner = THIS_MODULE;
 98         card->dai_link = dai_link;
 99         card->num_links = 1;
100         card->fully_routed = true;
101 
102         ret = snd_soc_fixup_dai_links_platform_name(card, pname);
103         if (ret)
104                 return ret;
105 
106         return devm_snd_soc_register_card(dev, card);
107 }
108 
109 static const struct platform_device_id avs_i2s_test_driver_ids[] = {
110         {
111                 .name = "avs_i2s_test",
112         },
113         {},
114 };
115 MODULE_DEVICE_TABLE(platform, avs_i2s_test_driver_ids);
116 
117 static struct platform_driver avs_i2s_test_driver = {
118         .probe = avs_i2s_test_probe,
119         .driver = {
120                 .name = "avs_i2s_test",
121                 .pm = &snd_soc_pm_ops,
122         },
123         .id_table = avs_i2s_test_driver_ids,
124 };
125 
126 module_platform_driver(avs_i2s_test_driver);
127 
128 MODULE_DESCRIPTION("Intel i2s test machine driver");
129 MODULE_LICENSE("GPL");
130 

~ [ 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