Merge branch 'gl843'

merge-requests/1/head
Stphane Voltz 2011-11-19 09:53:06 +01:00
commit 0e409babcc
16 zmienionych plików z 488 dodań i 259 usunięć

Wyświetl plik

@ -58,33 +58,12 @@
* SANE backend for Genesys Logic GL646/GL841/GL842/GL843/GL847/GL124 based scanners
*/
#include "../include/sane/config.h"
#define BUILD 64
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#ifdef HAVE_MKDIR
#include <sys/stat.h>
#include <sys/types.h>
#endif
#include "../include/sane/sane.h"
#include "../include/sane/sanei.h"
#include "../include/sane/saneopts.h"
#define BUILD 65
#define BACKEND_NAME genesys
#include "../include/sane/sanei_backend.h"
#include "../include/sane/sanei_usb.h"
#include "../include/sane/sanei_config.h"
#include "../include/_stdint.h"
#include "../include/sane/sanei_magic.h"
#include "genesys.h"
#include "../include/sane/sanei_config.h"
#include "../include/sane/sanei_magic.h"
#include "genesys_devices.c"
static SANE_Int num_devices = 0;
@ -437,62 +416,6 @@ sanei_genesys_create_slope_table3 (Genesys_Device * dev,
return sum_time;
}
/* Generate slope table for motor movement */
/* This function translates a call of the old slope creation function to a
call to the new one
*/
static SANE_Int
genesys_create_slope_table4 (Genesys_Device * dev,
uint16_t * slope_table, int steps,
int step_type, int exposure_time,
SANE_Bool same_speed, double yres,
int power_mode)
{
unsigned int sum_time = 0;
unsigned int vtarget;
unsigned int vend;
unsigned int vstart;
DBG (DBG_proc,
"sanei_genesys_create_slope_table: %d steps, step_type = %d, "
"exposure_time = %d, same_speed = %d, yres = %.2f, power_mode = %d\n",
steps, step_type, exposure_time, same_speed, yres, power_mode);
/* final speed */
vtarget = (exposure_time * yres) / dev->motor.base_ydpi;
vstart = dev->motor.slopes[power_mode][step_type].maximum_start_speed;
vend = dev->motor.slopes[power_mode][step_type].maximum_speed;
vtarget >>= step_type;
if (vtarget > 65535)
vtarget = 65535;
vstart >>= step_type;
if (vstart > 65535)
vstart = 65535;
vend >>= step_type;
if (vend > 65535)
vend = 65535;
sum_time = sanei_genesys_generate_slope_table (slope_table, 128,
steps,
vtarget,
vstart,
vend,
dev->motor.slopes[power_mode]
[step_type].minimum_steps <<
step_type,
dev->motor.slopes[power_mode]
[step_type].g, NULL, NULL);
DBG (DBG_proc,
"sanei_genesys_create_slope_table: returns sum_time=%d, completed\n",
sum_time);
return sum_time;
}
/* alternate slope table creation function */
/* the hardcoded values (g and vstart) will go in a motor struct */
@ -635,11 +558,6 @@ sanei_genesys_create_slope_table (Genesys_Device * dev,
dev = dev;
if (dev->model->flags & GENESYS_FLAG_ALT_SLOPE_CREATE)
return genesys_create_slope_table4 (dev, slope_table, steps,
step_type, exposure_time,
same_speed, yres, power_mode);
if (dev->model->motor_type == MOTOR_5345
|| dev->model->motor_type == MOTOR_HP2300
|| dev->model->motor_type == MOTOR_HP2400)
@ -5777,7 +5695,14 @@ init_options (Genesys_Scanner * s)
s->opt[OPT_SOURCE].size = max_string_size (source_list);
s->opt[OPT_SOURCE].constraint.string_list = source_list;
s->val[OPT_SOURCE].s = strdup (FLATBED);
DISABLE (OPT_SOURCE);
if (!(model->flags & GENESYS_FLAG_HAS_UTA))
{
DISABLE (OPT_SOURCE);
}
else
{
ENABLE (OPT_SOURCE);
}
/* preview */
s->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW;
@ -7001,6 +6926,7 @@ sane_close (SANE_Handle handle)
Genesys_Scanner *prev, *s;
Genesys_Calibration_Cache *cache, *next_cache;
SANE_Status status;
SANE_Range *range;
DBG (DBG_proc, "sane_close: start\n");
@ -7064,19 +6990,22 @@ sane_close (SANE_Handle handle)
FREE_IFNOT_NULL (s->dev->sensor.blue_gamma_table);
/* for an handful of bytes .. */
free (s->opt[OPT_RESOLUTION].constraint.word_list);
free ((void *)s->opt[OPT_RESOLUTION].constraint.word_list);
free (s->val[OPT_SOURCE].s);
free (s->val[OPT_MODE].s);
free (s->val[OPT_COLOR_FILTER].s);
FREE_IFNOT_NULL (s->opt[OPT_TL_X].constraint.range);
FREE_IFNOT_NULL (s->opt[OPT_TL_Y].constraint.range);
range=s->opt[OPT_TL_X].constraint.range;
FREE_IFNOT_NULL (range);
range=s->opt[OPT_TL_Y].constraint.range;
FREE_IFNOT_NULL (range);
if (prev)
prev->next = s->next;
else
first_handle = s->next;
/* maybe todo: shut down scanner */
/* LAMP OFF : same register across all the ASICs */
sanei_genesys_write_register (s->dev, 0x03, 0x00);
/* we need this to avoid ASIC getting stuck
* in bulk writes */
@ -7334,8 +7263,8 @@ set_option_value (Genesys_Scanner * s, int option, void *val,
}
/* assign new values */
free(s->opt[OPT_TL_X].constraint.range);
free(s->opt[OPT_TL_Y].constraint.range);
free((SANE_Range *)s->opt[OPT_TL_X].constraint.range);
free((SANE_Range *)s->opt[OPT_TL_Y].constraint.range);
s->opt[OPT_TL_X].constraint.range = x_range;
s->val[OPT_TL_X].w = 0;
s->opt[OPT_TL_Y].constraint.range = y_range;

Wyświetl plik

@ -97,6 +97,9 @@ usb 0x04a7 0x04ac
# Panasonic KV-SS080
usb 0x04da 0x100f
# Hewlett Packard ScanJet 4850C
usb 0x03f0 0x1b05
# Hewlett Packard ScanJet G4010
usb 0x03f0 0x4505

Wyświetl plik

@ -515,7 +515,7 @@ static Genesys_Sensor Sensor[] = {
/* 08 09 0a 0b */
{0x00, 0x00, 0x18, 0x69} ,
/* 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d */
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x0c, 0x00, 0x2a, 0x30, 0x00, 0x00, 0x08} ,
{0x2c, 0x09, 0x22, 0xb8, 0x10, 0xf0, 0x33, 0x0c, 0x00, 0x2a, 0x30, 0x00, 0x00, 0x08} ,
/* 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e */
{0x0b, 0x0e, 0x11, 0x02, 0x05, 0x08, 0x63, 0x00, 0x40, 0x00, 0x00, 0x00, 0x6f} ,
1.0, 1.0, 1.0,
@ -1151,6 +1151,61 @@ static Genesys_Model panasonic_kvss080_model = {
100
};
static Genesys_Model hp4850c_model = {
"hewlett-packard-scanjet-4850c", /* Name */
"Hewlett Packard", /* Device vendor string */
"ScanJet 4850C", /* Device model name */
GENESYS_GL843,
NULL,
{ 2400, 1200, 600, 400, 300, 200, 150, 100, 0},
{ 2400, 1200, 600, 400, 300, 200, 150, 100, 0},
{16, 8, 0}, /* possible depths in gray mode */
{16, 8, 0}, /* possible depths in color mode */
SANE_FIX (8.0), /* Start of scan area in mm (x) */
SANE_FIX (13.00), /* Start of scan area in mm (y) */
SANE_FIX (217.9), /* Size of scan area in mm (x) 5148 pixels at 600 dpi*/
SANE_FIX (315.0), /* Size of scan area in mm (y) */
SANE_FIX (3.0), /* Start of white strip in mm (y) */
SANE_FIX (0.0), /* Start of black mark in mm (x) */
SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */
SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */
SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */
SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */
SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */
SANE_FIX (0.0), /* Size of scan area after paper sensor stops
sensing document in mm */
SANE_FIX (0.0), /* Amount of feeding needed to eject document
after finishing scanning in mm */
0, 24, 48, /* RGB CCD Line-distance correction in line number */
/* 0 38 76 OK 1200/2400 */
/* 0 24 48 OK [100,600] dpi */
COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */
SANE_FALSE, /* Is this a CIS scanner? */
SANE_FALSE, /* Is this a sheetfed scanner? */
CCD_G4050,
DAC_G4050,
GPO_G4050,
MOTOR_G4050,
GENESYS_FLAG_LAZY_INIT |
GENESYS_FLAG_OFFSET_CALIBRATION |
GENESYS_FLAG_STAGGERED_LINE |
GENESYS_FLAG_SKIP_WARMUP |
GENESYS_FLAG_DARK_CALIBRATION |
GENESYS_FLAG_CUSTOM_GAMMA,
GENESYS_HAS_SCAN_SW | GENESYS_HAS_FILE_SW | GENESYS_HAS_COPY_SW,
100,
100
};
static Genesys_Model hpg4010_model = {
"hewlett-packard-scanjet-g4010", /* Name */
"Hewlett Packard", /* Device vendor string */
@ -1226,12 +1281,12 @@ static Genesys_Model hpg4050_model = {
SANE_FIX (3.0), /* Start of white strip in mm (y) */
SANE_FIX (0.0), /* Start of black mark in mm (x) */
SANE_FIX (0.0), /* Start of scan area in TA mode in mm (x) */
SANE_FIX (0.0), /* Start of scan area in TA mode in mm (y) */
SANE_FIX (100.0), /* Size of scan area in TA mode in mm (x) */
SANE_FIX (100.0), /* Size of scan area in TA mode in mm (y) */
SANE_FIX (8.0), /* Start of scan area in TA mode in mm (x) */
SANE_FIX (13.00), /* Start of scan area in TA mode in mm (y) */
SANE_FIX (217.9), /* Size of scan area in TA mode in mm (x) */
SANE_FIX (250.0), /* Size of scan area in TA mode in mm (y) */
SANE_FIX (0.0), /* Start of white strip in TA mode in mm (y) */
SANE_FIX (40.0), /* Start of white strip in TA mode in mm (y) */
SANE_FIX (0.0), /* Size of scan area after paper sensor stops
sensing document in mm */
@ -1255,6 +1310,7 @@ static Genesys_Model hpg4050_model = {
GENESYS_FLAG_STAGGERED_LINE |
GENESYS_FLAG_SKIP_WARMUP |
GENESYS_FLAG_DARK_CALIBRATION |
GENESYS_FLAG_HAS_UTA |
GENESYS_FLAG_CUSTOM_GAMMA,
GENESYS_HAS_SCAN_SW | GENESYS_HAS_FILE_SW | GENESYS_HAS_COPY_SW,
100,
@ -2790,6 +2846,7 @@ static Genesys_USB_Device_Entry genesys_usb_device_list[] = {
{0x04a9, 0x1907, &canon_lide_700f_model},
/* GL843 devices */
{0x04da, 0x100f, &panasonic_kvss080_model},
{0x03f0, 0x1b05, &hp4850c_model},
{0x03f0, 0x4505, &hpg4010_model},
{0x03f0, 0x4605, &hpg4050_model},
/* GL124 devices */

Wyświetl plik

@ -42,6 +42,9 @@
If you do not wish that, delete this exception notice.
*/
#undef BACKEND_NAME
#define BACKEND_NAME genesys_gl124
#include "genesys_gl124.h"
/****************************************************************************

Wyświetl plik

@ -41,9 +41,6 @@
If you do not wish that, delete this exception notice.
*/
#undef BACKEND_NAME
#define BACKEND_NAME genesys_gl124
#include "genesys.h"
#define REG01 0x01

Wyświetl plik

@ -48,6 +48,9 @@
If you do not wish that, delete this exception notice.
*/
#undef BACKEND_NAME
#define BACKEND_NAME genesys_gl646
#include "genesys_gl646.h"
/**

Wyświetl plik

@ -44,9 +44,6 @@
If you do not wish that, delete this exception notice.
*/
#undef BACKEND_NAME
#define BACKEND_NAME genesys_gl646
#include "genesys.h"
/*

Wyświetl plik

@ -3,7 +3,7 @@
Copyright (C) 2003 Oliver Rauch
Copyright (C) 2003, 2004 Henning Meier-Geinitz <henning@meier-geinitz.de>
Copyright (C) 2004 Gerhard Jaeger <gerhard@gjaeger.de>
Copyright (C) 2004-2010 Stephane Voltz <stef.dev@free.fr>
Copyright (C) 2004-2011 Stéphane Voltz <stef.dev@free.fr>
Copyright (C) 2005 Philipp Schmid <philipp8288@web.de>
Copyright (C) 2005-2009 Pierre Willenbrock <pierre@pirsoft.dnsalias.org>
Copyright (C) 2006 Laurent Charpentier <laurent_pubs@yahoo.com>
@ -50,6 +50,9 @@
If you do not wish that, delete this exception notice.
*/
#undef BACKEND_NAME
#define BACKEND_NAME genesys_gl841
#include "genesys_gl841.h"
/****************************************************************************
@ -1298,9 +1301,6 @@ gl841_set_fe (Genesys_Device * dev, uint8_t set)
return SANE_STATUS_GOOD;
}
#define MOTOR_FLAG_AUTO_GO_HOME 1
#define MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE 2
#define MOTOR_ACTION_FEED 1
#define MOTOR_ACTION_GO_HOME 2
#define MOTOR_ACTION_HOME_FREE 3

Wyświetl plik

@ -41,9 +41,6 @@
If you do not wish that, delete this exception notice.
*/
#undef BACKEND_NAME
#define BACKEND_NAME genesys_gl841
#include "genesys.h"
/* Individual bits */

Wyświetl plik

@ -42,6 +42,9 @@
If you do not wish that, delete this exception notice.
*/
#undef BACKEND_NAME
#define BACKEND_NAME genesys_gl843
#include "genesys_gl843.h"
/****************************************************************************
@ -444,25 +447,37 @@ gl843_test_motor_flag_bit (SANE_Byte val)
* profile is at a specific dpihw. Use first entry of table by default.
* @param sensor_type sensor id
* @param dpi hardware dpi for the scan
* @param flags to select between XPA, XPA+IR or regular scan from OPTICAL_FLAGS_*
* @return a pointer to a Sensor_Profile struct
*/
static Sensor_Profile *get_sensor_profile(int sensor_type, int dpi)
static Sensor_Profile *get_sensor_profile(int sensor_type, int dpi, int flags)
{
unsigned int i;
unsigned int i, count;
int idx;
Sensor_Profile *sp;
if(flags & OPTICAL_FLAG_USE_XPA)
{
sp=xpa_sensors;
count=sizeof(xpa_sensors)/sizeof(Sensor_Profile);
}
else
{
sp=sensors;
count=sizeof(sensors)/sizeof(Sensor_Profile);
}
i=0;
idx=-1;
while(i<sizeof(sensors)/sizeof(Sensor_Profile))
while(i<count)
{
/* exact match */
if(sensors[i].sensor_type==sensor_type && sensors[i].dpi==dpi)
if(sp[i].sensor_type==sensor_type && sp[i].dpi==dpi)
{
return &(sensors[i]);
return &(sp[i]);
}
/* closest match */
if(sensors[i].sensor_type==sensor_type)
if(sp[i].sensor_type==sensor_type)
{
if(idx<0)
{
@ -470,8 +485,8 @@ static Sensor_Profile *get_sensor_profile(int sensor_type, int dpi)
}
else
{
if(sensors[i].dpi>=dpi
&& sensors[i].dpi<sensors[idx].dpi)
if(sp[i].dpi>=dpi
&& sp[i].dpi<sp[idx].dpi)
{
idx=i;
}
@ -487,13 +502,13 @@ static Sensor_Profile *get_sensor_profile(int sensor_type, int dpi)
idx=0;
}
return &(sensors[idx]);
return &(sp[idx]);
}
/** copy sensor specific settings */
static void
gl843_setup_sensor (Genesys_Device * dev, Genesys_Register_Set * regs, int dpi)
gl843_setup_sensor (Genesys_Device * dev, Genesys_Register_Set * regs, int dpi,int flags)
{
Genesys_Register_Set *r;
Sensor_Profile *sensor;
@ -502,7 +517,7 @@ gl843_setup_sensor (Genesys_Device * dev, Genesys_Register_Set * regs, int dpi)
DBGSTART;
dpihw=sanei_genesys_compute_dpihw(dev,dpi);
sensor=get_sensor_profile(dev->model->ccd_type, dpihw);
sensor=get_sensor_profile(dev->model->ccd_type, dpihw, flags);
for (i = 0x06; i < 0x0e; i++)
{
@ -533,6 +548,11 @@ gl843_setup_sensor (Genesys_Device * dev, Genesys_Register_Set * regs, int dpi)
{
r->value = sensor->reg71;
}
r = sanei_genesys_get_address (regs, 0x7d);
if (r)
{
r->value = 0x90;
}
r = sanei_genesys_get_address (regs, 0x9e);
if (r)
{
@ -550,7 +570,7 @@ gl843_setup_sensor (Genesys_Device * dev, Genesys_Register_Set * regs, int dpi)
sanei_genesys_set_triple(regs,REG_CK3MAP,sensor->ck3map);
sanei_genesys_set_triple(regs,REG_CK4MAP,sensor->ck4map);
DBG (DBG_proc, "gl843_setup_sensor: completed \n");
DBGCOMPLETED;
}
@ -696,6 +716,15 @@ gl843_init_registers (Genesys_Device * dev)
SETREG (0x06, 0xd8); /* SCANMOD=110, PWRBIT and GAIN4 */
SETREG (0x0a, 0x18);
SETREG (0x0b, 0x69);
/* CIS exposure is used for XPA lamp movement */
SETREG (0x10, 0x2c);
SETREG (0x11, 0x09);
SETREG (0x12, 0x22);
SETREG (0x13, 0xb8);
SETREG (0x14, 0x10);
SETREG (0x15, 0xf0);
SETREG (0x6b, 0xf4);
SETREG (0x70, 0x00);
@ -1084,11 +1113,11 @@ gl843_init_motor_regs_scan (Genesys_Device * dev,
/**@brief compute exposure to use
* compute the sensor exposure based on target resolution
*/
static int gl843_compute_exposure(Genesys_Device *dev, int xres)
static int gl843_compute_exposure(Genesys_Device *dev, int xres, int flags)
{
Sensor_Profile *sensor;
sensor=get_sensor_profile(dev->model->ccd_type, xres);
sensor=get_sensor_profile(dev->model->ccd_type, xres, flags);
return sensor->exposure;
}
@ -1100,6 +1129,7 @@ static int gl843_compute_exposure(Genesys_Device *dev, int xres)
* scan's one
* @param start logical start pixel coordinate
* @param pixels logical number of pixels to use
* @param flags to drive specific settings such no calibration, XPA use ...
* @return SANE_STATUS_GOOD if OK
*/
static SANE_Status
@ -1111,7 +1141,9 @@ gl843_init_optical_regs_scan (Genesys_Device * dev,
unsigned int pixels,
int channels,
int depth,
SANE_Bool half_ccd, int color_filter, int flags)
SANE_Bool half_ccd,
int color_filter,
int flags)
{
unsigned int words_per_line;
unsigned int startx, endx, used_pixels;
@ -1128,11 +1160,6 @@ gl843_init_optical_regs_scan (Genesys_Device * dev,
exposure,
used_res, start, pixels, channels, depth, half_ccd, flags);
/* resolution is divided according to CKSEL */
r = sanei_genesys_get_address (reg, REG18);
cksel= (r->value & REG18_CKSEL)+1;
DBG (DBG_io2, "%s: cksel=%d\n", __FUNCTION__, cksel);
/* tgtime */
tgtime=1;
if (dev->model->ccd_type == CCD_G4050 && used_res>2400)
@ -1148,7 +1175,12 @@ gl843_init_optical_regs_scan (Genesys_Device * dev,
DBG (DBG_io2, "%s: dpihw=%d (factor=%d)\n", __FUNCTION__, dpihw, factor);
/* sensor parameters */
gl843_setup_sensor (dev, reg, dpihw);
gl843_setup_sensor (dev, reg, dpihw, flags);
/* resolution is divided according to CKSEL which is known once sensor is set up*/
r = sanei_genesys_get_address (reg, REG18);
cksel= (r->value & REG18_CKSEL)+1;
DBG (DBG_io2, "%s: cksel=%d\n", __FUNCTION__, cksel);
dpiset = used_res * cksel;
/* start and end coordinate in optical dpi coordinates */
@ -1205,6 +1237,13 @@ gl843_init_optical_regs_scan (Genesys_Device * dev,
else
r->value |= REG03_LAMPPWR;
/* select XPA */
r->value &= ~REG03_XPASEL;
if (flags & OPTICAL_FLAG_USE_XPA)
{
r->value |= REG03_XPASEL;
}
/* BW threshold */
r = sanei_genesys_get_address (reg, REG2E);
r->value = dev->settings.threshold;
@ -1398,6 +1437,23 @@ gl843_init_scan_regs (Genesys_Device * dev,
}
DBG (DBG_info, "%s : stagger=%d lines\n", __FUNCTION__, stagger);
/* we enable true gray for cis scanners only, and just when doing
* scan since color calibration is OK for this mode
*/
oflags = 0;
if (flags & SCAN_FLAG_DISABLE_SHADING)
oflags |= OPTICAL_FLAG_DISABLE_SHADING;
if (flags & SCAN_FLAG_DISABLE_GAMMA)
oflags |= OPTICAL_FLAG_DISABLE_GAMMA;
if (flags & SCAN_FLAG_DISABLE_LAMP)
oflags |= OPTICAL_FLAG_DISABLE_LAMP;
if (flags & SCAN_FLAG_CALIBRATION)
oflags |= OPTICAL_FLAG_DISABLE_DOUBLE;
if(stagger)
oflags |= OPTICAL_FLAG_STAGGER;
if (flags & SCAN_FLAG_USE_XPA)
oflags |= OPTICAL_FLAG_USE_XPA;
/** @brief compute used resolution */
if (flags & SCAN_FLAG_USE_OPTICAL_RES)
{
@ -1432,6 +1488,7 @@ gl843_init_scan_regs (Genesys_Device * dev,
used_pixels++;
dummy = 0;
/* dummy = 1; XXX STEF XXX */
/* slope_dpi */
/* cis color scan is effectively a gray scan with 3 gray lines per color line and a FILTER of 0 */
@ -1439,16 +1496,17 @@ gl843_init_scan_regs (Genesys_Device * dev,
slope_dpi = yres * channels;
else
slope_dpi = yres;
slope_dpi = slope_dpi * (1 + dummy);
/* scan_step_type */
if(flags & SCAN_FLAG_FEEDING)
{
exposure=gl843_compute_exposure (dev, sanei_genesys_get_lowest_ydpi(dev));
exposure=gl843_compute_exposure (dev, sanei_genesys_get_lowest_ydpi(dev), oflags);
scan_step_type=sanei_genesys_compute_step_type (gl843_motors, dev->model->motor_type, exposure);
}
else
{
exposure = gl843_compute_exposure (dev, used_res);
exposure = gl843_compute_exposure (dev, used_res, oflags);
scan_step_type = sanei_genesys_compute_step_type(gl843_motors, dev->model->motor_type, exposure);
}
@ -1464,23 +1522,10 @@ gl843_init_scan_regs (Genesys_Device * dev,
}
/* no 16 bit gamma for this ASIC */
if (depth == 16)
flags |= SCAN_FLAG_DISABLE_GAMMA;
/* we enable true gray for cis scanners only, and just when doing
* scan since color calibration is OK for this mode
*/
oflags = 0;
if (flags & SCAN_FLAG_DISABLE_SHADING)
oflags |= OPTICAL_FLAG_DISABLE_SHADING;
if (flags & SCAN_FLAG_DISABLE_GAMMA)
oflags |= OPTICAL_FLAG_DISABLE_GAMMA;
if (flags & SCAN_FLAG_DISABLE_LAMP)
oflags |= OPTICAL_FLAG_DISABLE_LAMP;
if (flags & SCAN_FLAG_CALIBRATION)
oflags |= OPTICAL_FLAG_DISABLE_DOUBLE;
if(stagger)
oflags |= OPTICAL_FLAG_STAGGER;
{
flags |= SCAN_FLAG_DISABLE_GAMMA;
oflags |= OPTICAL_FLAG_DISABLE_GAMMA;
}
/* now _LOGICAL_ optical values used are known, setup registers */
status = gl843_init_optical_regs_scan (dev,
@ -1530,17 +1575,19 @@ gl843_init_scan_regs (Genesys_Device * dev,
mflags|=MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE;
if(flags & SCAN_FLAG_FEEDING)
mflags|=MOTOR_FLAG_FEED;
if (flags & SCAN_FLAG_USE_XPA)
mflags |= MOTOR_FLAG_USE_XPA;
status = gl843_init_motor_regs_scan (dev,
reg,
exposure,
slope_dpi,
scan_step_type,
dev->model->is_cis ? lincnt * channels : lincnt,
dummy,
move,
scan_power_mode,
mflags);
status = gl843_init_motor_regs_scan (dev,
reg,
exposure,
slope_dpi,
scan_step_type,
dev->model->is_cis ? lincnt * channels : lincnt,
dummy,
move,
scan_power_mode,
mflags);
if (status != SANE_STATUS_GOOD)
return status;
@ -1639,6 +1686,7 @@ gl843_calculate_current_setup (Genesys_Device * dev)
SANE_Bool half_ccd; /* false: full CCD res is used, true, half max CCD res is used */
int optical_res;
int oflags;
DBG (DBG_info,
"gl843_calculate_current_setup settings:\n"
@ -1667,6 +1715,12 @@ gl843_calculate_current_setup (Genesys_Device * dev)
start += dev->settings.tl_x;
start = (start * dev->sensor.optical_res) / MM_PER_INCH;
/* optical flags */
oflags=0;
if(dev->settings.scan_method==SCAN_METHOD_TRANSPARENCY)
{
oflags=OPTICAL_FLAG_USE_XPA;
}
xres = dev->settings.xres;
yres = dev->settings.yres;
@ -1733,7 +1787,7 @@ gl843_calculate_current_setup (Genesys_Device * dev)
slope_dpi = yres;
/* exposure */
exposure = gl843_compute_exposure (dev, used_res);
exposure = gl843_compute_exposure (dev, used_res, oflags);
/* scan_step_type */
scan_step_type = sanei_genesys_compute_step_type(gl843_motors, dev->model->motor_type, exposure);
@ -1803,30 +1857,26 @@ gl843_set_lamp_power (Genesys_Device * dev,
{
Genesys_Register_Set *r;
int i;
uint8_t val;
val = sanei_genesys_read_reg_from_set (regs, REG03);
if (set)
{
sanei_genesys_set_reg_from_set (regs, 0x03,
sanei_genesys_read_reg_from_set (regs,
0x03)
| REG03_LAMPPWR);
val |= REG03_LAMPPWR;
sanei_genesys_set_reg_from_set (regs, REG03, val);
for (i = 0; i < 6; i++)
{
r = sanei_genesys_get_address (dev->calib_reg, 0x10 + i);
r = sanei_genesys_get_address (regs, 0x10 + i);
r->value = dev->sensor.regs_0x10_0x1d[i];
}
}
else
{
sanei_genesys_set_reg_from_set (regs, 0x03,
sanei_genesys_read_reg_from_set (regs,
0x03)
& ~REG03_LAMPPWR);
val &= ~REG03_LAMPPWR;
sanei_genesys_set_reg_from_set (regs, REG03, val);
for (i = 0; i < 6; i++)
{
r = sanei_genesys_get_address (dev->calib_reg, 0x10 + i);
r = sanei_genesys_get_address (regs, 0x10 + i);
r->value = 0x00;
}
}
@ -2154,16 +2204,14 @@ gl843_begin_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
SANE_Bool start_motor)
{
SANE_Status status;
uint8_t val;
uint16_t dpiset,dpihw;
uint8_t val,r03;
uint16_t dpiset, dpihw;
DBGSTART;
if (reg == NULL)
return SANE_STATUS_INVAL;
/* get back the target dpihw */
sanei_genesys_get_double(reg,REG_DPISET,&dpiset);
dpihw=sanei_genesys_compute_dpihw(dev,dpiset);
sanei_genesys_get_double (reg, REG_DPISET, &dpiset);
dpihw = sanei_genesys_compute_dpihw (dev, dpiset);
/* set up GPIO for scan */
/* KV case */
@ -2172,31 +2220,73 @@ gl843_begin_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
RIE (sanei_genesys_write_register (dev, REGA9, 0x00));
RIE (sanei_genesys_write_register (dev, REGA6, 0xf6));
/* blinking led */
RIE(sanei_genesys_write_register(dev,0x7e,0x04));
RIE (sanei_genesys_write_register (dev, 0x7e, 0x04));
}
if (dev->model->gpo_type == GPO_G4050)
{
RIE (sanei_genesys_write_register (dev, REGA7, 0xfe));
RIE (sanei_genesys_write_register (dev, REGA8, 0x3e));
RIE (sanei_genesys_write_register (dev, REGA9, 0x06));
switch(dpihw)
RIE (sanei_genesys_write_register (dev, REGA7, 0xfe));
RIE (sanei_genesys_write_register (dev, REGA8, 0x3e));
RIE (sanei_genesys_write_register (dev, REGA9, 0x06));
switch (dpihw)
{
case 1200:
case 2400:
case 4800:
RIE (sanei_genesys_write_register (dev, REG6C, 0x60));
RIE (sanei_genesys_write_register (dev, REGA6, 0x46));
break;
default: /* 600 dpi case */
RIE (sanei_genesys_write_register (dev, REG6C, 0x20));
RIE (sanei_genesys_write_register (dev, REGA6, 0x44));
}
/* turn on XPA lamp if XPA is selected and lamp power on*/
r03 = sanei_genesys_read_reg_from_set (reg, REG03);
if ((r03 & REG03_XPASEL) && (r03 & REG03_LAMPPWR))
{
case 1200:
case 2400:
case 4800:
RIE (sanei_genesys_write_register (dev, REG6C, 0x60));
RIE (sanei_genesys_write_register (dev, REGA6, 0x46));
break;
default: /* 600 dpi case */
RIE (sanei_genesys_write_register (dev, REG6C, 0x20));
RIE (sanei_genesys_write_register (dev, REGA6, 0x44));
RIE (sanei_genesys_read_register (dev, REGA6, &val));
/* switch off regular lamp */
val &= 0xbf;
/* light XPA lamp at full power (2 bits for level: __11 ____) */
val |= 0x30;
RIE (sanei_genesys_write_register (dev, REGA6, val));
}
/* enable XPA lamp motor */
if (r03 & REG03_XPASEL)
{
/* set MULTFILM et GPOADF */
RIE (sanei_genesys_read_register (dev, REG6B, &val));
val |=REG6B_MULTFILM|REG6B_GPOADF;
RIE (sanei_genesys_write_register (dev, REG6B, val));
RIE (sanei_genesys_read_register (dev, REG6C, &val));
val &= ~REG6C_GPIO15;
RIE (sanei_genesys_write_register (dev, REG6C, val));
RIE (sanei_genesys_read_register (dev, REGA6, &val));
val |= REGA6_GPIO20;
RIE (sanei_genesys_write_register(dev,REGA6,val));
RIE (sanei_genesys_read_register (dev, REGA8, &val));
val &= ~REGA8_GPO27;
RIE (sanei_genesys_write_register (dev, REGA8, val));
RIE (sanei_genesys_read_register (dev, REGA9, &val));
val |= REGA9_GPO32|REGA9_GPO31;
RIE (sanei_genesys_write_register (dev, REGA9, val));
}
/* blinking led */
RIE(sanei_genesys_write_register(dev,0x7e,0x01));
RIE (sanei_genesys_write_register (dev, REG7E, 0x01));
}
/* clear scan and feed count */
RIE (sanei_genesys_write_register (dev, REG0D, REG0D_CLRLNCNT | REG0D_CLRMCNT));
RIE (sanei_genesys_write_register
(dev, REG0D, REG0D_CLRLNCNT | REG0D_CLRMCNT));
/* enable scan and motor */
RIE (sanei_genesys_read_register (dev, REG01, &val));
@ -2226,6 +2316,7 @@ gl843_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
SANE_Bool check_stop)
{
SANE_Status status;
uint8_t val;
DBG (DBG_proc, "gl843_end_scan (check_stop = %d)\n", check_stop);
if (reg == NULL)
@ -2234,6 +2325,21 @@ gl843_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
/* post scan gpio */
RIE(sanei_genesys_write_register(dev,0x7e,0x00));
/* turn off XPA lamp if XPA is selected and lamp power on*/
val = sanei_genesys_read_reg_from_set (reg, REG03);
if (val & (REG03_XPASEL|REG03_LAMPPWR))
{
sanei_genesys_read_register (dev, REGA6, &val);
/* switch on regular lamp */
val |= 0x40;
/* no XPA lamp power (2 bits for level: __11 ____) */
val &= ~0x30;
RIE (sanei_genesys_write_register (dev, REGA6, val));
}
if (dev->model->is_sheetfed == SANE_TRUE)
{
status = SANE_STATUS_GOOD;
@ -2254,6 +2360,82 @@ gl843_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
return status;
}
/** @brief park XPA lamp
* park the XPA lamp if needed
*/
static SANE_Status gl843_park_xpa_lamp (Genesys_Device * dev)
{
Genesys_Register_Set local_reg[GENESYS_GL843_MAX_REGS];
SANE_Status status;
Genesys_Register_Set *r;
uint8_t val;
int loop = 0;
DBGSTART;
/* copy scan settings */
memset (local_reg, 0, sizeof (local_reg));
memcpy (local_reg, dev->reg, GENESYS_GL843_MAX_REGS * sizeof (Genesys_Register_Set));
/* set a huge feedl and reverse direction */
sanei_genesys_set_triple(local_reg,REG_FEEDL,0xbdcd);
/* clear scan and feed count */
RIE (sanei_genesys_write_register (dev, REG0D, REG0D_CLRLNCNT | REG0D_CLRMCNT));
/* set up for reverse and no scan */
r = sanei_genesys_get_address (local_reg, REG02);
r->value |= REG02_MTRREV;
r = sanei_genesys_get_address (local_reg, REG01);
r->value &= ~REG01_SCAN;
/* write to scanner and start action */
RIE (gl843_bulk_write_register (dev, local_reg, GENESYS_GL843_MAX_REGS));
status = gl843_start_action (dev);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error, "%s: failed to start motor: %s\n",__FUNCTION__, sane_strstatus (status));
gl843_stop_action (dev);
/* restore original registers */
gl843_bulk_write_register (dev, dev->reg, GENESYS_GL843_MAX_REGS);
return status;
}
while (loop < 600) /* do not wait longer then 60 seconds */
{
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error,
"%s: failed to read home sensor: %s\n",__FUNCTION__,
sane_strstatus (status));
return status;
}
if (DBG_LEVEL >= DBG_io2)
{
sanei_genesys_print_status (val);
}
if (val & REG41_HOMESNR) /* home sensor */
{
DBG (DBG_info, "%s: reached home position\n",__FUNCTION__);
DBG (DBG_proc, "%s: finished\n",__FUNCTION__);
/* clear GPOADF to avoid reparking again */
sanei_genesys_read_register (dev, REG6B, &val);
val &= ~REG6B_GPOADF;
sanei_genesys_write_register (dev, REG6B, val);
return SANE_STATUS_GOOD;
}
usleep (100000); /* sleep 100 ms */
++loop;
}
/* we are not parked here.... should we fail ? */
DBG (DBG_info, "%s: XPA lamp is not parked\n", __FUNCTION__);
DBGCOMPLETED;
return SANE_STATUS_GOOD;
}
/** @brief Moves the slider to the home (top) position slowly
* */
@ -2273,15 +2455,24 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
DBG (DBG_proc, "gl843_slow_back_home (wait_until_home = %d)\n",
wait_until_home);
if (dev->model->gpo_type == GPO_G4050)
{
/* test if we need to park XPA lamp, we check GPOADF */
RIE (sanei_genesys_read_register (dev, REG6B, &val));
if(val & REG6B_GPOADF)
{
RIE(gl843_park_xpa_lamp(dev));
}
}
/* regular slow back home */
dev->scanhead_position_in_steps = 0;
/* first read gives HOME_SENSOR true */
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error,
"gl124_slow_back_home: failed to read home sensor: %s\n",
sane_strstatus (status));
DBG (DBG_error, "%s: failed to read home sensor: %s\n", __FUNCTION__, sane_strstatus (status));
return status;
}
usleep (100000); /* sleep 100 ms */
@ -2384,7 +2575,7 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
return SANE_STATUS_IO_ERROR;
}
DBG (DBG_info, "gl124_slow_back_home: scanhead is still moving\n");
DBG (DBG_info, "%s: scanhead is still moving\n", __FUNCTION__);
DBGCOMPLETED;
return SANE_STATUS_GOOD;
}
@ -2609,9 +2800,6 @@ gl843_feed (Genesys_Device * dev, unsigned int steps)
SCAN_FLAG_DISABLE_GAMMA |
SCAN_FLAG_FEEDING |
SCAN_FLAG_IGNORE_LINE_DISTANCE);
sanei_genesys_set_triple(local_reg,REG_EXPR,0);
sanei_genesys_set_triple(local_reg,REG_EXPG,0);
sanei_genesys_set_triple(local_reg,REG_EXPB,0);
/* clear scan and feed count */
RIE (sanei_genesys_write_register (dev, REG0D, REG0D_CLRLNCNT));
@ -3800,6 +3988,31 @@ gl843_update_hardware_sensors (Genesys_Scanner * s)
return status;
}
#ifndef UNIT_TESTING
static
#endif
SANE_Status
gl843_move_to_ta (Genesys_Device * dev)
{
SANE_Status status = SANE_STATUS_GOOD;
float resolution;
unsigned int feed;
DBGSTART;
resolution=sanei_genesys_get_lowest_ydpi(dev);
feed = 16*(SANE_UNFIX (dev->model->y_offset_calib_ta) * resolution) / MM_PER_INCH;
status = gl843_feed (dev, feed);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error, "%s: failed to move to XPA calibration area\n", __FUNCTION__);
return status;
}
DBGCOMPLETED;
return status;
}
/** @brief search for a full width black or white strip.
* This function searches for a black or white stripe across the scanning area.
@ -4251,7 +4464,7 @@ static Genesys_Command_Set gl843_cmd_set = {
gl843_search_strip,
sanei_genesys_is_compatible_calibration,
NULL,
gl843_move_to_ta,
gl843_send_shading_data,
gl843_calculate_current_setup
};

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -42,6 +42,9 @@
If you do not wish that, delete this exception notice.
*/
#undef BACKEND_NAME
#define BACKEND_NAME genesys_gl847
#include "genesys_gl847.h"
/****************************************************************************

Wyświetl plik

@ -41,9 +41,6 @@
If you do not wish that, delete this exception notice.
*/
#undef BACKEND_NAME
#define BACKEND_NAME genesys_gl847
#include "genesys.h"
#define REG01 0x01

Wyświetl plik

@ -41,28 +41,9 @@
whether to permit this exception to apply to your modifications.
If you do not wish that, delete this exception notice.
*/
#include "../include/sane/config.h"
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include "../include/sane/sane.h"
#include "../include/sane/sanei.h"
#include "../include/sane/saneopts.h"
#ifndef HACK
#undef BACKEND_NAME
#define BACKEND_NAME genesys_low
#endif
#include "../include/sane/sanei_backend.h"
#include "../include/sane/sanei_config.h"
#include "../include/sane/sanei_usb.h"
#include "../include/_stdint.h"
#include "genesys_low.h"
/* ------------------------------------------------------------------------ */

Wyświetl plik

@ -67,6 +67,10 @@
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_MKDIR
#include <sys/stat.h>
#include <sys/types.h>
#endif
#include "../include/sane/sane.h"
#include "../include/sane/sanei.h"
@ -115,7 +119,7 @@
#define GENESYS_FLAG_MUST_WAIT (1 << 10) /**> tells wether the scanner must wait for the head when parking */
#define GENESYS_FLAG_ALT_SLOPE_CREATE (1 << 11) /**> use alternative slope creation function */
#define GENESYS_FLAG_HAS_UTA (1 << 11) /**> scanner has a transparency adapter */
#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*/
#define GENESYS_FLAG_CUSTOM_GAMMA (1 << 13) /**> allow custom gamma tables */
@ -744,27 +748,30 @@ typedef struct {
#define FAST_TABLE 3 /* table 4 at 0x5800 for gl124 */
#define HOME_TABLE 4 /* table 5 at 0x6000 for gl124 */
#define SCAN_FLAG_SINGLE_LINE 0x001
#define SCAN_FLAG_DISABLE_SHADING 0x002
#define SCAN_FLAG_DISABLE_GAMMA 0x004
#define SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE 0x008
#define SCAN_FLAG_IGNORE_LINE_DISTANCE 0x010
#define SCAN_FLAG_USE_OPTICAL_RES 0x020
#define SCAN_FLAG_DISABLE_LAMP 0x040
#define SCAN_FLAG_DYNAMIC_LINEART 0x080
#define SCAN_FLAG_CALIBRATION 0x100
#define SCAN_FLAG_FEEDING 0x200
#define SCAN_FLAG_SINGLE_LINE 0x001
#define SCAN_FLAG_DISABLE_SHADING 0x002
#define SCAN_FLAG_DISABLE_GAMMA 0x004
#define SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE 0x008
#define SCAN_FLAG_IGNORE_LINE_DISTANCE 0x010
#define SCAN_FLAG_USE_OPTICAL_RES 0x020
#define SCAN_FLAG_DISABLE_LAMP 0x040
#define SCAN_FLAG_DYNAMIC_LINEART 0x080
#define SCAN_FLAG_CALIBRATION 0x100
#define SCAN_FLAG_FEEDING 0x200
#define SCAN_FLAG_USE_XPA 0x400
#define MOTOR_FLAG_AUTO_GO_HOME 1
#define MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE 2
#define MOTOR_FLAG_FEED 4
#define MOTOR_FLAG_AUTO_GO_HOME 0x01
#define MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE 0x02
#define MOTOR_FLAG_FEED 0x04
#define MOTOR_FLAG_USE_XPA 0x08
#define OPTICAL_FLAG_DISABLE_GAMMA 1
#define OPTICAL_FLAG_DISABLE_SHADING 2
#define OPTICAL_FLAG_DISABLE_LAMP 4
#define OPTICAL_FLAG_ENABLE_LEDADD 8
#define OPTICAL_FLAG_DISABLE_DOUBLE 16
#define OPTICAL_FLAG_STAGGER 32
#define OPTICAL_FLAG_DISABLE_GAMMA 0x01
#define OPTICAL_FLAG_DISABLE_SHADING 0x02
#define OPTICAL_FLAG_DISABLE_LAMP 0x04
#define OPTICAL_FLAG_ENABLE_LEDADD 0x08
#define OPTICAL_FLAG_DISABLE_DOUBLE 0x10
#define OPTICAL_FLAG_STAGGER 0x20
#define OPTICAL_FLAG_USE_XPA 0x40
/*--------------------------------------------------------------------------*/
/* common functions needed by low level specific functions */

Wyświetl plik

@ -74,7 +74,13 @@
:interface "USB"
:usbid "0x03f0" "0x1405"
:status :complete
:comment "1200x1200 dpi max, same as HP3670C"
:comment "1200x1200 dpi max, same as HP 3670C"
:model "ScanJet 4850C"
:interface "USB"
:usbid "0x03f0" "0x1b05"
:status :untested
:comment "resolution from 100 to 2400 supported, UTA not supported yet"
:model "ScanJet G4010"
:interface "USB"