Version 0.1.38:

Removed changes regarding 12/14 bit support because of SANE
  feature freeze for 1.0.4.
  The following fixes are in the software compared to the version
  prior to the feature freeze:
  - refresh UI after a change in the scan mode setting (was not updated
    when going from Binary to Gray or vice versa)
  - Read values for "line distance" from the scanner instead of using
    hardcoded values. This makes sure the backend always uses the correct
    values regardless of firmware version.
  - Fixed an "off-by-one" error in the color reordering routine that
    caused weird artifacts in some instances.
DEVEL_2_0_BRANCH-1
Karl Heinz Kremer 2000-12-03 21:59:14 +00:00
rodzic 29a18dce83
commit 8ae8ba2e64
1 zmienionych plików z 130 dodań i 180 usunięć

Wyświetl plik

@ -16,7 +16,7 @@
*/
#define SANE_EPSON_VERSION "SANE Epson Backend v0.1.37 - 2000-12-03"
#define SANE_EPSON_VERSION "SANE Epson Backend v0.1.38 - 2000-12-03"
/*
This file is part of the SANE package.
@ -58,6 +58,15 @@
If you do not wish that, delete this exception notice. */
/*
2000-12-03 Version 0.1.38
removed changes regarding 12/14 bit support because
of SANE feature freeze for 1.0.4. The D1 fix for
reading the values from the scanner instead of using
hardcoded values and the fix for the off-by-one error
in the reorder routine are still in the code base.
Also force reload after change of scan mode.
The full backend can be downloaded from my web site at
http://www.freecolormanagement.com/sane
2000-12-03 Fixed off-by-one error in color reordering function.
2000-12-02 Read information about optical resolution and line
distance from scanner instead of hardcoded values.
@ -386,10 +395,52 @@ static EpsonCmdRec epson_cmd [ ] =
/*
* Definition of the mode_param struct, that is used to
* specify the valid parameters for the different scan modes.
* Depending on the capabilities of the scanner three different
* param sets are used: 8 bit, 12 bit and 16 bit per color channel
.) exposure time
- no docs found
- from epson_31101999.c
u_char default_tval[4] = {2, 0x80, 0x80, 0x80};
u_char neg_tval[4] = {2, 0x8e, 0x86, 0x92};
ESC T + 4 byte
- there are defs in include/sane/saneopts.h
#define SANE_NAME_CAL_EXPOS_TIME "cal-exposure-time"
#define SANE_NAME_CAL_EXPOS_TIME_R "cal-exposure-time-r"
#define SANE_NAME_CAL_EXPOS_TIME_G "cal-exposure-time-g"
#define SANE_NAME_CAL_EXPOS_TIME_B "cal-exposure-time-b"
#define SANE_NAME_SCAN_EXPOS_TIME "scan-exposure-time"
#define SANE_NAME_SCAN_EXPOS_TIME_R "scan-exposure-time-r"
#define SANE_NAME_SCAN_EXPOS_TIME_G "scan-exposure-time-g"
#define SANE_NAME_SCAN_EXPOS_TIME_B "scan-exposure-time-b"
#define SANE_NAME_SELECT_EXPOSURE_TIME "select-exposure-time"
Einmal für Calibrierung, andere für Scan. lamp-density gibt es auch noch.
One for calibration, other one for scan. There is also lamp-density defined.
- da war noch mal die blöde mail wo ganz genau drinsteht wie das geht.
.) 12 bit
- there are defs in include/sane/saneopts.h
#define SANE_NAME_TEN_BIT_MODE "ten-bit-mode"
#define SANE_NAME_TWELVE_BIT_MODE "twelve-bit-mode"
- not used by other backends.
*/
/*
*
*
*/
struct mode_param {
@ -399,77 +450,31 @@ struct mode_param {
int depth;
};
static const struct mode_param mode_params_8 [ ] =
static const struct mode_param mode_params [ ] =
{ { 0, 0x00, 0x30, 1}
, { 0, 0x00, 0x30, 8}
, { 1, 0x02, 0x00, 8}
};
static const struct mode_param mode_params_12 [ ] =
static const struct mode_param mode_params_5 [ ] =
{ { 0, 0x00, 0x30, 1}
, { 0, 0x00, 0x30, 8}
, { 0, 0x00, 0x30, 12}
, { 1, 0x03, 0x10, 8}
, { 1, 0x03, 0x10, 12}
};
static const struct mode_param mode_params_14 [ ] =
{ { 0, 0x00, 0x30, 1}
, { 0, 0x00, 0x30, 8}
, { 0, 0x00, 0x30, 14}
, { 1, 0x03, 0x10, 8}
, { 1, 0x03, 0x10, 14}
};
static const struct mode_param mode_params_16 [ ] =
{ { 0, 0x00, 0x30, 1}
, { 0, 0x00, 0x30, 8}
, { 0, 0x00, 0x30, 16}
, { 1, 0x03, 0x10, 8}
, { 1, 0x03, 0x10, 16}
};
static const SANE_String_Const mode_list_8 [ ] =
static const SANE_String_Const mode_list [ ] =
{ "Binary"
, "Gray"
, "Color"
, NULL
};
static const SANE_String_Const mode_list_12 [ ] =
static const SANE_String_Const mode_list_5 [ ] =
{ "Binary"
, "Gray (8 bit)"
, "Gray (12 bit)"
, "Color (24 bit)"
, "Color (36 bit)"
, "Gray"
, "Color"
, NULL
};
static const SANE_String_Const mode_list_14 [ ] =
{ "Binary"
, "Gray (8 bit)"
, "Gray (14 bit)"
, "Color (24 bit)"
, "Color (42 bit)"
, NULL
};
static const SANE_String_Const mode_list_16 [ ] =
{ "Binary"
, "Gray (8 bit)"
, "Gray (16 bit)"
, "Color (24 bit)"
, "Color (48 bit)"
, NULL
};
static const SANE_String_Const * mode_list = NULL;
static const struct mode_param * mode_params = NULL;
/*
* Define the different scan sources:
*/
#define FBF_STR "Flatbed"
#define TPU_STR "Transparency Unit"
@ -477,8 +482,7 @@ static const struct mode_param * mode_params = NULL;
/*
* source list need one dummy entry (save device settings is crashing).
* NOTE: no const - this list gets created while exploring the capabilities
* of the scanner.
* NOTE: no const.
*/
static SANE_String_Const source_list [ ] =
@ -488,7 +492,6 @@ static SANE_String_Const source_list [ ] =
, NULL
};
/* some defines to make handling the TPU easier: */
#define FILM_TYPE_POSITIVE (0)
#define FILM_TYPE_NEGATIVE (1)
@ -562,10 +565,10 @@ static const SANE_String_Const halftone_list_7 [ ] =
};
static int dropout_params [ ] =
{ 0x00 /* none */
, 0x10 /* red */
, 0x20 /* green */
, 0x30 /* blue */
{ 0x00
, 0x10
, 0x20
, 0x30
};
static const SANE_String_Const dropout_list [ ] =
@ -577,10 +580,7 @@ static const SANE_String_Const dropout_list [ ] =
};
/*
* Color correction:
* One array for the actual parameters that get sent to the scanner (color_params[]),
* one array for the strings that get displayed in the user interface (color_list[])
* and one array to mark the user defined color correction (dolor_userdefined[]).
* NOTE: if enable "User defined" change also default from 4 to 5.
*/
static int color_params [ ] =
@ -611,13 +611,6 @@ static const SANE_String_Const color_list [ ] =
, NULL
};
/*
* Gamma correction:
* The A and B level scanners work differently than the D level scanners, therefore
* I define two different sets of arrays, plus one set of variables that get set to
* the actally used params and list arrays at runtime.
*/
static int gamma_params_ab [ ] =
{ 0x01
, 0x03
@ -664,11 +657,6 @@ static SANE_Bool gamma_userdefined_d [ ] =
static SANE_Bool * gamma_userdefined;
static int * gamma_params;
/* Bay list:
* this is used for the FilmScan
*/
static const SANE_String_Const bay_list [ ] =
{ " 1 "
, " 2 "
@ -687,18 +675,13 @@ static const SANE_Range u8_range = { 0, 255, 0};
static const SANE_Range s8_range = { -127, 127, 0};
static const SANE_Range zoom_range = { 50, 200, 0};
/*
* The "switch_params" are used for several boolean choices
*/
static int switch_params [ ] =
{
0,
1
};
static int mirror_params [ ] =
{ 0
, 1
};
#define mirror_params switch_params
#define speed_params switch_params
#define film_params switch_params
#define speed_params mirror_params
#define film_params mirror_params
static const SANE_Range outline_emphasis_range = { -2, 2, 0 };
/* static const SANE_Range gamma_range = { -2, 2, 0 }; */
@ -1140,10 +1123,10 @@ static SANE_Status set_gamma_table ( Epson_Scanner * s) {
Print the gamma tables before sending them to the scanner.
*/
if (DBG_LEVEL > 10) {
if (DBG_LEVEL > 0) {
int c, i, j;
DBG (1, "set_gamma_table()\n");
DBG (10, "set_gamma_table()\n");
for (c=0; c<4; c++) {
for (i=0; i<256; i+= 16) {
DBG (1, "Gamma Table[%d][%d] ", c, i);
@ -1750,42 +1733,6 @@ static SANE_Status attach ( const char * dev_name, Epson_Device * * devp) {
} /* request identity 2 */
/*
* Check for the max. supported color depth.
*/
if (set_data_format(s, 16) == SANE_STATUS_GOOD)
{
s->hw->maxDepth = 16;
mode_list = mode_list_16;
mode_params = mode_params_16;
}
else if (set_data_format(s, 14) == SANE_STATUS_GOOD)
{
s->hw->maxDepth = 14;
mode_list = mode_list_14;
mode_params = mode_params_14;
}
else if (set_data_format(s, 12) == SANE_STATUS_GOOD)
{
s->hw->maxDepth = 12;
mode_list = mode_list_12;
mode_params = mode_params_12;
}
else
{
s->hw->maxDepth = 8;
mode_list = mode_list_8;
mode_params = mode_params_8;
}
DBG( 5, "Max. supported color depth = %d\n", s->hw->maxDepth);
/*
* Check for "request focus position" command. If this command is
* supported, then the scanner does also support the "set focus
@ -3374,8 +3321,9 @@ static SANE_Status setvalue( SANE_Handle handle,
sane_optstate( ic && iccu, s, OPT_CCT_9, &reload );
}
handle_depth_halftone( s, &reload );
reload = SANE_TRUE;
handle_depth_halftone( s, &reload );
break;
}
@ -3495,20 +3443,13 @@ SANE_Status sane_control_option ( SANE_Handle handle,
}
/*
* sane_get_parameters()
*
* This function is part of the SANE API and gets called when the front end
* requests information aobut the scan configuration (e.g. color depth, mode,
* bytes and pixels per line, number of lines. This information is returned
* in the SANE_Parameters structure.
*
*/
SANE_Status sane_get_parameters ( SANE_Handle handle, SANE_Parameters * params)
{
SANE_Status sane_get_parameters ( SANE_Handle handle, SANE_Parameters * params) {
Epson_Scanner * s = ( Epson_Scanner *) handle;
int ndpi;
int bytes_per_pixel;
DBG(5, "sane_get_parameters()\n");
@ -3531,36 +3472,15 @@ SANE_Status sane_get_parameters ( SANE_Handle handle, SANE_Parameters * params)
, SANE_UNFIX( s->val[ OPT_BR_Y].w)
);
/* Calculate bytes_per_pixel and bytes_per_line for
* any color depths.
*
* The color depth is stored in mode_params.depth:
*/
s->params.depth = mode_params[ s->val[ OPT_MODE].w].depth;
if (s->params.depth > 8)
{
if (s->val[OPT_PREVIEW].w) /* for preview the frontends can only handle 8 bits */
s->params.depth = 8;
else
s->params.depth = 16; /* the frontends can only handle 8 or 16 bits for gray or color */
}
bytes_per_pixel = s->params.depth / 8;
if (s->params.depth % 8) /* just in case ... */
{
bytes_per_pixel++;
}
/* pixels_per_line seems to be rounded to the next 8bit boundary */
/* pixels_per_line seems to be 8 * n. */
s->params.pixels_per_line = s->params.pixels_per_line & ~7;
s->params.last_frame = SANE_TRUE;
s->params.depth = mode_params[ s->val[ OPT_MODE].w].depth;
if( mode_params[ s->val[ OPT_MODE].w].color) {
s->params.format = SANE_FRAME_RGB;
s->params.bytes_per_line = 3 * s->params.pixels_per_line * bytes_per_pixel;
s->params.bytes_per_line = 3 * s->params.pixels_per_line;
} else {
s->params.format = SANE_FRAME_GRAY;
s->params.bytes_per_line = s->params.pixels_per_line * s->params.depth / 8;
@ -3573,15 +3493,11 @@ SANE_Status sane_get_parameters ( SANE_Handle handle, SANE_Parameters * params)
}
/*
* sane_start()
*
* This function is part of the SANE API and gets called from the front end to
* start the scan process.
*
*/
SANE_Status sane_start ( SANE_Handle handle)
{
SANE_Status sane_start ( SANE_Handle handle) {
Epson_Scanner * s = ( Epson_Scanner *) handle;
SANE_Status status;
const struct mode_param * mparam;
@ -3591,7 +3507,25 @@ SANE_Status sane_start ( SANE_Handle handle)
int lcount;
int i, j; /* loop counter */
DBG( 1, "preview %d\n", s->val[ OPT_PREVIEW].w);
#if 0
status = sane_get_parameters( handle, NULL);
if( status != SANE_STATUS_GOOD)
return status;
#endif
open_scanner( s);
/*
* NOTE: added cause there was error reported for some scanner.
* NOTE: disabled cause of batch use scanimage and ADF.
* reset( s);
*/
/*
*
*/
/*
* There is some undocumented special with TPU enable/disable.
* TPU power ESC e status
@ -3602,6 +3536,11 @@ SANE_Status sane_start ( SANE_Handle handle)
*
* probably it make no sense to scan with TPU powered on and source flatbed, cause light
* will come from both sides.
*/
/*
*
*/
if( s->hw->extension) {
@ -3700,21 +3639,11 @@ SANE_Status sane_start ( SANE_Handle handle)
}
/*
* Set the color depth. If a preview is requested, then always
* scan in 8bit mode if grayscale or color mode was selected. We
* are not testing for any of these modes, if preview is selected,
* and the color depth was more than 8 bits, then we just reset it
* to 8 bits.
*
*/
mparam = mode_params + s->val[ OPT_MODE].w;
if (s->val[OPT_PREVIEW].w && mparam->depth > 8)
status = set_data_format( s, 8);
else
status = set_data_format( s, mparam->depth);
status = set_data_format( s, mparam->depth);
if( SANE_STATUS_GOOD != status) {
DBG( 1, "sane_start: set_data_format failed: %s\n", sane_strstatus( status));
@ -3723,6 +3652,7 @@ SANE_Status sane_start ( SANE_Handle handle)
/*
* The byte sequence mode was introduced in B5, for B34 we need line sequence mode
*/
if( (s->hw->cmd->level[0] == 'D' ||
@ -3776,6 +3706,7 @@ SANE_Status sane_start ( SANE_Handle handle)
}
#if 1
if( SANE_OPTION_IS_ACTIVE( s->opt[ OPT_SPEED].cap) ) {
if( s->val[ OPT_PREVIEW].w)
@ -3789,6 +3720,9 @@ SANE_Status sane_start ( SANE_Handle handle)
}
}
#else
status = set_speed( s, mode_params[ s->val[ OPT_MODE]].depth == 1 ? 1 : 0);
#endif
/*
* use of speed_params is ok here since they are false and true.
@ -3883,6 +3817,14 @@ SANE_Status sane_start ( SANE_Handle handle)
}
}
#if 0
status = set_color_correction( s, 0x80);
if( SANE_STATUS_GOOD != status) {
DBG( 1, "sane_start: set_color_correction failed: %s\n", sane_strstatus (status));
return status;
}
#else
/*
* TODO: think about if SANE_OPTION_IS_ACTIVE is a good criteria to send commands.
*/
@ -3906,7 +3848,7 @@ SANE_Status sane_start ( SANE_Handle handle)
return status;
}
}
#endif
if (s->hw->cmd->set_threshold != 0 && SANE_OPTION_IS_ACTIVE( s->opt[ OPT_THRESHOLD].cap))
{
@ -4241,7 +4183,15 @@ static SANE_Status read_data_block ( Epson_Scanner * s, EpsonDataRec * result) {
if( result->status & STATUS_FER) {
DBG( 1, "fatal error - Status = %02x\n", result->status);
#if 0
/* check extended status if the option bit in status is set */
if( result->status & STATUS_OPTION) {
status = check_ext_status( s);
} else
status = SANE_STATUS_INVAL;
#else
status = check_ext_status( s);
#endif
/*
* Hack Alert!!!