genesys: Make handling of stagger more uniform across chipsets

fix-build-obselete-jpeg
Povilas Kanapickas 2020-03-20 23:29:02 +02:00
rodzic 75d227f9c4
commit e2fc129b56
1 zmienionych plików z 51 dodań i 38 usunięć

Wyświetl plik

@ -837,10 +837,6 @@ void compute_session_pixel_offsets(const Genesys_Device* dev, ScanSession& s,
}
s.pixel_startx += s.params.startx * sensor.optical_res / s.params.xres;
if (sensor.stagger_config.stagger_at_resolution(s.params.xres, s.params.yres) > 0) {
s.pixel_startx |= 1;
}
s.pixel_endx = s.pixel_startx + s.optical_pixels;
s.pixel_startx /= sensor.ccd_pixels_per_system_pixel() * s.ccd_size_divisor;
@ -854,10 +850,6 @@ void compute_session_pixel_offsets(const Genesys_Device* dev, ScanSession& s,
s.pixel_startx += sensor.dummy_pixel + 1;
if (s.num_staggered_lines > 0 && (s.pixel_startx & 1) == 0) {
s.pixel_startx++;
}
/* In case of SHDAREA, we need to align start on pixel average factor, startx is
different than 0 only when calling for function to setup for scan, where shading data
needs to be align.
@ -882,7 +874,52 @@ void compute_session_pixel_offsets(const Genesys_Device* dev, ScanSession& s,
s.pixel_startx /= s.hwdpi_divisor * ccd_pixels_per_system_pixel;
s.pixel_endx /= s.hwdpi_divisor * ccd_pixels_per_system_pixel;
} else if (dev->model->asic_type == AsicType::GL845 ||
dev->model->asic_type == AsicType::GL846 ||
dev->model->asic_type == AsicType::GL847)
{
unsigned startx = s.params.startx * sensor.optical_res / s.params.xres;
s.pixel_startx = startx;
s.pixel_startx += sensor.ccd_start_xoffset * ccd_pixels_per_system_pixel;
s.pixel_endx = s.pixel_startx + s.optical_pixels_raw;
s.pixel_startx /= s.hwdpi_divisor * s.segment_count * ccd_pixels_per_system_pixel;
s.pixel_endx /= s.hwdpi_divisor * s.segment_count * ccd_pixels_per_system_pixel;
} else if (dev->model->asic_type == AsicType::GL124) {
unsigned startx = s.params.startx * sensor.optical_res / s.params.xres;
s.pixel_startx = startx;
// FIXME: should we add sensor.dummy_pxel to pixel_startx at this point?
s.pixel_endx = s.pixel_startx + s.optical_pixels;
s.pixel_startx /= s.hwdpi_divisor * s.segment_count * ccd_pixels_per_system_pixel;
s.pixel_endx /= s.hwdpi_divisor * s.segment_count * ccd_pixels_per_system_pixel;
}
s.pixel_count_ratio = sensor.pixel_count_ratio;
s.pixel_startx = sensor.pixel_count_ratio.apply(s.pixel_startx);
s.pixel_endx = sensor.pixel_count_ratio.apply(s.pixel_endx);
if (dev->model->asic_type == AsicType::GL646) {
if (sensor.stagger_config.stagger_at_resolution(s.params.xres, s.params.yres) > 0 &&
(s.pixel_startx & 1) == 0)
{
s.pixel_startx++;
s.pixel_endx++;
}
} else if (dev->model->asic_type == AsicType::GL841) {
if (s.num_staggered_lines > 0 && (s.pixel_startx & 1) == 0) {
s.pixel_startx++;
s.pixel_endx++;
}
} else if (dev->model->asic_type == AsicType::GL843) {
// in case of stagger we have to start at an odd coordinate
// FIXME: we should probably just configure the image pipeline accordingly
bool stagger_starts_even = false;
if (dev->model->model_id == ModelId::CANON_4400F ||
dev->model->model_id == ModelId::CANON_8400F)
@ -899,38 +936,19 @@ void compute_session_pixel_offsets(const Genesys_Device* dev, ScanSession& s,
s.pixel_endx++;
}
}
} else if (dev->model->asic_type == AsicType::GL845 ||
dev->model->asic_type == AsicType::GL846 ||
dev->model->asic_type == AsicType::GL847)
{
unsigned startx = s.params.startx * sensor.optical_res / s.params.xres;
s.pixel_startx = startx;
if (s.num_staggered_lines > 0) {
s.pixel_startx |= 1;
if (s.num_staggered_lines > 0 && (s.pixel_startx & 1) == 0) {
s.pixel_startx++;
s.pixel_endx++;
}
s.pixel_startx += sensor.ccd_start_xoffset * ccd_pixels_per_system_pixel;
s.pixel_endx = s.pixel_startx + s.optical_pixels_raw;
s.pixel_startx /= s.hwdpi_divisor * s.segment_count * ccd_pixels_per_system_pixel;
s.pixel_endx /= s.hwdpi_divisor * s.segment_count * ccd_pixels_per_system_pixel;
} else if (dev->model->asic_type == AsicType::GL124) {
unsigned startx = s.params.startx * sensor.optical_res / s.params.xres;
s.pixel_startx = startx;
if (s.num_staggered_lines > 0) {
s.pixel_startx |= 1;
if (s.num_staggered_lines > 0 && (s.pixel_startx & 1) == 0) {
s.pixel_startx++;
s.pixel_endx++;
}
// FIXME: should we add sensor.dummy_pxel to pixel_startx at this point?
s.pixel_endx = s.pixel_startx + s.optical_pixels;
s.pixel_startx /= s.hwdpi_divisor * s.segment_count * ccd_pixels_per_system_pixel;
s.pixel_endx /= s.hwdpi_divisor * s.segment_count * ccd_pixels_per_system_pixel;
std::uint32_t segcnt = (sensor.custom_regs.get_value(gl124::REG_SEGCNT) << 16) +
(sensor.custom_regs.get_value(gl124::REG_SEGCNT + 1) << 8) +
@ -939,11 +957,6 @@ void compute_session_pixel_offsets(const Genesys_Device* dev, ScanSession& s,
s.pixel_endx = 0;
}
}
s.pixel_count_ratio = sensor.pixel_count_ratio;
s.pixel_startx = sensor.pixel_count_ratio.apply(s.pixel_startx);
s.pixel_endx = sensor.pixel_count_ratio.apply(s.pixel_endx);
}
void compute_session(const Genesys_Device* dev, ScanSession& s, const Genesys_Sensor& sensor)