kopia lustrzana https://gitlab.com/sane-project/backends
add a 10 minutes expiration time for GL646 CCD scanners' calibration cache
rodzic
4a5604412a
commit
12594427d9
|
@ -3335,6 +3335,9 @@ genesys_save_calibration (Genesys_Device * dev)
|
|||
SANE_Status status = SANE_STATUS_UNSUPPORTED;
|
||||
Genesys_Calibration_Cache *cache = NULL;
|
||||
uint8_t *tmp;
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
struct timeval time;
|
||||
#endif
|
||||
|
||||
DBG (DBG_proc, "genesys_save_calibration\n");
|
||||
|
||||
|
@ -3414,6 +3417,10 @@ genesys_save_calibration (Genesys_Device * dev)
|
|||
cache->average_size);
|
||||
memcpy (cache->white_average_data, dev->white_average_data,
|
||||
cache->average_size);
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
gettimeofday(&time,NULL);
|
||||
cache->last_calibration = time.tv_sec;
|
||||
#endif
|
||||
|
||||
DBG (DBG_proc, "genesys_save_calibration: completed\n");
|
||||
return SANE_STATUS_GOOD;
|
||||
|
|
|
@ -2786,7 +2786,8 @@ gl646_search_start_position (Genesys_Device * dev)
|
|||
settings.exposure_time = 0;
|
||||
|
||||
/* scan the desired area */
|
||||
status = simple_scan (dev, settings, SANE_TRUE, SANE_TRUE, SANE_FALSE, &data);
|
||||
status =
|
||||
simple_scan (dev, settings, SANE_TRUE, SANE_TRUE, SANE_FALSE, &data);
|
||||
|
||||
/* process data if scan is OK */
|
||||
if (status == SANE_STATUS_GOOD)
|
||||
|
@ -2898,7 +2899,8 @@ gl646_init_regs_for_shading (Genesys_Device * dev)
|
|||
settings.yres = dev->sensor.optical_res / half_ccd;
|
||||
settings.tl_x = 0;
|
||||
settings.tl_y = 0;
|
||||
settings.pixels = (dev->sensor.sensor_pixels * settings.xres) / dev->sensor.optical_res;
|
||||
settings.pixels =
|
||||
(dev->sensor.sensor_pixels * settings.xres) / dev->sensor.optical_res;
|
||||
settings.lines = dev->model->shading_lines * (3 - half_ccd);
|
||||
settings.depth = 16;
|
||||
settings.color_filter = dev->settings.color_filter;
|
||||
|
@ -3383,7 +3385,9 @@ gl646_offset_calibration (Genesys_Device * dev)
|
|||
dev->frontend.offset[0] = bottom;
|
||||
dev->frontend.offset[1] = bottom;
|
||||
dev->frontend.offset[2] = bottom;
|
||||
status = simple_scan (dev, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE, &first_line);
|
||||
status =
|
||||
simple_scan (dev, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE,
|
||||
&first_line);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
|
@ -3409,7 +3413,9 @@ gl646_offset_calibration (Genesys_Device * dev)
|
|||
dev->frontend.offset[0] = top;
|
||||
dev->frontend.offset[1] = top;
|
||||
dev->frontend.offset[2] = top;
|
||||
status = simple_scan (dev, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE, &second_line);
|
||||
status =
|
||||
simple_scan (dev, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE,
|
||||
&second_line);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
|
@ -3440,7 +3446,8 @@ gl646_offset_calibration (Genesys_Device * dev)
|
|||
|
||||
/* scan with no move */
|
||||
status =
|
||||
simple_scan (dev, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE, &second_line);
|
||||
simple_scan (dev, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE,
|
||||
&second_line);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
|
@ -3479,7 +3486,8 @@ gl646_offset_calibration (Genesys_Device * dev)
|
|||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
status =
|
||||
simple_scan (dev, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE, &second_line);
|
||||
simple_scan (dev, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE,
|
||||
&second_line);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
|
@ -3579,7 +3587,8 @@ gl646_coarse_gain_calibration (Genesys_Device * dev, int dpi)
|
|||
|| (average[2] < dev->sensor.gain_white_ref)) && (pass < 30))
|
||||
{
|
||||
/* scan with no move */
|
||||
status = simple_scan (dev, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE,&line);
|
||||
status =
|
||||
simple_scan (dev, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE, &line);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
|
@ -4234,7 +4243,8 @@ simple_scan (Genesys_Device * dev, Genesys_Settings settings, SANE_Bool move,
|
|||
if (buffer == NULL)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
"simple_scan: failed to allocate %d bytes of memory\n", settings.pixels * 3);
|
||||
"simple_scan: failed to allocate %d bytes of memory\n",
|
||||
settings.pixels * 3);
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
|
||||
|
@ -4247,11 +4257,15 @@ simple_scan (Genesys_Device * dev, Genesys_Settings settings, SANE_Bool move,
|
|||
for (x = 0; x < settings.pixels; x++)
|
||||
{
|
||||
buffer[x * 3] = (*data)[y * settings.pixels * 3 + x];
|
||||
buffer[x * 3 + 1] = (*data)[y * settings.pixels * 3 + settings.pixels + x];
|
||||
buffer[x * 3 + 2] = (*data)[y * settings.pixels * 3 + 2 * settings.pixels + x];
|
||||
buffer[x * 3 + 1] =
|
||||
(*data)[y * settings.pixels * 3 + settings.pixels + x];
|
||||
buffer[x * 3 + 2] =
|
||||
(*data)[y * settings.pixels * 3 + 2 * settings.pixels +
|
||||
x];
|
||||
}
|
||||
/* copy line back */
|
||||
memcpy ((*data) + settings.pixels * 3 * y, buffer, settings.pixels * 3);
|
||||
memcpy ((*data) + settings.pixels * 3 * y, buffer,
|
||||
settings.pixels * 3);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -4262,14 +4276,24 @@ simple_scan (Genesys_Device * dev, Genesys_Settings settings, SANE_Bool move,
|
|||
for (x = 0; x < settings.pixels; x++)
|
||||
{
|
||||
buffer[x * 6] = (*data)[y * settings.pixels * 6 + x * 2];
|
||||
buffer[x * 6 + 1] = (*data)[y * settings.pixels * 6 + x * 2 + 1];
|
||||
buffer[x * 6 + 2] = (*data)[y * settings.pixels * 6 + 2 * settings.pixels + x * 2 ];
|
||||
buffer[x * 6 + 3] = (*data)[y * settings.pixels * 6 + 2 * settings.pixels + x * 2 + 1];
|
||||
buffer[x * 6 + 4] = (*data)[y * settings.pixels * 6 + 4 * settings.pixels + x * 2 ];
|
||||
buffer[x * 6 + 5] = (*data)[y * settings.pixels * 6 + 4 * settings.pixels + x * 2 + 1];
|
||||
buffer[x * 6 + 1] =
|
||||
(*data)[y * settings.pixels * 6 + x * 2 + 1];
|
||||
buffer[x * 6 + 2] =
|
||||
(*data)[y * settings.pixels * 6 + 2 * settings.pixels +
|
||||
x * 2];
|
||||
buffer[x * 6 + 3] =
|
||||
(*data)[y * settings.pixels * 6 + 2 * settings.pixels +
|
||||
x * 2 + 1];
|
||||
buffer[x * 6 + 4] =
|
||||
(*data)[y * settings.pixels * 6 + 4 * settings.pixels +
|
||||
x * 2];
|
||||
buffer[x * 6 + 5] =
|
||||
(*data)[y * settings.pixels * 6 + 4 * settings.pixels +
|
||||
x * 2 + 1];
|
||||
}
|
||||
/* copy line back */
|
||||
memcpy ((*data) + settings.pixels * 6 * y, buffer, settings.pixels * 6);
|
||||
memcpy ((*data) + settings.pixels * 6 * y, buffer,
|
||||
settings.pixels * 6);
|
||||
}
|
||||
}
|
||||
free (buffer);
|
||||
|
@ -4492,6 +4516,10 @@ gl646_is_compatible_calibration (Genesys_Device * dev,
|
|||
Genesys_Calibration_Cache * cache,
|
||||
int for_overwrite)
|
||||
{
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
struct timeval time;
|
||||
#endif
|
||||
|
||||
DBG (DBG_proc,
|
||||
"gl646_is_compatible_calibration: start (for_overwrite=%d)\n",
|
||||
for_overwrite);
|
||||
|
@ -4522,6 +4550,18 @@ gl646_is_compatible_calibration (Genesys_Device * dev,
|
|||
return SANE_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/* a cache entry expires after 10 minutes for non CIS scanners */
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
gettimeofday (&time, NULL);
|
||||
if ((time.tv_sec - cache->last_calibration > 10 * 60)
|
||||
&& (dev->model->is_cis == SANE_FALSE))
|
||||
{
|
||||
DBG (DBG_proc,
|
||||
"gl646_is_compatible_calibration: expired entry, non compatible cache\n");
|
||||
return SANE_STATUS_UNSUPPORTED;
|
||||
}
|
||||
#endif
|
||||
|
||||
DBG (DBG_proc,
|
||||
"gl646_is_compatible_calibration: completed, cache compatible\n");
|
||||
return SANE_STATUS_GOOD;
|
||||
|
@ -4588,7 +4628,8 @@ gl646_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black)
|
|||
while (pass < 20 && !found)
|
||||
{
|
||||
/* scan a full width strip */
|
||||
status = simple_scan (dev, settings, SANE_TRUE, forward, SANE_FALSE, &data);
|
||||
status =
|
||||
simple_scan (dev, settings, SANE_TRUE, forward, SANE_FALSE, &data);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG (DBG_error, "gl646_search_strip: simple_scan failed\n");
|
||||
|
|
Ładowanie…
Reference in New Issue