kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Reduce duplication of *_stop_action() across the ASICs
rodzic
9e092f9d67
commit
5b7c19a7d5
|
@ -874,20 +874,10 @@ void sanei_genesys_search_reference_point(Genesys_Device* dev, Genesys_Sensor& s
|
|||
|
||||
namespace gl843 {
|
||||
void gl843_park_xpa_lamp(Genesys_Device* dev);
|
||||
void gl843_stop_action(Genesys_Device* dev);
|
||||
} // namespace gl843
|
||||
|
||||
namespace gl846 {
|
||||
void gl846_stop_action(Genesys_Device* dev);
|
||||
} // namespace gl846
|
||||
|
||||
namespace gl847 {
|
||||
void gl847_stop_action(Genesys_Device* dev);
|
||||
} // namespace gl847
|
||||
|
||||
namespace gl124 {
|
||||
void gl124_setup_scan_gpio(Genesys_Device* dev, int resolution);
|
||||
void gl124_stop_action(Genesys_Device* dev);
|
||||
} // namespace gl124
|
||||
|
||||
void scanner_clear_scan_and_feed_counts(Genesys_Device& dev)
|
||||
|
@ -993,27 +983,43 @@ bool scanner_is_motor_stopped(Genesys_Device& dev)
|
|||
|
||||
void scanner_stop_action(Genesys_Device& dev)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
|
||||
switch (dev.model->asic_type) {
|
||||
case AsicType::GL843: {
|
||||
gl843::gl843_stop_action(&dev);
|
||||
break;
|
||||
}
|
||||
case AsicType::GL843:
|
||||
case AsicType::GL845:
|
||||
case AsicType::GL846: {
|
||||
gl846::gl846_stop_action(&dev);
|
||||
case AsicType::GL846:
|
||||
case AsicType::GL847:
|
||||
case AsicType::GL124:
|
||||
break;
|
||||
}
|
||||
case AsicType::GL847:{
|
||||
gl847::gl847_stop_action(&dev);
|
||||
break;
|
||||
}
|
||||
case AsicType::GL124:{
|
||||
gl124::gl124_stop_action(&dev);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw SaneException("Unsupported asic type");
|
||||
}
|
||||
|
||||
if (dev.cmd_set->needs_update_home_sensor_gpio()) {
|
||||
dev.cmd_set->update_home_sensor_gpio(dev);
|
||||
}
|
||||
|
||||
if (scanner_is_motor_stopped(dev)) {
|
||||
DBG(DBG_info, "%s: already stopped\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
scanner_stop_action_no_move(dev, dev.reg);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < 10; ++i) {
|
||||
if (scanner_is_motor_stopped(dev)) {
|
||||
return;
|
||||
}
|
||||
|
||||
dev.interface->sleep_ms(100);
|
||||
}
|
||||
|
||||
throw SaneException(SANE_STATUS_IO_ERROR, "could not stop motor");
|
||||
}
|
||||
|
||||
void scanner_stop_action_no_move(Genesys_Device& dev, genesys::Genesys_Register_Set& regs)
|
||||
|
|
|
@ -999,38 +999,6 @@ void CommandSetGl124::set_powersaving(Genesys_Device* dev, int delay /* in minut
|
|||
}
|
||||
}
|
||||
|
||||
void gl124_stop_action(Genesys_Device* dev)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
unsigned int loop;
|
||||
|
||||
dev->cmd_set->update_home_sensor_gpio(*dev);
|
||||
if (scanner_is_motor_stopped(*dev)) {
|
||||
DBG(DBG_info, "%s: already stopped\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
scanner_stop_action_no_move(*dev, dev->reg);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
/** @brief setup GPIOs for scan
|
||||
* Setup GPIO values to drive motor (or light) needed for the
|
||||
* target resolution
|
||||
|
@ -1115,7 +1083,7 @@ void CommandSetGl124::end_scan(Genesys_Device* dev, Genesys_Register_Set* reg,
|
|||
DBG_HELPER_ARGS(dbg, "check_stop = %d", check_stop);
|
||||
|
||||
if (!dev->model->is_sheetfed) {
|
||||
gl124_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1573,14 +1541,14 @@ static void move_to_calibration_area(Genesys_Device* dev, const Genesys_Sensor&
|
|||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("move_to_calibration_area");
|
||||
gl124_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
return;
|
||||
}
|
||||
|
||||
sanei_genesys_read_data_from_scanner(dev, line.data(), size);
|
||||
|
||||
// stop scanning
|
||||
gl124_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
|
@ -1674,14 +1642,14 @@ SensorExposure CommandSetGl124::led_calibration(Genesys_Device* dev, const Genes
|
|||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("led_calibration");
|
||||
gl124_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
return { 0, 0, 0 };
|
||||
}
|
||||
|
||||
sanei_genesys_read_data_from_scanner(dev, line.data(), total_size);
|
||||
|
||||
// stop scanning
|
||||
gl124_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
|
@ -1998,7 +1966,7 @@ void CommandSetGl124::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("coarse_gain_calibration");
|
||||
gl124_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
slow_back_home(dev, true);
|
||||
return;
|
||||
}
|
||||
|
@ -2058,7 +2026,7 @@ void CommandSetGl124::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
dev->frontend.set_gain(2, dev->frontend.get_gain(1));
|
||||
}
|
||||
|
||||
gl124_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
|
||||
slow_back_home(dev, true);
|
||||
}
|
||||
|
|
|
@ -109,8 +109,6 @@ static Memory_layout layouts[]={
|
|||
}
|
||||
};
|
||||
|
||||
void gl124_stop_action(Genesys_Device* dev);
|
||||
|
||||
static void gl124_send_slope_table(Genesys_Device* dev, int table_nr,
|
||||
const std::vector<uint16_t>& slope_table, int steps);
|
||||
|
||||
|
|
|
@ -1315,35 +1315,6 @@ void CommandSetGl843::set_powersaving(Genesys_Device* dev, int delay /* in minut
|
|||
DBG_HELPER_ARGS(dbg, "delay = %d", delay);
|
||||
}
|
||||
|
||||
void gl843_stop_action(Genesys_Device* dev)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
unsigned int loop;
|
||||
|
||||
if (scanner_is_motor_stopped(*dev)) {
|
||||
DBG(DBG_info, "%s: already stopped\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
scanner_stop_action_no_move(*dev, dev->reg);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
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 gl843_get_paper_sensor(Genesys_Device* dev)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
|
@ -1692,7 +1663,7 @@ void CommandSetGl843::end_scan(Genesys_Device* dev, Genesys_Register_Set* reg,
|
|||
}
|
||||
|
||||
if (!dev->model->is_sheetfed) {
|
||||
gl843_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2235,8 +2206,7 @@ SensorExposure CommandSetGl843::led_calibration(Genesys_Device* dev, const Genes
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
gl843_stop_action (dev);
|
||||
scanner_stop_action(*dev);
|
||||
|
||||
turn++;
|
||||
|
||||
|
@ -2596,7 +2566,7 @@ void CommandSetGl843::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("coarse_gain_calibration");
|
||||
gl843_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
slow_back_home(dev, true);
|
||||
return;
|
||||
}
|
||||
|
@ -2649,7 +2619,7 @@ void CommandSetGl843::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
dev->frontend.set_gain(2, dev->frontend.get_gain(1));
|
||||
}
|
||||
|
||||
gl843_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
|
||||
slow_back_home(dev, true);
|
||||
}
|
||||
|
@ -2907,7 +2877,7 @@ void CommandSetGl843::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
unsigned int pass, count, found, x, y;
|
||||
|
||||
dev->cmd_set->set_fe(dev, sensor, AFE_SET);
|
||||
gl843_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
|
||||
/* set up for a gray scan at lowest dpi */
|
||||
dpi = sanei_genesys_get_lowest_dpi(dev);
|
||||
|
@ -2952,7 +2922,7 @@ void CommandSetGl843::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("search_strip");
|
||||
gl843_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2962,7 +2932,7 @@ void CommandSetGl843::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
auto data = read_unshuffled_image_from_scanner(dev, session,
|
||||
session.output_total_bytes_raw);
|
||||
|
||||
gl843_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
|
||||
pass = 0;
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
|
@ -2987,7 +2957,7 @@ void CommandSetGl843::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
// now we're on target, we can read data
|
||||
data = read_unshuffled_image_from_scanner(dev, session, session.output_total_bytes_raw);
|
||||
|
||||
gl843_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
|
|
|
@ -840,35 +840,6 @@ void CommandSetGl846::set_powersaving(Genesys_Device* dev, int delay /* in minut
|
|||
DBG_HELPER_ARGS(dbg, "delay = %d", delay);
|
||||
}
|
||||
|
||||
void gl846_stop_action(Genesys_Device* dev)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
unsigned int loop;
|
||||
|
||||
dev->cmd_set->update_home_sensor_gpio(*dev);
|
||||
if (scanner_is_motor_stopped(*dev)) {
|
||||
DBG(DBG_info, "%s: already stopped\n", __func__);
|
||||
return;
|
||||
}
|
||||
scanner_stop_action_no_move(*dev, dev->reg);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
// Send the low-level scan command
|
||||
void CommandSetGl846::begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set* reg, bool start_motor) const
|
||||
|
@ -907,7 +878,7 @@ void CommandSetGl846::end_scan(Genesys_Device* dev, Genesys_Register_Set* reg,
|
|||
DBG_HELPER_ARGS(dbg, "check_stop = %d", check_stop);
|
||||
|
||||
if (!dev->model->is_sheetfed) {
|
||||
gl846_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1339,7 +1310,7 @@ SensorExposure CommandSetGl846::led_calibration(Genesys_Device* dev, const Genes
|
|||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("led_calibration");
|
||||
gl846_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
slow_back_home(dev, true);
|
||||
return { 0, 0, 0 };
|
||||
}
|
||||
|
@ -1347,7 +1318,7 @@ SensorExposure CommandSetGl846::led_calibration(Genesys_Device* dev, const Genes
|
|||
sanei_genesys_read_data_from_scanner(dev, line.data(), total_size);
|
||||
|
||||
// stop scanning
|
||||
gl846_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
|
@ -1610,7 +1581,7 @@ void CommandSetGl846::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
|
||||
set_fe(dev, sensor, AFE_SET);
|
||||
|
||||
gl846_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
|
||||
// set up for a gray scan at lowest dpi
|
||||
const auto& resolution_settings = dev->model->get_resolution_settings(dev->settings.scan_method);
|
||||
|
@ -1655,7 +1626,7 @@ void CommandSetGl846::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("search_strip");
|
||||
gl846_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1664,7 +1635,7 @@ void CommandSetGl846::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
// now we're on target, we can read data
|
||||
sanei_genesys_read_data_from_scanner(dev, data.data(), size);
|
||||
|
||||
gl846_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
|
||||
pass = 0;
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
|
@ -1689,7 +1660,7 @@ void CommandSetGl846::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
// now we're on target, we can read data
|
||||
sanei_genesys_read_data_from_scanner(dev, data.data(), size);
|
||||
|
||||
gl846_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
|
@ -2039,7 +2010,7 @@ void CommandSetGl846::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("coarse_gain_calibration");
|
||||
gl846_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
slow_back_home(dev, true);
|
||||
return;
|
||||
}
|
||||
|
@ -2093,7 +2064,7 @@ void CommandSetGl846::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
dev->frontend.set_gain(2, gain0);
|
||||
}
|
||||
|
||||
gl846_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
|
||||
slow_back_home(dev, true);
|
||||
}
|
||||
|
|
|
@ -50,10 +50,6 @@
|
|||
namespace genesys {
|
||||
namespace gl846 {
|
||||
|
||||
void gl846_stop_action(Genesys_Device* dev);
|
||||
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GpioId gpio_id;
|
||||
|
|
|
@ -844,37 +844,6 @@ void CommandSetGl847::set_powersaving(Genesys_Device* dev, int delay /* in minut
|
|||
DBG_HELPER_ARGS(dbg, "delay = %d", delay);
|
||||
}
|
||||
|
||||
void gl847_stop_action(Genesys_Device* dev)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
unsigned int loop;
|
||||
|
||||
dev->cmd_set->update_home_sensor_gpio(*dev);
|
||||
if (scanner_is_motor_stopped(*dev)) {
|
||||
DBG(DBG_info, "%s: already stopped\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
scanner_stop_action_no_move(*dev, dev->reg);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
// Send the low-level scan command
|
||||
void CommandSetGl847::begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set* reg, bool start_motor) const
|
||||
|
@ -914,7 +883,7 @@ void CommandSetGl847::end_scan(Genesys_Device* dev, Genesys_Register_Set* reg,
|
|||
DBG_HELPER_ARGS(dbg, "check_stop = %d", check_stop);
|
||||
|
||||
if (!dev->model->is_sheetfed) {
|
||||
gl847_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1375,7 +1344,7 @@ SensorExposure CommandSetGl847::led_calibration(Genesys_Device* dev, const Genes
|
|||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("led_calibration");
|
||||
gl847_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
slow_back_home(dev, true);
|
||||
return { 0, 0, 0 };
|
||||
}
|
||||
|
@ -1383,7 +1352,7 @@ SensorExposure CommandSetGl847::led_calibration(Genesys_Device* dev, const Genes
|
|||
sanei_genesys_read_data_from_scanner(dev, line.data(), total_size);
|
||||
|
||||
// stop scanning
|
||||
gl847_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
|
@ -1682,7 +1651,7 @@ void CommandSetGl847::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
char title[80];
|
||||
|
||||
set_fe(dev, sensor, AFE_SET);
|
||||
gl847_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
|
||||
// set up for a gray scan at lowest dpi
|
||||
const auto& resolution_settings = dev->model->get_resolution_settings(dev->settings.scan_method);
|
||||
|
@ -1727,7 +1696,7 @@ void CommandSetGl847::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("search_strip");
|
||||
gl847_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1736,7 +1705,7 @@ void CommandSetGl847::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
// now we're on target, we can read data
|
||||
sanei_genesys_read_data_from_scanner(dev, data.data(), size);
|
||||
|
||||
gl847_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
|
||||
pass = 0;
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
|
@ -1761,7 +1730,7 @@ void CommandSetGl847::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
// now we're on target, we can read data
|
||||
sanei_genesys_read_data_from_scanner(dev, data.data(), size);
|
||||
|
||||
gl847_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
|
@ -2111,7 +2080,7 @@ void CommandSetGl847::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("coarse_gain_calibration");
|
||||
gl847_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
slow_back_home(dev, true);
|
||||
return;
|
||||
}
|
||||
|
@ -2171,7 +2140,7 @@ void CommandSetGl847::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
dev->frontend.set_gain(2, dev->frontend.get_gain(1));
|
||||
}
|
||||
|
||||
gl847_stop_action(dev);
|
||||
scanner_stop_action(*dev);
|
||||
|
||||
slow_back_home(dev, true);
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue