genesys: Simplify creation of command set

merge-requests/412/head
Povilas Kanapickas 2020-04-17 05:38:43 +03:00
rodzic c0deb9b2c4
commit edda9bff25
9 zmienionych plików z 20 dodań i 53 usunięć

Wyświetl plik

@ -5619,7 +5619,9 @@ static void sane_open_impl(SANE_String_Const devicename, SANE_Handle * handle)
init_options(s);
sanei_genesys_init_cmd_set(s->dev);
DBG_INIT();
s->dev->cmd_set = create_cmd_set(s->dev->model->asic_type);
// FIXME: we create sensor tables for the sensor, this should happen when we know which sensor
// we will select

Wyświetl plik

@ -1511,10 +1511,5 @@ void CommandSetGl124::move_to_ta(Genesys_Device* dev) const
throw SaneException("not implemented");
}
std::unique_ptr<CommandSet> create_gl124_cmd_set()
{
return std::unique_ptr<CommandSet>(new CommandSetGl124{});
}
} // namespace gl124
} // namespace genesys

Wyświetl plik

@ -3137,10 +3137,5 @@ void CommandSetGl646::asic_boot(Genesys_Device *dev, bool cold) const
throw SaneException("not implemented");
}
std::unique_ptr<CommandSet> create_gl646_cmd_set()
{
return std::unique_ptr<CommandSet>(new CommandSetGl646{});
}
} // namespace gl646
} // namespace genesys

Wyświetl plik

@ -2652,10 +2652,5 @@ void CommandSetGl841::asic_boot(Genesys_Device *dev, bool cold) const
dev->cmd_set->set_fe(dev, sensor, AFE_INIT);
}
std::unique_ptr<CommandSet> create_gl841_cmd_set()
{
return std::unique_ptr<CommandSet>(new CommandSetGl841{});
}
} // namespace gl841
} // namespace genesys

Wyświetl plik

@ -1890,10 +1890,5 @@ void CommandSetGl843::wait_for_motor_stop(Genesys_Device* dev) const
(void) dev;
}
std::unique_ptr<CommandSet> create_gl843_cmd_set()
{
return std::unique_ptr<CommandSet>(new CommandSetGl843{});
}
} // namespace gl843
} // namespace genesys

Wyświetl plik

@ -1275,10 +1275,5 @@ void CommandSetGl846::move_to_ta(Genesys_Device* dev) const
scanner_move(*dev, dev->model->default_method, feed, Direction::FORWARD);
}
std::unique_ptr<CommandSet> create_gl846_cmd_set()
{
return std::unique_ptr<CommandSet>(new CommandSetGl846{});
}
} // namespace gl846
} // namespace genesys

Wyświetl plik

@ -1172,10 +1172,5 @@ void CommandSetGl847::move_to_ta(Genesys_Device* dev) const
throw SaneException("not implemented");
}
std::unique_ptr<CommandSet> create_gl847_cmd_set()
{
return std::unique_ptr<CommandSet>(new CommandSetGl847{});
}
} // namespace gl847
} // namespace genesys

Wyświetl plik

@ -56,6 +56,14 @@
#include "gl847_registers.h"
#include "gl646_registers.h"
#include "gl124.h"
#include "gl646.h"
#include "gl841.h"
#include "gl843.h"
#include "gl846.h"
#include "gl847.h"
#include "gl646.h"
#include <cstdio>
#include <cmath>
#include <vector>
@ -66,29 +74,16 @@
namespace genesys {
/**
* setup the hardware dependent functions
*/
namespace gl124 { std::unique_ptr<CommandSet> create_gl124_cmd_set(); }
namespace gl646 { std::unique_ptr<CommandSet> create_gl646_cmd_set(); }
namespace gl841 { std::unique_ptr<CommandSet> create_gl841_cmd_set(); }
namespace gl843 { std::unique_ptr<CommandSet> create_gl843_cmd_set(); }
namespace gl846 { std::unique_ptr<CommandSet> create_gl846_cmd_set(); }
namespace gl847 { std::unique_ptr<CommandSet> create_gl847_cmd_set(); }
void sanei_genesys_init_cmd_set(Genesys_Device* dev)
std::unique_ptr<CommandSet> create_cmd_set(AsicType asic_type)
{
DBG_INIT ();
DBG_HELPER(dbg);
switch (dev->model->asic_type) {
case AsicType::GL646: dev->cmd_set = gl646::create_gl646_cmd_set(); break;
case AsicType::GL841: dev->cmd_set = gl841::create_gl841_cmd_set(); break;
case AsicType::GL843: dev->cmd_set = gl843::create_gl843_cmd_set(); break;
switch (asic_type) {
case AsicType::GL646: return std::unique_ptr<CommandSet>(new gl646::CommandSetGl646{});
case AsicType::GL841: return std::unique_ptr<CommandSet>(new gl841::CommandSetGl841{});
case AsicType::GL843: return std::unique_ptr<CommandSet>(new gl843::CommandSetGl843{});
case AsicType::GL845: // since only a few reg bits differs we handle both together
case AsicType::GL846: dev->cmd_set = gl846::create_gl846_cmd_set(); break;
case AsicType::GL847: dev->cmd_set = gl847::create_gl847_cmd_set(); break;
case AsicType::GL124: dev->cmd_set = gl124::create_gl124_cmd_set(); break;
case AsicType::GL846: return std::unique_ptr<CommandSet>(new gl846::CommandSetGl846{});
case AsicType::GL847: return std::unique_ptr<CommandSet>(new gl847::CommandSetGl847{});
case AsicType::GL124: return std::unique_ptr<CommandSet>(new gl124::CommandSetGl124{});
default: throw SaneException(SANE_STATUS_INVAL, "unknown ASIC type");
}
}

Wyświetl plik

@ -219,7 +219,7 @@ private:
/* common functions needed by low level specific functions */
/*--------------------------------------------------------------------------*/
extern void sanei_genesys_init_cmd_set(Genesys_Device* dev);
std::unique_ptr<CommandSet> create_cmd_set(AsicType asic_type);
// reads the status of the scanner
Status scanner_read_status(Genesys_Device& dev);