The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Eric Curtin <ericcurtin17@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Ryan Roberts <ryan.roberts@arm.com>,
	Cheng-Yi Chiang <cychiang@chromium.org>,
	Tzung-Bi Shih <tzungbi@kernel.org>,
	Guenter Roeck <groeck@chromium.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>, Benson Leung <bleung@chromium.org>,
	Oder Chiou <oder_chiou@realtek.com>,
	chrome-platform@lists.linux.dev, linux-sound@vger.kernel.org
Subject: [RFC PATCH v2 3/3] ASoC: codecs: Initialise PCM hardware tables at boot for page size
Date: Wed,  2 Dec 2026 03:17:29 +0000	[thread overview]
Message-ID: <20261202031733.1704898-4-ericcurtin17@gmail.com> (raw)
In-Reply-To: <20261202031733.1704898-1-ericcurtin17@gmail.com>

From: Ryan Roberts <ryan.roberts@arm.com>

The snd_pcm_hardware tables in cros_ec_codec.c and rt5514-spi.c use
PAGE_SIZE in their initialisers. That is not a constant expression with
arm64 boot-time page size selection, so the tables cannot be static
initialisers.

Define them with DEFINE_GLOBAL_PAGE_SIZE_VAR_CONST(), which keeps a
normal const initialiser for a fixed page size and otherwise fills the
table in once the page size is known at boot. In cros_ec_codec.c the
table was local to wov_pcm_open(), so it moves to file scope.

Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
Signed-off-by: Eric Curtin <eric.curtin@docker.com>
---
 sound/soc/codecs/cros_ec_codec.c | 30 +++++++++++++++---------------
 sound/soc/codecs/rt5514-spi.c    |  5 +++--
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/sound/soc/codecs/cros_ec_codec.c b/sound/soc/codecs/cros_ec_codec.c
index b6f7016a324a..f6e0395d47a1 100644
--- a/sound/soc/codecs/cros_ec_codec.c
+++ b/sound/soc/codecs/cros_ec_codec.c
@@ -874,24 +874,24 @@ static void wov_remove(struct snd_soc_component *component)
 			&priv->ec_device->event_notifier, &priv->wov_notifier);
 }
 
+static DEFINE_GLOBAL_PAGE_SIZE_VAR_CONST(struct snd_pcm_hardware, hw_param, {
+	.info = SNDRV_PCM_INFO_MMAP |
+		SNDRV_PCM_INFO_INTERLEAVED |
+		SNDRV_PCM_INFO_MMAP_VALID,
+	.formats = SNDRV_PCM_FMTBIT_S16_LE,
+	.rates = SNDRV_PCM_RATE_16000,
+	.channels_min = 1,
+	.channels_max = 1,
+	.period_bytes_min = PAGE_SIZE,
+	.period_bytes_max = 0x20000 / 8,
+	.periods_min = 8,
+	.periods_max = 8,
+	.buffer_bytes_max = 0x20000,
+});
+
 static int wov_pcm_open(struct snd_soc_component *component,
 			struct snd_pcm_substream *substream)
 {
-	static const struct snd_pcm_hardware hw_param = {
-		.info = SNDRV_PCM_INFO_MMAP |
-			SNDRV_PCM_INFO_INTERLEAVED |
-			SNDRV_PCM_INFO_MMAP_VALID,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
-		.rates = SNDRV_PCM_RATE_16000,
-		.channels_min = 1,
-		.channels_max = 1,
-		.period_bytes_min = PAGE_SIZE,
-		.period_bytes_max = 0x20000 / 8,
-		.periods_min = 8,
-		.periods_max = 8,
-		.buffer_bytes_max = 0x20000,
-	};
-
 	return snd_soc_set_runtime_hwparams(substream, &hw_param);
 }
 
diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c
index bcc2ff28b125..f619f3475397 100644
--- a/sound/soc/codecs/rt5514-spi.c
+++ b/sound/soc/codecs/rt5514-spi.c
@@ -46,7 +46,8 @@ struct rt5514_dsp {
 	int irq;
 };
 
-static const struct snd_pcm_hardware rt5514_spi_pcm_hardware = {
+static DEFINE_GLOBAL_PAGE_SIZE_VAR_CONST(struct snd_pcm_hardware,
+						rt5514_spi_pcm_hardware, {
 	.info			= SNDRV_PCM_INFO_MMAP |
 				  SNDRV_PCM_INFO_MMAP_VALID |
 				  SNDRV_PCM_INFO_INTERLEAVED,
@@ -58,7 +59,7 @@ static const struct snd_pcm_hardware rt5514_spi_pcm_hardware = {
 	.channels_min		= 1,
 	.channels_max		= 1,
 	.buffer_bytes_max	= 0x20000,
-};
+});
 
 static struct snd_soc_dai_driver rt5514_spi_dai = {
 	.name = "rt5514-dsp-cpu-dai",

  parent reply	other threads:[~2026-12-02  3:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  3:17 [RFC PATCH v2 0/3] ALSA/ASoC: Prepare for boot-time page size selection on arm64 Eric Curtin
2026-12-02  3:17 ` [RFC PATCH v2 1/3] ALSA: Handle run-time PAGE_SIZE in PCM hardware tables and #if checks Eric Curtin
2026-12-02  9:08   ` Takashi Iwai
2026-12-02  3:17 ` [RFC PATCH v2 2/3] ASoC: tegra: Initialise PCM hardware limits at boot for page size Eric Curtin
2026-12-02  3:17 ` Eric Curtin [this message]
2026-12-02  4:56   ` [RFC PATCH v2 3/3] ASoC: codecs: Initialise PCM hardware tables " Tzung-Bi Shih

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=20261202031733.1704898-4-ericcurtin17@gmail.com \
    --to=ericcurtin17@gmail.com \
    --cc=bleung@chromium.org \
    --cc=broonie@kernel.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=cychiang@chromium.org \
    --cc=groeck@chromium.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=oder_chiou@realtek.com \
    --cc=perex@perex.cz \
    --cc=ryan.roberts@arm.com \
    --cc=tiwai@suse.com \
    --cc=tzungbi@kernel.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