~ubuntu-branches/ubuntu/saucy/sane-backends/saucy

« back to all changes in this revision

Viewing changes to backend/kvs20xx.h

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2011-02-14 14:28:56 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110214142856-6gxjetg88q9zctid
Tags: 1.0.22-0ubuntu1
* New upstream release
* debian/control:
  - Use standards version 3.9.1
* debian/patches/allow_dll.d_symlinks.patch:
* debian/patches/fix_epson2_cancel.patch:
* debian/patches/fix_epson2_commands.patch:
* debian/patches/fix_xerox_mfp_color_mode.patch:
* debian/patches/genesys_disable_raw_data_log.patch:
* debian/patches/no_translations.patch:
* debian/patches/saned_exit_avahi_process.patch:
* debian/patches/scsi_perfection_2450.patch:
* debian/patches/scsi_scanjet_4c.patch:
* debian/patches/xerox_mfp_new_ids.patch:
  - Applied upstream
* debian/watch:
  - Dropped, the URL is not consistent between releases

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef __KVS20XX_H
 
2
#define __KVS20XX_H
 
3
 
 
4
/*
 
5
   Copyright (C) 2008, Panasonic Russia Ltd.
 
6
   Copyright (C) 2010, m. allan noah
 
7
*/
 
8
/*
 
9
   Panasonic KV-S20xx USB-SCSI scanners.
 
10
*/
 
11
 
 
12
#include <sys/param.h>
 
13
 
 
14
#undef  BACKEND_NAME
 
15
#define BACKEND_NAME kvs20xx
 
16
 
 
17
#define DBG_ERR  1
 
18
#define DBG_WARN 2
 
19
#define DBG_MSG  3
 
20
#define DBG_INFO 4
 
21
#define DBG_DBG  5
 
22
 
 
23
#define PANASONIC_ID    0x04da
 
24
#define KV_S2025C       0xdeadbeef
 
25
#define KV_S2045C       0xdeadbeee
 
26
#define KV_S2026C       0x1000
 
27
#define KV_S2046C       0x1001
 
28
#define KV_S2048C       0x1009
 
29
#define KV_S2028C       0x100a
 
30
#define USB     1
 
31
#define SCSI    2
 
32
#define MAX_READ_DATA_SIZE 0x10000
 
33
#define BULK_HEADER_SIZE        12
 
34
 
 
35
typedef unsigned char u8;
 
36
typedef unsigned u32;
 
37
typedef unsigned short u16;
 
38
 
 
39
#define SIDE_FRONT      0x00
 
40
#define SIDE_BACK       0x80
 
41
 
 
42
/* options */
 
43
typedef enum
 
44
{
 
45
  NUM_OPTS = 0,
 
46
 
 
47
  /* General options */
 
48
  MODE_GROUP,
 
49
  MODE,                         /* scanner modes */
 
50
  RESOLUTION,                   /* X and Y resolution */
 
51
 
 
52
  DUPLEX,                       /* Duplex mode */
 
53
  FEEDER_MODE,                  /* Feeder mode, fixed to Continous */
 
54
  LENGTHCTL,                    /* Length control mode */
 
55
  MANUALFEED,                   /* Manual feed mode */
 
56
  FEED_TIMEOUT,                 /* Feed timeout */
 
57
  DBLFEED,                      /* Double feed detection mode */
 
58
  FIT_TO_PAGE,                  /* Scanner shrinks image to fit scanned page */
 
59
 
 
60
  /* Geometry group */
 
61
  GEOMETRY_GROUP,
 
62
  PAPER_SIZE,                   /* Paper size */
 
63
  LANDSCAPE,                    /* true if landscape */
 
64
  TL_X,                         /* upper left X */
 
65
  TL_Y,                         /* upper left Y */
 
66
  BR_X,                         /* bottom right X */
 
67
  BR_Y,                         /* bottom right Y */
 
68
 
 
69
  ADVANCED_GROUP,
 
70
  BRIGHTNESS,                   /* Brightness */
 
71
  CONTRAST,                     /* Contrast */
 
72
  THRESHOLD,                    /* Binary threshold */
 
73
  IMAGE_EMPHASIS,               /* Image emphasis */
 
74
  GAMMA_CORRECTION,             /* Gamma correction */
 
75
  LAMP,                         /* Lamp -- color drop out */
 
76
  /* must come last: */
 
77
  NUM_OPTIONS
 
78
} KV_OPTION;
 
79
 
 
80
#ifndef SANE_OPTION
 
81
typedef union
 
82
{
 
83
  SANE_Bool b;          /**< bool */
 
84
  SANE_Word w;          /**< word */
 
85
  SANE_Word *wa;        /**< word array */
 
86
  SANE_String s;        /**< string */
 
87
}
 
88
Option_Value;
 
89
#define SANE_OPTION 1
 
90
#endif
 
91
 
 
92
struct scanner
 
93
{
 
94
  unsigned id;
 
95
  int scanning;
 
96
  int page;
 
97
  int side;
 
98
  int bus;
 
99
  SANE_Int file;
 
100
  SANE_Option_Descriptor opt[NUM_OPTIONS];
 
101
  Option_Value val[NUM_OPTIONS];
 
102
  SANE_Parameters params;
 
103
  u8 *buffer;
 
104
  u8 *data;
 
105
  unsigned side_size;
 
106
  unsigned read;
 
107
  unsigned dummy_size;
 
108
  unsigned saved_dummy_size;
 
109
};
 
110
 
 
111
struct window
 
112
{
 
113
  u8 reserved[6];
 
114
  u16 window_descriptor_block_length;
 
115
 
 
116
  u8 window_identifier;
 
117
  u8 reserved2;
 
118
  u16 x_resolution;
 
119
  u16 y_resolution;
 
120
  u32 upper_left_x;
 
121
  u32 upper_left_y;
 
122
  u32 width;
 
123
  u32 length;
 
124
  u8 brightness;
 
125
  u8 threshold;
 
126
  u8 contrast;
 
127
  u8 image_composition;
 
128
  u8 bit_per_pixel;
 
129
  u16 halftone_pattern;
 
130
  u8 reserved3;
 
131
  u16 bit_ordering;
 
132
  u8 compression_type;
 
133
  u8 compression_argument;
 
134
  u8 reserved4[6];
 
135
 
 
136
  u8 vendor_unique_identifier;
 
137
  u8 nobuf_fstspeed_dfstop;
 
138
  u8 mirror_image;
 
139
  u8 image_emphasis;
 
140
  u8 gamma_correction;
 
141
  u8 mcd_lamp_dfeed_sens;
 
142
  u8 reserved5;
 
143
  u8 document_size;
 
144
  u32 document_width;
 
145
  u32 document_length;
 
146
  u8 ahead_deskew_dfeed_scan_area_fspeed_rshad;
 
147
  u8 continuous_scanning_pages;
 
148
  u8 automatic_threshold_mode;
 
149
  u8 automatic_separation_mode;
 
150
  u8 standard_white_level_mode;
 
151
  u8 b_wnr_noise_reduction;
 
152
  u8 mfeed_toppos_btmpos_dsepa_hsepa_dcont_rstkr;
 
153
  u8 stop_mode;
 
154
} __attribute__((__packed__));
 
155
 
 
156
void init_options (struct scanner *);
 
157
void init_window (struct scanner *s, struct window *wnd, int wnd_id);
 
158
 
 
159
static inline u16
 
160
swap_bytes16 (u16 x)
 
161
{
 
162
  return x << 8 | x >> 8;
 
163
}
 
164
static inline u32
 
165
swap_bytes32 (u32 x)
 
166
{
 
167
  return x << 24 | x >> 24 |
 
168
    (x & (u32) 0x0000ff00UL) << 8 | (x & (u32) 0x00ff0000UL) >> 8;
 
169
}
 
170
 
 
171
#if __BYTE_ORDER == __BIG_ENDIAN
 
172
static inline void
 
173
set24 (u8 * p, u32 x)
 
174
{
 
175
  p[2] = x >> 16;
 
176
  p[1] = x >> 8;
 
177
  p[0] = x >> 0;
 
178
}
 
179
 
 
180
#define cpu2be16(x) (x)
 
181
#define cpu2be32(x) (x)
 
182
#define cpu2le16(x) swap_bytes16(x)
 
183
#define cpu2le32(x) swap_bytes32(x)
 
184
#define le2cpu16(x) swap_bytes16(x)
 
185
#define le2cpu32(x) swap_bytes32(x)
 
186
#define be2cpu16(x) (x)
 
187
#define be2cpu32(x) (x)
 
188
#define BIT_ORDERING 0
 
189
#elif __BYTE_ORDER == __LITTLE_ENDIAN
 
190
static inline void
 
191
set24 (u8 * p, u32 x)
 
192
{
 
193
  p[0] = x >> 16;
 
194
  p[1] = x >> 8;
 
195
  p[2] = x >> 0;
 
196
}
 
197
 
 
198
#define cpu2le16(x) (x)
 
199
#define cpu2le32(x) (x)
 
200
#define cpu2be16(x) swap_bytes16(x)
 
201
#define cpu2be32(x) swap_bytes32(x)
 
202
#define le2cpu16(x) (x)
 
203
#define le2cpu32(x) (x)
 
204
#define be2cpu16(x) swap_bytes16(x)
 
205
#define be2cpu32(x) swap_bytes32(x)
 
206
#define BIT_ORDERING 1
 
207
#else
 
208
#error __BYTE_ORDER not defined
 
209
#endif
 
210
 
 
211
#endif /*__KVS20XX_H*/