Commit 4df63ef5 authored by Povilas Kanapickas's avatar Povilas Kanapickas

Merge branch 'genesys-debug-improvements' into 'master'

genesys: Miscellaneous debug improvements

See merge request !64
parents 3c8b9b91 988a91ae
Pipeline #60816226 passed with stages
in 12 minutes and 59 seconds
......@@ -1062,7 +1062,7 @@ sanei_genesys_search_reference_point (Genesys_Device * dev, uint8_t * data,
memcpy (data, image, size);
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file ("laplace.pnm", image, 8, 1, width, height);
sanei_genesys_write_pnm_file("gl_laplace.pnm", image, 8, 1, width, height);
/* apply X direction sobel filter
-1 0 1
......@@ -1087,7 +1087,7 @@ sanei_genesys_search_reference_point (Genesys_Device * dev, uint8_t * data,
level = current;
}
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file ("xsobel.pnm", image, 8, 1, width, height);
sanei_genesys_write_pnm_file("gl_xsobel.pnm", image, 8, 1, width, height);
/* set up detection level */
level = level / 3;
......@@ -1109,8 +1109,7 @@ sanei_genesys_search_reference_point (Genesys_Device * dev, uint8_t * data,
left += x;
}
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file ("detected-xsobel.pnm", image, 8, 1, width,
height);
sanei_genesys_write_pnm_file("gl_detected-xsobel.pnm", image, 8, 1, width, height);
left = left / count;
/* turn it in CCD pixel at full sensor optical resolution */
......@@ -1140,7 +1139,7 @@ sanei_genesys_search_reference_point (Genesys_Device * dev, uint8_t * data,
level = current;
}
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file ("ysobel.pnm", image, 8, 1, width, height);
sanei_genesys_write_pnm_file("gl_ysobel.pnm", image, 8, 1, width, height);
/* set up detection level */
level = level / 3;
......@@ -1163,8 +1162,7 @@ sanei_genesys_search_reference_point (Genesys_Device * dev, uint8_t * data,
top += y;
}
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file ("detected-ysobel.pnm", image, 8, 1,
width, height);
sanei_genesys_write_pnm_file("gl_detected-ysobel.pnm", image, 8, 1, width, height);
top = top / count;
/* bottom of black stripe is of fixed witdh, this hardcoded value
......@@ -1596,12 +1594,10 @@ genesys_coarse_calibration (Genesys_Device * dev)
for (count = 0; count < (unsigned int) (size * 4 / 2); count++)
all_data_8[count] = all_data[count * 2 + 1];
status =
sanei_genesys_write_pnm_file ("coarse.pnm", all_data_8, 8,
channels, size / 6, 4);
sanei_genesys_write_pnm_file("gl_coarse.pnm", all_data_8, 8, channels, size / 6, 4);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: sanei_genesys_write_pnm_file failed: %s\n", __func__,
sane_strstatus(status));
DBG(DBG_error, "%s: failed: %s\n", __func__, sane_strstatus(status));
return status;
}
}
......@@ -1822,12 +1818,10 @@ genesys_dark_shading_calibration (Genesys_Device * dev)
if (DBG_LEVEL >= DBG_data)
{
sanei_genesys_write_pnm_file ("black_shading.pnm", calibration_data, 16,
channels, pixels_per_line,
dev->calib_lines);
sanei_genesys_write_pnm_file ("black_average.pnm",
dev->dark_average_data, 16, channels,
pixels_per_line, 1);
sanei_genesys_write_pnm_file("gl_black_shading.pnm", calibration_data, 16,
channels, pixels_per_line, dev->calib_lines);
sanei_genesys_write_pnm_file("gl_black_average.pnm",
dev->dark_average_data, 16, channels, pixels_per_line, 1);
}
free (calibration_data);
......@@ -2031,18 +2025,16 @@ genesys_white_shading_calibration (Genesys_Device * dev)
}
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file ("white_shading.pnm", calibration_data, 16,
channels, pixels_per_line,
dev->calib_lines);
sanei_genesys_write_pnm_file("gl_white_shading.pnm", calibration_data, 16,
channels, pixels_per_line, dev->calib_lines);
genesys_average_data (dev->white_average_data, calibration_data,
dev->calib_lines,
pixels_per_line * channels);
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file ("white_average.pnm",
dev->white_average_data, 16, channels,
pixels_per_line, 1);
sanei_genesys_write_pnm_file("gl_white_average.pnm", dev->white_average_data, 16, channels,
pixels_per_line, 1);
free (calibration_data);
......@@ -2172,15 +2164,15 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev)
{
if (dev->model->is_cis)
{
sanei_genesys_write_pnm_file ("black_white_shading.pnm", calibration_data,
16, 1, pixels_per_line*channels,
dev->calib_lines);
sanei_genesys_write_pnm_file("gl_black_white_shading.pnm", calibration_data,
16, 1, pixels_per_line*channels,
dev->calib_lines);
}
else
{
sanei_genesys_write_pnm_file ("black_white_shading.pnm", calibration_data,
16, channels, pixels_per_line,
dev->calib_lines);
sanei_genesys_write_pnm_file("gl_black_white_shading.pnm", calibration_data,
16, channels, pixels_per_line,
dev->calib_lines);
}
}
......@@ -2249,12 +2241,12 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev)
if (DBG_LEVEL >= DBG_data)
{
sanei_genesys_write_pnm_file ("white_average.pnm",
dev->white_average_data, 16, channels,
pixels_per_line, 1);
sanei_genesys_write_pnm_file ("dark_average.pnm",
dev->dark_average_data, 16, channels,
pixels_per_line, 1);
sanei_genesys_write_pnm_file("gl_white_average.pnm",
dev->white_average_data, 16, channels,
pixels_per_line, 1);
sanei_genesys_write_pnm_file("gl_dark_average.pnm",
dev->dark_average_data, 16, channels,
pixels_per_line, 1);
}
free (calibration_data);
......@@ -3747,14 +3739,10 @@ genesys_warmup_lamp (Genesys_Device * dev)
second_average /= pixel;
if (DBG_LEVEL >= DBG_data)
{
sanei_genesys_write_pnm_file ("warmup1.pnm", first_line, 8,
channels,
total_size / (lines * channels),
lines);
sanei_genesys_write_pnm_file ("warmup2.pnm", second_line, 8,
channels,
total_size / (lines * channels),
lines);
sanei_genesys_write_pnm_file("gl_warmup1.pnm", first_line, 8, channels,
total_size / (lines * channels), lines);
sanei_genesys_write_pnm_file("gl_warmup2.pnm", second_line, 8, channels,
total_size / (lines * channels), lines);
}
DBG(DBG_info, "%s: average 1 = %.2f, average 2 = %.2f\n", __func__, first_average,
second_average);
......@@ -6446,12 +6434,9 @@ genesys_buffer_image(Genesys_Scanner *s)
s->params.lines = total / s->params.bytes_per_line;
if (DBG_LEVEL >= DBG_io2)
{
sanei_genesys_write_pnm_file ("unprocessed.pnm",
dev->img_buffer,
s->params.depth,
s->params.format==SANE_FRAME_RGB ? 3:1,
s->params.pixels_per_line,
s->params.lines);
sanei_genesys_write_pnm_file("gl_unprocessed.pnm", dev->img_buffer, s->params.depth,
s->params.format==SANE_FRAME_RGB ? 3 : 1,
s->params.pixels_per_line, s->params.lines);
}
return SANE_STATUS_GOOD;
......
......@@ -2388,8 +2388,8 @@ gl124_search_start_position (Genesys_Device * dev)
}
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file ("search_position.pnm", data, 8, 1, pixels,
dev->model->search_lines);
sanei_genesys_write_pnm_file("gl124_search_position.pnm", data, 8, 1, pixels,
dev->model->search_lines);
status = gl124_end_scan (dev, local_reg, SANE_TRUE);
if (status != SANE_STATUS_GOOD)
......@@ -2885,7 +2885,7 @@ move_to_calibration_area (Genesys_Device * dev)
if (DBG_LEVEL >= DBG_data)
{
sanei_genesys_write_pnm_file ("movetocalarea.pnm", line, 8, 3, pixels, 1);
sanei_genesys_write_pnm_file("gl124_movetocalarea.pnm", line, 8, 3, pixels, 1);
}
/* cleanup before return */
......@@ -2914,7 +2914,6 @@ gl124_led_calibration (Genesys_Device * dev)
int channels, depth;
int avg[3];
int turn;
char fn[20];
uint16_t exp[3],target;
Sensor_Profile *sensor;
SANE_Bool acceptable;
......@@ -3002,8 +3001,9 @@ gl124_led_calibration (Genesys_Device * dev)
if (DBG_LEVEL >= DBG_data)
{
snprintf (fn, 20, "led_%02d.pnm", turn);
sanei_genesys_write_pnm_file (fn, line, depth, channels, num_pixels, 1);
char fn[30];
snprintf(fn, 30, "gl124_led_%02d.pnm", turn);
sanei_genesys_write_pnm_file(fn, line, depth, channels, num_pixels, 1);
}
/* compute average */
......@@ -3110,7 +3110,6 @@ gl124_offset_calibration (Genesys_Device * dev)
SANE_Status status = SANE_STATUS_GOOD;
uint8_t *first_line, *second_line, reg0a;
unsigned int channels, bpp;
char title[32];
int pass = 0, avg, total_size;
int topavg, bottomavg, resolution, lines;
int top, bottom, black_pixels, pixels;
......@@ -3191,8 +3190,9 @@ gl124_offset_calibration (Genesys_Device * dev)
RIEF2 (sanei_genesys_read_data_from_scanner (dev, first_line, total_size), first_line, second_line);
if (DBG_LEVEL >= DBG_data)
{
snprintf(title,20,"offset%03d.pnm",bottom);
sanei_genesys_write_pnm_file (title, first_line, bpp, channels, pixels, lines);
char title[30];
snprintf(title, 30, "gl124_offset%03d.pnm", bottom);
sanei_genesys_write_pnm_file(title, first_line, bpp, channels, pixels, lines);
}
bottomavg = dark_average (first_line, pixels, lines, channels, black_pixels);
......@@ -3231,8 +3231,9 @@ gl124_offset_calibration (Genesys_Device * dev)
if (DBG_LEVEL >= DBG_data)
{
sprintf (title, "offset%03d.pnm", dev->frontend.offset[1]);
sanei_genesys_write_pnm_file (title, second_line, bpp, channels, pixels, lines);
char title[30];
snprintf(title, 30, "gl124_offset%03d.pnm", dev->frontend.offset[1]);
sanei_genesys_write_pnm_file(title, second_line, bpp, channels, pixels, lines);
}
avg = dark_average (second_line, pixels, lines, channels, black_pixels);
......@@ -3353,7 +3354,7 @@ gl124_coarse_gain_calibration (Genesys_Device * dev, int dpi)
RIEF (sanei_genesys_read_data_from_scanner (dev, line, total_size), line);
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file ("coarse.pnm", line, bpp, channels, pixels, lines);
sanei_genesys_write_pnm_file("gl124_coarse.pnm", line, bpp, channels, pixels, lines);
/* average value on each channel */
for (j = 0; j < channels; j++)
......
......@@ -2761,10 +2761,8 @@ gl646_search_start_position (Genesys_Device * dev)
}
if (DBG_LEVEL >= DBG_data)
{
sanei_genesys_write_pnm_file ("search_position.pnm",
data,
settings.depth,
1, settings.pixels, settings.lines);
sanei_genesys_write_pnm_file("gl646_search_position.pnm", data, settings.depth, 1,
settings.pixels, settings.lines);
}
}
else
......@@ -3238,7 +3236,6 @@ gl646_led_calibration (Genesys_Device * dev)
unsigned int channels;
int avg[3], avga, avge;
int turn;
char fn[20];
uint16_t expr, expg, expb;
Genesys_Settings settings;
SANE_Int resolution;
......@@ -3336,10 +3333,9 @@ gl646_led_calibration (Genesys_Device * dev)
if (DBG_LEVEL >= DBG_data)
{
snprintf (fn, 20, "led_%02d.pnm", turn);
sanei_genesys_write_pnm_file (fn,
line,
16, channels, settings.pixels, 1);
char fn[30];
snprintf(fn, 30, "gl646_led_%02d.pnm", turn);
sanei_genesys_write_pnm_file(fn, line, 16, channels, settings.pixels, 1);
}
acceptable = SANE_TRUE;
......@@ -3452,7 +3448,6 @@ ad_fe_offset_calibration (Genesys_Device * dev)
SANE_Status status = SANE_STATUS_GOOD;
uint8_t *line;
unsigned int channels;
char title[32];
int pass = 0;
SANE_Int resolution;
Genesys_Settings settings;
......@@ -3508,7 +3503,8 @@ ad_fe_offset_calibration (Genesys_Device * dev)
}
if (DBG_LEVEL >= DBG_data)
{
sprintf (title, "offset%03d.pnm", (int)bottom);
char title[30];
snprintf(title, 30, "gl646_offset%03d.pnm", (int)bottom);
sanei_genesys_write_pnm_file (title, line, 8, channels,
settings.pixels, settings.lines);
}
......@@ -3560,7 +3556,6 @@ gl646_offset_calibration (Genesys_Device * dev)
SANE_Status status = SANE_STATUS_GOOD;
uint8_t *first_line, *second_line;
unsigned int channels;
char title[32];
int pass = 0, avg;
SANE_Int resolution;
Genesys_Settings settings;
......@@ -3633,9 +3628,10 @@ gl646_offset_calibration (Genesys_Device * dev)
}
if (DBG_LEVEL >= DBG_data)
{
sprintf (title, "offset%03d.pnm", bottom);
sanei_genesys_write_pnm_file (title, first_line, 8, channels,
settings.pixels, settings.lines);
char title[30];
snprintf(title, 30, "gl646_offset%03d.pnm", bottom);
sanei_genesys_write_pnm_file(title, first_line, 8, channels,
settings.pixels, settings.lines);
}
bottomavg =
dark_average (first_line, settings.pixels, settings.lines, channels,
......@@ -3660,7 +3656,8 @@ gl646_offset_calibration (Genesys_Device * dev)
if (DBG_LEVEL >= DBG_data)
{
sprintf (title, "offset%03d.pnm", top);
char title[30];
snprintf(title, 30, "gl646_offset%03d.pnm", top);
sanei_genesys_write_pnm_file (title, second_line, 8, channels,
settings.pixels, settings.lines);
}
......@@ -3693,7 +3690,8 @@ gl646_offset_calibration (Genesys_Device * dev)
if (DBG_LEVEL >= DBG_data)
{
sprintf (title, "offset%03d.pnm", dev->frontend.offset[1]);
char title[30];
snprintf(title, 30, "gl646_offset%03d.pnm", dev->frontend.offset[1]);
sanei_genesys_write_pnm_file (title, second_line, 8, channels,
settings.pixels, settings.lines);
}
......@@ -3729,9 +3727,8 @@ gl646_offset_calibration (Genesys_Device * dev)
DBG(DBG_error, "%s: failed to scan final line\n", __func__);
return status;
}
sanei_genesys_write_pnm_file ("offset-final.pnm", second_line, 8,
channels, settings.pixels,
settings.lines);
sanei_genesys_write_pnm_file("gl646_offset-final.pnm", second_line, 8, channels,
settings.pixels, settings.lines);
free (second_line);
}
......@@ -3805,10 +3802,8 @@ ad_fe_coarse_gain_calibration (Genesys_Device * dev, int dpi)
/* log scanning data */
if (DBG_LEVEL >= DBG_data)
{
sprintf (title, "alternative_coarse%02d.pnm", (int)pass);
sanei_genesys_write_pnm_file (title, line, 8,
channels, settings.pixels,
settings.lines);
sprintf (title, "gl646_alternative_coarse%02d.pnm", (int)pass);
sanei_genesys_write_pnm_file(title, line, 8, channels, settings.pixels, settings.lines);
}
pass++;
......@@ -3943,10 +3938,8 @@ gl646_coarse_gain_calibration (Genesys_Device * dev, int dpi)
/* log scanning data */
if (DBG_LEVEL >= DBG_data)
{
sprintf (title, "coarse_gain%02d.pnm", (int)pass);
sanei_genesys_write_pnm_file (title, line, 8,
channels, settings.pixels,
settings.lines);
sprintf (title, "gl646_coarse_gain%02d.pnm", (int)pass);
sanei_genesys_write_pnm_file(title, line, 8, channels, settings.pixels, settings.lines);
}
pass++;
......@@ -5116,7 +5109,7 @@ gl646_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black)
}
if (DBG_LEVEL >= DBG_data)
{
sprintf (title, "search_strip_%s%02d.pnm", forward ? "fwd" : "bwd",
sprintf (title, "gl646_search_strip_%s%02d.pnm", forward ? "fwd" : "bwd",
(int)pass);
sanei_genesys_write_pnm_file (title, data, settings.depth, 1,
settings.pixels, settings.lines);
......
......@@ -3769,8 +3769,8 @@ gl841_search_start_position (Genesys_Device * dev)
}
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file ("search_position.pnm", data, 8, 1, pixels,
dev->model->search_lines);
sanei_genesys_write_pnm_file("gl841_search_position.pnm", data, 8, 1, pixels,
dev->model->search_lines);
status = gl841_end_scan (dev, local_reg, SANE_TRUE);
if (status != SANE_STATUS_GOOD)
......@@ -4121,7 +4121,6 @@ gl841_led_calibration (Genesys_Device * dev)
int channels;
int avg[3], avga, avge;
int turn;
char fn[20];
uint16_t exp[3], target;
Genesys_Register_Set *r;
int move;
......@@ -4225,12 +4224,9 @@ gl841_led_calibration (Genesys_Device * dev)
RIE (sanei_genesys_read_data_from_scanner (dev, line, total_size));
if (DBG_LEVEL >= DBG_data) {
snprintf(fn,20,"led_%d.pnm",turn);
sanei_genesys_write_pnm_file (fn,
line,
16,
channels,
num_pixels, 1);
char fn[30];
snprintf(fn, 30, "gl841_led_%d.pnm", turn);
sanei_genesys_write_pnm_file(fn, line, 16, channels, num_pixels, 1);
}
/* compute average */
......@@ -4352,7 +4348,6 @@ ad_fe_offset_calibration (Genesys_Device * dev)
int i;
int average;
int turn;
char fn[20];
int top;
int bottom;
int target;
......@@ -4422,8 +4417,9 @@ ad_fe_offset_calibration (Genesys_Device * dev)
sanei_genesys_read_data_from_scanner (dev, line, total_size);
gl841_stop_action (dev);
if (DBG_LEVEL >= DBG_data) {
snprintf(fn,20,"offset_%02d.pnm",turn);
sanei_genesys_write_pnm_file (fn, line, 8, 3, num_pixels, 1);
char fn[30];
snprintf(fn, 30, "gl841_offset_%02d.pnm", turn);
sanei_genesys_write_pnm_file(fn, line, 8, 3, num_pixels, 1);
}
/* search for minimal value */
......@@ -4479,7 +4475,6 @@ gl841_offset_calibration (Genesys_Device * dev)
int min1[3],min2[3];
int cmin[3],cmax[3];
int turn;
char fn[20];
SANE_Bool acceptable = SANE_FALSE;
int mintgt = 0x400;
......@@ -4588,12 +4583,9 @@ gl841_offset_calibration (Genesys_Device * dev)
RIEF2 (sanei_genesys_read_data_from_scanner (dev, first_line, total_size), first_line, second_line);
if (DBG_LEVEL >= DBG_data) {
snprintf(fn,20,"offset1_%02d.pnm",turn);
sanei_genesys_write_pnm_file (fn,
first_line,
16,
channels,
num_pixels, 1);
char fn[30];
snprintf(fn, 30, "gl841_offset1_%02d.pnm", turn);
sanei_genesys_write_pnm_file(fn, first_line, 16, channels, num_pixels, 1);
}
acceptable = SANE_TRUE;
......@@ -4707,12 +4699,9 @@ gl841_offset_calibration (Genesys_Device * dev)
RIEF2 (sanei_genesys_read_data_from_scanner (dev, second_line, total_size), first_line, second_line);
if (DBG_LEVEL >= DBG_data) {
snprintf(fn,20,"offset2_%02d.pnm",turn);
sanei_genesys_write_pnm_file (fn,
second_line,
16,
channels,
num_pixels, 1);
char fn[30];
snprintf(fn, 30, "gl841_offset2_%02d.pnm", turn);
sanei_genesys_write_pnm_file(fn, second_line, 16, channels, num_pixels, 1);
}
acceptable = SANE_TRUE;
......@@ -4940,7 +4929,7 @@ gl841_coarse_gain_calibration (Genesys_Device * dev, int dpi)
RIEF (sanei_genesys_read_data_from_scanner (dev, line, total_size), line);
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file ("coarse.pnm", line, 16, channels, num_pixels, lines);
sanei_genesys_write_pnm_file("gl841_coarse.pnm", line, 16, channels, num_pixels, lines);
/* average high level for each channel and compute gain
to reach the target code
......@@ -5509,10 +5498,9 @@ gl841_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black)
pass = 0;
if (DBG_LEVEL >= DBG_data)
{
sprintf (title, "search_strip_%s_%s%02u.pnm", black ? "black" : "white",
forward ? "fwd" : "bwd", pass);
sanei_genesys_write_pnm_file (title, data, depth, channels, pixels,
lines);
sprintf(title, "gl841_search_strip_%s_%s%02u.pnm", black ? "black" : "white",
forward ? "fwd" : "bwd", pass);
sanei_genesys_write_pnm_file(title, data, depth, channels, pixels, lines);
}
/* loop until strip is found or maximum pass number done */
......@@ -5560,10 +5548,9 @@ gl841_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black)
if (DBG_LEVEL >= DBG_data)
{
sprintf (title, "search_strip_%s_%s%02u.pnm",
black ? "black" : "white", forward ? "fwd" : "bwd", pass);
sanei_genesys_write_pnm_file (title, data, depth, channels, pixels,
lines);
sprintf(title, "gl841_search_strip_%s_%s%02u.pnm",
black ? "black" : "white", forward ? "fwd" : "bwd", pass);
sanei_genesys_write_pnm_file(title, data, depth, channels, pixels, lines);
}
/* search data to find black strip */
......
......@@ -2517,8 +2517,8 @@ gl843_search_start_position (Genesys_Device * dev)
}
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file ("search_position.pnm", data, 8, 1, pixels,
dev->model->search_lines);
sanei_genesys_write_pnm_file("gl843_search_position.pnm", data, 8, 1, pixels,
dev->model->search_lines);
status = gl843_end_scan (dev, local_reg, SANE_TRUE);
if (status != SANE_STATUS_GOOD)
......@@ -2896,7 +2896,6 @@ gl843_led_calibration (Genesys_Device * dev)
int channels, depth;
int avg[3], avga, avge;
int turn;
char fn[20];
uint16_t expr, expg, expb;
Genesys_Register_Set *r;
......@@ -2987,9 +2986,9 @@ gl843_led_calibration (Genesys_Device * dev)
if (DBG_LEVEL >= DBG_data)
{
snprintf (fn, 20, "led_%02d.pnm", turn);
sanei_genesys_write_pnm_file (fn,
line, depth, channels, num_pixels, 1);
char fn[30];
snprintf(fn, 30, "gl843_led_%02d.pnm", turn);
sanei_genesys_write_pnm_file(fn, line, depth, channels, num_pixels, 1);
}
acceptable = SANE_TRUE;
......@@ -3117,7 +3116,6 @@ gl843_offset_calibration (Genesys_Device * dev)
SANE_Status status = SANE_STATUS_GOOD;
uint8_t *first_line, *second_line;
unsigned int channels, bpp;
char title[32];
int pass, total_size, i, resolution, lines;
int topavg[3], bottomavg[3], avg[3];
int top[3], bottom[3], black_pixels, pixels, factor, dpihw;
......@@ -3194,11 +3192,10 @@ gl843_offset_calibration (Genesys_Device * dev)
RIEF2 (sanei_genesys_read_data_from_scanner (dev, first_line, total_size), first_line, second_line);
if (DBG_LEVEL >= DBG_data)
{
for (i = 0; i < 3; i++)
{
snprintf (title, 20, "offset_%d_%03d.pnm", i, bottom[i]);
sanei_genesys_write_pnm_file (title, first_line, bpp, channels, pixels, lines);
}
char fn[40];
snprintf(fn, 40, "gl843_bottom_offset_%03d_%03d_%03d.pnm",
bottom[0], bottom[1], bottom[2]);
sanei_genesys_write_pnm_file(fn, first_line, bpp, channels, pixels, lines);
}
for (i = 0; i < 3; i++)
......@@ -3229,6 +3226,11 @@ gl843_offset_calibration (Genesys_Device * dev)
pass = 0;
// FIXME: we'll leak debug image if we encounter errors below
Genesys_Vector debug_image = sanei_gl_vector_create(1);
size_t debug_image_lines = 0;
Genesys_Vector debug_image_info = sanei_gl_vector_create(1);
/* loop until acceptable level */
while ((pass < 32)
&& ((top[0] - bottom[0] > 1)
......@@ -3254,11 +3256,13 @@ gl843_offset_calibration (Genesys_Device * dev)
if (DBG_LEVEL >= DBG_data)
{
for (i = 0; i < 3; i++)
{
sprintf (title, "offset_%d_%03d.pnm", i, dev->frontend.offset[i]);
sanei_genesys_write_pnm_file (title, second_line, bpp, channels, pixels, lines);
}
char title[100];
snprintf(title, 100, "lines: %d pixels_per_line: %d offsets[0..2]: %d %d %d\n",
lines, pixels,
dev->frontend.offset[0], dev->frontend.offset[1], dev->frontend.offset[2]);
sanei_gl_vector_append(&debug_image_info, title, strlen(title));
sanei_gl_vector_append(&debug_image, second_line, total_size);
debug_image_lines += lines;
}
for (i = 0; i < 3; i++)
......@@ -3282,6 +3286,18 @@ gl843_offset_calibration (Genesys_Device * dev)
}
}
}
if (DBG_LEVEL >= DBG_data)
{
sanei_genesys_write_file("gl843_offset_all_desc.txt",
(uint8_t*)debug_image_info.data, debug_image_info.size);
sanei_genesys_write_pnm_file("gl843_offset_all.pnm",
(uint8_t*)debug_image.data, bpp, channels, pixels, debug_image_lines);
}
sanei_gl_vector_destroy(&debug_image);
sanei_gl_vector_destroy(&debug_image_info);
DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, dev->frontend.offset[0],
dev->frontend.offset[1], dev->frontend.offset[2]);
......@@ -3383,7 +3399,7 @@ gl843_coarse_gain_calibration (Genesys_Device * dev, int dpi)
RIEF (sanei_genesys_read_data_from_scanner (dev, line, total_size), line);
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file ("coarse.pnm", line, bpp, channels, pixels, lines);
sanei_genesys_write_pnm_file("gl843_coarse.pnm", line, bpp, channels, pixels, lines);
/* average value on each channel */
for (j = 0; j < channels; j++)
......@@ -3731,7 +3747,6 @@ gl843_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black)
uint8_t *data;
int steps, depth, dpi;
unsigned int pass, count, found, x, y;
char title[80];
Genesys_Register_Set *r;
DBG(DBG_proc, "%s %s %s\n", __func__, black ? "black" : "white", forward ? "forward" : "reverse");
......@@ -3836,10 +3851,10 @@ gl843_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black)
pass = 0;
if (DBG_LEVEL >= DBG_data)
{
sprintf (title, "search_strip_%s_%s%02d.pnm",
black ? "black" : "white", forward ? "fwd" : "bwd", (int)pass);
sanei_genesys_write_pnm_file (title, data, depth, channels, pixels,
lines);
char fn[40];
snprintf(fn, 40, "gl843_search_strip_%s_%s%02d.pnm",
black ? "black" : "white", forward ? "fwd" : "bwd", (int)pass);
sanei_genesys_write_pnm_file(fn, data, depth, channels, pixels, lines);
}
/* loop until strip is found or maximum pass number done */
......@@ -3888,10 +3903,10 @@ gl843_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black)
if (DBG_LEVEL >= DBG_data)
{
sprintf (title, "search_strip_%s_%s%02d.pnm",
black ? "black" : "white", forward ? "fwd" : "bwd", (int)pass);
sanei_genesys_write_pnm_file (title, data, depth, channels,
pixels, lines);
char fn[40];
snprintf(fn, 40, "gl843_search_strip_%s_%s%02d.pnm",
black ? "black" : "white", forward ? "fwd" : "bwd", (int)pass);
sanei_genesys_write_pnm_file(fn, data, depth, channels, pixels, lines);
}
/* search data to find black strip */
......
......@@ -1945,8 +1945,8 @@ gl846_search_start_position (Genesys_Device * dev)
}
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file ("search_position.pnm", data, 8, 1, pixels,
dev->model->search_lines);
sanei_genesys_write_pnm_file("gl846_search_position.pnm", data, 8, 1, pixels,
dev->model->search_lines);
status = gl846_end_scan (dev, local_reg, SANE_TRUE);
if (status != SANE_STATUS_GOOD)
......@@ -2422,7 +2422,6 @@ gl846_led_calibration (Genesys_Device * dev)
int channels, depth;
int avg[3], top[3], bottom[3];
int turn;
char fn[20];
uint16_t exp[3];
Sensor_Profile *sensor;
float move;
......@@ -2511,7 +2510,8 @@ gl846_led_calibration (Genesys_Device * dev)
if (DBG_LEVEL >= DBG_data)
{
snprintf (fn, 20, "led_%02d.pnm", turn);
char fn[30];
snprintf(fn, 30, "gl846_led_%02d.pnm", turn);
sanei_genesys_write_pnm_file (fn, line, depth, channels, num_pixels, 1);
}
......@@ -2920,10 +2920,9 @@ gl846_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black)
pass = 0;
if (DBG_LEVEL >= DBG_data)
{
sprintf (title, "search_strip_%s_%s%02d.pnm",
black ? "black" : "white", forward ? "fwd" : "bwd", (int)pass);
sanei_genesys_write_pnm_file (title, data, depth, channels, pixels,
lines);
sprintf(title, "gl846_search_strip_%s_%s%02d.pnm",
black ? "black" : "white", forward ? "fwd" : "bwd", (int)pass);
sanei_genesys_write_pnm_file(title, data, depth, channels, pixels, lines);
}
/* loop until strip is found or maximum pass number done */
......@@ -2971,10 +2970,9 @@ gl846_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black)
if (DBG_LEVEL >= DBG_data)
{
sprintf (title, "search_strip_%s_%s%02d.pnm",
black ? "black" : "white", forward ? "fwd" : "bwd", (int)pass);
sanei_genesys_write_pnm_file (title, data, depth, channels,
pixels, lines);
sprintf(title, "gl846_search_strip_%s_%s%02d.pnm",
black ? "black" : "white", forward ? "fwd" : "bwd", (int)pass);