kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Extract scanner_stop_action_no_move() to use across the asics
rodzic
6913513dc2
commit
a90ab552a9
|
@ -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)
|
void scanner_move(Genesys_Device& dev, unsigned steps, Direction direction)
|
||||||
{
|
{
|
||||||
DBG_HELPER_ARGS(dbg, "steps=%d direction=%d", steps, static_cast<unsigned>(direction));
|
DBG_HELPER_ARGS(dbg, "steps=%d direction=%d", steps, static_cast<unsigned>(direction));
|
||||||
|
|
|
@ -1016,11 +1016,7 @@ void gl124_stop_action(Genesys_Device* dev)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ends scan */
|
scanner_stop_action_no_move(*dev, dev->reg);
|
||||||
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);
|
|
||||||
|
|
||||||
if (is_testing_mode()) {
|
if (is_testing_mode()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -2253,9 +2253,7 @@ void CommandSetGl841::slow_back_home(Genesys_Device* dev, bool wait_until_home)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* end previous scan if any */
|
scanner_stop_action_no_move(*dev, dev->reg);
|
||||||
regs_set_optical_off(dev->model->asic_type, dev->reg);
|
|
||||||
dev->interface->write_register(REG_0x01, dev->reg.get8(REG_0x01));
|
|
||||||
|
|
||||||
/* if motor is on, stop current action */
|
/* if motor is on, stop current action */
|
||||||
if (status.is_motor_enabled) {
|
if (status.is_motor_enabled) {
|
||||||
|
|
|
@ -1315,14 +1315,6 @@ void CommandSetGl843::set_powersaving(Genesys_Device* dev, int delay /* in minut
|
||||||
DBG_HELPER_ARGS(dbg, "delay = %d", delay);
|
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)
|
void gl843_stop_action(Genesys_Device* dev)
|
||||||
{
|
{
|
||||||
DBG_HELPER(dbg);
|
DBG_HELPER(dbg);
|
||||||
|
@ -1339,11 +1331,7 @@ void gl843_stop_action(Genesys_Device* dev)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ends scan
|
scanner_stop_action_no_move(*dev, dev->reg);
|
||||||
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);
|
|
||||||
|
|
||||||
if (is_testing_mode()) {
|
if (is_testing_mode()) {
|
||||||
return;
|
return;
|
||||||
|
@ -1849,7 +1837,7 @@ void CommandSetGl843::search_start_position(Genesys_Device* dev) const
|
||||||
// now we're on target, we can read data
|
// now we're on target, we can read data
|
||||||
Image image = read_unshuffled_image_from_scanner(dev, session, session.output_total_bytes_raw);
|
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) {
|
if (DBG_LEVEL >= DBG_data) {
|
||||||
sanei_genesys_write_pnm_file("gl843_search_position.pnm", image);
|
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,
|
auto image = read_unshuffled_image_from_scanner(dev, session,
|
||||||
session.output_total_bytes_raw);
|
session.output_total_bytes_raw);
|
||||||
gl843_stop_action_no_move(dev, ®s);
|
scanner_stop_action_no_move(*dev, regs);
|
||||||
|
|
||||||
if (DBG_LEVEL >= DBG_data)
|
if (DBG_LEVEL >= DBG_data)
|
||||||
{
|
{
|
||||||
|
@ -2407,13 +2395,13 @@ void CommandSetGl843::offset_calibration(Genesys_Device* dev, const Genesys_Sens
|
||||||
|
|
||||||
if (is_testing_mode()) {
|
if (is_testing_mode()) {
|
||||||
dev->interface->test_checkpoint("offset_calibration");
|
dev->interface->test_checkpoint("offset_calibration");
|
||||||
gl843_stop_action_no_move(dev, ®s);
|
scanner_stop_action_no_move(*dev, regs);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto first_line = read_unshuffled_image_from_scanner(dev, session,
|
auto first_line = read_unshuffled_image_from_scanner(dev, session,
|
||||||
session.output_total_bytes_raw);
|
session.output_total_bytes_raw);
|
||||||
gl843_stop_action_no_move(dev, ®s);
|
scanner_stop_action_no_move(*dev, regs);
|
||||||
|
|
||||||
if (DBG_LEVEL >= DBG_data)
|
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, ®s, true);
|
dev->cmd_set->begin_scan(dev, calib_sensor, ®s, true);
|
||||||
auto second_line = read_unshuffled_image_from_scanner(dev, session,
|
auto second_line = read_unshuffled_image_from_scanner(dev, session,
|
||||||
session.output_total_bytes_raw);
|
session.output_total_bytes_raw);
|
||||||
gl843_stop_action_no_move(dev, ®s);
|
scanner_stop_action_no_move(*dev, regs);
|
||||||
|
|
||||||
for (unsigned ch = 0; ch < 3; ch++){
|
for (unsigned ch = 0; ch < 3; ch++){
|
||||||
topavg[ch] = dark_average_channel(second_line, black_pixels, 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, ®s, true);
|
dev->cmd_set->begin_scan(dev, calib_sensor, ®s, true);
|
||||||
second_line = read_unshuffled_image_from_scanner(dev, session,
|
second_line = read_unshuffled_image_from_scanner(dev, session,
|
||||||
session.output_total_bytes_raw);
|
session.output_total_bytes_raw);
|
||||||
gl843_stop_action_no_move(dev, ®s);
|
scanner_stop_action_no_move(*dev, regs);
|
||||||
|
|
||||||
if (DBG_LEVEL >= DBG_data)
|
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);
|
auto line = read_unshuffled_image_from_scanner(dev, session, session.output_total_bytes_raw);
|
||||||
gl843_stop_action_no_move(dev, ®s);
|
scanner_stop_action_no_move(*dev, regs);
|
||||||
|
|
||||||
if (DBG_LEVEL >= DBG_data) {
|
if (DBG_LEVEL >= DBG_data) {
|
||||||
sanei_genesys_write_pnm_file("gl843_gain.pnm", line);
|
sanei_genesys_write_pnm_file("gl843_gain.pnm", line);
|
||||||
|
|
|
@ -856,10 +856,7 @@ void gl846_stop_action(Genesys_Device* dev)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ends scan */
|
scanner_stop_action_no_move(*dev, dev->reg);
|
||||||
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);
|
|
||||||
|
|
||||||
if (is_testing_mode()) {
|
if (is_testing_mode()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -860,11 +860,7 @@ void gl847_stop_action(Genesys_Device* dev)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ends scan */
|
scanner_stop_action_no_move(*dev, dev->reg);
|
||||||
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);
|
|
||||||
|
|
||||||
if (is_testing_mode()) {
|
if (is_testing_mode()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -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_start_action(Genesys_Device& dev, bool start_motor);
|
||||||
void scanner_stop_action(Genesys_Device& dev);
|
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,
|
const Motor_Profile& sanei_genesys_get_motor_profile(const std::vector<Motor_Profile>& motors,
|
||||||
MotorId motor_id, int exposure);
|
MotorId motor_id, int exposure);
|
||||||
|
|
Ładowanie…
Reference in New Issue