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

« back to all changes in this revision

Viewing changes to backend/magicolor.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
/*
 
2
 * magicolor.h - SANE library for Magicolor scanners.
 
3
 *
 
4
 * (C) 2010 Reinhold Kainhofer <reinhold@kainhofer.com>
 
5
 *
 
6
 * Based on the epson2 sane backend:
 
7
 * Based on Kazuhiro Sasayama previous
 
8
 * Work on epson.[ch] file from the SANE package.
 
9
 * Please see those files for original copyrights.
 
10
 * Copyright (C) 2006 Tower Technologies
 
11
 * Author: Alessandro Zummo <a.zummo@towertech.it>
 
12
 *
 
13
 * This file is part of the SANE package.
 
14
 *
 
15
 * This program is free software; you can redistribute it and/or
 
16
 * modify it under the terms of the GNU General Public License as
 
17
 * published by the Free Software Foundation, version 2.
 
18
 */
 
19
 
 
20
#ifndef magicolor_h
 
21
#define magicolor_h
 
22
 
 
23
#undef BACKEND_NAME
 
24
#define BACKEND_NAME magicolor
 
25
#define DEBUG_NOT_STATIC
 
26
 
 
27
#include <sys/ioctl.h>
 
28
 
 
29
#ifdef HAVE_STDDEF_H
 
30
#include <stddef.h>
 
31
#endif
 
32
 
 
33
#ifdef HAVE_STDLIB_H
 
34
#include <stdlib.h>
 
35
#endif
 
36
 
 
37
#ifdef NEED_SYS_TYPES_H
 
38
#include <sys/types.h>
 
39
#endif
 
40
 
 
41
#include <stdio.h>
 
42
 
 
43
#include "../include/sane/sane.h"
 
44
#include "../include/sane/sanei_debug.h"
 
45
#include "../include/sane/sanei_backend.h"
 
46
 
 
47
#ifdef __GNUC__
 
48
#define __func__ __FUNCTION__
 
49
#else
 
50
#define __func__ "(undef)"
 
51
/* I cast my vote for C99... :) */
 
52
#endif
 
53
 
 
54
/* Silence the compiler for unused arguments */
 
55
#define NOT_USED(x) ( (void)(x) )
 
56
 
 
57
#define MAGICOLOR_CONFIG_FILE "magicolor.conf"
 
58
 
 
59
#define NUM_OF_HEX_ELEMENTS (16)        /* number of hex numbers per line for data dump */
 
60
#define DEVICE_NAME_LEN (16)    /* length of device name in extended status */
 
61
 
 
62
 
 
63
 
 
64
/* misc constants */
 
65
 
 
66
#define NET     0x04
 
67
#define CMD     0x03
 
68
 
 
69
 
 
70
/* status values */
 
71
#define STATUS_READY            0x00    /* scanner is ready */
 
72
#define STATUS_ADF_JAM          0x01    /* ADF paper jam */
 
73
#define STATUS_OPEN             0x02    /* scanner is open */
 
74
#define STATUS_NOT_READY        0x03    /* scanner is in use on another interface */
 
75
 
 
76
#define ADF_LOADED              0x01    /* ADF is loaded */
 
77
 
 
78
#define MAGICOLOR_CAP_DEFAULT 0
 
79
 
 
80
#define MAGICOLOR_LEVEL_1690mf  0
 
81
#define MAGICOLOR_LEVEL_DEFAULT MAGICOLOR_LEVEL_1690mf
 
82
#define MAGICOLOR_LEVEL_NET     MAGICOLOR_LEVEL_1690mf
 
83
 
 
84
/* Structure holding the command set for a device */
 
85
struct MagicolorCmd
 
86
{
 
87
        const char *level;
 
88
        unsigned char scanner_cmd;
 
89
        unsigned char start_scanning;
 
90
        unsigned char request_error;
 
91
        unsigned char stop_scanning;
 
92
        unsigned char request_scan_parameters;
 
93
        unsigned char set_scan_parameters;
 
94
        unsigned char request_status;
 
95
        unsigned char request_data;
 
96
        unsigned char unknown1;
 
97
        unsigned char unknown2;
 
98
 
 
99
        unsigned char net_wrapper_cmd;
 
100
        unsigned char net_welcome;
 
101
        unsigned char net_lock;
 
102
        unsigned char net_lock_ack;
 
103
        unsigned char net_unlock;
 
104
};
 
105
 
 
106
/* Structure holding the device capabilities */
 
107
struct MagicolorCap
 
108
{
 
109
        unsigned int id;
 
110
        const char *cmds;
 
111
        const char *model;
 
112
        const char *OID;
 
113
        SANE_Int out_ep, in_ep;         /* USB bulk out/in endpoints */
 
114
 
 
115
        SANE_Int optical_res;           /* optical resolution */
 
116
        SANE_Range dpi_range;           /* max/min resolutions */
 
117
 
 
118
        SANE_Int *res_list;             /* list of resolutions */
 
119
        SANE_Int res_list_size;         /* number of entries in this list */
 
120
 
 
121
        SANE_Int maxDepth;              /* max. color depth */
 
122
        SANE_Word *depth_list;          /* list of color depths */
 
123
 
 
124
        SANE_Range brightness;          /* brightness range */
 
125
 
 
126
        SANE_Range fbf_x_range;         /* flattbed x range */
 
127
        SANE_Range fbf_y_range;         /* flattbed y range */
 
128
 
 
129
        SANE_Bool ADF;                  /* ADF is installed */
 
130
        SANE_Bool adf_duplex;           /* does the ADF handle duplex scanning */
 
131
        SANE_Range adf_x_range;         /* autom. document feeder x range */
 
132
        SANE_Range adf_y_range;         /* autom. document feeder y range */
 
133
};
 
134
 
 
135
enum {
 
136
        OPT_NUM_OPTS = 0,
 
137
        OPT_MODE_GROUP,
 
138
        OPT_MODE,
 
139
        OPT_BIT_DEPTH,
 
140
        OPT_BRIGHTNESS,
 
141
        OPT_RESOLUTION,
 
142
        OPT_PREVIEW,
 
143
        OPT_SOURCE,
 
144
        OPT_ADF_MODE,
 
145
        OPT_GEOMETRY_GROUP,
 
146
        OPT_TL_X,
 
147
        OPT_TL_Y,
 
148
        OPT_BR_X,
 
149
        OPT_BR_Y,
 
150
        NUM_OPTIONS
 
151
};
 
152
 
 
153
typedef enum
 
154
{       /* hardware connection to the scanner */
 
155
        SANE_MAGICOLOR_NODEV,   /* default, no HW specified yet */
 
156
        SANE_MAGICOLOR_USB,     /* USB interface */
 
157
        SANE_MAGICOLOR_NET      /* network interface */
 
158
} Magicolor_Connection_Type;
 
159
 
 
160
 
 
161
/* Structure holding the hardware description */
 
162
 
 
163
struct Magicolor_Device
 
164
{
 
165
        struct Magicolor_Device *next;
 
166
        int missing;
 
167
 
 
168
        char *name;
 
169
        char *model;
 
170
 
 
171
        SANE_Device sane;
 
172
 
 
173
        SANE_Range *x_range;    /* x range w/out extension */
 
174
        SANE_Range *y_range;    /* y range w/out extension */
 
175
 
 
176
        Magicolor_Connection_Type connection;
 
177
 
 
178
        struct MagicolorCmd *cmd;
 
179
        struct MagicolorCap *cap;
 
180
};
 
181
 
 
182
typedef struct Magicolor_Device Magicolor_Device;
 
183
 
 
184
/* Structure holding an instance of a scanner (i.e. scanner has been opened) */
 
185
struct Magicolor_Scanner
 
186
{
 
187
        struct Magicolor_Scanner *next;
 
188
        struct Magicolor_Device *hw;
 
189
 
 
190
        int fd;
 
191
 
 
192
        SANE_Option_Descriptor opt[NUM_OPTIONS];
 
193
        Option_Value val[NUM_OPTIONS];
 
194
        SANE_Parameters params;
 
195
 
 
196
        SANE_Bool eof;
 
197
        SANE_Byte *buf, *end, *ptr;
 
198
        SANE_Bool canceling;
 
199
 
 
200
        SANE_Int left, top;
 
201
        SANE_Int width, height;
 
202
 
 
203
        /* image block data */
 
204
        SANE_Int data_len;
 
205
        SANE_Int block_len;
 
206
        SANE_Int last_len;
 
207
        SANE_Int blocks;
 
208
        SANE_Int counter;
 
209
 
 
210
        /* store how many bytes of the current pixel line we have already
 
211
         * read in previous read attempts. Since each line will be padded
 
212
         * to multiples of 512 bytes, this is needed to know which bytes
 
213
         * to ignore */
 
214
        SANE_Int bytes_read_in_line;
 
215
        SANE_Byte *line_buffer;
 
216
        /* How many bytes are scanned per line (multiple of 512 bytes */
 
217
        SANE_Int scan_bytes_per_line;
 
218
};
 
219
 
 
220
typedef struct Magicolor_Scanner Magicolor_Scanner;
 
221
 
 
222
struct mode_param
 
223
{
 
224
        int flags;
 
225
        int colors;
 
226
        int depth;
 
227
};
 
228
 
 
229
enum {
 
230
        MODE_BINARY, MODE_GRAY, MODE_COLOR
 
231
};
 
232
 
 
233
#endif