2005-06-27 20:07:45 +00:00
|
|
|
/* sane - Scanner Access Now Easy.
|
|
|
|
|
|
|
|
Copyright (C) 2003, 2004 Henning Meier-Geinitz <henning@meier-geinitz.de>
|
2013-01-28 21:04:37 +00:00
|
|
|
Copyright (C) 2005-2013 Stephane Voltz <stef.dev@free.fr>
|
2006-03-27 14:41:30 +00:00
|
|
|
Copyright (C) 2006 Laurent Charpentier <laurent_pubs@yahoo.com>
|
2009-01-16 15:31:10 +00:00
|
|
|
Copyright (C) 2009 Pierre Willenbrock <pierre@pirsoft.dnsalias.org>
|
2013-12-16 04:45:31 +00:00
|
|
|
|
2005-06-27 20:07:45 +00:00
|
|
|
This file is part of the SANE package.
|
2013-12-16 04:45:31 +00:00
|
|
|
|
2005-06-27 20:07:45 +00:00
|
|
|
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.
|
2013-12-16 04:45:31 +00:00
|
|
|
|
2005-06-27 20:07:45 +00:00
|
|
|
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.
|
2013-12-16 04:45:31 +00:00
|
|
|
|
2005-06-27 20:07:45 +00:00
|
|
|
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.
|
2013-12-16 04:45:31 +00:00
|
|
|
|
2005-06-27 20:07:45 +00:00
|
|
|
As a special exception, the authors of SANE give permission for
|
|
|
|
additional uses of the libraries contained in this release of SANE.
|
2013-12-16 04:45:31 +00:00
|
|
|
|
2005-06-27 20:07:45 +00:00
|
|
|
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.
|
2013-12-16 04:45:31 +00:00
|
|
|
|
2005-06-27 20:07:45 +00:00
|
|
|
This exception does not, however, invalidate any other reasons why
|
|
|
|
the executable file might be covered by the GNU General Public
|
|
|
|
License.
|
2013-12-16 04:45:31 +00:00
|
|
|
|
2005-06-27 20:07:45 +00:00
|
|
|
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.
|
2013-12-16 04:45:31 +00:00
|
|
|
|
2005-06-27 20:07:45 +00:00
|
|
|
If you write modifications of your own for SANE, it is your choice
|
|
|
|
whether to permit this exception to apply to your modifications.
|
2013-12-16 04:45:31 +00:00
|
|
|
If you do not wish that, delete this exception notice.
|
2005-06-27 20:07:45 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GENESYS_H
|
|
|
|
#define GENESYS_H
|
|
|
|
|
2019-05-19 11:46:45 +00:00
|
|
|
#ifndef BACKEND_NAME
|
|
|
|
# define BACKEND_NAME genesys
|
|
|
|
#endif
|
|
|
|
|
2019-10-01 05:42:08 +00:00
|
|
|
#include "low.h"
|
2019-06-08 11:03:47 +00:00
|
|
|
#include <queue>
|
2005-06-27 20:07:45 +00:00
|
|
|
|
2014-02-20 05:51:38 +00:00
|
|
|
#ifndef PATH_MAX
|
|
|
|
# define PATH_MAX 1024
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(_WIN32) || defined(HAVE_OS2_H)
|
|
|
|
# define PATH_SEP '\\'
|
|
|
|
#else
|
|
|
|
# define PATH_SEP '/'
|
|
|
|
#endif
|
|
|
|
|
2010-05-16 05:37:00 +00:00
|
|
|
|
2005-06-27 20:07:45 +00:00
|
|
|
#define ENABLE(OPTION) s->opt[OPTION].cap &= ~SANE_CAP_INACTIVE
|
|
|
|
#define DISABLE(OPTION) s->opt[OPTION].cap |= SANE_CAP_INACTIVE
|
|
|
|
#define IS_ACTIVE(OPTION) (((s->opt[OPTION].cap) & SANE_CAP_INACTIVE) == 0)
|
|
|
|
|
|
|
|
#define GENESYS_CONFIG_FILE "genesys.conf"
|
|
|
|
|
|
|
|
/* Maximum time for lamp warm-up */
|
2010-03-15 05:24:23 +00:00
|
|
|
#define WARMUP_TIME 65
|
2005-06-27 20:07:45 +00:00
|
|
|
|
2019-06-08 11:03:52 +00:00
|
|
|
#define STR_FLATBED "Flatbed"
|
|
|
|
#define STR_TRANSPARENCY_ADAPTER "Transparency Adapter"
|
2019-06-08 11:03:55 +00:00
|
|
|
#define STR_TRANSPARENCY_ADAPTER_INFRARED "Transparency Adapter Infrared"
|
2010-03-02 05:38:19 +00:00
|
|
|
|
2005-06-27 20:07:45 +00:00
|
|
|
#ifndef SANE_I18N
|
|
|
|
#define SANE_I18N(text) text
|
|
|
|
#endif
|
|
|
|
|
2019-10-02 09:01:28 +00:00
|
|
|
namespace genesys {
|
|
|
|
|
2005-06-27 20:07:45 +00:00
|
|
|
/** List of SANE options
|
|
|
|
*/
|
|
|
|
enum Genesys_Option
|
|
|
|
{
|
|
|
|
OPT_NUM_OPTS = 0,
|
|
|
|
|
|
|
|
OPT_MODE_GROUP,
|
|
|
|
OPT_MODE,
|
|
|
|
OPT_SOURCE,
|
|
|
|
OPT_PREVIEW,
|
|
|
|
OPT_BIT_DEPTH,
|
|
|
|
OPT_RESOLUTION,
|
|
|
|
|
|
|
|
OPT_GEOMETRY_GROUP,
|
|
|
|
OPT_TL_X, /* top-left x */
|
|
|
|
OPT_TL_Y, /* top-left y */
|
|
|
|
OPT_BR_X, /* bottom-right x */
|
|
|
|
OPT_BR_Y, /* bottom-right y */
|
|
|
|
|
2008-04-05 09:21:56 +00:00
|
|
|
/* advanced image enhancement options */
|
|
|
|
OPT_ENHANCEMENT_GROUP,
|
|
|
|
OPT_CUSTOM_GAMMA, /* toggle to enable custom gamma tables */
|
|
|
|
OPT_GAMMA_VECTOR,
|
|
|
|
OPT_GAMMA_VECTOR_R,
|
|
|
|
OPT_GAMMA_VECTOR_G,
|
|
|
|
OPT_GAMMA_VECTOR_B,
|
2010-09-06 19:02:32 +00:00
|
|
|
OPT_SWDESKEW,
|
|
|
|
OPT_SWCROP,
|
|
|
|
OPT_SWDESPECK,
|
|
|
|
OPT_DESPECK,
|
2011-06-05 19:08:37 +00:00
|
|
|
OPT_SWSKIP,
|
|
|
|
OPT_SWDEROTATE,
|
2013-08-05 19:27:39 +00:00
|
|
|
OPT_BRIGHTNESS,
|
|
|
|
OPT_CONTRAST,
|
2008-04-05 09:21:56 +00:00
|
|
|
|
2005-06-27 20:07:45 +00:00
|
|
|
OPT_EXTRAS_GROUP,
|
|
|
|
OPT_LAMP_OFF_TIME,
|
2012-06-04 19:34:39 +00:00
|
|
|
OPT_LAMP_OFF,
|
2006-03-27 14:41:30 +00:00
|
|
|
OPT_THRESHOLD,
|
2010-01-20 20:48:27 +00:00
|
|
|
OPT_THRESHOLD_CURVE,
|
2006-06-07 22:39:09 +00:00
|
|
|
OPT_DISABLE_INTERPOLATION,
|
|
|
|
OPT_COLOR_FILTER,
|
2013-08-07 04:42:14 +00:00
|
|
|
OPT_CALIBRATION_FILE,
|
2015-04-12 07:46:26 +00:00
|
|
|
OPT_EXPIRATION_TIME,
|
2009-01-16 15:31:10 +00:00
|
|
|
|
|
|
|
OPT_SENSOR_GROUP,
|
|
|
|
OPT_SCAN_SW,
|
|
|
|
OPT_FILE_SW,
|
|
|
|
OPT_EMAIL_SW,
|
|
|
|
OPT_COPY_SW,
|
|
|
|
OPT_PAGE_LOADED_SW,
|
2009-01-19 05:46:43 +00:00
|
|
|
OPT_OCR_SW,
|
|
|
|
OPT_POWER_SW,
|
2013-01-31 05:12:09 +00:00
|
|
|
OPT_EXTRA_SW,
|
2009-10-19 04:24:03 +00:00
|
|
|
OPT_NEED_CALIBRATION_SW,
|
2009-03-12 05:29:53 +00:00
|
|
|
OPT_BUTTON_GROUP,
|
2009-02-27 12:37:16 +00:00
|
|
|
OPT_CALIBRATE,
|
2009-04-16 18:39:23 +00:00
|
|
|
OPT_CLEAR_CALIBRATION,
|
2019-05-11 09:00:25 +00:00
|
|
|
OPT_FORCE_CALIBRATION,
|
2019-07-13 01:14:45 +00:00
|
|
|
OPT_IGNORE_OFFSETS,
|
2009-01-16 15:31:10 +00:00
|
|
|
|
2005-06-27 20:07:45 +00:00
|
|
|
/* must come last: */
|
|
|
|
NUM_OPTIONS
|
|
|
|
};
|
|
|
|
|
2019-06-08 11:03:47 +00:00
|
|
|
enum GenesysButtonName : unsigned {
|
|
|
|
BUTTON_SCAN_SW = 0,
|
|
|
|
BUTTON_FILE_SW,
|
|
|
|
BUTTON_EMAIL_SW,
|
|
|
|
BUTTON_COPY_SW,
|
|
|
|
BUTTON_PAGE_LOADED_SW,
|
|
|
|
BUTTON_OCR_SW,
|
|
|
|
BUTTON_POWER_SW,
|
|
|
|
BUTTON_EXTRA_SW,
|
|
|
|
NUM_BUTTONS
|
|
|
|
};
|
|
|
|
|
|
|
|
GenesysButtonName genesys_option_to_button(int option);
|
|
|
|
|
|
|
|
class GenesysButton {
|
|
|
|
public:
|
|
|
|
void write(bool value)
|
|
|
|
{
|
|
|
|
if (value == value_) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
values_to_read_.push(value);
|
|
|
|
value_ = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool read()
|
|
|
|
{
|
|
|
|
if (values_to_read_.empty()) {
|
|
|
|
return value_;
|
|
|
|
}
|
|
|
|
bool ret = values_to_read_.front();
|
|
|
|
values_to_read_.pop();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool value_ = false;
|
|
|
|
std::queue<bool> values_to_read_;
|
|
|
|
};
|
2005-06-27 20:07:45 +00:00
|
|
|
|
2009-02-27 12:37:16 +00:00
|
|
|
/** Scanner object. Should have better be called Session than Scanner
|
2005-06-27 20:07:45 +00:00
|
|
|
*/
|
2019-05-25 08:15:34 +00:00
|
|
|
struct Genesys_Scanner
|
2005-06-27 20:07:45 +00:00
|
|
|
{
|
2019-05-25 08:15:34 +00:00
|
|
|
Genesys_Scanner() = default;
|
|
|
|
~Genesys_Scanner() = default;
|
|
|
|
|
|
|
|
// Next scanner in list
|
|
|
|
struct Genesys_Scanner *next;
|
|
|
|
|
|
|
|
// Low-level device object
|
|
|
|
Genesys_Device* dev = nullptr;
|
|
|
|
|
|
|
|
// SANE data
|
|
|
|
// We are currently scanning
|
2019-10-01 05:18:45 +00:00
|
|
|
bool scanning;
|
2019-05-25 08:15:34 +00:00
|
|
|
// Option descriptors
|
|
|
|
SANE_Option_Descriptor opt[NUM_OPTIONS];
|
2019-06-08 11:03:47 +00:00
|
|
|
|
2019-06-08 11:03:51 +00:00
|
|
|
// Option values
|
2019-06-08 11:03:50 +00:00
|
|
|
SANE_Word bit_depth = 0;
|
|
|
|
SANE_Word resolution = 0;
|
2019-06-08 11:03:51 +00:00
|
|
|
bool preview = false;
|
|
|
|
SANE_Word threshold = 0;
|
|
|
|
SANE_Word threshold_curve = 0;
|
|
|
|
bool disable_interpolation = false;
|
|
|
|
bool lamp_off = false;
|
|
|
|
SANE_Word lamp_off_time = 0;
|
|
|
|
bool swdeskew = false;
|
|
|
|
bool swcrop = false;
|
|
|
|
bool swdespeck = false;
|
|
|
|
bool swderotate = false;
|
|
|
|
SANE_Word swskip = 0;
|
|
|
|
SANE_Word despeck = 0;
|
|
|
|
SANE_Word contrast = 0;
|
|
|
|
SANE_Word brightness = 0;
|
|
|
|
SANE_Word expiration_time = 0;
|
|
|
|
bool custom_gamma = false;
|
2019-06-08 11:03:50 +00:00
|
|
|
|
2019-06-08 11:03:48 +00:00
|
|
|
SANE_Word pos_top_left_y = 0;
|
|
|
|
SANE_Word pos_top_left_x = 0;
|
|
|
|
SANE_Word pos_bottom_right_y = 0;
|
|
|
|
SANE_Word pos_bottom_right_x = 0;
|
|
|
|
|
2019-06-08 11:03:49 +00:00
|
|
|
std::string mode, source, color_filter;
|
|
|
|
|
|
|
|
std::string calibration_file;
|
2019-06-08 11:03:47 +00:00
|
|
|
// Button states
|
|
|
|
GenesysButton buttons[NUM_BUTTONS];
|
|
|
|
|
2019-05-25 08:15:34 +00:00
|
|
|
// SANE Parameters
|
|
|
|
SANE_Parameters params = {};
|
|
|
|
SANE_Int bpp_list[5] = {};
|
|
|
|
};
|
2005-06-27 20:07:45 +00:00
|
|
|
|
2019-07-22 23:00:42 +00:00
|
|
|
void write_calibration(std::ostream& str, Genesys_Device::Calibration& cache);
|
|
|
|
bool read_calibration(std::istream& str, Genesys_Device::Calibration& cache,
|
|
|
|
const std::string& path);
|
|
|
|
|
2019-10-02 09:01:28 +00:00
|
|
|
} // namespace genesys
|
|
|
|
|
2005-06-27 20:07:45 +00:00
|
|
|
#endif /* not GENESYS_H */
|