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

TOMOYO Linux Cross Reference
Linux/sound/soc/samsung/jive_wm8750.c

Version: ~ [ linux-6.1-rc5 ] ~ [ linux-6.0.8 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.78 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.154 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.224 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.265 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.299 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.333 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ 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
  2 //
  3 // Copyright 2007,2008 Simtec Electronics
  4 //
  5 // Based on sound/soc/pxa/spitz.c
  6 //      Copyright 2005 Wolfson Microelectronics PLC.
  7 //      Copyright 2005 Openedhand Ltd.
  8 
  9 #include <linux/module.h>
 10 #include <sound/soc.h>
 11 
 12 #include <asm/mach-types.h>
 13 
 14 #include "s3c2412-i2s.h"
 15 #include "../codecs/wm8750.h"
 16 
 17 static const struct snd_soc_dapm_route audio_map[] = {
 18         { "Headphone Jack", NULL, "LOUT1" },
 19         { "Headphone Jack", NULL, "ROUT1" },
 20         { "Internal Speaker", NULL, "LOUT2" },
 21         { "Internal Speaker", NULL, "ROUT2" },
 22         { "LINPUT1", NULL, "Line Input" },
 23         { "RINPUT1", NULL, "Line Input" },
 24 };
 25 
 26 static const struct snd_soc_dapm_widget wm8750_dapm_widgets[] = {
 27         SND_SOC_DAPM_HP("Headphone Jack", NULL),
 28         SND_SOC_DAPM_SPK("Internal Speaker", NULL),
 29         SND_SOC_DAPM_LINE("Line In", NULL),
 30 };
 31 
 32 static int jive_hw_params(struct snd_pcm_substream *substream,
 33                           struct snd_pcm_hw_params *params)
 34 {
 35         struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
 36         struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
 37         struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
 38         struct s3c_i2sv2_rate_calc div;
 39         unsigned int clk = 0;
 40         int ret = 0;
 41 
 42         switch (params_rate(params)) {
 43         case 8000:
 44         case 16000:
 45         case 48000:
 46         case 96000:
 47                 clk = 12288000;
 48                 break;
 49         case 11025:
 50         case 22050:
 51         case 44100:
 52                 clk = 11289600;
 53                 break;
 54         }
 55 
 56         s3c_i2sv2_iis_calc_rate(&div, NULL, params_rate(params),
 57                                 s3c_i2sv2_get_clock(cpu_dai));
 58 
 59         /* set the codec system clock for DAC and ADC */
 60         ret = snd_soc_dai_set_sysclk(codec_dai, WM8750_SYSCLK, clk,
 61                                      SND_SOC_CLOCK_IN);
 62         if (ret < 0)
 63                 return ret;
 64 
 65         ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C2412_DIV_RCLK, div.fs_div);
 66         if (ret < 0)
 67                 return ret;
 68 
 69         ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C2412_DIV_PRESCALER,
 70                                      div.clk_div - 1);
 71         if (ret < 0)
 72                 return ret;
 73 
 74         return 0;
 75 }
 76 
 77 static const struct snd_soc_ops jive_ops = {
 78         .hw_params      = jive_hw_params,
 79 };
 80 
 81 SND_SOC_DAILINK_DEFS(wm8750,
 82         DAILINK_COMP_ARRAY(COMP_CPU("s3c2412-i2s")),
 83         DAILINK_COMP_ARRAY(COMP_CODEC("wm8750.0-001a", "wm8750-hifi")),
 84         DAILINK_COMP_ARRAY(COMP_PLATFORM("s3c2412-i2s")));
 85 
 86 static struct snd_soc_dai_link jive_dai = {
 87         .name           = "wm8750",
 88         .stream_name    = "WM8750",
 89         .dai_fmt        = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
 90                           SND_SOC_DAIFMT_CBS_CFS,
 91         .ops            = &jive_ops,
 92         SND_SOC_DAILINK_REG(wm8750),
 93 };
 94 
 95 /* jive audio machine driver */
 96 static struct snd_soc_card snd_soc_machine_jive = {
 97         .name           = "Jive",
 98         .owner          = THIS_MODULE,
 99         .dai_link       = &jive_dai,
100         .num_links      = 1,
101 
102         .dapm_widgets   = wm8750_dapm_widgets,
103         .num_dapm_widgets = ARRAY_SIZE(wm8750_dapm_widgets),
104         .dapm_routes    = audio_map,
105         .num_dapm_routes = ARRAY_SIZE(audio_map),
106         .fully_routed   = true,
107 };
108 
109 static struct platform_device *jive_snd_device;
110 
111 static int __init jive_init(void)
112 {
113         int ret;
114 
115         if (!machine_is_jive())
116                 return 0;
117 
118         printk("JIVE WM8750 Audio support\n");
119 
120         jive_snd_device = platform_device_alloc("soc-audio", -1);
121         if (!jive_snd_device)
122                 return -ENOMEM;
123 
124         platform_set_drvdata(jive_snd_device, &snd_soc_machine_jive);
125         ret = platform_device_add(jive_snd_device);
126 
127         if (ret)
128                 platform_device_put(jive_snd_device);
129 
130         return ret;
131 }
132 
133 static void __exit jive_exit(void)
134 {
135         platform_device_unregister(jive_snd_device);
136 }
137 
138 module_init(jive_init);
139 module_exit(jive_exit);
140 
141 MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
142 MODULE_DESCRIPTION("ALSA SoC Jive Audio support");
143 MODULE_LICENSE("GPL");
144 

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