sound/hda/codecs/hdmi/simplehdmi.c
Source file repositories/reference/linux-study-clean/sound/hda/codecs/hdmi/simplehdmi.c
File Facts
- System
- Linux kernel
- Corpus path
sound/hda/codecs/hdmi/simplehdmi.c- Extension
.c- Size
- 6797 bytes
- Lines
- 252
- Domain
- Driver Families
- Bucket
- sound/hda
- 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.
- 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/slab.hlinux/module.hhdmi_local.hhda_jack.h
Detected Declarations
function snd_hda_hdmi_simple_build_pcmsfunction snd_hda_hdmi_simple_unsol_eventfunction free_hdmi_jack_privfunction simple_hdmi_build_jackfunction snd_hda_hdmi_simple_build_controlsfunction snd_hda_hdmi_simple_initfunction snd_hda_hdmi_simple_removefunction snd_hda_hdmi_simple_pcm_openfunction simple_playback_pcm_closefunction simple_playback_pcm_preparefunction snd_hda_hdmi_simple_probefunction simplehdmi_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Non-generic simple HDMI codec support
*/
#include <linux/slab.h>
#include <linux/module.h>
#include "hdmi_local.h"
#include "hda_jack.h"
int snd_hda_hdmi_simple_build_pcms(struct hda_codec *codec)
{
struct hdmi_spec *spec = codec->spec;
struct hda_pcm *info;
unsigned int chans;
struct hda_pcm_stream *pstr;
struct hdmi_spec_per_cvt *per_cvt;
per_cvt = get_cvt(spec, 0);
chans = get_wcaps(codec, per_cvt->cvt_nid);
chans = get_wcaps_channels(chans);
info = snd_hda_codec_pcm_new(codec, "HDMI 0");
if (!info)
return -ENOMEM;
spec->pcm_rec[0].pcm = info;
info->pcm_type = HDA_PCM_TYPE_HDMI;
pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK];
*pstr = spec->pcm_playback;
pstr->nid = per_cvt->cvt_nid;
if (pstr->channels_max <= 2 && chans && chans <= 16)
pstr->channels_max = chans;
return 0;
}
EXPORT_SYMBOL_NS_GPL(snd_hda_hdmi_simple_build_pcms, "SND_HDA_CODEC_HDMI");
/* unsolicited event for jack sensing */
void snd_hda_hdmi_simple_unsol_event(struct hda_codec *codec,
unsigned int res)
{
snd_hda_jack_set_dirty_all(codec);
snd_hda_jack_report_sync(codec);
}
EXPORT_SYMBOL_NS_GPL(snd_hda_hdmi_simple_unsol_event, "SND_HDA_CODEC_HDMI");
static void free_hdmi_jack_priv(struct snd_jack *jack)
{
struct hdmi_pcm *pcm = jack->private_data;
pcm->jack = NULL;
}
static int simple_hdmi_build_jack(struct hda_codec *codec)
{
char hdmi_str[32] = "HDMI/DP";
struct hdmi_spec *spec = codec->spec;
struct snd_jack *jack;
struct hdmi_pcm *pcmp = get_hdmi_pcm(spec, 0);
int pcmdev = pcmp->pcm->device;
int err;
if (pcmdev > 0)
sprintf(hdmi_str + strlen(hdmi_str), ",pcm=%d", pcmdev);
err = snd_jack_new(codec->card, hdmi_str, SND_JACK_AVOUT, &jack,
true, false);
if (err < 0)
return err;
pcmp->jack = jack;
jack->private_data = pcmp;
jack->private_free = free_hdmi_jack_priv;
return 0;
}
int snd_hda_hdmi_simple_build_controls(struct hda_codec *codec)
{
struct hdmi_spec *spec = codec->spec;
struct hdmi_spec_per_cvt *per_cvt;
int err;
per_cvt = get_cvt(spec, 0);
err = snd_hda_create_dig_out_ctls(codec, per_cvt->cvt_nid,
per_cvt->cvt_nid,
HDA_PCM_TYPE_HDMI);
if (err < 0)
return err;
return simple_hdmi_build_jack(codec);
}
Annotation
- Immediate include surface: `linux/slab.h`, `linux/module.h`, `hdmi_local.h`, `hda_jack.h`.
- Detected declarations: `function snd_hda_hdmi_simple_build_pcms`, `function snd_hda_hdmi_simple_unsol_event`, `function free_hdmi_jack_priv`, `function simple_hdmi_build_jack`, `function snd_hda_hdmi_simple_build_controls`, `function snd_hda_hdmi_simple_init`, `function snd_hda_hdmi_simple_remove`, `function snd_hda_hdmi_simple_pcm_open`, `function simple_playback_pcm_close`, `function simple_playback_pcm_prepare`.
- Atlas domain: Driver Families / sound/hda.
- 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.