sound/aoa/codecs/tas.c
Source file repositories/reference/linux-study-clean/sound/aoa/codecs/tas.c
File Facts
- System
- Linux kernel
- Corpus path
sound/aoa/codecs/tas.c- Extension
.c- Size
- 23616 bytes
- Lines
- 911
- Domain
- Driver Families
- Bucket
- sound/aoa
- 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/i2c.hasm/pmac_low_i2c.hlinux/delay.hlinux/module.hlinux/mutex.hlinux/of.hlinux/slab.htas.htas-gain-table.htas-basstreble.h../aoa.h../soundbus/soundbus.h
Detected Declarations
struct tasfunction tas_write_regfunction tas3004_set_drcfunction tas_set_treblefunction tas_set_bassfunction tas_set_volumefunction tas_set_mixerfunction tas_dev_registerfunction tas_snd_vol_infofunction tas_snd_vol_getfunction tas_snd_vol_putfunction tas_snd_mute_getfunction tas_snd_mute_putfunction tas_snd_mixer_infofunction tas_snd_mixer_getfunction tas_snd_mixer_putfunction tas_snd_drc_range_infofunction tas_snd_drc_range_getfunction tas_snd_drc_range_putfunction tas_snd_drc_switch_getfunction tas_snd_drc_switch_putfunction tas_snd_capture_source_infofunction tas_snd_capture_source_getfunction tas_snd_capture_source_putfunction tas_snd_treble_infofunction tas_snd_treble_getfunction tas_snd_treble_putfunction tas_snd_bass_infofunction tas_snd_bass_getfunction tas_snd_bass_putfunction tas_usablefunction tas_reset_initfunction tas_switch_clockfunction scoped_guardfunction tas_suspendfunction tas_resumefunction _tas_suspendfunction _tas_resumefunction tas_init_codecfunction scoped_guardfunction tas_exit_codecfunction tas_i2c_probefunction tas_i2c_remove
Annotated Snippet
struct tas {
struct aoa_codec codec;
struct i2c_client *i2c;
u32 mute_l:1, mute_r:1 ,
controls_created:1 ,
drc_enabled:1,
hw_enabled:1;
u8 cached_volume_l, cached_volume_r;
u8 mixer_l[3], mixer_r[3];
u8 bass, treble;
u8 acr;
int drc_range;
/* protects hardware access against concurrency from
* userspace when hitting controls and during
* codec init/suspend/resume */
struct mutex mtx;
};
static int tas_reset_init(struct tas *tas);
static struct tas *codec_to_tas(struct aoa_codec *codec)
{
return container_of(codec, struct tas, codec);
}
static inline int tas_write_reg(struct tas *tas, u8 reg, u8 len, u8 *data)
{
if (len == 1)
return i2c_smbus_write_byte_data(tas->i2c, reg, *data);
else
return i2c_smbus_write_i2c_block_data(tas->i2c, reg, len, data);
}
static void tas3004_set_drc(struct tas *tas)
{
unsigned char val[6];
if (tas->drc_enabled)
val[0] = 0x50; /* 3:1 above threshold */
else
val[0] = 0x51; /* disabled */
val[1] = 0x02; /* 1:1 below threshold */
if (tas->drc_range > 0xef)
val[2] = 0xef;
else if (tas->drc_range < 0)
val[2] = 0x00;
else
val[2] = tas->drc_range;
val[3] = 0xb0;
val[4] = 0x60;
val[5] = 0xa0;
tas_write_reg(tas, TAS_REG_DRC, 6, val);
}
static void tas_set_treble(struct tas *tas)
{
u8 tmp;
tmp = tas3004_treble(tas->treble);
tas_write_reg(tas, TAS_REG_TREBLE, 1, &tmp);
}
static void tas_set_bass(struct tas *tas)
{
u8 tmp;
tmp = tas3004_bass(tas->bass);
tas_write_reg(tas, TAS_REG_BASS, 1, &tmp);
}
static void tas_set_volume(struct tas *tas)
{
u8 block[6];
int tmp;
u8 left, right;
left = tas->cached_volume_l;
right = tas->cached_volume_r;
if (left > 177) left = 177;
if (right > 177) right = 177;
if (tas->mute_l) left = 0;
if (tas->mute_r) right = 0;
/* analysing the volume and mixer tables shows
* that they are similar enough when we shift
* the mixer table down by 4 bits. The error
* is miniscule, in just one item the error
Annotation
- Immediate include surface: `linux/i2c.h`, `asm/pmac_low_i2c.h`, `linux/delay.h`, `linux/module.h`, `linux/mutex.h`, `linux/of.h`, `linux/slab.h`, `tas.h`.
- Detected declarations: `struct tas`, `function tas_write_reg`, `function tas3004_set_drc`, `function tas_set_treble`, `function tas_set_bass`, `function tas_set_volume`, `function tas_set_mixer`, `function tas_dev_register`, `function tas_snd_vol_info`, `function tas_snd_vol_get`.
- Atlas domain: Driver Families / sound/aoa.
- 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.