kopia lustrzana https://gitlab.com/sane-project/backends
Use prefix 'p' instead of 'lp', fix other style issues.
rodzic
9e2aabc976
commit
4962b35abd
|
@ -122,12 +122,10 @@ static const Scanner_Model mustek_A2nu2_model = {
|
|||
};
|
||||
|
||||
|
||||
static SANE_Byte * g_lpNegImageData = NULL;
|
||||
static SANE_Byte * g_pNegImageData = NULL;
|
||||
static unsigned int g_dwAlreadyGetNegLines;
|
||||
|
||||
static SANE_Bool IsTAConnected (void);
|
||||
static void AutoLevel (SANE_Byte *lpSource, unsigned short ScanLines,
|
||||
unsigned int BytesPerLine);
|
||||
|
||||
|
||||
static size_t
|
||||
|
@ -487,6 +485,83 @@ SetParameters (TARGETIMAGE * pSetParameters)
|
|||
return SANE_TRUE;
|
||||
}
|
||||
|
||||
static unsigned short
|
||||
AdjustColorComponent (SANE_Byte c, SANE_Byte min, SANE_Byte max,
|
||||
SANE_Byte range)
|
||||
{
|
||||
if (range == 0)
|
||||
c = max;
|
||||
else if (c < min)
|
||||
c = 0;
|
||||
else
|
||||
{
|
||||
float fmax = (float) ((c - min) * 255) / range;
|
||||
c = (unsigned short) fmax;
|
||||
if ((fmax - c) >= 0.5)
|
||||
c++;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
static void
|
||||
AutoLevel (SANE_Byte * pSource, unsigned short ScanLines,
|
||||
unsigned int BytesPerLine)
|
||||
{
|
||||
unsigned int i, j;
|
||||
unsigned int tLines;
|
||||
SANE_Byte R, G, B;
|
||||
SANE_Byte max_R = 0, max_G = 0, max_B = 0;
|
||||
SANE_Byte min_R = 255, min_G = 255, min_B = 255;
|
||||
SANE_Byte range_R, range_G, range_B;
|
||||
unsigned int iWidth = BytesPerLine / 3;
|
||||
|
||||
DBG (DBG_FUNC, "AutoLevel: start\n");
|
||||
|
||||
/* find min and max values for each color component */
|
||||
for (j = 0, tLines = 0; j < ScanLines; j++, tLines += BytesPerLine)
|
||||
{
|
||||
for (i = 0; i < iWidth; i++)
|
||||
{
|
||||
R = pSource[tLines + i * 3 + 2];
|
||||
G = pSource[tLines + i * 3 + 1];
|
||||
B = pSource[tLines + i * 3];
|
||||
|
||||
max_R = _MAX (R, max_R);
|
||||
max_G = _MAX (G, max_G);
|
||||
max_B = _MAX (B, max_B);
|
||||
|
||||
min_R = _MIN (R, min_R);
|
||||
min_G = _MIN (G, min_G);
|
||||
min_B = _MIN (B, min_B);
|
||||
}
|
||||
}
|
||||
|
||||
range_R = max_R - min_R;
|
||||
range_G = max_G - min_G;
|
||||
range_B = max_B - min_B;
|
||||
|
||||
/* stretch histogram */
|
||||
for (j = 0, tLines = 0; j < ScanLines; j++, tLines += BytesPerLine)
|
||||
{
|
||||
for (i = 0; i < iWidth; i++)
|
||||
{
|
||||
R = pSource[tLines + i * 3 + 2];
|
||||
G = pSource[tLines + i * 3 + 1];
|
||||
B = pSource[tLines + i * 3];
|
||||
|
||||
R = AdjustColorComponent (R, min_R, max_R, range_R);
|
||||
G = AdjustColorComponent (G, min_G, max_G, range_G);
|
||||
B = AdjustColorComponent (B, min_B, max_B, range_B);
|
||||
|
||||
pSource[tLines + i * 3 + 2] = R;
|
||||
pSource[tLines + i * 3 + 1] = G;
|
||||
pSource[tLines + i * 3] = B;
|
||||
}
|
||||
}
|
||||
|
||||
DBG (DBG_FUNC, "AutoLevel: exit\n");
|
||||
}
|
||||
|
||||
static SANE_Bool
|
||||
ReadScannedData (IMAGEROWS * pImageRows, TARGETIMAGE * pTarget)
|
||||
{
|
||||
|
@ -507,28 +582,28 @@ ReadScannedData (IMAGEROWS * pImageRows, TARGETIMAGE * pTarget)
|
|||
if (pTarget->cmColorMode != CM_RGB24)
|
||||
return SANE_FALSE;
|
||||
|
||||
if (!g_lpNegImageData)
|
||||
if (!g_pNegImageData)
|
||||
{
|
||||
unsigned int TotalImageSize = g_SWHeight * pTarget->dwBytesPerRow;
|
||||
g_dwAlreadyGetNegLines = 0;
|
||||
g_lpNegImageData = malloc (TotalImageSize);
|
||||
if (!g_lpNegImageData)
|
||||
g_pNegImageData = malloc (TotalImageSize);
|
||||
if (!g_pNegImageData)
|
||||
{
|
||||
DBG (DBG_ERR, "ReadScannedData: error allocating memory\n");
|
||||
return SANE_FALSE;
|
||||
}
|
||||
|
||||
if (!MustScanner_GetRows (g_lpNegImageData, &g_SWHeight, isRGBInvert))
|
||||
if (!MustScanner_GetRows (g_pNegImageData, &g_SWHeight, isRGBInvert))
|
||||
return SANE_FALSE;
|
||||
DBG (DBG_INFO, "ReadScannedData: get image data is over!\n");
|
||||
|
||||
for (i = 0; i < TotalImageSize; i++)
|
||||
g_lpNegImageData[i] ^= 0xff;
|
||||
AutoLevel (g_lpNegImageData, g_SWHeight, pTarget->dwBytesPerRow);
|
||||
g_pNegImageData[i] ^= 0xff;
|
||||
AutoLevel (g_pNegImageData, g_SWHeight, pTarget->dwBytesPerRow);
|
||||
DBG (DBG_INFO, "ReadScannedData: autolevel is ok\n");
|
||||
}
|
||||
|
||||
memcpy (pImageRows->pBuffer, g_lpNegImageData +
|
||||
memcpy (pImageRows->pBuffer, g_pNegImageData +
|
||||
(pTarget->dwBytesPerRow * g_dwAlreadyGetNegLines),
|
||||
pTarget->dwBytesPerRow * Rows);
|
||||
pImageRows->wXferedLineNum = Rows;
|
||||
|
@ -537,8 +612,8 @@ ReadScannedData (IMAGEROWS * pImageRows, TARGETIMAGE * pTarget)
|
|||
g_dwAlreadyGetNegLines += Rows;
|
||||
if (g_dwAlreadyGetNegLines >= g_SWHeight)
|
||||
{
|
||||
free (g_lpNegImageData);
|
||||
g_lpNegImageData = NULL;
|
||||
free (g_pNegImageData);
|
||||
g_pNegImageData = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -582,10 +657,10 @@ StopScan (void)
|
|||
g_pGammaTable = NULL;
|
||||
}
|
||||
|
||||
if (g_lpReadImageHead)
|
||||
if (g_pReadImageHead)
|
||||
{
|
||||
free (g_lpReadImageHead);
|
||||
g_lpReadImageHead = NULL;
|
||||
free (g_pReadImageHead);
|
||||
g_pReadImageHead = NULL;
|
||||
}
|
||||
|
||||
DBG (DBG_FUNC, "StopScan: exit\n");
|
||||
|
@ -641,83 +716,6 @@ GetKeyStatus (SANE_Byte * pKey)
|
|||
}
|
||||
#endif
|
||||
|
||||
static unsigned short
|
||||
AdjustColorComponent (SANE_Byte c, SANE_Byte min, SANE_Byte max,
|
||||
SANE_Byte range)
|
||||
{
|
||||
if (range == 0)
|
||||
c = max;
|
||||
else if (c < min)
|
||||
c = 0;
|
||||
else
|
||||
{
|
||||
float fmax = (float) ((c - min) * 255) / range;
|
||||
c = (unsigned short) fmax;
|
||||
if ((fmax - c) >= 0.5)
|
||||
c++;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
static void
|
||||
AutoLevel (SANE_Byte *lpSource, unsigned short ScanLines,
|
||||
unsigned int BytesPerLine)
|
||||
{
|
||||
unsigned int i, j;
|
||||
unsigned int tLines;
|
||||
SANE_Byte R, G, B;
|
||||
SANE_Byte max_R = 0, max_G = 0, max_B = 0;
|
||||
SANE_Byte min_R = 255, min_G = 255, min_B = 255;
|
||||
SANE_Byte range_R, range_G, range_B;
|
||||
unsigned int iWidth = BytesPerLine / 3;
|
||||
|
||||
DBG (DBG_FUNC, "AutoLevel: start\n");
|
||||
|
||||
/* find min and max values for each color component */
|
||||
for (j = 0, tLines = 0; j < ScanLines; j++, tLines += BytesPerLine)
|
||||
{
|
||||
for (i = 0; i < iWidth; i++)
|
||||
{
|
||||
R = lpSource[tLines + i * 3 + 2];
|
||||
G = lpSource[tLines + i * 3 + 1];
|
||||
B = lpSource[tLines + i * 3];
|
||||
|
||||
max_R = _MAX (R, max_R);
|
||||
max_G = _MAX (G, max_G);
|
||||
max_B = _MAX (B, max_B);
|
||||
|
||||
min_R = _MIN (R, min_R);
|
||||
min_G = _MIN (G, min_G);
|
||||
min_B = _MIN (B, min_B);
|
||||
}
|
||||
}
|
||||
|
||||
range_R = max_R - min_R;
|
||||
range_G = max_G - min_G;
|
||||
range_B = max_B - min_B;
|
||||
|
||||
/* stretch histogram */
|
||||
for (j = 0, tLines = 0; j < ScanLines; j++, tLines += BytesPerLine)
|
||||
{
|
||||
for (i = 0; i < iWidth; i++)
|
||||
{
|
||||
R = lpSource[tLines + i * 3 + 2];
|
||||
G = lpSource[tLines + i * 3 + 1];
|
||||
B = lpSource[tLines + i * 3];
|
||||
|
||||
R = AdjustColorComponent (R, min_R, max_R, range_R);
|
||||
G = AdjustColorComponent (G, min_G, max_G, range_G);
|
||||
B = AdjustColorComponent (B, min_B, max_B, range_B);
|
||||
|
||||
lpSource[tLines + i * 3 + 2] = R;
|
||||
lpSource[tLines + i * 3 + 1] = G;
|
||||
lpSource[tLines + i * 3] = B;
|
||||
}
|
||||
}
|
||||
|
||||
DBG (DBG_FUNC, "AutoLevel: exit\n");
|
||||
}
|
||||
|
||||
|
||||
/****************************** SANE API functions ****************************/
|
||||
|
||||
|
|
|
@ -129,8 +129,8 @@ typedef struct Mustek_Scanner
|
|||
SANE_Bool bIsScanning;
|
||||
SANE_Bool bIsReading;
|
||||
SANE_Word read_rows; /* number of transfered image lines */
|
||||
SANE_Byte *Scan_data_buf;
|
||||
SANE_Byte *Scan_data_buf_start;
|
||||
SANE_Byte * Scan_data_buf;
|
||||
SANE_Byte * Scan_data_buf_start;
|
||||
size_t scan_buffer_len;
|
||||
} Mustek_Scanner;
|
||||
|
||||
|
|
|
@ -51,10 +51,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define _USE_MATH_DEFINES
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#include "../include/sane/sane.h"
|
||||
|
@ -75,12 +71,12 @@ static SANE_Byte RegisterBankStatus = ~0;
|
|||
|
||||
static SANE_Status
|
||||
WriteIOControl (ASIC * chip, unsigned short wValue, unsigned short wIndex,
|
||||
unsigned short wLength, SANE_Byte * lpBuf)
|
||||
unsigned short wLength, SANE_Byte * pBuf)
|
||||
{
|
||||
SANE_Status status;
|
||||
|
||||
status = sanei_usb_control_msg (chip->fd, 0x40, 0x01, wValue, wIndex, wLength,
|
||||
lpBuf);
|
||||
pBuf);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
DBG (DBG_ERR, "WriteIOControl Error!\n");
|
||||
|
||||
|
@ -89,12 +85,12 @@ WriteIOControl (ASIC * chip, unsigned short wValue, unsigned short wIndex,
|
|||
|
||||
static SANE_Status
|
||||
ReadIOControl (ASIC * chip, unsigned short wValue, unsigned short wIndex,
|
||||
unsigned short wLength, SANE_Byte * lpBuf)
|
||||
unsigned short wLength, SANE_Byte * pBuf)
|
||||
{
|
||||
SANE_Status status;
|
||||
|
||||
status = sanei_usb_control_msg (chip->fd, 0xc0, 0x01, wValue, wIndex, wLength,
|
||||
lpBuf);
|
||||
pBuf);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
DBG (DBG_ERR, "ReadIOControl Error!\n");
|
||||
|
||||
|
@ -233,7 +229,7 @@ Mustek_SetRWSize (ASIC * chip, SANE_Bool isWriteAccess, unsigned int size)
|
|||
}
|
||||
|
||||
static SANE_Status
|
||||
Mustek_DMARead (ASIC * chip, unsigned int size, SANE_Byte * lpData)
|
||||
Mustek_DMARead (ASIC * chip, unsigned int size, SANE_Byte * pData)
|
||||
{
|
||||
SANE_Status status;
|
||||
size_t cur_read_size;
|
||||
|
@ -256,7 +252,7 @@ Mustek_DMARead (ASIC * chip, unsigned int size, SANE_Byte * lpData)
|
|||
if (status != SANE_STATUS_GOOD)
|
||||
return status;
|
||||
|
||||
status = sanei_usb_read_bulk (chip->fd, lpData, &cur_read_size);
|
||||
status = sanei_usb_read_bulk (chip->fd, pData, &cur_read_size);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG (DBG_ERR, "Mustek_DMARead: read error\n");
|
||||
|
@ -264,7 +260,7 @@ Mustek_DMARead (ASIC * chip, unsigned int size, SANE_Byte * lpData)
|
|||
}
|
||||
|
||||
size -= cur_read_size;
|
||||
lpData += cur_read_size;
|
||||
pData += cur_read_size;
|
||||
}
|
||||
|
||||
if (cur_read_size < DMA_BLOCK_SIZE)
|
||||
|
@ -275,7 +271,7 @@ Mustek_DMARead (ASIC * chip, unsigned int size, SANE_Byte * lpData)
|
|||
}
|
||||
|
||||
static SANE_Status
|
||||
Mustek_DMAWrite (ASIC * chip, unsigned int size, SANE_Byte * lpData)
|
||||
Mustek_DMAWrite (ASIC * chip, unsigned int size, SANE_Byte * pData)
|
||||
{
|
||||
SANE_Status status;
|
||||
size_t cur_write_size;
|
||||
|
@ -298,7 +294,7 @@ Mustek_DMAWrite (ASIC * chip, unsigned int size, SANE_Byte * lpData)
|
|||
if (status != SANE_STATUS_GOOD)
|
||||
return status;
|
||||
|
||||
status = sanei_usb_write_bulk (chip->fd, lpData, &cur_write_size);
|
||||
status = sanei_usb_write_bulk (chip->fd, pData, &cur_write_size);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG (DBG_ERR, "Mustek_DMAWrite: write error\n");
|
||||
|
@ -306,7 +302,7 @@ Mustek_DMAWrite (ASIC * chip, unsigned int size, SANE_Byte * lpData)
|
|||
}
|
||||
|
||||
size -= cur_write_size;
|
||||
lpData += cur_write_size;
|
||||
pData += cur_write_size;
|
||||
}
|
||||
|
||||
status = Mustek_ClearFIFO (chip);
|
||||
|
@ -847,22 +843,22 @@ SetMotorStepTableForCalibration (ASIC * chip, LLF_MOTORMOVE * MotorStepsTable,
|
|||
}
|
||||
|
||||
static void
|
||||
CalculateScanMotorTable (LLF_CALCULATEMOTORTABLE * lpCalculateMotorTable)
|
||||
CalculateScanMotorTable (LLF_CALCULATEMOTORTABLE * pCalculateMotorTable)
|
||||
{
|
||||
unsigned short wEndSpeed, wStartSpeed;
|
||||
unsigned short wScanAccSteps;
|
||||
SANE_Byte bScanDecSteps;
|
||||
unsigned short * lpMotorTable;
|
||||
unsigned short * pMotorTable;
|
||||
long double y;
|
||||
unsigned short i;
|
||||
|
||||
DBG (DBG_ASIC, "CalculateScanMotorTable: Enter\n");
|
||||
|
||||
wStartSpeed = lpCalculateMotorTable->StartSpeed;
|
||||
wEndSpeed = lpCalculateMotorTable->EndSpeed;
|
||||
wScanAccSteps = lpCalculateMotorTable->AccStepBeforeScan;
|
||||
bScanDecSteps = lpCalculateMotorTable->DecStepAfterScan;
|
||||
lpMotorTable = lpCalculateMotorTable->lpMotorTable;
|
||||
wStartSpeed = pCalculateMotorTable->StartSpeed;
|
||||
wEndSpeed = pCalculateMotorTable->EndSpeed;
|
||||
wScanAccSteps = pCalculateMotorTable->AccStepBeforeScan;
|
||||
bScanDecSteps = pCalculateMotorTable->DecStepAfterScan;
|
||||
pMotorTable = pCalculateMotorTable->pMotorTable;
|
||||
|
||||
/* motor T0 & T6 acc table */
|
||||
for (i = 0; i < 512; i++)
|
||||
|
@ -870,8 +866,8 @@ CalculateScanMotorTable (LLF_CALCULATEMOTORTABLE * lpCalculateMotorTable)
|
|||
y = 6000 - 3500;
|
||||
y *= pow (0.09, (M_PI_2 * i) / 512) - pow (0.09, (M_PI_2 * 511) / 512);
|
||||
y += 4500;
|
||||
lpMotorTable[i] = (unsigned short) y; /* T0 */
|
||||
lpMotorTable[i + 512 * 6] = (unsigned short) y; /* T6 */
|
||||
pMotorTable[i] = (unsigned short) y; /* T0 */
|
||||
pMotorTable[i + 512 * 6] = (unsigned short) y; /* T6 */
|
||||
}
|
||||
|
||||
/* motor T1 & T7 dec table */
|
||||
|
@ -880,8 +876,8 @@ CalculateScanMotorTable (LLF_CALCULATEMOTORTABLE * lpCalculateMotorTable)
|
|||
y = 6000 - 3500;
|
||||
y *= pow (0.3, (M_PI_2 * i) / 256);
|
||||
y = 6000 - y;
|
||||
lpMotorTable[i + 512] = (unsigned short) y; /* T1 */
|
||||
lpMotorTable[i + 512 * 7] = (unsigned short) y; /* T7 */
|
||||
pMotorTable[i + 512] = (unsigned short) y; /* T1 */
|
||||
pMotorTable[i + 512 * 7] = (unsigned short) y; /* T7 */
|
||||
}
|
||||
|
||||
for (i = 0; i < wScanAccSteps; i++)
|
||||
|
@ -890,13 +886,13 @@ CalculateScanMotorTable (LLF_CALCULATEMOTORTABLE * lpCalculateMotorTable)
|
|||
y *= pow (0.09, (M_PI_2 * i) / wScanAccSteps) -
|
||||
pow (0.09, (M_PI_2 * (wScanAccSteps - 1)) / wScanAccSteps);
|
||||
y += wEndSpeed;
|
||||
lpMotorTable[i + 512 * 2] = (unsigned short) y; /* T2 */
|
||||
lpMotorTable[i + 512 * 4] = (unsigned short) y; /* T4 */
|
||||
pMotorTable[i + 512 * 2] = (unsigned short) y; /* T2 */
|
||||
pMotorTable[i + 512 * 4] = (unsigned short) y; /* T4 */
|
||||
}
|
||||
for (i = wScanAccSteps; i < 512; i++)
|
||||
{
|
||||
lpMotorTable[i + 512 * 2] = wEndSpeed; /* T2 */
|
||||
lpMotorTable[i + 512 * 4] = wEndSpeed; /* T4 */
|
||||
pMotorTable[i + 512 * 2] = wEndSpeed; /* T2 */
|
||||
pMotorTable[i + 512 * 4] = wEndSpeed; /* T4 */
|
||||
}
|
||||
|
||||
for (i = 0; i < (unsigned short) bScanDecSteps; i++)
|
||||
|
@ -904,53 +900,53 @@ CalculateScanMotorTable (LLF_CALCULATEMOTORTABLE * lpCalculateMotorTable)
|
|||
y = wStartSpeed - wEndSpeed;
|
||||
y *= pow (0.3, (M_PI_2 * i) / bScanDecSteps);
|
||||
y = wStartSpeed - y;
|
||||
lpMotorTable[i + 512 * 3] = (unsigned short) y; /* T3 */
|
||||
lpMotorTable[i + 512 * 5] = (unsigned short) y; /* T5 */
|
||||
pMotorTable[i + 512 * 3] = (unsigned short) y; /* T3 */
|
||||
pMotorTable[i + 512 * 5] = (unsigned short) y; /* T5 */
|
||||
}
|
||||
for (i = bScanDecSteps; i < 256; i++)
|
||||
{
|
||||
lpMotorTable[i + 512 * 3] = wStartSpeed; /* T3 */
|
||||
lpMotorTable[i + 512 * 5] = wStartSpeed; /* T5 */
|
||||
pMotorTable[i + 512 * 3] = wStartSpeed; /* T3 */
|
||||
pMotorTable[i + 512 * 5] = wStartSpeed; /* T5 */
|
||||
}
|
||||
|
||||
DBG (DBG_ASIC, "CalculateScanMotorTable: Exit\n");
|
||||
}
|
||||
|
||||
static void
|
||||
CalculateMoveMotorTable (LLF_CALCULATEMOTORTABLE * lpCalculateMotorTable)
|
||||
CalculateMoveMotorTable (LLF_CALCULATEMOTORTABLE * pCalculateMotorTable)
|
||||
{
|
||||
unsigned short wEndSpeed, wStartSpeed;
|
||||
unsigned short wScanAccSteps;
|
||||
unsigned short * lpMotorTable;
|
||||
unsigned short * pMotorTable;
|
||||
long double y;
|
||||
unsigned short i;
|
||||
|
||||
DBG (DBG_ASIC, "CalculateMoveMotorTable: Enter\n");
|
||||
|
||||
wStartSpeed = lpCalculateMotorTable->StartSpeed;
|
||||
wEndSpeed = lpCalculateMotorTable->EndSpeed;
|
||||
wScanAccSteps = lpCalculateMotorTable->AccStepBeforeScan;
|
||||
lpMotorTable = lpCalculateMotorTable->lpMotorTable;
|
||||
wStartSpeed = pCalculateMotorTable->StartSpeed;
|
||||
wEndSpeed = pCalculateMotorTable->EndSpeed;
|
||||
wScanAccSteps = pCalculateMotorTable->AccStepBeforeScan;
|
||||
pMotorTable = pCalculateMotorTable->pMotorTable;
|
||||
|
||||
for (i = 0; i < 512; i++)
|
||||
{
|
||||
/* before scan acc table */
|
||||
y = (wStartSpeed - wEndSpeed) *
|
||||
pow (0.09, (M_PI_2 * i) / 512) + wEndSpeed;
|
||||
lpMotorTable[i] = (unsigned short) y;
|
||||
lpMotorTable[i + 512 * 2] = (unsigned short) y;
|
||||
lpMotorTable[i + 512 * 4] = (unsigned short) y;
|
||||
lpMotorTable[i + 512 * 6] = (unsigned short) y;
|
||||
pMotorTable[i] = (unsigned short) y;
|
||||
pMotorTable[i + 512 * 2] = (unsigned short) y;
|
||||
pMotorTable[i + 512 * 4] = (unsigned short) y;
|
||||
pMotorTable[i + 512 * 6] = (unsigned short) y;
|
||||
}
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
y = wStartSpeed - (wStartSpeed - wEndSpeed) *
|
||||
pow (0.3, (M_PI_2 * i) / 256);
|
||||
lpMotorTable[i + 512] = (unsigned short) y;
|
||||
lpMotorTable[i + 512 * 3] = (unsigned short) y;
|
||||
lpMotorTable[i + 512 * 5] = (unsigned short) y;
|
||||
lpMotorTable[i + 512 * 7] = (unsigned short) y;
|
||||
pMotorTable[i + 512] = (unsigned short) y;
|
||||
pMotorTable[i + 512 * 3] = (unsigned short) y;
|
||||
pMotorTable[i + 512 * 5] = (unsigned short) y;
|
||||
pMotorTable[i + 512 * 7] = (unsigned short) y;
|
||||
}
|
||||
|
||||
for (i = 0; i < wScanAccSteps; i++)
|
||||
|
@ -959,7 +955,7 @@ CalculateMoveMotorTable (LLF_CALCULATEMOTORTABLE * lpCalculateMotorTable)
|
|||
(pow (0.09, (M_PI_2 * i) / wScanAccSteps) -
|
||||
pow (0.09, (M_PI_2 * (wScanAccSteps - 1)) / wScanAccSteps)) +
|
||||
wEndSpeed;
|
||||
lpMotorTable[i + 512 * 2] = (unsigned short) y;
|
||||
pMotorTable[i + 512 * 2] = (unsigned short) y;
|
||||
}
|
||||
|
||||
DBG (DBG_ASIC, "CalculateMoveMotorTable: Exit\n");
|
||||
|
@ -1005,7 +1001,7 @@ MotorMove (ASIC * chip, unsigned short wStartSpeed, unsigned short wEndSpeed,
|
|||
CalMotorTable.StartSpeed = wStartSpeed;
|
||||
CalMotorTable.EndSpeed = wEndSpeed;
|
||||
CalMotorTable.AccStepBeforeScan = 511;
|
||||
CalMotorTable.lpMotorTable = MotorTable;
|
||||
CalMotorTable.pMotorTable = MotorTable;
|
||||
CalculateMoveMotorTable (&CalMotorTable);
|
||||
|
||||
CurrentPhase.MoveType = _4_TABLE_SPACE_FOR_FULL_STEP;
|
||||
|
@ -1996,7 +1992,7 @@ Asic_Initialize (ASIC * chip)
|
|||
chip->isUsb20 = SANE_FALSE;
|
||||
chip->dwBytesCountPerRow = 0;
|
||||
chip->isMotorMoveToFirstLine = MOTOR_MOVE_TO_FIRST_LINE_ENABLE;
|
||||
chip->lpShadingTable = NULL;
|
||||
chip->pShadingTable = NULL;
|
||||
|
||||
InitTiming (chip);
|
||||
|
||||
|
@ -2143,7 +2139,7 @@ Asic_SetWindow (ASIC * chip, SCANSOURCE lsLightSource,
|
|||
unsigned short XRatioTypeWord;
|
||||
double XRatioTypeDouble;
|
||||
double XRatioAdderDouble;
|
||||
LLF_MOTORMOVE lpMotorStepsTable;
|
||||
LLF_MOTORMOVE pMotorStepsTable;
|
||||
SANE_Byte bDummyCycleNum;
|
||||
unsigned short wMultiMotorStep;
|
||||
SANE_Byte bMotorMoveType;
|
||||
|
@ -2156,7 +2152,7 @@ Asic_SetWindow (ASIC * chip, SCANSOURCE lsLightSource,
|
|||
SANE_Byte isMotorMoveToFirstLine;
|
||||
SANE_Byte isUniformSpeedToScan;
|
||||
SANE_Byte isScanBackTracking;
|
||||
unsigned short * lpMotorTable;
|
||||
unsigned short * pMotorTable;
|
||||
unsigned int RealTableSize;
|
||||
unsigned short wFullBank;
|
||||
|
||||
|
@ -2301,13 +2297,13 @@ Asic_SetWindow (ASIC * chip, SCANSOURCE lsLightSource,
|
|||
|
||||
if (ScanType == SCAN_TYPE_NORMAL)
|
||||
{
|
||||
SetMotorStepTable (chip, &lpMotorStepsTable, wY,
|
||||
SetMotorStepTable (chip, &pMotorStepsTable, wY,
|
||||
wLength * SENSOR_DPI / wYResolution * wMultiMotorStep,
|
||||
wYResolution);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetMotorStepTableForCalibration (chip, &lpMotorStepsTable,
|
||||
SetMotorStepTableForCalibration (chip, &pMotorStepsTable,
|
||||
wLength * SENSOR_DPI / wYResolution * wMultiMotorStep);
|
||||
}
|
||||
|
||||
|
@ -2362,19 +2358,19 @@ Asic_SetWindow (ASIC * chip, SCANSOURCE lsLightSource,
|
|||
Mustek_SendData (chip, ES01_FD_MotorFixedspeedLSB, LOBYTE (EndSpeed));
|
||||
Mustek_SendData (chip, ES01_FE_MotorFixedspeedMSB, HIBYTE (EndSpeed));
|
||||
|
||||
lpMotorTable = malloc (MOTOR_TABLE_SIZE * sizeof (unsigned short));
|
||||
if (!lpMotorTable)
|
||||
pMotorTable = malloc (MOTOR_TABLE_SIZE * sizeof (unsigned short));
|
||||
if (!pMotorTable)
|
||||
{
|
||||
DBG (DBG_ERR, "Asic_SetWindow: lpMotorTable == NULL\n");
|
||||
DBG (DBG_ERR, "Asic_SetWindow: pMotorTable == NULL\n");
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
memset (lpMotorTable, 0, MOTOR_TABLE_SIZE * sizeof (unsigned short));
|
||||
memset (pMotorTable, 0, MOTOR_TABLE_SIZE * sizeof (unsigned short));
|
||||
|
||||
CalMotorTable.StartSpeed = StartSpeed;
|
||||
CalMotorTable.EndSpeed = EndSpeed;
|
||||
CalMotorTable.AccStepBeforeScan = lpMotorStepsTable.wScanAccSteps;
|
||||
CalMotorTable.DecStepAfterScan = lpMotorStepsTable.bScanDecSteps;
|
||||
CalMotorTable.lpMotorTable = lpMotorTable;
|
||||
CalMotorTable.AccStepBeforeScan = pMotorStepsTable.wScanAccSteps;
|
||||
CalMotorTable.DecStepAfterScan = pMotorStepsTable.bScanDecSteps;
|
||||
CalMotorTable.pMotorTable = pMotorTable;
|
||||
if (ScanType == SCAN_TYPE_NORMAL)
|
||||
CalculateScanMotorTable (&CalMotorTable);
|
||||
else
|
||||
|
@ -2394,8 +2390,8 @@ Asic_SetWindow (ASIC * chip, SCANSOURCE lsLightSource,
|
|||
/* write motor table */
|
||||
RealTableSize = MOTOR_TABLE_SIZE;
|
||||
dwTableBaseAddr = PACK_AREA_START_ADDRESS - RealTableSize;
|
||||
status = LLFSetMotorTable (chip, dwTableBaseAddr, lpMotorTable);
|
||||
free (lpMotorTable);
|
||||
status = LLFSetMotorTable (chip, dwTableBaseAddr, pMotorTable);
|
||||
free (pMotorTable);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
return status;
|
||||
|
||||
|
@ -2411,7 +2407,7 @@ Asic_SetWindow (ASIC * chip, SCANSOURCE lsLightSource,
|
|||
RealTableSize = sizeof (unsigned short) *
|
||||
ShadingTableSize ((int) ((wWidth + 4) * XRatioAdderDouble));
|
||||
status = LLFSetShadingTable (chip, dwTableBaseAddr, RealTableSize,
|
||||
chip->lpShadingTable);
|
||||
chip->pShadingTable);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
return status;
|
||||
}
|
||||
|
@ -2750,8 +2746,8 @@ Asic_CarriageHome (ASIC * chip)
|
|||
}
|
||||
|
||||
SANE_Status
|
||||
Asic_SetShadingTable (ASIC * chip, unsigned short * lpWhiteShading,
|
||||
unsigned short * lpDarkShading,
|
||||
Asic_SetShadingTable (ASIC * chip, unsigned short * pWhiteShading,
|
||||
unsigned short * pDarkShading,
|
||||
unsigned short wXResolution, unsigned short wWidth)
|
||||
{
|
||||
unsigned short i, j, n;
|
||||
|
@ -2779,15 +2775,15 @@ Asic_SetShadingTable (ASIC * chip, unsigned short * lpWhiteShading,
|
|||
First 4 and last 5 elements of shading table cannot be used. */
|
||||
wShadingTableSize = ShadingTableSize (wValidPixelNumber) *
|
||||
sizeof (unsigned short);
|
||||
if (chip->lpShadingTable)
|
||||
free (chip->lpShadingTable);
|
||||
if (chip->pShadingTable)
|
||||
free (chip->pShadingTable);
|
||||
|
||||
DBG (DBG_ASIC, "Allocating a new shading table, size=%d byte\n",
|
||||
wShadingTableSize);
|
||||
chip->lpShadingTable = malloc (wShadingTableSize);
|
||||
if (!chip->lpShadingTable)
|
||||
chip->pShadingTable = malloc (wShadingTableSize);
|
||||
if (!chip->pShadingTable)
|
||||
{
|
||||
DBG (DBG_ASIC, "lpShadingTable == NULL\n");
|
||||
DBG (DBG_ASIC, "pShadingTable == NULL\n");
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
|
||||
|
@ -2800,13 +2796,13 @@ Asic_SetShadingTable (ASIC * chip, unsigned short * lpWhiteShading,
|
|||
|
||||
for (j = 0; j < numPixel; j++)
|
||||
{
|
||||
chip->lpShadingTable[i * 256 + j * 6] = lpDarkShading[n * 3];
|
||||
chip->lpShadingTable[i * 256 + j * 6 + 2] = lpDarkShading[n * 3 + 1];
|
||||
chip->lpShadingTable[i * 256 + j * 6 + 4] = lpDarkShading[n * 3 + 2];
|
||||
chip->pShadingTable[i * 256 + j * 6] = pDarkShading[n * 3];
|
||||
chip->pShadingTable[i * 256 + j * 6 + 2] = pDarkShading[n * 3 + 1];
|
||||
chip->pShadingTable[i * 256 + j * 6 + 4] = pDarkShading[n * 3 + 2];
|
||||
|
||||
chip->lpShadingTable[i * 256 + j * 6 + 1] = lpWhiteShading[n * 3];
|
||||
chip->lpShadingTable[i * 256 + j * 6 + 3] = lpWhiteShading[n * 3 + 1];
|
||||
chip->lpShadingTable[i * 256 + j * 6 + 5] = lpWhiteShading[n * 3 + 2];
|
||||
chip->pShadingTable[i * 256 + j * 6 + 1] = pWhiteShading[n * 3];
|
||||
chip->pShadingTable[i * 256 + j * 6 + 3] = pWhiteShading[n * 3 + 1];
|
||||
chip->pShadingTable[i * 256 + j * 6 + 5] = pWhiteShading[n * 3 + 2];
|
||||
|
||||
if ((j % (unsigned short) dbXRatioAdderDouble) ==
|
||||
(dbXRatioAdderDouble - 1))
|
||||
|
|
|
@ -129,7 +129,7 @@ typedef struct
|
|||
unsigned short EndSpeed;
|
||||
unsigned short AccStepBeforeScan;
|
||||
SANE_Byte DecStepAfterScan;
|
||||
unsigned short * lpMotorTable;
|
||||
unsigned short * pMotorTable;
|
||||
} LLF_CALCULATEMOTORTABLE;
|
||||
|
||||
typedef struct
|
||||
|
@ -200,7 +200,7 @@ typedef struct
|
|||
ADConverter AD;
|
||||
|
||||
SANE_Byte isMotorMoveToFirstLine;
|
||||
unsigned short * lpShadingTable;
|
||||
unsigned short * pShadingTable;
|
||||
} ASIC;
|
||||
|
||||
|
||||
|
@ -984,8 +984,8 @@ SANE_Status Asic_ReadCalibrationData (ASIC * chip, SANE_Byte * pBuffer,
|
|||
SANE_Status Asic_MotorMove (ASIC * chip, SANE_Bool isForward,
|
||||
unsigned int dwTotalSteps);
|
||||
SANE_Status Asic_CarriageHome (ASIC * chip);
|
||||
SANE_Status Asic_SetShadingTable (ASIC * chip, unsigned short * lpWhiteShading,
|
||||
unsigned short * lpDarkShading,
|
||||
SANE_Status Asic_SetShadingTable (ASIC * chip, unsigned short * pWhiteShading,
|
||||
unsigned short * pDarkShading,
|
||||
unsigned short wXResolution,
|
||||
unsigned short wWidth);
|
||||
|
||||
|
|
Plik diff jest za duży
Load Diff
|
@ -109,7 +109,7 @@ typedef struct
|
|||
|
||||
extern SANE_Bool g_isScanning;
|
||||
extern unsigned short g_SWHeight;
|
||||
extern SANE_Byte * g_lpReadImageHead;
|
||||
extern SANE_Byte * g_pReadImageHead;
|
||||
extern unsigned short g_wLineartThreshold;
|
||||
extern unsigned short * g_pGammaTable;
|
||||
extern SCANSOURCE g_ssScanSource;
|
||||
|
@ -118,7 +118,7 @@ extern ASIC g_chip;
|
|||
void MustScanner_Init (void);
|
||||
SANE_Bool MustScanner_PowerControl (SANE_Bool isLampOn, SANE_Bool isTALampOn);
|
||||
SANE_Bool MustScanner_BackHome (void);
|
||||
SANE_Bool MustScanner_GetRows (SANE_Byte * lpBlock, unsigned short * Rows,
|
||||
SANE_Bool MustScanner_GetRows (SANE_Byte * pBlock, unsigned short * Rows,
|
||||
SANE_Bool isOrderInvert);
|
||||
SANE_Bool MustScanner_ScanSuggest (TARGETIMAGE * pTarget);
|
||||
SANE_Bool MustScanner_StopScan (void);
|
||||
|
|
Ładowanie…
Reference in New Issue