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

TOMOYO Linux Cross Reference
Linux/sound/soc/intel/boards/haswell.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  * Intel Haswell Lynxpoint SST Audio
  4  *
  5  * Copyright (C) 2013, Intel Corporation. All rights reserved.
  6  */
  7 
  8 #include <linux/module.h>
  9 #include <linux/platform_device.h>
 10 #include <sound/core.h>
 11 #include <sound/pcm.h>
 12 #include <sound/soc.h>
 13 #include <sound/soc-acpi.h>
 14 #include <sound/pcm_params.h>
 15 
 16 #include "../common/sst-dsp.h"
 17 #include "../haswell/sst-haswell-ipc.h"
 18 
 19 #include "../../codecs/rt5640.h"
 20 
 21 /* Haswell ULT platforms have a Headphone and Mic jack */
 22 static const struct snd_soc_dapm_widget haswell_widgets[] = {
 23         SND_SOC_DAPM_HP("Headphones", NULL),
 24         SND_SOC_DAPM_MIC("Mic", NULL),
 25 };
 26 
 27 static const struct snd_soc_dapm_route haswell_rt5640_map[] = {
 28 
 29         {"Headphones", NULL, "HPOR"},
 30         {"Headphones", NULL, "HPOL"},
 31         {"IN2P", NULL, "Mic"},
 32 
 33         /* CODEC BE connections */
 34         {"SSP0 CODEC IN", NULL, "AIF1 Capture"},
 35         {"AIF1 Playback", NULL, "SSP0 CODEC OUT"},
 36 };
 37 
 38 static int haswell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,
 39                         struct snd_pcm_hw_params *params)
 40 {
 41         struct snd_interval *rate = hw_param_interval(params,
 42                         SNDRV_PCM_HW_PARAM_RATE);
 43         struct snd_interval *channels = hw_param_interval(params,
 44                                                 SNDRV_PCM_HW_PARAM_CHANNELS);
 45 
 46         /* The ADSP will covert the FE rate to 48k, stereo */
 47         rate->min = rate->max = 48000;
 48         channels->min = channels->max = 2;
 49 
 50         /* set SSP0 to 16 bit */
 51         params_set_format(params, SNDRV_PCM_FORMAT_S16_LE);
 52         return 0;
 53 }
 54 
 55 static int haswell_rt5640_hw_params(struct snd_pcm_substream *substream,
 56         struct snd_pcm_hw_params *params)
 57 {
 58         struct snd_soc_pcm_runtime *rtd = substream->private_data;
 59         struct snd_soc_dai *codec_dai = rtd->codec_dai;
 60         int ret;
 61 
 62         ret = snd_soc_dai_set_sysclk(codec_dai, RT5640_SCLK_S_MCLK, 12288000,
 63                 SND_SOC_CLOCK_IN);
 64 
 65         if (ret < 0) {
 66                 dev_err(rtd->dev, "can't set codec sysclk configuration\n");
 67                 return ret;
 68         }
 69 
 70         /* set correct codec filter for DAI format and clock config */
 71         snd_soc_component_update_bits(codec_dai->component, 0x83, 0xffff, 0x8000);
 72 
 73         return ret;
 74 }
 75 
 76 static const struct snd_soc_ops haswell_rt5640_ops = {
 77         .hw_params = haswell_rt5640_hw_params,
 78 };
 79 
 80 static int haswell_rtd_init(struct snd_soc_pcm_runtime *rtd)
 81 {
 82         struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
 83         struct sst_pdata *pdata = dev_get_platdata(component->dev);
 84         struct sst_hsw *haswell = pdata->dsp;
 85         int ret;
 86 
 87         /* Set ADSP SSP port settings */
 88         ret = sst_hsw_device_set_config(haswell, SST_HSW_DEVICE_SSP_0,
 89                 SST_HSW_DEVICE_MCLK_FREQ_24_MHZ,
 90                 SST_HSW_DEVICE_CLOCK_MASTER, 9);
 91         if (ret < 0) {
 92                 dev_err(rtd->dev, "failed to set device config\n");
 93                 return ret;
 94         }
 95 
 96         return 0;
 97 }
 98 
 99 static struct snd_soc_dai_link haswell_rt5640_dais[] = {
100         /* Front End DAI links */
101         {
102                 .name = "System",
103                 .stream_name = "System Playback/Capture",
104                 .cpu_dai_name = "System Pin",
105                 .platform_name = "haswell-pcm-audio",
106                 .dynamic = 1,
107                 .codec_name = "snd-soc-dummy",
108                 .codec_dai_name = "snd-soc-dummy-dai",
109                 .init = haswell_rtd_init,
110                 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
111                 .dpcm_playback = 1,
112                 .dpcm_capture = 1,
113         },
114         {
115                 .name = "Offload0",
116                 .stream_name = "Offload0 Playback",
117                 .cpu_dai_name = "Offload0 Pin",
118                 .platform_name = "haswell-pcm-audio",
119                 .dynamic = 1,
120                 .codec_name = "snd-soc-dummy",
121                 .codec_dai_name = "snd-soc-dummy-dai",
122                 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
123                 .dpcm_playback = 1,
124         },
125         {
126                 .name = "Offload1",
127                 .stream_name = "Offload1 Playback",
128                 .cpu_dai_name = "Offload1 Pin",
129                 .platform_name = "haswell-pcm-audio",
130                 .dynamic = 1,
131                 .codec_name = "snd-soc-dummy",
132                 .codec_dai_name = "snd-soc-dummy-dai",
133                 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
134                 .dpcm_playback = 1,
135         },
136         {
137                 .name = "Loopback",
138                 .stream_name = "Loopback",
139                 .cpu_dai_name = "Loopback Pin",
140                 .platform_name = "haswell-pcm-audio",
141                 .dynamic = 1,
142                 .codec_name = "snd-soc-dummy",
143                 .codec_dai_name = "snd-soc-dummy-dai",
144                 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
145                 .dpcm_capture = 1,
146         },
147 
148         /* Back End DAI links */
149         {
150                 /* SSP0 - Codec */
151                 .name = "Codec",
152                 .id = 0,
153                 .cpu_dai_name = "snd-soc-dummy-dai",
154                 .platform_name = "snd-soc-dummy",
155                 .no_pcm = 1,
156                 .codec_name = "i2c-INT33CA:00",
157                 .codec_dai_name = "rt5640-aif1",
158                 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
159                         SND_SOC_DAIFMT_CBS_CFS,
160                 .ignore_suspend = 1,
161                 .ignore_pmdown_time = 1,
162                 .be_hw_params_fixup = haswell_ssp0_fixup,
163                 .ops = &haswell_rt5640_ops,
164                 .dpcm_playback = 1,
165                 .dpcm_capture = 1,
166         },
167 };
168 
169 /* audio machine driver for Haswell Lynxpoint DSP + RT5640 */
170 static struct snd_soc_card haswell_rt5640 = {
171         .name = "haswell-rt5640",
172         .owner = THIS_MODULE,
173         .dai_link = haswell_rt5640_dais,
174         .num_links = ARRAY_SIZE(haswell_rt5640_dais),
175         .dapm_widgets = haswell_widgets,
176         .num_dapm_widgets = ARRAY_SIZE(haswell_widgets),
177         .dapm_routes = haswell_rt5640_map,
178         .num_dapm_routes = ARRAY_SIZE(haswell_rt5640_map),
179         .fully_routed = true,
180 };
181 
182 static int haswell_audio_probe(struct platform_device *pdev)
183 {
184         struct snd_soc_acpi_mach *mach;
185         const char *platform_name = NULL;
186         int ret;
187 
188         haswell_rt5640.dev = &pdev->dev;
189 
190         /* override plaform name, if required */
191         mach = (&pdev->dev)->platform_data;
192         if (mach) /* extra check since legacy does not pass parameters */
193                 platform_name = mach->mach_params.platform;
194 
195         ret = snd_soc_fixup_dai_links_platform_name(&haswell_rt5640,
196                                                     platform_name);
197         if (ret)
198                 return ret;
199 
200         return devm_snd_soc_register_card(&pdev->dev, &haswell_rt5640);
201 }
202 
203 static struct platform_driver haswell_audio = {
204         .probe = haswell_audio_probe,
205         .driver = {
206                 .name = "haswell-audio",
207         },
208 };
209 
210 module_platform_driver(haswell_audio)
211 
212 /* Module information */
213 MODULE_AUTHOR("Liam Girdwood, Xingchao Wang");
214 MODULE_DESCRIPTION("Intel SST Audio for Haswell Lynxpoint");
215 MODULE_LICENSE("GPL v2");
216 MODULE_ALIAS("platform:haswell-audio");
217 

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