diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2024-07-19 12:39:34 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2024-07-19 12:39:34 -0700 |
commit | 12cc3d5389f313f07222b000fefa2cd8fc98c4f8 (patch) | |
tree | 73e08510a0814f2b710c8bd7a8384087d7340b70 /tools | |
parent | a4f9285520584977127946a22eab2adfbc87d1bf (diff) | |
parent | 4594d26fca91fab0e1621d2ab196f3f9bab96bc8 (diff) |
Merge tag 'sound-6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
Pull sound updates from Takashi Iwai:
"Lots of changes in this cycle, but mostly for cleanups and
refactoring.
Significant amount of changes are about DT schema conversions for ASoC
at this time while we see other usual suspects, too.
Some highlights below:
Core:
- Re-introduction of PCM sync ID support API
- MIDI2 time-base extension in ALSA sequencer API
ASoC:
- Syncing of features between simple-audio-card and the two
audio-graph cards
- Support for specifying the order of operations for components
within cards to allow quirking for unusual systems
- Lots of DT schema conversions
- Continued SOF/Intel updates for topology, SoundWire, IPC3/4
- New support for Asahi Kasei AK4619, Cirrus Logic CS530x, Everest
Semiconductors ES8311, NXP i.MX95 and LPC32xx, Qualcomm LPASS v2.5
and WCD937x, Realtek RT1318 and RT1320 and Texas Instruments
PCM5242
HD-audio:
- More quirks, Intel PantherLake support, senarytech codec support
- Refactoring of Cirrus codec component-binding
Others:
- ALSA control kselftest improvements, and fixes for input value
checks in various drivers"
* tag 'sound-6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (349 commits)
kselftest/alsa: Log the PCM ID in pcm-test
kselftest/alsa: Use card name rather than number in test names
ALSA: hda/realtek: Fix the speaker output on Samsung Galaxy Book Pro 360
ALSA: hda/tas2781: Add new quirk for Lenovo Hera2 Laptop
ALSA: seq: ump: Skip useless ports for static blocks
ALSA: pcm_dmaengine: Don't synchronize DMA channel when DMA is paused
ALSA: usb: Use BIT() for bit values
ALSA: usb: Fix UBSAN warning in parse_audio_unit()
ALSA: hda/realtek: Enable headset mic on Positivo SU C1400
ASoC: tas2781: Add new Kontrol to set tas2563 digital Volume
ASoC: codecs: wcd937x: Remove separate handling for vdd-buck supply
ASoC: codecs: wcd937x: Remove the string compare in MIC BIAS widget settings
ASoC: codecs: wcd937x-sdw: Fix Unbalanced pm_runtime_enable
ASoC: dt-bindings: cirrus,cs42xx8: Convert to dtschema
ASoC: cs530x: Remove bclk from private structure
ASoC: cs530x: Calculate proper bclk rate using TDM
ASoC: dt-bindings: cirrus,cs4270: Convert to dtschema
firmware: cs_dsp: Rename fw_ver to wmfw_ver
firmware: cs_dsp: Clarify wmfw format version log message
firmware: cs_dsp: Make wmfw and bin filename arguments const char *
...
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/alsa/mixer-test.c | 143 | ||||
-rw-r--r-- | tools/testing/selftests/alsa/pcm-test.c | 70 |
2 files changed, 138 insertions, 75 deletions
diff --git a/tools/testing/selftests/alsa/mixer-test.c b/tools/testing/selftests/alsa/mixer-test.c index 1c04e5f638a0..2a4b2662035e 100644 --- a/tools/testing/selftests/alsa/mixer-test.c +++ b/tools/testing/selftests/alsa/mixer-test.c @@ -33,6 +33,8 @@ 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; @@ -91,8 +93,26 @@ static void find_controls(void) err = snd_card_get_longname(card, &card_longname); if (err != 0) card_longname = "Unknown"; - ksft_print_msg("Card %d - %s (%s)\n", card, - card_name, card_longname); + + 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); @@ -389,16 +409,16 @@ static void test_ctl_get_value(struct ctl_data *ctl) /* If the control is turned off let's be polite */ if (snd_ctl_elem_info_is_inactive(ctl->info)) { ksft_print_msg("%s is inactive\n", ctl->name); - ksft_test_result_skip("get_value.%d.%d\n", - ctl->card->card, ctl->elem); + ksft_test_result_skip("get_value.%s.%d\n", + ctl->card->card_name, ctl->elem); return; } /* Can't test reading on an unreadable control */ if (!snd_ctl_elem_info_is_readable(ctl->info)) { ksft_print_msg("%s is not readable\n", ctl->name); - ksft_test_result_skip("get_value.%d.%d\n", - ctl->card->card, ctl->elem); + ksft_test_result_skip("get_value.%s.%d\n", + ctl->card->card_name, ctl->elem); return; } @@ -413,8 +433,8 @@ static void test_ctl_get_value(struct ctl_data *ctl) err = -EINVAL; out: - ksft_test_result(err >= 0, "get_value.%d.%d\n", - ctl->card->card, ctl->elem); + ksft_test_result(err >= 0, "get_value.%s.%d\n", + ctl->card->card_name, ctl->elem); } static bool strend(const char *haystack, const char *needle) @@ -431,7 +451,7 @@ static void test_ctl_name(struct ctl_data *ctl) { bool name_ok = true; - ksft_print_msg("%d.%d %s\n", ctl->card->card, ctl->elem, + ksft_print_msg("%s.%d %s\n", ctl->card->card_name, ctl->elem, ctl->name); /* Only boolean controls should end in Switch */ @@ -453,8 +473,8 @@ static void test_ctl_name(struct ctl_data *ctl) } } - ksft_test_result(name_ok, "name.%d.%d\n", - ctl->card->card, ctl->elem); + ksft_test_result(name_ok, "name.%s.%d\n", + ctl->card->card_name, ctl->elem); } static void show_values(struct ctl_data *ctl, snd_ctl_elem_value_t *orig_val, @@ -626,28 +646,41 @@ static int write_and_verify(struct ctl_data *ctl, } /* + * We can't verify any specific value for volatile controls + * but we should still check that whatever we read is a valid + * vale for the control. + */ + if (snd_ctl_elem_info_is_volatile(ctl->info)) { + if (!ctl_value_valid(ctl, read_val)) { + ksft_print_msg("Volatile control %s has invalid value\n", + ctl->name); + return -EINVAL; + } + + return 0; + } + + /* * Check for an event if the value changed, or confirm that * there was none if it didn't. We rely on the kernel * generating the notification before it returns from the * write, this is currently true, should that ever change this * will most likely break and need updating. */ - if (!snd_ctl_elem_info_is_volatile(ctl->info)) { - err = wait_for_event(ctl, 0); - if (snd_ctl_elem_value_compare(initial_val, read_val)) { - if (err < 1) { - ksft_print_msg("No event generated for %s\n", - ctl->name); - show_values(ctl, initial_val, read_val); - ctl->event_missing++; - } - } else { - if (err != 0) { - ksft_print_msg("Spurious event generated for %s\n", - ctl->name); - show_values(ctl, initial_val, read_val); - ctl->event_spurious++; - } + err = wait_for_event(ctl, 0); + if (snd_ctl_elem_value_compare(initial_val, read_val)) { + if (err < 1) { + ksft_print_msg("No event generated for %s\n", + ctl->name); + show_values(ctl, initial_val, read_val); + ctl->event_missing++; + } + } else { + if (err != 0) { + ksft_print_msg("Spurious event generated for %s\n", + ctl->name); + show_values(ctl, initial_val, read_val); + ctl->event_spurious++; } } @@ -682,30 +715,30 @@ static void test_ctl_write_default(struct ctl_data *ctl) /* If the control is turned off let's be polite */ if (snd_ctl_elem_info_is_inactive(ctl->info)) { ksft_print_msg("%s is inactive\n", ctl->name); - ksft_test_result_skip("write_default.%d.%d\n", - ctl->card->card, ctl->elem); + ksft_test_result_skip("write_default.%s.%d\n", + ctl->card->card_name, ctl->elem); return; } if (!snd_ctl_elem_info_is_writable(ctl->info)) { ksft_print_msg("%s is not writeable\n", ctl->name); - ksft_test_result_skip("write_default.%d.%d\n", - ctl->card->card, ctl->elem); + ksft_test_result_skip("write_default.%s.%d\n", + ctl->card->card_name, ctl->elem); return; } /* No idea what the default was for unreadable controls */ if (!snd_ctl_elem_info_is_readable(ctl->info)) { ksft_print_msg("%s couldn't read default\n", ctl->name); - ksft_test_result_skip("write_default.%d.%d\n", - ctl->card->card, ctl->elem); + ksft_test_result_skip("write_default.%s.%d\n", + ctl->card->card_name, ctl->elem); return; } err = write_and_verify(ctl, ctl->def_val, NULL); - ksft_test_result(err >= 0, "write_default.%d.%d\n", - ctl->card->card, ctl->elem); + ksft_test_result(err >= 0, "write_default.%s.%d\n", + ctl->card->card_name, ctl->elem); } static bool test_ctl_write_valid_boolean(struct ctl_data *ctl) @@ -815,15 +848,15 @@ static void test_ctl_write_valid(struct ctl_data *ctl) /* If the control is turned off let's be polite */ if (snd_ctl_elem_info_is_inactive(ctl->info)) { ksft_print_msg("%s is inactive\n", ctl->name); - ksft_test_result_skip("write_valid.%d.%d\n", - ctl->card->card, ctl->elem); + ksft_test_result_skip("write_valid.%s.%d\n", + ctl->card->card_name, ctl->elem); return; } if (!snd_ctl_elem_info_is_writable(ctl->info)) { ksft_print_msg("%s is not writeable\n", ctl->name); - ksft_test_result_skip("write_valid.%d.%d\n", - ctl->card->card, ctl->elem); + ksft_test_result_skip("write_valid.%s.%d\n", + ctl->card->card_name, ctl->elem); return; } @@ -846,16 +879,16 @@ static void test_ctl_write_valid(struct ctl_data *ctl) default: /* No tests for this yet */ - ksft_test_result_skip("write_valid.%d.%d\n", - ctl->card->card, ctl->elem); + ksft_test_result_skip("write_valid.%s.%d\n", + ctl->card->card_name, ctl->elem); return; } /* Restore the default value to minimise disruption */ write_and_verify(ctl, ctl->def_val, NULL); - ksft_test_result(pass, "write_valid.%d.%d\n", - ctl->card->card, ctl->elem); + ksft_test_result(pass, "write_valid.%s.%d\n", + ctl->card->card_name, ctl->elem); } static bool test_ctl_write_invalid_value(struct ctl_data *ctl, @@ -1027,15 +1060,15 @@ static void test_ctl_write_invalid(struct ctl_data *ctl) /* If the control is turned off let's be polite */ if (snd_ctl_elem_info_is_inactive(ctl->info)) { ksft_print_msg("%s is inactive\n", ctl->name); - ksft_test_result_skip("write_invalid.%d.%d\n", - ctl->card->card, ctl->elem); + ksft_test_result_skip("write_invalid.%s.%d\n", + ctl->card->card_name, ctl->elem); return; } if (!snd_ctl_elem_info_is_writable(ctl->info)) { ksft_print_msg("%s is not writeable\n", ctl->name); - ksft_test_result_skip("write_invalid.%d.%d\n", - ctl->card->card, ctl->elem); + ksft_test_result_skip("write_invalid.%s.%d\n", + ctl->card->card_name, ctl->elem); return; } @@ -1058,28 +1091,28 @@ static void test_ctl_write_invalid(struct ctl_data *ctl) default: /* No tests for this yet */ - ksft_test_result_skip("write_invalid.%d.%d\n", - ctl->card->card, ctl->elem); + ksft_test_result_skip("write_invalid.%s.%d\n", + ctl->card->card_name, ctl->elem); return; } /* Restore the default value to minimise disruption */ write_and_verify(ctl, ctl->def_val, NULL); - ksft_test_result(pass, "write_invalid.%d.%d\n", - ctl->card->card, ctl->elem); + ksft_test_result(pass, "write_invalid.%s.%d\n", + ctl->card->card_name, ctl->elem); } static void test_ctl_event_missing(struct ctl_data *ctl) { - ksft_test_result(!ctl->event_missing, "event_missing.%d.%d\n", - ctl->card->card, ctl->elem); + ksft_test_result(!ctl->event_missing, "event_missing.%s.%d\n", + ctl->card->card_name, ctl->elem); } static void test_ctl_event_spurious(struct ctl_data *ctl) { - ksft_test_result(!ctl->event_spurious, "event_spurious.%d.%d\n", - ctl->card->card, ctl->elem); + ksft_test_result(!ctl->event_spurious, "event_spurious.%s.%d\n", + ctl->card->card_name, ctl->elem); } int main(void) diff --git a/tools/testing/selftests/alsa/pcm-test.c b/tools/testing/selftests/alsa/pcm-test.c index de664dedb541..dbd7c222ce93 100644 --- a/tools/testing/selftests/alsa/pcm-test.c +++ b/tools/testing/selftests/alsa/pcm-test.c @@ -24,6 +24,8 @@ typedef struct timespec timestamp_t; struct card_data { int card; + snd_ctl_card_info_t *info; + const char *name; pthread_t thread; struct card_data *next; }; @@ -35,6 +37,7 @@ struct pcm_data { int card; int device; int subdevice; + const char *card_name; snd_pcm_stream_t stream; snd_config_t *pcm_config; struct pcm_data *next; @@ -167,6 +170,10 @@ static void find_pcms(void) config = get_alsalib_config(); while (card >= 0) { + card_data = calloc(1, sizeof(*card_data)); + if (!card_data) + ksft_exit_fail_msg("Out of memory\n"); + sprintf(name, "hw:%d", card); err = snd_ctl_open_lconf(&handle, name, 0, config); @@ -182,14 +189,29 @@ static void find_pcms(void) err = snd_card_get_longname(card, &card_longname); if (err != 0) card_longname = "Unknown"; - ksft_print_msg("Card %d - %s (%s)\n", card, - card_name, card_longname); + + 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(handle, card_data->info); + if (err == 0) { + card_data->name = snd_ctl_card_info_get_id(card_data->info); + if (!card_data->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->name) + card_data->name = "Unknown"; + + ksft_print_msg("Card %d/%s - %s (%s)\n", card, + card_data->name, card_name, card_longname); card_config = conf_by_card(card); - card_data = calloc(1, sizeof(*card_data)); - if (!card_data) - ksft_exit_fail_msg("Out of memory\n"); card_data->card = card; card_data->next = card_list; card_list = card_data; @@ -218,6 +240,10 @@ static void find_pcms(void) if (err < 0) ksft_exit_fail_msg("snd_ctl_pcm_info: %d:%d:%d\n", dev, 0, stream); + + ksft_print_msg("%s.0 - %s\n", card_data->name, + snd_pcm_info_get_id(pcm_info)); + count = snd_pcm_info_get_subdevices_count(pcm_info); for (subdev = 0; subdev < count; subdev++) { sprintf(key, "pcm.%d.%d.%s", dev, subdev, snd_pcm_stream_name(stream)); @@ -232,6 +258,7 @@ static void find_pcms(void) pcm_data->card = card; pcm_data->device = dev; pcm_data->subdevice = subdev; + pcm_data->card_name = card_data->name; pcm_data->stream = stream; pcm_data->pcm_config = conf_get_subtree(card_config, key, NULL); pcm_data->next = pcm_list; @@ -294,9 +321,9 @@ static void test_pcm_time(struct pcm_data *data, enum test_class class, desc = conf_get_string(pcm_cfg, "description", NULL, NULL); if (desc) - ksft_print_msg("%s.%s.%d.%d.%d.%s - %s\n", + ksft_print_msg("%s.%s.%s.%d.%d.%s - %s\n", test_class_name, test_name, - data->card, data->device, data->subdevice, + data->card_name, data->device, data->subdevice, snd_pcm_stream_name(data->stream), desc); @@ -352,9 +379,9 @@ __format: old_format = format; format = snd_pcm_format_value(alt_formats[i]); if (format != SND_PCM_FORMAT_UNKNOWN) { - ksft_print_msg("%s.%d.%d.%d.%s.%s format %s -> %s\n", + ksft_print_msg("%s.%s.%d.%d.%s.%s format %s -> %s\n", test_name, - data->card, data->device, data->subdevice, + data->card_name, data->device, data->subdevice, snd_pcm_stream_name(data->stream), snd_pcm_access_name(access), snd_pcm_format_name(old_format), @@ -383,7 +410,7 @@ __format: goto __close; } if (rrate != rate) { - snprintf(msg, sizeof(msg), "rate mismatch %ld != %d", rate, rrate); + snprintf(msg, sizeof(msg), "rate mismatch %ld != %u", rate, rrate); goto __close; } rperiod_size = period_size; @@ -430,9 +457,9 @@ __format: goto __close; } - ksft_print_msg("%s.%s.%d.%d.%d.%s hw_params.%s.%s.%ld.%ld.%ld.%ld sw_params.%ld\n", + ksft_print_msg("%s.%s.%s.%d.%d.%s hw_params.%s.%s.%ld.%ld.%ld.%ld sw_params.%ld\n", test_class_name, test_name, - data->card, data->device, data->subdevice, + data->card_name, data->device, data->subdevice, snd_pcm_stream_name(data->stream), snd_pcm_access_name(access), snd_pcm_format_name(format), @@ -491,9 +518,10 @@ __close: * Anything specified as specific to this system * should always be supported. */ - ksft_test_result(!skip, "%s.%s.%d.%d.%d.%s.params\n", + ksft_test_result(!skip, "%s.%s.%s.%d.%d.%s.params\n", test_class_name, test_name, - data->card, data->device, data->subdevice, + data->card_name, data->device, + data->subdevice, snd_pcm_stream_name(data->stream)); break; default: @@ -501,14 +529,16 @@ __close: } if (!skip) - ksft_test_result(pass, "%s.%s.%d.%d.%d.%s\n", + ksft_test_result(pass, "%s.%s.%s.%d.%d.%s\n", test_class_name, test_name, - data->card, data->device, data->subdevice, + data->card_name, data->device, + data->subdevice, snd_pcm_stream_name(data->stream)); else - ksft_test_result_skip("%s.%s.%d.%d.%d.%s\n", + ksft_test_result_skip("%s.%s.%s.%d.%d.%s\n", test_class_name, test_name, - data->card, data->device, data->subdevice, + data->card_name, data->device, + data->subdevice, snd_pcm_stream_name(data->stream)); if (msg[0]) @@ -609,8 +639,8 @@ int main(void) conf->filename, conf->config_id); for (pcm = pcm_missing; pcm != NULL; pcm = pcm->next) { - ksft_test_result(false, "test.missing.%d.%d.%d.%s\n", - pcm->card, pcm->device, pcm->subdevice, + ksft_test_result(false, "test.missing.%s.%d.%d.%s\n", + pcm->card_name, pcm->device, pcm->subdevice, snd_pcm_stream_name(pcm->stream)); } |