* [PATCH 0/2] ASoC: simple-audio-mux: add mux-name
@ 2024-06-27 3:51 Kuninori Morimoto
2024-06-27 3:51 ` [PATCH 1/2] ASoC: simple-audio-mux: enable to select MUX names Kuninori Morimoto
2024-06-27 3:52 ` [PATCH 2/2] ASoC: dt-bindings: simple-audio-mux: add mux-names property Kuninori Morimoto
0 siblings, 2 replies; 6+ messages in thread
From: Kuninori Morimoto @ 2024-06-27 3:51 UTC (permalink / raw)
To: Alexandre Belloni, Conor Dooley, Jaroslav Kysela,
Krzysztof Kozlowski, Krzysztof Kozlowski, Liam Girdwood,
Mark Brown, Rob Herring, Takashi Iwai, devicetree, linux-sound
Hi Mark
Current simple-audio-mux selects MUX by "Input 1" or "Input 2",
but it is not user friendly. This patch adds new "mux-names" property
and enable to select MUX by own names, like below.
Original
> amixer set "MUX" "Input 1"
> amixer set "MUX" "Input 2"
Use mux-names
sound_mux: mux {
compatible = "simple-audio-mux";
mux-gpios = <...>;
=> mux-names = "Device_A", "Device_B";
};
> amixer set "MUX" "Device_A"
> amixer set "MUX" "Device_B"
Kuninori Morimoto (2):
ASoC: simple-audio-mux: enable to select MUX names
ASoC: dt-bindings: simple-audio-mux: add mux-names property
.../bindings/sound/simple-audio-mux.yaml | 4 ++
sound/soc/codecs/simple-mux.c | 55 ++++++++++++++-----
2 files changed, 44 insertions(+), 15 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] ASoC: simple-audio-mux: enable to select MUX names
2024-06-27 3:51 [PATCH 0/2] ASoC: simple-audio-mux: add mux-name Kuninori Morimoto
@ 2024-06-27 3:51 ` Kuninori Morimoto
2024-06-27 3:52 ` [PATCH 2/2] ASoC: dt-bindings: simple-audio-mux: add mux-names property Kuninori Morimoto
1 sibling, 0 replies; 6+ messages in thread
From: Kuninori Morimoto @ 2024-06-27 3:51 UTC (permalink / raw)
To: Alexandre Belloni, Conor Dooley, Jaroslav Kysela,
Krzysztof Kozlowski, Krzysztof Kozlowski, Liam Girdwood,
Mark Brown, Rob Herring, Takashi Iwai, devicetree, linux-sound
Current simple-audio-mux selects MUX by "Input 1" or "Input 2",
it is not user friendly. Adds new "mux-names" property and enable to
select MUX by own names.
Original
> amixer set "MUX" "Input 1"
Use mux-names
sound_mux: mux {
compatible = "simple-audio-mux";
mux-gpios = <...>;
mux-names = "Device_A", "Device_B";
};
> amixer set "MUX" "Device_A"
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/codecs/simple-mux.c | 55 +++++++++++++++++++++++++----------
1 file changed, 40 insertions(+), 15 deletions(-)
diff --git a/sound/soc/codecs/simple-mux.c b/sound/soc/codecs/simple-mux.c
index bf67de12d20b..41f982078043 100644
--- a/sound/soc/codecs/simple-mux.c
+++ b/sound/soc/codecs/simple-mux.c
@@ -9,12 +9,21 @@
#include <linux/regulator/consumer.h>
#include <sound/soc.h>
+#define MUX_TEXT_SIZE 2
+#define MUX_WIDGET_SIZE 4
+#define MUX_ROUTE_SIZE 3
struct simple_mux {
struct gpio_desc *gpiod_mux;
unsigned int mux;
+ const char *mux_texts[MUX_TEXT_SIZE];
+ struct soc_enum mux_enum;
+ struct snd_kcontrol_new mux_mux;
+ struct snd_soc_dapm_widget mux_widgets[MUX_WIDGET_SIZE];
+ struct snd_soc_dapm_route mux_routes[MUX_ROUTE_SIZE];
+ struct snd_soc_component_driver mux_driver;
};
-static const char * const simple_mux_texts[] = {
+static const char * const simple_mux_texts[MUX_TEXT_SIZE] = {
"Input 1", "Input 2"
};
@@ -66,30 +75,23 @@ static unsigned int simple_mux_read(struct snd_soc_component *component,
static const struct snd_kcontrol_new simple_mux_mux =
SOC_DAPM_ENUM_EXT("Muxer", simple_mux_enum, simple_mux_control_get, simple_mux_control_put);
-static const struct snd_soc_dapm_widget simple_mux_dapm_widgets[] = {
+static const struct snd_soc_dapm_widget simple_mux_dapm_widgets[MUX_WIDGET_SIZE] = {
SND_SOC_DAPM_INPUT("IN1"),
SND_SOC_DAPM_INPUT("IN2"),
- SND_SOC_DAPM_MUX("MUX", SND_SOC_NOPM, 0, 0, &simple_mux_mux),
+ SND_SOC_DAPM_MUX("MUX", SND_SOC_NOPM, 0, 0, &simple_mux_mux), // see simple_mux_probe()
SND_SOC_DAPM_OUTPUT("OUT"),
};
-static const struct snd_soc_dapm_route simple_mux_dapm_routes[] = {
+static const struct snd_soc_dapm_route simple_mux_dapm_routes[MUX_ROUTE_SIZE] = {
{ "OUT", NULL, "MUX" },
- { "MUX", "Input 1", "IN1" },
- { "MUX", "Input 2", "IN2" },
-};
-
-static const struct snd_soc_component_driver simple_mux_component_driver = {
- .dapm_widgets = simple_mux_dapm_widgets,
- .num_dapm_widgets = ARRAY_SIZE(simple_mux_dapm_widgets),
- .dapm_routes = simple_mux_dapm_routes,
- .num_dapm_routes = ARRAY_SIZE(simple_mux_dapm_routes),
- .read = simple_mux_read,
+ { "MUX", "Input 1", "IN1" }, // see simple_mux_probe()
+ { "MUX", "Input 2", "IN2" }, // see simple_mux_probe()
};
static int simple_mux_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
+ struct device_node *np = dev->of_node;
struct simple_mux *priv;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -103,7 +105,30 @@ static int simple_mux_probe(struct platform_device *pdev)
return dev_err_probe(dev, PTR_ERR(priv->gpiod_mux),
"Failed to get 'mux' gpio");
- return devm_snd_soc_register_component(dev, &simple_mux_component_driver, NULL, 0);
+ /* Copy default settings */
+ memcpy(&priv->mux_texts, &simple_mux_texts, sizeof(priv->mux_texts));
+ memcpy(&priv->mux_enum, &simple_mux_enum, sizeof(priv->mux_enum));
+ memcpy(&priv->mux_mux, &simple_mux_mux, sizeof(priv->mux_mux));
+ memcpy(&priv->mux_widgets, &simple_mux_dapm_widgets, sizeof(priv->mux_widgets));
+ memcpy(&priv->mux_routes, &simple_mux_dapm_routes, sizeof(priv->mux_routes));
+
+ priv->mux_driver.dapm_widgets = priv->mux_widgets;
+ priv->mux_driver.num_dapm_widgets = MUX_WIDGET_SIZE;
+ priv->mux_driver.dapm_routes = priv->mux_routes;
+ priv->mux_driver.num_dapm_routes = MUX_ROUTE_SIZE;
+ priv->mux_driver.read = simple_mux_read;
+
+ /* Overwrite text ("Input 1", "Input 2") if property exists */
+ of_property_read_string_array(np, "mux-names", priv->mux_texts, MUX_TEXT_SIZE);
+
+ /* switch to use priv data instead of default */
+ priv->mux_enum.texts = priv->mux_texts;
+ priv->mux_mux.private_value = (unsigned long)&priv->mux_enum;
+ priv->mux_widgets[2].kcontrol_news = &priv->mux_mux;
+ priv->mux_routes[1].control = priv->mux_texts[0]; // "Input 1"
+ priv->mux_routes[2].control = priv->mux_texts[1]; // "Input 2"
+
+ return devm_snd_soc_register_component(dev, &priv->mux_driver, NULL, 0);
}
#ifdef CONFIG_OF
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] ASoC: dt-bindings: simple-audio-mux: add mux-names property
2024-06-27 3:51 [PATCH 0/2] ASoC: simple-audio-mux: add mux-name Kuninori Morimoto
2024-06-27 3:51 ` [PATCH 1/2] ASoC: simple-audio-mux: enable to select MUX names Kuninori Morimoto
@ 2024-06-27 3:52 ` Kuninori Morimoto
2024-06-27 7:46 ` Krzysztof Kozlowski
1 sibling, 1 reply; 6+ messages in thread
From: Kuninori Morimoto @ 2024-06-27 3:52 UTC (permalink / raw)
To: Alexandre Belloni, Conor Dooley, Jaroslav Kysela,
Krzysztof Kozlowski, Krzysztof Kozlowski, Liam Girdwood,
Mark Brown, Rob Herring, Takashi Iwai, devicetree, linux-sound
Current simple-audio-mux selects MUX by "Input 1" or "Input 2",
it is not user friendly. Adds new "mux-names" property and enable to
select MUX by own names.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
Documentation/devicetree/bindings/sound/simple-audio-mux.yaml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Documentation/devicetree/bindings/sound/simple-audio-mux.yaml b/Documentation/devicetree/bindings/sound/simple-audio-mux.yaml
index 9f319caf3db7..6e4018936887 100644
--- a/Documentation/devicetree/bindings/sound/simple-audio-mux.yaml
+++ b/Documentation/devicetree/bindings/sound/simple-audio-mux.yaml
@@ -24,6 +24,10 @@ properties:
description: |
GPIOs used to select the input line.
+ mux-names:
+ description: |
+ Name of multiplexers. default is "Input 1", "Input 2"
+
sound-name-prefix: true
required:
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] ASoC: dt-bindings: simple-audio-mux: add mux-names property
2024-06-27 3:52 ` [PATCH 2/2] ASoC: dt-bindings: simple-audio-mux: add mux-names property Kuninori Morimoto
@ 2024-06-27 7:46 ` Krzysztof Kozlowski
2024-06-27 11:45 ` Mark Brown
0 siblings, 1 reply; 6+ messages in thread
From: Krzysztof Kozlowski @ 2024-06-27 7:46 UTC (permalink / raw)
To: Kuninori Morimoto, Alexandre Belloni, Conor Dooley,
Jaroslav Kysela, Krzysztof Kozlowski, Krzysztof Kozlowski,
Liam Girdwood, Mark Brown, Rob Herring, Takashi Iwai, devicetree,
linux-sound
On 27/06/2024 05:52, Kuninori Morimoto wrote:
> Current simple-audio-mux selects MUX by "Input 1" or "Input 2",
> it is not user friendly. Adds new "mux-names" property and enable to
> select MUX by own names.
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
> Documentation/devicetree/bindings/sound/simple-audio-mux.yaml | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/sound/simple-audio-mux.yaml b/Documentation/devicetree/bindings/sound/simple-audio-mux.yaml
> index 9f319caf3db7..6e4018936887 100644
> --- a/Documentation/devicetree/bindings/sound/simple-audio-mux.yaml
> +++ b/Documentation/devicetree/bindings/sound/simple-audio-mux.yaml
> @@ -24,6 +24,10 @@ properties:
> description: |
> GPIOs used to select the input line.
>
> + mux-names:
> + description: |
> + Name of multiplexers. default is "Input 1", "Input 2"
> +
I have troubles with this binding... It seems driver expects only one
GPIO, but the binding allows any number. Similarly mux-names...
Anyway, this does not look like hardware description but rather
configuration of driver. What's wrong with input 1 or mux 1 or whatever
is there for default?
Also: extend the example.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] ASoC: dt-bindings: simple-audio-mux: add mux-names property
2024-06-27 7:46 ` Krzysztof Kozlowski
@ 2024-06-27 11:45 ` Mark Brown
2024-06-27 23:08 ` Kuninori Morimoto
0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2024-06-27 11:45 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Kuninori Morimoto, Alexandre Belloni, Conor Dooley,
Jaroslav Kysela, Krzysztof Kozlowski, Krzysztof Kozlowski,
Liam Girdwood, Rob Herring, Takashi Iwai, devicetree, linux-sound
[-- Attachment #1: Type: text/plain, Size: 1108 bytes --]
On Thu, Jun 27, 2024 at 09:46:29AM +0200, Krzysztof Kozlowski wrote:
> On 27/06/2024 05:52, Kuninori Morimoto wrote:
> > Current simple-audio-mux selects MUX by "Input 1" or "Input 2",
> > it is not user friendly. Adds new "mux-names" property and enable to
> > select MUX by own names.
> > + mux-names:
> > + description: |
> > + Name of multiplexers. default is "Input 1", "Input 2"
> I have troubles with this binding... It seems driver expects only one
> GPIO, but the binding allows any number. Similarly mux-names...
> Anyway, this does not look like hardware description but rather
> configuration of driver. What's wrong with input 1 or mux 1 or whatever
> is there for default?
I would expect that when this driver is deployed it would mainly be for
selecting between things like microphone inputs that are defined and
labelled as part of the system hardware design. Using numbered inputs
would *work* but it's not great for usability so I do see a use case for
labels. Possibly we could figure something out by walking the graph but
that seems quite hard, possibly unreasonably so.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] ASoC: dt-bindings: simple-audio-mux: add mux-names property
2024-06-27 11:45 ` Mark Brown
@ 2024-06-27 23:08 ` Kuninori Morimoto
0 siblings, 0 replies; 6+ messages in thread
From: Kuninori Morimoto @ 2024-06-27 23:08 UTC (permalink / raw)
To: Mark Brown
Cc: Krzysztof Kozlowski, Alexandre Belloni, Conor Dooley,
Jaroslav Kysela, Krzysztof Kozlowski, Krzysztof Kozlowski,
Liam Girdwood, Rob Herring, Takashi Iwai, devicetree, linux-sound
Hi Krzysztof, Mark
> > > Current simple-audio-mux selects MUX by "Input 1" or "Input 2",
> > > it is not user friendly. Adds new "mux-names" property and enable to
> > > select MUX by own names.
>
> > > + mux-names:
> > > + description: |
> > > + Name of multiplexers. default is "Input 1", "Input 2"
>
> > I have troubles with this binding... It seems driver expects only one
> > GPIO, but the binding allows any number. Similarly mux-names...
>
> > Anyway, this does not look like hardware description but rather
> > configuration of driver. What's wrong with input 1 or mux 1 or whatever
> > is there for default?
>
> I would expect that when this driver is deployed it would mainly be for
> selecting between things like microphone inputs that are defined and
> labelled as part of the system hardware design. Using numbered inputs
> would *work* but it's not great for usability so I do see a use case for
> labels. Possibly we could figure something out by walking the graph but
> that seems quite hard, possibly unreasonably so.
Thank you for explaning, Mark
I noticed that the property naming is not so good.
I will fix property name and git-log, and re-post v2.
Thank you for your help !!
Best regards
---
Kuninori Morimoto
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-06-27 23:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-27 3:51 [PATCH 0/2] ASoC: simple-audio-mux: add mux-name Kuninori Morimoto
2024-06-27 3:51 ` [PATCH 1/2] ASoC: simple-audio-mux: enable to select MUX names Kuninori Morimoto
2024-06-27 3:52 ` [PATCH 2/2] ASoC: dt-bindings: simple-audio-mux: add mux-names property Kuninori Morimoto
2024-06-27 7:46 ` Krzysztof Kozlowski
2024-06-27 11:45 ` Mark Brown
2024-06-27 23:08 ` Kuninori Morimoto
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox