work toward shading calibration

- black/white strip searching reliable
- call to dar and white shading calibration
merge-requests/1/head
Stphane Voltz 2009-06-15 22:16:06 +02:00
rodzic 7c44981be0
commit 3135e94c90
3 zmienionych plików z 359 dodań i 248 usunięć

Wyświetl plik

@ -282,8 +282,7 @@ sanei_genesys_set_reg_from_set (Genesys_Register_Set * reg, SANE_Byte address,
/* Write to one register */ /* Write to one register */
SANE_Status SANE_Status
sanei_genesys_write_register (Genesys_Device * dev, uint8_t reg, sanei_genesys_write_register (Genesys_Device * dev, uint8_t reg, uint8_t val)
uint8_t val)
{ {
SANE_Status status; SANE_Status status;
@ -318,8 +317,7 @@ sanei_genesys_write_register (Genesys_Device * dev, uint8_t reg,
/* Read from one register */ /* Read from one register */
SANE_Status SANE_Status
sanei_genesys_read_register (Genesys_Device * dev, uint8_t reg, sanei_genesys_read_register (Genesys_Device * dev, uint8_t reg, uint8_t * val)
uint8_t * val)
{ {
SANE_Status status; SANE_Status status;
@ -428,7 +426,8 @@ sanei_genesys_init_structs (Genesys_Device * dev)
{ {
DBG (DBG_error0, DBG (DBG_error0,
"sanei_genesys_init_structs: bad description(s) for ccd/gpo/motor=%d/%d/%d\n", "sanei_genesys_init_structs: bad description(s) for ccd/gpo/motor=%d/%d/%d\n",
dev->model->ccd_type, dev->model->gpo_type, dev->model->motor_type); dev->model->ccd_type, dev->model->gpo_type,
dev->model->motor_type);
} }
} }
@ -448,7 +447,8 @@ sanei_genesys_init_fe (Genesys_Device * dev)
DBG (DBG_error0, DBG (DBG_error0,
"sanei_genesys_init_fe: failed to find description for dac_type %d\n", "sanei_genesys_init_fe: failed to find description for dac_type %d\n",
dev->model->dac_type); dev->model->dac_type);
DBG (DBG_info, "sanei_genesys_init_fe: dac_type %d set up\n", dev->model->dac_type); DBG (DBG_info, "sanei_genesys_init_fe: dac_type %d set up\n",
dev->model->dac_type);
} }
/* Write data for analog frontend */ /* Write data for analog frontend */
@ -734,12 +734,11 @@ sanei_genesys_create_slope_table3 (Genesys_Device * dev,
vtarget, vtarget,
vstart, vstart,
vend, vend,
dev->motor. dev->motor.slopes[power_mode]
slopes[power_mode] [step_type].minimum_steps <<
[step_type]. step_type,
minimum_steps << step_type, dev->
dev->motor. motor.slopes[power_mode]
slopes[power_mode]
[step_type].g, used_steps, [step_type].g, used_steps,
&vfinal); &vfinal);
@ -797,12 +796,11 @@ genesys_create_slope_table4 (Genesys_Device * dev,
vtarget, vtarget,
vstart, vstart,
vend, vend,
dev->motor. dev->motor.slopes[power_mode]
slopes[power_mode] [step_type].minimum_steps <<
[step_type]. step_type,
minimum_steps << step_type, dev->
dev->motor. motor.slopes[power_mode]
slopes[power_mode]
[step_type].g, NULL, NULL); [step_type].g, NULL, NULL);
DBG (DBG_proc, DBG (DBG_proc,
@ -977,8 +975,7 @@ sanei_genesys_create_slope_table (Genesys_Device * dev,
divider = 1 << step_type; divider = 1 << step_type;
time_period = time_period =
(uint32_t) (yres * exposure_time / (uint32_t) (yres * exposure_time / dev->motor.base_ydpi /*MOTOR_GEAR */ );
dev->motor.base_ydpi /*MOTOR_GEAR */ );
if ((time_period < 2000) && (same_speed)) if ((time_period < 2000) && (same_speed))
same_speed = SANE_FALSE; same_speed = SANE_FALSE;
@ -1740,8 +1737,7 @@ sanei_genesys_calculate_zmode (Genesys_Device * dev, uint32_t exposure_time,
uint32_t steps_sum, uint16_t last_speed, uint32_t steps_sum, uint16_t last_speed,
uint32_t feedl, uint8_t fastfed, uint32_t feedl, uint8_t fastfed,
uint8_t scanfed, uint8_t fwdstep, uint8_t scanfed, uint8_t fwdstep,
uint8_t tgtime, uint32_t * z1, uint8_t tgtime, uint32_t * z1, uint32_t * z2)
uint32_t * z2)
{ {
uint8_t exposure_factor; uint8_t exposure_factor;
@ -2262,19 +2258,27 @@ genesys_dark_shading_calibration (Genesys_Device * dev)
calibration_data = malloc (size); calibration_data = malloc (size);
if (!calibration_data) if (!calibration_data)
{ {
DBG (DBG_error, "genesys_dark_shading_calibration: " DBG (DBG_error, "genesys_dark_shading_calibration: failed to allocate calibration data memory\n");
"failed to allocate calibration data memory\n");
return SANE_STATUS_NO_MEM; return SANE_STATUS_NO_MEM;
} }
/* turn off motor and lamp power */ /* turn off motor and lamp power for flatbed scanners, but not for sheetfed scanners
* because they have a calibration sheet with a sufficent black strip */
if (dev->model->is_sheetfed==SANE_FALSE)
{
dev->model->cmd_set->set_lamp_power (dev, dev->calib_reg, SANE_FALSE); dev->model->cmd_set->set_lamp_power (dev, dev->calib_reg, SANE_FALSE);
dev->model->cmd_set->set_motor_power (dev->calib_reg, SANE_FALSE); dev->model->cmd_set->set_motor_power (dev->calib_reg, SANE_FALSE);
}
else
{
dev->model->cmd_set->set_lamp_power (dev, dev->calib_reg, SANE_TRUE);
dev->model->cmd_set->set_motor_power (dev->calib_reg, SANE_TRUE);
}
status = status =
dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg,
dev->model->cmd_set-> dev->model->
bulk_full_size ()); cmd_set->bulk_full_size ());
if (status != SANE_STATUS_GOOD) if (status != SANE_STATUS_GOOD)
{ {
free (calibration_data); free (calibration_data);
@ -2325,8 +2329,9 @@ genesys_dark_shading_calibration (Genesys_Device * dev)
sanei_genesys_write_pnm_file ("black_shading.pnm", calibration_data, 16, sanei_genesys_write_pnm_file ("black_shading.pnm", calibration_data, 16,
channels, pixels_per_line, channels, pixels_per_line,
dev->model->shading_lines); dev->model->shading_lines);
sanei_genesys_write_pnm_file ("black_average.pnm", dev->dark_average_data, sanei_genesys_write_pnm_file ("black_average.pnm",
16, channels, pixels_per_line, 1); dev->dark_average_data, 16, channels,
pixels_per_line, 1);
} }
free (calibration_data); free (calibration_data);
@ -2479,8 +2484,8 @@ genesys_white_shading_calibration (Genesys_Device * dev)
status = status =
dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg,
dev->model->cmd_set-> dev->model->
bulk_full_size ()); cmd_set->bulk_full_size ());
if (status != SANE_STATUS_GOOD) if (status != SANE_STATUS_GOOD)
{ {
free (calibration_data); free (calibration_data);
@ -2558,7 +2563,7 @@ genesys_white_shading_calibration (Genesys_Device * dev)
} }
/* This calibration uses a scan over the calibration target, comprising a /* This calibration uses a scan over the calibration target, comprising a
* black and a white stripe. (So the motor must be on.) * black and a white strip. (So the motor must be on.)
*/ */
static SANE_Status static SANE_Status
genesys_dark_white_shading_calibration (Genesys_Device * dev) genesys_dark_white_shading_calibration (Genesys_Device * dev)
@ -2620,8 +2625,8 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev)
status = status =
dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg,
dev->model->cmd_set-> dev->model->
bulk_full_size ()); cmd_set->bulk_full_size ());
if (status != SANE_STATUS_GOOD) if (status != SANE_STATUS_GOOD)
{ {
free (calibration_data); free (calibration_data);
@ -2930,7 +2935,7 @@ genesys_send_shading_coefficient (Genesys_Device * dev)
channels = dev->calib_channels; channels = dev->calib_channels;
/* 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 && dev->model->asic_type != GENESYS_GL646)
{ {
switch (sanei_genesys_read_reg_from_set (dev->reg, 0x05) >> 6) switch (sanei_genesys_read_reg_from_set (dev->reg, 0x05) >> 6)
{ {
@ -2968,6 +2973,16 @@ genesys_send_shading_coefficient (Genesys_Device * dev)
switch (dev->model->ccd_type) switch (dev->model->ccd_type)
{ {
case CIS_XP200:
target_code = 0xfa00;
memset (shading_data, 0x00, pixels_per_line * 4 * channels);
o = 0;
avgpixels = 1;
compute_coefficients (dev,
shading_data,
pixels_per_line,
channels, avgpixels, o, coeff, target_code);
break;
case CCD_5345: case CCD_5345:
target_code = 0xfa00; target_code = 0xfa00;
memset (shading_data, 0x00, pixels_per_line * 4 * channels); memset (shading_data, 0x00, pixels_per_line * 4 * channels);
@ -3200,7 +3215,8 @@ genesys_restore_calibration (Genesys_Device * dev)
DBG (DBG_proc, "genesys_restore_calibration\n"); DBG (DBG_proc, "genesys_restore_calibration\n");
/* if no cache or no function to evaluate cache entry ther can be no match */ /* if no cache or no function to evaluate cache entry ther can be no match */
if (!dev->model->cmd_set->is_compatible_calibration || dev->calibration_cache==NULL) if (!dev->model->cmd_set->is_compatible_calibration
|| dev->calibration_cache == NULL)
return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_UNSUPPORTED;
/* we walk the link list of calibration cache in search for a /* we walk the link list of calibration cache in search for a
@ -3487,6 +3503,7 @@ genesys_flatbed_calibration (Genesys_Device * dev)
pixels_per_line = (SANE_UNFIX (dev->model->x_size) * dev->settings.xres) / pixels_per_line = (SANE_UNFIX (dev->model->x_size) * dev->settings.xres) /
MM_PER_INCH; MM_PER_INCH;
/* XXX STEF XXX ??? could this be the root of 2300 shading problems */
/* send default shading data */ /* send default shading data */
status = sanei_genesys_init_shading_data (dev, pixels_per_line); status = sanei_genesys_init_shading_data (dev, pixels_per_line);
if (status != SANE_STATUS_GOOD) if (status != SANE_STATUS_GOOD)
@ -3602,6 +3619,78 @@ genesys_sheetfed_calibration (Genesys_Device * dev)
return status; return status;
} }
/******************* shading calibration ***************************/
/* send default shading data */
/* XXX STEF XXX status = sanei_genesys_init_shading_data (dev, pixels_per_line);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error,
"genesys_sheetfed_calibration: failed to init shading process: %s\n",
sane_strstatus (status));
return status;
}*/
/* we know we hare on a black area */
if (dev->model->flags & GENESYS_FLAG_DARK_CALIBRATION)
{
status = dev->model->cmd_set->init_regs_for_shading (dev);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error,
"genesys_sheetfed_calibration: failed to do wset up registers for shading calibration: %s\n",
sane_strstatus (status));
return status;
}
status = genesys_dark_shading_calibration (dev);
if (status != SANE_STATUS_GOOD)
{
dev->model->cmd_set->eject_document (dev);
DBG (DBG_error,
"genesys_sheetfed_calibration: failed to do dark shading calibration: %s\n",
sane_strstatus (status));
return status;
}
}
/* go back to a white area */
status = dev->model->cmd_set->search_strip (dev, SANE_FALSE, SANE_FALSE);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error,
"genesys_sheetfed_calibration: failed to find black strip: %s\n",
sane_strstatus (status));
dev->model->cmd_set->eject_document (dev);
return status;
}
status = dev->model->cmd_set->init_regs_for_shading (dev);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error,
"genesys_sheetfed_calibration: failed to do wset up registers for shading calibration: %s\n",
sane_strstatus (status));
return status;
}
status = genesys_white_shading_calibration (dev);
if (status != SANE_STATUS_GOOD)
{
dev->model->cmd_set->eject_document (dev);
DBG (DBG_error,
"genesys_sheetfed_calibration: failed to do white shading calibration: %s\n",
sane_strstatus (status));
return status;
}
/* send the shading coefficient */
status = genesys_send_shading_coefficient (dev);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error,
"genesys_sheetfed_calibration: failed to send shading calibration coefficients: %s\n",
sane_strstatus (status));
return status;
}
/* and finally eject calibration sheet */ /* and finally eject calibration sheet */
status = dev->model->cmd_set->eject_document (dev); status = dev->model->cmd_set->eject_document (dev);
if (status != SANE_STATUS_GOOD) if (status != SANE_STATUS_GOOD)
@ -3953,8 +4042,8 @@ genesys_start_scan (Genesys_Device * dev)
status = status =
dev->model->cmd_set->bulk_write_register (dev, dev->reg, dev->model->cmd_set->bulk_write_register (dev, dev->reg,
dev->model->cmd_set-> dev->model->
bulk_full_size ()); cmd_set->bulk_full_size ());
if (status != SANE_STATUS_GOOD) if (status != SANE_STATUS_GOOD)
{ {
DBG (DBG_error, DBG (DBG_error,
@ -5159,7 +5248,8 @@ init_options (Genesys_Scanner * s)
s->opt[OPT_SCAN_SW].type = SANE_TYPE_BOOL; s->opt[OPT_SCAN_SW].type = SANE_TYPE_BOOL;
s->opt[OPT_SCAN_SW].unit = SANE_UNIT_NONE; s->opt[OPT_SCAN_SW].unit = SANE_UNIT_NONE;
if (model->buttons & GENESYS_HAS_SCAN_SW) if (model->buttons & GENESYS_HAS_SCAN_SW)
s->opt[OPT_SCAN_SW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; s->opt[OPT_SCAN_SW].cap =
SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED;
else else
s->opt[OPT_SCAN_SW].cap = SANE_CAP_INACTIVE; s->opt[OPT_SCAN_SW].cap = SANE_CAP_INACTIVE;
s->val[OPT_SCAN_SW].b = 0; s->val[OPT_SCAN_SW].b = 0;
@ -5256,11 +5346,14 @@ init_options (Genesys_Scanner * s)
/* calibrate button */ /* calibrate button */
s->opt[OPT_CALIBRATE].name = "calibrate"; s->opt[OPT_CALIBRATE].name = "calibrate";
s->opt[OPT_CALIBRATE].title = SANE_I18N ("Calibrate"); s->opt[OPT_CALIBRATE].title = SANE_I18N ("Calibrate");
s->opt[OPT_CALIBRATE].desc = SANE_I18N("Start calibration using special sheet"); s->opt[OPT_CALIBRATE].desc =
SANE_I18N ("Start calibration using special sheet");
s->opt[OPT_CALIBRATE].type = SANE_TYPE_BUTTON; s->opt[OPT_CALIBRATE].type = SANE_TYPE_BUTTON;
s->opt[OPT_CALIBRATE].unit = SANE_UNIT_NONE; s->opt[OPT_CALIBRATE].unit = SANE_UNIT_NONE;
if (model->buttons & GENESYS_HAS_CALIBRATE) if (model->buttons & GENESYS_HAS_CALIBRATE)
s->opt[OPT_CALIBRATE].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED | SANE_CAP_AUTOMATIC; s->opt[OPT_CALIBRATE].cap =
SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED |
SANE_CAP_AUTOMATIC;
else else
s->opt[OPT_CALIBRATE].cap = SANE_CAP_INACTIVE; s->opt[OPT_CALIBRATE].cap = SANE_CAP_INACTIVE;
s->val[OPT_CALIBRATE].b = 0; s->val[OPT_CALIBRATE].b = 0;
@ -5272,7 +5365,9 @@ init_options (Genesys_Scanner * s)
s->opt[OPT_CLEAR_CALIBRATION].desc = SANE_I18N ("Clear calibration cache"); s->opt[OPT_CLEAR_CALIBRATION].desc = SANE_I18N ("Clear calibration cache");
s->opt[OPT_CLEAR_CALIBRATION].type = SANE_TYPE_BUTTON; s->opt[OPT_CLEAR_CALIBRATION].type = SANE_TYPE_BUTTON;
s->opt[OPT_CLEAR_CALIBRATION].unit = SANE_UNIT_NONE; s->opt[OPT_CLEAR_CALIBRATION].unit = SANE_UNIT_NONE;
s->opt[OPT_CLEAR_CALIBRATION].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED | SANE_CAP_AUTOMATIC; s->opt[OPT_CLEAR_CALIBRATION].cap =
SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED |
SANE_CAP_AUTOMATIC;
s->val[OPT_CLEAR_CALIBRATION].b = 0; s->val[OPT_CLEAR_CALIBRATION].b = 0;
s->last_val[OPT_CLEAR_CALIBRATION].b = 0; s->last_val[OPT_CLEAR_CALIBRATION].b = 0;
@ -5491,7 +5586,8 @@ read_calibration(Genesys_Device * dev)
fread (&size, 4, 1, fp); fread (&size, 4, 1, fp);
if (size != sizeof (struct Genesys_Calibration_Cache)) if (size != sizeof (struct Genesys_Calibration_Cache))
{ {
DBG ( DBG_info, "Calibration: Size of calibration cache struct differs\n" ); DBG (DBG_info,
"Calibration: Size of calibration cache struct differs\n");
fclose (fp); fclose (fp);
DBG (DBG_proc, "read_calibration: exit\n"); DBG (DBG_proc, "read_calibration: exit\n");
return; return;
@ -5504,7 +5600,8 @@ read_calibration(Genesys_Device * dev)
if (!cache) if (!cache)
{ {
DBG (DBG_error, "read_calibration: could not allocate cache struct\n"); DBG (DBG_error,
"read_calibration: could not allocate cache struct\n");
break; break;
} }
@ -5525,13 +5622,19 @@ read_calibration(Genesys_Device * dev)
free (cache); free (cache);
break; break;
} }
BILT1(fread(&cache->last_calibration,sizeof(cache->last_calibration),1,fp)); BILT1 (fread
(&cache->last_calibration, sizeof (cache->last_calibration), 1,
fp));
BILT1 (fread (&cache->frontend, sizeof (cache->frontend), 1, fp)); BILT1 (fread (&cache->frontend, sizeof (cache->frontend), 1, fp));
/* the gamma (and later) fields are not stored */ /* the gamma (and later) fields are not stored */
BILT1(fread(&cache->sensor,offsetof(Genesys_Sensor,red_gamma),1,fp)); BILT1 (fread
BILT1(fread(&cache->calib_pixels,sizeof(cache->calib_pixels),1,fp)); (&cache->sensor, offsetof (Genesys_Sensor, red_gamma), 1, fp));
BILT1(fread(&cache->calib_channels,sizeof(cache->calib_channels),1,fp)); BILT1 (fread
BILT1(fread(&cache->average_size,sizeof(cache->average_size),1,fp)); (&cache->calib_pixels, sizeof (cache->calib_pixels), 1, fp));
BILT1 (fread
(&cache->calib_channels, sizeof (cache->calib_channels), 1, fp));
BILT1 (fread
(&cache->average_size, sizeof (cache->average_size), 1, fp));
/* Make sure we don't do bad things if someone feeds us a forged/ /* Make sure we don't do bad things if someone feeds us a forged/
sufficiently corrupted calibration file. sufficiently corrupted calibration file.
@ -5552,7 +5655,8 @@ read_calibration(Genesys_Device * dev)
FREE_IFNOT_NULL (cache->white_average_data); FREE_IFNOT_NULL (cache->white_average_data);
FREE_IFNOT_NULL (cache->dark_average_data); FREE_IFNOT_NULL (cache->dark_average_data);
free (cache); free (cache);
DBG (DBG_error, "read_calibration: could not allocate space for average data\n"); DBG (DBG_error,
"read_calibration: could not allocate space for average data\n");
break; break;
} }
@ -5604,7 +5708,8 @@ write_calibration(Genesys_Device * dev)
for (cache = dev->calibration_cache; cache; cache = cache->next) for (cache = dev->calibration_cache; cache; cache = cache->next)
{ {
fwrite (&cache->used_setup, sizeof (cache->used_setup), 1, fp); fwrite (&cache->used_setup, sizeof (cache->used_setup), 1, fp);
fwrite(&cache->last_calibration,sizeof(cache->last_calibration),1,fp); fwrite (&cache->last_calibration, sizeof (cache->last_calibration), 1,
fp);
fwrite (&cache->frontend, sizeof (cache->frontend), 1, fp); fwrite (&cache->frontend, sizeof (cache->frontend), 1, fp);
/* the gamma (and later) fields are not stored */ /* the gamma (and later) fields are not stored */
fwrite (&cache->sensor, offsetof (Genesys_Sensor, red_gamma), 1, fp); fwrite (&cache->sensor, offsetof (Genesys_Sensor, red_gamma), 1, fp);
@ -5839,9 +5944,12 @@ sane_open (SANE_String_Const devicename, SANE_Handle * handle)
*/ */
ptr = getenv ("HOME"); ptr = getenv ("HOME");
if( NULL == ptr ) { if (NULL == ptr)
{
sprintf (tmp_str, "/tmp/%s.cal", s->dev->model->name); sprintf (tmp_str, "/tmp/%s.cal", s->dev->model->name);
} else { }
else
{
sprintf (tmp_str, "%s/.sane/%s.cal", ptr, s->dev->model->name); sprintf (tmp_str, "%s/.sane/%s.cal", ptr, s->dev->model->name);
} }
s->dev->calib_file = strdup (tmp_str); s->dev->calib_file = strdup (tmp_str);
@ -5878,6 +5986,12 @@ sane_close (SANE_Handle handle)
return; /* oops, not a handle we know about */ return; /* oops, not a handle we know about */
} }
/* eject document for shhetfed scanners */
if (s->dev->model->is_sheetfed == SANE_TRUE)
{
s->dev->model->cmd_set->eject_document (s->dev);
}
/* here is the place to store calibration cache */ /* here is the place to store calibration cache */
write_calibration (s->dev); write_calibration (s->dev);
@ -6124,8 +6238,8 @@ set_option_value (Genesys_Scanner * s, int option, void *val,
if (*(SANE_Word *) val != s->val[option].w) if (*(SANE_Word *) val != s->val[option].w)
{ {
s->val[option].w = *(SANE_Word *) val; s->val[option].w = *(SANE_Word *) val;
RIE (s->dev->model-> RIE (s->dev->model->cmd_set->
cmd_set->set_powersaving (s->dev, s->val[option].w)); set_powersaving (s->dev, s->val[option].w));
} }
break; break;
@ -6162,38 +6276,27 @@ set_option_value (Genesys_Scanner * s, int option, void *val,
sanei_genesys_create_gamma_table (s->dev->sensor.red_gamma_table, sanei_genesys_create_gamma_table (s->dev->sensor.red_gamma_table,
s->opt[OPT_GAMMA_VECTOR_R].size / s->opt[OPT_GAMMA_VECTOR_R].size /
sizeof (SANE_Word), sizeof (SANE_Word),
s-> s->opt
opt [OPT_GAMMA_VECTOR_R].
[OPT_GAMMA_VECTOR_R].constraint. constraint.range->max,
range->max, s->opt[OPT_GAMMA_VECTOR_R].
s-> constraint.range->max,
opt
[OPT_GAMMA_VECTOR_R].constraint.
range->max,
s->dev->sensor.red_gamma); s->dev->sensor.red_gamma);
sanei_genesys_create_gamma_table (s->dev->sensor.green_gamma_table, sanei_genesys_create_gamma_table (s->dev->sensor.green_gamma_table,
s->opt[OPT_GAMMA_VECTOR_G].size / s->opt[OPT_GAMMA_VECTOR_G].size /
sizeof (SANE_Word), sizeof (SANE_Word),
s-> s->opt[OPT_GAMMA_VECTOR_G].
opt constraint.range->max,
[OPT_GAMMA_VECTOR_G].constraint. s->opt[OPT_GAMMA_VECTOR_G].
range->max, constraint.range->max,
s->
opt
[OPT_GAMMA_VECTOR_G].constraint.
range->max,
s->dev->sensor.red_gamma); s->dev->sensor.red_gamma);
sanei_genesys_create_gamma_table (s->dev->sensor.blue_gamma_table, sanei_genesys_create_gamma_table (s->dev->sensor.blue_gamma_table,
s->opt[OPT_GAMMA_VECTOR_B].size / s->opt[OPT_GAMMA_VECTOR_B].size /
sizeof (SANE_Word), sizeof (SANE_Word),
s-> s->opt[OPT_GAMMA_VECTOR_B].
opt constraint.range->max,
[OPT_GAMMA_VECTOR_B].constraint. s->opt[OPT_GAMMA_VECTOR_B].
range->max, constraint.range->max,
s->
opt
[OPT_GAMMA_VECTOR_B].constraint.
range->max,
s->dev->sensor.red_gamma); s->dev->sensor.red_gamma);
} }
break; break;

Wyświetl plik

@ -974,6 +974,7 @@ Genesys_Model visioneer_xp200_model = {
GENESYS_FLAG_14BIT_GAMMA GENESYS_FLAG_14BIT_GAMMA
| GENESYS_FLAG_CUSTOM_GAMMA | GENESYS_FLAG_CUSTOM_GAMMA
| GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_SKIP_WARMUP
| GENESYS_FLAG_DARK_CALIBRATION
| GENESYS_FLAG_NO_CALIBRATION, | GENESYS_FLAG_NO_CALIBRATION,
GENESYS_HAS_SCAN_SW | GENESYS_HAS_PAGE_LOADED_SW | GENESYS_HAS_CALIBRATE, GENESYS_HAS_SCAN_SW | GENESYS_HAS_PAGE_LOADED_SW | GENESYS_HAS_CALIBRATE,
20, 20,

Wyświetl plik

@ -941,10 +941,12 @@ gl646_setup_registers (Genesys_Device * dev,
linecnt = (1000 * motor->ydpi) / MM_PER_INCH; linecnt = (1000 * motor->ydpi) / MM_PER_INCH;
} */ } */
/* CIS scanners read one line per color channel */ /* CIS scanners read one line per color channel
* since gray mode use 'add' we also read 3 channels even not in
* color mode */
if (dev->model->is_cis == SANE_TRUE) if (dev->model->is_cis == SANE_TRUE)
{ {
linecnt *= channels; linecnt *= 3;
} }
gl646_set_triple_reg (regs, REG_LINCNT, linecnt); gl646_set_triple_reg (regs, REG_LINCNT, linecnt);
@ -2547,7 +2549,7 @@ static SANE_Status
gl646_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg, gl646_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
SANE_Bool check_stop) SANE_Bool check_stop)
{ {
return end_scan (dev, reg, check_stop, SANE_TRUE); return end_scan (dev, reg, check_stop, SANE_FALSE);
} }
/** /**
@ -4229,6 +4231,10 @@ simple_scan (Genesys_Device * dev, Genesys_Settings settings, SANE_Bool move,
free (buffer); free (buffer);
} }
/* put back real line number in settings */
/* XXX STEF XXX */
settings.lines = lines;
/* end scan , waiting the motor to stop if needed (if moving), but without ejecting doc */ /* end scan , waiting the motor to stop if needed (if moving), but without ejecting doc */
status = end_scan (dev, dev->reg, SANE_TRUE, SANE_FALSE); status = end_scan (dev, dev->reg, SANE_TRUE, SANE_FALSE);
if (status != SANE_STATUS_GOOD) if (status != SANE_STATUS_GOOD)
@ -4497,7 +4503,7 @@ gl646_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black)
int res = get_closest_resolution (dev->model->ccd_type, 75, SANE_FALSE); int res = get_closest_resolution (dev->model->ccd_type, 75, SANE_FALSE);
unsigned char *data = NULL; unsigned char *data = NULL;
unsigned int pass, count, found, x, y; unsigned int pass, count, found, x, y;
char titre[80]; char title[80];
DBG (DBG_proc, "gl646_search_strip: start\n"); DBG (DBG_proc, "gl646_search_strip: start\n");
/* adapt to half_ccd case */ /* adapt to half_ccd case */
@ -4517,12 +4523,12 @@ gl646_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black)
settings.yres = res; settings.yres = res;
settings.tl_x = 0; settings.tl_x = 0;
settings.tl_y = 0; settings.tl_y = 0;
settings.pixels = settings.pixels = (SANE_UNFIX (dev->model->x_size) * res) / MM_PER_INCH;
(dev->sensor.sensor_pixels * res) / dev->sensor.optical_res;
if (half_ccd == SANE_TRUE) if (half_ccd == SANE_TRUE)
{ {
settings.pixels /= 2; settings.pixels /= 2;
} }
/* 15 mm at at time */ /* 15 mm at at time */
settings.lines = (15 * settings.yres) / MM_PER_INCH; /* may become a parameter from genesys_devices.c */ settings.lines = (15 * settings.yres) / MM_PER_INCH; /* may become a parameter from genesys_devices.c */
settings.depth = 8; settings.depth = 8;
@ -4551,8 +4557,8 @@ gl646_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black)
} }
if (DBG_LEVEL >= DBG_data) if (DBG_LEVEL >= DBG_data)
{ {
sprintf (titre, "search_strip%02d.pnm", pass); sprintf (title, "search_strip_%s%02d.pnm", forward ? "fwd" : "bwd", pass);
sanei_genesys_write_pnm_file (titre, data, settings.depth, 1, sanei_genesys_write_pnm_file (title, data, settings.depth, 1,
settings.pixels, settings.lines); settings.pixels, settings.lines);
} }
@ -4574,6 +4580,7 @@ gl646_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black)
count++; count++;
} }
} }
/* at end of line, if count >0, line is not fully of the desired color /* at end of line, if count >0, line is not fully of the desired color
* so we must go to next line of the buffer */ * so we must go to next line of the buffer */
if (count == 0) if (count == 0)