kopia lustrzana https://gitlab.com/sane-project/backends
Move global state variables of mustek_usb2_high.c into scanner structure.
rodzic
60a244ed1e
commit
3f5592ef8e
|
@ -301,7 +301,7 @@ init_options (Mustek_Scanner * s)
|
|||
s->opt[OPT_SOURCE].constraint.string_list = source_list;
|
||||
s->val[OPT_SOURCE].s = strdup (source_list[SS_REFLECTIVE]);
|
||||
|
||||
status = Scanner_IsTAConnected (&hasTA);
|
||||
status = Scanner_IsTAConnected (&s->state, &hasTA);
|
||||
if ((status != SANE_STATUS_GOOD) || !hasTA)
|
||||
s->opt[OPT_SOURCE].cap |= SANE_CAP_INACTIVE;
|
||||
|
||||
|
@ -481,20 +481,21 @@ sane_open (SANE_String_Const devicename, SANE_Handle * handle)
|
|||
DBG_ENTER ();
|
||||
DBG (DBG_FUNC, "devicename=%s\n", devicename);
|
||||
|
||||
Scanner_Init ();
|
||||
|
||||
status = Scanner_PowerControl (SANE_FALSE, SANE_FALSE);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
return status;
|
||||
status = Scanner_BackHome ();
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
return status;
|
||||
|
||||
s = malloc (sizeof (*s));
|
||||
if (!s)
|
||||
return SANE_STATUS_NO_MEM;
|
||||
memset (s, 0, sizeof (*s));
|
||||
s->model = mustek_A2nu2_model;
|
||||
|
||||
Scanner_Init (&s->state);
|
||||
|
||||
status = Scanner_PowerControl (&s->state, SANE_FALSE, SANE_FALSE);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
return status;
|
||||
status = Scanner_BackHome (&s->state);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
return status;
|
||||
|
||||
init_options (s);
|
||||
*handle = s;
|
||||
|
||||
|
@ -508,8 +509,8 @@ sane_close (SANE_Handle handle)
|
|||
Mustek_Scanner *s = handle;
|
||||
DBG_ENTER ();
|
||||
|
||||
Scanner_PowerControl (SANE_FALSE, SANE_FALSE);
|
||||
Scanner_BackHome ();
|
||||
Scanner_PowerControl (&s->state, SANE_FALSE, SANE_FALSE);
|
||||
Scanner_BackHome (&s->state);
|
||||
|
||||
free (s->scan_buf);
|
||||
s->scan_buf = NULL;
|
||||
|
@ -735,7 +736,7 @@ sane_start (SANE_Handle handle)
|
|||
DBG (DBG_INFO, "target.cmColorMode=%d\n", target.cmColorMode);
|
||||
DBG (DBG_INFO, "target.ssScanSource=%d\n", target.ssScanSource);
|
||||
|
||||
status = Scanner_Reset ();
|
||||
status = Scanner_Reset (&s->state);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
return status;
|
||||
|
||||
|
@ -758,13 +759,13 @@ sane_start (SANE_Handle handle)
|
|||
s->scan_buf_len = 0;
|
||||
|
||||
if (target.ssScanSource == SS_REFLECTIVE)
|
||||
status = Scanner_PowerControl (SANE_TRUE, SANE_FALSE);
|
||||
status = Scanner_PowerControl (&s->state, SANE_TRUE, SANE_FALSE);
|
||||
else
|
||||
status = Scanner_PowerControl (SANE_FALSE, SANE_TRUE);
|
||||
status = Scanner_PowerControl (&s->state, SANE_FALSE, SANE_TRUE);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
return status;
|
||||
|
||||
status = Scanner_SetupScan (&target);
|
||||
status = Scanner_SetupScan (&s->state, &target);
|
||||
|
||||
DBG_LEAVE ();
|
||||
return status;
|
||||
|
@ -816,7 +817,7 @@ sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len,
|
|||
|
||||
s->bIsReading = SANE_TRUE;
|
||||
lines_received = (unsigned short) lines;
|
||||
status = Scanner_GetRows (tempbuf, &lines_received,
|
||||
status = Scanner_GetRows (&s->state, tempbuf, &lines_received,
|
||||
s->model.isRGBInvert);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
|
@ -886,8 +887,8 @@ sane_cancel (SANE_Handle handle)
|
|||
else
|
||||
DBG (DBG_INFO, "scan finished\n");
|
||||
|
||||
Scanner_StopScan ();
|
||||
Scanner_BackHome ();
|
||||
Scanner_StopScan (&s->state);
|
||||
Scanner_BackHome (&s->state);
|
||||
|
||||
for (i = 0; i < 20; i++)
|
||||
{
|
||||
|
|
|
@ -112,6 +112,7 @@ typedef struct Mustek_Scanner
|
|||
Option_Value val[NUM_OPTIONS];
|
||||
SANE_Parameters params;
|
||||
Scanner_Model model;
|
||||
Scanner_State state;
|
||||
SANE_Bool bIsScanning;
|
||||
SANE_Bool bIsReading;
|
||||
SANE_Bool bInvertImage;
|
||||
|
|
Plik diff jest za duży
Load Diff
|
@ -48,6 +48,8 @@
|
|||
#ifndef MUSTEK_USB2_HIGH_H
|
||||
#define MUSTEK_USB2_HIGH_H
|
||||
|
||||
#include <pthread.h> /* TODO: use sanei_thread functions instead */
|
||||
|
||||
#include "mustek_usb2_asic.h"
|
||||
|
||||
|
||||
|
@ -82,6 +84,43 @@ typedef struct
|
|||
unsigned short wStartPosition;
|
||||
} CALIBRATIONPARAM;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SANE_Bool bOpened;
|
||||
SANE_Bool bPrepared;
|
||||
SANE_Bool isCanceled;
|
||||
SANE_Bool bFirstReadImage;
|
||||
|
||||
SANE_Byte * pReadImageHead;
|
||||
unsigned short * pGammaTable;
|
||||
ASIC chip;
|
||||
|
||||
TARGETIMAGE Target;
|
||||
unsigned int BytesPerRow;
|
||||
unsigned int SWBytesPerRow;
|
||||
unsigned short SWWidth;
|
||||
unsigned short SWHeight;
|
||||
|
||||
unsigned int wtheReadyLines;
|
||||
unsigned int wMaxScanLines;
|
||||
unsigned int dwScannedTotalLines;
|
||||
unsigned int dwTotalTotalXferLines;
|
||||
|
||||
pthread_t threadid_readimage;
|
||||
pthread_mutex_t scannedLinesMutex;
|
||||
pthread_mutex_t readyLinesMutex;
|
||||
|
||||
/* even & odd sensor problem */
|
||||
unsigned short wPixelDistance;
|
||||
unsigned short wLineDistance;
|
||||
unsigned short wScanLinesPerBlock;
|
||||
|
||||
/* for modifying the last point */
|
||||
SANE_Bool bIsFirstReadBefData;
|
||||
SANE_Byte * pBefLineImageData;
|
||||
unsigned int dwAlreadyGetLines;
|
||||
} Scanner_State;
|
||||
|
||||
|
||||
#define _MAX(a,b) ((a)>(b)?(a):(b))
|
||||
#define _MIN(a,b) ((a)<(b)?(a):(b))
|
||||
|
@ -114,20 +153,22 @@ typedef struct
|
|||
/*#define DEBUG_SAVE_IMAGE*/
|
||||
|
||||
|
||||
void Scanner_Init (void);
|
||||
void Scanner_Init (Scanner_State * st);
|
||||
SANE_Bool Scanner_IsPresent (void);
|
||||
SANE_Status Scanner_PowerControl (SANE_Bool isLampOn, SANE_Bool isTALampOn);
|
||||
SANE_Status Scanner_BackHome (void);
|
||||
SANE_Status Scanner_IsTAConnected (SANE_Bool * pHasTA);
|
||||
SANE_Status Scanner_PowerControl (Scanner_State * st, SANE_Bool isLampOn,
|
||||
SANE_Bool isTALampOn);
|
||||
SANE_Status Scanner_BackHome (Scanner_State * st);
|
||||
SANE_Status Scanner_IsTAConnected (Scanner_State * st, SANE_Bool * pHasTA);
|
||||
#if SANE_UNUSED
|
||||
SANE_Status Scanner_GetKeyStatus (SANE_Byte * pKey);
|
||||
SANE_Status Scanner_GetKeyStatus (Scanner_State * st, SANE_Byte * pKey);
|
||||
#endif
|
||||
SANE_Status Scanner_GetRows (SANE_Byte * pBlock, unsigned short * pNumRows,
|
||||
SANE_Status Scanner_GetRows (Scanner_State * st, SANE_Byte * pBlock,
|
||||
unsigned short * pNumRows,
|
||||
SANE_Bool isOrderInvert);
|
||||
void Scanner_ScanSuggest (TARGETIMAGE * pTarget);
|
||||
SANE_Status Scanner_StopScan (void);
|
||||
SANE_Status Scanner_Reset (void);
|
||||
SANE_Status Scanner_SetupScan (TARGETIMAGE * pTarget);
|
||||
SANE_Status Scanner_StopScan (Scanner_State * st);
|
||||
SANE_Status Scanner_Reset (Scanner_State * st);
|
||||
SANE_Status Scanner_SetupScan (Scanner_State * st, TARGETIMAGE * pTarget);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Ładowanie…
Reference in New Issue