scan alignment troubles

merge-requests/1/head
Stphane Voltz 2010-05-24 06:41:27 +02:00
rodzic a78b0edee7
commit 7cd2ed8ac9
2 zmienionych plików z 39 dodań i 56 usunięć

Wyświetl plik

@ -430,8 +430,8 @@ static Genesys_Sensor Sensor[] = {
{CIS_CANONLIDE100, {CIS_CANONLIDE100,
1200, /* optical resolution */ 1200, /* optical resolution */
87, /* black pixels */ 87, /* black pixels */
16, /* dummy pixels */ 16, /* dummy pixels 16 */
0, 303,
10272, /* 10272 */ 10272, /* 10272 */
210, 210,
200, 200,
@ -788,7 +788,8 @@ static Genesys_Motor Motor[] = {
{ /* power mode 0 */ { /* power mode 0 */
{ 2343, 1017, 128, 0.80}, /* full step */ { 2343, 1017, 128, 0.80}, /* full step */
{ 4678, 2034, 64, 0.80}, /* half step */ { 4678, 2034, 64, 0.80}, /* half step */
{ 4*2034, 4*2034, 32, 0.80}, /* quarter step */ { 4*2034, 4*2034, 32, 0.80}, /* quarter step 0.75*2712 */
/*{ 4*2034, 4*2034, 32, 0.80}, quarter step */
/* extra values kept for documentation /* extra values kept for documentation
{ 2343, 864, 32, 0.80}, full step { 2343, 864, 32, 0.80}, full step
{ 2*1171, 2*648, 32, 0.80}, half step */ { 2*1171, 2*648, 32, 0.80}, half step */
@ -935,7 +936,7 @@ static Genesys_Model canon_lide_100_model = {
{16, 8, 0}, /* possible depths in gray mode */ {16, 8, 0}, /* possible depths in gray mode */
{16, 8, 0}, /* possible depths in color mode */ {16, 8, 0}, /* possible depths in color mode */
SANE_FIX (6.0), /* Start of scan area in mm (x) 6.95 */ SANE_FIX (0.0), /* Start of scan area in mm (x) 6.95 */
SANE_FIX (30.0), /* Start of scan area in mm (y) */ SANE_FIX (30.0), /* Start of scan area in mm (y) */
SANE_FIX (216.07), /* Size of scan area in mm (x) */ SANE_FIX (216.07), /* Size of scan area in mm (x) */
SANE_FIX (299.0), /* Size of scan area in mm (y) */ SANE_FIX (299.0), /* Size of scan area in mm (y) */
@ -972,7 +973,7 @@ static Genesys_Model canon_lide_100_model = {
| GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_DARK_CALIBRATION
| GENESYS_FLAG_CUSTOM_GAMMA, | GENESYS_FLAG_CUSTOM_GAMMA,
GENESYS_HAS_SCAN_SW | GENESYS_HAS_COPY_SW | GENESYS_HAS_EMAIL_SW | GENESYS_HAS_FILE_SW, GENESYS_HAS_SCAN_SW | GENESYS_HAS_COPY_SW | GENESYS_HAS_EMAIL_SW | GENESYS_HAS_FILE_SW,
150, 50,
400 400
}; };

Wyświetl plik

@ -461,9 +461,9 @@ gl847_init_registers (Genesys_Device * dev)
SETREG (0x14, 0x00); SETREG (0x14, 0x00);
SETREG (0x15, 0x00); SETREG (0x15, 0x00);
SETREG (0x16, 0x10); SETREG (0x16, 0x10);
SETREG (0x17, 0x0c); SETREG (0x17, 0x08);
SETREG (0x18, 0x00); SETREG (0x18, 0x00);
SETREG (0x19, 0xff); SETREG (0x19, 0x50);
SETREG (0x1a, 0x34); SETREG (0x1a, 0x34);
SETREG (0x1b, 0x00); SETREG (0x1b, 0x00);
SETREG (0x1c, 0x02); SETREG (0x1c, 0x02);
@ -1416,7 +1416,7 @@ gl847_init_optical_regs_scan (Genesys_Device * dev,
SANE_Bool half_ccd, int color_filter, int flags) SANE_Bool half_ccd, int color_filter, int flags)
{ {
unsigned int words_per_line; unsigned int words_per_line;
unsigned int end, used_pixels; unsigned int startx,endx, used_pixels;
unsigned int dpiset; unsigned int dpiset;
unsigned int i; unsigned int i;
Genesys_Register_Set *r; Genesys_Register_Set *r;
@ -1428,6 +1428,7 @@ gl847_init_optical_regs_scan (Genesys_Device * dev,
exposure_time, exposure_time,
used_res, start, pixels, channels, depth, half_ccd, flags); used_res, start, pixels, channels, depth, half_ccd, flags);
startx = dev->sensor.dummy_pixel + 1 + dev->sensor.CCD_start_xoffset - 32;
if(pixels<dev->sensor.sensor_pixels) if(pixels<dev->sensor.sensor_pixels)
{ {
used_pixels = dev->sensor.sensor_pixels; used_pixels = dev->sensor.sensor_pixels;
@ -1436,7 +1437,7 @@ gl847_init_optical_regs_scan (Genesys_Device * dev,
{ {
used_pixels = pixels; used_pixels = pixels;
} }
end = start + used_pixels; endx = startx + used_pixels;
status = gl847_set_fe (dev, AFE_SET); status = gl847_set_fe (dev, AFE_SET);
if (status != SANE_STATUS_GOOD) if (status != SANE_STATUS_GOOD)
@ -1456,11 +1457,14 @@ gl847_init_optical_regs_scan (Genesys_Device * dev,
r->value &= ~(REG01_SCAN | REG01_SHDAREA); r->value &= ~(REG01_SCAN | REG01_SHDAREA);
if ((flags & OPTICAL_FLAG_DISABLE_SHADING) || if ((flags & OPTICAL_FLAG_DISABLE_SHADING) ||
(dev->model->flags & GENESYS_FLAG_NO_CALIBRATION)) (dev->model->flags & GENESYS_FLAG_NO_CALIBRATION))
r->value &= ~REG01_DVDSET; {
r->value &= ~REG01_DVDSET;
}
else else
{ {
r->value |= REG01_DVDSET | REG01_SHDAREA; r->value |= REG01_DVDSET;
} }
r->value &= ~REG01_DVDSET; /* XXX STEF XXX */
/* average looks better than deletion, and we are already set up to /* average looks better than deletion, and we are already set up to
use one of the average enabled resolutions */ use one of the average enabled resolutions */
@ -1556,13 +1560,13 @@ gl847_init_optical_regs_scan (Genesys_Device * dev,
DBG (DBG_io2, "%s: dpiset used=%d\n", __FUNCTION__, dpiset); DBG (DBG_io2, "%s: dpiset used=%d\n", __FUNCTION__, dpiset);
r = sanei_genesys_get_address (reg, 0x30); r = sanei_genesys_get_address (reg, 0x30);
r->value = HIBYTE (start); r->value = HIBYTE (startx);
r = sanei_genesys_get_address (reg, 0x31); r = sanei_genesys_get_address (reg, 0x31);
r->value = LOBYTE (start); r->value = LOBYTE (startx);
r = sanei_genesys_get_address (reg, 0x32); r = sanei_genesys_get_address (reg, 0x32);
r->value = HIBYTE (end); r->value = HIBYTE (endx);
r = sanei_genesys_get_address (reg, 0x33); r = sanei_genesys_get_address (reg, 0x33);
r->value = LOBYTE (end); r->value = LOBYTE (endx);
/* words(16bit) before gamma, conversion to 8 bit or lineart*/ /* words(16bit) before gamma, conversion to 8 bit or lineart*/
words_per_line = (used_pixels * dpiset) / gl847_get_dpihw (dev); words_per_line = (used_pixels * dpiset) / gl847_get_dpihw (dev);
@ -1604,13 +1608,13 @@ gl847_init_optical_regs_scan (Genesys_Device * dev,
r = sanei_genesys_get_address (reg, 0x34); r = sanei_genesys_get_address (reg, 0x34);
r->value = dev->sensor.dummy_pixel; r->value = dev->sensor.dummy_pixel;
/* XXX STEF XXX */ /* XXX STEF XXX
r = sanei_genesys_get_address (reg, 0x1d); r = sanei_genesys_get_address (reg, 0x1d);
i = 2*r->value; i = 2*r->value;
r = sanei_genesys_get_address (reg, 0x17); r = sanei_genesys_get_address (reg, 0x17);
i += r->value; i += r->value;
r = sanei_genesys_get_address (reg, 0x34); r = sanei_genesys_get_address (reg, 0x34);
r->value = i; r->value = i; */
DBG (DBG_proc, "gl847_init_optical_regs_scan : completed. \n"); DBG (DBG_proc, "gl847_init_optical_regs_scan : completed. \n");
return SANE_STATUS_GOOD; return SANE_STATUS_GOOD;
@ -1768,18 +1772,11 @@ independent of our calculated values:
used_res = optical_res / 15; used_res = optical_res / 15;
/* compute scan parameters values */ /* compute scan parameters values */
/* pixels are allways given at half or full CCD optical resolution */ /* pixels are allways given at full optical resolution */
/* use detected left margin and fixed value */ /* use detected left margin and fixed value */
/* start */ /* start */
/* add x coordinates */ /* add x coordinates */
start = start = startx;
((dev->sensor.CCD_start_xoffset + startx) * used_res) /
dev->sensor.optical_res;
/* needs to be aligned for used_res */
start = (start * optical_res) / used_res;
start += dev->sensor.dummy_pixel + 1;
if (stagger > 0) if (stagger > 0)
start |= 1; start |= 1;
@ -2063,22 +2060,20 @@ gl847_calculate_current_setup (Genesys_Device * dev)
dev->settings.yres, dev->settings.lines, dev->settings.pixels, dev->settings.yres, dev->settings.lines, dev->settings.pixels,
dev->settings.tl_x, dev->settings.tl_y, dev->settings.scan_mode); dev->settings.tl_x, dev->settings.tl_y, dev->settings.scan_mode);
/* channels */ /* channels */
if (dev->settings.scan_mode == 4) /* single pass color */ if (dev->settings.scan_mode == 4) /* single pass color */
channels = 3; channels = 3;
else else
channels = 1; channels = 1;
/* depth */ /* depth */
depth = dev->settings.depth; depth = dev->settings.depth;
if (dev->settings.scan_mode == 0) if (dev->settings.scan_mode == 0)
depth = 1; depth = 1;
/* start */ /* start */
start = SANE_UNFIX (dev->model->x_offset); start = SANE_UNFIX (dev->model->x_offset);
start += dev->settings.tl_x; start += dev->settings.tl_x;
start = (start * dev->sensor.optical_res) / MM_PER_INCH; start = (start * dev->sensor.optical_res) / MM_PER_INCH;
@ -2155,19 +2150,6 @@ gl847_calculate_current_setup (Genesys_Device * dev)
/* compute scan parameters values */ /* compute scan parameters values */
/* pixels are allways given at half or full CCD optical resolution */ /* pixels are allways given at half or full CCD optical resolution */
/* use detected left margin and fixed value */ /* use detected left margin and fixed value */
/* start */
/* add x coordinates */
start =
((dev->sensor.CCD_start_xoffset + startx) * used_res) /
dev->sensor.optical_res;
/* needs to be aligned for used_res */
start = (start * optical_res) / used_res;
start += dev->sensor.dummy_pixel + 1;
if (stagger > 0)
start |= 1;
/* compute correct pixels number */ /* compute correct pixels number */
/* pixels */ /* pixels */
@ -2924,7 +2906,7 @@ gl847_feed (Genesys_Device * dev, int steps)
if (status != SANE_STATUS_GOOD) if (status != SANE_STATUS_GOOD)
{ {
DBG (DBG_error, DBG (DBG_error,
"gl847_feed: Failed to stop action: %s\n", "gl847_feed: failed to stop action: %s\n",
sane_strstatus (status)); sane_strstatus (status));
return status; return status;
} }
@ -2942,7 +2924,7 @@ gl847_feed (Genesys_Device * dev, int steps)
if (status != SANE_STATUS_GOOD) if (status != SANE_STATUS_GOOD)
{ {
DBG (DBG_error, DBG (DBG_error,
"gl847_feed: Failed to bulk write registers: %s\n", "gl847_feed: failed to bulk write registers: %s\n",
sane_strstatus (status)); sane_strstatus (status));
return status; return status;
} }
@ -2951,7 +2933,7 @@ gl847_feed (Genesys_Device * dev, int steps)
if (status != SANE_STATUS_GOOD) if (status != SANE_STATUS_GOOD)
{ {
DBG (DBG_error, DBG (DBG_error,
"gl847_feed: Failed to start motor: %s\n", "gl847_feed: failed to start motor: %s\n",
sane_strstatus (status)); sane_strstatus (status));
gl847_stop_action (dev); gl847_stop_action (dev);
/* send original registers */ /* send original registers */
@ -2966,7 +2948,7 @@ gl847_feed (Genesys_Device * dev, int steps)
if (status != SANE_STATUS_GOOD) if (status != SANE_STATUS_GOOD)
{ {
DBG (DBG_error, DBG (DBG_error,
"gl847_feed: Failed to read home sensor: %s\n", "gl847_feed: failed to read home sensor: %s\n",
sane_strstatus (status)); sane_strstatus (status));
return status; return status;
} }
@ -2985,7 +2967,7 @@ gl847_feed (Genesys_Device * dev, int steps)
gl847_stop_action (dev); gl847_stop_action (dev);
DBG (DBG_error, DBG (DBG_error,
"gl847_feed: timeout while waiting for scanhead to go home\n"); "gl847_feed: timeout while feeding\n");
return SANE_STATUS_IO_ERROR; return SANE_STATUS_IO_ERROR;
} }
@ -3341,8 +3323,7 @@ gl847_init_regs_for_shading (Genesys_Device * dev)
dev->settings.color_filter, dev->settings.color_filter,
SCAN_FLAG_DISABLE_SHADING | SCAN_FLAG_DISABLE_SHADING |
SCAN_FLAG_DISABLE_GAMMA | SCAN_FLAG_DISABLE_GAMMA |
/* we don't handle differing shading areas very well */ SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE |
/* SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE |*/
SCAN_FLAG_IGNORE_LINE_DISTANCE | SCAN_FLAG_IGNORE_LINE_DISTANCE |
SCAN_FLAG_USE_OPTICAL_RES); SCAN_FLAG_USE_OPTICAL_RES);
@ -3655,7 +3636,7 @@ gl847_led_calibration (Genesys_Device * dev)
int i, j; int i, j;
SANE_Status status = SANE_STATUS_GOOD; SANE_Status status = SANE_STATUS_GOOD;
int val; int val;
int channels; int channels, depth;
int avg[3], avga, avge; int avg[3], avga, avge;
int turn; int turn;
char fn[20]; char fn[20];
@ -3668,6 +3649,7 @@ gl847_led_calibration (Genesys_Device * dev)
/* offset calibration is always done in color mode */ /* offset calibration is always done in color mode */
channels = 3; channels = 3;
depth=16;
/* initial calibration reg values */ /* initial calibration reg values */
memcpy (dev->calib_reg, dev->reg, memcpy (dev->calib_reg, dev->reg,
@ -3683,7 +3665,7 @@ gl847_led_calibration (Genesys_Device * dev)
dev->settings.xres) / dev->settings.xres) /
dev->sensor.optical_res, dev->sensor.optical_res,
1, 1,
16, depth,
channels, channels,
dev->settings.color_filter, dev->settings.color_filter,
SCAN_FLAG_DISABLE_SHADING | SCAN_FLAG_DISABLE_SHADING |
@ -3706,7 +3688,7 @@ gl847_led_calibration (Genesys_Device * dev)
used_res = dev->current_setup.xres; used_res = dev->current_setup.xres;
num_pixels = dev->current_setup.pixels; num_pixels = dev->current_setup.pixels;
total_size = num_pixels * channels * 2 * 1; /* colors * bytes_per_color * scan lines */ total_size = num_pixels * channels * (depth/8) * 1; /* colors * bytes_per_color * scan lines */
line = malloc (total_size); line = malloc (total_size);
if (!line) if (!line)
@ -3755,7 +3737,7 @@ gl847_led_calibration (Genesys_Device * dev)
{ {
snprintf (fn, 20, "led_%d.pnm", turn); snprintf (fn, 20, "led_%d.pnm", turn);
sanei_genesys_write_pnm_file (fn, sanei_genesys_write_pnm_file (fn,
line, 16, channels, num_pixels, 1); line, depth, channels, num_pixels, 1);
} }
acceptable = SANE_TRUE; acceptable = SANE_TRUE;