kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Use common code path to compute session optical_pixels_raw
rodzic
3a323a751a
commit
eb0882ecc4
|
@ -708,18 +708,15 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
start |= 1;
|
||||
}
|
||||
unsigned startx = start + sensor.CCD_start_xoffset * ccd_pixels_per_system_pixel;
|
||||
unsigned endx = startx + session.optical_pixels;
|
||||
unsigned endx = startx + session.optical_pixels_raw;
|
||||
|
||||
// compute pixel coordinate in the given dpihw space, taking segments into account
|
||||
startx /= session.hwdpi_divisor * session.segment_count;
|
||||
endx /= session.hwdpi_divisor * session.segment_count;
|
||||
dev->deseg.pixel_groups = (endx - startx) / ccd_pixels_per_system_pixel;
|
||||
dev->deseg.conseq_pixel_dist_bytes = 0;
|
||||
dev->deseg.pixel_groups = session.optical_pixels /
|
||||
(session.hwdpi_divisor * session.segment_count * ccd_pixels_per_system_pixel);
|
||||
dev->deseg.skip_bytes = 0;
|
||||
|
||||
/* use a segcnt rounded to next even number */
|
||||
endx += ((session.conseq_pixel_dist_bytes + 1) & 0xfffe) * (session.segment_count - 1) * ccd_pixels_per_system_pixel;
|
||||
|
||||
gl846_set_fe(dev, sensor, AFE_SET);
|
||||
|
||||
/* enable shading */
|
||||
|
|
|
@ -724,21 +724,15 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
|
||||
// start and end coordinate in optical dpi coordinates
|
||||
unsigned startx = start + sensor.CCD_start_xoffset * ccd_pixels_per_system_pixel;
|
||||
unsigned endx = startx + session.optical_pixels;
|
||||
|
||||
/* sensors are built from 600 dpi segments for LiDE 100/200
|
||||
* and 1200 dpi for the 700F */
|
||||
unsigned endx = startx + session.optical_pixels_raw;
|
||||
|
||||
// compute pixel coordinate in the given dpihw space, taking segments into account
|
||||
startx /= session.hwdpi_divisor * session.segment_count;
|
||||
endx /= session.hwdpi_divisor * session.segment_count;
|
||||
dev->deseg.pixel_groups = (endx - startx) / ccd_pixels_per_system_pixel;
|
||||
dev->deseg.conseq_pixel_dist_bytes = 0;
|
||||
dev->deseg.pixel_groups = session.optical_pixels /
|
||||
(session.hwdpi_divisor * session.segment_count * ccd_pixels_per_system_pixel);
|
||||
dev->deseg.skip_bytes = 0;
|
||||
|
||||
/* use a segcnt rounded to next even number */
|
||||
endx += ((session.conseq_pixel_dist_bytes + 1) & 0xfffe) * (session.segment_count - 1) * ccd_pixels_per_system_pixel;
|
||||
|
||||
gl847_set_fe(dev, sensor, AFE_SET);
|
||||
|
||||
/* enable shading */
|
||||
|
|
|
@ -1324,17 +1324,24 @@ void compute_session(Genesys_Device* dev, ScanSession& s, const Genesys_Sensor&
|
|||
s.segment_count = sensor_profile->get_segment_count();
|
||||
}
|
||||
|
||||
s.optical_pixels_raw = s.optical_pixels;
|
||||
s.conseq_pixel_dist_bytes = 0;
|
||||
|
||||
if (dev->model->asic_type == AsicType::GL845 ||
|
||||
dev->model->asic_type == AsicType::GL846 ||
|
||||
dev->model->asic_type == AsicType::GL847)
|
||||
{
|
||||
// in case of multi-segments sensor, we have to add the witdh of the sensor crossed by the
|
||||
// scan area
|
||||
if (s.segment_count > 1) {
|
||||
s.conseq_pixel_dist_bytes = sensor_profile->segment_size;
|
||||
// TODO: apply to optical_pixels_raw before the multiply below
|
||||
|
||||
// in case of multi-segments sensor, we have to add the width of the sensor crossed by
|
||||
// the scan area
|
||||
unsigned extra_segment_scan_area = align_multiple_ceil(s.conseq_pixel_dist_bytes, 2);
|
||||
extra_segment_scan_area *= s.segment_count - 1;
|
||||
extra_segment_scan_area *= s.hwdpi_divisor * s.segment_count;
|
||||
extra_segment_scan_area *= ccd_pixels_per_system_pixel;
|
||||
|
||||
s.optical_pixels_raw += extra_segment_scan_area;
|
||||
s.conseq_pixel_dist_bytes = multiply_by_depth_ceil(s.conseq_pixel_dist_bytes,
|
||||
s.params.depth);
|
||||
}
|
||||
|
@ -2018,6 +2025,7 @@ void debug_dump(unsigned level, const ScanSession& session)
|
|||
DBG(level, " ccd_size_divisor : %d\n", session.ccd_size_divisor);
|
||||
DBG(level, " optical_resolution : %d\n", session.optical_resolution);
|
||||
DBG(level, " optical_pixels : %d\n", session.optical_pixels);
|
||||
DBG(level, " optical_pixels_raw : %d\n", session.optical_pixels_raw);
|
||||
DBG(level, " output_resolution : %d\n", session.output_resolution);
|
||||
DBG(level, " output_pixels : %d\n", session.output_pixels);
|
||||
DBG(level, " output_line_bytes : %d\n", session.output_line_bytes);
|
||||
|
|
|
@ -649,6 +649,16 @@ inline T abs_diff(T a, T b)
|
|||
}
|
||||
}
|
||||
|
||||
inline uint64_t align_multiple_floor(uint64_t x, uint64_t multiple)
|
||||
{
|
||||
return (x / multiple) * multiple;
|
||||
}
|
||||
|
||||
inline uint64_t align_multiple_ceil(uint64_t x, uint64_t multiple)
|
||||
{
|
||||
return ((x + multiple - 1) / multiple) * multiple;
|
||||
}
|
||||
|
||||
inline unsigned multiply_by_depth_ceil(unsigned pixels, unsigned depth)
|
||||
{
|
||||
if (depth == 1) {
|
||||
|
|
|
@ -227,9 +227,13 @@ struct ScanSession {
|
|||
// the optical resolution of the scanner.
|
||||
unsigned optical_resolution = 0;
|
||||
|
||||
// the number of pixels at the optical resolution.
|
||||
// the number of pixels at the optical resolution, not including segmentation overhead.
|
||||
unsigned optical_pixels = 0;
|
||||
|
||||
// the number of pixels at the optical resolution, including segmentation overhead.
|
||||
// only on gl846, g847
|
||||
unsigned optical_pixels_raw = 0;
|
||||
|
||||
// the resolution of the output data.
|
||||
// gl843-only
|
||||
unsigned output_resolution = 0;
|
||||
|
|
Ładowanie…
Reference in New Issue