Re: HP support

David Mosberger-Tang (davidm@azstarnet.com)
Tue, 27 May 1997 08:41:51 -0700

If you're having problems with the HP backend, could you try the
following patch, please? The patch is relative to sane-0.57 and fixes
the following things:

- make brightness/contrast range detection automatic (the old
code definitively was broken), the new one hopefully works;
I can't test this myself since I don't have an HP scanner

- fix a bug in preview.c (I thought it had made it into sane-0.57
already, but obviously not so); this bug fix _may_ solve the oddities
that have been reported

- minor fix to xscanimage.c

If the brightness/contrast controls don't work as expected, please send me
the output you get with:

SANE_DEBUG_HP=3 scanimage -h -d hp

--david

diff -urN sane-0.57/backend/hp.c sane-0.58/backend/hp.c
--- sane-0.57/backend/hp.c Fri May 9 08:00:59 1997
+++ sane-0.58/backend/hp.c Tue May 27 07:57:10 1997
@@ -66,20 +66,6 @@
0
};

-static const SANE_Range s1_range =
- {
- -1, /* minimum */
- 1, /* maximum */
- 1 /* quantization */
- };
-
-static const SANE_Range s7_range =
- {
- -127, /* minimum */
- 127, /* maximum */
- 1 /* quantization */
- };
-
#define INQ_LEN 255
static const u_int8_t inquiry[] =
{
@@ -204,6 +190,10 @@
{10330, 'H', 'g', 10078, 0}, /* max_y */
{10323, 'L', 'k', 38, 0}, /* min_dpi */
{10323, 'H', 'g', 600, 0}, /* max_dpi */
+ {10317, 'L', 'k', 0, 0}, /* min_brightness */
+ {10317, 'H', 'g', 0, 0}, /* max_brightness */
+ {10316, 'L', 'k', 0, 0}, /* min_contrast */
+ {10316, 'H', 'g', 0, 0}, /* max_contrast */
};

for (dev = first_dev; dev; dev = dev->next)
@@ -281,6 +271,14 @@
dev->dpi_range.max = inq_params[5].value;
dev->dpi_range.quant = 1;

+ dev->brightness_range.min = inq_params[6].value;
+ dev->brightness_range.max = inq_params[7].value;
+ dev->brightness_range.quant = 1;
+
+ dev->contrast_range.min = inq_params[8].value;
+ dev->contrast_range.max = inq_params[9].value;
+ dev->contrast_range.quant = 1;
+
str = malloc (17);
memcpy (str, result + 16, 16);
str[16] = ' ';
@@ -417,11 +415,8 @@
s->opt[OPT_BRIGHTNESS].type = SANE_TYPE_INT;
s->opt[OPT_BRIGHTNESS].unit = SANE_UNIT_NONE;
s->opt[OPT_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE;
- s->opt[OPT_BRIGHTNESS].constraint.range = &s7_range;
+ s->opt[OPT_BRIGHTNESS].constraint.range = &s->hw->brightness_range;
s->val[OPT_BRIGHTNESS].w = 0;
- if (!s->hw->sane.model[0])
- /* plain ScanJet has only three levels */
- s->opt[OPT_BRIGHTNESS].constraint.range = &s1_range;

/* contrast */
s->opt[OPT_CONTRAST].name = SANE_NAME_CONTRAST;
@@ -430,9 +425,9 @@
s->opt[OPT_CONTRAST].type = SANE_TYPE_INT;
s->opt[OPT_CONTRAST].unit = SANE_UNIT_NONE;
s->opt[OPT_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE;
- s->opt[OPT_CONTRAST].constraint.range = &s7_range;
+ s->opt[OPT_CONTRAST].constraint.range = &s->hw->contrast_range;
s->val[OPT_CONTRAST].w = 0;
- if (s->hw->sane.model[0])
+ if (s->hw->contrast_range.min == s->hw->contrast_range.max)
/* plain ScanJet doesn't support contrast */
s->opt[OPT_CONTRAST].cap |= SANE_CAP_INACTIVE;
return SANE_STATUS_GOOD;
diff -urN sane-0.57/backend/hp.h sane-0.58/backend/hp.h
--- sane-0.57/backend/hp.h Wed Mar 19 18:42:10 1997
+++ sane-0.58/backend/hp.h Tue May 27 07:53:39 1997
@@ -58,6 +58,8 @@
SANE_Range dpi_range;
SANE_Range x_range;
SANE_Range y_range;
+ SANE_Range brightness_range;
+ SANE_Range contrast_range;
unsigned flags;
}
HP_Device;
diff -urN sane-0.57/frontend/preview.c sane-0.58/frontend/preview.c
--- sane-0.57/frontend/preview.c Sun May 4 18:13:47 1997
+++ sane-0.58/frontend/preview.c Mon May 12 07:43:07 1997
@@ -233,7 +233,7 @@

/* don't draw last line unless it's complete: */
height = p->image_y;
- if (p->image_x == 0)
+ if (p->image_x == 0 && height < p->image_height)
++height;

/* for now, use simple nearest-neighbor interpolation: */

diff -urN sane-0.57/frontend/xscanimage.c sane-0.58/frontend/xscanimage.c
--- sane-0.57/frontend/xscanimage.c Sun May 4 18:14:19 1997
+++ sane-0.58/frontend/xscanimage.c Thu May 15 08:42:08 1997
@@ -763,8 +763,6 @@

ScanWin.x = ScanWin.y = 0;

- gsg_sync (dialog);
-
status = sane_start (dev);
if (status != SANE_STATUS_GOOD)
{
@@ -907,6 +905,7 @@
return;
}
}
+ gsg_sync (dialog);
scan_start ();
}

--
Source code, list archive, and docs: http://www.azstarnet.com/~axplinux/sane/
To unsubscribe: mail -s unsubscribe sane-devel-request@listserv.azstarnet.com