ulpt patch fixes Brother HL1240

Joe Talbott josepht at cstone.net
Thu Feb 7 12:01:48 PST 2008


The attached patch fixes an issue I have with ulpt and my Brother
HL1240 laser printer.  Sending a request with bmRequestType =
UT_WRITE_CLASS_OTHER causes the printer to disconnect from the usb bus
which appears to act as a hard reset.  If no objections I'll commit in
a few days.

Joe
Index: sys/dev/usbmisc/ulpt/ulpt.c
===================================================================
RCS file: /home/dcvs/src/sys/dev/usbmisc/ulpt/ulpt.c,v
retrieving revision 1.24
diff -u -r1.24 ulpt.c
--- sys/dev/usbmisc/ulpt/ulpt.c	6 Nov 2007 07:37:01 -0000	1.24
+++ sys/dev/usbmisc/ulpt/ulpt.c	7 Feb 2008 11:39:41 -0000
@@ -116,6 +116,8 @@
 
 	int sc_refcnt;
 	u_char sc_dying;
+	int vendor;
+	int product;
 };
 
 static d_open_t ulptopen;
@@ -256,6 +258,8 @@
 
 	sc->sc_in = -1;
 	sc->sc_out = -1;
+	sc->vendor = uaa->vendor;
+	sc->product = uaa->product;
 	for (i = 0; i < epcount; i++) {
 		ed = usbd_interface2endpoint_descriptor(iface, i);
 		if (ed == NULL) {
@@ -365,6 +369,10 @@
 ulpt_reset(struct ulpt_softc *sc)
 {
 	usb_device_request_t req;
+	int other_fails;
+
+	/* The Brother HL1240 doesn't handle UT_WRITE_CLASS_OTHER */
+	other_fails = (sc->vendor == 0x04f9 && sc->product == 0x0006);
 
 	DPRINTFN(1, ("ulpt_reset\n"));
 	req.bRequest = UR_SOFT_RESET;
@@ -379,7 +387,8 @@
 	 * so we try both.
 	 */
 	req.bmRequestType = UT_WRITE_CLASS_OTHER;
-	if (usbd_do_request(sc->sc_udev, &req, 0)) {	/* 1.0 */
+	/* Some printers don't handle UT_WRITE_CLASS_OTHER */
+	if (other_fails || usbd_do_request(sc->sc_udev, &req, 0)) {/* 1.0 */
 		req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
 		(void)usbd_do_request(sc->sc_udev, &req, 0); /* 1.1 */
 	}




More information about the Submit mailing list