kopia lustrzana https://gitlab.com/sane-project/backends
Merge branch 'genesys-session-optical-pixels' into 'master'
genesys: Use common code path to compute session optical_pixels See merge request sane-project/backends!147merge-requests/148/merge
commit
fc85e7d15d
|
@ -1062,7 +1062,7 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
DBG_HELPER(dbg);
|
||||
session.assert_computed();
|
||||
|
||||
int start, used_pixels;
|
||||
int start;
|
||||
int bytes_per_line;
|
||||
int move;
|
||||
unsigned int lincnt;
|
||||
|
@ -1095,21 +1095,8 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
/* use detected left margin and fixed value */
|
||||
start = session.params.startx;
|
||||
|
||||
if (stagger > 0)
|
||||
start |= 1;
|
||||
|
||||
/* compute correct pixels number */
|
||||
used_pixels = (session.params.pixels * session.optical_resolution) / session.params.xres;
|
||||
DBG (DBG_info, "%s: used_pixels=%d\n", __func__, used_pixels);
|
||||
|
||||
/* round up pixels number if needed */
|
||||
if (used_pixels * session.params.xres < session.params.pixels * session.optical_resolution) {
|
||||
used_pixels++;
|
||||
}
|
||||
|
||||
/* we want even number of pixels here */
|
||||
if (used_pixels & 1) {
|
||||
used_pixels++;
|
||||
if (stagger > 0) {
|
||||
start |= 1;
|
||||
}
|
||||
|
||||
/* cis color scan is effectively a gray scan with 3 gray lines per color line and a FILTER of 0 */
|
||||
|
@ -1147,8 +1134,9 @@ 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, session, used_res, start,
|
||||
used_pixels, session.params.channels, session.params.depth,
|
||||
session.ccd_size_divisor, session.params.color_filter);
|
||||
session.optical_pixels, session.params.channels,
|
||||
session.params.depth, session.ccd_size_divisor,
|
||||
session.params.color_filter);
|
||||
|
||||
/*** motor parameters ***/
|
||||
|
||||
|
@ -1175,7 +1163,7 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
/*** prepares data reordering ***/
|
||||
|
||||
/* words_per_line */
|
||||
bytes_per_line = (used_pixels * used_res) / session.optical_resolution;
|
||||
bytes_per_line = (session.optical_pixels * used_res) / session.optical_resolution;
|
||||
bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8;
|
||||
|
||||
/* since we don't have sheetfed scanners to handle,
|
||||
|
@ -1184,7 +1172,8 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
requested_buffer_size = 16 * bytes_per_line;
|
||||
|
||||
read_buffer_size = 2 * requested_buffer_size +
|
||||
((max_shift + stagger) * used_pixels * session.params.channels * session.params.depth) / 8;
|
||||
((max_shift + stagger) * session.optical_pixels * session.params.channels *
|
||||
session.params.depth) / 8;
|
||||
|
||||
dev->read_buffer.clear();
|
||||
dev->read_buffer.alloc(read_buffer_size);
|
||||
|
@ -1204,7 +1193,7 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
dev->read_active = SANE_TRUE;
|
||||
|
||||
dev->session = session;
|
||||
dev->current_setup.pixels = (used_pixels * used_res) / session.optical_resolution;
|
||||
dev->current_setup.pixels = (session.optical_pixels * used_res) / session.optical_resolution;
|
||||
DBG(DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels);
|
||||
dev->current_setup.lines = lincnt;
|
||||
dev->current_setup.exposure_time = exposure_time;
|
||||
|
@ -1232,15 +1221,12 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
int start;
|
||||
|
||||
int used_res;
|
||||
int used_pixels;
|
||||
unsigned int lincnt;
|
||||
int exposure_time;
|
||||
int stagger;
|
||||
|
||||
int max_shift, dpihw;
|
||||
|
||||
int optical_res;
|
||||
|
||||
DBG(DBG_info, "%s ", __func__);
|
||||
debug_dump(DBG_info, dev->settings);
|
||||
|
||||
|
@ -1269,17 +1255,13 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
DBG(DBG_info, "%s ", __func__);
|
||||
debug_dump(DBG_info, session.params);
|
||||
|
||||
/* optical_res */
|
||||
optical_res = sensor.optical_res;
|
||||
|
||||
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 */
|
||||
|
||||
used_pixels = (session.params.pixels * optical_res) / session.params.xres;
|
||||
DBG (DBG_info, "%s: used_pixels=%d\n", __func__, used_pixels);
|
||||
DBG(DBG_info, "%s: used_pixels=%d\n", __func__, session.optical_pixels);
|
||||
|
||||
exposure_time = get_sensor_profile(sensor, session.params.xres,
|
||||
session.ccd_size_divisor).exposure_lperiod;
|
||||
|
@ -1307,7 +1289,7 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso
|
|||
lincnt = session.params.lines + max_shift + stagger;
|
||||
|
||||
dev->session = session;
|
||||
dev->current_setup.pixels = (used_pixels * used_res) / optical_res;
|
||||
dev->current_setup.pixels = (session.optical_pixels * used_res) / sensor.optical_res;
|
||||
DBG (DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels);
|
||||
dev->current_setup.lines = lincnt;
|
||||
dev->current_setup.exposure_time = exposure_time;
|
||||
|
|
|
@ -351,13 +351,8 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
|||
startx |= 1;
|
||||
}
|
||||
|
||||
uint32_t pixels = (session.params.pixels * session.optical_resolution) / 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;
|
||||
uint32_t endx = startx + session.optical_pixels;
|
||||
|
||||
int i, nb;
|
||||
Motor_Master *motor = NULL;
|
||||
|
|
|
@ -1760,7 +1760,7 @@ static void gl841_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
session.assert_computed();
|
||||
|
||||
int used_res;
|
||||
int start, used_pixels;
|
||||
int start;
|
||||
int bytes_per_line;
|
||||
int move;
|
||||
unsigned int lincnt;
|
||||
|
@ -1843,14 +1843,6 @@ independent of our calculated values:
|
|||
start=(start/avg)*avg;
|
||||
}
|
||||
|
||||
/* compute correct pixels number */
|
||||
used_pixels = (session.params.pixels * session.optical_resolution) / session.params.xres;
|
||||
|
||||
/* round up pixels number if needed */
|
||||
if (used_pixels * session.params.xres < session.params.pixels * session.optical_resolution) {
|
||||
used_pixels++;
|
||||
}
|
||||
|
||||
/* dummy */
|
||||
/* dummy lines: may not be usefull, for instance 250 dpi works with 0 or 1
|
||||
dummy line. Maybe the dummy line adds correctness since the motor runs
|
||||
|
@ -1890,11 +1882,11 @@ dummy \ scanned lines
|
|||
slope_dpi = slope_dpi * (1 + dummy);
|
||||
|
||||
scan_step_type = gl841_scan_step_type(dev, session.params.yres);
|
||||
exposure_time = gl841_exposure_time(dev, sensor,
|
||||
exposure_time = gl841_exposure_time(dev, sensor,
|
||||
slope_dpi,
|
||||
scan_step_type,
|
||||
start,
|
||||
used_pixels);
|
||||
session.optical_pixels);
|
||||
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
|
||||
|
||||
/*** optical parameters ***/
|
||||
|
@ -1910,8 +1902,9 @@ dummy \ scanned lines
|
|||
}
|
||||
|
||||
gl841_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, used_res, start,
|
||||
used_pixels, session.params.channels, session.params.depth,
|
||||
session.ccd_size_divisor, session.params.color_filter);
|
||||
session.optical_pixels, session.params.channels,
|
||||
session.params.depth, session.ccd_size_divisor,
|
||||
session.params.color_filter);
|
||||
|
||||
/*** motor parameters ***/
|
||||
|
||||
|
@ -1951,7 +1944,7 @@ dummy \ scanned lines
|
|||
/*** prepares data reordering ***/
|
||||
|
||||
/* words_per_line */
|
||||
bytes_per_line = (used_pixels * used_res) / session.optical_resolution;
|
||||
bytes_per_line = (session.optical_pixels * used_res) / session.optical_resolution;
|
||||
bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8;
|
||||
|
||||
requested_buffer_size = 8 * bytes_per_line;
|
||||
|
@ -1961,7 +1954,7 @@ dummy \ scanned lines
|
|||
}
|
||||
|
||||
read_buffer_size = 2 * requested_buffer_size +
|
||||
((max_shift + stagger) * used_pixels * session.params.channels * session.params.depth) / 8;
|
||||
((max_shift + stagger) * session.optical_pixels * session.params.channels * session.params.depth) / 8;
|
||||
|
||||
dev->read_buffer.clear();
|
||||
dev->read_buffer.alloc(read_buffer_size);
|
||||
|
@ -1981,7 +1974,7 @@ dummy \ scanned lines
|
|||
dev->read_active = SANE_TRUE;
|
||||
|
||||
dev->session = session;
|
||||
dev->current_setup.pixels = (used_pixels * used_res) / session.optical_resolution;
|
||||
dev->current_setup.pixels = (session.optical_pixels * used_res) / session.optical_resolution;
|
||||
dev->current_setup.lines = lincnt;
|
||||
dev->current_setup.exposure_time = exposure_time;
|
||||
dev->current_setup.xres = used_res;
|
||||
|
@ -2022,7 +2015,6 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se
|
|||
int start;
|
||||
|
||||
int used_res;
|
||||
int used_pixels;
|
||||
unsigned int lincnt;
|
||||
int exposure_time;
|
||||
int stagger;
|
||||
|
@ -2088,13 +2080,6 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se
|
|||
start |= 1;
|
||||
}
|
||||
|
||||
used_pixels = (session.params.pixels * session.optical_resolution) / session.params.xres;
|
||||
|
||||
// round up pixels number if needed
|
||||
if (used_pixels * session.params.xres < session.params.pixels * session.optical_resolution) {
|
||||
used_pixels++;
|
||||
}
|
||||
|
||||
/* dummy lines: may not be usefull, for instance 250 dpi works with 0 or 1
|
||||
dummy line. Maybe the dummy line adds correctness since the motor runs
|
||||
slower (higher dpi)
|
||||
|
@ -2136,7 +2121,7 @@ dummy \ scanned lines
|
|||
slope_dpi,
|
||||
scan_step_type,
|
||||
start,
|
||||
used_pixels);
|
||||
session.optical_pixels);
|
||||
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
|
||||
|
||||
/* scanned area must be enlarged by max color shift needed */
|
||||
|
@ -2146,7 +2131,7 @@ dummy \ scanned lines
|
|||
lincnt = session.params.lines + max_shift + stagger;
|
||||
|
||||
dev->session = session;
|
||||
dev->current_setup.pixels = (used_pixels * used_res) / session.optical_resolution;
|
||||
dev->current_setup.pixels = (session.optical_pixels * used_res) / session.optical_resolution;
|
||||
dev->current_setup.lines = lincnt;
|
||||
dev->current_setup.exposure_time = exposure_time;
|
||||
dev->current_setup.xres = used_res;
|
||||
|
|
|
@ -1184,14 +1184,6 @@ static void gl843_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
r->value = sensor.dummy_pixel;
|
||||
}
|
||||
|
||||
static unsigned align_int_up(unsigned num, unsigned alignment)
|
||||
{
|
||||
unsigned mask = alignment - 1;
|
||||
if (num & mask)
|
||||
num = (num & ~mask) + alignment;
|
||||
return num;
|
||||
}
|
||||
|
||||
// computes physical parameters for specific scan setup
|
||||
static void gl843_compute_session(Genesys_Device* dev, ScanSession& s,
|
||||
const Genesys_Sensor& sensor)
|
||||
|
@ -1201,20 +1193,6 @@ static void gl843_compute_session(Genesys_Device* dev, ScanSession& s,
|
|||
// compute optical and output resolutions
|
||||
s.hwdpi_divisor = sensor.get_hwdpi_divisor_for_dpi(s.params.xres);
|
||||
|
||||
if (s.output_resolution > s.optical_resolution) {
|
||||
throw std::runtime_error("output resolution higher than optical resolution");
|
||||
}
|
||||
|
||||
// compute the number of optical pixels that will be acquired by the chip
|
||||
s.optical_pixels = (s.params.pixels * s.optical_resolution) / s.output_resolution;
|
||||
if (s.optical_pixels * s.output_resolution < s.params.pixels * s.optical_resolution) {
|
||||
s.optical_pixels++;
|
||||
}
|
||||
|
||||
// ensure the number of optical pixels is divisible by 2.
|
||||
// In quarter-CCD mode optical_pixels is 4x larger than the actual physical number
|
||||
s.optical_pixels = align_int_up(s.optical_pixels, 2 * s.ccd_size_divisor);
|
||||
|
||||
// after all adjustments on the optical pixels have been made, compute the number of pixels
|
||||
// to retrieve from the chip
|
||||
s.output_pixels = (s.optical_pixels * s.output_resolution) / s.optical_resolution;
|
||||
|
@ -1402,7 +1380,6 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
{
|
||||
int start;
|
||||
|
||||
int used_pixels;
|
||||
unsigned int lincnt;
|
||||
int exposure;
|
||||
int stagger;
|
||||
|
@ -1467,10 +1444,6 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
/* pixels are allways given at half or full CCD optical resolution */
|
||||
/* use detected left margin and fixed value */
|
||||
|
||||
/* compute correct pixels number */
|
||||
used_pixels = (session.params.pixels * session.optical_resolution) / session.params.xres;
|
||||
DBG(DBG_info, "%s: used_pixels=%d\n", __func__, used_pixels);
|
||||
|
||||
/* exposure */
|
||||
exposure = sensor.exposure_lperiod;
|
||||
if (exposure < 0) {
|
||||
|
@ -1497,7 +1470,7 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
lincnt = session.params.lines + max_shift + stagger;
|
||||
|
||||
dev->session = session;
|
||||
dev->current_setup.pixels = (used_pixels * used_res) / session.optical_resolution;
|
||||
dev->current_setup.pixels = (session.optical_pixels * used_res) / session.optical_resolution;
|
||||
DBG(DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels);
|
||||
dev->current_setup.lines = lincnt;
|
||||
dev->current_setup.exposure_time = exposure;
|
||||
|
|
|
@ -947,7 +947,7 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
DBG_HELPER(dbg);
|
||||
session.assert_computed();
|
||||
|
||||
int start, used_pixels;
|
||||
int start;
|
||||
int bytes_per_line;
|
||||
int move;
|
||||
unsigned int lincnt;
|
||||
|
@ -984,14 +984,6 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
start |= 1;
|
||||
}
|
||||
|
||||
/* compute correct pixels number */
|
||||
used_pixels = (session.params.pixels * session.optical_resolution) / session.params.xres;
|
||||
|
||||
/* round up pixels number if needed */
|
||||
if (used_pixels * session.params.xres < session.params.pixels * session.optical_resolution) {
|
||||
used_pixels++;
|
||||
}
|
||||
|
||||
dummy = 3-session.params.channels;
|
||||
|
||||
/* slope_dpi */
|
||||
|
@ -1023,7 +1015,7 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
* scan since color calibration is OK for this mode
|
||||
*/
|
||||
gl846_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, used_res, start,
|
||||
used_pixels, session.params.channels, session.params.depth,
|
||||
session.optical_pixels, session.params.channels, session.params.depth,
|
||||
session.params.color_filter);
|
||||
|
||||
/*** motor parameters ***/
|
||||
|
@ -1053,13 +1045,14 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
/*** prepares data reordering ***/
|
||||
|
||||
/* words_per_line */
|
||||
bytes_per_line = (used_pixels * used_res) / session.optical_resolution;
|
||||
bytes_per_line = (session.optical_pixels * used_res) / session.optical_resolution;
|
||||
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 * session.params.channels * session.params.depth) / 8;
|
||||
((max_shift + stagger) * session.optical_pixels * session.params.channels *
|
||||
session.params.depth) / 8;
|
||||
|
||||
dev->read_buffer.clear();
|
||||
dev->read_buffer.alloc(read_buffer_size);
|
||||
|
@ -1079,7 +1072,7 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
dev->read_active = SANE_TRUE;
|
||||
|
||||
dev->session = session;
|
||||
dev->current_setup.pixels = (used_pixels * used_res) / session.optical_resolution;
|
||||
dev->current_setup.pixels = (session.optical_pixels * used_res) / session.optical_resolution;
|
||||
dev->current_setup.lines = lincnt;
|
||||
dev->current_setup.exposure_time = exposure_time;
|
||||
dev->current_setup.xres = used_res;
|
||||
|
@ -1120,8 +1113,6 @@ gl846_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
{
|
||||
int start;
|
||||
|
||||
int used_res;
|
||||
int used_pixels;
|
||||
unsigned int lincnt;
|
||||
int exposure_time;
|
||||
int stagger;
|
||||
|
@ -1130,8 +1121,6 @@ gl846_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
int dummy = 0;
|
||||
int max_shift;
|
||||
|
||||
int optical_res;
|
||||
|
||||
DBG(DBG_info, "%s ", __func__);
|
||||
debug_dump(DBG_info, dev->settings);
|
||||
|
||||
|
@ -1160,9 +1149,6 @@ gl846_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
DBG(DBG_info, "%s ", __func__);
|
||||
debug_dump(DBG_info, session.params);
|
||||
|
||||
/* optical_res */
|
||||
optical_res = sensor.optical_res;
|
||||
|
||||
if (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE) {
|
||||
stagger = (4 * session.params.yres) / dev->motor.base_ydpi;
|
||||
} else {
|
||||
|
@ -1170,15 +1156,11 @@ gl846_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
}
|
||||
DBG(DBG_info, "%s: stagger=%d lines\n", __func__, stagger);
|
||||
|
||||
/* resolution is choosen from a fixed list */
|
||||
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 = (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
|
||||
|
@ -1191,7 +1173,7 @@ gl846_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
|
||||
slope_dpi = slope_dpi * (1 + dummy);
|
||||
|
||||
exposure_time = get_sensor_profile(sensor, used_res).exposure_lperiod;
|
||||
exposure_time = get_sensor_profile(sensor, session.params.xres).exposure_lperiod;
|
||||
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
|
||||
|
||||
max_shift = sanei_genesys_compute_max_shift(dev, session.params.channels, session.params.yres, 0);
|
||||
|
@ -1199,10 +1181,10 @@ gl846_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
lincnt = session.params.lines + max_shift + stagger;
|
||||
|
||||
dev->session = session;
|
||||
dev->current_setup.pixels = (used_pixels * used_res) / optical_res;
|
||||
dev->current_setup.pixels = (session.optical_pixels * session.params.xres) / sensor.optical_res;
|
||||
dev->current_setup.lines = lincnt;
|
||||
dev->current_setup.exposure_time = exposure_time;
|
||||
dev->current_setup.xres = used_res;
|
||||
dev->current_setup.xres = session.params.xres;
|
||||
dev->current_setup.ccd_size_divisor = session.ccd_size_divisor;
|
||||
dev->current_setup.stagger = stagger;
|
||||
dev->current_setup.max_shift = max_shift + stagger;
|
||||
|
|
|
@ -966,7 +966,7 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
DBG_HELPER(dbg);
|
||||
session.assert_computed();
|
||||
|
||||
int start, used_pixels;
|
||||
int start;
|
||||
int bytes_per_line;
|
||||
int move;
|
||||
unsigned int lincnt;
|
||||
|
@ -999,17 +999,10 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
/* add x coordinates */
|
||||
start = session.params.startx;
|
||||
|
||||
if (stagger > 0)
|
||||
start |= 1;
|
||||
|
||||
/* compute correct pixels number */
|
||||
/* pixels */
|
||||
used_pixels = (session.params.pixels * session.optical_resolution) / session.params.xres;
|
||||
|
||||
/* round up pixels number if needed */
|
||||
if (used_pixels * session.params.xres < session.params.pixels * session.optical_resolution) {
|
||||
used_pixels++;
|
||||
if (stagger > 0) {
|
||||
start |= 1;
|
||||
}
|
||||
|
||||
dummy = 3 - session.params.channels;
|
||||
|
||||
/* slope_dpi */
|
||||
|
@ -1041,8 +1034,8 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
* scan since color calibration is OK for this mode
|
||||
*/
|
||||
gl847_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, used_res, start,
|
||||
used_pixels, session.params.channels, session.params.depth,
|
||||
session.params.color_filter);
|
||||
session.optical_pixels, session.params.channels,
|
||||
session.params.depth, session.params.color_filter);
|
||||
|
||||
/*** motor parameters ***/
|
||||
|
||||
|
@ -1069,13 +1062,14 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
/*** prepares data reordering ***/
|
||||
|
||||
/* words_per_line */
|
||||
bytes_per_line = (used_pixels * used_res) / session.optical_resolution;
|
||||
bytes_per_line = (session.optical_pixels * used_res) / session.optical_resolution;
|
||||
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 * session.params.channels * session.params.depth) / 8;
|
||||
((max_shift + stagger) * session.optical_pixels * session.params.channels *
|
||||
session.params.depth) / 8;
|
||||
|
||||
dev->read_buffer.clear();
|
||||
dev->read_buffer.alloc(read_buffer_size);
|
||||
|
@ -1095,7 +1089,7 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
dev->read_active = SANE_TRUE;
|
||||
|
||||
dev->session = session;
|
||||
dev->current_setup.pixels = (used_pixels * used_res) / session.optical_resolution;
|
||||
dev->current_setup.pixels = (session.optical_pixels * used_res) / session.optical_resolution;
|
||||
dev->current_setup.lines = lincnt;
|
||||
dev->current_setup.exposure_time = exposure_time;
|
||||
dev->current_setup.xres = used_res;
|
||||
|
@ -1135,8 +1129,6 @@ gl847_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
{
|
||||
int start;
|
||||
|
||||
int used_res;
|
||||
int used_pixels;
|
||||
unsigned int lincnt;
|
||||
int exposure_time;
|
||||
int stagger;
|
||||
|
@ -1187,15 +1179,11 @@ gl847_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
|
||||
DBG(DBG_info, "%s: stagger=%d lines\n", __func__, stagger);
|
||||
|
||||
/* resolution is choosen from a fixed list */
|
||||
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 = (session.params.pixels * optical_res) / used_res;
|
||||
dummy = 3 - session.params.channels;
|
||||
|
||||
/* slope_dpi */
|
||||
|
@ -1209,7 +1197,7 @@ gl847_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
|
||||
slope_dpi = slope_dpi * (1 + dummy);
|
||||
|
||||
exposure_time = get_sensor_profile(sensor, used_res).exposure_lperiod;
|
||||
exposure_time = get_sensor_profile(sensor, session.params.xres).exposure_lperiod;
|
||||
DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time);
|
||||
|
||||
max_shift = sanei_genesys_compute_max_shift(dev, session.params.channels, session.params.yres, 0);
|
||||
|
@ -1217,10 +1205,10 @@ gl847_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
lincnt = session.params.lines + max_shift + stagger;
|
||||
|
||||
dev->session = session;
|
||||
dev->current_setup.pixels = (used_pixels * used_res) / optical_res;
|
||||
dev->current_setup.pixels = (session.optical_pixels * session.params.xres) / optical_res;
|
||||
dev->current_setup.lines = lincnt;
|
||||
dev->current_setup.exposure_time = exposure_time;
|
||||
dev->current_setup.xres = used_res;
|
||||
dev->current_setup.xres = session.params.xres;
|
||||
dev->current_setup.ccd_size_divisor = session.ccd_size_divisor;
|
||||
dev->current_setup.stagger = stagger;
|
||||
dev->current_setup.max_shift = max_shift + stagger;
|
||||
|
|
|
@ -1130,6 +1130,14 @@ void sanei_genesys_send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& s
|
|||
}
|
||||
}
|
||||
|
||||
static unsigned align_int_up(unsigned num, unsigned alignment)
|
||||
{
|
||||
unsigned mask = alignment - 1;
|
||||
if (num & mask)
|
||||
num = (num & ~mask) + alignment;
|
||||
return num;
|
||||
}
|
||||
|
||||
void compute_session(Genesys_Device* dev, ScanSession& s, const Genesys_Sensor& sensor)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
|
@ -1146,6 +1154,31 @@ void compute_session(Genesys_Device* dev, ScanSession& s, const Genesys_Sensor&
|
|||
s.optical_resolution = sensor.optical_res / s.ccd_size_divisor;
|
||||
}
|
||||
s.output_resolution = s.params.xres;
|
||||
|
||||
if (s.output_resolution > s.optical_resolution) {
|
||||
throw std::runtime_error("output resolution higher than optical resolution");
|
||||
}
|
||||
|
||||
// compute the number of optical pixels that will be acquired by the chip
|
||||
s.optical_pixels = (s.params.pixels * s.optical_resolution) / s.output_resolution;
|
||||
if (s.optical_pixels * s.output_resolution < s.params.pixels * s.optical_resolution) {
|
||||
s.optical_pixels++;
|
||||
}
|
||||
|
||||
if (dev->model->asic_type == AsicType::GL841) {
|
||||
if (s.optical_pixels & 1)
|
||||
s.optical_pixels++;
|
||||
}
|
||||
|
||||
if (dev->model->asic_type == AsicType::GL646 && s.params.xres == 400) {
|
||||
s.optical_pixels = (s.optical_pixels / 6) * 6;
|
||||
}
|
||||
|
||||
if (dev->model->asic_type == AsicType::GL843) {
|
||||
// ensure the number of optical pixels is divisible by 2.
|
||||
// In quarter-CCD mode optical_pixels is 4x larger than the actual physical number
|
||||
s.optical_pixels = align_int_up(s.optical_pixels, 2 * s.ccd_size_divisor);
|
||||
}
|
||||
}
|
||||
|
||||
/** @brief initialize device
|
||||
|
|
|
@ -228,7 +228,6 @@ struct ScanSession {
|
|||
unsigned optical_resolution = 0;
|
||||
|
||||
// the number of pixels at the optical resolution.
|
||||
// gl843-only
|
||||
unsigned optical_pixels = 0;
|
||||
|
||||
// the number of bytes in the output of a single line directly from scanner
|
||||
|
|
Ładowanie…
Reference in New Issue