sound/soc/sof/intel/hda-codec.c
Source file repositories/reference/linux-study-clean/sound/soc/sof/intel/hda-codec.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/sof/intel/hda-codec.c- Extension
.c- Size
- 12124 bytes
- Lines
- 458
- Domain
- Driver Families
- Bucket
- sound/soc
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/module.hsound/hdaudio_ext.hsound/hda_register.hsound/hda_codec.hsound/hda_i915.hsound/sof.h../ops.hhda.h../../codecs/hdac_hda.h
Detected Declarations
function request_codec_modulefunction hda_codec_load_modulefunction hda_codec_jack_wake_enablefunction list_for_each_codecfunction hda_codec_jack_checkfunction hda_codec_probefunction hda_codec_probe_busfunction hda_codec_check_for_state_changefunction hda_codec_detect_maskfunction hda_codec_init_cmd_iofunction hda_codec_resume_cmd_iofunction hda_codec_stop_cmd_iofunction hda_codec_suspend_cmd_iofunction hda_codec_rirb_status_clearfunction hda_codec_set_codec_wakeupfunction hda_codec_check_rirb_statusfunction hda_codec_device_removefunction hda_codec_i915_display_powerfunction hda_codec_i915_initfunction hda_codec_i915_exit
Annotated Snippet
list_for_each_codec(codec, hbus) {
/* only set WAKEEN when needed for HDaudio codecs */
mask |= BIT(codec->core.addr);
if (codec->jacktbl.used)
val |= BIT(codec->core.addr);
}
} else {
list_for_each_codec(codec, hbus) {
/* reset WAKEEN only HDaudio codecs */
mask |= BIT(codec->core.addr);
}
}
snd_hdac_chip_updatew(bus, WAKEEN, mask & STATESTS_INT_MASK, val);
}
EXPORT_SYMBOL_NS_GPL(hda_codec_jack_wake_enable, "SND_SOC_SOF_HDA_AUDIO_CODEC");
/* check jack status after resuming from suspend mode */
void hda_codec_jack_check(struct snd_sof_dev *sdev)
{
struct hda_bus *hbus = sof_to_hbus(sdev);
struct hda_codec *codec;
if (IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC_DEBUG_SUPPORT) &&
sof_debug_check_flag(SOF_DBG_FORCE_NOCODEC))
return;
list_for_each_codec(codec, hbus)
/*
* Wake up all jack-detecting codecs regardless whether an event
* has been recorded in STATESTS
*/
if (codec->jacktbl.used)
pm_request_resume(&codec->core.dev);
}
EXPORT_SYMBOL_NS_GPL(hda_codec_jack_check, "SND_SOC_SOF_HDA_AUDIO_CODEC");
#if IS_ENABLED(CONFIG_SND_HDA_GENERIC)
#define is_generic_config(bus) \
((bus)->modelname && !strcmp((bus)->modelname, "generic"))
#else
#define is_generic_config(x) 0
#endif
static struct hda_codec *hda_codec_device_init(struct hdac_bus *bus, int addr, int type)
{
struct hda_codec *codec;
codec = snd_hda_codec_device_init(to_hda_bus(bus), addr, "ehdaudio%dD%d", bus->idx, addr);
if (IS_ERR(codec)) {
dev_err(bus->dev, "device init failed for hdac device\n");
return codec;
}
codec->core.type = type;
return codec;
}
/* probe individual codec */
static int hda_codec_probe(struct snd_sof_dev *sdev, int address)
{
struct hdac_hda_priv *hda_priv;
struct hda_bus *hbus = sof_to_hbus(sdev);
struct hda_codec *codec;
u32 hda_cmd = (address << 28) | (AC_NODE_ROOT << 20) |
(AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID;
u32 resp = -1;
int ret, retry = 0;
do {
mutex_lock(&hbus->core.cmd_mutex);
snd_hdac_bus_send_cmd(&hbus->core, hda_cmd);
snd_hdac_bus_get_response(&hbus->core, address, &resp);
mutex_unlock(&hbus->core.cmd_mutex);
} while (resp == -1 && retry++ < CODEC_PROBE_RETRIES);
if (resp == -1)
return -EIO;
dev_dbg(sdev->dev, "HDA codec #%d probed OK: response: %x\n",
address, resp);
hda_priv = devm_kzalloc(sdev->dev, sizeof(*hda_priv), GFP_KERNEL);
if (!hda_priv)
return -ENOMEM;
codec = hda_codec_device_init(&hbus->core, address, HDA_DEV_LEGACY);
ret = PTR_ERR_OR_ZERO(codec);
if (ret < 0)
return ret;
Annotation
- Immediate include surface: `linux/module.h`, `sound/hdaudio_ext.h`, `sound/hda_register.h`, `sound/hda_codec.h`, `sound/hda_i915.h`, `sound/sof.h`, `../ops.h`, `hda.h`.
- Detected declarations: `function request_codec_module`, `function hda_codec_load_module`, `function hda_codec_jack_wake_enable`, `function list_for_each_codec`, `function hda_codec_jack_check`, `function hda_codec_probe`, `function hda_codec_probe_bus`, `function hda_codec_check_for_state_change`, `function hda_codec_detect_mask`, `function hda_codec_init_cmd_io`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.