1141cc406Sopenharmony_ci/* sane - Scanner Access Now Easy.
2141cc406Sopenharmony_ci   Copyright (C) 2001-2012 Stéphane Voltz <stef.dev@free.fr>
3141cc406Sopenharmony_ci   This file is part of the SANE package.
4141cc406Sopenharmony_ci
5141cc406Sopenharmony_ci   This program is free software; you can redistribute it and/or
6141cc406Sopenharmony_ci   modify it under the terms of the GNU General Public License as
7141cc406Sopenharmony_ci   published by the Free Software Foundation; either version 2 of the
8141cc406Sopenharmony_ci   License, or (at your option) any later version.
9141cc406Sopenharmony_ci
10141cc406Sopenharmony_ci   This program is distributed in the hope that it will be useful, but
11141cc406Sopenharmony_ci   WITHOUT ANY WARRANTY; without even the implied warranty of
12141cc406Sopenharmony_ci   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13141cc406Sopenharmony_ci   General Public License for more details.
14141cc406Sopenharmony_ci
15141cc406Sopenharmony_ci   You should have received a copy of the GNU General Public License
16141cc406Sopenharmony_ci   along with this program.  If not, see <https://www.gnu.org/licenses/>.
17141cc406Sopenharmony_ci
18141cc406Sopenharmony_ci   As a special exception, the authors of SANE give permission for
19141cc406Sopenharmony_ci   additional uses of the libraries contained in this release of SANE.
20141cc406Sopenharmony_ci
21141cc406Sopenharmony_ci   The exception is that, if you link a SANE library with other files
22141cc406Sopenharmony_ci   to produce an executable, this does not by itself cause the
23141cc406Sopenharmony_ci   resulting executable to be covered by the GNU General Public
24141cc406Sopenharmony_ci   License.  Your use of that executable is in no way restricted on
25141cc406Sopenharmony_ci   account of linking the SANE library code into it.
26141cc406Sopenharmony_ci
27141cc406Sopenharmony_ci   This exception does not, however, invalidate any other reasons why
28141cc406Sopenharmony_ci   the executable file might be covered by the GNU General Public
29141cc406Sopenharmony_ci   License.
30141cc406Sopenharmony_ci
31141cc406Sopenharmony_ci   If you submit changes to SANE to the maintainers to be included in
32141cc406Sopenharmony_ci   a subsequent release, you agree by submitting the changes that
33141cc406Sopenharmony_ci   those changes may be distributed with this exception intact.
34141cc406Sopenharmony_ci
35141cc406Sopenharmony_ci   If you write modifications of your own for SANE, it is your choice
36141cc406Sopenharmony_ci   whether to permit this exception to apply to your modifications.
37141cc406Sopenharmony_ci   If you do not wish that, delete this exception notice.
38141cc406Sopenharmony_ci
39141cc406Sopenharmony_ci   This file implements a SANE backend for Umax PP flatbed scanners.  */
40141cc406Sopenharmony_ci
41141cc406Sopenharmony_ci#ifndef umax_pp_h
42141cc406Sopenharmony_ci#define umax_pp_h
43141cc406Sopenharmony_ci
44141cc406Sopenharmony_ci#include <sys/types.h>
45141cc406Sopenharmony_ci#include <sys/time.h>
46141cc406Sopenharmony_ci#include <../include/sane/sanei_debug.h>
47141cc406Sopenharmony_ci
48141cc406Sopenharmony_ci
49141cc406Sopenharmony_cienum Umax_PP_Option
50141cc406Sopenharmony_ci{
51141cc406Sopenharmony_ci  OPT_NUM_OPTS = 0,
52141cc406Sopenharmony_ci
53141cc406Sopenharmony_ci  OPT_MODE_GROUP,
54141cc406Sopenharmony_ci  OPT_MODE,
55141cc406Sopenharmony_ci  OPT_RESOLUTION,
56141cc406Sopenharmony_ci  OPT_PREVIEW,
57141cc406Sopenharmony_ci  OPT_GRAY_PREVIEW,
58141cc406Sopenharmony_ci
59141cc406Sopenharmony_ci  OPT_GEOMETRY_GROUP,
60141cc406Sopenharmony_ci  OPT_TL_X,			/* top-left x */
61141cc406Sopenharmony_ci  OPT_TL_Y,			/* top-left y */
62141cc406Sopenharmony_ci  OPT_BR_X,			/* bottom-right x */
63141cc406Sopenharmony_ci  OPT_BR_Y,			/* bottom-right y */
64141cc406Sopenharmony_ci
65141cc406Sopenharmony_ci  OPT_ENHANCEMENT_GROUP,
66141cc406Sopenharmony_ci
67141cc406Sopenharmony_ci  OPT_LAMP_CONTROL,
68141cc406Sopenharmony_ci  OPT_UTA_CONTROL,
69141cc406Sopenharmony_ci
70141cc406Sopenharmony_ci  OPT_CUSTOM_GAMMA,		/* use custom gamma tables? */
71141cc406Sopenharmony_ci  /* The gamma vectors MUST appear in the order gray, red, green,
72141cc406Sopenharmony_ci     blue.  */
73141cc406Sopenharmony_ci  OPT_GAMMA_VECTOR,
74141cc406Sopenharmony_ci  OPT_GAMMA_VECTOR_R,
75141cc406Sopenharmony_ci  OPT_GAMMA_VECTOR_G,
76141cc406Sopenharmony_ci  OPT_GAMMA_VECTOR_B,
77141cc406Sopenharmony_ci
78141cc406Sopenharmony_ci  OPT_MANUAL_GAIN,
79141cc406Sopenharmony_ci  OPT_GRAY_GAIN,
80141cc406Sopenharmony_ci  OPT_RED_GAIN,
81141cc406Sopenharmony_ci  OPT_GREEN_GAIN,
82141cc406Sopenharmony_ci  OPT_BLUE_GAIN,
83141cc406Sopenharmony_ci
84141cc406Sopenharmony_ci  OPT_MANUAL_OFFSET,
85141cc406Sopenharmony_ci  OPT_GRAY_OFFSET,
86141cc406Sopenharmony_ci  OPT_RED_OFFSET,
87141cc406Sopenharmony_ci  OPT_GREEN_OFFSET,
88141cc406Sopenharmony_ci  OPT_BLUE_OFFSET,
89141cc406Sopenharmony_ci
90141cc406Sopenharmony_ci  /* must come last: */
91141cc406Sopenharmony_ci  NUM_OPTIONS
92141cc406Sopenharmony_ci};
93141cc406Sopenharmony_ci
94141cc406Sopenharmony_ci
95141cc406Sopenharmony_citypedef struct Umax_PP_Descriptor
96141cc406Sopenharmony_ci{
97141cc406Sopenharmony_ci  SANE_Device sane;
98141cc406Sopenharmony_ci
99141cc406Sopenharmony_ci  SANE_String port;
100141cc406Sopenharmony_ci  SANE_String ppdevice;
101141cc406Sopenharmony_ci
102141cc406Sopenharmony_ci  SANE_Int max_res;
103141cc406Sopenharmony_ci  SANE_Int ccd_res;
104141cc406Sopenharmony_ci  SANE_Int max_h_size;
105141cc406Sopenharmony_ci  SANE_Int max_v_size;
106141cc406Sopenharmony_ci  long int buf_size;
107141cc406Sopenharmony_ci  u_char revision;
108141cc406Sopenharmony_ci
109141cc406Sopenharmony_ci  /* default values */
110141cc406Sopenharmony_ci  SANE_Int gray_gain;
111141cc406Sopenharmony_ci  SANE_Int red_gain;
112141cc406Sopenharmony_ci  SANE_Int blue_gain;
113141cc406Sopenharmony_ci  SANE_Int green_gain;
114141cc406Sopenharmony_ci  SANE_Int gray_offset;
115141cc406Sopenharmony_ci  SANE_Int red_offset;
116141cc406Sopenharmony_ci  SANE_Int blue_offset;
117141cc406Sopenharmony_ci  SANE_Int green_offset;
118141cc406Sopenharmony_ci}
119141cc406Sopenharmony_ciUmax_PP_Descriptor;
120141cc406Sopenharmony_ci
121141cc406Sopenharmony_citypedef struct Umax_PP_Device
122141cc406Sopenharmony_ci{
123141cc406Sopenharmony_ci  struct Umax_PP_Device *next;
124141cc406Sopenharmony_ci  Umax_PP_Descriptor *desc;
125141cc406Sopenharmony_ci
126141cc406Sopenharmony_ci
127141cc406Sopenharmony_ci  SANE_Option_Descriptor opt[NUM_OPTIONS];
128141cc406Sopenharmony_ci  Option_Value val[NUM_OPTIONS];
129141cc406Sopenharmony_ci
130141cc406Sopenharmony_ci  SANE_Int gamma_table[4][256];
131141cc406Sopenharmony_ci
132141cc406Sopenharmony_ci  int state;
133141cc406Sopenharmony_ci  int mode;
134141cc406Sopenharmony_ci
135141cc406Sopenharmony_ci  int TopX;
136141cc406Sopenharmony_ci  int TopY;
137141cc406Sopenharmony_ci  int BottomX;
138141cc406Sopenharmony_ci  int BottomY;
139141cc406Sopenharmony_ci
140141cc406Sopenharmony_ci  int dpi;
141141cc406Sopenharmony_ci  int gain;
142141cc406Sopenharmony_ci  int color;
143141cc406Sopenharmony_ci  int bpp;			/* bytes per pixel */
144141cc406Sopenharmony_ci  int tw;			/* target width in pixels */
145141cc406Sopenharmony_ci  int th;			/* target height in pixels */
146141cc406Sopenharmony_ci
147141cc406Sopenharmony_ci
148141cc406Sopenharmony_ci
149141cc406Sopenharmony_ci  SANE_Byte *calibration;
150141cc406Sopenharmony_ci
151141cc406Sopenharmony_ci  SANE_Byte *buf;
152141cc406Sopenharmony_ci  long int bufsize;		/* size of read buffer                 */
153141cc406Sopenharmony_ci  long int buflen;		/* size of data length in buffer       */
154141cc406Sopenharmony_ci  long int bufread;		/* number of bytes read in the buffer  */
155141cc406Sopenharmony_ci  long int read;		/* bytes read from previous start scan */
156141cc406Sopenharmony_ci
157141cc406Sopenharmony_ci  SANE_Parameters params;
158141cc406Sopenharmony_ci  SANE_Range dpi_range;
159141cc406Sopenharmony_ci  SANE_Range x_range;
160141cc406Sopenharmony_ci  SANE_Range y_range;
161141cc406Sopenharmony_ci
162141cc406Sopenharmony_ci  SANE_Int gray_gain;
163141cc406Sopenharmony_ci  SANE_Int red_gain;
164141cc406Sopenharmony_ci  SANE_Int blue_gain;
165141cc406Sopenharmony_ci  SANE_Int green_gain;
166141cc406Sopenharmony_ci
167141cc406Sopenharmony_ci  SANE_Int gray_offset;
168141cc406Sopenharmony_ci  SANE_Int red_offset;
169141cc406Sopenharmony_ci  SANE_Int blue_offset;
170141cc406Sopenharmony_ci  SANE_Int green_offset;
171141cc406Sopenharmony_ci}
172141cc406Sopenharmony_ciUmax_PP_Device;
173141cc406Sopenharmony_ci
174141cc406Sopenharmony_ci
175141cc406Sopenharmony_ci/**
176141cc406Sopenharmony_ci * enumeration of configuration options
177141cc406Sopenharmony_ci */
178141cc406Sopenharmony_cienum Umax_PP_Configure_Option
179141cc406Sopenharmony_ci{
180141cc406Sopenharmony_ci  CFG_BUFFER = 0,
181141cc406Sopenharmony_ci  CFG_RED_GAIN,
182141cc406Sopenharmony_ci  CFG_GREEN_GAIN,
183141cc406Sopenharmony_ci  CFG_BLUE_GAIN,
184141cc406Sopenharmony_ci  CFG_RED_OFFSET,
185141cc406Sopenharmony_ci  CFG_GREEN_OFFSET,
186141cc406Sopenharmony_ci  CFG_BLUE_OFFSET,
187141cc406Sopenharmony_ci  CFG_VENDOR,
188141cc406Sopenharmony_ci  CFG_NAME,
189141cc406Sopenharmony_ci  CFG_MODEL,
190141cc406Sopenharmony_ci  CFG_ASTRA,
191141cc406Sopenharmony_ci  NUM_CFG_OPTIONS
192141cc406Sopenharmony_ci};
193141cc406Sopenharmony_ci
194141cc406Sopenharmony_ci#define DEBUG()		DBG(4, "%s(v%d.%d.%d-%s): line %d: debug exception\n", \
195141cc406Sopenharmony_ci			  __func__, SANE_CURRENT_MAJOR, SANE_CURRENT_MINOR,	\
196141cc406Sopenharmony_ci			  UMAX_PP_BUILD, UMAX_PP_STATE, __LINE__)
197141cc406Sopenharmony_ci
198141cc406Sopenharmony_ci#endif /* umax_pp_h */
199