Merge branch 'genesys-misc-cleanup' into 'master'

genesys: Miscellaneous cleanup

See merge request sane-project/backends!148
merge-requests/149/head
Povilas Kanapickas 2019-08-31 18:19:57 +00:00
commit 6b7052c4cf
7 zmienionych plików z 136 dodań i 133 usunięć

Wyświetl plik

@ -1050,6 +1050,9 @@ static void gl124_compute_session(Genesys_Device* dev, ScanSession& s,
s.enable_ledadd = (s.params.channels == 1 && dev->model->is_cis && dev->settings.true_gray);
s.computed = true;
DBG(DBG_info, "%s ", __func__);
debug_dump(DBG_info, s);
}
/** set up registers for an actual scan
@ -1076,8 +1079,6 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
int max_shift;
size_t requested_buffer_size, read_buffer_size;
debug_dump(DBG_info, session.params);
DBG (DBG_info, "%s: optical_res=%d\n", __func__, session.optical_resolution);
/* stagger */
@ -1088,8 +1089,6 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
}
DBG (DBG_info, "gl124_init_scan_regs : stagger=%d lines\n", stagger);
unsigned used_res = session.params.xres;
/* compute scan parameters values */
/* pixels are allways given at full optical resolution */
/* use detected left margin and fixed value */
@ -1112,7 +1111,7 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
}
else
{
exposure_time = get_sensor_profile(sensor, used_res,
exposure_time = get_sensor_profile(sensor, session.params.xres,
session.ccd_size_divisor).exposure_lperiod;
scan_step_type = sanei_genesys_compute_step_type(gl124_motor_profiles,
dev->model->motor_type, exposure_time);
@ -1133,7 +1132,8 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
*/
// now _LOGICAL_ optical values used are known, setup registers
gl124_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, used_res, start,
gl124_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, session.params.xres,
start,
session.optical_pixels, session.params.channels,
session.params.depth, session.ccd_size_divisor,
session.params.color_filter);
@ -1163,7 +1163,7 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
/*** prepares data reordering ***/
/* words_per_line */
bytes_per_line = (session.optical_pixels * used_res) / session.optical_resolution;
bytes_per_line = (session.optical_pixels * session.params.xres) / session.optical_resolution;
bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8;
/* since we don't have sheetfed scanners to handle,
@ -1193,11 +1193,11 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
dev->read_active = SANE_TRUE;
dev->session = session;
dev->current_setup.pixels = (session.optical_pixels * used_res) / session.optical_resolution;
dev->current_setup.pixels = (session.optical_pixels * session.params.xres) / session.optical_resolution;
DBG(DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels);
dev->current_setup.lines = lincnt;
dev->current_setup.exposure_time = exposure_time;
dev->current_setup.xres = used_res;
dev->current_setup.xres = session.params.xres;
dev->current_setup.ccd_size_divisor = session.ccd_size_divisor;
dev->current_setup.stagger = stagger;
dev->current_setup.max_shift = max_shift + stagger;
@ -1220,7 +1220,6 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso
{
int start;
int used_res;
unsigned int lincnt;
int exposure_time;
int stagger;
@ -1252,11 +1251,6 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso
gl124_compute_session(dev, session, sensor);
DBG(DBG_info, "%s ", __func__);
debug_dump(DBG_info, session.params);
used_res = session.params.xres;
/* compute scan parameters values */
/* pixels are allways given at half or full CCD optical resolution */
/* use detected left margin and fixed value */
@ -1272,7 +1266,7 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso
session.params.yres, 0);
// compute hw dpi for sensor
dpihw = sensor.get_register_hwdpi(used_res);
dpihw = sensor.get_register_hwdpi(session.params.xres);
const SensorProfile& sensor_profile = get_sensor_profile(sensor, dpihw,
session.ccd_size_divisor);
@ -1289,11 +1283,11 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso
lincnt = session.params.lines + max_shift + stagger;
dev->session = session;
dev->current_setup.pixels = (session.optical_pixels * used_res) / sensor.optical_res;
dev->current_setup.pixels = (session.optical_pixels * session.params.xres) / sensor.optical_res;
DBG (DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels);
dev->current_setup.lines = lincnt;
dev->current_setup.exposure_time = exposure_time;
dev->current_setup.xres = used_res;
dev->current_setup.xres = session.params.xres;
dev->current_setup.ccd_size_divisor = session.ccd_size_divisor;
dev->current_setup.stagger = stagger;
dev->current_setup.max_shift = max_shift + stagger;

