From: "Cássio Gabriel" <cassiogabrielcontato@gmail.com>
To: Takashi Iwai <tiwai@suse.com>,
Thierry Reding <thierry.reding@kernel.org>,
Jonathan Hunter <jonathanh@nvidia.com>,
Jaroslav Kysela <perex@perex.cz>
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-tegra@vger.kernel.org, notify@kernel.org,
"Cássio Gabriel" <cassiogabrielcontato@gmail.com>
Subject: [PATCH RFC 2/4] ALSA: hda: Make CEA channel allocation interfaces const
Date: Fri, 12 Jun 2026 01:53:24 -0300 [thread overview]
Message-ID: <20260612-alsa-cea-channel-allocation-v1-2-b1bcbb6b1051@gmail.com> (raw)
In-Reply-To: <20260612-alsa-cea-channel-allocation-v1-0-b1bcbb6b1051@gmail.com>
The CEA channel allocation descriptors are initialized once and only
read by the HDA channel-map helpers and codec-specific callbacks.
Qualify the pointers passed through these interfaces as const. This
makes their read-only contract explicit and prepares the interfaces for
using an immutable common allocation table.
Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
---
include/sound/hda_chmap.h | 8 +++++---
sound/hda/codecs/hdmi/atihdmi.c | 6 +++---
sound/hda/codecs/hdmi/nvhdmi.c | 3 ++-
sound/hda/codecs/hdmi/tegrahdmi.c | 3 ++-
sound/hda/core/hdmi_chmap.c | 12 +++++++-----
5 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/include/sound/hda_chmap.h b/include/sound/hda_chmap.h
index e508f3192294..b539595fd5cd 100644
--- a/include/sound/hda_chmap.h
+++ b/include/sound/hda_chmap.h
@@ -28,9 +28,10 @@ struct hdac_chmap_ops {
* for devices that have non-standard mapping requirements.
*/
int (*chmap_cea_alloc_validate_get_type)(struct hdac_chmap *chmap,
- struct hdac_cea_channel_speaker_allocation *cap, int channels);
+ const struct hdac_cea_channel_speaker_allocation *cap,
+ int channels);
void (*cea_alloc_to_tlv_chmap)(struct hdac_chmap *hchmap,
- struct hdac_cea_channel_speaker_allocation *cap,
+ const struct hdac_cea_channel_speaker_allocation *cap,
unsigned int *chmap, int channels);
/* check that the user-given chmap is supported */
@@ -71,7 +72,8 @@ void snd_hdac_setup_channel_mapping(struct hdac_chmap *chmap,
int channels, unsigned char *map,
bool chmap_set);
void snd_hdac_print_channel_allocation(int spk_alloc, char *buf, int buflen);
-struct hdac_cea_channel_speaker_allocation *snd_hdac_get_ch_alloc_from_ca(int ca);
+const struct hdac_cea_channel_speaker_allocation *
+snd_hdac_get_ch_alloc_from_ca(int ca);
int snd_hdac_chmap_to_spk_mask(unsigned char c);
int snd_hdac_spk_to_chmap(int spk);
int snd_hdac_add_chmap_ctls(struct snd_pcm *pcm, int pcm_idx,
diff --git a/sound/hda/codecs/hdmi/atihdmi.c b/sound/hda/codecs/hdmi/atihdmi.c
index 44366f75de33..9afdbf44b6f0 100644
--- a/sound/hda/codecs/hdmi/atihdmi.c
+++ b/sound/hda/codecs/hdmi/atihdmi.c
@@ -262,7 +262,7 @@ static int atihdmi_paired_swap_fc_lfe(int pos)
static int atihdmi_paired_chmap_validate(struct hdac_chmap *chmap,
int ca, int chs, unsigned char *map)
{
- struct hdac_cea_channel_speaker_allocation *cap;
+ const struct hdac_cea_channel_speaker_allocation *cap;
int i, j;
/* check that only channel pairs need to be remapped on old pre-rev3 ATI/AMD */
@@ -377,7 +377,7 @@ static int atihdmi_pin_get_slot_channel(struct hdac_device *hdac,
static int atihdmi_paired_chmap_cea_alloc_validate_get_type(
struct hdac_chmap *chmap,
- struct hdac_cea_channel_speaker_allocation *cap,
+ const struct hdac_cea_channel_speaker_allocation *cap,
int channels)
{
int c;
@@ -406,7 +406,7 @@ static int atihdmi_paired_chmap_cea_alloc_validate_get_type(
}
static void atihdmi_paired_cea_alloc_to_tlv_chmap(struct hdac_chmap *hchmap,
- struct hdac_cea_channel_speaker_allocation *cap,
+ const struct hdac_cea_channel_speaker_allocation *cap,
unsigned int *chmap, int channels)
{
/* produce paired maps for pre-rev3 ATI/AMD codecs */
diff --git a/sound/hda/codecs/hdmi/nvhdmi.c b/sound/hda/codecs/hdmi/nvhdmi.c
index 94671ad24b5e..eaefa016cdec 100644
--- a/sound/hda/codecs/hdmi/nvhdmi.c
+++ b/sound/hda/codecs/hdmi/nvhdmi.c
@@ -24,7 +24,8 @@ enum {
* - 0x10de0040
*/
static int nvhdmi_chmap_cea_alloc_validate_get_type(struct hdac_chmap *chmap,
- struct hdac_cea_channel_speaker_allocation *cap, int channels)
+ const struct hdac_cea_channel_speaker_allocation *cap,
+ int channels)
{
if (cap->ca_index == 0x00 && channels == 2)
return SNDRV_CTL_TLVT_CHMAP_FIXED;
diff --git a/sound/hda/codecs/hdmi/tegrahdmi.c b/sound/hda/codecs/hdmi/tegrahdmi.c
index ebb6410a4831..751a50cd4b7d 100644
--- a/sound/hda/codecs/hdmi/tegrahdmi.c
+++ b/sound/hda/codecs/hdmi/tegrahdmi.c
@@ -205,7 +205,8 @@ static int tegra_hdmi_build_pcms(struct hda_codec *codec)
* - 0x10de0040
*/
static int nvhdmi_chmap_cea_alloc_validate_get_type(struct hdac_chmap *chmap,
- struct hdac_cea_channel_speaker_allocation *cap, int channels)
+ const struct hdac_cea_channel_speaker_allocation *cap,
+ int channels)
{
if (cap->ca_index == 0x00 && channels == 2)
return SNDRV_CTL_TLVT_CHMAP_FIXED;
diff --git a/sound/hda/core/hdmi_chmap.c b/sound/hda/core/hdmi_chmap.c
index c897fc443467..f76b5dcc6433 100644
--- a/sound/hda/core/hdmi_chmap.c
+++ b/sound/hda/core/hdmi_chmap.c
@@ -341,7 +341,7 @@ static void hdmi_std_setup_channel_mapping(struct hdac_chmap *chmap,
bool non_pcm,
int ca)
{
- struct hdac_cea_channel_speaker_allocation *ch_alloc;
+ const struct hdac_cea_channel_speaker_allocation *ch_alloc;
int i;
int err;
int order;
@@ -581,7 +581,8 @@ int snd_hdac_get_active_channels(int ca)
}
EXPORT_SYMBOL_GPL(snd_hdac_get_active_channels);
-struct hdac_cea_channel_speaker_allocation *snd_hdac_get_ch_alloc_from_ca(int ca)
+const struct hdac_cea_channel_speaker_allocation *
+snd_hdac_get_ch_alloc_from_ca(int ca)
{
return &channel_allocations[get_channel_allocation_order(ca)];
}
@@ -622,7 +623,8 @@ static int hdmi_chmap_ctl_info(struct snd_kcontrol *kcontrol,
}
static int hdmi_chmap_cea_alloc_validate_get_type(struct hdac_chmap *chmap,
- struct hdac_cea_channel_speaker_allocation *cap, int channels)
+ const struct hdac_cea_channel_speaker_allocation *cap,
+ int channels)
{
/* If the speaker allocation matches the channel count, it is OK.*/
if (cap->channels != channels)
@@ -633,7 +635,7 @@ static int hdmi_chmap_cea_alloc_validate_get_type(struct hdac_chmap *chmap,
}
static void hdmi_cea_alloc_to_tlv_chmap(struct hdac_chmap *hchmap,
- struct hdac_cea_channel_speaker_allocation *cap,
+ const struct hdac_cea_channel_speaker_allocation *cap,
unsigned int *chmap, int channels)
{
int count = 0;
@@ -690,7 +692,7 @@ static int hdmi_chmap_ctl_tlv(struct snd_kcontrol *kcontrol, int op_flag,
for (chs = 2; chs <= max_chs; chs++) {
int i;
- struct hdac_cea_channel_speaker_allocation *cap;
+ const struct hdac_cea_channel_speaker_allocation *cap;
cap = channel_allocations;
for (i = 0; i < ARRAY_SIZE(channel_allocations); i++, cap++) {
--
2.54.0
next prev parent reply other threads:[~2026-06-12 4:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-12 4:53 [PATCH RFC 0/4] ALSA: Consolidate CEA channel allocation data Cássio Gabriel
2026-06-12 4:53 ` [PATCH RFC 1/4] ALSA: pcm: Add common CEA channel allocation helpers Cássio Gabriel
2026-06-12 4:53 ` Cássio Gabriel [this message]
2026-06-12 4:53 ` [PATCH RFC 3/4] ALSA: hda: Use common CEA channel allocations Cássio Gabriel
2026-06-12 4:53 ` [PATCH RFC 4/4] ALSA: x86: " Cássio Gabriel
2026-06-12 9:13 ` [PATCH RFC 0/4] ALSA: Consolidate CEA channel allocation data Takashi Iwai
2026-06-12 11:44 ` Cássio Gabriel
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=20260612-alsa-cea-channel-allocation-v1-2-b1bcbb6b1051@gmail.com \
--to=cassiogabrielcontato@gmail.com \
--cc=jonathanh@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=notify@kernel.org \
--cc=perex@perex.cz \
--cc=thierry.reding@kernel.org \
--cc=tiwai@suse.com \
/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®