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

TOMOYO Linux Cross Reference
Linux/sound/soc/tegra/trimslice.c

Version: ~ [ linux-6.3-rc3 ] ~ [ linux-6.2.7 ] ~ [ linux-6.1.20 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.103 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.175 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.237 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.278 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.310 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ 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  * trimslice.c - TrimSlice machine ASoC driver
  4  *
  5  * Copyright (C) 2011 - CompuLab, Ltd.
  6  * Author: Mike Rapoport <mike@compulab.co.il>
  7  *
  8  * Based on code copyright/by:
  9  * Author: Stephen Warren <swarren@nvidia.com>
 10  * Copyright (C) 2010-2011 - NVIDIA, Inc.
 11  */
 12 
 13 #include <linux/module.h>
 14 #include <linux/of.h>
 15 #include <linux/platform_device.h>
 16 #include <linux/slab.h>
 17 
 18 #include <sound/core.h>
 19 #include <sound/jack.h>
 20 #include <sound/pcm.h>
 21 #include <sound/pcm_params.h>
 22 #include <sound/soc.h>
 23 
 24 #include "../codecs/tlv320aic23.h"
 25 
 26 #include "tegra_asoc_utils.h"
 27 
 28 #define DRV_NAME "tegra-snd-trimslice"
 29 
 30 struct tegra_trimslice {
 31         struct tegra_asoc_utils_data util_data;
 32 };
 33 
 34 static int trimslice_asoc_hw_params(struct snd_pcm_substream *substream,
 35                                         struct snd_pcm_hw_params *params)
 36 {
 37         struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
 38         struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
 39         struct snd_soc_card *card = rtd->card;
 40         struct tegra_trimslice *trimslice = snd_soc_card_get_drvdata(card);
 41         int srate, mclk;
 42         int err;
 43 
 44         srate = params_rate(params);
 45         mclk = 128 * srate;
 46 
 47         err = tegra_asoc_utils_set_rate(&trimslice->util_data, srate, mclk);
 48         if (err < 0) {
 49                 dev_err(card->dev, "Can't configure clocks\n");
 50                 return err;
 51         }
 52 
 53         err = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
 54                                         SND_SOC_CLOCK_IN);
 55         if (err < 0) {
 56                 dev_err(card->dev, "codec_dai clock not set\n");
 57                 return err;
 58         }
 59 
 60         return 0;
 61 }
 62 
 63 static const struct snd_soc_ops trimslice_asoc_ops = {
 64         .hw_params = trimslice_asoc_hw_params,
 65 };
 66 
 67 static const struct snd_soc_dapm_widget trimslice_dapm_widgets[] = {
 68         SND_SOC_DAPM_HP("Line Out", NULL),
 69         SND_SOC_DAPM_LINE("Line In", NULL),
 70 };
 71 
 72 static const struct snd_soc_dapm_route trimslice_audio_map[] = {
 73         {"Line Out", NULL, "LOUT"},
 74         {"Line Out", NULL, "ROUT"},
 75 
 76         {"LLINEIN", NULL, "Line In"},
 77         {"RLINEIN", NULL, "Line In"},
 78 };
 79 
 80 SND_SOC_DAILINK_DEFS(single_dsp,
 81         DAILINK_COMP_ARRAY(COMP_EMPTY()),
 82         DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "tlv320aic23-hifi")),
 83         DAILINK_COMP_ARRAY(COMP_EMPTY()));
 84 
 85 static struct snd_soc_dai_link trimslice_tlv320aic23_dai = {
 86         .name = "TLV320AIC23",
 87         .stream_name = "AIC23",
 88         .ops = &trimslice_asoc_ops,
 89         .dai_fmt = SND_SOC_DAIFMT_I2S |
 90                    SND_SOC_DAIFMT_NB_NF |
 91                    SND_SOC_DAIFMT_CBS_CFS,
 92         SND_SOC_DAILINK_REG(single_dsp),
 93 };
 94 
 95 static struct snd_soc_card snd_soc_trimslice = {
 96         .name = "tegra-trimslice",
 97         .driver_name = "tegra",
 98         .owner = THIS_MODULE,
 99         .dai_link = &trimslice_tlv320aic23_dai,
100         .num_links = 1,
101 
102         .dapm_widgets = trimslice_dapm_widgets,
103         .num_dapm_widgets = ARRAY_SIZE(trimslice_dapm_widgets),
104         .dapm_routes = trimslice_audio_map,
105         .num_dapm_routes = ARRAY_SIZE(trimslice_audio_map),
106         .fully_routed = true,
107 };
108 
109 static int tegra_snd_trimslice_probe(struct platform_device *pdev)
110 {
111         struct device_node *np = pdev->dev.of_node;
112         struct snd_soc_card *card = &snd_soc_trimslice;
113         struct tegra_trimslice *trimslice;
114         int ret;
115 
116         trimslice = devm_kzalloc(&pdev->dev, sizeof(struct tegra_trimslice),
117                                  GFP_KERNEL);
118         if (!trimslice)
119                 return -ENOMEM;
120 
121         card->dev = &pdev->dev;
122         snd_soc_card_set_drvdata(card, trimslice);
123 
124         trimslice_tlv320aic23_dai.codecs->of_node = of_parse_phandle(np,
125                         "nvidia,audio-codec", 0);
126         if (!trimslice_tlv320aic23_dai.codecs->of_node) {
127                 dev_err(&pdev->dev,
128                         "Property 'nvidia,audio-codec' missing or invalid\n");
129                 return -EINVAL;
130         }
131 
132         trimslice_tlv320aic23_dai.cpus->of_node = of_parse_phandle(np,
133                         "nvidia,i2s-controller", 0);
134         if (!trimslice_tlv320aic23_dai.cpus->of_node) {
135                 dev_err(&pdev->dev,
136                         "Property 'nvidia,i2s-controller' missing or invalid\n");
137                 return -EINVAL;
138         }
139 
140         trimslice_tlv320aic23_dai.platforms->of_node =
141                         trimslice_tlv320aic23_dai.cpus->of_node;
142 
143         ret = tegra_asoc_utils_init(&trimslice->util_data, &pdev->dev);
144         if (ret)
145                 return ret;
146 
147         ret = devm_snd_soc_register_card(&pdev->dev, card);
148         if (ret)
149                 return dev_err_probe(&pdev->dev, ret,
150                                      "snd_soc_register_card failed\n");
151 
152         return 0;
153 }
154 
155 static const struct of_device_id trimslice_of_match[] = {
156         { .compatible = "nvidia,tegra-audio-trimslice", },
157         {},
158 };
159 MODULE_DEVICE_TABLE(of, trimslice_of_match);
160 
161 static struct platform_driver tegra_snd_trimslice_driver = {
162         .driver = {
163                 .name = DRV_NAME,
164                 .of_match_table = trimslice_of_match,
165         },
166         .probe = tegra_snd_trimslice_probe,
167 };
168 module_platform_driver(tegra_snd_trimslice_driver);
169 
170 MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>");
171 MODULE_DESCRIPTION("Trimslice machine ASoC driver");
172 MODULE_LICENSE("GPL");
173 MODULE_ALIAS("platform:" DRV_NAME);
174 

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

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | 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.

osdn.jp