kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Add support for per-resolution or per-method motor profiles
rodzic
479718a6b5
commit
247a6b7882
|
@ -113,6 +113,7 @@ class ScannerInterfaceUsb;
|
|||
class TestScannerInterface;
|
||||
|
||||
// sensor.h
|
||||
class ScanMethodFilter;
|
||||
class ResolutionFilter;
|
||||
struct GenesysFrontendLayout;
|
||||
struct Genesys_Frontend;
|
||||
|
|
|
@ -856,7 +856,7 @@ void CommandSetGl124::init_regs_for_scan_session(Genesys_Device* dev, const Gene
|
|||
} else {
|
||||
exposure_time = sensor.exposure_lperiod;
|
||||
}
|
||||
const auto& motor_profile = get_motor_profile_by_exposure(dev->motor, exposure_time);
|
||||
const auto& motor_profile = get_motor_profile_by_exposure(dev->motor, exposure_time, session);
|
||||
|
||||
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
|
||||
DBG(DBG_info, "%s : scan_step_type=%d\n", __func__, static_cast<unsigned>(motor_profile.step_type));
|
||||
|
|
|
@ -1179,7 +1179,7 @@ void CommandSetGl843::init_regs_for_scan_session(Genesys_Device* dev, const Gene
|
|||
if (exposure < 0) {
|
||||
throw std::runtime_error("Exposure not defined in sensor definition");
|
||||
}
|
||||
const auto& motor_profile = get_motor_profile_by_exposure(dev->motor, exposure);
|
||||
const auto& motor_profile = get_motor_profile_by_exposure(dev->motor, exposure, session);
|
||||
|
||||
DBG(DBG_info, "%s : exposure=%d pixels\n", __func__, exposure);
|
||||
DBG(DBG_info, "%s : scan_step_type=%d\n", __func__,
|
||||
|
|
|
@ -705,7 +705,7 @@ void CommandSetGl846::init_regs_for_scan_session(Genesys_Device* dev, const Gene
|
|||
slope_dpi = slope_dpi * (1 + dummy);
|
||||
|
||||
exposure_time = sensor.exposure_lperiod;
|
||||
const auto& motor_profile = get_motor_profile_by_exposure(dev->motor, exposure_time);
|
||||
const auto& motor_profile = get_motor_profile_by_exposure(dev->motor, exposure_time, session);
|
||||
|
||||
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
|
||||
DBG(DBG_info, "%s : scan_step_type=%d\n", __func__,
|
||||
|
|
|
@ -712,7 +712,7 @@ void CommandSetGl847::init_regs_for_scan_session(Genesys_Device* dev, const Gene
|
|||
slope_dpi = slope_dpi * (1 + dummy);
|
||||
|
||||
exposure_time = sensor.exposure_lperiod;
|
||||
const auto& motor_profile = get_motor_profile_by_exposure(dev->motor, exposure_time);
|
||||
const auto& motor_profile = get_motor_profile_by_exposure(dev->motor, exposure_time, session);
|
||||
|
||||
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
|
||||
DBG(DBG_info, "%s : scan_step_type=%d\n", __func__,
|
||||
|
|
|
@ -1729,13 +1729,21 @@ void sanei_genesys_wait_for_home(Genesys_Device* dev)
|
|||
* @param exposure exposure time
|
||||
* @return a pointer to a MotorProfile struct
|
||||
*/
|
||||
const MotorProfile& get_motor_profile_by_exposure(const Genesys_Motor& motor, unsigned exposure)
|
||||
const MotorProfile& get_motor_profile_by_exposure(const Genesys_Motor& motor, unsigned exposure,
|
||||
const ScanSession& session)
|
||||
{
|
||||
int best_i = -1;
|
||||
|
||||
for (unsigned i = 0; i < motor.profiles.size(); ++i) {
|
||||
const auto& profile = motor.profiles[i];
|
||||
|
||||
if (!profile.resolutions.matches(session.params.yres)) {
|
||||
continue;
|
||||
}
|
||||
if (!profile.scan_methods.matches(session.params.scan_method)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (profile.max_exposure == exposure) {
|
||||
return profile;
|
||||
}
|
||||
|
|
|
@ -388,7 +388,8 @@ void scanner_stop_action_no_move(Genesys_Device& dev, Genesys_Register_Set& regs
|
|||
|
||||
bool scanner_is_motor_stopped(Genesys_Device& dev);
|
||||
|
||||
const MotorProfile& get_motor_profile_by_exposure(const Genesys_Motor& motor, unsigned exposure);
|
||||
const MotorProfile& get_motor_profile_by_exposure(const Genesys_Motor& motor, unsigned exposure,
|
||||
const ScanSession& session);
|
||||
|
||||
MotorSlopeTable sanei_genesys_slope_table(AsicType asic_type, int dpi, int exposure, int base_dpi,
|
||||
unsigned step_multiplier,
|
||||
|
|
|
@ -168,13 +168,11 @@ std::ostream& operator<<(std::ostream& out, const MotorProfile& profile)
|
|||
{
|
||||
out << "MotorProfile{\n"
|
||||
<< " max_exposure: " << profile.max_exposure << '\n'
|
||||
<< " step_type: " << profile.step_type << '\n';
|
||||
|
||||
if (profile.motor_vref != -1) {
|
||||
out << " motor_vref: " << profile.motor_vref << '\n';
|
||||
}
|
||||
|
||||
out << " slope: " << format_indent_braced_list(4, profile.slope) << '\n'
|
||||
<< " step_type: " << profile.step_type << '\n'
|
||||
<< " motor_vref: " << profile.motor_vref << '\n'
|
||||
<< " resolutions: " << format_indent_braced_list(4, profile.resolutions) << '\n'
|
||||
<< " scan_methods: " << format_indent_braced_list(4, profile.scan_methods) << '\n'
|
||||
<< " slope: " << format_indent_braced_list(4, profile.slope) << '\n'
|
||||
<< '}';
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include "enums.h"
|
||||
#include "sensor.h"
|
||||
|
||||
namespace genesys {
|
||||
|
||||
|
@ -148,6 +149,12 @@ struct MotorProfile
|
|||
MotorSlope slope;
|
||||
StepType step_type = StepType::FULL;
|
||||
int motor_vref = -1;
|
||||
|
||||
// the resolutions this profile is good for
|
||||
ResolutionFilter resolutions = ResolutionFilter::ANY;
|
||||
// the scan method this profile is good for. If the list is empty, good for any method.
|
||||
ScanMethodFilter scan_methods = ScanMethodFilter::ANY;
|
||||
|
||||
unsigned max_exposure = 0; // 0 - any exposure
|
||||
};
|
||||
|
||||
|
|
|
@ -122,6 +122,16 @@ std::ostream& operator<<(std::ostream& out, const ResolutionFilter& resolutions)
|
|||
return out;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const ScanMethodFilter& methods)
|
||||
{
|
||||
if (methods.matches_any()) {
|
||||
out << "ANY";
|
||||
return out;
|
||||
}
|
||||
out << format_vector_unsigned(4, methods.methods());
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const Genesys_Sensor& sensor)
|
||||
{
|
||||
out << "Genesys_Sensor{\n"
|
||||
|
|
|
@ -290,6 +290,46 @@ void serialize(Stream& str, ResolutionFilter& x)
|
|||
}
|
||||
|
||||
|
||||
class ScanMethodFilter
|
||||
{
|
||||
public:
|
||||
struct Any {};
|
||||
static constexpr Any ANY{};
|
||||
|
||||
ScanMethodFilter() : matches_any_{false} {}
|
||||
ScanMethodFilter(Any) : matches_any_{true} {}
|
||||
ScanMethodFilter(std::initializer_list<ScanMethod> methods) :
|
||||
matches_any_{false},
|
||||
methods_{methods}
|
||||
{}
|
||||
|
||||
bool matches(ScanMethod method) const
|
||||
{
|
||||
if (matches_any_)
|
||||
return true;
|
||||
auto it = std::find(methods_.begin(), methods_.end(), method);
|
||||
return it != methods_.end();
|
||||
}
|
||||
|
||||
bool operator==(const ScanMethodFilter& other) const
|
||||
{
|
||||
return matches_any_ == other.matches_any_ && methods_ == other.methods_;
|
||||
}
|
||||
|
||||
bool matches_any() const { return matches_any_; }
|
||||
const std::vector<ScanMethod>& methods() const { return methods_; }
|
||||
|
||||
private:
|
||||
bool matches_any_ = false;
|
||||
std::vector<ScanMethod> methods_;
|
||||
|
||||
template<class Stream>
|
||||
friend void serialize(Stream& str, ResolutionFilter& x);
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const ScanMethodFilter& methods);
|
||||
|
||||
|
||||
struct Genesys_Sensor {
|
||||
|
||||
Genesys_Sensor() = default;
|
||||
|
|
Ładowanie…
Reference in New Issue