genesys: Use common code path to compute ..._segment_pixel_group_count

merge-requests/169/head
Povilas Kanapickas 2019-09-12 22:21:58 +03:00
rodzic 4870a9f975
commit 192dd886cd
8 zmienionych plików z 25 dodań i 26 usunięć

Wyświetl plik

@ -3432,7 +3432,7 @@ static void genesys_fill_line_interp_buffer(Genesys_Device* dev, uint8_t* work_b
dev->deseg.curr_byte++;
/* go to next line if needed */
if (dev->deseg.curr_byte == dev->deseg.pixel_groups) {
if (dev->deseg.curr_byte == dev->session.output_segment_pixel_group_count) {
dev->oe_buffer.set_pos(dev->oe_buffer.pos() + dev->session.output_line_bytes_raw);
dev->deseg.curr_byte = 0;
dev->line_count++;
@ -3475,7 +3475,7 @@ static void genesys_fill_segmented_buffer(Genesys_Device* dev, uint8_t* work_buf
while (count < size)
{
if (depth==1) {
while (dev->deseg.curr_byte < dev->deseg.pixel_groups && count < size) {
while (dev->deseg.curr_byte < dev->session.output_segment_pixel_group_count && count < size) {
for (unsigned n = 0; n < dev->session.segment_count; n++) {
work_buffer_dst[count+n] = 0;
}
@ -3496,7 +3496,7 @@ static void genesys_fill_segmented_buffer(Genesys_Device* dev, uint8_t* work_buf
}
}
if (depth==8) {
while (dev->deseg.curr_byte < dev->deseg.pixel_groups && count < size) {
while (dev->deseg.curr_byte < dev->session.output_segment_pixel_group_count && count < size) {
for (unsigned n = 0; n < dev->session.segment_count; n++) {
work_buffer_dst[count+n] = dev->oe_buffer.get_read_pos()[dev->deseg.curr_byte + dev->deseg.skip_bytes + dev->session.conseq_pixel_dist_bytes *dev->segment_order[n]];
}
@ -3506,7 +3506,7 @@ static void genesys_fill_segmented_buffer(Genesys_Device* dev, uint8_t* work_buf
}
}
if (depth==16) {
while (dev->deseg.curr_byte < dev->deseg.pixel_groups && count < size) {
while (dev->deseg.curr_byte < dev->session.output_segment_pixel_group_count && count < size) {
for (unsigned n = 0; n < dev->session.segment_count; n++) {
work_buffer_dst[count+n*2] = dev->oe_buffer.get_read_pos()[dev->deseg.curr_byte + dev->deseg.skip_bytes + dev->session.conseq_pixel_dist_bytes * dev->segment_order[n]];
work_buffer_dst[count+n*2+1] = dev->oe_buffer.get_read_pos()[dev->deseg.curr_byte + dev->deseg.skip_bytes + dev->session.conseq_pixel_dist_bytes * dev->segment_order[n] + 1];
@ -3518,7 +3518,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) {
if (dev->deseg.curr_byte == dev->session.output_segment_pixel_group_count) {
dev->oe_buffer.set_pos(dev->oe_buffer.pos() + dev->session.output_line_bytes_raw);
dev->deseg.curr_byte = 0;
}

Wyświetl plik

@ -198,10 +198,6 @@ struct DesegmentationState
// The number of bytes to skip at start of line. Currently it's always zero.
unsigned skip_bytes = 0;
// The number of "even" pixels to scan. This corresponds to the number of pixels that will be
// scanned from a single segment
unsigned pixel_groups = 0;
// The current byte during desegmentation process
unsigned curr_byte = 0;
};

Wyświetl plik

@ -947,13 +947,11 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
dev->deseg.curr_byte = 0;
dev->deseg.skip_bytes = 0;
dev->deseg.pixel_groups = 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->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

Wyświetl plik

@ -1159,7 +1159,6 @@ static void gl843_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->len =%lu\n", __func__, (unsigned long) dev->deseg.pixel_groups);
/* MAXWD is expressed in 2 words unit */
/* nousedspace = (mem_bank_range * 1024 / 256 -1 ) * 4; */

Wyświetl plik

@ -684,7 +684,6 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
const ScanSession& session)
{
DBG_HELPER_ARGS(dbg, "exposure_time=%d", exposure_time);
unsigned int words_per_line;
unsigned int dpihw;
GenesysRegister *r;
@ -713,8 +712,6 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
// 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 = session.optical_pixels /
(session.hwdpi_divisor * session.segment_count * ccd_pixels_per_system_pixel);
dev->deseg.skip_bytes = 0;
gl846_set_fe(dev, sensor, AFE_SET);
@ -811,9 +808,6 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
}*/
}
/* words(16bit) before gamma, conversion to 8 bit or lineart*/
dev->deseg.pixel_groups = multiply_by_depth_ceil(dev->deseg.pixel_groups, session.params.depth);
dev->deseg.curr_byte = 0;
dev->line_interp = 0;
@ -828,8 +822,6 @@ 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->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();

Wyświetl plik

@ -729,8 +729,6 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
// 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 = session.optical_pixels /
(session.hwdpi_divisor * session.segment_count * ccd_pixels_per_system_pixel);
dev->deseg.skip_bytes = 0;
gl847_set_fe(dev, sensor, AFE_SET);
@ -827,8 +825,6 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
}*/
}
dev->deseg.pixel_groups = multiply_by_depth_ceil(dev->deseg.pixel_groups, session.params.depth);
dev->deseg.curr_byte = 0;
dev->line_interp = 0;
@ -843,8 +839,6 @@ 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->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();

Wyświetl plik

@ -1363,6 +1363,19 @@ void compute_session(Genesys_Device* dev, ScanSession& s, const Genesys_Sensor&
s.conseq_pixel_dist_bytes = s.output_line_bytes_raw / s.segment_count;
}
s.output_segment_pixel_group_count = 0;
if (dev->model->asic_type == AsicType::GL124) {
s.output_segment_pixel_group_count = s.output_line_bytes_raw / s.segment_count;
}
if (dev->model->asic_type == AsicType::GL845 ||
dev->model->asic_type == AsicType::GL846 ||
dev->model->asic_type == AsicType::GL847)
{
s.output_segment_pixel_group_count = multiply_by_depth_ceil(
s.optical_pixels / (s.hwdpi_divisor * s.segment_count * ccd_pixels_per_system_pixel),
s.params.depth);
}
compute_session_buffer_sizes(dev->model->asic_type, s);
}
@ -2052,6 +2065,8 @@ void debug_dump(unsigned level, const ScanSession& session)
DBG(level, " pixel_startx : %d\n", session.pixel_startx);
DBG(level, " pixel_endx : %d\n", session.pixel_endx);
DBG(level, " conseq_pixel_dist_bytes : %d\n", session.conseq_pixel_dist_bytes);
DBG(level, " output_segment_pixel_group_count : %d\n",
session.output_segment_pixel_group_count);
DBG(level, " buffer_size_read : %zu\n", session.buffer_size_read);
DBG(level, " buffer_size_read : %zu\n", session.buffer_size_lines);
DBG(level, " buffer_size_shrink : %zu\n", session.buffer_size_shrink);

Wyświetl plik

@ -276,6 +276,11 @@ struct ScanSession {
// only on gl124, gl846, gl847
unsigned conseq_pixel_dist_bytes = 0;
// The number of "even" pixels to scan. This corresponds to the number of pixels that will be
// scanned from a single segment
// only on gl124, gl846, gl847
unsigned output_segment_pixel_group_count = 0;
// the sizes of the corresponding buffers
size_t buffer_size_read = 0;
size_t buffer_size_lines = 0;