Tizen 2.1 base
[platform/upstream/hplip.git] / scan / sane / marvelli.h
1
2 /************************************************************************************\
3
4   marvelli.h - HP SANE backend support for Marvell based multi-function peripherals
5
6   (c) 2008 Copyright Hewlett-Packard Development Company, LP
7
8   Permission is hereby granted, free of charge, to any person obtaining a copy 
9   of this software and associated documentation files (the "Software"), to deal 
10   in the Software without restriction, including without limitation the rights 
11   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 
12   of the Software, and to permit persons to whom the Software is furnished to do 
13   so, subject to the following conditions:
14
15   The above copyright notice and this permission notice shall be included in all
16   copies or substantial portions of the Software.
17
18   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
19   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 
20   FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 
21   COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 
22   IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
23   WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24   
25   Author: David Suffield, Yashwant Sahu  
26
27 \************************************************************************************/
28
29 #ifndef _MARVELLI_H
30 #define _MARVELLI_H
31
32 #define MARVELL_CONTRAST_MIN -127
33 #define MARVELL_CONTRAST_MAX 127
34 #define MARVELL_CONTRAST_DEFAULT 0
35
36 #define MM_PER_INCH     25.4
37
38 enum MARVELL_OPTION_NUMBER
39
40    MARVELL_OPTION_COUNT = 0,
41    MARVELL_OPTION_GROUP_SCAN_MODE,
42                    MARVELL_OPTION_SCAN_MODE,
43                    MARVELL_OPTION_SCAN_RESOLUTION,
44                    MARVELL_OPTION_INPUT_SOURCE,     /* platen, ADF */ 
45    MARVELL_OPTION_GROUP_ADVANCED,
46                    MARVELL_OPTION_CONTRAST,
47    MARVELL_OPTION_GROUP_GEOMETRY,
48                    MARVELL_OPTION_TL_X,
49                    MARVELL_OPTION_TL_Y,
50                    MARVELL_OPTION_BR_X,
51                    MARVELL_OPTION_BR_Y,
52    MARVELL_OPTION_MAX
53 };
54
55 #define MAX_LIST_SIZE 32
56 #define MAX_STRING_SIZE 32
57
58 enum COLOR_ENTRY
59 {
60    CE_BLACK_AND_WHITE1 = 1,
61    CE_GRAY8, 
62    CE_RGB24, 
63    CE_MAX,
64 };
65
66 enum INPUT_SOURCE 
67 {
68    IS_PLATEN = 1,
69    IS_ADF,
70    IS_MAX,
71 };
72
73 enum MARVELL_VERSION
74 {
75     MARVELL_1 = 1,
76     MARVELL_2,
77 };
78
79 struct marvell_session
80 {
81    char *tag;  /* handle identifier */
82    HPMUD_DEVICE dd;  /* hpiod device descriptor */
83    HPMUD_CHANNEL cd;  /* hpiod soap channel descriptor */
84    char uri[HPMUD_LINE_SIZE];
85    char model[HPMUD_LINE_SIZE];
86    int scan_type;
87    int is_user_cancel;
88    IP_IMAGE_TRAITS image_traits;   /* specified by image processor */      
89
90    SANE_Option_Descriptor option[MARVELL_OPTION_MAX];
91
92    SANE_String_Const scan_mode_list[CE_MAX];
93    enum COLOR_ENTRY scan_mode_map[CE_MAX];
94    enum COLOR_ENTRY current_scan_mode;
95
96    SANE_String_Const input_source_list[IS_MAX];
97    enum INPUT_SOURCE input_source_map[IS_MAX];
98    enum INPUT_SOURCE current_input_source;
99
100    SANE_Int resolution_list[MAX_LIST_SIZE];
101    SANE_Int current_resolution;
102
103    SANE_Range contrast_range;
104    SANE_Int current_contrast;
105
106    SANE_Range tlxRange, tlyRange, brxRange, bryRange;
107    SANE_Fixed currentTlx, currentTly, currentBrx, currentBry;
108    SANE_Fixed effectiveTlx, effectiveTly, effectiveBrx, effectiveBry;
109    SANE_Fixed min_width, min_height;
110
111    IP_HANDLE ip_handle;
112
113    int cnt;                   /* number bytes available in buf[] */ 
114    unsigned char buf[32768];  /* line buffer (max = 1200dpi * 8.5inches * 3pixels) */
115
116    void *hpmud_handle;         /* returned by dlopen */
117    void *bb_handle;            /* returned by dlopen */
118    void *bb_session;
119    int (*bb_open)(struct marvell_session *ps);
120    int (*bb_close)(struct marvell_session *ps);
121    int (*bb_get_parameters)(struct marvell_session *ps, SANE_Parameters *pp, int scan_started); 
122    int (*bb_is_paper_in_adf)(struct marvell_session *ps); /* 0 = no paper in adf, 1 = paper in adf, 2 = no adf, -1 = error */
123    int (*bb_start_scan)(struct marvell_session *ps);
124    int (*bb_get_image_data)(struct marvell_session *ps, int max_length); /* see cnt and buf above */
125    int (*bb_end_page)(struct marvell_session *ps, int io_error);
126    int (*bb_end_scan)(struct marvell_session *ps, int io_error);
127 /* Add new elements here. */
128    void *math_handle;         /* returned by dlopen */
129    enum HPMUD_SCANSRC scansrc;       /* 0=NA */
130    enum MARVELL_VERSION version;
131 };
132
133 #endif  // _MARVELLI_H
134
135