int ugen_set_interface(struct ugen_softc *sc, int ifaceidx, int altno) { struct usbd_interface *iface; usb_endpoint_descriptor_t *ed; int err; struct ugen_endpoint *sce; u_int8_t niface, nendpt, endptno, endpt; int dir; DPRINTFN(15, ("ugen_set_interface %d %d\n", ifaceidx, altno)); err = usbd_interface_count(sc->sc_udev, &niface); if (err) return (err); if (ifaceidx < 0 || ifaceidx >= niface || usbd_iface_claimed(sc->sc_udev, ifaceidx)) return (USBD_INVAL); err = usbd_device2interface_handle(sc->sc_udev, ifaceidx, &iface); if (err) return (err); err = usbd_endpoint_count(iface, &nendpt); if (err) return (err); for (endptno = 0; endptno < nendpt; endptno++) { ed = usbd_interface2endpoint_descriptor(iface,endptno); endpt = ed->bEndpointAddress; dir = UE_GET_DIR(endpt) == UE_DIR_IN ? IN : OUT; sce = &sc->sc_endpoints[UE_GET_ADDR(endpt)][dir]; sce->sc = 0; sce->edesc = 0; sce->iface = 0; } /* change setting */ err = usbd_set_interface(iface, altno); if (err) goto out; err = usbd_endpoint_count(iface, &nendpt); if (err) goto out; out: for (endptno = 0; endptno < nendpt; endptno++) { ed = usbd_interface2endpoint_descriptor(iface,endptno); endpt = ed->bEndpointAddress; dir = UE_GET_DIR(endpt) == UE_DIR_IN ? IN : OUT; sce = &sc->sc_endpoints[UE_GET_ADDR(endpt)][dir]; sce->sc = sc; sce->edesc = ed; sce->iface = iface; } return (err); }
void urio_attach(struct device *parent, struct device *self, void *aux) { struct urio_softc *sc = (struct urio_softc *)self; struct usb_attach_arg *uaa = aux; struct usbd_device *dev = uaa->device; struct usbd_interface *iface; usbd_status err; usb_endpoint_descriptor_t *ed; u_int8_t epcount; int i; DPRINTFN(10,("urio_attach: sc=%p\n", sc)); err = usbd_set_config_no(dev, URIO_CONFIG_NO, 1); if (err) { printf("%s: setting config no failed\n", sc->sc_dev.dv_xname); return; } err = usbd_device2interface_handle(dev, URIO_IFACE_IDX, &iface); if (err) { printf("%s: getting interface handle failed\n", sc->sc_dev.dv_xname); return; } sc->sc_udev = dev; sc->sc_iface = iface; epcount = 0; (void)usbd_endpoint_count(iface, &epcount); sc->sc_in_addr = -1; sc->sc_out_addr = -1; for (i = 0; i < epcount; i++) { ed = usbd_interface2endpoint_descriptor(iface, i); if (ed == NULL) { printf("%s: couldn't get ep %d\n", sc->sc_dev.dv_xname, i); return; } if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN && UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) { sc->sc_in_addr = ed->bEndpointAddress; } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT && UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) { sc->sc_out_addr = ed->bEndpointAddress; } } if (sc->sc_in_addr == -1 || sc->sc_out_addr == -1) { printf("%s: missing endpoint\n", sc->sc_dev.dv_xname); return; } DPRINTFN(10, ("urio_attach: %p\n", sc->sc_udev)); }
static void udsir_attach(device_t parent, device_t self, void *aux) { struct udsir_softc *sc = device_private(self); struct usbif_attach_arg *uiaa = aux; struct usbd_device *dev = uiaa->uiaa_device; struct usbd_interface *iface = uiaa->uiaa_iface; char *devinfop; usb_endpoint_descriptor_t *ed; uint8_t epcount; int i; struct ir_attach_args ia; DPRINTFN(10, ("udsir_attach: sc=%p\n", sc)); sc->sc_dev = self; aprint_naive("\n"); aprint_normal("\n"); devinfop = usbd_devinfo_alloc(dev, 0); aprint_normal_dev(self, "%s\n", devinfop); usbd_devinfo_free(devinfop); sc->sc_udev = dev; sc->sc_iface = iface; epcount = 0; (void)usbd_endpoint_count(iface, &epcount); sc->sc_rd_addr = -1; sc->sc_wr_addr = -1; for (i = 0; i < epcount; i++) { ed = usbd_interface2endpoint_descriptor(iface, i); if (ed == NULL) { aprint_error_dev(self, "couldn't get ep %d\n", i); return; } if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN && UE_GET_XFERTYPE(ed->bmAttributes) == UE_INTERRUPT) { sc->sc_rd_addr = ed->bEndpointAddress; sc->sc_rd_maxpsz = UGETW(ed->wMaxPacketSize); } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT && UE_GET_XFERTYPE(ed->bmAttributes) == UE_INTERRUPT) { sc->sc_wr_addr = ed->bEndpointAddress; sc->sc_wr_maxpsz = UGETW(ed->wMaxPacketSize); } } if (sc->sc_rd_addr == -1 || sc->sc_wr_addr == -1) { aprint_error_dev(self, "missing endpoint\n"); return; } DPRINTFN(10, ("udsir_attach: %p\n", sc->sc_udev)); usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, sc->sc_dev); ia.ia_type = IR_TYPE_IRFRAME; ia.ia_methods = &udsir_methods; ia.ia_handle = sc; sc->sc_child = config_found(self, &ia, ir_print); selinit(&sc->sc_rd_sel); selinit(&sc->sc_wr_sel); return; }
static int urio_attach(device_t self) { struct urio_softc *sc = device_get_softc(self); struct usb_attach_arg *uaa = device_get_ivars(self); usbd_interface_handle iface; u_int8_t epcount; usbd_status r; char * ermsg = "<none>"; int i; DPRINTFN(10,("urio_attach: sc=%p\n", sc)); sc->sc_dev = self; sc->sc_udev = uaa->device; if ((!uaa->device) || (!uaa->iface)) { ermsg = "device or iface"; goto nobulk; } sc->sc_iface = iface = uaa->iface; sc->sc_opened = 0; sc->sc_pipeh_in = 0; sc->sc_pipeh_out = 0; sc->sc_refcnt = 0; r = usbd_endpoint_count(iface, &epcount); if (r != USBD_NORMAL_COMPLETION) { ermsg = "endpoints"; goto nobulk; } sc->sc_epaddr[RIO_OUT] = 0xff; sc->sc_epaddr[RIO_IN] = 0x00; for (i = 0; i < epcount; i++) { usb_endpoint_descriptor_t *edesc = usbd_interface2endpoint_descriptor(iface, i); int d; if (!edesc) { ermsg = "interface endpoint"; goto nobulk; } d = RIO_UE_GET_DIR(edesc->bEndpointAddress); if (d != RIO_NODIR) sc->sc_epaddr[d] = edesc->bEndpointAddress; } if ( sc->sc_epaddr[RIO_OUT] == 0xff || sc->sc_epaddr[RIO_IN] == 0x00) { ermsg = "Rio I&O"; goto nobulk; } make_dev(&urio_ops, device_get_unit(self), UID_ROOT, GID_OPERATOR, 0644, "urio%d", device_get_unit(self)); DPRINTFN(10, ("urio_attach: %p\n", sc->sc_udev)); return 0; nobulk: kprintf("%s: could not find %s\n", device_get_nameunit(sc->sc_dev),ermsg); return ENXIO; }
void urio_attach(device_t parent, device_t self, void *aux) { struct urio_softc *sc = device_private(self); struct usb_attach_arg *uaa = aux; usbd_device_handle dev = uaa->device; usbd_interface_handle iface; char *devinfop; usbd_status err; usb_endpoint_descriptor_t *ed; u_int8_t epcount; int i; DPRINTFN(10,("urio_attach: sc=%p\n", sc)); sc->sc_dev = self; aprint_naive("\n"); aprint_normal("\n"); devinfop = usbd_devinfo_alloc(dev, 0); aprint_normal_dev(self, "%s\n", devinfop); usbd_devinfo_free(devinfop); err = usbd_set_config_no(dev, URIO_CONFIG_NO, 1); if (err) { aprint_error_dev(self, "failed to set configuration" ", err=%s\n", usbd_errstr(err)); return; } err = usbd_device2interface_handle(dev, URIO_IFACE_IDX, &iface); if (err) { aprint_error_dev(self, "getting interface handle failed\n"); return; } sc->sc_udev = dev; sc->sc_iface = iface; epcount = 0; (void)usbd_endpoint_count(iface, &epcount); sc->sc_in_addr = -1; sc->sc_out_addr = -1; for (i = 0; i < epcount; i++) { ed = usbd_interface2endpoint_descriptor(iface, i); if (ed == NULL) { aprint_error_dev(self, "couldn't get ep %d\n", i); return; } if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN && UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) { sc->sc_in_addr = ed->bEndpointAddress; } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT && UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) { sc->sc_out_addr = ed->bEndpointAddress; } } if (sc->sc_in_addr == -1 || sc->sc_out_addr == -1) { aprint_error_dev(self, "missing endpoint\n"); return; } DPRINTFN(10, ("urio_attach: %p\n", sc->sc_udev)); usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, sc->sc_dev); return; }
int ugen_set_config(struct ugen_softc *sc, int configno) { struct usbd_device *dev = sc->sc_udev; usb_config_descriptor_t *cdesc; struct usbd_interface *iface; usb_endpoint_descriptor_t *ed; struct ugen_endpoint *sce; u_int8_t niface, nendpt; int ifaceno, endptno, endpt; int err; int dir; DPRINTFN(1,("ugen_set_config: %s to configno %d, sc=%p\n", sc->sc_dev.dv_xname, configno, sc)); /* * We start at 1, not 0, because we don't care whether the * control endpoint is open or not. It is always present. */ for (endptno = 1; endptno < USB_MAX_ENDPOINTS; endptno++) if (sc->sc_is_open[endptno]) { DPRINTFN(1, ("ugen_set_config: %s - endpoint %d is open\n", sc->sc_dev.dv_xname, endptno)); return (USBD_IN_USE); } /* Avoid setting the current value. */ cdesc = usbd_get_config_descriptor(dev); if (!cdesc || cdesc->bConfigurationValue != configno) { if (sc->sc_secondary) { printf("%s: secondary, not changing config to %d\n", __func__, configno); return (USBD_IN_USE); } else { err = usbd_set_config_no(dev, configno, 1); if (err) return (err); } } err = usbd_interface_count(dev, &niface); if (err) return (err); memset(sc->sc_endpoints, 0, sizeof sc->sc_endpoints); for (ifaceno = 0; ifaceno < niface; ifaceno++) { DPRINTFN(1,("ugen_set_config: ifaceno %d\n", ifaceno)); if (usbd_iface_claimed(sc->sc_udev, ifaceno)) { DPRINTF(("%s: iface %d not available\n", __func__, ifaceno)); continue; } err = usbd_device2interface_handle(dev, ifaceno, &iface); if (err) return (err); err = usbd_endpoint_count(iface, &nendpt); if (err) return (err); for (endptno = 0; endptno < nendpt; endptno++) { ed = usbd_interface2endpoint_descriptor(iface,endptno); endpt = ed->bEndpointAddress; dir = UE_GET_DIR(endpt) == UE_DIR_IN ? IN : OUT; sce = &sc->sc_endpoints[UE_GET_ADDR(endpt)][dir]; DPRINTFN(1,("ugen_set_config: endptno %d, endpt=0x%02x" "(%d,%d), sce=%p\n", endptno, endpt, UE_GET_ADDR(endpt), UE_GET_DIR(endpt), sce)); sce->sc = sc; sce->edesc = ed; sce->iface = iface; } } return (0); }
/* set ISOC configuration */ int ubt_set_isoc_config(struct ubt_softc *sc) { usb_endpoint_descriptor_t *ed; int rd_addr, wr_addr, rd_size, wr_size; uint8_t count, i; int err; err = usbd_set_interface(sc->sc_iface1, sc->sc_config); if (err != USBD_NORMAL_COMPLETION) { kprintf( "%s: Could not set config %d on ISOC interface. %s (%d)\n", device_get_nameunit(sc->sc_dev), sc->sc_config, usbd_errstr(err), err); return err == USBD_IN_USE ? EBUSY : EIO; } /* * We wont get past the above if there are any pipes open, so no * need to worry about buf/xfer/pipe deallocation. If we get an * error after this, the frame quantities will be 0 and no SCO * data will be possible. */ sc->sc_scord_size = rd_size = 0; sc->sc_scord_addr = rd_addr = -1; sc->sc_scowr_size = wr_size = 0; sc->sc_scowr_addr = wr_addr = -1; count = 0; (void)usbd_endpoint_count(sc->sc_iface1, &count); for (i = 0 ; i < count ; i++) { ed = usbd_interface2endpoint_descriptor(sc->sc_iface1, i); if (ed == NULL) { kprintf("%s: could not read endpoint descriptor %d\n", device_get_nameunit(sc->sc_dev), i); return EIO; } DPRINTFN(5, "%s: endpoint type %02x (%02x) addr %02x (%s)\n", device_get_nameunit(sc->sc_dev), UE_GET_XFERTYPE(ed->bmAttributes), UE_GET_ISO_TYPE(ed->bmAttributes), ed->bEndpointAddress, UE_GET_DIR(ed->bEndpointAddress) ? "in" : "out"); if (UE_GET_XFERTYPE(ed->bmAttributes) != UE_ISOCHRONOUS) continue; if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN) { rd_addr = ed->bEndpointAddress; rd_size = UGETW(ed->wMaxPacketSize); } else { wr_addr = ed->bEndpointAddress; wr_size = UGETW(ed->wMaxPacketSize); } } if (rd_addr == -1) { kprintf( "%s: missing ISOC IN endpoint on interface config %d\n", device_get_nameunit(sc->sc_dev), sc->sc_config); return ENOENT; } if (wr_addr == -1) { kprintf( "%s: missing ISOC OUT endpoint on interface config %d\n", device_get_nameunit(sc->sc_dev), sc->sc_config); return ENOENT; } #ifdef DIAGNOSTIC if (rd_size > MLEN) { kprintf("%s: rd_size=%d exceeds MLEN\n", device_get_nameunit(sc->sc_dev), rd_size); return EOVERFLOW; } if (wr_size > MLEN) { kprintf("%s: wr_size=%d exceeds MLEN\n", device_get_nameunit(sc->sc_dev), wr_size); return EOVERFLOW; } #endif sc->sc_scord_size = rd_size; sc->sc_scord_addr = rd_addr; sc->sc_scowr_size = wr_size; sc->sc_scowr_addr = wr_addr; return 0; }
static int ubt_attach(device_t self) { struct ubt_softc *sc = device_get_softc(self); struct usb_attach_arg *uaa = device_get_ivars(self); usb_config_descriptor_t *cd; usb_endpoint_descriptor_t *ed; int err; uint8_t count, i; DPRINTFN(50, "ubt_attach: sc=%p\n", sc); sc->sc_udev = uaa->device; sc->sc_dev = self; /* * Move the device into the configured state */ err = usbd_set_config_index(sc->sc_udev, 0, 1); if (err) { kprintf("%s: failed to set configuration idx 0: %s\n", device_get_nameunit(sc->sc_dev), usbd_errstr(err)); return ENXIO; } /* * Interface 0 must have 3 endpoints * 1) Interrupt endpoint to receive HCI events * 2) Bulk IN endpoint to receive ACL data * 3) Bulk OUT endpoint to send ACL data */ err = usbd_device2interface_handle(sc->sc_udev, 0, &sc->sc_iface0); if (err) { kprintf("%s: Could not get interface 0 handle %s (%d)\n", device_get_nameunit(sc->sc_dev), usbd_errstr(err), err); return ENXIO; } sc->sc_evt_addr = -1; sc->sc_aclrd_addr = -1; sc->sc_aclwr_addr = -1; count = 0; (void)usbd_endpoint_count(sc->sc_iface0, &count); for (i = 0 ; i < count ; i++) { int dir, type; ed = usbd_interface2endpoint_descriptor(sc->sc_iface0, i); if (ed == NULL) { kprintf("%s: could not read endpoint descriptor %d\n", device_get_nameunit(sc->sc_dev), i); return ENXIO; } dir = UE_GET_DIR(ed->bEndpointAddress); type = UE_GET_XFERTYPE(ed->bmAttributes); if (dir == UE_DIR_IN && type == UE_INTERRUPT) sc->sc_evt_addr = ed->bEndpointAddress; else if (dir == UE_DIR_IN && type == UE_BULK) sc->sc_aclrd_addr = ed->bEndpointAddress; else if (dir == UE_DIR_OUT && type == UE_BULK) sc->sc_aclwr_addr = ed->bEndpointAddress; } if (sc->sc_evt_addr == -1) { kprintf("%s: missing INTERRUPT endpoint on interface 0\n", device_get_nameunit(sc->sc_dev)); return ENXIO; } if (sc->sc_aclrd_addr == -1) { kprintf("%s: missing BULK IN endpoint on interface 0\n", device_get_nameunit(sc->sc_dev)); return ENXIO; } if (sc->sc_aclwr_addr == -1) { kprintf("%s: missing BULK OUT endpoint on interface 0\n", device_get_nameunit(sc->sc_dev)); return ENXIO; } /* * Interface 1 must have 2 endpoints * 1) Isochronous IN endpoint to receive SCO data * 2) Isochronous OUT endpoint to send SCO data * * and will have several configurations, which can be selected * via a sysctl variable. We select config 0 to start, which * means that no SCO data will be available. */ err = usbd_device2interface_handle(sc->sc_udev, 1, &sc->sc_iface1); if (err) { kprintf("%s: Could not get interface 1 handle %s (%d)\n", device_get_nameunit(sc->sc_dev), usbd_errstr(err), err); return ENXIO; } cd = usbd_get_config_descriptor(sc->sc_udev); if (cd == NULL) { kprintf("%s: could not get config descriptor\n", device_get_nameunit(sc->sc_dev)); return ENXIO; } sc->sc_alt_config = usbd_get_no_alts(cd, 1); /* set initial config */ err = ubt_set_isoc_config(sc); if (err) { kprintf("%s: ISOC config failed\n", device_get_nameunit(sc->sc_dev)); return ENXIO; } /* Attach HCI */ sc->sc_unit = hci_attach(&ubt_hci, sc->sc_dev, 0); usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, sc->sc_dev); sc->sc_ok = 1; sysctl_ctx_init(&sc->sysctl_ctx); sc->sysctl_tree = SYSCTL_ADD_NODE(&sc->sysctl_ctx, SYSCTL_STATIC_CHILDREN(_hw), OID_AUTO, device_get_nameunit(sc->sc_dev), CTLFLAG_RD, 0, ""); if (sc->sysctl_tree == NULL) { /* Failure isn't fatal */ device_printf(sc->sc_dev, "Unable to create sysctl tree\n"); return 0; } SYSCTL_ADD_PROC(&sc->sysctl_ctx, SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "config", CTLTYPE_INT|CTLFLAG_RW, (void *)sc, 0, ubt_sysctl_config, "I", "Configuration number"); SYSCTL_ADD_INT(&sc->sysctl_ctx, SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "alt_config", CTLFLAG_RD, &sc->sc_alt_config, 0, "Number of alternate configurations"); SYSCTL_ADD_INT(&sc->sysctl_ctx, SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "sco_rxsize", CTLFLAG_RD, &sc->sc_scord_size, 0, "Max SCO receive size"); SYSCTL_ADD_INT(&sc->sysctl_ctx, SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "sco_wrsize", CTLFLAG_RD, &sc->sc_scowr_size, 0, "Max SCO transmit size"); return 0; }
void ulpt_attach(struct device *parent, struct device *self, void *aux) { struct ulpt_softc *sc = (struct ulpt_softc *)self; struct usb_attach_arg *uaa = aux; struct usbd_device *dev = uaa->device; struct usbd_interface *iface = uaa->iface; usb_interface_descriptor_t *ifcd = usbd_get_interface_descriptor(iface); usb_interface_descriptor_t *id, *iend; usb_config_descriptor_t *cdesc; usbd_status err; usb_endpoint_descriptor_t *ed; u_int8_t epcount; int i, altno; DPRINTFN(10,("ulpt_attach: sc=%p\n", sc)); //printf("%s: iclass %d/%d\n", sc->sc_dev.dv_xname, // ifcd->bInterfaceClass, ifcd->bInterfaceSubClass); /* XXX * Stepping through the alternate settings needs to be abstracted out. */ cdesc = usbd_get_config_descriptor(dev); if (cdesc == NULL) { printf("%s: failed to get configuration descriptor\n", sc->sc_dev.dv_xname); return; } iend = (usb_interface_descriptor_t *) ((char *)cdesc + UGETW(cdesc->wTotalLength)); #ifdef DIAGNOSTIC if (ifcd < (usb_interface_descriptor_t *)cdesc || ifcd >= iend) panic("ulpt: iface desc out of range"); #endif /* Step through all the descriptors looking for bidir mode */ for (id = ifcd, altno = 0; id < iend; id = (void *)((char *)id + id->bLength)) { if (id->bDescriptorType == UDESC_INTERFACE && id->bInterfaceNumber == ifcd->bInterfaceNumber) { if (id->bInterfaceClass == UICLASS_PRINTER && id->bInterfaceSubClass == UISUBCLASS_PRINTER && (id->bInterfaceProtocol == UIPROTO_PRINTER_BI /*|| id->bInterfaceProtocol == UIPROTO_PRINTER_1284*/)) goto found; altno++; } } id = ifcd; /* not found, use original */ found: if (id != ifcd) { /* Found a new bidir setting */ DPRINTF(("ulpt_attach: set altno = %d\n", altno)); err = usbd_set_interface(iface, altno); if (err) { printf("%s: setting alternate interface failed\n", sc->sc_dev.dv_xname); usbd_deactivate(sc->sc_udev); return; } } epcount = 0; (void)usbd_endpoint_count(iface, &epcount); sc->sc_in = -1; sc->sc_out = -1; for (i = 0; i < epcount; i++) { ed = usbd_interface2endpoint_descriptor(iface, i); if (ed == NULL) { printf("%s: couldn't get ep %d\n", sc->sc_dev.dv_xname, i); return; } if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN && UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) { sc->sc_in = ed->bEndpointAddress; } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT && UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) { sc->sc_out = ed->bEndpointAddress; } } if (sc->sc_out == -1) { printf("%s: could not find bulk out endpoint\n", sc->sc_dev.dv_xname); usbd_deactivate(sc->sc_udev); return; } if (usbd_get_quirks(dev)->uq_flags & UQ_BROKEN_BIDIR) { /* This device doesn't handle reading properly. */ sc->sc_in = -1; } printf("%s: using %s-directional mode\n", sc->sc_dev.dv_xname, sc->sc_in >= 0 ? "bi" : "uni"); DPRINTFN(10, ("ulpt_attach: bulk=%d\n", sc->sc_out)); sc->sc_iface = iface; sc->sc_ifaceno = id->bInterfaceNumber; sc->sc_udev = dev; /* maybe the device needs firmware */ sc->sc_fwdev = ulpt_lookup(uaa->vendor, uaa->product); if (sc->sc_fwdev) { if (rootvp == NULL) mountroothook_establish(ulpt_load_firmware, sc); else ulpt_load_firmware(sc); } #if 0 /* * This code is disabled because for some mysterious reason it causes * printing not to work. But only sometimes, and mostly with * UHCI and less often with OHCI. *sigh* */ { usb_config_descriptor_t *cd = usbd_get_config_descriptor(dev); usb_device_request_t req; int len, alen; req.bmRequestType = UT_READ_CLASS_INTERFACE; req.bRequest = UR_GET_DEVICE_ID; USETW(req.wValue, cd->bConfigurationValue); USETW2(req.wIndex, id->bInterfaceNumber, id->bAlternateSetting); USETW(req.wLength, DEVINFOSIZE - 1); err = usbd_do_request_flags(dev, &req, devinfop, USBD_SHORT_XFER_OK, &alen, USBD_DEFAULT_TIMEOUT); if (err) { printf("%s: cannot get device id\n", sc->sc_dev.dv_xname); } else if (alen <= 2) { printf("%s: empty device id, no printer connected?\n", sc->sc_dev.dv_xname); } else { /* devinfop now contains an IEEE-1284 device ID */ len = ((devinfop[0] & 0xff) << 8) | (devinfop[1] & 0xff); if (len > DEVINFOSIZE - 3) len = DEVINFOSIZE - 3; devinfo[len] = 0; printf("%s: device id <", sc->sc_dev.dv_xname); ieee1284_print_id(devinfop+2); printf(">\n"); } } #endif }