From 459c62c131b4794d115c38b7a555d2415f7e9870 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sat, 21 Mar 2020 00:11:24 +0200 Subject: [PATCH] genesys: Simplify dpiset calculation on gl841 --- backend/genesys/gl841.cpp | 13 ++- backend/genesys/tables_sensor.cpp | 160 +++++++++++++++++++++++++++--- 2 files changed, 154 insertions(+), 19 deletions(-) diff --git a/backend/genesys/gl841.cpp b/backend/genesys/gl841.cpp index 85bf95103..71b1424df 100644 --- a/backend/genesys/gl841.cpp +++ b/backend/genesys/gl841.cpp @@ -1270,7 +1270,7 @@ static void gl841_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens r = sanei_genesys_get_address (reg, 0x29); r->value = 255; /*<<<"magic" number, only suitable for cis*/ - reg->set16(REG_DPISET, gl841_get_dpihw(dev) * session.output_resolution / session.optical_resolution); + reg->set16(REG_DPISET, sensor.dpiset_override); reg->set16(REG_STRPIXEL, session.pixel_startx); reg->set16(REG_ENDPIXEL, session.pixel_endx); @@ -3058,8 +3058,8 @@ void CommandSetGl841::send_shading_data(Genesys_Device* dev, const Genesys_Senso uint8_t* data, int size) const { DBG_HELPER_ARGS(dbg, "writing %d bytes of shading data", size); - uint32_t length, x, factor, pixels, i; - uint16_t dpiset, dpihw, beginpixel; + uint32_t length, x, pixels, i; + uint16_t dpihw, beginpixel; uint8_t *ptr,*src; /* old method if no SHDAREA */ @@ -3074,12 +3074,11 @@ void CommandSetGl841::send_shading_data(Genesys_Device* dev, const Genesys_Senso unsigned endpixel = dev->session.pixel_endx; /* compute deletion/average factor */ - dpiset = dev->reg.get16(REG_DPISET); dpihw = gl841_get_dpihw(dev); unsigned ccd_size_divisor = dev->session.ccd_size_divisor; - factor=dpihw/dpiset; - DBG(DBG_io2, "%s: dpihw=%d, dpiset=%d, ccd_size_divisor=%d, factor=%d\n", __func__, dpihw, dpiset, - ccd_size_divisor, factor); + unsigned factor = dpihw / sensor.dpiset_override; + DBG(DBG_io2, "%s: dpihw=%d, ccd_size_divisor=%d, factor=%d\n", __func__, dpihw, + ccd_size_divisor, factor); /* turn pixel value into bytes 2x16 bits words */ strpixel*=2*2; /* 2 words of 2 bytes */ diff --git a/backend/genesys/tables_sensor.cpp b/backend/genesys/tables_sensor.cpp index 1eab3f15f..6f5ca0968 100644 --- a/backend/genesys/tables_sensor.cpp +++ b/backend/genesys/tables_sensor.cpp @@ -497,17 +497,24 @@ void genesys_init_sensor_tables() { ValueFilterAny resolutions; unsigned register_dpihw; + unsigned dpiset_override; unsigned shading_resolution; }; CustomSensorSettings custom_settings[] = { - { { 75, 100, 150, 200, 300, 600 }, 1200, 600 }, - { { 1200 }, 1200, 1200 }, + { { 75 }, 1200, 150, 600 }, + { { 100 }, 1200, 200, 600 }, + { { 150 }, 1200, 300, 600 }, + { { 200 }, 1200, 400, 600 }, + { { 300 }, 1200, 600, 600 }, + { { 600 }, 1200, 1200, 600 }, + { { 1200 }, 1200, 1200, 1200 }, }; for (const CustomSensorSettings& setting : custom_settings) { sensor.resolutions = setting.resolutions; sensor.register_dpihw = setting.register_dpihw; + sensor.dpiset_override = setting.dpiset_override; sensor.shading_resolution = setting.shading_resolution; s_sensors->push_back(sensor); } @@ -710,8 +717,27 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; - s_sensors->push_back(sensor); + { + struct CustomSensorSettings + { + ValueFilterAny resolutions; + unsigned dpiset_override; + }; + CustomSensorSettings custom_settings[] = { + { { 75 }, 75 }, + { { 150 }, 150 }, + { { 300 }, 300 }, + { { 600 }, 600 }, + { { 1200 }, 1200 }, + }; + + for (const CustomSensorSettings& setting : custom_settings) { + sensor.resolutions = setting.resolutions; + sensor.dpiset_override = setting.dpiset_override; + s_sensors->push_back(sensor); + } + } sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_ROADWARRIOR; // gl841 @@ -746,7 +772,27 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; - s_sensors->push_back(sensor); + { + struct CustomSensorSettings + { + ValueFilterAny resolutions; + unsigned dpiset_override; + }; + + CustomSensorSettings custom_settings[] = { + { { 75 }, 75 }, + { { 150 }, 150 }, + { { 300 }, 300 }, + { { 600 }, 600 }, + { { 1200 }, 1200 }, + }; + + for (const CustomSensorSettings& setting : custom_settings) { + sensor.resolutions = setting.resolutions; + sensor.dpiset_override = setting.dpiset_override; + s_sensors->push_back(sensor); + } + } sensor = Genesys_Sensor(); @@ -782,7 +828,26 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; - s_sensors->push_back(sensor); + { + struct CustomSensorSettings + { + ValueFilterAny resolutions; + unsigned dpiset_override; + }; + + CustomSensorSettings custom_settings[] = { + { { 75 }, 75 }, + { { 150 }, 150 }, + { { 300 }, 300 }, + { { 600 }, 600 }, + }; + + for (const CustomSensorSettings& setting : custom_settings) { + sensor.resolutions = setting.resolutions; + sensor.dpiset_override = setting.dpiset_override; + s_sensors->push_back(sensor); + } + } sensor = Genesys_Sensor(); @@ -818,7 +883,26 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; - s_sensors->push_back(sensor); + { + struct CustomSensorSettings + { + ValueFilterAny resolutions; + unsigned dpiset_override; + }; + + CustomSensorSettings custom_settings[] = { + { { 75 }, 150 }, + { { 150 }, 300 }, + { { 300 }, 600 }, + { { 600 }, 1200 }, + }; + + for (const CustomSensorSettings& setting : custom_settings) { + sensor.resolutions = setting.resolutions; + sensor.dpiset_override = setting.dpiset_override; + s_sensors->push_back(sensor); + } + } sensor = Genesys_Sensor(); @@ -854,7 +938,26 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; - s_sensors->push_back(sensor); + { + struct CustomSensorSettings + { + ValueFilterAny resolutions; + unsigned dpiset_override; + }; + + CustomSensorSettings custom_settings[] = { + { { 75 }, 150 }, + { { 150 }, 300 }, + { { 300 }, 600 }, + { { 600 }, 600 }, + }; + + for (const CustomSensorSettings& setting : custom_settings) { + sensor.resolutions = setting.resolutions; + sensor.dpiset_override = setting.dpiset_override; + s_sensors->push_back(sensor); + } + } sensor = Genesys_Sensor(); @@ -891,7 +994,26 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; - s_sensors->push_back(sensor); + { + struct CustomSensorSettings + { + ValueFilterAny resolutions; + unsigned dpiset_override; + }; + + CustomSensorSettings custom_settings[] = { + { { 75 }, 75 }, + { { 150 }, 150 }, + { { 300 }, 300 }, + { { 600 }, 600 }, + }; + + for (const CustomSensorSettings& setting : custom_settings) { + sensor.resolutions = setting.resolutions; + sensor.dpiset_override = setting.dpiset_override; + s_sensors->push_back(sensor); + } + } sensor = Genesys_Sensor(); @@ -2822,16 +2944,23 @@ void genesys_init_sensor_tables() { ValueFilterAny resolutions; unsigned register_dpihw; + unsigned dpiset_override; }; CustomSensorSettings custom_settings[] = { - { { 75, 100, 150, 200, 300, 400, 600 }, 600 }, - { { 1200 }, 1200 }, + { { 75 }, 600, 150 }, + { { 100 }, 600, 200 }, + { { 150 }, 600, 300 }, + { { 200 }, 600, 400 }, + { { 300 }, 600, 600 }, + { { 600 }, 600, 1200 }, + { { 1200 }, 1200, 1200 }, }; for (const CustomSensorSettings& setting : custom_settings) { sensor.resolutions = setting.resolutions; sensor.register_dpihw = setting.register_dpihw; + sensor.dpiset_override = setting.dpiset_override; sensor.shading_resolution = setting.register_dpihw; s_sensors->push_back(sensor); } @@ -3221,16 +3350,23 @@ void genesys_init_sensor_tables() struct CustomSensorSettings { ValueFilterAny resolutions; + unsigned dpiset_override; unsigned shading_resolution; }; CustomSensorSettings custom_settings[] = { - { { 75, 100, 150, 200, 300, 600 }, 600 }, - { { 1200 }, 1200 }, + { { 75 }, 150, 600 }, + { { 100 }, 200, 600 }, + { { 150 }, 300, 600 }, + { { 200 }, 400, 600 }, + { { 300 }, 600, 600 }, + { { 600 }, 1200, 600 }, + { { 1200 }, 1200, 1200 }, }; for (const CustomSensorSettings& setting : custom_settings) { sensor.resolutions = setting.resolutions; + sensor.dpiset_override = setting.dpiset_override; sensor.shading_resolution = setting.shading_resolution; s_sensors->push_back(sensor); }