Merge branch 'genesys-sensor-optical-resolution' into 'master'

genesys: Add real optical resolution to sensor structs

See merge request sane-project/backends!456
merge-requests/463/merge
Povilas Kanapickas 2020-05-18 03:50:52 +00:00
commit 0415fb4b7d
16 zmienionych plików z 313 dodań i 414 usunięć

Wyświetl plik

@ -198,7 +198,7 @@ void genesys_deskew(Genesys_Scanner *s, const Genesys_Sensor& sensor)
bg=0xff;
}
TIE(sanei_magic_findSkew(&s->params, dev->img_buffer.data(),
sensor.optical_res, sensor.optical_res,
sensor.full_resolution, sensor.full_resolution,
&x, &y, &slope));
DBG(DBG_info, "%s: slope=%f => %f\n", __func__, slope, slope * 180 / M_PI);

Wyświetl plik

@ -1498,13 +1498,13 @@ void scanner_offset_calibration(Genesys_Device& dev, const Genesys_Sensor& senso
}
}
unsigned target_pixels = dev.model->x_size_calib_mm * sensor.optical_res / MM_PER_INCH;
unsigned target_pixels = dev.model->x_size_calib_mm * sensor.full_resolution / MM_PER_INCH;
unsigned start_pixel = 0;
unsigned black_pixels = (sensor.black_pixels * sensor.optical_res) / sensor.optical_res;
unsigned black_pixels = (sensor.black_pixels * sensor.full_resolution) / sensor.full_resolution;
unsigned channels = 3;
unsigned lines = 1;
unsigned resolution = sensor.optical_res;
unsigned resolution = sensor.full_resolution;
const Genesys_Sensor* calib_sensor = &sensor;
if (dev.model->asic_type == AsicType::GL843) {
@ -1514,7 +1514,7 @@ void scanner_offset_calibration(Genesys_Device& dev, const Genesys_Sensor& senso
const auto& dpihw_sensor = sanei_genesys_find_sensor(&dev, dev.settings.xres, channels,
dev.settings.scan_method);
resolution = dpihw_sensor.shading_resolution;
unsigned factor = sensor.optical_res / resolution;
unsigned factor = sensor.full_resolution / resolution;
calib_sensor = &sanei_genesys_find_sensor(&dev, resolution, channels,
dev.settings.scan_method);
@ -1524,12 +1524,10 @@ void scanner_offset_calibration(Genesys_Device& dev, const Genesys_Sensor& senso
if (should_calibrate_only_active_area(dev, dev.settings)) {
float offset = dev.model->x_offset_ta;
offset /= calib_sensor->get_ccd_size_divisor_for_dpi(resolution);
start_pixel = static_cast<int>((offset * resolution) / MM_PER_INCH);
start_pixel = static_cast<int>((offset * calib_sensor->get_optical_resolution()) / MM_PER_INCH);
float size = dev.model->x_size_ta;
size /= calib_sensor->get_ccd_size_divisor_for_dpi(resolution);
target_pixels = static_cast<int>((size * resolution) / MM_PER_INCH);
target_pixels = static_cast<int>((size * calib_sensor->get_optical_resolution()) / MM_PER_INCH);
}
if (dev.model->model_id == ModelId::CANON_4400F &&
@ -1794,7 +1792,7 @@ void scanner_coarse_gain_calibration(Genesys_Device& dev, const Genesys_Sensor&
// coarse gain calibration is always done in color mode
unsigned channels = 3;
unsigned resolution = sensor.optical_res;
unsigned resolution = sensor.full_resolution;
if (dev.model->asic_type == AsicType::GL841) {
const auto& dpihw_sensor = sanei_genesys_find_sensor(&dev, dev.settings.xres, channels,
dev.settings.scan_method);
@ -1818,7 +1816,7 @@ void scanner_coarse_gain_calibration(Genesys_Device& dev, const Genesys_Sensor&
dev.model->asic_type == AsicType::GL847 ||
dev.model->asic_type == AsicType::GL124)
{
if (dev.settings.xres < sensor.optical_res) {
if (dev.settings.xres < sensor.full_resolution) {
coeff = 0.9f;
}
}
@ -2385,7 +2383,7 @@ static void genesys_shading_calibration_impl(Genesys_Device* dev, const Genesys_
// BUG: we are using wrong pixel number here
unsigned start_offset =
dev->calib_session.params.startx * sensor.optical_res / dev->calib_session.params.xres;
dev->calib_session.params.startx * sensor.full_resolution / dev->calib_session.params.xres;
unsigned out_pixels_per_line = pixels_per_line + start_offset;
// FIXME: we set this during both dark and white calibration. A cleaner approach should
@ -2509,7 +2507,7 @@ static void genesys_dummy_dark_shading(Genesys_Device* dev, const Genesys_Sensor
// BUG: we are using wrong pixel number here
unsigned start_offset =
dev->calib_session.params.startx * sensor.optical_res / dev->calib_session.params.xres;
dev->calib_session.params.startx * sensor.full_resolution / dev->calib_session.params.xres;
unsigned out_pixels_per_line = pixels_per_line + start_offset;
@ -2519,8 +2517,7 @@ static void genesys_dummy_dark_shading(Genesys_Device* dev, const Genesys_Sensor
/* we average values on 'the left' where CCD pixels are under casing and
give darkest values. We then use these as dummy dark calibration */
if (dev->settings.xres <= sensor.optical_res / 2)
{
if (dev->settings.xres <= sensor.full_resolution / 2) {
skip = 4;
xend = 36;
}
@ -2636,7 +2633,7 @@ static void genesys_dark_white_shading_calibration(Genesys_Device* dev,
// BUG: we are using wrong pixel number here
unsigned start_offset =
dev->calib_session.params.startx * sensor.optical_res / dev->calib_session.params.xres;
dev->calib_session.params.startx * sensor.full_resolution / dev->calib_session.params.xres;
unsigned out_pixels_per_line = pixels_per_line + start_offset;
@ -2868,13 +2865,12 @@ compute_averaged_planar (Genesys_Device * dev, const Genesys_Sensor& sensor,
*/
res = dev->settings.xres;
if (sensor.get_ccd_size_divisor_for_dpi(dev->settings.xres) > 1)
{
if (sensor.full_resolution > sensor.get_optical_resolution()) {
res *= 2;
}
/* this should be evenly dividable */
basepixels = sensor.optical_res / res;
// this should be evenly dividable
basepixels = sensor.full_resolution / res;
/* gl841 supports 1/1 1/2 1/3 1/4 1/5 1/6 1/8 1/10 1/12 1/15 averaging */
if (basepixels < 1)
@ -3159,9 +3155,10 @@ compute_shifted_coefficients (Genesys_Device * dev,
auto cmat = color_order_to_cmat(color_order);
x = dev->settings.xres;
if (sensor.get_ccd_size_divisor_for_dpi(dev->settings.xres) > 1)
x *= 2; /* scanner is using half-ccd mode */
basepixels = sensor.optical_res / x; /*this should be evenly dividable */
if (sensor.full_resolution > sensor.get_optical_resolution()) {
x *= 2; // scanner is using half-ccd mode
}
basepixels = sensor.full_resolution / x; // this should be evenly dividable
/* gl841 supports 1/1 1/2 1/3 1/4 1/5 1/6 1/8 1/10 1/12 1/15 averaging */
if (basepixels < 1)
@ -3247,7 +3244,7 @@ static void genesys_send_shading_coefficient(Genesys_Device* dev, const Genesys_
// BUG: we are using wrong pixel number here
unsigned start_offset =
dev->calib_session.params.startx * sensor.optical_res / dev->calib_session.params.xres;
dev->calib_session.params.startx * sensor.full_resolution / dev->calib_session.params.xres;
if (dev->model->asic_type == AsicType::GL842 ||
dev->model->asic_type == AsicType::GL843)
@ -3315,13 +3312,10 @@ static void genesys_send_shading_coefficient(Genesys_Device* dev, const Genesys_
}
/* compute avg factor */
if(dev->settings.xres>sensor.optical_res)
{
factor=1;
}
else
{
factor=sensor.optical_res/dev->settings.xres;
if (dev->settings.xres > sensor.full_resolution) {
factor = 1;
} else {
factor = sensor.full_resolution / dev->settings.xres;
}
/* for GL646, shading data is planar if REG_0x01_FASTMOD is set and
@ -3370,10 +3364,9 @@ static void genesys_send_shading_coefficient(Genesys_Device* dev, const Genesys_
case SensorId::CCD_HP2300:
target_code = 0xdc00;
o = 2;
if(dev->settings.xres<=sensor.optical_res/2)
{
o = o - sensor.dummy_pixel / 2;
}
if (dev->settings.xres <= sensor.full_resolution / 2) {
o = o - sensor.dummy_pixel / 2;
}
compute_coefficients (dev,
shading_data.data(),
pixels_per_line,
@ -3386,7 +3379,7 @@ static void genesys_send_shading_coefficient(Genesys_Device* dev, const Genesys_
case SensorId::CCD_5345:
target_code = 0xe000;
o = 4;
if(dev->settings.xres<=sensor.optical_res/2)
if(dev->settings.xres<=sensor.full_resolution/2)
{
o = o - sensor.dummy_pixel;
}
@ -3628,8 +3621,8 @@ static void genesys_flatbed_calibration(Genesys_Device* dev, Genesys_Sensor& sen
DBG_HELPER(dbg);
uint32_t pixels_per_line;
unsigned coarse_res = sensor.optical_res;
if (dev->settings.yres <= sensor.optical_res / 2) {
unsigned coarse_res = sensor.full_resolution;
if (dev->settings.yres <= sensor.full_resolution / 2) {
coarse_res /= 2;
}
@ -3758,7 +3751,7 @@ static void genesys_sheetfed_calibration(Genesys_Device* dev, Genesys_Sensor& se
// first step, load document
dev->cmd_set->load_document(dev);
unsigned coarse_res = sensor.optical_res;
unsigned coarse_res = sensor.full_resolution;
/* the afe needs to sends valid data even before calibration */
@ -3862,7 +3855,7 @@ static void genesys_sheetfed_calibration(Genesys_Device* dev, Genesys_Sensor& se
dev->cmd_set->eject_document(dev);
// restore settings
dev->settings.xres = sensor.optical_res;
dev->settings.xres = sensor.full_resolution;
}
/**
@ -4347,10 +4340,10 @@ static void calc_parameters(Genesys_Scanner* s)
const auto& sensor = sanei_genesys_find_sensor_any(s->dev);
// hardware settings
if (static_cast<unsigned>(s->resolution) > sensor.optical_res &&
if (static_cast<unsigned>(s->resolution) > sensor.full_resolution &&
s->dev->settings.disable_interpolation)
{
s->dev->settings.xres = sensor.optical_res;
s->dev->settings.xres = sensor.full_resolution;
} else {
s->dev->settings.xres = s->resolution;
}

Wyświetl plik

@ -367,7 +367,7 @@ gl124_init_registers (Genesys_Device * dev)
// fine tune upon device description
const auto& sensor = sanei_genesys_find_sensor_any(dev);
const auto& dpihw_sensor = sanei_genesys_find_sensor(dev, sensor.optical_res,
const auto& dpihw_sensor = sanei_genesys_find_sensor(dev, sensor.full_resolution,
3, ScanMethod::FLATBED);
sanei_genesys_set_dpihw(dev->reg, dpihw_sensor.register_dpihw);
}
@ -528,7 +528,7 @@ static void gl124_init_motor_regs_scan(Genesys_Device* dev,
r02 |= REG_0x02_AGOHOME;
}
if (has_flag(flags, ScanFlag::DISABLE_BUFFER_FULL_MOVE) || (yres >= sensor.optical_res))
if (has_flag(flags, ScanFlag::DISABLE_BUFFER_FULL_MOVE) || (yres >= sensor.full_resolution))
{
r02 |= REG_0x02_ACDCDIS;
}
@ -609,22 +609,6 @@ static void gl124_init_motor_regs_scan(Genesys_Device* dev,
reg->set16(REG_FMOVDEC, fast_table.table.size());
}
/** @brief setup optical related registers
* start and pixels are expressed in optical sensor resolution coordinate
* space.
* @param dev scanner device to use
* @param reg registers to set up
* @param exposure_time exposure time to use
* @param used_res scanning resolution used, may differ from
* scan's one
* @param start logical start pixel coordinate
* @param pixels logical number of pixels to use
* @param channels number of color channels (currently 1 or 3)
* @param depth bit depth of the scan (1, 8 or 16)
* @param ccd_size_divisor whether sensor's timings are such that x coordinates must be halved
* @param color_filter color channel to use as gray data
* @param flags optical flags (@see )
*/
static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg, unsigned int exposure_time,
const ScanSession& session)
@ -743,7 +727,8 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
// MAXWD is expressed in 2 words unit
// BUG: we shouldn't multiply by channels here
reg->set24(REG_MAXWD, session.output_line_bytes_raw / session.ccd_size_divisor * session.params.channels);
reg->set24(REG_MAXWD, session.output_line_bytes_raw * session.params.channels *
session.optical_resolution / session.full_resolution);
reg->set24(REG_LPERIOD, exposure_time);
reg->set16(REG_DUMMY, sensor.dummy_pixel);
}
@ -819,7 +804,7 @@ ScanSession CommandSetGl124::calculate_scan_session(const Genesys_Device* dev,
float start = dev->model->x_offset;
start += settings.tl_x;
start /= sensor.get_ccd_size_divisor_for_dpi(settings.xres);
start /= sensor.full_resolution / sensor.get_optical_resolution();
start = static_cast<float>((start * settings.xres) / MM_PER_INCH);
ScanSession session;
@ -1230,11 +1215,11 @@ void CommandSetGl124::init_regs_for_warmup(Genesys_Device* dev, const Genesys_Se
}
ScanSession session;
session.params.xres = sensor.optical_res;
session.params.xres = sensor.full_resolution;
session.params.yres = dev->motor.base_ydpi;
session.params.startx = dev->model->x_size_calib_mm * sensor.optical_res / MM_PER_INCH / 4;
session.params.startx = dev->model->x_size_calib_mm * sensor.full_resolution / MM_PER_INCH / 4;
session.params.starty = 0;
session.params.pixels = dev->model->x_size_calib_mm * sensor.optical_res / MM_PER_INCH / 2;
session.params.pixels = dev->model->x_size_calib_mm * sensor.full_resolution / MM_PER_INCH / 2;
session.params.lines = 1;
session.params.depth = dev->model->bpp_color_values.front();
session.params.channels = 3;

Wyświetl plik

@ -600,7 +600,7 @@ void CommandSetGl646::init_regs_for_scan_session(Genesys_Device* dev, const Gene
break;
}
sanei_genesys_set_dpihw(*regs, sensor.optical_res);
sanei_genesys_set_dpihw(*regs, sensor.full_resolution);
/* gamma enable for scans */
if (has_flag(dev->model->flags, ModelFlag::GAMMA_14BIT)) {
@ -932,7 +932,7 @@ gl646_init_regs (Genesys_Device * dev)
const auto& sensor = sanei_genesys_find_sensor_any(dev);
dev->reg.find_reg(0x05).value = 0x00; /* 12 bits gamma, disable gamma, 24 clocks/pixel */
sanei_genesys_set_dpihw(dev->reg, sensor.optical_res);
sanei_genesys_set_dpihw(dev->reg, sensor.full_resolution);
if (has_flag(dev->model->flags, ModelFlag::GAMMA_14BIT)) {
dev->reg.find_reg(0x05).value |= REG_0x05_GMM14BIT;
@ -1116,8 +1116,7 @@ static void gl646_wm_hp3670(Genesys_Device* dev, const Genesys_Sensor& sensor, u
default: /* AFE_SET */
/* mode setup */
i = dev->frontend.regs.get_value(0x03);
if (dpi > sensor.optical_res / 2)
{
if (dpi > sensor.full_resolution / 2) {
/* fe_reg_0x03 must be 0x12 for 1200 dpi in WOLFSON_HP3670.
* WOLFSON_HP2400 in 1200 dpi mode works well with
* fe_reg_0x03 set to 0x32 or 0x12 but not to 0x02 */
@ -1804,8 +1803,6 @@ void CommandSetGl646::move_back_home(Genesys_Device* dev, bool wait_until_home)
* init registers for shading calibration
* we assume that scanner's head is on an area suiting shading calibration.
* We scan a full scan width area by the shading line number for the device
* at either at full sensor's resolution or half depending upon ccd_size_divisor
* @param dev scanner's device
*/
void CommandSetGl646::init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const
@ -1816,10 +1813,9 @@ void CommandSetGl646::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
/* fill settings for scan : always a color scan */
int channels = 3;
unsigned ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(dev->settings.xres);
unsigned cksel = get_cksel(dev->model->sensor_id, dev->settings.xres, channels);
unsigned resolution = sensor.optical_res / ccd_size_divisor / cksel;
unsigned resolution = sensor.get_optical_resolution() / cksel;
// FIXME: we select wrong calibration sensor
const auto& calib_sensor = sanei_genesys_find_sensor(dev, dev->settings.xres, channels,
dev->settings.scan_method);
@ -1951,11 +1947,11 @@ SensorExposure CommandSetGl646::led_calibration(Genesys_Device* dev, const Genes
}
// offset calibration is always done in color mode
unsigned pixels = dev->model->x_size_calib_mm * sensor.optical_res / MM_PER_INCH;
unsigned pixels = dev->model->x_size_calib_mm * sensor.full_resolution / MM_PER_INCH;
ScanSession session;
session.params.xres = sensor.optical_res;
session.params.yres = sensor.optical_res;
session.params.xres = sensor.full_resolution;
session.params.yres = sensor.full_resolution;
session.params.startx = 0;
session.params.starty = 0;
session.params.pixels = pixels;
@ -2121,11 +2117,11 @@ static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
channels = 3;
// FIXME: maybe reuse `sensor`
const auto& calib_sensor = sanei_genesys_find_sensor(dev, sensor.optical_res, 3,
const auto& calib_sensor = sanei_genesys_find_sensor(dev, sensor.full_resolution, 3,
ScanMethod::FLATBED);
black_pixels = (calib_sensor.black_pixels * sensor.optical_res) / calib_sensor.optical_res;
black_pixels = (calib_sensor.black_pixels * sensor.full_resolution) / calib_sensor.full_resolution;
unsigned pixels = dev->model->x_size_calib_mm * sensor.optical_res / MM_PER_INCH;
unsigned pixels = dev->model->x_size_calib_mm * sensor.full_resolution / MM_PER_INCH;
unsigned lines = CALIBRATION_LINES;
if (dev->model->is_cis) {
@ -2133,8 +2129,8 @@ static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
}
ScanSession session;
session.params.xres = sensor.optical_res;
session.params.yres = sensor.optical_res;
session.params.xres = sensor.full_resolution;
session.params.yres = sensor.full_resolution;
session.params.startx = 0;
session.params.starty = 0;
session.params.pixels = pixels;
@ -2236,7 +2232,7 @@ void CommandSetGl646::offset_calibration(Genesys_Device* dev, const Genesys_Sens
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, channels,
ScanMethod::FLATBED);
black_pixels = (calib_sensor.black_pixels * resolution) / calib_sensor.optical_res;
black_pixels = (calib_sensor.black_pixels * resolution) / calib_sensor.full_resolution;
unsigned pixels = dev->model->x_size_calib_mm * resolution / MM_PER_INCH;
unsigned lines = CALIBRATION_LINES;
@ -2579,7 +2575,7 @@ void CommandSetGl646::init(Genesys_Device* dev) const
// Init shading data
sanei_genesys_init_shading_data(dev, sensor,
dev->model->x_size_calib_mm * sensor.optical_res /
dev->model->x_size_calib_mm * sensor.full_resolution /
MM_PER_INCH);
dev->initial_regs = dev->reg;
@ -2635,7 +2631,7 @@ void CommandSetGl646::init(Genesys_Device* dev) const
if (dev->model->gpio_id != GpioId::HP3670 &&
dev->model->gpio_id != GpioId::HP2400)
{
switch (sensor.optical_res)
switch (sensor.full_resolution)
{
case 600:
addr = 0x08200;
@ -2957,7 +2953,7 @@ static void write_control(Genesys_Device* dev, const Genesys_Sensor& sensor, int
/* MD6471/G2410/HP2300 and XP200 read/write data from an undocumented memory area which
* is after the second slope table */
switch (sensor.optical_res)
switch (sensor.full_resolution)
{
case 600:
addr = 0x08200;

Wyświetl plik

@ -189,8 +189,8 @@ gl841_init_registers (Genesys_Device * dev)
dev->reg.init_reg(0x2c, 0x00);
dev->reg.init_reg(0x2d, 0x00);
if (dev->model->model_id == ModelId::CANON_LIDE_80) {
dev->reg.init_reg(0x2c, sensor.optical_res >> 8);
dev->reg.init_reg(0x2d, sensor.optical_res & 0xff);
dev->reg.init_reg(0x2c, sensor.full_resolution >> 8);
dev->reg.init_reg(0x2d, sensor.full_resolution & 0xff);
}
dev->reg.init_reg(0x2e, 0x80);
dev->reg.init_reg(0x2f, 0x80);
@ -2160,7 +2160,7 @@ void CommandSetGl841::init_regs_for_warmup(Genesys_Device* dev, const Genesys_Se
}
ScanSession session;
session.params.xres = sensor.optical_res;
session.params.xres = sensor.full_resolution;
session.params.yres = dev->settings.yres;
session.params.startx = sensor.dummy_pixel;
session.params.starty = 0;

Wyświetl plik

@ -277,7 +277,7 @@ static void gl842_init_motor_regs_scan(Genesys_Device* dev,
// disable backtracking if needed
if (has_flag(flags, ScanFlag::DISABLE_BUFFER_FULL_MOVE) ||
(scan_yres >= 2400) ||
(scan_yres >= sensor.optical_res))
(scan_yres >= sensor.full_resolution))
{
reg02 |= REG_0x02_ACDCDIS;
}
@ -857,7 +857,7 @@ void CommandSetGl842::init_regs_for_warmup(Genesys_Device* dev, const Genesys_Se
ScanSession session;
session.params.xres = resolution;
session.params.yres = resolution;
session.params.startx = (num_pixels / 2) * resolution / calib_sensor.optical_res;
session.params.startx = (num_pixels / 2) * resolution / calib_sensor.full_resolution;
session.params.starty = 0;
session.params.pixels = num_pixels;
session.params.lines = 1;

Wyświetl plik

@ -123,7 +123,7 @@ gl843_init_registers (Genesys_Device * dev)
initial_scan_method = ScanMethod::TRANSPARENCY;
}
const auto& sensor = sanei_genesys_find_sensor_any(dev);
const auto& dpihw_sensor = sanei_genesys_find_sensor(dev, sensor.optical_res,
const auto& dpihw_sensor = sanei_genesys_find_sensor(dev, sensor.full_resolution,
3, initial_scan_method);
sanei_genesys_set_dpihw(dev->reg, dpihw_sensor.register_dpihw);
@ -729,9 +729,9 @@ static void gl843_init_motor_regs_scan(Genesys_Device* dev,
}
/* disable backtracking */
if (has_flag(flags, ScanFlag::DISABLE_BUFFER_FULL_MOVE)
||(scan_yres>=2400 && dev->model->model_id != ModelId::CANON_4400F)
||(scan_yres>=sensor.optical_res))
if (has_flag(flags, ScanFlag::DISABLE_BUFFER_FULL_MOVE) ||
(scan_yres>=2400 && dev->model->model_id != ModelId::CANON_4400F) ||
(scan_yres>=sensor.full_resolution))
{
reg02 |= REG_0x02_ACDCDIS;
}
@ -836,7 +836,7 @@ static void gl843_init_motor_regs_scan(Genesys_Device* dev,
// FIXME: take this information from motor struct
std::uint8_t reg_vref = reg->get8(0x80);
reg_vref = 0x50;
unsigned coeff = sensor.optical_res / scan_yres;
unsigned coeff = sensor.full_resolution / scan_yres;
if (dev->model->motor_id == MotorId::KVSS080) {
if (coeff >= 1) {
reg_vref |= 0x05;
@ -871,7 +871,6 @@ static void gl843_init_motor_regs_scan(Genesys_Device* dev,
* @param pixels logical number of pixels to use
* @param channels number of color channles used (1 or 3)
* @param depth bit depth of the scan (1, 8 or 16 bits)
* @param ccd_size_divisor true specifies how much x coordinates must be shrunk
* @param color_filter to choose the color channel used in gray scans
* @param flags to drive specific settings such no calibration, XPA use ...
*/
@ -1006,8 +1005,9 @@ static void gl843_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
/* MAXWD is expressed in 2 words unit */
/* nousedspace = (mem_bank_range * 1024 / 256 -1 ) * 4; */
// BUG: the division by ccd_size_divisor likely does not make sense
reg->set24(REG_MAXWD, (session.output_line_bytes / session.ccd_size_divisor) >> 1);
// BUG: the division by optical and full resolution factor likely does not make sense
reg->set24(REG_MAXWD, (session.output_line_bytes *
session.optical_resolution / session.full_resolution) >> 1);
reg->set16(REG_LPERIOD, exposure / tgtime);
reg->set8(REG_DUMMY, sensor.dummy_pixel);
}
@ -1539,7 +1539,7 @@ void CommandSetGl843::init_regs_for_warmup(Genesys_Device* dev, const Genesys_Se
ScanSession session;
session.params.xres = resolution;
session.params.yres = resolution;
session.params.startx = (num_pixels / 2) * resolution / calib_sensor.optical_res;
session.params.startx = (num_pixels / 2) * resolution / calib_sensor.full_resolution;
session.params.starty = 0;
session.params.pixels = num_pixels;
session.params.lines = 1;

Wyświetl plik

@ -299,7 +299,7 @@ gl846_init_registers (Genesys_Device * dev)
}
const auto& sensor = sanei_genesys_find_sensor_any(dev);
const auto& dpihw_sensor = sanei_genesys_find_sensor(dev, sensor.optical_res,
const auto& dpihw_sensor = sanei_genesys_find_sensor(dev, sensor.full_resolution,
3, dev->model->default_method);
sanei_genesys_set_dpihw(dev->reg, dpihw_sensor.register_dpihw);
}
@ -398,7 +398,7 @@ static void gl846_init_motor_regs_scan(Genesys_Device* dev,
reg02 |= REG_0x02_AGOHOME | REG_0x02_NOTHOME;
}
if (has_flag(flags, ScanFlag::DISABLE_BUFFER_FULL_MOVE) || (scan_yres>=sensor.optical_res)) {
if (has_flag(flags, ScanFlag::DISABLE_BUFFER_FULL_MOVE) || (scan_yres>=sensor.full_resolution)) {
reg02 |= REG_0x02_ACDCDIS;
}
if (has_flag(flags, ScanFlag::REVERSE)) {
@ -938,7 +938,7 @@ void CommandSetGl846::send_shading_data(Genesys_Device* dev, const Genesys_Senso
// we're using SHDAREA, thus we only need to upload part of the line
unsigned offset = dev->session.pixel_count_ratio.apply(
dev->session.params.startx * sensor.optical_res / dev->session.params.xres);
dev->session.params.startx * sensor.full_resolution / dev->session.params.xres);
unsigned pixels = dev->session.pixel_count_ratio.apply(dev->session.optical_pixels_raw);
// turn pixel value into bytes 2x16 bits words

Wyświetl plik

@ -210,7 +210,7 @@ gl847_init_registers (Genesys_Device * dev)
}
const auto& sensor = sanei_genesys_find_sensor_any(dev);
const auto& dpihw_sensor = sanei_genesys_find_sensor(dev, sensor.optical_res,
const auto& dpihw_sensor = sanei_genesys_find_sensor(dev, sensor.full_resolution,
3, ScanMethod::FLATBED);
sanei_genesys_set_dpihw(dev->reg, dpihw_sensor.register_dpihw);
}
@ -291,7 +291,7 @@ static void gl847_init_motor_regs_scan(Genesys_Device* dev,
reg02 |= REG_0x02_AGOHOME | REG_0x02_NOTHOME;
}
if (has_flag(flags, ScanFlag::DISABLE_BUFFER_FULL_MOVE) || (scan_yres >= sensor.optical_res)) {
if (has_flag(flags, ScanFlag::DISABLE_BUFFER_FULL_MOVE) || (scan_yres >= sensor.full_resolution)) {
reg02 |= REG_0x02_ACDCDIS;
}
if (has_flag(flags, ScanFlag::REVERSE)) {
@ -779,7 +779,7 @@ void CommandSetGl847::send_shading_data(Genesys_Device* dev, const Genesys_Senso
// we're using SHDAREA, thus we only need to upload part of the line
unsigned offset = dev->session.pixel_count_ratio.apply(
dev->session.params.startx * sensor.optical_res / dev->session.params.xres);
dev->session.params.startx * sensor.full_resolution / dev->session.params.xres);
unsigned pixels = dev->session.pixel_count_ratio.apply(dev->session.optical_pixels_raw);
// turn pixel value into bytes 2x16 bits words

Wyświetl plik

@ -808,8 +808,8 @@ void compute_session_pixel_offsets(const Genesys_Device* dev, ScanSession& s,
const Genesys_Sensor& sensor)
{
if (dev->model->asic_type == AsicType::GL646) {
s.pixel_startx += s.output_startx * sensor.optical_res / s.params.xres;
s.pixel_endx = s.pixel_startx + s.optical_pixels * s.ccd_size_divisor;
s.pixel_startx += s.output_startx * sensor.full_resolution / s.params.xres;
s.pixel_endx = s.pixel_startx + s.optical_pixels * s.full_resolution / s.optical_resolution;
} else if (dev->model->asic_type == AsicType::GL841 ||
dev->model->asic_type == AsicType::GL842 ||
@ -823,7 +823,7 @@ void compute_session_pixel_offsets(const Genesys_Device* dev, ScanSession& s,
dev->model->asic_type == AsicType::GL847 ||
dev->model->asic_type == AsicType::GL124)
{
s.pixel_startx = s.output_startx * sensor.optical_res / s.params.xres;
s.pixel_startx = s.output_startx * sensor.full_resolution / s.params.xres;
s.pixel_endx = s.pixel_startx + s.optical_pixels_raw;
}
@ -896,13 +896,12 @@ void compute_session(const Genesys_Device* dev, ScanSession& s, const Genesys_Se
}
// compute optical and output resolutions
s.ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(s.params.xres);
s.pixel_count_ratio = sensor.pixel_count_ratio;
s.optical_resolution = sensor.optical_res / s.ccd_size_divisor;
s.full_resolution = sensor.full_resolution;
s.optical_resolution = sensor.get_optical_resolution();
s.output_resolution = s.params.xres;
s.pixel_count_ratio = sensor.pixel_count_ratio;
if (s.output_resolution > s.optical_resolution) {
throw std::runtime_error("output resolution higher than optical resolution");
}
@ -923,7 +922,8 @@ void compute_session(const Genesys_Device* dev, ScanSession& s, const Genesys_Se
if (dev->model->asic_type == AsicType::GL843) {
// ensure the number of optical pixels is divisible by 2.
// In quarter-CCD mode optical_pixels is 4x larger than the actual physical number
s.optical_pixels = align_int_up(s.optical_pixels, 2 * s.ccd_size_divisor);
s.optical_pixels = align_int_up(s.optical_pixels,
2 * s.full_resolution / s.optical_resolution);
if (dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7200 ||
dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7200I ||
@ -1005,7 +1005,7 @@ void compute_session(const Genesys_Device* dev, ScanSession& s, const Genesys_Se
}
s.output_line_bytes_raw = multiply_by_depth_ceil(
(s.optical_pixels_raw * s.output_resolution) / sensor.optical_res / s.segment_count,
(s.optical_pixels_raw * s.output_resolution) / sensor.full_resolution / s.segment_count,
s.params.depth);
}
@ -1019,7 +1019,7 @@ void compute_session(const Genesys_Device* dev, ScanSession& s, const Genesys_Se
if (dev->model->is_cis) {
s.output_line_bytes_raw = s.output_channel_bytes;
}
s.conseq_pixel_dist = s.output_pixels / s.ccd_size_divisor / s.segment_count;
s.conseq_pixel_dist = s.output_pixels / (s.full_resolution / s.optical_resolution) / s.segment_count;
}
if (dev->model->asic_type == AsicType::GL842 ||
@ -1034,7 +1034,7 @@ void compute_session(const Genesys_Device* dev, ScanSession& s, const Genesys_Se
dev->model->asic_type == AsicType::GL843)
{
s.output_segment_pixel_group_count = s.output_pixels /
(s.ccd_size_divisor * s.segment_count);
(s.full_resolution / s.optical_resolution * s.segment_count);
}
if (dev->model->asic_type == AsicType::GL845 ||
dev->model->asic_type == AsicType::GL846 ||
@ -1086,8 +1086,9 @@ static std::size_t get_usb_buffer_read_size(AsicType asic, const ScanSession& se
return 1;
case AsicType::GL124:
// BUG: we shouldn't multiply by channels here nor divide by ccd_size_divisor
return session.output_line_bytes_raw / session.ccd_size_divisor * session.params.channels;
// BUG: we shouldn't multiply by channels here nor adjuct by resolution factor
return session.output_line_bytes_raw * session.optical_resolution / session.full_resolution
* session.params.channels;
case AsicType::GL845:
case AsicType::GL846:

Wyświetl plik

@ -121,13 +121,13 @@ std::ostream& operator<<(std::ostream& out, const Genesys_Sensor& sensor)
{
out << "Genesys_Sensor{\n"
<< " sensor_id: " << static_cast<unsigned>(sensor.sensor_id) << '\n'
<< " optical_res: " << sensor.optical_res << '\n'
<< " full_resolution: " << sensor.full_resolution << '\n'
<< " optical_resolution: " << sensor.get_optical_resolution() << '\n'
<< " resolutions: " << format_indent_braced_list(4, sensor.resolutions) << '\n'
<< " channels: " << format_vector_unsigned(4, sensor.channels) << '\n'
<< " method: " << sensor.method << '\n'
<< " register_dpihw: " << sensor.register_dpihw << '\n'
<< " register_dpiset: " << sensor.register_dpiset << '\n'
<< " ccd_size_divisor: " << sensor.ccd_size_divisor << '\n'
<< " shading_factor: " << sensor.shading_factor << '\n'
<< " shading_pixel_offset: " << sensor.shading_pixel_offset << '\n'
<< " pixel_count_ratio: " << sensor.pixel_count_ratio << '\n'

Wyświetl plik

@ -258,7 +258,12 @@ struct Genesys_Sensor {
// sensor resolution in CCD pixels. Note that we may read more than one CCD pixel per logical
// pixel, see ccd_pixels_per_system_pixel()
unsigned optical_res = 0;
unsigned full_resolution = 0;
// sensor resolution in pixel values that are read by the chip. Many scanners make low
// resolutions faster by configuring the timings in such a way that 1/2 or 1/4 of pixel values
// that are read. If zero, then it is equal to `full_resolution`.
unsigned optical_resolution = 0;
// the resolution list that the sensor is usable at.
ValueFilterAny<unsigned> resolutions = VALUE_FILTER_ANY;
@ -277,9 +282,6 @@ struct Genesys_Sensor {
// resolution. The value zero does not set the override.
unsigned register_dpiset = 0;
// CCD may present itself as half or quarter-size CCD on certain resolutions
int ccd_size_divisor = 1;
// The resolution to use for shading calibration
unsigned shading_resolution = 0;
@ -331,11 +333,11 @@ struct Genesys_Sensor {
// red, green and blue gamma coefficient for default gamma tables
AssignableArray<float, 3> gamma;
std::function<unsigned(const Genesys_Sensor&, unsigned)> get_ccd_size_divisor_fun;
unsigned get_ccd_size_divisor_for_dpi(unsigned xres) const
unsigned get_optical_resolution() const
{
return get_ccd_size_divisor_fun(*this, xres);
if (optical_resolution != 0)
return optical_resolution;
return full_resolution;
}
// how many CCD pixels are processed per system pixel time. This corresponds to CKSEL + 1
@ -361,11 +363,11 @@ struct Genesys_Sensor {
bool operator==(const Genesys_Sensor& other) const
{
return sensor_id == other.sensor_id &&
optical_res == other.optical_res &&
full_resolution == other.full_resolution &&
optical_resolution == other.optical_resolution &&
resolutions == other.resolutions &&
method == other.method &&
shading_resolution == other.shading_resolution &&
ccd_size_divisor == other.ccd_size_divisor &&
shading_factor == other.shading_factor &&
shading_pixel_offset == other.shading_pixel_offset &&
pixel_count_ratio == other.pixel_count_ratio &&
@ -390,11 +392,10 @@ template<class Stream>
void serialize(Stream& str, Genesys_Sensor& x)
{
serialize(str, x.sensor_id);
serialize(str, x.optical_res);
serialize(str, x.full_resolution);
serialize(str, x.resolutions);
serialize(str, x.method);
serialize(str, x.shading_resolution);
serialize(str, x.ccd_size_divisor);
serialize(str, x.shading_factor);
serialize(str, x.shading_pixel_offset);
serialize(str, x.output_pixel_offset);

Wyświetl plik

@ -97,7 +97,7 @@ bool ScanSession::operator==(const ScanSession& other) const
{
return params == other.params &&
computed == other.computed &&
ccd_size_divisor == other.ccd_size_divisor &&
full_resolution == other.full_resolution &&
optical_resolution == other.optical_resolution &&
optical_pixels == other.optical_pixels &&
optical_pixels_raw == other.optical_pixels_raw &&
@ -136,7 +136,7 @@ std::ostream& operator<<(std::ostream& out, const ScanSession& session)
{
out << "ScanSession{\n"
<< " computed: " << session.computed << '\n'
<< " ccd_size_divisor: " << session.ccd_size_divisor << '\n'
<< " full_resolution: " << session.full_resolution << '\n'
<< " optical_resolution: " << session.optical_resolution << '\n'
<< " optical_pixels: " << session.optical_pixels << '\n'
<< " optical_pixels_raw: " << session.optical_pixels_raw << '\n'

Wyświetl plik

@ -212,11 +212,10 @@ struct ScanSession {
// whether the session setup has been computed via compute_session()
bool computed = false;
// specifies the reduction (if any) of CCD effective dpi which is performed by latching the
// data coming from CCD in such a way that 1/2 or 3/4 of pixel data is ignored.
unsigned ccd_size_divisor = 1;
// specifies the full resolution of the sensor that is being used.
unsigned full_resolution = 0;
// the optical resolution of the scanner.
// the optical resolution of the sensor that is being used.
unsigned optical_resolution = 0;
// the number of pixels at the optical resolution, not including segmentation overhead.
@ -230,7 +229,6 @@ struct ScanSession {
unsigned optical_line_count = 0;
// the resolution of the output data.
// gl843-only
unsigned output_resolution = 0;
// the offset in pixels from the beginning of output data
@ -343,7 +341,7 @@ void serialize(Stream& str, ScanSession& x)
serialize(str, x.params);
serialize_newline(str);
serialize(str, x.computed);
serialize(str, x.ccd_size_divisor);
serialize(str, x.full_resolution);
serialize(str, x.optical_resolution);
serialize(str, x.optical_pixels);
serialize(str, x.optical_pixels_raw);

Wyświetl plik

@ -66,7 +66,7 @@ Genesys_Calibration_Cache create_fake_calibration_entry()
Genesys_Sensor sensor;
sensor.sensor_id = SensorId::CCD_UMAX;
sensor.optical_res = 1200;
sensor.full_resolution = 1200;
sensor.black_pixels = 48;
sensor.dummy_pixel = 64;
sensor.fau_gain_white_ref = 210;