sound/soc/codecs/mt6660.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/mt6660.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/mt6660.c- Extension
.c- Size
- 15071 bytes
- Lines
- 581
- 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/module.hlinux/kernel.hlinux/err.hlinux/i2c.hlinux/pm_runtime.hlinux/delay.hsound/soc.hsound/tlv.hsound/pcm_params.hmt6660.h
Detected Declarations
struct reg_size_tablestruct reg_tablefunction mt6660_get_reg_sizefunction mt6660_reg_writefunction mt6660_reg_readfunction mt6660_codec_dac_eventfunction mt6660_codec_classd_eventfunction mt6660_component_get_volswfunction _mt6660_chip_power_onfunction mt6660_component_settingfunction mt6660_component_probefunction mt6660_component_removefunction mt6660_component_aif_hw_paramsfunction _mt6660_chip_id_checkfunction _mt6660_chip_sw_resetfunction _mt6660_read_chip_revisionfunction mt6660_i2c_probefunction mt6660_i2c_removefunction mt6660_i2c_runtime_suspendfunction mt6660_i2c_runtime_resume
Annotated Snippet
struct reg_size_table {
u32 addr;
u8 size;
};
static const struct reg_size_table mt6660_reg_size_table[] = {
{ MT6660_REG_HPF1_COEF, 4 },
{ MT6660_REG_HPF2_COEF, 4 },
{ MT6660_REG_TDM_CFG3, 2 },
{ MT6660_REG_RESV17, 2 },
{ MT6660_REG_RESV23, 2 },
{ MT6660_REG_SIGMAX, 2 },
{ MT6660_REG_DEVID, 2 },
{ MT6660_REG_HCLIP_CTRL, 2 },
{ MT6660_REG_DA_GAIN, 2 },
};
static int mt6660_get_reg_size(uint32_t addr)
{
int i;
for (i = 0; i < ARRAY_SIZE(mt6660_reg_size_table); i++) {
if (mt6660_reg_size_table[i].addr == addr)
return mt6660_reg_size_table[i].size;
}
return 1;
}
static int mt6660_reg_write(void *context, unsigned int reg, unsigned int val)
{
struct mt6660_chip *chip = context;
int size = mt6660_get_reg_size(reg);
u8 reg_data[4];
int i;
for (i = 0; i < size; i++)
reg_data[size - i - 1] = (val >> (8 * i)) & 0xff;
return i2c_smbus_write_i2c_block_data(chip->i2c, reg, size, reg_data);
}
static int mt6660_reg_read(void *context, unsigned int reg, unsigned int *val)
{
struct mt6660_chip *chip = context;
int size = mt6660_get_reg_size(reg);
int i, ret;
u8 data[4];
u32 reg_data = 0;
ret = i2c_smbus_read_i2c_block_data(chip->i2c, reg, size, data);
if (ret < 0)
return ret;
for (i = 0; i < size; i++) {
reg_data <<= 8;
reg_data |= data[i];
}
*val = reg_data;
return 0;
}
static const struct regmap_config mt6660_regmap_config = {
.reg_bits = 8,
.val_bits = 32,
.reg_write = mt6660_reg_write,
.reg_read = mt6660_reg_read,
};
static int mt6660_codec_dac_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
if (event == SND_SOC_DAPM_POST_PMU)
usleep_range(1000, 1100);
return 0;
}
static int mt6660_codec_classd_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_component *component =
snd_soc_dapm_to_component(w->dapm);
int ret;
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
dev_dbg(component->dev,
"%s: before classd turn on\n", __func__);
/* config to adaptive mode */
ret = snd_soc_component_update_bits(component,
MT6660_REG_BST_CTRL, 0x03, 0x03);
if (ret < 0) {
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/err.h`, `linux/i2c.h`, `linux/pm_runtime.h`, `linux/delay.h`, `sound/soc.h`, `sound/tlv.h`.
- Detected declarations: `struct reg_size_table`, `struct reg_table`, `function mt6660_get_reg_size`, `function mt6660_reg_write`, `function mt6660_reg_read`, `function mt6660_codec_dac_event`, `function mt6660_codec_classd_event`, `function mt6660_component_get_volsw`, `function _mt6660_chip_power_on`, `function mt6660_component_setting`.
- 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.