diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-05-24 21:03:56 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-05-24 21:03:56 +0200 |
commit | 58912f68c2489bcee787599837447e0d64dfd61a (patch) | |
tree | dda50aadde35fe152da1a8d50769987ace0f1496 /backend/genesys.c | |
parent | cfd27ef2ad8b005fd47ab41ef29b71d9e3d48201 (diff) |
New upstream version 1.0.27upstream/1.0.27
Diffstat (limited to 'backend/genesys.c')
-rw-r--r-- | backend/genesys.c | 104 |
1 files changed, 55 insertions, 49 deletions
diff --git a/backend/genesys.c b/backend/genesys.c index 984cead..db0a2b2 100644 --- a/backend/genesys.c +++ b/backend/genesys.c @@ -2,7 +2,7 @@ Copyright (C) 2003, 2004 Henning Meier-Geinitz <henning@meier-geinitz.de> Copyright (C) 2004, 2005 Gerhard Jaeger <gerhard@gjaeger.de> - Copyright (C) 2004-2015 Stéphane Voltz <stef.dev@free.fr> + Copyright (C) 2004-2016 Stéphane Voltz <stef.dev@free.fr> Copyright (C) 2005-2009 Pierre Willenbrock <pierre@pirsoft.dnsalias.org> Copyright (C) 2006 Laurent Charpentier <laurent_pubs@yahoo.com> Copyright (C) 2007 Luke <iceyfor@gmail.com> @@ -58,7 +58,7 @@ * SANE backend for Genesys Logic GL646/GL841/GL842/GL843/GL846/GL847/GL124 based scanners */ -#define BUILD 2508 +#define BUILD 2511 #define BACKEND_NAME genesys #include "genesys.h" @@ -387,7 +387,7 @@ sanei_genesys_create_slope_table3 (Genesys_Device * dev, DBG (DBG_proc, "%s: step_type = %d, " - "exposure_time = %d, yres = %g, power_mode = %d\n", __FUNCTION__, step_type, + "exposure_time = %d, yres = %g, power_mode = %d\n", __func__, step_type, exposure_time, yres, power_mode); /* final speed */ @@ -792,7 +792,7 @@ sanei_genesys_exposure_time2 (Genesys_Device * dev, float ydpi, exposure = exposure_by_led; DBG (DBG_info, "%s: ydpi=%d, step=%d, endpixel=%d led=%d, power=%d => exposure=%d\n", - __FUNCTION__, (int)ydpi, step_type, endpixel, exposure_by_led, power_mode, exposure); + __func__, (int)ydpi, step_type, endpixel, exposure_by_led, power_mode, exposure); return exposure; } @@ -928,7 +928,7 @@ genesys_send_offset_and_shading (Genesys_Device * dev, uint8_t * data, int start_address; SANE_Status status; - DBG (DBG_proc, "%s: (size = %d)\n", __FUNCTION__, size); + DBG (DBG_proc, "%s: (size = %d)\n", __func__, size); /* ASIC higher than gl843 doesn't have register 2A/2B, so we route to * a per ASIC shading data loading function if available. @@ -978,7 +978,7 @@ genesys_send_offset_and_shading (Genesys_Device * dev, uint8_t * data, status = sanei_genesys_set_buffer_address (dev, start_address); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to set buffer address: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to set buffer address: %s\n", __func__, sane_strstatus (status)); return status; } @@ -986,7 +986,7 @@ genesys_send_offset_and_shading (Genesys_Device * dev, uint8_t * data, status = dev->model->cmd_set->bulk_write_data (dev, 0x3c, data, size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to send shading table: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to send shading table: %s\n", __func__, sane_strstatus (status)); return status; } @@ -1046,7 +1046,7 @@ sanei_genesys_init_shading_data (Genesys_Device * dev, int pixels_per_line) free (shading_data); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to send shading data: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to send shading data: %s\n", __func__, sane_strstatus (status)); } @@ -1489,7 +1489,7 @@ genesys_coarse_calibration (Genesys_Device * dev) status = dev->model->cmd_set->set_fe (dev, AFE_INIT); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to set frontend: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to set frontend: %s\n", __func__, sane_strstatus (status)); free(all_data); free(calibration_data); @@ -2069,9 +2069,12 @@ genesys_white_shading_calibration (Genesys_Device * dev) /* turn on motor and lamp power */ dev->model->cmd_set->set_lamp_power (dev, dev->calib_reg, SANE_TRUE); dev->model->cmd_set->set_motor_power (dev->calib_reg, motor); - if (dev->model->flags & GENESYS_FLAG_SHADING_REPARK) + + /* if needed, go back before doin next scan, by using rewind, registers and + * slopes table are kept intact from previous scan */ + if (dev->model->flags & GENESYS_FLAG_SHADING_REPARK && dev->model->cmd_set->rewind) { - status = dev->model->cmd_set->slow_back_home (dev, SANE_TRUE); + status = dev->model->cmd_set->rewind (dev); } status = @@ -2180,7 +2183,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev) SANE_Bool motor; - DBG (DBG_proc, "%s: (lines = %d)\n", __FUNCTION__, (unsigned int)dev->calib_lines); + DBG (DBG_proc, "%s: (lines = %d)\n", __func__, (unsigned int)dev->calib_lines); pixels_per_line = dev->calib_pixels; channels = dev->calib_channels; @@ -2193,7 +2196,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev) dev->white_average_data = malloc (dev->average_size); if (!dev->white_average_data) { - DBG (DBG_error, "%s: failed to allocate white average memory\n", __FUNCTION__); + DBG (DBG_error, "%s: failed to allocate white average memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -2203,7 +2206,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev) dev->dark_average_data = malloc (channels * 2 * pixels_per_line); if (!dev->dark_average_data) { - DBG (DBG_error, "%s: failed to allocate dark average memory\n", __FUNCTION__); + DBG (DBG_error, "%s: failed to allocate dark average memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -2212,7 +2215,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev) calibration_data = malloc (size); if (!calibration_data) { - DBG (DBG_error, "%s: failed to allocate calibration memory\n", __FUNCTION__); + DBG (DBG_error, "%s: failed to allocate calibration memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -2233,7 +2236,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (calibration_data); - DBG (DBG_error, "%s: failed to bulk write registers: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus (status)); return status; } @@ -2243,7 +2246,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (calibration_data); - DBG (DBG_error, "%s: failed to begin scan: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to begin scan: %s\n", __func__, sane_strstatus (status)); return status; } @@ -2252,7 +2255,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (calibration_data); - DBG (DBG_error, "%s: failed to read data: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to read data: %s\n", __func__, sane_strstatus (status)); return status; } @@ -2261,7 +2264,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (calibration_data); - DBG (DBG_error, "%s: Failed to end scan: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: Failed to end scan: %s\n", __func__, sane_strstatus (status)); return status; } @@ -2434,7 +2437,7 @@ compute_averaged_planar (Genesys_Device * dev, unsigned int x, i, j, br, dk, res, avgpixels, basepixels, val; unsigned int fill,factor; - DBG (DBG_info, "%s: pixels=%d, offset=%d\n", __FUNCTION__, pixels_per_line, o); + DBG (DBG_info, "%s: pixels=%d, offset=%d\n", __func__, pixels_per_line, o); /* initialize result */ memset (shading_data, 0xff, words_per_color * 3 * 2); @@ -2504,9 +2507,9 @@ compute_averaged_planar (Genesys_Device * dev, fill=1; } - DBG (DBG_info, "%s: averaging over %d pixels\n", __FUNCTION__, avgpixels); - DBG (DBG_info, "%s: packing factor is %d\n", __FUNCTION__, factor); - DBG (DBG_info, "%s: fill length is %d\n", __FUNCTION__, fill); + DBG (DBG_info, "%s: averaging over %d pixels\n", __func__, avgpixels); + DBG (DBG_info, "%s: packing factor is %d\n", __func__, factor); + DBG (DBG_info, "%s: fill length is %d\n", __func__, fill); for (x = 0; x <= pixels_per_line - avgpixels; x += avgpixels) { @@ -2903,7 +2906,7 @@ genesys_send_shading_coefficient (Genesys_Device * dev) shading_data = malloc (length); if (!shading_data) { - DBG (DBG_error, "%s: failed to allocate memory\n", __FUNCTION__); + DBG (DBG_error, "%s: failed to allocate memory\n", __func__); return SANE_STATUS_NO_MEM; } memset (shading_data, 0, length); @@ -3071,7 +3074,7 @@ genesys_send_shading_coefficient (Genesys_Device * dev) shading_data = malloc (length); if (!shading_data) { - DBG (DBG_error, "%s: failed to allocate memory\n", __FUNCTION__); + DBG (DBG_error, "%s: failed to allocate memory\n", __func__); return SANE_STATUS_NO_MEM; } memset (shading_data, 0, length); @@ -3121,7 +3124,7 @@ genesys_send_shading_coefficient (Genesys_Device * dev) 256); /* patch_size: contigous extent */ break; default: - DBG (DBG_error, "%s: sensor %d not supported\n", __FUNCTION__, dev->model->ccd_type); + DBG (DBG_error, "%s: sensor %d not supported\n", __func__, dev->model->ccd_type); return SANE_STATUS_UNSUPPORTED; break; } @@ -3131,7 +3134,7 @@ genesys_send_shading_coefficient (Genesys_Device * dev) free (shading_data); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to send shading data: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed to send shading data: %s\n", __func__, sane_strstatus (status)); } @@ -3689,7 +3692,7 @@ genesys_sheetfed_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { dev->model->cmd_set->eject_document (dev); - DBG (DBG_error, "%s: failed eject target: %s\n", __FUNCTION__, + DBG (DBG_error, "%s: failed eject target: %s\n", __func__, sane_strstatus (status)); return status; } @@ -3821,7 +3824,7 @@ genesys_warmup_lamp (Genesys_Device * dev) /* check if the current chipset implements warmup */ if(dev->model->cmd_set->init_regs_for_warmup==NULL) { - DBG (DBG_error, "%s: init_regs_for_warmup not implemented\n", __FUNCTION__); + DBG (DBG_error, "%s: init_regs_for_warmup not implemented\n", __func__); return status; } @@ -4346,7 +4349,7 @@ genesys_fill_line_interp_buffer (Genesys_Device * dev, uint8_t *work_buffer_dst, if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to read %lu bytes (%s)\n", __FUNCTION__, + "%s: failed to read %lu bytes (%s)\n", __func__, (u_long) dev->oe_buffer.size, sane_strstatus (status)); return SANE_STATUS_IO_ERROR; } @@ -4383,7 +4386,7 @@ genesys_fill_line_interp_buffer (Genesys_Device * dev, uint8_t *work_buffer_dst, if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to read %lu bytes (%s)\n", __FUNCTION__, + "%s: failed to read %lu bytes (%s)\n", __func__, (u_long) dev->oe_buffer.size, sane_strstatus (status)); return SANE_STATUS_IO_ERROR; } @@ -4417,7 +4420,7 @@ genesys_fill_segmented_buffer (Genesys_Device * dev, uint8_t *work_buffer_dst, s if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to read %lu bytes (%s)\n", __FUNCTION__, + "%s: failed to read %lu bytes (%s)\n", __func__, (u_long) dev->oe_buffer.size, sane_strstatus (status)); return SANE_STATUS_IO_ERROR; } @@ -4508,7 +4511,7 @@ genesys_fill_segmented_buffer (Genesys_Device * dev, uint8_t *work_buffer_dst, s if (status != SANE_STATUS_GOOD) { DBG (DBG_error, - "%s: failed to read %lu bytes (%s)\n", __FUNCTION__, + "%s: failed to read %lu bytes (%s)\n", __func__, (u_long) dev->oe_buffer.size, sane_strstatus (status)); return SANE_STATUS_IO_ERROR; } @@ -5496,7 +5499,7 @@ GENESYS_STATIC char *calibration_filename(Genesys_Device *currdev) snprintf (tmpstr, PATH_MAX, "%s%c.sane%c%s", ptr, PATH_SEP, PATH_SEP, filename); } - DBG (DBG_info, "%s: calibration filename >%s<\n", __FUNCTION__, tmpstr); + DBG (DBG_info, "%s: calibration filename >%s<\n", __func__, tmpstr); return tmpstr; } @@ -5893,7 +5896,7 @@ init_options (Genesys_Scanner * s) DISABLE (OPT_COLOR_FILTER); } - /* calibration stor file name */ + /* calibration store file name */ s->opt[OPT_CALIBRATION_FILE].name = "calibration-file"; s->opt[OPT_CALIBRATION_FILE].title = SANE_I18N ("Calibration file"); s->opt[OPT_CALIBRATION_FILE].desc = SANE_I18N ("Specify the calibration file to use"); @@ -6330,7 +6333,7 @@ probe_genesys_devices (void) free (new_dev); } - DBG(DBG_info, "%s: %d devices currently attached\n", __FUNCTION__, num_devices); + DBG(DBG_info, "%s: %d devices currently attached\n", __func__, num_devices); DBGCOMPLETED; @@ -6545,7 +6548,7 @@ genesys_buffer_image(Genesys_Scanner *s) lines = (SANE_UNFIX (dev->model->y_size) * dev->settings.yres) / MM_PER_INCH; } - DBG (DBG_info, "%s: buffering %d lines of %d bytes\n", __FUNCTION__, lines, + DBG (DBG_info, "%s: buffering %d lines of %d bytes\n", __func__, lines, s->params.bytes_per_line); /* maximum bytes to read */ @@ -6568,7 +6571,7 @@ genesys_buffer_image(Genesys_Scanner *s) { DBG (DBG_error, "%s: digital processing requires too much memory.\nConsider disabling it\n", - __FUNCTION__); + __func__); return SANE_STATUS_NO_MEM; } @@ -6585,7 +6588,7 @@ genesys_buffer_image(Genesys_Scanner *s) if (status != SANE_STATUS_EOF && status != SANE_STATUS_GOOD) { free (s->dev->img_buffer); - DBG (DBG_error, "%s: %s buffering failed\n", __FUNCTION__, + DBG (DBG_error, "%s: %s buffering failed\n", __func__, sane_strstatus (status)); return status; } @@ -6600,7 +6603,7 @@ genesys_buffer_image(Genesys_Scanner *s) { DBG (DBG_error0, "%s: digital processing requires too much memory.\nConsider disabling it\n", - __FUNCTION__); + __func__); return SANE_STATUS_NO_MEM; } } @@ -6627,7 +6630,7 @@ genesys_buffer_image(Genesys_Scanner *s) { DBG (DBG_error0, "%s: digital processing requires too much memory.\nConsider disabling it\n", - __FUNCTION__); + __func__); return SANE_STATUS_NO_MEM; } genesys_gray_lineart (dev, @@ -6669,10 +6672,10 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) DBG_INIT (); DBG (DBG_init, "SANE Genesys backend version %d.%d build %d from %s\n", SANE_CURRENT_MAJOR, V_MINOR, BUILD, PACKAGE_STRING); -#ifdef HAVE_LIBUSB_1_0 +#ifdef HAVE_LIBUSB DBG (DBG_init, "SANE Genesys backend built with libusb-1.0\n"); #endif -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY DBG (DBG_init, "SANE Genesys backend built with libusb\n"); #endif @@ -6942,8 +6945,8 @@ sane_open (SANE_String_Const devicename, SANE_Handle * handle) tmpstr=calibration_filename(s->dev); s->val[OPT_CALIBRATION_FILE].s = strdup (tmpstr); s->dev->calib_file = strdup (tmpstr); - DBG (DBG_info, "%s: Calibration filename set to:\n", __FUNCTION__); - DBG (DBG_info, "%s: >%s<\n", __FUNCTION__, s->dev->calib_file); + DBG (DBG_info, "%s: Calibration filename set to:\n", __func__); + DBG (DBG_info, "%s: >%s<\n", __func__, s->dev->calib_file); free(tmpstr); /* now open file, fetch calibration records */ @@ -7033,7 +7036,9 @@ sane_close (SANE_Handle handle) FREE_IFNOT_NULL (s->dev->sensor.gamma_table[1]); FREE_IFNOT_NULL (s->dev->sensor.gamma_table[2]); - /* for an handful of bytes .. */ + s->dev->already_initialized = SANE_FALSE; + + /* for an handful of bytes .. */ free ((void *)(size_t)s->opt[OPT_RESOLUTION].constraint.word_list); free (s->val[OPT_SOURCE].s); free (s->val[OPT_MODE].s); @@ -7125,6 +7130,7 @@ get_option_value (Genesys_Scanner * s, int option, void *val) case OPT_DESPECK: case OPT_CONTRAST: case OPT_BRIGHTNESS: + case OPT_EXPIRATION_TIME: *(SANE_Word *) val = s->val[option].w; break; case OPT_CUSTOM_GAMMA: @@ -7245,8 +7251,8 @@ static SANE_Status set_calibration_value (Genesys_Scanner * s, int option, void if (tmp) free (tmp); dev->calib_file = strdup (val); - DBG (DBG_info, "%s: Calibration filename set to:\n", __FUNCTION__); - DBG (DBG_info, "%s: >%s<\n", __FUNCTION__, s->dev->calib_file); + DBG (DBG_info, "%s: Calibration filename set to:\n", __func__); + DBG (DBG_info, "%s: >%s<\n", __func__, s->dev->calib_file); DBGCOMPLETED; return SANE_STATUS_GOOD; @@ -7536,7 +7542,7 @@ set_option_value (Genesys_Scanner * s, int option, void *val, { DBG (DBG_error, "%s: failed to disable power saving mode: %s\n", - __FUNCTION__, sane_strstatus (status)); + __func__, sane_strstatus (status)); } else status = genesys_scanner_calibration (s->dev); |