From: John Watts <contact@jookia.org>
To: alsa-devel@alsa-project.org
Cc: "Liam Girdwood" <lgirdwood@gmail.com>,
"Mark Brown" <broonie@kernel.org>,
"Rob Herring" <robh+dt@kernel.org>,
"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Chen-Yu Tsai" <wens@csie.org>,
"Jernej Skrabec" <jernej.skrabec@gmail.com>,
"Samuel Holland" <samuel@sholland.org>,
"Jaroslav Kysela" <perex@perex.cz>,
"Takashi Iwai" <tiwai@suse.com>,
"John Watts" <contact@jookia.org>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Maxime Ripard" <mripard@kernel.org>,
devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [RFC PATCH 3/7] ASoC: sunxi: sun4i-i2s: Prepare for runtime channel slot selection
Date: Sat, 12 Aug 2023 06:14:02 +1000 [thread overview]
Message-ID: <20230811201406.4096210-4-contact@jookia.org> (raw)
In-Reply-To: <20230811201406.4096210-1-contact@jookia.org>
The sun4i I2S controller supports mapping channels to specific TDM
slots. This is usually done in a 1:1 mapping because there's not
really a reason to re-order the TDM slots in software.
On the R329 and D1 multiplexing can be done using pins as well as
TDM. Here's an example of using 3 pins and 2 slots (left and right):
Channel 0 -> DIN0 -> ADC0, TDM slot 0
Channel 1 -> DIN0 -> ADC0, TDM slot 1
Channel 2 -> DIN1 -> ADC1, TDM slot 0
Channel 3 -> DIN1 -> ADC1, TDM slot 1
Channel 4 -> DIN2 -> ADC2, TDM slot 0
Channel 5 -> DIN2 -> ADC2, TDM slot 1
This connects 3 separate TDM-unaware ADCs to the I2S controller.
Likewise, multiple TDM slots could be used to run two sets of
TDM-aware ADCs on one I2S controller.
Prepare for configurable slot selection by adding a channel to slot
mapping array and using that in the R329 code if we multiple DIN pins.
Signed-off-by: John Watts <contact@jookia.org>
---
sound/soc/sunxi/sun4i-i2s.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index cf66f21646a4..627bf319e1cc 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -217,6 +217,7 @@ struct sun4i_i2s {
unsigned int slots;
unsigned int slot_width;
u8 channel_dins[16];
+ u8 channel_slots[16];
struct snd_dmaengine_dai_dma_data capture_dma_data;
struct snd_dmaengine_dai_dma_data playback_dma_data;
@@ -266,6 +267,17 @@ static int sun4i_i2s_read_channel_dins(struct device *dev, struct sun4i_i2s *i2s
return 0;
}
+static int sun4i_i2s_read_channel_slots(struct device *dev, struct sun4i_i2s *i2s)
+{
+ int max_channels = ARRAY_SIZE(i2s->channel_dins);
+
+ /* Use a 1:1 mapping by default */
+ for (int i = 0; i < max_channels; ++i)
+ i2s->channel_slots[i] = i;
+
+ return 0;
+}
+
static const struct sun4i_i2s_clk_div sun4i_i2s_bclk_div[] = {
{ .div = 2, .val = 0 },
{ .div = 4, .val = 1 },
@@ -570,7 +582,7 @@ static void sun50i_h6_write_channel_map(const struct sun4i_i2s *i2s,
for (int i = 3; i >= 0; i--) {
int channel = channel_start + i;
u8 din = i2s->channel_dins[channel];
- u8 slot = channel; /* Map slot to channel */
+ u8 slot = i2s->channel_slots[channel];
reg_value <<= 8;
reg_value |= (din << 4) | slot;
@@ -1616,6 +1628,11 @@ static int sun4i_i2s_probe(struct platform_device *pdev)
return -EINVAL;
}
+ if (sun4i_i2s_read_channel_slots(&pdev->dev, i2s)) {
+ dev_err(&pdev->dev, "Invalid channel slots\n");
+ return -EINVAL;
+ }
+
i2s->playback_dma_data.addr = res->start +
i2s->variant->reg_offset_txdata;
i2s->playback_dma_data.maxburst = 8;
--
2.41.0
next prev parent reply other threads:[~2023-08-11 20:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-11 20:13 [RFC PATCH 0/7] sun4i-i2s: Support channel remapping John Watts
2023-08-11 20:14 ` [RFC PATCH 1/7] ASoC: sunxi: sun4i-i2s: Prepare for runtime DIN pin selection John Watts
2023-08-11 20:14 ` [RFC PATCH 2/7] ASoC: sunxi: sun4i-i2s: Use channel-dins device tree property John Watts
2023-08-11 20:14 ` John Watts [this message]
2023-08-11 20:14 ` [RFC PATCH 4/7] ASoC: sunxi: sun4i-i2s: Use channel-slots " John Watts
2023-08-11 20:14 ` [RFC PATCH 5/7] ASoC: sunxi: sun4i-i2s: Detect TDM slots based on channel slots John Watts
2023-08-11 20:14 ` [RFC PATCH 6/7] dt-bindings: sound: sun4i-i2s: Add channel-dins property John Watts
2023-08-21 17:34 ` Rob Herring
2023-08-11 20:14 ` [RFC PATCH 7/7] dt-bindings: sound: sun4i-i2s: Add channel-slots property John Watts
2023-08-21 17:35 ` Rob Herring
2023-08-31 12:24 ` [RFC PATCH 0/7] sun4i-i2s: Support channel remapping Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230811201406.4096210-4-contact@jookia.org \
--to=contact@jookia.org \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jernej.skrabec@gmail.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=mripard@kernel.org \
--cc=perex@perex.cz \
--cc=robh+dt@kernel.org \
--cc=samuel@sholland.org \
--cc=tiwai@suse.com \
--cc=u.kleine-koenig@pengutronix.de \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®