kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Move *_set_xpa_motor_power() to common command set
rodzic
3753716e04
commit
cbb3d98e83
|
@ -159,6 +159,10 @@ public:
|
|||
|
||||
/// cold boot init function
|
||||
virtual void asic_boot(Genesys_Device* dev, bool cold) const = 0;
|
||||
|
||||
/// enables or disables XPA slider motor
|
||||
virtual void set_xpa_motor_power(Genesys_Device& dev, Genesys_Register_Set& regs,
|
||||
bool set) const = 0;
|
||||
};
|
||||
|
||||
} // namespace genesys
|
||||
|
|
|
@ -28,4 +28,80 @@ namespace genesys {
|
|||
|
||||
CommandSetCommon::~CommandSetCommon() = default;
|
||||
|
||||
void CommandSetCommon::set_xpa_motor_power(Genesys_Device& dev, Genesys_Register_Set& regs,
|
||||
bool set) const
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
|
||||
struct MotorSettings {
|
||||
ModelId model_id;
|
||||
ResolutionFilter resolutions;
|
||||
GenesysRegisterSettingSet regs_on;
|
||||
GenesysRegisterSettingSet regs_off;
|
||||
};
|
||||
|
||||
MotorSettings settings[] = {
|
||||
{ ModelId::CANON_8400F, { 400, 800, 1600 }, {
|
||||
{ 0x6c, 0x00, 0x90 },
|
||||
{ 0xa9, 0x04, 0x06 },
|
||||
}, {
|
||||
{ 0x6c, 0x90, 0x90 },
|
||||
{ 0xa9, 0x02, 0x06 },
|
||||
}
|
||||
},
|
||||
{ ModelId::CANON_8400F, { 3200 }, {
|
||||
{ 0x6c, 0x00, 0x92 },
|
||||
{ 0xa9, 0x04, 0x06 },
|
||||
}, {
|
||||
{ 0x6c, 0x90, 0x90 },
|
||||
{ 0xa9, 0x02, 0x06 },
|
||||
}
|
||||
},
|
||||
{ ModelId::CANON_8600F, { 300, 600, 1200 }, {
|
||||
{ 0x6c, 0x00, 0x20 },
|
||||
{ 0xa6, 0x01, 0x41 },
|
||||
}, {
|
||||
{ 0x6c, 0x20, 0x22 },
|
||||
{ 0xa6, 0x00, 0x41 },
|
||||
}
|
||||
},
|
||||
{ ModelId::CANON_8600F, { 2400, 4800 }, {
|
||||
{ 0x6c, 0x02, 0x22 },
|
||||
{ 0xa6, 0x01, 0x41 },
|
||||
}, {
|
||||
{ 0x6c, 0x20, 0x22 },
|
||||
{ 0xa6, 0x00, 0x41 },
|
||||
}
|
||||
},
|
||||
{ ModelId::HP_SCANJET_G4050, ResolutionFilter::ANY, {
|
||||
{ 0x6b, 0x81, 0x81 }, // set MULTFILM and GPOADF
|
||||
{ 0x6c, 0x00, 0x40 }, // note that reverse change is not applied on off
|
||||
// 0xa6 register 0x08 bit likely sets motor power. No move at all without that one
|
||||
{ 0xa6, 0x08, 0x08 }, // note that reverse change is not applied on off
|
||||
{ 0xa8, 0x00, 0x04 },
|
||||
{ 0xa9, 0x30, 0x30 },
|
||||
}, {
|
||||
{ 0x6b, 0x00, 0x01 }, // BUG: note that only ADF is unset
|
||||
{ 0xa8, 0x04, 0x04 },
|
||||
{ 0xa9, 0x00, 0x10 }, // note that 0x20 bit is not reset
|
||||
}
|
||||
},
|
||||
{ ModelId::PLUSTEK_OPTICFILM_7200I, ResolutionFilter::ANY, {}, {} },
|
||||
{ ModelId::PLUSTEK_OPTICFILM_7300, ResolutionFilter::ANY, {}, {} },
|
||||
{ ModelId::PLUSTEK_OPTICFILM_7500I, ResolutionFilter::ANY, {}, {} },
|
||||
};
|
||||
|
||||
for (const auto& setting : settings) {
|
||||
if (setting.model_id == dev.model->model_id &&
|
||||
setting.resolutions.matches(dev.session.output_resolution))
|
||||
{
|
||||
apply_reg_settings_to_device(dev, set ? setting.regs_on : setting.regs_off);
|
||||
regs.state.is_xpa_motor_on = set;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw SaneException("Motor settings have not been found");
|
||||
}
|
||||
|
||||
} // namespace genesys
|
||||
|
|
|
@ -34,6 +34,9 @@ class CommandSetCommon : public CommandSet
|
|||
{
|
||||
public:
|
||||
~CommandSetCommon() override;
|
||||
|
||||
void set_xpa_motor_power(Genesys_Device& dev, Genesys_Register_Set& regs,
|
||||
bool set) const override;
|
||||
};
|
||||
|
||||
} // namespace genesys
|
||||
|
|
|
@ -718,11 +718,6 @@ void sanei_genesys_search_reference_point(Genesys_Device* dev, Genesys_Sensor& s
|
|||
sensor.ccd_start_xoffset, left, top);
|
||||
}
|
||||
|
||||
namespace gl843 {
|
||||
void gl843_park_xpa_lamp(Genesys_Device* dev);
|
||||
void gl843_set_xpa_motor_power(Genesys_Device* dev, Genesys_Register_Set& regs, bool set);
|
||||
} // namespace gl843
|
||||
|
||||
namespace gl124 {
|
||||
void gl124_setup_scan_gpio(Genesys_Device* dev, int resolution);
|
||||
} // namespace gl124
|
||||
|
@ -969,14 +964,14 @@ void scanner_move(Genesys_Device& dev, ScanMethod scan_method, unsigned steps, D
|
|||
|
||||
dev.interface->write_registers(local_reg);
|
||||
if (uses_secondary_head) {
|
||||
gl843::gl843_set_xpa_motor_power(&dev, local_reg, true);
|
||||
dev.cmd_set->set_xpa_motor_power(dev, local_reg, true);
|
||||
}
|
||||
|
||||
try {
|
||||
scanner_start_action(dev, true);
|
||||
} catch (...) {
|
||||
catch_all_exceptions(__func__, [&]() {
|
||||
gl843::gl843_set_xpa_motor_power(&dev, local_reg, false);
|
||||
dev.cmd_set->set_xpa_motor_power(dev, local_reg, false);
|
||||
});
|
||||
catch_all_exceptions(__func__, [&]() { scanner_stop_action(dev); });
|
||||
// restore original registers
|
||||
|
@ -997,7 +992,7 @@ void scanner_move(Genesys_Device& dev, ScanMethod scan_method, unsigned steps, D
|
|||
scanner_stop_action(dev);
|
||||
}
|
||||
if (uses_secondary_head) {
|
||||
gl843::gl843_set_xpa_motor_power(&dev, local_reg, false);
|
||||
dev.cmd_set->set_xpa_motor_power(dev, local_reg, false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1020,7 +1015,7 @@ void scanner_move(Genesys_Device& dev, ScanMethod scan_method, unsigned steps, D
|
|||
scanner_stop_action(dev);
|
||||
}
|
||||
if (uses_secondary_head) {
|
||||
gl843::gl843_set_xpa_motor_power(&dev, local_reg, false);
|
||||
dev.cmd_set->set_xpa_motor_power(dev, local_reg, false);
|
||||
}
|
||||
|
||||
dev.advance_head_pos_by_steps(ScanHeadId::PRIMARY, direction, steps);
|
||||
|
@ -1230,7 +1225,7 @@ void scanner_move_back_home_ta(Genesys_Device& dev)
|
|||
scanner_clear_scan_and_feed_counts(dev);
|
||||
|
||||
dev.interface->write_registers(local_reg);
|
||||
gl843::gl843_set_xpa_motor_power(&dev, local_reg, true);
|
||||
dev.cmd_set->set_xpa_motor_power(dev, local_reg, true);
|
||||
|
||||
try {
|
||||
scanner_start_action(dev, true);
|
||||
|
@ -1255,7 +1250,7 @@ void scanner_move_back_home_ta(Genesys_Device& dev)
|
|||
}
|
||||
|
||||
scanner_stop_action(dev);
|
||||
gl843::gl843_set_xpa_motor_power(&dev, local_reg, false);
|
||||
dev.cmd_set->set_xpa_motor_power(dev, local_reg, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1277,7 +1272,7 @@ void scanner_move_back_home_ta(Genesys_Device& dev)
|
|||
}
|
||||
|
||||
scanner_stop_action(dev);
|
||||
gl843::gl843_set_xpa_motor_power(&dev, local_reg, false);
|
||||
dev.cmd_set->set_xpa_motor_power(dev, local_reg, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1363,83 +1363,6 @@ void CommandSetGl843::detect_document_end(Genesys_Device* dev) const
|
|||
}
|
||||
}
|
||||
|
||||
// enables or disables XPA slider motor
|
||||
void gl843_set_xpa_motor_power(Genesys_Device* dev, Genesys_Register_Set& regs, bool set)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
|
||||
struct MotorSettings {
|
||||
ModelId model_id;
|
||||
ResolutionFilter resolutions;
|
||||
GenesysRegisterSettingSet regs_on;
|
||||
GenesysRegisterSettingSet regs_off;
|
||||
};
|
||||
|
||||
MotorSettings settings[] = {
|
||||
{ ModelId::CANON_8400F, { 400, 800, 1600 }, {
|
||||
{ 0x6c, 0x00, 0x90 },
|
||||
{ 0xa9, 0x04, 0x06 },
|
||||
}, {
|
||||
{ 0x6c, 0x90, 0x90 },
|
||||
{ 0xa9, 0x02, 0x06 },
|
||||
}
|
||||
},
|
||||
{ ModelId::CANON_8400F, { 3200 }, {
|
||||
{ 0x6c, 0x00, 0x92 },
|
||||
{ 0xa9, 0x04, 0x06 },
|
||||
}, {
|
||||
{ 0x6c, 0x90, 0x90 },
|
||||
{ 0xa9, 0x02, 0x06 },
|
||||
}
|
||||
},
|
||||
{ ModelId::CANON_8600F, { 300, 600, 1200 }, {
|
||||
{ 0x6c, 0x00, 0x20 },
|
||||
{ 0xa6, 0x01, 0x41 },
|
||||
}, {
|
||||
{ 0x6c, 0x20, 0x22 },
|
||||
{ 0xa6, 0x00, 0x41 },
|
||||
}
|
||||
},
|
||||
{ ModelId::CANON_8600F, { 2400, 4800 }, {
|
||||
{ 0x6c, 0x02, 0x22 },
|
||||
{ 0xa6, 0x01, 0x41 },
|
||||
}, {
|
||||
{ 0x6c, 0x20, 0x22 },
|
||||
{ 0xa6, 0x00, 0x41 },
|
||||
}
|
||||
},
|
||||
{ ModelId::HP_SCANJET_G4050, ResolutionFilter::ANY, {
|
||||
{ 0x6b, 0x81, 0x81 }, // set MULTFILM and GPOADF
|
||||
{ 0x6c, 0x00, 0x40 }, // note that reverse change is not applied on off
|
||||
// 0xa6 register 0x08 bit likely sets motor power. No move at all without that one
|
||||
{ 0xa6, 0x08, 0x08 }, // note that reverse change is not applied on off
|
||||
{ 0xa8, 0x00, 0x04 },
|
||||
{ 0xa9, 0x30, 0x30 },
|
||||
}, {
|
||||
{ 0x6b, 0x00, 0x01 }, // BUG: note that only ADF is unset
|
||||
{ 0xa8, 0x04, 0x04 },
|
||||
{ 0xa9, 0x00, 0x10 }, // note that 0x20 bit is not reset
|
||||
}
|
||||
},
|
||||
{ ModelId::PLUSTEK_OPTICFILM_7200I, ResolutionFilter::ANY, {}, {} },
|
||||
{ ModelId::PLUSTEK_OPTICFILM_7300, ResolutionFilter::ANY, {}, {} },
|
||||
{ ModelId::PLUSTEK_OPTICFILM_7500I, ResolutionFilter::ANY, {}, {} },
|
||||
};
|
||||
|
||||
for (const auto& setting : settings) {
|
||||
if (setting.model_id == dev->model->model_id &&
|
||||
setting.resolutions.matches(dev->session.output_resolution))
|
||||
{
|
||||
apply_reg_settings_to_device(*dev, set ? setting.regs_on : setting.regs_off);
|
||||
regs.state.is_xpa_motor_on = set;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw SaneException("Motor settings have not been found");
|
||||
}
|
||||
|
||||
|
||||
/** @brief light XPA lamp
|
||||
* toggle gpios to switch off regular lamp and light on the
|
||||
* XPA light
|
||||
|
@ -1565,7 +1488,7 @@ void CommandSetGl843::begin_scan(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
}
|
||||
|
||||
if (reg->state.is_xpa_on) {
|
||||
gl843_set_xpa_motor_power(dev, *reg, true);
|
||||
dev->cmd_set->set_xpa_motor_power(*dev, *reg, true);
|
||||
}
|
||||
|
||||
// blinking led
|
||||
|
@ -1577,7 +1500,7 @@ void CommandSetGl843::begin_scan(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
gl843_set_xpa_lamp_power(dev, true);
|
||||
}
|
||||
if (reg->state.is_xpa_on) {
|
||||
gl843_set_xpa_motor_power(dev, *reg, true);
|
||||
dev->cmd_set->set_xpa_motor_power(*dev, *reg, true);
|
||||
}
|
||||
break;
|
||||
case GpioId::PLUSTEK_OPTICFILM_7200I:
|
||||
|
|
Ładowanie…
Reference in New Issue