kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Use common code path to calculate session line sizes
rodzic
9915608309
commit
ed4419e73d
|
@ -1066,7 +1066,6 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
session.assert_computed();
|
session.assert_computed();
|
||||||
|
|
||||||
int start;
|
int start;
|
||||||
int bytes_per_line;
|
|
||||||
int move;
|
int move;
|
||||||
unsigned int mflags;
|
unsigned int mflags;
|
||||||
int exposure_time;
|
int exposure_time;
|
||||||
|
@ -1145,18 +1144,13 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
|
|
||||||
/*** prepares data reordering ***/
|
/*** prepares data reordering ***/
|
||||||
|
|
||||||
/* words_per_line */
|
|
||||||
bytes_per_line = session.output_pixels;
|
|
||||||
bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8;
|
|
||||||
|
|
||||||
/* since we don't have sheetfed scanners to handle,
|
/* since we don't have sheetfed scanners to handle,
|
||||||
* use huge read buffer */
|
* use huge read buffer */
|
||||||
/* TODO find the best size according to settings */
|
/* TODO find the best size according to settings */
|
||||||
requested_buffer_size = 16 * bytes_per_line;
|
requested_buffer_size = 16 * session.output_line_bytes;
|
||||||
|
|
||||||
read_buffer_size = 2 * requested_buffer_size +
|
read_buffer_size = 2 * requested_buffer_size +
|
||||||
((session.max_color_shift_lines + session.num_staggered_lines) * session.optical_pixels *
|
(session.max_color_shift_lines + session.num_staggered_lines) * session.optical_line_bytes;
|
||||||
session.params.channels * session.params.depth) / 8;
|
|
||||||
|
|
||||||
dev->read_buffer.clear();
|
dev->read_buffer.clear();
|
||||||
dev->read_buffer.alloc(read_buffer_size);
|
dev->read_buffer.alloc(read_buffer_size);
|
||||||
|
@ -1170,7 +1164,7 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
dev->out_buffer.clear();
|
dev->out_buffer.clear();
|
||||||
dev->out_buffer.alloc((8 * dev->settings.pixels * session.params.channels * session.params.depth) / 8);
|
dev->out_buffer.alloc((8 * dev->settings.pixels * session.params.channels * session.params.depth) / 8);
|
||||||
|
|
||||||
dev->read_bytes_left = bytes_per_line * session.output_line_count;
|
dev->read_bytes_left = session.output_line_bytes * session.output_line_count;
|
||||||
|
|
||||||
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
||||||
dev->read_active = SANE_TRUE;
|
dev->read_active = SANE_TRUE;
|
||||||
|
|
|
@ -357,11 +357,8 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
||||||
int i, nb;
|
int i, nb;
|
||||||
Motor_Master *motor = NULL;
|
Motor_Master *motor = NULL;
|
||||||
unsigned int used1, used2, vfinal;
|
unsigned int used1, used2, vfinal;
|
||||||
unsigned int bpp; /**> bytes per pixel */
|
|
||||||
uint32_t z1, z2;
|
uint32_t z1, z2;
|
||||||
uint16_t ex, sx;
|
uint16_t ex, sx;
|
||||||
int words_per_line;
|
|
||||||
size_t requested_buffer_size;
|
|
||||||
size_t read_buffer_size;
|
size_t read_buffer_size;
|
||||||
int feedl;
|
int feedl;
|
||||||
|
|
||||||
|
@ -567,24 +564,10 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
||||||
DBG(DBG_info, "%s: startx=%d, endx=%d, ccd_size_divisor=%d\n", __func__, sx, ex,
|
DBG(DBG_info, "%s: startx=%d, endx=%d, ccd_size_divisor=%d\n", __func__, sx, ex,
|
||||||
session.ccd_size_divisor);
|
session.ccd_size_divisor);
|
||||||
|
|
||||||
/* words_per_line must be computed according to the scan's resolution */
|
dev->bpl = session.output_line_channel_bytes;
|
||||||
/* in fact, words_per_line _gives_ the actual scan resolution */
|
dev->wpl = session.output_line_bytes;
|
||||||
words_per_line = session.output_pixels;
|
|
||||||
bpp = session.params.depth/8;
|
|
||||||
if (session.params.depth == 1) {
|
|
||||||
words_per_line = (words_per_line+7)/8 ;
|
|
||||||
bpp=1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
words_per_line *= bpp;
|
|
||||||
}
|
|
||||||
dev->bpl = words_per_line;
|
|
||||||
words_per_line *= session.params.channels;
|
|
||||||
dev->wpl = words_per_line;
|
|
||||||
|
|
||||||
DBG(DBG_info, "%s: wpl=%d\n", __func__, words_per_line);
|
regs->set24(REG_MAXWD, session.output_line_bytes);
|
||||||
regs->set24(REG_MAXWD, words_per_line);
|
|
||||||
|
|
||||||
regs->set16(REG_DPISET, session.output_resolution * session.ccd_size_divisor *
|
regs->set16(REG_DPISET, session.output_resolution * session.ccd_size_divisor *
|
||||||
sensor.ccd_pixels_per_system_pixel());
|
sensor.ccd_pixels_per_system_pixel());
|
||||||
|
@ -739,9 +722,8 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
||||||
/* now we're done with registers setup values used by data transfer */
|
/* now we're done with registers setup values used by data transfer */
|
||||||
/* we setup values needed for the data transfer */
|
/* we setup values needed for the data transfer */
|
||||||
|
|
||||||
/* we must use a round number of words_per_line */
|
// we must use a round number of words_per_line
|
||||||
requested_buffer_size = 8 * words_per_line;
|
read_buffer_size = 16 * session.output_line_bytes +
|
||||||
read_buffer_size = 2 * requested_buffer_size +
|
|
||||||
((session.max_color_shift_lines + session.num_staggered_lines) * session.params.pixels *
|
((session.max_color_shift_lines + session.num_staggered_lines) * session.params.pixels *
|
||||||
session.params.channels * session.params.depth) / 8;
|
session.params.channels * session.params.depth) / 8;
|
||||||
|
|
||||||
|
@ -752,15 +734,15 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
||||||
dev->lines_buffer.alloc(read_buffer_size);
|
dev->lines_buffer.alloc(read_buffer_size);
|
||||||
|
|
||||||
dev->shrink_buffer.clear();
|
dev->shrink_buffer.clear();
|
||||||
dev->shrink_buffer.alloc(requested_buffer_size);
|
dev->shrink_buffer.alloc(8 * session.output_line_bytes);
|
||||||
|
|
||||||
dev->out_buffer.clear();
|
dev->out_buffer.clear();
|
||||||
dev->out_buffer.alloc(8 * session.params.pixels * session.params.channels * bpp);
|
dev->out_buffer.alloc(8 * session.output_line_bytes);
|
||||||
|
|
||||||
/* scan bytes to read */
|
/* scan bytes to read */
|
||||||
unsigned cis_channel_multiplier = dev->model->is_cis ? session.params.channels : 1;
|
unsigned cis_channel_multiplier = dev->model->is_cis ? session.params.channels : 1;
|
||||||
|
|
||||||
dev->read_bytes_left = words_per_line * session.output_line_count * cis_channel_multiplier;
|
dev->read_bytes_left = session.output_line_bytes * session.output_line_count * cis_channel_multiplier;
|
||||||
|
|
||||||
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
||||||
dev->read_active = SANE_TRUE;
|
dev->read_active = SANE_TRUE;
|
||||||
|
|
|
@ -1763,7 +1763,6 @@ static void gl841_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
session.assert_computed();
|
session.assert_computed();
|
||||||
|
|
||||||
int start;
|
int start;
|
||||||
int bytes_per_line;
|
|
||||||
int move;
|
int move;
|
||||||
int exposure_time;
|
int exposure_time;
|
||||||
int avg;
|
int avg;
|
||||||
|
@ -1920,19 +1919,14 @@ dummy \ scanned lines
|
||||||
|
|
||||||
/*** prepares data reordering ***/
|
/*** prepares data reordering ***/
|
||||||
|
|
||||||
/* words_per_line */
|
requested_buffer_size = 8 * session.output_line_bytes;
|
||||||
bytes_per_line = session.output_pixels;
|
// we must use a multiple of session.output_line_bytes
|
||||||
bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8;
|
|
||||||
|
|
||||||
requested_buffer_size = 8 * bytes_per_line;
|
|
||||||
/* we must use a round number of bytes_per_line */
|
|
||||||
if (requested_buffer_size > sanei_genesys_get_bulk_max_size(dev)) {
|
if (requested_buffer_size > sanei_genesys_get_bulk_max_size(dev)) {
|
||||||
requested_buffer_size = (sanei_genesys_get_bulk_max_size(dev) / bytes_per_line) * bytes_per_line;
|
requested_buffer_size = (sanei_genesys_get_bulk_max_size(dev) / session.output_line_bytes) * session.output_line_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
read_buffer_size = 2 * requested_buffer_size +
|
read_buffer_size = 2 * requested_buffer_size +
|
||||||
((session.max_color_shift_lines + session.num_staggered_lines) * session.optical_pixels *
|
(session.max_color_shift_lines + session.num_staggered_lines) * session.optical_line_bytes;
|
||||||
session.params.channels * session.params.depth) / 8;
|
|
||||||
|
|
||||||
dev->read_buffer.clear();
|
dev->read_buffer.clear();
|
||||||
dev->read_buffer.alloc(read_buffer_size);
|
dev->read_buffer.alloc(read_buffer_size);
|
||||||
|
@ -1946,7 +1940,7 @@ dummy \ scanned lines
|
||||||
dev->out_buffer.clear();
|
dev->out_buffer.clear();
|
||||||
dev->out_buffer.alloc((8 * dev->settings.pixels * session.params.channels * session.params.depth) / 8);
|
dev->out_buffer.alloc((8 * dev->settings.pixels * session.params.channels * session.params.depth) / 8);
|
||||||
|
|
||||||
dev->read_bytes_left = bytes_per_line * session.output_line_count;
|
dev->read_bytes_left = session.output_line_bytes * session.output_line_count;
|
||||||
|
|
||||||
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
||||||
dev->read_active = SANE_TRUE;
|
dev->read_active = SANE_TRUE;
|
||||||
|
|
|
@ -1157,12 +1157,8 @@ static void gl843_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
||||||
reg->set16(REG_STRPIXEL, session.pixel_startx);
|
reg->set16(REG_STRPIXEL, session.pixel_startx);
|
||||||
reg->set16(REG_ENDPIXEL, session.pixel_endx);
|
reg->set16(REG_ENDPIXEL, session.pixel_endx);
|
||||||
|
|
||||||
// words(16bit) before gamma, conversion to 8 bit or lineart */
|
dev->wpl = session.output_line_channel_bytes; // FIXME: this is not currently used
|
||||||
// FIXME: this computation differs from session.output_line_bytes
|
dev->bpl = session.output_line_channel_bytes; // FIXME: this is not currently used
|
||||||
unsigned words_per_line = (session.output_pixels / session.ccd_size_divisor) * (session.params.depth / 8);
|
|
||||||
|
|
||||||
dev->wpl = words_per_line; // FIXME: this is not currently used
|
|
||||||
dev->bpl = words_per_line; // FIXME: this is not currently used
|
|
||||||
|
|
||||||
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);
|
||||||
|
@ -1170,12 +1166,10 @@ static void gl843_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
||||||
DBG(DBG_io2, "%s: dev->len =%lu\n", __func__, (unsigned long)dev->len);
|
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->dist =%lu\n", __func__, (unsigned long)dev->dist);
|
||||||
|
|
||||||
words_per_line *= session.params.channels;
|
|
||||||
|
|
||||||
/* 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; */
|
||||||
reg->set24(REG_MAXWD, (words_per_line) >> 1);
|
// BUG: the division by ccd_size_divisor likely does not make sense
|
||||||
DBG(DBG_io2, "%s: words_per_line used=%d\n", __func__, words_per_line);
|
reg->set24(REG_MAXWD, (session.output_line_bytes / session.ccd_size_divisor) >> 1);
|
||||||
|
|
||||||
reg->set16(REG_LPERIOD, exposure / tgtime);
|
reg->set16(REG_LPERIOD, exposure / tgtime);
|
||||||
DBG(DBG_io2, "%s: exposure used=%d\n", __func__, exposure/tgtime);
|
DBG(DBG_io2, "%s: exposure used=%d\n", __func__, exposure/tgtime);
|
||||||
|
@ -1193,8 +1187,6 @@ static void gl843_compute_session(Genesys_Device* dev, ScanSession& s,
|
||||||
// compute optical and output resolutions
|
// compute optical and output resolutions
|
||||||
s.hwdpi_divisor = sensor.get_hwdpi_divisor_for_dpi(s.params.xres);
|
s.hwdpi_divisor = sensor.get_hwdpi_divisor_for_dpi(s.params.xres);
|
||||||
|
|
||||||
s.optical_line_bytes = (s.optical_pixels * s.params.channels * s.params.depth) / 8;
|
|
||||||
s.output_line_bytes = (s.output_pixels * s.params.channels * s.params.depth) / 8;
|
|
||||||
|
|
||||||
// compute physical pixel positions
|
// compute physical pixel positions
|
||||||
unsigned ccd_pixels_per_system_pixel = sensor.ccd_pixels_per_system_pixel();
|
unsigned ccd_pixels_per_system_pixel = sensor.ccd_pixels_per_system_pixel();
|
||||||
|
|
|
@ -951,7 +951,6 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
session.assert_computed();
|
session.assert_computed();
|
||||||
|
|
||||||
int start;
|
int start;
|
||||||
int bytes_per_line;
|
|
||||||
int move;
|
int move;
|
||||||
unsigned int mflags; /**> motor flags */
|
unsigned int mflags; /**> motor flags */
|
||||||
int exposure_time;
|
int exposure_time;
|
||||||
|
@ -1027,15 +1026,10 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
|
|
||||||
/*** prepares data reordering ***/
|
/*** prepares data reordering ***/
|
||||||
|
|
||||||
/* words_per_line */
|
requested_buffer_size = 8 * session.output_line_bytes;
|
||||||
bytes_per_line = session.output_pixels;
|
|
||||||
bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8;
|
|
||||||
|
|
||||||
requested_buffer_size = 8 * bytes_per_line;
|
|
||||||
|
|
||||||
read_buffer_size = 2 * requested_buffer_size +
|
read_buffer_size = 2 * requested_buffer_size +
|
||||||
((session.max_color_shift_lines + session.num_staggered_lines) * session.optical_pixels * session.params.channels *
|
(session.max_color_shift_lines + session.num_staggered_lines) * session.optical_line_bytes;
|
||||||
session.params.depth) / 8;
|
|
||||||
|
|
||||||
dev->read_buffer.clear();
|
dev->read_buffer.clear();
|
||||||
dev->read_buffer.alloc(read_buffer_size);
|
dev->read_buffer.alloc(read_buffer_size);
|
||||||
|
@ -1049,7 +1043,7 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
dev->out_buffer.clear();
|
dev->out_buffer.clear();
|
||||||
dev->out_buffer.alloc((8 * session.params.pixels * session.params.channels * session.params.depth) / 8);
|
dev->out_buffer.alloc((8 * session.params.pixels * session.params.channels * session.params.depth) / 8);
|
||||||
|
|
||||||
dev->read_bytes_left = bytes_per_line * session.output_line_count;
|
dev->read_bytes_left = session.output_line_bytes * session.output_line_count;
|
||||||
|
|
||||||
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
||||||
dev->read_active = SANE_TRUE;
|
dev->read_active = SANE_TRUE;
|
||||||
|
|
|
@ -970,7 +970,6 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
session.assert_computed();
|
session.assert_computed();
|
||||||
|
|
||||||
int start;
|
int start;
|
||||||
int bytes_per_line;
|
|
||||||
int move;
|
int move;
|
||||||
unsigned int mflags; /**> motor flags */
|
unsigned int mflags; /**> motor flags */
|
||||||
int exposure_time;
|
int exposure_time;
|
||||||
|
@ -1043,15 +1042,10 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
|
|
||||||
/*** prepares data reordering ***/
|
/*** prepares data reordering ***/
|
||||||
|
|
||||||
/* words_per_line */
|
requested_buffer_size = 8 * session.output_line_bytes;
|
||||||
bytes_per_line = session.output_pixels;
|
|
||||||
bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8;
|
|
||||||
|
|
||||||
requested_buffer_size = 8 * bytes_per_line;
|
|
||||||
|
|
||||||
read_buffer_size = 2 * requested_buffer_size +
|
read_buffer_size = 2 * requested_buffer_size +
|
||||||
((session.max_color_shift_lines + session.num_staggered_lines) * session.optical_pixels *
|
(session.max_color_shift_lines + session.num_staggered_lines) * session.optical_line_bytes;
|
||||||
session.params.channels * session.params.depth) / 8;
|
|
||||||
|
|
||||||
dev->read_buffer.clear();
|
dev->read_buffer.clear();
|
||||||
dev->read_buffer.alloc(read_buffer_size);
|
dev->read_buffer.alloc(read_buffer_size);
|
||||||
|
@ -1065,7 +1059,7 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
dev->out_buffer.clear();
|
dev->out_buffer.clear();
|
||||||
dev->out_buffer.alloc((8 * session.params.pixels * session.params.channels * session.params.depth) / 8);
|
dev->out_buffer.alloc((8 * session.params.pixels * session.params.channels * session.params.depth) / 8);
|
||||||
|
|
||||||
dev->read_bytes_left = bytes_per_line * session.output_line_count;
|
dev->read_bytes_left = session.output_line_bytes * session.output_line_count;
|
||||||
|
|
||||||
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
||||||
dev->read_active = SANE_TRUE;
|
dev->read_active = SANE_TRUE;
|
||||||
|
|
|
@ -1223,6 +1223,10 @@ void compute_session(Genesys_Device* dev, ScanSession& s, const Genesys_Sensor&
|
||||||
s.params.yres, s.params.flags);
|
s.params.yres, s.params.flags);
|
||||||
|
|
||||||
s.output_line_count = s.params.lines + s.max_color_shift_lines + s.num_staggered_lines;
|
s.output_line_count = s.params.lines + s.max_color_shift_lines + s.num_staggered_lines;
|
||||||
|
|
||||||
|
s.optical_line_bytes = multiply_by_depth_ceil(s.optical_pixels, s.params.depth) * s.params.channels;
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief initialize device
|
/** @brief initialize device
|
||||||
|
|
|
@ -231,7 +231,6 @@ struct ScanSession {
|
||||||
unsigned optical_pixels = 0;
|
unsigned optical_pixels = 0;
|
||||||
|
|
||||||
// the number of bytes in the output of a single line directly from scanner
|
// the number of bytes in the output of a single line directly from scanner
|
||||||
// gl843-only
|
|
||||||
unsigned optical_line_bytes = 0;
|
unsigned optical_line_bytes = 0;
|
||||||
|
|
||||||
// the resolution of the output data.
|
// the resolution of the output data.
|
||||||
|
@ -241,8 +240,10 @@ struct ScanSession {
|
||||||
// the number of pixels in output data
|
// the number of pixels in output data
|
||||||
unsigned output_pixels = 0;
|
unsigned output_pixels = 0;
|
||||||
|
|
||||||
|
// the number of bytes in the output of a channel of a single line
|
||||||
|
unsigned output_line_channel_bytes;
|
||||||
|
|
||||||
// the number of bytes in the output of a single line
|
// the number of bytes in the output of a single line
|
||||||
// gl843-only
|
|
||||||
unsigned output_line_bytes = 0;
|
unsigned output_line_bytes = 0;
|
||||||
|
|
||||||
// the number of lines in the output of the scanner. This must be larger than the user
|
// the number of lines in the output of the scanner. This must be larger than the user
|
||||||
|
|
Ładowanie…
Reference in New Issue