kopia lustrzana https://gitlab.com/sane-project/backends
Merge branch 'genesys-identify-sensor-channel-count' into 'master'
genesys: Identify sensor by supported channel count See merge request sane-project/backends!140merge-requests/141/merge
commit
ab9f5531c1
|
@ -192,12 +192,12 @@ const Genesys_Sensor& sanei_genesys_find_sensor_any(Genesys_Device* dev)
|
||||||
throw std::runtime_error("Given device does not have sensor defined");
|
throw std::runtime_error("Given device does not have sensor defined");
|
||||||
}
|
}
|
||||||
|
|
||||||
const Genesys_Sensor& sanei_genesys_find_sensor(Genesys_Device* dev, int dpi,
|
const Genesys_Sensor& sanei_genesys_find_sensor(Genesys_Device* dev, int dpi, unsigned channels,
|
||||||
ScanMethod scan_method)
|
ScanMethod scan_method)
|
||||||
{
|
{
|
||||||
for (const auto& sensor : *s_sensors) {
|
for (const auto& sensor : *s_sensors) {
|
||||||
if (dev->model->ccd_type == sensor.sensor_id && sensor.resolutions.matches(dpi) &&
|
if (dev->model->ccd_type == sensor.sensor_id && sensor.resolutions.matches(dpi) &&
|
||||||
sensor.method == scan_method)
|
sensor.matches_channel_count(channels) && sensor.method == scan_method)
|
||||||
{
|
{
|
||||||
return sensor;
|
return sensor;
|
||||||
}
|
}
|
||||||
|
@ -206,11 +206,12 @@ const Genesys_Sensor& sanei_genesys_find_sensor(Genesys_Device* dev, int dpi,
|
||||||
}
|
}
|
||||||
|
|
||||||
Genesys_Sensor& sanei_genesys_find_sensor_for_write(Genesys_Device* dev, int dpi,
|
Genesys_Sensor& sanei_genesys_find_sensor_for_write(Genesys_Device* dev, int dpi,
|
||||||
|
unsigned channels,
|
||||||
ScanMethod scan_method)
|
ScanMethod scan_method)
|
||||||
{
|
{
|
||||||
for (auto& sensor : *s_sensors) {
|
for (auto& sensor : *s_sensors) {
|
||||||
if (dev->model->ccd_type == sensor.sensor_id && sensor.resolutions.matches(dpi) &&
|
if (dev->model->ccd_type == sensor.sensor_id && sensor.resolutions.matches(dpi) &&
|
||||||
sensor.method == scan_method)
|
sensor.matches_channel_count(channels) && sensor.method == scan_method)
|
||||||
{
|
{
|
||||||
return sensor;
|
return sensor;
|
||||||
}
|
}
|
||||||
|
@ -1382,7 +1383,6 @@ static void genesys_coarse_calibration(Genesys_Device* dev, Genesys_Sensor& sens
|
||||||
int size;
|
int size;
|
||||||
int black_pixels;
|
int black_pixels;
|
||||||
int white_average;
|
int white_average;
|
||||||
int channels;
|
|
||||||
uint8_t offset[4] = { 0xa0, 0x00, 0xa0, 0x40 }; /* first value isn't used */
|
uint8_t offset[4] = { 0xa0, 0x00, 0xa0, 0x40 }; /* first value isn't used */
|
||||||
uint16_t white[12], dark[12];
|
uint16_t white[12], dark[12];
|
||||||
int i, j;
|
int i, j;
|
||||||
|
@ -1390,10 +1390,7 @@ static void genesys_coarse_calibration(Genesys_Device* dev, Genesys_Sensor& sens
|
||||||
black_pixels = sensor.black_pixels
|
black_pixels = sensor.black_pixels
|
||||||
* dev->settings.xres / sensor.optical_res;
|
* dev->settings.xres / sensor.optical_res;
|
||||||
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
unsigned channels = dev->settings.get_channels();
|
||||||
channels = 3;
|
|
||||||
else
|
|
||||||
channels = 1;
|
|
||||||
|
|
||||||
DBG(DBG_info, "channels %d y_size %d xres %d\n", channels, dev->model->y_size,
|
DBG(DBG_info, "channels %d y_size %d xres %d\n", channels, dev->model->y_size,
|
||||||
dev->settings.xres);
|
dev->settings.xres);
|
||||||
|
@ -3281,6 +3278,7 @@ static void genesys_start_scan(Genesys_Device* dev, SANE_Bool lamp_off)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& sensor = sanei_genesys_find_sensor_for_write(dev, dev->settings.xres,
|
auto& sensor = sanei_genesys_find_sensor_for_write(dev, dev->settings.xres,
|
||||||
|
dev->settings.get_channels(),
|
||||||
dev->settings.scan_method);
|
dev->settings.scan_method);
|
||||||
|
|
||||||
// send gamma tables. They have been set to device or user value
|
// send gamma tables. They have been set to device or user value
|
||||||
|
@ -5641,6 +5639,7 @@ get_option_value (Genesys_Scanner * s, int option, void *val)
|
||||||
SANE_Status status = SANE_STATUS_GOOD;
|
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->resolution,
|
||||||
|
s->dev->settings.get_channels(),
|
||||||
s->dev->settings.scan_method);
|
s->dev->settings.scan_method);
|
||||||
|
|
||||||
switch (option)
|
switch (option)
|
||||||
|
@ -6170,6 +6169,7 @@ set_option_value (Genesys_Scanner * s, int option, void *val,
|
||||||
break;
|
break;
|
||||||
case OPT_CALIBRATE: {
|
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->resolution,
|
||||||
|
s->dev->settings.get_channels(),
|
||||||
s->dev->settings.scan_method);
|
s->dev->settings.scan_method);
|
||||||
catch_all_exceptions(__func__, [&]()
|
catch_all_exceptions(__func__, [&]()
|
||||||
{
|
{
|
||||||
|
@ -6401,8 +6401,9 @@ SANE_Status sane_start_impl(SANE_Handle handle)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->swdeskew) {
|
if (s->swdeskew) {
|
||||||
const auto& sensor = sanei_genesys_find_sensor(s->dev, s->dev->settings.xres,
|
const auto& sensor = sanei_genesys_find_sensor(s->dev, s->dev->settings.xres,
|
||||||
s->dev->settings.scan_method);
|
s->dev->settings.get_channels(),
|
||||||
|
s->dev->settings.scan_method);
|
||||||
catch_all_exceptions(__func__, [&](){ genesys_deskew(s, sensor); });
|
catch_all_exceptions(__func__, [&](){ genesys_deskew(s, sensor); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1272,8 +1272,6 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
static void
|
static void
|
||||||
gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||||
{
|
{
|
||||||
int channels;
|
|
||||||
int depth;
|
|
||||||
int start;
|
int start;
|
||||||
|
|
||||||
int used_res;
|
int used_res;
|
||||||
|
@ -1289,17 +1287,6 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso
|
||||||
DBG(DBG_info, "%s ", __func__);
|
DBG(DBG_info, "%s ", __func__);
|
||||||
debug_dump(DBG_info, dev->settings);
|
debug_dump(DBG_info, dev->settings);
|
||||||
|
|
||||||
/* channels */
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
|
||||||
channels = 3;
|
|
||||||
else
|
|
||||||
channels = 1;
|
|
||||||
|
|
||||||
/* depth */
|
|
||||||
depth = dev->settings.depth;
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::LINEART)
|
|
||||||
depth = 1;
|
|
||||||
|
|
||||||
/* start */
|
/* start */
|
||||||
start = SANE_UNFIX (dev->model->x_offset);
|
start = SANE_UNFIX (dev->model->x_offset);
|
||||||
start += dev->settings.tl_x;
|
start += dev->settings.tl_x;
|
||||||
|
@ -1312,8 +1299,8 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso
|
||||||
session.params.starty = 0; // not used
|
session.params.starty = 0; // not used
|
||||||
session.params.pixels = dev->settings.pixels;
|
session.params.pixels = dev->settings.pixels;
|
||||||
session.params.lines = dev->settings.lines;
|
session.params.lines = dev->settings.lines;
|
||||||
session.params.depth = depth;
|
session.params.depth = dev->settings.get_depth();
|
||||||
session.params.channels = channels;
|
session.params.channels = dev->settings.get_channels();
|
||||||
session.params.scan_method = dev->settings.scan_method;
|
session.params.scan_method = dev->settings.scan_method;
|
||||||
session.params.scan_mode = dev->settings.scan_mode;
|
session.params.scan_mode = dev->settings.scan_mode;
|
||||||
session.params.color_filter = dev->settings.color_filter;
|
session.params.color_filter = dev->settings.color_filter;
|
||||||
|
@ -1730,7 +1717,7 @@ static void gl124_feed(Genesys_Device* dev, unsigned int steps, int reverse)
|
||||||
local_reg = dev->reg;
|
local_reg = dev->reg;
|
||||||
|
|
||||||
resolution=sanei_genesys_get_lowest_ydpi(dev);
|
resolution=sanei_genesys_get_lowest_ydpi(dev);
|
||||||
const auto& sensor = sanei_genesys_find_sensor(dev, resolution, ScanMethod::FLATBED);
|
const auto& sensor = sanei_genesys_find_sensor(dev, resolution, 3, ScanMethod::FLATBED);
|
||||||
|
|
||||||
ScanSession session;
|
ScanSession session;
|
||||||
session.params.xres = resolution;
|
session.params.xres = resolution;
|
||||||
|
@ -1815,7 +1802,7 @@ static void gl124_search_start_position(Genesys_Device* dev)
|
||||||
|
|
||||||
// FIXME: the current approach of doing search only for one resolution does not work on scanners
|
// FIXME: the current approach of doing search only for one resolution does not work on scanners
|
||||||
// whith employ different sensors with potentially different settings.
|
// whith employ different sensors with potentially different settings.
|
||||||
const auto& sensor = sanei_genesys_find_sensor(dev, dpi, ScanMethod::FLATBED);
|
const auto& sensor = sanei_genesys_find_sensor(dev, dpi, 1, ScanMethod::FLATBED);
|
||||||
|
|
||||||
ScanSession session;
|
ScanSession session;
|
||||||
session.params.xres = dpi;
|
session.params.xres = dpi;
|
||||||
|
@ -1877,14 +1864,6 @@ static void gl124_init_regs_for_coarse_calibration(Genesys_Device* dev,
|
||||||
Genesys_Register_Set& regs)
|
Genesys_Register_Set& regs)
|
||||||
{
|
{
|
||||||
DBG_HELPER(dbg);
|
DBG_HELPER(dbg);
|
||||||
uint8_t channels;
|
|
||||||
|
|
||||||
/* set line size */
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS) {
|
|
||||||
channels = 3;
|
|
||||||
} else {
|
|
||||||
channels = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ScanSession session;
|
ScanSession session;
|
||||||
session.params.xres = dev->settings.xres;
|
session.params.xres = dev->settings.xres;
|
||||||
|
@ -1894,7 +1873,7 @@ static void gl124_init_regs_for_coarse_calibration(Genesys_Device* dev,
|
||||||
session.params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel();
|
session.params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel();
|
||||||
session.params.lines = 20;
|
session.params.lines = 20;
|
||||||
session.params.depth = 16;
|
session.params.depth = 16;
|
||||||
session.params.channels = channels;
|
session.params.channels = dev->settings.get_channels();
|
||||||
session.params.scan_method = dev->settings.scan_method;
|
session.params.scan_method = dev->settings.scan_method;
|
||||||
session.params.scan_mode = dev->settings.scan_mode;
|
session.params.scan_mode = dev->settings.scan_mode;
|
||||||
session.params.color_filter = dev->settings.color_filter;
|
session.params.color_filter = dev->settings.color_filter;
|
||||||
|
@ -2009,26 +1988,13 @@ static void gl124_wait_for_motor_stop(Genesys_Device* dev)
|
||||||
static void gl124_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor)
|
static void gl124_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor)
|
||||||
{
|
{
|
||||||
DBG_HELPER(dbg);
|
DBG_HELPER(dbg);
|
||||||
int channels;
|
|
||||||
int flags;
|
int flags;
|
||||||
int depth;
|
|
||||||
float move;
|
float move;
|
||||||
int move_dpi;
|
int move_dpi;
|
||||||
float start;
|
float start;
|
||||||
|
|
||||||
debug_dump(DBG_info, dev->settings);
|
debug_dump(DBG_info, dev->settings);
|
||||||
|
|
||||||
/* channels */
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
|
||||||
channels = 3;
|
|
||||||
else
|
|
||||||
channels = 1;
|
|
||||||
|
|
||||||
/* depth */
|
|
||||||
depth = dev->settings.depth;
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::LINEART)
|
|
||||||
depth = 1;
|
|
||||||
|
|
||||||
/* y (motor) distance to move to reach scanned area */
|
/* y (motor) distance to move to reach scanned area */
|
||||||
move_dpi = dev->motor.base_ydpi/4;
|
move_dpi = dev->motor.base_ydpi/4;
|
||||||
move = SANE_UNFIX (dev->model->y_offset);
|
move = SANE_UNFIX (dev->model->y_offset);
|
||||||
|
@ -2036,8 +2002,7 @@ static void gl124_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor&
|
||||||
move = (move * move_dpi) / MM_PER_INCH;
|
move = (move * move_dpi) / MM_PER_INCH;
|
||||||
DBG (DBG_info, "%s: move=%f steps\n", __func__, move);
|
DBG (DBG_info, "%s: move=%f steps\n", __func__, move);
|
||||||
|
|
||||||
if(channels*dev->settings.yres>=600 && move>700)
|
if (dev->settings.get_channels() * dev->settings.yres >= 600 && move > 700) {
|
||||||
{
|
|
||||||
gl124_feed(dev, move-500, SANE_FALSE);
|
gl124_feed(dev, move-500, SANE_FALSE);
|
||||||
move=500;
|
move=500;
|
||||||
}
|
}
|
||||||
|
@ -2065,8 +2030,8 @@ static void gl124_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor&
|
||||||
session.params.starty = move;
|
session.params.starty = move;
|
||||||
session.params.pixels = dev->settings.pixels;
|
session.params.pixels = dev->settings.pixels;
|
||||||
session.params.lines = dev->settings.lines;
|
session.params.lines = dev->settings.lines;
|
||||||
session.params.depth = depth;
|
session.params.depth = dev->settings.get_depth();
|
||||||
session.params.channels = channels;
|
session.params.channels = dev->settings.get_channels();
|
||||||
session.params.scan_method = dev->settings.scan_method;
|
session.params.scan_method = dev->settings.scan_method;
|
||||||
session.params.scan_mode = dev->settings.scan_mode;
|
session.params.scan_mode = dev->settings.scan_mode;
|
||||||
session.params.color_filter = dev->settings.color_filter;
|
session.params.color_filter = dev->settings.color_filter;
|
||||||
|
|
|
@ -1942,7 +1942,7 @@ static void gl646_slow_back_home(Genesys_Device* dev, SANE_Bool wait_until_home)
|
||||||
settings.threshold = 0;
|
settings.threshold = 0;
|
||||||
settings.dynamic_lineart = SANE_FALSE;
|
settings.dynamic_lineart = SANE_FALSE;
|
||||||
|
|
||||||
const auto& sensor = sanei_genesys_find_sensor(dev, settings.xres, ScanMethod::FLATBED);
|
const auto& sensor = sanei_genesys_find_sensor(dev, settings.xres, 3, ScanMethod::FLATBED);
|
||||||
|
|
||||||
setup_for_scan(dev, sensor, &dev->reg, settings, SANE_TRUE, SANE_TRUE, SANE_TRUE);
|
setup_for_scan(dev, sensor, &dev->reg, settings, SANE_TRUE, SANE_TRUE, SANE_TRUE);
|
||||||
|
|
||||||
|
@ -2016,7 +2016,7 @@ static void gl646_search_start_position(Genesys_Device* dev)
|
||||||
|
|
||||||
// FIXME: the current approach of doing search only for one resolution does not work on scanners
|
// FIXME: the current approach of doing search only for one resolution does not work on scanners
|
||||||
// whith employ different sensors with potentially different settings.
|
// whith employ different sensors with potentially different settings.
|
||||||
const auto& sensor = sanei_genesys_find_sensor(dev, resolution, ScanMethod::FLATBED);
|
const auto& sensor = sanei_genesys_find_sensor(dev, resolution, 1, ScanMethod::FLATBED);
|
||||||
|
|
||||||
/* fill settings for a gray level scan */
|
/* fill settings for a gray level scan */
|
||||||
settings.scan_method = ScanMethod::FLATBED;
|
settings.scan_method = ScanMethod::FLATBED;
|
||||||
|
@ -2101,6 +2101,9 @@ static void gl646_init_regs_for_shading(Genesys_Device* dev, const Genesys_Senso
|
||||||
/* fill settings for scan : always a color scan */
|
/* fill settings for scan : always a color scan */
|
||||||
int channels = 3;
|
int channels = 3;
|
||||||
|
|
||||||
|
const auto& calib_sensor = sanei_genesys_find_sensor(dev, dev->settings.xres, channels,
|
||||||
|
dev->settings.scan_method);
|
||||||
|
|
||||||
unsigned ccd_size_divisor = 1;
|
unsigned ccd_size_divisor = 1;
|
||||||
if (sensor.ccd_size_divisor > 1) {
|
if (sensor.ccd_size_divisor > 1) {
|
||||||
// when shading all (full width) line, we must adapt to ccd_size_divisor != 1 case
|
// when shading all (full width) line, we must adapt to ccd_size_divisor != 1 case
|
||||||
|
@ -2120,8 +2123,7 @@ static void gl646_init_regs_for_shading(Genesys_Device* dev, const Genesys_Senso
|
||||||
settings.yres = settings.xres;
|
settings.yres = settings.xres;
|
||||||
settings.tl_x = 0;
|
settings.tl_x = 0;
|
||||||
settings.tl_y = 0;
|
settings.tl_y = 0;
|
||||||
settings.pixels =
|
settings.pixels = (calib_sensor.sensor_pixels * settings.xres) / calib_sensor.optical_res;
|
||||||
(sensor.sensor_pixels * settings.xres) / sensor.optical_res;
|
|
||||||
dev->calib_lines = dev->model->shading_lines;
|
dev->calib_lines = dev->model->shading_lines;
|
||||||
settings.lines = dev->calib_lines * (3 - ccd_size_divisor);
|
settings.lines = dev->calib_lines * (3 - ccd_size_divisor);
|
||||||
settings.depth = 16;
|
settings.depth = 16;
|
||||||
|
@ -2136,7 +2138,7 @@ static void gl646_init_regs_for_shading(Genesys_Device* dev, const Genesys_Senso
|
||||||
|
|
||||||
// we don't want top offset, but we need right margin to be the same than the one for the final
|
// we don't want top offset, but we need right margin to be the same than the one for the final
|
||||||
// scan
|
// scan
|
||||||
setup_for_scan(dev, sensor, &dev->reg, settings, SANE_TRUE, SANE_FALSE, SANE_FALSE);
|
setup_for_scan(dev, calib_sensor, &dev->reg, settings, SANE_TRUE, SANE_FALSE, SANE_FALSE);
|
||||||
|
|
||||||
/* used when sending shading calibration data */
|
/* used when sending shading calibration data */
|
||||||
dev->calib_pixels = settings.pixels;
|
dev->calib_pixels = settings.pixels;
|
||||||
|
@ -2217,19 +2219,9 @@ static void setup_for_scan(Genesys_Device* dev,
|
||||||
{
|
{
|
||||||
DBG_HELPER(dbg);
|
DBG_HELPER(dbg);
|
||||||
SANE_Int depth;
|
SANE_Int depth;
|
||||||
int channels;
|
|
||||||
|
|
||||||
debug_dump(DBG_info, dev->settings);
|
debug_dump(DBG_info, dev->settings);
|
||||||
|
|
||||||
if (settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
|
||||||
{
|
|
||||||
channels = 3;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
channels = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
depth=settings.depth;
|
depth=settings.depth;
|
||||||
if (settings.scan_mode == ScanColorMode::LINEART)
|
if (settings.scan_mode == ScanColorMode::LINEART)
|
||||||
{
|
{
|
||||||
|
@ -2283,7 +2275,7 @@ static void setup_for_scan(Genesys_Device* dev,
|
||||||
session.params.pixels = settings.pixels;
|
session.params.pixels = settings.pixels;
|
||||||
session.params.lines = settings.lines;
|
session.params.lines = settings.lines;
|
||||||
session.params.depth = depth;
|
session.params.depth = depth;
|
||||||
session.params.channels = channels;
|
session.params.channels = settings.get_channels();
|
||||||
session.params.scan_method = dev->settings.scan_method;
|
session.params.scan_method = dev->settings.scan_method;
|
||||||
session.params.scan_mode = settings.scan_mode;
|
session.params.scan_mode = settings.scan_mode;
|
||||||
session.params.color_filter = settings.color_filter;
|
session.params.color_filter = settings.color_filter;
|
||||||
|
@ -2367,7 +2359,6 @@ static SensorExposure gl646_led_calibration(Genesys_Device* dev, const Genesys_S
|
||||||
int total_size;
|
int total_size;
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
int val;
|
int val;
|
||||||
unsigned int channels;
|
|
||||||
int avg[3], avga, avge;
|
int avg[3], avga, avge;
|
||||||
int turn;
|
int turn;
|
||||||
uint16_t expr, expg, expb;
|
uint16_t expr, expg, expb;
|
||||||
|
@ -2376,15 +2367,15 @@ static SensorExposure gl646_led_calibration(Genesys_Device* dev, const Genesys_S
|
||||||
|
|
||||||
SANE_Bool acceptable = SANE_FALSE;
|
SANE_Bool acceptable = SANE_FALSE;
|
||||||
|
|
||||||
|
unsigned channels = dev->settings.get_channels();
|
||||||
|
|
||||||
/* get led calibration resolution */
|
/* get led calibration resolution */
|
||||||
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
||||||
{
|
{
|
||||||
channels = 3;
|
|
||||||
settings.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
settings.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
channels = 1;
|
|
||||||
settings.scan_mode = ScanColorMode::GRAY;
|
settings.scan_mode = ScanColorMode::GRAY;
|
||||||
}
|
}
|
||||||
resolution = get_closest_resolution(dev->model->ccd_type, sensor.optical_res, channels);
|
resolution = get_closest_resolution(dev->model->ccd_type, sensor.optical_res, channels);
|
||||||
|
@ -2546,6 +2537,8 @@ dark_average (uint8_t * data, unsigned int pixels, unsigned int lines,
|
||||||
static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor)
|
static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor)
|
||||||
{
|
{
|
||||||
DBG_HELPER(dbg);
|
DBG_HELPER(dbg);
|
||||||
|
(void) sensor;
|
||||||
|
|
||||||
unsigned int channels;
|
unsigned int channels;
|
||||||
int pass = 0;
|
int pass = 0;
|
||||||
SANE_Int resolution;
|
SANE_Int resolution;
|
||||||
|
@ -2555,8 +2548,8 @@ static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
|
||||||
|
|
||||||
channels = 3;
|
channels = 3;
|
||||||
resolution = get_closest_resolution(dev->model->ccd_type, sensor.optical_res, channels);
|
resolution = get_closest_resolution(dev->model->ccd_type, sensor.optical_res, channels);
|
||||||
black_pixels =
|
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, 3, ScanMethod::FLATBED);
|
||||||
(sensor.black_pixels * resolution) / sensor.optical_res;
|
black_pixels = (calib_sensor.black_pixels * resolution) / calib_sensor.optical_res;
|
||||||
DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels);
|
DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels);
|
||||||
|
|
||||||
settings.scan_method = ScanMethod::FLATBED;
|
settings.scan_method = ScanMethod::FLATBED;
|
||||||
|
@ -2565,8 +2558,7 @@ static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
|
||||||
settings.yres = resolution;
|
settings.yres = resolution;
|
||||||
settings.tl_x = 0;
|
settings.tl_x = 0;
|
||||||
settings.tl_y = 0;
|
settings.tl_y = 0;
|
||||||
settings.pixels =
|
settings.pixels = (calib_sensor.sensor_pixels * resolution) / calib_sensor.optical_res;
|
||||||
(sensor.sensor_pixels * resolution) / sensor.optical_res;
|
|
||||||
settings.lines = CALIBRATION_LINES;
|
settings.lines = CALIBRATION_LINES;
|
||||||
settings.depth = 8;
|
settings.depth = 8;
|
||||||
settings.color_filter = ColorFilter::RED;
|
settings.color_filter = ColorFilter::RED;
|
||||||
|
@ -2590,7 +2582,7 @@ static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
|
||||||
dev->frontend.set_offset(0, bottom);
|
dev->frontend.set_offset(0, bottom);
|
||||||
dev->frontend.set_offset(1, bottom);
|
dev->frontend.set_offset(1, bottom);
|
||||||
dev->frontend.set_offset(2, bottom);
|
dev->frontend.set_offset(2, bottom);
|
||||||
simple_scan(dev, sensor, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE, line);
|
simple_scan(dev, calib_sensor, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE, line);
|
||||||
|
|
||||||
if (DBG_LEVEL >= DBG_data)
|
if (DBG_LEVEL >= DBG_data)
|
||||||
{
|
{
|
||||||
|
@ -2643,6 +2635,7 @@ static void gl646_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
|
||||||
{
|
{
|
||||||
DBG_HELPER(dbg);
|
DBG_HELPER(dbg);
|
||||||
(void) regs;
|
(void) regs;
|
||||||
|
|
||||||
unsigned int channels;
|
unsigned int channels;
|
||||||
int pass = 0, avg;
|
int pass = 0, avg;
|
||||||
SANE_Int resolution;
|
SANE_Int resolution;
|
||||||
|
@ -2667,8 +2660,10 @@ static void gl646_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
|
||||||
} else {
|
} else {
|
||||||
resolution = get_closest_resolution(dev->model->ccd_type, dev->settings.xres, channels);
|
resolution = get_closest_resolution(dev->model->ccd_type, dev->settings.xres, channels);
|
||||||
}
|
}
|
||||||
black_pixels =
|
|
||||||
(sensor.black_pixels * resolution) / sensor.optical_res;
|
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, 3, ScanMethod::FLATBED);
|
||||||
|
black_pixels = (calib_sensor.black_pixels * resolution) / calib_sensor.optical_res;
|
||||||
|
|
||||||
DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels);
|
DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels);
|
||||||
|
|
||||||
settings.scan_method = ScanMethod::FLATBED;
|
settings.scan_method = ScanMethod::FLATBED;
|
||||||
|
@ -2677,8 +2672,7 @@ static void gl646_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
|
||||||
settings.yres = resolution;
|
settings.yres = resolution;
|
||||||
settings.tl_x = 0;
|
settings.tl_x = 0;
|
||||||
settings.tl_y = 0;
|
settings.tl_y = 0;
|
||||||
settings.pixels =
|
settings.pixels = (calib_sensor.sensor_pixels * resolution) / calib_sensor.optical_res;
|
||||||
(sensor.sensor_pixels * resolution) / sensor.optical_res;
|
|
||||||
settings.lines = CALIBRATION_LINES;
|
settings.lines = CALIBRATION_LINES;
|
||||||
settings.depth = 8;
|
settings.depth = 8;
|
||||||
settings.color_filter = ColorFilter::RED;
|
settings.color_filter = ColorFilter::RED;
|
||||||
|
@ -2701,7 +2695,7 @@ static void gl646_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
|
||||||
|
|
||||||
std::vector<uint8_t> first_line, second_line;
|
std::vector<uint8_t> first_line, second_line;
|
||||||
|
|
||||||
simple_scan(dev, sensor, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE, first_line);
|
simple_scan(dev, calib_sensor, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE, first_line);
|
||||||
|
|
||||||
if (DBG_LEVEL >= DBG_data)
|
if (DBG_LEVEL >= DBG_data)
|
||||||
{
|
{
|
||||||
|
@ -2719,7 +2713,7 @@ static void gl646_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
|
||||||
dev->frontend.set_offset(0, top);
|
dev->frontend.set_offset(0, top);
|
||||||
dev->frontend.set_offset(1, top);
|
dev->frontend.set_offset(1, top);
|
||||||
dev->frontend.set_offset(2, top);
|
dev->frontend.set_offset(2, top);
|
||||||
simple_scan(dev, sensor, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE, second_line);
|
simple_scan(dev, calib_sensor, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE, second_line);
|
||||||
|
|
||||||
if (DBG_LEVEL >= DBG_data)
|
if (DBG_LEVEL >= DBG_data)
|
||||||
{
|
{
|
||||||
|
@ -2743,7 +2737,7 @@ static void gl646_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
|
||||||
dev->frontend.set_offset(2, (top + bottom) / 2);
|
dev->frontend.set_offset(2, (top + bottom) / 2);
|
||||||
|
|
||||||
// scan with no move
|
// scan with no move
|
||||||
simple_scan(dev, sensor, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE, second_line);
|
simple_scan(dev, calib_sensor, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE, second_line);
|
||||||
|
|
||||||
if (DBG_LEVEL >= DBG_data)
|
if (DBG_LEVEL >= DBG_data)
|
||||||
{
|
{
|
||||||
|
@ -2784,7 +2778,9 @@ static void ad_fe_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen
|
||||||
Genesys_Register_Set& regs, int dpi)
|
Genesys_Register_Set& regs, int dpi)
|
||||||
{
|
{
|
||||||
DBG_HELPER(dbg);
|
DBG_HELPER(dbg);
|
||||||
|
(void) sensor;
|
||||||
(void) regs;
|
(void) regs;
|
||||||
|
|
||||||
unsigned int i, channels, val;
|
unsigned int i, channels, val;
|
||||||
unsigned int size, count, resolution, pass;
|
unsigned int size, count, resolution, pass;
|
||||||
float average;
|
float average;
|
||||||
|
@ -2795,6 +2791,9 @@ static void ad_fe_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen
|
||||||
/* resolution is the one from the final scan */
|
/* resolution is the one from the final scan */
|
||||||
channels = 3;
|
channels = 3;
|
||||||
resolution = get_closest_resolution(dev->model->ccd_type, dpi, channels);
|
resolution = get_closest_resolution(dev->model->ccd_type, dpi, channels);
|
||||||
|
|
||||||
|
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, 3, ScanMethod::FLATBED);
|
||||||
|
|
||||||
settings.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
settings.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||||
|
|
||||||
settings.scan_method = ScanMethod::FLATBED;
|
settings.scan_method = ScanMethod::FLATBED;
|
||||||
|
@ -2802,8 +2801,7 @@ static void ad_fe_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen
|
||||||
settings.yres = resolution;
|
settings.yres = resolution;
|
||||||
settings.tl_x = 0;
|
settings.tl_x = 0;
|
||||||
settings.tl_y = 0;
|
settings.tl_y = 0;
|
||||||
settings.pixels =
|
settings.pixels = (calib_sensor.sensor_pixels * resolution) / calib_sensor.optical_res;
|
||||||
(sensor.sensor_pixels * resolution) / sensor.optical_res;
|
|
||||||
settings.lines = CALIBRATION_LINES;
|
settings.lines = CALIBRATION_LINES;
|
||||||
settings.depth = 8;
|
settings.depth = 8;
|
||||||
settings.color_filter = ColorFilter::RED;
|
settings.color_filter = ColorFilter::RED;
|
||||||
|
@ -2824,11 +2822,10 @@ static void ad_fe_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen
|
||||||
|
|
||||||
std::vector<uint8_t> line;
|
std::vector<uint8_t> line;
|
||||||
|
|
||||||
/* loop until each channel raises to acceptable level */
|
// loop until each channel raises to acceptable level
|
||||||
while ((average < sensor.gain_white_ref) && (pass < 30))
|
while ((average < calib_sensor.gain_white_ref) && (pass < 30)) {
|
||||||
{
|
|
||||||
// scan with no move
|
// scan with no move
|
||||||
simple_scan(dev, sensor, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE, line);
|
simple_scan(dev, calib_sensor, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE, line);
|
||||||
|
|
||||||
/* log scanning data */
|
/* log scanning data */
|
||||||
if (DBG_LEVEL >= DBG_data)
|
if (DBG_LEVEL >= DBG_data)
|
||||||
|
@ -2852,7 +2849,7 @@ static void ad_fe_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen
|
||||||
|
|
||||||
uint8_t gain0 = dev->frontend.get_gain(0);
|
uint8_t gain0 = dev->frontend.get_gain(0);
|
||||||
// adjusts gain for the channel
|
// adjusts gain for the channel
|
||||||
if (average < sensor.gain_white_ref) {
|
if (average < calib_sensor.gain_white_ref) {
|
||||||
gain0 += 1;
|
gain0 += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2902,6 +2899,9 @@ static void gl646_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen
|
||||||
resolution = get_closest_resolution(dev->model->ccd_type, dev->settings.xres, channels);
|
resolution = get_closest_resolution(dev->model->ccd_type, dev->settings.xres, channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, channels,
|
||||||
|
ScanMethod::FLATBED);
|
||||||
|
|
||||||
settings.scan_method = dev->settings.scan_method;
|
settings.scan_method = dev->settings.scan_method;
|
||||||
settings.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
settings.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||||
settings.xres = resolution;
|
settings.xres = resolution;
|
||||||
|
@ -2910,7 +2910,7 @@ static void gl646_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen
|
||||||
if (settings.scan_method == ScanMethod::FLATBED)
|
if (settings.scan_method == ScanMethod::FLATBED)
|
||||||
{
|
{
|
||||||
settings.tl_x = 0;
|
settings.tl_x = 0;
|
||||||
settings.pixels = (sensor.sensor_pixels * resolution) / sensor.optical_res;
|
settings.pixels = (calib_sensor.sensor_pixels * resolution) / calib_sensor.optical_res;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2955,12 +2955,12 @@ static void gl646_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen
|
||||||
std::vector<uint8_t> line;
|
std::vector<uint8_t> line;
|
||||||
|
|
||||||
/* loop until each channel raises to acceptable level */
|
/* loop until each channel raises to acceptable level */
|
||||||
while (((average[0] < sensor.gain_white_ref)
|
while (((average[0] < calib_sensor.gain_white_ref) ||
|
||||||
|| (average[1] < sensor.gain_white_ref)
|
(average[1] < calib_sensor.gain_white_ref) ||
|
||||||
|| (average[2] < sensor.gain_white_ref)) && (pass < 30))
|
(average[2] < calib_sensor.gain_white_ref)) && (pass < 30))
|
||||||
{
|
{
|
||||||
// scan with no move
|
// scan with no move
|
||||||
simple_scan(dev, sensor, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE, line);
|
simple_scan(dev, calib_sensor, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE, line);
|
||||||
|
|
||||||
/* log scanning data */
|
/* log scanning data */
|
||||||
if (DBG_LEVEL >= DBG_data)
|
if (DBG_LEVEL >= DBG_data)
|
||||||
|
@ -3011,7 +3011,7 @@ static void gl646_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen
|
||||||
average[k] = average[k] / count;
|
average[k] = average[k] / count;
|
||||||
|
|
||||||
/* adjusts gain for the channel */
|
/* adjusts gain for the channel */
|
||||||
if (average[k] < sensor.gain_white_ref)
|
if (average[k] < calib_sensor.gain_white_ref)
|
||||||
dev->frontend.set_gain(k, dev->frontend.get_gain(k) + 1);
|
dev->frontend.set_gain(k, dev->frontend.get_gain(k) + 1);
|
||||||
|
|
||||||
DBG(DBG_proc, "%s: channel %d, average = %.2f, gain = %d\n", __func__, k, average[k],
|
DBG(DBG_proc, "%s: channel %d, average = %.2f, gain = %d\n", __func__, k, average[k],
|
||||||
|
@ -3039,6 +3039,8 @@ static void gl646_init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor
|
||||||
int* total_size)
|
int* total_size)
|
||||||
{
|
{
|
||||||
DBG_HELPER(dbg);
|
DBG_HELPER(dbg);
|
||||||
|
(void) sensor;
|
||||||
|
|
||||||
Genesys_Settings settings;
|
Genesys_Settings settings;
|
||||||
int resolution, lines;
|
int resolution, lines;
|
||||||
|
|
||||||
|
@ -3046,6 +3048,9 @@ static void gl646_init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor
|
||||||
|
|
||||||
resolution = get_closest_resolution(dev->model->ccd_type, 300, 1);
|
resolution = get_closest_resolution(dev->model->ccd_type, 300, 1);
|
||||||
|
|
||||||
|
const auto& local_sensor = sanei_genesys_find_sensor(dev, resolution, 1,
|
||||||
|
dev->settings.scan_method);
|
||||||
|
|
||||||
/* set up for a half width 2 lines gray scan without moving */
|
/* set up for a half width 2 lines gray scan without moving */
|
||||||
settings.scan_method = ScanMethod::FLATBED;
|
settings.scan_method = ScanMethod::FLATBED;
|
||||||
settings.scan_mode = ScanColorMode::GRAY;
|
settings.scan_mode = ScanColorMode::GRAY;
|
||||||
|
@ -3053,8 +3058,7 @@ static void gl646_init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor
|
||||||
settings.yres = resolution;
|
settings.yres = resolution;
|
||||||
settings.tl_x = 0;
|
settings.tl_x = 0;
|
||||||
settings.tl_y = 0;
|
settings.tl_y = 0;
|
||||||
settings.pixels =
|
settings.pixels = (local_sensor.sensor_pixels * resolution) / local_sensor.optical_res;
|
||||||
(sensor.sensor_pixels * resolution) / sensor.optical_res;
|
|
||||||
settings.lines = 2;
|
settings.lines = 2;
|
||||||
settings.depth = 8;
|
settings.depth = 8;
|
||||||
settings.color_filter = ColorFilter::RED;
|
settings.color_filter = ColorFilter::RED;
|
||||||
|
@ -3064,7 +3068,7 @@ static void gl646_init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor
|
||||||
settings.dynamic_lineart = SANE_FALSE;
|
settings.dynamic_lineart = SANE_FALSE;
|
||||||
|
|
||||||
// setup for scan
|
// setup for scan
|
||||||
setup_for_scan(dev, sensor, &dev->reg, settings, SANE_TRUE, SANE_FALSE, SANE_FALSE);
|
setup_for_scan(dev, local_sensor, &dev->reg, settings, SANE_TRUE, SANE_FALSE, SANE_FALSE);
|
||||||
|
|
||||||
/* we are not going to move, so clear these bits */
|
/* we are not going to move, so clear these bits */
|
||||||
dev->reg.find_reg(0x02).value &= ~(REG02_FASTFED | REG02_AGOHOME);
|
dev->reg.find_reg(0x02).value &= ~(REG02_FASTFED | REG02_AGOHOME);
|
||||||
|
@ -3084,7 +3088,7 @@ static void gl646_init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor
|
||||||
*total_size = lines * settings.pixels;
|
*total_size = lines * settings.pixels;
|
||||||
|
|
||||||
// now registers are ok, write them to scanner
|
// now registers are ok, write them to scanner
|
||||||
gl646_set_fe(dev, sensor, AFE_SET, settings.xres);
|
gl646_set_fe(dev, local_sensor, AFE_SET, settings.xres);
|
||||||
dev->write_registers(*local_reg);
|
dev->write_registers(*local_reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3115,7 +3119,7 @@ static void gl646_repark_head(Genesys_Device* dev)
|
||||||
settings.threshold = 0;
|
settings.threshold = 0;
|
||||||
settings.dynamic_lineart = SANE_FALSE;
|
settings.dynamic_lineart = SANE_FALSE;
|
||||||
|
|
||||||
const auto& sensor = sanei_genesys_find_sensor(dev, settings.xres, ScanMethod::FLATBED);
|
const auto& sensor = sanei_genesys_find_sensor(dev, settings.xres, 3, ScanMethod::FLATBED);
|
||||||
|
|
||||||
setup_for_scan(dev, sensor, &dev->reg, settings, SANE_FALSE, SANE_FALSE, SANE_FALSE);
|
setup_for_scan(dev, sensor, &dev->reg, settings, SANE_FALSE, SANE_FALSE, SANE_FALSE);
|
||||||
|
|
||||||
|
@ -3357,13 +3361,12 @@ static void simple_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
|
||||||
lines = dev->reg.get24(REG_LINCNT) + 1;
|
lines = dev->reg.get24(REG_LINCNT) + 1;
|
||||||
}
|
}
|
||||||
size = lines * settings.pixels;
|
size = lines * settings.pixels;
|
||||||
if (settings.depth == 16)
|
if (settings.depth == 16) {
|
||||||
bpp = 2;
|
bpp = 2;
|
||||||
else
|
} else {
|
||||||
bpp = 1;
|
bpp = 1;
|
||||||
size *= bpp;
|
}
|
||||||
if (settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
size *= bpp * settings.get_channels();
|
||||||
size *= 3;
|
|
||||||
data.clear();
|
data.clear();
|
||||||
data.resize(size);
|
data.resize(size);
|
||||||
|
|
||||||
|
@ -3501,7 +3504,7 @@ static void simple_move(Genesys_Device* dev, SANE_Int distance)
|
||||||
|
|
||||||
int resolution = get_lowest_resolution(dev->model->ccd_type, 3);
|
int resolution = get_lowest_resolution(dev->model->ccd_type, 3);
|
||||||
|
|
||||||
const auto& sensor = sanei_genesys_find_sensor(dev, resolution, ScanMethod::FLATBED);
|
const auto& sensor = sanei_genesys_find_sensor(dev, resolution, 3, ScanMethod::FLATBED);
|
||||||
|
|
||||||
/* TODO give a no AGOHOME flag */
|
/* TODO give a no AGOHOME flag */
|
||||||
settings.scan_method = ScanMethod::TRANSPARENCY;
|
settings.scan_method = ScanMethod::TRANSPARENCY;
|
||||||
|
@ -3732,12 +3735,7 @@ gl646_is_compatible_calibration (Genesys_Device * dev, const Genesys_Sensor& sen
|
||||||
/* build minimal current_setup for calibration cache use only, it will be better
|
/* build minimal current_setup for calibration cache use only, it will be better
|
||||||
* computed when during setup for scan
|
* computed when during setup for scan
|
||||||
*/
|
*/
|
||||||
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
dev->session.params.channels = dev->settings.get_channels();
|
||||||
{
|
|
||||||
dev->session.params.channels = 3;
|
|
||||||
} else {
|
|
||||||
dev->session.params.channels = 1;
|
|
||||||
}
|
|
||||||
dev->current_setup.xres = dev->settings.xres;
|
dev->current_setup.xres = dev->settings.xres;
|
||||||
|
|
||||||
DBG(DBG_io, "%s: requested=(%d,%f), tested=(%d,%f)\n", __func__,
|
DBG(DBG_io, "%s: requested=(%d,%f), tested=(%d,%f)\n", __func__,
|
||||||
|
@ -3796,13 +3794,17 @@ static void gl646_search_strip(Genesys_Device* dev, const Genesys_Sensor& sensor
|
||||||
SANE_Bool black)
|
SANE_Bool black)
|
||||||
{
|
{
|
||||||
DBG_HELPER(dbg);
|
DBG_HELPER(dbg);
|
||||||
|
(void) sensor;
|
||||||
|
|
||||||
Genesys_Settings settings;
|
Genesys_Settings settings;
|
||||||
int res = get_closest_resolution(dev->model->ccd_type, 75, 1);
|
int res = get_closest_resolution(dev->model->ccd_type, 75, 1);
|
||||||
unsigned int pass, count, found, x, y;
|
unsigned int pass, count, found, x, y;
|
||||||
char title[80];
|
char title[80];
|
||||||
|
|
||||||
|
const auto& calib_sensor = sanei_genesys_find_sensor(dev, res, 1, ScanMethod::FLATBED);
|
||||||
|
|
||||||
unsigned ccd_size_divisor = 1;
|
unsigned ccd_size_divisor = 1;
|
||||||
if (sensor.ccd_size_divisor > 1) {
|
if (calib_sensor.ccd_size_divisor > 1) {
|
||||||
ccd_size_divisor = get_ccd_size_divisor(dev->model->ccd_type, res, 1);
|
ccd_size_divisor = get_ccd_size_divisor(dev->model->ccd_type, res, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3837,7 +3839,7 @@ static void gl646_search_strip(Genesys_Device* dev, const Genesys_Sensor& sensor
|
||||||
while (pass < 20 && !found)
|
while (pass < 20 && !found)
|
||||||
{
|
{
|
||||||
// scan a full width strip
|
// scan a full width strip
|
||||||
simple_scan(dev, sensor, settings, SANE_TRUE, forward, SANE_FALSE, data);
|
simple_scan(dev, calib_sensor, settings, SANE_TRUE, forward, SANE_FALSE, data);
|
||||||
|
|
||||||
if (DBG_LEVEL >= DBG_data)
|
if (DBG_LEVEL >= DBG_data)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2035,8 +2035,6 @@ dummy \ scanned lines
|
||||||
|
|
||||||
static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||||
{
|
{
|
||||||
int channels;
|
|
||||||
int depth;
|
|
||||||
int start;
|
int start;
|
||||||
|
|
||||||
int used_res;
|
int used_res;
|
||||||
|
@ -2056,17 +2054,6 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se
|
||||||
DBG(DBG_info, "%s ", __func__);
|
DBG(DBG_info, "%s ", __func__);
|
||||||
debug_dump(DBG_info, dev->settings);
|
debug_dump(DBG_info, dev->settings);
|
||||||
|
|
||||||
/* channels */
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
|
||||||
channels = 3;
|
|
||||||
else
|
|
||||||
channels = 1;
|
|
||||||
|
|
||||||
/* depth */
|
|
||||||
depth = dev->settings.depth;
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::LINEART)
|
|
||||||
depth = 1;
|
|
||||||
|
|
||||||
/* start */
|
/* start */
|
||||||
start = SANE_UNFIX (dev->model->x_offset);
|
start = SANE_UNFIX (dev->model->x_offset);
|
||||||
|
|
||||||
|
@ -2081,8 +2068,8 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se
|
||||||
session.params.starty = 0; // not used
|
session.params.starty = 0; // not used
|
||||||
session.params.pixels = dev->settings.pixels;
|
session.params.pixels = dev->settings.pixels;
|
||||||
session.params.lines = dev->settings.lines;
|
session.params.lines = dev->settings.lines;
|
||||||
session.params.depth = depth;
|
session.params.depth = dev->settings.get_depth();
|
||||||
session.params.channels = channels;
|
session.params.channels = dev->settings.get_channels();
|
||||||
session.params.scan_method = dev->settings.scan_method;
|
session.params.scan_method = dev->settings.scan_method;
|
||||||
session.params.scan_mode = dev->settings.scan_mode;
|
session.params.scan_mode = dev->settings.scan_mode;
|
||||||
session.params.color_filter = dev->settings.color_filter;
|
session.params.color_filter = dev->settings.color_filter;
|
||||||
|
@ -2894,7 +2881,7 @@ static void gl841_search_start_position(Genesys_Device* dev)
|
||||||
|
|
||||||
// FIXME: the current approach of doing search only for one resolution does not work on scanners
|
// FIXME: the current approach of doing search only for one resolution does not work on scanners
|
||||||
// whith employ different sensors with potentially different settings.
|
// whith employ different sensors with potentially different settings.
|
||||||
const auto& sensor = sanei_genesys_find_sensor(dev, dpi, ScanMethod::FLATBED);
|
const auto& sensor = sanei_genesys_find_sensor(dev, dpi, 1, ScanMethod::FLATBED);
|
||||||
|
|
||||||
ScanSession session;
|
ScanSession session;
|
||||||
session.params.xres = dpi;
|
session.params.xres = dpi;
|
||||||
|
@ -2956,14 +2943,6 @@ static void gl841_init_regs_for_coarse_calibration(Genesys_Device* dev,
|
||||||
Genesys_Register_Set& regs)
|
Genesys_Register_Set& regs)
|
||||||
{
|
{
|
||||||
DBG_HELPER(dbg);
|
DBG_HELPER(dbg);
|
||||||
uint8_t channels;
|
|
||||||
|
|
||||||
/* set line size */
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
|
||||||
channels = 3;
|
|
||||||
else {
|
|
||||||
channels = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ScanSession session;
|
ScanSession session;
|
||||||
session.params.xres = dev->settings.xres;
|
session.params.xres = dev->settings.xres;
|
||||||
|
@ -2973,7 +2952,7 @@ static void gl841_init_regs_for_coarse_calibration(Genesys_Device* dev,
|
||||||
session.params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel();
|
session.params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel();
|
||||||
session.params.lines = 20;
|
session.params.lines = 20;
|
||||||
session.params.depth = 16;
|
session.params.depth = 16;
|
||||||
session.params.channels = channels;
|
session.params.channels = dev->settings.get_channels();
|
||||||
session.params.scan_method = dev->settings.scan_method;
|
session.params.scan_method = dev->settings.scan_method;
|
||||||
session.params.scan_mode = dev->settings.scan_mode;
|
session.params.scan_mode = dev->settings.scan_mode;
|
||||||
session.params.color_filter = dev->settings.color_filter;
|
session.params.color_filter = dev->settings.color_filter;
|
||||||
|
@ -3061,27 +3040,13 @@ static void gl841_init_regs_for_shading(Genesys_Device* dev, const Genesys_Senso
|
||||||
static void gl841_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor)
|
static void gl841_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor)
|
||||||
{
|
{
|
||||||
DBG_HELPER(dbg);
|
DBG_HELPER(dbg);
|
||||||
int channels;
|
|
||||||
int flags;
|
int flags;
|
||||||
int depth;
|
|
||||||
float move;
|
float move;
|
||||||
int move_dpi;
|
int move_dpi;
|
||||||
float start;
|
float start;
|
||||||
|
|
||||||
debug_dump(DBG_info, dev->settings);
|
debug_dump(DBG_info, dev->settings);
|
||||||
|
|
||||||
/* channels */
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
|
||||||
channels = 3;
|
|
||||||
else
|
|
||||||
channels = 1;
|
|
||||||
|
|
||||||
/* depth */
|
|
||||||
depth = dev->settings.depth;
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::LINEART)
|
|
||||||
depth = 1;
|
|
||||||
|
|
||||||
|
|
||||||
/* steps to move to reach scanning area:
|
/* steps to move to reach scanning area:
|
||||||
- first we move to physical start of scanning
|
- first we move to physical start of scanning
|
||||||
either by a fixed steps amount from the black strip
|
either by a fixed steps amount from the black strip
|
||||||
|
@ -3157,8 +3122,8 @@ static void gl841_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor&
|
||||||
session.params.starty = move;
|
session.params.starty = move;
|
||||||
session.params.pixels = dev->settings.pixels;
|
session.params.pixels = dev->settings.pixels;
|
||||||
session.params.lines = dev->settings.lines;
|
session.params.lines = dev->settings.lines;
|
||||||
session.params.depth = depth;
|
session.params.depth = dev->settings.get_depth();
|
||||||
session.params.channels = channels;
|
session.params.channels = dev->settings.get_channels();
|
||||||
session.params.scan_method = dev->settings.scan_method;
|
session.params.scan_method = dev->settings.scan_method;
|
||||||
session.params.scan_mode = dev->settings.scan_mode;
|
session.params.scan_mode = dev->settings.scan_mode;
|
||||||
session.params.color_filter = dev->settings.color_filter;
|
session.params.color_filter = dev->settings.color_filter;
|
||||||
|
|
|
@ -1403,8 +1403,6 @@ static void gl843_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
static void
|
static void
|
||||||
gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||||
{
|
{
|
||||||
int channels;
|
|
||||||
int depth;
|
|
||||||
int start;
|
int start;
|
||||||
|
|
||||||
int used_res;
|
int used_res;
|
||||||
|
@ -1423,18 +1421,6 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
||||||
/* we have 2 domains for ccd: xres below or above half ccd max dpi */
|
/* we have 2 domains for ccd: xres below or above half ccd max dpi */
|
||||||
unsigned ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(dev->settings.xres);
|
unsigned ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(dev->settings.xres);
|
||||||
|
|
||||||
/* channels */
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
|
||||||
channels = 3;
|
|
||||||
else
|
|
||||||
channels = 1;
|
|
||||||
|
|
||||||
/* depth */
|
|
||||||
depth = dev->settings.depth;
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::LINEART) {
|
|
||||||
depth = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dev->settings.scan_method == ScanMethod::TRANSPARENCY ||
|
if (dev->settings.scan_method == ScanMethod::TRANSPARENCY ||
|
||||||
dev->settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED)
|
dev->settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED)
|
||||||
{
|
{
|
||||||
|
@ -1460,8 +1446,8 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
||||||
session.params.starty = 0; // not used
|
session.params.starty = 0; // not used
|
||||||
session.params.pixels = dev->settings.pixels;
|
session.params.pixels = dev->settings.pixels;
|
||||||
session.params.lines = dev->settings.lines;
|
session.params.lines = dev->settings.lines;
|
||||||
session.params.depth = depth;
|
session.params.depth = dev->settings.get_depth();
|
||||||
session.params.channels = channels;
|
session.params.channels = dev->settings.get_channels();
|
||||||
session.params.scan_method = dev->settings.scan_method;
|
session.params.scan_method = dev->settings.scan_method;
|
||||||
session.params.scan_mode = dev->settings.scan_mode;
|
session.params.scan_mode = dev->settings.scan_mode;
|
||||||
session.params.color_filter = dev->settings.color_filter;
|
session.params.color_filter = dev->settings.color_filter;
|
||||||
|
@ -2139,7 +2125,7 @@ static void gl843_slow_back_home(Genesys_Device* dev, SANE_Bool wait_until_home)
|
||||||
local_reg = dev->reg;
|
local_reg = dev->reg;
|
||||||
resolution=sanei_genesys_get_lowest_ydpi(dev);
|
resolution=sanei_genesys_get_lowest_ydpi(dev);
|
||||||
|
|
||||||
const auto& sensor = sanei_genesys_find_sensor(dev, resolution, ScanMethod::FLATBED);
|
const auto& sensor = sanei_genesys_find_sensor(dev, resolution, 1, ScanMethod::FLATBED);
|
||||||
|
|
||||||
ScanSession session;
|
ScanSession session;
|
||||||
session.params.xres = resolution;
|
session.params.xres = resolution;
|
||||||
|
@ -2234,7 +2220,7 @@ static void gl843_search_start_position(Genesys_Device* dev)
|
||||||
|
|
||||||
// FIXME: the current approach of doing search only for one resolution does not work on scanners
|
// FIXME: the current approach of doing search only for one resolution does not work on scanners
|
||||||
// whith employ different sensors with potentially different settings.
|
// whith employ different sensors with potentially different settings.
|
||||||
const auto& sensor = sanei_genesys_find_sensor(dev, dpi, ScanMethod::FLATBED);
|
const auto& sensor = sanei_genesys_find_sensor(dev, dpi, 1, ScanMethod::FLATBED);
|
||||||
|
|
||||||
ScanSession session;
|
ScanSession session;
|
||||||
session.params.xres = dpi;
|
session.params.xres = dpi;
|
||||||
|
@ -2298,13 +2284,6 @@ static void gl843_init_regs_for_coarse_calibration(Genesys_Device* dev,
|
||||||
Genesys_Register_Set& regs)
|
Genesys_Register_Set& regs)
|
||||||
{
|
{
|
||||||
DBG_HELPER(dbg);
|
DBG_HELPER(dbg);
|
||||||
uint8_t channels;
|
|
||||||
|
|
||||||
/* set line size */
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
|
||||||
channels = 3;
|
|
||||||
else
|
|
||||||
channels = 1;
|
|
||||||
|
|
||||||
int flags = SCAN_FLAG_DISABLE_SHADING |
|
int flags = SCAN_FLAG_DISABLE_SHADING |
|
||||||
SCAN_FLAG_DISABLE_GAMMA |
|
SCAN_FLAG_DISABLE_GAMMA |
|
||||||
|
@ -2324,7 +2303,7 @@ static void gl843_init_regs_for_coarse_calibration(Genesys_Device* dev,
|
||||||
session.params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel();
|
session.params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel();
|
||||||
session.params.lines = 20;
|
session.params.lines = 20;
|
||||||
session.params.depth = 16;
|
session.params.depth = 16;
|
||||||
session.params.channels = channels;
|
session.params.channels = dev->settings.get_channels();
|
||||||
session.params.scan_method = dev->settings.scan_method;
|
session.params.scan_method = dev->settings.scan_method;
|
||||||
session.params.scan_mode = dev->settings.scan_mode;
|
session.params.scan_mode = dev->settings.scan_mode;
|
||||||
session.params.color_filter = dev->settings.color_filter;
|
session.params.color_filter = dev->settings.color_filter;
|
||||||
|
@ -2358,7 +2337,7 @@ static void gl843_feed(Genesys_Device* dev, unsigned int steps)
|
||||||
|
|
||||||
resolution=sanei_genesys_get_lowest_ydpi(dev);
|
resolution=sanei_genesys_get_lowest_ydpi(dev);
|
||||||
|
|
||||||
const auto& sensor = sanei_genesys_find_sensor(dev, resolution, ScanMethod::FLATBED);
|
const auto& sensor = sanei_genesys_find_sensor(dev, resolution, 3, ScanMethod::FLATBED);
|
||||||
|
|
||||||
ScanSession session;
|
ScanSession session;
|
||||||
session.params.xres = resolution;
|
session.params.xres = resolution;
|
||||||
|
@ -2438,7 +2417,7 @@ static void gl843_init_regs_for_shading(Genesys_Device* dev, const Genesys_Senso
|
||||||
factor=sensor.optical_res/dpihw;
|
factor=sensor.optical_res/dpihw;
|
||||||
resolution=dpihw;
|
resolution=dpihw;
|
||||||
|
|
||||||
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution,
|
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, dev->calib_channels,
|
||||||
dev->settings.scan_method);
|
dev->settings.scan_method);
|
||||||
|
|
||||||
if ((dev->settings.scan_method == ScanMethod::TRANSPARENCY ||
|
if ((dev->settings.scan_method == ScanMethod::TRANSPARENCY ||
|
||||||
|
@ -2516,26 +2495,13 @@ static void gl843_init_regs_for_shading(Genesys_Device* dev, const Genesys_Senso
|
||||||
static void gl843_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor)
|
static void gl843_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor)
|
||||||
{
|
{
|
||||||
DBG_HELPER(dbg);
|
DBG_HELPER(dbg);
|
||||||
int channels;
|
|
||||||
int flags;
|
int flags;
|
||||||
int depth;
|
|
||||||
float move;
|
float move;
|
||||||
int move_dpi;
|
int move_dpi;
|
||||||
float start;
|
float start;
|
||||||
|
|
||||||
debug_dump(DBG_info, dev->settings);
|
debug_dump(DBG_info, dev->settings);
|
||||||
|
|
||||||
/* channels */
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
|
||||||
channels = 3;
|
|
||||||
else
|
|
||||||
channels = 1;
|
|
||||||
|
|
||||||
/* depth */
|
|
||||||
depth = dev->settings.depth;
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::LINEART)
|
|
||||||
depth = 1;
|
|
||||||
|
|
||||||
move_dpi = dev->motor.base_ydpi;
|
move_dpi = dev->motor.base_ydpi;
|
||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
|
@ -2597,8 +2563,8 @@ static void gl843_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor&
|
||||||
session.params.starty = move;
|
session.params.starty = move;
|
||||||
session.params.pixels = dev->settings.pixels;
|
session.params.pixels = dev->settings.pixels;
|
||||||
session.params.lines = dev->settings.lines;
|
session.params.lines = dev->settings.lines;
|
||||||
session.params.depth = depth;
|
session.params.depth = dev->settings.get_depth();
|
||||||
session.params.channels = channels;
|
session.params.channels = dev->settings.get_channels();
|
||||||
session.params.scan_method = dev->settings.scan_method;
|
session.params.scan_method = dev->settings.scan_method;
|
||||||
session.params.scan_mode = dev->settings.scan_mode;
|
session.params.scan_mode = dev->settings.scan_mode;
|
||||||
session.params.color_filter = dev->settings.color_filter;
|
session.params.color_filter = dev->settings.color_filter;
|
||||||
|
@ -2670,7 +2636,8 @@ static SensorExposure gl843_led_calibration(Genesys_Device* dev, const Genesys_S
|
||||||
used_res = sensor.optical_res;
|
used_res = sensor.optical_res;
|
||||||
|
|
||||||
// take a copy, as we're going to modify exposure
|
// take a copy, as we're going to modify exposure
|
||||||
auto calib_sensor = sanei_genesys_find_sensor(dev, used_res, dev->settings.scan_method);
|
auto calib_sensor = sanei_genesys_find_sensor(dev, used_res, channels,
|
||||||
|
dev->settings.scan_method);
|
||||||
|
|
||||||
num_pixels =
|
num_pixels =
|
||||||
(calib_sensor.sensor_pixels * used_res) / calib_sensor.optical_res;
|
(calib_sensor.sensor_pixels * used_res) / calib_sensor.optical_res;
|
||||||
|
@ -2881,7 +2848,7 @@ static void gl843_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
|
||||||
factor = sensor.optical_res / dpihw;
|
factor = sensor.optical_res / dpihw;
|
||||||
resolution = dpihw;
|
resolution = dpihw;
|
||||||
|
|
||||||
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution,
|
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, channels,
|
||||||
dev->settings.scan_method);
|
dev->settings.scan_method);
|
||||||
|
|
||||||
int target_pixels = calib_sensor.sensor_pixels / factor;
|
int target_pixels = calib_sensor.sensor_pixels / factor;
|
||||||
|
@ -3138,7 +3105,7 @@ static void gl843_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen
|
||||||
flags |= SCAN_FLAG_USE_XPA;
|
flags |= SCAN_FLAG_USE_XPA;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution,
|
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, channels,
|
||||||
dev->settings.scan_method);
|
dev->settings.scan_method);
|
||||||
|
|
||||||
ScanSession session;
|
ScanSession session;
|
||||||
|
@ -3289,7 +3256,7 @@ static void gl843_init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor
|
||||||
dpihw = sensor.get_logical_hwdpi(resolution);
|
dpihw = sensor.get_logical_hwdpi(resolution);
|
||||||
resolution=dpihw;
|
resolution=dpihw;
|
||||||
|
|
||||||
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution,
|
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, *channels,
|
||||||
dev->settings.scan_method);
|
dev->settings.scan_method);
|
||||||
factor = calib_sensor.optical_res/dpihw;
|
factor = calib_sensor.optical_res/dpihw;
|
||||||
num_pixels = calib_sensor.sensor_pixels/(factor*2);
|
num_pixels = calib_sensor.sensor_pixels/(factor*2);
|
||||||
|
@ -3512,7 +3479,8 @@ static void gl843_search_strip(Genesys_Device* dev, const Genesys_Sensor& sensor
|
||||||
dpi = sanei_genesys_get_lowest_dpi(dev);
|
dpi = sanei_genesys_get_lowest_dpi(dev);
|
||||||
channels = 1;
|
channels = 1;
|
||||||
|
|
||||||
const auto& calib_sensor = sanei_genesys_find_sensor(dev, dpi, dev->settings.scan_method);
|
const auto& calib_sensor = sanei_genesys_find_sensor(dev, dpi, channels,
|
||||||
|
dev->settings.scan_method);
|
||||||
|
|
||||||
/* 10 MM */
|
/* 10 MM */
|
||||||
/* lines = (10 * dpi) / MM_PER_INCH; */
|
/* lines = (10 * dpi) / MM_PER_INCH; */
|
||||||
|
|
|
@ -1139,8 +1139,6 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
static void
|
static void
|
||||||
gl846_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
gl846_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||||
{
|
{
|
||||||
int channels;
|
|
||||||
int depth;
|
|
||||||
int start;
|
int start;
|
||||||
|
|
||||||
int used_res;
|
int used_res;
|
||||||
|
@ -1158,17 +1156,6 @@ gl846_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
||||||
DBG(DBG_info, "%s ", __func__);
|
DBG(DBG_info, "%s ", __func__);
|
||||||
debug_dump(DBG_info, dev->settings);
|
debug_dump(DBG_info, dev->settings);
|
||||||
|
|
||||||
/* channels */
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
|
||||||
channels = 3;
|
|
||||||
else
|
|
||||||
channels = 1;
|
|
||||||
|
|
||||||
/* depth */
|
|
||||||
depth = dev->settings.depth;
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::LINEART)
|
|
||||||
depth = 1;
|
|
||||||
|
|
||||||
/* start */
|
/* start */
|
||||||
start = SANE_UNFIX (dev->model->x_offset);
|
start = SANE_UNFIX (dev->model->x_offset);
|
||||||
start += dev->settings.tl_x;
|
start += dev->settings.tl_x;
|
||||||
|
@ -1181,8 +1168,8 @@ gl846_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
||||||
session.params.starty = 0; // not used
|
session.params.starty = 0; // not used
|
||||||
session.params.pixels = dev->settings.pixels;
|
session.params.pixels = dev->settings.pixels;
|
||||||
session.params.lines = dev->settings.lines;
|
session.params.lines = dev->settings.lines;
|
||||||
session.params.depth = depth;
|
session.params.depth = dev->settings.get_depth();
|
||||||
session.params.channels = channels;
|
session.params.channels = dev->settings.get_channels();
|
||||||
session.params.scan_method = dev->settings.scan_method;
|
session.params.scan_method = dev->settings.scan_method;
|
||||||
session.params.scan_mode = dev->settings.scan_mode;
|
session.params.scan_mode = dev->settings.scan_mode;
|
||||||
session.params.color_filter = dev->settings.color_filter;
|
session.params.color_filter = dev->settings.color_filter;
|
||||||
|
@ -1500,7 +1487,7 @@ static void gl846_search_start_position(Genesys_Device* dev)
|
||||||
|
|
||||||
// FIXME: the current approach of doing search only for one resolution does not work on scanners
|
// FIXME: the current approach of doing search only for one resolution does not work on scanners
|
||||||
// whith employ different sensors with potentially different settings.
|
// whith employ different sensors with potentially different settings.
|
||||||
const auto& sensor = sanei_genesys_find_sensor(dev, dpi, ScanMethod::FLATBED);
|
const auto& sensor = sanei_genesys_find_sensor(dev, dpi, 1, ScanMethod::FLATBED);
|
||||||
|
|
||||||
ScanSession session;
|
ScanSession session;
|
||||||
session.params.xres = dpi;
|
session.params.xres = dpi;
|
||||||
|
@ -1563,14 +1550,6 @@ static void gl846_init_regs_for_coarse_calibration(Genesys_Device* dev,
|
||||||
Genesys_Register_Set& regs)
|
Genesys_Register_Set& regs)
|
||||||
{
|
{
|
||||||
DBG_HELPER(dbg);
|
DBG_HELPER(dbg);
|
||||||
uint8_t channels;
|
|
||||||
|
|
||||||
/* set line size */
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
|
||||||
channels = 3;
|
|
||||||
else {
|
|
||||||
channels = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ScanSession session;
|
ScanSession session;
|
||||||
session.params.xres = dev->settings.xres;
|
session.params.xres = dev->settings.xres;
|
||||||
|
@ -1580,7 +1559,7 @@ static void gl846_init_regs_for_coarse_calibration(Genesys_Device* dev,
|
||||||
session.params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel();
|
session.params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel();
|
||||||
session.params.lines = 20;
|
session.params.lines = 20;
|
||||||
session.params.depth = 16;
|
session.params.depth = 16;
|
||||||
session.params.channels = channels;
|
session.params.channels = dev->settings.get_channels();
|
||||||
session.params.scan_method = dev->settings.scan_method;
|
session.params.scan_method = dev->settings.scan_method;
|
||||||
session.params.scan_mode = dev->settings.scan_mode;
|
session.params.scan_mode = dev->settings.scan_mode;
|
||||||
session.params.color_filter = dev->settings.color_filter;
|
session.params.color_filter = dev->settings.color_filter;
|
||||||
|
@ -1614,7 +1593,7 @@ static void gl846_feed(Genesys_Device* dev, unsigned int steps)
|
||||||
local_reg = dev->reg;
|
local_reg = dev->reg;
|
||||||
|
|
||||||
resolution=sanei_genesys_get_lowest_ydpi(dev);
|
resolution=sanei_genesys_get_lowest_ydpi(dev);
|
||||||
const auto& sensor = sanei_genesys_find_sensor(dev, resolution, ScanMethod::FLATBED);
|
const auto& sensor = sanei_genesys_find_sensor(dev, resolution, 3, ScanMethod::FLATBED);
|
||||||
|
|
||||||
ScanSession session;
|
ScanSession session;
|
||||||
session.params.xres = resolution;
|
session.params.xres = resolution;
|
||||||
|
@ -1735,27 +1714,13 @@ static void gl846_init_regs_for_shading(Genesys_Device* dev, const Genesys_Senso
|
||||||
static void gl846_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor)
|
static void gl846_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor)
|
||||||
{
|
{
|
||||||
DBG_HELPER(dbg);
|
DBG_HELPER(dbg);
|
||||||
int channels;
|
|
||||||
int flags;
|
int flags;
|
||||||
int depth;
|
|
||||||
float move;
|
float move;
|
||||||
int move_dpi;
|
int move_dpi;
|
||||||
float start;
|
float start;
|
||||||
|
|
||||||
debug_dump(DBG_info, dev->settings);
|
debug_dump(DBG_info, dev->settings);
|
||||||
|
|
||||||
/* channels */
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
|
||||||
channels = 3;
|
|
||||||
else
|
|
||||||
channels = 1;
|
|
||||||
|
|
||||||
/* depth */
|
|
||||||
depth = dev->settings.depth;
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::LINEART)
|
|
||||||
depth = 1;
|
|
||||||
|
|
||||||
|
|
||||||
/* steps to move to reach scanning area:
|
/* steps to move to reach scanning area:
|
||||||
- first we move to physical start of scanning
|
- first we move to physical start of scanning
|
||||||
either by a fixed steps amount from the black strip
|
either by a fixed steps amount from the black strip
|
||||||
|
@ -1788,7 +1753,7 @@ static void gl846_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor&
|
||||||
* computing acceleration/deceleration distance for scan
|
* computing acceleration/deceleration distance for scan
|
||||||
* resolution. So leave a remainder for it so scan makes the final
|
* resolution. So leave a remainder for it so scan makes the final
|
||||||
* move tuning */
|
* move tuning */
|
||||||
if(channels*dev->settings.yres>=600 && move>700)
|
if (dev->settings.get_channels() * dev->settings.yres >= 600 && move > 700)
|
||||||
{
|
{
|
||||||
gl846_feed(dev, move-500);
|
gl846_feed(dev, move-500);
|
||||||
move=500;
|
move=500;
|
||||||
|
@ -1821,8 +1786,8 @@ static void gl846_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor&
|
||||||
session.params.starty = move;
|
session.params.starty = move;
|
||||||
session.params.pixels = dev->settings.pixels;
|
session.params.pixels = dev->settings.pixels;
|
||||||
session.params.lines = dev->settings.lines;
|
session.params.lines = dev->settings.lines;
|
||||||
session.params.depth = depth;
|
session.params.depth = dev->settings.get_depth();
|
||||||
session.params.channels = channels;
|
session.params.channels = dev->settings.get_channels();
|
||||||
session.params.scan_method = dev->settings.scan_method;
|
session.params.scan_method = dev->settings.scan_method;
|
||||||
session.params.scan_mode = dev->settings.scan_mode;
|
session.params.scan_mode = dev->settings.scan_mode;
|
||||||
session.params.color_filter = dev->settings.color_filter;
|
session.params.color_filter = dev->settings.color_filter;
|
||||||
|
|
|
@ -1155,8 +1155,6 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
static void
|
static void
|
||||||
gl847_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
gl847_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||||
{
|
{
|
||||||
int channels;
|
|
||||||
int depth;
|
|
||||||
int start;
|
int start;
|
||||||
|
|
||||||
int used_res;
|
int used_res;
|
||||||
|
@ -1174,17 +1172,6 @@ gl847_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
||||||
DBG(DBG_info, "%s ", __func__);
|
DBG(DBG_info, "%s ", __func__);
|
||||||
debug_dump(DBG_info, dev->settings);
|
debug_dump(DBG_info, dev->settings);
|
||||||
|
|
||||||
/* channels */
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
|
||||||
channels = 3;
|
|
||||||
else
|
|
||||||
channels = 1;
|
|
||||||
|
|
||||||
/* depth */
|
|
||||||
depth = dev->settings.depth;
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::LINEART)
|
|
||||||
depth = 1;
|
|
||||||
|
|
||||||
/* start */
|
/* start */
|
||||||
start = SANE_UNFIX (dev->model->x_offset);
|
start = SANE_UNFIX (dev->model->x_offset);
|
||||||
start += dev->settings.tl_x;
|
start += dev->settings.tl_x;
|
||||||
|
@ -1197,8 +1184,8 @@ gl847_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
||||||
session.params.starty = 0; // not used
|
session.params.starty = 0; // not used
|
||||||
session.params.pixels = dev->settings.pixels;
|
session.params.pixels = dev->settings.pixels;
|
||||||
session.params.lines = dev->settings.lines;
|
session.params.lines = dev->settings.lines;
|
||||||
session.params.depth = depth;
|
session.params.depth = dev->settings.get_depth();
|
||||||
session.params.channels = channels;
|
session.params.channels = dev->settings.get_channels();
|
||||||
session.params.scan_method = dev->settings.scan_method;
|
session.params.scan_method = dev->settings.scan_method;
|
||||||
session.params.scan_mode = dev->settings.scan_mode;
|
session.params.scan_mode = dev->settings.scan_mode;
|
||||||
session.params.color_filter = dev->settings.color_filter;
|
session.params.color_filter = dev->settings.color_filter;
|
||||||
|
@ -1557,7 +1544,7 @@ static void gl847_search_start_position(Genesys_Device* dev)
|
||||||
|
|
||||||
// FIXME: the current approach of doing search only for one resolution does not work on scanners
|
// FIXME: the current approach of doing search only for one resolution does not work on scanners
|
||||||
// whith employ different sensors with potentially different settings.
|
// whith employ different sensors with potentially different settings.
|
||||||
const auto& sensor = sanei_genesys_find_sensor(dev, dpi, ScanMethod::FLATBED);
|
const auto& sensor = sanei_genesys_find_sensor(dev, dpi, 1, ScanMethod::FLATBED);
|
||||||
|
|
||||||
ScanSession session;
|
ScanSession session;
|
||||||
session.params.xres = dpi;
|
session.params.xres = dpi;
|
||||||
|
@ -1620,14 +1607,6 @@ static void gl847_init_regs_for_coarse_calibration(Genesys_Device* dev,
|
||||||
Genesys_Register_Set& regs)
|
Genesys_Register_Set& regs)
|
||||||
{
|
{
|
||||||
DBG_HELPER(dbg);
|
DBG_HELPER(dbg);
|
||||||
uint8_t channels;
|
|
||||||
|
|
||||||
/* set line size */
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
|
||||||
channels = 3;
|
|
||||||
else {
|
|
||||||
channels = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ScanSession session;
|
ScanSession session;
|
||||||
session.params.xres = dev->settings.xres;
|
session.params.xres = dev->settings.xres;
|
||||||
|
@ -1637,7 +1616,7 @@ static void gl847_init_regs_for_coarse_calibration(Genesys_Device* dev,
|
||||||
session.params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel();
|
session.params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel();
|
||||||
session.params.lines = 20;
|
session.params.lines = 20;
|
||||||
session.params.depth = 16;
|
session.params.depth = 16;
|
||||||
session.params.channels = channels;
|
session.params.channels = dev->settings.get_channels();
|
||||||
session.params.scan_method = dev->settings.scan_method;
|
session.params.scan_method = dev->settings.scan_method;
|
||||||
session.params.scan_mode = dev->settings.scan_mode;
|
session.params.scan_mode = dev->settings.scan_mode;
|
||||||
session.params.color_filter = dev->settings.color_filter;
|
session.params.color_filter = dev->settings.color_filter;
|
||||||
|
@ -1670,7 +1649,7 @@ static void gl847_feed(Genesys_Device* dev, unsigned int steps)
|
||||||
local_reg = dev->reg;
|
local_reg = dev->reg;
|
||||||
|
|
||||||
resolution=sanei_genesys_get_lowest_ydpi(dev);
|
resolution=sanei_genesys_get_lowest_ydpi(dev);
|
||||||
const auto& sensor = sanei_genesys_find_sensor(dev, resolution, ScanMethod::FLATBED);
|
const auto& sensor = sanei_genesys_find_sensor(dev, resolution, 3, ScanMethod::FLATBED);
|
||||||
|
|
||||||
ScanSession session;
|
ScanSession session;
|
||||||
session.params.xres = resolution;
|
session.params.xres = resolution;
|
||||||
|
@ -1791,27 +1770,13 @@ static void gl847_init_regs_for_shading(Genesys_Device* dev, const Genesys_Senso
|
||||||
static void gl847_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor)
|
static void gl847_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor)
|
||||||
{
|
{
|
||||||
DBG_HELPER(dbg);
|
DBG_HELPER(dbg);
|
||||||
int channels;
|
|
||||||
int flags;
|
int flags;
|
||||||
int depth;
|
|
||||||
float move;
|
float move;
|
||||||
int move_dpi;
|
int move_dpi;
|
||||||
float start;
|
float start;
|
||||||
|
|
||||||
debug_dump(DBG_info, dev->settings);
|
debug_dump(DBG_info, dev->settings);
|
||||||
|
|
||||||
/* channels */
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
|
||||||
channels = 3;
|
|
||||||
else
|
|
||||||
channels = 1;
|
|
||||||
|
|
||||||
/* depth */
|
|
||||||
depth = dev->settings.depth;
|
|
||||||
if (dev->settings.scan_mode == ScanColorMode::LINEART)
|
|
||||||
depth = 1;
|
|
||||||
|
|
||||||
|
|
||||||
/* steps to move to reach scanning area:
|
/* steps to move to reach scanning area:
|
||||||
- first we move to physical start of scanning
|
- first we move to physical start of scanning
|
||||||
either by a fixed steps amount from the black strip
|
either by a fixed steps amount from the black strip
|
||||||
|
@ -1844,8 +1809,7 @@ static void gl847_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor&
|
||||||
* computing acceleration/deceleration distance for scan
|
* computing acceleration/deceleration distance for scan
|
||||||
* resolution. So leave a remainder for it so scan makes the final
|
* resolution. So leave a remainder for it so scan makes the final
|
||||||
* move tuning */
|
* move tuning */
|
||||||
if(channels*dev->settings.yres>=600 && move>700)
|
if (dev->settings.get_channels() * dev->settings.yres >= 600 && move > 700) {
|
||||||
{
|
|
||||||
gl847_feed(dev, move-500);
|
gl847_feed(dev, move-500);
|
||||||
move=500;
|
move=500;
|
||||||
}
|
}
|
||||||
|
@ -1877,8 +1841,8 @@ static void gl847_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor&
|
||||||
session.params.starty = move;
|
session.params.starty = move;
|
||||||
session.params.pixels = dev->settings.pixels;
|
session.params.pixels = dev->settings.pixels;
|
||||||
session.params.lines = dev->settings.lines;
|
session.params.lines = dev->settings.lines;
|
||||||
session.params.depth = depth;
|
session.params.depth = dev->settings.get_depth();
|
||||||
session.params.channels = channels;
|
session.params.channels = dev->settings.get_channels();
|
||||||
session.params.scan_method = dev->settings.scan_method;
|
session.params.scan_method = dev->settings.scan_method;
|
||||||
session.params.scan_mode = dev->settings.scan_mode;
|
session.params.scan_mode = dev->settings.scan_mode;
|
||||||
session.params.color_filter = dev->settings.color_filter;
|
session.params.color_filter = dev->settings.color_filter;
|
||||||
|
|
|
@ -427,9 +427,9 @@ extern void sanei_genesys_write_ahb(Genesys_Device* dev, uint32_t addr, uint32_t
|
||||||
extern void sanei_genesys_init_structs (Genesys_Device * dev);
|
extern void sanei_genesys_init_structs (Genesys_Device * dev);
|
||||||
|
|
||||||
const Genesys_Sensor& sanei_genesys_find_sensor_any(Genesys_Device* dev);
|
const Genesys_Sensor& sanei_genesys_find_sensor_any(Genesys_Device* dev);
|
||||||
const Genesys_Sensor& sanei_genesys_find_sensor(Genesys_Device* dev, int dpi,
|
const Genesys_Sensor& sanei_genesys_find_sensor(Genesys_Device* dev, int dpi, unsigned channels,
|
||||||
ScanMethod scan_method);
|
ScanMethod scan_method);
|
||||||
Genesys_Sensor& sanei_genesys_find_sensor_for_write(Genesys_Device* dev, int dpi,
|
Genesys_Sensor& sanei_genesys_find_sensor_for_write(Genesys_Device* dev, int dpi, unsigned channels,
|
||||||
ScanMethod scan_method);
|
ScanMethod scan_method);
|
||||||
|
|
||||||
std::vector<std::reference_wrapper<const Genesys_Sensor>>
|
std::vector<std::reference_wrapper<const Genesys_Sensor>>
|
||||||
|
|
|
@ -253,6 +253,9 @@ struct Genesys_Sensor {
|
||||||
// the resolution list that the sensor is usable at.
|
// the resolution list that the sensor is usable at.
|
||||||
ResolutionFilter resolutions = ResolutionFilter::ANY;
|
ResolutionFilter resolutions = ResolutionFilter::ANY;
|
||||||
|
|
||||||
|
// the channel list that the sensor is usable at
|
||||||
|
std::vector<unsigned> channels = { 1, 3 };
|
||||||
|
|
||||||
// the scan method used with the sensor
|
// the scan method used with the sensor
|
||||||
ScanMethod method = ScanMethod::FLATBED;
|
ScanMethod method = ScanMethod::FLATBED;
|
||||||
|
|
||||||
|
@ -316,6 +319,11 @@ struct Genesys_Sensor {
|
||||||
return (custom_regs.get_value(0x18) & REG_0x18_CKSEL) + 1;
|
return (custom_regs.get_value(0x18) & REG_0x18_CKSEL) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool matches_channel_count(unsigned count) const
|
||||||
|
{
|
||||||
|
return std::find(channels.begin(), channels.end(), count) != channels.end();
|
||||||
|
}
|
||||||
|
|
||||||
bool operator==(const Genesys_Sensor& other) const
|
bool operator==(const Genesys_Sensor& other) const
|
||||||
{
|
{
|
||||||
return sensor_id == other.sensor_id &&
|
return sensor_id == other.sensor_id &&
|
||||||
|
|
|
@ -95,6 +95,21 @@ struct Genesys_Settings
|
||||||
|
|
||||||
// cache entries expiration time
|
// cache entries expiration time
|
||||||
int expiration_time = 0;
|
int expiration_time = 0;
|
||||||
|
|
||||||
|
unsigned get_channels() const
|
||||||
|
{
|
||||||
|
if (scan_mode == ScanColorMode::COLOR_SINGLE_PASS)
|
||||||
|
return 3;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned get_depth() const
|
||||||
|
{
|
||||||
|
if (scan_mode == ScanColorMode::LINEART)
|
||||||
|
return 1;
|
||||||
|
return depth;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SetupParams {
|
struct SetupParams {
|
||||||
|
|
Ładowanie…
Reference in New Issue