From nobody Sun Apr 12 07:25:04 2026 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E4AC3890EE for ; Sat, 11 Apr 2026 14:58:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775919489; cv=none; b=EL6GerLvzJhkA9G2Jdq5igw0wk5PY2b8BCQgvm+tI09T9BwGdAAGDxS0NsoU8JzFCT6kqE5Y1/AsQI8sJukOjffniURzkTAHyLrvMtwoiK6oatQvaoZ40vlPLmFQShenN8A3EDCOnk4fnZ3IW2w/aVVu/ryaOqgrMzSuXzPOnYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775919489; c=relaxed/simple; bh=GvUUnavXTrTzCeaOmfiAqtoNpa4n5tFwZBrof78Pboc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qPnbhvzeHow43WyYx+rd0iu58bVC0r+6+HObYJJnDf6+o4CC4LL1TXotjpIFLFOIr+LNbqgjTC6oT+r/nQri4ToNYzWlGe8iT64RjdiV7fXLdcw60q6mi0XdfwZoV+phvDzRmaCUjazRpL5FXR9ubjy5jc8Rkc55/mse1M+RRd0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20251104.gappssmtp.com header.i=@baylibre-com.20251104.gappssmtp.com header.b=QL0TnhRD; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20251104.gappssmtp.com header.i=@baylibre-com.20251104.gappssmtp.com header.b="QL0TnhRD" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-48897fd88ebso31789595e9.2 for ; Sat, 11 Apr 2026 07:58:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20251104.gappssmtp.com; s=20251104; t=1775919484; x=1776524284; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ecSMrOBx0pzo4y3143wojd4syVHZTf/XbWi3AqukMso=; b=QL0TnhRDgYrvL9WuPQGwJuU0HhtRDT92hD4pCg3kjZQFt1RsnFOndeY7qQwwHGWB/c Ki3SYjcOZp4GhuSUTab2A/Y4yUng4X3xBIq0yqw5pT2LoV8u9E5PKsWCY68jYoW1keGp XC5fXb2Mgq4bsQBU2U0PGv1DjvwsIxX2Wux7pH3CE5GqjRUw9siFmGbGBi++p8NeVHwW R+qDfVylzpRwFL2NqEXBbk38ryeqMoYzAhSl0ohzUDYBmyCLLmtj2BAj39SUg8ebfnt7 LSKussMp5lnjBt9KKAczoDeXf3UvAxyBG/9Mj6vcDgFvXM5CLkYDFWkR5v+IWtIqYWS3 UixQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775919484; x=1776524284; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=ecSMrOBx0pzo4y3143wojd4syVHZTf/XbWi3AqukMso=; b=ogYcx4XvANK6G9rPY+BqrytuQwmFqBHZbJuwbnOvqJSl9gczjRmEjn9hXVx3t+6sjT n3zbE7CCV+wk30Q1RVNjDshfF/TBUDwGVKcJHHTjPWdMUdA0zl9VPcIe1pEXP7OhjQhh xf94ppHQ5ysbnmWIEn+RK0bIiQG8KpQZXadVzSG9MqCku5yM4leW/vmwLMgPFiHInSlR vRO3TVaRf6C5ysNBHytjVVLAdyhNuCCiWZy7JEm8x5MNuVO36QjJnvoBE435eobJD/Ci 08iEle3VZN9KPQtzwj7zAKSxgfsisxfChcQGogE1WOgVpXftvVR+3xlas6YwP78GK7yn lL5w== X-Gm-Message-State: AOJu0YxK1TekEdHj1/oZ0CTBJEtBcTHT92+QbUncUR44Anrychfx9ub0 WPxOw7YQeGZTKXAduMUSTbr6nC+lKkVr+CnQj8hUqOkUeDpgp3Ttzf5cNoDEjVMJHWY= X-Gm-Gg: AeBDies/XhEruuCvuaDb6Fa0qXpyWx8ZiEnOAXixMNs5HNb8NLwfgCN4jJSGOys4Ysn LKAnayUY7scy/FLkGtZawbI6hIW292ft0sJes4N2FQbxPPrOpRZgvU2he1tKFUjbGx4R4B6eROt 7avrHYa0BELFo1fXyTRHWJ2LBqJQxO4mSSaMis/mVBzQttYJWv37lCWAUHkAR1/VGj208Djia0R xO47N1IF7IxF0l1tbjLEN0aqNy9Kon2tqPoZgLTHsSH6yGIMwcbuxsa4vpJvNjkPaxMSQu6OrtC MWNs6Z9ySJcu2dxRGXVyCn664leD9cnn6JIb3pz7KYb9tW/5/1m0acIPikfjs1Gaya6TGflu2VR 1M/cOEkRzqHvBc2RInlqtgOL5nvUjnqrH4GmzlxT32E449ov8kZ0YAoxRFpHjRzNNAa/4UQdTsz OvCgqMNuH1i9ApaYC1ld/7 X-Received: by 2002:a05:600c:3150:b0:488:c80c:c236 with SMTP id 5b1f17b1804b1-488d68057f3mr100729095e9.5.1775919483749; Sat, 11 Apr 2026 07:58:03 -0700 (PDT) Received: from [127.0.1.1] ([151.61.248.52]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488d5dc7070sm48882375e9.10.2026.04.11.07.58.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Apr 2026 07:58:03 -0700 (PDT) From: Valerio Setti Date: Sat, 11 Apr 2026 16:57:29 +0200 Subject: [PATCH RFC v2 04/11] ASoC: meson: aiu: use aiu-formatter-i2s to format I2S output data Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260411-audin-rfc-v2-4-4c8a6ec5fcab@baylibre.com> References: <20260411-audin-rfc-v2-0-4c8a6ec5fcab@baylibre.com> In-Reply-To: <20260411-audin-rfc-v2-0-4c8a6ec5fcab@baylibre.com> To: Jerome Brunet , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Neil Armstrong , Kevin Hilman , Martin Blumenstingl , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Valerio Setti Cc: linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, devicetree@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6044; i=vsetti@baylibre.com; h=from:subject:message-id; bh=GvUUnavXTrTzCeaOmfiAqtoNpa4n5tFwZBrof78Pboc=; b=owGbwMvMwCF2z3ty7kUrRgbG02pJDJm3EoujFh9NYsnautmp8dAxR+7Vs6p+Mk29eWM2113x6 v0WBxtSO0pZGMQ4GGTFFFlYpt/7XVCq9tA44WQBzBxWJpAhDFycAjCRPDaGv+JsavcKLCRMpnq7 Vh9RLuvZdnKv8/Sw4ypmCxeJtznNWs/IcPC88j/JS+EO1450NvvHHSnfUnn7yZdlRnlH7T8qqGw 4wwwA X-Developer-Key: i=vsetti@baylibre.com; a=openpgp; fpr=0497DEFB707526E13360C970DE4B936DD13A0100 Create a new DAPM widget for "I2S formatter" and place it on the path between FIFO and output DAI interface. Remove I2S output formatting code from aiu-encoder-i2s since it's now implemented from aiu-formatter-i2s. Signed-off-by: Valerio Setti --- sound/soc/meson/aiu-encoder-i2s.c | 56 -----------------------------------= ---- sound/soc/meson/aiu.c | 30 ++++++++++++++++++--- sound/soc/meson/aiu.h | 1 + 3 files changed, 27 insertions(+), 60 deletions(-) diff --git a/sound/soc/meson/aiu-encoder-i2s.c b/sound/soc/meson/aiu-encode= r-i2s.c index 76a33878b9df101ad62b18abd8cc14b7908c2c42..ce28850fde23f4fd1872c4364e1= 3588138ba26ba 100644 --- a/sound/soc/meson/aiu-encoder-i2s.c +++ b/sound/soc/meson/aiu-encoder-i2s.c @@ -13,13 +13,6 @@ #include "gx-formatter.h" #include "gx-interface.h" =20 -#define AIU_I2S_SOURCE_DESC_MODE_8CH BIT(0) -#define AIU_I2S_SOURCE_DESC_MODE_24BIT BIT(5) -#define AIU_I2S_SOURCE_DESC_MODE_32BIT BIT(9) -#define AIU_I2S_SOURCE_DESC_MODE_SPLIT BIT(11) -#define AIU_RST_SOFT_I2S_FAST BIT(0) - -#define AIU_I2S_DAC_CFG_MSB_FIRST BIT(2) #define AIU_CLK_CTRL_I2S_DIV_EN BIT(0) #define AIU_CLK_CTRL_I2S_DIV GENMASK(3, 2) #define AIU_CLK_CTRL_AOCLK_INVERT BIT(6) @@ -37,49 +30,6 @@ static void aiu_encoder_i2s_divider_enable(struct snd_so= c_component *component, enable ? AIU_CLK_CTRL_I2S_DIV_EN : 0); } =20 -static int aiu_encoder_i2s_setup_desc(struct snd_soc_component *component, - struct snd_pcm_hw_params *params) -{ - /* Always operate in split (classic interleaved) mode */ - unsigned int desc =3D AIU_I2S_SOURCE_DESC_MODE_SPLIT; - - /* Reset required to update the pipeline */ - snd_soc_component_write(component, AIU_RST_SOFT, AIU_RST_SOFT_I2S_FAST); - snd_soc_component_read(component, AIU_I2S_SYNC); - - switch (params_physical_width(params)) { - case 16: /* Nothing to do */ - break; - - case 32: - desc |=3D (AIU_I2S_SOURCE_DESC_MODE_24BIT | - AIU_I2S_SOURCE_DESC_MODE_32BIT); - break; - - default: - return -EINVAL; - } - - switch (params_channels(params)) { - case 2: /* Nothing to do */ - break; - case 8: - desc |=3D AIU_I2S_SOURCE_DESC_MODE_8CH; - break; - default: - return -EINVAL; - } - - snd_soc_component_update_bits(component, AIU_I2S_SOURCE_DESC, - AIU_I2S_SOURCE_DESC_MODE_8CH | - AIU_I2S_SOURCE_DESC_MODE_24BIT | - AIU_I2S_SOURCE_DESC_MODE_32BIT | - AIU_I2S_SOURCE_DESC_MODE_SPLIT, - desc); - - return 0; -} - static int aiu_encoder_i2s_set_legacy_div(struct snd_soc_component *compon= ent, struct gx_stream *ts, unsigned int bs) @@ -194,12 +144,6 @@ static int aiu_encoder_i2s_hw_params(struct snd_pcm_su= bstream *substream, ts->width =3D params_width(params); ts->channels =3D params_channels(params); =20 - ret =3D aiu_encoder_i2s_setup_desc(component, params); - if (ret) { - dev_err(dai->dev, "setting i2s desc failed\n"); - return ret; - } - ret =3D aiu_encoder_i2s_set_clocks(component, ts); if (ret) { dev_err(dai->dev, "setting i2s clocks failed\n"); diff --git a/sound/soc/meson/aiu.c b/sound/soc/meson/aiu.c index f2890111c1d2cfa2213bf01849957a796744b9ae..bb3e0364190766ab4ce9ea3ebd3= 13eecf220a244 100644 --- a/sound/soc/meson/aiu.c +++ b/sound/soc/meson/aiu.c @@ -29,13 +29,22 @@ static SOC_ENUM_SINGLE_DECL(aiu_spdif_encode_sel_enum, = AIU_I2S_MISC, static const struct snd_kcontrol_new aiu_spdif_encode_mux =3D SOC_DAPM_ENUM("SPDIF Buffer Src", aiu_spdif_encode_sel_enum); =20 -static const struct snd_soc_dapm_widget aiu_cpu_dapm_widgets[] =3D { - SND_SOC_DAPM_MUX("SPDIF SRC SEL", SND_SOC_NOPM, 0, 0, - &aiu_spdif_encode_mux), +#define AIU_WIDGET_SPDIF_SRC_SEL 0 +#define AIU_WIDGET_I2S_FORMATTER 1 + +static struct snd_soc_dapm_widget aiu_cpu_dapm_widgets[] =3D { + [AIU_WIDGET_SPDIF_SRC_SEL] =3D + SND_SOC_DAPM_MUX("SPDIF SRC SEL", SND_SOC_NOPM, 0, 0, + &aiu_spdif_encode_mux), + [AIU_WIDGET_I2S_FORMATTER] =3D + SND_SOC_DAPM_PGA_E("I2S Formatter", SND_SOC_NOPM, 0, 0, NULL, 0, + gx_formatter_event, + (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD)), }; =20 static const struct snd_soc_dapm_route aiu_cpu_dapm_routes[] =3D { - { "I2S Encoder Playback", NULL, "I2S FIFO Playback" }, + { "I2S Formatter", NULL, "I2S FIFO Playback" }, + { "I2S Encoder Playback", NULL, "I2S Formatter" }, { "SPDIF SRC SEL", "SPDIF", "SPDIF FIFO Playback" }, { "SPDIF SRC SEL", "I2S", "I2S FIFO Playback" }, { "SPDIF Encoder Playback", NULL, "SPDIF SRC SEL" }, @@ -172,6 +181,11 @@ static const struct regmap_config aiu_regmap_cfg =3D { .max_register =3D 0x2ac, }; =20 +const struct gx_formatter_driver aiu_formatter_i2s_drv =3D { + .regmap_cfg =3D &aiu_regmap_cfg, + .ops =3D &aiu_formatter_i2s_ops, +}; + static int aiu_clk_bulk_get(struct device *dev, const char * const *ids, unsigned int num, @@ -291,6 +305,14 @@ static int aiu_probe(struct platform_device *pdev) return ret; } =20 + /* Allocate the aiu-formatter into its widget */ + ret =3D gx_formatter_create(dev, &aiu_cpu_dapm_widgets[AIU_WIDGET_I2S_FOR= MATTER], + &aiu_formatter_i2s_drv, map); + if (ret) { + dev_err(dev, "Failed to allocate aiu formatter\n"); + return ret; + } + /* Register the hdmi codec control component */ ret =3D aiu_hdmi_ctrl_register_component(dev); if (ret) { diff --git a/sound/soc/meson/aiu.h b/sound/soc/meson/aiu.h index 68310de0bdf7a97d8de2ff306c159248ee9b0ede..7d0b98c1f351b3c526ca06c43a4= c04ee5f4b6dfa 100644 --- a/sound/soc/meson/aiu.h +++ b/sound/soc/meson/aiu.h @@ -61,6 +61,7 @@ extern const struct snd_soc_dai_ops aiu_fifo_i2s_dai_ops; extern const struct snd_soc_dai_ops aiu_fifo_spdif_dai_ops; extern const struct snd_soc_dai_ops aiu_encoder_i2s_dai_ops; extern const struct snd_soc_dai_ops aiu_encoder_spdif_dai_ops; +extern const struct gx_formatter_ops aiu_formatter_i2s_ops; =20 #define AIU_IEC958_BPF 0x000 #define AIU_958_MISC 0x010 --=20 2.39.5