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

genesys: Miscellaneous simplifications

See merge request sane-project/backends!146
merge-requests/147/head
Povilas Kanapickas 2019-08-31 17:44:21 +00:00
commit 3db2278bea
7 zmienionych plików z 37 dodań i 144 usunięć

Wyświetl plik

@ -557,19 +557,6 @@ static void gl124_set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint
}
}
/**@brief compute exposure to use
* compute the sensor exposure based on target resolution
* @param dev pointer to device description
* @param xres sensor's required resolution
* @param ccd_size_divisor how many CCD pixels are processed for output pixel
*/
static int gl124_compute_exposure(const Genesys_Sensor& sensor, int xres, unsigned ccd_size_divisor)
{
return get_sensor_profile(sensor, xres, ccd_size_divisor).exposure_lperiod;
}
static void gl124_init_motor_regs_scan(Genesys_Device* dev,
const Genesys_Sensor& sensor,
Genesys_Register_Set* reg,
@ -1075,7 +1062,6 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
DBG_HELPER(dbg);
session.assert_computed();
int used_res;
int start, used_pixels;
int bytes_per_line;
int move;
@ -1102,20 +1088,7 @@ 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);
/** @brief compute used resolution */
if (session.params.flags & SCAN_FLAG_USE_OPTICAL_RES) {
used_res = session.optical_resolution;
}
else
{
// resolution is choosen from a fixed list and can be used directly, unless we have ydpi
// higher than sensor's maximum one */
if (session.params.xres > session.optical_resolution) {
used_res = session.optical_resolution;
} else {
used_res = session.params.xres;
}
}
unsigned used_res = session.params.xres;
/* compute scan parameters values */
/* pixels are allways given at full optical resolution */
@ -1152,7 +1125,8 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
}
else
{
exposure_time = gl124_compute_exposure(sensor, used_res, session.ccd_size_divisor);
exposure_time = get_sensor_profile(sensor, used_res,
session.ccd_size_divisor).exposure_lperiod;
scan_step_type = sanei_genesys_compute_step_type(gl124_motor_profiles,
dev->model->motor_type, exposure_time);
}
@ -1298,11 +1272,7 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso
/* optical_res */
optical_res = sensor.optical_res;
if (session.params.xres <= (unsigned) optical_res) {
used_res = session.params.xres;
} else {
used_res = optical_res;
}
used_res = session.params.xres;
/* compute scan parameters values */
/* pixels are allways given at half or full CCD optical resolution */
@ -1311,7 +1281,9 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso
used_pixels = (session.params.pixels * optical_res) / session.params.xres;
DBG (DBG_info, "%s: used_pixels=%d\n", __func__, used_pixels);
exposure_time = gl124_compute_exposure(sensor, session.params.xres, session.ccd_size_divisor);
exposure_time = get_sensor_profile(sensor, session.params.xres,
session.ccd_size_divisor).exposure_lperiod;
DBG (DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
max_shift = sanei_genesys_compute_max_shift(dev, session.params.channels,

Wyświetl plik

@ -2830,6 +2830,8 @@ static void gl646_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen
Genesys_Register_Set& regs, int dpi)
{
DBG_HELPER(dbg);
(void) dpi;
unsigned int i, j, k, channels, val, maximum, idx;
unsigned int count, resolution, pass;
float average[3];
@ -2846,11 +2848,7 @@ static void gl646_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen
channels = 3;
/* we are searching a sensor resolution */
if (dpi > sensor.optical_res) {
resolution = sensor.optical_res;
} else {
resolution = get_closest_resolution(dev->model->ccd_type, dev->settings.xres, channels);
}
resolution = get_closest_resolution(dev->model->ccd_type, dev->settings.xres, channels);
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, channels,
ScanMethod::FLATBED);

Wyświetl plik

@ -1740,6 +1740,17 @@ static void gl841_compute_session(Genesys_Device* dev, ScanSession& s,
s.computed = true;
}
static void gl841_assert_supported_resolution(const ScanSession& session)
{
for (unsigned factor : {1, 2, 3, 4, 5, 6, 8, 10, 12, 15}) {
if (session.output_resolution == session.optical_resolution / factor) {
return;
}
}
throw SaneException("Unsupported resolution %d for optical resolution %d",
session.output_resolution, session.optical_resolution);
}
// set up registers for an actual scan this function sets up the scanner to scan in normal or single
// line mode
static void gl841_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sensor,
@ -1754,7 +1765,6 @@ static void gl841_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
int move;
unsigned int lincnt;
int exposure_time;
int i;
int stagger;
int avg;
@ -1803,32 +1813,12 @@ independent of our calculated values:
}
DBG(DBG_info, "%s : stagger=%d lines\n", __func__, stagger);
/* used_res */
i = session.optical_resolution / session.params.xres;
/* gl841 supports 1/1 1/2 1/3 1/4 1/5 1/6 1/8 1/10 1/12 1/15 averaging */
if (i < 2 || (session.params.flags & SCAN_FLAG_USE_OPTICAL_RES)) {
// optical_res >= xres > optical_res/2
if (session.params.flags & SCAN_FLAG_USE_OPTICAL_RES) {
used_res = session.optical_resolution;
} else if (i < 3) /* optical_res/2 >= xres > optical_res/3 */
used_res = session.optical_resolution/2;
else if (i < 4) /* optical_res/3 >= xres > optical_res/4 */
used_res = session.optical_resolution/3;
else if (i < 5) /* optical_res/4 >= xres > optical_res/5 */
used_res = session.optical_resolution/4;
else if (i < 6) /* optical_res/5 >= xres > optical_res/6 */
used_res = session.optical_resolution/5;
else if (i < 8) /* optical_res/6 >= xres > optical_res/8 */
used_res = session.optical_resolution/6;
else if (i < 10) /* optical_res/8 >= xres > optical_res/10 */
used_res = session.optical_resolution/8;
else if (i < 12) /* optical_res/10 >= xres > optical_res/12 */
used_res = session.optical_resolution/10;
else if (i < 15) /* optical_res/12 >= xres > optical_res/15 */
used_res = session.optical_resolution/12;
else
used_res = session.optical_resolution/15;
} 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 */
@ -2035,7 +2025,6 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se
int used_pixels;
unsigned int lincnt;
int exposure_time;
int i;
int stagger;
int slope_dpi = 0;
@ -2082,31 +2071,8 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se
}
DBG(DBG_info, "%s: stagger=%d lines\n", __func__, stagger);
/* used_res */
i = session.optical_resolution / session.params.xres;
/* gl841 supports 1/1 1/2 1/3 1/4 1/5 1/6 1/8 1/10 1/12 1/15 averaging */
if (i < 2) /* optical_res >= xres > optical_res/2 */
used_res = session.optical_resolution;
else if (i < 3) /* optical_res/2 >= xres > optical_res/3 */
used_res = session.optical_resolution / 2;
else if (i < 4) /* optical_res/3 >= xres > optical_res/4 */
used_res = session.optical_resolution / 3;
else if (i < 5) /* optical_res/4 >= xres > optical_res/5 */
used_res = session.optical_resolution / 4;
else if (i < 6) /* optical_res/5 >= xres > optical_res/6 */
used_res = session.optical_resolution / 5;
else if (i < 8) /* optical_res/6 >= xres > optical_res/8 */
used_res = session.optical_resolution / 6;
else if (i < 10) /* optical_res/8 >= xres > optical_res/10 */
used_res = session.optical_resolution / 8;
else if (i < 12) /* optical_res/10 >= xres > optical_res/12 */
used_res = session.optical_resolution / 10;
else if (i < 15) /* optical_res/12 >= xres > optical_res/15 */
used_res = session.optical_resolution / 12;
else
used_res = session.optical_resolution / 15;
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 */

Wyświetl plik

@ -1402,7 +1402,6 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
{
int start;
int used_res;
int used_pixels;
unsigned int lincnt;
int exposure;
@ -1462,11 +1461,7 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
}
DBG(DBG_info, "%s: stagger=%d lines\n", __func__, stagger);
if (session.params.xres <= (unsigned) session.optical_resolution) {
used_res = session.params.xres;
} else {
used_res = session.optical_resolution;
}
int used_res = session.params.xres;
/* compute scan parameters values */
/* pixels are allways given at half or full CCD optical resolution */

Wyświetl plik

@ -183,15 +183,6 @@ static const SensorProfile& get_sensor_profile(const Genesys_Sensor& sensor, uns
return sensor.sensor_profiles[best_i];
}
/**@brief compute exposure to use
* compute the sensor exposure based on target resolution
*/
static unsigned gl846_compute_exposure(const Genesys_Sensor& sensor, unsigned xres)
{
return get_sensor_profile(sensor, xres).exposure_lperiod;
}
/** @brief sensor specific settings
*/
static void gl846_setup_sensor(Genesys_Device * dev, const Genesys_Sensor& sensor,
@ -956,7 +947,6 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
DBG_HELPER(dbg);
session.assert_computed();
int used_res;
int start, used_pixels;
int bytes_per_line;
int move;
@ -981,14 +971,7 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
}
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
{
/* resolution is choosen from a list */
used_res = session.params.xres;
}
unsigned used_res = session.params.xres;
/* compute scan parameters values */
/* pixels are allways given at full optical resolution */
@ -1022,7 +1005,7 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
slope_dpi = slope_dpi * (1 + dummy);
exposure_time = gl846_compute_exposure(sensor, used_res);
exposure_time = get_sensor_profile(sensor, used_res).exposure_lperiod;
scan_step_type = sanei_genesys_compute_step_type(gl846_motor_profiles, dev->model->motor_type,
exposure_time);
@ -1208,7 +1191,7 @@ gl846_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
slope_dpi = slope_dpi * (1 + dummy);
exposure_time = gl846_compute_exposure(sensor, used_res);
exposure_time = get_sensor_profile(sensor, used_res).exposure_lperiod;
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
max_shift = sanei_genesys_compute_max_shift(dev, session.params.channels, session.params.yres, 0);

Wyświetl plik

@ -178,15 +178,6 @@ static const SensorProfile& get_sensor_profile(const Genesys_Sensor& sensor, uns
return sensor.sensor_profiles[best_i];
}
/**@brief compute exposure to use
* compute the sensor exposure based on target resolution
*/
static int gl847_compute_exposure(const Genesys_Sensor& sensor, unsigned xres)
{
return get_sensor_profile(sensor, xres).exposure_lperiod;
}
/** @brief sensor specific settings
*/
static void gl847_setup_sensor(Genesys_Device * dev, const Genesys_Sensor& sensor,
@ -975,7 +966,6 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
DBG_HELPER(dbg);
session.assert_computed();
int used_res;
int start, used_pixels;
int bytes_per_line;
int move;
@ -1000,13 +990,7 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
}
DBG(DBG_info, "%s : stagger=%d lines\n", __func__, stagger);
/* used_res */
if (session.params.flags & SCAN_FLAG_USE_OPTICAL_RES) {
used_res = session.optical_resolution;
} else {
/* resolution is choosen from a list */
used_res = session.params.xres;
}
unsigned used_res = session.params.xres;
/* compute scan parameters values */
/* pixels are allways given at full optical resolution */
@ -1039,7 +1023,7 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
slope_dpi = slope_dpi * (1 + dummy);
exposure_time = gl847_compute_exposure(sensor, used_res);
exposure_time = get_sensor_profile(sensor, used_res).exposure_lperiod;
scan_step_type = sanei_genesys_compute_step_type(gl847_motor_profiles, dev->model->motor_type,
exposure_time);
@ -1225,7 +1209,7 @@ gl847_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
slope_dpi = slope_dpi * (1 + dummy);
exposure_time = gl847_compute_exposure(sensor, used_res);
exposure_time = get_sensor_profile(sensor, used_res).exposure_lperiod;
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
max_shift = sanei_genesys_compute_max_shift(dev, session.params.channels, session.params.yres, 0);

Wyświetl plik

@ -1510,7 +1510,7 @@ bool sanei_genesys_is_compatible_calibration(Genesys_Device * dev, const Genesys
#ifdef HAVE_SYS_TIME_H
struct timeval time;
#endif
int compatible = 1, resolution;
int compatible = 1;
if(dev->cmd_set->calculate_current_setup == nullptr) {
DBG (DBG_proc, "%s: no calculate_setup, non compatible cache\n", __func__);
@ -1525,12 +1525,7 @@ bool sanei_genesys_is_compatible_calibration(Genesys_Device * dev, const Genesys
* requested scan. In the case of CIS scanners, dpi isn't a criteria */
if (dev->model->is_cis == SANE_FALSE)
{
resolution = dev->settings.xres;
if(resolution>sensor.optical_res)
{
resolution=sensor.optical_res;
}
compatible = (resolution == ((int) cache->used_setup.xres));
compatible = (dev->settings.xres == ((int) cache->used_setup.xres));
}
else
{