genesys: Extract scanner_stop_action_no_move() to use across the asics

merge-requests/213/head
Povilas Kanapickas 2019-12-01 10:08:56 +02:00
rodzic 6913513dc2
commit a90ab552a9
7 zmienionych plików z 37 dodań i 37 usunięć

Wyświetl plik

@ -973,6 +973,30 @@ void scanner_stop_action(Genesys_Device& dev)
}
}
void scanner_stop_action_no_move(Genesys_Device& dev, genesys::Genesys_Register_Set& regs)
{
switch (dev.model->asic_type) {
case AsicType::GL646:
case AsicType::GL841:
case AsicType::GL843:
case AsicType::GL845:
case AsicType::GL846:
case AsicType::GL847:
case AsicType::GL124:
break;
default:
throw SaneException("Unsupported asic type");
}
regs_set_optical_off(dev.model->asic_type, regs);
// same across all supported ASICs
dev.interface->write_register(0x01, regs.get8(0x01));
// looks like certain scanners lock up if we try to scan immediately after stopping previous
// action.
dev.interface->sleep_ms(100);
}
void scanner_move(Genesys_Device& dev, unsigned steps, Direction direction)
{
DBG_HELPER_ARGS(dbg, "steps=%d direction=%d", steps, static_cast<unsigned>(direction));

Wyświetl plik

@ -1016,11 +1016,7 @@ void gl124_stop_action(Genesys_Device* dev)
return;
}
/* ends scan */
regs_set_optical_off(dev->model->asic_type, dev->reg);
dev->interface->write_register(REG_0x01, dev->reg.get8(REG_0x01));
dev->interface->sleep_ms(100);
scanner_stop_action_no_move(*dev, dev->reg);
if (is_testing_mode()) {
return;

Wyświetl plik

@ -2253,9 +2253,7 @@ void CommandSetGl841::slow_back_home(Genesys_Device* dev, bool wait_until_home)
return;
}
/* end previous scan if any */
regs_set_optical_off(dev->model->asic_type, dev->reg);
dev->interface->write_register(REG_0x01, dev->reg.get8(REG_0x01));
scanner_stop_action_no_move(*dev, dev->reg);
/* if motor is on, stop current action */
if (status.is_motor_enabled) {

Wyświetl plik

@ -1315,14 +1315,6 @@ void CommandSetGl843::set_powersaving(Genesys_Device* dev, int delay /* in minut
DBG_HELPER_ARGS(dbg, "delay = %d", delay);
}
static void gl843_stop_action_no_move(Genesys_Device* dev, Genesys_Register_Set* reg)
{
DBG_HELPER(dbg);
regs_set_optical_off(dev->model->asic_type, *reg);
dev->interface->write_register(REG_0x01, reg->get8(REG_0x01));
dev->interface->sleep_ms(100);
}
void gl843_stop_action(Genesys_Device* dev)
{
DBG_HELPER(dbg);
@ -1339,11 +1331,7 @@ void gl843_stop_action(Genesys_Device* dev)
return;
}
// ends scan
regs_set_optical_off(dev->model->asic_type, dev->reg);
dev->interface->write_register(REG_0x01, dev->reg.get8(REG_0x01));
dev->interface->sleep_ms(100);
scanner_stop_action_no_move(*dev, dev->reg);
if (is_testing_mode()) {
return;
@ -1849,7 +1837,7 @@ void CommandSetGl843::search_start_position(Genesys_Device* dev) const
// now we're on target, we can read data
Image image = read_unshuffled_image_from_scanner(dev, session, session.output_total_bytes_raw);
gl843_stop_action_no_move(dev, &local_reg);
scanner_stop_action_no_move(*dev, local_reg);
if (DBG_LEVEL >= DBG_data) {
sanei_genesys_write_pnm_file("gl843_search_position.pnm", image);
@ -2201,7 +2189,7 @@ SensorExposure CommandSetGl843::led_calibration(Genesys_Device* dev, const Genes
auto image = read_unshuffled_image_from_scanner(dev, session,
session.output_total_bytes_raw);
gl843_stop_action_no_move(dev, &regs);
scanner_stop_action_no_move(*dev, regs);
if (DBG_LEVEL >= DBG_data)
{
@ -2407,13 +2395,13 @@ void CommandSetGl843::offset_calibration(Genesys_Device* dev, const Genesys_Sens
if (is_testing_mode()) {
dev->interface->test_checkpoint("offset_calibration");
gl843_stop_action_no_move(dev, &regs);
scanner_stop_action_no_move(*dev, regs);
return;
}
auto first_line = read_unshuffled_image_from_scanner(dev, session,
session.output_total_bytes_raw);
gl843_stop_action_no_move(dev, &regs);
scanner_stop_action_no_move(*dev, regs);
if (DBG_LEVEL >= DBG_data)
{
@ -2442,7 +2430,7 @@ void CommandSetGl843::offset_calibration(Genesys_Device* dev, const Genesys_Sens
dev->cmd_set->begin_scan(dev, calib_sensor, &regs, true);
auto second_line = read_unshuffled_image_from_scanner(dev, session,
session.output_total_bytes_raw);
gl843_stop_action_no_move(dev, &regs);
scanner_stop_action_no_move(*dev, regs);
for (unsigned ch = 0; ch < 3; ch++){
topavg[ch] = dark_average_channel(second_line, black_pixels, ch);
@ -2476,7 +2464,7 @@ void CommandSetGl843::offset_calibration(Genesys_Device* dev, const Genesys_Sens
dev->cmd_set->begin_scan(dev, calib_sensor, &regs, true);
second_line = read_unshuffled_image_from_scanner(dev, session,
session.output_total_bytes_raw);
gl843_stop_action_no_move(dev, &regs);
scanner_stop_action_no_move(*dev, regs);
if (DBG_LEVEL >= DBG_data)
{
@ -2626,7 +2614,7 @@ void CommandSetGl843::coarse_gain_calibration(Genesys_Device* dev, const Genesys
}
auto line = read_unshuffled_image_from_scanner(dev, session, session.output_total_bytes_raw);
gl843_stop_action_no_move(dev, &regs);
scanner_stop_action_no_move(*dev, regs);
if (DBG_LEVEL >= DBG_data) {
sanei_genesys_write_pnm_file("gl843_gain.pnm", line);

Wyświetl plik

@ -856,10 +856,7 @@ void gl846_stop_action(Genesys_Device* dev)
return;
}
/* ends scan */
regs_set_optical_off(dev->model->asic_type, dev->reg);
dev->interface->write_register(REG_0x01, dev->reg.get8(REG_0x01));
dev->interface->sleep_ms(100);
scanner_stop_action_no_move(*dev, dev->reg);
if (is_testing_mode()) {
return;

Wyświetl plik

@ -860,11 +860,7 @@ void gl847_stop_action(Genesys_Device* dev)
return;
}
/* ends scan */
regs_set_optical_off(dev->model->asic_type, dev->reg);
dev->interface->write_register(REG_0x01, dev->reg.get8(REG_0x01));
dev->interface->sleep_ms(100);
scanner_stop_action_no_move(*dev, dev->reg);
if (is_testing_mode()) {
return;

Wyświetl plik

@ -411,6 +411,7 @@ extern void sanei_genesys_asic_init(Genesys_Device* dev, bool cold);
void scanner_start_action(Genesys_Device& dev, bool start_motor);
void scanner_stop_action(Genesys_Device& dev);
void scanner_stop_action_no_move(Genesys_Device& dev, Genesys_Register_Set& regs);
const Motor_Profile& sanei_genesys_get_motor_profile(const std::vector<Motor_Profile>& motors,
MotorId motor_id, int exposure);