bdw-rt5677.c (908e757daecf2120c3019fa630ae5d4c3cd7165b) | bdw-rt5677.c (2207b93bc7866e5ece41b5bad46ddfed995b2137) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * ASoC machine driver for Intel Broadwell platforms with RT5677 codec 4 * 5 * Copyright (c) 2014, The Chromium OS Authors. All rights reserved. 6 */ 7 8#include <linux/acpi.h> --- 142 unchanged lines hidden (view full) --- 151 /* set SSP0 to 16 bit */ 152 params_set_format(params, SNDRV_PCM_FORMAT_S16_LE); 153 return 0; 154} 155 156static int bdw_rt5677_hw_params(struct snd_pcm_substream *substream, 157 struct snd_pcm_hw_params *params) 158{ | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * ASoC machine driver for Intel Broadwell platforms with RT5677 codec 4 * 5 * Copyright (c) 2014, The Chromium OS Authors. All rights reserved. 6 */ 7 8#include <linux/acpi.h> --- 142 unchanged lines hidden (view full) --- 151 /* set SSP0 to 16 bit */ 152 params_set_format(params, SNDRV_PCM_FORMAT_S16_LE); 153 return 0; 154} 155 156static int bdw_rt5677_hw_params(struct snd_pcm_substream *substream, 157 struct snd_pcm_hw_params *params) 158{ |
159 struct snd_soc_pcm_runtime *rtd = substream->private_data; | 159 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
160 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); 161 int ret; 162 163 ret = snd_soc_dai_set_sysclk(codec_dai, RT5677_SCLK_S_MCLK, 24576000, 164 SND_SOC_CLOCK_IN); 165 if (ret < 0) { 166 dev_err(rtd->dev, "can't set codec sysclk configuration\n"); 167 return ret; 168 } 169 170 return ret; 171} 172 173static int bdw_rt5677_dsp_hw_params(struct snd_pcm_substream *substream, 174 struct snd_pcm_hw_params *params) 175{ | 160 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); 161 int ret; 162 163 ret = snd_soc_dai_set_sysclk(codec_dai, RT5677_SCLK_S_MCLK, 24576000, 164 SND_SOC_CLOCK_IN); 165 if (ret < 0) { 166 dev_err(rtd->dev, "can't set codec sysclk configuration\n"); 167 return ret; 168 } 169 170 return ret; 171} 172 173static int bdw_rt5677_dsp_hw_params(struct snd_pcm_substream *substream, 174 struct snd_pcm_hw_params *params) 175{ |
176 struct snd_soc_pcm_runtime *rtd = substream->private_data; | 176 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
177 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); 178 int ret; 179 180 ret = snd_soc_dai_set_sysclk(codec_dai, RT5677_SCLK_S_PLL1, 24576000, 181 SND_SOC_CLOCK_IN); 182 if (ret < 0) { 183 dev_err(rtd->dev, "can't set codec sysclk configuration\n"); 184 return ret; --- 82 unchanged lines hidden (view full) --- 267 RT5677_CLK_SEL_I2S1_ASRC); 268 /* Enable codec ASRC function for Mono ADC L. 269 * The ASRC clock source is clk_sys2_asrc. 270 */ 271 rt5677_sel_asrc_clk_src(component, RT5677_AD_MONO_L_FILTER, 272 RT5677_CLK_SEL_SYS2); 273 274 /* Request rt5677 GPIO for headphone amp control */ | 177 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); 178 int ret; 179 180 ret = snd_soc_dai_set_sysclk(codec_dai, RT5677_SCLK_S_PLL1, 24576000, 181 SND_SOC_CLOCK_IN); 182 if (ret < 0) { 183 dev_err(rtd->dev, "can't set codec sysclk configuration\n"); 184 return ret; --- 82 unchanged lines hidden (view full) --- 267 RT5677_CLK_SEL_I2S1_ASRC); 268 /* Enable codec ASRC function for Mono ADC L. 269 * The ASRC clock source is clk_sys2_asrc. 270 */ 271 rt5677_sel_asrc_clk_src(component, RT5677_AD_MONO_L_FILTER, 272 RT5677_CLK_SEL_SYS2); 273 274 /* Request rt5677 GPIO for headphone amp control */ |
275 bdw_rt5677->gpio_hp_en = devm_gpiod_get(component->dev, "headphone-enable", 276 GPIOD_OUT_LOW); | 275 bdw_rt5677->gpio_hp_en = gpiod_get(component->dev, "headphone-enable", 276 GPIOD_OUT_LOW); |
277 if (IS_ERR(bdw_rt5677->gpio_hp_en)) { 278 dev_err(component->dev, "Can't find HP_AMP_SHDN_L gpio\n"); 279 return PTR_ERR(bdw_rt5677->gpio_hp_en); 280 } 281 282 /* Create and initialize headphone jack */ 283 if (!snd_soc_card_jack_new(rtd->card, "Headphone Jack", 284 SND_JACK_HEADPHONE, &headphone_jack, --- 17 unchanged lines hidden (view full) --- 302 dev_err(component->dev, "Can't create mic jack\n"); 303 } 304 bdw_rt5677->component = component; 305 306 snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1"); 307 return 0; 308} 309 | 277 if (IS_ERR(bdw_rt5677->gpio_hp_en)) { 278 dev_err(component->dev, "Can't find HP_AMP_SHDN_L gpio\n"); 279 return PTR_ERR(bdw_rt5677->gpio_hp_en); 280 } 281 282 /* Create and initialize headphone jack */ 283 if (!snd_soc_card_jack_new(rtd->card, "Headphone Jack", 284 SND_JACK_HEADPHONE, &headphone_jack, --- 17 unchanged lines hidden (view full) --- 302 dev_err(component->dev, "Can't create mic jack\n"); 303 } 304 bdw_rt5677->component = component; 305 306 snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1"); 307 return 0; 308} 309 |
310static void bdw_rt5677_exit(struct snd_soc_pcm_runtime *rtd) 311{ 312 struct bdw_rt5677_priv *bdw_rt5677 = 313 snd_soc_card_get_drvdata(rtd->card); 314 315 /* 316 * The .exit() can be reached without going through the .init() 317 * so explicitly test if the gpiod is valid 318 */ 319 if (!IS_ERR_OR_NULL(bdw_rt5677->gpio_hp_en)) 320 gpiod_put(bdw_rt5677->gpio_hp_en); 321} 322 |
|
310/* broadwell digital audio interface glue - connects codec <--> CPU */ 311SND_SOC_DAILINK_DEF(dummy, 312 DAILINK_COMP_ARRAY(COMP_DUMMY())); 313 314SND_SOC_DAILINK_DEF(fe, 315 DAILINK_COMP_ARRAY(COMP_CPU("System Pin"))); 316 317SND_SOC_DAILINK_DEF(platform, --- 50 unchanged lines hidden (view full) --- 368 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | 369 SND_SOC_DAIFMT_CBS_CFS, 370 .ignore_pmdown_time = 1, 371 .be_hw_params_fixup = broadwell_ssp0_fixup, 372 .ops = &bdw_rt5677_ops, 373 .dpcm_playback = 1, 374 .dpcm_capture = 1, 375 .init = bdw_rt5677_init, | 323/* broadwell digital audio interface glue - connects codec <--> CPU */ 324SND_SOC_DAILINK_DEF(dummy, 325 DAILINK_COMP_ARRAY(COMP_DUMMY())); 326 327SND_SOC_DAILINK_DEF(fe, 328 DAILINK_COMP_ARRAY(COMP_CPU("System Pin"))); 329 330SND_SOC_DAILINK_DEF(platform, --- 50 unchanged lines hidden (view full) --- 381 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | 382 SND_SOC_DAIFMT_CBS_CFS, 383 .ignore_pmdown_time = 1, 384 .be_hw_params_fixup = broadwell_ssp0_fixup, 385 .ops = &bdw_rt5677_ops, 386 .dpcm_playback = 1, 387 .dpcm_capture = 1, 388 .init = bdw_rt5677_init, |
389 .exit = bdw_rt5677_exit, |
|
376#if !IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL) 377 SND_SOC_DAILINK_REG(dummy, be, dummy), 378#else 379 SND_SOC_DAILINK_REG(ssp0_port, be, platform), 380#endif 381 }, 382}; 383 --- 16 unchanged lines hidden (view full) --- 400 401 if (bdw_rt5677->component) { 402 dapm = snd_soc_component_get_dapm(bdw_rt5677->component); 403 snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1"); 404 } 405 return 0; 406} 407 | 390#if !IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL) 391 SND_SOC_DAILINK_REG(dummy, be, dummy), 392#else 393 SND_SOC_DAILINK_REG(ssp0_port, be, platform), 394#endif 395 }, 396}; 397 --- 16 unchanged lines hidden (view full) --- 414 415 if (bdw_rt5677->component) { 416 dapm = snd_soc_component_get_dapm(bdw_rt5677->component); 417 snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1"); 418 } 419 return 0; 420} 421 |
422#if IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL) 423/* use space before codec name to simplify card ID, and simplify driver name */ 424#define CARD_NAME "bdw rt5677" /* card name will be 'sof-bdw rt5677' */ 425#define DRIVER_NAME "SOF" 426#else 427#define CARD_NAME "bdw-rt5677" 428#define DRIVER_NAME NULL /* card name will be used for driver name */ 429#endif 430 |
|
408/* ASoC machine driver for Broadwell DSP + RT5677 */ 409static struct snd_soc_card bdw_rt5677_card = { | 431/* ASoC machine driver for Broadwell DSP + RT5677 */ 432static struct snd_soc_card bdw_rt5677_card = { |
410 .name = "bdw-rt5677", | 433 .name = CARD_NAME, 434 .driver_name = DRIVER_NAME, |
411 .owner = THIS_MODULE, 412 .dai_link = bdw_rt5677_dais, 413 .num_links = ARRAY_SIZE(bdw_rt5677_dais), 414 .dapm_widgets = bdw_rt5677_widgets, 415 .num_dapm_widgets = ARRAY_SIZE(bdw_rt5677_widgets), 416 .dapm_routes = bdw_rt5677_map, 417 .num_dapm_routes = ARRAY_SIZE(bdw_rt5677_map), 418 .controls = bdw_rt5677_controls, --- 48 unchanged lines hidden --- | 435 .owner = THIS_MODULE, 436 .dai_link = bdw_rt5677_dais, 437 .num_links = ARRAY_SIZE(bdw_rt5677_dais), 438 .dapm_widgets = bdw_rt5677_widgets, 439 .num_dapm_widgets = ARRAY_SIZE(bdw_rt5677_widgets), 440 .dapm_routes = bdw_rt5677_map, 441 .num_dapm_routes = ARRAY_SIZE(bdw_rt5677_map), 442 .controls = bdw_rt5677_controls, --- 48 unchanged lines hidden --- |