root/dev/usb/umidi_quirks.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. umidi_search_quirk
  2. umidi_print_quirk
  3. umidi_get_quirk_data_from_type

    1 /*      $OpenBSD: umidi_quirks.c,v 1.8 2007/05/05 16:31:27 krw Exp $    */
    2 /*      $NetBSD: umidi_quirks.c,v 1.4 2002/06/19 13:55:30 tshiozak Exp $        */
    3 
    4 /*
    5  * Copyright (c) 2001 The NetBSD Foundation, Inc.
    6  * All rights reserved.
    7  *
    8  * This code is derived from software contributed to The NetBSD Foundation
    9  * by Takuya SHIOZAKI (tshiozak@netbsd.org).
   10  *
   11  * Redistribution and use in source and binary forms, with or without
   12  * modification, are permitted provided that the following conditions
   13  * are met:
   14  * 1. Redistributions of source code must retain the above copyright
   15  *    notice, this list of conditions and the following disclaimer.
   16  * 2. Redistributions in binary form must reproduce the above copyright
   17  *    notice, this list of conditions and the following disclaimer in the
   18  *    documentation and/or other materials provided with the distribution.
   19  * 3. All advertising materials mentioning features or use of this software
   20  *    must display the following acknowledgement:
   21  *        This product includes software developed by the NetBSD
   22  *        Foundation, Inc. and its contributors.
   23  * 4. Neither the name of The NetBSD Foundation nor the names of its
   24  *    contributors may be used to endorse or promote products derived
   25  *    from this software without specific prior written permission.
   26  *
   27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   37  * POSSIBILITY OF SUCH DAMAGE.
   38  */
   39 
   40 #include <sys/param.h>
   41 #include <sys/systm.h>
   42 #include <sys/kernel.h>
   43 #include <sys/malloc.h>
   44 #include <sys/device.h>
   45 #include <sys/ioctl.h>
   46 #include <sys/conf.h>
   47 #include <sys/file.h>
   48 #include <sys/selinfo.h>
   49 #include <sys/proc.h>
   50 #include <sys/vnode.h>
   51 #include <sys/poll.h>
   52 
   53 #include <dev/usb/usb.h>
   54 #include <dev/usb/usbdi.h>
   55 #include <dev/usb/usbdi_util.h>
   56 
   57 #include <dev/usb/usbdevs.h>
   58 #include <dev/usb/uaudioreg.h>
   59 #include <dev/usb/umidireg.h>
   60 #include <dev/usb/umidivar.h>
   61 #include <dev/usb/umidi_quirks.h>
   62 
   63 /*
   64  * quirk codes for UMIDI
   65  */
   66 
   67 #ifdef UMIDIQUIRK_DEBUG
   68 #define DPRINTF(x)      if (umidiquirkdebug) printf x
   69 #define DPRINTFN(n,x)   if (umidiquirkdebug >= (n)) printf x
   70 int     umidiquirkdebug = 1;
   71 #else
   72 #define DPRINTF(x)
   73 #define DPRINTFN(n,x)
   74 #endif
   75 
   76 
   77 /*
   78  * YAMAHA UX-256
   79  *  --- this is a typical yamaha device, but has a broken descriptor :-<
   80  */
   81 
   82 UMQ_FIXED_EP_DEF(YAMAHA, YAMAHA_UX256, ANYIFACE, 1, 1) = {
   83         /* out */
   84         { 0, 16 },
   85         /* in */
   86         { 1, 8 }
   87 };
   88 
   89 UMQ_DEF(YAMAHA, YAMAHA_UX256, ANYIFACE) = {
   90         UMQ_FIXED_EP_REG(YAMAHA, YAMAHA_UX256, ANYIFACE),
   91 #if 0
   92         UMQ_YAMAHA_REG(YAMAHA, ANYPRODUCT, ANYIFACE),
   93 #endif
   94         UMQ_TERMINATOR
   95 };
   96 
   97 
   98 /*
   99  * YAMAHA generic
  100  */
  101 UMQ_DEF(YAMAHA, ANYPRODUCT, ANYIFACE) = {
  102         UMQ_YAMAHA_REG(YAMAHA, ANYPRODUCT, ANYIFACE),
  103         UMQ_TERMINATOR
  104 };
  105 
  106 
  107 /*
  108  * ROLAND UM-1
  109  */
  110 UMQ_FIXED_EP_DEF(ROLAND, ROLAND_UM1, 2, 1, 1) = {
  111         /* out */
  112         { 0, 1 },
  113         /* in */
  114         { 1, 1 }
  115 };
  116 
  117 UMQ_DEF(ROLAND, ROLAND_UM1, 2) = {
  118         UMQ_FIXED_EP_REG(ROLAND, ROLAND_UM1, 2),
  119         UMQ_TERMINATOR
  120 };
  121 
  122 /*
  123  * ROLAND SC-8850
  124  */
  125 UMQ_FIXED_EP_DEF(ROLAND, ROLAND_SC8850, 2, 1, 1) = {
  126         /* out */
  127         { 0, 6 },
  128         /* in */
  129         { 1, 6 }
  130 };
  131 
  132 UMQ_DEF(ROLAND, ROLAND_SC8850, 2) = {
  133         UMQ_FIXED_EP_REG(ROLAND, ROLAND_SC8850, 2),
  134         UMQ_TERMINATOR
  135 };
  136 
  137 /*
  138  * ROLAND SD-90
  139  */
  140 UMQ_FIXED_EP_DEF(ROLAND, ROLAND_SD90, 2, 1, 1) = {
  141         /* out */
  142         { 0, 4 },
  143         /* in */
  144         { 1, 4 }
  145 };
  146 
  147 UMQ_DEF(ROLAND, ROLAND_SD90, 2) = {
  148         UMQ_FIXED_EP_REG(ROLAND, ROLAND_SD90, 2),
  149         UMQ_TERMINATOR
  150 };
  151 
  152 
  153 /*
  154  * ROLAND UM-880 (native mode)
  155  */
  156 UMQ_FIXED_EP_DEF(ROLAND, ROLAND_UM880N, 0, 1, 1) = {
  157         /* out */
  158         { 0, 9 },
  159         /* in */
  160         { 1, 9 }
  161 };
  162 
  163 UMQ_DEF(ROLAND, ROLAND_UM880N, 0) = {
  164         UMQ_FIXED_EP_REG(ROLAND, ROLAND_UM880N, 0),
  165         UMQ_TERMINATOR
  166 };
  167 
  168 /*
  169  * ROLAND UA-100
  170  */
  171 UMQ_FIXED_EP_DEF(ROLAND, ROLAND_UA100, 2, 1, 1) = {
  172         /* out */
  173         { 0, 3 },
  174         /* in */
  175         { 1, 3 }
  176 };
  177 
  178 UMQ_DEF(ROLAND, ROLAND_UA100, 2) = {
  179         UMQ_FIXED_EP_REG(ROLAND, ROLAND_UA100, 2),
  180         UMQ_TERMINATOR
  181 };
  182 
  183 /*
  184  * ROLAND UM-4
  185  */
  186 UMQ_FIXED_EP_DEF(ROLAND, ROLAND_UM4, 2, 1, 1) = {
  187         /* out */
  188         { 0, 4 },
  189         /* in */
  190         { 1, 4 }
  191 };
  192 
  193 UMQ_DEF(ROLAND, ROLAND_UM4, 2) = {
  194         UMQ_FIXED_EP_REG(ROLAND, ROLAND_UM4, 2),
  195         UMQ_TERMINATOR
  196 };
  197 
  198 /*
  199  * ROLAND U-8
  200  */
  201 UMQ_FIXED_EP_DEF(ROLAND, ROLAND_U8, 2, 1, 1) = {
  202         /* out */
  203         { 0, 2 },
  204         /* in */
  205         { 1, 2 }
  206 };
  207 
  208 UMQ_DEF(ROLAND, ROLAND_U8, 2) = {
  209         UMQ_FIXED_EP_REG(ROLAND, ROLAND_U8, 2),
  210         UMQ_TERMINATOR
  211 };
  212 
  213 /*
  214  * ROLAND UM-2
  215  */
  216 UMQ_FIXED_EP_DEF(ROLAND, ROLAND_UM2, 2, 1, 1) = {
  217         /* out */
  218         { 0, 2 },
  219         /* in */
  220         { 1, 2 }
  221 };
  222 
  223 UMQ_DEF(ROLAND, ROLAND_UM2, 2) = {
  224         UMQ_FIXED_EP_REG(ROLAND, ROLAND_UM2, 2),
  225         UMQ_TERMINATOR
  226 };
  227 
  228 /*
  229  * ROLAND SC-8820
  230  */
  231 UMQ_FIXED_EP_DEF(ROLAND, ROLAND_SC8820, 2, 1, 1) = {
  232         /* out */
  233         { 0, 5 }, /* cables 0, 1, 4 only */
  234         /* in */
  235         { 1, 5 } /* do. */
  236 };
  237 
  238 UMQ_DEF(ROLAND, ROLAND_SC8820, 2) = {
  239         UMQ_FIXED_EP_REG(ROLAND, ROLAND_SC8820, 2),
  240         UMQ_TERMINATOR
  241 };
  242 
  243 /*
  244  * ROLAND PC-300
  245  */
  246 UMQ_FIXED_EP_DEF(ROLAND, ROLAND_PC300, 2, 1, 1) = {
  247         /* out */
  248         { 0, 1 },
  249         /* in */
  250         { 1, 1 }
  251 };
  252 
  253 UMQ_DEF(ROLAND, ROLAND_PC300, 2) = {
  254         UMQ_FIXED_EP_REG(ROLAND, ROLAND_PC300, 2),
  255         UMQ_TERMINATOR
  256 };
  257 
  258 /*
  259  * ROLAND SK-500
  260  */
  261 UMQ_FIXED_EP_DEF(ROLAND, ROLAND_SK500, 2, 1, 1) = {
  262         /* out */
  263         { 0, 5 }, /* cables 0, 1, 4 only */
  264         /* in */
  265         { 1, 5 } /* do. */
  266 };
  267 
  268 UMQ_DEF(ROLAND, ROLAND_SK500, 2) = {
  269         UMQ_FIXED_EP_REG(ROLAND, ROLAND_SK500, 2),
  270         UMQ_TERMINATOR
  271 };
  272 
  273 /*
  274  * ROLAND SC-D70
  275  */
  276 UMQ_FIXED_EP_DEF(ROLAND, ROLAND_SCD70, 2, 1, 1) = {
  277         /* out */
  278         { 0, 3 },
  279         /* in */
  280         { 1, 3 }
  281 };
  282 
  283 UMQ_DEF(ROLAND, ROLAND_SCD70, 2) = {
  284         UMQ_FIXED_EP_REG(ROLAND, ROLAND_SCD70, 2),
  285         UMQ_TERMINATOR
  286 };
  287 
  288 /*
  289  * ROLAND UM-550
  290  */
  291 UMQ_FIXED_EP_DEF(ROLAND, ROLAND_UM550, 0, 1, 1) = {
  292         /* out */
  293         { 0, 6 },
  294         /* in */
  295         { 1, 6 }
  296 };
  297 
  298 UMQ_DEF(ROLAND, ROLAND_UM550, 0) = {
  299         UMQ_FIXED_EP_REG(ROLAND, ROLAND_UM550, 0),
  300         UMQ_TERMINATOR
  301 };
  302 
  303 /*
  304  * ROLAND SD-20
  305  */
  306 UMQ_FIXED_EP_DEF(ROLAND, ROLAND_SD20, 0, 1, 1) = {
  307         /* out */
  308         { 0, 2 },
  309         /* in */
  310         { 1, 3 }
  311 };
  312 
  313 UMQ_DEF(ROLAND, ROLAND_SD20, 0) = {
  314         UMQ_FIXED_EP_REG(ROLAND, ROLAND_SD20, 0),
  315         UMQ_TERMINATOR
  316 };
  317 
  318 /*
  319  * ROLAND SD-80
  320  */
  321 UMQ_FIXED_EP_DEF(ROLAND, ROLAND_SD80, 0, 1, 1) = {
  322         /* out */
  323         { 0, 4 },
  324         /* in */
  325         { 1, 4 }
  326 };
  327 
  328 UMQ_DEF(ROLAND, ROLAND_SD80, 0) = {
  329         UMQ_FIXED_EP_REG(ROLAND, ROLAND_SD80, 0),
  330         UMQ_TERMINATOR
  331 };
  332 
  333 /*
  334  * ROLAND UA-700
  335  */
  336 UMQ_FIXED_EP_DEF(ROLAND, ROLAND_UA700, 3, 1, 1) = {
  337         /* out */
  338         { 0, 2 },
  339         /* in */
  340         { 1, 2 }
  341 };
  342 
  343 UMQ_DEF(ROLAND, ROLAND_UA700, 3) = {
  344         UMQ_FIXED_EP_REG(ROLAND, ROLAND_UA700, 3),
  345         UMQ_TERMINATOR
  346 };
  347 
  348 
  349 /*
  350  * quirk list
  351  */
  352 struct umidi_quirk umidi_quirklist[] = {
  353         UMQ_REG(YAMAHA, YAMAHA_UX256, ANYIFACE),
  354         UMQ_REG(YAMAHA, ANYPRODUCT, ANYIFACE),
  355         UMQ_REG(ROLAND, ROLAND_UM1, 2),
  356         UMQ_REG(ROLAND, ROLAND_SC8850, 2),
  357         UMQ_REG(ROLAND, ROLAND_SD90, 2),
  358         UMQ_REG(ROLAND, ROLAND_UM880N, 0),
  359         UMQ_REG(ROLAND, ROLAND_UA100, 2),
  360         UMQ_REG(ROLAND, ROLAND_UM4, 2),
  361         UMQ_REG(ROLAND, ROLAND_U8, 2),
  362         UMQ_REG(ROLAND, ROLAND_UM2, 2),
  363         UMQ_REG(ROLAND, ROLAND_SC8820, 2),
  364         UMQ_REG(ROLAND, ROLAND_PC300, 2),
  365         UMQ_REG(ROLAND, ROLAND_SK500, 2),
  366         UMQ_REG(ROLAND, ROLAND_SCD70, 2),
  367         UMQ_REG(ROLAND, ROLAND_UM550, 0),
  368         UMQ_REG(ROLAND, ROLAND_SD20, 0),
  369         UMQ_REG(ROLAND, ROLAND_SD80, 0),
  370         UMQ_REG(ROLAND, ROLAND_UA700, 3),
  371         UMQ_TERMINATOR
  372 };
  373 
  374 
  375 /*
  376  * quirk utilities
  377  */
  378 
  379 struct umidi_quirk *
  380 umidi_search_quirk(int vendor, int product, int ifaceno)
  381 {
  382         struct umidi_quirk *p;
  383         struct umq_data *q;
  384 
  385         DPRINTF(("umidi_search_quirk: v=%d, p=%d, i=%d\n",
  386                  vendor, product, ifaceno));
  387 
  388         for (p=&umidi_quirklist[0]; p->vendor; p++) {
  389                 DPRINTFN(10, ("\tv=%d, p=%d, i=%d",
  390                               p->vendor, p->product, p->iface));
  391                 if ((p->vendor==vendor || p->vendor==ANYVENDOR) &&
  392                     (p->product==product || p->product==ANYPRODUCT) &&
  393                     (p->iface==ifaceno || p->iface==ANYIFACE)) {
  394                         DPRINTFN(10, (" found\n"));
  395                         if (!p->type_mask)
  396                                 /* make quirk mask */
  397                                 for (q=p->quirks; q->type; q++)
  398                                         p->type_mask |= 1<<(q->type-1);
  399                         return p;
  400                 }
  401                 DPRINTFN(10, ("\n"));
  402         }
  403 
  404         return NULL;
  405 }
  406 
  407 static char *quirk_name[] = {
  408         "NULL",
  409         "Fixed Endpoint",
  410         "Yamaha Specific",
  411 };
  412 
  413 void
  414 umidi_print_quirk(struct umidi_quirk *q)
  415 {
  416         struct umq_data *qd;
  417         if (q) {
  418                 printf("(");
  419                 for (qd=q->quirks; qd->type; qd++)
  420                         printf("%s%s", quirk_name[qd->type],
  421                                (qd+1)->type?", ":")\n");
  422         } else {
  423                 printf("(genuine USB-MIDI)\n");
  424         }
  425 }
  426 
  427 void *
  428 umidi_get_quirk_data_from_type(struct umidi_quirk *q, u_int32_t type)
  429 {
  430         struct umq_data *qd;
  431         if (q) {
  432                 for (qd=q->quirks; qd->type; qd++)
  433                         if (qd->type == type)
  434                                 return qd->data;
  435         }
  436         return NULL;
  437 }

/* [<][>][^][v][top][bottom][index][help] */