sound/hda/core/hdmi_chmap.c
Source file repositories/reference/linux-study-clean/sound/hda/core/hdmi_chmap.c
File Facts
- System
- Linux kernel
- Corpus path
sound/hda/core/hdmi_chmap.c- Extension
.c- Size
- 25255 bytes
- Lines
- 872
- Domain
- Driver Families
- Bucket
- sound/hda
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hsound/control.hsound/tlv.hsound/hda_chmap.h
Detected Declarations
struct channel_map_tableenum cea_speaker_placementfunction hdmi_pin_set_slot_channelfunction hdmi_pin_get_slot_channelfunction hdmi_get_channel_countfunction hdmi_set_channel_countfunction init_channel_allocationsfunction get_channel_allocation_orderfunction snd_hdac_print_channel_allocationfunction hdmi_channel_allocation_spk_alloc_blkfunction hdmi_debug_channel_mappingfunction hdmi_std_setup_channel_mappingfunction snd_hdac_chmap_to_spk_maskfunction to_cea_slotfunction snd_hdac_spk_to_chmapfunction from_cea_slotfunction hdmi_manual_channel_allocationfunction hdmi_manual_setup_channel_mappingfunction hdmi_setup_fake_chmapfunction snd_hdac_setup_channel_mappingfunction snd_hdac_get_active_channelsfunction snd_hdac_channel_allocationfunction hdmi_chmap_ctl_infofunction hdmi_chmap_cea_alloc_validate_get_typefunction hdmi_cea_alloc_to_tlv_chmapfunction spk_mask_from_spk_allocfunction hdmi_chmap_ctl_tlvfunction hdmi_chmap_ctl_getfunction chmap_value_checkfunction hdmi_chmap_ctl_putfunction snd_hdac_register_chmap_opsfunction snd_hdac_add_chmap_ctlsexport snd_hdac_print_channel_allocationexport snd_hdac_chmap_to_spk_maskexport snd_hdac_spk_to_chmapexport snd_hdac_setup_channel_mappingexport snd_hdac_get_active_channelsexport snd_hdac_get_ch_alloc_from_caexport snd_hdac_channel_allocationexport snd_hdac_register_chmap_opsexport snd_hdac_add_chmap_ctls
Annotated Snippet
struct channel_map_table {
unsigned char map; /* ALSA API channel map position */
int spk_mask; /* speaker position bit mask */
};
static struct channel_map_table map_tables[] = {
{ SNDRV_CHMAP_FL, FL },
{ SNDRV_CHMAP_FR, FR },
{ SNDRV_CHMAP_RL, RL },
{ SNDRV_CHMAP_RR, RR },
{ SNDRV_CHMAP_LFE, LFE },
{ SNDRV_CHMAP_FC, FC },
{ SNDRV_CHMAP_RLC, RLC },
{ SNDRV_CHMAP_RRC, RRC },
{ SNDRV_CHMAP_RC, RC },
{ SNDRV_CHMAP_FLC, FLC },
{ SNDRV_CHMAP_FRC, FRC },
{ SNDRV_CHMAP_TFL, FLH },
{ SNDRV_CHMAP_TFR, FRH },
{ SNDRV_CHMAP_FLW, FLW },
{ SNDRV_CHMAP_FRW, FRW },
{ SNDRV_CHMAP_TC, TC },
{ SNDRV_CHMAP_TFC, FCH },
{} /* terminator */
};
/* from ALSA API channel position to speaker bit mask */
int snd_hdac_chmap_to_spk_mask(unsigned char c)
{
struct channel_map_table *t = map_tables;
for (; t->map; t++) {
if (t->map == c)
return t->spk_mask;
}
return 0;
}
EXPORT_SYMBOL_GPL(snd_hdac_chmap_to_spk_mask);
/* from ALSA API channel position to CEA slot */
static int to_cea_slot(int ordered_ca, unsigned char pos)
{
int mask = snd_hdac_chmap_to_spk_mask(pos);
int i;
/* Add sanity check to pass klockwork check.
* This should never happen.
*/
if (ordered_ca >= ARRAY_SIZE(channel_allocations))
return -1;
if (mask) {
for (i = 0; i < 8; i++) {
if (channel_allocations[ordered_ca].speakers[7 - i] == mask)
return i;
}
}
return -1;
}
/* from speaker bit mask to ALSA API channel position */
int snd_hdac_spk_to_chmap(int spk)
{
struct channel_map_table *t = map_tables;
for (; t->map; t++) {
if (t->spk_mask == spk)
return t->map;
}
return 0;
}
EXPORT_SYMBOL_GPL(snd_hdac_spk_to_chmap);
/* from CEA slot to ALSA API channel position */
static int from_cea_slot(int ordered_ca, unsigned char slot)
{
int mask;
/* Add sanity check to pass klockwork check.
* This should never happen.
*/
if (slot >= 8)
return 0;
mask = channel_allocations[ordered_ca].speakers[7 - slot];
return snd_hdac_spk_to_chmap(mask);
}
Annotation
- Immediate include surface: `linux/module.h`, `sound/control.h`, `sound/tlv.h`, `sound/hda_chmap.h`.
- Detected declarations: `struct channel_map_table`, `enum cea_speaker_placement`, `function hdmi_pin_set_slot_channel`, `function hdmi_pin_get_slot_channel`, `function hdmi_get_channel_count`, `function hdmi_set_channel_count`, `function init_channel_allocations`, `function get_channel_allocation_order`, `function snd_hdac_print_channel_allocation`, `function hdmi_channel_allocation_spk_alloc_blk`.
- Atlas domain: Driver Families / sound/hda.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.