sound/soc/codecs/mt6358.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/mt6358.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/mt6358.c- Extension
.c- Size
- 70340 bytes
- Lines
- 2431
- 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/platform_device.hlinux/mod_devicetable.hlinux/module.hlinux/delay.hlinux/kthread.hlinux/sched.hlinux/mfd/mt6397/core.hlinux/regulator/consumer.hsound/soc.hsound/tlv.hmt6358.h
Detected Declarations
struct mt6358_privfunction mt6358_set_mtkaif_protocolfunction playback_gpio_setfunction playback_gpio_resetfunction capture_gpio_setfunction capture_gpio_resetfunction mt6358_mtkaif_tx_enablefunction mt6358_mtkaif_tx_disablefunction hp_zcd_disablefunction hp_main_output_rampfunction hp_aux_feedback_loop_gain_rampfunction hp_pull_downfunction is_valid_hp_pga_idxfunction headset_volume_rampfunction mt6358_put_volswfunction mt6358_enable_wov_phase2function mt6358_disable_wov_phase2function mt6358_get_wovfunction mt6358_put_wovfunction mt6358_dmic_mode_getfunction mt6358_dmic_mode_setfunction mt_clksq_eventfunction mt_sgen_eventfunction mt_aif_in_eventfunction mtk_hp_enablefunction mtk_hp_disablefunction mtk_hp_spk_enablefunction mtk_hp_spk_disablefunction mt_hp_eventfunction mt_rcv_eventfunction mt_aif_out_eventfunction mt_adc_supply_eventfunction mt6358_amic_enablefunction mt6358_amic_disablefunction mt6358_dmic_enablefunction mt6358_dmic_disablefunction mt6358_restore_pgafunction mt_mic_type_eventfunction mt_adc_l_eventfunction mt_adc_r_eventfunction mt_pga_left_eventfunction mt_pga_right_eventfunction mt_delay_250_eventfunction mt6358_codec_dai_hw_paramsfunction mt6358_codec_init_regfunction mt6358_codec_probefunction mt6358_parse_dtfunction mt6358_platform_driver_probe
Annotated Snippet
struct mt6358_priv {
struct device *dev;
struct regmap *regmap;
unsigned int dl_rate;
unsigned int ul_rate;
int ana_gain[AUDIO_ANALOG_VOLUME_TYPE_MAX];
unsigned int mux_select[MUX_NUM];
int dev_counter[DEVICE_NUM];
int mtkaif_protocol;
struct regulator *avdd_reg;
int wov_enabled;
int dmic_one_wire_mode;
};
int mt6358_set_mtkaif_protocol(struct snd_soc_component *cmpnt,
int mtkaif_protocol)
{
struct mt6358_priv *priv = snd_soc_component_get_drvdata(cmpnt);
priv->mtkaif_protocol = mtkaif_protocol;
return 0;
}
EXPORT_SYMBOL_GPL(mt6358_set_mtkaif_protocol);
static void playback_gpio_set(struct mt6358_priv *priv)
{
/* set gpio mosi mode */
regmap_update_bits(priv->regmap, MT6358_GPIO_MODE2_CLR,
0x01f8, 0x01f8);
regmap_update_bits(priv->regmap, MT6358_GPIO_MODE2_SET,
0xffff, 0x0249);
regmap_update_bits(priv->regmap, MT6358_GPIO_MODE2,
0xffff, 0x0249);
}
static void playback_gpio_reset(struct mt6358_priv *priv)
{
/* set pad_aud_*_mosi to GPIO mode and dir input
* reason:
* pad_aud_dat_mosi*, because the pin is used as boot strap
* don't clean clk/sync, for mtkaif protocol 2
*/
regmap_update_bits(priv->regmap, MT6358_GPIO_MODE2_CLR,
0x01f8, 0x01f8);
regmap_update_bits(priv->regmap, MT6358_GPIO_MODE2,
0x01f8, 0x0000);
regmap_update_bits(priv->regmap, MT6358_GPIO_DIR0,
0xf << 8, 0x0);
}
static void capture_gpio_set(struct mt6358_priv *priv)
{
/* set gpio miso mode */
regmap_update_bits(priv->regmap, MT6358_GPIO_MODE3_CLR,
0xffff, 0xffff);
regmap_update_bits(priv->regmap, MT6358_GPIO_MODE3_SET,
0xffff, 0x0249);
regmap_update_bits(priv->regmap, MT6358_GPIO_MODE3,
0xffff, 0x0249);
}
static void capture_gpio_reset(struct mt6358_priv *priv)
{
/* set pad_aud_*_miso to GPIO mode and dir input
* reason:
* pad_aud_clk_miso, because when playback only the miso_clk
* will also have 26m, so will have power leak
* pad_aud_dat_miso*, because the pin is used as boot strap
*/
regmap_update_bits(priv->regmap, MT6358_GPIO_MODE3_CLR,
0xffff, 0xffff);
regmap_update_bits(priv->regmap, MT6358_GPIO_MODE3,
0xffff, 0x0000);
regmap_update_bits(priv->regmap, MT6358_GPIO_DIR0,
0xf << 12, 0x0);
}
static int mt6358_mtkaif_tx_enable(struct mt6358_priv *priv)
{
switch (priv->mtkaif_protocol) {
case MT6358_MTKAIF_PROTOCOL_2_CLK_P2:
/* MTKAIF TX format setting */
regmap_update_bits(priv->regmap,
Annotation
- Immediate include surface: `linux/platform_device.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/delay.h`, `linux/kthread.h`, `linux/sched.h`, `linux/mfd/mt6397/core.h`, `linux/regulator/consumer.h`.
- Detected declarations: `struct mt6358_priv`, `function mt6358_set_mtkaif_protocol`, `function playback_gpio_set`, `function playback_gpio_reset`, `function capture_gpio_set`, `function capture_gpio_reset`, `function mt6358_mtkaif_tx_enable`, `function mt6358_mtkaif_tx_disable`, `function hp_zcd_disable`, `function hp_main_output_ramp`.
- 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.