Wyświetl plik

@ -297,6 +297,9 @@ static void gl646_compute_session(Genesys_Device* dev, ScanSession& s,
compute_session(dev, s, sensor);
s.computed = true;
DBG(DBG_info, "%s ", __func__);
debug_dump(DBG_info, s);
}
/**
@ -323,7 +326,6 @@ static void gl646_setup_registers(Genesys_Device* dev,
session.assert_computed();
debug_dump(DBG_info, sensor);
debug_dump(DBG_info, session);
int resolution = session.params.xres;
uint32_t move = session.params.starty;

Wyświetl plik

@ -1738,6 +1738,9 @@ static void gl841_compute_session(Genesys_Device* dev, ScanSession& s,
compute_session(dev, s, sensor);
s.computed = true;
DBG(DBG_info, "%s ", __func__);
debug_dump(DBG_info, s);
}
static void gl841_assert_supported_resolution(const ScanSession& session)
@ -1759,7 +1762,6 @@ static void gl841_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
DBG_HELPER(dbg);
session.assert_computed();
int used_res;
int start;
int bytes_per_line;
int move;
@ -1774,8 +1776,6 @@ static void gl841_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
int max_shift;
size_t requested_buffer_size, read_buffer_size;
debug_dump(DBG_info, session.params);
/*
results:
@ -1813,20 +1813,14 @@ independent of our calculated values:
}
DBG(DBG_info, "%s : stagger=%d lines\n", __func__, stagger);
if (session.params.flags & SCAN_FLAG_USE_OPTICAL_RES) {
used_res = session.optical_resolution;
} else {
used_res = session.params.xres;
}
gl841_assert_supported_resolution(session);
/* compute scan parameters values */
/* pixels are allways given at half or full CCD optical resolution */
/* use detected left margin and fixed value */
start = ((sensor.CCD_start_xoffset + session.params.startx) * used_res) / sensor.optical_res;
start = ((sensor.CCD_start_xoffset + session.params.startx) * session.optical_resolution)
/ sensor.optical_res;
// needs to be aligned for used_res
start = (start * session.optical_resolution) / used_res;
start += sensor.dummy_pixel + 1;
@ -1839,7 +1833,7 @@ independent of our calculated values:
* scan, where shading data needs to be align */
if((dev->reg.find_reg(0x01).value & REG01_SHDAREA) != 0)
{
avg = session.optical_resolution / used_res;
avg = session.optical_resolution / session.params.xres;
start=(start/avg)*avg;
}
@ -1901,7 +1895,7 @@ dummy \ scanned lines
session.params.flags |= SCAN_FLAG_DISABLE_GAMMA;
}
gl841_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, used_res, start,
gl841_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, session.params.xres, start,
session.optical_pixels, session.params.channels,
session.params.depth, session.ccd_size_divisor,
session.params.color_filter);
@ -1944,7 +1938,7 @@ dummy \ scanned lines
/*** prepares data reordering ***/
/* words_per_line */
bytes_per_line = (session.optical_pixels * used_res) / session.optical_resolution;
bytes_per_line = (session.optical_pixels * session.params.xres) / session.optical_resolution;
bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8;
requested_buffer_size = 8 * bytes_per_line;
@ -1974,10 +1968,10 @@ dummy \ scanned lines
dev->read_active = SANE_TRUE;
dev->session = session;
dev->current_setup.pixels = (session.optical_pixels * used_res) / session.optical_resolution;
dev->current_setup.pixels = (session.optical_pixels * session.params.xres) / session.optical_resolution;
dev->current_setup.lines = lincnt;
dev->current_setup.exposure_time = exposure_time;
dev->current_setup.xres = used_res;
dev->current_setup.xres = session.params.xres;
dev->current_setup.ccd_size_divisor = session.ccd_size_divisor;
dev->current_setup.stagger = stagger;
dev->current_setup.max_shift = max_shift + stagger;
@ -2014,7 +2008,6 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se
{
int start;
int used_res;
unsigned int lincnt;
int exposure_time;
int stagger;
@ -2051,9 +2044,6 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se
gl841_compute_session(dev, session, sensor);
DBG(DBG_info, "%s ", __func__);
debug_dump(DBG_info, session.params);
/* stagger */
if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) {
@ -2063,16 +2053,12 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se
}
DBG(DBG_info, "%s: stagger=%d lines\n", __func__, stagger);
used_res = session.params.xres;
gl841_assert_supported_resolution(session);
/* compute scan parameters values */
/* pixels are allways given at half or full CCD optical resolution */
/* use detected left margin and fixed value */
start = ((sensor.CCD_start_xoffset + session.params.startx) * used_res) / sensor.optical_res;
// needs to be aligned for used_res
start = (start * session.optical_resolution) / used_res;
start = ((sensor.CCD_start_xoffset + session.params.startx) * session.optical_resolution) / sensor.optical_res;
start += sensor.dummy_pixel + 1;
@ -2131,10 +2117,10 @@ dummy \ scanned lines
lincnt = session.params.lines + max_shift + stagger;
dev->session = session;
dev->current_setup.pixels = (session.optical_pixels * used_res) / session.optical_resolution;
dev->current_setup.pixels = (session.optical_pixels * session.params.xres) / session.optical_resolution;
dev->current_setup.lines = lincnt;
dev->current_setup.exposure_time = exposure_time;
dev->current_setup.xres = used_res;
dev->current_setup.xres = session.params.xres;
dev->current_setup.ccd_size_divisor = session.ccd_size_divisor;
dev->current_setup.stagger = stagger;
dev->current_setup.max_shift = max_shift + stagger;
@ -2949,12 +2935,20 @@ static void gl841_init_regs_for_shading(Genesys_Device* dev, const Genesys_Senso
dev->calib_channels = 3;
dev->calib_lines = dev->model->shading_lines;
unsigned resolution = sensor.get_logical_hwdpi(dev->settings.xres);
unsigned factor = sensor.optical_res / resolution;
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, dev->calib_channels,
dev->settings.scan_method);
dev->calib_pixels = calib_sensor.sensor_pixels / factor;
ScanSession session;
session.params.xres = dev->settings.xres;
session.params.xres = resolution;
session.params.yres = ydpi;
session.params.startx = 0;
session.params.starty = starty;
session.params.pixels = (sensor.sensor_pixels * dev->settings.xres) / sensor.optical_res;
session.params.pixels = dev->calib_pixels;
session.params.lines = dev->calib_lines;
session.params.depth = 16;
session.params.channels = dev->calib_channels;
@ -2963,14 +2957,12 @@ static void gl841_init_regs_for_shading(Genesys_Device* dev, const Genesys_Senso
session.params.color_filter = dev->settings.color_filter;
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
SCAN_FLAG_DISABLE_GAMMA |
SCAN_FLAG_USE_OPTICAL_RES |
/*SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE |*/
SCAN_FLAG_IGNORE_LINE_DISTANCE;
gl841_compute_session(dev, session, sensor);
gl841_compute_session(dev, session, calib_sensor);
gl841_init_scan_regs(dev, sensor, &regs, session);
gl841_init_scan_regs(dev, calib_sensor, &regs, session);
dev->calib_pixels = dev->current_setup.pixels;
dev->scanhead_position_in_steps += dev->calib_lines + starty;
dev->write_registers(regs);
@ -3133,12 +3125,20 @@ static SensorExposure gl841_led_calibration(Genesys_Device* dev, const Genesys_S
/* offset calibration is always done in color mode */
channels = 3;
unsigned resolution = sensor.get_logical_hwdpi(dev->settings.xres);
unsigned factor = sensor.optical_res / resolution;
const auto& calib_sensor_base = sanei_genesys_find_sensor(dev, resolution, channels,
dev->settings.scan_method);
num_pixels = calib_sensor_base.sensor_pixels / factor;
ScanSession session;
session.params.xres = dev->settings.xres;
session.params.xres = resolution;
session.params.yres = dev->settings.yres;
session.params.startx = 0;
session.params.starty = 0;
session.params.pixels = (sensor.sensor_pixels*dev->settings.xres) / sensor.optical_res;
session.params.pixels = num_pixels;
session.params.lines = 1;
session.params.depth = 16;
session.params.channels = channels;
@ -3148,15 +3148,13 @@ static SensorExposure gl841_led_calibration(Genesys_Device* dev, const Genesys_S
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
SCAN_FLAG_DISABLE_GAMMA |
SCAN_FLAG_SINGLE_LINE |
SCAN_FLAG_IGNORE_LINE_DISTANCE |
SCAN_FLAG_USE_OPTICAL_RES;
gl841_compute_session(dev, session, sensor);
SCAN_FLAG_IGNORE_LINE_DISTANCE;
gl841_compute_session(dev, session, calib_sensor_base);
gl841_init_scan_regs(dev, sensor, &regs, session);
gl841_init_scan_regs(dev, calib_sensor_base, &regs, session);
dev->write_registers(regs);
num_pixels = dev->current_setup.pixels;
total_size = num_pixels * channels * 2 * 1; /* colors * bytes_per_color * scan lines */
@ -3180,7 +3178,7 @@ static SensorExposure gl841_led_calibration(Genesys_Device* dev, const Genesys_S
max_exposure=((exp[0]+exp[1]+exp[2])/3)*2;
target=sensor.gain_white_ref*256;
auto calib_sensor = sensor;
auto calib_sensor = calib_sensor_base;
do {
calib_sensor.exposure.red = exp[0];
@ -3331,12 +3329,20 @@ static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
return;
}
unsigned resolution = sensor.get_logical_hwdpi(dev->settings.xres);
unsigned factor = sensor.optical_res / resolution;
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, 3,
dev->settings.scan_method);
num_pixels = calib_sensor.sensor_pixels / factor;
ScanSession session;
session.params.xres = dev->settings.xres;
session.params.xres = resolution;
session.params.yres = dev->settings.yres;
session.params.startx = 0;
session.params.starty = 0;
session.params.pixels = (sensor.sensor_pixels*dev->settings.xres) / sensor.optical_res;
session.params.pixels = num_pixels;
session.params.lines = 1;
session.params.depth = 8;
session.params.channels = 3;
@ -3346,13 +3352,11 @@ static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
SCAN_FLAG_DISABLE_GAMMA |
SCAN_FLAG_SINGLE_LINE |
SCAN_FLAG_IGNORE_LINE_DISTANCE |
SCAN_FLAG_USE_OPTICAL_RES;
gl841_compute_session(dev, session, sensor);
SCAN_FLAG_IGNORE_LINE_DISTANCE;
gl841_compute_session(dev, session, calib_sensor);
gl841_init_scan_regs(dev, sensor, &regs, session);
gl841_init_scan_regs(dev, calib_sensor, &regs, session);
num_pixels = dev->current_setup.pixels;
total_size = num_pixels * 3 * 2 * 1;
std::vector<uint8_t> line(total_size);
@ -3375,8 +3379,8 @@ static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
/* scan line */
DBG(DBG_info, "%s: starting line reading\n", __func__);
dev->write_registers(regs);
gl841_set_fe(dev, sensor, AFE_SET);
gl841_begin_scan(dev, sensor, &regs, SANE_TRUE);
gl841_set_fe(dev, calib_sensor, AFE_SET);
gl841_begin_scan(dev, calib_sensor, &regs, SANE_TRUE);
sanei_genesys_read_data_from_scanner(dev, line.data(), total_size);
gl841_stop_action (dev);
if (DBG_LEVEL >= DBG_data) {
@ -3449,12 +3453,20 @@ static void gl841_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
/* offset calibration is always done in color mode */
channels = 3;
unsigned resolution = sensor.get_logical_hwdpi(dev->settings.xres);
unsigned factor = sensor.optical_res / resolution;
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, channels,
dev->settings.scan_method);
num_pixels = calib_sensor.sensor_pixels / factor;
ScanSession session;
session.params.xres = dev->settings.xres;
session.params.xres = resolution;
session.params.yres = dev->settings.yres;
session.params.startx = 0;
session.params.starty = 0;
session.params.pixels = (sensor.sensor_pixels*dev->settings.xres) / sensor.optical_res;
session.params.pixels = num_pixels;
session.params.lines = 1;
session.params.depth = 16;
session.params.channels = channels;
@ -3465,13 +3477,10 @@ static void gl841_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
SCAN_FLAG_DISABLE_GAMMA |
SCAN_FLAG_SINGLE_LINE |
SCAN_FLAG_IGNORE_LINE_DISTANCE |
SCAN_FLAG_USE_OPTICAL_RES |
SCAN_FLAG_DISABLE_LAMP;
gl841_compute_session(dev, session, sensor);
gl841_compute_session(dev, session, calib_sensor);
gl841_init_scan_regs(dev, sensor, &regs, session);
num_pixels = dev->current_setup.pixels;
gl841_init_scan_regs(dev, calib_sensor, &regs, session);
total_size = num_pixels * channels * 2 * 1; /* colors * bytes_per_color * scan lines */
@ -3517,10 +3526,10 @@ static void gl841_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
dev->frontend.set_offset(j, off[j]);
}
gl841_set_fe(dev, sensor, AFE_SET);
gl841_set_fe(dev, calib_sensor, AFE_SET);
DBG(DBG_info, "%s: starting first line reading\n", __func__);
gl841_begin_scan(dev, sensor, &regs, SANE_TRUE);
gl841_begin_scan(dev, calib_sensor, &regs, SANE_TRUE);
sanei_genesys_read_data_from_scanner(dev, first_line.data(), total_size);
@ -3624,11 +3633,11 @@ static void gl841_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
dev->frontend.set_offset(j, off[j]);
}
gl841_set_fe(dev, sensor, AFE_SET);
gl841_set_fe(dev, calib_sensor, AFE_SET);
DBG(DBG_info, "%s: starting second line reading\n", __func__);
dev->write_registers(regs);
gl841_begin_scan(dev, sensor, &regs, SANE_TRUE);
gl841_begin_scan(dev, calib_sensor, &regs, SANE_TRUE);
sanei_genesys_read_data_from_scanner(dev, second_line.data(), total_size);
if (DBG_LEVEL >= DBG_data) {
@ -3810,12 +3819,20 @@ static void gl841_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen
/* coarse gain calibration is allways done in color mode */
channels = 3;
unsigned resolution = sensor.get_logical_hwdpi(dev->settings.xres);
unsigned factor = sensor.optical_res / resolution;
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, channels,
dev->settings.scan_method);
num_pixels = calib_sensor.sensor_pixels / factor;
ScanSession session;
session.params.xres = dev->settings.xres;
session.params.xres = resolution;
session.params.yres = dev->settings.yres;
session.params.startx = 0;
session.params.starty = 0;
session.params.pixels = (sensor.sensor_pixels*dev->settings.xres) / sensor.optical_res;
session.params.pixels = num_pixels;
session.params.lines = lines;
session.params.depth = 16;
session.params.channels = channels;
@ -3825,21 +3842,18 @@ static void gl841_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
SCAN_FLAG_DISABLE_GAMMA |
SCAN_FLAG_SINGLE_LINE |
SCAN_FLAG_IGNORE_LINE_DISTANCE |
SCAN_FLAG_USE_OPTICAL_RES;
gl841_compute_session(dev, session, sensor);
SCAN_FLAG_IGNORE_LINE_DISTANCE;
gl841_compute_session(dev, session, calib_sensor);
gl841_init_scan_regs(dev, sensor, &regs, session);
gl841_init_scan_regs(dev, calib_sensor, &regs, session);
dev->write_registers(regs);
num_pixels = dev->current_setup.pixels;
total_size = num_pixels * channels * 2 * lines; /* colors * bytes_per_color * scan lines */
std::vector<uint8_t> line(total_size);
gl841_begin_scan(dev, sensor, &regs, SANE_TRUE);
gl841_begin_scan(dev, calib_sensor, &regs, SANE_TRUE);
sanei_genesys_read_data_from_scanner(dev, line.data(), total_size);
if (DBG_LEVEL >= DBG_data)
@ -3975,8 +3989,7 @@ static void gl841_init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
SCAN_FLAG_DISABLE_GAMMA |
SCAN_FLAG_SINGLE_LINE |
SCAN_FLAG_IGNORE_LINE_DISTANCE |
SCAN_FLAG_USE_OPTICAL_RES;
SCAN_FLAG_IGNORE_LINE_DISTANCE;
gl841_compute_session(dev, session, sensor);
gl841_init_scan_regs(dev, sensor, local_reg, session);
@ -4115,12 +4128,20 @@ static void gl841_init(Genesys_Device* dev)
Genesys_Register_Set& regs = dev->calib_reg;
regs = dev->reg;
unsigned resolution = sensor.get_logical_hwdpi(300);
unsigned factor = sensor.optical_res / resolution;
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, 3,
dev->settings.scan_method);
unsigned num_pixels = 16 / factor;
ScanSession session;
session.params.xres = 300;
session.params.xres = resolution;
session.params.yres = 300;
session.params.startx = 0;
session.params.starty = 0;
session.params.pixels = (16 * 300) / sensor.optical_res;
session.params.pixels = num_pixels;
session.params.lines = 1;
session.params.depth = 16;
session.params.channels = 3;
@ -4130,20 +4151,19 @@ static void gl841_init(Genesys_Device* dev)
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
SCAN_FLAG_DISABLE_GAMMA |
SCAN_FLAG_SINGLE_LINE |
SCAN_FLAG_IGNORE_LINE_DISTANCE |
SCAN_FLAG_USE_OPTICAL_RES;
gl841_compute_session(dev, session, sensor);
SCAN_FLAG_IGNORE_LINE_DISTANCE;
gl841_compute_session(dev, session, calib_sensor);
gl841_init_scan_regs(dev, sensor, &regs, session);
gl841_init_scan_regs(dev, calib_sensor, &regs, session);
dev->write_registers(regs);
size = dev->current_setup.pixels * 3 * 2 * 1; /* colors * bytes_per_color * scan lines */
size = num_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__);
gl841_begin_scan(dev, sensor, &regs, SANE_TRUE);
gl841_begin_scan(dev, calib_sensor, &regs, SANE_TRUE);
sanei_usb_set_timeout(1000);/* 1 second*/

