ALSA: usb-audio: Handle discrete rates properly in hw constraints
authorTakashi Iwai <tiwai@suse.de>
Mon, 23 Nov 2020 08:53:07 +0000 (09:53 +0100)
committerTakashi Iwai <tiwai@suse.de>
Mon, 23 Nov 2020 14:11:02 +0000 (15:11 +0100)
commitbc4e94aa8e72e79598e63a0b73febdcd8aeb541f
tree7d8a4f198a5b0957c4dc1d848994addd1d7a5ccd
parent418baf2c28f3473039f2f7377760bd8f6897ae18
ALSA: usb-audio: Handle discrete rates properly in hw constraints

In the current code, when the device provides the discrete sample rate
tables with unusual sample rates, the driver tries to gather the whole
values from the audioformat entries and create a hw-constraint rule to
restrict with this single rate list.  This is rather inefficient and
may overlook the rates that are associated only with the certain
audioformat entries.

This patch improves the hw constraint setup by rewriting the existing
hw_rule_rate().  The discrete sample rates (identified by rate_table
and nr_rates of format entry) are checked in the existing
hw_rule_rate() instead of extra rules; in the case of discrete rates,
the function compares with each rate table entry and calculates the
min/max values from there.  For the contiguous rates, the behavior
doesn't change.

Along with it, snd_usb_pcm_check_knot() and snb_usb_substream
rate_list field become superfluous, thus those are dropped.

Tested-by: Keith Milner <kamilner@superlative.org>
Tested-by: Dylan Robinson <dylan_robinson@motu.com>
Link: https://lore.kernel.org/r/20201123085347.19667-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/card.h
sound/usb/pcm.c
sound/usb/stream.c