kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Move logical and register dpi computation to sensor struct
rodzic
c4468f998a
commit
025ec317e3
|
@ -582,6 +582,33 @@ void genesys_init_frontend_tables()
|
|||
s_frontends->push_back(fe);
|
||||
}
|
||||
|
||||
inline unsigned default_get_logical_hwdpi(const Genesys_Sensor& sensor, unsigned xres)
|
||||
{
|
||||
// can't be below 600 dpi
|
||||
if (xres <= 600) {
|
||||
return 600;
|
||||
}
|
||||
if (xres <= static_cast<unsigned>(sensor.optical_res) / 4) {
|
||||
return sensor.optical_res / 4;
|
||||
}
|
||||
if (xres <= static_cast<unsigned>(sensor.optical_res) / 2) {
|
||||
return sensor.optical_res / 2;
|
||||
}
|
||||
return sensor.optical_res;
|
||||
}
|
||||
|
||||
inline unsigned get_sensor_optical_with_ccd_divisor(const Genesys_Sensor& sensor, unsigned xres)
|
||||
{
|
||||
unsigned hwres = sensor.optical_res / sensor.get_ccd_size_divisor_for_dpi(xres);
|
||||
|
||||
if (xres <= hwres / 4) {
|
||||
return hwres / 4;
|
||||
}
|
||||
if (xres <= hwres / 2) {
|
||||
return hwres / 2;
|
||||
}
|
||||
return hwres;
|
||||
}
|
||||
|
||||
/** for setting up the sensor-specific settings:
|
||||
* Optical Resolution, number of black pixels, number of dummy pixels,
|
||||
|
@ -632,6 +659,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x00 },
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -673,6 +702,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x00 },
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -714,6 +745,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x00 },
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -756,6 +789,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x00 },
|
||||
};
|
||||
sensor.gamma = {2.38, 2.35, 2.34};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -797,6 +832,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x00 },
|
||||
};
|
||||
sensor.gamma = {2.1, 2.1, 2.1};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -839,6 +876,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x16 },
|
||||
};
|
||||
sensor.gamma = {2.1, 2.1, 2.1};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -881,6 +920,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x00 },
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -922,6 +963,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x16 },
|
||||
};
|
||||
sensor.gamma = {2.1, 2.1, 2.1};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -963,6 +1006,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x00 },
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -1004,6 +1049,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x01 },
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -1045,6 +1092,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x01 },
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -1086,6 +1135,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x01 },
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -1127,6 +1178,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x01 },
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -1168,6 +1221,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x01 },
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -1209,6 +1264,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x41 },
|
||||
};
|
||||
sensor.gamma = {1.7, 1.7, 1.7};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -1252,6 +1309,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x41 },
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -1293,6 +1352,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x41 },
|
||||
};
|
||||
sensor.gamma = {1.7, 1.7, 1.7};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -1335,6 +1396,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5a, 0xc0 },
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -1351,6 +1414,8 @@ void genesys_init_sensor_tables()
|
|||
sensor.exposure = { 0x2c09, 0x22b8, 0x10f0 };
|
||||
sensor.custom_regs = {};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
|
||||
{
|
||||
struct CustomSensorSettings {
|
||||
|
@ -1559,6 +1624,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5a, 0x40 },
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.get_logical_hwdpi_fun = get_sensor_optical_with_ccd_divisor;
|
||||
sensor.get_register_hwdpi_fun = [](const Genesys_Sensor&, unsigned) { return 4800; };
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -1577,6 +1644,9 @@ void genesys_init_sensor_tables()
|
|||
sensor.exposure = { 0x9c40, 0x9c40, 0x9c40 };
|
||||
sensor.custom_regs = {};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.get_logical_hwdpi_fun = get_sensor_optical_with_ccd_divisor;
|
||||
sensor.get_register_hwdpi_fun = [](const Genesys_Sensor&, unsigned) { return 4800; };
|
||||
|
||||
{
|
||||
struct CustomSensorSettings {
|
||||
int min_resolution;
|
||||
|
@ -1787,6 +1857,8 @@ void genesys_init_sensor_tables()
|
|||
sensor.exposure = { 0x9c40, 0x9c40, 0x9c40 };
|
||||
sensor.custom_regs = {};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.get_logical_hwdpi_fun = get_sensor_optical_with_ccd_divisor;
|
||||
sensor.get_register_hwdpi_fun = [](const Genesys_Sensor&, unsigned) { return 4800; };
|
||||
|
||||
{
|
||||
struct CustomSensorSettings {
|
||||
|
@ -2007,6 +2079,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x6f },
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -2049,6 +2123,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x00 },
|
||||
};
|
||||
sensor.gamma = {2.1, 2.1, 2.1};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -2092,6 +2168,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x1f },
|
||||
};
|
||||
sensor.gamma = {2.1, 2.1, 2.1};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -2134,6 +2212,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x00 },
|
||||
};
|
||||
sensor.gamma = {2.1, 2.1, 2.1};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -2176,6 +2256,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x00 },
|
||||
};
|
||||
sensor.gamma = {2.1, 2.1, 2.1};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -2218,6 +2300,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x02 },
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -2259,6 +2343,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x1f },
|
||||
};
|
||||
sensor.gamma = {1.7, 1.7, 1.7};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -2300,6 +2386,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x1f },
|
||||
};
|
||||
sensor.gamma = {1.7, 1.7, 1.7};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -2346,6 +2434,8 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5e, 0x41 },
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
s_sensors->push_back(sensor);
|
||||
}
|
||||
|
||||
|
|
|
@ -842,8 +842,8 @@ static void gl124_setup_sensor(Genesys_Device * dev,
|
|||
regs->set8(addr, sensor.custom_regs.get_value(addr));
|
||||
}
|
||||
|
||||
/* set EXPDUMMY and CKxMAP */
|
||||
dpihw = sanei_genesys_compute_dpihw(dev, sensor, dpi);
|
||||
// set EXPDUMMY and CKxMAP
|
||||
dpihw = sensor.get_register_hwdpi(dpi);
|
||||
Sensor_Profile* sensor_profile = get_sensor_profile(dev->model->ccd_type, dpihw, half_ccd);
|
||||
|
||||
regs->set8(0x18, sensor_profile->reg18);
|
||||
|
@ -929,9 +929,9 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
unsigned ccd_pixels_per_system_pixel = sensor.ccd_pixels_per_system_pixel();
|
||||
DBG(DBG_io2, "%s: ccd_pixels_per_system_pixel=%d\n", __func__, ccd_pixels_per_system_pixel);
|
||||
|
||||
/* to manage high resolution device while keeping good
|
||||
* low resolution scanning speed, we make hardware dpi vary */
|
||||
dpihw = sanei_genesys_compute_dpihw(dev, sensor, used_res * ccd_pixels_per_system_pixel);
|
||||
// to manage high resolution device while keeping good low resolution scanning speed, we
|
||||
// make hardware dpi vary
|
||||
dpihw = sensor.get_register_hwdpi(used_res * ccd_pixels_per_system_pixel);
|
||||
factor=sensor.optical_res/dpihw;
|
||||
DBG (DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor);
|
||||
|
||||
|
@ -1451,8 +1451,8 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
/* max_shift */
|
||||
max_shift=sanei_genesys_compute_max_shift(dev, params.channels, params.yres, 0);
|
||||
|
||||
/* compute hw dpi for sensor */
|
||||
dpihw=sanei_genesys_compute_dpihw(dev, sensor,used_res);
|
||||
// compute hw dpi for sensor
|
||||
dpihw = sensor.get_register_hwdpi(used_res);
|
||||
|
||||
Sensor_Profile* sensor_profile = get_sensor_profile(dev->model->ccd_type, dpihw, half_ccd);
|
||||
dev->segnb=sensor_profile->reg98 & 0x0f;
|
||||
|
@ -2037,7 +2037,7 @@ static void gl124_init_regs_for_shading(Genesys_Device* dev, const Genesys_Senso
|
|||
|
||||
dev->calib_channels = 3;
|
||||
dev->calib_lines = dev->model->shading_lines;
|
||||
dpihw=sanei_genesys_compute_dpihw(dev, sensor, dev->settings.xres);
|
||||
dpihw = sensor.get_register_hwdpi(dev->settings.xres);
|
||||
if(dpihw>=2400)
|
||||
{
|
||||
dev->calib_lines *= 2;
|
||||
|
@ -2213,7 +2213,7 @@ static void gl124_send_shading_data(Genesys_Device* dev, const Genesys_Sensor& s
|
|||
|
||||
/* compute deletion factor */
|
||||
sanei_genesys_get_double(&dev->reg,REG_DPISET,&dpiset);
|
||||
dpihw=sanei_genesys_compute_dpihw(dev, sensor, dpiset);
|
||||
dpihw = sensor.get_register_hwdpi(dpiset);
|
||||
factor=dpihw/dpiset;
|
||||
DBG( DBG_io2, "%s: factor=%d\n",__func__,factor);
|
||||
|
||||
|
@ -2383,7 +2383,7 @@ static void gl124_led_calibration(Genesys_Device* dev, Genesys_Sensor& sensor,
|
|||
/* offset calibration is always done in 16 bit depth color mode */
|
||||
channels = 3;
|
||||
depth=16;
|
||||
dpihw=sanei_genesys_compute_dpihw(dev, sensor, dev->settings.xres);
|
||||
dpihw = sensor.get_register_hwdpi(dev->settings.xres);
|
||||
half_ccd=compute_half_ccd(sensor, dev->settings.xres);
|
||||
if(half_ccd==SANE_TRUE)
|
||||
{
|
||||
|
|
|
@ -996,7 +996,7 @@ static void gl843_init_motor_regs_scan(Genesys_Device* dev,
|
|||
if (!(dev->model->flags & GENESYS_FLAG_FULL_HWDPI_MODE))
|
||||
{
|
||||
r->value = 0x50;
|
||||
coeff=sensor.optical_res/sanei_genesys_compute_dpihw(dev, sensor, scan_yres);
|
||||
coeff=sensor.optical_res / sensor.get_register_hwdpi(scan_yres);
|
||||
if (dev->model->motor_type == MOTOR_KVSS080)
|
||||
{
|
||||
if(coeff>=1)
|
||||
|
@ -1058,9 +1058,9 @@ static void gl843_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
tgtime = exposure / 65536 + 1;
|
||||
DBG(DBG_io2, "%s: tgtime=%d\n", __func__, tgtime);
|
||||
|
||||
/* to manage high resolution device while keeping good
|
||||
* low resolution scanning speed, we make hardware dpi vary */
|
||||
dpihw=sanei_genesys_compute_dpihw(dev, sensor, used_res);
|
||||
// to manage high resolution device while keeping good low resolution scanning speed, we make
|
||||
// hardware dpi vary
|
||||
dpihw = sensor.get_register_hwdpi(used_res);
|
||||
factor=sensor.optical_res/dpihw;
|
||||
DBG(DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor);
|
||||
|
||||
|
@ -2089,7 +2089,7 @@ static void gl843_begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
|
|||
|
||||
/* get back the target dpihw */
|
||||
sanei_genesys_get_double (reg, REG_DPISET, &dpiset);
|
||||
dpihw = sanei_genesys_compute_dpihw(dev, sensor, dpiset);
|
||||
dpihw = sensor.get_register_hwdpi(dpiset);
|
||||
|
||||
/* set up GPIO for scan */
|
||||
switch(dev->model->gpo_type)
|
||||
|
@ -2586,7 +2586,7 @@ static void gl843_init_regs_for_shading(Genesys_Device* dev, const Genesys_Senso
|
|||
dev->calib_lines = dev->model->shading_lines;
|
||||
}
|
||||
|
||||
dpihw = sanei_genesys_compute_dpihw_calibration(dev, sensor, dev->settings.xres);
|
||||
dpihw = sensor.get_logical_hwdpi(dev->settings.xres);
|
||||
factor=sensor.optical_res/dpihw;
|
||||
resolution=dpihw;
|
||||
|
||||
|
@ -3025,8 +3025,8 @@ static void gl843_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
|
|||
lines = 8;
|
||||
bpp = 8;
|
||||
|
||||
/* compute divider factor to compute final pixels number */
|
||||
dpihw = sanei_genesys_compute_dpihw_calibration(dev, sensor, dev->settings.xres);
|
||||
// compute divider factor to compute final pixels number
|
||||
dpihw = sensor.get_logical_hwdpi(dev->settings.xres);
|
||||
factor = sensor.optical_res / dpihw;
|
||||
resolution = dpihw;
|
||||
|
||||
|
@ -3246,7 +3246,7 @@ static void gl843_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen
|
|||
int resolution;
|
||||
int bpp;
|
||||
|
||||
dpihw=sanei_genesys_compute_dpihw_calibration(dev, sensor, dpi);
|
||||
dpihw = sensor.get_logical_hwdpi(dpi);
|
||||
factor=sensor.optical_res/dpihw;
|
||||
|
||||
/* coarse gain calibration is always done in color mode */
|
||||
|
@ -3432,7 +3432,7 @@ static void gl843_init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor
|
|||
/* setup scan */
|
||||
*channels=3;
|
||||
resolution=600;
|
||||
dpihw=sanei_genesys_compute_dpihw_calibration(dev, sensor, resolution);
|
||||
dpihw = sensor.get_logical_hwdpi(resolution);
|
||||
resolution=dpihw;
|
||||
|
||||
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution,
|
||||
|
@ -3878,7 +3878,7 @@ static void gl843_send_shading_data(Genesys_Device* dev, const Genesys_Sensor& s
|
|||
* compute offset within data for SHDAREA case */
|
||||
r = sanei_genesys_get_address(&dev->reg, REG18);
|
||||
sanei_genesys_get_double(&dev->reg,REG_DPISET,&dpiset);
|
||||
factor=sensor.optical_res/sanei_genesys_compute_dpihw(dev, sensor, dpiset);
|
||||
factor = sensor.optical_res / sensor.get_register_hwdpi(dpiset);
|
||||
|
||||
/* start coordinate in optical dpi coordinates */
|
||||
startx = (sensor.dummy_pixel / sensor.ccd_pixels_per_system_pixel()) / factor;
|
||||
|
@ -3891,8 +3891,7 @@ static void gl843_send_shading_data(Genesys_Device* dev, const Genesys_Sensor& s
|
|||
{
|
||||
int optical_res = sensor.optical_res / dev->current_setup.ccd_size_divisor;
|
||||
int dpiset_real = dpiset / dev->current_setup.ccd_size_divisor;
|
||||
int half_ccd_factor = optical_res /
|
||||
sanei_genesys_compute_dpihw_calibration(dev, sensor, dpiset_real);
|
||||
int half_ccd_factor = optical_res / sensor.get_logical_hwdpi(dpiset_real);
|
||||
strpixel /= half_ccd_factor;
|
||||
endpixel /= half_ccd_factor;
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ static void gl846_setup_sensor(Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
int dpihw;
|
||||
uint16_t exp;
|
||||
|
||||
dpihw=sanei_genesys_compute_dpihw(dev, sensor, dpi);
|
||||
dpihw = sensor.get_register_hwdpi(dpi);
|
||||
|
||||
for (uint16_t addr = 0x16; addr < 0x1e; addr++) {
|
||||
regs->set8(addr, sensor.custom_regs.get_value(addr));
|
||||
|
@ -228,8 +228,8 @@ static void gl846_setup_sensor(Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
regs->set8(addr, sensor.custom_regs.get_value(addr));
|
||||
}
|
||||
|
||||
/* set EXPDUMMY and CKxMAP */
|
||||
dpihw=sanei_genesys_compute_dpihw(dev, sensor, dpi);
|
||||
// set EXPDUMMY and CKxMAP
|
||||
dpihw = sensor.get_register_hwdpi(dpi);
|
||||
Sensor_Profile* sensor_profile = get_sensor_profile(dev->model->ccd_type, dpihw);
|
||||
|
||||
sanei_genesys_set_reg_from_set(regs,REG_EXPDMY,(uint8_t)((sensor_profile->expdummy) & 0xff));
|
||||
|
@ -696,8 +696,7 @@ static void gl846_init_motor_regs_scan(Genesys_Device* dev,
|
|||
|
||||
if(dev->model->gpo_type==GPO_IMG101)
|
||||
{
|
||||
if(scan_yres==sanei_genesys_compute_dpihw(dev, sensor,scan_yres))
|
||||
{
|
||||
if (scan_yres == sensor.get_register_hwdpi(scan_yres)) {
|
||||
val=1;
|
||||
}
|
||||
else
|
||||
|
@ -795,7 +794,7 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
|
||||
// to manage high resolution device while keeping good low resolution scanning speed,
|
||||
// we make hardware dpi vary
|
||||
dpihw = sanei_genesys_compute_dpihw(dev, sensor, used_res * ccd_pixels_per_system_pixel);
|
||||
dpihw = sensor.get_register_hwdpi(used_res * ccd_pixels_per_system_pixel);
|
||||
factor = sensor.optical_res/dpihw;
|
||||
DBG(DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor);
|
||||
|
||||
|
@ -1780,7 +1779,7 @@ static void gl846_init_regs_for_shading(Genesys_Device* dev, const Genesys_Senso
|
|||
/* initial calibration reg values */
|
||||
regs = dev->reg;
|
||||
|
||||
dev->calib_resolution = sanei_genesys_compute_dpihw(dev, sensor, dev->settings.xres);
|
||||
dev->calib_resolution = sensor.get_register_hwdpi(dev->settings.xres);
|
||||
dev->calib_total_bytes_to_read = 0;
|
||||
dev->calib_lines = dev->model->shading_lines;
|
||||
if(dev->calib_resolution==4800)
|
||||
|
@ -1955,7 +1954,7 @@ static void gl846_send_shading_data(Genesys_Device* dev, const Genesys_Sensor& s
|
|||
dpiset=tempo;
|
||||
DBG(DBG_io2, "%s: STRPIXEL=%d, ENDPIXEL=%d, PIXELS=%d, DPISET=%d\n", __func__, strpixel, endpixel,
|
||||
endpixel-strpixel, dpiset);
|
||||
dpihw=sanei_genesys_compute_dpihw(dev, sensor, dpiset);
|
||||
dpihw = sensor.get_register_hwdpi(dpiset);
|
||||
factor=dpihw/dpiset;
|
||||
DBG(DBG_io2, "%s: factor=%d\n", __func__, factor);
|
||||
|
||||
|
@ -2047,7 +2046,7 @@ static void gl846_led_calibration(Genesys_Device* dev, Genesys_Sensor& sensor,
|
|||
/* offset calibration is always done in color mode */
|
||||
channels = 3;
|
||||
depth=16;
|
||||
used_res=sanei_genesys_compute_dpihw(dev, sensor, dev->settings.xres);
|
||||
used_res = sensor.get_register_hwdpi(dev->settings.xres);
|
||||
Sensor_Profile* sensor_profile = get_sensor_profile(dev->model->ccd_type, used_res);
|
||||
num_pixels = (sensor.sensor_pixels*used_res)/sensor.optical_res;
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ static void gl847_setup_sensor(Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
int dpihw;
|
||||
uint16_t exp;
|
||||
|
||||
dpihw=sanei_genesys_compute_dpihw(dev, sensor, dpi);
|
||||
dpihw = sensor.get_register_hwdpi(dpi);
|
||||
|
||||
for (uint16_t addr = 0x16; addr < 0x1e; addr++) {
|
||||
regs->set8(addr, sensor.custom_regs.get_value(addr));
|
||||
|
@ -223,8 +223,8 @@ static void gl847_setup_sensor(Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
regs->set8(addr, sensor.custom_regs.get_value(addr));
|
||||
}
|
||||
|
||||
/* set EXPDUMMY and CKxMAP */
|
||||
dpihw=sanei_genesys_compute_dpihw(dev, sensor, dpi);
|
||||
// set EXPDUMMY and CKxMAP
|
||||
dpihw = sensor.get_register_hwdpi(dpi);
|
||||
Sensor_Profile* sensor_profile=get_sensor_profile(dev->model->ccd_type, dpihw);
|
||||
|
||||
sanei_genesys_set_reg_from_set(regs,REG_EXPDMY,(uint8_t)((sensor_profile->expdummy) & 0xff));
|
||||
|
@ -809,7 +809,7 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
|
||||
// to manage high resolution device while keeping good low resolution scanning speed, we make
|
||||
// hardware dpi vary
|
||||
dpihw = sanei_genesys_compute_dpihw(dev, sensor, used_res * ccd_pixels_per_system_pixel);
|
||||
dpihw = sensor.get_register_hwdpi(used_res * ccd_pixels_per_system_pixel);
|
||||
factor=sensor.optical_res/dpihw;
|
||||
DBG(DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor);
|
||||
|
||||
|
@ -1835,7 +1835,7 @@ static void gl847_init_regs_for_shading(Genesys_Device* dev, const Genesys_Senso
|
|||
/* initial calibration reg values */
|
||||
regs = dev->reg;
|
||||
|
||||
dev->calib_resolution = sanei_genesys_compute_dpihw(dev, sensor, dev->settings.xres);
|
||||
dev->calib_resolution = sensor.get_register_hwdpi(dev->settings.xres);
|
||||
dev->calib_total_bytes_to_read = 0;
|
||||
dev->calib_lines = dev->model->shading_lines;
|
||||
if(dev->calib_resolution==4800)
|
||||
|
@ -2010,7 +2010,7 @@ static void gl847_send_shading_data(Genesys_Device* dev, const Genesys_Sensor& s
|
|||
dpiset=tempo;
|
||||
DBG(DBG_io2, "%s: STRPIXEL=%d, ENDPIXEL=%d, PIXELS=%d, DPISET=%d\n", __func__, strpixel, endpixel,
|
||||
endpixel-strpixel, dpiset);
|
||||
dpihw=sanei_genesys_compute_dpihw(dev, sensor, dpiset);
|
||||
dpihw = sensor.get_register_hwdpi(dpiset);
|
||||
factor=dpihw/dpiset;
|
||||
DBG(DBG_io2, "%s: factor=%d\n", __func__, factor);
|
||||
|
||||
|
@ -2102,7 +2102,7 @@ static void gl847_led_calibration(Genesys_Device* dev, Genesys_Sensor& sensor,
|
|||
/* offset calibration is always done in color mode */
|
||||
channels = 3;
|
||||
depth=16;
|
||||
used_res=sanei_genesys_compute_dpihw(dev, sensor, dev->settings.xres);
|
||||
used_res = sensor.get_register_hwdpi(dev->settings.xres);
|
||||
Sensor_Profile* sensor_profile=get_sensor_profile(dev->model->ccd_type, used_res);
|
||||
num_pixels = (sensor.sensor_pixels*used_res)/sensor.optical_res;
|
||||
|
||||
|
|
|
@ -1306,62 +1306,6 @@ void sanei_genesys_wait_for_home(Genesys_Device* dev)
|
|||
}
|
||||
}
|
||||
|
||||
/**@brief compute hardware sensor dpi to use
|
||||
* compute the sensor hardware dpi based on target resolution.
|
||||
* A lower dpihw enable faster scans.
|
||||
* @param dev device used for the scan
|
||||
* @param xres x resolution of the scan
|
||||
* @return the hardware dpi to use
|
||||
*/
|
||||
int sanei_genesys_compute_dpihw(Genesys_Device *dev, const Genesys_Sensor& sensor, int xres)
|
||||
{
|
||||
/* some scanners use always hardware dpi for sensor */
|
||||
if (dev->model->flags & GENESYS_FLAG_FULL_HWDPI_MODE)
|
||||
{
|
||||
return sensor.optical_res;
|
||||
}
|
||||
|
||||
/* can't be below 600 dpi */
|
||||
if (xres <= 600)
|
||||
{
|
||||
return 600;
|
||||
}
|
||||
if (xres <= sensor.optical_res / 4)
|
||||
{
|
||||
return sensor.optical_res / 4;
|
||||
}
|
||||
if (xres <= sensor.optical_res / 2)
|
||||
{
|
||||
return sensor.optical_res / 2;
|
||||
}
|
||||
return sensor.optical_res;
|
||||
}
|
||||
|
||||
// sanei_genesys_compute_dpihw returns the dpihw that is written to register.
|
||||
// However the number of pixels depends on half_ccd mode
|
||||
int sanei_genesys_compute_dpihw_calibration(Genesys_Device *dev, const Genesys_Sensor& sensor,
|
||||
int xres)
|
||||
{
|
||||
if (dev->model->model_id == MODEL_CANON_CANOSCAN_8400F ||
|
||||
dev->model->model_id == MODEL_CANON_CANOSCAN_8600F)
|
||||
{
|
||||
// real resolution is half of the "official" resolution - half_ccd mode
|
||||
int hwres = sensor.optical_res / sensor.get_ccd_size_divisor_for_dpi(xres);
|
||||
|
||||
if (xres <= hwres / 4)
|
||||
{
|
||||
return hwres / 4;
|
||||
}
|
||||
if (xres <= hwres / 2)
|
||||
{
|
||||
return hwres / 2;
|
||||
}
|
||||
return hwres;
|
||||
}
|
||||
|
||||
return sanei_genesys_compute_dpihw(dev, sensor, xres);
|
||||
}
|
||||
|
||||
/** @brief motor profile
|
||||
* search for the database of motor profiles and get the best one. Each
|
||||
* profile is at full step and at a reference exposure. Use first entry
|
||||
|
@ -1597,8 +1541,8 @@ bool sanei_genesys_is_compatible_calibration(Genesys_Device * dev, const Genesys
|
|||
}
|
||||
else
|
||||
{
|
||||
resolution=sanei_genesys_compute_dpihw(dev, sensor, dev->settings.xres);
|
||||
compatible = (resolution == ((int) sanei_genesys_compute_dpihw(dev, sensor,cache->used_setup.xres)));
|
||||
compatible = (sensor.get_register_hwdpi(dev->settings.xres) ==
|
||||
sensor.get_register_hwdpi(cache->used_setup.xres));
|
||||
}
|
||||
DBG (DBG_io, "%s: after resolution check current compatible=%d\n", __func__, compatible);
|
||||
if (dev->current_setup.ccd_size_divisor != cache->used_setup.ccd_size_divisor)
|
||||
|
|
|
@ -678,6 +678,12 @@ 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_logical_hwdpi_fun;
|
||||
std::function<unsigned(const Genesys_Sensor&, unsigned)> get_register_hwdpi_fun;
|
||||
|
||||
unsigned get_logical_hwdpi(unsigned xres) const { return get_logical_hwdpi_fun(*this, xres); }
|
||||
unsigned get_register_hwdpi(unsigned xres) const { return get_register_hwdpi_fun(*this, xres); }
|
||||
|
||||
int get_ccd_size_divisor_for_dpi(int xres) const
|
||||
{
|
||||
if (ccd_size_divisor >= 4 && xres * 4 <= optical_res) {
|
||||
|
@ -1947,11 +1953,6 @@ extern void sanei_genesys_wait_for_home(Genesys_Device* dev);
|
|||
|
||||
extern void sanei_genesys_asic_init(Genesys_Device* dev, SANE_Bool cold);
|
||||
|
||||
int sanei_genesys_compute_dpihw(Genesys_Device *dev, const Genesys_Sensor& sensor, int xres);
|
||||
|
||||
int sanei_genesys_compute_dpihw_calibration(Genesys_Device *dev, const Genesys_Sensor& sensor,
|
||||
int xres);
|
||||
|
||||
extern
|
||||
Motor_Profile *sanei_genesys_get_motor_profile(Motor_Profile *motors, int motor_type, int exposure);
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue