Hi,

I needed to add some quirks to support the M-Audio FastTrack Pro USB
audio interface.

* The device needs to be switched to the configuration 2 to show all
  its capabilities. This is done by a new quirk in usb_subr.c
* It claims to consume little-endian samples, but actually expects
  big-endian samples.


OK?

Christopher


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    28 Jan 2017 11:53:17 -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_FASTTRACKPRO 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_MIDIMAN, USB_PRODUCT_MIDIMAN_FASTTRACKPRO },
+               UAUDIO_FLAG_FASTTRACKPRO | UAUDIO_FLAG_DEPENDENT }
 };
 #define uaudio_lookup(v, p) \
        ((struct uaudio_devs *)usb_lookup(uaudio_devs, v, p))
@@ -531,8 +534,18 @@ uaudio_attach(struct device *parent, str
                                found = 1;
                        }
                }
-               if (found)
+               if (found) {
                        usbd_claim_iface(sc->sc_udev, i);
+                       if (sc->sc_quirks & UAUDIO_FLAG_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);
+                       }
+               }
        }
 
        for (j = 0; j < sc->sc_nalts; j++) {
@@ -1662,7 +1675,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_FASTTRACKPRO)
+                       enc = AUDIO_ENCODING_SLINEAR_BE;
+               else
+                       enc = AUDIO_ENCODING_SLINEAR_LE;
                format_str = "pcm";
                break;
        case UA_FMT_PCM8:
@@ -1687,9 +1703,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,",
+              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 +3332,9 @@ uaudio_set_params(void *addr, int setmod
                        }
                        break;
                }
