sound/soc/intel/avs/control.c
Source file repositories/reference/linux-study-clean/sound/soc/intel/avs/control.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/intel/avs/control.c- Extension
.c- Size
- 6076 bytes
- Lines
- 215
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/cleanup.hsound/soc.havs.hcontrol.hmessages.hpath.h
Detected Declarations
function list_for_each_entryfunction avs_control_volume_getfunction avs_control_volume_putfunction avs_control_volume_infofunction avs_control_mute_getfunction avs_control_mute_putfunction avs_control_mute_info
Annotated Snippet
list_for_each_entry(ppl, &path->ppl_list, node) {
list_for_each_entry(mod, &ppl->mod_list, node) {
guid_t *type = &mod->template->cfg_ext->type;
if ((guid_equal(type, &AVS_PEAKVOL_MOD_UUID) ||
guid_equal(type, &AVS_GAIN_MOD_UUID)) &&
mod->template->ctl_id == id) {
spin_unlock(&adev->path_list_lock);
return mod;
}
}
}
}
spin_unlock(&adev->path_list_lock);
return NULL;
}
int avs_control_volume_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *uctl)
{
struct soc_mixer_control *mc = (struct soc_mixer_control *)kctl->private_value;
struct avs_control_data *ctl_data = mc->dobj.private;
struct avs_path_module *active_module;
struct avs_volume_cfg *dspvols;
struct avs_dev *adev;
size_t num_dspvols;
int ret, i;
adev = avs_get_kcontrol_adev(kctl);
/* Prevent access to modules while path is being constructed. */
guard(mutex)(&adev->path_mutex);
active_module = avs_get_volume_module(adev, ctl_data->id);
if (active_module) {
ret = avs_ipc_peakvol_get_volume(adev, active_module->module_id,
active_module->instance_id, &dspvols,
&num_dspvols);
if (ret)
return AVS_IPC_RET(ret);
/* Do not copy more than the control can store. */
num_dspvols = min_t(u32, num_dspvols, SND_SOC_TPLG_MAX_CHAN);
for (i = 0; i < num_dspvols; i++)
ctl_data->values[i] = dspvols[i].target_volume;
kfree(dspvols);
}
memcpy(uctl->value.integer.value, ctl_data->values, sizeof(ctl_data->values));
return 0;
}
int avs_control_volume_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *uctl)
{
struct avs_path_module *active_module;
struct avs_control_data *ctl_data;
struct soc_mixer_control *mc;
struct avs_dev *adev;
long *input;
int ret, i;
mc = (struct soc_mixer_control *)kctl->private_value;
ctl_data = mc->dobj.private;
adev = avs_get_kcontrol_adev(kctl);
input = uctl->value.integer.value;
i = 0;
/* mc->num_channels can be 0. */
do {
if (input[i] < mc->min || input[i] > mc->max)
return -EINVAL;
} while (++i < mc->num_channels);
if (!memcmp(ctl_data->values, input, sizeof(ctl_data->values)))
return 0;
/* Prevent access to modules while path is being constructed. */
guard(mutex)(&adev->path_mutex);
active_module = avs_get_volume_module(adev, ctl_data->id);
if (active_module) {
ret = avs_peakvol_set_volume(adev, active_module, mc, input);
if (ret)
return ret;
}
memcpy(ctl_data->values, input, sizeof(ctl_data->values));
return 1;
}
Annotation
- Immediate include surface: `linux/cleanup.h`, `sound/soc.h`, `avs.h`, `control.h`, `messages.h`, `path.h`.
- Detected declarations: `function list_for_each_entry`, `function avs_control_volume_get`, `function avs_control_volume_put`, `function avs_control_volume_info`, `function avs_control_mute_get`, `function avs_control_mute_put`, `function avs_control_mute_info`.
- 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.