drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c
Source file repositories/reference/linux-study-clean/drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c- Extension
.c- Size
- 6484 bytes
- Lines
- 239
- Domain
- Driver Families
- Bucket
- drivers/staging
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
sound/core.hsound/control.hsound/tlv.hsound/asoundef.hbcm2835.h
Detected Declarations
function bcm2835_audio_set_chip_ctlsfunction snd_bcm2835_ctl_infofunction snd_bcm2835_ctl_getfunction snd_bcm2835_ctl_putfunction snd_bcm2835_spdif_default_infofunction snd_bcm2835_spdif_default_getfunction snd_bcm2835_spdif_default_putfunction snd_bcm2835_spdif_mask_infofunction snd_bcm2835_spdif_mask_getfunction create_ctlsfunction snd_bcm2835_new_headphones_ctlfunction snd_bcm2835_new_hdmi_ctl
Annotated Snippet
if (chip->alsa_stream[i]) {
err = bcm2835_audio_set_ctls(chip->alsa_stream[i]);
if (err < 0)
break;
}
}
return err;
}
static int snd_bcm2835_ctl_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{
if (kcontrol->private_value == PCM_PLAYBACK_VOLUME) {
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
uinfo->count = 1;
uinfo->value.integer.min = CTRL_VOL_MIN;
uinfo->value.integer.max = CTRL_VOL_MAX; /* 2303 */
} else if (kcontrol->private_value == PCM_PLAYBACK_MUTE) {
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
uinfo->count = 1;
uinfo->value.integer.min = 0;
uinfo->value.integer.max = 1;
} else if (kcontrol->private_value == PCM_PLAYBACK_DEVICE) {
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
uinfo->count = 1;
uinfo->value.integer.min = 0;
uinfo->value.integer.max = AUDIO_DEST_MAX - 1;
}
return 0;
}
static int snd_bcm2835_ctl_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct bcm2835_chip *chip = snd_kcontrol_chip(kcontrol);
mutex_lock(&chip->audio_mutex);
if (kcontrol->private_value == PCM_PLAYBACK_VOLUME)
ucontrol->value.integer.value[0] = chip->volume;
else if (kcontrol->private_value == PCM_PLAYBACK_MUTE)
ucontrol->value.integer.value[0] = chip->mute;
else if (kcontrol->private_value == PCM_PLAYBACK_DEVICE)
ucontrol->value.integer.value[0] = chip->dest;
mutex_unlock(&chip->audio_mutex);
return 0;
}
static int snd_bcm2835_ctl_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct bcm2835_chip *chip = snd_kcontrol_chip(kcontrol);
struct snd_ctl_elem_info info;
int val, *valp;
int changed = 0;
if (kcontrol->private_value == PCM_PLAYBACK_VOLUME)
valp = &chip->volume;
else if (kcontrol->private_value == PCM_PLAYBACK_MUTE)
valp = &chip->mute;
else if (kcontrol->private_value == PCM_PLAYBACK_DEVICE)
valp = &chip->dest;
else
return -EINVAL;
val = ucontrol->value.integer.value[0];
snd_bcm2835_ctl_info(kcontrol, &info);
if (val < info.value.integer.min || val > info.value.integer.max)
return -EINVAL;
mutex_lock(&chip->audio_mutex);
if (val != *valp) {
*valp = val;
changed = 1;
if (bcm2835_audio_set_chip_ctls(chip))
dev_err(chip->card->dev, "Failed to set ALSA controls..\n");
}
mutex_unlock(&chip->audio_mutex);
return changed;
}
static DECLARE_TLV_DB_SCALE(snd_bcm2835_db_scale, CTRL_VOL_MIN, 1, 1);
static const struct snd_kcontrol_new snd_bcm2835_ctl[] = {
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "PCM Playback Volume",
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ,
Annotation
- Immediate include surface: `sound/core.h`, `sound/control.h`, `sound/tlv.h`, `sound/asoundef.h`, `bcm2835.h`.
- Detected declarations: `function bcm2835_audio_set_chip_ctls`, `function snd_bcm2835_ctl_info`, `function snd_bcm2835_ctl_get`, `function snd_bcm2835_ctl_put`, `function snd_bcm2835_spdif_default_info`, `function snd_bcm2835_spdif_default_get`, `function snd_bcm2835_spdif_default_put`, `function snd_bcm2835_spdif_mask_info`, `function snd_bcm2835_spdif_mask_get`, `function create_ctls`.
- Atlas domain: Driver Families / drivers/staging.
- 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.