1141cc406Sopenharmony_ci/* sane - Scanner Access Now Easy. 2141cc406Sopenharmony_ci Copyright (C) 1997 David Mosberger-Tang 3141cc406Sopenharmony_ci This file is part of the SANE package. 4141cc406Sopenharmony_ci 5141cc406Sopenharmony_ci As a special exception, the authors of SANE give permission for 6141cc406Sopenharmony_ci additional uses of the libraries contained in this release of SANE. 7141cc406Sopenharmony_ci 8141cc406Sopenharmony_ci The exception is that, if you link a SANE library with other files 9141cc406Sopenharmony_ci to produce an executable, this does not by itself cause the 10141cc406Sopenharmony_ci resulting executable to be covered by the GNU General Public 11141cc406Sopenharmony_ci License. Your use of that executable is in no way restricted on 12141cc406Sopenharmony_ci account of linking the SANE library code into it. 13141cc406Sopenharmony_ci 14141cc406Sopenharmony_ci This exception does not, however, invalidate any other reasons why 15141cc406Sopenharmony_ci the executable file might be covered by the GNU General Public 16141cc406Sopenharmony_ci License. 17141cc406Sopenharmony_ci 18141cc406Sopenharmony_ci If you submit changes to SANE to the maintainers to be included in 19141cc406Sopenharmony_ci a subsequent release, you agree by submitting the changes that 20141cc406Sopenharmony_ci those changes may be distributed with this exception intact. 21141cc406Sopenharmony_ci 22141cc406Sopenharmony_ci If you write modifications of your own for SANE, it is your choice 23141cc406Sopenharmony_ci whether to permit this exception to apply to your modifications. 24141cc406Sopenharmony_ci If you do not wish that, delete this exception notice. 25141cc406Sopenharmony_ci 26141cc406Sopenharmony_ci Portions of this code are derived from Scott Laird's qcam driver. 27141cc406Sopenharmony_ci It's copyright notice is reproduced here: 28141cc406Sopenharmony_ci 29141cc406Sopenharmony_ci Copyright (C) 1996 by Scott Laird 30141cc406Sopenharmony_ci 31141cc406Sopenharmony_ci Permission is hereby granted, free of charge, to any person 32141cc406Sopenharmony_ci obtaining a copy of this software and associated documentation 33141cc406Sopenharmony_ci files (the "Software"), to deal in the Software without 34141cc406Sopenharmony_ci restriction, including without limitation the rights to use, copy, 35141cc406Sopenharmony_ci modify, merge, publish, distribute, sublicense, and/or sell copies 36141cc406Sopenharmony_ci of the Software, and to permit persons to whom the Software is 37141cc406Sopenharmony_ci furnished to do so, subject to the following conditions: 38141cc406Sopenharmony_ci 39141cc406Sopenharmony_ci The above copyright notice and this permission notice shall be 40141cc406Sopenharmony_ci included in all copies or substantial portions of the Software. 41141cc406Sopenharmony_ci 42141cc406Sopenharmony_ci THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 43141cc406Sopenharmony_ci EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 44141cc406Sopenharmony_ci MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 45141cc406Sopenharmony_ci NONINFRINGEMENT. IN NO EVENT SHALL SCOTT LAIRD BE LIABLE FOR ANY 46141cc406Sopenharmony_ci CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 47141cc406Sopenharmony_ci CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 48141cc406Sopenharmony_ci WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 49141cc406Sopenharmony_ci 50141cc406Sopenharmony_ci#ifndef qcam_h 51141cc406Sopenharmony_ci#define qcam_h 52141cc406Sopenharmony_ci 53141cc406Sopenharmony_ci#include "../include/sane/sane.h" 54141cc406Sopenharmony_ci 55141cc406Sopenharmony_citypedef enum 56141cc406Sopenharmony_ci { 57141cc406Sopenharmony_ci QC_MONO = 0x01, 58141cc406Sopenharmony_ci QC_COLOR = 0x10 59141cc406Sopenharmony_ci } 60141cc406Sopenharmony_ciQC_Model; 61141cc406Sopenharmony_ci 62141cc406Sopenharmony_citypedef enum 63141cc406Sopenharmony_ci { 64141cc406Sopenharmony_ci QC_RES_LOW = 0, 65141cc406Sopenharmony_ci QC_RES_HIGH 66141cc406Sopenharmony_ci } 67141cc406Sopenharmony_ciQC_Resolution; 68141cc406Sopenharmony_ci 69141cc406Sopenharmony_ci/* commands common to all quick-cameras: */ 70141cc406Sopenharmony_citypedef enum 71141cc406Sopenharmony_ci { 72141cc406Sopenharmony_ci QC_SEND_VIDEO_FRAME = 7, 73141cc406Sopenharmony_ci QC_SET_BRIGHTNESS = 11, 74141cc406Sopenharmony_ci QC_SET_TOP = 13, 75141cc406Sopenharmony_ci QC_SET_LEFT = 15, 76141cc406Sopenharmony_ci QC_SET_NUM_V = 17, 77141cc406Sopenharmony_ci QC_SET_NUM_H = 19, 78141cc406Sopenharmony_ci QC_SEND_VERSION = 23, 79141cc406Sopenharmony_ci QC_SET_BLACK = 29, 80141cc406Sopenharmony_ci QC_SET_WHITE = 31, 81141cc406Sopenharmony_ci QC_SET_SATURATION = 35, 82141cc406Sopenharmony_ci QC_SEND_STATUS = 41, 83141cc406Sopenharmony_ci QC_SET_SPEED = 45 84141cc406Sopenharmony_ci } 85141cc406Sopenharmony_ciQC_Command; 86141cc406Sopenharmony_ci 87141cc406Sopenharmony_ci/* commands for grayscale camera: */ 88141cc406Sopenharmony_citypedef enum 89141cc406Sopenharmony_ci { 90141cc406Sopenharmony_ci QC_MONO_SET_CONTRAST = 25, 91141cc406Sopenharmony_ci QC_MONO_AUTO_ADJUST_OFFSET = 27, 92141cc406Sopenharmony_ci QC_MONO_GET_OFFSET = 33 93141cc406Sopenharmony_ci } 94141cc406Sopenharmony_ciQC_Mono_Command; 95141cc406Sopenharmony_ci 96141cc406Sopenharmony_ci/* commands for color camera: */ 97141cc406Sopenharmony_citypedef enum 98141cc406Sopenharmony_ci { 99141cc406Sopenharmony_ci QC_COL_LOAD_RAM = 27, 100141cc406Sopenharmony_ci QC_COL_SET_HUE = 33, 101141cc406Sopenharmony_ci QC_COL_SET_CONTRAST = 37 102141cc406Sopenharmony_ci } 103141cc406Sopenharmony_ciQC_Col_Command; 104141cc406Sopenharmony_ci 105141cc406Sopenharmony_citypedef enum 106141cc406Sopenharmony_ci { 107141cc406Sopenharmony_ci OPT_NUM_OPTS = 0, 108141cc406Sopenharmony_ci 109141cc406Sopenharmony_ci OPT_MODE_GROUP, 110141cc406Sopenharmony_ci OPT_DEPTH, /* 4 or 6 (b&w) or 24 (color) */ 111141cc406Sopenharmony_ci OPT_RESOLUTION, /* resolution in pixels */ 112141cc406Sopenharmony_ci OPT_XFER_SCALE, /* transfer-scale */ 113141cc406Sopenharmony_ci OPT_DESPECKLE, /* turn on despeckling? */ 114141cc406Sopenharmony_ci OPT_TEST, /* test image */ 115141cc406Sopenharmony_ci 116141cc406Sopenharmony_ci OPT_GEOMETRY_GROUP, 117141cc406Sopenharmony_ci OPT_TL_X, /* top-left x */ 118141cc406Sopenharmony_ci OPT_TL_Y, /* top-left y */ 119141cc406Sopenharmony_ci OPT_BR_X, /* bottom-right x */ 120141cc406Sopenharmony_ci OPT_BR_Y, /* bottom-right y */ 121141cc406Sopenharmony_ci 122141cc406Sopenharmony_ci OPT_ENHANCEMENT_GROUP, 123141cc406Sopenharmony_ci OPT_BRIGHTNESS, 124141cc406Sopenharmony_ci OPT_CONTRAST, 125141cc406Sopenharmony_ci OPT_BLACK_LEVEL, 126141cc406Sopenharmony_ci OPT_WHITE_LEVEL, 127141cc406Sopenharmony_ci OPT_HUE, 128141cc406Sopenharmony_ci OPT_SATURATION, 129141cc406Sopenharmony_ci 130141cc406Sopenharmony_ci /* must come last: */ 131141cc406Sopenharmony_ci NUM_OPTIONS 132141cc406Sopenharmony_ci } 133141cc406Sopenharmony_ciQC_Option; 134141cc406Sopenharmony_ci 135141cc406Sopenharmony_citypedef enum 136141cc406Sopenharmony_ci { 137141cc406Sopenharmony_ci QC_UNIDIR, 138141cc406Sopenharmony_ci QC_BIDIR 139141cc406Sopenharmony_ci } QC_Port_Mode; 140141cc406Sopenharmony_ci 141141cc406Sopenharmony_citypedef struct 142141cc406Sopenharmony_ci { 143141cc406Sopenharmony_ci size_t num_bytes; /* # of bytes to read */ 144141cc406Sopenharmony_ci QC_Resolution resolution; /* high-resolution? */ 145141cc406Sopenharmony_ci SANE_Parameters params; /* other parameters */ 146141cc406Sopenharmony_ci u_int mode; /* qcam scan code (get video data command) */ 147141cc406Sopenharmony_ci int despeckle; /* apply despeckling filter? */ 148141cc406Sopenharmony_ci } 149141cc406Sopenharmony_ciQC_Scan_Request; 150141cc406Sopenharmony_ci 151141cc406Sopenharmony_citypedef struct QC_Device 152141cc406Sopenharmony_ci { 153141cc406Sopenharmony_ci struct QC_Device * next; 154141cc406Sopenharmony_ci SANE_Device sane; 155141cc406Sopenharmony_ci QC_Port_Mode port_mode; 156141cc406Sopenharmony_ci int port; /* i/o port address */ 157141cc406Sopenharmony_ci int version; /* camera version */ 158141cc406Sopenharmony_ci int lock_fd; /* used for locking protocol */ 159141cc406Sopenharmony_ci } 160141cc406Sopenharmony_ciQC_Device; 161141cc406Sopenharmony_ci 162141cc406Sopenharmony_citypedef struct QC_Scanner 163141cc406Sopenharmony_ci { 164141cc406Sopenharmony_ci struct QC_Scanner *next; 165141cc406Sopenharmony_ci 166141cc406Sopenharmony_ci SANE_Option_Descriptor opt[NUM_OPTIONS]; 167141cc406Sopenharmony_ci Option_Value val[NUM_OPTIONS]; 168141cc406Sopenharmony_ci QC_Resolution resolution; 169141cc406Sopenharmony_ci SANE_Parameters params; 170141cc406Sopenharmony_ci QC_Device *hw; 171141cc406Sopenharmony_ci SANE_Int user_corner; /* bitmask of user-selected coordinates */ 172141cc406Sopenharmony_ci SANE_Int value_changed; /* bitmask of options that were set */ 173141cc406Sopenharmony_ci SANE_Bool scanning; 174141cc406Sopenharmony_ci SANE_Bool deliver_eof; 175141cc406Sopenharmony_ci SANE_Bool holding_lock; /* are we holding the lock? */ 176141cc406Sopenharmony_ci /* state for reading a frame: */ 177141cc406Sopenharmony_ci size_t num_bytes; /* # of bytes read so far */ 178141cc406Sopenharmony_ci size_t bytes_per_frame; /* total number of bytes in frame */ 179141cc406Sopenharmony_ci /* state relating to the reader-process */ 180141cc406Sopenharmony_ci int reader_pid; /* -1 if there is no reader process (yet) */ 181141cc406Sopenharmony_ci int from_child; /* fd to read from child process*/ 182141cc406Sopenharmony_ci int to_child; /* fd to write to child */ 183141cc406Sopenharmony_ci int read_fd; /* used to read data */ 184141cc406Sopenharmony_ci /* internal state for qc_readbytes(): */ 185141cc406Sopenharmony_ci int readbytes_state; 186141cc406Sopenharmony_ci unsigned int saved_bits; 187141cc406Sopenharmony_ci } 188141cc406Sopenharmony_ciQC_Scanner; 189141cc406Sopenharmony_ci 190141cc406Sopenharmony_ci#endif /* qcam_h */ 191