kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Use common code path to compute session segment_count
rodzic
ae784d9927
commit
41b5e5f5ff
|
@ -3476,13 +3476,13 @@ static void genesys_fill_segmented_buffer(Genesys_Device* dev, uint8_t* work_buf
|
|||
{
|
||||
if (depth==1) {
|
||||
while (dev->deseg.curr_byte < dev->deseg.pixel_groups && count < size) {
|
||||
for (unsigned n = 0; n < dev->deseg.segment_count; n++) {
|
||||
for (unsigned n = 0; n < dev->session.segment_count; n++) {
|
||||
work_buffer_dst[count+n] = 0;
|
||||
}
|
||||
/* interleaving is at bit level */
|
||||
for (i=0;i<8;i++) {
|
||||
k = count + (i * dev->deseg.segment_count) / 8;
|
||||
for (unsigned n = 0; n < dev->deseg.segment_count; n++) {
|
||||
k = count + (i * dev->session.segment_count) / 8;
|
||||
for (unsigned n = 0; n < dev->session.segment_count; n++) {
|
||||
work_buffer_dst[k] = work_buffer_dst[k] << 1;
|
||||
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;
|
||||
|
@ -3491,28 +3491,28 @@ static void genesys_fill_segmented_buffer(Genesys_Device* dev, uint8_t* work_buf
|
|||
}
|
||||
|
||||
/* update counter and pointer */
|
||||
count += dev->deseg.segment_count;
|
||||
count += dev->session.segment_count;
|
||||
dev->deseg.curr_byte++;
|
||||
}
|
||||
}
|
||||
if (depth==8) {
|
||||
while (dev->deseg.curr_byte < dev->deseg.pixel_groups && count < size) {
|
||||
for (unsigned n = 0; n < dev->deseg.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->deseg.conseq_pixel_dist_bytes *dev->segment_order[n]];
|
||||
}
|
||||
/* update counter and pointer */
|
||||
count += dev->deseg.segment_count;
|
||||
count += dev->session.segment_count;
|
||||
dev->deseg.curr_byte++;
|
||||
}
|
||||
}
|
||||
if (depth==16) {
|
||||
while (dev->deseg.curr_byte < dev->deseg.pixel_groups && count < size) {
|
||||
for (unsigned n = 0; n < dev->deseg.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->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->deseg.segment_count * 2;
|
||||
count += dev->session.segment_count * 2;
|
||||
dev->deseg.curr_byte += 2;
|
||||
}
|
||||
}
|
||||
|
@ -3591,7 +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->deseg.segment_count > 1) {
|
||||
else if (dev->session.segment_count > 1) {
|
||||
// multi-segment sensors processing
|
||||
genesys_fill_segmented_buffer(dev, work_buffer_dst, size);
|
||||
}
|
||||
|
@ -5527,7 +5527,6 @@ 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->deseg.segment_count = 0;
|
||||
s->dev->binary=NULL;
|
||||
|
||||
*handle = s;
|
||||
|
|
|
@ -195,9 +195,6 @@ 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;
|
||||
|
||||
|
|
|
@ -936,18 +936,14 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
}
|
||||
}
|
||||
|
||||
/* segment number */
|
||||
r = sanei_genesys_get_address (reg, 0x98);
|
||||
unsigned segment_count = r->value & 0x0f;
|
||||
|
||||
reg->set24(REG_STRPIXEL, startx / segment_count);
|
||||
DBG (DBG_io2, "%s: strpixel used=%d\n", __func__, startx / segment_count);
|
||||
reg->set24(REG_STRPIXEL, startx / session.segment_count);
|
||||
DBG(DBG_io2, "%s: strpixel used=%d\n", __func__, startx / session.segment_count);
|
||||
segcnt = reg->get24(REG_SEGCNT);
|
||||
if(endx / segment_count == segcnt) {
|
||||
if (endx / session.segment_count == segcnt) {
|
||||
endx=0;
|
||||
}
|
||||
reg->set24(REG_ENDPIXEL, endx / segment_count);
|
||||
DBG (DBG_io2, "%s: endpixel used=%d\n", __func__, endx / segment_count);
|
||||
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_channel_bytes =
|
||||
|
@ -956,9 +952,8 @@ 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 = 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->deseg.pixel_groups = dev->deseg.raw_channel_bytes / session.segment_count;
|
||||
dev->deseg.conseq_pixel_dist_bytes = dev->deseg.raw_channel_bytes / session.segment_count;
|
||||
dev->line_count = 0;
|
||||
dev->line_interp = 0;
|
||||
|
||||
|
@ -1116,8 +1111,6 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
|
||||
int exposure_time;
|
||||
|
||||
int dpihw;
|
||||
|
||||
DBG(DBG_info, "%s ", __func__);
|
||||
debug_dump(DBG_info, dev->settings);
|
||||
|
||||
|
@ -1154,13 +1147,6 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
|
||||
DBG (DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
|
||||
|
||||
// compute hw dpi for sensor
|
||||
dpihw = sensor.get_register_hwdpi(session.params.xres);
|
||||
|
||||
const SensorProfile& sensor_profile = get_sensor_profile(dev->model->asic_type, sensor, dpihw,
|
||||
session.ccd_size_divisor);
|
||||
dev->deseg.segment_count = sensor_profile.custom_regs.get_value(0x98) & 0x0f;
|
||||
|
||||
dev->session = session;
|
||||
dev->current_setup.pixels = session.output_pixels;
|
||||
DBG (DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels);
|
||||
|
@ -1893,7 +1879,7 @@ static void gl124_send_shading_data(Genesys_Device* dev, const Genesys_Sensor& s
|
|||
if(dev->binary!=NULL)
|
||||
{
|
||||
std::fprintf(dev->binary,"P5\n%d %d\n%d\n",
|
||||
(endpixel - strpixel) / factor * channels * dev->deseg.segment_count,
|
||||
(endpixel - strpixel) / factor * channels * dev->session.segment_count,
|
||||
lines / channels, 255);
|
||||
}
|
||||
}
|
||||
|
@ -1905,7 +1891,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->deseg.segment_count, 0);
|
||||
std::vector<uint8_t> buffer(pixels * dev->session.segment_count, 0);
|
||||
|
||||
/* write actual red data */
|
||||
for(i=0;i<3;i++)
|
||||
|
@ -1921,7 +1907,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->deseg.segment_count) {
|
||||
switch (dev->session.segment_count) {
|
||||
case 1:
|
||||
ptr[0+pixels*0]=src[0+segcnt*0];
|
||||
ptr[1+pixels*0]=src[1+segcnt*0];
|
||||
|
@ -1963,7 +1949,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->deseg.segment_count, buffer.data());
|
||||
sanei_genesys_write_ahb(dev, addr, pixels * dev->session.segment_count, buffer.data());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -710,23 +710,21 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
unsigned startx = start / ccd_pixels_per_system_pixel + sensor.CCD_start_xoffset;
|
||||
unsigned endx = startx + session.optical_pixels / ccd_pixels_per_system_pixel;
|
||||
|
||||
unsigned segment_count = sensor_profile.get_segment_count();
|
||||
|
||||
// compute pixel coordinate in the given dpihw space, taking segments into account
|
||||
startx /= session.hwdpi_divisor * segment_count;
|
||||
endx /= session.hwdpi_divisor * segment_count;
|
||||
startx /= session.hwdpi_divisor * session.segment_count;
|
||||
endx /= session.hwdpi_divisor * session.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 (segment_count > 1) {
|
||||
if (session.segment_count > 1) {
|
||||
dev->deseg.conseq_pixel_dist_bytes = sensor_profile.segment_size;
|
||||
}
|
||||
|
||||
/* use a segcnt rounded to next even number */
|
||||
endx += ((dev->deseg.conseq_pixel_dist_bytes + 1) & 0xfffe) * (segment_count - 1);
|
||||
endx += ((dev->deseg.conseq_pixel_dist_bytes + 1) & 0xfffe) * (session.segment_count - 1);
|
||||
unsigned used_pixels = endx - startx;
|
||||
|
||||
gl846_set_fe(dev, sensor, AFE_SET);
|
||||
|
@ -830,7 +828,6 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
dev->deseg.conseq_pixel_dist_bytes = multiply_by_depth_ceil(dev->deseg.conseq_pixel_dist_bytes, session.params.depth);
|
||||
|
||||
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;
|
||||
|
@ -848,7 +845,7 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
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);
|
||||
DBG (DBG_io2, "%s: dev->segnb =%lu\n", __func__, (unsigned long) dev->session.segment_count);
|
||||
|
||||
dev->deseg.raw_line_bytes = dev->deseg.raw_channel_bytes * session.params.channels;
|
||||
|
||||
|
|
|
@ -729,23 +729,22 @@ 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 */
|
||||
unsigned segment_count = sensor_profile.get_segment_count();
|
||||
|
||||
// compute pixel coordinate in the given dpihw space, taking segments into account
|
||||
startx /= session.hwdpi_divisor * segment_count;
|
||||
endx /= session.hwdpi_divisor * segment_count;
|
||||
startx /= session.hwdpi_divisor * session.segment_count;
|
||||
endx /= session.hwdpi_divisor * session.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 (segment_count > 1) {
|
||||
if (session.segment_count > 1) {
|
||||
dev->deseg.conseq_pixel_dist_bytes = sensor_profile.segment_size;
|
||||
}
|
||||
|
||||
/* use a segcnt rounded to next even number */
|
||||
endx += ((dev->deseg.conseq_pixel_dist_bytes + 1) & 0xfffe) * (segment_count - 1);
|
||||
endx += ((dev->deseg.conseq_pixel_dist_bytes + 1) & 0xfffe) * (session.segment_count - 1);
|
||||
unsigned used_pixels = endx - startx;
|
||||
|
||||
gl847_set_fe(dev, sensor, AFE_SET);
|
||||
|
@ -849,7 +848,6 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
dev->deseg.conseq_pixel_dist_bytes = multiply_by_depth_ceil(dev->deseg.conseq_pixel_dist_bytes, session.params.depth);
|
||||
|
||||
dev->deseg.curr_byte = 0;
|
||||
dev->deseg.segment_count = segment_count;
|
||||
dev->line_interp = 0;
|
||||
|
||||
reg->set16(REG_DPISET,dpiset);
|
||||
|
@ -866,7 +864,7 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
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);
|
||||
DBG (DBG_io2, "%s: dev->segnb =%lu\n", __func__, (unsigned long) dev->session.segment_count);
|
||||
|
||||
dev->deseg.raw_line_bytes = dev->deseg.raw_channel_bytes * session.params.channels;
|
||||
|
||||
|
|
|
@ -1293,6 +1293,19 @@ void compute_session(Genesys_Device* dev, ScanSession& s, const Genesys_Sensor&
|
|||
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;
|
||||
|
||||
s.segment_count = 1;
|
||||
if (dev->model->flags & GENESYS_FLAG_SIS_SENSOR || dev->model->asic_type == AsicType::GL124) {
|
||||
unsigned ccd_size_divisor_for_profile = 1;
|
||||
if (dev->model->asic_type == AsicType::GL124) {
|
||||
ccd_size_divisor_for_profile = s.ccd_size_divisor;
|
||||
}
|
||||
unsigned dpihw = sensor.get_register_hwdpi(s.output_resolution * ccd_pixels_per_system_pixel);
|
||||
|
||||
const auto& sensor_profile = get_sensor_profile(dev->model->asic_type, sensor, dpihw,
|
||||
ccd_size_divisor_for_profile);
|
||||
s.segment_count = sensor_profile.get_segment_count();
|
||||
}
|
||||
|
||||
compute_session_buffer_sizes(dev->model->asic_type, s);
|
||||
}
|
||||
|
||||
|
@ -1976,6 +1989,7 @@ void debug_dump(unsigned level, const ScanSession& session)
|
|||
DBG(level, " num_staggered_lines : %d\n", session.num_staggered_lines);
|
||||
DBG(level, " max_color_shift_lines : %d\n", session.max_color_shift_lines);
|
||||
DBG(level, " enable_ledadd : %d\n", session.enable_ledadd);
|
||||
DBG(level, " segment_count : %d\n", session.segment_count);
|
||||
DBG(level, " pixel_startx : %d\n", session.pixel_startx);
|
||||
DBG(level, " pixel_endx : %d\n", session.pixel_endx);
|
||||
DBG(level, " buffer_size_read : %zu\n", session.buffer_size_read);
|
||||
|
|
|
@ -255,6 +255,9 @@ struct ScanSession {
|
|||
// different color channels
|
||||
unsigned max_color_shift_lines = 0;
|
||||
|
||||
// the number of scanner segments used in the current scan
|
||||
unsigned segment_count = 1;
|
||||
|
||||
// the physical pixel positions that are sent to the registers
|
||||
// gl843-only
|
||||
unsigned pixel_startx = 0;
|
||||
|
|
Ładowanie…
Reference in New Issue