sound/soc/codecs/mt6351.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/mt6351.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/mt6351.c- Extension
.c- Size
- 41644 bytes
- Lines
- 1497
- 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.hlinux/platform_device.hlinux/slab.hlinux/mod_devicetable.hlinux/module.hlinux/delay.hsound/core.hsound/pcm.hsound/soc.hsound/tlv.hmt6351.h
Detected Declarations
struct mt6351_privfunction set_hp_gain_zerofunction get_cap_reg_valfunction get_play_reg_valfunction mt6351_codec_dai_hw_paramsfunction hp_gain_ramp_setfunction hp_zcd_enablefunction hp_zcd_disablefunction mt_reg_set_clr_eventfunction mt_ncp_eventfunction mt_sgen_eventfunction mt_aif_in_eventfunction mt_hp_eventfunction mt_aif_out_eventfunction mt_adc_clkgen_eventfunction mt_pga_left_eventfunction mt_pga_right_eventfunction mt_mic_bias_0_eventfunction mt_mic_bias_1_eventfunction mt_mic_bias_2_eventfunction mt6351_codec_init_regfunction mt6351_codec_probefunction mt6351_codec_driver_probe
Annotated Snippet
struct mt6351_priv {
struct device *dev;
struct regmap *regmap;
unsigned int dl_rate;
unsigned int ul_rate;
int ana_gain[AUDIO_ANALOG_VOLUME_TYPE_MAX];
int hp_en_counter;
};
static void set_hp_gain_zero(struct snd_soc_component *cmpnt)
{
regmap_update_bits(cmpnt->regmap, MT6351_ZCD_CON2,
0x1f << 7, 0x8 << 7);
regmap_update_bits(cmpnt->regmap, MT6351_ZCD_CON2,
0x1f << 0, 0x8 << 0);
}
static unsigned int get_cap_reg_val(struct snd_soc_component *cmpnt,
unsigned int rate)
{
switch (rate) {
case 8000:
return 0;
case 16000:
return 1;
case 32000:
return 2;
case 48000:
return 3;
case 96000:
return 4;
case 192000:
return 5;
default:
dev_warn(cmpnt->dev, "%s(), error rate %d, return 3",
__func__, rate);
return 3;
}
}
static unsigned int get_play_reg_val(struct snd_soc_component *cmpnt,
unsigned int rate)
{
switch (rate) {
case 8000:
return 0;
case 11025:
return 1;
case 12000:
return 2;
case 16000:
return 3;
case 22050:
return 4;
case 24000:
return 5;
case 32000:
return 6;
case 44100:
return 7;
case 48000:
case 96000:
case 192000:
return 8;
default:
dev_warn(cmpnt->dev, "%s(), error rate %d, return 8",
__func__, rate);
return 8;
}
}
static int mt6351_codec_dai_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct snd_soc_component *cmpnt = dai->component;
struct mt6351_priv *priv = snd_soc_component_get_drvdata(cmpnt);
unsigned int rate = params_rate(params);
dev_dbg(priv->dev, "%s(), substream->stream %d, rate %d\n",
__func__, substream->stream, rate);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
priv->dl_rate = rate;
else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
priv->ul_rate = rate;
Annotation
- Immediate include surface: `linux/dma-mapping.h`, `linux/platform_device.h`, `linux/slab.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/delay.h`, `sound/core.h`, `sound/pcm.h`.
- Detected declarations: `struct mt6351_priv`, `function set_hp_gain_zero`, `function get_cap_reg_val`, `function get_play_reg_val`, `function mt6351_codec_dai_hw_params`, `function hp_gain_ramp_set`, `function hp_zcd_enable`, `function hp_zcd_disable`, `function mt_reg_set_clr_event`, `function mt_ncp_event`.
- 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.