2
* magicolor.h - SANE library for Magicolor scanners.
4
* (C) 2010 Reinhold Kainhofer <reinhold@kainhofer.com>
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>
13
* This file is part of the SANE package.
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.
24
#define BACKEND_NAME magicolor
25
#define DEBUG_NOT_STATIC
27
#include <sys/ioctl.h>
37
#ifdef NEED_SYS_TYPES_H
38
#include <sys/types.h>
43
#include "../include/sane/sane.h"
44
#include "../include/sane/sanei_debug.h"
45
#include "../include/sane/sanei_backend.h"
48
#define __func__ __FUNCTION__
50
#define __func__ "(undef)"
51
/* I cast my vote for C99... :) */
54
/* Silence the compiler for unused arguments */
55
#define NOT_USED(x) ( (void)(x) )
57
#define MAGICOLOR_CONFIG_FILE "magicolor.conf"
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 */
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 */
76
#define ADF_LOADED 0x01 /* ADF is loaded */
78
#define MAGICOLOR_CAP_DEFAULT 0
80
#define MAGICOLOR_LEVEL_1690mf 0
81
#define MAGICOLOR_LEVEL_DEFAULT MAGICOLOR_LEVEL_1690mf
82
#define MAGICOLOR_LEVEL_NET MAGICOLOR_LEVEL_1690mf
84
/* Structure holding the command set for a device */
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;
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;
106
/* Structure holding the device capabilities */
113
SANE_Int out_ep, in_ep; /* USB bulk out/in endpoints */
115
SANE_Int optical_res; /* optical resolution */
116
SANE_Range dpi_range; /* max/min resolutions */
118
SANE_Int *res_list; /* list of resolutions */
119
SANE_Int res_list_size; /* number of entries in this list */
121
SANE_Int maxDepth; /* max. color depth */
122
SANE_Word *depth_list; /* list of color depths */
124
SANE_Range brightness; /* brightness range */
126
SANE_Range fbf_x_range; /* flattbed x range */
127
SANE_Range fbf_y_range; /* flattbed y range */
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 */
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;
161
/* Structure holding the hardware description */
163
struct Magicolor_Device
165
struct Magicolor_Device *next;
173
SANE_Range *x_range; /* x range w/out extension */
174
SANE_Range *y_range; /* y range w/out extension */
176
Magicolor_Connection_Type connection;
178
struct MagicolorCmd *cmd;
179
struct MagicolorCap *cap;
182
typedef struct Magicolor_Device Magicolor_Device;
184
/* Structure holding an instance of a scanner (i.e. scanner has been opened) */
185
struct Magicolor_Scanner
187
struct Magicolor_Scanner *next;
188
struct Magicolor_Device *hw;
192
SANE_Option_Descriptor opt[NUM_OPTIONS];
193
Option_Value val[NUM_OPTIONS];
194
SANE_Parameters params;
197
SANE_Byte *buf, *end, *ptr;
201
SANE_Int width, height;
203
/* image block data */
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
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;
220
typedef struct Magicolor_Scanner Magicolor_Scanner;
230
MODE_BINARY, MODE_GRAY, MODE_COLOR