sound/soc/codecs/max98396.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/max98396.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/max98396.c- Extension
.c- Size
- 63439 bytes
- Lines
- 1915
- 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/gpio/consumer.hlinux/i2c.hlinux/module.hsound/pcm_params.hlinux/regulator/consumer.hsound/soc.hsound/tlv.hmax98396.h
Detected Declarations
function max98396_global_enable_onofffunction max98396_dai_set_fmtfunction max98396_pcm_config_indexfunction max98396_dai_hw_paramsfunction max98396_dai_tdm_slotfunction max98396_dac_eventfunction max98396_readable_registerfunction max98396_volatile_regfunction max98397_readable_registerfunction max98397_volatile_regfunction max98396_mux_getfunction max98396_mux_putfunction max98396_adc_value_getfunction max98396_resetfunction max98396_probefunction max98396_suspendfunction max98396_resumefunction max98396_read_device_propertyfunction max98396_core_supplies_disablefunction max98396_supply_disablefunction max98396_i2c_probe
Annotated Snippet
if (format != (reg & format_mask)) {
update = true;
} else {
ret = regmap_read(max98396->regmap,
MAX98396_R2042_PCM_CLK_SETUP, ®);
if (ret < 0)
return -EINVAL;
if (bclk_pol != (reg & MAX98396_PCM_MODE_CFG_BCLKEDGE))
update = true;
}
/* GLOBAL_EN OFF prior to pcm mode, clock configuration change */
if (update)
max98396_global_enable_onoff(max98396->regmap, false);
}
regmap_update_bits(max98396->regmap,
MAX98396_R2041_PCM_MODE_CFG,
format_mask, format);
regmap_update_bits(max98396->regmap,
MAX98396_R2042_PCM_CLK_SETUP,
MAX98396_PCM_MODE_CFG_BCLKEDGE,
bclk_pol);
if (status && update)
max98396_global_enable_onoff(max98396->regmap, true);
return 0;
}
#define MAX98396_BSEL_32 0x2
#define MAX98396_BSEL_48 0x3
#define MAX98396_BSEL_64 0x4
#define MAX98396_BSEL_96 0x5
#define MAX98396_BSEL_128 0x6
#define MAX98396_BSEL_192 0x7
#define MAX98396_BSEL_256 0x8
#define MAX98396_BSEL_384 0x9
#define MAX98396_BSEL_512 0xa
#define MAX98396_BSEL_320 0xb
#define MAX98396_BSEL_250 0xc
#define MAX98396_BSEL_125 0xd
/* Refer to table 5 in the datasheet */
static const struct max98396_pcm_config {
int in, out, width, bsel, max_sr;
} max98396_pcm_configs[] = {
{ .in = 2, .out = 4, .width = 16, .bsel = MAX98396_BSEL_32, .max_sr = 192000 },
{ .in = 2, .out = 6, .width = 24, .bsel = MAX98396_BSEL_48, .max_sr = 192000 },
{ .in = 2, .out = 8, .width = 32, .bsel = MAX98396_BSEL_64, .max_sr = 192000 },
{ .in = 3, .out = 15, .width = 32, .bsel = MAX98396_BSEL_125, .max_sr = 192000 },
{ .in = 4, .out = 8, .width = 16, .bsel = MAX98396_BSEL_64, .max_sr = 192000 },
{ .in = 4, .out = 12, .width = 24, .bsel = MAX98396_BSEL_96, .max_sr = 192000 },
{ .in = 4, .out = 16, .width = 32, .bsel = MAX98396_BSEL_128, .max_sr = 192000 },
{ .in = 5, .out = 15, .width = 24, .bsel = MAX98396_BSEL_125, .max_sr = 192000 },
{ .in = 7, .out = 15, .width = 16, .bsel = MAX98396_BSEL_125, .max_sr = 192000 },
{ .in = 2, .out = 4, .width = 16, .bsel = MAX98396_BSEL_32, .max_sr = 96000 },
{ .in = 2, .out = 6, .width = 24, .bsel = MAX98396_BSEL_48, .max_sr = 96000 },
{ .in = 2, .out = 8, .width = 32, .bsel = MAX98396_BSEL_64, .max_sr = 96000 },
{ .in = 3, .out = 15, .width = 32, .bsel = MAX98396_BSEL_125, .max_sr = 96000 },
{ .in = 4, .out = 8, .width = 16, .bsel = MAX98396_BSEL_64, .max_sr = 96000 },
{ .in = 4, .out = 12, .width = 24, .bsel = MAX98396_BSEL_96, .max_sr = 96000 },
{ .in = 4, .out = 16, .width = 32, .bsel = MAX98396_BSEL_128, .max_sr = 96000 },
{ .in = 5, .out = 15, .width = 24, .bsel = MAX98396_BSEL_125, .max_sr = 96000 },
{ .in = 7, .out = 15, .width = 16, .bsel = MAX98396_BSEL_125, .max_sr = 96000 },
{ .in = 7, .out = 31, .width = 32, .bsel = MAX98396_BSEL_250, .max_sr = 96000 },
{ .in = 8, .out = 16, .width = 16, .bsel = MAX98396_BSEL_128, .max_sr = 96000 },
{ .in = 8, .out = 24, .width = 24, .bsel = MAX98396_BSEL_192, .max_sr = 96000 },
{ .in = 8, .out = 32, .width = 32, .bsel = MAX98396_BSEL_256, .max_sr = 96000 },
{ .in = 10, .out = 31, .width = 24, .bsel = MAX98396_BSEL_250, .max_sr = 96000 },
{ .in = 15, .out = 31, .width = 16, .bsel = MAX98396_BSEL_250, .max_sr = 96000 },
{ .in = 16, .out = 32, .width = 16, .bsel = MAX98396_BSEL_256, .max_sr = 96000 },
{ .in = 7, .out = 31, .width = 32, .bsel = MAX98396_BSEL_250, .max_sr = 48000 },
{ .in = 10, .out = 31, .width = 24, .bsel = MAX98396_BSEL_250, .max_sr = 48000 },
{ .in = 10, .out = 40, .width = 32, .bsel = MAX98396_BSEL_320, .max_sr = 48000 },
{ .in = 15, .out = 31, .width = 16, .bsel = MAX98396_BSEL_250, .max_sr = 48000 },
{ .in = 16, .out = 48, .width = 24, .bsel = MAX98396_BSEL_384, .max_sr = 48000 },
{ .in = 16, .out = 64, .width = 32, .bsel = MAX98396_BSEL_512, .max_sr = 48000 },
};
static int max98396_pcm_config_index(int in_slots, int out_slots, int width)
{
int i;
for (i = 0; i < ARRAY_SIZE(max98396_pcm_configs); i++) {
const struct max98396_pcm_config *c = &max98396_pcm_configs[i];
if (in_slots == c->in && out_slots <= c->out && width == c->width)
return i;
}
Annotation
- Immediate include surface: `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/module.h`, `sound/pcm_params.h`, `linux/regulator/consumer.h`, `sound/soc.h`, `sound/tlv.h`, `max98396.h`.
- Detected declarations: `function max98396_global_enable_onoff`, `function max98396_dai_set_fmt`, `function max98396_pcm_config_index`, `function max98396_dai_hw_params`, `function max98396_dai_tdm_slot`, `function max98396_dac_event`, `function max98396_readable_register`, `function max98396_volatile_reg`, `function max98397_readable_register`, `function max98397_volatile_reg`.
- 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.