sound/soc/codecs/max9877.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/max9877.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/max9877.c- Extension
.c- Size
- 4551 bytes
- Lines
- 172
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/init.hlinux/i2c.hlinux/regmap.hsound/soc.hsound/tlv.hmax9877.h
Detected Declarations
function max9877_i2c_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* max9877.c -- amp driver for max9877
*
* Copyright (C) 2009 Samsung Electronics Co.Ltd
* Author: Joonyoung Shim <jy0922.shim@samsung.com>
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/regmap.h>
#include <sound/soc.h>
#include <sound/tlv.h>
#include "max9877.h"
static const struct reg_default max9877_regs[] = {
{ 0, 0x40 },
{ 1, 0x00 },
{ 2, 0x00 },
{ 3, 0x00 },
{ 4, 0x49 },
};
static const DECLARE_TLV_DB_RANGE(max9877_pgain_tlv,
0, 1, TLV_DB_SCALE_ITEM(0, 900, 0),
2, 2, TLV_DB_SCALE_ITEM(2000, 0, 0)
);
static const DECLARE_TLV_DB_RANGE(max9877_output_tlv,
0, 7, TLV_DB_SCALE_ITEM(-7900, 400, 1),
8, 15, TLV_DB_SCALE_ITEM(-4700, 300, 0),
16, 23, TLV_DB_SCALE_ITEM(-2300, 200, 0),
24, 31, TLV_DB_SCALE_ITEM(-700, 100, 0)
);
static const char *max9877_out_mode[] = {
"INA -> SPK",
"INA -> HP",
"INA -> SPK and HP",
"INB -> SPK",
"INB -> HP",
"INB -> SPK and HP",
"INA + INB -> SPK",
"INA + INB -> HP",
"INA + INB -> SPK and HP",
};
static const char *max9877_osc_mode[] = {
"1176KHz",
"1100KHz",
"700KHz",
};
static const struct soc_enum max9877_enum[] = {
SOC_ENUM_SINGLE(MAX9877_OUTPUT_MODE, 0, ARRAY_SIZE(max9877_out_mode),
max9877_out_mode),
SOC_ENUM_SINGLE(MAX9877_OUTPUT_MODE, MAX9877_OSC_OFFSET,
ARRAY_SIZE(max9877_osc_mode), max9877_osc_mode),
};
static const struct snd_kcontrol_new max9877_controls[] = {
SOC_SINGLE_TLV("MAX9877 PGAINA Playback Volume",
MAX9877_INPUT_MODE, 0, 2, 0, max9877_pgain_tlv),
SOC_SINGLE_TLV("MAX9877 PGAINB Playback Volume",
MAX9877_INPUT_MODE, 2, 2, 0, max9877_pgain_tlv),
SOC_SINGLE_TLV("MAX9877 Amp Speaker Playback Volume",
MAX9877_SPK_VOLUME, 0, 31, 0, max9877_output_tlv),
SOC_DOUBLE_R_TLV("MAX9877 Amp HP Playback Volume",
MAX9877_HPL_VOLUME, MAX9877_HPR_VOLUME, 0, 31, 0,
max9877_output_tlv),
SOC_SINGLE("MAX9877 INB Stereo Switch",
MAX9877_INPUT_MODE, 4, 1, 1),
SOC_SINGLE("MAX9877 INA Stereo Switch",
MAX9877_INPUT_MODE, 5, 1, 1),
SOC_SINGLE("MAX9877 Zero-crossing detection Switch",
MAX9877_INPUT_MODE, 6, 1, 0),
SOC_SINGLE("MAX9877 Bypass Mode Switch",
MAX9877_OUTPUT_MODE, 6, 1, 0),
SOC_ENUM("MAX9877 Output Mode", max9877_enum[0]),
SOC_ENUM("MAX9877 Oscillator Mode", max9877_enum[1]),
};
static const struct snd_soc_dapm_widget max9877_dapm_widgets[] = {
SND_SOC_DAPM_INPUT("INA1"),
SND_SOC_DAPM_INPUT("INA2"),
SND_SOC_DAPM_INPUT("INB1"),
SND_SOC_DAPM_INPUT("INB2"),
SND_SOC_DAPM_INPUT("RXIN+"),
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/i2c.h`, `linux/regmap.h`, `sound/soc.h`, `sound/tlv.h`, `max9877.h`.
- Detected declarations: `function max9877_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.