genesys: Move desegmentation line width data to a separate struct

merge-requests/162/head
Povilas Kanapickas 2019-09-12 21:26:52 +03:00
rodzic 827c3a049d
commit dd70296827
8 zmienionych plików z 53 dodań i 50 usunięć

Wyświetl plik

@ -3434,7 +3434,7 @@ static void genesys_fill_line_interp_buffer(Genesys_Device* dev, uint8_t* work_b
/* go to next line if needed */
if (dev->cur == dev->len)
{
dev->oe_buffer.set_pos(dev->oe_buffer.pos() + dev->bpl);
dev->oe_buffer.set_pos(dev->oe_buffer.pos() + dev->deseg.raw_channel_bytes);
dev->cur = 0;
dev->line_count++;
}
@ -3521,7 +3521,7 @@ static void genesys_fill_segmented_buffer(Genesys_Device* dev, uint8_t* work_buf
/* go to next line if needed */
if (dev->cur == dev->len)
{
dev->oe_buffer.set_pos(dev->oe_buffer.pos() + dev->bpl);
dev->oe_buffer.set_pos(dev->oe_buffer.pos() + dev->deseg.raw_channel_bytes);
dev->cur = 0;
}

Wyświetl plik

@ -192,6 +192,15 @@ struct Genesys_Model
}
};
// Describes the geometry of the raw data coming out of the scanner for desegmentation.
struct DesegmentationState
{
// total bytes in a channel received from a scanner
unsigned raw_channel_bytes = 0;
// total bytes in a line received from a scanner
unsigned raw_line_bytes = 0;
};
/**
* Describes the current device status for the backend
* session. This should be more accurately called
@ -283,15 +292,16 @@ 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 `wpl` which corresponds to this information on certain scanners.
// scanners, see `deseg.raw_line_bytes` which corresponds to this information on certain
// scanners.
size_t read_bytes_left_after_deseg = 0;
// total bytes read sent to frontend
size_t total_bytes_read = 0;
// total bytes read to be sent to frontend
size_t total_bytes_to_read = 0;
// asic's word per line
size_t wpl = 0;
DesegmentationState deseg;
// contains the real used values
Genesys_Current_Setup current_setup;
@ -315,8 +325,6 @@ struct Genesys_Device
int line_interp = 0;
// number of scan lines used during scan
int line_count = 0;
// bytes per full scan widthline
size_t bpl = 0;
// bytes distance between an odd and an even pixel
size_t dist = 0;
// number of even pixels

Wyświetl plik

@ -828,7 +828,7 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
{
DBG_HELPER_ARGS(dbg, "exposure_time=%d, start=%d\n",
exposure_time, start);
unsigned int words_per_line, segcnt;
unsigned int segcnt;
unsigned int startx, endx, segnb;
unsigned int dpihw, factor;
GenesysRegister *r;
@ -991,35 +991,34 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
DBG (DBG_io2, "%s: endpixel used=%d\n", __func__, endx/segnb);
// words(16bit) before gamma, conversion to 8 bit or lineart
words_per_line = multiply_by_depth_ceil(session.output_pixels / session.ccd_size_divisor,
session.params.depth);
dev->deseg.raw_channel_bytes =
multiply_by_depth_ceil(session.output_pixels / session.ccd_size_divisor,
session.params.depth);
dev->bpl = words_per_line;
dev->cur = 0;
dev->skip = 0;
dev->len = dev->bpl/segnb;
dev->dist = dev->bpl/segnb;
dev->len = dev->deseg.raw_channel_bytes / segnb;
dev->dist = dev->deseg.raw_channel_bytes / segnb;
dev->segnb = segnb;
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->bpl);
DBG (DBG_io2, "%s: dev->bpl =%lu\n", __func__, (unsigned long) dev->deseg.raw_channel_bytes);
DBG (DBG_io2, "%s: dev->len =%lu\n", __func__, (unsigned long)dev->len);
DBG (DBG_io2, "%s: dev->dist =%lu\n", __func__, (unsigned long)dev->dist);
DBG (DBG_io2, "%s: dev->line_interp=%lu\n", __func__, (unsigned long)dev->line_interp);
words_per_line *= session.params.channels;
dev->wpl = words_per_line;
dev->deseg.raw_line_bytes = dev->deseg.raw_channel_bytes * session.params.channels;
/* allocate buffer for odd/even pixels handling */
dev->oe_buffer.clear();
dev->oe_buffer.alloc(dev->wpl);
dev->oe_buffer.alloc(dev->deseg.raw_line_bytes);
/* MAXWD is expressed in 2 words unit */
reg->set24(REG_MAXWD, words_per_line);
DBG (DBG_io2, "%s: words_per_line used=%d\n", __func__, words_per_line);
// MAXWD is expressed in 2 words unit
reg->set24(REG_MAXWD, dev->deseg.raw_line_bytes);
DBG (DBG_io2, "%s: words_per_line used=%d\n", __func__, dev->deseg.raw_line_bytes);
reg->set24(REG_LPERIOD, exposure_time);
DBG (DBG_io2, "%s: exposure_time used=%d\n", __func__, exposure_time);

Wyświetl plik

@ -563,8 +563,8 @@ 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->bpl = session.output_channel_bytes;
dev->wpl = session.output_line_bytes;
dev->deseg.raw_channel_bytes = session.output_channel_bytes;
dev->deseg.raw_line_bytes = session.output_line_bytes;
regs->set24(REG_MAXWD, session.output_line_bytes);
@ -1511,7 +1511,8 @@ 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->wpl;
bytes_left += lines * dev->deseg.raw_line_bytes;
if (dev->session.params.depth > 8) {
bytes_left = 2 * bytes_left;
}

Wyświetl plik

@ -1604,8 +1604,8 @@ 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->wpl = session.output_line_bytes;
dev->bpl = session.output_line_bytes;
dev->deseg.raw_line_bytes = session.output_line_bytes;
dev->deseg.raw_channel_bytes = session.output_line_bytes;
reg->set24(REG_MAXWD, session.output_line_bytes);
@ -2442,7 +2442,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->wpl;
total_bytes_to_read=(scancnt+postcnt) * dev->deseg.raw_line_bytes;
DBG(DBG_io, "%s: old total_bytes_to_read=%u\n", __func__,
(unsigned int)dev->total_bytes_to_read);

Wyświetl plik

@ -1157,12 +1157,12 @@ 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->wpl = session.output_channel_bytes; // FIXME: this is not currently used
dev->bpl = session.output_channel_bytes; // FIXME: this is not currently used
dev->deseg.raw_line_bytes = session.output_channel_bytes; // FIXME: this is not currently used
dev->deseg.raw_channel_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->bpl);
DBG(DBG_io2, "%s: dev->bpl =%lu\n", __func__, (unsigned long) dev->deseg.raw_channel_bytes);
DBG(DBG_io2, "%s: dev->len =%lu\n", __func__, (unsigned long)dev->len);
DBG(DBG_io2, "%s: dev->dist =%lu\n", __func__, (unsigned long)dev->dist);
@ -1588,9 +1588,9 @@ static void gl843_detect_document_end(Genesys_Device* dev)
DBG(DBG_io, "%s: adding %d line to flush\n", __func__, lines);
/* 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->wpl;
// 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;
/* if we are already close to end of scan, flushing isn't needed */
if (bytes_to_flush < read_bytes_left)

Wyświetl plik

@ -871,11 +871,10 @@ 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 = (used_pixels * session.params.xres * ccd_pixels_per_system_pixel) / sensor.get_register_hwdpi(session.params.xres * ccd_pixels_per_system_pixel);
words_per_line = multiply_by_depth_ceil(words_per_line, session.params.depth);
dev->deseg.raw_channel_bytes = multiply_by_depth_ceil(words_per_line, session.params.depth);
dev->len = multiply_by_depth_ceil(dev->len, session.params.depth);
dev->dist = multiply_by_depth_ceil(dev->dist, session.params.depth);
dev->bpl = words_per_line;
dev->cur=0;
dev->segnb=segnb;
dev->line_interp = 0;
@ -892,20 +891,19 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
DBG (DBG_io2, "%s: used_pixels=%d\n", __func__, used_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: dev->bpl =%lu\n", __func__, (unsigned long)dev->bpl);
DBG (DBG_io2, "%s: dev->bpl =%lu\n", __func__, (unsigned long) dev->deseg.raw_channel_bytes);
DBG (DBG_io2, "%s: dev->len =%lu\n", __func__, (unsigned long)dev->len);
DBG (DBG_io2, "%s: dev->dist =%lu\n", __func__, (unsigned long)dev->dist);
DBG (DBG_io2, "%s: dev->segnb =%lu\n", __func__, (unsigned long)dev->segnb);
words_per_line *= session.params.channels;
dev->wpl = words_per_line;
dev->deseg.raw_line_bytes = dev->deseg.raw_channel_bytes * session.params.channels;
dev->oe_buffer.clear();
dev->oe_buffer.alloc(dev->wpl);
dev->oe_buffer.alloc(dev->deseg.raw_line_bytes);
/* MAXWD is expressed in 4 words unit */
reg->set24(REG_MAXWD, (words_per_line >> 2));
DBG (DBG_io2, "%s: words_per_line used=%d\n", __func__, words_per_line);
reg->set24(REG_MAXWD, (dev->deseg.raw_line_bytes >> 2));
DBG(DBG_io2, "%s: words_per_line used=%d\n", __func__, dev->deseg.raw_line_bytes);
reg->set16(REG_LPERIOD, exposure_time);
DBG (DBG_io2, "%s: exposure_time used=%d\n", __func__, exposure_time);

Wyświetl plik

@ -744,7 +744,6 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
const ScanSession& session, unsigned int start)
{
DBG_HELPER_ARGS(dbg, "exposure_time=%d, start=%d", exposure_time, start);
unsigned int words_per_line;
unsigned dpiset, dpihw, segnb, factor;
GenesysRegister *r;
@ -890,12 +889,11 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
}
/* words(16bit) before gamma, conversion to 8 bit or lineart*/
words_per_line = (used_pixels * dpiset) / dpihw;
words_per_line = multiply_by_depth_ceil(words_per_line, session.params.depth);
dev->deseg.raw_channel_bytes = multiply_by_depth_ceil((used_pixels * dpiset) / dpihw,
session.params.depth);
dev->len = multiply_by_depth_ceil(dev->len, session.params.depth);
dev->dist = multiply_by_depth_ceil(dev->dist, session.params.depth);
dev->bpl = words_per_line;
dev->cur=0;
dev->segnb=segnb;
dev->line_interp = 0;
@ -911,20 +909,19 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
DBG (DBG_io2, "%s: used_pixels=%d\n", __func__, used_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: dev->bpl =%lu\n", __func__, (unsigned long)dev->bpl);
DBG (DBG_io2, "%s: dev->bpl =%lu\n", __func__, (unsigned long) dev->deseg.raw_channel_bytes);
DBG (DBG_io2, "%s: dev->len =%lu\n", __func__, (unsigned long)dev->len);
DBG (DBG_io2, "%s: dev->dist =%lu\n", __func__, (unsigned long)dev->dist);
DBG (DBG_io2, "%s: dev->segnb =%lu\n", __func__, (unsigned long)dev->segnb);
words_per_line *= session.params.channels;
dev->wpl = words_per_line;
dev->deseg.raw_line_bytes = dev->deseg.raw_channel_bytes * session.params.channels;
dev->oe_buffer.clear();
dev->oe_buffer.alloc(dev->wpl);
dev->oe_buffer.alloc(dev->deseg.raw_line_bytes);
/* MAXWD is expressed in 4 words unit */
reg->set24(REG_MAXWD, (words_per_line >> 2));
DBG(DBG_io2, "%s: words_per_line used=%d\n", __func__, words_per_line);
reg->set24(REG_MAXWD, (dev->deseg.raw_line_bytes >> 2));
DBG(DBG_io2, "%s: words_per_line used=%d\n", __func__, dev->deseg.raw_line_bytes);
reg->set16(REG_LPERIOD, exposure_time);
DBG(DBG_io2, "%s: exposure_time used=%d\n", __func__, exposure_time);