summaryrefslogtreecommitdiff
path: root/backend/hpsj5s.c
diff options
context:
space:
mode:
Diffstat (limited to 'backend/hpsj5s.c')
-rw-r--r--backend/hpsj5s.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/backend/hpsj5s.c b/backend/hpsj5s.c
index 9c6ad79..77fcc46 100644
--- a/backend/hpsj5s.c
+++ b/backend/hpsj5s.c
@@ -961,8 +961,7 @@ GetCalibration ()
{ /*WARNING!!! Deadlock possible! */
bTest = CallFunctionWithRetVal (0xB5);
}
- while ((((bTest & 0x80) == 1) && ((bTest & 0x3F) <= 2)) ||
- (((bTest & 0x80) == 0) && ((bTest & 0x3F) >= 5)));
+ while ((bTest & 0x80) ? (bTest & 0x3F) <= 2 : (bTest & 0x3F) >= 5);
CallFunctionWithParameter (0xCD, 0);
/*Skip this line for ECP: */
@@ -1065,7 +1064,7 @@ CalibrateScanElements ()
SANE_Byte CurrentLowTransferBorder;
SANE_Byte CurrentUpSaveBorder;
SANE_Byte CurrentLowSaveBorder;
- SANE_Byte CurrentSpeed1, CurrentSpeed2;
+ SANE_Byte CurrentSpeed1, CurrentSpeed2;
SANE_Byte CorrectionValue;
SANE_Byte FilteredBuffer[2570];
@@ -1150,8 +1149,7 @@ CalibrateScanElements ()
usleep (1);
}
while ((timeout < 1000) &&
- ((((bTest & 0x80) == 1) && ((bTest & 0x3F) <= 2)) ||
- (((bTest & 0x80) == 0) && ((bTest & 0x3F) >= 5))));
+ ((bTest & 0x80) ? (bTest & 0x3F) <= 2 : (bTest & 0x3F) >= 5));
/*Let's read it... */
if(timeout < 1000)
@@ -1167,14 +1165,14 @@ CalibrateScanElements ()
CallFunctionWithParameter (0x91, 0); /*Stop engine. */
/*Note: if first read failed, junk would be calculated, but if previous
- read was succeded, but last one failed, previous data'ld be used.
+ read was succeeded, but last one failed, previous data'ld be used.
*/
for(Temp = 0, j = 0; j < 2570; j++)
Temp += FilteredBuffer[j];
Temp /= 2570;
if((Average == 0)||(Average > Temp))
- Average = Temp;
+ Average = Temp;
}
for(Index = 0; Index < 3; Index++) /*Three color components*/
@@ -1190,7 +1188,7 @@ CalibrateScanElements ()
CallFunctionWithParameter (0x92, CurrentLowTransferBorder|0x80);
for(j=2999; j>0; j--)
CallFunctionWithParameter (0xC6, 0);
-
+
CurrentUpSaveBorder = arUpSaveBorders[Index];
CallFunctionWithParameter (CurrentUpSaveBorder, 0xFF);
@@ -1199,9 +1197,9 @@ CalibrateScanElements ()
CallFunctionWithParameter (0x90,0);
Calibration = 0x80;
CallFunctionWithParameter (CurrentUpSaveBorder, 0x80);
-
+
CurrentSpeed1 = CurrentSpeed2 = arSpeeds[Index];
-
+
for(CorrectionValue = 0x40; CorrectionValue != 0;CorrectionValue >>= 2)
{
CallFunctionWithParameter (0x91, CurrentSpeed2);
@@ -1218,8 +1216,7 @@ CalibrateScanElements ()
usleep (1);
}
while ((timeout < 1000) &&
- ((((bTest & 0x80) == 1) && ((bTest & 0x3F) <= 2)) ||
- (((bTest & 0x80) == 0) && ((bTest & 0x3F) >= 5))));
+ ((bTest & 0x80) ? (bTest & 0x3F) <= 2 : (bTest & 0x3F) >= 5));
/*Let's read it... */
if(timeout < 1000)
@@ -1235,11 +1232,11 @@ CalibrateScanElements ()
Perhaps, we can optimize it in future.*/
WriteScannerRegister (0x91, 0);
usleep(10);
-
+
for(Temp = 0,j = 0; j < 16;j++)
Temp += FilteredBuffer[509+j]; /*At this offset calcalates HP's driver.*/
Temp /= 16;
-
+
if(Average > Temp)
{
Calibration += CorrectionValue;
@@ -1247,7 +1244,7 @@ CalibrateScanElements ()
}
else
Calibration -= CorrectionValue;
-
+
WriteScannerRegister (CurrentUpSaveBorder, Calibration);
}/*By CorrectionValue we tune UpSaveBorder*/