[cups-devel] [PATCH 2/2] [not actually needed] rastertoepson: add ability to disable shingling

Matthew Ogilvie mmogilvi_cups at miniinfo.net
Sat Mar 28 21:32:24 PDT 2015


I suggest NOT applying this to official CUPS, unless someone
can come up with a real use case for it.  I'm sending it to
the mailing list just in case someone does have a use.

Also, when/if it is included, it could probably use a more
integrated way to configure the setting besides
an environment variable.  (Perhaps something available in the
adminstration UI, or at least customizable in the ppd file.)

When I went to test this cleaned up version of this patch, I
was no longer able to reproduce the original problem (below) that
inspired me to write an unpublished/rough version in the first
place.  The only possible reason for this I can think of is that
out of curiousity I had removed, looked at, and reseated a
cartridge labeled "Epson LQ-1500 emulation".  Presumably there was
some kind of loose connection or something, although I have
no idea how a connector could be loose in a way that only
showed buggy symptoms when asked to advance the page by less
than 24/180 of an inch.

-------------------

Before I reseated the above cartridge, my ALPS ARQ 324e
printer seemed to have a firmware bug where
sometimes a line advance of 8/180 does not actually advance
by 8.  Shingling tickled this apparent printer bug, causing a kind of
double-vision/blurryness in the output, so I wanted a way to disable
shingling in favor of either direct output, or interleaving
(depending on what each mode supports).

With this patch, shingling can be disabled by setting the
environment variable CUPS_RASTERTOEPSON_DISABLE_SHINGLING=1.
Although it may be necessary to rename/wrap the rastertoepson
executable with a shell script to set it, since it doesn't
seem to be inherited from the init script that starts cupsd
(at least on my system).

If the variable isn't so set, then the driver should continue to
output exactly what it did before.

FUTURE?: It would probably be better to have some kind of printer
config option to do this, but I'm not sure exactly how to add
a configuration option, and it would probably make more sense
as a separate commit anyway.

FUTURE?: I noticed in the documentation that
there are a few 24-pin printers that support the "ESC +" command,
and those printers could theoretically emulate an Nx360 mode by using
two passes separated by a page advance of 1/360, or some kind of
new shingling pattern based on this concept.  (Usually the Nx360
modes are only available on 48-pin printers.)  This driver makes
no attempt to support such emulated Nx360 modes.
---
 filter/rastertoepson.c | 57 +++++++++++++++++++++++++++++++++-----------------
 1 file changed, 38 insertions(+), 19 deletions(-)

diff --git a/filter/rastertoepson.c b/filter/rastertoepson.c
index 572e86d..dd6e854 100644
--- a/filter/rastertoepson.c
+++ b/filter/rastertoepson.c
@@ -117,6 +117,7 @@ StartPage(
 {
   int		n, t;			/* Numbers */
   unsigned	plane;			/* Looping var */
+  const char	*disableShingle;
 
 
  /*
@@ -177,12 +178,24 @@ StartPage(
 
 	    case 180 :
 	    case 360 :
-        	Shingling = 1;
+		disableShingle = getenv("CUPS_RASTERTOEPSON_DISABLE_SHINGLING");
+		Shingling = disableShingle == NULL ||
+		            atoi(disableShingle) == 0;
 
         	if (header->HWResolution[1] == 180)
-        	  printf("\033\063\010");/* Set line feed */
+		{
+		  if (Shingling)
+		    printf("\033\063\010");	/* Set line feed */
+		  else
+		    printf("\033\063\030");	/* Set line feed */
+		}
 		else
-        	  printf("\033+\010");	/* Set line feed */
+		{
+		  if (Shingling)
+		    printf("\033+\010");	/* Set line feed */
+		  else
+		    printf("\033+\060");	/* Set line feed */
+		}
         	break;
 	  }
         break;
@@ -774,6 +787,7 @@ OutputRows(
                 dot_min;		/* Minimum number of bytes */
   unsigned char *dot_ptr,		/* Pointer to print data */
 		*ptr;			/* Current data */
+  int modeByte;
 
 
   dot_min = DotBytes * DotColumns;
@@ -824,38 +838,40 @@ OutputRows(
     * Start bitmap graphics for this line...
     */
 
-    printf("\033*");			/* Select bit image */
     switch (header->HWResolution[0])
     {
       case 60 : /* 60x60/72 DPI gfx */
-          putchar(0);
+          modeByte=0;
           break;
       case 120 : /* 120x60/72 DPI gfx */
-          putchar(1);
+          modeByte=1;
           break;
       case 180 : /* 180 DPI gfx */
-          putchar(39);
+          modeByte=39;
           break;
       case 240 : /* 240x72 DPI gfx */
-          putchar(3);
+          modeByte=3;
           break;
       case 360 : /* 360x180/360 DPI gfx */
 	  if (header->HWResolution[1] == 180)
 	  {
-            if (Shingling && LineCount != 0)
-              putchar(40);		/* 360x180 fast */
-            else
-              putchar(41);		/* 360x180 slow */
+            modeByte=40; 		/* 360x180 fast (no adjacent dots) */
+            /* Note: Non-reachable code in older versions of this driver
+             * implied that modeByte=41 is a 360x180 slow mode that handles
+             * adjacent dots.  But official documentation makes no such
+             * claim.
+             */
 	  }
 	  else
           {
 	    if (Shingling && LineCount != 0)
-              putchar(72);		/* 360x360 fast */
+              modeByte=72;		/* 360x360 fast */
             else
-              putchar(73);		/* 360x360 slow */
+              modeByte=73;		/* 360x360 slow */
           }
           break;
     }
+    printf("\033*%c",modeByte);			/* Select bit image */
 
     n = dot_count / DotBytes;
     putchar((int)(n & 255));
@@ -865,8 +881,14 @@ OutputRows(
     * Write the graphics data...
     */
 
+    /* Mode 1 (120x60) documenation claims to support adjacent dots, but
+     * historically this driver interleaves mode 1 dots for some reason.
+     */
     if (header->HWResolution[0] == 120 ||
-        header->HWResolution[0] == 240)
+        header->HWResolution[0] == 240 ||
+        ( !Shingling &&
+          header->HWResolution[0] == 360 &&
+          header->HWResolution[1] == 180 ))
     {
      /*
       * Need to interleave the dots to avoid hosing the print head...
@@ -896,10 +918,7 @@ OutputRows(
 	putchar((int)(i >> 8));
       }
 
-      if (header->HWResolution[0] == 120)
-      	printf("\033*\001");		/* Select bit image */
-      else
-      	printf("\033*\003");		/* Select bit image */
+      printf("\033*%c",modeByte);
 
       n = (unsigned)dot_count / DotBytes;
       putchar((int)(n & 255));
-- 
2.0.5




More information about the cups-devel mailing list