1 /* sane - Scanner Access Now Easy. 2 Copyright (C) 2001-2012 Stéphane Voltz <stef.dev@free.fr> 3 This file is part of the SANE package. 4 5 This program is free software; you can redistribute it and/or 6 modify it under the terms of the GNU General Public License as 7 published by the Free Software Foundation; either version 2 of the 8 License, or (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, but 11 WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <https://www.gnu.org/licenses/>. 17 18 As a special exception, the authors of SANE give permission for 19 additional uses of the libraries contained in this release of SANE. 20 21 The exception is that, if you link a SANE library with other files 22 to produce an executable, this does not by itself cause the 23 resulting executable to be covered by the GNU General Public 24 License. Your use of that executable is in no way restricted on 25 account of linking the SANE library code into it. 26 27 This exception does not, however, invalidate any other reasons why 28 the executable file might be covered by the GNU General Public 29 License. 30 31 If you submit changes to SANE to the maintainers to be included in 32 a subsequent release, you agree by submitting the changes that 33 those changes may be distributed with this exception intact. 34 35 If you write modifications of your own for SANE, it is your choice 36 whether to permit this exception to apply to your modifications. 37 If you do not wish that, delete this exception notice. 38 39 This file implements a SANE backend for Umax PP flatbed scanners. */ 40 41 #ifdef HAVE_LINUX_PPDEV_H 42 #include <linux/parport.h> 43 #include <linux/ppdev.h> 44 #include <sys/ioctl.h> 45 #endif 46 47 #include "umax_pp_low.h" 48 49 #ifndef _UMAX1220P_ 50 #define _UMAX1220P_ 51 52 #define UMAX1220P_OK 0 53 #define UMAX1220P_NOSCANNER 1 54 #define UMAX1220P_TRANSPORT_FAILED 2 55 #define UMAX1220P_PROBE_FAILED 3 56 #define UMAX1220P_SCANNER_FAILED 4 57 #define UMAX1220P_PARK_FAILED 5 58 #define UMAX1220P_START_FAILED 6 59 #define UMAX1220P_READ_FAILED 7 60 #define UMAX1220P_BUSY 8 61 62 /* 63 probes the port for an umax1220p scanner 64 initialize transport layer 65 probe scanner 66 67 if name is null, direct I/O is attempted to address given in port 68 else ppdev is tried using the given name as device 69 70 on success returns UMAX1220P_OK, 71 else one of the error above. 72 73 */ 74 75 extern int sanei_umax_pp_attach (int port, const char *name); 76 77 /* 78 recognizes 1220P from 2000P 79 80 on success returns UMAX1220P_OK, 81 else one of the error above. 82 83 */ 84 85 extern int sanei_umax_pp_model (int port, int *model); 86 87 88 /* 89 if on=1 -> lights scanner lamp 90 if on=0 -> lights off scanner lamp 91 92 on success returns UMAX1220P_OK, 93 else one of the error above. 94 */ 95 96 extern int sanei_umax_pp_lamp (int on); 97 98 99 100 /* 101 probes the port for an umax1220p scanner 102 initialize transport layer 103 initialize scanner 104 105 on success returns UMAX1220P_OK, 106 else one of the error above. 107 108 port: addr when doing direc I/O 109 name: ppdev character device name 110 111 */ 112 113 extern int sanei_umax_pp_open (int port, char *name); 114 115 116 117 /* 118 release any resource acquired during open 119 since there may be only one scanner, no port parameter 120 */ 121 extern int sanei_umax_pp_close (void); 122 123 124 125 126 /* 127 stops any pending action, then parks the head 128 */ 129 extern int sanei_umax_pp_cancel (void); 130 131 /* starts scanning: 132 - find scanner origin 133 - does channel gain calibration if needed 134 - does calibration 135 - initialize scan operation 136 137 x, y, width and height are expressed in 600 dpi unit 138 139 dpi must be 75, 150, 300, 600 or 1200 140 141 color is true for color scan, false for gray-levels 142 143 gain value is 256*red_gain+16*green_gain+blue_gain 144 if gain is given (ie <> 0), auto gain will not be performed 145 146 147 148 returns UMAX1220P_OK on success, or one of the error above 149 if successful, rbpp holds bytes/pixel, rth the height and rtw 150 the width of scanned area expressed in pixels 151 */ 152 extern int sanei_umax_pp_start (int x, int y, int width, int height, int dpi, 153 int color, int autoset, int gain, 154 int offset, int *rbpp, int *rtw, int *rth); 155 156 157 /* reads one block of data from scanner 158 returns UMAX1220P_OK on success, or UMAX1220P_READ_FAILED on error 159 it also sets internal cancel flag on error 160 161 len if the length of the block needed 162 window if the width in pixels of the scanned area 163 dpi is the resolution, it is used to choose the best read method 164 last is true if it is the last block of the scan 165 buffer will hold the data read 166 */ 167 extern int sanei_umax_pp_read (long len, int window, int dpi, int last, 168 unsigned char *buffer); 169 170 171 172 /* get ASIC status from scanner 173 returns UMAX1220P_OK if scanner idle, or UMAX1220P_BUSY if 174 scanner's motor is on 175 */ 176 extern int sanei_umax_pp_status (void); 177 178 /* set auto calibration 0: no, else yes */ 179 extern void sanei_umax_pp_setauto (int mode); 180 181 /* set umax astra model number */ 182 extern void sanei_umax_pp_setastra (int val); 183 184 /* set gamma tables */ 185 extern void sanei_umax_pp_gamma (int *red, int *green, int *blue); 186 187 /* sets coordinate of first usable left pixel */ 188 extern int sanei_umax_pp_getLeft (void); 189 #endif 190