- possible fix for failed scan at 300 and 1200 dpi for

HP4400 with sensor type 2
merge-requests/1/head
Stéphane Voltz 2008-12-03 20:33:31 +00:00
rodzic e629a77f7e
commit e04240297d
3 zmienionych plików z 94 dodań i 42 usunięć

Wyświetl plik

@ -1,3 +1,7 @@
2008-12-03 Stéphane Voltz <stef.dev@free.fr>
* backend/rts8891.c backend/rts8891_low.c: possible fix for
failed scan at 300 and 1200 dpi for HP4400, sensor type 2.
2008-12-01 Julien Blache <jb@jblache.org>
* sanei/sanei_usb.c: fix assignment in if clause, reported on
sane-devel.

Wyświetl plik

@ -118,7 +118,7 @@
/* #define FAST_INIT 1 */
#define BUILD 10
#define BUILD 12
#define MOVE_DPI 100
@ -321,7 +321,7 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize)
DBG (DBG_proc, "sane_init: start\n");
if (version_code)
*version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, 0);
*version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, BUILD);
/* cold-plugging case : probe for allready plugged devices */
status = probe_rts8891_devices ();
@ -5463,7 +5463,7 @@ shading_calibration (struct Rts8891_Device *dev, SANE_Bool color, int mode,
dev->regs[0x8a] = 0x00; /* 0x01 */
dev->regs[0x8d] = 0x00; /* 0x77 */
/* c5,c6 ?? */
dev->regs[0xd3] = 0x02; /* 0x0e */
/* dev->regs[0xd3] = 0x02; 0x0e */
dev->regs[0xd4] = 0x04; /* 0x10 */
dev->regs[0xe2] = 0x02; /* 0x05 */
/* dev->regs[0xe5] = 0xbb;
@ -5524,7 +5524,7 @@ shading_calibration (struct Rts8891_Device *dev, SANE_Bool color, int mode,
dev->regs[0xd0] = 0xe8;
dev->regs[0xd1] = 0xf6;
dev->regs[0xd2] = 0x17;
dev->regs[0xd3] = 0x0b;
/* dev->regs[0xd3] = 0x0b; */
dev->regs[0xd4] = 0x0d;
/* dev->regs[0xe5] = 0xe4; */
SET_DOUBLE (dev->regs, EXPOSURE_REG, 228);
@ -5555,7 +5555,7 @@ shading_calibration (struct Rts8891_Device *dev, SANE_Bool color, int mode,
dev->regs[0xd1] = 0xf7;
dev->regs[0xd2] = 0x00;
dev->regs[0xd3] = 0x0e;
/* dev->regs[0xd3] = 0x0e; */
dev->regs[0xd4] = 0x10;
/* dev->regs[0xe5] = 0xe4; */
@ -5592,7 +5592,7 @@ shading_calibration (struct Rts8891_Device *dev, SANE_Bool color, int mode,
dev->regs[0xd0] = 0xe8;
dev->regs[0xd1] = 0xf6;
dev->regs[0xd2] = 0x17;
dev->regs[0xd3] = 0x0b;
/* dev->regs[0xd3] = 0x0b; */
dev->regs[0xd4] = 0x0d;
SET_DOUBLE (dev->regs, EXPOSURE_REG, 457);
break;
@ -5626,7 +5626,7 @@ shading_calibration (struct Rts8891_Device *dev, SANE_Bool color, int mode,
dev->regs[0xd0] = 0xf7; /* 0xea */
dev->regs[0xd1] = 0xea; /* 0xf3 */
dev->regs[0xd2] = 0x0b; /* 0x14 */
dev->regs[0xd3] = 0x17; /* 0x02 */
/* dev->regs[0xd3] = 0x17; 0x02 */
dev->regs[0xd4] = 0x01; /* 0x04 */
dev->regs[0xe2] = 0x02; /* 0x05 */
/* regs[0xe5] = 0x93; regs[0xe6] = 0x03; */
@ -5669,7 +5669,7 @@ shading_calibration (struct Rts8891_Device *dev, SANE_Bool color, int mode,
dev->regs[0xd0] = 0xef;
dev->regs[0xd1] = 0xe2;
dev->regs[0xd2] = 0x03;
dev->regs[0xd3] = 0x17;
/* dev->regs[0xd3] = 0x17; */
dev->regs[0xd4] = 0x01;
/* dev->regs[0xe5] = 0xc9;
dev->regs[0xe6] = 0x01; 0x01c9=457 */
@ -5706,7 +5706,7 @@ shading_calibration (struct Rts8891_Device *dev, SANE_Bool color, int mode,
dev->regs[0xd1] = 0xea;
dev->regs[0xd2] = 0x0b;
dev->regs[0xd3] = 0x17;
/* dev->regs[0xd3] = 0x17; */
dev->regs[0xd4] = 0x01;
/* dev->regs[0xe5] = 0xc9;
dev->regs[0xe6] = 0x01; 0x1c9=457 */
@ -5743,7 +5743,7 @@ shading_calibration (struct Rts8891_Device *dev, SANE_Bool color, int mode,
dev->regs[0xd0] = 0xef;
dev->regs[0xd1] = 0xe2;
dev->regs[0xd2] = 0x03;
dev->regs[0xd3] = 0x17;
/* dev->regs[0xd3] = 0x17; */
dev->regs[0xd4] = 0x01;
/* 0x0393 = 915 = 2*457+1 */
SET_DOUBLE (dev->regs, EXPOSURE_REG, 915);
@ -5840,7 +5840,7 @@ shading_calibration (struct Rts8891_Device *dev, SANE_Bool color, int mode,
dev->regs[0xd0] = 0xf4;
dev->regs[0xd1] = 0xe7;
dev->regs[0xd2] = 0x08;
dev->regs[0xd3] = 0x0e;
/* dev->regs[0xd3] = 0x0e; */
dev->regs[0xd4] = 0x10;
dev->regs[0xd7] = 0x31;
break;
@ -5891,7 +5891,7 @@ shading_calibration (struct Rts8891_Device *dev, SANE_Bool color, int mode,
dev->regs[0xd0] = 0xf4;
dev->regs[0xd1] = 0xe7;
dev->regs[0xd2] = 0x08;
dev->regs[0xd3] = 0x0e;
/*dev->regs[0xd3] = 0x0e;*/
dev->regs[0xd4] = 0x10;
dev->regs[0xd7] = 0x31;
dev->regs[0xe2] = 0x02;
@ -5947,7 +5947,7 @@ shading_calibration (struct Rts8891_Device *dev, SANE_Bool color, int mode,
dev->regs[0xd0] = 0xf7;
dev->regs[0xd1] = 0xea;
dev->regs[0xd2] = 0x0b;
dev->regs[0xd3] = 0x17;
/* dev->regs[0xd3] = 0x17; */
dev->regs[0xd4] = 0xc1;
dev->regs[0xd7] = 0x14;
dev->regs[0xd8] = 0xa4;
@ -6001,7 +6001,7 @@ shading_calibration (struct Rts8891_Device *dev, SANE_Bool color, int mode,
dev->regs[0xcd] = 0x00;
dev->regs[0xd1] = 0xec;
dev->regs[0xd2] = 0x0d;
dev->regs[0xd3] = 0x05;
/* dev->regs[0xd3] = 0x05; */
dev->regs[0xd4] = 0x67;
dev->regs[0xd7] = 0x10;
dev->regs[0xd8] = 0x52;
@ -6049,7 +6049,7 @@ shading_calibration (struct Rts8891_Device *dev, SANE_Bool color, int mode,
dev->regs[0xd0] = 0xf7;
dev->regs[0xd1] = 0xec;
dev->regs[0xd2] = 0x0d;
dev->regs[0xd3] = 0x05;
/* dev->regs[0xd3] = 0x05; */
dev->regs[0xd4] = 0x67;
dev->regs[0xd7] = 0x10;
dev->regs[0xd8] = 0x52;
@ -6075,7 +6075,7 @@ shading_calibration (struct Rts8891_Device *dev, SANE_Bool color, int mode,
/* scan shading area */
sanei_rts88xx_set_status (dev->devnum, dev->regs, status1, light);
format = rts8891_data_format (dev->xdpi);
format = rts8891_data_format (dev->xdpi, dev->sensor);
status =
rts8891_simple_scan (dev->devnum, dev->regs, dev->reg_count, format,
size, image);
@ -6357,9 +6357,8 @@ send_calibration_data (struct Rts8891_Session *session)
fclose (calib);
}
/* signals color format from hardware */
/* XXX STEF XXX format = rts8891_data_format (dev->xdpi); */
format= dev->regs[0xd3];
/* signals color format/divisor from hardware */
rts8891_data_format (dev->xdpi, dev->sensor);
status = sanei_rts88xx_write_reg (dev->devnum, 0xd3, &format);
/* for some reason, we have to add 6 to the size for the first write */
@ -7558,6 +7557,9 @@ write_scan_registers (struct Rts8891_Session *session)
break;
}
/* sets divisor */
dev->regs[0xd3] = rts8891_data_format (dev->xdpi, dev->sensor);
/* toggle front panel light to signal gray scan */
if (session->params.format == SANE_FRAME_GRAY)
{

Wyświetl plik

@ -57,7 +57,7 @@
#endif
#include "rts8891_low.h"
#define RTS8891_BUILD 8
#define RTS8891_BUILD 12
#define RTS8891_MAX_REGISTERS 244
/* init rts8891 library */
@ -301,30 +301,74 @@ rts8891_simple_scan (SANE_Int devnum, SANE_Byte * regs, int regcount,
}
/**
* set the data format. Is part of the commit sequence
* set the data format. Is part of the commit sequence. Then returned
* value is the value used in d3 register for a scan.
*/
static SANE_Int
rts8891_data_format (SANE_Int dpi)
rts8891_data_format (SANE_Int dpi, int sensor)
{
SANE_Byte reg = 0x00;
switch (dpi)
/* it seems that lower nibble is a divisor */
if (sensor == SENSOR_TYPE_BARE || sensor == SENSOR_TYPE_XPA)
{
case 75:
reg = 0x02;
break;
case 150:
reg = 0x0e; /* 0x0b : gray */
break;
case 300:
reg = 0x17;
break;
case 600:
reg = 0x02; /* 0x0e : gray */
break;
case 1200:
reg = 0x17; /* 0x05 : gray */
break;
switch (dpi)
{
case 75:
reg = 0x02;
break;
case 150:
if (sensor == SENSOR_TYPE_BARE)
reg = 0x0e;
else
reg = 0x0b;
break;
case 300:
reg = 0x17;
break;
case 600:
if (sensor == SENSOR_TYPE_BARE)
reg = 0x02;
else
reg = 0x0e;
break;
case 1200:
if (sensor == SENSOR_TYPE_BARE)
reg = 0x17;
else
reg = 0x05;
break;
}
}
if (sensor == SENSOR_TYPE_4400 || sensor == SENSOR_TYPE_4400_BARE)
{
switch (dpi)
{
case 75:
reg = 0x02;
break;
case 150:
if (sensor == SENSOR_TYPE_4400)
reg = 0x0b;
else
reg = 0x17;
break;
case 300:
reg = 0x17;
break;
case 600:
if (sensor == SENSOR_TYPE_4400)
reg = 0x0e;
else
reg = 0x02;
break;
case 1200:
if (sensor == SENSOR_TYPE_4400)
reg = 0x05;
else
reg = 0x17;
break;
}
}
return reg;
}
@ -373,15 +417,16 @@ rts8891_move (struct Rts8891_Device *device, SANE_Byte * regs,
SANE_Int distance, SANE_Bool forward)
{
SANE_Status status = SANE_STATUS_GOOD;
SANE_Byte regs10,regs11;
SANE_Byte regs10, regs11;
DBG (DBG_proc, "rts8891_move: start\n");
DBG (DBG_io, "rts8891_move: %d lines %s, sensor=%d\n", distance,
forward == SANE_TRUE ? "forward" : "backward",device->sensor);
forward == SANE_TRUE ? "forward" : "backward", device->sensor);
/* prepare scan */
rts8891_set_default_regs (regs);
if (device->sensor != SENSOR_TYPE_4400 && device->sensor != SENSOR_TYPE_4400_BARE)
if (device->sensor != SENSOR_TYPE_4400
&& device->sensor != SENSOR_TYPE_4400_BARE)
{
regs10 = 0x20;
regs11 = 0x28;
@ -448,7 +493,8 @@ rts8891_move (struct Rts8891_Device *device, SANE_Byte * regs,
regs[0xe9] = 0x02;
/* hp4400 sensors */
if (device->sensor == SENSOR_TYPE_4400 || device->sensor == SENSOR_TYPE_4400_BARE)
if (device->sensor == SENSOR_TYPE_4400
|| device->sensor == SENSOR_TYPE_4400_BARE)
{
regs[0x13] = 0x39; /* 0x20 */
regs[0x14] = 0xf0; /* 0xf8 */