summaryrefslogtreecommitdiff
path: root/backend/umax_pp_low.c
diff options
context:
space:
mode:
Diffstat (limited to 'backend/umax_pp_low.c')
-rw-r--r--backend/umax_pp_low.c142
1 files changed, 75 insertions, 67 deletions
diff --git a/backend/umax_pp_low.c b/backend/umax_pp_low.c
index 1e38aba..c5d9a93 100644
--- a/backend/umax_pp_low.c
+++ b/backend/umax_pp_low.c
@@ -1,5 +1,5 @@
/**
- Copyright (C) 2001-2012 Stéphane Voltz <stef.dev@free.fr>
+ Copyright (C) 2001-2012 Stéphane Voltz <stef.dev@free.fr>
This file is part of the SANE package.
This program is free software; you can redistribute it and/or
@@ -297,7 +297,7 @@ sanei_outb (unsigned int port, unsigned char value)
static void
sanei_insb (unsigned int port, unsigned char *addr, unsigned long count)
{
- int i;
+ unsigned int i;
for (i = 0; i < count; i++)
addr[i] = sanei_inb (port);
@@ -306,7 +306,7 @@ sanei_insb (unsigned int port, unsigned char *addr, unsigned long count)
static void
sanei_insl (unsigned int port, unsigned char *addr, unsigned long count)
{
- int i;
+ unsigned int i;
for (i = 0; i < count * 4; i++)
addr[i] = sanei_inb (port);
@@ -316,7 +316,7 @@ static void
sanei_outsb (unsigned int port, const unsigned char *addr,
unsigned long count)
{
- int i;
+ unsigned int i;
for (i = 0; i < count; i++)
sanei_outb (port, addr[i]);
@@ -326,7 +326,7 @@ static void
sanei_outsl (unsigned int port, const unsigned char *addr,
unsigned long count)
{
- int i;
+ unsigned int i;
for (i = 0; i < count * 4; i++)
sanei_outb (port, addr[i]);
@@ -865,7 +865,7 @@ sanei_parport_find_device (void)
else
{
#ifdef HAVE_LINUX_PPDEV_H
- /* on kernel < 2.4.23, you have to CLAIM the device
+ /* on kernel < 2.4.23, you have to CLAIM the device
* to check it really exists
* we may hang if another program already claimed it
*/
@@ -926,13 +926,22 @@ sanei_parport_find_device (void)
int
sanei_umax_pp_initPort (int port, char *name)
{
- int fd, ectr;
+#ifndef IO_SUPPORT_MISSING
+# ifdef HAVE_LINUX_PPDEV_H
int found = 0;
-#if ((defined HAVE_IOPERM)||(defined HAVE_MACHINE_CPUFUNC_H)||(defined HAVE_LINUX_PPDEV_H))
+ int fd;
int mode, modes, rc;
-#endif
-#ifdef HAVE_LINUX_PPDEV_H
+# ifdef PPGETMODES
char strmodes[160];
+# endif
+# endif
+# ifdef HAVE_DEV_PPBUS_PP_H
+ int found = 0;
+ int fd;
+# endif
+# ifdef HAVE_IOPERM
+ int ectr;
+# endif
#endif
/* since this function must be called before */
@@ -1793,8 +1802,8 @@ sanei_umax_pp_setauto (int autoset)
}
#ifdef HAVE_LINUX_PPDEV_H
-/* set to the parallel port needed using ppdev
- * returns 1 if ok, 0 else
+/* set to the parallel port needed using ppdev
+ * returns 1 if ok, 0 else
*/
static int
ppdev_set_mode (int mode)
@@ -2807,7 +2816,7 @@ ECPregisterRead (int reg)
Outb (CONTROL, 0x4);
- /* ECP FIFO mode, interrupt bit, dma disabled,
+ /* ECP FIFO mode, interrupt bit, dma disabled,
service bit, fifo full=0, fifo empty=0 */
ECPFifoMode (); /*Outb (ECR, 0x60); */
if (waitFifoEmpty () == 0)
@@ -2825,12 +2834,12 @@ ECPregisterRead (int reg)
}
breg = Inb (ECR);
- /* byte mode, interrupt bit, dma disabled,
+ /* byte mode, interrupt bit, dma disabled,
service bit, fifo full=0, fifo empty=0 */
byteMode (); /*Outb (ECR, 0x20); */
Outb (CONTROL, 0x20); /* data reverse */
- /* ECP FIFO mode, interrupt bit, dma disabled,
+ /* ECP FIFO mode, interrupt bit, dma disabled,
service bit, fifo full=0, fifo empty=0 */
ECPFifoMode (); /*Outb (ECR, 0x60); */
if (waitFifoNotEmpty () == 0)
@@ -2859,9 +2868,9 @@ EPPregisterRead (int reg)
#ifdef HAVE_LINUX_PPDEV_H
int fd, mode, rc;
unsigned char breg, bval;
+ int value;
#endif
int control;
- int value;
#ifdef HAVE_LINUX_PPDEV_H
@@ -2910,7 +2919,7 @@ EPPregisterRead (int reg)
control = Inb (CONTROL);
control = (control & 0x1F) | 0x20;
Outb (CONTROL, control);
- value = Inb (EPPDATA);
+ Inb (EPPDATA);
control = Inb (CONTROL);
control = control & 0x1F;
Outb (CONTROL, control);
@@ -2943,9 +2952,8 @@ registerRead (int reg)
static void
ECPregisterWrite (int reg, int value)
{
- unsigned char breg;
-
#ifdef HAVE_LINUX_PPDEV_H
+ unsigned char breg;
int rc, fd;
fd = sanei_umax_pp_getparport ();
@@ -2963,12 +2971,12 @@ ECPregisterWrite (int reg, int value)
}
#endif
- /* standard mode, interrupt bit, dma disabled,
+ /* standard mode, interrupt bit, dma disabled,
service bit, fifo full=0, fifo empty=0 */
compatMode ();
Outb (CONTROL, 0x04); /* reset ? */
- /* ECP FIFO mode, interrupt bit, dma disabled,
+ /* ECP FIFO mode, interrupt bit, dma disabled,
service bit, fifo full=0, fifo empty=0 */
ECPFifoMode (); /*Outb (ECR, 0x60); */
if (waitFifoEmpty () == 0)
@@ -2977,7 +2985,7 @@ ECPregisterWrite (int reg, int value)
__FILE__, __LINE__);
return;
}
- breg = Inb (ECR);
+ Inb (ECR);
Outb (DATA, reg);
if (waitFifoEmpty () == 0)
@@ -2986,7 +2994,7 @@ ECPregisterWrite (int reg, int value)
__FILE__, __LINE__);
return;
}
- breg = Inb (ECR);
+ Inb (ECR);
Outb (ECPDATA, value);
if (waitFifoEmpty () == 0)
@@ -2995,7 +3003,7 @@ ECPregisterWrite (int reg, int value)
__FILE__, __LINE__);
return;
}
- breg = Inb (ECR);
+ Inb (ECR);
Outb (CONTROL, 0x04);
byteMode ();
return;
@@ -3429,8 +3437,8 @@ ECPbufferWrite (int size, unsigned char *source)
}
breg = Inb (ECR);
- /* block transfer direction
- * 0x80 means from scanner to PC, 0xC0 means PC to scanner
+ /* block transfer direction
+ * 0x80 means from scanner to PC, 0xC0 means PC to scanner
*/
Outb (DATA, 0xC0);
@@ -4957,7 +4965,7 @@ sendWord (int *cmd)
/******************************************************************************/
/* ringScanner: returns 1 if scanner present, else 0 */
/******************************************************************************/
-/*
+/*
* in fact this function is really close to CPP macro in
* /usr/src/linux/drivers/block/paride/epat.c .....
* we have almost CPP(8)
@@ -6005,7 +6013,7 @@ initScanner610p (int recover)
return 1;
}
- /* here we do re-homing
+ /* here we do re-homing
* since it is first probe or recover */
/* move forward */
CMDSYNC (0xC2);
@@ -6096,7 +6104,7 @@ initScanner610p (int recover)
/* 1: OK
2: homing happened
3: scanner busy
- 0: init failed
+ 0: init failed
init transport layer
init scanner
@@ -6308,13 +6316,13 @@ sanei_umax_pp_initScanner (int recover)
}
-/*
+/*
1: OK
2: failed, try again
- 0: init failed
+ 0: init failed
initialize the transport layer
-
+
*/
static int
@@ -6400,13 +6408,13 @@ initTransport610p (void)
return 1;
}
-/*
+/*
1: OK
2: failed, try again
- 0: init failed
+ 0: init failed
initialize the transport layer
-
+
*/
static int
@@ -6605,13 +6613,13 @@ initTransport1220P (int recover) /* ECP OK !! */
return 1;
}
-/*
+/*
1: OK
2: failed, try again
- 0: init failed
+ 0: init failed
initialize the transport layer
-
+
*/
int
@@ -6643,7 +6651,7 @@ probe610p (int recover)
return 0;
}
- /* make sure we won't try 1220/200P later
+ /* make sure we won't try 1220/200P later
* since we got here, we have a 610, and in any case
* NOT a 1220P/2000P, since no EPAT present */
sanei_umax_pp_setastra (610);
@@ -6660,7 +6668,7 @@ probe610p (int recover)
}
- /*
+ /*
* try PS2 mode
* returns 1 on success, 0 on failure
*/
@@ -7018,7 +7026,7 @@ probeECP (unsigned char *dest)
* inb ECR,35
*/
/* routine A */
- breg = Inb (CONTROL); /* 0x04 évidemment! */
+ breg = Inb (CONTROL); /* 0x04 évidemment! */
breg = Inb (ECR);
breg = Inb (ECR);
breg = Inb (ECR);
@@ -8617,9 +8625,9 @@ EPPcmdGetBuffer610p (int cmd, int len, unsigned char *buffer)
int word[5];
int count, needed, max;
#ifdef HAVE_LINUX_PPDEV_H
- int fd, mode, rc;
+ int fd, mode, rc, wait;
#endif
- int loop, wait, remain;
+ int loop, remain;
/* first we set length and channel */
/* compute word */
@@ -8702,7 +8710,6 @@ EPPcmdGetBuffer610p (int cmd, int len, unsigned char *buffer)
else
remain = 4;
loop = (needed - remain) / 2;
- wait = 0;
DBG (32, "EPPcmdGetBuffer610p: %d loops to do \n", loop);
status = 0x20;
@@ -8742,6 +8749,7 @@ EPPcmdGetBuffer610p (int cmd, int len, unsigned char *buffer)
/* there is one form for full CCD width reads, and another for other
reads */
#ifdef HAVE_LINUX_PPDEV_H
+ wait = 0;
/* check we have ppdev working */
fd = sanei_umax_pp_getparport ();
if (fd > 0)
@@ -9368,7 +9376,7 @@ cmdGetBlockBuffer (int cmd, int len, int window, unsigned char *buffer)
return read;
}
-/*
+/*
* encodes DC offsets: must be in [0..0x0F] range
*/
static void
@@ -9387,7 +9395,7 @@ decodeDC (int *motor)
}
-/*
+/*
* encodes VGA : must be in [0..0x0F] range
*/
static void
@@ -9402,10 +9410,10 @@ encodeVGA (int vgaRed, int vgaGreen, int vgaBlue, int *motor)
{
motor[10] = (vgaGreen << 4) | vgaBlue;
motor[11] = (motor[11] & 0xF0) | vgaRed;
- /* ancien
- F00: vert
+ /* ancien
+ F00: vert
0F0: bleu
- 00F: rouge
+ 00F: rouge
motor[10] = (vgaRed << 4) | vgaGreen;
motor[11] = (motor[11] & 0xF0) | vgaBlue; */
}
@@ -9693,7 +9701,7 @@ bloc8Decode (int *op)
static int
completionWait (void)
{
- /* for 610P, wait and sync is done while
+ /* for 610P, wait and sync is done while
* reading data from the scanner */
CMDSYNC (0x40);
usleep (100000);
@@ -9893,7 +9901,7 @@ evalGain (int sum, int count)
avg = (float) (sum) / (float) (count);
pct = 100.0 - (avg * 100.0) / targetCode;
gn = (int) (pct / 0.57);
-
+
/* give gain for dark areas a boost */
#ifdef UMAX_PP_DANGEROUS_EXPERIMENT
if(getenv("AREA")!=NULL)
@@ -9907,7 +9915,7 @@ evalGain (int sum, int count)
pct = gn;
avg = exp((-pct)/area)*coeff+cnst;
gn = gn * avg;
-
+
/* bound checking : there are sightings of >127 values being negative */
if (gn < 0)
gn = 0;
@@ -9985,7 +9993,7 @@ computeCalibrationData (int color, int width, unsigned char *source,
/* move head by the distance given using precision or not */
-/* 0: failed
+/* 0: failed
1: success */
static int
move (int distance, int precision, unsigned char *buffer)
@@ -10437,11 +10445,11 @@ shadingCalibration1220p (int color,
/* get calibration data */
/*
if (sanei_umax_pp_getauto ())
- { auto settings doesn't use offset
+ { auto settings doesn't use offset
offset = 0x000;
}
else
- { manual settings
+ { manual settings
gain = 0x777;
offset = 0x000;
}
@@ -10743,7 +10751,7 @@ sanei_umax_pp_scan (int x, int y, int width, int height, int dpi, int color,
read += len;
}
- /* in color mode we have to fill the 'reserve' area
+ /* in color mode we have to fill the 'reserve' area
* so that we can reorder data lines */
while ((read - dataoffset < reserve) && (!gCancel))
{
@@ -10823,8 +10831,8 @@ sanei_umax_pp_scan (int x, int y, int width, int height, int dpi, int color,
}
}
/* copy tail lines for next block */
- /* memcpy (buffer,
- * (buffer + reserve) + (hp * bpl - reserve),
+ /* memcpy (buffer,
+ * (buffer + reserve) + (hp * bpl - reserve),
* reserve + remain); */
memcpy (buffer, buffer + hp * bpl, reserve + remain);
break;
@@ -11194,8 +11202,8 @@ sanei_umax_pp_startScan (int x, int y, int width, int height, int dpi,
th = (height * dpi) / hwdpi;
tw = (width * xdpi) / hwdpi;
- /* corrects y to match exact scan area start
- * and lets room for a leading zone so that
+ /* corrects y to match exact scan area start
+ * and lets room for a leading zone so that
* we can reorder data */
switch (sanei_umax_pp_getastra ())
{
@@ -11476,7 +11484,7 @@ sanei_umax_pp_startScan (int x, int y, int width, int height, int dpi,
/* 3 ccd lines + 3 gamma tables + end tag */
if (sanei_umax_pp_getastra () <= 610)
{
- /* XXX STEF XXX : there is a 4 pixels shift to the right
+ /* XXX STEF XXX : there is a 4 pixels shift to the right
* the first shading correction value applies to the forth
* pixel of scan (at 300 dpi), we allready shift to the left
* when doing shadingCalibration, but now we have to move coeffs
@@ -11504,7 +11512,7 @@ sanei_umax_pp_startScan (int x, int y, int width, int height, int dpi,
return 1;
}
-/*
+/*
* check the scanner model. Return 1220 for
* a 1220P, or 2000 for a 2000P.
* and 610 for a 610p
@@ -11728,7 +11736,7 @@ loadDefaultTables (void)
}
/* set and reread first table */
- /* since 1660P seems to have another type of CCD
+ /* since 1660P seems to have another type of CCD
* this table is not sent/needed
*/
err = 0;
@@ -11829,7 +11837,7 @@ loadDefaultTables (void)
return rc;
}
-/* inquire scanner status
+/* inquire scanner status
* O: failure
* 1: OK
* 2: first scanner init, needs re-homing
@@ -12070,7 +12078,7 @@ offsetCalibration1220p (int color, int *offRed, int *offGreen, int *offBlue)
* computes DC offset to have black pixel really black out of
* CCD ie black gives 0
* 610P doesn't implement method described in LM9811 datasheet
- * but scan a black line with decreasing offsets until the
+ * but scan a black line with decreasing offsets until the
* scanned data reach a 'good black level'.
* returns 1 and DC offsets in the corresponding vars on success .
* On failure, returns 0.
@@ -12247,7 +12255,7 @@ offsetCalibration610p (int color, int *offRed, int *offGreen, int *offBlue)
return 1;
}
-/*
+/*
* generic offset calibration function
*/
static int
@@ -12339,7 +12347,7 @@ coarseGainCalibration610p (int color, int dcRed, int dcGreen, int dcBlue,
/* move back to desired area */
MOVE (-69, PRECISION_OFF, NULL);
- /* first scan : taking a reference full width scan to
+ /* first scan : taking a reference full width scan to
* find usable full width of the CCD
*/
*vgaRed = 0x08;