sound/i2c/cs8427.c
Source file repositories/reference/linux-study-clean/sound/i2c/cs8427.c
File Facts
- System
- Linux kernel
- Corpus path
sound/i2c/cs8427.c- Extension
.c- Size
- 18045 bytes
- Lines
- 623
- Domain
- Driver Families
- Bucket
- sound/i2c
- 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.
- 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/slab.hlinux/delay.hlinux/init.hlinux/bitrev.hlinux/module.hlinux/unaligned.hsound/core.hsound/control.hsound/pcm.hsound/cs8427.hsound/asoundef.h
Detected Declarations
struct cs8427_streamstruct cs8427function snd_cs8427_reg_writefunction snd_cs8427_reg_readfunction snd_cs8427_select_corudatafunction snd_cs8427_send_corudatafunction snd_cs8427_freefunction snd_cs8427_initfunction snd_cs8427_createfunction snd_cs8427_resetfunction snd_cs8427_in_status_infofunction snd_cs8427_in_status_getfunction snd_cs8427_qsubcode_infofunction snd_cs8427_qsubcode_getfunction snd_cs8427_spdif_infofunction snd_cs8427_spdif_getfunction snd_cs8427_spdif_putfunction snd_cs8427_spdif_mask_infofunction snd_cs8427_spdif_mask_getfunction snd_cs8427_iec958_buildfunction snd_cs8427_iec958_activefunction snd_cs8427_iec958_pcmexport snd_cs8427_reg_writeexport snd_cs8427_initexport snd_cs8427_createexport snd_cs8427_iec958_buildexport snd_cs8427_iec958_activeexport snd_cs8427_iec958_pcm
Annotated Snippet
struct cs8427_stream {
struct snd_pcm_substream *substream;
char hw_status[24]; /* hardware status */
char def_status[24]; /* default status */
char pcm_status[24]; /* PCM private status */
char hw_udata[32];
struct snd_kcontrol *pcm_ctl;
};
struct cs8427 {
unsigned char regmap[0x14]; /* map of first 1 + 13 registers */
unsigned int rate;
unsigned int reset_timeout;
struct cs8427_stream playback;
struct cs8427_stream capture;
};
int snd_cs8427_reg_write(struct snd_i2c_device *device, unsigned char reg,
unsigned char val)
{
int err;
unsigned char buf[2];
buf[0] = reg & 0x7f;
buf[1] = val;
err = snd_i2c_sendbytes(device, buf, 2);
if (err != 2) {
dev_err(device->bus->card->dev,
"unable to send bytes 0x%02x:0x%02x to CS8427 (%i)\n",
buf[0], buf[1], err);
return err < 0 ? err : -EIO;
}
return 0;
}
EXPORT_SYMBOL(snd_cs8427_reg_write);
static int snd_cs8427_reg_read(struct snd_i2c_device *device, unsigned char reg)
{
int err;
unsigned char buf;
err = snd_i2c_sendbytes(device, ®, 1);
if (err != 1) {
dev_err(device->bus->card->dev,
"unable to send register 0x%x byte to CS8427\n", reg);
return err < 0 ? err : -EIO;
}
err = snd_i2c_readbytes(device, &buf, 1);
if (err != 1) {
dev_err(device->bus->card->dev,
"unable to read register 0x%x byte from CS8427\n", reg);
return err < 0 ? err : -EIO;
}
return buf;
}
static int snd_cs8427_select_corudata(struct snd_i2c_device *device, int udata)
{
struct cs8427 *chip = device->private_data;
int err;
udata = udata ? CS8427_BSEL : 0;
if (udata != (chip->regmap[CS8427_REG_CSDATABUF] & udata)) {
chip->regmap[CS8427_REG_CSDATABUF] &= ~CS8427_BSEL;
chip->regmap[CS8427_REG_CSDATABUF] |= udata;
err = snd_cs8427_reg_write(device, CS8427_REG_CSDATABUF,
chip->regmap[CS8427_REG_CSDATABUF]);
if (err < 0)
return err;
}
return 0;
}
static int snd_cs8427_send_corudata(struct snd_i2c_device *device,
int udata,
unsigned char *ndata,
int count)
{
struct cs8427 *chip = device->private_data;
char *hw_data = udata ?
chip->playback.hw_udata : chip->playback.hw_status;
unsigned char data[32];
int err, idx;
if (!memcmp(hw_data, ndata, count))
return 0;
err = snd_cs8427_select_corudata(device, udata);
if (err < 0)
return err;
Annotation
- Immediate include surface: `linux/slab.h`, `linux/delay.h`, `linux/init.h`, `linux/bitrev.h`, `linux/module.h`, `linux/unaligned.h`, `sound/core.h`, `sound/control.h`.
- Detected declarations: `struct cs8427_stream`, `struct cs8427`, `function snd_cs8427_reg_write`, `function snd_cs8427_reg_read`, `function snd_cs8427_select_corudata`, `function snd_cs8427_send_corudata`, `function snd_cs8427_free`, `function snd_cs8427_init`, `function snd_cs8427_create`, `function snd_cs8427_reset`.
- Atlas domain: Driver Families / sound/i2c.
- Implementation status: integration 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.