sound/ppc/daca.c
Source file repositories/reference/linux-study-clean/sound/ppc/daca.c
File Facts
- System
- Linux kernel
- Corpus path
sound/ppc/daca.c- Extension
.c- Size
- 6362 bytes
- Lines
- 278
- Domain
- Driver Families
- Bucket
- sound/ppc
- 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/init.hlinux/i2c.hlinux/kmod.hlinux/slab.hsound/core.hpmac.h
Detected Declarations
struct pmac_dacafunction daca_init_clientfunction daca_set_volumefunction daca_get_deemphasisfunction daca_put_deemphasisfunction daca_info_volumefunction daca_get_volumefunction daca_put_volumefunction daca_get_ampfunction daca_put_ampfunction daca_resumefunction daca_cleanupfunction snd_pmac_daca_init
Annotated Snippet
struct pmac_daca {
struct pmac_keywest i2c;
int left_vol, right_vol;
unsigned int deemphasis : 1;
unsigned int amp_on : 1;
};
/*
* initialize / detect DACA
*/
static int daca_init_client(struct pmac_keywest *i2c)
{
unsigned short wdata = 0x00;
/* SR: no swap, 1bit delay, 32-48kHz */
/* GCFG: power amp inverted, DAC on */
if (i2c_smbus_write_byte_data(i2c->client, DACA_REG_SR, 0x08) < 0 ||
i2c_smbus_write_byte_data(i2c->client, DACA_REG_GCFG, 0x05) < 0)
return -EINVAL;
return i2c_smbus_write_block_data(i2c->client, DACA_REG_AVOL,
2, (unsigned char*)&wdata);
}
/*
* update volume
*/
static int daca_set_volume(struct pmac_daca *mix)
{
unsigned char data[2];
if (! mix->i2c.client)
return -ENODEV;
if (mix->left_vol > DACA_VOL_MAX)
data[0] = DACA_VOL_MAX;
else
data[0] = mix->left_vol;
if (mix->right_vol > DACA_VOL_MAX)
data[1] = DACA_VOL_MAX;
else
data[1] = mix->right_vol;
data[1] |= mix->deemphasis ? 0x40 : 0;
if (i2c_smbus_write_block_data(mix->i2c.client, DACA_REG_AVOL,
2, data) < 0) {
dev_err(&mix->i2c.client->dev, "failed to set volume\n");
return -EINVAL;
}
return 0;
}
/* deemphasis switch */
#define daca_info_deemphasis snd_ctl_boolean_mono_info
static int daca_get_deemphasis(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
struct pmac_daca *mix;
mix = chip->mixer_data;
if (!mix)
return -ENODEV;
ucontrol->value.integer.value[0] = mix->deemphasis ? 1 : 0;
return 0;
}
static int daca_put_deemphasis(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
struct pmac_daca *mix;
int change;
mix = chip->mixer_data;
if (!mix)
return -ENODEV;
change = mix->deemphasis != ucontrol->value.integer.value[0];
if (change) {
mix->deemphasis = !!ucontrol->value.integer.value[0];
daca_set_volume(mix);
}
return change;
}
/* output volume */
static int daca_info_volume(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
uinfo->count = 2;
Annotation
- Immediate include surface: `linux/init.h`, `linux/i2c.h`, `linux/kmod.h`, `linux/slab.h`, `sound/core.h`, `pmac.h`.
- Detected declarations: `struct pmac_daca`, `function daca_init_client`, `function daca_set_volume`, `function daca_get_deemphasis`, `function daca_put_deemphasis`, `function daca_info_volume`, `function daca_get_volume`, `function daca_put_volume`, `function daca_get_amp`, `function daca_put_amp`.
- Atlas domain: Driver Families / sound/ppc.
- 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.