sound/soc/codecs/mt6359.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/mt6359.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/mt6359.c- Extension
.c- Size
- 88352 bytes
- Lines
- 2961
- 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.
- 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/delay.hlinux/kthread.hlinux/mfd/mt6397/core.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/regulator/consumer.hlinux/sched.hsound/soc.hsound/tlv.hmt6359.h
Detected Declarations
function mt6359_set_gpio_smtfunction mt6359_set_gpio_drivingfunction mt6359_set_playback_gpiofunction mt6359_reset_playback_gpiofunction mt6359_set_capture_gpiofunction mt6359_reset_capture_gpiofunction mt6359_set_dcxofunction mt6359_set_clksqfunction mt6359_set_aud_global_biasfunction mt6359_set_topckfunction mt6359_set_decoder_clkfunction mt6359_mtkaif_tx_enablefunction mt6359_mtkaif_tx_disablefunction mt6359_set_mtkaif_protocolfunction mt6359_mtkaif_calibration_enablefunction mt6359_mtkaif_calibration_disablefunction mt6359_set_mtkaif_calibration_phasefunction zcd_disablefunction hp_main_output_rampfunction hp_aux_feedback_loop_gain_rampfunction hp_in_pair_currentfunction hp_pull_downfunction is_valid_hp_pga_idxfunction headset_volume_rampfunction mt6359_put_volswfunction mt6359_get_playback_volswfunction mt_sgen_eventfunction mtk_hp_enablefunction mtk_hp_disablefunction mt_hp_eventfunction mt_rcv_eventfunction mt_lo_eventfunction mt_adc_clk_gen_eventfunction mt_dcc_clk_eventfunction mt_mic_bias_0_eventfunction mt_mic_bias_1_eventfunction mt_mic_bias_2_eventfunction mt_mtkaif_tx_eventfunction mt_ul_src_dmic_eventfunction mt_ul_src_34_dmic_eventfunction mt_adc_l_eventfunction mt_adc_r_eventfunction mt_adc_3_eventfunction mt_pga_l_mux_eventfunction mt_pga_r_mux_eventfunction mt_pga_3_mux_eventfunction mt_pga_l_eventfunction mt_pga_r_event
Annotated Snippet
if (is_valid_hp_pga_idx(reg_idx)) {
regmap_update_bits(priv->regmap,
MT6359_ZCD_CON2,
DL_GAIN_REG_MASK,
(reg_idx << 7) | reg_idx);
usleep_range(600, 650);
}
offset--;
count++;
}
}
static int mt6359_put_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct mt6359_priv *priv = snd_soc_component_get_drvdata(component);
struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value;
unsigned int reg = 0;
int index = ucontrol->value.integer.value[0];
int orig_gain[2], new_gain[2];
int ret;
switch (mc->reg) {
case MT6359_ZCD_CON2:
orig_gain[0] = priv->ana_gain[AUDIO_ANALOG_VOLUME_HPOUTL];
orig_gain[1] = priv->ana_gain[AUDIO_ANALOG_VOLUME_HPOUTR];
break;
case MT6359_ZCD_CON1:
orig_gain[0] = priv->ana_gain[AUDIO_ANALOG_VOLUME_LINEOUTL];
orig_gain[1] = priv->ana_gain[AUDIO_ANALOG_VOLUME_LINEOUTR];
break;
case MT6359_ZCD_CON3:
orig_gain[0] = priv->ana_gain[AUDIO_ANALOG_VOLUME_HSOUTL];
break;
case MT6359_AUDENC_ANA_CON0:
orig_gain[0] = priv->ana_gain[AUDIO_ANALOG_VOLUME_MICAMP1];
break;
case MT6359_AUDENC_ANA_CON1:
orig_gain[0] = priv->ana_gain[AUDIO_ANALOG_VOLUME_MICAMP2];
break;
case MT6359_AUDENC_ANA_CON2:
orig_gain[0] = priv->ana_gain[AUDIO_ANALOG_VOLUME_MICAMP3];
break;
default:
return -EINVAL;
}
ret = snd_soc_put_volsw(kcontrol, ucontrol);
if (ret < 0)
return ret;
switch (mc->reg) {
case MT6359_ZCD_CON2:
regmap_read(priv->regmap, MT6359_ZCD_CON2, ®);
priv->ana_gain[AUDIO_ANALOG_VOLUME_HPOUTL] =
(reg >> RG_AUDHPLGAIN_SFT) & RG_AUDHPLGAIN_MASK;
priv->ana_gain[AUDIO_ANALOG_VOLUME_HPOUTR] =
(reg >> RG_AUDHPRGAIN_SFT) & RG_AUDHPRGAIN_MASK;
new_gain[0] = priv->ana_gain[AUDIO_ANALOG_VOLUME_HPOUTL];
new_gain[1] = priv->ana_gain[AUDIO_ANALOG_VOLUME_HPOUTR];
break;
case MT6359_ZCD_CON1:
regmap_read(priv->regmap, MT6359_ZCD_CON1, ®);
priv->ana_gain[AUDIO_ANALOG_VOLUME_LINEOUTL] =
(reg >> RG_AUDLOLGAIN_SFT) & RG_AUDLOLGAIN_MASK;
priv->ana_gain[AUDIO_ANALOG_VOLUME_LINEOUTR] =
(reg >> RG_AUDLORGAIN_SFT) & RG_AUDLORGAIN_MASK;
new_gain[0] = priv->ana_gain[AUDIO_ANALOG_VOLUME_LINEOUTL];
new_gain[1] = priv->ana_gain[AUDIO_ANALOG_VOLUME_LINEOUTR];
break;
case MT6359_ZCD_CON3:
regmap_read(priv->regmap, MT6359_ZCD_CON3, ®);
priv->ana_gain[AUDIO_ANALOG_VOLUME_HSOUTL] =
(reg >> RG_AUDHSGAIN_SFT) & RG_AUDHSGAIN_MASK;
new_gain[0] = priv->ana_gain[AUDIO_ANALOG_VOLUME_HSOUTL];
break;
case MT6359_AUDENC_ANA_CON0:
regmap_read(priv->regmap, MT6359_AUDENC_ANA_CON0, ®);
priv->ana_gain[AUDIO_ANALOG_VOLUME_MICAMP1] =
(reg >> RG_AUDPREAMPLGAIN_SFT) & RG_AUDPREAMPLGAIN_MASK;
new_gain[0] = priv->ana_gain[AUDIO_ANALOG_VOLUME_MICAMP1];
break;
case MT6359_AUDENC_ANA_CON1:
regmap_read(priv->regmap, MT6359_AUDENC_ANA_CON1, ®);
priv->ana_gain[AUDIO_ANALOG_VOLUME_MICAMP2] =
(reg >> RG_AUDPREAMPRGAIN_SFT) & RG_AUDPREAMPRGAIN_MASK;
new_gain[0] = priv->ana_gain[AUDIO_ANALOG_VOLUME_MICAMP2];
break;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/kthread.h`, `linux/mfd/mt6397/core.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/regulator/consumer.h`, `linux/sched.h`.
- Detected declarations: `function mt6359_set_gpio_smt`, `function mt6359_set_gpio_driving`, `function mt6359_set_playback_gpio`, `function mt6359_reset_playback_gpio`, `function mt6359_set_capture_gpio`, `function mt6359_reset_capture_gpio`, `function mt6359_set_dcxo`, `function mt6359_set_clksq`, `function mt6359_set_aud_global_bias`, `function mt6359_set_topck`.
- Atlas domain: Driver Families / sound/soc.
- 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.