1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
|
/*
* epsonds.c - Epson ESC/I-2 driver.
*
* Copyright (C) 2015 Tower Technologies
* Author: Alessandro Zummo <a.zummo@towertech.it>
*
* This file is part of the SANE package.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, version 2.
*/
#ifndef epsonds_h
#define epsonds_h
#undef BACKEND_NAME
#define BACKEND_NAME epsonds
#define DEBUG_NOT_STATIC
#define mode_params epsonds_mode_params
#define source_list epsonds_source_list
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#ifdef HAVE_STDDEF_H
#include <stddef.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef NEED_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <string.h> /* for memset and memcpy */
#include <stdio.h>
#include "sane/sane.h"
#include "sane/sanei_backend.h"
#include "sane/sanei_debug.h"
#include "sane/sanei_usb.h"
#include "sane/sanei_jpeg.h"
#define EPSONDS_CONFIG_FILE "epsonds.conf"
#ifndef PATH_MAX
#define PATH_MAX (1024)
#endif
#ifndef XtNumber
#define XtNumber(x) (sizeof(x) / sizeof(x[0]))
#define XtOffset(p_type, field) ((size_t)&(((p_type)NULL)->field))
#define XtOffsetOf(s_type, field) XtOffset(s_type*, field)
#endif
#define ACK 0x06
#define NAK 0x15
#define FS 0x1C
#define FBF_STR SANE_I18N("Flatbed")
#define TPU_STR SANE_I18N("Transparency Unit")
#define ADF_STR SANE_I18N("Automatic Document Feeder")
#define STRING_FLATBED SANE_I18N("Flatbed")
#define STRING_ADFFRONT SANE_I18N("ADF Front")
#define STRING_ADFDUPLEX SANE_I18N("ADF Duplex")
enum {
OPT_NUM_OPTS = 0,
OPT_STANDARD_GROUP,
OPT_SOURCE,
OPT_MODE,
OPT_DEPTH,
OPT_RESOLUTION,
OPT_GEOMETRY_GROUP,
OPT_TL_X,
OPT_TL_Y,
OPT_BR_X,
OPT_BR_Y,
OPT_EQU_GROUP,
OPT_EJECT,
OPT_LOAD,
OPT_ADF_SKEW,
OPT_ADF_CRP,
NUM_OPTIONS
};
typedef enum
{ /* hardware connection to the scanner */
SANE_EPSONDS_NODEV, /* default, no HW specified yet */
SANE_EPSONDS_USB, /* USB interface */
SANE_EPSONDS_NET /* network interface */
} epsonds_conn_type;
/* hardware description */
struct epsonds_device
{
struct epsonds_device *next;
epsonds_conn_type connection;
char *name;
char *model;
unsigned int model_id;
SANE_Device sane;
SANE_Range *x_range;
SANE_Range *y_range;
SANE_Range dpi_range;
SANE_Byte alignment;
SANE_Int *res_list; /* list of resolutions */
SANE_Int *depth_list;
SANE_Int max_depth; /* max. color depth */
SANE_Bool has_raw; /* supports RAW format */
SANE_Bool has_mono; /*supprt M001*/
SANE_Bool has_fb; /* flatbed */
SANE_Range fbf_x_range; /* x range */
SANE_Range fbf_y_range; /* y range */
SANE_Byte fbf_alignment; /* left, center, right */
SANE_Bool fbf_has_skew; /* supports skew correction */
SANE_Bool has_adf; /* adf */
SANE_Range adf_x_range; /* x range */
SANE_Range adf_y_range; /* y range */
SANE_Bool adf_is_duplex; /* supports duplex mode */
SANE_Bool adf_singlepass; /* supports single pass duplex */
SANE_Bool adf_has_skew; /* supports skew correction */
SANE_Bool adf_has_load; /* supports load command */
SANE_Bool adf_has_eject; /* supports eject command */
SANE_Byte adf_alignment; /* left, center, right */
SANE_Byte adf_has_dfd; /* supports double feed detection */
SANE_Byte adf_has_crp; /* supports crp */
SANE_Bool has_tpu; /* tpu */
SANE_Range tpu_x_range; /* transparency unit x range */
SANE_Range tpu_y_range; /* transparency unit y range */
SANE_Int lut_id;
};
typedef struct epsonds_device epsonds_device;
typedef struct ring_buffer
{
SANE_Byte *ring, *wp, *rp, *end;
SANE_Int fill, size;
} ring_buffer;
/* an instance of a scanner */
struct epsonds_scanner
{
struct epsonds_scanner *next;
struct epsonds_device *hw;
int fd;
SANE_Option_Descriptor opt[NUM_OPTIONS];
Option_Value val[NUM_OPTIONS];
SANE_Parameters params;
size_t bsz; /* transfer buffer size */
SANE_Byte *buf, *line_buffer;
ring_buffer *current, front, back;
SANE_Bool eof, scanning, canceling, locked, backside, mode_jpeg;
SANE_Int left, top, pages, dummy;
SANE_Int width_front, height_front;
SANE_Int width_back , height_back;
SANE_Int width_temp, height_temp;
/* jpeg stuff */
djpeg_dest_ptr jdst;
struct jpeg_decompress_struct jpeg_cinfo;
struct jpeg_error_mgr jpeg_err;
SANE_Bool jpeg_header_seen;
/* network buffers */
unsigned char *netbuf, *netptr;
size_t netlen;
SANE_Byte *frontJpegBuf, *backJpegBuf;
SANE_Int frontJpegBufLen, backJpegBufLen;
SANE_Int acquirePage;
SANE_Int isflatbedScan;
SANE_Int isDuplexScan;
SANE_Int needToConvertBW;
SANE_Int scanEnd;
};
typedef struct epsonds_scanner epsonds_scanner;
struct mode_param
{
int color;
int flags;
int dropout_mask;
int depth;
};
enum {
MODE_BINARY, MODE_GRAY, MODE_COLOR
};
#endif
|