genesys: Expose update_home_sensor_gpio() in the cmd set

merge-requests/228/merge
Povilas Kanapickas 2019-11-30 19:06:49 +02:00
rodzic 326733a479
commit a355df168a
7 zmienionych plików z 65 dodań i 54 usunięć

Wyświetl plik

@ -107,6 +107,16 @@ public:
// Updates hardware sensor information in Genesys_Scanner.val[].
virtual void update_hardware_sensors(struct Genesys_Scanner* s) const = 0;
/** Whether the scanner needs to call update_home_sensor_gpio before reading the status of the
home sensor. On some chipsets this is unreliable until update_home_sensor_gpio() is called.
*/
virtual bool needs_update_home_sensor_gpio() const { return false; }
/** Needed on some chipsets before reading the status of the home sensor to make this operation
reliable.
*/
virtual void update_home_sensor_gpio(Genesys_Device& dev) const { (void) dev; }
// functions for sheetfed scanners
// load document into scanner

Wyświetl plik

@ -53,15 +53,6 @@
namespace genesys {
namespace gl124 {
static void gl124_homsnr_gpio(Genesys_Device* dev)
{
DBG_HELPER(dbg);
uint8_t val = dev->interface->read_register(REG_0x32);
val &= ~REG_0x32_GPIO10;
dev->interface->write_register(REG_0x32, val);
}
/** @brief set all registers to default values .
* This function is called only once at the beginning and
* fills register startup values for registers reused across scans.
@ -1018,9 +1009,7 @@ static void gl124_stop_action(Genesys_Device* dev)
std::uint8_t val40;
unsigned int loop;
// post scan gpio : without that HOMSNR is unreliable
gl124_homsnr_gpio(dev);
dev->cmd_set->update_home_sensor_gpio(*dev);
scanner_read_print_status(*dev);
val40 = dev->interface->read_register(REG_0x100);
@ -1197,8 +1186,7 @@ void CommandSetGl124::slow_back_home(Genesys_Device* dev, bool wait_until_home)
int loop = 0;
// post scan gpio : without that HOMSNR is unreliable
gl124_homsnr_gpio(dev);
dev->cmd_set->update_home_sensor_gpio(*dev);
auto status = scanner_read_reliable_status(*dev);
if (status.is_at_home) {
@ -1257,9 +1245,7 @@ void CommandSetGl124::slow_back_home(Genesys_Device* dev, bool wait_until_home)
throw;
}
// post scan gpio : without that HOMSNR is unreliable
gl124_homsnr_gpio(dev);
update_home_sensor_gpio(*dev);
if (is_testing_mode()) {
dev->interface->test_checkpoint("slow_back_home");
return;
@ -2503,6 +2489,15 @@ void CommandSetGl124::update_hardware_sensors(Genesys_Scanner* s) const
}
}
void CommandSetGl124::update_home_sensor_gpio(Genesys_Device& dev) const
{
DBG_HELPER(dbg);
std::uint8_t val = dev.interface->read_register(REG_0x32);
val &= ~REG_0x32_GPIO10;
dev.interface->write_register(REG_0x32, val);
}
bool CommandSetGl124::needs_home_before_init_regs_for_scan(Genesys_Device* dev) const
{
(void) dev;

Wyświetl plik

@ -165,6 +165,10 @@ public:
void update_hardware_sensors(struct Genesys_Scanner* s) const override;
bool needs_update_home_sensor_gpio() const override { return true; }
void update_home_sensor_gpio(Genesys_Device& dev) const override;
void load_document(Genesys_Device* dev) const override;
void detect_document_end(Genesys_Device* dev) const override;

Wyświetl plik

@ -327,15 +327,6 @@ static void gl846_set_adi_fe(Genesys_Device* dev, uint8_t set)
}
}
static void gl846_homsnr_gpio(Genesys_Device* dev)
{
DBG_HELPER(dbg);
uint8_t val = dev->interface->read_register(REG_0x6C);
val |= 0x41;
dev->interface->write_register(REG_0x6C, val);
}
// Set values of analog frontend
void CommandSetGl846::set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t set) const
{
@ -855,8 +846,7 @@ static void gl846_stop_action(Genesys_Device* dev)
DBG_HELPER(dbg);
unsigned int loop;
// post scan gpio : without that HOMSNR is unreliable
gl846_homsnr_gpio(dev);
dev->cmd_set->update_home_sensor_gpio(*dev);
scanner_read_print_status(*dev);
uint8_t val40 = dev->interface->read_register(REG_0x40);
@ -947,8 +937,7 @@ void CommandSetGl846::slow_back_home(Genesys_Device* dev, bool wait_until_home)
int loop = 0;
ScanColorMode scan_mode;
// post scan gpio : without that HOMSNR is unreliable
gl846_homsnr_gpio(dev);
update_home_sensor_gpio(*dev);
// first read gives HOME_SENSOR true
auto status = scanner_read_reliable_status(*dev);
@ -1011,8 +1000,7 @@ void CommandSetGl846::slow_back_home(Genesys_Device* dev, bool wait_until_home)
throw;
}
// post scan gpio : without that HOMSNR is unreliable
gl846_homsnr_gpio(dev);
update_home_sensor_gpio(*dev);
if (is_testing_mode()) {
dev->interface->test_checkpoint("slow_back_home");
@ -1783,6 +1771,16 @@ void CommandSetGl846::update_hardware_sensors(Genesys_Scanner* s) const
s->buttons[BUTTON_COPY_SW].write((val & copy) == 0);
}
void CommandSetGl846::update_home_sensor_gpio(Genesys_Device& dev) const
{
DBG_HELPER(dbg);
std::uint8_t val = dev.interface->read_register(REG_0x6C);
val |= 0x41;
dev.interface->write_register(REG_0x6C, val);
}
/** @brief search for a full width black or white strip.
* This function searches for a black or white stripe across the scanning area.
* When searching backward, the searched area must completely be of the desired

Wyświetl plik

@ -186,6 +186,10 @@ public:
void update_hardware_sensors(struct Genesys_Scanner* s) const override;
bool needs_update_home_sensor_gpio() const override { return true; }
void update_home_sensor_gpio(Genesys_Device& dev) const override;
void load_document(Genesys_Device* dev) const override;
void detect_document_end(Genesys_Device* dev) const override;

Wyświetl plik

@ -352,22 +352,6 @@ static void gl847_set_ad_fe(Genesys_Device* dev, uint8_t set)
}
}
static void gl847_homsnr_gpio(Genesys_Device* dev)
{
DBG_HELPER(dbg);
uint8_t val;
if (dev->model->gpio_id == GpioId::CANON_LIDE_700F) {
val = dev->interface->read_register(REG_0x6C);
val &= ~REG_0x6C_GPIO10;
dev->interface->write_register(REG_0x6C, val);
} else {
val = dev->interface->read_register(REG_0x6C);
val |= REG_0x6C_GPIO10;
dev->interface->write_register(REG_0x6C, val);
}
}
// Set values of analog frontend
void CommandSetGl847::set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t set) const
{
@ -867,8 +851,7 @@ static void gl847_stop_action(Genesys_Device* dev)
uint8_t val;
unsigned int loop;
// post scan gpio : without that HOMSNR is unreliable
gl847_homsnr_gpio(dev);
dev->cmd_set->update_home_sensor_gpio(*dev);
scanner_read_print_status(*dev);
uint8_t val40 = dev->interface->read_register(REG_0x40);
@ -1000,8 +983,7 @@ void CommandSetGl847::slow_back_home(Genesys_Device* dev, bool wait_until_home)
int loop = 0;
ScanColorMode scan_mode;
// post scan gpio : without that HOMSNR is unreliable
gl847_homsnr_gpio(dev);
update_home_sensor_gpio(*dev);
// first read gives HOME_SENSOR true
auto status = scanner_read_reliable_status(*dev);
@ -1061,8 +1043,7 @@ void CommandSetGl847::slow_back_home(Genesys_Device* dev, bool wait_until_home)
throw;
}
// post scan gpio : without that HOMSNR is unreliable
gl847_homsnr_gpio(dev);
update_home_sensor_gpio(*dev);
if (is_testing_mode()) {
dev->interface->test_checkpoint("slow_back_home");
@ -1854,6 +1835,21 @@ void CommandSetGl847::update_hardware_sensors(Genesys_Scanner* s) const
s->buttons[BUTTON_COPY_SW].write((val & copy) == 0);
}
void CommandSetGl847::update_home_sensor_gpio(Genesys_Device& dev) const
{
DBG_HELPER(dbg);
if (dev.model->gpio_id == GpioId::CANON_LIDE_700F) {
std::uint8_t val = dev.interface->read_register(REG_0x6C);
val &= ~REG_0x6C_GPIO10;
dev.interface->write_register(REG_0x6C, val);
} else {
std::uint8_t val = dev.interface->read_register(REG_0x6C);
val |= REG_0x6C_GPIO10;
dev.interface->write_register(REG_0x6C, val);
}
}
/** @brief search for a full width black or white strip.
* This function searches for a black or white stripe across the scanning area.
* When searching backward, the searched area must completely be of the desired

Wyświetl plik

@ -170,6 +170,10 @@ public:
void update_hardware_sensors(struct Genesys_Scanner* s) const override;
bool needs_update_home_sensor_gpio() const override { return true; }
void update_home_sensor_gpio(Genesys_Device& dev) const override;
void load_document(Genesys_Device* dev) const override;
void detect_document_end(Genesys_Device* dev) const override;