sound/soc/codecs/tas2781-comlib-i2c.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/tas2781-comlib-i2c.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/tas2781-comlib-i2c.c- Extension
.c- Size
- 9294 bytes
- Lines
- 372
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/crc8.hlinux/firmware.hlinux/gpio/consumer.hlinux/i2c.hlinux/init.hlinux/interrupt.hlinux/module.hlinux/of.hlinux/of_irq.hlinux/regmap.hlinux/slab.hsound/pcm_params.hsound/soc.hsound/tas2781.hsound/tas2781-comlib-i2c.h
Detected Declarations
function tasdevice_change_chn_bookfunction tasdev_chn_switchfunction tasdevice_dev_update_bitsfunction tasdevice_initfunction tasdevice_clampfunction tasdevice_amp_putvolfunction tasdevice_amp_getvolfunction tasdevice_digital_getvolfunction tasdevice_digital_putvolfunction tasdevice_resetfunction tascodec_initexport tasdev_chn_switchexport tasdevice_dev_update_bitsexport tasdevice_kzallocexport tasdevice_initexport tasdevice_amp_putvolexport tasdevice_amp_getvolexport tasdevice_digital_getvolexport tasdevice_digital_putvolexport tasdevice_resetexport tascodec_init
Annotated Snippet
if (client->addr != tasdev->dev_addr) {
client->addr = tasdev->dev_addr;
/* All tas2781s share the same regmap, clear the page
* inside regmap once switching to another tas2781.
* Register 0 at any pages and any books inside tas2781
* is the same one for page-switching.
*/
ret = regmap_write(map, TASDEVICE_PAGE_SELECT, 0);
if (ret < 0) {
dev_err(tas_priv->dev, "%s, E=%d channel:%d\n",
__func__, ret, chn);
goto out;
}
}
if (tasdev->cur_book != book) {
ret = regmap_write(map, TASDEVICE_BOOKCTL_REG, book);
if (ret < 0) {
dev_err(tas_priv->dev, "%s, E=%d\n",
__func__, ret);
goto out;
}
tasdev->cur_book = book;
}
} else {
ret = -EINVAL;
dev_err(tas_priv->dev, "%s, no such channel(%d)\n", __func__,
chn);
}
out:
return ret;
}
int tasdev_chn_switch(struct tasdevice_priv *tas_priv,
unsigned short chn)
{
struct i2c_client *client = (struct i2c_client *)tas_priv->client;
struct tasdevice *tasdev = &tas_priv->tasdevice[chn];
struct regmap *map = tas_priv->regmap;
int ret;
if (client->addr != tasdev->dev_addr) {
client->addr = tasdev->dev_addr;
/* All devices share the same regmap, clear the page
* inside regmap once switching to another device.
* Register 0 at any pages and any books inside tas2781
* is the same one for page-switching.
*/
ret = regmap_write(map, TASDEVICE_PAGE_SELECT, 0);
if (ret < 0) {
dev_err(tas_priv->dev, "%s, E=%d\n", __func__, ret);
return ret;
}
return 1;
}
return 0;
}
EXPORT_SYMBOL_GPL(tasdev_chn_switch);
int tasdevice_dev_update_bits(
struct tasdevice_priv *tas_priv, unsigned short chn,
unsigned int reg, unsigned int mask, unsigned int value)
{
int ret = 0;
if (chn < tas_priv->ndev) {
struct regmap *map = tas_priv->regmap;
ret = tas_priv->change_chn_book(tas_priv, chn,
TASDEVICE_BOOK_ID(reg));
if (ret < 0)
goto out;
ret = regmap_update_bits(map, TASDEVICE_PGRG(reg),
mask, value);
if (ret < 0)
dev_err(tas_priv->dev, "%s, E=%d\n", __func__, ret);
} else {
dev_err(tas_priv->dev, "%s, no such channel(%d)\n", __func__,
chn);
ret = -EINVAL;
}
out:
return ret;
}
EXPORT_SYMBOL_GPL(tasdevice_dev_update_bits);
struct tasdevice_priv *tasdevice_kzalloc(struct i2c_client *i2c)
Annotation
- Immediate include surface: `linux/crc8.h`, `linux/firmware.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/init.h`, `linux/interrupt.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `function tasdevice_change_chn_book`, `function tasdev_chn_switch`, `function tasdevice_dev_update_bits`, `function tasdevice_init`, `function tasdevice_clamp`, `function tasdevice_amp_putvol`, `function tasdevice_amp_getvol`, `function tasdevice_digital_getvol`, `function tasdevice_digital_putvol`, `function tasdevice_reset`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: integration 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.