kopia lustrzana https://gitlab.com/sane-project/backends
Merge branch 'genesys-desegmetation-refactor' into 'master'
genesys: Simplify desegmentation state (part 2) See merge request sane-project/backends!162merge-requests/163/merge
commit
37b60ada83
|
@ -3424,18 +3424,17 @@ static void genesys_fill_line_interp_buffer(Genesys_Device* dev, uint8_t* work_b
|
|||
// dev->line_interp holds the number of lines scanned for one line of data sent
|
||||
if (((dev->line_count / dev->session.params.channels) % dev->line_interp) == 0) {
|
||||
/* copy pixel when line matches */
|
||||
work_buffer_dst[count] = dev->oe_buffer.get_read_pos()[dev->cur];
|
||||
work_buffer_dst[count] = dev->oe_buffer.get_read_pos()[dev->deseg.curr_byte];
|
||||
count++;
|
||||
}
|
||||
|
||||
/* always update pointer so we skip uncopied data */
|
||||
dev->cur++;
|
||||
// always update pointer so we skip uncopied data
|
||||
dev->deseg.curr_byte++;
|
||||
|
||||
/* go to next line if needed */
|
||||
if (dev->cur == dev->len)
|
||||
{
|
||||
dev->oe_buffer.set_pos(dev->oe_buffer.pos() + dev->bpl);
|
||||
dev->cur = 0;
|
||||
if (dev->deseg.curr_byte == dev->deseg.pixel_groups) {
|
||||
dev->oe_buffer.set_pos(dev->oe_buffer.pos() + dev->deseg.raw_channel_bytes);
|
||||
dev->deseg.curr_byte = 0;
|
||||
dev->line_count++;
|
||||
}
|
||||
|
||||
|
@ -3458,7 +3457,7 @@ static void genesys_fill_segmented_buffer(Genesys_Device* dev, uint8_t* work_buf
|
|||
{
|
||||
DBG_HELPER(dbg);
|
||||
size_t count;
|
||||
int depth,i,n,k;
|
||||
int depth, i, k;
|
||||
|
||||
depth = dev->settings.depth;
|
||||
if (dev->settings.scan_mode == ScanColorMode::LINEART && dev->settings.dynamic_lineart==SANE_FALSE)
|
||||
|
@ -3476,53 +3475,52 @@ static void genesys_fill_segmented_buffer(Genesys_Device* dev, uint8_t* work_buf
|
|||
while (count < size)
|
||||
{
|
||||
if (depth==1) {
|
||||
while (dev->cur < dev->len && count < size) {
|
||||
for (n=0; n<dev->segnb; n++) {
|
||||
while (dev->deseg.curr_byte < dev->deseg.pixel_groups && count < size) {
|
||||
for (unsigned n = 0; n < dev->deseg.segment_count; n++) {
|
||||
work_buffer_dst[count+n] = 0;
|
||||
}
|
||||
/* interleaving is at bit level */
|
||||
for (i=0;i<8;i++) {
|
||||
k=count+(i*dev->segnb)/8;
|
||||
for (n=0;n<dev->segnb;n++) {
|
||||
k = count + (i * dev->deseg.segment_count) / 8;
|
||||
for (unsigned n = 0; n < dev->deseg.segment_count; n++) {
|
||||
work_buffer_dst[k] = work_buffer_dst[k] << 1;
|
||||
if ((dev->oe_buffer.get_read_pos()[dev->cur + dev->skip + dev->dist*dev->segment_order[n]])&(128>>i)) {
|
||||
if ((dev->oe_buffer.get_read_pos()[dev->deseg.curr_byte + dev->deseg.skip_bytes + dev->deseg.conseq_pixel_dist_bytes * dev->segment_order[n]])&(128>>i)) {
|
||||
work_buffer_dst[k] |= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* update counter and pointer */
|
||||
count += dev->segnb;
|
||||
dev->cur++;
|
||||
count += dev->deseg.segment_count;
|
||||
dev->deseg.curr_byte++;
|
||||
}
|
||||
}
|
||||
if (depth==8) {
|
||||
while (dev->cur < dev->len && count < size) {
|
||||
for (n=0;n<dev->segnb;n++) {
|
||||
work_buffer_dst[count+n] = dev->oe_buffer.get_read_pos()[dev->cur + dev->skip + dev->dist*dev->segment_order[n]];
|
||||
while (dev->deseg.curr_byte < dev->deseg.pixel_groups && count < size) {
|
||||
for (unsigned n = 0; n < dev->deseg.segment_count; n++) {
|
||||
work_buffer_dst[count+n] = dev->oe_buffer.get_read_pos()[dev->deseg.curr_byte + dev->deseg.skip_bytes + dev->deseg.conseq_pixel_dist_bytes *dev->segment_order[n]];
|
||||
}
|
||||
/* update counter and pointer */
|
||||
count += dev->segnb;
|
||||
dev->cur++;
|
||||
count += dev->deseg.segment_count;
|
||||
dev->deseg.curr_byte++;
|
||||
}
|
||||
}
|
||||
if (depth==16) {
|
||||
while (dev->cur < dev->len && count < size) {
|
||||
for (n=0;n<dev->segnb;n++) {
|
||||
work_buffer_dst[count+n*2] = dev->oe_buffer.get_read_pos()[dev->cur + dev->skip + dev->dist*dev->segment_order[n]];
|
||||
work_buffer_dst[count+n*2+1] = dev->oe_buffer.get_read_pos()[dev->cur + dev->skip + dev->dist*dev->segment_order[n] + 1];
|
||||
while (dev->deseg.curr_byte < dev->deseg.pixel_groups && count < size) {
|
||||
for (unsigned n = 0; n < dev->deseg.segment_count; n++) {
|
||||
work_buffer_dst[count+n*2] = dev->oe_buffer.get_read_pos()[dev->deseg.curr_byte + dev->deseg.skip_bytes + dev->deseg.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->deseg.conseq_pixel_dist_bytes * dev->segment_order[n] + 1];
|
||||
}
|
||||
/* update counter and pointer */
|
||||
count += dev->segnb*2;
|
||||
dev->cur+=2;
|
||||
count += dev->deseg.segment_count * 2;
|
||||
dev->deseg.curr_byte += 2;
|
||||
}
|
||||
}
|
||||
|
||||
/* go to next line if needed */
|
||||
if (dev->cur == dev->len)
|
||||
{
|
||||
dev->oe_buffer.set_pos(dev->oe_buffer.pos() + dev->bpl);
|
||||
dev->cur = 0;
|
||||
if (dev->deseg.curr_byte == dev->deseg.pixel_groups) {
|
||||
dev->oe_buffer.set_pos(dev->oe_buffer.pos() + dev->deseg.raw_channel_bytes);
|
||||
dev->deseg.curr_byte = 0;
|
||||
}
|
||||
|
||||
/* read a new buffer if needed */
|
||||
|
@ -3593,8 +3591,7 @@ static void genesys_fill_read_buffer(Genesys_Device* dev)
|
|||
// line interpolation
|
||||
genesys_fill_line_interp_buffer(dev, work_buffer_dst, size);
|
||||
}
|
||||
else if (dev->segnb>1)
|
||||
{
|
||||
else if (dev->deseg.segment_count > 1) {
|
||||
// multi-segment sensors processing
|
||||
genesys_fill_segmented_buffer(dev, work_buffer_dst, size);
|
||||
}
|
||||
|
@ -5530,7 +5527,7 @@ sane_open_impl(SANE_String_Const devicename, SANE_Handle * handle)
|
|||
s->dev->force_calibration = 0;
|
||||
s->dev->line_interp = 0;
|
||||
s->dev->line_count = 0;
|
||||
s->dev->segnb = 0;
|
||||
s->dev->deseg.segment_count = 0;
|
||||
s->dev->binary=NULL;
|
||||
|
||||
*handle = s;
|
||||
|
|
|
@ -192,6 +192,33 @@ struct Genesys_Model
|
|||
}
|
||||
};
|
||||
|
||||
// Describes the geometry of the raw data coming out of the scanner for desegmentation.
|
||||
struct DesegmentationState
|
||||
{
|
||||
// The number of segments in the sensor
|
||||
unsigned segment_count = 0;
|
||||
|
||||
// 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;
|
||||
|
||||
// Distance in bytes between consecutive pixels, e.g. between odd and even pixels. Note that
|
||||
// the number of segments can be large.
|
||||
unsigned conseq_pixel_dist_bytes = 0;
|
||||
|
||||
// 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;
|
||||
|
||||
// The current byte during desegmentation process
|
||||
unsigned curr_byte = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the current device status for the backend
|
||||
* session. This should be more accurately called
|
||||
|
@ -283,15 +310,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;
|
||||
|
@ -309,22 +337,10 @@ struct Genesys_Device
|
|||
SANE_Int ld_shift_g = 0;
|
||||
// used blue line-distance shift
|
||||
SANE_Int ld_shift_b = 0;
|
||||
// number of segments composing the sensor
|
||||
int segnb = 0;
|
||||
// number of lines used in line interpolation
|
||||
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
|
||||
size_t len = 0;
|
||||
// current pixel position within sub window
|
||||
size_t cur = 0;
|
||||
// number of bytes to skip at start of line
|
||||
size_t skip = 0;
|
||||
|
||||
// array describing the order of the sub-segments of the sensor
|
||||
std::vector<unsigned> segment_order;
|
||||
|
|
|
@ -828,8 +828,8 @@ 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 startx, endx, segnb;
|
||||
unsigned int segcnt;
|
||||
unsigned int startx, endx;
|
||||
unsigned int dpihw, factor;
|
||||
GenesysRegister *r;
|
||||
uint32_t expmax;
|
||||
|
@ -978,48 +978,46 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
|
||||
/* segment number */
|
||||
r = sanei_genesys_get_address (reg, 0x98);
|
||||
segnb = r->value & 0x0f;
|
||||
unsigned segment_count = r->value & 0x0f;
|
||||
|
||||
reg->set24(REG_STRPIXEL, startx / segnb);
|
||||
DBG (DBG_io2, "%s: strpixel used=%d\n", __func__, startx/segnb);
|
||||
reg->set24(REG_STRPIXEL, startx / segment_count);
|
||||
DBG (DBG_io2, "%s: strpixel used=%d\n", __func__, startx / segment_count);
|
||||
segcnt = reg->get24(REG_SEGCNT);
|
||||
if(endx/segnb==segcnt)
|
||||
{
|
||||
if(endx / segment_count == segcnt) {
|
||||
endx=0;
|
||||
}
|
||||
reg->set24(REG_ENDPIXEL, endx / segnb);
|
||||
DBG (DBG_io2, "%s: endpixel used=%d\n", __func__, endx/segnb);
|
||||
reg->set24(REG_ENDPIXEL, endx / segment_count);
|
||||
DBG (DBG_io2, "%s: endpixel used=%d\n", __func__, endx / segment_count);
|
||||
|
||||
// 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->segnb = segnb;
|
||||
dev->deseg.curr_byte = 0;
|
||||
dev->deseg.skip_bytes = 0;
|
||||
dev->deseg.pixel_groups = dev->deseg.raw_channel_bytes / segment_count;
|
||||
dev->deseg.conseq_pixel_dist_bytes = dev->deseg.raw_channel_bytes / segment_count;
|
||||
dev->deseg.segment_count = 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->bpl);
|
||||
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->bpl =%lu\n", __func__, (unsigned long) dev->deseg.raw_channel_bytes);
|
||||
DBG (DBG_io2, "%s: dev->len =%lu\n", __func__, (unsigned long) dev->deseg.pixel_groups);
|
||||
DBG (DBG_io2, "%s: dev->dist =%lu\n", __func__, (unsigned long) dev->deseg.conseq_pixel_dist_bytes);
|
||||
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);
|
||||
|
@ -1211,7 +1209,7 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
|
||||
const SensorProfile& sensor_profile = get_sensor_profile(sensor, dpihw,
|
||||
session.ccd_size_divisor);
|
||||
dev->segnb = sensor_profile.custom_regs.get_value(0x98) & 0x0f;
|
||||
dev->deseg.segment_count = sensor_profile.custom_regs.get_value(0x98) & 0x0f;
|
||||
|
||||
dev->session = session;
|
||||
dev->current_setup.pixels = session.output_pixels;
|
||||
|
@ -1944,7 +1942,9 @@ static void gl124_send_shading_data(Genesys_Device* dev, const Genesys_Sensor& s
|
|||
channels = dev->session.params.channels;
|
||||
if(dev->binary!=NULL)
|
||||
{
|
||||
fprintf(dev->binary,"P5\n%d %d\n%d\n",(endpixel-strpixel)/factor*channels*dev->segnb,lines/channels,255);
|
||||
std::fprintf(dev->binary,"P5\n%d %d\n%d\n",
|
||||
(endpixel - strpixel) / factor * channels * dev->deseg.segment_count,
|
||||
lines / channels, 255);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1955,7 +1955,7 @@ static void gl124_send_shading_data(Genesys_Device* dev, const Genesys_Sensor& s
|
|||
pixels=endpixel-strpixel;
|
||||
|
||||
DBG( DBG_io2, "%s: using chunks of %d bytes (%d shading data pixels)\n",__func__,length, length/4);
|
||||
std::vector<uint8_t> buffer(pixels * dev->segnb, 0);
|
||||
std::vector<uint8_t> buffer(pixels * dev->deseg.segment_count, 0);
|
||||
|
||||
/* write actual red data */
|
||||
for(i=0;i<3;i++)
|
||||
|
@ -1971,8 +1971,7 @@ static void gl124_send_shading_data(Genesys_Device* dev, const Genesys_Sensor& s
|
|||
src=data+x+strpixel+i*length;
|
||||
|
||||
/* iterate over all the segments */
|
||||
switch(dev->segnb)
|
||||
{
|
||||
switch (dev->deseg.segment_count) {
|
||||
case 1:
|
||||
ptr[0+pixels*0]=src[0+segcnt*0];
|
||||
ptr[1+pixels*0]=src[1+segcnt*0];
|
||||
|
@ -2014,7 +2013,7 @@ static void gl124_send_shading_data(Genesys_Device* dev, const Genesys_Sensor& s
|
|||
}
|
||||
uint8_t val = dev->read_register(0xd0+i);
|
||||
addr = val * 8192 + 0x10000000;
|
||||
sanei_genesys_write_ahb(dev, addr, pixels*dev->segnb, buffer.data());
|
||||
sanei_genesys_write_ahb(dev, addr, pixels * dev->deseg.segment_count, buffer.data());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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_line_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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1157,14 +1157,14 @@ 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_line_channel_bytes; // FIXME: this is not currently used
|
||||
dev->bpl = session.output_line_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->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->bpl =%lu\n", __func__, (unsigned long) dev->deseg.raw_channel_bytes);
|
||||
DBG(DBG_io2, "%s: dev->len =%lu\n", __func__, (unsigned long) dev->deseg.pixel_groups);
|
||||
DBG(DBG_io2, "%s: dev->dist =%lu\n", __func__, (unsigned long) dev->deseg.conseq_pixel_dist_bytes);
|
||||
|
||||
/* MAXWD is expressed in 2 words unit */
|
||||
/* nousedspace = (mem_bank_range * 1024 / 256 -1 ) * 4; */
|
||||
|
@ -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)
|
||||
|
|
|
@ -726,7 +726,7 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
{
|
||||
DBG_HELPER_ARGS(dbg, "exposure_time=%d, start=%d", exposure_time, start);
|
||||
unsigned int words_per_line;
|
||||
unsigned int dpihw, segnb, factor;
|
||||
unsigned int dpihw, factor;
|
||||
GenesysRegister *r;
|
||||
|
||||
// resolution is divided according to ccd_pixels_per_system_pixel()
|
||||
|
@ -749,30 +749,26 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
|
||||
/* sensors are built from 600 dpi segments for LiDE 100/200
|
||||
* and 1200 dpi for the 700F */
|
||||
if (dev->model->flags & GENESYS_FLAG_SIS_SENSOR)
|
||||
{
|
||||
segnb=dpihw/600;
|
||||
}
|
||||
else
|
||||
{
|
||||
segnb=1;
|
||||
unsigned segment_count = 1;
|
||||
if (dev->model->flags & GENESYS_FLAG_SIS_SENSOR) {
|
||||
segment_count = dpihw / 600;
|
||||
}
|
||||
|
||||
// compute pixel coordinate in the given dpihw space, taking segments into account
|
||||
startx /= factor*segnb;
|
||||
endx /= factor*segnb;
|
||||
dev->len = endx - startx;
|
||||
dev->dist=0;
|
||||
dev->skip=0;
|
||||
startx /= factor * segment_count;
|
||||
endx /= factor * segment_count;
|
||||
dev->deseg.pixel_groups = endx - startx;
|
||||
dev->deseg.conseq_pixel_dist_bytes = 0;
|
||||
dev->deseg.skip_bytes = 0;
|
||||
|
||||
/* in cas of multi-segments sensor, we have to add the witdh
|
||||
* of the sensor crossed by the scan area */
|
||||
if (dev->model->flags & GENESYS_FLAG_SIS_SENSOR && segnb > 1) {
|
||||
dev->dist = sensor_profile.segment_count;
|
||||
if (dev->model->flags & GENESYS_FLAG_SIS_SENSOR && segment_count > 1) {
|
||||
dev->deseg.conseq_pixel_dist_bytes = sensor_profile.segment_size;
|
||||
}
|
||||
|
||||
/* use a segcnt rounded to next even number */
|
||||
endx += ((dev->dist+1)&0xfffe)*(segnb-1);
|
||||
endx += ((dev->deseg.conseq_pixel_dist_bytes + 1) & 0xfffe) * (segment_count - 1);
|
||||
unsigned used_pixels = endx - startx;
|
||||
|
||||
gl846_set_fe(dev, sensor, AFE_SET);
|
||||
|
@ -871,13 +867,12 @@ 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->len = multiply_by_depth_ceil(dev->len, session.params.depth);
|
||||
dev->dist = multiply_by_depth_ceil(dev->dist, session.params.depth);
|
||||
dev->deseg.raw_channel_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.conseq_pixel_dist_bytes = multiply_by_depth_ceil(dev->deseg.conseq_pixel_dist_bytes, session.params.depth);
|
||||
|
||||
dev->bpl = words_per_line;
|
||||
dev->cur=0;
|
||||
dev->segnb=segnb;
|
||||
dev->deseg.curr_byte = 0;
|
||||
dev->deseg.segment_count = segment_count;
|
||||
dev->line_interp = 0;
|
||||
|
||||
unsigned dpiset = session.params.xres * ccd_pixels_per_system_pixel;
|
||||
|
@ -892,20 +887,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->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);
|
||||
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->deseg.pixel_groups);
|
||||
DBG (DBG_io2, "%s: dev->dist =%lu\n", __func__, (unsigned long) dev->deseg.conseq_pixel_dist_bytes);
|
||||
DBG (DBG_io2, "%s: dev->segnb =%lu\n", __func__, (unsigned long) dev->deseg.segment_count);
|
||||
|
||||
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);
|
||||
|
|
|
@ -744,8 +744,7 @@ 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;
|
||||
unsigned dpiset, dpihw, factor;
|
||||
GenesysRegister *r;
|
||||
|
||||
// resolution is divided according to ccd_pixels_per_system_pixel()
|
||||
|
@ -769,30 +768,26 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
|
||||
/* sensors are built from 600 dpi segments for LiDE 100/200
|
||||
* and 1200 dpi for the 700F */
|
||||
if (dev->model->flags & GENESYS_FLAG_SIS_SENSOR)
|
||||
{
|
||||
segnb=dpihw/600;
|
||||
}
|
||||
else
|
||||
{
|
||||
segnb=1;
|
||||
unsigned segment_count = 1;
|
||||
if (dev->model->flags & GENESYS_FLAG_SIS_SENSOR) {
|
||||
segment_count = dpihw/600;
|
||||
}
|
||||
|
||||
// compute pixel coordinate in the given dpihw space, taking segments into account
|
||||
startx /= factor*segnb;
|
||||
endx /= factor*segnb;
|
||||
dev->len=endx-startx;
|
||||
dev->dist=0;
|
||||
dev->skip=0;
|
||||
startx /= factor * segment_count;
|
||||
endx /= factor * segment_count;
|
||||
dev->deseg.pixel_groups = endx-startx;
|
||||
dev->deseg.conseq_pixel_dist_bytes = 0;
|
||||
dev->deseg.skip_bytes = 0;
|
||||
|
||||
/* in cas of multi-segments sensor, we have to add the witdh
|
||||
* of the sensor crossed by the scan area */
|
||||
if (dev->model->flags & GENESYS_FLAG_SIS_SENSOR && segnb > 1) {
|
||||
dev->dist = sensor_profile.segment_count;
|
||||
if (dev->model->flags & GENESYS_FLAG_SIS_SENSOR && segment_count > 1) {
|
||||
dev->deseg.conseq_pixel_dist_bytes = sensor_profile.segment_size;
|
||||
}
|
||||
|
||||
/* use a segcnt rounded to next even number */
|
||||
endx += ((dev->dist+1)&0xfffe)*(segnb-1);
|
||||
endx += ((dev->deseg.conseq_pixel_dist_bytes + 1) & 0xfffe) * (segment_count - 1);
|
||||
unsigned used_pixels = endx - startx;
|
||||
|
||||
gl847_set_fe(dev, sensor, AFE_SET);
|
||||
|
@ -890,14 +885,13 @@ 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->len = multiply_by_depth_ceil(dev->len, session.params.depth);
|
||||
dev->dist = multiply_by_depth_ceil(dev->dist, session.params.depth);
|
||||
dev->deseg.raw_channel_bytes = multiply_by_depth_ceil((used_pixels * dpiset) / dpihw,
|
||||
session.params.depth);
|
||||
dev->deseg.pixel_groups = multiply_by_depth_ceil(dev->deseg.pixel_groups, session.params.depth);
|
||||
dev->deseg.conseq_pixel_dist_bytes = multiply_by_depth_ceil(dev->deseg.conseq_pixel_dist_bytes, session.params.depth);
|
||||
|
||||
dev->bpl = words_per_line;
|
||||
dev->cur=0;
|
||||
dev->segnb=segnb;
|
||||
dev->deseg.curr_byte = 0;
|
||||
dev->deseg.segment_count = segment_count;
|
||||
dev->line_interp = 0;
|
||||
|
||||
reg->set16(REG_DPISET,dpiset);
|
||||
|
@ -911,20 +905,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->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);
|
||||
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->deseg.pixel_groups);
|
||||
DBG (DBG_io2, "%s: dev->dist =%lu\n", __func__, (unsigned long) dev->deseg.conseq_pixel_dist_bytes);
|
||||
DBG (DBG_io2, "%s: dev->segnb =%lu\n", __func__, (unsigned long) dev->deseg.segment_count);
|
||||
|
||||
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);
|
||||
|
|
|
@ -1280,8 +1280,8 @@ void compute_session(Genesys_Device* dev, ScanSession& s, const Genesys_Sensor&
|
|||
|
||||
s.output_line_count = s.params.lines + s.max_color_shift_lines + s.num_staggered_lines;
|
||||
|
||||
s.output_line_channel_bytes = multiply_by_depth_ceil(s.output_pixels, s.params.depth);
|
||||
s.output_line_bytes = s.output_line_channel_bytes * s.params.channels;
|
||||
s.output_channel_bytes = multiply_by_depth_ceil(s.output_pixels, s.params.depth);
|
||||
s.output_line_bytes = s.output_channel_bytes * s.params.channels;
|
||||
|
||||
compute_session_buffer_sizes(dev->model->asic_type, s);
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ struct SensorProfile
|
|||
unsigned ccd_size_divisor = 1;
|
||||
unsigned exposure_lperiod = 0;
|
||||
SensorExposure exposure;
|
||||
unsigned segment_count = 0; // only on GL846, GL847
|
||||
unsigned segment_size = 0; // only on GL846, GL847
|
||||
std::vector<unsigned> segment_order;
|
||||
GenesysRegisterSettingSet custom_regs;
|
||||
|
||||
|
|
|
@ -238,7 +238,7 @@ struct ScanSession {
|
|||
unsigned output_pixels = 0;
|
||||
|
||||
// the number of bytes in the output of a channel of a single line
|
||||
unsigned output_line_channel_bytes;
|
||||
unsigned output_channel_bytes = 0;
|
||||
|
||||
// the number of bytes in the output of a single line
|
||||
unsigned output_line_bytes = 0;
|
||||
|
|
|
@ -1638,7 +1638,7 @@ void genesys_init_sensor_tables()
|
|||
profile.dpi = 200;
|
||||
profile.exposure_lperiod = 2848;
|
||||
profile.exposure = { 410, 275, 203 };
|
||||
profile.segment_count = 5136;
|
||||
profile.segment_size = 5136;
|
||||
profile.segment_order = {};
|
||||
profile.custom_regs = {
|
||||
{ 0x17, 0x0a },
|
||||
|
@ -1653,7 +1653,7 @@ void genesys_init_sensor_tables()
|
|||
profile.dpi = 300;
|
||||
profile.exposure_lperiod = 1424;
|
||||
profile.exposure = { 410, 275, 203 };
|
||||
profile.segment_count = 5136;
|
||||
profile.segment_size = 5136;
|
||||
profile.segment_order = {};
|
||||
profile.custom_regs = {
|
||||
{ 0x17, 0x0a },
|
||||
|
@ -1668,7 +1668,7 @@ void genesys_init_sensor_tables()
|
|||
profile.dpi = 600;
|
||||
profile.exposure_lperiod = 1432;
|
||||
profile.exposure = { 410, 275, 203 };
|
||||
profile.segment_count = 5136;
|
||||
profile.segment_size = 5136;
|
||||
profile.segment_order = {};
|
||||
profile.custom_regs = {
|
||||
{ 0x17, 0x0a },
|
||||
|
@ -1683,7 +1683,7 @@ void genesys_init_sensor_tables()
|
|||
profile.dpi = 1200;
|
||||
profile.exposure_lperiod = 2712;
|
||||
profile.exposure = { 746, 478, 353 };
|
||||
profile.segment_count = 5136;
|
||||
profile.segment_size = 5136;
|
||||
profile.segment_order = {0, 1};
|
||||
profile.custom_regs = {
|
||||
{ 0x17, 0x08 },
|
||||
|
@ -1698,7 +1698,7 @@ void genesys_init_sensor_tables()
|
|||
profile.dpi = 2400;
|
||||
profile.exposure_lperiod = 5280;
|
||||
profile.exposure = { 1417, 909, 643 };
|
||||
profile.segment_count = 5136;
|
||||
profile.segment_size = 5136;
|
||||
profile.segment_order = {0, 2, 1, 3};
|
||||
profile.custom_regs = {
|
||||
{ 0x17, 0x06 },
|
||||
|
@ -1713,7 +1713,7 @@ void genesys_init_sensor_tables()
|
|||
profile.dpi = 4800;
|
||||
profile.exposure_lperiod = 10416;
|
||||
profile.exposure = { 2692, 1728, 1221 };
|
||||
profile.segment_count = 5136;
|
||||
profile.segment_size = 5136;
|
||||
profile.segment_order = {0, 2, 4, 6, 1, 3, 5, 7};
|
||||
profile.custom_regs = {
|
||||
{ 0x17, 0x04 },
|
||||
|
@ -1776,7 +1776,7 @@ void genesys_init_sensor_tables()
|
|||
profile.dpi = 150;
|
||||
profile.exposure_lperiod = 2848;
|
||||
profile.exposure = { 465, 310, 239 };
|
||||
profile.segment_count = 5187;
|
||||
profile.segment_size = 5187;
|
||||
profile.segment_order = {};
|
||||
profile.custom_regs = {
|
||||
{ 0x17, 0x0c },
|
||||
|
@ -1791,7 +1791,7 @@ void genesys_init_sensor_tables()
|
|||
profile.dpi = 300;
|
||||
profile.exposure_lperiod = 1424;
|
||||
profile.exposure = { 465, 310, 239 };
|
||||
profile.segment_count = 5187;
|
||||
profile.segment_size = 5187;
|
||||
profile.segment_order = {};
|
||||
profile.custom_regs = {
|
||||
{ 0x17, 0x0c },
|
||||
|
@ -1806,7 +1806,7 @@ void genesys_init_sensor_tables()
|
|||
profile.dpi = 600;
|
||||
profile.exposure_lperiod = 1504;
|
||||
profile.exposure = { 465, 310, 239 };
|
||||
profile.segment_count = 5187;
|
||||
profile.segment_size = 5187;
|
||||
profile.segment_order = {};
|
||||
profile.custom_regs = {
|
||||
{ 0x17, 0x0c },
|
||||
|
@ -1821,7 +1821,7 @@ void genesys_init_sensor_tables()
|
|||
profile.dpi = 1200;
|
||||
profile.exposure_lperiod = 2696;
|
||||
profile.exposure = { 1464, 844, 555 };
|
||||
profile.segment_count = 5187;
|
||||
profile.segment_size = 5187;
|
||||
profile.segment_order = {0, 1};
|
||||
profile.custom_regs = {
|
||||
{ 0x17, 0x0a },
|
||||
|
@ -1836,7 +1836,7 @@ void genesys_init_sensor_tables()
|
|||
profile.dpi = 2400;
|
||||
profile.exposure_lperiod = 10576;
|
||||
profile.exposure = { 2798, 1558, 972 };
|
||||
profile.segment_count = 5187;
|
||||
profile.segment_size = 5187;
|
||||
profile.segment_order = {0, 1, 2, 3};
|
||||
profile.custom_regs = {
|
||||
{ 0x17, 0x08 },
|
||||
|
@ -1851,7 +1851,7 @@ void genesys_init_sensor_tables()
|
|||
profile.dpi = 4800;
|
||||
profile.exposure_lperiod = 10576;
|
||||
profile.exposure = { 2798, 1558, 972 };
|
||||
profile.segment_count = 5187;
|
||||
profile.segment_size = 5187;
|
||||
profile.segment_order = {0, 1, 4, 5, 2, 3, 6, 7};
|
||||
profile.custom_regs = {
|
||||
{ 0x17, 0x06 },
|
||||
|
@ -1912,7 +1912,7 @@ void genesys_init_sensor_tables()
|
|||
profile.dpi = 200;
|
||||
profile.exposure_lperiod = 2848;
|
||||
profile.exposure = { 410, 275, 203 };
|
||||
profile.segment_count = 5136;
|
||||
profile.segment_size = 5136;
|
||||
profile.segment_order = {};
|
||||
profile.custom_regs = {
|
||||
{ 0x17, 0x0a },
|
||||
|
@ -1928,7 +1928,7 @@ void genesys_init_sensor_tables()
|
|||
profile.dpi = 300;
|
||||
profile.exposure_lperiod = 1424;
|
||||
profile.exposure = { 410, 275, 203 };
|
||||
profile.segment_count = 5136;
|
||||
profile.segment_size = 5136;
|
||||
profile.segment_order = {};
|
||||
profile.custom_regs = {
|
||||
{ 0x17, 0x0a },
|
||||
|
@ -1943,7 +1943,7 @@ void genesys_init_sensor_tables()
|
|||
profile.dpi = 600;
|
||||
profile.exposure_lperiod = 1432;
|
||||
profile.exposure = { 410, 275, 203 };
|
||||
profile.segment_count = 5136;
|
||||
profile.segment_size = 5136;
|
||||
profile.segment_order = {};
|
||||
profile.custom_regs = {
|
||||
{ 0x17, 0x0a },
|
||||
|
@ -1958,7 +1958,7 @@ void genesys_init_sensor_tables()
|
|||
profile.dpi = 1200;
|
||||
profile.exposure_lperiod = 2712;
|
||||
profile.exposure = { 746, 478, 353 };
|
||||
profile.segment_count = 5136;
|
||||
profile.segment_size = 5136;
|
||||
profile.segment_order = {0, 1};
|
||||
profile.custom_regs = {
|
||||
{ 0x17, 0x08 },
|
||||
|
@ -1973,7 +1973,7 @@ void genesys_init_sensor_tables()
|
|||
profile.dpi = 2400;
|
||||
profile.exposure_lperiod = 5280;
|
||||
profile.exposure = { 1417, 909, 643 };
|
||||
profile.segment_count = 5136;
|
||||
profile.segment_size = 5136;
|
||||
profile.segment_order = {0, 2, 1, 3};
|
||||
profile.custom_regs = {
|
||||
{ 0x17, 0x06 },
|
||||
|
@ -3354,7 +3354,7 @@ void genesys_init_sensor_tables()
|
|||
profile.dpi = 1200;
|
||||
profile.exposure_lperiod = 11000;
|
||||
profile.exposure = { 0, 0, 0 };
|
||||
profile.segment_count = 5136;
|
||||
profile.segment_size = 5136;
|
||||
profile.segment_order = {0, 1};
|
||||
profile.custom_regs = {
|
||||
{ 0x17, 0x13 },
|
||||
|
@ -3416,7 +3416,7 @@ void genesys_init_sensor_tables()
|
|||
profile.dpi = 1200;
|
||||
profile.exposure_lperiod = 11000;
|
||||
profile.exposure = { 0, 0, 0 };
|
||||
profile.segment_count = 5136;
|
||||
profile.segment_size = 5136;
|
||||
profile.segment_order = {0, 1};
|
||||
profile.custom_regs = {
|
||||
{ 0x17, 0x13 },
|
||||
|
|
Ładowanie…
Reference in New Issue