[PATCH RFC 2/4] ALSA: hda: Make CEA channel allocation interfaces const
From: Cássio Gabriel
Date: Fri Jun 12 2026 - 00:54:26 EST
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@xxxxxxxxx>
---
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