kopia lustrzana https://gitlab.com/sane-project/backends
Merge branch 'genesys-motors-refactor' into 'master'
genesys: Extract move chip-specific motor handling code to the common area See merge request sane-project/backends!256merge-requests/213/head
commit
ae732126b9
|
@ -107,8 +107,7 @@ public:
|
|||
Genesys_Register_Set& regs) const = 0;
|
||||
|
||||
virtual void wait_for_motor_stop(Genesys_Device* dev) const = 0;
|
||||
virtual void slow_back_home(Genesys_Device* dev, bool wait_until_home) const = 0;
|
||||
virtual void slow_back_home_ta(Genesys_Device& dev) const = 0;
|
||||
virtual void move_back_home(Genesys_Device* dev, bool wait_until_home) const = 0;
|
||||
|
||||
virtual void rewind(Genesys_Device* dev) const = 0;
|
||||
|
||||
|
|
|
@ -874,6 +874,7 @@ void sanei_genesys_search_reference_point(Genesys_Device* dev, Genesys_Sensor& s
|
|||
|
||||
namespace gl843 {
|
||||
void gl843_park_xpa_lamp(Genesys_Device* dev);
|
||||
void gl843_set_xpa_motor_power(Genesys_Device* dev, Genesys_Register_Set& regs, bool set);
|
||||
} // namespace gl843
|
||||
|
||||
namespace gl124 {
|
||||
|
@ -1046,17 +1047,19 @@ void scanner_stop_action_no_move(Genesys_Device& dev, genesys::Genesys_Register_
|
|||
dev.interface->sleep_ms(100);
|
||||
}
|
||||
|
||||
void scanner_move(Genesys_Device& dev, unsigned steps, Direction direction)
|
||||
void scanner_move(Genesys_Device& dev, ScanMethod scan_method, unsigned steps, Direction direction)
|
||||
{
|
||||
DBG_HELPER_ARGS(dbg, "steps=%d direction=%d", steps, static_cast<unsigned>(direction));
|
||||
|
||||
auto local_reg = dev.reg;
|
||||
|
||||
auto scan_method = dev.model->default_method;
|
||||
unsigned resolution = dev.model->get_resolution_settings(scan_method).get_min_resolution_y();
|
||||
|
||||
const auto& sensor = sanei_genesys_find_sensor(&dev, resolution, 3, scan_method);
|
||||
|
||||
bool uses_secondary_head = (scan_method == ScanMethod::TRANSPARENCY ||
|
||||
scan_method == ScanMethod::TRANSPARENCY_INFRARED);
|
||||
|
||||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
session.params.yres = resolution;
|
||||
|
@ -1096,10 +1099,16 @@ void scanner_move(Genesys_Device& dev, unsigned steps, Direction direction)
|
|||
scanner_clear_scan_and_feed_counts2(dev);
|
||||
|
||||
dev.interface->write_registers(local_reg);
|
||||
if (uses_secondary_head) {
|
||||
gl843::gl843_set_xpa_motor_power(&dev, local_reg, true);
|
||||
}
|
||||
|
||||
try {
|
||||
scanner_start_action(dev, true);
|
||||
} catch (...) {
|
||||
catch_all_exceptions(__func__, [&]() {
|
||||
gl843::gl843_set_xpa_motor_power(&dev, local_reg, false);
|
||||
});
|
||||
catch_all_exceptions(__func__, [&]() { scanner_stop_action(dev); });
|
||||
// restore original registers
|
||||
catch_all_exceptions(__func__, [&]() { dev.interface->write_registers(dev.reg); });
|
||||
|
@ -1108,11 +1117,13 @@ void scanner_move(Genesys_Device& dev, unsigned steps, Direction direction)
|
|||
|
||||
if (is_testing_mode()) {
|
||||
dev.interface->test_checkpoint("feed");
|
||||
|
||||
// FIXME: why don't we stop the scanner like on other ASICs
|
||||
if (dev.model->asic_type != AsicType::GL843) {
|
||||
scanner_stop_action(dev);
|
||||
}
|
||||
if (uses_secondary_head) {
|
||||
gl843::gl843_set_xpa_motor_power(&dev, local_reg, false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1127,12 +1138,15 @@ void scanner_move(Genesys_Device& dev, unsigned steps, Direction direction)
|
|||
if (dev.model->asic_type != AsicType::GL843) {
|
||||
scanner_stop_action(dev);
|
||||
}
|
||||
if (uses_secondary_head) {
|
||||
gl843::gl843_set_xpa_motor_power(&dev, local_reg, false);
|
||||
}
|
||||
|
||||
// looks like certain scanners lock up if we scan immediately after feeding
|
||||
dev.interface->sleep_ms(100);
|
||||
}
|
||||
|
||||
void scanner_slow_back_home(Genesys_Device& dev, bool wait_until_home)
|
||||
void scanner_move_back_home(Genesys_Device& dev, bool wait_until_home)
|
||||
{
|
||||
DBG_HELPER_ARGS(dbg, "wait_until_home = %d", wait_until_home);
|
||||
|
||||
|
@ -1148,7 +1162,7 @@ void scanner_slow_back_home(Genesys_Device& dev, bool wait_until_home)
|
|||
}
|
||||
|
||||
if (dev.needs_home_ta) {
|
||||
dev.cmd_set->slow_back_home_ta(dev);
|
||||
scanner_move_back_home_ta(dev);
|
||||
}
|
||||
|
||||
if (dev.cmd_set->needs_update_home_sensor_gpio()) {
|
||||
|
@ -1169,7 +1183,7 @@ void scanner_slow_back_home(Genesys_Device& dev, bool wait_until_home)
|
|||
|
||||
if (dev.model->model_id == ModelId::CANON_LIDE_210) {
|
||||
// move the head back a little first
|
||||
scanner_move(dev, 20, Direction::BACKWARD);
|
||||
scanner_move(dev, dev.model->default_method, 20, Direction::BACKWARD);
|
||||
}
|
||||
|
||||
Genesys_Register_Set local_reg = dev.reg;
|
||||
|
@ -1235,7 +1249,7 @@ void scanner_slow_back_home(Genesys_Device& dev, bool wait_until_home)
|
|||
}
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev.interface->test_checkpoint("slow_back_home");
|
||||
dev.interface->test_checkpoint("move_back_home");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1265,6 +1279,83 @@ void scanner_slow_back_home(Genesys_Device& dev, bool wait_until_home)
|
|||
dbg.log(DBG_info, "scanhead is still moving");
|
||||
}
|
||||
|
||||
void scanner_move_back_home_ta(Genesys_Device& dev)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
|
||||
switch (dev.model->asic_type) {
|
||||
case AsicType::GL843:
|
||||
break;
|
||||
default:
|
||||
throw SaneException("Unsupported asic type");
|
||||
}
|
||||
|
||||
Genesys_Register_Set local_reg = dev.reg;
|
||||
|
||||
auto scan_method = ScanMethod::TRANSPARENCY;
|
||||
unsigned resolution = dev.model->get_resolution_settings(scan_method).get_min_resolution_y();
|
||||
|
||||
const auto& sensor = sanei_genesys_find_sensor(&dev, resolution, 1, scan_method);
|
||||
|
||||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
session.params.yres = resolution;
|
||||
session.params.startx = 100;
|
||||
session.params.starty = 30000;
|
||||
session.params.pixels = 100;
|
||||
session.params.lines = 100;
|
||||
session.params.depth = 8;
|
||||
session.params.channels = 1;
|
||||
session.params.scan_method = scan_method;
|
||||
session.params.scan_mode = ScanColorMode::GRAY;
|
||||
session.params.color_filter = ColorFilter::RED;
|
||||
session.params.flags = ScanFlag::DISABLE_SHADING |
|
||||
ScanFlag::DISABLE_GAMMA |
|
||||
ScanFlag::IGNORE_LINE_DISTANCE |
|
||||
ScanFlag::REVERSE;
|
||||
|
||||
compute_session(&dev, session, sensor);
|
||||
|
||||
dev.cmd_set->init_regs_for_scan_session(&dev, sensor, &local_reg, session);
|
||||
|
||||
scanner_clear_scan_and_feed_counts(dev);
|
||||
|
||||
dev.interface->write_registers(local_reg);
|
||||
gl843::gl843_set_xpa_motor_power(&dev, local_reg, true);
|
||||
|
||||
try {
|
||||
scanner_start_action(dev, true);
|
||||
} catch (...) {
|
||||
catch_all_exceptions(__func__, [&]() { scanner_stop_action(dev); });
|
||||
// restore original registers
|
||||
catch_all_exceptions(__func__, [&]() { dev.interface->write_registers(dev.reg); });
|
||||
throw;
|
||||
}
|
||||
|
||||
if (is_testing_mode()) {
|
||||
scanner_stop_action(dev);
|
||||
return;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < 300; ++i) {
|
||||
|
||||
auto status = scanner_read_status(dev);
|
||||
|
||||
if (status.is_at_home) {
|
||||
dbg.log(DBG_info, "TA reached home position");
|
||||
scanner_stop_action(dev);
|
||||
gl843::gl843_set_xpa_motor_power(&dev, local_reg, false);
|
||||
dev.needs_home_ta = false;
|
||||
return;
|
||||
}
|
||||
|
||||
dev.interface->sleep_ms(100);
|
||||
}
|
||||
|
||||
// we are not parked here.... should we fail ?
|
||||
dbg.log(DBG_info, "XPA lamp is not parked");
|
||||
}
|
||||
|
||||
void sanei_genesys_calculate_zmod(bool two_table,
|
||||
uint32_t exposure_time,
|
||||
const std::vector<uint16_t>& slope_table,
|
||||
|
@ -1794,7 +1885,7 @@ static void genesys_repark_sensor_before_shading(Genesys_Device* dev)
|
|||
if (dev->cmd_set->has_rewind()) {
|
||||
dev->cmd_set->rewind(dev);
|
||||
} else {
|
||||
dev->cmd_set->slow_back_home(dev, true);
|
||||
dev->cmd_set->move_back_home(dev, true);
|
||||
}
|
||||
|
||||
if (dev->settings.scan_method == ScanMethod::TRANSPARENCY ||
|
||||
|
@ -1809,7 +1900,7 @@ static void genesys_repark_sensor_after_white_shading(Genesys_Device* dev)
|
|||
{
|
||||
DBG_HELPER(dbg);
|
||||
if (dev->model->flags & GENESYS_FLAG_SHADING_REPARK) {
|
||||
dev->cmd_set->slow_back_home(dev, true);
|
||||
dev->cmd_set->move_back_home(dev, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3234,7 +3325,7 @@ static void genesys_start_scan(Genesys_Device* dev, bool lamp_off)
|
|||
dev->cmd_set->search_start_position (dev);
|
||||
|
||||
dev->parking = false;
|
||||
dev->cmd_set->slow_back_home (dev, true);
|
||||
dev->cmd_set->move_back_home(dev, true);
|
||||
dev->scanhead_position_in_steps = 0;
|
||||
}
|
||||
else
|
||||
|
@ -3243,7 +3334,7 @@ static void genesys_start_scan(Genesys_Device* dev, bool lamp_off)
|
|||
/* TODO: check we can drop this since we cannot have the
|
||||
scanner's head wandering here */
|
||||
dev->parking = false;
|
||||
dev->cmd_set->slow_back_home (dev, true);
|
||||
dev->cmd_set->move_back_home(dev, true);
|
||||
|
||||
dev->scanhead_position_in_steps = 0;
|
||||
}
|
||||
|
@ -3293,7 +3384,7 @@ static void genesys_start_scan(Genesys_Device* dev, bool lamp_off)
|
|||
dev->cmd_set->wait_for_motor_stop(dev);
|
||||
|
||||
if (dev->cmd_set->needs_home_before_init_regs_for_scan(dev)) {
|
||||
dev->cmd_set->slow_back_home(dev, true);
|
||||
dev->cmd_set->move_back_home(dev, true);
|
||||
}
|
||||
|
||||
if (dev->settings.scan_method == ScanMethod::TRANSPARENCY ||
|
||||
|
@ -3412,7 +3503,7 @@ static void genesys_read_ordered_data(Genesys_Device* dev, SANE_Byte* destinatio
|
|||
if (!dev->model->is_sheetfed && !(dev->model->flags & GENESYS_FLAG_MUST_WAIT) &&
|
||||
!dev->parking)
|
||||
{
|
||||
dev->cmd_set->slow_back_home(dev, false);
|
||||
dev->cmd_set->move_back_home(dev, false);
|
||||
dev->parking = true;
|
||||
}
|
||||
throw SaneException(SANE_STATUS_EOF, "nothing more to scan: EOF");
|
||||
|
@ -4751,7 +4842,7 @@ static void genesys_buffer_image(Genesys_Scanner *s)
|
|||
* computing so we can save time
|
||||
*/
|
||||
if (!dev->model->is_sheetfed && !dev->parking) {
|
||||
dev->cmd_set->slow_back_home(dev, dev->model->flags & GENESYS_FLAG_MUST_WAIT);
|
||||
dev->cmd_set->move_back_home(dev, dev->model->flags & GENESYS_FLAG_MUST_WAIT);
|
||||
dev->parking = !(s->dev->model->flags & GENESYS_FLAG_MUST_WAIT);
|
||||
}
|
||||
|
||||
|
@ -5959,7 +6050,7 @@ void sane_read_impl(SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_
|
|||
if (!dev->model->is_sheetfed && !(dev->model->flags & GENESYS_FLAG_MUST_WAIT) &&
|
||||
!dev->parking)
|
||||
{
|
||||
dev->cmd_set->slow_back_home(dev, false);
|
||||
dev->cmd_set->move_back_home(dev, false);
|
||||
dev->parking = true;
|
||||
}
|
||||
throw SaneException(SANE_STATUS_EOF);
|
||||
|
@ -6056,7 +6147,7 @@ void sane_cancel_impl(SANE_Handle handle)
|
|||
/* park head if flatbed scanner */
|
||||
if (!s->dev->model->is_sheetfed) {
|
||||
if (!s->dev->parking) {
|
||||
s->dev->cmd_set->slow_back_home (s->dev, s->dev->model->flags &
|
||||
s->dev->cmd_set->move_back_home (s->dev, s->dev->model->flags &
|
||||
GENESYS_FLAG_MUST_WAIT);
|
||||
|
||||
s->dev->parking = !(s->dev->model->flags & GENESYS_FLAG_MUST_WAIT);
|
||||
|
|
|
@ -1125,15 +1125,9 @@ void CommandSetGl124::rewind(Genesys_Device* dev) const
|
|||
* @param wait_until_home true to make the function waiting for head
|
||||
* to be home before returning, if fals returne immediately
|
||||
*/
|
||||
void CommandSetGl124::slow_back_home(Genesys_Device* dev, bool wait_until_home) const
|
||||
void CommandSetGl124::move_back_home(Genesys_Device* dev, bool wait_until_home) const
|
||||
{
|
||||
scanner_slow_back_home(*dev, wait_until_home);
|
||||
}
|
||||
|
||||
void CommandSetGl124::slow_back_home_ta(Genesys_Device& dev) const
|
||||
{
|
||||
(void) dev;
|
||||
throw SaneException("not implemented");
|
||||
scanner_move_back_home(*dev, wait_until_home);
|
||||
}
|
||||
|
||||
// Automatically set top-left edge of the scan area by scanning a 200x200 pixels area at 600 dpi
|
||||
|
@ -1357,7 +1351,8 @@ void CommandSetGl124::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
DBG (DBG_info, "%s: move=%f steps\n", __func__, move);
|
||||
|
||||
if (dev->settings.get_channels() * dev->settings.yres >= 600 && move > 700) {
|
||||
scanner_move(*dev, static_cast<unsigned>(move - 500), Direction::FORWARD);
|
||||
scanner_move(*dev, dev->model->default_method, static_cast<unsigned>(move - 500),
|
||||
Direction::FORWARD);
|
||||
move=500;
|
||||
}
|
||||
DBG(DBG_info, "%s: move=%f steps\n", __func__, move);
|
||||
|
@ -1967,7 +1962,7 @@ void CommandSetGl124::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("coarse_gain_calibration");
|
||||
scanner_stop_action(*dev);
|
||||
slow_back_home(dev, true);
|
||||
move_back_home(dev, true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2028,7 +2023,7 @@ void CommandSetGl124::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
|
||||
scanner_stop_action(*dev);
|
||||
|
||||
slow_back_home(dev, true);
|
||||
move_back_home(dev, true);
|
||||
}
|
||||
|
||||
// wait for lamp warmup by scanning the same line until difference
|
||||
|
|
|
@ -160,8 +160,7 @@ public:
|
|||
Genesys_Register_Set& regs) const override;
|
||||
|
||||
void wait_for_motor_stop(Genesys_Device* dev) const override;
|
||||
void slow_back_home(Genesys_Device* dev, bool wait_until_home) const override;
|
||||
void slow_back_home_ta(Genesys_Device& dev) const override;
|
||||
void move_back_home(Genesys_Device* dev, bool wait_until_home) const override;
|
||||
void rewind(Genesys_Device* dev) const override;
|
||||
|
||||
void update_hardware_sensors(struct Genesys_Scanner* s) const override;
|
||||
|
|
|
@ -1451,7 +1451,7 @@ void CommandSetGl646::end_scan(Genesys_Device* dev, Genesys_Register_Set* reg,
|
|||
* @param dev scanner's device
|
||||
* @param wait_until_home true if the function waits until head parked
|
||||
*/
|
||||
void CommandSetGl646::slow_back_home(Genesys_Device* dev, bool wait_until_home) const
|
||||
void CommandSetGl646::move_back_home(Genesys_Device* dev, bool wait_until_home) const
|
||||
{
|
||||
DBG_HELPER_ARGS(dbg, "wait_until_home = %d\n", wait_until_home);
|
||||
int i;
|
||||
|
@ -1545,7 +1545,7 @@ void CommandSetGl646::slow_back_home(Genesys_Device* dev, bool wait_until_home)
|
|||
dev->cmd_set->begin_scan(dev, sensor, &dev->reg, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("slow_back_home");
|
||||
dev->interface->test_checkpoint("move_back_home");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1577,12 +1577,6 @@ void CommandSetGl646::slow_back_home(Genesys_Device* dev, bool wait_until_home)
|
|||
DBG(DBG_info, "%s: scanhead is still moving\n", __func__);
|
||||
}
|
||||
|
||||
void CommandSetGl646::slow_back_home_ta(Genesys_Device& dev) const
|
||||
{
|
||||
(void) dev;
|
||||
throw SaneException("not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically set top-left edge of the scan area by scanning an
|
||||
* area at 300 dpi from very top of scanner
|
||||
|
@ -2701,7 +2695,7 @@ static void gl646_repark_head(Genesys_Device* dev)
|
|||
while (steps < expected);
|
||||
|
||||
// toggle motor flag, put an huge step number and redo move backward
|
||||
dev->cmd_set->slow_back_home(dev, 1);
|
||||
dev->cmd_set->move_back_home(dev, 1);
|
||||
}
|
||||
|
||||
/* *
|
||||
|
@ -2846,7 +2840,7 @@ void CommandSetGl646::init(Genesys_Device* dev) const
|
|||
}
|
||||
else
|
||||
{
|
||||
slow_back_home(dev, true);
|
||||
move_back_home(dev, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -281,8 +281,7 @@ public:
|
|||
Genesys_Register_Set& regs) const override;
|
||||
|
||||
void wait_for_motor_stop(Genesys_Device* dev) const override;
|
||||
void slow_back_home(Genesys_Device* dev, bool wait_until_home) const override;
|
||||
void slow_back_home_ta(Genesys_Device& dev) const override;
|
||||
void move_back_home(Genesys_Device* dev, bool wait_until_home) const override;
|
||||
void rewind(Genesys_Device* dev) const override;
|
||||
|
||||
bool has_rewind() const override { return false; }
|
||||
|
|
|
@ -2210,7 +2210,7 @@ static void gl841_feed(Genesys_Device* dev, int steps)
|
|||
}
|
||||
|
||||
// Moves the slider to the home (top) position slowly
|
||||
void CommandSetGl841::slow_back_home(Genesys_Device* dev, bool wait_until_home) const
|
||||
void CommandSetGl841::move_back_home(Genesys_Device* dev, bool wait_until_home) const
|
||||
{
|
||||
DBG_HELPER_ARGS(dbg, "wait_until_home = %d", wait_until_home);
|
||||
Genesys_Register_Set local_reg;
|
||||
|
@ -2278,7 +2278,7 @@ void CommandSetGl841::slow_back_home(Genesys_Device* dev, bool wait_until_home)
|
|||
}
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("slow_back_home");
|
||||
dev->interface->test_checkpoint("move_back_home");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2305,12 +2305,6 @@ void CommandSetGl841::slow_back_home(Genesys_Device* dev, bool wait_until_home)
|
|||
DBG(DBG_info, "%s: scanhead is still moving\n", __func__);
|
||||
}
|
||||
|
||||
void CommandSetGl841::slow_back_home_ta(Genesys_Device& dev) const
|
||||
{
|
||||
(void) dev;
|
||||
throw SaneException("not implemented");
|
||||
}
|
||||
|
||||
// Automatically set top-left edge of the scan area by scanning a 200x200 pixels area at 600 dpi
|
||||
// from very top of scanner
|
||||
void CommandSetGl841::search_start_position(Genesys_Device* dev) const
|
||||
|
@ -2710,7 +2704,7 @@ SensorExposure CommandSetGl841::led_calibration(Genesys_Device* dev, const Genes
|
|||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("led_calibration");
|
||||
slow_back_home(dev, true);
|
||||
move_back_home(dev, true);
|
||||
return { 0, 0, 0 };
|
||||
}
|
||||
|
||||
|
@ -2815,7 +2809,7 @@ SensorExposure CommandSetGl841::led_calibration(Genesys_Device* dev, const Genes
|
|||
|
||||
DBG(DBG_info,"%s: acceptable exposure: %d,%d,%d\n", __func__, exp[0], exp[1], exp[2]);
|
||||
|
||||
dev->cmd_set->slow_back_home(dev, true);
|
||||
dev->cmd_set->move_back_home(dev, true);
|
||||
|
||||
return calib_sensor.exposure;
|
||||
}
|
||||
|
@ -3384,7 +3378,7 @@ void CommandSetGl841::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("coarse_gain_calibration");
|
||||
gl841_stop_action(dev);
|
||||
slow_back_home(dev, true);
|
||||
move_back_home(dev, true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3481,7 +3475,7 @@ void CommandSetGl841::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
|
||||
gl841_stop_action(dev);
|
||||
|
||||
dev->cmd_set->slow_back_home(dev, true);
|
||||
dev->cmd_set->move_back_home(dev, true);
|
||||
}
|
||||
|
||||
// wait for lamp warmup by scanning the same line until difference
|
||||
|
@ -3546,7 +3540,7 @@ static void sanei_gl841_repark_head(Genesys_Device* dev)
|
|||
gl841_feed(dev,232);
|
||||
|
||||
// toggle motor flag, put an huge step number and redo move backward
|
||||
dev->cmd_set->slow_back_home(dev, true);
|
||||
dev->cmd_set->move_back_home(dev, true);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3592,11 +3586,11 @@ void CommandSetGl841::init(Genesys_Device* dev) const
|
|||
// Set analog frontend
|
||||
dev->cmd_set->set_fe(dev, sensor, AFE_INIT);
|
||||
|
||||
// FIXME: slow_back_home modifies dev->calib_reg and requires it to be filled
|
||||
// FIXME: move_back_home modifies dev->calib_reg and requires it to be filled
|
||||
dev->calib_reg = dev->reg;
|
||||
|
||||
// Move home
|
||||
dev->cmd_set->slow_back_home(dev, true);
|
||||
dev->cmd_set->move_back_home(dev, true);
|
||||
|
||||
// Init shading data
|
||||
sanei_genesys_init_shading_data(dev, sensor, sensor.sensor_pixels);
|
||||
|
|
|
@ -98,8 +98,7 @@ public:
|
|||
Genesys_Register_Set& regs) const override;
|
||||
|
||||
void wait_for_motor_stop(Genesys_Device* dev) const override;
|
||||
void slow_back_home(Genesys_Device* dev, bool wait_until_home) const override;
|
||||
void slow_back_home_ta(Genesys_Device& dev) const override;
|
||||
void move_back_home(Genesys_Device* dev, bool wait_until_home) const override;
|
||||
void rewind(Genesys_Device* dev) const override;
|
||||
|
||||
bool has_rewind() const override { return false; }
|
||||
|
|
|
@ -1386,8 +1386,9 @@ void CommandSetGl843::detect_document_end(Genesys_Device* dev) const
|
|||
}
|
||||
|
||||
// enables or disables XPA slider motor
|
||||
static void gl843_set_xpa_motor_power(Genesys_Device* dev, bool set)
|
||||
void gl843_set_xpa_motor_power(Genesys_Device* dev, Genesys_Register_Set& regs, bool set)
|
||||
{
|
||||
(void) regs;
|
||||
DBG_HELPER(dbg);
|
||||
uint8_t val;
|
||||
|
||||
|
@ -1606,7 +1607,7 @@ void CommandSetGl843::begin_scan(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
|
||||
if (reg->state.is_xpa_on) {
|
||||
dev->needs_home_ta = true;
|
||||
gl843_set_xpa_motor_power(dev, true);
|
||||
gl843_set_xpa_motor_power(dev, *reg, true);
|
||||
}
|
||||
|
||||
// blinking led
|
||||
|
@ -1619,7 +1620,7 @@ void CommandSetGl843::begin_scan(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
}
|
||||
if (reg->state.is_xpa_on) {
|
||||
dev->needs_home_ta = true;
|
||||
gl843_set_xpa_motor_power(dev, true);
|
||||
gl843_set_xpa_motor_power(dev, *reg, true);
|
||||
}
|
||||
break;
|
||||
case GpioId::PLUSTEK_OPTICFILM_7200I:
|
||||
|
@ -1667,77 +1668,11 @@ void CommandSetGl843::end_scan(Genesys_Device* dev, Genesys_Register_Set* reg,
|
|||
}
|
||||
}
|
||||
|
||||
/** @brief park XPA lamp
|
||||
* park the XPA lamp if needed
|
||||
*/
|
||||
void CommandSetGl843::slow_back_home_ta(Genesys_Device& dev) const
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
Genesys_Register_Set local_reg = dev.reg;
|
||||
|
||||
auto scan_method = ScanMethod::TRANSPARENCY;
|
||||
unsigned resolution = dev.model->get_resolution_settings(scan_method).get_min_resolution_y();
|
||||
|
||||
const auto& sensor = sanei_genesys_find_sensor(&dev, resolution, 1, scan_method);
|
||||
|
||||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
session.params.yres = resolution;
|
||||
session.params.startx = 100;
|
||||
session.params.starty = 30000;
|
||||
session.params.pixels = 100;
|
||||
session.params.lines = 100;
|
||||
session.params.depth = 8;
|
||||
session.params.channels = 1;
|
||||
session.params.scan_method = scan_method;
|
||||
session.params.scan_mode = ScanColorMode::GRAY;
|
||||
session.params.color_filter = ColorFilter::RED;
|
||||
session.params.flags = ScanFlag::DISABLE_SHADING |
|
||||
ScanFlag::DISABLE_GAMMA |
|
||||
ScanFlag::IGNORE_LINE_DISTANCE |
|
||||
ScanFlag::REVERSE;
|
||||
|
||||
compute_session(&dev, session, sensor);
|
||||
|
||||
dev.cmd_set->init_regs_for_scan_session(&dev, sensor, &local_reg, session);
|
||||
|
||||
scanner_clear_scan_and_feed_counts(dev);
|
||||
|
||||
dev.interface->write_registers(local_reg);
|
||||
gl843_set_xpa_motor_power(&dev, true);
|
||||
try {
|
||||
scanner_start_action(dev, true);
|
||||
} catch (...) {
|
||||
catch_all_exceptions(__func__, [&]() { scanner_stop_action(dev); });
|
||||
// restore original registers
|
||||
catch_all_exceptions(__func__, [&]() { dev.interface->write_registers(dev.reg); });
|
||||
throw;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < 300; ++i) {
|
||||
|
||||
auto status = scanner_read_status(dev);
|
||||
|
||||
if (status.is_at_home) {
|
||||
dbg.log(DBG_info, "TA reached home position");
|
||||
scanner_stop_action(dev);
|
||||
gl843_set_xpa_motor_power(&dev, false);
|
||||
dev.needs_home_ta = false;
|
||||
return;
|
||||
}
|
||||
|
||||
dev.interface->sleep_ms(100);
|
||||
}
|
||||
|
||||
// we are not parked here.... should we fail ?
|
||||
dbg.log(DBG_info, "XPA lamp is not parked");
|
||||
}
|
||||
|
||||
/** @brief Moves the slider to the home (top) position slowly
|
||||
* */
|
||||
void CommandSetGl843::slow_back_home(Genesys_Device* dev, bool wait_until_home) const
|
||||
void CommandSetGl843::move_back_home(Genesys_Device* dev, bool wait_until_home) const
|
||||
{
|
||||
scanner_slow_back_home(*dev, wait_until_home);
|
||||
scanner_move_back_home(*dev, wait_until_home);
|
||||
}
|
||||
|
||||
// Automatically set top-left edge of the scan area by scanning a 200x200 pixels area at 600 dpi
|
||||
|
@ -2142,7 +2077,7 @@ SensorExposure CommandSetGl843::led_calibration(Genesys_Device* dev, const Genes
|
|||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("led_calibration");
|
||||
slow_back_home(dev, true);
|
||||
move_back_home(dev, true);
|
||||
return { 0, 0, 0 };
|
||||
}
|
||||
|
||||
|
@ -2215,7 +2150,7 @@ SensorExposure CommandSetGl843::led_calibration(Genesys_Device* dev, const Genes
|
|||
|
||||
DBG(DBG_info, "%s: acceptable exposure: %d,%d,%d\n", __func__, expr, expg, expb);
|
||||
|
||||
slow_back_home(dev, true);
|
||||
move_back_home(dev, true);
|
||||
|
||||
return calib_sensor.exposure;
|
||||
}
|
||||
|
@ -2567,7 +2502,7 @@ void CommandSetGl843::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("coarse_gain_calibration");
|
||||
scanner_stop_action(*dev);
|
||||
slow_back_home(dev, true);
|
||||
move_back_home(dev, true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2621,7 +2556,7 @@ void CommandSetGl843::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
|
||||
scanner_stop_action(*dev);
|
||||
|
||||
slow_back_home(dev, true);
|
||||
move_back_home(dev, true);
|
||||
}
|
||||
|
||||
// wait for lamp warmup by scanning the same line until difference
|
||||
|
@ -2795,7 +2730,7 @@ void CommandSetGl843::asic_boot(Genesys_Device* dev, bool cold) const
|
|||
// setup gpio
|
||||
gl843_init_gpio(dev);
|
||||
|
||||
scanner_move(*dev, 300, Direction::FORWARD);
|
||||
scanner_move(*dev, dev->model->default_method, 300, Direction::FORWARD);
|
||||
dev->interface->sleep_ms(100);
|
||||
}
|
||||
|
||||
|
@ -2855,7 +2790,7 @@ void CommandSetGl843::move_to_ta(Genesys_Device* dev) const
|
|||
}
|
||||
unsigned feed = static_cast<unsigned>(multiplier * (dev->model->y_offset_sensor_to_ta * resolution) /
|
||||
MM_PER_INCH);
|
||||
scanner_move(*dev, feed, Direction::FORWARD);
|
||||
scanner_move(*dev, dev->model->default_method, feed, Direction::FORWARD);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -98,8 +98,7 @@ public:
|
|||
Genesys_Register_Set& regs) const override;
|
||||
|
||||
void wait_for_motor_stop(Genesys_Device* dev) const override;
|
||||
void slow_back_home(Genesys_Device* dev, bool wait_until_home) const override;
|
||||
void slow_back_home_ta(Genesys_Device& dev) const override;
|
||||
void move_back_home(Genesys_Device* dev, bool wait_until_home) const override;
|
||||
void rewind(Genesys_Device* dev) const override;
|
||||
|
||||
bool has_rewind() const override { return false; }
|
||||
|
|
|
@ -883,15 +883,9 @@ void CommandSetGl846::end_scan(Genesys_Device* dev, Genesys_Register_Set* reg,
|
|||
}
|
||||
|
||||
// Moves the slider to the home (top) postion slowly
|
||||
void CommandSetGl846::slow_back_home(Genesys_Device* dev, bool wait_until_home) const
|
||||
void CommandSetGl846::move_back_home(Genesys_Device* dev, bool wait_until_home) const
|
||||
{
|
||||
scanner_slow_back_home(*dev, wait_until_home);
|
||||
}
|
||||
|
||||
void CommandSetGl846::slow_back_home_ta(Genesys_Device& dev) const
|
||||
{
|
||||
(void) dev;
|
||||
throw SaneException("not implemented");
|
||||
scanner_move_back_home(*dev, wait_until_home);
|
||||
}
|
||||
|
||||
// Automatically set top-left edge of the scan area by scanning a 200x200 pixels area at 600 dpi
|
||||
|
@ -1107,7 +1101,8 @@ void CommandSetGl846::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
* resolution. So leave a remainder for it so scan makes the final
|
||||
* move tuning */
|
||||
if (dev->settings.get_channels() * dev->settings.yres >= 600 && move > 700) {
|
||||
scanner_move(*dev, static_cast<unsigned>(move - 500), Direction::FORWARD);
|
||||
scanner_move(*dev, dev->model->default_method, static_cast<unsigned>(move - 500),
|
||||
Direction::FORWARD);
|
||||
move=500;
|
||||
}
|
||||
|
||||
|
@ -1241,7 +1236,8 @@ SensorExposure CommandSetGl846::led_calibration(Genesys_Device* dev, const Genes
|
|||
move = static_cast<float>((move * (dev->motor.base_ydpi / 4)) / MM_PER_INCH);
|
||||
if(move>20)
|
||||
{
|
||||
scanner_move(*dev, static_cast<unsigned>(move), Direction::FORWARD);
|
||||
scanner_move(*dev, dev->model->default_method, static_cast<unsigned>(move),
|
||||
Direction::FORWARD);
|
||||
}
|
||||
DBG(DBG_io, "%s: move=%f steps\n", __func__, move);
|
||||
|
||||
|
@ -1311,7 +1307,7 @@ SensorExposure CommandSetGl846::led_calibration(Genesys_Device* dev, const Genes
|
|||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("led_calibration");
|
||||
scanner_stop_action(*dev);
|
||||
slow_back_home(dev, true);
|
||||
move_back_home(dev, true);
|
||||
return { 0, 0, 0 };
|
||||
}
|
||||
|
||||
|
@ -1380,7 +1376,7 @@ SensorExposure CommandSetGl846::led_calibration(Genesys_Device* dev, const Genes
|
|||
/* go back home */
|
||||
if(move>20)
|
||||
{
|
||||
slow_back_home(dev, true);
|
||||
move_back_home(dev, true);
|
||||
}
|
||||
|
||||
return { exp[0], exp[1], exp[2] };
|
||||
|
@ -2011,7 +2007,7 @@ void CommandSetGl846::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("coarse_gain_calibration");
|
||||
scanner_stop_action(*dev);
|
||||
slow_back_home(dev, true);
|
||||
move_back_home(dev, true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2066,7 +2062,7 @@ void CommandSetGl846::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
|
||||
scanner_stop_action(*dev);
|
||||
|
||||
slow_back_home(dev, true);
|
||||
move_back_home(dev, true);
|
||||
}
|
||||
|
||||
bool CommandSetGl846::needs_home_before_init_regs_for_scan(Genesys_Device* dev) const
|
||||
|
|
|
@ -173,8 +173,7 @@ public:
|
|||
Genesys_Register_Set& regs) const override;
|
||||
|
||||
void wait_for_motor_stop(Genesys_Device* dev) const override;
|
||||
void slow_back_home(Genesys_Device* dev, bool wait_until_home) const override;
|
||||
void slow_back_home_ta(Genesys_Device& dev) const override;
|
||||
void move_back_home(Genesys_Device* dev, bool wait_until_home) const override;
|
||||
void rewind(Genesys_Device* dev) const override;
|
||||
|
||||
bool has_rewind() const override { return false; }
|
||||
|
|
|
@ -926,15 +926,9 @@ static void gl847_rewind(Genesys_Device* dev)
|
|||
* @param wait_until_home true to make the function waiting for head
|
||||
* to be home before returning, if fals returne immediately
|
||||
*/
|
||||
void CommandSetGl847::slow_back_home(Genesys_Device* dev, bool wait_until_home) const
|
||||
void CommandSetGl847::move_back_home(Genesys_Device* dev, bool wait_until_home) const
|
||||
{
|
||||
scanner_slow_back_home(*dev, wait_until_home);
|
||||
}
|
||||
|
||||
void CommandSetGl847::slow_back_home_ta(Genesys_Device& dev) const
|
||||
{
|
||||
(void) dev;
|
||||
throw SaneException("not implemented");
|
||||
scanner_move_back_home(*dev, wait_until_home);
|
||||
}
|
||||
|
||||
// Automatically set top-left edge of the scan area by scanning a 200x200 pixels area at 600 dpi
|
||||
|
@ -1141,7 +1135,8 @@ void CommandSetGl847::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
* resolution. So leave a remainder for it so scan makes the final
|
||||
* move tuning */
|
||||
if (dev->settings.get_channels() * dev->settings.yres >= 600 && move > 700) {
|
||||
scanner_move(*dev, static_cast<unsigned>(move - 500), Direction::FORWARD);
|
||||
scanner_move(*dev, dev->model->default_method, static_cast<unsigned>(move - 500),
|
||||
Direction::FORWARD);
|
||||
move=500;
|
||||
}
|
||||
|
||||
|
@ -1275,7 +1270,8 @@ SensorExposure CommandSetGl847::led_calibration(Genesys_Device* dev, const Genes
|
|||
move = static_cast<float>(dev->model->y_offset_calib_white);
|
||||
move = static_cast<float>((move * (dev->motor.base_ydpi / 4)) / MM_PER_INCH);
|
||||
if (move > 20) {
|
||||
scanner_move(*dev, static_cast<unsigned>(move), Direction::FORWARD);
|
||||
scanner_move(*dev, dev->model->default_method, static_cast<unsigned>(move),
|
||||
Direction::FORWARD);
|
||||
}
|
||||
DBG(DBG_io, "%s: move=%f steps\n", __func__, move);
|
||||
|
||||
|
@ -1345,7 +1341,7 @@ SensorExposure CommandSetGl847::led_calibration(Genesys_Device* dev, const Genes
|
|||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("led_calibration");
|
||||
scanner_stop_action(*dev);
|
||||
slow_back_home(dev, true);
|
||||
move_back_home(dev, true);
|
||||
return { 0, 0, 0 };
|
||||
}
|
||||
|
||||
|
@ -1408,7 +1404,7 @@ SensorExposure CommandSetGl847::led_calibration(Genesys_Device* dev, const Genes
|
|||
|
||||
// go back home
|
||||
if (move>20) {
|
||||
slow_back_home(dev, true);
|
||||
move_back_home(dev, true);
|
||||
}
|
||||
|
||||
return { exp[0], exp[1], exp[2] };
|
||||
|
@ -2081,7 +2077,7 @@ void CommandSetGl847::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("coarse_gain_calibration");
|
||||
scanner_stop_action(*dev);
|
||||
slow_back_home(dev, true);
|
||||
move_back_home(dev, true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2142,7 +2138,7 @@ void CommandSetGl847::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
|
||||
scanner_stop_action(*dev);
|
||||
|
||||
slow_back_home(dev, true);
|
||||
move_back_home(dev, true);
|
||||
}
|
||||
|
||||
bool CommandSetGl847::needs_home_before_init_regs_for_scan(Genesys_Device* dev) const
|
||||
|
|
|
@ -161,8 +161,7 @@ public:
|
|||
Genesys_Register_Set& regs) const override;
|
||||
|
||||
void wait_for_motor_stop(Genesys_Device* dev) const override;
|
||||
void slow_back_home(Genesys_Device* dev, bool wait_until_home) const override;
|
||||
void slow_back_home_ta(Genesys_Device& dev) const override;
|
||||
void move_back_home(Genesys_Device* dev, bool wait_until_home) const override;
|
||||
void rewind(Genesys_Device* dev) const override;
|
||||
|
||||
bool has_rewind() const override { return false; }
|
||||
|
|
|
@ -1582,7 +1582,7 @@ void sanei_genesys_asic_init(Genesys_Device* dev, bool /*max_regs*/)
|
|||
dev->already_initialized = true;
|
||||
|
||||
// Move to home if needed
|
||||
dev->cmd_set->slow_back_home(dev, true);
|
||||
dev->cmd_set->move_back_home(dev, true);
|
||||
dev->scanhead_position_in_steps = 0;
|
||||
|
||||
// Set powersaving (default = 15 minutes)
|
||||
|
|
|
@ -353,9 +353,11 @@ extern void sanei_genesys_search_reference_point(Genesys_Device* dev, Genesys_Se
|
|||
int width, int height);
|
||||
|
||||
// moves the scan head by the specified steps at the motor base dpi
|
||||
void scanner_move(Genesys_Device& dev, unsigned steps, Direction direction);
|
||||
void scanner_move(Genesys_Device& dev, ScanMethod scan_method, unsigned steps, Direction direction);
|
||||
|
||||
void scanner_move_back_home(Genesys_Device& dev, bool wait_until_home);
|
||||
void scanner_move_back_home_ta(Genesys_Device& dev);
|
||||
|
||||
void scanner_slow_back_home(Genesys_Device& dev, bool wait_until_home);
|
||||
void scanner_clear_scan_and_feed_counts(Genesys_Device& dev);
|
||||
|
||||
extern void sanei_genesys_write_file(const char* filename, const std::uint8_t* data,
|
||||
|
|
Ładowanie…
Reference in New Issue