sound/soc/codecs/rtq9128.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/rtq9128.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/rtq9128.c- Extension
.c- Size
- 26388 bytes
- Lines
- 890
- 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/bitfield.hlinux/bits.hlinux/delay.hlinux/gpio/consumer.hlinux/i2c.hlinux/kernel.hlinux/mod_devicetable.hlinux/module.hlinux/pm_runtime.hlinux/property.hlinux/regmap.hsound/pcm_params.hsound/soc.hsound/tlv.h
Detected Declarations
struct rtq9128_datastruct rtq9128_init_regenum rtq9128_chip_modelfunction rtq9128_get_reg_sizefunction rtq9128_i2c_writefunction rtq9128_i2c_readfunction rtq9128_is_readable_regfunction rtq9128_is_writeable_regfunction rtq9128_is_volatile_regfunction rtq9128_dac_power_eventfunction rtq9128_component_probefunction rtq9128_dai_set_fmtfunction rtq9128_dai_set_tdm_slotfunction rtq9128_dai_hw_paramsfunction rtq9128_dai_mute_streamfunction rtq9128_probefunction rtq9128_pm_runtime_suspendfunction rtq9128_pm_runtime_resume
Annotated Snippet
struct rtq9128_data {
struct gpio_desc *enable;
unsigned int daifmt;
int tdm_slots;
int tdm_slot_width;
bool tdm_input_data2_select;
enum rtq9128_chip_model chip_model;
};
struct rtq9128_init_reg {
unsigned int reg;
unsigned int val;
};
static int rtq9128_get_reg_size(unsigned int reg)
{
switch (reg) {
case 0x5C ... 0x6F:
case 0x98 ... 0x9F:
case 0xC0 ... 0xC3:
case 0xC8 ... 0xCF:
case 0xDF ... 0xE5:
case 0xF9:
return 4;
case 0x40 ... 0x4F:
return 3;
case 0x30 ... 0x35:
case 0x8C ... 0x97:
case 0xC4 ... 0xC7:
case 0xD7 ... 0xDA:
return 2;
default:
return 1;
}
}
static int rtq9128_i2c_write(void *context, const void *data, size_t count)
{
struct device *dev = context;
struct i2c_client *i2c = to_i2c_client(dev);
u8 reg = *(u8 *)data;
int rg_size;
if (count != 5) {
dev_err(dev, "Invalid write for data length (%d)\n", (int)count);
return -EINVAL;
}
rg_size = rtq9128_get_reg_size(reg);
return i2c_smbus_write_i2c_block_data(i2c, reg, rg_size, data + count - rg_size);
}
static int rtq9128_i2c_read(void *context, const void *reg_buf, size_t reg_size, void *val_buf,
size_t val_size)
{
struct device *dev = context;
struct i2c_client *i2c = to_i2c_client(dev);
u8 reg = *(u8 *)reg_buf;
u8 data_tmp[4] = {};
int rg_size, ret;
if (reg_size != 1 || val_size != 4) {
dev_err(dev, "Invalid read for reg_size (%d) or val_size (%d)\n", (int)reg_size,
(int)val_size);
return -EINVAL;
}
rg_size = rtq9128_get_reg_size(reg);
ret = i2c_smbus_read_i2c_block_data(i2c, reg, rg_size, data_tmp);
if (ret < 0)
return ret;
else if (ret != rg_size)
return -EIO;
memset(val_buf, 0, val_size - rg_size);
memcpy(val_buf + val_size - rg_size, data_tmp, rg_size);
return 0;
}
static const struct regmap_bus rtq9128_regmap_bus = {
.write = rtq9128_i2c_write,
.read = rtq9128_i2c_read,
.max_raw_read = 4,
.max_raw_write = 4,
};
static bool rtq9128_is_readable_reg(struct device *dev, unsigned int reg)
{
switch (reg) {
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bits.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/kernel.h`, `linux/mod_devicetable.h`, `linux/module.h`.
- Detected declarations: `struct rtq9128_data`, `struct rtq9128_init_reg`, `enum rtq9128_chip_model`, `function rtq9128_get_reg_size`, `function rtq9128_i2c_write`, `function rtq9128_i2c_read`, `function rtq9128_is_readable_reg`, `function rtq9128_is_writeable_reg`, `function rtq9128_is_volatile_reg`, `function rtq9128_dac_power_event`.
- 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.