mirror of
https://github.com/openharmony/third_party_sane-airscan.git
synced 2026-07-01 21:14:00 -04:00
Added ID_SCANINTENT_UNSET value for the 'sane-intent'
If ID_SCANINTENT_UNSET is selected, the intent is not sent to the device. This is compatible with the previous version of the driver. This compatibility is important because, sooner or later, we will encounter a device that supports some intents but fails to scan when one of them is actually selected. Having an explicit unset option provides users with a reasonable fallback. ID_SCANINTENT_UNSET is the default value for the 'sane-intent' option. It helps avoid introducing unexpected changes in scanning quality for users who have been using sane-airscan for some time.
This commit is contained in:
+10
-10
@@ -140,12 +140,14 @@ static ID_SCANINTENT
|
||||
devopt_choose_scanintent (devopt *opt, ID_SCANINTENT wanted)
|
||||
{
|
||||
devcaps_source *src = opt->caps.src[opt->src];
|
||||
unsigned int scanintent = src->scanintents;
|
||||
unsigned int scanintents = src->scanintents;
|
||||
|
||||
scanintents |= 1 << ID_SCANINTENT_UNSET; /* Always implicitly supported */
|
||||
|
||||
/* Prefer wanted mode if possible */
|
||||
if (wanted != ID_SCANINTENT_UNKNOWN) {
|
||||
while (wanted < NUM_ID_SCANINTENT) {
|
||||
if ((scanintent & (1 << wanted)) != 0) {
|
||||
if ((scanintents & (1 << wanted)) != 0) {
|
||||
return wanted;
|
||||
}
|
||||
wanted ++;
|
||||
@@ -155,11 +157,12 @@ devopt_choose_scanintent (devopt *opt, ID_SCANINTENT wanted)
|
||||
/* Nothing found in a previous step. Just choose the first mode
|
||||
* supported by the scanner */
|
||||
wanted = (ID_SCANINTENT) 0;
|
||||
while ((scanintent & (1 << wanted)) == 0 && wanted < NUM_ID_SCANINTENT) {
|
||||
while ((scanintents & (1 << wanted)) == 0 && wanted < NUM_ID_SCANINTENT) {
|
||||
wanted ++;
|
||||
}
|
||||
|
||||
if (wanted >= NUM_ID_SCANINTENT) {
|
||||
wanted = ID_SCANINTENT_UNKNOWN;
|
||||
wanted = ID_SCANINTENT_UNSET;
|
||||
}
|
||||
|
||||
return wanted;
|
||||
@@ -226,6 +229,7 @@ devopt_rebuild_opt_desc (devopt *opt)
|
||||
}
|
||||
}
|
||||
|
||||
scanintents |= 1 << ID_SCANINTENT_UNSET; /* Always implicitly supported */
|
||||
for (i = 0; i < NUM_ID_SCANINTENT; i ++) {
|
||||
if ((scanintents & (1 << i)) != 0) {
|
||||
opt->sane_scanintents =
|
||||
@@ -689,7 +693,7 @@ devopt_set_defaults (devopt *opt)
|
||||
|
||||
opt->colormode_emul = devopt_choose_colormode(opt, ID_COLORMODE_UNKNOWN);
|
||||
opt->colormode_real = devopt_real_colormode(opt->colormode_emul, src);
|
||||
opt->scanintent = devopt_choose_scanintent(opt, ID_SCANINTENT_UNKNOWN);
|
||||
opt->scanintent = ID_SCANINTENT_UNSET;
|
||||
opt->resolution = devopt_choose_resolution(opt, CONFIG_DEFAULT_RESOLUTION);
|
||||
|
||||
opt->tl_x = 0;
|
||||
@@ -815,11 +819,7 @@ devopt_get_option (devopt *opt, SANE_Int option, void *value)
|
||||
break;
|
||||
|
||||
case OPT_SCAN_INTENT:
|
||||
if (opt->scanintent == ID_SCANINTENT_UNKNOWN) {
|
||||
strcpy(value, "");
|
||||
} else {
|
||||
strcpy(value, id_scanintent_sane_name(opt->scanintent));
|
||||
}
|
||||
strcpy(value, id_scanintent_sane_name(opt->scanintent));
|
||||
break;
|
||||
|
||||
case OPT_SCAN_SOURCE:
|
||||
|
||||
+1
-1
@@ -793,13 +793,13 @@ escl_scan_query (const proto_ctx *ctx)
|
||||
}
|
||||
|
||||
switch (params->scanintent) {
|
||||
case ID_SCANINTENT_UNSET: break;
|
||||
case ID_SCANINTENT_DOCUMENT: scanintent = "Document"; break;
|
||||
case ID_SCANINTENT_TEXTANDGRAPHIC: scanintent = "TextAndGraphic"; break;
|
||||
case ID_SCANINTENT_PHOTO: scanintent = "Photo"; break;
|
||||
case ID_SCANINTENT_PREVIEW: scanintent = "Preview"; break;
|
||||
case ID_SCANINTENT_OBJECT: scanintent = "Object"; break;
|
||||
case ID_SCANINTENT_BUSINESSCARD: scanintent = "BusinessCard"; break;
|
||||
case ID_SCANINTENT_UNKNOWN: break;
|
||||
|
||||
default:
|
||||
log_internal_error(ctx->log);
|
||||
|
||||
@@ -182,6 +182,7 @@ id_format_short_name (ID_FORMAT id)
|
||||
* SANE name mapping
|
||||
*/
|
||||
static id_name_table id_scanintent_sane_name_table[] = {
|
||||
{ID_SCANINTENT_UNSET, "*unset*"},
|
||||
{ID_SCANINTENT_AUTO, "Auto"},
|
||||
{ID_SCANINTENT_DOCUMENT, "Document"},
|
||||
{ID_SCANINTENT_TEXTANDGRAPHIC, "Text and Graphic"},
|
||||
|
||||
+1
-1
@@ -826,12 +826,12 @@ wsd_scan_query (const proto_ctx *ctx)
|
||||
}
|
||||
|
||||
switch (params->scanintent) {
|
||||
case ID_SCANINTENT_UNSET: break;
|
||||
case ID_SCANINTENT_AUTO: contenttype = "Auto"; break;
|
||||
case ID_SCANINTENT_DOCUMENT: contenttype = "Text"; break;
|
||||
case ID_SCANINTENT_PHOTO: contenttype = "Photo"; break;
|
||||
case ID_SCANINTENT_HALFTONE: contenttype = "Halftone"; break;
|
||||
case ID_SCANINTENT_TEXTANDGRAPHIC: contenttype = "Mixed"; break;
|
||||
case ID_SCANINTENT_UNKNOWN: break;
|
||||
|
||||
default:
|
||||
log_internal_error(ctx->log);
|
||||
|
||||
@@ -811,6 +811,7 @@ id_format_short_name (ID_FORMAT id);
|
||||
*/
|
||||
typedef enum {
|
||||
ID_SCANINTENT_UNKNOWN = -1,
|
||||
ID_SCANINTENT_UNSET, /* Intent is not set */
|
||||
ID_SCANINTENT_AUTO, /* WSD: Auto */
|
||||
ID_SCANINTENT_DOCUMENT, /* eSCL: Docoment, WSD: Text */
|
||||
ID_SCANINTENT_TEXTANDGRAPHIC, /* eSCL: TextAndGraphic, WSD: Mixed */
|
||||
|
||||
Reference in New Issue
Block a user