Commit cfa12367 authored by Yong Zhi's avatar Yong Zhi Committed by Mark Brown

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: default avatarYong Zhi <yong.zhi@intel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 3467a64d
...@@ -27,12 +27,15 @@ ...@@ -27,12 +27,15 @@
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include "../../codecs/nau8825.h" #include "../../codecs/nau8825.h"
#include "../../codecs/hdac_hdmi.h" #include "../../codecs/hdac_hdmi.h"
#include "../skylake/skl.h"
#define SKL_NUVOTON_CODEC_DAI "nau8825-hifi" #define SKL_NUVOTON_CODEC_DAI "nau8825-hifi"
#define SKL_SSM_CODEC_DAI "ssm4567-hifi" #define SKL_SSM_CODEC_DAI "ssm4567-hifi"
#define DMIC_CH(p) p->list[p->count-1]
static struct snd_soc_jack skylake_headset; static struct snd_soc_jack skylake_headset;
static struct snd_soc_card skylake_audio_card; static struct snd_soc_card skylake_audio_card;
static const struct snd_pcm_hw_constraint_list *dmic_constraints;
struct skl_hdmi_pcm { struct skl_hdmi_pcm {
struct list_head head; struct list_head head;
...@@ -367,7 +370,7 @@ static int skylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd, ...@@ -367,7 +370,7 @@ static int skylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
{ {
struct snd_interval *channels = hw_param_interval(params, struct snd_interval *channels = hw_param_interval(params,
SNDRV_PCM_HW_PARAM_CHANNELS); SNDRV_PCM_HW_PARAM_CHANNELS);
if (params_channels(params) == 2) if (params_channels(params) == 2 || DMIC_CH(dmic_constraints) == 2)
channels->min = channels->max = 2; channels->min = channels->max = 2;
else else
channels->min = channels->max = 4; channels->min = channels->max = 4;
...@@ -405,13 +408,23 @@ static struct snd_pcm_hw_constraint_list constraints_dmic_channels = { ...@@ -405,13 +408,23 @@ static struct snd_pcm_hw_constraint_list constraints_dmic_channels = {
.mask = 0, .mask = 0,
}; };
static const unsigned int dmic_2ch[] = {
2,
};
static const struct snd_pcm_hw_constraint_list constraints_dmic_2ch = {
.count = ARRAY_SIZE(dmic_2ch),
.list = dmic_2ch,
.mask = 0,
};
static int skylake_dmic_startup(struct snd_pcm_substream *substream) static int skylake_dmic_startup(struct snd_pcm_substream *substream)
{ {
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
runtime->hw.channels_max = 4; runtime->hw.channels_max = DMIC_CH(dmic_constraints);
snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
&constraints_dmic_channels); dmic_constraints);
return snd_pcm_hw_constraint_list(substream->runtime, 0, return snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
...@@ -676,6 +689,7 @@ static struct snd_soc_card skylake_audio_card = { ...@@ -676,6 +689,7 @@ static struct snd_soc_card skylake_audio_card = {
static int skylake_audio_probe(struct platform_device *pdev) static int skylake_audio_probe(struct platform_device *pdev)
{ {
struct skl_nau88125_private *ctx; struct skl_nau88125_private *ctx;
struct skl_machine_pdata *pdata;
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC); ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC);
if (!ctx) if (!ctx)
...@@ -686,6 +700,11 @@ static int skylake_audio_probe(struct platform_device *pdev) ...@@ -686,6 +700,11 @@ static int skylake_audio_probe(struct platform_device *pdev)
skylake_audio_card.dev = &pdev->dev; skylake_audio_card.dev = &pdev->dev;
snd_soc_card_set_drvdata(&skylake_audio_card, ctx); snd_soc_card_set_drvdata(&skylake_audio_card, ctx);
pdata = dev_get_drvdata(&pdev->dev);
if (pdata)
dmic_constraints = pdata->dmic_num == 2 ?
&constraints_dmic_2ch : &constraints_dmic_channels;
return devm_snd_soc_register_card(&pdev->dev, &skylake_audio_card); return devm_snd_soc_register_card(&pdev->dev, &skylake_audio_card);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment