devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: codecs: dmic: Make number of channels configurable
@ 2018-01-05 20:39 Matthias Kaehlcke
       [not found] ` <20180105203957.184883-1-mka-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Matthias Kaehlcke @ 2018-01-05 20:39 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Rob Herring, Mark Rutland
  Cc: alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Bhumika Goyal,
	Arnaud Pouliquen, huang lin, Brian Norris, Dylan Reid,
	Matthias Kaehlcke

The DMIC DAI driver specifies a number of 1 to 8 channels for each DAI.
The actual number of mics can currently not be configured in the device
tree or audio glue, but is derived from the min/max channels of the CPU
and codec DAI. A typical CPU DAI has two or more channels, in consequence
a single mic is treated as a stereo/multi channel device, even though
only one channel carries audio data.

This change adds the option to specify the number of used DMIC channels
in the device tree. When specified this value overwrites the default
channels_max value of 8 in the snd_soc_dai_driver struct of the codec.

Signed-off-by: Matthias Kaehlcke <mka-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
 Documentation/devicetree/bindings/sound/dmic.txt |  2 ++
 sound/soc/codecs/dmic.c                          | 24 +++++++++++++++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/sound/dmic.txt b/Documentation/devicetree/bindings/sound/dmic.txt
index 54c8ef6498a8..f7bf65611453 100644
--- a/Documentation/devicetree/bindings/sound/dmic.txt
+++ b/Documentation/devicetree/bindings/sound/dmic.txt
@@ -7,10 +7,12 @@ Required properties:
 
 Optional properties:
 	- dmicen-gpios: GPIO specifier for dmic to control start and stop
+	- num-channels: Number of microphones on this DAI
 
 Example node:
 
 	dmic_codec: dmic@0 {
 		compatible = "dmic-codec";
 		dmicen-gpios = <&gpio4 3 GPIO_ACTIVE_HIGH>;
+		num-channels = <1>;
 	};
diff --git a/sound/soc/codecs/dmic.c b/sound/soc/codecs/dmic.c
index b88a1ee66f80..c88f974ebe3e 100644
--- a/sound/soc/codecs/dmic.c
+++ b/sound/soc/codecs/dmic.c
@@ -107,8 +107,30 @@ static const struct snd_soc_codec_driver soc_dmic = {
 
 static int dmic_dev_probe(struct platform_device *pdev)
 {
+	int err;
+	u32 chans;
+	struct snd_soc_dai_driver *dai_drv = &dmic_dai;
+
+	if (pdev->dev.of_node) {
+		err = of_property_read_u32(pdev->dev.of_node, "num-channels", &chans);
+		if (err && (err != -ENOENT))
+			return err;
+
+		if (!err) {
+			if (chans < 1 || chans > 8)
+				return -EINVAL;
+
+			dai_drv = devm_kzalloc(&pdev->dev, sizeof(*dai_drv), GFP_KERNEL);
+			if (!dai_drv)
+				return -ENOMEM;
+
+			memcpy(dai_drv, &dmic_dai, sizeof(*dai_drv));
+			dai_drv->capture.channels_max = chans;
+		}
+	}
+
 	return snd_soc_register_codec(&pdev->dev,
-			&soc_dmic, &dmic_dai, 1);
+			&soc_dmic, dai_drv, 1);
 }
 
 static int dmic_dev_remove(struct platform_device *pdev)
-- 
2.16.0.rc0.223.g4a4ac83678-goog

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] ASoC: codecs: dmic: Make number of channels configurable
       [not found] ` <20180105203957.184883-1-mka-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
@ 2018-01-09  4:17   ` Rob Herring
  0 siblings, 0 replies; 4+ messages in thread
From: Rob Herring @ 2018-01-09  4:17 UTC (permalink / raw)
  To: Matthias Kaehlcke
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Mark Rutland, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Bhumika Goyal,
	Arnaud Pouliquen, huang lin, Brian Norris, Dylan Reid

On Fri, Jan 05, 2018 at 12:39:57PM -0800, Matthias Kaehlcke wrote:
> The DMIC DAI driver specifies a number of 1 to 8 channels for each DAI.
> The actual number of mics can currently not be configured in the device
> tree or audio glue, but is derived from the min/max channels of the CPU
> and codec DAI. A typical CPU DAI has two or more channels, in consequence
> a single mic is treated as a stereo/multi channel device, even though
> only one channel carries audio data.
> 
> This change adds the option to specify the number of used DMIC channels
> in the device tree. When specified this value overwrites the default
> channels_max value of 8 in the snd_soc_dai_driver struct of the codec.
> 
> Signed-off-by: Matthias Kaehlcke <mka-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> ---
>  Documentation/devicetree/bindings/sound/dmic.txt |  2 ++

Reviewed-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

>  sound/soc/codecs/dmic.c                          | 24 +++++++++++++++++++++++-
>  2 files changed, 25 insertions(+), 1 deletion(-)
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] ASoC: codecs: dmic: Make number of channels configurable
  2018-01-05 20:39 [PATCH] ASoC: codecs: dmic: Make number of channels configurable Matthias Kaehlcke
       [not found] ` <20180105203957.184883-1-mka-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
@ 2018-01-09  9:04 ` Arnaud Pouliquen
  2018-01-09 17:43 ` Applied "ASoC: codecs: dmic: Make number of channels configurable" to the asoc tree Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Arnaud Pouliquen @ 2018-01-09  9:04 UTC (permalink / raw)
  To: Matthias Kaehlcke, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Rob Herring, Mark Rutland
  Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
	huang lin, Brian Norris, linux-kernel@vger.kernel.org, Dylan Reid,
	Bhumika Goyal

Hello Mathias,

Next time could you add patch version in your mail subject ( [PATCH vX])
easier to follow versions :-).

otherwise,

Acked-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>

Regards,
Arnaud

On 01/05/2018 09:39 PM, Matthias Kaehlcke wrote:
> The DMIC DAI driver specifies a number of 1 to 8 channels for each DAI.
> The actual number of mics can currently not be configured in the device
> tree or audio glue, but is derived from the min/max channels of the CPU
> and codec DAI. A typical CPU DAI has two or more channels, in consequence
> a single mic is treated as a stereo/multi channel device, even though
> only one channel carries audio data.
> 
> This change adds the option to specify the number of used DMIC channels
> in the device tree. When specified this value overwrites the default
> channels_max value of 8 in the snd_soc_dai_driver struct of the codec.
> 
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> ---
>  Documentation/devicetree/bindings/sound/dmic.txt |  2 ++
>  sound/soc/codecs/dmic.c                          | 24
> +++++++++++++++++++++++-
>  2 files changed, 25 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/sound/dmic.txt
> b/Documentation/devicetree/bindings/sound/dmic.txt
> index 54c8ef6498a8..f7bf65611453 100644
> --- a/Documentation/devicetree/bindings/sound/dmic.txt
> +++ b/Documentation/devicetree/bindings/sound/dmic.txt
> @@ -7,10 +7,12 @@ Required properties:
>  
>  Optional properties:
>          - dmicen-gpios: GPIO specifier for dmic to control start and stop
> +       - num-channels: Number of microphones on this DAI
>  
>  Example node:
>  
>          dmic_codec: dmic@0 {
>                  compatible = "dmic-codec";
>                  dmicen-gpios = <&gpio4 3 GPIO_ACTIVE_HIGH>;
> +               num-channels = <1>;
>          };
> diff --git a/sound/soc/codecs/dmic.c b/sound/soc/codecs/dmic.c
> index b88a1ee66f80..c88f974ebe3e 100644
> --- a/sound/soc/codecs/dmic.c
> +++ b/sound/soc/codecs/dmic.c
> @@ -107,8 +107,30 @@ static const struct snd_soc_codec_driver soc_dmic = {
>  
>  static int dmic_dev_probe(struct platform_device *pdev)
>  {
> +       int err;
> +       u32 chans;
> +       struct snd_soc_dai_driver *dai_drv = &dmic_dai;
> +
> +       if (pdev->dev.of_node) {
> +               err = of_property_read_u32(pdev->dev.of_node,
> "num-channels", &chans);
> +               if (err && (err != -ENOENT))
> +                       return err;
> +
> +               if (!err) {
> +                       if (chans < 1 || chans > 8)
> +                               return -EINVAL;
> +
> +                       dai_drv = devm_kzalloc(&pdev->dev,
> sizeof(*dai_drv), GFP_KERNEL);
> +                       if (!dai_drv)
> +                               return -ENOMEM;
> +
> +                       memcpy(dai_drv, &dmic_dai, sizeof(*dai_drv));
> +                       dai_drv->capture.channels_max = chans;
> +               }
> +       }
> +

>          return snd_soc_register_codec(&pdev->dev,
> -                       &soc_dmic, &dmic_dai, 1);
> +                       &soc_dmic, dai_drv, 1);
>  }
>  
>  static int dmic_dev_remove(struct platform_device *pdev)
> -- 
> 2.16.0.rc0.223.g4a4ac83678-goog
> 
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* Applied "ASoC: codecs: dmic: Make number of channels configurable" to the asoc tree
  2018-01-05 20:39 [PATCH] ASoC: codecs: dmic: Make number of channels configurable Matthias Kaehlcke
       [not found] ` <20180105203957.184883-1-mka-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
  2018-01-09  9:04 ` Arnaud Pouliquen
@ 2018-01-09 17:43 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2018-01-09 17:43 UTC (permalink / raw)
  To: Matthias Kaehlcke; +Cc: Arnaud Pouliquen, Mark Brown, Liam Girdwood

The patch

   ASoC: codecs: dmic: Make number of channels configurable

has been applied to the asoc tree at

   https://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 7fb59e940f6225beed0b24cd09e9fad9aebb7565 Mon Sep 17 00:00:00 2001
From: Matthias Kaehlcke <mka@chromium.org>
Date: Fri, 5 Jan 2018 12:39:57 -0800
Subject: [PATCH] ASoC: codecs: dmic: Make number of channels configurable

The DMIC DAI driver specifies a number of 1 to 8 channels for each DAI.
The actual number of mics can currently not be configured in the device
tree or audio glue, but is derived from the min/max channels of the CPU
and codec DAI. A typical CPU DAI has two or more channels, in consequence
a single mic is treated as a stereo/multi channel device, even though
only one channel carries audio data.

This change adds the option to specify the number of used DMIC channels
in the device tree. When specified this value overwrites the default
channels_max value of 8 in the snd_soc_dai_driver struct of the codec.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 Documentation/devicetree/bindings/sound/dmic.txt |  2 ++
 sound/soc/codecs/dmic.c                          | 24 +++++++++++++++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/sound/dmic.txt b/Documentation/devicetree/bindings/sound/dmic.txt
index 54c8ef6498a8..f7bf65611453 100644
--- a/Documentation/devicetree/bindings/sound/dmic.txt
+++ b/Documentation/devicetree/bindings/sound/dmic.txt
@@ -7,10 +7,12 @@ Required properties:
 
 Optional properties:
 	- dmicen-gpios: GPIO specifier for dmic to control start and stop
+	- num-channels: Number of microphones on this DAI
 
 Example node:
 
 	dmic_codec: dmic@0 {
 		compatible = "dmic-codec";
 		dmicen-gpios = <&gpio4 3 GPIO_ACTIVE_HIGH>;
+		num-channels = <1>;
 	};
diff --git a/sound/soc/codecs/dmic.c b/sound/soc/codecs/dmic.c
index b88a1ee66f80..c88f974ebe3e 100644
--- a/sound/soc/codecs/dmic.c
+++ b/sound/soc/codecs/dmic.c
@@ -107,8 +107,30 @@ static const struct snd_soc_codec_driver soc_dmic = {
 
 static int dmic_dev_probe(struct platform_device *pdev)
 {
+	int err;
+	u32 chans;
+	struct snd_soc_dai_driver *dai_drv = &dmic_dai;
+
+	if (pdev->dev.of_node) {
+		err = of_property_read_u32(pdev->dev.of_node, "num-channels", &chans);
+		if (err && (err != -ENOENT))
+			return err;
+
+		if (!err) {
+			if (chans < 1 || chans > 8)
+				return -EINVAL;
+
+			dai_drv = devm_kzalloc(&pdev->dev, sizeof(*dai_drv), GFP_KERNEL);
+			if (!dai_drv)
+				return -ENOMEM;
+
+			memcpy(dai_drv, &dmic_dai, sizeof(*dai_drv));
+			dai_drv->capture.channels_max = chans;
+		}
+	}
+
 	return snd_soc_register_codec(&pdev->dev,
-			&soc_dmic, &dmic_dai, 1);
+			&soc_dmic, dai_drv, 1);
 }
 
 static int dmic_dev_remove(struct platform_device *pdev)
-- 
2.15.1

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

end of thread, other threads:[~2018-01-09 17:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-05 20:39 [PATCH] ASoC: codecs: dmic: Make number of channels configurable Matthias Kaehlcke
     [not found] ` <20180105203957.184883-1-mka-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2018-01-09  4:17   ` Rob Herring
2018-01-09  9:04 ` Arnaud Pouliquen
2018-01-09 17:43 ` Applied "ASoC: codecs: dmic: Make number of channels configurable" to the asoc tree Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).