kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Include full session description into the device struct
rodzic
f4401d501f
commit
38b97f1402
|
@ -2873,6 +2873,7 @@ static void genesys_save_calibration(Genesys_Device* dev, const Genesys_Sensor&
|
|||
found_cache_it->white_average_data = dev->white_average_data;
|
||||
|
||||
found_cache_it->used_setup = dev->current_setup;
|
||||
found_cache_it->params = dev->session.params;
|
||||
found_cache_it->frontend = dev->frontend;
|
||||
found_cache_it->sensor = sensor;
|
||||
|
||||
|
@ -3504,7 +3505,7 @@ static void genesys_fill_line_interp_buffer(Genesys_Device* dev, uint8_t* work_b
|
|||
{
|
||||
/* line counter */
|
||||
// dev->line_interp holds the number of lines scanned for one line of data sent
|
||||
if (((dev->line_count / dev->current_setup.params.channels) % dev->line_interp) == 0) {
|
||||
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];
|
||||
count++;
|
||||
|
@ -3723,10 +3724,11 @@ static void genesys_read_ordered_data(Genesys_Device* dev, SANE_Byte* destinatio
|
|||
}
|
||||
|
||||
debug_dump(DBG_info, dev->current_setup);
|
||||
debug_dump(DBG_info, dev->session.params);
|
||||
|
||||
/* prepare conversion */
|
||||
channels = dev->current_setup.params.channels;
|
||||
depth = dev->current_setup.params.depth;
|
||||
channels = dev->session.params.channels;
|
||||
depth = dev->session.params.depth;
|
||||
|
||||
src_pixels = dev->current_setup.pixels;
|
||||
|
||||
|
@ -4151,7 +4153,7 @@ static void calc_parameters(Genesys_Scanner* s)
|
|||
if (s->dev->settings.xres >= 1200 && (
|
||||
s->dev->model->asic_type == AsicType::GL124 ||
|
||||
s->dev->model->asic_type == AsicType::GL847 ||
|
||||
s->dev->current_setup.xres < s->dev->current_setup.params.yres))
|
||||
s->dev->current_setup.xres < s->dev->session.params.yres))
|
||||
{
|
||||
s->params.pixels_per_line = (s->params.pixels_per_line/16)*16;
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ struct Genesys_Calibration_Cache
|
|||
|
||||
// used to check if entry is compatible
|
||||
Genesys_Current_Setup used_setup;
|
||||
SetupParams params;
|
||||
time_t last_calibration = 0;
|
||||
|
||||
Genesys_Frontend frontend;
|
||||
|
@ -68,6 +69,7 @@ struct Genesys_Calibration_Cache
|
|||
bool operator==(const Genesys_Calibration_Cache& other) const
|
||||
{
|
||||
return used_setup == other.used_setup &&
|
||||
params == other.params &&
|
||||
last_calibration == other.last_calibration &&
|
||||
frontend == other.frontend &&
|
||||
sensor == other.sensor &&
|
||||
|
@ -84,6 +86,8 @@ void serialize(Stream& str, Genesys_Calibration_Cache& x)
|
|||
{
|
||||
serialize(str, x.used_setup);
|
||||
serialize_newline(str);
|
||||
serialize(str, x.params);
|
||||
serialize_newline(str);
|
||||
serialize(str, x.last_calibration);
|
||||
serialize_newline(str);
|
||||
serialize(str, x.frontend);
|
||||
|
|
|
@ -287,6 +287,8 @@ struct Genesys_Device
|
|||
|
||||
// contains the real used values
|
||||
Genesys_Current_Setup current_setup;
|
||||
// contains computed data for the current setup
|
||||
ScanSession session;
|
||||
|
||||
// look up table used in dynamic rasterization
|
||||
unsigned char lineart_lut[256] = {};
|
||||
|
|
|
@ -1314,7 +1314,7 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
dev->read_active = SANE_TRUE;
|
||||
|
||||
|
||||
dev->current_setup.params = params;
|
||||
dev->session.params = params;
|
||||
dev->current_setup.pixels = (used_pixels * used_res) / optical_res;
|
||||
DBG(DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels);
|
||||
dev->current_setup.lines = lincnt;
|
||||
|
@ -1433,7 +1433,7 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
/* lincnt */
|
||||
lincnt = params.lines + max_shift + stagger;
|
||||
|
||||
dev->current_setup.params = params;
|
||||
dev->session.params = params;
|
||||
dev->current_setup.pixels = (used_pixels * used_res) / optical_res;
|
||||
DBG (DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels);
|
||||
dev->current_setup.lines = lincnt;
|
||||
|
@ -2174,7 +2174,7 @@ static void gl124_send_shading_data(Genesys_Device* dev, const Genesys_Sensor& s
|
|||
{
|
||||
dev->binary=fopen("binary.pnm","wb");
|
||||
lines = dev->reg.get24(REG_LINCNT);
|
||||
channels = dev->current_setup.params.channels;
|
||||
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);
|
||||
|
|
|
@ -943,7 +943,7 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
|||
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
||||
dev->read_active = SANE_TRUE;
|
||||
|
||||
dev->current_setup.params = params;
|
||||
dev->session.params = params;
|
||||
dev->current_setup.pixels =
|
||||
((endx - startx) * sensor_mst->xdpi) / sensor.optical_res;
|
||||
dev->current_setup.lines = linecnt;
|
||||
|
@ -1731,13 +1731,13 @@ static void gl646_detect_document_end(Genesys_Device* dev)
|
|||
sanei_genesys_read_valid_words(dev, &bytes_left);
|
||||
|
||||
/* we add the number of lines needed to read the last part of the document in */
|
||||
lines = (SANE_UNFIX(dev->model->y_offset) * dev->current_setup.params.yres) / MM_PER_INCH;
|
||||
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;
|
||||
if (dev->current_setup.params.depth > 8) {
|
||||
if (dev->session.params.depth > 8) {
|
||||
bytes_left = 2 * bytes_left;
|
||||
}
|
||||
if (dev->current_setup.params.channels > 1) {
|
||||
if (dev->session.params.channels > 1) {
|
||||
bytes_left = 3 * bytes_left;
|
||||
}
|
||||
if (bytes_left < dev->read_bytes_left)
|
||||
|
@ -2249,7 +2249,7 @@ static void gl646_init_regs_for_shading(Genesys_Device* dev, const Genesys_Senso
|
|||
|
||||
/* used when sending shading calibration data */
|
||||
dev->calib_pixels = settings.pixels;
|
||||
dev->calib_channels = dev->current_setup.params.channels;
|
||||
dev->calib_channels = dev->session.params.channels;
|
||||
if (dev->model->is_cis == SANE_FALSE)
|
||||
{
|
||||
dev->calib_channels = 3;
|
||||
|
@ -3850,31 +3850,31 @@ gl646_is_compatible_calibration (Genesys_Device * dev, const Genesys_Sensor& sen
|
|||
*/
|
||||
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
||||
{
|
||||
dev->current_setup.params.channels = 3;
|
||||
dev->session.params.channels = 3;
|
||||
} else {
|
||||
dev->current_setup.params.channels = 1;
|
||||
dev->session.params.channels = 1;
|
||||
}
|
||||
dev->current_setup.xres = dev->settings.xres;
|
||||
|
||||
DBG(DBG_io, "%s: requested=(%d,%f), tested=(%d,%f)\n", __func__,
|
||||
dev->current_setup.params.channels, dev->current_setup.xres,
|
||||
cache->used_setup.params.channels, cache->used_setup.xres);
|
||||
dev->session.params.channels, dev->current_setup.xres,
|
||||
cache->params.channels, cache->used_setup.xres);
|
||||
|
||||
/* a calibration cache is compatible if color mode and x dpi match the user
|
||||
* requested scan. In the case of CIS scanners, dpi isn't a criteria */
|
||||
if (dev->model->is_cis == SANE_FALSE)
|
||||
{
|
||||
compatible = (dev->current_setup.params.channels == cache->used_setup.params.channels) &&
|
||||
compatible = (dev->session.params.channels == cache->params.channels) &&
|
||||
(((int) dev->current_setup.xres) == ((int) cache->used_setup.xres));
|
||||
} else {
|
||||
compatible = dev->current_setup.params.channels == cache->used_setup.params.channels;
|
||||
compatible = dev->session.params.channels == cache->params.channels;
|
||||
}
|
||||
|
||||
if (dev->current_setup.params.scan_method != cache->used_setup.params.scan_method)
|
||||
if (dev->session.params.scan_method != cache->params.scan_method)
|
||||
{
|
||||
DBG(DBG_io, "%s: current method=%d, used=%d\n", __func__,
|
||||
static_cast<unsigned>(dev->current_setup.params.scan_method),
|
||||
static_cast<unsigned>(cache->used_setup.params.scan_method));
|
||||
static_cast<unsigned>(dev->session.params.scan_method),
|
||||
static_cast<unsigned>(cache->params.scan_method));
|
||||
compatible = 0;
|
||||
}
|
||||
if (!compatible)
|
||||
|
|
|
@ -2038,7 +2038,7 @@ dummy \ scanned lines
|
|||
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
||||
dev->read_active = SANE_TRUE;
|
||||
|
||||
dev->current_setup.params = params;
|
||||
dev->session.params = params;
|
||||
dev->current_setup.pixels = (used_pixels * used_res)/optical_res;
|
||||
dev->current_setup.lines = lincnt;
|
||||
dev->current_setup.exposure_time = exposure_time;
|
||||
|
@ -2248,7 +2248,7 @@ dummy \ scanned lines
|
|||
|
||||
lincnt = params.lines + max_shift + stagger;
|
||||
|
||||
dev->current_setup.params = params;
|
||||
dev->session.params = params;
|
||||
dev->current_setup.pixels = (used_pixels * used_res)/optical_res;
|
||||
dev->current_setup.lines = lincnt;
|
||||
dev->current_setup.exposure_time = exposure_time;
|
||||
|
@ -4574,7 +4574,7 @@ static void gl841_send_shading_data(Genesys_Device* dev, const Genesys_Sensor& s
|
|||
{
|
||||
dev->binary=fopen("binary.pnm","wb");
|
||||
lines = dev->reg.get24(REG_LINCNT);
|
||||
channels = dev->current_setup.params.channels;
|
||||
channels = dev->session.params.channels;
|
||||
if(dev->binary!=NULL)
|
||||
{
|
||||
fprintf(dev->binary,"P5\n%d %d\n%d\n",(endpixel-strpixel)/factor*channels,lines/channels,255);
|
||||
|
|
|
@ -1449,7 +1449,7 @@ static void gl843_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
||||
dev->read_active = SANE_TRUE;
|
||||
|
||||
dev->current_setup.params = session.params;
|
||||
dev->session = session;
|
||||
dev->current_setup.pixels = session.output_pixels;
|
||||
DBG(DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels);
|
||||
dev->current_setup.lines = session.output_line_count;
|
||||
|
@ -1593,7 +1593,7 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
/* lincnt */
|
||||
lincnt = params.lines + max_shift + stagger;
|
||||
|
||||
dev->current_setup.params = params;
|
||||
dev->session.params = params;
|
||||
dev->current_setup.pixels = (used_pixels * used_res) / optical_res;
|
||||
DBG(DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels);
|
||||
dev->current_setup.lines = lincnt;
|
||||
|
@ -1745,8 +1745,8 @@ static void gl843_detect_document_end(Genesys_Device* dev)
|
|||
DBG(DBG_info, "%s: no more document\n", __func__);
|
||||
dev->document = SANE_FALSE;
|
||||
|
||||
unsigned channels = dev->current_setup.params.channels;
|
||||
unsigned depth = dev->current_setup.params.depth;
|
||||
unsigned channels = dev->session.params.channels;
|
||||
unsigned depth = dev->session.params.depth;
|
||||
read_bytes_left = (int) dev->read_bytes_left;
|
||||
DBG(DBG_io, "%s: read_bytes_left=%d\n", __func__, read_bytes_left);
|
||||
|
||||
|
@ -1771,7 +1771,7 @@ static void gl843_detect_document_end(Genesys_Device* dev)
|
|||
|
||||
// Adjust number of bytes to read. We need to read the final bytes which are word per
|
||||
// line times number of last lines to have doc leaving feeder
|
||||
lines = (SANE_UNFIX(dev->model->post_scan) * dev->current_setup.params.yres) / MM_PER_INCH +
|
||||
lines = (SANE_UNFIX(dev->model->post_scan) * dev->session.params.yres) / MM_PER_INCH +
|
||||
flines;
|
||||
|
||||
DBG(DBG_io, "%s: adding %d line to flush\n", __func__, lines);
|
||||
|
|
|
@ -1168,7 +1168,7 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
||||
dev->read_active = SANE_TRUE;
|
||||
|
||||
dev->current_setup.params = params;
|
||||
dev->session.params = params;
|
||||
dev->current_setup.pixels = (used_pixels * used_res) / optical_res;
|
||||
dev->current_setup.lines = lincnt;
|
||||
dev->current_setup.exposure_time = exposure_time;
|
||||
|
@ -1304,7 +1304,7 @@ gl846_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
/* lincnt */
|
||||
lincnt = params.lines + max_shift + stagger;
|
||||
|
||||
dev->current_setup.params = params;
|
||||
dev->session.params = params;
|
||||
dev->current_setup.pixels = (used_pixels * used_res) / optical_res;
|
||||
dev->current_setup.lines = lincnt;
|
||||
dev->current_setup.exposure_time = exposure_time;
|
||||
|
@ -1933,7 +1933,7 @@ static void gl846_send_shading_data(Genesys_Device* dev, const Genesys_Sensor& s
|
|||
{
|
||||
dev->binary=fopen("binary.pnm","wb");
|
||||
lines = dev->reg.get24(REG_LINCNT);
|
||||
unsigned channels = dev->current_setup.params.channels;
|
||||
unsigned channels = dev->session.params.channels;
|
||||
if(dev->binary!=NULL)
|
||||
{
|
||||
fprintf(dev->binary,"P5\n%d %d\n%d\n",(endpixel-strpixel)/factor*channels,lines/channels,255);
|
||||
|
|
|
@ -1185,7 +1185,7 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
||||
dev->read_active = SANE_TRUE;
|
||||
|
||||
dev->current_setup.params = params;
|
||||
dev->session.params = params;
|
||||
dev->current_setup.pixels = (used_pixels * used_res) / optical_res;
|
||||
dev->current_setup.lines = lincnt;
|
||||
dev->current_setup.exposure_time = exposure_time;
|
||||
|
@ -1322,7 +1322,7 @@ gl847_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
/* lincnt */
|
||||
lincnt = params.lines + max_shift + stagger;
|
||||
|
||||
dev->current_setup.params = params;
|
||||
dev->session.params = params;
|
||||
dev->current_setup.pixels = (used_pixels * used_res) / optical_res;
|
||||
dev->current_setup.lines = lincnt;
|
||||
dev->current_setup.exposure_time = exposure_time;
|
||||
|
@ -1988,7 +1988,7 @@ static void gl847_send_shading_data(Genesys_Device* dev, const Genesys_Sensor& s
|
|||
{
|
||||
dev->binary=fopen("binary.pnm","wb");
|
||||
lines = dev->reg.get24(REG_LINCNT);
|
||||
unsigned channels = dev->current_setup.params.channels;
|
||||
unsigned channels = dev->session.params.channels;
|
||||
if(dev->binary!=NULL)
|
||||
{
|
||||
fprintf(dev->binary,"P5\n%d %d\n%d\n",(endpixel-strpixel)/factor*channels,lines/channels,255);
|
||||
|
|
|
@ -1475,11 +1475,11 @@ bool sanei_genesys_is_compatible_calibration(Genesys_Device * dev, const Genesys
|
|||
dev->current_setup.ccd_size_divisor, cache->used_setup.ccd_size_divisor);
|
||||
compatible = 0;
|
||||
}
|
||||
if (dev->current_setup.params.scan_method != cache->used_setup.params.scan_method)
|
||||
if (dev->session.params.scan_method != cache->params.scan_method)
|
||||
{
|
||||
DBG (DBG_io, "%s: current method=%d, used=%d\n", __func__,
|
||||
static_cast<unsigned>(dev->current_setup.params.scan_method),
|
||||
static_cast<unsigned>(cache->used_setup.params.scan_method));
|
||||
static_cast<unsigned>(dev->session.params.scan_method),
|
||||
static_cast<unsigned>(cache->params.scan_method));
|
||||
compatible = 0;
|
||||
}
|
||||
if (!compatible)
|
||||
|
@ -1722,7 +1722,6 @@ void debug_dump(unsigned level, const Genesys_Current_Setup& setup)
|
|||
setup.ccd_size_divisor,
|
||||
setup.stagger,
|
||||
setup.max_shift);
|
||||
debug_dump(level, setup.params);
|
||||
}
|
||||
|
||||
void debug_dump(unsigned level, const Genesys_Register_Set& regs)
|
||||
|
|
|
@ -178,38 +178,49 @@ struct ScanSession {
|
|||
SetupParams params;
|
||||
|
||||
// whether the session setup has been computed via gl843_compute_session()
|
||||
// gl843-only
|
||||
bool computed = false;
|
||||
|
||||
// whether CCD operates as half-resolution or full resolution at a specific resolution
|
||||
// gl843-only
|
||||
unsigned ccd_size_divisor = 1;
|
||||
|
||||
// the optical resolution of the scanner.
|
||||
// gl843-only
|
||||
unsigned optical_resolution = 0;
|
||||
|
||||
// the number of pixels at the optical resolution.
|
||||
// gl843-only
|
||||
unsigned optical_pixels = 0;
|
||||
|
||||
// the number of bytes in the output of a single line directly from scanner
|
||||
// gl843-only
|
||||
unsigned optical_line_bytes = 0;
|
||||
|
||||
// the resolution of the output data.
|
||||
// gl843-only
|
||||
unsigned output_resolution = 0;
|
||||
|
||||
// the number of pixels in output data
|
||||
// gl843-only
|
||||
unsigned output_pixels = 0;
|
||||
|
||||
// the number of bytes in the output of a single line
|
||||
// gl843-only
|
||||
unsigned output_line_bytes = 0;
|
||||
|
||||
// the number of lines in the output of the scanner. This must be larger than the user
|
||||
// gl843-only
|
||||
// requested number due to line staggering and color channel shifting.
|
||||
unsigned output_line_count = 0;
|
||||
|
||||
// the number of staggered lines (i.e. lines that overlap during scanning due to line being
|
||||
// gl843-only
|
||||
// thinner than the CCD element)
|
||||
unsigned num_staggered_lines = 0;
|
||||
|
||||
// the number of lines that color channels shift due to different physical positions of
|
||||
// gl843-only
|
||||
// different color channels
|
||||
unsigned max_color_shift_lines = 0;
|
||||
|
||||
|
@ -223,9 +234,6 @@ struct ScanSession {
|
|||
|
||||
struct Genesys_Current_Setup
|
||||
{
|
||||
// params used for this setup
|
||||
SetupParams params;
|
||||
|
||||
// pixel count expected from scanner
|
||||
int pixels = 0;
|
||||
// line count expected from scanner
|
||||
|
@ -243,8 +251,7 @@ struct Genesys_Current_Setup
|
|||
|
||||
bool operator==(const Genesys_Current_Setup& other) const
|
||||
{
|
||||
return params == other.params &&
|
||||
pixels == other.pixels &&
|
||||
return pixels == other.pixels &&
|
||||
lines == other.lines &&
|
||||
exposure_time == other.exposure_time &&
|
||||
xres == other.xres &&
|
||||
|
@ -257,8 +264,6 @@ struct Genesys_Current_Setup
|
|||
template<class Stream>
|
||||
void serialize(Stream& str, Genesys_Current_Setup& x)
|
||||
{
|
||||
serialize(str, x.params);
|
||||
serialize_newline(str);
|
||||
serialize(str, x.pixels);
|
||||
serialize(str, x.lines);
|
||||
serialize(str, x.exposure_time);
|
||||
|
|
|
@ -36,6 +36,11 @@ Genesys_Calibration_Cache create_fake_calibration_entry()
|
|||
calib.used_setup.lines = 150;
|
||||
calib.used_setup.xres = 100.5;
|
||||
|
||||
calib.params.channels = 3;
|
||||
calib.params.depth = 8;
|
||||
calib.params.lines = 100;
|
||||
calib.params.pixels = 200;
|
||||
|
||||
GenesysFrontendLayout wolfson_layout;
|
||||
wolfson_layout.offset_addr = { 0x20, 0x21, 0x22 };
|
||||
wolfson_layout.gain_addr = { 0x28, 0x29, 0x2a };
|
||||
|
|
Ładowanie…
Reference in New Issue