sound/soc/codecs/mt6357.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/mt6357.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/mt6357.c- Extension
.c- Size
- 64168 bytes
- Lines
- 1856
- Domain
- Driver Families
- Bucket
- sound/soc
- 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/dma-mapping.hsound/soc.hsound/tlv.hlinux/mfd/mt6397/core.hlinux/regulator/consumer.hmt6357.h
Detected Declarations
function Copyrightfunction set_capture_gpiofunction hp_main_output_rampfunction hp_aux_feedback_loop_gain_rampfunction hp_pull_downfunction is_valid_hp_pga_idxfunction volume_rampfunction lo_volume_rampfunction hp_volume_rampfunction hs_volume_rampfunction mt6357_set_dmicfunction mt6357_set_amicfunction mt6357_set_loopbackfunction mt6357_set_ul_sine_genfunction mt_aif_out_eventfunction mt_adc_supply_eventfunction mt_mic_type_eventfunction mt_pga_left_eventfunction mt_pga_right_eventfunction adc_enable_eventfunction configure_downlinksfunction mt_audio_in_eventfunction mt_delay_250_eventfunction lo_mux_eventfunction hs_mux_eventfunction hp_main_mux_eventfunction right_dac_eventfunction left_dac_eventfunction mt6357_codec_probefunction mt6357_get_micbias_idxfunction mt6357_parse_dtfunction mt6357_platform_driver_probe
Annotated Snippet
if (lto != lfrom) {
lfrom += lcount;
if (is_valid_hp_pga_idx(lfrom)) {
regmap_update_bits(priv->regmap, reg_addr,
MT6357_DL_GAIN_REG_LEFT_MASK,
lfrom << MT6357_DL_GAIN_REG_LEFT_SHIFT);
sleep = 1;
}
}
if (rto != rfrom) {
rfrom += rcount;
if (is_valid_hp_pga_idx(rfrom)) {
regmap_update_bits(priv->regmap, reg_addr,
MT6357_DL_GAIN_REG_RIGHT_MASK,
rfrom << MT6357_DL_GAIN_REG_RIGHT_SHIFT);
sleep = 1;
}
}
if (sleep)
usleep_range(200, 300);
}
}
static void lo_volume_ramp(struct mt6357_priv *priv, int lfrom, int lto, int rfrom, int rto)
{
volume_ramp(priv, lfrom, lto, rfrom, rto, MT6357_ZCD_CON1);
}
static void hp_volume_ramp(struct mt6357_priv *priv, int lfrom, int lto, int rfrom, int rto)
{
volume_ramp(priv, lfrom, lto, rfrom, rto, MT6357_ZCD_CON2);
}
static void hs_volume_ramp(struct mt6357_priv *priv, int from, int to)
{
volume_ramp(priv, from, to, 0, 0, MT6357_ZCD_CON3);
}
/* Volume and channel swap controls */
static const DECLARE_TLV_DB_SCALE(playback_tlv, -1000, 100, 0);
static const DECLARE_TLV_DB_SCALE(capture_tlv, 0, 600, 0);
static const DECLARE_TLV_DB_SCALE(hp_degain_tlv, -1200, 1200, 0);
static const struct snd_kcontrol_new mt6357_controls[] = {
/* dl pga gain */
SOC_DOUBLE_TLV("Headphone Volume",
MT6357_ZCD_CON2, MT6357_AUD_HPL_GAIN_SFT,
MT6357_AUD_HPR_GAIN_SFT, MT6357_AUD_HP_GAIN_MAX,
1, playback_tlv),
SOC_SINGLE_TLV("Headphone Vin Volume",
MT6357_AUDDEC_ANA_CON7, MT6357_HP_IVBUF_DEGAIN_SFT,
MT6357_HP_IVBUF_DEGAIN_MAX, 1, hp_degain_tlv),
SOC_DOUBLE_TLV("Lineout Volume",
MT6357_ZCD_CON1, MT6357_AUD_LOL_GAIN_SFT,
MT6357_AUD_LOR_GAIN_SFT, MT6357_AUD_LO_GAIN_MAX,
1, playback_tlv),
SOC_SINGLE_TLV("Handset Volume",
MT6357_ZCD_CON3, MT6357_AUD_HS_GAIN_SFT,
MT6357_AUD_HS_GAIN_MAX, 1, playback_tlv),
/* ul pga gain */
SOC_DOUBLE_R_TLV("Mic Volume",
MT6357_AUDENC_ANA_CON0, MT6357_AUDENC_ANA_CON1,
MT6357_AUDPREAMPLGAIN_SFT, MT6357_AUDPREAMPLGAIN_MAX,
0, capture_tlv),
};
/* Uplink controls */
enum {
MIC_TYPE_MUX_IDLE,
MIC_TYPE_MUX_ACC,
MIC_TYPE_MUX_DMIC,
MIC_TYPE_MUX_DCC,
MIC_TYPE_MUX_DCC_ECM_DIFF,
MIC_TYPE_MUX_DCC_ECM_SINGLE,
MIC_TYPE_MUX_LPBK,
MIC_TYPE_MUX_SGEN,
};
#define IS_DCC_BASE(type) ((type) == MIC_TYPE_MUX_DCC || \
(type) == MIC_TYPE_MUX_DCC_ECM_DIFF || \
(type) == MIC_TYPE_MUX_DCC_ECM_SINGLE)
static const char * const mic_type_mux_map[] = {
"Idle",
"ACC",
"DMIC",
"DCC",
"DCC_ECM_DIFF",
"DCC_ECM_SINGLE",
Annotation
- Immediate include surface: `linux/dma-mapping.h`, `sound/soc.h`, `sound/tlv.h`, `linux/mfd/mt6397/core.h`, `linux/regulator/consumer.h`, `mt6357.h`.
- Detected declarations: `function Copyright`, `function set_capture_gpio`, `function hp_main_output_ramp`, `function hp_aux_feedback_loop_gain_ramp`, `function hp_pull_down`, `function is_valid_hp_pga_idx`, `function volume_ramp`, `function lo_volume_ramp`, `function hp_volume_ramp`, `function hs_volume_ramp`.
- Atlas domain: Driver Families / sound/soc.
- 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.