sound/soc/codecs/tas5805m.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/tas5805m.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/tas5805m.c- Extension
.c- Size
- 19226 bytes
- Lines
- 612
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/moduleparam.hlinux/kernel.hlinux/firmware.hlinux/slab.hlinux/of.hlinux/init.hlinux/i2c.hlinux/regmap.hlinux/gpio/consumer.hlinux/regulator/consumer.hlinux/atomic.hlinux/workqueue.hsound/soc.hsound/pcm.hsound/initval.h
Detected Declarations
struct tas5805m_privfunction set_dsp_scalefunction tas5805m_refreshfunction tas5805m_vol_infofunction tas5805m_vol_getfunction volume_is_validfunction tas5805m_vol_putfunction send_cfgfunction tas5805m_triggerfunction do_workfunction tas5805m_dac_eventfunction tas5805m_mutefunction tas5805m_i2c_probefunction tas5805m_i2c_remove
Annotated Snippet
struct tas5805m_priv {
struct i2c_client *i2c;
struct regulator *pvdd;
struct gpio_desc *gpio_pdn_n;
uint8_t *dsp_cfg_data;
int dsp_cfg_len;
struct regmap *regmap;
int vol[2];
bool is_powered;
bool is_muted;
struct work_struct work;
struct mutex lock;
};
static void set_dsp_scale(struct regmap *rm, int offset, int vol)
{
uint8_t v[4];
uint32_t x = tas5805m_volume[vol];
int i;
for (i = 0; i < 4; i++) {
v[3 - i] = x;
x >>= 8;
}
regmap_bulk_write(rm, offset, v, ARRAY_SIZE(v));
}
static void tas5805m_refresh(struct tas5805m_priv *tas5805m)
{
struct regmap *rm = tas5805m->regmap;
dev_dbg(&tas5805m->i2c->dev, "refresh: is_muted=%d, vol=%d/%d\n",
tas5805m->is_muted, tas5805m->vol[0], tas5805m->vol[1]);
regmap_write(rm, REG_PAGE, 0x00);
regmap_write(rm, REG_BOOK, 0x8c);
regmap_write(rm, REG_PAGE, 0x2a);
/* Refresh volume. The actual volume control documented in the
* datasheet doesn't seem to work correctly. This is a pair of
* DSP registers which are *not* documented in the datasheet.
*/
set_dsp_scale(rm, 0x24, tas5805m->vol[0]);
set_dsp_scale(rm, 0x28, tas5805m->vol[1]);
regmap_write(rm, REG_PAGE, 0x00);
regmap_write(rm, REG_BOOK, 0x00);
/* Set/clear digital soft-mute */
regmap_write(rm, REG_DEVICE_CTRL_2,
(tas5805m->is_muted ? DCTRL2_MUTE : 0) |
DCTRL2_MODE_PLAY);
}
static int tas5805m_vol_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
uinfo->count = 2;
uinfo->value.integer.min = TAS5805M_VOLUME_MIN;
uinfo->value.integer.max = TAS5805M_VOLUME_MAX;
return 0;
}
static int tas5805m_vol_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct tas5805m_priv *tas5805m =
snd_soc_component_get_drvdata(component);
mutex_lock(&tas5805m->lock);
ucontrol->value.integer.value[0] = tas5805m->vol[0];
ucontrol->value.integer.value[1] = tas5805m->vol[1];
mutex_unlock(&tas5805m->lock);
return 0;
}
static inline int volume_is_valid(int v)
{
return (v >= TAS5805M_VOLUME_MIN) && (v <= TAS5805M_VOLUME_MAX);
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/moduleparam.h`, `linux/kernel.h`, `linux/firmware.h`, `linux/slab.h`, `linux/of.h`, `linux/init.h`, `linux/i2c.h`.
- Detected declarations: `struct tas5805m_priv`, `function set_dsp_scale`, `function tas5805m_refresh`, `function tas5805m_vol_info`, `function tas5805m_vol_get`, `function volume_is_valid`, `function tas5805m_vol_put`, `function send_cfg`, `function tas5805m_trigger`, `function do_work`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.