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
|
/*
* kodakaio.c - SANE library for Kodak ESP Aio scanners.
*
* Copyright (C) 2011-2013 Paul Newall
*
* Based on the Magicolor sane backend:
* Based on the epson2 sane backend:
* Based on Kazuhiro Sasayama previous
* work on epson.[ch] file from the SANE package.
* Please see those files for additional copyrights.
* Author: Paul Newall
*
*
* 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.
29/12/12 added KodakAio_Scanner.ack
2/1/13 added KodakAio_Scanner.background[]
*/
#ifndef kodakaio_h
#define kodakaio_h
#undef BACKEND_NAME
#define BACKEND_NAME kodakaio
#define DEBUG_NOT_STATIC
#include <sys/ioctl.h>
#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 <stdio.h>
#include "../include/sane/sane.h"
#include "../include/sane/sanei_debug.h"
#include "../include/sane/sanei_backend.h"
/* Silence the compiler for unused arguments */
#define NOT_USED(x) ( (void)(x) )
#define KODAKAIO_CONFIG_FILE "kodakaio.conf"
#define NUM_OF_HEX_ELEMENTS (16) /* number of hex numbers per line for data dump */
#define DEVICE_NAME_LEN (16) /* length of device name in extended status */
#define CAP_DEFAULT 0
/* Structure holding the device capabilities */
struct KodakaioCap
{
SANE_Word id; /* USB pid */
const char *cmds; /* may be used for different command sets in future */
const char *model;
SANE_Int out_ep, in_ep; /* USB bulk out/in endpoints */
SANE_Int optical_res; /* optical resolution */
SANE_Range dpi_range; /* max/min resolutions */
SANE_Int *res_list; /* list of resolutions */
SANE_Int res_list_size; /* number of entries in this list */
SANE_Int maxDepth; /* max. color depth */
SANE_Word *depth_list; /* list of color depths */
/* SANE_Range brightness; brightness range */
SANE_Range fbf_x_range; /* flattbed x range */
SANE_Range fbf_y_range; /* flattbed y range */
SANE_Bool ADF; /* ADF is installed */
SANE_Bool adf_duplex; /* does the ADF handle duplex scanning */
SANE_Range adf_x_range; /* autom. document feeder x range */
SANE_Range adf_y_range; /* autom. document feeder y range */
};
/*
Options:OPT_BRIGHTNESS, used to be after BIT_DEPTH
*/
enum {
OPT_NUM_OPTS = 0,
OPT_MODE_GROUP,
OPT_MODE,
OPT_THRESHOLD,
OPT_BIT_DEPTH,
OPT_RESOLUTION,
OPT_TRIALOPT, /* for debuggging */
OPT_PREVIEW,
OPT_SOURCE,
OPT_ADF_MODE,
OPT_PADDING, /* Selects padding of adf pages to the specified length */
OPT_GEOMETRY_GROUP,
OPT_TL_X,
OPT_TL_Y,
OPT_BR_X,
OPT_BR_Y,
NUM_OPTIONS
};
typedef enum
{ /* hardware connection to the scanner */
SANE_KODAKAIO_NODEV, /* default, no HW specified yet */
SANE_KODAKAIO_USB, /* USB interface */
SANE_KODAKAIO_NET /* network interface */
} Kodakaio_Connection_Type;
/* Structure holding the hardware description */
struct Kodak_Device
{
struct Kodak_Device *next;
int missing;
char *name;
char *model;
SANE_Device sane;
SANE_Range *x_range; /* x range w/out extension */
SANE_Range *y_range; /* y range w/out extension */
Kodakaio_Connection_Type connection;
struct KodakaioCap *cap;
};
typedef struct Kodak_Device Kodak_Device;
/* Structure holding an instance of a scanner (i.e. scanner has been opened) */
struct KodakAio_Scanner
{
struct KodakAio_Scanner *next;
struct Kodak_Device *hw;
int fd;
SANE_Option_Descriptor opt[NUM_OPTIONS];
Option_Value val[NUM_OPTIONS];
SANE_Parameters params;
SANE_Bool ack; /* scanner has finished a page (happens early with adf and padding) */
SANE_Bool eof; /* backend has finished a page (after padding with adf) */
SANE_Byte *buf, *end, *ptr;
SANE_Bool canceling;
SANE_Bool scanning; /* scan in progress */
SANE_Bool adf_loaded; /* paper in adf */
SANE_Int background[3]; /* stores background RGB components for padding */
SANE_Int left, top; /* in optres units? */
SANE_Int width, height; /* in optres units? */
/* SANE_Int threshold; 0..255 for lineart*/
/* image block data */
SANE_Int data_len;
SANE_Int block_len;
SANE_Int last_len; /* to be phased out */
SANE_Int blocks; /* to be phased out */
SANE_Int counter;
SANE_Int bytes_unread; /* to track when to stop */
/* Used to store how many bytes of the current pixel line we have already
* read in previous read attempts. Since each line will be padded
* to multiples of 512 bytes, this is needed to know which bytes
* to ignore. NOT NEEDED FOR KODAKAIO */
SANE_Int bytes_read_in_line;
SANE_Byte *line_buffer;
/* How many bytes are scanned per line */
SANE_Int scan_bytes_per_line;
};
typedef struct KodakAio_Scanner KodakAio_Scanner;
struct mode_param
{
int flags;
int colors;
int depth;
};
enum {
MODE_COLOR, MODE_GRAY, MODE_LINEART
};
#endif
|