From owner-freebsd-stable@FreeBSD.ORG Mon Sep 22 05:39:21 2003 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C7AD816A4B3 for ; Mon, 22 Sep 2003 05:39:21 -0700 (PDT) Received: from srv1.cosmo-project.de (srv1.cosmo-project.de [213.83.6.106]) by mx1.FreeBSD.org (Postfix) with ESMTP id 336A443FEC for ; Mon, 22 Sep 2003 05:39:20 -0700 (PDT) (envelope-from ticso@cicely12.cicely.de) Received: from cicely5.cicely.de (cicely5.cicely.de [IPv6:3ffe:400:8d0:301:200:92ff:fe9b:20e7]) (authenticated bits=0) h8MCdEFs017257 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK); Mon, 22 Sep 2003 14:39:16 +0200 (CEST) (envelope-from ticso@cicely12.cicely.de) Received: from cicely12.cicely.de (cicely12.cicely.de [IPv6:3ffe:400:8d0:301::12]) by cicely5.cicely.de (8.12.10/8.12.10) with ESMTP id h8MCdDWZ062392 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 22 Sep 2003 14:39:13 +0200 (CEST) (envelope-from ticso@cicely12.cicely.de) Received: from cicely12.cicely.de (localhost [127.0.0.1]) by cicely12.cicely.de (8.12.9/8.12.9) with ESMTP id h8MCdDrY078665; Mon, 22 Sep 2003 14:39:13 +0200 (CEST) (envelope-from ticso@cicely12.cicely.de) Received: (from ticso@localhost) by cicely12.cicely.de (8.12.9/8.12.9/Submit) id h8MCdCLe078664; Mon, 22 Sep 2003 14:39:12 +0200 (CEST) Date: Mon, 22 Sep 2003 14:39:12 +0200 From: Bernd Walter To: Kirk Strauser Message-ID: <20030922123911.GE21665@cicely12.cicely.de> References: <87fzisoi53.fsf@strauser.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="aM3YZ0Iwxop3KEKx" Content-Disposition: inline In-Reply-To: <87fzisoi53.fsf@strauser.com> X-Operating-System: FreeBSD cicely12.cicely.de 5.1-CURRENT alpha User-Agent: Mutt/1.5.4i cc: freebsd-stable@freebsd.org Subject: Re: HP Laserjet 1200 on USB X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: ticso@cicely.de List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Sep 2003 12:39:22 -0000 --aM3YZ0Iwxop3KEKx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Sep 19, 2003 at 11:30:32AM -0500, Kirk Strauser wrote: > When I bought my Laserjet 1200SE about a year ago, FreeBSD wasn't capable of > using its USB interface. I see no indication that this has changed. Is > anybody working on this as a personal project? Is there any general > progress on it? > > Basically, parallel printing 50MB Postscript files is killing me. I think > I'm going to have to give in and move the Printer onto a Linux workstation > unless somebody knows something I don't. -stable stumbles over 1284 mode if the printer lists it as the first alternative. For -current this is not a problem. I have a patch for -stable to switch to a working alternative somewhere around - I hope that the attached is the right one... -- B.Walter BWCT http://www.bwct.de ticso@bwct.de info@bwct.de --aM3YZ0Iwxop3KEKx Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ulpt-2.diff" --- ulpt.c.orig Fri May 2 15:50:58 2003 +++ ulpt.c Fri May 2 15:56:40 2003 @@ -174,7 +174,8 @@ id->bInterfaceClass == UICLASS_PRINTER && id->bInterfaceSubClass == UISUBCLASS_PRINTER && (id->bInterfaceProtocol == UIPROTO_PRINTER_UNI || - id->bInterfaceProtocol == UIPROTO_PRINTER_BI)) + id->bInterfaceProtocol == UIPROTO_PRINTER_BI || + id->bInterfaceProtocol == UIPROTO_PRINTER_1284)) return (UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO); return (UMATCH_NONE); } @@ -183,79 +184,63 @@ { USB_ATTACH_START(ulpt, sc, uaa); usbd_device_handle dev = uaa->device; + + usb_config_descriptor_t *cdesc; + usbd_interface_handle iface = uaa->iface; - usb_interface_descriptor_t *id = usbd_get_interface_descriptor(iface); + usb_interface_descriptor_t *ifcd = usbd_get_interface_descriptor(iface); + usb_interface_descriptor_t *id, *iend; char devinfo[1024]; usb_endpoint_descriptor_t *ed; usbd_status err; + u_int8_t epcount; + int i, altno; DPRINTFN(10,("ulpt_attach: sc=%p\n", sc)); usbd_devinfo(dev, 0, devinfo); USB_ATTACH_SETUP; - printf("%s: %s, iclass %d/%d\n", USBDEVNAME(sc->sc_dev), - devinfo, id->bInterfaceClass, id->bInterfaceSubClass); - /* Figure out which endpoint is the bulk out endpoint. */ - ed = usbd_interface2endpoint_descriptor(iface, 0); - if (ed == NULL) - goto nobulk; - if (UE_GET_DIR(ed->bEndpointAddress) != UE_DIR_OUT || - (ed->bmAttributes & UE_XFERTYPE) != UE_BULK) { - /* In case we are using a bidir protocol... */ - ed = usbd_interface2endpoint_descriptor(iface, 1); - if (ed == NULL) - goto nobulk; - if (UE_GET_DIR(ed->bEndpointAddress) != UE_DIR_OUT || - (ed->bmAttributes & UE_XFERTYPE) != UE_BULK) - goto nobulk; - } - sc->sc_bulk = ed->bEndpointAddress; - DPRINTFN(10, ("ulpt_attach: bulk=%d\n", sc->sc_bulk)); - - sc->sc_iface = iface; - err = usbd_interface2device_handle(iface, &sc->sc_udev); - if (err) { - sc->sc_dying = 1; - USB_ATTACH_ERROR_RETURN; - } - sc->sc_ifaceno = id->bInterfaceNumber; - -#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, sizeof devinfo - 1); - err = usbd_do_request_flags(dev, &req, devinfo, USBD_SHORT_XFER_OK, - &alen); - if (err) { - printf("%s: cannot get device id\n", USBDEVNAME(sc->sc_dev)); - } else if (alen <= 2) { - printf("%s: empty device id, no printer connected?\n", - USBDEVNAME(sc->sc_dev)); - } else { - /* devinfo now contains an IEEE-1284 device ID */ - len = ((devinfo[0] & 0xff) << 8) | (devinfo[1] & 0xff); - if (len > sizeof devinfo - 3) - len = sizeof devinfo - 3; - devinfo[len] = 0; - printf("%s: device id <", USBDEVNAME(sc->sc_dev)); - ieee1284_print_id(devinfo+2); - printf(">\n"); - } - } + cdesc = usbd_get_config_descriptor(dev); + if (cdesc == NULL) { + printf("%s: failed to get configuration descriptor\n", + USBDEVNAME(sc->sc_dev)); + USB_ATTACH_ERROR_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\n"); #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) { + DPRINTF(("ulpt_attach: set altno = %d\n", altno)); + err = usbd_set_interface(iface, altno); + if (err == 0) { + printf("%s: %s, iclass %d/%d-%d(%d)\n", USBDEVNAME(sc->sc_dev), + devinfo, id->bInterfaceClass, id->bInterfaceSubClass, + id->bInterfaceNumber+id->bAlternateSetting, id->bInterfaceProtocol); + epcount = 0; + (void)usbd_endpoint_count(iface, &epcount); + for (i = 0; i < epcount; i++) { + ed = usbd_interface2endpoint_descriptor(iface, i); + if (ed != NULL) { + if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT && + (ed->bmAttributes & UE_XFERTYPE) == UE_BULK) { + sc->sc_bulk = ed->bEndpointAddress; + DPRINTFN(10, ("ulpt_attach: bulk=%d\n", sc->sc_bulk)); + sc->sc_iface = iface; + err = usbd_interface2device_handle(iface, &sc->sc_udev); + if (err == 0) { + sc->sc_ifaceno = id->bInterfaceNumber; #if defined(__FreeBSD__) sc->dev = make_dev(&ulpt_cdevsw, device_get_unit(self), UID_ROOT, GID_OPERATOR, 0644, "ulpt%d", device_get_unit(self)); @@ -263,10 +248,17 @@ device_get_unit(self)|ULPT_NOPRIME, UID_ROOT, GID_OPERATOR, 0644, "unlpt%d", device_get_unit(self)); #endif - USB_ATTACH_SUCCESS_RETURN; - - nobulk: + } + } + } + } + } + } + altno++; + } + } + id = ifcd; /* not found, use original */ printf("%s: could not find bulk endpoint\n", USBDEVNAME(sc->sc_dev)); sc->sc_dying = 1; USB_ATTACH_ERROR_RETURN; --aM3YZ0Iwxop3KEKx--