[sane-devel] Canon LiDE 80 (2nd try)

Stefan Lucke stefan at lucke.in-berlin.de
Sun Feb 10 21:08:59 UTC 2008


On Saturday 09 February 2008, Stefan Lucke wrote:
> On Friday 08 February 2008, Reinhard Biegel wrote:
> > Am Wednesday, 6. February 2008 schrieb Reinhard Biegel:
> > > Oh....i just remember there was something that had to be called at any
> > > price but didn't find any documentation about that. I'm going to look for
> > > that in my logs.
> > 
> > Hi again,
> > 
> > I wanted to capture some logs today. But I had to find out that Canon doen't 
> > even provide drivers for 64bit Vista, which i set up some days ago. 
> > *goingcrazy*
> > 
> > As far as I remember there was a bulk write to gamma address space during 
> > initialisation which wrote data beyond the end of gamma table in the logs. 
> > When saying 'beyond' I'm refering the GL841 datasheet.
> 
> You are talking about writes like:

I guess YES.

> set_write_register(0x5b, 0x0c)
> set_write_register(0x5c, 0x00)
> set_register(0x28)
> buf_prepaccess(0x00000080,BULK_OUT)
> Data: 01 00 82 00 80 00 00 00
> Index: 0
> BULK>(128)
>   0x18, 0x36, 0x18, 0x36,  0x18, 0x36, 0x18, 0x36,

>   0x18, 0x76, 0x18, 0x76,  0x18, 0x76, 0x18, 0x76,

Thats not the right one, see attached diff.

> 
> 5b/5c build address 0x0c 00, whereas gamma address is defined as 10bit.
> I tried a few of them, but without luck.

Now I found the right one AND the right time: Before doing the reset ;-).

So now I've the initial motor movement with LED blinking and a scan
movement with green LED.

But no (strange) data arrives.


-- 
Stefan Lucke
-------------- next part --------------
? backend/genesys_low.c
Index: backend/genesys_devices.c
===================================================================
RCS file: /cvsroot/sane/sane-backends/backend/genesys_devices.c,v
retrieving revision 1.11
diff -p -U 3 -r1.11 genesys_devices.c
--- backend/genesys_devices.c	22 Nov 2007 14:05:12 -0000	1.11
+++ backend/genesys_devices.c	10 Feb 2008 21:00:49 -0000
@@ -218,6 +218,29 @@ static Genesys_Sensor Sensor[] = {
    ,
    1.0, 1.0, 1.0,
    NULL, NULL, NULL}
+  ,
+  /* CANOLIDE80 */
+  {600,
+/*TODO: find a good reason for keeping all three following variables*/
+   87,				/*(black) */
+   87,				/* (dummy) */
+   0,				/* (startxoffset) */
+   10400,			/*sensor_pixels */
+   210,
+   200,
+   {0x00, 0x00, 0x00, 0x00},
+   {0x06, 0x13, 0x55, 0x02, 0x32, 0x04, 0x32, 0x14, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x04
+    },
+   {0x05, 0x07,
+    0x00, 0x00, 0x00, 0x00,	/*[GB](HI|LOW) not needed for cis */
+    0x3a, 0x03,
+    0x40,			/*TODO: bit7 */
+    0x00, 0x00, 0x00, 0x00	/*TODO (these do no harm, but may be neccessery for CCD) */
+    }
+   ,
+   1.0, 1.0, 1.0,
+   NULL, NULL, NULL}
 };
 
 /** for General Purpose Output specific settings:
@@ -280,6 +303,13 @@ static Genesys_Gpo Gpo[] = {
    {0xef, 0x80}
    ,
    }
+  ,
+  /* CANONLIDE80 */
+  {
+   {0x00, 0x8f}
+   ,
+   {0x6d, 0x80}
+  }
 };
 
 #define MOTOR_ST24       2
@@ -393,6 +423,17 @@ static Genesys_Motor Motor[] = {
      0.8,
     },},},
   },
+  {				/* Canon LiDE 80 */
+   2400, 2400, 1, 2,
+   {
+    {{4687,  937, 128, 0.8, },
+     {4687,  937, 128, 0.8, }, /* {4200, 3800,  30, 0.8, },*/
+    },
+    {{9375, 1875, 128, 0.8, }, /* {3500, 1300, 60, 0.8, }, */
+     {9375, 1875, 128, 0.8, }, /* {3500, 1400, 60, 0.8, }, */
+    },
+   },
+  },
 };
 
 /* here we have the various device settings...
@@ -521,6 +562,53 @@ static Genesys_Model canon_lide_60_model
   400
 };				/* this is completely untested -- hmg */
 
