From 84357741a6a6e6430f199b2c3f7498e0e97da9ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 12 Feb 2023 17:35:53 +0100 Subject: New upstream version 1.2.1 --- backend/fujitsu.c | 56 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 19 deletions(-) (limited to 'backend/fujitsu.c') diff --git a/backend/fujitsu.c b/backend/fujitsu.c index d17e015..52d0988 100644 --- a/backend/fujitsu.c +++ b/backend/fujitsu.c @@ -6,7 +6,7 @@ Copyright (C) 2000 Randolph Bentson Copyright (C) 2001 Frederik Ramm Copyright (C) 2001-2004 Oliver Schirrmeister - Copyright (C) 2003-2021 m. allan noah + Copyright (C) 2003-2022 m. allan noah JPEG output and low memory usage support funded by: Archivista GmbH, www.archivista.ch @@ -15,7 +15,7 @@ Automatic length detection support funded by: Martin G. Miller, mgmiller at optonline.net Software image enhancement routines and recent scanner support funded by: - Fujitsu Computer Products of America, Inc. www.fcpa.com + PFU America, Inc., fujitsuscanners.com -------------------------------------------------------------------------- @@ -611,6 +611,11 @@ - fix JPEG duplex memory corruption - change window_gamma init (fixes bright/contrast for iX1500) - only call send_lut after set_window (remove late_lut) + v138 2022-06-01, MAN + - minor updates to company name (FCPA -> PFU) + v139 2022-11-15, MAN + - move updated window_gamma logic to set_window + - use internal gamma table if possible (fixes #618) SANE FLOW DIAGRAM @@ -660,7 +665,7 @@ #include "fujitsu.h" #define DEBUG 1 -#define BUILD 137 +#define BUILD 139 /* values for SANE_DEBUG_FUJITSU env var: - errors 5 @@ -764,7 +769,7 @@ static struct fujitsu *fujitsu_devList = NULL; SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { - authorize = authorize; /* get rid of compiler warning */ + (void) authorize; /* get rid of compiler warning */ DBG_INIT (); DBG (10, "sane_init: start\n"); @@ -819,7 +824,7 @@ sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) int num_devices=0; int i=0; - local_only = local_only; /* get rid of compiler warning */ + (void) local_only; /* get rid of compiler warning */ DBG (10, "sane_get_devices: start\n"); @@ -2107,12 +2112,6 @@ init_model (struct fujitsu *s) s->ppl_mod_by_mode[MODE_GRAYSCALE] = 1; s->ppl_mod_by_mode[MODE_COLOR] = 1; - /* we prefer to use the downloaded (LUT) gamma table (0x80) if possible. - * but if scanner has only built-in gamma tables, we use the first one (0) */ - if (s->num_download_gamma){ - s->window_gamma = 0x80; - } - /* endorser type tells string length (among other things) */ if(s->has_endorser_b){ /*old-style is 40 bytes*/ @@ -2206,7 +2205,10 @@ init_model (struct fujitsu *s) s->color_interlace = COLOR_INTERLACE_3091; s->duplex_interlace = DUPLEX_INTERLACE_3091; s->ghs_in_rs = 1; - s->window_gamma = 0; + + /* might be inaccurate */ + s->num_internal_gamma = 1; + s->num_download_gamma = 0; s->reverse_by_mode[MODE_LINEART] = 1; s->reverse_by_mode[MODE_HALFTONE] = 1; @@ -7055,12 +7057,11 @@ sane_start (SANE_Handle handle) goto errors; } - /* send lut if scanner has no hardware brightness/contrast, - * or we are going to ask it to use a downloaded gamma table */ - if (!s->brightness_steps || !s->contrast_steps || s->window_gamma & 0x80){ + /* send lut if set_window said we would */ + if ( s->window_gamma ){ ret = send_lut(s); if (ret != SANE_STATUS_GOOD) - DBG (5, "sane_start: WARNING: cannot late send_lut %d\n", ret); + DBG (5, "sane_start: WARNING: cannot send_lut %d\n", ret); } /* some scanners need the q table sent, even when not scanning jpeg */ @@ -7614,6 +7615,23 @@ set_window (struct fujitsu *s) /* the remainder of the block varies based on model and mode, * except for gamma and paper size, those are in the same place */ + /* determine if we need to send gamma LUT. + * send lut if scanner supports it and any of: + * has no hardware brightness but user changed it + * has no hardware contrast but user changed it + * has no internal gamma table */ + if ( s->num_download_gamma && ( + (!s->brightness_steps && s->brightness != 0) + || (!s->contrast_steps && s->contrast != 0 ) + || !s->num_internal_gamma + ) ){ + s->window_gamma = 0x80; + } + /* otherwise, use the internal table */ + else{ + s->window_gamma = 0; + } + /*vuid c0*/ if(s->has_vuid_3091){ set_WD_vendor_id_code (desc1, WD_VUID_3091); @@ -9270,7 +9288,7 @@ sense_handler (int fd, unsigned char * sensed_data, void *arg) DBG (5, "sense_handler: start\n"); /* kill compiler warning */ - fd = fd; + (void) fd; /* copy the rs return data into the scanner struct so that the caller can use it if he wants */ @@ -9605,8 +9623,8 @@ do_scsi_cmd(struct fujitsu *s, int runRS, int shortTime, int ret; /*shut up compiler*/ - runRS=runRS; - shortTime=shortTime; + (void) runRS; + (void) shortTime; DBG(10, "do_scsi_cmd: start\n"); -- cgit v1.2.3