- fixed color data lines reordering for 610P

merge-requests/1/head
Stéphane Voltz 2004-05-13 05:00:28 +00:00
rodzic bb02ac5f19
commit 94e5c585fb
4 zmienionych plików z 147 dodań i 36 usunięć

Wyświetl plik

@ -1,3 +1,8 @@
2004-05-13 Stéphane Voltz <svoltz@wanadoo.fr>
* backend/umax_pp_low.c backend/umax_pp.c tools/umax_pp.c: fixed
data lines reordering for 610P
2004-05-12 Henning Meier-Geinitz <henning@meier-geinitz.de> 2004-05-12 Henning Meier-Geinitz <henning@meier-geinitz.de>
* sane-backends.lsm: Updated FTP server link to ftp.sane-project.org. * sane-backends.lsm: Updated FTP server link to ftp.sane-project.org.

Wyświetl plik

@ -406,7 +406,7 @@ umax_pp_get_sync (SANE_Int dpi)
switch (dpi) switch (dpi)
{ {
case 600: case 600:
return 8; return 16;
case 300: case 300:
return 8; return 8;
case 150: case 150:
@ -2169,6 +2169,9 @@ sane_start (SANE_Handle handle)
{ {
delta = umax_pp_get_sync (dev->dpi); delta = umax_pp_get_sync (dev->dpi);
points = 2 * delta; points = 2 * delta;
/* first lines are 'garbage' for 610P */
if(sanei_umax_pp_getastra()<1210)
points*=2;
DBG (64, "sane_start:umax_pp_start(%d,%d,%d,%d,%d,1,%X,%X)\n", DBG (64, "sane_start:umax_pp_start(%d,%d,%d,%d,%d,1,%X,%X)\n",
dev->TopX, dev->TopX,
dev->TopY - points, dev->TopY - points,
@ -2198,7 +2201,7 @@ sane_start (SANE_Handle handle)
/* to allow reordering, we must */ /* to allow reordering, we must */
/* substract it from real scanning */ /* substract it from real scanning */
/* zone */ /* zone */
dev->th -= 2 * delta; dev->th -= points;
DBG (64, "sane_start: bpp=%d,tw=%d,th=%d\n", dev->bpp, dev->tw, DBG (64, "sane_start: bpp=%d,tw=%d,th=%d\n", dev->bpp, dev->tw,
dev->th); dev->th);
} }
@ -2227,8 +2230,6 @@ sane_start (SANE_Handle handle)
if (rc != UMAX1220P_OK) if (rc != UMAX1220P_OK)
{ {
DBG (2, "sane_start: failure\n"); DBG (2, "sane_start: failure\n");
DEBUG ();
return SANE_STATUS_IO_ERROR; return SANE_STATUS_IO_ERROR;
} }
@ -2238,6 +2239,22 @@ sane_start (SANE_Handle handle)
dev->bufread = 0; dev->bufread = 0;
dev->read = 0; dev->read = 0;
/* leading lines for 610P aren't complete in color mode */
/* and should be discarded */
if((sanei_umax_pp_getastra()<1210)&&(dev->color == UMAX_PP_MODE_COLOR))
{
rc =
sanei_umax_pp_read (2 * delta * dev->tw * dev->bpp, dev->tw, dev->dpi,
0,
dev->buf + UMAX_PP_RESERVE -
2 * delta * dev->tw * dev->bpp);
if (rc != UMAX1220P_OK)
{
DBG (2, "sane_start: first lines discarding failed\n");
return SANE_STATUS_IO_ERROR;
}
}
/* in case of color, we have to preload blue and green */ /* in case of color, we have to preload blue and green */
/* data to allow reordering while later read */ /* data to allow reordering while later read */
if ((dev->color == UMAX_PP_MODE_COLOR) && (delta > 0)) if ((dev->color == UMAX_PP_MODE_COLOR) && (delta > 0))

Wyświetl plik

@ -826,10 +826,18 @@ sanei_parport_find_port (void)
char ** char **
sanei_parport_find_device (void) sanei_parport_find_device (void)
{ {
char *devices[] = { "/dev/ppi0", char *devices[] = {
/* FreeBSD */
"/dev/ppi0",
"/dev/ppi1", "/dev/ppi1",
"/dev/ppi2", "/dev/ppi2",
"/dev/ppi3", "/dev/ppi3",
/* linux ppdev with devfs */
"/dev/parports/0",
"/dev/parports/1",
"/dev/parports/2",
"/dev/parports/3",
/* linux ppdev */
"/dev/parport0", "/dev/parport0",
"/dev/parport1", "/dev/parport1",
"/dev/parport2", "/dev/parport2",
@ -3603,15 +3611,20 @@ init005 (int arg)
int int
putByte610p (int data) putByte610p (int data)
{ {
int status, control; int status, control, j;
j=0;
do {
status = Inb (STATUS) & 0xF8;
j++;
} while((j<20)&&(status & 0x08));
status = Inb (STATUS) & 0xF8;
if ((status != 0xC8) && (status != 0xC0)) if ((status != 0xC8) && (status != 0xC0))
{ {
DBG (0, DBG (0,
"putByte610p failed, expected 0xC8 or 0xC0 got 0x%02X ! (%s:%d)\n", "putByte610p failed, expected 0xC8 or 0xC0 got 0x%02X ! (%s:%d)\n",
status, __FILE__, __LINE__); status, __FILE__, __LINE__);
/* XXX STEF XXX return 0; */ return 0;
} }
control = Inb (CONTROL) & 0x1F; /* data forward */ control = Inb (CONTROL) & 0x1F; /* data forward */
Outb (CONTROL, control); Outb (CONTROL, control);
@ -4550,7 +4563,7 @@ retry:
static int static int
SPPsendWord610p (int *cmd) SPPsendWord610p (int *cmd)
{ {
int i; int i, j;
int tmp, status; int tmp, status;
#ifdef HAVE_LINUX_PPDEV_H #ifdef HAVE_LINUX_PPDEV_H
@ -4620,6 +4633,12 @@ SPPsendWord610p (int *cmd)
return 0; return 0;
} }
status = Inb (STATUS) & 0xF8; status = Inb (STATUS) & 0xF8;
j=0;
while((j<256)&&(status & 0x08))
{
j++;
status = Inb (STATUS) & 0xF8;
}
if ((status != 0x80) && (status != 0xA0)) if ((status != 0x80) && (status != 0xA0))
{ {
DBG (0, "SPPsendWord610p found 0x%X expected 0x80 or 0xA0 (%s:%d)\n", DBG (0, "SPPsendWord610p found 0x%X expected 0x80 or 0xA0 (%s:%d)\n",
@ -10408,7 +10427,7 @@ sanei_umax_pp_scan (int x, int y, int width, int height, int dpi, int color,
int th, tw, bpp; int th, tw, bpp;
int nb; int nb;
int bx, by, delta; int bx, by, delta;
int reserve, rc, remain; int reserve, rc, remain, offset;
/* colors don't come in sync, so we must increase y */ /* colors don't come in sync, so we must increase y */
/* to have extra lines to reorder datas */ /* to have extra lines to reorder datas */
@ -10457,13 +10476,20 @@ sanei_umax_pp_scan (int x, int y, int width, int height, int dpi, int color,
delta = 0; delta = 0;
} }
/* in color mode, we need extra lines to reorder data */
if (color >= RGB_MODE) if (color >= RGB_MODE)
rc = sanei_umax_pp_startScan {
(x, y - 2 * delta, width, height + 2 * delta, dpi, color, brightness, if(sanei_umax_pp_getastra()<=610)
contrast, &bpp, &tw, &th); offset=4 * delta;
else
offset=2 *delta;
}
else else
offset=0;
rc = sanei_umax_pp_startScan rc = sanei_umax_pp_startScan
(x, y, width, height, dpi, color, brightness, contrast, &bpp, &tw, &th); (x, y - offset, width, height + offset, dpi, color, brightness,
contrast, &bpp, &tw, &th);
if (rc == 1) if (rc == 1)
{ {
/* blocksize must be multiple of the number of bytes per line */ /* blocksize must be multiple of the number of bytes per line */
@ -10472,22 +10498,33 @@ sanei_umax_pp_scan (int x, int y, int width, int height, int dpi, int color,
/* write data to file operation */ /* write data to file operation */
/*blocksize=(2096100/bpl)*bpl; */ /*blocksize=(2096100/bpl)*bpl; */
bpl = bpp * tw; bpl = bpp * tw;
hp = 16776960 / bpl; /* 16 Mo buffer (!!) */ /*hp = 16776960 / bpl;*/ /* XXX STEF XXX 16 Mo buffer (!!) */
hp = 2096100 / bpl; hp = 2096100 / bpl;
blocksize = hp * bpl; blocksize = hp * bpl;
nb = 0; nb = 0;
read = 0; somme = bpl * th;
DBG (8, "Getting buffer %d*%d*%d=%ld=0x%lX (%s:%d) \n", bpp, tw, th,
somme, somme, __FILE__, __LINE__);
/* correct th to be usable scan height */
th-=offset;
/* we need a 2 * delta lines reserve to reorder data */ /* we need a 2 * delta lines reserve to reorder data */
if (color >= RGB_MODE) if (color >= RGB_MODE)
reserve = 3 * 2 * delta * tw; {
reserve = 2 * delta * bpl;
if(sanei_umax_pp_getastra()<1210)
offset=reserve;
else
offset=0;
}
else else
{
reserve = 0; reserve = 0;
offset=0;
}
/* get scanned data */ /* get scanned data */
somme = bpp * tw * th;
DBG (8, "Getting buffer %d*%d*%d=%ld=0x%lX (%s:%d) \n", bpp, tw, th,
somme, somme, __FILE__, __LINE__);
/* allocate memory */ /* allocate memory */
buffer = (unsigned char *) malloc (blocksize + reserve); buffer = (unsigned char *) malloc (blocksize + reserve);
@ -10511,15 +10548,51 @@ sanei_umax_pp_scan (int x, int y, int width, int height, int dpi, int color,
/* write pnm header */ /* write pnm header */
if (color >= RGB_MODE) if (color >= RGB_MODE)
fprintf (fout, "P6\n%d %d\n255\n", tw, th - 2 * delta); fprintf (fout, "P6\n%d %d\n255\n", tw, th - 2 * delta);
/*fprintf (fout, "P5\n%d %d\n255\n", tw, 3*th);*/
else else
fprintf (fout, "P5\n%d %d\n255\n", tw, th); fprintf (fout, "P5\n%d %d\n255\n", tw, th);
} }
/* read some line first until we got clean data */
read=0;
remain = 0;
while(read<offset)
{
if (read==0)
len = offset;
else
len = offset - read;
len =
sanei_umax_pp_readBlock (len, tw, dpi, 0, buffer+read);
if (len == 0)
{
DBG (0,
"sanei_umax_pp_readBlock failed, cancelling scan ...\n");
gCancel = 1;
}
read+=len;
}
/* in color mode we have to fill the 'reserve' area
* so that we can reorder data lines */
while((read-offset<reserve)&&(!gCancel))
{
len = reserve - read + offset;
len =
sanei_umax_pp_readBlock (len, tw, dpi, 0, buffer+read-offset);
if (len == 0)
{
DBG (0,
"sanei_umax_pp_readBlock failed, cancelling scan ...\n");
gCancel = 1;
}
read+=len;
}
/* data reading loop */ /* data reading loop */
#ifdef HAVE_SYS_TIME_H #ifdef HAVE_SYS_TIME_H
gettimeofday (&td, NULL); gettimeofday (&td, NULL);
#endif #endif
remain = 0;
while ((read < somme) && (!gCancel)) while ((read < somme) && (!gCancel))
{ {
/* 2096100 max */ /* 2096100 max */
@ -10529,8 +10602,7 @@ sanei_umax_pp_scan (int x, int y, int width, int height, int dpi, int color,
len = somme - read; len = somme - read;
len = len =
sanei_umax_pp_readBlock (len, tw, dpi, (len < blocksize), sanei_umax_pp_readBlock (len, tw, dpi, (len < blocksize),
buffer + (read == buffer + reserve + remain);
0 ? 0 : reserve) + remain);
if (len == 0) if (len == 0)
{ {
DBG (0, DBG (0,
@ -10557,12 +10629,14 @@ sanei_umax_pp_scan (int x, int y, int width, int height, int dpi, int color,
switch (sanei_umax_pp_getastra ()) switch (sanei_umax_pp_getastra ())
{ {
case 6100: case 6100:
fwrite (buffer, len, 1, fout); fwrite (buffer+reserve, hp*bpl, 1, fout);
break; break;
case 610: case 610:
for (by = 0; by < hp - (read == 0 ? 2 * delta : 0); /* first comes RED
by++) * then BLUE
* and finally GREEN */
for (by = 0; by < hp ; by++)
{ {
for (bx = 0; bx < tw; bx++) for (bx = 0; bx < tw; bx++)
{ {
@ -10582,7 +10656,10 @@ sanei_umax_pp_scan (int x, int y, int width, int height, int dpi, int color,
} }
} }
/* copy tail lines for next block */ /* copy tail lines for next block */
memcpy (buffer, buffer + 3 * by * tw, reserve + remain); /* memcpy (buffer,
* (buffer + reserve) + (hp * bpl - reserve),
* reserve + remain); */
memcpy (buffer, buffer + hp * bpl, reserve + remain);
break; break;
case 1600: case 1600:
for (by = 0; by < hp; by++) for (by = 0; by < hp; by++)
@ -10998,21 +11075,34 @@ sanei_umax_pp_startScan (int x, int y, int width, int height, int dpi,
switch (dpi) switch (dpi)
{ {
case 600: case 600:
y += 64; y += 0;
break; break;
case 300: case 300:
y += 48; y += 0;
break; break;
case 150: case 150:
y += 40; y += 0;
break; break;
case 75: case 75:
y += 36; y += 0;
break; break;
} }
else else
y += 48; switch (dpi)
break; {
case 600:
y += 0;
break;
case 300:
y += 0;
break;
case 150:
y += 0;
break;
case 75:
y += 0;
break;
}
default: default:
y += 8; y += 8;
break; break;

Wyświetl plik

@ -336,7 +336,7 @@ main (int argc, char **argv)
} }
if (trace) if (trace)
{ {
printf ("UMAX 610P/1220P/2000P scanning program version 6.0 starting ...\n"); printf ("UMAX 610P/1220P/2000P scanning program version 6.1 starting ...\n");
#ifdef HAVE_LINUX_PPDEV_H #ifdef HAVE_LINUX_PPDEV_H
printf ("ppdev character device built-in.\n"); printf ("ppdev character device built-in.\n");
#endif #endif
@ -388,8 +388,7 @@ main (int argc, char **argv)
printf ("checkModel() failed (%s:%d)\n", __FILE__, __LINE__); printf ("checkModel() failed (%s:%d)\n", __FILE__, __LINE__);
return 0; return 0;
} }
if (trace) printf ("UMAX Astra %dP detected \n", i);
printf ("UMAX Astra %dP detected \n", i);
/* free scanner if a scan is planned */ /* free scanner if a scan is planned */
if (scan) if (scan)