Tizen 2.1 base
[platform/upstream/hplip.git] / scan / sane / soapi.h
1 /************************************************************************************\
2
3   soapi.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   Author: David Suffield
25
26 \************************************************************************************/
27
28 #ifndef _SOAPI_H
29 #define _SOAPI_H
30
31 #define SOAP_CONTRAST_MIN -127
32 #define SOAP_CONTRAST_MAX 127
33 #define SOAP_CONTRAST_DEFAULT 0
34
35 #define MM_PER_INCH     25.4
36
37 enum SOAP_OPTION_NUMBER
38
39    SOAP_OPTION_COUNT = 0,
40    SOAP_OPTION_GROUP_SCAN_MODE,
41                    SOAP_OPTION_SCAN_MODE,
42                    SOAP_OPTION_SCAN_RESOLUTION,
43    SOAP_OPTION_GROUP_ADVANCED,
44                    SOAP_OPTION_CONTRAST,
45                    SOAP_OPTION_COMPRESSION,
46                    SOAP_OPTION_JPEG_QUALITY,
47    SOAP_OPTION_GROUP_GEOMETRY,
48                    SOAP_OPTION_TL_X,
49                    SOAP_OPTION_TL_Y,
50                    SOAP_OPTION_BR_X,
51                    SOAP_OPTION_BR_Y,
52    SOAP_OPTION_MAX
53 };
54
55 #define MAX_LIST_SIZE 32
56 #define MAX_STRING_SIZE 32
57
58 enum SCAN_FORMAT
59 {
60    SF_HPRAW = 1,
61    SF_JFIF,
62    SF_MMR,
63    SF_MAX
64 };
65
66 enum COLOR_ENTRY
67 {
68    CE_BLACK_AND_WHITE1 = 1,  /* Lineart is not supported on Horse Thief (ie: LJM1522). Windows converts GRAY8 to MONO. Ditto for us. */
69    CE_GRAY8, 
70    CE_RGB24, 
71    CE_RGB48,      /* for test only */
72    CE_MAX
73 };
74
75 enum SCAN_PARAM_OPTION
76 {
77    SPO_BEST_GUESS = 0,   /* scan not started, return "best guess" scan parameters */
78    SPO_STARTED = 1,      /* scan started, return "job resonse" or "image processor" scan parameters */ 
79    SPO_STARTED_JR = 2,   /* scan started, but return "job response" scan parameters only */
80 };
81
82 struct soap_session
83 {
84    char *tag;  /* handle identifier */
85    HPMUD_DEVICE dd;  /* hpiod device descriptor */
86    HPMUD_CHANNEL cd;  /* hpiod soap channel descriptor */
87    char uri[HPMUD_LINE_SIZE];
88    char model[HPMUD_LINE_SIZE];
89    int scan_type;
90    int user_cancel;
91    IP_IMAGE_TRAITS image_traits;   /* specified by image header */      
92
93    SANE_Option_Descriptor option[SOAP_OPTION_MAX];
94
95    SANE_String_Const scanModeList[CE_MAX];
96    enum COLOR_ENTRY scanModeMap[CE_MAX];
97    enum COLOR_ENTRY currentScanMode;
98
99    SANE_Int resolutionList[MAX_LIST_SIZE];
100    SANE_Int currentResolution;
101
102    SANE_Range contrastRange;
103    SANE_Int currentContrast;
104
105    SANE_String_Const compressionList[SF_MAX];
106    enum SCAN_FORMAT compressionMap[SF_MAX];
107    enum SCAN_FORMAT currentCompression; 
108
109    SANE_Range jpegQualityRange;
110    SANE_Int currentJpegQuality;
111
112    SANE_Range tlxRange, tlyRange, brxRange, bryRange;
113    SANE_Fixed currentTlx, currentTly, currentBrx, currentBry;
114    SANE_Fixed effectiveTlx, effectiveTly, effectiveBrx, effectiveBry;
115    SANE_Fixed min_width, min_height;
116
117    IP_HANDLE ip_handle;
118
119    int index;                    /* dime buffer index */
120    int cnt;                      /* dime buffer count */
121    unsigned char buf[16384];    /* dime buffer */
122
123    void *hpmud_handle;         /* returned by dlopen */
124    void *math_handle;         /* returned by dlopen */
125    void *bb_handle;            /* returned by dlopen */
126    void *bb_session;
127    int (*bb_open)(struct soap_session *ps);
128    int (*bb_close)(struct soap_session *ps);
129    int (*bb_get_parameters)(struct soap_session *ps, SANE_Parameters *pp, int scan_started); 
130    int (*bb_is_paper_in_adf)(struct soap_session *ps); /* 0 = no paper in adf, 1 = paper in adf, -1 = error */
131    int (*bb_start_scan)(struct soap_session *ps);
132    int (*bb_get_image_data)(struct soap_session *ps, int max_length); /* see cnt and buf above */
133    int (*bb_end_page)(struct soap_session *ps, int io_error);
134    int (*bb_end_scan)(struct soap_session *ps, int io_error);
135 /* Add new elements here. */
136 };
137
138 #endif  // _SOAPI_H