| 
									
										
										
										
											2001-05-03 19:34:02 +00:00
										 |  |  | /* sane - Scanner Access Now Easy.
 | 
					
						
							| 
									
										
										
										
											2017-05-27 06:22:15 +00:00
										 |  |  |    Copyright (C) 2001-2012 Stéphane Voltz <stef.dev@free.fr> | 
					
						
							| 
									
										
										
										
											2001-05-03 19:34:02 +00:00
										 |  |  |    This file is part of the SANE package. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |    modify it under the terms of the GNU General Public License as | 
					
						
							|  |  |  |    published by the Free Software Foundation; either version 2 of the | 
					
						
							|  |  |  |    License, or (at your option) any later version. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    This program is distributed in the hope that it will be useful, but | 
					
						
							|  |  |  |    WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
					
						
							|  |  |  |    General Public License for more details. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |    along with this program; if not, write to the Free Software | 
					
						
							|  |  |  |    Foundation, Inc., 59 Temple Place - Suite 330, Boston, | 
					
						
							|  |  |  |    MA 02111-1307, USA. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    As a special exception, the authors of SANE give permission for | 
					
						
							|  |  |  |    additional uses of the libraries contained in this release of SANE. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    The exception is that, if you link a SANE library with other files | 
					
						
							|  |  |  |    to produce an executable, this does not by itself cause the | 
					
						
							|  |  |  |    resulting executable to be covered by the GNU General Public | 
					
						
							|  |  |  |    License.  Your use of that executable is in no way restricted on | 
					
						
							|  |  |  |    account of linking the SANE library code into it. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    This exception does not, however, invalidate any other reasons why | 
					
						
							|  |  |  |    the executable file might be covered by the GNU General Public | 
					
						
							|  |  |  |    License. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    If you submit changes to SANE to the maintainers to be included in | 
					
						
							|  |  |  |    a subsequent release, you agree by submitting the changes that | 
					
						
							|  |  |  |    those changes may be distributed with this exception intact. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    If you write modifications of your own for SANE, it is your choice | 
					
						
							|  |  |  |    whether to permit this exception to apply to your modifications. | 
					
						
							|  |  |  |    If you do not wish that, delete this exception notice. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    This file implements a SANE backend for Umax PP flatbed scanners.  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef HAVE_LINUX_PPDEV_H
 | 
					
						
							|  |  |  | #include <linux/parport.h>
 | 
					
						
							|  |  |  | #include <linux/ppdev.h>
 | 
					
						
							|  |  |  | #include <sys/ioctl.h>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "umax_pp_low.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef _UMAX1220P_
 | 
					
						
							|  |  |  | #define  _UMAX1220P_
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define UMAX1220P_OK               0
 | 
					
						
							|  |  |  | #define UMAX1220P_NOSCANNER        1
 | 
					
						
							|  |  |  | #define UMAX1220P_TRANSPORT_FAILED 2
 | 
					
						
							|  |  |  | #define UMAX1220P_PROBE_FAILED     3
 | 
					
						
							|  |  |  | #define UMAX1220P_SCANNER_FAILED   4
 | 
					
						
							|  |  |  | #define UMAX1220P_PARK_FAILED      5
 | 
					
						
							|  |  |  | #define UMAX1220P_START_FAILED     6
 | 
					
						
							|  |  |  | #define UMAX1220P_READ_FAILED      7
 | 
					
						
							|  |  |  | #define UMAX1220P_BUSY             8
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  probes the port for an umax1220p scanner | 
					
						
							|  |  |  |  initialize transport layer | 
					
						
							|  |  |  |  probe scanner | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-02-15 08:43:42 +00:00
										 |  |  |  if name is null, direct I/O is attempted to address given in port | 
					
						
							|  |  |  |  else ppdev is tried using the given name as device | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-05-03 19:34:02 +00:00
										 |  |  |  on success returns UMAX1220P_OK, | 
					
						
							|  |  |  |  else one of the error above. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-19 12:14:16 +00:00
										 |  |  | extern int sanei_umax_pp_attach (int port, const char *name); | 
					
						
							| 
									
										
										
										
											2001-05-03 19:34:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  recognizes 1220P from 2000P | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  on success returns UMAX1220P_OK, | 
					
						
							|  |  |  |  else one of the error above. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern int sanei_umax_pp_model (int port, int *model); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-27 05:27:22 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2001-05-03 19:34:02 +00:00
										 |  |  | if on=1 -> lights scanner lamp | 
					
						
							|  |  |  | if on=0 -> lights off scanner lamp | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  on success returns UMAX1220P_OK, | 
					
						
							|  |  |  |  else one of the error above. | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern int sanei_umax_pp_lamp (int on); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  probes the port for an umax1220p scanner | 
					
						
							|  |  |  |  initialize transport layer | 
					
						
							|  |  |  |  initialize scanner | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  on succes returns UMAX1220P_OK, | 
					
						
							|  |  |  |  else one of the error above. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-02-15 08:43:42 +00:00
										 |  |  |  port: addr when doing direc I/O | 
					
						
							|  |  |  |  name: ppdev character device name | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-05-03 19:34:02 +00:00
										 |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-09 05:27:39 +00:00
										 |  |  | extern int sanei_umax_pp_open (int port, char *name); | 
					
						
							| 
									
										
										
										
											2001-05-03 19:34:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-09-03 12:43:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-27 05:27:22 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2001-09-03 12:43:26 +00:00
										 |  |  | 	release any ressource acquired during open | 
					
						
							|  |  |  | 	since there may be only one scanner, no port parameter | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | extern int sanei_umax_pp_close (void); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-05-03 19:34:02 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  stops any pending action, then parks the head | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | extern int sanei_umax_pp_cancel (void); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* starts scanning:
 | 
					
						
							|  |  |  | 	- find scanner origin | 
					
						
							| 
									
										
										
										
											2004-08-25 19:51:58 +00:00
										 |  |  | 	- does channel gain calibration if needed | 
					
						
							| 
									
										
										
										
											2001-05-03 19:34:02 +00:00
										 |  |  | 	- does calibration | 
					
						
							|  |  |  | 	- initialize scan operation | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	x, y, width and height are expressed in 600 dpi unit | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	dpi must be 75, 150, 300, 600 or 1200 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	color is true for color scan, false for gray-levels | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-08-25 19:51:58 +00:00
										 |  |  | 	gain value is 256*red_gain+16*green_gain+blue_gain | 
					
						
							|  |  |  | 	if gain is given (ie <> 0), auto gain will not be performed | 
					
						
							| 
									
										
										
										
											2001-05-03 19:34:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-27 05:27:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |    returns UMAX1220P_OK on success, or one of the error above | 
					
						
							| 
									
										
										
										
											2001-05-03 19:34:02 +00:00
										 |  |  |    if successful, rbpp holds bytes/pixel, rth the height and rtw | 
					
						
							|  |  |  |    the width of scanned area expressed in pixels | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | extern int sanei_umax_pp_start (int x, int y, int width, int height, int dpi, | 
					
						
							| 
									
										
										
										
											2004-08-25 19:51:58 +00:00
										 |  |  | 				int color, int autoset, int gain, | 
					
						
							|  |  |  | 				int offset, int *rbpp, int *rtw, int *rth); | 
					
						
							| 
									
										
										
										
											2001-05-03 19:34:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* reads one block of data from scanner
 | 
					
						
							|  |  |  | 	returns UMAX1220P_OK on success, or UMAX1220P_READ_FAILED on error | 
					
						
							|  |  |  | 	it also sets internal cancel flag on error | 
					
						
							| 
									
										
										
										
											2017-05-27 05:27:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-05-03 19:34:02 +00:00
										 |  |  | 	len if the length of the block needed | 
					
						
							|  |  |  | 	window if the width in pixels of the scanned area | 
					
						
							|  |  |  | 	dpi is the resolution, it is used to choose the best read method | 
					
						
							|  |  |  | 	last is true if it is the last block of the scan | 
					
						
							|  |  |  | 	buffer will hold the data read | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | extern int sanei_umax_pp_read (long len, int window, int dpi, int last, | 
					
						
							|  |  |  | 			       unsigned char *buffer); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* get ASIC status from scanner
 | 
					
						
							|  |  |  | 	returns UMAX1220P_OK if scanner idle, or UMAX1220P_BUSY if | 
					
						
							|  |  |  | 	scanner's motor is on | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | extern int sanei_umax_pp_status (void); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-01-06 16:23:02 +00:00
										 |  |  | /* set auto calibration 0: no, else yes */ | 
					
						
							|  |  |  | extern void sanei_umax_pp_setauto (int mode); | 
					
						
							| 
									
										
										
										
											2001-05-03 19:34:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* set umax astra model number */ | 
					
						
							|  |  |  | extern void sanei_umax_pp_setastra (int val); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* set gamma tables */ | 
					
						
							|  |  |  | extern void sanei_umax_pp_gamma (int *red, int *green, int *blue); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-05-03 05:14:20 +00:00
										 |  |  | /* sets coordinate of first usable left pixel */ | 
					
						
							|  |  |  | extern int sanei_umax_pp_getLeft (void); | 
					
						
							| 
									
										
										
										
											2001-05-03 19:34:02 +00:00
										 |  |  | #endif
 |