genesys: Simplify segment count calculation

merge-requests/165/head
Povilas Kanapickas 2019-09-12 21:24:29 +03:00
rodzic a4729cff19
commit ae784d9927
3 zmienionych plików z 15 dodań i 12 usunięć

Wyświetl plik

@ -710,12 +710,7 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
unsigned startx = start / ccd_pixels_per_system_pixel + sensor.CCD_start_xoffset;
unsigned endx = startx + session.optical_pixels / ccd_pixels_per_system_pixel;
/* sensors are built from 600 dpi segments for LiDE 100/200
* and 1200 dpi for the 700F */
unsigned segment_count = 1;
if (dev->model->flags & GENESYS_FLAG_SIS_SENSOR) {
segment_count = dpihw / 600;
}
unsigned segment_count = sensor_profile.get_segment_count();
// compute pixel coordinate in the given dpihw space, taking segments into account
startx /= session.hwdpi_divisor * segment_count;
@ -726,7 +721,7 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
/* in cas of multi-segments sensor, we have to add the witdh
* of the sensor crossed by the scan area */
if (dev->model->flags & GENESYS_FLAG_SIS_SENSOR && segment_count > 1) {
if (segment_count > 1) {
dev->deseg.conseq_pixel_dist_bytes = sensor_profile.segment_size;
}

Wyświetl plik

@ -729,10 +729,7 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
/* sensors are built from 600 dpi segments for LiDE 100/200
* and 1200 dpi for the 700F */
unsigned segment_count = 1;
if (dev->model->flags & GENESYS_FLAG_SIS_SENSOR) {
segment_count = dpihw/600;
}
unsigned segment_count = sensor_profile.get_segment_count();
// compute pixel coordinate in the given dpihw space, taking segments into account
startx /= session.hwdpi_divisor * segment_count;
@ -743,7 +740,7 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
/* in cas of multi-segments sensor, we have to add the witdh
* of the sensor crossed by the scan area */
if (dev->model->flags & GENESYS_FLAG_SIS_SENSOR && segment_count > 1) {
if (segment_count > 1) {
dev->deseg.conseq_pixel_dist_bytes = sensor_profile.segment_size;
}

Wyświetl plik

@ -166,9 +166,20 @@ struct SensorProfile
unsigned exposure_lperiod = 0;
SensorExposure exposure;
unsigned segment_size = 0; // only on GL846, GL847
// the order of the segments, if any, for the profile. If the sensor is not segmented or uses
// only single segment, this array can be empty
std::vector<unsigned> segment_order;
GenesysRegisterSettingSet custom_regs;
unsigned get_segment_count() const
{
if (segment_order.size() < 2)
return 1;
return segment_order.size();
}
bool operator==(const SensorProfile& other) const
{
return dpi == other.dpi &&