diff --git a/backend/genesys_gl124.cc b/backend/genesys_gl124.cc index 169d720b2..9f6bf52f0 100644 --- a/backend/genesys_gl124.cc +++ b/backend/genesys_gl124.cc @@ -1092,8 +1092,7 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens debug_dump(DBG_info, session.params); - unsigned optical_res = sensor.optical_res / session.ccd_size_divisor; - DBG (DBG_info, "%s: optical_res=%d\n", __func__, optical_res); + DBG (DBG_info, "%s: optical_res=%d\n", __func__, session.optical_resolution); /* stagger */ if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) { @@ -1105,14 +1104,14 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens /** @brief compute used resolution */ if (session.params.flags & SCAN_FLAG_USE_OPTICAL_RES) { - used_res = 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 > optical_res) { - used_res = optical_res; + if (session.params.xres > session.optical_resolution) { + used_res = session.optical_resolution; } else { used_res = session.params.xres; } @@ -1127,11 +1126,11 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens start |= 1; /* compute correct pixels number */ - used_pixels = (session.params.pixels * optical_res) / session.params.xres; + used_pixels = (session.params.pixels * session.optical_resolution) / session.params.xres; DBG (DBG_info, "%s: used_pixels=%d\n", __func__, used_pixels); /* round up pixels number if needed */ - if (used_pixels * session.params.xres < session.params.pixels * optical_res) { + if (used_pixels * session.params.xres < session.params.pixels * session.optical_resolution) { used_pixels++; } @@ -1202,7 +1201,7 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens /*** prepares data reordering ***/ /* words_per_line */ - bytes_per_line = (used_pixels * used_res) / optical_res; + bytes_per_line = (used_pixels * used_res) / 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, @@ -1231,7 +1230,7 @@ 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 = (used_pixels * used_res) / optical_res; + dev->current_setup.pixels = (used_pixels * used_res) / 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; diff --git a/backend/genesys_gl646.cc b/backend/genesys_gl646.cc index 2dd39a502..a66a338f7 100644 --- a/backend/genesys_gl646.cc +++ b/backend/genesys_gl646.cc @@ -351,7 +351,7 @@ static void gl646_setup_registers(Genesys_Device* dev, startx |= 1; } - uint32_t pixels = (session.params.pixels * sensor.optical_res) / session.params.xres; + uint32_t pixels = (session.params.pixels * session.optical_resolution) / session.params.xres; // special requirement for 400 dpi on 1200 dpi sensors if (session.params.xres == 400) { pixels = (pixels / 6) * 6; @@ -374,12 +374,9 @@ static void gl646_setup_registers(Genesys_Device* dev, DBG(DBG_info, "%s: startx=%d, endx=%d, linecnt=%d\n", __func__, startx, endx, linecnt); /* x resolution is capped by sensor's capability */ - if (resolution > sensor.optical_res) - { - xresolution = sensor.optical_res; - } - else - { + if (static_cast(resolution) > session.optical_resolution) { + xresolution = session.optical_resolution; + } else { xresolution = resolution; } diff --git a/backend/genesys_gl841.cc b/backend/genesys_gl841.cc index c901f16e3..b1ebd88a8 100644 --- a/backend/genesys_gl841.cc +++ b/backend/genesys_gl841.cc @@ -1764,8 +1764,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; - int optical_res; - debug_dump(DBG_info, session.params); /* @@ -1796,10 +1794,6 @@ independent of our calculated values: dev->bytes_to_read */ -/* optical_res */ - - optical_res = sensor.optical_res / session.ccd_size_divisor; - /* stagger */ if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) { @@ -1810,39 +1804,39 @@ independent of our calculated values: DBG(DBG_info, "%s : stagger=%d lines\n", __func__, stagger); /* used_res */ - i = optical_res / session.params.xres; + 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 - used_res = optical_res; + used_res = session.optical_resolution; } else if (i < 3) /* optical_res/2 >= xres > optical_res/3 */ - used_res = optical_res/2; + used_res = session.optical_resolution/2; else if (i < 4) /* optical_res/3 >= xres > optical_res/4 */ - used_res = optical_res/3; + used_res = session.optical_resolution/3; else if (i < 5) /* optical_res/4 >= xres > optical_res/5 */ - used_res = optical_res/4; + used_res = session.optical_resolution/4; else if (i < 6) /* optical_res/5 >= xres > optical_res/6 */ - used_res = optical_res/5; + used_res = session.optical_resolution/5; else if (i < 8) /* optical_res/6 >= xres > optical_res/8 */ - used_res = optical_res/6; + used_res = session.optical_resolution/6; else if (i < 10) /* optical_res/8 >= xres > optical_res/10 */ - used_res = optical_res/8; + used_res = session.optical_resolution/8; else if (i < 12) /* optical_res/10 >= xres > optical_res/12 */ - used_res = optical_res/10; + used_res = session.optical_resolution/10; else if (i < 15) /* optical_res/12 >= xres > optical_res/15 */ - used_res = optical_res/12; + used_res = session.optical_resolution/12; else - used_res = optical_res/15; + used_res = session.optical_resolution/15; /* 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 * optical_res) / used_res; + // needs to be aligned for used_res + start = (start * session.optical_resolution) / used_res; start += sensor.dummy_pixel + 1; @@ -1855,15 +1849,15 @@ independent of our calculated values: * scan, where shading data needs to be align */ if((dev->reg.find_reg(0x01).value & REG01_SHDAREA) != 0) { - avg=optical_res/used_res; + avg = session.optical_resolution / used_res; start=(start/avg)*avg; } /* compute correct pixels number */ - used_pixels = (session.params.pixels * optical_res) / session.params.xres; + used_pixels = (session.params.pixels * session.optical_resolution) / session.params.xres; /* round up pixels number if needed */ - if (used_pixels * session.params.xres < session.params.pixels * optical_res) { + if (used_pixels * session.params.xres < session.params.pixels * session.optical_resolution) { used_pixels++; } @@ -1967,7 +1961,7 @@ dummy \ scanned lines /*** prepares data reordering ***/ /* words_per_line */ - bytes_per_line = (used_pixels * used_res) / optical_res; + bytes_per_line = (used_pixels * used_res) / session.optical_resolution; bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8; requested_buffer_size = 8 * bytes_per_line; @@ -1997,7 +1991,7 @@ dummy \ scanned lines dev->read_active = SANE_TRUE; dev->session = session; - dev->current_setup.pixels = (used_pixels * used_res)/optical_res; + dev->current_setup.pixels = (used_pixels * used_res) / session.optical_resolution; dev->current_setup.lines = lincnt; dev->current_setup.exposure_time = exposure_time; dev->current_setup.xres = used_res; @@ -2049,8 +2043,6 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se int scan_step_type = 1; int max_shift; - int optical_res; - DBG(DBG_info, "%s ", __func__); debug_dump(DBG_info, dev->settings); @@ -2080,10 +2072,6 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se DBG(DBG_info, "%s ", __func__); debug_dump(DBG_info, session.params); -/* optical_res */ - - optical_res = sensor.optical_res / session.ccd_size_divisor; - /* stagger */ if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) { @@ -2094,38 +2082,38 @@ 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 = optical_res / session.params.xres; + 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 = optical_res; + used_res = session.optical_resolution; else if (i < 3) /* optical_res/2 >= xres > optical_res/3 */ - used_res = optical_res/2; + used_res = session.optical_resolution / 2; else if (i < 4) /* optical_res/3 >= xres > optical_res/4 */ - used_res = optical_res/3; + used_res = session.optical_resolution / 3; else if (i < 5) /* optical_res/4 >= xres > optical_res/5 */ - used_res = optical_res/4; + used_res = session.optical_resolution / 4; else if (i < 6) /* optical_res/5 >= xres > optical_res/6 */ - used_res = optical_res/5; + used_res = session.optical_resolution / 5; else if (i < 8) /* optical_res/6 >= xres > optical_res/8 */ - used_res = optical_res/6; + used_res = session.optical_resolution / 6; else if (i < 10) /* optical_res/8 >= xres > optical_res/10 */ - used_res = optical_res/8; + used_res = session.optical_resolution / 8; else if (i < 12) /* optical_res/10 >= xres > optical_res/12 */ - used_res = optical_res/10; + used_res = session.optical_resolution / 10; else if (i < 15) /* optical_res/12 >= xres > optical_res/15 */ - used_res = optical_res/12; + used_res = session.optical_resolution / 12; else - used_res = optical_res/15; + used_res = session.optical_resolution / 15; /* 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 * optical_res) / used_res; + // needs to be aligned for used_res + start = (start * session.optical_resolution) / used_res; start += sensor.dummy_pixel + 1; @@ -2133,10 +2121,10 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se start |= 1; } - used_pixels = (session.params.pixels * optical_res) / session.params.xres; + used_pixels = (session.params.pixels * session.optical_resolution) / session.params.xres; // round up pixels number if needed - if (used_pixels * session.params.xres < session.params.pixels * optical_res) { + if (used_pixels * session.params.xres < session.params.pixels * session.optical_resolution) { used_pixels++; } @@ -2191,7 +2179,7 @@ dummy \ scanned lines lincnt = session.params.lines + max_shift + stagger; dev->session = session; - dev->current_setup.pixels = (used_pixels * used_res)/optical_res; + dev->current_setup.pixels = (used_pixels * used_res) / session.optical_resolution; dev->current_setup.lines = lincnt; dev->current_setup.exposure_time = exposure_time; dev->current_setup.xres = used_res; diff --git a/backend/genesys_gl843.cc b/backend/genesys_gl843.cc index b2b12a1d4..a78aa5c0b 100644 --- a/backend/genesys_gl843.cc +++ b/backend/genesys_gl843.cc @@ -1201,9 +1201,6 @@ static void gl843_compute_session(Genesys_Device* dev, ScanSession& s, // compute optical and output resolutions s.hwdpi_divisor = sensor.get_hwdpi_divisor_for_dpi(s.params.xres); - s.optical_resolution = sensor.optical_res / s.ccd_size_divisor; - s.output_resolution = s.params.xres; - if (s.output_resolution > s.optical_resolution) { throw std::runtime_error("output resolution higher than optical resolution"); } @@ -1413,8 +1410,6 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor int max_shift; - int optical_res; - DBG(DBG_info, "%s ", __func__); debug_dump(DBG_info, dev->settings); @@ -1458,9 +1453,6 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor DBG(DBG_info, "%s ", __func__); debug_dump(DBG_info, session.params); - // optical_res - optical_res = sensor.optical_res / session.ccd_size_divisor; - /* stagger */ if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) { stagger = (4 * session.params.yres) / dev->motor.base_ydpi; @@ -1469,10 +1461,10 @@ 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) optical_res) { + if (session.params.xres <= (unsigned) session.optical_resolution) { used_res = session.params.xres; } else { - used_res = optical_res; + used_res = session.optical_resolution; } /* compute scan parameters values */ @@ -1480,7 +1472,7 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor /* use detected left margin and fixed value */ /* compute correct pixels number */ - used_pixels = (session.params.pixels * optical_res) / session.params.xres; + used_pixels = (session.params.pixels * session.optical_resolution) / session.params.xres; DBG(DBG_info, "%s: used_pixels=%d\n", __func__, used_pixels); /* exposure */ @@ -1509,7 +1501,7 @@ 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 = (used_pixels * used_res) / optical_res; + dev->current_setup.pixels = (used_pixels * used_res) / 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; diff --git a/backend/genesys_gl846.cc b/backend/genesys_gl846.cc index 84de797ce..c395659ee 100644 --- a/backend/genesys_gl846.cc +++ b/backend/genesys_gl846.cc @@ -971,12 +971,8 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens int max_shift; size_t requested_buffer_size, read_buffer_size; - int optical_res; - debug_dump(DBG_info, session.params); - optical_res = sensor.optical_res / session.ccd_size_divisor; - /* stagger */ if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) { stagger = (4 * session.params.yres) / dev->motor.base_ydpi; @@ -986,7 +982,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 = optical_res; + used_res = session.optical_resolution; } else { @@ -1006,10 +1002,10 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens } /* compute correct pixels number */ - used_pixels = (session.params.pixels * optical_res) / session.params.xres; + used_pixels = (session.params.pixels * session.optical_resolution) / session.params.xres; /* round up pixels number if needed */ - if (used_pixels * session.params.xres < session.params.pixels * optical_res) { + if (used_pixels * session.params.xres < session.params.pixels * session.optical_resolution) { used_pixels++; } @@ -1074,7 +1070,7 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens /*** prepares data reordering ***/ /* words_per_line */ - bytes_per_line = (used_pixels * used_res) / optical_res; + bytes_per_line = (used_pixels * used_res) / session.optical_resolution; bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8; requested_buffer_size = 8 * bytes_per_line; @@ -1100,7 +1096,7 @@ 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 = (used_pixels * used_res) / optical_res; + dev->current_setup.pixels = (used_pixels * used_res) / session.optical_resolution; dev->current_setup.lines = lincnt; dev->current_setup.exposure_time = exposure_time; dev->current_setup.xres = used_res; diff --git a/backend/genesys_gl847.cc b/backend/genesys_gl847.cc index e67f73fd9..35e313fca 100644 --- a/backend/genesys_gl847.cc +++ b/backend/genesys_gl847.cc @@ -990,12 +990,8 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens int max_shift; size_t requested_buffer_size, read_buffer_size; - int optical_res; - debug_dump(DBG_info, session.params); - optical_res = sensor.optical_res / session.ccd_size_divisor; - /* stagger */ if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) { stagger = (4 * session.params.yres) / dev->motor.base_ydpi; @@ -1006,10 +1002,8 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens /* used_res */ if (session.params.flags & SCAN_FLAG_USE_OPTICAL_RES) { - used_res = optical_res; - } - else - { + used_res = session.optical_resolution; + } else { /* resolution is choosen from a list */ used_res = session.params.xres; } @@ -1026,10 +1020,10 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens /* compute correct pixels number */ /* pixels */ - used_pixels = (session.params.pixels * optical_res) / session.params.xres; + used_pixels = (session.params.pixels * session.optical_resolution) / session.params.xres; /* round up pixels number if needed */ - if (used_pixels * session.params.xres < session.params.pixels * optical_res) { + if (used_pixels * session.params.xres < session.params.pixels * session.optical_resolution) { used_pixels++; } dummy = 3 - session.params.channels; @@ -1091,7 +1085,7 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens /*** prepares data reordering ***/ /* words_per_line */ - bytes_per_line = (used_pixels * used_res) / optical_res; + bytes_per_line = (used_pixels * used_res) / session.optical_resolution; bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8; requested_buffer_size = 8 * bytes_per_line; @@ -1117,7 +1111,7 @@ 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 = (used_pixels * used_res) / optical_res; + dev->current_setup.pixels = (used_pixels * used_res) / session.optical_resolution; dev->current_setup.lines = lincnt; dev->current_setup.exposure_time = exposure_time; dev->current_setup.xres = used_res; diff --git a/backend/genesys_low.cc b/backend/genesys_low.cc index b761ffc0c..cb43160b8 100644 --- a/backend/genesys_low.cc +++ b/backend/genesys_low.cc @@ -1139,6 +1139,13 @@ void compute_session(Genesys_Device* dev, ScanSession& s, const Genesys_Sensor& // compute optical and output resolutions s.ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(s.params.xres); + + if (dev->model->asic_type == AsicType::GL646) { + s.optical_resolution = sensor.optical_res; + } else { + s.optical_resolution = sensor.optical_res / s.ccd_size_divisor; + } + s.output_resolution = s.params.xres; } /** @brief initialize device diff --git a/backend/genesys_settings.h b/backend/genesys_settings.h index 6551db1c2..6a391ecf2 100644 --- a/backend/genesys_settings.h +++ b/backend/genesys_settings.h @@ -205,7 +205,6 @@ struct ScanSession { unsigned ccd_size_divisor = 1; // the optical resolution of the scanner. - // gl843-only unsigned optical_resolution = 0; // the number of pixels at the optical resolution.