summaryrefslogtreecommitdiff
path: root/backend/mustek_pp_cis.c
diff options
context:
space:
mode:
Diffstat (limited to 'backend/mustek_pp_cis.c')
-rw-r--r--backend/mustek_pp_cis.c742
1 files changed, 371 insertions, 371 deletions
diff --git a/backend/mustek_pp_cis.c b/backend/mustek_pp_cis.c
index 96e89f1..e95c6cf 100644
--- a/backend/mustek_pp_cis.c
+++ b/backend/mustek_pp_cis.c
@@ -44,14 +44,14 @@
/*
Global picture
-
+
Mustek_PP_handle -> Mustek_PP_dev
-> priv = Mustek_PP_CIS_dev -> CIS
*/
-
+
/*
* This flag determines whether the scanner uses fast skipping at high
- * resolutions. It is possible that this fast skipping introduces
+ * resolutions. It is possible that this fast skipping introduces
* inaccuracies. It if turns out to be a problem, fast skipping can
* be disabled by setting this flag to 0.
*/
@@ -68,7 +68,7 @@
#define MUSTEK_PP_CIS_1200CP_DEFAULT_SKIP 330
/*
- * Number of scan lines on which the average is taken to determine the
+ * Number of scan lines on which the average is taken to determine the
* maximum number of color levels.
*/
#define MUSTEK_PP_CIS_AVERAGE_COUNT 32
@@ -110,14 +110,14 @@
*** MA1015 chipset related functionality ***
******************************************************************************
*****************************************************************************/
-
+
/*
- These defines control some debugging functionality
+ These defines control some debugging functionality
#define M1015_TRACE_REGS -> trace the status of the internal registers
#define M1015_LOG_HL -> create a high-level log file (register-level)
#define M1015_LOG_LL -> create a low-level log file (byte-level)
-
+
By default, all logging/tracing is turned off.
*/
@@ -130,13 +130,13 @@
#ifdef M1015_LOG_LL
static FILE* M1015_LOG_1;
-
+
#define M1015_START_LL\
M1015_LOG_1 = fopen("cis_ll.log", "w");
-
+
#define M1015_STOP_LL\
fclose(M1015_LOG_1);
-
+
#define SANEI_PA4S2_WRITEBYTE(fd, reg, val)\
do\
{\
@@ -144,10 +144,10 @@
fprintf(M1015_LOG_1, "\tsanei_pa4s2_writebyte(fd, %d, 0x%02X);\n", \
reg, val);\
} while (0)
-
+
static const char* cis_last_rreg_name;
- static int cis_read_count;
-
+ static int cis_read_count;
+
#define SANEI_PA4S2_READBEGIN(fd, reg)\
do\
{\
@@ -155,14 +155,14 @@
cis_read_count = 0;\
sanei_pa4s2_readbegin(fd, reg);\
} while (0)
-
+
#define SANEI_PA4S2_READBYTE(fd, val)\
do\
{\
sanei_pa4s2_readbyte(fd, val);\
++cis_read_count;\
} while (0)
-
+
#define SANEI_PA4S2_READEND(fd)\
do\
{\
@@ -170,41 +170,41 @@
fprintf(M1015_LOG_1, "\tread_reg(%s, %d);\n", \
cis_last_rreg_name, cis_read_count);\
} while (0)
-
+
#define M1015_MARK_LL(info)\
fprintf(M1015_LOG_1, "* %s\n", info);
-
+
#else /* M1015_LOG_LL */
#define M1015_START_LL
#define M1015_STOP_LL
-
+
#define SANEI_PA4S2_WRITEBYTE(fd, reg, val)\
sanei_pa4s2_writebyte (fd, reg, val)
-
+
#define SANEI_PA4S2_READBEGIN(fd, reg)\
sanei_pa4s2_readbegin(fd, reg)
-
+
#define SANEI_PA4S2_READBYTE(fd, val)\
sanei_pa4s2_readbyte(fd, val)
-
+
#define SANEI_PA4S2_READEND(fd)\
sanei_pa4s2_readend(fd)
-
+
#define M1015_MARK_LL(info)
-
+
#endif /* M1015_LOG_LL */
-
+
/******************************************************************************
* High-level logging: traces the flow of the driver in a hierarchical way
* up to the level of register acccesses.
- *****************************************************************************/
+ *****************************************************************************/
#ifdef M1015_LOG_HL
static FILE* M1015_LOG_2;
static char hl_prev_line[4096], hl_next_line[4096], hl_repeat_count;
-
+
/*
* A few variables for hierarchical log message indentation.
*/
@@ -213,7 +213,7 @@
" ";
static const char* cis_indent;
static const char* cis_indent_end;
-
+
#define M1015_START_HL\
M1015_LOG_2 = fopen("cis_hl.log", "w");\
cis_indent = cis_indent_start + strlen(cis_indent_start);\
@@ -221,7 +221,7 @@
hl_prev_line[0] = 0;\
hl_next_line[0] = 0;\
hl_repeat_count = 0;
-
+
#define M1015_FLUSH_HL\
if (strcmp(hl_prev_line, hl_next_line))\
{\
@@ -238,7 +238,7 @@
{\
hl_repeat_count += 1;\
}
-
+
#define M1015_MARK(info)\
sprintf(&hl_next_line[0], "%s+ %s\n", cis_indent, info);\
M1015_FLUSH_HL
@@ -246,45 +246,45 @@
#define M1015_STOP_HL\
hl_next_line[0] = 0;\
M1015_FLUSH_HL\
- fclose(M1015_LOG_2);
-
-#else /* M1015_LOG_HL */
+ fclose(M1015_LOG_2);
+
+#else /* M1015_LOG_HL */
#define M1015_START_HL
#define M1015_STOP_HL
#define M1015_MARK(info)
#define M1015_FLUSH_HL
-
+
#endif /* M1015_LOG_HL */
#ifdef M1015_TRACE_REGS
#define M1015_DISPLAY_REGS(dev, msg) Mustek_PP_1015_display_regs(dev, msg)
#define M1015_DISPLAY_REG(msg, val) Mustek_PP_1015_display_reg(msg, val)
#else
- #define M1015_DISPLAY_REGS(dev, msg)
- #define M1015_DISPLAY_REG(msg, val)
+ #define M1015_DISPLAY_REGS(dev, msg)
+ #define M1015_DISPLAY_REG(msg, val)
#endif
-
+
#if defined (M1015_LOG_HL) || defined (M1015_LOG_LL)
-static const char*
+static const char*
Mustek_PP_1015_reg_r_name(Mustek_PP_1015R_reg id)
{
static const char* names[4] = { "ASIC", "SCAN_VAL", "MOTOR", "BANK_COUNT" };
return names[id & 0x03];
}
-static const char*
+static const char*
Mustek_PP_1015_bit_name(Mustek_PP_1015R_bit id)
{
static const char* names[4] = { "????", "MOTOR_HOME", "????", "MOTOR_BUSY" };
return names[id & 0x03];
}
-static const char*
+static const char*
Mustek_PP_1015_reg_w_name(Mustek_PP_1015R_reg id)
{
- static const char* names[4][4] =
+ static const char* names[4][4] =
{
{ "RED_REF", "GREEN_REF", "BLUE_REF", "DPI_CONTROL" },
{ "BYTE_COUNT_HB", "BYTE_COUNT_LB", "SKIP_COUNT", "EXPOSE_TIME" },
@@ -304,9 +304,9 @@ Mustek_PP_1015_show_val(int val)
/*
Since we use a static temporary buffer, we must make sure that the
buffer isn't altered while it is still in use (typically because
- more than one value is converted in a printf statement).
+ more than one value is converted in a printf statement).
Therefore the buffer is organized as a ring buffer. If should contain
- at least 21 elements in order to be able to display all registers
+ at least 21 elements in order to be able to display all registers
with one printf statement.
*/
#define Mustek_PP_1015_RING_BUFFER_SIZE 50
@@ -314,9 +314,9 @@ Mustek_PP_1015_show_val(int val)
static int index = 0;
int i;
char* current = (char*)buf[index++];
-
+
if (index >= Mustek_PP_1015_RING_BUFFER_SIZE) index = 0;
-
+
if (val < 0)
{
/* The register has not been initialized yet. */
@@ -345,8 +345,8 @@ Mustek_PP_1015_display_regs(Mustek_PP_CIS_dev * dev, const char* info)
* Rx : read-only register no. x
* ByWx : write-only register no. x of bank no. y
*/
-
- fprintf(stderr,
+
+ fprintf(stderr,
"\n"
"Register status: %s\n"
"\n"
@@ -403,12 +403,12 @@ Mustek_PP_1015_display_regs(Mustek_PP_CIS_dev * dev, const char* info)
(dev->CIS.regs.channel == 0x40 ? "GREEN" :
(dev->CIS.regs.channel == 0xC0 ? "BLUE" : "unknown")))
);
-}
+}
/******************************************************************************
* Displays a single register value
*****************************************************************************/
-static void
+static void
Mustek_PP_1015_display_reg(const char* info, int val)
{
fprintf (stderr, "%s: %s\n", info, Mustek_PP_1015_show_val(val));
@@ -432,21 +432,21 @@ Mustek_PP_1015_read_reg(Mustek_PP_CIS_dev * dev, Mustek_PP_1015R_reg reg)
{
SANE_Byte tmp;
assert(reg <= 3);
-
- SANEI_PA4S2_READBEGIN (dev->desc->fd, reg & 0x03);
- SANEI_PA4S2_READBYTE (dev->desc->fd, &tmp);
- SANEI_PA4S2_READEND (dev->desc->fd);
-
+
+ SANEI_PA4S2_READBEGIN (dev->desc->fd, reg & 0x03);
+ SANEI_PA4S2_READBYTE (dev->desc->fd, &tmp);
+ SANEI_PA4S2_READEND (dev->desc->fd);
+
#ifdef M1015_LOG_HL
- sprintf(&hl_next_line[0], "%s read_reg(%s); [%s]\n", cis_indent,
+ sprintf(&hl_next_line[0], "%s read_reg(%s); [%s]\n", cis_indent,
Mustek_PP_1015_reg_r_name(reg), Mustek_PP_1015_show_val(tmp));
M1015_FLUSH_HL;
#endif
-
-#ifdef M1015_TRACE_REGS
+
+#ifdef M1015_TRACE_REGS
dev->CIS.regs.in_regs[reg & 0x03] = tmp;
#endif
-
+
return tmp;
}
@@ -463,12 +463,12 @@ Mustek_PP_1015_wait_bit(Mustek_PP_CIS_dev * dev, Mustek_PP_1015R_reg reg,
SANE_Byte tmp;
SANE_Byte mask, val;
int tries = 0;
-
+
assert(reg <= 3);
assert(bit <= 3);
-
+
mask = 1 << bit;
-
+
/* We don't want to wait forever */
while (dev->desc->state != STATE_CANCELLED)
{
@@ -476,26 +476,26 @@ Mustek_PP_1015_wait_bit(Mustek_PP_CIS_dev * dev, Mustek_PP_1015R_reg reg,
++tries;
#endif
- sanei_pa4s2_readbegin (dev->desc->fd, reg & 0x03);
- sanei_pa4s2_readbyte (dev->desc->fd, &tmp);
- sanei_pa4s2_readend (dev->desc->fd);
-
+ sanei_pa4s2_readbegin (dev->desc->fd, reg & 0x03);
+ sanei_pa4s2_readbyte (dev->desc->fd, &tmp);
+ sanei_pa4s2_readend (dev->desc->fd);
+
#ifdef M1015_LOG_HL
- sprintf(&hl_next_line[0], "%s wait_bit(%s, %s, %d): %s %s;\n", cis_indent,
+ sprintf(&hl_next_line[0], "%s wait_bit(%s, %s, %d): %s %s;\n", cis_indent,
Mustek_PP_1015_reg_r_name(reg), Mustek_PP_1015_bit_name(bit),
on?1:0, Mustek_PP_1015_show_val(mask), Mustek_PP_1015_show_val(tmp));
M1015_FLUSH_HL;
#endif
val = ((on == SANE_TRUE) ? tmp : ~tmp ) & mask;
-
+
if (val != 0) break;
-
+
if (period) usleep(period);
-
- if (tries > 50000)
+
+ if (tries > 50000)
{
#ifdef M1015_LOG_HL
- sprintf(&hl_next_line[0], "%s wait_bit(%s, %s, %d): failed;\n", cis_indent,
+ sprintf(&hl_next_line[0], "%s wait_bit(%s, %s, %d): failed;\n", cis_indent,
Mustek_PP_1015_reg_r_name(reg), Mustek_PP_1015_bit_name(bit), on?1:0);
M1015_FLUSH_HL;
#endif
@@ -504,9 +504,9 @@ Mustek_PP_1015_wait_bit(Mustek_PP_CIS_dev * dev, Mustek_PP_1015R_reg reg,
return SANE_FALSE;
}
}
-
+
#ifdef M1015_LOG_HL
- sprintf(&hl_next_line[0], "%s wait_bit(%s, %s, %d);\n", cis_indent,
+ sprintf(&hl_next_line[0], "%s wait_bit(%s, %s, %d);\n", cis_indent,
Mustek_PP_1015_reg_r_name(reg), Mustek_PP_1015_bit_name(bit), on?1:0);
M1015_FLUSH_HL;
#endif
@@ -514,12 +514,12 @@ Mustek_PP_1015_wait_bit(Mustek_PP_CIS_dev * dev, Mustek_PP_1015R_reg reg,
fprintf(M1015_LOG_1, "\tread_reg(%s, %d);\n", Mustek_PP_1015_reg_r_name(reg),
tries);
#endif
-
-#ifdef M1015_TRACE_REGS
+
+#ifdef M1015_TRACE_REGS
dev->CIS.regs.in_regs[reg & 0x03] = tmp;
#endif
return dev->desc->state != STATE_CANCELLED ? SANE_TRUE : SANE_FALSE;
-}
+}
/******************************************************************************
*
@@ -540,9 +540,9 @@ Mustek_PP_1015_wait_bit(Mustek_PP_CIS_dev * dev, Mustek_PP_1015R_reg reg,
* Bank 2
* 0: unknown, used to start linear sequence during calibration
* 1: motor control code (forward, return home, ...)
- * 2: never used
+ * 2: never used
* 3: never used
- *
+ *
* Bank 3
* 0: reduction factor (16bit internal -> 8bit) -> target for calibration
* 1: unknown -> always set to 0x05
@@ -550,27 +550,27 @@ Mustek_PP_1015_wait_bit(Mustek_PP_CIS_dev * dev, Mustek_PP_1015R_reg reg,
* 3: never used
*
*****************************************************************************/
-
+
static void
Mustek_PP_1015_write_reg(Mustek_PP_CIS_dev * dev, Mustek_PP_1015W_reg reg, SANE_Byte val)
{
-
+
SANE_Byte regBank = (reg & 0xF0) >> 4;
SANE_Byte regNo = (reg & 0x0F);
-
+
assert (regNo <= 3);
assert (regBank <= 3);
-
+
SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, (1 << (4+regNo))+ regBank);
SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 5, val);
SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, regBank);
-
-#ifdef M1015_TRACE_REGS
+
+#ifdef M1015_TRACE_REGS
dev->CIS.regs.out_regs[regBank][regNo] = val;
#endif
#ifdef M1015_LOG_HL
- sprintf(&hl_next_line[0], "%s write_reg(%s, 0x%02X);\n", cis_indent,
+ sprintf(&hl_next_line[0], "%s write_reg(%s, 0x%02X);\n", cis_indent,
Mustek_PP_1015_reg_w_name(reg), val);
M1015_FLUSH_HL;
#endif
@@ -586,28 +586,28 @@ Mustek_PP_1015_write_reg(Mustek_PP_CIS_dev * dev, Mustek_PP_1015W_reg reg, SANE_
*
*****************************************************************************/
static void
-Mustek_PP_1015_write_reg2(Mustek_PP_CIS_dev * dev, Mustek_PP_1015W_reg reg,
+Mustek_PP_1015_write_reg2(Mustek_PP_CIS_dev * dev, Mustek_PP_1015W_reg reg,
SANE_Byte val1, SANE_Byte val2)
{
SANE_Byte regBank = (reg & 0xF0) >> 4;
SANE_Byte regNo = (reg & 0x0F);
-
+
assert (regNo <= 2);
assert (regBank <= 3);
-
+
SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, (1 << (4+regNo))+ regBank);
SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 5, val1);
SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, (1 << (5+regNo))+ regBank);
SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 5, val2);
SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, regBank);
-
-#ifdef M1015_TRACE_REGS
+
+#ifdef M1015_TRACE_REGS
dev->CIS.regs.out_regs[regBank][regNo] = val1;
dev->CIS.regs.out_regs[regBank][regNo+1] = val2;
#endif
-
+
#ifdef M1015_LOG_HL
- sprintf(&hl_next_line[0], "%s write_reg2(%s, 0x%02X, 0x%02X);\n",
+ sprintf(&hl_next_line[0], "%s write_reg2(%s, 0x%02X, 0x%02X);\n",
cis_indent, Mustek_PP_1015_reg_w_name(reg), val1, val2);
M1015_FLUSH_HL;
#endif
@@ -624,15 +624,15 @@ Mustek_PP_1015_write_reg2(Mustek_PP_CIS_dev * dev, Mustek_PP_1015W_reg reg,
*
*****************************************************************************/
static void
-Mustek_PP_1015_write_reg3(Mustek_PP_CIS_dev * dev, Mustek_PP_1015W_reg reg,
+Mustek_PP_1015_write_reg3(Mustek_PP_CIS_dev * dev, Mustek_PP_1015W_reg reg,
SANE_Byte val1, SANE_Byte val2, SANE_Byte val3)
{
SANE_Byte regBank = (reg & 0xF0) >> 4;
SANE_Byte regNo = (reg & 0x0F);
-
+
assert (regNo <= 1);
assert (regBank <= 3);
-
+
SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, (1 << (4+regNo))+ regBank);
SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 5, val1);
SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, (1 << (5+regNo))+ regBank);
@@ -640,15 +640,15 @@ Mustek_PP_1015_write_reg3(Mustek_PP_CIS_dev * dev, Mustek_PP_1015W_reg reg,
SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, (1 << (6+regNo))+ regBank);
SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 5, val3);
SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, regBank);
-
-#ifdef M1015_TRACE_REGS
+
+#ifdef M1015_TRACE_REGS
dev->CIS.regs.out_regs[regBank][regNo ] = val1;
dev->CIS.regs.out_regs[regBank][regNo+1] = val2;
dev->CIS.regs.out_regs[regBank][regNo+2] = val3;
#endif
-
+
#ifdef M1015_LOG_HL
- sprintf(&hl_next_line[0], "%s write_reg3(%s, 0x%02X, 0x%02X, 0x%02X);\n",
+ sprintf(&hl_next_line[0], "%s write_reg3(%s, 0x%02X, 0x%02X, 0x%02X);\n",
cis_indent, Mustek_PP_1015_reg_w_name(reg), val1, val2, val3);
M1015_FLUSH_HL;
#endif
@@ -656,43 +656,43 @@ Mustek_PP_1015_write_reg3(Mustek_PP_CIS_dev * dev, Mustek_PP_1015W_reg reg,
/******************************************************************************
* Opens a register for a (series of) write operation(s).
- *****************************************************************************/
+ *****************************************************************************/
static void
Mustek_PP_1015_write_reg_start(Mustek_PP_CIS_dev * dev, Mustek_PP_1015W_reg reg)
{
SANE_Byte regBank = (reg & 0xF0) >> 4;
SANE_Byte regNo = (reg & 0x0F);
-
+
assert (regNo <= 3);
assert (regBank <= 3);
-
+
dev->CIS.regs.current_write_reg = reg;
-
+
#ifdef M1015_LOG_HL
dev->CIS.regs.write_count = 0;
#endif
-
+
SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, (1 << (4+regNo))+ regBank);
}
/******************************************************************************
* Writes a value to the currently open register.
- *****************************************************************************/
+ *****************************************************************************/
static void
Mustek_PP_1015_write_reg_val(Mustek_PP_CIS_dev * dev, SANE_Byte val)
{
-#ifdef M1015_TRACE_REGS
+#ifdef M1015_TRACE_REGS
SANE_Byte regBank = (dev->CIS.regs.current_write_reg & 0xF0) >> 4;
SANE_Byte regNo = (dev->CIS.regs.current_write_reg & 0x0F);
-
+
assert (regNo <= 3);
assert (regBank <= 3);
-
+
dev->CIS.regs.out_regs[regBank][regNo] = val;
#endif
-
+
SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 5, val);
-
+
#ifdef M1015_LOG_HL
++dev->CIS.regs.write_count;
#endif
@@ -700,7 +700,7 @@ Mustek_PP_1015_write_reg_val(Mustek_PP_CIS_dev * dev, SANE_Byte val)
/******************************************************************************
* Closes a register after a (series of) write operation(s).
- *****************************************************************************/
+ *****************************************************************************/
static void
Mustek_PP_1015_write_reg_stop(Mustek_PP_CIS_dev * dev)
{
@@ -708,16 +708,16 @@ Mustek_PP_1015_write_reg_stop(Mustek_PP_CIS_dev * dev)
#ifdef M1015_LOG_HL
SANE_Byte regNo = (dev->CIS.regs.current_write_reg & 0x0F);
assert (regNo <= 3);
-
+
sprintf(&hl_next_line[0], "%s write_reg_multi(%s, *%d);\n", cis_indent,
- Mustek_PP_1015_reg_w_name(dev->CIS.regs.current_write_reg),
+ Mustek_PP_1015_reg_w_name(dev->CIS.regs.current_write_reg),
dev->CIS.regs.write_count);
M1015_FLUSH_HL;
#endif
assert (regBank <= 3);
-
+
SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, regBank);
-}
+}
/******************************************************************************
*
@@ -725,12 +725,12 @@ Mustek_PP_1015_write_reg_stop(Mustek_PP_CIS_dev * dev)
* internal registers, ie., the 3rd bit should not be zero.
*
*****************************************************************************/
-static void
+static void
Mustek_PP_1015_send_command(Mustek_PP_CIS_dev * dev, SANE_Byte command)
{
assert (command & 0x04);
SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, command);
-
+
#ifdef M1015_LOG_HL
sprintf(&hl_next_line[0], "%s send_command(0x%02X);\n", cis_indent, command);
M1015_FLUSH_HL;
@@ -742,7 +742,7 @@ Mustek_PP_1015_send_command(Mustek_PP_CIS_dev * dev, SANE_Byte command)
## CIS driver ##
##############################################################################
*****************************************************************************/
-
+
/******************************************************************************
* Resolution conversion functions
*****************************************************************************/
@@ -810,7 +810,7 @@ cis_wait_bank_change (Mustek_PP_CIS_dev * dev, int bankcount)
struct timeval start, end;
unsigned long diff;
int firsttime = 1;
-
+
gettimeofday (&start, NULL);
do
@@ -830,14 +830,14 @@ cis_wait_bank_change (Mustek_PP_CIS_dev * dev, int bankcount)
}
while ((dev->bank_count != bankcount) && (diff < MUSTEK_PP_CIS_WAIT_BANK));
-
+
if (dev->bank_count != bankcount && dev->desc->state != STATE_CANCELLED)
{
u_char tmp;
tmp = Mustek_PP_1015_read_reg(dev, 3);
DBG(2, "cis_wait_bank_change: Missed a bank: got %d [%s], "
- "wanted %d, waited %d msec\n",
- dev->bank_count, Mustek_PP_1015_show_val(tmp), bankcount,
+ "wanted %d, waited %d msec\n",
+ dev->bank_count, Mustek_PP_1015_show_val(tmp), bankcount,
MUSTEK_PP_CIS_WAIT_BANK);
}
@@ -846,10 +846,10 @@ cis_wait_bank_change (Mustek_PP_CIS_dev * dev, int bankcount)
/******************************************************************************
* Configure the CIS for a given resolution.
- *
- * CIS scanners seem to have 2 modes:
*
- * low resolution (50-300 DPI) and
+ * CIS scanners seem to have 2 modes:
+ *
+ * low resolution (50-300 DPI) and
* high resolution (300-600 DPI).
*
* Depending on the resolution requested by the user, the scanner is used
@@ -861,7 +861,7 @@ static void
cis_set_dpi_value (Mustek_PP_CIS_dev * dev)
{
u_char val = 0;
-
+
if (dev->model == MUSTEK_PP_CIS1200PLUS)
{
/* Toshiba CIS: only 600 DPI + decimation */
@@ -887,7 +887,7 @@ cis_set_dpi_value (Mustek_PP_CIS_dev * dev)
break;
default:
assert (0);
- }
+ }
}
else
{
@@ -916,7 +916,7 @@ cis_set_dpi_value (Mustek_PP_CIS_dev * dev)
assert (0);
}
}
-
+
Mustek_PP_1015_write_reg(dev, MA1015W_DPI_CONTROL, val | 0x04);
DBG (4, "cis_set_dpi_value: dpi: %d -> value 0x%02x\n", dev->CIS.hw_hres, val);
@@ -928,19 +928,19 @@ cis_set_ccd_channel (Mustek_PP_CIS_dev * dev)
SANE_Byte codes[] = { 0x84, 0x44, 0xC4 };
SANE_Byte chancode;
-
+
assert (dev->CIS.channel < 3);
-
+
chancode = codes[dev->CIS.channel];
-
- /*
- The TWAIN driver sets an extra bit in lineart mode.
- When I do this too, I don't see any effect on the image.
- Moreover, for 1 resolution, namely 400 dpi, the bank counter seems
+
+ /*
+ The TWAIN driver sets an extra bit in lineart mode.
+ When I do this too, I don't see any effect on the image.
+ Moreover, for 1 resolution, namely 400 dpi, the bank counter seems
to behave strangely, and the synchronization get completely lost.
I guess the software conversion from gray to lineart is good enough,
so I'll leave it like that.
-
+
if (dev->CIS.setParameters)
{
chancode |= (dev->desc->mode == MODE_BW) ? 0x20: 0;
@@ -948,7 +948,7 @@ cis_set_ccd_channel (Mustek_PP_CIS_dev * dev)
*/
SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, chancode);
-
+
#ifdef M1015_TRACE_REGS
dev->CIS.regs.channel = chancode;
#endif
@@ -958,43 +958,43 @@ static void
cis_config_ccd (Mustek_PP_CIS_dev * dev)
{
SANE_Int skipCount, byteCount;
-
+
if (dev->CIS.res != 0)
dev->CIS.hres_step =
SANE_FIX ((float) dev->CIS.hw_hres / (float) dev->CIS.res);
/* CIS: <= 300 dpi -> 0x86
- > 300 dpi -> 0x96 */
+ > 300 dpi -> 0x96 */
if (dev->CIS.cisRes == 600)
SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, 0x96);
else
SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, 0x86);
-
+
cis_set_dpi_value(dev);
-
+
if (dev->CIS.setParameters)
{
dev->CIS.channel = dev->desc->mode == MODE_COLOR ?
MUSTEK_PP_CIS_CHANNEL_RED : MUSTEK_PP_CIS_CHANNEL_GRAY;
}
else
- {
+ {
dev->CIS.channel = MUSTEK_PP_CIS_CHANNEL_GRAY;
}
-
+
cis_set_ccd_channel (dev);
-
+
Mustek_PP_1015_write_reg (dev, MA1015W_POWER_ON_DELAY, 0xAA);
- Mustek_PP_1015_write_reg (dev, MA1015W_CCD_TIMING, 0x05);
- Mustek_PP_1015_write_reg (dev, MA1015W_CCD_TIMING_ADJ, 0x00);
+ Mustek_PP_1015_write_reg (dev, MA1015W_CCD_TIMING, 0x05);
+ Mustek_PP_1015_write_reg (dev, MA1015W_CCD_TIMING_ADJ, 0x00);
Mustek_PP_1015_send_command (dev, 0x45); /* or 0x05 for no 8kbank */
/*
* Unknown sequence.
* Seems to be always the same during configuration, independent of the
- * mode and the resolution.
+ * mode and the resolution.
*/
CIS_CLEAR_FULLFLAG(dev);
CIS_INC_READ(dev);
@@ -1020,14 +1020,14 @@ cis_config_ccd (Mustek_PP_CIS_dev * dev)
# > 300 DPI
#
# Skip = 67 + skipimage
- #
+ #
# Skip1 = Skip / 32
# Skip2 = Skip % 32
#
# Bytes = Skip2*hw_hres/600 + (imagebytes * hw_hres/res) + 2
#
*/
-
+
skipCount = 67; /* Hardware parameter - fixed */
if (dev->CIS.setParameters == SANE_TRUE)
@@ -1043,11 +1043,11 @@ cis_config_ccd (Mustek_PP_CIS_dev * dev)
*/
DBG(4, "cis_config_ccd: Skip count: %d\n", skipCount);
skipCount += max2cis_hres(dev, dev->CIS.skipimagebytes);
- DBG(4, "cis_config_ccd: Skip count: %d (cis res: %d)\n", skipCount,
+ DBG(4, "cis_config_ccd: Skip count: %d (cis res: %d)\n", skipCount,
dev->CIS.cisRes);
skipCount += (int)(2.0/25.4*dev->CIS.cisRes);
DBG(4, "cis_config_ccd: Skip count: %d\n", skipCount);
-
+
Mustek_PP_1015_write_reg (dev, MA1015W_SKIP_COUNT, skipCount / 32);
DBG(4, "cis_config_ccd: Skip count: %d (x32)\n", skipCount / 32);
}
@@ -1056,12 +1056,12 @@ cis_config_ccd (Mustek_PP_CIS_dev * dev)
Mustek_PP_1015_write_reg (dev, MA1015W_SKIP_COUNT, 0);
DBG(4, "cis_config_ccd: Skip count: 67 (x32)\n");
}
-
+
skipCount %= 32;
skipCount = cis2max_res(dev, skipCount); /* Back to max res */
-
- Mustek_PP_1015_write_reg(dev, MA1015W_EXPOSE_TIME, dev->CIS.exposeTime);
-
+
+ Mustek_PP_1015_write_reg(dev, MA1015W_EXPOSE_TIME, dev->CIS.exposeTime);
+
DBG(4, "cis_config_ccd: skipcount: %d imagebytes: %d\n", skipCount, dev->CIS.imagebytes);
/* set_initial_skip_1015 (dev); */
if (dev->CIS.setParameters == SANE_TRUE)
@@ -1071,20 +1071,20 @@ cis_config_ccd (Mustek_PP_CIS_dev * dev)
/* The TWAIN drivers always sends the same value: 0x96 */
Mustek_PP_1015_write_reg3(dev, MA1015W_RED_REF, 0x96, 0x96, 0x96);
dev->CIS.adjustskip = max2hw_hres(dev, skipCount);
- byteCount = max2hw_hres(dev, skipCount + dev->CIS.imagebytes) + 2;
+ byteCount = max2hw_hres(dev, skipCount + dev->CIS.imagebytes) + 2;
dev->CIS.setParameters = SANE_FALSE;
}
else
{
dev->CIS.adjustskip = 0;
- byteCount = max2hw_hres(dev, skipCount);
+ byteCount = max2hw_hres(dev, skipCount);
}
- DBG(4, "cis_config_ccd: adjust skip: %d bytecount: %d\n",
+ DBG(4, "cis_config_ccd: adjust skip: %d bytecount: %d\n",
dev->CIS.adjustskip, byteCount);
-
- Mustek_PP_1015_write_reg2(dev, MA1015W_BYTE_COUNT_HB,
- byteCount >> 8, byteCount & 0xFF);
-
+
+ Mustek_PP_1015_write_reg2(dev, MA1015W_BYTE_COUNT_HB,
+ byteCount >> 8, byteCount & 0xFF);
+
cis_get_bank_count (dev);
DBG(5, "cis_config_ccd: done\n");
}
@@ -1093,8 +1093,8 @@ static SANE_Bool
cis_wait_motor_stable (Mustek_PP_CIS_dev * dev)
{
static struct timeval timeoutVal;
- SANE_Bool ret =
- Mustek_PP_1015_wait_bit (dev, MA1015R_MOTOR, MA1015B_MOTOR_STABLE,
+ SANE_Bool ret =
+ Mustek_PP_1015_wait_bit (dev, MA1015R_MOTOR, MA1015B_MOTOR_STABLE,
SANE_FALSE, 0);
#ifdef HAVE_SYS_SELECT_H
if (dev->engine_delay > 0)
@@ -1111,7 +1111,7 @@ static void
cis_motor_forward (Mustek_PP_CIS_dev * dev)
{
SANE_Byte control;
-
+
if (dev->model == MUSTEK_PP_CIS600)
{
switch (dev->CIS.hw_vres)
@@ -1150,11 +1150,11 @@ cis_motor_forward (Mustek_PP_CIS_dev * dev)
#if MUSTEK_PP_CIS_MOTOR_REVERSE == 1
control ^= 0x10;
#endif
-
+
DBG(4, "cis_motor_forward: @%d dpi: 0x%02X.\n", dev->CIS.hw_vres, control);
if (!cis_wait_motor_stable (dev))
return;
-
+
Mustek_PP_1015_write_reg(dev, MA1015W_MOTOR_CONTROL, control);
}
@@ -1166,20 +1166,20 @@ cis_move_motor (Mustek_PP_CIS_dev * dev, SANE_Int steps) /* steps @ maxres */
SANE_Int fullSteps, biSteps, quadSteps;
/*
* During a multi-step feed, the expose time is fixed. The value depends
- * on the type of the motor (600/1200 CP)
+ * on the type of the motor (600/1200 CP)
*/
SANE_Byte savedExposeTime = dev->CIS.exposeTime;
dev->CIS.exposeTime = 85;
-
+
DBG(4, "cis_move_motor: Moving motor %d steps.\n", steps);
-
+
/* Just in case ... */
if (steps < 0)
{
DBG(1, "cis_move_motor: trying to move negative steps: %d\n", steps);
steps = 0; /* We must go through the configuration procedure */
- }
-
+ }
+
/*
* Using the parameter settings for the 600 CP on a 1200 CP scanner
* doesn't work: the engine doesn't move and makes a sharp noise, which
@@ -1190,8 +1190,8 @@ cis_move_motor (Mustek_PP_CIS_dev * dev, SANE_Int steps) /* steps @ maxres */
dev->CIS.exposeTime <<= 1;
cis_config_ccd(dev);
dev->CIS.exposeTime = savedExposeTime;
-
- /*
+
+ /*
* This is a minor speed optimization: when we are using the high
* resolution mode, long feeds (eg, to move to a scan area at the bottom
* of the page) can be made almost twice as fast by using double motor
@@ -1199,8 +1199,8 @@ cis_move_motor (Mustek_PP_CIS_dev * dev, SANE_Int steps) /* steps @ maxres */
* It is possible, though, that fast skipping (which is the default) is
* not very accurate on some scanners. Therefore, the user can disable
* this through the configuration file.
- */
-
+ */
+
fullSteps = steps & 1;
biSteps = steps >> 1;
if (dev->fast_skip) {
@@ -1210,33 +1210,33 @@ cis_move_motor (Mustek_PP_CIS_dev * dev, SANE_Int steps) /* steps @ maxres */
else {
quadSteps = 0;
}
-
+
M1015_DISPLAY_REGS(dev, "Before move");
-
+
#if MUSTEK_PP_CIS_MOTOR_REVERSE == 1
fullStep ^= 0x10;
biStep ^= 0x10;
quadStep ^= 0x10;
#endif
-
+
DBG(4, "cis_move_motor: 4x%d 2x%d 1x%d\n", quadSteps, biSteps, fullSteps);
- /* Note: the TWAIN driver opens the motor control register only
+ /* Note: the TWAIN driver opens the motor control register only
once before the loop, and closes it after the loop. I've tried this
too, but it resulted in inaccurate skip distances; therefore, the
motor control register is now opened and closed for each step. */
-
+
while (quadSteps-- > 0 && dev->desc->state != STATE_CANCELLED)
{
cis_wait_motor_stable (dev);
Mustek_PP_1015_write_reg(dev, MA1015W_MOTOR_CONTROL, quadStep);
}
-
+
while (biSteps-- > 0 && dev->desc->state != STATE_CANCELLED)
{
cis_wait_motor_stable (dev);
Mustek_PP_1015_write_reg(dev, MA1015W_MOTOR_CONTROL, biStep);
}
-
+
while (fullSteps-- > 0 && dev->desc->state != STATE_CANCELLED)
{
cis_wait_motor_stable (dev);
@@ -1247,16 +1247,16 @@ cis_move_motor (Mustek_PP_CIS_dev * dev, SANE_Int steps) /* steps @ maxres */
static void
cis_set_et_pd_sti (Mustek_PP_CIS_dev * dev)
{
- Mustek_PP_1015_write_reg(dev, MA1015W_EXPOSE_TIME,
+ Mustek_PP_1015_write_reg(dev, MA1015W_EXPOSE_TIME,
dev->CIS.exposeTime);
- Mustek_PP_1015_write_reg(dev, MA1015W_POWER_ON_DELAY,
+ Mustek_PP_1015_write_reg(dev, MA1015W_POWER_ON_DELAY,
dev->CIS.powerOnDelay[dev->CIS.channel]);
cis_set_ccd_channel (dev);
cis_set_sti (dev);
}
/*
- * Prepare the scanner for catching the next channel and, if necessary,
+ * Prepare the scanner for catching the next channel and, if necessary,
* move the head one step further.
*/
static SANE_Bool
@@ -1264,32 +1264,32 @@ cis_wait_next_channel (Mustek_PP_CIS_dev * dev)
{
int moveAtChannel = dev->desc->mode == MODE_COLOR ?
MUSTEK_PP_CIS_CHANNEL_BLUE : MUSTEK_PP_CIS_CHANNEL_GRAY;
-
+
if (!cis_wait_bank_change (dev, dev->bank_count))
{
DBG(2, "cis_wait_next_channel: Could not get next bank.\n");
return SANE_FALSE;
}
-
+
moveAtChannel = (dev->desc->mode == MODE_COLOR) ?
MUSTEK_PP_CIS_CHANNEL_BLUE : MUSTEK_PP_CIS_CHANNEL_GRAY;
-
+
if (dev->CIS.channel == moveAtChannel && !dev->CIS.dontMove)
{
cis_motor_forward (dev);
}
-
+
cis_set_et_pd_sti (dev);
-
+
if (dev->desc->mode == MODE_COLOR)
{
++dev->CIS.channel;
dev->CIS.channel %= 3;
}
-
+
return SANE_TRUE;
}
-
+
/*
* Wait for the device to be ready for scanning. Cycles through the different
* channels and sets the parameters (only green channel in gray/lineart).
@@ -1299,10 +1299,10 @@ cis_wait_read_ready (Mustek_PP_CIS_dev * dev)
{
int channel;
dev->CIS.dontIncRead = SANE_TRUE;
-
+
dev->CIS.channel = dev->desc->mode == MODE_COLOR ?
MUSTEK_PP_CIS_CHANNEL_RED : MUSTEK_PP_CIS_CHANNEL_GRAY;
-
+
for (channel = 0; channel < 3; ++channel)
{
if (!cis_wait_next_channel(dev)) return SANE_FALSE;
@@ -1313,9 +1313,9 @@ cis_wait_read_ready (Mustek_PP_CIS_dev * dev)
static int
delay_read (int delay)
{
- /*
+ /*
* A (very) smart compiler may complete optimize the delay loop away. By
- * adding some difficult data dependencies, we can try to prevent this.
+ * adding some difficult data dependencies, we can try to prevent this.
*/
static int prevent_removal, i;
for (i = 0; i<delay; ++i)
@@ -1329,8 +1329,8 @@ delay_read (int delay)
** Reads one line of pixels
*/
static void
-cis_read_line_low_level (Mustek_PP_CIS_dev * dev, SANE_Byte * buf,
- SANE_Int pixel, SANE_Byte * calib_low,
+cis_read_line_low_level (Mustek_PP_CIS_dev * dev, SANE_Byte * buf,
+ SANE_Int pixel, SANE_Byte * calib_low,
SANE_Byte * calib_hi, SANE_Int * gamma)
{
u_char color;
@@ -1340,7 +1340,7 @@ cis_read_line_low_level (Mustek_PP_CIS_dev * dev, SANE_Byte * buf,
if (pixel <= 0)
return;
-
+
SANEI_PA4S2_READBEGIN (dev->desc->fd, 1);
while(skips-- >= 0)
@@ -1384,7 +1384,7 @@ cis_read_line_low_level (Mustek_PP_CIS_dev * dev, SANE_Byte * buf,
else if (dev->CIS.hw_hres > dev->CIS.res)
{
/* Sub-sampling */
-
+
int pos = 0;
DBG (6, "cis_read_line_low_level: sub-sampling\n");
ctr = 0;
@@ -1428,8 +1428,8 @@ cis_read_line_low_level (Mustek_PP_CIS_dev * dev, SANE_Byte * buf,
int calctr = 0;
SANE_Int pos = 0, nextPos = 1;
/* Step: eg: 600 DPI -> 700 DPI -> hres_step = 6/7 -> step = 1/7 */
- SANE_Int step = SANE_FIX(1) - dev->CIS.hres_step;
-
+ SANE_Int step = SANE_FIX(1) - dev->CIS.hres_step;
+
/* Super-sampling */
DBG (6, "cis_read_line_low_level: super-sampling\n");
do
@@ -1446,11 +1446,11 @@ cis_read_line_low_level (Mustek_PP_CIS_dev * dev, SANE_Byte * buf,
if (calib_hi) {
hi_val = calib_hi[calctr] ;
}
-
+
if (++calctr >= dev->calib_pixels) {
- /* Avoid array boundary violations due to rounding errors
+ /* Avoid array boundary violations due to rounding errors
(due to the incremental calculation, the current position
- may be inaccurate to up to two pixels, so we may need to
+ may be inaccurate to up to two pixels, so we may need to
read a few extra bytes -> use the last calibration value) */
calctr = dev->calib_pixels - 1;
DBG (3, "cis_read_line_low_level: calibration overshoot\n");
@@ -1467,19 +1467,19 @@ cis_read_line_low_level (Mustek_PP_CIS_dev * dev, SANE_Byte * buf,
cval = gamma[cval];
pos += step;
-
+
if ((pos >> SANE_FIXED_SCALE_SHIFT) >= nextPos)
{
nextPos++;
-
+
/* Insert an interpolated value */
buf[bpos] = (buf[bpos-1] + cval)/2; /* Interpolate */
++bpos;
-
+
/* Store the plain value, but only if we still need pixels */
if (bpos < pixel)
buf[bpos++] = cval;
-
+
pos += step; /* Take interpolated value into account for pos */
}
else
@@ -1489,7 +1489,7 @@ cis_read_line_low_level (Mustek_PP_CIS_dev * dev, SANE_Byte * buf,
}
while (bpos < pixel);
}
-
+
SANEI_PA4S2_READEND (dev->desc->fd);
DBG (6, "cis_read_line_low_level: done\n");
}
@@ -1502,8 +1502,8 @@ cis_read_line (Mustek_PP_CIS_dev * dev, SANE_Byte* buf, SANE_Int pixel,
CIS_INC_READ(dev);
else
dev->CIS.dontIncRead = SANE_FALSE;
-
-
+
+
if (raw)
{
/* No color correction; raw data */
@@ -1513,12 +1513,12 @@ cis_read_line (Mustek_PP_CIS_dev * dev, SANE_Byte* buf, SANE_Int pixel,
{
/* Color correction */
cis_read_line_low_level (dev, buf, pixel,
- dev->calib_low[dev->CIS.channel],
- dev->calib_hi[dev->CIS.channel],
- (dev->desc->val[OPT_CUSTOM_GAMMA].w ?
+ dev->calib_low[dev->CIS.channel],
+ dev->calib_hi[dev->CIS.channel],
+ (dev->desc->val[OPT_CUSTOM_GAMMA].w ?
dev->desc->gamma_table[dev->CIS.channel] : NULL));
}
-
+
return cis_wait_next_channel(dev);
}
@@ -1528,7 +1528,7 @@ cis_get_next_line (Mustek_PP_CIS_dev * dev, SANE_Byte * buf)
SANE_Byte *dest, *tmpbuf = dev->tmpbuf;
int ctr, channel, first, last, stride, step = dev->CIS.line_step;
SANE_Byte gotline;
-
+
if (dev->desc->mode == MODE_COLOR)
{
first = MUSTEK_PP_CIS_CHANNEL_RED;
@@ -1541,7 +1541,7 @@ cis_get_next_line (Mustek_PP_CIS_dev * dev, SANE_Byte * buf)
last = MUSTEK_PP_CIS_CHANNEL_GRAY;
stride = 1;
}
-
+
gotline = SANE_FALSE;
do
{
@@ -1556,8 +1556,8 @@ cis_get_next_line (Mustek_PP_CIS_dev * dev, SANE_Byte * buf)
for (channel = first; channel <= last; ++channel)
{
- if (!cis_read_line(dev, tmpbuf, dev->desc->params.pixels_per_line,
- SANE_FALSE))
+ if (!cis_read_line(dev, tmpbuf, dev->desc->params.pixels_per_line,
+ SANE_FALSE))
return;
dest = buf + channel - first;
@@ -1601,7 +1601,7 @@ cis_get_color_line (Mustek_PP_CIS_dev * dev, SANE_Byte * buf)
/******************************************************************************
* Saves the state of the device during reset and calibration.
*****************************************************************************/
-static void
+static void
cis_save_state (Mustek_PP_CIS_dev * dev)
{
dev->Saved_CIS = dev->CIS;
@@ -1610,7 +1610,7 @@ cis_save_state (Mustek_PP_CIS_dev * dev)
/******************************************************************************
* Restores the state of the device after reset and calibration.
*****************************************************************************/
-static void
+static void
cis_restore_state (Mustek_PP_CIS_dev * dev)
{
dev->CIS = dev->Saved_CIS;
@@ -1624,10 +1624,10 @@ static int
cis_check_result(SANE_Byte* buffer, int pixel)
{
int i, maxVal = 0;
-
- for (i=0;i<pixel;++i)
+
+ for (i=0;i<pixel;++i)
if (buffer[i] > maxVal) maxVal = buffer[i];
-
+
if (maxVal > 250) return CIS_TOO_BRIGHT;
if (maxVal < 240) return CIS_TOO_DARK;
return CIS_OK;
@@ -1641,29 +1641,29 @@ cis_maximize_dynamic_range(Mustek_PP_CIS_dev * dev)
SANE_Byte powerOnDelayLower[3], powerOnDelayUpper[3], exposeTime[3];
SANE_Byte buf[3][MUSTEK_PP_CIS_MAX_H_PIXEL];
SANE_Int pixels = dev->calib_pixels;
-
+
DBG(3, "cis_maximize_dynamic_range: starting\n");
-
+
for (channel = 0; channel < 3; ++channel)
{
exposeTime[channel] = 254;
dev->CIS.powerOnDelay[channel] = 170;
powerOnDelayLower[channel] = 1;
powerOnDelayUpper[channel] = 254;
- }
+ }
dev->CIS.setParameters = SANE_TRUE;
dev->CIS.exposeTime = exposeTime[MUSTEK_PP_CIS_CHANNEL_GREEN];
cis_config_ccd(dev);
-
+
M1015_DISPLAY_REGS(dev, "before maximizing dynamic range");
dev->CIS.dontMove = SANE_TRUE; /* Don't move while calibrating */
-
+
if (!cis_wait_read_ready(dev) && dev->desc->state != STATE_CANCELLED)
{
DBG(2, "cis_maximize_dynamic_range: DEVICE NOT READY!\n");
return SANE_FALSE;
}
-
+
if (dev->desc->mode == MODE_COLOR)
{
first = MUSTEK_PP_CIS_CHANNEL_RED;
@@ -1674,10 +1674,10 @@ cis_maximize_dynamic_range(Mustek_PP_CIS_dev * dev)
first = MUSTEK_PP_CIS_CHANNEL_GRAY;
last = MUSTEK_PP_CIS_CHANNEL_GRAY;
}
-
+
dev->CIS.channel = first;
-
- /* Perform a kind of binary search. In the worst case, we should find
+
+ /* Perform a kind of binary search. In the worst case, we should find
the optimal power delay values after 8 iterations */
for( i=0; i<8; i++)
{
@@ -1686,20 +1686,20 @@ cis_maximize_dynamic_range(Mustek_PP_CIS_dev * dev)
dev->CIS.powerOnDelay[channel] = (powerOnDelayLower[channel] +
powerOnDelayUpper[channel]) / 2;
}
- Mustek_PP_1015_write_reg(dev, MA1015W_POWER_ON_DELAY,
+ Mustek_PP_1015_write_reg(dev, MA1015W_POWER_ON_DELAY,
dev->CIS.powerOnDelay[1]); /* Green */
for (pixel = 0; pixel < pixels; ++pixel)
{
buf[0][pixel] = buf[1][pixel] = buf[2][pixel] = 255;
}
-
+
/* Scan 4 lines, but ignore the first 3 ones. */
for (j = 0; j < 4; ++j)
{
for (channel = first; channel <= last; ++channel)
{
- if (!cis_read_line(dev, &buf[channel][0], pixels,
+ if (!cis_read_line(dev, &buf[channel][0], pixels,
/* raw = */ SANE_TRUE))
return SANE_FALSE;
}
@@ -1711,50 +1711,50 @@ cis_maximize_dynamic_range(Mustek_PP_CIS_dev * dev)
{
case CIS_TOO_BRIGHT:
powerOnDelayLower[channel] = dev->CIS.powerOnDelay[channel];
- break;
-
+ break;
+
case CIS_TOO_DARK:
powerOnDelayUpper[channel] = dev->CIS.powerOnDelay[channel];
- break;
-
+ break;
+
default:
- break;
+ break;
}
- }
- DBG (4, "cis_maximize_dynamic_range: power on delay %3d %3d %3d\n",
- dev->CIS.powerOnDelay[0], dev->CIS.powerOnDelay[1],
+ }
+ DBG (4, "cis_maximize_dynamic_range: power on delay %3d %3d %3d\n",
+ dev->CIS.powerOnDelay[0], dev->CIS.powerOnDelay[1],
dev->CIS.powerOnDelay[2]);
}
dev->CIS.dontMove = SANE_FALSE;
-
- DBG (3, "cis_maximize_dynamic_range: power on delay %3d %3d %3d\n",
- dev->CIS.powerOnDelay[0], dev->CIS.powerOnDelay[1],
+
+ DBG (3, "cis_maximize_dynamic_range: power on delay %3d %3d %3d\n",
+ dev->CIS.powerOnDelay[0], dev->CIS.powerOnDelay[1],
dev->CIS.powerOnDelay[2]);
-
+
minExposeTime = (dev->CIS.hw_hres <= 300) ? 170 : 253;
-
+
for (channel = first; channel <= last; ++channel)
{
dev->CIS.powerOnDelay[channel] = (powerOnDelayLower[channel] +
powerOnDelayUpper[channel]) / 2;
exposeTime[channel] -= dev->CIS.powerOnDelay[channel] - 1;
dev->CIS.powerOnDelay[channel] = 1;
-
+
if (exposeTime[channel] < minExposeTime)
{
- dev->CIS.powerOnDelay[channel] +=
+ dev->CIS.powerOnDelay[channel] +=
minExposeTime - exposeTime[channel];
exposeTime[channel] = minExposeTime;
}
- }
-
+ }
+
dev->CIS.exposeTime = exposeTime[MUSTEK_PP_CIS_CHANNEL_GREEN];
-
+
DBG (3, "cis_maximize_dynamic_range: expose time: %3d\n", exposeTime[1]);
- DBG (3, "cis_maximize_dynamic_range: power on delay %3d %3d %3d\n",
- dev->CIS.powerOnDelay[0], dev->CIS.powerOnDelay[1],
+ DBG (3, "cis_maximize_dynamic_range: power on delay %3d %3d %3d\n",
+ dev->CIS.powerOnDelay[0], dev->CIS.powerOnDelay[1],
dev->CIS.powerOnDelay[2]);
-
+
/*
* Short the calibration. Temporary, to find out what is wrong with
* the calibration on a 600 CP.
@@ -1776,29 +1776,29 @@ cis_measure_extremes(Mustek_PP_CIS_dev * dev, SANE_Byte* calib[3],
SANE_Byte max[3][MUSTEK_PP_CIS_MAX_H_PIXEL];
SANE_Int sum[3][MUSTEK_PP_CIS_MAX_H_PIXEL];
int channel, cnt, p;
-
+
memset((void*)&min, 255, 3*MUSTEK_PP_CIS_MAX_H_PIXEL*sizeof(SANE_Byte));
memset((void*)&max, 0, 3*MUSTEK_PP_CIS_MAX_H_PIXEL*sizeof(SANE_Byte));
memset((void*)&sum, 0, 3*MUSTEK_PP_CIS_MAX_H_PIXEL*sizeof(SANE_Int));
-
+
dev->CIS.channel = first;
-
+
/* Purge the banks first (there's always a 3-cycle delay) */
for (channel = first; channel <= last; ++channel)
{
- if (!cis_read_line(dev, &buf[channel%3][0], pixels,
+ if (!cis_read_line(dev, &buf[channel%3][0], pixels,
/* raw = */ SANE_TRUE))
return SANE_FALSE;
}
--dev->CIS.skipsToOrigin;
-
+
for (cnt = 0; cnt < MUSTEK_PP_CIS_AVERAGE_COUNT + 2; ++cnt)
{
for (channel = first; channel <= last; ++channel)
{
- DBG(4, "cis_measure_extremes: Reading line %d - channel %d\n",
+ DBG(4, "cis_measure_extremes: Reading line %d - channel %d\n",
cnt, channel);
- if (!cis_read_line(dev, &buf[channel][0], pixels,
+ if (!cis_read_line(dev, &buf[channel][0], pixels,
/* raw = */ SANE_TRUE))
return SANE_FALSE;
@@ -1813,7 +1813,7 @@ cis_measure_extremes(Mustek_PP_CIS_dev * dev, SANE_Byte* calib[3],
--dev->CIS.skipsToOrigin;
}
DBG(4, "cis_measure_extremes: Averaging\n");
- for (channel = first; channel <= last; ++channel)
+ for (channel = first; channel <= last; ++channel)
{
/* Ignore the extreme values and take the average of the others. */
for (p = 0; p < pixels; ++p)
@@ -1825,7 +1825,7 @@ cis_measure_extremes(Mustek_PP_CIS_dev * dev, SANE_Byte* calib[3],
}
DBG(4, "cis_measure_extremes: Done\n");
return SANE_TRUE;
-}
+}
static SANE_Bool
cis_normalize_ranges(Mustek_PP_CIS_dev * dev)
@@ -1834,7 +1834,7 @@ cis_normalize_ranges(Mustek_PP_CIS_dev * dev)
SANE_Byte powerOnDelay[3] ;
SANE_Int pixels = dev->calib_pixels;
SANE_Int channel, p, first, last;
-
+
if (dev->desc->mode == MODE_COLOR)
{
first = MUSTEK_PP_CIS_CHANNEL_RED;
@@ -1845,7 +1845,7 @@ cis_normalize_ranges(Mustek_PP_CIS_dev * dev)
first = MUSTEK_PP_CIS_CHANNEL_GRAY;
last = MUSTEK_PP_CIS_CHANNEL_GRAY;
}
-
+
DBG(3, "cis_normalize_ranges: Measuring high extremes\n");
/* Measure extremes with normal lighting */
if (!cis_measure_extremes(dev, dev->calib_hi, pixels, first, last)) {
@@ -1857,17 +1857,17 @@ cis_normalize_ranges(Mustek_PP_CIS_dev * dev)
powerOnDelay[channel] = dev->CIS.powerOnDelay[channel];
dev->CIS.powerOnDelay[channel] = dev->CIS.exposeTime;
}
-
+
DBG(3, "cis_normalize_ranges: Measuring low extremes\n");
if (!cis_measure_extremes(dev, dev->calib_low, pixels, first, last)) {
return SANE_FALSE;
}
-
+
/* Restore settings */
for (channel=first; channel<=last; ++channel) {
dev->CIS.powerOnDelay[channel] = powerOnDelay[channel];
}
-
+
/* Make sure calib_hi is greater than calib_low */
for (channel = first; channel <= last; ++channel) {
for (p = 0; p<pixels; p++) {
@@ -1894,16 +1894,16 @@ cis_normalize_ranges(Mustek_PP_CIS_dev * dev)
}
DBG(3, "cis_normalize_ranges: calibration done\n");
return SANE_TRUE;
-}
+}
/*
- * This routine measures the time that we have to wait between reading
+ * This routine measures the time that we have to wait between reading
* to pixels from the scanner. Especially at low resolutions, but also
* for narrow-width scans at high resolutions, reading too fast cause
- * color stability problems.
+ * color stability problems.
* This routine sends a test pattern to the scanner memory banks and tries
- * to measure how fast it can be retrieved without errors.
- * The same is done by the TWAIN driver (TESTIO.CPP:TestDelay).
+ * to measure how fast it can be retrieved without errors.
+ * The same is done by the TWAIN driver (TESTIO.CPP:TestDelay).
*/
static SANE_Bool
cis_measure_delay(Mustek_PP_CIS_dev * dev)
@@ -1912,7 +1912,7 @@ cis_measure_delay(Mustek_PP_CIS_dev * dev)
unsigned i, j, d;
int saved_res;
SANE_Bool error = SANE_FALSE;
-
+
CIS_CLEAR_FULLFLAG(dev);
CIS_CLEAR_WRITE_ADDR(dev);
CIS_CLEAR_WRITE_BANK(dev);
@@ -1921,26 +1921,26 @@ cis_measure_delay(Mustek_PP_CIS_dev * dev)
M1015_DISPLAY_REGS(dev, "Before delay measurement");
assert(dev->CIS.adjustskip == 0);
-
+
/* Sawtooth */
for (i=0; i<2048; ++i)
{
buf[0][i] = i % 255; /* Why 255 ? Seems to have no real importance */
}
-
+
Mustek_PP_1015_write_reg_start(dev, MA1015W_SRAM_SOURCE_PC);
for (i=0; i<2048; ++i)
{
Mustek_PP_1015_write_reg_val(dev, buf[0][i]);
}
Mustek_PP_1015_write_reg_stop(dev);
-
+
/* Bank offset measurement */
dev->CIS.delay = 0; /* Initialize to zero, measure next */
-
+
saved_res = dev->CIS.res;
dev->CIS.res = dev->CIS.hw_hres;
-
+
/*
* Note: the TWAIN driver seems to have a fast EPP mode too. That one is
* tried first, and then they try the normal mode. I haven't figured out
@@ -1953,7 +1953,7 @@ cis_measure_delay(Mustek_PP_CIS_dev * dev)
for (d = 0; d < 75 /* 255 */ && dev->desc->state != STATE_CANCELLED; d += 5)
{
dev->CIS.delay = d;
-
+
/*
* We read the line 5 times to make sure that all garbage is flushed.
*/
@@ -1964,7 +1964,7 @@ cis_measure_delay(Mustek_PP_CIS_dev * dev)
cis_read_line_low_level (dev, &buf[1][0], 2048, NULL, NULL, NULL);
if (dev->desc->state == STATE_CANCELLED) return SANE_FALSE;
}
-
+
error = SANE_FALSE;
/* Check 100 times whether we can read without errors. */
for (i=0; i<100 && !error; ++i)
@@ -1973,24 +1973,24 @@ cis_measure_delay(Mustek_PP_CIS_dev * dev)
CIS_CLEAR_READ_BANK(dev);
cis_read_line_low_level (dev, &buf[1][0], 2048, NULL, NULL, NULL);
if (dev->desc->state == STATE_CANCELLED) return SANE_FALSE;
-
+
for (j=0; j<2048; ++j)
{
- if (buf[0][j] != buf[1][j])
+ if (buf[0][j] != buf[1][j])
{
error = SANE_TRUE;
break;
}
}
}
-
- DBG (3, "cis_measure_delay: delay %d\n", dev->CIS.delay);
+
+ DBG (3, "cis_measure_delay: delay %d\n", dev->CIS.delay);
if (!error)
break;
}
-
+
dev->CIS.res = saved_res;
-
+
if (error)
{
fprintf(stderr, "mustek_pp_cis: failed to measure delay.\n");
@@ -2000,10 +2000,10 @@ cis_measure_delay(Mustek_PP_CIS_dev * dev)
fprintf(stderr, "%d ", buf[1][j]);
}
fprintf(stderr, "\n");
- dev->CIS.delay = 0;
+ dev->CIS.delay = 0;
}
-
- DBG (3, "cis_measure_delay: delay %d\n", dev->CIS.delay);
+
+ DBG (3, "cis_measure_delay: delay %d\n", dev->CIS.delay);
return SANE_TRUE;
}
@@ -2023,11 +2023,11 @@ cis_return_home (Mustek_PP_CIS_dev * dev, SANE_Bool nowait)
dev->CIS.exposeTime = 170;
cis_config_ccd(dev);
dev->CIS.exposeTime = savedExposeTime;
-
+
cis_motor_control (dev, 0xEB);
if (nowait == SANE_FALSE)
- Mustek_PP_1015_wait_bit(dev, MA1015R_MOTOR, MA1015B_MOTOR_HOME,
+ Mustek_PP_1015_wait_bit(dev, MA1015R_MOTOR, MA1015B_MOTOR_HOME,
SANE_TRUE, 1000);
}
@@ -2043,25 +2043,25 @@ cis_reset_device (Mustek_PP_CIS_dev * dev)
dev->CIS.adjustskip = 0;
dev->CIS.dontIncRead = SANE_TRUE;
dev->CIS.dontMove = SANE_FALSE;
-
+
cis_save_state(dev);
dev->CIS.hw_hres = 300;
dev->CIS.channel = MUSTEK_PP_CIS_CHANNEL_GREEN;
dev->CIS.setParameters = SANE_FALSE;
dev->CIS.exposeTime = 0xAA;
-
+
cis_config_ccd (dev);
-
+
cis_restore_state(dev);
-
+
}
static SANE_Bool
cis_calibrate (Mustek_PP_CIS_dev * dev)
{
int i, saved_res = dev->CIS.res, saved_vres = dev->CIS.hw_vres;
-
+
/*
* Flow of operation observed from the twain driver
* (it is assumed that the lamp is at the origin, and that the CIS is
@@ -2078,11 +2078,11 @@ cis_calibrate (Mustek_PP_CIS_dev * dev)
* doesn't seem to be any correlation with the current mode of the
* scanner, so I assume that the exact number isn't really relevant.
* The values that are read are the one that were sent to the bank,
- * rotated by 1 byte in my case.
+ * rotated by 1 byte in my case.
*
*
- * It seems that the width of the black border is being measured at
- * this stage, possibly multiple times till it stabilizes.
+ * It seems that the width of the black border is being measured at
+ * this stage, possibly multiple times till it stabilizes.
* I assume that the buffer is read 100 times to allow the lamp to
* warm up and that the width of the black border is then being
* measured till it stabilizes. That would explain the minimum number
@@ -2091,38 +2091,38 @@ cis_calibrate (Mustek_PP_CIS_dev * dev)
* - reset the device
*
* - move the motor 110 steps forward. The TWAIN driver moves 90 steps,
- * and I've used 90 steps for a long time too, but occasionally,
- * 90 steps is a fraction to short to reach the start of the
+ * and I've used 90 steps for a long time too, but occasionally,
+ * 90 steps is a fraction to short to reach the start of the
* calibration strip (the motor movements are not very accurate;
* an offset of 1 mm is not unusual). Therefore, I've increased it to
* 110 steps. This gives us an additional 1.6 mm slack, which should
- * prevent calibration errors.
- * (Note that the MUSTEK_PP_CIS_????CP_DEFAULT_SKIP constants have to
+ * prevent calibration errors.
+ * (Note that the MUSTEK_PP_CIS_????CP_DEFAULT_SKIP constants have to
* be adjusted if the number of steps is altered.)
*
* - configure the CIS : actual resolution + set parameters
- *
+ *
*/
-
- /*
+
+ /*
* We must make sure that we are in the scanning state; otherwise we may
* still be in the canceled state from a previous scan (even if terminated
- * normally), and the whole calibration would go wrong.
- */
+ * normally), and the whole calibration would go wrong.
+ */
dev->desc->state = STATE_SCANNING;
-
+
cis_reset_device (dev);
cis_return_home (dev, SANE_FALSE); /* Wait till it's home */
-
+
/* Use maximum resolution during calibration; otherwise we may calibrate
past the calibration strip. */
dev->CIS.hw_vres = dev->desc->dev->maxres;
/* This field remembers how many steps we still have to go @ max res */
dev->CIS.skipsToOrigin = dev->top_skip; /*max2hw_vres(dev, dev->top_skip); */
-
+
if (!cis_measure_delay(dev))
return SANE_FALSE;
-
+
cis_reset_device (dev);
/* Move motor 110 steps @ 300 DPI */
@@ -2140,30 +2140,30 @@ cis_calibrate (Mustek_PP_CIS_dev * dev)
cis_wait_motor_stable (dev);
}
Mustek_PP_1015_write_reg_stop(dev);
-
+
/* Next, we maximize the dynamic range of the scanner. During calibration
we don't want to extrapolate, so we limit the resolution if necessary */
-
- if (dev->CIS.hw_hres < dev->CIS.res)
+
+ if (dev->CIS.hw_hres < dev->CIS.res)
dev->CIS.res = dev->CIS.hw_hres;
-
+
if (!cis_maximize_dynamic_range(dev))
return SANE_FALSE;
-
+
if (!cis_normalize_ranges(dev))
return SANE_FALSE;
-
+
dev->CIS.res = saved_res;
dev->CIS.hw_vres = saved_vres;
-
+
/* Convert steps back to max res size, which are used during skipping */
/* dev->CIS.skipsToOrigin = hw2max_vres(dev, dev->CIS.skipsToOrigin); */
-
+
/* Move to the origin */
- DBG(3, "cis_calibrate: remaining skips to origin @maxres: %d\n",
+ DBG(3, "cis_calibrate: remaining skips to origin @maxres: %d\n",
dev->CIS.skipsToOrigin);
cis_move_motor(dev, dev->CIS.skipsToOrigin);
-
+
if (dev->calib_mode)
{
/* In calibration mode, we scan the interior of the scanner before the
@@ -2172,10 +2172,10 @@ cis_calibrate (Mustek_PP_CIS_dev * dev)
DBG(3, "cis_calibrate: running in calibration mode. Returning home.\n");
cis_return_home (dev, SANE_FALSE); /* Wait till it's home */
}
-
+
return dev->desc->state != STATE_CANCELLED ? SANE_TRUE : SANE_FALSE;
-
-}
+
+}
/******************************************************************************
******************************************************************************
@@ -2189,7 +2189,7 @@ cis_calibrate (Mustek_PP_CIS_dev * dev)
/* Shared initialization routine */
static SANE_Status cis_attach(SANE_String_Const port,
- SANE_String_Const name,
+ SANE_String_Const name,
SANE_Attach_Callback attach,
SANE_Int driverNo,
SANE_Int info)
@@ -2204,19 +2204,19 @@ static SANE_Status cis_attach(SANE_String_Const port,
{
SANE_Status altStatus;
SANE_String_Const altPort;
-
+
DBG (2, "cis_attach: couldn't attach to `%s' (%s)\n", port,
sane_strstatus (status));
-
- /* Make migration to libieee1284 painless for users that used
+
+ /* Make migration to libieee1284 painless for users that used
direct io in the past */
if (strcmp(port, "0x378") == 0) altPort = "parport0";
else if (strcmp(port, "0x278") == 0) altPort = "parport1";
else if (strcmp(port, "0x3BC") == 0) altPort = "parport2";
else return status;
-
+
DBG (2, "cis_attach: trying alternative port name: %s\n", altPort);
-
+
altStatus = sanei_pa4s2_open (altPort, &fd);
if (altStatus != SANE_STATUS_GOOD)
{
@@ -2225,7 +2225,7 @@ static SANE_Status cis_attach(SANE_String_Const port,
return status; /* Return original status, not alternative status */
}
}
-
+
M1015_START_LL;
M1015_START_HL;
@@ -2237,17 +2237,17 @@ static SANE_Status cis_attach(SANE_String_Const port,
sanei_pa4s2_enable (fd, SANE_FALSE);
sanei_pa4s2_close (fd);
-
+
if (asic != 0xA5) /* Identifies the MA1015 chipset */
{
/* CIS driver only works for MA1015 chipset */
DBG (2, "cis_attach: asic id (0x%02x) not recognized\n", asic);
- return SANE_STATUS_INVAL;
+ return SANE_STATUS_INVAL;
}
DBG (3, "cis_attach: device %s attached\n", name);
DBG (3, "cis_attach: asic 0x%02x\n", asic);
-
+
return attach(port, name, driverNo, info);
}
@@ -2292,7 +2292,7 @@ void cis_drv_capabilities(SANE_Int info, SANE_String *model,
*caps = CAP_NOTHING;
switch(info)
- {
+ {
case MUSTEK_PP_CIS600:
*model = strdup("600CP");
*maxres = 600;
@@ -2338,19 +2338,19 @@ SANE_Status cis_drv_open (SANE_String port, SANE_Int caps, SANE_Int *fd)
{
SANE_Status altStatus;
SANE_String_Const altPort;
-
+
DBG (2, "cis_attach: couldn't attach to `%s' (%s)\n", port,
sane_strstatus (status));
-
- /* Make migration to libieee1284 painless for users that used
+
+ /* Make migration to libieee1284 painless for users that used
direct io in the past */
if (strcmp(port, "0x378") == 0) altPort = "parport0";
else if (strcmp(port, "0x278") == 0) altPort = "parport1";
else if (strcmp(port, "0x3BC") == 0) altPort = "parport2";
else return status;
-
+
DBG (2, "cis_attach: trying alternative port name: %s\n", altPort);
-
+
altStatus = sanei_pa4s2_open (altPort, fd);
if (altStatus != SANE_STATUS_GOOD)
{
@@ -2379,16 +2379,16 @@ void cis_drv_setup (SANE_Handle hndl)
}
memset(cisdev, 0, sizeof(Mustek_PP_CIS_dev));
DBG(3, "cis_drv_setup: cis device allocated\n");
-
+
dev->lamp_on = 0;
dev->priv = cisdev;
-
+
cisdev->desc = dev;
cisdev->model = dev->dev->info;
cisdev->CIS.hw_hres = 300;
cisdev->CIS.cisRes = 300;
cisdev->CIS.hw_vres = 300;
-
+
/* Default values for configurable parameters; configuration file
may override them. */
cisdev->fast_skip = SANE_TRUE;
@@ -2424,7 +2424,7 @@ SANE_Status cis_drv_config(SANE_Handle hndl, SANE_String_Const optname,
return SANE_STATUS_INVAL;
}
dvalue = atof(optval);
-
+
/* An adjustment of +/- 5 mm should be sufficient and safe */
if (dvalue < -5.0)
{
@@ -2440,13 +2440,13 @@ SANE_Status cis_drv_config(SANE_Handle hndl, SANE_String_Const optname,
}
/* In practice, there is a lower bound on the value that can be used,
but if the top_skip value is smaller than that value, the only result
- will be that the driver tries to move the head a negative number
+ will be that the driver tries to move the head a negative number
of steps after calibration. The move routine just ignores negative
steps, so no harm can be done. */
cisdev->top_skip += MM_TO_PIXEL(dvalue, dev->dev->maxres);
- DBG (3, "cis_drv_config: setting top skip value to %d\n",
+ DBG (3, "cis_drv_config: setting top skip value to %d\n",
cisdev->top_skip);
-
+
/* Just to be cautious; we don't want the head to hit the bottom */
if (cisdev->top_skip > 600) cisdev->top_skip = 600;
if (cisdev->top_skip < -600) cisdev->top_skip = -600;
@@ -2519,7 +2519,7 @@ void cis_drv_close (SANE_Handle hndl)
Mustek_pp_Handle *dev = hndl;
Mustek_PP_CIS_dev *cisdev = dev->priv;
DBG (3, "cis_close: resetting device.\n");
- sanei_pa4s2_enable (dev->fd, SANE_TRUE);
+ sanei_pa4s2_enable (dev->fd, SANE_TRUE);
cis_reset_device (cisdev);
DBG (3, "cis_close: returning home.\n");
cis_return_home (cisdev, SANE_TRUE); /* Don't wait */
@@ -2541,7 +2541,7 @@ SANE_Status cis_drv_start (SANE_Handle hndl)
Mustek_pp_Handle *dev = hndl;
Mustek_PP_CIS_dev *cisdev = dev->priv;
SANE_Int pixels = dev->params.pixels_per_line;
-
+
if (!cisdev)
{
DBG (2, "cis_drv_start: not enough memory for device\n");
@@ -2629,7 +2629,7 @@ SANE_Status cis_drv_start (SANE_Handle hndl)
(cisdev->model == MUSTEK_PP_CIS1200 && dev->res <= 300))
cisdev->CIS.cisRes = 300;
else
- cisdev->CIS.cisRes = 600;
+ cisdev->CIS.cisRes = 600;
/* Calibration only makes sense for hardware pixels, not for interpolated
pixels, so we limit the number of calibration pixels to the maximum
@@ -2638,10 +2638,10 @@ SANE_Status cis_drv_start (SANE_Handle hndl)
cisdev->calib_pixels = (pixels * cisdev->CIS.hw_hres) / dev->res;
else
cisdev->calib_pixels = pixels;
-
- DBG (3, "cis_drv_start: hres: %d vres: %d cisres: %d\n",
+
+ DBG (3, "cis_drv_start: hres: %d vres: %d cisres: %d\n",
cisdev->CIS.hw_hres, cisdev->CIS.hw_vres, cisdev->CIS.cisRes);
-
+
sanei_pa4s2_enable (dev->fd, SANE_TRUE);
cis_reset_device (cisdev);
@@ -2653,7 +2653,7 @@ SANE_Status cis_drv_start (SANE_Handle hndl)
/*
* Set all registers to -1 (uninitialized)
- */
+ */
for (i=0; i<4; ++i)
{
cisdev->CIS.regs.in_regs[i] = -1;
@@ -2682,12 +2682,12 @@ SANE_Status cis_drv_start (SANE_Handle hndl)
dev->priv = NULL;
return SANE_STATUS_NO_MEM;
}
-
- /* Allocate memory for calibration; calibrating interpolated pixels
+
+ /* Allocate memory for calibration; calibrating interpolated pixels
makes no sense */
- if (pixels > (dev->dev->maxhsize >> 1))
+ if (pixels > (dev->dev->maxhsize >> 1))
pixels = (dev->dev->maxhsize >> 1);
-
+
cisdev->calib_low[1] = malloc (pixels);
cisdev->calib_hi[1] = malloc (pixels);
@@ -2751,7 +2751,7 @@ SANE_Status cis_drv_start (SANE_Handle hndl)
cis_move_motor (cisdev, dev->topY); /* Measured in max resolution */
- /* It is vital to reinitialize the scanner right before we start the
+ /* It is vital to reinitialize the scanner right before we start the
real scanning. Otherwise the bank synchronization may have gotten lost
by the time we reach the top of the scan area */
@@ -2759,12 +2759,12 @@ SANE_Status cis_drv_start (SANE_Handle hndl)
cis_config_ccd(cisdev);
cis_wait_read_ready(cisdev);
- sanei_pa4s2_enable (dev->fd, SANE_FALSE);
+ sanei_pa4s2_enable (dev->fd, SANE_FALSE);
cisdev->CIS.line_step =
SANE_FIX ((float) cisdev->CIS.hw_vres / (float) cisdev->CIS.res);
- /*
+ /*
* It is very important that line_diff is not initialized at zero !
* If it is set to zero, the motor will keep on moving forever (or better,
* till the scanner breaks).
@@ -2789,7 +2789,7 @@ void cis_drv_read (SANE_Handle hndl, SANE_Byte *buffer)
Mustek_pp_Handle *dev = hndl;
Mustek_PP_CIS_dev *cisdev = dev->priv;
DBG(6, "cis_drv_read: Reading line\n");
- sanei_pa4s2_enable (dev->fd, SANE_TRUE);
+ sanei_pa4s2_enable (dev->fd, SANE_TRUE);
switch (dev->mode)
{
case MODE_BW:
@@ -2814,13 +2814,13 @@ void cis_drv_stop (SANE_Handle hndl)
{
Mustek_pp_Handle *dev = hndl;
Mustek_PP_CIS_dev *cisdev = dev->priv;
-
+
/* device is scanning: return lamp and free buffers */
DBG (3, "cis_drv_stop: stopping current scan\n");
dev->state = STATE_CANCELLED;
DBG (9, "cis_drv_stop: enabling fd\n");
- sanei_pa4s2_enable (dev->fd, SANE_TRUE);
+ sanei_pa4s2_enable (dev->fd, SANE_TRUE);
Mustek_PP_1015_write_reg(cisdev, MA1015W_MOTOR_CONTROL, 0); /* stop */
DBG (9, "cis_drv_stop: resetting device (1)\n");
cis_reset_device (cisdev);
@@ -2829,7 +2829,7 @@ void cis_drv_stop (SANE_Handle hndl)
DBG (9, "cis_drv_stop: resetting device (2)\n");
cis_reset_device (cisdev);
DBG (9, "cis_drv_stop: disabling fd\n");
- sanei_pa4s2_enable (dev->fd, SANE_FALSE);
+ sanei_pa4s2_enable (dev->fd, SANE_FALSE);
DBG (9, "cis_drv_stop: freeing buffers\n");
/* This is no good: canceling while the device is scanning and