genesys: Move *_set_xpa_lamp_power() to common command set

merge-requests/317/merge
Povilas Kanapickas 2020-01-12 10:57:06 +02:00
rodzic cbb3d98e83
commit 05978e1c8b
4 zmienionych plików z 98 dodań i 96 usunięć

Wyświetl plik

@ -160,6 +160,9 @@ 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_lamp_power(Genesys_Device& dev, bool set) 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;

Wyświetl plik

@ -28,6 +28,95 @@ namespace genesys {
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,
bool set) const
{

Wyświetl plik

@ -35,6 +35,8 @@ class CommandSetCommon : public CommandSet
public:
~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,
bool set) const override;
};

Wyświetl plik

@ -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
void CommandSetGl843::begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
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) {
gl843_set_xpa_lamp_power(dev, true);
dev->cmd_set->set_xpa_lamp_power(*dev, true);
}
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_8600F:
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) {
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_7500I: {
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;
}
@ -1547,7 +1455,7 @@ void CommandSetGl843::end_scan(Genesys_Device* dev, Genesys_Register_Set* reg,
// turn off XPA lamp if needed
// 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) {
gl843_set_xpa_lamp_power(dev, false);
dev->cmd_set->set_xpa_lamp_power(*dev, false);
}
if (!dev->model->is_sheetfed) {