Merge branch 'genesys-simplify-motor-profile-setup-gl841' into 'master'

genesys: Simplify motor profile setup on gl841

See merge request sane-project/backends!448
merge-requests/463/merge
Povilas Kanapickas 2020-05-16 18:52:33 +00:00
commit c9beb6b0ba
3 zmienionych plików z 75 dodań i 102 usunięć

Wyświetl plik

@ -664,10 +664,9 @@ static void gl841_init_motor_regs_feed(Genesys_Device* dev, const Genesys_Sensor
} }
static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg, Genesys_Register_Set* reg, const MotorProfile& motor_profile,
unsigned int scan_exposure_time,/*pixel*/ unsigned int scan_exposure_time,/*pixel*/
unsigned scan_yres, // dpi, motor resolution unsigned scan_yres, // dpi, motor resolution
StepType scan_step_type,
unsigned int scan_lines,/*lines, scan resolution*/ unsigned int scan_lines,/*lines, scan resolution*/
unsigned int scan_dummy, unsigned int scan_dummy,
// number of scan lines to add in a scan_lines line // number of scan lines to add in a scan_lines line
@ -677,7 +676,7 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor
{ {
DBG_HELPER_ARGS(dbg, "scan_exposure_time=%d, scan_yres=%d, scan_step_type=%d, scan_lines=%d," DBG_HELPER_ARGS(dbg, "scan_exposure_time=%d, scan_yres=%d, scan_step_type=%d, scan_lines=%d,"
" scan_dummy=%d, feed_steps=%d, flags=%x", " scan_dummy=%d, feed_steps=%d, flags=%x",
scan_exposure_time, scan_yres, static_cast<unsigned>(scan_step_type), scan_exposure_time, scan_yres, static_cast<unsigned>(motor_profile.step_type),
scan_lines, scan_dummy, feed_steps, static_cast<unsigned>(flags)); scan_lines, scan_dummy, feed_steps, static_cast<unsigned>(flags));
unsigned int fast_exposure; unsigned int fast_exposure;
int use_fast_fed = 0; int use_fast_fed = 0;
@ -685,7 +684,6 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor
unsigned int slow_time; unsigned int slow_time;
unsigned int feedl; unsigned int feedl;
unsigned int min_restep = 0x20; unsigned int min_restep = 0x20;
uint32_t z1, z2;
fast_exposure = gl841_exposure_time(dev, sensor, fast_exposure = gl841_exposure_time(dev, sensor,
dev->motor.base_ydpi / 4, dev->motor.base_ydpi / 4,
@ -717,15 +715,15 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor
*/ */
auto slow_table = sanei_genesys_create_slope_table3(dev->model->asic_type, dev->motor, auto slow_table = sanei_genesys_create_slope_table3(dev->model->asic_type, dev->motor,
scan_step_type, scan_exposure_time, motor_profile.step_type,
scan_yres); scan_exposure_time, scan_yres);
auto back_table = sanei_genesys_create_slope_table3(dev->model->asic_type, dev->motor, auto back_table = sanei_genesys_create_slope_table3(dev->model->asic_type, dev->motor,
scan_step_type, 0, scan_yres); motor_profile.step_type, 0, scan_yres);
if (feed_steps < (slow_table.steps_count >> static_cast<unsigned>(scan_step_type))) { if (feed_steps < (slow_table.steps_count >> static_cast<unsigned>(motor_profile.step_type))) {
/*TODO: what should we do here?? go back to exposure calculation?*/ /*TODO: what should we do here?? go back to exposure calculation?*/
feed_steps = slow_table.steps_count >> static_cast<unsigned>(scan_step_type); feed_steps = slow_table.steps_count >> static_cast<unsigned>(motor_profile.step_type);
} }
auto fast_table = sanei_genesys_create_slope_table3(dev->model->asic_type, dev->motor, auto fast_table = sanei_genesys_create_slope_table3(dev->model->asic_type, dev->motor,
@ -733,9 +731,9 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor
dev->motor.base_ydpi / 4); dev->motor.base_ydpi / 4);
unsigned max_fast_slope_steps_count = 1; unsigned max_fast_slope_steps_count = 1;
if (feed_steps > (slow_table.steps_count >> static_cast<unsigned>(scan_step_type)) + 2) { if (feed_steps > (slow_table.steps_count >> static_cast<unsigned>(motor_profile.step_type)) + 2) {
max_fast_slope_steps_count = (feed_steps - max_fast_slope_steps_count = (feed_steps -
(slow_table.steps_count >> static_cast<unsigned>(scan_step_type))) / 2; (slow_table.steps_count >> static_cast<unsigned>(motor_profile.step_type))) / 2;
} }
if (fast_table.steps_count > max_fast_slope_steps_count) { if (fast_table.steps_count > max_fast_slope_steps_count) {
@ -751,7 +749,7 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor
use_fast_fed = 0; use_fast_fed = 0;
} }
else if (feed_steps < fast_table.steps_count * 2 + else if (feed_steps < fast_table.steps_count * 2 +
(slow_table.steps_count >> static_cast<unsigned>(scan_step_type))) (slow_table.steps_count >> static_cast<unsigned>(motor_profile.step_type)))
{ {
use_fast_fed = 0; use_fast_fed = 0;
DBG(DBG_info, "%s: feed too short, slow move forced.\n", __func__); DBG(DBG_info, "%s: feed too short, slow move forced.\n", __func__);
@ -767,11 +765,11 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor
fast_time = fast_time =
fast_exposure / 4 * fast_exposure / 4 *
(feed_steps - fast_table.steps_count*2 - (feed_steps - fast_table.steps_count*2 -
(slow_table.steps_count >> static_cast<unsigned>(scan_step_type))) (slow_table.steps_count >> static_cast<unsigned>(motor_profile.step_type)))
+ fast_table.pixeltime_sum*2 + slow_table.pixeltime_sum; + fast_table.pixeltime_sum*2 + slow_table.pixeltime_sum;
slow_time = slow_time =
(scan_exposure_time * scan_yres) / dev->motor.base_ydpi * (scan_exposure_time * scan_yres) / dev->motor.base_ydpi *
(feed_steps - (slow_table.steps_count >> static_cast<unsigned>(scan_step_type))) (feed_steps - (slow_table.steps_count >> static_cast<unsigned>(motor_profile.step_type)))
+ slow_table.pixeltime_sum; + slow_table.pixeltime_sum;
DBG(DBG_info, "%s: Time for slow move: %d\n", __func__, slow_time); DBG(DBG_info, "%s: Time for slow move: %d\n", __func__, slow_time);
@ -782,11 +780,11 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor
if (use_fast_fed) { if (use_fast_fed) {
feedl = feed_steps - fast_table.steps_count * 2 - feedl = feed_steps - fast_table.steps_count * 2 -
(slow_table.steps_count >> static_cast<unsigned>(scan_step_type)); (slow_table.steps_count >> static_cast<unsigned>(motor_profile.step_type));
} else if ((feed_steps << static_cast<unsigned>(scan_step_type)) < slow_table.steps_count) { } else if ((feed_steps << static_cast<unsigned>(motor_profile.step_type)) < slow_table.steps_count) {
feedl = 0; feedl = 0;
} else { } else {
feedl = (feed_steps << static_cast<unsigned>(scan_step_type)) - slow_table.steps_count; feedl = (feed_steps << static_cast<unsigned>(motor_profile.step_type)) - slow_table.steps_count;
} }
DBG(DBG_info, "%s: Decided to use %s mode\n", __func__, use_fast_fed?"fast feed":"slow feed"); DBG(DBG_info, "%s: Decided to use %s mode\n", __func__, use_fast_fed?"fast feed":"slow feed");
@ -867,19 +865,11 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor
z1 = (slope_0_time-1) % exposure_time; z1 = (slope_0_time-1) % exposure_time;
z2 = (slope_0_time-1) % exposure_time; z2 = (slope_0_time-1) % exposure_time;
*/ */
z1 = z2 = 0; reg->set24(REG_0x60, 0);
reg->set24(REG_0x63, 0);
DBG(DBG_info, "%s: z1 = %d\n", __func__, z1);
DBG(DBG_info, "%s: z2 = %d\n", __func__, z2);
reg->set8(0x60, ((z1 >> 16) & 0xff));
reg->set8(0x61, ((z1 >> 8) & 0xff));
reg->set8(0x62, (z1 & 0xff));
reg->set8(0x63, ((z2 >> 16) & 0xff));
reg->set8(0x64, ((z2 >> 8) & 0xff));
reg->set8(0x65, (z2 & 0xff));
reg->find_reg(REG_0x1E).value &= REG_0x1E_WDTIME; reg->find_reg(REG_0x1E).value &= REG_0x1E_WDTIME;
reg->find_reg(REG_0x1E).value |= scan_dummy; reg->find_reg(REG_0x1E).value |= scan_dummy;
reg->set8(0x67, 0x3f | (static_cast<unsigned>(scan_step_type) << 6)); reg->set8(0x67, 0x3f | (static_cast<unsigned>(motor_profile.step_type) << 6));
reg->set8(0x68, 0x3f); reg->set8(0x68, 0x3f);
reg->set8(REG_STEPNO, (slow_table.steps_count >> 1) + (slow_table.steps_count & 1)); reg->set8(REG_STEPNO, (slow_table.steps_count >> 1) + (slow_table.steps_count & 1));
reg->set8(REG_FASTNO, (back_table.steps_count >> 1) + (back_table.steps_count & 1)); reg->set8(REG_FASTNO, (back_table.steps_count >> 1) + (back_table.steps_count & 1));
@ -1065,37 +1055,6 @@ int led_exposure;
return exposure_time; return exposure_time;
} }
/**@brief compute scan_step_type
* Try to do at least 4 steps per line. if that is impossible we will have to
* live with that.
* @param dev device
* @param yres motor resolution
*/
static StepType gl841_scan_step_type(Genesys_Device *dev, int yres)
{
StepType type = StepType::FULL;
/* TODO : check if there is a bug around the use of max_step_type */
/* should be <=1, need to chek all devices entry in genesys_devices */
if (yres * 4 < dev->motor.base_ydpi || dev->motor.max_step_type() == StepType::FULL) {
type = StepType::FULL;
} else if (yres * 4 < dev->motor.base_ydpi * 2 ||
dev->motor.max_step_type() <= StepType::HALF)
{
type = StepType::HALF;
} else {
type = StepType::QUARTER;
}
/* this motor behaves differently */
if (dev->model->motor_id==MotorId::CANON_LIDE_80) {
// driven by 'frequency' tables ?
type = StepType::FULL;
}
return type;
}
void CommandSetGl841::init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor, void CommandSetGl841::init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg, Genesys_Register_Set* reg,
const ScanSession& session) const const ScanSession& session) const
@ -1109,34 +1068,6 @@ void CommandSetGl841::init_regs_for_scan_session(Genesys_Device* dev, const Gene
int slope_dpi = 0; int slope_dpi = 0;
int dummy = 0; int dummy = 0;
/*
results:
for scanner:
start
end
dpiset
exposure_time
dummy
z1
z2
for ordered_read:
dev->words_per_line
dev->read_factor
dev->requested_buffer_size
dev->read_buffer_size
dev->read_pos
dev->read_bytes_in_buffer
dev->read_bytes_left
dev->max_shift
dev->stagger
independent of our calculated values:
dev->total_bytes_read
dev->bytes_to_read
*/
/* dummy */ /* dummy */
/* dummy lines: may not be usefull, for instance 250 dpi works with 0 or 1 /* dummy lines: may not be usefull, for instance 250 dpi works with 0 or 1
dummy line. Maybe the dummy line adds correctness since the motor runs dummy line. Maybe the dummy line adds correctness since the motor runs
@ -1175,10 +1106,11 @@ dummy \ scanned lines
slope_dpi = slope_dpi * (1 + dummy); slope_dpi = slope_dpi * (1 + dummy);
StepType scan_step_type = gl841_scan_step_type(dev, session.params.yres); const auto& motor_profile = get_motor_profile(dev->motor.profiles, 0, session);
exposure_time = gl841_exposure_time(dev, sensor, exposure_time = gl841_exposure_time(dev, sensor,
slope_dpi, slope_dpi,
scan_step_type, motor_profile.step_type,
session.pixel_startx, session.pixel_startx,
session.optical_pixels); session.optical_pixels);
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time); DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
@ -1203,7 +1135,7 @@ dummy \ scanned lines
if (has_flag(session.params.flags, ScanFlag::SINGLE_LINE)) { if (has_flag(session.params.flags, ScanFlag::SINGLE_LINE)) {
gl841_init_motor_regs_off(reg, session.optical_line_count); gl841_init_motor_regs_off(reg, session.optical_line_count);
} else { } else {
gl841_init_motor_regs_scan(dev, sensor, reg, exposure_time, slope_dpi, scan_step_type, gl841_init_motor_regs_scan(dev, sensor, reg, motor_profile, exposure_time, slope_dpi,
session.optical_line_count, dummy, move, session.params.flags); session.optical_line_count, dummy, move, session.params.flags);
} }

Wyświetl plik

@ -224,10 +224,12 @@ static constexpr RegShift REG_0x5ES_DECSEL = 5;
static constexpr RegMask REG_0x5E_STOPTIM = 0x1f; static constexpr RegMask REG_0x5E_STOPTIM = 0x1f;
static constexpr RegShift REG_0x5ES_STOPTIM = 0; static constexpr RegShift REG_0x5ES_STOPTIM = 0;
static constexpr RegAddr REG_0x60 = 0x60;
static constexpr RegMask REG_0x60_ZIMOD = 0x1f; static constexpr RegMask REG_0x60_ZIMOD = 0x1f;
static constexpr RegMask REG_0x61_Z1MOD = 0xff; static constexpr RegMask REG_0x61_Z1MOD = 0xff;
static constexpr RegMask REG_0x62_Z1MOD = 0xff; static constexpr RegMask REG_0x62_Z1MOD = 0xff;
static constexpr RegAddr REG_0x63 = 0x63;
static constexpr RegMask REG_0x63_Z2MOD = 0x1f; static constexpr RegMask REG_0x63_Z2MOD = 0x1f;
static constexpr RegMask REG_0x64_Z2MOD = 0xff; static constexpr RegMask REG_0x64_Z2MOD = 0xff;
static constexpr RegMask REG_0x65_Z2MOD = 0xff; static constexpr RegMask REG_0x65_Z2MOD = 0xff;

Wyświetl plik

@ -106,8 +106,14 @@ void genesys_init_motor_tables()
motor = Genesys_Motor(); motor = Genesys_Motor();
motor.id = MotorId::CANON_LIDE_35; motor.id = MotorId::CANON_LIDE_35;
motor.base_ydpi = 1200; motor.base_ydpi = 1200;
motor.profiles.push_back({MotorSlope::create_from_steps(3500, 1300, 60), StepType::FULL, 0});
motor.profiles.push_back({MotorSlope::create_from_steps(3500, 1400, 60), StepType::HALF, 0}); profile = MotorProfile{MotorSlope::create_from_steps(3500, 1300, 60), StepType::FULL, 0};
profile.resolutions = {75, 100, 150, 200};
motor.profiles.push_back(profile);
profile = MotorProfile{MotorSlope::create_from_steps(3500, 1400, 60), StepType::HALF, 0};
profile.resolutions = {300, 600, 1200, 2400};
motor.profiles.push_back(profile);
s_motors->push_back(std::move(motor)); s_motors->push_back(std::move(motor));
@ -123,32 +129,58 @@ void genesys_init_motor_tables()
motor.id = MotorId::XP300; motor.id = MotorId::XP300;
motor.base_ydpi = 300; motor.base_ydpi = 300;
// works best with GPIO10, GPIO14 off // works best with GPIO10, GPIO14 off
motor.profiles.push_back({MotorSlope::create_from_steps(3700, 3700, 2), StepType::FULL, 0}); profile = MotorProfile{MotorSlope::create_from_steps(3700, 3700, 2), StepType::FULL, 0};
motor.profiles.push_back({MotorSlope::create_from_steps(11000, 11000, 2), StepType::HALF, 0}); profile.resolutions = {}; // used during fast moves
motor.profiles.push_back(profile);
// FIXME: this motor profile is useless
profile = MotorProfile{MotorSlope::create_from_steps(11000, 11000, 2), StepType::HALF, 0};
profile.resolutions = {75, 150, 300, 600};
motor.profiles.push_back(profile);
s_motors->push_back(std::move(motor)); s_motors->push_back(std::move(motor));
motor = Genesys_Motor(); motor = Genesys_Motor();
motor.id = MotorId::DP665; motor.id = MotorId::DP665;
motor.base_ydpi = 750; motor.base_ydpi = 750;
motor.profiles.push_back({MotorSlope::create_from_steps(3000, 2500, 10), StepType::FULL, 0});
motor.profiles.push_back({MotorSlope::create_from_steps(11000, 11000, 2), StepType::HALF, 0}); profile = MotorProfile{MotorSlope::create_from_steps(3000, 2500, 10), StepType::FULL, 0};
profile.resolutions = {75, 150};
motor.profiles.push_back(profile);
// FIXME: this motor profile is useless
profile = MotorProfile{MotorSlope::create_from_steps(11000, 11000, 2), StepType::HALF, 0};
profile.resolutions = {300, 600, 1200};
motor.profiles.push_back(profile);
s_motors->push_back(std::move(motor)); s_motors->push_back(std::move(motor));
motor = Genesys_Motor(); motor = Genesys_Motor();
motor.id = MotorId::ROADWARRIOR; motor.id = MotorId::ROADWARRIOR;
motor.base_ydpi = 750; motor.base_ydpi = 750;
motor.profiles.push_back({MotorSlope::create_from_steps(3000, 2600, 10), StepType::FULL, 0});
motor.profiles.push_back({MotorSlope::create_from_steps(11000, 11000, 2), StepType::HALF, 0}); profile = MotorProfile{MotorSlope::create_from_steps(3000, 2600, 10), StepType::FULL, 0};
profile.resolutions = {75, 150};
motor.profiles.push_back(profile);
// FIXME: this motor profile is useless
profile = MotorProfile{MotorSlope::create_from_steps(11000, 11000, 2), StepType::HALF, 0};
profile.resolutions = {300, 600, 1200};
motor.profiles.push_back(profile);
s_motors->push_back(std::move(motor)); s_motors->push_back(std::move(motor));
motor = Genesys_Motor(); motor = Genesys_Motor();
motor.id = MotorId::DSMOBILE_600; motor.id = MotorId::DSMOBILE_600;
motor.base_ydpi = 750; motor.base_ydpi = 750;
motor.profiles.push_back({MotorSlope::create_from_steps(6666, 3700, 8), StepType::FULL, 0});
motor.profiles.push_back({MotorSlope::create_from_steps(6666, 3700, 8), StepType::HALF, 0}); profile = MotorProfile{MotorSlope::create_from_steps(6666, 3700, 8), StepType::FULL, 0};
profile.resolutions = {75, 150};
motor.profiles.push_back(profile);
profile = MotorProfile{MotorSlope::create_from_steps(6666, 3700, 8), StepType::HALF, 0};
profile.resolutions = {300, 600, 1200};
motor.profiles.push_back(profile);
s_motors->push_back(std::move(motor)); s_motors->push_back(std::move(motor));
@ -385,8 +417,15 @@ void genesys_init_motor_tables()
motor = Genesys_Motor(); motor = Genesys_Motor();
motor.id = MotorId::PLUSTEK_OPTICPRO_3600; motor.id = MotorId::PLUSTEK_OPTICPRO_3600;
motor.base_ydpi = 1200; motor.base_ydpi = 1200;
motor.profiles.push_back({MotorSlope::create_from_steps(3500, 1300, 60), StepType::FULL, 0});
motor.profiles.push_back({MotorSlope::create_from_steps(3500, 3250, 60), StepType::HALF, 0}); profile = MotorProfile{MotorSlope::create_from_steps(3500, 1300, 60), StepType::FULL, 0};
profile.resolutions = {75, 100, 150, 200};
motor.profiles.push_back(profile);
// FIXME: this motor profile is almost useless
profile = MotorProfile{MotorSlope::create_from_steps(3500, 3250, 60), StepType::HALF, 0};
profile.resolutions = {300, 400, 600, 1200};
motor.profiles.push_back(profile);
s_motors->push_back(std::move(motor)); s_motors->push_back(std::move(motor));