1141cc406Sopenharmony_ci/* sane - Scanner Access Now Easy. 2141cc406Sopenharmony_ci 3141cc406Sopenharmony_ci Copyright (C) 2001-2003 Eddy De Greef <eddy_de_greef at scarlet dot be> 4141cc406Sopenharmony_ci This file is part of the SANE package. 5141cc406Sopenharmony_ci 6141cc406Sopenharmony_ci This program is free software; you can redistribute it and/or 7141cc406Sopenharmony_ci modify it under the terms of the GNU General Public License as 8141cc406Sopenharmony_ci published by the Free Software Foundation; either version 2 of the 9141cc406Sopenharmony_ci License, or (at your option) any later version. 10141cc406Sopenharmony_ci 11141cc406Sopenharmony_ci This program is distributed in the hope that it will be useful, but 12141cc406Sopenharmony_ci WITHOUT ANY WARRANTY; without even the implied warranty of 13141cc406Sopenharmony_ci MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14141cc406Sopenharmony_ci General Public License for more details. 15141cc406Sopenharmony_ci 16141cc406Sopenharmony_ci You should have received a copy of the GNU General Public License 17141cc406Sopenharmony_ci along with this program. If not, see <https://www.gnu.org/licenses/>. 18141cc406Sopenharmony_ci 19141cc406Sopenharmony_ci As a special exception, the authors of SANE give permission for 20141cc406Sopenharmony_ci additional uses of the libraries contained in this release of SANE. 21141cc406Sopenharmony_ci 22141cc406Sopenharmony_ci The exception is that, if you link a SANE library with other files 23141cc406Sopenharmony_ci to produce an executable, this does not by itself cause the 24141cc406Sopenharmony_ci resulting executable to be covered by the GNU General Public 25141cc406Sopenharmony_ci License. Your use of that executable is in no way restricted on 26141cc406Sopenharmony_ci account of linking the SANE library code into it. 27141cc406Sopenharmony_ci 28141cc406Sopenharmony_ci This exception does not, however, invalidate any other reasons why 29141cc406Sopenharmony_ci the executable file might be covered by the GNU General Public 30141cc406Sopenharmony_ci License. 31141cc406Sopenharmony_ci 32141cc406Sopenharmony_ci If you submit changes to SANE to the maintainers to be included in 33141cc406Sopenharmony_ci a subsequent release, you agree by submitting the changes that 34141cc406Sopenharmony_ci those changes may be distributed with this exception intact. 35141cc406Sopenharmony_ci 36141cc406Sopenharmony_ci If you write modifications of your own for SANE, it is your choice 37141cc406Sopenharmony_ci whether to permit this exception to apply to your modifications. 38141cc406Sopenharmony_ci If you do not wish that, delete this exception notice. 39141cc406Sopenharmony_ci 40141cc406Sopenharmony_ci This file implements a SANE backend for Mustek PP flatbed _CIS_ scanners. 41141cc406Sopenharmony_ci*/ 42141cc406Sopenharmony_ci 43141cc406Sopenharmony_ci#ifndef mustek_pp_cis_h 44141cc406Sopenharmony_ci#define mustek_pp_cis_h 45141cc406Sopenharmony_ci 46141cc406Sopenharmony_ci#include "../include/sane/sane.h" 47141cc406Sopenharmony_ci 48141cc406Sopenharmony_ci/****************************************************************************** 49141cc406Sopenharmony_ci * Read register symbols. 50141cc406Sopenharmony_ci *****************************************************************************/ 51141cc406Sopenharmony_citypedef enum { 52141cc406Sopenharmony_ci MA1015R_ASIC = 0x00, 53141cc406Sopenharmony_ci MA1015R_SCAN_VAL = 0x01, 54141cc406Sopenharmony_ci MA1015R_MOTOR = 0x02, 55141cc406Sopenharmony_ci MA1015R_BANK_COUNT = 0x03 56141cc406Sopenharmony_ci } 57141cc406Sopenharmony_ciMustek_PP_1015R_reg; 58141cc406Sopenharmony_ci 59141cc406Sopenharmony_ci/****************************************************************************** 60141cc406Sopenharmony_ci * Read register bitmask symbols. 61141cc406Sopenharmony_ci *****************************************************************************/ 62141cc406Sopenharmony_citypedef enum { 63141cc406Sopenharmony_ci MA1015B_MOTOR_HOME = 0x01, 64141cc406Sopenharmony_ci MA1015B_MOTOR_STABLE = 0x03 65141cc406Sopenharmony_ci } 66141cc406Sopenharmony_ciMustek_PP_1015R_bit; 67141cc406Sopenharmony_ci 68141cc406Sopenharmony_ci/****************************************************************************** 69141cc406Sopenharmony_ci * Write register symbols: (bank number << 4) + register number. 70141cc406Sopenharmony_ci *****************************************************************************/ 71141cc406Sopenharmony_ci 72141cc406Sopenharmony_citypedef enum { 73141cc406Sopenharmony_ci MA1015W_RED_REF = 0x00, 74141cc406Sopenharmony_ci MA1015W_GREEN_REF = 0x01, 75141cc406Sopenharmony_ci MA1015W_BLUE_REF = 0x02, 76141cc406Sopenharmony_ci MA1015W_DPI_CONTROL = 0x03, 77141cc406Sopenharmony_ci 78141cc406Sopenharmony_ci MA1015W_BYTE_COUNT_HB = 0x10, 79141cc406Sopenharmony_ci MA1015W_BYTE_COUNT_LB = 0x11, 80141cc406Sopenharmony_ci MA1015W_SKIP_COUNT = 0x12, 81141cc406Sopenharmony_ci MA1015W_EXPOSE_TIME = 0x13, 82141cc406Sopenharmony_ci 83141cc406Sopenharmony_ci MA1015W_SRAM_SOURCE_PC = 0x20, 84141cc406Sopenharmony_ci MA1015W_MOTOR_CONTROL = 0x21, 85141cc406Sopenharmony_ci MA1015W_UNKNOWN_42 = 0x22, 86141cc406Sopenharmony_ci MA1015W_UNKNOWN_82 = 0x23, 87141cc406Sopenharmony_ci 88141cc406Sopenharmony_ci MA1015W_POWER_ON_DELAY = 0x30, 89141cc406Sopenharmony_ci MA1015W_CCD_TIMING = 0x31, 90141cc406Sopenharmony_ci MA1015W_CCD_TIMING_ADJ = 0x32, 91141cc406Sopenharmony_ci MA1015W_RIGHT_BOUND = 0x33 92141cc406Sopenharmony_ci } 93141cc406Sopenharmony_ciMustek_PP_1015W_reg; 94141cc406Sopenharmony_ci 95141cc406Sopenharmony_ci 96141cc406Sopenharmony_ci/****************************************************************************** 97141cc406Sopenharmony_ci * Mustek MA1015 register tracing structure. 98141cc406Sopenharmony_ci * Can be used to trace the status of the registers of the MA1015 chipset 99141cc406Sopenharmony_ci * during debugging. Most fields are not used in production code. 100141cc406Sopenharmony_ci *****************************************************************************/ 101141cc406Sopenharmony_citypedef struct Mustek_PP_1015_Registers 102141cc406Sopenharmony_ci{ 103141cc406Sopenharmony_ci SANE_Byte in_regs[4]; 104141cc406Sopenharmony_ci SANE_Byte out_regs[4][4]; 105141cc406Sopenharmony_ci SANE_Byte channel; 106141cc406Sopenharmony_ci 107141cc406Sopenharmony_ci Mustek_PP_1015R_reg current_read_reg; 108141cc406Sopenharmony_ci SANE_Int read_count; 109141cc406Sopenharmony_ci 110141cc406Sopenharmony_ci Mustek_PP_1015W_reg current_write_reg; /* always used */ 111141cc406Sopenharmony_ci SANE_Int write_count; 112141cc406Sopenharmony_ci} 113141cc406Sopenharmony_ciMustek_PP_1015_Registers; 114141cc406Sopenharmony_ci 115141cc406Sopenharmony_ci 116141cc406Sopenharmony_ci/****************************************************************************** 117141cc406Sopenharmony_ci * CIS information 118141cc406Sopenharmony_ci *****************************************************************************/ 119141cc406Sopenharmony_citypedef struct Mustek_PP_CIS_Info 120141cc406Sopenharmony_ci{ 121141cc406Sopenharmony_ci /* Expose time (= time the lamp is on ?) */ 122141cc406Sopenharmony_ci SANE_Byte exposeTime; 123141cc406Sopenharmony_ci 124141cc406Sopenharmony_ci /* Power-on delay (= time between lamp on and start of capturing ?) */ 125141cc406Sopenharmony_ci SANE_Byte powerOnDelay[3]; 126141cc406Sopenharmony_ci 127141cc406Sopenharmony_ci /* Motor step control */ 128141cc406Sopenharmony_ci SANE_Byte phaseType; 129141cc406Sopenharmony_ci 130141cc406Sopenharmony_ci /* Use 8K bank or 4K bank */ 131141cc406Sopenharmony_ci SANE_Bool use8KBank; 132141cc406Sopenharmony_ci 133141cc406Sopenharmony_ci /* High resolution (600 DPI) or not (300 DPI) */ 134141cc406Sopenharmony_ci SANE_Bool highRes; 135141cc406Sopenharmony_ci 136141cc406Sopenharmony_ci /* delay between pixels; reading too fast causes stability problems */ 137141cc406Sopenharmony_ci SANE_Int delay; 138141cc406Sopenharmony_ci 139141cc406Sopenharmony_ci /* Register representation */ 140141cc406Sopenharmony_ci Mustek_PP_1015_Registers regs; 141141cc406Sopenharmony_ci 142141cc406Sopenharmony_ci /* Current color channel */ 143141cc406Sopenharmony_ci SANE_Int channel; 144141cc406Sopenharmony_ci 145141cc406Sopenharmony_ci /* Blocks motor movements during calibration */ 146141cc406Sopenharmony_ci SANE_Bool dontMove; 147141cc406Sopenharmony_ci 148141cc406Sopenharmony_ci /* Prevents read increment the before the first read */ 149141cc406Sopenharmony_ci SANE_Bool dontIncRead; 150141cc406Sopenharmony_ci 151141cc406Sopenharmony_ci /* Controls whether or not calibration parameters are transmitted 152141cc406Sopenharmony_ci during CIS configuration */ 153141cc406Sopenharmony_ci SANE_Bool setParameters; 154141cc406Sopenharmony_ci 155141cc406Sopenharmony_ci /* Number of lines to skip to reach the origin (used during calibration) */ 156141cc406Sopenharmony_ci SANE_Int skipsToOrigin; 157141cc406Sopenharmony_ci 158141cc406Sopenharmony_ci /* Physical resolution of the CIS: either 300 or 600 DPI */ 159141cc406Sopenharmony_ci SANE_Int cisRes; 160141cc406Sopenharmony_ci 161141cc406Sopenharmony_ci /* CCD mode (color/grayscale/lineart) */ 162141cc406Sopenharmony_ci SANE_Int mode; 163141cc406Sopenharmony_ci 164141cc406Sopenharmony_ci /* how many positions to skip until scan area starts @ max res */ 165141cc406Sopenharmony_ci SANE_Int skipimagebytes; 166141cc406Sopenharmony_ci 167141cc406Sopenharmony_ci /* how many image bytes to scan @ max res */ 168141cc406Sopenharmony_ci SANE_Int imagebytes; 169141cc406Sopenharmony_ci 170141cc406Sopenharmony_ci /* total skip, adjusted to resolution */ 171141cc406Sopenharmony_ci SANE_Int adjustskip; 172141cc406Sopenharmony_ci 173141cc406Sopenharmony_ci /* current resolution */ 174141cc406Sopenharmony_ci SANE_Int res; 175141cc406Sopenharmony_ci 176141cc406Sopenharmony_ci /* current horizontal hardware resolution */ 177141cc406Sopenharmony_ci SANE_Int hw_hres; 178141cc406Sopenharmony_ci 179141cc406Sopenharmony_ci /* current vertical hardware resolution */ 180141cc406Sopenharmony_ci SANE_Int hw_vres; 181141cc406Sopenharmony_ci 182141cc406Sopenharmony_ci /* how many positions to scan for one pixel */ 183141cc406Sopenharmony_ci SANE_Int hres_step; 184141cc406Sopenharmony_ci 185141cc406Sopenharmony_ci /* how many lines to scan for one scanline */ 186141cc406Sopenharmony_ci SANE_Int line_step; 187141cc406Sopenharmony_ci 188141cc406Sopenharmony_ci /* inversion */ 189141cc406Sopenharmony_ci SANE_Bool invert; 190141cc406Sopenharmony_ci 191141cc406Sopenharmony_ci} Mustek_PP_CIS_Info; 192141cc406Sopenharmony_ci 193141cc406Sopenharmony_cistruct Mustek_pp_Handle; 194141cc406Sopenharmony_citypedef struct Mustek_PP_CIS_dev 195141cc406Sopenharmony_ci{ 196141cc406Sopenharmony_ci /* device descriptor */ 197141cc406Sopenharmony_ci struct Mustek_pp_Handle *desc; 198141cc406Sopenharmony_ci 199141cc406Sopenharmony_ci /* model identification (600CP/1200CP/1200CP+) */ 200141cc406Sopenharmony_ci SANE_Int model; 201141cc406Sopenharmony_ci 202141cc406Sopenharmony_ci /* CIS status */ 203141cc406Sopenharmony_ci Mustek_PP_CIS_Info CIS; 204141cc406Sopenharmony_ci 205141cc406Sopenharmony_ci /* used during calibration & return_home */ 206141cc406Sopenharmony_ci Mustek_PP_CIS_Info Saved_CIS; 207141cc406Sopenharmony_ci 208141cc406Sopenharmony_ci /* bank count */ 209141cc406Sopenharmony_ci int bank_count; 210141cc406Sopenharmony_ci 211141cc406Sopenharmony_ci /* those are used to count the hardware line the scanner is at, the 212141cc406Sopenharmony_ci line the current bank is at and the lines we've scanned */ 213141cc406Sopenharmony_ci int line; 214141cc406Sopenharmony_ci int line_diff; 215141cc406Sopenharmony_ci int ccd_line; 216141cc406Sopenharmony_ci int lines_left; 217141cc406Sopenharmony_ci 218141cc406Sopenharmony_ci /* Configuration parameters that the user can calibrate */ 219141cc406Sopenharmony_ci /* Starting position at the top */ 220141cc406Sopenharmony_ci SANE_Int top_skip; 221141cc406Sopenharmony_ci /* Use fast skipping method for head movements ? (default: yes) */ 222141cc406Sopenharmony_ci SANE_Bool fast_skip; 223141cc406Sopenharmony_ci /* Discrimination value to choose between black and white */ 224141cc406Sopenharmony_ci SANE_Byte bw_limit; 225141cc406Sopenharmony_ci /* Run in calibration mode ? (default: no) */ 226141cc406Sopenharmony_ci SANE_Bool calib_mode; 227141cc406Sopenharmony_ci /* Extra delay between engine commands (ms). Default: zero. */ 228141cc406Sopenharmony_ci SANE_Int engine_delay; 229141cc406Sopenharmony_ci 230141cc406Sopenharmony_ci /* temporary buffer for 1 line (of one color) */ 231141cc406Sopenharmony_ci SANE_Byte *tmpbuf; 232141cc406Sopenharmony_ci 233141cc406Sopenharmony_ci /* calibration buffers (low cut, high cut) */ 234141cc406Sopenharmony_ci SANE_Byte *calib_low[3]; 235141cc406Sopenharmony_ci SANE_Byte *calib_hi[3]; 236141cc406Sopenharmony_ci 237141cc406Sopenharmony_ci /* Number of pixels in calibration buffers (<= number of pixels to scan) */ 238141cc406Sopenharmony_ci int calib_pixels; 239141cc406Sopenharmony_ci 240141cc406Sopenharmony_ci} Mustek_PP_CIS_dev; 241141cc406Sopenharmony_ci 242141cc406Sopenharmony_ci#define CIS_AVERAGE_NONE(dev) Mustek_PP_1015_send_command(dev, 0x05) 243141cc406Sopenharmony_ci#define CIS_AVERAGE_TWOPIXEL(dev) Mustek_PP_1015_send_command(dev, 0x15) 244141cc406Sopenharmony_ci#define CIS_AVERAGE_THREEPIXEL(dev) Mustek_PP_1015_send_command(dev, 0x35) 245141cc406Sopenharmony_ci#define CIS_WIDTH_4K(dev) Mustek_PP_1015_send_command(dev, 0x05) 246141cc406Sopenharmony_ci#define CIS_WIDTH_8K(dev) Mustek_PP_1015_send_command(dev, 0x45) 247141cc406Sopenharmony_ci#define CIS_STOP_TOGGLE(dev) Mustek_PP_1015_send_command(dev, 0x85) 248141cc406Sopenharmony_ci 249141cc406Sopenharmony_ci#define CIS_PIP_AS_INPUT(dev) Mustek_PP_1015_send_command(dev, 0x46) 250141cc406Sopenharmony_ci#define CIS_PIP_AS_OUTPUT_0(dev) Mustek_PP_1015_send_command(dev, 0x06) 251141cc406Sopenharmony_ci#define CIS_PIP_AS_OUTPUT_1(dev) Mustek_PP_1015_send_command(dev, 0x16) 252141cc406Sopenharmony_ci#define CIS_POP_AS_INPUT(dev) Mustek_PP_1015_send_command(dev, 0x86) 253141cc406Sopenharmony_ci#define CIS_POP_AS_OUTPUT_0(dev) Mustek_PP_1015_send_command(dev, 0x06) 254141cc406Sopenharmony_ci#define CIS_POP_AS_OUTPUT_1(dev) Mustek_PP_1015_send_command(dev, 0x26) 255141cc406Sopenharmony_ci 256141cc406Sopenharmony_ci#define CIS_INC_READ(dev) Mustek_PP_1015_send_command(dev, 0x07) 257141cc406Sopenharmony_ci#define CIS_CLEAR_WRITE_BANK(dev) Mustek_PP_1015_send_command(dev, 0x17) 258141cc406Sopenharmony_ci#define CIS_CLEAR_READ_BANK(dev) Mustek_PP_1015_send_command(dev, 0x27) 259141cc406Sopenharmony_ci#define CIS_CLEAR_FULLFLAG(dev) Mustek_PP_1015_send_command(dev, 0x37) 260141cc406Sopenharmony_ci#define CIS_POWER_ON(dev) Mustek_PP_1015_send_command(dev, 0x47) 261141cc406Sopenharmony_ci#define CIS_POWER_OFF(dev) Mustek_PP_1015_send_command(dev, 0x57) 262141cc406Sopenharmony_ci#define CIS_CLEAR_WRITE_ADDR(dev) Mustek_PP_1015_send_command(dev, 0x67) 263141cc406Sopenharmony_ci#define CIS_CLEAR_TOGGLE(dev) Mustek_PP_1015_send_command(dev, 0x77) 264141cc406Sopenharmony_ci 265141cc406Sopenharmony_ci#define CIS_NO(dev) Mustek_PP_1015_send_command(dev, 0x08) 266141cc406Sopenharmony_ci#define CIS_OST_POS(dev) Mustek_PP_1015_send_command(dev, 0x18) 267141cc406Sopenharmony_ci#define CIS_OST_TYP(dev) Mustek_PP_1015_send_command(dev, 0x28) 268141cc406Sopenharmony_ci#define CIS_OP_MOD_0(dev) Mustek_PP_1015_send_command(dev, 0x48) 269141cc406Sopenharmony_ci#define CIS_OP_MOD_1(dev) Mustek_PP_1015_send_command(dev, 0x88) 270141cc406Sopenharmony_ci 271141cc406Sopenharmony_ci#endif /* __mustek_pp_cis_h */ 272