Printers using the foo2zjs driver (in ports/print/foo2zjs) need
to attach as ugen so that a firmware file can be downloaded to
them with a command such as 'cat firmware.dl > /dev/ugen0.01".

I got a HP LaserJet 1020 which needs this driver, and currently
attaches as ulpt(4) which doesn't work. It is possible to make it
appear as ugen(4) by disabling ulpt(4) but I'd rather just have
the kernel do the right thing by default.

Currently this only adds a quirk for my printer. If this diff goes
in I'll later add more printers listed at
http://www.openprinting.org/driver/foo2zjs/
once I've obtained their device IDs.

Is this fine?

Index: ulpt.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/ulpt.c,v
retrieving revision 1.40
diff -u -p -r1.40 ulpt.c
--- ulpt.c      17 Sep 2011 08:36:06 -0000      1.40
+++ ulpt.c      25 Jan 2013 13:13:58 -0000
@@ -146,6 +146,8 @@ ulpt_match(struct device *parent, void *
        DPRINTFN(10,("ulpt_match\n"));
        if (uaa->iface == NULL)
                return (UMATCH_NONE);
+       if (usbd_get_quirks(uaa->device)->uq_flags & UQ_BAD_ULTP)
+               return (UMATCH_NONE);
        id = usbd_get_interface_descriptor(uaa->iface);
        if (id != NULL &&
            id->bInterfaceClass == UICLASS_PRINTER &&
Index: usb_quirks.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/usb_quirks.c,v
retrieving revision 1.66
diff -u -p -r1.66 usb_quirks.c
--- usb_quirks.c        31 Jan 2012 21:13:32 -0000      1.66
+++ usb_quirks.c        25 Jan 2013 13:04:17 -0000
@@ -172,6 +172,9 @@ const struct usbd_quirk_entry {
  { USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_WLNOTEBOOK2,
        ANY, { UQ_MS_BAD_CLASS | UQ_MS_LEADING_BYTE }},
 
+ /* printers that must attach as ugen(4) not ulpt(4) (need firmware download) 
*/
+ { USB_VENDOR_HP, USB_PRODUCT_HP_1020,     ANY,   { UQ_BAD_ULTP }},
+
  { 0, 0, 0, { 0 } }
 };
 
Index: usb_quirks.h
===================================================================
RCS file: /cvs/src/sys/dev/usb/usb_quirks.h,v
retrieving revision 1.16
diff -u -p -r1.16 usb_quirks.h
--- usb_quirks.h        19 Jul 2010 05:08:37 -0000      1.16
+++ usb_quirks.h        25 Jan 2013 13:15:42 -0000
@@ -49,6 +49,7 @@ struct usbd_quirks {
 #define UQ_MS_LEADING_BYTE     0x00010000 /* mouse sends unknown leading byte 
*/
 #define UQ_EHCI_NEEDTO_DISOWN  0x00020000 /* must hand device over to USB 1.1
                                                if attached to EHCI */
+#define UQ_BAD_ULTP            0x00040000 /* printer must be ugen not ulpt */
 };
 
 extern const struct usbd_quirks usbd_no_quirk;
Index: usbdevs
===================================================================
RCS file: /cvs/src/sys/dev/usb/usbdevs,v
retrieving revision 1.595
diff -u -p -r1.595 usbdevs
--- usbdevs     4 Jan 2013 02:47:46 -0000       1.595
+++ usbdevs     25 Jan 2013 13:02:30 -0000
@@ -2052,6 +2052,7 @@ product HP RT2200         0x1f0a  R/T2200 UPS
 product HP R1500G2             0x1fe0  R1500 G2 UPS
 product HP T750G2              0x1fe1  T750 G2 UPS
 product HP 640C                        0x2004  DeskJet 640c
+product HP 1020                        0x2b17  LaserJet 1020
 product HP P1100               0x3102  Photosmart P1100
 product HP HN210E              0x811c  HN210E Ethernet
 
Index: usbdevs.h
===================================================================
RCS file: /cvs/src/sys/dev/usb/usbdevs.h,v
retrieving revision 1.605
diff -u -p -r1.605 usbdevs.h
--- usbdevs.h   4 Jan 2013 02:48:27 -0000       1.605
+++ usbdevs.h   25 Jan 2013 13:14:51 -0000
@@ -2059,6 +2059,7 @@
 #define        USB_PRODUCT_HP_R1500G2  0x1fe0          /* R1500 G2 UPS */
 #define        USB_PRODUCT_HP_T750G2   0x1fe1          /* T750 G2 UPS */
 #define        USB_PRODUCT_HP_640C     0x2004          /* DeskJet 640c */
+#define        USB_PRODUCT_HP_1020     0x2b17          /* LaserJet 1020 */
 #define        USB_PRODUCT_HP_P1100    0x3102          /* Photosmart P1100 */
 #define        USB_PRODUCT_HP_HN210E   0x811c          /* HN210E Ethernet */
 
Index: usbdevs_data.h
===================================================================
RCS file: /cvs/src/sys/dev/usb/usbdevs_data.h,v
retrieving revision 1.599
diff -u -p -r1.599 usbdevs_data.h
--- usbdevs_data.h      4 Jan 2013 02:48:27 -0000       1.599
+++ usbdevs_data.h      25 Jan 2013 13:14:51 -0000
@@ -4228,6 +4228,10 @@ const struct usb_known_product usb_known
        {
            USB_VENDOR_HP, USB_PRODUCT_HP_640C,
            "DeskJet 640c",
+       },
+       {
+           USB_VENDOR_HP, USB_PRODUCT_HP_1020,
+           "LaserJet 1020",
        },
        {
            USB_VENDOR_HP, USB_PRODUCT_HP_P1100,


Reply via email to