kopia lustrzana https://gitlab.com/sane-project/backends
backend/pixma.c backend/pixma.h backend/pixma_mp150.c backend/pixma_mp810.c
backend/pixma_sane_options.c backend/pixma_sane_options.h: - added new options: original (type of original to be scanned) target (action to be perfomed as target of the scan) Both these indocators can be returned by the scanner. pixma_mp810 can definately return these (e.g. for my MP980) I have assumed that the same applies to devices in pixma_mp150.c The target used to be returned in button1/2 in bits 0 - 8. - All button options are now read and cached when any of the options are read (SANE_ACTION_GET_VALUE) or SANE_ACTION_SET_VALUE is used on option button_update. When reading an option again, the status of all options is re-read. - Added a dummy info field that is used in case info is NULL as this is a valid inputmerge-requests/1/head
rodzic
240ea344b8
commit
d9e7dc5412
|
@ -87,9 +87,12 @@
|
|||
|
||||
/* pixma_sane_options.h generated by
|
||||
* scripts/pixma_gen_options.py h < pixma.c > pixma_sane_options.h
|
||||
* *and* formatted */
|
||||
*/
|
||||
#include "pixma_sane_options.h"
|
||||
|
||||
#define BUTTON_GROUP_SIZE ( opt_target - opt_button_1 + 1 )
|
||||
#define BUTTON_GROUP_INDEX(x) ( x - opt_button_1 )
|
||||
|
||||
typedef struct pixma_sane_t
|
||||
{
|
||||
struct pixma_sane_t *next;
|
||||
|
@ -103,6 +106,7 @@ typedef struct pixma_sane_t
|
|||
SANE_Status last_read_status; /* valid if !idle && !scanning */
|
||||
|
||||
option_descriptor_t opt[opt_last];
|
||||
char button_option_is_cached[BUTTON_GROUP_SIZE];
|
||||
SANE_Range xrange, yrange;
|
||||
SANE_Word dpi_list[9]; /* up to 9600 dpi */
|
||||
SANE_String_Const mode_list[6];
|
||||
|
@ -128,6 +132,13 @@ static pixma_sane_t *first_scanner = NULL;
|
|||
static const SANE_Device **dev_list = NULL;
|
||||
static const char* conf_devices[MAX_CONF_DEVICES];
|
||||
|
||||
static void mark_all_button_options_cached ( struct pixma_sane_t * ss )
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (opt__group_5 - opt_button_1); i++ )
|
||||
ss -> button_option_is_cached[i] = 1;
|
||||
}
|
||||
|
||||
static SANE_Status config_attach_pixma(SANEI_Config * config, const char *devname)
|
||||
{
|
||||
int i;
|
||||
|
@ -272,16 +283,22 @@ update_button_state (pixma_sane_t * ss, SANE_Int * info)
|
|||
switch (ev & ~PIXMA_EV_ACTION_MASK)
|
||||
{
|
||||
case PIXMA_EV_BUTTON1:
|
||||
b1 = (ev & PIXMA_EV_ACTION_MASK) + 1;
|
||||
b1 = 1;
|
||||
break;
|
||||
case PIXMA_EV_BUTTON2:
|
||||
b2 = (ev & PIXMA_EV_ACTION_MASK) + 1;
|
||||
b2 = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (b1 != OVAL (opt_button_1).w || b2 != OVAL (opt_button_2).w)
|
||||
{
|
||||
*info |= SANE_INFO_RELOAD_OPTIONS;
|
||||
OVAL (opt_button_1).w = b1;
|
||||
OVAL (opt_button_2).w = b2;
|
||||
OVAL (opt_original).w = GET_EV_ORIGINAL(ev);
|
||||
OVAL (opt_target).w = GET_EV_TARGET(ev);
|
||||
}
|
||||
mark_all_button_options_cached(ss);
|
||||
}
|
||||
|
||||
static SANE_Bool
|
||||
|
@ -598,11 +615,17 @@ control_option (pixma_sane_t * ss, SANE_Int n,
|
|||
{
|
||||
int result, i;
|
||||
const pixma_config_t *cfg;
|
||||
SANE_Int dummy;
|
||||
|
||||
/* info may be null, better to set a dummy here then test everywhere */
|
||||
if (info == NULL)
|
||||
info = &dummy;
|
||||
|
||||
cfg = pixma_get_config (ss->s);
|
||||
|
||||
/* PDBG (pixma_dbg (4, "*control_option***** n = %u, a = %u\n", n, a)); */
|
||||
|
||||
/* first deal with options that require special treatment */
|
||||
result = SANE_STATUS_UNSUPPORTED;
|
||||
switch (n)
|
||||
{
|
||||
|
@ -638,8 +661,18 @@ control_option (pixma_sane_t * ss, SANE_Int n,
|
|||
return SANE_STATUS_INVAL;
|
||||
}
|
||||
break;
|
||||
case opt_button_1:
|
||||
case opt_button_2:
|
||||
case opt_original:
|
||||
case opt_target:
|
||||
/* poll scanner if option is not cached */
|
||||
if (! ss->button_option_is_cached[ BUTTON_GROUP_INDEX(n) ] )
|
||||
update_button_state (ss, info);
|
||||
/* mark this option as read */
|
||||
ss->button_option_is_cached[ BUTTON_GROUP_INDEX(n) ] = 0;
|
||||
}
|
||||
|
||||
/* now deal with getting and setting of options */
|
||||
switch (SOD (n).type)
|
||||
{
|
||||
case SANE_TYPE_BOOL:
|
||||
|
@ -659,6 +692,7 @@ control_option (pixma_sane_t * ss, SANE_Int n,
|
|||
if (result != SANE_STATUS_GOOD)
|
||||
return result;
|
||||
|
||||
/* deal with dependencies between options */
|
||||
switch (n)
|
||||
{
|
||||
case opt_custom_gamma:
|
||||
|
@ -1271,7 +1305,7 @@ sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only)
|
|||
SANE_Status
|
||||
sane_open (SANE_String_Const name, SANE_Handle * h)
|
||||
{
|
||||
unsigned i, nscanners;
|
||||
unsigned i, j, nscanners;
|
||||
int error = 0;
|
||||
pixma_sane_t *ss = NULL;
|
||||
const pixma_config_t *cfg;
|
||||
|
@ -1331,7 +1365,8 @@ sane_open (SANE_String_Const name, SANE_Handle * h)
|
|||
ss->rpipe = -1;
|
||||
ss->idle = SANE_TRUE;
|
||||
ss->scanning = SANE_FALSE;
|
||||
|
||||
for (j=0; j < BUTTON_GROUP_SIZE; j++)
|
||||
ss->button_option_is_cached[j] = 0;
|
||||
error = pixma_open (i, &ss->s);
|
||||
if (error < 0)
|
||||
{
|
||||
|
@ -1731,12 +1766,22 @@ type button button-update
|
|||
type int button-1
|
||||
default 0
|
||||
title Button 1
|
||||
cap soft_select soft_detect advanced
|
||||
cap soft_detect advanced
|
||||
|
||||
type int button-2
|
||||
default 0
|
||||
title Button 2
|
||||
cap soft_select soft_detect advanced
|
||||
cap soft_detect advanced
|
||||
|
||||
type int original
|
||||
default 0
|
||||
title Type of original to scan
|
||||
cap soft_detect advanced
|
||||
|
||||
type int target
|
||||
default 0
|
||||
title Target operation type
|
||||
cap soft_detect advanced
|
||||
|
||||
rem -------------------------------------------
|
||||
type group
|
||||
|
@ -1762,5 +1807,5 @@ END SANE_Option_Descriptor
|
|||
|
||||
/* pixma_sane_options.c generated by
|
||||
* scripts/pixma_gen_options.py < pixma.c > pixma_sane_options.c
|
||||
* *and* formatted */
|
||||
*/
|
||||
#include "pixma_sane_options.c"
|
||||
|
|
|
@ -152,12 +152,18 @@ typedef uint32_t uint32_t;
|
|||
#define PIXMA_CAP_EXPERIMENT (1 << 31)
|
||||
/**@}*/
|
||||
|
||||
/** \name Button events returned by pixma_wait_event() */
|
||||
/** \name Button events and related information returned by pixma_wait_event() */
|
||||
/**@{*/
|
||||
#define PIXMA_EV_NONE 0
|
||||
#define PIXMA_EV_ACTION_MASK (0xff)
|
||||
#define PIXMA_EV_BUTTON1 (1 << 8)
|
||||
#define PIXMA_EV_BUTTON2 (2 << 8)
|
||||
#define PIXMA_EV_ACTION_MASK (0xffff)
|
||||
#define PIXMA_EV_BUTTON1 (1 << 16)
|
||||
#define PIXMA_EV_BUTTON2 (2 << 16)
|
||||
#define PIXMA_EV_TARGET_MASK (0xff)
|
||||
#define PIXMA_EV_ORIGINAL_MASK (0xff00)
|
||||
|
||||
#define GET_EV_TARGET(x) (x & PIXMA_EV_TARGET_MASK)
|
||||
#define GET_EV_ORIGINAL(x) ( (x & PIXMA_EV_ORIGINAL_MASK) >> 8 )
|
||||
|
||||
/**@}*/
|
||||
/** @} end of API group */
|
||||
|
||||
|
|
|
@ -915,9 +915,9 @@ 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]; /* b/w scan */
|
||||
s->events = PIXMA_EV_BUTTON2 | buf[1] | ((buf[0] & 0xf0) << 4); /* b/w scan */
|
||||
if (buf[0] & 1)
|
||||
s->events = PIXMA_EV_BUTTON1 | buf[1]; /* color scan */
|
||||
s->events = PIXMA_EV_BUTTON1 | buf[1] | ((buf[0] & 0xf0) << 4); /* color scan */
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1040,9 +1040,9 @@ 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]; /* b/w scan */
|
||||
s->events = PIXMA_EV_BUTTON2 | buf[1] | ((buf[0] & 0xf0) << 4); /* b/w scan */
|
||||
if (buf[0] & 1)
|
||||
s->events = PIXMA_EV_BUTTON1 | buf[1]; /* color scan */
|
||||
s->events = PIXMA_EV_BUTTON1 | buf[1] | ((buf[0] & 0xf0) << 4); /* color scan */
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
/* Automatically generated from pixma_sane.c */
|
||||
static const SANE_Range constraint_gamma_table = { 0, 255, 0 };
|
||||
static const SANE_Range constraint_gamma = { SANE_FIX (0.3), SANE_FIX (5),
|
||||
SANE_FIX (0) };
|
||||
static const SANE_Range constraint_threshold = { 0, 100, 1 };
|
||||
static const SANE_Range constraint_threshold_curve = { 0, 127, 1 };
|
||||
static const SANE_Range constraint_gamma_table =
|
||||
{ 0,255,0 };
|
||||
static const SANE_Range constraint_gamma =
|
||||
{ SANE_FIX(0.3),SANE_FIX(5),SANE_FIX(0) };
|
||||
static const SANE_Range constraint_threshold =
|
||||
{ 0,100,1 };
|
||||
static const SANE_Range constraint_threshold_curve =
|
||||
{ 0,127,1 };
|
||||
|
||||
static int
|
||||
find_string_in_list (SANE_String_Const str, const SANE_String_Const * list)
|
||||
|
||||
static
|
||||
int find_string_in_list(SANE_String_Const str, const SANE_String_Const *list)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; list[i] && strcmp (str, list[i]) != 0; i++)
|
||||
{
|
||||
}
|
||||
for (i = 0; list[i] && strcmp(str, list[i]) != 0; i++) {}
|
||||
return i;
|
||||
}
|
||||
|
||||
static int
|
||||
build_option_descriptors (struct pixma_sane_t *ss)
|
||||
static
|
||||
int build_option_descriptors(struct pixma_sane_t *ss)
|
||||
{
|
||||
SANE_Option_Descriptor *sod;
|
||||
option_descriptor_t *opt;
|
||||
|
@ -116,8 +118,7 @@ build_option_descriptors (struct pixma_sane_t *ss)
|
|||
sod->name = "custom-gamma";
|
||||
sod->unit = SANE_UNIT_NONE;
|
||||
sod->size = sizeof(SANE_Word);
|
||||
sod->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_AUTOMATIC
|
||||
| SANE_CAP_INACTIVE;
|
||||
sod->cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT|SANE_CAP_AUTOMATIC|SANE_CAP_INACTIVE;
|
||||
sod->constraint_type = SANE_CONSTRAINT_NONE;
|
||||
OPT_IN_CTX[opt_custom_gamma].info = 0;
|
||||
opt->def.w = SANE_TRUE;
|
||||
|
@ -131,8 +132,7 @@ build_option_descriptors (struct pixma_sane_t *ss)
|
|||
sod->name = "gamma-table";
|
||||
sod->unit = SANE_UNIT_NONE;
|
||||
sod->size = 4096 * sizeof(SANE_Word);
|
||||
sod->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_AUTOMATIC
|
||||
| SANE_CAP_INACTIVE;
|
||||
sod->cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT|SANE_CAP_AUTOMATIC|SANE_CAP_INACTIVE;
|
||||
sod->constraint_type = SANE_CONSTRAINT_RANGE;
|
||||
sod->constraint.range = &constraint_gamma_table;
|
||||
OPT_IN_CTX[opt_gamma_table].info = 0;
|
||||
|
@ -145,8 +145,7 @@ build_option_descriptors (struct pixma_sane_t *ss)
|
|||
sod->name = "gamma";
|
||||
sod->unit = SANE_UNIT_NONE;
|
||||
sod->size = 1 * sizeof(SANE_Word);
|
||||
sod->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_AUTOMATIC
|
||||
| SANE_CAP_INACTIVE;
|
||||
sod->cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT|SANE_CAP_AUTOMATIC|SANE_CAP_INACTIVE;
|
||||
sod->constraint_type = SANE_CONSTRAINT_RANGE;
|
||||
sod->constraint.range = &constraint_gamma;
|
||||
OPT_IN_CTX[opt_gamma].info = 0;
|
||||
|
@ -245,7 +244,7 @@ build_option_descriptors (struct pixma_sane_t *ss)
|
|||
sod->name = "button-1";
|
||||
sod->unit = SANE_UNIT_NONE;
|
||||
sod->size = 1 * sizeof(SANE_Word);
|
||||
sod->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED;
|
||||
sod->cap = SANE_CAP_SOFT_DETECT|SANE_CAP_ADVANCED;
|
||||
sod->constraint_type = SANE_CONSTRAINT_NONE;
|
||||
OPT_IN_CTX[opt_button_1].info = 0;
|
||||
opt->def.w = 0;
|
||||
|
@ -259,12 +258,40 @@ build_option_descriptors (struct pixma_sane_t *ss)
|
|||
sod->name = "button-2";
|
||||
sod->unit = SANE_UNIT_NONE;
|
||||
sod->size = 1 * sizeof(SANE_Word);
|
||||
sod->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED;
|
||||
sod->cap = SANE_CAP_SOFT_DETECT|SANE_CAP_ADVANCED;
|
||||
sod->constraint_type = SANE_CONSTRAINT_NONE;
|
||||
OPT_IN_CTX[opt_button_2].info = 0;
|
||||
opt->def.w = 0;
|
||||
opt->val.w = 0;
|
||||
|
||||
opt = &(OPT_IN_CTX[opt_original]);
|
||||
sod = &opt->sod;
|
||||
sod->type = SANE_TYPE_INT;
|
||||
sod->title = SANE_I18N("Type of original to scan");
|
||||
sod->desc = sod->title;
|
||||
sod->name = "original";
|
||||
sod->unit = SANE_UNIT_NONE;
|
||||
sod->size = 1 * sizeof(SANE_Word);
|
||||
sod->cap = SANE_CAP_SOFT_DETECT|SANE_CAP_ADVANCED;
|
||||
sod->constraint_type = SANE_CONSTRAINT_NONE;
|
||||
OPT_IN_CTX[opt_original].info = 0;
|
||||
opt->def.w = 0;
|
||||
opt->val.w = 0;
|
||||
|
||||
opt = &(OPT_IN_CTX[opt_target]);
|
||||
sod = &opt->sod;
|
||||
sod->type = SANE_TYPE_INT;
|
||||
sod->title = SANE_I18N("Target operation type");
|
||||
sod->desc = sod->title;
|
||||
sod->name = "target";
|
||||
sod->unit = SANE_UNIT_NONE;
|
||||
sod->size = 1 * sizeof(SANE_Word);
|
||||
sod->cap = SANE_CAP_SOFT_DETECT|SANE_CAP_ADVANCED;
|
||||
sod->constraint_type = SANE_CONSTRAINT_NONE;
|
||||
OPT_IN_CTX[opt_target].info = 0;
|
||||
opt->def.w = 0;
|
||||
opt->val.w = 0;
|
||||
|
||||
opt = &(OPT_IN_CTX[opt__group_5]);
|
||||
sod = &opt->sod;
|
||||
sod->type = SANE_TYPE_GROUP;
|
||||
|
@ -279,8 +306,7 @@ build_option_descriptors (struct pixma_sane_t *ss)
|
|||
sod->name = "threshold";
|
||||
sod->unit = SANE_UNIT_PERCENT;
|
||||
sod->size = 1 * sizeof(SANE_Word);
|
||||
sod->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_AUTOMATIC
|
||||
| SANE_CAP_INACTIVE;
|
||||
sod->cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT|SANE_CAP_AUTOMATIC|SANE_CAP_INACTIVE;
|
||||
sod->constraint_type = SANE_CONSTRAINT_RANGE;
|
||||
sod->constraint.range = &constraint_threshold;
|
||||
OPT_IN_CTX[opt_threshold].info = 0;
|
||||
|
@ -295,8 +321,7 @@ build_option_descriptors (struct pixma_sane_t *ss)
|
|||
sod->name = "threshold-curve";
|
||||
sod->unit = SANE_UNIT_NONE;
|
||||
sod->size = 1 * sizeof(SANE_Word);
|
||||
sod->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_AUTOMATIC
|
||||
| SANE_CAP_INACTIVE;
|
||||
sod->cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT|SANE_CAP_AUTOMATIC|SANE_CAP_INACTIVE;
|
||||
sod->constraint_type = SANE_CONSTRAINT_RANGE;
|
||||
sod->constraint.range = &constraint_threshold_curve;
|
||||
OPT_IN_CTX[opt_threshold_curve].info = 0;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
/* Automatically generated from pixma_sane.c */
|
||||
|
||||
typedef union
|
||||
{
|
||||
typedef union {
|
||||
SANE_Word w;
|
||||
SANE_Int i;
|
||||
SANE_Bool b;
|
||||
|
@ -10,8 +9,7 @@ typedef union
|
|||
void *ptr;
|
||||
} option_value_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
opt_opt_num_opts,
|
||||
opt__group_1,
|
||||
opt_resolution,
|
||||
|
@ -31,18 +29,22 @@ typedef enum
|
|||
opt_button_update,
|
||||
opt_button_1,
|
||||
opt_button_2,
|
||||
opt_original,
|
||||
opt_target,
|
||||
opt__group_5,
|
||||
opt_threshold,
|
||||
opt_threshold_curve,
|
||||
opt_last
|
||||
} option_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
typedef struct {
|
||||
SANE_Option_Descriptor sod;
|
||||
option_value_t val,def;
|
||||
SANE_Word info;
|
||||
} option_descriptor_t;
|
||||
|
||||
|
||||
struct pixma_sane_t;
|
||||
static int build_option_descriptors(struct pixma_sane_t *ss);
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue