* 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>
* 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) 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) 2006 Laurent Charpentier <laurent_pubs@yahoo.com>
Copyright (C) 2007 Luke <iceyfor@gmail.com>
This file is part of the SANE package.
@ -51,7 +52,7 @@
#include "../include/sane/config.h"
#define BUILD 8
#define BUILD 9
#include <errno.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++)
{
if (reg[i].address == address) {
if (reg[i].address == address)
{
reg[i].value = value;
break;
}
@ -408,8 +410,7 @@ sanei_genesys_fe_write_data (Genesys_Device * dev, u_int8_t addr,
reg[2].address = 0x3b;
reg[2].value = data & 0xff;
status =
dev->model->cmd_set->bulk_write_register (dev, reg, 6);
status = dev->model->cmd_set->bulk_write_register (dev, reg, 6);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error,
@ -542,10 +543,10 @@ sanei_genesys_stop_motor (Genesys_Device * dev)
* done.
*/
static SANE_Int
genesys_generate_slope_table (
u_int16_t * slope_table, unsigned int max_steps,
genesys_generate_slope_table (u_int16_t * slope_table, unsigned int max_steps,
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)
{
double t;
@ -560,9 +561,7 @@ genesys_generate_slope_table (
if (!vfinal)
vfinal = &_vfinal;
DBG (DBG_proc,
"genesys_generate_slope_table: table size: %d\n",
max_steps);
DBG (DBG_proc, "genesys_generate_slope_table: table size: %d\n", max_steps);
DBG (DBG_proc,
"genesys_generate_slope_table: stop at time: %d, use %d steps max\n",
@ -570,8 +569,7 @@ genesys_generate_slope_table (
DBG (DBG_proc,
"genesys_generate_slope_table: target slope: "
"vstart: %d, vend: %d, steps: %d, g: %g\n",
vstart, vend, steps, g);
"vstart: %d, vend: %d, steps: %d, g: %g\n", vstart, vend, steps, g);
sum = 0;
c = 0;
@ -593,7 +591,8 @@ genesys_generate_slope_table (
DBG (DBG_io, "slope_table[%3d] = %5d\n", c, t2);
sum += t2;
}
if (t2 > stop_at) {
if (t2 > stop_at)
{
DBG (DBG_warn, "Can not reach target speed(%d) in %d steps.\n",
stop_at, use_steps);
DBG (DBG_warn, "Expect image to be distorted. "
@ -616,7 +615,8 @@ genesys_generate_slope_table (
sum += *vfinal;
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;
}
@ -649,8 +649,7 @@ sanei_genesys_create_slope_table3 (Genesys_Device * dev,
int step_type, int exposure_time,
double yres,
unsigned int *used_steps,
unsigned int *final_exposure
)
unsigned int *final_exposure)
{
unsigned int sum_time = 0;
unsigned int vtarget;
@ -660,8 +659,7 @@ sanei_genesys_create_slope_table3 (Genesys_Device * dev,
DBG (DBG_proc,
"sanei_genesys_create_slope_table: step_type = %d, "
"exposure_time = %d, yres = %g\n", step_type,
exposure_time, yres);
"exposure_time = %d, yres = %g\n", step_type, exposure_time, yres);
DBG (DBG_proc, "sanei_genesys_create_slope_table: yres = %.2f\n", yres);
/* final speed */
@ -682,18 +680,15 @@ sanei_genesys_create_slope_table3 (Genesys_Device * dev,
if (vend > 65535)
vend = 65535;
sum_time = genesys_generate_slope_table(
slope_table, max_step,
sum_time = genesys_generate_slope_table (slope_table, max_step,
use_steps,
vtarget,
vstart,
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,
used_steps,
&vfinal);
used_steps, &vfinal);
if (final_exposure)
*final_exposure = (vfinal * dev->motor.base_ydpi) / yres;
@ -744,18 +739,15 @@ genesys_create_slope_table4 (Genesys_Device * dev,
if (vend > 65535)
vend = 65535;
sum_time = genesys_generate_slope_table(
slope_table, 128,
sum_time = genesys_generate_slope_table (slope_table, 128,
steps,
vtarget,
vstart,
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,
NULL,
NULL);
NULL, NULL);
DBG (DBG_proc,
"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",
i, (int) value);
}
DBG (DBG_proc,
"sanei_genesys_create_gamma_table: completed\n");
DBG (DBG_proc, "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
sanei_genesys_exposure_time2 (Genesys_Device * dev, float ydpi,
int step_type, int endpixel,
int led_exposure)
int step_type, int endpixel, int led_exposure)
{
int exposure_by_ccd = endpixel + 32;
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 */
switch (xdpi)
{
case 200:
return 7210;
default:
return 11111;
}
@ -1187,7 +1179,7 @@ sanei_genesys_exposure_time (Genesys_Device * dev, Genesys_Register_Set * reg,
switch (xdpi)
{
case 600:
return 11902;
return 19200; /*11902; */
default:
return 11111;
}
@ -1387,7 +1379,8 @@ sanei_genesys_read_data_from_scanner (Genesys_Device * dev, u_int8_t * data,
/* memset(data,0,size);*/
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 */
do
@ -1517,7 +1510,8 @@ sanei_genesys_search_reference_point (Genesys_Device * dev, u_int8_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 ("detected-xsobel.pnm", image, 8, 1, width,
height);
left = left / count;
/* 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;
}
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;
/* 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 */
if (dev->model->ccd_type == CCD_HP2300
if ((dev->model->ccd_type == CCD_HP2300
&& dev->model->motor_type == MOTOR_HP2300)
|| (dev->model->ccd_type == CCD_HP2400
&& dev->model->motor_type == MOTOR_HP2400))
{
top = 0;
count = 0;
@ -1873,14 +1870,17 @@ genesys_coarse_calibration (Genesys_Device * dev)
DBG (DBG_info, "channels %d y_size %d xres %d\n",
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 */
calibration_data = malloc (size);
if (!calibration_data)
{
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;
}
@ -2188,8 +2188,7 @@ genesys_dark_shading_calibration (Genesys_Device * dev)
/* end pixel - start pixel */
pixels_per_line =
(genesys_pixels_per_line (dev->calib_reg)
* genesys_dpiset(dev->calib_reg)) /
dev->sensor.optical_res;
* genesys_dpiset (dev->calib_reg)) / dev->sensor.optical_res;
if (dev->settings.scan_mode == 4) /* single pass color */
channels = 3;
@ -2321,8 +2320,7 @@ genesys_dummy_dark_shading (Genesys_Device * dev)
pixels_per_line =
(genesys_pixels_per_line (dev->calib_reg)
* genesys_dpiset(dev->calib_reg)) /
dev->sensor.optical_res;
* genesys_dpiset (dev->calib_reg)) / dev->sensor.optical_res;
if (dev->settings.scan_mode == 4) /* single pass color */
channels = 3;
@ -2418,8 +2416,7 @@ genesys_white_shading_calibration (Genesys_Device * dev)
pixels_per_line =
(genesys_pixels_per_line (dev->calib_reg)
* genesys_dpiset(dev->calib_reg)) /
dev->sensor.optical_res;
* genesys_dpiset (dev->calib_reg)) / dev->sensor.optical_res;
if (dev->settings.scan_mode == 4) /* single pass color */
channels = 3;
@ -2541,7 +2538,8 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev)
u_int8_t channels;
unsigned int x;
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",
@ -2549,8 +2547,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev)
pixels_per_line =
(genesys_pixels_per_line (dev->calib_reg)
* genesys_dpiset(dev->calib_reg)) /
dev->sensor.optical_res;
* genesys_dpiset (dev->calib_reg)) / dev->sensor.optical_res;
if (dev->settings.scan_mode == 4) /* single pass color */
channels = 3;
@ -2638,8 +2635,8 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev)
}
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file ("black_white_shading.pnm", calibration_data, 16,
channels, pixels_per_line,
sanei_genesys_write_pnm_file ("black_white_shading.pnm", calibration_data,
16, channels, pixels_per_line,
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++)
{
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)
white = col;
@ -2676,13 +2675,17 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev)
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 + 1] << 8;
col |=
calibration_data[(x + y * pixels_per_line * channels) * 2 +
1] << 8;
if (col >= white) {
if (col >= white)
{
white_sum += col;
white_count++;
}
if (col <= dark) {
if (col <= dark)
{
dark_sum += col;
dark_count++;
}
@ -2699,7 +2702,8 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev)
*average_white++ = white_sum >> 8;
}
if (DBG_LEVEL >= DBG_data) {
if (DBG_LEVEL >= DBG_data)
{
sanei_genesys_write_pnm_file ("white_average.pnm",
dev->white_average_data, 16, channels,
pixels_per_line, 1);
@ -2733,8 +2737,7 @@ genesys_send_shading_coefficient (Genesys_Device * dev)
pixels_per_line =
(genesys_pixels_per_line (dev->calib_reg)
* genesys_dpiset(dev->calib_reg)) /
dev->sensor.optical_res;
* genesys_dpiset (dev->calib_reg)) / dev->sensor.optical_res;
if (dev->settings.scan_mode == 4) /* single pass color */
channels = 3;
@ -2742,8 +2745,10 @@ genesys_send_shading_coefficient (Genesys_Device * dev)
channels = 1;
/* we always build data for three channels, even for gray */
if (dev->model->is_cis) {
switch ( sanei_genesys_read_reg_from_set(dev->reg, 0x05) >> 6) {
if (dev->model->is_cis)
{
switch (sanei_genesys_read_reg_from_set (dev->reg, 0x05) >> 6)
{
case 0:
words_per_color = 0x5500;
break;
@ -2953,7 +2958,9 @@ genesys_send_shading_coefficient (Genesys_Device * dev)
/*this should be evenly dividable */
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++)
{
@ -2961,32 +2968,38 @@ genesys_send_shading_coefficient (Genesys_Device * dev)
if ((x * avgpixels + o) * 2 * 2 + 3 > words_per_color)
break;
for ( j = 0; j < channels; j++) {
for (j = 0; j < channels; j++)
{
/* dark data */
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 */
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)
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;
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*/
for (i = 0; i < avgpixels; i++) {
shading_data[
(x*avgpixels+o+i) * 2 * 2 + words_per_color * j
] = val & 0xff;
shading_data[
(x*avgpixels+o+i) * 2 * 2 + words_per_color * j + 1
] = val >> 8;
for (i = 0; i < avgpixels; i++)
{
shading_data[(x * avgpixels + o + i) * 2 * 2 +
words_per_color * j] = val & 0xff;
shading_data[(x * avgpixels + o + i) * 2 * 2 +
words_per_color * j + 1] = val >> 8;
}
val = br - dk;
@ -2997,39 +3010,36 @@ genesys_send_shading_coefficient (Genesys_Device * dev)
val = 65535;
/*fill all pixels, even if only the first one is relevant*/
for (i = 0; i < avgpixels; i++) {
shading_data[
(x*avgpixels+o+i) * 2 * 2 + words_per_color * j + 2
] = val & 0xff;
shading_data[
(x*avgpixels+o+i) * 2 * 2 + words_per_color * j + 3
] = val >> 8;
for (i = 0; i < avgpixels; i++)
{
shading_data[(x * avgpixels + o + i) * 2 * 2 +
words_per_color * j + 2] = val & 0xff;
shading_data[(x * avgpixels + o + i) * 2 * 2 +
words_per_color * j + 3] = val >> 8;
}
}
/*fill remaining channels*/
for ( j = channels; j < 3; j++) {
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 + words_per_color * 0
];
shading_data[
(x*avgpixels+o+i) * 2 * 2 + words_per_color * j + 1
] = shading_data[
(x*avgpixels+o+i) * 2 * 2 + words_per_color * 0 + 1
];
shading_data[
(x*avgpixels+o+i) * 2 * 2 + words_per_color * j + 2
] = shading_data[
(x*avgpixels+o+i) * 2 * 2 + words_per_color * 0 + 2
];
shading_data[
(x*avgpixels+o+i) * 2 * 2 + words_per_color * j + 3
] = shading_data[
(x*avgpixels+o+i) * 2 * 2 + words_per_color * 0 + 3
];
for (j = channels; j < 3; j++)
{
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 +
words_per_color * 0];
shading_data[(x * avgpixels + o + i) * 2 * 2 +
words_per_color * j + 1] =
shading_data[(x * avgpixels + o + i) * 2 * 2 +
words_per_color * 0 + 1];
shading_data[(x * avgpixels + o + i) * 2 * 2 +
words_per_color * j + 2] =
shading_data[(x * avgpixels + o + i) * 2 * 2 +
words_per_color * 0 + 2];
shading_data[(x * avgpixels + o + i) * 2 * 2 +
words_per_color * j + 3] =
shading_data[(x * avgpixels + o + i) * 2 * 2 +
words_per_color * 0 + 3];
}
}
@ -3047,6 +3057,7 @@ genesys_send_shading_coefficient (Genesys_Device * dev)
*/
break;
case CCD_HP2300:
case CCD_HP2400:
default:
target_code = 0xFA00;
for (x = 6; x < pixels_per_line; x++)
@ -3178,9 +3189,7 @@ genesys_send_shading_coefficient (Genesys_Device * dev)
if (dev->model->is_cis)
status =
genesys_send_offset_and_shading (dev, shading_data,
0x1fe00);
status = genesys_send_offset_and_shading (dev, shading_data, 0x1fe00);
else
status =
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
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)
{
DBG (DBG_error,
@ -3499,7 +3509,8 @@ genesys_warmup_lamp (Genesys_Device * dev)
fixes the communication with scanner . Put usb timeout to a friendly
value first, so that 'recovery' doesn't take too long */
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)
{
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;
if (buf->pos + buf->avail + size > buf->size)
{
memmove (buf->buffer, buf->buffer + buf->pos,
buf->avail);
memmove (buf->buffer, buf->buffer + buf->pos, buf->avail);
buf->pos = 0;
}
return buf->buffer + buf->pos + buf->avail;
@ -3838,7 +3848,8 @@ static FILE *rawfile = NULL;
#endif
static SANE_Status
genesys_fill_read_buffer(Genesys_Device * dev) {
genesys_fill_read_buffer (Genesys_Device * dev)
{
size_t size;
size_t space;
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 */
size &= ~0xff;
if (dev->read_bytes_left < size) {
if (dev->read_bytes_left < size)
{
size = dev->read_bytes_left;
/*round up to a multiple of 256 bytes*/
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
will read as much data as requested. */
status =
dev->model->cmd_set->bulk_read_data (
dev, 0x45,
work_buffer_dst, size);
dev->model->cmd_set->bulk_read_data (dev, 0x45, work_buffer_dst, size);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error,
@ -3887,7 +3897,8 @@ genesys_fill_read_buffer(Genesys_Device * dev) {
}
#ifdef SANE_DEBUG_LOG_RAW_DATA
if (rawfile != NULL) {
if (rawfile != NULL)
{
/*TODO: convert big/little endian if depth == 16.
note: xv got this wrong for P5/P6.*/
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.yres,
dev->current_setup.half_ccd ? "yes" : "no",
dev->current_setup.stagger,
dev->current_setup.max_shift);
dev->current_setup.stagger, dev->current_setup.max_shift);
/*prepare conversion*/
/* 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) /
(src_pixels * channels * depth));
if (channels == 1) {
if (channels == 1)
{
ccd_shift[0] = 0;
ccd_shift[1] = dev->current_setup.stagger;
shift_count = 2;
} else {
}
else
{
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] =
((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] =
((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[0] + dev->current_setup.stagger;
ccd_shift[4] =
ccd_shift[1] + dev->current_setup.stagger;
ccd_shift[5] =
ccd_shift[2] + dev->current_setup.stagger;
ccd_shift[3] = ccd_shift[0] + dev->current_setup.stagger;
ccd_shift[4] = ccd_shift[1] + dev->current_setup.stagger;
ccd_shift[5] = ccd_shift[2] + dev->current_setup.stagger;
shift_count = 6;
}
@ -4088,7 +4101,8 @@ Problems with the first approach:
status = genesys_fill_read_buffer (dev);
if (status != SANE_STATUS_GOOD) {
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error,
"genesys_read_ordered_data: genesys_fill_read_buffer failed\n");
return status;
@ -4097,9 +4111,11 @@ Problems with the first approach:
src_buffer = &(dev->read_buffer);
/* maybe reorder components/bytes */
if (needs_reorder) {
if (needs_reorder)
{
/*not implemented for depth == 1.*/
if (depth == 1) {
if (depth == 1)
{
DBG (DBG_error, "Can't reorder single bit data\n");
return SANE_STATUS_INVAL;
}
@ -4123,9 +4139,11 @@ Problems with the first approach:
DBG (DBG_info, "genesys_read_ordered_data: reordering %d lines\n",
dst_lines);
if (dst_lines != 0) {
if (dst_lines != 0)
{
if (channels == 3) {
if (channels == 3)
{
step_1_mode = 0;
if (depth == 16)
@ -4137,55 +4155,73 @@ Problems with the first approach:
if (dev->model->line_mode_color_order == COLOR_ORDER_BGR)
step_1_mode |= 4;
switch (step_1_mode) {
switch (step_1_mode)
{
case 1: /* RGB, chunky, 16 bit */
#ifdef WORDS_BIGENDIAN
status = genesys_reorder_components_endian_16(
work_buffer_src, work_buffer_dst,
dst_lines, src_pixels, 3);
status =
genesys_reorder_components_endian_16 (work_buffer_src,
work_buffer_dst,
dst_lines,
src_pixels, 3);
break;
#endif /*WORDS_BIGENDIAN */
case 0: /* RGB, chunky, 8 bit */
status = SANE_STATUS_GOOD;
break;
case 2: /* RGB, cis, 8 bit */
status = genesys_reorder_components_cis_8(
work_buffer_src, work_buffer_dst,
status =
genesys_reorder_components_cis_8 (work_buffer_src,
work_buffer_dst,
dst_lines, src_pixels);
break;
case 3: /* RGB, cis, 16 bit */
status = genesys_reorder_components_cis_16(
work_buffer_src, work_buffer_dst,
status =
genesys_reorder_components_cis_16 (work_buffer_src,
work_buffer_dst,
dst_lines, src_pixels);
break;
case 4: /* BGR, chunky, 8 bit */
status = genesys_reorder_components_bgr_8(
work_buffer_src, work_buffer_dst,
status =
genesys_reorder_components_bgr_8 (work_buffer_src,
work_buffer_dst,
dst_lines, src_pixels);
break;
case 5: /* BGR, chunky, 16 bit */
status = genesys_reorder_components_bgr_16(
work_buffer_src, work_buffer_dst,
status =
genesys_reorder_components_bgr_16 (work_buffer_src,
work_buffer_dst,
dst_lines, src_pixels);
break;
case 6: /* BGR, cis, 8 bit */
status = genesys_reorder_components_cis_bgr_8(
work_buffer_src, work_buffer_dst,
dst_lines, src_pixels);
status =
genesys_reorder_components_cis_bgr_8 (work_buffer_src,
work_buffer_dst,
dst_lines,
src_pixels);
break;
case 7: /* BGR, cis, 16 bit */
status = genesys_reorder_components_cis_bgr_16(
work_buffer_src, work_buffer_dst,
dst_lines, src_pixels);
status =
genesys_reorder_components_cis_bgr_16 (work_buffer_src,
work_buffer_dst,
dst_lines,
src_pixels);
break;
}
} else {
}
else
{
#ifdef WORDS_BIGENDIAN
if (depth == 16) {
status = genesys_reorder_components_endian_16(
work_buffer_src, work_buffer_dst,
dst_lines, src_pixels, 1);
} else {
if (depth == 16)
{
status =
genesys_reorder_components_endian_16 (work_buffer_src,
work_buffer_dst,
dst_lines,
src_pixels, 1);
}
else
{
status = SANE_STATUS_GOOD;
}
#else /*!WORDS_BIGENDIAN */
@ -4193,7 +4229,8 @@ Problems with the first approach:
#endif /*WORDS_BIGENDIAN */
}
if (status != SANE_STATUS_GOOD) {
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error,
"genesys_read_ordered_data: failed to convert byte ordering(%s)\n",
sane_strstatus (status));
@ -4208,9 +4245,11 @@ Problems with the first approach:
}
/* maybe reverse effects of ccd layout */
if (needs_ccd) {
if (needs_ccd)
{
/*should not happen with depth == 1.*/
if (depth == 1) {
if (depth == 1)
{
DBG (DBG_error, "Can't reverse ccd for single bit data\n");
return SANE_STATUS_INVAL;
}
@ -4237,29 +4276,28 @@ Problems with the first approach:
dst_lines = (bytes * 8) / (src_pixels * channels * depth);
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",
dst_lines);
if (dst_lines != 0) {
if (dst_lines != 0)
{
if (depth == 8)
status = genesys_reverse_ccd_8(
work_buffer_src, work_buffer_dst,
status = genesys_reverse_ccd_8 (work_buffer_src, work_buffer_dst,
dst_lines,
src_pixels * channels,
ccd_shift,
shift_count);
ccd_shift, shift_count);
else
status = genesys_reverse_ccd_16(
work_buffer_src, work_buffer_dst,
status = genesys_reverse_ccd_16 (work_buffer_src, work_buffer_dst,
dst_lines,
src_pixels * channels,
ccd_shift,
shift_count);
ccd_shift, shift_count);
if (status != SANE_STATUS_GOOD) {
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error,
"genesys_read_ordered_data: failed to reverse ccd effects(%s)\n",
sane_strstatus (status));
@ -4274,7 +4312,8 @@ Problems with the first approach:
}
/* maybe shrink(or enlarge) lines */
if (needs_shrink) {
if (needs_shrink)
{
dst_buffer = &(dev->out_buffer);
@ -4293,36 +4332,36 @@ Problems with the first approach:
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",
dst_lines);
if (dst_lines != 0) {
if (dst_lines != 0)
{
if (depth == 1)
status = genesys_shrink_lines_1 (work_buffer_src,
work_buffer_dst,
dst_lines,
src_pixels,
dev->settings.pixels,
channels);
dev->settings.pixels, channels);
else if (depth == 8)
status = genesys_shrink_lines_8 (work_buffer_src,
work_buffer_dst,
dst_lines,
src_pixels,
dev->settings.pixels,
channels);
dev->settings.pixels, channels);
else
status = genesys_shrink_lines_16 (work_buffer_src,
work_buffer_dst,
dst_lines,
src_pixels,
dev->settings.pixels,
channels);
dev->settings.pixels, channels);
if (status != SANE_STATUS_GOOD) {
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error,
"genesys_read_ordered_data: failed to shrink lines(%s)\n",
sane_strstatus (status));
@ -4351,7 +4390,8 @@ Problems with the first approach:
if (needs_reverse)
{
status = genesys_reverse_bits (work_buffer_src, destination, bytes);
if (status != SANE_STATUS_GOOD) {
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error,
"genesys_read_ordered_data: failed to reverse bits(%s)\n",
sane_strstatus (status));
@ -4361,7 +4401,8 @@ Problems with the first approach:
}
else if (needs_gray_lineart)
{
if (depth != 8) {
if (depth != 8)
{
DBG (DBG_error, "Cannot convert from 16bit to lineart\n");
return SANE_STATUS_INVAL;
}
@ -4373,9 +4414,9 @@ Problems with the first approach:
status = genesys_gray_lineart (work_buffer_src, destination,
dev->settings.pixels,
channels,
dst_lines,
dev->settings.threshold);
if (status != SANE_STATUS_GOOD) {
dst_lines, dev->settings.threshold);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error,
"genesys_read_ordered_data: failed to reverse bits(%s)\n",
sane_strstatus (status));
@ -4454,7 +4495,8 @@ calc_parameters (Genesys_Scanner * s)
/* 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 */
if (resolution > s->dev->sensor.optical_res &&
@ -4708,7 +4750,8 @@ init_options (Genesys_Scanner * s)
/* 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 =
SANE_I18N
("When using high resolutions where the horizontal resolution is smaller "
@ -5351,10 +5394,13 @@ sane_control_option (SANE_Handle handle, SANE_Int option,
else
{
DISABLE (OPT_THRESHOLD);
if (strcmp (s->val[option].s, "Gray") == 0) {
if (strcmp (s->val[option].s, "Gray") == 0)
{
ENABLE (OPT_COLOR_FILTER);
create_bpp_list (s, s->dev->model->bpp_gray_values);
} else {
}
else
{
DISABLE (OPT_COLOR_FILTER);
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-2005 Henning Meier-Geinitz <henning@meier-geinitz.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) 2007 Luke <iceyfor@gmail.com>
This file is part of the SANE package.
@ -474,10 +475,7 @@ static Genesys_Model canon_lide_50_model = {
DAC_CANONLIDE35,
GPO_CANONLIDE35,
MOTOR_CANONLIDE35,
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_LAZY_INIT | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_DARK_WHITE_CALIBRATION, /* Which flags are needed for this scanner? */
280,
400
};
@ -518,10 +516,7 @@ static Genesys_Model canon_lide_60_model = {
DAC_CANONLIDE35,
GPO_CANONLIDE35,
MOTOR_CANONLIDE35,
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_LAZY_INIT | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_DARK_WHITE_CALIBRATION, /* Which flags are needed for this scanner? */
300,
400
}; /* this is completely untested -- hmg */
@ -607,8 +602,12 @@ static Genesys_Model hp2400c_model = {
DAC_WOLFSON_HP2400,
GPO_HP2400,
MOTOR_HP2400,
GENESYS_FLAG_UNTESTED
| GENESYS_FLAG_REPARK | GENESYS_FLAG_USE_PARK | GENESYS_FLAG_14BIT_GAMMA,
GENESYS_FLAG_UNTESTED /* not fully working yet */
| GENESYS_FLAG_REPARK
| GENESYS_FLAG_14BIT_GAMMA
| GENESYS_FLAG_SEARCH_START
| GENESYS_FLAG_MUST_WAIT
| GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_OFFSET_CALIBRATION,
20,
132
};

Wyświetl plik

@ -3,8 +3,9 @@
Copyright (C) 2003 Oliver Rauch
Copyright (C) 2003, 2004 Henning Meier-Geinitz <henning@meier-geinitz.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) 2007 Luke <iceyfor@gmail.com>
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 */
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->value = 2;
@ -732,6 +744,7 @@ gl646_setup_sensor (Genesys_Device * dev,
r = sanei_genesys_get_address (regs, 0x0b);
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 */
/* 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_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_0x20].value = 0x10 /*0x01 */ ; /* n * 2k, below this condition, motor move forward *//* todo: huh, 2k is pretty low? */
}
}
else
{
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 */
/* 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_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;
exposure_time = 6 * MOTOR_SPEED_MAX;
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 ... */
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 & ~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 */
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 & ~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_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_0x6d].value = 0x54;
@ -2019,7 +2045,8 @@ gl646_search_start_position (Genesys_Device * dev)
local_reg[reg_0x62].value = LOBYTE (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) */
else
{
@ -2408,7 +2435,8 @@ gl646_init_regs_for_shading (Genesys_Device * dev)
if (dev->model->motor_type == MOTOR_5345)
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_0x22].value = 16;
@ -2429,7 +2457,8 @@ gl646_init_regs_for_shading (Genesys_Device * dev)
steps = dev->model->y_offset * step_parts;
if (dev->model->motor_type == MOTOR_5345)
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;
else
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));
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 =
sanei_genesys_exposure_time (dev, dev->reg, dev->settings.xres);
else
@ -3289,7 +3319,8 @@ gl646_offset_calibration (Genesys_Device * dev)
steps = 0;
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;
steps = 1;
@ -3312,7 +3343,7 @@ gl646_offset_calibration (Genesys_Device * dev)
dev->calib_reg[reg_0x01].value &= ~REG01_DVDSET;
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)
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_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_0x6b].value = 0x02;