sound/hda/codecs/via.c
Source file repositories/reference/linux-study-clean/sound/hda/codecs/via.c
File Facts
- System
- Linux kernel
- Corpus path
sound/hda/codecs/via.c- Extension
.c- Size
- 31291 bytes
- Lines
- 1175
- 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.
- 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/delay.hlinux/slab.hlinux/module.hsound/core.hsound/asoundef.hsound/hda_codec.hhda_local.hhda_auto_parser.hhda_jack.hgeneric.h
Detected Declarations
struct via_specenum VIA_HDA_CODECfunction get_codec_typefunction vt1708_stop_hp_workfunction vt1708_update_hp_workfunction via_pin_power_ctl_infofunction via_pin_power_ctl_getfunction via_pin_power_ctl_putfunction set_beep_ampfunction auto_parse_beepfunction is_aa_path_mutefunction __analog_low_current_modefunction analog_low_current_modefunction via_playback_pcm_hookfunction via_removefunction via_suspendfunction via_resumefunction via_check_power_statusfunction vt1708_set_pinconfig_connectfunction vt1708_jack_detect_getfunction vt1708_jack_detect_putfunction via_parse_auto_configfunction via_initfunction via_build_controlsfunction via_build_pcmsfunction probe_vt1708function probe_vt1709function probe_vt1708Bfunction override_mic_boostfunction probe_vt1708Sfunction probe_vt1702function add_secret_dac_pathfunction probe_vt1718Sfunction vt1716s_dmic_infofunction vt1716s_dmic_getfunction vt1716s_dmic_putfunction probe_vt1716Sfunction via_fixup_intmic_boostfunction via_fixup_power_savefunction fix_vt1802_connectionsfunction probe_vt2002Pfunction probe_vt1812function probe_vt3476function via_probe
Annotated Snippet
struct via_spec {
struct hda_gen_spec gen;
/* HP mode source */
unsigned int dmic_enabled;
enum VIA_HDA_CODEC codec_type;
/* analog low-power control */
bool alc_mode;
/* work to check hp jack state */
int hp_work_active;
int vt1708_jack_detect;
};
static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec);
static void via_playback_pcm_hook(struct hda_pcm_stream *hinfo,
struct hda_codec *codec,
struct snd_pcm_substream *substream,
int action);
static struct via_spec *via_new_spec(struct hda_codec *codec)
{
struct via_spec *spec;
spec = kzalloc_obj(*spec);
if (spec == NULL)
return NULL;
codec->spec = spec;
snd_hda_gen_spec_init(&spec->gen);
spec->codec_type = get_codec_type(codec);
/* VT1708BCE & VT1708S are almost same */
if (spec->codec_type == VT1708BCE)
spec->codec_type = VT1708S;
spec->gen.indep_hp = 1;
spec->gen.keep_eapd_on = 1;
spec->gen.dac_min_mute = 1;
spec->gen.pcm_playback_hook = via_playback_pcm_hook;
spec->gen.add_stereo_mix_input = HDA_HINT_STEREO_MIX_AUTO;
codec->power_save_node = 1;
spec->gen.power_down_unused = 1;
return spec;
}
static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec)
{
u32 vendor_id = codec->core.vendor_id;
u16 ven_id = vendor_id >> 16;
u16 dev_id = vendor_id & 0xffff;
enum VIA_HDA_CODEC codec_type;
/* get codec type */
if (ven_id != 0x1106)
codec_type = UNKNOWN;
else if (dev_id >= 0x1708 && dev_id <= 0x170b)
codec_type = VT1708;
else if (dev_id >= 0xe710 && dev_id <= 0xe713)
codec_type = VT1709_10CH;
else if (dev_id >= 0xe714 && dev_id <= 0xe717)
codec_type = VT1709_6CH;
else if (dev_id >= 0xe720 && dev_id <= 0xe723) {
codec_type = VT1708B_8CH;
if (snd_hda_param_read(codec, 0x16, AC_PAR_CONNLIST_LEN) == 0x7)
codec_type = VT1708BCE;
} else if (dev_id >= 0xe724 && dev_id <= 0xe727)
codec_type = VT1708B_4CH;
else if ((dev_id & 0xfff) == 0x397
&& (dev_id >> 12) < 8)
codec_type = VT1708S;
else if ((dev_id & 0xfff) == 0x398
&& (dev_id >> 12) < 8)
codec_type = VT1702;
else if ((dev_id & 0xfff) == 0x428
&& (dev_id >> 12) < 8)
codec_type = VT1718S;
else if (dev_id == 0x0433 || dev_id == 0xa721)
codec_type = VT1716S;
else if (dev_id == 0x0441 || dev_id == 0x4441)
codec_type = VT1718S;
else if (dev_id == 0x0438 || dev_id == 0x4438)
codec_type = VT2002P;
else if (dev_id == 0x0448)
codec_type = VT1812;
else if (dev_id == 0x0440)
codec_type = VT1708S;
else if ((dev_id & 0xfff) == 0x446)
codec_type = VT1802;
else if (dev_id == 0x4760)
codec_type = VT1705CF;
Annotation
- Immediate include surface: `linux/init.h`, `linux/delay.h`, `linux/slab.h`, `linux/module.h`, `sound/core.h`, `sound/asoundef.h`, `sound/hda_codec.h`, `hda_local.h`.
- Detected declarations: `struct via_spec`, `enum VIA_HDA_CODEC`, `function get_codec_type`, `function vt1708_stop_hp_work`, `function vt1708_update_hp_work`, `function via_pin_power_ctl_info`, `function via_pin_power_ctl_get`, `function via_pin_power_ctl_put`, `function set_beep_amp`, `function auto_parse_beep`.
- 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.