Merge branch 'genesys-remove-1bit-support' into 'master'

genesys: Remove support for scanning 1 bit output

See merge request sane-project/backends!212
merge-requests/214/merge
Povilas Kanapickas 2019-10-12 16:09:29 +00:00
commit a89ffe8f2c
15 zmienionych plików z 128 dodań i 362 usunięć

Wyświetl plik

@ -47,15 +47,6 @@
#include "conv.h"
#include "sane/sanei_magic.h"
void genesys_reverse_bits(uint8_t* src_data, uint8_t* dst_data, size_t bytes)
{
DBG_HELPER(dbg);
size_t i;
for(i = 0; i < bytes; i++) {
*dst_data++ = ~ *src_data++;
}
}
/**
* uses the threshold/threshold_curve to control software binarization
* This code was taken from the epjistsu backend by m. allan noah

Wyświetl plik

@ -48,8 +48,6 @@
#include "sensor.h"
#include "genesys.h"
void genesys_reverse_bits(uint8_t* src_data, uint8_t* dst_data, size_t bytes);
void binarize_line(Genesys_Device* dev, std::uint8_t* src, std::uint8_t* dst, int width);
void genesys_gray_lineart(Genesys_Device* dev,

Wyświetl plik

@ -3155,7 +3155,7 @@ static void genesys_start_scan(Genesys_Device* dev, bool lamp_off)
}
/* build look up table for dynamic lineart */
if (dev->settings.dynamic_lineart) {
if (dev->settings.scan_mode == ScanColorMode::LINEART) {
sanei_genesys_load_lut(dev->lineart_lut, 8, 8, 50, 205, dev->settings.threshold_curve,
dev->settings.threshold-127);
}
@ -3322,15 +3322,8 @@ Problems with the first approach:
bytes = *len;
work_buffer_src = src_buffer->get_read_pos();
if (dev->session.pipeline_needs_reverse) {
genesys_reverse_bits(work_buffer_src, destination, bytes);
*len = bytes;
}
else
{
memcpy (destination, work_buffer_src, bytes);
*len = bytes;
}
std::memcpy(destination, work_buffer_src, bytes);
*len = bytes;
/* avoid signaling some extra data because we have treated a full block
* on the last block */
@ -3552,23 +3545,6 @@ static void calc_parameters(Genesys_Scanner* s)
s->dev->settings.true_gray = 0;
}
/* dynamic lineart */
s->dev->settings.dynamic_lineart = false;
s->dev->settings.threshold_curve=0;
if (!s->disable_dynamic_lineart && s->dev->settings.scan_mode == ScanColorMode::LINEART) {
s->dev->settings.dynamic_lineart = true;
}
/* hardware lineart works only when we don't have interleave data
* for GL847 scanners, ie up to 600 DPI, then we have to rely on
* dynamic_lineart */
if (s->dev->settings.xres > 600 &&
s->dev->model->asic_type==AsicType::GL847 &&
s->dev->settings.scan_mode == ScanColorMode::LINEART)
{
s->dev->settings.dynamic_lineart = true;
}
// threshold curve for dynamic rasterization
s->dev->settings.threshold_curve = s->threshold_curve;
@ -4080,23 +4056,6 @@ static void init_options(Genesys_Scanner* s)
s->opt[OPT_THRESHOLD_CURVE].constraint.range = &threshold_curve_range;
s->threshold_curve = 50;
/* dynamic linart */
s->opt[OPT_DISABLE_DYNAMIC_LINEART].name = "disable-dynamic-lineart";
s->opt[OPT_DISABLE_DYNAMIC_LINEART].title = SANE_I18N ("Disable dynamic lineart");
s->opt[OPT_DISABLE_DYNAMIC_LINEART].desc =
SANE_I18N ("Disable use of a software adaptive algorithm to generate lineart relying instead on hardware lineart.");
s->opt[OPT_DISABLE_DYNAMIC_LINEART].type = SANE_TYPE_BOOL;
s->opt[OPT_DISABLE_DYNAMIC_LINEART].unit = SANE_UNIT_NONE;
s->opt[OPT_DISABLE_DYNAMIC_LINEART].constraint_type = SANE_CONSTRAINT_NONE;
s->disable_dynamic_lineart = false;
/* fastmod is required for hw lineart to work */
if ((s->dev->model->asic_type == AsicType::GL646) &&
(s->dev->model->motor_id != MotorId::XP200))
{
s->opt[OPT_DISABLE_DYNAMIC_LINEART].cap = SANE_CAP_INACTIVE;
}
/* disable_interpolation */
s->opt[OPT_DISABLE_INTERPOLATION].name = "disable-interpolation";
s->opt[OPT_DISABLE_INTERPOLATION].title =
@ -4616,7 +4575,7 @@ static void genesys_buffer_image(Genesys_Scanner *s)
/* maximum bytes to read */
maximum = s->params.bytes_per_line * lines;
if (s->dev->settings.dynamic_lineart) {
if (s->dev->settings.scan_mode == ScanColorMode::LINEART) {
maximum *= 8;
}
@ -4668,7 +4627,7 @@ static void genesys_buffer_image(Genesys_Scanner *s)
/* in case of dynamic lineart, we have buffered gray data which
* must be converted to lineart first */
if (s->dev->settings.dynamic_lineart) {
if (s->dev->settings.scan_mode == ScanColorMode::LINEART) {
total/=8;
std::vector<uint8_t> lineart(total);
@ -5084,9 +5043,6 @@ get_option_value (Genesys_Scanner * s, int option, void *val)
case OPT_THRESHOLD_CURVE:
*reinterpret_cast<SANE_Word*>(val) = s->threshold_curve;
break;
case OPT_DISABLE_DYNAMIC_LINEART:
*reinterpret_cast<SANE_Word*>(val) = s->disable_dynamic_lineart;
break;
case OPT_DISABLE_INTERPOLATION:
*reinterpret_cast<SANE_Word*>(val) = s->disable_interpolation;
break;
@ -5311,11 +5267,6 @@ set_option_value (Genesys_Scanner * s, int option, void *val,
calc_parameters(s);
*myinfo |= SANE_INFO_RELOAD_PARAMS;
break;
case OPT_DISABLE_DYNAMIC_LINEART:
s->disable_dynamic_lineart = *reinterpret_cast<SANE_Word*>(val);
calc_parameters(s);
*myinfo |= SANE_INFO_RELOAD_PARAMS;
break;
case OPT_SWCROP:
s->swcrop = *reinterpret_cast<SANE_Word*>(val);
calc_parameters(s);
@ -5450,13 +5401,11 @@ set_option_value (Genesys_Scanner * s, int option, void *val,
if (s->dev->model->asic_type != AsicType::GL646 || !s->dev->model->is_cis) {
ENABLE(OPT_COLOR_FILTER);
}
ENABLE (OPT_DISABLE_DYNAMIC_LINEART);
}
else
{
DISABLE (OPT_THRESHOLD);
DISABLE (OPT_THRESHOLD_CURVE);
DISABLE (OPT_DISABLE_DYNAMIC_LINEART);
if (s->mode == SANE_VALUE_SCAN_MODE_GRAY)
{
if (s->dev->model->asic_type != AsicType::GL646 || !s->dev->model->is_cis) {
@ -5785,7 +5734,7 @@ SANE_Status sane_start_impl(SANE_Handle handle)
s->scanning = true;
/* allocate intermediate buffer when doing dynamic lineart */
if (s->dev->settings.dynamic_lineart) {
if (s->dev->settings.scan_mode == ScanColorMode::LINEART) {
s->dev->binarize_buffer.clear();
s->dev->binarize_buffer.alloc(s->dev->settings.pixels);
s->dev->local_buffer.clear();
@ -5915,7 +5864,7 @@ sane_read_impl(SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int*
{
/* dynamic lineart is another kind of digital processing that needs
* another layer of buffering on top of genesys_read_ordered_data */
if (dev->settings.dynamic_lineart) {
if (dev->settings.scan_mode == ScanColorMode::LINEART) {
/* if buffer is empty, fill it with genesys_read_ordered_data */
if(dev->binarize_buffer.avail() == 0)
{

Wyświetl plik

@ -122,7 +122,6 @@ enum Genesys_Option
OPT_LAMP_OFF,
OPT_THRESHOLD,
OPT_THRESHOLD_CURVE,
OPT_DISABLE_DYNAMIC_LINEART,
OPT_DISABLE_INTERPOLATION,
OPT_COLOR_FILTER,
OPT_CALIBRATION_FILE,
@ -213,7 +212,6 @@ struct Genesys_Scanner
bool preview = false;
SANE_Word threshold = 0;
SANE_Word threshold_curve = 0;
bool disable_dynamic_lineart = false;
bool disable_interpolation = false;
bool lamp_off = false;
SANE_Word lamp_off_time = 0;

Wyświetl plik

@ -802,12 +802,7 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
/* monochrome / color scan */
r = sanei_genesys_get_address (reg, REG04);
switch (session.params.depth)
{
case 1:
r->value &= ~REG04_BITSET;
r->value |= REG04_LINEART;
break;
switch (session.params.depth) {
case 8:
r->value &= ~(REG04_LINEART | REG04_BITSET);
break;
@ -907,12 +902,6 @@ static void gl124_compute_session(Genesys_Device* dev, ScanSession& s,
{
DBG_HELPER(dbg);
/* in case of dynamic lineart, we use an internal 8 bit gray scan
* to generate 1 lineart data */
if (s.params.flags & SCAN_FLAG_DYNAMIC_LINEART) {
s.params.depth = 8;
}
compute_session(dev, s, sensor);
s.enable_ledadd = (s.params.channels == 1 && dev->model->is_cis && dev->settings.true_gray);
@ -1032,7 +1021,7 @@ void CommandSetGl124::calculate_current_setup(Genesys_Device * dev,
session.params.pixels = dev->settings.pixels;
session.params.requested_pixels = dev->settings.requested_pixels;
session.params.lines = dev->settings.lines;
session.params.depth = dev->settings.get_depth();
session.params.depth = dev->settings.depth;
session.params.channels = dev->settings.get_channels();
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = dev->settings.scan_mode;
@ -1685,7 +1674,6 @@ void CommandSetGl124::wait_for_motor_stop(Genesys_Device* dev) const
void CommandSetGl124::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor) const
{
DBG_HELPER(dbg);
int flags;
float move;
int move_dpi;
float start;
@ -1711,15 +1699,6 @@ void CommandSetGl124::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sens
start /= sensor.get_ccd_size_divisor_for_dpi(dev->settings.xres);
start = (start * sensor.optical_res) / MM_PER_INCH;
flags = 0;
/* enable emulated lineart from gray data */
if(dev->settings.scan_mode == ScanColorMode::LINEART
&& dev->settings.dynamic_lineart)
{
flags |= SCAN_FLAG_DYNAMIC_LINEART;
}
ScanSession session;
session.params.xres = dev->settings.xres;
session.params.yres = dev->settings.yres;
@ -1728,12 +1707,12 @@ void CommandSetGl124::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sens
session.params.pixels = dev->settings.pixels;
session.params.requested_pixels = dev->settings.requested_pixels;
session.params.lines = dev->settings.lines;
session.params.depth = dev->settings.get_depth();
session.params.depth = dev->settings.depth;
session.params.channels = dev->settings.get_channels();
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = dev->settings.scan_mode;
session.params.color_filter = dev->settings.color_filter;
session.params.flags = flags;
session.params.flags = 0;
gl124_compute_session(dev, session, sensor);
gl124_init_scan_regs(dev, sensor, &dev->reg, session);
@ -1922,7 +1901,7 @@ SensorExposure CommandSetGl124::led_calibration(Genesys_Device* dev, const Genes
int dpihw;
int i, j;
int val;
int channels, depth;
int channels;
int avg[3];
int turn;
uint16_t exp[3],target;
@ -1932,7 +1911,6 @@ SensorExposure CommandSetGl124::led_calibration(Genesys_Device* dev, const Genes
/* offset calibration is always done in 16 bit depth color mode */
channels = 3;
depth=16;
dpihw = sensor.get_register_hwdpi(dev->settings.xres);
resolution = dpihw;
unsigned ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(dev->settings.xres);
@ -1952,7 +1930,7 @@ SensorExposure CommandSetGl124::led_calibration(Genesys_Device* dev, const Genes
session.params.starty = 0;
session.params.pixels = num_pixels;
session.params.lines = 1;
session.params.depth = depth;
session.params.depth = 16;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
@ -1965,7 +1943,7 @@ SensorExposure CommandSetGl124::led_calibration(Genesys_Device* dev, const Genes
gl124_init_scan_regs(dev, sensor, &regs, session);
total_size = num_pixels * channels * (depth/8) * 1; /* colors * bytes_per_color * scan lines */
total_size = num_pixels * channels * (session.params.depth / 8) * 1;
std::vector<uint8_t> line(total_size);
// initial loop values and boundaries
@ -2000,7 +1978,8 @@ SensorExposure CommandSetGl124::led_calibration(Genesys_Device* dev, const Genes
{
char fn[30];
snprintf(fn, 30, "gl124_led_%02d.pnm", turn);
sanei_genesys_write_pnm_file(fn, line.data(), depth, channels, num_pixels, 1);
sanei_genesys_write_pnm_file(fn, line.data(), session.params.depth, channels, num_pixels,
1);
}
/* compute average */
@ -2093,7 +2072,7 @@ void CommandSetGl124::offset_calibration(Genesys_Device* dev, const Genesys_Sens
Genesys_Register_Set& regs) const
{
DBG_HELPER(dbg);
unsigned int channels, bpp;
unsigned channels;
int pass = 0, avg, total_size;
int topavg, bottomavg, lines;
int top, bottom, black_pixels, pixels;
@ -2109,7 +2088,6 @@ void CommandSetGl124::offset_calibration(Genesys_Device* dev, const Genesys_Sens
channels = 3;
dev->calib_pixels = sensor.sensor_pixels;
lines=1;
bpp=8;
pixels = (sensor.sensor_pixels * sensor.optical_res) / sensor.optical_res;
black_pixels = (sensor.black_pixels * sensor.optical_res) / sensor.optical_res;
DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels);
@ -2121,7 +2099,7 @@ void CommandSetGl124::offset_calibration(Genesys_Device* dev, const Genesys_Sens
session.params.starty = 0;
session.params.pixels = pixels;
session.params.lines = lines;
session.params.depth = bpp;
session.params.depth = 8;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
@ -2137,7 +2115,7 @@ void CommandSetGl124::offset_calibration(Genesys_Device* dev, const Genesys_Sens
sanei_genesys_set_motor_power(regs, false);
/* allocate memory for scans */
total_size = pixels * channels * lines * (bpp/8); /* colors * bytes_per_color * scan lines */
total_size = pixels * channels * lines * (session.params.depth / 8);
std::vector<uint8_t> first_line(total_size);
std::vector<uint8_t> second_line(total_size);
@ -2162,7 +2140,8 @@ void CommandSetGl124::offset_calibration(Genesys_Device* dev, const Genesys_Sens
{
char title[30];
snprintf(title, 30, "gl124_offset%03d.pnm", bottom);
sanei_genesys_write_pnm_file(title, first_line.data(), bpp, channels, pixels, lines);
sanei_genesys_write_pnm_file(title, first_line.data(), session.params.depth,
channels, pixels, lines);
}
bottomavg = dark_average(first_line.data(), pixels, lines, channels, black_pixels);
@ -2203,7 +2182,8 @@ void CommandSetGl124::offset_calibration(Genesys_Device* dev, const Genesys_Sens
{
char title[30];
snprintf(title, 30, "gl124_offset%03d.pnm", dev->frontend.get_offset(1));
sanei_genesys_write_pnm_file(title, second_line.data(), bpp, channels, pixels, lines);
sanei_genesys_write_pnm_file(title, second_line.data(), session.params.depth,
channels, pixels, lines);
}
avg = dark_average(second_line.data(), pixels, lines, channels, black_pixels);
@ -2247,7 +2227,6 @@ void CommandSetGl124::coarse_gain_calibration(Genesys_Device* dev, const Genesys
int max[3];
float gain[3],coeff;
int val, code, lines;
int bpp;
// no gain nor offset for TI AFE
uint8_t reg0a = dev->read_register(REG0A);
@ -2266,7 +2245,6 @@ void CommandSetGl124::coarse_gain_calibration(Genesys_Device* dev, const Genesys
coeff=1.0;
}
lines=10;
bpp=8;
pixels = (sensor.sensor_pixels * sensor.optical_res) / sensor.optical_res;
ScanSession session;
@ -2276,7 +2254,7 @@ void CommandSetGl124::coarse_gain_calibration(Genesys_Device* dev, const Genesys
session.params.starty = 0;
session.params.pixels = pixels;
session.params.lines = lines;
session.params.depth = bpp;
session.params.depth = 8;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
@ -2298,7 +2276,7 @@ void CommandSetGl124::coarse_gain_calibration(Genesys_Device* dev, const Genesys
dev->write_registers(regs);
total_size = pixels * channels * (16/bpp) * lines;
total_size = pixels * channels * (16 / session.params.depth) * lines;
std::vector<uint8_t> line(total_size);
@ -2306,8 +2284,10 @@ void CommandSetGl124::coarse_gain_calibration(Genesys_Device* dev, const Genesys
begin_scan(dev, sensor, &regs, true);
sanei_genesys_read_data_from_scanner(dev, line.data(), total_size);
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file("gl124_gain.pnm", line.data(), bpp, channels, pixels, lines);
if (DBG_LEVEL >= DBG_data) {
sanei_genesys_write_pnm_file("gl124_gain.pnm", line.data(), session.params.depth,
channels, pixels, lines);
}
/* average value on each channel */
for (j = 0; j < channels; j++)
@ -2315,23 +2295,10 @@ void CommandSetGl124::coarse_gain_calibration(Genesys_Device* dev, const Genesys
max[j] = 0;
for (i = pixels/4; i < (pixels*3/4); i++)
{
if(bpp==16)
{
if (dev->model->is_cis)
val =
line[i * 2 + j * 2 * pixels + 1] * 256 +
line[i * 2 + j * 2 * pixels];
else
val =
line[i * 2 * channels + 2 * j + 1] * 256 +
line[i * 2 * channels + 2 * j];
}
else
{
if (dev->model->is_cis)
val = line[i + j * pixels];
else
val = line[i * channels + j];
if (dev->model->is_cis) {
val = line[i + j * pixels];
} else {
val = line[i * channels + j];
}
max[j] += val;

Wyświetl plik

@ -405,10 +405,6 @@ static void gl646_setup_registers(Genesys_Device* dev,
/* R04 */
/* monochrome / color scan */
switch (session.params.depth) {
case 1:
regs->find_reg(0x04).value &= ~REG04_BITSET;
regs->find_reg(0x04).value |= REG04_LINEART;
break;
case 8:
regs->find_reg(0x04).value &= ~(REG04_LINEART | REG04_BITSET);
break;
@ -1717,7 +1713,6 @@ void CommandSetGl646::slow_back_home(Genesys_Device* dev, bool wait_until_home)
settings.disable_interpolation = 0;
settings.threshold = 0;
settings.dynamic_lineart = false;
const auto& sensor = sanei_genesys_find_sensor(dev, settings.xres, 3,
dev->model->default_method);
@ -1811,7 +1806,6 @@ void CommandSetGl646::search_start_position(Genesys_Device* dev) const
settings.disable_interpolation = 0;
settings.threshold = 0;
settings.dynamic_lineart = false;
// scan the desired area
std::vector<uint8_t> data;
@ -1908,7 +1902,6 @@ void CommandSetGl646::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
settings.disable_interpolation = dev->settings.disable_interpolation;
settings.threshold = dev->settings.threshold;
settings.dynamic_lineart = false;
/* keep account of the movement for final scan move */
dev->scanhead_position_in_steps += settings.lines;
@ -1993,23 +1986,9 @@ static void setup_for_scan(Genesys_Device* dev,
bool ycorrection)
{
DBG_HELPER(dbg);
SANE_Int depth;
debug_dump(DBG_info, dev->settings);
depth=settings.depth;
if (settings.scan_mode == ScanColorMode::LINEART)
{
if (settings.dynamic_lineart) {
depth = 8;
}
else
{
/* XXX STEF XXX : why does the common layer never send depth=1 ? */
depth = 1;
}
}
// compute distance to move
float move = 0;
// XXX STEF XXX MD5345 -> optical_ydpi, other base_ydpi => half/full step ? */
@ -2049,7 +2028,7 @@ static void setup_for_scan(Genesys_Device* dev,
session.params.pixels = settings.pixels;
session.params.requested_pixels = settings.requested_pixels;
session.params.lines = settings.lines;
session.params.depth = depth;
session.params.depth = settings.depth;
session.params.channels = settings.get_channels();
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = settings.scan_mode;
@ -2170,7 +2149,6 @@ SensorExposure CommandSetGl646::led_calibration(Genesys_Device* dev, const Genes
settings.disable_interpolation = 0;
settings.threshold = 0;
settings.dynamic_lineart = false;
/* colors * bytes_per_color * scan lines */
total_size = settings.pixels * channels * 2 * 1;
@ -2341,7 +2319,6 @@ static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
settings.disable_interpolation = 0;
settings.threshold = 0;
settings.dynamic_lineart = false;
/* scan first line of data with no gain */
dev->frontend.set_gain(0, 0);
@ -2449,7 +2426,6 @@ void CommandSetGl646::offset_calibration(Genesys_Device* dev, const Genesys_Sens
settings.disable_interpolation = 0;
settings.threshold = 0;
settings.dynamic_lineart = false;
/* scan first line of data with no gain, but with offset from
* last calibration */
@ -2579,7 +2555,6 @@ static void ad_fe_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen
settings.disable_interpolation = 0;
settings.threshold = 0;
settings.dynamic_lineart = false;
size = channels * settings.pixels * settings.lines;
@ -2692,7 +2667,6 @@ void CommandSetGl646::coarse_gain_calibration(Genesys_Device* dev, const Genesys
settings.disable_interpolation = 0;
settings.threshold = 0;
settings.dynamic_lineart = false;
/* start gain value */
dev->frontend.set_gain(0, 1);
@ -2835,7 +2809,6 @@ void CommandSetGl646::init_regs_for_warmup(Genesys_Device* dev, const Genesys_Se
settings.disable_interpolation = 0;
settings.threshold = 0;
settings.dynamic_lineart = false;
// setup for scan
setup_for_scan(dev, local_sensor, &dev->reg, settings, true, false, false);
@ -2888,7 +2861,6 @@ static void gl646_repark_head(Genesys_Device* dev)
settings.disable_interpolation = 0;
settings.threshold = 0;
settings.dynamic_lineart = false;
const auto& sensor = sanei_genesys_find_sensor(dev, settings.xres, 3,
dev->model->default_method);
@ -3256,7 +3228,6 @@ static void simple_move(Genesys_Device* dev, SANE_Int distance)
settings.disable_interpolation = 0;
settings.threshold = 0;
settings.dynamic_lineart = false;
std::vector<uint8_t> data;
simple_scan(dev, sensor, settings, true, true, false, data);
@ -3552,7 +3523,6 @@ void CommandSetGl646::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
settings.disable_interpolation = 0;
settings.threshold = 0;
settings.dynamic_lineart = false;
/* signals if a strip of the given color has been found */
found = 0;

Wyświetl plik

@ -1442,10 +1442,6 @@ static void gl841_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
/* monochrome / color scan */
r = sanei_genesys_get_address (reg, 0x04);
switch (session.params.depth) {
case 1:
r->value &= ~REG04_BITSET;
r->value |= REG04_LINEART;
break;
case 8:
r->value &= ~(REG04_LINEART | REG04_BITSET);
break;
@ -1622,11 +1618,6 @@ static void gl841_compute_session(Genesys_Device* dev, ScanSession& s,
{
DBG_HELPER(dbg);
//in case of dynamic lineart, we use an internal 8 bit gray scan to generate 1 lineart data
if (s.params.flags & SCAN_FLAG_DYNAMIC_LINEART) {
s.params.depth = 8;
}
// no 16 bit gamma for this ASIC
if (s.params.depth == 16) {
s.params.flags |= SCAN_FLAG_DISABLE_GAMMA;
@ -1822,7 +1813,7 @@ void CommandSetGl841::calculate_current_setup(Genesys_Device * dev,
session.params.pixels = dev->settings.pixels;
session.params.requested_pixels = dev->settings.requested_pixels;
session.params.lines = dev->settings.lines;
session.params.depth = dev->settings.get_depth();
session.params.depth = dev->settings.depth;
session.params.channels = dev->settings.get_channels();
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = dev->settings.scan_mode;
@ -2759,8 +2750,6 @@ void CommandSetGl841::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sens
start = (start * sensor.optical_res) / MM_PER_INCH;
flags=0;
/* we enable true gray for cis scanners only, and just when doing
* scan since color calibration is OK for this mode
*/
@ -2776,13 +2765,6 @@ void CommandSetGl841::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sens
flags |= SCAN_FLAG_ENABLE_LEDADD;
}
/* enable emulated lineart from gray data */
if(dev->settings.scan_mode == ScanColorMode::LINEART
&& dev->settings.dynamic_lineart)
{
flags |= SCAN_FLAG_DYNAMIC_LINEART;
}
ScanSession session;
session.params.xres = dev->settings.xres;
session.params.yres = dev->settings.yres;
@ -2791,7 +2773,7 @@ void CommandSetGl841::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sens
session.params.pixels = dev->settings.pixels;
session.params.requested_pixels = dev->settings.requested_pixels;
session.params.lines = dev->settings.lines;
session.params.depth = dev->settings.get_depth();
session.params.depth = dev->settings.depth;
session.params.channels = dev->settings.get_channels();
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = dev->settings.scan_mode;
@ -3952,7 +3934,6 @@ void CommandSetGl841::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
unsigned int pixels, lines, channels;
Genesys_Register_Set local_reg;
size_t size;
int depth;
unsigned int pass, count, found, x, y, length;
char title[80];
GenesysRegister *r;
@ -3980,10 +3961,7 @@ void CommandSetGl841::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
/* lines = (dev->model->shading_lines * dpi) / dev->motor.base_ydpi; */
lines = (10*dpi)/MM_PER_INCH;
depth = 8;
pixels = (sensor.sensor_pixels * dpi) / sensor.optical_res;
size = pixels * channels * lines * (depth / 8);
std::vector<uint8_t> data(size);
/* 20 cm max length for calibration sheet */
length = ((200 * dpi) / MM_PER_INCH)/lines;
@ -3999,7 +3977,7 @@ void CommandSetGl841::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
session.params.starty = 0;
session.params.pixels = pixels;
session.params.lines = lines;
session.params.depth = depth;
session.params.depth = 8;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::GRAY;
@ -4007,6 +3985,9 @@ void CommandSetGl841::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
session.params.flags = SCAN_FLAG_DISABLE_SHADING | SCAN_FLAG_DISABLE_GAMMA;
gl841_compute_session(dev, session, sensor);
size = pixels * channels * lines * (session.params.depth / 8);
std::vector<uint8_t> data(size);
gl841_init_scan_regs(dev, sensor, &local_reg, session);
/* set up for reverse or forward */
@ -4034,7 +4015,8 @@ void CommandSetGl841::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
{
sprintf(title, "gl841_search_strip_%s_%s%02u.pnm", black ? "black" : "white",
forward ? "fwd" : "bwd", pass);
sanei_genesys_write_pnm_file(title, data.data(), depth, channels, pixels, lines);
sanei_genesys_write_pnm_file(title, data.data(), session.params.depth,
channels, pixels, lines);
}
/* loop until strip is found or maximum pass number done */
@ -4058,7 +4040,8 @@ void CommandSetGl841::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
{
sprintf(title, "gl841_search_strip_%s_%s%02u.pnm",
black ? "black" : "white", forward ? "fwd" : "bwd", pass);
sanei_genesys_write_pnm_file(title, data.data(), depth, channels, pixels, lines);
sanei_genesys_write_pnm_file(title, data.data(), session.params.depth,
channels, pixels, lines);
}
/* search data to find black strip */

Wyświetl plik

@ -1123,12 +1123,7 @@ static void gl843_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
/* monochrome / color scan */
r = sanei_genesys_get_address (reg, REG04);
switch (session.params.depth)
{
case 1:
r->value &= ~REG04_BITSET;
r->value |= REG04_LINEART;
break;
switch (session.params.depth) {
case 8:
r->value &= ~(REG04_LINEART | REG04_BITSET);
break;
@ -1207,11 +1202,6 @@ static void gl843_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
static void gl843_compute_session(Genesys_Device* dev, ScanSession& s,
const Genesys_Sensor& sensor)
{
// in case of dynamic lineart, we use an internal 8 bit gray scan to generate 1 lineart data
if (s.params.flags & SCAN_FLAG_DYNAMIC_LINEART) {
s.params.depth = 8;
}
// no 16 bit gamma for this ASIC
if (s.params.depth == 16) {
s.params.flags |= SCAN_FLAG_DISABLE_GAMMA;
@ -1363,7 +1353,7 @@ void CommandSetGl843::calculate_current_setup(Genesys_Device * dev,
session.params.pixels = dev->settings.pixels;
session.params.requested_pixels = dev->settings.requested_pixels;
session.params.lines = dev->settings.lines;
session.params.depth = dev->settings.get_depth();
session.params.depth = dev->settings.depth;
session.params.channels = dev->settings.get_channels();
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = dev->settings.scan_mode;
@ -2381,13 +2371,6 @@ void CommandSetGl843::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sens
start += dev->settings.tl_x;
start = (start * sensor.optical_res) / MM_PER_INCH;
/* enable emulated lineart from gray data */
if(dev->settings.scan_mode == ScanColorMode::LINEART
&& dev->settings.dynamic_lineart)
{
flags |= SCAN_FLAG_DYNAMIC_LINEART;
}
ScanSession session;
session.params.xres = dev->settings.xres;
session.params.yres = dev->settings.yres;
@ -2396,7 +2379,7 @@ void CommandSetGl843::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sens
session.params.pixels = dev->settings.pixels;
session.params.requested_pixels = dev->settings.requested_pixels;
session.params.lines = dev->settings.lines;
session.params.depth = dev->settings.get_depth();
session.params.depth = dev->settings.depth;
session.params.channels = dev->settings.get_channels();
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = dev->settings.scan_mode;
@ -2452,14 +2435,12 @@ SensorExposure CommandSetGl843::led_calibration(Genesys_Device* dev, const Genes
{
DBG_HELPER(dbg);
int num_pixels;
int depth;
int avg[3], avga, avge;
int turn;
uint16_t expr, expg, expb;
// offset calibration is always done in color mode
unsigned channels = 3;
depth = 16;
// take a copy, as we're going to modify exposure
auto calib_sensor = sanei_genesys_find_sensor(dev, sensor.optical_res, channels,
@ -2477,7 +2458,7 @@ SensorExposure CommandSetGl843::led_calibration(Genesys_Device* dev, const Genes
session.params.starty = 0;
session.params.pixels = num_pixels;
session.params.lines = 1;
session.params.depth = depth;
session.params.depth = 16;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
@ -2640,7 +2621,7 @@ void CommandSetGl843::offset_calibration(Genesys_Device* dev, const Genesys_Sens
if (dev->frontend.layout.type != FrontendType::WOLFSON)
return;
unsigned int channels, bpp;
unsigned channels;
int pass, resolution, lines;
int topavg[3], bottomavg[3], avg[3];
int top[3], bottom[3], black_pixels, pixels, factor, dpihw;
@ -2648,7 +2629,6 @@ void CommandSetGl843::offset_calibration(Genesys_Device* dev, const Genesys_Sens
/* offset calibration is always done in color mode */
channels = 3;
lines = 8;
bpp = 8;
// compute divider factor to compute final pixels number
dpihw = sensor.get_logical_hwdpi(dev->settings.xres);
@ -2694,7 +2674,7 @@ void CommandSetGl843::offset_calibration(Genesys_Device* dev, const Genesys_Sens
session.params.starty = 0;
session.params.pixels = target_pixels;
session.params.lines = lines;
session.params.depth = bpp;
session.params.depth = 8;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
@ -2832,7 +2812,8 @@ void CommandSetGl843::offset_calibration(Genesys_Device* dev, const Genesys_Sens
reinterpret_cast<const std::uint8_t*>(debug_image_info.data()),
debug_image_info.size());
sanei_genesys_write_pnm_file("gl843_offset_all.pnm",
debug_image.data(), bpp, channels, pixels, debug_image_lines);
debug_image.data(), session.params.depth, channels, pixels,
debug_image_lines);
}
DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__,
@ -2859,7 +2840,6 @@ void CommandSetGl843::coarse_gain_calibration(Genesys_Device* dev, const Genesys
float coeff;
int lines;
int resolution;
int bpp;
if (dev->frontend.layout.type != FrontendType::WOLFSON)
return;
@ -2887,7 +2867,6 @@ void CommandSetGl843::coarse_gain_calibration(Genesys_Device* dev, const Genesys
}
resolution=dpihw;
lines=10;
bpp=8;
int target_pixels = sensor.sensor_pixels / factor;
int flags = SCAN_FLAG_DISABLE_SHADING |
@ -2911,7 +2890,7 @@ void CommandSetGl843::coarse_gain_calibration(Genesys_Device* dev, const Genesys
session.params.starty = 0;
session.params.pixels = target_pixels;
session.params.lines = lines;
session.params.depth = bpp;
session.params.depth = 8;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
@ -2954,9 +2933,6 @@ void CommandSetGl843::coarse_gain_calibration(Genesys_Device* dev, const Genesys
// in transparency scans for example
std::sort(values.begin(), values.end());
uint16_t curr_output = values[unsigned((values.size() - 1) * 0.95)];
if (bpp == 16) {
curr_output /= 256;
}
float target_value = calib_sensor.gain_white_ref * coeff;
int code = compute_frontend_gain(curr_output, target_value, dev->frontend.layout.type);
@ -3233,7 +3209,7 @@ void CommandSetGl843::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
DBG_HELPER_ARGS(dbg, "%s %s", black ? "black" : "white", forward ? "forward" : "reverse");
unsigned int pixels, lines, channels;
Genesys_Register_Set local_reg;
int depth, dpi;
int dpi;
unsigned int pass, count, found, x, y;
GenesysRegister *r;
@ -3251,7 +3227,6 @@ void CommandSetGl843::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
/* lines = (10 * dpi) / MM_PER_INCH; */
/* shading calibation is done with dev->motor.base_ydpi */
lines = (dev->model->shading_lines * dpi) / dev->motor.base_ydpi;
depth = 8;
pixels = (calib_sensor.sensor_pixels * dpi) / calib_sensor.optical_res;
dev->scanhead_position_in_steps = 0;
@ -3265,7 +3240,7 @@ void CommandSetGl843::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
session.params.starty = 0;
session.params.pixels = pixels;
session.params.lines = lines;
session.params.depth = depth;
session.params.depth = 8;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::GRAY;

Wyświetl plik

@ -59,7 +59,6 @@
#define SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE 0x008
#define SCAN_FLAG_IGNORE_LINE_DISTANCE 0x010
#define SCAN_FLAG_DISABLE_LAMP 0x040
#define SCAN_FLAG_DYNAMIC_LINEART 0x080
#define SETREG(adr,val) { dev->reg.init_reg(adr, val); }

Wyświetl plik

@ -668,12 +668,7 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
/* monochrome / color scan */
r = sanei_genesys_get_address (reg, REG04);
switch (session.params.depth)
{
case 1:
r->value &= ~REG04_BITSET;
r->value |= REG04_LINEART;
break;
switch (session.params.depth) {
case 8:
r->value &= ~(REG04_LINEART | REG04_BITSET);
break;
@ -756,11 +751,6 @@ static void gl846_compute_session(Genesys_Device* dev, ScanSession& s,
{
DBG_HELPER(dbg);
// in case of dynamic lineart, we use an internal 8 bit gray scan to generate 1 lineart data
if (s.params.flags & SCAN_FLAG_DYNAMIC_LINEART) {
s.params.depth = 8;
}
compute_session(dev, s, sensor);
s.enable_ledadd = (s.params.channels == 1 && dev->model->is_cis && dev->settings.true_gray);
@ -881,7 +871,7 @@ void CommandSetGl846::calculate_current_setup(Genesys_Device* dev,
session.params.pixels = dev->settings.pixels;
session.params.requested_pixels = dev->settings.requested_pixels;
session.params.lines = dev->settings.lines;
session.params.depth = dev->settings.get_depth();
session.params.depth = dev->settings.depth;
session.params.channels = dev->settings.get_channels();
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = dev->settings.scan_mode;
@ -1406,7 +1396,6 @@ void CommandSetGl846::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
void CommandSetGl846::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor) const
{
DBG_HELPER(dbg);
int flags;
float move;
int move_dpi;
float start;
@ -1459,18 +1448,6 @@ void CommandSetGl846::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sens
start += dev->settings.tl_x;
start = (start * sensor.optical_res) / MM_PER_INCH;
flags = 0;
/* emulated lineart from gray data is required for now */
if(dev->settings.scan_mode == ScanColorMode::LINEART
&& dev->settings.dynamic_lineart)
{
flags |= SCAN_FLAG_DYNAMIC_LINEART;
}
/* backtracking isn't handled well, so don't enable it */
flags |= SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE;
ScanSession session;
session.params.xres = dev->settings.xres;
session.params.yres = dev->settings.yres;
@ -1479,12 +1456,13 @@ void CommandSetGl846::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sens
session.params.pixels = dev->settings.pixels;
session.params.requested_pixels = dev->settings.requested_pixels;
session.params.lines = dev->settings.lines;
session.params.depth = dev->settings.get_depth();
session.params.depth = dev->settings.depth;
session.params.channels = dev->settings.get_channels();
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = dev->settings.scan_mode;
session.params.color_filter = dev->settings.color_filter;
session.params.flags = flags;
// backtracking isn't handled well, so don't enable it
session.params.flags = SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE;
gl846_compute_session(dev, session, sensor);
gl846_init_scan_regs(dev, sensor, &dev->reg, session);
@ -1589,7 +1567,7 @@ SensorExposure CommandSetGl846::led_calibration(Genesys_Device* dev, const Genes
int used_res;
int i, j;
int val;
int channels, depth;
int channels;
int avg[3], top[3], bottom[3];
int turn;
uint16_t exp[3];
@ -1605,7 +1583,6 @@ SensorExposure CommandSetGl846::led_calibration(Genesys_Device* dev, const Genes
/* offset calibration is always done in color mode */
channels = 3;
depth=16;
used_res = sensor.get_register_hwdpi(dev->settings.xres);
const auto& sensor_profile = get_sensor_profile(dev->model->asic_type, sensor, used_res, 1);
num_pixels = (sensor.sensor_pixels*used_res)/sensor.optical_res;
@ -1620,7 +1597,7 @@ SensorExposure CommandSetGl846::led_calibration(Genesys_Device* dev, const Genes
session.params.starty = 0;
session.params.pixels = num_pixels;
session.params.lines = 1;
session.params.depth = depth;
session.params.depth = 16;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
@ -1633,7 +1610,7 @@ SensorExposure CommandSetGl846::led_calibration(Genesys_Device* dev, const Genes
gl846_init_scan_regs(dev, sensor, &regs, session);
total_size = num_pixels * channels * (depth/8) * 1; /* colors * bytes_per_color * scan lines */
total_size = num_pixels * channels * (session.params.depth / 8) * 1;
std::vector<uint8_t> line(total_size);
/* initial loop values and boundaries */
@ -1675,7 +1652,8 @@ SensorExposure CommandSetGl846::led_calibration(Genesys_Device* dev, const Genes
{
char fn[30];
snprintf(fn, 30, "gl846_led_%02d.pnm", turn);
sanei_genesys_write_pnm_file(fn, line.data(), depth, channels, num_pixels, 1);
sanei_genesys_write_pnm_file(fn, line.data(), session.params.depth,
channels, num_pixels, 1);
}
/* compute average */
@ -1916,7 +1894,6 @@ void CommandSetGl846::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
unsigned int pixels, lines, channels;
Genesys_Register_Set local_reg;
size_t size;
int depth;
unsigned int pass, count, found, x, y;
char title[80];
GenesysRegister *r;
@ -1933,10 +1910,7 @@ void CommandSetGl846::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
/* lines = (10 * dpi) / MM_PER_INCH; */
/* shading calibation is done with dev->motor.base_ydpi */
lines = (dev->model->shading_lines * dpi) / dev->motor.base_ydpi;
depth = 8;
pixels = (sensor.sensor_pixels * dpi) / sensor.optical_res;
size = pixels * channels * lines * (depth / 8);
std::vector<uint8_t> data(size);
dev->scanhead_position_in_steps = 0;
@ -1949,7 +1923,7 @@ void CommandSetGl846::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
session.params.starty = 0;
session.params.pixels = pixels;
session.params.lines = lines;
session.params.depth = depth;
session.params.depth = 8;
session.params.channels = channels;
session.params.scan_mode = ScanColorMode::GRAY;
session.params.color_filter = ColorFilter::RED;
@ -1959,6 +1933,9 @@ void CommandSetGl846::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
gl846_init_scan_regs(dev, sensor, &local_reg, session);
size = pixels * channels * lines * (session.params.depth / 8);
std::vector<uint8_t> data(size);
/* set up for reverse or forward */
r = sanei_genesys_get_address (&local_reg, REG02);
if (forward) {
@ -1983,7 +1960,8 @@ void CommandSetGl846::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
{
std::sprintf(title, "gl846_search_strip_%s_%s%02d.pnm",
black ? "black" : "white", forward ? "fwd" : "bwd", pass);
sanei_genesys_write_pnm_file(title, data.data(), depth, channels, pixels, lines);
sanei_genesys_write_pnm_file(title, data.data(), session.params.depth,
channels, pixels, lines);
}
/* loop until strip is found or maximum pass number done */
@ -2006,7 +1984,8 @@ void CommandSetGl846::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
{
std::sprintf(title, "gl846_search_strip_%s_%s%02d.pnm",
black ? "black" : "white", forward ? "fwd" : "bwd", pass);
sanei_genesys_write_pnm_file(title, data.data(), depth, channels, pixels, lines);
sanei_genesys_write_pnm_file(title, data.data(), session.params.depth,
channels, pixels, lines);
}
/* search data to find black strip */
@ -2138,7 +2117,7 @@ void CommandSetGl846::offset_calibration(Genesys_Device* dev, const Genesys_Sens
Genesys_Register_Set& regs) const
{
DBG_HELPER(dbg);
unsigned int channels, bpp;
unsigned channels;
int pass = 0, avg, total_size;
int topavg, bottomavg, lines;
int top, bottom, black_pixels, pixels;
@ -2154,7 +2133,6 @@ void CommandSetGl846::offset_calibration(Genesys_Device* dev, const Genesys_Sens
channels = 3;
dev->calib_pixels = sensor.sensor_pixels;
lines=1;
bpp=8;
pixels = (sensor.sensor_pixels * sensor.optical_res) / sensor.optical_res;
black_pixels = (sensor.black_pixels * sensor.optical_res) / sensor.optical_res;
DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels);
@ -2166,7 +2144,7 @@ void CommandSetGl846::offset_calibration(Genesys_Device* dev, const Genesys_Sens
session.params.starty = 0;
session.params.pixels = pixels;
session.params.lines = lines;
session.params.depth = bpp;
session.params.depth = 8;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
@ -2181,8 +2159,7 @@ void CommandSetGl846::offset_calibration(Genesys_Device* dev, const Genesys_Sens
sanei_genesys_set_motor_power(regs, false);
/* allocate memory for scans */
total_size = pixels * channels * lines * (bpp/8); /* colors * bytes_per_color * scan lines */
total_size = pixels * channels * lines * (session.params.depth / 8);
std::vector<uint8_t> first_line(total_size);
std::vector<uint8_t> second_line(total_size);
@ -2207,7 +2184,8 @@ void CommandSetGl846::offset_calibration(Genesys_Device* dev, const Genesys_Sens
{
char fn[30];
snprintf(fn, 30, "gl846_offset%03d.pnm", bottom);
sanei_genesys_write_pnm_file(fn, first_line.data(), bpp, channels, pixels, lines);
sanei_genesys_write_pnm_file(fn, first_line.data(), session.params.depth,
channels, pixels, lines);
}
bottomavg = dark_average(first_line.data(), pixels, lines, channels, black_pixels);
@ -2248,7 +2226,8 @@ void CommandSetGl846::offset_calibration(Genesys_Device* dev, const Genesys_Sens
{
char fn[30];
snprintf(fn, 30, "gl846_offset%03d.pnm", dev->frontend.get_offset(1));
sanei_genesys_write_pnm_file(fn, second_line.data(), bpp, channels, pixels, lines);
sanei_genesys_write_pnm_file(fn, second_line.data(), session.params.depth,
channels, pixels, lines);
}
avg = dark_average(second_line.data(), pixels, lines, channels, black_pixels);
@ -2282,7 +2261,6 @@ void CommandSetGl846::coarse_gain_calibration(Genesys_Device* dev, const Genesys
int max[3];
float gain[3],coeff;
int val, code, lines;
int bpp;
DBG(DBG_proc, "%s: dpi = %d\n", __func__, dpi);
@ -2306,7 +2284,6 @@ void CommandSetGl846::coarse_gain_calibration(Genesys_Device* dev, const Genesys
coeff=1.0;
}
lines=10;
bpp=8;
pixels = (sensor.sensor_pixels * sensor.optical_res) / sensor.optical_res;
ScanSession session;
@ -2316,7 +2293,7 @@ void CommandSetGl846::coarse_gain_calibration(Genesys_Device* dev, const Genesys
session.params.starty = 0;
session.params.pixels = pixels;
session.params.lines = lines;
session.params.depth = bpp;
session.params.depth = 8;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
@ -2338,7 +2315,7 @@ void CommandSetGl846::coarse_gain_calibration(Genesys_Device* dev, const Genesys
dev->write_registers(regs);
total_size = pixels * channels * (16/bpp) * lines;
total_size = pixels * channels * (16 / session.params.depth) * lines;
std::vector<uint8_t> line(total_size);
@ -2346,8 +2323,10 @@ void CommandSetGl846::coarse_gain_calibration(Genesys_Device* dev, const Genesys
begin_scan(dev, sensor, &regs, true);
sanei_genesys_read_data_from_scanner(dev, line.data(), total_size);
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file("gl846_gain.pnm", line.data(), bpp, channels, pixels, lines);
if (DBG_LEVEL >= DBG_data) {
sanei_genesys_write_pnm_file("gl846_gain.pnm", line.data(), session.params.depth,
channels, pixels, lines);
}
/* average value on each channel */
for (j = 0; j < channels; j++)

Wyświetl plik

@ -678,12 +678,7 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
/* monochrome / color scan */
r = sanei_genesys_get_address (reg, REG04);
switch (session.params.depth)
{
case 1:
r->value &= ~REG04_BITSET;
r->value |= REG04_LINEART;
break;
switch (session.params.depth) {
case 8:
r->value &= ~(REG04_LINEART | REG04_BITSET);
break;
@ -766,11 +761,6 @@ static void gl847_compute_session(Genesys_Device* dev, ScanSession& s,
{
DBG_HELPER(dbg);
// in case of dynamic lineart, we use an internal 8 bit gray scan to generate 1 lineart data
if (s.params.flags & SCAN_FLAG_DYNAMIC_LINEART) {
s.params.depth = 8;
}
compute_session(dev, s, sensor);
s.computed = true;
@ -883,7 +873,7 @@ void CommandSetGl847::calculate_current_setup(Genesys_Device * dev,
session.params.pixels = dev->settings.pixels;
session.params.requested_pixels = dev->settings.requested_pixels;
session.params.lines = dev->settings.lines;
session.params.depth = dev->settings.get_depth();
session.params.depth = dev->settings.depth;
session.params.channels = dev->settings.get_channels();
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = dev->settings.scan_mode;
@ -1446,7 +1436,6 @@ void CommandSetGl847::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
void CommandSetGl847::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor) const
{
DBG_HELPER(dbg);
int flags;
float move;
int move_dpi;
float start;
@ -1498,18 +1487,6 @@ void CommandSetGl847::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sens
start += dev->settings.tl_x;
start = (start * sensor.optical_res) / MM_PER_INCH;
flags = 0;
/* emulated lineart from gray data is required for now */
if(dev->settings.scan_mode == ScanColorMode::LINEART
&& dev->settings.dynamic_lineart)
{
flags |= SCAN_FLAG_DYNAMIC_LINEART;
}
/* backtracking isn't handled well, so don't enable it */
flags |= SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE;
ScanSession session;
session.params.xres = dev->settings.xres;
session.params.yres = dev->settings.yres;
@ -1518,12 +1495,13 @@ void CommandSetGl847::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sens
session.params.pixels = dev->settings.pixels;
session.params.requested_pixels = dev->settings.requested_pixels;
session.params.lines = dev->settings.lines;
session.params.depth = dev->settings.get_depth();
session.params.depth = dev->settings.depth;
session.params.channels = dev->settings.get_channels();
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = dev->settings.scan_mode;
session.params.color_filter = dev->settings.color_filter;
session.params.flags = flags;
// backtracking isn't handled well, so don't enable it
session.params.flags = SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE;
gl847_compute_session(dev, session, sensor);
gl847_init_scan_regs(dev, sensor, &dev->reg, session);
@ -1628,7 +1606,7 @@ SensorExposure CommandSetGl847::led_calibration(Genesys_Device* dev, const Genes
int used_res;
int i, j;
int val;
int channels, depth;
int channels;
int avg[3], top[3], bottom[3];
int turn;
uint16_t exp[3];
@ -1644,7 +1622,6 @@ SensorExposure CommandSetGl847::led_calibration(Genesys_Device* dev, const Genes
/* offset calibration is always done in color mode */
channels = 3;
depth=16;
used_res = sensor.get_register_hwdpi(dev->settings.xres);
const auto& sensor_profile = get_sensor_profile(dev->model->asic_type, sensor, used_res, 1);
num_pixels = (sensor.sensor_pixels*used_res)/sensor.optical_res;
@ -1659,7 +1636,7 @@ SensorExposure CommandSetGl847::led_calibration(Genesys_Device* dev, const Genes
session.params.starty = 0;
session.params.pixels = num_pixels;
session.params.lines = 1;
session.params.depth = depth;
session.params.depth = 16;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
@ -1672,7 +1649,7 @@ SensorExposure CommandSetGl847::led_calibration(Genesys_Device* dev, const Genes
gl847_init_scan_regs(dev, sensor, &regs, session);
total_size = num_pixels * channels * (depth/8) * 1; /* colors * bytes_per_color * scan lines */
total_size = num_pixels * channels * (session.params.depth/8) * 1;
std::vector<uint8_t> line(total_size);
// initial loop values and boundaries
@ -1714,7 +1691,8 @@ SensorExposure CommandSetGl847::led_calibration(Genesys_Device* dev, const Genes
{
char fn[30];
snprintf(fn, 30, "gl847_led_%02d.pnm", turn);
sanei_genesys_write_pnm_file(fn, line.data(), depth, channels, num_pixels, 1);
sanei_genesys_write_pnm_file(fn, line.data(), session.params.depth,
channels, num_pixels, 1);
}
/* compute average */
@ -1992,7 +1970,6 @@ void CommandSetGl847::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
unsigned int pixels, lines, channels;
Genesys_Register_Set local_reg;
size_t size;
int depth;
unsigned int pass, count, found, x, y;
char title[80];
GenesysRegister *r;
@ -2008,10 +1985,7 @@ void CommandSetGl847::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
/* lines = (10 * dpi) / MM_PER_INCH; */
/* shading calibation is done with dev->motor.base_ydpi */
lines = (dev->model->shading_lines * dpi) / dev->motor.base_ydpi;
depth = 8;
pixels = (sensor.sensor_pixels * dpi) / sensor.optical_res;
size = pixels * channels * lines * (depth / 8);
std::vector<uint8_t> data(size);
dev->scanhead_position_in_steps = 0;
local_reg = dev->reg;
@ -2023,7 +1997,7 @@ void CommandSetGl847::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
session.params.starty = 0;
session.params.pixels = pixels;
session.params.lines = lines;
session.params.depth = depth;
session.params.depth = 8;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::GRAY;
@ -2032,6 +2006,9 @@ void CommandSetGl847::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
SCAN_FLAG_DISABLE_GAMMA;
gl847_compute_session(dev, session, sensor);
size = pixels * channels * lines * (session.params.depth / 8);
std::vector<uint8_t> data(size);
gl847_init_scan_regs(dev, sensor, &local_reg, session);
/* set up for reverse or forward */
@ -2058,7 +2035,8 @@ void CommandSetGl847::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
{
std::sprintf(title, "gl847_search_strip_%s_%s%02d.pnm",
black ? "black" : "white", forward ? "fwd" : "bwd", pass);
sanei_genesys_write_pnm_file(title, data.data(), depth, channels, pixels, lines);
sanei_genesys_write_pnm_file(title, data.data(), session.params.depth,
channels, pixels, lines);
}
/* loop until strip is found or maximum pass number done */
@ -2081,7 +2059,8 @@ void CommandSetGl847::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
{
sprintf(title, "gl847_search_strip_%s_%s%02d.pnm",
black ? "black" : "white", forward ? "fwd" : "bwd", (int)pass);
sanei_genesys_write_pnm_file(title, data.data(), depth, channels, pixels, lines);
sanei_genesys_write_pnm_file(title, data.data(), session.params.depth,
channels, pixels, lines);
}
/* search data to find black strip */
@ -2213,7 +2192,7 @@ void CommandSetGl847::offset_calibration(Genesys_Device* dev, const Genesys_Sens
Genesys_Register_Set& regs) const
{
DBG_HELPER(dbg);
unsigned int channels, bpp;
unsigned channels;
int pass = 0, avg, total_size;
int topavg, bottomavg, lines;
int top, bottom, black_pixels, pixels;
@ -2229,7 +2208,6 @@ void CommandSetGl847::offset_calibration(Genesys_Device* dev, const Genesys_Sens
channels = 3;
dev->calib_pixels = sensor.sensor_pixels;
lines=1;
bpp=8;
pixels= (sensor.sensor_pixels * sensor.optical_res) / sensor.optical_res;
black_pixels = (sensor.black_pixels * sensor.optical_res) / sensor.optical_res;
DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels);
@ -2241,7 +2219,7 @@ void CommandSetGl847::offset_calibration(Genesys_Device* dev, const Genesys_Sens
session.params.starty = 0;
session.params.pixels = pixels;
session.params.lines = lines;
session.params.depth = bpp;
session.params.depth = 8;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
@ -2257,7 +2235,7 @@ void CommandSetGl847::offset_calibration(Genesys_Device* dev, const Genesys_Sens
sanei_genesys_set_motor_power(regs, false);
/* allocate memory for scans */
total_size = pixels * channels * lines * (bpp/8); /* colors * bytes_per_color * scan lines */
total_size = pixels * channels * lines * (session.params.depth / 8); /* colors * bytes_per_color * scan lines */
std::vector<uint8_t> first_line(total_size);
std::vector<uint8_t> second_line(total_size);
@ -2282,7 +2260,8 @@ void CommandSetGl847::offset_calibration(Genesys_Device* dev, const Genesys_Sens
{
char fn[30];
snprintf(fn, 30, "gl847_offset%03d.pnm", bottom);
sanei_genesys_write_pnm_file(fn, first_line.data(), bpp, channels, pixels, lines);
sanei_genesys_write_pnm_file(fn, first_line.data(), session.params.depth,
channels, pixels, lines);
}
bottomavg = dark_average (first_line.data(), pixels, lines, channels, black_pixels);
@ -2323,7 +2302,8 @@ void CommandSetGl847::offset_calibration(Genesys_Device* dev, const Genesys_Sens
{
char fn[30];
snprintf(fn, 30, "gl847_offset%03d.pnm", dev->frontend.get_offset(1));
sanei_genesys_write_pnm_file(fn, second_line.data(), bpp, channels, pixels, lines);
sanei_genesys_write_pnm_file(fn, second_line.data(), session.params.depth,
channels, pixels, lines);
}
avg = dark_average(second_line.data(), pixels, lines, channels, black_pixels);
@ -2357,7 +2337,6 @@ void CommandSetGl847::coarse_gain_calibration(Genesys_Device* dev, const Genesys
int max[3];
float gain[3],coeff;
int val, code, lines;
int bpp;
// no gain nor offset for AKM AFE
uint8_t reg04 = dev->read_register(REG04);
@ -2379,7 +2358,6 @@ void CommandSetGl847::coarse_gain_calibration(Genesys_Device* dev, const Genesys
coeff=1.0;
}
lines=10;
bpp=8;
pixels = (sensor.sensor_pixels * sensor.optical_res) / sensor.optical_res;
ScanSession session;
@ -2389,7 +2367,7 @@ void CommandSetGl847::coarse_gain_calibration(Genesys_Device* dev, const Genesys
session.params.starty = 0;
session.params.pixels = pixels;
session.params.lines = lines;
session.params.depth = bpp;
session.params.depth = 8;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
@ -2411,7 +2389,7 @@ void CommandSetGl847::coarse_gain_calibration(Genesys_Device* dev, const Genesys
dev->write_registers(regs);
total_size = pixels * channels * (16/bpp) * lines;
total_size = pixels * channels * (16 / session.params.depth) * lines;
std::vector<uint8_t> line(total_size);
@ -2419,8 +2397,10 @@ void CommandSetGl847::coarse_gain_calibration(Genesys_Device* dev, const Genesys
begin_scan(dev, sensor, &regs, true);
sanei_genesys_read_data_from_scanner(dev, line.data(), total_size);
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file("gl847_gain.pnm", line.data(), bpp, channels, pixels, lines);
if (DBG_LEVEL >= DBG_data) {
sanei_genesys_write_pnm_file("gl847_gain.pnm", line.data(), session.params.depth,
channels, pixels, lines);
}
/* average value on each channel */
for (j = 0; j < channels; j++)
@ -2428,23 +2408,10 @@ void CommandSetGl847::coarse_gain_calibration(Genesys_Device* dev, const Genesys
max[j] = 0;
for (i = pixels/4; i < (pixels*3/4); i++)
{
if(bpp==16)
{
if (dev->model->is_cis)
val =
line[i * 2 + j * 2 * pixels + 1] * 256 +
line[i * 2 + j * 2 * pixels];
else
val =
line[i * 2 * channels + 2 * j + 1] * 256 +
line[i * 2 * channels + 2 * j];
}
else
{
if (dev->model->is_cis)
val = line[i + j * pixels];
else
val = line[i * channels + j];
if (dev->model->is_cis) {
val = line[i + j * pixels];
} else {
val = line[i * channels + j];
}
max[j] += val;

Wyświetl plik

@ -515,6 +515,7 @@ class ImagePipelineStack
{
public:
ImagePipelineStack() {}
~ImagePipelineStack() { clear(); }
std::size_t get_input_width() const;
std::size_t get_input_height() const;

Wyświetl plik

@ -1330,7 +1330,6 @@ void compute_session_pipeline(const Genesys_Device* dev, ScanSession& s)
}
s.pipeline_needs_ccd = s.max_color_shift_lines + s.num_staggered_lines > 0;
s.pipeline_needs_shrink = dev->settings.requested_pixels != s.output_pixels;
s.pipeline_needs_reverse = depth == 1;
}
void compute_session_pixel_offsets(const Genesys_Device* dev, ScanSession& s,
@ -1447,6 +1446,10 @@ void compute_session(Genesys_Device* dev, ScanSession& s, const Genesys_Sensor&
(void) dev;
s.params.assert_valid();
if (s.params.depth != 8 && s.params.depth != 16) {
throw SaneException("Unsupported depth setting %d", s.params.depth);
}
unsigned ccd_pixels_per_system_pixel = sensor.ccd_pixels_per_system_pixel();
// compute optical and output resolutions
@ -2558,11 +2561,10 @@ void debug_dump(unsigned level, const ScanSession& session)
DBG(level, " buffer_size_read : %zu\n", session.buffer_size_lines);
DBG(level, " buffer_size_shrink : %zu\n", session.buffer_size_shrink);
DBG(level, " buffer_size_out : %zu\n", session.buffer_size_out);
DBG(level, " filters:%s%s%s%s\n",
DBG(level, " filters:%s%s%s\n",
session.pipeline_needs_reorder ? " reorder" : "",
session.pipeline_needs_ccd ? " ccd" : "",
session.pipeline_needs_shrink ? " shrink" : "",
session.pipeline_needs_reverse ? " reverse" : "");
session.pipeline_needs_shrink ? " shrink" : "");
debug_dump(level, session.params);
}

Wyświetl plik

@ -255,7 +255,6 @@ extern Motor_Profile gl124_motor_profiles[];
#define SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE 0x008
#define SCAN_FLAG_IGNORE_LINE_DISTANCE 0x010
#define SCAN_FLAG_DISABLE_LAMP 0x040
#define SCAN_FLAG_DYNAMIC_LINEART 0x080
#define SCAN_FLAG_CALIBRATION 0x100
#define SCAN_FLAG_FEEDING 0x200
#define SCAN_FLAG_USE_XPA 0x400

Wyświetl plik

@ -86,9 +86,6 @@ struct Genesys_Settings
// Disable interpolation for xres<yres
int disable_interpolation = 0;
// true is lineart is generated from gray data by the dynamic rasterization algoright
int dynamic_lineart = 0;
// value for contrast enhancement in the [-100..100] range
int contrast = 0;
@ -104,14 +101,6 @@ struct Genesys_Settings
return 3;
return 1;
}
unsigned get_depth() const
{
if (scan_mode == ScanColorMode::LINEART)
return 1;
return depth;
}
};
struct SetupParams {
@ -307,7 +296,6 @@ struct ScanSession {
bool pipeline_needs_reorder = false;
bool pipeline_needs_ccd = false;
bool pipeline_needs_shrink = false;
bool pipeline_needs_reverse = false;
void assert_computed() const
{