sound/hda/codecs/hdmi/nvhdmi.c
Source file repositories/reference/linux-study-clean/sound/hda/codecs/hdmi/nvhdmi.c
File Facts
- System
- Linux kernel
- Corpus path
sound/hda/codecs/hdmi/nvhdmi.c- Extension
.c- Size
- 9157 bytes
- Lines
- 241
- Domain
- Driver Families
- Bucket
- sound/hda
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/slab.hlinux/module.hsound/core.hsound/tlv.hsound/hdaudio.hsound/hda_codec.hhda_local.hhdmi_local.h
Detected Declarations
function nvhdmi_chmap_cea_alloc_validate_get_typefunction nvhdmi_chmap_validatefunction nvhdmi_pin2portfunction nvhdmi_port2pinfunction probe_genericfunction probe_legacyfunction nvhdmi_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Nvidia HDMI codec support
*/
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <sound/core.h>
#include <sound/tlv.h>
#include <sound/hdaudio.h>
#include <sound/hda_codec.h>
#include "hda_local.h"
#include "hdmi_local.h"
enum {
MODEL_GENERIC,
MODEL_LEGACY,
};
/*
* NVIDIA codecs ignore ASP mapping for 2ch - confirmed on:
* - 0x10de0015
* - 0x10de0040
*/
static int nvhdmi_chmap_cea_alloc_validate_get_type(struct hdac_chmap *chmap,
struct hdac_cea_channel_speaker_allocation *cap, int channels)
{
if (cap->ca_index == 0x00 && channels == 2)
return SNDRV_CTL_TLVT_CHMAP_FIXED;
/* If the speaker allocation matches the channel count, it is OK. */
if (cap->channels != channels)
return -1;
/* all channels are remappable freely */
return SNDRV_CTL_TLVT_CHMAP_VAR;
}
static int nvhdmi_chmap_validate(struct hdac_chmap *chmap,
int ca, int chs, unsigned char *map)
{
if (ca == 0x00 && (map[0] != SNDRV_CHMAP_FL || map[1] != SNDRV_CHMAP_FR))
return -EINVAL;
return 0;
}
/* map from pin NID to port; port is 0-based */
/* for Nvidia: assume widget NID starting from 4, with step 1 (4, 5, 6, ...) */
static int nvhdmi_pin2port(void *audio_ptr, int pin_nid)
{
return pin_nid - 4;
}
/* reverse-map from port to pin NID: see above */
static int nvhdmi_port2pin(struct hda_codec *codec, int port)
{
return port + 4;
}
static const struct drm_audio_component_audio_ops nvhdmi_audio_ops = {
.pin2port = nvhdmi_pin2port,
.pin_eld_notify = snd_hda_hdmi_acomp_pin_eld_notify,
.master_bind = snd_hda_hdmi_acomp_master_bind,
.master_unbind = snd_hda_hdmi_acomp_master_unbind,
};
static int probe_generic(struct hda_codec *codec)
{
struct hdmi_spec *spec;
int err;
err = snd_hda_hdmi_generic_alloc(codec);
if (err < 0)
return err;
codec->dp_mst = true;
spec = codec->spec;
err = snd_hda_hdmi_parse_codec(codec);
if (err < 0) {
snd_hda_hdmi_generic_spec_free(codec);
return err;
}
snd_hda_hdmi_generic_init_per_pins(codec);
spec->dyn_pin_out = true;
Annotation
- Immediate include surface: `linux/init.h`, `linux/slab.h`, `linux/module.h`, `sound/core.h`, `sound/tlv.h`, `sound/hdaudio.h`, `sound/hda_codec.h`, `hda_local.h`.
- Detected declarations: `function nvhdmi_chmap_cea_alloc_validate_get_type`, `function nvhdmi_chmap_validate`, `function nvhdmi_pin2port`, `function nvhdmi_port2pin`, `function probe_generic`, `function probe_legacy`, `function nvhdmi_probe`.
- Atlas domain: Driver Families / sound/hda.
- Implementation status: source 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.