kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Extract scanner_is_motor_stopped() to use across the asics
rodzic
c2863d6ba1
commit
9e092f9d67
|
@ -63,6 +63,7 @@
|
||||||
#include "genesys.h"
|
#include "genesys.h"
|
||||||
#include "conv.h"
|
#include "conv.h"
|
||||||
#include "gl124_registers.h"
|
#include "gl124_registers.h"
|
||||||
|
#include "gl841_registers.h"
|
||||||
#include "gl843_registers.h"
|
#include "gl843_registers.h"
|
||||||
#include "gl846_registers.h"
|
#include "gl846_registers.h"
|
||||||
#include "gl847_registers.h"
|
#include "gl847_registers.h"
|
||||||
|
@ -948,6 +949,48 @@ void scanner_clear_scan_and_feed_counts2(Genesys_Device& dev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool scanner_is_motor_stopped(Genesys_Device& dev)
|
||||||
|
{
|
||||||
|
switch (dev.model->asic_type) {
|
||||||
|
case AsicType::GL841: {
|
||||||
|
auto reg = dev.interface->read_register(gl841::REG_0x40);
|
||||||
|
|
||||||
|
return (!(reg & gl841::REG_0x40_DATAENB) && !(reg & gl841::REG_0x40_MOTMFLG));
|
||||||
|
}
|
||||||
|
case AsicType::GL843: {
|
||||||
|
auto status = scanner_read_status(dev);
|
||||||
|
auto reg = dev.interface->read_register(gl843::REG_0x40);
|
||||||
|
|
||||||
|
return (!(reg & gl843::REG_0x40_DATAENB) && !(reg & gl843::REG_0x40_MOTMFLG) &&
|
||||||
|
!status.is_motor_enabled);
|
||||||
|
}
|
||||||
|
case AsicType::GL845:
|
||||||
|
case AsicType::GL846: {
|
||||||
|
auto status = scanner_read_status(dev);
|
||||||
|
auto reg = dev.interface->read_register(gl846::REG_0x40);
|
||||||
|
|
||||||
|
return (!(reg & gl846::REG_0x40_DATAENB) && !(reg & gl846::REG_0x40_MOTMFLG) &&
|
||||||
|
!status.is_motor_enabled);
|
||||||
|
}
|
||||||
|
case AsicType::GL847: {
|
||||||
|
auto status = scanner_read_status(dev);
|
||||||
|
auto reg = dev.interface->read_register(gl847::REG_0x40);
|
||||||
|
|
||||||
|
return (!(reg & gl847::REG_0x40_DATAENB) && !(reg & gl847::REG_0x40_MOTMFLG) &&
|
||||||
|
!status.is_motor_enabled);
|
||||||
|
}
|
||||||
|
case AsicType::GL124: {
|
||||||
|
auto status = scanner_read_status(dev);
|
||||||
|
auto reg = dev.interface->read_register(gl124::REG_0x100);
|
||||||
|
|
||||||
|
return (!(reg & gl124::REG_0x100_DATAENB) && !(reg & gl124::REG_0x100_MOTMFLG) &&
|
||||||
|
!status.is_motor_enabled);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
throw SaneException("Unsupported asic type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void scanner_stop_action(Genesys_Device& dev)
|
void scanner_stop_action(Genesys_Device& dev)
|
||||||
{
|
{
|
||||||
switch (dev.model->asic_type) {
|
switch (dev.model->asic_type) {
|
||||||
|
|
|
@ -1002,18 +1002,12 @@ void CommandSetGl124::set_powersaving(Genesys_Device* dev, int delay /* in minut
|
||||||
void gl124_stop_action(Genesys_Device* dev)
|
void gl124_stop_action(Genesys_Device* dev)
|
||||||
{
|
{
|
||||||
DBG_HELPER(dbg);
|
DBG_HELPER(dbg);
|
||||||
std::uint8_t val40;
|
|
||||||
unsigned int loop;
|
unsigned int loop;
|
||||||
|
|
||||||
dev->cmd_set->update_home_sensor_gpio(*dev);
|
dev->cmd_set->update_home_sensor_gpio(*dev);
|
||||||
auto status = scanner_read_status(*dev);
|
if (scanner_is_motor_stopped(*dev)) {
|
||||||
|
DBG(DBG_info, "%s: already stopped\n", __func__);
|
||||||
val40 = dev->interface->read_register(REG_0x100);
|
return;
|
||||||
|
|
||||||
/* only stop action if needed */
|
|
||||||
if (!(val40 & REG_0x100_DATAENB) && !(val40 & REG_0x100_MOTMFLG) && !status.is_motor_enabled) {
|
|
||||||
DBG (DBG_info, "%s: already stopped\n", __func__);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scanner_stop_action_no_move(*dev, dev->reg);
|
scanner_stop_action_no_move(*dev, dev->reg);
|
||||||
|
@ -1025,13 +1019,7 @@ void gl124_stop_action(Genesys_Device* dev)
|
||||||
loop = 10;
|
loop = 10;
|
||||||
while (loop > 0)
|
while (loop > 0)
|
||||||
{
|
{
|
||||||
auto status = scanner_read_status(*dev);
|
if (scanner_is_motor_stopped(*dev)) {
|
||||||
val40 = dev->interface->read_register(REG_0x100);
|
|
||||||
|
|
||||||
/* if scanner is in command mode, we are done */
|
|
||||||
if (!(val40 & REG_0x100_DATAENB) && !(val40 & REG_0x100_MOTMFLG) &&
|
|
||||||
!status.is_motor_enabled)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1860,12 +1860,9 @@ static void gl841_stop_action(Genesys_Device* dev)
|
||||||
|
|
||||||
scanner_read_print_status(*dev);
|
scanner_read_print_status(*dev);
|
||||||
|
|
||||||
uint8_t val40 = dev->interface->read_register(0x40);
|
if (scanner_is_motor_stopped(*dev)) {
|
||||||
|
DBG(DBG_info, "%s: already stopped\n", __func__);
|
||||||
/* only stop action if needed */
|
return;
|
||||||
if (!(val40 & REG_0x40_DATAENB) && !(val40 & REG_0x40_MOTMFLG)) {
|
|
||||||
DBG(DBG_info, "%s: already stopped\n", __func__);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local_reg = dev->reg;
|
local_reg = dev->reg;
|
||||||
|
@ -1885,12 +1882,9 @@ static void gl841_stop_action(Genesys_Device* dev)
|
||||||
|
|
||||||
loop = 10;
|
loop = 10;
|
||||||
while (loop > 0) {
|
while (loop > 0) {
|
||||||
val40 = dev->interface->read_register(0x40);
|
if (scanner_is_motor_stopped(*dev)) {
|
||||||
|
return;
|
||||||
/* if scanner is in command mode, we are done */
|
}
|
||||||
if (!(val40 & REG_0x40_DATAENB) && !(val40 & REG_0x40_MOTMFLG)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev->interface->sleep_ms(100);
|
dev->interface->sleep_ms(100);
|
||||||
loop--;
|
loop--;
|
||||||
|
|
|
@ -188,6 +188,7 @@ static constexpr RegAddr REG_ENDPIXEL = 0x32;
|
||||||
static constexpr RegAddr REG_MAXWD = 0x35;
|
static constexpr RegAddr REG_MAXWD = 0x35;
|
||||||
static constexpr RegAddr REG_LPERIOD = 0x38;
|
static constexpr RegAddr REG_LPERIOD = 0x38;
|
||||||
|
|
||||||
|
static constexpr RegAddr REG_0x40 = 0x40;
|
||||||
static constexpr RegMask REG_0x40_HISPDFLG = 0x04;
|
static constexpr RegMask REG_0x40_HISPDFLG = 0x04;
|
||||||
static constexpr RegMask REG_0x40_MOTMFLG = 0x02;
|
static constexpr RegMask REG_0x40_MOTMFLG = 0x02;
|
||||||
static constexpr RegMask REG_0x40_DATAENB = 0x01;
|
static constexpr RegMask REG_0x40_DATAENB = 0x01;
|
||||||
|
|
|
@ -1320,15 +1320,9 @@ void gl843_stop_action(Genesys_Device* dev)
|
||||||
DBG_HELPER(dbg);
|
DBG_HELPER(dbg);
|
||||||
unsigned int loop;
|
unsigned int loop;
|
||||||
|
|
||||||
auto status = scanner_read_status(*dev);
|
if (scanner_is_motor_stopped(*dev)) {
|
||||||
|
DBG(DBG_info, "%s: already stopped\n", __func__);
|
||||||
uint8_t val40 = dev->interface->read_register(REG_0x40);
|
return;
|
||||||
|
|
||||||
/* only stop action if needed */
|
|
||||||
if (!(val40 & REG_0x40_DATAENB) && !(val40 & REG_0x40_MOTMFLG) && !status.is_motor_enabled)
|
|
||||||
{
|
|
||||||
DBG(DBG_info, "%s: already stopped\n", __func__);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scanner_stop_action_no_move(*dev, dev->reg);
|
scanner_stop_action_no_move(*dev, dev->reg);
|
||||||
|
@ -1339,13 +1333,7 @@ void gl843_stop_action(Genesys_Device* dev)
|
||||||
|
|
||||||
loop = 10;
|
loop = 10;
|
||||||
while (loop > 0) {
|
while (loop > 0) {
|
||||||
auto status = scanner_read_status(*dev);
|
if (scanner_is_motor_stopped(*dev)) {
|
||||||
val40 = dev->interface->read_register(0x40);
|
|
||||||
|
|
||||||
/* if scanner is in command mode, we are done */
|
|
||||||
if (!(val40 & REG_0x40_DATAENB) && !(val40 & REG_0x40_MOTMFLG)
|
|
||||||
&& !status.is_motor_enabled)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -846,16 +846,10 @@ void gl846_stop_action(Genesys_Device* dev)
|
||||||
unsigned int loop;
|
unsigned int loop;
|
||||||
|
|
||||||
dev->cmd_set->update_home_sensor_gpio(*dev);
|
dev->cmd_set->update_home_sensor_gpio(*dev);
|
||||||
auto status = scanner_read_status(*dev);
|
if (scanner_is_motor_stopped(*dev)) {
|
||||||
|
DBG(DBG_info, "%s: already stopped\n", __func__);
|
||||||
uint8_t val40 = dev->interface->read_register(REG_0x40);
|
return;
|
||||||
|
|
||||||
/* only stop action if needed */
|
|
||||||
if (!(val40 & REG_0x40_DATAENB) && !(val40 & REG_0x40_MOTMFLG) && !status.is_motor_enabled) {
|
|
||||||
DBG(DBG_info, "%s: already stopped\n", __func__);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scanner_stop_action_no_move(*dev, dev->reg);
|
scanner_stop_action_no_move(*dev, dev->reg);
|
||||||
|
|
||||||
if (is_testing_mode()) {
|
if (is_testing_mode()) {
|
||||||
|
@ -864,13 +858,7 @@ void gl846_stop_action(Genesys_Device* dev)
|
||||||
|
|
||||||
loop = 10;
|
loop = 10;
|
||||||
while (loop > 0) {
|
while (loop > 0) {
|
||||||
auto status = scanner_read_status(*dev);
|
if (scanner_is_motor_stopped(*dev)) {
|
||||||
val40 = dev->interface->read_register(REG_0x40);
|
|
||||||
|
|
||||||
/* if scanner is in command mode, we are done */
|
|
||||||
if (!(val40 & REG_0x40_DATAENB) && !(val40 & REG_0x40_MOTMFLG) &&
|
|
||||||
!status.is_motor_enabled)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -850,14 +850,9 @@ void gl847_stop_action(Genesys_Device* dev)
|
||||||
unsigned int loop;
|
unsigned int loop;
|
||||||
|
|
||||||
dev->cmd_set->update_home_sensor_gpio(*dev);
|
dev->cmd_set->update_home_sensor_gpio(*dev);
|
||||||
auto status = scanner_read_status(*dev);
|
if (scanner_is_motor_stopped(*dev)) {
|
||||||
|
DBG(DBG_info, "%s: already stopped\n", __func__);
|
||||||
uint8_t val40 = dev->interface->read_register(REG_0x40);
|
return;
|
||||||
|
|
||||||
/* only stop action if needed */
|
|
||||||
if (!(val40 & REG_0x40_DATAENB) && !(val40 & REG_0x40_MOTMFLG) && !status.is_motor_enabled) {
|
|
||||||
DBG(DBG_info, "%s: already stopped\n", __func__);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scanner_stop_action_no_move(*dev, dev->reg);
|
scanner_stop_action_no_move(*dev, dev->reg);
|
||||||
|
@ -869,14 +864,8 @@ void gl847_stop_action(Genesys_Device* dev)
|
||||||
loop = 10;
|
loop = 10;
|
||||||
while (loop > 0)
|
while (loop > 0)
|
||||||
{
|
{
|
||||||
auto status = scanner_read_status(*dev);
|
if (scanner_is_motor_stopped(*dev)) {
|
||||||
val40 = dev->interface->read_register(REG_0x40);
|
return;
|
||||||
|
|
||||||
/* if scanner is in command mode, we are done */
|
|
||||||
if (!(val40 & REG_0x40_DATAENB) && !(val40 & REG_0x40_MOTMFLG) &&
|
|
||||||
!status.is_motor_enabled)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dev->interface->sleep_ms(100);
|
dev->interface->sleep_ms(100);
|
||||||
|
|
|
@ -413,6 +413,8 @@ void scanner_start_action(Genesys_Device& dev, bool start_motor);
|
||||||
void scanner_stop_action(Genesys_Device& dev);
|
void scanner_stop_action(Genesys_Device& dev);
|
||||||
void scanner_stop_action_no_move(Genesys_Device& dev, Genesys_Register_Set& regs);
|
void scanner_stop_action_no_move(Genesys_Device& dev, Genesys_Register_Set& regs);
|
||||||
|
|
||||||
|
bool scanner_is_motor_stopped(Genesys_Device& dev);
|
||||||
|
|
||||||
const Motor_Profile& sanei_genesys_get_motor_profile(const std::vector<Motor_Profile>& motors,
|
const Motor_Profile& sanei_genesys_get_motor_profile(const std::vector<Motor_Profile>& motors,
|
||||||
MotorId motor_id, int exposure);
|
MotorId motor_id, int exposure);
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue