sound/hda/codecs/generic.c
Source file repositories/reference/linux-study-clean/sound/hda/codecs/generic.c
File Facts
- System
- Linux kernel
- Corpus path
sound/hda/codecs/generic.c- Extension
.c- Size
- 168226 bytes
- Lines
- 6146
- 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/init.hlinux/slab.hlinux/export.hlinux/sort.hlinux/delay.hlinux/ctype.hlinux/string.hlinux/bitops.hlinux/module.hlinux/leds.hsound/core.hsound/jack.hsound/tlv.hsound/hda_codec.hhda_local.hhda_auto_parser.hhda_jack.hhda_beep.hgeneric.h
Detected Declarations
function Copyrightfunction kctlfunction free_kctlsfunction snd_hda_gen_spec_freefunction parse_user_hintsfunction restore_pin_ctlfunction set_pin_targetfunction set_pin_targetsfunction find_idx_in_nid_listfunction is_nid_containedfunction snd_array_for_eachfunction snd_hda_get_path_idxfunction is_dac_already_usedfunction snd_array_for_eachfunction is_reachable_pathfunction is_ctl_usedfunction is_ctl_associatedfunction print_nid_pathfunction __parse_nid_pathfunction snd_hda_parse_nid_pathfunction snd_hda_add_new_pathfunction invalidate_nid_pathfunction get_preferred_dacfunction look_for_dacfunction amp_val_replace_channelsfunction same_amp_capsfunction look_for_out_mute_nidfunction look_for_out_vol_nidfunction has_amp_infunction has_amp_outfunction is_active_nidfunction snd_array_for_eachfunction get_amp_val_to_activatefunction is_stereo_ampsfunction init_ampfunction update_ampfunction get_amp_mask_to_modifyfunction activate_ampfunction check_and_activate_ampfunction activate_amp_outfunction activate_amp_infunction path_power_updatefunction sync_power_state_changefunction snd_hda_activate_pathfunction path_power_down_syncfunction set_pin_eapdfunction resume_path_from_idxfunction add_control
Annotated Snippet
if (conn[i] != from_nid) {
/* special case: when from_nid is 0,
* try to find an empty DAC
*/
if (from_nid ||
get_wcaps_type(get_wcaps(codec, conn[i])) != AC_WID_AUD_OUT ||
is_dac_already_used(codec, conn[i]))
continue;
}
/* anchor is not requested or already passed? */
if (anchor_nid <= 0)
goto found;
}
if (depth >= MAX_NID_PATH_DEPTH)
return false;
for (i = 0; i < nums; i++) {
unsigned int type;
type = get_wcaps_type(get_wcaps(codec, conn[i]));
if (type == AC_WID_AUD_OUT || type == AC_WID_AUD_IN ||
type == AC_WID_PIN)
continue;
if (__parse_nid_path(codec, from_nid, conn[i],
anchor_nid, path, depth + 1))
goto found;
}
return false;
found:
path->path[path->depth] = conn[i];
path->idx[path->depth + 1] = i;
if (nums > 1 && get_wcaps_type(get_wcaps(codec, to_nid)) != AC_WID_AUD_MIX)
path->multi[path->depth + 1] = 1;
path->depth++;
return true;
}
/*
* snd_hda_parse_nid_path - parse the widget path from the given nid to
* the target nid
* @codec: the HDA codec
* @from_nid: the NID where the path start from
* @to_nid: the NID where the path ends at
* @anchor_nid: the anchor indication
* @path: the path object to store the result
*
* Returns true if a matching path is found.
*
* The parsing behavior depends on parameters:
* when @from_nid is 0, try to find an empty DAC;
* when @anchor_nid is set to a positive value, only paths through the widget
* with the given value are evaluated.
* when @anchor_nid is set to a negative value, paths through the widget
* with the negative of given value are excluded, only other paths are chosen.
* when @anchor_nid is zero, no special handling about path selection.
*/
static bool snd_hda_parse_nid_path(struct hda_codec *codec, hda_nid_t from_nid,
hda_nid_t to_nid, int anchor_nid,
struct nid_path *path)
{
if (__parse_nid_path(codec, from_nid, to_nid, anchor_nid, path, 1)) {
path->path[path->depth] = to_nid;
path->depth++;
return true;
}
return false;
}
/**
* snd_hda_add_new_path - parse the path between the given NIDs and
* add to the path list
* @codec: the HDA codec
* @from_nid: the NID where the path start from
* @to_nid: the NID where the path ends at
* @anchor_nid: the anchor indication, see snd_hda_parse_nid_path()
*
* If no valid path is found, returns NULL.
*/
struct nid_path *
snd_hda_add_new_path(struct hda_codec *codec, hda_nid_t from_nid,
hda_nid_t to_nid, int anchor_nid)
{
struct hda_gen_spec *spec = codec->spec;
struct nid_path *path;
if (from_nid && to_nid && !is_reachable_path(codec, from_nid, to_nid))
return NULL;
/* check whether the path has been already added */
path = get_nid_path(codec, from_nid, to_nid, anchor_nid);
if (path)
Annotation
- Immediate include surface: `linux/init.h`, `linux/slab.h`, `linux/export.h`, `linux/sort.h`, `linux/delay.h`, `linux/ctype.h`, `linux/string.h`, `linux/bitops.h`.
- Detected declarations: `function Copyright`, `function kctl`, `function free_kctls`, `function snd_hda_gen_spec_free`, `function parse_user_hints`, `function restore_pin_ctl`, `function set_pin_target`, `function set_pin_targets`, `function find_idx_in_nid_list`, `function is_nid_contained`.
- 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.