1 /************************************************************************************\
2 
3   ledmi.h - HP SANE backend support for LEDM based multi-function peripherals
4 
5   (c) 2010 Copyright HP 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   Primary Author: Naga Samrat Chowdary, Narla
25   Contributing Authors: Yashwant Kumar Sahu, Sarbeswar Meher
26 
27 \************************************************************************************/
28 
29 # ifndef _LEDMI_H
30 # define _LEDMI_H
31 
32 # include "sane.h"
33 # include "hpip.h"
34 # include "hpmud.h"
35 
36 # define LEDM_CONTRAST_MIN 0 /*According the LEDM spec*/
37 # define LEDM_CONTRAST_MAX 2000
38 # define LEDM_CONTRAST_DEFAULT 1000
39 # define LEDM_BRIGHTNESS_MIN 0
40 # define LEDM_BRIGHTNESS_MAX 2000
41 # define LEDM_BRIGHTNESS_DEFAULT 1000
42 
43 # define MM_PER_INCH     25.4
44 
45 enum LEDM_OPTION_NUMBER
46 {
47   LEDM_OPTION_COUNT = 0,
48   LEDM_OPTION_GROUP_SCAN_MODE,
49         LEDM_OPTION_SCAN_MODE,
50         LEDM_OPTION_SCAN_RESOLUTION,
51         LEDM_OPTION_INPUT_SOURCE,     /* platen, ADF, ADFDuplex */
52   LEDM_OPTION_GROUP_ADVANCED,
53         LEDM_OPTION_BRIGHTNESS,
54         LEDM_OPTION_CONTRAST,
55         LEDM_OPTION_COMPRESSION,
56         LEDM_OPTION_JPEG_QUALITY,
57   LEDM_OPTION_GROUP_GEOMETRY,
58         LEDM_OPTION_TL_X,
59         LEDM_OPTION_TL_Y,
60         LEDM_OPTION_BR_X,
61         LEDM_OPTION_BR_Y,
62   LEDM_OPTION_MAX
63 };
64 
65 # define MAX_LIST_SIZE 32
66 # define MAX_STRING_SIZE 32
67 
68 enum SCAN_FORMAT
69 {
70   SF_RAW = 1,
71   SF_JPEG,
72   SF_MAX
73 };
74 
75 enum INPUT_SOURCE
76 {
77   IS_PLATEN = 1,
78   IS_ADF,
79   IS_ADF_DUPLEX,
80   IS_MAX
81 };
82 
83 enum COLOR_ENTRY
84 {
85   CE_K1 = 1,
86   CE_GRAY8,
87   CE_COLOR8,
88   CE_MAX
89 };
90 
91 enum SCAN_PARAM_OPTION
92 {
93   SPO_BEST_GUESS = 0,             /* scan not started, return "best guess" scan parameters */
94   SPO_STARTED = 1,                /* scan started, return "job resonse" or "image processor" scan parameters */
95   SPO_STARTED_JR = 2,             /* scan started, but return "job response" scan parameters only */
96 };
97 
98 struct ledm_session
99 {
100   char *tag;                      /* handle identifier */
101   HPMUD_DEVICE dd;                /* hpiod device descriptor */
102   HPMUD_CHANNEL cd;               /* hpiod LEDM channel descriptor */
103   char uri[HPMUD_LINE_SIZE];
104   char model[HPMUD_LINE_SIZE];
105   char url[256];
106   int scan_type;
107   int user_cancel;
108 
109   IP_IMAGE_TRAITS image_traits;   /* specified by image header */
110 
111   SANE_Option_Descriptor option[LEDM_OPTION_MAX];
112 
113   SANE_String_Const inputSourceList[IS_MAX];
114   enum INPUT_SOURCE inputSourceMap[IS_MAX];
115   enum INPUT_SOURCE currentInputSource;
116 
117   SANE_Int resolutionList[MAX_LIST_SIZE];
118   SANE_Int currentResolution;
119 
120   SANE_Range contrastRange;
121   SANE_Int currentContrast;
122 
123   SANE_String_Const scanModeList[CE_MAX];
124   enum COLOR_ENTRY scanModeMap[CE_MAX];
125   enum COLOR_ENTRY currentScanMode;
126 
127   SANE_String_Const compressionList[SF_MAX];
128   enum SCAN_FORMAT compressionMap[SF_MAX];
129   enum SCAN_FORMAT currentCompression;
130 
131   SANE_Range jpegQualityRange;
132   SANE_Int currentJpegQuality;
133 
134   SANE_Range tlxRange, tlyRange, brxRange, bryRange;
135   SANE_Fixed currentTlx, currentTly, currentBrx, currentBry;
136   SANE_Fixed effectiveTlx, effectiveTly, effectiveBrx, effectiveBry;
137   SANE_Fixed min_width, min_height;
138   SANE_Int platen_resolutionList[MAX_LIST_SIZE];
139 
140   SANE_Fixed platen_min_width, platen_min_height;
141   SANE_Range platen_tlxRange, platen_tlyRange, platen_brxRange, platen_bryRange;
142   SANE_Fixed adf_min_width, adf_min_height;
143   SANE_Range adf_tlxRange, adf_tlyRange, adf_brxRange, adf_bryRange;
144   SANE_Int adf_resolutionList[MAX_LIST_SIZE];
145 
146   SANE_Range brightnessRange;
147   SANE_Int currentBrightness;
148 
149   IP_HANDLE ip_handle;
150 
151   int index;                      /* image buffer index */
152   int cnt;                        /* image buffer count */
153   unsigned char buf[32768];       /* image chunk buffer */
154 
155   void *bb_session;
156   /* Add new elements here. */
157   int job_id;
158   int page_id;
159 };
160 
161 int bb_open(struct ledm_session*);
162 int bb_close(struct ledm_session*);
163 int bb_get_parameters(struct ledm_session*, SANE_Parameters*, int);
164 int bb_is_paper_in_adf();         /* 0 = no paper in adf, 1 = paper in adf, -1 = error */
165 SANE_Status bb_start_scan(struct ledm_session*);
166 int bb_get_image_data(struct ledm_session*, int);
167 int bb_end_page(struct ledm_session*, int);
168 int bb_end_scan(struct ledm_session* , int);
169 
170 #endif  // _LEDMI_H
171