Merge branch 'genesys-misc-cleanup' into 'master'

genesys: Miscellaneous cleanup

See merge request sane-project/backends!164
merge-requests/165/merge
Povilas Kanapickas 2019-09-24 21:11:09 +00:00
commit a4729cff19
9 zmienionych plików z 135 dodań i 225 usunięć

Wyświetl plik

@ -301,8 +301,6 @@ enum class AsicType : unsigned
GL845,
GL846,
GL847,
GL848,
GL123,
GL124,
};

Wyświetl plik

@ -93,49 +93,6 @@ gl124_test_motor_flag_bit (SANE_Byte val)
return SANE_FALSE;
}
/** @brief sensor profile
* search for the database of motor profiles and get the best one. Each
* profile is at a specific dpihw. Use LiDE 110 table by default.
* @param sensor_type sensor id
* @param dpi hardware dpi for the scan
* @param ccd_size_divisor flag to signal half ccd mode
* @return a pointer to a Sensor_Profile struct
*/
static const SensorProfile& get_sensor_profile(const Genesys_Sensor& sensor, unsigned dpi,
unsigned ccd_size_divisor)
{
int best_i = -1;
for (unsigned i = 0; i < sensor.sensor_profiles.size(); ++i) {
// exact match
if (sensor.sensor_profiles[i].dpi == dpi &&
sensor.sensor_profiles[i].ccd_size_divisor == ccd_size_divisor)
{
return sensor.sensor_profiles[i];
}
// closest match
if (sensor.sensor_profiles[i].ccd_size_divisor == ccd_size_divisor) {
if (best_i < 0) {
best_i = i;
} else {
if (sensor.sensor_profiles[i].dpi >= dpi &&
sensor.sensor_profiles[i].dpi < sensor.sensor_profiles[best_i].dpi)
{
best_i = i;
}
}
}
}
// default fallback
if (best_i < 0) {
DBG(DBG_warn,"%s: using default sensor profile\n",__func__);
return *s_fallback_sensor_profile_gl124;
}
return sensor.sensor_profiles[best_i];
}
static void gl124_homsnr_gpio(Genesys_Device* dev)
{
DBG_HELPER(dbg);
@ -821,10 +778,9 @@ static void gl124_setup_sensor(Genesys_Device * dev,
*/
static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg, unsigned int exposure_time,
const ScanSession& session, unsigned int start)
const ScanSession& session)
{
DBG_HELPER_ARGS(dbg, "exposure_time=%d, start=%d\n",
exposure_time, start);
DBG_HELPER_ARGS(dbg, "exposure_time=%d", exposure_time);
unsigned int segcnt;
unsigned int startx, endx;
unsigned int dpihw;
@ -841,11 +797,18 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
DBG(DBG_io2, "%s: dpihw=%d\n", __func__, dpihw);
// sensor parameters
const auto& sensor_profile = get_sensor_profile(sensor, dpihw, session.ccd_size_divisor);
const auto& sensor_profile = get_sensor_profile(dev->model->asic_type, sensor, dpihw,
session.ccd_size_divisor);
gl124_setup_sensor(dev, sensor, sensor_profile, reg);
/* start and end coordinate in optical dpi coordinates */
/* startx = start / ccd_pixels_per_system_pixel + sensor.dummy_pixel; XXX STEF XXX */
unsigned start = session.params.startx;
if (session.num_staggered_lines > 0) {
start |= 1;
}
startx = start / ccd_pixels_per_system_pixel;
endx = startx + session.optical_pixels / ccd_pixels_per_system_pixel;
@ -1026,6 +989,13 @@ static void gl124_compute_session(Genesys_Device* dev, ScanSession& s,
const Genesys_Sensor& sensor)
{
DBG_HELPER(dbg);
/* in case of dynamic lineart, we use an internal 8 bit gray scan
* to generate 1 lineart data */
if (s.params.flags & SCAN_FLAG_DYNAMIC_LINEART) {
s.params.depth = 8;
}
compute_session(dev, s, sensor);
s.enable_ledadd = (s.params.channels == 1 && dev->model->is_cis && dev->settings.true_gray);
@ -1040,12 +1010,11 @@ static void gl124_compute_session(Genesys_Device* dev, ScanSession& s,
* this function sets up the scanner to scan in normal or single line mode
*/
static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg, ScanSession& session)
Genesys_Register_Set* reg, const ScanSession& session)
{
DBG_HELPER(dbg);
session.assert_computed();
int start;
int move;
unsigned int mflags;
int exposure_time;
@ -1056,15 +1025,6 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
DBG (DBG_info, "%s: optical_res=%d\n", __func__, session.optical_resolution);
/* compute scan parameters values */
/* pixels are allways given at full optical resolution */
/* use detected left margin and fixed value */
start = session.params.startx;
if (session.num_staggered_lines > 0) {
start |= 1;
}
/* cis color scan is effectively a gray scan with 3 gray lines per color line and a FILTER of 0 */
if (dev->model->is_cis) {
slope_dpi = session.params.yres * session.params.channels;
@ -1078,7 +1038,7 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
}
else
{
exposure_time = get_sensor_profile(sensor, session.params.xres,
exposure_time = get_sensor_profile(dev->model->asic_type, sensor, session.params.xres,
session.ccd_size_divisor).exposure_lperiod;
scan_step_type = sanei_genesys_compute_step_type(gl124_motor_profiles,
dev->model->motor_type, exposure_time);
@ -1087,19 +1047,12 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
DBG(DBG_info, "%s : scan_step_type=%d\n", __func__, scan_step_type);
/*** optical parameters ***/
/* in case of dynamic lineart, we use an internal 8 bit gray scan
* to generate 1 lineart data */
if (session.params.flags & SCAN_FLAG_DYNAMIC_LINEART) {
session.params.depth = 8;
}
/* we enable true gray for cis scanners only, and just when doing
* scan since color calibration is OK for this mode
*/
// now _LOGICAL_ optical values used are known, setup registers
gl124_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, start);
gl124_init_optical_regs_scan(dev, sensor, reg, exposure_time, session);
/* add tl_y to base movement */
move = session.params.starty;
@ -1196,7 +1149,7 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso
DBG(DBG_info, "%s: used_pixels=%d\n", __func__, session.optical_pixels);
exposure_time = get_sensor_profile(sensor, session.params.xres,
exposure_time = get_sensor_profile(dev->model->asic_type, sensor, session.params.xres,
session.ccd_size_divisor).exposure_lperiod;
DBG (DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
@ -1204,7 +1157,7 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso
// compute hw dpi for sensor
dpihw = sensor.get_register_hwdpi(session.params.xres);
const SensorProfile& sensor_profile = get_sensor_profile(sensor, dpihw,
const SensorProfile& sensor_profile = get_sensor_profile(dev->model->asic_type, sensor, dpihw,
session.ccd_size_divisor);
dev->deseg.segment_count = sensor_profile.custom_regs.get_value(0x98) & 0x0f;
@ -2103,7 +2056,8 @@ static SensorExposure gl124_led_calibration(Genesys_Device* dev, const Genesys_S
unsigned ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(dev->settings.xres);
resolution /= ccd_size_divisor;
const auto& sensor_profile = get_sensor_profile(sensor, dpihw, ccd_size_divisor);
const auto& sensor_profile = get_sensor_profile(dev->model->asic_type, sensor, dpihw,
ccd_size_divisor);
num_pixels = (sensor.sensor_pixels*resolution)/sensor.optical_res;
/* initial calibration reg values */

Wyświetl plik

@ -317,7 +317,7 @@ static void gl646_compute_session(Genesys_Device* dev, ScanSession& s,
static void gl646_setup_registers(Genesys_Device* dev,
const Genesys_Sensor& sensor,
Genesys_Register_Set* regs,
ScanSession& session,
const ScanSession& session,
std::vector<uint16_t>& slope_table1,
std::vector<uint16_t>& slope_table2,
bool xcorrection)

Wyświetl plik

@ -1700,6 +1700,17 @@ static void gl841_compute_session(Genesys_Device* dev, ScanSession& s,
const Genesys_Sensor& sensor)
{
DBG_HELPER(dbg);
//in case of dynamic lineart, we use an internal 8 bit gray scan to generate 1 lineart data
if (s.params.flags & SCAN_FLAG_DYNAMIC_LINEART) {
s.params.depth = 8;
}
// no 16 bit gamma for this ASIC
if (s.params.depth == 16) {
s.params.flags |= SCAN_FLAG_DISABLE_GAMMA;
}
compute_session(dev, s, sensor);
s.computed = true;
@ -1722,7 +1733,7 @@ static void gl841_assert_supported_resolution(const ScanSession& session)
// set up registers for an actual scan this function sets up the scanner to scan in normal or single
// line mode
static void gl841_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg, ScanSession& session)
Genesys_Register_Set* reg, const ScanSession& session)
{
DBG_HELPER(dbg);
session.assert_computed();
@ -1835,18 +1846,6 @@ dummy \ scanned lines
session.optical_pixels);
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
/*** optical parameters ***/
/* in case of dynamic lineart, we use an internal 8 bit gray scan
* to generate 1 lineart data */
if (session.params.flags & SCAN_FLAG_DYNAMIC_LINEART) {
session.params.depth = 8;
}
// no 16 bit gamma for this ASIC
if (session.params.depth == 16) {
session.params.flags |= SCAN_FLAG_DISABLE_GAMMA;
}
gl841_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, start);
move = session.params.starty;

Wyświetl plik

@ -1182,6 +1182,16 @@ static void gl843_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
static void gl843_compute_session(Genesys_Device* dev, ScanSession& s,
const Genesys_Sensor& sensor)
{
// in case of dynamic lineart, we use an internal 8 bit gray scan to generate 1 lineart data
if (s.params.flags & SCAN_FLAG_DYNAMIC_LINEART) {
s.params.depth = 8;
}
// no 16 bit gamma for this ASIC
if (s.params.depth == 16) {
s.params.flags |= SCAN_FLAG_DISABLE_GAMMA;
}
compute_session(dev, s, sensor);
// compute physical pixel positions
@ -1207,7 +1217,7 @@ static void gl843_compute_session(Genesys_Device* dev, ScanSession& s,
// set up registers for an actual scan this function sets up the scanner to scan in normal or single
// line mode
static void gl843_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg, ScanSession& session)
Genesys_Register_Set* reg, const ScanSession& session)
{
DBG_HELPER(dbg);
session.assert_computed();
@ -1247,18 +1257,6 @@ static void gl843_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
DBG(DBG_info, "%s : exposure=%d pixels\n", __func__, exposure);
DBG(DBG_info, "%s : scan_step_type=%d\n", __func__, scan_step_type);
/*** optical parameters ***/
/* in case of dynamic lineart, we use an internal 8 bit gray scan
* to generate 1 lineart data */
if (session.params.flags & SCAN_FLAG_DYNAMIC_LINEART) {
session.params.depth = 8;
}
/* no 16 bit gamma for this ASIC */
if (session.params.depth == 16) {
session.params.flags |= SCAN_FLAG_DISABLE_GAMMA;
}
// now _LOGICAL_ optical values used are known, setup registers
gl843_init_optical_regs_scan(dev, sensor, reg, exposure, session);

Wyświetl plik

@ -147,42 +147,6 @@ gl846_get_step_multiplier (Genesys_Register_Set * regs)
return value;
}
/** @brief sensor profile
* search for the database of motor profiles and get the best one. Each
* profile is at a specific dpihw. Use LiDE 110 table by default.
* @param sensor_type sensor id
* @param dpi hardware dpi for the scan
* @return a pointer to a Sensor_Profile struct
*/
static const SensorProfile& get_sensor_profile(const Genesys_Sensor& sensor, unsigned dpi)
{
int best_i = -1;
for (unsigned i = 0; i < sensor.sensor_profiles.size(); ++i) {
// exact match
if (sensor.sensor_profiles[i].dpi == dpi) {
return sensor.sensor_profiles[i];
}
// closest match
if (best_i < 0) {
best_i = i;
} else {
if (sensor.sensor_profiles[i].dpi >= dpi &&
sensor.sensor_profiles[i].dpi < sensor.sensor_profiles[best_i].dpi)
{
best_i = i;
}
}
}
// default fallback
if (best_i < 0) {
DBG(DBG_warn,"%s: using default sensor profile\n",__func__);
return *s_fallback_sensor_profile_gl846;
}
return sensor.sensor_profiles[best_i];
}
/** @brief sensor specific settings
*/
static void gl846_setup_sensor(Genesys_Device * dev, const Genesys_Sensor& sensor,
@ -717,9 +681,9 @@ static void gl846_init_motor_regs_scan(Genesys_Device* dev,
*/
static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg, unsigned int exposure_time,
const ScanSession& session, unsigned int start)
const ScanSession& session)
{
DBG_HELPER_ARGS(dbg, "exposure_time=%d, start=%d", exposure_time, start);
DBG_HELPER_ARGS(dbg, "exposure_time=%d", exposure_time);
unsigned int words_per_line;
unsigned int dpihw;
GenesysRegister *r;
@ -734,10 +698,15 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
DBG(DBG_io2, "%s: dpihw=%d\n", __func__, dpihw);
// sensor parameters
const auto& sensor_profile = get_sensor_profile(sensor, dpihw);
const auto& sensor_profile = get_sensor_profile(dev->model->asic_type, sensor, dpihw, 1);
gl846_setup_sensor(dev, sensor, sensor_profile, reg);
// start and end coordinate in optical dpi coordinates
unsigned start = session.params.startx;
if (session.num_staggered_lines > 0) {
start |= 1;
}
unsigned startx = start / ccd_pixels_per_system_pixel + sensor.CCD_start_xoffset;
unsigned endx = startx + session.optical_pixels / ccd_pixels_per_system_pixel;
@ -906,6 +875,12 @@ static void gl846_compute_session(Genesys_Device* dev, ScanSession& s,
const Genesys_Sensor& sensor)
{
DBG_HELPER(dbg);
// in case of dynamic lineart, we use an internal 8 bit gray scan to generate 1 lineart data
if (s.params.flags & SCAN_FLAG_DYNAMIC_LINEART) {
s.params.depth = 8;
}
compute_session(dev, s, sensor);
s.enable_ledadd = (s.params.channels == 1 && dev->model->is_cis && dev->settings.true_gray);
@ -919,12 +894,11 @@ static void gl846_compute_session(Genesys_Device* dev, ScanSession& s,
// set up registers for an actual scan this function sets up the scanner to scan in normal or single
// line mode
static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg, ScanSession& session)
Genesys_Register_Set* reg, const ScanSession& session)
{
DBG_HELPER(dbg);
session.assert_computed();
int start;
int move;
unsigned int mflags; /**> motor flags */
int exposure_time;
@ -933,17 +907,6 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
int dummy = 0;
int scan_step_type = 1;
/* compute scan parameters values */
/* pixels are allways given at full optical resolution */
/* use detected left margin and fixed value */
/* start */
/* add x coordinates */
start = session.params.startx;
if (session.num_staggered_lines > 0) {
start |= 1;
}
dummy = 3-session.params.channels;
/* slope_dpi */
@ -957,24 +920,18 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
slope_dpi = slope_dpi * (1 + dummy);
exposure_time = get_sensor_profile(sensor, session.params.xres).exposure_lperiod;
exposure_time = get_sensor_profile(dev->model->asic_type, sensor,
session.params.xres, 1).exposure_lperiod;
scan_step_type = sanei_genesys_compute_step_type(gl846_motor_profiles, dev->model->motor_type,
exposure_time);
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
DBG(DBG_info, "%s : scan_step_type=%d\n", __func__, scan_step_type);
/*** optical parameters ***/
/* in case of dynamic lineart, we use an internal 8 bit gray scan
* to generate 1 lineart data */
if (session.params.flags & SCAN_FLAG_DYNAMIC_LINEART) {
session.params.depth = 8;
}
/* we enable true gray for cis scanners only, and just when doing
* scan since color calibration is OK for this mode
*/
gl846_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, start);
gl846_init_optical_regs_scan(dev, sensor, reg, exposure_time, session);
/*** motor parameters ***/
@ -1084,7 +1041,8 @@ gl846_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
slope_dpi = slope_dpi * (1 + dummy);
exposure_time = get_sensor_profile(sensor, session.params.xres).exposure_lperiod;
exposure_time = get_sensor_profile(dev->model->asic_type, sensor,
session.params.xres, 1).exposure_lperiod;
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
dev->session = session;
@ -1788,7 +1746,7 @@ static SensorExposure gl846_led_calibration(Genesys_Device* dev, const Genesys_S
channels = 3;
depth=16;
used_res = sensor.get_register_hwdpi(dev->settings.xres);
const auto& sensor_profile = get_sensor_profile(sensor, used_res);
const auto& sensor_profile = get_sensor_profile(dev->model->asic_type, sensor, used_res, 1);
num_pixels = (sensor.sensor_pixels*used_res)/sensor.optical_res;
/* initial calibration reg values */

Wyświetl plik

@ -142,42 +142,6 @@ gl847_get_step_multiplier (Genesys_Register_Set * regs)
return value;
}
/** @brief sensor profile
* search for the database of motor profiles and get the best one. Each
* profile is at a specific dpihw. Use LiDE 110 table by default.
* @param sensor_type sensor id
* @param dpi hardware dpi for the scan
* @return a pointer to a Sensor_Profile struct
*/
static const SensorProfile& get_sensor_profile(const Genesys_Sensor& sensor, unsigned dpi)
{
int best_i = -1;
for (unsigned i = 0; i < sensor.sensor_profiles.size(); ++i) {
// exact match
if (sensor.sensor_profiles[i].dpi == dpi) {
return sensor.sensor_profiles[i];
}
// closest match
if (best_i < 0) {
best_i = i;
} else {
if (sensor.sensor_profiles[i].dpi >= dpi &&
sensor.sensor_profiles[i].dpi < sensor.sensor_profiles[best_i].dpi)
{
best_i = i;
}
}
}
// default fallback
if (best_i < 0) {
DBG(DBG_warn,"%s: using default sensor profile\n",__func__);
return *s_fallback_sensor_profile_gl847;
}
return sensor.sensor_profiles[best_i];
}
/** @brief sensor specific settings
*/
static void gl847_setup_sensor(Genesys_Device * dev, const Genesys_Sensor& sensor,
@ -734,9 +698,9 @@ static void gl847_init_motor_regs_scan(Genesys_Device* dev,
*/
static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg, unsigned int exposure_time,
const ScanSession& session, unsigned int start)
const ScanSession& session)
{
DBG_HELPER_ARGS(dbg, "exposure_time=%d, start=%d", exposure_time, start);
DBG_HELPER_ARGS(dbg, "exposure_time=%d", exposure_time);
unsigned dpiset, dpihw;
GenesysRegister *r;
@ -750,10 +714,15 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
DBG(DBG_io2, "%s: dpihw=%d\n", __func__, dpihw);
// sensor parameters
const auto& sensor_profile = get_sensor_profile(sensor, dpihw);
const auto& sensor_profile = get_sensor_profile(dev->model->asic_type, sensor, dpihw, 1);
gl847_setup_sensor(dev, sensor, sensor_profile, reg);
dpiset = session.params.xres * ccd_pixels_per_system_pixel;
unsigned start = session.params.startx;
if (session.num_staggered_lines > 0) {
start |= 1;
}
// start and end coordinate in optical dpi coordinates
unsigned startx = start / ccd_pixels_per_system_pixel + sensor.CCD_start_xoffset;
unsigned endx = startx + session.optical_pixels / ccd_pixels_per_system_pixel;
@ -922,6 +891,12 @@ static void gl847_compute_session(Genesys_Device* dev, ScanSession& s,
const Genesys_Sensor& sensor)
{
DBG_HELPER(dbg);
// in case of dynamic lineart, we use an internal 8 bit gray scan to generate 1 lineart data
if (s.params.flags & SCAN_FLAG_DYNAMIC_LINEART) {
s.params.depth = 8;
}
compute_session(dev, s, sensor);
s.computed = true;
@ -933,12 +908,11 @@ static void gl847_compute_session(Genesys_Device* dev, ScanSession& s,
// set up registers for an actual scan this function sets up the scanner to scan in normal or single
// line mode
static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg, ScanSession& session)
Genesys_Register_Set* reg, const ScanSession& session)
{
DBG_HELPER(dbg);
session.assert_computed();
int start;
int move;
unsigned int mflags; /**> motor flags */
int exposure_time;
@ -947,17 +921,6 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
int dummy = 0;
int scan_step_type = 1;
/* compute scan parameters values */
/* pixels are allways given at full optical resolution */
/* use detected left margin and fixed value */
/* start */
/* add x coordinates */
start = session.params.startx;
if (session.num_staggered_lines > 0) {
start |= 1;
}
dummy = 3 - session.params.channels;
/* slope_dpi */
@ -971,24 +934,18 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
slope_dpi = slope_dpi * (1 + dummy);
exposure_time = get_sensor_profile(sensor, session.params.xres).exposure_lperiod;
exposure_time = get_sensor_profile(dev->model->asic_type, sensor,
session.params.xres, 1).exposure_lperiod;
scan_step_type = sanei_genesys_compute_step_type(gl847_motor_profiles, dev->model->motor_type,
exposure_time);
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
DBG(DBG_info, "%s : scan_step_type=%d\n", __func__, scan_step_type);
/*** optical parameters ***/
/* in case of dynamic lineart, we use an internal 8 bit gray scan
* to generate 1 lineart data */
if (session.params.flags & SCAN_FLAG_DYNAMIC_LINEART) {
session.params.depth = 8;
}
/* we enable true gray for cis scanners only, and just when doing
* scan since color calibration is OK for this mode
*/
gl847_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, start);
gl847_init_optical_regs_scan(dev, sensor, reg, exposure_time, session);
move = session.params.starty;
DBG(DBG_info, "%s: move=%d steps\n", __func__, move);
@ -1096,7 +1053,8 @@ gl847_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
slope_dpi = slope_dpi * (1 + dummy);
exposure_time = get_sensor_profile(sensor, session.params.xres).exposure_lperiod;
exposure_time = get_sensor_profile(dev->model->asic_type, sensor,
session.params.xres, 1).exposure_lperiod;
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
dev->session = session;
@ -1836,7 +1794,7 @@ static SensorExposure gl847_led_calibration(Genesys_Device* dev, const Genesys_S
channels = 3;
depth=16;
used_res = sensor.get_register_hwdpi(dev->settings.xres);
const auto& sensor_profile = get_sensor_profile(sensor, used_res);
const auto& sensor_profile = get_sensor_profile(dev->model->asic_type, sensor, used_res, 1);
num_pixels = (sensor.sensor_pixels*used_res)/sensor.optical_res;
/* initial calibration reg values */

Wyświetl plik

@ -1296,6 +1296,48 @@ void compute_session(Genesys_Device* dev, ScanSession& s, const Genesys_Sensor&
compute_session_buffer_sizes(dev->model->asic_type, s);
}
const SensorProfile& get_sensor_profile(AsicType asic_type, const Genesys_Sensor& sensor,
unsigned dpi, unsigned ccd_size_divisor)
{
int best_i = -1;
for (unsigned i = 0; i < sensor.sensor_profiles.size(); ++i) {
// exact match
if (sensor.sensor_profiles[i].dpi == dpi &&
sensor.sensor_profiles[i].ccd_size_divisor == ccd_size_divisor)
{
return sensor.sensor_profiles[i];
}
// closest match
if (sensor.sensor_profiles[i].ccd_size_divisor == ccd_size_divisor) {
if (best_i < 0) {
best_i = i;
} else {
if (sensor.sensor_profiles[i].dpi >= dpi &&
sensor.sensor_profiles[i].dpi < sensor.sensor_profiles[best_i].dpi)
{
best_i = i;
}
}
}
}
// default fallback
if (best_i < 0) {
DBG(DBG_warn, "%s: using default sensor profile\n", __func__);
if (asic_type == AsicType::GL124)
return *s_fallback_sensor_profile_gl124;
if (asic_type == AsicType::GL845 || asic_type == AsicType::GL846)
return *s_fallback_sensor_profile_gl846;
if (asic_type == AsicType::GL847)
return *s_fallback_sensor_profile_gl847;
throw SaneException("Unknown asic type for default profile %d",
static_cast<unsigned>(asic_type));
}
return sensor.sensor_profiles[best_i];
}
/** @brief initialize device
* Initialize backend and ASIC : registers, motor tables, and gamma tables
* then ensure scanner's head is at home. Designed for gl846+ ASICs.

Wyświetl plik

@ -636,6 +636,9 @@ extern void sanei_genesys_generate_gamma_buffer(Genesys_Device* dev,
void compute_session(Genesys_Device* dev, ScanSession& s, const Genesys_Sensor& sensor);
const SensorProfile& get_sensor_profile(AsicType asic_type, const Genesys_Sensor& sensor,
unsigned dpi, unsigned ccd_size_divisor);
template<class T>
inline T abs_diff(T a, T b)
{