1 /* --------------------------------------------------------------------------------------------------------- */ 2 3 /* umax.h - headerfile for SANE-backend for umax scanners 4 5 (C) 1997-2002 Oliver Rauch 6 7 This program is free software; you can redistribute it and/or 8 modify it under the terms of the GNU General Public License as 9 published by the Free Software Foundation; either version 2 of the 10 License, or (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, but 13 WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program. If not, see <https://www.gnu.org/licenses/>. 19 20 As a special exception, the authors of SANE give permission for 21 additional uses of the libraries contained in this release of SANE. 22 23 The exception is that, if you link a SANE library with other files 24 to produce an executable, this does not by itself cause the 25 resulting executable to be covered by the GNU General Public 26 License. Your use of that executable is in no way restricted on 27 account of linking the SANE library code into it. 28 29 This exception does not, however, invalidate any other reasons why 30 the executable file might be covered by the GNU General Public 31 License. 32 33 If you submit changes to SANE to the maintainers to be included in 34 a subsequent release, you agree by submitting the changes that 35 those changes may be distributed with this exception intact. 36 37 If you write modifications of your own for SANE, it is your choice 38 whether to permit this exception to apply to your modifications. 39 If you do not wish that, delete this exception notice. 40 41 */ 42 43 /* --------------------------------------------------------------------------------------------------------- */ 44 45 46 #ifndef umax_h 47 #define umax_h 48 49 #include "sys/types.h" 50 51 /* --------------------------------------------------------------------------------------------------------- */ 52 /* COMPILER OPTIONS: */ 53 54 #define UMAX_ENABLE_USB 55 #define UMAX_HIDE_UNUSED 56 57 /* #define SANE_UMAX_DEBUG_S12 */ 58 /* #define UMAX_CALIBRATION_MODE_SELECTABLE */ 59 60 /* --------------------------------------------------------------------------------------------------------- */ 61 62 #define SANE_UMAX_SCSI_MAXQUEUE 8 63 64 /* --------------------------------------------------------------------------------------------------------- */ 65 66 #define SANE_UMAX_FIX_ROUND(val) ((SANE_Word) ((val) * (1 << SANE_FIXED_SCALE_SHIFT) + 1.0 / (1 << (SANE_FIXED_SCALE_SHIFT+1)))) 67 68 /* --------------------------------------------------------------------------------------------------------- */ 69 70 enum Umax_Option 71 { 72 OPT_NUM_OPTS = 0, 73 74 /* ------------------------------------------- */ 75 76 OPT_MODE_GROUP, 77 OPT_MODE, 78 OPT_SOURCE, 79 OPT_X_RESOLUTION, 80 OPT_Y_RESOLUTION, 81 82 OPT_RESOLUTION_BIND, /* bind x and y resolution */ 83 OPT_NEGATIVE, 84 85 /* ------------------------------------------- */ 86 87 OPT_GEOMETRY_GROUP, 88 OPT_TL_X, /* top-left x */ 89 OPT_TL_Y, /* top-left y */ 90 OPT_BR_X, /* bottom-right x */ 91 OPT_BR_Y, /* bottom-right y */ 92 93 /* ------------------------------------------- */ 94 95 OPT_ENHANCEMENT_GROUP, 96 97 OPT_BIT_DEPTH, /* output bit depth */ 98 OPT_QUALITY, /* quality calibration */ 99 OPT_DOR, /* double optical resolution */ 100 OPT_WARMUP, 101 OPT_RGB_BIND, /* use same rgb-values for each color in color-mode */ 102 103 OPT_BRIGHTNESS, 104 OPT_CONTRAST, 105 OPT_THRESHOLD, 106 107 OPT_HIGHLIGHT, /* highlight */ 108 OPT_HIGHLIGHT_R, 109 OPT_HIGHLIGHT_G, 110 OPT_HIGHLIGHT_B, 111 112 OPT_SHADOW, /* shadow */ 113 OPT_SHADOW_R, 114 OPT_SHADOW_G, 115 OPT_SHADOW_B, 116 117 OPT_ANALOG_GAMMA, /* analog gamma */ 118 OPT_ANALOG_GAMMA_R, 119 OPT_ANALOG_GAMMA_G, 120 OPT_ANALOG_GAMMA_B, 121 122 OPT_CUSTOM_GAMMA, /* use custom gamma tables */ 123 /* The gamma vectors MUST appear in the order gray, red, green, blue. */ 124 OPT_GAMMA_VECTOR, 125 OPT_GAMMA_VECTOR_R, 126 OPT_GAMMA_VECTOR_G, 127 OPT_GAMMA_VECTOR_B, 128 129 OPT_HALFTONE_DIMENSION, 130 OPT_HALFTONE_PATTERN, 131 132 /* ------------------------------------------- */ 133 134 OPT_ADVANCED_GROUP, 135 136 OPT_CAL_EXPOS_TIME, /* exposure time for calibration */ 137 OPT_CAL_EXPOS_TIME_R, 138 OPT_CAL_EXPOS_TIME_G, 139 OPT_CAL_EXPOS_TIME_B, 140 OPT_SCAN_EXPOS_TIME, /* exposure time for scan */ 141 OPT_SCAN_EXPOS_TIME_R, 142 OPT_SCAN_EXPOS_TIME_G, 143 OPT_SCAN_EXPOS_TIME_B, 144 145 OPT_DISABLE_PRE_FOCUS, 146 OPT_MANUAL_PRE_FOCUS, 147 OPT_FIX_FOCUS_POSITION, 148 OPT_LENS_CALIBRATION_DOC_POS, 149 OPT_HOLDER_FOCUS_POS_0MM, 150 151 OPT_CAL_LAMP_DEN, 152 OPT_SCAN_LAMP_DEN, 153 154 OPT_SELECT_EXPOSURE_TIME, 155 OPT_SELECT_CAL_EXPOSURE_TIME, 156 OPT_SELECT_LAMP_DENSITY, 157 158 OPT_LAMP_ON, 159 OPT_LAMP_OFF, 160 OPT_LAMP_OFF_AT_EXIT, 161 162 OPT_BATCH_SCAN_START, /* start batch scan function */ 163 OPT_BATCH_SCAN_LOOP, /* loop batch scan function */ 164 OPT_BATCH_SCAN_END, /* end batch scan function */ 165 OPT_BATCH_NEXT_TL_Y, /* batch scan function next y position */ 166 167 #ifdef UMAX_CALIBRATION_MODE_SELECTABLE 168 OPT_CALIB_MODE, 169 #endif 170 171 OPT_PREVIEW, /* preview, sets preview-bit and bind x/y-resolution */ 172 173 /* must come last: */ 174 NUM_OPTIONS 175 }; 176 177 178 /* -------------------------------------------------------------------------------------------------------- */ 179 180 181 /* LIST OF AVAILABLE SCANNERS, THE VALUES LISTED HERE ARE THE SAME FOR DIFFERENT APPLICATIONS 182 THAT USE THE SAME DEVICE */ 183 184 /* Umax_Device contains values relevant for the device that are not interesting for the sane interface */ 185 186 typedef struct Umax_Device 187 { 188 struct Umax_Device *next; 189 SANE_Device sane; 190 191 int connection_type; 192 #define SANE_UMAX_UNKNOWN 0 193 #define SANE_UMAX_SCSI 1 194 #define SANE_UMAX_USB 2 195 196 SANE_Range x_dpi_range; 197 SANE_Range y_dpi_range; 198 SANE_Range x_range; 199 SANE_Range y_range; 200 SANE_Range analog_gamma_range; 201 unsigned flags; 202 203 unsigned char *buffer[SANE_UMAX_SCSI_MAXQUEUE]; /* buffer used for scsi-transfer */ 204 void *queue_id[SANE_UMAX_SCSI_MAXQUEUE]; /* scsi queue id */ 205 size_t length_queued[SANE_UMAX_SCSI_MAXQUEUE]; /* length of queued data */ 206 size_t length_read[SANE_UMAX_SCSI_MAXQUEUE]; /* length of returned data */ 207 unsigned int bufsize; 208 unsigned int row_bufsize; 209 unsigned int request_scsi_maxqueue; 210 unsigned int request_preview_lines; 211 unsigned int request_scan_lines; 212 unsigned int handle_bad_sense_error; 213 unsigned int execute_request_sense; 214 unsigned int force_preview_bit_rgb; 215 unsigned int scsi_buffer_size_min; 216 unsigned int scsi_buffer_size_max; 217 unsigned int scsi_maxqueue; 218 219 unsigned char *pixelbuffer; /* buffer used for pixel ordering */ 220 unsigned int pixelline_max; /* number of lines that fit into pixelbuffer */ 221 unsigned int pixelline_ready[3]; /* finished absolute line for each color */ 222 unsigned int pixelline_next[3]; /* next line to write for each color */ 223 unsigned int pixelline_del[3]; /* next line to delete in opt_res for col */ 224 unsigned int pixelline_optic[3]; /* scanned line in opt_res for each color */ 225 unsigned int pixelline_opt_res; /* number of scanned line in optical res */ 226 unsigned int pixelline_read; /* number of read pixel-lines */ 227 unsigned int pixelline_written; /* number of written pixel-lines */ 228 unsigned int CCD_distance; /* color line distance in optical resolution */ 229 unsigned int CCD_color[9]; /* color order */ 230 /* 0 / 1 2 / 3 4 5 / 6 7 / 8 */ 231 # define CCD_color_red 0 232 # define CCD_color_green 1 233 # define CCD_color_blue 2 234 235 char *devicename; /* name of the scanner device */ 236 int sfd; /* output file descriptor, scanner device */ 237 238 char vendor[9]; /* will be UMAX */ 239 char product[17]; /* e.g. "SuperVista_S12" or so */ 240 char version[5]; /* e.g. V1.3 */ 241 242 int three_pass; /* used in RGB-mode if 3-pass => 1 */ 243 int three_pass_color; /* select color for scanning in 3pass mode */ 244 unsigned int row_len; /* len of one scan-line in bytes */ 245 unsigned int lines_max; /* maximum number of lines to scan */ 246 unsigned int max_value; /* used for pnm-file */ 247 248 /* data defined by inquiry */ 249 int inquiry_len; /* length of inquiry return block */ 250 int inquiry_wdb_len; /* length of window descriptor block */ 251 int inquiry_vidmem; /* size of video memory */ 252 int inquiry_optical_res; /* optical resolution */ 253 int inquiry_x_res; /* maximum x-resolution */ 254 int inquiry_y_res; /* maximum y-resolution */ 255 int inquiry_dor_optical_res; /* optical resolution for dor mode */ 256 int inquiry_dor_x_res; /* maximum x-resolution for dor mode */ 257 int inquiry_dor_y_res; /* maximum y-resolution for dor mode */ 258 double inquiry_fb_width; /* flatbed width in inches */ 259 double inquiry_fb_length; /* flatbed length in inches */ 260 double inquiry_uta_width; /* transparency width in inches */ 261 double inquiry_uta_length; /* transparency length in inches */ 262 double inquiry_uta_x_off; /* transparency x offset in inches */ 263 double inquiry_uta_y_off; /* transparency y offset in inches */ 264 double inquiry_dor_width; /* double resolution width in inches */ 265 double inquiry_dor_length; /* double resolution length in inches */ 266 double inquiry_dor_x_off; /* double resolution x offset in inches */ 267 double inquiry_dor_y_off; /* double resolution y offset in inches */ 268 269 int inquiry_exposure_adj; /* 1 if exposure adjust is supported */ 270 int inquiry_exposure_time_step_unit; /* exposure time unit in micro sec */ 271 int inquiry_exposure_time_max; /* exposure time maximum */ 272 int inquiry_exposure_time_l_min; /* exposure tine minimum for lineart */ 273 int inquiry_exposure_time_l_fb_def; /* exposure time default for lineart/flatbed */ 274 int inquiry_exposure_time_l_uta_def; /* exposure time default for lineart/uta */ 275 int inquiry_exposure_time_h_min; /* exposure tine minimum for halftone */ 276 int inquiry_exposure_time_h_fb_def; /* exposure time default for halftone/flatbed */ 277 int inquiry_exposure_time_h_uta_def; /* exposure time default for halftone/uta */ 278 int inquiry_exposure_time_g_min; /* exposure tine minimum for grayscale */ 279 int inquiry_exposure_time_g_fb_def; /* exposure time default for grayscale/flatbed */ 280 int inquiry_exposure_time_g_uta_def; /* exposure time default for grayscale/uta */ 281 int inquiry_exposure_time_c_min; /* exposure tine minimum for color */ 282 int inquiry_exposure_time_c_fb_def_r; /* exposure time default for color red/flatbed */ 283 int inquiry_exposure_time_c_fb_def_g; /* exposure time default for color green/flatbed */ 284 int inquiry_exposure_time_c_fb_def_b; /* exposure time default for color blue/flatbed */ 285 int inquiry_exposure_time_c_uta_def_r; /* exposure time default for color red/uta */ 286 int inquiry_exposure_time_c_uta_def_g; /* exposure time default for color green/uta */ 287 int inquiry_exposure_time_c_uta_def_b; /* exposure time default for color blue/uta */ 288 289 int inquiry_max_warmup_time; /* maximum lamp warmup time in sec */ 290 int inquiry_cbhs; /* 50, 255, 255+autoexp. */ 291 int inquiry_cbhs_min; /* minimum value for cbhs */ 292 int inquiry_cbhs_max; /* maximum value for cbhs */ 293 int inquiry_contrast_min; /* minimum value for c */ 294 int inquiry_contrast_max; /* maximum value for c */ 295 int inquiry_brightness_min; /* minimum value for b */ 296 int inquiry_brightness_max; /* maximum value for b */ 297 int inquiry_threshold_min; /* minimum value for t */ 298 int inquiry_threshold_max; /* maximum value for t */ 299 int inquiry_highlight_min; /* minimum value for h */ 300 int inquiry_highlight_max; /* maximum value for h */ 301 int inquiry_shadow_min; /* minimum value for s */ 302 int inquiry_shadow_max; /* maximum value for s */ 303 304 int inquiry_quality_ctrl; /* 1 = supported */ 305 int inquiry_batch_scan; /* 1 = supported */ 306 int inquiry_preview; /* 1 = supported */ 307 int inquiry_lamp_ctrl; /* 1 = supported */ 308 int inquiry_transavail; /* 1 = uta available */ 309 int inquiry_adfmode; /* 1 = adf available */ 310 int inquiry_uta; /* 1 = uta supported */ 311 int inquiry_adf; /* 1 = adf supported */ 312 int inquiry_dor; /* 1 = dor supported */ 313 int inquiry_reverse; /* 1 = 1 bit reverse supported */ 314 int inquiry_reverse_multi; /* 1 = multi bit reverse supported */ 315 int inquiry_analog_gamma; /* 1 = analog gamma supported */ 316 int inquiry_lineart_order; /* 1 = LSB first, 0 = MSB first */ 317 318 int inquiry_lens_cal_in_doc_pos; /* 1 = lens calibration in doc pos supported */ 319 int inquiry_manual_focus; /* 1 = manual focus supported */ 320 int inquiry_sel_uta_lens_cal_pos; /* 1 = selection of lens calib pos for uta supported */ 321 322 int inquiry_gamma_dwload; /* 1 = gamma download supported */ 323 int inquiry_gamma_DCF; /* gamma download curve format */ 324 325 int inquiry_one_pass_color; /* 1 = 1 pass supported */ 326 int inquiry_three_pass_color; /* 1 = 3 pass supported */ 327 int inquiry_color; /* 1 = color mode supported */ 328 int inquiry_gray; /* 1 = grayscale mode supported */ 329 int inquiry_halftone; /* 1 = halftone mode supported */ 330 int inquiry_lineart; /* 1 = lineart mode supported */ 331 332 int inquiry_calibration; /* 1 = calibration mode control supported */ 333 int inquiry_highlight; /* 1 = highlight supported */ 334 int inquiry_shadow; /* 1 = shadow supported */ 335 int inquiry_GIB; /* gamma input bits */ 336 int inquiry_GOB; /* gamma output bits */ 337 int inquiry_max_calib_lines; /* maximum calibration lines */ 338 int inquiry_color_order; /* color ordering support */ 339 int inquiry_CCD_line_distance; /* color line distance */ 340 int inquiry_fb_uta_color_arrangement; /* line arrangement for fb & uta */ 341 int inquiry_adf_color_arrangement; /* line arrangement for adf */ 342 343 unsigned int relevant_optical_res; /* optical resolution */ 344 unsigned int relevant_max_x_res; /* maximum x-resolution */ 345 unsigned int relevant_max_y_res; /* maximum y-resolution */ 346 347 /* selected data */ 348 349 int use_exposure_time_min; /* exposure tine minimum */ 350 int use_exposure_time_def_r; /* exposure time default */ 351 int use_exposure_time_def_g; /* exposure time default */ 352 int use_exposure_time_def_b; /* exposure time default */ 353 354 int wdb_len; /* use this length of WDB */ 355 unsigned int width_in_pixels; /* that's the wanted width in pixels */ 356 unsigned int length_in_pixels; /* that's the wanted length in pixels */ 357 unsigned int scanwidth; /* that's the width in pixels at x_coordinate_base dpi */ 358 unsigned int scanlength; /* that's the length in pixels at y_coordinate_base dpi */ 359 unsigned int bytes_per_color; /* bytes per each color */ 360 361 unsigned int x_resolution; /* scan-resolution for x in dpi */ 362 unsigned int y_resolution; /* scan-resolution for y in dpi */ 363 double scale_x; /* x-scaling of optical resolution */ 364 double scale_y; /* y-scaling of optical resolution */ 365 int upper_left_x; /* that's the left edge in points at 1200pt/inch */ 366 int upper_left_y; /* that's the top edge in points at 1200pt/inch */ 367 368 unsigned int x_coordinate_base; /* x base in pixels/inch, normally 1200 */ 369 unsigned int y_coordinate_base; /* y base in pixels/inch, normally 1200 */ 370 371 unsigned int bits_per_pixel; /* number of bits per pixel */ 372 int bits_per_pixel_code; /* 1 = 24bpp, 4 = 30 bpp, 8 = 36 bpp */ 373 int gamma_input_bits_code; /* 1 = 24bpp, 4 = 30 bpp, 8 = 36 bpp */ 374 int set_auto; /* 0 or 1, don't know what it is */ 375 int preview; /* 1 if preview */ 376 int batch_scan; /* 1 = batch scan, 0 = normal scan */ 377 int batch_end; /* 1 = reposition scanhead */ 378 int batch_next_tl_y; /* top left y position for next batch scan */ 379 int quality; /* 1 = quality_calibration, 0 = fast */ 380 int reverse; /* 1: exchange black and white */ 381 int reverse_multi; /* 1: invert color values */ 382 int WD_speed; /* is a combination of slow and smear */ 383 int slow; /* 1: slow scan speed */ 384 int smear; /* 1: don't care about image smearing problem */ 385 int dor; /* double resolution */ 386 int cbhs_range; /* 50,255 or 255+autoexposure */ 387 int fix_focus_position; /* fix focus position */ 388 int lens_cal_in_doc_pos; /* lens calibration in document position */ 389 int disable_pre_focus; /* disable pre focus */ 390 int holder_focus_pos_0mm; /* 0.6mm <-> 0.0mm holder focus position */ 391 int manual_focus; /* automatic <-> manual focus */ 392 int warmup; /* 1=set warmup-bit */ 393 int module; /* flatbed or transparency */ 394 int adf; /* 1 if ADF turned on */ 395 int uta; /* 1 if UTA turned on */ 396 int calibration; /* calibration :0=ignore, 1=driver, 2=by image */ 397 int low_byte_first; /* 10 bit mode: 0=high byte first, 1=low byte first */ 398 int colormode; /* LINEART, HALFTONE, GRAYSCALE or RGB */ 399 # define LINEART 1 400 # define HALFTONE 2 401 # define GRAYSCALE 3 402 # define RGB_LINEART 4 403 # define RGB_HALFTONE 5 404 # define RGB 6 405 406 int exposure_time_calibration_r; /* red exposure time for calibration */ 407 int exposure_time_calibration_g; /* green exposure time for calibration */ 408 int exposure_time_calibration_b; /* blue exposure time for calibration */ 409 int exposure_time_scan_r; /* red exposure time for scan */ 410 int exposure_time_scan_g; /* green exposure time for scan */ 411 int exposure_time_scan_b; /* bue exposure time for scan */ 412 413 int c_density; /* next calibration lamp density */ 414 int s_density; /* next scan lamp density */ 415 416 int threshold; /* (128) 0-255, lineart mode */ 417 int brightness; /* (128) cbhs_range 0-255, halftone mode */ 418 int contrast; /* (128) cbhs_range 0-255, halftone-mode */ 419 int highlight_r; /* (255) cbhs_range 1-255, each mode */ 420 int highlight_g; /* (255) cbhs_range 1-255, each mode */ 421 int highlight_b; /* (255) cbhs_range 1-255, each mode */ 422 int shadow_r; /* (0) cbhs_range 0-254, each mode */ 423 int shadow_g; /* (0) cbhs_range 0-254, each mode */ 424 int shadow_b; /* (0) cbhs_range 0-254, each mode */ 425 int halftone; /* halftone pattern select */ 426 427 int digital_gamma_r; /* gamma-select for red and gray */ 428 int digital_gamma_g; /* gamma-select value for green */ 429 int digital_gamma_b; /* gamma-select value for blue */ 430 431 int analog_gamma_r; /* analog gamma red and gray */ 432 int analog_gamma_g; /* analog gamma green */ 433 int analog_gamma_b; /* analog gamma blue */ 434 435 int calib_lines; /* request calibration lines */ 436 437 int do_calibration; /* 1: do calibration by driver */ 438 int do_color_ordering; /* 1: order line-mode to pixel-mode */ 439 440 int button0_pressed; /* scan-button 0 on scanner is pressed => 1 */ 441 int button1_pressed; /* scan-button 1 on scanner is pressed => 1 */ 442 int button2_pressed; /* scan-button 2 on scanner is pressed => 1 */ 443 444 int calibration_area; /* define calibration area if no area is given */ 445 int calibration_width_offset; /* some scanners do calibrate with some additional pixels */ 446 int calibration_width_offset_batch; /* the same for batch scanning */ 447 int calibration_bytespp; /* correction of bytespp if driver knows about it */ 448 int exposure_time_rgb_bind; /* exposure time can not be defined for each color */ 449 int invert_shading_data; /* invert shading data before sending it to the scanner */ 450 int common_xy_resolutions; /* do not allow different x and y resolution */ 451 int pause_for_color_calibration; /* pause between start_scan and do_calibration in ms */ 452 int pause_for_gray_calibration; /* pause between start_scan and do_calibration in ms */ 453 int pause_after_calibration; /* pause between do_calibration and read data in ms */ 454 int pause_after_reposition; /* pause for repositioning in ms */ 455 int pause_for_moving; /* pause for moving scanhead over full scanarea in ms */ 456 int lamp_control_available; /* is set when scanner supportes lamp control */ 457 int gamma_lsb_padded; /* 16 bit gamma data is padded to lsb */ 458 int force_quality_calibration; /* always set quality calibration */ 459 } Umax_Device; 460 461 462 /* --------------------------------------------------------------------------------------------------------- */ 463 464 465 /* LIST OF OPEND DEVICES, A DEVICE MAY BE OPEND TWICE, ALL VALUES LISTED HERE MAY BE 466 DIFFERENT FOR DIFFERENT APPLICATIONS */ 467 468 /* Umax_Scanner contains values relevant for the sane interface */ 469 470 typedef struct Umax_Scanner 471 { 472 struct Umax_Scanner *next; 473 Umax_Device *device; 474 475 SANE_Option_Descriptor opt[NUM_OPTIONS]; 476 Option_Value val[NUM_OPTIONS]; 477 SANE_Int *gamma_table[4]; 478 SANE_Int halftone_pattern[64]; 479 SANE_Range gamma_range; 480 unsigned int gamma_length; 481 SANE_Range output_range; 482 unsigned int output_bytes; 483 SANE_Range exposure_time_range; 484 485 int scanning; 486 SANE_Parameters params; 487 488 SANE_Pid reader_pid; 489 int pipe_read_fd; 490 int pipe_write_fd; 491 } Umax_Scanner; 492 493 494 /* --------------------------------------------------------------------------------------------------------- */ 495 496 497 #endif /* umax-sane_h */ 498