kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Move *_set_xpa_lamp_power() to common command set
rodzic
cbb3d98e83
commit
05978e1c8b
|
@ -160,6 +160,9 @@ public:
|
||||||
/// cold boot init function
|
/// cold boot init function
|
||||||
virtual void asic_boot(Genesys_Device* dev, bool cold) const = 0;
|
virtual void asic_boot(Genesys_Device* dev, bool cold) const = 0;
|
||||||
|
|
||||||
|
/// enables or disables XPA slider motor
|
||||||
|
virtual void set_xpa_lamp_power(Genesys_Device& dev, bool set) const = 0;
|
||||||
|
|
||||||
/// enables or disables XPA slider motor
|
/// enables or disables XPA slider motor
|
||||||
virtual void set_xpa_motor_power(Genesys_Device& dev, Genesys_Register_Set& regs,
|
virtual void set_xpa_motor_power(Genesys_Device& dev, Genesys_Register_Set& regs,
|
||||||
bool set) const = 0;
|
bool set) const = 0;
|
||||||
|
|
|
@ -28,6 +28,95 @@ namespace genesys {
|
||||||
|
|
||||||
CommandSetCommon::~CommandSetCommon() = default;
|
CommandSetCommon::~CommandSetCommon() = default;
|
||||||
|
|
||||||
|
void CommandSetCommon::set_xpa_lamp_power(Genesys_Device& dev, bool set) const
|
||||||
|
|
||||||
|
{
|
||||||
|
DBG_HELPER(dbg);
|
||||||
|
|
||||||
|
struct LampSettings {
|
||||||
|
ModelId model_id;
|
||||||
|
ScanMethod scan_method;
|
||||||
|
GenesysRegisterSettingSet regs_on;
|
||||||
|
GenesysRegisterSettingSet regs_off;
|
||||||
|
};
|
||||||
|
|
||||||
|
// FIXME: BUG: we're not clearing the registers to the previous state when returning back when
|
||||||
|
// turning off the lamp
|
||||||
|
LampSettings settings[] = {
|
||||||
|
{ ModelId::CANON_8400F, ScanMethod::TRANSPARENCY, {
|
||||||
|
{ 0xa6, 0x34, 0xf4 },
|
||||||
|
}, {
|
||||||
|
{ 0xa6, 0x40, 0x70 },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ ModelId::CANON_8400F, ScanMethod::TRANSPARENCY_INFRARED, {
|
||||||
|
{ 0x6c, 0x40, 0x40 },
|
||||||
|
{ 0xa6, 0x01, 0xff },
|
||||||
|
}, {
|
||||||
|
{ 0x6c, 0x00, 0x40 },
|
||||||
|
{ 0xa6, 0x00, 0xff },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ ModelId::CANON_8600F, ScanMethod::TRANSPARENCY, {
|
||||||
|
{ 0xa6, 0x34, 0xf4 },
|
||||||
|
{ 0xa7, 0xe0, 0xe0 },
|
||||||
|
}, {
|
||||||
|
{ 0xa6, 0x40, 0x70 },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ ModelId::CANON_8600F, ScanMethod::TRANSPARENCY_INFRARED, {
|
||||||
|
{ 0xa6, 0x00, 0xc0 },
|
||||||
|
{ 0xa7, 0xe0, 0xe0 },
|
||||||
|
{ 0x6c, 0x80, 0x80 },
|
||||||
|
}, {
|
||||||
|
{ 0xa6, 0x00, 0xc0 },
|
||||||
|
{ 0x6c, 0x00, 0x80 },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ ModelId::PLUSTEK_OPTICFILM_7200I, ScanMethod::TRANSPARENCY, {
|
||||||
|
}, {
|
||||||
|
{ 0xa6, 0x40, 0x70 }, // BUG: remove this cleanup write, it was enabled by accident
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ ModelId::PLUSTEK_OPTICFILM_7200I, ScanMethod::TRANSPARENCY_INFRARED, {
|
||||||
|
{ 0xa8, 0x07, 0x07 },
|
||||||
|
}, {
|
||||||
|
{ 0xa8, 0x00, 0x07 },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ ModelId::PLUSTEK_OPTICFILM_7300, ScanMethod::TRANSPARENCY, {}, {} },
|
||||||
|
{ ModelId::PLUSTEK_OPTICFILM_7500I, ScanMethod::TRANSPARENCY, {}, {} },
|
||||||
|
{ ModelId::PLUSTEK_OPTICFILM_7500I, ScanMethod::TRANSPARENCY_INFRARED, {
|
||||||
|
{ 0xa8, 0x07, 0x07 },
|
||||||
|
}, {
|
||||||
|
{ 0xa8, 0x00, 0x07 },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const auto& setting : settings) {
|
||||||
|
if (setting.model_id == dev.model->model_id &&
|
||||||
|
setting.scan_method == dev.settings.scan_method)
|
||||||
|
{
|
||||||
|
apply_reg_settings_to_device(dev, set ? setting.regs_on : setting.regs_off);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// BUG: we're currently calling the function in shut down path of regular lamp
|
||||||
|
if (set) {
|
||||||
|
throw SaneException("Unexpected code path entered");
|
||||||
|
}
|
||||||
|
|
||||||
|
GenesysRegisterSettingSet regs = {
|
||||||
|
{ 0xa6, 0x40, 0x70 },
|
||||||
|
};
|
||||||
|
apply_reg_settings_to_device(dev, regs);
|
||||||
|
// TODO: throw exception when we're only calling this function in error return path
|
||||||
|
// throw SaneException("Could not find XPA lamp settings");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void CommandSetCommon::set_xpa_motor_power(Genesys_Device& dev, Genesys_Register_Set& regs,
|
void CommandSetCommon::set_xpa_motor_power(Genesys_Device& dev, Genesys_Register_Set& regs,
|
||||||
bool set) const
|
bool set) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,6 +35,8 @@ class CommandSetCommon : public CommandSet
|
||||||
public:
|
public:
|
||||||
~CommandSetCommon() override;
|
~CommandSetCommon() override;
|
||||||
|
|
||||||
|
void set_xpa_lamp_power(Genesys_Device& dev, bool set) const override;
|
||||||
|
|
||||||
void set_xpa_motor_power(Genesys_Device& dev, Genesys_Register_Set& regs,
|
void set_xpa_motor_power(Genesys_Device& dev, Genesys_Register_Set& regs,
|
||||||
bool set) const override;
|
bool set) const override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1363,98 +1363,6 @@ void CommandSetGl843::detect_document_end(Genesys_Device* dev) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief light XPA lamp
|
|
||||||
* toggle gpios to switch off regular lamp and light on the
|
|
||||||
* XPA light
|
|
||||||
* @param dev device to set up
|
|
||||||
*/
|
|
||||||
static void gl843_set_xpa_lamp_power(Genesys_Device* dev, bool set)
|
|
||||||
{
|
|
||||||
DBG_HELPER(dbg);
|
|
||||||
|
|
||||||
struct LampSettings {
|
|
||||||
ModelId model_id;
|
|
||||||
ScanMethod scan_method;
|
|
||||||
GenesysRegisterSettingSet regs_on;
|
|
||||||
GenesysRegisterSettingSet regs_off;
|
|
||||||
};
|
|
||||||
|
|
||||||
// FIXME: BUG: we're not clearing the registers to the previous state when returning back when
|
|
||||||
// turning off the lamp
|
|
||||||
LampSettings settings[] = {
|
|
||||||
{ ModelId::CANON_8400F, ScanMethod::TRANSPARENCY, {
|
|
||||||
{ 0xa6, 0x34, 0xf4 },
|
|
||||||
}, {
|
|
||||||
{ 0xa6, 0x40, 0x70 },
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ ModelId::CANON_8400F, ScanMethod::TRANSPARENCY_INFRARED, {
|
|
||||||
{ 0x6c, 0x40, 0x40 },
|
|
||||||
{ 0xa6, 0x01, 0xff },
|
|
||||||
}, {
|
|
||||||
{ 0x6c, 0x00, 0x40 },
|
|
||||||
{ 0xa6, 0x00, 0xff },
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ ModelId::CANON_8600F, ScanMethod::TRANSPARENCY, {
|
|
||||||
{ 0xa6, 0x34, 0xf4 },
|
|
||||||
{ 0xa7, 0xe0, 0xe0 },
|
|
||||||
}, {
|
|
||||||
{ 0xa6, 0x40, 0x70 },
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ ModelId::CANON_8600F, ScanMethod::TRANSPARENCY_INFRARED, {
|
|
||||||
{ 0xa6, 0x00, 0xc0 },
|
|
||||||
{ 0xa7, 0xe0, 0xe0 },
|
|
||||||
{ 0x6c, 0x80, 0x80 },
|
|
||||||
}, {
|
|
||||||
{ 0xa6, 0x00, 0xc0 },
|
|
||||||
{ 0x6c, 0x00, 0x80 },
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ ModelId::PLUSTEK_OPTICFILM_7200I, ScanMethod::TRANSPARENCY, {
|
|
||||||
}, {
|
|
||||||
{ 0xa6, 0x40, 0x70 }, // BUG: remove this cleanup write, it was enabled by accident
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ ModelId::PLUSTEK_OPTICFILM_7200I, ScanMethod::TRANSPARENCY_INFRARED, {
|
|
||||||
{ 0xa8, 0x07, 0x07 },
|
|
||||||
}, {
|
|
||||||
{ 0xa8, 0x00, 0x07 },
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ ModelId::PLUSTEK_OPTICFILM_7300, ScanMethod::TRANSPARENCY, {}, {} },
|
|
||||||
{ ModelId::PLUSTEK_OPTICFILM_7500I, ScanMethod::TRANSPARENCY, {}, {} },
|
|
||||||
{ ModelId::PLUSTEK_OPTICFILM_7500I, ScanMethod::TRANSPARENCY_INFRARED, {
|
|
||||||
{ 0xa8, 0x07, 0x07 },
|
|
||||||
}, {
|
|
||||||
{ 0xa8, 0x00, 0x07 },
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
for (const auto& setting : settings) {
|
|
||||||
if (setting.model_id == dev->model->model_id &&
|
|
||||||
setting.scan_method == dev->settings.scan_method)
|
|
||||||
{
|
|
||||||
apply_reg_settings_to_device(*dev, set ? setting.regs_on : setting.regs_off);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// BUG: we're currently calling the function in shut down path of regular lamp
|
|
||||||
if (set) {
|
|
||||||
throw SaneException("Unexpected code path entered");
|
|
||||||
}
|
|
||||||
|
|
||||||
GenesysRegisterSettingSet regs = {
|
|
||||||
{ 0xa6, 0x40, 0x70 },
|
|
||||||
};
|
|
||||||
apply_reg_settings_to_device(*dev, regs);
|
|
||||||
// TODO: throw exception when we're only calling this function in error return path
|
|
||||||
// throw SaneException("Could not find XPA lamp settings");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send the low-level scan command
|
// Send the low-level scan command
|
||||||
void CommandSetGl843::begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
|
void CommandSetGl843::begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
|
||||||
Genesys_Register_Set* reg, bool start_motor) const
|
Genesys_Register_Set* reg, bool start_motor) const
|
||||||
|
@ -1484,7 +1392,7 @@ void CommandSetGl843::begin_scan(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reg->state.is_xpa_on && reg->state.is_lamp_on) {
|
if (reg->state.is_xpa_on && reg->state.is_lamp_on) {
|
||||||
gl843_set_xpa_lamp_power(dev, true);
|
dev->cmd_set->set_xpa_lamp_power(*dev, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reg->state.is_xpa_on) {
|
if (reg->state.is_xpa_on) {
|
||||||
|
@ -1497,7 +1405,7 @@ void CommandSetGl843::begin_scan(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
case GpioId::CANON_8400F:
|
case GpioId::CANON_8400F:
|
||||||
case GpioId::CANON_8600F:
|
case GpioId::CANON_8600F:
|
||||||
if (reg->state.is_xpa_on && reg->state.is_lamp_on) {
|
if (reg->state.is_xpa_on && reg->state.is_lamp_on) {
|
||||||
gl843_set_xpa_lamp_power(dev, true);
|
dev->cmd_set->set_xpa_lamp_power(*dev, true);
|
||||||
}
|
}
|
||||||
if (reg->state.is_xpa_on) {
|
if (reg->state.is_xpa_on) {
|
||||||
dev->cmd_set->set_xpa_motor_power(*dev, *reg, true);
|
dev->cmd_set->set_xpa_motor_power(*dev, *reg, true);
|
||||||
|
@ -1507,7 +1415,7 @@ void CommandSetGl843::begin_scan(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
case GpioId::PLUSTEK_OPTICFILM_7300:
|
case GpioId::PLUSTEK_OPTICFILM_7300:
|
||||||
case GpioId::PLUSTEK_OPTICFILM_7500I: {
|
case GpioId::PLUSTEK_OPTICFILM_7500I: {
|
||||||
if (reg->state.is_xpa_on && reg->state.is_lamp_on) {
|
if (reg->state.is_xpa_on && reg->state.is_lamp_on) {
|
||||||
gl843_set_xpa_lamp_power(dev, true);
|
dev->cmd_set->set_xpa_lamp_power(*dev, true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1547,7 +1455,7 @@ void CommandSetGl843::end_scan(Genesys_Device* dev, Genesys_Register_Set* reg,
|
||||||
// turn off XPA lamp if needed
|
// turn off XPA lamp if needed
|
||||||
// BUG: the if condition below probably shouldn't be enabled when XPA is off
|
// BUG: the if condition below probably shouldn't be enabled when XPA is off
|
||||||
if (reg->state.is_xpa_on || reg->state.is_lamp_on) {
|
if (reg->state.is_xpa_on || reg->state.is_lamp_on) {
|
||||||
gl843_set_xpa_lamp_power(dev, false);
|
dev->cmd_set->set_xpa_lamp_power(*dev, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dev->model->is_sheetfed) {
|
if (!dev->model->is_sheetfed) {
|
||||||
|
|
Ładowanie…
Reference in New Issue