kopia lustrzana https://gitlab.com/sane-project/backends
epson2: add infrared support
Adds infrared support for GT-X800 and GT-X700. Can be tested by enabling the infrared frame type in sane.h and using tiffscan (http://code.google.com/p/tiffscan/) tiffscan --mode=infrared --scanmerge-requests/1/head
rodzic
362669768d
commit
017696919b
|
@ -666,6 +666,100 @@ esci_set_scanning_parameter(SANE_Handle handle, unsigned char *buf)
|
|||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
|
||||
/* FS S */
|
||||
|
||||
SANE_Status
|
||||
esci_get_scanning_parameter(SANE_Handle handle, unsigned char *buf)
|
||||
{
|
||||
Epson_Scanner *s = (Epson_Scanner *) handle;
|
||||
SANE_Status status;
|
||||
unsigned char params[2];
|
||||
|
||||
DBG(8, "%s\n", __func__);
|
||||
|
||||
if (buf == NULL)
|
||||
return SANE_STATUS_INVAL;
|
||||
|
||||
params[0] = FS;
|
||||
params[1] = 'S';
|
||||
|
||||
status = e2_txrx(s, params, 2, buf, 64);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
return status;
|
||||
|
||||
DBG(10, "resolution of main scan : %lu\n",
|
||||
(u_long) le32atoh(&buf[0]));
|
||||
DBG(10, "resolution of sub scan : %lu\n",
|
||||
(u_long) le32atoh(&buf[4]));
|
||||
DBG(10, "offset length of main scan : %lu\n",
|
||||
(u_long) le32atoh(&buf[8]));
|
||||
DBG(10, "offset length of sub scan : %lu\n",
|
||||
(u_long) le32atoh(&buf[12]));
|
||||
DBG(10, "scanning length of main scan: %lu\n",
|
||||
(u_long) le32atoh(&buf[16]));
|
||||
DBG(10, "scanning length of sub scan : %lu\n",
|
||||
(u_long) le32atoh(&buf[20]));
|
||||
DBG(10, "scanning color : %d\n", buf[24]);
|
||||
DBG(10, "data format : %d\n", buf[25]);
|
||||
DBG(10, "option control : %d\n", buf[26]);
|
||||
DBG(10, "scanning mode : %d\n", buf[27]);
|
||||
DBG(10, "block line number : %d\n", buf[28]);
|
||||
DBG(10, "gamma correction : %d\n", buf[29]);
|
||||
DBG(10, "brightness : %d\n", buf[30]);
|
||||
DBG(10, "color correction : %d\n", buf[31]);
|
||||
DBG(10, "halftone processing : %d\n", buf[32]);
|
||||
DBG(10, "threshold : %d\n", buf[33]);
|
||||
DBG(10, "auto area segmentation : %d\n", buf[34]);
|
||||
DBG(10, "sharpness control : %d\n", buf[35]);
|
||||
DBG(10, "mirroring : %d\n", buf[36]);
|
||||
DBG(10, "film type : %d\n", buf[37]);
|
||||
DBG(10, "main lamp lighting mode : %d\n", buf[38]);
|
||||
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
|
||||
/* ESC # */
|
||||
|
||||
SANE_Status
|
||||
esci_enable_infrared(SANE_Handle handle)
|
||||
{
|
||||
Epson_Scanner *s = (Epson_Scanner *) handle;
|
||||
SANE_Status status;
|
||||
int i;
|
||||
unsigned char params[2];
|
||||
unsigned char buf[64];
|
||||
|
||||
unsigned char seq[32] = {
|
||||
0xCA, 0xFB, 0x77, 0x71, 0x20, 0x16, 0xDA, 0x09,
|
||||
0x5F, 0x57, 0x09, 0x12, 0x04, 0x83, 0x76, 0x77,
|
||||
0x3C, 0x73, 0x9C, 0xBE, 0x7A, 0xE0, 0x52, 0xE2,
|
||||
0x90, 0x0D, 0xFF, 0x9A, 0xEF, 0x4C, 0x2C, 0x81
|
||||
};
|
||||
|
||||
DBG(8, "%s\n", __func__);
|
||||
|
||||
status = esci_get_scanning_parameter(handle, buf);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
return status;
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
buf[i] = seq[i] ^ buf[i];
|
||||
}
|
||||
|
||||
params[0] = ESC;
|
||||
params[1] = '#';
|
||||
|
||||
status = e2_cmd_simple(s, params, 2);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
return status;
|
||||
|
||||
status = e2_cmd_simple(s, buf, 32);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
return status;
|
||||
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
|
||||
SANE_Status
|
||||
esci_request_command_parameter(SANE_Handle handle, unsigned char *buf)
|
||||
{
|
||||
|
|
|
@ -59,3 +59,4 @@ SANE_Status esci_feed(Epson_Scanner * s);
|
|||
SANE_Status esci_eject(Epson_Scanner * s);
|
||||
SANE_Status esci_request_extended_status(SANE_Handle handle, unsigned char **data,
|
||||
size_t * data_len);
|
||||
SANE_Status esci_enable_infrared(SANE_Handle handle);
|
||||
|
|
|
@ -1305,14 +1305,25 @@ e2_init_parameters(Epson_Scanner * s)
|
|||
|
||||
s->params.last_frame = SANE_TRUE;
|
||||
|
||||
if (mode_params[s->val[OPT_MODE].w].color) {
|
||||
s->params.format = SANE_FRAME_RGB;
|
||||
s->params.bytes_per_line =
|
||||
3 * s->params.pixels_per_line * bytes_per_pixel;
|
||||
} else {
|
||||
switch (s->val[OPT_MODE].w) {
|
||||
case MODE_BINARY:
|
||||
case MODE_GRAY:
|
||||
s->params.format = SANE_FRAME_GRAY;
|
||||
s->params.bytes_per_line =
|
||||
s->params.pixels_per_line * s->params.depth / 8;
|
||||
break;
|
||||
case MODE_COLOR:
|
||||
s->params.format = SANE_FRAME_RGB;
|
||||
s->params.bytes_per_line =
|
||||
3 * s->params.pixels_per_line * bytes_per_pixel;
|
||||
break;
|
||||
#ifdef SANE_FRAME_IR
|
||||
case MODE_INFRARED:
|
||||
s->params.format = SANE_FRAME_IR;
|
||||
s->params.bytes_per_line =
|
||||
s->params.pixels_per_line * s->params.depth / 8;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -85,13 +85,17 @@
|
|||
struct mode_param mode_params[] = {
|
||||
{0, 0x00, 0x30, 1},
|
||||
{0, 0x00, 0x30, 8},
|
||||
{1, 0x02, 0x00, 8}
|
||||
{1, 0x02, 0x00, 8},
|
||||
{0, 0x00, 0x30, 1}
|
||||
};
|
||||
|
||||
static const SANE_String_Const mode_list[] = {
|
||||
static SANE_String_Const mode_list[] = {
|
||||
SANE_I18N("Binary"),
|
||||
SANE_I18N("Gray"),
|
||||
SANE_I18N("Color"),
|
||||
#ifdef SANE_FRAME_IR
|
||||
SANE_I18N("Infrared"),
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -970,6 +974,10 @@ init_options(Epson_Scanner *s)
|
|||
s->opt[OPT_MODE].constraint.string_list = mode_list;
|
||||
s->val[OPT_MODE].w = 0; /* Binary */
|
||||
|
||||
/* disable infrared on unsupported scanners */
|
||||
if (!e2_model(s, "GT-X800") && !e2_model(s, "GT-X700"))
|
||||
mode_list[MODE_INFRARED] = NULL;
|
||||
|
||||
/* bit depth */
|
||||
s->opt[OPT_BIT_DEPTH].name = SANE_NAME_BIT_DEPTH;
|
||||
s->opt[OPT_BIT_DEPTH].title = SANE_TITLE_BIT_DEPTH;
|
||||
|
@ -2148,14 +2156,26 @@ sane_get_parameters(SANE_Handle handle, SANE_Parameters *params)
|
|||
|
||||
s->params.last_frame = SANE_TRUE;
|
||||
|
||||
if (mode_params[s->val[OPT_MODE].w].color) {
|
||||
s->params.format = SANE_FRAME_RGB;
|
||||
s->params.bytes_per_line =
|
||||
3 * s->params.pixels_per_line * bytes_per_pixel;
|
||||
} else {
|
||||
switch (s->val[OPT_MODE].w) {
|
||||
case MODE_BINARY:
|
||||
case MODE_GRAY:
|
||||
s->params.format = SANE_FRAME_GRAY;
|
||||
s->params.bytes_per_line =
|
||||
s->params.pixels_per_line * s->params.depth / 8;
|
||||
break;
|
||||
|
||||
case MODE_COLOR:
|
||||
s->params.format = SANE_FRAME_RGB;
|
||||
s->params.bytes_per_line =
|
||||
3 * s->params.pixels_per_line * bytes_per_pixel;
|
||||
break;
|
||||
#ifdef SANE_FRAME_IR
|
||||
case MODE_INFRARED:
|
||||
s->params.format = SANE_FRAME_IR;
|
||||
s->params.bytes_per_line =
|
||||
s->params.pixels_per_line * s->params.depth / 8;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (NULL != params)
|
||||
|
@ -2203,6 +2223,10 @@ sane_start(SANE_Handle handle)
|
|||
if (status != SANE_STATUS_GOOD)
|
||||
return status;
|
||||
|
||||
/* enable infrared */
|
||||
if (s->val[OPT_MODE].w == MODE_INFRARED)
|
||||
esci_enable_infrared(handle);
|
||||
|
||||
/* ESC , bay */
|
||||
if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_BAY].cap)) {
|
||||
status = esci_set_bay(s, s->val[OPT_BAY].w);
|
||||
|
@ -2337,7 +2361,6 @@ sane_start(SANE_Handle handle)
|
|||
if (status == SANE_STATUS_GOOD)
|
||||
status = e2_start_ext_scan(s);
|
||||
}
|
||||
|
||||
} else
|
||||
status = e2_start_std_scan(s);
|
||||
|
||||
|
|
|
@ -374,4 +374,8 @@ struct mode_param
|
|||
int depth;
|
||||
};
|
||||
|
||||
enum {
|
||||
MODE_BINARY, MODE_GRAY, MODE_COLOR, MODE_INFRARED
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Ładowanie…
Reference in New Issue