[BACK]Return to umidi.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / dev / usb

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/dev/usb/umidi.c between version 1.35 and 1.35.4.3

version 1.35, 2008/04/05 16:35:35 version 1.35.4.3, 2010/03/11 15:04:07
Line 15 
Line 15 
  * 2. Redistributions in binary form must reproduce the above copyright   * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the   *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.   *    documentation and/or other materials provided with the distribution.
  * 3. All advertising materials mentioning features or use of this software  
  *    must display the following acknowledgement:  
  *        This product includes software developed by the NetBSD  
  *        Foundation, Inc. and its contributors.  
  * 4. Neither the name of The NetBSD Foundation nor the names of its  
  *    contributors may be used to endorse or promote products derived  
  *    from this software without specific prior written permission.  
  *   *
  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS   * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
Line 111  static void close_in_jack(struct umidi_j
Line 104  static void close_in_jack(struct umidi_j
   
 static usbd_status attach_mididev(struct umidi_softc *, struct umidi_mididev *);  static usbd_status attach_mididev(struct umidi_softc *, struct umidi_mididev *);
 static usbd_status detach_mididev(struct umidi_mididev *, int);  static usbd_status detach_mididev(struct umidi_mididev *, int);
 static usbd_status deactivate_mididev(struct umidi_mididev *);  static void deactivate_mididev(struct umidi_mididev *);
 static usbd_status alloc_all_mididevs(struct umidi_softc *, int);  static usbd_status alloc_all_mididevs(struct umidi_softc *, int);
 static void free_all_mididevs(struct umidi_softc *);  static void free_all_mididevs(struct umidi_softc *);
 static usbd_status attach_all_mididevs(struct umidi_softc *);  static usbd_status attach_all_mididevs(struct umidi_softc *);
 static usbd_status detach_all_mididevs(struct umidi_softc *, int);  static usbd_status detach_all_mididevs(struct umidi_softc *, int);
 static usbd_status deactivate_all_mididevs(struct umidi_softc *);  static void deactivate_all_mididevs(struct umidi_softc *);
 static char *describe_mididev(struct umidi_mididev *);  static char *describe_mididev(struct umidi_mididev *);
   
 #ifdef UMIDI_DEBUG  #ifdef UMIDI_DEBUG
Line 154  struct midi_hw_if_ext umidi_hw_if_mm = {
Line 147  struct midi_hw_if_ext umidi_hw_if_mm = {
         .compress = 1,          .compress = 1,
 };  };
   
 int umidi_match(device_t, struct cfdata *, void *);  int umidi_match(device_t, cfdata_t, void *);
 void umidi_attach(device_t, device_t, void *);  void umidi_attach(device_t, device_t, void *);
 void umidi_childdet(device_t, device_t);  void umidi_childdet(device_t, device_t);
 int umidi_detach(device_t, int);  int umidi_detach(device_t, int);
 int umidi_activate(device_t, enum devact);  int umidi_activate(device_t, enum devact);
 extern struct cfdriver umidi_cd;  extern struct cfdriver umidi_cd;
 CFATTACH_DECL2(umidi, sizeof(struct umidi_softc), umidi_match,  CFATTACH_DECL2_NEW(umidi, sizeof(struct umidi_softc), umidi_match,
     umidi_attach, umidi_detach, umidi_activate, NULL, umidi_childdet);      umidi_attach, umidi_detach, umidi_activate, NULL, umidi_childdet);
   
 USB_MATCH(umidi)  USB_MATCH(umidi)
Line 187  USB_ATTACH(umidi)
Line 180  USB_ATTACH(umidi)
   
         DPRINTFN(1,("umidi_attach\n"));          DPRINTFN(1,("umidi_attach\n"));
   
           sc->sc_dev = self;
   
         devinfop = usbd_devinfo_alloc(uaa->device, 0);          devinfop = usbd_devinfo_alloc(uaa->device, 0);
         printf("\n%s: %s\n", USBDEVNAME(sc->sc_dev), devinfop);          aprint_normal("%s\n", devinfop);
         usbd_devinfo_free(devinfop);          usbd_devinfo_free(devinfop);
   
         sc->sc_iface = uaa->iface;          sc->sc_iface = uaa->iface;
Line 196  USB_ATTACH(umidi)
Line 191  USB_ATTACH(umidi)
   
         sc->sc_quirk =          sc->sc_quirk =
             umidi_search_quirk(uaa->vendor, uaa->product, uaa->ifaceno);              umidi_search_quirk(uaa->vendor, uaa->product, uaa->ifaceno);
         printf("%s: ", USBDEVNAME(sc->sc_dev));          aprint_normal_dev(self, "");
         umidi_print_quirk(sc->sc_quirk);          umidi_print_quirk(sc->sc_quirk);
   
   
         err = alloc_all_endpoints(sc);          err = alloc_all_endpoints(sc);
         if (err!=USBD_NORMAL_COMPLETION) {          if (err!=USBD_NORMAL_COMPLETION) {
                 printf("%s: alloc_all_endpoints failed. (err=%d)\n",                  aprint_error_dev(self,
                        USBDEVNAME(sc->sc_dev), err);                      "alloc_all_endpoints failed. (err=%d)\n", err);
                 goto error;                  goto error;
         }          }
         err = alloc_all_jacks(sc);          err = alloc_all_jacks(sc);
         if (err!=USBD_NORMAL_COMPLETION) {          if (err!=USBD_NORMAL_COMPLETION) {
                 free_all_endpoints(sc);                  free_all_endpoints(sc);
                 printf("%s: alloc_all_jacks failed. (err=%d)\n",                  aprint_error_dev(self, "alloc_all_jacks failed. (err=%d)\n",
                        USBDEVNAME(sc->sc_dev), err);                      err);
                 goto error;                  goto error;
         }          }
         printf("%s: out=%d, in=%d\n",          aprint_normal_dev(self, "out=%d, in=%d\n",
                USBDEVNAME(sc->sc_dev),  
                sc->sc_out_num_jacks, sc->sc_in_num_jacks);                 sc->sc_out_num_jacks, sc->sc_in_num_jacks);
   
         err = assign_all_jacks_automatically(sc);          err = assign_all_jacks_automatically(sc);
Line 222  USB_ATTACH(umidi)
Line 216  USB_ATTACH(umidi)
                 unbind_all_jacks(sc);                  unbind_all_jacks(sc);
                 free_all_jacks(sc);                  free_all_jacks(sc);
                 free_all_endpoints(sc);                  free_all_endpoints(sc);
                 printf("%s: assign_all_jacks_automatically failed. (err=%d)\n",                  aprint_error_dev(self,
                        USBDEVNAME(sc->sc_dev), err);                      "assign_all_jacks_automatically failed. (err=%d)\n", err);
                 goto error;                  goto error;
         }          }
         err = attach_all_mididevs(sc);          err = attach_all_mididevs(sc);
         if (err!=USBD_NORMAL_COMPLETION) {          if (err!=USBD_NORMAL_COMPLETION) {
                 free_all_jacks(sc);                  free_all_jacks(sc);
                 free_all_endpoints(sc);                  free_all_endpoints(sc);
                 printf("%s: attach_all_mididevs failed. (err=%d)\n",                  aprint_error_dev(self,
                        USBDEVNAME(sc->sc_dev), err);                      "attach_all_mididevs failed. (err=%d)\n", err);
         }          }
   
 #ifdef UMIDI_DEBUG  #ifdef UMIDI_DEBUG
