On 29/01/17(Sun) 19:33, Christopher Zimmermann wrote:
> [...]
> Index: uaudio.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/usb/uaudio.c,v
> retrieving revision 1.122
> diff -u -p -r1.122 uaudio.c
> --- uaudio.c 3 Jan 2017 06:45:58 -0000 1.122
> +++ uaudio.c 29 Jan 2017 17:13:28 -0000
> @@ -172,6 +172,7 @@ struct chan {
> #define UAUDIO_FLAG_VENDOR_CLASS 0x0010 /* claims vendor class but
> works */
> #define UAUDIO_FLAG_DEPENDENT 0x0020 /* play and record params must
> equal */
> #define UAUDIO_FLAG_EMU0202 0x0040
> +#define UAUDIO_FLAG_BE 0x0080
>
> struct uaudio_devs {
> struct usb_devno uv_dev;
> @@ -223,7 +224,9 @@ struct uaudio_devs {
> { { USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_QUICKCAMZOOM },
> UAUDIO_FLAG_BAD_AUDIO },
> { { USB_VENDOR_TELEX, USB_PRODUCT_TELEX_MIC1 },
> - UAUDIO_FLAG_NO_FRAC }
> + UAUDIO_FLAG_NO_FRAC },
> + { { USB_VENDOR_MAUDIO, USB_PRODUCT_MAUDIO_FASTTRACKPRO },
> + UAUDIO_FLAG_BE | UAUDIO_FLAG_DEPENDENT }
> };
> #define uaudio_lookup(v, p) \
> ((struct uaudio_devs *)usb_lookup(uaudio_devs, v, p))
> @@ -444,6 +447,11 @@ uaudio_match(struct device *parent, void
> if (uaa->iface == NULL || uaa->device == NULL)
> return (UMATCH_NONE);
>
> + if (uaa->vendor == USB_VENDOR_MAUDIO &&
> + uaa->product == USB_PRODUCT_MAUDIO_FASTTRACKPRO &&
> + uaa->configno != 2)
> + return UMATCH_NONE;
Why to you need this?
> +
> quirk = uaudio_lookup(uaa->vendor, uaa->product);
> if (quirk)
> flags = quirk->flags;
> @@ -531,8 +539,21 @@ uaudio_attach(struct device *parent, str
> found = 1;
> }
> }
> - if (found)
> + if (found) {
> usbd_claim_iface(sc->sc_udev, i);
> + if (uaa->vendor == USB_VENDOR_MAUDIO &&
> + uaa->product == USB_PRODUCT_MAUDIO_FASTTRACKPRO) {
> + /*
> + * temporarily switch every iface to 24bit.
> + * Causes the device to be big endian even
> + * for 16bit samples.
> + * using 16bits first will cause the device
> + * to break when we later switch to 24bit.
> + */
> + usbd_set_interface(sc->sc_alts[i].ifaceh, 2);
> + usbd_set_interface(sc->sc_alts[i].ifaceh, 0);
How did you figure that out? Is this behavior documented somehwere?
> + }
> + }
> }
>
> for (j = 0; j < sc->sc_nalts; j++) {
> @@ -1662,7 +1683,10 @@ uaudio_process_as(struct uaudio_softc *s
> } else if (prec == 24) {
> sc->sc_altflags |= HAS_24;
> }
> - enc = AUDIO_ENCODING_SLINEAR_LE;
> + if (sc->sc_quirks & UAUDIO_FLAG_BE)
> + enc = AUDIO_ENCODING_SLINEAR_BE;
> + else
> + enc = AUDIO_ENCODING_SLINEAR_LE;
> format_str = "pcm";
> break;
> case UA_FMT_PCM8:
> @@ -1687,9 +1711,13 @@ uaudio_process_as(struct uaudio_softc *s
> return (USBD_NORMAL_COMPLETION);
> }
> #ifdef UAUDIO_DEBUG
> - printf("%s: %s: %d-ch %d-bit %d-byte %s,", sc->sc_dev.dv_xname,
> + printf("%s: %s: alt %d(%d) for interface %d %d-ch %d-bit %d-byte %s enc
> %d,",
This line is > 80 chars.
> + sc->sc_dev.dv_xname,
> dir == UE_DIR_IN ? "recording" : "playback",
> - chan, prec, bps, format_str);
> + id->bAlternateSetting,
> + sc->sc_nalts,
> + id->bInterfaceNumber,
> + chan, prec, bps, format_str, enc);
> if (asf1d->bSamFreqType == UA_SAMP_CONTNUOUS) {
> printf(" %d-%dHz\n", UA_SAMP_LO(asf1d), UA_SAMP_HI(asf1d));
> } else {
> @@ -3312,6 +3340,9 @@ uaudio_set_params(void *addr, int setmod
> }
> break;
> }
> +
> + if (sc->sc_quirks & UAUDIO_FLAG_BE)
> + p->encoding = AUDIO_ENCODING_SLINEAR_BE;
Why do you need this chunk and we don't need to set AUDIO_ENCODING_SLINEAR_SE
in the other case?
>
> i = uaudio_match_alt(sc, p, mode);
> if (i < 0) {
> Index: umidi.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/usb/umidi.c,v
> retrieving revision 1.43
> diff -u -p -r1.43 umidi.c
> --- umidi.c 7 Jan 2017 06:10:40 -0000 1.43
> +++ umidi.c 29 Jan 2017 17:13:29 -0000
> @@ -41,6 +41,7 @@
> #include <sys/poll.h>
>
> #include <dev/usb/usb.h>
> +#include <dev/usb/usbdevs.h>
> #include <dev/usb/usbdi.h>
> #include <dev/usb/usbdi_util.h>
>
> @@ -152,6 +153,11 @@ umidi_match(struct device *parent, void
> DPRINTFN(1,("umidi_match\n"));
>
> if (uaa->iface == NULL)
> + return UMATCH_NONE;
> +
> + if (uaa->vendor == USB_VENDOR_MAUDIO &&
> + uaa->product == USB_PRODUCT_MAUDIO_FASTTRACKPRO &&
> + uaa->configno != 2)
> return UMATCH_NONE;
I'd leave the configno check out and add a comment explaining why we
want to force this driver to attach to uaudio(4).
> if (umidi_search_quirk(uaa->vendor, uaa->product, uaa->ifaceno))
> Index: usbdevs
> ===================================================================
> RCS file: /cvs/src/sys/dev/usb/usbdevs,v
> retrieving revision 1.673
> diff -u -p -r1.673 usbdevs
> --- usbdevs 15 Dec 2016 15:42:05 -0000 1.673
> +++ usbdevs 29 Jan 2017 17:13:30 -0000
> @@ -283,6 +283,7 @@ vendor DIGITALSTREAM 0x074e Digital Stre
> vendor AUREAL 0x0755 Aureal Semiconductor
> vendor IDOWELL 0x075d iDowell
> vendor MIDIMAN 0x0763 Midiman
> +vendor MAUDIO 0x0763 M-Audio
How can they have the same vendor ID? It's just the same company, so
rename the existing entry.
> vendor CYBERPOWER 0x0764 CyberPower
> vendor SURECOM 0x0769 Surecom Technology
> vendor LINKSYS2 0x077b Linksys
> @@ -3027,6 +3028,9 @@ product MICROTEK V6UL 0x80ac ScanMaker
>
> /* Midiman products */
> product MIDIMAN MIDISPORT2X2 0x1001 Midisport 2x2
> +
> +/* M-Audio products */
> +product MAUDIO FASTTRACKPRO 0x2012 FastTrack Pro
>
> /* Minds At Work LLC products */
> product MINDSATWORK DW 0x0001 Digital Wallet