tools/testing/selftests/alsa/mixer-test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/alsa/mixer-test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/alsa/mixer-test.c- Extension
.c- Size
- 29957 bytes
- Lines
- 1146
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdio.hstdlib.hstdbool.hlimits.hstring.hgetopt.hstdarg.hctype.hmath.herrno.hassert.halsa/asoundlib.hpoll.hstdint.hkselftest.halsa-local.h
Detected Declarations
struct card_datastruct ctl_datafunction find_controlsfunction wait_for_eventfunction ctl_value_index_validfunction ctl_value_validfunction test_ctl_get_valuefunction strendfunction test_ctl_namefunction snd_ctl_elem_info_is_writablefunction show_valuesfunction show_mismatchfunction write_and_verifyfunction test_ctl_write_defaultfunction test_ctl_write_valid_booleanfunction test_ctl_write_valid_integerfunction test_ctl_write_valid_integer64function test_ctl_write_valid_enumeratedfunction test_ctl_write_validfunction test_ctl_write_invalid_valuefunction test_ctl_write_invalid_booleanfunction test_ctl_write_invalid_integerfunction test_ctl_write_invalid_integer64function test_ctl_write_invalid_enumeratedfunction test_ctl_write_invalidfunction test_ctl_event_missingfunction test_ctl_event_spuriousfunction main
Annotated Snippet
struct card_data {
snd_ctl_t *handle;
int card;
snd_ctl_card_info_t *info;
const char *card_name;
struct pollfd pollfd;
int num_ctls;
snd_ctl_elem_list_t *ctls;
struct card_data *next;
};
struct ctl_data {
const char *name;
snd_ctl_elem_id_t *id;
snd_ctl_elem_info_t *info;
snd_ctl_elem_value_t *def_val;
int elem;
int event_missing;
int event_spurious;
struct card_data *card;
struct ctl_data *next;
};
int num_cards;
int num_controls;
struct card_data *card_list;
struct ctl_data *ctl_list;
static void find_controls(void)
{
char name[32];
int card, ctl, err;
struct card_data *card_data;
struct ctl_data *ctl_data;
snd_config_t *config;
char *card_name, *card_longname;
card = -1;
if (snd_card_next(&card) < 0 || card < 0)
return;
config = get_alsalib_config();
while (card >= 0) {
sprintf(name, "hw:%d", card);
card_data = malloc(sizeof(*card_data));
if (!card_data)
ksft_exit_fail_msg("Out of memory\n");
err = snd_ctl_open_lconf(&card_data->handle, name, 0, config);
if (err < 0) {
ksft_print_msg("Failed to get hctl for card %d: %s\n",
card, snd_strerror(err));
goto next_card;
}
err = snd_card_get_name(card, &card_name);
if (err != 0)
card_name = "Unknown";
err = snd_card_get_longname(card, &card_longname);
if (err != 0)
card_longname = "Unknown";
err = snd_ctl_card_info_malloc(&card_data->info);
if (err != 0)
ksft_exit_fail_msg("Failed to allocate card info: %d\n",
err);
err = snd_ctl_card_info(card_data->handle, card_data->info);
if (err == 0) {
card_data->card_name = snd_ctl_card_info_get_id(card_data->info);
if (!card_data->card_name)
ksft_print_msg("Failed to get card ID\n");
} else {
ksft_print_msg("Failed to get card info: %d\n", err);
}
if (!card_data->card_name)
card_data->card_name = "Unknown";
ksft_print_msg("Card %d/%s - %s (%s)\n", card,
card_data->card_name, card_name, card_longname);
/* Count controls */
snd_ctl_elem_list_malloc(&card_data->ctls);
snd_ctl_elem_list(card_data->handle, card_data->ctls);
card_data->num_ctls = snd_ctl_elem_list_get_count(card_data->ctls);
/* Enumerate control information */
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `stdbool.h`, `limits.h`, `string.h`, `getopt.h`, `stdarg.h`, `ctype.h`.
- Detected declarations: `struct card_data`, `struct ctl_data`, `function find_controls`, `function wait_for_event`, `function ctl_value_index_valid`, `function ctl_value_valid`, `function test_ctl_get_value`, `function strend`, `function test_ctl_name`, `function snd_ctl_elem_info_is_writable`.
- Atlas domain: Support Tooling And Documentation / tools.
- 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.