+
+               if (sc->sc_quirks & UAUDIO_FLAG_FASTTRACKPRO)
+                       p->encoding = AUDIO_ENCODING_SLINEAR_BE;
 
                i = uaudio_match_alt(sc, p, mode);
                if (i < 0) {
Index: usb_quirks.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/usb_quirks.c,v
retrieving revision 1.74
diff -u -p -r1.74 usb_quirks.c
--- usb_quirks.c        27 Nov 2015 10:59:32 -0000      1.74
+++ usb_quirks.c        28 Jan 2017 11:53:17 -0000
@@ -67,6 +67,8 @@ const struct usbd_quirk_entry {
        0x001, { UQ_ASSUME_CM_OVER_DATA }},
  { USB_VENDOR_EICON, USB_PRODUCT_EICON_DIVA852,
        0x100, { UQ_ASSUME_CM_OVER_DATA }},
+ { USB_VENDOR_MIDIMAN, USB_PRODUCT_MIDIMAN_FASTTRACKPRO,
+       0x100, { 1 << UQ_CONFIG_SHIFT }},
  /* YAMAHA router's ucdDevice is the version of firmware and often changes. */
  { USB_VENDOR_YAMAHA, USB_PRODUCT_YAMAHA_RTA54I,
        ANY, { UQ_ASSUME_CM_OVER_DATA }},
Index: usb_quirks.h
===================================================================
RCS file: /cvs/src/sys/dev/usb/usb_quirks.h,v
retrieving revision 1.16
diff -u -p -r1.16 usb_quirks.h
--- usb_quirks.h        19 Jul 2010 05:08:37 -0000      1.16
+++ usb_quirks.h        28 Jan 2017 11:53:17 -0000
@@ -49,6 +49,8 @@ struct usbd_quirks {
 #define UQ_MS_LEADING_BYTE     0x00010000 /* mouse sends unknown leading byte 
*/
 #define UQ_EHCI_NEEDTO_DISOWN  0x00020000 /* must hand device over to USB 1.1
                                                if attached to EHCI */
+#define        UQ_CONFIG_MASK          0x0f000000 /* needs to use specific 
configuration. */
+#define        UQ_CONFIG_SHIFT         24
 };
 
 extern const struct usbd_quirks usbd_no_quirk;
Index: usb_subr.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/usb_subr.c,v
retrieving revision 1.131
diff -u -p -r1.131 usb_subr.c
--- usb_subr.c  19 Sep 2016 16:46:10 -0000      1.131
+++ usb_subr.c  28 Jan 2017 11:53:18 -0000
@@ -906,7 +906,9 @@ usbd_probe_and_attach(struct device *par
        DPRINTF(("usbd_probe_and_attach: looping over %d configurations\n",
                 dd->bNumConfigurations));
        /* Next try with interface drivers. */
-       for (confi = 0; confi < dd->bNumConfigurations; confi++) {
+       for (confi = (dev->quirks->uq_flags & UQ_CONFIG_MASK) >> 
UQ_CONFIG_SHIFT;
+           confi < dd->bNumConfigurations; confi++)
+       {
                DPRINTFN(1,("usbd_probe_and_attach: trying config idx=%d\n",
                            confi));
                err = usbd_set_config_index(dev, confi, 1);
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     28 Jan 2017 11:53:19 -0000
@@ -3027,6 +3027,7 @@ product MICROTEK V6UL             0x80ac  ScanMaker 
 
 /* Midiman products */
 product MIDIMAN MIDISPORT2X2   0x1001  Midisport 2x2
+product MIDIMAN FASTTRACKPRO   0x2012  FastTrack Pro
 
 /* Minds At Work LLC products */
 product MINDSATWORK DW         0x0001  Digital Wallet
Index: usbdevs.h
===================================================================
RCS file: /cvs/src/sys/dev/usb/usbdevs.h,v
retrieving revision 1.685
diff -u -p -r1.685 usbdevs.h
--- usbdevs.h   15 Dec 2016 15:44:46 -0000      1.685
+++ usbdevs.h   28 Jan 2017 11:53:21 -0000
@@ -1,4 +1,4 @@
-/*     $OpenBSD: usbdevs.h,v 1.685 2016/12/15 15:44:46 pirofti Exp $   */
+/*     $OpenBSD$       */
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
@@ -3034,6 +3034,7 @@
 
 /* Midiman products */
 #define        USB_PRODUCT_MIDIMAN_MIDISPORT2X2        0x1001          /* 
Midisport 2x2 */
+#define        USB_PRODUCT_MIDIMAN_FASTTRACKPRO        0x2012          /* 
FastTrack Pro */
 
 /* Minds At Work LLC products */
 #define        USB_PRODUCT_MINDSATWORK_DW      0x0001          /* Digital 
Wallet */
Index: usbdevs_data.h
===================================================================
RCS file: /cvs/src/sys/dev/usb/usbdevs_data.h,v
retrieving revision 1.679
diff -u -p -r1.679 usbdevs_data.h
--- usbdevs_data.h      15 Dec 2016 15:44:46 -0000      1.679
+++ usbdevs_data.h      28 Jan 2017 11:53:23 -0000
@@ -1,4 +1,4 @@
-/*     $OpenBSD: usbdevs_data.h,v 1.679 2016/12/15 15:44:46 pirofti Exp $      
*/
+/*     $OpenBSD$       */
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
@@ -7332,6 +7332,10 @@ const struct usb_known_product usb_known
        {
            USB_VENDOR_MIDIMAN, USB_PRODUCT_MIDIMAN_MIDISPORT2X2,
            "Midisport 2x2",
+       },
+       {
+           USB_VENDOR_MIDIMAN, USB_PRODUCT_MIDIMAN_FASTTRACKPRO,
+           "FastTrack Pro",
        },
        {
            USB_VENDOR_MINDSATWORK, USB_PRODUCT_MINDSATWORK_DW,



-- 
http://gmerlin.de
OpenPGP: http://gmerlin.de/christopher.pub
2779 7F73 44FD 0736 B67A  C410 69EC 7922 34B4 2566

Attachment: pgpEmsq1Rqi9u.pgp
Description: OpenPGP digital signature

Reply via email to