genesys: Assume correct resolution is passed from high-level

merge-requests/146/head
Povilas Kanapickas 2019-08-24 10:00:52 +03:00
rodzic 9a21a8335f
commit ec5225e1f8
5 zmienionych plików z 25 dodań i 75 usunięć

Wyświetl plik

@ -1272,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 */

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

@ -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
{