From f480521a231596f5c3ce35dbc7466b6913aa34af Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Thu, 12 Sep 2019 21:55:29 +0300 Subject: [PATCH] genesys: Pass sensor profile directly to *_setup_sensor() where possible --- backend/genesys_gl124.cc | 10 ++++------ backend/genesys_gl846.cc | 9 ++------- backend/genesys_gl847.cc | 11 ++--------- 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/backend/genesys_gl124.cc b/backend/genesys_gl124.cc index 8d0f7671f..22ef6101c 100644 --- a/backend/genesys_gl124.cc +++ b/backend/genesys_gl124.cc @@ -760,8 +760,8 @@ static void gl124_init_motor_regs_scan(Genesys_Device* dev, * */ static void gl124_setup_sensor(Genesys_Device * dev, const Genesys_Sensor& sensor, - Genesys_Register_Set * regs, unsigned dpihw, - unsigned ccd_size_divisor) + const SensorProfile& sensor_profile, + Genesys_Register_Set * regs) { DBG_HELPER(dbg); uint32_t exp; @@ -777,9 +777,6 @@ static void gl124_setup_sensor(Genesys_Device * dev, regs->set8(addr, sensor.custom_regs.get_value(addr)); } - // set EXPDUMMY and CKxMAP - const auto& sensor_profile = get_sensor_profile(sensor, dpihw, ccd_size_divisor); - for (auto reg : sensor_profile.custom_regs) { regs->set8(reg.address, reg.value); } @@ -845,7 +842,8 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens DBG (DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor); // sensor parameters - gl124_setup_sensor(dev, sensor, reg, dpihw, session.ccd_size_divisor); + const auto& sensor_profile = get_sensor_profile(sensor, dpihw, session.ccd_size_divisor); + gl124_setup_sensor(dev, sensor, sensor_profile, reg); /* start and end coordinate in optical dpi coordinates */ /* startx = start / ccd_pixels_per_system_pixel + sensor.dummy_pixel; XXX STEF XXX */ diff --git a/backend/genesys_gl846.cc b/backend/genesys_gl846.cc index fbde72bc7..7e09d24d0 100644 --- a/backend/genesys_gl846.cc +++ b/backend/genesys_gl846.cc @@ -186,10 +186,9 @@ static const SensorProfile& get_sensor_profile(const Genesys_Sensor& sensor, uns /** @brief sensor specific settings */ static void gl846_setup_sensor(Genesys_Device * dev, const Genesys_Sensor& sensor, - Genesys_Register_Set * regs, int dpi) + const SensorProfile& sensor_profile, Genesys_Register_Set* regs) { DBG_HELPER(dbg); - int dpihw; uint16_t exp; for (uint16_t addr = 0x16; addr < 0x1e; addr++) { @@ -200,10 +199,6 @@ 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 = sensor.get_register_hwdpi(dpi); - const auto& sensor_profile = get_sensor_profile(sensor, dpihw); - for (const auto& reg : sensor_profile.custom_regs) { regs->set8(reg.address, reg.value); } @@ -741,7 +736,7 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens // sensor parameters const auto& sensor_profile = get_sensor_profile(sensor, dpihw); - gl846_setup_sensor(dev, sensor, reg, dpihw); + gl846_setup_sensor(dev, sensor, sensor_profile, reg); // start and end coordinate in optical dpi coordinates unsigned startx = start / ccd_pixels_per_system_pixel + sensor.CCD_start_xoffset; diff --git a/backend/genesys_gl847.cc b/backend/genesys_gl847.cc index 529217c7a..257c0ab37 100644 --- a/backend/genesys_gl847.cc +++ b/backend/genesys_gl847.cc @@ -181,14 +181,11 @@ static const SensorProfile& get_sensor_profile(const Genesys_Sensor& sensor, uns /** @brief sensor specific settings */ static void gl847_setup_sensor(Genesys_Device * dev, const Genesys_Sensor& sensor, - Genesys_Register_Set * regs, int dpi) + const SensorProfile& sensor_profile, Genesys_Register_Set* regs) { DBG_HELPER(dbg); - int dpihw; uint16_t exp; - dpihw = sensor.get_register_hwdpi(dpi); - for (uint16_t addr = 0x16; addr < 0x1e; addr++) { regs->set8(addr, sensor.custom_regs.get_value(addr)); } @@ -197,10 +194,6 @@ 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 = sensor.get_register_hwdpi(dpi); - const auto& sensor_profile = get_sensor_profile(sensor, dpihw); - for (const auto& reg : sensor_profile.custom_regs) { regs->set8(reg.address, reg.value); } @@ -759,7 +752,7 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens // sensor parameters const auto& sensor_profile = get_sensor_profile(sensor, dpihw); - gl847_setup_sensor(dev, sensor, reg, dpihw); + gl847_setup_sensor(dev, sensor, sensor_profile, reg); dpiset = session.params.xres * ccd_pixels_per_system_pixel; // start and end coordinate in optical dpi coordinates