Wyświetl plik

@ -1229,6 +1229,9 @@ static void gl843_compute_session(Genesys_Device* dev, ScanSession& s,
}
s.computed = true;
DBG(DBG_info, "%s ", __func__);
debug_dump(DBG_info, s);
}
// set up registers for an actual scan this function sets up the scanner to scan in normal or single
@ -1247,8 +1250,6 @@ static void gl843_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
int scan_step_type = 1;
size_t requested_buffer_size, read_buffer_size;
debug_dump(DBG_info, session.params);
DBG(DBG_info, "%s : stagger=%d lines\n", __func__, session.num_staggered_lines);
/* we enable true gray for cis scanners only, and just when doing
@ -1427,9 +1428,6 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
gl843_compute_session(dev, session, sensor);
DBG(DBG_info, "%s ", __func__);
debug_dump(DBG_info, session.params);
/* stagger */
if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) {
stagger = (4 * session.params.yres) / dev->motor.base_ydpi;
@ -1438,8 +1436,6 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
}
DBG(DBG_info, "%s: stagger=%d lines\n", __func__, stagger);
int used_res = session.params.xres;
/* compute scan parameters values */
/* pixels are allways given at half or full CCD optical resolution */
/* use detected left margin and fixed value */
@ -1470,11 +1466,11 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
lincnt = session.params.lines + max_shift + stagger;
dev->session = session;
dev->current_setup.pixels = (session.optical_pixels * used_res) / session.optical_resolution;
dev->current_setup.pixels = (session.optical_pixels * session.params.xres) / session.optical_resolution;
DBG(DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels);
dev->current_setup.lines = lincnt;
dev->current_setup.exposure_time = exposure;
dev->current_setup.xres = used_res;
dev->current_setup.xres = session.params.xres;
dev->current_setup.ccd_size_divisor = session.ccd_size_divisor;
dev->current_setup.stagger = stagger;
dev->current_setup.max_shift = max_shift + stagger;

Wyświetl plik

@ -937,6 +937,9 @@ static void gl846_compute_session(Genesys_Device* dev, ScanSession& s,
s.enable_ledadd = (s.params.channels == 1 && dev->model->is_cis && dev->settings.true_gray);
s.computed = true;
DBG(DBG_info, "%s ", __func__);
debug_dump(DBG_info, s);
}
// set up registers for an actual scan this function sets up the scanner to scan in normal or single
@ -961,8 +964,6 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
int max_shift;
size_t requested_buffer_size, read_buffer_size;
debug_dump(DBG_info, session.params);
/* stagger */
if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) {
stagger = (4 * session.params.yres) / dev->motor.base_ydpi;
@ -971,8 +972,6 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
}
DBG(DBG_info, "%s : stagger=%d lines\n", __func__, stagger);
unsigned used_res = session.params.xres;
/* compute scan parameters values */
/* pixels are allways given at full optical resolution */
/* use detected left margin and fixed value */
@ -997,7 +996,7 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
slope_dpi = slope_dpi * (1 + dummy);
exposure_time = get_sensor_profile(sensor, used_res).exposure_lperiod;
exposure_time = get_sensor_profile(sensor, session.params.xres).exposure_lperiod;
scan_step_type = sanei_genesys_compute_step_type(gl846_motor_profiles, dev->model->motor_type,
exposure_time);
@ -1014,7 +1013,7 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
/* we enable true gray for cis scanners only, and just when doing
* scan since color calibration is OK for this mode
*/
gl846_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, used_res, start,
gl846_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, session.params.xres, start,
session.optical_pixels, session.params.channels, session.params.depth,
session.params.color_filter);
@ -1045,7 +1044,7 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
/*** prepares data reordering ***/
/* words_per_line */
bytes_per_line = (session.optical_pixels * used_res) / session.optical_resolution;
bytes_per_line = (session.optical_pixels * session.params.xres) / session.optical_resolution;
bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8;
requested_buffer_size = 8 * bytes_per_line;
@ -1072,10 +1071,10 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
dev->read_active = SANE_TRUE;
dev->session = session;
dev->current_setup.pixels = (session.optical_pixels * used_res) / session.optical_resolution;
dev->current_setup.pixels = (session.optical_pixels * session.params.xres) / session.optical_resolution;
dev->current_setup.lines = lincnt;
dev->current_setup.exposure_time = exposure_time;
dev->current_setup.xres = used_res;
dev->current_setup.xres = session.params.xres;
dev->current_setup.ccd_size_divisor = session.ccd_size_divisor;
dev->current_setup.stagger = stagger;
dev->current_setup.max_shift = max_shift + stagger;
@ -1146,9 +1145,6 @@ gl846_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
gl846_compute_session(dev, session, sensor);
DBG(DBG_info, "%s ", __func__);
debug_dump(DBG_info, session.params);
if (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE) {
stagger = (4 * session.params.yres) / dev->motor.base_ydpi;
} else {

Wyświetl plik

@ -956,6 +956,9 @@ static void gl847_compute_session(Genesys_Device* dev, ScanSession& s,
compute_session(dev, s, sensor);
s.computed = true;
DBG(DBG_info, "%s ", __func__);
debug_dump(DBG_info, s);
}
// set up registers for an actual scan this function sets up the scanner to scan in normal or single
@ -980,8 +983,6 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
int max_shift;
size_t requested_buffer_size, read_buffer_size;
debug_dump(DBG_info, session.params);
/* stagger */
if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) {
stagger = (4 * session.params.yres) / dev->motor.base_ydpi;
@ -990,8 +991,6 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
}
DBG(DBG_info, "%s : stagger=%d lines\n", __func__, stagger);
unsigned used_res = session.params.xres;
/* compute scan parameters values */
/* pixels are allways given at full optical resolution */
/* use detected left margin and fixed value */
@ -1016,7 +1015,7 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
slope_dpi = slope_dpi * (1 + dummy);
exposure_time = get_sensor_profile(sensor, used_res).exposure_lperiod;
exposure_time = get_sensor_profile(sensor, session.params.xres).exposure_lperiod;
scan_step_type = sanei_genesys_compute_step_type(gl847_motor_profiles, dev->model->motor_type,
exposure_time);
@ -1033,7 +1032,7 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
/* we enable true gray for cis scanners only, and just when doing
* scan since color calibration is OK for this mode
*/
gl847_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, used_res, start,
gl847_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, session.params.xres, start,
session.optical_pixels, session.params.channels,
session.params.depth, session.params.color_filter);
@ -1062,7 +1061,7 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
/*** prepares data reordering ***/
/* words_per_line */
bytes_per_line = (session.optical_pixels * used_res) / session.optical_resolution;
bytes_per_line = (session.optical_pixels * session.params.xres) / session.optical_resolution;
bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8;
requested_buffer_size = 8 * bytes_per_line;
@ -1089,10 +1088,10 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
dev->read_active = SANE_TRUE;
dev->session = session;
dev->current_setup.pixels = (session.optical_pixels * used_res) / session.optical_resolution;
dev->current_setup.pixels = (session.optical_pixels * session.params.xres) / session.optical_resolution;
dev->current_setup.lines = lincnt;
dev->current_setup.exposure_time = exposure_time;
dev->current_setup.xres = used_res;
dev->current_setup.xres = session.params.xres;
dev->current_setup.ccd_size_divisor = session.ccd_size_divisor;
dev->current_setup.stagger = stagger;
dev->current_setup.max_shift = max_shift + stagger;
@ -1164,9 +1163,6 @@ gl847_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
gl847_compute_session(dev, session, sensor);
DBG(DBG_info, "%s ", __func__);
debug_dump(DBG_info, session.params);
/* optical_res */
optical_res = sensor.optical_res;

Wyświetl plik

@ -372,7 +372,6 @@ extern Motor_Profile gl124_motor_profiles[];
#define SCAN_FLAG_DISABLE_GAMMA 0x004
#define SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE 0x008
#define SCAN_FLAG_IGNORE_LINE_DISTANCE 0x010
#define SCAN_FLAG_USE_OPTICAL_RES 0x020
#define SCAN_FLAG_DISABLE_LAMP 0x040
#define SCAN_FLAG_DYNAMIC_LINEART 0x080
#define SCAN_FLAG_CALIBRATION 0x100