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

TOMOYO Linux Cross Reference
Linux/sound/soc/pxa/imote2.c

Version: ~ [ linux-5.16-rc3 ] ~ [ linux-5.15.5 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.82 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.162 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.218 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.256 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.291 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.293 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ 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.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 
  3 #include <linux/module.h>
  4 #include <sound/soc.h>
  5 
  6 #include <asm/mach-types.h>
  7 
  8 #include "../codecs/wm8940.h"
  9 #include "pxa2xx-i2s.h"
 10 
 11 static int imote2_asoc_hw_params(struct snd_pcm_substream *substream,
 12                                  struct snd_pcm_hw_params *params)
 13 {
 14         struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
 15         struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
 16         struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
 17         unsigned int clk = 0;
 18         int ret;
 19 
 20         switch (params_rate(params)) {
 21         case 8000:
 22         case 16000:
 23         case 48000:
 24         case 96000:
 25                 clk = 12288000;
 26                 break;
 27         case 11025:
 28         case 22050:
 29         case 44100:
 30                 clk = 11289600;
 31                 break;
 32         }
 33 
 34         ret = snd_soc_dai_set_sysclk(codec_dai, 0, clk,
 35                                      SND_SOC_CLOCK_IN);
 36         if (ret < 0)
 37                 return ret;
 38 
 39         /* set the I2S system clock as input (unused) */
 40         ret = snd_soc_dai_set_sysclk(cpu_dai, PXA2XX_I2S_SYSCLK, clk,
 41                 SND_SOC_CLOCK_OUT);
 42 
 43         return ret;
 44 }
 45 
 46 static const struct snd_soc_ops imote2_asoc_ops = {
 47         .hw_params = imote2_asoc_hw_params,
 48 };
 49 
 50 SND_SOC_DAILINK_DEFS(wm8940,
 51         DAILINK_COMP_ARRAY(COMP_CPU("pxa2xx-i2s")),
 52         DAILINK_COMP_ARRAY(COMP_CODEC("wm8940-codec.0-0034",
 53                                       "wm8940-hifi")),
 54         DAILINK_COMP_ARRAY(COMP_PLATFORM("pxa-pcm-audio")));
 55 
 56 static struct snd_soc_dai_link imote2_dai = {
 57         .name = "WM8940",
 58         .stream_name = "WM8940",
 59         .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
 60                    SND_SOC_DAIFMT_CBS_CFS,
 61         .ops = &imote2_asoc_ops,
 62         SND_SOC_DAILINK_REG(wm8940),
 63 };
 64 
 65 static struct snd_soc_card imote2 = {
 66         .name = "Imote2",
 67         .owner = THIS_MODULE,
 68         .dai_link = &imote2_dai,
 69         .num_links = 1,
 70 };
 71 
 72 static int imote2_probe(struct platform_device *pdev)
 73 {
 74         struct snd_soc_card *card = &imote2;
 75         int ret;
 76 
 77         card->dev = &pdev->dev;
 78 
 79         ret = devm_snd_soc_register_card(&pdev->dev, card);
 80         if (ret)
 81                 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
 82                         ret);
 83         return ret;
 84 }
 85 
 86 static struct platform_driver imote2_driver = {
 87         .driver         = {
 88                 .name   = "imote2-audio",
 89                 .pm     = &snd_soc_pm_ops,
 90         },
 91         .probe          = imote2_probe,
 92 };
 93 
 94 module_platform_driver(imote2_driver);
 95 
 96 MODULE_AUTHOR("Jonathan Cameron");
 97 MODULE_DESCRIPTION("ALSA SoC Imote 2");
 98 MODULE_LICENSE("GPL");
 99 MODULE_ALIAS("platform:imote2-audio");
100 

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