move ld_shift_* values from motor to device session level

merge-requests/1/head
Stphane Voltz 2011-09-22 06:17:02 +02:00
rodzic c7e0cbd84c
commit 6490c9635f
8 zmienionych plików z 79 dodań i 155 usunięć

Wyświetl plik

@ -210,6 +210,7 @@ sanei_genesys_init_structs (Genesys_Device * dev)
}
}
/* sanity check */
if (sensor_ok == 0 || motor_ok == 0 || gpo_ok == 0)
{
DBG (DBG_error0,
@ -217,6 +218,11 @@ sanei_genesys_init_structs (Genesys_Device * dev)
dev->model->ccd_type, dev->model->gpo_type,
dev->model->motor_type);
}
/* set up initial line distance shift */
dev->ld_shift_r = dev->model->ld_shift_r;
dev->ld_shift_g = dev->model->ld_shift_g;
dev->ld_shift_b = dev->model->ld_shift_b;
}
void
@ -5131,13 +5137,13 @@ genesys_read_ordered_data (Genesys_Device * dev, SANE_Byte * destination,
else
{
ccd_shift[0] =
((dev->model->ld_shift_r * dev->settings.yres) /
((dev->ld_shift_r * dev->settings.yres) /
dev->motor.base_ydpi);
ccd_shift[1] =
((dev->model->ld_shift_g * dev->settings.yres) /
((dev->ld_shift_g * dev->settings.yres) /
dev->motor.base_ydpi);
ccd_shift[2] =
((dev->model->ld_shift_b * dev->settings.yres) /
((dev->ld_shift_b * dev->settings.yres) /
dev->motor.base_ydpi);
ccd_shift[3] = ccd_shift[0] + dev->current_setup.stagger;

Wyświetl plik

@ -1593,21 +1593,7 @@ gl124_init_scan_regs (Genesys_Device * dev,
/*** motor parameters ***/
/* max_shift */
/* scanned area must be enlarged by max color shift needed */
/* all values are assumed >= 0 */
if (channels > 1 && !(flags & SCAN_FLAG_IGNORE_LINE_DISTANCE))
{
max_shift = dev->model->ld_shift_r;
if (dev->model->ld_shift_b > max_shift)
max_shift = dev->model->ld_shift_b;
if (dev->model->ld_shift_g > max_shift)
max_shift = dev->model->ld_shift_g;
max_shift = (max_shift * yres) / dev->motor.base_ydpi;
}
else
{
max_shift = 0;
}
max_shift=sanei_genesys_compute_max_shift(dev,channels,yres,flags);
/* lines to scan */
lincnt = lines + max_shift + stagger;
@ -1829,22 +1815,8 @@ gl124_calculate_current_setup (Genesys_Device * dev)
scan_step_type = gl124_compute_step_type(dev, exposure_time);
DBG (DBG_info, "%s : exposure_time=%d pixels\n", __FUNCTION__, exposure_time);
/* max_shift */
/* scanned area must be enlarged by max color shift needed */
/* all values are assumed >= 0 */
if (channels > 1)
{
max_shift = dev->model->ld_shift_r;
if (dev->model->ld_shift_b > max_shift)
max_shift = dev->model->ld_shift_b;
if (dev->model->ld_shift_g > max_shift)
max_shift = dev->model->ld_shift_g;
max_shift = (max_shift * yres) / dev->motor.base_ydpi;
}
else
{
max_shift = 0;
}
/* max_shift */
max_shift=sanei_genesys_compute_max_shift(dev,channels,yres,0);
dpihw=sanei_genesys_compute_dpihw(dev,used_res);
sensor=get_sensor_profile(dev->model->ccd_type, dpihw);
@ -2470,7 +2442,6 @@ gl124_init_regs_for_coarse_calibration (Genesys_Device * dev)
SANE_Status status;
uint8_t channels;
uint8_t cksel;
Genesys_Register_Set *r;
DBGSTART;
cksel = (dev->calib_reg[reg_0x18].value & REG18_CKSEL) + 1; /* clock speed = 1..4 clocks */
@ -2531,7 +2502,6 @@ gl124_init_regs_for_shading (Genesys_Device * dev)
{
SANE_Status status;
int move, resolution, dpihw, factor;
Genesys_Register_Set *r;
DBGSTART;
@ -2967,7 +2937,6 @@ gl124_led_calibration (Genesys_Device * dev)
char fn[20];
uint32_t expr, expg, expb;
Sensor_Profile *sensor;
Genesys_Register_Set *r;
SANE_Bool acceptable = SANE_FALSE;
@ -3188,7 +3157,6 @@ dark_average (uint8_t * data, unsigned int pixels, unsigned int lines,
static SANE_Status
gl124_offset_calibration (Genesys_Device * dev)
{
Genesys_Register_Set *r;
SANE_Status status = SANE_STATUS_GOOD;
uint8_t *first_line, *second_line, reg0a;
unsigned int channels, bpp;
@ -3365,7 +3333,6 @@ gl124_coarse_gain_calibration (Genesys_Device * dev, int dpi)
float gain[3],coeff;
int val, code, lines;
int resolution;
Genesys_Register_Set *r;
int bpp;
DBG (DBG_proc, "gl124_coarse_gain_calibration: dpi = %d\n", dpi);
@ -3518,7 +3485,6 @@ gl124_init_regs_for_warmup (Genesys_Device * dev,
{
int num_pixels;
SANE_Status status = SANE_STATUS_GOOD;
Genesys_Register_Set *r;
DBGSTART;
if (dev == NULL || reg == NULL || channels == NULL || total_size == NULL)

Wyświetl plik

@ -1027,22 +1027,7 @@ gl646_setup_registers (Genesys_Device * dev,
linecnt = (linecnt * motor->ydpi) / scan_settings.yres;
/* scanned area height must be enlarged by max color shift needed */
/* all values are assumed >= 0 */
if (channels > 1)
{
max_shift = dev->model->ld_shift_r;
if (dev->model->ld_shift_b > max_shift)
max_shift = dev->model->ld_shift_b;
if (dev->model->ld_shift_g > max_shift)
max_shift = dev->model->ld_shift_g;
max_shift = (max_shift * scan_settings.yres) / dev->motor.base_ydpi;
linecnt += max_shift;
}
else
{
max_shift = 0;
}
max_shift=sanei_genesys_compute_max_shift(dev,channels,scan_settings.yres,0);
/* at QUATER_STEP lines are 'staggered' and need correction */
stagger = 0;

Wyświetl plik

@ -2793,25 +2793,10 @@ dummy \ scanned lines
/*** motor parameters ***/
/* max_shift */
/* scanned area must be enlarged by max color shift needed */
/* all values are assumed >= 0 */
if (channels > 1 && !(flags & SCAN_FLAG_IGNORE_LINE_DISTANCE))
{
max_shift = dev->model->ld_shift_r;
if (dev->model->ld_shift_b > max_shift)
max_shift = dev->model->ld_shift_b;
if (dev->model->ld_shift_g > max_shift)
max_shift = dev->model->ld_shift_g;
max_shift =
(max_shift * yres) / dev->motor.base_ydpi;
}
else
{
max_shift = 0;
}
max_shift=sanei_genesys_compute_max_shift(dev,channels,yres,flags);
/* lincnt */
/* lincnt */
lincnt = lines + max_shift + stagger;
/* move */
@ -3171,25 +3156,10 @@ dummy \ scanned lines
DBG (DBG_info, "gl841_calculate_current_setup : exposure_time=%d pixels\n",
exposure_time);
/* max_shift */
/* scanned area must be enlarged by max color shift needed */
/* all values are assumed >= 0 */
if (channels > 1)
{
max_shift = dev->model->ld_shift_r;
if (dev->model->ld_shift_b > max_shift)
max_shift = dev->model->ld_shift_b;
if (dev->model->ld_shift_g > max_shift)
max_shift = dev->model->ld_shift_g;
max_shift =
(max_shift * yres) / dev->motor.base_ydpi;
}
else
{
max_shift = 0;
}
max_shift=sanei_genesys_compute_max_shift(dev,channels,yres,0);
/* lincnt */
/* lincnt */
lincnt = lines + max_shift + stagger;
dev->current_setup.pixels = (used_pixels * used_res)/optical_res;

Wyświetl plik

@ -1476,20 +1476,7 @@ gl843_init_scan_regs (Genesys_Device * dev,
/* max_shift */
/* scanned area must be enlarged by max color shift needed */
/* all values are assumed >= 0 */
if (channels > 1 && !(flags & SCAN_FLAG_IGNORE_LINE_DISTANCE))
{
max_shift = dev->model->ld_shift_r;
if (dev->model->ld_shift_b > max_shift)
max_shift = dev->model->ld_shift_b;
if (dev->model->ld_shift_g > max_shift)
max_shift = dev->model->ld_shift_g;
max_shift = (max_shift * yres) / dev->motor.base_ydpi;
}
else
{
max_shift = 0;
}
max_shift=sanei_genesys_compute_max_shift(dev,channels,yres,flags);
/* lines to scan */
lincnt = lines + max_shift + stagger;
@ -1713,22 +1700,8 @@ gl843_calculate_current_setup (Genesys_Device * dev)
scan_step_type = sanei_genesys_compute_step_type(gl843_motors, dev->model->motor_type, exposure);
DBG (DBG_info, "%s : exposure=%d pixels\n", __FUNCTION__, exposure);
/* max_shift */
/* scanned area must be enlarged by max color shift needed */
/* all values are assumed >= 0 */
if (channels > 1)
{
max_shift = dev->model->ld_shift_r;
if (dev->model->ld_shift_b > max_shift)
max_shift = dev->model->ld_shift_b;
if (dev->model->ld_shift_g > max_shift)
max_shift = dev->model->ld_shift_g;
max_shift = (max_shift * yres) / dev->motor.base_ydpi;
}
else
{
max_shift = 0;
}
max_shift=sanei_genesys_compute_max_shift(dev,channels,yres,0);
/* lincnt */
lincnt = lines + max_shift + stagger;

Wyświetl plik

@ -1520,24 +1520,10 @@ gl847_init_scan_regs (Genesys_Device * dev,
/*** motor parameters ***/
/* max_shift */
/* scanned area must be enlarged by max color shift needed */
/* all values are assumed >= 0 */
if (channels > 1 && !(flags & SCAN_FLAG_IGNORE_LINE_DISTANCE))
{
max_shift = dev->model->ld_shift_r;
if (dev->model->ld_shift_b > max_shift)
max_shift = dev->model->ld_shift_b;
if (dev->model->ld_shift_g > max_shift)
max_shift = dev->model->ld_shift_g;
max_shift = (max_shift * yres) / dev->motor.base_ydpi;
}
else
{
max_shift = 0;
}
/* max_shift */
max_shift=sanei_genesys_compute_max_shift(dev,channels,yres,flags);
/* lincnt */
/* lincnt */
lincnt = lines + max_shift + stagger;
/* add tl_y to base movement */
@ -1769,24 +1755,10 @@ gl847_calculate_current_setup (Genesys_Device * dev)
scan_step_type = sanei_genesys_compute_step_type(gl847_motors, dev->model->motor_type, exposure_time);
DBG (DBG_info, "%s : exposure_time=%d pixels\n", __FUNCTION__, exposure_time);
/* max_shift */
/* scanned area must be enlarged by max color shift needed */
/* all values are assumed >= 0 */
if (channels > 1)
{
max_shift = dev->model->ld_shift_r;
if (dev->model->ld_shift_b > max_shift)
max_shift = dev->model->ld_shift_b;
if (dev->model->ld_shift_g > max_shift)
max_shift = dev->model->ld_shift_g;
max_shift = (max_shift * yres) / dev->motor.base_ydpi;
}
else
{
max_shift = 0;
}
/* max_shift */
max_shift=sanei_genesys_compute_max_shift(dev,channels,yres,0);
/* lincnt */
/* lincnt */
lincnt = lines + max_shift + stagger;
dev->current_setup.pixels = (used_pixels * used_res) / optical_res;
@ -2512,7 +2484,6 @@ gl847_init_regs_for_scan (Genesys_Device * dev)
float move;
int move_dpi;
float start;
uint8_t val;
SANE_Status status;
@ -2848,7 +2819,6 @@ gl847_led_calibration (Genesys_Device * dev)
char fn[20];
uint16_t expr, expg, expb;
Sensor_Profile *sensor;
Genesys_Register_Set *r;
SANE_Bool acceptable = SANE_FALSE;

Wyświetl plik

@ -1462,4 +1462,38 @@ sanei_genesys_is_compatible_calibration (Genesys_Device * dev,
}
/** @brief compute maximum line distance shift
* compute maximum line distance shift for the motor and sensor
* combination. Line distance shift is the distance between different
* color component of CCD sensors. Since these components aren't at
* the same physical place, they scan diffrent lines. Software must
* take this into account to accurately mix color data.
* @param dev device session to compute max_shift for
* @param channels number of color channels for the scan
* @param yres motor resolution used for the scan
* @param flags scan flags
* @return 0 or line distance shift
*/
int sanei_genesys_compute_max_shift(Genesys_Device *dev,
int channels,
int yres,
int flags)
{
int max_shift;
max_shift=0;
if (channels > 1 && !(flags & SCAN_FLAG_IGNORE_LINE_DISTANCE))
{
max_shift = dev->ld_shift_r;
if (dev->ld_shift_b > max_shift)
max_shift = dev->ld_shift_b;
if (dev->ld_shift_g > max_shift)
max_shift = dev->ld_shift_g;
max_shift = (max_shift * yres) / dev->motor.base_ydpi;
}
return max_shift;
}
/* vim: set sw=2 cino=>2se-1sn-1s{s^-1st0(0u0 smarttab expandtab: */

Wyświetl plik

@ -670,6 +670,9 @@ struct Genesys_Device
struct Genesys_Device *next;
SANE_Int ld_shift_r; /**> used red line-distance shift*/
SANE_Int ld_shift_g; /**> used green line-distance shift*/
SANE_Int ld_shift_b; /**> used blue line-distance shift*/
int segnb; /**> number of segments composing the sensor */
int line_interp; /**> number of lines used in line interpolation */
int line_count; /**> number of scan lines used during scan */
@ -952,6 +955,23 @@ sanei_genesys_is_compatible_calibration (Genesys_Device * dev,
Genesys_Calibration_Cache * cache,
int for_overwrite);
/** @brief compute maximum line distance shift
* compute maximum line distance shift for the motor and sensor
* combination. Line distance shift is the distance between different
* color component of CCD sensors. Since these components aren't at
* the same physical place, they scan diffrent lines. Software must
* take this into account to accurately mix color data.
* @param dev device session to compute max_shift for
* @param channels number of color channels for the scan
* @param yres motor resolution used for the scan
* @param flags scan flags
* @return 0 or line distance shift
*/
int sanei_genesys_compute_max_shift(Genesys_Device *dev,
int channels,
int yres,
int flags);
/*---------------------------------------------------------------------------*/
/* ASIC specific functions declarations */
/*---------------------------------------------------------------------------*/