sound/hda/codecs/hdmi/tegrahdmi.c
Source file repositories/reference/linux-study-clean/sound/hda/codecs/hdmi/tegrahdmi.c
File Facts
- System
- Linux kernel
- Corpus path
sound/hda/codecs/hdmi/tegrahdmi.c- Extension
.c- Size
- 9208 bytes
- Lines
- 320
- 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 formatfunction tegra_hdmi_pcm_preparefunction tegra_hdmi_pcm_cleanupfunction tegra_hdmi_build_pcmsfunction nvhdmi_chmap_cea_alloc_validate_get_typefunction nvhdmi_chmap_validatefunction tegra_hdmi_initfunction tegrahdmi_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Nvidia Tegra 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_TEGRA,
MODEL_TEGRA234,
};
/*
* The HDA codec on NVIDIA Tegra contains two scratch registers that are
* accessed using vendor-defined verbs. These registers can be used for
* interoperability between the HDA and HDMI drivers.
*/
/* Audio Function Group node */
#define NVIDIA_AFG_NID 0x01
/*
* The SCRATCH0 register is used to notify the HDMI codec of changes in audio
* format. On Tegra, bit 31 is used as a trigger that causes an interrupt to
* be raised in the HDMI codec. The remainder of the bits is arbitrary. This
* implementation stores the HDA format (see AC_FMT_*) in bits [15:0] and an
* additional bit (at position 30) to signal the validity of the format.
*
* | 31 | 30 | 29 16 | 15 0 |
* +---------+-------+--------+--------+
* | TRIGGER | VALID | UNUSED | FORMAT |
* +-----------------------------------|
*
* Note that for the trigger bit to take effect it needs to change value
* (i.e. it needs to be toggled). The trigger bit is not applicable from
* TEGRA234 chip onwards, as new verb id 0xf80 will be used for interrupt
* trigger to hdmi.
*/
#define NVIDIA_SET_HOST_INTR 0xf80
#define NVIDIA_GET_SCRATCH0 0xfa6
#define NVIDIA_SET_SCRATCH0_BYTE0 0xfa7
#define NVIDIA_SET_SCRATCH0_BYTE1 0xfa8
#define NVIDIA_SET_SCRATCH0_BYTE2 0xfa9
#define NVIDIA_SET_SCRATCH0_BYTE3 0xfaa
#define NVIDIA_SCRATCH_TRIGGER (1 << 7)
#define NVIDIA_SCRATCH_VALID (1 << 6)
#define NVIDIA_GET_SCRATCH1 0xfab
#define NVIDIA_SET_SCRATCH1_BYTE0 0xfac
#define NVIDIA_SET_SCRATCH1_BYTE1 0xfad
#define NVIDIA_SET_SCRATCH1_BYTE2 0xfae
#define NVIDIA_SET_SCRATCH1_BYTE3 0xfaf
/*
* The format parameter is the HDA audio format (see AC_FMT_*). If set to 0,
* the format is invalidated so that the HDMI codec can be disabled.
*/
static void tegra_hdmi_set_format(struct hda_codec *codec,
hda_nid_t cvt_nid,
unsigned int format)
{
unsigned int value;
unsigned int nid = NVIDIA_AFG_NID;
struct hdmi_spec *spec = codec->spec;
/*
* Tegra HDA codec design from TEGRA234 chip onwards support DP MST.
* This resulted in moving scratch registers from audio function
* group to converter widget context. So CVT NID should be used for
* scratch register read/write for DP MST supported Tegra HDA codec.
*/
if (codec->dp_mst)
nid = cvt_nid;
/* bits [31:30] contain the trigger and valid bits */
value = snd_hda_codec_read(codec, nid, 0,
NVIDIA_GET_SCRATCH0, 0);
value = (value >> 24) & 0xff;
/* bits [15:0] are used to store the HDA format */
snd_hda_codec_write(codec, nid, 0,
NVIDIA_SET_SCRATCH0_BYTE0,
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 format`, `function tegra_hdmi_pcm_prepare`, `function tegra_hdmi_pcm_cleanup`, `function tegra_hdmi_build_pcms`, `function nvhdmi_chmap_cea_alloc_validate_get_type`, `function nvhdmi_chmap_validate`, `function tegra_hdmi_init`, `function tegrahdmi_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.