All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yong Zhi <yong.zhi@intel.com>
To: broonie@kernel.org
Cc: alsa-devel@alsa-project.org, srinivas.sripathi@intel.com,
	vinod.koul@intel.com, yang.a.fang@intel.com,
	sathya.prakash.m.r@intel.com, jeeja.kp@intel.com,
	vedang.patel@intel.com, Yong Zhi <yong.zhi@intel.com>
Subject: [PATCH v2 3/3] ASoC: Intel: boards: configure DMIC for machine sklnau8825adi
Date: Wed, 25 May 2016 06:19:49 -0700	[thread overview]
Message-ID: <1464182389-1419-1-git-send-email-yong.zhi@intel.com> (raw)
In-Reply-To: <ac23a9ba3795ed50bea2d88dc90b419238ef1542.1463673471.git.yong.zhi@intel.com>

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>
---
 sound/soc/intel/boards/skl_nau88l25_ssm4567.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c
index 73cbddb..d4e174f 100644
--- a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c
+++ b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c
@@ -27,12 +27,15 @@
 #include <sound/pcm_params.h>
 #include "../../codecs/nau8825.h"
 #include "../../codecs/hdac_hdmi.h"
+#include "../skylake/skl.h"
 
 #define SKL_NUVOTON_CODEC_DAI	"nau8825-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_card skylake_audio_card;
+static const struct snd_pcm_hw_constraint_list *dmic_constraints;
 
 enum {
 	SKL_DPCM_AUDIO_PB = 0,
@@ -325,7 +328,7 @@ static int skylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
 {
 	struct snd_interval *channels = hw_param_interval(params,
 						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;
 	else
 		channels->min = channels->max = 4;
@@ -363,11 +366,21 @@ static struct snd_pcm_hw_constraint_list constraints_dmic_channels = {
 	.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)
 {
 	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,
 			&constraints_dmic_channels);
 
@@ -603,8 +616,14 @@ static struct snd_soc_card skylake_audio_card = {
 
 static int skylake_audio_probe(struct platform_device *pdev)
 {
+	struct skl_machine_pdata *pdata;
 	skylake_audio_card.dev = &pdev->dev;
 
+	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);
 }
 
-- 
1.9.1

  parent reply	other threads:[~2016-05-25 13:17 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-19 15:58 [PATCH] ASoC: add api to retrieve dmic array info from coreboot nhlt Yong Zhi
2016-05-19 16:01 ` Mark Brown
2016-05-19 16:17   ` Zhi, Yong
2016-05-23  5:47     ` Vinod Koul
2016-05-23 17:01       ` Mark Brown
2016-05-25 13:19 ` [PATCH v2 1/3] ASoC: Intel: Skylake: Add api to retrieve dmic array info from nhlt Yong Zhi
2016-05-26  5:23   ` Vinod Koul
2016-05-27  4:30   ` [PATCH v3 1/5] " Yong Zhi
2016-05-30  3:35     ` Vinod Koul
2016-05-30 17:39     ` Applied "ASoC: Intel: Skylake: Add api to retrieve dmic array info from nhlt" to the asoc tree Mark Brown
2016-05-27  4:30   ` [PATCH v3 2/5] ASoC: Intel: boards: configure DMIC for machine sklnau8825max Yong Zhi
2016-05-30 17:16     ` Mark Brown
2016-05-27  4:30   ` [PATCH v3 3/5] ASoC: Intel: boards: configure DMIC for machine sklnau8825adi Yong Zhi
2016-05-27  4:31   ` [PATCH v3 4/5] ASoC: Intel: Skylake: Add channel constraints for refcap Yong Zhi
2016-05-27  4:31   ` [PATCH v3 5/5] ASoC: Intel: Skylake: Use refcap device for mono recording Yong Zhi
2016-05-31 15:22   ` [PATCH v4 1/2] ASoC: Intel: boards: configure DMIC for machine sklnau8825adi Yong Zhi
2016-05-31 17:45     ` Applied "ASoC: Intel: boards: configure DMIC for machine sklnau8825adi" to the asoc tree Mark Brown
2016-05-31 15:24   ` [PATCH v4 2/2] ASoC: Intel: boards: configure DMIC for machine sklnau8825max Yong Zhi
2016-05-31 17:45     ` Applied "ASoC: Intel: boards: configure DMIC for machine sklnau8825max" to the asoc tree Mark Brown
2016-05-25 13:19 ` [PATCH v2 2/3] ASoC: Intel: boards: configure DMIC for machine sklnau8825max Yong Zhi
2016-05-26  5:24   ` Vinod Koul
2016-05-25 13:19 ` Yong Zhi [this message]
2016-05-26  5:25   ` [PATCH v2 3/3] ASoC: Intel: boards: configure DMIC for machine sklnau8825adi Vinod Koul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1464182389-1419-1-git-send-email-yong.zhi@intel.com \
    --to=yong.zhi@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=jeeja.kp@intel.com \
    --cc=sathya.prakash.m.r@intel.com \
    --cc=srinivas.sripathi@intel.com \
    --cc=vedang.patel@intel.com \
    --cc=vinod.koul@intel.com \
    --cc=yang.a.fang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.