All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: amd: add logic to check dmic hardware runtime
@ 2020-06-20 12:04 Vijendar Mukunda
  2020-06-22 13:27 ` Jaroslav Kysela
  0 siblings, 1 reply; 6+ messages in thread
From: Vijendar Mukunda @ 2020-06-20 12:04 UTC (permalink / raw)
  To: alsa-devel
  Cc: Alexander.Deucher, hui.wang, Virendra-Pratap.Arya, Vijendar Mukunda

Add logic to check DMIC hardware exists or not on
the platform at runtime.

Add module param for overriding DMIC hardware check
at runtime.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
---
 sound/soc/amd/renoir/rn-pci-acp3x.c | 29 +++++++++++++++++++++++++++++
 sound/soc/amd/renoir/rn_acp3x.h     |  7 +++++++
 2 files changed, 36 insertions(+)

diff --git a/sound/soc/amd/renoir/rn-pci-acp3x.c b/sound/soc/amd/renoir/rn-pci-acp3x.c
index 859ed67..ef6eeba 100644
--- a/sound/soc/amd/renoir/rn-pci-acp3x.c
+++ b/sound/soc/amd/renoir/rn-pci-acp3x.c
@@ -5,6 +5,7 @@
 //Copyright 2020 Advanced Micro Devices, Inc.
 
 #include <linux/pci.h>
+#include <linux/acpi.h>
 #include <linux/module.h>
 #include <linux/io.h>
 #include <linux/delay.h>
@@ -18,6 +19,16 @@ static int acp_power_gating;
 module_param(acp_power_gating, int, 0644);
 MODULE_PARM_DESC(acp_power_gating, "Enable acp power gating");
 
+/**
+ * dmic_acpi_check = 0 - Skips DMIC device creation and returns probe failure
+ *                 = 1 - Assumes that platform has DMIC support and skips ACPI
+ *                       method check
+ *                 = 2 - Checks ACPI method to know DMIC hardware status runtime
+ */
+static int dmic_acpi_check = ACP_DMIC_AUTO;
+module_param(dmic_acpi_check, int, 0644);
+MODULE_PARM_DESC(dmic_acpi_check, "checks Dmic hardware runtime");
+
 struct acp_dev_data {
 	void __iomem *acp_base;
 	struct resource *res;
@@ -157,6 +168,8 @@ static int snd_rn_acp_probe(struct pci_dev *pci,
 {
 	struct acp_dev_data *adata;
 	struct platform_device_info pdevinfo[ACP_DEVS];
+	acpi_handle handle;
+	acpi_integer dmic_status;
 	unsigned int irqflags;
 	int ret, index;
 	u32 addr;
@@ -201,6 +214,22 @@ static int snd_rn_acp_probe(struct pci_dev *pci,
 	if (ret)
 		goto disable_msi;
 
+	if (!dmic_acpi_check) {
+		ret = -ENODEV;
+		goto de_init;
+	} else if (dmic_acpi_check == ACP_DMIC_AUTO) {
+		handle = ACPI_HANDLE(&pci->dev);
+		ret = acpi_evaluate_integer(handle, "_WOV", NULL, &dmic_status);
+		if (ACPI_FAILURE(ret)) {
+			ret = -EINVAL;
+			goto de_init;
+		}
+		if (!dmic_status) {
+			ret = -ENODEV;
+			goto de_init;
+		}
+	}
+
 	adata->res = devm_kzalloc(&pci->dev,
 				  sizeof(struct resource) * 2,
 				  GFP_KERNEL);
diff --git a/sound/soc/amd/renoir/rn_acp3x.h b/sound/soc/amd/renoir/rn_acp3x.h
index 75228e3..fcc5dca 100644
--- a/sound/soc/amd/renoir/rn_acp3x.h
+++ b/sound/soc/amd/renoir/rn_acp3x.h
@@ -55,6 +55,13 @@
 
 #define MAX_BUFFER (CAPTURE_MAX_PERIOD_SIZE * CAPTURE_MAX_NUM_PERIODS)
 #define MIN_BUFFER MAX_BUFFER
+
+enum acp_dmic_audio {
+	ACP_DMIC_DISABLE = 0,
+	ACP_DMIC_ENABLE,
+	ACP_DMIC_AUTO
+};
+
 struct pdm_dev_data {
 	u32 pdm_irq;
 	void __iomem *acp_base;
-- 
2.7.4


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

* Re: [PATCH] ASoC: amd: add logic to check dmic hardware runtime
  2020-06-20 12:04 [PATCH] ASoC: amd: add logic to check dmic hardware runtime Vijendar Mukunda
@ 2020-06-22 13:27 ` Jaroslav Kysela
  2020-06-22 13:52   ` Takashi Iwai
  0 siblings, 1 reply; 6+ messages in thread
From: Jaroslav Kysela @ 2020-06-22 13:27 UTC (permalink / raw)
  To: Vijendar Mukunda, alsa-devel
  Cc: Alexander.Deucher, hui.wang, Virendra-Pratap.Arya

Dne 20. 06. 20 v 14:04 Vijendar Mukunda napsal(a):
> Add logic to check DMIC hardware exists or not on
> the platform at runtime.
> 
> Add module param for overriding DMIC hardware check
> at runtime.
> 
> Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
> ---
>   sound/soc/amd/renoir/rn-pci-acp3x.c | 29 +++++++++++++++++++++++++++++
>   sound/soc/amd/renoir/rn_acp3x.h     |  7 +++++++
>   2 files changed, 36 insertions(+)
> 
> diff --git a/sound/soc/amd/renoir/rn-pci-acp3x.c b/sound/soc/amd/renoir/rn-pci-acp3x.c
> index 859ed67..ef6eeba 100644
> --- a/sound/soc/amd/renoir/rn-pci-acp3x.c
> +++ b/sound/soc/amd/renoir/rn-pci-acp3x.c
> @@ -5,6 +5,7 @@
>   //Copyright 2020 Advanced Micro Devices, Inc.
>   
>   #include <linux/pci.h>
> +#include <linux/acpi.h>
>   #include <linux/module.h>
>   #include <linux/io.h>
>   #include <linux/delay.h>
> @@ -18,6 +19,16 @@ static int acp_power_gating;
>   module_param(acp_power_gating, int, 0644);
>   MODULE_PARM_DESC(acp_power_gating, "Enable acp power gating");
>   
> +/**
> + * dmic_acpi_check = 0 - Skips DMIC device creation and returns probe failure
> + *                 = 1 - Assumes that platform has DMIC support and skips ACPI
> + *                       method check
> + *                 = 2 - Checks ACPI method to know DMIC hardware status runtime
> + */
> +static int dmic_acpi_check = ACP_DMIC_AUTO;

I would prefer to have 0 = auto, 1 = force, 2 = skip to put the 
dmic_acpi_check variable to BSS. Otherwise the patch looks good. Thanks.

					Jaroslav
-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

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

* Re: [PATCH] ASoC: amd: add logic to check dmic hardware runtime
  2020-06-22 13:27 ` Jaroslav Kysela
@ 2020-06-22 13:52   ` Takashi Iwai
  0 siblings, 0 replies; 6+ messages in thread
From: Takashi Iwai @ 2020-06-22 13:52 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Alexander.Deucher, hui.wang, alsa-devel, Virendra-Pratap.Arya,
	Vijendar Mukunda

On Mon, 22 Jun 2020 15:27:25 +0200,
Jaroslav Kysela wrote:
> 
> Dne 20. 06. 20 v 14:04 Vijendar Mukunda napsal(a):
> > Add logic to check DMIC hardware exists or not on
> > the platform at runtime.
> >
> > Add module param for overriding DMIC hardware check
> > at runtime.
> >
> > Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
> > ---
> >   sound/soc/amd/renoir/rn-pci-acp3x.c | 29 +++++++++++++++++++++++++++++
> >   sound/soc/amd/renoir/rn_acp3x.h     |  7 +++++++
> >   2 files changed, 36 insertions(+)
> >
> > diff --git a/sound/soc/amd/renoir/rn-pci-acp3x.c b/sound/soc/amd/renoir/rn-pci-acp3x.c
> > index 859ed67..ef6eeba 100644
> > --- a/sound/soc/amd/renoir/rn-pci-acp3x.c
> > +++ b/sound/soc/amd/renoir/rn-pci-acp3x.c
> > @@ -5,6 +5,7 @@
> >   //Copyright 2020 Advanced Micro Devices, Inc.
> >     #include <linux/pci.h>
> > +#include <linux/acpi.h>
> >   #include <linux/module.h>
> >   #include <linux/io.h>
> >   #include <linux/delay.h>
> > @@ -18,6 +19,16 @@ static int acp_power_gating;
> >   module_param(acp_power_gating, int, 0644);
> >   MODULE_PARM_DESC(acp_power_gating, "Enable acp power gating");
> >   +/**
> > + * dmic_acpi_check = 0 - Skips DMIC device creation and returns probe failure
> > + *                 = 1 - Assumes that platform has DMIC support and skips ACPI
> > + *                       method check
> > + *                 = 2 - Checks ACPI method to know DMIC hardware status runtime
> > + */
> > +static int dmic_acpi_check = ACP_DMIC_AUTO;
> 
> I would prefer to have 0 = auto, 1 = force, 2 = skip to put the
> dmic_acpi_check variable to BSS. Otherwise the patch looks
> good. Thanks.

It's "bint" module parameter type is used for this kind of flag, which
implies:
	-1 = auto, whatever the default
	0 = disable
	1 = enable

Then user can pass dmic_acpi_check=1 or dmic_acpi_check=true (or on)
to explicitly enable the flag.


Takashi

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

* Re: [PATCH] ASoC: amd: add logic to check dmic hardware runtime
  2020-06-23 20:27 Vijendar Mukunda
  2020-06-23 20:25 ` Deucher, Alexander
@ 2020-06-23 21:44 ` Jaroslav Kysela
  1 sibling, 0 replies; 6+ messages in thread
From: Jaroslav Kysela @ 2020-06-23 21:44 UTC (permalink / raw)
  To: Vijendar Mukunda, alsa-devel
  Cc: Alexander.Deucher, hui.wang, Virendra-Pratap.Arya

Dne 23. 06. 20 v 22:27 Vijendar Mukunda napsal(a):
> Add logic to check DMIC hardware exists or not on
> the platform at runtime.
> 
> Add module param for overriding DMIC hardware check
> at runtime.
> 
> Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
> ---
>   sound/soc/amd/renoir/rn-pci-acp3x.c | 29 +++++++++++++++++++++++++++++
>   sound/soc/amd/renoir/rn_acp3x.h     |  2 ++
>   2 files changed, 31 insertions(+)
> 
> diff --git a/sound/soc/amd/renoir/rn-pci-acp3x.c b/sound/soc/amd/renoir/rn-pci-acp3x.c
> index 859ed67..faa7566 100644
> --- a/sound/soc/amd/renoir/rn-pci-acp3x.c
> +++ b/sound/soc/amd/renoir/rn-pci-acp3x.c
> @@ -5,6 +5,7 @@
>   //Copyright 2020 Advanced Micro Devices, Inc.
>   
>   #include <linux/pci.h>
> +#include <linux/acpi.h>
>   #include <linux/module.h>
>   #include <linux/io.h>
>   #include <linux/delay.h>
> @@ -18,6 +19,16 @@ static int acp_power_gating;
>   module_param(acp_power_gating, int, 0644);
>   MODULE_PARM_DESC(acp_power_gating, "Enable acp power gating");
>   
> +/**
> + * dmic_acpi_check = -1 - Checks ACPI method to know DMIC hardware status runtime
> + *                 = 0 - Skips the DMIC device creation and returns probe failure
> + *                 = 1 - Assumes that platform has DMIC support and skips ACPI
> + *                       method check
> + */
> +static int dmic_acpi_check = ACP_DMIC_AUTO;
> +module_param(dmic_acpi_check, int, 0644);

I think that Takashi suggested the bint (boolean/integer type here):

   module_param(dmic_acpi_check, bint, 0644);

					Jaroslav

-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

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

* [PATCH] ASoC: amd: add logic to check dmic hardware runtime
@ 2020-06-23 20:27 Vijendar Mukunda
  2020-06-23 20:25 ` Deucher, Alexander
  2020-06-23 21:44 ` Jaroslav Kysela
  0 siblings, 2 replies; 6+ messages in thread
From: Vijendar Mukunda @ 2020-06-23 20:27 UTC (permalink / raw)
  To: perex, alsa-devel
  Cc: Alexander.Deucher, hui.wang, Virendra-Pratap.Arya, Vijendar Mukunda

Add logic to check DMIC hardware exists or not on
the platform at runtime.

Add module param for overriding DMIC hardware check
at runtime.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
---
 sound/soc/amd/renoir/rn-pci-acp3x.c | 29 +++++++++++++++++++++++++++++
 sound/soc/amd/renoir/rn_acp3x.h     |  2 ++
 2 files changed, 31 insertions(+)

diff --git a/sound/soc/amd/renoir/rn-pci-acp3x.c b/sound/soc/amd/renoir/rn-pci-acp3x.c
index 859ed67..faa7566 100644
--- a/sound/soc/amd/renoir/rn-pci-acp3x.c
+++ b/sound/soc/amd/renoir/rn-pci-acp3x.c
@@ -5,6 +5,7 @@
 //Copyright 2020 Advanced Micro Devices, Inc.
 
 #include <linux/pci.h>
+#include <linux/acpi.h>
 #include <linux/module.h>
 #include <linux/io.h>
 #include <linux/delay.h>
@@ -18,6 +19,16 @@ static int acp_power_gating;
 module_param(acp_power_gating, int, 0644);
 MODULE_PARM_DESC(acp_power_gating, "Enable acp power gating");
 
+/**
+ * dmic_acpi_check = -1 - Checks ACPI method to know DMIC hardware status runtime
+ *                 = 0 - Skips the DMIC device creation and returns probe failure
+ *                 = 1 - Assumes that platform has DMIC support and skips ACPI
+ *                       method check
+ */
+static int dmic_acpi_check = ACP_DMIC_AUTO;
+module_param(dmic_acpi_check, int, 0644);
+MODULE_PARM_DESC(dmic_acpi_check, "checks Dmic hardware runtime");
+
 struct acp_dev_data {
 	void __iomem *acp_base;
 	struct resource *res;
@@ -157,6 +168,8 @@ static int snd_rn_acp_probe(struct pci_dev *pci,
 {
 	struct acp_dev_data *adata;
 	struct platform_device_info pdevinfo[ACP_DEVS];
+	acpi_handle handle;
+	acpi_integer dmic_status;
 	unsigned int irqflags;
 	int ret, index;
 	u32 addr;
@@ -201,6 +214,22 @@ static int snd_rn_acp_probe(struct pci_dev *pci,
 	if (ret)
 		goto disable_msi;
 
+	if (!dmic_acpi_check) {
+		ret = -ENODEV;
+		goto de_init;
+	} else if (dmic_acpi_check == ACP_DMIC_AUTO) {
+		handle = ACPI_HANDLE(&pci->dev);
+		ret = acpi_evaluate_integer(handle, "_WOV", NULL, &dmic_status);
+		if (ACPI_FAILURE(ret)) {
+			ret = -EINVAL;
+			goto de_init;
+		}
+		if (!dmic_status) {
+			ret = -ENODEV;
+			goto de_init;
+		}
+	}
+
 	adata->res = devm_kzalloc(&pci->dev,
 				  sizeof(struct resource) * 2,
 				  GFP_KERNEL);
diff --git a/sound/soc/amd/renoir/rn_acp3x.h b/sound/soc/amd/renoir/rn_acp3x.h
index 75228e3..1462039 100644
--- a/sound/soc/amd/renoir/rn_acp3x.h
+++ b/sound/soc/amd/renoir/rn_acp3x.h
@@ -55,6 +55,8 @@
 
 #define MAX_BUFFER (CAPTURE_MAX_PERIOD_SIZE * CAPTURE_MAX_NUM_PERIODS)
 #define MIN_BUFFER MAX_BUFFER
+#define	ACP_DMIC_AUTO   -1
+
 struct pdm_dev_data {
 	u32 pdm_irq;
 	void __iomem *acp_base;
-- 
2.7.4


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

* RE: [PATCH] ASoC: amd: add logic to check dmic hardware runtime
  2020-06-23 20:27 Vijendar Mukunda
@ 2020-06-23 20:25 ` Deucher, Alexander
  2020-06-23 21:44 ` Jaroslav Kysela
  1 sibling, 0 replies; 6+ messages in thread
From: Deucher, Alexander @ 2020-06-23 20:25 UTC (permalink / raw)
  To: Mukunda, Vijendar, perex, alsa-devel
  Cc: hui.wang, Arya, Virendra-Pratap, Mukunda, Vijendar

[AMD Public Use]

> -----Original Message-----
> From: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
> Sent: Tuesday, June 23, 2020 4:27 PM
> To: perex@perex.cz; alsa-devel@alsa-project.org
> Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; Arya, Virendra-
> Pratap <Virendra-Pratap.Arya@amd.com>; hui.wang@canonical.com;
> Mukunda, Vijendar <Vijendar.Mukunda@amd.com>
> Subject: [PATCH] ASoC: amd: add logic to check dmic hardware runtime
> 
> Add logic to check DMIC hardware exists or not on the platform at runtime.
> 
> Add module param for overriding DMIC hardware check at runtime.
> 
> Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  sound/soc/amd/renoir/rn-pci-acp3x.c | 29
> +++++++++++++++++++++++++++++
>  sound/soc/amd/renoir/rn_acp3x.h     |  2 ++
>  2 files changed, 31 insertions(+)
> 
> diff --git a/sound/soc/amd/renoir/rn-pci-acp3x.c
> b/sound/soc/amd/renoir/rn-pci-acp3x.c
> index 859ed67..faa7566 100644
> --- a/sound/soc/amd/renoir/rn-pci-acp3x.c
> +++ b/sound/soc/amd/renoir/rn-pci-acp3x.c
> @@ -5,6 +5,7 @@
>  //Copyright 2020 Advanced Micro Devices, Inc.
> 
>  #include <linux/pci.h>
> +#include <linux/acpi.h>
>  #include <linux/module.h>
>  #include <linux/io.h>
>  #include <linux/delay.h>
> @@ -18,6 +19,16 @@ static int acp_power_gating;
> module_param(acp_power_gating, int, 0644);
> MODULE_PARM_DESC(acp_power_gating, "Enable acp power gating");
> 
> +/**
> + * dmic_acpi_check = -1 - Checks ACPI method to know DMIC hardware
> status runtime
> + *                 = 0 - Skips the DMIC device creation and returns probe failure
> + *                 = 1 - Assumes that platform has DMIC support and skips ACPI
> + *                       method check
> + */
> +static int dmic_acpi_check = ACP_DMIC_AUTO;
> +module_param(dmic_acpi_check, int, 0644);
> +MODULE_PARM_DESC(dmic_acpi_check, "checks Dmic hardware
> runtime");
> +
>  struct acp_dev_data {
>  	void __iomem *acp_base;
>  	struct resource *res;
> @@ -157,6 +168,8 @@ static int snd_rn_acp_probe(struct pci_dev *pci,  {
>  	struct acp_dev_data *adata;
>  	struct platform_device_info pdevinfo[ACP_DEVS];
> +	acpi_handle handle;
> +	acpi_integer dmic_status;
>  	unsigned int irqflags;
>  	int ret, index;
>  	u32 addr;
> @@ -201,6 +214,22 @@ static int snd_rn_acp_probe(struct pci_dev *pci,
>  	if (ret)
>  		goto disable_msi;
> 
> +	if (!dmic_acpi_check) {
> +		ret = -ENODEV;
> +		goto de_init;
> +	} else if (dmic_acpi_check == ACP_DMIC_AUTO) {
> +		handle = ACPI_HANDLE(&pci->dev);
> +		ret = acpi_evaluate_integer(handle, "_WOV", NULL,
> &dmic_status);
> +		if (ACPI_FAILURE(ret)) {
> +			ret = -EINVAL;
> +			goto de_init;
> +		}
> +		if (!dmic_status) {
> +			ret = -ENODEV;
> +			goto de_init;
> +		}
> +	}
> +
>  	adata->res = devm_kzalloc(&pci->dev,
>  				  sizeof(struct resource) * 2,
>  				  GFP_KERNEL);
> diff --git a/sound/soc/amd/renoir/rn_acp3x.h
> b/sound/soc/amd/renoir/rn_acp3x.h index 75228e3..1462039 100644
> --- a/sound/soc/amd/renoir/rn_acp3x.h
> +++ b/sound/soc/amd/renoir/rn_acp3x.h
> @@ -55,6 +55,8 @@
> 
>  #define MAX_BUFFER (CAPTURE_MAX_PERIOD_SIZE *
> CAPTURE_MAX_NUM_PERIODS)  #define MIN_BUFFER MAX_BUFFER
> +#define	ACP_DMIC_AUTO   -1
> +
>  struct pdm_dev_data {
>  	u32 pdm_irq;
>  	void __iomem *acp_base;
> --
> 2.7.4

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

end of thread, other threads:[~2020-06-23 21:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-20 12:04 [PATCH] ASoC: amd: add logic to check dmic hardware runtime Vijendar Mukunda
2020-06-22 13:27 ` Jaroslav Kysela
2020-06-22 13:52   ` Takashi Iwai
2020-06-23 20:27 Vijendar Mukunda
2020-06-23 20:25 ` Deucher, Alexander
2020-06-23 21:44 ` Jaroslav Kysela

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.