sound/soc/codecs/uda1380.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/uda1380.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/uda1380.c- Extension
.c- Size
- 23822 bytes
- Lines
- 830
- 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/module.hlinux/init.hlinux/types.hlinux/slab.hlinux/errno.hlinux/gpio/consumer.hlinux/delay.hlinux/i2c.hlinux/property.hlinux/workqueue.hsound/core.hsound/control.hsound/initval.hsound/soc.hsound/tlv.huda1380.h
Detected Declarations
struct uda1380_privfunction uda1380_read_reg_cachefunction uda1380_write_reg_cachefunction uda1380_writefunction uda1380_sync_cachefunction uda1380_resetfunction uda1380_flush_workfunction for_each_set_bitfunction uda1380_set_dai_fmt_bothfunction uda1380_set_dai_fmt_playbackfunction uda1380_set_dai_fmt_capturefunction uda1380_triggerfunction uda1380_pcm_hw_paramsfunction uda1380_pcm_shutdownfunction uda1380_set_bias_levelfunction uda1380_probefunction uda1380_i2c_probe
Annotated Snippet
struct uda1380_priv {
struct snd_soc_component *component;
unsigned int dac_clk;
struct work_struct work;
struct i2c_client *i2c;
struct gpio_desc *power;
struct gpio_desc *reset;
u16 reg_cache[];
};
/*
* uda1380 register cache
*/
static const u16 uda1380_reg[UDA1380_CACHEREGNUM] = {
0x0502, 0x0000, 0x0000, 0x3f3f,
0x0202, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0xff00, 0x0000, 0x4800,
0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x8000, 0x0002, 0x0000,
};
static unsigned long uda1380_cache_dirty;
/*
* read uda1380 register cache
*/
static inline unsigned int uda1380_read_reg_cache(struct snd_soc_component *component,
unsigned int reg)
{
struct uda1380_priv *uda1380 = snd_soc_component_get_drvdata(component);
u16 *cache = uda1380->reg_cache;
if (reg == UDA1380_RESET)
return 0;
if (reg >= UDA1380_CACHEREGNUM)
return -1;
return cache[reg];
}
/*
* write uda1380 register cache
*/
static inline void uda1380_write_reg_cache(struct snd_soc_component *component,
u16 reg, unsigned int value)
{
struct uda1380_priv *uda1380 = snd_soc_component_get_drvdata(component);
u16 *cache = uda1380->reg_cache;
if (reg >= UDA1380_CACHEREGNUM)
return;
if ((reg >= 0x10) && (cache[reg] != value))
set_bit(reg - 0x10, &uda1380_cache_dirty);
cache[reg] = value;
}
/*
* write to the UDA1380 register space
*/
static int uda1380_write(struct snd_soc_component *component, unsigned int reg,
unsigned int value)
{
struct uda1380_priv *uda1380 = snd_soc_component_get_drvdata(component);
u8 data[3];
unsigned int val;
int ret;
/* data is
* data[0] is register offset
* data[1] is MS byte
* data[2] is LS byte
*/
data[0] = reg;
data[1] = (value & 0xff00) >> 8;
data[2] = value & 0x00ff;
uda1380_write_reg_cache(component, reg, value);
/* the interpolator & decimator regs must only be written when the
* codec DAI is active.
*/
if (!snd_soc_component_active(component) && (reg >= UDA1380_MVOL))
return 0;
pr_debug("uda1380: hw write %x val %x\n", reg, value);
ret = i2c_master_send(uda1380->i2c, data, 3);
if (ret != 3) {
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/types.h`, `linux/slab.h`, `linux/errno.h`, `linux/gpio/consumer.h`, `linux/delay.h`, `linux/i2c.h`.
- Detected declarations: `struct uda1380_priv`, `function uda1380_read_reg_cache`, `function uda1380_write_reg_cache`, `function uda1380_write`, `function uda1380_sync_cache`, `function uda1380_reset`, `function uda1380_flush_work`, `function for_each_set_bit`, `function uda1380_set_dai_fmt_both`, `function uda1380_set_dai_fmt_playback`.
- 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.