kopia lustrzana https://gitlab.com/sane-project/backends
Merge branch 'genesys-misc-fixes' into 'master'
genesys: Miscellaneous fixes for numerous scanners See merge request sane-project/backends!222merge-requests/224/head
commit
6b0f3ca124
|
@ -72,8 +72,7 @@ static unsigned num_uncaught_exceptions()
|
|||
|
||||
SaneException::SaneException(SANE_Status status) : status_(status)
|
||||
{
|
||||
std::va_list args;
|
||||
set_msg(nullptr, args);
|
||||
set_msg();
|
||||
}
|
||||
|
||||
SaneException::SaneException(SANE_Status status, const char* format, ...) : status_(status)
|
||||
|
@ -102,17 +101,19 @@ const char* SaneException::what() const noexcept
|
|||
return msg_.c_str();
|
||||
}
|
||||
|
||||
void SaneException::set_msg()
|
||||
{
|
||||
const char* status_msg = sane_strstatus(status_);
|
||||
std::size_t status_msg_len = std::strlen(status_msg);
|
||||
msg_.reserve(status_msg_len);
|
||||
msg_ = status_msg;
|
||||
}
|
||||
|
||||
void SaneException::set_msg(const char* format, std::va_list vlist)
|
||||
{
|
||||
const char* status_msg = sane_strstatus(status_);
|
||||
std::size_t status_msg_len = std::strlen(status_msg);
|
||||
|
||||
if (format == nullptr) {
|
||||
msg_.reserve(status_msg_len);
|
||||
msg_ = status_msg;
|
||||
return;
|
||||
}
|
||||
|
||||
int msg_len = std::vsnprintf(nullptr, 0, format, vlist);
|
||||
if (msg_len < 0) {
|
||||
const char* formatting_error_msg = "(error formatting arguments)";
|
||||
|
|
|
@ -86,6 +86,7 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
void set_msg();
|
||||
void set_msg(const char* format, std::va_list vlist);
|
||||
|
||||
std::string msg_;
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
#include "../include/sane/sanei_magic.h"
|
||||
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
|
@ -2495,10 +2496,8 @@ static void genesys_send_shading_coefficient(Genesys_Device* dev, const Genesys_
|
|||
case SensorId::CIS_CANON_LIDE_120:
|
||||
case SensorId::CIS_CANON_LIDE_210:
|
||||
case SensorId::CIS_CANON_LIDE_220:
|
||||
target_code = 0xf000;
|
||||
break;
|
||||
case SensorId::CIS_CANON_LIDE_700F:
|
||||
target_code = 0xc000; /* from experimentation */
|
||||
target_code = 0xc000;
|
||||
break;
|
||||
default:
|
||||
target_code = 0xdc00;
|
||||
|
|
|
@ -825,12 +825,10 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
|
||||
sanei_genesys_set_dpihw(*reg, sensor, dpihw);
|
||||
|
||||
// enable gamma tables
|
||||
r = sanei_genesys_get_address (reg, REG_0x05);
|
||||
if (session.params.flags & SCAN_FLAG_DISABLE_GAMMA) {
|
||||
r->value &= ~REG_0x05_GMMENB;
|
||||
if (should_enable_gamma(session, sensor)) {
|
||||
reg->find_reg(REG_0x05).value |= REG_0x05_GMMENB;
|
||||
} else {
|
||||
r->value |= REG_0x05_GMMENB;
|
||||
reg->find_reg(REG_0x05).value &= ~REG_0x05_GMMENB;
|
||||
}
|
||||
|
||||
unsigned dpiset_reg = session.output_resolution * ccd_pixels_per_system_pixel *
|
||||
|
|
|
@ -1504,11 +1504,10 @@ static void gl841_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
}
|
||||
|
||||
// enable gamma tables
|
||||
r = sanei_genesys_get_address (reg, 0x05);
|
||||
if (session.params.flags & SCAN_FLAG_DISABLE_GAMMA) {
|
||||
r->value &= ~REG_0x05_GMMENB;
|
||||
if (should_enable_gamma(session, sensor)) {
|
||||
reg->find_reg(REG_0x05).value |= REG_0x05_GMMENB;
|
||||
} else {
|
||||
r->value |= REG_0x05_GMMENB;
|
||||
reg->find_reg(REG_0x05).value &= ~REG_0x05_GMMENB;
|
||||
}
|
||||
|
||||
/* sensor parameters */
|
||||
|
|
|
@ -79,6 +79,7 @@
|
|||
|
||||
#define REG_0x04S_AFEMOD 4
|
||||
|
||||
#define REG_0x05 0x05
|
||||
#define REG_0x05_DPIHW 0xc0
|
||||
#define REG_0x05_DPIHW_600 0x00
|
||||
#define REG_0x05_DPIHW_1200 0x40
|
||||
|
|
|
@ -1158,12 +1158,10 @@ static void gl843_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
|
||||
sanei_genesys_set_dpihw(*reg, sensor, dpihw);
|
||||
|
||||
// enable gamma tables
|
||||
r = sanei_genesys_get_address(reg, REG_0x05);
|
||||
if (session.params.flags & SCAN_FLAG_DISABLE_GAMMA) {
|
||||
r->value &= ~REG_0x05_GMMENB;
|
||||
if (should_enable_gamma(session, sensor)) {
|
||||
reg->find_reg(REG_0x05).value |= REG_0x05_GMMENB;
|
||||
} else {
|
||||
r->value |= REG_0x05_GMMENB;
|
||||
reg->find_reg(REG_0x05).value &= ~REG_0x05_GMMENB;
|
||||
}
|
||||
|
||||
unsigned dpiset = session.output_resolution * session.ccd_size_divisor *
|
||||
|
@ -2150,7 +2148,8 @@ static void gl843_feed(Genesys_Device* dev, unsigned int steps)
|
|||
/* prepare local registers */
|
||||
local_reg = dev->reg;
|
||||
|
||||
unsigned resolution = sanei_genesys_get_lowest_ydpi(dev);
|
||||
const auto& resolution_settings = dev->model->get_resolution_settings(dev->model->default_method);
|
||||
unsigned resolution = resolution_settings.get_min_resolution_y();
|
||||
|
||||
const auto& sensor = sanei_genesys_find_sensor(dev, resolution, 3, dev->model->default_method);
|
||||
|
||||
|
@ -3176,9 +3175,9 @@ void CommandSetGl843::update_hardware_sensors(Genesys_Scanner* s) const
|
|||
void CommandSetGl843::move_to_ta(Genesys_Device* dev) const
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
float resolution;
|
||||
|
||||
resolution=sanei_genesys_get_lowest_ydpi(dev);
|
||||
const auto& resolution_settings = dev->model->get_resolution_settings(dev->model->default_method);
|
||||
float resolution = resolution_settings.get_min_resolution_y();
|
||||
unsigned feed = static_cast<unsigned>(16 * (dev->model->y_offset_sensor_to_ta * resolution) /
|
||||
MM_PER_INCH);
|
||||
gl843_feed(dev, feed);
|
||||
|
|
|
@ -698,12 +698,10 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
|
||||
sanei_genesys_set_dpihw(*reg, sensor, dpihw);
|
||||
|
||||
// enable gamma tables
|
||||
r = sanei_genesys_get_address (reg, REG_0x05);
|
||||
if (session.params.flags & SCAN_FLAG_DISABLE_GAMMA) {
|
||||
r->value &= ~REG_0x05_GMMENB;
|
||||
if (should_enable_gamma(session, sensor)) {
|
||||
reg->find_reg(REG_0x05).value |= REG_0x05_GMMENB;
|
||||
} else {
|
||||
r->value |= REG_0x05_GMMENB;
|
||||
reg->find_reg(REG_0x05).value &= ~REG_0x05_GMMENB;
|
||||
}
|
||||
|
||||
/* CIS scanners can do true gray by setting LEDADD */
|
||||
|
|
|
@ -709,12 +709,10 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
|
||||
sanei_genesys_set_dpihw(*reg, sensor, dpihw);
|
||||
|
||||
// enable gamma tables
|
||||
r = sanei_genesys_get_address (reg, REG_0x05);
|
||||
if (session.params.flags & SCAN_FLAG_DISABLE_GAMMA) {
|
||||
r->value &= ~REG_0x05_GMMENB;
|
||||
if (should_enable_gamma(session, sensor)) {
|
||||
reg->find_reg(REG_0x05).value |= REG_0x05_GMMENB;
|
||||
} else {
|
||||
r->value |= REG_0x05_GMMENB;
|
||||
reg->find_reg(REG_0x05).value &= ~REG_0x05_GMMENB;
|
||||
}
|
||||
|
||||
/* CIS scanners can do true gray by setting LEDADD */
|
||||
|
@ -1376,7 +1374,6 @@ void CommandSetGl847::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
|
|||
Genesys_Register_Set& regs) const
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
float move;
|
||||
|
||||
dev->calib_channels = 3;
|
||||
|
||||
|
@ -1392,19 +1389,11 @@ void CommandSetGl847::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
|
|||
DBG(DBG_io, "%s: calib_lines = %zu\n", __func__, dev->calib_lines);
|
||||
DBG(DBG_io, "%s: calib_pixels = %zu\n", __func__, dev->calib_pixels);
|
||||
|
||||
/* this is aworkaround insufficent distance for slope
|
||||
* motor acceleration TODO special motor slope for shading */
|
||||
move=1;
|
||||
if(dev->calib_resolution<1200)
|
||||
{
|
||||
move=40;
|
||||
}
|
||||
|
||||
ScanSession session;
|
||||
session.params.xres = dev->calib_resolution;
|
||||
session.params.yres = dev->calib_resolution;
|
||||
session.params.yres = dev->motor.base_ydpi;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = static_cast<unsigned>(move);
|
||||
session.params.starty = 20;
|
||||
session.params.pixels = dev->calib_pixels;
|
||||
session.params.lines = dev->calib_lines;
|
||||
session.params.depth = 16;
|
||||
|
@ -1641,13 +1630,13 @@ SensorExposure CommandSetGl847::led_calibration(Genesys_Device* dev, const Genes
|
|||
exp[1] = sensor_profile.exposure.green;
|
||||
exp[2] = sensor_profile.exposure.blue;
|
||||
|
||||
bottom[0]=29000;
|
||||
bottom[1]=29000;
|
||||
bottom[2]=29000;
|
||||
bottom[0] = 28000;
|
||||
bottom[1] = 28000;
|
||||
bottom[2] = 28000;
|
||||
|
||||
top[0]=41000;
|
||||
top[1]=51000;
|
||||
top[2]=51000;
|
||||
top[0] = 32000;
|
||||
top[1] = 32000;
|
||||
top[2] = 32000;
|
||||
|
||||
turn = 0;
|
||||
|
||||
|
@ -1705,14 +1694,9 @@ SensorExposure CommandSetGl847::led_calibration(Genesys_Device* dev, const Genes
|
|||
acceptable = true;
|
||||
for(i=0;i<3;i++)
|
||||
{
|
||||
if(avg[i]<bottom[i])
|
||||
{
|
||||
exp[i]=(exp[i]*bottom[i])/avg[i];
|
||||
acceptable = false;
|
||||
}
|
||||
if(avg[i]>top[i])
|
||||
{
|
||||
exp[i]=(exp[i]*top[i])/avg[i];
|
||||
if (avg[i] < bottom[i] || avg[i] > top[i]) {
|
||||
auto target = (bottom[i] + top[i]) / 2;
|
||||
exp[i] = (exp[i] * target) / avg[i];
|
||||
acceptable = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "image_pipeline.h"
|
||||
#include "image.h"
|
||||
#include "low.h"
|
||||
#include <cmath>
|
||||
#include <numeric>
|
||||
|
||||
namespace genesys {
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "assert.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
@ -972,6 +973,20 @@ void sanei_genesys_set_motor_power(Genesys_Register_Set& regs, bool set)
|
|||
}
|
||||
}
|
||||
|
||||
bool should_enable_gamma(const ScanSession& session, const Genesys_Sensor& sensor)
|
||||
{
|
||||
if (session.params.flags & SCAN_FLAG_DISABLE_GAMMA) {
|
||||
return false;
|
||||
}
|
||||
if (sensor.gamma[0] == 1.0f || sensor.gamma[1] == 1.0f || sensor.gamma[2] == 1.0f) {
|
||||
return false;
|
||||
}
|
||||
if (session.params.depth == 16)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write to many registers at once
|
||||
* Note: sequential call to write register, no effective
|
||||
|
|
|
@ -336,6 +336,8 @@ void sanei_genesys_set_lamp_power(Genesys_Device* dev, const Genesys_Sensor& sen
|
|||
|
||||
void sanei_genesys_set_motor_power(Genesys_Register_Set& regs, bool set);
|
||||
|
||||
bool should_enable_gamma(const ScanSession& session, const Genesys_Sensor& sensor);
|
||||
|
||||
/** Calculates the values of the Z{1,2}MOD registers. They are a phase correction to synchronize
|
||||
with the line clock during acceleration and deceleration.
|
||||
|
||||
|
|
|
@ -386,11 +386,11 @@ void genesys_init_usb_device_tables()
|
|||
model.bpp_color_values = { 8, 16 };
|
||||
|
||||
model.x_offset = 8.0;
|
||||
model.y_offset = 13.00;
|
||||
model.y_offset = 10.00;
|
||||
model.x_size = 217.9;
|
||||
model.y_size = 315.0;
|
||||
|
||||
model.y_offset_calib_white = 3.0;
|
||||
model.y_offset_calib_white = 0.0;
|
||||
model.x_offset_calib_black = 0.0;
|
||||
|
||||
model.x_offset_ta = 8.0;
|
||||
|
@ -651,7 +651,7 @@ void genesys_init_usb_device_tables()
|
|||
model.resolutions = {
|
||||
{
|
||||
{ ScanMethod::FLATBED },
|
||||
{ 4800, 2400, 1200, 600, 300, 200, 150, 100, 75 },
|
||||
{ 2400, 1200, 600, 300, 200, 150, 100, 75 },
|
||||
{ 4800, 2400, 1200, 600, 300, 200, 150, 100, 75 },
|
||||
}
|
||||
};
|
||||
|
@ -730,7 +730,7 @@ void genesys_init_usb_device_tables()
|
|||
model.x_size = 216.70;
|
||||
model.y_size = 300.0;
|
||||
|
||||
model.y_offset_calib_white = 1.0;
|
||||
model.y_offset_calib_white = 0.0;
|
||||
model.x_offset_calib_black = 0.0;
|
||||
|
||||
model.x_offset_ta = 0.0;
|
||||
|
@ -764,7 +764,7 @@ void genesys_init_usb_device_tables()
|
|||
GENESYS_HAS_COPY_SW |
|
||||
GENESYS_HAS_EMAIL_SW |
|
||||
GENESYS_HAS_FILE_SW;
|
||||
model.shading_lines = 50;
|
||||
model.shading_lines = 25;
|
||||
model.shading_ta_lines = 0;
|
||||
model.search_lines = 400;
|
||||
|
||||
|
@ -781,7 +781,7 @@ void genesys_init_usb_device_tables()
|
|||
model.resolutions = {
|
||||
{
|
||||
{ ScanMethod::FLATBED },
|
||||
{ 4800, 2400, 1200, 600, 300, 150, 100, 75 },
|
||||
{ 2400, 1200, 600, 300, 150, 100, 75 },
|
||||
{ 4800, 2400, 1200, 600, 300, 150, 100, 75 },
|
||||
}
|
||||
};
|
||||
|
@ -975,8 +975,8 @@ void genesys_init_usb_device_tables()
|
|||
model.resolutions = {
|
||||
{
|
||||
{ ScanMethod::FLATBED },
|
||||
{ 1200, 600, 400, 300, 200, 150, 100, 75 },
|
||||
{ 1200, 600, 400, 300, 200, 150, 100, 75 },
|
||||
{ 4800, 2400, 1200, 600, 400, 300, 200, 150, 100, 75 },
|
||||
{ 4800, 2400, 1200, 600, 400, 300, 200, 150, 100, 75 },
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1298,10 +1298,8 @@ void genesys_init_usb_device_tables()
|
|||
model.resolutions = {
|
||||
{
|
||||
{ ScanMethod::FLATBED },
|
||||
// FIXME: the scanner supports 1200 ydpi, but we never scanned at this resolution so for now
|
||||
// it's not supported
|
||||
{ 600, 300, 150, 75 },
|
||||
{ /* 1200, */600, 300, 150, 75 },
|
||||
{ 1200, 600, 300, 150, 75 },
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1628,7 +1628,7 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5d, 0x00 },
|
||||
{ 0x5e, 0x41 },
|
||||
};
|
||||
sensor.gamma = { 1.7f, 1.7f, 1.7f };
|
||||
sensor.gamma = { 2.2f, 2.2f, 2.2f };
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi;
|
||||
|
@ -1902,7 +1902,7 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5d, 0x00 },
|
||||
{ 0x5e, 0x41 },
|
||||
};
|
||||
sensor.gamma = { 1.7f, 1.7f, 1.7f };
|
||||
sensor.gamma = { 2.2f, 2.2f, 2.2f };
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi;
|
||||
|
@ -2758,7 +2758,7 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5d, 0x00 },
|
||||
{ 0x5e, 0x00 },
|
||||
};
|
||||
sensor.gamma = { 2.1f, 2.1f, 2.1f };
|
||||
sensor.gamma = { 2.2f, 2.2f, 2.2f };
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi;
|
||||
|
@ -2894,7 +2894,7 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5d, 0x00 },
|
||||
{ 0x5e, 0x1f },
|
||||
};
|
||||
sensor.gamma = { 2.1f, 2.1f, 2.1f };
|
||||
sensor.gamma = { 2.2f, 2.2f, 2.2f };
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi;
|
||||
|
@ -3029,7 +3029,7 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5d, 0x00 },
|
||||
{ 0x5e, 0x00 },
|
||||
};
|
||||
sensor.gamma = { 2.1f, 2.1f, 2.1f };
|
||||
sensor.gamma = { 2.2f, 2.2f, 2.2f };
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi;
|
||||
|
@ -3164,7 +3164,7 @@ void genesys_init_sensor_tables()
|
|||
{ 0x5d, 0x00 },
|
||||
{ 0x5e, 0x00 },
|
||||
};
|
||||
sensor.gamma = { 2.1f, 2.1f, 2.1f };
|
||||
sensor.gamma = { 2.2f, 2.2f, 2.2f };
|
||||
sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_register_hwdpi_fun = default_get_logical_hwdpi;
|
||||
sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi;
|
||||
|
|
Ładowanie…
Reference in New Issue