From 351b7328520c16730ceb46e5acae16038c42185e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Tue, 16 Feb 2021 18:24:19 +0100 Subject: New upstream version 1.0.32 --- backend/pixma/pixma.c | 57 +++++++++++++++++++++-------- backend/pixma/pixma.h | 33 ++++++++++++----- backend/pixma/pixma_bjnp.c | 28 +++++++-------- backend/pixma/pixma_bjnp.h | 16 ++++----- backend/pixma/pixma_bjnp_private.h | 10 +++--- backend/pixma/pixma_common.c | 31 ++++++++++++---- backend/pixma/pixma_common.h | 11 +++--- backend/pixma/pixma_imageclass.c | 10 +++--- backend/pixma/pixma_io.h | 8 ++--- backend/pixma/pixma_io_sanei.c | 4 +-- backend/pixma/pixma_mp150.c | 73 ++++++++++++++++++++++++++++++-------- backend/pixma/pixma_mp730.c | 4 +-- backend/pixma/pixma_mp750.c | 6 ++-- backend/pixma/pixma_mp800.c | 21 +++++++---- backend/pixma/pixma_rename.h | 4 +-- 15 files changed, 211 insertions(+), 105 deletions(-) (limited to 'backend/pixma') diff --git a/backend/pixma/pixma.c b/backend/pixma/pixma.c index c32907c..b4e423d 100644 --- a/backend/pixma/pixma.c +++ b/backend/pixma/pixma.c @@ -17,9 +17,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 . As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. @@ -116,6 +114,8 @@ typedef struct pixma_sane_t uint8_t gamma_table[4096]; SANE_String_Const source_list[4]; pixma_paper_source_t source_map[4]; + SANE_String_Const calibrate_list[PIXMA_CALIBRATE_NUM_OPTS + 1]; + pixma_calibrate_option_t calibrate_map[PIXMA_CALIBRATE_NUM_OPTS + 1]; unsigned byte_pos_in_line, output_line_size; uint64_t image_bytes_read; @@ -159,10 +159,11 @@ static void mark_all_button_options_cached ( struct pixma_sane_t * ss ) ss -> button_option_is_cached[i] = 1; } -static SANE_Status config_attach_pixma(SANEI_Config * config, const char *devname) +static SANE_Status config_attach_pixma(SANEI_Config __sane_unused__ * config, + const char *devname, + void __sane_unused__ *data) { int i; - UNUSED(config); for (i=0; i < (MAX_CONF_DEVICES -1); i++) { if(conf_devices[i] == NULL) @@ -504,6 +505,22 @@ create_dpi_list (pixma_sane_t * ss) /*PDBG (pixma_dbg (4, "*create_dpi_list***** min_dpi = %d, max_dpi = %d\n", min_dpi, max_dpi));*/ } + +static void +create_calibrate_list (pixma_sane_t * ss) +{ + int i = 0; + ss->calibrate_list[i] = SANE_I18N ("Once"); + ss->calibrate_map[i] = PIXMA_CALIBRATE_ONCE; + i++; + ss->calibrate_list[i] = SANE_I18N ("Always"); + ss->calibrate_map[i] = PIXMA_CALIBRATE_ALWAYS; + i++; + ss->calibrate_list[i] = SANE_I18N ("Never"); + ss->calibrate_map[i] = PIXMA_CALIBRATE_NEVER; + i++; +} + static void select_value_from_list (pixma_sane_t * ss, SANE_Int n, void *v, SANE_Int * info) @@ -935,6 +952,7 @@ calc_scan_param (pixma_sane_t * ss, pixma_scan_param_t * sp) sp->threshold = 2.55 * OVAL (opt_threshold).w; sp->threshold_curve = OVAL (opt_threshold_curve).w; sp->adf_wait = OVAL (opt_adf_wait).w; + sp->calibrate = ss->calibrate_map[OVAL (opt_calibrate).w]; error = pixma_check_scan_param (ss->s, sp); if (error < 0) @@ -997,6 +1015,8 @@ init_option_descriptors (pixma_sane_t * ss) i++; } + create_calibrate_list (ss); + build_option_descriptors (ss); /* Enable options that are available only in some scanners. */ @@ -1433,8 +1453,8 @@ static void pixma_jpeg_read(pixma_sane_t *ss, SANE_Byte *data, SANE_Int max_length, SANE_Int *length) { - struct jpeg_decompress_struct cinfo = ss->jpeg_cinfo; - pixma_jpeg_src_mgr *src = (pixma_jpeg_src_mgr *)ss->jpeg_cinfo.src; + struct jpeg_decompress_struct *cinfo = &ss->jpeg_cinfo; + pixma_jpeg_src_mgr *src = (pixma_jpeg_src_mgr *)cinfo->src; int l; @@ -1454,7 +1474,7 @@ pixma_jpeg_read(pixma_sane_t *ss, SANE_Byte *data, return; } - if (cinfo.output_scanline >= cinfo.output_height) + if (cinfo->output_scanline >= cinfo->output_height) { *length = 0; return; @@ -1464,7 +1484,7 @@ pixma_jpeg_read(pixma_sane_t *ss, SANE_Byte *data, * only one line at time is supported */ - l = jpeg_read_scanlines(&cinfo, ss->jdst->buffer, 1); + l = jpeg_read_scanlines(cinfo, ss->jdst->buffer, 1); if (l == 0) return; @@ -1472,7 +1492,7 @@ pixma_jpeg_read(pixma_sane_t *ss, SANE_Byte *data, * linebuffer holds width * bytesperpixel */ - (*ss->jdst->put_pixel_rows)(&cinfo, ss->jdst, 1, (char *)src->linebuffer); + (*ss->jdst->put_pixel_rows)(cinfo, ss->jdst, 1, (char *)src->linebuffer); *length = ss->sp.w * ss->sp.channels; /* Convert RGB into grayscale */ @@ -1505,9 +1525,9 @@ pixma_jpeg_read(pixma_sane_t *ss, SANE_Byte *data, b = (b << 1) | 0; else b = (b << 1) | 1; + if ((i % 8) == 0) + *(d++) = b; } - if ((i % 8) == 0) - *(d++) = b; } src->linebuffer_size = *length; @@ -1656,8 +1676,8 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) config.descriptors = NULL; config.values = NULL; - if (sanei_configure_attach(PIXMA_CONFIG_FILE, &config, config_attach_pixma) != - SANE_STATUS_GOOD) + if (sanei_configure_attach(PIXMA_CONFIG_FILE, &config, + config_attach_pixma, NULL) != SANE_STATUS_GOOD) PDBG(pixma_dbg(2, "Could not read pixma configuration file: %s\n", PIXMA_CONFIG_FILE)); @@ -2255,9 +2275,16 @@ type int adf-wait default 0 constraint (0,3600,1) title ADF Waiting Time - desc When set, the scanner waits upto the specified time in seconds for a new document inserted into the automatic document feeder. + desc When set, the scanner waits up to the specified time in seconds for a new document inserted into the automatic document feeder. cap soft_select soft_detect automatic inactive +type string calibrate[30] + constraint @string_list = ss->calibrate_list + title Calibration + desc When to perform scanner calibration. If you choose \"Once\" it will be performed a single time per driver init for single page scans, and for the first page for each ADF scan. + default Once + cap soft_select soft_detect automatic + rem ------------------------------------------- END SANE_Option_Descriptor */ diff --git a/backend/pixma/pixma.h b/backend/pixma/pixma.h index c9026a7..dc07cfa 100644 --- a/backend/pixma/pixma.h +++ b/backend/pixma/pixma.h @@ -17,9 +17,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 . As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. @@ -120,7 +118,7 @@ typedef uint32_t uint32_t; /**@{*/ #define PIXMA_VERSION_MAJOR 0 #define PIXMA_VERSION_MINOR 28 -#define PIXMA_VERSION_BUILD 5 +#define PIXMA_VERSION_BUILD 6 /**@}*/ /** \name Error codes */ @@ -157,8 +155,9 @@ typedef uint32_t uint32_t; #define PIXMA_CAP_NEGATIVE (1 << 10) #define PIXMA_CAP_TPUIR ((1 << 11) | PIXMA_CAP_TPU) #define PIXMA_CAP_ADF_WAIT (1 << 12) -#define PIXMA_CAP_ADF_JPEG (1 << 13) -#define PIXMA_CAP_GT_4096 (1 << 14) /* gamma table has 4096 8-bit values +#define PIXMA_CAP_ADF_JPEG (1 << 13) /* scanner returns image as jpeg from ADF */ +#define PIXMA_CAP_JPEG (1 << 14) /* scanner always returns image as jpeg */ +#define PIXMA_CAP_GT_4096 (1 << 15) /* gamma table has 4096 8-bit values * only generation 1 scanners * usually gamma table has 1024 16-bit values */ @@ -224,7 +223,8 @@ typedef enum pixma_paper_source_t PIXMA_SOURCE_FLATBED, PIXMA_SOURCE_ADF, PIXMA_SOURCE_TPU, - PIXMA_SOURCE_ADFDUP /* duplex */ + PIXMA_SOURCE_ADFDUP, /* duplex */ + PIXMA_SOURCE_NONE } pixma_paper_source_t; /** Scan modes */ @@ -276,6 +276,14 @@ typedef enum pixma_calibration_status_t PIXMA_CALIBRATION_ERROR } pixma_calibration_status_t; +typedef enum pixma_calibrate_option_t +{ + PIXMA_CALIBRATE_ONCE, + PIXMA_CALIBRATE_ALWAYS, + PIXMA_CALIBRATE_NEVER, + PIXMA_CALIBRATE_NUM_OPTS +} pixma_calibrate_option_t; + /** Device status. */ struct pixma_device_status_t { @@ -305,7 +313,7 @@ struct pixma_scan_param_t * 1 = 1 bit B/W lineart (flatbed) * 8 = 8 bit grayscale, * 24 bit color (both flatbed) - * 16 = 16 bit grayscale (TPU, flatbed not implemeted), + * 16 = 16 bit grayscale (TPU, flatbed not implemented), * 48 bit color (TPU, flatbed not implemented) */ unsigned depth; @@ -359,6 +367,9 @@ struct pixma_scan_param_t /** \see #pixma_scan_mode_t */ pixma_scan_mode_t mode; + /** \see #pixma_calibrate_option_t */ + pixma_calibrate_option_t calibrate; + /** The current page # in the same ADF scan session, 0 in non ADF */ unsigned adf_pageid; @@ -510,6 +521,12 @@ int pixma_enable_background (pixma_t *, int enabled); */ int pixma_get_device_status (pixma_t *, pixma_device_status_t * status); +/** Decide whether to run calibration or not. + * Decision takes into account scan_param, source and last_source. + * \return 0x01 for calibration and 0x00 for no calibration + */ +unsigned pixma_calc_calibrate (pixma_t *); + const char *pixma_get_string (pixma_t *, pixma_string_index_t); const pixma_config_t *pixma_get_config (pixma_t *); void pixma_fill_gamma_table (double gamma, uint8_t * table, unsigned n); diff --git a/backend/pixma/pixma_bjnp.c b/backend/pixma/pixma_bjnp.c index 4e83714..63dd56d 100644 --- a/backend/pixma/pixma_bjnp.c +++ b/backend/pixma/pixma_bjnp.c @@ -15,8 +15,8 @@ License for more details. You should have received a copy of the GNU General Public License - along with sane; see the file COPYING. If not, write to the Free - Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with sane; see the file COPYING. + If not, see . As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. @@ -661,8 +661,8 @@ udp_command (const int dev_no, char *command, int cmd_len, char *response, int resp_len) { /* - * send udp command to given device and recieve the response` - * returns: the legth of the response or -1 + * send udp command to given device and receive the response` + * returns: the length of the response or -1 */ int sockfd; struct timeval timeout; @@ -958,7 +958,7 @@ prepare_socket(const char *if_name, const bjnp_sockaddr_t *local_sa, * local_sa: local address to use * broadcast_sa: broadcast address to use, if NULL we use all hosts * dest_sa: (write) where to return destination address of broadcast - * retuns: open socket or -1 + * returns: open socket or -1 */ int socket = -1; @@ -1831,7 +1831,7 @@ bjnp_allocate_device (SANE_String_Const devname, /* Check if found the scanner before, if so we use the best address * but still make sure the scanner is listed only once. * We check for matching addresses as wel as matching mac_addresses as - * an IPv6 host can have multiple adresses */ + * an IPv6 host can have multiple addresses */ if ( strcmp( device[i].mac_address, device[bjnp_no_devices].mac_address ) == 0 ) { @@ -2392,9 +2392,9 @@ sanei_bjnp_set_timeout (SANE_Int devno, SANE_Int timeout) * @param size size of the data * * @return - * - SANE_STATUS_GOOD - on succes + * - SANE_STATUS_GOOD - on success * - SANE_STATUS_EOF - if zero bytes have been read - * - SANE_STATUS_IO_ERROR - if an error occured during the read + * - SANE_STATUS_IO_ERROR - if an error occurred during the read * - SANE_STATUS_INVAL - on every other error * */ @@ -2456,7 +2456,7 @@ sanei_bjnp_read_bulk (SANE_Int dn, SANE_Byte * buffer, size_t * size) if ( device[dn].scanner_data_left < device[dn].blocksize) { /* the scanner will not react at all to a read request, when no more data is available */ - /* we now determine end of data by comparing the payload size to the maximun blocksize */ + /* we now determine end of data by comparing the payload size to the maximum blocksize */ /* this block is shorter than blocksize, so after this block we are done */ device[dn].last_block = 1; @@ -2493,7 +2493,7 @@ sanei_bjnp_read_bulk (SANE_Int dn, SANE_Byte * buffer, size_t * size) recvd = recvd + read_size; } - PDBG (bjnp_dbg (LOG_DEBUG, "bjnp_read_bulk: %s: Returning %ld bytes, backend expexts %ld\n", + PDBG (bjnp_dbg (LOG_DEBUG, "bjnp_read_bulk: %s: Returning %ld bytes, backend expects %ld\n", (recvd == *size)? "OK": "NOTICE",recvd, *size ) ); *size = recvd; if ( *size == 0 ) @@ -2511,8 +2511,8 @@ sanei_bjnp_read_bulk (SANE_Int dn, SANE_Byte * buffer, size_t * size) * @param size size of the data * * @return - * - SANE_STATUS_GOOD - on succes - * - SANE_STATUS_IO_ERROR - if an error occured during the write + * - SANE_STATUS_GOOD - on success + * - SANE_STATUS_IO_ERROR - if an error occurred during the write * - SANE_STATUS_INVAL - on every other error */ @@ -2584,9 +2584,9 @@ sanei_bjnp_write_bulk (SANE_Int dn, const SANE_Byte * buffer, size_t * size) * @param size size of the data * * @return - * - SANE_STATUS_GOOD - on succes + * - SANE_STATUS_GOOD - on success * - SANE_STATUS_EOF - if zero bytes have been read - * - SANE_STATUS_IO_ERROR - if an error occured during the read + * - SANE_STATUS_IO_ERROR - if an error occurred during the read * - SANE_STATUS_INVAL - on every other error * */ diff --git a/backend/pixma/pixma_bjnp.h b/backend/pixma/pixma_bjnp.h index 79e084e..3f4ab53 100644 --- a/backend/pixma/pixma_bjnp.h +++ b/backend/pixma/pixma_bjnp.h @@ -18,8 +18,8 @@ License for more details. You should have received a copy of the GNU General Public License - along with sane; see the file COPYING. If not, write to the Free - Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with sane; see the file COPYING. + If not, see . As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. @@ -151,9 +151,9 @@ extern void sanei_bjnp_set_timeout (SANE_Int devno, SANE_Int timeout); * @param size size of the data * * @return - * - SANE_STATUS_GOOD - on succes + * - SANE_STATUS_GOOD - on success * - SANE_STATUS_EOF - if zero bytes have been read - * - SANE_STATUS_IO_ERROR - if an error occured during the read + * - SANE_STATUS_IO_ERROR - if an error occurred during the read * - SANE_STATUS_INVAL - on every other error * */ @@ -170,8 +170,8 @@ sanei_bjnp_read_bulk (SANE_Int dn, SANE_Byte * buffer, size_t * size); * @param size size of the data * * @return - * - SANE_STATUS_GOOD - on succes - * - SANE_STATUS_IO_ERROR - if an error occured during the write + * - SANE_STATUS_GOOD - on success + * - SANE_STATUS_IO_ERROR - if an error occurred during the write * - SANE_STATUS_INVAL - on every other error */ extern SANE_Status @@ -187,9 +187,9 @@ sanei_bjnp_write_bulk (SANE_Int dn, const SANE_Byte * buffer, size_t * size); * @param size size of the data * * @return - * - SANE_STATUS_GOOD - on succes + * - SANE_STATUS_GOOD - on success * - SANE_STATUS_EOF - if zero bytes have been read - * - SANE_STATUS_IO_ERROR - if an error occured during the read + * - SANE_STATUS_IO_ERROR - if an error occurred during the read * - SANE_STATUS_INVAL - on every other error * */ diff --git a/backend/pixma/pixma_bjnp_private.h b/backend/pixma/pixma_bjnp_private.h index 19ba496..c759fc7 100644 --- a/backend/pixma/pixma_bjnp_private.h +++ b/backend/pixma/pixma_bjnp_private.h @@ -26,8 +26,8 @@ License for more details. You should have received a copy of the GNU General Public License - along with sane; see the file COPYING. If not, write to the Free - Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with sane; see the file COPYING. + If not, see . As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. @@ -80,7 +80,7 @@ /* timers */ #define BJNP_BROADCAST_INTERVAL 10 /* ms between broadcasts */ #define BJNP_BC_RESPONSE_TIMEOUT 500 /* waiting time for broadc. responses */ -#define BJNP_TIMEOUT_DEFAULT 10000 /* minimum tiemout value for network operations */ +#define BJNP_TIMEOUT_DEFAULT 10000 /* minimum timeout value for network operations */ #define BJNP_TIMEOUT_TCP_CONNECT 2000 /* timeout for tcp connect attempts in ms */ #define BJNP_USLEEP_MS 1000 /* sleep for 1 msec */ #define BJNP_TCP_CONNECT_INTERVAL 100 /* TCP retry interval in ms */ @@ -187,7 +187,7 @@ struct __attribute__ ((__packed__)) BJNP_command struct __attribute__ ((__packed__)) DISCOVER_RESPONSE { - struct BJNP_command response; /* reponse header */ + struct BJNP_command response; /* response header */ char unknown1[4]; /* 00 01 08 00 */ char mac_len; /* length of mac address */ char addr_len; /* length of address field */ @@ -354,7 +354,7 @@ typedef struct device_s /* sockets */ - int tcp_socket; /* open tcp socket for communcation to scannner */ + int tcp_socket; /* open tcp socket for communication to scannner */ int16_t serial; /* sequence number of command */ /* communication state */ diff --git a/backend/pixma/pixma_common.c b/backend/pixma/pixma_common.c index 436311a..6bce4bc 100644 --- a/backend/pixma/pixma_common.c +++ b/backend/pixma/pixma_common.c @@ -17,9 +17,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 . As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. @@ -56,8 +54,6 @@ #if defined(HAVE_LIBXML2) # include -#else -# error "The pixma backend requires libxml2" #endif #include "pixma_rename.h" @@ -682,7 +678,7 @@ pixma_cmd_transaction (pixma_t * s, const void *cmd, unsigned cmdlen, going back to the home position after the last scan session has been cancelled, you won't get the response before it arrives home. This takes about 5 seconds. If the last session was succeeded, the scanner will - immediatly answer with PIXMA_STATUS_BUSY. + immediately answer with PIXMA_STATUS_BUSY. Is 8 seconds timeout enough? This affects ALL commands that use pixma_cmd_transaction(). Default value set in pixma_open(). */ @@ -814,6 +810,7 @@ pixma_open (unsigned devnr, pixma_t ** handle) strncpy (s->id, pixma_get_device_id (devnr), sizeof (s->id) - 1); s->ops = s->cfg->ops; s->scanning = 0; + s->last_source = PIXMA_SOURCE_NONE; error = s->ops->open (s); if (error < 0) goto rollback; @@ -967,6 +964,8 @@ pixma_read_image (pixma_t * s, void *buf, unsigned len) if (result == 0) { /* end of image? */ s->ops->finish_scan (s); + /* set last source after successful scan */ + s->last_source = s->param->source; if ((s->cur_image_size != s->param->image_size) && !s->param->mode_jpeg) { pixma_dbg (1, "WARNING:image size mismatches\n"); @@ -1140,6 +1139,9 @@ pixma_check_scan_param (pixma_t * s, pixma_scan_param_t * sp) sp->source)); } break; + case PIXMA_SOURCE_NONE: + /* this source can not be selected */ + break; } if (sp->depth == 0) @@ -1241,6 +1243,22 @@ pixma_get_device_status (pixma_t * s, pixma_device_status_t * status) return s->ops->get_status (s, status); } +unsigned +pixma_calc_calibrate (pixma_t * p) +{ + pixma_scan_param_t * sp = p->param; + if (sp->calibrate == PIXMA_CALIBRATE_ALWAYS) + return 0x01; + if (sp->calibrate == PIXMA_CALIBRATE_NEVER) + return 0x00; + /* sp->calibrate == PIXMA_CALIBRATE_ONCE */ + if (sp->source == PIXMA_SOURCE_ADF || sp->source == PIXMA_SOURCE_ADFDUP) + return sp->adf_pageid == 0 ? 0x01 : 0x00; + /* sp->source == PIXMA_SOURCE_FLATBED | TPU */ + return sp->source == p->last_source ? 0x00 : 0x01; +} + +#if defined(HAVE_LIBXML2) static const char * format_xml_response(const char *resp_details) { @@ -1334,3 +1352,4 @@ clean: xmlFreeDoc(doc); return status; } +#endif diff --git a/backend/pixma/pixma_common.h b/backend/pixma/pixma_common.h index 3e4e5bd..5b393dc 100644 --- a/backend/pixma/pixma_common.h +++ b/backend/pixma/pixma_common.h @@ -16,9 +16,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 . As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. @@ -119,6 +117,7 @@ struct pixma_t uint32_t events; void *subdriver; /* can be used by model driver. */ int rec_tmo; /* receive timeout [s] */ + pixma_paper_source_t last_source; /* used for calibrate=once */ /* private */ uint64_t cur_image_size; @@ -162,7 +161,7 @@ struct pixma_scan_ops_t void (*finish_scan) (pixma_t *); /** [Optional] Wait for a user's event, e.g. button event. \a timeout is - * in milliseconds. If an event occured before it's timed out, flags in + * in milliseconds. If an event occurred before it's timed out, flags in * \a s->events should be set accordingly. * \see PIXMA_EV_* */ void (*wait_event) (pixma_t * s, int timeout); @@ -176,7 +175,7 @@ struct pixma_scan_ops_t }; -/** \name Funtions for read and write big-endian integer values */ +/** \name Functions for read and write big-endian integer values */ /**@{*/ void pixma_set_be16 (uint16_t x, uint8_t * buf); void pixma_set_be32 (uint32_t x, uint8_t * buf); @@ -205,7 +204,9 @@ uint8_t *pixma_newcmd (pixma_cmdbuf_t *, unsigned cmd, int pixma_exec (pixma_t *, pixma_cmdbuf_t *); int pixma_exec_short_cmd (pixma_t *, pixma_cmdbuf_t *, unsigned cmd); int pixma_map_status_errno (unsigned status); +#if defined(HAVE_LIBXML2) int pixma_parse_xml_response(const char *xml_message); +#endif /**@}*/ #define pixma_fill_checksum(start, end) do { \ diff --git a/backend/pixma/pixma_imageclass.c b/backend/pixma/pixma_imageclass.c index be483b2..ae06180 100644 --- a/backend/pixma/pixma_imageclass.c +++ b/backend/pixma/pixma_imageclass.c @@ -17,9 +17,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 . As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. @@ -461,7 +459,7 @@ step1 (pixma_t * s) iclass_t *mf = (iclass_t *) s->subdriver; /* don't wait full timeout for 1st command */ - rec_tmo = s->rec_tmo; /* save globel timeout */ + rec_tmo = s->rec_tmo; /* save global timeout */ s->rec_tmo = 2; /* set timeout to 2 seconds */ error = query_status (s); s->rec_tmo = rec_tmo; /* restore global timeout */ @@ -622,6 +620,8 @@ iclass_check_param (pixma_t * s, pixma_scan_param_t * sp) if ((s->cfg->cap & PIXMA_CAP_ADF) && sp->source == PIXMA_SOURCE_FLATBED) sp->h = MIN (sp->h, 877 * sp->xdpi / 75); + sp->mode_jpeg = (s->cfg->cap & PIXMA_CAP_JPEG); + /* PDBG (pixma_dbg (4, "*iclass_check_param***** Finally: channels=%u, depth=%u, x=%u, y=%u, w=%u, line_size=%" PRIu64 " , h=%u*****\n", sp->channels, sp->depth, sp->x, sp->y, sp->w, sp->line_size, sp->h)); */ @@ -979,7 +979,7 @@ const pixma_config_t pixma_iclass_devices[] = { DEV ("Canon i-SENSYS MF110/910 Series", "MF110", MF110_PID, 600, 0, 640, 1050, 0), DEV ("Canon i-SENSYS MF520 Series", "MF520", MF520_PID, 600, 0, 640, 1050, PIXMA_CAP_ADFDUP), DEV ("Canon i-SENSYS MF420 Series", "MF420", MF420_PID, 600, 0, 640, 1050, PIXMA_CAP_ADFDUP), - DEV ("Canon i-SENSYS MF260 Series", "MF260", MF260_PID, 600, 0, 640, 1050, PIXMA_CAP_ADFDUP), + DEV ("Canon i-SENSYS MF260 Series", "MF260", MF260_PID, 600, 0, 640, 1050, PIXMA_CAP_JPEG | PIXMA_CAP_ADFDUP), DEV ("Canon i-SENSYS MF740 Series", "MF740", MF740_PID, 600, 0, 640, 1050, PIXMA_CAP_ADFDUP), DEV ("Canon i-SENSYS MF741C/743C", "MF741C/743C", MF743_PID, 600, 300, 640, 1050, PIXMA_CAP_ADFDUP), /* ADFDUP restricted to 300dpi */ DEV ("Canon i-SENSYS MF640 Series", "MF642C/643C/644C", MF640_PID, 600, 0, 640, 1050, PIXMA_CAP_ADFDUP), diff --git a/backend/pixma/pixma_io.h b/backend/pixma/pixma_io.h index 715bab5..71202e4 100644 --- a/backend/pixma/pixma_io.h +++ b/backend/pixma/pixma_io.h @@ -15,9 +15,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 . As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. @@ -128,7 +126,7 @@ int pixma_reset_device (pixma_io_t *); /** Write data to the device. This function may not be interrupted by signals. * It will return iff * - \a len bytes have been successfully written or - * - an error (inclusive timeout) occured. + * - an error (inclusive timeout) occurred. * . * \note Calling pixma_write(io, buf, n1) and pixma(io, buf+n1, n2) may * not be the same as pixma_write(io, buf, n1+n2) if n1 is not @@ -146,7 +144,7 @@ int pixma_write (pixma_io_t *, const void *cmd, unsigned len); * It will return iff * - \a size bytes have been successfully read, * - a short packet has been read or - * - an error (inclusive timeout) occured. + * - an error (inclusive timeout) occurred. * . * \param[out] buf * \param[in] size of the buffer diff --git a/backend/pixma/pixma_io_sanei.c b/backend/pixma/pixma_io_sanei.c index c7b7a29..ae780b3 100644 --- a/backend/pixma/pixma_io_sanei.c +++ b/backend/pixma/pixma_io_sanei.c @@ -17,9 +17,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 . As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. diff --git a/backend/pixma/pixma_mp150.c b/backend/pixma/pixma_mp150.c index b438c1b..f3d5934 100644 --- a/backend/pixma/pixma_mp150.c +++ b/backend/pixma/pixma_mp150.c @@ -17,9 +17,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 . As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. @@ -299,6 +297,25 @@ #define TS3300_PID 0x18a2 #define E3300_PID 0x18a3 +/* 2020 new devices (untested) */ +#define G7080_PID 0x1864 +#define GM4080_PID 0x186A +#define TS3400_PID 0x18B7 +#define E3400_PID 0x18B8 +#define TR7000_PID 0x18B9 +#define G2020_PID 0x18BD +#define G3060_PID 0x18C3 +#define G2060_PID 0x18C1 +#define G3020_PID 0x18BF +#define TS7430_PID 0x18B2 +#define XK90_PID 0x18B6 +#define TS8430_PID 0x18B5 +#define TR7600_PID 0x18AA +#define TR8600_PID 0x18AD +#define TR8630_PID 0x18AF +#define TS6400_PID 0x18D3 +#define TS7400_PID 0x18D7 + /* Generation 4 XML messages that encapsulates the Pixma protocol messages */ #define XML_START_1 \ "\ @@ -322,6 +339,10 @@ 00000001\ " +#if !defined(HAVE_LIBXML2) +#define XML_OK "OK" +#endif + enum mp150_state_t { state_idle, @@ -459,7 +480,11 @@ send_xml_dialog (pixma_t * s, const char * xml_message) PDBG (pixma_dbg (10, "XML message sent to scanner:\n%s\n", xml_message)); PDBG (pixma_dbg (10, "XML response back from scanner:\n%s\n", mp->cb.buf)); +#if defined(HAVE_LIBXML2) return pixma_parse_xml_response((const char*)mp->cb.buf) == PIXMA_STATUS_OK; +#else + return (strcasestr ((const char *) mp->cb.buf, XML_OK) != NULL); +#endif } static int @@ -614,7 +639,7 @@ static unsigned calc_raw_width (const mp150_t * mp, const pixma_scan_param_t * param) { unsigned raw_width; - /* NOTE: Actually, we can send arbitary width to MP150. Lines returned + /* NOTE: Actually, we can send arbitrary width to MP150. Lines returned are always padded to multiple of 4 or 12 pixels. Is this valid for other models, too? */ if (mp->generation >= 2) @@ -705,10 +730,7 @@ send_scan_param (pixma_t * s) { data[0x03] = 0x01; } - else - { - data[0x05] = 0x01; /* This one also seen at 0. Don't know yet what's used for */ - } + data[0x05] = pixma_calc_calibrate (s); pixma_set_be16 (xdpi | 0x8000, data + 0x08); pixma_set_be16 (ydpi | 0x8000, data + 0x0a); pixma_set_be32 (x - xs, data + 0x0c); @@ -909,6 +931,7 @@ handle_interrupt (pixma_t * s, int timeout) || s->cfg->pid == MG5400_PID || s->cfg->pid == MG6200_PID || s->cfg->pid == MG6300_PID + || s->cfg->pid == MX340_PID || s->cfg->pid == MX520_PID || s->cfg->pid == MX720_PID || s->cfg->pid == MX920_PID @@ -938,8 +961,11 @@ handle_interrupt (pixma_t * s, int timeout) /* some scanners provide additional information: * document type in buf[6] 01=Document; 02=Photo; 03=Auto Scan * ADF status in buf[8] 01 = ADF empty; 02 = ADF filled - * ADF orientation in buf[16] 01=Portrait; 02=Landscape */ - if (s->cfg->pid == TR4500_PID) + * ADF orientation in buf[16] 01=Portrait; 02=Landscape + * + * ToDo: maybe this if isn't needed + */ + if (s->cfg->pid == TR4500_PID || s->cfg->pid == MX340_PID) { s->events |= (buf[6] & 0x0f) << 12; s->events |= (buf[8] & 0x0f) << 20; @@ -1029,7 +1055,7 @@ reorder_pixels (uint8_t * linebuf, uint8_t * sptr, unsigned c, unsigned n, memcpy (sptr, linebuf, line_size); } -/* the scanned image must be shrinked by factor "scale" +/* the scanned image must be shrunk by factor "scale" * the image can be formatted as rgb (c=3) or gray (c=1) * we need to crop the left side (xs) * we ignore more pixels inside scanned line (wx), behind needed line (w) @@ -1069,7 +1095,7 @@ shrink_image (uint8_t * dptr, uint8_t * sptr, unsigned xs, unsigned w, pixel = 0; /* sum shrink pixels */ - for (unsigned m = 0; m < scale; m++) /* get pixels from shrinked lines */ + for (unsigned m = 0; m < scale; m++) /* get pixels from shrunk lines */ { for (unsigned n = 0; n < scale; n++) /* get pixels from same line */ { @@ -1080,7 +1106,7 @@ shrink_image (uint8_t * dptr, uint8_t * sptr, unsigned xs, unsigned w, #endif } - /* jump over shrinked data */ + /* jump over shrunk data */ src += c * scale; /* next pixel */ dst += c; @@ -1715,7 +1741,7 @@ const pixma_config_t pixma_mp150_devices[] = { DEVICE ("Canon PIXMA MP190", "MP190", MP190_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), /* PIXMA 2009 vintage */ - DEVICE ("Canon PIXMA MX320", "MX320", MX320_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), + DEVICE ("Canon PIXMA MX320", "MX320", MX320_PID, 0, 1200, 0, 600, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MX330", "MX330", MX330_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MX860", "MX860", MX860_PID, 0, 2400, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP), /* width and height adjusted to flatbed size 21.8 x 30.2 cm^2 respective @@ -1805,7 +1831,7 @@ const pixma_config_t pixma_mp150_devices[] = { DEVICE ("Canon PIXMA E460 Series", "E460", E460_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), /* Latest devices (2015) Generation 5 CIS */ - DEVICE ("Canon PIXMA MX490 Series", "MX490", MX490_PID, 0, 600, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), + DEVICE ("Canon PIXMA MX490 Series", "MX490", MX490_PID, 0, 600, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF | PIXMA_CAP_ADF_JPEG), DEVICE ("Canon PIXMA E480 Series", "E480", E480_PID, 0, 600, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MG3600 Series", "MG3600", MG3600_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG7700 Series", "MG7700", MG7700_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), @@ -1882,6 +1908,23 @@ const pixma_config_t pixma_mp150_devices[] = { DEVICE ("Canon PIXMA TS6330 Series", "TS6330", TS6330_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS3300 Series", "TS3300", TS3300_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA E3300 Series", "E3300", E3300_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS3400 Series", "TS3400", TS3400_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA E3400 Series", "E3400", E3400_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), + DEVICE ("Canon PIXMA TR7000 Series", "TR7000", TR7000_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), + DEVICE ("Canon PIXMA G2020", "G2020", G2020_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA G3060", "G3060", G3060_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA G2060", "G2060", G2060_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA G3020", "G3020", G3020_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS7430 Series", "TS7430", TS7430_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXUS XK90 Series", "XK90", XK90_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS8430 Series", "TS8430", TS8430_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TR7600 Series", "TR7600", TR7600_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), + DEVICE ("Canon PIXMA TR8600 Series", "TR8600", TR8600_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), + DEVICE ("Canon PIXMA TR8630 Series", "TR8630", TR8630_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), + DEVICE ("Canon PIXMA TS6400 Series", "TS6400", TS6400_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS7400 Series", "TS7400", TS7400_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA G7080 Series", "G7080", G7080_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA GM4080", "GM4080", GM4080_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), END_OF_DEVICE_LIST }; diff --git a/backend/pixma/pixma_mp730.c b/backend/pixma/pixma_mp730.c index fcc9ae8..3a436d7 100644 --- a/backend/pixma/pixma_mp730.c +++ b/backend/pixma/pixma_mp730.c @@ -17,9 +17,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 . As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. diff --git a/backend/pixma/pixma_mp750.c b/backend/pixma/pixma_mp750.c index cc1c3ad..80ccfd2 100644 --- a/backend/pixma/pixma_mp750.c +++ b/backend/pixma/pixma_mp750.c @@ -16,9 +16,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 . As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. @@ -827,7 +825,7 @@ mp750_fill_buffer (pixma_t * s, pixma_imagebuf_t * ib) n = mp->rawimg_left / 3; /* n = number of pixels in the buffer? */ - /* Color to Grayscale converion for CCD sensor */ + /* Color to Grayscale conversion for CCD sensor */ if (is_ccd_grayscale (s)) { shift_rgb (mp->rawimg, n, shift[0], shift[1], shift[2], mp->stripe_shift, mp->line_size, mp->imgcol + mp->imgbuf_ofs); diff --git a/backend/pixma/pixma_mp800.c b/backend/pixma/pixma_mp800.c index 905c246..fba7553 100644 --- a/backend/pixma/pixma_mp800.c +++ b/backend/pixma/pixma_mp800.c @@ -17,9 +17,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 . As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. @@ -152,6 +150,10 @@ 00000001\ " +#if !defined(HAVE_LIBXML2) +#define XML_OK "OK" +#endif + enum mp810_state_t { state_idle, @@ -291,7 +293,11 @@ static int send_xml_dialog (pixma_t * s, const char * xml_message) PDBG(pixma_dbg (10, "XML message sent to scanner:\n%s\n", xml_message)); PDBG(pixma_dbg (10, "XML response back from scanner:\n%s\n", mp->cb.buf)); +#if defined(HAVE_LIBXML2) return pixma_parse_xml_response((const char*)mp->cb.buf) == PIXMA_STATUS_OK; +#else + return (strcasestr ((const char *) mp->cb.buf, XML_OK) != NULL); +#endif } static void new_cmd_tpu_msg (pixma_t *s, pixma_cmdbuf_t * cb, uint16_t cmd) @@ -401,6 +407,10 @@ static int select_source (pixma_t * s) data[0] = 4; data[1] = 2; break; + + case PIXMA_SOURCE_NONE: + /* this source can not be selected */ + break; } return pixma_exec (s, &mp->cb); } @@ -483,7 +493,7 @@ static unsigned calc_raw_width (const mp810_t * mp, const pixma_scan_param_t * param) { unsigned raw_width; - /* NOTE: Actually, we can send arbitary width to MP810. Lines returned + /* NOTE: Actually, we can send arbitrary width to MP810. Lines returned are always padded to multiple of 4 or 12 pixels. Is this valid for other models, too? */ if (mp->generation >= 2) @@ -929,8 +939,7 @@ static int send_scan_param (pixma_t * s) data[0x02] = 0x03; data[0x03] = 0x03; } - if (s->cfg->pid != MG8200_PID) - data[0x05] = 0x01; /* This one also seen at 0. Don't know yet what's used for */ + data[0x05] = pixma_calc_calibrate (s); /* the scanner controls the scan */ /* no software control needed */ pixma_set_be16 (s->param->xdpi | 0x8000, data + 0x08); diff --git a/backend/pixma/pixma_rename.h b/backend/pixma/pixma_rename.h index ad3d960..7feb962 100644 --- a/backend/pixma/pixma_rename.h +++ b/backend/pixma/pixma_rename.h @@ -15,9 +15,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 . As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. -- cgit v1.2.3