kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Make sure correct session data is used for saving calibration
rodzic
68f388eb6a
commit
7213738359
|
@ -2593,11 +2593,13 @@ genesys_restore_calibration(Genesys_Device * dev, Genesys_Sensor& sensor)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto session = dev->cmd_set->calculate_scan_session(dev, sensor, dev->settings);
|
||||||
|
|
||||||
/* we walk the link list of calibration cache in search for a
|
/* we walk the link list of calibration cache in search for a
|
||||||
* matching one */
|
* matching one */
|
||||||
for (auto& cache : dev->calibration_cache)
|
for (auto& cache : dev->calibration_cache)
|
||||||
{
|
{
|
||||||
if (sanei_genesys_is_compatible_calibration(dev, sensor, &cache, false)) {
|
if (sanei_genesys_is_compatible_calibration(dev, session, &cache, false)) {
|
||||||
dev->frontend = cache.frontend;
|
dev->frontend = cache.frontend;
|
||||||
/* we don't restore the gamma fields */
|
/* we don't restore the gamma fields */
|
||||||
sensor.exposure = cache.sensor.exposure;
|
sensor.exposure = cache.sensor.exposure;
|
||||||
|
@ -2629,11 +2631,13 @@ static void genesys_save_calibration(Genesys_Device* dev, const Genesys_Sensor&
|
||||||
struct timeval time;
|
struct timeval time;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
auto session = dev->cmd_set->calculate_scan_session(dev, sensor, dev->settings);
|
||||||
|
|
||||||
auto found_cache_it = dev->calibration_cache.end();
|
auto found_cache_it = dev->calibration_cache.end();
|
||||||
for (auto cache_it = dev->calibration_cache.begin(); cache_it != dev->calibration_cache.end();
|
for (auto cache_it = dev->calibration_cache.begin(); cache_it != dev->calibration_cache.end();
|
||||||
cache_it++)
|
cache_it++)
|
||||||
{
|
{
|
||||||
if (sanei_genesys_is_compatible_calibration(dev, sensor, &*cache_it, true)) {
|
if (sanei_genesys_is_compatible_calibration(dev, session, &*cache_it, true)) {
|
||||||
found_cache_it = cache_it;
|
found_cache_it = cache_it;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2652,7 +2656,7 @@ static void genesys_save_calibration(Genesys_Device* dev, const Genesys_Sensor&
|
||||||
found_cache_it->dark_average_data = dev->dark_average_data;
|
found_cache_it->dark_average_data = dev->dark_average_data;
|
||||||
found_cache_it->white_average_data = dev->white_average_data;
|
found_cache_it->white_average_data = dev->white_average_data;
|
||||||
|
|
||||||
found_cache_it->params = dev->session.params;
|
found_cache_it->params = session.params;
|
||||||
found_cache_it->frontend = dev->frontend;
|
found_cache_it->frontend = dev->frontend;
|
||||||
found_cache_it->sensor = sensor;
|
found_cache_it->sensor = sensor;
|
||||||
|
|
||||||
|
@ -5177,19 +5181,28 @@ static void get_option_value(Genesys_Scanner* s, int option, void* val)
|
||||||
s->dev->cmd_set->update_hardware_sensors(s);
|
s->dev->cmd_set->update_hardware_sensors(s);
|
||||||
*reinterpret_cast<SANE_Bool*>(val) = s->buttons[genesys_option_to_button(option)].read();
|
*reinterpret_cast<SANE_Bool*>(val) = s->buttons[genesys_option_to_button(option)].read();
|
||||||
break;
|
break;
|
||||||
case OPT_NEED_CALIBRATION_SW:
|
|
||||||
if (!sensor)
|
|
||||||
throw SaneException("Unsupported scanner mode selected");
|
|
||||||
|
|
||||||
/* scanner needs calibration for current mode unless a matching
|
case OPT_NEED_CALIBRATION_SW: {
|
||||||
* calibration cache is found */
|
if (!sensor) {
|
||||||
*reinterpret_cast<SANE_Bool*>(val) = SANE_TRUE;
|
throw SaneException("Unsupported scanner mode selected");
|
||||||
|
}
|
||||||
|
|
||||||
|
// scanner needs calibration for current mode unless a matching calibration cache is
|
||||||
|
// found
|
||||||
|
|
||||||
|
bool result = true;
|
||||||
|
|
||||||
|
auto session = s->dev->cmd_set->calculate_scan_session(s->dev, *sensor,
|
||||||
|
s->dev->settings);
|
||||||
|
|
||||||
for (auto& cache : s->dev->calibration_cache) {
|
for (auto& cache : s->dev->calibration_cache) {
|
||||||
if (sanei_genesys_is_compatible_calibration(s->dev, *sensor, &cache, false)) {
|
if (sanei_genesys_is_compatible_calibration(s->dev, session, &cache, false)) {
|
||||||
*reinterpret_cast<SANE_Bool*>(val) = SANE_FALSE;
|
*reinterpret_cast<SANE_Bool*>(val) = SANE_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*reinterpret_cast<SANE_Bool*>(val) = result;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
DBG(DBG_warn, "%s: can't get unknown option %d\n", __func__, option);
|
DBG(DBG_warn, "%s: can't get unknown option %d\n", __func__, option);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2318,16 +2318,16 @@ int sanei_genesys_get_lowest_dpi(Genesys_Device *dev)
|
||||||
* flatbed cache entries are considred too old and then expires if they
|
* flatbed cache entries are considred too old and then expires if they
|
||||||
* are older than the expiration time option, forcing calibration at least once
|
* are older than the expiration time option, forcing calibration at least once
|
||||||
* then given time. */
|
* then given time. */
|
||||||
bool sanei_genesys_is_compatible_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
bool sanei_genesys_is_compatible_calibration(Genesys_Device* dev,
|
||||||
Genesys_Calibration_Cache * cache, int for_overwrite)
|
const ScanSession& session,
|
||||||
|
const Genesys_Calibration_Cache* cache,
|
||||||
|
bool for_overwrite)
|
||||||
{
|
{
|
||||||
DBG_HELPER(dbg);
|
DBG_HELPER(dbg);
|
||||||
#ifdef HAVE_SYS_TIME_H
|
#ifdef HAVE_SYS_TIME_H
|
||||||
struct timeval time;
|
struct timeval time;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto session = dev->cmd_set->calculate_scan_session(dev, sensor, dev->settings);
|
|
||||||
|
|
||||||
bool compatible = true;
|
bool compatible = true;
|
||||||
|
|
||||||
const auto& dev_params = session.params;
|
const auto& dev_params = session.params;
|
||||||
|
|
|
@ -488,10 +488,10 @@ int sanei_genesys_get_lowest_ydpi(Genesys_Device *dev);
|
||||||
extern
|
extern
|
||||||
int sanei_genesys_get_lowest_dpi(Genesys_Device *dev);
|
int sanei_genesys_get_lowest_dpi(Genesys_Device *dev);
|
||||||
|
|
||||||
extern bool
|
bool sanei_genesys_is_compatible_calibration(Genesys_Device* dev,
|
||||||
sanei_genesys_is_compatible_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor,
|
const ScanSession& session,
|
||||||
Genesys_Calibration_Cache * cache,
|
const Genesys_Calibration_Cache* cache,
|
||||||
int for_overwrite);
|
bool for_overwrite);
|
||||||
|
|
||||||
extern void sanei_genesys_load_lut(unsigned char* lut,
|
extern void sanei_genesys_load_lut(unsigned char* lut,
|
||||||
int in_bits, int out_bits,
|
int in_bits, int out_bits,
|
||||||
|
|
Ładowanie…
Reference in New Issue