1141cc406Sopenharmony_ci/* sane - Scanner Access Now Easy. 2141cc406Sopenharmony_ci Copyright (C) 2001-2012 Stéphane Voltz <stef.dev@free.fr> 3141cc406Sopenharmony_ci This file is part of the SANE package. 4141cc406Sopenharmony_ci 5141cc406Sopenharmony_ci This program is free software; you can redistribute it and/or 6141cc406Sopenharmony_ci modify it under the terms of the GNU General Public License as 7141cc406Sopenharmony_ci published by the Free Software Foundation; either version 2 of the 8141cc406Sopenharmony_ci License, or (at your option) any later version. 9141cc406Sopenharmony_ci 10141cc406Sopenharmony_ci This program is distributed in the hope that it will be useful, but 11141cc406Sopenharmony_ci WITHOUT ANY WARRANTY; without even the implied warranty of 12141cc406Sopenharmony_ci MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13141cc406Sopenharmony_ci General Public License for more details. 14141cc406Sopenharmony_ci 15141cc406Sopenharmony_ci You should have received a copy of the GNU General Public License 16141cc406Sopenharmony_ci along with this program. If not, see <https://www.gnu.org/licenses/>. 17141cc406Sopenharmony_ci 18141cc406Sopenharmony_ci As a special exception, the authors of SANE give permission for 19141cc406Sopenharmony_ci additional uses of the libraries contained in this release of SANE. 20141cc406Sopenharmony_ci 21141cc406Sopenharmony_ci The exception is that, if you link a SANE library with other files 22141cc406Sopenharmony_ci to produce an executable, this does not by itself cause the 23141cc406Sopenharmony_ci resulting executable to be covered by the GNU General Public 24141cc406Sopenharmony_ci License. Your use of that executable is in no way restricted on 25141cc406Sopenharmony_ci account of linking the SANE library code into it. 26141cc406Sopenharmony_ci 27141cc406Sopenharmony_ci This exception does not, however, invalidate any other reasons why 28141cc406Sopenharmony_ci the executable file might be covered by the GNU General Public 29141cc406Sopenharmony_ci License. 30141cc406Sopenharmony_ci 31141cc406Sopenharmony_ci If you submit changes to SANE to the maintainers to be included in 32141cc406Sopenharmony_ci a subsequent release, you agree by submitting the changes that 33141cc406Sopenharmony_ci those changes may be distributed with this exception intact. 34141cc406Sopenharmony_ci 35141cc406Sopenharmony_ci If you write modifications of your own for SANE, it is your choice 36141cc406Sopenharmony_ci whether to permit this exception to apply to your modifications. 37141cc406Sopenharmony_ci If you do not wish that, delete this exception notice. 38141cc406Sopenharmony_ci 39141cc406Sopenharmony_ci This file implements a SANE backend for Umax PP flatbed scanners. */ 40141cc406Sopenharmony_ci 41141cc406Sopenharmony_ci#ifdef HAVE_LINUX_PPDEV_H 42141cc406Sopenharmony_ci#include <linux/parport.h> 43141cc406Sopenharmony_ci#include <linux/ppdev.h> 44141cc406Sopenharmony_ci#include <sys/ioctl.h> 45141cc406Sopenharmony_ci#endif 46141cc406Sopenharmony_ci 47141cc406Sopenharmony_ci#include "umax_pp_low.h" 48141cc406Sopenharmony_ci 49141cc406Sopenharmony_ci#ifndef _UMAX1220P_ 50141cc406Sopenharmony_ci#define _UMAX1220P_ 51141cc406Sopenharmony_ci 52141cc406Sopenharmony_ci#define UMAX1220P_OK 0 53141cc406Sopenharmony_ci#define UMAX1220P_NOSCANNER 1 54141cc406Sopenharmony_ci#define UMAX1220P_TRANSPORT_FAILED 2 55141cc406Sopenharmony_ci#define UMAX1220P_PROBE_FAILED 3 56141cc406Sopenharmony_ci#define UMAX1220P_SCANNER_FAILED 4 57141cc406Sopenharmony_ci#define UMAX1220P_PARK_FAILED 5 58141cc406Sopenharmony_ci#define UMAX1220P_START_FAILED 6 59141cc406Sopenharmony_ci#define UMAX1220P_READ_FAILED 7 60141cc406Sopenharmony_ci#define UMAX1220P_BUSY 8 61141cc406Sopenharmony_ci 62141cc406Sopenharmony_ci/* 63141cc406Sopenharmony_ci probes the port for an umax1220p scanner 64141cc406Sopenharmony_ci initialize transport layer 65141cc406Sopenharmony_ci probe scanner 66141cc406Sopenharmony_ci 67141cc406Sopenharmony_ci if name is null, direct I/O is attempted to address given in port 68141cc406Sopenharmony_ci else ppdev is tried using the given name as device 69141cc406Sopenharmony_ci 70141cc406Sopenharmony_ci on success returns UMAX1220P_OK, 71141cc406Sopenharmony_ci else one of the error above. 72141cc406Sopenharmony_ci 73141cc406Sopenharmony_ci*/ 74141cc406Sopenharmony_ci 75141cc406Sopenharmony_ciextern int sanei_umax_pp_attach (int port, const char *name); 76141cc406Sopenharmony_ci 77141cc406Sopenharmony_ci/* 78141cc406Sopenharmony_ci recognizes 1220P from 2000P 79141cc406Sopenharmony_ci 80141cc406Sopenharmony_ci on success returns UMAX1220P_OK, 81141cc406Sopenharmony_ci else one of the error above. 82141cc406Sopenharmony_ci 83141cc406Sopenharmony_ci*/ 84141cc406Sopenharmony_ci 85141cc406Sopenharmony_ciextern int sanei_umax_pp_model (int port, int *model); 86141cc406Sopenharmony_ci 87141cc406Sopenharmony_ci 88141cc406Sopenharmony_ci/* 89141cc406Sopenharmony_ciif on=1 -> lights scanner lamp 90141cc406Sopenharmony_ciif on=0 -> lights off scanner lamp 91141cc406Sopenharmony_ci 92141cc406Sopenharmony_ci on success returns UMAX1220P_OK, 93141cc406Sopenharmony_ci else one of the error above. 94141cc406Sopenharmony_ci*/ 95141cc406Sopenharmony_ci 96141cc406Sopenharmony_ciextern int sanei_umax_pp_lamp (int on); 97141cc406Sopenharmony_ci 98141cc406Sopenharmony_ci 99141cc406Sopenharmony_ci 100141cc406Sopenharmony_ci/* 101141cc406Sopenharmony_ci probes the port for an umax1220p scanner 102141cc406Sopenharmony_ci initialize transport layer 103141cc406Sopenharmony_ci initialize scanner 104141cc406Sopenharmony_ci 105141cc406Sopenharmony_ci on success returns UMAX1220P_OK, 106141cc406Sopenharmony_ci else one of the error above. 107141cc406Sopenharmony_ci 108141cc406Sopenharmony_ci port: addr when doing direc I/O 109141cc406Sopenharmony_ci name: ppdev character device name 110141cc406Sopenharmony_ci 111141cc406Sopenharmony_ci*/ 112141cc406Sopenharmony_ci 113141cc406Sopenharmony_ciextern int sanei_umax_pp_open (int port, char *name); 114141cc406Sopenharmony_ci 115141cc406Sopenharmony_ci 116141cc406Sopenharmony_ci 117141cc406Sopenharmony_ci/* 118141cc406Sopenharmony_ci release any resource acquired during open 119141cc406Sopenharmony_ci since there may be only one scanner, no port parameter 120141cc406Sopenharmony_ci*/ 121141cc406Sopenharmony_ciextern int sanei_umax_pp_close (void); 122141cc406Sopenharmony_ci 123141cc406Sopenharmony_ci 124141cc406Sopenharmony_ci 125141cc406Sopenharmony_ci 126141cc406Sopenharmony_ci/* 127141cc406Sopenharmony_ci stops any pending action, then parks the head 128141cc406Sopenharmony_ci*/ 129141cc406Sopenharmony_ciextern int sanei_umax_pp_cancel (void); 130141cc406Sopenharmony_ci 131141cc406Sopenharmony_ci/* starts scanning: 132141cc406Sopenharmony_ci - find scanner origin 133141cc406Sopenharmony_ci - does channel gain calibration if needed 134141cc406Sopenharmony_ci - does calibration 135141cc406Sopenharmony_ci - initialize scan operation 136141cc406Sopenharmony_ci 137141cc406Sopenharmony_ci x, y, width and height are expressed in 600 dpi unit 138141cc406Sopenharmony_ci 139141cc406Sopenharmony_ci dpi must be 75, 150, 300, 600 or 1200 140141cc406Sopenharmony_ci 141141cc406Sopenharmony_ci color is true for color scan, false for gray-levels 142141cc406Sopenharmony_ci 143141cc406Sopenharmony_ci gain value is 256*red_gain+16*green_gain+blue_gain 144141cc406Sopenharmony_ci if gain is given (ie <> 0), auto gain will not be performed 145141cc406Sopenharmony_ci 146141cc406Sopenharmony_ci 147141cc406Sopenharmony_ci 148141cc406Sopenharmony_ci returns UMAX1220P_OK on success, or one of the error above 149141cc406Sopenharmony_ci if successful, rbpp holds bytes/pixel, rth the height and rtw 150141cc406Sopenharmony_ci the width of scanned area expressed in pixels 151141cc406Sopenharmony_ci*/ 152141cc406Sopenharmony_ciextern int sanei_umax_pp_start (int x, int y, int width, int height, int dpi, 153141cc406Sopenharmony_ci int color, int autoset, int gain, 154141cc406Sopenharmony_ci int offset, int *rbpp, int *rtw, int *rth); 155141cc406Sopenharmony_ci 156141cc406Sopenharmony_ci 157141cc406Sopenharmony_ci/* reads one block of data from scanner 158141cc406Sopenharmony_ci returns UMAX1220P_OK on success, or UMAX1220P_READ_FAILED on error 159141cc406Sopenharmony_ci it also sets internal cancel flag on error 160141cc406Sopenharmony_ci 161141cc406Sopenharmony_ci len if the length of the block needed 162141cc406Sopenharmony_ci window if the width in pixels of the scanned area 163141cc406Sopenharmony_ci dpi is the resolution, it is used to choose the best read method 164141cc406Sopenharmony_ci last is true if it is the last block of the scan 165141cc406Sopenharmony_ci buffer will hold the data read 166141cc406Sopenharmony_ci*/ 167141cc406Sopenharmony_ciextern int sanei_umax_pp_read (long len, int window, int dpi, int last, 168141cc406Sopenharmony_ci unsigned char *buffer); 169141cc406Sopenharmony_ci 170141cc406Sopenharmony_ci 171141cc406Sopenharmony_ci 172141cc406Sopenharmony_ci/* get ASIC status from scanner 173141cc406Sopenharmony_ci returns UMAX1220P_OK if scanner idle, or UMAX1220P_BUSY if 174141cc406Sopenharmony_ci scanner's motor is on 175141cc406Sopenharmony_ci*/ 176141cc406Sopenharmony_ciextern int sanei_umax_pp_status (void); 177141cc406Sopenharmony_ci 178141cc406Sopenharmony_ci/* set auto calibration 0: no, else yes */ 179141cc406Sopenharmony_ciextern void sanei_umax_pp_setauto (int mode); 180141cc406Sopenharmony_ci 181141cc406Sopenharmony_ci/* set umax astra model number */ 182141cc406Sopenharmony_ciextern void sanei_umax_pp_setastra (int val); 183141cc406Sopenharmony_ci 184141cc406Sopenharmony_ci/* set gamma tables */ 185141cc406Sopenharmony_ciextern void sanei_umax_pp_gamma (int *red, int *green, int *blue); 186141cc406Sopenharmony_ci 187141cc406Sopenharmony_ci/* sets coordinate of first usable left pixel */ 188141cc406Sopenharmony_ciextern int sanei_umax_pp_getLeft (void); 189141cc406Sopenharmony_ci#endif 190