[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230811201406.4096210-3-contact@jookia.org>
Date: Sat, 12 Aug 2023 06:14:01 +1000
From: John Watts <contact@...kia.org>
To: alsa-devel@...a-project.org
Cc: Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>,
Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Conor Dooley <conor+dt@...nel.org>,
Chen-Yu Tsai <wens@...e.org>,
Jernej Skrabec <jernej.skrabec@...il.com>,
Samuel Holland <samuel@...lland.org>,
Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>, John Watts <contact@...kia.org>,
Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>,
Maxime Ripard <mripard@...nel.org>, devicetree@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-sunxi@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: [RFC PATCH 2/7] ASoC: sunxi: sun4i-i2s: Use channel-dins device tree property
Instead of using DIN pin 0 for all pins, allow changing this using
the device tree property.
As an example:
&i2s2 {
channel-dins = /bits/ 8 <0 0 1 1 2 2>;
};
This sets channels 0 and 1 to DIN pin 0, channels 1 and 2 to DIN pin 1,
and channels 3 and 4 to DIN pin 3 respectively.
Signed-off-by: John Watts <contact@...kia.org>
---
sound/soc/sunxi/sun4i-i2s.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index d8f999ecaf05..cf66f21646a4 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -236,8 +236,33 @@ struct sun4i_i2s_clk_div {
static int sun4i_i2s_read_channel_dins(struct device *dev, struct sun4i_i2s *i2s)
{
+ struct device_node *np = dev->of_node;
+ int max_channels = ARRAY_SIZE(i2s->channel_dins);
+ int ret;
+
/* Use DIN pin 0 by default */
memset(i2s->channel_dins, 0, sizeof(i2s->channel_dins));
+
+ if (!np)
+ return 0;
+
+ ret = of_property_read_variable_u8_array(np, "channel-dins",
+ i2s->channel_dins,
+ 1, max_channels);
+
+ if (ret == -EINVAL)
+ return 0;
+
+ if (ret < 0)
+ return ret;
+
+ for (int i = 0; i < ret; ++i) {
+ u8 din = i2s->channel_dins[i];
+
+ if (din >= i2s->variant->num_din_pins)
+ return -EINVAL;
+ }
+
return 0;
}
--
2.41.0
Powered by blists - more mailing lists