pixma: add new button options

some scanners return more options from push-button:
document-type, adf-status and adf-orientation
merge-requests/244/head
Rolf Bensch 2020-07-11 00:28:39 +02:00
rodzic b8cf6b4b49
commit 1da5ae889a
5 zmienionych plików z 104 dodań i 22 usunięć

Wyświetl plik

@ -92,7 +92,7 @@
*/
#include "pixma_sane_options.h"
#define BUTTON_GROUP_SIZE ( opt_scan_resolution - opt_button_1 + 1 )
#define BUTTON_GROUP_SIZE ( opt_adf_orientation - opt_button_1 + 1 )
#define BUTTON_GROUP_INDEX(x) ( x - opt_button_1 )
typedef struct pixma_sane_t
@ -318,6 +318,9 @@ update_button_state (pixma_sane_t * ss, SANE_Int * info)
OVAL (opt_original).w = GET_EV_ORIGINAL(ev);
OVAL (opt_target).w = GET_EV_TARGET(ev);
OVAL (opt_scan_resolution).w = GET_EV_DPI(ev);
OVAL (opt_document_type).w = GET_EV_DOC(ev);
OVAL (opt_adf_status).w = GET_EV_STAT(ev);
OVAL (opt_adf_orientation).w = GET_EV_ORIENT(ev);
}
mark_all_button_options_cached(ss);
}
@ -749,6 +752,9 @@ control_option (pixma_sane_t * ss, SANE_Int n,
case opt_original:
case opt_target:
case opt_scan_resolution:
case opt_document_type:
case opt_adf_status:
case opt_adf_orientation:
/* poll scanner if option is not cached */
if (! ss->button_option_is_cached[ BUTTON_GROUP_INDEX(n) ] )
update_button_state (ss, info);
@ -2212,6 +2218,21 @@ type int scan-resolution
title Scan resolution
cap soft_detect advanced
type int document-type
default 0
title Document type
cap soft_detect advanced
type int adf-status
default 0
title ADF status
cap soft_detect advanced
type int adf-orientation
default 0
title ADF orientation
cap soft_detect advanced
rem -------------------------------------------
type group
title Extras

Wyświetl plik

@ -171,13 +171,19 @@ typedef uint32_t uint32_t;
#define PIXMA_EV_ACTION_MASK (0xffffff)
#define PIXMA_EV_BUTTON1 (1 << 24)
#define PIXMA_EV_BUTTON2 (2 << 24)
#define PIXMA_EV_TARGET_MASK (0xff)
#define PIXMA_EV_ORIGINAL_MASK (0xff00)
#define PIXMA_EV_DPI_MASK (0xff0000)
#define PIXMA_EV_TARGET_MASK (0x0f)
#define PIXMA_EV_ORIGINAL_MASK (0x0f00)
#define PIXMA_EV_DPI_MASK (0x0f0000)
#define PIXMA_EV_DOC_MASK (0xf000)
#define PIXMA_EV_STAT_MASK (0xf00000)
#define PIXMA_EV_ORIENT_MASK (0xf0)
#define GET_EV_TARGET(x) (x & PIXMA_EV_TARGET_MASK)
#define GET_EV_ORIGINAL(x) ( (x & PIXMA_EV_ORIGINAL_MASK) >> 8 )
#define GET_EV_DPI(x) ( (x & PIXMA_EV_DPI_MASK) >> 16 )
#define GET_EV_DOC(x) ( (x & PIXMA_EV_DOC_MASK) >> 12 )
#define GET_EV_STAT(x) ( (x & PIXMA_EV_STAT_MASK) >> 20 )
#define GET_EV_ORIENT(x) ( (x & PIXMA_EV_ORIENT_MASK) >> 4 )
/**@}*/
/** @} end of API group */

Wyświetl plik

@ -923,18 +923,26 @@ handle_interrupt (pixma_t * s, int timeout)
* target = format; original = size; scan-resolution = dpi */
{
if (buf[7] & 1)
s->events = PIXMA_EV_BUTTON1 | buf[11] | buf[10]<<8 | buf[12]<<16; /* color scan */
{
/* color scan */
s->events = PIXMA_EV_BUTTON1 | (buf[11] & 0x0f) | (buf[10] & 0x0f) << 8
| (buf[12] & 0x0f) << 16;
}
if (buf[7] & 2)
s->events = PIXMA_EV_BUTTON2 | buf[11] | buf[10]<<8 | buf[12]<<16; /* b/w scan */
{
/* b/w scan */
s->events = PIXMA_EV_BUTTON2 | (buf[11] & 0x0f) | (buf[10] & 0x0f) << 8
| (buf[12] & 0x0f) << 16;
}
/* some scanners provide additional information:
* document type in buf[6] 01=Document; 02=Photo; 03=Auto Scan
* ADF orientation in buf[16] 01=Portrait; 02=Landscape
* high nibble of target = ADF orientation
* high nibble of original = document type */
* ADF status in buf[8] 01 = ADF empty; 02 = ADF filled
* ADF orientation in buf[16] 01=Portrait; 02=Landscape */
if (s->cfg->pid == TR4500_PID)
{
s->events |= (buf[6] & 0x0f) << 12;
s->events |= (buf[8] & 0x0f) << 20;
s->events |= (buf[16] & 0x0f) << 4;
}
}
@ -944,10 +952,16 @@ handle_interrupt (pixma_t * s, int timeout)
* target in buf[0x13] 01=copy; 02=auto; 03=send; 05=start PDF; 06=finish PDF
* "Finish PDF" is Button-2, all others are Button-1 */
{
if (buf[0x13] == 0x06)
s->events = PIXMA_EV_BUTTON2 | buf[0x13]; /* button 2 = cancel / end scan */
else if (buf[0x13])
s->events = PIXMA_EV_BUTTON1 | buf[0x13]; /* button 1 = start scan */
if (buf[0x13] == 0x06)
{
/* button 2 = cancel / end scan */
s->events = PIXMA_EV_BUTTON2 | (buf[0x13] & 0x0f);
}
else if (buf[0x13])
{
/* button 1 = start scan */
s->events = PIXMA_EV_BUTTON1 | (buf[0x13] & 0x0f);
}
}
else
/* button no. in buf[0]
@ -963,9 +977,15 @@ handle_interrupt (pixma_t * s, int timeout)
if (buf[9] & 2)
query_status (s);
if (buf[0] & 2)
s->events = PIXMA_EV_BUTTON2 | buf[1] | ((buf[0] & 0xf0) << 4); /* b/w scan */
{
/* b/w scan */
s->events = PIXMA_EV_BUTTON2 | (buf[1] & 0x0f) | (buf[0] & 0xf0) << 4;
}
if (buf[0] & 1)
s->events = PIXMA_EV_BUTTON1 | buf[1] | ((buf[0] & 0xf0) << 4); /* color scan */
{
/* color scan */
s->events = PIXMA_EV_BUTTON1 | (buf[1] & 0x0f) | ((buf[0] & 0xf0) << 4);
}
}
return 1;
}

