genesys: Deduplicate init_regs_for_scan()

merge-requests/244/head
Povilas Kanapickas 2020-05-26 01:32:40 +03:00
rodzic 66ba92cfb6
commit 57a398888d
16 zmienionych plików z 32 dodań i 146 usunięć

Wyświetl plik

@ -71,8 +71,6 @@ public:
virtual void init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const = 0;
virtual void init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const = 0;
/** Set up registers for a scan. Similar to init_regs_for_scan except that the session is
already computed from the session

Wyświetl plik

@ -3995,6 +3995,37 @@ static void genesys_warmup_lamp(Genesys_Device* dev)
}
}
static void init_regs_for_scan(Genesys_Device& dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs)
{
DBG_HELPER(dbg);
debug_dump(DBG_info, dev.settings);
auto session = dev.cmd_set->calculate_scan_session(&dev, sensor, dev.settings);
if (dev.model->asic_type == AsicType::GL124 ||
dev.model->asic_type == AsicType::GL845 ||
dev.model->asic_type == AsicType::GL846 ||
dev.model->asic_type == AsicType::GL847)
{
/* Fast move to scan area:
We don't move fast the whole distance since it would involve computing
acceleration/deceleration distance for scan resolution. So leave a remainder for it so
scan makes the final move tuning
*/
if (dev.settings.get_channels() * dev.settings.yres >= 600 && session.params.starty > 700) {
scanner_move(dev, dev.model->default_method,
static_cast<unsigned>(session.params.starty - 500),
Direction::FORWARD);
session.params.starty = 500;
}
compute_session(&dev, session, sensor);
}
dev.cmd_set->init_regs_for_scan_session(&dev, sensor, &regs, session);
}
// High-level start of scanning
static void genesys_start_scan(Genesys_Device* dev, bool lamp_off)
@ -4082,7 +4113,7 @@ static void genesys_start_scan(Genesys_Device* dev, bool lamp_off)
dev->cmd_set->move_to_ta(dev);
}
dev->cmd_set->init_regs_for_scan(dev, sensor, dev->reg);
init_regs_for_scan(*dev, sensor, dev->reg);
/* no lamp during scan */
if (lamp_off) {

Wyświetl plik

@ -1020,25 +1020,6 @@ void CommandSetGl124::wait_for_motor_stop(Genesys_Device* dev) const
dev->interface->sleep_ms(50);
}
/** @brief set up registers for the actual scan
*/
void CommandSetGl124::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const
{
DBG_HELPER(dbg);
auto session = calculate_scan_session(dev, sensor, dev->settings);
if (dev->settings.get_channels() * dev->settings.yres >= 600 && session.params.starty > 700) {
scanner_move(*dev, dev->model->default_method,
static_cast<unsigned>(session.params.starty - 500),
Direction::FORWARD);
session.params.starty = 500;
}
compute_session(dev, session, sensor);
init_regs_for_scan_session(dev, sensor, &regs, session);
}
/**
* Send shading calibration data. The buffer is considered to always hold values
* for all the channels.

Wyświetl plik

@ -65,9 +65,6 @@ public:
void init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const override;
void init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const override;
void init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg,
const ScanSession& session) const override;

Wyświetl plik

@ -1860,22 +1860,6 @@ bool CommandSetGl646::needs_home_before_init_regs_for_scan(Genesys_Device* dev)
dev->settings.scan_method == ScanMethod::FLATBED;
}
/**
* set up registers for the actual scan. The scan's parameters are given
* through the device settings. It allocates the scan buffers.
*/
void CommandSetGl646::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const
{
DBG_HELPER(dbg);
debug_dump(DBG_info, dev->settings);
ScanSession session = calculate_scan_session(dev, sensor, dev->settings);
init_regs_for_scan_session(dev, sensor, &regs, session);
}
/**
* this function send gamma table to ASIC
*/

Wyświetl plik

@ -69,9 +69,6 @@ public:
void init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const override;
void init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const override;
void init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg,
const ScanSession& session) const override;

Wyświetl plik

