Tizen 2.1 base
[platform/upstream/hplip.git] / scan / sane / soaphti.h
1 /************************************************************************************\
2
3   soaphti.h - HP SANE backend support for soap based multi-function peripherals
4
5   (c) 2006,2008 Copyright Hewlett-Packard Development Company, LP
6
7   Permission is hereby granted, free of charge, to any person obtaining a copy 
8   of this software and associated documentation files (the "Software"), to deal 
9   in the Software without restriction, including without limitation the rights 
10   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 
11   of the Software, and to permit persons to whom the Software is furnished to do 
12   so, subject to the following conditions:
13
14   The above copyright notice and this permission notice shall be included in all
15   copies or substantial portions of the Software.
16
17   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
18   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 
19   FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 
20   COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 
21   IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
22   WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24   Note when the LJM1522 input source is ADF, all pages loaded in the ADF must be scanned
25   as one complete scan job, otherwise the ADF will jam. This mean if you try to scan
26   one page only when multiple pages are loaded, the second page will jam. This is how the
27   hardware works. The Windows driver has the same limitation.
28
29   Author: David Suffield
30
31 \************************************************************************************/
32
33 #ifndef _SOAPHTI_H
34 #define _SOAPHTI_H
35
36 #define SOAP_CONTRAST_MIN -127
37 #define SOAP_CONTRAST_MAX 127
38 #define SOAP_CONTRAST_DEFAULT 0
39
40 #define MM_PER_INCH     25.4
41
42 enum SOAP_OPTION_NUMBER
43
44    SOAP_OPTION_COUNT = 0,
45    SOAP_OPTION_GROUP_SCAN_MODE,
46                    SOAP_OPTION_SCAN_MODE,
47                    SOAP_OPTION_SCAN_RESOLUTION,
48                    SOAP_OPTION_INPUT_SOURCE,     /* platen, ADF, ADFDuplex */ 
49    SOAP_OPTION_GROUP_ADVANCED,
50                    SOAP_OPTION_CONTRAST,
51                    SOAP_OPTION_COMPRESSION,
52                    SOAP_OPTION_JPEG_QUALITY,
53    SOAP_OPTION_GROUP_GEOMETRY,
54                    SOAP_OPTION_TL_X,
55                    SOAP_OPTION_TL_Y,
56                    SOAP_OPTION_BR_X,
57                    SOAP_OPTION_BR_Y,
58    SOAP_OPTION_MAX
59 };
60
61 #define MAX_LIST_SIZE 32
62 #define MAX_STRING_SIZE 32
63
64 enum SCAN_FORMAT
65 {
66    SF_HPRAW = 1,
67    SF_JFIF,
68    SF_MAX
69 };
70
71 enum INPUT_SOURCE 
72 {
73    IS_PLATEN = 1,
74    IS_ADF,
75    IS_ADF_DUPLEX,
76    IS_MAX
77 };
78
79 enum COLOR_ENTRY
80 {
81    CE_BLACK_AND_WHITE1 = 1,  /* Lineart is not supported on Horse Thief (ie: LJM1522). Windows converts GRAY8 to MONO. Ditto for us. */
82    CE_GRAY8, 
83    CE_RGB24, 
84    CE_RGB48,      /* for test only */
85    CE_MAX
86 };
87
88 enum SCAN_PARAM_OPTION
89 {
90    SPO_BEST_GUESS = 0,   /* scan not started, return "best guess" scan parameters */
91    SPO_STARTED = 1,      /* scan started, return "job resonse" or "image processor" scan parameters */ 
92    SPO_STARTED_JR = 2,   /* scan started, but return "job response" scan parameters only */
93 };
94
95 struct soap_session
96 {
97    char *tag;  /* handle identifier */
98    HPMUD_DEVICE dd;  /* hpiod device descriptor */
99    HPMUD_CHANNEL cd;  /* hpiod soap channel descriptor */
100    char uri[HPMUD_LINE_SIZE];
101    char model[HPMUD_LINE_SIZE];
102    int scan_type;
103
104    IP_IMAGE_TRAITS image_traits;   /* specified by image header */      
105
106    SANE_Option_Descriptor option[SOAP_OPTION_MAX];
107
108    SANE_String_Const scanModeList[CE_MAX];
109    enum COLOR_ENTRY scanModeMap[CE_MAX];
110    enum COLOR_ENTRY currentScanMode;
111
112    SANE_String_Const inputSourceList[IS_MAX];
113    enum INPUT_SOURCE inputSourceMap[IS_MAX];
114    enum INPUT_SOURCE currentInputSource;
115
116    SANE_Int resolutionList[MAX_LIST_SIZE];
117    SANE_Int currentResolution;
118
119    SANE_Range contrastRange;
120    SANE_Int currentContrast;
121
122    SANE_String_Const compressionList[SF_MAX];
123    enum SCAN_FORMAT compressionMap[SF_MAX];
124    enum SCAN_FORMAT currentCompression; 
125
126    SANE_Range jpegQualityRange;
127    SANE_Int currentJpegQuality;
128
129    SANE_Range tlxRange, tlyRange, brxRange, bryRange;
130    SANE_Fixed currentTlx, currentTly, currentBrx, currentBry;
131    SANE_Fixed effectiveTlx, effectiveTly, effectiveBrx, effectiveBry;
132    SANE_Fixed min_width, min_height;
133
134    SANE_Fixed platen_min_width, platen_min_height;
135    SANE_Range platen_tlxRange, platen_tlyRange, platen_brxRange, platen_bryRange;
136    SANE_Int platen_resolutionList[MAX_LIST_SIZE];
137
138    SANE_Fixed adf_min_width, adf_min_height;
139    SANE_Range adf_tlxRange, adf_tlyRange, adf_brxRange, adf_bryRange;
140    SANE_Int adf_resolutionList[MAX_LIST_SIZE];
141    
142    IP_HANDLE ip_handle;
143
144    int index;                    /* dime buffer index */
145    int cnt;                      /* dime buffer count */
146    unsigned char buf[16384];    /* dime buffer */
147    int user_cancel;
148
149    void *hpmud_handle;         /* returned by dlopen */
150    void *math_handle;         /* returned by dlopen */
151    void *bb_handle;            /* returned by dlopen */
152    void *bb_session;
153    int (*bb_open)(struct soap_session *ps);
154    int (*bb_close)(struct soap_session *ps);
155    int (*bb_get_parameters)(struct soap_session *ps, SANE_Parameters *pp, int scan_started); 
156    int (*bb_is_paper_in_adf)(struct soap_session *ps); /* 0 = no paper in adf, 1 = paper in adf, -1 = error */
157    int (*bb_start_scan)(struct soap_session *ps);
158    int (*bb_get_image_data)(struct soap_session *ps, int max_length); /* see cnt and buf above */
159    int (*bb_end_page)(struct soap_session *ps, int io_error);
160    int (*bb_end_scan)(struct soap_session *ps, int io_error);
161 /* Add new elements here. */
162 };
163
164 #endif  // _SOAPHTI_H