kopia lustrzana https://gitlab.com/sane-project/backends
code cleanups to prepare glxxx_init_scan_regs convergence
rodzic
e56afbd8e8
commit
dbc2f9976f
|
@ -1191,18 +1191,12 @@ gl124_setup_sensor (Genesys_Device * dev, Genesys_Register_Set * regs, int dpi)
|
||||||
DBGCOMPLETED;
|
DBGCOMPLETED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
/** @brief setup optical related registers
|
/** @brief setup optical related registers
|
||||||
* start and pixels are expressed in optical sensor resolution coordinate
|
* start and pixels are expressed in optical sensor resolution coordinate
|
||||||
* space. To handle odd/even case we double the resolution and
|
* space.
|
||||||
* use only first logical half the sensor which maps to effective CCD.
|
* @param exposure_time exposure time to use
|
||||||
|
* @param used_res scanning resolution used, may differ from
|
||||||
|
* scan's one
|
||||||
* @param start logical start pixel coordinate
|
* @param start logical start pixel coordinate
|
||||||
* @param pixels logical number of pixels to use
|
* @param pixels logical number of pixels to use
|
||||||
* @return SANE_STATUS_GOOD if OK
|
* @return SANE_STATUS_GOOD if OK
|
||||||
|
@ -1407,7 +1401,7 @@ gl124_init_optical_regs_scan (Genesys_Device * dev,
|
||||||
words_per_line *= channels;
|
words_per_line *= channels;
|
||||||
dev->wpl = words_per_line;
|
dev->wpl = words_per_line;
|
||||||
|
|
||||||
/* allocate buffer for odd/even pixles handling */
|
/* allocate buffer for odd/even pixels handling */
|
||||||
if(dev->oe_buffer.buffer!=NULL)
|
if(dev->oe_buffer.buffer!=NULL)
|
||||||
{
|
{
|
||||||
sanei_genesys_buffer_free (&(dev->oe_buffer));
|
sanei_genesys_buffer_free (&(dev->oe_buffer));
|
||||||
|
@ -1499,17 +1493,15 @@ gl124_init_scan_regs (Genesys_Device * dev,
|
||||||
stagger = 0;
|
stagger = 0;
|
||||||
DBG (DBG_info, "gl124_init_scan_regs : stagger=%d lines\n", stagger);
|
DBG (DBG_info, "gl124_init_scan_regs : stagger=%d lines\n", stagger);
|
||||||
|
|
||||||
/** @brief compute used resolution
|
/** @brief compute used resolution */
|
||||||
* the sensor if mapped only to odd pixels. So we double the optical
|
|
||||||
* resolution and use first half
|
|
||||||
* */
|
|
||||||
if (flags & SCAN_FLAG_USE_OPTICAL_RES)
|
if (flags & SCAN_FLAG_USE_OPTICAL_RES)
|
||||||
{
|
{
|
||||||
used_res = optical_res;
|
used_res = optical_res;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* resolution is choosen from a fixed list and can be used directly */
|
/* resolution is choosen from a fixed list and can be used directly,
|
||||||
|
* unless we have ydpi higher than sensor's maximum one */
|
||||||
if(xres>optical_res)
|
if(xres>optical_res)
|
||||||
used_res=optical_res;
|
used_res=optical_res;
|
||||||
else
|
else
|
||||||
|
@ -1527,7 +1519,6 @@ gl124_init_scan_regs (Genesys_Device * dev,
|
||||||
start |= 1;
|
start |= 1;
|
||||||
|
|
||||||
/* compute correct pixels number */
|
/* compute correct pixels number */
|
||||||
/* pixels */
|
|
||||||
used_pixels = (pixels * optical_res) / xres;
|
used_pixels = (pixels * optical_res) / xres;
|
||||||
DBG (DBG_info, "%s: used_pixels=%d\n", __FUNCTION__, used_pixels);
|
DBG (DBG_info, "%s: used_pixels=%d\n", __FUNCTION__, used_pixels);
|
||||||
|
|
||||||
|
@ -1560,12 +1551,10 @@ gl124_init_scan_regs (Genesys_Device * dev,
|
||||||
scan_step_type = gl124_compute_step_type(dev, exposure_time);
|
scan_step_type = gl124_compute_step_type(dev, exposure_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG (DBG_info, "gl124_init_scan_regs : exposure_time=%d pixels\n",
|
DBG (DBG_info, "gl124_init_scan_regs : exposure_time=%d pixels\n", exposure_time);
|
||||||
exposure_time);
|
DBG (DBG_info, "gl124_init_scan_regs : scan_step_type=%d\n", scan_step_type);
|
||||||
DBG (DBG_info, "gl124_init_scan_regs : scan_step_type=%d\n",
|
|
||||||
scan_step_type);
|
|
||||||
|
|
||||||
/*** optical parameters ***/
|
/*** optical parameters ***/
|
||||||
/* in case of dynamic lineart, we use an internal 8 bit gray scan
|
/* in case of dynamic lineart, we use an internal 8 bit gray scan
|
||||||
* to generate 1 lineart data */
|
* to generate 1 lineart data */
|
||||||
if ((flags & SCAN_FLAG_DYNAMIC_LINEART)
|
if ((flags & SCAN_FLAG_DYNAMIC_LINEART)
|
||||||
|
@ -1596,14 +1585,15 @@ gl124_init_scan_regs (Genesys_Device * dev,
|
||||||
used_pixels,
|
used_pixels,
|
||||||
channels,
|
channels,
|
||||||
depth,
|
depth,
|
||||||
half_ccd, color_filter, oflags);
|
half_ccd,
|
||||||
|
color_filter,
|
||||||
|
oflags);
|
||||||
if (status != SANE_STATUS_GOOD)
|
if (status != SANE_STATUS_GOOD)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
/*** motor parameters ***/
|
/*** motor parameters ***/
|
||||||
|
|
||||||
/* max_shift */
|
/* max_shift */
|
||||||
/* scanned area must be enlarged by max color shift needed */
|
/* scanned area must be enlarged by max color shift needed */
|
||||||
/* all values are assumed >= 0 */
|
/* all values are assumed >= 0 */
|
||||||
if (channels > 1 && !(flags & SCAN_FLAG_IGNORE_LINE_DISTANCE))
|
if (channels > 1 && !(flags & SCAN_FLAG_IGNORE_LINE_DISTANCE))
|
||||||
|
@ -2539,24 +2529,25 @@ gl124_init_regs_for_coarse_calibration (Genesys_Device * dev)
|
||||||
|
|
||||||
|
|
||||||
/* init registers for shading calibration */
|
/* init registers for shading calibration */
|
||||||
|
/* shading calibration is done at dpihw */
|
||||||
static SANE_Status
|
static SANE_Status
|
||||||
gl124_init_regs_for_shading (Genesys_Device * dev)
|
gl124_init_regs_for_shading (Genesys_Device * dev)
|
||||||
{
|
{
|
||||||
SANE_Status status;
|
SANE_Status status;
|
||||||
int move,resolution;
|
int move, resolution, dpihw, factor;
|
||||||
Genesys_Register_Set *r;
|
Genesys_Register_Set *r;
|
||||||
|
|
||||||
DBGSTART;
|
DBGSTART;
|
||||||
|
|
||||||
/* initial calibration reg values */
|
/* initial calibration reg values */
|
||||||
memcpy (dev->calib_reg, dev->reg,
|
memcpy (dev->calib_reg, dev->reg, GENESYS_GL124_MAX_REGS * sizeof (Genesys_Register_Set));
|
||||||
GENESYS_GL124_MAX_REGS * sizeof (Genesys_Register_Set));
|
|
||||||
|
|
||||||
dev->calib_channels = 3;
|
dev->calib_channels = 3;
|
||||||
resolution=sanei_genesys_compute_dpihw(dev,dev->settings.xres);
|
|
||||||
dev->calib_lines = dev->model->shading_lines;
|
dev->calib_lines = dev->model->shading_lines;
|
||||||
dev->calib_pixels = (dev->sensor.sensor_pixels*resolution)/dev->sensor.optical_res;
|
dpihw=sanei_genesys_compute_dpihw(dev,dev->settings.xres);
|
||||||
|
factor=dev->sensor.optical_res/dpihw;
|
||||||
dev->calib_resolution = resolution;
|
dev->calib_resolution = resolution;
|
||||||
|
dev->calib_pixels = dev->sensor.sensor_pixels/factor;
|
||||||
|
|
||||||
/* distance to move to reach white target at high resolution */
|
/* distance to move to reach white target at high resolution */
|
||||||
move=0;
|
move=0;
|
||||||
|
@ -2578,13 +2569,12 @@ gl124_init_regs_for_shading (Genesys_Device * dev)
|
||||||
16,
|
16,
|
||||||
dev->calib_channels,
|
dev->calib_channels,
|
||||||
0,
|
0,
|
||||||
0);
|
SCAN_FLAG_DISABLE_SHADING |
|
||||||
r = sanei_genesys_get_address (dev->calib_reg, REG01);
|
SCAN_FLAG_DISABLE_GAMMA |
|
||||||
r->value &= ~REG01_DVDSET;
|
SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE |
|
||||||
|
SCAN_FLAG_IGNORE_LINE_DISTANCE);
|
||||||
r = sanei_genesys_get_address (dev->calib_reg, REG02);
|
r = sanei_genesys_get_address (dev->calib_reg, REG02);
|
||||||
r->value &= ~REG02_MTRPWR;
|
r->value &= ~REG02_MTRPWR;
|
||||||
r = sanei_genesys_get_address (dev->calib_reg, REG05);
|
|
||||||
r->value &= ~REG05_GMMENB;
|
|
||||||
|
|
||||||
if (status != SANE_STATUS_GOOD)
|
if (status != SANE_STATUS_GOOD)
|
||||||
{
|
{
|
||||||
|
@ -2595,8 +2585,7 @@ gl124_init_regs_for_shading (Genesys_Device * dev)
|
||||||
|
|
||||||
dev->scanhead_position_in_steps += dev->calib_lines + move;
|
dev->scanhead_position_in_steps += dev->calib_lines + move;
|
||||||
|
|
||||||
status =
|
status = gl124_bulk_write_register (dev, dev->calib_reg, GENESYS_GL124_MAX_REGS);
|
||||||
gl124_bulk_write_register (dev, dev->calib_reg, GENESYS_GL124_MAX_REGS);
|
|
||||||
if (status != SANE_STATUS_GOOD)
|
if (status != SANE_STATUS_GOOD)
|
||||||
{
|
{
|
||||||
DBG (DBG_error,
|
DBG (DBG_error,
|
||||||
|
@ -3410,7 +3399,7 @@ gl124_coarse_gain_calibration (Genesys_Device * dev, int dpi)
|
||||||
}
|
}
|
||||||
lines=10;
|
lines=10;
|
||||||
bpp=8;
|
bpp=8;
|
||||||
pixels = (dev->sensor.sensor_pixels * resolution) / dev->sensor.optical_res,
|
pixels = (dev->sensor.sensor_pixels * resolution) / dev->sensor.optical_res;
|
||||||
|
|
||||||
status = gl124_init_scan_regs (dev,
|
status = gl124_init_scan_regs (dev,
|
||||||
dev->calib_reg,
|
dev->calib_reg,
|
||||||
|
|
Ładowanie…
Reference in New Issue