* genesys/gl646: HP2400 warmup fix by Luke <iceyfor@gmail.com>

merge-requests/1/head
Stéphane Voltz 2007-08-26 09:49:18 +00:00
rodzic a55ccf9ad0
commit 825ff7335e
4 zmienionych plików z 801 dodań i 719 usunięć

Wyświetl plik

@ -1,3 +1,8 @@
2007-08-26 Stephane Voltz <stef.dev@free.fr>
* backend/genesys.c backend/genesys_gl646.c backend/genesys_devices.c:
HP2400 warmup fix by Luke
2007-08-19 Henning Geinitz <sane@geinitz.org> 2007-08-19 Henning Geinitz <sane@geinitz.org>
* backend/gt68xx.c backend/gt68xx.conf.in backend/gt68xx_devices.c * backend/gt68xx.c backend/gt68xx.conf.in backend/gt68xx_devices.c

Wyświetl plik

@ -2,9 +2,10 @@
Copyright (C) 2003, 2004 Henning Meier-Geinitz <henning@meier-geinitz.de> Copyright (C) 2003, 2004 Henning Meier-Geinitz <henning@meier-geinitz.de>
Copyright (C) 2004, 2005 Gerhard Jaeger <gerhard@gjaeger.de> Copyright (C) 2004, 2005 Gerhard Jaeger <gerhard@gjaeger.de>
Copyright (C) 2004, 2005 Stephane Voltz <stefdev@modulonet.fr> Copyright (C) 2004, 2007 Stephane Voltz <stef.dev@free.fr>
Copyright (C) 2005, 2006 Pierre Willenbrock <pierre@pirsoft.dnsalias.org> Copyright (C) 2005, 2006 Pierre Willenbrock <pierre@pirsoft.dnsalias.org>
Copyright (C) 2006 Laurent Charpentier <laurent_pubs@yahoo.com> Copyright (C) 2006 Laurent Charpentier <laurent_pubs@yahoo.com>
Copyright (C) 2007 Luke <iceyfor@gmail.com>
This file is part of the SANE package. This file is part of the SANE package.
@ -51,7 +52,7 @@
#include "../include/sane/config.h" #include "../include/sane/config.h"
#define BUILD 8 #define BUILD 9
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
@ -245,7 +246,8 @@ sanei_genesys_set_reg_from_set (Genesys_Register_Set * reg, SANE_Byte address,
for (i = 0; i < GENESYS_MAX_REGS && reg[i].address; i++) for (i = 0; i < GENESYS_MAX_REGS && reg[i].address; i++)
{ {
if (reg[i].address == address) { if (reg[i].address == address)
{
reg[i].value = value; reg[i].value = value;
break; break;
} }
@ -408,8 +410,7 @@ sanei_genesys_fe_write_data (Genesys_Device * dev, u_int8_t addr,
reg[2].address = 0x3b; reg[2].address = 0x3b;
reg[2].value = data & 0xff; reg[2].value = data & 0xff;
status = status = dev->model->cmd_set->bulk_write_register (dev, reg, 6);
dev->model->cmd_set->bulk_write_register (dev, reg, 6);
if (status != SANE_STATUS_GOOD) if (status != SANE_STATUS_GOOD)
{ {
DBG (DBG_error, DBG (DBG_error,
@ -542,10 +543,10 @@ sanei_genesys_stop_motor (Genesys_Device * dev)
* done. * done.
*/ */
static SANE_Int static SANE_Int
genesys_generate_slope_table ( genesys_generate_slope_table (u_int16_t * slope_table, unsigned int max_steps,
u_int16_t * slope_table, unsigned int max_steps,
unsigned int use_steps, u_int16_t stop_at, unsigned int use_steps, u_int16_t stop_at,
u_int16_t vstart, u_int16_t vend, unsigned int steps, double g, u_int16_t vstart, u_int16_t vend,
unsigned int steps, double g,
unsigned int *used_steps, unsigned int *vfinal) unsigned int *used_steps, unsigned int *vfinal)
{ {
double t; double t;
@ -560,9 +561,7 @@ genesys_generate_slope_table (
if (!vfinal) if (!vfinal)
vfinal = &_vfinal; vfinal = &_vfinal;
DBG (DBG_proc, DBG (DBG_proc, "genesys_generate_slope_table: table size: %d\n", max_steps);
"genesys_generate_slope_table: table size: %d\n",
max_steps);
DBG (DBG_proc, DBG (DBG_proc,
"genesys_generate_slope_table: stop at time: %d, use %d steps max\n", "genesys_generate_slope_table: stop at time: %d, use %d steps max\n",
@ -570,8 +569,7 @@ genesys_generate_slope_table (
DBG (DBG_proc, DBG (DBG_proc,
"genesys_generate_slope_table: target slope: " "genesys_generate_slope_table: target slope: "
"vstart: %d, vend: %d, steps: %d, g: %g\n", "vstart: %d, vend: %d, steps: %d, g: %g\n", vstart, vend, steps, g);
vstart, vend, steps, g);
sum = 0; sum = 0;
c = 0; c = 0;
@ -593,7 +591,8 @@ genesys_generate_slope_table (
DBG (DBG_io, "slope_table[%3d] = %5d\n", c, t2); DBG (DBG_io, "slope_table[%3d] = %5d\n", c, t2);
sum += t2; sum += t2;
} }
if (t2 > stop_at) { if (t2 > stop_at)
{
DBG (DBG_warn, "Can not reach target speed(%d) in %d steps.\n", DBG (DBG_warn, "Can not reach target speed(%d) in %d steps.\n",
stop_at, use_steps); stop_at, use_steps);
DBG (DBG_warn, "Expect image to be distorted. " DBG (DBG_warn, "Expect image to be distorted. "
@ -616,7 +615,8 @@ genesys_generate_slope_table (
sum += *vfinal; sum += *vfinal;
DBG (DBG_proc, DBG (DBG_proc,
"sanei_genesys_generate_slope_table: returns sum=%d, used %d steps, completed\n", sum, *used_steps); "sanei_genesys_generate_slope_table: returns sum=%d, used %d steps, completed\n",
sum, *used_steps);
return sum; return sum;
} }
@ -649,8 +649,7 @@ sanei_genesys_create_slope_table3 (Genesys_Device * dev,
int step_type, int exposure_time, int step_type, int exposure_time,
double yres, double yres,
unsigned int *used_steps, unsigned int *used_steps,
unsigned int *final_exposure unsigned int *final_exposure)
)
{ {
unsigned int sum_time = 0; unsigned int sum_time = 0;
unsigned int vtarget; unsigned int vtarget;
@ -660,8 +659,7 @@ sanei_genesys_create_slope_table3 (Genesys_Device * dev,
DBG (DBG_proc, DBG (DBG_proc,
"sanei_genesys_create_slope_table: step_type = %d, " "sanei_genesys_create_slope_table: step_type = %d, "
"exposure_time = %d, yres = %g\n", step_type, "exposure_time = %d, yres = %g\n", step_type, exposure_time, yres);
exposure_time, yres);
DBG (DBG_proc, "sanei_genesys_create_slope_table: yres = %.2f\n", yres); DBG (DBG_proc, "sanei_genesys_create_slope_table: yres = %.2f\n", yres);
/* final speed */ /* final speed */
@ -682,18 +680,15 @@ sanei_genesys_create_slope_table3 (Genesys_Device * dev,
if (vend > 65535) if (vend > 65535)
vend = 65535; vend = 65535;
sum_time = genesys_generate_slope_table( sum_time = genesys_generate_slope_table (slope_table, max_step,
slope_table, max_step,
use_steps, use_steps,
vtarget, vtarget,
vstart, vstart,
vend, vend,
dev->motor.slopes[step_type].minimum_steps << step_type, dev->motor.slopes[step_type].
minimum_steps << step_type,
dev->motor.slopes[step_type].g, dev->motor.slopes[step_type].g,
used_steps, used_steps, &vfinal);
&vfinal);
if (final_exposure) if (final_exposure)
*final_exposure = (vfinal * dev->motor.base_ydpi) / yres; *final_exposure = (vfinal * dev->motor.base_ydpi) / yres;
@ -744,18 +739,15 @@ genesys_create_slope_table4 (Genesys_Device * dev,
if (vend > 65535) if (vend > 65535)
vend = 65535; vend = 65535;
sum_time = genesys_generate_slope_table( sum_time = genesys_generate_slope_table (slope_table, 128,
slope_table, 128,
steps, steps,
vtarget, vtarget,
vstart, vstart,
vend, vend,
dev->motor.slopes[step_type].minimum_steps << step_type, dev->motor.slopes[step_type].
minimum_steps << step_type,
dev->motor.slopes[step_type].g, dev->motor.slopes[step_type].g,
NULL, NULL, NULL);
NULL);
DBG (DBG_proc, DBG (DBG_proc,
"sanei_genesys_create_slope_table: returns sum_time=%d, completed\n", "sanei_genesys_create_slope_table: returns sum_time=%d, completed\n",
@ -1087,8 +1079,7 @@ sanei_genesys_create_gamma_table (u_int16_t * gamma_table, int size,
"sanei_genesys_create_gamma_table: gamma_table[%.3d] = %.5d\n", "sanei_genesys_create_gamma_table: gamma_table[%.3d] = %.5d\n",
i, (int) value); i, (int) value);
} }
DBG (DBG_proc, DBG (DBG_proc, "sanei_genesys_create_gamma_table: completed\n");
"sanei_genesys_create_gamma_table: completed\n");
} }
@ -1105,8 +1096,7 @@ sanei_genesys_create_gamma_table (u_int16_t * gamma_table, int size,
*/ */
SANE_Int SANE_Int
sanei_genesys_exposure_time2 (Genesys_Device * dev, float ydpi, sanei_genesys_exposure_time2 (Genesys_Device * dev, float ydpi,
int step_type, int endpixel, int step_type, int endpixel, int led_exposure)
int led_exposure)
{ {
int exposure_by_ccd = endpixel + 32; int exposure_by_ccd = endpixel + 32;
int exposure_by_motor = (dev->motor.slopes[step_type].maximum_speed int exposure_by_motor = (dev->motor.slopes[step_type].maximum_speed
@ -1177,6 +1167,8 @@ sanei_genesys_exposure_time (Genesys_Device * dev, Genesys_Register_Set * reg,
/* monochrome */ /* monochrome */
switch (xdpi) switch (xdpi)
{ {
case 200:
return 7210;
default: default:
return 11111; return 11111;
} }
@ -1187,7 +1179,7 @@ sanei_genesys_exposure_time (Genesys_Device * dev, Genesys_Register_Set * reg,
switch (xdpi) switch (xdpi)
{ {
case 600: case 600:
return 11902; return 19200; /*11902; */
default: default:
return 11111; return 11111;
} }
@ -1387,7 +1379,8 @@ sanei_genesys_read_data_from_scanner (Genesys_Device * dev, u_int8_t * data,
/* memset(data,0,size);*/ /* memset(data,0,size);*/
if (size & 1) if (size & 1)
DBG (DBG_info, "WARNING sanei_genesys_read_data_from_scanner: odd number of bytes\n"); DBG (DBG_info,
"WARNING sanei_genesys_read_data_from_scanner: odd number of bytes\n");
/* wait until buffer not empty for up to 5 seconds */ /* wait until buffer not empty for up to 5 seconds */
do do
@ -1517,7 +1510,8 @@ sanei_genesys_search_reference_point (Genesys_Device * dev, u_int8_t * data,
left += x; left += x;
} }
if (DBG_LEVEL >= DBG_data) if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file ("detected-xsobel.pnm", image, 8, 1, width, height); sanei_genesys_write_pnm_file ("detected-xsobel.pnm", image, 8, 1, width,
height);
left = left / count; left = left / count;
/* turn it in CCD pixel at full sensor optical resolution */ /* turn it in CCD pixel at full sensor optical resolution */
@ -1570,7 +1564,8 @@ sanei_genesys_search_reference_point (Genesys_Device * dev, u_int8_t * data,
top += y; top += y;
} }
if (DBG_LEVEL >= DBG_data) if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file ("detected-ysobel.pnm", image, 8, 1, width, height); sanei_genesys_write_pnm_file ("detected-ysobel.pnm", image, 8, 1,
width, height);
top = top / count; top = top / count;
/* find bottom of black stripe */ /* find bottom of black stripe */
@ -1592,8 +1587,10 @@ sanei_genesys_search_reference_point (Genesys_Device * dev, u_int8_t * data,
} }
/* find white corner in dark area */ /* find white corner in dark area */
if (dev->model->ccd_type == CCD_HP2300 if ((dev->model->ccd_type == CCD_HP2300
&& dev->model->motor_type == MOTOR_HP2300) && dev->model->motor_type == MOTOR_HP2300)
|| (dev->model->ccd_type == CCD_HP2400
&& dev->model->motor_type == MOTOR_HP2400))
{ {
top = 0; top = 0;
count = 0; count = 0;
@ -1873,14 +1870,17 @@ genesys_coarse_calibration (Genesys_Device * dev)
DBG (DBG_info, "channels %d y_size %d xres %d\n", DBG (DBG_info, "channels %d y_size %d xres %d\n",
channels, dev->model->y_size, dev->settings.xres); channels, dev->model->y_size, dev->settings.xres);
size = channels * 2 * SANE_UNFIX(dev->model->y_size) * dev->settings.xres / 25.4; size =
channels * 2 * SANE_UNFIX (dev->model->y_size) * dev->settings.xres /
25.4;
/* 1 1 mm 1/inch inch/mm */ /* 1 1 mm 1/inch inch/mm */
calibration_data = malloc (size); calibration_data = malloc (size);
if (!calibration_data) if (!calibration_data)
{ {
DBG (DBG_error, DBG (DBG_error,
"genesys_coarse_calibration: failed to allocate memory(%d bytes)\n", size); "genesys_coarse_calibration: failed to allocate memory(%d bytes)\n",
size);
return SANE_STATUS_NO_MEM; return SANE_STATUS_NO_MEM;
} }
@ -2188,8 +2188,7 @@ genesys_dark_shading_calibration (Genesys_Device * dev)
/* end pixel - start pixel */ /* end pixel - start pixel */
pixels_per_line = pixels_per_line =
(genesys_pixels_per_line (dev->calib_reg) (genesys_pixels_per_line (dev->calib_reg)
* genesys_dpiset(dev->calib_reg)) / * genesys_dpiset (dev->calib_reg)) / dev->sensor.optical_res;
dev->sensor.optical_res;
if (dev->settings.scan_mode == 4) /* single pass color */ if (dev->settings.scan_mode == 4) /* single pass color */
channels = 3; channels = 3;
@ -2321,8 +2320,7 @@ genesys_dummy_dark_shading (Genesys_Device * dev)
pixels_per_line = pixels_per_line =
(genesys_pixels_per_line (dev->calib_reg) (genesys_pixels_per_line (dev->calib_reg)
* genesys_dpiset(dev->calib_reg)) / * genesys_dpiset (dev->calib_reg)) / dev->sensor.optical_res;
dev->sensor.optical_res;
if (dev->settings.scan_mode == 4) /* single pass color */ if (dev->settings.scan_mode == 4) /* single pass color */
channels = 3; channels = 3;
@ -2418,8 +2416,7 @@ genesys_white_shading_calibration (Genesys_Device * dev)
pixels_per_line = pixels_per_line =
(genesys_pixels_per_line (dev->calib_reg) (genesys_pixels_per_line (dev->calib_reg)
* genesys_dpiset(dev->calib_reg)) / * genesys_dpiset (dev->calib_reg)) / dev->sensor.optical_res;
dev->sensor.optical_res;
if (dev->settings.scan_mode == 4) /* single pass color */ if (dev->settings.scan_mode == 4) /* single pass color */
channels = 3; channels = 3;
@ -2541,7 +2538,8 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev)
u_int8_t channels; u_int8_t channels;
unsigned int x; unsigned int x;
int y; int y;
u_int32_t dark, white, dark_sum, white_sum, dark_count, white_count, col, dif; u_int32_t dark, white, dark_sum, white_sum, dark_count, white_count, col,
dif;
DBG (DBG_proc, "genesys_black_white_shading_calibration (lines = %d)\n", DBG (DBG_proc, "genesys_black_white_shading_calibration (lines = %d)\n",
@ -2549,8 +2547,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev)
pixels_per_line = pixels_per_line =
(genesys_pixels_per_line (dev->calib_reg) (genesys_pixels_per_line (dev->calib_reg)
* genesys_dpiset(dev->calib_reg)) / * genesys_dpiset (dev->calib_reg)) / dev->sensor.optical_res;
dev->sensor.optical_res;
if (dev->settings.scan_mode == 4) /* single pass color */ if (dev->settings.scan_mode == 4) /* single pass color */
channels = 3; channels = 3;
@ -2638,8 +2635,8 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev)
} }
if (DBG_LEVEL >= DBG_data) if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file ("black_white_shading.pnm", calibration_data, 16, sanei_genesys_write_pnm_file ("black_white_shading.pnm", calibration_data,
channels, pixels_per_line, 16, channels, pixels_per_line,
dev->model->shading_lines); dev->model->shading_lines);
@ -2654,7 +2651,9 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev)
for (y = 0; y < dev->model->shading_lines; y++) for (y = 0; y < dev->model->shading_lines; y++)
{ {
col = calibration_data[(x + y * pixels_per_line * channels) * 2]; col = calibration_data[(x + y * pixels_per_line * channels) * 2];
col |= calibration_data[(x + y * pixels_per_line * channels) * 2 + 1] << 8; col |=
calibration_data[(x + y * pixels_per_line * channels) * 2 +
1] << 8;
if (col > white) if (col > white)
white = col; white = col;
@ -2676,13 +2675,17 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev)
for (y = 0; y < dev->model->shading_lines; y++) for (y = 0; y < dev->model->shading_lines; y++)
{ {
col = calibration_data[(x + y * pixels_per_line * channels) * 2]; col = calibration_data[(x + y * pixels_per_line * channels) * 2];
col |= calibration_data[(x + y * pixels_per_line * channels) * 2 + 1] << 8; col |=
calibration_data[(x + y * pixels_per_line * channels) * 2 +
1] << 8;
if (col >= white) { if (col >= white)
{
white_sum += col; white_sum += col;
white_count++; white_count++;
} }
if (col <= dark) { if (col <= dark)
{
dark_sum += col; dark_sum += col;
dark_count++; dark_count++;
} }
@ -2699,7 +2702,8 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev)
*average_white++ = white_sum >> 8; *average_white++ = white_sum >> 8;
} }
if (DBG_LEVEL >= DBG_data) { if (DBG_LEVEL >= DBG_data)
{
sanei_genesys_write_pnm_file ("white_average.pnm", sanei_genesys_write_pnm_file ("white_average.pnm",
dev->white_average_data, 16, channels, dev->white_average_data, 16, channels,
pixels_per_line, 1); pixels_per_line, 1);
@ -2733,8 +2737,7 @@ genesys_send_shading_coefficient (Genesys_Device * dev)
pixels_per_line = pixels_per_line =
(genesys_pixels_per_line (dev->calib_reg) (genesys_pixels_per_line (dev->calib_reg)
* genesys_dpiset(dev->calib_reg)) / * genesys_dpiset (dev->calib_reg)) / dev->sensor.optical_res;
dev->sensor.optical_res;
if (dev->settings.scan_mode == 4) /* single pass color */ if (dev->settings.scan_mode == 4) /* single pass color */
channels = 3; channels = 3;
@ -2742,8 +2745,10 @@ genesys_send_shading_coefficient (Genesys_Device * dev)
channels = 1; channels = 1;
/* we always build data for three channels, even for gray */ /* we always build data for three channels, even for gray */
if (dev->model->is_cis) { if (dev->model->is_cis)
switch ( sanei_genesys_read_reg_from_set(dev->reg, 0x05) >> 6) { {
switch (sanei_genesys_read_reg_from_set (dev->reg, 0x05) >> 6)
{
case 0: case 0:
words_per_color = 0x5500; words_per_color = 0x5500;
break; break;
@ -2953,7 +2958,9 @@ genesys_send_shading_coefficient (Genesys_Device * dev)
/*this should be evenly dividable */ /*this should be evenly dividable */
avgpixels = dev->sensor.optical_res / genesys_dpiset (dev->calib_reg); avgpixels = dev->sensor.optical_res / genesys_dpiset (dev->calib_reg);
DBG (DBG_info, "genesys_send_shading_coefficient: averaging over %d pixels\n", avgpixels); DBG (DBG_info,
"genesys_send_shading_coefficient: averaging over %d pixels\n",
avgpixels);
for (x = 0; x < pixels_per_line - o; x++) for (x = 0; x < pixels_per_line - o; x++)
{ {
@ -2961,32 +2968,38 @@ genesys_send_shading_coefficient (Genesys_Device * dev)
if ((x * avgpixels + o) * 2 * 2 + 3 > words_per_color) if ((x * avgpixels + o) * 2 * 2 + 3 > words_per_color)
break; break;
for ( j = 0; j < channels; j++) { for (j = 0; j < channels; j++)
{
/* dark data */ /* dark data */
dk = dev->dark_average_data[(x + pixels_per_line * j) * 2] | dk = dev->dark_average_data[(x + pixels_per_line * j) * 2] |
(dev->dark_average_data[(x + pixels_per_line * j) * 2 + 1] << 8); (dev->
dark_average_data[(x + pixels_per_line * j) * 2 + 1] << 8);
/* white data */ /* white data */
br = (dev->white_average_data[(x + pixels_per_line * j) * 2] br = (dev->white_average_data[(x + pixels_per_line * j) * 2]
| (dev->white_average_data[(x + pixels_per_line * j) * 2 + 1] << 8)); | (dev->
white_average_data[(x + pixels_per_line * j) * 2 +
1] << 8));
if (br * target_dark > dk * target_bright) if (br * target_dark > dk * target_bright)
val = 0; val = 0;
else if (dk*target_bright - br*target_dark > 65535 * (target_bright - target_dark)) else if (dk * target_bright - br * target_dark >
65535 * (target_bright - target_dark))
val = 65535; val = 65535;
else else
val = (dk*target_bright - br*target_dark)/(target_bright - target_dark); val =
(dk * target_bright - br * target_dark) / (target_bright -
target_dark);
/*fill all pixels, even if only the first one is relevant*/ /*fill all pixels, even if only the first one is relevant*/
for (i = 0; i < avgpixels; i++) { for (i = 0; i < avgpixels; i++)
shading_data[ {
(x*avgpixels+o+i) * 2 * 2 + words_per_color * j shading_data[(x * avgpixels + o + i) * 2 * 2 +
] = val & 0xff; words_per_color * j] = val & 0xff;
shading_data[ shading_data[(x * avgpixels + o + i) * 2 * 2 +
(x*avgpixels+o+i) * 2 * 2 + words_per_color * j + 1 words_per_color * j + 1] = val >> 8;
] = val >> 8;
} }
val = br - dk; val = br - dk;
@ -2997,39 +3010,36 @@ genesys_send_shading_coefficient (Genesys_Device * dev)
val = 65535; val = 65535;
/*fill all pixels, even if only the first one is relevant*/ /*fill all pixels, even if only the first one is relevant*/
for (i = 0; i < avgpixels; i++) { for (i = 0; i < avgpixels; i++)
shading_data[ {
(x*avgpixels+o+i) * 2 * 2 + words_per_color * j + 2 shading_data[(x * avgpixels + o + i) * 2 * 2 +
] = val & 0xff; words_per_color * j + 2] = val & 0xff;
shading_data[ shading_data[(x * avgpixels + o + i) * 2 * 2 +
(x*avgpixels+o+i) * 2 * 2 + words_per_color * j + 3 words_per_color * j + 3] = val >> 8;
] = val >> 8;
} }
} }
/*fill remaining channels*/ /*fill remaining channels*/
for ( j = channels; j < 3; j++) { for (j = channels; j < 3; j++)
for (i = 0; i < avgpixels; i++) { {
shading_data[ for (i = 0; i < avgpixels; i++)
(x*avgpixels+o+i) * 2 * 2 + words_per_color * j {
] = shading_data[ shading_data[(x * avgpixels + o + i) * 2 * 2 +
(x*avgpixels+o+i) * 2 * 2 + words_per_color * 0 words_per_color * j] =
]; shading_data[(x * avgpixels + o + i) * 2 * 2 +
shading_data[ words_per_color * 0];
(x*avgpixels+o+i) * 2 * 2 + words_per_color * j + 1 shading_data[(x * avgpixels + o + i) * 2 * 2 +
] = shading_data[ words_per_color * j + 1] =
(x*avgpixels+o+i) * 2 * 2 + words_per_color * 0 + 1 shading_data[(x * avgpixels + o + i) * 2 * 2 +
]; words_per_color * 0 + 1];
shading_data[ shading_data[(x * avgpixels + o + i) * 2 * 2 +
(x*avgpixels+o+i) * 2 * 2 + words_per_color * j + 2 words_per_color * j + 2] =
] = shading_data[ shading_data[(x * avgpixels + o + i) * 2 * 2 +
(x*avgpixels+o+i) * 2 * 2 + words_per_color * 0 + 2 words_per_color * 0 + 2];
]; shading_data[(x * avgpixels + o + i) * 2 * 2 +
shading_data[ words_per_color * j + 3] =
(x*avgpixels+o+i) * 2 * 2 + words_per_color * j + 3 shading_data[(x * avgpixels + o + i) * 2 * 2 +
] = shading_data[ words_per_color * 0 + 3];
(x*avgpixels+o+i) * 2 * 2 + words_per_color * 0 + 3
];
} }
} }
@ -3047,6 +3057,7 @@ genesys_send_shading_coefficient (Genesys_Device * dev)
*/ */
break; break;
case CCD_HP2300: case CCD_HP2300:
case CCD_HP2400:
default: default:
target_code = 0xFA00; target_code = 0xFA00;
for (x = 6; x < pixels_per_line; x++) for (x = 6; x < pixels_per_line; x++)
@ -3178,9 +3189,7 @@ genesys_send_shading_coefficient (Genesys_Device * dev)
if (dev->model->is_cis) if (dev->model->is_cis)
status = status = genesys_send_offset_and_shading (dev, shading_data, 0x1fe00);
genesys_send_offset_and_shading (dev, shading_data,
0x1fe00);
else else
status = status =
genesys_send_offset_and_shading (dev, shading_data, genesys_send_offset_and_shading (dev, shading_data,
@ -3308,7 +3317,8 @@ genesys_flatbed_calibration (Genesys_Device * dev)
/* since we have 2 gain calibration proc, skip second if first one was /* since we have 2 gain calibration proc, skip second if first one was
used. */ used. */
{ {
status = dev->model->cmd_set->init_regs_for_coarse_calibration (dev); status =
dev->model->cmd_set->init_regs_for_coarse_calibration (dev);
if (status != SANE_STATUS_GOOD) if (status != SANE_STATUS_GOOD)
{ {
DBG (DBG_error, DBG (DBG_error,
@ -3499,7 +3509,8 @@ genesys_warmup_lamp (Genesys_Device * dev)
fixes the communication with scanner . Put usb timeout to a friendly fixes the communication with scanner . Put usb timeout to a friendly
value first, so that 'recovery' doesn't take too long */ value first, so that 'recovery' doesn't take too long */
sanei_usb_set_timeout (2 * 1000); sanei_usb_set_timeout (2 * 1000);
status = sanei_genesys_read_data_from_scanner (dev, first_line, total_size); status =
sanei_genesys_read_data_from_scanner (dev, first_line, total_size);
if (status != SANE_STATUS_GOOD) if (status != SANE_STATUS_GOOD)
{ {
RIE (sanei_genesys_read_data_from_scanner RIE (sanei_genesys_read_data_from_scanner
@ -3796,8 +3807,7 @@ sanei_genesys_buffer_get_write_pos(Genesys_Buffer * buf, size_t size)
return NULL; return NULL;
if (buf->pos + buf->avail + size > buf->size) if (buf->pos + buf->avail + size > buf->size)
{ {
memmove (buf->buffer, buf->buffer + buf->pos, memmove (buf->buffer, buf->buffer + buf->pos, buf->avail);
buf->avail);
buf->pos = 0; buf->pos = 0;
} }
return buf->buffer + buf->pos + buf->avail; return buf->buffer + buf->pos + buf->avail;
@ -3838,7 +3848,8 @@ static FILE *rawfile = NULL;
#endif #endif
static SANE_Status static SANE_Status
genesys_fill_read_buffer(Genesys_Device * dev) { genesys_fill_read_buffer (Genesys_Device * dev)
{
size_t size; size_t size;
size_t space; size_t space;
SANE_Status status; SANE_Status status;
@ -3859,7 +3870,8 @@ genesys_fill_read_buffer(Genesys_Device * dev) {
/* Some setups need the reads to be multiples of 256 bytes */ /* Some setups need the reads to be multiples of 256 bytes */
size &= ~0xff; size &= ~0xff;
if (dev->read_bytes_left < size) { if (dev->read_bytes_left < size)
{
size = dev->read_bytes_left; size = dev->read_bytes_left;
/*round up to a multiple of 256 bytes*/ /*round up to a multiple of 256 bytes*/
size += (size & 0xff) ? 0x100 : 0x00; size += (size & 0xff) ? 0x100 : 0x00;
@ -3875,9 +3887,7 @@ genesys_fill_read_buffer(Genesys_Device * dev) {
/* size is already maxed to our needs. bulk_read_data /* size is already maxed to our needs. bulk_read_data
will read as much data as requested. */ will read as much data as requested. */
status = status =
dev->model->cmd_set->bulk_read_data ( dev->model->cmd_set->bulk_read_data (dev, 0x45, work_buffer_dst, size);
dev, 0x45,
work_buffer_dst, size);
if (status != SANE_STATUS_GOOD) if (status != SANE_STATUS_GOOD)
{ {
DBG (DBG_error, DBG (DBG_error,
@ -3887,7 +3897,8 @@ genesys_fill_read_buffer(Genesys_Device * dev) {
} }
#ifdef SANE_DEBUG_LOG_RAW_DATA #ifdef SANE_DEBUG_LOG_RAW_DATA
if (rawfile != NULL) { if (rawfile != NULL)
{
/*TODO: convert big/little endian if depth == 16. /*TODO: convert big/little endian if depth == 16.
note: xv got this wrong for P5/P6.*/ note: xv got this wrong for P5/P6.*/
fwrite (work_buffer_dst, size, 1, rawfile); fwrite (work_buffer_dst, size, 1, rawfile);
@ -3956,8 +3967,7 @@ genesys_read_ordered_data (Genesys_Device * dev, SANE_Byte * destination,
dev->current_setup.xres, dev->current_setup.xres,
dev->current_setup.yres, dev->current_setup.yres,
dev->current_setup.half_ccd ? "yes" : "no", dev->current_setup.half_ccd ? "yes" : "no",
dev->current_setup.stagger, dev->current_setup.stagger, dev->current_setup.max_shift);
dev->current_setup.max_shift);
/*prepare conversion*/ /*prepare conversion*/
/* current settings */ /* current settings */
@ -4036,24 +4046,27 @@ genesys_read_ordered_data (Genesys_Device * dev, SANE_Byte * destination,
((dev->read_bytes_left + dev->read_buffer.avail) * 8) / ((dev->read_bytes_left + dev->read_buffer.avail) * 8) /
(src_pixels * channels * depth)); (src_pixels * channels * depth));
if (channels == 1) { if (channels == 1)
{
ccd_shift[0] = 0; ccd_shift[0] = 0;
ccd_shift[1] = dev->current_setup.stagger; ccd_shift[1] = dev->current_setup.stagger;
shift_count = 2; shift_count = 2;
} else { }
else
{
ccd_shift[0] = ccd_shift[0] =
((dev->model->ld_shift_r * dev->settings.yres) / dev->motor.base_ydpi); ((dev->model->ld_shift_r * dev->settings.yres) /
dev->motor.base_ydpi);
ccd_shift[1] = ccd_shift[1] =
((dev->model->ld_shift_g * dev->settings.yres) / dev->motor.base_ydpi); ((dev->model->ld_shift_g * dev->settings.yres) /
dev->motor.base_ydpi);
ccd_shift[2] = ccd_shift[2] =
((dev->model->ld_shift_b * dev->settings.yres) / dev->motor.base_ydpi); ((dev->model->ld_shift_b * dev->settings.yres) /
dev->motor.base_ydpi);
ccd_shift[3] = ccd_shift[3] = ccd_shift[0] + dev->current_setup.stagger;
ccd_shift[0] + dev->current_setup.stagger; ccd_shift[4] = ccd_shift[1] + dev->current_setup.stagger;
ccd_shift[4] = ccd_shift[5] = ccd_shift[2] + dev->current_setup.stagger;
ccd_shift[1] + dev->current_setup.stagger;
ccd_shift[5] =
ccd_shift[2] + dev->current_setup.stagger;
shift_count = 6; shift_count = 6;
} }
@ -4088,7 +4101,8 @@ Problems with the first approach:
status = genesys_fill_read_buffer (dev); status = genesys_fill_read_buffer (dev);
if (status != SANE_STATUS_GOOD) { if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error, DBG (DBG_error,
"genesys_read_ordered_data: genesys_fill_read_buffer failed\n"); "genesys_read_ordered_data: genesys_fill_read_buffer failed\n");
return status; return status;
@ -4097,9 +4111,11 @@ Problems with the first approach:
src_buffer = &(dev->read_buffer); src_buffer = &(dev->read_buffer);
/* maybe reorder components/bytes */ /* maybe reorder components/bytes */
if (needs_reorder) { if (needs_reorder)
{
/*not implemented for depth == 1.*/ /*not implemented for depth == 1.*/
if (depth == 1) { if (depth == 1)
{
DBG (DBG_error, "Can't reorder single bit data\n"); DBG (DBG_error, "Can't reorder single bit data\n");
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
@ -4123,9 +4139,11 @@ Problems with the first approach:
DBG (DBG_info, "genesys_read_ordered_data: reordering %d lines\n", DBG (DBG_info, "genesys_read_ordered_data: reordering %d lines\n",
dst_lines); dst_lines);
if (dst_lines != 0) { if (dst_lines != 0)
{
if (channels == 3) { if (channels == 3)
{
step_1_mode = 0; step_1_mode = 0;
if (depth == 16) if (depth == 16)
@ -4137,55 +4155,73 @@ Problems with the first approach:
if (dev->model->line_mode_color_order == COLOR_ORDER_BGR) if (dev->model->line_mode_color_order == COLOR_ORDER_BGR)
step_1_mode |= 4; step_1_mode |= 4;
switch (step_1_mode) { switch (step_1_mode)
{
case 1: /* RGB, chunky, 16 bit */ case 1: /* RGB, chunky, 16 bit */
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
status = genesys_reorder_components_endian_16( status =
work_buffer_src, work_buffer_dst, genesys_reorder_components_endian_16 (work_buffer_src,
dst_lines, src_pixels, 3); work_buffer_dst,
dst_lines,
src_pixels, 3);
break; break;
#endif /*WORDS_BIGENDIAN */ #endif /*WORDS_BIGENDIAN */
case 0: /* RGB, chunky, 8 bit */ case 0: /* RGB, chunky, 8 bit */
status = SANE_STATUS_GOOD; status = SANE_STATUS_GOOD;
break; break;
case 2: /* RGB, cis, 8 bit */ case 2: /* RGB, cis, 8 bit */
status = genesys_reorder_components_cis_8( status =
work_buffer_src, work_buffer_dst, genesys_reorder_components_cis_8 (work_buffer_src,
work_buffer_dst,
dst_lines, src_pixels); dst_lines, src_pixels);
break; break;
case 3: /* RGB, cis, 16 bit */ case 3: /* RGB, cis, 16 bit */
status = genesys_reorder_components_cis_16( status =
work_buffer_src, work_buffer_dst, genesys_reorder_components_cis_16 (work_buffer_src,
work_buffer_dst,
dst_lines, src_pixels); dst_lines, src_pixels);
break; break;
case 4: /* BGR, chunky, 8 bit */ case 4: /* BGR, chunky, 8 bit */
status = genesys_reorder_components_bgr_8( status =
work_buffer_src, work_buffer_dst, genesys_reorder_components_bgr_8 (work_buffer_src,
work_buffer_dst,
dst_lines, src_pixels); dst_lines, src_pixels);
break; break;
case 5: /* BGR, chunky, 16 bit */ case 5: /* BGR, chunky, 16 bit */
status = genesys_reorder_components_bgr_16( status =
work_buffer_src, work_buffer_dst, genesys_reorder_components_bgr_16 (work_buffer_src,
work_buffer_dst,
dst_lines, src_pixels); dst_lines, src_pixels);
break; break;
case 6: /* BGR, cis, 8 bit */ case 6: /* BGR, cis, 8 bit */
status = genesys_reorder_components_cis_bgr_8( status =
work_buffer_src, work_buffer_dst, genesys_reorder_components_cis_bgr_8 (work_buffer_src,
dst_lines, src_pixels); work_buffer_dst,
dst_lines,
src_pixels);
break; break;
case 7: /* BGR, cis, 16 bit */ case 7: /* BGR, cis, 16 bit */
status = genesys_reorder_components_cis_bgr_16( status =
work_buffer_src, work_buffer_dst, genesys_reorder_components_cis_bgr_16 (work_buffer_src,
dst_lines, src_pixels); work_buffer_dst,
dst_lines,
src_pixels);
break; break;
} }
} else { }
else
{
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
if (depth == 16) { if (depth == 16)
status = genesys_reorder_components_endian_16( {
work_buffer_src, work_buffer_dst, status =
dst_lines, src_pixels, 1); genesys_reorder_components_endian_16 (work_buffer_src,
} else { work_buffer_dst,
dst_lines,
src_pixels, 1);
}
else
{
status = SANE_STATUS_GOOD; status = SANE_STATUS_GOOD;
} }
#else /*!WORDS_BIGENDIAN */ #else /*!WORDS_BIGENDIAN */
@ -4193,7 +4229,8 @@ Problems with the first approach:
#endif /*WORDS_BIGENDIAN */ #endif /*WORDS_BIGENDIAN */
} }
if (status != SANE_STATUS_GOOD) { if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error, DBG (DBG_error,
"genesys_read_ordered_data: failed to convert byte ordering(%s)\n", "genesys_read_ordered_data: failed to convert byte ordering(%s)\n",
sane_strstatus (status)); sane_strstatus (status));
@ -4208,9 +4245,11 @@ Problems with the first approach:
} }
/* maybe reverse effects of ccd layout */ /* maybe reverse effects of ccd layout */
if (needs_ccd) { if (needs_ccd)
{
/*should not happen with depth == 1.*/ /*should not happen with depth == 1.*/
if (depth == 1) { if (depth == 1)
{
DBG (DBG_error, "Can't reverse ccd for single bit data\n"); DBG (DBG_error, "Can't reverse ccd for single bit data\n");
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
@ -4237,29 +4276,28 @@ Problems with the first approach:
dst_lines = (bytes * 8) / (src_pixels * channels * depth); dst_lines = (bytes * 8) / (src_pixels * channels * depth);
bytes = (dst_lines * src_pixels * channels * depth) / 8; bytes = (dst_lines * src_pixels * channels * depth) / 8;
work_buffer_dst = sanei_genesys_buffer_get_write_pos(dst_buffer, bytes); work_buffer_dst =
sanei_genesys_buffer_get_write_pos (dst_buffer, bytes);
DBG (DBG_info, "genesys_read_ordered_data: un-ccd-ing %d lines\n", DBG (DBG_info, "genesys_read_ordered_data: un-ccd-ing %d lines\n",
dst_lines); dst_lines);
if (dst_lines != 0) { if (dst_lines != 0)
{
if (depth == 8) if (depth == 8)
status = genesys_reverse_ccd_8( status = genesys_reverse_ccd_8 (work_buffer_src, work_buffer_dst,
work_buffer_src, work_buffer_dst,
dst_lines, dst_lines,
src_pixels * channels, src_pixels * channels,
ccd_shift, ccd_shift, shift_count);
shift_count);
else else
status = genesys_reverse_ccd_16( status = genesys_reverse_ccd_16 (work_buffer_src, work_buffer_dst,
work_buffer_src, work_buffer_dst,
dst_lines, dst_lines,
src_pixels * channels, src_pixels * channels,
ccd_shift, ccd_shift, shift_count);
shift_count);
if (status != SANE_STATUS_GOOD) { if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error, DBG (DBG_error,
"genesys_read_ordered_data: failed to reverse ccd effects(%s)\n", "genesys_read_ordered_data: failed to reverse ccd effects(%s)\n",
sane_strstatus (status)); sane_strstatus (status));
@ -4274,7 +4312,8 @@ Problems with the first approach:
} }
/* maybe shrink(or enlarge) lines */ /* maybe shrink(or enlarge) lines */
if (needs_shrink) { if (needs_shrink)
{
dst_buffer = &(dev->out_buffer); dst_buffer = &(dev->out_buffer);
@ -4293,36 +4332,36 @@ Problems with the first approach:
bytes = (dst_lines * dev->settings.pixels * channels * depth) / 8; bytes = (dst_lines * dev->settings.pixels * channels * depth) / 8;
work_buffer_dst = sanei_genesys_buffer_get_write_pos(dst_buffer, bytes); work_buffer_dst =
sanei_genesys_buffer_get_write_pos (dst_buffer, bytes);
DBG (DBG_info, "genesys_read_ordered_data: shrinking %d lines\n", DBG (DBG_info, "genesys_read_ordered_data: shrinking %d lines\n",
dst_lines); dst_lines);
if (dst_lines != 0) { if (dst_lines != 0)
{
if (depth == 1) if (depth == 1)
status = genesys_shrink_lines_1 (work_buffer_src, status = genesys_shrink_lines_1 (work_buffer_src,
work_buffer_dst, work_buffer_dst,
dst_lines, dst_lines,
src_pixels, src_pixels,
dev->settings.pixels, dev->settings.pixels, channels);
channels);
else if (depth == 8) else if (depth == 8)
status = genesys_shrink_lines_8 (work_buffer_src, status = genesys_shrink_lines_8 (work_buffer_src,
work_buffer_dst, work_buffer_dst,
dst_lines, dst_lines,
src_pixels, src_pixels,
dev->settings.pixels, dev->settings.pixels, channels);
channels);
else else
status = genesys_shrink_lines_16 (work_buffer_src, status = genesys_shrink_lines_16 (work_buffer_src,
work_buffer_dst, work_buffer_dst,
dst_lines, dst_lines,
src_pixels, src_pixels,
dev->settings.pixels, dev->settings.pixels, channels);
channels);
if (status != SANE_STATUS_GOOD) { if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error, DBG (DBG_error,
"genesys_read_ordered_data: failed to shrink lines(%s)\n", "genesys_read_ordered_data: failed to shrink lines(%s)\n",
sane_strstatus (status)); sane_strstatus (status));
@ -4351,7 +4390,8 @@ Problems with the first approach:
if (needs_reverse) if (needs_reverse)
{ {
status = genesys_reverse_bits (work_buffer_src, destination, bytes); status = genesys_reverse_bits (work_buffer_src, destination, bytes);
if (status != SANE_STATUS_GOOD) { if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error, DBG (DBG_error,
"genesys_read_ordered_data: failed to reverse bits(%s)\n", "genesys_read_ordered_data: failed to reverse bits(%s)\n",
sane_strstatus (status)); sane_strstatus (status));
@ -4361,7 +4401,8 @@ Problems with the first approach:
} }
else if (needs_gray_lineart) else if (needs_gray_lineart)
{ {
if (depth != 8) { if (depth != 8)
{
DBG (DBG_error, "Cannot convert from 16bit to lineart\n"); DBG (DBG_error, "Cannot convert from 16bit to lineart\n");
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
@ -4373,9 +4414,9 @@ Problems with the first approach:
status = genesys_gray_lineart (work_buffer_src, destination, status = genesys_gray_lineart (work_buffer_src, destination,
dev->settings.pixels, dev->settings.pixels,
channels, channels,
dst_lines, dst_lines, dev->settings.threshold);
dev->settings.threshold); if (status != SANE_STATUS_GOOD)
if (status != SANE_STATUS_GOOD) { {
DBG (DBG_error, DBG (DBG_error,
"genesys_read_ordered_data: failed to reverse bits(%s)\n", "genesys_read_ordered_data: failed to reverse bits(%s)\n",
sane_strstatus (status)); sane_strstatus (status));
@ -4454,7 +4495,8 @@ calc_parameters (Genesys_Scanner * s)
/* interpolation */ /* interpolation */
s->dev->settings.disable_interpolation = s->val[OPT_DISABLE_INTERPOLATION].w == SANE_TRUE; s->dev->settings.disable_interpolation =
s->val[OPT_DISABLE_INTERPOLATION].w == SANE_TRUE;
/* Hardware settings */ /* Hardware settings */
if (resolution > s->dev->sensor.optical_res && if (resolution > s->dev->sensor.optical_res &&
@ -4708,7 +4750,8 @@ init_options (Genesys_Scanner * s)
/* disable_interpolation */ /* disable_interpolation */
s->opt[OPT_DISABLE_INTERPOLATION].name = "disable-interpolation"; s->opt[OPT_DISABLE_INTERPOLATION].name = "disable-interpolation";
s->opt[OPT_DISABLE_INTERPOLATION].title = SANE_I18N("Disable interpolation"); s->opt[OPT_DISABLE_INTERPOLATION].title =
SANE_I18N ("Disable interpolation");
s->opt[OPT_DISABLE_INTERPOLATION].desc = s->opt[OPT_DISABLE_INTERPOLATION].desc =
SANE_I18N SANE_I18N
("When using high resolutions where the horizontal resolution is smaller " ("When using high resolutions where the horizontal resolution is smaller "
@ -5351,10 +5394,13 @@ sane_control_option (SANE_Handle handle, SANE_Int option,
else else
{ {
DISABLE (OPT_THRESHOLD); DISABLE (OPT_THRESHOLD);
if (strcmp (s->val[option].s, "Gray") == 0) { if (strcmp (s->val[option].s, "Gray") == 0)
{
ENABLE (OPT_COLOR_FILTER); ENABLE (OPT_COLOR_FILTER);
create_bpp_list (s, s->dev->model->bpp_gray_values); create_bpp_list (s, s->dev->model->bpp_gray_values);
} else { }
else
{
DISABLE (OPT_COLOR_FILTER); DISABLE (OPT_COLOR_FILTER);
create_bpp_list (s, s->dev->model->bpp_color_values); create_bpp_list (s, s->dev->model->bpp_color_values);
} }

Wyświetl plik

@ -3,8 +3,9 @@
Copyright (C) 2003 Oliver Rauch Copyright (C) 2003 Oliver Rauch
Copyright (C) 2003-2005 Henning Meier-Geinitz <henning@meier-geinitz.de> Copyright (C) 2003-2005 Henning Meier-Geinitz <henning@meier-geinitz.de>
Copyright (C) 2004, 2005 Gerhard Jaeger <gerhard@gjaeger.de> Copyright (C) 2004, 2005 Gerhard Jaeger <gerhard@gjaeger.de>
Copyright (C) 2004, 2005 Stephane Voltz <svoltz@numericable.fr> Copyright (C) 2004-2007 Stephane Voltz <stef.dev@free.fr>
Copyright (C) 2005 Pierre Willenbrock <pierre@pirsoft.dnsalias.org> Copyright (C) 2005 Pierre Willenbrock <pierre@pirsoft.dnsalias.org>
Copyright (C) 2007 Luke <iceyfor@gmail.com>
This file is part of the SANE package. This file is part of the SANE package.
@ -474,10 +475,7 @@ static Genesys_Model canon_lide_50_model = {
DAC_CANONLIDE35, DAC_CANONLIDE35,
GPO_CANONLIDE35, GPO_CANONLIDE35,
MOTOR_CANONLIDE35, MOTOR_CANONLIDE35,
GENESYS_FLAG_LAZY_INIT GENESYS_FLAG_LAZY_INIT | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_DARK_WHITE_CALIBRATION, /* Which flags are needed for this scanner? */
| GENESYS_FLAG_SKIP_WARMUP
| GENESYS_FLAG_OFFSET_CALIBRATION
| GENESYS_FLAG_DARK_WHITE_CALIBRATION, /* Which flags are needed for this scanner? */
280, 280,
400 400
}; };
@ -518,10 +516,7 @@ static Genesys_Model canon_lide_60_model = {
DAC_CANONLIDE35, DAC_CANONLIDE35,
GPO_CANONLIDE35, GPO_CANONLIDE35,
MOTOR_CANONLIDE35, MOTOR_CANONLIDE35,
GENESYS_FLAG_LAZY_INIT GENESYS_FLAG_LAZY_INIT | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_DARK_WHITE_CALIBRATION, /* Which flags are needed for this scanner? */
| GENESYS_FLAG_SKIP_WARMUP
| GENESYS_FLAG_OFFSET_CALIBRATION
| GENESYS_FLAG_DARK_WHITE_CALIBRATION, /* Which flags are needed for this scanner? */
300, 300,
400 400
}; /* this is completely untested -- hmg */ }; /* this is completely untested -- hmg */
@ -607,8 +602,12 @@ static Genesys_Model hp2400c_model = {
DAC_WOLFSON_HP2400, DAC_WOLFSON_HP2400,
GPO_HP2400, GPO_HP2400,
MOTOR_HP2400, MOTOR_HP2400,
GENESYS_FLAG_UNTESTED GENESYS_FLAG_UNTESTED /* not fully working yet */
| GENESYS_FLAG_REPARK | GENESYS_FLAG_USE_PARK | GENESYS_FLAG_14BIT_GAMMA, | GENESYS_FLAG_REPARK
| GENESYS_FLAG_14BIT_GAMMA
| GENESYS_FLAG_SEARCH_START
| GENESYS_FLAG_MUST_WAIT
| GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_OFFSET_CALIBRATION,
20, 20,
132 132
}; };

Wyświetl plik

@ -3,8 +3,9 @@
Copyright (C) 2003 Oliver Rauch Copyright (C) 2003 Oliver Rauch
Copyright (C) 2003, 2004 Henning Meier-Geinitz <henning@meier-geinitz.de> Copyright (C) 2003, 2004 Henning Meier-Geinitz <henning@meier-geinitz.de>
Copyright (C) 2004 Gerhard Jaeger <gerhard@gjaeger.de> Copyright (C) 2004 Gerhard Jaeger <gerhard@gjaeger.de>
Copyright (C) 2004 - 2006 Stephane Voltz <stefdev@modulonet.fr> Copyright (C) 2004 - 2007 Stephane Voltz <stef.dev@free.fr>
Copyright (C) 2005, 2006 Pierre Willenbrock <pierre@pirsoft.dnsalias.org> Copyright (C) 2005, 2006 Pierre Willenbrock <pierre@pirsoft.dnsalias.org>
Copyright (C) 2007 Luke <iceyfor@gmail.com>
This file is part of the SANE package. This file is part of the SANE package.
@ -722,6 +723,17 @@ gl646_setup_sensor (Genesys_Device * dev,
{ {
/* settings for CCD used at half is max resolution */ /* settings for CCD used at half is max resolution */
if (half_ccd) if (half_ccd)
{
r = sanei_genesys_get_address (regs, 0x08);
r->value = 0x14;
r = sanei_genesys_get_address (regs, 0x09);
r->value = 0x15;
r = sanei_genesys_get_address (regs, 0x0a);
r->value = 0x00;
r = sanei_genesys_get_address (regs, 0x0b);
r->value = 0x00;
}
else
{ {
r = sanei_genesys_get_address (regs, 0x08); r = sanei_genesys_get_address (regs, 0x08);
r->value = 2; r->value = 2;
@ -732,6 +744,7 @@ gl646_setup_sensor (Genesys_Device * dev,
r = sanei_genesys_get_address (regs, 0x0b); r = sanei_genesys_get_address (regs, 0x0b);
r->value = 0; r->value = 0;
} }
} }
} }
@ -952,12 +965,21 @@ gl646_init_regs (Genesys_Device * dev)
/* ST12: 0x20 0x10 0x21 0x08 0x22 0x10 0x23 0x10 0x24 0x08 0x25 0x00 0x26 0x00 0x27 0xd4 0x28 0x01 0x29 0xff */ /* ST12: 0x20 0x10 0x21 0x08 0x22 0x10 0x23 0x10 0x24 0x08 0x25 0x00 0x26 0x00 0x27 0xd4 0x28 0x01 0x29 0xff */
/* ST24: 0x20 0x10 0x21 0x08 0x22 0x10 0x23 0x10 0x24 0x08 0x25 0x00 0x26 0x00 0x27 0xd4 0x28 0x01 0x29 0xff */ /* ST24: 0x20 0x10 0x21 0x08 0x22 0x10 0x23 0x10 0x24 0x08 0x25 0x00 0x26 0x00 0x27 0xd4 0x28 0x01 0x29 0xff */
/* TODO this construct deserve a switch */
if (dev->model->ccd_type != CCD_HP2300) if (dev->model->ccd_type != CCD_HP2300)
{
if (dev->model->ccd_type == CCD_HP2400)
{
dev->reg[reg_0x1e].value = 0x40;
dev->reg[reg_0x1f].value = 0x10;
dev->reg[reg_0x20].value = 0x20;
}
else
{ {
dev->reg[reg_0x1f].value = 0x01; /* scan feed step for table one in two table mode only */ dev->reg[reg_0x1f].value = 0x01; /* scan feed step for table one in two table mode only */
dev->reg[reg_0x20].value = 0x10 /*0x01 */ ; /* n * 2k, below this condition, motor move forward *//* todo: huh, 2k is pretty low? */ dev->reg[reg_0x20].value = 0x10 /*0x01 */ ; /* n * 2k, below this condition, motor move forward *//* todo: huh, 2k is pretty low? */
} }
}
else else
{ {
dev->reg[reg_0x1e].value = 0xf0; dev->reg[reg_0x1e].value = 0xf0;
@ -1050,7 +1072,8 @@ gl646_init_regs (Genesys_Device * dev)
/* ST12: 0x6a 0x7f 0x6b 0xff 0x6c 0x00 0x6d 0x01 */ /* ST12: 0x6a 0x7f 0x6b 0xff 0x6c 0x00 0x6d 0x01 */
/* ST24: 0x6a 0x40 0x6b 0xff 0x6c 0x00 0x6d 0x01 */ /* ST24: 0x6a 0x40 0x6b 0xff 0x6c 0x00 0x6d 0x01 */
if (dev->model->motor_type == MOTOR_HP2300) if (dev->model->motor_type == MOTOR_HP2300
|| dev->model->motor_type == MOTOR_HP2400)
{ {
dev->reg[reg_0x6a].value = 0x7f; /* table two steps number for acc/dec */ dev->reg[reg_0x6a].value = 0x7f; /* table two steps number for acc/dec */
dev->reg[reg_0x6b].value = 0x78; /* table two steps number for acc/dec */ dev->reg[reg_0x6b].value = 0x78; /* table two steps number for acc/dec */
@ -1550,7 +1573,8 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
prepare_steps = 4; prepare_steps = 4;
exposure_time = 6 * MOTOR_SPEED_MAX; exposure_time = 6 * MOTOR_SPEED_MAX;
steps = 14700 - 2 * prepare_steps; steps = 14700 - 2 * prepare_steps;
if (dev->model->motor_type == MOTOR_HP2300) if (dev->model->motor_type == MOTOR_HP2300
|| dev->model->motor_type == MOTOR_HP2400)
{ {
steps = 65535; /* enough to get back home ... */ steps = 65535; /* enough to get back home ... */
dpi = dev->motor.base_ydpi / 4; dpi = dev->motor.base_ydpi / 4;
@ -1563,7 +1587,8 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
local_reg[reg_0x01].value = local_reg[reg_0x01].value =
local_reg[reg_0x01].value & ~REG01_FASTMOD & ~REG01_SCAN; local_reg[reg_0x01].value & ~REG01_FASTMOD & ~REG01_SCAN;
local_reg[reg_0x02].value = (local_reg[reg_0x02].value & ~REG02_FASTFED & ~REG02_STEPSEL) | REG02_MTRPWR | REG02_MTRREV; /* Motor on, direction = reverse */ local_reg[reg_0x02].value = (local_reg[reg_0x02].value & ~REG02_FASTFED & ~REG02_STEPSEL) | REG02_MTRPWR | REG02_MTRREV; /* Motor on, direction = reverse */
if (dev->model->motor_type == MOTOR_HP2300) if (dev->model->motor_type == MOTOR_HP2300
|| dev->model->motor_type == MOTOR_HP2400)
local_reg[reg_0x02].value = local_reg[reg_0x02].value =
(local_reg[reg_0x02].value & ~REG02_STEPSEL) | REG02_HALFSTEP; (local_reg[reg_0x02].value & ~REG02_STEPSEL) | REG02_HALFSTEP;
@ -1578,7 +1603,8 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
local_reg[reg_0x3f].value = LOBYTE (LOWORD (steps)); local_reg[reg_0x3f].value = LOBYTE (LOWORD (steps));
local_reg[reg_0x6c].value = 0x00; /* one time period (only one speed) */ local_reg[reg_0x6c].value = 0x00; /* one time period (only one speed) */
if (dev->model->motor_type != MOTOR_HP2300) if (dev->model->motor_type != MOTOR_HP2300
&& dev->model->motor_type != MOTOR_HP2400)
{ {
local_reg[reg_0x66].value = local_reg[reg_0x66].value | REG66_LOW_CURRENT; /* gpio7-12: reset GPIO11 (low current) */ local_reg[reg_0x66].value = local_reg[reg_0x66].value | REG66_LOW_CURRENT; /* gpio7-12: reset GPIO11 (low current) */
local_reg[reg_0x6d].value = 0x54; local_reg[reg_0x6d].value = 0x54;
@ -2019,7 +2045,8 @@ gl646_search_start_position (Genesys_Device * dev)
local_reg[reg_0x62].value = LOBYTE (0); local_reg[reg_0x62].value = LOBYTE (0);
local_reg[reg_0x63].value = HIBYTE (0); local_reg[reg_0x63].value = HIBYTE (0);
if (dev->model->motor_type != MOTOR_HP2300) if (dev->model->motor_type != MOTOR_HP2300
&& dev->model->motor_type != MOTOR_HP2400)
local_reg[reg_0x65].value = 0x00; /* PWM duty cycle for table one motor phase (63 = max) */ local_reg[reg_0x65].value = 0x00; /* PWM duty cycle for table one motor phase (63 = max) */
else else
{ {
@ -2408,7 +2435,8 @@ gl646_init_regs_for_shading (Genesys_Device * dev)
if (dev->model->motor_type == MOTOR_5345) if (dev->model->motor_type == MOTOR_5345)
gl646_setup_steps (dev, dev->calib_reg, dpiset); gl646_setup_steps (dev, dev->calib_reg, dpiset);
else if (dev->model->motor_type == MOTOR_HP2300) else if (dev->model->motor_type == MOTOR_HP2300
|| dev->model->motor_type == MOTOR_HP2400)
{ {
dev->calib_reg[reg_0x21].value = 2; dev->calib_reg[reg_0x21].value = 2;
dev->calib_reg[reg_0x22].value = 16; dev->calib_reg[reg_0x22].value = 16;
@ -2429,7 +2457,8 @@ gl646_init_regs_for_shading (Genesys_Device * dev)
steps = dev->model->y_offset * step_parts; steps = dev->model->y_offset * step_parts;
if (dev->model->motor_type == MOTOR_5345) if (dev->model->motor_type == MOTOR_5345)
steps = 0; steps = 0;
else if (dev->model->motor_type == MOTOR_HP2300) else if (dev->model->motor_type == MOTOR_HP2300
|| dev->model->motor_type == MOTOR_HP2400)
steps = 1; steps = 1;
else else
dev->calib_reg[reg_0x6b].value = 0x20 * step_parts; dev->calib_reg[reg_0x6b].value = 0x20 * step_parts;
@ -2897,7 +2926,8 @@ gl646_init_regs_for_scan (Genesys_Device * dev)
dev->reg[reg_0x37].value = LOBYTE (LOWORD (words_per_line)); dev->reg[reg_0x37].value = LOBYTE (LOWORD (words_per_line));
if ((dev->model->ccd_type == CCD_5345) if ((dev->model->ccd_type == CCD_5345)
|| (dev->model->ccd_type == CCD_HP2300)) || (dev->model->ccd_type == CCD_HP2300)
|| (dev->model->ccd_type == CCD_HP2400))
exposure_time = exposure_time =
sanei_genesys_exposure_time (dev, dev->reg, dev->settings.xres); sanei_genesys_exposure_time (dev, dev->reg, dev->settings.xres);
else else
@ -3289,7 +3319,8 @@ gl646_offset_calibration (Genesys_Device * dev)
steps = 0; steps = 0;
lincnt = 1; lincnt = 1;
} }
else if (dev->model->ccd_type == CCD_HP2300) else if (dev->model->ccd_type == CCD_HP2300
|| dev->model->ccd_type == CCD_HP2400)
{ {
dpi = dev->settings.xres; dpi = dev->settings.xres;
steps = 1; steps = 1;
@ -3312,7 +3343,7 @@ gl646_offset_calibration (Genesys_Device * dev)
dev->calib_reg[reg_0x01].value &= ~REG01_DVDSET; dev->calib_reg[reg_0x01].value &= ~REG01_DVDSET;
dev->calib_reg[reg_0x02].value = REG02_ACDCDIS; dev->calib_reg[reg_0x02].value = REG02_ACDCDIS;
if (dev->model->motor_type == MOTOR_5345 || MOTOR_HP2300) if (dev->model->motor_type == MOTOR_5345 || MOTOR_HP2300 || MOTOR_HP2400)
{ {
if (half_ccd) if (half_ccd)
dev->calib_reg[reg_0x02].value = dev->calib_reg[reg_0x02].value =
@ -3447,7 +3478,8 @@ ST12: 0x60 0x00 0x61 0x00 0x62 0x00 0x63 0x00 0x64 0x00 0x65 0x3f 0x66 0x00 0x67
dev->calib_reg[reg_0x62].value = HIBYTE (0); dev->calib_reg[reg_0x62].value = HIBYTE (0);
dev->calib_reg[reg_0x63].value = LOBYTE (0); dev->calib_reg[reg_0x63].value = LOBYTE (0);
if (dev->model->motor_type == MOTOR_HP2300) if (dev->model->motor_type == MOTOR_HP2300
|| dev->model->motor_type == MOTOR_HP2400)
{ {
dev->calib_reg[reg_0x65].value = 0x3f; /* PWM duty cycle for table one motor phase (63 = max) */ dev->calib_reg[reg_0x65].value = 0x3f; /* PWM duty cycle for table one motor phase (63 = max) */
dev->calib_reg[reg_0x6b].value = 0x02; dev->calib_reg[reg_0x6b].value = 0x02;