sound/soc/codecs/ntp8835.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/ntp8835.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/ntp8835.c- Extension
.c- Size
- 12422 bytes
- Lines
- 481
- 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/kernel.hlinux/clk.hlinux/bits.hlinux/reset.hlinux/init.hlinux/i2c.hlinux/regmap.hsound/initval.hsound/core.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/soc-component.hsound/tlv.hntpfw.h
Detected Declarations
struct ntp8835_privfunction ntp8835_mute_infofunction ntp8835_mute_getfunction ntp8835_mute_putfunction ntp8835_reset_gpiofunction ntp8835_load_firmwarefunction ntp8835_snd_suspendfunction ntp8835_snd_resumefunction ntp8835_probefunction ntp8835_set_component_sysclkfunction ntp8835_hw_paramsfunction ntp8835_set_fmtfunction ntp8835_i2c_probe
Annotated Snippet
struct ntp8835_priv {
struct i2c_client *i2c;
struct reset_control *reset;
unsigned int format;
struct clk *mclk;
unsigned int mclk_rate;
};
static const DECLARE_TLV_DB_RANGE(ntp8835_vol_scale,
0, 1, TLV_DB_SCALE_ITEM(-15000, 0, 0),
2, 6, TLV_DB_SCALE_ITEM(-15000, 1000, 0),
7, 0xff, TLV_DB_SCALE_ITEM(-10000, 50, 0),
);
static int ntp8835_mute_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
uinfo->access =
(SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE);
uinfo->count = 1;
uinfo->value.integer.min = 0;
uinfo->value.integer.max = 1;
uinfo->value.integer.step = 1;
return 0;
}
static int ntp8835_mute_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
unsigned int val;
val = snd_soc_component_read(component, NTP8835_SOFT_MUTE);
ucontrol->value.integer.value[0] = val ? 0 : 1;
return 0;
}
static int ntp8835_mute_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
unsigned int val;
val = ucontrol->value.integer.value[0] ? 0 : 7;
snd_soc_component_write(component, NTP8835_SOFT_MUTE, val);
return 0;
}
static const struct snd_kcontrol_new ntp8835_vol_control[] = {
SOC_SINGLE_TLV("Playback Volume", NTP8835_MASTER_VOL, 0,
0xff, 0, ntp8835_vol_scale),
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Playback Switch",
.info = ntp8835_mute_info,
.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE,
.get = ntp8835_mute_get,
.put = ntp8835_mute_put,
},
};
static void ntp8835_reset_gpio(struct ntp8835_priv *ntp8835)
{
/*
* Proper initialization sequence for NTP835 amplifier requires driving
* /RESET signal low during power up for at least 0.1us. The sequence is,
* according to NTP8835 datasheet, 6.2 Timing Sequence (recommended):
* Deassert for T2 >= 1ms...
*/
reset_control_deassert(ntp8835->reset);
fsleep(1000);
/* ...Assert for T3 >= 0.1us... */
reset_control_assert(ntp8835->reset);
fsleep(1);
/* ...Deassert, and wait for T4 >= 0.5ms before sound on sequence. */
reset_control_deassert(ntp8835->reset);
fsleep(500);
}
static const struct reg_sequence ntp8835_sound_on[] = {
{ NTP8835_PWM_MASK_CTRL0, NTP8835_PWM_MASK_CTRL0_FPMLD },
{ NTP8835_PWM_SWITCH, 0x00 },
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/clk.h`, `linux/bits.h`, `linux/reset.h`, `linux/init.h`, `linux/i2c.h`, `linux/regmap.h`, `sound/initval.h`.
- Detected declarations: `struct ntp8835_priv`, `function ntp8835_mute_info`, `function ntp8835_mute_get`, `function ntp8835_mute_put`, `function ntp8835_reset_gpio`, `function ntp8835_load_firmware`, `function ntp8835_snd_suspend`, `function ntp8835_snd_resume`, `function ntp8835_probe`, `function ntp8835_set_component_sysclk`.
- 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.