2001-05-03 19:34:02 +00:00
|
|
|
|
/* sane - Scanner Access Now Easy.
|
|
|
|
|
Copyright (C) 2001 St<EFBFBD>phane Voltz <svoltz@wanadoo.fr>
|
|
|
|
|
This file is part of the SANE package.
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
|
|
|
|
published by the Free Software Foundation; either version 2 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but
|
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
|
|
|
|
MA 02111-1307, USA.
|
|
|
|
|
|
|
|
|
|
As a special exception, the authors of SANE give permission for
|
|
|
|
|
additional uses of the libraries contained in this release of SANE.
|
|
|
|
|
|
|
|
|
|
The exception is that, if you link a SANE library with other files
|
|
|
|
|
to produce an executable, this does not by itself cause the
|
|
|
|
|
resulting executable to be covered by the GNU General Public
|
|
|
|
|
License. Your use of that executable is in no way restricted on
|
|
|
|
|
account of linking the SANE library code into it.
|
|
|
|
|
|
|
|
|
|
This exception does not, however, invalidate any other reasons why
|
|
|
|
|
the executable file might be covered by the GNU General Public
|
|
|
|
|
License.
|
|
|
|
|
|
|
|
|
|
If you submit changes to SANE to the maintainers to be included in
|
|
|
|
|
a subsequent release, you agree by submitting the changes that
|
|
|
|
|
those changes may be distributed with this exception intact.
|
|
|
|
|
|
|
|
|
|
If you write modifications of your own for SANE, it is your choice
|
|
|
|
|
whether to permit this exception to apply to your modifications.
|
|
|
|
|
If you do not wish that, delete this exception notice.
|
|
|
|
|
|
|
|
|
|
This file implements a SANE backend for Umax PP flatbed scanners. */
|
|
|
|
|
|
|
|
|
|
/* CREDITS:
|
|
|
|
|
Started by being a mere copy of mustek_pp
|
|
|
|
|
by Jochen Eisinger <jochen.eisinger@gmx.net>
|
|
|
|
|
then evolved in its own thing */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "../include/sane/config.h"
|
|
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <limits.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
2002-02-05 07:14:53 +00:00
|
|
|
|
#ifdef HAVE_UNISTD_H
|
2001-05-03 19:34:02 +00:00
|
|
|
|
#include <unistd.h>
|
2002-02-05 07:14:53 +00:00
|
|
|
|
#endif
|
2001-05-03 19:34:02 +00:00
|
|
|
|
#include <math.h>
|
|
|
|
|
|
2002-02-05 07:14:53 +00:00
|
|
|
|
#ifdef HAVE_SYS_TIME_H
|
2001-05-03 19:34:02 +00:00
|
|
|
|
#include <sys/time.h>
|
2002-02-05 07:14:53 +00:00
|
|
|
|
#endif
|
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
2001-05-03 19:34:02 +00:00
|
|
|
|
#include <sys/types.h>
|
2002-02-05 07:14:53 +00:00
|
|
|
|
#endif
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
#include "../include/sane/sane.h"
|
|
|
|
|
#include "../include/sane/sanei.h"
|
|
|
|
|
#include "../include/sane/saneopts.h"
|
1994-02-15 08:43:42 +00:00
|
|
|
|
#include "../include/sane/sanei_config.h"
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define BACKEND_NAME umax_pp
|
|
|
|
|
#include "../include/sane/sanei_backend.h"
|
|
|
|
|
|
2003-09-12 16:10:33 +00:00
|
|
|
|
#include "umax_pp_mid.h"
|
|
|
|
|
#include "umax_pp.h"
|
2002-01-06 16:20:45 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DMALLOC
|
|
|
|
|
#include "dmalloc.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2001-05-03 19:34:02 +00:00
|
|
|
|
#define UMAX_PP_CONFIG_FILE "umax_pp.conf"
|
|
|
|
|
|
|
|
|
|
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* DEBUG
|
|
|
|
|
* for debug output, set SANE_DEBUG_UMAX_PP to
|
|
|
|
|
* 0 for nothing
|
|
|
|
|
* 1 for errors
|
|
|
|
|
* 2 for warnings
|
|
|
|
|
* 3 for additional information
|
|
|
|
|
* 4 for debug information
|
|
|
|
|
* 5 for code flow protocol (there isn't any)
|
|
|
|
|
* 129 if you want to know which parameters are unused
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* history:
|
2003-02-09 08:26:00 +00:00
|
|
|
|
* see Changelog
|
2001-05-03 19:34:02 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2003-08-15 06:56:24 +00:00
|
|
|
|
#define UMAX_PP_BUILD 13
|
|
|
|
|
#define UMAX_PP_STATE "stable"
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
static int num_devices = 0;
|
|
|
|
|
static Umax_PP_Descriptor *devlist = NULL;
|
2001-05-16 04:52:43 +00:00
|
|
|
|
static const SANE_Device **devarray = NULL;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
static Umax_PP_Device *first_dev = NULL;
|
|
|
|
|
|
|
|
|
|
|
1994-02-15 08:43:42 +00:00
|
|
|
|
/* 2 Meg scan buffer */
|
|
|
|
|
static long int buf_size = 2048 * 1024;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
static int red_brightness = 0;
|
|
|
|
|
static int green_brightness = 0;
|
|
|
|
|
static int blue_brightness = 0;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
static int red_contrast = 0;
|
|
|
|
|
static int green_contrast = 0;
|
|
|
|
|
static int blue_contrast = 0;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const SANE_String_Const mode_list[] = {
|
2003-02-23 08:54:16 +00:00
|
|
|
|
SANE_I18N ("Lineart"), SANE_I18N ("Grayscale"), SANE_I18N ("Color"), 0
|
2001-05-03 19:34:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const SANE_Range u4_range = {
|
|
|
|
|
0, /* minimum */
|
|
|
|
|
15, /* maximum */
|
|
|
|
|
0 /* quantization */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const SANE_Range u8_range = {
|
|
|
|
|
0, /* minimum */
|
|
|
|
|
255, /* maximum */
|
|
|
|
|
0 /* quantization */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define UMAX_PP_CHANNEL_RED 0
|
|
|
|
|
#define UMAX_PP_CHANNEL_GREEN 1
|
|
|
|
|
#define UMAX_PP_CHANNEL_BLUE 2
|
|
|
|
|
#define UMAX_PP_CHANNEL_GRAY 1
|
|
|
|
|
|
|
|
|
|
#define UMAX_PP_STATE_SCANNING 2
|
|
|
|
|
#define UMAX_PP_STATE_CANCELLED 1
|
|
|
|
|
#define UMAX_PP_STATE_IDLE 0
|
|
|
|
|
|
|
|
|
|
#define UMAX_PP_MODE_LINEART 0
|
|
|
|
|
#define UMAX_PP_MODE_GRAYSCALE 1
|
|
|
|
|
#define UMAX_PP_MODE_COLOR 2
|
|
|
|
|
|
|
|
|
|
#define MM_PER_INCH 25.4
|
|
|
|
|
#define MM_TO_PIXEL(mm, res) (SANE_UNFIX(mm) * (float )res / MM_PER_INCH)
|
|
|
|
|
#define PIXEL_TO_MM(px, res) (SANE_FIX((float )(px * MM_PER_INCH / (res / 10)) / 10.0))
|
|
|
|
|
|
2003-10-09 05:27:39 +00:00
|
|
|
|
#define UMAX_PP_DEFAULT_PORT "/dev/parport0"
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
2003-02-09 08:26:00 +00:00
|
|
|
|
#define UMAX_PP_RESERVE 259200
|
1994-02-15 08:43:42 +00:00
|
|
|
|
/*
|
|
|
|
|
* devname may be either an hardware address for direct I/O (0x378 for instance)
|
|
|
|
|
* or the device name used by ppdev on linux systems (/dev/parport0 )
|
|
|
|
|
*/
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static SANE_Status
|
|
|
|
|
attach (const char *devname)
|
|
|
|
|
{
|
|
|
|
|
Umax_PP_Descriptor *dev;
|
|
|
|
|
int i;
|
|
|
|
|
SANE_Status status = SANE_STATUS_GOOD;
|
1994-02-15 08:43:42 +00:00
|
|
|
|
int ret, prt = 0, mdl;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
char model[32];
|
1994-02-15 08:43:42 +00:00
|
|
|
|
char name[64];
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
1994-02-15 08:43:42 +00:00
|
|
|
|
memset (name, 0, 64);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
1994-02-15 08:43:42 +00:00
|
|
|
|
if ((strlen (devname) < 3))
|
2001-05-03 19:34:02 +00:00
|
|
|
|
return SANE_STATUS_INVAL;
|
|
|
|
|
|
1994-02-15 08:43:42 +00:00
|
|
|
|
/* if the name begins with a slash, it's a device, else it's an addr */
|
2002-02-20 05:47:47 +00:00
|
|
|
|
if (devname != NULL)
|
1994-02-15 08:43:42 +00:00
|
|
|
|
{
|
2002-02-20 05:47:47 +00:00
|
|
|
|
if ((devname[0] == '/'))
|
|
|
|
|
{
|
|
|
|
|
strncpy (name, devname, 64);
|
|
|
|
|
}
|
1994-02-15 08:43:42 +00:00
|
|
|
|
else
|
2002-02-20 05:47:47 +00:00
|
|
|
|
{
|
|
|
|
|
if ((devname[0] == '0')
|
|
|
|
|
&& ((devname[1] == 'x') || (devname[1] == 'X')))
|
|
|
|
|
prt = strtol (devname + 2, NULL, 16);
|
|
|
|
|
else
|
|
|
|
|
prt = atoi (devname);
|
|
|
|
|
}
|
1994-02-15 08:43:42 +00:00
|
|
|
|
}
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < num_devices; i++)
|
1994-02-15 08:43:42 +00:00
|
|
|
|
{
|
|
|
|
|
if (devname[0] == '/')
|
|
|
|
|
{
|
|
|
|
|
if (strcmp (devlist[i].ppdevice, devname) == 0)
|
|
|
|
|
return SANE_STATUS_GOOD;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (strcmp (devlist[i].port, devname) == 0)
|
|
|
|
|
return SANE_STATUS_GOOD;
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
1994-02-15 08:43:42 +00:00
|
|
|
|
ret = sanei_umax_pp_attach (prt, name);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
switch (ret)
|
|
|
|
|
{
|
|
|
|
|
case UMAX1220P_OK:
|
|
|
|
|
status = SANE_STATUS_GOOD;
|
|
|
|
|
break;
|
|
|
|
|
case UMAX1220P_BUSY:
|
|
|
|
|
status = SANE_STATUS_DEVICE_BUSY;
|
|
|
|
|
break;
|
|
|
|
|
case UMAX1220P_TRANSPORT_FAILED:
|
1994-02-15 08:43:42 +00:00
|
|
|
|
DBG (1, "attach: failed to init transport layer on %s\n", devname);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
status = SANE_STATUS_IO_ERROR;
|
|
|
|
|
break;
|
|
|
|
|
case UMAX1220P_PROBE_FAILED:
|
1994-02-15 08:43:42 +00:00
|
|
|
|
DBG (1, "attach: failed to probe scanner on %s\n", devname);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
status = SANE_STATUS_IO_ERROR;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (status != SANE_STATUS_GOOD)
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "attach: couldn't attach to `%s' (%s)\n", devname,
|
|
|
|
|
sane_strstatus (status));
|
|
|
|
|
DEBUG ();
|
|
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* now look for the model */
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
ret = sanei_umax_pp_model (prt, &mdl);
|
|
|
|
|
if (ret != UMAX1220P_OK)
|
|
|
|
|
{
|
1994-02-15 08:43:42 +00:00
|
|
|
|
DBG (1, "attach: waiting for busy scanner on %s\n", devname);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
while (ret == UMAX1220P_BUSY);
|
|
|
|
|
|
|
|
|
|
if (ret != UMAX1220P_OK)
|
|
|
|
|
{
|
2002-02-20 05:47:47 +00:00
|
|
|
|
DBG (1, "attach: failed to recognize scanner model on %s\n", devname);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
return SANE_STATUS_IO_ERROR;
|
|
|
|
|
}
|
|
|
|
|
sprintf (model, "Astra %dP", mdl);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dev = malloc (sizeof (Umax_PP_Descriptor) * (num_devices + 1));
|
|
|
|
|
|
|
|
|
|
if (dev == NULL)
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "attach: not enough memory for device descriptor\n");
|
|
|
|
|
DEBUG ();
|
|
|
|
|
return SANE_STATUS_NO_MEM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memset (dev, 0, sizeof (Umax_PP_Descriptor) * (num_devices + 1));
|
|
|
|
|
|
|
|
|
|
if (num_devices > 0)
|
|
|
|
|
{
|
|
|
|
|
memcpy (dev + 1, devlist, sizeof (Umax_PP_Descriptor) * (num_devices));
|
|
|
|
|
free (devlist);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
devlist = dev;
|
|
|
|
|
num_devices++;
|
|
|
|
|
|
|
|
|
|
dev->sane.name = strdup (devname);
|
|
|
|
|
dev->sane.vendor = strdup ("UMAX");
|
|
|
|
|
dev->sane.type = "flatbed scanner";
|
|
|
|
|
|
1994-02-15 08:43:42 +00:00
|
|
|
|
if (devname[0] == '/')
|
|
|
|
|
dev->ppdevice = strdup (devname);
|
|
|
|
|
else
|
|
|
|
|
dev->port = strdup (devname);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
dev->buf_size = buf_size;
|
|
|
|
|
|
|
|
|
|
if (mdl > 610)
|
|
|
|
|
{ /* Astra 1220, 1600 and 2000 */
|
|
|
|
|
dev->max_res = 1200;
|
|
|
|
|
dev->max_h_size = 5100;
|
|
|
|
|
dev->max_v_size = 7000;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{ /* Astra 610 */
|
|
|
|
|
dev->max_res = 600;
|
|
|
|
|
dev->max_h_size = 2050;
|
|
|
|
|
dev->max_v_size = 3500;
|
|
|
|
|
}
|
|
|
|
|
dev->sane.model = strdup (model);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DBG (3, "attach: device %s attached\n", devname);
|
|
|
|
|
|
|
|
|
|
return SANE_STATUS_GOOD;
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-09 05:27:39 +00:00
|
|
|
|
/*
|
|
|
|
|
* walk a port list and try to attach to them
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static SANE_Int
|
|
|
|
|
umax_pp_try_ports (char **ports)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
int rc = SANE_STATUS_INVAL;
|
|
|
|
|
|
|
|
|
|
if (ports != NULL)
|
|
|
|
|
{
|
|
|
|
|
i = 0;
|
|
|
|
|
rc = SANE_STATUS_INVAL;
|
|
|
|
|
while (ports[i] != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (rc != SANE_STATUS_GOOD)
|
|
|
|
|
{
|
|
|
|
|
DBG (3, "umax_pp_try_ports: trying port `%s'\n", ports[i]);
|
|
|
|
|
rc = attach (ports[i]);
|
|
|
|
|
if (rc != SANE_STATUS_GOOD)
|
|
|
|
|
DBG (3, "init: couldn't attach to port `%s'\n", ports[i]);
|
|
|
|
|
else
|
|
|
|
|
DBG (3, "init: attach to port `%s' successfull\n", ports[i]);
|
|
|
|
|
}
|
|
|
|
|
free (ports[i]);
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
free (ports);
|
|
|
|
|
}
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* attempt to auto detect right parallel port
|
|
|
|
|
* if safe set to SANE_TRUE, no direct hardware access
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static SANE_Int
|
|
|
|
|
umax_pp_auto_attach (SANE_Int safe)
|
|
|
|
|
{
|
|
|
|
|
char **ports;
|
|
|
|
|
int rc = SANE_STATUS_INVAL;
|
|
|
|
|
|
|
|
|
|
/* safe tests: user parallel port devices */
|
|
|
|
|
ports = sanei_parport_find_device ();
|
|
|
|
|
if (ports != NULL)
|
|
|
|
|
rc = umax_pp_try_ports (ports);
|
|
|
|
|
|
|
|
|
|
/* try for direct hardware access */
|
|
|
|
|
if ((safe != SANE_TRUE) && (rc != SANE_STATUS_GOOD))
|
|
|
|
|
{
|
|
|
|
|
ports = sanei_parport_find_port ();
|
|
|
|
|
if (ports != NULL)
|
|
|
|
|
rc = umax_pp_try_ports (ports);
|
|
|
|
|
}
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
2003-02-09 08:26:00 +00:00
|
|
|
|
static SANE_Int
|
|
|
|
|
umax_pp_get_sync (SANE_Int dpi)
|
|
|
|
|
{
|
|
|
|
|
/* delta between color frames */
|
|
|
|
|
switch (dpi)
|
|
|
|
|
{
|
|
|
|
|
case 1200:
|
|
|
|
|
return 8;
|
|
|
|
|
case 600:
|
|
|
|
|
return 4;
|
|
|
|
|
case 300:
|
|
|
|
|
return 2;
|
|
|
|
|
case 150:
|
|
|
|
|
return 1;
|
|
|
|
|
default:
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static SANE_Status
|
|
|
|
|
init_options (Umax_PP_Device * dev)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
/* sets initial option value to zero */
|
|
|
|
|
memset (dev->opt, 0, sizeof (dev->opt));
|
|
|
|
|
memset (dev->val, 0, sizeof (dev->val));
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_OPTIONS; ++i)
|
|
|
|
|
{
|
|
|
|
|
dev->opt[i].size = sizeof (SANE_Word);
|
|
|
|
|
dev->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT;
|
|
|
|
|
}
|
|
|
|
|
|
2001-09-03 12:43:26 +00:00
|
|
|
|
dev->opt[OPT_NUM_OPTS].name = SANE_NAME_NUM_OPTIONS;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
dev->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS;
|
|
|
|
|
dev->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS;
|
|
|
|
|
dev->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT;
|
|
|
|
|
dev->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT;
|
|
|
|
|
dev->val[OPT_NUM_OPTS].w = NUM_OPTIONS;
|
|
|
|
|
|
|
|
|
|
/* "Mode" group: */
|
|
|
|
|
|
2002-10-08 20:01:11 +00:00
|
|
|
|
dev->opt[OPT_MODE_GROUP].title = SANE_TITLE_SCAN_MODE;
|
2001-09-03 12:43:26 +00:00
|
|
|
|
dev->opt[OPT_MODE_GROUP].name = "";
|
2001-05-03 19:34:02 +00:00
|
|
|
|
dev->opt[OPT_MODE_GROUP].desc = "";
|
|
|
|
|
dev->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP;
|
2002-08-15 08:32:08 +00:00
|
|
|
|
dev->opt[OPT_MODE_GROUP].size = 0;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
dev->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE;
|
|
|
|
|
|
|
|
|
|
/* scan mode */
|
|
|
|
|
dev->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE;
|
|
|
|
|
dev->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE;
|
|
|
|
|
dev->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE;
|
|
|
|
|
dev->opt[OPT_MODE].type = SANE_TYPE_STRING;
|
|
|
|
|
dev->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST;
|
|
|
|
|
dev->opt[OPT_MODE].size = 10;
|
|
|
|
|
dev->opt[OPT_MODE].constraint.string_list = mode_list;
|
|
|
|
|
dev->val[OPT_MODE].s = strdup (mode_list[1]);
|
|
|
|
|
|
|
|
|
|
/* resolution */
|
|
|
|
|
dev->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION;
|
|
|
|
|
dev->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION;
|
|
|
|
|
dev->opt[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION;
|
|
|
|
|
dev->opt[OPT_RESOLUTION].type = SANE_TYPE_FIXED;
|
|
|
|
|
dev->opt[OPT_RESOLUTION].unit = SANE_UNIT_DPI;
|
|
|
|
|
dev->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE;
|
|
|
|
|
dev->opt[OPT_RESOLUTION].constraint.range = &dev->dpi_range;
|
|
|
|
|
dev->val[OPT_RESOLUTION].w = dev->dpi_range.min;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* preview */
|
|
|
|
|
dev->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW;
|
|
|
|
|
dev->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW;
|
|
|
|
|
dev->opt[OPT_PREVIEW].desc = SANE_DESC_PREVIEW;
|
|
|
|
|
dev->opt[OPT_PREVIEW].type = SANE_TYPE_BOOL;
|
|
|
|
|
dev->opt[OPT_PREVIEW].size = sizeof (SANE_Word);
|
|
|
|
|
dev->opt[OPT_PREVIEW].unit = SANE_UNIT_NONE;
|
|
|
|
|
dev->val[OPT_PREVIEW].w = SANE_FALSE;
|
|
|
|
|
|
|
|
|
|
/* gray preview */
|
|
|
|
|
dev->opt[OPT_GRAY_PREVIEW].name = SANE_NAME_GRAY_PREVIEW;
|
|
|
|
|
dev->opt[OPT_GRAY_PREVIEW].title = SANE_TITLE_GRAY_PREVIEW;
|
|
|
|
|
dev->opt[OPT_GRAY_PREVIEW].desc = SANE_DESC_GRAY_PREVIEW;
|
|
|
|
|
dev->opt[OPT_GRAY_PREVIEW].type = SANE_TYPE_BOOL;
|
2001-09-03 12:43:26 +00:00
|
|
|
|
dev->opt[OPT_GRAY_PREVIEW].size = sizeof (SANE_Word);
|
|
|
|
|
dev->opt[OPT_GRAY_PREVIEW].unit = SANE_UNIT_NONE;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
dev->val[OPT_GRAY_PREVIEW].w = SANE_FALSE;
|
|
|
|
|
|
|
|
|
|
/* "Geometry" group: */
|
|
|
|
|
|
2002-05-30 16:13:44 +00:00
|
|
|
|
dev->opt[OPT_GEOMETRY_GROUP].title = SANE_I18N ("Geometry");
|
2001-05-03 19:34:02 +00:00
|
|
|
|
dev->opt[OPT_GEOMETRY_GROUP].desc = "";
|
2001-09-03 12:43:26 +00:00
|
|
|
|
dev->opt[OPT_GEOMETRY_GROUP].name = "";
|
2001-05-03 19:34:02 +00:00
|
|
|
|
dev->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP;
|
2002-08-15 08:32:08 +00:00
|
|
|
|
dev->opt[OPT_GEOMETRY_GROUP].size = 0;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
dev->opt[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE;
|
|
|
|
|
|
|
|
|
|
/* top-left x */
|
|
|
|
|
dev->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X;
|
|
|
|
|
dev->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X;
|
|
|
|
|
dev->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X;
|
|
|
|
|
dev->opt[OPT_TL_X].type = SANE_TYPE_INT;
|
|
|
|
|
dev->opt[OPT_TL_X].unit = SANE_UNIT_PIXEL;
|
|
|
|
|
dev->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE;
|
|
|
|
|
dev->opt[OPT_TL_X].constraint.range = &dev->x_range;
|
|
|
|
|
dev->val[OPT_TL_X].w = 0;
|
|
|
|
|
|
|
|
|
|
/* top-left y */
|
|
|
|
|
dev->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y;
|
|
|
|
|
dev->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y;
|
|
|
|
|
dev->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y;
|
|
|
|
|
dev->opt[OPT_TL_Y].type = SANE_TYPE_INT;
|
|
|
|
|
dev->opt[OPT_TL_Y].unit = SANE_UNIT_PIXEL;
|
|
|
|
|
dev->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE;
|
|
|
|
|
dev->opt[OPT_TL_Y].constraint.range = &dev->y_range;
|
|
|
|
|
dev->val[OPT_TL_Y].w = 0;
|
|
|
|
|
|
|
|
|
|
/* bottom-right x */
|
|
|
|
|
dev->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X;
|
|
|
|
|
dev->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X;
|
|
|
|
|
dev->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X;
|
|
|
|
|
dev->opt[OPT_BR_X].type = SANE_TYPE_INT;
|
|
|
|
|
dev->opt[OPT_BR_X].unit = SANE_UNIT_PIXEL;
|
|
|
|
|
dev->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE;
|
|
|
|
|
dev->opt[OPT_BR_X].constraint.range = &dev->x_range;
|
|
|
|
|
dev->val[OPT_BR_X].w = dev->x_range.max;
|
|
|
|
|
|
|
|
|
|
/* bottom-right y */
|
|
|
|
|
dev->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y;
|
|
|
|
|
dev->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y;
|
|
|
|
|
dev->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y;
|
|
|
|
|
dev->opt[OPT_BR_Y].type = SANE_TYPE_INT;
|
|
|
|
|
dev->opt[OPT_BR_Y].unit = SANE_UNIT_PIXEL;
|
|
|
|
|
dev->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE;
|
|
|
|
|
dev->opt[OPT_BR_Y].constraint.range = &dev->y_range;
|
|
|
|
|
dev->val[OPT_BR_Y].w = dev->y_range.max;
|
|
|
|
|
|
|
|
|
|
/* "Enhancement" group: */
|
|
|
|
|
|
2002-05-30 16:13:44 +00:00
|
|
|
|
dev->opt[OPT_ENHANCEMENT_GROUP].title = SANE_I18N ("Enhancement");
|
2001-05-03 19:34:02 +00:00
|
|
|
|
dev->opt[OPT_ENHANCEMENT_GROUP].desc = "";
|
2001-09-03 12:43:26 +00:00
|
|
|
|
dev->opt[OPT_ENHANCEMENT_GROUP].name = "";
|
2001-05-03 19:34:02 +00:00
|
|
|
|
dev->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP;
|
2002-08-15 08:32:08 +00:00
|
|
|
|
dev->opt[OPT_ENHANCEMENT_GROUP].size = 0;
|
2001-09-03 12:43:26 +00:00
|
|
|
|
dev->opt[OPT_ENHANCEMENT_GROUP].cap |= SANE_CAP_ADVANCED;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
dev->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE;
|
|
|
|
|
|
2001-09-03 12:43:26 +00:00
|
|
|
|
/* lamp control */
|
2002-12-02 20:15:03 +00:00
|
|
|
|
dev->opt[OPT_LAMP_CONTROL].name = "lamp-control";
|
2002-05-30 16:13:44 +00:00
|
|
|
|
dev->opt[OPT_LAMP_CONTROL].title = SANE_I18N ("Lamp on");
|
|
|
|
|
dev->opt[OPT_LAMP_CONTROL].desc = SANE_I18N ("Sets lamp on/off");
|
2001-05-03 19:34:02 +00:00
|
|
|
|
dev->opt[OPT_LAMP_CONTROL].type = SANE_TYPE_BOOL;
|
|
|
|
|
dev->opt[OPT_LAMP_CONTROL].size = sizeof (SANE_Word);
|
|
|
|
|
dev->opt[OPT_LAMP_CONTROL].unit = SANE_UNIT_NONE;
|
|
|
|
|
dev->val[OPT_LAMP_CONTROL].w = SANE_TRUE;
|
2001-09-03 12:43:26 +00:00
|
|
|
|
dev->opt[OPT_LAMP_CONTROL].cap |= SANE_CAP_ADVANCED;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
2002-10-31 06:53:52 +00:00
|
|
|
|
/* UTA control */
|
2002-12-02 20:15:03 +00:00
|
|
|
|
dev->opt[OPT_UTA_CONTROL].name = "UTA-control";
|
2002-10-31 06:53:52 +00:00
|
|
|
|
dev->opt[OPT_UTA_CONTROL].title = SANE_I18N ("UTA on");
|
|
|
|
|
dev->opt[OPT_UTA_CONTROL].desc = SANE_I18N ("Sets UTA on/off");
|
|
|
|
|
dev->opt[OPT_UTA_CONTROL].type = SANE_TYPE_BOOL;
|
|
|
|
|
dev->opt[OPT_UTA_CONTROL].size = sizeof (SANE_Word);
|
|
|
|
|
dev->opt[OPT_UTA_CONTROL].unit = SANE_UNIT_NONE;
|
|
|
|
|
dev->val[OPT_UTA_CONTROL].w = SANE_TRUE;
|
2003-08-17 09:04:23 +00:00
|
|
|
|
dev->opt[OPT_UTA_CONTROL].cap |= SANE_CAP_ADVANCED | SANE_CAP_INACTIVE;
|
2002-10-31 06:53:52 +00:00
|
|
|
|
|
2001-05-03 19:34:02 +00:00
|
|
|
|
/* custom-gamma table */
|
|
|
|
|
dev->opt[OPT_CUSTOM_GAMMA].name = SANE_NAME_CUSTOM_GAMMA;
|
|
|
|
|
dev->opt[OPT_CUSTOM_GAMMA].title = SANE_TITLE_CUSTOM_GAMMA;
|
|
|
|
|
dev->opt[OPT_CUSTOM_GAMMA].desc = SANE_DESC_CUSTOM_GAMMA;
|
|
|
|
|
dev->opt[OPT_CUSTOM_GAMMA].type = SANE_TYPE_BOOL;
|
2003-08-15 06:56:24 +00:00
|
|
|
|
dev->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_ADVANCED;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
dev->val[OPT_CUSTOM_GAMMA].w = SANE_FALSE;
|
|
|
|
|
|
|
|
|
|
/* grayscale gamma vector */
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR].name = SANE_NAME_GAMMA_VECTOR;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR].title = SANE_TITLE_GAMMA_VECTOR;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR].desc = SANE_DESC_GAMMA_VECTOR;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR].type = SANE_TYPE_INT;
|
2001-09-03 12:43:26 +00:00
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR].unit = SANE_UNIT_NONE;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR].size = 256 * sizeof (SANE_Word);
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR].constraint_type = SANE_CONSTRAINT_RANGE;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR].constraint.range = &u8_range;
|
|
|
|
|
dev->val[OPT_GAMMA_VECTOR].wa = &dev->gamma_table[0][0];
|
|
|
|
|
|
|
|
|
|
/* red gamma vector */
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_R].name = SANE_NAME_GAMMA_VECTOR_R;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_R].title = SANE_TITLE_GAMMA_VECTOR_R;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_R].desc = SANE_DESC_GAMMA_VECTOR_R;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_R].type = SANE_TYPE_INT;
|
2001-09-03 12:43:26 +00:00
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_R].unit = SANE_UNIT_NONE;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_R].size = 256 * sizeof (SANE_Word);
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_R].constraint_type = SANE_CONSTRAINT_RANGE;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_R].constraint.range = &u8_range;
|
|
|
|
|
dev->val[OPT_GAMMA_VECTOR_R].wa = &dev->gamma_table[1][0];
|
|
|
|
|
|
|
|
|
|
/* green gamma vector */
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_G].name = SANE_NAME_GAMMA_VECTOR_G;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_G].title = SANE_TITLE_GAMMA_VECTOR_G;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_G].desc = SANE_DESC_GAMMA_VECTOR_G;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_G].type = SANE_TYPE_INT;
|
2001-09-03 12:43:26 +00:00
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_G].unit = SANE_UNIT_NONE;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_G].size = 256 * sizeof (SANE_Word);
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_G].constraint_type = SANE_CONSTRAINT_RANGE;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_G].constraint.range = &u8_range;
|
|
|
|
|
dev->val[OPT_GAMMA_VECTOR_G].wa = &dev->gamma_table[2][0];
|
|
|
|
|
|
|
|
|
|
/* blue gamma vector */
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_B].name = SANE_NAME_GAMMA_VECTOR_B;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_B].title = SANE_TITLE_GAMMA_VECTOR_B;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_B].desc = SANE_DESC_GAMMA_VECTOR_B;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_B].type = SANE_TYPE_INT;
|
2001-09-03 12:43:26 +00:00
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_B].unit = SANE_UNIT_NONE;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_B].size = 256 * sizeof (SANE_Word);
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_B].constraint_type = SANE_CONSTRAINT_RANGE;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_B].constraint.range = &u8_range;
|
|
|
|
|
dev->val[OPT_GAMMA_VECTOR_B].wa = &dev->gamma_table[3][0];
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
/* brightness group */
|
|
|
|
|
dev->opt[OPT_MANUAL_BRIGHTNESS].name = "manual-channel-brightness";
|
|
|
|
|
dev->opt[OPT_MANUAL_BRIGHTNESS].title = SANE_I18N ("Brightness");
|
2003-04-18 12:53:55 +00:00
|
|
|
|
dev->opt[OPT_MANUAL_BRIGHTNESS].desc =
|
|
|
|
|
SANE_I18N ("Color channels brightness settings");
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->opt[OPT_MANUAL_BRIGHTNESS].type = SANE_TYPE_BOOL;
|
|
|
|
|
dev->opt[OPT_MANUAL_BRIGHTNESS].cap |= SANE_CAP_ADVANCED;
|
|
|
|
|
dev->val[OPT_MANUAL_BRIGHTNESS].w = SANE_FALSE;
|
|
|
|
|
|
|
|
|
|
/* gray brightness */
|
|
|
|
|
dev->opt[OPT_GRAY_BRIGHTNESS].name = "gray-brightness";
|
|
|
|
|
dev->opt[OPT_GRAY_BRIGHTNESS].title = SANE_I18N ("Gray brightness");
|
2003-04-18 12:53:55 +00:00
|
|
|
|
dev->opt[OPT_GRAY_BRIGHTNESS].desc =
|
|
|
|
|
SANE_I18N ("Sets gray channel brightness");
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->opt[OPT_GRAY_BRIGHTNESS].type = SANE_TYPE_INT;
|
|
|
|
|
dev->opt[OPT_GRAY_BRIGHTNESS].cap |= SANE_CAP_INACTIVE | SANE_CAP_ADVANCED;
|
|
|
|
|
dev->opt[OPT_GRAY_BRIGHTNESS].unit = SANE_UNIT_NONE;
|
|
|
|
|
dev->opt[OPT_GRAY_BRIGHTNESS].size = sizeof (SANE_Int);
|
|
|
|
|
dev->opt[OPT_GRAY_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE;
|
|
|
|
|
dev->opt[OPT_GRAY_BRIGHTNESS].constraint.range = &u4_range;
|
|
|
|
|
dev->val[OPT_GRAY_BRIGHTNESS].w = dev->gray_brightness;
|
|
|
|
|
|
|
|
|
|
/* red brightness */
|
|
|
|
|
dev->opt[OPT_RED_BRIGHTNESS].name = "red-brightness";
|
|
|
|
|
dev->opt[OPT_RED_BRIGHTNESS].title = SANE_I18N ("Red brightness");
|
2003-04-18 12:53:55 +00:00
|
|
|
|
dev->opt[OPT_RED_BRIGHTNESS].desc =
|
|
|
|
|
SANE_I18N ("Sets red channel brightness");
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->opt[OPT_RED_BRIGHTNESS].type = SANE_TYPE_INT;
|
|
|
|
|
dev->opt[OPT_RED_BRIGHTNESS].cap |= SANE_CAP_INACTIVE | SANE_CAP_ADVANCED;
|
|
|
|
|
dev->opt[OPT_RED_BRIGHTNESS].unit = SANE_UNIT_NONE;
|
|
|
|
|
dev->opt[OPT_RED_BRIGHTNESS].size = sizeof (SANE_Int);
|
|
|
|
|
dev->opt[OPT_RED_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE;
|
|
|
|
|
dev->opt[OPT_RED_BRIGHTNESS].constraint.range = &u4_range;
|
|
|
|
|
dev->val[OPT_RED_BRIGHTNESS].w = dev->red_brightness;
|
|
|
|
|
|
|
|
|
|
/* green brightness */
|
|
|
|
|
dev->opt[OPT_GREEN_BRIGHTNESS].name = "green-brightness";
|
|
|
|
|
dev->opt[OPT_GREEN_BRIGHTNESS].title = SANE_I18N ("Green brightness");
|
2003-04-18 12:53:55 +00:00
|
|
|
|
dev->opt[OPT_GREEN_BRIGHTNESS].desc =
|
|
|
|
|
SANE_I18N ("Sets green channel brightness");
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->opt[OPT_GREEN_BRIGHTNESS].type = SANE_TYPE_INT;
|
|
|
|
|
dev->opt[OPT_GREEN_BRIGHTNESS].cap |= SANE_CAP_INACTIVE | SANE_CAP_ADVANCED;
|
|
|
|
|
dev->opt[OPT_GREEN_BRIGHTNESS].unit = SANE_UNIT_NONE;
|
|
|
|
|
dev->opt[OPT_GREEN_BRIGHTNESS].size = sizeof (SANE_Int);
|
|
|
|
|
dev->opt[OPT_GREEN_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE;
|
|
|
|
|
dev->opt[OPT_GREEN_BRIGHTNESS].constraint.range = &u4_range;
|
|
|
|
|
dev->val[OPT_GREEN_BRIGHTNESS].w = dev->green_brightness;
|
|
|
|
|
|
|
|
|
|
/* blue brightness */
|
|
|
|
|
dev->opt[OPT_BLUE_BRIGHTNESS].name = "blue-brightness";
|
|
|
|
|
dev->opt[OPT_BLUE_BRIGHTNESS].title = SANE_I18N ("Blue brightness");
|
2003-04-18 12:53:55 +00:00
|
|
|
|
dev->opt[OPT_BLUE_BRIGHTNESS].desc =
|
|
|
|
|
SANE_I18N ("Sets blue channel brightness");
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->opt[OPT_BLUE_BRIGHTNESS].type = SANE_TYPE_INT;
|
|
|
|
|
dev->opt[OPT_BLUE_BRIGHTNESS].cap |= SANE_CAP_INACTIVE | SANE_CAP_ADVANCED;
|
|
|
|
|
dev->opt[OPT_BLUE_BRIGHTNESS].unit = SANE_UNIT_NONE;
|
|
|
|
|
dev->opt[OPT_BLUE_BRIGHTNESS].size = sizeof (SANE_Int);
|
|
|
|
|
dev->opt[OPT_BLUE_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE;
|
|
|
|
|
dev->opt[OPT_BLUE_BRIGHTNESS].constraint.range = &u4_range;
|
|
|
|
|
dev->val[OPT_BLUE_BRIGHTNESS].w = dev->blue_brightness;
|
|
|
|
|
|
|
|
|
|
/* contrast group */
|
|
|
|
|
dev->opt[OPT_MANUAL_CONTRAST].name = "manual-contrast";
|
|
|
|
|
dev->opt[OPT_MANUAL_CONTRAST].title = SANE_TITLE_CONTRAST;
|
|
|
|
|
dev->opt[OPT_MANUAL_CONTRAST].desc =
|
|
|
|
|
SANE_I18N ("Color channels contrast settings");
|
|
|
|
|
dev->opt[OPT_MANUAL_CONTRAST].type = SANE_TYPE_BOOL;
|
|
|
|
|
dev->opt[OPT_MANUAL_CONTRAST].cap |= SANE_CAP_ADVANCED;
|
|
|
|
|
dev->val[OPT_MANUAL_CONTRAST].w = SANE_FALSE;
|
|
|
|
|
|
|
|
|
|
/* gray contrast */
|
|
|
|
|
dev->opt[OPT_GRAY_CONTRAST].name = "gray-contrast";
|
|
|
|
|
dev->opt[OPT_GRAY_CONTRAST].title = SANE_I18N ("Gray contrast");
|
2003-04-18 12:53:55 +00:00
|
|
|
|
dev->opt[OPT_GRAY_CONTRAST].desc = SANE_I18N ("Sets gray channel contrast");
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->opt[OPT_GRAY_CONTRAST].type = SANE_TYPE_INT;
|
|
|
|
|
dev->opt[OPT_GRAY_CONTRAST].cap |= SANE_CAP_INACTIVE | SANE_CAP_ADVANCED;
|
|
|
|
|
dev->opt[OPT_GRAY_CONTRAST].unit = SANE_UNIT_NONE;
|
|
|
|
|
dev->opt[OPT_GRAY_CONTRAST].size = sizeof (SANE_Int);
|
|
|
|
|
dev->opt[OPT_GRAY_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE;
|
|
|
|
|
dev->opt[OPT_GRAY_CONTRAST].constraint.range = &u4_range;
|
|
|
|
|
dev->val[OPT_GRAY_CONTRAST].w = dev->gray_contrast;
|
|
|
|
|
|
|
|
|
|
/* red contrast */
|
|
|
|
|
dev->opt[OPT_RED_CONTRAST].name = "red-contrast";
|
|
|
|
|
dev->opt[OPT_RED_CONTRAST].title = SANE_TITLE_CONTRAST;
|
|
|
|
|
dev->opt[OPT_RED_CONTRAST].desc = SANE_I18N ("Sets red channel contrast");
|
|
|
|
|
dev->opt[OPT_RED_CONTRAST].type = SANE_TYPE_INT;
|
|
|
|
|
dev->opt[OPT_RED_CONTRAST].cap |= SANE_CAP_INACTIVE | SANE_CAP_ADVANCED;
|
|
|
|
|
dev->opt[OPT_RED_CONTRAST].unit = SANE_UNIT_NONE;
|
|
|
|
|
dev->opt[OPT_RED_CONTRAST].size = sizeof (SANE_Int);
|
|
|
|
|
dev->opt[OPT_RED_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE;
|
|
|
|
|
dev->opt[OPT_RED_CONTRAST].constraint.range = &u4_range;
|
|
|
|
|
dev->val[OPT_RED_CONTRAST].w = dev->red_contrast;
|
|
|
|
|
|
|
|
|
|
/* green contrast */
|
|
|
|
|
dev->opt[OPT_GREEN_CONTRAST].name = "green-contrast";
|
|
|
|
|
dev->opt[OPT_GREEN_CONTRAST].title = SANE_TITLE_CONTRAST;
|
|
|
|
|
dev->opt[OPT_GREEN_CONTRAST].desc =
|
|
|
|
|
SANE_I18N ("Sets green channel contrast");
|
|
|
|
|
dev->opt[OPT_GREEN_CONTRAST].type = SANE_TYPE_INT;
|
|
|
|
|
dev->opt[OPT_GREEN_CONTRAST].cap |= SANE_CAP_INACTIVE | SANE_CAP_ADVANCED;
|
|
|
|
|
dev->opt[OPT_GREEN_CONTRAST].unit = SANE_UNIT_NONE;
|
|
|
|
|
dev->opt[OPT_GREEN_CONTRAST].size = sizeof (SANE_Int);
|
|
|
|
|
dev->opt[OPT_GREEN_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE;
|
|
|
|
|
dev->opt[OPT_GREEN_CONTRAST].constraint.range = &u4_range;
|
|
|
|
|
dev->val[OPT_GREEN_CONTRAST].w = dev->green_contrast;
|
|
|
|
|
|
|
|
|
|
/* blue contrast */
|
|
|
|
|
dev->opt[OPT_BLUE_CONTRAST].name = "blue-contrast";
|
|
|
|
|
dev->opt[OPT_BLUE_CONTRAST].title = SANE_TITLE_CONTRAST;
|
2003-04-18 12:53:55 +00:00
|
|
|
|
dev->opt[OPT_BLUE_CONTRAST].desc = SANE_I18N ("Sets blue channel contrast");
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->opt[OPT_BLUE_CONTRAST].type = SANE_TYPE_INT;
|
|
|
|
|
dev->opt[OPT_BLUE_CONTRAST].cap |= SANE_CAP_INACTIVE | SANE_CAP_ADVANCED;
|
|
|
|
|
dev->opt[OPT_BLUE_CONTRAST].unit = SANE_UNIT_NONE;
|
|
|
|
|
dev->opt[OPT_BLUE_CONTRAST].size = sizeof (SANE_Int);
|
|
|
|
|
dev->opt[OPT_BLUE_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE;
|
|
|
|
|
dev->opt[OPT_BLUE_CONTRAST].constraint.range = &u4_range;
|
|
|
|
|
dev->val[OPT_BLUE_CONTRAST].w = dev->blue_contrast;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
return SANE_STATUS_GOOD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-02-20 05:47:47 +00:00
|
|
|
|
SANE_Status
|
|
|
|
|
sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
char dev_name[512];
|
|
|
|
|
const char *cp;
|
|
|
|
|
size_t len;
|
|
|
|
|
FILE *fp;
|
|
|
|
|
SANE_Status ret;
|
|
|
|
|
|
|
|
|
|
DBG_INIT ();
|
|
|
|
|
|
|
|
|
|
if (authorize != NULL)
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "init: SANE_Auth_Callback not supported (yet) ...\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (version_code != NULL)
|
|
|
|
|
*version_code = SANE_VERSION_CODE (V_MAJOR, V_MINOR, UMAX_PP_BUILD);
|
|
|
|
|
|
|
|
|
|
DBG (3, "init: SANE v%s, backend v%d.%d.%d-%s\n", VERSION, V_MAJOR, V_MINOR,
|
|
|
|
|
UMAX_PP_BUILD, UMAX_PP_STATE);
|
|
|
|
|
|
|
|
|
|
fp = sanei_config_open (UMAX_PP_CONFIG_FILE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (fp == NULL)
|
|
|
|
|
{
|
2003-10-09 05:27:39 +00:00
|
|
|
|
DBG (2, "init: no configuration file, using default `port %s'\n",
|
2001-05-03 19:34:02 +00:00
|
|
|
|
UMAX_PP_DEFAULT_PORT);
|
|
|
|
|
|
2003-10-09 05:27:39 +00:00
|
|
|
|
ret = attach (UMAX_PP_DEFAULT_PORT);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (sanei_config_read (dev_name, sizeof (dev_name), fp))
|
|
|
|
|
{
|
|
|
|
|
cp = sanei_config_skip_whitespace (dev_name);
|
|
|
|
|
if (!*cp || *cp == '#') /* ignore line comments & empty lines */
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
len = strlen (cp);
|
|
|
|
|
|
|
|
|
|
if (!len)
|
|
|
|
|
continue; /* ignore empty lines */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (strncmp (cp, "option", 6) == 0 && isspace (cp[6]))
|
|
|
|
|
{
|
|
|
|
|
|
1994-02-15 08:43:42 +00:00
|
|
|
|
DBG (3, "init: evaluating option <%s>\n", cp);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
cp += 7;
|
|
|
|
|
cp = sanei_config_skip_whitespace (cp);
|
|
|
|
|
|
|
|
|
|
if (strncmp (cp, "buffer", 6) == 0 && isspace (cp[6]))
|
|
|
|
|
{
|
|
|
|
|
char *end;
|
|
|
|
|
long int val;
|
|
|
|
|
|
|
|
|
|
cp += 7;
|
|
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
|
val = strtol (cp, &end, 0);
|
|
|
|
|
|
|
|
|
|
if ((end == cp || errno) || (val < 0))
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "init: invalid value `%s`, falling back to %ld\n",
|
|
|
|
|
cp, buf_size);
|
|
|
|
|
val = buf_size; /* safe fallback */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DBG (3, "init: option buffer %ld\n", val);
|
|
|
|
|
|
|
|
|
|
if (num_devices == 0)
|
|
|
|
|
{
|
|
|
|
|
DBG (3, "init: setting global option buffer to %ld\n", val);
|
|
|
|
|
buf_size = val;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DBG (3, "init: setting buffer to %ld for device %s\n",
|
|
|
|
|
val, devlist[0].sane.name);
|
|
|
|
|
devlist[0].buf_size = val;
|
|
|
|
|
}
|
|
|
|
|
}
|
1994-02-15 08:43:42 +00:00
|
|
|
|
else if (strncmp (cp, "astra", 5) == 0)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
char *end;
|
|
|
|
|
long int val;
|
|
|
|
|
|
1994-02-15 08:43:42 +00:00
|
|
|
|
cp += 6;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
|
val = strtol (cp, &end, 0);
|
|
|
|
|
|
|
|
|
|
if ((end == cp || errno))
|
|
|
|
|
{
|
|
|
|
|
val = 1220; /* safe fallback */
|
|
|
|
|
DBG (2,
|
|
|
|
|
"init: invalid astra value `%s`, falling back to %ld\n",
|
|
|
|
|
cp, val);
|
|
|
|
|
}
|
|
|
|
|
if ((val != 610)
|
|
|
|
|
&& (val != 1220) && (val != 1600) && (val != 2000))
|
|
|
|
|
{
|
|
|
|
|
val = 1220; /* safe fallback */
|
|
|
|
|
DBG (2,
|
|
|
|
|
"init: invalid astra value `%s`, falling back to %ld\n",
|
|
|
|
|
cp, val);
|
|
|
|
|
}
|
|
|
|
|
sanei_umax_pp_setastra (val);
|
|
|
|
|
DBG (3, "init: option astra %ld P\n", val);
|
|
|
|
|
}
|
2003-04-18 12:53:55 +00:00
|
|
|
|
else if ((strncmp (cp, "red-brightness", 14) == 0)
|
|
|
|
|
&& isspace (cp[14]))
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
char *end;
|
|
|
|
|
long int val;
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
cp += 15;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
|
val = strtol (cp, &end, 0);
|
|
|
|
|
|
|
|
|
|
if ((end == cp || errno) || (val < 0) || (val > 15))
|
|
|
|
|
{
|
|
|
|
|
val = 8; /* safe fallback */
|
|
|
|
|
DBG (2, "init: invalid value `%s`, falling back to %ld\n",
|
|
|
|
|
cp, val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DBG (3, "init: option buffer %ld\n", val);
|
|
|
|
|
|
2003-04-18 12:53:55 +00:00
|
|
|
|
DBG (3, "init: setting global option red-brightness to %ld\n",
|
|
|
|
|
val);
|
2003-02-25 07:04:12 +00:00
|
|
|
|
red_brightness = val;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
2003-04-18 12:53:55 +00:00
|
|
|
|
else if (strncmp (cp, "green-brightness", 16) == 0
|
|
|
|
|
&& isspace (cp[16]))
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
char *end;
|
|
|
|
|
long int val;
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
cp += 17;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
|
val = strtol (cp, &end, 0);
|
|
|
|
|
|
|
|
|
|
if ((end == cp || errno) || (val < 0) || (val > 15))
|
|
|
|
|
{
|
|
|
|
|
val = 4; /* safe fallback */
|
|
|
|
|
DBG (2, "init: invalid value `%s`, falling back to %ld\n",
|
|
|
|
|
cp, val);
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
DBG (3, "init: option green-brightness %ld\n", val);
|
2003-04-18 12:53:55 +00:00
|
|
|
|
DBG (3, "init: setting global option green-brightness to %ld\n",
|
|
|
|
|
val);
|
2003-02-25 07:04:12 +00:00
|
|
|
|
green_brightness = val;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
2003-04-18 12:53:55 +00:00
|
|
|
|
else if (strncmp (cp, "blue-brightness", 15) == 0
|
|
|
|
|
&& isspace (cp[15]))
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
char *end;
|
|
|
|
|
long int val;
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
cp += 16;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
|
val = strtol (cp, &end, 0);
|
|
|
|
|
|
|
|
|
|
if ((end == cp || errno) || (val < 0) || (val > 15))
|
|
|
|
|
{
|
|
|
|
|
val = 8; /* safe fallback */
|
|
|
|
|
DBG (2, "init: invalid value `%s`, falling back to %ld\n",
|
|
|
|
|
cp, val);
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
DBG (3, "init: option blue-brightness %ld\n", val);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
2003-04-18 12:53:55 +00:00
|
|
|
|
DBG (3, "init: setting global option blue-brightness to %ld\n",
|
|
|
|
|
val);
|
2003-02-25 07:04:12 +00:00
|
|
|
|
blue_brightness = val;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
2003-04-18 12:53:55 +00:00
|
|
|
|
else if ((strncmp (cp, "red-contrast", 12) == 0)
|
|
|
|
|
&& isspace (cp[12]))
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
char *end;
|
|
|
|
|
long int val;
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
cp += 13;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
|
val = strtol (cp, &end, 0);
|
|
|
|
|
|
|
|
|
|
if ((end == cp || errno) || (val < 0) || (val > 15))
|
|
|
|
|
{
|
|
|
|
|
val = 8; /* safe fallback */
|
|
|
|
|
DBG (2, "init: invalid value `%s`, falling back to %ld\n",
|
|
|
|
|
cp, val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DBG (3, "init: option buffer %ld\n", val);
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
DBG (3, "init: setting global option red-contrast to %ld\n",
|
2001-05-03 19:34:02 +00:00
|
|
|
|
val);
|
2003-02-25 07:04:12 +00:00
|
|
|
|
red_contrast = val;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
2003-02-25 07:04:12 +00:00
|
|
|
|
else if (strncmp (cp, "green-contrast", 14) == 0
|
|
|
|
|
&& isspace (cp[14]))
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
char *end;
|
|
|
|
|
long int val;
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
cp += 15;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
|
val = strtol (cp, &end, 0);
|
|
|
|
|
|
|
|
|
|
if ((end == cp || errno) || (val < 0) || (val > 15))
|
|
|
|
|
{
|
|
|
|
|
val = 4; /* safe fallback */
|
|
|
|
|
DBG (2, "init: invalid value `%s`, falling back to %ld\n",
|
|
|
|
|
cp, val);
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
DBG (3, "init: option green-contrast %ld\n", val);
|
|
|
|
|
DBG (3, "init: setting global option green-contrast to %ld\n",
|
2001-05-03 19:34:02 +00:00
|
|
|
|
val);
|
2003-02-25 07:04:12 +00:00
|
|
|
|
green_contrast = val;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
2003-04-18 12:53:55 +00:00
|
|
|
|
else if (strncmp (cp, "blue-contrast", 13) == 0 && isspace (cp[13]))
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
char *end;
|
|
|
|
|
long int val;
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
cp += 14;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
|
val = strtol (cp, &end, 0);
|
|
|
|
|
|
|
|
|
|
if ((end == cp || errno) || (val < 0) || (val > 15))
|
|
|
|
|
{
|
|
|
|
|
val = 8; /* safe fallback */
|
|
|
|
|
DBG (2, "init: invalid value `%s`, falling back to %ld\n",
|
|
|
|
|
cp, val);
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
DBG (3, "init: option blue-contrast %ld\n", val);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
DBG (3, "init: setting global option blue-contrast to %ld\n",
|
2001-05-03 19:34:02 +00:00
|
|
|
|
val);
|
2003-02-25 07:04:12 +00:00
|
|
|
|
blue_contrast = val;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ((strncmp (cp, "port", 4) == 0) && isspace (cp[4]))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
cp += 5;
|
|
|
|
|
cp = sanei_config_skip_whitespace (cp);
|
|
|
|
|
|
|
|
|
|
if (*cp)
|
|
|
|
|
{
|
2003-10-09 05:27:39 +00:00
|
|
|
|
/* here, the argument maybe a device, an address, or special
|
|
|
|
|
* keywords 'auto' and 'safe-auto'
|
|
|
|
|
*/
|
|
|
|
|
if (strcmp (cp, "safe-auto") == 0)
|
|
|
|
|
{
|
|
|
|
|
/* try every device we can find */
|
|
|
|
|
if (umax_pp_auto_attach (SANE_TRUE) != SANE_STATUS_GOOD)
|
|
|
|
|
DBG (2, "init: safe-auto attach failed !");
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp (cp, "auto") == 0)
|
|
|
|
|
{
|
|
|
|
|
/* try every port/device we can find */
|
|
|
|
|
if (umax_pp_auto_attach (SANE_FALSE) != SANE_STATUS_GOOD)
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "init: auto attach failed !");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DBG (3, "init: trying port `%s'\n", cp);
|
|
|
|
|
|
|
|
|
|
DBG (3, "attach(%s)\n", cp);
|
|
|
|
|
if (attach (cp) != SANE_STATUS_GOOD)
|
|
|
|
|
DBG (2, "init: couldn't attach to port `%s'\n", cp);
|
|
|
|
|
}
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ((strncmp (cp, "name", 4) == 0) && isspace (cp[4]))
|
|
|
|
|
{
|
|
|
|
|
cp += 5;
|
|
|
|
|
cp = sanei_config_skip_whitespace (cp);
|
|
|
|
|
|
|
|
|
|
if (num_devices == 0)
|
|
|
|
|
DBG (2, "init: 'name' only allowed after 'port'\n");
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DBG (3, "init: naming device %s '%s'\n", devlist[0].port, cp);
|
|
|
|
|
free (devlist[0].sane.name);
|
|
|
|
|
devlist[0].sane.name = strdup (cp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ((strncmp (cp, "model", 5) == 0) && isspace (cp[5]))
|
|
|
|
|
{
|
|
|
|
|
cp += 6;
|
|
|
|
|
cp = sanei_config_skip_whitespace (cp);
|
|
|
|
|
|
|
|
|
|
if (num_devices == 0)
|
|
|
|
|
DBG (2, "init: 'model' only allowed after 'port'\n");
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DBG (3, "init: device %s is a '%s'\n", devlist[0].port, cp);
|
|
|
|
|
free (devlist[0].sane.model);
|
|
|
|
|
devlist[0].sane.model = strdup (cp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ((strncmp (cp, "vendor", 6) == 0) && isspace (cp[6]))
|
|
|
|
|
{
|
|
|
|
|
cp += 7;
|
|
|
|
|
cp = sanei_config_skip_whitespace (cp);
|
|
|
|
|
|
|
|
|
|
if (num_devices == 0)
|
|
|
|
|
DBG (2, "init: 'vendor' only allowed after 'port'\n");
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DBG (3, "init: device %s is from '%s'\n", devlist[0].port, cp);
|
|
|
|
|
free (devlist[0].sane.vendor);
|
|
|
|
|
devlist[0].sane.vendor = strdup (cp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
DBG (2, "init: don't know what to do with `%s'\n", cp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fclose (fp);
|
|
|
|
|
|
|
|
|
|
return SANE_STATUS_GOOD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
sane_exit (void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
Umax_PP_Device *dev;
|
|
|
|
|
|
2001-09-03 12:43:26 +00:00
|
|
|
|
DBG (3, "sane_exit: (...)\n");
|
2001-05-03 19:34:02 +00:00
|
|
|
|
if (first_dev)
|
|
|
|
|
DBG (3, "exit: closing open devices\n");
|
|
|
|
|
|
|
|
|
|
while (first_dev)
|
|
|
|
|
{
|
|
|
|
|
dev = first_dev;
|
|
|
|
|
sane_close (dev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < num_devices; i++)
|
|
|
|
|
{
|
|
|
|
|
free (devlist[i].port);
|
|
|
|
|
free (devlist[i].sane.name);
|
|
|
|
|
free (devlist[i].sane.model);
|
|
|
|
|
free (devlist[i].sane.vendor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (devlist != NULL)
|
2003-04-18 12:53:55 +00:00
|
|
|
|
{
|
|
|
|
|
free (devlist);
|
|
|
|
|
devlist = NULL;
|
|
|
|
|
}
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
2001-05-16 04:52:43 +00:00
|
|
|
|
if (devarray != NULL)
|
2003-04-18 12:53:55 +00:00
|
|
|
|
{
|
|
|
|
|
free (devarray);
|
|
|
|
|
devarray = NULL;
|
|
|
|
|
}
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
2003-02-23 08:54:16 +00:00
|
|
|
|
/* reset values */
|
2001-05-03 19:34:02 +00:00
|
|
|
|
num_devices = 0;
|
2003-02-23 08:54:16 +00:00
|
|
|
|
first_dev = NULL;
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
red_brightness = 0;
|
|
|
|
|
green_brightness = 0;
|
|
|
|
|
blue_brightness = 0;
|
2003-02-23 08:54:16 +00:00
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
red_contrast = 0;
|
|
|
|
|
green_contrast = 0;
|
|
|
|
|
blue_contrast = 0;
|
2003-02-23 08:54:16 +00:00
|
|
|
|
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SANE_Status
|
|
|
|
|
sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
DBG (3, "get_devices\n");
|
|
|
|
|
DBG (129, "unused arg: local_only = %d\n", (int) local_only);
|
|
|
|
|
|
|
|
|
|
if (devarray != NULL)
|
2003-04-18 12:53:55 +00:00
|
|
|
|
{
|
|
|
|
|
free (devarray);
|
|
|
|
|
devarray = NULL;
|
|
|
|
|
}
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
devarray = malloc ((num_devices + 1) * sizeof (devarray[0]));
|
|
|
|
|
|
|
|
|
|
if (devarray == NULL)
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "get_devices: not enough memory for device list\n");
|
|
|
|
|
DEBUG ();
|
|
|
|
|
return SANE_STATUS_NO_MEM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < num_devices; i++)
|
|
|
|
|
devarray[i] = &devlist[i].sane;
|
|
|
|
|
|
|
|
|
|
devarray[num_devices] = NULL;
|
|
|
|
|
*device_list = devarray;
|
|
|
|
|
|
|
|
|
|
return SANE_STATUS_GOOD;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-20 05:47:47 +00:00
|
|
|
|
SANE_Status
|
|
|
|
|
sane_open (SANE_String_Const devicename, SANE_Handle * handle)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
Umax_PP_Device *dev;
|
|
|
|
|
Umax_PP_Descriptor *desc;
|
|
|
|
|
int i, j;
|
1994-02-15 08:43:42 +00:00
|
|
|
|
int rc, prt = 0;
|
|
|
|
|
char *name = NULL;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
DBG (3, "open: device `%s'\n", devicename);
|
|
|
|
|
|
|
|
|
|
if (devicename[0])
|
|
|
|
|
{
|
|
|
|
|
for (i = 0; i < num_devices; i++)
|
|
|
|
|
if (strcmp (devlist[i].sane.name, devicename) == 0)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (i >= num_devices)
|
|
|
|
|
for (i = 0; i < num_devices; i++)
|
|
|
|
|
if (strcmp (devlist[i].port, devicename) == 0)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (i >= num_devices)
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "open: device doesn't exist\n");
|
|
|
|
|
DEBUG ();
|
|
|
|
|
return SANE_STATUS_INVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
desc = &devlist[i];
|
|
|
|
|
|
2002-02-20 05:47:47 +00:00
|
|
|
|
if (devlist[i].ppdevice != NULL)
|
1994-02-15 08:43:42 +00:00
|
|
|
|
{
|
2002-02-20 05:47:47 +00:00
|
|
|
|
if (devlist[i].ppdevice[0] == '/')
|
|
|
|
|
{
|
|
|
|
|
name = devlist[i].ppdevice;
|
|
|
|
|
}
|
1994-02-15 08:43:42 +00:00
|
|
|
|
}
|
2001-05-03 19:34:02 +00:00
|
|
|
|
else
|
1994-02-15 08:43:42 +00:00
|
|
|
|
{
|
|
|
|
|
if ((devlist[i].port[0] == '0')
|
|
|
|
|
&& ((devlist[i].port[1] == 'x') || (devlist[i].port[1] == 'X')))
|
|
|
|
|
prt = strtol (devlist[i].port + 2, NULL, 16);
|
|
|
|
|
else
|
|
|
|
|
prt = atoi (devlist[i].port);
|
|
|
|
|
DBG (64, "open: devlist[i].port='%s' -> port=0x%X\n",
|
|
|
|
|
devlist[i].port, prt);
|
|
|
|
|
}
|
|
|
|
|
rc = sanei_umax_pp_open (prt, name);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (num_devices == 0)
|
|
|
|
|
{
|
|
|
|
|
DBG (1, "open: no devices present\n");
|
|
|
|
|
return SANE_STATUS_INVAL;
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
DBG (3, "open: trying default device %s, port=%s,ppdev=%s\n",
|
|
|
|
|
devlist[0].sane.name, devlist[0].port, devlist[0].ppdevice);
|
2003-04-18 12:53:55 +00:00
|
|
|
|
if (devlist[0].port != NULL)
|
2003-10-09 05:27:39 +00:00
|
|
|
|
{
|
|
|
|
|
if ((devlist[0].port[0] == '0')
|
|
|
|
|
&& ((devlist[0].port[1] == 'x') || (devlist[0].port[1] == 'X')))
|
|
|
|
|
prt = strtol (devlist[0].port + 2, NULL, 16);
|
|
|
|
|
else
|
|
|
|
|
prt = atoi (devlist[0].port);
|
2003-09-18 05:17:23 +00:00
|
|
|
|
rc = sanei_umax_pp_open (prt, NULL);
|
2003-10-09 05:27:39 +00:00
|
|
|
|
}
|
2003-02-23 08:54:16 +00:00
|
|
|
|
else
|
2003-10-09 05:27:39 +00:00
|
|
|
|
{
|
|
|
|
|
rc = sanei_umax_pp_open (0, devlist[0].ppdevice);
|
|
|
|
|
}
|
2001-05-03 19:34:02 +00:00
|
|
|
|
desc = &devlist[0];
|
|
|
|
|
}
|
|
|
|
|
switch (rc)
|
|
|
|
|
{
|
|
|
|
|
case UMAX1220P_TRANSPORT_FAILED:
|
1994-02-15 08:43:42 +00:00
|
|
|
|
if (name == NULL)
|
|
|
|
|
{
|
2003-09-18 05:17:23 +00:00
|
|
|
|
DBG (1, "failed to init transport layer on port 0x%03X\n", prt);
|
1994-02-15 08:43:42 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DBG (1, "failed to init transport layer on device %s\n", name);
|
|
|
|
|
}
|
2001-05-03 19:34:02 +00:00
|
|
|
|
return SANE_STATUS_IO_ERROR;
|
1994-02-15 08:43:42 +00:00
|
|
|
|
|
2001-05-03 19:34:02 +00:00
|
|
|
|
case UMAX1220P_SCANNER_FAILED:
|
1994-02-15 08:43:42 +00:00
|
|
|
|
if (name == NULL)
|
|
|
|
|
{
|
2003-09-18 05:17:23 +00:00
|
|
|
|
DBG (1, "failed to initialize scanner on port 0x%03X\n", prt);
|
1994-02-15 08:43:42 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DBG (1, "failed to initialize scanner on device %s\n", name);
|
|
|
|
|
}
|
2001-05-03 19:34:02 +00:00
|
|
|
|
return SANE_STATUS_IO_ERROR;
|
|
|
|
|
case UMAX1220P_BUSY:
|
1994-02-15 08:43:42 +00:00
|
|
|
|
if (name == NULL)
|
|
|
|
|
{
|
2003-09-18 05:17:23 +00:00
|
|
|
|
DBG (1, "busy scanner on port 0x%03X\n", prt);
|
1994-02-15 08:43:42 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DBG (1, "busy scanner on device %s\n", name);
|
|
|
|
|
}
|
2001-05-03 19:34:02 +00:00
|
|
|
|
return SANE_STATUS_DEVICE_BUSY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dev = (Umax_PP_Device *) malloc (sizeof (*dev));
|
|
|
|
|
|
|
|
|
|
if (dev == NULL)
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "open: not enough memory for device descriptor\n");
|
|
|
|
|
DEBUG ();
|
|
|
|
|
return SANE_STATUS_NO_MEM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memset (dev, 0, sizeof (*dev));
|
|
|
|
|
|
|
|
|
|
dev->desc = desc;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 4; ++i)
|
|
|
|
|
for (j = 0; j < 256; ++j)
|
|
|
|
|
dev->gamma_table[i][j] = j;
|
|
|
|
|
|
2003-02-09 08:26:00 +00:00
|
|
|
|
/* the extra amount of UMAX_PP_RESERVE bytes is to handle */
|
|
|
|
|
/* the data needed to resync the color frames */
|
|
|
|
|
dev->buf = malloc (dev->desc->buf_size + UMAX_PP_RESERVE);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
dev->bufsize = dev->desc->buf_size;
|
|
|
|
|
|
|
|
|
|
dev->dpi_range.min = SANE_FIX (75);
|
|
|
|
|
dev->dpi_range.max = SANE_FIX (dev->desc->max_res);
|
|
|
|
|
dev->dpi_range.quant = 0;
|
|
|
|
|
|
|
|
|
|
dev->x_range.min = 0;
|
|
|
|
|
dev->x_range.max = dev->desc->max_h_size;
|
|
|
|
|
dev->x_range.quant = 0;
|
|
|
|
|
|
|
|
|
|
dev->y_range.min = 0;
|
|
|
|
|
dev->y_range.max = dev->desc->max_v_size;
|
|
|
|
|
dev->y_range.quant = 0;
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->gray_brightness = 0;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
/* use pre defined settings read from umax_pp.conf */
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->red_brightness = red_brightness;
|
|
|
|
|
dev->green_brightness = green_brightness;
|
|
|
|
|
dev->blue_brightness = blue_brightness;
|
|
|
|
|
dev->red_contrast = red_contrast;
|
|
|
|
|
dev->green_contrast = green_contrast;
|
|
|
|
|
dev->blue_contrast = blue_contrast;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dev->buf == NULL)
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "open: not enough memory for scan buffer (%lu bytes)\n",
|
|
|
|
|
(long int) dev->desc->buf_size);
|
|
|
|
|
DEBUG ();
|
|
|
|
|
free (dev);
|
|
|
|
|
return SANE_STATUS_NO_MEM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
init_options (dev);
|
|
|
|
|
|
|
|
|
|
dev->next = first_dev;
|
|
|
|
|
first_dev = dev;
|
|
|
|
|
|
2002-10-31 06:53:52 +00:00
|
|
|
|
|
|
|
|
|
if (sanei_umax_pp_UTA () == 1)
|
|
|
|
|
dev->opt[OPT_UTA_CONTROL].cap &= ~SANE_CAP_INACTIVE;
|
|
|
|
|
|
2001-05-03 19:34:02 +00:00
|
|
|
|
*handle = dev;
|
|
|
|
|
|
|
|
|
|
DBG (3, "open: success\n");
|
|
|
|
|
|
|
|
|
|
return SANE_STATUS_GOOD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
sane_close (SANE_Handle handle)
|
|
|
|
|
{
|
|
|
|
|
Umax_PP_Device *prev, *dev;
|
|
|
|
|
int rc;
|
|
|
|
|
|
2001-09-03 12:43:26 +00:00
|
|
|
|
DBG (3, "sane_close: ...\n");
|
2001-05-03 19:34:02 +00:00
|
|
|
|
/* remove handle from list of open handles: */
|
|
|
|
|
prev = NULL;
|
|
|
|
|
|
|
|
|
|
for (dev = first_dev; dev; dev = dev->next)
|
|
|
|
|
{
|
|
|
|
|
if (dev == handle)
|
|
|
|
|
break;
|
|
|
|
|
prev = dev;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dev == NULL)
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "close: unknown device\n");
|
|
|
|
|
DEBUG ();
|
|
|
|
|
return; /* oops, not a handle we know about */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dev->state == UMAX_PP_STATE_SCANNING)
|
|
|
|
|
sane_cancel (handle); /* remember: sane_cancel is a macro and
|
|
|
|
|
expands to sane_umax_pp_cancel ()... */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* if the scanner is parking head, we wait it to finish */
|
|
|
|
|
while (dev->state == UMAX_PP_STATE_CANCELLED)
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "close: waiting scanner to park head\n");
|
|
|
|
|
rc = sanei_umax_pp_status ();
|
|
|
|
|
|
|
|
|
|
/* check if scanner busy parking */
|
|
|
|
|
if (rc != UMAX1220P_BUSY)
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "close: scanner head parked\n");
|
|
|
|
|
dev->state = UMAX_PP_STATE_IDLE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
/* then we switch off brightness if needed */
|
2001-05-03 19:34:02 +00:00
|
|
|
|
if (dev->val[OPT_LAMP_CONTROL].w == SANE_TRUE)
|
|
|
|
|
{
|
|
|
|
|
rc = sanei_umax_pp_lamp (0);
|
|
|
|
|
if (rc == UMAX1220P_TRANSPORT_FAILED)
|
|
|
|
|
{
|
2003-02-25 07:04:12 +00:00
|
|
|
|
DBG (1, "close: switch off brightness failed (ignored....)\n");
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-10 16:43:15 +00:00
|
|
|
|
sanei_umax_pp_close ();
|
2001-09-03 12:43:26 +00:00
|
|
|
|
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (prev != NULL)
|
|
|
|
|
prev->next = dev->next;
|
|
|
|
|
else
|
|
|
|
|
first_dev = dev->next;
|
|
|
|
|
|
|
|
|
|
free (dev->buf);
|
|
|
|
|
DBG (3, "close: device closed\n");
|
|
|
|
|
|
|
|
|
|
free (handle);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const SANE_Option_Descriptor *
|
|
|
|
|
sane_get_option_descriptor (SANE_Handle handle, SANE_Int option)
|
|
|
|
|
{
|
|
|
|
|
Umax_PP_Device *dev = handle;
|
|
|
|
|
|
|
|
|
|
if ((unsigned) option >= NUM_OPTIONS)
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "get_option_descriptor: option %d doesn't exist\n", option);
|
|
|
|
|
DEBUG ();
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DBG (6, "get_option_descriptor: requested option %d (%s)\n",
|
|
|
|
|
option, dev->opt[option].name);
|
|
|
|
|
|
|
|
|
|
return dev->opt + option;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SANE_Status
|
|
|
|
|
sane_control_option (SANE_Handle handle, SANE_Int option,
|
|
|
|
|
SANE_Action action, void *val, SANE_Int * info)
|
|
|
|
|
{
|
|
|
|
|
Umax_PP_Device *dev = handle;
|
|
|
|
|
SANE_Status status;
|
2002-01-06 16:20:45 +00:00
|
|
|
|
SANE_Word w, cap, tmpw;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
int dpi, rc;
|
2003-08-15 06:56:24 +00:00
|
|
|
|
unsigned int i;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
DBG (6, "control_option: option %d, action %d\n", option, action);
|
|
|
|
|
|
|
|
|
|
if (info)
|
|
|
|
|
*info = 0;
|
|
|
|
|
|
|
|
|
|
if (dev->state == UMAX_PP_STATE_SCANNING)
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "control_option: device is scanning\n");
|
|
|
|
|
DEBUG ();
|
|
|
|
|
return SANE_STATUS_DEVICE_BUSY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((unsigned int) option >= NUM_OPTIONS)
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "control_option: option doesn't exist\n");
|
|
|
|
|
DEBUG ();
|
|
|
|
|
return SANE_STATUS_INVAL;
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-02 06:17:29 +00:00
|
|
|
|
|
2001-05-03 19:34:02 +00:00
|
|
|
|
cap = dev->opt[option].cap;
|
|
|
|
|
|
|
|
|
|
if (!SANE_OPTION_IS_ACTIVE (cap))
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "control_option: option isn't active\n");
|
|
|
|
|
DEBUG ();
|
|
|
|
|
return SANE_STATUS_INVAL;
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-09 08:26:00 +00:00
|
|
|
|
DBG (6, "control_option: option <%s>, action ... %d\n",
|
|
|
|
|
dev->opt[option].name, action);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
if (action == SANE_ACTION_GET_VALUE)
|
|
|
|
|
{
|
|
|
|
|
DBG (6, " get value\n");
|
|
|
|
|
switch (option)
|
|
|
|
|
{
|
|
|
|
|
/* word options: */
|
|
|
|
|
case OPT_PREVIEW:
|
|
|
|
|
case OPT_GRAY_PREVIEW:
|
|
|
|
|
case OPT_LAMP_CONTROL:
|
2002-10-31 06:53:52 +00:00
|
|
|
|
case OPT_UTA_CONTROL:
|
2001-05-03 19:34:02 +00:00
|
|
|
|
case OPT_RESOLUTION:
|
|
|
|
|
case OPT_TL_X:
|
|
|
|
|
case OPT_TL_Y:
|
|
|
|
|
case OPT_BR_X:
|
|
|
|
|
case OPT_BR_Y:
|
|
|
|
|
case OPT_NUM_OPTS:
|
|
|
|
|
case OPT_CUSTOM_GAMMA:
|
2003-02-25 07:04:12 +00:00
|
|
|
|
case OPT_MANUAL_BRIGHTNESS:
|
|
|
|
|
case OPT_GRAY_BRIGHTNESS:
|
|
|
|
|
case OPT_GREEN_BRIGHTNESS:
|
|
|
|
|
case OPT_RED_BRIGHTNESS:
|
|
|
|
|
case OPT_BLUE_BRIGHTNESS:
|
|
|
|
|
case OPT_MANUAL_CONTRAST:
|
|
|
|
|
case OPT_GRAY_CONTRAST:
|
|
|
|
|
case OPT_GREEN_CONTRAST:
|
|
|
|
|
case OPT_RED_CONTRAST:
|
|
|
|
|
case OPT_BLUE_CONTRAST:
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
*(SANE_Word *) val = dev->val[option].w;
|
|
|
|
|
return SANE_STATUS_GOOD;
|
|
|
|
|
|
|
|
|
|
/* word-array options: */
|
|
|
|
|
case OPT_GAMMA_VECTOR:
|
|
|
|
|
case OPT_GAMMA_VECTOR_R:
|
|
|
|
|
case OPT_GAMMA_VECTOR_G:
|
|
|
|
|
case OPT_GAMMA_VECTOR_B:
|
|
|
|
|
|
2003-10-09 05:27:39 +00:00
|
|
|
|
for (i = 0; i < dev->opt[option].size / sizeof (SANE_Word); i++)
|
|
|
|
|
{
|
|
|
|
|
if (((SANE_Int *) val)[i] < 0 || ((SANE_Int *) val)[i] > 255)
|
2003-08-15 06:56:24 +00:00
|
|
|
|
{
|
2003-10-09 05:27:39 +00:00
|
|
|
|
DBG (2, "Value at index %d out of range\n", i);
|
|
|
|
|
return SANE_STATUS_INVAL;
|
2003-08-15 06:56:24 +00:00
|
|
|
|
}
|
2003-10-09 05:27:39 +00:00
|
|
|
|
}
|
2001-05-03 19:34:02 +00:00
|
|
|
|
memcpy (val, dev->val[option].wa, dev->opt[option].size);
|
|
|
|
|
return SANE_STATUS_GOOD;
|
|
|
|
|
|
|
|
|
|
/* string options: */
|
|
|
|
|
case OPT_MODE:
|
|
|
|
|
|
|
|
|
|
strcpy (val, dev->val[option].s);
|
|
|
|
|
return SANE_STATUS_GOOD;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (action == SANE_ACTION_SET_VALUE)
|
|
|
|
|
{
|
|
|
|
|
DBG (6, " set value\n");
|
|
|
|
|
|
|
|
|
|
if (!SANE_OPTION_IS_SETTABLE (cap))
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "control_option: option can't be set\n");
|
|
|
|
|
DEBUG ();
|
|
|
|
|
return SANE_STATUS_INVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
status = sanei_constrain_value (dev->opt + option, val, info);
|
|
|
|
|
|
|
|
|
|
if (status != SANE_STATUS_GOOD)
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "control_option: constrain_value failed (%s)\n",
|
|
|
|
|
sane_strstatus (status));
|
|
|
|
|
DEBUG ();
|
|
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (option == OPT_RESOLUTION)
|
|
|
|
|
{
|
|
|
|
|
DBG (16, "control_option: setting resolution to %d\n",
|
|
|
|
|
*(SANE_Int *) val);
|
|
|
|
|
}
|
|
|
|
|
if (option == OPT_PREVIEW)
|
|
|
|
|
{
|
|
|
|
|
DBG (16, "control_option: setting preview to %d\n",
|
|
|
|
|
*(SANE_Word *) val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (option)
|
|
|
|
|
{
|
|
|
|
|
/* (mostly) side-effect-free word options: */
|
|
|
|
|
case OPT_PREVIEW:
|
|
|
|
|
case OPT_GRAY_PREVIEW:
|
|
|
|
|
case OPT_TL_Y:
|
|
|
|
|
case OPT_BR_Y:
|
|
|
|
|
|
|
|
|
|
if (info)
|
|
|
|
|
*info |= SANE_INFO_RELOAD_PARAMS;
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
case OPT_GRAY_BRIGHTNESS:
|
|
|
|
|
case OPT_GREEN_BRIGHTNESS:
|
|
|
|
|
case OPT_RED_BRIGHTNESS:
|
|
|
|
|
case OPT_BLUE_BRIGHTNESS:
|
|
|
|
|
case OPT_GRAY_CONTRAST:
|
|
|
|
|
case OPT_GREEN_CONTRAST:
|
|
|
|
|
case OPT_RED_CONTRAST:
|
|
|
|
|
case OPT_BLUE_CONTRAST:
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
dev->val[option].w = *(SANE_Word *) val;
|
2002-01-06 16:20:45 +00:00
|
|
|
|
/* sanity check */
|
|
|
|
|
if (dev->val[OPT_BR_Y].w < dev->val[OPT_TL_Y].w)
|
|
|
|
|
{
|
|
|
|
|
tmpw = dev->val[OPT_BR_Y].w;
|
|
|
|
|
dev->val[OPT_BR_Y].w = dev->val[OPT_TL_Y].w;
|
|
|
|
|
dev->val[OPT_TL_Y].w = tmpw;
|
|
|
|
|
if (info)
|
|
|
|
|
*info |= SANE_INFO_INEXACT;
|
|
|
|
|
DBG (16, "control_option: swapping Y coordinates\n");
|
|
|
|
|
}
|
2003-02-09 08:26:00 +00:00
|
|
|
|
if (strcmp (dev->val[OPT_MODE].s, "Color") == 0)
|
|
|
|
|
{
|
|
|
|
|
dpi = (int) (SANE_UNFIX (dev->val[OPT_RESOLUTION].w));
|
|
|
|
|
if (dev->val[OPT_TL_Y].w < 2 * umax_pp_get_sync (dpi))
|
|
|
|
|
{
|
|
|
|
|
DBG (16, "control_option: correcting TL_Y coordinates\n");
|
|
|
|
|
dev->val[OPT_TL_Y].w = 2 * umax_pp_get_sync (dpi);
|
|
|
|
|
if (info)
|
|
|
|
|
*info |= SANE_INFO_INEXACT;
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-05-03 19:34:02 +00:00
|
|
|
|
return SANE_STATUS_GOOD;
|
|
|
|
|
|
|
|
|
|
/* side-effect-free word-array options: */
|
|
|
|
|
case OPT_GAMMA_VECTOR:
|
|
|
|
|
case OPT_GAMMA_VECTOR_R:
|
|
|
|
|
case OPT_GAMMA_VECTOR_G:
|
|
|
|
|
case OPT_GAMMA_VECTOR_B:
|
|
|
|
|
|
|
|
|
|
memcpy (dev->val[option].wa, val, dev->opt[option].size);
|
|
|
|
|
return SANE_STATUS_GOOD;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* options with side-effects: */
|
2002-10-31 06:53:52 +00:00
|
|
|
|
case OPT_UTA_CONTROL:
|
|
|
|
|
dev->val[option].w = *(SANE_Word *) val;
|
|
|
|
|
return SANE_STATUS_GOOD;
|
|
|
|
|
|
2001-05-03 19:34:02 +00:00
|
|
|
|
case OPT_LAMP_CONTROL:
|
|
|
|
|
if (dev->state != UMAX_PP_STATE_IDLE)
|
|
|
|
|
{
|
|
|
|
|
rc = sanei_umax_pp_status ();
|
|
|
|
|
|
|
|
|
|
/* check if scanner busy parking */
|
|
|
|
|
if (rc == UMAX1220P_BUSY)
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "control_option: scanner busy\n");
|
|
|
|
|
if (info)
|
|
|
|
|
*info |= SANE_INFO_RELOAD_PARAMS;
|
|
|
|
|
return SANE_STATUS_DEVICE_BUSY;
|
|
|
|
|
}
|
|
|
|
|
dev->state = UMAX_PP_STATE_IDLE;
|
|
|
|
|
}
|
|
|
|
|
dev->val[option].w = *(SANE_Word *) val;
|
|
|
|
|
if (dev->val[option].w == SANE_TRUE)
|
|
|
|
|
rc = sanei_umax_pp_lamp (1);
|
|
|
|
|
else
|
|
|
|
|
rc = sanei_umax_pp_lamp (0);
|
|
|
|
|
if (rc == UMAX1220P_TRANSPORT_FAILED)
|
|
|
|
|
return SANE_STATUS_IO_ERROR;
|
|
|
|
|
return SANE_STATUS_GOOD;
|
|
|
|
|
|
|
|
|
|
case OPT_TL_X:
|
|
|
|
|
case OPT_BR_X:
|
|
|
|
|
if (info)
|
|
|
|
|
*info |= SANE_INFO_RELOAD_PARAMS;
|
|
|
|
|
dpi = (int) (SANE_UNFIX (dev->val[OPT_RESOLUTION].w));
|
|
|
|
|
dev->val[option].w = *(SANE_Word *) val;
|
|
|
|
|
/* coords rounded to allow 32 bit IO/transfer */
|
|
|
|
|
/* at high resolution */
|
|
|
|
|
if (dpi >= 600)
|
|
|
|
|
{
|
|
|
|
|
if (dev->val[option].w & 0x03)
|
|
|
|
|
{
|
|
|
|
|
if (info)
|
|
|
|
|
*info |= SANE_INFO_INEXACT;
|
|
|
|
|
dev->val[option].w = dev->val[option].w & 0xFFFC;
|
|
|
|
|
*(SANE_Word *) val = dev->val[option].w;
|
|
|
|
|
DBG (16, "control_option: rounding X to %d\n",
|
|
|
|
|
*(SANE_Word *) val);
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-01-06 16:20:45 +00:00
|
|
|
|
/* sanity check */
|
|
|
|
|
if (dev->val[OPT_BR_X].w < dev->val[OPT_TL_X].w)
|
|
|
|
|
{
|
|
|
|
|
tmpw = dev->val[OPT_BR_X].w;
|
|
|
|
|
dev->val[OPT_BR_X].w = dev->val[OPT_TL_X].w;
|
|
|
|
|
dev->val[OPT_TL_X].w = tmpw;
|
|
|
|
|
if (info)
|
|
|
|
|
*info |= SANE_INFO_INEXACT;
|
|
|
|
|
DBG (16, "control_option: swapping X coordinates\n");
|
|
|
|
|
}
|
2001-05-03 19:34:02 +00:00
|
|
|
|
return SANE_STATUS_GOOD;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case OPT_RESOLUTION:
|
|
|
|
|
if (info)
|
|
|
|
|
*info |= SANE_INFO_RELOAD_PARAMS;
|
|
|
|
|
/* resolution : only have 75, 150, 300, 600 and 1200 */
|
|
|
|
|
dpi = (int) (SANE_UNFIX (*(SANE_Word *) val));
|
|
|
|
|
if ((dpi != 75)
|
|
|
|
|
&& (dpi != 150)
|
|
|
|
|
&& (dpi != 300) && (dpi != 600) && (dpi != 1200))
|
|
|
|
|
{
|
|
|
|
|
if (dpi <= 75)
|
|
|
|
|
dpi = 75;
|
|
|
|
|
else if (dpi <= 150)
|
|
|
|
|
dpi = 150;
|
|
|
|
|
else if (dpi <= 300)
|
|
|
|
|
dpi = 300;
|
|
|
|
|
else if (dpi <= 600)
|
|
|
|
|
dpi = 600;
|
|
|
|
|
else
|
|
|
|
|
dpi = 1200;
|
|
|
|
|
if (info)
|
|
|
|
|
*info |= SANE_INFO_INEXACT;
|
|
|
|
|
*(SANE_Word *) val = SANE_FIX ((SANE_Word) dpi);
|
|
|
|
|
}
|
|
|
|
|
dev->val[option].w = *(SANE_Word *) val;
|
|
|
|
|
|
|
|
|
|
/* correct top x and bottom x if needed */
|
|
|
|
|
if (dpi >= 600)
|
|
|
|
|
{
|
|
|
|
|
dev->val[OPT_TL_X].w = dev->val[OPT_TL_X].w & 0xFFFC;
|
2003-02-09 08:26:00 +00:00
|
|
|
|
dev->val[OPT_BR_X].w = dev->val[OPT_BR_X].w & 0xFFFC;
|
|
|
|
|
}
|
|
|
|
|
/* corrects top y for offset */
|
|
|
|
|
if (strcmp (dev->val[OPT_MODE].s, "Color") == 0)
|
|
|
|
|
{
|
|
|
|
|
if (dev->val[OPT_TL_Y].w < 2 * umax_pp_get_sync (dpi))
|
|
|
|
|
{
|
|
|
|
|
DBG (16, "control_option: correcting TL_Y coordinates\n");
|
|
|
|
|
dev->val[OPT_TL_Y].w = 2 * umax_pp_get_sync (dpi);
|
|
|
|
|
if (info)
|
|
|
|
|
*info |= SANE_INFO_INEXACT;
|
|
|
|
|
}
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
return SANE_STATUS_GOOD;
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
case OPT_MANUAL_CONTRAST:
|
2001-05-03 19:34:02 +00:00
|
|
|
|
w = *(SANE_Word *) val;
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
if (w == dev->val[OPT_MANUAL_CONTRAST].w)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
return SANE_STATUS_GOOD; /* no change */
|
|
|
|
|
|
|
|
|
|
if (info)
|
|
|
|
|
*info |= SANE_INFO_RELOAD_OPTIONS;
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->val[OPT_MANUAL_CONTRAST].w = w;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
if (w == SANE_TRUE)
|
|
|
|
|
{
|
|
|
|
|
const char *mode = dev->val[OPT_MODE].s;
|
|
|
|
|
|
2003-02-23 08:54:16 +00:00
|
|
|
|
if ((strcmp (mode, "Grayscale") == 0)
|
2002-05-30 16:13:44 +00:00
|
|
|
|
|| (strcmp (mode, "Lineart") == 0))
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->opt[OPT_GRAY_CONTRAST].cap &= ~SANE_CAP_INACTIVE;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
else if (strcmp (mode, "Color") == 0)
|
|
|
|
|
{
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->opt[OPT_GRAY_CONTRAST].cap |= SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_RED_CONTRAST].cap &= ~SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_GREEN_CONTRAST].cap &= ~SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_BLUE_CONTRAST].cap &= ~SANE_CAP_INACTIVE;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->opt[OPT_GRAY_CONTRAST].cap |= SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_RED_CONTRAST].cap |= SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_GREEN_CONTRAST].cap |= SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_BLUE_CONTRAST].cap |= SANE_CAP_INACTIVE;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
return SANE_STATUS_GOOD;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
case OPT_MANUAL_BRIGHTNESS:
|
2001-05-03 19:34:02 +00:00
|
|
|
|
w = *(SANE_Word *) val;
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
if (w == dev->val[OPT_MANUAL_BRIGHTNESS].w)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
return SANE_STATUS_GOOD; /* no change */
|
|
|
|
|
|
|
|
|
|
if (info)
|
|
|
|
|
*info |= SANE_INFO_RELOAD_OPTIONS;
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->val[OPT_MANUAL_BRIGHTNESS].w = w;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
if (w == SANE_TRUE)
|
|
|
|
|
{
|
|
|
|
|
const char *mode = dev->val[OPT_MODE].s;
|
|
|
|
|
|
2003-02-23 08:54:16 +00:00
|
|
|
|
if ((strcmp (mode, "Grayscale") == 0)
|
2002-05-30 16:13:44 +00:00
|
|
|
|
|| (strcmp (mode, "Lineart") == 0))
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->opt[OPT_GRAY_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
else if (strcmp (mode, "Color") == 0)
|
|
|
|
|
{
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->opt[OPT_GRAY_BRIGHTNESS].cap |= SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_RED_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_GREEN_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_BLUE_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->opt[OPT_GRAY_BRIGHTNESS].cap |= SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_RED_BRIGHTNESS].cap |= SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_GREEN_BRIGHTNESS].cap |= SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_BLUE_BRIGHTNESS].cap |= SANE_CAP_INACTIVE;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
return SANE_STATUS_GOOD;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case OPT_CUSTOM_GAMMA:
|
|
|
|
|
w = *(SANE_Word *) val;
|
|
|
|
|
|
|
|
|
|
if (w == dev->val[OPT_CUSTOM_GAMMA].w)
|
|
|
|
|
return SANE_STATUS_GOOD; /* no change */
|
|
|
|
|
|
|
|
|
|
if (info)
|
|
|
|
|
*info |= SANE_INFO_RELOAD_OPTIONS;
|
|
|
|
|
|
|
|
|
|
dev->val[OPT_CUSTOM_GAMMA].w = w;
|
|
|
|
|
|
|
|
|
|
if (w == SANE_TRUE)
|
|
|
|
|
{
|
|
|
|
|
const char *mode = dev->val[OPT_MODE].s;
|
|
|
|
|
|
2003-02-23 08:54:16 +00:00
|
|
|
|
if ((strcmp (mode, "Grayscale") == 0)
|
2002-05-30 16:13:44 +00:00
|
|
|
|
|| (strcmp (mode, "Lineart") == 0))
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE;
|
|
|
|
|
sanei_umax_pp_gamma (NULL, dev->val[OPT_GAMMA_VECTOR].wa,
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp (mode, "Color") == 0)
|
|
|
|
|
{
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE;
|
|
|
|
|
sanei_umax_pp_gamma (dev->val[OPT_GAMMA_VECTOR_R].wa,
|
|
|
|
|
dev->val[OPT_GAMMA_VECTOR_G].wa,
|
|
|
|
|
dev->val[OPT_GAMMA_VECTOR_B].wa);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE;
|
|
|
|
|
sanei_umax_pp_gamma (NULL, NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return SANE_STATUS_GOOD;
|
|
|
|
|
|
|
|
|
|
case OPT_MODE:
|
|
|
|
|
{
|
|
|
|
|
char *old_val = dev->val[option].s;
|
|
|
|
|
|
|
|
|
|
if (old_val)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp (old_val, val) == 0)
|
|
|
|
|
return SANE_STATUS_GOOD; /* no change */
|
|
|
|
|
|
|
|
|
|
free (old_val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (info)
|
|
|
|
|
*info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS;
|
|
|
|
|
|
|
|
|
|
dev->val[option].s = strdup (val);
|
|
|
|
|
|
2003-02-09 08:26:00 +00:00
|
|
|
|
/* corrects top y for offset */
|
|
|
|
|
if (strcmp (val, "Color") == 0)
|
|
|
|
|
{
|
|
|
|
|
dpi = (int) (SANE_UNFIX (dev->val[OPT_RESOLUTION].w));
|
|
|
|
|
if (dev->val[OPT_TL_Y].w < 2 * umax_pp_get_sync (dpi))
|
|
|
|
|
{
|
|
|
|
|
dev->val[OPT_TL_Y].w = 2 * umax_pp_get_sync (dpi);
|
|
|
|
|
DBG (16, "control_option: correcting TL_Y coordinates\n");
|
|
|
|
|
if (info)
|
|
|
|
|
*info |= SANE_INFO_INEXACT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-05-03 19:34:02 +00:00
|
|
|
|
dev->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE;
|
|
|
|
|
sanei_umax_pp_gamma (NULL, NULL, NULL);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dev->val[OPT_CUSTOM_GAMMA].w == SANE_TRUE)
|
|
|
|
|
{
|
2003-02-23 08:54:16 +00:00
|
|
|
|
if ((strcmp (val, "Grayscale") == 0)
|
2002-05-30 16:13:44 +00:00
|
|
|
|
|| (strcmp (val, "Lineart") == 0))
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE;
|
|
|
|
|
sanei_umax_pp_gamma (NULL, dev->val[OPT_GAMMA_VECTOR].wa,
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp (val, "Color") == 0)
|
|
|
|
|
{
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE;
|
|
|
|
|
sanei_umax_pp_gamma (dev->val[OPT_GAMMA_VECTOR_R].wa,
|
|
|
|
|
dev->val[OPT_GAMMA_VECTOR_G].wa,
|
|
|
|
|
dev->val[OPT_GAMMA_VECTOR_B].wa);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
/* rebuild OPT CONTRAST */
|
|
|
|
|
dev->opt[OPT_GRAY_CONTRAST].cap |= SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_RED_CONTRAST].cap |= SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_GREEN_CONTRAST].cap |= SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_BLUE_CONTRAST].cap |= SANE_CAP_INACTIVE;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
if (dev->val[OPT_MANUAL_CONTRAST].w == SANE_TRUE)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
2003-02-23 08:54:16 +00:00
|
|
|
|
if ((strcmp (val, "Grayscale") == 0)
|
2002-05-30 16:13:44 +00:00
|
|
|
|
|| (strcmp (val, "Lineart") == 0))
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->opt[OPT_GRAY_CONTRAST].cap &= ~SANE_CAP_INACTIVE;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
else if (strcmp (val, "Color") == 0)
|
|
|
|
|
{
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->opt[OPT_RED_CONTRAST].cap &= ~SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_GREEN_CONTRAST].cap &= ~SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_BLUE_CONTRAST].cap &= ~SANE_CAP_INACTIVE;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
/* rebuild OPT BRIGHTNESS */
|
|
|
|
|
dev->opt[OPT_GRAY_BRIGHTNESS].cap |= SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_RED_BRIGHTNESS].cap |= SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_GREEN_BRIGHTNESS].cap |= SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_BLUE_BRIGHTNESS].cap |= SANE_CAP_INACTIVE;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
if (dev->val[OPT_MANUAL_BRIGHTNESS].w == SANE_TRUE)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
2003-02-23 08:54:16 +00:00
|
|
|
|
if ((strcmp (val, "Grayscale") == 0)
|
2002-05-30 16:13:44 +00:00
|
|
|
|
|| (strcmp (val, "Lineart") == 0))
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->opt[OPT_GRAY_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
else if (strcmp (val, "Color") == 0)
|
|
|
|
|
{
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->opt[OPT_RED_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_GREEN_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE;
|
|
|
|
|
dev->opt[OPT_BLUE_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return SANE_STATUS_GOOD;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DBG (2, "control_option: unknown action %d \n", action);
|
|
|
|
|
DEBUG ();
|
|
|
|
|
return SANE_STATUS_INVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-02-20 05:47:47 +00:00
|
|
|
|
SANE_Status
|
|
|
|
|
sane_get_parameters (SANE_Handle handle, SANE_Parameters * params)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
Umax_PP_Device *dev = handle;
|
|
|
|
|
int dpi, remain;
|
|
|
|
|
|
|
|
|
|
memset (&(dev->params), 0, sizeof (dev->params));
|
|
|
|
|
DBG (64, "sane_get_parameters\n");
|
|
|
|
|
|
|
|
|
|
/* color/gray */
|
2002-05-30 16:13:44 +00:00
|
|
|
|
if (strcmp (dev->val[OPT_MODE].s, "Color") != 0)
|
2002-10-09 05:16:14 +00:00
|
|
|
|
{
|
2003-02-23 08:54:16 +00:00
|
|
|
|
if (strcmp (dev->val[OPT_MODE].s, "Grayscale") != 0)
|
2002-10-09 05:16:14 +00:00
|
|
|
|
dev->color = UMAX_PP_MODE_LINEART;
|
|
|
|
|
else
|
|
|
|
|
dev->color = UMAX_PP_MODE_GRAYSCALE;
|
|
|
|
|
}
|
2001-05-03 19:34:02 +00:00
|
|
|
|
else
|
|
|
|
|
dev->color = UMAX_PP_MODE_COLOR;
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
/* contrast control */
|
|
|
|
|
if (dev->val[OPT_MANUAL_CONTRAST].w == SANE_TRUE)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
2002-05-30 16:13:44 +00:00
|
|
|
|
if (dev->color != UMAX_PP_MODE_COLOR)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->red_contrast = 0;
|
|
|
|
|
dev->green_contrast = (int) (dev->val[OPT_GRAY_CONTRAST].w);
|
|
|
|
|
dev->blue_contrast = 0;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->red_contrast = (int) (dev->val[OPT_RED_CONTRAST].w);
|
|
|
|
|
dev->green_contrast = (int) (dev->val[OPT_GREEN_CONTRAST].w);
|
|
|
|
|
dev->blue_contrast = (int) (dev->val[OPT_BLUE_CONTRAST].w);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->red_contrast = 2;
|
|
|
|
|
dev->green_contrast = 2;
|
|
|
|
|
dev->blue_contrast = 2;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-02-25 07:04:12 +00:00
|
|
|
|
/* brightness control */
|
|
|
|
|
if (dev->val[OPT_MANUAL_BRIGHTNESS].w == SANE_TRUE)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
2002-05-30 16:13:44 +00:00
|
|
|
|
if (dev->color != UMAX_PP_MODE_COLOR)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->red_brightness = 0;
|
|
|
|
|
dev->green_brightness = (int) (dev->val[OPT_GRAY_BRIGHTNESS].w);
|
|
|
|
|
dev->blue_brightness = 0;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->red_brightness = (int) (dev->val[OPT_RED_BRIGHTNESS].w);
|
|
|
|
|
dev->green_brightness = (int) (dev->val[OPT_GREEN_BRIGHTNESS].w);
|
|
|
|
|
dev->blue_brightness = (int) (dev->val[OPT_BLUE_BRIGHTNESS].w);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->red_brightness = red_brightness;
|
|
|
|
|
dev->green_brightness = green_brightness;
|
|
|
|
|
dev->blue_brightness = blue_brightness;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* geometry */
|
|
|
|
|
dev->TopX = dev->val[OPT_TL_X].w;
|
|
|
|
|
dev->TopY = dev->val[OPT_TL_Y].w;
|
|
|
|
|
dev->BottomX = dev->val[OPT_BR_X].w;
|
|
|
|
|
dev->BottomY = dev->val[OPT_BR_Y].w;
|
|
|
|
|
|
|
|
|
|
/* resolution : only have 75, 150, 300, 600 and 1200 */
|
|
|
|
|
dpi = (int) (SANE_UNFIX (dev->val[OPT_RESOLUTION].w));
|
|
|
|
|
if (dpi <= 75)
|
|
|
|
|
dpi = 75;
|
|
|
|
|
else if (dpi <= 150)
|
|
|
|
|
dpi = 150;
|
|
|
|
|
else if (dpi <= 300)
|
|
|
|
|
dpi = 300;
|
|
|
|
|
else if (dpi <= 600)
|
|
|
|
|
dpi = 600;
|
|
|
|
|
else
|
|
|
|
|
dpi = 1200;
|
|
|
|
|
dev->dpi = dpi;
|
|
|
|
|
|
|
|
|
|
DBG (16, "sane_get_parameters: dpi set to %d\n", dpi);
|
|
|
|
|
|
|
|
|
|
/* for highest resolutions , width must be aligned on 32 bit word */
|
|
|
|
|
if (dpi >= 600)
|
|
|
|
|
{
|
|
|
|
|
remain = (dev->BottomX - dev->TopX) & 0x03;
|
|
|
|
|
if (remain)
|
|
|
|
|
{
|
|
|
|
|
DBG (64, "sane_get_parameters: %d-%d -> remain is %d\n",
|
|
|
|
|
dev->BottomX, dev->TopX, remain);
|
|
|
|
|
if (dev->BottomX + remain < 5100)
|
|
|
|
|
dev->BottomX += remain;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
remain -= (5100 - dev->BottomX);
|
|
|
|
|
dev->BottomX = 5100;
|
|
|
|
|
dev->TopX -= remain;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dev->val[OPT_PREVIEW].w == SANE_TRUE)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (dev->val[OPT_GRAY_PREVIEW].w == SANE_TRUE)
|
|
|
|
|
{
|
|
|
|
|
DBG (16, "sane_get_parameters: gray preview\n");
|
|
|
|
|
dev->color = UMAX_PP_MODE_GRAYSCALE;
|
|
|
|
|
dev->params.format = SANE_FRAME_GRAY;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DBG (16, "sane_get_parameters: color preview\n");
|
|
|
|
|
dev->color = UMAX_PP_MODE_COLOR;
|
|
|
|
|
dev->params.format = SANE_FRAME_RGB;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dev->dpi = 75;
|
|
|
|
|
dev->TopX = 0;
|
|
|
|
|
dev->TopY = 0;
|
|
|
|
|
dev->BottomX = 5100;
|
|
|
|
|
dev->BottomY = 7000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* fill params */
|
|
|
|
|
dev->params.last_frame = SANE_TRUE;
|
|
|
|
|
dev->params.lines = ((dev->BottomY - dev->TopY) * dev->dpi) / 600;
|
|
|
|
|
if (dev->dpi == 1200)
|
|
|
|
|
dpi = 600;
|
|
|
|
|
else
|
|
|
|
|
dpi = dev->dpi;
|
|
|
|
|
dev->params.pixels_per_line = ((dev->BottomX - dev->TopX) * dpi) / 600;
|
|
|
|
|
dev->params.bytes_per_line = dev->params.pixels_per_line;
|
|
|
|
|
if (dev->color == UMAX_PP_MODE_COLOR)
|
|
|
|
|
{
|
|
|
|
|
dev->params.bytes_per_line *= 3;
|
|
|
|
|
dev->params.format = SANE_FRAME_RGB;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dev->params.format = SANE_FRAME_GRAY;
|
|
|
|
|
}
|
|
|
|
|
dev->params.depth = 8;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* success */
|
|
|
|
|
if (params != NULL)
|
|
|
|
|
memcpy (params, &(dev->params), sizeof (dev->params));
|
|
|
|
|
return SANE_STATUS_GOOD;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-20 05:47:47 +00:00
|
|
|
|
SANE_Status
|
|
|
|
|
sane_start (SANE_Handle handle)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
Umax_PP_Device *dev = handle;
|
2002-01-06 16:20:45 +00:00
|
|
|
|
int rc, autoset;
|
2003-02-09 08:26:00 +00:00
|
|
|
|
int delta = 0;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
/* sanity check */
|
|
|
|
|
if (dev->state == UMAX_PP_STATE_SCANNING)
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "start: device is already scanning\n");
|
|
|
|
|
DEBUG ();
|
|
|
|
|
|
|
|
|
|
return SANE_STATUS_DEVICE_BUSY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* if cancelled, check if head is back home */
|
|
|
|
|
if (dev->state == UMAX_PP_STATE_CANCELLED)
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "start: checking if scanner is parking head .... \n");
|
|
|
|
|
|
|
|
|
|
rc = sanei_umax_pp_status ();
|
|
|
|
|
|
|
|
|
|
/* check if scanner busy parking */
|
|
|
|
|
if (rc == UMAX1220P_BUSY)
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "start: scanner busy\n");
|
|
|
|
|
return SANE_STATUS_DEVICE_BUSY;
|
|
|
|
|
}
|
|
|
|
|
dev->state = UMAX_PP_STATE_IDLE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* get values from options */
|
|
|
|
|
sane_get_parameters (handle, NULL);
|
|
|
|
|
|
|
|
|
|
/* sets lamp flag to TRUE */
|
|
|
|
|
dev->val[OPT_LAMP_CONTROL].w = SANE_TRUE;
|
|
|
|
|
|
2002-01-06 16:20:45 +00:00
|
|
|
|
/* tests if we do auto setting */
|
2003-02-25 07:04:12 +00:00
|
|
|
|
if (dev->val[OPT_MANUAL_BRIGHTNESS].w == SANE_TRUE)
|
2002-01-06 16:20:45 +00:00
|
|
|
|
autoset = 0;
|
|
|
|
|
else
|
|
|
|
|
autoset = 1;
|
|
|
|
|
|
2003-02-09 08:26:00 +00:00
|
|
|
|
|
2001-05-03 19:34:02 +00:00
|
|
|
|
/* call start scan */
|
|
|
|
|
if (dev->color == UMAX_PP_MODE_COLOR)
|
|
|
|
|
{
|
2003-02-09 08:26:00 +00:00
|
|
|
|
delta = umax_pp_get_sync (dev->dpi);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
DBG (64, "start:umax_pp_start(%d,%d,%d,%d,%d,1,%X,%X)\n",
|
|
|
|
|
dev->TopX,
|
2003-02-09 08:26:00 +00:00
|
|
|
|
dev->TopY - 2 * delta,
|
2001-05-03 19:34:02 +00:00
|
|
|
|
dev->BottomX - dev->TopX,
|
|
|
|
|
dev->BottomY - dev->TopY,
|
|
|
|
|
dev->dpi,
|
2003-04-18 12:53:55 +00:00
|
|
|
|
(dev->red_brightness << 8) + (dev->green_brightness << 4) +
|
|
|
|
|
dev->blue_brightness,
|
2003-02-25 07:04:12 +00:00
|
|
|
|
(dev->red_contrast << 8) + (dev->green_contrast << 4) +
|
|
|
|
|
dev->blue_contrast);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
rc = sanei_umax_pp_start (dev->TopX,
|
2003-02-09 08:26:00 +00:00
|
|
|
|
dev->TopY - 2 * delta,
|
2001-05-03 19:34:02 +00:00
|
|
|
|
dev->BottomX - dev->TopX,
|
|
|
|
|
dev->BottomY - dev->TopY,
|
|
|
|
|
dev->dpi,
|
2002-05-30 16:13:44 +00:00
|
|
|
|
2,
|
2002-01-06 16:20:45 +00:00
|
|
|
|
autoset,
|
2003-02-25 07:04:12 +00:00
|
|
|
|
(dev->red_brightness << 8) +
|
2003-04-18 12:53:55 +00:00
|
|
|
|
(dev->green_brightness << 4) +
|
|
|
|
|
dev->blue_brightness,
|
2003-02-25 07:04:12 +00:00
|
|
|
|
(dev->red_contrast << 8) +
|
|
|
|
|
(dev->green_contrast << 4) +
|
2003-04-18 12:53:55 +00:00
|
|
|
|
dev->blue_contrast, &(dev->bpp), &(dev->tw),
|
|
|
|
|
&(dev->th));
|
2003-02-09 08:26:00 +00:00
|
|
|
|
/* we enlarged the scanning zone */
|
|
|
|
|
/* to allow reordering, we must */
|
|
|
|
|
/* substract it from real scanning */
|
|
|
|
|
/* zone */
|
|
|
|
|
dev->th -= 2 * delta;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DBG (64, "start:umax_pp_start(%d,%d,%d,%d,%d,0,%X,%X)\n",
|
|
|
|
|
dev->TopX,
|
|
|
|
|
dev->TopY,
|
|
|
|
|
dev->BottomX - dev->TopX,
|
2003-02-25 07:04:12 +00:00
|
|
|
|
dev->BottomY - dev->TopY, dev->dpi, dev->gray_brightness << 4,
|
|
|
|
|
dev->gray_contrast << 4);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
rc = sanei_umax_pp_start (dev->TopX,
|
|
|
|
|
dev->TopY,
|
|
|
|
|
dev->BottomX - dev->TopX,
|
|
|
|
|
dev->BottomY - dev->TopY,
|
|
|
|
|
dev->dpi,
|
2002-05-30 16:13:44 +00:00
|
|
|
|
(dev->color ==
|
|
|
|
|
UMAX_PP_MODE_GRAYSCALE) ? 1 : 0, autoset,
|
2003-04-18 12:53:55 +00:00
|
|
|
|
dev->gray_brightness << 4,
|
|
|
|
|
dev->gray_contrast << 4, &(dev->bpp),
|
|
|
|
|
&(dev->tw), &(dev->th));
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rc != UMAX1220P_OK)
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "start: failure\n");
|
|
|
|
|
DEBUG ();
|
|
|
|
|
|
|
|
|
|
return SANE_STATUS_IO_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* scan started, no bytes read */
|
|
|
|
|
dev->state = UMAX_PP_STATE_SCANNING;
|
|
|
|
|
dev->buflen = 0;
|
|
|
|
|
dev->bufread = 0;
|
|
|
|
|
dev->read = 0;
|
|
|
|
|
|
2003-02-09 08:26:00 +00:00
|
|
|
|
/* in case of color, we have to preload blue and green */
|
|
|
|
|
/* data to allow reordering while later read */
|
|
|
|
|
if ((dev->color == UMAX_PP_MODE_COLOR) && (delta > 0))
|
|
|
|
|
{
|
|
|
|
|
rc =
|
|
|
|
|
sanei_umax_pp_read (2 * delta * dev->tw * dev->bpp, dev->tw, dev->dpi,
|
|
|
|
|
0,
|
|
|
|
|
dev->buf + UMAX_PP_RESERVE -
|
|
|
|
|
2 * delta * dev->tw * dev->bpp);
|
|
|
|
|
if (rc != UMAX1220P_OK)
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "start: preload buffer failed\n");
|
|
|
|
|
return SANE_STATUS_IO_ERROR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-05-03 19:34:02 +00:00
|
|
|
|
/* OK .... */
|
|
|
|
|
return SANE_STATUS_GOOD;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SANE_Status
|
|
|
|
|
sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len,
|
|
|
|
|
SANE_Int * len)
|
|
|
|
|
{
|
|
|
|
|
Umax_PP_Device *dev = handle;
|
|
|
|
|
long int length;
|
|
|
|
|
int last, rc;
|
|
|
|
|
int x, y, nl, ll;
|
|
|
|
|
SANE_Byte *lbuf;
|
2002-05-30 16:13:44 +00:00
|
|
|
|
int max = 0;
|
|
|
|
|
int min = 255;
|
2003-02-09 08:26:00 +00:00
|
|
|
|
int delta = 0;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* no data until further notice */
|
|
|
|
|
*len = 0;
|
|
|
|
|
DBG (64, "sane_read(max_len=%d)\n", max_len);
|
|
|
|
|
ll = dev->tw * dev->bpp;
|
|
|
|
|
|
|
|
|
|
/* sanity check */
|
|
|
|
|
if (dev->state == UMAX_PP_STATE_CANCELLED)
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "read: scan cancelled\n");
|
|
|
|
|
DEBUG ();
|
|
|
|
|
|
|
|
|
|
return SANE_STATUS_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* eof test */
|
|
|
|
|
if (dev->read >= dev->th * ll)
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "read: end of scan reached\n");
|
|
|
|
|
return SANE_STATUS_EOF;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* read data from scanner if needed */
|
|
|
|
|
if ((dev->buflen == 0) || (dev->bufread >= dev->buflen))
|
|
|
|
|
{
|
|
|
|
|
DBG (64, "sane_read: reading data from scanner\n");
|
|
|
|
|
/* absolute number of bytes needed */
|
|
|
|
|
length = ll * dev->th - dev->read;
|
|
|
|
|
|
|
|
|
|
/* does all fit in a single last read ? */
|
|
|
|
|
if (length <= dev->bufsize)
|
|
|
|
|
{
|
|
|
|
|
last = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
last = 0;
|
|
|
|
|
/* round number of scan lines */
|
|
|
|
|
length = (dev->bufsize / ll) * ll;
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-09 08:26:00 +00:00
|
|
|
|
delta = umax_pp_get_sync (dev->dpi);
|
|
|
|
|
|
|
|
|
|
if (dev->color == UMAX_PP_MODE_COLOR)
|
|
|
|
|
rc =
|
|
|
|
|
sanei_umax_pp_read (length, dev->tw, dev->dpi, last,
|
|
|
|
|
dev->buf + UMAX_PP_RESERVE);
|
|
|
|
|
else
|
|
|
|
|
rc = sanei_umax_pp_read (length, dev->tw, dev->dpi, last, dev->buf);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
if (rc != UMAX1220P_OK)
|
|
|
|
|
return SANE_STATUS_IO_ERROR;
|
|
|
|
|
dev->buflen = length;
|
|
|
|
|
DBG (64, "sane_read: got %ld bytes of data from scanner\n", length);
|
|
|
|
|
|
2003-02-09 08:26:00 +00:00
|
|
|
|
/* we transform data for software lineart */
|
|
|
|
|
if (dev->color == UMAX_PP_MODE_LINEART)
|
|
|
|
|
{
|
|
|
|
|
DBG (64, "sane_read: software lineart\n");
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
2003-02-09 08:26:00 +00:00
|
|
|
|
for (y = 0; y < length; y++)
|
|
|
|
|
{
|
|
|
|
|
if (dev->buf[y] > max)
|
|
|
|
|
max = dev->buf[y];
|
|
|
|
|
if (dev->buf[y] < min)
|
|
|
|
|
min = dev->buf[y];
|
|
|
|
|
}
|
|
|
|
|
max = (min + max) / 2;
|
|
|
|
|
for (y = 0; y < length; y++)
|
|
|
|
|
{
|
|
|
|
|
if (dev->buf[y] > max)
|
|
|
|
|
dev->buf[y] = 255;
|
|
|
|
|
else
|
|
|
|
|
dev->buf[y] = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (dev->color == UMAX_PP_MODE_COLOR)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
2003-02-09 08:26:00 +00:00
|
|
|
|
/* number of lines */
|
|
|
|
|
nl = dev->buflen / ll;
|
1994-02-15 08:43:42 +00:00
|
|
|
|
DBG (64, "sane_read: reordering %ld bytes of data (lines=%d)\n",
|
2001-05-03 19:34:02 +00:00
|
|
|
|
length, nl);
|
2003-02-09 08:26:00 +00:00
|
|
|
|
lbuf = (SANE_Byte *) malloc (dev->bufsize + UMAX_PP_RESERVE);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
if (lbuf == NULL)
|
|
|
|
|
{
|
|
|
|
|
DBG (1, "sane_read: couldn't allocate %ld bytes\n",
|
2003-02-09 08:26:00 +00:00
|
|
|
|
dev->bufsize + UMAX_PP_RESERVE);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
return SANE_STATUS_NO_MEM;
|
|
|
|
|
}
|
2003-02-09 08:26:00 +00:00
|
|
|
|
/* reorder data in R,G,B values */
|
|
|
|
|
for (y = 0; y < nl; y++)
|
1994-02-15 08:43:42 +00:00
|
|
|
|
{
|
2003-02-09 08:26:00 +00:00
|
|
|
|
for (x = 0; x < dev->tw; x++)
|
1994-02-15 08:43:42 +00:00
|
|
|
|
{
|
2003-02-09 08:26:00 +00:00
|
|
|
|
/* red value: sync'ed */
|
|
|
|
|
lbuf[x * dev->bpp + y * ll + UMAX_PP_RESERVE] =
|
|
|
|
|
dev->buf[x + y * ll + 2 * dev->tw + UMAX_PP_RESERVE];
|
|
|
|
|
/* green value, +delta line ahead of sync */
|
|
|
|
|
lbuf[x * dev->bpp + y * ll + 1 + UMAX_PP_RESERVE] =
|
|
|
|
|
dev->buf[x + (y - delta) * ll + dev->tw +
|
|
|
|
|
UMAX_PP_RESERVE];
|
|
|
|
|
/* blue value, +2*delta line ahead of sync */
|
|
|
|
|
lbuf[x * dev->bpp + y * ll + 2 + UMAX_PP_RESERVE] =
|
|
|
|
|
dev->buf[x + (y - 2 * delta) * ll + UMAX_PP_RESERVE];
|
1994-02-15 08:43:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-02-09 08:26:00 +00:00
|
|
|
|
/* store last data lines for next reordering */
|
|
|
|
|
if (!last)
|
|
|
|
|
memcpy (lbuf + UMAX_PP_RESERVE - 2 * delta * ll,
|
|
|
|
|
dev->buf + UMAX_PP_RESERVE + dev->buflen - 2 * delta * ll,
|
|
|
|
|
2 * delta * ll);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
free (dev->buf);
|
|
|
|
|
dev->buf = lbuf;
|
|
|
|
|
}
|
2003-02-09 08:26:00 +00:00
|
|
|
|
dev->bufread = 0;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* how much get data we can get from memory buffer */
|
|
|
|
|
length = dev->buflen - dev->bufread;
|
|
|
|
|
DBG (64, "sane_read: %ld bytes of data available\n", length);
|
|
|
|
|
if (length > max_len)
|
|
|
|
|
length = max_len;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-02-09 08:26:00 +00:00
|
|
|
|
if (dev->color == UMAX_PP_MODE_COLOR)
|
|
|
|
|
memcpy (buf, dev->buf + dev->bufread + UMAX_PP_RESERVE, length);
|
|
|
|
|
else
|
|
|
|
|
memcpy (buf, dev->buf + dev->bufread, length);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
*len = length;
|
|
|
|
|
dev->bufread += length;
|
|
|
|
|
dev->read += length;
|
1994-02-15 08:43:42 +00:00
|
|
|
|
DBG (64, "sane_read %ld bytes read\n", length);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
return SANE_STATUS_GOOD;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
sane_cancel (SANE_Handle handle)
|
|
|
|
|
{
|
|
|
|
|
Umax_PP_Device *dev = handle;
|
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
DBG (64, "sane_cancel\n");
|
|
|
|
|
if (dev->state == UMAX_PP_STATE_IDLE)
|
|
|
|
|
{
|
|
|
|
|
DBG (3, "cancel: cancelling idle \n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (dev->state == UMAX_PP_STATE_SCANNING)
|
|
|
|
|
{
|
|
|
|
|
DBG (3, "cancel: stopping current scan\n");
|
|
|
|
|
|
|
|
|
|
dev->buflen = 0;
|
|
|
|
|
|
|
|
|
|
dev->state = UMAX_PP_STATE_CANCELLED;
|
|
|
|
|
sanei_umax_pp_cancel ();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* STATE_CANCELLED */
|
|
|
|
|
DBG (2, "cancel: checking if scanner is still parking head .... \n");
|
|
|
|
|
|
|
|
|
|
rc = sanei_umax_pp_status ();
|
|
|
|
|
|
|
|
|
|
/* check if scanner busy parking */
|
|
|
|
|
if (rc == UMAX1220P_BUSY)
|
|
|
|
|
{
|
|
|
|
|
DBG (2, "cancel: scanner busy\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
dev->state = UMAX_PP_STATE_IDLE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-20 05:47:47 +00:00
|
|
|
|
SANE_Status
|
|
|
|
|
sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
DBG (129, "unused arg: handle = %p, non_blocking = %d\n",
|
|
|
|
|
handle, (int) non_blocking);
|
|
|
|
|
|
|
|
|
|
DBG (2, "set_io_mode: not supported\n");
|
|
|
|
|
|
|
|
|
|
return SANE_STATUS_UNSUPPORTED;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-20 05:47:47 +00:00
|
|
|
|
SANE_Status
|
|
|
|
|
sane_get_select_fd (SANE_Handle handle, SANE_Int * fd)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
|
2002-02-20 05:47:47 +00:00
|
|
|
|
DBG (129, "unused arg: handle = %p, fd = %p\n", handle, (void *) fd);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
DBG (2, "get_select_fd: not supported\n");
|
|
|
|
|
|
|
|
|
|
return SANE_STATUS_UNSUPPORTED;
|
|
|
|
|
}
|