sound/hda/common/auto_parser.c
Source file repositories/reference/linux-study-clean/sound/hda/common/auto_parser.c
File Facts
- System
- Linux kernel
- Corpus path
sound/hda/common/auto_parser.c- Extension
.c- Size
- 31586 bytes
- Lines
- 1105
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/slab.hlinux/export.hlinux/sort.hsound/core.hsound/hda_codec.hhda_local.hhda_auto_parser.h
Detected Declarations
struct auto_out_pinfunction Copyrightfunction compare_seqfunction sort_pins_by_sequencefunction add_auto_cfg_input_pinfunction compare_input_typefunction reorder_outputsfunction check_pincap_validityfunction can_be_headset_micfunction outputsfunction for_each_hda_codec_nodefunction attributefunction check_mic_location_needfunction hda_get_input_pin_labelfunction find_idx_in_nid_listfunction get_hp_label_indexfunction fill_audio_out_namefunction hda_get_autocfg_input_labelfunction snd_hda_apply_verbsfunction snd_hda_apply_verbsfunction snd_hda_apply_pincfgsfunction set_pin_targetsfunction __snd_hda_apply_fixupfunction snd_hda_apply_fixupfunction pin_config_matchfunction snd_array_for_eachfunction snd_hda_pick_pin_fixupfunction hda_quirk_matchfunction hda_quirk_lookup_idfunction snd_hda_pick_fixupfunction sscanfexport snd_hda_parse_pin_defcfgexport snd_hda_get_input_pin_attrexport hda_get_autocfg_input_labelexport snd_hda_get_pin_labelexport snd_hda_add_verbsexport snd_hda_apply_verbsexport snd_hda_apply_pincfgsexport __snd_hda_apply_fixupexport snd_hda_apply_fixupexport snd_hda_pick_pin_fixupexport snd_hda_pick_fixup
Annotated Snippet
struct auto_out_pin {
hda_nid_t pin;
short seq;
};
static int compare_seq(const void *ap, const void *bp)
{
const struct auto_out_pin *a = ap;
const struct auto_out_pin *b = bp;
return (int)(a->seq - b->seq);
}
/*
* Sort an associated group of pins according to their sequence numbers.
* then store it to a pin array.
*/
static void sort_pins_by_sequence(hda_nid_t *pins, struct auto_out_pin *list,
int num_pins)
{
int i;
sort(list, num_pins, sizeof(list[0]), compare_seq, NULL);
for (i = 0; i < num_pins; i++)
pins[i] = list[i].pin;
}
/* add the found input-pin to the cfg->inputs[] table */
static void add_auto_cfg_input_pin(struct hda_codec *codec, struct auto_pin_cfg *cfg,
hda_nid_t nid, int type)
{
if (cfg->num_inputs < AUTO_CFG_MAX_INS) {
cfg->inputs[cfg->num_inputs].pin = nid;
cfg->inputs[cfg->num_inputs].type = type;
cfg->inputs[cfg->num_inputs].has_boost_on_pin =
nid_has_volume(codec, nid, HDA_INPUT);
cfg->num_inputs++;
}
}
static int compare_input_type(const void *ap, const void *bp)
{
const struct auto_pin_cfg_item *a = ap;
const struct auto_pin_cfg_item *b = bp;
if (a->type != b->type)
return (int)(a->type - b->type);
/* If has both hs_mic and hp_mic, pick the hs_mic ahead of hp_mic. */
if (a->is_headset_mic && b->is_headphone_mic)
return -1; /* don't swap */
else if (a->is_headphone_mic && b->is_headset_mic)
return 1; /* swap */
/* In case one has boost and the other one has not,
pick the one with boost first. */
if (a->has_boost_on_pin != b->has_boost_on_pin)
return (int)(b->has_boost_on_pin - a->has_boost_on_pin);
/* Keep the original order */
return a->order - b->order;
}
/* Reorder the surround channels
* ALSA sequence is front/surr/clfe/side
* HDA sequence is:
* 4-ch: front/surr => OK as it is
* 6-ch: front/clfe/surr
* 8-ch: front/clfe/rear/side|fc
*/
static void reorder_outputs(unsigned int nums, hda_nid_t *pins)
{
switch (nums) {
case 3:
case 4:
swap(pins[1], pins[2]);
break;
}
}
/* check whether the given pin has a proper pin I/O capability bit */
static bool check_pincap_validity(struct hda_codec *codec, hda_nid_t pin,
unsigned int dev)
{
unsigned int pincap = snd_hda_query_pin_caps(codec, pin);
/* some old hardware don't return the proper pincaps */
if (!pincap)
return true;
switch (dev) {
case AC_JACK_LINE_OUT:
Annotation
- Immediate include surface: `linux/slab.h`, `linux/export.h`, `linux/sort.h`, `sound/core.h`, `sound/hda_codec.h`, `hda_local.h`, `hda_auto_parser.h`.
- Detected declarations: `struct auto_out_pin`, `function Copyright`, `function compare_seq`, `function sort_pins_by_sequence`, `function add_auto_cfg_input_pin`, `function compare_input_type`, `function reorder_outputs`, `function check_pincap_validity`, `function can_be_headset_mic`, `function outputs`.
- 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.