Wyświetl plik

@ -1172,9 +1172,17 @@ static int handle_interrupt (pixma_t * s, int timeout)
* target = format; original = size; scan-resolution = dpi */
{
if (buf[7] & 1)
s->events = PIXMA_EV_BUTTON1 | buf[11] | buf[10]<<8 | buf[12]<<16; /* color scan */
{
/* color scan */
s->events = PIXMA_EV_BUTTON1 | (buf[11] & 0x0f) | (buf[10] & 0x0f) << 8
| (buf[12] & 0x0f) << 16;
}
if (buf[7] & 2)
s->events = PIXMA_EV_BUTTON2 | buf[11] | buf[10]<<8 | buf[12]<<16; /* b/w scan */
{
/* b/w scan */
s->events = PIXMA_EV_BUTTON2 | (buf[11] & 0x0f) | (buf[10] & 0x0f) << 8
| (buf[12] & 0x0f) << 16;
}
}
else if (s->cfg->pid == CS8800F_PID
|| s->cfg->pid == CS9000F_PID
@ -1185,9 +1193,15 @@ static int handle_interrupt (pixma_t * s, int timeout)
{
if ((s->cfg->pid == CS8800F_PID && buf[1] == 0x70)
|| (s->cfg->pid != CS8800F_PID && buf[1] == 0x50))
s->events = PIXMA_EV_BUTTON2 | buf[1] >> 4; /* button 2 = cancel / end scan */
{
/* button 2 = cancel / end scan */
s->events = PIXMA_EV_BUTTON2 | buf[1] >> 4;
}
else
s->events = PIXMA_EV_BUTTON1 | buf[1] >> 4; /* button 1 = start scan */
{
/* button 1 = start scan */
s->events = PIXMA_EV_BUTTON1 | buf[1] >> 4;
}
}
else
/* button no. in buf[0]
@ -1204,9 +1218,15 @@ static int handle_interrupt (pixma_t * s, int timeout)
query_status (s);
if (buf[0] & 2)
s->events = PIXMA_EV_BUTTON2 | buf[1] | ((buf[0] & 0xf0) << 4); /* b/w scan */
{
/* b/w scan */
s->events = PIXMA_EV_BUTTON2 | (buf[1] & 0x0f) | (buf[0] & 0xf0) << 4;
}
if (buf[0] & 1)
s->events = PIXMA_EV_BUTTON1 | buf[1] | ((buf[0] & 0xf0) << 4); /* color scan */
{
/* color scan */
s->events = PIXMA_EV_BUTTON1 | (buf[1] & 0x0f) | (buf[0] & 0xf0) << 4;
}
}
return 1;
}

Wyświetl plik

@ -240,10 +240,25 @@ or 1 = JPEG, 2 = TIFF, 3 = PDF, 4 = Compact PDF. For some scanners this value
is equivalent to the number of the pressed button. Not all scanners can provide
this data.
.TP
.I scan-resolution
.I scan\-resolution
(read only) Returns the resolution of the scan operation if the scanner
provides that data. Known values: 1 = 75 dpi, 2 = 150 dpi, 3 = 300 dpi,
4 = 600 dpi. Not all scanners can provide this data.
.TP
.I document\-type
(read only) Returns the type of the scanned document if the scanner provides
that data. Known values: 1 = Document, 2 = Photo, 3 = Auto scan. Not all scanners
can provide this data.
.TP
.I adf\-status
(read only) Returns the status of the document feeder if the scanner provides
that data. Known values: 1 = ADF empty, 2 = ADF filled. Not all scanners can
provide this data.
.TP
.I adf\-orientation
(read only) Returns the scan orientation of the medium scanned from ADF if the
scanner provides that data. Known values: 1 = Portrait, 2 = Landscape. Not all
scanners can provide this data.
.SH FILES
.TP
.I @LIBDIR@/libsane\-pixma.a