Hi, below you find an updated diff. OK?
On 2017-01-29 Martin Pieuchot <m...@openbsd.org> wrote: > On 29/01/17(Sun) 19:33, Christopher Zimmermann wrote: > > [...] > > @@ -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? This device exposes only a very limited set of features in configuration 1. To force usb_subr.c:usbd_probe_and_attach() to try configuration 2 both uaudio and umidi must attach to the device only configuration 2. Otherwise one will claim the device and other configurations won't be tried. > > @@ -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? It's not documented. I did not find a similar hack in the linux driver. Still its a reproducable behaviour. > > @@ -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_LE in the other case? We probably should set it to _LE in the other case. I moved this piece of code into uaudio_match_alt() and made it agnostic about the specific endianness. > > @@ -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). See my comment above about the same piece of code in uaudio.c. If I don't add this condition umidi will attach to configuration 1 and configuration 2 wouldn't be tried, uaudio wouldn't attach. Here's the updated diff: 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 31 Jan 2017 12:37:46 -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_MIDIMAN, USB_PRODUCT_MIDIMAN_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_MIDIMAN && + uaa->product == USB_PRODUCT_MIDIMAN_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_MIDIMAN && + uaa->product == USB_PRODUCT_MIDIMAN_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: @@ -3180,11 +3209,18 @@ uaudio_match_alt(void *addr, struct audi continue; DPRINTFN(6,("%s: matched %s alt %d for direction\n", __func__, mode == AUMODE_RECORD ? "rec" : "play", i)); - if (sc->sc_alts[i].encoding != p->encoding) - continue; a1d = sc->sc_alts[i].asf1desc; if (a1d->bBitResolution != p->precision) continue; + if (p->precision > 8) + /* + * Don't search for matching encoding. + * Just tell the upper layers which one we support. + */ + p->encoding = sc->sc_alts[i].encoding; + else if (p->encoding != sc->sc_alts[i].encoding) + continue; + alts_eh |= 1 << i; DPRINTFN(6,("%s: matched %s alt %d for enc/pre\n", __func__, mode == AUMODE_RECORD ? "rec" : "play", i)); 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 31 Jan 2017 12:37:46 -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_MIDIMAN && + uaa->product == USB_PRODUCT_MIDIMAN_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 31 Jan 2017 12:37:48 -0000 @@ -282,7 +282,7 @@ vendor SYNTECH 0x0745 Syntech Informati vendor DIGITALSTREAM 0x074e Digital Stream vendor AUREAL 0x0755 Aureal Semiconductor vendor IDOWELL 0x075d iDowell -vendor MIDIMAN 0x0763 Midiman +vendor MIDIMAN 0x0763 M-Audio / former Midiman vendor CYBERPOWER 0x0764 CyberPower vendor SURECOM 0x0769 Surecom Technology vendor LINKSYS2 0x077b Linksys @@ -3027,6 +3027,9 @@ product MICROTEK V6UL 0x80ac ScanMaker /* Midiman products */ product MIDIMAN MIDISPORT2X2 0x1001 Midisport 2x2 + +/* M-Audio products */ +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 31 Jan 2017 12:37:50 -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. @@ -289,7 +289,7 @@ #define USB_VENDOR_DIGITALSTREAM 0x074e /* Digital Stream */ #define USB_VENDOR_AUREAL 0x0755 /* Aureal Semiconductor */ #define USB_VENDOR_IDOWELL 0x075d /* iDowell */ -#define USB_VENDOR_MIDIMAN 0x0763 /* Midiman */ +#define USB_VENDOR_MIDIMAN 0x0763 /* M-Audio / former Midiman */ #define USB_VENDOR_CYBERPOWER 0x0764 /* CyberPower */ #define USB_VENDOR_SURECOM 0x0769 /* Surecom Technology */ #define USB_VENDOR_LINKSYS2 0x077b /* Linksys */ @@ -3034,6 +3034,9 @@ /* Midiman products */ #define USB_PRODUCT_MIDIMAN_MIDISPORT2X2 0x1001 /* Midisport 2x2 */ + +/* M-Audio products */ +#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 31 Jan 2017 12:37:52 -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_MIDIMAN, USB_PRODUCT_MIDIMAN_FASTTRACKPRO, + "FastTrack Pro", + }, + { USB_VENDOR_MINDSATWORK, USB_PRODUCT_MINDSATWORK_DW, "Digital Wallet", }, @@ -12483,7 +12487,7 @@ const struct usb_known_vendor usb_known_ }, { USB_VENDOR_MIDIMAN, - "Midiman", + "M-Audio / former Midiman", }, { USB_VENDOR_CYBERPOWER, -- http://gmerlin.de OpenPGP: http://gmerlin.de/christopher.pub 2779 7F73 44FD 0736 B67A C410 69EC 7922 34B4 2566
pgp_oTIYkN8tF.pgp
Description: OpenPGP digital signature