xref: /third_party/backends/backend/pixma/pixma.h (revision 141cc406)
1141cc406Sopenharmony_ci/* SANE - Scanner Access Now Easy.
2141cc406Sopenharmony_ci
3141cc406Sopenharmony_ci   Copyright (C) 2011-2020 Rolf Bensch <rolf at bensch hyphen online dot de>
4141cc406Sopenharmony_ci   Copyright (C) 2007-2008 Nicolas Martin, <nicols-guest at alioth dot debian dot org>
5141cc406Sopenharmony_ci   Copyright (C) 2006-2007 Wittawat Yamwong <wittawat@web.de>
6141cc406Sopenharmony_ci
7141cc406Sopenharmony_ci   This file is part of the SANE package.
8141cc406Sopenharmony_ci
9141cc406Sopenharmony_ci   This program is free software; you can redistribute it and/or
10141cc406Sopenharmony_ci   modify it under the terms of the GNU General Public License as
11141cc406Sopenharmony_ci   published by the Free Software Foundation; either version 2 of the
12141cc406Sopenharmony_ci   License, or (at your option) any later version.
13141cc406Sopenharmony_ci
14141cc406Sopenharmony_ci   This program is distributed in the hope that it will be useful, but
15141cc406Sopenharmony_ci   WITHOUT ANY WARRANTY; without even the implied warranty of
16141cc406Sopenharmony_ci   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17141cc406Sopenharmony_ci   General Public License for more details.
18141cc406Sopenharmony_ci
19141cc406Sopenharmony_ci   You should have received a copy of the GNU General Public License
20141cc406Sopenharmony_ci   along with this program.  If not, see <https://www.gnu.org/licenses/>.
21141cc406Sopenharmony_ci
22141cc406Sopenharmony_ci   As a special exception, the authors of SANE give permission for
23141cc406Sopenharmony_ci   additional uses of the libraries contained in this release of SANE.
24141cc406Sopenharmony_ci
25141cc406Sopenharmony_ci   The exception is that, if you link a SANE library with other files
26141cc406Sopenharmony_ci   to produce an executable, this does not by itself cause the
27141cc406Sopenharmony_ci   resulting executable to be covered by the GNU General Public
28141cc406Sopenharmony_ci   License.  Your use of that executable is in no way restricted on
29141cc406Sopenharmony_ci   account of linking the SANE library code into it.
30141cc406Sopenharmony_ci
31141cc406Sopenharmony_ci   This exception does not, however, invalidate any other reasons why
32141cc406Sopenharmony_ci   the executable file might be covered by the GNU General Public
33141cc406Sopenharmony_ci   License.
34141cc406Sopenharmony_ci
35141cc406Sopenharmony_ci   If you submit changes to SANE to the maintainers to be included in
36141cc406Sopenharmony_ci   a subsequent release, you agree by submitting the changes that
37141cc406Sopenharmony_ci   those changes may be distributed with this exception intact.
38141cc406Sopenharmony_ci
39141cc406Sopenharmony_ci   If you write modifications of your own for SANE, it is your choice
40141cc406Sopenharmony_ci   whether to permit this exception to apply to your modifications.
41141cc406Sopenharmony_ci   If you do not wish that, delete this exception notice.
42141cc406Sopenharmony_ci */
43141cc406Sopenharmony_ci#ifndef PIXMA_H
44141cc406Sopenharmony_ci#define PIXMA_H
45141cc406Sopenharmony_ci
46141cc406Sopenharmony_ci#include "../include/sane/sane.h"
47141cc406Sopenharmony_ci
48141cc406Sopenharmony_ci
49141cc406Sopenharmony_ci/*!
50141cc406Sopenharmony_ci * \mainpage Scanner driver for Canon PIXMA MP series
51141cc406Sopenharmony_ci * \section example Sample code for application
52141cc406Sopenharmony_ci * \code
53141cc406Sopenharmony_ci *    pixma_set_debug_level(level);
54141cc406Sopenharmony_ci *    pixma_init();
55141cc406Sopenharmony_ci *    nscanners = pixma_find_scanners();
56141cc406Sopenharmony_ci *    devnr = choose_scanner(nscanners);
57141cc406Sopenharmony_ci *    scanner = pixma_open(devnr);
58141cc406Sopenharmony_ci *    setup_param(param);
59141cc406Sopenharmony_ci *    pixma_check_scan_param(scanner, param);
60141cc406Sopenharmony_ci *    do {
61141cc406Sopenharmony_ci *        if (I_need_events &&
62141cc406Sopenharmony_ci *            (ev = pixma_wait_event(scanner, timeout)) > 0) {
63141cc406Sopenharmony_ci *            handle_event(ev);
64141cc406Sopenharmony_ci *        }
65141cc406Sopenharmony_ci *        pixma_scan(scanner, param);
66141cc406Sopenharmony_ci *        while ((count = pixma_read_image(scanner, buf, len)) > 0) {
67141cc406Sopenharmony_ci *            write(buf, count);
68141cc406Sopenharmony_ci *            if (error_occured_in_write) {
69141cc406Sopenharmony_ci *                pixma_cancel(scanner);
70141cc406Sopenharmony_ci *            }
71141cc406Sopenharmony_ci *        }
72141cc406Sopenharmony_ci *    } while (!enough);
73141cc406Sopenharmony_ci *    pixma_close(scanner);
74141cc406Sopenharmony_ci *    pixma_cleanup();
75141cc406Sopenharmony_ci * \endcode
76141cc406Sopenharmony_ci *
77141cc406Sopenharmony_ci * <b>Note:</b> pixma_cancel() can be called asynchronously to
78141cc406Sopenharmony_ci * interrupt pixma_read_image(). It does not cancel the operation
79141cc406Sopenharmony_ci * immediately. pixma_read_image() <em>must</em> be called until it
80141cc406Sopenharmony_ci * returns zero or an error (probably \c PIXMA_ECANCELED).
81141cc406Sopenharmony_ci *
82141cc406Sopenharmony_ci * \section reference Reference
83141cc406Sopenharmony_ci * - \subpage API
84141cc406Sopenharmony_ci * - \subpage IO
85141cc406Sopenharmony_ci * - \subpage subdriver
86141cc406Sopenharmony_ci * - \subpage debug
87141cc406Sopenharmony_ci */
88141cc406Sopenharmony_ci
89141cc406Sopenharmony_ci/*!
90141cc406Sopenharmony_ci * \defgroup API The driver API
91141cc406Sopenharmony_ci * \brief The driver API.
92141cc406Sopenharmony_ci *
93141cc406Sopenharmony_ci * The return value of functions that returns \c int has the following
94141cc406Sopenharmony_ci * meaning if not otherwise specified:
95141cc406Sopenharmony_ci *    - >= 0  if succeeded
96141cc406Sopenharmony_ci *    - < 0 if failed
97141cc406Sopenharmony_ci */
98141cc406Sopenharmony_ci
99141cc406Sopenharmony_ci#ifdef HAVE_STDINT_H
100141cc406Sopenharmony_ci# include <stdint.h>		/* available in ISO C99 */
101141cc406Sopenharmony_ci#else
102141cc406Sopenharmony_ci# include <sys/types.h>
103141cc406Sopenharmony_citypedef uint8_t uint8_t;
104141cc406Sopenharmony_citypedef uint16_t uint16_t;
105141cc406Sopenharmony_citypedef uint32_t uint32_t;
106141cc406Sopenharmony_ci#endif /* HAVE_STDINT_H */
107141cc406Sopenharmony_ci
108141cc406Sopenharmony_ci#ifdef HAVE_INTTYPES_H
109141cc406Sopenharmony_ci# include <inttypes.h>          /* available in ISO C99 */
110141cc406Sopenharmony_ci#endif /* HAVE_INTTYPES_H */
111141cc406Sopenharmony_ci
112141cc406Sopenharmony_ci/** \addtogroup API
113141cc406Sopenharmony_ci *  @{ */
114141cc406Sopenharmony_ci/** Don't forget to update the backend version in the SANE Backend specification
115141cc406Sopenharmony_ci *  file: doc/descriptions/pixma.desc !!!
116141cc406Sopenharmony_ci */
117141cc406Sopenharmony_ci/** \name Version of the driver */
118141cc406Sopenharmony_ci/**@{*/
119141cc406Sopenharmony_ci#define PIXMA_VERSION_MAJOR 0
120141cc406Sopenharmony_ci#define PIXMA_VERSION_MINOR 28
121141cc406Sopenharmony_ci#define PIXMA_VERSION_BUILD 6
122141cc406Sopenharmony_ci/**@}*/
123141cc406Sopenharmony_ci
124141cc406Sopenharmony_ci/** \name Error codes */
125141cc406Sopenharmony_ci/**@{*/
126141cc406Sopenharmony_ci#define PIXMA_EIO               -1
127141cc406Sopenharmony_ci#define PIXMA_ENODEV            -2
128141cc406Sopenharmony_ci#define PIXMA_EACCES            -3
129141cc406Sopenharmony_ci#define PIXMA_ENOMEM            -4
130141cc406Sopenharmony_ci#define PIXMA_EINVAL            -5
131141cc406Sopenharmony_ci#define PIXMA_EBUSY             -6
132141cc406Sopenharmony_ci#define PIXMA_ECANCELED         -7
133141cc406Sopenharmony_ci#define PIXMA_ENOTSUP           -8
134141cc406Sopenharmony_ci#define PIXMA_ETIMEDOUT         -9
135141cc406Sopenharmony_ci#define PIXMA_EPROTO            -10
136141cc406Sopenharmony_ci#define PIXMA_EPAPER_JAMMED     -11
137141cc406Sopenharmony_ci#define PIXMA_ECOVER_OPEN       -12
138141cc406Sopenharmony_ci#define PIXMA_ENO_PAPER         -13
139141cc406Sopenharmony_ci#define PIXMA_EOF               -14
140141cc406Sopenharmony_ci/**@}*/
141141cc406Sopenharmony_ci
142141cc406Sopenharmony_ci/** \name Capabilities for using with pixma_config_t::cap */
143141cc406Sopenharmony_ci/**@{*/
144141cc406Sopenharmony_ci#define PIXMA_CAP_EASY_RGB     (1 << 0)
145141cc406Sopenharmony_ci#define PIXMA_CAP_GRAY         (1 << 1)
146141cc406Sopenharmony_ci#define PIXMA_CAP_ADF          (1 << 2)
147141cc406Sopenharmony_ci#define PIXMA_CAP_48BIT        (1 << 3)
148141cc406Sopenharmony_ci#define PIXMA_CAP_GAMMA_TABLE  (1 << 4)
149141cc406Sopenharmony_ci#define PIXMA_CAP_EVENTS       (1 << 5)
150141cc406Sopenharmony_ci#define PIXMA_CAP_TPU          (1 << 6)
151141cc406Sopenharmony_ci#define PIXMA_CAP_ADFDUP       ((1 << 7) | PIXMA_CAP_ADF)
152141cc406Sopenharmony_ci#define PIXMA_CAP_CIS          (0)
153141cc406Sopenharmony_ci#define PIXMA_CAP_CCD          (1 << 8)
154141cc406Sopenharmony_ci#define PIXMA_CAP_LINEART      (1 << 9)
155141cc406Sopenharmony_ci#define PIXMA_CAP_NEGATIVE     (1 << 10)
156141cc406Sopenharmony_ci#define PIXMA_CAP_TPUIR        ((1 << 11) | PIXMA_CAP_TPU)
157141cc406Sopenharmony_ci#define PIXMA_CAP_ADF_WAIT     (1 << 12)
158141cc406Sopenharmony_ci#define PIXMA_CAP_ADF_JPEG     (1 << 13)    /* scanner returns image as jpeg from ADF */
159141cc406Sopenharmony_ci#define PIXMA_CAP_JPEG         (1 << 14)    /* scanner always returns image as jpeg */
160141cc406Sopenharmony_ci#define PIXMA_CAP_GT_4096      (1 << 15)    /* gamma table has 4096 8-bit values
161141cc406Sopenharmony_ci                                             * only generation 1 scanners
162141cc406Sopenharmony_ci                                             * usually gamma table has 1024 16-bit values
163141cc406Sopenharmony_ci                                             */
164141cc406Sopenharmony_ci#define PIXMA_CAP_EXPERIMENT   (1 << 31)
165141cc406Sopenharmony_ci/**@}*/
166141cc406Sopenharmony_ci
167141cc406Sopenharmony_ci/** \name Button events and related information returned by pixma_wait_event() */
168141cc406Sopenharmony_ci/**@{*/
169141cc406Sopenharmony_ci#define PIXMA_EV_NONE          0
170141cc406Sopenharmony_ci#define PIXMA_EV_ACTION_MASK   (0xffffff)
171141cc406Sopenharmony_ci#define PIXMA_EV_BUTTON1       (1 << 24)
172141cc406Sopenharmony_ci#define PIXMA_EV_BUTTON2       (2 << 24)
173141cc406Sopenharmony_ci#define PIXMA_EV_TARGET_MASK   (0x0f)
174141cc406Sopenharmony_ci#define PIXMA_EV_ORIGINAL_MASK (0x0f00)
175141cc406Sopenharmony_ci#define PIXMA_EV_DPI_MASK      (0x0f0000)
176141cc406Sopenharmony_ci#define PIXMA_EV_DOC_MASK      (0xf000)
177141cc406Sopenharmony_ci#define PIXMA_EV_STAT_MASK     (0xf00000)
178141cc406Sopenharmony_ci#define PIXMA_EV_ORIENT_MASK   (0xf0)
179141cc406Sopenharmony_ci
180141cc406Sopenharmony_ci#define GET_EV_TARGET(x) (x & PIXMA_EV_TARGET_MASK)
181141cc406Sopenharmony_ci#define GET_EV_ORIGINAL(x) ( (x & PIXMA_EV_ORIGINAL_MASK) >> 8 )
182141cc406Sopenharmony_ci#define GET_EV_DPI(x) ( (x & PIXMA_EV_DPI_MASK) >> 16 )
183141cc406Sopenharmony_ci#define GET_EV_DOC(x) ( (x & PIXMA_EV_DOC_MASK) >> 12 )
184141cc406Sopenharmony_ci#define GET_EV_STAT(x) ( (x & PIXMA_EV_STAT_MASK) >> 20 )
185141cc406Sopenharmony_ci#define GET_EV_ORIENT(x) ( (x & PIXMA_EV_ORIENT_MASK) >> 4 )
186141cc406Sopenharmony_ci
187141cc406Sopenharmony_ci/**@}*/
188141cc406Sopenharmony_ci/** @} end of API group */
189141cc406Sopenharmony_ci
190141cc406Sopenharmony_ci#define PIXMA_CONFIG_FILE "pixma.conf"
191141cc406Sopenharmony_ci#define MAX_CONF_DEVICES 15
192141cc406Sopenharmony_ci
193141cc406Sopenharmony_cistruct pixma_t;
194141cc406Sopenharmony_cistruct pixma_scan_ops_t;
195141cc406Sopenharmony_cistruct pixma_scan_param_t;
196141cc406Sopenharmony_cistruct pixma_config_t;
197141cc406Sopenharmony_cistruct pixma_cmdbuf_t;
198141cc406Sopenharmony_cistruct pixma_imagebuf_t;
199141cc406Sopenharmony_cistruct pixma_device_status_t;
200141cc406Sopenharmony_ci
201141cc406Sopenharmony_citypedef struct pixma_t pixma_t;
202141cc406Sopenharmony_citypedef struct pixma_scan_ops_t pixma_scan_ops_t;
203141cc406Sopenharmony_citypedef struct pixma_scan_param_t pixma_scan_param_t;
204141cc406Sopenharmony_citypedef struct pixma_config_t pixma_config_t;
205141cc406Sopenharmony_citypedef struct pixma_cmdbuf_t pixma_cmdbuf_t;
206141cc406Sopenharmony_citypedef struct pixma_imagebuf_t pixma_imagebuf_t;
207141cc406Sopenharmony_citypedef struct pixma_device_status_t pixma_device_status_t;
208141cc406Sopenharmony_ci
209141cc406Sopenharmony_ci
210141cc406Sopenharmony_ci/** \addtogroup API
211141cc406Sopenharmony_ci *  @{ */
212141cc406Sopenharmony_ci/** String index constants */
213141cc406Sopenharmony_citypedef enum pixma_string_index_t
214141cc406Sopenharmony_ci{
215141cc406Sopenharmony_ci  PIXMA_STRING_MODEL,
216141cc406Sopenharmony_ci  PIXMA_STRING_ID,
217141cc406Sopenharmony_ci  PIXMA_STRING_LAST
218141cc406Sopenharmony_ci} pixma_string_index_t;
219141cc406Sopenharmony_ci
220141cc406Sopenharmony_ci/** Paper sources */
221141cc406Sopenharmony_citypedef enum pixma_paper_source_t
222141cc406Sopenharmony_ci{
223141cc406Sopenharmony_ci  PIXMA_SOURCE_FLATBED,
224141cc406Sopenharmony_ci  PIXMA_SOURCE_ADF,
225141cc406Sopenharmony_ci  PIXMA_SOURCE_TPU,
226141cc406Sopenharmony_ci  PIXMA_SOURCE_ADFDUP,		/* duplex */
227141cc406Sopenharmony_ci  PIXMA_SOURCE_NONE
228141cc406Sopenharmony_ci} pixma_paper_source_t;
229141cc406Sopenharmony_ci
230141cc406Sopenharmony_ci/** Scan modes */
231141cc406Sopenharmony_citypedef enum pixma_scan_mode_t
232141cc406Sopenharmony_ci{
233141cc406Sopenharmony_ci  /* standard scan modes */
234141cc406Sopenharmony_ci  PIXMA_SCAN_MODE_COLOR,
235141cc406Sopenharmony_ci  PIXMA_SCAN_MODE_GRAY,
236141cc406Sopenharmony_ci  /* TPU scan modes for negatives */
237141cc406Sopenharmony_ci  PIXMA_SCAN_MODE_NEGATIVE_COLOR,
238141cc406Sopenharmony_ci  PIXMA_SCAN_MODE_NEGATIVE_GRAY,
239141cc406Sopenharmony_ci  /* extended scan modes for 48 bit flatbed scanners */
240141cc406Sopenharmony_ci  PIXMA_SCAN_MODE_COLOR_48,
241141cc406Sopenharmony_ci  PIXMA_SCAN_MODE_GRAY_16,
242141cc406Sopenharmony_ci  /* 1 bit lineart scan mode */
243141cc406Sopenharmony_ci  PIXMA_SCAN_MODE_LINEART,
244141cc406Sopenharmony_ci  /* TPUIR scan mode */
245141cc406Sopenharmony_ci  PIXMA_SCAN_MODE_TPUIR
246141cc406Sopenharmony_ci} pixma_scan_mode_t;
247141cc406Sopenharmony_ci
248141cc406Sopenharmony_citypedef enum pixma_hardware_status_t
249141cc406Sopenharmony_ci{
250141cc406Sopenharmony_ci  PIXMA_HARDWARE_OK,
251141cc406Sopenharmony_ci  PIXMA_HARDWARE_ERROR
252141cc406Sopenharmony_ci} pixma_hardware_status_t;
253141cc406Sopenharmony_ci
254141cc406Sopenharmony_citypedef enum pixma_lamp_status_t
255141cc406Sopenharmony_ci{
256141cc406Sopenharmony_ci  PIXMA_LAMP_OK,
257141cc406Sopenharmony_ci  PIXMA_LAMP_WARMING_UP,
258141cc406Sopenharmony_ci  PIXMA_LAMP_OFF,
259141cc406Sopenharmony_ci  PIXMA_LAMP_ERROR
260141cc406Sopenharmony_ci} pixma_lamp_status_t;
261141cc406Sopenharmony_ci
262141cc406Sopenharmony_citypedef enum pixma_adf_status_t
263141cc406Sopenharmony_ci{
264141cc406Sopenharmony_ci  PIXMA_ADF_OK,
265141cc406Sopenharmony_ci  PIXMA_ADF_NO_PAPER,
266141cc406Sopenharmony_ci  PIXMA_ADF_JAMMED,
267141cc406Sopenharmony_ci  PIXMA_ADF_COVER_OPEN,
268141cc406Sopenharmony_ci  PIXMA_ADF_ERROR
269141cc406Sopenharmony_ci} pixma_adf_status_t;
270141cc406Sopenharmony_ci
271141cc406Sopenharmony_citypedef enum pixma_calibration_status_t
272141cc406Sopenharmony_ci{
273141cc406Sopenharmony_ci  PIXMA_CALIBRATION_OK,
274141cc406Sopenharmony_ci  PIXMA_CALIBRATION_IN_PROGRESS,
275141cc406Sopenharmony_ci  PIXMA_CALIBRATION_OFF,
276141cc406Sopenharmony_ci  PIXMA_CALIBRATION_ERROR
277141cc406Sopenharmony_ci} pixma_calibration_status_t;
278141cc406Sopenharmony_ci
279141cc406Sopenharmony_citypedef enum pixma_calibrate_option_t
280141cc406Sopenharmony_ci{
281141cc406Sopenharmony_ci  PIXMA_CALIBRATE_ONCE,
282141cc406Sopenharmony_ci  PIXMA_CALIBRATE_ALWAYS,
283141cc406Sopenharmony_ci  PIXMA_CALIBRATE_NEVER,
284141cc406Sopenharmony_ci  PIXMA_CALIBRATE_NUM_OPTS
285141cc406Sopenharmony_ci} pixma_calibrate_option_t;
286141cc406Sopenharmony_ci
287141cc406Sopenharmony_ci/** Device status. */
288141cc406Sopenharmony_cistruct pixma_device_status_t
289141cc406Sopenharmony_ci{
290141cc406Sopenharmony_ci  pixma_hardware_status_t hardware;
291141cc406Sopenharmony_ci  pixma_lamp_status_t lamp;
292141cc406Sopenharmony_ci  pixma_adf_status_t adf;
293141cc406Sopenharmony_ci  pixma_calibration_status_t cal;
294141cc406Sopenharmony_ci};
295141cc406Sopenharmony_ci
296141cc406Sopenharmony_ci/** Scan parameters. */
297141cc406Sopenharmony_cistruct pixma_scan_param_t
298141cc406Sopenharmony_ci{
299141cc406Sopenharmony_ci    /** Size in bytes of one image line (row).
300141cc406Sopenharmony_ci     *  line_size >= depth / 8 * channels * w <br>
301141cc406Sopenharmony_ci     *  This field will be set by pixma_check_scan_param(). */
302141cc406Sopenharmony_ci  uint64_t line_size;
303141cc406Sopenharmony_ci
304141cc406Sopenharmony_ci    /** Size in bytes of the whole image.
305141cc406Sopenharmony_ci     *  image_size = line_size * h <br>
306141cc406Sopenharmony_ci     *  This field will be set by pixma_check_scan_param(). */
307141cc406Sopenharmony_ci  uint64_t image_size;
308141cc406Sopenharmony_ci
309141cc406Sopenharmony_ci    /** Channels per pixel. 1 = grayscale and lineart, 3 = color */
310141cc406Sopenharmony_ci  unsigned channels;
311141cc406Sopenharmony_ci
312141cc406Sopenharmony_ci    /** Bits per channels.
313141cc406Sopenharmony_ci     *   1 =  1 bit B/W lineart (flatbed)
314141cc406Sopenharmony_ci     *   8 =  8 bit grayscale,
315141cc406Sopenharmony_ci     *       24 bit color (both flatbed)
316141cc406Sopenharmony_ci     *  16 = 16 bit grayscale (TPU, flatbed not implemented),
317141cc406Sopenharmony_ci     *       48 bit color (TPU, flatbed not implemented) */
318141cc406Sopenharmony_ci  unsigned depth;
319141cc406Sopenharmony_ci
320141cc406Sopenharmony_ci  /*@{ */
321141cc406Sopenharmony_ci    /** Resolution. Valid values are 75,150,300,600,1200... */
322141cc406Sopenharmony_ci  unsigned xdpi, ydpi;
323141cc406Sopenharmony_ci  /*@} */
324141cc406Sopenharmony_ci
325141cc406Sopenharmony_ci  /*! \name Scan area in pixels
326141cc406Sopenharmony_ci   * (0,0) = top left; positive x extends to the right; positive y to the
327141cc406Sopenharmony_ci   *  bottom; in pixels.
328141cc406Sopenharmony_ci   * xs is the offset in x direction of the selected scan range relative
329141cc406Sopenharmony_ci   * to the range read from the scanner and wx the width in x direction
330141cc406Sopenharmony_ci   * of the scan line read from scanner. */
331141cc406Sopenharmony_ci  /*@{ */
332141cc406Sopenharmony_ci  unsigned x, y, w, h,   xs, wx;
333141cc406Sopenharmony_ci  /*@} */
334141cc406Sopenharmony_ci
335141cc406Sopenharmony_ci  /** Flag indicating whether the offset correction for TPU scans
336141cc406Sopenharmony_ci   *  was already performed (to avoid repeated corrections).
337141cc406Sopenharmony_ci   *  Currently only used in pixma_mp800.c sub-driver */
338141cc406Sopenharmony_ci  unsigned tpu_offset_added;
339141cc406Sopenharmony_ci
340141cc406Sopenharmony_ci  /* Flag indicating if data from scanner will be in JPEG format */
341141cc406Sopenharmony_ci  unsigned mode_jpeg;
342141cc406Sopenharmony_ci
343141cc406Sopenharmony_ci  /** Flag indicating whether a software-lineart scan is in progress
344141cc406Sopenharmony_ci   *  0 = other scan
345141cc406Sopenharmony_ci   *  1 = software-lineart scan */
346141cc406Sopenharmony_ci  unsigned software_lineart;
347141cc406Sopenharmony_ci
348141cc406Sopenharmony_ci  /** Threshold for software-lineart scans */
349141cc406Sopenharmony_ci  unsigned threshold;
350141cc406Sopenharmony_ci
351141cc406Sopenharmony_ci  /** lineart threshold curve for dynamic rasterization */
352141cc406Sopenharmony_ci  unsigned threshold_curve;
353141cc406Sopenharmony_ci
354141cc406Sopenharmony_ci  /* look up table used in dynamic rasterization */
355141cc406Sopenharmony_ci  unsigned char lineart_lut[256];
356141cc406Sopenharmony_ci
357141cc406Sopenharmony_ci    /** Gamma table. 4096 entries, 12 bit => 8 bit. If \c NULL, default gamma
358141cc406Sopenharmony_ci     *  specified by subdriver will be used. */
359141cc406Sopenharmony_ci  const uint8_t *gamma_table;
360141cc406Sopenharmony_ci
361141cc406Sopenharmony_ci  /** value for auto generated gamma table */
362141cc406Sopenharmony_ci  double gamma;
363141cc406Sopenharmony_ci
364141cc406Sopenharmony_ci    /** \see #pixma_paper_source_t */
365141cc406Sopenharmony_ci  pixma_paper_source_t source;
366141cc406Sopenharmony_ci
367141cc406Sopenharmony_ci  /** \see #pixma_scan_mode_t */
368141cc406Sopenharmony_ci  pixma_scan_mode_t mode;
369141cc406Sopenharmony_ci
370141cc406Sopenharmony_ci  /** \see #pixma_calibrate_option_t */
371141cc406Sopenharmony_ci  pixma_calibrate_option_t calibrate;
372141cc406Sopenharmony_ci
373141cc406Sopenharmony_ci    /** The current page # in the same ADF scan session, 0 in non ADF */
374141cc406Sopenharmony_ci  unsigned adf_pageid;
375141cc406Sopenharmony_ci
376141cc406Sopenharmony_ci  /** adf-wait */
377141cc406Sopenharmony_ci  unsigned adf_wait;
378141cc406Sopenharmony_ci  unsigned frontend_cancel;
379141cc406Sopenharmony_ci};
380141cc406Sopenharmony_ci
381141cc406Sopenharmony_ci/** PIXMA model information */
382141cc406Sopenharmony_cistruct pixma_config_t
383141cc406Sopenharmony_ci{
384141cc406Sopenharmony_ci  /* If you change this structure, don't forget to update the device list in
385141cc406Sopenharmony_ci   * subdrivers. */
386141cc406Sopenharmony_ci  const char *name;	   /**< Model name. */
387141cc406Sopenharmony_ci  const char *model;   /**< Short model */
388141cc406Sopenharmony_ci  uint16_t vid;		     /**< USB Vendor ID */
389141cc406Sopenharmony_ci  uint16_t pid;		     /**< USB Product ID */
390141cc406Sopenharmony_ci  unsigned iface;	     /**< USB Interface number */
391141cc406Sopenharmony_ci  const pixma_scan_ops_t *ops;	  /**< Subdriver ops */
392141cc406Sopenharmony_ci  unsigned min_xdpi;   /**< Minimum horizontal resolution[DPI] */
393141cc406Sopenharmony_ci  unsigned min_xdpi_16;/**< Minimum horizontal resolution[DPI] for 16-bit scans */
394141cc406Sopenharmony_ci  unsigned xdpi;	     /**< Maximum horizontal resolution[DPI] */
395141cc406Sopenharmony_ci  unsigned ydpi;	     /**< Maximum vertical resolution[DPI] */
396141cc406Sopenharmony_ci  unsigned adftpu_min_dpi;    /**< Maximum horizontal resolution[DPI] for adf/tpu
397141cc406Sopenharmony_ci                                 *  only needed if ADF/TPU has another min. dpi value than 75 dpi */
398141cc406Sopenharmony_ci  unsigned adftpu_max_dpi;    /**< Maximum vertical resolution[DPI] for adf/tpu
399141cc406Sopenharmony_ci                                 *  only needed if ADF/TPU has another max. dpi value than xdpi */
400141cc406Sopenharmony_ci  unsigned tpuir_min_dpi;       /**< Minimum resolution[DPI] for tpu-ir
401141cc406Sopenharmony_ci                                   *  only needed if TPU-IR has another min. dpi value than 75 dpi */
402141cc406Sopenharmony_ci  unsigned tpuir_max_dpi;       /**< Maximum resolution[DPI] for tpu-ir
403141cc406Sopenharmony_ci                                   *  only needed if TPU-IR has another max. dpi value than xdpi */
404141cc406Sopenharmony_ci  unsigned width;	     /**< Maximum width of scannable area in pixels at 75DPI */
405141cc406Sopenharmony_ci  unsigned height;	   /**< Maximum height of scannable area in pixels at 75DPI */
406141cc406Sopenharmony_ci  unsigned cap;		     /**< Capability bitfield \see PIXMA_CAP_* */
407141cc406Sopenharmony_ci};
408141cc406Sopenharmony_ci
409141cc406Sopenharmony_ci
410141cc406Sopenharmony_ci/* Defined in pixma_common.c */
411141cc406Sopenharmony_ci
412141cc406Sopenharmony_ci/** Initialize the driver. It must be called before any other functions
413141cc406Sopenharmony_ci *  except pixma_set_debug_level(). */
414141cc406Sopenharmony_ciint pixma_init (void);
415141cc406Sopenharmony_ci
416141cc406Sopenharmony_ci/** Free resources allocated by the driver. */
417141cc406Sopenharmony_civoid pixma_cleanup (void);
418141cc406Sopenharmony_ci
419141cc406Sopenharmony_ci/** Set the debug level.
420141cc406Sopenharmony_ci *  \param[in] level the debug level
421141cc406Sopenharmony_ci *    - 0 No debug output at all
422141cc406Sopenharmony_ci *    - 1 Only errors and warning
423141cc406Sopenharmony_ci *    - 2 General information
424141cc406Sopenharmony_ci *    - 3 Debugging messages
425141cc406Sopenharmony_ci *    - 10 USB traffic dump */
426141cc406Sopenharmony_civoid pixma_set_debug_level (int level);
427141cc406Sopenharmony_ci
428141cc406Sopenharmony_ci/** Find scanners. The device number used in pixma_open(),
429141cc406Sopenharmony_ci *  pixma_get_device_model(), pixma_get_device_id() and
430141cc406Sopenharmony_ci *  pixma_get_device_config() must be less than the value returned by the last
431141cc406Sopenharmony_ci *  call of this function.
432141cc406Sopenharmony_ci *
433141cc406Sopenharmony_ci *  \return The number of scanners found currently. The return value is
434141cc406Sopenharmony_ci *  guaranteed to be valid until the next call to pixma_find_scanners(). */
435141cc406Sopenharmony_ciint pixma_find_scanners (const char **conf_devices, SANE_Bool local_only);
436141cc406Sopenharmony_ci
437141cc406Sopenharmony_ci/** Return the model name of the device \a devnr. */
438141cc406Sopenharmony_ciconst char *pixma_get_device_model (unsigned devnr);
439141cc406Sopenharmony_ci
440141cc406Sopenharmony_ci/** Return the unique ID of the device \a devnr. */
441141cc406Sopenharmony_ciconst char *pixma_get_device_id (unsigned devnr);
442141cc406Sopenharmony_ci
443141cc406Sopenharmony_ci/** Return the device configuration of the device \a devnr. */
444141cc406Sopenharmony_ciconst struct pixma_config_t *pixma_get_device_config (unsigned devnr);
445141cc406Sopenharmony_ci
446141cc406Sopenharmony_ci/** Open a connection to the scanner \a devnr.
447141cc406Sopenharmony_ci *  \param[in] devnr The scanner number
448141cc406Sopenharmony_ci *  \param[out] handle The device handle
449141cc406Sopenharmony_ci *  \see pixma_find_scanners() */
450141cc406Sopenharmony_ciint pixma_open (unsigned devnr, pixma_t ** handle);
451141cc406Sopenharmony_ci
452141cc406Sopenharmony_ci/** Close the connection to the scanner. The scanning process is aborted
453141cc406Sopenharmony_ci *  if necessary before the function returns. */
454141cc406Sopenharmony_civoid pixma_close (pixma_t * s);
455141cc406Sopenharmony_ci
456141cc406Sopenharmony_ci/** Initiate an image acquisition process. You must keep \a sp valid until the
457141cc406Sopenharmony_ci *  image acquisition process has finished. */
458141cc406Sopenharmony_ciint pixma_scan (pixma_t *, pixma_scan_param_t * sp);
459141cc406Sopenharmony_ci
460141cc406Sopenharmony_ci/** Read a block of image data. It blocks until there is at least one byte
461141cc406Sopenharmony_ci *  available or an error occurs.
462141cc406Sopenharmony_ci *
463141cc406Sopenharmony_ci *  \param[out] buf Pointer to the buffer
464141cc406Sopenharmony_ci *  \param[in] len Size of the buffer
465141cc406Sopenharmony_ci *
466141cc406Sopenharmony_ci *  \retval count Number of bytes written to the buffer or error. Possible
467141cc406Sopenharmony_ci *  return value:
468141cc406Sopenharmony_ci *     - count = 0 for end of image
469141cc406Sopenharmony_ci *     - count = \a len
470141cc406Sopenharmony_ci *     - 0 < count < \a len if and only if it is the last block.
471141cc406Sopenharmony_ci *     - count < 0 for error  */
472141cc406Sopenharmony_ciint pixma_read_image (pixma_t *, void *buf, unsigned len);
473141cc406Sopenharmony_ci
474141cc406Sopenharmony_ci#if 0
475141cc406Sopenharmony_ci/** Read a block of image data and write to \a fd.
476141cc406Sopenharmony_ci *  \param[in] fd output file descriptor
477141cc406Sopenharmony_ci *  \see pixma_read_image() */
478141cc406Sopenharmony_ciint pixma_read_image_write (pixma_t *, int fd);
479141cc406Sopenharmony_ci#endif
480141cc406Sopenharmony_ci
481141cc406Sopenharmony_ci/** Cancel the scanning process. No effect if no scanning process is in
482141cc406Sopenharmony_ci *  progress. It can be called asynchronously e.g. within a signal
483141cc406Sopenharmony_ci *  handle. pixma_cancel() doesn't abort the operation immediately.  It
484141cc406Sopenharmony_ci *  guarantees that the current call or, at the latest, the next call to
485141cc406Sopenharmony_ci *  pixma_read_image() will return zero or an error (probably PIXMA_ECANCELED). */
486141cc406Sopenharmony_civoid pixma_cancel (pixma_t *);
487141cc406Sopenharmony_ci
488141cc406Sopenharmony_ci/** Check the scan parameters. This function can change your parameters to
489141cc406Sopenharmony_ci *  match the device capability, e.g. adjust width and height to the available
490141cc406Sopenharmony_ci *  area.
491141cc406Sopenharmony_ci *  \return PIXMA_EINVAL for invalid parameters. */
492141cc406Sopenharmony_ciint pixma_check_scan_param (pixma_t *, pixma_scan_param_t *);
493141cc406Sopenharmony_ci
494141cc406Sopenharmony_ci/** Wait until a scanner button is pressed or it times out. It should not be
495141cc406Sopenharmony_ci *  called during image acquisition is in progress.
496141cc406Sopenharmony_ci *  \param[in] timeout in milliseconds, less than 0 means forever
497141cc406Sopenharmony_ci *  \return
498141cc406Sopenharmony_ci *   - \c PIXMA_EV_NONE if it timed out.
499141cc406Sopenharmony_ci *   - non-zero value indicates which button was pressed.
500141cc406Sopenharmony_ci *  \see PIXMA_EV_*
501141cc406Sopenharmony_ci */
502141cc406Sopenharmony_ciuint32_t pixma_wait_event (pixma_t *, int timeout);
503141cc406Sopenharmony_ci
504141cc406Sopenharmony_ci/** Activate connection to scanner */
505141cc406Sopenharmony_ciint pixma_activate_connection (pixma_t *);
506141cc406Sopenharmony_ci
507141cc406Sopenharmony_ci/** De-activate connection to scanner */
508141cc406Sopenharmony_ci
509141cc406Sopenharmony_ciint pixma_deactivate_connection (pixma_t *);
510141cc406Sopenharmony_ci
511141cc406Sopenharmony_ci
512141cc406Sopenharmony_ci/** Enable or disable background tasks. Currently, the only one task
513141cc406Sopenharmony_ci *  is submitting interrupt URB in background.
514141cc406Sopenharmony_ci *  \param[in] enabled if not zero, enable background task.
515141cc406Sopenharmony_ci *  \see pixma_set_interrupt_mode() */
516141cc406Sopenharmony_ciint pixma_enable_background (pixma_t *, int enabled);
517141cc406Sopenharmony_ci
518141cc406Sopenharmony_ci/** Read the current device status.
519141cc406Sopenharmony_ci *  \param[out] status the current device status
520141cc406Sopenharmony_ci *  \return 0 if succeeded. Otherwise, failed.
521141cc406Sopenharmony_ci */
522141cc406Sopenharmony_ciint pixma_get_device_status (pixma_t *, pixma_device_status_t * status);
523141cc406Sopenharmony_ci
524141cc406Sopenharmony_ci/** Decide whether to run calibration or not.
525141cc406Sopenharmony_ci *  Decision takes into account scan_param, source and last_source.
526141cc406Sopenharmony_ci *  \return 0x01 for calibration and 0x00 for no calibration
527141cc406Sopenharmony_ci */
528141cc406Sopenharmony_ciunsigned pixma_calc_calibrate (pixma_t *);
529141cc406Sopenharmony_ci
530141cc406Sopenharmony_ciconst char *pixma_get_string (pixma_t *, pixma_string_index_t);
531141cc406Sopenharmony_ciconst pixma_config_t *pixma_get_config (pixma_t *);
532141cc406Sopenharmony_civoid pixma_fill_gamma_table (double gamma, uint8_t * table, unsigned n);
533141cc406Sopenharmony_ciconst char *pixma_strerror (int error);
534141cc406Sopenharmony_ci
535141cc406Sopenharmony_ci/** @} end of API group */
536141cc406Sopenharmony_ci
537141cc406Sopenharmony_ci#endif
538