On 2017-01-30 Martin Pieuchot <m...@openbsd.org> wrote:
> On 29/01/17(Sun) 14:45, Christopher Zimmermann wrote:
> 
> > You are talking about usb_subr.c? Done.  
> 
> No I'm not :)

> Yes please, do not touch usb_subr.c.  

> Also make sure your comment below respect style(9).

ok. I got it. I added conditions to uaudio.c and umidi.c to accept the
device only in configuration 2.
The quirks in uaudio.c stay the same.

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    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;
+
        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);
+                       }
+               }
        }
 
        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,",
+              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;
 
                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;
 
        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
 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
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   29 Jan 2017 17:13:32 -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.
@@ -290,6 +290,7 @@
 #define        USB_VENDOR_AUREAL       0x0755          /* Aureal Semiconductor 
*/
 #define        USB_VENDOR_IDOWELL      0x075d          /* iDowell */
 #define        USB_VENDOR_MIDIMAN      0x0763          /* Midiman */
+#define        USB_VENDOR_MAUDIO       0x0763          /* M-Audio */
 #define        USB_VENDOR_CYBERPOWER   0x0764          /* CyberPower */
 #define        USB_VENDOR_SURECOM      0x0769          /* Surecom Technology */
 #define        USB_VENDOR_LINKSYS2     0x077b          /* Linksys */
@@ -3034,6 +3035,9 @@
 
 /* Midiman products */
 #define        USB_PRODUCT_MIDIMAN_MIDISPORT2X2        0x1001          /* 
Midisport 2x2 */
+
+/* M-Audio products */
+#define        USB_PRODUCT_MAUDIO_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      29 Jan 2017 17:13:34 -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.
@@ -7334,6 +7334,10 @@ const struct usb_known_product usb_known
            "Midisport 2x2",
        },
        {
+           USB_VENDOR_MAUDIO, USB_PRODUCT_MAUDIO_FASTTRACKPRO,
+           "FastTrack Pro",
+       },
+       {
            USB_VENDOR_MINDSATWORK, USB_PRODUCT_MINDSATWORK_DW,
            "Digital Wallet",
        },
@@ -12484,6 +12488,10 @@ const struct usb_known_vendor usb_known_
        {
            USB_VENDOR_MIDIMAN,
            "Midiman",
+       },
+       {
+           USB_VENDOR_MAUDIO,
+           "M-Audio",
        },
        {
            USB_VENDOR_CYBERPOWER,



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

Attachment: pgpU5vy6E2vZT.pgp
Description: OpenPGP digital signature

Reply via email to