From e0e9d639fd02b783031323eb3d146e6b9810a809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Voltz?= Date: Mon, 19 Oct 2009 06:24:03 +0200 Subject: [PATCH] add soft sensor to signal that the scanner needs calibration --- backend/genesys.c | 31 ++++++++++++++++++++++++++++++- backend/genesys.h | 1 + 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/backend/genesys.c b/backend/genesys.c index 5206e7077..99ccca341 100644 --- a/backend/genesys.c +++ b/backend/genesys.c @@ -5557,6 +5557,20 @@ init_options (Genesys_Scanner * s) s->val[OPT_POWER_SW].b = 0; s->last_val[OPT_POWER_SW].b = 0; + /* calibration needed */ + s->opt[OPT_NEED_CALIBRATION_SW].name = "need-calibration"; + s->opt[OPT_NEED_CALIBRATION_SW].title = SANE_I18N ("Need calibration"); + s->opt[OPT_NEED_CALIBRATION_SW].desc = SANE_I18N ("The scanner needs calibration for the current settings"); + s->opt[OPT_NEED_CALIBRATION_SW].type = SANE_TYPE_BOOL; + s->opt[OPT_NEED_CALIBRATION_SW].unit = SANE_UNIT_NONE; + if (model->buttons & GENESYS_HAS_CALIBRATE) + s->opt[OPT_NEED_CALIBRATION_SW].cap = + SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; + else + s->opt[OPT_NEED_CALIBRATION_SW].cap = SANE_CAP_INACTIVE; + s->val[OPT_NEED_CALIBRATION_SW].b = 0; + s->last_val[OPT_NEED_CALIBRATION_SW].b = 0; + /* button group */ s->opt[OPT_BUTTON_GROUP].name = "Buttons"; s->opt[OPT_BUTTON_GROUP].title = SANE_I18N ("Buttons"); @@ -6275,6 +6289,7 @@ get_option_value (Genesys_Scanner * s, int option, void *val) SANE_Word *table; uint16_t *gamma; SANE_Status status = SANE_STATUS_GOOD; + Genesys_Calibration_Cache *cache; switch (option) { @@ -6352,7 +6367,21 @@ get_option_value (Genesys_Scanner * s, int option, void *val) *(SANE_Bool *) val = s->val[option].b; s->last_val[option].b = *(SANE_Bool *) val; break; - /* button */ + case OPT_NEED_CALIBRATION_SW: + /* scanner needs calibration for current mode unless a matching + * calibration cache is found */ + *(SANE_Bool *) val = SANE_TRUE; + for (cache = s->dev->calibration_cache; cache; cache = cache->next) + { + if (s->dev->model-> + cmd_set->is_compatible_calibration (s->dev, cache, + SANE_FALSE) == + SANE_STATUS_GOOD) + { + *(SANE_Bool *) val = SANE_FALSE; + } + } + break; default: DBG (DBG_warn, "get_option_value: can't get unknown option %d\n", option); diff --git a/backend/genesys.h b/backend/genesys.h index 4fc6846c6..844b9a120 100644 --- a/backend/genesys.h +++ b/backend/genesys.h @@ -103,6 +103,7 @@ enum Genesys_Option OPT_PAGE_LOADED_SW, OPT_OCR_SW, OPT_POWER_SW, + OPT_NEED_CALIBRATION_SW, OPT_BUTTON_GROUP, OPT_CALIBRATE, OPT_CLEAR_CALIBRATION,