kopia lustrzana https://gitlab.com/sane-project/backends
Merge branch 'genesys-session-optical-resolution' into 'master'
genesys: Use common code path to compute session optical_resolution See merge request sane-project/backends!144merge-requests/145/merge
commit
6fcfab3fda
|
@ -1092,8 +1092,7 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
|
|
||||||
debug_dump(DBG_info, session.params);
|
debug_dump(DBG_info, session.params);
|
||||||
|
|
||||||
unsigned optical_res = sensor.optical_res / session.ccd_size_divisor;
|
DBG (DBG_info, "%s: optical_res=%d\n", __func__, session.optical_resolution);
|
||||||
DBG (DBG_info, "%s: optical_res=%d\n", __func__, optical_res);
|
|
||||||
|
|
||||||
/* stagger */
|
/* stagger */
|
||||||
if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) {
|
if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) {
|
||||||
|
@ -1105,14 +1104,14 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
|
|
||||||
/** @brief compute used resolution */
|
/** @brief compute used resolution */
|
||||||
if (session.params.flags & SCAN_FLAG_USE_OPTICAL_RES) {
|
if (session.params.flags & SCAN_FLAG_USE_OPTICAL_RES) {
|
||||||
used_res = optical_res;
|
used_res = session.optical_resolution;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// resolution is choosen from a fixed list and can be used directly, unless we have ydpi
|
// resolution is choosen from a fixed list and can be used directly, unless we have ydpi
|
||||||
// higher than sensor's maximum one */
|
// higher than sensor's maximum one */
|
||||||
if (session.params.xres > optical_res) {
|
if (session.params.xres > session.optical_resolution) {
|
||||||
used_res = optical_res;
|
used_res = session.optical_resolution;
|
||||||
} else {
|
} else {
|
||||||
used_res = session.params.xres;
|
used_res = session.params.xres;
|
||||||
}
|
}
|
||||||
|
@ -1127,11 +1126,11 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
start |= 1;
|
start |= 1;
|
||||||
|
|
||||||
/* compute correct pixels number */
|
/* compute correct pixels number */
|
||||||
used_pixels = (session.params.pixels * optical_res) / session.params.xres;
|
used_pixels = (session.params.pixels * session.optical_resolution) / session.params.xres;
|
||||||
DBG (DBG_info, "%s: used_pixels=%d\n", __func__, used_pixels);
|
DBG (DBG_info, "%s: used_pixels=%d\n", __func__, used_pixels);
|
||||||
|
|
||||||
/* round up pixels number if needed */
|
/* round up pixels number if needed */
|
||||||
if (used_pixels * session.params.xres < session.params.pixels * optical_res) {
|
if (used_pixels * session.params.xres < session.params.pixels * session.optical_resolution) {
|
||||||
used_pixels++;
|
used_pixels++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1202,7 +1201,7 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
/*** prepares data reordering ***/
|
/*** prepares data reordering ***/
|
||||||
|
|
||||||
/* words_per_line */
|
/* words_per_line */
|
||||||
bytes_per_line = (used_pixels * used_res) / optical_res;
|
bytes_per_line = (used_pixels * used_res) / session.optical_resolution;
|
||||||
bytes_per_line = (bytes_per_line * session.params.channels * session.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,
|
/* since we don't have sheetfed scanners to handle,
|
||||||
|
@ -1231,7 +1230,7 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
dev->read_active = SANE_TRUE;
|
dev->read_active = SANE_TRUE;
|
||||||
|
|
||||||
dev->session = session;
|
dev->session = session;
|
||||||
dev->current_setup.pixels = (used_pixels * used_res) / optical_res;
|
dev->current_setup.pixels = (used_pixels * used_res) / session.optical_resolution;
|
||||||
DBG(DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels);
|
DBG(DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels);
|
||||||
dev->current_setup.lines = lincnt;
|
dev->current_setup.lines = lincnt;
|
||||||
dev->current_setup.exposure_time = exposure_time;
|
dev->current_setup.exposure_time = exposure_time;
|
||||||
|
|
|
@ -351,7 +351,7 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
||||||
startx |= 1;
|
startx |= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t pixels = (session.params.pixels * sensor.optical_res) / session.params.xres;
|
uint32_t pixels = (session.params.pixels * session.optical_resolution) / session.params.xres;
|
||||||
// special requirement for 400 dpi on 1200 dpi sensors
|
// special requirement for 400 dpi on 1200 dpi sensors
|
||||||
if (session.params.xres == 400) {
|
if (session.params.xres == 400) {
|
||||||
pixels = (pixels / 6) * 6;
|
pixels = (pixels / 6) * 6;
|
||||||
|
@ -374,12 +374,9 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
||||||
DBG(DBG_info, "%s: startx=%d, endx=%d, linecnt=%d\n", __func__, startx, endx, linecnt);
|
DBG(DBG_info, "%s: startx=%d, endx=%d, linecnt=%d\n", __func__, startx, endx, linecnt);
|
||||||
|
|
||||||
/* x resolution is capped by sensor's capability */
|
/* x resolution is capped by sensor's capability */
|
||||||
if (resolution > sensor.optical_res)
|
if (static_cast<unsigned>(resolution) > session.optical_resolution) {
|
||||||
{
|
xresolution = session.optical_resolution;
|
||||||
xresolution = sensor.optical_res;
|
} else {
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
xresolution = resolution;
|
xresolution = resolution;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1764,8 +1764,6 @@ static void gl841_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
int max_shift;
|
int max_shift;
|
||||||
size_t requested_buffer_size, read_buffer_size;
|
size_t requested_buffer_size, read_buffer_size;
|
||||||
|
|
||||||
int optical_res;
|
|
||||||
|
|
||||||
debug_dump(DBG_info, session.params);
|
debug_dump(DBG_info, session.params);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1796,10 +1794,6 @@ independent of our calculated values:
|
||||||
dev->bytes_to_read
|
dev->bytes_to_read
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* optical_res */
|
|
||||||
|
|
||||||
optical_res = sensor.optical_res / session.ccd_size_divisor;
|
|
||||||
|
|
||||||
/* stagger */
|
/* stagger */
|
||||||
|
|
||||||
if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) {
|
if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) {
|
||||||
|
@ -1810,39 +1804,39 @@ independent of our calculated values:
|
||||||
DBG(DBG_info, "%s : stagger=%d lines\n", __func__, stagger);
|
DBG(DBG_info, "%s : stagger=%d lines\n", __func__, stagger);
|
||||||
|
|
||||||
/* used_res */
|
/* used_res */
|
||||||
i = optical_res / session.params.xres;
|
i = session.optical_resolution / 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 */
|
/* 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 || (session.params.flags & SCAN_FLAG_USE_OPTICAL_RES)) {
|
if (i < 2 || (session.params.flags & SCAN_FLAG_USE_OPTICAL_RES)) {
|
||||||
// optical_res >= xres > optical_res/2
|
// optical_res >= xres > optical_res/2
|
||||||
used_res = optical_res;
|
used_res = session.optical_resolution;
|
||||||
} else if (i < 3) /* optical_res/2 >= xres > optical_res/3 */
|
} else if (i < 3) /* optical_res/2 >= xres > optical_res/3 */
|
||||||
used_res = optical_res/2;
|
used_res = session.optical_resolution/2;
|
||||||
else if (i < 4) /* optical_res/3 >= xres > optical_res/4 */
|
else if (i < 4) /* optical_res/3 >= xres > optical_res/4 */
|
||||||
used_res = optical_res/3;
|
used_res = session.optical_resolution/3;
|
||||||
else if (i < 5) /* optical_res/4 >= xres > optical_res/5 */
|
else if (i < 5) /* optical_res/4 >= xres > optical_res/5 */
|
||||||
used_res = optical_res/4;
|
used_res = session.optical_resolution/4;
|
||||||
else if (i < 6) /* optical_res/5 >= xres > optical_res/6 */
|
else if (i < 6) /* optical_res/5 >= xres > optical_res/6 */
|
||||||
used_res = optical_res/5;
|
used_res = session.optical_resolution/5;
|
||||||
else if (i < 8) /* optical_res/6 >= xres > optical_res/8 */
|
else if (i < 8) /* optical_res/6 >= xres > optical_res/8 */
|
||||||
used_res = optical_res/6;
|
used_res = session.optical_resolution/6;
|
||||||
else if (i < 10) /* optical_res/8 >= xres > optical_res/10 */
|
else if (i < 10) /* optical_res/8 >= xres > optical_res/10 */
|
||||||
used_res = optical_res/8;
|
used_res = session.optical_resolution/8;
|
||||||
else if (i < 12) /* optical_res/10 >= xres > optical_res/12 */
|
else if (i < 12) /* optical_res/10 >= xres > optical_res/12 */
|
||||||
used_res = optical_res/10;
|
used_res = session.optical_resolution/10;
|
||||||
else if (i < 15) /* optical_res/12 >= xres > optical_res/15 */
|
else if (i < 15) /* optical_res/12 >= xres > optical_res/15 */
|
||||||
used_res = optical_res/12;
|
used_res = session.optical_resolution/12;
|
||||||
else
|
else
|
||||||
used_res = optical_res/15;
|
used_res = session.optical_resolution/15;
|
||||||
|
|
||||||
/* compute scan parameters values */
|
/* compute scan parameters values */
|
||||||
/* pixels are allways given at half or full CCD optical resolution */
|
/* pixels are allways given at half or full CCD optical resolution */
|
||||||
/* use detected left margin and fixed value */
|
/* use detected left margin and fixed value */
|
||||||
start = ((sensor.CCD_start_xoffset + session.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 */
|
// needs to be aligned for used_res
|
||||||
start = (start * optical_res) / used_res;
|
start = (start * session.optical_resolution) / used_res;
|
||||||
|
|
||||||
start += sensor.dummy_pixel + 1;
|
start += sensor.dummy_pixel + 1;
|
||||||
|
|
||||||
|
@ -1855,15 +1849,15 @@ independent of our calculated values:
|
||||||
* scan, where shading data needs to be align */
|
* scan, where shading data needs to be align */
|
||||||
if((dev->reg.find_reg(0x01).value & REG01_SHDAREA) != 0)
|
if((dev->reg.find_reg(0x01).value & REG01_SHDAREA) != 0)
|
||||||
{
|
{
|
||||||
avg=optical_res/used_res;
|
avg = session.optical_resolution / used_res;
|
||||||
start=(start/avg)*avg;
|
start=(start/avg)*avg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* compute correct pixels number */
|
/* compute correct pixels number */
|
||||||
used_pixels = (session.params.pixels * optical_res) / session.params.xres;
|
used_pixels = (session.params.pixels * session.optical_resolution) / session.params.xres;
|
||||||
|
|
||||||
/* round up pixels number if needed */
|
/* round up pixels number if needed */
|
||||||
if (used_pixels * session.params.xres < session.params.pixels * optical_res) {
|
if (used_pixels * session.params.xres < session.params.pixels * session.optical_resolution) {
|
||||||
used_pixels++;
|
used_pixels++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1967,7 +1961,7 @@ dummy \ scanned lines
|
||||||
/*** prepares data reordering ***/
|
/*** prepares data reordering ***/
|
||||||
|
|
||||||
/* words_per_line */
|
/* words_per_line */
|
||||||
bytes_per_line = (used_pixels * used_res) / optical_res;
|
bytes_per_line = (used_pixels * used_res) / session.optical_resolution;
|
||||||
bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8;
|
bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8;
|
||||||
|
|
||||||
requested_buffer_size = 8 * bytes_per_line;
|
requested_buffer_size = 8 * bytes_per_line;
|
||||||
|
@ -1997,7 +1991,7 @@ dummy \ scanned lines
|
||||||
dev->read_active = SANE_TRUE;
|
dev->read_active = SANE_TRUE;
|
||||||
|
|
||||||
dev->session = session;
|
dev->session = session;
|
||||||
dev->current_setup.pixels = (used_pixels * used_res)/optical_res;
|
dev->current_setup.pixels = (used_pixels * used_res) / session.optical_resolution;
|
||||||
dev->current_setup.lines = lincnt;
|
dev->current_setup.lines = lincnt;
|
||||||
dev->current_setup.exposure_time = exposure_time;
|
dev->current_setup.exposure_time = exposure_time;
|
||||||
dev->current_setup.xres = used_res;
|
dev->current_setup.xres = used_res;
|
||||||
|
@ -2049,8 +2043,6 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se
|
||||||
int scan_step_type = 1;
|
int scan_step_type = 1;
|
||||||
int max_shift;
|
int max_shift;
|
||||||
|
|
||||||
int optical_res;
|
|
||||||
|
|
||||||
DBG(DBG_info, "%s ", __func__);
|
DBG(DBG_info, "%s ", __func__);
|
||||||
debug_dump(DBG_info, dev->settings);
|
debug_dump(DBG_info, dev->settings);
|
||||||
|
|
||||||
|
@ -2080,10 +2072,6 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se
|
||||||
DBG(DBG_info, "%s ", __func__);
|
DBG(DBG_info, "%s ", __func__);
|
||||||
debug_dump(DBG_info, session.params);
|
debug_dump(DBG_info, session.params);
|
||||||
|
|
||||||
/* optical_res */
|
|
||||||
|
|
||||||
optical_res = sensor.optical_res / session.ccd_size_divisor;
|
|
||||||
|
|
||||||
/* stagger */
|
/* stagger */
|
||||||
|
|
||||||
if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) {
|
if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) {
|
||||||
|
@ -2094,38 +2082,38 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se
|
||||||
DBG(DBG_info, "%s: stagger=%d lines\n", __func__, stagger);
|
DBG(DBG_info, "%s: stagger=%d lines\n", __func__, stagger);
|
||||||
|
|
||||||
/* used_res */
|
/* used_res */
|
||||||
i = optical_res / session.params.xres;
|
i = session.optical_resolution / 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 */
|
/* 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) /* optical_res >= xres > optical_res/2 */
|
if (i < 2) /* optical_res >= xres > optical_res/2 */
|
||||||
used_res = optical_res;
|
used_res = session.optical_resolution;
|
||||||
else if (i < 3) /* optical_res/2 >= xres > optical_res/3 */
|
else if (i < 3) /* optical_res/2 >= xres > optical_res/3 */
|
||||||
used_res = optical_res/2;
|
used_res = session.optical_resolution / 2;
|
||||||
else if (i < 4) /* optical_res/3 >= xres > optical_res/4 */
|
else if (i < 4) /* optical_res/3 >= xres > optical_res/4 */
|
||||||
used_res = optical_res/3;
|
used_res = session.optical_resolution / 3;
|
||||||
else if (i < 5) /* optical_res/4 >= xres > optical_res/5 */
|
else if (i < 5) /* optical_res/4 >= xres > optical_res/5 */
|
||||||
used_res = optical_res/4;
|
used_res = session.optical_resolution / 4;
|
||||||
else if (i < 6) /* optical_res/5 >= xres > optical_res/6 */
|
else if (i < 6) /* optical_res/5 >= xres > optical_res/6 */
|
||||||
used_res = optical_res/5;
|
used_res = session.optical_resolution / 5;
|
||||||
else if (i < 8) /* optical_res/6 >= xres > optical_res/8 */
|
else if (i < 8) /* optical_res/6 >= xres > optical_res/8 */
|
||||||
used_res = optical_res/6;
|
used_res = session.optical_resolution / 6;
|
||||||
else if (i < 10) /* optical_res/8 >= xres > optical_res/10 */
|
else if (i < 10) /* optical_res/8 >= xres > optical_res/10 */
|
||||||
used_res = optical_res/8;
|
used_res = session.optical_resolution / 8;
|
||||||
else if (i < 12) /* optical_res/10 >= xres > optical_res/12 */
|
else if (i < 12) /* optical_res/10 >= xres > optical_res/12 */
|
||||||
used_res = optical_res/10;
|
used_res = session.optical_resolution / 10;
|
||||||
else if (i < 15) /* optical_res/12 >= xres > optical_res/15 */
|
else if (i < 15) /* optical_res/12 >= xres > optical_res/15 */
|
||||||
used_res = optical_res/12;
|
used_res = session.optical_resolution / 12;
|
||||||
else
|
else
|
||||||
used_res = optical_res/15;
|
used_res = session.optical_resolution / 15;
|
||||||
|
|
||||||
/* compute scan parameters values */
|
/* compute scan parameters values */
|
||||||
/* pixels are allways given at half or full CCD optical resolution */
|
/* pixels are allways given at half or full CCD optical resolution */
|
||||||
/* use detected left margin and fixed value */
|
/* use detected left margin and fixed value */
|
||||||
start = ((sensor.CCD_start_xoffset + session.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 */
|
// needs to be aligned for used_res
|
||||||
start = (start * optical_res) / used_res;
|
start = (start * session.optical_resolution) / used_res;
|
||||||
|
|
||||||
start += sensor.dummy_pixel + 1;
|
start += sensor.dummy_pixel + 1;
|
||||||
|
|
||||||
|
@ -2133,10 +2121,10 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se
|
||||||
start |= 1;
|
start |= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
used_pixels = (session.params.pixels * optical_res) / session.params.xres;
|
used_pixels = (session.params.pixels * session.optical_resolution) / session.params.xres;
|
||||||
|
|
||||||
// round up pixels number if needed
|
// round up pixels number if needed
|
||||||
if (used_pixels * session.params.xres < session.params.pixels * optical_res) {
|
if (used_pixels * session.params.xres < session.params.pixels * session.optical_resolution) {
|
||||||
used_pixels++;
|
used_pixels++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2191,7 +2179,7 @@ dummy \ scanned lines
|
||||||
lincnt = session.params.lines + max_shift + stagger;
|
lincnt = session.params.lines + max_shift + stagger;
|
||||||
|
|
||||||
dev->session = session;
|
dev->session = session;
|
||||||
dev->current_setup.pixels = (used_pixels * used_res)/optical_res;
|
dev->current_setup.pixels = (used_pixels * used_res) / session.optical_resolution;
|
||||||
dev->current_setup.lines = lincnt;
|
dev->current_setup.lines = lincnt;
|
||||||
dev->current_setup.exposure_time = exposure_time;
|
dev->current_setup.exposure_time = exposure_time;
|
||||||
dev->current_setup.xres = used_res;
|
dev->current_setup.xres = used_res;
|
||||||
|
|
|
@ -1201,9 +1201,6 @@ static void gl843_compute_session(Genesys_Device* dev, ScanSession& s,
|
||||||
// compute optical and output resolutions
|
// compute optical and output resolutions
|
||||||
s.hwdpi_divisor = sensor.get_hwdpi_divisor_for_dpi(s.params.xres);
|
s.hwdpi_divisor = sensor.get_hwdpi_divisor_for_dpi(s.params.xres);
|
||||||
|
|
||||||
s.optical_resolution = sensor.optical_res / s.ccd_size_divisor;
|
|
||||||
s.output_resolution = s.params.xres;
|
|
||||||
|
|
||||||
if (s.output_resolution > s.optical_resolution) {
|
if (s.output_resolution > s.optical_resolution) {
|
||||||
throw std::runtime_error("output resolution higher than optical resolution");
|
throw std::runtime_error("output resolution higher than optical resolution");
|
||||||
}
|
}
|
||||||
|
@ -1413,8 +1410,6 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
||||||
|
|
||||||
int max_shift;
|
int max_shift;
|
||||||
|
|
||||||
int optical_res;
|
|
||||||
|
|
||||||
DBG(DBG_info, "%s ", __func__);
|
DBG(DBG_info, "%s ", __func__);
|
||||||
debug_dump(DBG_info, dev->settings);
|
debug_dump(DBG_info, dev->settings);
|
||||||
|
|
||||||
|
@ -1458,9 +1453,6 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
||||||
DBG(DBG_info, "%s ", __func__);
|
DBG(DBG_info, "%s ", __func__);
|
||||||
debug_dump(DBG_info, session.params);
|
debug_dump(DBG_info, session.params);
|
||||||
|
|
||||||
// optical_res
|
|
||||||
optical_res = sensor.optical_res / session.ccd_size_divisor;
|
|
||||||
|
|
||||||
/* stagger */
|
/* stagger */
|
||||||
if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) {
|
if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) {
|
||||||
stagger = (4 * session.params.yres) / dev->motor.base_ydpi;
|
stagger = (4 * session.params.yres) / dev->motor.base_ydpi;
|
||||||
|
@ -1469,10 +1461,10 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
||||||
}
|
}
|
||||||
DBG(DBG_info, "%s: stagger=%d lines\n", __func__, stagger);
|
DBG(DBG_info, "%s: stagger=%d lines\n", __func__, stagger);
|
||||||
|
|
||||||
if (session.params.xres <= (unsigned) optical_res) {
|
if (session.params.xres <= (unsigned) session.optical_resolution) {
|
||||||
used_res = session.params.xres;
|
used_res = session.params.xres;
|
||||||
} else {
|
} else {
|
||||||
used_res = optical_res;
|
used_res = session.optical_resolution;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* compute scan parameters values */
|
/* compute scan parameters values */
|
||||||
|
@ -1480,7 +1472,7 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
||||||
/* use detected left margin and fixed value */
|
/* use detected left margin and fixed value */
|
||||||
|
|
||||||
/* compute correct pixels number */
|
/* compute correct pixels number */
|
||||||
used_pixels = (session.params.pixels * optical_res) / session.params.xres;
|
used_pixels = (session.params.pixels * session.optical_resolution) / session.params.xres;
|
||||||
DBG(DBG_info, "%s: used_pixels=%d\n", __func__, used_pixels);
|
DBG(DBG_info, "%s: used_pixels=%d\n", __func__, used_pixels);
|
||||||
|
|
||||||
/* exposure */
|
/* exposure */
|
||||||
|
@ -1509,7 +1501,7 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor
|
||||||
lincnt = session.params.lines + max_shift + stagger;
|
lincnt = session.params.lines + max_shift + stagger;
|
||||||
|
|
||||||
dev->session = session;
|
dev->session = session;
|
||||||
dev->current_setup.pixels = (used_pixels * used_res) / optical_res;
|
dev->current_setup.pixels = (used_pixels * used_res) / session.optical_resolution;
|
||||||
DBG(DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels);
|
DBG(DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels);
|
||||||
dev->current_setup.lines = lincnt;
|
dev->current_setup.lines = lincnt;
|
||||||
dev->current_setup.exposure_time = exposure;
|
dev->current_setup.exposure_time = exposure;
|
||||||
|
|
|
@ -971,12 +971,8 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
int max_shift;
|
int max_shift;
|
||||||
size_t requested_buffer_size, read_buffer_size;
|
size_t requested_buffer_size, read_buffer_size;
|
||||||
|
|
||||||
int optical_res;
|
|
||||||
|
|
||||||
debug_dump(DBG_info, session.params);
|
debug_dump(DBG_info, session.params);
|
||||||
|
|
||||||
optical_res = sensor.optical_res / session.ccd_size_divisor;
|
|
||||||
|
|
||||||
/* stagger */
|
/* stagger */
|
||||||
if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) {
|
if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) {
|
||||||
stagger = (4 * session.params.yres) / dev->motor.base_ydpi;
|
stagger = (4 * session.params.yres) / dev->motor.base_ydpi;
|
||||||
|
@ -986,7 +982,7 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
DBG(DBG_info, "%s : stagger=%d lines\n", __func__, stagger);
|
DBG(DBG_info, "%s : stagger=%d lines\n", __func__, stagger);
|
||||||
|
|
||||||
if (session.params.flags & SCAN_FLAG_USE_OPTICAL_RES) {
|
if (session.params.flags & SCAN_FLAG_USE_OPTICAL_RES) {
|
||||||
used_res = optical_res;
|
used_res = session.optical_resolution;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1006,10 +1002,10 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
}
|
}
|
||||||
|
|
||||||
/* compute correct pixels number */
|
/* compute correct pixels number */
|
||||||
used_pixels = (session.params.pixels * optical_res) / session.params.xres;
|
used_pixels = (session.params.pixels * session.optical_resolution) / session.params.xres;
|
||||||
|
|
||||||
/* round up pixels number if needed */
|
/* round up pixels number if needed */
|
||||||
if (used_pixels * session.params.xres < session.params.pixels * optical_res) {
|
if (used_pixels * session.params.xres < session.params.pixels * session.optical_resolution) {
|
||||||
used_pixels++;
|
used_pixels++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1074,7 +1070,7 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
/*** prepares data reordering ***/
|
/*** prepares data reordering ***/
|
||||||
|
|
||||||
/* words_per_line */
|
/* words_per_line */
|
||||||
bytes_per_line = (used_pixels * used_res) / optical_res;
|
bytes_per_line = (used_pixels * used_res) / session.optical_resolution;
|
||||||
bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8;
|
bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8;
|
||||||
|
|
||||||
requested_buffer_size = 8 * bytes_per_line;
|
requested_buffer_size = 8 * bytes_per_line;
|
||||||
|
@ -1100,7 +1096,7 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
dev->read_active = SANE_TRUE;
|
dev->read_active = SANE_TRUE;
|
||||||
|
|
||||||
dev->session = session;
|
dev->session = session;
|
||||||
dev->current_setup.pixels = (used_pixels * used_res) / optical_res;
|
dev->current_setup.pixels = (used_pixels * used_res) / session.optical_resolution;
|
||||||
dev->current_setup.lines = lincnt;
|
dev->current_setup.lines = lincnt;
|
||||||
dev->current_setup.exposure_time = exposure_time;
|
dev->current_setup.exposure_time = exposure_time;
|
||||||
dev->current_setup.xres = used_res;
|
dev->current_setup.xres = used_res;
|
||||||
|
|
|
@ -990,12 +990,8 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
int max_shift;
|
int max_shift;
|
||||||
size_t requested_buffer_size, read_buffer_size;
|
size_t requested_buffer_size, read_buffer_size;
|
||||||
|
|
||||||
int optical_res;
|
|
||||||
|
|
||||||
debug_dump(DBG_info, session.params);
|
debug_dump(DBG_info, session.params);
|
||||||
|
|
||||||
optical_res = sensor.optical_res / session.ccd_size_divisor;
|
|
||||||
|
|
||||||
/* stagger */
|
/* stagger */
|
||||||
if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) {
|
if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) {
|
||||||
stagger = (4 * session.params.yres) / dev->motor.base_ydpi;
|
stagger = (4 * session.params.yres) / dev->motor.base_ydpi;
|
||||||
|
@ -1006,10 +1002,8 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
|
|
||||||
/* used_res */
|
/* used_res */
|
||||||
if (session.params.flags & SCAN_FLAG_USE_OPTICAL_RES) {
|
if (session.params.flags & SCAN_FLAG_USE_OPTICAL_RES) {
|
||||||
used_res = optical_res;
|
used_res = session.optical_resolution;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
/* resolution is choosen from a list */
|
/* resolution is choosen from a list */
|
||||||
used_res = session.params.xres;
|
used_res = session.params.xres;
|
||||||
}
|
}
|
||||||
|
@ -1026,10 +1020,10 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
|
|
||||||
/* compute correct pixels number */
|
/* compute correct pixels number */
|
||||||
/* pixels */
|
/* pixels */
|
||||||
used_pixels = (session.params.pixels * optical_res) / session.params.xres;
|
used_pixels = (session.params.pixels * session.optical_resolution) / session.params.xres;
|
||||||
|
|
||||||
/* round up pixels number if needed */
|
/* round up pixels number if needed */
|
||||||
if (used_pixels * session.params.xres < session.params.pixels * optical_res) {
|
if (used_pixels * session.params.xres < session.params.pixels * session.optical_resolution) {
|
||||||
used_pixels++;
|
used_pixels++;
|
||||||
}
|
}
|
||||||
dummy = 3 - session.params.channels;
|
dummy = 3 - session.params.channels;
|
||||||
|
@ -1091,7 +1085,7 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
/*** prepares data reordering ***/
|
/*** prepares data reordering ***/
|
||||||
|
|
||||||
/* words_per_line */
|
/* words_per_line */
|
||||||
bytes_per_line = (used_pixels * used_res) / optical_res;
|
bytes_per_line = (used_pixels * used_res) / session.optical_resolution;
|
||||||
bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8;
|
bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8;
|
||||||
|
|
||||||
requested_buffer_size = 8 * bytes_per_line;
|
requested_buffer_size = 8 * bytes_per_line;
|
||||||
|
@ -1117,7 +1111,7 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
||||||
dev->read_active = SANE_TRUE;
|
dev->read_active = SANE_TRUE;
|
||||||
|
|
||||||
dev->session = session;
|
dev->session = session;
|
||||||
dev->current_setup.pixels = (used_pixels * used_res) / optical_res;
|
dev->current_setup.pixels = (used_pixels * used_res) / session.optical_resolution;
|
||||||
dev->current_setup.lines = lincnt;
|
dev->current_setup.lines = lincnt;
|
||||||
dev->current_setup.exposure_time = exposure_time;
|
dev->current_setup.exposure_time = exposure_time;
|
||||||
dev->current_setup.xres = used_res;
|
dev->current_setup.xres = used_res;
|
||||||
|
|
|
@ -1139,6 +1139,13 @@ void compute_session(Genesys_Device* dev, ScanSession& s, const Genesys_Sensor&
|
||||||
|
|
||||||
// compute optical and output resolutions
|
// compute optical and output resolutions
|
||||||
s.ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(s.params.xres);
|
s.ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(s.params.xres);
|
||||||
|
|
||||||
|
if (dev->model->asic_type == AsicType::GL646) {
|
||||||
|
s.optical_resolution = sensor.optical_res;
|
||||||
|
} else {
|
||||||
|
s.optical_resolution = sensor.optical_res / s.ccd_size_divisor;
|
||||||
|
}
|
||||||
|
s.output_resolution = s.params.xres;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief initialize device
|
/** @brief initialize device
|
||||||
|
|
|
@ -205,7 +205,6 @@ struct ScanSession {
|
||||||
unsigned ccd_size_divisor = 1;
|
unsigned ccd_size_divisor = 1;
|
||||||
|
|
||||||
// the optical resolution of the scanner.
|
// the optical resolution of the scanner.
|
||||||
// gl843-only
|
|
||||||
unsigned optical_resolution = 0;
|
unsigned optical_resolution = 0;
|
||||||
|
|
||||||
// the number of pixels at the optical resolution.
|
// the number of pixels at the optical resolution.
|
||||||
|
|
Ładowanie…
Reference in New Issue