kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Simplify words_per_line calculations
rodzic
463f5f4364
commit
96a893bb0d
|
@ -830,8 +830,7 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
exposure_time, start);
|
||||
unsigned int words_per_line, segcnt;
|
||||
unsigned int startx, endx, segnb;
|
||||
unsigned int dpiset, dpihw, factor;
|
||||
unsigned int bytes;
|
||||
unsigned int dpihw, factor;
|
||||
GenesysRegister *r;
|
||||
uint32_t expmax;
|
||||
|
||||
|
@ -841,13 +840,12 @@ 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
|
||||
// make hardware dpi vary
|
||||
dpihw = sensor.get_register_hwdpi(session.params.xres * ccd_pixels_per_system_pixel);
|
||||
factor = sensor.get_hwdpi_divisor_for_dpi(session.params.xres * ccd_pixels_per_system_pixel);
|
||||
dpihw = sensor.get_register_hwdpi(session.output_resolution * ccd_pixels_per_system_pixel);
|
||||
factor = sensor.get_hwdpi_divisor_for_dpi(session.output_resolution * ccd_pixels_per_system_pixel);
|
||||
DBG (DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor);
|
||||
|
||||
// sensor parameters
|
||||
gl124_setup_sensor(dev, sensor, reg, dpihw, session.ccd_size_divisor);
|
||||
dpiset = session.params.xres * ccd_pixels_per_system_pixel;
|
||||
|
||||
/* start and end coordinate in optical dpi coordinates */
|
||||
/* startx = start / ccd_pixels_per_system_pixel + sensor.dummy_pixel; XXX STEF XXX */
|
||||
|
@ -857,7 +855,6 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
/* pixel coordinate factor correction when used dpihw is not maximal one */
|
||||
startx/=factor;
|
||||
endx/=factor;
|
||||
unsigned used_pixels = endx - startx;
|
||||
|
||||
gl124_set_fe(dev, sensor, AFE_SET);
|
||||
|
||||
|
@ -940,7 +937,8 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
r->value |= REG05_GMMENB;
|
||||
}
|
||||
|
||||
unsigned dpiset_reg = dpiset * session.ccd_size_divisor;
|
||||
unsigned dpiset_reg = session.output_resolution * ccd_pixels_per_system_pixel *
|
||||
session.ccd_size_divisor;
|
||||
if (sensor.dpiset_override != 0) {
|
||||
dpiset_reg = sensor.dpiset_override;
|
||||
}
|
||||
|
@ -992,17 +990,9 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
reg->set24(REG_ENDPIXEL, endx / segnb);
|
||||
DBG (DBG_io2, "%s: endpixel used=%d\n", __func__, endx/segnb);
|
||||
|
||||
/* words(16bit) before gamma, conversion to 8 bit or lineart */
|
||||
words_per_line = (used_pixels * dpiset) / dpihw;
|
||||
bytes = session.params.depth / 8;
|
||||
if (session.params.depth == 1)
|
||||
{
|
||||
words_per_line = (words_per_line >> 3) + ((words_per_line & 7) ? 1 : 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
words_per_line *= bytes;
|
||||
}
|
||||
// words(16bit) before gamma, conversion to 8 bit or lineart
|
||||
words_per_line = multiply_by_depth_ceil(session.output_pixels / session.ccd_size_divisor,
|
||||
session.params.depth);
|
||||
|
||||
dev->bpl = words_per_line;
|
||||
dev->cur = 0;
|
||||
|
@ -1013,7 +1003,6 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
dev->line_count = 0;
|
||||
dev->line_interp = 0;
|
||||
|
||||
DBG (DBG_io2, "%s: used_pixels =%d\n", __func__, used_pixels);
|
||||
DBG (DBG_io2, "%s: pixels =%d\n", __func__, session.optical_pixels);
|
||||
DBG (DBG_io2, "%s: depth =%d\n", __func__, session.params.depth);
|
||||
DBG (DBG_io2, "%s: dev->bpl =%lu\n", __func__, (unsigned long)dev->bpl);
|
||||
|
|
|
@ -1456,9 +1456,7 @@ static void gl841_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
const ScanSession& session, unsigned int start)
|
||||
{
|
||||
DBG_HELPER_ARGS(dbg, "exposure_time=%d, start=%d", exposure_time, start);
|
||||
unsigned int words_per_line;
|
||||
unsigned int end;
|
||||
unsigned int dpiset;
|
||||
GenesysRegister* r;
|
||||
uint16_t expavg, expr, expb, expg;
|
||||
|
||||
|
@ -1466,18 +1464,6 @@ static void gl841_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
|
||||
gl841_set_fe(dev, sensor, AFE_SET);
|
||||
|
||||
/* adjust used_res for chosen dpihw */
|
||||
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
|
||||
to dpihw, so we need to double dpiset.
|
||||
|
||||
For the scanner only the ratio of dpiset and dpihw is of relevance to scale
|
||||
down properly.
|
||||
*/
|
||||
dpiset = used_res * session.ccd_size_divisor;
|
||||
|
||||
/* gpio part.*/
|
||||
if (dev->model->gpo_type == GPO_CANONLIDE35)
|
||||
{
|
||||
|
@ -1613,30 +1599,15 @@ static void gl841_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
r = sanei_genesys_get_address (reg, 0x29);
|
||||
r->value = 255; /*<<<"magic" number, only suitable for cis*/
|
||||
|
||||
reg->set16(REG_DPISET, dpiset);
|
||||
reg->set16(REG_DPISET, gl841_get_dpihw(dev) * session.output_resolution / session.optical_resolution);
|
||||
reg->set16(REG_STRPIXEL, start);
|
||||
reg->set16(REG_ENDPIXEL, end);
|
||||
DBG(DBG_io2, "%s: STRPIXEL=%d, ENDPIXEL=%d\n", __func__, start, end);
|
||||
|
||||
/* words(16bit) before gamma, conversion to 8 bit or lineart*/
|
||||
words_per_line = (session.optical_pixels * dpiset) / gl841_get_dpihw(dev);
|
||||
dev->wpl = session.output_line_bytes;
|
||||
dev->bpl = session.output_line_bytes;
|
||||
|
||||
words_per_line *= session.params.channels;
|
||||
|
||||
if (session.params.depth == 1)
|
||||
words_per_line = (words_per_line >> 3) + ((words_per_line & 7)?1:0);
|
||||
else
|
||||
words_per_line *= session.params.depth / 8;
|
||||
|
||||
dev->wpl = words_per_line;
|
||||
dev->bpl = words_per_line;
|
||||
|
||||
r = sanei_genesys_get_address (reg, 0x35);
|
||||
r->value = LOBYTE (HIWORD (words_per_line));
|
||||
r = sanei_genesys_get_address (reg, 0x36);
|
||||
r->value = HIBYTE (LOWORD (words_per_line));
|
||||
r = sanei_genesys_get_address (reg, 0x37);
|
||||
r->value = LOBYTE (LOWORD (words_per_line));
|
||||
reg->set24(REG_MAXWD, session.output_line_bytes);
|
||||
|
||||
reg->set16(REG_LPERIOD, exposure_time);
|
||||
|
||||
|
|
|
@ -174,6 +174,7 @@
|
|||
#define REG_DPISET 0x2c
|
||||
#define REG_STRPIXEL 0x30
|
||||
#define REG_ENDPIXEL 0x32
|
||||
#define REG_MAXWD 0x35
|
||||
#define REG_LPERIOD 0x38
|
||||
|
||||
#define REG40_HISPDFLG 0x04
|
||||
|
|
|
@ -727,7 +727,6 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
DBG_HELPER_ARGS(dbg, "exposure_time=%d, start=%d", exposure_time, start);
|
||||
unsigned int words_per_line;
|
||||
unsigned int dpiset, dpihw, segnb, factor;
|
||||
unsigned int bytes;
|
||||
GenesysRegister *r;
|
||||
|
||||
// resolution is divided according to ccd_pixels_per_system_pixel()
|
||||
|
@ -873,19 +872,9 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
|
||||
/* words(16bit) before gamma, conversion to 8 bit or lineart*/
|
||||
words_per_line = (used_pixels * dpiset) / dpihw;
|
||||
bytes=session.params.depth/8;
|
||||
if (session.params.depth == 1)
|
||||
{
|
||||
words_per_line = (words_per_line+7)/8 ;
|
||||
dev->len = (dev->len >> 3) + ((dev->len & 7) ? 1 : 0);
|
||||
dev->dist = (dev->dist >> 3) + ((dev->dist & 7) ? 1 : 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
words_per_line *= bytes;
|
||||
dev->dist *= bytes;
|
||||
dev->len *= bytes;
|
||||
}
|
||||
words_per_line = multiply_by_depth_ceil(words_per_line, session.params.depth);
|
||||
dev->len = multiply_by_depth_ceil(dev->len, session.params.depth);
|
||||
dev->dist = multiply_by_depth_ceil(dev->dist, session.params.depth);
|
||||
|
||||
dev->bpl = words_per_line;
|
||||
dev->cur=0;
|
||||
|
|
|
@ -746,7 +746,6 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
DBG_HELPER_ARGS(dbg, "exposure_time=%d, start=%d", exposure_time, start);
|
||||
unsigned int words_per_line;
|
||||
unsigned dpiset, dpihw, segnb, factor;
|
||||
unsigned int bytes;
|
||||
GenesysRegister *r;
|
||||
|
||||
// resolution is divided according to ccd_pixels_per_system_pixel()
|
||||
|
@ -892,19 +891,9 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
|
||||
/* words(16bit) before gamma, conversion to 8 bit or lineart*/
|
||||
words_per_line = (used_pixels * dpiset) / dpihw;
|
||||
bytes=session.params.depth/8;
|
||||
if (session.params.depth == 1)
|
||||
{
|
||||
words_per_line = (words_per_line+7)/8 ;
|
||||
dev->len = (dev->len >> 3) + ((dev->len & 7) ? 1 : 0);
|
||||
dev->dist = (dev->dist >> 3) + ((dev->dist & 7) ? 1 : 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
words_per_line *= bytes;
|
||||
dev->dist *= bytes;
|
||||
dev->len *= bytes;
|
||||
}
|
||||
words_per_line = multiply_by_depth_ceil(words_per_line, session.params.depth);
|
||||
dev->len = multiply_by_depth_ceil(dev->len, session.params.depth);
|
||||
dev->dist = multiply_by_depth_ceil(dev->dist, session.params.depth);
|
||||
|
||||
dev->bpl = words_per_line;
|
||||
dev->cur=0;
|
||||
|
|
Ładowanie…
Reference in New Issue