kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Don't use dev->calib_reg directly when possible
rodzic
c09370eab4
commit
723426d78b
|
@ -3177,7 +3177,7 @@ genesys_flatbed_calibration(Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
/* do offset calibration if needed */
|
||||
if (dev->model->flags & GENESYS_FLAG_OFFSET_CALIBRATION)
|
||||
{
|
||||
status = dev->model->cmd_set->offset_calibration (dev, sensor);
|
||||
status = dev->model->cmd_set->offset_calibration(dev, sensor, dev->calib_reg);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: offset calibration failed: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -3185,7 +3185,7 @@ genesys_flatbed_calibration(Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
}
|
||||
|
||||
/* since all the registers are set up correctly, just use them */
|
||||
status = dev->model->cmd_set->coarse_gain_calibration(dev, sensor, yres);
|
||||
status = dev->model->cmd_set->coarse_gain_calibration(dev, sensor, dev->calib_reg, yres);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: coarse gain calibration: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -3197,7 +3197,7 @@ genesys_flatbed_calibration(Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
/* since we have 2 gain calibration proc, skip second if first one was
|
||||
used. */
|
||||
{
|
||||
status = dev->model->cmd_set->init_regs_for_coarse_calibration(dev, sensor);
|
||||
status = dev->model->cmd_set->init_regs_for_coarse_calibration(dev, sensor, dev->calib_reg);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to send calibration registers: %s\n", __func__,
|
||||
|
@ -3218,7 +3218,7 @@ genesys_flatbed_calibration(Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
if (dev->model->is_cis)
|
||||
{
|
||||
/* the afe now sends valid data for doing led calibration */
|
||||
status = dev->model->cmd_set->led_calibration(dev, sensor);
|
||||
status = dev->model->cmd_set->led_calibration(dev, sensor, dev->calib_reg);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: led calibration failed: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -3228,7 +3228,7 @@ genesys_flatbed_calibration(Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
/* calibrate afe again to match new exposure */
|
||||
if (dev->model->flags & GENESYS_FLAG_OFFSET_CALIBRATION)
|
||||
{
|
||||
status = dev->model->cmd_set->offset_calibration (dev, sensor);
|
||||
status = dev->model->cmd_set->offset_calibration(dev, sensor, dev->calib_reg);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: offset calibration failed: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -3237,7 +3237,7 @@ genesys_flatbed_calibration(Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
|
||||
/* since all the registers are set up correctly, just use them */
|
||||
|
||||
status = dev->model->cmd_set->coarse_gain_calibration (dev, sensor, yres);
|
||||
status = dev->model->cmd_set->coarse_gain_calibration(dev, sensor, dev->calib_reg, yres);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: coarse gain calibration: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -3248,8 +3248,8 @@ genesys_flatbed_calibration(Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
/* since we have 2 gain calibration proc, skip second if first one was
|
||||
used. */
|
||||
{
|
||||
status =
|
||||
dev->model->cmd_set->init_regs_for_coarse_calibration(dev, sensor);
|
||||
status = dev->model->cmd_set->init_regs_for_coarse_calibration(dev, sensor,
|
||||
dev->calib_reg);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to send calibration registers: %s\n", __func__,
|
||||
|
@ -3286,7 +3286,7 @@ genesys_flatbed_calibration(Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
}
|
||||
|
||||
/* shading calibration */
|
||||
status = dev->model->cmd_set->init_regs_for_shading(dev, sensor);
|
||||
status = dev->model->cmd_set->init_regs_for_shading(dev, sensor, dev->calib_reg);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to send shading registers: %s\n", __func__,
|
||||
|
@ -3398,7 +3398,7 @@ static SANE_Status genesys_sheetfed_calibration(Genesys_Device * dev, Genesys_Se
|
|||
|
||||
if (dev->model->is_cis)
|
||||
{
|
||||
status = dev->model->cmd_set->led_calibration(dev, sensor);
|
||||
status = dev->model->cmd_set->led_calibration(dev, sensor, dev->calib_reg);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: led calibration failed: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -3409,7 +3409,7 @@ static SANE_Status genesys_sheetfed_calibration(Genesys_Device * dev, Genesys_Se
|
|||
/* calibrate afe */
|
||||
if (dev->model->flags & GENESYS_FLAG_OFFSET_CALIBRATION)
|
||||
{
|
||||
status = dev->model->cmd_set->offset_calibration (dev, sensor);
|
||||
status = dev->model->cmd_set->offset_calibration(dev, sensor, dev->calib_reg);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: offset calibration failed: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -3418,7 +3418,7 @@ static SANE_Status genesys_sheetfed_calibration(Genesys_Device * dev, Genesys_Se
|
|||
|
||||
/* since all the registers are set up correctly, just use them */
|
||||
|
||||
status = dev->model->cmd_set->coarse_gain_calibration (dev, sensor, xres);
|
||||
status = dev->model->cmd_set->coarse_gain_calibration(dev, sensor, dev->calib_reg, xres);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: coarse gain calibration: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -3429,8 +3429,7 @@ static SANE_Status genesys_sheetfed_calibration(Genesys_Device * dev, Genesys_Se
|
|||
/* since we have 2 gain calibration proc, skip second if first one was
|
||||
used. */
|
||||
{
|
||||
status =
|
||||
dev->model->cmd_set->init_regs_for_coarse_calibration(dev, sensor);
|
||||
status = dev->model->cmd_set->init_regs_for_coarse_calibration(dev, sensor, dev->calib_reg);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to send calibration registers: %s\n", __func__,
|
||||
|
@ -3459,7 +3458,7 @@ static SANE_Status genesys_sheetfed_calibration(Genesys_Device * dev, Genesys_Se
|
|||
return status;
|
||||
}
|
||||
|
||||
status = dev->model->cmd_set->init_regs_for_shading(dev, sensor);
|
||||
status = dev->model->cmd_set->init_regs_for_shading(dev, sensor, dev->calib_reg);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to do set up registers for shading calibration: %s\n",
|
||||
|
@ -3487,7 +3486,7 @@ static SANE_Status genesys_sheetfed_calibration(Genesys_Device * dev, Genesys_Se
|
|||
return status;
|
||||
}
|
||||
|
||||
status = dev->model->cmd_set->init_regs_for_shading(dev, sensor);
|
||||
status = dev->model->cmd_set->init_regs_for_shading(dev, sensor, dev->calib_reg);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to do set up registers for shading calibration: %s\n", __func__,
|
||||
|
|
|
@ -2335,14 +2335,15 @@ gl124_search_start_position (Genesys_Device * dev)
|
|||
* sets up register for coarse gain calibration
|
||||
* todo: check it for scanners using it */
|
||||
static SANE_Status
|
||||
gl124_init_regs_for_coarse_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||
gl124_init_regs_for_coarse_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs)
|
||||
{
|
||||
SANE_Status status;
|
||||
uint8_t channels;
|
||||
uint8_t cksel;
|
||||
|
||||
DBGSTART;
|
||||
cksel = (dev->calib_reg.find_reg(0x18).value & REG18_CKSEL) + 1; /* clock speed = 1..4 clocks */
|
||||
cksel = (regs.find_reg(0x18).value & REG18_CKSEL) + 1; /* clock speed = 1..4 clocks */
|
||||
|
||||
/* set line size */
|
||||
if (dev->settings.scan_mode == SCAN_MODE_COLOR) /* single pass color */
|
||||
|
@ -2351,7 +2352,7 @@ gl124_init_regs_for_coarse_calibration (Genesys_Device * dev, const Genesys_Sens
|
|||
channels = 1;
|
||||
|
||||
status = gl124_init_scan_regs (dev, sensor,
|
||||
&dev->calib_reg,
|
||||
®s,
|
||||
dev->settings.xres,
|
||||
dev->settings.yres,
|
||||
0,
|
||||
|
@ -2373,12 +2374,12 @@ gl124_init_regs_for_coarse_calibration (Genesys_Device * dev, const Genesys_Sens
|
|||
DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
gl124_set_motor_power(&dev->calib_reg, SANE_FALSE);
|
||||
gl124_set_motor_power(®s, SANE_FALSE);
|
||||
|
||||
DBG(DBG_info, "%s: optical sensor res: %d dpi, actual res: %d\n", __func__,
|
||||
sensor.optical_res / cksel, dev->settings.xres);
|
||||
|
||||
status = dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg);
|
||||
status = dev->model->cmd_set->bulk_write_register(dev, regs);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -2393,7 +2394,8 @@ gl124_init_regs_for_coarse_calibration (Genesys_Device * dev, const Genesys_Sens
|
|||
/* init registers for shading calibration */
|
||||
/* shading calibration is done at dpihw */
|
||||
static SANE_Status
|
||||
gl124_init_regs_for_shading(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||
gl124_init_regs_for_shading(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs)
|
||||
{
|
||||
SANE_Status status;
|
||||
int move, resolution, dpihw, factor;
|
||||
|
@ -2401,7 +2403,7 @@ gl124_init_regs_for_shading(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
DBGSTART;
|
||||
|
||||
/* initial calibration reg values */
|
||||
dev->calib_reg = dev->reg;
|
||||
regs = dev->reg;
|
||||
|
||||
dev->calib_channels = 3;
|
||||
dev->calib_lines = dev->model->shading_lines;
|
||||
|
@ -2432,8 +2434,7 @@ gl124_init_regs_for_shading(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
}
|
||||
DBG (DBG_io, "%s: move=%d steps\n", __func__, move);
|
||||
|
||||
status = gl124_init_scan_regs (dev, sensor,
|
||||
&dev->calib_reg,
|
||||
status = gl124_init_scan_regs (dev, sensor, ®s,
|
||||
resolution,
|
||||
resolution,
|
||||
0,
|
||||
|
@ -2449,7 +2450,7 @@ gl124_init_regs_for_shading(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE);
|
||||
gl124_set_motor_power(&dev->calib_reg, SANE_FALSE);
|
||||
gl124_set_motor_power(®s, SANE_FALSE);
|
||||
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
|
@ -2460,7 +2461,7 @@ gl124_init_regs_for_shading(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
|
||||
dev->scanhead_position_in_steps += dev->calib_lines + move;
|
||||
|
||||
status = dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg);
|
||||
status = dev->model->cmd_set->bulk_write_register(dev, regs);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
|
@ -2742,7 +2743,8 @@ gl124_send_shading_data (Genesys_Device * dev, const Genesys_Sensor& sensor,
|
|||
* @return SANE_STATUS_GOOD on success, else the error code
|
||||
*/
|
||||
static SANE_Status
|
||||
move_to_calibration_area (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||
move_to_calibration_area (Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs)
|
||||
{
|
||||
int pixels;
|
||||
int size;
|
||||
|
@ -2753,11 +2755,11 @@ move_to_calibration_area (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
pixels = (sensor.sensor_pixels*600)/sensor.optical_res;
|
||||
|
||||
/* initial calibration reg values */
|
||||
dev->calib_reg = dev->reg;
|
||||
regs = dev->reg;
|
||||
|
||||
/* set up for the calibration scan */
|
||||
status = gl124_init_scan_regs (dev, sensor,
|
||||
&dev->calib_reg,
|
||||
®s,
|
||||
600,
|
||||
600,
|
||||
0,
|
||||
|
@ -2783,10 +2785,10 @@ move_to_calibration_area (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
std::vector<uint8_t> line(size);
|
||||
|
||||
/* write registers and scan data */
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, regs));
|
||||
|
||||
DBG (DBG_info, "%s: starting line reading\n", __func__);
|
||||
RIE(gl124_begin_scan (dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl124_begin_scan (dev, sensor, ®s, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner(dev, line.data(), size));
|
||||
|
||||
/* stop scanning */
|
||||
|
@ -2807,7 +2809,7 @@ move_to_calibration_area (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
-needs working coarse/gain
|
||||
*/
|
||||
static SANE_Status
|
||||
gl124_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
||||
gl124_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor, Genesys_Register_Set& regs)
|
||||
{
|
||||
int num_pixels;
|
||||
int total_size;
|
||||
|
@ -2826,7 +2828,7 @@ gl124_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
DBGSTART;
|
||||
|
||||
/* move to calibration area */
|
||||
move_to_calibration_area(dev, sensor);
|
||||
move_to_calibration_area(dev, sensor, regs);
|
||||
|
||||
/* offset calibration is always done in 16 bit depth color mode */
|
||||
channels = 3;
|
||||
|
@ -2845,11 +2847,11 @@ gl124_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
num_pixels = (sensor.sensor_pixels*resolution)/sensor.optical_res;
|
||||
|
||||
/* initial calibration reg values */
|
||||
dev->calib_reg = dev->reg;
|
||||
regs = dev->reg;
|
||||
|
||||
/* set up for the calibration scan */
|
||||
status = gl124_init_scan_regs (dev, sensor,
|
||||
&dev->calib_reg,
|
||||
®s,
|
||||
resolution,
|
||||
resolution,
|
||||
0,
|
||||
|
@ -2883,19 +2885,19 @@ gl124_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
turn = 0;
|
||||
|
||||
/* no move during led calibration */
|
||||
gl124_set_motor_power (&dev->calib_reg, SANE_FALSE);
|
||||
gl124_set_motor_power (®s, SANE_FALSE);
|
||||
do
|
||||
{
|
||||
/* set up exposure */
|
||||
sanei_genesys_set_triple(&dev->calib_reg,REG_EXPR,exp[0]);
|
||||
sanei_genesys_set_triple(&dev->calib_reg,REG_EXPG,exp[1]);
|
||||
sanei_genesys_set_triple(&dev->calib_reg,REG_EXPB,exp[2]);
|
||||
sanei_genesys_set_triple(®s,REG_EXPR,exp[0]);
|
||||
sanei_genesys_set_triple(®s,REG_EXPG,exp[1]);
|
||||
sanei_genesys_set_triple(®s,REG_EXPB,exp[2]);
|
||||
|
||||
/* write registers and scan data */
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, regs));
|
||||
|
||||
DBG(DBG_info, "%s: starting line reading\n", __func__);
|
||||
RIE(gl124_begin_scan (dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl124_begin_scan (dev, sensor, ®s, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner (dev, line.data(), total_size));
|
||||
|
||||
/* stop scanning */
|
||||
|
@ -3001,7 +3003,8 @@ dark_average (uint8_t * data, unsigned int pixels, unsigned int lines,
|
|||
|
||||
|
||||
static SANE_Status
|
||||
gl124_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||
gl124_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs)
|
||||
{
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
uint8_t reg0a;
|
||||
|
@ -3031,7 +3034,7 @@ gl124_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels);
|
||||
|
||||
status = gl124_init_scan_regs (dev, sensor,
|
||||
&dev->calib_reg,
|
||||
®s,
|
||||
resolution,
|
||||
resolution,
|
||||
0,
|
||||
|
@ -3052,7 +3055,7 @@ gl124_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
gl124_set_motor_power (&dev->calib_reg, SANE_FALSE);
|
||||
gl124_set_motor_power (®s, SANE_FALSE);
|
||||
|
||||
/* allocate memory for scans */
|
||||
total_size = pixels * channels * lines * (bpp/8); /* colors * bytes_per_color * scan lines */
|
||||
|
@ -3072,9 +3075,9 @@ gl124_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
dev->frontend.set_offset(2, bottom);
|
||||
|
||||
RIE(gl124_set_fe(dev, sensor, AFE_SET));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, regs));
|
||||
DBG(DBG_info, "%s: starting first line reading\n", __func__);
|
||||
RIE(gl124_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl124_begin_scan(dev, sensor, ®s, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner(dev, first_line.data(), total_size));
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
|
@ -3092,9 +3095,9 @@ gl124_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
dev->frontend.set_offset(1, top);
|
||||
dev->frontend.set_offset(2, top);
|
||||
RIE(gl124_set_fe(dev, sensor, AFE_SET));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, regs));
|
||||
DBG(DBG_info, "%s: starting second line reading\n", __func__);
|
||||
RIE(gl124_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl124_begin_scan(dev, sensor, ®s, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner (dev, second_line.data(), total_size));
|
||||
|
||||
topavg = dark_average(second_line.data(), pixels, lines, channels, black_pixels);
|
||||
|
@ -3112,9 +3115,9 @@ gl124_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
|
||||
/* scan with no move */
|
||||
RIE(gl124_set_fe(dev, sensor, AFE_SET));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, regs));
|
||||
DBG(DBG_info, "%s: starting second line reading\n", __func__);
|
||||
RIE(gl124_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl124_begin_scan(dev, sensor, ®s, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner(dev, second_line.data(), total_size));
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
|
@ -3159,7 +3162,8 @@ gl124_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
be done with shading.
|
||||
*/
|
||||
static SANE_Status
|
||||
gl124_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor, int dpi)
|
||||
gl124_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs, int dpi)
|
||||
{
|
||||
int pixels;
|
||||
int total_size;
|
||||
|
@ -3202,7 +3206,7 @@ gl124_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
pixels = (sensor.sensor_pixels * resolution) / sensor.optical_res;
|
||||
|
||||
status = gl124_init_scan_regs (dev, sensor,
|
||||
&dev->calib_reg,
|
||||
®s,
|
||||
resolution,
|
||||
resolution,
|
||||
0,
|
||||
|
@ -3218,7 +3222,7 @@ gl124_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE);
|
||||
gl124_set_motor_power(&dev->calib_reg, SANE_FALSE);
|
||||
gl124_set_motor_power(®s, SANE_FALSE);
|
||||
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
|
@ -3226,14 +3230,14 @@ gl124_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
return status;
|
||||
}
|
||||
|
||||
RIE (dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
RIE (dev->model->cmd_set->bulk_write_register(dev, regs));
|
||||
|
||||
total_size = pixels * channels * (16/bpp) * lines;
|
||||
|
||||
std::vector<uint8_t> line(total_size);
|
||||
|
||||
RIE(gl124_set_fe(dev, sensor, AFE_SET));
|
||||
RIE(gl124_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl124_begin_scan(dev, sensor, ®s, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner(dev, line.data(), total_size));
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
|
|
|
@ -2696,9 +2696,11 @@ gl646_search_start_position (Genesys_Device * dev)
|
|||
* sets up register for coarse gain calibration
|
||||
*/
|
||||
static SANE_Status
|
||||
gl646_init_regs_for_coarse_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||
gl646_init_regs_for_coarse_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs)
|
||||
{
|
||||
(void) sensor;
|
||||
(void) regs;
|
||||
|
||||
DBG(DBG_proc, "%s\n", __func__);
|
||||
DBG(DBG_proc, "%s: end\n", __func__);
|
||||
|
@ -2722,8 +2724,10 @@ gl646_init_regs_for_coarse_calibration (Genesys_Device * dev, const Genesys_Sens
|
|||
* @return SANE_STATUS_GOOD if success, else error code
|
||||
*/
|
||||
static SANE_Status
|
||||
gl646_init_regs_for_shading (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||
gl646_init_regs_for_shading(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs)
|
||||
{
|
||||
(void) regs;
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
Genesys_Settings settings;
|
||||
/* 1: no half_ccd, 2: use half number of pixels */
|
||||
|
@ -3120,8 +3124,9 @@ gl646_send_gamma_table (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
* currently limited to the XP200
|
||||
*/
|
||||
static SANE_Status
|
||||
gl646_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
||||
gl646_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor, Genesys_Register_Set& regs)
|
||||
{
|
||||
(void) regs;
|
||||
int total_size;
|
||||
unsigned int i, j;
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
|
@ -3430,8 +3435,10 @@ ad_fe_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
* @return SANE_STATUS_GOOD if success, else error code is failure
|
||||
*/
|
||||
static SANE_Status
|
||||
gl646_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||
gl646_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs)
|
||||
{
|
||||
(void) regs;
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
unsigned int channels;
|
||||
int pass = 0, avg;
|
||||
|
@ -3607,8 +3614,10 @@ gl646_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
* Alternative coarse gain calibration
|
||||
*/
|
||||
static SANE_Status
|
||||
ad_fe_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor, int dpi)
|
||||
ad_fe_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs, int dpi)
|
||||
{
|
||||
(void) regs;
|
||||
unsigned int i, channels, val;
|
||||
unsigned int size, count, resolution, pass;
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
|
@ -3713,7 +3722,8 @@ ad_fe_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
* @param dpi resolutnio to calibrate at
|
||||
*/
|
||||
static SANE_Status
|
||||
gl646_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor, int dpi)
|
||||
gl646_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs, int dpi)
|
||||
{
|
||||
unsigned int i, j, k, channels, val, maximum, idx;
|
||||
unsigned int count, resolution, pass;
|
||||
|
@ -3724,7 +3734,7 @@ gl646_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
|
||||
if (dev->model->ccd_type == CIS_XP200)
|
||||
{
|
||||
return ad_fe_coarse_gain_calibration (dev, sensor, sensor.optical_res);
|
||||
return ad_fe_coarse_gain_calibration (dev, sensor, regs, sensor.optical_res);
|
||||
}
|
||||
DBGSTART;
|
||||
|
||||
|
|
|
@ -3732,7 +3732,8 @@ gl841_search_start_position (Genesys_Device * dev)
|
|||
* sets up register for coarse gain calibration
|
||||
* todo: check it for scanners using it */
|
||||
static SANE_Status
|
||||
gl841_init_regs_for_coarse_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||
gl841_init_regs_for_coarse_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs)
|
||||
{
|
||||
SANE_Status status;
|
||||
uint8_t channels;
|
||||
|
@ -3740,7 +3741,7 @@ gl841_init_regs_for_coarse_calibration (Genesys_Device * dev, const Genesys_Sens
|
|||
|
||||
DBGSTART;
|
||||
|
||||
cksel = (dev->calib_reg.find_reg(0x18).value & REG18_CKSEL) + 1; /* clock speed = 1..4 clocks */
|
||||
cksel = (regs.find_reg(0x18).value & REG18_CKSEL) + 1; /* clock speed = 1..4 clocks */
|
||||
|
||||
/* set line size */
|
||||
if (dev->settings.scan_mode == SCAN_MODE_COLOR) /* single pass color */
|
||||
|
@ -3749,7 +3750,7 @@ gl841_init_regs_for_coarse_calibration (Genesys_Device * dev, const Genesys_Sens
|
|||
channels = 1;
|
||||
|
||||
status = gl841_init_scan_regs (dev, sensor,
|
||||
&dev->calib_reg,
|
||||
®s,
|
||||
dev->settings.xres,
|
||||
dev->settings.yres,
|
||||
0,
|
||||
|
@ -3773,7 +3774,7 @@ gl841_init_regs_for_coarse_calibration (Genesys_Device * dev, const Genesys_Sens
|
|||
DBG(DBG_info, "%s: optical sensor res: %d dpi, actual res: %d\n", __func__,
|
||||
sensor.optical_res / cksel, dev->settings.xres);
|
||||
|
||||
status = sanei_genesys_bulk_write_register(dev, dev->calib_reg);
|
||||
status = sanei_genesys_bulk_write_register(dev, regs);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -3782,7 +3783,7 @@ gl841_init_regs_for_coarse_calibration (Genesys_Device * dev, const Genesys_Sens
|
|||
|
||||
|
||||
/* if (DBG_LEVEL >= DBG_info)
|
||||
sanei_gl841_print_registers (dev->calib_reg);*/
|
||||
sanei_gl841_print_registers (regs);*/
|
||||
|
||||
DBGCOMPLETED;
|
||||
return SANE_STATUS_GOOD;
|
||||
|
@ -3791,7 +3792,8 @@ gl841_init_regs_for_coarse_calibration (Genesys_Device * dev, const Genesys_Sens
|
|||
|
||||
/* init registers for shading calibration */
|
||||
static SANE_Status
|
||||
gl841_init_regs_for_shading (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||
gl841_init_regs_for_shading(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs)
|
||||
{
|
||||
SANE_Status status;
|
||||
SANE_Int ydpi;
|
||||
|
@ -3801,7 +3803,7 @@ gl841_init_regs_for_shading (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
DBG(DBG_proc, "%s: lines = %d\n", __func__, (int)(dev->calib_lines));
|
||||
|
||||
/* initial calibration reg values */
|
||||
dev->calib_reg = dev->reg;
|
||||
regs = dev->reg;
|
||||
|
||||
ydpi = dev->motor.base_ydpi;
|
||||
if (dev->model->motor_type == MOTOR_PLUSTEK_3600) /* TODO PLUSTEK_3600: 1200dpi not yet working, produces dark bar */
|
||||
|
@ -3827,7 +3829,7 @@ gl841_init_regs_for_shading (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
dev->calib_channels = 3;
|
||||
dev->calib_lines = dev->model->shading_lines;
|
||||
status = gl841_init_scan_regs (dev, sensor,
|
||||
&dev->calib_reg,
|
||||
®s,
|
||||
dev->settings.xres,
|
||||
ydpi,
|
||||
0,
|
||||
|
@ -3851,7 +3853,7 @@ gl841_init_regs_for_shading (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
dev->calib_pixels = dev->current_setup.pixels;
|
||||
dev->scanhead_position_in_steps += dev->calib_lines + starty;
|
||||
|
||||
status = sanei_genesys_bulk_write_register(dev, dev->calib_reg);
|
||||
status = sanei_genesys_bulk_write_register(dev, regs);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -4030,7 +4032,7 @@ gl841_send_gamma_table(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
-needs working coarse/gain
|
||||
*/
|
||||
static SANE_Status
|
||||
gl841_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
||||
gl841_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor, Genesys_Register_Set& regs)
|
||||
{
|
||||
int num_pixels;
|
||||
int total_size;
|
||||
|
@ -4069,7 +4071,7 @@ gl841_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
channels = 3;
|
||||
|
||||
status = gl841_init_scan_regs (dev, sensor,
|
||||
&dev->calib_reg,
|
||||
®s,
|
||||
dev->settings.xres,
|
||||
dev->settings.yres,
|
||||
0,
|
||||
|
@ -4092,7 +4094,7 @@ gl841_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
return status;
|
||||
}
|
||||
|
||||
RIE(sanei_genesys_bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(sanei_genesys_bulk_write_register(dev, regs));
|
||||
|
||||
num_pixels = dev->current_setup.pixels;
|
||||
|
||||
|
@ -4123,7 +4125,7 @@ gl841_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
sensor.exposure.green = exp[1];
|
||||
sensor.exposure.blue = exp[2];
|
||||
|
||||
sanei_genesys_set_exposure(dev->calib_reg, sensor.exposure);
|
||||
sanei_genesys_set_exposure(regs, sensor.exposure);
|
||||
RIE(sanei_genesys_write_register(dev, 0x10, (sensor.exposure.red >> 8) & 0xff));
|
||||
RIE(sanei_genesys_write_register(dev, 0x11, sensor.exposure.red & 0xff));
|
||||
RIE(sanei_genesys_write_register(dev, 0x12, (sensor.exposure.green >> 8) & 0xff));
|
||||
|
@ -4131,10 +4133,10 @@ gl841_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
RIE(sanei_genesys_write_register(dev, 0x14, (sensor.exposure.blue >> 8) & 0xff));
|
||||
RIE(sanei_genesys_write_register(dev, 0x15, sensor.exposure.blue & 0xff));
|
||||
|
||||
RIE(sanei_genesys_bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(sanei_genesys_bulk_write_register(dev, regs));
|
||||
|
||||
DBG(DBG_info, "%s: starting line reading\n", __func__);
|
||||
RIE(gl841_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl841_begin_scan(dev, sensor, ®s, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner(dev, line.data(), total_size));
|
||||
|
||||
if (DBG_LEVEL >= DBG_data) {
|
||||
|
@ -4250,7 +4252,8 @@ gl841_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
* We scan a line with no gain until average offset reaches the target
|
||||
*/
|
||||
static SANE_Status
|
||||
ad_fe_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||
ad_fe_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs)
|
||||
{
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
int num_pixels;
|
||||
|
@ -4272,7 +4275,7 @@ ad_fe_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
}
|
||||
|
||||
status = gl841_init_scan_regs (dev, sensor,
|
||||
&dev->calib_reg,
|
||||
®s,
|
||||
dev->settings.xres,
|
||||
dev->settings.yres,
|
||||
0,
|
||||
|
@ -4316,9 +4319,9 @@ ad_fe_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
|
||||
/* scan line */
|
||||
DBG(DBG_info, "%s: starting line reading\n", __func__);
|
||||
sanei_genesys_bulk_write_register(dev, dev->calib_reg);
|
||||
sanei_genesys_bulk_write_register(dev, regs);
|
||||
gl841_set_fe(dev, sensor, AFE_SET);
|
||||
gl841_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE);
|
||||
gl841_begin_scan(dev, sensor, ®s, SANE_TRUE);
|
||||
sanei_genesys_read_data_from_scanner(dev, line.data(), total_size);
|
||||
gl841_stop_action (dev);
|
||||
if (DBG_LEVEL >= DBG_data) {
|
||||
|
@ -4369,7 +4372,8 @@ ad_fe_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
this function expects the slider to be where?
|
||||
*/
|
||||
static SANE_Status
|
||||
gl841_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||
gl841_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs)
|
||||
{
|
||||
int num_pixels;
|
||||
int total_size;
|
||||
|
@ -4389,14 +4393,14 @@ gl841_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
/* Analog Device fronted have a different calibration */
|
||||
if ((dev->reg.find_reg(0x04).value & REG04_FESET) == 0x02)
|
||||
{
|
||||
return ad_fe_offset_calibration (dev, sensor);
|
||||
return ad_fe_offset_calibration(dev, sensor, regs);
|
||||
}
|
||||
|
||||
/* offset calibration is always done in color mode */
|
||||
channels = 3;
|
||||
|
||||
status = gl841_init_scan_regs (dev, sensor,
|
||||
&dev->calib_reg,
|
||||
®s,
|
||||
dev->settings.xres,
|
||||
dev->settings.yres,
|
||||
0,
|
||||
|
@ -4459,7 +4463,7 @@ gl841_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
|
||||
do {
|
||||
|
||||
RIE(sanei_genesys_bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(sanei_genesys_bulk_write_register(dev, regs));
|
||||
|
||||
for (j=0; j < channels; j++) {
|
||||
off[j] = (offh[j]+offl[j])/2;
|
||||
|
@ -4475,7 +4479,7 @@ gl841_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
}
|
||||
|
||||
DBG(DBG_info, "%s: starting first line reading\n", __func__);
|
||||
RIE(gl841_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl841_begin_scan(dev, sensor, ®s, SANE_TRUE));
|
||||
|
||||
RIE(sanei_genesys_read_data_from_scanner (dev, first_line.data(), total_size));
|
||||
|
||||
|
@ -4588,8 +4592,8 @@ gl841_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
}
|
||||
|
||||
DBG(DBG_info, "%s: starting second line reading\n", __func__);
|
||||
RIE(sanei_genesys_bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(gl841_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(sanei_genesys_bulk_write_register(dev, regs));
|
||||
RIE(gl841_begin_scan(dev, sensor, ®s, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner (dev, second_line.data(), total_size));
|
||||
|
||||
if (DBG_LEVEL >= DBG_data) {
|
||||
|
@ -4750,7 +4754,8 @@ gl841_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
be done with shading.
|
||||
*/
|
||||
static SANE_Status
|
||||
gl841_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor, int dpi)
|
||||
gl841_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs, int dpi)
|
||||
{
|
||||
int num_pixels;
|
||||
int total_size;
|
||||
|
@ -4782,7 +4787,7 @@ gl841_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
channels = 3;
|
||||
|
||||
status = gl841_init_scan_regs (dev, sensor,
|
||||
&dev->calib_reg,
|
||||
®s,
|
||||
dev->settings.xres,
|
||||
dev->settings.yres,
|
||||
0,
|
||||
|
@ -4805,7 +4810,7 @@ gl841_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
return status;
|
||||
}
|
||||
|
||||
RIE(sanei_genesys_bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(sanei_genesys_bulk_write_register(dev, regs));
|
||||
|
||||
num_pixels = dev->current_setup.pixels;
|
||||
|
||||
|
@ -4813,7 +4818,7 @@ gl841_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
|
||||
std::vector<uint8_t> line(total_size);
|
||||
|
||||
RIE(gl841_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl841_begin_scan(dev, sensor, ®s, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner(dev, line.data(), total_size));
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
|
@ -5141,10 +5146,11 @@ gl841_init (Genesys_Device * dev)
|
|||
}
|
||||
|
||||
/* initial calibration reg values */
|
||||
dev->calib_reg = dev->reg;
|
||||
Genesys_Register_Set& regs = dev->calib_reg;
|
||||
regs = dev->reg;
|
||||
|
||||
status = gl841_init_scan_regs (dev, sensor,
|
||||
&dev->calib_reg,
|
||||
®s,
|
||||
300,
|
||||
300,
|
||||
0,
|
||||
|
@ -5161,14 +5167,14 @@ gl841_init (Genesys_Device * dev)
|
|||
SCAN_FLAG_USE_OPTICAL_RES
|
||||
);
|
||||
|
||||
RIE(sanei_genesys_bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(sanei_genesys_bulk_write_register(dev, regs));
|
||||
|
||||
size = dev->current_setup.pixels * 3 * 2 * 1; /* colors * bytes_per_color * scan lines */
|
||||
|
||||
std::vector<uint8_t> line(size);
|
||||
|
||||
DBG(DBG_info, "%s: starting dummy data reading\n", __func__);
|
||||
RIE(gl841_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl841_begin_scan(dev, sensor, ®s, SANE_TRUE));
|
||||
|
||||
sanei_usb_set_timeout(1000);/* 1 second*/
|
||||
|
||||
|
@ -5177,9 +5183,9 @@ gl841_init (Genesys_Device * dev)
|
|||
|
||||
sanei_usb_set_timeout(30 * 1000);/* 30 seconds*/
|
||||
|
||||
RIE (gl841_end_scan(dev, &dev->calib_reg, SANE_TRUE));
|
||||
RIE (gl841_end_scan(dev, ®s, SANE_TRUE));
|
||||
|
||||
dev->calib_reg = dev->reg;
|
||||
regs = dev->reg;
|
||||
|
||||
/* Set powersaving (default = 15 minutes) */
|
||||
RIE (gl841_set_powersaving (dev, 15));
|
||||
|
|
|
@ -2734,14 +2734,15 @@ gl843_search_start_position (Genesys_Device * dev)
|
|||
* sets up register for coarse gain calibration
|
||||
* todo: check it for scanners using it */
|
||||
static SANE_Status
|
||||
gl843_init_regs_for_coarse_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||
gl843_init_regs_for_coarse_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs)
|
||||
{
|
||||
SANE_Status status;
|
||||
uint8_t channels;
|
||||
uint8_t cksel;
|
||||
|
||||
DBGSTART;
|
||||
cksel = (dev->calib_reg.find_reg(0x18).value & REG18_CKSEL) + 1; /* clock speed = 1..4 clocks */
|
||||
cksel = (regs.find_reg(0x18).value & REG18_CKSEL) + 1; /* clock speed = 1..4 clocks */
|
||||
|
||||
/* set line size */
|
||||
if (dev->settings.scan_mode == SCAN_MODE_COLOR) /* single pass color */
|
||||
|
@ -2772,19 +2773,19 @@ gl843_init_regs_for_coarse_calibration (Genesys_Device * dev, const Genesys_Sens
|
|||
session.params.flags = flags;
|
||||
gl843_compute_session(dev, session, sensor);
|
||||
|
||||
status = gl843_init_scan_regs(dev, sensor, &dev->calib_reg, session);
|
||||
status = gl843_init_scan_regs(dev, sensor, ®s, session);
|
||||
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
gl843_set_motor_power (&dev->calib_reg, SANE_FALSE);
|
||||
gl843_set_motor_power (®s, SANE_FALSE);
|
||||
|
||||
DBG(DBG_info, "%s: optical sensor res: %d dpi, actual res: %d\n", __func__,
|
||||
sensor.optical_res / cksel, dev->settings.xres);
|
||||
|
||||
status = dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg);
|
||||
status = dev->model->cmd_set->bulk_write_register(dev, regs);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -2884,7 +2885,8 @@ static SANE_Status gl843_move_to_ta (Genesys_Device * dev);
|
|||
/* init registers for shading calibration */
|
||||
/* shading calibration is done at dpihw */
|
||||
static SANE_Status
|
||||
gl843_init_regs_for_shading (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||
gl843_init_regs_for_shading(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs)
|
||||
{
|
||||
SANE_Status status;
|
||||
int move, resolution, dpihw, factor;
|
||||
|
@ -2893,7 +2895,7 @@ gl843_init_regs_for_shading (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
DBGSTART;
|
||||
|
||||
/* initial calibration reg values */
|
||||
dev->calib_reg = dev->reg;
|
||||
regs = dev->reg;
|
||||
|
||||
dev->calib_channels = 3;
|
||||
if (dev->settings.scan_method == ScanMethod::TRANSPARENCY)
|
||||
|
@ -2962,7 +2964,7 @@ gl843_init_regs_for_shading (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
session.params.flags = flags;
|
||||
gl843_compute_session(dev, session, calib_sensor);
|
||||
|
||||
status = gl843_init_scan_regs(dev, calib_sensor, &dev->calib_reg, session);
|
||||
status = gl843_init_scan_regs(dev, calib_sensor, ®s, session);
|
||||
|
||||
// the pixel number may be updated to conform to scanner constraints
|
||||
dev->calib_pixels = dev->current_setup.pixels;
|
||||
|
@ -2976,10 +2978,10 @@ gl843_init_regs_for_shading (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
dev->calib_total_bytes_to_read = dev->read_bytes_left;
|
||||
|
||||
dev->scanhead_position_in_steps += dev->calib_lines + move;
|
||||
sanei_genesys_get_double(&dev->calib_reg,REG_STRPIXEL,&strpixel);
|
||||
sanei_genesys_get_double(®s,REG_STRPIXEL,&strpixel);
|
||||
DBG(DBG_info, "%s: STRPIXEL=%d\n", __func__, strpixel);
|
||||
|
||||
status = dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg);
|
||||
status = dev->model->cmd_set->bulk_write_register(dev, regs);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -3143,7 +3145,7 @@ gl843_send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor)
|
|||
-needs working coarse/gain
|
||||
*/
|
||||
static SANE_Status
|
||||
gl843_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
||||
gl843_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor, Genesys_Register_Set& regs)
|
||||
{
|
||||
int num_pixels;
|
||||
int total_size;
|
||||
|
@ -3171,7 +3173,7 @@ gl843_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
(calib_sensor.sensor_pixels * used_res) / calib_sensor.optical_res;
|
||||
|
||||
/* initial calibration reg values */
|
||||
dev->calib_reg = dev->reg;
|
||||
regs = dev->reg;
|
||||
|
||||
ScanSession session;
|
||||
session.params.xres = used_res;
|
||||
|
@ -3190,7 +3192,7 @@ gl843_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl843_compute_session(dev, session, calib_sensor);
|
||||
|
||||
status = gl843_init_scan_regs(dev, calib_sensor, &dev->calib_reg, session);
|
||||
status = gl843_init_scan_regs(dev, calib_sensor, ®s, session);
|
||||
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
|
@ -3198,7 +3200,7 @@ gl843_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
return status;
|
||||
}
|
||||
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, regs));
|
||||
|
||||
total_size = dev->read_bytes_left;
|
||||
|
||||
|
@ -3225,14 +3227,14 @@ gl843_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
calib_sensor.exposure.green = expg;
|
||||
calib_sensor.exposure.blue = expb;
|
||||
|
||||
sanei_genesys_set_exposure(dev->calib_reg, calib_sensor.exposure);
|
||||
sanei_genesys_set_exposure(regs, calib_sensor.exposure);
|
||||
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, regs));
|
||||
|
||||
DBG(DBG_info, "%s: starting first line reading\n", __func__);
|
||||
RIE (gl843_begin_scan(dev, calib_sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE (gl843_begin_scan(dev, calib_sensor, ®s, SANE_TRUE));
|
||||
RIE (sanei_genesys_read_data_from_scanner(dev, line.data(), total_size));
|
||||
RIE(gl843_stop_action_no_move(dev, &dev->calib_reg));
|
||||
RIE(gl843_stop_action_no_move(dev, ®s));
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
|
@ -3362,7 +3364,8 @@ dark_average_channel (uint8_t * data, unsigned int pixels, unsigned int lines,
|
|||
* @param dev device to calibrate
|
||||
*/
|
||||
static SANE_Status
|
||||
gl843_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||
gl843_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs)
|
||||
{
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
unsigned int channels, bpp;
|
||||
|
@ -3432,13 +3435,13 @@ gl843_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
DBG(DBG_io, "%s: resolution =%d\n", __func__, resolution);
|
||||
DBG(DBG_io, "%s: pixels =%d\n", __func__, pixels);
|
||||
DBG(DBG_io, "%s: black_pixels=%d\n", __func__, black_pixels);
|
||||
status = gl843_init_scan_regs(dev, calib_sensor, &dev->calib_reg, session);
|
||||
status = gl843_init_scan_regs(dev, calib_sensor, ®s, session);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
gl843_set_motor_power(&dev->calib_reg, SANE_FALSE);
|
||||
gl843_set_motor_power(®s, SANE_FALSE);
|
||||
|
||||
/* allocate memory for scans */
|
||||
total_size = dev->read_bytes_left;
|
||||
|
@ -3456,11 +3459,11 @@ gl843_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
RIE(gl843_set_fe(dev, calib_sensor, AFE_SET));
|
||||
|
||||
/* scan with obttom AFE settings */
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, regs));
|
||||
DBG(DBG_info, "%s: starting first line reading\n", __func__);
|
||||
RIE(gl843_begin_scan(dev, calib_sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl843_begin_scan(dev, calib_sensor, ®s, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner(dev, first_line.data(), total_size));
|
||||
RIE(gl843_stop_action_no_move(dev, &dev->calib_reg));
|
||||
RIE(gl843_stop_action_no_move(dev, ®s));
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
|
@ -3485,11 +3488,11 @@ gl843_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
RIE(gl843_set_fe(dev, calib_sensor, AFE_SET));
|
||||
|
||||
/* scan with top AFE values */
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, regs));
|
||||
DBG(DBG_info, "%s: starting second line reading\n", __func__);
|
||||
RIE(gl843_begin_scan(dev, calib_sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl843_begin_scan(dev, calib_sensor, ®s, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner(dev, second_line.data(), total_size));
|
||||
RIE(gl843_stop_action_no_move(dev, &dev->calib_reg));
|
||||
RIE(gl843_stop_action_no_move(dev, ®s));
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
|
@ -3521,11 +3524,11 @@ gl843_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
RIE(gl843_set_fe(dev, calib_sensor, AFE_SET));
|
||||
|
||||
/* scan with no move */
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, regs));
|
||||
DBG(DBG_info, "%s: starting second line reading\n", __func__);
|
||||
RIE(gl843_begin_scan(dev, calib_sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl843_begin_scan(dev, calib_sensor, ®s, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner(dev, second_line.data(), total_size));
|
||||
RIE(gl843_stop_action_no_move(dev, &dev->calib_reg));
|
||||
RIE(gl843_stop_action_no_move(dev, ®s));
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
|
@ -3591,7 +3594,8 @@ gl843_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
be done with shading.
|
||||
*/
|
||||
static SANE_Status
|
||||
gl843_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor, int dpi)
|
||||
gl843_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs, int dpi)
|
||||
{
|
||||
int pixels, factor, dpihw;
|
||||
int total_size;
|
||||
|
@ -3659,8 +3663,8 @@ gl843_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
gl843_compute_session(dev, session, calib_sensor);
|
||||
pixels = session.output_pixels;
|
||||
|
||||
status = gl843_init_scan_regs(dev, calib_sensor, &dev->calib_reg, session);
|
||||
gl843_set_motor_power(&dev->calib_reg, SANE_FALSE);
|
||||
status = gl843_init_scan_regs(dev, calib_sensor, ®s, session);
|
||||
gl843_set_motor_power(®s, SANE_FALSE);
|
||||
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
|
@ -3668,16 +3672,16 @@ gl843_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
return status;
|
||||
}
|
||||
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, regs));
|
||||
|
||||
total_size = dev->read_bytes_left;
|
||||
|
||||
std::vector<uint8_t> line(total_size);
|
||||
|
||||
RIE(gl843_set_fe(dev, calib_sensor, AFE_SET));
|
||||
RIE(gl843_begin_scan(dev, calib_sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl843_begin_scan(dev, calib_sensor, ®s, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner (dev, line.data(), total_size));
|
||||
RIE(gl843_stop_action_no_move(dev, &dev->calib_reg));
|
||||
RIE(gl843_stop_action_no_move(dev, ®s));
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
sanei_genesys_write_pnm_file("gl843_coarse.pnm", line.data(), bpp, channels, pixels, lines);
|
||||
|
|
|
@ -1942,7 +1942,8 @@ gl846_search_start_position (Genesys_Device * dev)
|
|||
* sets up register for coarse gain calibration
|
||||
* todo: check it for scanners using it */
|
||||
static SANE_Status
|
||||
gl846_init_regs_for_coarse_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||
gl846_init_regs_for_coarse_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs)
|
||||
{
|
||||
SANE_Status status;
|
||||
uint8_t channels;
|
||||
|
@ -1951,7 +1952,7 @@ gl846_init_regs_for_coarse_calibration (Genesys_Device * dev, const Genesys_Sens
|
|||
DBG(DBG_proc, "%s\n", __func__);
|
||||
|
||||
|
||||
cksel = (dev->calib_reg.find_reg(0x18).value & REG18_CKSEL) + 1; /* clock speed = 1..4 clocks */
|
||||
cksel = (regs.find_reg(0x18).value & REG18_CKSEL) + 1; /* clock speed = 1..4 clocks */
|
||||
|
||||
/* set line size */
|
||||
if (dev->settings.scan_mode == SCAN_MODE_COLOR) /* single pass color */
|
||||
|
@ -1960,7 +1961,7 @@ gl846_init_regs_for_coarse_calibration (Genesys_Device * dev, const Genesys_Sens
|
|||
channels = 1;
|
||||
|
||||
status = gl846_init_scan_regs (dev, sensor,
|
||||
&dev->calib_reg,
|
||||
®s,
|
||||
dev->settings.xres,
|
||||
dev->settings.yres,
|
||||
0,
|
||||
|
@ -1983,7 +1984,7 @@ gl846_init_regs_for_coarse_calibration (Genesys_Device * dev, const Genesys_Sens
|
|||
DBG(DBG_info, "%s: optical sensor res: %d dpi, actual res: %d\n", __func__,
|
||||
sensor.optical_res / cksel, dev->settings.xres);
|
||||
|
||||
status = dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg);
|
||||
status = dev->model->cmd_set->bulk_write_register(dev, regs);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: Failed to bulk write registers: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -2082,7 +2083,8 @@ gl846_feed (Genesys_Device * dev, unsigned int steps)
|
|||
|
||||
/* init registers for shading calibration */
|
||||
static SANE_Status
|
||||
gl846_init_regs_for_shading (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||
gl846_init_regs_for_shading(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs)
|
||||
{
|
||||
SANE_Status status;
|
||||
float move;
|
||||
|
@ -2091,7 +2093,7 @@ gl846_init_regs_for_shading (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
dev->calib_channels = 3;
|
||||
|
||||
/* initial calibration reg values */
|
||||
dev->calib_reg = dev->reg;
|
||||
regs = dev->reg;
|
||||
|
||||
dev->calib_resolution = sanei_genesys_compute_dpihw(dev, sensor, dev->settings.xres);
|
||||
dev->calib_total_bytes_to_read = 0;
|
||||
|
@ -2111,7 +2113,7 @@ gl846_init_regs_for_shading (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
}
|
||||
|
||||
status = gl846_init_scan_regs (dev, sensor,
|
||||
&dev->calib_reg,
|
||||
®s,
|
||||
dev->calib_resolution,
|
||||
dev->calib_resolution,
|
||||
0,
|
||||
|
@ -2132,7 +2134,7 @@ gl846_init_regs_for_shading (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
return status;
|
||||
}
|
||||
|
||||
status = dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg);
|
||||
status = dev->model->cmd_set->bulk_write_register(dev, regs);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -2371,7 +2373,7 @@ gl846_send_shading_data (Genesys_Device * dev, const Genesys_Sensor& sensor,
|
|||
* @param dev device to calibrate
|
||||
*/
|
||||
static SANE_Status
|
||||
gl846_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
||||
gl846_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor, Genesys_Register_Set& regs)
|
||||
{
|
||||
int num_pixels;
|
||||
int total_size;
|
||||
|
@ -2404,11 +2406,11 @@ gl846_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
num_pixels = (sensor.sensor_pixels*used_res)/sensor.optical_res;
|
||||
|
||||
/* initial calibration reg values */
|
||||
dev->calib_reg = dev->reg;
|
||||
regs = dev->reg;
|
||||
|
||||
/* set up for the calibration scan */
|
||||
status = gl846_init_scan_regs (dev, sensor,
|
||||
&dev->calib_reg,
|
||||
®s,
|
||||
used_res,
|
||||
used_res,
|
||||
0,
|
||||
|
@ -2447,19 +2449,19 @@ gl846_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
turn = 0;
|
||||
|
||||
/* no move during led calibration */
|
||||
gl846_set_motor_power (&dev->calib_reg, SANE_FALSE);
|
||||
gl846_set_motor_power (®s, SANE_FALSE);
|
||||
do
|
||||
{
|
||||
/* set up exposure */
|
||||
sanei_genesys_set_double(&dev->calib_reg,REG_EXPR,exp[0]);
|
||||
sanei_genesys_set_double(&dev->calib_reg,REG_EXPG,exp[1]);
|
||||
sanei_genesys_set_double(&dev->calib_reg,REG_EXPB,exp[2]);
|
||||
sanei_genesys_set_double(®s,REG_EXPR,exp[0]);
|
||||
sanei_genesys_set_double(®s,REG_EXPG,exp[1]);
|
||||
sanei_genesys_set_double(®s,REG_EXPB,exp[2]);
|
||||
|
||||
/* write registers and scan data */
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, regs));
|
||||
|
||||
DBG(DBG_info, "%s: starting line reading\n", __func__);
|
||||
RIE(gl846_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl846_begin_scan(dev, sensor, ®s, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner(dev, line.data(), total_size));
|
||||
|
||||
/* stop scanning */
|
||||
|
@ -3040,7 +3042,8 @@ dark_average (uint8_t * data, unsigned int pixels, unsigned int lines,
|
|||
}
|
||||
|
||||
static SANE_Status
|
||||
gl846_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||
gl846_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs)
|
||||
{
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
uint8_t reg04;
|
||||
|
@ -3070,7 +3073,7 @@ gl846_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels);
|
||||
|
||||
status = gl846_init_scan_regs (dev, sensor,
|
||||
&dev->calib_reg,
|
||||
®s,
|
||||
resolution,
|
||||
resolution,
|
||||
0,
|
||||
|
@ -3089,7 +3092,7 @@ gl846_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
gl846_set_motor_power (&dev->calib_reg, SANE_FALSE);
|
||||
gl846_set_motor_power (®s, SANE_FALSE);
|
||||
|
||||
/* allocate memory for scans */
|
||||
total_size = pixels * channels * lines * (bpp/8); /* colors * bytes_per_color * scan lines */
|
||||
|
@ -3109,9 +3112,9 @@ gl846_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
dev->frontend.set_offset(2, bottom);
|
||||
|
||||
RIE(gl846_set_fe(dev, sensor, AFE_SET));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, regs));
|
||||
DBG(DBG_info, "%s: starting first line reading\n", __func__);
|
||||
RIE(gl846_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl846_begin_scan(dev, sensor, ®s, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner (dev, first_line.data(), total_size));
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
|
@ -3129,9 +3132,9 @@ gl846_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
dev->frontend.set_offset(1, top);
|
||||
dev->frontend.set_offset(2, top);
|
||||
RIE(gl846_set_fe(dev, sensor, AFE_SET));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, regs));
|
||||
DBG(DBG_info, "%s: starting second line reading\n", __func__);
|
||||
RIE(gl846_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl846_begin_scan(dev, sensor, ®s, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner (dev, second_line.data(), total_size));
|
||||
|
||||
topavg = dark_average(second_line.data(), pixels, lines, channels, black_pixels);
|
||||
|
@ -3149,9 +3152,9 @@ gl846_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
|
||||
/* scan with no move */
|
||||
RIE(gl846_set_fe(dev, sensor, AFE_SET));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, regs));
|
||||
DBG(DBG_info, "%s: starting second line reading\n", __func__);
|
||||
RIE(gl846_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl846_begin_scan(dev, sensor, ®s, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner (dev, second_line.data(), total_size));
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
|
@ -3186,7 +3189,8 @@ gl846_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
}
|
||||
|
||||
static SANE_Status
|
||||
gl846_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor, int dpi)
|
||||
gl846_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs, int dpi)
|
||||
{
|
||||
int pixels;
|
||||
int total_size;
|
||||
|
@ -3229,7 +3233,7 @@ gl846_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
pixels = (sensor.sensor_pixels * resolution) / sensor.optical_res;
|
||||
|
||||
status = gl846_init_scan_regs (dev, sensor,
|
||||
&dev->calib_reg,
|
||||
®s,
|
||||
resolution,
|
||||
resolution,
|
||||
0,
|
||||
|
@ -3243,7 +3247,7 @@ gl846_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE);
|
||||
gl846_set_motor_power(&dev->calib_reg, SANE_FALSE);
|
||||
gl846_set_motor_power(®s, SANE_FALSE);
|
||||
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
|
@ -3251,14 +3255,14 @@ gl846_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
return status;
|
||||
}
|
||||
|
||||
RIE (dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
RIE (dev->model->cmd_set->bulk_write_register(dev, regs));
|
||||
|
||||
total_size = pixels * channels * (16/bpp) * lines;
|
||||
|
||||
std::vector<uint8_t> line(total_size);
|
||||
|
||||
RIE(gl846_set_fe(dev, sensor, AFE_SET));
|
||||
RIE(gl846_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl846_begin_scan(dev, sensor, ®s, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner(dev, line.data(), total_size));
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
|
|
|
@ -2006,7 +2006,8 @@ gl847_search_start_position (Genesys_Device * dev)
|
|||
* sets up register for coarse gain calibration
|
||||
* todo: check it for scanners using it */
|
||||
static SANE_Status
|
||||
gl847_init_regs_for_coarse_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||
gl847_init_regs_for_coarse_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs)
|
||||
{
|
||||
SANE_Status status;
|
||||
uint8_t channels;
|
||||
|
@ -2015,7 +2016,7 @@ gl847_init_regs_for_coarse_calibration (Genesys_Device * dev, const Genesys_Sens
|
|||
DBG(DBG_proc, "%s\n", __func__);
|
||||
|
||||
|
||||
cksel = (dev->calib_reg.find_reg(0x18).value & REG18_CKSEL) + 1; /* clock speed = 1..4 clocks */
|
||||
cksel = (regs.find_reg(0x18).value & REG18_CKSEL) + 1; /* clock speed = 1..4 clocks */
|
||||
|
||||
/* set line size */
|
||||
if (dev->settings.scan_mode == SCAN_MODE_COLOR) /* single pass color */
|
||||
|
@ -2024,7 +2025,7 @@ gl847_init_regs_for_coarse_calibration (Genesys_Device * dev, const Genesys_Sens
|
|||
channels = 1;
|
||||
|
||||
status = gl847_init_scan_regs (dev, sensor,
|
||||
&dev->calib_reg,
|
||||
®s,
|
||||
dev->settings.xres,
|
||||
dev->settings.yres,
|
||||
0,
|
||||
|
@ -2048,7 +2049,7 @@ gl847_init_regs_for_coarse_calibration (Genesys_Device * dev, const Genesys_Sens
|
|||
sensor.optical_res / cksel, dev->settings.xres);
|
||||
|
||||
status =
|
||||
dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg);
|
||||
dev->model->cmd_set->bulk_write_register(dev, regs);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: Failed to bulk write registers: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -2146,7 +2147,8 @@ gl847_feed (Genesys_Device * dev, unsigned int steps)
|
|||
|
||||
/* init registers for shading calibration */
|
||||
static SANE_Status
|
||||
gl847_init_regs_for_shading (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||
gl847_init_regs_for_shading(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs)
|
||||
{
|
||||
SANE_Status status;
|
||||
float move;
|
||||
|
@ -2155,7 +2157,7 @@ gl847_init_regs_for_shading (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
dev->calib_channels = 3;
|
||||
|
||||
/* initial calibration reg values */
|
||||
dev->calib_reg = dev->reg;
|
||||
regs = dev->reg;
|
||||
|
||||
dev->calib_resolution = sanei_genesys_compute_dpihw(dev, sensor, dev->settings.xres);
|
||||
dev->calib_total_bytes_to_read = 0;
|
||||
|
@ -2175,7 +2177,7 @@ gl847_init_regs_for_shading (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
}
|
||||
|
||||
status = gl847_init_scan_regs (dev, sensor,
|
||||
&dev->calib_reg,
|
||||
®s,
|
||||
dev->calib_resolution,
|
||||
dev->calib_resolution,
|
||||
0,
|
||||
|
@ -2196,7 +2198,7 @@ gl847_init_regs_for_shading (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
return status;
|
||||
}
|
||||
|
||||
status = dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg);
|
||||
status = dev->model->cmd_set->bulk_write_register(dev, regs);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -2435,7 +2437,7 @@ gl847_send_shading_data (Genesys_Device * dev, const Genesys_Sensor& sensor,
|
|||
* @param dev device to calibrate
|
||||
*/
|
||||
static SANE_Status
|
||||
gl847_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
||||
gl847_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor, Genesys_Register_Set& regs)
|
||||
{
|
||||
int num_pixels;
|
||||
int total_size;
|
||||
|
@ -2468,11 +2470,11 @@ gl847_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
num_pixels = (sensor.sensor_pixels*used_res)/sensor.optical_res;
|
||||
|
||||
/* initial calibration reg values */
|
||||
dev->calib_reg = dev->reg;
|
||||
regs = dev->reg;
|
||||
|
||||
/* set up for the calibration scan */
|
||||
status = gl847_init_scan_regs (dev, sensor,
|
||||
&dev->calib_reg,
|
||||
®s,
|
||||
used_res,
|
||||
used_res,
|
||||
0,
|
||||
|
@ -2511,19 +2513,19 @@ gl847_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
turn = 0;
|
||||
|
||||
/* no move during led calibration */
|
||||
gl847_set_motor_power(&dev->calib_reg, SANE_FALSE);
|
||||
gl847_set_motor_power(®s, SANE_FALSE);
|
||||
do
|
||||
{
|
||||
/* set up exposure */
|
||||
sanei_genesys_set_double(&dev->calib_reg,REG_EXPR,exp[0]);
|
||||
sanei_genesys_set_double(&dev->calib_reg,REG_EXPG,exp[1]);
|
||||
sanei_genesys_set_double(&dev->calib_reg,REG_EXPB,exp[2]);
|
||||
sanei_genesys_set_double(®s,REG_EXPR,exp[0]);
|
||||
sanei_genesys_set_double(®s,REG_EXPG,exp[1]);
|
||||
sanei_genesys_set_double(®s,REG_EXPB,exp[2]);
|
||||
|
||||
/* write registers and scan data */
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, regs));
|
||||
|
||||
DBG(DBG_info, "%s: starting line reading\n", __func__);
|
||||
RIE(gl847_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl847_begin_scan(dev, sensor, ®s, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner(dev, line.data(), total_size));
|
||||
|
||||
/* stop scanning */
|
||||
|
@ -3140,7 +3142,8 @@ dark_average (uint8_t * data, unsigned int pixels, unsigned int lines,
|
|||
}
|
||||
|
||||
static SANE_Status
|
||||
gl847_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||
gl847_offset_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs)
|
||||
{
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
uint8_t reg04;
|
||||
|
@ -3170,7 +3173,7 @@ gl847_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels);
|
||||
|
||||
status = gl847_init_scan_regs (dev, sensor,
|
||||
&dev->calib_reg,
|
||||
®s,
|
||||
resolution,
|
||||
resolution,
|
||||
0,
|
||||
|
@ -3189,7 +3192,7 @@ gl847_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
gl847_set_motor_power(&dev->calib_reg, SANE_FALSE);
|
||||
gl847_set_motor_power(®s, SANE_FALSE);
|
||||
|
||||
/* allocate memory for scans */
|
||||
total_size = pixels * channels * lines * (bpp/8); /* colors * bytes_per_color * scan lines */
|
||||
|
@ -3209,9 +3212,9 @@ gl847_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
dev->frontend.set_offset(2, bottom);
|
||||
|
||||
RIE(gl847_set_fe(dev, sensor, AFE_SET));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, regs));
|
||||
DBG(DBG_info, "%s: starting first line reading\n", __func__);
|
||||
RIE(gl847_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl847_begin_scan(dev, sensor, ®s, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner(dev, first_line.data(), total_size));
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
|
@ -3229,9 +3232,9 @@ gl847_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
dev->frontend.set_offset(1, top);
|
||||
dev->frontend.set_offset(2, top);
|
||||
RIE(gl847_set_fe(dev, sensor, AFE_SET));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, regs));
|
||||
DBG(DBG_info, "%s: starting second line reading\n", __func__);
|
||||
RIE(gl847_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl847_begin_scan(dev, sensor, ®s, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner (dev, second_line.data(), total_size));
|
||||
|
||||
topavg = dark_average(second_line.data(), pixels, lines, channels, black_pixels);
|
||||
|
@ -3249,9 +3252,9 @@ gl847_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
|
||||
/* scan with no move */
|
||||
RIE(gl847_set_fe(dev, sensor, AFE_SET));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, regs));
|
||||
DBG(DBG_info, "%s: starting second line reading\n", __func__);
|
||||
RIE(gl847_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl847_begin_scan(dev, sensor, ®s, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner (dev, second_line.data(), total_size));
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
|
@ -3286,7 +3289,8 @@ gl847_offset_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
|||
}
|
||||
|
||||
static SANE_Status
|
||||
gl847_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& sensor, int dpi)
|
||||
gl847_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs, int dpi)
|
||||
{
|
||||
int pixels;
|
||||
int total_size;
|
||||
|
@ -3329,7 +3333,7 @@ gl847_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
pixels = (sensor.sensor_pixels * resolution) / sensor.optical_res;
|
||||
|
||||
status = gl847_init_scan_regs (dev, sensor,
|
||||
&dev->calib_reg,
|
||||
®s,
|
||||
resolution,
|
||||
resolution,
|
||||
0,
|
||||
|
@ -3343,7 +3347,7 @@ gl847_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE);
|
||||
gl847_set_motor_power(&dev->calib_reg, SANE_FALSE);
|
||||
gl847_set_motor_power(®s, SANE_FALSE);
|
||||
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
|
@ -3351,14 +3355,14 @@ gl847_coarse_gain_calibration (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
return status;
|
||||
}
|
||||
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, dev->calib_reg));
|
||||
RIE(dev->model->cmd_set->bulk_write_register(dev, regs));
|
||||
|
||||
total_size = pixels * channels * (16/bpp) * lines;
|
||||
|
||||
std::vector<uint8_t> line(total_size);
|
||||
|
||||
RIE(gl847_set_fe(dev, sensor, AFE_SET));
|
||||
RIE(gl847_begin_scan(dev, sensor, &dev->calib_reg, SANE_TRUE));
|
||||
RIE(gl847_begin_scan(dev, sensor, ®s, SANE_TRUE));
|
||||
RIE(sanei_genesys_read_data_from_scanner(dev, line.data(), total_size));
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
|
|
|
@ -941,8 +941,10 @@ typedef struct Genesys_Command_Set
|
|||
Genesys_Register_Set * regs,
|
||||
int *channels, int *total_size);
|
||||
SANE_Status (*init_regs_for_coarse_calibration) (Genesys_Device * dev,
|
||||
const Genesys_Sensor& sensor);
|
||||
SANE_Status (*init_regs_for_shading) (Genesys_Device * dev, const Genesys_Sensor& sensor);
|
||||
const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs);
|
||||
SANE_Status (*init_regs_for_shading) (Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs);
|
||||
SANE_Status (*init_regs_for_scan) (Genesys_Device * dev, const Genesys_Sensor& sensor);
|
||||
|
||||
SANE_Bool (*get_filter_bit) (Genesys_Register_Set * reg);
|
||||
|
@ -977,16 +979,19 @@ typedef struct Genesys_Command_Set
|
|||
SANE_Status (*send_gamma_table) (Genesys_Device * dev, const Genesys_Sensor& sensor);
|
||||
|
||||
SANE_Status (*search_start_position) (Genesys_Device * dev);
|
||||
SANE_Status (*offset_calibration) (Genesys_Device * dev, const Genesys_Sensor& sensor);
|
||||
SANE_Status (*offset_calibration) (Genesys_Device * dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs);
|
||||
SANE_Status (*coarse_gain_calibration) (Genesys_Device * dev,
|
||||
const Genesys_Sensor& sensor, int dpi);
|
||||
SANE_Status (*led_calibration) (Genesys_Device * dev, Genesys_Sensor& sensor);
|
||||
const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs, int dpi);
|
||||
SANE_Status (*led_calibration) (Genesys_Device * dev, Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs);
|
||||
|
||||
SANE_Status (*slow_back_home) (Genesys_Device * dev, SANE_Bool wait_until_home);
|
||||
SANE_Status (*rewind) (Genesys_Device * dev);
|
||||
|
||||
SANE_Status (*bulk_write_register) (Genesys_Device * dev,
|
||||
Genesys_Register_Set& reg);
|
||||
Genesys_Register_Set& regs);
|
||||
|
||||
SANE_Status (*bulk_write_data) (Genesys_Device * dev, uint8_t addr,
|
||||
uint8_t * data, size_t len);
|
||||
|
@ -1509,7 +1514,7 @@ sanei_genesys_write_hregister (Genesys_Device * dev, uint16_t reg, uint8_t val);
|
|||
|
||||
extern SANE_Status
|
||||
sanei_genesys_bulk_write_register(Genesys_Device * dev,
|
||||
Genesys_Register_Set& reg);
|
||||
Genesys_Register_Set& regs);
|
||||
|
||||
extern SANE_Status sanei_genesys_write_0x8c (Genesys_Device * dev, uint8_t index, uint8_t val);
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue