sound/soc/codecs/cs4349.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/cs4349.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/cs4349.c- Extension
.c- Size
- 9743 bytes
- Lines
- 383
- 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/mod_devicetable.hlinux/module.hlinux/moduleparam.hlinux/kernel.hlinux/init.hlinux/delay.hlinux/gpio/consumer.hlinux/platform_device.hlinux/pm.hlinux/i2c.hlinux/regmap.hlinux/slab.hsound/core.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/soc-dapm.hsound/initval.hsound/tlv.hcs4349.h
Detected Declarations
struct cs4349_privatefunction cs4349_readable_registerfunction cs4349_writeable_registerfunction cs4349_set_dai_fmtfunction cs4349_pcm_hw_paramsfunction cs4349_mutefunction cs4349_i2c_probefunction cs4349_i2c_removefunction cs4349_runtime_suspendfunction cs4349_runtime_resume
Annotated Snippet
struct cs4349_private {
struct regmap *regmap;
struct gpio_desc *reset_gpio;
unsigned int mode;
int rate;
};
static bool cs4349_readable_register(struct device *dev, unsigned int reg)
{
switch (reg) {
case CS4349_CHIPID ... CS4349_MISC:
return true;
default:
return false;
}
}
static bool cs4349_writeable_register(struct device *dev, unsigned int reg)
{
switch (reg) {
case CS4349_MODE ... CS4349_MISC:
return true;
default:
return false;
}
}
static int cs4349_set_dai_fmt(struct snd_soc_dai *codec_dai,
unsigned int format)
{
struct snd_soc_component *component = codec_dai->component;
struct cs4349_private *cs4349 = snd_soc_component_get_drvdata(component);
unsigned int fmt;
fmt = format & SND_SOC_DAIFMT_FORMAT_MASK;
switch (fmt) {
case SND_SOC_DAIFMT_I2S:
case SND_SOC_DAIFMT_LEFT_J:
case SND_SOC_DAIFMT_RIGHT_J:
cs4349->mode = format & SND_SOC_DAIFMT_FORMAT_MASK;
break;
default:
return -EINVAL;
}
return 0;
}
static int cs4349_pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;
struct cs4349_private *cs4349 = snd_soc_component_get_drvdata(component);
int fmt, ret;
cs4349->rate = params_rate(params);
switch (cs4349->mode) {
case SND_SOC_DAIFMT_I2S:
fmt = DIF_I2S;
break;
case SND_SOC_DAIFMT_LEFT_J:
fmt = DIF_LEFT_JST;
break;
case SND_SOC_DAIFMT_RIGHT_J:
switch (params_width(params)) {
case 16:
fmt = DIF_RGHT_JST16;
break;
case 24:
fmt = DIF_RGHT_JST24;
break;
default:
return -EINVAL;
}
break;
default:
return -EINVAL;
}
ret = snd_soc_component_update_bits(component, CS4349_MODE, DIF_MASK,
MODE_FORMAT(fmt));
if (ret < 0)
return ret;
return 0;
}
Annotation
- Immediate include surface: `linux/mod_devicetable.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/kernel.h`, `linux/init.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/platform_device.h`.
- Detected declarations: `struct cs4349_private`, `function cs4349_readable_register`, `function cs4349_writeable_register`, `function cs4349_set_dai_fmt`, `function cs4349_pcm_hw_params`, `function cs4349_mute`, `function cs4349_i2c_probe`, `function cs4349_i2c_remove`, `function cs4349_runtime_suspend`, `function cs4349_runtime_resume`.
- 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.