sound/soc/codecs/simple-amplifier.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/simple-amplifier.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/simple-amplifier.c- Extension
.c- Size
- 26659 bytes
- Lines
- 977
- 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/bitmap.hlinux/bits.hlinux/gpio/consumer.hlinux/math.hlinux/minmax.hlinux/mod_devicetable.hlinux/module.hlinux/platform_device.hlinux/regulator/consumer.hlinux/slab.hsound/soc.hlinux/sort.hsound/tlv.h
Detected Declarations
struct simple_amp_singlestruct simple_amp_pointstruct simple_amp_rangestruct simple_amp_rangesstruct simple_amp_labelsstruct simple_amp_multistruct simple_amp_datastruct simple_ampstruct simple_amp_supplyenum simple_amp_modefunction simple_amp_power_eventfunction simple_amp_single_kctrl_write_gpiofunction simple_amp_single_kctrl_infofunction simple_amp_single_kctrl_getfunction simple_amp_single_kctrl_putfunction simple_amp_single_add_kcontrolfunction simple_amp_multi_ranges_kctrl_to_gpiofunction simple_amp_multi_kctrl_write_gpiosfunction simple_amp_multi_kctrl_int_infofunction simple_amp_multi_kctrl_int_getfunction simple_amp_multi_kctrl_int_putfunction simple_amp_multi_kctrl_enum_infofunction simple_amp_multi_kctrl_enum_getfunction simple_amp_multi_kctrl_enum_putfunction simple_amp_multi_add_kcontrolfunction simple_amp_add_basic_dapmfunction simple_amp_add_power_suppliesfunction simple_amp_component_probefunction simple_amp_component_removefunction simple_amp_parse_single_gpiofunction simple_amp_cmp_rangesfunction simple_amp_check_new_rangefunction simple_amp_parse_rangesfunction simple_amp_parse_labelsfunction simple_amp_parse_multi_gpiofunction simple_amp_probe
Annotated Snippet
struct simple_amp_single {
struct gpio_desc *gpio;
bool is_inverted;
int kctrl_val;
const char *control_name;
};
struct simple_amp_point {
u32 gpio_val;
int gain_db;
};
struct simple_amp_range {
unsigned int nb_points;
struct simple_amp_point min;
struct simple_amp_point max;
};
struct simple_amp_ranges {
unsigned int nb_ranges;
struct simple_amp_range *tab_ranges;
};
struct simple_amp_labels {
unsigned int nb_labels;
const char **tab_labels;
};
enum simple_amp_mode {
SIMPLE_AMP_MODE_NONE,
SIMPLE_AMP_MODE_RANGES,
SIMPLE_AMP_MODE_LABELS,
};
struct simple_amp_multi {
struct gpio_descs *gpios;
u32 kctrl_val;
u32 kctrl_max;
const char *control_name;
unsigned int *tlv_array;
enum simple_amp_mode mode;
union {
struct simple_amp_ranges ranges;
struct simple_amp_labels labels;
};
};
struct simple_amp_data {
unsigned int supports;
#define SIMPLE_AUDIO_SUPPORT_PGA BIT(0)
#define SIMPLE_AUDIO_SUPPORT_POWER_SUPPLIES BIT(1)
#define SIMPLE_AUDIO_SUPPORT_MUTE BIT(2)
#define SIMPLE_AUDIO_SUPPORT_BYPASS BIT(3)
const struct snd_soc_dapm_widget *dapm_widgets;
unsigned int num_dapm_widgets;
const struct snd_soc_dapm_route *dapm_routes;
unsigned int num_dapm_routes;
};
struct simple_amp {
const struct simple_amp_data *data;
struct gpio_desc *gpiod_enable;
struct simple_amp_single mute;
struct simple_amp_single bypass;
struct simple_amp_multi gain;
};
static int simple_amp_power_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *control, int event)
{
struct snd_soc_component *c = snd_soc_dapm_to_component(w->dapm);
struct simple_amp *simple_amp = snd_soc_component_get_drvdata(c);
int val;
switch (event) {
case SND_SOC_DAPM_POST_PMU:
val = 1;
break;
case SND_SOC_DAPM_PRE_PMD:
val = 0;
break;
default:
WARN(1, "Unexpected event");
return -EINVAL;
}
gpiod_set_value_cansleep(simple_amp->gpiod_enable, val);
return 0;
Annotation
- Immediate include surface: `linux/bitmap.h`, `linux/bits.h`, `linux/gpio/consumer.h`, `linux/math.h`, `linux/minmax.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/platform_device.h`.
- Detected declarations: `struct simple_amp_single`, `struct simple_amp_point`, `struct simple_amp_range`, `struct simple_amp_ranges`, `struct simple_amp_labels`, `struct simple_amp_multi`, `struct simple_amp_data`, `struct simple_amp`, `struct simple_amp_supply`, `enum simple_amp_mode`.
- 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.