LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   printer in compatibility mode (https://www.linuxquestions.org/questions/linux-hardware-18/printer-in-compatibility-mode-390210/)

hazeposse 12-07-2005 12:09 PM

printer in compatibility mode
 
I want to let work my printer in the compatibility mode instead of the nibble mode. does anybody know the best ways and is it also possible to do it in printer.c? And how?

/*
* We are a "new" style driver with usb_device_id table,
* but our requirements are too intricate for simple match to handle.
*
* The "proto_bias" option may be used to specify the preferred protocol
* for all USB printers (1=7/1/1, 2=7/1/2, 3=7/1/3). If the device
* supports the preferred protocol, then we bind to it.
*
* The best interface for us is 7/1/2, because it is compatible
* with a stream of characters. If we find it, we bind to it.
*
* Note that the people from hpoj.sourceforge.net need to be able to
* bind to 7/1/3 (MLC/1284.4), so we provide them ioctls for this purpose.
*
* Failing 7/1/2, we look for 7/1/3, even though it's probably not
* stream-compatible, because this matches the behaviour of the old code.
*
* If nothing else, we bind to 7/1/1 - the unidirectional interface.
*/
static int usblp_select_alts(struct usblp *usblp)
{
struct usb_interface *if_alt;
struct usb_interface_descriptor *ifd;
struct usb_endpoint_descriptor *epd, *epwrite, *epread;
int p, i, e;

if_alt = &usblp->dev->actconfig->interface[usblp->ifnum];

for (p = 0; p < USBLP_MAX_PROTOCOLS; p++)
usblp->protocol[p].alt_setting = -1;

/* Find out what we have. */
for (i = 0; i < if_alt->num_altsetting; i++) {
ifd = &if_alt->altsetting[i];

if (ifd->bInterfaceClass != 7 || ifd->bInterfaceSubClass != 1)
continue;

if (ifd->bInterfaceProtocol < USBLP_FIRST_PROTOCOL ||
ifd->bInterfaceProtocol > USBLP_LAST_PROTOCOL)
continue;

/* Look for bulk OUT and IN endpoints. */
epwrite = epread = 0;
for (e = 0; e < ifd->bNumEndpoints; e++) {
epd = &ifd->endpoint[e];

if ((epd->bmAttributes&USB_ENDPOINT_XFERTYPE_MASK)!=
USB_ENDPOINT_XFER_BULK)
continue;

if (!(epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK)) {
if (!epwrite) epwrite=epd;

} else {
if (!epread) epread=epd;
}
}

/* Ignore buggy hardware without the right endpoints. */
if (!epwrite || (ifd->bInterfaceProtocol > 1 && !epread))
continue;

/* Turn off reads for 7/1/1 (unidirectional) interfaces
* and buggy bidirectional printers. */
if (ifd->bInterfaceProtocol == 1) {
epread = NULL;
} else if (usblp->quirks & USBLP_QUIRK_BIDIR) {
info("Disabling reads from problem bidirectional "
"printer on usblp%d", usblp->minor);
epread = NULL;
}

usblp->protocol[ifd->bInterfaceProtocol].alt_setting = i;
usblp->protocol[ifd->bInterfaceProtocol].epwrite = epwrite;
usblp->protocol[ifd->bInterfaceProtocol].epread = epread;
}

/* If our requested protocol is supported, then use it. */
if (proto_bias >= USBLP_FIRST_PROTOCOL &&
proto_bias <= USBLP_LAST_PROTOCOL &&
usblp->protocol[proto_bias].alt_setting != -1)
return proto_bias;

/* Ordering is important here. */
if (usblp->protocol[2].alt_setting != -1) return 2;
if (usblp->protocol[1].alt_setting != -1) return 1;
if (usblp->protocol[3].alt_setting != -1) return 3;

/* If nothing is available, then don't bind to this device. */
return -1;
}


All times are GMT -5. The time now is 01:16 PM.