epson2: enable focus for all scanner types

Even with USB based scanners, we need to send the esci command to set
the focus. There is no byte in the extended scanning parameters for it.
So, move the code to a place where it is called for all cases.

Signed-off-by: Wolfram Sang <wsa@kernel.org>
merge-requests/540/head
Wolfram Sang 2020-09-26 11:32:49 +02:00
rodzic 1653b0f80c
commit a0e68f7de9
2 zmienionych plików z 22 dodań i 25 usunięć

Wyświetl plik

@ -948,8 +948,6 @@ e2_set_extended_scanning_parameters(Epson_Scanner * s)
/* ESC e */
buf[26] = extensionCtrl;
/* XXX focus */
}
/* ESC g, scanning mode (normal or high speed) */
@ -1063,29 +1061,6 @@ e2_set_scanning_parameters(Epson_Scanner * s)
* buffer to set the scan area for
* ES-9000H and GT-30000
*/
/*
* set the focus position according to the extension used:
* if the TPU is selected, then focus 2.5mm above the glass,
* otherwise focus on the glass. Scanners that don't support
* this feature, will just ignore these calls.
*/
if (s->hw->focusSupport == SANE_TRUE) {
if (s->val[OPT_FOCUS].w == 0) {
DBG(1, "setting focus to glass surface\n");
status = esci_set_focus_position(s, 0x40);
} else {
DBG(1,
"setting focus to 2.5mm above glass\n");
status = esci_set_focus_position(s, 0x59);
}
if (status != SANE_STATUS_GOOD) {
DBG(1, "setting focus failed\n");
return status;
}
}
}
/* ESC C, Set color */

Wyświetl plik

@ -2117,6 +2117,28 @@ sane_start(SANE_Handle handle)
return status;
}
/*
* set the focus position according to the extension used:
* if the TPU is selected, then focus 2.5mm above the glass,
* otherwise focus on the glass.
*/
if (s->hw->extension && s->hw->focusSupport == SANE_TRUE) {
if (s->val[OPT_FOCUS].w == 0) {
DBG(1, "setting focus to glass surface\n");
status = esci_set_focus_position(s, 0x40);
} else {
DBG(1,
"setting focus to 2.5mm above glass\n");
status = esci_set_focus_position(s, 0x59);
}
if (status != SANE_STATUS_GOOD) {
DBG(1, "setting focus failed\n");
return status;
}
}
/* set scanning parameters */
if (dev->extended_commands)
status = e2_set_extended_scanning_parameters(s);