kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Use single code path to compute session output_line_bytes_raw
rodzic
1f4a5311d7
commit
95eb6a72dd
|
@ -3433,7 +3433,7 @@ static void genesys_fill_line_interp_buffer(Genesys_Device* dev, uint8_t* work_b
|
|||
|
||||
/* go to next line if needed */
|
||||
if (dev->deseg.curr_byte == dev->deseg.pixel_groups) {
|
||||
dev->oe_buffer.set_pos(dev->oe_buffer.pos() + dev->deseg.raw_line_bytes);
|
||||
dev->oe_buffer.set_pos(dev->oe_buffer.pos() + dev->session.output_line_bytes_raw);
|
||||
dev->deseg.curr_byte = 0;
|
||||
dev->line_count++;
|
||||
}
|
||||
|
@ -3519,7 +3519,7 @@ static void genesys_fill_segmented_buffer(Genesys_Device* dev, uint8_t* work_buf
|
|||
|
||||
/* go to next line if needed */
|
||||
if (dev->deseg.curr_byte == dev->deseg.pixel_groups) {
|
||||
dev->oe_buffer.set_pos(dev->oe_buffer.pos() + dev->deseg.raw_line_bytes);
|
||||
dev->oe_buffer.set_pos(dev->oe_buffer.pos() + dev->session.output_line_bytes_raw);
|
||||
dev->deseg.curr_byte = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -202,9 +202,6 @@ struct DesegmentationState
|
|||
// scanned from a single segment
|
||||
unsigned pixel_groups = 0;
|
||||
|
||||
// Total bytes in a line received from a scanner
|
||||
unsigned raw_line_bytes = 0;
|
||||
|
||||
// The current byte during desegmentation process
|
||||
unsigned curr_byte = 0;
|
||||
};
|
||||
|
@ -300,7 +297,7 @@ struct Genesys_Device
|
|||
Genesys_Buffer local_buffer;
|
||||
|
||||
// bytes to read from desegmentation step. This is not the same as physical bytes read from
|
||||
// scanners, see `deseg.raw_line_bytes` which corresponds to this information on certain
|
||||
// scanners, see `session.output_line_bytes_raw` which corresponds to this information on certain
|
||||
// scanners.
|
||||
size_t read_bytes_left_after_deseg = 0;
|
||||
|
||||
|
|
|
@ -945,34 +945,26 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
reg->set24(REG_ENDPIXEL, endx / session.segment_count);
|
||||
DBG(DBG_io2, "%s: endpixel used=%d\n", __func__, endx / session.segment_count);
|
||||
|
||||
// words(16bit) before gamma, conversion to 8 bit or lineart
|
||||
dev->deseg.raw_line_bytes =
|
||||
multiply_by_depth_ceil(session.output_pixels / session.ccd_size_divisor,
|
||||
session.params.depth);
|
||||
|
||||
dev->deseg.curr_byte = 0;
|
||||
dev->deseg.skip_bytes = 0;
|
||||
dev->deseg.pixel_groups = dev->deseg.raw_line_bytes / session.segment_count;
|
||||
const_cast<ScanSession&>(session).conseq_pixel_dist_bytes = dev->deseg.raw_line_bytes / session.segment_count;
|
||||
dev->deseg.pixel_groups = session.output_line_bytes_raw / session.segment_count;
|
||||
const_cast<ScanSession&>(session).conseq_pixel_dist_bytes = session.output_line_bytes_raw / session.segment_count;
|
||||
dev->line_count = 0;
|
||||
dev->line_interp = 0;
|
||||
|
||||
DBG (DBG_io2, "%s: pixels =%d\n", __func__, session.optical_pixels);
|
||||
DBG (DBG_io2, "%s: depth =%d\n", __func__, session.params.depth);
|
||||
DBG (DBG_io2, "%s: dev->bpl =%lu\n", __func__, (unsigned long) dev->deseg.raw_line_bytes);
|
||||
DBG (DBG_io2, "%s: dev->len =%lu\n", __func__, (unsigned long) dev->deseg.pixel_groups);
|
||||
DBG (DBG_io2, "%s: dev->line_interp=%lu\n", __func__, (unsigned long)dev->line_interp);
|
||||
|
||||
// BUG: we shouldn't multiply by channels here
|
||||
dev->oe_buffer.clear();
|
||||
dev->oe_buffer.alloc(dev->deseg.raw_line_bytes * session.params.channels);
|
||||
dev->oe_buffer.alloc(session.output_line_bytes_raw * session.params.channels);
|
||||
|
||||
// MAXWD is expressed in 2 words unit
|
||||
|
||||
// BUG: we shouldn't multiply by channels here
|
||||
reg->set24(REG_MAXWD, dev->deseg.raw_line_bytes * session.params.channels);
|
||||
DBG(DBG_io2, "%s: words_per_line used=%d\n", __func__,
|
||||
dev->deseg.raw_line_bytes * session.params.channels);
|
||||
reg->set24(REG_MAXWD, session.output_line_bytes_raw * session.params.channels);
|
||||
|
||||
reg->set24(REG_LPERIOD, exposure_time);
|
||||
DBG (DBG_io2, "%s: exposure_time used=%d\n", __func__, exposure_time);
|
||||
|
|
|
@ -563,8 +563,6 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
|||
DBG(DBG_info, "%s: startx=%d, endx=%d, ccd_size_divisor=%d\n", __func__, sx, ex,
|
||||
session.ccd_size_divisor);
|
||||
|
||||
dev->deseg.raw_line_bytes = session.output_channel_bytes;
|
||||
|
||||
regs->set24(REG_MAXWD, session.output_line_bytes);
|
||||
|
||||
regs->set16(REG_DPISET, session.output_resolution * session.ccd_size_divisor *
|
||||
|
@ -1510,7 +1508,7 @@ static void gl646_detect_document_end(Genesys_Device* dev)
|
|||
/* we add the number of lines needed to read the last part of the document in */
|
||||
lines = (SANE_UNFIX(dev->model->y_offset) * dev->session.params.yres) / MM_PER_INCH;
|
||||
DBG(DBG_io, "%s: adding %d line to flush\n", __func__, lines);
|
||||
bytes_left += lines * dev->deseg.raw_line_bytes;
|
||||
bytes_left += lines * dev->session.output_line_bytes_raw;
|
||||
|
||||
if (dev->session.params.depth > 8) {
|
||||
bytes_left = 2 * bytes_left;
|
||||
|
|
|
@ -1604,8 +1604,6 @@ static void gl841_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
reg->set16(REG_ENDPIXEL, end);
|
||||
DBG(DBG_io2, "%s: STRPIXEL=%d, ENDPIXEL=%d\n", __func__, start, end);
|
||||
|
||||
dev->deseg.raw_line_bytes = session.output_line_bytes;
|
||||
|
||||
reg->set24(REG_MAXWD, session.output_line_bytes);
|
||||
|
||||
reg->set16(REG_LPERIOD, exposure_time);
|
||||
|
@ -2440,7 +2438,7 @@ static void gl841_detect_document_end(Genesys_Device* dev)
|
|||
|
||||
/* the current scancnt is also the final one, so we use it to
|
||||
* compute total bytes to read. We also add the line count to eject document */
|
||||
total_bytes_to_read=(scancnt+postcnt) * dev->deseg.raw_line_bytes;
|
||||
total_bytes_to_read=(scancnt+postcnt) * dev->session.output_line_bytes_raw;
|
||||
|
||||
DBG(DBG_io, "%s: old total_bytes_to_read=%u\n", __func__,
|
||||
(unsigned int)dev->total_bytes_to_read);
|
||||
|
|
|
@ -1157,11 +1157,8 @@ static void gl843_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
reg->set16(REG_STRPIXEL, session.pixel_startx);
|
||||
reg->set16(REG_ENDPIXEL, session.pixel_endx);
|
||||
|
||||
dev->deseg.raw_line_bytes = session.output_channel_bytes; // FIXME: this is not currently used
|
||||
|
||||
DBG(DBG_io2, "%s: pixels =%d\n", __func__, session.optical_pixels);
|
||||
DBG(DBG_io2, "%s: depth =%d\n", __func__, session.params.depth);
|
||||
DBG(DBG_io2, "%s: dev->bpl =%lu\n", __func__, (unsigned long) dev->deseg.raw_line_bytes);
|
||||
DBG(DBG_io2, "%s: dev->len =%lu\n", __func__, (unsigned long) dev->deseg.pixel_groups);
|
||||
|
||||
/* MAXWD is expressed in 2 words unit */
|
||||
|
@ -1582,7 +1579,7 @@ static void gl843_detect_document_end(Genesys_Device* dev)
|
|||
|
||||
// number of bytes to read from scanner to get document out of it after
|
||||
// end of document dectected by hardware sensor */
|
||||
bytes_to_flush = lines * dev->deseg.raw_line_bytes;
|
||||
bytes_to_flush = lines * dev->session.output_line_bytes_raw;
|
||||
|
||||
/* if we are already close to end of scan, flushing isn't needed */
|
||||
if (bytes_to_flush < read_bytes_left)
|
||||
|
|
|
@ -812,9 +812,6 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
}
|
||||
|
||||
/* words(16bit) before gamma, conversion to 8 bit or lineart*/
|
||||
words_per_line = (session.optical_pixels_raw * session.params.xres) /
|
||||
sensor.optical_res / session.segment_count;
|
||||
dev->deseg.raw_line_bytes = multiply_by_depth_ceil(words_per_line, session.params.depth);
|
||||
dev->deseg.pixel_groups = multiply_by_depth_ceil(dev->deseg.pixel_groups, session.params.depth);
|
||||
|
||||
dev->deseg.curr_byte = 0;
|
||||
|
@ -831,17 +828,16 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
|
||||
DBG (DBG_io2, "%s: pixels =%d\n", __func__, session.optical_pixels);
|
||||
DBG (DBG_io2, "%s: depth =%d\n", __func__, session.params.depth);
|
||||
DBG (DBG_io2, "%s: dev->bpl =%lu\n", __func__, (unsigned long) dev->deseg.raw_line_bytes);
|
||||
DBG (DBG_io2, "%s: dev->len =%lu\n", __func__, (unsigned long) dev->deseg.pixel_groups);
|
||||
DBG (DBG_io2, "%s: dev->segnb =%lu\n", __func__, (unsigned long) dev->session.segment_count);
|
||||
|
||||
// BUG: we shouldn't multiply by channels here
|
||||
dev->oe_buffer.clear();
|
||||
dev->oe_buffer.alloc(dev->deseg.raw_line_bytes * session.params.channels);
|
||||
dev->oe_buffer.alloc(session.output_line_bytes_raw * session.params.channels);
|
||||
|
||||
/* MAXWD is expressed in 4 words unit */
|
||||
// BUG: we shouldn't multiply by channels here
|
||||
reg->set24(REG_MAXWD, (dev->deseg.raw_line_bytes * session.params.channels >> 2));
|
||||
reg->set24(REG_MAXWD, (session.output_line_bytes_raw * session.params.channels >> 2));
|
||||
|
||||
reg->set16(REG_LPERIOD, exposure_time);
|
||||
DBG (DBG_io2, "%s: exposure_time used=%d\n", __func__, exposure_time);
|
||||
|
|
|
@ -827,10 +827,6 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
}*/
|
||||
}
|
||||
|
||||
/* words(16bit) before gamma, conversion to 8 bit or lineart*/
|
||||
dev->deseg.raw_line_bytes = multiply_by_depth_ceil(
|
||||
(session.optical_pixels_raw * session.params.xres) / sensor.optical_res / session.segment_count,
|
||||
session.params.depth);
|
||||
dev->deseg.pixel_groups = multiply_by_depth_ceil(dev->deseg.pixel_groups, session.params.depth);
|
||||
|
||||
dev->deseg.curr_byte = 0;
|
||||
|
@ -847,16 +843,16 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
|
||||
DBG (DBG_io2, "%s: pixels =%d\n", __func__, session.optical_pixels);
|
||||
DBG (DBG_io2, "%s: depth =%d\n", __func__, session.params.depth);
|
||||
DBG (DBG_io2, "%s: dev->bpl =%lu\n", __func__, (unsigned long) dev->deseg.raw_line_bytes);
|
||||
DBG (DBG_io2, "%s: dev->len =%lu\n", __func__, (unsigned long) dev->deseg.pixel_groups);
|
||||
DBG (DBG_io2, "%s: dev->segnb =%lu\n", __func__, (unsigned long) dev->session.segment_count);
|
||||
|
||||
// BUG: we shouldn't multiply by channels here
|
||||
dev->oe_buffer.clear();
|
||||
dev->oe_buffer.alloc(dev->deseg.raw_line_bytes * session.params.channels);
|
||||
dev->oe_buffer.alloc(session.output_line_bytes_raw * session.params.channels);
|
||||
|
||||
/* MAXWD is expressed in 4 words unit */
|
||||
reg->set24(REG_MAXWD, (dev->deseg.raw_line_bytes * session.params.channels >> 2));
|
||||
// BUG: we shouldn't multiply by channels here
|
||||
reg->set24(REG_MAXWD, (session.output_line_bytes_raw * session.params.channels >> 2));
|
||||
|
||||
reg->set16(REG_LPERIOD, exposure_time);
|
||||
DBG(DBG_io2, "%s: exposure_time used=%d\n", __func__, exposure_time);
|
||||
|
|
|
@ -1325,8 +1325,14 @@ void compute_session(Genesys_Device* dev, ScanSession& s, const Genesys_Sensor&
|
|||
}
|
||||
|
||||
s.optical_pixels_raw = s.optical_pixels;
|
||||
s.output_line_bytes_raw = s.output_line_bytes;
|
||||
s.conseq_pixel_dist_bytes = 0;
|
||||
|
||||
if (dev->model->asic_type == AsicType::GL646) {
|
||||
// BUG: most likely segmented sensors were never used, so incorrect value was supplied
|
||||
s.output_line_bytes_raw = s.output_channel_bytes;
|
||||
}
|
||||
|
||||
if (dev->model->asic_type == AsicType::GL845 ||
|
||||
dev->model->asic_type == AsicType::GL846 ||
|
||||
dev->model->asic_type == AsicType::GL847)
|
||||
|
@ -1345,6 +1351,15 @@ void compute_session(Genesys_Device* dev, ScanSession& s, const Genesys_Sensor&
|
|||
s.conseq_pixel_dist_bytes = multiply_by_depth_ceil(s.conseq_pixel_dist_bytes,
|
||||
s.params.depth);
|
||||
}
|
||||
|
||||
s.output_line_bytes_raw = multiply_by_depth_ceil(
|
||||
(s.optical_pixels_raw * s.output_resolution) / sensor.optical_res / s.segment_count,
|
||||
s.params.depth);
|
||||
}
|
||||
|
||||
if (dev->model->asic_type == AsicType::GL124) {
|
||||
s.output_line_bytes_raw = multiply_by_depth_ceil(s.output_pixels / s.ccd_size_divisor,
|
||||
s.params.depth);
|
||||
}
|
||||
|
||||
// TODO: gl124 conseq_pixel_dist_bytes
|
||||
|
@ -2029,6 +2044,7 @@ void debug_dump(unsigned level, const ScanSession& session)
|
|||
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);
|
||||
DBG(level, " output_line_bytes_raw : %d\n", session.output_line_bytes_raw);
|
||||
DBG(level, " output_line_count : %d\n", session.output_line_count);
|
||||
DBG(level, " num_staggered_lines : %d\n", session.num_staggered_lines);
|
||||
DBG(level, " max_color_shift_lines : %d\n", session.max_color_shift_lines);
|
||||
|
|
|
@ -238,15 +238,19 @@ struct ScanSession {
|
|||
// gl843-only
|
||||
unsigned output_resolution = 0;
|
||||
|
||||
// the number of pixels in output data
|
||||
// the number of pixels in output data (after desegmentation)
|
||||
unsigned output_pixels = 0;
|
||||
|
||||
// the number of bytes in the output of a channel of a single line
|
||||
// the number of bytes in the output of a channel of a single line (after desegmentation)
|
||||
unsigned output_channel_bytes = 0;
|
||||
|
||||
// the number of bytes in the output of a single line
|
||||
// the number of bytes in the output of a single line (after desegmentation)
|
||||
unsigned output_line_bytes = 0;
|
||||
|
||||
// the number of bytes per line in the output data from the scanner (before desegmentation)
|
||||
// Equal to output_line_bytes if sensor does not have segments
|
||||
unsigned output_line_bytes_raw = 0;
|
||||
|
||||
// the number of lines in the output of the scanner. This must be larger than the user
|
||||
// requested number due to line staggering and color channel shifting.
|
||||
unsigned output_line_count = 0;
|
||||
|
|
Ładowanie…
Reference in New Issue