sound/core/pcm_drm_eld.c
Source file repositories/reference/linux-study-clean/sound/core/pcm_drm_eld.c
File Facts
- System
- Linux kernel
- Corpus path
sound/core/pcm_drm_eld.c- Extension
.c- Size
- 14842 bytes
- Lines
- 552
- Domain
- Driver Families
- Bucket
- sound/core
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/export.hlinux/hdmi.hlinux/unaligned.hdrm/drm_edid.hdrm/drm_eld.hsound/info.hsound/pcm.hsound/pcm_drm_eld.h
Detected Declarations
function map_rate_familiesfunction sad_rate_maskfunction sad_max_channelsfunction eld_limit_ratesfunction eld_limit_channelsfunction snd_pcm_hw_constraint_eldfunction hdmi_update_short_audio_descfunction snd_parse_eldfunction hdmi_print_pcm_ratesfunction eld_print_pcm_bitsfunction hdmi_show_short_audio_descfunction snd_eld_print_channel_allocationfunction snd_show_eldfunction hdmi_print_sad_infofunction snd_print_eld_infoexport snd_pcm_hw_constraint_eldexport snd_parse_eldexport snd_show_eldexport snd_print_eld_info
Annotated Snippet
if (ELD_FIXED_BYTES + mnl + 3 * (i + 1) > size) {
dev_info(dev, "HDMI: out of range SAD %d\n", i);
goto out_fail;
}
hdmi_update_short_audio_desc(dev, e->sad + i,
buf + ELD_FIXED_BYTES + mnl + 3 * i);
}
/*
* HDMI sink's ELD info cannot always be retrieved for now, e.g.
* in console or for audio devices. Assume the highest speakers
* configuration, to _not_ prohibit multi-channel audio playback.
*/
if (!e->spk_alloc && e->sad_count)
e->spk_alloc = 0xffff;
return 0;
out_fail:
return -EINVAL;
}
EXPORT_SYMBOL_GPL(snd_parse_eld);
/*
* SNDRV_PCM_RATE_* and AC_PAR_PCM values don't match, print correct rates with
* hdmi-specific routine.
*/
static void hdmi_print_pcm_rates(int pcm, char *buf, int buflen)
{
static const unsigned int alsa_rates[] = {
5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, 64000,
88200, 96000, 176400, 192000, 384000
};
int i, j;
for (i = 0, j = 0; i < ARRAY_SIZE(alsa_rates); i++)
if (pcm & (1 << i))
j += scnprintf(buf + j, buflen - j, " %d",
alsa_rates[i]);
buf[j] = '\0'; /* necessary when j == 0 */
}
static void eld_print_pcm_bits(int pcm, char *buf, int buflen)
{
static const unsigned int bits[] = { 8, 16, 20, 24, 32 };
int i, j;
for (i = 0, j = 0; i < ARRAY_SIZE(bits); i++)
if (pcm & (ELD_PCM_BITS_8 << i))
j += scnprintf(buf + j, buflen - j, " %d", bits[i]);
buf[j] = '\0'; /* necessary when j == 0 */
}
static void hdmi_show_short_audio_desc(struct device *dev,
struct snd_cea_sad *a)
{
char buf[SND_PRINT_RATES_ADVISED_BUFSIZE];
char buf2[8 + SND_PRINT_BITS_ADVISED_BUFSIZE] = ", bits =";
if (!a->format)
return;
hdmi_print_pcm_rates(a->rates, buf, sizeof(buf));
if (a->format == AUDIO_CODING_TYPE_LPCM)
eld_print_pcm_bits(a->sample_bits, buf2 + 8, sizeof(buf2) - 8);
else if (a->max_bitrate)
snprintf(buf2, sizeof(buf2),
", max bitrate = %d", a->max_bitrate);
else
buf2[0] = '\0';
dev_dbg(dev,
"HDMI: supports coding type %s: channels = %d, rates =%s%s\n",
cea_audio_coding_type_names[a->format],
a->channels, buf, buf2);
}
static void snd_eld_print_channel_allocation(int spk_alloc, char *buf, int buflen)
{
int i, j;
for (i = 0, j = 0; i < ARRAY_SIZE(cea_speaker_allocation_names); i++) {
if (spk_alloc & (1 << i))
j += scnprintf(buf + j, buflen - j, " %s",
cea_speaker_allocation_names[i]);
}
buf[j] = '\0'; /* necessary when j == 0 */
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/export.h`, `linux/hdmi.h`, `linux/unaligned.h`, `drm/drm_edid.h`, `drm/drm_eld.h`, `sound/info.h`, `sound/pcm.h`.
- Detected declarations: `function map_rate_families`, `function sad_rate_mask`, `function sad_max_channels`, `function eld_limit_rates`, `function eld_limit_channels`, `function snd_pcm_hw_constraint_eld`, `function hdmi_update_short_audio_desc`, `function snd_parse_eld`, `function hdmi_print_pcm_rates`, `function eld_print_pcm_bits`.
- Atlas domain: Driver Families / sound/core.
- Implementation status: integration implementation candidate.
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.