kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Use session struct to pass data to the setup functions
rodzic
a18ec0faac
commit
cafb97d293
|
@ -1131,15 +1131,25 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
reg->set16(REG_DUMMY, sensor.dummy_pixel);
|
||||
}
|
||||
|
||||
static void gl124_compute_session(Genesys_Device* dev, ScanSession& s,
|
||||
const Genesys_Sensor& sensor)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
(void) sensor;
|
||||
(void) dev;
|
||||
s.params.assert_valid();
|
||||
s.computed = true;
|
||||
}
|
||||
|
||||
/** set up registers for an actual scan
|
||||
*
|
||||
* this function sets up the scanner to scan in normal or single line mode
|
||||
*/
|
||||
static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set* reg, SetupParams& params)
|
||||
Genesys_Register_Set* reg, ScanSession& session)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
params.assert_valid();
|
||||
session.assert_computed();
|
||||
|
||||
int used_res;
|
||||
int start, used_pixels;
|
||||
|
@ -1156,68 +1166,66 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
int max_shift;
|
||||
size_t requested_buffer_size, read_buffer_size;
|
||||
|
||||
debug_dump(DBG_info, params);
|
||||
debug_dump(DBG_info, session.params);
|
||||
|
||||
unsigned ccd_size_divisor = compute_ccd_size_divisor(sensor, params.xres);
|
||||
unsigned ccd_size_divisor = compute_ccd_size_divisor(sensor, session.params.xres);
|
||||
|
||||
unsigned optical_res = sensor.optical_res / ccd_size_divisor;
|
||||
DBG (DBG_info, "%s: optical_res=%d\n", __func__, optical_res);
|
||||
|
||||
/* stagger */
|
||||
if (ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) {
|
||||
stagger = (4 * params.yres) / dev->motor.base_ydpi;
|
||||
stagger = (4 * session.params.yres) / dev->motor.base_ydpi;
|
||||
} else {
|
||||
stagger = 0;
|
||||
}
|
||||
DBG (DBG_info, "gl124_init_scan_regs : stagger=%d lines\n", stagger);
|
||||
|
||||
/** @brief compute used resolution */
|
||||
if (params.flags & SCAN_FLAG_USE_OPTICAL_RES)
|
||||
{
|
||||
if (session.params.flags & SCAN_FLAG_USE_OPTICAL_RES) {
|
||||
used_res = optical_res;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* resolution is choosen from a fixed list and can be used directly,
|
||||
* unless we have ydpi higher than sensor's maximum one */
|
||||
if(params.xres>optical_res)
|
||||
used_res=optical_res;
|
||||
else
|
||||
used_res = params.xres;
|
||||
// resolution is choosen from a fixed list and can be used directly, unless we have ydpi
|
||||
// higher than sensor's maximum one */
|
||||
if (session.params.xres > optical_res) {
|
||||
used_res = optical_res;
|
||||
} else {
|
||||
used_res = session.params.xres;
|
||||
}
|
||||
}
|
||||
|
||||
/* compute scan parameters values */
|
||||
/* pixels are allways given at full optical resolution */
|
||||
/* use detected left margin and fixed value */
|
||||
/* start */
|
||||
/* add x coordinates */
|
||||
start = params.startx;
|
||||
start = session.params.startx;
|
||||
|
||||
if (stagger > 0)
|
||||
start |= 1;
|
||||
|
||||
/* compute correct pixels number */
|
||||
used_pixels = (params.pixels * optical_res) / params.xres;
|
||||
used_pixels = (session.params.pixels * optical_res) / session.params.xres;
|
||||
DBG (DBG_info, "%s: used_pixels=%d\n", __func__, used_pixels);
|
||||
|
||||
/* round up pixels number if needed */
|
||||
if (used_pixels * params.xres < params.pixels * optical_res)
|
||||
used_pixels++;
|
||||
if (used_pixels * session.params.xres < session.params.pixels * optical_res) {
|
||||
used_pixels++;
|
||||
}
|
||||
|
||||
/* we want even number of pixels here */
|
||||
if(used_pixels & 1)
|
||||
used_pixels++;
|
||||
if (used_pixels & 1) {
|
||||
used_pixels++;
|
||||
}
|
||||
|
||||
/* slope_dpi */
|
||||
/* cis color scan is effectively a gray scan with 3 gray lines per color line and a FILTER of 0 */
|
||||
if (dev->model->is_cis)
|
||||
slope_dpi = params.yres * params.channels;
|
||||
else
|
||||
slope_dpi = params.yres;
|
||||
/* cis color scan is effectively a gray scan with 3 gray lines per color line and a FILTER of 0 */
|
||||
if (dev->model->is_cis) {
|
||||
slope_dpi = session.params.yres * session.params.channels;
|
||||
} else {
|
||||
slope_dpi = session.params.yres;
|
||||
}
|
||||
|
||||
/* scan_step_type */
|
||||
if(params.flags & SCAN_FLAG_FEEDING)
|
||||
{
|
||||
if(session.params.flags & SCAN_FLAG_FEEDING) {
|
||||
scan_step_type=0;
|
||||
exposure_time=MOVE_EXPOSURE;
|
||||
}
|
||||
|
@ -1233,20 +1241,23 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
/*** optical parameters ***/
|
||||
/* in case of dynamic lineart, we use an internal 8 bit gray scan
|
||||
* to generate 1 lineart data */
|
||||
if (params.flags & SCAN_FLAG_DYNAMIC_LINEART) {
|
||||
params.depth = 8;
|
||||
if (session.params.flags & SCAN_FLAG_DYNAMIC_LINEART) {
|
||||
session.params.depth = 8;
|
||||
}
|
||||
|
||||
/* we enable true gray for cis scanners only, and just when doing
|
||||
* scan since color calibration is OK for this mode
|
||||
*/
|
||||
oflags = 0;
|
||||
if (params.flags & SCAN_FLAG_DISABLE_SHADING)
|
||||
oflags |= OPTICAL_FLAG_DISABLE_SHADING;
|
||||
if (params.flags & SCAN_FLAG_DISABLE_GAMMA)
|
||||
oflags |= OPTICAL_FLAG_DISABLE_GAMMA;
|
||||
if (params.flags & SCAN_FLAG_DISABLE_LAMP)
|
||||
oflags |= OPTICAL_FLAG_DISABLE_LAMP;
|
||||
oflags = 0;
|
||||
if (session.params.flags & SCAN_FLAG_DISABLE_SHADING) {
|
||||
oflags |= OPTICAL_FLAG_DISABLE_SHADING;
|
||||
}
|
||||
if (session.params.flags & SCAN_FLAG_DISABLE_GAMMA) {
|
||||
oflags |= OPTICAL_FLAG_DISABLE_GAMMA;
|
||||
}
|
||||
if (session.params.flags & SCAN_FLAG_DISABLE_LAMP) {
|
||||
oflags |= OPTICAL_FLAG_DISABLE_LAMP;
|
||||
}
|
||||
|
||||
if (dev->model->is_cis && dev->settings.true_gray)
|
||||
{
|
||||
|
@ -1255,46 +1266,44 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
|
||||
// now _LOGICAL_ optical values used are known, setup registers
|
||||
gl124_init_optical_regs_scan(dev, sensor, reg, exposure_time, used_res, start, used_pixels,
|
||||
params.channels, params.depth, ccd_size_divisor,
|
||||
params.color_filter, oflags);
|
||||
session.params.channels, session.params.depth, ccd_size_divisor,
|
||||
session.params.color_filter, oflags);
|
||||
|
||||
/*** motor parameters ***/
|
||||
|
||||
/* max_shift */
|
||||
max_shift=sanei_genesys_compute_max_shift(dev,params.channels,params.yres,params.flags);
|
||||
max_shift = sanei_genesys_compute_max_shift(dev, session.params.channels, session.params.yres,
|
||||
session.params.flags);
|
||||
|
||||
/* lines to scan */
|
||||
lincnt = params.lines + max_shift + stagger;
|
||||
lincnt = session.params.lines + max_shift + stagger;
|
||||
|
||||
/* add tl_y to base movement */
|
||||
move = params.starty;
|
||||
move = session.params.starty;
|
||||
DBG(DBG_info, "%s: move=%d steps\n", __func__, move);
|
||||
|
||||
mflags = 0;
|
||||
if (params.flags & SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE) {
|
||||
if (session.params.flags & SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE) {
|
||||
mflags |= MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE;
|
||||
}
|
||||
if (params.flags & SCAN_FLAG_FEEDING) {
|
||||
if (session.params.flags & SCAN_FLAG_FEEDING) {
|
||||
mflags |= MOTOR_FLAG_FEED;
|
||||
}
|
||||
gl124_init_motor_regs_scan(dev, sensor, reg, exposure_time, slope_dpi, scan_step_type,
|
||||
dev->model->is_cis ? lincnt * params.channels : lincnt,
|
||||
dummy, move, params.scan_mode, mflags);
|
||||
dev->model->is_cis ? lincnt * session.params.channels : lincnt,
|
||||
dummy, move, session.params.scan_mode, mflags);
|
||||
|
||||
/*** prepares data reordering ***/
|
||||
|
||||
/* words_per_line */
|
||||
bytes_per_line = (used_pixels * used_res) / optical_res;
|
||||
bytes_per_line = (bytes_per_line * params.channels * params.depth) / 8;
|
||||
bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8;
|
||||
|
||||
/* since we don't have sheetfed scanners to handle,
|
||||
* use huge read buffer */
|
||||
/* TODO find the best size according to settings */
|
||||
requested_buffer_size = 16 * bytes_per_line;
|
||||
|
||||
read_buffer_size =
|
||||
2 * requested_buffer_size +
|
||||
((max_shift + stagger) * used_pixels * params.channels * params.depth) / 8;
|
||||
read_buffer_size = 2 * requested_buffer_size +
|
||||
((max_shift + stagger) * used_pixels * session.params.channels * session.params.depth) / 8;
|
||||
|
||||
dev->read_buffer.clear();
|
||||
dev->read_buffer.alloc(read_buffer_size);
|
||||
|
@ -1306,15 +1315,14 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
dev->shrink_buffer.alloc(requested_buffer_size);
|
||||
|
||||
dev->out_buffer.clear();
|
||||
dev->out_buffer.alloc((8 * dev->settings.pixels * params.channels * params.depth) / 8);
|
||||
dev->out_buffer.alloc((8 * dev->settings.pixels * session.params.channels * session.params.depth) / 8);
|
||||
|
||||
dev->read_bytes_left = bytes_per_line * lincnt;
|
||||
|
||||
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
||||
dev->read_active = SANE_TRUE;
|
||||
|
||||
|
||||
dev->session.params = params;
|
||||
dev->session = session;
|
||||
dev->current_setup.pixels = (used_pixels * used_res) / optical_res;
|
||||
DBG(DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels);
|
||||
dev->current_setup.lines = lincnt;
|
||||
|
@ -1325,14 +1333,13 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
dev->current_setup.max_shift = max_shift + stagger;
|
||||
|
||||
dev->total_bytes_read = 0;
|
||||
if (params.depth == 1)
|
||||
dev->total_bytes_to_read =
|
||||
((dev->settings.pixels * dev->settings.lines) / 8 +
|
||||
(((dev->settings.pixels * dev->settings.lines) % 8) ? 1 : 0)) *
|
||||
params.channels;
|
||||
else
|
||||
dev->total_bytes_to_read =
|
||||
dev->settings.pixels * dev->settings.lines * params.channels * (params.depth / 8);
|
||||
if (session.params.depth == 1) {
|
||||
dev->total_bytes_to_read = ((dev->settings.pixels * dev->settings.lines) / 8 +
|
||||
(((dev->settings.pixels * dev->settings.lines) % 8) ? 1 : 0)) * session.params.channels;
|
||||
} else {
|
||||
dev->total_bytes_to_read = dev->settings.pixels * dev->settings.lines *
|
||||
session.params.channels * (session.params.depth / 8);
|
||||
}
|
||||
|
||||
DBG(DBG_info, "%s: total bytes to send = %lu\n", __func__, (u_long) dev->total_bytes_to_read);
|
||||
}
|
||||
|
@ -1373,47 +1380,46 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
start += dev->settings.tl_x;
|
||||
start = (start * sensor.optical_res) / MM_PER_INCH;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dev->settings.xres;
|
||||
params.yres = dev->settings.yres;
|
||||
params.startx = start;
|
||||
params.starty = 0; // not used
|
||||
params.pixels = dev->settings.pixels;
|
||||
params.lines = dev->settings.lines;
|
||||
params.depth = depth;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = dev->settings.scan_mode;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = 0;
|
||||
ScanSession session;
|
||||
session.params.xres = dev->settings.xres;
|
||||
session.params.yres = dev->settings.yres;
|
||||
session.params.startx = start;
|
||||
session.params.starty = 0; // not used
|
||||
session.params.pixels = dev->settings.pixels;
|
||||
session.params.lines = dev->settings.lines;
|
||||
session.params.depth = depth;
|
||||
session.params.channels = 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 = 0;
|
||||
|
||||
unsigned ccd_size_divisor = compute_ccd_size_divisor(sensor, params.xres);
|
||||
unsigned ccd_size_divisor = compute_ccd_size_divisor(sensor, session.params.xres);
|
||||
|
||||
DBG(DBG_info, "%s ", __func__);
|
||||
debug_dump(DBG_info, params);
|
||||
debug_dump(DBG_info, session.params);
|
||||
|
||||
/* optical_res */
|
||||
optical_res = sensor.optical_res;
|
||||
|
||||
if (params.xres <= (unsigned) optical_res)
|
||||
used_res = params.xres;
|
||||
else
|
||||
used_res=optical_res;
|
||||
if (session.params.xres <= (unsigned) optical_res) {
|
||||
used_res = session.params.xres;
|
||||
} else {
|
||||
used_res = optical_res;
|
||||
}
|
||||
|
||||
/* compute scan parameters values */
|
||||
/* pixels are allways given at half or full CCD optical resolution */
|
||||
/* use detected left margin and fixed value */
|
||||
|
||||
/* compute correct pixels number */
|
||||
used_pixels = (params.pixels * optical_res) / params.xres;
|
||||
used_pixels = (session.params.pixels * optical_res) / session.params.xres;
|
||||
DBG (DBG_info, "%s: used_pixels=%d\n", __func__, used_pixels);
|
||||
|
||||
/* exposure */
|
||||
exposure_time = gl124_compute_exposure(dev, params.xres, ccd_size_divisor);
|
||||
exposure_time = gl124_compute_exposure(dev, session.params.xres, ccd_size_divisor);
|
||||
DBG (DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
|
||||
|
||||
/* max_shift */
|
||||
max_shift=sanei_genesys_compute_max_shift(dev, params.channels, params.yres, 0);
|
||||
max_shift = sanei_genesys_compute_max_shift(dev, session.params.channels,
|
||||
session.params.yres, 0);
|
||||
|
||||
// compute hw dpi for sensor
|
||||
dpihw = sensor.get_register_hwdpi(used_res);
|
||||
|
@ -1424,16 +1430,15 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
|
||||
/* stagger */
|
||||
if (ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) {
|
||||
stagger = (4 * params.yres) / dev->motor.base_ydpi;
|
||||
stagger = (4 * session.params.yres) / dev->motor.base_ydpi;
|
||||
} else {
|
||||
stagger = 0;
|
||||
}
|
||||
DBG (DBG_info, "%s: stagger=%d lines\n", __func__, stagger);
|
||||
|
||||
/* lincnt */
|
||||
lincnt = params.lines + max_shift + stagger;
|
||||
lincnt = session.params.lines + max_shift + stagger;
|
||||
|
||||
dev->session.params = params;
|
||||
dev->session = session;
|
||||
dev->current_setup.pixels = (used_pixels * used_res) / optical_res;
|
||||
DBG (DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels);
|
||||
dev->current_setup.lines = lincnt;
|
||||
|
@ -1714,23 +1719,24 @@ static void gl124_slow_back_home(Genesys_Device* dev, SANE_Bool wait_until_home)
|
|||
|
||||
const auto& sensor = sanei_genesys_find_sensor_any(dev);
|
||||
|
||||
SetupParams params;
|
||||
params.xres = resolution;
|
||||
params.yres = resolution;
|
||||
params.startx = 100;
|
||||
params.starty = 30000;
|
||||
params.pixels = 100;
|
||||
params.lines = 100;
|
||||
params.depth = 8;
|
||||
params.channels = 1;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::GRAY;
|
||||
params.color_filter = ColorFilter::RED;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
session.params.yres = resolution;
|
||||
session.params.startx = 100;
|
||||
session.params.starty = 30000;
|
||||
session.params.pixels = 100;
|
||||
session.params.lines = 100;
|
||||
session.params.depth = 8;
|
||||
session.params.channels = 1;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::GRAY;
|
||||
session.params.color_filter = ColorFilter::RED;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl124_compute_session(dev, session, sensor);
|
||||
|
||||
gl124_init_scan_regs(dev, sensor, &local_reg, params);
|
||||
gl124_init_scan_regs(dev, sensor, &local_reg, session);
|
||||
|
||||
// clear scan and feed count
|
||||
dev->write_register(REG0D, REG0D_CLRLNCNT | REG0D_CLRMCNT);
|
||||
|
@ -1802,25 +1808,26 @@ static void gl124_feed(Genesys_Device* dev, unsigned int steps, int reverse)
|
|||
resolution=sanei_genesys_get_lowest_ydpi(dev);
|
||||
const auto& sensor = sanei_genesys_find_sensor(dev, resolution, ScanMethod::FLATBED);
|
||||
|
||||
SetupParams params;
|
||||
params.xres = resolution;
|
||||
params.yres = resolution;
|
||||
params.startx = 0;
|
||||
params.starty = steps;
|
||||
params.pixels = 100;
|
||||
params.lines = 3;
|
||||
params.depth = 8;
|
||||
params.channels = 3;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_FEEDING |
|
||||
SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
session.params.yres = resolution;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = steps;
|
||||
session.params.pixels = 100;
|
||||
session.params.lines = 3;
|
||||
session.params.depth = 8;
|
||||
session.params.channels = 3;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
session.params.color_filter = dev->settings.color_filter;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_FEEDING |
|
||||
SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl124_compute_session(dev, session, sensor);
|
||||
|
||||
gl124_init_scan_regs(dev, sensor, &local_reg, params);
|
||||
gl124_init_scan_regs(dev, sensor, &local_reg, session);
|
||||
|
||||
local_reg.set24(REG_EXPR, 0);
|
||||
local_reg.set24(REG_EXPG, 0);
|
||||
|
@ -1886,24 +1893,25 @@ static void gl124_search_start_position(Genesys_Device* dev)
|
|||
// whith employ different sensors with potentially different settings.
|
||||
auto& sensor = sanei_genesys_find_sensor_for_write(dev, dpi, ScanMethod::FLATBED);
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dpi;
|
||||
params.yres = dpi;
|
||||
params.startx = 0;
|
||||
params.starty = 0; /*we should give a small offset here~60 steps */
|
||||
params.pixels = 600;
|
||||
params.lines = dev->model->search_lines;
|
||||
params.depth = 8;
|
||||
params.channels = 1;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::GRAY;
|
||||
params.color_filter = ColorFilter::GREEN;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE |
|
||||
SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE;
|
||||
ScanSession session;
|
||||
session.params.xres = dpi;
|
||||
session.params.yres = dpi;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0; /*we should give a small offset here~60 steps */
|
||||
session.params.pixels = 600;
|
||||
session.params.lines = dev->model->search_lines;
|
||||
session.params.depth = 8;
|
||||
session.params.channels = 1;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::GRAY;
|
||||
session.params.color_filter = ColorFilter::GREEN;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE |
|
||||
SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE;
|
||||
gl124_compute_session(dev, session, sensor);
|
||||
|
||||
gl124_init_scan_regs(dev, sensor, &local_reg, params);
|
||||
gl124_init_scan_regs(dev, sensor, &local_reg, session);
|
||||
|
||||
// send to scanner
|
||||
dev->write_registers(local_reg);
|
||||
|
@ -1952,25 +1960,26 @@ static void gl124_init_regs_for_coarse_calibration(Genesys_Device* dev,
|
|||
channels = 1;
|
||||
}
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dev->settings.xres;
|
||||
params.yres = dev->settings.yres;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel();
|
||||
params.lines = 20;
|
||||
params.depth = 16;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = dev->settings.scan_mode;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_FEEDING |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = dev->settings.xres;
|
||||
session.params.yres = dev->settings.yres;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel();
|
||||
session.params.lines = 20;
|
||||
session.params.depth = 16;
|
||||
session.params.channels = 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 = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_FEEDING |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl124_compute_session(dev, session, sensor);
|
||||
|
||||
gl124_init_scan_regs(dev, sensor, ®s, params);
|
||||
gl124_init_scan_regs(dev, sensor, ®s, session);
|
||||
|
||||
sanei_genesys_set_motor_power(regs, false);
|
||||
|
||||
|
@ -2019,25 +2028,26 @@ static void gl124_init_regs_for_shading(Genesys_Device* dev, const Genesys_Senso
|
|||
}
|
||||
DBG (DBG_io, "%s: move=%d steps\n", __func__, move);
|
||||
|
||||
SetupParams params;
|
||||
params.xres = resolution;
|
||||
params.yres = resolution;
|
||||
params.startx = 0;
|
||||
params.starty = move;
|
||||
params.pixels = dev->calib_pixels;
|
||||
params.lines = dev->calib_lines;
|
||||
params.depth = 16;
|
||||
params.channels = dev->calib_channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
params.color_filter = ColorFilter::RED;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
session.params.yres = resolution;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = move;
|
||||
session.params.pixels = dev->calib_pixels;
|
||||
session.params.lines = dev->calib_lines;
|
||||
session.params.depth = 16;
|
||||
session.params.channels = dev->calib_channels;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
session.params.color_filter = ColorFilter::RED;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl124_compute_session(dev, session, sensor);
|
||||
|
||||
try {
|
||||
gl124_init_scan_regs(dev, sensor, ®s, params);
|
||||
gl124_init_scan_regs(dev, sensor, ®s, session);
|
||||
} catch (...) {
|
||||
catch_all_exceptions(__func__, [&](){ sanei_genesys_set_motor_power(regs, false); });
|
||||
throw;
|
||||
|
@ -2122,21 +2132,22 @@ static void gl124_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor&
|
|||
flags |= SCAN_FLAG_DYNAMIC_LINEART;
|
||||
}
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dev->settings.xres;
|
||||
params.yres = dev->settings.yres;
|
||||
params.startx = start;
|
||||
params.starty = move;
|
||||
params.pixels = dev->settings.pixels;
|
||||
params.lines = dev->settings.lines;
|
||||
params.depth = depth;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = dev->settings.scan_mode;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = flags;
|
||||
ScanSession session;
|
||||
session.params.xres = dev->settings.xres;
|
||||
session.params.yres = dev->settings.yres;
|
||||
session.params.startx = start;
|
||||
session.params.starty = move;
|
||||
session.params.pixels = dev->settings.pixels;
|
||||
session.params.lines = dev->settings.lines;
|
||||
session.params.depth = depth;
|
||||
session.params.channels = 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;
|
||||
gl124_compute_session(dev, session, sensor);
|
||||
|
||||
gl124_init_scan_regs(dev, sensor, &dev->reg, params);
|
||||
gl124_init_scan_regs(dev, sensor, &dev->reg, session);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2269,24 +2280,25 @@ static void move_to_calibration_area(Genesys_Device* dev, const Genesys_Sensor&
|
|||
/* initial calibration reg values */
|
||||
regs = dev->reg;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = 600;
|
||||
params.yres = 600;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = pixels;
|
||||
params.lines = 1;
|
||||
params.depth = 8;
|
||||
params.channels = 3;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = 600;
|
||||
session.params.yres = 600;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = pixels;
|
||||
session.params.lines = 1;
|
||||
session.params.depth = 8;
|
||||
session.params.channels = 3;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
session.params.color_filter = dev->settings.color_filter;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl124_compute_session(dev, session, sensor);
|
||||
|
||||
gl124_init_scan_regs(dev, sensor, ®s, params);
|
||||
gl124_init_scan_regs(dev, sensor, ®s, session);
|
||||
|
||||
size = pixels * 3;
|
||||
std::vector<uint8_t> line(size);
|
||||
|
@ -2346,24 +2358,25 @@ static void gl124_led_calibration(Genesys_Device* dev, Genesys_Sensor& sensor,
|
|||
/* initial calibration reg values */
|
||||
regs = dev->reg;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = resolution;
|
||||
params.yres = resolution;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = num_pixels;
|
||||
params.lines = 1;
|
||||
params.depth = depth;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
session.params.yres = resolution;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = num_pixels;
|
||||
session.params.lines = 1;
|
||||
session.params.depth = depth;
|
||||
session.params.channels = channels;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
session.params.color_filter = dev->settings.color_filter;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl124_compute_session(dev, session, sensor);
|
||||
|
||||
gl124_init_scan_regs(dev, sensor, ®s, params);
|
||||
gl124_init_scan_regs(dev, sensor, ®s, session);
|
||||
|
||||
total_size = num_pixels * channels * (depth/8) * 1; /* colors * bytes_per_color * scan lines */
|
||||
std::vector<uint8_t> line(total_size);
|
||||
|
@ -2517,24 +2530,25 @@ static void gl124_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
|
|||
black_pixels = (sensor.black_pixels * resolution) / sensor.optical_res;
|
||||
DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels);
|
||||
|
||||
SetupParams params;
|
||||
params.xres = resolution;
|
||||
params.yres = resolution;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = pixels;
|
||||
params.lines = lines;
|
||||
params.depth = bpp;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
session.params.yres = resolution;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = pixels;
|
||||
session.params.lines = lines;
|
||||
session.params.depth = bpp;
|
||||
session.params.channels = channels;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
session.params.color_filter = dev->settings.color_filter;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl124_compute_session(dev, session, sensor);
|
||||
|
||||
gl124_init_scan_regs(dev, sensor, ®s, params);
|
||||
gl124_init_scan_regs(dev, sensor, ®s, session);
|
||||
|
||||
sanei_genesys_set_motor_power(regs, false);
|
||||
|
||||
|
@ -2677,25 +2691,26 @@ static void gl124_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen
|
|||
bpp=8;
|
||||
pixels = (sensor.sensor_pixels * resolution) / sensor.optical_res;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = resolution;
|
||||
params.yres = resolution;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = pixels;
|
||||
params.lines = lines;
|
||||
params.depth = bpp;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
session.params.yres = resolution;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = pixels;
|
||||
session.params.lines = lines;
|
||||
session.params.depth = bpp;
|
||||
session.params.channels = channels;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
session.params.color_filter = dev->settings.color_filter;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl124_compute_session(dev, session, sensor);
|
||||
|
||||
try {
|
||||
gl124_init_scan_regs(dev, sensor, ®s, params);
|
||||
gl124_init_scan_regs(dev, sensor, ®s, session);
|
||||
} catch (...) {
|
||||
catch_all_exceptions(__func__, [&](){ sanei_genesys_set_motor_power(regs, false); });
|
||||
throw;
|
||||
|
@ -2794,24 +2809,25 @@ static void gl124_init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor
|
|||
|
||||
*reg = dev->reg;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = sensor.optical_res;
|
||||
params.yres = dev->motor.base_ydpi;
|
||||
params.startx = sensor.sensor_pixels / 4;
|
||||
params.starty = 0;
|
||||
params.pixels = sensor.sensor_pixels / 2;
|
||||
params.lines = 1;
|
||||
params.depth = 8;
|
||||
params.channels = *channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = sensor.optical_res;
|
||||
session.params.yres = dev->motor.base_ydpi;
|
||||
session.params.startx = sensor.sensor_pixels / 4;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = sensor.sensor_pixels / 2;
|
||||
session.params.lines = 1;
|
||||
session.params.depth = 8;
|
||||
session.params.channels = *channels;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
session.params.color_filter = dev->settings.color_filter;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl124_compute_session(dev, session, sensor);
|
||||
|
||||
gl124_init_scan_regs(dev, sensor, reg, params);
|
||||
gl124_init_scan_regs(dev, sensor, reg, session);
|
||||
|
||||
num_pixels = dev->current_setup.pixels;
|
||||
|
||||
|
|
|
@ -463,9 +463,6 @@ static Motor_Profile motors[]={
|
|||
{0, 0, 0, NULL},
|
||||
};
|
||||
|
||||
static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set* reg, SetupParams& params);
|
||||
|
||||
static void gl124_start_action(Genesys_Device* dev);
|
||||
static void gl124_begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set* reg, SANE_Bool start_motor);
|
||||
|
|
|
@ -342,6 +342,16 @@ static int get_cksel(int sensor_id, int required, unsigned channels)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static void gl646_compute_session(Genesys_Device* dev, ScanSession& s,
|
||||
const Genesys_Sensor& sensor)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
(void) sensor;
|
||||
(void) dev;
|
||||
s.params.assert_valid();
|
||||
s.computed = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup register and motor tables for a scan at the
|
||||
* given resolution and color mode. TODO try to not use any filed from
|
||||
|
@ -357,15 +367,17 @@ static int get_cksel(int sensor_id, int required, unsigned channels)
|
|||
static void gl646_setup_registers(Genesys_Device* dev,
|
||||
const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set* regs,
|
||||
SetupParams& params,
|
||||
ScanSession& session,
|
||||
uint16_t* slope_table1,
|
||||
uint16_t* slope_table2,
|
||||
bool xcorrection)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
int resolution = params.xres;
|
||||
uint32_t move = params.starty;
|
||||
uint32_t linecnt = params.lines;
|
||||
session.assert_computed();
|
||||
|
||||
int resolution = session.params.xres;
|
||||
uint32_t move = session.params.starty;
|
||||
uint32_t linecnt = session.params.lines;
|
||||
|
||||
uint32_t startx = 0;
|
||||
/* pixels are allways given at full CCD optical resolution */
|
||||
|
@ -382,19 +394,18 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
|||
}
|
||||
|
||||
/* add x coordinates : expressed in sensor max dpi */
|
||||
startx += params.startx;
|
||||
startx += session.params.startx;
|
||||
|
||||
/* stagger works with odd start cordinates */
|
||||
if (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE) {
|
||||
startx |= 1;
|
||||
}
|
||||
|
||||
uint32_t pixels = (params.pixels * sensor.optical_res) / params.xres;
|
||||
/* special requirement for 400 dpi on 1200 dpi sensors */
|
||||
if (params.xres == 400)
|
||||
{
|
||||
uint32_t pixels = (session.params.pixels * sensor.optical_res) / session.params.xres;
|
||||
// special requirement for 400 dpi on 1200 dpi sensors
|
||||
if (session.params.xres == 400) {
|
||||
pixels = (pixels / 6) * 6;
|
||||
}
|
||||
}
|
||||
/* TODO check for pixel width overflow */
|
||||
uint32_t endx = startx + pixels;
|
||||
|
||||
|
@ -433,16 +444,15 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
|||
{
|
||||
if (dev->model->ccd_type == sensor_master[i].sensor
|
||||
&& sensor_master[i].dpi == xresolution
|
||||
&& sensor_master[i].channels == params.channels)
|
||||
&& sensor_master[i].channels == session.params.channels)
|
||||
{
|
||||
sensor_mst = &sensor_master[i];
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (sensor_mst == NULL)
|
||||
{
|
||||
if (sensor_mst == NULL) {
|
||||
throw SaneException("unable to find settings for sensor %d at %d dpi channels=%d",
|
||||
dev->model->ccd_type, xresolution, params.channels);
|
||||
dev->model->ccd_type, xresolution, session.params.channels);
|
||||
}
|
||||
|
||||
/* for the given resolution, search for master
|
||||
|
@ -453,7 +463,7 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
|||
{
|
||||
if (dev->model->motor_type == motor_master[i].motor
|
||||
&& motor_master[i].dpi == resolution
|
||||
&& motor_master[i].channels == params.channels)
|
||||
&& motor_master[i].channels == session.params.channels)
|
||||
{
|
||||
motor = &motor_master[i];
|
||||
}
|
||||
|
@ -462,7 +472,7 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
|||
if (motor == NULL)
|
||||
{
|
||||
throw SaneException("unable to find settings for motor %d at %d dpi, color=%d",
|
||||
dev->model->motor_type, resolution, params.channels);
|
||||
dev->model->motor_type, resolution, session.params.channels);
|
||||
}
|
||||
|
||||
/* now we can search for the specific sensor settings */
|
||||
|
@ -614,15 +624,14 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
|||
|
||||
/* select XPA */
|
||||
regs->find_reg(0x03).value &= ~REG03_XPASEL;
|
||||
if (params.flags & SCAN_FLAG_USE_XPA) {
|
||||
if (session.params.flags & SCAN_FLAG_USE_XPA) {
|
||||
regs->find_reg(0x03).value |= REG03_XPASEL;
|
||||
}
|
||||
regs->state.is_xpa_on = params.flags & SCAN_FLAG_USE_XPA;
|
||||
regs->state.is_xpa_on = session.params.flags & SCAN_FLAG_USE_XPA;
|
||||
|
||||
/* R04 */
|
||||
/* monochrome / color scan */
|
||||
switch (params.depth)
|
||||
{
|
||||
switch (session.params.depth) {
|
||||
case 1:
|
||||
regs->find_reg(0x04).value &= ~REG04_BITSET;
|
||||
regs->find_reg(0x04).value |= REG04_LINEART;
|
||||
|
@ -660,8 +669,8 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
|||
regs->find_reg(0x05).value &= ~REG05_GMMENB;
|
||||
|
||||
/* true CIS gray if needed */
|
||||
if (dev->model->is_cis == SANE_TRUE && params.channels == 1
|
||||
&& dev->settings.true_gray)
|
||||
if (dev->model->is_cis == SANE_TRUE && session.params.channels == 1 &&
|
||||
dev->settings.true_gray)
|
||||
{
|
||||
regs->find_reg(0x05).value |= REG05_LEDADD;
|
||||
}
|
||||
|
@ -682,8 +691,7 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
|||
{
|
||||
/* reset count of dummy lines to zero */
|
||||
regs->find_reg(0x1e).value &= ~REG1E_LINESEL;
|
||||
if (params.xres >= 1200)
|
||||
{
|
||||
if (session.params.xres >= 1200) {
|
||||
/* there must be one dummy line */
|
||||
regs->find_reg(0x1e).value |= 1 & REG1E_LINESEL;
|
||||
|
||||
|
@ -704,19 +712,20 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
|||
regs->find_reg(0x24).value = motor->steps1;
|
||||
|
||||
/* scanned area height must be enlarged by max color shift needed */
|
||||
max_shift=sanei_genesys_compute_max_shift(dev,params.channels, params.yres, 0);
|
||||
max_shift = sanei_genesys_compute_max_shift(dev, session.params.channels,
|
||||
session.params.yres, 0);
|
||||
|
||||
/* we adjust linecnt according to real motor dpi */
|
||||
linecnt = (linecnt * motor->ydpi) / params.yres + max_shift;
|
||||
linecnt = (linecnt * motor->ydpi) / session.params.yres + max_shift;
|
||||
|
||||
/* at QUATER_STEP lines are 'staggered' and need correction */
|
||||
stagger = 0;
|
||||
if (ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) {
|
||||
/* for HP3670, stagger happens only at >=1200 dpi */
|
||||
if ((dev->model->motor_type != MOTOR_HP3670 && dev->model->motor_type != MOTOR_HP2400)
|
||||
|| params.yres >= (unsigned) sensor.optical_res)
|
||||
if ((dev->model->motor_type != MOTOR_HP3670 && dev->model->motor_type != MOTOR_HP2400)
|
||||
|| session.params.yres >= (unsigned) sensor.optical_res)
|
||||
{
|
||||
stagger = (4 * params.yres) / dev->motor.base_ydpi;
|
||||
stagger = (4 * session.params.yres) / dev->motor.base_ydpi;
|
||||
}
|
||||
}
|
||||
linecnt += stagger;
|
||||
|
@ -729,7 +738,7 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
|||
if (dev->model->is_cis == SANE_TRUE)
|
||||
{
|
||||
regs->set24(REG_LINCNT, linecnt * 3);
|
||||
linecnt *= params.channels;
|
||||
linecnt *= session.params.channels;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -746,9 +755,8 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
|||
/* words_per_line must be computed according to the scan's resolution */
|
||||
/* in fact, words_per_line _gives_ the actual scan resolution */
|
||||
words_per_line = (((endx - startx) * sensor_mst->xdpi) / sensor.optical_res);
|
||||
bpp=params.depth/8;
|
||||
if (params.depth == 1)
|
||||
{
|
||||
bpp = session.params.depth/8;
|
||||
if (session.params.depth == 1) {
|
||||
words_per_line = (words_per_line+7)/8 ;
|
||||
bpp=1;
|
||||
}
|
||||
|
@ -757,7 +765,7 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
|||
words_per_line *= bpp;
|
||||
}
|
||||
dev->bpl = words_per_line;
|
||||
words_per_line *= params.channels;
|
||||
words_per_line *= session.params.channels;
|
||||
dev->wpl = words_per_line;
|
||||
|
||||
DBG(DBG_info, "%s: wpl=%d\n", __func__, words_per_line);
|
||||
|
@ -921,9 +929,8 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
|||
|
||||
/* we must use a round number of words_per_line */
|
||||
requested_buffer_size = 8 * words_per_line;
|
||||
read_buffer_size =
|
||||
2 * requested_buffer_size +
|
||||
((max_shift + stagger) * params.pixels * params.channels * params.depth) / 8;
|
||||
read_buffer_size = 2 * requested_buffer_size +
|
||||
((max_shift + stagger) * session.params.pixels * session.params.channels * session.params.depth) / 8;
|
||||
|
||||
dev->read_buffer.clear();
|
||||
dev->read_buffer.alloc(read_buffer_size);
|
||||
|
@ -935,7 +942,7 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
|||
dev->shrink_buffer.alloc(requested_buffer_size);
|
||||
|
||||
dev->out_buffer.clear();
|
||||
dev->out_buffer.alloc(8 * params.pixels * params.channels * bpp);
|
||||
dev->out_buffer.alloc(8 * session.params.pixels * session.params.channels * bpp);
|
||||
|
||||
/* scan bytes to read */
|
||||
dev->read_bytes_left = words_per_line * linecnt;
|
||||
|
@ -943,7 +950,7 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
|||
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
||||
dev->read_active = SANE_TRUE;
|
||||
|
||||
dev->session.params = params;
|
||||
dev->session = session;
|
||||
dev->current_setup.pixels =
|
||||
((endx - startx) * sensor_mst->xdpi) / sensor.optical_res;
|
||||
dev->current_setup.lines = linecnt;
|
||||
|
@ -957,18 +964,18 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
|||
* total_bytes_read is the number of bytes sent to frontend
|
||||
* read_bytes_left is the number of bytes to read from the scanner
|
||||
*/
|
||||
dev->total_bytes_read = 0;
|
||||
if (params.depth == 1) {
|
||||
dev->total_bytes_to_read = ((params.pixels * params.lines) / 8 +
|
||||
(((params.pixels * params.lines) % 8) ? 1 : 0)) * params.channels;
|
||||
dev->total_bytes_read = 0;
|
||||
if (session.params.depth == 1) {
|
||||
dev->total_bytes_to_read = ((session.params.pixels * session.params.lines) / 8 +
|
||||
(((session.params.pixels * session.params.lines) % 8) ? 1 : 0)) * session.params.channels;
|
||||
} else {
|
||||
dev->total_bytes_to_read = params.pixels * params.lines * params.channels * bpp;
|
||||
dev->total_bytes_to_read = session.params.pixels * session.params.lines * session.params.channels * bpp;
|
||||
}
|
||||
|
||||
/* select color filter based on settings */
|
||||
regs->find_reg(0x04).value &= ~REG04_FILTER;
|
||||
if (params.channels == 1) {
|
||||
switch (params.color_filter) {
|
||||
if (session.params.channels == 1) {
|
||||
switch (session.params.color_filter) {
|
||||
case ColorFilter::RED:
|
||||
regs->find_reg(0x04).value |= 0x04;
|
||||
break;
|
||||
|
@ -2384,28 +2391,29 @@ static void setup_for_scan(Genesys_Device* dev,
|
|||
}
|
||||
start = (start * sensor.optical_res) / MM_PER_INCH;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = settings.xres;
|
||||
params.yres = settings.yres;
|
||||
params.startx = start;
|
||||
params.starty = move;
|
||||
params.pixels = settings.pixels;
|
||||
params.lines = settings.lines;
|
||||
params.depth = depth;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = settings.scan_mode;
|
||||
params.color_filter = settings.color_filter;
|
||||
params.flags = 0;
|
||||
ScanSession session;
|
||||
session.params.xres = settings.xres;
|
||||
session.params.yres = settings.yres;
|
||||
session.params.startx = start;
|
||||
session.params.starty = move;
|
||||
session.params.pixels = settings.pixels;
|
||||
session.params.lines = settings.lines;
|
||||
session.params.depth = depth;
|
||||
session.params.channels = channels;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = settings.scan_mode;
|
||||
session.params.color_filter = settings.color_filter;
|
||||
session.params.flags = 0;
|
||||
if (settings.scan_method == ScanMethod::TRANSPARENCY) {
|
||||
params.flags |= SCAN_FLAG_USE_XPA;
|
||||
session.params.flags |= SCAN_FLAG_USE_XPA;
|
||||
}
|
||||
gl646_compute_session(dev, session, sensor);
|
||||
|
||||
uint16_t slope_table0[256] = {};
|
||||
uint16_t slope_table1[256] = {};
|
||||
|
||||
// set up correct values for scan (gamma and shading enabled)
|
||||
gl646_setup_registers(dev, sensor, regs, params, slope_table0, slope_table1, xcorrection);
|
||||
gl646_setup_registers(dev, sensor, regs, session, slope_table0, slope_table1, xcorrection);
|
||||
|
||||
// send computed slope tables
|
||||
gl646_send_slope_table(dev, 0, slope_table0, regs->get8(0x21));
|
||||
|
|
|
@ -195,18 +195,6 @@ static void setup_for_scan(Genesys_Device* device,
|
|||
SANE_Bool xcorrection,
|
||||
SANE_Bool ycorrection);
|
||||
|
||||
/**
|
||||
* sets up the registers for a scan corresponding to the settings.
|
||||
* Builds motor slope tables. Computes buffer sizes and data amount to
|
||||
* transfer. It also sets up analog frontend.
|
||||
* */
|
||||
static void gl646_setup_registers(Genesys_Device* dev,
|
||||
const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set* regs, SetupParams& params,
|
||||
uint16_t* slope_table1,
|
||||
uint16_t* slope_table2,
|
||||
bool xcorrection);
|
||||
|
||||
/**
|
||||
* Does a simple move of the given distance by doing a scan at lowest resolution
|
||||
* shading correction. Memory for data is allocated in this function
|
||||
|
|
|
@ -1760,13 +1760,23 @@ int scan_step_type=0;
|
|||
return scan_step_type;
|
||||
}
|
||||
|
||||
static void gl841_compute_session(Genesys_Device* dev, ScanSession& s,
|
||||
const Genesys_Sensor& sensor)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
(void) sensor;
|
||||
(void) dev;
|
||||
s.params.assert_valid();
|
||||
s.computed = true;
|
||||
}
|
||||
|
||||
// set up registers for an actual scan this function sets up the scanner to scan in normal or single
|
||||
// line mode
|
||||
static void gl841_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set* reg, SetupParams& params)
|
||||
Genesys_Register_Set* reg, ScanSession& session)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
params.assert_valid();
|
||||
session.assert_computed();
|
||||
|
||||
int used_res;
|
||||
int start, used_pixels;
|
||||
|
@ -1788,7 +1798,7 @@ static void gl841_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
int optical_res;
|
||||
unsigned int oflags; /**> optical flags */
|
||||
|
||||
debug_dump(DBG_info, params);
|
||||
debug_dump(DBG_info, session.params);
|
||||
|
||||
/*
|
||||
results:
|
||||
|
@ -1819,7 +1829,7 @@ independent of our calculated values:
|
|||
*/
|
||||
|
||||
/* 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(params.xres);
|
||||
unsigned ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(session.params.xres);
|
||||
|
||||
/* optical_res */
|
||||
|
||||
|
@ -1828,20 +1838,21 @@ independent of our calculated values:
|
|||
/* stagger */
|
||||
|
||||
if (ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) {
|
||||
stagger = (4 * params.yres) / dev->motor.base_ydpi;
|
||||
stagger = (4 * session.params.yres) / dev->motor.base_ydpi;
|
||||
} else {
|
||||
stagger = 0;
|
||||
}
|
||||
DBG(DBG_info, "%s : stagger=%d lines\n", __func__, stagger);
|
||||
|
||||
/* used_res */
|
||||
i = optical_res / params.xres;
|
||||
i = optical_res / session.params.xres;
|
||||
|
||||
/* gl841 supports 1/1 1/2 1/3 1/4 1/5 1/6 1/8 1/10 1/12 1/15 averaging */
|
||||
|
||||
if (i < 2 || (params.flags & SCAN_FLAG_USE_OPTICAL_RES)) /* optical_res >= xres > optical_res/2 */
|
||||
used_res = optical_res;
|
||||
else if (i < 3) /* optical_res/2 >= xres > optical_res/3 */
|
||||
if (i < 2 || (session.params.flags & SCAN_FLAG_USE_OPTICAL_RES)) {
|
||||
// optical_res >= xres > optical_res/2
|
||||
used_res = optical_res;
|
||||
} else if (i < 3) /* optical_res/2 >= xres > optical_res/3 */
|
||||
used_res = optical_res/2;
|
||||
else if (i < 4) /* optical_res/3 >= xres > optical_res/4 */
|
||||
used_res = optical_res/3;
|
||||
|
@ -1863,9 +1874,7 @@ independent of our calculated values:
|
|||
/* compute scan parameters values */
|
||||
/* pixels are allways given at half or full CCD optical resolution */
|
||||
/* use detected left margin and fixed value */
|
||||
/* start */
|
||||
/* add x coordinates */
|
||||
start = ((sensor.CCD_start_xoffset + params.startx) * used_res) / sensor.optical_res;
|
||||
start = ((sensor.CCD_start_xoffset + session.params.startx) * used_res) / sensor.optical_res;
|
||||
|
||||
/* needs to be aligned for used_res */
|
||||
start = (start * optical_res) / used_res;
|
||||
|
@ -1886,12 +1895,12 @@ independent of our calculated values:
|
|||
}
|
||||
|
||||
/* compute correct pixels number */
|
||||
/* pixels */
|
||||
used_pixels = (params.pixels * optical_res) / params.xres;
|
||||
used_pixels = (session.params.pixels * optical_res) / session.params.xres;
|
||||
|
||||
/* round up pixels number if needed */
|
||||
if (used_pixels * params.xres < params.pixels * optical_res)
|
||||
used_pixels++;
|
||||
if (used_pixels * session.params.xres < session.params.pixels * optical_res) {
|
||||
used_pixels++;
|
||||
}
|
||||
|
||||
/* dummy */
|
||||
/* dummy lines: may not be usefull, for instance 250 dpi works with 0 or 1
|
||||
|
@ -1923,14 +1932,15 @@ dummy \ scanned lines
|
|||
/* slope_dpi */
|
||||
/* cis color scan is effectively a gray scan with 3 gray lines per color
|
||||
line and a FILTER of 0 */
|
||||
if (dev->model->is_cis)
|
||||
slope_dpi = params.yres* params.channels;
|
||||
else
|
||||
slope_dpi = params.yres;
|
||||
if (dev->model->is_cis) {
|
||||
slope_dpi = session.params.yres* session.params.channels;
|
||||
} else {
|
||||
slope_dpi = session.params.yres;
|
||||
}
|
||||
|
||||
slope_dpi = slope_dpi * (1 + dummy);
|
||||
|
||||
scan_step_type = gl841_scan_step_type(dev, params.yres);
|
||||
scan_step_type = gl841_scan_step_type(dev, session.params.yres);
|
||||
exposure_time = gl841_exposure_time(dev, sensor,
|
||||
slope_dpi,
|
||||
scan_step_type,
|
||||
|
@ -1942,43 +1952,37 @@ dummy \ scanned lines
|
|||
/*** optical parameters ***/
|
||||
/* in case of dynamic lineart, we use an internal 8 bit gray scan
|
||||
* to generate 1 lineart data */
|
||||
if(params.flags & SCAN_FLAG_DYNAMIC_LINEART)
|
||||
{
|
||||
params.depth=8;
|
||||
if (session.params.flags & SCAN_FLAG_DYNAMIC_LINEART) {
|
||||
session.params.depth = 8;
|
||||
}
|
||||
|
||||
oflags=0;
|
||||
if (params.flags & SCAN_FLAG_DISABLE_SHADING)
|
||||
{
|
||||
oflags |= OPTICAL_FLAG_DISABLE_SHADING;
|
||||
if (session.params.flags & SCAN_FLAG_DISABLE_SHADING) {
|
||||
oflags |= OPTICAL_FLAG_DISABLE_SHADING;
|
||||
}
|
||||
if ((params.flags & SCAN_FLAG_DISABLE_GAMMA) || (params.depth==16))
|
||||
{
|
||||
oflags |= OPTICAL_FLAG_DISABLE_GAMMA;
|
||||
if ((session.params.flags & SCAN_FLAG_DISABLE_GAMMA) || (session.params.depth == 16)) {
|
||||
oflags |= OPTICAL_FLAG_DISABLE_GAMMA;
|
||||
}
|
||||
if (params.flags & SCAN_FLAG_DISABLE_LAMP)
|
||||
{
|
||||
oflags |= OPTICAL_FLAG_DISABLE_LAMP;
|
||||
if (session.params.flags & SCAN_FLAG_DISABLE_LAMP) {
|
||||
oflags |= OPTICAL_FLAG_DISABLE_LAMP;
|
||||
}
|
||||
if (params.flags & SCAN_FLAG_ENABLE_LEDADD)
|
||||
{
|
||||
oflags |= OPTICAL_FLAG_ENABLE_LEDADD;
|
||||
if (session.params.flags & SCAN_FLAG_ENABLE_LEDADD) {
|
||||
oflags |= OPTICAL_FLAG_ENABLE_LEDADD;
|
||||
}
|
||||
|
||||
gl841_init_optical_regs_scan(dev, sensor, reg, exposure_time, used_res, start, used_pixels,
|
||||
params.channels, params.depth, ccd_size_divisor,
|
||||
params.color_filter, oflags);
|
||||
session.params.channels, session.params.depth, ccd_size_divisor,
|
||||
session.params.color_filter, oflags);
|
||||
|
||||
/*** motor parameters ***/
|
||||
|
||||
/* scanned area must be enlarged by max color shift needed */
|
||||
max_shift=sanei_genesys_compute_max_shift(dev, params.channels,params.yres,params.flags);
|
||||
// scanned area must be enlarged by max color shift needed */
|
||||
max_shift = sanei_genesys_compute_max_shift(dev, session.params.channels,
|
||||
session.params.yres, session.params.flags);
|
||||
|
||||
/* lincnt */
|
||||
lincnt = params.lines + max_shift + stagger;
|
||||
lincnt = session.params.lines + max_shift + stagger;
|
||||
|
||||
/* add tl_y to base movement */
|
||||
move = params.starty;
|
||||
move = session.params.starty;
|
||||
DBG(DBG_info, "%s: move=%d steps\n", __func__, move);
|
||||
|
||||
/* subtract current head position */
|
||||
|
@ -1993,14 +1997,14 @@ dummy \ scanned lines
|
|||
/* move = ((move + dummy) / (dummy + 1)) * (dummy + 1);
|
||||
DBG(DBG_info, "%s: move=%d steps\n", __func__, move);*/
|
||||
|
||||
if (params.flags & SCAN_FLAG_SINGLE_LINE) {
|
||||
gl841_init_motor_regs_off(reg, dev->model->is_cis?lincnt* params.channels:lincnt);
|
||||
if (session.params.flags & SCAN_FLAG_SINGLE_LINE) {
|
||||
gl841_init_motor_regs_off(reg, dev->model->is_cis?lincnt* session.params.channels:lincnt);
|
||||
} else {
|
||||
gl841_init_motor_regs_scan(dev, sensor, reg, exposure_time, slope_dpi, scan_step_type,
|
||||
dev->model->is_cis?lincnt* params.channels:lincnt,
|
||||
dev->model->is_cis ? lincnt * session.params.channels : lincnt,
|
||||
dummy, move, scan_power_mode,
|
||||
(params.flags & SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE)?
|
||||
MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE:0);
|
||||
(session.params.flags & SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE) ?
|
||||
MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE : 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2009,17 +2013,16 @@ dummy \ scanned lines
|
|||
|
||||
/* words_per_line */
|
||||
bytes_per_line = (used_pixels * used_res) / optical_res;
|
||||
bytes_per_line = (bytes_per_line * params.channels * params.depth) / 8;
|
||||
bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8;
|
||||
|
||||
requested_buffer_size = 8 * bytes_per_line;
|
||||
/* we must use a round number of bytes_per_line */
|
||||
if (requested_buffer_size > sanei_genesys_get_bulk_max_size(dev))
|
||||
requested_buffer_size =
|
||||
(sanei_genesys_get_bulk_max_size(dev) / bytes_per_line) * bytes_per_line;
|
||||
if (requested_buffer_size > sanei_genesys_get_bulk_max_size(dev)) {
|
||||
requested_buffer_size = (sanei_genesys_get_bulk_max_size(dev) / bytes_per_line) * bytes_per_line;
|
||||
}
|
||||
|
||||
read_buffer_size =
|
||||
2 * requested_buffer_size +
|
||||
((max_shift + stagger) * used_pixels * params.channels * params.depth) / 8;
|
||||
read_buffer_size = 2 * requested_buffer_size +
|
||||
((max_shift + stagger) * used_pixels * session.params.channels * session.params.depth) / 8;
|
||||
|
||||
dev->read_buffer.clear();
|
||||
dev->read_buffer.alloc(read_buffer_size);
|
||||
|
@ -2031,14 +2034,14 @@ dummy \ scanned lines
|
|||
dev->shrink_buffer.alloc(requested_buffer_size);
|
||||
|
||||
dev->out_buffer.clear();
|
||||
dev->out_buffer.alloc((8 * dev->settings.pixels * params.channels * params.depth) / 8);
|
||||
dev->out_buffer.alloc((8 * dev->settings.pixels * session.params.channels * session.params.depth) / 8);
|
||||
|
||||
dev->read_bytes_left = bytes_per_line * lincnt;
|
||||
|
||||
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
||||
dev->read_active = SANE_TRUE;
|
||||
|
||||
dev->session.params = params;
|
||||
dev->session = session;
|
||||
dev->current_setup.pixels = (used_pixels * used_res)/optical_res;
|
||||
dev->current_setup.lines = lincnt;
|
||||
dev->current_setup.exposure_time = exposure_time;
|
||||
|
@ -2063,14 +2066,13 @@ dummy \ scanned lines
|
|||
*/
|
||||
|
||||
dev->total_bytes_read = 0;
|
||||
if (params.depth == 1)
|
||||
dev->total_bytes_to_read =
|
||||
((dev->settings.pixels * dev->settings.lines) / 8 +
|
||||
(((dev->settings.pixels * dev->settings.lines)%8)?1:0)
|
||||
) * params.channels;
|
||||
else
|
||||
dev->total_bytes_to_read =
|
||||
dev->settings.pixels * dev->settings.lines * params.channels * (params.depth / 8);
|
||||
if (session.params.depth == 1) {
|
||||
dev->total_bytes_to_read = ((dev->settings.pixels * dev->settings.lines) / 8 +
|
||||
(((dev->settings.pixels * dev->settings.lines)%8)?1:0)) * session.params.channels;
|
||||
} else {
|
||||
dev->total_bytes_to_read =
|
||||
dev->settings.pixels * dev->settings.lines * session.params.channels * (session.params.depth / 8);
|
||||
}
|
||||
|
||||
DBG(DBG_info, "%s: total bytes to send = %lu\n", __func__, (u_long) dev->total_bytes_to_read);
|
||||
/* END TODO */
|
||||
|
@ -2118,25 +2120,25 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se
|
|||
|
||||
start = (start * sensor.optical_res) / MM_PER_INCH;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dev->settings.xres;
|
||||
params.yres = dev->settings.yres;
|
||||
params.startx = start;
|
||||
params.starty = 0; // not used
|
||||
params.pixels = dev->settings.pixels;
|
||||
params.lines = dev->settings.lines;
|
||||
params.depth = depth;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = dev->settings.scan_mode;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = 0;
|
||||
ScanSession session;
|
||||
session.params.xres = dev->settings.xres;
|
||||
session.params.yres = dev->settings.yres;
|
||||
session.params.startx = start;
|
||||
session.params.starty = 0; // not used
|
||||
session.params.pixels = dev->settings.pixels;
|
||||
session.params.lines = dev->settings.lines;
|
||||
session.params.depth = depth;
|
||||
session.params.channels = 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 = 0;
|
||||
|
||||
DBG(DBG_info, "%s ", __func__);
|
||||
debug_dump(DBG_info, params);
|
||||
debug_dump(DBG_info, session.params);
|
||||
|
||||
/* 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(params.xres);
|
||||
unsigned ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(session.params.xres);
|
||||
|
||||
/* optical_res */
|
||||
|
||||
|
@ -2145,14 +2147,14 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se
|
|||
/* stagger */
|
||||
|
||||
if (ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) {
|
||||
stagger = (4 * params.yres) / dev->motor.base_ydpi;
|
||||
stagger = (4 * session.params.yres) / dev->motor.base_ydpi;
|
||||
} else {
|
||||
stagger = 0;
|
||||
}
|
||||
DBG(DBG_info, "%s: stagger=%d lines\n", __func__, stagger);
|
||||
|
||||
/* used_res */
|
||||
i = optical_res / params.xres;
|
||||
i = optical_res / session.params.xres;
|
||||
|
||||
/* gl841 supports 1/1 1/2 1/3 1/4 1/5 1/6 1/8 1/10 1/12 1/15 averaging */
|
||||
|
||||
|
@ -2180,7 +2182,7 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se
|
|||
/* compute scan parameters values */
|
||||
/* pixels are allways given at half or full CCD optical resolution */
|
||||
/* use detected left margin and fixed value */
|
||||
start = ((sensor.CCD_start_xoffset + params.startx) * used_res) / sensor.optical_res;
|
||||
start = ((sensor.CCD_start_xoffset + session.params.startx) * used_res) / sensor.optical_res;
|
||||
|
||||
/* needs to be aligned for used_res */
|
||||
start = (start * optical_res) / used_res;
|
||||
|
@ -2191,10 +2193,10 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se
|
|||
start |= 1;
|
||||
}
|
||||
|
||||
used_pixels = (params.pixels * optical_res) / params.xres;
|
||||
used_pixels = (session.params.pixels * optical_res) / session.params.xres;
|
||||
|
||||
// round up pixels number if needed
|
||||
if (used_pixels * params.xres < params.pixels * optical_res) {
|
||||
if (used_pixels * session.params.xres < session.params.pixels * optical_res) {
|
||||
used_pixels++;
|
||||
}
|
||||
|
||||
|
@ -2227,14 +2229,14 @@ dummy \ scanned lines
|
|||
/* cis color scan is effectively a gray scan with 3 gray lines per color
|
||||
line and a FILTER of 0 */
|
||||
if (dev->model->is_cis) {
|
||||
slope_dpi = params.yres * params.channels;
|
||||
slope_dpi = session.params.yres * session.params.channels;
|
||||
} else {
|
||||
slope_dpi = params.yres;
|
||||
slope_dpi = session.params.yres;
|
||||
}
|
||||
|
||||
slope_dpi = slope_dpi * (1 + dummy);
|
||||
|
||||
scan_step_type = gl841_scan_step_type(dev, params.yres);
|
||||
scan_step_type = gl841_scan_step_type(dev, session.params.yres);
|
||||
exposure_time = gl841_exposure_time(dev, sensor,
|
||||
slope_dpi,
|
||||
scan_step_type,
|
||||
|
@ -2244,11 +2246,12 @@ dummy \ scanned lines
|
|||
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
|
||||
|
||||
/* scanned area must be enlarged by max color shift needed */
|
||||
max_shift = sanei_genesys_compute_max_shift(dev, params.channels, params.yres, 0);
|
||||
max_shift = sanei_genesys_compute_max_shift(dev, session.params.channels,
|
||||
session.params.yres, 0);
|
||||
|
||||
lincnt = params.lines + max_shift + stagger;
|
||||
lincnt = session.params.lines + max_shift + stagger;
|
||||
|
||||
dev->session.params = params;
|
||||
dev->session = session;
|
||||
dev->current_setup.pixels = (used_pixels * used_res)/optical_res;
|
||||
dev->current_setup.lines = lincnt;
|
||||
dev->current_setup.exposure_time = exposure_time;
|
||||
|
@ -2941,24 +2944,25 @@ static void gl841_search_start_position(Genesys_Device* dev)
|
|||
// whith employ different sensors with potentially different settings.
|
||||
auto& sensor = sanei_genesys_find_sensor_for_write(dev, dpi, ScanMethod::FLATBED);
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dpi;
|
||||
params.yres = dpi;
|
||||
params.startx = 0;
|
||||
params.starty = 0; /*we should give a small offset here~60 steps*/
|
||||
params.pixels = 600;
|
||||
params.lines = dev->model->search_lines;
|
||||
params.depth = 8;
|
||||
params.channels = 1;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::GRAY;
|
||||
params.color_filter = ColorFilter::GREEN;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE |
|
||||
SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE;
|
||||
ScanSession session;
|
||||
session.params.xres = dpi;
|
||||
session.params.yres = dpi;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0; /*we should give a small offset here~60 steps*/
|
||||
session.params.pixels = 600;
|
||||
session.params.lines = dev->model->search_lines;
|
||||
session.params.depth = 8;
|
||||
session.params.channels = 1;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::GRAY;
|
||||
session.params.color_filter = ColorFilter::GREEN;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE |
|
||||
SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE;
|
||||
gl841_compute_session(dev, session, sensor);
|
||||
|
||||
gl841_init_scan_regs(dev, sensor, &local_reg, params);
|
||||
gl841_init_scan_regs(dev, sensor, &local_reg, session);
|
||||
|
||||
// send to scanner
|
||||
dev->write_registers(local_reg);
|
||||
|
@ -3009,24 +3013,25 @@ static void gl841_init_regs_for_coarse_calibration(Genesys_Device* dev,
|
|||
channels = 1;
|
||||
}
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dev->settings.xres;
|
||||
params.yres = dev->settings.yres;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel();
|
||||
params.lines = 20;
|
||||
params.depth = 16;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = dev->settings.scan_mode;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = dev->settings.xres;
|
||||
session.params.yres = dev->settings.yres;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel();
|
||||
session.params.lines = 20;
|
||||
session.params.depth = 16;
|
||||
session.params.channels = 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 = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl841_compute_session(dev, session, sensor);
|
||||
|
||||
gl841_init_scan_regs(dev, sensor, ®s, params);
|
||||
gl841_init_scan_regs(dev, sensor, ®s, session);
|
||||
|
||||
DBG(DBG_info, "%s: optical sensor res: %d dpi, actual res: %d\n", __func__,
|
||||
sensor.optical_res / sensor.ccd_pixels_per_system_pixel(), dev->settings.xres);
|
||||
|
@ -3073,25 +3078,26 @@ static void gl841_init_regs_for_shading(Genesys_Device* dev, const Genesys_Senso
|
|||
dev->calib_channels = 3;
|
||||
dev->calib_lines = dev->model->shading_lines;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dev->settings.xres;
|
||||
params.yres = ydpi;
|
||||
params.startx = 0;
|
||||
params.starty = starty;
|
||||
params.pixels = (sensor.sensor_pixels * dev->settings.xres) / sensor.optical_res;
|
||||
params.lines = dev->calib_lines;
|
||||
params.depth = 16;
|
||||
params.channels = dev->calib_channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_USE_OPTICAL_RES |
|
||||
/*SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE |*/
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = dev->settings.xres;
|
||||
session.params.yres = ydpi;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = starty;
|
||||
session.params.pixels = (sensor.sensor_pixels * dev->settings.xres) / sensor.optical_res;
|
||||
session.params.lines = dev->calib_lines;
|
||||
session.params.depth = 16;
|
||||
session.params.channels = dev->calib_channels;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
session.params.color_filter = dev->settings.color_filter;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_USE_OPTICAL_RES |
|
||||
/*SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE |*/
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl841_compute_session(dev, session, sensor);
|
||||
|
||||
gl841_init_scan_regs(dev, sensor, ®s, params);
|
||||
gl841_init_scan_regs(dev, sensor, ®s, session);
|
||||
|
||||
dev->calib_pixels = dev->current_setup.pixels;
|
||||
dev->scanhead_position_in_steps += dev->calib_lines + starty;
|
||||
|
@ -3192,21 +3198,22 @@ static void gl841_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor&
|
|||
flags |= SCAN_FLAG_DYNAMIC_LINEART;
|
||||
}
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dev->settings.xres;
|
||||
params.yres = dev->settings.yres;
|
||||
params.startx = start;
|
||||
params.starty = move;
|
||||
params.pixels = dev->settings.pixels;
|
||||
params.lines = dev->settings.lines;
|
||||
params.depth = depth;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = dev->settings.scan_mode;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = flags;
|
||||
ScanSession session;
|
||||
session.params.xres = dev->settings.xres;
|
||||
session.params.yres = dev->settings.yres;
|
||||
session.params.startx = start;
|
||||
session.params.starty = move;
|
||||
session.params.pixels = dev->settings.pixels;
|
||||
session.params.lines = dev->settings.lines;
|
||||
session.params.depth = depth;
|
||||
session.params.channels = 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;
|
||||
gl841_compute_session(dev, session, sensor);
|
||||
|
||||
gl841_init_scan_regs(dev, sensor, &dev->reg, params);
|
||||
gl841_init_scan_regs(dev, sensor, &dev->reg, session);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3268,25 +3275,26 @@ static void gl841_led_calibration(Genesys_Device* dev, Genesys_Sensor& sensor,
|
|||
/* offset calibration is always done in color mode */
|
||||
channels = 3;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dev->settings.xres;
|
||||
params.yres = dev->settings.yres;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = (sensor.sensor_pixels*dev->settings.xres) / sensor.optical_res;
|
||||
params.lines = 1;
|
||||
params.depth = 16;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE |
|
||||
SCAN_FLAG_USE_OPTICAL_RES;
|
||||
ScanSession session;
|
||||
session.params.xres = dev->settings.xres;
|
||||
session.params.yres = dev->settings.yres;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = (sensor.sensor_pixels*dev->settings.xres) / sensor.optical_res;
|
||||
session.params.lines = 1;
|
||||
session.params.depth = 16;
|
||||
session.params.channels = channels;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
session.params.color_filter = dev->settings.color_filter;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE |
|
||||
SCAN_FLAG_USE_OPTICAL_RES;
|
||||
gl841_compute_session(dev, session, sensor);
|
||||
|
||||
gl841_init_scan_regs(dev, sensor, ®s, params);
|
||||
gl841_init_scan_regs(dev, sensor, ®s, session);
|
||||
|
||||
dev->write_registers(regs);
|
||||
|
||||
|
@ -3461,25 +3469,26 @@ static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
|
|||
return;
|
||||
}
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dev->settings.xres;
|
||||
params.yres = dev->settings.yres;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = (sensor.sensor_pixels*dev->settings.xres) / sensor.optical_res;
|
||||
params.lines = 1;
|
||||
params.depth = 8;
|
||||
params.channels = 3;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE |
|
||||
SCAN_FLAG_USE_OPTICAL_RES;
|
||||
ScanSession session;
|
||||
session.params.xres = dev->settings.xres;
|
||||
session.params.yres = dev->settings.yres;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = (sensor.sensor_pixels*dev->settings.xres) / sensor.optical_res;
|
||||
session.params.lines = 1;
|
||||
session.params.depth = 8;
|
||||
session.params.channels = 3;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
session.params.color_filter = dev->settings.color_filter;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE |
|
||||
SCAN_FLAG_USE_OPTICAL_RES;
|
||||
gl841_compute_session(dev, session, sensor);
|
||||
|
||||
gl841_init_scan_regs(dev, sensor, ®s, params);
|
||||
gl841_init_scan_regs(dev, sensor, ®s, session);
|
||||
|
||||
num_pixels = dev->current_setup.pixels;
|
||||
total_size = num_pixels * 3 * 2 * 1;
|
||||
|
@ -3578,26 +3587,27 @@ static void gl841_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
|
|||
/* offset calibration is always done in color mode */
|
||||
channels = 3;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dev->settings.xres;
|
||||
params.yres = dev->settings.yres;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = (sensor.sensor_pixels*dev->settings.xres) / sensor.optical_res;
|
||||
params.lines = 1;
|
||||
params.depth = 16;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE |
|
||||
SCAN_FLAG_USE_OPTICAL_RES |
|
||||
SCAN_FLAG_DISABLE_LAMP;
|
||||
ScanSession session;
|
||||
session.params.xres = dev->settings.xres;
|
||||
session.params.yres = dev->settings.yres;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = (sensor.sensor_pixels*dev->settings.xres) / sensor.optical_res;
|
||||
session.params.lines = 1;
|
||||
session.params.depth = 16;
|
||||
session.params.channels = channels;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
session.params.color_filter = dev->settings.color_filter;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE |
|
||||
SCAN_FLAG_USE_OPTICAL_RES |
|
||||
SCAN_FLAG_DISABLE_LAMP;
|
||||
gl841_compute_session(dev, session, sensor);
|
||||
|
||||
gl841_init_scan_regs(dev, sensor, ®s, params);
|
||||
gl841_init_scan_regs(dev, sensor, ®s, session);
|
||||
|
||||
num_pixels = dev->current_setup.pixels;
|
||||
|
||||
|
@ -3938,25 +3948,26 @@ static void gl841_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen
|
|||
/* coarse gain calibration is allways done in color mode */
|
||||
channels = 3;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dev->settings.xres;
|
||||
params.yres = dev->settings.yres;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = (sensor.sensor_pixels*dev->settings.xres) / sensor.optical_res;
|
||||
params.lines = lines;
|
||||
params.depth = 16;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE |
|
||||
SCAN_FLAG_USE_OPTICAL_RES;
|
||||
ScanSession session;
|
||||
session.params.xres = dev->settings.xres;
|
||||
session.params.yres = dev->settings.yres;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = (sensor.sensor_pixels*dev->settings.xres) / sensor.optical_res;
|
||||
session.params.lines = lines;
|
||||
session.params.depth = 16;
|
||||
session.params.channels = channels;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
session.params.color_filter = dev->settings.color_filter;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE |
|
||||
SCAN_FLAG_USE_OPTICAL_RES;
|
||||
gl841_compute_session(dev, session, sensor);
|
||||
|
||||
gl841_init_scan_regs(dev, sensor, ®s, params);
|
||||
gl841_init_scan_regs(dev, sensor, ®s, session);
|
||||
|
||||
dev->write_registers(regs);
|
||||
|
||||
|
@ -4083,29 +4094,30 @@ static void gl841_init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor
|
|||
dev->frontend.set_offset(1, 0x80);
|
||||
dev->frontend.set_offset(2, 0x80);
|
||||
|
||||
SetupParams params;
|
||||
params.xres = sensor.optical_res;
|
||||
params.yres = dev->settings.yres;
|
||||
params.startx = sensor.dummy_pixel;
|
||||
params.starty = 0;
|
||||
params.pixels = num_pixels;
|
||||
params.lines = 1;
|
||||
params.depth = 16;
|
||||
params.channels = *channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
if (*channels == 3) {
|
||||
params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
} else {
|
||||
params.scan_mode = ScanColorMode::GRAY;
|
||||
}
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE |
|
||||
SCAN_FLAG_USE_OPTICAL_RES;
|
||||
ScanSession session;
|
||||
session.params.xres = sensor.optical_res;
|
||||
session.params.yres = dev->settings.yres;
|
||||
session.params.startx = sensor.dummy_pixel;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = num_pixels;
|
||||
session.params.lines = 1;
|
||||
session.params.depth = 16;
|
||||
session.params.channels = *channels;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
if (*channels == 3) {
|
||||
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
} else {
|
||||
session.params.scan_mode = ScanColorMode::GRAY;
|
||||
}
|
||||
session.params.color_filter = dev->settings.color_filter;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE |
|
||||
SCAN_FLAG_USE_OPTICAL_RES;
|
||||
gl841_compute_session(dev, session, sensor);
|
||||
|
||||
gl841_init_scan_regs(dev, sensor, local_reg, params);
|
||||
gl841_init_scan_regs(dev, sensor, local_reg, session);
|
||||
|
||||
num_pixels = dev->current_setup.pixels;
|
||||
|
||||
|
@ -4241,25 +4253,26 @@ static void gl841_init(Genesys_Device* dev)
|
|||
Genesys_Register_Set& regs = dev->calib_reg;
|
||||
regs = dev->reg;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = 300;
|
||||
params.yres = 300;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = (16 * 300) / sensor.optical_res;
|
||||
params.lines = 1;
|
||||
params.depth = 16;
|
||||
params.channels = 3;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
params.color_filter = ColorFilter::RED;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE |
|
||||
SCAN_FLAG_USE_OPTICAL_RES;
|
||||
ScanSession session;
|
||||
session.params.xres = 300;
|
||||
session.params.yres = 300;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = (16 * 300) / sensor.optical_res;
|
||||
session.params.lines = 1;
|
||||
session.params.depth = 16;
|
||||
session.params.channels = 3;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
session.params.color_filter = ColorFilter::RED;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE |
|
||||
SCAN_FLAG_USE_OPTICAL_RES;
|
||||
gl841_compute_session(dev, session, sensor);
|
||||
|
||||
gl841_init_scan_regs(dev, sensor, ®s, params);
|
||||
gl841_init_scan_regs(dev, sensor, ®s, session);
|
||||
|
||||
dev->write_registers(regs);
|
||||
|
||||
|
@ -4370,21 +4383,22 @@ static void gl841_search_strip(Genesys_Device* dev, const Genesys_Sensor& sensor
|
|||
|
||||
local_reg = dev->reg;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dpi;
|
||||
params.yres = dpi;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = pixels;
|
||||
params.lines = lines;
|
||||
params.depth = depth;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::GRAY;
|
||||
params.color_filter = ColorFilter::RED;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING | SCAN_FLAG_DISABLE_GAMMA;
|
||||
ScanSession session;
|
||||
session.params.xres = dpi;
|
||||
session.params.yres = dpi;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = pixels;
|
||||
session.params.lines = lines;
|
||||
session.params.depth = depth;
|
||||
session.params.channels = channels;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::GRAY;
|
||||
session.params.color_filter = ColorFilter::RED;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING | SCAN_FLAG_DISABLE_GAMMA;
|
||||
gl841_compute_session(dev, session, sensor);
|
||||
|
||||
gl841_init_scan_regs(dev, sensor, &local_reg, params);
|
||||
gl841_init_scan_regs(dev, sensor, &local_reg, session);
|
||||
|
||||
/* set up for reverse or forward */
|
||||
r = sanei_genesys_get_address(&local_reg, 0x02);
|
||||
|
|
|
@ -1525,35 +1525,36 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
start += dev->settings.tl_x;
|
||||
start = (start * sensor.optical_res) / MM_PER_INCH;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dev->settings.xres;
|
||||
params.yres = dev->settings.yres;
|
||||
params.startx = start; // not used
|
||||
params.starty = 0; // not used
|
||||
params.pixels = dev->settings.pixels;
|
||||
params.lines = dev->settings.lines;
|
||||
params.depth = depth;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = dev->settings.scan_mode;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = 0;
|
||||
ScanSession session;
|
||||
session.params.xres = dev->settings.xres;
|
||||
session.params.yres = dev->settings.yres;
|
||||
session.params.startx = start; // not used
|
||||
session.params.starty = 0; // not used
|
||||
session.params.pixels = dev->settings.pixels;
|
||||
session.params.lines = dev->settings.lines;
|
||||
session.params.depth = depth;
|
||||
session.params.channels = 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 = 0;
|
||||
|
||||
DBG(DBG_info, "%s ", __func__);
|
||||
debug_dump(DBG_info, params);
|
||||
debug_dump(DBG_info, session.params);
|
||||
|
||||
/* optical_res */
|
||||
optical_res = sensor.optical_res / ccd_size_divisor;
|
||||
|
||||
/* stagger */
|
||||
if (ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE))
|
||||
stagger = (4 * params.yres) / dev->motor.base_ydpi;
|
||||
else
|
||||
stagger = 0;
|
||||
if (ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) {
|
||||
stagger = (4 * session.params.yres) / dev->motor.base_ydpi;
|
||||
} else {
|
||||
stagger = 0;
|
||||
}
|
||||
DBG(DBG_info, "%s: stagger=%d lines\n", __func__, stagger);
|
||||
|
||||
if (params.xres <= (unsigned) optical_res) {
|
||||
used_res = params.xres;
|
||||
if (session.params.xres <= (unsigned) optical_res) {
|
||||
used_res = session.params.xres;
|
||||
} else {
|
||||
used_res = optical_res;
|
||||
}
|
||||
|
@ -1563,7 +1564,7 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
/* use detected left margin and fixed value */
|
||||
|
||||
/* compute correct pixels number */
|
||||
used_pixels = (params.pixels * optical_res) / params.xres;
|
||||
used_pixels = (session.params.pixels * optical_res) / session.params.xres;
|
||||
DBG(DBG_info, "%s: used_pixels=%d\n", __func__, used_pixels);
|
||||
|
||||
/* exposure */
|
||||
|
@ -1574,26 +1575,24 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
DBG(DBG_info, "%s : exposure=%d pixels\n", __func__, exposure);
|
||||
|
||||
/* it seems base_dpi of the G4050 motor is changed above 600 dpi*/
|
||||
if (dev->model->motor_type == MOTOR_G4050 && params.yres>600)
|
||||
{
|
||||
if (dev->model->motor_type == MOTOR_G4050 && session.params.yres>600) {
|
||||
dev->ld_shift_r = (dev->model->ld_shift_r*3800)/dev->motor.base_ydpi;
|
||||
dev->ld_shift_g = (dev->model->ld_shift_g*3800)/dev->motor.base_ydpi;
|
||||
dev->ld_shift_b = (dev->model->ld_shift_b*3800)/dev->motor.base_ydpi;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
dev->ld_shift_r = dev->model->ld_shift_r;
|
||||
dev->ld_shift_g = dev->model->ld_shift_g;
|
||||
dev->ld_shift_b = dev->model->ld_shift_b;
|
||||
}
|
||||
|
||||
/* scanned area must be enlarged by max color shift needed */
|
||||
max_shift = sanei_genesys_compute_max_shift(dev, params.channels, params.yres, 0);
|
||||
max_shift = sanei_genesys_compute_max_shift(dev, session.params.channels,
|
||||
session.params.yres, 0);
|
||||
|
||||
/* lincnt */
|
||||
lincnt = params.lines + max_shift + stagger;
|
||||
lincnt = session.params.lines + max_shift + stagger;
|
||||
|
||||
dev->session.params = params;
|
||||
dev->session = session;
|
||||
dev->current_setup.pixels = (used_pixels * used_res) / optical_res;
|
||||
DBG(DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels);
|
||||
dev->current_setup.lines = lincnt;
|
||||
|
|
|
@ -999,13 +999,23 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
r->value = sensor.dummy_pixel;
|
||||
}
|
||||
|
||||
static void gl846_compute_session(Genesys_Device* dev, ScanSession& s,
|
||||
const Genesys_Sensor& sensor)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
(void) sensor;
|
||||
(void) dev;
|
||||
s.params.assert_valid();
|
||||
s.computed = true;
|
||||
}
|
||||
|
||||
// set up registers for an actual scan this function sets up the scanner to scan in normal or single
|
||||
// line mode
|
||||
static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set* reg, SetupParams& params)
|
||||
Genesys_Register_Set* reg, ScanSession& session)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
params.assert_valid();
|
||||
session.assert_computed();
|
||||
|
||||
int used_res;
|
||||
int start, used_pixels;
|
||||
|
@ -1026,30 +1036,28 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
|
||||
int optical_res;
|
||||
|
||||
debug_dump(DBG_info, params);
|
||||
debug_dump(DBG_info, session.params);
|
||||
|
||||
// we may have 2 domains for ccd: xres below or above half ccd max dpi
|
||||
unsigned ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(params.xres);
|
||||
unsigned ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(session.params.xres);
|
||||
|
||||
optical_res = sensor.optical_res / ccd_size_divisor;
|
||||
|
||||
/* stagger */
|
||||
if (ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) {
|
||||
stagger = (4 * params.yres) / dev->motor.base_ydpi;
|
||||
stagger = (4 * session.params.yres) / dev->motor.base_ydpi;
|
||||
} else {
|
||||
stagger = 0;
|
||||
}
|
||||
DBG(DBG_info, "%s : stagger=%d lines\n", __func__, stagger);
|
||||
|
||||
/* used_res */
|
||||
if (params.flags & SCAN_FLAG_USE_OPTICAL_RES)
|
||||
{
|
||||
if (session.params.flags & SCAN_FLAG_USE_OPTICAL_RES) {
|
||||
used_res = optical_res;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* resolution is choosen from a list */
|
||||
used_res = params.xres;
|
||||
used_res = session.params.xres;
|
||||
}
|
||||
|
||||
/* compute scan parameters values */
|
||||
|
@ -1057,28 +1065,30 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
/* use detected left margin and fixed value */
|
||||
/* start */
|
||||
/* add x coordinates */
|
||||
start = params.startx;
|
||||
start = session.params.startx;
|
||||
|
||||
if (stagger > 0)
|
||||
start |= 1;
|
||||
if (stagger > 0) {
|
||||
start |= 1;
|
||||
}
|
||||
|
||||
/* compute correct pixels number */
|
||||
/* pixels */
|
||||
used_pixels = (params.pixels * optical_res) / params.xres;
|
||||
used_pixels = (session.params.pixels * optical_res) / session.params.xres;
|
||||
|
||||
/* round up pixels number if needed */
|
||||
if (used_pixels * params.xres < params.pixels * optical_res)
|
||||
used_pixels++;
|
||||
if (used_pixels * session.params.xres < session.params.pixels * optical_res) {
|
||||
used_pixels++;
|
||||
}
|
||||
|
||||
dummy = 3-params.channels;
|
||||
dummy = 3-session.params.channels;
|
||||
|
||||
/* slope_dpi */
|
||||
/* cis color scan is effectively a gray scan with 3 gray lines per color
|
||||
line and a FILTER of 0 */
|
||||
if (dev->model->is_cis)
|
||||
slope_dpi = params.yres * params.channels;
|
||||
else
|
||||
slope_dpi = params.yres;
|
||||
if (dev->model->is_cis) {
|
||||
slope_dpi = session.params.yres * session.params.channels;
|
||||
} else {
|
||||
slope_dpi = session.params.yres;
|
||||
}
|
||||
|
||||
slope_dpi = slope_dpi * (1 + dummy);
|
||||
|
||||
|
@ -1091,65 +1101,67 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
/*** optical parameters ***/
|
||||
/* in case of dynamic lineart, we use an internal 8 bit gray scan
|
||||
* to generate 1 lineart data */
|
||||
if (params.flags & SCAN_FLAG_DYNAMIC_LINEART) {
|
||||
params.depth = 8;
|
||||
if (session.params.flags & SCAN_FLAG_DYNAMIC_LINEART) {
|
||||
session.params.depth = 8;
|
||||
}
|
||||
|
||||
/* we enable true gray for cis scanners only, and just when doing
|
||||
* scan since color calibration is OK for this mode
|
||||
*/
|
||||
oflags = 0;
|
||||
if(params.flags & SCAN_FLAG_DISABLE_SHADING)
|
||||
oflags |= OPTICAL_FLAG_DISABLE_SHADING;
|
||||
if(params.flags & SCAN_FLAG_DISABLE_GAMMA)
|
||||
oflags |= OPTICAL_FLAG_DISABLE_GAMMA;
|
||||
if(params.flags & SCAN_FLAG_DISABLE_LAMP)
|
||||
oflags |= OPTICAL_FLAG_DISABLE_LAMP;
|
||||
|
||||
oflags = 0;
|
||||
if (session.params.flags & SCAN_FLAG_DISABLE_SHADING) {
|
||||
oflags |= OPTICAL_FLAG_DISABLE_SHADING;
|
||||
}
|
||||
if (session.params.flags & SCAN_FLAG_DISABLE_GAMMA) {
|
||||
oflags |= OPTICAL_FLAG_DISABLE_GAMMA;
|
||||
}
|
||||
if (session.params.flags & SCAN_FLAG_DISABLE_LAMP) {
|
||||
oflags |= OPTICAL_FLAG_DISABLE_LAMP;
|
||||
}
|
||||
if (dev->model->is_cis && dev->settings.true_gray)
|
||||
{
|
||||
oflags |= OPTICAL_FLAG_ENABLE_LEDADD;
|
||||
}
|
||||
|
||||
gl846_init_optical_regs_scan(dev, sensor, reg, exposure_time, used_res, start, used_pixels,
|
||||
params.channels, params.depth, params.color_filter,
|
||||
session.params.channels, session.params.depth,
|
||||
session.params.color_filter,
|
||||
oflags);
|
||||
|
||||
/*** motor parameters ***/
|
||||
|
||||
/* max_shift */
|
||||
max_shift=sanei_genesys_compute_max_shift(dev,params.channels,params.yres,params.flags);
|
||||
max_shift = sanei_genesys_compute_max_shift(dev, session.params.channels, session.params.yres,
|
||||
session.params.flags);
|
||||
|
||||
/* lincnt */
|
||||
lincnt = params.lines + max_shift + stagger;
|
||||
lincnt = session.params.lines + max_shift + stagger;
|
||||
|
||||
/* add tl_y to base movement */
|
||||
move = params.starty;
|
||||
move = session.params.starty;
|
||||
DBG(DBG_info, "%s: move=%d steps\n", __func__, move);
|
||||
|
||||
mflags = 0;
|
||||
if (params.flags & SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE) {
|
||||
if (session.params.flags & SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE) {
|
||||
mflags |= MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE;
|
||||
}
|
||||
if (params.flags & SCAN_FLAG_FEEDING) {
|
||||
if (session.params.flags & SCAN_FLAG_FEEDING) {
|
||||
mflags |= MOTOR_FLAG_FEED;
|
||||
}
|
||||
|
||||
gl846_init_motor_regs_scan(dev, sensor, reg, exposure_time, slope_dpi, scan_step_type,
|
||||
dev->model->is_cis ? lincnt * params.channels : lincnt, dummy, move,
|
||||
scan_power_mode, mflags);
|
||||
dev->model->is_cis ? lincnt * session.params.channels : lincnt,
|
||||
dummy, move, scan_power_mode, mflags);
|
||||
|
||||
/*** prepares data reordering ***/
|
||||
|
||||
/* words_per_line */
|
||||
bytes_per_line = (used_pixels * used_res) / optical_res;
|
||||
bytes_per_line = (bytes_per_line * params.channels * params.depth) / 8;
|
||||
bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8;
|
||||
|
||||
requested_buffer_size = 8 * bytes_per_line;
|
||||
|
||||
read_buffer_size =
|
||||
2 * requested_buffer_size +
|
||||
((max_shift + stagger) * used_pixels * params.channels * params.depth) / 8;
|
||||
read_buffer_size = 2 * requested_buffer_size +
|
||||
((max_shift + stagger) * used_pixels * session.params.channels * session.params.depth) / 8;
|
||||
|
||||
dev->read_buffer.clear();
|
||||
dev->read_buffer.alloc(read_buffer_size);
|
||||
|
@ -1161,14 +1173,14 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
dev->shrink_buffer.alloc(requested_buffer_size);
|
||||
|
||||
dev->out_buffer.clear();
|
||||
dev->out_buffer.alloc((8 * params.pixels * params.channels * params.depth) / 8);
|
||||
dev->out_buffer.alloc((8 * session.params.pixels * session.params.channels * session.params.depth) / 8);
|
||||
|
||||
dev->read_bytes_left = bytes_per_line * lincnt;
|
||||
|
||||
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
||||
dev->read_active = SANE_TRUE;
|
||||
|
||||
dev->session.params = params;
|
||||
dev->session = session;
|
||||
dev->current_setup.pixels = (used_pixels * used_res) / optical_res;
|
||||
dev->current_setup.lines = lincnt;
|
||||
dev->current_setup.exposure_time = exposure_time;
|
||||
|
@ -1193,14 +1205,13 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
*/
|
||||
|
||||
dev->total_bytes_read = 0;
|
||||
if (params.depth == 1)
|
||||
dev->total_bytes_to_read =
|
||||
((params.pixels * params.lines) / 8 +
|
||||
(((params.pixels * params.lines) % 8) ? 1 : 0)) *
|
||||
params.channels;
|
||||
else
|
||||
dev->total_bytes_to_read =
|
||||
params.pixels * params.lines * params.channels * (params.depth / 8);
|
||||
if (session.params.depth == 1) {
|
||||
dev->total_bytes_to_read = ((session.params.pixels * session.params.lines) / 8 +
|
||||
(((session.params.pixels * session.params.lines) % 8) ? 1 : 0)) *
|
||||
session.params.channels;
|
||||
} else {
|
||||
dev->total_bytes_to_read = session.params.pixels * session.params.lines * session.params.channels * (session.params.depth / 8);
|
||||
}
|
||||
|
||||
DBG(DBG_info, "%s: total bytes to send = %lu\n", __func__, (u_long) dev->total_bytes_to_read);
|
||||
/* END TODO */
|
||||
|
@ -1244,54 +1255,53 @@ gl846_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
start += dev->settings.tl_x;
|
||||
start = (start * sensor.optical_res) / MM_PER_INCH;
|
||||
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dev->settings.xres;
|
||||
params.yres = dev->settings.yres;
|
||||
params.startx = start; // not used
|
||||
params.starty = 0; // not used
|
||||
params.pixels = dev->settings.pixels;
|
||||
params.lines = dev->settings.lines;
|
||||
params.depth = depth;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = dev->settings.scan_mode;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = 0;
|
||||
ScanSession session;
|
||||
session.params.xres = dev->settings.xres;
|
||||
session.params.yres = dev->settings.yres;
|
||||
session.params.startx = start; // not used
|
||||
session.params.starty = 0; // not used
|
||||
session.params.pixels = dev->settings.pixels;
|
||||
session.params.lines = dev->settings.lines;
|
||||
session.params.depth = depth;
|
||||
session.params.channels = 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 = 0;
|
||||
|
||||
DBG(DBG_info, "%s ", __func__);
|
||||
debug_dump(DBG_info, params);
|
||||
debug_dump(DBG_info, session.params);
|
||||
|
||||
// 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(params.xres);
|
||||
unsigned ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(session.params.xres);
|
||||
|
||||
/* optical_res */
|
||||
optical_res = sensor.optical_res;
|
||||
|
||||
/* stagger */
|
||||
if (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)
|
||||
stagger = (4 * params.yres) / dev->motor.base_ydpi;
|
||||
else
|
||||
stagger = 0;
|
||||
if (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE) {
|
||||
stagger = (4 * session.params.yres) / dev->motor.base_ydpi;
|
||||
} else {
|
||||
stagger = 0;
|
||||
}
|
||||
DBG(DBG_info, "%s: stagger=%d lines\n", __func__, stagger);
|
||||
|
||||
/* resolution is choosen from a fixed list */
|
||||
used_res = params.xres;
|
||||
used_res = session.params.xres;
|
||||
|
||||
/* compute scan parameters values */
|
||||
/* pixels are allways given at half or full CCD optical resolution */
|
||||
/* use detected left margin and fixed value */
|
||||
|
||||
/* compute correct pixels number */
|
||||
used_pixels = (params.pixels * optical_res) / used_res;
|
||||
dummy = 3 - params.channels;
|
||||
used_pixels = (session.params.pixels * optical_res) / used_res;
|
||||
dummy = 3 - session.params.channels;
|
||||
|
||||
/* cis color scan is effectively a gray scan with 3 gray lines per color
|
||||
line and a FILTER of 0 */
|
||||
if (dev->model->is_cis) {
|
||||
slope_dpi = params.yres * params.channels;
|
||||
slope_dpi = session.params.yres * session.params.channels;
|
||||
} else {
|
||||
slope_dpi = params.yres;
|
||||
slope_dpi = session.params.yres;
|
||||
}
|
||||
|
||||
slope_dpi = slope_dpi * (1 + dummy);
|
||||
|
@ -1299,12 +1309,11 @@ gl846_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
exposure_time = gl846_compute_exposure (dev, used_res);
|
||||
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
|
||||
|
||||
max_shift = sanei_genesys_compute_max_shift(dev, params.channels, params.yres, 0);
|
||||
max_shift = sanei_genesys_compute_max_shift(dev, session.params.channels, session.params.yres, 0);
|
||||
|
||||
/* lincnt */
|
||||
lincnt = params.lines + max_shift + stagger;
|
||||
lincnt = session.params.lines + max_shift + stagger;
|
||||
|
||||
dev->session.params = params;
|
||||
dev->session = session;
|
||||
dev->current_setup.pixels = (used_pixels * used_res) / optical_res;
|
||||
dev->current_setup.lines = lincnt;
|
||||
dev->current_setup.exposure_time = exposure_time;
|
||||
|
@ -1481,23 +1490,24 @@ static void gl846_slow_back_home(Genesys_Device* dev, SANE_Bool wait_until_home
|
|||
scan_mode= dev->settings.scan_mode;
|
||||
dev->settings.scan_mode = ScanColorMode::LINEART;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = resolution;
|
||||
params.yres = resolution;
|
||||
params.startx = 100;
|
||||
params.starty = 30000;
|
||||
params.pixels = 100;
|
||||
params.lines = 100;
|
||||
params.depth = 8;
|
||||
params.channels = 1;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::GRAY;
|
||||
params.color_filter = ColorFilter::RED;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
session.params.yres = resolution;
|
||||
session.params.startx = 100;
|
||||
session.params.starty = 30000;
|
||||
session.params.pixels = 100;
|
||||
session.params.lines = 100;
|
||||
session.params.depth = 8;
|
||||
session.params.channels = 1;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::GRAY;
|
||||
session.params.color_filter = ColorFilter::RED;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl846_compute_session(dev, session, sensor);
|
||||
|
||||
gl846_init_scan_regs(dev, sensor, &local_reg, params);
|
||||
gl846_init_scan_regs(dev, sensor, &local_reg, session);
|
||||
|
||||
dev->settings.scan_mode=scan_mode;
|
||||
|
||||
|
@ -1574,23 +1584,24 @@ static void gl846_search_start_position(Genesys_Device* dev)
|
|||
// whith employ different sensors with potentially different settings.
|
||||
auto& sensor = sanei_genesys_find_sensor_for_write(dev, dpi, ScanMethod::FLATBED);
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dpi;
|
||||
params.yres = dpi;
|
||||
params.startx = 0;
|
||||
params.starty = 0; /*we should give a small offset here~60 steps */
|
||||
params.pixels = 600;
|
||||
params.lines = dev->model->search_lines;
|
||||
params.depth = 8;
|
||||
params.channels = 1;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::GRAY;
|
||||
params.color_filter = ColorFilter::GREEN;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = dpi;
|
||||
session.params.yres = dpi;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0; /*we should give a small offset here~60 steps */
|
||||
session.params.pixels = 600;
|
||||
session.params.lines = dev->model->search_lines;
|
||||
session.params.depth = 8;
|
||||
session.params.channels = 1;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::GRAY;
|
||||
session.params.color_filter = ColorFilter::GREEN;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl846_compute_session(dev, session, sensor);
|
||||
|
||||
gl846_init_scan_regs(dev, sensor, &local_reg, params);
|
||||
gl846_init_scan_regs(dev, sensor, &local_reg, session);
|
||||
|
||||
// send to scanner
|
||||
dev->write_registers(local_reg);
|
||||
|
@ -1641,24 +1652,25 @@ static void gl846_init_regs_for_coarse_calibration(Genesys_Device* dev,
|
|||
channels = 1;
|
||||
}
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dev->settings.xres;
|
||||
params.yres = dev->settings.yres;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel();
|
||||
params.lines = 20;
|
||||
params.depth = 16;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = dev->settings.scan_mode;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = dev->settings.xres;
|
||||
session.params.yres = dev->settings.yres;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel();
|
||||
session.params.lines = 20;
|
||||
session.params.depth = 16;
|
||||
session.params.channels = 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 = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl846_compute_session(dev, session, sensor);
|
||||
|
||||
gl846_init_scan_regs(dev, sensor, ®s, params);
|
||||
gl846_init_scan_regs(dev, sensor, ®s, session);
|
||||
|
||||
DBG(DBG_info, "%s: optical sensor res: %d dpi, actual res: %d\n", __func__,
|
||||
sensor.optical_res / sensor.ccd_pixels_per_system_pixel(), dev->settings.xres);
|
||||
|
@ -1684,24 +1696,25 @@ static void gl846_feed(Genesys_Device* dev, unsigned int steps)
|
|||
resolution=sanei_genesys_get_lowest_ydpi(dev);
|
||||
const auto& sensor = sanei_genesys_find_sensor(dev, resolution, ScanMethod::FLATBED);
|
||||
|
||||
SetupParams params;
|
||||
params.xres = resolution;
|
||||
params.yres = resolution;
|
||||
params.startx = 0;
|
||||
params.starty = steps;
|
||||
params.pixels = 100;
|
||||
params.lines = 3;
|
||||
params.depth = 8;
|
||||
params.channels = 3;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_FEEDING |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
session.params.yres = resolution;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = steps;
|
||||
session.params.pixels = 100;
|
||||
session.params.lines = 3;
|
||||
session.params.depth = 8;
|
||||
session.params.channels = 3;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
session.params.color_filter = dev->settings.color_filter;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_FEEDING |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl846_compute_session(dev, session, sensor);
|
||||
|
||||
gl846_init_scan_regs(dev, sensor, &local_reg, params);
|
||||
gl846_init_scan_regs(dev, sensor, &local_reg, session);
|
||||
|
||||
local_reg.set24(REG_EXPR, 0);
|
||||
local_reg.set24(REG_EXPG, 0);
|
||||
|
@ -1771,24 +1784,25 @@ static void gl846_init_regs_for_shading(Genesys_Device* dev, const Genesys_Senso
|
|||
move=40;
|
||||
}
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dev->calib_resolution;
|
||||
params.yres = dev->calib_resolution;
|
||||
params.startx = 0;
|
||||
params.starty = move;
|
||||
params.pixels = dev->calib_pixels;
|
||||
params.lines = dev->calib_lines;
|
||||
params.depth = 16;
|
||||
params.channels = dev->calib_channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
ScanSession session;
|
||||
session.params.xres = dev->calib_resolution;
|
||||
session.params.yres = dev->calib_resolution;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = move;
|
||||
session.params.pixels = dev->calib_pixels;
|
||||
session.params.lines = dev->calib_lines;
|
||||
session.params.depth = 16;
|
||||
session.params.channels = dev->calib_channels;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
session.params.color_filter = dev->settings.color_filter;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl846_compute_session(dev, session, sensor);
|
||||
|
||||
gl846_init_scan_regs(dev, sensor, ®s, params);
|
||||
gl846_init_scan_regs(dev, sensor, ®s, session);
|
||||
|
||||
dev->write_registers(regs);
|
||||
|
||||
|
@ -1880,21 +1894,22 @@ static void gl846_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor&
|
|||
/* backtracking isn't handled well, so don't enable it */
|
||||
flags |= SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dev->settings.xres;
|
||||
params.yres = dev->settings.yres;
|
||||
params.startx = start;
|
||||
params.starty = move;
|
||||
params.pixels = dev->settings.pixels;
|
||||
params.lines = dev->settings.lines;
|
||||
params.depth = depth;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = dev->settings.scan_mode;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = flags;
|
||||
ScanSession session;
|
||||
session.params.xres = dev->settings.xres;
|
||||
session.params.yres = dev->settings.yres;
|
||||
session.params.startx = start;
|
||||
session.params.starty = move;
|
||||
session.params.pixels = dev->settings.pixels;
|
||||
session.params.lines = dev->settings.lines;
|
||||
session.params.depth = depth;
|
||||
session.params.channels = 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;
|
||||
gl846_compute_session(dev, session, sensor);
|
||||
|
||||
gl846_init_scan_regs(dev, sensor, &dev->reg, params);
|
||||
gl846_init_scan_regs(dev, sensor, &dev->reg, session);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2024,24 +2039,25 @@ static void gl846_led_calibration(Genesys_Device* dev, Genesys_Sensor& sensor,
|
|||
/* initial calibration reg values */
|
||||
regs = dev->reg;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = used_res;
|
||||
params.yres = used_res;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = num_pixels;
|
||||
params.lines = 1;
|
||||
params.depth = depth;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = used_res;
|
||||
session.params.yres = used_res;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = num_pixels;
|
||||
session.params.lines = 1;
|
||||
session.params.depth = depth;
|
||||
session.params.channels = channels;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
session.params.color_filter = dev->settings.color_filter;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl846_compute_session(dev, session, sensor);
|
||||
|
||||
gl846_init_scan_regs(dev, sensor, ®s, params);
|
||||
gl846_init_scan_regs(dev, sensor, ®s, session);
|
||||
|
||||
total_size = num_pixels * channels * (depth/8) * 1; /* colors * bytes_per_color * scan lines */
|
||||
std::vector<uint8_t> line(total_size);
|
||||
|
@ -2356,21 +2372,22 @@ static void gl846_search_strip(Genesys_Device* dev, const Genesys_Sensor& sensor
|
|||
|
||||
local_reg = dev->reg;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dpi;
|
||||
params.yres = dpi;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = pixels;
|
||||
params.lines = lines;
|
||||
params.depth = depth;
|
||||
params.channels = channels;
|
||||
params.scan_mode = ScanColorMode::GRAY;
|
||||
params.color_filter = ColorFilter::RED;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA;
|
||||
ScanSession session;
|
||||
session.params.xres = dpi;
|
||||
session.params.yres = dpi;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = pixels;
|
||||
session.params.lines = lines;
|
||||
session.params.depth = depth;
|
||||
session.params.channels = channels;
|
||||
session.params.scan_mode = ScanColorMode::GRAY;
|
||||
session.params.color_filter = ColorFilter::RED;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA;
|
||||
gl846_compute_session(dev, session, sensor);
|
||||
|
||||
gl846_init_scan_regs(dev, sensor, &local_reg, params);
|
||||
gl846_init_scan_regs(dev, sensor, &local_reg, session);
|
||||
|
||||
/* set up for reverse or forward */
|
||||
r = sanei_genesys_get_address (&local_reg, REG02);
|
||||
|
@ -2579,24 +2596,25 @@ static void gl846_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
|
|||
black_pixels = (sensor.black_pixels * resolution) / sensor.optical_res;
|
||||
DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels);
|
||||
|
||||
SetupParams params;
|
||||
params.xres = resolution;
|
||||
params.yres = resolution;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = pixels;
|
||||
params.lines = lines;
|
||||
params.depth = bpp;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
session.params.yres = resolution;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = pixels;
|
||||
session.params.lines = lines;
|
||||
session.params.depth = bpp;
|
||||
session.params.channels = channels;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
session.params.color_filter = dev->settings.color_filter;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl846_compute_session(dev, session, sensor);
|
||||
|
||||
gl846_init_scan_regs(dev, sensor, ®s, params);
|
||||
gl846_init_scan_regs(dev, sensor, ®s, session);
|
||||
|
||||
sanei_genesys_set_motor_power(regs, false);
|
||||
|
||||
|
@ -2732,25 +2750,26 @@ static void gl846_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen
|
|||
bpp=8;
|
||||
pixels = (sensor.sensor_pixels * resolution) / sensor.optical_res;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = resolution;
|
||||
params.yres = resolution;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = pixels;
|
||||
params.lines = lines;
|
||||
params.depth = bpp;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
session.params.yres = resolution;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = pixels;
|
||||
session.params.lines = lines;
|
||||
session.params.depth = bpp;
|
||||
session.params.channels = channels;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
session.params.color_filter = dev->settings.color_filter;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl846_compute_session(dev, session, sensor);
|
||||
|
||||
try {
|
||||
gl846_init_scan_regs(dev, sensor, ®s, params);
|
||||
gl846_init_scan_regs(dev, sensor, ®s, session);
|
||||
} catch (...) {
|
||||
catch_all_exceptions(__func__, [&](){ sanei_genesys_set_motor_power(regs, false); });
|
||||
throw;
|
||||
|
|
|
@ -338,13 +338,6 @@
|
|||
#define SETREG(adr,val) { dev->reg.init_reg(adr, val); }
|
||||
|
||||
|
||||
/** set up registers for an actual scan
|
||||
*
|
||||
* this function sets up the scanner to scan in normal or single line mode
|
||||
*/
|
||||
static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set* reg, SetupParams& params);
|
||||
|
||||
// Send the low-level scan command
|
||||
static void gl846_begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set* reg, SANE_Bool start_motor);
|
||||
|
|
|
@ -1017,13 +1017,23 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
r->value = sensor.dummy_pixel;
|
||||
}
|
||||
|
||||
static void gl847_compute_session(Genesys_Device* dev, ScanSession& s,
|
||||
const Genesys_Sensor& sensor)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
(void) sensor;
|
||||
(void) dev;
|
||||
s.params.assert_valid();
|
||||
s.computed = true;
|
||||
}
|
||||
|
||||
// set up registers for an actual scan this function sets up the scanner to scan in normal or single
|
||||
// line mode
|
||||
static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set* reg, SetupParams& params)
|
||||
Genesys_Register_Set* reg, ScanSession& session)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
params.assert_valid();
|
||||
session.assert_computed();
|
||||
|
||||
int used_res;
|
||||
int start, used_pixels;
|
||||
|
@ -1044,30 +1054,29 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
|
||||
int optical_res;
|
||||
|
||||
debug_dump(DBG_info, params);
|
||||
debug_dump(DBG_info, session.params);
|
||||
|
||||
// we may have 2 domains for ccd: xres below or above half ccd max dpi */
|
||||
unsigned ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(params.xres);
|
||||
unsigned ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(session.params.xres);
|
||||
|
||||
optical_res = sensor.optical_res / ccd_size_divisor;
|
||||
|
||||
/* stagger */
|
||||
if (ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) {
|
||||
stagger = (4 * params.yres) / dev->motor.base_ydpi;
|
||||
stagger = (4 * session.params.yres) / dev->motor.base_ydpi;
|
||||
} else {
|
||||
stagger = 0;
|
||||
}
|
||||
DBG(DBG_info, "%s : stagger=%d lines\n", __func__, stagger);
|
||||
|
||||
/* used_res */
|
||||
if (params.flags & SCAN_FLAG_USE_OPTICAL_RES)
|
||||
{
|
||||
if (session.params.flags & SCAN_FLAG_USE_OPTICAL_RES) {
|
||||
used_res = optical_res;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* resolution is choosen from a list */
|
||||
used_res = params.xres;
|
||||
used_res = session.params.xres;
|
||||
}
|
||||
|
||||
/* compute scan parameters values */
|
||||
|
@ -1075,28 +1084,29 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
/* use detected left margin and fixed value */
|
||||
/* start */
|
||||
/* add x coordinates */
|
||||
start = params.startx;
|
||||
start = session.params.startx;
|
||||
|
||||
if (stagger > 0)
|
||||
start |= 1;
|
||||
|
||||
/* compute correct pixels number */
|
||||
/* pixels */
|
||||
used_pixels = (params.pixels * optical_res) / params.xres;
|
||||
used_pixels = (session.params.pixels * optical_res) / session.params.xres;
|
||||
|
||||
/* round up pixels number if needed */
|
||||
if (used_pixels * params.xres < params.pixels * optical_res)
|
||||
used_pixels++;
|
||||
|
||||
dummy = 3-params.channels;
|
||||
if (used_pixels * session.params.xres < session.params.pixels * optical_res) {
|
||||
used_pixels++;
|
||||
}
|
||||
dummy = 3 - session.params.channels;
|
||||
|
||||
/* slope_dpi */
|
||||
/* cis color scan is effectively a gray scan with 3 gray lines per color
|
||||
line and a FILTER of 0 */
|
||||
if (dev->model->is_cis)
|
||||
slope_dpi = params.yres * params.channels;
|
||||
else
|
||||
slope_dpi = params.yres;
|
||||
if (dev->model->is_cis) {
|
||||
slope_dpi = session.params.yres * session.params.channels;
|
||||
} else {
|
||||
slope_dpi = session.params.yres;
|
||||
}
|
||||
|
||||
slope_dpi = slope_dpi * (1 + dummy);
|
||||
|
||||
|
@ -1109,20 +1119,23 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
/*** optical parameters ***/
|
||||
/* in case of dynamic lineart, we use an internal 8 bit gray scan
|
||||
* to generate 1 lineart data */
|
||||
if (params.flags & SCAN_FLAG_DYNAMIC_LINEART) {
|
||||
params.depth = 8;
|
||||
if (session.params.flags & SCAN_FLAG_DYNAMIC_LINEART) {
|
||||
session.params.depth = 8;
|
||||
}
|
||||
|
||||
/* we enable true gray for cis scanners only, and just when doing
|
||||
* scan since color calibration is OK for this mode
|
||||
*/
|
||||
oflags = 0;
|
||||
if(params.flags & SCAN_FLAG_DISABLE_SHADING)
|
||||
oflags |= OPTICAL_FLAG_DISABLE_SHADING;
|
||||
if(params.flags & SCAN_FLAG_DISABLE_GAMMA)
|
||||
oflags |= OPTICAL_FLAG_DISABLE_GAMMA;
|
||||
if(params.flags & SCAN_FLAG_DISABLE_LAMP)
|
||||
oflags |= OPTICAL_FLAG_DISABLE_LAMP;
|
||||
if (session.params.flags & SCAN_FLAG_DISABLE_SHADING) {
|
||||
oflags |= OPTICAL_FLAG_DISABLE_SHADING;
|
||||
}
|
||||
if (session.params.flags & SCAN_FLAG_DISABLE_GAMMA) {
|
||||
oflags |= OPTICAL_FLAG_DISABLE_GAMMA;
|
||||
}
|
||||
if (session.params.flags & SCAN_FLAG_DISABLE_LAMP) {
|
||||
oflags |= OPTICAL_FLAG_DISABLE_LAMP;
|
||||
}
|
||||
|
||||
if (dev->model->is_cis && dev->settings.true_gray)
|
||||
{
|
||||
|
@ -1130,43 +1143,41 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
}
|
||||
|
||||
gl847_init_optical_regs_scan(dev, sensor, reg, exposure_time, used_res, start, used_pixels,
|
||||
params.channels, params.depth, params.color_filter, oflags);
|
||||
session.params.channels, session.params.depth,
|
||||
session.params.color_filter, oflags);
|
||||
|
||||
/*** motor parameters ***/
|
||||
|
||||
/* max_shift */
|
||||
max_shift=sanei_genesys_compute_max_shift(dev,params.channels,params.yres,params.flags);
|
||||
max_shift = sanei_genesys_compute_max_shift(dev, session.params.channels, session.params.yres,
|
||||
session.params.flags);
|
||||
|
||||
/* lincnt */
|
||||
lincnt = params.lines + max_shift + stagger;
|
||||
lincnt = session.params.lines + max_shift + stagger;
|
||||
|
||||
/* add tl_y to base movement */
|
||||
move = params.starty;
|
||||
DBG(DBG_info, "%s: move=%d steps\n", __func__, move);
|
||||
move = session.params.starty;
|
||||
DBG(DBG_info, "%s: move=%d steps\n", __func__, move);
|
||||
|
||||
mflags=0;
|
||||
if (params.flags & SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE) {
|
||||
if (session.params.flags & SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE) {
|
||||
mflags |= MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE;
|
||||
}
|
||||
if (params.flags & SCAN_FLAG_FEEDING) {
|
||||
if (session.params.flags & SCAN_FLAG_FEEDING) {
|
||||
mflags |= MOTOR_FLAG_FEED;
|
||||
}
|
||||
|
||||
gl847_init_motor_regs_scan(dev, sensor, reg, exposure_time, slope_dpi, scan_step_type,
|
||||
dev->model->is_cis ? lincnt * params.channels : lincnt, dummy, move,
|
||||
scan_power_mode, mflags);
|
||||
dev->model->is_cis ? lincnt * session.params.channels : lincnt,
|
||||
dummy, move, scan_power_mode, mflags);
|
||||
|
||||
/*** prepares data reordering ***/
|
||||
|
||||
/* words_per_line */
|
||||
bytes_per_line = (used_pixels * used_res) / optical_res;
|
||||
bytes_per_line = (bytes_per_line * params.channels * params.depth) / 8;
|
||||
bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8;
|
||||
|
||||
requested_buffer_size = 8 * bytes_per_line;
|
||||
|
||||
read_buffer_size =
|
||||
2 * requested_buffer_size +
|
||||
((max_shift + stagger) * used_pixels * params.channels * params.depth) / 8;
|
||||
read_buffer_size = 2 * requested_buffer_size +
|
||||
((max_shift + stagger) * used_pixels * session.params.channels * session.params.depth) / 8;
|
||||
|
||||
dev->read_buffer.clear();
|
||||
dev->read_buffer.alloc(read_buffer_size);
|
||||
|
@ -1178,14 +1189,14 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
dev->shrink_buffer.alloc(requested_buffer_size);
|
||||
|
||||
dev->out_buffer.clear();
|
||||
dev->out_buffer.alloc((8 * params.pixels * params.channels * params.depth) / 8);
|
||||
dev->out_buffer.alloc((8 * session.params.pixels * session.params.channels * session.params.depth) / 8);
|
||||
|
||||
dev->read_bytes_left = bytes_per_line * lincnt;
|
||||
|
||||
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
||||
dev->read_active = SANE_TRUE;
|
||||
|
||||
dev->session.params = params;
|
||||
dev->session = session;
|
||||
dev->current_setup.pixels = (used_pixels * used_res) / optical_res;
|
||||
dev->current_setup.lines = lincnt;
|
||||
dev->current_setup.exposure_time = exposure_time;
|
||||
|
@ -1198,7 +1209,7 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
/* scan bytes to send to the frontend */
|
||||
/* theory :
|
||||
target_size =
|
||||
(params.pixels * params.lines * channels * depth) / 8;
|
||||
(session.params.pixels * session.params.lines * channels * depth) / 8;
|
||||
but it suffers from integer overflow so we do the following:
|
||||
|
||||
1 bit color images store color data byte-wise, eg byte 0 contains
|
||||
|
@ -1209,15 +1220,13 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
-- pierre
|
||||
*/
|
||||
|
||||
dev->total_bytes_read = 0;
|
||||
if (params.depth == 1)
|
||||
dev->total_bytes_to_read =
|
||||
((params.pixels * params.lines) / 8 +
|
||||
(((params.pixels * params.lines) % 8) ? 1 : 0)) *
|
||||
params.channels;
|
||||
else
|
||||
dev->total_bytes_to_read =
|
||||
params.pixels * params.lines * params.channels * (params.depth / 8);
|
||||
dev->total_bytes_read = 0;
|
||||
if (session.params.depth == 1) {
|
||||
dev->total_bytes_to_read = ((session.params.pixels * session.params.lines) / 8 +
|
||||
(((session.params.pixels * session.params.lines) % 8) ? 1 : 0)) * session.params.channels;
|
||||
} else {
|
||||
dev->total_bytes_to_read = session.params.pixels * session.params.lines * session.params.channels * (session.params.depth / 8);
|
||||
}
|
||||
|
||||
DBG(DBG_info, "%s: total bytes to send = %lu\n", __func__, (u_long) dev->total_bytes_to_read);
|
||||
/* END TODO */
|
||||
|
@ -1261,54 +1270,56 @@ gl847_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
start += dev->settings.tl_x;
|
||||
start = (start * sensor.optical_res) / MM_PER_INCH;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dev->settings.xres;
|
||||
params.yres = dev->settings.yres;
|
||||
params.startx = start; // not used
|
||||
params.starty = 0; // not used
|
||||
params.pixels = dev->settings.pixels;
|
||||
params.lines = dev->settings.lines;
|
||||
params.depth = depth;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = dev->settings.scan_mode;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = 0;
|
||||
ScanSession session;
|
||||
session.params.xres = dev->settings.xres;
|
||||
session.params.yres = dev->settings.yres;
|
||||
session.params.startx = start; // not used
|
||||
session.params.starty = 0; // not used
|
||||
session.params.pixels = dev->settings.pixels;
|
||||
session.params.lines = dev->settings.lines;
|
||||
session.params.depth = depth;
|
||||
session.params.channels = 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 = 0;
|
||||
|
||||
DBG(DBG_info, "%s ", __func__);
|
||||
debug_dump(DBG_info, params);
|
||||
debug_dump(DBG_info, session.params);
|
||||
|
||||
// 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(params.xres);
|
||||
unsigned ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(session.params.xres);
|
||||
|
||||
/* optical_res */
|
||||
optical_res = sensor.optical_res;
|
||||
|
||||
/* stagger */
|
||||
if (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)
|
||||
stagger = (4 * params.yres) / dev->motor.base_ydpi;
|
||||
else
|
||||
stagger = 0;
|
||||
if (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE) {
|
||||
stagger = (4 * session.params.yres) / dev->motor.base_ydpi;
|
||||
} else {
|
||||
stagger = 0;
|
||||
}
|
||||
|
||||
DBG(DBG_info, "%s: stagger=%d lines\n", __func__, stagger);
|
||||
|
||||
/* resolution is choosen from a fixed list */
|
||||
used_res = params.xres;
|
||||
used_res = session.params.xres;
|
||||
|
||||
/* compute scan parameters values */
|
||||
/* pixels are allways given at half or full CCD optical resolution */
|
||||
/* use detected left margin and fixed value */
|
||||
|
||||
/* compute correct pixels number */
|
||||
used_pixels = (params.pixels * optical_res) / used_res;
|
||||
dummy = 3 - params.channels;
|
||||
used_pixels = (session.params.pixels * optical_res) / used_res;
|
||||
dummy = 3 - session.params.channels;
|
||||
|
||||
/* slope_dpi */
|
||||
/* cis color scan is effectively a gray scan with 3 gray lines per color
|
||||
line and a FILTER of 0 */
|
||||
if (dev->model->is_cis) {
|
||||
slope_dpi = params.yres * params.channels;
|
||||
slope_dpi = session.params.yres * session.params.channels;
|
||||
} else {
|
||||
slope_dpi = params.yres;
|
||||
slope_dpi = session.params.yres;
|
||||
}
|
||||
|
||||
slope_dpi = slope_dpi * (1 + dummy);
|
||||
|
@ -1316,13 +1327,11 @@ gl847_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
exposure_time = gl847_compute_exposure (dev, used_res);
|
||||
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
|
||||
|
||||
/* max_shift */
|
||||
max_shift = sanei_genesys_compute_max_shift(dev, params.channels, params.yres, 0);
|
||||
max_shift = sanei_genesys_compute_max_shift(dev, session.params.channels, session.params.yres, 0);
|
||||
|
||||
/* lincnt */
|
||||
lincnt = params.lines + max_shift + stagger;
|
||||
lincnt = session.params.lines + max_shift + stagger;
|
||||
|
||||
dev->session.params = params;
|
||||
dev->session = session;
|
||||
dev->current_setup.pixels = (used_pixels * used_res) / optical_res;
|
||||
dev->current_setup.lines = lincnt;
|
||||
dev->current_setup.exposure_time = exposure_time;
|
||||
|
@ -1539,23 +1548,24 @@ static void gl847_slow_back_home(Genesys_Device* dev, SANE_Bool wait_until_home)
|
|||
scan_mode = dev->settings.scan_mode;
|
||||
dev->settings.scan_mode = ScanColorMode::LINEART;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = resolution;
|
||||
params.yres = resolution;
|
||||
params.startx = 100;
|
||||
params.starty = 30000;
|
||||
params.pixels = 100;
|
||||
params.lines = 100;
|
||||
params.depth = 8;
|
||||
params.channels = 1;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::GRAY;
|
||||
params.color_filter = ColorFilter::RED;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
session.params.yres = resolution;
|
||||
session.params.startx = 100;
|
||||
session.params.starty = 30000;
|
||||
session.params.pixels = 100;
|
||||
session.params.lines = 100;
|
||||
session.params.depth = 8;
|
||||
session.params.channels = 1;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::GRAY;
|
||||
session.params.color_filter = ColorFilter::RED;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl847_compute_session(dev, session, sensor);
|
||||
|
||||
gl847_init_scan_regs(dev, sensor, &local_reg, params);
|
||||
gl847_init_scan_regs(dev, sensor, &local_reg, session);
|
||||
|
||||
dev->settings.scan_mode = scan_mode;
|
||||
|
||||
|
@ -1630,23 +1640,24 @@ static void gl847_search_start_position(Genesys_Device* dev)
|
|||
// whith employ different sensors with potentially different settings.
|
||||
auto& sensor = sanei_genesys_find_sensor_for_write(dev, dpi, ScanMethod::FLATBED);
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dpi;
|
||||
params.yres = dpi;
|
||||
params.startx = 0;
|
||||
params.starty = 0; /*we should give a small offset here~60 steps */
|
||||
params.pixels = 600;
|
||||
params.lines = dev->model->search_lines;
|
||||
params.depth = 8;
|
||||
params.channels = 1;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::GRAY;
|
||||
params.color_filter = ColorFilter::GREEN;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = dpi;
|
||||
session.params.yres = dpi;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0; /*we should give a small offset here~60 steps */
|
||||
session.params.pixels = 600;
|
||||
session.params.lines = dev->model->search_lines;
|
||||
session.params.depth = 8;
|
||||
session.params.channels = 1;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::GRAY;
|
||||
session.params.color_filter = ColorFilter::GREEN;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl847_compute_session(dev, session, sensor);
|
||||
|
||||
gl847_init_scan_regs(dev, sensor, &local_reg, params);
|
||||
gl847_init_scan_regs(dev, sensor, &local_reg, session);
|
||||
|
||||
// send to scanner
|
||||
dev->write_registers(local_reg);
|
||||
|
@ -1697,24 +1708,25 @@ static void gl847_init_regs_for_coarse_calibration(Genesys_Device* dev,
|
|||
channels = 1;
|
||||
}
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dev->settings.xres;
|
||||
params.yres = dev->settings.yres;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel();
|
||||
params.lines = 20;
|
||||
params.depth = 16;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = dev->settings.scan_mode;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = dev->settings.xres;
|
||||
session.params.yres = dev->settings.yres;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel();
|
||||
session.params.lines = 20;
|
||||
session.params.depth = 16;
|
||||
session.params.channels = 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 = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl847_compute_session(dev, session, sensor);
|
||||
|
||||
gl847_init_scan_regs(dev, sensor, ®s, params);
|
||||
gl847_init_scan_regs(dev, sensor, ®s, session);
|
||||
|
||||
DBG(DBG_info, "%s: optical sensor res: %d dpi, actual res: %d\n", __func__,
|
||||
sensor.optical_res / sensor.ccd_pixels_per_system_pixel(), dev->settings.xres);
|
||||
|
@ -1739,24 +1751,25 @@ static void gl847_feed(Genesys_Device* dev, unsigned int steps)
|
|||
resolution=sanei_genesys_get_lowest_ydpi(dev);
|
||||
const auto& sensor = sanei_genesys_find_sensor(dev, resolution, ScanMethod::FLATBED);
|
||||
|
||||
SetupParams params;
|
||||
params.xres = resolution;
|
||||
params.yres = resolution;
|
||||
params.startx = 0;
|
||||
params.starty = steps;
|
||||
params.pixels = 100;
|
||||
params.lines = 3;
|
||||
params.depth = 8;
|
||||
params.channels = 3;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_FEEDING |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
session.params.yres = resolution;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = steps;
|
||||
session.params.pixels = 100;
|
||||
session.params.lines = 3;
|
||||
session.params.depth = 8;
|
||||
session.params.channels = 3;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
session.params.color_filter = dev->settings.color_filter;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_FEEDING |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl847_compute_session(dev, session, sensor);
|
||||
|
||||
gl847_init_scan_regs(dev, sensor, &local_reg, params);
|
||||
gl847_init_scan_regs(dev, sensor, &local_reg, session);
|
||||
|
||||
// set exposure to zero
|
||||
local_reg.set24(REG_EXPR,0);
|
||||
|
@ -1826,24 +1839,25 @@ static void gl847_init_regs_for_shading(Genesys_Device* dev, const Genesys_Senso
|
|||
move=40;
|
||||
}
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dev->calib_resolution;
|
||||
params.yres = dev->calib_resolution;
|
||||
params.startx = 0;
|
||||
params.starty = move;
|
||||
params.pixels = dev->calib_pixels;
|
||||
params.lines = dev->calib_lines;
|
||||
params.depth = 16;
|
||||
params.channels = dev->calib_channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = dev->calib_resolution;
|
||||
session.params.yres = dev->calib_resolution;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = move;
|
||||
session.params.pixels = dev->calib_pixels;
|
||||
session.params.lines = dev->calib_lines;
|
||||
session.params.depth = 16;
|
||||
session.params.channels = dev->calib_channels;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
session.params.color_filter = dev->settings.color_filter;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl847_compute_session(dev, session, sensor);
|
||||
|
||||
gl847_init_scan_regs(dev, sensor, ®s, params);
|
||||
gl847_init_scan_regs(dev, sensor, ®s, session);
|
||||
|
||||
dev->write_registers(regs);
|
||||
|
||||
|
@ -1935,21 +1949,22 @@ static void gl847_init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor&
|
|||
/* backtracking isn't handled well, so don't enable it */
|
||||
flags |= SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dev->settings.xres;
|
||||
params.yres = dev->settings.yres;
|
||||
params.startx = start;
|
||||
params.starty = move;
|
||||
params.pixels = dev->settings.pixels;
|
||||
params.lines = dev->settings.lines;
|
||||
params.depth = depth;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = dev->settings.scan_mode;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = flags;
|
||||
ScanSession session;
|
||||
session.params.xres = dev->settings.xres;
|
||||
session.params.yres = dev->settings.yres;
|
||||
session.params.startx = start;
|
||||
session.params.starty = move;
|
||||
session.params.pixels = dev->settings.pixels;
|
||||
session.params.lines = dev->settings.lines;
|
||||
session.params.depth = depth;
|
||||
session.params.channels = 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;
|
||||
gl847_compute_session(dev, session, sensor);
|
||||
|
||||
gl847_init_scan_regs(dev, sensor, &dev->reg, params);
|
||||
gl847_init_scan_regs(dev, sensor, &dev->reg, session);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2079,24 +2094,25 @@ static void gl847_led_calibration(Genesys_Device* dev, Genesys_Sensor& sensor,
|
|||
/* initial calibration reg values */
|
||||
regs = dev->reg;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = used_res;
|
||||
params.yres = used_res;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = num_pixels;
|
||||
params.lines = 1;
|
||||
params.depth = depth;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = used_res;
|
||||
session.params.yres = used_res;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = num_pixels;
|
||||
session.params.lines = 1;
|
||||
session.params.depth = depth;
|
||||
session.params.channels = channels;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
session.params.color_filter = dev->settings.color_filter;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl847_compute_session(dev, session, sensor);
|
||||
|
||||
gl847_init_scan_regs(dev, sensor, ®s, params);
|
||||
gl847_init_scan_regs(dev, sensor, ®s, session);
|
||||
|
||||
total_size = num_pixels * channels * (depth/8) * 1; /* colors * bytes_per_color * scan lines */
|
||||
std::vector<uint8_t> line(total_size);
|
||||
|
@ -2450,22 +2466,23 @@ static void gl847_search_strip(Genesys_Device* dev, const Genesys_Sensor& sensor
|
|||
|
||||
local_reg = dev->reg;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = dpi;
|
||||
params.yres = dpi;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = pixels;
|
||||
params.lines = lines;
|
||||
params.depth = depth;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::GRAY;
|
||||
params.color_filter = ColorFilter::RED;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA;
|
||||
ScanSession session;
|
||||
session.params.xres = dpi;
|
||||
session.params.yres = dpi;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = pixels;
|
||||
session.params.lines = lines;
|
||||
session.params.depth = depth;
|
||||
session.params.channels = channels;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::GRAY;
|
||||
session.params.color_filter = ColorFilter::RED;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA;
|
||||
gl847_compute_session(dev, session, sensor);
|
||||
|
||||
gl847_init_scan_regs(dev, sensor, &local_reg, params);
|
||||
gl847_init_scan_regs(dev, sensor, &local_reg, session);
|
||||
|
||||
/* set up for reverse or forward */
|
||||
r = sanei_genesys_get_address(&local_reg, REG02);
|
||||
|
@ -2674,24 +2691,25 @@ static void gl847_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
|
|||
black_pixels = (sensor.black_pixels * resolution) / sensor.optical_res;
|
||||
DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels);
|
||||
|
||||
SetupParams params;
|
||||
params.xres = resolution;
|
||||
params.yres = resolution;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = pixels;
|
||||
params.lines = lines;
|
||||
params.depth = bpp;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
session.params.yres = resolution;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = pixels;
|
||||
session.params.lines = lines;
|
||||
session.params.depth = bpp;
|
||||
session.params.channels = channels;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
session.params.color_filter = dev->settings.color_filter;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl847_compute_session(dev, session, sensor);
|
||||
|
||||
gl847_init_scan_regs(dev, sensor, ®s, params);
|
||||
gl847_init_scan_regs(dev, sensor, ®s, session);
|
||||
|
||||
sanei_genesys_set_motor_power(regs, false);
|
||||
|
||||
|
@ -2825,25 +2843,26 @@ static void gl847_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen
|
|||
bpp=8;
|
||||
pixels = (sensor.sensor_pixels * resolution) / sensor.optical_res;
|
||||
|
||||
SetupParams params;
|
||||
params.xres = resolution;
|
||||
params.yres = resolution;
|
||||
params.startx = 0;
|
||||
params.starty = 0;
|
||||
params.pixels = pixels;
|
||||
params.lines = lines;
|
||||
params.depth = bpp;
|
||||
params.channels = channels;
|
||||
params.scan_method = dev->settings.scan_method;
|
||||
params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
params.color_filter = dev->settings.color_filter;
|
||||
params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
session.params.yres = resolution;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = pixels;
|
||||
session.params.lines = lines;
|
||||
session.params.depth = bpp;
|
||||
session.params.channels = channels;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
session.params.color_filter = dev->settings.color_filter;
|
||||
session.params.flags = SCAN_FLAG_DISABLE_SHADING |
|
||||
SCAN_FLAG_DISABLE_GAMMA |
|
||||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
gl847_compute_session(dev, session, sensor);
|
||||
|
||||
try {
|
||||
gl847_init_scan_regs(dev, sensor, ®s, params);
|
||||
gl847_init_scan_regs(dev, sensor, ®s, session);
|
||||
} catch (...) {
|
||||
catch_all_exceptions(__func__, [&](){ sanei_genesys_set_motor_power(regs, false); });
|
||||
throw;
|
||||
|
|
|
@ -326,9 +326,6 @@
|
|||
*
|
||||
* this function sets up the scanner to scan in normal or single line mode
|
||||
*/
|
||||
static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set* reg, SetupParams& params);
|
||||
|
||||
// Send the low-level scan command
|
||||
static void gl847_begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set* reg, SANE_Bool start_motor);
|
||||
|
|
|
@ -177,7 +177,7 @@ void serialize(Stream& str, SetupParams& x)
|
|||
struct ScanSession {
|
||||
SetupParams params;
|
||||
|
||||
// whether the session setup has been computed via gl843_compute_session()
|
||||
// whether the session setup has been computed via gl*_compute_session()
|
||||
// gl843-only
|
||||
bool computed = false;
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue