~ubuntu-branches/debian/jessie/sane-backends/jessie

« back to all changes in this revision

Viewing changes to backend/genesys_low.h

  • Committer: Package Import Robot
  • Author(s): Markus Koschany
  • Date: 2013-07-04 17:41:47 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20130704174147-tl5tzd8bwvmctka2
Tags: 1.0.23-1
* QA upload.
* New upstream release.
* This package has been orphaned. Set maintainer to the Debian QA Group.
* Bump compat level to 9 (was 5) and require debhelper >= 9.
* debian/control:
  - sane-utils: Inherit Section: graphics from source package sane-backends.
  - Remove versioned dependencies. They are trivially satisfied.
* Drop the following patches. They are merged upstream now.
  - fix_v4l_build.patch
  - hurd_path_max_fix.patch
  - sane_desc_udev+acl.patch
  - scanimage_man_batch_start.patch
  - udev_usb_suspend.patch
  - xerox_mfp_add_scx_4623fw.patch
  - xerox_mfp_fix_usb_device.patch
* Drop disable_rpath.patch because the RPATH is already removed by chrpath
  in debian/rules.
* Rebase and refresh all other patches against the new upstream relase.
* debian/rules:
  - Simplify debian/rules by using dh sequencer.
  - Build with --parallel and with autotools_dev.
  - Enable all hardening build flags.
  - Install umax_pp with sane-utils.install.
* Build-Depend on libtiff5-dev. Thanks to Michael Terry for the patch.
  (Closes: #681079)
* Build-Depend on libusb-1.0-0-dev and enable libusb1.0 support in
  debian/rules. Thanks to Martin Pitt for the report and Whoopie for the
  patch. (Closes: #687137)

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
   Copyright (C) 2003 Oliver Rauch
4
4
   Copyright (C) 2003, 2004 Henning Meier-Geinitz <henning@meier-geinitz.de>
5
5
   Copyright (C) 2004, 2005 Gerhard Jaeger <gerhard@gjaeger.de>
6
 
   Copyright (C) 2004-2010 St�phane Voltz <stef.dev@free.fr>
 
6
   Copyright (C) 2004-2012 St�phane Voltz <stef.dev@free.fr>
7
7
   Copyright (C) 2005-2009 Pierre Willenbrock <pierre@pirsoft.dnsalias.org>
8
8
   Copyright (C) 2006 Laurent Charpentier <laurent_pubs@yahoo.com>
9
9
   Parts of the structs have been taken from the gt68xx backend by
51
51
#ifndef GENESYS_LOW_H
52
52
#define GENESYS_LOW_H
53
53
 
 
54
 
 
55
#include "../include/sane/config.h"
 
56
 
 
57
#include <errno.h>
 
58
#include <string.h>
 
59
#include <stdlib.h>
 
60
#include <stdio.h>
 
61
#include <unistd.h>
 
62
#include <math.h>
54
63
#include <stddef.h>
55
64
#ifdef HAVE_SYS_TIME_H
56
65
#include <sys/time.h>
57
66
#endif
 
67
#ifdef HAVE_SYS_TYPES_H
 
68
#include <sys/types.h>
 
69
#endif
 
70
#ifdef HAVE_MKDIR 
 
71
#include <sys/stat.h>
 
72
#include <sys/types.h>
 
73
#endif
 
74
 
58
75
#include "../include/sane/sane.h"
 
76
#include "../include/sane/sanei.h"
 
77
#include "../include/sane/saneopts.h"
 
78
 
 
79
#include "../include/sane/sanei_backend.h"
 
80
#include "../include/sane/sanei_usb.h"
 
81
 
 
82
#include "../include/_stdint.h"
59
83
 
60
84
#define DBG_error0      0       /* errors/warnings printed even with devuglevel 0 */
61
85
#define DBG_error       1       /* fatal errors */
81
105
#define GENESYS_FLAG_LAZY_INIT    (1 << 2)      /**> skip extensive ASIC test at init   */
82
106
#define GENESYS_FLAG_XPA          (1 << 3)
83
107
#define GENESYS_FLAG_SKIP_WARMUP  (1 << 4)      /**> skip genesys_warmup()              */
84
 
#define GENESYS_FLAG_OFFSET_CALIBRATION   (1 << 5)      /**> do offset calibration      */
 
108
/** @brief offset calibration flag
 
109
 * signals that the scanner does offset calibration. In this case off_calibration() and
 
110
 * coarse_gain_calibration() functions must be implemented 
 
111
 */
 
112
#define GENESYS_FLAG_OFFSET_CALIBRATION   (1 << 5)
85
113
#define GENESYS_FLAG_SEARCH_START (1 << 6)      /**> do start search before scanning    */
86
114
#define GENESYS_FLAG_REPARK       (1 << 7)      /**> repark head (and check for lock) by 
87
115
                                                   moving without scanning */
91
119
#define GENESYS_FLAG_MUST_WAIT        (1 << 10) /**> tells wether the scanner must wait for the head when parking */
92
120
 
93
121
 
94
 
#define GENESYS_FLAG_ALT_SLOPE_CREATE (1 << 11) /**> use alternative slope creation function */
 
122
#define GENESYS_FLAG_HAS_UTA          (1 << 11) /**> scanner has a transparency adapter */
95
123
 
96
124
#define GENESYS_FLAG_DARK_WHITE_CALIBRATION (1 << 12) /**> yet another calibration method. does white and dark shading in one run, depending on a black and a white strip*/
97
125
#define GENESYS_FLAG_CUSTOM_GAMMA     (1 << 13)       /**> allow custom gamma tables */
98
126
#define GENESYS_FLAG_NO_CALIBRATION   (1 << 14)       /**> allow scanners to use skip the calibration, needed for sheetfed scanners */
99
127
#define GENESYS_FLAG_HALF_CCD_MODE    (1 << 15)       /**> scanner has setting for half ccd mode */
100
 
#define GENESYS_FLAG_ODD_EVEN_CIS     (1 << 16)       /**> scan odd and even pixels come in separated lines */
 
128
#define GENESYS_FLAG_SIS_SENSOR       (1 << 16)       /**> handling of multi-segments sensors in software */
 
129
#define GENESYS_FLAG_SHADING_NO_MOVE  (1 << 17)       /**> scanner doesn't move sensor during shading calibration */
 
130
#define GENESYS_FLAG_SHADING_REPARK   (1 << 18)       /**> repark head between shading scans */
101
131
 
102
132
#define GENESYS_HAS_NO_BUTTONS       0              /**> scanner has no supported button */
103
133
#define GENESYS_HAS_SCAN_SW          (1 << 0)       /**> scanner has SCAN button */
269
299
#define DAC_G4050          13
270
300
#define DAC_CANONLIDE110   14
271
301
#define DAC_PLUSTEK_3600   15
 
302
#define DAC_CANONLIDE700   16
272
303
 
273
304
#define CCD_UMAX         0
274
305
#define CCD_ST12         1      /* SONY ILX548: 5340 Pixel  ??? */
291
322
#define CCD_G4050        18
292
323
#define CIS_CANONLIDE110 19
293
324
#define CCD_PLUSTEK_3600 20
 
325
#define CCD_HP_N6310     21
 
326
#define CIS_CANONLIDE700 22
294
327
 
295
328
#define GPO_UMAX         0
296
329
#define GPO_ST12         1
309
342
#define GPO_G4050        14
310
343
#define GPO_CANONLIDE110 15
311
344
#define GPO_PLUSTEK_3600 16
 
345
#define GPO_CANONLIDE210 17
 
346
#define GPO_HP_N6310     18
 
347
#define GPO_CANONLIDE700 19
312
348
 
313
349
#define MOTOR_UMAX       0
314
350
#define MOTOR_5345       1
328
364
#define MOTOR_G4050        16
329
365
#define MOTOR_CANONLIDE110 17
330
366
#define MOTOR_PLUSTEK_3600 18
 
367
#define MOTOR_CANONLIDE700 19
331
368
 
332
369
 
333
370
/* Forward typedefs */
453
490
     */
454
491
    SANE_Status (*send_shading_data) (Genesys_Device * dev, uint8_t * data, int size);
455
492
 
 
493
    /**
 
494
     * calculate current scan setup
 
495
     */
 
496
    SANE_Status (*calculate_current_setup) (Genesys_Device * dev);
 
497
 
456
498
} Genesys_Command_Set;
457
499
 
 
500
/** @brief structure to describe a scanner model
 
501
 * This structure describes a model. It is composed of information on the
 
502
 * sensor, the motor, scanner geometry and flags to drive operation.
 
503
 */
458
504
typedef struct Genesys_Model
459
505
{
460
506
  SANE_String_Const name;
601
647
  struct Genesys_Calibration_Cache *next;
602
648
};
603
649
 
 
650
/**
 
651
 * Describes the current device status for the backend
 
652
 * session. This should be more accurately called
 
653
 * Genesys_Session .
 
654
 */
604
655
struct Genesys_Device
605
656
{
606
657
  SANE_Int dn;
 
658
  SANE_Word vendorId;                   /**< USB vendor identifier */
 
659
  SANE_Word productId;                  /**< USB product identifier */
607
660
  SANE_Bool usb_mode;
608
661
  SANE_String file_name;
609
662
  SANE_String calib_file;
622
675
  time_t init_date;
623
676
 
624
677
  size_t average_size;
625
 
  size_t calib_pixels;
 
678
  size_t calib_pixels;  /**> number of pixels used during shading calibration */
 
679
  size_t calib_lines;   /**> number of lines used during shading calibration */
626
680
  size_t calib_channels;
 
681
  size_t calib_resolution;
627
682
  uint8_t *white_average_data;
628
683
  uint8_t *dark_average_data;
629
684
  uint16_t dark[3];
641
696
  Genesys_Buffer lines_buffer;
642
697
  Genesys_Buffer shrink_buffer;
643
698
  Genesys_Buffer out_buffer;
644
 
 
645
 
  size_t read_bytes_left;       /* bytes to read from scanner */
646
 
 
647
 
  size_t total_bytes_read;      /* total bytes read sent to frontend */
648
 
  size_t total_bytes_to_read;   /* total bytes read to be sent to frontend */
649
 
  size_t wpl;                   /* asic's word per line */
 
699
  Genesys_Buffer binarize_buffer; /**> buffer for digital lineart from gray data */
 
700
  Genesys_Buffer local_buffer;    /**> local buffer for gray data during dynamix lineart */
 
701
 
 
702
  size_t read_bytes_left;       /**> bytes to read from scanner */
 
703
 
 
704
  size_t total_bytes_read;      /**> total bytes read sent to frontend */
 
705
  size_t total_bytes_to_read;   /**> total bytes read to be sent to frontend */
 
706
  size_t wpl;                   /**> asic's word per line */
650
707
 
651
708
  Genesys_Current_Setup current_setup; /* contains the real used values */
652
709
 
657
714
 
658
715
  struct Genesys_Device *next;
659
716
 
 
717
  SANE_Int ld_shift_r;          /**> used red line-distance shift*/
 
718
  SANE_Int ld_shift_g;          /**> used green line-distance shift*/
 
719
  SANE_Int ld_shift_b;          /**> used blue line-distance shift*/
660
720
  int segnb;       /**> number of segments composing the sensor */
661
721
  int line_interp; /**> number of lines used in line interpolation */
662
722
  int line_count;  /**> number of scan lines used during scan */
663
723
  size_t bpl;      /**> bytes per full scan widthline */
664
 
  size_t skip;     /**> bytes to skip from start of line to get first required pixel */
665
724
  size_t dist;     /**> bytes distance between an odd and an even pixel */
666
725
  size_t len;      /**> number of even pixels */
667
726
  size_t cur;      /**> current pixel position within sub window */
 
727
  size_t skip;     /**> number of bytes to skip at start of line */
 
728
  size_t *order;   /**> array describing the order of the sub-segments of the sensor */
668
729
  Genesys_Buffer oe_buffer; /**> buffer to handle even/odd data */
669
730
 
670
731
  SANE_Bool buffer_image; /**> when true the scanned picture is first buffered
671
732
                           * to allow software image enhancements */
672
733
  SANE_Byte *img_buffer; /**> image buffer where the scanned picture is stored */
 
734
 
 
735
  FILE *binary; /**> binary logger file */
673
736
};
674
737
 
675
738
typedef struct Genesys_USB_Device_Entry
679
742
  Genesys_Model *model;                 /**< Scanner model information */
680
743
} Genesys_USB_Device_Entry;
681
744
 
 
745
/**
 
746
 * structure for motor database
 
747
 */
 
748
typedef struct {
 
749
        int motor_type;  /**> motor id */
 
750
        int exposure;    /**> exposure for the slope table */
 
751
        int step_type;   /**> default step type for given exposure */
 
752
        uint32_t *table; /**> 0 terminated slope table at full step */
 
753
} Motor_Profile;
 
754
 
 
755
#define FULL_STEP       0
 
756
#define HALF_STEP       1
 
757
#define QUARTER_STEP    2
 
758
#define EIGHTH_STEP     3
 
759
 
 
760
#define SLOPE_TABLE_SIZE 1024
 
761
 
 
762
#define SCAN_TABLE      0       /* table 1 at 0x4000 for gl124 */
 
763
#define BACKTRACK_TABLE 1       /* table 2 at 0x4800 for gl124 */
 
764
#define STOP_TABLE      2       /* table 3 at 0x5000 for gl124 */
 
765
#define FAST_TABLE      3       /* table 4 at 0x5800 for gl124 */
 
766
#define HOME_TABLE      4       /* table 5 at 0x6000 for gl124 */
 
767
 
 
768
#define SCAN_FLAG_SINGLE_LINE               0x001
 
769
#define SCAN_FLAG_DISABLE_SHADING           0x002
 
770
#define SCAN_FLAG_DISABLE_GAMMA             0x004
 
771
#define SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE  0x008
 
772
#define SCAN_FLAG_IGNORE_LINE_DISTANCE      0x010
 
773
#define SCAN_FLAG_USE_OPTICAL_RES           0x020
 
774
#define SCAN_FLAG_DISABLE_LAMP              0x040
 
775
#define SCAN_FLAG_DYNAMIC_LINEART           0x080
 
776
#define SCAN_FLAG_CALIBRATION               0x100
 
777
#define SCAN_FLAG_FEEDING                   0x200
 
778
#define SCAN_FLAG_USE_XPA                   0x400
 
779
 
 
780
#define MOTOR_FLAG_AUTO_GO_HOME             0x01
 
781
#define MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE 0x02
 
782
#define MOTOR_FLAG_FEED                     0x04
 
783
#define MOTOR_FLAG_USE_XPA                  0x08
 
784
 
 
785
#define OPTICAL_FLAG_DISABLE_GAMMA          0x01
 
786
#define OPTICAL_FLAG_DISABLE_SHADING        0x02
 
787
#define OPTICAL_FLAG_DISABLE_LAMP           0x04
 
788
#define OPTICAL_FLAG_ENABLE_LEDADD          0x08
 
789
#define OPTICAL_FLAG_DISABLE_DOUBLE         0x10
 
790
#define OPTICAL_FLAG_STAGGER                0x20
 
791
#define OPTICAL_FLAG_USE_XPA                0x40
 
792
 
682
793
/*--------------------------------------------------------------------------*/
683
794
/*       common functions needed by low level specific functions            */
684
795
/*--------------------------------------------------------------------------*/
855
966
extern SANE_Status
856
967
sanei_genesys_wait_for_home(Genesys_Device *dev);
857
968
 
 
969
extern 
 
970
int sanei_genesys_compute_dpihw(Genesys_Device *dev, int xres);
 
971
 
 
972
extern
 
973
Motor_Profile *sanei_genesys_get_motor_profile(Motor_Profile *motors, int motor_type, int exposure);
 
974
 
 
975
extern
 
976
int sanei_genesys_compute_step_type(Motor_Profile *motors, int motor_type, int exposure);
 
977
 
 
978
extern
 
979
int sanei_genesys_slope_table(uint16_t *slope, int *steps, int dpi, int exposure, int base_dpi, int step_type, int factor, int motor_type, Motor_Profile *motors);
 
980
 
 
981
/** @brief find lowest motor resolution for the device.
 
982
 * Parses the resolution list for motor and
 
983
 * returns the lowest value.
 
984
 * @param device for which to find the lowest motor resolution
 
985
 * @return the lowest available motor resolution for the device
 
986
 */
 
987
extern
 
988
int sanei_genesys_get_lowest_ydpi(Genesys_Device *dev);
 
989
 
 
990
/** @brief find lowest resolution for the device.
 
991
 * Parses the resolution list for motor and sensor and
 
992
 * returns the lowest value.
 
993
 * @param device for which to find the lowest resolution
 
994
 * @return the lowest available resolution for the device
 
995
 */
 
996
extern
 
997
int sanei_genesys_get_lowest_dpi(Genesys_Device *dev);
 
998
 
 
999
/**
 
1000
 * reads previously cached calibration data
 
1001
 * from file
 
1002
 */
 
1003
extern SANE_Status
 
1004
sanei_genesys_read_calibration (Genesys_Device * dev);
 
1005
 
 
1006
extern SANE_Status
 
1007
sanei_genesys_is_compatible_calibration (Genesys_Device * dev,
 
1008
                                 Genesys_Calibration_Cache * cache,
 
1009
                                 int for_overwrite);
 
1010
 
 
1011
/** @brief compute maximum line distance shift
 
1012
 * compute maximum line distance shift for the motor and sensor
 
1013
 * combination. Line distance shift is the distance between different
 
1014
 * color component of CCD sensors. Since these components aren't at
 
1015
 * the same physical place, they scan diffrent lines. Software must
 
1016
 * take this into account to accurately mix color data.
 
1017
 * @param dev device session to compute max_shift for
 
1018
 * @param channels number of color channels for the scan
 
1019
 * @param yres motor resolution used for the scan
 
1020
 * @param flags scan flags
 
1021
 * @return 0 or line distance shift
 
1022
 */
 
1023
int sanei_genesys_compute_max_shift(Genesys_Device *dev,
 
1024
                                    int channels,
 
1025
                                    int yres,
 
1026
                                    int flags);
 
1027
 
858
1028
/*---------------------------------------------------------------------------*/
859
1029
/*                ASIC specific functions declarations                       */
860
1030
/*---------------------------------------------------------------------------*/