kopia lustrzana https://gitlab.com/sane-project/backends
Merge branch 'genesys-ensure-correct-resolution-high-level' into 'master'
genesys: Ensure that correct resolution is passed from high level See merge request sane-project/backends!145merge-requests/146/merge
commit
66c804a7ea
|
@ -3666,7 +3666,7 @@ static void genesys_read_ordered_data(Genesys_Device* dev, SANE_Byte* destinatio
|
|||
needs_reorder = 0;
|
||||
|
||||
needs_ccd = dev->current_setup.max_shift > 0;
|
||||
needs_shrink = dev->settings.pixels != src_pixels;
|
||||
needs_shrink = dev->settings.requested_pixels != src_pixels;
|
||||
needs_reverse = depth == 1;
|
||||
|
||||
DBG(DBG_info, "%s: using filters:%s%s%s%s\n", __func__,
|
||||
|
@ -3696,7 +3696,7 @@ static void genesys_read_ordered_data(Genesys_Device* dev, SANE_Byte* destinatio
|
|||
|
||||
DBG(DBG_info, "%s: %lu lines left by output\n", __func__,
|
||||
((dev->total_bytes_to_read - dev->total_bytes_read) * 8UL) /
|
||||
(dev->settings.pixels * channels * depth));
|
||||
(dev->settings.requested_pixels * channels * depth));
|
||||
DBG(DBG_info, "%s: %lu lines left by input\n", __func__,
|
||||
((dev->read_bytes_left + dev->read_buffer.avail()) * 8UL) /
|
||||
(src_pixels * channels * depth));
|
||||
|
@ -3917,10 +3917,11 @@ Problems with the first approach:
|
|||
/* we are greedy. we work as much as possible */
|
||||
bytes = dst_buffer->size() - dst_buffer->avail();
|
||||
|
||||
if (dst_lines > (bytes * 8) / (dev->settings.pixels * channels * depth))
|
||||
dst_lines = (bytes * 8) / (dev->settings.pixels * channels * depth);
|
||||
if (dst_lines > (bytes * 8) / (dev->settings.requested_pixels * channels * depth)) {
|
||||
dst_lines = (bytes * 8) / (dev->settings.requested_pixels * channels * depth);
|
||||
}
|
||||
|
||||
bytes = (dst_lines * dev->settings.pixels * channels * depth) / 8;
|
||||
bytes = (dst_lines * dev->settings.requested_pixels * channels * depth) / 8;
|
||||
|
||||
work_buffer_dst = dst_buffer->get_write_pos(bytes);
|
||||
|
||||
|
@ -3930,21 +3931,21 @@ Problems with the first approach:
|
|||
{
|
||||
if (depth == 1)
|
||||
genesys_shrink_lines_1(work_buffer_src, work_buffer_dst, dst_lines, src_pixels,
|
||||
dev->settings.pixels, channels);
|
||||
dev->settings.requested_pixels, channels);
|
||||
else if (depth == 8)
|
||||
genesys_shrink_lines_8(work_buffer_src, work_buffer_dst, dst_lines, src_pixels,
|
||||
dev->settings.pixels, channels);
|
||||
dev->settings.requested_pixels, channels);
|
||||
else
|
||||
genesys_shrink_lines_16(work_buffer_src, work_buffer_dst, dst_lines, src_pixels,
|
||||
dev->settings.pixels, channels);
|
||||
dev->settings.requested_pixels, channels);
|
||||
|
||||
/* we just consumed this many bytes*/
|
||||
bytes = (dst_lines * src_pixels * channels * depth) / 8;
|
||||
src_buffer->consume(bytes);
|
||||
|
||||
/* we just created this many bytes*/
|
||||
bytes = (dst_lines * dev->settings.pixels * channels * depth) / 8;
|
||||
dst_buffer->produce(bytes);
|
||||
bytes = (dst_lines * dev->settings.requested_pixels * channels * depth) / 8;
|
||||
dst_buffer->produce(bytes);
|
||||
}
|
||||
src_buffer = dst_buffer;
|
||||
}
|
||||
|
@ -4009,6 +4010,32 @@ max_string_size (const SANE_String_Const strings[])
|
|||
return max_size;
|
||||
}
|
||||
|
||||
static unsigned pick_resolution(const std::vector<unsigned>& resolutions, unsigned resolution,
|
||||
const char* direction)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
|
||||
if (resolutions.empty())
|
||||
throw SaneException("Empty resolution list");
|
||||
|
||||
unsigned best_res = resolutions.front();
|
||||
unsigned min_diff = abs_diff(best_res, resolution);
|
||||
|
||||
for (auto it = std::next(resolutions.begin()); it != resolutions.end(); ++it) {
|
||||
unsigned curr_diff = abs_diff(*it, resolution);
|
||||
if (curr_diff < min_diff) {
|
||||
min_diff = curr_diff;
|
||||
best_res = *it;
|
||||
}
|
||||
}
|
||||
|
||||
if (best_res != resolution) {
|
||||
DBG(DBG_warn, "%s: using resolution %d that is nearest to %d for direction %s\n",
|
||||
__func__, best_res, resolution, direction);
|
||||
}
|
||||
return best_res;
|
||||
}
|
||||
|
||||
static void calc_parameters(Genesys_Scanner* s)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
|
@ -4049,8 +4076,11 @@ static void calc_parameters(Genesys_Scanner* s)
|
|||
}
|
||||
s->dev->settings.yres = s->resolution;
|
||||
|
||||
s->dev->settings.xres = pick_resolution(s->dev->model->xdpi_values, s->dev->settings.xres, "X");
|
||||
s->dev->settings.yres = pick_resolution(s->dev->model->ydpi_values, s->dev->settings.yres, "Y");
|
||||
|
||||
s->params.lines = ((br_y - tl_y) * s->dev->settings.yres) / MM_PER_INCH;
|
||||
s->params.pixels_per_line = ((br_x - tl_x) * s->resolution) / MM_PER_INCH;
|
||||
unsigned pixels_per_line = ((br_x - tl_x) * s->dev->settings.xres) / MM_PER_INCH;
|
||||
|
||||
/* we need an even pixels number
|
||||
* TODO invert test logic or generalize behaviour across all ASICs */
|
||||
|
@ -4061,10 +4091,15 @@ static void calc_parameters(Genesys_Scanner* s)
|
|||
s->dev->model->asic_type == AsicType::GL846 ||
|
||||
s->dev->model->asic_type == AsicType::GL843)
|
||||
{
|
||||
if (s->dev->settings.xres <= 1200)
|
||||
s->params.pixels_per_line = (s->params.pixels_per_line/4)*4;
|
||||
else
|
||||
s->params.pixels_per_line = (s->params.pixels_per_line/16)*16;
|
||||
if (s->dev->settings.xres <= 1200) {
|
||||
pixels_per_line = (pixels_per_line / 4) * 4;
|
||||
} else if (s->dev->settings.xres < s->dev->settings.yres) {
|
||||
// BUG: this is an artifact of the fact that the resolution was twice as large than
|
||||
// the actual resolution when scanning above the supported scanner X resolution
|
||||
pixels_per_line = (pixels_per_line / 8) * 8;
|
||||
} else {
|
||||
pixels_per_line = (pixels_per_line / 16) * 16;
|
||||
}
|
||||
}
|
||||
|
||||
/* corner case for true lineart for sensor with several segments
|
||||
|
@ -4074,25 +4109,35 @@ static void calc_parameters(Genesys_Scanner* s)
|
|||
s->dev->model->asic_type == AsicType::GL847 ||
|
||||
s->dev->current_setup.xres < s->dev->session.params.yres))
|
||||
{
|
||||
s->params.pixels_per_line = (s->params.pixels_per_line/16)*16;
|
||||
if (s->dev->settings.xres < s->dev->settings.yres) {
|
||||
// FIXME: this is an artifact of the fact that the resolution was twice as large than
|
||||
// the actual resolution when scanning above the supported scanner X resolution
|
||||
pixels_per_line = (pixels_per_line / 8) * 8;
|
||||
} else {
|
||||
pixels_per_line = (pixels_per_line / 16) * 16;
|
||||
}
|
||||
}
|
||||
|
||||
s->params.bytes_per_line = s->params.pixels_per_line;
|
||||
unsigned xres_factor = s->resolution / s->dev->settings.xres;
|
||||
|
||||
unsigned bytes_per_line = 0;
|
||||
|
||||
if (s->params.depth > 8)
|
||||
{
|
||||
s->params.depth = 16;
|
||||
s->params.bytes_per_line *= 2;
|
||||
bytes_per_line = 2 * pixels_per_line;
|
||||
}
|
||||
else if (s->params.depth == 1)
|
||||
{
|
||||
s->params.bytes_per_line /= 8;
|
||||
/* round down pixel number
|
||||
really? rounding down means loss of at most 7 pixels! -- pierre */
|
||||
s->params.pixels_per_line = 8 * s->params.bytes_per_line;
|
||||
// round down pixel number. This will is lossy operation, at most 7 pixels will be lost
|
||||
pixels_per_line = (pixels_per_line / 8) * 8;
|
||||
bytes_per_line = pixels_per_line / 8;
|
||||
} else {
|
||||
bytes_per_line = pixels_per_line;
|
||||
}
|
||||
|
||||
if (s->params.format == SANE_FRAME_RGB) {
|
||||
s->params.bytes_per_line *= 3;
|
||||
bytes_per_line *= 3;
|
||||
}
|
||||
|
||||
if (s->mode == SANE_VALUE_SCAN_MODE_COLOR) {
|
||||
|
@ -4114,7 +4159,10 @@ static void calc_parameters(Genesys_Scanner* s)
|
|||
}
|
||||
|
||||
s->dev->settings.lines = s->params.lines;
|
||||
s->dev->settings.pixels = s->params.pixels_per_line;
|
||||
s->dev->settings.pixels = pixels_per_line;
|
||||
s->dev->settings.requested_pixels = pixels_per_line * xres_factor;
|
||||
s->params.pixels_per_line = pixels_per_line * xres_factor;
|
||||
s->params.bytes_per_line = bytes_per_line * xres_factor;
|
||||
s->dev->settings.tl_x = tl_x;
|
||||
s->dev->settings.tl_y = tl_y;
|
||||
|
||||
|
@ -4431,18 +4479,21 @@ static void init_options(Genesys_Scanner* s)
|
|||
s->opt[OPT_BIT_DEPTH].constraint.word_list = s->bpp_list;
|
||||
create_bpp_list (s, model->bpp_gray_values);
|
||||
s->bit_depth = 8;
|
||||
if (s->opt[OPT_BIT_DEPTH].constraint.word_list[0] < 2)
|
||||
DISABLE (OPT_BIT_DEPTH);
|
||||
if (s->opt[OPT_BIT_DEPTH].constraint.word_list[0] < 2) {
|
||||
DISABLE (OPT_BIT_DEPTH);
|
||||
}
|
||||
|
||||
/* resolution */
|
||||
unsigned min_dpi = *std::min_element(model->xdpi_values.begin(), model->xdpi_values.end());
|
||||
// resolution
|
||||
auto resolutions = model->get_resolutions();
|
||||
|
||||
dpi_list = (SANE_Word*) malloc((model->xdpi_values.size() + 1) * sizeof(SANE_Word));
|
||||
unsigned min_dpi = *std::min_element(resolutions.begin(), resolutions.end());
|
||||
|
||||
dpi_list = (SANE_Word*) malloc((resolutions.size() + 1) * sizeof(SANE_Word));
|
||||
if (!dpi_list) {
|
||||
throw SaneException(SANE_STATUS_NO_MEM);
|
||||
}
|
||||
dpi_list[0] = model->xdpi_values.size();
|
||||
std::copy(model->xdpi_values.begin(), model->xdpi_values.end(), dpi_list + 1);
|
||||
dpi_list[0] = resolutions.size();
|
||||
std::copy(resolutions.begin(), resolutions.end(), dpi_list + 1);
|
||||
|
||||
s->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION;
|
||||
s->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION;
|
||||
|
@ -5108,7 +5159,7 @@ probe_genesys_devices (void)
|
|||
of Genesys_Calibration_Cache as is.
|
||||
*/
|
||||
static const char* CALIBRATION_IDENT = "sane_genesys";
|
||||
static const int CALIBRATION_VERSION = 6;
|
||||
static const int CALIBRATION_VERSION = 7;
|
||||
|
||||
bool read_calibration(std::istream& str, Genesys_Device::Calibration& calibration,
|
||||
const std::string& path)
|
||||
|
@ -5638,7 +5689,7 @@ get_option_value (Genesys_Scanner * s, int option, void *val)
|
|||
unsigned option_size = 0;
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
|
||||
const Genesys_Sensor& sensor = sanei_genesys_find_sensor(s->dev, s->resolution,
|
||||
const Genesys_Sensor& sensor = sanei_genesys_find_sensor(s->dev, s->dev->settings.xres,
|
||||
s->dev->settings.get_channels(),
|
||||
s->dev->settings.scan_method);
|
||||
|
||||
|
@ -6168,7 +6219,7 @@ set_option_value (Genesys_Scanner * s, int option, void *val,
|
|||
}
|
||||
break;
|
||||
case OPT_CALIBRATE: {
|
||||
auto& sensor = sanei_genesys_find_sensor_for_write(s->dev, s->resolution,
|
||||
auto& sensor = sanei_genesys_find_sensor_for_write(s->dev, s->dev->settings.xres,
|
||||
s->dev->settings.get_channels(),
|
||||
s->dev->settings.scan_method);
|
||||
catch_all_exceptions(__func__, [&]()
|
||||
|
|
|
@ -178,6 +178,18 @@ struct Genesys_Model
|
|||
SANE_Int shading_ta_lines = 0;
|
||||
// how many lines are used to search start position
|
||||
SANE_Int search_lines = 0;
|
||||
|
||||
std::vector<unsigned> get_resolutions() const
|
||||
{
|
||||
std::vector<unsigned> ret;
|
||||
std::copy(xdpi_values.begin(), xdpi_values.end(), std::back_inserter(ret));
|
||||
std::copy(ydpi_values.begin(), ydpi_values.end(), std::back_inserter(ret));
|
||||
// sort in decreasing order
|
||||
|
||||
std::sort(ret.begin(), ret.end(), std::greater<unsigned>());
|
||||
ret.erase(std::unique(ret.begin(), ret.end()), ret.end());
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -1241,14 +1241,15 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
|
||||
dev->total_bytes_read = 0;
|
||||
if (session.params.depth == 1) {
|
||||
dev->total_bytes_to_read = ((dev->settings.pixels * dev->settings.lines) / 8 +
|
||||
(((dev->settings.pixels * dev->settings.lines) % 8) ? 1 : 0)) * session.params.channels;
|
||||
dev->total_bytes_to_read = ((session.params.get_requested_pixels() * dev->settings.lines) / 8 +
|
||||
(((session.params.get_requested_pixels() * dev->settings.lines) % 8) ? 1 : 0)) * session.params.channels;
|
||||
} else {
|
||||
dev->total_bytes_to_read = dev->settings.pixels * dev->settings.lines *
|
||||
dev->total_bytes_to_read = session.params.get_requested_pixels() * dev->settings.lines *
|
||||
session.params.channels * (session.params.depth / 8);
|
||||
}
|
||||
|
||||
DBG(DBG_info, "%s: total bytes to send = %lu\n", __func__, (u_long) dev->total_bytes_to_read);
|
||||
DBG(DBG_info, "%s: total bytes to send to frontend = %lu\n", __func__,
|
||||
(u_long) dev->total_bytes_to_read);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1280,6 +1281,7 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
session.params.startx = start;
|
||||
session.params.starty = 0; // not used
|
||||
session.params.pixels = dev->settings.pixels;
|
||||
session.params.requested_pixels = dev->settings.requested_pixels;
|
||||
session.params.lines = dev->settings.lines;
|
||||
session.params.depth = dev->settings.get_depth();
|
||||
session.params.channels = dev->settings.get_channels();
|
||||
|
@ -2012,6 +2014,7 @@ static void gl124_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor&
|
|||
session.params.startx = start;
|
||||
session.params.starty = move;
|
||||
session.params.pixels = dev->settings.pixels;
|
||||
session.params.requested_pixels = dev->settings.requested_pixels;
|
||||
session.params.lines = dev->settings.lines;
|
||||
session.params.depth = dev->settings.get_depth();
|
||||
session.params.channels = dev->settings.get_channels();
|
||||
|
|
|
@ -816,6 +816,7 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
|||
*/
|
||||
dev->total_bytes_read = 0;
|
||||
if (session.params.depth == 1) {
|
||||
// BUG: should use settings.requested_pixels
|
||||
dev->total_bytes_to_read = ((session.params.pixels * session.params.lines) / 8 +
|
||||
(((session.params.pixels * session.params.lines) % 8) ? 1 : 0)) * session.params.channels;
|
||||
} else {
|
||||
|
|
|
@ -2016,11 +2016,11 @@ dummy \ scanned lines
|
|||
|
||||
dev->total_bytes_read = 0;
|
||||
if (session.params.depth == 1) {
|
||||
dev->total_bytes_to_read = ((dev->settings.pixels * dev->settings.lines) / 8 +
|
||||
(((dev->settings.pixels * dev->settings.lines)%8)?1:0)) * session.params.channels;
|
||||
dev->total_bytes_to_read = ((session.params.get_requested_pixels() * dev->settings.lines) / 8 +
|
||||
(((session.params.get_requested_pixels() * dev->settings.lines)%8)?1:0)) * session.params.channels;
|
||||
} else {
|
||||
dev->total_bytes_to_read =
|
||||
dev->settings.pixels * dev->settings.lines * session.params.channels * (session.params.depth / 8);
|
||||
session.params.get_requested_pixels() * dev->settings.lines * session.params.channels * (session.params.depth / 8);
|
||||
}
|
||||
|
||||
DBG(DBG_info, "%s: total bytes to send = %lu\n", __func__, (u_long) dev->total_bytes_to_read);
|
||||
|
@ -2059,6 +2059,7 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se
|
|||
session.params.startx = start;
|
||||
session.params.starty = 0; // not used
|
||||
session.params.pixels = dev->settings.pixels;
|
||||
session.params.requested_pixels = dev->settings.requested_pixels;
|
||||
session.params.lines = dev->settings.lines;
|
||||
session.params.depth = dev->settings.get_depth();
|
||||
session.params.channels = dev->settings.get_channels();
|
||||
|
@ -3109,6 +3110,7 @@ static void gl841_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor&
|
|||
session.params.startx = start;
|
||||
session.params.starty = move;
|
||||
session.params.pixels = dev->settings.pixels;
|
||||
session.params.requested_pixels = dev->settings.requested_pixels;
|
||||
session.params.lines = dev->settings.lines;
|
||||
session.params.depth = dev->settings.get_depth();
|
||||
session.params.channels = dev->settings.get_channels();
|
||||
|
|
|
@ -1386,11 +1386,11 @@ static void gl843_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
|
||||
dev->total_bytes_read = 0;
|
||||
if (session.params.depth == 1) {
|
||||
dev->total_bytes_to_read = ((session.params.pixels * session.params.lines) / 8 +
|
||||
(((session.params.pixels * session.params.lines) % 8) ? 1 : 0)) *
|
||||
dev->total_bytes_to_read = ((session.params.get_requested_pixels() * session.params.lines) / 8 +
|
||||
(((session.params.get_requested_pixels() * session.params.lines) % 8) ? 1 : 0)) *
|
||||
session.params.channels;
|
||||
} else {
|
||||
dev->total_bytes_to_read = session.params.pixels * session.params.lines *
|
||||
dev->total_bytes_to_read = session.params.get_requested_pixels() * session.params.lines *
|
||||
session.params.channels * (session.params.depth / 8);
|
||||
}
|
||||
|
||||
|
@ -1440,6 +1440,7 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
session.params.startx = start; // not used
|
||||
session.params.starty = 0; // not used
|
||||
session.params.pixels = dev->settings.pixels;
|
||||
session.params.requested_pixels = dev->settings.requested_pixels;
|
||||
session.params.lines = dev->settings.lines;
|
||||
session.params.depth = dev->settings.get_depth();
|
||||
session.params.channels = dev->settings.get_channels();
|
||||
|
@ -2556,6 +2557,7 @@ static void gl843_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor&
|
|||
session.params.startx = start;
|
||||
session.params.starty = move;
|
||||
session.params.pixels = dev->settings.pixels;
|
||||
session.params.requested_pixels = dev->settings.requested_pixels;
|
||||
session.params.lines = dev->settings.lines;
|
||||
session.params.depth = dev->settings.get_depth();
|
||||
session.params.channels = dev->settings.get_channels();
|
||||
|
|
|
@ -1121,11 +1121,11 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
|
||||
dev->total_bytes_read = 0;
|
||||
if (session.params.depth == 1) {
|
||||
dev->total_bytes_to_read = ((session.params.pixels * session.params.lines) / 8 +
|
||||
(((session.params.pixels * session.params.lines) % 8) ? 1 : 0)) *
|
||||
dev->total_bytes_to_read = ((session.params.get_requested_pixels() * session.params.lines) / 8 +
|
||||
(((session.params.get_requested_pixels() * session.params.lines) % 8) ? 1 : 0)) *
|
||||
session.params.channels;
|
||||
} else {
|
||||
dev->total_bytes_to_read = session.params.pixels * session.params.lines * session.params.channels * (session.params.depth / 8);
|
||||
dev->total_bytes_to_read = session.params.get_requested_pixels() * session.params.lines * session.params.channels * (session.params.depth / 8);
|
||||
}
|
||||
|
||||
DBG(DBG_info, "%s: total bytes to send = %lu\n", __func__, (u_long) dev->total_bytes_to_read);
|
||||
|
@ -1163,6 +1163,7 @@ gl846_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
session.params.startx = start; // not used
|
||||
session.params.starty = 0; // not used
|
||||
session.params.pixels = dev->settings.pixels;
|
||||
session.params.requested_pixels = dev->settings.requested_pixels;
|
||||
session.params.lines = dev->settings.lines;
|
||||
session.params.depth = dev->settings.get_depth();
|
||||
session.params.channels = dev->settings.get_channels();
|
||||
|
@ -1781,6 +1782,7 @@ static void gl846_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor&
|
|||
session.params.startx = start;
|
||||
session.params.starty = move;
|
||||
session.params.pixels = dev->settings.pixels;
|
||||
session.params.requested_pixels = dev->settings.requested_pixels;
|
||||
session.params.lines = dev->settings.lines;
|
||||
session.params.depth = dev->settings.get_depth();
|
||||
session.params.channels = dev->settings.get_channels();
|
||||
|
|
|
@ -1136,10 +1136,10 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
|
||||
dev->total_bytes_read = 0;
|
||||
if (session.params.depth == 1) {
|
||||
dev->total_bytes_to_read = ((session.params.pixels * session.params.lines) / 8 +
|
||||
(((session.params.pixels * session.params.lines) % 8) ? 1 : 0)) * session.params.channels;
|
||||
dev->total_bytes_to_read = ((session.params.get_requested_pixels() * session.params.lines) / 8 +
|
||||
(((session.params.get_requested_pixels() * session.params.lines) % 8) ? 1 : 0)) * session.params.channels;
|
||||
} else {
|
||||
dev->total_bytes_to_read = session.params.pixels * session.params.lines * session.params.channels * (session.params.depth / 8);
|
||||
dev->total_bytes_to_read = session.params.get_requested_pixels() * session.params.lines * session.params.channels * (session.params.depth / 8);
|
||||
}
|
||||
|
||||
DBG(DBG_info, "%s: total bytes to send = %lu\n", __func__, (u_long) dev->total_bytes_to_read);
|
||||
|
@ -1177,6 +1177,7 @@ gl847_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
session.params.startx = start; // not used
|
||||
session.params.starty = 0; // not used
|
||||
session.params.pixels = dev->settings.pixels;
|
||||
session.params.requested_pixels = dev->settings.requested_pixels;
|
||||
session.params.lines = dev->settings.lines;
|
||||
session.params.depth = dev->settings.get_depth();
|
||||
session.params.channels = dev->settings.get_channels();
|
||||
|
@ -1834,6 +1835,7 @@ static void gl847_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor&
|
|||
session.params.startx = start;
|
||||
session.params.starty = move;
|
||||
session.params.pixels = dev->settings.pixels;
|
||||
session.params.requested_pixels = dev->settings.requested_pixels;
|
||||
session.params.lines = dev->settings.lines;
|
||||
session.params.depth = dev->settings.get_depth();
|
||||
session.params.channels = dev->settings.get_channels();
|
||||
|
|
|
@ -1744,11 +1744,12 @@ void debug_dump(unsigned level, const Genesys_Settings& settings)
|
|||
"Resolution X/Y : %u / %u dpi\n"
|
||||
"Lines : %u\n"
|
||||
"Pixels per line : %u\n"
|
||||
"Pixels per line (requested) : %u\n"
|
||||
"Depth : %u\n"
|
||||
"Start position X/Y : %.3f/%.3f\n"
|
||||
"Scan mode : %d\n\n",
|
||||
settings.xres, settings.yres,
|
||||
settings.lines, settings.pixels, settings.depth,
|
||||
settings.lines, settings.pixels, settings.requested_pixels, settings.depth,
|
||||
settings.tl_x, settings.tl_y,
|
||||
static_cast<unsigned>(settings.scan_mode));
|
||||
}
|
||||
|
@ -1759,6 +1760,7 @@ void debug_dump(unsigned level, const SetupParams& params)
|
|||
"Resolution X/Y : %u / %u dpi\n"
|
||||
"Lines : %u\n"
|
||||
"Pixels per line : %u\n"
|
||||
"Pixels per line (requested) : %u\n"
|
||||
"Depth : %u\n"
|
||||
"Channels : %u\n"
|
||||
"Start position X/Y : %g / %g\n"
|
||||
|
@ -1766,7 +1768,7 @@ void debug_dump(unsigned level, const SetupParams& params)
|
|||
"Color filter : %d\n"
|
||||
"Flags : %x\n",
|
||||
params.xres, params.yres,
|
||||
params.lines, params.pixels,
|
||||
params.lines, params.pixels, params.requested_pixels,
|
||||
params.depth, params.channels,
|
||||
params.startx, params.starty,
|
||||
static_cast<unsigned>(params.scan_mode),
|
||||
|
|
|
@ -637,6 +637,16 @@ extern void sanei_genesys_generate_gamma_buffer(Genesys_Device* dev,
|
|||
|
||||
void compute_session(Genesys_Device* dev, ScanSession& s, const Genesys_Sensor& sensor);
|
||||
|
||||
template<class T>
|
||||
inline T abs_diff(T a, T b)
|
||||
{
|
||||
if (a < b) {
|
||||
return b - a;
|
||||
} else {
|
||||
return a - b;
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* ASIC specific functions declarations */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -64,8 +64,10 @@ struct Genesys_Settings
|
|||
|
||||
// number of lines at scan resolution
|
||||
unsigned int lines = 0;
|
||||
// number of pixels at scan resolution
|
||||
// number of pixels expected from the scanner
|
||||
unsigned int pixels = 0;
|
||||
// number of pixels expected by the frontend
|
||||
unsigned requested_pixels = 0;
|
||||
|
||||
// bit depth of the scan
|
||||
unsigned int depth = 0;
|
||||
|
@ -127,6 +129,14 @@ struct SetupParams {
|
|||
// the number of pixels in X direction. Note that each logical pixel may correspond to more
|
||||
// than one CCD pixel, see CKSEL and GenesysSensor::ccd_pixels_per_system_pixel()
|
||||
unsigned pixels = NOT_SET;
|
||||
|
||||
// the number of pixels in the X direction as requested by the frontend. This will be different
|
||||
// from `pixels` if the X resolution requested by the frontend is different than the actual
|
||||
// resolution. This is only needed to compute dev->total_bytes_to_read. If 0, then the value
|
||||
// is the same as pixels.
|
||||
// TODO: move the computation of total_bytes_to_read to a higher layer.
|
||||
unsigned requested_pixels = 0;
|
||||
|
||||
// the number of pixels in Y direction
|
||||
unsigned lines = NOT_SET;
|
||||
// the depth of the scan in bits. Allowed are 1, 8, 16
|
||||
|
@ -142,6 +152,14 @@ struct SetupParams {
|
|||
|
||||
unsigned flags = NOT_SET;
|
||||
|
||||
unsigned get_requested_pixels() const
|
||||
{
|
||||
if (requested_pixels != 0) {
|
||||
return requested_pixels;
|
||||
}
|
||||
return pixels;
|
||||
}
|
||||
|
||||
void assert_valid() const
|
||||
{
|
||||
if (xres == NOT_SET || yres == NOT_SET || startx < 0 || starty < 0 ||
|
||||
|
@ -162,6 +180,7 @@ struct SetupParams {
|
|||
startx == other.startx &&
|
||||
starty == other.starty &&
|
||||
pixels == other.pixels &&
|
||||
requested_pixels == other.requested_pixels &&
|
||||
lines == other.lines &&
|
||||
depth == other.depth &&
|
||||
channels == other.channels &&
|
||||
|
@ -180,6 +199,7 @@ void serialize(Stream& str, SetupParams& x)
|
|||
serialize(str, x.startx);
|
||||
serialize(str, x.starty);
|
||||
serialize(str, x.pixels);
|
||||
serialize(str, x.requested_pixels);
|
||||
serialize(str, x.lines);
|
||||
serialize(str, x.depth);
|
||||
serialize(str, x.channels);
|
||||
|
|
|
@ -645,7 +645,7 @@ void genesys_init_usb_device_tables()
|
|||
model.model_id = MODEL_CANON_LIDE_110;
|
||||
model.asic_type = AsicType::GL124;
|
||||
|
||||
model.xdpi_values = { 4800, 2400, 1200, 600, /* 400,*/ 300, 150, 100, 75 };
|
||||
model.xdpi_values = { 2400, 1200, 600, /* 400,*/ 300, 150, 100, 75 };
|
||||
model.ydpi_values = { 4800, 2400, 1200, 600, /* 400,*/ 300, 150, 100, 75 };
|
||||
model.bpp_gray_values = { 16, 8 };
|
||||
model.bpp_color_values = { 16, 8 };
|
||||
|
@ -1174,8 +1174,11 @@ void genesys_init_usb_device_tables()
|
|||
model.model_id = MODEL_HP_SCANJET_2300C;
|
||||
model.asic_type = AsicType::GL646;
|
||||
|
||||
// FIXME: the scanner supports 1200 ydpi, but we never scanned at this resolution so for now
|
||||
// it's not supported
|
||||
model.xdpi_values = { 600, 300, 150, 75 };
|
||||
model.ydpi_values = { 1200, 600, 300, 150, 75 };
|
||||
model.ydpi_values = { /* 1200, */600, 300, 150, 75 };
|
||||
|
||||
model.bpp_gray_values = { 16, 8 };
|
||||
model.bpp_color_values = { 16, 8 };
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue