All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: add api to retrieve dmic array info from coreboot nhlt
@ 2016-05-19 15:58 Yong Zhi
  2016-05-19 16:01 ` Mark Brown
                   ` (3 more replies)
  0 siblings, 4 replies; 23+ messages in thread
From: Yong Zhi @ 2016-05-19 15:58 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, marc.herbert,
	yang.a.fang, sathya.prakash.m.r, jeeja.kp, vedang.patel,
	Yong Zhi

skylake can be configured with either both 2 and 4 channel DMIC
array, or 2 channel DMIC array only, this patch provides an API to
retrieve the DMIC info from nhlt.

Signed-off-by: Yong Zhi <yong.zhi@intel.com>
---
 sound/soc/intel/skylake/skl-nhlt.c | 37 +++++++++++++++++++++++++++++++++++++
 sound/soc/intel/skylake/skl-nhlt.h | 22 ++++++++++++++++++++++
 sound/soc/intel/skylake/skl.c      | 12 ++++++++++--
 sound/soc/intel/skylake/skl.h      |  6 ++++++
 4 files changed, 75 insertions(+), 2 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-nhlt.c b/sound/soc/intel/skylake/skl-nhlt.c
index 7d73648..be4c4a3 100644
--- a/sound/soc/intel/skylake/skl-nhlt.c
+++ b/sound/soc/intel/skylake/skl-nhlt.c
@@ -18,6 +18,7 @@
  *
  */
 #include "skl.h"
+#include <linux/pci.h>
 
 /* Unique identification for getting NHLT blobs */
 static u8 OSC_UUID[16] = {0x6E, 0x88, 0x9F, 0xA6, 0xEB, 0x6C, 0x94, 0x45,
@@ -149,6 +150,42 @@ struct nhlt_specific_cfg
 	return NULL;
 }
 
+int skl_get_dmic_geo(struct skl *skl)
+{
+	struct nhlt_acpi_table *nhlt = (struct nhlt_acpi_table *)skl->nhlt;
+	struct nhlt_endpoint *epnt;
+	struct nhlt_dmic_array_config *cfg;
+	struct device *dev = &(skl->pci->dev);
+	unsigned int dmic_geo = 0;
+	u8 j;
+
+	epnt = (struct nhlt_endpoint *)nhlt->desc;
+
+	for (j = 0; j < nhlt->endpoint_count; j++) {
+		if (epnt->linktype == NHLT_LINK_DMIC) {
+			cfg = (struct nhlt_dmic_array_config  *)
+					(epnt->config.caps);
+			switch (cfg->array_type) {
+			case NHLT_MIC_ARRAY_2CH_SMALL:
+			case NHLT_MIC_ARRAY_2CH_BIG:
+				dmic_geo |= MIC_ARRAY_2CH;
+				break;
+			case NHLT_MIC_ARRAY_4CH_1ST_GEOM:
+			case NHLT_MIC_ARRAY_4CH_L_SHAPED:
+			case NHLT_MIC_ARRAY_4CH_2ND_GEOM:
+				dmic_geo |= MIC_ARRAY_4CH;
+				break;
+			default:
+				dev_warn(dev, "undefined DMIC array_type 0x%0x\n",
+						cfg->array_type);
+			}
+		}
+		epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length);
+	}
+
+	return dmic_geo;
+}
+
 static void skl_nhlt_trim_space(struct skl *skl)
 {
 	char *s = skl->tplg_name;
diff --git a/sound/soc/intel/skylake/skl-nhlt.h b/sound/soc/intel/skylake/skl-nhlt.h
index 3769f9f..116534e7 100644
--- a/sound/soc/intel/skylake/skl-nhlt.h
+++ b/sound/soc/intel/skylake/skl-nhlt.h
@@ -103,4 +103,26 @@ struct nhlt_resource_desc  {
 	u64 length;
 } __packed;
 
+#define MIC_ARRAY_2CH 2
+#define MIC_ARRAY_4CH 4
+
+struct nhlt_tdm_config {
+	u8 virtual_slot;
+	u8 config_type;
+} __packed;
+
+struct nhlt_dmic_array_config {
+	struct nhlt_tdm_config tdm_config;
+	u8 array_type;
+} __packed;
+
+enum {
+	NHLT_MIC_ARRAY_2CH_SMALL = 0xa,
+	NHLT_MIC_ARRAY_2CH_BIG = 0xb,
+	NHLT_MIC_ARRAY_4CH_1ST_GEOM = 0xc,
+	NHLT_MIC_ARRAY_4CH_L_SHAPED = 0xd,
+	NHLT_MIC_ARRAY_4CH_2ND_GEOM = 0xe,
+	NHLT_MIC_ARRAY_VENDOR_DEFINED = 0xf,
+};
+
 #endif
diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c
index 06d8c26..b0f7226 100644
--- a/sound/soc/intel/skylake/skl.c
+++ b/sound/soc/intel/skylake/skl.c
@@ -35,6 +35,8 @@
 #include "skl-sst-dsp.h"
 #include "skl-sst-ipc.h"
 
+static struct skl_machine_pdata skl_dmic_data;
+
 /*
  * initialize the PCI registers
  */
@@ -397,6 +399,10 @@ static int skl_machine_device_register(struct skl *skl, void *driver_data)
 		platform_device_put(pdev);
 		return -EIO;
 	}
+
+	if (mach->pdata)
+		dev_set_drvdata(&pdev->dev, mach->pdata);
+
 	skl->i2s_dev = pdev;
 
 	return 0;
@@ -666,6 +672,8 @@ static int skl_probe(struct pci_dev *pci,
 
 	pci_set_drvdata(skl->pci, ebus);
 
+	skl_dmic_data.dmic_num = skl_get_dmic_geo(skl);
+
 	/* check if dsp is there */
 	if (ebus->ppcap) {
 		err = skl_machine_device_register(skl,
@@ -787,9 +795,9 @@ static void skl_remove(struct pci_dev *pci)
 static struct sst_acpi_mach sst_skl_devdata[] = {
 	{ "INT343A", "skl_alc286s_i2s", "intel/dsp_fw_release.bin", NULL, NULL, NULL },
 	{ "INT343B", "skl_nau88l25_ssm4567_i2s", "intel/dsp_fw_release.bin",
-				NULL, NULL, NULL },
+				NULL, NULL, &skl_dmic_data },
 	{ "MX98357A", "skl_nau88l25_max98357a_i2s", "intel/dsp_fw_release.bin",
-				NULL, NULL, NULL },
+				NULL, NULL, &skl_dmic_data },
 	{}
 };
 
diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h
index 4b4b387..f66be17 100644
--- a/sound/soc/intel/skylake/skl.h
+++ b/sound/soc/intel/skylake/skl.h
@@ -90,6 +90,11 @@ struct skl_dma_params {
 	u8 stream_tag;
 };
 
+/* to pass dmic data */
+struct skl_machine_pdata {
+	u32 dmic_num;
+};
+
 struct skl_dsp_ops {
 	int id;
 	struct skl_dsp_loader_ops (*loader_ops)(void);
@@ -108,6 +113,7 @@ void skl_nhlt_free(struct nhlt_acpi_table *addr);
 struct nhlt_specific_cfg *skl_get_ep_blob(struct skl *skl, u32 instance,
 			u8 link_type, u8 s_fmt, u8 no_ch, u32 s_rate, u8 dirn);
 
+int skl_get_dmic_geo(struct skl *skl);
 int skl_nhlt_update_topology_bin(struct skl *skl);
 int skl_init_dsp(struct skl *skl);
 int skl_free_dsp(struct skl *skl);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH] ASoC: add api to retrieve dmic array info from coreboot nhlt
  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-25 13:19 ` [PATCH v2 1/3] ASoC: Intel: Skylake: Add api to retrieve dmic array info from nhlt Yong Zhi
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 23+ messages in thread
From: Mark Brown @ 2016-05-19 16:01 UTC (permalink / raw)
  To: Yong Zhi
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, marc.herbert,
	yang.a.fang, sathya.prakash.m.r, jeeja.kp, vedang.patel


[-- Attachment #1.1: Type: text/plain, Size: 316 bytes --]

On Thu, May 19, 2016 at 08:58:59AM -0700, Yong Zhi wrote:
> skylake can be configured with either both 2 and 4 channel DMIC
> array, or 2 channel DMIC array only, this patch provides an API to
> retrieve the DMIC info from nhlt.

What's the difference between this and the similarly titled patch you
sent yesterday?

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH] ASoC: add api to retrieve dmic array info from coreboot nhlt
  2016-05-19 16:01 ` Mark Brown
@ 2016-05-19 16:17   ` Zhi, Yong
  2016-05-23  5:47     ` Vinod Koul
  0 siblings, 1 reply; 23+ messages in thread
From: Zhi, Yong @ 2016-05-19 16:17 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, Sripathi, Srinivas, Koul, Vinod, Fang, Yang A, M R,
	Sathya Prakash, Kp, Jeeja, Patel, Vedang

-----Original Message-----
From: Mark Brown [mailto:broonie@kernel.org] 
Sent: Thursday, May 19, 2016 9:02 AM
To: Zhi, Yong <yong.zhi@intel.com>
Cc: alsa-devel@alsa-project.org; Koul, Vinod <vinod.koul@intel.com>; Kp, Jeeja <jeeja.kp@intel.com>; Patel, Vedang <vedang.patel@intel.com>; Fang, Yang A <yang.a.fang@intel.com>; M R, Sathya Prakash <sathya.prakash.m.r@intel.com>; Herbert, Marc <marc.herbert@intel.com>; Sripathi, Srinivas <srinivas.sripathi@intel.com>
Subject: Re: [PATCH] ASoC: add api to retrieve dmic array info from coreboot nhlt

On Thu, May 19, 2016 at 08:58:59AM -0700, Yong Zhi wrote:
> skylake can be configured with either both 2 and 4 channel DMIC array, 
> or 2 channel DMIC array only, this patch provides an API to retrieve 
> the DMIC info from nhlt.

What's the difference between this and the similarly titled patch you sent yesterday?

[YZ], Hi, Mark, the only function change is at line 143 below, found another product that also needs to get DMIC config info yesterday.

        { "INT343B", "skl_nau88l25_ssm4567_i2s", "intel/dsp_fw_release.bin",
-                               NULL, NULL, NULL },
+                               NULL, NULL, &skl_dmic_data },

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH] ASoC: add api to retrieve dmic array info from coreboot nhlt
  2016-05-19 16:17   ` Zhi, Yong
@ 2016-05-23  5:47     ` Vinod Koul
  2016-05-23 17:01       ` Mark Brown
  0 siblings, 1 reply; 23+ messages in thread
From: Vinod Koul @ 2016-05-23  5:47 UTC (permalink / raw)
  To: Zhi, Yong
  Cc: alsa-devel, Sripathi, Srinivas, Fang, Yang A, Mark Brown, M R,
	Sathya Prakash, Kp, Jeeja, Patel, Vedang

On Thu, May 19, 2016 at 09:47:41PM +0530, Zhi, Yong wrote:
> -----Original Message-----
> From: Mark Brown [mailto:broonie@kernel.org] 
> Sent: Thursday, May 19, 2016 9:02 AM
> To: Zhi, Yong <yong.zhi@intel.com>
> Cc: alsa-devel@alsa-project.org; Koul, Vinod <vinod.koul@intel.com>; Kp, Jeeja <jeeja.kp@intel.com>; Patel, Vedang <vedang.patel@intel.com>; Fang, Yang A <yang.a.fang@intel.com>; M R, Sathya Prakash <sathya.prakash.m.r@intel.com>; Herbert, Marc <marc.herbert@intel.com>; Sripathi, Srinivas <srinivas.sripathi@intel.com>
> Subject: Re: [PATCH] ASoC: add api to retrieve dmic array info from coreboot nhlt
> 
> On Thu, May 19, 2016 at 08:58:59AM -0700, Yong Zhi wrote:
> > skylake can be configured with either both 2 and 4 channel DMIC array, 
> > or 2 channel DMIC array only, this patch provides an API to retrieve 
> > the DMIC info from nhlt.
> 
> What's the difference between this and the similarly titled patch you sent yesterday?
> 
> [YZ], Hi, Mark, the only function change is at line 143 below, found another product that also needs to get DMIC config info yesterday.

Yong,

You please wrap you replies..

The patches are doing two different things, so they should have different
titles mentioning the work the patch is doing.

Also you should consider posting them as a series.

Please update this and post the updated v2.

Thanks
-- 
~Vinod

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH] ASoC: add api to retrieve dmic array info from coreboot nhlt
  2016-05-23  5:47     ` Vinod Koul
@ 2016-05-23 17:01       ` Mark Brown
  0 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2016-05-23 17:01 UTC (permalink / raw)
  To: Vinod Koul
  Cc: alsa-devel, Sripathi, Srinivas, Fang, Yang A, M R,
	Sathya Prakash, Kp, Jeeja, Patel, Vedang, Zhi, Yong


[-- Attachment #1.1: Type: text/plain, Size: 516 bytes --]

On Mon, May 23, 2016 at 11:17:33AM +0530, Vinod Koul wrote:

> > [YZ], Hi, Mark, the only function change is at line 143 below, found another product that also needs to get DMIC config info yesterday.

> The patches are doing two different things, so they should have different
> titles mentioning the work the patch is doing.

> Also you should consider posting them as a series.

> Please update this and post the updated v2.

Definitely, please - I misunderstood the above reply and discarded the
original patch.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v2 1/3] ASoC: Intel: Skylake: Add api to retrieve dmic array info from nhlt
  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-25 13:19 ` Yong Zhi
  2016-05-26  5:23   ` Vinod Koul
                     ` (7 more replies)
  2016-05-25 13:19 ` [PATCH v2 2/3] ASoC: Intel: boards: configure DMIC for machine sklnau8825max Yong Zhi
  2016-05-25 13:19 ` [PATCH v2 3/3] ASoC: Intel: boards: configure DMIC for machine sklnau8825adi Yong Zhi
  3 siblings, 8 replies; 23+ messages in thread
From: Yong Zhi @ 2016-05-25 13:19 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, yang.a.fang,
	sathya.prakash.m.r, jeeja.kp, vedang.patel, Yong Zhi

skylake can be configured with either both 2 and 4 channel DMIC
array, or 2 channel DMIC array only, this patch provides an API to
retrieve the DMIC info from nhlt.

Signed-off-by: Yong Zhi <yong.zhi@intel.com>
---
 sound/soc/intel/skylake/skl-nhlt.c | 37 +++++++++++++++++++++++++++++++++++++
 sound/soc/intel/skylake/skl-nhlt.h | 22 ++++++++++++++++++++++
 sound/soc/intel/skylake/skl.c      | 12 ++++++++++--
 sound/soc/intel/skylake/skl.h      |  6 ++++++
 4 files changed, 75 insertions(+), 2 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-nhlt.c b/sound/soc/intel/skylake/skl-nhlt.c
index 7d73648..be4c4a3 100644
--- a/sound/soc/intel/skylake/skl-nhlt.c
+++ b/sound/soc/intel/skylake/skl-nhlt.c
@@ -18,6 +18,7 @@
  *
  */
 #include "skl.h"
+#include <linux/pci.h>
 
 /* Unique identification for getting NHLT blobs */
 static u8 OSC_UUID[16] = {0x6E, 0x88, 0x9F, 0xA6, 0xEB, 0x6C, 0x94, 0x45,
@@ -149,6 +150,42 @@ struct nhlt_specific_cfg
 	return NULL;
 }
 
+int skl_get_dmic_geo(struct skl *skl)
+{
+	struct nhlt_acpi_table *nhlt = (struct nhlt_acpi_table *)skl->nhlt;
+	struct nhlt_endpoint *epnt;
+	struct nhlt_dmic_array_config *cfg;
+	struct device *dev = &(skl->pci->dev);
+	unsigned int dmic_geo = 0;
+	u8 j;
+
+	epnt = (struct nhlt_endpoint *)nhlt->desc;
+
+	for (j = 0; j < nhlt->endpoint_count; j++) {
+		if (epnt->linktype == NHLT_LINK_DMIC) {
+			cfg = (struct nhlt_dmic_array_config  *)
+					(epnt->config.caps);
+			switch (cfg->array_type) {
+			case NHLT_MIC_ARRAY_2CH_SMALL:
+			case NHLT_MIC_ARRAY_2CH_BIG:
+				dmic_geo |= MIC_ARRAY_2CH;
+				break;
+			case NHLT_MIC_ARRAY_4CH_1ST_GEOM:
+			case NHLT_MIC_ARRAY_4CH_L_SHAPED:
+			case NHLT_MIC_ARRAY_4CH_2ND_GEOM:
+				dmic_geo |= MIC_ARRAY_4CH;
+				break;
+			default:
+				dev_warn(dev, "undefined DMIC array_type 0x%0x\n",
+						cfg->array_type);
+			}
+		}
+		epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length);
+	}
+
+	return dmic_geo;
+}
+
 static void skl_nhlt_trim_space(struct skl *skl)
 {
 	char *s = skl->tplg_name;
diff --git a/sound/soc/intel/skylake/skl-nhlt.h b/sound/soc/intel/skylake/skl-nhlt.h
index 3769f9f..116534e7 100644
--- a/sound/soc/intel/skylake/skl-nhlt.h
+++ b/sound/soc/intel/skylake/skl-nhlt.h
@@ -103,4 +103,26 @@ struct nhlt_resource_desc  {
 	u64 length;
 } __packed;
 
+#define MIC_ARRAY_2CH 2
+#define MIC_ARRAY_4CH 4
+
+struct nhlt_tdm_config {
+	u8 virtual_slot;
+	u8 config_type;
+} __packed;
+
+struct nhlt_dmic_array_config {
+	struct nhlt_tdm_config tdm_config;
+	u8 array_type;
+} __packed;
+
+enum {
+	NHLT_MIC_ARRAY_2CH_SMALL = 0xa,
+	NHLT_MIC_ARRAY_2CH_BIG = 0xb,
+	NHLT_MIC_ARRAY_4CH_1ST_GEOM = 0xc,
+	NHLT_MIC_ARRAY_4CH_L_SHAPED = 0xd,
+	NHLT_MIC_ARRAY_4CH_2ND_GEOM = 0xe,
+	NHLT_MIC_ARRAY_VENDOR_DEFINED = 0xf,
+};
+
 #endif
diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c
index 06d8c26..b0f7226 100644
--- a/sound/soc/intel/skylake/skl.c
+++ b/sound/soc/intel/skylake/skl.c
@@ -35,6 +35,8 @@
 #include "skl-sst-dsp.h"
 #include "skl-sst-ipc.h"
 
+static struct skl_machine_pdata skl_dmic_data;
+
 /*
  * initialize the PCI registers
  */
@@ -397,6 +399,10 @@ static int skl_machine_device_register(struct skl *skl, void *driver_data)
 		platform_device_put(pdev);
 		return -EIO;
 	}
+
+	if (mach->pdata)
+		dev_set_drvdata(&pdev->dev, mach->pdata);
+
 	skl->i2s_dev = pdev;
 
 	return 0;
@@ -666,6 +672,8 @@ static int skl_probe(struct pci_dev *pci,
 
 	pci_set_drvdata(skl->pci, ebus);
 
+	skl_dmic_data.dmic_num = skl_get_dmic_geo(skl);
+
 	/* check if dsp is there */
 	if (ebus->ppcap) {
 		err = skl_machine_device_register(skl,
@@ -787,9 +795,9 @@ static void skl_remove(struct pci_dev *pci)
 static struct sst_acpi_mach sst_skl_devdata[] = {
 	{ "INT343A", "skl_alc286s_i2s", "intel/dsp_fw_release.bin", NULL, NULL, NULL },
 	{ "INT343B", "skl_nau88l25_ssm4567_i2s", "intel/dsp_fw_release.bin",
-				NULL, NULL, NULL },
+				NULL, NULL, &skl_dmic_data },
 	{ "MX98357A", "skl_nau88l25_max98357a_i2s", "intel/dsp_fw_release.bin",
-				NULL, NULL, NULL },
+				NULL, NULL, &skl_dmic_data },
 	{}
 };
 
diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h
index 4b4b387..f66be17 100644
--- a/sound/soc/intel/skylake/skl.h
+++ b/sound/soc/intel/skylake/skl.h
@@ -90,6 +90,11 @@ struct skl_dma_params {
 	u8 stream_tag;
 };
 
+/* to pass dmic data */
+struct skl_machine_pdata {
+	u32 dmic_num;
+};
+
 struct skl_dsp_ops {
 	int id;
 	struct skl_dsp_loader_ops (*loader_ops)(void);
@@ -108,6 +113,7 @@ void skl_nhlt_free(struct nhlt_acpi_table *addr);
 struct nhlt_specific_cfg *skl_get_ep_blob(struct skl *skl, u32 instance,
 			u8 link_type, u8 s_fmt, u8 no_ch, u32 s_rate, u8 dirn);
 
+int skl_get_dmic_geo(struct skl *skl);
 int skl_nhlt_update_topology_bin(struct skl *skl);
 int skl_init_dsp(struct skl *skl);
 int skl_free_dsp(struct skl *skl);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 2/3] ASoC: Intel: boards: configure DMIC for machine sklnau8825max
  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-25 13:19 ` [PATCH v2 1/3] ASoC: Intel: Skylake: Add api to retrieve dmic array info from nhlt Yong Zhi
@ 2016-05-25 13:19 ` Yong Zhi
  2016-05-26  5:24   ` Vinod Koul
  2016-05-25 13:19 ` [PATCH v2 3/3] ASoC: Intel: boards: configure DMIC for machine sklnau8825adi Yong Zhi
  3 siblings, 1 reply; 23+ messages in thread
From: Yong Zhi @ 2016-05-25 13:19 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, yang.a.fang,
	sathya.prakash.m.r, jeeja.kp, vedang.patel, Yong Zhi

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_max98357a.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/sound/soc/intel/boards/skl_nau88l25_max98357a.c b/sound/soc/intel/boards/skl_nau88l25_max98357a.c
index 7cc7251..43fab12 100644
--- a/sound/soc/intel/boards/skl_nau88l25_max98357a.c
+++ b/sound/soc/intel/boards/skl_nau88l25_max98357a.c
@@ -23,12 +23,15 @@
 #include <sound/soc.h>
 #include "../../codecs/nau8825.h"
 #include "../../codecs/hdac_hdmi.h"
+#include "../skylake/skl.h"
 
 #define SKL_NUVOTON_CODEC_DAI	"nau8825-hifi"
 #define SKL_MAXIM_CODEC_DAI "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,
@@ -296,7 +299,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;
@@ -314,13 +317,23 @@ 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);
+			dmic_constraints);
 
 	return snd_pcm_hw_constraint_list(substream->runtime, 0,
 			SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
@@ -550,8 +563,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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 3/3] ASoC: Intel: boards: configure DMIC for machine sklnau8825adi
  2016-05-19 15:58 [PATCH] ASoC: add api to retrieve dmic array info from coreboot nhlt Yong Zhi
                   ` (2 preceding siblings ...)
  2016-05-25 13:19 ` [PATCH v2 2/3] ASoC: Intel: boards: configure DMIC for machine sklnau8825max Yong Zhi
@ 2016-05-25 13:19 ` Yong Zhi
  2016-05-26  5:25   ` Vinod Koul
  3 siblings, 1 reply; 23+ messages in thread
From: Yong Zhi @ 2016-05-25 13:19 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, yang.a.fang,
	sathya.prakash.m.r, jeeja.kp, vedang.patel, Yong Zhi

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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 1/3] ASoC: Intel: Skylake: Add api to retrieve dmic array info from nhlt
  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
                     ` (6 subsequent siblings)
  7 siblings, 0 replies; 23+ messages in thread
From: Vinod Koul @ 2016-05-26  5:23 UTC (permalink / raw)
  To: Yong Zhi
  Cc: alsa-devel, srinivas.sripathi, yang.a.fang, broonie,
	sathya.prakash.m.r, jeeja.kp, vedang.patel

On Wed, May 25, 2016 at 06:19:17AM -0700, Yong Zhi wrote:
> skylake can be configured with either both 2 and 4 channel DMIC

Skylake

> array, or 2 channel DMIC array only, this patch provides an API to
> retrieve the DMIC info from nhlt.
> 
>   *
>   */
>  #include "skl.h"
> +#include <linux/pci.h>

Typical convention is to have standard includes before local ones

> +int skl_get_dmic_geo(struct skl *skl)
> +{
> +	struct nhlt_acpi_table *nhlt = (struct nhlt_acpi_table *)skl->nhlt;
> +	struct nhlt_endpoint *epnt;
> +	struct nhlt_dmic_array_config *cfg;
> +	struct device *dev = &(skl->pci->dev);

i dont think braces are required..

> +	unsigned int dmic_geo = 0;
> +	u8 j;
> +
> +	epnt = (struct nhlt_endpoint *)nhlt->desc;
> +
> +	for (j = 0; j < nhlt->endpoint_count; j++) {
> +		if (epnt->linktype == NHLT_LINK_DMIC) {
> +			cfg = (struct nhlt_dmic_array_config  *)
> +					(epnt->config.caps);
> +			switch (cfg->array_type) {
> +			case NHLT_MIC_ARRAY_2CH_SMALL:
> +			case NHLT_MIC_ARRAY_2CH_BIG:
> +				dmic_geo |= MIC_ARRAY_2CH;
> +				break;

empty line here please

> +			case NHLT_MIC_ARRAY_4CH_1ST_GEOM:
> +			case NHLT_MIC_ARRAY_4CH_L_SHAPED:
> +			case NHLT_MIC_ARRAY_4CH_2ND_GEOM:
> +				dmic_geo |= MIC_ARRAY_4CH;
> +				break;

here too

-- 
~Vinod

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 2/3] ASoC: Intel: boards: configure DMIC for machine sklnau8825max
  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
  0 siblings, 0 replies; 23+ messages in thread
From: Vinod Koul @ 2016-05-26  5:24 UTC (permalink / raw)
  To: Yong Zhi
  Cc: alsa-devel, srinivas.sripathi, yang.a.fang, broonie,
	sathya.prakash.m.r, jeeja.kp, vedang.patel

On Wed, May 25, 2016 at 06:19:38AM -0700, Yong Zhi wrote:
> 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>

Acked-by: Vinod Koul <vinod.koul@intel.com>

-- 
~Vinod

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 3/3] ASoC: Intel: boards: configure DMIC for machine sklnau8825adi
  2016-05-25 13:19 ` [PATCH v2 3/3] ASoC: Intel: boards: configure DMIC for machine sklnau8825adi Yong Zhi
@ 2016-05-26  5:25   ` Vinod Koul
  0 siblings, 0 replies; 23+ messages in thread
From: Vinod Koul @ 2016-05-26  5:25 UTC (permalink / raw)
  To: Yong Zhi
  Cc: alsa-devel, srinivas.sripathi, yang.a.fang, broonie,
	sathya.prakash.m.r, jeeja.kp, vedang.patel

On Wed, May 25, 2016 at 06:19:49AM -0700, Yong Zhi wrote:
> 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>

Acked-by: Vinod Koul <vinod.koul@intel.com>

-- 
~Vinod

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v3 1/5] ASoC: Intel: Skylake: Add api to retrieve dmic array info from nhlt
  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   ` 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
                     ` (5 subsequent siblings)
  7 siblings, 2 replies; 23+ messages in thread
From: Yong Zhi @ 2016-05-27  4:30 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, yang.a.fang,
	sathya.prakash.m.r, jeeja.kp, vedang.patel, Yong Zhi

Skylake can be configured with either both 2 and 4 channel DMIC
array, or 2 channel DMIC array only, this patch provides an API to
retrieve the DMIC info from nhlt.

Signed-off-by: Yong Zhi <yong.zhi@intel.com>
---
 sound/soc/intel/skylake/skl-nhlt.c | 40 ++++++++++++++++++++++++++++++++++++++
 sound/soc/intel/skylake/skl-nhlt.h | 22 +++++++++++++++++++++
 sound/soc/intel/skylake/skl.c      | 12 ++++++++++--
 sound/soc/intel/skylake/skl.h      |  6 ++++++
 4 files changed, 78 insertions(+), 2 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-nhlt.c b/sound/soc/intel/skylake/skl-nhlt.c
index 7d73648..3f8e6f0 100644
--- a/sound/soc/intel/skylake/skl-nhlt.c
+++ b/sound/soc/intel/skylake/skl-nhlt.c
@@ -17,6 +17,7 @@
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *
  */
+#include <linux/pci.h>
 #include "skl.h"
 
 /* Unique identification for getting NHLT blobs */
@@ -149,6 +150,45 @@ struct nhlt_specific_cfg
 	return NULL;
 }
 
+int skl_get_dmic_geo(struct skl *skl)
+{
+	struct nhlt_acpi_table *nhlt = (struct nhlt_acpi_table *)skl->nhlt;
+	struct nhlt_endpoint *epnt;
+	struct nhlt_dmic_array_config *cfg;
+	struct device *dev = &skl->pci->dev;
+	unsigned int dmic_geo = 0;
+	u8 j;
+
+	epnt = (struct nhlt_endpoint *)nhlt->desc;
+
+	for (j = 0; j < nhlt->endpoint_count; j++) {
+		if (epnt->linktype == NHLT_LINK_DMIC) {
+			cfg = (struct nhlt_dmic_array_config  *)
+					(epnt->config.caps);
+			switch (cfg->array_type) {
+			case NHLT_MIC_ARRAY_2CH_SMALL:
+			case NHLT_MIC_ARRAY_2CH_BIG:
+				dmic_geo |= MIC_ARRAY_2CH;
+				break;
+
+			case NHLT_MIC_ARRAY_4CH_1ST_GEOM:
+			case NHLT_MIC_ARRAY_4CH_L_SHAPED:
+			case NHLT_MIC_ARRAY_4CH_2ND_GEOM:
+				dmic_geo |= MIC_ARRAY_4CH;
+				break;
+
+			default:
+				dev_warn(dev, "undefined DMIC array_type 0x%0x\n",
+						cfg->array_type);
+
+			}
+		}
+		epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length);
+	}
+
+	return dmic_geo;
+}
+
 static void skl_nhlt_trim_space(struct skl *skl)
 {
 	char *s = skl->tplg_name;
diff --git a/sound/soc/intel/skylake/skl-nhlt.h b/sound/soc/intel/skylake/skl-nhlt.h
index 3769f9f..116534e7 100644
--- a/sound/soc/intel/skylake/skl-nhlt.h
+++ b/sound/soc/intel/skylake/skl-nhlt.h
@@ -103,4 +103,26 @@ struct nhlt_resource_desc  {
 	u64 length;
 } __packed;
 
+#define MIC_ARRAY_2CH 2
+#define MIC_ARRAY_4CH 4
+
+struct nhlt_tdm_config {
+	u8 virtual_slot;
+	u8 config_type;
+} __packed;
+
+struct nhlt_dmic_array_config {
+	struct nhlt_tdm_config tdm_config;
+	u8 array_type;
+} __packed;
+
+enum {
+	NHLT_MIC_ARRAY_2CH_SMALL = 0xa,
+	NHLT_MIC_ARRAY_2CH_BIG = 0xb,
+	NHLT_MIC_ARRAY_4CH_1ST_GEOM = 0xc,
+	NHLT_MIC_ARRAY_4CH_L_SHAPED = 0xd,
+	NHLT_MIC_ARRAY_4CH_2ND_GEOM = 0xe,
+	NHLT_MIC_ARRAY_VENDOR_DEFINED = 0xf,
+};
+
 #endif
diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c
index 06d8c26..b0f7226 100644
--- a/sound/soc/intel/skylake/skl.c
+++ b/sound/soc/intel/skylake/skl.c
@@ -35,6 +35,8 @@
 #include "skl-sst-dsp.h"
 #include "skl-sst-ipc.h"
 
+static struct skl_machine_pdata skl_dmic_data;
+
 /*
  * initialize the PCI registers
  */
@@ -397,6 +399,10 @@ static int skl_machine_device_register(struct skl *skl, void *driver_data)
 		platform_device_put(pdev);
 		return -EIO;
 	}
+
+	if (mach->pdata)
+		dev_set_drvdata(&pdev->dev, mach->pdata);
+
 	skl->i2s_dev = pdev;
 
 	return 0;
@@ -666,6 +672,8 @@ static int skl_probe(struct pci_dev *pci,
 
 	pci_set_drvdata(skl->pci, ebus);
 
+	skl_dmic_data.dmic_num = skl_get_dmic_geo(skl);
+
 	/* check if dsp is there */
 	if (ebus->ppcap) {
 		err = skl_machine_device_register(skl,
@@ -787,9 +795,9 @@ static void skl_remove(struct pci_dev *pci)
 static struct sst_acpi_mach sst_skl_devdata[] = {
 	{ "INT343A", "skl_alc286s_i2s", "intel/dsp_fw_release.bin", NULL, NULL, NULL },
 	{ "INT343B", "skl_nau88l25_ssm4567_i2s", "intel/dsp_fw_release.bin",
-				NULL, NULL, NULL },
+				NULL, NULL, &skl_dmic_data },
 	{ "MX98357A", "skl_nau88l25_max98357a_i2s", "intel/dsp_fw_release.bin",
-				NULL, NULL, NULL },
+				NULL, NULL, &skl_dmic_data },
 	{}
 };
 
diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h
index 4b4b387..f66be17 100644
--- a/sound/soc/intel/skylake/skl.h
+++ b/sound/soc/intel/skylake/skl.h
@@ -90,6 +90,11 @@ struct skl_dma_params {
 	u8 stream_tag;
 };
 
+/* to pass dmic data */
+struct skl_machine_pdata {
+	u32 dmic_num;
+};
+
 struct skl_dsp_ops {
 	int id;
 	struct skl_dsp_loader_ops (*loader_ops)(void);
@@ -108,6 +113,7 @@ void skl_nhlt_free(struct nhlt_acpi_table *addr);
 struct nhlt_specific_cfg *skl_get_ep_blob(struct skl *skl, u32 instance,
 			u8 link_type, u8 s_fmt, u8 no_ch, u32 s_rate, u8 dirn);
 
+int skl_get_dmic_geo(struct skl *skl);
 int skl_nhlt_update_topology_bin(struct skl *skl);
 int skl_init_dsp(struct skl *skl);
 int skl_free_dsp(struct skl *skl);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v3 2/5] ASoC: Intel: boards: configure DMIC for machine sklnau8825max
  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-27  4:30   ` 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
                     ` (4 subsequent siblings)
  7 siblings, 1 reply; 23+ messages in thread
From: Yong Zhi @ 2016-05-27  4:30 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, yang.a.fang,
	sathya.prakash.m.r, jeeja.kp, vedang.patel, Yong Zhi

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_max98357a.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/sound/soc/intel/boards/skl_nau88l25_max98357a.c b/sound/soc/intel/boards/skl_nau88l25_max98357a.c
index 7cc7251..43fab12 100644
--- a/sound/soc/intel/boards/skl_nau88l25_max98357a.c
+++ b/sound/soc/intel/boards/skl_nau88l25_max98357a.c
@@ -23,12 +23,15 @@
 #include <sound/soc.h>
 #include "../../codecs/nau8825.h"
 #include "../../codecs/hdac_hdmi.h"
+#include "../skylake/skl.h"
 
 #define SKL_NUVOTON_CODEC_DAI	"nau8825-hifi"
 #define SKL_MAXIM_CODEC_DAI "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,
@@ -296,7 +299,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;
@@ -314,13 +317,23 @@ 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);
+			dmic_constraints);
 
 	return snd_pcm_hw_constraint_list(substream->runtime, 0,
 			SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
@@ -550,8 +563,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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v3 3/5] ASoC: Intel: boards: configure DMIC for machine sklnau8825adi
  2016-05-25 13:19 ` [PATCH v2 1/3] ASoC: Intel: Skylake: Add api to retrieve dmic array info from nhlt Yong Zhi
                     ` (2 preceding siblings ...)
  2016-05-27  4:30   ` [PATCH v3 2/5] ASoC: Intel: boards: configure DMIC for machine sklnau8825max Yong Zhi
@ 2016-05-27  4:30   ` Yong Zhi
  2016-05-27  4:31   ` [PATCH v3 4/5] ASoC: Intel: Skylake: Add channel constraints for refcap Yong Zhi
                     ` (3 subsequent siblings)
  7 siblings, 0 replies; 23+ messages in thread
From: Yong Zhi @ 2016-05-27  4:30 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, yang.a.fang,
	sathya.prakash.m.r, jeeja.kp, vedang.patel, Yong Zhi

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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v3 4/5] ASoC: Intel: Skylake: Add channel constraints for refcap
  2016-05-25 13:19 ` [PATCH v2 1/3] ASoC: Intel: Skylake: Add api to retrieve dmic array info from nhlt Yong Zhi
                     ` (3 preceding siblings ...)
  2016-05-27  4:30   ` [PATCH v3 3/5] ASoC: Intel: boards: configure DMIC for machine sklnau8825adi Yong Zhi
@ 2016-05-27  4:31   ` Yong Zhi
  2016-05-27  4:31   ` [PATCH v3 5/5] ASoC: Intel: Skylake: Use refcap device for mono recording Yong Zhi
                     ` (2 subsequent siblings)
  7 siblings, 0 replies; 23+ messages in thread
From: Yong Zhi @ 2016-05-27  4:31 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, yang.a.fang,
	sathya.prakash.m.r, jeeja.kp, vedang.patel, Yong Zhi

Add constraint for ref DMIC to match with the topology firmware
configured for machine sklnau8825max.

Signed-off-by: Yong Zhi <yong.zhi@intel.com>
---
 sound/soc/intel/boards/skl_nau88l25_max98357a.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/sound/soc/intel/boards/skl_nau88l25_max98357a.c b/sound/soc/intel/boards/skl_nau88l25_max98357a.c
index 43fab12..57c3c86 100644
--- a/sound/soc/intel/boards/skl_nau88l25_max98357a.c
+++ b/sound/soc/intel/boards/skl_nau88l25_max98357a.c
@@ -352,8 +352,22 @@ static struct snd_pcm_hw_constraint_list constraints_16000 = {
 	.list  = rates_16000,
 };
 
+static const unsigned int ch_mono[] = {
+	1,
+};
+
+static const struct snd_pcm_hw_constraint_list constraints_refcap = {
+	.count = ARRAY_SIZE(ch_mono),
+	.list  = ch_mono,
+};
+
 static int skylake_refcap_startup(struct snd_pcm_substream *substream)
 {
+	substream->runtime->hw.channels_max = 1;
+	snd_pcm_hw_constraint_list(substream->runtime, 0,
+					SNDRV_PCM_HW_PARAM_CHANNELS,
+					&constraints_refcap);
+
 	return snd_pcm_hw_constraint_list(substream->runtime, 0,
 				SNDRV_PCM_HW_PARAM_RATE,
 				&constraints_16000);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v3 5/5] ASoC: Intel: Skylake: Use refcap device for mono recording
  2016-05-25 13:19 ` [PATCH v2 1/3] ASoC: Intel: Skylake: Add api to retrieve dmic array info from nhlt Yong Zhi
                     ` (4 preceding siblings ...)
  2016-05-27  4:31   ` [PATCH v3 4/5] ASoC: Intel: Skylake: Add channel constraints for refcap Yong Zhi
@ 2016-05-27  4:31   ` Yong Zhi
  2016-05-31 15:22   ` [PATCH v4 1/2] ASoC: Intel: boards: configure DMIC for machine sklnau8825adi Yong Zhi
  2016-05-31 15:24   ` [PATCH v4 2/2] ASoC: Intel: boards: configure DMIC for machine sklnau8825max Yong Zhi
  7 siblings, 0 replies; 23+ messages in thread
From: Yong Zhi @ 2016-05-27  4:31 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, yang.a.fang,
	sathya.prakash.m.r, jeeja.kp, vedang.patel, Yong Zhi

Only mono channel is allowed for refcap device.

Signed-off-by: Yong Zhi <yong.zhi@intel.com>
---
 sound/soc/intel/boards/skl_nau88l25_ssm4567.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c
index d4e174f..d151f1f 100644
--- a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c
+++ b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c
@@ -401,8 +401,22 @@ static struct snd_pcm_hw_constraint_list constraints_16000 = {
 	.list  = rates_16000,
 };
 
+static const unsigned int ch_mono[] = {
+	1,
+};
+
+static const struct snd_pcm_hw_constraint_list constraints_refcap = {
+	.count = ARRAY_SIZE(ch_mono),
+	.list  = ch_mono,
+};
+
 static int skylake_refcap_startup(struct snd_pcm_substream *substream)
 {
+	substream->runtime->hw.channels_max = 1;
+	snd_pcm_hw_constraint_list(substream->runtime, 0,
+					SNDRV_PCM_HW_PARAM_CHANNELS,
+					&constraints_refcap);
+
 	return snd_pcm_hw_constraint_list(substream->runtime, 0,
 			SNDRV_PCM_HW_PARAM_RATE,
 			&constraints_16000);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH v3 1/5] ASoC: Intel: Skylake: Add api to retrieve dmic array info from nhlt
  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
  1 sibling, 0 replies; 23+ messages in thread
From: Vinod Koul @ 2016-05-30  3:35 UTC (permalink / raw)
  To: Yong Zhi
  Cc: alsa-devel, srinivas.sripathi, yang.a.fang, broonie,
	sathya.prakash.m.r, jeeja.kp, vedang.patel

On Thu, May 26, 2016 at 09:30:15PM -0700, Yong Zhi wrote:
> Skylake can be configured with either both 2 and 4 channel DMIC
> array, or 2 channel DMIC array only, this patch provides an API to
> retrieve the DMIC info from nhlt.

All 5 patches:

Acked-by: Vinod Koul <vinod.koul@intel.com>


-- 
~Vinod

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v3 2/5] ASoC: Intel: boards: configure DMIC for machine sklnau8825max
  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
  0 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2016-05-30 17:16 UTC (permalink / raw)
  To: Yong Zhi
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, yang.a.fang,
	sathya.prakash.m.r, jeeja.kp, vedang.patel


[-- Attachment #1.1: Type: text/plain, Size: 242 bytes --]

On Thu, May 26, 2016 at 09:30:26PM -0700, Yong Zhi wrote:
> This machine driver can support 2 or 4 DMIC configuration, so
> apply the ch constraint according to driver pdata.

This doesn't apply against current code, please check and resend.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Applied "ASoC: Intel: Skylake: Add api to retrieve dmic array info from nhlt" to the asoc tree
  2016-05-27  4:30   ` [PATCH v3 1/5] " Yong Zhi
  2016-05-30  3:35     ` Vinod Koul
@ 2016-05-30 17:39     ` Mark Brown
  1 sibling, 0 replies; 23+ messages in thread
From: Mark Brown @ 2016-05-30 17:39 UTC (permalink / raw)
  To: Yong Zhi
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, yang.a.fang, broonie,
	sathya.prakash.m.r, jeeja.kp, vedang.patel

The patch

   ASoC: Intel: Skylake: Add api to retrieve dmic array info from nhlt

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From f65cf7d666371562ef83b487a31e73642f3a3564 Mon Sep 17 00:00:00 2001
From: Yong Zhi <yong.zhi@intel.com>
Date: Thu, 26 May 2016 21:30:15 -0700
Subject: [PATCH] ASoC: Intel: Skylake: Add api to retrieve dmic array info
 from nhlt

Skylake can be configured with either both 2 and 4 channel DMIC
array, or 2 channel DMIC array only, this patch provides an API to
retrieve the DMIC info from nhlt.

Signed-off-by: Yong Zhi <yong.zhi@intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/skylake/skl-nhlt.c | 40 ++++++++++++++++++++++++++++++++++++++
 sound/soc/intel/skylake/skl-nhlt.h | 22 +++++++++++++++++++++
 sound/soc/intel/skylake/skl.c      | 12 ++++++++++--
 sound/soc/intel/skylake/skl.h      |  6 ++++++
 4 files changed, 78 insertions(+), 2 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-nhlt.c b/sound/soc/intel/skylake/skl-nhlt.c
index 7d73648e5f9a..3f8e6f0b7eb5 100644
--- a/sound/soc/intel/skylake/skl-nhlt.c
+++ b/sound/soc/intel/skylake/skl-nhlt.c
@@ -17,6 +17,7 @@
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *
  */
+#include <linux/pci.h>
 #include "skl.h"
 
 /* Unique identification for getting NHLT blobs */
@@ -149,6 +150,45 @@ struct nhlt_specific_cfg
 	return NULL;
 }
 
+int skl_get_dmic_geo(struct skl *skl)
+{
+	struct nhlt_acpi_table *nhlt = (struct nhlt_acpi_table *)skl->nhlt;
+	struct nhlt_endpoint *epnt;
+	struct nhlt_dmic_array_config *cfg;
+	struct device *dev = &skl->pci->dev;
+	unsigned int dmic_geo = 0;
+	u8 j;
+
+	epnt = (struct nhlt_endpoint *)nhlt->desc;
+
+	for (j = 0; j < nhlt->endpoint_count; j++) {
+		if (epnt->linktype == NHLT_LINK_DMIC) {
+			cfg = (struct nhlt_dmic_array_config  *)
+					(epnt->config.caps);
+			switch (cfg->array_type) {
+			case NHLT_MIC_ARRAY_2CH_SMALL:
+			case NHLT_MIC_ARRAY_2CH_BIG:
+				dmic_geo |= MIC_ARRAY_2CH;
+				break;
+
+			case NHLT_MIC_ARRAY_4CH_1ST_GEOM:
+			case NHLT_MIC_ARRAY_4CH_L_SHAPED:
+			case NHLT_MIC_ARRAY_4CH_2ND_GEOM:
+				dmic_geo |= MIC_ARRAY_4CH;
+				break;
+
+			default:
+				dev_warn(dev, "undefined DMIC array_type 0x%0x\n",
+						cfg->array_type);
+
+			}
+		}
+		epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length);
+	}
+
+	return dmic_geo;
+}
+
 static void skl_nhlt_trim_space(struct skl *skl)
 {
 	char *s = skl->tplg_name;
diff --git a/sound/soc/intel/skylake/skl-nhlt.h b/sound/soc/intel/skylake/skl-nhlt.h
index 3769f9fefe2b..116534e7b3c5 100644
--- a/sound/soc/intel/skylake/skl-nhlt.h
+++ b/sound/soc/intel/skylake/skl-nhlt.h
@@ -103,4 +103,26 @@ struct nhlt_resource_desc  {
 	u64 length;
 } __packed;
 
+#define MIC_ARRAY_2CH 2
+#define MIC_ARRAY_4CH 4
+
+struct nhlt_tdm_config {
+	u8 virtual_slot;
+	u8 config_type;
+} __packed;
+
+struct nhlt_dmic_array_config {
+	struct nhlt_tdm_config tdm_config;
+	u8 array_type;
+} __packed;
+
+enum {
+	NHLT_MIC_ARRAY_2CH_SMALL = 0xa,
+	NHLT_MIC_ARRAY_2CH_BIG = 0xb,
+	NHLT_MIC_ARRAY_4CH_1ST_GEOM = 0xc,
+	NHLT_MIC_ARRAY_4CH_L_SHAPED = 0xd,
+	NHLT_MIC_ARRAY_4CH_2ND_GEOM = 0xe,
+	NHLT_MIC_ARRAY_VENDOR_DEFINED = 0xf,
+};
+
 #endif
diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c
index 06d8c263c68f..b0f7226b878f 100644
--- a/sound/soc/intel/skylake/skl.c
+++ b/sound/soc/intel/skylake/skl.c
@@ -35,6 +35,8 @@
 #include "skl-sst-dsp.h"
 #include "skl-sst-ipc.h"
 
+static struct skl_machine_pdata skl_dmic_data;
+
 /*
  * initialize the PCI registers
  */
@@ -397,6 +399,10 @@ static int skl_machine_device_register(struct skl *skl, void *driver_data)
 		platform_device_put(pdev);
 		return -EIO;
 	}
+
+	if (mach->pdata)
+		dev_set_drvdata(&pdev->dev, mach->pdata);
+
 	skl->i2s_dev = pdev;
 
 	return 0;
@@ -666,6 +672,8 @@ static int skl_probe(struct pci_dev *pci,
 
 	pci_set_drvdata(skl->pci, ebus);
 
+	skl_dmic_data.dmic_num = skl_get_dmic_geo(skl);
+
 	/* check if dsp is there */
 	if (ebus->ppcap) {
 		err = skl_machine_device_register(skl,
@@ -787,9 +795,9 @@ static void skl_remove(struct pci_dev *pci)
 static struct sst_acpi_mach sst_skl_devdata[] = {
 	{ "INT343A", "skl_alc286s_i2s", "intel/dsp_fw_release.bin", NULL, NULL, NULL },
 	{ "INT343B", "skl_nau88l25_ssm4567_i2s", "intel/dsp_fw_release.bin",
-				NULL, NULL, NULL },
+				NULL, NULL, &skl_dmic_data },
 	{ "MX98357A", "skl_nau88l25_max98357a_i2s", "intel/dsp_fw_release.bin",
-				NULL, NULL, NULL },
+				NULL, NULL, &skl_dmic_data },
 	{}
 };
 
diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h
index 4b4b3876aea9..f66be173f86b 100644
--- a/sound/soc/intel/skylake/skl.h
+++ b/sound/soc/intel/skylake/skl.h
@@ -90,6 +90,11 @@ struct skl_dma_params {
 	u8 stream_tag;
 };
 
+/* to pass dmic data */
+struct skl_machine_pdata {
+	u32 dmic_num;
+};
+
 struct skl_dsp_ops {
 	int id;
 	struct skl_dsp_loader_ops (*loader_ops)(void);
@@ -108,6 +113,7 @@ void skl_nhlt_free(struct nhlt_acpi_table *addr);
 struct nhlt_specific_cfg *skl_get_ep_blob(struct skl *skl, u32 instance,
 			u8 link_type, u8 s_fmt, u8 no_ch, u32 s_rate, u8 dirn);
 
+int skl_get_dmic_geo(struct skl *skl);
 int skl_nhlt_update_topology_bin(struct skl *skl);
 int skl_init_dsp(struct skl *skl);
 int skl_free_dsp(struct skl *skl);
-- 
2.8.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v4 1/2] ASoC: Intel: boards: configure DMIC for machine sklnau8825adi
  2016-05-25 13:19 ` [PATCH v2 1/3] ASoC: Intel: Skylake: Add api to retrieve dmic array info from nhlt Yong Zhi
                     ` (5 preceding siblings ...)
  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   ` 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
  7 siblings, 1 reply; 23+ messages in thread
From: Yong Zhi @ 2016-05-31 15:22 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, yang.a.fang,
	sathya.prakash.m.r, jeeja.kp, vedang.patel, Yong Zhi

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 | 25 ++++++++++++++++++++++---
 1 file 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 2647d88..22f2e9d 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;
 
 struct skl_hdmi_pcm {
 	struct list_head head;
@@ -367,7 +370,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;
@@ -405,13 +408,23 @@ 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);
+			dmic_constraints);
 
 	return snd_pcm_hw_constraint_list(substream->runtime, 0,
 			SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
@@ -676,6 +689,7 @@ static struct snd_soc_card skylake_audio_card = {
 static int skylake_audio_probe(struct platform_device *pdev)
 {
 	struct skl_nau88125_private *ctx;
+	struct skl_machine_pdata *pdata;
 
 	ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC);
 	if (!ctx)
@@ -686,6 +700,11 @@ static int skylake_audio_probe(struct platform_device *pdev)
 	skylake_audio_card.dev = &pdev->dev;
 	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);
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v4 2/2] ASoC: Intel: boards: configure DMIC for machine sklnau8825max
  2016-05-25 13:19 ` [PATCH v2 1/3] ASoC: Intel: Skylake: Add api to retrieve dmic array info from nhlt Yong Zhi
                     ` (6 preceding siblings ...)
  2016-05-31 15:22   ` [PATCH v4 1/2] ASoC: Intel: boards: configure DMIC for machine sklnau8825adi Yong Zhi
@ 2016-05-31 15:24   ` Yong Zhi
  2016-05-31 17:45     ` Applied "ASoC: Intel: boards: configure DMIC for machine sklnau8825max" to the asoc tree Mark Brown
  7 siblings, 1 reply; 23+ messages in thread
From: Yong Zhi @ 2016-05-31 15:24 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, yang.a.fang,
	sathya.prakash.m.r, jeeja.kp, vedang.patel, Yong Zhi

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_max98357a.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/sound/soc/intel/boards/skl_nau88l25_max98357a.c b/sound/soc/intel/boards/skl_nau88l25_max98357a.c
index fc3f475..afc6f74 100644
--- a/sound/soc/intel/boards/skl_nau88l25_max98357a.c
+++ b/sound/soc/intel/boards/skl_nau88l25_max98357a.c
@@ -23,12 +23,15 @@
 #include <sound/soc.h>
 #include "../../codecs/nau8825.h"
 #include "../../codecs/hdac_hdmi.h"
+#include "../skylake/skl.h"
 
 #define SKL_NUVOTON_CODEC_DAI	"nau8825-hifi"
 #define SKL_MAXIM_CODEC_DAI "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;
 
 struct skl_hdmi_pcm {
 	struct list_head head;
@@ -339,7 +342,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;
@@ -357,13 +360,23 @@ 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);
+			dmic_constraints);
 
 	return snd_pcm_hw_constraint_list(substream->runtime, 0,
 			SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
@@ -624,6 +637,7 @@ static struct snd_soc_card skylake_audio_card = {
 static int skylake_audio_probe(struct platform_device *pdev)
 {
 	struct skl_nau8825_private *ctx;
+	struct skl_machine_pdata *pdata;
 
 	ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC);
 	if (!ctx)
@@ -634,6 +648,11 @@ static int skylake_audio_probe(struct platform_device *pdev)
 	skylake_audio_card.dev = &pdev->dev;
 	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);
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Applied "ASoC: Intel: boards: configure DMIC for machine sklnau8825max" to the asoc tree
  2016-05-31 15:24   ` [PATCH v4 2/2] ASoC: Intel: boards: configure DMIC for machine sklnau8825max Yong Zhi
@ 2016-05-31 17:45     ` Mark Brown
  0 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2016-05-31 17:45 UTC (permalink / raw)
  To: Yong Zhi
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, yang.a.fang, broonie,
	sathya.prakash.m.r, jeeja.kp, vedang.patel

The patch

   ASoC: Intel: boards: configure DMIC for machine sklnau8825max

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 05282c7751e865df69301927e9b311b28f2fe416 Mon Sep 17 00:00:00 2001
From: Yong Zhi <yong.zhi@intel.com>
Date: Tue, 31 May 2016 10:24:03 -0500
Subject: [PATCH] ASoC: Intel: boards: configure DMIC for machine sklnau8825max

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>
---
 sound/soc/intel/boards/skl_nau88l25_max98357a.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/sound/soc/intel/boards/skl_nau88l25_max98357a.c b/sound/soc/intel/boards/skl_nau88l25_max98357a.c
index fc3f4750c432..afc6f744dff1 100644
--- a/sound/soc/intel/boards/skl_nau88l25_max98357a.c
+++ b/sound/soc/intel/boards/skl_nau88l25_max98357a.c
@@ -23,12 +23,15 @@
 #include <sound/soc.h>
 #include "../../codecs/nau8825.h"
 #include "../../codecs/hdac_hdmi.h"
+#include "../skylake/skl.h"
 
 #define SKL_NUVOTON_CODEC_DAI	"nau8825-hifi"
 #define SKL_MAXIM_CODEC_DAI "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;
 
 struct skl_hdmi_pcm {
 	struct list_head head;
@@ -339,7 +342,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;
@@ -357,13 +360,23 @@ 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);
+			dmic_constraints);
 
 	return snd_pcm_hw_constraint_list(substream->runtime, 0,
 			SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
@@ -624,6 +637,7 @@ static struct snd_soc_card skylake_audio_card = {
 static int skylake_audio_probe(struct platform_device *pdev)
 {
 	struct skl_nau8825_private *ctx;
+	struct skl_machine_pdata *pdata;
 
 	ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC);
 	if (!ctx)
@@ -634,6 +648,11 @@ static int skylake_audio_probe(struct platform_device *pdev)
 	skylake_audio_card.dev = &pdev->dev;
 	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);
 }
 
-- 
2.8.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Applied "ASoC: Intel: boards: configure DMIC for machine sklnau8825adi" to the asoc tree
  2016-05-31 15:22   ` [PATCH v4 1/2] ASoC: Intel: boards: configure DMIC for machine sklnau8825adi Yong Zhi
@ 2016-05-31 17:45     ` Mark Brown
  0 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2016-05-31 17:45 UTC (permalink / raw)
  To: Yong Zhi
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, yang.a.fang, broonie,
	sathya.prakash.m.r, jeeja.kp, vedang.patel

The patch

   ASoC: Intel: boards: configure DMIC for machine sklnau8825adi

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From cfa12367f8e032e515853a3ae12545dee18b9806 Mon Sep 17 00:00:00 2001
From: Yong Zhi <yong.zhi@intel.com>
Date: Tue, 31 May 2016 10:22:48 -0500
Subject: [PATCH] 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>
---
 sound/soc/intel/boards/skl_nau88l25_ssm4567.c | 25 ++++++++++++++++++++++---
 1 file 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 @@
 #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;
 
 struct skl_hdmi_pcm {
 	struct list_head head;
@@ -367,7 +370,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;
@@ -405,13 +408,23 @@ 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);
+			dmic_constraints);
 
 	return snd_pcm_hw_constraint_list(substream->runtime, 0,
 			SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
@@ -676,6 +689,7 @@ static struct snd_soc_card skylake_audio_card = {
 static int skylake_audio_probe(struct platform_device *pdev)
 {
 	struct skl_nau88125_private *ctx;
+	struct skl_machine_pdata *pdata;
 
 	ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC);
 	if (!ctx)
@@ -686,6 +700,11 @@ static int skylake_audio_probe(struct platform_device *pdev)
 	skylake_audio_card.dev = &pdev->dev;
 	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);
 }
 
-- 
2.8.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2016-05-31 17:45 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH v2 3/3] ASoC: Intel: boards: configure DMIC for machine sklnau8825adi Yong Zhi
2016-05-26  5:25   ` Vinod Koul

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.