@ -1617,19 +1617,6 @@ void CommandSetGl841::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
dev->calib_session = session;
}
// set up registers for the actual scan
void CommandSetGl841::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const
{
DBG_HELPER(dbg);
debug_dump(DBG_info, dev->settings);
auto session = calculate_scan_session(dev, sensor, dev->settings);
init_regs_for_scan_session(dev, sensor, &regs, session);
}
// this function sends generic gamma table (ie linear ones) or the Sensor specific one if provided
void CommandSetGl841::send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const
{

Wyświetl plik

@ -65,9 +65,6 @@ public:
void init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const override;
void init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const override;
void init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg,
const ScanSession& session) const override;

Wyświetl plik

@ -769,15 +769,6 @@ void CommandSetGl842::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
dev->calib_session = session;
}
void CommandSetGl842::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const
{
DBG_HELPER(dbg);
ScanSession session = calculate_scan_session(dev, sensor, dev->settings);
init_regs_for_scan_session(dev, sensor, &regs, session);
}
void CommandSetGl842::send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const
{
DBG_HELPER(dbg);

Wyświetl plik

@ -65,9 +65,6 @@ public:
void init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const override;
void init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const override;
void init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg,
const ScanSession& session) const override;

Wyświetl plik

@ -1439,17 +1439,6 @@ void CommandSetGl843::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
dev->calib_session = session;
}
/** @brief set up registers for the actual scan
*/
void CommandSetGl843::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const
{
DBG_HELPER(dbg);
ScanSession session = calculate_scan_session(dev, sensor, dev->settings);
init_regs_for_scan_session(dev, sensor, &regs, session);
}
/**
* This function sends gamma tables to ASIC
*/

Wyświetl plik

@ -65,9 +65,6 @@ public:
void init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const override;
void init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const override;
void init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg,
const ScanSession& session) const override;

Wyświetl plik

@ -893,33 +893,6 @@ void CommandSetGl846::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
dev->calib_session = session;
}
/** @brief set up registers for the actual scan
*/
void CommandSetGl846::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const
{
DBG_HELPER(dbg);
auto session = calculate_scan_session(dev, sensor, dev->settings);
/* Fast move to scan area:
We don't move fast the whole distance since it would involve computing
acceleration/deceleration distance for scan resolution. So leave a remainder for it so
scan makes the final move tuning
*/
if (dev->settings.get_channels() * dev->settings.yres >= 600 && session.params.starty > 700) {
scanner_move(*dev, dev->model->default_method,
static_cast<unsigned>(session.params.starty - 500),
Direction::FORWARD);
session.params.starty = 500;
}
compute_session(dev, session, sensor);
init_regs_for_scan_session(dev, sensor, &regs, session);
}
/**
* Send shading calibration data. The buffer is considered to always hold values
* for all the channels.

Wyświetl plik

@ -65,9 +65,6 @@ public:
void init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const override;
void init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const override;
void init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg,
const ScanSession& session) const override;

Wyświetl plik

@ -790,33 +790,6 @@ void CommandSetGl847::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
dev->calib_session = session;
}
/** @brief set up registers for the actual scan
*/
void CommandSetGl847::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const
{
DBG_HELPER(dbg);
auto session = calculate_scan_session(dev, sensor, dev->settings);
/* Fast move to scan area:
We don't move fast the whole distance since it would involve computing
acceleration/deceleration distance for scan resolution. So leave a remainder for it so
scan makes the final move tuning
*/
if (dev->settings.get_channels() * dev->settings.yres >= 600 && session.params.starty > 700) {
scanner_move(*dev, dev->model->default_method,
static_cast<unsigned>(session.params.starty - 500),
Direction::FORWARD);
session.params.starty = 500;
}
compute_session(dev, session, sensor);
init_regs_for_scan_session(dev, sensor, &regs, session);
}
/**
* Send shading calibration data. The buffer is considered to always hold values
* for all the channels.

Wyświetl plik

@ -65,9 +65,6 @@ public:
void init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const override;
void init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const override;
void init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg,
const ScanSession& session) const override;