kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Make the size of slope tables configurable by asic type
rodzic
c685ac075b
commit
dec9962773
|
|
@ -567,7 +567,7 @@ static void gl124_init_motor_regs_scan(Genesys_Device* dev,
|
|||
reg->set16(REG_SCANFED, 4);
|
||||
|
||||
/* scan and backtracking slope table */
|
||||
auto scan_table = sanei_genesys_slope_table(yres, scan_exposure_time,
|
||||
auto scan_table = sanei_genesys_slope_table(dev->model->asic_type, yres, scan_exposure_time,
|
||||
dev->motor.base_ydpi, factor, motor_profile);
|
||||
gl124_send_slope_table(dev, SCAN_TABLE, scan_table.table, scan_table.steps_count);
|
||||
gl124_send_slope_table(dev, BACKTRACK_TABLE, scan_table.table, scan_table.steps_count);
|
||||
|
|
@ -583,7 +583,7 @@ static void gl124_init_motor_regs_scan(Genesys_Device* dev,
|
|||
fast_dpi*=3;
|
||||
}
|
||||
*/
|
||||
auto fast_table = sanei_genesys_slope_table(fast_dpi, scan_exposure_time, dev->motor.base_ydpi,
|
||||
auto fast_table = sanei_genesys_slope_table(dev->model->asic_type, fast_dpi, scan_exposure_time, dev->motor.base_ydpi,
|
||||
factor, motor_profile);
|
||||
gl124_send_slope_table(dev, STOP_TABLE, fast_table.table, fast_table.steps_count);
|
||||
gl124_send_slope_table(dev, FAST_TABLE, fast_table.table, fast_table.steps_count);
|
||||
|
|
|
|||
|
|
@ -869,8 +869,8 @@ static void gl843_init_motor_regs_scan(Genesys_Device* dev,
|
|||
}
|
||||
|
||||
/* scan and backtracking slope table */
|
||||
auto scan_table = sanei_genesys_slope_table(scan_yres, exposure, dev->motor.base_ydpi,
|
||||
factor, motor_profile);
|
||||
auto scan_table = sanei_genesys_slope_table(dev->model->asic_type, scan_yres, exposure,
|
||||
dev->motor.base_ydpi, factor, motor_profile);
|
||||
|
||||
gl843_send_slope_table(dev, SCAN_TABLE, scan_table.table, scan_table.steps_count * factor);
|
||||
gl843_send_slope_table(dev, BACKTRACK_TABLE, scan_table.table, scan_table.steps_count * factor);
|
||||
|
|
@ -897,8 +897,8 @@ static void gl843_init_motor_regs_scan(Genesys_Device* dev,
|
|||
if (dev->model->model_id == ModelId::CANON_4400F) {
|
||||
fast_yres = scan_yres;
|
||||
}
|
||||
auto fast_table = sanei_genesys_slope_table(fast_yres, exposure, dev->motor.base_ydpi,
|
||||
factor, fast_motor_profile);
|
||||
auto fast_table = sanei_genesys_slope_table(dev->model->asic_type, fast_yres, exposure,
|
||||
dev->motor.base_ydpi, factor, fast_motor_profile);
|
||||
gl843_send_slope_table(dev, STOP_TABLE, fast_table.table, fast_table.steps_count * factor);
|
||||
gl843_send_slope_table(dev, FAST_TABLE, fast_table.table, fast_table.steps_count * factor);
|
||||
gl843_send_slope_table(dev, HOME_TABLE, fast_table.table, fast_table.steps_count * factor);
|
||||
|
|
|
|||
|
|
@ -386,7 +386,8 @@ static void gl846_init_motor_regs_scan(Genesys_Device* dev,
|
|||
}
|
||||
|
||||
/* scan and backtracking slope table */
|
||||
auto scan_table = sanei_genesys_slope_table(scan_yres, scan_exposure_time, dev->motor.base_ydpi,
|
||||
auto scan_table = sanei_genesys_slope_table(dev->model->asic_type, scan_yres,
|
||||
scan_exposure_time, dev->motor.base_ydpi,
|
||||
factor, motor_profile);
|
||||
gl846_send_slope_table(dev, SCAN_TABLE, scan_table.table, scan_table.steps_count * factor);
|
||||
gl846_send_slope_table(dev, BACKTRACK_TABLE, scan_table.table, scan_table.steps_count * factor);
|
||||
|
|
@ -403,7 +404,8 @@ static void gl846_init_motor_regs_scan(Genesys_Device* dev,
|
|||
Motor_Profile fast_motor_profile = motor_profile;
|
||||
fast_motor_profile.step_type = fast_step_type;
|
||||
|
||||
auto fast_table = sanei_genesys_slope_table(fast_dpi, scan_exposure_time, dev->motor.base_ydpi,
|
||||
auto fast_table = sanei_genesys_slope_table(dev->model->asic_type, fast_dpi,
|
||||
scan_exposure_time, dev->motor.base_ydpi,
|
||||
factor, fast_motor_profile);
|
||||
|
||||
gl846_send_slope_table(dev, STOP_TABLE, fast_table.table, fast_table.steps_count * factor);
|
||||
|
|
|
|||
|
|
@ -418,7 +418,8 @@ static void gl847_init_motor_regs_scan(Genesys_Device* dev,
|
|||
}
|
||||
|
||||
/* scan and backtracking slope table */
|
||||
auto scan_table = sanei_genesys_slope_table(scan_yres, scan_exposure_time, dev->motor.base_ydpi,
|
||||
auto scan_table = sanei_genesys_slope_table(dev->model->asic_type, scan_yres,
|
||||
scan_exposure_time, dev->motor.base_ydpi,
|
||||
factor, motor_profile);
|
||||
gl847_send_slope_table(dev, SCAN_TABLE, scan_table.table, scan_table.steps_count * factor);
|
||||
gl847_send_slope_table(dev, BACKTRACK_TABLE, scan_table.table, scan_table.steps_count * factor);
|
||||
|
|
@ -433,7 +434,8 @@ static void gl847_init_motor_regs_scan(Genesys_Device* dev,
|
|||
Motor_Profile fast_motor_profile = motor_profile;
|
||||
fast_motor_profile.step_type = fast_step_type;
|
||||
|
||||
auto fast_table = sanei_genesys_slope_table(fast_dpi, scan_exposure_time, dev->motor.base_ydpi,
|
||||
auto fast_table = sanei_genesys_slope_table(dev->model->asic_type, fast_dpi,
|
||||
scan_exposure_time, dev->motor.base_ydpi,
|
||||
factor, fast_motor_profile);
|
||||
|
||||
gl847_send_slope_table(dev, STOP_TABLE, fast_table.table, fast_table.steps_count * factor);
|
||||
|
|
|
|||
|
|
@ -1759,13 +1759,14 @@ const Motor_Profile& sanei_genesys_get_motor_profile(const std::vector<Motor_Pro
|
|||
return motors[idx];
|
||||
}
|
||||
|
||||
MotorSlopeTable sanei_genesys_slope_table(int dpi, int exposure, int base_dpi,
|
||||
MotorSlopeTable sanei_genesys_slope_table(AsicType asic_type, int dpi, int exposure, int base_dpi,
|
||||
int factor, const Motor_Profile& motor_profile)
|
||||
{
|
||||
unsigned target_speed_w = ((exposure * dpi) / base_dpi);
|
||||
|
||||
auto table = create_slope_table(motor_profile.slope, target_speed_w, motor_profile.step_type,
|
||||
factor, 2 * factor);
|
||||
factor, 2 * factor,
|
||||
get_slope_table_max_size(asic_type));
|
||||
table.steps_count /= factor;
|
||||
table.final_exposure = (table.final_exposure * base_dpi) / dpi;
|
||||
return table;
|
||||
|
|
|
|||
|
|
@ -231,8 +231,6 @@ extern StaticInit<std::vector<Motor_Profile>> gl846_motor_profiles;
|
|||
extern StaticInit<std::vector<Motor_Profile>> gl847_motor_profiles;
|
||||
extern StaticInit<std::vector<Motor_Profile>> gl124_motor_profiles;
|
||||
|
||||
constexpr unsigned SLOPE_TABLE_SIZE = 1024;
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* common functions needed by low level specific functions */
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
|
@ -417,7 +415,7 @@ bool scanner_is_motor_stopped(Genesys_Device& dev);
|
|||
const Motor_Profile& sanei_genesys_get_motor_profile(const std::vector<Motor_Profile>& motors,
|
||||
MotorId motor_id, int exposure);
|
||||
|
||||
MotorSlopeTable sanei_genesys_slope_table(int dpi, int exposure, int base_dpi,
|
||||
MotorSlopeTable sanei_genesys_slope_table(AsicType asic_type, int dpi, int exposure, int base_dpi,
|
||||
int factor, const Motor_Profile& motor_profile);
|
||||
|
||||
/** @brief find lowest motor resolution for the device.
|
||||
|
|
|
|||
|
|
@ -80,9 +80,24 @@ MotorSlope MotorSlope::create_from_steps(unsigned initial_w, unsigned max_w,
|
|||
return slope;
|
||||
}
|
||||
|
||||
unsigned get_slope_table_max_size(AsicType asic_type)
|
||||
{
|
||||
switch (asic_type) {
|
||||
case AsicType::GL646:
|
||||
case AsicType::GL841: return 255;
|
||||
case AsicType::GL843:
|
||||
case AsicType::GL845:
|
||||
case AsicType::GL846:
|
||||
case AsicType::GL847:
|
||||
case AsicType::GL124: return 1024;
|
||||
default:
|
||||
throw SaneException("Unknown asic type");
|
||||
}
|
||||
}
|
||||
|
||||
MotorSlopeTable create_slope_table(const MotorSlope& slope, unsigned target_speed_w,
|
||||
StepType step_type, unsigned steps_alignment,
|
||||
unsigned min_size)
|
||||
unsigned min_size, unsigned max_size)
|
||||
{
|
||||
DBG_HELPER_ARGS(dbg, "target_speed_w: %d, step_type: %d, steps_alignment: %d, min_size: %d",
|
||||
target_speed_w, static_cast<unsigned>(step_type), steps_alignment, min_size);
|
||||
|
|
@ -99,9 +114,9 @@ MotorSlopeTable create_slope_table(const MotorSlope& slope, unsigned target_spee
|
|||
|
||||
unsigned final_speed = std::max(target_speed_shifted_w, max_speed_shifted_w);
|
||||
|
||||
table.table.reserve(MotorSlopeTable::SLOPE_TABLE_SIZE);
|
||||
table.table.reserve(max_size);
|
||||
|
||||
while (true) {
|
||||
while (table.table.size() < max_size - 1) {
|
||||
unsigned current = slope.get_table_step_shifted(table.table.size(), step_type);
|
||||
if (current <= final_speed) {
|
||||
break;
|
||||
|
|
@ -116,7 +131,9 @@ MotorSlopeTable create_slope_table(const MotorSlope& slope, unsigned target_spee
|
|||
table.pixeltime_sum += table.table.back();
|
||||
|
||||
// fill the table up to the specified size
|
||||
while (table.table.size() % steps_alignment != 0 || table.table.size() < min_size) {
|
||||
while (table.table.size() < max_size - 1 &&
|
||||
(table.table.size() % steps_alignment != 0 || table.table.size() < min_size))
|
||||
{
|
||||
table.table.push_back(table.table.back());
|
||||
table.pixeltime_sum += table.table.back();
|
||||
}
|
||||
|
|
@ -124,7 +141,7 @@ MotorSlopeTable create_slope_table(const MotorSlope& slope, unsigned target_spee
|
|||
table.steps_count = table.table.size();
|
||||
|
||||
// fill the rest of the table with the final speed
|
||||
table.table.resize(MotorSlopeTable::SLOPE_TABLE_SIZE, final_speed);
|
||||
table.table.resize(max_size, final_speed);
|
||||
|
||||
table.final_exposure = final_speed;
|
||||
|
||||
|
|
|
|||
|
|
@ -135,6 +135,9 @@ struct MotorSlope
|
|||
// max speed in pixeltime per step
|
||||
unsigned max_speed_w = 0;
|
||||
|
||||
// maximum number of steps in the table
|
||||
unsigned max_step_count;
|
||||
|
||||
// acceleration in steps per pixeltime squared.
|
||||
float acceleration = 0;
|
||||
|
||||
|
|
@ -146,8 +149,6 @@ struct MotorSlope
|
|||
|
||||
struct MotorSlopeTable
|
||||
{
|
||||
constexpr static unsigned SLOPE_TABLE_SIZE = 1024;
|
||||
|
||||
std::vector<std::uint16_t> table;
|
||||
unsigned steps_count = 0;
|
||||
unsigned pixeltime_sum = 0;
|
||||
|
|
@ -156,9 +157,11 @@ struct MotorSlopeTable
|
|||
unsigned final_exposure = 0;
|
||||
};
|
||||
|
||||
unsigned get_slope_table_max_size(AsicType asic_type);
|
||||
|
||||
MotorSlopeTable create_slope_table(const MotorSlope& slope, unsigned target_speed_w,
|
||||
StepType step_type, unsigned steps_alignment,
|
||||
unsigned min_size);
|
||||
unsigned min_size, unsigned max_size);
|
||||
|
||||
class Genesys_Motor_Slope
|
||||
{
|
||||
|
|
|
|||
|
|
@ -147,29 +147,31 @@ void test_create_slope_table3()
|
|||
|
||||
void test_create_slope_table_small_full_step()
|
||||
{
|
||||
unsigned max_table_size = 1024;
|
||||
|
||||
// created approximately from LIDE 110 slow table: { 62464, 7896, 2632, 0 }
|
||||
MotorSlope slope;
|
||||
slope.initial_speed_w = 62464;
|
||||
slope.max_speed_w = 2632;
|
||||
slope.acceleration = 1.2e-8;
|
||||
|
||||
auto table = create_slope_table(slope, 5000, StepType::FULL, 4, 8);
|
||||
auto table = create_slope_table(slope, 5000, StepType::FULL, 4, 8, max_table_size);
|
||||
|
||||
std::vector<std::uint16_t> expected_table = {
|
||||
62464, 62464, 6420, 5000
|
||||
};
|
||||
expected_table.resize(table.SLOPE_TABLE_SIZE, 5000);
|
||||
expected_table.resize(max_table_size, 5000);
|
||||
ASSERT_EQ(table.table, expected_table);
|
||||
ASSERT_EQ(table.steps_count, 8u);
|
||||
ASSERT_EQ(table.pixeltime_sum, 156348u);
|
||||
|
||||
|
||||
table = create_slope_table(slope, 3000, StepType::FULL, 4, 8);
|
||||
table = create_slope_table(slope, 3000, StepType::FULL, 4, 8, max_table_size);
|
||||
|
||||
expected_table = {
|
||||
62464, 62464, 6420, 4552, 3720, 3223, 3000
|
||||
};
|
||||
expected_table.resize(table.SLOPE_TABLE_SIZE, 3000);
|
||||
expected_table.resize(max_table_size, 3000);
|
||||
ASSERT_EQ(table.table, expected_table);
|
||||
ASSERT_EQ(table.steps_count, 8u);
|
||||
ASSERT_EQ(table.pixeltime_sum, 148843u);
|
||||
|
|
@ -177,18 +179,20 @@ void test_create_slope_table_small_full_step()
|
|||
|
||||
void test_create_slope_table_small_full_step_target_speed_too_high()
|
||||
{
|
||||
unsigned max_table_size = 1024;
|
||||
|
||||
// created approximately from LIDE 110 slow table: { 62464, 7896, 2632, 0 }
|
||||
MotorSlope slope;
|
||||
slope.initial_speed_w = 62464;
|
||||
slope.max_speed_w = 2632;
|
||||
slope.acceleration = 1.2e-8;
|
||||
|
||||
auto table = create_slope_table(slope, 2000, StepType::FULL, 4, 8);
|
||||
auto table = create_slope_table(slope, 2000, StepType::FULL, 4, 8, max_table_size);
|
||||
|
||||
std::vector<std::uint16_t> expected_table = {
|
||||
62464, 62464, 6420, 4552, 3720, 3223, 2883, 2632
|
||||
};
|
||||
expected_table.resize(table.SLOPE_TABLE_SIZE, 2632);
|
||||
expected_table.resize(max_table_size, 2632);
|
||||
ASSERT_EQ(table.table, expected_table);
|
||||
ASSERT_EQ(table.steps_count, 8u);
|
||||
ASSERT_EQ(table.pixeltime_sum, 148358u);
|
||||
|
|
@ -196,29 +200,31 @@ void test_create_slope_table_small_full_step_target_speed_too_high()
|
|||
|
||||
void test_create_slope_table_small_half_step()
|
||||
{
|
||||
unsigned max_table_size = 1024;
|
||||
|
||||
// created approximately from LIDE 110 slow table: { 62464, 7896, 2632, 0 }
|
||||
MotorSlope slope;
|
||||
slope.initial_speed_w = 62464;
|
||||
slope.max_speed_w = 2632;
|
||||
slope.acceleration = 1.2e-8;
|
||||
|
||||
auto table = create_slope_table(slope, 5000, StepType::HALF, 4, 8);
|
||||
auto table = create_slope_table(slope, 5000, StepType::HALF, 4, 8, max_table_size);
|
||||
|
||||
std::vector<std::uint16_t> expected_table = {
|
||||
31232, 31232, 3210, 2500
|
||||
};
|
||||
expected_table.resize(table.SLOPE_TABLE_SIZE, 2500);
|
||||
expected_table.resize(max_table_size, 2500);
|
||||
ASSERT_EQ(table.table, expected_table);
|
||||
ASSERT_EQ(table.steps_count, 8u);
|
||||
ASSERT_EQ(table.pixeltime_sum, 78174u);
|
||||
|
||||
|
||||
table = create_slope_table(slope, 3000, StepType::HALF, 4, 8);
|
||||
table = create_slope_table(slope, 3000, StepType::HALF, 4, 8, max_table_size);
|
||||
|
||||
expected_table = {
|
||||
31232, 31232, 3210, 2276, 1860, 1611, 1500
|
||||
};
|
||||
expected_table.resize(table.SLOPE_TABLE_SIZE, 1500);
|
||||
expected_table.resize(max_table_size, 1500);
|
||||
ASSERT_EQ(table.table, expected_table);
|
||||
ASSERT_EQ(table.steps_count, 8u);
|
||||
ASSERT_EQ(table.pixeltime_sum, 74421u);
|
||||
|
|
@ -226,6 +232,8 @@ void test_create_slope_table_small_half_step()
|
|||
|
||||
void test_create_slope_table_large_full_step()
|
||||
{
|
||||
unsigned max_table_size = 1024;
|
||||
|
||||
/* created approximately from Canon 8600F table:
|
||||
54612, 54612, 34604, 26280, 21708, 18688, 16564, 14936, 13652, 12616,
|
||||
11768, 11024, 10400, 9872, 9392, 8960, 8584, 8240, 7940, 7648,
|
||||
|
|
@ -255,7 +263,7 @@ void test_create_slope_table_large_full_step()
|
|||
slope.max_speed_w = 1500;
|
||||
slope.acceleration = 1.013948e-9;
|
||||
|
||||
auto table = create_slope_table(slope, 3000, StepType::FULL, 4, 8);
|
||||
auto table = create_slope_table(slope, 3000, StepType::FULL, 4, 8, max_table_size);
|
||||
|
||||
std::vector<std::uint16_t> expected_table = {
|
||||
54612, 54612, 20570, 15090, 12481, 10880, 9770, 8943, 8295, 7771,
|
||||
|
|
@ -265,13 +273,13 @@ void test_create_slope_table_large_full_step()
|
|||
3548, 3503, 3461, 3419, 3379, 3341, 3304, 3268, 3233, 3199,
|
||||
3166, 3135, 3104, 3074, 3045, 3017, 3000,
|
||||
};
|
||||
expected_table.resize(table.SLOPE_TABLE_SIZE, 3000);
|
||||
expected_table.resize(max_table_size, 3000);
|
||||
ASSERT_EQ(table.table, expected_table);
|
||||
ASSERT_EQ(table.steps_count, 60u);
|
||||
ASSERT_EQ(table.pixeltime_sum, 412616u);
|
||||
|
||||
|
||||
table = create_slope_table(slope, 1500, StepType::FULL, 4, 8);
|
||||
table = create_slope_table(slope, 1500, StepType::FULL, 4, 8, max_table_size);
|
||||
|
||||
expected_table = {
|
||||
54612, 54612, 20570, 15090, 12481, 10880, 9770, 8943, 8295, 7771,
|
||||
|
|
@ -298,7 +306,7 @@ void test_create_slope_table_large_full_step()
|
|||
1535, 1531, 1528, 1524, 1520, 1517, 1513, 1510, 1506, 1503,
|
||||
1500,
|
||||
};
|
||||
expected_table.resize(table.SLOPE_TABLE_SIZE, 1500);
|
||||
expected_table.resize(max_table_size, 1500);
|
||||
ASSERT_EQ(table.table, expected_table);
|
||||
ASSERT_EQ(table.steps_count, 224u);
|
||||
ASSERT_EQ(table.pixeltime_sum, 734910u);
|
||||
|
|
@ -306,6 +314,8 @@ void test_create_slope_table_large_full_step()
|
|||
|
||||
void test_create_slope_table_large_half_step()
|
||||
{
|
||||
unsigned max_table_size = 1024;
|
||||
|
||||
// created approximately from Canon 8600F table, see the full step test for the data
|
||||
|
||||
MotorSlope slope;
|
||||
|
|
@ -313,7 +323,7 @@ void test_create_slope_table_large_half_step()
|
|||
slope.max_speed_w = 1500;
|
||||
slope.acceleration = 1.013948e-9;
|
||||
|
||||
auto table = create_slope_table(slope, 3000, StepType::HALF, 4, 8);
|
||||
auto table = create_slope_table(slope, 3000, StepType::HALF, 4, 8, max_table_size);
|
||||
|
||||
std::vector<std::uint16_t> expected_table = {
|
||||
27306, 27306, 10285, 7545, 6240, 5440, 4885, 4471, 4147, 3885,
|
||||
|
|
@ -323,13 +333,13 @@ void test_create_slope_table_large_half_step()
|
|||
1774, 1751, 1730, 1709, 1689, 1670, 1652, 1634, 1616, 1599,
|
||||
1583, 1567, 1552, 1537, 1522, 1508, 1500,
|
||||
};
|
||||
expected_table.resize(table.SLOPE_TABLE_SIZE, 1500);
|
||||
expected_table.resize(max_table_size, 1500);
|
||||
ASSERT_EQ(table.table, expected_table);
|
||||
ASSERT_EQ(table.steps_count, 60u);
|
||||
ASSERT_EQ(table.pixeltime_sum, 206294u);
|
||||
|
||||
|
||||
table = create_slope_table(slope, 1500, StepType::HALF, 4, 8);
|
||||
table = create_slope_table(slope, 1500, StepType::HALF, 4, 8, max_table_size);
|
||||
|
||||
expected_table = {
|
||||
27306, 27306, 10285, 7545, 6240, 5440, 4885, 4471, 4147, 3885,
|
||||
|
|
@ -356,7 +366,7 @@ void test_create_slope_table_large_half_step()
|
|||
767, 765, 764, 762, 760, 758, 756, 755, 753, 751,
|
||||
750,
|
||||
};
|
||||
expected_table.resize(table.SLOPE_TABLE_SIZE, 750);
|
||||
expected_table.resize(max_table_size, 750);
|
||||
ASSERT_EQ(table.table, expected_table);
|
||||
ASSERT_EQ(table.steps_count, 224u);
|
||||
ASSERT_EQ(table.pixeltime_sum, 367399u);
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue