genesys: Don't duplicate data passed to *_init_optical_regs_scan()

merge-requests/160/head
Povilas Kanapickas 2019-09-12 20:06:36 +03:00
rodzic f44c0bb680
commit 463f5f4364
4 zmienionych plików z 63 dodań i 92 usunięć

Wyświetl plik

@ -824,14 +824,10 @@ static void gl124_setup_sensor(Genesys_Device * dev,
*/ */
static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg, unsigned int exposure_time, Genesys_Register_Set* reg, unsigned int exposure_time,
const ScanSession& session, int used_res, const ScanSession& session, unsigned int start)
unsigned int start, unsigned int pixels,
int channels, int depth, unsigned ccd_size_divisor,
ColorFilter color_filter)
{ {
DBG_HELPER_ARGS(dbg, "exposure_time=%d, used_res=%d, start=%d, pixels=%d, channels=%d, depth=%d, " DBG_HELPER_ARGS(dbg, "exposure_time=%d, start=%d\n",
"ccd_size_divisor=%d\n", exposure_time, start);
exposure_time, used_res, start, pixels, channels, depth, ccd_size_divisor);
unsigned int words_per_line, segcnt; unsigned int words_per_line, segcnt;
unsigned int startx, endx, segnb; unsigned int startx, endx, segnb;
unsigned int dpiset, dpihw, factor; unsigned int dpiset, dpihw, factor;
@ -845,18 +841,18 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
// to manage high resolution device while keeping good low resolution scanning speed, we // to manage high resolution device while keeping good low resolution scanning speed, we
// make hardware dpi vary // make hardware dpi vary
dpihw = sensor.get_register_hwdpi(used_res * ccd_pixels_per_system_pixel); dpihw = sensor.get_register_hwdpi(session.params.xres * ccd_pixels_per_system_pixel);
factor = sensor.get_hwdpi_divisor_for_dpi(used_res * ccd_pixels_per_system_pixel); factor = sensor.get_hwdpi_divisor_for_dpi(session.params.xres * ccd_pixels_per_system_pixel);
DBG (DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor); DBG (DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor);
// sensor parameters // sensor parameters
gl124_setup_sensor(dev, sensor, reg, dpihw, ccd_size_divisor); gl124_setup_sensor(dev, sensor, reg, dpihw, session.ccd_size_divisor);
dpiset = used_res * ccd_pixels_per_system_pixel; dpiset = session.params.xres * ccd_pixels_per_system_pixel;
/* start and end coordinate in optical dpi coordinates */ /* start and end coordinate in optical dpi coordinates */
/* startx = start / ccd_pixels_per_system_pixel + sensor.dummy_pixel; XXX STEF XXX */ /* startx = start / ccd_pixels_per_system_pixel + sensor.dummy_pixel; XXX STEF XXX */
startx = start / ccd_pixels_per_system_pixel; startx = start / ccd_pixels_per_system_pixel;
endx = startx + pixels / ccd_pixels_per_system_pixel; endx = startx + session.optical_pixels / ccd_pixels_per_system_pixel;
/* pixel coordinate factor correction when used dpihw is not maximal one */ /* pixel coordinate factor correction when used dpihw is not maximal one */
startx/=factor; startx/=factor;
@ -880,7 +876,7 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
r->value &= ~REG01_SCAN; r->value &= ~REG01_SCAN;
r = sanei_genesys_get_address (reg, REG03); r = sanei_genesys_get_address (reg, REG03);
if((dev->model->ccd_type!=CIS_CANONLIDE120)&&(used_res>=600)) if((dev->model->ccd_type!=CIS_CANONLIDE120)&&(session.params.xres>=600))
{ {
r->value &= ~REG03_AVEENB; r->value &= ~REG03_AVEENB;
DBG (DBG_io, "%s: disabling AVEENB\n", __func__); DBG (DBG_io, "%s: disabling AVEENB\n", __func__);
@ -900,7 +896,7 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
/* monochrome / color scan */ /* monochrome / color scan */
r = sanei_genesys_get_address (reg, REG04); r = sanei_genesys_get_address (reg, REG04);
switch (depth) switch (session.params.depth)
{ {
case 1: case 1:
r->value &= ~REG04_BITSET; r->value &= ~REG04_BITSET;
@ -916,9 +912,9 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
} }
r->value &= ~REG04_FILTER; r->value &= ~REG04_FILTER;
if (channels == 1) if (session.params.channels == 1)
{ {
switch (color_filter) switch (session.params.color_filter)
{ {
case ColorFilter::RED: case ColorFilter::RED:
r->value |= 0x10; r->value |= 0x10;
@ -944,7 +940,7 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
r->value |= REG05_GMMENB; r->value |= REG05_GMMENB;
} }
unsigned dpiset_reg = dpiset * ccd_size_divisor; unsigned dpiset_reg = dpiset * session.ccd_size_divisor;
if (sensor.dpiset_override != 0) { if (sensor.dpiset_override != 0) {
dpiset_reg = sensor.dpiset_override; dpiset_reg = sensor.dpiset_override;
} }
@ -998,8 +994,8 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
/* words(16bit) before gamma, conversion to 8 bit or lineart */ /* words(16bit) before gamma, conversion to 8 bit or lineart */
words_per_line = (used_pixels * dpiset) / dpihw; words_per_line = (used_pixels * dpiset) / dpihw;
bytes = depth / 8; bytes = session.params.depth / 8;
if (depth == 1) if (session.params.depth == 1)
{ {
words_per_line = (words_per_line >> 3) + ((words_per_line & 7) ? 1 : 0); words_per_line = (words_per_line >> 3) + ((words_per_line & 7) ? 1 : 0);
} }
@ -1018,14 +1014,14 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
dev->line_interp = 0; dev->line_interp = 0;
DBG (DBG_io2, "%s: used_pixels =%d\n", __func__, used_pixels); DBG (DBG_io2, "%s: used_pixels =%d\n", __func__, used_pixels);
DBG (DBG_io2, "%s: pixels =%d\n", __func__, pixels); DBG (DBG_io2, "%s: pixels =%d\n", __func__, session.optical_pixels);
DBG (DBG_io2, "%s: depth =%d\n", __func__, depth); DBG (DBG_io2, "%s: depth =%d\n", __func__, session.params.depth);
DBG (DBG_io2, "%s: dev->bpl =%lu\n", __func__, (unsigned long)dev->bpl); DBG (DBG_io2, "%s: dev->bpl =%lu\n", __func__, (unsigned long)dev->bpl);
DBG (DBG_io2, "%s: dev->len =%lu\n", __func__, (unsigned long)dev->len); DBG (DBG_io2, "%s: dev->len =%lu\n", __func__, (unsigned long)dev->len);
DBG (DBG_io2, "%s: dev->dist =%lu\n", __func__, (unsigned long)dev->dist); DBG (DBG_io2, "%s: dev->dist =%lu\n", __func__, (unsigned long)dev->dist);
DBG (DBG_io2, "%s: dev->line_interp=%lu\n", __func__, (unsigned long)dev->line_interp); DBG (DBG_io2, "%s: dev->line_interp=%lu\n", __func__, (unsigned long)dev->line_interp);
words_per_line *= channels; words_per_line *= session.params.channels;
dev->wpl = words_per_line; dev->wpl = words_per_line;
/* allocate buffer for odd/even pixels handling */ /* allocate buffer for odd/even pixels handling */
@ -1120,11 +1116,7 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
*/ */
// now _LOGICAL_ optical values used are known, setup registers // now _LOGICAL_ optical values used are known, setup registers
gl124_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, session.params.xres, gl124_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, start);
start,
session.optical_pixels, session.params.channels,
session.params.depth, session.ccd_size_divisor,
session.params.color_filter);
/* add tl_y to base movement */ /* add tl_y to base movement */
move = session.params.starty; move = session.params.starty;

Wyświetl plik

@ -1453,27 +1453,21 @@ static void gl841_init_optical_regs_off(Genesys_Register_Set* reg)
static void gl841_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, static void gl841_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg, unsigned int exposure_time, Genesys_Register_Set* reg, unsigned int exposure_time,
const ScanSession& session, unsigned int used_res, const ScanSession& session, unsigned int start)
unsigned int start,
unsigned int pixels, int channels,
int depth, unsigned ccd_size_divisor,
ColorFilter color_filter)
{ {
DBG_HELPER_ARGS(dbg, "exposure_time=%d, used_res=%d, start=%d, pixels=%d, channels=%d, " DBG_HELPER_ARGS(dbg, "exposure_time=%d, start=%d", exposure_time, start);
"depth=%d, ccd_size_divisor=%d",
exposure_time, used_res, start, pixels, channels, depth, ccd_size_divisor);
unsigned int words_per_line; unsigned int words_per_line;
unsigned int end; unsigned int end;
unsigned int dpiset; unsigned int dpiset;
GenesysRegister* r; GenesysRegister* r;
uint16_t expavg, expr, expb, expg; uint16_t expavg, expr, expb, expg;
end = start + pixels; end = start + session.optical_pixels;
gl841_set_fe(dev, sensor, AFE_SET); gl841_set_fe(dev, sensor, AFE_SET);
/* adjust used_res for chosen dpihw */ /* adjust used_res for chosen dpihw */
used_res = used_res * gl841_get_dpihw(dev) / sensor.optical_res; unsigned used_res = session.params.xres * gl841_get_dpihw(dev) / sensor.optical_res;
/* /*
with ccd_size_divisor==2 the optical resolution of the ccd is halved. We don't apply this with ccd_size_divisor==2 the optical resolution of the ccd is halved. We don't apply this
@ -1482,13 +1476,13 @@ static void gl841_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
For the scanner only the ratio of dpiset and dpihw is of relevance to scale For the scanner only the ratio of dpiset and dpihw is of relevance to scale
down properly. down properly.
*/ */
dpiset = used_res * ccd_size_divisor; dpiset = used_res * session.ccd_size_divisor;
/* gpio part.*/ /* gpio part.*/
if (dev->model->gpo_type == GPO_CANONLIDE35) if (dev->model->gpo_type == GPO_CANONLIDE35)
{ {
r = sanei_genesys_get_address (reg, REG6C); r = sanei_genesys_get_address (reg, REG6C);
if (ccd_size_divisor > 1) { if (session.ccd_size_divisor > 1) {
r->value &= ~0x80; r->value &= ~0x80;
} else { } else {
r->value |= 0x80; r->value |= 0x80;
@ -1497,7 +1491,7 @@ static void gl841_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
if (dev->model->gpo_type == GPO_CANONLIDE80) if (dev->model->gpo_type == GPO_CANONLIDE80)
{ {
r = sanei_genesys_get_address (reg, REG6C); r = sanei_genesys_get_address (reg, REG6C);
if (ccd_size_divisor > 1) { if (session.ccd_size_divisor > 1) {
r->value &= ~0x40; r->value &= ~0x40;
r->value |= 0x20; r->value |= 0x20;
} else { } else {
@ -1534,7 +1528,7 @@ static void gl841_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
/* monochrome / color scan */ /* monochrome / color scan */
r = sanei_genesys_get_address (reg, 0x04); r = sanei_genesys_get_address (reg, 0x04);
switch (depth) { switch (session.params.depth) {
case 1: case 1:
r->value &= ~REG04_BITSET; r->value &= ~REG04_BITSET;
r->value |= REG04_LINEART; r->value |= REG04_LINEART;
@ -1554,9 +1548,9 @@ static void gl841_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
if (session.params.flags & SCAN_FLAG_ENABLE_LEDADD) { if (session.params.flags & SCAN_FLAG_ENABLE_LEDADD) {
r->value |= 0x10; /* no filter */ r->value |= 0x10; /* no filter */
} }
else if (channels == 1) else if (session.params.channels == 1)
{ {
switch (color_filter) switch (session.params.color_filter)
{ {
case ColorFilter::RED: case ColorFilter::RED:
r->value |= 0x14; r->value |= 0x14;
@ -1614,7 +1608,7 @@ static void gl841_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
} }
/* sensor parameters */ /* sensor parameters */
sanei_gl841_setup_sensor(dev, sensor, &dev->reg, 1, ccd_size_divisor); sanei_gl841_setup_sensor(dev, sensor, &dev->reg, 1, session.ccd_size_divisor);
r = sanei_genesys_get_address (reg, 0x29); r = sanei_genesys_get_address (reg, 0x29);
r->value = 255; /*<<<"magic" number, only suitable for cis*/ r->value = 255; /*<<<"magic" number, only suitable for cis*/
@ -1625,14 +1619,14 @@ static void gl841_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
DBG(DBG_io2, "%s: STRPIXEL=%d, ENDPIXEL=%d\n", __func__, start, end); DBG(DBG_io2, "%s: STRPIXEL=%d, ENDPIXEL=%d\n", __func__, start, end);
/* words(16bit) before gamma, conversion to 8 bit or lineart*/ /* words(16bit) before gamma, conversion to 8 bit or lineart*/
words_per_line = (pixels * dpiset) / gl841_get_dpihw(dev); words_per_line = (session.optical_pixels * dpiset) / gl841_get_dpihw(dev);
words_per_line *= channels; words_per_line *= session.params.channels;
if (depth == 1) if (session.params.depth == 1)
words_per_line = (words_per_line >> 3) + ((words_per_line & 7)?1:0); words_per_line = (words_per_line >> 3) + ((words_per_line & 7)?1:0);
else else
words_per_line *= depth / 8; words_per_line *= session.params.depth / 8;
dev->wpl = words_per_line; dev->wpl = words_per_line;
dev->bpl = words_per_line; dev->bpl = words_per_line;
@ -1883,10 +1877,7 @@ dummy \ scanned lines
session.params.flags |= SCAN_FLAG_DISABLE_GAMMA; session.params.flags |= SCAN_FLAG_DISABLE_GAMMA;
} }
gl841_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, session.params.xres, start, gl841_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, start);
session.optical_pixels, session.params.channels,
session.params.depth, session.ccd_size_divisor,
session.params.color_filter);
move = session.params.starty; move = session.params.starty;
DBG(DBG_info, "%s: move=%d steps\n", __func__, move); DBG(DBG_info, "%s: move=%d steps\n", __func__, move);

Wyświetl plik

@ -722,12 +722,9 @@ static void gl846_init_motor_regs_scan(Genesys_Device* dev,
*/ */
static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg, unsigned int exposure_time, Genesys_Register_Set* reg, unsigned int exposure_time,
const ScanSession& session, int used_res, const ScanSession& session, unsigned int start)
unsigned int start, unsigned int pixels,
int channels, int depth, ColorFilter color_filter)
{ {
DBG_HELPER_ARGS(dbg, "exposure_time=%d, used_res=%d, start=%d, pixels=%d, channels=%d, depth=%d", DBG_HELPER_ARGS(dbg, "exposure_time=%d, start=%d", exposure_time, start);
exposure_time, used_res, start, pixels, channels, depth);
unsigned int words_per_line; unsigned int words_per_line;
unsigned int dpiset, dpihw, segnb, factor; unsigned int dpiset, dpihw, segnb, factor;
unsigned int bytes; unsigned int bytes;
@ -739,18 +736,18 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
// to manage high resolution device while keeping good low resolution scanning speed, // to manage high resolution device while keeping good low resolution scanning speed,
// we make hardware dpi vary // we make hardware dpi vary
dpihw = sensor.get_register_hwdpi(used_res * ccd_pixels_per_system_pixel); dpihw = sensor.get_register_hwdpi(session.params.xres * ccd_pixels_per_system_pixel);
factor = sensor.optical_res/dpihw; factor = sensor.optical_res/dpihw;
DBG(DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor); DBG(DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor);
// sensor parameters // sensor parameters
const auto& sensor_profile = get_sensor_profile(sensor, dpihw); const auto& sensor_profile = get_sensor_profile(sensor, dpihw);
gl846_setup_sensor(dev, sensor, reg, dpihw); gl846_setup_sensor(dev, sensor, reg, dpihw);
dpiset = used_res * ccd_pixels_per_system_pixel ; dpiset = session.params.xres * ccd_pixels_per_system_pixel ;
// start and end coordinate in optical dpi coordinates // start and end coordinate in optical dpi coordinates
unsigned startx = start / ccd_pixels_per_system_pixel + sensor.CCD_start_xoffset; unsigned startx = start / ccd_pixels_per_system_pixel + sensor.CCD_start_xoffset;
unsigned endx = startx + pixels / ccd_pixels_per_system_pixel; unsigned endx = startx + session.optical_pixels / ccd_pixels_per_system_pixel;
/* sensors are built from 600 dpi segments for LiDE 100/200 /* sensors are built from 600 dpi segments for LiDE 100/200
* and 1200 dpi for the 700F */ * and 1200 dpi for the 700F */
@ -810,7 +807,7 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
/* monochrome / color scan */ /* monochrome / color scan */
r = sanei_genesys_get_address (reg, REG04); r = sanei_genesys_get_address (reg, REG04);
switch (depth) switch (session.params.depth)
{ {
case 1: case 1:
r->value &= ~REG04_BITSET; r->value &= ~REG04_BITSET;
@ -826,9 +823,9 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
} }
r->value &= ~(REG04_FILTER | REG04_AFEMOD); r->value &= ~(REG04_FILTER | REG04_AFEMOD);
if (channels == 1) if (session.params.channels == 1)
{ {
switch (color_filter) switch (session.params.color_filter)
{ {
case ColorFilter::RED: case ColorFilter::RED:
r->value |= 0x24; r->value |= 0x24;
@ -876,8 +873,8 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
/* words(16bit) before gamma, conversion to 8 bit or lineart*/ /* words(16bit) before gamma, conversion to 8 bit or lineart*/
words_per_line = (used_pixels * dpiset) / dpihw; words_per_line = (used_pixels * dpiset) / dpihw;
bytes=depth/8; bytes=session.params.depth/8;
if (depth == 1) if (session.params.depth == 1)
{ {
words_per_line = (words_per_line+7)/8 ; words_per_line = (words_per_line+7)/8 ;
dev->len = (dev->len >> 3) + ((dev->len & 7) ? 1 : 0); dev->len = (dev->len >> 3) + ((dev->len & 7) ? 1 : 0);
@ -904,14 +901,14 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
DBG (DBG_io2, "%s: endx =%d\n", __func__, endx); DBG (DBG_io2, "%s: endx =%d\n", __func__, endx);
DBG (DBG_io2, "%s: used_pixels=%d\n", __func__, used_pixels); DBG (DBG_io2, "%s: used_pixels=%d\n", __func__, used_pixels);
DBG (DBG_io2, "%s: pixels =%d\n", __func__, pixels); DBG (DBG_io2, "%s: pixels =%d\n", __func__, session.optical_pixels);
DBG (DBG_io2, "%s: depth =%d\n", __func__, depth); DBG (DBG_io2, "%s: depth =%d\n", __func__, session.params.depth);
DBG (DBG_io2, "%s: dev->bpl =%lu\n", __func__, (unsigned long)dev->bpl); DBG (DBG_io2, "%s: dev->bpl =%lu\n", __func__, (unsigned long)dev->bpl);
DBG (DBG_io2, "%s: dev->len =%lu\n", __func__, (unsigned long)dev->len); DBG (DBG_io2, "%s: dev->len =%lu\n", __func__, (unsigned long)dev->len);
DBG (DBG_io2, "%s: dev->dist =%lu\n", __func__, (unsigned long)dev->dist); DBG (DBG_io2, "%s: dev->dist =%lu\n", __func__, (unsigned long)dev->dist);
DBG (DBG_io2, "%s: dev->segnb =%lu\n", __func__, (unsigned long)dev->segnb); DBG (DBG_io2, "%s: dev->segnb =%lu\n", __func__, (unsigned long)dev->segnb);
words_per_line *= channels; words_per_line *= session.params.channels;
dev->wpl = words_per_line; dev->wpl = words_per_line;
dev->oe_buffer.clear(); dev->oe_buffer.clear();
@ -1001,9 +998,7 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
/* we enable true gray for cis scanners only, and just when doing /* we enable true gray for cis scanners only, and just when doing
* scan since color calibration is OK for this mode * scan since color calibration is OK for this mode
*/ */
gl846_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, session.params.xres, start, gl846_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, start);
session.optical_pixels, session.params.channels, session.params.depth,
session.params.color_filter);
/*** motor parameters ***/ /*** motor parameters ***/

Wyświetl plik

@ -741,14 +741,9 @@ static void gl847_init_motor_regs_scan(Genesys_Device* dev,
*/ */
static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set* reg, unsigned int exposure_time, Genesys_Register_Set* reg, unsigned int exposure_time,
const ScanSession& session, int used_res, const ScanSession& session, unsigned int start)
unsigned int start, unsigned int pixels,
int channels, int depth,
ColorFilter color_filter)
{ {
DBG_HELPER_ARGS(dbg, "exposure_time=%d, used_res=%d, start=%d, pixels=%d, channels=%d, " DBG_HELPER_ARGS(dbg, "exposure_time=%d, start=%d", exposure_time, start);
"depth=%d",
exposure_time, used_res, start, pixels, channels, depth);
unsigned int words_per_line; unsigned int words_per_line;
unsigned dpiset, dpihw, segnb, factor; unsigned dpiset, dpihw, segnb, factor;
unsigned int bytes; unsigned int bytes;
@ -760,18 +755,18 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
// to manage high resolution device while keeping good low resolution scanning speed, we make // to manage high resolution device while keeping good low resolution scanning speed, we make
// hardware dpi vary // hardware dpi vary
dpihw = sensor.get_register_hwdpi(used_res * ccd_pixels_per_system_pixel); dpihw = sensor.get_register_hwdpi(session.params.xres * ccd_pixels_per_system_pixel);
factor=sensor.optical_res/dpihw; factor=sensor.optical_res/dpihw;
DBG(DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor); DBG(DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor);
// sensor parameters // sensor parameters
const auto& sensor_profile = get_sensor_profile(sensor, dpihw); const auto& sensor_profile = get_sensor_profile(sensor, dpihw);
gl847_setup_sensor(dev, sensor, reg, dpihw); gl847_setup_sensor(dev, sensor, reg, dpihw);
dpiset = used_res * ccd_pixels_per_system_pixel; dpiset = session.params.xres * ccd_pixels_per_system_pixel;
// start and end coordinate in optical dpi coordinates // start and end coordinate in optical dpi coordinates
unsigned startx = start / ccd_pixels_per_system_pixel + sensor.CCD_start_xoffset; unsigned startx = start / ccd_pixels_per_system_pixel + sensor.CCD_start_xoffset;
unsigned endx = startx + pixels / ccd_pixels_per_system_pixel; unsigned endx = startx + session.optical_pixels / ccd_pixels_per_system_pixel;
/* sensors are built from 600 dpi segments for LiDE 100/200 /* sensors are built from 600 dpi segments for LiDE 100/200
* and 1200 dpi for the 700F */ * and 1200 dpi for the 700F */
@ -831,7 +826,7 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
/* monochrome / color scan */ /* monochrome / color scan */
r = sanei_genesys_get_address (reg, REG04); r = sanei_genesys_get_address (reg, REG04);
switch (depth) switch (session.params.depth)
{ {
case 1: case 1:
r->value &= ~REG04_BITSET; r->value &= ~REG04_BITSET;
@ -847,9 +842,9 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
} }
r->value &= ~(REG04_FILTER | REG04_AFEMOD); r->value &= ~(REG04_FILTER | REG04_AFEMOD);
if (channels == 1) if (session.params.channels == 1)
{ {
switch (color_filter) switch (session.params.color_filter)
{ {
case ColorFilter::RED: case ColorFilter::RED:
@ -897,8 +892,8 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
/* words(16bit) before gamma, conversion to 8 bit or lineart*/ /* words(16bit) before gamma, conversion to 8 bit or lineart*/
words_per_line = (used_pixels * dpiset) / dpihw; words_per_line = (used_pixels * dpiset) / dpihw;
bytes=depth/8; bytes=session.params.depth/8;
if (depth == 1) if (session.params.depth == 1)
{ {
words_per_line = (words_per_line+7)/8 ; words_per_line = (words_per_line+7)/8 ;
dev->len = (dev->len >> 3) + ((dev->len & 7) ? 1 : 0); dev->len = (dev->len >> 3) + ((dev->len & 7) ? 1 : 0);
@ -925,14 +920,14 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
DBG (DBG_io2, "%s: endx =%d\n", __func__, endx); DBG (DBG_io2, "%s: endx =%d\n", __func__, endx);
DBG (DBG_io2, "%s: used_pixels=%d\n", __func__, used_pixels); DBG (DBG_io2, "%s: used_pixels=%d\n", __func__, used_pixels);
DBG (DBG_io2, "%s: pixels =%d\n", __func__, pixels); DBG (DBG_io2, "%s: pixels =%d\n", __func__, session.optical_pixels);
DBG (DBG_io2, "%s: depth =%d\n", __func__, depth); DBG (DBG_io2, "%s: depth =%d\n", __func__, session.params.depth);
DBG (DBG_io2, "%s: dev->bpl =%lu\n", __func__, (unsigned long)dev->bpl); DBG (DBG_io2, "%s: dev->bpl =%lu\n", __func__, (unsigned long)dev->bpl);
DBG (DBG_io2, "%s: dev->len =%lu\n", __func__, (unsigned long)dev->len); DBG (DBG_io2, "%s: dev->len =%lu\n", __func__, (unsigned long)dev->len);
DBG (DBG_io2, "%s: dev->dist =%lu\n", __func__, (unsigned long)dev->dist); DBG (DBG_io2, "%s: dev->dist =%lu\n", __func__, (unsigned long)dev->dist);
DBG (DBG_io2, "%s: dev->segnb =%lu\n", __func__, (unsigned long)dev->segnb); DBG (DBG_io2, "%s: dev->segnb =%lu\n", __func__, (unsigned long)dev->segnb);
words_per_line *= channels; words_per_line *= session.params.channels;
dev->wpl = words_per_line; dev->wpl = words_per_line;
dev->oe_buffer.clear(); dev->oe_buffer.clear();
@ -1020,9 +1015,7 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
/* we enable true gray for cis scanners only, and just when doing /* we enable true gray for cis scanners only, and just when doing
* scan since color calibration is OK for this mode * scan since color calibration is OK for this mode
*/ */
gl847_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, session.params.xres, start, gl847_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, start);
session.optical_pixels, session.params.channels,
session.params.depth, session.params.color_filter);
move = session.params.starty; move = session.params.starty;
DBG(DBG_info, "%s: move=%d steps\n", __func__, move); DBG(DBG_info, "%s: move=%d steps\n", __func__, move);