piuspatch  v0.1
USB addition to PIE backend
only-pie/backend/pie_usb.h
Go to the documentation of this file.
00001 /* sane - Scanner Access Now Easy.
00002 
00003    pie_usb.h
00004 
00005    Copyright (C) 2012 Michael Rickmann <mrickma@gwdg.de>
00006    
00007    This file is part of the SANE package.
00008    
00009    This program is free software; you can redistribute it and/or
00010    modify it under the terms of the GNU General Public License as
00011    published by the Free Software Foundation; either version 2 of the
00012    License, or (at your option) any later version.
00013    
00014    This program is distributed in the hope that it will be useful, but
00015    WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017    General Public License for more details.
00018    
00019    You should have received a copy of the GNU General Public License
00020    along with this program; if not, write to the Free Software
00021    Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00022    MA 02111-1307, USA.
00023    
00024    As a special exception, the authors of SANE give permission for
00025    additional uses of the libraries contained in this release of SANE.
00026    
00027    The exception is that, if you link a SANE library with other files
00028    to produce an executable, this does not by itself cause the
00029    resulting executable to be covered by the GNU General Public
00030    License.  Your use of that executable is in no way restricted on
00031    account of linking the SANE library code into it.
00032    
00033    This exception does not, however, invalidate any other reasons why
00034    the executable file might be covered by the GNU General Public
00035    License.
00036    
00037    If you submit changes to SANE to the maintainers to be included in
00038    a subsequent release, you agree by submitting the changes that
00039    those changes may be distributed with this exception intact.
00040    
00041    If you write modifications of your own for SANE, it is your choice
00042    whether to permit this exception to apply to your modifications.
00043    If you do not wish that, delete this exception notice. 
00044 */
00045 
00098 #ifndef PIE_USB_H
00099 #define PIE_USB_H
00100 
00101 
00102 /* ----------------------------------------------------------------
00103  * defines for the SCSI over USB interface
00104  */
00105 
00106 #define BULKIN_MAXSIZE          0xFFF0
00107 #define BUFFER_MAXSIZE          0x7F000
00108 #define AVERAGE_CAL_LINES       13
00109 
00110 /* USB control message values */
00111 
00112 #define REQUEST_TYPE_IN         (USB_TYPE_VENDOR | USB_DIR_IN)
00113 #define REQUEST_TYPE_OUT        (USB_TYPE_VENDOR | USB_DIR_OUT)
00114 
00115 /* the following have a taste of genesys */
00116 #define REQUEST_REGISTER        0x0c
00117 #define REQUEST_BUFFER          0x04
00118 
00119 #define VALUE_BUFFER            0x82
00120 #define VALUE_READ_REGISTER     0x84
00121 #define VALUE_WRITE_REGISTER    0x85
00122 #define VALUE_INIT_1            0x87
00123 #define VALUE_INIT_2            0x88
00124 #define VALUE_BUF_ENDACCESS     0x8c
00125 #define VALUE_GET_REGISTER      0x8e
00126 /* fortunately 0, index of USB commands */
00127 #define INDEX                   0x00
00128 
00129 /* e.g.
00130    control  0x40 0x0c 0x87 0x00 len     1 wrote 0x04
00131             REQUEST_TYPE_OUT
00132                  REQUEST_REGISTER
00133                       VALUE_INIT_1
00134                            INDEX
00135 */
00136 
00140 typedef struct PIE_USB_Value_Data
00141 {
00142   SANE_Byte bValue;     
00143   SANE_Byte bData;      
00144 } PIE_USB_Value_Data;
00145 
00146 
00157 enum PIE_USB_Operation_Mode
00158 {
00159   OPM_PREVIEW,          
00160   OPM_SKIPCAL,          
00161   OPM_QUALITY           
00162 };
00163 
00164 
00173 #define SLOW_START 26700.0
00174 #define SLOW_LENGTH 5340.0
00175 #define SLOW_HEIGHT 8.0
00176 #define SLOW_IRED -2
00177 
00181 typedef struct PIE_USB_cal_ired
00182 {
00183   uint16_t texp;                
00184   unsigned char offset;         
00185   unsigned char zero;
00186   unsigned char gain;           
00187 } __attribute__ ((__packed__)) PIE_USB_cal_ired;
00188 
00189 
00193 typedef struct PIE_USB_Calibration_Read
00194 {
00195   unsigned char zero_1[54];
00196   /* values describing internal calibration */
00197   uint16_t illumination[3];     
00198   uint16_t texp[3];             
00199   unsigned char offset[3];      
00200   unsigned char zero_2[3];
00203   unsigned char gain[3];
00204   unsigned char some_time;      
00205   uint16_t t_min;               
00206   unsigned char no_idea[20];
00207   PIE_USB_cal_ired infrared;    
00208 } __attribute__ ((__packed__)) PIE_USB_Calibration_Read;
00209 
00213 typedef struct PIE_USB_Calibration_Send
00214 {
00216   unsigned char scsi_cmd[6];
00220   uint16_t texp[3];
00222   unsigned char offset[3];
00224   unsigned char zero_2[3];
00226   unsigned char gain[3];
00227   unsigned char some_time[3];
00228   /* infrared bytes are usually copied from calibration read */
00229   PIE_USB_cal_ired infrared;
00230 } __attribute__ ((__packed__)) PIE_USB_Calibration_Send;
00231 
00232 
00236 typedef struct PIE_USB_Calibration_Set
00237 {
00238   uint16_t texp[3];             
00239   uint16_t texp_max;            
00240   unsigned char gain[3];        
00241 } PIE_USB_Calibration_Set;
00242 
00243 
00249 typedef struct PIE_USB_Calibration
00250 {
00251   int brightness[3];            
00252   int *shades;                  
00253   unsigned char *sensors;       
00254   int mean_shade[4];            
00256   int target_shade[4];
00257   PIE_USB_Calibration_Set cal_hiqual;   
00258   PIE_USB_Calibration_Set cal_normal;   
00259 } PIE_USB_Calibration;
00260 
00261 
00271 typedef struct PIE_USB_Model
00272 {
00273   SANE_String vendor;
00274   SANE_String model;
00275   SANE_Byte model_id;           
00276   SANE_Word flags;              
00277   unsigned char op_mode[3];     
00278   SANE_Int default_brightness;  
00279   double gain_const[3];         
00283   double offs_factor[3];
00284   int gain_min;                 
00286   int gain_hiqual_max;
00287   int texp_normal_max;          
00289   int gain_hiqual_part;
00292   PIE_USB_Calibration_Set default_hiqual;
00294   PIE_USB_Calibration_Set default_normal;
00295 } PIE_USB_Model;
00296 
00300 typedef struct PIE_USB_Device_Entry
00301 {
00302   SANE_Word vendor;             
00303   SANE_Word product;            
00304   PIE_USB_Model *model;         
00305 } PIE_USB_Device_Entry;
00306 
00307 /* model peculiarities going into the flags value */
00308 #define PIE_USB_FLAG_MIRROR_IMAGE       (1 << 0)        
00309 #define PIE_USB_FLAG_XRES_FAKE          (1 << 1)        
00312 #define CONST_GAMMA     0.454545455
00313 
00314 #endif /* not PIE_USB_H */
00315 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines