genesys code cleanup

- create an include file for genesys_gl841.c
- simplify includes
- cleanup warnings
merge-requests/1/head
Stphane Voltz 2011-11-02 08:33:45 +01:00
rodzic bbecafdfba
commit 11d8819768
10 zmienionych plików z 114 dodań i 455 usunięć

Wyświetl plik

@ -480,7 +480,7 @@ libsane_fujitsu_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS)
libsane_fujitsu_la_LIBADD = $(COMMON_LIBS) libfujitsu.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo ../sanei/sanei_config2.lo sane_strstatus.lo ../sanei/sanei_usb.lo ../sanei/sanei_scsi.lo ../sanei/sanei_magic.lo $(MATH_LIB) $(SCSI_LIBS) $(USB_LIBS) $(RESMGR_LIBS) libsane_fujitsu_la_LIBADD = $(COMMON_LIBS) libfujitsu.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo ../sanei/sanei_config2.lo sane_strstatus.lo ../sanei/sanei_usb.lo ../sanei/sanei_scsi.lo ../sanei/sanei_magic.lo $(MATH_LIB) $(SCSI_LIBS) $(USB_LIBS) $(RESMGR_LIBS)
EXTRA_DIST += fujitsu.conf.in EXTRA_DIST += fujitsu.conf.in
libgenesys_la_SOURCES = genesys.c genesys.h genesys_gl646.c genesys_gl646.h genesys_gl841.c genesys_gl843.c genesys_gl843.h genesys_gl847.c genesys_gl847.h genesys_gl124.c genesys_gl124.h genesys_low.c genesys_low.h libgenesys_la_SOURCES = genesys.c genesys.h genesys_gl646.c genesys_gl646.h genesys_gl841.c genesys_gl841.h genesys_gl843.c genesys_gl843.h genesys_gl847.c genesys_gl847.h genesys_gl124.c genesys_gl124.h genesys_low.c genesys_low.h
libgenesys_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=genesys libgenesys_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=genesys
nodist_libsane_genesys_la_SOURCES = genesys-s.c nodist_libsane_genesys_la_SOURCES = genesys-s.c

Wyświetl plik

@ -2037,7 +2037,7 @@ nodist_libsane_fujitsu_la_SOURCES = fujitsu-s.c
libsane_fujitsu_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=fujitsu libsane_fujitsu_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=fujitsu
libsane_fujitsu_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_fujitsu_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS)
libsane_fujitsu_la_LIBADD = $(COMMON_LIBS) libfujitsu.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo ../sanei/sanei_config2.lo sane_strstatus.lo ../sanei/sanei_usb.lo ../sanei/sanei_scsi.lo ../sanei/sanei_magic.lo $(MATH_LIB) $(SCSI_LIBS) $(USB_LIBS) $(RESMGR_LIBS) libsane_fujitsu_la_LIBADD = $(COMMON_LIBS) libfujitsu.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo ../sanei/sanei_config2.lo sane_strstatus.lo ../sanei/sanei_usb.lo ../sanei/sanei_scsi.lo ../sanei/sanei_magic.lo $(MATH_LIB) $(SCSI_LIBS) $(USB_LIBS) $(RESMGR_LIBS)
libgenesys_la_SOURCES = genesys.c genesys.h genesys_gl646.c genesys_gl646.h genesys_gl841.c genesys_gl843.c genesys_gl843.h genesys_gl847.c genesys_gl847.h genesys_gl124.c genesys_gl124.h genesys_low.c genesys_low.h libgenesys_la_SOURCES = genesys.c genesys.h genesys_gl646.c genesys_gl646.h genesys_gl841.c genesys_gl841.h genesys_gl843.c genesys_gl843.h genesys_gl847.c genesys_gl847.h genesys_gl124.c genesys_gl124.h genesys_low.c genesys_low.h
libgenesys_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=genesys libgenesys_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=genesys
nodist_libsane_genesys_la_SOURCES = genesys-s.c nodist_libsane_genesys_la_SOURCES = genesys-s.c
libsane_genesys_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=genesys libsane_genesys_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=genesys

Wyświetl plik

@ -3986,6 +3986,13 @@ genesys_warmup_lamp (Genesys_Device * dev)
DBG (DBG_proc, "genesys_warmup_lamp: start\n"); DBG (DBG_proc, "genesys_warmup_lamp: start\n");
/* check if the current chipset implements warmup */
if(dev->model->cmd_set->init_regs_for_warmup==NULL)
{
DBG (DBG_error, "%s: init_regs_for_warmup not implemented\n", __FUNCTION__);
return status;
}
dev->model->cmd_set->init_regs_for_warmup (dev, dev->reg, &channels, &total_size); dev->model->cmd_set->init_regs_for_warmup (dev, dev->reg, &channels, &total_size);
first_line = malloc (total_size); first_line = malloc (total_size);
if (!first_line) if (!first_line)

Wyświetl plik

@ -40,28 +40,10 @@
whether to permit this exception to apply to your modifications. whether to permit this exception to apply to your modifications.
If you do not wish that, delete this exception notice. 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 #undef BACKEND_NAME
#define BACKEND_NAME genesys_gl124 #define BACKEND_NAME genesys_gl124
#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.h" #include "genesys.h"
#define REG01 0x01 #define REG01 0x01

Wyświetl plik

@ -2,7 +2,7 @@
Copyright (C) 2003-2004 Henning Meier-Geinitz <henning@meier-geinitz.de> Copyright (C) 2003-2004 Henning Meier-Geinitz <henning@meier-geinitz.de>
Copyright (C) 2004-2005 Gerhard Jaeger <gerhard@gjaeger.de> Copyright (C) 2004-2005 Gerhard Jaeger <gerhard@gjaeger.de>
Copyright (C) 2004-2010 Stéphane Voltz <stef.dev@free.fr> Copyright (C) 2004-2011 Stéphane Voltz <stef.dev@free.fr>
Copyright (C) 2005-2009 Pierre Willenbrock <pierre@pirsoft.dnsalias.org> Copyright (C) 2005-2009 Pierre Willenbrock <pierre@pirsoft.dnsalias.org>
This file is part of the SANE package. This file is part of the SANE package.
@ -43,26 +43,10 @@
whether to permit this exception to apply to your modifications. whether to permit this exception to apply to your modifications.
If you do not wish that, delete this exception notice. 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"
#undef BACKEND_NAME #undef BACKEND_NAME
#define BACKEND_NAME genesys_gl646 #define BACKEND_NAME genesys_gl646
#include "../include/sane/sanei_backend.h"
#include "../include/sane/sanei_config.h"
#include "../include/sane/sanei_usb.h"
#include "../include/_stdint.h"
#include "genesys.h" #include "genesys.h"
/* /*

Wyświetl plik

@ -50,332 +50,7 @@
If you do not wish that, delete this exception notice. If you do not wish that, delete this exception notice.
*/ */
#undef BACKEND_NAME #include "genesys_gl841.h"
#define BACKEND_NAME genesys_gl841
#include "../include/sane/config.h"
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include "../include/_stdint.h"
#include "../include/sane/sane.h"
#include "../include/sane/sanei.h"
#include "../include/sane/saneopts.h"
#include "../include/sane/sanei_backend.h"
#include "../include/sane/sanei_config.h"
#include "../include/sane/sanei_usb.h"
#include "genesys.h"
/* Individual bits */
/*adapted to sanei_gl841
*
*todo: add macros
*
*/
#define REG01_CISSET 0x80
#define REG01_DOGENB 0x40
#define REG01_DVDSET 0x20
#define REG01_M16DRAM 0x08
#define REG01_DRAMSEL 0x04
#define REG01_SHDAREA 0x02
#define REG01_SCAN 0x01
#define REG02_NOTHOME 0x80
#define REG02_ACDCDIS 0x40
#define REG02_AGOHOME 0x20
#define REG02_MTRPWR 0x10
#define REG02_FASTFED 0x08
#define REG02_MTRREV 0x04
#define REG02_HOMENEG 0x02
#define REG02_LONGCURV 0x01
#define REG03_LAMPDOG 0x80
#define REG03_AVEENB 0x40
#define REG03_XPASEL 0x20
#define REG03_LAMPPWR 0x10
#define REG03_LAMPTIM 0x0f
#define REG04_LINEART 0x80
#define REG04_BITSET 0x40
#define REG04_AFEMOD 0x30
#define REG04_FILTER 0x0c
#define REG04_FESET 0x03
#define REG04S_AFEMOD 4
#define REG05_DPIHW 0xc0
#define REG05_DPIHW_600 0x00
#define REG05_DPIHW_1200 0x40
#define REG05_DPIHW_2400 0x80
#define REG05_MTLLAMP 0x30
#define REG05_GMMENB 0x08
#define REG05_MTLBASE 0x03
#define REG06_SCANMOD 0xe0
#define REG06S_SCANMOD 5
#define REG06_PWRBIT 0x10
#define REG06_GAIN4 0x08
#define REG06_OPTEST 0x07
#define REG07_SRAMSEL 0x08
#define REG07_FASTDMA 0x04
#define REG07_DMASEL 0x02
#define REG07_DMARDWR 0x01
#define REG08_DECFLAG 0x40
#define REG08_GMMFFR 0x20
#define REG08_GMMFFG 0x10
#define REG08_GMMFFB 0x08
#define REG08_GMMZR 0x04
#define REG08_GMMZG 0x02
#define REG08_GMMZB 0x01
#define REG09_MCNTSET 0xc0
#define REG09_CLKSET 0x30
#define REG09_BACKSCAN 0x08
#define REG09_ENHANCE 0x04
#define REG09_SHORTTG 0x02
#define REG09_NWAIT 0x01
#define REG09S_MCNTSET 6
#define REG09S_CLKSET 4
#define REG0A_SRAMBUF 0x01
#define REG0D_CLRLNCNT 0x01
#define REG16_CTRLHI 0x80
#define REG16_TOSHIBA 0x40
#define REG16_TGINV 0x20
#define REG16_CK1INV 0x10
#define REG16_CK2INV 0x08
#define REG16_CTRLINV 0x04
#define REG16_CKDIS 0x02
#define REG16_CTRLDIS 0x01
#define REG17_TGMODE 0xc0
#define REG17_TGMODE_NO_DUMMY 0x00
#define REG17_TGMODE_REF 0x40
#define REG17_TGMODE_XPA 0x80
#define REG17_TGW 0x3f
#define REG17S_TGW 0
#define REG18_CNSET 0x80
#define REG18_DCKSEL 0x60
#define REG18_CKTOGGLE 0x10
#define REG18_CKDELAY 0x0c
#define REG18_CKSEL 0x03
#define REG1A_MANUAL3 0x02
#define REG1A_MANUAL1 0x01
#define REG1A_CK4INV 0x08
#define REG1A_CK3INV 0x04
#define REG1A_LINECLP 0x02
#define REG1C_TGTIME 0x07
#define REG1D_CK4LOW 0x80
#define REG1D_CK3LOW 0x40
#define REG1D_CK1LOW 0x20
#define REG1D_TGSHLD 0x1f
#define REG1DS_TGSHLD 0
#define REG1E_WDTIME 0xf0
#define REG1ES_WDTIME 4
#define REG1E_LINESEL 0x0f
#define REG1ES_LINESEL 0
#define REG40_HISPDFLG 0x04
#define REG40_MOTMFLG 0x02
#define REG40_DATAENB 0x01
#define REG41_PWRBIT 0x80
#define REG41_BUFEMPTY 0x40
#define REG41_FEEDFSH 0x20
#define REG41_SCANFSH 0x10
#define REG41_HOMESNR 0x08
#define REG41_LAMPSTS 0x04
#define REG41_FEBUSY 0x02
#define REG41_MOTORENB 0x01
#define REG58_VSMP 0xf8
#define REG58S_VSMP 3
#define REG58_VSMPW 0x07
#define REG58S_VSMPW 0
#define REG59_BSMP 0xf8
#define REG59S_BSMP 3
#define REG59_BSMPW 0x07
#define REG59S_BSMPW 0
#define REG5A_ADCLKINV 0x80
#define REG5A_RLCSEL 0x40
#define REG5A_CDSREF 0x30
#define REG5AS_CDSREF 4
#define REG5A_RLC 0x0f
#define REG5AS_RLC 0
#define REG5E_DECSEL 0xe0
#define REG5ES_DECSEL 5
#define REG5E_STOPTIM 0x1f
#define REG5ES_STOPTIM 0
#define REG60_ZIMOD 0x1f
#define REG61_Z1MOD 0xff
#define REG62_Z1MOD 0xff
#define REG63_Z2MOD 0x1f
#define REG64_Z2MOD 0xff
#define REG65_Z2MOD 0xff
#define REG67_STEPSEL 0xc0
#define REG67_FULLSTEP 0x00
#define REG67_HALFSTEP 0x40
#define REG67_QUATERSTEP 0x80
#define REG67_MTRPWM 0x3f
#define REG68_FSTPSEL 0xc0
#define REG68_FULLSTEP 0x00
#define REG68_HALFSTEP 0x40
#define REG68_QUATERSTEP 0x80
#define REG68_FASTPWM 0x3f
#define REG6B_MULTFILM 0x80
#define REG6B_GPOM13 0x40
#define REG6B_GPOM12 0x20
#define REG6B_GPOM11 0x10
#define REG6B_GPO18 0x02
#define REG6B_GPO17 0x01
#define REG6C_GPIOH 0xff
#define REG6C_GPIOL 0xff
#define REG87_LEDADD 0x04
/* we don't need a genesys_sanei_gl841.h yet, declarations aren't numerous enough */
/* writable registers *//*adapted to sanei_gl841 */
enum
{
reg_0x01 = 0,
reg_0x02,
reg_0x03,
reg_0x04,
reg_0x05,
reg_0x06,
reg_0x07,
reg_0x08,
reg_0x09,
reg_0x0a,
reg_0x10,
reg_0x11,
reg_0x12,
reg_0x13,
reg_0x14,
reg_0x15,
reg_0x16,
reg_0x17,
reg_0x18,
reg_0x19,
reg_0x1a,
reg_0x1b,
reg_0x1c,
reg_0x1d,
reg_0x1e,
reg_0x1f,
reg_0x20,
reg_0x21,
reg_0x22,
reg_0x23,
reg_0x24,
reg_0x25,
reg_0x26,
reg_0x27,
reg_0x29,
reg_0x2c,
reg_0x2d,
reg_0x2e,
reg_0x2f,
reg_0x30,
reg_0x31,
reg_0x32,
reg_0x33,
reg_0x34,
reg_0x35,
reg_0x36,
reg_0x37,
reg_0x38,
reg_0x39,
reg_0x3d,
reg_0x3e,
reg_0x3f,
reg_0x52,
reg_0x53,
reg_0x54,
reg_0x55,
reg_0x56,
reg_0x57,
reg_0x58,
reg_0x59,
reg_0x5a,
reg_0x5d,
reg_0x5e,
reg_0x5f,
reg_0x60,
reg_0x61,
reg_0x62,
reg_0x63,
reg_0x64,
reg_0x65,
reg_0x66,
reg_0x67,
reg_0x68,
reg_0x69,
reg_0x6a,
reg_0x6b,
reg_0x6c,
reg_0x6d,
reg_0x6e,
reg_0x6f,
reg_0x70,
reg_0x71,
reg_0x72,
reg_0x73,
reg_0x74,
reg_0x75,
reg_0x76,
reg_0x77,
reg_0x78,
reg_0x79,
reg_0x7a,
reg_0x7b,
reg_0x7c,
reg_0x7d,
reg_0x7e,
reg_0x7f,
reg_0x80,
reg_0x81,
reg_0x82,
reg_0x83,
reg_0x84,
reg_0x85,
reg_0x86,
reg_0x87,
GENESYS_GL841_MAX_REGS
};
/**************************************************************************** /****************************************************************************
Low level function Low level function
@ -3835,7 +3510,7 @@ gl841_begin_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
/* Send the stop scan command */ /* Send the stop scan command */
static SANE_Status static SANE_Status
gl841_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg, gl841_end_scan (Genesys_Device * dev, Genesys_Register_Set __sane_unused__ * reg,
SANE_Bool check_stop) SANE_Bool check_stop)
{ {
SANE_Status status; SANE_Status status;
@ -5442,8 +5117,11 @@ gl841_is_compatible_calibration (Genesys_Device * dev,
int for_overwrite) int for_overwrite)
{ {
SANE_Status status; SANE_Status status;
#ifdef HAVE_SYS_TIME_H
struct timeval time;
#endif
DBG (DBG_proc, "gl841_is_compatible_calibration\n"); DBGSTART;
/* calibration cache not working yet for this model */ /* calibration cache not working yet for this model */
if (dev->model->ccd_type == CCD_PLUSTEK_3600) if (dev->model->ccd_type == CCD_PLUSTEK_3600)
@ -5466,8 +5144,22 @@ gl841_is_compatible_calibration (Genesys_Device * dev,
if (dev->current_setup.half_ccd != cache->used_setup.half_ccd) if (dev->current_setup.half_ccd != cache->used_setup.half_ccd)
return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_UNSUPPORTED;
DBG (DBG_proc, "gl841_is_compatible_calibration: completed\n"); /* a cache entry expires after 30 minutes for non sheetfed scanners */
/* this is not taken into account when overwriting cache entries */
#ifdef HAVE_SYS_TIME_H
if(for_overwrite == SANE_FALSE)
{
gettimeofday (&time, NULL);
if ((time.tv_sec - cache->last_calibration > 30 * 60)
&& (dev->model->is_sheetfed == SANE_FALSE))
{
DBG (DBG_proc, "%s: expired entry, non compatible cache\n",__FUNCTION__);
return SANE_STATUS_UNSUPPORTED;
}
}
#endif
DBGCOMPLETED;
return SANE_STATUS_GOOD; return SANE_STATUS_GOOD;
} }

Wyświetl plik

@ -40,28 +40,10 @@
whether to permit this exception to apply to your modifications. whether to permit this exception to apply to your modifications.
If you do not wish that, delete this exception notice. 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 #undef BACKEND_NAME
#define BACKEND_NAME genesys_gl843 #define BACKEND_NAME genesys_gl843
#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.h" #include "genesys.h"
#ifdef UNIT_TESTING #ifdef UNIT_TESTING

Wyświetl plik

@ -1797,7 +1797,7 @@ gl847_set_motor_power (Genesys_Register_Set * regs, SANE_Bool set)
} }
static void static void
gl847_set_lamp_power (Genesys_Device * dev, gl847_set_lamp_power (Genesys_Device __sane_unused__ * dev,
Genesys_Register_Set * regs, SANE_Bool set) Genesys_Register_Set * regs, SANE_Bool set)
{ {
if (set) if (set)
@ -1934,7 +1934,6 @@ gl847_stop_action (Genesys_Device * dev)
} }
/* Send the low-level scan command */ /* Send the low-level scan command */
/* todo : is this that useful ? */
#ifndef UNIT_TESTING #ifndef UNIT_TESTING
static static
#endif #endif
@ -2995,50 +2994,6 @@ gl847_led_calibration (Genesys_Device * dev)
return status; return status;
} }
/* this function does the offset calibration by scanning one line of the calibration
area below scanner's top. There is a black margin and the remaining is white.
sanei_genesys_search_start() must have been called so that the offsets and margins
are allready known.
this function expects the slider to be where?
*/
static SANE_Status
gl847_offset_calibration (Genesys_Device * dev)
{
DBG (DBG_proc, "%s: not implemented \n", __FUNCTION__);
return SANE_STATUS_GOOD;
}
/* alternative coarse gain calibration
this on uses the settings from offset_calibration and
uses only one scanline
*/
/*
with offset and coarse calibration we only want to get our input range into
a reasonable shape. the fine calibration of the upper and lower bounds will
be done with shading.
*/
static SANE_Status
gl847_coarse_gain_calibration (Genesys_Device * dev, int dpi)
{
DBG (DBG_proc, "%s: not implemented \n", __FUNCTION__);
return SANE_STATUS_GOOD;
}
/*
* wait for lamp warmup by scanning the same line until difference
* between 2 scans is below a threshold
*/
static SANE_Status
gl847_init_regs_for_warmup (Genesys_Device * dev,
Genesys_Register_Set * local_reg,
int *channels, int *total_size)
{
DBG (DBG_proc, "%s: not implemented \n", __FUNCTION__);
return SANE_STATUS_INVAL;
}
/** /**
* set up GPIO/GPOE for idle state * set up GPIO/GPOE for idle state
*/ */
@ -3742,7 +3697,7 @@ static Genesys_Command_Set gl847_cmd_set = {
"gl847-generic", /* the name of this set */ "gl847-generic", /* the name of this set */
gl847_init, gl847_init,
gl847_init_regs_for_warmup, NULL, /*gl847_init_regs_for_warmup*/
gl847_init_regs_for_coarse_calibration, gl847_init_regs_for_coarse_calibration,
gl847_init_regs_for_shading, gl847_init_regs_for_shading,
gl847_init_regs_for_scan, gl847_init_regs_for_scan,
@ -3771,8 +3726,8 @@ static Genesys_Command_Set gl847_cmd_set = {
gl847_search_start_position, gl847_search_start_position,
gl847_offset_calibration, NULL, /*gl847_offset_calibration*/
gl847_coarse_gain_calibration, NULL, /*gl847_coarse_gain_calibration*/
gl847_led_calibration, gl847_led_calibration,
gl847_slow_back_home, gl847_slow_back_home,

Wyświetl plik

@ -1,6 +1,6 @@
/* sane - Scanner Access Now Easy. /* sane - Scanner Access Now Easy.
Copyright (C) 2010 Stéphane Voltz <stef.dev@free.fr> Copyright (C) 2010-2011 Stéphane Voltz <stef.dev@free.fr>
This file is part of the SANE package. This file is part of the SANE package.
@ -40,31 +40,12 @@
whether to permit this exception to apply to your modifications. whether to permit this exception to apply to your modifications.
If you do not wish that, delete this exception notice. 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"
#undef BACKEND_NAME #undef BACKEND_NAME
#define BACKEND_NAME genesys_gl847 #define BACKEND_NAME genesys_gl847
#include "../include/sane/sanei_backend.h"
#include "../include/sane/sanei_config.h"
#include "../include/sane/sanei_usb.h"
#include "../include/_stdint.h"
#include "genesys.h" #include "genesys.h"
#define DBGSTART DBG (DBG_proc, "%s start\n", __FUNCTION__);
#define DBGCOMPLETED DBG (DBG_proc, "%s completed\n", __FUNCTION__);
#define REG01 0x01 #define REG01 0x01
#define REG01_CISSET 0x80 #define REG01_CISSET 0x80
#define REG01_DOGENB 0x40 #define REG01_DOGENB 0x40
@ -483,6 +464,61 @@ enum
#define SETREG(adr,val) {dev->reg[reg_##adr].address=adr;dev->reg[reg_##adr].value=val;} #define SETREG(adr,val) {dev->reg[reg_##adr].address=adr;dev->reg[reg_##adr].value=val;}
/**
* Write to many GL847 registers at once
* Note: sequential call to write register, no effective
* bulk write implemented.
* @param dev device to write to
* @param reg pointer to an array of registers
* @param elems size of the array
*/
#ifndef UNIT_TESTING
static
#endif
SANE_Status gl847_bulk_write_register (Genesys_Device * dev, Genesys_Register_Set * reg, size_t elems);
/** set up registers for an actual scan
*
* this function sets up the scanner to scan in normal or single line mode
*/
#ifndef UNIT_TESTING
static
#endif
SANE_Status gl847_init_scan_regs (Genesys_Device * dev,
Genesys_Register_Set * reg,
float xres, /*dpi */
float yres, /*dpi */
float startx, /*optical_res, from dummy_pixel+1 */
float starty, /*base_ydpi, from home! */
float pixels,
float lines,
unsigned int depth,
unsigned int channels,
int color_filter,
unsigned int flags);
/* Send the low-level scan command */
#ifndef UNIT_TESTING
static
#endif
SANE_Status gl847_begin_scan (Genesys_Device * dev, Genesys_Register_Set * reg, SANE_Bool start_motor);
/* Send the stop scan command */
#ifndef UNIT_TESTING
static
#endif
SANE_Status gl847_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg, SANE_Bool check_stop);
/** @brief moves the slider to steps at motor base dpi
* @param dev device to work on
* @param steps number of steps to move
* */
#ifndef UNIT_TESTING
static
#endif
SANE_Status
gl847_feed (Genesys_Device * dev, unsigned int steps);
typedef struct typedef struct
{ {
uint8_t rd0; uint8_t rd0;

Wyświetl plik

@ -51,6 +51,15 @@
#ifndef GENESYS_LOW_H #ifndef GENESYS_LOW_H
#define GENESYS_LOW_H #define GENESYS_LOW_H
#include "../include/sane/config.h"
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <math.h>
#include <stddef.h> #include <stddef.h>
#ifdef HAVE_SYS_TIME_H #ifdef HAVE_SYS_TIME_H
#include <sys/time.h> #include <sys/time.h>
@ -58,7 +67,15 @@
#ifdef HAVE_SYS_TYPES_H #ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> #include <sys/types.h>
#endif #endif
#include "../include/sane/sane.h" #include "../include/sane/sane.h"
#include "../include/sane/sanei.h"
#include "../include/sane/saneopts.h"
#include "../include/sane/sanei_backend.h"
#include "../include/sane/sanei_usb.h"
#include "../include/_stdint.h"
#define DBG_error0 0 /* errors/warnings printed even with devuglevel 0 */ #define DBG_error0 0 /* errors/warnings printed even with devuglevel 0 */
#define DBG_error 1 /* fatal errors */ #define DBG_error 1 /* fatal errors */
@ -84,7 +101,11 @@
#define GENESYS_FLAG_LAZY_INIT (1 << 2) /**> skip extensive ASIC test at init */ #define GENESYS_FLAG_LAZY_INIT (1 << 2) /**> skip extensive ASIC test at init */
#define GENESYS_FLAG_XPA (1 << 3) #define GENESYS_FLAG_XPA (1 << 3)
#define GENESYS_FLAG_SKIP_WARMUP (1 << 4) /**> skip genesys_warmup() */ #define GENESYS_FLAG_SKIP_WARMUP (1 << 4) /**> skip genesys_warmup() */
#define GENESYS_FLAG_OFFSET_CALIBRATION (1 << 5) /**> do offset calibration */ /** @brief offset calibration flag
* signals that the scanner does offset calibration. In this case off_calibration() and
* coarse_gain_calibration() functions must be implemented
*/
#define GENESYS_FLAG_OFFSET_CALIBRATION (1 << 5)
#define GENESYS_FLAG_SEARCH_START (1 << 6) /**> do start search before scanning */ #define GENESYS_FLAG_SEARCH_START (1 << 6) /**> do start search before scanning */
#define GENESYS_FLAG_REPARK (1 << 7) /**> repark head (and check for lock) by #define GENESYS_FLAG_REPARK (1 << 7) /**> repark head (and check for lock) by
moving without scanning */ moving without scanning */