1 /* sane - Scanner Access Now Easy.
2    Copyright (C) 2001-2012 Stéphane Voltz <stef.dev@free.fr>
3    This file is part of the SANE package.
4 
5    This program is free software; you can redistribute it and/or
6    modify it under the terms of the GNU General Public License as
7    published by the Free Software Foundation; either version 2 of the
8    License, or (at your option) any later version.
9 
10    This program is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    General Public License for more details.
14 
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <https://www.gnu.org/licenses/>.
17 
18    As a special exception, the authors of SANE give permission for
19    additional uses of the libraries contained in this release of SANE.
20 
21    The exception is that, if you link a SANE library with other files
22    to produce an executable, this does not by itself cause the
23    resulting executable to be covered by the GNU General Public
24    License.  Your use of that executable is in no way restricted on
25    account of linking the SANE library code into it.
26 
27    This exception does not, however, invalidate any other reasons why
28    the executable file might be covered by the GNU General Public
29    License.
30 
31    If you submit changes to SANE to the maintainers to be included in
32    a subsequent release, you agree by submitting the changes that
33    those changes may be distributed with this exception intact.
34 
35    If you write modifications of your own for SANE, it is your choice
36    whether to permit this exception to apply to your modifications.
37    If you do not wish that, delete this exception notice.
38 
39    This file implements a SANE backend for Umax PP flatbed scanners.  */
40 
41 #ifndef umax_pp_h
42 #define umax_pp_h
43 
44 #include <sys/types.h>
45 #include <sys/time.h>
46 #include <../include/sane/sanei_debug.h>
47 
48 
49 enum Umax_PP_Option
50 {
51   OPT_NUM_OPTS = 0,
52 
53   OPT_MODE_GROUP,
54   OPT_MODE,
55   OPT_RESOLUTION,
56   OPT_PREVIEW,
57   OPT_GRAY_PREVIEW,
58 
59   OPT_GEOMETRY_GROUP,
60   OPT_TL_X,			/* top-left x */
61   OPT_TL_Y,			/* top-left y */
62   OPT_BR_X,			/* bottom-right x */
63   OPT_BR_Y,			/* bottom-right y */
64 
65   OPT_ENHANCEMENT_GROUP,
66 
67   OPT_LAMP_CONTROL,
68   OPT_UTA_CONTROL,
69 
70   OPT_CUSTOM_GAMMA,		/* use custom gamma tables? */
71   /* The gamma vectors MUST appear in the order gray, red, green,
72      blue.  */
73   OPT_GAMMA_VECTOR,
74   OPT_GAMMA_VECTOR_R,
75   OPT_GAMMA_VECTOR_G,
76   OPT_GAMMA_VECTOR_B,
77 
78   OPT_MANUAL_GAIN,
79   OPT_GRAY_GAIN,
80   OPT_RED_GAIN,
81   OPT_GREEN_GAIN,
82   OPT_BLUE_GAIN,
83 
84   OPT_MANUAL_OFFSET,
85   OPT_GRAY_OFFSET,
86   OPT_RED_OFFSET,
87   OPT_GREEN_OFFSET,
88   OPT_BLUE_OFFSET,
89 
90   /* must come last: */
91   NUM_OPTIONS
92 };
93 
94 
95 typedef struct Umax_PP_Descriptor
96 {
97   SANE_Device sane;
98 
99   SANE_String port;
100   SANE_String ppdevice;
101 
102   SANE_Int max_res;
103   SANE_Int ccd_res;
104   SANE_Int max_h_size;
105   SANE_Int max_v_size;
106   long int buf_size;
107   u_char revision;
108 
109   /* default values */
110   SANE_Int gray_gain;
111   SANE_Int red_gain;
112   SANE_Int blue_gain;
113   SANE_Int green_gain;
114   SANE_Int gray_offset;
115   SANE_Int red_offset;
116   SANE_Int blue_offset;
117   SANE_Int green_offset;
118 }
119 Umax_PP_Descriptor;
120 
121 typedef struct Umax_PP_Device
122 {
123   struct Umax_PP_Device *next;
124   Umax_PP_Descriptor *desc;
125 
126 
127   SANE_Option_Descriptor opt[NUM_OPTIONS];
128   Option_Value val[NUM_OPTIONS];
129 
130   SANE_Int gamma_table[4][256];
131 
132   int state;
133   int mode;
134 
135   int TopX;
136   int TopY;
137   int BottomX;
138   int BottomY;
139 
140   int dpi;
141   int gain;
142   int color;
143   int bpp;			/* bytes per pixel */
144   int tw;			/* target width in pixels */
145   int th;			/* target height in pixels */
146 
147 
148 
149   SANE_Byte *calibration;
150 
151   SANE_Byte *buf;
152   long int bufsize;		/* size of read buffer                 */
153   long int buflen;		/* size of data length in buffer       */
154   long int bufread;		/* number of bytes read in the buffer  */
155   long int read;		/* bytes read from previous start scan */
156 
157   SANE_Parameters params;
158   SANE_Range dpi_range;
159   SANE_Range x_range;
160   SANE_Range y_range;
161 
162   SANE_Int gray_gain;
163   SANE_Int red_gain;
164   SANE_Int blue_gain;
165   SANE_Int green_gain;
166 
167   SANE_Int gray_offset;
168   SANE_Int red_offset;
169   SANE_Int blue_offset;
170   SANE_Int green_offset;
171 }
172 Umax_PP_Device;
173 
174 
175 /**
176  * enumeration of configuration options
177  */
178 enum Umax_PP_Configure_Option
179 {
180   CFG_BUFFER = 0,
181   CFG_RED_GAIN,
182   CFG_GREEN_GAIN,
183   CFG_BLUE_GAIN,
184   CFG_RED_OFFSET,
185   CFG_GREEN_OFFSET,
186   CFG_BLUE_OFFSET,
187   CFG_VENDOR,
188   CFG_NAME,
189   CFG_MODEL,
190   CFG_ASTRA,
191   NUM_CFG_OPTIONS
192 };
193 
194 #define DEBUG()		DBG(4, "%s(v%d.%d.%d-%s): line %d: debug exception\n", \
195 			  __func__, SANE_CURRENT_MAJOR, V_MINOR,	\
196 			  UMAX_PP_BUILD, UMAX_PP_STATE, __LINE__)
197 
198 #endif /* umax_pp_h */
199