Faster AFE calibration. Minor fixes. New version: 1.0-28.

DEVEL_2_0_BRANCH-1
Henning Geinitz 2002-10-31 19:50:44 +00:00
rodzic 719d9cdd36
commit 7b590a0cde
7 zmienionych plików z 146 dodań i 117 usunięć

Wyświetl plik

@ -1,6 +1,9 @@
2002-10-31 Henning Meier-Geinitz <henning@meier-geinitz.de>
* configure configure.in: Print installation directories.
* backend/gt68xx.c backend/gt68xx_devices.c backend/gt68xx_high.c
backend/gt68xx_low.c backend/gt68xx_low.h doc/gt68xx/gt68xx.CHANGES:
Faster AFE calibration. Minor fixes. New version: 1.0-28.
2002-10-31 Stéphane Voltz <svoltz@wanadoo.fr>

Wyświetl plik

@ -48,7 +48,7 @@
#include "../include/sane/config.h"
#define BUILD 27
#define BUILD 28
#define MAX_DEBUG
#define WARMUP_TIME 30

Wyświetl plik

@ -49,29 +49,6 @@
#include "gt68xx_gt6801.c"
#include "gt68xx_gt6816.c"
/* Default parameters for the analog frontend (offset, gain) */
static GT68xx_AFE_Parameters default_afe_params = {
0x14, 0x07, 0x14, 0x07, 0x14, 0x07
};
static GT68xx_AFE_Parameters mustek_2400ta_afe_params = {
0x2a, 0x0c, 0x2e, 0x06, 0x2d, 0x07
};
static GT68xx_AFE_Parameters mustek_1200ta_afe_params = {
0x2a, 0x0c, 0x2e, 0x06, 0x2d, 0x07
};
static GT68xx_AFE_Parameters mustek_1200cu_afe_params = {
0x14, 0x06, 0x15, 0x08, 0x11, 0x04
};
/* Default exposure times */
static GT68xx_Exposure_Parameters default_exposure_params = {
0x157, 0x157, 0x157
};
static GT68xx_Command_Set mustek_gt6816_command_set = {
"mustek-gt6816",
@ -160,8 +137,8 @@ static GT68xx_Model mustek_2400ta_model = {
0,
COLOR_ORDER_RGB,
&mustek_2400ta_afe_params,
&default_exposure_params,
{0x2a, 0x0c, 0x2e, 0x06, 0x2d, 0x07},
{0x157, 0x157, 0x157},
SANE_FALSE,
0
/* flatbed values tested */
@ -188,7 +165,7 @@ static GT68xx_Model mustek_2400taplus_model = {
{16, 12, 8, 0},
SANE_FIX (7.41),
SANE_FIX (7.4),
SANE_FIX (219.0),
SANE_FIX (217.5),
SANE_FIX (298.0),
SANE_FIX (0.0),
SANE_FIX (5.0),
@ -203,8 +180,8 @@ static GT68xx_Model mustek_2400taplus_model = {
8,
COLOR_ORDER_RGB,
&mustek_2400ta_afe_params,
&default_exposure_params,
{0x2a, 0x0c, 0x2e, 0x06, 0x2d, 0x07},
{0x157, 0x157, 0x157},
SANE_FALSE,
0
/* Setup and tested */
@ -247,8 +224,8 @@ static GT68xx_Model mustek_1200ta_model = {
0,
COLOR_ORDER_RGB,
&mustek_1200ta_afe_params,
&default_exposure_params,
{0x2a, 0x0c, 0x2e, 0x06, 0x2d, 0x07},
{0x157, 0x157, 0x157},
SANE_FALSE,
0
/* Everything untested */
@ -290,8 +267,8 @@ static GT68xx_Model mustek_1200cuplus_model = {
0,
COLOR_ORDER_BGR,
&default_afe_params,
&default_exposure_params,
{0x14, 0x07, 0x14, 0x07, 0x14, 0x07},
{0x157, 0x157, 0x157},
SANE_TRUE,
0
/* Everything untested */
@ -333,8 +310,8 @@ static GT68xx_Model mustek_2400cuplus_model = {
0,
COLOR_ORDER_BGR,
&default_afe_params,
&default_exposure_params,
{0x1a, 0x16, 0x15, 0x08, 0x0e, 0x02},
{0x157, 0x157, 0x157},
SANE_TRUE,
0
/* Setup and tested */
@ -379,8 +356,8 @@ static GT68xx_Model mustek_1200cu_model = {
0,
COLOR_ORDER_BGR,
&mustek_1200cu_afe_params,
&default_exposure_params,
{0x13, 0x04, 0x15, 0x06, 0x0f, 0x02},
{0x157, 0x157, 0x157},
SANE_TRUE,
0
/* Setup and tested */
@ -422,8 +399,8 @@ static GT68xx_Model mustek_scanexpress1200ubplus_model = {
0,
COLOR_ORDER_BGR,
&mustek_1200cu_afe_params,
&default_exposure_params,
{0x0f, 0x01, 0x15, 0x06, 0x13, 0x04},
{0x157, 0x157, 0x157},
SANE_TRUE,
0
/* Setup and tested */
@ -464,8 +441,8 @@ static GT68xx_Model artec_ultima2000_model = {
0,
COLOR_ORDER_BGR,
&mustek_1200cu_afe_params,
&default_exposure_params,
{0x0f, 0x01, 0x15, 0x06, 0x13, 0x04},
{0x157, 0x157, 0x157},
SANE_TRUE,
GT68XX_FLAG_MIRROR_X | GT68XX_FLAG_MOTOR_HOME | GT68XX_FLAG_OFFSET_INV
/* Setup for Cytron TCM MD 9385 */
@ -507,8 +484,8 @@ static GT68xx_Model mustek_2400cu_model = {
0,
COLOR_ORDER_BGR,
&mustek_1200cu_afe_params,
&default_exposure_params,
{0x0f, 0x01, 0x15, 0x06, 0x13, 0x04},
{0x157, 0x157, 0x157},
SANE_TRUE,
0
/* basically tested, works up to 300 dpi (?) */
@ -550,8 +527,8 @@ static GT68xx_Model mustek_a3usb_model = {
0,
COLOR_ORDER_BGR,
&default_afe_params,
&default_exposure_params,
{0x14, 0x07, 0x14, 0x07, 0x14, 0x07},
{0x157, 0x157, 0x157},
SANE_TRUE,
0
/* Completely untested */
@ -594,8 +571,8 @@ static GT68xx_Model lexmark_x73_model = {
0,
COLOR_ORDER_RGB,
&default_afe_params,
&default_exposure_params,
{0x14, 0x07, 0x14, 0x07, 0x14, 0x07},
{0x157, 0x157, 0x157},
SANE_FALSE,
0
/* 50 dpi and 1200 dpi scan does not work (for lexmark x70); when using

Wyświetl plik

@ -451,7 +451,6 @@ gt68xx_scanner_internal_start_scan (GT68xx_Scanner * scanner)
break;
usleep (100000);
}
if (!ready)
{
XDBG ((5, "%s: scanner still not ready - giving up\n", function_name));
@ -643,6 +642,8 @@ gt68xx_scanner_calibrate (GT68xx_Scanner * scanner,
GT68xx_Scan_Request req;
SANE_Int i;
unsigned int *buffer_pointers[3];
GT68xx_AFE_Parameters *afe = scanner->dev->afe;
GT68xx_Exposure_Parameters *exposure = scanner->dev->exposure;
memcpy (&req, request, sizeof (req));
@ -666,6 +667,11 @@ gt68xx_scanner_calibrate (GT68xx_Scanner * scanner,
else
req.mbs = SANE_TRUE;
DBG (3, "afe 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", afe->r_offset,
afe->r_pga, afe->g_offset, afe->g_pga, afe->b_offset, afe->b_pga);
DBG (3, "exposure 0x%02x 0x%02x 0x%02x\n", exposure->r_time,
exposure->g_time, exposure->b_time);
if (!scanner->calib)
return SANE_STATUS_GOOD;
@ -1436,26 +1442,41 @@ gt68xx_afe_cis_calc_white (GT68xx_Afe_Values * values,
static SANE_Bool
gt68xx_afe_cis_adjust_offset (GT68xx_Afe_Values * values,
unsigned int *black_buffer, SANE_Int off_dist,
SANE_Byte * offset)
unsigned int *black_buffer,
SANE_Int offset_direction, SANE_Byte * offset)
{
SANE_Int offs = *offset;
SANE_Int offs = 0, tmp_offset = *offset;
SANE_Int low = 8, high = 22;
gt68xx_afe_cis_calc_black (values, black_buffer);
if (values->black < 5)
offs += off_dist;
else if (values->black > 15)
offs -= off_dist;
if (values->black < low)
{
offs = (offset_direction * (low - values->black) / 4);
if (offs == 0)
offs = offset_direction;
DBG (5, "black = %d (too low) --> offs = %d\n", values->black, offs);
}
else if (values->black > high)
{
offs = -(offset_direction * (values->black - high) / 7);
if (offs == 0)
offs = -offset_direction;
DBG (5, "black = %d (too high) --> offs = %d\n", values->black, offs);
}
else
{
DBG (5, "black = %d (ok)\n", values->black);
}
if (offs < 0)
offs = 0;
if (offs > 63)
offs = 63;
if (offs == *offset)
if (offs == 0)
return SANE_TRUE;
*offset = offs;
tmp_offset += offs;
if (tmp_offset < 0)
tmp_offset = 0;
if (tmp_offset > 63)
tmp_offset = 63;
*offset = tmp_offset;
return SANE_FALSE;
}
@ -1467,8 +1488,20 @@ gt68xx_afe_cis_adjust_gain (GT68xx_Afe_Values * values,
gt68xx_afe_cis_calc_white (values, white_buffer);
if (values->white < 240)
g += 2;
if (values->white < 235)
{
g += 1;
DBG (5, "white = %d (too low) --> gain += 1\n", values->white);
}
else if (values->white > 250)
{
g -= 1;
DBG (5, "white = %d (too high) --> gain -= 1\n", values->white);
}
else
{
DBG (5, "white = %d (ok)\n", values->white);
}
if (g < 0)
g = 0;
if (g > 63)
@ -1483,20 +1516,27 @@ gt68xx_afe_cis_adjust_gain (GT68xx_Afe_Values * values,
static SANE_Bool
gt68xx_afe_cis_adjust_exposure (GT68xx_Afe_Values * values,
unsigned int *white_buffer,
SANE_Int expos_dist, SANE_Int border,
SANE_Int * exposure_time)
SANE_Int border, SANE_Int * exposure_time)
{
gt68xx_afe_cis_calc_white (values, white_buffer);
if (values->white < border)
{
*exposure_time += expos_dist;
*exposure_time += ((border - values->white) * 2);
DBG (5, "white = %d (too low) --> += %d\n",
values->white, ((border - values->white) * 2));
return SANE_FALSE;
}
if (values->white > border + 10)
else if (values->white > border + 10)
{
*exposure_time -= expos_dist;
*exposure_time -= ((values->white - (border + 10)) * 2);
DBG (5, "white = %d (too high) --> -= %d\n",
values->white, ((values->white - (border + 10)) * 2));
return SANE_FALSE;
}
else
{
DBG (5, "white = %d (ok)\n", values->white);
}
return SANE_TRUE;
}
@ -1591,11 +1631,11 @@ static SANE_Status
gt68xx_afe_cis_auto (GT68xx_Scanner * scanner)
{
DECLARE_FUNCTION_NAME ("gt68xx_afe_cis_auto") SANE_Status status;
int total_count, offset_count;
int total_count, offset_count, exposure_count;
GT68xx_Afe_Values values;
GT68xx_AFE_Parameters *afe = scanner->dev->afe;
GT68xx_Exposure_Parameters *exposure = scanner->dev->exposure;
SANE_Int off_dist, expos_dist;
SANE_Int offset_direction;
SANE_Int done;
SANE_Bool first = SANE_TRUE;
unsigned int *r_buffer = 0, *g_buffer = 0, *b_buffer = 0;
@ -1615,15 +1655,13 @@ gt68xx_afe_cis_auto (GT68xx_Scanner * scanner)
return SANE_STATUS_NO_MEM;
total_count = 0;
afe->r_pga = afe->g_pga = afe->b_pga = 0x06;
/* afe->r_pga = afe->g_pga = afe->b_pga = 0x06; */
do
{
offset_count = 0;
off_dist = 32;
offset_direction = 1;
if (scanner->dev->model->flags & GT68XX_FLAG_OFFSET_INV)
off_dist = -off_dist;
afe->r_offset = afe->g_offset = afe->b_offset = 0x20;
offset_direction = -1;
exposure->r_time = exposure->g_time = exposure->b_time = 0x157;
do
{
@ -1633,23 +1671,23 @@ gt68xx_afe_cis_auto (GT68xx_Scanner * scanner)
/* read black line */
RIE (gt68xx_afe_cis_read_lines (&values, scanner, SANE_FALSE, first,
r_buffer, g_buffer, b_buffer));
off_dist /= 2;
/*offset_direction /= 2; */
done =
gt68xx_afe_cis_adjust_offset (&values, r_buffer, off_dist,
gt68xx_afe_cis_adjust_offset (&values, r_buffer, offset_direction,
&afe->r_offset);
done &=
gt68xx_afe_cis_adjust_offset (&values, g_buffer, off_dist,
gt68xx_afe_cis_adjust_offset (&values, g_buffer, offset_direction,
&afe->g_offset);
done &=
gt68xx_afe_cis_adjust_offset (&values, b_buffer, off_dist,
gt68xx_afe_cis_adjust_offset (&values, b_buffer, offset_direction,
&afe->b_offset);
offset_count++;
total_count++;
first = SANE_FALSE;
}
while (offset_count < 6 && !done);
while (offset_count < 10 && !done);
/* AFE gain */
IF_DBG (gt68xx_afe_dump ("gain", total_count, afe));
@ -1669,8 +1707,7 @@ gt68xx_afe_cis_auto (GT68xx_Scanner * scanner)
IF_DBG (gt68xx_afe_dump ("final", total_count, afe));
/* Exposure time */
expos_dist = exposure->r_time;
exposure_count = 0;
do
{
IF_DBG (gt68xx_afe_exposure_dump ("exposure", total_count, exposure));
@ -1678,21 +1715,21 @@ gt68xx_afe_cis_auto (GT68xx_Scanner * scanner)
/* read white line */
RIE (gt68xx_afe_cis_read_lines (&values, scanner, SANE_TRUE, SANE_FALSE,
r_buffer, g_buffer, b_buffer));
expos_dist /= 2;
done = gt68xx_afe_cis_adjust_exposure (&values, r_buffer, expos_dist,
230, &exposure->r_time);
done &= gt68xx_afe_cis_adjust_exposure (&values, g_buffer, expos_dist,
230, &exposure->g_time);
done &= gt68xx_afe_cis_adjust_exposure (&values, b_buffer, expos_dist,
230, &exposure->b_time);
done = gt68xx_afe_cis_adjust_exposure (&values, r_buffer, 230,
&exposure->r_time);
done &= gt68xx_afe_cis_adjust_exposure (&values, g_buffer, 230,
&exposure->g_time);
done &= gt68xx_afe_cis_adjust_exposure (&values, b_buffer, 230,
&exposure->b_time);
exposure_count++;
total_count++;
}
while (!done && expos_dist > 0);
while (!done && exposure_count < 10);
free (r_buffer);
free (g_buffer);
free (b_buffer);
XDBG ((4, "%s: total_count: %d\n", function_name, total_count));
return SANE_STATUS_GOOD;
}

Wyświetl plik

@ -412,8 +412,8 @@ gt68xx_device_activate (GT68xx_Device * dev)
if (!dev->afe || !dev->exposure)
return SANE_STATUS_NO_MEM;
memcpy (dev->afe, dev->model->afe_params, sizeof (*dev->afe));
memcpy (dev->exposure, dev->model->exposure, sizeof (*dev->exposure));
memcpy (dev->afe, &dev->model->afe_params, sizeof (*dev->afe));
memcpy (dev->exposure, &dev->model->exposure, sizeof (*dev->exposure));
dev->active = SANE_TRUE;
return SANE_STATUS_GOOD;

Wyświetl plik

@ -182,6 +182,28 @@ struct GT68xx_USB_Device_Entry
*/
static GT68xx_USB_Device_Entry gt68xx_usb_device_list[MAX_SCANNERS];
/** GT68xx analog front-end (AFE) parameters.
*/
struct GT68xx_AFE_Parameters
{
SANE_Byte r_offset; /**< Red channel offset */
SANE_Byte r_pga; /**< Red channel PGA gain */
SANE_Byte g_offset; /**< Green channel offset (also used for mono) */
SANE_Byte g_pga; /**< Green channel PGA gain (also used for mono) */
SANE_Byte b_offset; /**< Blue channel offset */
SANE_Byte b_pga; /**< Blue channel PGA gain */
};
/** GT68xx exposure time parameters.
*/
struct GT68xx_Exposure_Parameters
{
SANE_Int r_time; /**< Red exposure time */
SANE_Int g_time; /**< Red exposure time */
SANE_Int b_time; /**< Red exposure time */
};
/**
* Scanner command set description.
*
@ -438,8 +460,8 @@ struct GT68xx_Model
SANE_Int ld_shift_double;
GT68xx_Color_Order line_mode_color_order;
GT68xx_AFE_Parameters *afe_params;
GT68xx_Exposure_Parameters *exposure;
GT68xx_AFE_Parameters afe_params;
GT68xx_Exposure_Parameters exposure;
SANE_Bool is_cis; /* Is this a CIS or CCD scanner? */
SANE_Word flags; /* Which hacks are needed for this scanner? */
@ -538,26 +560,6 @@ struct GT68xx_Scan_Parameters
SANE_Int double_column;
};
/** GT68xx analog front-end (AFE) parameters.
*/
struct GT68xx_AFE_Parameters
{
SANE_Byte r_offset; /**< Red channel offset */
SANE_Byte r_pga; /**< Red channel PGA gain */
SANE_Byte g_offset; /**< Green channel offset (also used for mono) */
SANE_Byte g_pga; /**< Green channel PGA gain (also used for mono) */
SANE_Byte b_offset; /**< Blue channel offset */
SANE_Byte b_pga; /**< Blue channel PGA gain */
};
/** GT68xx exposure time parameters.
*/
struct GT68xx_Exposure_Parameters
{
SANE_Int r_time; /**< Red exposure time */
SANE_Int g_time; /**< Red exposure time */
SANE_Int b_time; /**< Red exposure time */
};
#define GT68XX_PACKET_SIZE 64

Wyświetl plik

@ -1,4 +1,14 @@
V 1.0-27 (2002-10-??)
V 1.0-28 (2002-10-31)
- Reduce scan width of 2400 TA Plus: otherwise the black mark would create
light vertical stripes.
- Removed default parameters. Set AFE and exposure in every model struct.
- Faster automatic gain setting for the CIS scanners. The default values from
the model struct and the last values are used for calculation.
- Set default AFE values for ScanExpress 1200 UB Plus, BearPaw 1200 CU, BearPaw
2400 CU Plus.
V 1.0-27 (2002-10-25)
- Bugfix: override applies to all devices found by the last usb line.
- Individual resolutions + depth values for every scanner.