Line 243  USB_ATTACH(umidi)
Line 237  USB_ATTACH(umidi)
   
         USB_ATTACH_SUCCESS_RETURN;          USB_ATTACH_SUCCESS_RETURN;
 error:  error:
         printf("%s: disabled.\n", USBDEVNAME(sc->sc_dev));          aprint_error_dev(self, "disabled.\n");
         sc->sc_dying = 1;          sc->sc_dying = 1;
         USB_ATTACH_ERROR_RETURN;          USB_ATTACH_ERROR_RETURN;
 }  }
Line 270  umidi_activate(device_t self, enum devac
Line 264  umidi_activate(device_t self, enum devac
         struct umidi_softc *sc = device_private(self);          struct umidi_softc *sc = device_private(self);
   
         switch (act) {          switch (act) {
         case DVACT_ACTIVATE:  
                 DPRINTFN(1,("umidi_activate (activate)\n"));  
   
                 return EOPNOTSUPP;  
                 break;  
         case DVACT_DEACTIVATE:          case DVACT_DEACTIVATE:
                 DPRINTFN(1,("umidi_activate (deactivate)\n"));                  DPRINTFN(1,("umidi_activate (deactivate)\n"));
                 sc->sc_dying = 1;                  sc->sc_dying = 1;
                 deactivate_all_mididevs(sc);                  deactivate_all_mididevs(sc);
                 break;                  return 0;
           default:
                   DPRINTFN(1,("umidi_activate (%d)\n", act));
                   return EOPNOTSUPP;
         }          }
         return 0;  
 }  }
   
 USB_DETACH(umidi)  USB_DETACH(umidi)
Line 558  static usbd_status
Line 549  static usbd_status
 alloc_all_endpoints_fixed_ep(struct umidi_softc *sc)  alloc_all_endpoints_fixed_ep(struct umidi_softc *sc)
 {  {
         usbd_status err;          usbd_status err;
         struct umq_fixed_ep_desc *fp;          const struct umq_fixed_ep_desc *fp;
         struct umidi_endpoint *ep;          struct umidi_endpoint *ep;
         usb_endpoint_descriptor_t *epd;          usb_endpoint_descriptor_t *epd;
         int i;          int i;
Line 587  alloc_all_endpoints_fixed_ep(struct umid
Line 578  alloc_all_endpoints_fixed_ep(struct umid
                         sc->sc_iface,                          sc->sc_iface,
                         fp->out_ep[i].ep);                          fp->out_ep[i].ep);
                 if (!epd) {                  if (!epd) {
                         printf("%s: cannot get endpoint descriptor(out:%d)\n",                          aprint_error_dev(sc->sc_dev,
                                USBDEVNAME(sc->sc_dev), fp->out_ep[i].ep);                              "cannot get endpoint descriptor(out:%d)\n",
                                fp->out_ep[i].ep);
                         err = USBD_INVAL;                          err = USBD_INVAL;
                         goto error;                          goto error;
                 }                  }
                 if (UE_GET_XFERTYPE(epd->bmAttributes)!=UE_BULK ||                  if (UE_GET_XFERTYPE(epd->bmAttributes)!=UE_BULK ||
                     UE_GET_DIR(epd->bEndpointAddress)!=UE_DIR_OUT) {                      UE_GET_DIR(epd->bEndpointAddress)!=UE_DIR_OUT) {
                         printf("%s: illegal endpoint(out:%d)\n",                          aprint_error_dev(sc->sc_dev, "illegal endpoint(out:%d)\n",
                                USBDEVNAME(sc->sc_dev), fp->out_ep[i].ep);                              fp->out_ep[i].ep);
                         err = USBD_INVAL;                          err = USBD_INVAL;
                         goto error;                          goto error;
                 }                  }
Line 613  alloc_all_endpoints_fixed_ep(struct umid
Line 605  alloc_all_endpoints_fixed_ep(struct umid
                         sc->sc_iface,                          sc->sc_iface,
                         fp->in_ep[i].ep);                          fp->in_ep[i].ep);
                 if (!epd) {                  if (!epd) {
                         printf("%s: cannot get endpoint descriptor(in:%d)\n",                          aprint_error_dev(sc->sc_dev,
                                USBDEVNAME(sc->sc_dev), fp->in_ep[i].ep);                              "cannot get endpoint descriptor(in:%d)\n",
                                fp->in_ep[i].ep);
                         err = USBD_INVAL;                          err = USBD_INVAL;
                         goto error;                          goto error;
                 }                  }
Line 634  alloc_all_endpoints_fixed_ep(struct umid
Line 627  alloc_all_endpoints_fixed_ep(struct umid
                                 break;                                  break;
                         /*FALLTHROUGH*/                          /*FALLTHROUGH*/
                 default:                  default:
                         printf("%s: illegal endpoint(in:%d)\n",                          aprint_error_dev(sc->sc_dev,
                                USBDEVNAME(sc->sc_dev), fp->in_ep[i].ep);                              "illegal endpoint(in:%d)\n", fp->in_ep[i].ep);
                         err = USBD_INVAL;                          err = USBD_INVAL;
                         goto error;                          goto error;
                 }                  }
Line 854  alloc_all_jacks(struct umidi_softc *sc)
Line 847  alloc_all_jacks(struct umidi_softc *sc)
         int i, j;          int i, j;
         struct umidi_endpoint *ep;          struct umidi_endpoint *ep;
         struct umidi_jack *jack;          struct umidi_jack *jack;
         unsigned char *cn_spec;          const unsigned char *cn_spec;
   
         if (UMQ_ISTYPE(sc, UMQ_TYPE_CN_SEQ_PER_EP))          if (UMQ_ISTYPE(sc, UMQ_TYPE_CN_SEQ_PER_EP))
                 sc->cblnums_global = 0;                  sc->cblnums_global = 0;
Line 1015  assign_all_jacks_automatically(struct um
Line 1008  assign_all_jacks_automatically(struct um
         usbd_status err;          usbd_status err;
         int i;          int i;
         struct umidi_jack *out, *in;          struct umidi_jack *out, *in;
         signed char *asg_spec;          const signed char *asg_spec;
   
         err =          err =
             alloc_all_mididevs(sc,              alloc_all_mididevs(sc,
Line 1164  attach_mididev(struct umidi_softc *sc, s
Line 1157  attach_mididev(struct umidi_softc *sc, s
   
         mididev->label = describe_mididev(mididev);          mididev->label = describe_mididev(mididev);
   
         mididev->mdev = midi_attach_mi(&umidi_hw_if, mididev, &sc->sc_dev);          mididev->mdev = midi_attach_mi(&umidi_hw_if, mididev, sc->sc_dev);
   
         return USBD_NORMAL_COMPLETION;          return USBD_NORMAL_COMPLETION;
 }  }
Line 1193  detach_mididev(struct umidi_mididev *mid
Line 1186  detach_mididev(struct umidi_mididev *mid
         return USBD_NORMAL_COMPLETION;          return USBD_NORMAL_COMPLETION;
 }  }
   
 static usbd_status  static void
 deactivate_mididev(struct umidi_mididev *mididev)  deactivate_mididev(struct umidi_mididev *mididev)
 {  {
         if (mididev->out_jack)          if (mididev->out_jack)
                 mididev->out_jack->binded = 0;                  mididev->out_jack->binded = 0;
         if (mididev->in_jack)          if (mididev->in_jack)
                 mididev->in_jack->binded = 0;                  mididev->in_jack->binded = 0;
         config_deactivate(mididev->mdev);  
   
         return USBD_NORMAL_COMPLETION;  
 }  }
   
 static usbd_status  static usbd_status
Line 1257  detach_all_mididevs(struct umidi_softc *
Line 1247  detach_all_mididevs(struct umidi_softc *
         return USBD_NORMAL_COMPLETION;          return USBD_NORMAL_COMPLETION;
 }  }
   
 static usbd_status  static void
 deactivate_all_mididevs(struct umidi_softc *sc)  deactivate_all_mididevs(struct umidi_softc *sc)
 {  {
         usbd_status err;  
         int i;          int i;
   
         if (sc->sc_mididevs)          if (sc->sc_mididevs) {
                 for (i=0; i<sc->sc_num_mididevs; i++) {                  for (i=0; i<sc->sc_num_mididevs; i++)
                         err = deactivate_mididev(&sc->sc_mididevs[i]);                          deactivate_mididev(&sc->sc_mididevs[i]);
                         if (err!=USBD_NORMAL_COMPLETION)          }
                                 return err;  
                 }  
   
         return USBD_NORMAL_COMPLETION;  
 }  }
   
 /*  /*
Line 1490  out_jack_output(struct umidi_jack *out_j
Line 1475  out_jack_output(struct umidi_jack *out_j
         if ( umididebug >= 100 )          if ( umididebug >= 100 )
                 microtime(&umidi_tv);                  microtime(&umidi_tv);
 #endif  #endif
         DPRINTFN(100, ("umidi out: %lu.%06lus ep=%p cn=%d len=%d cin=%#x\n",          DPRINTFN(100, ("umidi out: %"PRIu64".%06"PRIu64"s ep=%p cn=%d len=%d cin=%#x\n",
             umidi_tv.tv_sec%100, umidi_tv.tv_usec,              umidi_tv.tv_sec%100, (uint64_t)umidi_tv.tv_usec,
             ep, out_jack->cable_number, len, cin));              ep, out_jack->cable_number, len, cin));
   
         s = splusb();          s = splusb();
Line 1635  out_intr(usbd_xfer_handle xfer, usbd_pri
Line 1620  out_intr(usbd_xfer_handle xfer, usbd_pri
 #endif  #endif
         usbd_get_xfer_status(xfer, NULL, NULL, &count, NULL);          usbd_get_xfer_status(xfer, NULL, NULL, &count, NULL);
         if ( 0 == count % UMIDI_PACKET_SIZE ) {          if ( 0 == count % UMIDI_PACKET_SIZE ) {
                 DPRINTFN(200,("%s: %lu.%06lus out ep %p xfer length %u\n",                  DPRINTFN(200,("%s: %"PRIu64".%06"PRIu64"s out ep %p xfer length %u\n",
                              USBDEVNAME(ep->sc->sc_dev),                               USBDEVNAME(ep->sc->sc_dev),
                              umidi_tv.tv_sec%100, umidi_tv.tv_usec, ep, count));                               umidi_tv.tv_sec%100, (uint64_t)umidi_tv.tv_usec, ep, count));
         } else {          } else {
                 DPRINTF(("%s: output endpoint %p odd transfer length %u\n",                  DPRINTF(("%s: output endpoint %p odd transfer length %u\n",
                         USBDEVNAME(ep->sc->sc_dev), ep, count));                          USBDEVNAME(ep->sc->sc_dev), ep, count));

Legend:
Removed from v.1.35  
changed lines
  Added in v.1.35.4.3

CVSweb <webmaster@jp.NetBSD.org>