/* sane - Scanner Access Now Easy.
Copyright (C) 2009-2012 stef.dev@free.fr
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; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
/** @file p5_device.h
* @brief Declaration of low level structures used by the p5 backend.
*
* The structures and function declared here are used to do the low level
* communication with the physical device.
*/
#ifndef P5_DEVICE_H
#define P5_DEVICE_H
#include
#include
#include
#include "../include/_stdint.h"
#ifdef HAVE_LINUX_PPDEV_H
#include
#include
#include
#include
#include
#include
#endif
/** @name debugging levels
*/
/* @{ */
#define DBG_error0 0 /* errors/warnings printed even with devuglevel 0 */
#define DBG_error 1 /* fatal errors */
#define DBG_warn 2 /* warnings and non-fatal errors */
#define DBG_info 4 /* informational messages */
#define DBG_proc 8 /* starting/finishing functions */
#define DBG_trace 16 /* tracing messages */
#define DBG_io 32 /* io functions */
#define DBG_io2 64 /* io functions that are called very often */
#define DBG_data 128 /* log image data */
/* @} */
/**
* maximal number of resolutions
*/
#define MAX_RESOLUTIONS 8
/**> sensor's number of pixels 8.5' @ 300 dpi */
#define MAX_SENSOR_PIXELS 2550
/**> number of lines to skip when doing calibration */
#define CALIBRATION_SKIP_LINES 80
/**> last value considered as black for calibration */
#define BLACK_LEVEL 40
/**> white target value for calibration */
#define WHITE_TARGET 220.0
/** per dpi calibration rgb data
* Calibration data structure
*/
typedef struct P5_Calibration_Data
{
unsigned int dpi;
uint8_t black_data[MAX_SENSOR_PIXELS * 3];
uint8_t white_data[MAX_SENSOR_PIXELS * 3];
} P5_Calibration_Data;
/**
* This structure describes a particular model which is handled by the backend.
* Contained data is immutable and is used to initialize the P5_Device
* structure.
*/
typedef struct P5_Model
{
/** @name device identifier
* These values are set up once the physical device has been detected. They
* are used to build the return value of sane_get_devices().
*/
/* @{ */
SANE_String_Const name;
SANE_String_Const vendor;
SANE_String_Const product;
SANE_String_Const type;
/* @} */
/** @name resolution
* list of avalailable physical resolution.
* The resolutions must sorted from lower to higher value. The list is terminated
* by a value of 0.
*/
/* @{ */
int xdpi_values[MAX_RESOLUTIONS]; /** possible x resolutions */
int ydpi_values[MAX_RESOLUTIONS]; /** possible y resolutions */
/* @} */
/** @name scan area description
* Minimal and maximal values. It's easier to have dedicated members instead
* of searching these values in the dpi lists. They are initialized from dpi
* lists.
*/
/* @{ */
int max_xdpi; /** physical maximum x dpi */
int max_ydpi; /** physical maximum y dpi */
int min_xdpi; /** physical minimum x dpi */
int min_ydpi; /** physical minimum y dpi */
/* @} */
/** @name line distance shift
* Distance between CCD arrays for each color. Expressed in line
* number at maximum motor resolution.
*/
int lds;
/** @name scan area description
* The geometry values are expressed from the head parking position,
* or the start. For a given model, the scan area selected by a frontend
* will have to fit within these values.
*/
/* @{ */
SANE_Fixed x_offset; /** Start of scan area in mm */
SANE_Fixed y_offset; /** Start of scan area in mm */
SANE_Fixed x_size; /** Size of scan area in mm */
SANE_Fixed y_size; /** Size of scan area in mm */
/* @} */
} P5_Model;
/**
* Enumeration of configuration options for a device. It must starts at 0.
*/
enum P5_Configure_Option
{
CFG_MODEL_NAME = 0, /**