genesys: Reuse scanner_stop_action() on gl841

merge-requests/414/head
Povilas Kanapickas 2020-04-20 00:35:53 +03:00
rodzic 98ee100237
commit f965c2ef25
2 zmienionych plików z 19 dodań i 88 usunięć

Wyświetl plik

@ -1117,10 +1117,6 @@ void scanner_move_back_home_ta(Genesys_Device& dev)
throw SaneException("Timeout waiting for XPA lamp to park");
}
namespace gl841 {
void gl841_stop_action(Genesys_Device* dev);
} // namespace gl841
void scanner_search_strip(Genesys_Device& dev, bool forward, bool black)
{
DBG_HELPER_ARGS(dbg, "%s %s", black ? "black" : "white", forward ? "forward" : "reverse");
@ -1187,11 +1183,7 @@ void scanner_search_strip(Genesys_Device& dev, bool forward, bool black)
if (is_testing_mode()) {
dev.interface->test_checkpoint("search_strip");
if (dev.model->asic_type == AsicType::GL841) {
gl841::gl841_stop_action(&dev);
} else {
scanner_stop_action(dev);
}
scanner_stop_action(dev);
return;
}
@ -1200,11 +1192,7 @@ void scanner_search_strip(Genesys_Device& dev, bool forward, bool black)
// now we're on target, we can read data
auto image = read_unshuffled_image_from_scanner(&dev, session, session.output_total_bytes);
if (dev.model->asic_type == AsicType::GL841) {
gl841::gl841_stop_action(&dev);
} else {
scanner_stop_action(dev);
}
scanner_stop_action(dev);
unsigned pass = 0;
if (DBG_LEVEL >= DBG_data) {
@ -1770,11 +1758,7 @@ void scanner_coarse_gain_calibration(Genesys_Device& dev, const Genesys_Sensor&
if (is_testing_mode()) {
dev.interface->test_checkpoint("coarse_gain_calibration");
if (dev.model->asic_type == AsicType::GL841) {
gl841::gl841_stop_action(&dev);
} else {
scanner_stop_action(dev);
}
scanner_stop_action(dev);
dev.cmd_set->move_back_home(&dev, true);
return;
}
@ -1876,11 +1860,7 @@ void scanner_coarse_gain_calibration(Genesys_Device& dev, const Genesys_Sensor&
dev.frontend.get_gain(1),
dev.frontend.get_gain(2));
if (dev.model->asic_type == AsicType::GL841) {
gl841::gl841_stop_action(&dev);
} else {
scanner_stop_action(dev);
}
scanner_stop_action(dev);
dev.cmd_set->move_back_home(&dev, true);
}
@ -2032,9 +2012,8 @@ SensorExposure scanner_led_calibration(Genesys_Device& dev, const Genesys_Sensor
if (is_testing_mode()) {
dev.interface->test_checkpoint("led_calibration");
scanner_stop_action(dev);
if (dev.model->asic_type == AsicType::GL841) {
// FIXME: we should call gl841_stop_action() here
scanner_stop_action(dev);
dev.cmd_set->move_back_home(&dev, true);
return { exp[0], exp[1], exp[2] };
} else if (dev.model->asic_type == AsicType::GL124) {
@ -2049,11 +2028,7 @@ SensorExposure scanner_led_calibration(Genesys_Device& dev, const Genesys_Sensor
auto image = read_unshuffled_image_from_scanner(&dev, session, session.output_line_bytes);
if (dev.model->asic_type == AsicType::GL841) {
gl841::gl841_stop_action(&dev);
} else {
scanner_stop_action(dev);
}
scanner_stop_action(dev);
if (DBG_LEVEL >= DBG_data) {
char fn[30];

Wyświetl plik

@ -1466,49 +1466,6 @@ void CommandSetGl841::set_powersaving(Genesys_Device* dev, int delay /* in minut
dev->interface->write_registers(local_reg);
}
void gl841_stop_action(Genesys_Device* dev)
{
// FIXME: figure out a way to merge this to scanner_stop_action()
DBG_HELPER(dbg);
Genesys_Register_Set local_reg;
unsigned int loop;
scanner_read_print_status(*dev);
if (scanner_is_motor_stopped(*dev)) {
DBG(DBG_info, "%s: already stopped\n", __func__);
return;
}
local_reg = dev->reg;
regs_set_optical_off(dev->model->asic_type, local_reg);
gl841_init_motor_regs_off(&local_reg,0);
dev->interface->write_registers(local_reg);
if (is_testing_mode()) {
return;
}
/* looks like writing the right registers to zero is enough to get the chip
out of scan mode into command mode, actually triggering(writing to
register 0x0f) seems to be unnecessary */
loop = 10;
while (loop > 0) {
if (scanner_is_motor_stopped(*dev)) {
return;
}
dev->interface->sleep_ms(100);
loop--;
}
throw SaneException(SANE_STATUS_IO_ERROR, "could not stop motor");
}
static bool gl841_get_paper_sensor(Genesys_Device* dev)
{
DBG_HELPER(dbg);
@ -1537,8 +1494,7 @@ void CommandSetGl841::eject_document(Genesys_Device* dev) const
// FIXME: unused result
scanner_read_status(*dev);
gl841_stop_action(dev);
scanner_stop_action(*dev);
local_reg = dev->reg;
@ -1552,7 +1508,7 @@ void CommandSetGl841::eject_document(Genesys_Device* dev) const
try {
scanner_start_action(*dev, true);
} catch (...) {
catch_all_exceptions(__func__, [&]() { gl841_stop_action(dev); });
catch_all_exceptions(__func__, [&]() { scanner_stop_action(*dev); });
// restore original registers
catch_all_exceptions(__func__, [&]()
{
@ -1563,7 +1519,7 @@ void CommandSetGl841::eject_document(Genesys_Device* dev) const
if (is_testing_mode()) {
dev->interface->test_checkpoint("eject_document");
gl841_stop_action(dev);
scanner_stop_action(*dev);
return;
}
@ -1590,7 +1546,7 @@ void CommandSetGl841::eject_document(Genesys_Device* dev) const
{
// when we come here then the scanner needed too much time for this, so we better stop
// the motor
catch_all_exceptions(__func__, [&](){ gl841_stop_action(dev); });
catch_all_exceptions(__func__, [&](){ scanner_stop_action(*dev); });
throw SaneException(SANE_STATUS_IO_ERROR,
"timeout while waiting for scanhead to go home");
}
@ -1622,7 +1578,7 @@ void CommandSetGl841::eject_document(Genesys_Device* dev) const
++loop;
}
gl841_stop_action(dev);
scanner_stop_action(*dev);
dev->document = false;
}
@ -1764,7 +1720,7 @@ void CommandSetGl841::end_scan(Genesys_Device* dev, Genesys_Register_Set __sane_
DBG_HELPER_ARGS(dbg, "check_stop = %d", check_stop);
if (!dev->model->is_sheetfed) {
gl841_stop_action(dev);
scanner_stop_action(*dev);
}
}
@ -1809,7 +1765,7 @@ void CommandSetGl841::move_back_home(Genesys_Device* dev, bool wait_until_home)
/* if motor is on, stop current action */
if (status.is_motor_enabled) {
gl841_stop_action(dev);
scanner_stop_action(*dev);
}
local_reg = dev->reg;
@ -1826,7 +1782,7 @@ void CommandSetGl841::move_back_home(Genesys_Device* dev, bool wait_until_home)
try {
scanner_start_action(*dev, true);
} catch (...) {
catch_all_exceptions(__func__, [&]() { gl841_stop_action(dev); });
catch_all_exceptions(__func__, [&]() { scanner_stop_action(*dev); });
// restore original registers
catch_all_exceptions(__func__, [&]()
{
@ -1858,7 +1814,7 @@ void CommandSetGl841::move_back_home(Genesys_Device* dev, bool wait_until_home)
// when we come here then the scanner needed too much time for this, so we better stop
// the motor
catch_all_exceptions(__func__, [&](){ gl841_stop_action(dev); });
catch_all_exceptions(__func__, [&](){ scanner_stop_action(*dev); });
dev->set_head_pos_unknown(ScanHeadId::PRIMARY);
throw SaneException(SANE_STATUS_IO_ERROR, "timeout while waiting for scanhead to go home");
}
@ -2020,12 +1976,12 @@ static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
if (is_testing_mode()) {
dev->interface->test_checkpoint("ad_fe_offset_calibration");
gl841_stop_action(dev);
scanner_stop_action(*dev);
return;
}
sanei_genesys_read_data_from_scanner(dev, line.data(), total_size);
gl841_stop_action (dev);
scanner_stop_action(*dev);
if (DBG_LEVEL >= DBG_data) {
char fn[30];
std::snprintf(fn, 30, "gl841_offset_%02d.pnm", turn);
@ -2221,7 +2177,7 @@ void CommandSetGl841::offset_calibration(Genesys_Device* dev, const Genesys_Sens
offl[2] = offl[1] = offl[0];
}
gl841_stop_action(dev);
scanner_stop_action(*dev);
turn++;
} while (!acceptable && turn < 100);
@ -2311,7 +2267,7 @@ void CommandSetGl841::offset_calibration(Genesys_Device* dev, const Genesys_Sens
offl[2] = offl[1] = offl[0];
}
gl841_stop_action(dev);
scanner_stop_action(*dev);
turn++;