diff --git a/backend/genesys/enums.h b/backend/genesys/enums.h index a091c3e18..abb108fbb 100644 --- a/backend/genesys/enums.h +++ b/backend/genesys/enums.h @@ -552,6 +552,9 @@ enum class ScanFlag : unsigned USE_XPA = 1 << 9, ENABLE_LEDADD = 1 << 10, REVERSE = 1 << 12, + + // (unused): the scanner should return head to home position automatically after scan. + AUTO_GO_HOME = 1 << 13, }; inline ScanFlag operator|(ScanFlag left, ScanFlag right) @@ -591,39 +594,6 @@ inline void serialize(std::ostream& str, ScanFlag& x) std::ostream& operator<<(std::ostream& out, ScanFlag flags); - -enum class MotorFlag : unsigned -{ - NONE = 0, - AUTO_GO_HOME = 1 << 0, - DISABLE_BUFFER_FULL_MOVE = 1 << 2, - FEED = 1 << 3, - USE_XPA = 1 << 4, - REVERSE = 1 << 5, -}; - -inline MotorFlag operator|(MotorFlag left, MotorFlag right) -{ - return static_cast(static_cast(left) | static_cast(right)); -} - -inline MotorFlag& operator|=(MotorFlag& left, MotorFlag right) -{ - left = left | right; - return left; -} - -inline MotorFlag operator&(MotorFlag left, MotorFlag right) -{ - return static_cast(static_cast(left) & static_cast(right)); -} - -inline bool has_flag(MotorFlag flags, MotorFlag which) -{ - return (flags & which) == which; -} - - enum class Direction : unsigned { FORWARD = 0, diff --git a/backend/genesys/gl124.cpp b/backend/genesys/gl124.cpp index 43cf2153a..0e9b88454 100644 --- a/backend/genesys/gl124.cpp +++ b/backend/genesys/gl124.cpp @@ -504,7 +504,7 @@ static void gl124_init_motor_regs_scan(Genesys_Device* dev, unsigned int scan_dummy, unsigned int feed_steps, ScanColorMode scan_mode, - MotorFlag flags) + ScanFlag flags) { DBG_HELPER(dbg); int use_fast_fed; @@ -579,15 +579,15 @@ static void gl124_init_motor_regs_scan(Genesys_Device* dev, r02 &= ~REG_0x02_FASTFED; } - if (has_flag(flags, MotorFlag::AUTO_GO_HOME)) { + if (has_flag(flags, ScanFlag::AUTO_GO_HOME)) { r02 |= REG_0x02_AGOHOME; } - if (has_flag(flags, MotorFlag::DISABLE_BUFFER_FULL_MOVE) || (yres >= sensor.optical_res)) + if (has_flag(flags, ScanFlag::DISABLE_BUFFER_FULL_MOVE) || (yres >= sensor.optical_res)) { r02 |= REG_0x02_ACDCDIS; } - if (has_flag(flags, MotorFlag::REVERSE)) { + if (has_flag(flags, ScanFlag::REVERSE)) { r02 |= REG_0x02_MTRREV; } @@ -629,7 +629,7 @@ static void gl124_init_motor_regs_scan(Genesys_Device* dev, feedl <<= static_cast(motor_profile.step_type); dist = scan_table.steps_count; - if (has_flag(flags, MotorFlag::FEED)) { + if (has_flag(flags, ScanFlag::FEEDING)) { dist *= 2; } if (use_fast_fed) { @@ -857,19 +857,9 @@ void CommandSetGl124::init_regs_for_scan_session(Genesys_Device* dev, const Gene move = session.params.starty; DBG(DBG_info, "%s: move=%d steps\n", __func__, move); - MotorFlag mflags = MotorFlag::NONE; - if (has_flag(session.params.flags, ScanFlag::DISABLE_BUFFER_FULL_MOVE)) { - mflags |= MotorFlag::DISABLE_BUFFER_FULL_MOVE; - } - if (has_flag(session.params.flags, ScanFlag::FEEDING)) { - mflags |= MotorFlag::FEED; - } - if (has_flag(session.params.flags, ScanFlag::REVERSE)) { - mflags |= MotorFlag::REVERSE; - } gl124_init_motor_regs_scan(dev, sensor, reg, motor_profile, exposure_time, slope_dpi, session.optical_line_count, - dummy, move, session.params.scan_mode, mflags); + dummy, move, session.params.scan_mode, session.params.flags); /*** prepares data reordering ***/ diff --git a/backend/genesys/gl841.cpp b/backend/genesys/gl841.cpp index bbced7a95..156b88297 100644 --- a/backend/genesys/gl841.cpp +++ b/backend/genesys/gl841.cpp @@ -592,7 +592,7 @@ uint8_t *table; static void gl841_init_motor_regs(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, unsigned int feed_steps,/*1/base_ydpi*/ /*maybe float for half/quarter step resolution?*/ - unsigned int action, MotorFlag flags) + unsigned int action, ScanFlag flags) { DBG_HELPER_ARGS(dbg, "feed_steps=%d, action=%d, flags=%x", feed_steps, action, static_cast(flags)); @@ -660,7 +660,7 @@ static void gl841_init_motor_regs(Genesys_Device* dev, const Genesys_Sensor& sen else reg->find_reg(0x02).value &= ~0x08; - if (has_flag(flags, MotorFlag::AUTO_GO_HOME)) { + if (has_flag(flags, ScanFlag::AUTO_GO_HOME)) { reg->find_reg(0x02).value |= 0x20; } else { reg->find_reg(0x02).value &= ~0x20; @@ -668,7 +668,7 @@ static void gl841_init_motor_regs(Genesys_Device* dev, const Genesys_Sensor& sen reg->find_reg(0x02).value &= ~0x40; - if (has_flag(flags, MotorFlag::REVERSE)) { + if (has_flag(flags, ScanFlag::REVERSE)) { reg->find_reg(0x02).value |= REG_0x02_MTRREV; } @@ -693,7 +693,7 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor // number of scan lines to add in a scan_lines line unsigned int feed_steps,/*1/base_ydpi*/ // maybe float for half/quarter step resolution? - MotorFlag flags) + ScanFlag flags) { DBG_HELPER_ARGS(dbg, "scan_exposure_time=%d, scan_yres=%d, scan_step_type=%d, scan_lines=%d," " scan_dummy=%d, feed_steps=%d, flags=%x", @@ -810,36 +810,6 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor } DBG(DBG_info, "%s: Decided to use %s mode\n", __func__, use_fast_fed?"fast feed":"slow feed"); -/* all needed slopes available. we did even decide which mode to use. - what next? - - transfer slopes -SCAN: -flags \ use_fast_fed ! 0 1 -------------------------\-------------------- - 0 ! 0,1,2 0,1,2,3 -MotorFlag::AUTO_GO_HOME ! 0,1,2,4 0,1,2,3,4 -OFF: none -FEED: 3 -GO_HOME: 3 -HOME_FREE: 3 - - setup registers - * slope specific registers (already done) - * DECSEL for HOME_FREE/GO_HOME/SCAN - * FEEDL - * MTRREV - * MTRPWR - * FASTFED - * STEPSEL - * MTRPWM - * FSTPSEL - * FASTPWM - * HOMENEG - * BWDSTEP - * FWDSTEP - * Z1 - * Z2 - */ - reg->set8(0x3d, (feedl >> 16) & 0xf); reg->set8(0x3e, (feedl >> 8) & 0xff); reg->set8(0x3f, feedl & 0xff); @@ -857,12 +827,12 @@ HOME_FREE: 3 else reg->find_reg(0x02).value &= ~0x08; - if (has_flag(flags, MotorFlag::AUTO_GO_HOME)) + if (has_flag(flags, ScanFlag::AUTO_GO_HOME)) reg->find_reg(0x02).value |= 0x20; else reg->find_reg(0x02).value &= ~0x20; - if (has_flag(flags, MotorFlag::DISABLE_BUFFER_FULL_MOVE)) { + if (has_flag(flags, ScanFlag::DISABLE_BUFFER_FULL_MOVE)) { reg->find_reg(0x02).value |= 0x40; } else { reg->find_reg(0x02).value &= ~0x40; @@ -876,7 +846,7 @@ HOME_FREE: 3 gl841_send_slope_table(dev, sensor, 3, fast_table.table, 256); } - if (has_flag(flags, MotorFlag::AUTO_GO_HOME)) { + if (has_flag(flags, ScanFlag::AUTO_GO_HOME)) { gl841_send_slope_table(dev, sensor, 4, fast_table.table, 256); } @@ -1250,11 +1220,8 @@ dummy \ scanned lines if (has_flag(session.params.flags, ScanFlag::SINGLE_LINE)) { gl841_init_motor_regs_off(reg, session.optical_line_count); } else { - auto motor_flag = has_flag(session.params.flags, ScanFlag::DISABLE_BUFFER_FULL_MOVE) ? - MotorFlag::DISABLE_BUFFER_FULL_MOVE : MotorFlag::NONE; - gl841_init_motor_regs_scan(dev, sensor, reg, exposure_time, slope_dpi, scan_step_type, - session.optical_line_count, dummy, move, motor_flag); + session.optical_line_count, dummy, move, session.params.flags); } dev->read_buffer.clear(); @@ -1578,7 +1545,7 @@ void CommandSetGl841::eject_document(Genesys_Device* dev) const regs_set_optical_off(dev->model->asic_type, local_reg); const auto& sensor = sanei_genesys_find_sensor_any(dev); - gl841_init_motor_regs(dev, sensor, &local_reg, 65536, MOTOR_ACTION_FEED, MotorFlag::NONE); + gl841_init_motor_regs(dev, sensor, &local_reg, 65536, MOTOR_ACTION_FEED, ScanFlag::NONE); dev->interface->write_registers(local_reg); @@ -1849,7 +1816,7 @@ void CommandSetGl841::move_back_home(Genesys_Device* dev, bool wait_until_home) const auto& sensor = sanei_genesys_find_sensor_any(dev); - gl841_init_motor_regs(dev, sensor, &local_reg, 65536, MOTOR_ACTION_GO_HOME, MotorFlag::REVERSE); + gl841_init_motor_regs(dev, sensor, &local_reg, 65536, MOTOR_ACTION_GO_HOME, ScanFlag::REVERSE); // set up for no scan regs_set_optical_off(dev->model->asic_type, local_reg); diff --git a/backend/genesys/gl843.cpp b/backend/genesys/gl843.cpp index fb58de8f5..0cdd5aa3e 100644 --- a/backend/genesys/gl843.cpp +++ b/backend/genesys/gl843.cpp @@ -723,7 +723,7 @@ static void gl843_init_motor_regs_scan(Genesys_Device* dev, unsigned int scan_lines, unsigned int scan_dummy, unsigned int feed_steps, - MotorFlag flags) + ScanFlag flags) { DBG_HELPER_ARGS(dbg, "exposure=%d, scan_yres=%d, step_type=%d, scan_lines=%d, scan_dummy=%d, " "feed_steps=%d, flags=%x", @@ -737,7 +737,7 @@ static void gl843_init_motor_regs_scan(Genesys_Device* dev, bool use_fast_fed = false; - if ((scan_yres >= 300 && feed_steps > 900) || (has_flag(flags, MotorFlag::FEED))) { + if ((scan_yres >= 300 && feed_steps > 900) || (has_flag(flags, ScanFlag::FEEDING))) { use_fast_fed = true; } @@ -755,19 +755,19 @@ static void gl843_init_motor_regs_scan(Genesys_Device* dev, } // in case of automatic go home, move until home sensor - if (has_flag(flags, MotorFlag::AUTO_GO_HOME)) { + if (has_flag(flags, ScanFlag::AUTO_GO_HOME)) { reg02 |= REG_0x02_AGOHOME | REG_0x02_NOTHOME; } /* disable backtracking */ - if (has_flag(flags, MotorFlag::DISABLE_BUFFER_FULL_MOVE) + if (has_flag(flags, ScanFlag::DISABLE_BUFFER_FULL_MOVE) ||(scan_yres>=2400 && dev->model->model_id != ModelId::CANON_4400F) ||(scan_yres>=sensor.optical_res)) { reg02 |= REG_0x02_ACDCDIS; } - if (has_flag(flags, MotorFlag::REVERSE)) { + if (has_flag(flags, ScanFlag::REVERSE)) { reg02 |= REG_0x02_MTRREV; } else { reg02 &= ~REG_0x02_MTRREV; @@ -1094,24 +1094,9 @@ void CommandSetGl843::init_regs_for_scan_session(Genesys_Device* dev, const Gene // now _LOGICAL_ optical values used are known, setup registers gl843_init_optical_regs_scan(dev, sensor, reg, exposure, session); - - /*** motor parameters ***/ - MotorFlag mflags = MotorFlag::NONE; - if (has_flag(session.params.flags, ScanFlag::DISABLE_BUFFER_FULL_MOVE)) { - mflags |= MotorFlag::DISABLE_BUFFER_FULL_MOVE; - } - if (has_flag(session.params.flags, ScanFlag::FEEDING)) { - mflags |= MotorFlag::FEED; - } - if (has_flag(session.params.flags, ScanFlag::USE_XPA)) { - mflags |= MotorFlag::USE_XPA; - } - if (has_flag(session.params.flags, ScanFlag::REVERSE)) { - mflags |= MotorFlag::REVERSE; - } - gl843_init_motor_regs_scan(dev, sensor, session, reg, motor_profile, exposure, slope_dpi, - session.optical_line_count, dummy, session.params.starty, mflags); + session.optical_line_count, dummy, session.params.starty, + session.params.flags); dev->read_buffer.clear(); dev->read_buffer.alloc(session.buffer_size_read); diff --git a/backend/genesys/gl846.cpp b/backend/genesys/gl846.cpp index 8e05e045c..9d85b7314 100644 --- a/backend/genesys/gl846.cpp +++ b/backend/genesys/gl846.cpp @@ -405,7 +405,7 @@ static void gl846_init_motor_regs_scan(Genesys_Device* dev, unsigned int scan_lines, unsigned int scan_dummy, unsigned int feed_steps, - MotorFlag flags) + ScanFlag flags) { DBG_HELPER_ARGS(dbg, "scan_exposure_time=%d, scan_yres=%d, step_type=%d, scan_lines=%d, " "scan_dummy=%d, feed_steps=%d, flags=%x", @@ -415,7 +415,7 @@ static void gl846_init_motor_regs_scan(Genesys_Device* dev, unsigned step_multiplier = gl846_get_step_multiplier(reg); bool use_fast_fed = false; - if (dev->settings.yres == 4444 && feed_steps > 100 && !has_flag(flags, MotorFlag::FEED)) { + if (dev->settings.yres == 4444 && feed_steps > 100 && !has_flag(flags, ScanFlag::FEEDING)) { use_fast_fed = true; } @@ -432,14 +432,14 @@ static void gl846_init_motor_regs_scan(Genesys_Device* dev, reg02 &= ~REG_0x02_FASTFED; } - if (has_flag(flags, MotorFlag::AUTO_GO_HOME)) { + if (has_flag(flags, ScanFlag::AUTO_GO_HOME)) { reg02 |= REG_0x02_AGOHOME | REG_0x02_NOTHOME; } - if (has_flag(flags, MotorFlag::DISABLE_BUFFER_FULL_MOVE) ||(scan_yres>=sensor.optical_res)) { + if (has_flag(flags, ScanFlag::DISABLE_BUFFER_FULL_MOVE) || (scan_yres>=sensor.optical_res)) { reg02 |= REG_0x02_ACDCDIS; } - if (has_flag(flags, MotorFlag::REVERSE)) { + if (has_flag(flags, ScanFlag::REVERSE)) { reg02 |= REG_0x02_MTRREV; } else { reg02 &= ~REG_0x02_MTRREV; @@ -494,7 +494,7 @@ static void gl846_init_motor_regs_scan(Genesys_Device* dev, } else { feedl <<= static_cast(motor_profile.step_type); dist = scan_table.steps_count; - if (has_flag(flags, MotorFlag::FEED)) { + if (has_flag(flags, ScanFlag::FEEDING)) { dist *= 2; } } @@ -738,20 +738,9 @@ void CommandSetGl846::init_regs_for_scan_session(Genesys_Device* dev, const Gene * scan since color calibration is OK for this mode */ gl846_init_optical_regs_scan(dev, sensor, reg, exposure_time, session); - - MotorFlag mflags = MotorFlag::NONE; - if (has_flag(session.params.flags, ScanFlag::DISABLE_BUFFER_FULL_MOVE)) { - mflags |= MotorFlag::DISABLE_BUFFER_FULL_MOVE; - } - if (has_flag(session.params.flags, ScanFlag::FEEDING)) { - mflags |= MotorFlag::FEED; - } - if (has_flag(session.params.flags, ScanFlag::REVERSE)) { - mflags |= MotorFlag::REVERSE; - } - gl846_init_motor_regs_scan(dev, sensor, session, reg, motor_profile, exposure_time, slope_dpi, - session.optical_line_count, dummy, session.params.starty, mflags); + session.optical_line_count, dummy, session.params.starty, + session.params.flags); /*** prepares data reordering ***/ diff --git a/backend/genesys/gl847.cpp b/backend/genesys/gl847.cpp index 797a3cb35..12846f0b6 100644 --- a/backend/genesys/gl847.cpp +++ b/backend/genesys/gl847.cpp @@ -342,7 +342,7 @@ static void gl847_init_motor_regs_scan(Genesys_Device* dev, unsigned int scan_lines, unsigned int scan_dummy, unsigned int feed_steps, - MotorFlag flags) + ScanFlag flags) { DBG_HELPER_ARGS(dbg, "scan_exposure_time=%d, can_yres=%d, step_type=%d, scan_lines=%d, " "scan_dummy=%d, feed_steps=%d, flags=%x", @@ -352,7 +352,7 @@ static void gl847_init_motor_regs_scan(Genesys_Device* dev, unsigned step_multiplier = gl847_get_step_multiplier (reg); bool use_fast_fed = false; - if (dev->settings.yres == 4444 && feed_steps > 100 && !has_flag(flags, MotorFlag::FEED)) { + if (dev->settings.yres == 4444 && feed_steps > 100 && !has_flag(flags, ScanFlag::FEEDING)) { use_fast_fed = true; } @@ -369,14 +369,14 @@ static void gl847_init_motor_regs_scan(Genesys_Device* dev, reg02 &= ~REG_0x02_FASTFED; } - if (has_flag(flags, MotorFlag::AUTO_GO_HOME)) { + if (has_flag(flags, ScanFlag::AUTO_GO_HOME)) { reg02 |= REG_0x02_AGOHOME | REG_0x02_NOTHOME; } - if (has_flag(flags, MotorFlag::DISABLE_BUFFER_FULL_MOVE) ||(scan_yres>=sensor.optical_res)) { + if (has_flag(flags, ScanFlag::DISABLE_BUFFER_FULL_MOVE) || (scan_yres >= sensor.optical_res)) { reg02 |= REG_0x02_ACDCDIS; } - if (has_flag(flags, MotorFlag::REVERSE)) { + if (has_flag(flags, ScanFlag::REVERSE)) { reg02 |= REG_0x02_MTRREV; } else { reg02 &= ~REG_0x02_MTRREV; @@ -423,7 +423,7 @@ static void gl847_init_motor_regs_scan(Genesys_Device* dev, } else { feedl <<= static_cast(motor_profile.step_type); dist = scan_table.steps_count; - if (has_flag(flags, MotorFlag::FEED)) { + if (has_flag(flags, ScanFlag::FEEDING)) { dist *= 2; } } @@ -631,7 +631,6 @@ void CommandSetGl847::init_regs_for_scan_session(Genesys_Device* dev, const Gene DBG_HELPER(dbg); session.assert_computed(); - int move; int exposure_time; int slope_dpi = 0; @@ -661,23 +660,9 @@ void CommandSetGl847::init_regs_for_scan_session(Genesys_Device* dev, const Gene * scan since color calibration is OK for this mode */ gl847_init_optical_regs_scan(dev, sensor, reg, exposure_time, session); - - move = session.params.starty; - DBG(DBG_info, "%s: move=%d steps\n", __func__, move); - - MotorFlag mflags = MotorFlag::NONE; - if (has_flag(session.params.flags, ScanFlag::DISABLE_BUFFER_FULL_MOVE)) { - mflags |= MotorFlag::DISABLE_BUFFER_FULL_MOVE; - } - if (has_flag(session.params.flags, ScanFlag::FEEDING)) { - mflags |= MotorFlag::FEED; - } - if (has_flag(session.params.flags, ScanFlag::REVERSE)) { - mflags |= MotorFlag::REVERSE; - } - gl847_init_motor_regs_scan(dev, sensor, reg, motor_profile, exposure_time, slope_dpi, - session.optical_line_count, dummy, move, mflags); + session.optical_line_count, dummy, session.params.starty, + session.params.flags); dev->read_buffer.clear(); dev->read_buffer.alloc(session.buffer_size_read);