+static Genesys_Model canon_lide_80_model = {
+  "canon-lide-80",		/* Name */
+  "Canon",			/* Device vendor string */
+  "LiDE 80",			/* Device model name */
+  GENESYS_GL841,
+  NULL,
+
+  {2400, 1200, 600, 300, 150, 75, 0},	/* possible x-resolutions */
+  {4800, 2400, 1200, 600, 300, 150, 75, 0},	/* possible y-resolutions */
+  {16, 8, 0},			/* possible depths in gray mode */
+  {16, 8, 0},			/* possible depths in color mode */
+
+  SANE_FIX (0.42),		/* Start of scan area in mm  (x) */
+  SANE_FIX (7.9),		/* Start of scan area in mm (y) */
+  SANE_FIX (218.0),		/* Size of scan area in mm (x) */
+  SANE_FIX (299.0),		/* Size of scan area in mm (y) */
+
+  SANE_FIX (3.0),		/* Start of white strip in mm (y) */
+  SANE_FIX (0.0),		/* Start of black mark in mm (x) */
+
+  SANE_FIX (0.0),		/* Start of scan area in TA mode in mm (x) */
+  SANE_FIX (0.0),		/* Start of scan area in TA mode in mm (y) */
+  SANE_FIX (100.0),		/* Size of scan area in TA mode in mm (x) */
+  SANE_FIX (100.0),		/* Size of scan area in TA mode in mm (y) */
+
+  SANE_FIX (0.0),		/* Start of white strip in TA mode in mm (y) */
+
+  0, 0, 0,			/* RGB CCD Line-distance correction in pixel */
+
+  COLOR_ORDER_RGB,		/* Order of the CCD/CIS colors */
+
+  SANE_TRUE,			/* Is this a CIS scanner? */
+  CCD_CANONLIDE80,
+  DAC_CANONLIDE35,
+  GPO_CANONLIDE80,
+  MOTOR_CANONLIDE80,
+  GENESYS_FLAG_UNTESTED | 
+        GENESYS_FLAG_LiDE80 |
+	GENESYS_FLAG_LAZY_INIT |
+	GENESYS_FLAG_SKIP_WARMUP |
+  	GENESYS_FLAG_OFFSET_CALIBRATION | 
+	GENESYS_FLAG_DARK_WHITE_CALIBRATION,	
+				/* Which flags are needed for this scanner? */
+  300,
+  400
+};
+
 static Genesys_Model hp2300c_model = {
   "hewlett-packard-scanjet-2300c",	/* Name */
   "Hewlett Packard",		/* Device vendor string */
@@ -791,6 +879,7 @@ static Genesys_Model medion_md5345_model
 static Genesys_USB_Device_Entry genesys_usb_device_list[] = {
   {0x0638, 0x0a10, &umax_astra_4500_model},
   {0x04a9, 0x2213, &canon_lide_50_model},
+  {0x04a9, 0x2214, &canon_lide_80_model},
   {0x04a9, 0x221c, &canon_lide_60_model},
   {0x03f0, 0x0901, &hp2300c_model},
   {0x03f0, 0x0a01, &hp2400c_model},
Index: backend/genesys_gl841.c
===================================================================
RCS file: /cvsroot/sane/sane-backends/backend/genesys_gl841.c,v
retrieving revision 1.19
diff -p -U 3 -r1.19 genesys_gl841.c
--- backend/genesys_gl841.c	3 Feb 2008 10:34:20 -0000	1.19
+++ backend/genesys_gl841.c	10 Feb 2008 21:00:56 -0000
@@ -404,6 +404,14 @@ gl841_bulk_write_register (Genesys_Devic
       msg[0] = reg[i].address;
       msg[1] = reg[i].value;
       
+      /* LiDE80 hack to turn on LEDs ! */
+      if (dev->model->flags & GENESYS_FLAG_LiDE80 &&
+          (reg[i]. address == 0x6c || reg[i]. address == 0x6d))
+          continue;
+
+      DBG (DBG_io2, "reg[0x%02x] = 0x%02x\n", msg[0],
+	   msg[1]);
+
       status =
 	  sanei_usb_control_msg (dev->dn, REQUEST_TYPE_OUT, REQUEST_BUFFER,
 				 VALUE_SET_REGISTER, INDEX, 2, msg);
@@ -415,8 +423,6 @@ gl841_bulk_write_register (Genesys_Devic
 	  return status;
       }
 
-      DBG (DBG_io2, "reg[0x%02x] = 0x%02x\n", msg[0],
-	   msg[1]);
   }
   
 
@@ -513,7 +519,7 @@ printtime(char *p) {
     gettimeofday(&t,NULL);
     dif = t.tv_sec - start_time.tv_sec;
     dif = dif*1000000 + t.tv_usec - start_time.tv_usec;
-    fprintf(stderr,"%s %lluµs\n",p,dif);
+    fprintf(stderr,"%s %llu�s\n",p,dif);
 }
 */
 
@@ -705,6 +711,41 @@ gl841_bulk_write_data_gamma (Genesys_Dev
   return status;
 }
 
+/**/
+static void
+gl841_LiDE80_hack (Genesys_Device *dev)
+{
+	SANE_Status		status;
+	static u_int8_t 	junk_tab [] =
+	{
+		0x8a, 0x32, 0x8a, 0x32,  0x8a, 0x32, 0x8a, 0x32,
+		0x45, 0x33, 0x45, 0x33,  0x45, 0x33, 0x45, 0x33,
+		0xc0, 0x13, 0xc0, 0x13,  0xc0, 0x13, 0xc0, 0x13,
+		0x45, 0xb3, 0x45, 0xb3,  0x45, 0xb3, 0x45, 0xb3,
+		0x8a, 0xb2, 0x8a, 0xb2,  0x8a, 0xb2, 0x8a, 0xb2,
+		0x4d, 0xb1, 0x4d, 0xb1,  0x4d, 0xb1, 0x4d, 0xb1,
+		0x0f, 0xe0, 0x0f, 0xe0,  0x0f, 0xe0, 0x0f, 0xe0,
+		0x4d, 0xf1, 0x4d, 0xf1,  0x4d, 0xf1, 0x4d, 0xf1,
+		0x8a, 0xf2, 0x8a, 0xf2,  0x8a, 0xf2, 0x8a, 0xf2,
+		0x45, 0xf3, 0x45, 0xf3,  0x45, 0xf3, 0x45, 0xf3,
+		0xc0, 0x53, 0xc0, 0x53,  0xc0, 0x53, 0xc0, 0x53,
+		0x45, 0x73, 0x45, 0x73,  0x45, 0x73, 0x45, 0x73,
+		0x8a, 0x72, 0x8a, 0x72,  0x8a, 0x72, 0x8a, 0x72,
+		0x4d, 0x71, 0x4d, 0x71,  0x4d, 0x71, 0x4d, 0x71,
+		0x0f, 0x20, 0x0f, 0x20,  0x0f, 0x20, 0x0f, 0x20,
+		0x4d, 0x31, 0x4d, 0x31,  0x4d, 0x31, 0x4d, 0x31
+	};
+
+	sanei_genesys_write_register (dev, 0x60, 0x06);
+	sanei_genesys_write_register (dev, 0x61, 0x13);
+	sanei_genesys_write_register (dev, 0x62, 0x55);
+	sanei_genesys_write_register (dev, 0x63, 0x02);
+	sanei_genesys_write_register (dev, 0x64, 0x34);
+	sanei_genesys_write_register (dev, 0x65, 0x04);
+
+	status = gl841_set_buffer_address_gamma (dev, 0x0c000);
+	status = gl841_bulk_write_data_gamma (dev, 0x28, junk_tab, 128);
+}
 
 /****************************************************************************
  Mid level functions 
@@ -2023,6 +2064,12 @@ HOME_FREE: 3
     r = sanei_genesys_get_address (reg, 0x69);
     r->value = 0;
     
+    if (dev->model->flags & GENESYS_FLAG_LiDE80)
+      {
+        r = sanei_genesys_get_address (reg, 0x6b);
+        r->value |= 1; /* LiDE 80: turn on motor home sensor */
+      }
+
     r = sanei_genesys_get_address (reg, 0x6a);
     r->value = (fast_slope_steps >> 1) + (fast_slope_steps & 1);
     
@@ -3434,7 +3481,7 @@ gl841_feed (Genesys_Device * dev, int st
       return status;
     }
 
-  while (loop < 3)		/* do not wait longer then 30 seconds */
+  while (loop < 300)		/* do not wait longer then 30 seconds */
   {
       status = sanei_genesys_get_status (dev, &val);
       if (status != SANE_STATUS_GOOD)
@@ -3452,6 +3499,7 @@ gl841_feed (Genesys_Device * dev, int st
 	  return SANE_STATUS_GOOD;
       }
       usleep (100000);	/* sleep 100 ms */
+      ++loop;
   }
 
   /* when we come here then the scanner needed too much time for this, so we better stop the motor */
@@ -3475,6 +3523,15 @@ gl841_slow_back_home (Genesys_Device * d
        wait_until_home);
 
   memset (local_reg, 0, sizeof (local_reg));
+
+  if (dev->model->flags & GENESYS_FLAG_LiDE80)
+    {
+      /* LiDE 80: ensure that home sensor is powered on for reading ;-) */
+      sanei_genesys_read_register (dev, 0x6b, &val);
+      val |= 1;
+      sanei_genesys_write_register (dev, 0x6b, val);
+    }
+
   val = 0;
   status = sanei_genesys_get_status (dev, &val);
   if (status != SANE_STATUS_GOOD)
@@ -3563,6 +3620,14 @@ gl841_slow_back_home (Genesys_Device * d
       return status;
     }
 
+  if (dev->model->flags & GENESYS_FLAG_LiDE80)
+    {
+      /* LiDE80: required too, to enabled LEDs */
+      sanei_genesys_read_register (dev, 0x6c, &val);
+      val |= 0x08;
+      sanei_genesys_write_register (dev, 0x6c, val);
+    }
+
   status = sanei_genesys_start_motor (dev);
   if (status != SANE_STATUS_GOOD)
     {
@@ -3579,7 +3644,7 @@ gl841_slow_back_home (Genesys_Device * d
     {
       int loop = 0;
 
-      while (loop < 3)		/* do not wait longer then 30 seconds */
+      while (loop < 300)		/* do not wait longer then 30 seconds */
 	{
 	  status = sanei_genesys_get_status (dev, &val);
 	  if (status != SANE_STATUS_GOOD)
@@ -3598,6 +3663,7 @@ gl841_slow_back_home (Genesys_Device * d
 	      return SANE_STATUS_GOOD;
 	    }
 	  usleep (100000);	/* sleep 100 ms */
+	  ++loop;
 	}
 
       /* when we come here then the scanner needed too much time for this, so we better stop the motor */
@@ -3729,6 +3795,7 @@ gl841_park_head (Genesys_Device * dev, G
 		}
 	    }
 	  usleep (100000);
+	  ++loop;
 	}
     } else {
 	DBG (DBG_info,
@@ -4219,7 +4286,7 @@ gl841_led_calibration (Genesys_Device * 
   if (status != SANE_STATUS_GOOD)
     {
       DBG (DBG_error,
-	   "gl841_coarse_gain_calibration: Failed to feed: %s\n",
+	   "gl841_led_calibration: Failed to feed: %s\n",
 	   sane_strstatus (status));
       return status;
     }
@@ -5088,9 +5155,19 @@ gl841_init (Genesys_Device * dev)
   RIE (sanei_usb_control_msg (dev->dn, REQUEST_TYPE_OUT, REQUEST_REGISTER,
 			      VALUE_INIT, INDEX, 1, &val));
 
+  if (dev->model->flags & GENESYS_FLAG_LiDE80)
+    gl841_LiDE80_hack (dev);
+
   /* ASIC reset */
   RIE (sanei_genesys_write_register (dev, 0x0e, 0x00));
 
+  if (dev->model->flags & GENESYS_FLAG_LiDE80)
+    {
+      RIE (sanei_genesys_write_register (dev, 0x6b, 0x0c));
+      RIE (sanei_genesys_write_register (dev, 0x6e, 0x6d));
+      RIE (sanei_genesys_write_register (dev, 0x6c, 0x00));
+    }
+
   /* Write initial registers */
   RIE (gl841_bulk_write_register
        (dev, dev->reg, GENESYS_GL841_MAX_REGS));
Index: backend/genesys_low.h
===================================================================
RCS file: /cvsroot/sane/sane-backends/backend/genesys_low.h,v
retrieving revision 1.8
diff -p -U 3 -r1.8 genesys_low.h
--- backend/genesys_low.h	22 Nov 2007 14:05:13 -0000	1.8
+++ backend/genesys_low.h	10 Feb 2008 21:00:56 -0000
@@ -95,6 +95,7 @@
 						   creation function */
 
 #define GENESYS_FLAG_DARK_WHITE_CALIBRATION (1 << 12) /*yet another calibration method. does white and dark shading in one run, depending on a black and a white strip*/
+#define GENESYS_FLAG_LiDE80		(1 << 13) /* do something special for LiDE80 */
 
 /* USB control message values */
 #define REQUEST_TYPE_IN		(USB_TYPE_VENDOR | USB_DIR_IN)
@@ -239,6 +240,7 @@ Genesys_Color_Order;
 #define CCD_HP2400       4
 #define CCD_HP2300       5
 #define CCD_CANONLIDE35  6
+#define CCD_CANONLIDE80  7
 
 #define GPO_UMAX         0
 #define GPO_ST12         1
@@ -247,6 +249,7 @@ Genesys_Color_Order;
 #define GPO_HP2400       4
 #define GPO_HP2300       5
 #define GPO_CANONLIDE35  6
+#define GPO_CANONLIDE80  7
 
 #define MOTOR_UMAX       0
 #define MOTOR_5345       1
@@ -254,6 +257,7 @@ Genesys_Color_Order;
 #define MOTOR_HP2400     3
 #define MOTOR_HP2300     4
 #define MOTOR_CANONLIDE35 5
+#define MOTOR_CANONLIDE80 6
 
 
 /* Forward typedefs */


More information about the sane-devel mailing list