sm3600: fixed gain table transfer
authorMarian Eichholz <eichholz@computer.org>
Thu, 15 Apr 2004 21:06:58 +0000 (21:06 +0000)
committerMarian Eichholz <eichholz@computer.org>
Thu, 15 Apr 2004 21:06:58 +0000 (21:06 +0000)
ChangeLog
backend/sm3600-color.c
backend/sm3600-gray.c
backend/sm3600-scanmtek.c
backend/sm3600.h

index e2442f4..38a23a0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,8 @@
          out by Mattias Ellert, thanks: Waiting longer for DoJog() command
          completion, new function for transmitting the line gain correction
          data with correct endianess, Chassis-Gray-Level lowered.
+       * backend/sm3600.c : Fixed off-by-one-error in p->lines
+          backend/sm3600-scanmtek: Fixed just broken UploadGainCorrection()
 
 2004-04-14  Karl Heinz Kremer <khk@khk.net>
 
index 9b4a17f..9b3c540 100644 (file)
@@ -271,7 +271,7 @@ TState StartScanColor(TInstance *this)
   UploadGammaTable(this,0x4000,this->agammaB);
   INST_ASSERT();
 
-  UploadGainCorrection(this);
+  UploadGainCorrection(this,0x6000);
   INST_ASSERT();
 
   /* enough for 1/100 inch sensor distance */
index 195258b..d9fda86 100644 (file)
@@ -346,7 +346,7 @@ TState StartScanGray(TInstance *this)
   RegWrite(this,0x40,1,0x20); /* FIFO at   0x08000 */
   UploadGammaTable(this,0,this->agammaY); INST_ASSERT();
 
-  UploadGainCorrection(this);
+  UploadGainCorrection(this, 0x2000);
   INST_ASSERT();
 
   /* for halftone dithering we need one history line */
index 5297efa..4aa4f1b 100644 (file)
@@ -280,16 +280,13 @@ UploadGainCorrection()
 ********************************************************************** */
 
 __SM3600EXPORT__
-TState UploadGainCorrection(TInstance *this)
+TState UploadGainCorrection(TInstance *this, int iTableOffset)
 {
-#ifndef SM3600_NO_GAIN_CORRECTION
-  RegWrite(this,0x3D,1,0x0F | 0x80); /* 10XXXXXX : one offset table */
-  RegWrite(this,0x3F,1,0x18); /* 16KB gain at 0x06000 */
   {
     struct TGain {
       unsigned char uchLow;
       unsigned char uchHigh;
-    } aGain[8192];
+    } aGain[0x2000]; /* 16 KB */
     int i,iOff;
     unsigned short uwGain;
 
@@ -297,16 +294,17 @@ TState UploadGainCorrection(TInstance *this)
       Oopsi: correction data starts at the left of the scanning window!
     */
     iOff=this->param.x/2+this->calibration.xMargin;
-    memset(aGain,0,sizeof(aGain));
+    memset(aGain,0xFF,sizeof(aGain));
+    RegWrite(this,0x3D,1,0x0F | 0x80); /* 10XXXXXX : one offset table */
+    RegWrite(this,0x3F,1, iTableOffset==0x6000 ? 0x18 : 0x08); /* 16KB gain at 0x06000 or 0x02000 */
     for (i=iOff; i<MAX_PIXEL_PER_SCANLINE; i++)
       {
        uwGain=this->calibration.achStripeY[i]<<4;
        aGain[i-iOff].uchLow =(unsigned char)(uwGain&0xFF);
        aGain[i-iOff].uchHigh=(unsigned char)(uwGain>>8);
       }
-    for (i=0; i<0x2000; i+=0x1000)
-      MemWriteArray(this,(0x6000+i)>>1,0x1000,(unsigned char*)(aGain+i));
+    for (i=0; i<0x4000; i+=0x1000)
+      MemWriteArray(this,(iTableOffset+i)>>1,0x1000,((unsigned char*)aGain)+i);
   }
-#endif
   return SANE_STATUS_GOOD;
 }
index 1dec468..2898900 100644 (file)
@@ -283,7 +283,7 @@ __SM3600EXPORT__ TState DoLampSwitch(TInstance *this,int nPattern);
 #endif
 __SM3600EXPORT__ TState DoCalibration(TInstance *this);
 __SM3600EXPORT__ TState UploadGammaTable(TInstance *this, int iByteAddress, SANE_Int *pnGamma);
-__SM3600EXPORT__ TState UploadGainCorrection(TInstance *this);
+__SM3600EXPORT__ TState UploadGainCorrection(TInstance *this, int iTableOffset);
 
 /* sm3600-scanusb.c */
 __SM3600EXPORT__ TState RegWrite(TInstance *this,int iRegister, int cb, unsigned long ulValue);