2020-11-23 16:53:43 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
//
|
|
|
|
// Special handling for implicit feedback mode
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/usb.h>
|
|
|
|
#include <linux/usb/audio.h>
|
|
|
|
#include <linux/usb/audio-v2.h>
|
|
|
|
|
|
|
|
#include <sound/core.h>
|
|
|
|
#include <sound/pcm.h>
|
|
|
|
#include <sound/pcm_params.h>
|
|
|
|
|
|
|
|
#include "usbaudio.h"
|
|
|
|
#include "card.h"
|
|
|
|
#include "helper.h"
|
|
|
|
#include "implicit.h"
|
|
|
|
|
|
|
|
enum {
|
|
|
|
IMPLICIT_FB_NONE,
|
2020-11-23 16:53:44 +08:00
|
|
|
IMPLICIT_FB_GENERIC,
|
2020-11-23 16:53:43 +08:00
|
|
|
IMPLICIT_FB_FIXED,
|
ALSA: usb-audio: Apply implicit feedback mode for BOSS devices
During the recent rewrite of the implicit feedback support, we've
tested to apply the implicit fb on BOSS devices, but it failed, as the
capture stream didn't start without the playback. As the end result,
it got another type of quirk for tying both streams but starts
playback always (commit 6234fdc1cede "ALSA: usb-audio: Quirk for BOSS
GT-001").
Meanwhile, Mike Oliphant has tested the real implicit feedback mode
for the playback again with the latest code, and found out that it
actually works if the initial feedback sync is skipped; that is, on
those BOSS devices, the playback stream has to be started at first
without waiting for the capture URB completions. Otherwise it gets
stuck. In the rest operations after the capture stream processed, we
can take them as the implicit feedback source.
This patch is an attempt to improve the support for BOSS devices with
the implicit feedback mode in the way described above. It adds a new
flag to snd_usb_audio, playback_first, indicating that the playback
stream starts without sync with the initial capture completion. This
flag is set in the quirk table with the new IMPLICIT_FB_BOTH type.
Reported-and-tested-by: Mike Oliphant <oliphant@nostatic.org>
Link: https://lore.kernel.org/r/20210414083255.9527-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-04-14 16:32:55 +08:00
|
|
|
IMPLICIT_FB_BOTH, /* generic playback + capture (for BOSS) */
|
2020-11-23 16:53:43 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct snd_usb_implicit_fb_match {
|
|
|
|
unsigned int id;
|
|
|
|
unsigned int iface_class;
|
|
|
|
unsigned int ep_num;
|
|
|
|
unsigned int iface;
|
|
|
|
int type;
|
|
|
|
};
|
|
|
|
|
2020-11-23 16:53:44 +08:00
|
|
|
#define IMPLICIT_FB_GENERIC_DEV(vend, prod) \
|
|
|
|
{ .id = USB_ID(vend, prod), .type = IMPLICIT_FB_GENERIC }
|
2020-11-23 16:53:43 +08:00
|
|
|
#define IMPLICIT_FB_FIXED_DEV(vend, prod, ep, ifnum) \
|
|
|
|
{ .id = USB_ID(vend, prod), .type = IMPLICIT_FB_FIXED, .ep_num = (ep),\
|
|
|
|
.iface = (ifnum) }
|
ALSA: usb-audio: Apply implicit feedback mode for BOSS devices
During the recent rewrite of the implicit feedback support, we've
tested to apply the implicit fb on BOSS devices, but it failed, as the
capture stream didn't start without the playback. As the end result,
it got another type of quirk for tying both streams but starts
playback always (commit 6234fdc1cede "ALSA: usb-audio: Quirk for BOSS
GT-001").
Meanwhile, Mike Oliphant has tested the real implicit feedback mode
for the playback again with the latest code, and found out that it
actually works if the initial feedback sync is skipped; that is, on
those BOSS devices, the playback stream has to be started at first
without waiting for the capture URB completions. Otherwise it gets
stuck. In the rest operations after the capture stream processed, we
can take them as the implicit feedback source.
This patch is an attempt to improve the support for BOSS devices with
the implicit feedback mode in the way described above. It adds a new
flag to snd_usb_audio, playback_first, indicating that the playback
stream starts without sync with the initial capture completion. This
flag is set in the quirk table with the new IMPLICIT_FB_BOTH type.
Reported-and-tested-by: Mike Oliphant <oliphant@nostatic.org>
Link: https://lore.kernel.org/r/20210414083255.9527-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-04-14 16:32:55 +08:00
|
|
|
#define IMPLICIT_FB_BOTH_DEV(vend, prod, ep, ifnum) \
|
|
|
|
{ .id = USB_ID(vend, prod), .type = IMPLICIT_FB_BOTH, .ep_num = (ep),\
|
|
|
|
.iface = (ifnum) }
|
2020-11-23 16:53:43 +08:00
|
|
|
#define IMPLICIT_FB_SKIP_DEV(vend, prod) \
|
|
|
|
{ .id = USB_ID(vend, prod), .type = IMPLICIT_FB_NONE }
|
|
|
|
|
|
|
|
/* Implicit feedback quirk table for playback */
|
|
|
|
static const struct snd_usb_implicit_fb_match playback_implicit_fb_quirks[] = {
|
2020-11-23 16:53:44 +08:00
|
|
|
/* Generic matching */
|
2020-12-10 00:18:35 +08:00
|
|
|
IMPLICIT_FB_GENERIC_DEV(0x0499, 0x1509), /* Steinberg UR22 */
|
2020-11-23 16:53:44 +08:00
|
|
|
IMPLICIT_FB_GENERIC_DEV(0x0763, 0x2080), /* M-Audio FastTrack Ultra */
|
|
|
|
IMPLICIT_FB_GENERIC_DEV(0x0763, 0x2081), /* M-Audio FastTrack Ultra */
|
|
|
|
IMPLICIT_FB_GENERIC_DEV(0x0763, 0x2030), /* M-Audio Fast Track C400 */
|
|
|
|
IMPLICIT_FB_GENERIC_DEV(0x0763, 0x2031), /* M-Audio Fast Track C600 */
|
|
|
|
|
2020-11-23 16:53:43 +08:00
|
|
|
/* Fixed EP */
|
2020-11-23 16:53:44 +08:00
|
|
|
/* FIXME: check the availability of generic matching */
|
2020-11-23 16:53:43 +08:00
|
|
|
IMPLICIT_FB_FIXED_DEV(0x1397, 0x0001, 0x81, 1), /* Behringer UFX1604 */
|
|
|
|
IMPLICIT_FB_FIXED_DEV(0x1397, 0x0002, 0x81, 1), /* Behringer UFX1204 */
|
|
|
|
IMPLICIT_FB_FIXED_DEV(0x2466, 0x8010, 0x81, 2), /* Fractal Audio Axe-Fx III */
|
|
|
|
IMPLICIT_FB_FIXED_DEV(0x31e9, 0x0001, 0x81, 2), /* Solid State Logic SSL2 */
|
|
|
|
IMPLICIT_FB_FIXED_DEV(0x31e9, 0x0002, 0x81, 2), /* Solid State Logic SSL2+ */
|
|
|
|
IMPLICIT_FB_FIXED_DEV(0x0499, 0x172f, 0x81, 2), /* Steinberg UR22C */
|
|
|
|
IMPLICIT_FB_FIXED_DEV(0x0d9a, 0x00df, 0x81, 2), /* RTX6001 */
|
|
|
|
IMPLICIT_FB_FIXED_DEV(0x22f0, 0x0006, 0x81, 3), /* Allen&Heath Qu-16 */
|
|
|
|
IMPLICIT_FB_FIXED_DEV(0x1686, 0xf029, 0x82, 2), /* Zoom UAC-2 */
|
|
|
|
IMPLICIT_FB_FIXED_DEV(0x2466, 0x8003, 0x86, 2), /* Fractal Audio Axe-Fx II */
|
|
|
|
IMPLICIT_FB_FIXED_DEV(0x0499, 0x172a, 0x86, 2), /* Yamaha MODX */
|
|
|
|
|
|
|
|
/* Special matching */
|
|
|
|
{ .id = USB_ID(0x07fd, 0x0004), .iface_class = USB_CLASS_AUDIO,
|
|
|
|
.type = IMPLICIT_FB_NONE }, /* MicroBook IIc */
|
|
|
|
/* ep = 0x84, ifnum = 0 */
|
|
|
|
{ .id = USB_ID(0x07fd, 0x0004), .iface_class = USB_CLASS_VENDOR_SPEC,
|
|
|
|
.type = IMPLICIT_FB_FIXED,
|
|
|
|
.ep_num = 0x84, .iface = 0 }, /* MOTU MicroBook II */
|
|
|
|
|
|
|
|
{} /* terminator */
|
|
|
|
};
|
|
|
|
|
2020-11-23 16:53:44 +08:00
|
|
|
/* Implicit feedback quirk table for capture: only FIXED type */
|
2020-11-23 16:53:43 +08:00
|
|
|
static const struct snd_usb_implicit_fb_match capture_implicit_fb_quirks[] = {
|
|
|
|
{} /* terminator */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* set up sync EP information on the audioformat */
|
|
|
|
static int add_implicit_fb_sync_ep(struct snd_usb_audio *chip,
|
|
|
|
struct audioformat *fmt,
|
2021-01-08 15:52:19 +08:00
|
|
|
int ep, int ep_idx, int ifnum,
|
2020-11-23 16:53:43 +08:00
|
|
|
const struct usb_host_interface *alts)
|
|
|
|
{
|
|
|
|
struct usb_interface *iface;
|
|
|
|
|
|
|
|
if (!alts) {
|
|
|
|
iface = usb_ifnum_to_if(chip->dev, ifnum);
|
|
|
|
if (!iface || iface->num_altsetting < 2)
|
|
|
|
return 0;
|
|
|
|
alts = &iface->altsetting[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt->sync_ep = ep;
|
|
|
|
fmt->sync_iface = ifnum;
|
|
|
|
fmt->sync_altsetting = alts->desc.bAlternateSetting;
|
2021-01-08 15:52:19 +08:00
|
|
|
fmt->sync_ep_idx = ep_idx;
|
2020-11-23 16:53:43 +08:00
|
|
|
fmt->implicit_fb = 1;
|
|
|
|
usb_audio_dbg(chip,
|
|
|
|
"%d:%d: added %s implicit_fb sync_ep %x, iface %d:%d\n",
|
|
|
|
fmt->iface, fmt->altsetting,
|
|
|
|
(ep & USB_DIR_IN) ? "playback" : "capture",
|
|
|
|
fmt->sync_ep, fmt->sync_iface, fmt->sync_altsetting);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check whether the given UAC2 iface:altset points to an implicit fb source */
|
|
|
|
static int add_generic_uac2_implicit_fb(struct snd_usb_audio *chip,
|
|
|
|
struct audioformat *fmt,
|
|
|
|
unsigned int ifnum,
|
|
|
|
unsigned int altsetting)
|
|
|
|
{
|
|
|
|
struct usb_host_interface *alts;
|
|
|
|
struct usb_endpoint_descriptor *epd;
|
|
|
|
|
|
|
|
alts = snd_usb_get_host_interface(chip, ifnum, altsetting);
|
|
|
|
if (!alts)
|
|
|
|
return 0;
|
|
|
|
if (alts->desc.bInterfaceClass != USB_CLASS_AUDIO ||
|
|
|
|
alts->desc.bInterfaceSubClass != USB_SUBCLASS_AUDIOSTREAMING ||
|
|
|
|
alts->desc.bInterfaceProtocol != UAC_VERSION_2 ||
|
|
|
|
alts->desc.bNumEndpoints < 1)
|
|
|
|
return 0;
|
|
|
|
epd = get_endpoint(alts, 0);
|
|
|
|
if (!usb_endpoint_is_isoc_in(epd) ||
|
|
|
|
(epd->bmAttributes & USB_ENDPOINT_USAGE_MASK) !=
|
|
|
|
USB_ENDPOINT_USAGE_IMPLICIT_FB)
|
|
|
|
return 0;
|
2021-01-08 15:52:19 +08:00
|
|
|
return add_implicit_fb_sync_ep(chip, fmt, epd->bEndpointAddress, 0,
|
2020-11-23 16:53:43 +08:00
|
|
|
ifnum, alts);
|
|
|
|
}
|
|
|
|
|
ALSA: usb-audio: Generic application of implicit fb to Roland/BOSS devices
Through the examinations and experiments with lots of Roland and BOSS
USB-audio devices, we found out that the recently introduced
full-duplex operations with the implicit feedback mode work fine for
quite a few devices, while the others need only the capture-side quirk
to enforce the full-duplex mode. The recent commit d86f43b17ed4
("ALSA: usb-audio: Add support for many Roland devices' implicit
feedback quirks") tried to add such quirk entries manually in the
lists, but this turned out to be too many and error-prone, hence it
was reverted again.
This patch is another attempt to cover those missing Roland/BOSS
devices but in a more generic way. It matches the devices with the
vendor ID 0x0582, and checks whether they are with both ASYNC sync
types or ASYNC is only for capture device. In the former case, it's
the device with the implicit feedback mode, and applies accordingly.
In both cases, the capture stream requires always the full-duplex
mode, and we apply the known capture quirk for that, too.
Basically the already existing BOSS device quirk entries become
redundant after this generic matching, so those are removed. Although
the capture_implicit_fb_quirks[] table became empty and superfluous, I
keep it for now, so that people can put a special device easily at any
time later again.
Link: https://lore.kernel.org/r/CAOsVg8rA61B=005_VyUwpw3piVwA7Bo5fs1GYEB054efyzGjLw@mail.gmail.com
Link: https://lore.kernel.org/r/20210414083255.9527-1-tiwai@suse.de
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=212519
Tested-by: Lucas Endres <jaffa225man@gmail.com>
Link: https://lore.kernel.org/r/20210422120413.457-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-04-22 20:04:13 +08:00
|
|
|
static bool roland_sanity_check_iface(struct usb_host_interface *alts)
|
|
|
|
{
|
|
|
|
if (alts->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC ||
|
|
|
|
(alts->desc.bInterfaceSubClass != 2 &&
|
|
|
|
alts->desc.bInterfaceProtocol != 2) ||
|
|
|
|
alts->desc.bNumEndpoints < 1)
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Like the UAC2 case above, but specific to Roland with vendor class and hack */
|
2020-11-23 16:53:43 +08:00
|
|
|
static int add_roland_implicit_fb(struct snd_usb_audio *chip,
|
|
|
|
struct audioformat *fmt,
|
ALSA: usb-audio: Generic application of implicit fb to Roland/BOSS devices
Through the examinations and experiments with lots of Roland and BOSS
USB-audio devices, we found out that the recently introduced
full-duplex operations with the implicit feedback mode work fine for
quite a few devices, while the others need only the capture-side quirk
to enforce the full-duplex mode. The recent commit d86f43b17ed4
("ALSA: usb-audio: Add support for many Roland devices' implicit
feedback quirks") tried to add such quirk entries manually in the
lists, but this turned out to be too many and error-prone, hence it
was reverted again.
This patch is another attempt to cover those missing Roland/BOSS
devices but in a more generic way. It matches the devices with the
vendor ID 0x0582, and checks whether they are with both ASYNC sync
types or ASYNC is only for capture device. In the former case, it's
the device with the implicit feedback mode, and applies accordingly.
In both cases, the capture stream requires always the full-duplex
mode, and we apply the known capture quirk for that, too.
Basically the already existing BOSS device quirk entries become
redundant after this generic matching, so those are removed. Although
the capture_implicit_fb_quirks[] table became empty and superfluous, I
keep it for now, so that people can put a special device easily at any
time later again.
Link: https://lore.kernel.org/r/CAOsVg8rA61B=005_VyUwpw3piVwA7Bo5fs1GYEB054efyzGjLw@mail.gmail.com
Link: https://lore.kernel.org/r/20210414083255.9527-1-tiwai@suse.de
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=212519
Tested-by: Lucas Endres <jaffa225man@gmail.com>
Link: https://lore.kernel.org/r/20210422120413.457-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-04-22 20:04:13 +08:00
|
|
|
struct usb_host_interface *alts)
|
2020-11-23 16:53:43 +08:00
|
|
|
{
|
|
|
|
struct usb_endpoint_descriptor *epd;
|
|
|
|
|
ALSA: usb-audio: Generic application of implicit fb to Roland/BOSS devices
Through the examinations and experiments with lots of Roland and BOSS
USB-audio devices, we found out that the recently introduced
full-duplex operations with the implicit feedback mode work fine for
quite a few devices, while the others need only the capture-side quirk
to enforce the full-duplex mode. The recent commit d86f43b17ed4
("ALSA: usb-audio: Add support for many Roland devices' implicit
feedback quirks") tried to add such quirk entries manually in the
lists, but this turned out to be too many and error-prone, hence it
was reverted again.
This patch is another attempt to cover those missing Roland/BOSS
devices but in a more generic way. It matches the devices with the
vendor ID 0x0582, and checks whether they are with both ASYNC sync
types or ASYNC is only for capture device. In the former case, it's
the device with the implicit feedback mode, and applies accordingly.
In both cases, the capture stream requires always the full-duplex
mode, and we apply the known capture quirk for that, too.
Basically the already existing BOSS device quirk entries become
redundant after this generic matching, so those are removed. Although
the capture_implicit_fb_quirks[] table became empty and superfluous, I
keep it for now, so that people can put a special device easily at any
time later again.
Link: https://lore.kernel.org/r/CAOsVg8rA61B=005_VyUwpw3piVwA7Bo5fs1GYEB054efyzGjLw@mail.gmail.com
Link: https://lore.kernel.org/r/20210414083255.9527-1-tiwai@suse.de
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=212519
Tested-by: Lucas Endres <jaffa225man@gmail.com>
Link: https://lore.kernel.org/r/20210422120413.457-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-04-22 20:04:13 +08:00
|
|
|
if (!roland_sanity_check_iface(alts))
|
2020-11-23 16:53:43 +08:00
|
|
|
return 0;
|
ALSA: usb-audio: Generic application of implicit fb to Roland/BOSS devices
Through the examinations and experiments with lots of Roland and BOSS
USB-audio devices, we found out that the recently introduced
full-duplex operations with the implicit feedback mode work fine for
quite a few devices, while the others need only the capture-side quirk
to enforce the full-duplex mode. The recent commit d86f43b17ed4
("ALSA: usb-audio: Add support for many Roland devices' implicit
feedback quirks") tried to add such quirk entries manually in the
lists, but this turned out to be too many and error-prone, hence it
was reverted again.
This patch is another attempt to cover those missing Roland/BOSS
devices but in a more generic way. It matches the devices with the
vendor ID 0x0582, and checks whether they are with both ASYNC sync
types or ASYNC is only for capture device. In the former case, it's
the device with the implicit feedback mode, and applies accordingly.
In both cases, the capture stream requires always the full-duplex
mode, and we apply the known capture quirk for that, too.
Basically the already existing BOSS device quirk entries become
redundant after this generic matching, so those are removed. Although
the capture_implicit_fb_quirks[] table became empty and superfluous, I
keep it for now, so that people can put a special device easily at any
time later again.
Link: https://lore.kernel.org/r/CAOsVg8rA61B=005_VyUwpw3piVwA7Bo5fs1GYEB054efyzGjLw@mail.gmail.com
Link: https://lore.kernel.org/r/20210414083255.9527-1-tiwai@suse.de
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=212519
Tested-by: Lucas Endres <jaffa225man@gmail.com>
Link: https://lore.kernel.org/r/20210422120413.457-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-04-22 20:04:13 +08:00
|
|
|
/* only when both streams are with ASYNC type */
|
|
|
|
epd = get_endpoint(alts, 0);
|
|
|
|
if (!usb_endpoint_is_isoc_out(epd) ||
|
|
|
|
(epd->bmAttributes & USB_ENDPOINT_SYNCTYPE) != USB_ENDPOINT_SYNC_ASYNC)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* check capture EP */
|
|
|
|
alts = snd_usb_get_host_interface(chip,
|
|
|
|
alts->desc.bInterfaceNumber + 1,
|
|
|
|
alts->desc.bAlternateSetting);
|
|
|
|
if (!alts || !roland_sanity_check_iface(alts))
|
2020-11-23 16:53:43 +08:00
|
|
|
return 0;
|
|
|
|
epd = get_endpoint(alts, 0);
|
|
|
|
if (!usb_endpoint_is_isoc_in(epd) ||
|
ALSA: usb-audio: Generic application of implicit fb to Roland/BOSS devices
Through the examinations and experiments with lots of Roland and BOSS
USB-audio devices, we found out that the recently introduced
full-duplex operations with the implicit feedback mode work fine for
quite a few devices, while the others need only the capture-side quirk
to enforce the full-duplex mode. The recent commit d86f43b17ed4
("ALSA: usb-audio: Add support for many Roland devices' implicit
feedback quirks") tried to add such quirk entries manually in the
lists, but this turned out to be too many and error-prone, hence it
was reverted again.
This patch is another attempt to cover those missing Roland/BOSS
devices but in a more generic way. It matches the devices with the
vendor ID 0x0582, and checks whether they are with both ASYNC sync
types or ASYNC is only for capture device. In the former case, it's
the device with the implicit feedback mode, and applies accordingly.
In both cases, the capture stream requires always the full-duplex
mode, and we apply the known capture quirk for that, too.
Basically the already existing BOSS device quirk entries become
redundant after this generic matching, so those are removed. Although
the capture_implicit_fb_quirks[] table became empty and superfluous, I
keep it for now, so that people can put a special device easily at any
time later again.
Link: https://lore.kernel.org/r/CAOsVg8rA61B=005_VyUwpw3piVwA7Bo5fs1GYEB054efyzGjLw@mail.gmail.com
Link: https://lore.kernel.org/r/20210414083255.9527-1-tiwai@suse.de
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=212519
Tested-by: Lucas Endres <jaffa225man@gmail.com>
Link: https://lore.kernel.org/r/20210422120413.457-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-04-22 20:04:13 +08:00
|
|
|
(epd->bmAttributes & USB_ENDPOINT_SYNCTYPE) != USB_ENDPOINT_SYNC_ASYNC)
|
2020-11-23 16:53:43 +08:00
|
|
|
return 0;
|
2021-07-29 15:38:51 +08:00
|
|
|
chip->quirk_flags |= QUIRK_FLAG_PLAYBACK_FIRST;
|
2021-01-08 15:52:19 +08:00
|
|
|
return add_implicit_fb_sync_ep(chip, fmt, epd->bEndpointAddress, 0,
|
ALSA: usb-audio: Generic application of implicit fb to Roland/BOSS devices
Through the examinations and experiments with lots of Roland and BOSS
USB-audio devices, we found out that the recently introduced
full-duplex operations with the implicit feedback mode work fine for
quite a few devices, while the others need only the capture-side quirk
to enforce the full-duplex mode. The recent commit d86f43b17ed4
("ALSA: usb-audio: Add support for many Roland devices' implicit
feedback quirks") tried to add such quirk entries manually in the
lists, but this turned out to be too many and error-prone, hence it
was reverted again.
This patch is another attempt to cover those missing Roland/BOSS
devices but in a more generic way. It matches the devices with the
vendor ID 0x0582, and checks whether they are with both ASYNC sync
types or ASYNC is only for capture device. In the former case, it's
the device with the implicit feedback mode, and applies accordingly.
In both cases, the capture stream requires always the full-duplex
mode, and we apply the known capture quirk for that, too.
Basically the already existing BOSS device quirk entries become
redundant after this generic matching, so those are removed. Although
the capture_implicit_fb_quirks[] table became empty and superfluous, I
keep it for now, so that people can put a special device easily at any
time later again.
Link: https://lore.kernel.org/r/CAOsVg8rA61B=005_VyUwpw3piVwA7Bo5fs1GYEB054efyzGjLw@mail.gmail.com
Link: https://lore.kernel.org/r/20210414083255.9527-1-tiwai@suse.de
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=212519
Tested-by: Lucas Endres <jaffa225man@gmail.com>
Link: https://lore.kernel.org/r/20210422120413.457-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-04-22 20:04:13 +08:00
|
|
|
alts->desc.bInterfaceNumber, alts);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* capture quirk for Roland device; always full-duplex */
|
|
|
|
static int add_roland_capture_quirk(struct snd_usb_audio *chip,
|
|
|
|
struct audioformat *fmt,
|
|
|
|
struct usb_host_interface *alts)
|
|
|
|
{
|
|
|
|
struct usb_endpoint_descriptor *epd;
|
|
|
|
|
|
|
|
if (!roland_sanity_check_iface(alts))
|
|
|
|
return 0;
|
|
|
|
epd = get_endpoint(alts, 0);
|
|
|
|
if (!usb_endpoint_is_isoc_in(epd) ||
|
|
|
|
(epd->bmAttributes & USB_ENDPOINT_SYNCTYPE) != USB_ENDPOINT_SYNC_ASYNC)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
alts = snd_usb_get_host_interface(chip,
|
|
|
|
alts->desc.bInterfaceNumber - 1,
|
|
|
|
alts->desc.bAlternateSetting);
|
|
|
|
if (!alts || !roland_sanity_check_iface(alts))
|
|
|
|
return 0;
|
|
|
|
epd = get_endpoint(alts, 0);
|
|
|
|
if (!usb_endpoint_is_isoc_out(epd))
|
|
|
|
return 0;
|
|
|
|
return add_implicit_fb_sync_ep(chip, fmt, epd->bEndpointAddress, 0,
|
|
|
|
alts->desc.bInterfaceNumber, alts);
|
2020-11-23 16:53:43 +08:00
|
|
|
}
|
|
|
|
|
ALSA: usb-audio: Re-apply implicit feedback mode to Pioneer devices
Pioneer devices are supposed to be working with the implicit feedback
mode, but so far the attempt to apply the implicit feedback caused
issues, hence we explicitly skipped the implicit feedback mode for
them. Recently, Geraldo discovered that the device actually works if
you skip the generic matching of the sync EPs for the capture stream.
That is, we should apply the implicit feedback setup for the playback
like other similar devices, while we need to return 1 from
audioformat_capture_quirk() so that no further matching will be done.
And, later on, Olivia reported later that the fiddling with the
capture quirk alone doesn't suffice for the test with speaker-test
program. This seems to be a similar case like the recently fixed BOSS
devices. Indeed, the problem could be addressed by setting
playback_first flag, which indicates that the playback URBs have to be
sent out at first even in the implicit feedback mode.
This patch implements the application of the implicit feedback to
Pioneer devices as described in the above. The former
skip_pioneer_sync_ep() was dropped, and instead we provide
is_pioneer_implicit_fb() to check the Pioneer devices that need the
implicit feedback. In the audioformat_implicit_fb_quirk(), simply
apply the implicit fb for playback and set chip->playback_first flag
if matching, and in audioformat_capture_quirk()(), it returns 1 for
skipping the generic EP sync handling.
Reported-by: Geraldo <geraldogabriel@gmail.com>
Tested-by: Olivia Mackintosh <livvy@base.nu>
Link: https://lore.kernel.org/r/s5ha6pygqfz.wl-tiwai@suse.de
Link: https://lore.kernel.org/r/20210419153918.450-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-04-19 23:39:18 +08:00
|
|
|
/* Playback and capture EPs on Pioneer devices share the same iface/altset
|
|
|
|
* for the implicit feedback operation
|
2021-01-08 15:52:19 +08:00
|
|
|
*/
|
ALSA: usb-audio: Re-apply implicit feedback mode to Pioneer devices
Pioneer devices are supposed to be working with the implicit feedback
mode, but so far the attempt to apply the implicit feedback caused
issues, hence we explicitly skipped the implicit feedback mode for
them. Recently, Geraldo discovered that the device actually works if
you skip the generic matching of the sync EPs for the capture stream.
That is, we should apply the implicit feedback setup for the playback
like other similar devices, while we need to return 1 from
audioformat_capture_quirk() so that no further matching will be done.
And, later on, Olivia reported later that the fiddling with the
capture quirk alone doesn't suffice for the test with speaker-test
program. This seems to be a similar case like the recently fixed BOSS
devices. Indeed, the problem could be addressed by setting
playback_first flag, which indicates that the playback URBs have to be
sent out at first even in the implicit feedback mode.
This patch implements the application of the implicit feedback to
Pioneer devices as described in the above. The former
skip_pioneer_sync_ep() was dropped, and instead we provide
is_pioneer_implicit_fb() to check the Pioneer devices that need the
implicit feedback. In the audioformat_implicit_fb_quirk(), simply
apply the implicit fb for playback and set chip->playback_first flag
if matching, and in audioformat_capture_quirk()(), it returns 1 for
skipping the generic EP sync handling.
Reported-by: Geraldo <geraldogabriel@gmail.com>
Tested-by: Olivia Mackintosh <livvy@base.nu>
Link: https://lore.kernel.org/r/s5ha6pygqfz.wl-tiwai@suse.de
Link: https://lore.kernel.org/r/20210419153918.450-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-04-19 23:39:18 +08:00
|
|
|
static bool is_pioneer_implicit_fb(struct snd_usb_audio *chip,
|
|
|
|
struct usb_host_interface *alts)
|
|
|
|
|
2021-01-08 15:52:19 +08:00
|
|
|
{
|
|
|
|
struct usb_endpoint_descriptor *epd;
|
|
|
|
|
ALSA: usb-audio: Re-apply implicit feedback mode to Pioneer devices
Pioneer devices are supposed to be working with the implicit feedback
mode, but so far the attempt to apply the implicit feedback caused
issues, hence we explicitly skipped the implicit feedback mode for
them. Recently, Geraldo discovered that the device actually works if
you skip the generic matching of the sync EPs for the capture stream.
That is, we should apply the implicit feedback setup for the playback
like other similar devices, while we need to return 1 from
audioformat_capture_quirk() so that no further matching will be done.
And, later on, Olivia reported later that the fiddling with the
capture quirk alone doesn't suffice for the test with speaker-test
program. This seems to be a similar case like the recently fixed BOSS
devices. Indeed, the problem could be addressed by setting
playback_first flag, which indicates that the playback URBs have to be
sent out at first even in the implicit feedback mode.
This patch implements the application of the implicit feedback to
Pioneer devices as described in the above. The former
skip_pioneer_sync_ep() was dropped, and instead we provide
is_pioneer_implicit_fb() to check the Pioneer devices that need the
implicit feedback. In the audioformat_implicit_fb_quirk(), simply
apply the implicit fb for playback and set chip->playback_first flag
if matching, and in audioformat_capture_quirk()(), it returns 1 for
skipping the generic EP sync handling.
Reported-by: Geraldo <geraldogabriel@gmail.com>
Tested-by: Olivia Mackintosh <livvy@base.nu>
Link: https://lore.kernel.org/r/s5ha6pygqfz.wl-tiwai@suse.de
Link: https://lore.kernel.org/r/20210419153918.450-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-04-19 23:39:18 +08:00
|
|
|
if (USB_ID_VENDOR(chip->usb_id) != 0x2b73 &&
|
|
|
|
USB_ID_VENDOR(chip->usb_id) != 0x08e4)
|
|
|
|
return false;
|
|
|
|
if (alts->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC)
|
|
|
|
return false;
|
2021-01-08 15:52:19 +08:00
|
|
|
if (alts->desc.bNumEndpoints != 2)
|
ALSA: usb-audio: Re-apply implicit feedback mode to Pioneer devices
Pioneer devices are supposed to be working with the implicit feedback
mode, but so far the attempt to apply the implicit feedback caused
issues, hence we explicitly skipped the implicit feedback mode for
them. Recently, Geraldo discovered that the device actually works if
you skip the generic matching of the sync EPs for the capture stream.
That is, we should apply the implicit feedback setup for the playback
like other similar devices, while we need to return 1 from
audioformat_capture_quirk() so that no further matching will be done.
And, later on, Olivia reported later that the fiddling with the
capture quirk alone doesn't suffice for the test with speaker-test
program. This seems to be a similar case like the recently fixed BOSS
devices. Indeed, the problem could be addressed by setting
playback_first flag, which indicates that the playback URBs have to be
sent out at first even in the implicit feedback mode.
This patch implements the application of the implicit feedback to
Pioneer devices as described in the above. The former
skip_pioneer_sync_ep() was dropped, and instead we provide
is_pioneer_implicit_fb() to check the Pioneer devices that need the
implicit feedback. In the audioformat_implicit_fb_quirk(), simply
apply the implicit fb for playback and set chip->playback_first flag
if matching, and in audioformat_capture_quirk()(), it returns 1 for
skipping the generic EP sync handling.
Reported-by: Geraldo <geraldogabriel@gmail.com>
Tested-by: Olivia Mackintosh <livvy@base.nu>
Link: https://lore.kernel.org/r/s5ha6pygqfz.wl-tiwai@suse.de
Link: https://lore.kernel.org/r/20210419153918.450-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-04-19 23:39:18 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
epd = get_endpoint(alts, 0);
|
|
|
|
if (!usb_endpoint_is_isoc_out(epd) ||
|
|
|
|
(epd->bmAttributes & USB_ENDPOINT_SYNCTYPE) != USB_ENDPOINT_SYNC_ASYNC)
|
|
|
|
return false;
|
2021-01-08 15:52:19 +08:00
|
|
|
|
|
|
|
epd = get_endpoint(alts, 1);
|
|
|
|
if (!usb_endpoint_is_isoc_in(epd) ||
|
|
|
|
(epd->bmAttributes & USB_ENDPOINT_SYNCTYPE) != USB_ENDPOINT_SYNC_ASYNC ||
|
|
|
|
((epd->bmAttributes & USB_ENDPOINT_USAGE_MASK) !=
|
|
|
|
USB_ENDPOINT_USAGE_DATA &&
|
|
|
|
(epd->bmAttributes & USB_ENDPOINT_USAGE_MASK) !=
|
|
|
|
USB_ENDPOINT_USAGE_IMPLICIT_FB))
|
ALSA: usb-audio: Re-apply implicit feedback mode to Pioneer devices
Pioneer devices are supposed to be working with the implicit feedback
mode, but so far the attempt to apply the implicit feedback caused
issues, hence we explicitly skipped the implicit feedback mode for
them. Recently, Geraldo discovered that the device actually works if
you skip the generic matching of the sync EPs for the capture stream.
That is, we should apply the implicit feedback setup for the playback
like other similar devices, while we need to return 1 from
audioformat_capture_quirk() so that no further matching will be done.
And, later on, Olivia reported later that the fiddling with the
capture quirk alone doesn't suffice for the test with speaker-test
program. This seems to be a similar case like the recently fixed BOSS
devices. Indeed, the problem could be addressed by setting
playback_first flag, which indicates that the playback URBs have to be
sent out at first even in the implicit feedback mode.
This patch implements the application of the implicit feedback to
Pioneer devices as described in the above. The former
skip_pioneer_sync_ep() was dropped, and instead we provide
is_pioneer_implicit_fb() to check the Pioneer devices that need the
implicit feedback. In the audioformat_implicit_fb_quirk(), simply
apply the implicit fb for playback and set chip->playback_first flag
if matching, and in audioformat_capture_quirk()(), it returns 1 for
skipping the generic EP sync handling.
Reported-by: Geraldo <geraldogabriel@gmail.com>
Tested-by: Olivia Mackintosh <livvy@base.nu>
Link: https://lore.kernel.org/r/s5ha6pygqfz.wl-tiwai@suse.de
Link: https://lore.kernel.org/r/20210419153918.450-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-04-19 23:39:18 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2021-01-08 15:52:19 +08:00
|
|
|
}
|
2020-11-23 16:53:44 +08:00
|
|
|
|
|
|
|
static int __add_generic_implicit_fb(struct snd_usb_audio *chip,
|
|
|
|
struct audioformat *fmt,
|
|
|
|
int iface, int altset)
|
|
|
|
{
|
|
|
|
struct usb_host_interface *alts;
|
|
|
|
struct usb_endpoint_descriptor *epd;
|
|
|
|
|
|
|
|
alts = snd_usb_get_host_interface(chip, iface, altset);
|
|
|
|
if (!alts)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if ((alts->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC &&
|
|
|
|
alts->desc.bInterfaceClass != USB_CLASS_AUDIO) ||
|
|
|
|
alts->desc.bNumEndpoints < 1)
|
|
|
|
return 0;
|
|
|
|
epd = get_endpoint(alts, 0);
|
|
|
|
if (!usb_endpoint_is_isoc_in(epd) ||
|
|
|
|
(epd->bmAttributes & USB_ENDPOINT_SYNCTYPE) != USB_ENDPOINT_SYNC_ASYNC)
|
|
|
|
return 0;
|
2021-01-08 15:52:19 +08:00
|
|
|
return add_implicit_fb_sync_ep(chip, fmt, epd->bEndpointAddress, 0,
|
2020-11-23 16:53:44 +08:00
|
|
|
iface, alts);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* More generic quirk: look for the sync EP next to the data EP */
|
|
|
|
static int add_generic_implicit_fb(struct snd_usb_audio *chip,
|
|
|
|
struct audioformat *fmt,
|
|
|
|
struct usb_host_interface *alts)
|
|
|
|
{
|
|
|
|
if ((fmt->ep_attr & USB_ENDPOINT_SYNCTYPE) != USB_ENDPOINT_SYNC_ASYNC)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (__add_generic_implicit_fb(chip, fmt,
|
|
|
|
alts->desc.bInterfaceNumber + 1,
|
|
|
|
alts->desc.bAlternateSetting))
|
|
|
|
return 1;
|
|
|
|
return __add_generic_implicit_fb(chip, fmt,
|
|
|
|
alts->desc.bInterfaceNumber - 1,
|
|
|
|
alts->desc.bAlternateSetting);
|
|
|
|
}
|
|
|
|
|
2020-11-23 16:53:43 +08:00
|
|
|
static const struct snd_usb_implicit_fb_match *
|
|
|
|
find_implicit_fb_entry(struct snd_usb_audio *chip,
|
|
|
|
const struct snd_usb_implicit_fb_match *match,
|
|
|
|
const struct usb_host_interface *alts)
|
|
|
|
{
|
|
|
|
for (; match->id; match++)
|
|
|
|
if (match->id == chip->usb_id &&
|
|
|
|
(!match->iface_class ||
|
|
|
|
(alts->desc.bInterfaceClass == match->iface_class)))
|
|
|
|
return match;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Setup an implicit feedback endpoint from a quirk. Returns 0 if no quirk
|
|
|
|
* applies. Returns 1 if a quirk was found.
|
|
|
|
*/
|
|
|
|
static int audioformat_implicit_fb_quirk(struct snd_usb_audio *chip,
|
|
|
|
struct audioformat *fmt,
|
|
|
|
struct usb_host_interface *alts)
|
|
|
|
{
|
|
|
|
const struct snd_usb_implicit_fb_match *p;
|
|
|
|
unsigned int attr = fmt->ep_attr & USB_ENDPOINT_SYNCTYPE;
|
|
|
|
|
|
|
|
p = find_implicit_fb_entry(chip, playback_implicit_fb_quirks, alts);
|
|
|
|
if (p) {
|
|
|
|
switch (p->type) {
|
2020-11-23 16:53:44 +08:00
|
|
|
case IMPLICIT_FB_GENERIC:
|
|
|
|
return add_generic_implicit_fb(chip, fmt, alts);
|
2020-11-23 16:53:43 +08:00
|
|
|
case IMPLICIT_FB_NONE:
|
|
|
|
return 0; /* No quirk */
|
|
|
|
case IMPLICIT_FB_FIXED:
|
2021-01-08 15:52:19 +08:00
|
|
|
return add_implicit_fb_sync_ep(chip, fmt, p->ep_num, 0,
|
2020-11-23 16:53:43 +08:00
|
|
|
p->iface, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
ALSA: usb-audio: Apply implicit feedback mode for BOSS devices
During the recent rewrite of the implicit feedback support, we've
tested to apply the implicit fb on BOSS devices, but it failed, as the
capture stream didn't start without the playback. As the end result,
it got another type of quirk for tying both streams but starts
playback always (commit 6234fdc1cede "ALSA: usb-audio: Quirk for BOSS
GT-001").
Meanwhile, Mike Oliphant has tested the real implicit feedback mode
for the playback again with the latest code, and found out that it
actually works if the initial feedback sync is skipped; that is, on
those BOSS devices, the playback stream has to be started at first
without waiting for the capture URB completions. Otherwise it gets
stuck. In the rest operations after the capture stream processed, we
can take them as the implicit feedback source.
This patch is an attempt to improve the support for BOSS devices with
the implicit feedback mode in the way described above. It adds a new
flag to snd_usb_audio, playback_first, indicating that the playback
stream starts without sync with the initial capture completion. This
flag is set in the quirk table with the new IMPLICIT_FB_BOTH type.
Reported-and-tested-by: Mike Oliphant <oliphant@nostatic.org>
Link: https://lore.kernel.org/r/20210414083255.9527-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-04-14 16:32:55 +08:00
|
|
|
/* Special handling for devices with capture quirks */
|
2021-04-06 19:38:37 +08:00
|
|
|
p = find_implicit_fb_entry(chip, capture_implicit_fb_quirks, alts);
|
ALSA: usb-audio: Apply implicit feedback mode for BOSS devices
During the recent rewrite of the implicit feedback support, we've
tested to apply the implicit fb on BOSS devices, but it failed, as the
capture stream didn't start without the playback. As the end result,
it got another type of quirk for tying both streams but starts
playback always (commit 6234fdc1cede "ALSA: usb-audio: Quirk for BOSS
GT-001").
Meanwhile, Mike Oliphant has tested the real implicit feedback mode
for the playback again with the latest code, and found out that it
actually works if the initial feedback sync is skipped; that is, on
those BOSS devices, the playback stream has to be started at first
without waiting for the capture URB completions. Otherwise it gets
stuck. In the rest operations after the capture stream processed, we
can take them as the implicit feedback source.
This patch is an attempt to improve the support for BOSS devices with
the implicit feedback mode in the way described above. It adds a new
flag to snd_usb_audio, playback_first, indicating that the playback
stream starts without sync with the initial capture completion. This
flag is set in the quirk table with the new IMPLICIT_FB_BOTH type.
Reported-and-tested-by: Mike Oliphant <oliphant@nostatic.org>
Link: https://lore.kernel.org/r/20210414083255.9527-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-04-14 16:32:55 +08:00
|
|
|
if (p) {
|
|
|
|
switch (p->type) {
|
|
|
|
case IMPLICIT_FB_FIXED:
|
|
|
|
return 0; /* no quirk */
|
|
|
|
case IMPLICIT_FB_BOTH:
|
2021-07-29 15:38:51 +08:00
|
|
|
chip->quirk_flags |= QUIRK_FLAG_PLAYBACK_FIRST;
|
ALSA: usb-audio: Apply implicit feedback mode for BOSS devices
During the recent rewrite of the implicit feedback support, we've
tested to apply the implicit fb on BOSS devices, but it failed, as the
capture stream didn't start without the playback. As the end result,
it got another type of quirk for tying both streams but starts
playback always (commit 6234fdc1cede "ALSA: usb-audio: Quirk for BOSS
GT-001").
Meanwhile, Mike Oliphant has tested the real implicit feedback mode
for the playback again with the latest code, and found out that it
actually works if the initial feedback sync is skipped; that is, on
those BOSS devices, the playback stream has to be started at first
without waiting for the capture URB completions. Otherwise it gets
stuck. In the rest operations after the capture stream processed, we
can take them as the implicit feedback source.
This patch is an attempt to improve the support for BOSS devices with
the implicit feedback mode in the way described above. It adds a new
flag to snd_usb_audio, playback_first, indicating that the playback
stream starts without sync with the initial capture completion. This
flag is set in the quirk table with the new IMPLICIT_FB_BOTH type.
Reported-and-tested-by: Mike Oliphant <oliphant@nostatic.org>
Link: https://lore.kernel.org/r/20210414083255.9527-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-04-14 16:32:55 +08:00
|
|
|
return add_generic_implicit_fb(chip, fmt, alts);
|
|
|
|
}
|
|
|
|
}
|
2021-04-06 19:38:37 +08:00
|
|
|
|
2020-11-23 16:53:43 +08:00
|
|
|
/* Generic UAC2 implicit feedback */
|
|
|
|
if (attr == USB_ENDPOINT_SYNC_ASYNC &&
|
|
|
|
alts->desc.bInterfaceClass == USB_CLASS_AUDIO &&
|
|
|
|
alts->desc.bInterfaceProtocol == UAC_VERSION_2 &&
|
|
|
|
alts->desc.bNumEndpoints == 1) {
|
|
|
|
if (add_generic_uac2_implicit_fb(chip, fmt,
|
|
|
|
alts->desc.bInterfaceNumber + 1,
|
|
|
|
alts->desc.bAlternateSetting))
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Roland/BOSS implicit feedback with vendor spec class */
|
ALSA: usb-audio: Generic application of implicit fb to Roland/BOSS devices
Through the examinations and experiments with lots of Roland and BOSS
USB-audio devices, we found out that the recently introduced
full-duplex operations with the implicit feedback mode work fine for
quite a few devices, while the others need only the capture-side quirk
to enforce the full-duplex mode. The recent commit d86f43b17ed4
("ALSA: usb-audio: Add support for many Roland devices' implicit
feedback quirks") tried to add such quirk entries manually in the
lists, but this turned out to be too many and error-prone, hence it
was reverted again.
This patch is another attempt to cover those missing Roland/BOSS
devices but in a more generic way. It matches the devices with the
vendor ID 0x0582, and checks whether they are with both ASYNC sync
types or ASYNC is only for capture device. In the former case, it's
the device with the implicit feedback mode, and applies accordingly.
In both cases, the capture stream requires always the full-duplex
mode, and we apply the known capture quirk for that, too.
Basically the already existing BOSS device quirk entries become
redundant after this generic matching, so those are removed. Although
the capture_implicit_fb_quirks[] table became empty and superfluous, I
keep it for now, so that people can put a special device easily at any
time later again.
Link: https://lore.kernel.org/r/CAOsVg8rA61B=005_VyUwpw3piVwA7Bo5fs1GYEB054efyzGjLw@mail.gmail.com
Link: https://lore.kernel.org/r/20210414083255.9527-1-tiwai@suse.de
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=212519
Tested-by: Lucas Endres <jaffa225man@gmail.com>
Link: https://lore.kernel.org/r/20210422120413.457-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-04-22 20:04:13 +08:00
|
|
|
if (USB_ID_VENDOR(chip->usb_id) == 0x0582) {
|
|
|
|
if (add_roland_implicit_fb(chip, fmt, alts) > 0)
|
2020-11-23 16:53:43 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2021-01-18 15:58:16 +08:00
|
|
|
/* Pioneer devices with vendor spec class */
|
ALSA: usb-audio: Re-apply implicit feedback mode to Pioneer devices
Pioneer devices are supposed to be working with the implicit feedback
mode, but so far the attempt to apply the implicit feedback caused
issues, hence we explicitly skipped the implicit feedback mode for
them. Recently, Geraldo discovered that the device actually works if
you skip the generic matching of the sync EPs for the capture stream.
That is, we should apply the implicit feedback setup for the playback
like other similar devices, while we need to return 1 from
audioformat_capture_quirk() so that no further matching will be done.
And, later on, Olivia reported later that the fiddling with the
capture quirk alone doesn't suffice for the test with speaker-test
program. This seems to be a similar case like the recently fixed BOSS
devices. Indeed, the problem could be addressed by setting
playback_first flag, which indicates that the playback URBs have to be
sent out at first even in the implicit feedback mode.
This patch implements the application of the implicit feedback to
Pioneer devices as described in the above. The former
skip_pioneer_sync_ep() was dropped, and instead we provide
is_pioneer_implicit_fb() to check the Pioneer devices that need the
implicit feedback. In the audioformat_implicit_fb_quirk(), simply
apply the implicit fb for playback and set chip->playback_first flag
if matching, and in audioformat_capture_quirk()(), it returns 1 for
skipping the generic EP sync handling.
Reported-by: Geraldo <geraldogabriel@gmail.com>
Tested-by: Olivia Mackintosh <livvy@base.nu>
Link: https://lore.kernel.org/r/s5ha6pygqfz.wl-tiwai@suse.de
Link: https://lore.kernel.org/r/20210419153918.450-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-04-19 23:39:18 +08:00
|
|
|
if (is_pioneer_implicit_fb(chip, alts)) {
|
2021-07-29 15:38:51 +08:00
|
|
|
chip->quirk_flags |= QUIRK_FLAG_PLAYBACK_FIRST;
|
ALSA: usb-audio: Re-apply implicit feedback mode to Pioneer devices
Pioneer devices are supposed to be working with the implicit feedback
mode, but so far the attempt to apply the implicit feedback caused
issues, hence we explicitly skipped the implicit feedback mode for
them. Recently, Geraldo discovered that the device actually works if
you skip the generic matching of the sync EPs for the capture stream.
That is, we should apply the implicit feedback setup for the playback
like other similar devices, while we need to return 1 from
audioformat_capture_quirk() so that no further matching will be done.
And, later on, Olivia reported later that the fiddling with the
capture quirk alone doesn't suffice for the test with speaker-test
program. This seems to be a similar case like the recently fixed BOSS
devices. Indeed, the problem could be addressed by setting
playback_first flag, which indicates that the playback URBs have to be
sent out at first even in the implicit feedback mode.
This patch implements the application of the implicit feedback to
Pioneer devices as described in the above. The former
skip_pioneer_sync_ep() was dropped, and instead we provide
is_pioneer_implicit_fb() to check the Pioneer devices that need the
implicit feedback. In the audioformat_implicit_fb_quirk(), simply
apply the implicit fb for playback and set chip->playback_first flag
if matching, and in audioformat_capture_quirk()(), it returns 1 for
skipping the generic EP sync handling.
Reported-by: Geraldo <geraldogabriel@gmail.com>
Tested-by: Olivia Mackintosh <livvy@base.nu>
Link: https://lore.kernel.org/r/s5ha6pygqfz.wl-tiwai@suse.de
Link: https://lore.kernel.org/r/20210419153918.450-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-04-19 23:39:18 +08:00
|
|
|
return add_implicit_fb_sync_ep(chip, fmt,
|
|
|
|
get_endpoint(alts, 1)->bEndpointAddress,
|
|
|
|
1, alts->desc.bInterfaceNumber,
|
|
|
|
alts);
|
2021-01-08 15:52:19 +08:00
|
|
|
}
|
|
|
|
|
2020-11-23 16:53:45 +08:00
|
|
|
/* Try the generic implicit fb if available */
|
|
|
|
if (chip->generic_implicit_fb)
|
|
|
|
return add_generic_implicit_fb(chip, fmt, alts);
|
|
|
|
|
2020-11-23 16:53:43 +08:00
|
|
|
/* No quirk */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* same for capture, but only handling FIXED entry */
|
|
|
|
static int audioformat_capture_quirk(struct snd_usb_audio *chip,
|
|
|
|
struct audioformat *fmt,
|
|
|
|
struct usb_host_interface *alts)
|
|
|
|
{
|
|
|
|
const struct snd_usb_implicit_fb_match *p;
|
|
|
|
|
|
|
|
p = find_implicit_fb_entry(chip, capture_implicit_fb_quirks, alts);
|
ALSA: usb-audio: Apply implicit feedback mode for BOSS devices
During the recent rewrite of the implicit feedback support, we've
tested to apply the implicit fb on BOSS devices, but it failed, as the
capture stream didn't start without the playback. As the end result,
it got another type of quirk for tying both streams but starts
playback always (commit 6234fdc1cede "ALSA: usb-audio: Quirk for BOSS
GT-001").
Meanwhile, Mike Oliphant has tested the real implicit feedback mode
for the playback again with the latest code, and found out that it
actually works if the initial feedback sync is skipped; that is, on
those BOSS devices, the playback stream has to be started at first
without waiting for the capture URB completions. Otherwise it gets
stuck. In the rest operations after the capture stream processed, we
can take them as the implicit feedback source.
This patch is an attempt to improve the support for BOSS devices with
the implicit feedback mode in the way described above. It adds a new
flag to snd_usb_audio, playback_first, indicating that the playback
stream starts without sync with the initial capture completion. This
flag is set in the quirk table with the new IMPLICIT_FB_BOTH type.
Reported-and-tested-by: Mike Oliphant <oliphant@nostatic.org>
Link: https://lore.kernel.org/r/20210414083255.9527-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-04-14 16:32:55 +08:00
|
|
|
if (p && (p->type == IMPLICIT_FB_FIXED || p->type == IMPLICIT_FB_BOTH))
|
2021-01-08 15:52:19 +08:00
|
|
|
return add_implicit_fb_sync_ep(chip, fmt, p->ep_num, 0,
|
|
|
|
p->iface, NULL);
|
ALSA: usb-audio: Generic application of implicit fb to Roland/BOSS devices
Through the examinations and experiments with lots of Roland and BOSS
USB-audio devices, we found out that the recently introduced
full-duplex operations with the implicit feedback mode work fine for
quite a few devices, while the others need only the capture-side quirk
to enforce the full-duplex mode. The recent commit d86f43b17ed4
("ALSA: usb-audio: Add support for many Roland devices' implicit
feedback quirks") tried to add such quirk entries manually in the
lists, but this turned out to be too many and error-prone, hence it
was reverted again.
This patch is another attempt to cover those missing Roland/BOSS
devices but in a more generic way. It matches the devices with the
vendor ID 0x0582, and checks whether they are with both ASYNC sync
types or ASYNC is only for capture device. In the former case, it's
the device with the implicit feedback mode, and applies accordingly.
In both cases, the capture stream requires always the full-duplex
mode, and we apply the known capture quirk for that, too.
Basically the already existing BOSS device quirk entries become
redundant after this generic matching, so those are removed. Although
the capture_implicit_fb_quirks[] table became empty and superfluous, I
keep it for now, so that people can put a special device easily at any
time later again.
Link: https://lore.kernel.org/r/CAOsVg8rA61B=005_VyUwpw3piVwA7Bo5fs1GYEB054efyzGjLw@mail.gmail.com
Link: https://lore.kernel.org/r/20210414083255.9527-1-tiwai@suse.de
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=212519
Tested-by: Lucas Endres <jaffa225man@gmail.com>
Link: https://lore.kernel.org/r/20210422120413.457-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-04-22 20:04:13 +08:00
|
|
|
|
|
|
|
/* Roland/BOSS need full-duplex streams */
|
|
|
|
if (USB_ID_VENDOR(chip->usb_id) == 0x0582) {
|
|
|
|
if (add_roland_capture_quirk(chip, fmt, alts) > 0)
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
ALSA: usb-audio: Re-apply implicit feedback mode to Pioneer devices
Pioneer devices are supposed to be working with the implicit feedback
mode, but so far the attempt to apply the implicit feedback caused
issues, hence we explicitly skipped the implicit feedback mode for
them. Recently, Geraldo discovered that the device actually works if
you skip the generic matching of the sync EPs for the capture stream.
That is, we should apply the implicit feedback setup for the playback
like other similar devices, while we need to return 1 from
audioformat_capture_quirk() so that no further matching will be done.
And, later on, Olivia reported later that the fiddling with the
capture quirk alone doesn't suffice for the test with speaker-test
program. This seems to be a similar case like the recently fixed BOSS
devices. Indeed, the problem could be addressed by setting
playback_first flag, which indicates that the playback URBs have to be
sent out at first even in the implicit feedback mode.
This patch implements the application of the implicit feedback to
Pioneer devices as described in the above. The former
skip_pioneer_sync_ep() was dropped, and instead we provide
is_pioneer_implicit_fb() to check the Pioneer devices that need the
implicit feedback. In the audioformat_implicit_fb_quirk(), simply
apply the implicit fb for playback and set chip->playback_first flag
if matching, and in audioformat_capture_quirk()(), it returns 1 for
skipping the generic EP sync handling.
Reported-by: Geraldo <geraldogabriel@gmail.com>
Tested-by: Olivia Mackintosh <livvy@base.nu>
Link: https://lore.kernel.org/r/s5ha6pygqfz.wl-tiwai@suse.de
Link: https://lore.kernel.org/r/20210419153918.450-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-04-19 23:39:18 +08:00
|
|
|
if (is_pioneer_implicit_fb(chip, alts))
|
|
|
|
return 1; /* skip the quirk, also don't handle generic sync EP */
|
2020-11-23 16:53:43 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Parse altset and set up implicit feedback endpoint on the audioformat
|
|
|
|
*/
|
|
|
|
int snd_usb_parse_implicit_fb_quirk(struct snd_usb_audio *chip,
|
|
|
|
struct audioformat *fmt,
|
|
|
|
struct usb_host_interface *alts)
|
|
|
|
{
|
|
|
|
if (fmt->endpoint & USB_DIR_IN)
|
|
|
|
return audioformat_capture_quirk(chip, fmt, alts);
|
|
|
|
else
|
|
|
|
return audioformat_implicit_fb_quirk(chip, fmt, alts);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the score of matching two audioformats.
|
|
|
|
* Veto the audioformat if:
|
|
|
|
* - It has no channels for some reason.
|
|
|
|
* - Requested PCM format is not supported.
|
|
|
|
* - Requested sample rate is not supported.
|
|
|
|
*/
|
|
|
|
static int match_endpoint_audioformats(struct snd_usb_substream *subs,
|
|
|
|
const struct audioformat *fp,
|
|
|
|
int rate, int channels,
|
|
|
|
snd_pcm_format_t pcm_format)
|
|
|
|
{
|
|
|
|
int i, score;
|
|
|
|
|
|
|
|
if (fp->channels < 1)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!(fp->formats & pcm_format_to_bits(pcm_format)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (fp->rates & SNDRV_PCM_RATE_CONTINUOUS) {
|
|
|
|
if (rate < fp->rate_min || rate > fp->rate_max)
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < fp->nr_rates; i++) {
|
|
|
|
if (fp->rate_table[i] == rate)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i >= fp->nr_rates)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
score = 1;
|
|
|
|
if (fp->channels == channels)
|
|
|
|
score++;
|
|
|
|
|
|
|
|
return score;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct snd_usb_substream *
|
|
|
|
find_matching_substream(struct snd_usb_audio *chip, int stream, int ep_num,
|
|
|
|
int fmt_type)
|
|
|
|
{
|
|
|
|
struct snd_usb_stream *as;
|
|
|
|
struct snd_usb_substream *subs;
|
|
|
|
|
|
|
|
list_for_each_entry(as, &chip->pcm_list, list) {
|
|
|
|
subs = &as->substream[stream];
|
|
|
|
if (as->fmt_type == fmt_type && subs->ep_num == ep_num)
|
|
|
|
return subs;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the audioformat that is suitable for the implicit fb
|
|
|
|
*/
|
|
|
|
const struct audioformat *
|
|
|
|
snd_usb_find_implicit_fb_sync_format(struct snd_usb_audio *chip,
|
|
|
|
const struct audioformat *target,
|
|
|
|
const struct snd_pcm_hw_params *params,
|
|
|
|
int stream)
|
|
|
|
{
|
|
|
|
struct snd_usb_substream *subs;
|
2021-01-08 15:52:16 +08:00
|
|
|
const struct audioformat *fp, *sync_fmt = NULL;
|
2020-11-23 16:53:43 +08:00
|
|
|
int score, high_score;
|
|
|
|
|
2021-01-08 15:52:16 +08:00
|
|
|
/* Use the original audioformat as fallback for the shared altset */
|
2020-11-23 16:53:43 +08:00
|
|
|
if (target->iface == target->sync_iface &&
|
|
|
|
target->altsetting == target->sync_altsetting)
|
2021-01-08 15:52:16 +08:00
|
|
|
sync_fmt = target;
|
2020-11-23 16:53:43 +08:00
|
|
|
|
|
|
|
subs = find_matching_substream(chip, stream, target->sync_ep,
|
|
|
|
target->fmt_type);
|
|
|
|
if (!subs)
|
2021-01-08 15:52:16 +08:00
|
|
|
return sync_fmt;
|
2020-11-23 16:53:43 +08:00
|
|
|
|
|
|
|
high_score = 0;
|
|
|
|
list_for_each_entry(fp, &subs->fmt_list, list) {
|
|
|
|
score = match_endpoint_audioformats(subs, fp,
|
|
|
|
params_rate(params),
|
|
|
|
params_channels(params),
|
|
|
|
params_format(params));
|
|
|
|
if (score > high_score) {
|
|
|
|
sync_fmt = fp;
|
|
|
|
high_score = score;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return sync_fmt;
|
|
|
|
}
|
|
|
|
|