blob: 11a85e66aa96de6992cf08909d80947a38ab0141 [file] [log] [blame]
Takashi Iwai9fddc152020-11-23 09:53:43 +01001// SPDX-License-Identifier: GPL-2.0-or-later
2//
3// Special handling for implicit feedback mode
4//
5
6#include <linux/init.h>
7#include <linux/usb.h>
8#include <linux/usb/audio.h>
9#include <linux/usb/audio-v2.h>
10
11#include <sound/core.h>
12#include <sound/pcm.h>
13#include <sound/pcm_params.h>
14
15#include "usbaudio.h"
16#include "card.h"
17#include "helper.h"
18#include "implicit.h"
19
20enum {
21 IMPLICIT_FB_NONE,
Takashi Iwai83b7dcb2020-11-23 09:53:44 +010022 IMPLICIT_FB_GENERIC,
Takashi Iwai9fddc152020-11-23 09:53:43 +010023 IMPLICIT_FB_FIXED,
24};
25
26struct snd_usb_implicit_fb_match {
27 unsigned int id;
28 unsigned int iface_class;
29 unsigned int ep_num;
30 unsigned int iface;
31 int type;
32};
33
Takashi Iwai83b7dcb2020-11-23 09:53:44 +010034#define IMPLICIT_FB_GENERIC_DEV(vend, prod) \
35 { .id = USB_ID(vend, prod), .type = IMPLICIT_FB_GENERIC }
Takashi Iwai9fddc152020-11-23 09:53:43 +010036#define IMPLICIT_FB_FIXED_DEV(vend, prod, ep, ifnum) \
37 { .id = USB_ID(vend, prod), .type = IMPLICIT_FB_FIXED, .ep_num = (ep),\
38 .iface = (ifnum) }
39#define IMPLICIT_FB_SKIP_DEV(vend, prod) \
40 { .id = USB_ID(vend, prod), .type = IMPLICIT_FB_NONE }
41
42/* Implicit feedback quirk table for playback */
43static const struct snd_usb_implicit_fb_match playback_implicit_fb_quirks[] = {
Takashi Iwai83b7dcb2020-11-23 09:53:44 +010044 /* Generic matching */
Takashi Iwaic9a867f2020-12-09 17:18:35 +010045 IMPLICIT_FB_GENERIC_DEV(0x0499, 0x1509), /* Steinberg UR22 */
Takashi Iwai83b7dcb2020-11-23 09:53:44 +010046 IMPLICIT_FB_GENERIC_DEV(0x0763, 0x2080), /* M-Audio FastTrack Ultra */
47 IMPLICIT_FB_GENERIC_DEV(0x0763, 0x2081), /* M-Audio FastTrack Ultra */
48 IMPLICIT_FB_GENERIC_DEV(0x0763, 0x2030), /* M-Audio Fast Track C400 */
49 IMPLICIT_FB_GENERIC_DEV(0x0763, 0x2031), /* M-Audio Fast Track C600 */
50
Takashi Iwai9fddc152020-11-23 09:53:43 +010051 /* Fixed EP */
Takashi Iwai83b7dcb2020-11-23 09:53:44 +010052 /* FIXME: check the availability of generic matching */
Takashi Iwai9fddc152020-11-23 09:53:43 +010053 IMPLICIT_FB_FIXED_DEV(0x1397, 0x0001, 0x81, 1), /* Behringer UFX1604 */
54 IMPLICIT_FB_FIXED_DEV(0x1397, 0x0002, 0x81, 1), /* Behringer UFX1204 */
Takashi Iwai9fddc152020-11-23 09:53:43 +010055 IMPLICIT_FB_FIXED_DEV(0x2466, 0x8010, 0x81, 2), /* Fractal Audio Axe-Fx III */
Takashi Iwai9fddc152020-11-23 09:53:43 +010056 IMPLICIT_FB_FIXED_DEV(0x31e9, 0x0001, 0x81, 2), /* Solid State Logic SSL2 */
57 IMPLICIT_FB_FIXED_DEV(0x31e9, 0x0002, 0x81, 2), /* Solid State Logic SSL2+ */
58 IMPLICIT_FB_FIXED_DEV(0x0499, 0x172f, 0x81, 2), /* Steinberg UR22C */
59 IMPLICIT_FB_FIXED_DEV(0x0d9a, 0x00df, 0x81, 2), /* RTX6001 */
Takashi Iwai9fddc152020-11-23 09:53:43 +010060 IMPLICIT_FB_FIXED_DEV(0x22f0, 0x0006, 0x81, 3), /* Allen&Heath Qu-16 */
Takashi Iwai9fddc152020-11-23 09:53:43 +010061 IMPLICIT_FB_FIXED_DEV(0x1686, 0xf029, 0x82, 2), /* Zoom UAC-2 */
62 IMPLICIT_FB_FIXED_DEV(0x2466, 0x8003, 0x86, 2), /* Fractal Audio Axe-Fx II */
63 IMPLICIT_FB_FIXED_DEV(0x0499, 0x172a, 0x86, 2), /* Yamaha MODX */
64
65 /* Special matching */
66 { .id = USB_ID(0x07fd, 0x0004), .iface_class = USB_CLASS_AUDIO,
67 .type = IMPLICIT_FB_NONE }, /* MicroBook IIc */
68 /* ep = 0x84, ifnum = 0 */
69 { .id = USB_ID(0x07fd, 0x0004), .iface_class = USB_CLASS_VENDOR_SPEC,
70 .type = IMPLICIT_FB_FIXED,
71 .ep_num = 0x84, .iface = 0 }, /* MOTU MicroBook II */
72
Takashi Iwai9fddc152020-11-23 09:53:43 +010073 /* No quirk for playback but with capture quirk (see below) */
Takashi Iwaiad0e6a32020-11-23 09:53:46 +010074 IMPLICIT_FB_SKIP_DEV(0x0582, 0x0130), /* BOSS BR-80 */
Timon Reinoldb0e13062021-01-02 22:08:35 +010075 IMPLICIT_FB_SKIP_DEV(0x0582, 0x0171), /* BOSS RC-505 */
Takashi Iwai15447b62021-02-14 16:42:51 +010076 IMPLICIT_FB_SKIP_DEV(0x0582, 0x0185), /* BOSS GP-10 */
Takashi Iwaiad0e6a32020-11-23 09:53:46 +010077 IMPLICIT_FB_SKIP_DEV(0x0582, 0x0189), /* BOSS GT-100v2 */
Mike Oliphant43877222020-12-21 13:55:33 -080078 IMPLICIT_FB_SKIP_DEV(0x0582, 0x01d6), /* BOSS GT-1 */
Takashi Iwaiad0e6a32020-11-23 09:53:46 +010079 IMPLICIT_FB_SKIP_DEV(0x0582, 0x01d8), /* BOSS Katana */
Takashi Iwai9fddc152020-11-23 09:53:43 +010080 IMPLICIT_FB_SKIP_DEV(0x0582, 0x01e5), /* BOSS GT-001 */
Takashi Iwai3deba4d2020-12-29 09:34:28 +010081 IMPLICIT_FB_SKIP_DEV(0x0582, 0x0203), /* BOSS AD-10 */
Takashi Iwai9fddc152020-11-23 09:53:43 +010082
83 {} /* terminator */
84};
85
Takashi Iwai83b7dcb2020-11-23 09:53:44 +010086/* Implicit feedback quirk table for capture: only FIXED type */
Takashi Iwai9fddc152020-11-23 09:53:43 +010087static const struct snd_usb_implicit_fb_match capture_implicit_fb_quirks[] = {
Takashi Iwaiad0e6a32020-11-23 09:53:46 +010088 IMPLICIT_FB_FIXED_DEV(0x0582, 0x0130, 0x0d, 0x01), /* BOSS BR-80 */
Timon Reinoldb0e13062021-01-02 22:08:35 +010089 IMPLICIT_FB_FIXED_DEV(0x0582, 0x0171, 0x0d, 0x01), /* BOSS RC-505 */
Takashi Iwai15447b62021-02-14 16:42:51 +010090 IMPLICIT_FB_FIXED_DEV(0x0582, 0x0185, 0x0d, 0x01), /* BOSS GP-10 */
Takashi Iwaiad0e6a32020-11-23 09:53:46 +010091 IMPLICIT_FB_FIXED_DEV(0x0582, 0x0189, 0x0d, 0x01), /* BOSS GT-100v2 */
Mike Oliphant43877222020-12-21 13:55:33 -080092 IMPLICIT_FB_FIXED_DEV(0x0582, 0x01d6, 0x0d, 0x01), /* BOSS GT-1 */
Takashi Iwaiad0e6a32020-11-23 09:53:46 +010093 IMPLICIT_FB_FIXED_DEV(0x0582, 0x01d8, 0x0d, 0x01), /* BOSS Katana */
Takashi Iwai9fddc152020-11-23 09:53:43 +010094 IMPLICIT_FB_FIXED_DEV(0x0582, 0x01e5, 0x0d, 0x01), /* BOSS GT-001 */
Takashi Iwai3deba4d2020-12-29 09:34:28 +010095 IMPLICIT_FB_FIXED_DEV(0x0582, 0x0203, 0x0d, 0x01), /* BOSS AD-10 */
Takashi Iwai9fddc152020-11-23 09:53:43 +010096
97 {} /* terminator */
98};
99
100/* set up sync EP information on the audioformat */
101static int add_implicit_fb_sync_ep(struct snd_usb_audio *chip,
102 struct audioformat *fmt,
Takashi Iwai167c9dc2021-01-08 08:52:19 +0100103 int ep, int ep_idx, int ifnum,
Takashi Iwai9fddc152020-11-23 09:53:43 +0100104 const struct usb_host_interface *alts)
105{
106 struct usb_interface *iface;
107
108 if (!alts) {
109 iface = usb_ifnum_to_if(chip->dev, ifnum);
110 if (!iface || iface->num_altsetting < 2)
111 return 0;
112 alts = &iface->altsetting[1];
113 }
114
115 fmt->sync_ep = ep;
116 fmt->sync_iface = ifnum;
117 fmt->sync_altsetting = alts->desc.bAlternateSetting;
Takashi Iwai167c9dc2021-01-08 08:52:19 +0100118 fmt->sync_ep_idx = ep_idx;
Takashi Iwai9fddc152020-11-23 09:53:43 +0100119 fmt->implicit_fb = 1;
120 usb_audio_dbg(chip,
121 "%d:%d: added %s implicit_fb sync_ep %x, iface %d:%d\n",
122 fmt->iface, fmt->altsetting,
123 (ep & USB_DIR_IN) ? "playback" : "capture",
124 fmt->sync_ep, fmt->sync_iface, fmt->sync_altsetting);
125 return 1;
126}
127
128/* Check whether the given UAC2 iface:altset points to an implicit fb source */
129static int add_generic_uac2_implicit_fb(struct snd_usb_audio *chip,
130 struct audioformat *fmt,
131 unsigned int ifnum,
132 unsigned int altsetting)
133{
134 struct usb_host_interface *alts;
135 struct usb_endpoint_descriptor *epd;
136
137 alts = snd_usb_get_host_interface(chip, ifnum, altsetting);
138 if (!alts)
139 return 0;
140 if (alts->desc.bInterfaceClass != USB_CLASS_AUDIO ||
141 alts->desc.bInterfaceSubClass != USB_SUBCLASS_AUDIOSTREAMING ||
142 alts->desc.bInterfaceProtocol != UAC_VERSION_2 ||
143 alts->desc.bNumEndpoints < 1)
144 return 0;
145 epd = get_endpoint(alts, 0);
146 if (!usb_endpoint_is_isoc_in(epd) ||
147 (epd->bmAttributes & USB_ENDPOINT_USAGE_MASK) !=
148 USB_ENDPOINT_USAGE_IMPLICIT_FB)
149 return 0;
Takashi Iwai167c9dc2021-01-08 08:52:19 +0100150 return add_implicit_fb_sync_ep(chip, fmt, epd->bEndpointAddress, 0,
Takashi Iwai9fddc152020-11-23 09:53:43 +0100151 ifnum, alts);
152}
153
154/* Like the function above, but specific to Roland with vendor class and hack */
155static int add_roland_implicit_fb(struct snd_usb_audio *chip,
156 struct audioformat *fmt,
157 unsigned int ifnum,
158 unsigned int altsetting)
159{
160 struct usb_host_interface *alts;
161 struct usb_endpoint_descriptor *epd;
162
163 alts = snd_usb_get_host_interface(chip, ifnum, altsetting);
164 if (!alts)
165 return 0;
166 if (alts->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC ||
167 (alts->desc.bInterfaceSubClass != 2 &&
168 alts->desc.bInterfaceProtocol != 2) ||
169 alts->desc.bNumEndpoints < 1)
170 return 0;
171 epd = get_endpoint(alts, 0);
172 if (!usb_endpoint_is_isoc_in(epd) ||
173 (epd->bmAttributes & USB_ENDPOINT_USAGE_MASK) !=
174 USB_ENDPOINT_USAGE_IMPLICIT_FB)
175 return 0;
Takashi Iwai167c9dc2021-01-08 08:52:19 +0100176 return add_implicit_fb_sync_ep(chip, fmt, epd->bEndpointAddress, 0,
Takashi Iwai9fddc152020-11-23 09:53:43 +0100177 ifnum, alts);
178}
179
Takashi Iwai532a2082021-01-18 08:58:16 +0100180/* Playback and capture EPs on Pioneer devices share the same iface/altset,
181 * but they don't seem working with the implicit fb mode well, hence we
182 * just return as if the sync were already set up.
Takashi Iwai167c9dc2021-01-08 08:52:19 +0100183 */
Takashi Iwai532a2082021-01-18 08:58:16 +0100184static int skip_pioneer_sync_ep(struct snd_usb_audio *chip,
185 struct audioformat *fmt,
186 struct usb_host_interface *alts)
Takashi Iwai167c9dc2021-01-08 08:52:19 +0100187{
188 struct usb_endpoint_descriptor *epd;
189
190 if (alts->desc.bNumEndpoints != 2)
191 return 0;
192
193 epd = get_endpoint(alts, 1);
194 if (!usb_endpoint_is_isoc_in(epd) ||
195 (epd->bmAttributes & USB_ENDPOINT_SYNCTYPE) != USB_ENDPOINT_SYNC_ASYNC ||
196 ((epd->bmAttributes & USB_ENDPOINT_USAGE_MASK) !=
197 USB_ENDPOINT_USAGE_DATA &&
198 (epd->bmAttributes & USB_ENDPOINT_USAGE_MASK) !=
199 USB_ENDPOINT_USAGE_IMPLICIT_FB))
200 return 0;
Takashi Iwai532a2082021-01-18 08:58:16 +0100201 return 1; /* don't handle with the implicit fb, just skip sync EP */
Takashi Iwai167c9dc2021-01-08 08:52:19 +0100202}
Takashi Iwai83b7dcb2020-11-23 09:53:44 +0100203
204static int __add_generic_implicit_fb(struct snd_usb_audio *chip,
205 struct audioformat *fmt,
206 int iface, int altset)
207{
208 struct usb_host_interface *alts;
209 struct usb_endpoint_descriptor *epd;
210
211 alts = snd_usb_get_host_interface(chip, iface, altset);
212 if (!alts)
213 return 0;
214
215 if ((alts->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC &&
216 alts->desc.bInterfaceClass != USB_CLASS_AUDIO) ||
217 alts->desc.bNumEndpoints < 1)
218 return 0;
219 epd = get_endpoint(alts, 0);
220 if (!usb_endpoint_is_isoc_in(epd) ||
221 (epd->bmAttributes & USB_ENDPOINT_SYNCTYPE) != USB_ENDPOINT_SYNC_ASYNC)
222 return 0;
Takashi Iwai167c9dc2021-01-08 08:52:19 +0100223 return add_implicit_fb_sync_ep(chip, fmt, epd->bEndpointAddress, 0,
Takashi Iwai83b7dcb2020-11-23 09:53:44 +0100224 iface, alts);
225}
226
227/* More generic quirk: look for the sync EP next to the data EP */
228static int add_generic_implicit_fb(struct snd_usb_audio *chip,
229 struct audioformat *fmt,
230 struct usb_host_interface *alts)
231{
232 if ((fmt->ep_attr & USB_ENDPOINT_SYNCTYPE) != USB_ENDPOINT_SYNC_ASYNC)
233 return 0;
234
235 if (__add_generic_implicit_fb(chip, fmt,
236 alts->desc.bInterfaceNumber + 1,
237 alts->desc.bAlternateSetting))
238 return 1;
239 return __add_generic_implicit_fb(chip, fmt,
240 alts->desc.bInterfaceNumber - 1,
241 alts->desc.bAlternateSetting);
242}
243
Takashi Iwai9fddc152020-11-23 09:53:43 +0100244static const struct snd_usb_implicit_fb_match *
245find_implicit_fb_entry(struct snd_usb_audio *chip,
246 const struct snd_usb_implicit_fb_match *match,
247 const struct usb_host_interface *alts)
248{
249 for (; match->id; match++)
250 if (match->id == chip->usb_id &&
251 (!match->iface_class ||
252 (alts->desc.bInterfaceClass == match->iface_class)))
253 return match;
254
255 return NULL;
256}
257
258/* Setup an implicit feedback endpoint from a quirk. Returns 0 if no quirk
259 * applies. Returns 1 if a quirk was found.
260 */
261static int audioformat_implicit_fb_quirk(struct snd_usb_audio *chip,
262 struct audioformat *fmt,
263 struct usb_host_interface *alts)
264{
265 const struct snd_usb_implicit_fb_match *p;
266 unsigned int attr = fmt->ep_attr & USB_ENDPOINT_SYNCTYPE;
267
268 p = find_implicit_fb_entry(chip, playback_implicit_fb_quirks, alts);
269 if (p) {
270 switch (p->type) {
Takashi Iwai83b7dcb2020-11-23 09:53:44 +0100271 case IMPLICIT_FB_GENERIC:
272 return add_generic_implicit_fb(chip, fmt, alts);
Takashi Iwai9fddc152020-11-23 09:53:43 +0100273 case IMPLICIT_FB_NONE:
274 return 0; /* No quirk */
275 case IMPLICIT_FB_FIXED:
Takashi Iwai167c9dc2021-01-08 08:52:19 +0100276 return add_implicit_fb_sync_ep(chip, fmt, p->ep_num, 0,
Takashi Iwai9fddc152020-11-23 09:53:43 +0100277 p->iface, NULL);
278 }
279 }
280
281 /* Generic UAC2 implicit feedback */
282 if (attr == USB_ENDPOINT_SYNC_ASYNC &&
283 alts->desc.bInterfaceClass == USB_CLASS_AUDIO &&
284 alts->desc.bInterfaceProtocol == UAC_VERSION_2 &&
285 alts->desc.bNumEndpoints == 1) {
286 if (add_generic_uac2_implicit_fb(chip, fmt,
287 alts->desc.bInterfaceNumber + 1,
288 alts->desc.bAlternateSetting))
289 return 1;
290 }
291
292 /* Roland/BOSS implicit feedback with vendor spec class */
293 if (attr == USB_ENDPOINT_SYNC_ASYNC &&
294 alts->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC &&
295 alts->desc.bInterfaceProtocol == 2 &&
296 alts->desc.bNumEndpoints == 1 &&
297 USB_ID_VENDOR(chip->usb_id) == 0x0582 /* Roland */) {
298 if (add_roland_implicit_fb(chip, fmt,
299 alts->desc.bInterfaceNumber + 1,
300 alts->desc.bAlternateSetting))
301 return 1;
302 }
303
Takashi Iwai532a2082021-01-18 08:58:16 +0100304 /* Pioneer devices with vendor spec class */
Takashi Iwai167c9dc2021-01-08 08:52:19 +0100305 if (attr == USB_ENDPOINT_SYNC_ASYNC &&
306 alts->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC &&
Olivia Mackintoshb952ac72021-01-18 13:06:21 +0000307 (USB_ID_VENDOR(chip->usb_id) == 0x2b73 || /* Pioneer */
308 USB_ID_VENDOR(chip->usb_id) == 0x08e4 /* Pioneer */)) {
Takashi Iwai532a2082021-01-18 08:58:16 +0100309 if (skip_pioneer_sync_ep(chip, fmt, alts))
Takashi Iwai167c9dc2021-01-08 08:52:19 +0100310 return 1;
311 }
312
Takashi Iwai62abd092020-11-23 09:53:45 +0100313 /* Try the generic implicit fb if available */
314 if (chip->generic_implicit_fb)
315 return add_generic_implicit_fb(chip, fmt, alts);
316
Takashi Iwai9fddc152020-11-23 09:53:43 +0100317 /* No quirk */
318 return 0;
319}
320
321/* same for capture, but only handling FIXED entry */
322static int audioformat_capture_quirk(struct snd_usb_audio *chip,
323 struct audioformat *fmt,
324 struct usb_host_interface *alts)
325{
326 const struct snd_usb_implicit_fb_match *p;
327
328 p = find_implicit_fb_entry(chip, capture_implicit_fb_quirks, alts);
329 if (p && p->type == IMPLICIT_FB_FIXED)
Takashi Iwai167c9dc2021-01-08 08:52:19 +0100330 return add_implicit_fb_sync_ep(chip, fmt, p->ep_num, 0,
331 p->iface, NULL);
Takashi Iwai9fddc152020-11-23 09:53:43 +0100332 return 0;
333}
334
335/*
336 * Parse altset and set up implicit feedback endpoint on the audioformat
337 */
338int snd_usb_parse_implicit_fb_quirk(struct snd_usb_audio *chip,
339 struct audioformat *fmt,
340 struct usb_host_interface *alts)
341{
342 if (fmt->endpoint & USB_DIR_IN)
343 return audioformat_capture_quirk(chip, fmt, alts);
344 else
345 return audioformat_implicit_fb_quirk(chip, fmt, alts);
346}
347
348/*
349 * Return the score of matching two audioformats.
350 * Veto the audioformat if:
351 * - It has no channels for some reason.
352 * - Requested PCM format is not supported.
353 * - Requested sample rate is not supported.
354 */
355static int match_endpoint_audioformats(struct snd_usb_substream *subs,
356 const struct audioformat *fp,
357 int rate, int channels,
358 snd_pcm_format_t pcm_format)
359{
360 int i, score;
361
362 if (fp->channels < 1)
363 return 0;
364
365 if (!(fp->formats & pcm_format_to_bits(pcm_format)))
366 return 0;
367
368 if (fp->rates & SNDRV_PCM_RATE_CONTINUOUS) {
369 if (rate < fp->rate_min || rate > fp->rate_max)
370 return 0;
371 } else {
372 for (i = 0; i < fp->nr_rates; i++) {
373 if (fp->rate_table[i] == rate)
374 break;
375 }
376 if (i >= fp->nr_rates)
377 return 0;
378 }
379
380 score = 1;
381 if (fp->channels == channels)
382 score++;
383
384 return score;
385}
386
387static struct snd_usb_substream *
388find_matching_substream(struct snd_usb_audio *chip, int stream, int ep_num,
389 int fmt_type)
390{
391 struct snd_usb_stream *as;
392 struct snd_usb_substream *subs;
393
394 list_for_each_entry(as, &chip->pcm_list, list) {
395 subs = &as->substream[stream];
396 if (as->fmt_type == fmt_type && subs->ep_num == ep_num)
397 return subs;
398 }
399
400 return NULL;
401}
402
403/*
404 * Return the audioformat that is suitable for the implicit fb
405 */
406const struct audioformat *
407snd_usb_find_implicit_fb_sync_format(struct snd_usb_audio *chip,
408 const struct audioformat *target,
409 const struct snd_pcm_hw_params *params,
410 int stream)
411{
412 struct snd_usb_substream *subs;
Takashi Iwai5d15f1e2021-01-08 08:52:16 +0100413 const struct audioformat *fp, *sync_fmt = NULL;
Takashi Iwai9fddc152020-11-23 09:53:43 +0100414 int score, high_score;
415
Takashi Iwai5d15f1e2021-01-08 08:52:16 +0100416 /* Use the original audioformat as fallback for the shared altset */
Takashi Iwai9fddc152020-11-23 09:53:43 +0100417 if (target->iface == target->sync_iface &&
418 target->altsetting == target->sync_altsetting)
Takashi Iwai5d15f1e2021-01-08 08:52:16 +0100419 sync_fmt = target;
Takashi Iwai9fddc152020-11-23 09:53:43 +0100420
421 subs = find_matching_substream(chip, stream, target->sync_ep,
422 target->fmt_type);
423 if (!subs)
Takashi Iwai5d15f1e2021-01-08 08:52:16 +0100424 return sync_fmt;
Takashi Iwai9fddc152020-11-23 09:53:43 +0100425
Takashi Iwai9fddc152020-11-23 09:53:43 +0100426 high_score = 0;
427 list_for_each_entry(fp, &subs->fmt_list, list) {
428 score = match_endpoint_audioformats(subs, fp,
429 params_rate(params),
430 params_channels(params),
431 params_format(params));
432 if (score > high_score) {
433 sync_fmt = fp;
434 high_score = score;
435 }
436 }
437
438 return sync_fmt;
439}
440