kopia lustrzana https://gitlab.com/sane-project/backends
Use standard macros for byte swapping.
rodzic
281f53aa18
commit
b2b3cf767a
|
@ -48,18 +48,18 @@
|
|||
|
||||
#define BUILD 11
|
||||
|
||||
#include "../include/sane/config.h"
|
||||
#include "sane/config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../include/sane/sane.h"
|
||||
#include "../include/sane/sanei.h"
|
||||
#include "../include/sane/saneopts.h"
|
||||
#include "sane/sane.h"
|
||||
#include "sane/sanei.h"
|
||||
#include "sane/saneopts.h"
|
||||
|
||||
#define BACKEND_NAME mustek_usb2
|
||||
#include "../include/sane/sanei_backend.h"
|
||||
#include "sane/sanei_backend.h"
|
||||
|
||||
#include "mustek_usb2.h"
|
||||
|
||||
|
|
|
@ -46,16 +46,17 @@
|
|||
and similar USB2 scanners. */
|
||||
|
||||
#define DEBUG_DECLARE_ONLY
|
||||
#include "../include/sane/config.h"
|
||||
#include "sane/config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "../include/sane/sane.h"
|
||||
#include "../include/sane/sanei_usb.h"
|
||||
#include "../include/sane/sanei_backend.h"
|
||||
#include "byteorder.h"
|
||||
#include "sane/sane.h"
|
||||
#include "sane/sanei_usb.h"
|
||||
#include "sane/sanei_backend.h"
|
||||
|
||||
#include "mustek_usb2_asic.h"
|
||||
|
||||
|
@ -844,8 +845,8 @@ CalculateScanMotorTable (CALCULATEMOTORTABLE * pCalculateMotorTable)
|
|||
y = 6000 - 3500;
|
||||
y *= pow (0.09, (M_PI_2 * i) / 512) - pow (0.09, (M_PI_2 * 511) / 512);
|
||||
y += 4500;
|
||||
pMotorTable[i] = CPU2LE16 ((unsigned short) y); /* T0 */
|
||||
pMotorTable[i + 512 * 6] = CPU2LE16 ((unsigned short) y); /* T6 */
|
||||
pMotorTable[i] = htole16 ((unsigned short) y); /* T0 */
|
||||
pMotorTable[i + 512 * 6] = htole16 ((unsigned short) y); /* T6 */
|
||||
}
|
||||
|
||||
/* motor T1 & T7 dec table */
|
||||
|
@ -854,8 +855,8 @@ CalculateScanMotorTable (CALCULATEMOTORTABLE * pCalculateMotorTable)
|
|||
y = 6000 - 3500;
|
||||
y *= pow (0.3, (M_PI_2 * i) / 256);
|
||||
y = 6000 - y;
|
||||
pMotorTable[i + 512] = CPU2LE16 ((unsigned short) y); /* T1 */
|
||||
pMotorTable[i + 512 * 7] = CPU2LE16 ((unsigned short) y); /* T7 */
|
||||
pMotorTable[i + 512] = htole16 ((unsigned short) y); /* T1 */
|
||||
pMotorTable[i + 512 * 7] = htole16 ((unsigned short) y); /* T7 */
|
||||
}
|
||||
|
||||
for (i = 0; i < wScanAccSteps; i++)
|
||||
|
@ -864,13 +865,13 @@ CalculateScanMotorTable (CALCULATEMOTORTABLE * pCalculateMotorTable)
|
|||
y *= pow (0.09, (M_PI_2 * i) / wScanAccSteps) -
|
||||
pow (0.09, (M_PI_2 * (wScanAccSteps - 1)) / wScanAccSteps);
|
||||
y += wEndSpeed;
|
||||
pMotorTable[i + 512 * 2] = CPU2LE16 ((unsigned short) y); /* T2 */
|
||||
pMotorTable[i + 512 * 4] = CPU2LE16 ((unsigned short) y); /* T4 */
|
||||
pMotorTable[i + 512 * 2] = htole16 ((unsigned short) y); /* T2 */
|
||||
pMotorTable[i + 512 * 4] = htole16 ((unsigned short) y); /* T4 */
|
||||
}
|
||||
for (i = wScanAccSteps; i < 512; i++)
|
||||
{
|
||||
pMotorTable[i + 512 * 2] = CPU2LE16 (wEndSpeed); /* T2 */
|
||||
pMotorTable[i + 512 * 4] = CPU2LE16 (wEndSpeed); /* T4 */
|
||||
pMotorTable[i + 512 * 2] = htole16 (wEndSpeed); /* T2 */
|
||||
pMotorTable[i + 512 * 4] = htole16 (wEndSpeed); /* T4 */
|
||||
}
|
||||
|
||||
for (i = 0; i < (unsigned short) bScanDecSteps; i++)
|
||||
|
@ -878,13 +879,13 @@ CalculateScanMotorTable (CALCULATEMOTORTABLE * pCalculateMotorTable)
|
|||
y = wStartSpeed - wEndSpeed;
|
||||
y *= pow (0.3, (M_PI_2 * i) / bScanDecSteps);
|
||||
y = wStartSpeed - y;
|
||||
pMotorTable[i + 512 * 3] = CPU2LE16 ((unsigned short) y); /* T3 */
|
||||
pMotorTable[i + 512 * 5] = CPU2LE16 ((unsigned short) y); /* T5 */
|
||||
pMotorTable[i + 512 * 3] = htole16 ((unsigned short) y); /* T3 */
|
||||
pMotorTable[i + 512 * 5] = htole16 ((unsigned short) y); /* T5 */
|
||||
}
|
||||
for (i = bScanDecSteps; i < 256; i++)
|
||||
{
|
||||
pMotorTable[i + 512 * 3] = CPU2LE16 (wStartSpeed); /* T3 */
|
||||
pMotorTable[i + 512 * 5] = CPU2LE16 (wStartSpeed); /* T5 */
|
||||
pMotorTable[i + 512 * 3] = htole16 (wStartSpeed); /* T3 */
|
||||
pMotorTable[i + 512 * 5] = htole16 (wStartSpeed); /* T5 */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -907,20 +908,20 @@ CalculateMoveMotorTable (CALCULATEMOTORTABLE * pCalculateMotorTable)
|
|||
/* before scan acc table */
|
||||
y = (wStartSpeed - wEndSpeed) *
|
||||
pow (0.09, (M_PI_2 * i) / 512) + wEndSpeed;
|
||||
pMotorTable[i] = CPU2LE16 ((unsigned short) y);
|
||||
pMotorTable[i + 512 * 2] = CPU2LE16 ((unsigned short) y);
|
||||
pMotorTable[i + 512 * 4] = CPU2LE16 ((unsigned short) y);
|
||||
pMotorTable[i + 512 * 6] = CPU2LE16 ((unsigned short) y);
|
||||
pMotorTable[i] = htole16 ((unsigned short) y);
|
||||
pMotorTable[i + 512 * 2] = htole16 ((unsigned short) y);
|
||||
pMotorTable[i + 512 * 4] = htole16 ((unsigned short) y);
|
||||
pMotorTable[i + 512 * 6] = htole16 ((unsigned short) y);
|
||||
}
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
y = wStartSpeed - (wStartSpeed - wEndSpeed) *
|
||||
pow (0.3, (M_PI_2 * i) / 256);
|
||||
pMotorTable[i + 512] = CPU2LE16 ((unsigned short) y);
|
||||
pMotorTable[i + 512 * 3] = CPU2LE16 ((unsigned short) y);
|
||||
pMotorTable[i + 512 * 5] = CPU2LE16 ((unsigned short) y);
|
||||
pMotorTable[i + 512 * 7] = CPU2LE16 ((unsigned short) y);
|
||||
pMotorTable[i + 512] = htole16 ((unsigned short) y);
|
||||
pMotorTable[i + 512 * 3] = htole16 ((unsigned short) y);
|
||||
pMotorTable[i + 512 * 5] = htole16 ((unsigned short) y);
|
||||
pMotorTable[i + 512 * 7] = htole16 ((unsigned short) y);
|
||||
}
|
||||
|
||||
for (i = 0; i < wScanAccSteps; i++)
|
||||
|
@ -929,7 +930,7 @@ CalculateMoveMotorTable (CALCULATEMOTORTABLE * pCalculateMotorTable)
|
|||
(pow (0.09, (M_PI_2 * i) / wScanAccSteps) -
|
||||
pow (0.09, (M_PI_2 * (wScanAccSteps - 1)) / wScanAccSteps)) +
|
||||
wEndSpeed;
|
||||
pMotorTable[i + 512 * 2] = CPU2LE16 ((unsigned short) y);
|
||||
pMotorTable[i + 512 * 2] = htole16 ((unsigned short) y);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2032,7 +2033,7 @@ Asic_SetWindow (ASIC * chip, SCANSOURCE lsLightSource,
|
|||
SCAN_TYPE ScanType, SANE_Byte bScanBits,
|
||||
unsigned short wXResolution, unsigned short wYResolution,
|
||||
unsigned short wX, unsigned short wY,
|
||||
unsigned short wWidth, unsigned short wLength)
|
||||
unsigned short wWidth, unsigned short wHeight)
|
||||
{
|
||||
SANE_Status status;
|
||||
unsigned short ValidPixelNumber;
|
||||
|
@ -2060,9 +2061,9 @@ Asic_SetWindow (ASIC * chip, SCANSOURCE lsLightSource,
|
|||
DBG_ASIC_ENTER ();
|
||||
DBG (DBG_ASIC, "lsLightSource=%d,ScanType=%d,bScanBits=%d," \
|
||||
"wXResolution=%d,wYResolution=%d,wX=%d,wY=%d," \
|
||||
"wWidth=%d,wLength=%d\n",
|
||||
"wWidth=%d,wHeight=%d\n",
|
||||
lsLightSource, ScanType, bScanBits, wXResolution, wYResolution, wX, wY,
|
||||
wWidth, wLength);
|
||||
wWidth, wHeight);
|
||||
|
||||
if (chip->firmwarestate != FS_OPENED)
|
||||
{
|
||||
|
@ -2196,13 +2197,13 @@ Asic_SetWindow (ASIC * chip, SCANSOURCE lsLightSource,
|
|||
if (ScanType == SCAN_TYPE_NORMAL)
|
||||
{
|
||||
SetMotorStepTable (chip, &pMotorStepsTable, wY,
|
||||
wLength * SENSOR_DPI / wYResolution * wMultiMotorStep,
|
||||
wHeight * SENSOR_DPI / wYResolution * wMultiMotorStep,
|
||||
wYResolution);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetMotorStepTableForCalibration (chip, &pMotorStepsTable,
|
||||
wLength * SENSOR_DPI / wYResolution * wMultiMotorStep);
|
||||
wHeight * SENSOR_DPI / wYResolution * wMultiMotorStep);
|
||||
}
|
||||
|
||||
/* calculate line time */
|
||||
|
@ -2673,18 +2674,18 @@ Asic_SetShadingTable (ASIC * chip, unsigned short * pWhiteShading,
|
|||
for (j = 0; j < numPixel; j++)
|
||||
{
|
||||
chip->pShadingTable[i * 256 + j * 6] =
|
||||
CPU2LE16 (pDarkShading[n * 3]);
|
||||
htole16 (pDarkShading[n * 3]);
|
||||
chip->pShadingTable[i * 256 + j * 6 + 2] =
|
||||
CPU2LE16 (pDarkShading[n * 3 + 1]);
|
||||
htole16 (pDarkShading[n * 3 + 1]);
|
||||
chip->pShadingTable[i * 256 + j * 6 + 4] =
|
||||
CPU2LE16 (pDarkShading[n * 3 + 2]);
|
||||
htole16 (pDarkShading[n * 3 + 2]);
|
||||
|
||||
chip->pShadingTable[i * 256 + j * 6 + 1] =
|
||||
CPU2LE16 (pWhiteShading[n * 3]);
|
||||
htole16 (pWhiteShading[n * 3]);
|
||||
chip->pShadingTable[i * 256 + j * 6 + 3] =
|
||||
CPU2LE16 (pWhiteShading[n * 3 + 1]);
|
||||
htole16 (pWhiteShading[n * 3 + 1]);
|
||||
chip->pShadingTable[i * 256 + j * 6 + 5] =
|
||||
CPU2LE16 (pWhiteShading[n * 3 + 2]);
|
||||
htole16 (pWhiteShading[n * 3 + 2]);
|
||||
|
||||
if ((j % (unsigned short) dbXRatioAdderDouble) ==
|
||||
(dbXRatioAdderDouble - 1))
|
||||
|
|
|
@ -58,9 +58,6 @@
|
|||
# define BYTE1(x) (SANE_Byte)(((unsigned int)(x) >> 16) & 0xff)
|
||||
# define BYTE2(x) (SANE_Byte)(((unsigned int)(x) >> 8) & 0xff)
|
||||
# define BYTE3(x) (SANE_Byte)((unsigned int)(x) & 0xff)
|
||||
# define _SWAP16(x) (((x) & 0xff) << 8 | ((x) & 0xff00) >> 8)
|
||||
# define LE2CPU16(x) _SWAP16(x)
|
||||
# define CPU2LE16(x) _SWAP16(x)
|
||||
#else
|
||||
# define LOBYTE(w) (SANE_Byte)((unsigned short)(w) & 0xff)
|
||||
# define HIBYTE(w) (SANE_Byte)(((unsigned short)(w) >> 8) & 0xff)
|
||||
|
@ -68,8 +65,6 @@
|
|||
# define BYTE1(x) (SANE_Byte)(((unsigned int)(x) >> 8) & 0xff)
|
||||
# define BYTE2(x) (SANE_Byte)(((unsigned int)(x) >> 16) & 0xff)
|
||||
# define BYTE3(x) (SANE_Byte)(((unsigned int)(x) >> 24) & 0xff)
|
||||
# define LE2CPU16(x) (x)
|
||||
# define CPU2LE16(x) (x)
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -986,7 +981,7 @@ SANE_Status Asic_SetWindow (ASIC * chip, SCANSOURCE lsLightSource,
|
|||
unsigned short wXResolution,
|
||||
unsigned short wYResolution,
|
||||
unsigned short wX, unsigned short wY,
|
||||
unsigned short wWidth, unsigned short wLength);
|
||||
unsigned short wWidth, unsigned short wHeight);
|
||||
SANE_Status Asic_ScanStart (ASIC * chip);
|
||||
SANE_Status Asic_ScanStop (ASIC * chip);
|
||||
SANE_Status Asic_ReadImage (ASIC * chip, SANE_Byte * pBuffer,
|
||||
|
|
|
@ -46,15 +46,17 @@
|
|||
and similar USB2 scanners. */
|
||||
|
||||
#define DEBUG_DECLARE_ONLY
|
||||
#include "../include/sane/config.h"
|
||||
#include "sane/config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include <pthread.h> /* TODO: use sanei_thread functions instead */
|
||||
|
||||
#include "../include/sane/sane.h"
|
||||
#include "../include/sane/sanei_backend.h"
|
||||
#include "byteorder.h"
|
||||
#include "sane/sane.h"
|
||||
#include "sane/sanei_backend.h"
|
||||
|
||||
#include "mustek_usb2_high.h"
|
||||
|
||||
|
@ -272,9 +274,9 @@ GetRgb48BitLineHalf (Scanner_State * st, SANE_Byte * pLine,
|
|||
wBTempData = st->pReadImageHead[wBLinePos + i * 6 + 4] |
|
||||
(st->pReadImageHead[wBLinePos + i * 6 + 5] << 8);
|
||||
|
||||
wRTempData = LE2CPU16 (wRTempData);
|
||||
wGTempData = LE2CPU16 (wGTempData);
|
||||
wBTempData = LE2CPU16 (wBTempData);
|
||||
LE16TOH (wRTempData);
|
||||
LE16TOH (wGTempData);
|
||||
LE16TOH (wBTempData);
|
||||
|
||||
SetPixel48Bit ((unsigned short *) (pLine + (i * 6)), st->pGammaTable,
|
||||
wRTempData, wGTempData, wBTempData, isOrderInvert);
|
||||
|
@ -342,9 +344,9 @@ GetRgb48BitLineFull (Scanner_State * st, SANE_Byte * pLine,
|
|||
(st->pReadImageHead[wBLinePosEven + (i + 1) * 6 + 5] << 8);
|
||||
dwBTempData /= 2;
|
||||
|
||||
dwRTempData = LE2CPU16 (dwRTempData);
|
||||
dwGTempData = LE2CPU16 (dwGTempData);
|
||||
dwBTempData = LE2CPU16 (dwBTempData);
|
||||
LE16TOH (dwRTempData);
|
||||
LE16TOH (dwGTempData);
|
||||
LE16TOH (dwBTempData);
|
||||
|
||||
SetPixel48Bit ((unsigned short *) (pLine + (i * 6)), st->pGammaTable,
|
||||
dwRTempData, dwGTempData, dwBTempData, isOrderInvert);
|
||||
|
@ -368,9 +370,9 @@ GetRgb48BitLineFull (Scanner_State * st, SANE_Byte * pLine,
|
|||
(st->pReadImageHead[wBLinePosOdd + (i + 1) * 6 + 5] << 8);
|
||||
dwBTempData /= 2;
|
||||
|
||||
dwRTempData = LE2CPU16 (dwRTempData);
|
||||
dwGTempData = LE2CPU16 (dwGTempData);
|
||||
dwBTempData = LE2CPU16 (dwBTempData);
|
||||
LE16TOH (dwRTempData);
|
||||
LE16TOH (dwGTempData);
|
||||
LE16TOH (dwBTempData);
|
||||
|
||||
SetPixel48Bit ((unsigned short *) (pLine + (i * 6)), st->pGammaTable,
|
||||
dwRTempData, dwGTempData, dwBTempData, isOrderInvert);
|
||||
|
@ -536,7 +538,7 @@ GetMono16BitLineHalf (Scanner_State * st, SANE_Byte * pLine,
|
|||
{
|
||||
wTempData = st->pReadImageHead[wLinePos + i * 2] |
|
||||
(st->pReadImageHead[wLinePos + i * 2 + 1] << 8);
|
||||
wTempData = LE2CPU16 (wTempData);
|
||||
LE16TOH (wTempData);
|
||||
*((unsigned short *) (pLine + (i * 2))) = st->pGammaTable[wTempData];
|
||||
}
|
||||
}
|
||||
|
@ -576,7 +578,7 @@ GetMono16BitLineFull (Scanner_State * st, SANE_Byte * pLine,
|
|||
dwTempData += (unsigned int)
|
||||
st->pReadImageHead[wLinePosEven + (i + 1) * 2 + 1] << 8;
|
||||
dwTempData /= 2;
|
||||
dwTempData = LE2CPU16 (dwTempData);
|
||||
LE16TOH (dwTempData);
|
||||
|
||||
*((unsigned short *) (pLine + (i * 2))) = st->pGammaTable[dwTempData];
|
||||
i++;
|
||||
|
@ -589,7 +591,7 @@ GetMono16BitLineFull (Scanner_State * st, SANE_Byte * pLine,
|
|||
dwTempData += (unsigned int)
|
||||
st->pReadImageHead[wLinePosOdd + (i + 1) * 2 + 1] << 8;
|
||||
dwTempData /= 2;
|
||||
dwTempData = LE2CPU16 (dwTempData);
|
||||
LE16TOH (dwTempData);
|
||||
|
||||
*((unsigned short *) (pLine + (i * 2))) = st->pGammaTable[dwTempData];
|
||||
i++;
|
||||
|
@ -1798,9 +1800,9 @@ LineCalibration16Bits (Scanner_State * st)
|
|||
{
|
||||
for (j = 0; j < wCalHeight; j++)
|
||||
{
|
||||
pRDarkSort[j] = LE2CPU16 (pDarkData[j * wCalWidth * 3 + i * 3]);
|
||||
pGDarkSort[j] = LE2CPU16 (pDarkData[j * wCalWidth * 3 + i * 3 + 1]);
|
||||
pBDarkSort[j] = LE2CPU16 (pDarkData[j * wCalWidth * 3 + i * 3 + 2]);
|
||||
pRDarkSort[j] = le16toh (pDarkData[j * wCalWidth * 3 + i * 3]);
|
||||
pGDarkSort[j] = le16toh (pDarkData[j * wCalWidth * 3 + i * 3 + 1]);
|
||||
pBDarkSort[j] = le16toh (pDarkData[j * wCalWidth * 3 + i * 3 + 2]);
|
||||
}
|
||||
|
||||
/* sum of dark level for all pixels */
|
||||
|
@ -1849,9 +1851,9 @@ LineCalibration16Bits (Scanner_State * st)
|
|||
{
|
||||
for (j = 0; j < wCalHeight; j++)
|
||||
{
|
||||
pRWhiteSort[j] = LE2CPU16 (pWhiteData[j * wCalWidth * 3 + i * 3]);
|
||||
pGWhiteSort[j] = LE2CPU16 (pWhiteData[j * wCalWidth * 3 + i * 3 + 1]);
|
||||
pBWhiteSort[j] = LE2CPU16 (pWhiteData[j * wCalWidth * 3 + i * 3 + 2]);
|
||||
pRWhiteSort[j] = le16toh (pWhiteData[j * wCalWidth * 3 + i * 3]);
|
||||
pGWhiteSort[j] = le16toh (pWhiteData[j * wCalWidth * 3 + i * 3 + 1]);
|
||||
pBWhiteSort[j] = le16toh (pWhiteData[j * wCalWidth * 3 + i * 3 + 2]);
|
||||
}
|
||||
|
||||
if ((st->Target.wXDpi == SENSOR_DPI) && ((i % 2) == 0))
|
||||
|
|
|
@ -48,8 +48,6 @@
|
|||
#ifndef MUSTEK_USB2_HIGH_H
|
||||
#define MUSTEK_USB2_HIGH_H
|
||||
|
||||
#include <pthread.h> /* TODO: use sanei_thread functions instead */
|
||||
|
||||
#include "mustek_usb2_asic.h"
|
||||
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue