sound/soc/codecs/max9768.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/max9768.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/max9768.c- Extension
.c- Size
- 6451 bytes
- Lines
- 233
- 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/init.hlinux/module.hlinux/i2c.hlinux/slab.hlinux/gpio/consumer.hlinux/regmap.hsound/core.hsound/soc.hsound/tlv.hsound/max9768.h
Detected Declarations
struct max9768function max9768_get_gpiofunction max9768_set_gpiofunction max9768_probefunction max9768_i2c_probe
Annotated Snippet
struct max9768 {
struct regmap *regmap;
struct gpio_desc *mute;
struct gpio_desc *shdn;
u32 flags;
};
static const struct reg_default max9768_default_regs[] = {
{ 0, 0 },
{ 3, MAX9768_CTRL_FILTERLESS},
};
static int max9768_get_gpio(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *c = snd_kcontrol_chip(kcontrol);
struct max9768 *max9768 = snd_soc_component_get_drvdata(c);
int val = gpiod_get_value_cansleep(max9768->mute);
ucontrol->value.integer.value[0] = !val;
return 0;
}
static int max9768_set_gpio(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *c = snd_kcontrol_chip(kcontrol);
struct max9768 *max9768 = snd_soc_component_get_drvdata(c);
bool val = !ucontrol->value.integer.value[0];
int ret;
if (val != gpiod_get_value_cansleep(max9768->mute))
ret = 1;
else
ret = 0;
gpiod_set_value_cansleep(max9768->mute, val);
return ret;
}
static const DECLARE_TLV_DB_RANGE(volume_tlv,
0, 0, TLV_DB_SCALE_ITEM(-16150, 0, 0),
1, 1, TLV_DB_SCALE_ITEM(-9280, 0, 0),
2, 2, TLV_DB_SCALE_ITEM(-9030, 0, 0),
3, 3, TLV_DB_SCALE_ITEM(-8680, 0, 0),
4, 4, TLV_DB_SCALE_ITEM(-8430, 0, 0),
5, 5, TLV_DB_SCALE_ITEM(-8080, 0, 0),
6, 6, TLV_DB_SCALE_ITEM(-7830, 0, 0),
7, 7, TLV_DB_SCALE_ITEM(-7470, 0, 0),
8, 8, TLV_DB_SCALE_ITEM(-7220, 0, 0),
9, 9, TLV_DB_SCALE_ITEM(-6870, 0, 0),
10, 10, TLV_DB_SCALE_ITEM(-6620, 0, 0),
11, 11, TLV_DB_SCALE_ITEM(-6270, 0, 0),
12, 12, TLV_DB_SCALE_ITEM(-6020, 0, 0),
13, 13, TLV_DB_SCALE_ITEM(-5670, 0, 0),
14, 14, TLV_DB_SCALE_ITEM(-5420, 0, 0),
15, 17, TLV_DB_SCALE_ITEM(-5060, 250, 0),
18, 18, TLV_DB_SCALE_ITEM(-4370, 0, 0),
19, 19, TLV_DB_SCALE_ITEM(-4210, 0, 0),
20, 20, TLV_DB_SCALE_ITEM(-3960, 0, 0),
21, 21, TLV_DB_SCALE_ITEM(-3760, 0, 0),
22, 22, TLV_DB_SCALE_ITEM(-3600, 0, 0),
23, 23, TLV_DB_SCALE_ITEM(-3340, 0, 0),
24, 24, TLV_DB_SCALE_ITEM(-3150, 0, 0),
25, 25, TLV_DB_SCALE_ITEM(-2980, 0, 0),
26, 26, TLV_DB_SCALE_ITEM(-2720, 0, 0),
27, 27, TLV_DB_SCALE_ITEM(-2520, 0, 0),
28, 30, TLV_DB_SCALE_ITEM(-2350, 190, 0),
31, 31, TLV_DB_SCALE_ITEM(-1750, 0, 0),
32, 34, TLV_DB_SCALE_ITEM(-1640, 100, 0),
35, 37, TLV_DB_SCALE_ITEM(-1310, 110, 0),
38, 39, TLV_DB_SCALE_ITEM(-990, 100, 0),
40, 40, TLV_DB_SCALE_ITEM(-710, 0, 0),
41, 41, TLV_DB_SCALE_ITEM(-600, 0, 0),
42, 42, TLV_DB_SCALE_ITEM(-500, 0, 0),
43, 43, TLV_DB_SCALE_ITEM(-340, 0, 0),
44, 44, TLV_DB_SCALE_ITEM(-190, 0, 0),
45, 45, TLV_DB_SCALE_ITEM(-50, 0, 0),
46, 46, TLV_DB_SCALE_ITEM(50, 0, 0),
47, 50, TLV_DB_SCALE_ITEM(120, 40, 0),
51, 57, TLV_DB_SCALE_ITEM(290, 50, 0),
58, 58, TLV_DB_SCALE_ITEM(650, 0, 0),
59, 62, TLV_DB_SCALE_ITEM(700, 60, 0),
63, 63, TLV_DB_SCALE_ITEM(950, 0, 0)
);
static const struct snd_kcontrol_new max9768_volume[] = {
SOC_SINGLE_TLV("Playback Volume", MAX9768_VOL, 0, 63, 0, volume_tlv),
Annotation
- Immediate include surface: `linux/init.h`, `linux/module.h`, `linux/i2c.h`, `linux/slab.h`, `linux/gpio/consumer.h`, `linux/regmap.h`, `sound/core.h`, `sound/soc.h`.
- Detected declarations: `struct max9768`, `function max9768_get_gpio`, `function max9768_set_gpio`, `function max9768_probe`, `function max9768_i2c_probe`.
- 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.