kopia lustrzana https://gitlab.com/sane-project/backends
enable hardware lineart for gl646 scanners
rodzic
4b2d7777e2
commit
9d97e5a606
|
@ -5785,12 +5785,6 @@ init_options (Genesys_Scanner * s)
|
||||||
s->opt[OPT_DISABLE_DYNAMIC_LINEART].constraint_type = SANE_CONSTRAINT_NONE;
|
s->opt[OPT_DISABLE_DYNAMIC_LINEART].constraint_type = SANE_CONSTRAINT_NONE;
|
||||||
s->val[OPT_DISABLE_DYNAMIC_LINEART].w = SANE_FALSE;
|
s->val[OPT_DISABLE_DYNAMIC_LINEART].w = SANE_FALSE;
|
||||||
|
|
||||||
/* not working for GL646 scanners yet */
|
|
||||||
if (s->dev->model->asic_type == GENESYS_GL646)
|
|
||||||
{
|
|
||||||
s->opt[OPT_DISABLE_DYNAMIC_LINEART].cap = SANE_CAP_INACTIVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* disable_interpolation */
|
/* disable_interpolation */
|
||||||
s->opt[OPT_DISABLE_INTERPOLATION].name = "disable-interpolation";
|
s->opt[OPT_DISABLE_INTERPOLATION].name = "disable-interpolation";
|
||||||
s->opt[OPT_DISABLE_INTERPOLATION].title =
|
s->opt[OPT_DISABLE_INTERPOLATION].title =
|
||||||
|
|
|
@ -709,7 +709,8 @@ gl646_setup_registers (Genesys_Device * dev,
|
||||||
uint32_t move,
|
uint32_t move,
|
||||||
uint32_t linecnt,
|
uint32_t linecnt,
|
||||||
uint16_t startx,
|
uint16_t startx,
|
||||||
uint16_t endx, SANE_Bool color, SANE_Int depth)
|
uint16_t endx, SANE_Bool color,
|
||||||
|
SANE_Int depth)
|
||||||
{
|
{
|
||||||
SANE_Status status = SANE_STATUS_GOOD;
|
SANE_Status status = SANE_STATUS_GOOD;
|
||||||
int i, nb;
|
int i, nb;
|
||||||
|
@ -718,9 +719,10 @@ gl646_setup_registers (Genesys_Device * dev,
|
||||||
Sensor_Settings *settings = NULL;
|
Sensor_Settings *settings = NULL;
|
||||||
Genesys_Register_Set *r;
|
Genesys_Register_Set *r;
|
||||||
unsigned int used1, used2, vfinal;
|
unsigned int used1, used2, vfinal;
|
||||||
|
unsigned int bpp; /**> bytes per pixel */
|
||||||
uint32_t z1, z2;
|
uint32_t z1, z2;
|
||||||
uint16_t ex, sx;
|
uint16_t ex, sx;
|
||||||
int channels = 1, stagger, wpl, max_shift;
|
int channels = 1, stagger, words_per_line, max_shift;
|
||||||
size_t requested_buffer_size;
|
size_t requested_buffer_size;
|
||||||
size_t read_buffer_size;
|
size_t read_buffer_size;
|
||||||
SANE_Bool half_ccd = SANE_FALSE;
|
SANE_Bool half_ccd = SANE_FALSE;
|
||||||
|
@ -948,13 +950,20 @@ gl646_setup_registers (Genesys_Device * dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* R04 */
|
/* R04 */
|
||||||
if (depth > 8)
|
/* monochrome / color scan */
|
||||||
{
|
switch (depth)
|
||||||
regs[reg_0x04].value |= REG04_BITSET;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
case 1:
|
||||||
regs[reg_0x04].value &= ~REG04_BITSET;
|
regs[reg_0x04].value &= ~REG04_BITSET;
|
||||||
|
regs[reg_0x04].value |= REG04_LINEART;
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
regs[reg_0x04].value &= ~(REG04_LINEART | REG04_BITSET);
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
regs[reg_0x04].value &= ~REG04_LINEART;
|
||||||
|
regs[reg_0x04].value |= REG04_BITSET;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* R05 */
|
/* R05 */
|
||||||
|
@ -1075,18 +1084,25 @@ gl646_setup_registers (Genesys_Device * dev,
|
||||||
DBG (DBG_info, "gl646_setup_registers: startx=%d, endx=%d, half_ccd=%d\n",
|
DBG (DBG_info, "gl646_setup_registers: startx=%d, endx=%d, half_ccd=%d\n",
|
||||||
sx, ex, half_ccd);
|
sx, ex, half_ccd);
|
||||||
|
|
||||||
/* wpl must be computed according to the scan's resolution */
|
/* words_per_line must be computed according to the scan's resolution */
|
||||||
/* in fact, wpl _gives_ the actual scan resolution */
|
/* in fact, words_per_line _gives_ the actual scan resolution */
|
||||||
wpl = (((endx - startx) * sensor->xdpi) / dev->sensor.optical_res);
|
words_per_line = (((endx - startx) * sensor->xdpi) / dev->sensor.optical_res);
|
||||||
if (depth == 16)
|
bpp=depth/8;
|
||||||
wpl *= 2;
|
if (depth == 1)
|
||||||
if (dev->model->is_cis == SANE_FALSE)
|
{
|
||||||
wpl *= channels;
|
words_per_line = (words_per_line+7)/8 ;
|
||||||
dev->wpl = wpl;
|
bpp=1;
|
||||||
dev->bpl = wpl;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
words_per_line *= bpp;
|
||||||
|
}
|
||||||
|
dev->bpl = words_per_line;
|
||||||
|
words_per_line *= channels;
|
||||||
|
dev->wpl = words_per_line;
|
||||||
|
|
||||||
DBG (DBG_info, "gl646_setup_registers: wpl=%d\n", wpl);
|
DBG (DBG_info, "gl646_setup_registers: wpl=%d\n", words_per_line);
|
||||||
gl646_set_triple_reg (regs, REG_MAXWD, wpl);
|
gl646_set_triple_reg (regs, REG_MAXWD, words_per_line);
|
||||||
|
|
||||||
gl646_set_double_reg (regs, REG_DPISET, sensor->dpiset);
|
gl646_set_double_reg (regs, REG_DPISET, sensor->dpiset);
|
||||||
gl646_set_double_reg (regs, REG_LPERIOD, sensor->exposure);
|
gl646_set_double_reg (regs, REG_LPERIOD, sensor->exposure);
|
||||||
|
@ -1249,15 +1265,15 @@ gl646_setup_registers (Genesys_Device * dev,
|
||||||
* need the buffer to be short enough not to miss the end of document in the feeder*/
|
* need the buffer to be short enough not to miss the end of document in the feeder*/
|
||||||
if (dev->model->is_sheetfed == SANE_FALSE)
|
if (dev->model->is_sheetfed == SANE_FALSE)
|
||||||
{
|
{
|
||||||
requested_buffer_size = (GL646_BULKIN_MAXSIZE / wpl) * wpl;
|
requested_buffer_size = (GL646_BULKIN_MAXSIZE / words_per_line) * words_per_line;
|
||||||
/* TODO seems CIS scanners should be treated differently */
|
/* TODO seems CIS scanners should be treated differently */
|
||||||
read_buffer_size =
|
read_buffer_size =
|
||||||
2 * requested_buffer_size +
|
2 * requested_buffer_size +
|
||||||
((max_shift + stagger) * scan_settings.pixels * channels * depth) / 8;
|
((max_shift + stagger) * scan_settings.pixels * channels * bpp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
requested_buffer_size = 8 * wpl * channels;
|
requested_buffer_size = 8 * words_per_line * channels;
|
||||||
read_buffer_size = requested_buffer_size;
|
read_buffer_size = requested_buffer_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1273,11 +1289,10 @@ gl646_setup_registers (Genesys_Device * dev,
|
||||||
|
|
||||||
RIE (sanei_genesys_buffer_free (&(dev->out_buffer)));
|
RIE (sanei_genesys_buffer_free (&(dev->out_buffer)));
|
||||||
RIE (sanei_genesys_buffer_alloc (&(dev->out_buffer),
|
RIE (sanei_genesys_buffer_alloc (&(dev->out_buffer),
|
||||||
(8 * scan_settings.pixels * channels *
|
8 * scan_settings.pixels * channels * bpp));
|
||||||
depth) / 8));
|
|
||||||
|
|
||||||
/* scan bytes to read */
|
/* scan bytes to read */
|
||||||
dev->read_bytes_left = wpl * linecnt;
|
dev->read_bytes_left = words_per_line * linecnt;
|
||||||
|
|
||||||
DBG (DBG_info,
|
DBG (DBG_info,
|
||||||
"gl646_setup_registers: physical bytes to read = %lu\n",
|
"gl646_setup_registers: physical bytes to read = %lu\n",
|
||||||
|
@ -1308,7 +1323,7 @@ gl646_setup_registers (Genesys_Device * dev,
|
||||||
channels;
|
channels;
|
||||||
else
|
else
|
||||||
dev->total_bytes_to_read =
|
dev->total_bytes_to_read =
|
||||||
scan_settings.pixels * scan_settings.lines * channels * (depth / 8);
|
scan_settings.pixels * scan_settings.lines * channels * bpp;
|
||||||
|
|
||||||
DBG (DBG_proc, "gl646_setup_registers: end\n");
|
DBG (DBG_proc, "gl646_setup_registers: end\n");
|
||||||
return SANE_STATUS_GOOD;
|
return SANE_STATUS_GOOD;
|
||||||
|
@ -3063,6 +3078,7 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
|
||||||
settings.disable_interpolation = 0;
|
settings.disable_interpolation = 0;
|
||||||
settings.threshold = 0;
|
settings.threshold = 0;
|
||||||
settings.exposure_time = 0;
|
settings.exposure_time = 0;
|
||||||
|
settings.dynamic_lineart = SANE_FALSE;
|
||||||
|
|
||||||
status = setup_for_scan (dev, settings, SANE_TRUE, SANE_TRUE, SANE_TRUE);
|
status = setup_for_scan (dev, settings, SANE_TRUE, SANE_TRUE, SANE_TRUE);
|
||||||
|
|
||||||
|
@ -3178,6 +3194,7 @@ gl646_search_start_position (Genesys_Device * dev)
|
||||||
settings.disable_interpolation = 0;
|
settings.disable_interpolation = 0;
|
||||||
settings.threshold = 0;
|
settings.threshold = 0;
|
||||||
settings.exposure_time = 0;
|
settings.exposure_time = 0;
|
||||||
|
settings.dynamic_lineart = SANE_FALSE;
|
||||||
|
|
||||||
/* scan the desired area */
|
/* scan the desired area */
|
||||||
status =
|
status =
|
||||||
|
@ -3310,6 +3327,7 @@ gl646_init_regs_for_shading (Genesys_Device * dev)
|
||||||
settings.disable_interpolation = dev->settings.disable_interpolation;
|
settings.disable_interpolation = dev->settings.disable_interpolation;
|
||||||
settings.threshold = dev->settings.threshold;
|
settings.threshold = dev->settings.threshold;
|
||||||
settings.exposure_time = dev->settings.exposure_time;
|
settings.exposure_time = dev->settings.exposure_time;
|
||||||
|
settings.dynamic_lineart = SANE_FALSE;
|
||||||
|
|
||||||
/* keep account of the movement for final scan move */
|
/* keep account of the movement for final scan move */
|
||||||
dev->scanhead_position_in_steps += settings.lines;
|
dev->scanhead_position_in_steps += settings.lines;
|
||||||
|
@ -3403,6 +3421,7 @@ setup_for_scan (Genesys_Device * dev, Genesys_Settings settings,
|
||||||
{
|
{
|
||||||
SANE_Status status = SANE_STATUS_GOOD;
|
SANE_Status status = SANE_STATUS_GOOD;
|
||||||
SANE_Bool color;
|
SANE_Bool color;
|
||||||
|
SANE_Int depth;
|
||||||
int channels;
|
int channels;
|
||||||
uint16_t startx = 0, endx, pixels;
|
uint16_t startx = 0, endx, pixels;
|
||||||
int move = 0;
|
int move = 0;
|
||||||
|
@ -3425,6 +3444,20 @@ setup_for_scan (Genesys_Device * dev, Genesys_Settings settings,
|
||||||
channels = 1;
|
channels = 1;
|
||||||
color = SANE_FALSE;
|
color = SANE_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
depth=settings.depth;
|
||||||
|
if (settings.scan_mode == SCAN_MODE_LINEART)
|
||||||
|
{
|
||||||
|
if (settings.dynamic_lineart == SANE_TRUE)
|
||||||
|
{
|
||||||
|
depth = 8;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* XXX STEF XXX : why does the common layer never send depth=1 ? */
|
||||||
|
depth = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* compute distance to move */
|
/* compute distance to move */
|
||||||
move = 0;
|
move = 0;
|
||||||
|
@ -3514,7 +3547,8 @@ setup_for_scan (Genesys_Device * dev, Genesys_Settings settings,
|
||||||
settings.xres,
|
settings.xres,
|
||||||
move,
|
move,
|
||||||
settings.lines,
|
settings.lines,
|
||||||
startx, endx, color, settings.depth);
|
startx, endx, color,
|
||||||
|
depth);
|
||||||
if (status != SANE_STATUS_GOOD)
|
if (status != SANE_STATUS_GOOD)
|
||||||
{
|
{
|
||||||
DBG (DBG_error,
|
DBG (DBG_error,
|
||||||
|
@ -3744,6 +3778,7 @@ gl646_led_calibration (Genesys_Device * dev)
|
||||||
settings.disable_interpolation = 0;
|
settings.disable_interpolation = 0;
|
||||||
settings.threshold = 0;
|
settings.threshold = 0;
|
||||||
settings.exposure_time = 0;
|
settings.exposure_time = 0;
|
||||||
|
settings.dynamic_lineart = SANE_FALSE;
|
||||||
|
|
||||||
/* colors * bytes_per_color * scan lines */
|
/* colors * bytes_per_color * scan lines */
|
||||||
total_size = settings.pixels * channels * 2 * 1;
|
total_size = settings.pixels * channels * 2 * 1;
|
||||||
|
@ -3751,7 +3786,7 @@ gl646_led_calibration (Genesys_Device * dev)
|
||||||
line = malloc (total_size);
|
line = malloc (total_size);
|
||||||
if (!line)
|
if (!line)
|
||||||
{
|
{
|
||||||
DBG (DBG_error, "gl646_led_calibration: Failed to allocate %d bytes\n",
|
DBG (DBG_error, "gl646_led_calibration: failed to allocate %d bytes\n",
|
||||||
total_size);
|
total_size);
|
||||||
return SANE_STATUS_NO_MEM;
|
return SANE_STATUS_NO_MEM;
|
||||||
}
|
}
|
||||||
|
@ -3946,6 +3981,7 @@ ad_fe_offset_calibration (Genesys_Device * dev)
|
||||||
settings.disable_interpolation = 0;
|
settings.disable_interpolation = 0;
|
||||||
settings.threshold = 0;
|
settings.threshold = 0;
|
||||||
settings.exposure_time = 0;
|
settings.exposure_time = 0;
|
||||||
|
settings.dynamic_lineart = SANE_FALSE;
|
||||||
|
|
||||||
/* scan first line of data with no gain */
|
/* scan first line of data with no gain */
|
||||||
dev->frontend.gain[0] = 0;
|
dev->frontend.gain[0] = 0;
|
||||||
|
@ -4073,6 +4109,7 @@ gl646_offset_calibration (Genesys_Device * dev)
|
||||||
settings.disable_interpolation = 0;
|
settings.disable_interpolation = 0;
|
||||||
settings.threshold = 0;
|
settings.threshold = 0;
|
||||||
settings.exposure_time = 0;
|
settings.exposure_time = 0;
|
||||||
|
settings.dynamic_lineart = SANE_FALSE;
|
||||||
|
|
||||||
/* scan first line of data with no gain, but with offset from
|
/* scan first line of data with no gain, but with offset from
|
||||||
* last calibration */
|
* last calibration */
|
||||||
|
@ -4242,6 +4279,7 @@ ad_fe_coarse_gain_calibration (Genesys_Device * dev, int dpi)
|
||||||
settings.disable_interpolation = 0;
|
settings.disable_interpolation = 0;
|
||||||
settings.threshold = 0;
|
settings.threshold = 0;
|
||||||
settings.exposure_time = 0;
|
settings.exposure_time = 0;
|
||||||
|
settings.dynamic_lineart = SANE_FALSE;
|
||||||
|
|
||||||
size = channels * settings.pixels * settings.lines;
|
size = channels * settings.pixels * settings.lines;
|
||||||
|
|
||||||
|
@ -4371,6 +4409,7 @@ gl646_coarse_gain_calibration (Genesys_Device * dev, int dpi)
|
||||||
settings.disable_interpolation = 0;
|
settings.disable_interpolation = 0;
|
||||||
settings.threshold = 0;
|
settings.threshold = 0;
|
||||||
settings.exposure_time = 0;
|
settings.exposure_time = 0;
|
||||||
|
settings.dynamic_lineart = SANE_FALSE;
|
||||||
|
|
||||||
/* start gain value */
|
/* start gain value */
|
||||||
dev->frontend.gain[0] = 1;
|
dev->frontend.gain[0] = 1;
|
||||||
|
@ -4516,6 +4555,7 @@ gl646_init_regs_for_warmup (Genesys_Device * dev,
|
||||||
settings.disable_interpolation = 0;
|
settings.disable_interpolation = 0;
|
||||||
settings.threshold = 0;
|
settings.threshold = 0;
|
||||||
settings.exposure_time = 0;
|
settings.exposure_time = 0;
|
||||||
|
settings.dynamic_lineart = SANE_FALSE;
|
||||||
|
|
||||||
/* setup for scan */
|
/* setup for scan */
|
||||||
status = setup_for_scan (dev, settings, SANE_TRUE, SANE_FALSE, SANE_FALSE);
|
status = setup_for_scan (dev, settings, SANE_TRUE, SANE_FALSE, SANE_FALSE);
|
||||||
|
@ -4584,6 +4624,7 @@ gl646_repark_head (Genesys_Device * dev)
|
||||||
settings.disable_interpolation = 0;
|
settings.disable_interpolation = 0;
|
||||||
settings.threshold = 0;
|
settings.threshold = 0;
|
||||||
settings.exposure_time = 0;
|
settings.exposure_time = 0;
|
||||||
|
settings.dynamic_lineart = SANE_FALSE;
|
||||||
|
|
||||||
status = setup_for_scan (dev, settings, SANE_FALSE, SANE_FALSE, SANE_FALSE);
|
status = setup_for_scan (dev, settings, SANE_FALSE, SANE_FALSE, SANE_FALSE);
|
||||||
if (status != SANE_STATUS_GOOD)
|
if (status != SANE_STATUS_GOOD)
|
||||||
|
@ -5240,6 +5281,7 @@ simple_move (Genesys_Device * dev, SANE_Int distance)
|
||||||
settings.disable_interpolation = 0;
|
settings.disable_interpolation = 0;
|
||||||
settings.threshold = 0;
|
settings.threshold = 0;
|
||||||
settings.exposure_time = 0;
|
settings.exposure_time = 0;
|
||||||
|
settings.dynamic_lineart = SANE_FALSE;
|
||||||
|
|
||||||
status =
|
status =
|
||||||
simple_scan (dev, settings, SANE_TRUE, SANE_TRUE, SANE_FALSE, &data);
|
simple_scan (dev, settings, SANE_TRUE, SANE_TRUE, SANE_FALSE, &data);
|
||||||
|
@ -5623,6 +5665,7 @@ gl646_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black)
|
||||||
settings.disable_interpolation = 0;
|
settings.disable_interpolation = 0;
|
||||||
settings.threshold = 0;
|
settings.threshold = 0;
|
||||||
settings.exposure_time = 0;
|
settings.exposure_time = 0;
|
||||||
|
settings.dynamic_lineart = SANE_FALSE;
|
||||||
|
|
||||||
/* signals if a strip of the given color has been found */
|
/* signals if a strip of the given color has been found */
|
||||||
found = 0;
|
found = 0;
|
||||||
|
|
Ładowanie…
Reference in New Issue