diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2021-02-16 18:24:19 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2021-02-16 18:24:19 +0100 |
commit | 351b7328520c16730ceb46e5acae16038c42185e (patch) | |
tree | fae21fd5c94f3c3ed0202a95c9ada705482e647b /backend/fujitsu.c | |
parent | ad38bc6ecb80ddeb562841b33258dd53659b1da6 (diff) |
New upstream version 1.0.32upstream/1.0.32
Diffstat (limited to 'backend/fujitsu.c')
-rw-r--r-- | backend/fujitsu.c | 102 |
1 files changed, 46 insertions, 56 deletions
diff --git a/backend/fujitsu.c b/backend/fujitsu.c index d24975e..6c1c8f6 100644 --- a/backend/fujitsu.c +++ b/backend/fujitsu.c @@ -30,9 +30,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA. + along with this program. If not, see <https://www.gnu.org/licenses/>. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. @@ -172,11 +170,11 @@ - use sanei_scsi_open_extended() to set buffer size - fix some compiler warns: 32&64 bit gcc v26 2006-05-23, MAN - - dont send scanner control (F1) if unsupported + - don't send scanner control (F1) if unsupported v27 2006-05-30, MAN - speed up hexdump (adeuring A T gmx D O T net) - duplex request same size block from both sides - - dont #include or call sanei_thread + - don't #include or call sanei_thread - split usb/scsi command DBG into 25 and 30 v28 2006-06-01, MAN - sane_read() usleep if scanner is busy @@ -201,10 +199,10 @@ - add error msg if VPD missing or non-extended - remove references to color_lineart and ht units - rework init_model to support more known models - - dont send paper size data if using flatbed + - don't send paper size data if using flatbed v31 2006-06-13, MAN - add 5220C usb id - - dont show ink level buttons if no imprinter + - don't show ink level buttons if no imprinter - run ghs/rs every second instead of every other v32 2006-06-14, MAN - add 4220C2 usb id @@ -299,7 +297,7 @@ - proper async sane_cancel support - re-enable JPEG support - replace s->img_count with s->side - - sane_get_parameters(): dont round up larger than current paper size + - sane_get_parameters(): don't round up larger than current paper size - sane_start() rewritten, shorter, more clear - return values are SANE_Status, not int - hide unused functions @@ -386,7 +384,7 @@ - set SANE_CAP_INACTIVE on all disabled options - fix bug in mode_select page for sleep timer v78 2008-08-26, MAN - - recent model names (fi-6xxx) dont end in 'C' + - recent model names (fi-6xxx) don't end in 'C' - simplify flatbed area overrides - call scanner_control to change source during sane_start v79 2008-10-01, MAN @@ -423,7 +421,7 @@ - track frontend reading sensor/button values to reload - deactivate double feed options if df-action == default v88 2009-01-21, MAN - - dont export private symbols + - don't export private symbols v89 2009-02-20, MAN - fi-4750 returns random garbage to serial number queries v90 2009-02-23, MAN @@ -482,7 +480,7 @@ - cache software crop/deskew parameters for use on backside of duplex - fi-6110 does not support bgcolor or prepick v106 2011-01-30, MAN (SANE 1.0.22) - - dont call mode_select with a page code the scanner does not support + - don't call mode_select with a page code the scanner does not support v107 2011-11-03, MAN - M3091 does not support scanner_control(adf) - Correct buffer overflow in read_from_3091duplex() @@ -609,6 +607,10 @@ - add support for fi-800R - add support for card scanning slot (Return Path) - fix bug with reading hardware sensors on first invocation + v137 2020-09-23, MAN + - fix JPEG duplex memory corruption + - change window_gamma init (fixes bright/contrast for iX1500) + - only call send_lut after set_window (remove late_lut) SANE FLOW DIAGRAM @@ -658,7 +660,7 @@ #include "fujitsu.h" #define DEBUG 1 -#define BUILD 136 +#define BUILD 137 /* values for SANE_DEBUG_FUJITSU env var: - errors 5 @@ -1217,7 +1219,7 @@ init_inquire (struct fujitsu *s) s->color_raster_offset = get_IN_color_offset(in); DBG (15, " color offset: %d lines\n",s->color_raster_offset); - /* FIXME: we dont store all of these? */ + /* FIXME: we don't store all of these? */ DBG (15, " long gray scan: %d\n",get_IN_long_gray(in)); DBG (15, " long color scan: %d\n",get_IN_long_color(in)); @@ -1701,7 +1703,7 @@ init_vpd (struct fujitsu *s) s->has_comp_JPG3 = get_IN_compression_JPG_INDEP (in); DBG (15, " compression JPG3: %d\n", s->has_comp_JPG3); - /* FIXME: we dont store these? */ + /* FIXME: we don't store these? */ DBG (15, " back endorser mech: %d\n", get_IN_endorser_b_mech(in)); DBG (15, " back endorser stamp: %d\n", get_IN_endorser_b_stamp(in)); DBG (15, " back endorser elec: %d\n", get_IN_endorser_b_elec(in)); @@ -2105,11 +2107,9 @@ init_model (struct fujitsu *s) s->ppl_mod_by_mode[MODE_GRAYSCALE] = 1; s->ppl_mod_by_mode[MODE_COLOR] = 1; - /* if scanner has built-in gamma tables, we use the first one (0) */ - /* otherwise, we use the first downloaded one (0x80) */ - /* note that you may NOT need to send the table to use it, */ - /* the scanner will fall back to the brightness/contrast LUT */ - if (!s->num_internal_gamma && s->num_download_gamma){ + /* 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; } @@ -2365,7 +2365,6 @@ init_model (struct fujitsu *s) /* weirdness */ s->need_q_table = 1; - s->late_lut = 1; s->need_diag_preread = 1; s->ppl_mod_by_mode[MODE_COLOR] = 2; s->hopper_before_op = 1; @@ -2378,7 +2377,7 @@ init_model (struct fujitsu *s) s->can_mode[MODE_LINEART] = 2; s->can_mode[MODE_GRAYSCALE] = 2; - /* dont bother with this one */ + /* don't bother with this one */ s->can_mode[MODE_HALFTONE] = 0; } @@ -2389,7 +2388,6 @@ init_model (struct fujitsu *s) /* weirdness */ s->need_q_table = 1; - s->late_lut = 1; s->need_diag_preread = 1; s->ppl_mod_by_mode[MODE_COLOR] = 2; s->hopper_before_op = 1; @@ -2398,7 +2396,7 @@ init_model (struct fujitsu *s) /* lies */ s->adbits = 8; - /* dont bother with this one */ + /* don't bother with this one */ s->can_mode[MODE_HALFTONE] = 0; } @@ -4202,7 +4200,7 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) opt->unit = SANE_UNIT_NONE; opt->size = sizeof(SANE_Word); - /*old type cant do this?*/ + /*old type can't do this?*/ if ((s->has_endorser_f && s->endorser_type_f != ET_OLD) || (s->has_endorser_b && s->endorser_type_b != ET_OLD)){ opt->cap=SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; @@ -5336,7 +5334,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option, DBG (20, "sane_control_option: set value for '%s' (%d)\n", s->opt[option].name,option); if ( s->started ) { - DBG (5, "sane_control_option: cant set, device busy\n"); + DBG (5, "sane_control_option: can't set, device busy\n"); return SANE_STATUS_DEVICE_BUSY; } @@ -5351,7 +5349,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option, return status; } - /* may have been changed by constrain, so dont copy until now */ + /* may have been changed by constrain, so don't copy until now */ val_c = *(SANE_Word *)val; /* @@ -6429,7 +6427,7 @@ diag_preread (struct fujitsu *s) set_SD_preread_yres(out,s->resolution_y); /* call helper function, scanner wants lies about paper width */ set_SD_preread_paper_width(out, get_page_width(s)); - /* dont call helper function, scanner wants actual length? */ + /* don't call helper function, scanner wants actual length? */ set_SD_preread_paper_length(out, s->page_height); set_SD_preread_composition(out, s->s_mode); @@ -6789,7 +6787,7 @@ sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) params->pixels_per_line = s->u_params.pixels_per_line; params->bytes_per_line = s->u_params.bytes_per_line; - /* we wont know the end until we get to it */ + /* we won't know the end until we get to it */ if(s->ald && !must_fully_buffer(s)){ DBG (15, "sane_get_parameters: hand-scanner mode\n"); params->lines = -1; @@ -6941,7 +6939,7 @@ update_u_params (struct fujitsu * s) * * this will be called between sides of a duplex scan, * and at the start of each page of an adf batch. - * hence, we spend alot of time playing with s->started, etc. + * hence, we spend a lot of time playing with s->started, etc. */ SANE_Status sane_start (SANE_Handle handle) @@ -7050,14 +7048,6 @@ sane_start (SANE_Handle handle) if (ret != SANE_STATUS_GOOD) DBG (5, "sane_start: WARNING: cannot send_endorser %d\n", ret); - /* send lut if scanner has no hardware brightness/contrast, - * or we are going to ask it to use a downloaded gamma table */ - if (!s->late_lut && (!s->brightness_steps || !s->contrast_steps || s->window_gamma & 0x80)){ - ret = send_lut(s); - if (ret != SANE_STATUS_GOOD) - DBG (5, "sane_start: WARNING: cannot early send_lut %d\n", ret); - } - /* set window command */ ret = set_window(s); if (ret != SANE_STATUS_GOOD) { @@ -7067,7 +7057,7 @@ sane_start (SANE_Handle handle) /* send lut if scanner has no hardware brightness/contrast, * or we are going to ask it to use a downloaded gamma table */ - if (s->late_lut && (!s->brightness_steps || !s->contrast_steps || s->window_gamma & 0x80)){ + if (!s->brightness_steps || !s->contrast_steps || s->window_gamma & 0x80){ ret = send_lut(s); if (ret != SANE_STATUS_GOOD) DBG (5, "sane_start: WARNING: cannot late send_lut %d\n", ret); @@ -7110,10 +7100,10 @@ sane_start (SANE_Handle handle) } /* set clean defaults with new sheet of paper */ - /* dont reset the transfer vars on backside of duplex page */ + /* don't reset the transfer vars on backside of duplex page */ /* otherwise buffered back page will be lost */ /* ingest paper with adf (no-op for fb) */ - /* dont call object pos or scan on back side of duplex scan */ + /* don't call object pos or scan on back side of duplex scan */ if(s->side == SIDE_FRONT || s->source == SOURCE_ADF_BACK || s->source == SOURCE_CARD_BACK){ s->bytes_rx[0]=0; @@ -7187,7 +7177,7 @@ sane_start (SANE_Handle handle) s->buff_tot[SIDE_BACK] = s->bytes_tot[SIDE_BACK]; /* the back buffer is normally very large, but some scanners or - * option combinations dont need it, so we make a small one */ + * option combinations don't need it, so we make a small one */ if(s->low_mem || s->source == SOURCE_ADF_BACK || s->source == SOURCE_CARD_BACK || s->duplex_interlace == DUPLEX_INTERLACE_NONE) s->buff_tot[SIDE_BACK] = s->buffer_size; @@ -7739,7 +7729,7 @@ set_window (struct fujitsu *s) /* call helper function, scanner wants lies about paper width */ set_WD_paper_width_X (desc1, get_page_width(s)); - /* dont call helper function, scanner wants actual length? */ + /* don't call helper function, scanner wants actual length? */ set_WD_paper_length_Y (desc1, s->page_height); } @@ -7974,7 +7964,7 @@ start_scan (struct fujitsu *s) /* checks started and cancelled flags in scanner struct, * sends cancel command to scanner if required. don't call - * this function asyncronously, wait for pending operation */ + * this function asynchronously, wait for pending operation */ static SANE_Status check_for_cancel(struct fujitsu *s) { @@ -8166,7 +8156,7 @@ sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len return ret; } -/* bare jpeg images dont contain resolution, but JFIF APP0 does, so we add */ +/* bare jpeg images don't contain resolution, but JFIF APP0 does, so we add */ static SANE_Status inject_jfif_header(struct fujitsu *s, int side) { @@ -8220,21 +8210,21 @@ read_from_JPEGduplex(struct fujitsu *s) int avail = s->buff_tot[SIDE_FRONT] - s->buff_rx[SIDE_FRONT]; if(bytes > avail){ bytes = avail; - /* leave space for JFIF header at start of image */ - if(s->bytes_rx[SIDE_FRONT] < 2) - bytes -= JFIF_APP0_LENGTH; } } if(!s->eof_rx[SIDE_BACK]){ int avail = s->buff_tot[SIDE_BACK] - s->buff_rx[SIDE_BACK]; if(bytes > avail){ bytes = avail; - /* leave space for JFIF header at start of image */ - if(s->bytes_rx[SIDE_BACK] < 2) - bytes -= JFIF_APP0_LENGTH; } } + /* leave space for JFIF header in the small front side buffer, + * if we are at the beginning of the image */ + if(s->bytes_rx[SIDE_FRONT] < 3){ + bytes -= JFIF_APP0_LENGTH; + } + DBG(15, "read_from_JPEGduplex: fto:%d frx:%d bto:%d brx:%d pa:%d\n", s->bytes_tot[SIDE_FRONT], s->bytes_rx[SIDE_FRONT], s->bytes_tot[SIDE_BACK], s->bytes_rx[SIDE_BACK], @@ -8378,7 +8368,7 @@ read_from_JPEGduplex(struct fujitsu *s) } /* unknown, warn */ - else if(in[i] != 0xff){ + else if(in[i] != 0x00){ DBG(15, "read_from_JPEGduplex: unknown %02x\n", in[i]); } } @@ -8415,7 +8405,7 @@ read_from_JPEGduplex(struct fujitsu *s) s->bytes_rx[SIDE_FRONT]++; } - /* image is interlaced afterall, continue */ + /* image is interlaced after all, continue */ else{ DBG(15, "read_from_JPEGduplex: wrong width, req:%d got:%d\n", s->s_params.pixels_per_line,width); @@ -8484,7 +8474,7 @@ read_from_JPEGduplex(struct fujitsu *s) free(in); - /* jpeg uses in-band EOI marker, so this is ususally redundant */ + /* jpeg uses in-band EOI marker, so this is usually redundant */ if(ret == SANE_STATUS_EOF){ DBG(15, "read_from_JPEGduplex: got EOF, finishing\n"); s->eof_rx[SIDE_FRONT] = 1; @@ -9157,7 +9147,7 @@ downsample_from_buffer(struct fujitsu *s, SANE_Byte * buf, * handle h is a valid handle) but usually affects long-running * operations only (such as image is acquisition). It is safe to call * this function asynchronously (e.g., from within a signal handler). - * It is important to note that completion of this operaton does not + * It is important to note that completion of this operation does not * imply that the currently pending operation has been cancelled. It * only guarantees that cancellation has been initiated. Cancellation * completes only when the cancelled call returns (typically with a @@ -9963,7 +9953,7 @@ get_page_width(struct fujitsu *s) return s->page_width; } - /* cant overscan larger than scanner max */ + /* can't overscan larger than scanner max */ if(width > s->max_x){ return s->max_x; } @@ -9992,7 +9982,7 @@ get_page_height(struct fujitsu *s) return s->page_height; } - /* cant overscan larger than scanner max */ + /* can't overscan larger than scanner max */ if(height > s->max_y){ return s->max_y; } |