diff options
author | Yong Zhi <yong.zhi@intel.com> | 2016-05-31 11:22:48 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-05-31 13:37:44 -0400 |
commit | cfa12367f8e032e515853a3ae12545dee18b9806 (patch) | |
tree | e53b2d20fec1f0c01030b0fafdbe73e0b217bd34 | |
parent | 3467a64dded3bcdbff8c3c9db2b1f1af20a9e295 (diff) |
ASoC: Intel: boards: configure DMIC for machine sklnau8825adi
This machine driver can support 2 or 4 DMIC configuration, so
apply the ch constraint according to driver pdata.
Signed-off-by: Yong Zhi <yong.zhi@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/intel/boards/skl_nau88l25_ssm4567.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c index 2647d885ee00..22f2e9d84e72 100644 --- a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c +++ b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c | |||
@@ -27,12 +27,15 @@ | |||
27 | #include <sound/pcm_params.h> | 27 | #include <sound/pcm_params.h> |
28 | #include "../../codecs/nau8825.h" | 28 | #include "../../codecs/nau8825.h" |
29 | #include "../../codecs/hdac_hdmi.h" | 29 | #include "../../codecs/hdac_hdmi.h" |
30 | #include "../skylake/skl.h" | ||
30 | 31 | ||
31 | #define SKL_NUVOTON_CODEC_DAI "nau8825-hifi" | 32 | #define SKL_NUVOTON_CODEC_DAI "nau8825-hifi" |
32 | #define SKL_SSM_CODEC_DAI "ssm4567-hifi" | 33 | #define SKL_SSM_CODEC_DAI "ssm4567-hifi" |
34 | #define DMIC_CH(p) p->list[p->count-1] | ||
33 | 35 | ||
34 | static struct snd_soc_jack skylake_headset; | 36 | static struct snd_soc_jack skylake_headset; |
35 | static struct snd_soc_card skylake_audio_card; | 37 | static struct snd_soc_card skylake_audio_card; |
38 | static const struct snd_pcm_hw_constraint_list *dmic_constraints; | ||
36 | 39 | ||
37 | struct skl_hdmi_pcm { | 40 | struct skl_hdmi_pcm { |
38 | struct list_head head; | 41 | struct list_head head; |
@@ -367,7 +370,7 @@ static int skylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd, | |||
367 | { | 370 | { |
368 | struct snd_interval *channels = hw_param_interval(params, | 371 | struct snd_interval *channels = hw_param_interval(params, |
369 | SNDRV_PCM_HW_PARAM_CHANNELS); | 372 | SNDRV_PCM_HW_PARAM_CHANNELS); |
370 | if (params_channels(params) == 2) | 373 | if (params_channels(params) == 2 || DMIC_CH(dmic_constraints) == 2) |
371 | channels->min = channels->max = 2; | 374 | channels->min = channels->max = 2; |
372 | else | 375 | else |
373 | channels->min = channels->max = 4; | 376 | channels->min = channels->max = 4; |
@@ -405,13 +408,23 @@ static struct snd_pcm_hw_constraint_list constraints_dmic_channels = { | |||
405 | .mask = 0, | 408 | .mask = 0, |
406 | }; | 409 | }; |
407 | 410 | ||
411 | static const unsigned int dmic_2ch[] = { | ||
412 | 2, | ||
413 | }; | ||
414 | |||
415 | static const struct snd_pcm_hw_constraint_list constraints_dmic_2ch = { | ||
416 | .count = ARRAY_SIZE(dmic_2ch), | ||
417 | .list = dmic_2ch, | ||
418 | .mask = 0, | ||
419 | }; | ||
420 | |||
408 | static int skylake_dmic_startup(struct snd_pcm_substream *substream) | 421 | static int skylake_dmic_startup(struct snd_pcm_substream *substream) |
409 | { | 422 | { |
410 | struct snd_pcm_runtime *runtime = substream->runtime; | 423 | struct snd_pcm_runtime *runtime = substream->runtime; |
411 | 424 | ||
412 | runtime->hw.channels_max = 4; | 425 | runtime->hw.channels_max = DMIC_CH(dmic_constraints); |
413 | snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, | 426 | snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, |
414 | &constraints_dmic_channels); | 427 | dmic_constraints); |
415 | 428 | ||
416 | return snd_pcm_hw_constraint_list(substream->runtime, 0, | 429 | return snd_pcm_hw_constraint_list(substream->runtime, 0, |
417 | SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); | 430 | SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); |
@@ -676,6 +689,7 @@ static struct snd_soc_card skylake_audio_card = { | |||
676 | static int skylake_audio_probe(struct platform_device *pdev) | 689 | static int skylake_audio_probe(struct platform_device *pdev) |
677 | { | 690 | { |
678 | struct skl_nau88125_private *ctx; | 691 | struct skl_nau88125_private *ctx; |
692 | struct skl_machine_pdata *pdata; | ||
679 | 693 | ||
680 | ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC); | 694 | ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC); |
681 | if (!ctx) | 695 | if (!ctx) |
@@ -686,6 +700,11 @@ static int skylake_audio_probe(struct platform_device *pdev) | |||
686 | skylake_audio_card.dev = &pdev->dev; | 700 | skylake_audio_card.dev = &pdev->dev; |
687 | snd_soc_card_set_drvdata(&skylake_audio_card, ctx); | 701 | snd_soc_card_set_drvdata(&skylake_audio_card, ctx); |
688 | 702 | ||
703 | pdata = dev_get_drvdata(&pdev->dev); | ||
704 | if (pdata) | ||
705 | dmic_constraints = pdata->dmic_num == 2 ? | ||
706 | &constraints_dmic_2ch : &constraints_dmic_channels; | ||
707 | |||
689 | return devm_snd_soc_register_card(&pdev->dev, &skylake_audio_card); | 708 | return devm_snd_soc_register_card(&pdev->dev, &skylake_audio_card); |
690 | } | 709 | } |
691 | 710 | ||