sound/x86/intel_hdmi_audio.c
Source file repositories/reference/linux-study-clean/sound/x86/intel_hdmi_audio.c
File Facts
- System
- Linux kernel
- Corpus path
sound/x86/intel_hdmi_audio.c- Extension
.c- Size
- 50232 bytes
- Lines
- 1829
- Domain
- Driver Families
- Bucket
- sound/x86
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/platform_device.hlinux/io.hlinux/slab.hlinux/module.hlinux/interrupt.hlinux/pm_runtime.hlinux/dma-mapping.hlinux/delay.hlinux/string.hsound/core.hsound/asoundef.hsound/pcm.hsound/pcm_params.hsound/initval.hsound/control.hsound/jack.hdrm/drm_edid.hdrm/drm_eld.hdrm/intel/intel_lpe_audio.hintel_hdmi_audio.h
Detected Declarations
function had_substream_putfunction had_substream_putfunction had_config_offsetfunction had_read_register_rawfunction had_write_register_rawfunction had_read_registerfunction had_write_registerfunction had_enable_audiofunction had_ack_irqsfunction had_reset_audiofunction had_prog_status_regfunction had_init_audio_ctrlfunction init_channel_allocationsfunction had_channel_allocationfunction spk_to_chmapfunction had_build_channel_allocation_mapfunction had_chmap_ctl_infofunction had_chmap_ctl_getfunction had_register_chmap_ctlsfunction had_prog_dipfunction had_calculate_maud_valuefunction had_prog_ctsfunction had_calculate_n_valuefunction had_prog_nfunction pcm_headfunction had_invalidate_bdfunction had_init_ringbuffunction had_advance_ringbuffunction had_process_ringbuffunction had_process_buffer_donefunction wait_clear_underrun_bitfunction had_pcm_sync_stopfunction had_process_buffer_underrunfunction had_pcm_openfunction had_pcm_closefunction had_pcm_hw_paramsfunction had_pcm_triggerfunction had_pcm_preparefunction had_pcm_pointerfunction had_process_mode_changefunction had_process_hot_plugfunction scoped_guardfunction had_process_hot_unplugfunction scoped_guardfunction had_iec958_infofunction had_iec958_getfunction had_iec958_mask_getfunction had_iec958_put
Annotated Snippet
if (p->speakers[j]) {
p->channels++;
p->spk_mask |= p->speakers[j];
}
}
}
/*
* The transformation takes two steps:
*
* eld->spk_alloc => (eld_speaker_allocation_bits[]) => spk_mask
* spk_mask => (channel_allocations[]) => ai->CA
*
* TODO: it could select the wrong CA from multiple candidates.
*/
static int had_channel_allocation(struct snd_intelhad *intelhaddata,
int channels)
{
int i;
int ca = 0;
int spk_mask = 0;
/*
* CA defaults to 0 for basic stereo audio
*/
if (channels <= 2)
return 0;
/*
* expand ELD's speaker allocation mask
*
* ELD tells the speaker mask in a compact(paired) form,
* expand ELD's notions to match the ones used by Audio InfoFrame.
*/
for (i = 0; i < ARRAY_SIZE(eld_speaker_allocation_bits); i++) {
if (intelhaddata->eld[DRM_ELD_SPEAKER] & (1 << i))
spk_mask |= eld_speaker_allocation_bits[i];
}
/* search for the first working match in the CA table */
for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) {
if (channels == channel_allocations[i].channels &&
(spk_mask & channel_allocations[i].spk_mask) ==
channel_allocations[i].spk_mask) {
ca = channel_allocations[i].ca_index;
break;
}
}
dev_dbg(intelhaddata->dev, "select CA 0x%x for %d\n", ca, channels);
return ca;
}
/* from speaker bit mask to ALSA API channel position */
static int spk_to_chmap(int spk)
{
const struct channel_map_table *t = map_tables;
for (; t->map; t++) {
if (t->spk_mask == spk)
return t->map;
}
return 0;
}
static void had_build_channel_allocation_map(struct snd_intelhad *intelhaddata)
{
int i, c;
int spk_mask = 0;
struct snd_pcm_chmap_elem *chmap;
u8 eld_high, eld_high_mask = 0xF0;
u8 high_msb;
kfree(intelhaddata->chmap->chmap);
intelhaddata->chmap->chmap = NULL;
chmap = kzalloc_obj(*chmap);
if (!chmap)
return;
dev_dbg(intelhaddata->dev, "eld speaker = %x\n",
intelhaddata->eld[DRM_ELD_SPEAKER]);
/* WA: Fix the max channel supported to 8 */
/*
* Sink may support more than 8 channels, if eld_high has more than
* one bit set. SOC supports max 8 channels.
Annotation
- Immediate include surface: `linux/types.h`, `linux/platform_device.h`, `linux/io.h`, `linux/slab.h`, `linux/module.h`, `linux/interrupt.h`, `linux/pm_runtime.h`, `linux/dma-mapping.h`.
- Detected declarations: `function had_substream_put`, `function had_substream_put`, `function had_config_offset`, `function had_read_register_raw`, `function had_write_register_raw`, `function had_read_register`, `function had_write_register`, `function had_enable_audio`, `function had_ack_irqs`, `function had_reset_audio`.
- Atlas domain: Driver Families / sound/x86.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.