sound/hda/codecs/hdmi/nvhdmi-mcp.c
Source file repositories/reference/linux-study-clean/sound/hda/codecs/hdmi/nvhdmi-mcp.c
File Facts
- System
- Linux kernel
- Corpus path
sound/hda/codecs/hdmi/nvhdmi-mcp.c- Extension
.c- Size
- 10141 bytes
- Lines
- 384
- 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/hdaudio.hsound/hda_codec.hhda_local.hhdmi_local.h
Detected Declarations
function nvhdmi_mcp_initfunction nvhdmi_8ch_7x_set_info_frame_parametersfunction nvhdmi_8ch_7x_pcm_closefunction nvhdmi_8ch_7x_pcm_preparefunction nvhdmi_mcp_build_pcmsfunction nvhdmi_mcp_build_controlsfunction nvhdmi_mcp_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Legacy Nvidia HDMI codec support
*/
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <sound/core.h>
#include <sound/hdaudio.h>
#include <sound/hda_codec.h>
#include "hda_local.h"
#include "hdmi_local.h"
enum { MODEL_2CH, MODEL_8CH };
#define Nv_VERB_SET_Channel_Allocation 0xF79
#define Nv_VERB_SET_Info_Frame_Checksum 0xF7A
#define Nv_VERB_SET_Audio_Protection_On 0xF98
#define Nv_VERB_SET_Audio_Protection_Off 0xF99
#define nvhdmi_master_con_nid_7x 0x04
#define nvhdmi_master_pin_nid_7x 0x05
static const hda_nid_t nvhdmi_con_nids_7x[4] = {
/*front, rear, clfe, rear_surr */
0x6, 0x8, 0xa, 0xc,
};
static const struct hda_verb nvhdmi_basic_init_7x_2ch[] = {
/* set audio protect on */
{ 0x1, Nv_VERB_SET_Audio_Protection_On, 0x1},
/* enable digital output on pin widget */
{ 0x5, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
{} /* terminator */
};
static const struct hda_verb nvhdmi_basic_init_7x_8ch[] = {
/* set audio protect on */
{ 0x1, Nv_VERB_SET_Audio_Protection_On, 0x1},
/* enable digital output on pin widget */
{ 0x5, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
{ 0x7, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
{ 0x9, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
{ 0xb, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
{ 0xd, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
{} /* terminator */
};
static int nvhdmi_mcp_init(struct hda_codec *codec)
{
struct hdmi_spec *spec = codec->spec;
if (spec->multiout.max_channels == 2)
snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_2ch);
else
snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_8ch);
return 0;
}
static void nvhdmi_8ch_7x_set_info_frame_parameters(struct hda_codec *codec,
int channels)
{
unsigned int chanmask;
int chan = channels ? (channels - 1) : 1;
switch (channels) {
default:
case 0:
case 2:
chanmask = 0x00;
break;
case 4:
chanmask = 0x08;
break;
case 6:
chanmask = 0x0b;
break;
case 8:
chanmask = 0x13;
break;
}
/* Set the audio infoframe channel allocation and checksum fields. The
* channel count is computed implicitly by the hardware.
*/
snd_hda_codec_write(codec, 0x1, 0,
Nv_VERB_SET_Channel_Allocation, chanmask);
snd_hda_codec_write(codec, 0x1, 0,
Annotation
- Immediate include surface: `linux/init.h`, `linux/slab.h`, `linux/module.h`, `sound/core.h`, `sound/hdaudio.h`, `sound/hda_codec.h`, `hda_local.h`, `hdmi_local.h`.
- Detected declarations: `function nvhdmi_mcp_init`, `function nvhdmi_8ch_7x_set_info_frame_parameters`, `function nvhdmi_8ch_7x_pcm_close`, `function nvhdmi_8ch_7x_pcm_prepare`, `function nvhdmi_mcp_build_pcms`, `function nvhdmi_mcp_build_controls`, `function nvhdmi_mcp_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.