gl847 nearing completion

- used_res given is not hte right one 80 dpi instead of 75
- slope table can't be created so scan hangs if no calibration first
- first scanned byte are black
merge-requests/1/head
Stphane Voltz 2010-05-29 07:58:27 +02:00
rodzic bc944cbc3a
commit 22fd7ed54c
3 zmienionych plików z 62 dodań i 72 usunięć

Wyświetl plik

@ -3020,10 +3020,12 @@ compute_averaged_planar (Genesys_Device * dev,
res *= 2;
}
/*this should be evenly dividable */
/* this should be evenly dividable */
avgpixels = dev->sensor.optical_res / res;
/* due to resolution list is directly good to use */
/* gl841 and gl847 supports 1/1 1/2 1/3 1/4 1/5 1/6 1/8 1/10 1/12 1/15 averaging */
/* XXX STEF XXX
if (avgpixels < 1)
avgpixels = 1;
else if (avgpixels < 6)
@ -3037,7 +3039,7 @@ compute_averaged_planar (Genesys_Device * dev,
else if (avgpixels < 15)
avgpixels = 12;
else
avgpixels = 15;
avgpixels = 15; */
DBG (DBG_info, "%s: averaging over %d pixels\n", __FUNCTION__, avgpixels);
@ -3074,7 +3076,6 @@ compute_averaged_planar (Genesys_Device * dev,
else
val = (dk * target_bright - br * target_dark) / (target_bright
- target_dark);
#if 0
/*fill all pixels, even if only the last one is relevant */
for (i = 0; i < avgpixels; i++)
@ -3104,27 +3105,6 @@ compute_averaged_planar (Genesys_Device * dev,
shading_data[(x/avgpixels) * 2 * 2 + words_per_color * 2 * j + 2] = val & 0xff;
shading_data[(x/avgpixels) * 2 * 2 + words_per_color * 2 * j + 3] = val >> 8;
}
#if 0
/*fill remaining channels */
for (j = channels; j < 3; j++)
{
for (i = 0; i < avgpixels; i++)
{
shading_data[(x + o + i) * 2 * 2 + words_per_color * 2 * j]
= shading_data[(x + o + i) * 2 * 2 + words_per_color * 0];
shading_data[(x + o + i) * 2 * 2 + words_per_color * 2 * j + 1]
= shading_data[(x + o + i) * 2 * 2 + words_per_color
* 2 * 0 + 1];
shading_data[(x + o + i) * 2 * 2 + words_per_color * 2 * j + 2]
= shading_data[(x + o + i) * 2 * 2 + words_per_color
* 2 * 0 + 2];
shading_data[(x + o + i) * 2 * 2 + words_per_color * 2 * j + 3]
= shading_data[(x + o + i) * 2 * 2 + words_per_color
* 2 * 0 + 3];
}
}
#endif
}
}
@ -3987,7 +3967,15 @@ genesys_flatbed_calibration (Genesys_Device * dev)
}
}
pixels_per_line = (SANE_UNFIX (dev->model->x_size) * dev->settings.xres) / MM_PER_INCH;
/* we always use sensor pixel number in case of odd/even sensors */
if (!(dev->model->flags & GENESYS_FLAG_ODD_EVEN_CIS))
{
pixels_per_line = (SANE_UNFIX (dev->model->x_size) * dev->settings.xres) / MM_PER_INCH;
}
else
{
pixels_per_line = dev->sensor.sensor_pixels;
}
/* send default shading data */
status = sanei_genesys_init_shading_data (dev, pixels_per_line);
@ -4922,7 +4910,7 @@ static SANE_Status accurate_line_read(Genesys_Device * dev,
#ifdef SANE_DEBUG_LOG_RAW_DATA
if (rawfile != NULL)
{
fwrite (dev->oe_buffer.buffer, dev->oe_buffer.avail, 1, rawfile);
fwrite (buffer, size, 1, rawfile);
}
#endif
return status;
@ -5120,7 +5108,7 @@ genesys_fill_read_buffer (Genesys_Device * dev)
work_buffer_dst[count + 3] =
dev->oe_buffer.buffer[dev->cur + dev->skip + dev->dist +
dev->oe_buffer.pos+1];
count += 5;
count += 4;
dev->cur+=2;
}
}
@ -5285,7 +5273,7 @@ genesys_read_ordered_data (Genesys_Device * dev, SANE_Byte * destination,
{
fprintf (rawfile,
"P5\n%d %d\n%d\n",
dev->sensor.sensor_pixels*3,
(dev->sensor.sensor_pixels*3*dev->settings.xres)/dev->sensor.optical_res,
dev->current_setup.lines,
(1 << dev->current_setup.depth) - 1);
}
@ -5772,6 +5760,11 @@ calc_parameters (Genesys_Scanner * s)
s->params.lines = ((br_y - tl_y) * s->dev->settings.yres) / MM_PER_INCH;
s->params.pixels_per_line =
((br_x - tl_x) * s->dev->settings.xres) / MM_PER_INCH;
/* we need an even number of pixels for even/odd handling */
if (s->dev->model->flags & GENESYS_FLAG_ODD_EVEN_CIS)
{
s->params.pixels_per_line = (s->params.pixels_per_line/2)*2;
}
s->params.bytes_per_line = s->params.pixels_per_line;
if (s->params.depth > 8)
@ -6155,16 +6148,16 @@ init_options (Genesys_Scanner * s)
s->opt[OPT_DISABLE_DYNAMIC_LINEART].title = SANE_I18N ("Disable dynamic lineart");
s->opt[OPT_DISABLE_DYNAMIC_LINEART].desc =
SANE_I18N
("Disabel use of a software adaptative algorithm to generate lineart instead of"
("Disable use of a software adaptative algorithm to generate lineart instead of"
" relying on hardware lineart");
s->opt[OPT_DISABLE_DYNAMIC_LINEART].type = SANE_TYPE_BOOL;
s->opt[OPT_DISABLE_DYNAMIC_LINEART].unit = SANE_UNIT_NONE;
s->opt[OPT_DISABLE_DYNAMIC_LINEART].constraint_type = SANE_CONSTRAINT_NONE;
s->val[OPT_DISABLE_DYNAMIC_LINEART].w = SANE_FALSE;
/* not working for GL646 scanners yet */
/* not working for GL646 scanners yet, and required for GL847 ones */
if (s->dev->model->asic_type == GENESYS_GL646 || s->dev->model->asic_type == GENESYS_GL847)
{
s->opt[OPT_DISABLE_DYNAMIC_LINEART].cap |= SANE_CAP_INACTIVE;
s->opt[OPT_DISABLE_DYNAMIC_LINEART].cap = SANE_CAP_INACTIVE;
}
/* disable_interpolation */

Wyświetl plik

@ -431,15 +431,15 @@ static Genesys_Sensor Sensor[] = {
1200, /* optical resolution */
87, /* black pixels */
16, /* dummy pixels 16 */
303,
10272, /* 10272 */
303, /* 303 */
10272, /* 10272 */
210,
200,
{0x00, 0x00, 0x00, 0x00},
/* reg 0x10 - 0x15 */
{0x03, 0x00, 0x02, 0x00, 0x01, 0x80, /* EXPR/EXPG/EXPB */
/* reg 0x16 - 0x1d */
0x10, 0x08, 0x00, 0x50, 0x34, 0x00, 0x02, 0x04 },
/* reg 0x16 - 0x1d 0x19=0x50*/
0x10, 0x08, 0x00, 0xff, 0x34, 0x00, 0x02, 0x04 },
/* reg 0x52 - 0x5e */
{0x03, 0x07,
0x00, 0x00, 0x00, 0x00,
@ -931,8 +931,8 @@ static Genesys_Model canon_lide_100_model = {
GENESYS_GL847,
NULL,
{1200, 600, 300, 150, 75, 0}, /* possible x-resolutions */
{1200, 600, 300, 150, 75, 0}, /* possible y-resolutions */
{1200, 600, 300, 150, 100, 80, 75, 0}, /* possible x-resolutions */
{1200, 600, 300, 150, 100, 80, 75, 0}, /* possible y-resolutions */
{16, 8, 0}, /* possible depths in gray mode */
{16, 8, 0}, /* possible depths in color mode */

Wyświetl plik

@ -464,7 +464,8 @@ gl847_init_registers (Genesys_Device * dev)
SETREG (0x16, 0x10);
SETREG (0x17, 0x08);
SETREG (0x18, 0x00);
SETREG (0x19, 0x50);
/* SETREG (0x19, 0x50); XXX STEF XXX */
SETREG (0x19, 0xff);
SETREG (0x1a, 0x34);
SETREG (0x1b, 0x00);
SETREG (0x1c, 0x02);
@ -776,6 +777,7 @@ HOME_FREE: 3
r->value = (feedl >> 8) & 0xff;
r = sanei_genesys_get_address (reg, 0x3f);
r->value = feedl & 0xff;
DBG (DBG_io ,"%s: feedl=%d\n",__FUNCTION__,feedl);
r = sanei_genesys_get_address (reg, 0x25);
r->value = (scan_lines >> 16) & 0xf;
@ -917,6 +919,7 @@ HOME_FREE: 3
r->value = (feedl >> 8) & 0xff;
r = sanei_genesys_get_address (reg, 0x3f);
r->value = feedl & 0xff;
DBG (DBG_io ,"%s: feedl=%d\n",__FUNCTION__,feedl);
r = sanei_genesys_get_address (reg, 0x25);
r->value = 0;
@ -986,12 +989,11 @@ HOME_FREE: 3
r->value = 1;
r = sanei_genesys_get_address (reg, 0x6a);
r->value = (fast_slope_steps >> 1) + (fast_slope_steps & 1);
r->value = fast_slope_steps; /* XXX STEF XXX */
r->value = fast_slope_steps;
r = sanei_genesys_get_address (reg, 0x5f);
r->value = (fast_slope_steps >> 1) + (fast_slope_steps & 1);
r->value = fast_slope_steps; /* XXX STEF XXX */
r->value = fast_slope_steps;
DBG (DBG_proc, "gl847_init_motor_regs : completed. \n");
@ -1031,7 +1033,9 @@ HOME_FREE: 3
* Z2
*/
static SANE_Status
gl847_init_motor_regs_scan (Genesys_Device * dev, Genesys_Register_Set * reg, unsigned int scan_exposure_time, /*pixel */
gl847_init_motor_regs_scan (Genesys_Device * dev,
Genesys_Register_Set * reg,
unsigned int scan_exposure_time, /*pixel */
float scan_yres, /*dpi, motor resolution */
int scan_step_type, /*0: full, 1: half, 2: quarter */
unsigned int scan_lines, /*lines, scan resolution */
@ -1164,6 +1168,7 @@ gl847_init_motor_regs_scan (Genesys_Device * dev, Genesys_Register_Set * reg, un
use_fast_fed = fast_time < slow_time;
}
use_fast_fed = 0; /* XXX STEF XXX */
DBG (DBG_info, "gl847_init_motor_regs_scan: decided to use %s mode\n",
use_fast_fed ? "fast feed" : "slow feed");
@ -1175,6 +1180,7 @@ gl847_init_motor_regs_scan (Genesys_Device * dev, Genesys_Register_Set * reg, un
else
feedl = (feed_steps << scan_step_type) - slow_slope_steps;
/* all needed slopes available. we did even decide which mode to use.
what next? */
r = sanei_genesys_get_address (reg, 0x3d);
@ -1183,6 +1189,7 @@ gl847_init_motor_regs_scan (Genesys_Device * dev, Genesys_Register_Set * reg, un
r->value = (feedl >> 8) & 0xff;
r = sanei_genesys_get_address (reg, 0x3f);
r->value = feedl & 0xff;
DBG (DBG_io ,"%s: feedl=%d\n",__FUNCTION__,feedl);
r = sanei_genesys_get_address (reg, 0x25);
r->value = (scan_lines >> 16) & 0xf;
@ -1328,24 +1335,19 @@ gl847_init_motor_regs_scan (Genesys_Device * dev, Genesys_Register_Set * reg, un
r->value = REG68_FASTPWM;
r = sanei_genesys_get_address (reg, 0x21);
r->value = (slow_slope_steps >> 1) + (slow_slope_steps & 1);
r->value = slow_slope_steps; /* XXX STEF XXX */
r->value = slow_slope_steps;
r = sanei_genesys_get_address (reg, 0x24);
r->value = (back_slope_steps >> 1) + (back_slope_steps & 1);
r->value = back_slope_steps; /* XXX STEF XXX */
r->value = back_slope_steps;
r = sanei_genesys_get_address (reg, 0x69);
r->value = (slow_slope_steps >> 1) + (slow_slope_steps & 1);
r->value = slow_slope_steps; /* XXX STEF XXX */
r->value = slow_slope_steps;
r = sanei_genesys_get_address (reg, 0x6a);
r->value = (fast_slope_steps >> 1) + (fast_slope_steps & 1);
r->value = fast_slope_steps; /* XXX STEF XXX */
r->value = fast_slope_steps;
r = sanei_genesys_get_address (reg, 0x5f);
r->value = (fast_slope_steps >> 1) + (fast_slope_steps & 1);
r->value = fast_slope_steps; /* XXX STEF XXX */
r->value = fast_slope_steps;
DBGCOMPLETED;
@ -1488,6 +1490,7 @@ gl847_init_optical_regs_scan (Genesys_Device * dev,
r = sanei_genesys_get_address (reg, 0x19);
r->value = 0x50;
r->value = 0xff; /* XXX STEF XXX */
/* BW threshold */
r = sanei_genesys_get_address (reg, 0x2e);
@ -1585,7 +1588,7 @@ gl847_init_optical_regs_scan (Genesys_Device * dev,
DBG (DBG_io2, "%s: dev->skip=%d\n", __FUNCTION__, dev->skip);
RIE (sanei_genesys_buffer_free (&(dev->oe_buffer)));
RIE (sanei_genesys_buffer_alloc (&(dev->oe_buffer), dev->bpl));
RIE (sanei_genesys_buffer_alloc (&(dev->oe_buffer), dev->bpl*channels));
words_per_line *= channels;
@ -2314,7 +2317,7 @@ gl847_set_lamp_power (Genesys_Device * dev,
}
r = sanei_genesys_get_address (regs, 0x19);
r->value = 0x50;
r->value = 0xff;
r->value = 0xff; /* XXX STEF XXX */
}
else
{
@ -3308,7 +3311,7 @@ gl847_init_regs_for_shading (Genesys_Device * dev)
status = gl847_init_scan_regs (dev,
dev->calib_reg,
dev->settings.xres,
dev->sensor.optical_res,
dev->motor.base_ydpi,
0,
0,
@ -3360,6 +3363,7 @@ gl847_init_regs_for_scan (Genesys_Device * dev)
float move;
int move_dpi;
float start;
uint8_t val;
SANE_Status status;
@ -3416,11 +3420,9 @@ gl847_init_regs_for_scan (Genesys_Device * dev)
return status;
}
/* start */
/* start */
start = SANE_UNFIX (dev->model->x_offset);
start += dev->settings.tl_x;
start = (start * dev->sensor.optical_res) / MM_PER_INCH;
flags = 0;
@ -3433,19 +3435,16 @@ gl847_init_regs_for_scan (Genesys_Device * dev)
{
flags |= OPTICAL_FLAG_ENABLE_LEDADD;
}
/* enable emulated lineart from gray data */
if (dev->settings.scan_mode == SCAN_MODE_LINEART
&& dev->settings.dynamic_lineart)
{
flags |= SCAN_FLAG_DYNAMIC_LINEART;
}
/* emulated lineart from gray data s required for now */
flags |= SCAN_FLAG_DYNAMIC_LINEART;
status = gl847_init_scan_regs (dev,
dev->reg,
dev->settings.xres,
dev->settings.yres,
start,
0,
4,
dev->settings.pixels,
dev->settings.lines,
depth,
@ -3652,6 +3651,8 @@ gl847_led_calibration (Genesys_Device * dev)
/* offset calibration is always done in color mode */
channels = 3;
depth=16;
used_res = dev->sensor.optical_res;
num_pixels = (dev->sensor.sensor_pixels*used_res)/dev->sensor.optical_res;
/* initial calibration reg values */
memcpy (dev->calib_reg, dev->reg,
@ -3659,13 +3660,11 @@ gl847_led_calibration (Genesys_Device * dev)
status = gl847_init_scan_regs (dev,
dev->calib_reg,
dev->settings.xres,
dev->settings.yres,
used_res,
dev->motor.base_ydpi,
0,
0,
(dev->sensor.sensor_pixels *
dev->settings.xres) /
dev->sensor.optical_res,
num_pixels,
1,
depth,
channels,
@ -3687,8 +3686,6 @@ gl847_led_calibration (Genesys_Device * dev)
RIE (gl847_bulk_write_register
(dev, dev->calib_reg, GENESYS_GL847_MAX_REGS));
used_res = dev->current_setup.xres;
num_pixels = dev->current_setup.pixels;
total_size = num_pixels * channels * (depth/8) * 1; /* colors * bytes_per_color * scan lines */