* [PATCH v2 0/2] ASoc: simple-mux: Allow to specify an idle-state
@ 2024-11-14 11:01 Hendrik v. Raven
2024-11-14 11:01 ` [PATCH v2 1/2] ASoc: simple-mux: add idle-state support Hendrik v. Raven
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Hendrik v. Raven @ 2024-11-14 11:01 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Alexandre Belloni
Cc: linux-sound, linux-kernel, devicetree, Hendrik v. Raven
This series adds support for the idle-state property from the mux
framework to the simple-mux audio variant. It allows to specify the state
of the mux when it is not in use.
Signed-off-by: Hendrik v. Raven <h.v.raven@merzmedtech.de>
---
Changes in v2:
- Fix nullpointer dereference in simple_mux_event by accessing component
from w->dapm instead of kcontrol.
- Link to v1: https://lore.kernel.org/r/20241114-simple-mux-idle-state-v1-0-0b082dd6549b@merzmedtech.de
---
Hendrik v. Raven (2):
ASoc: simple-mux: add idle-state support
ASoC: dt-bindings: simple-mux: add idle-state property
.../bindings/sound/simple-audio-mux.yaml | 5 +++
sound/soc/codecs/simple-mux.c | 39 +++++++++++++++++++++-
2 files changed, 43 insertions(+), 1 deletion(-)
---
base-commit: 2d5404caa8c7bb5c4e0435f94b28834ae5456623
change-id: 20241114-simple-mux-idle-state-08dd2d49e312
Best regards,
--
Hendrik v. Raven <h.v.raven@merzmedtech.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/2] ASoc: simple-mux: add idle-state support
2024-11-14 11:01 [PATCH v2 0/2] ASoc: simple-mux: Allow to specify an idle-state Hendrik v. Raven
@ 2024-11-14 11:01 ` Hendrik v. Raven
2024-11-14 11:01 ` [PATCH v2 2/2] ASoC: dt-bindings: simple-mux: add idle-state property Hendrik v. Raven
2024-11-14 16:58 ` [PATCH v2 0/2] ASoc: simple-mux: Allow to specify an idle-state Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Hendrik v. Raven @ 2024-11-14 11:01 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Alexandre Belloni
Cc: linux-sound, linux-kernel, devicetree, Hendrik v. Raven
So far the mux changes it state immediately, even when not in use. Allow
overriding this behaviour by specifying an optional idle-state. This
state is used whenever the mux is powered down, only switching to the
selected state on power up. If unspecified it defaults to as-is,
maintaining the previous behaviour.
Signed-off-by: Hendrik v. Raven <h.v.raven@merzmedtech.de>
---
Changes in v2:
- fix nullpointer dereference in simple_mux_event
---
sound/soc/codecs/simple-mux.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/simple-mux.c b/sound/soc/codecs/simple-mux.c
index 240af0563283e5a9dd720d51a2cefd22bd241faa..3906964401557db7799a2e1a8dd8abd445e841f4 100644
--- a/sound/soc/codecs/simple-mux.c
+++ b/sound/soc/codecs/simple-mux.c
@@ -6,6 +6,7 @@
#include <linux/gpio/consumer.h>
#include <linux/module.h>
+#include <linux/mux/driver.h>
#include <linux/regulator/consumer.h>
#include <sound/soc.h>
@@ -16,6 +17,7 @@ struct simple_mux {
struct gpio_desc *gpiod_mux;
unsigned int mux;
const char *mux_texts[MUX_TEXT_SIZE];
+ unsigned int idle_state;
struct soc_enum mux_enum;
struct snd_kcontrol_new mux_mux;
struct snd_soc_dapm_widget mux_widgets[MUX_WIDGET_SIZE];
@@ -57,6 +59,9 @@ static int simple_mux_control_put(struct snd_kcontrol *kcontrol,
priv->mux = ucontrol->value.enumerated.item[0];
+ if (priv->idle_state != MUX_IDLE_AS_IS && dapm->bias_level < SND_SOC_BIAS_PREPARE)
+ return 0;
+
gpiod_set_value_cansleep(priv->gpiod_mux, priv->mux);
return snd_soc_dapm_mux_update_power(dapm, kcontrol,
@@ -75,10 +80,33 @@ 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 int simple_mux_event(struct snd_soc_dapm_widget *w,
+ struct snd_kcontrol *kcontrol, int event)
+{
+ struct snd_soc_component *c = snd_soc_dapm_to_component(w->dapm);
+ struct simple_mux *priv = snd_soc_component_get_drvdata(c);
+
+ if (priv->idle_state != MUX_IDLE_AS_IS) {
+ switch (event) {
+ case SND_SOC_DAPM_PRE_PMU:
+ gpiod_set_value_cansleep(priv->gpiod_mux, priv->mux);
+ break;
+ case SND_SOC_DAPM_POST_PMD:
+ gpiod_set_value_cansleep(priv->gpiod_mux, priv->idle_state);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return 0;
+}
+
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), // see simple_mux_probe()
+ SND_SOC_DAPM_MUX_E("MUX", SND_SOC_NOPM, 0, 0, &simple_mux_mux, // see simple_mux_probe()
+ simple_mux_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_OUTPUT("OUT"),
};
@@ -93,6 +121,7 @@ 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;
+ int ret;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
@@ -121,6 +150,14 @@ static int simple_mux_probe(struct platform_device *pdev)
/* Overwrite text ("Input 1", "Input 2") if property exists */
of_property_read_string_array(np, "state-labels", priv->mux_texts, MUX_TEXT_SIZE);
+ ret = of_property_read_u32(np, "idle-state", &priv->idle_state);
+ if (ret < 0) {
+ priv->idle_state = MUX_IDLE_AS_IS;
+ } else if (priv->idle_state != MUX_IDLE_AS_IS && priv->idle_state >= 2) {
+ dev_err(dev, "invalid idle-state %u\n", priv->idle_state);
+ return -EINVAL;
+ }
+
/* 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;
--
2.47.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] ASoC: dt-bindings: simple-mux: add idle-state property
2024-11-14 11:01 [PATCH v2 0/2] ASoc: simple-mux: Allow to specify an idle-state Hendrik v. Raven
2024-11-14 11:01 ` [PATCH v2 1/2] ASoc: simple-mux: add idle-state support Hendrik v. Raven
@ 2024-11-14 11:01 ` Hendrik v. Raven
2024-11-14 16:58 ` [PATCH v2 0/2] ASoc: simple-mux: Allow to specify an idle-state Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Hendrik v. Raven @ 2024-11-14 11:01 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Alexandre Belloni
Cc: linux-sound, linux-kernel, devicetree, Hendrik v. Raven
simple-mux immediately activates the new output, even when it is powered
down. This can be undesirable in some cases, for example when a
mechanical relais is used.
Adds "idle-state" property from the mux controller to select the output
state to be used when the mux is powered down.
Signed-off-by: Hendrik v. Raven <h.v.raven@merzmedtech.de>
---
Changes in v2:
- No changes
---
Documentation/devicetree/bindings/sound/simple-audio-mux.yaml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Documentation/devicetree/bindings/sound/simple-audio-mux.yaml b/Documentation/devicetree/bindings/sound/simple-audio-mux.yaml
index 194ac1d4f4f5f40a9bc44e8cd0acbf2eab708365..9b1bda4852e160618ffd349d2f7c90645d5b3e03 100644
--- a/Documentation/devicetree/bindings/sound/simple-audio-mux.yaml
+++ b/Documentation/devicetree/bindings/sound/simple-audio-mux.yaml
@@ -29,6 +29,10 @@ properties:
$ref: /schemas/types.yaml#/definitions/string-array
maxItems: 2
+ idle-state:
+ description: If present specifies the state when the mux is powered down
+ $ref: /schemas/mux/mux-controller.yaml#/properties/idle-state
+
sound-name-prefix: true
required:
@@ -43,4 +47,5 @@ examples:
compatible = "simple-audio-mux";
mux-gpios = <&gpio 3 0>;
state-labels = "Label_A", "Label_B";
+ idle-state = <0>;
};
--
2.47.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 0/2] ASoc: simple-mux: Allow to specify an idle-state
2024-11-14 11:01 [PATCH v2 0/2] ASoc: simple-mux: Allow to specify an idle-state Hendrik v. Raven
2024-11-14 11:01 ` [PATCH v2 1/2] ASoc: simple-mux: add idle-state support Hendrik v. Raven
2024-11-14 11:01 ` [PATCH v2 2/2] ASoC: dt-bindings: simple-mux: add idle-state property Hendrik v. Raven
@ 2024-11-14 16:58 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2024-11-14 16:58 UTC (permalink / raw)
To: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Alexandre Belloni,
Hendrik v. Raven
Cc: linux-sound, linux-kernel, devicetree
On Thu, 14 Nov 2024 12:01:24 +0100, Hendrik v. Raven wrote:
> This series adds support for the idle-state property from the mux
> framework to the simple-mux audio variant. It allows to specify the state
> of the mux when it is not in use.
>
>
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/2] ASoc: simple-mux: add idle-state support
commit: 2b974284aa073d6e2936f9032e8ad7b99480b5b8
[2/2] ASoC: dt-bindings: simple-mux: add idle-state property
commit: 3b7e11a0116c30848d44429650ad80f9cc3bd963
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-11-14 16:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-14 11:01 [PATCH v2 0/2] ASoc: simple-mux: Allow to specify an idle-state Hendrik v. Raven
2024-11-14 11:01 ` [PATCH v2 1/2] ASoc: simple-mux: add idle-state support Hendrik v. Raven
2024-11-14 11:01 ` [PATCH v2 2/2] ASoC: dt-bindings: simple-mux: add idle-state property Hendrik v. Raven
2024-11-14 16:58 ` [PATCH v2 0/2] ASoc: simple-mux: Allow to specify an idle-state Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox