kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Use common code path to compute ..._segment_pixel_group_count
rodzic
4870a9f975
commit
192dd886cd
|
@ -3432,7 +3432,7 @@ static void genesys_fill_line_interp_buffer(Genesys_Device* dev, uint8_t* work_b
|
||||||
dev->deseg.curr_byte++;
|
dev->deseg.curr_byte++;
|
||||||
|
|
||||||
/* go to next line if needed */
|
/* 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->oe_buffer.set_pos(dev->oe_buffer.pos() + dev->session.output_line_bytes_raw);
|
||||||
dev->deseg.curr_byte = 0;
|
dev->deseg.curr_byte = 0;
|
||||||
dev->line_count++;
|
dev->line_count++;
|
||||||
|
@ -3475,7 +3475,7 @@ static void genesys_fill_segmented_buffer(Genesys_Device* dev, uint8_t* work_buf
|
||||||
while (count < size)
|
while (count < size)
|
||||||
{
|
{
|
||||||
if (depth==1) {
|
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++) {
|
for (unsigned n = 0; n < dev->session.segment_count; n++) {
|
||||||
work_buffer_dst[count+n] = 0;
|
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) {
|
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++) {
|
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]];
|
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) {
|
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++) {
|
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] = 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];
|
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 */
|
/* 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->oe_buffer.set_pos(dev->oe_buffer.pos() + dev->session.output_line_bytes_raw);
|
||||||
dev->deseg.curr_byte = 0;
|
dev->deseg.curr_byte = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,10 +198,6 @@ struct DesegmentationState
|
||||||
// The number of bytes to skip at start of line. Currently it's always zero.
|
// The number of bytes to skip at start of line. Currently it's always zero.
|
||||||
unsigned skip_bytes = 0;
|
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
|
// The current byte during desegmentation process
|
||||||
unsigned curr_byte = 0;
|
unsigned curr_byte = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -947,13 +947,11 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
||||||
|
|
||||||
dev->deseg.curr_byte = 0;
|
dev->deseg.curr_byte = 0;
|
||||||
dev->deseg.skip_bytes = 0;
|
dev->deseg.skip_bytes = 0;
|
||||||
dev->deseg.pixel_groups = session.output_line_bytes_raw / session.segment_count;
|
|
||||||
dev->line_count = 0;
|
dev->line_count = 0;
|
||||||
dev->line_interp = 0;
|
dev->line_interp = 0;
|
||||||
|
|
||||||
DBG (DBG_io2, "%s: pixels =%d\n", __func__, session.optical_pixels);
|
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: 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);
|
DBG (DBG_io2, "%s: dev->line_interp=%lu\n", __func__, (unsigned long)dev->line_interp);
|
||||||
|
|
||||||
// BUG: we shouldn't multiply by channels here
|
// BUG: we shouldn't multiply by channels here
|
||||||
|
|
|
@ -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: pixels =%d\n", __func__, session.optical_pixels);
|
||||||
DBG(DBG_io2, "%s: depth =%d\n", __func__, session.params.depth);
|
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 */
|
/* MAXWD is expressed in 2 words unit */
|
||||||
/* nousedspace = (mem_bank_range * 1024 / 256 -1 ) * 4; */
|
/* nousedspace = (mem_bank_range * 1024 / 256 -1 ) * 4; */
|
||||||
|
|
|
@ -684,7 +684,6 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
||||||
const ScanSession& session)
|
const ScanSession& session)
|
||||||
{
|
{
|
||||||
DBG_HELPER_ARGS(dbg, "exposure_time=%d", exposure_time);
|
DBG_HELPER_ARGS(dbg, "exposure_time=%d", exposure_time);
|
||||||
unsigned int words_per_line;
|
|
||||||
unsigned int dpihw;
|
unsigned int dpihw;
|
||||||
GenesysRegister *r;
|
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
|
// compute pixel coordinate in the given dpihw space, taking segments into account
|
||||||
startx /= session.hwdpi_divisor * session.segment_count;
|
startx /= session.hwdpi_divisor * session.segment_count;
|
||||||
endx /= 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;
|
dev->deseg.skip_bytes = 0;
|
||||||
|
|
||||||
gl846_set_fe(dev, sensor, AFE_SET);
|
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->deseg.curr_byte = 0;
|
||||||
dev->line_interp = 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: pixels =%d\n", __func__, session.optical_pixels);
|
||||||
DBG (DBG_io2, "%s: depth =%d\n", __func__, session.params.depth);
|
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
|
// BUG: we shouldn't multiply by channels here
|
||||||
dev->oe_buffer.clear();
|
dev->oe_buffer.clear();
|
||||||
|
|
|
@ -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
|
// compute pixel coordinate in the given dpihw space, taking segments into account
|
||||||
startx /= session.hwdpi_divisor * session.segment_count;
|
startx /= session.hwdpi_divisor * session.segment_count;
|
||||||
endx /= 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;
|
dev->deseg.skip_bytes = 0;
|
||||||
|
|
||||||
gl847_set_fe(dev, sensor, AFE_SET);
|
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->deseg.curr_byte = 0;
|
||||||
dev->line_interp = 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: pixels =%d\n", __func__, session.optical_pixels);
|
||||||
DBG (DBG_io2, "%s: depth =%d\n", __func__, session.params.depth);
|
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
|
// BUG: we shouldn't multiply by channels here
|
||||||
dev->oe_buffer.clear();
|
dev->oe_buffer.clear();
|
||||||
|
|
|
@ -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.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);
|
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_startx : %d\n", session.pixel_startx);
|
||||||
DBG(level, " pixel_endx : %d\n", session.pixel_endx);
|
DBG(level, " pixel_endx : %d\n", session.pixel_endx);
|
||||||
DBG(level, " conseq_pixel_dist_bytes : %d\n", session.conseq_pixel_dist_bytes);
|
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_read);
|
||||||
DBG(level, " buffer_size_read : %zu\n", session.buffer_size_lines);
|
DBG(level, " buffer_size_read : %zu\n", session.buffer_size_lines);
|
||||||
DBG(level, " buffer_size_shrink : %zu\n", session.buffer_size_shrink);
|
DBG(level, " buffer_size_shrink : %zu\n", session.buffer_size_shrink);
|
||||||
|
|
|
@ -276,6 +276,11 @@ struct ScanSession {
|
||||||
// only on gl124, gl846, gl847
|
// only on gl124, gl846, gl847
|
||||||
unsigned conseq_pixel_dist_bytes = 0;
|
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
|
// the sizes of the corresponding buffers
|
||||||
size_t buffer_size_read = 0;
|
size_t buffer_size_read = 0;
|
||||||
size_t buffer_size_lines = 0;
|
size_t buffer_size_lines = 0;
|
||||||
|
|
Ładowanie…
Reference in New Issue