From 58912f68c2489bcee787599837447e0d64dfd61a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 24 May 2017 21:03:56 +0200 Subject: New upstream version 1.0.27 --- backend/pixma_mp150.c | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) (limited to 'backend/pixma_mp150.c') diff --git a/backend/pixma_mp150.c b/backend/pixma_mp150.c index 4f8b232..dca0965 100644 --- a/backend/pixma_mp150.c +++ b/backend/pixma_mp150.c @@ -1,6 +1,6 @@ /* SANE - Scanner Access Now Easy. - Copyright (C) 2011-2015 Rolf Bensch + Copyright (C) 2011-2016 Rolf Bensch Copyright (C) 2007-2009 Nicolas Martin, Copyright (C) 2006-2007 Wittawat Yamwong @@ -228,7 +228,19 @@ #define MX490_PID 0x1787 #define E480_PID 0x1789 #define MG3600_PID 0x178a - +#define MG7700_PID 0x178b +#define MG6900_PID 0x178c +#define MG6800_PID 0x178d +#define MG5700_PID 0x178e + +/* 2016 new devices (untested) */ +#define TS9000_PID 0x179f +#define TS8000_PID 0x1800 +#define TS6000_PID 0x1801 +#define TS5000_PID 0x1802 +#define MG3000_PID 0x180b +#define E470_PID 0x180c +#define G3000_PID 0x181d /* Generation 4 XML messages that encapsulates the Pixma protocol messages */ #define XML_START_1 \ @@ -824,6 +836,7 @@ query_status (pixma_t * s) return error; } +#if 0 static int send_time (pixma_t * s) { @@ -843,6 +856,7 @@ send_time (pixma_t * s) PDBG (pixma_dbg (3, "Sending time: '%s'\n", (char *) data)); return pixma_exec (s, &mp->cb); } +#endif /* TODO: Simplify this function. Read the whole data packet in one shot. */ static int @@ -945,11 +959,13 @@ handle_interrupt (pixma_t * s, int timeout) * tt: target * rr: scan resolution * poll event with 'scanimage -A' */ - if (s->cfg->pid == MG6200_PID + if (s->cfg->pid == MG5400_PID + || s->cfg->pid == MG6200_PID || s->cfg->pid == MG6300_PID || s->cfg->pid == MX520_PID || s->cfg->pid == MX720_PID - || s->cfg->pid == MX920_PID) + || s->cfg->pid == MX920_PID + || s->cfg->pid == MB5000_PID) /* button no. in buf[7] * size in buf[10] 01=A4; 02=Letter; 08=10x15; 09=13x18; 0b=auto * format in buf[11] 01=JPEG; 02=TIFF; 03=PDF; 04=Kompakt-PDF @@ -968,7 +984,10 @@ handle_interrupt (pixma_t * s, int timeout) { /* More than one event can be reported at the same time. */ if (buf[3] & 1) + /* FIXME: This function makes trouble with a lot of scanners send_time (s); + */ + PDBG (pixma_dbg (1, "WARNING:send_time() disabled!\n")); if (buf[9] & 2) query_status (s); if (buf[0] & 2) @@ -1150,13 +1169,17 @@ post_process_image_data (pixma_t * s, pixma_imagebuf_t * ib) && s->cfg->pid != MX920_PID && s->cfg->pid != MG3100_PID && s->cfg->pid != MG3500_PID + && s->cfg->pid != MG3600_PID && s->cfg->pid != MG2100_PID && s->cfg->pid != MG5300_PID + && s->cfg->pid != MG5400_PID && s->cfg->pid != MG5500_PID && s->cfg->pid != MG6300_PID && s->cfg->pid != MG6400_PID && s->cfg->pid != MG7100_PID - && s->cfg->pid != MG7500_PID) + && s->cfg->pid != MG7500_PID + && s->cfg->pid != MG7700_PID + && s->cfg->pid != MB5000_PID) reorder_pixels (mp->linebuf, sptr, c, n, m, s->param->wx, line_size); /* Crop line to selected borders */ @@ -1828,6 +1851,19 @@ const pixma_config_t pixma_mp150_devices[] = { DEVICE ("Canon PIXMA MX490 Series", "MX490", MX490_PID, 600, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA E480 Series", "E480", E480_PID, 600, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MG3600 Series", "MG3600", MG3600_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA MG7700 Series", "MG7700", MG7700_PID, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA MG6900 Series", "MG6900", MG6900_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA MG6800 Series", "MG6800", MG6800_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA MG5700 Series", "MG5700", MG5700_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + + /* Latest devices (2016) Generation 4 CIS */ + DEVICE ("Canon PIXMA TS9000 Series", "TS9000", TS9000_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS8000 Series", "TS8000", TS8000_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS6000 Series", "TS6000", TS6000_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS5000 Series", "TS5000", TS5000_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA MG3000 Series", "MG3000", MG3000_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA E470 Series", "E470", E470_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA G4000 Series", "G3000", G3000_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), END_OF_DEVICE_LIST }; -- cgit v1.2.3 From 1687222e1b9e74c89cafbb5910e72d8ec7bfd40f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 31 Jul 2019 16:59:49 +0200 Subject: New upstream version 1.0.28 --- backend/pixma_mp150.c | 314 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 229 insertions(+), 85 deletions(-) (limited to 'backend/pixma_mp150.c') diff --git a/backend/pixma_mp150.c b/backend/pixma_mp150.c index dca0965..5f0a4ac 100644 --- a/backend/pixma_mp150.c +++ b/backend/pixma_mp150.c @@ -1,6 +1,6 @@ /* SANE - Scanner Access Now Easy. - Copyright (C) 2011-2016 Rolf Bensch + Copyright (C) 2011-2019 Rolf Bensch Copyright (C) 2007-2009 Nicolas Martin, Copyright (C) 2006-2007 Wittawat Yamwong @@ -69,7 +69,7 @@ if ((error = (x)) < 0) \ return error; \ } while(0) - + #define WAIT_INTERRUPT(x) do { \ error = handle_interrupt (s, x); \ if (s->cancel) \ @@ -168,6 +168,7 @@ #define MX420_PID 0x174f #define MX880_PID 0x1750 +/* Generation 5 */ /* 2011 new devices (untested) */ #define MG2100_PID 0x1751 #define MG3100_PID 0x1752 @@ -234,13 +235,60 @@ #define MG5700_PID 0x178e /* 2016 new devices (untested) */ +#define MB2700_PID 0x1792 +#define MB2100_PID 0x1793 +#define G3000_PID 0x1794 +#define G2000_PID 0x1795 #define TS9000_PID 0x179f #define TS8000_PID 0x1800 #define TS6000_PID 0x1801 #define TS5000_PID 0x1802 #define MG3000_PID 0x180b #define E470_PID 0x180c -#define G3000_PID 0x181d +#define E410_PID 0x181e + +/* 2017 new devices (untested) */ +#define G4000_PID 0x181d +#define TS6100_PID 0x1822 +#define TS5100_PID 0x1825 +#define TS3100_PID 0x1827 +#define E3100_PID 0x1828 + +/* 2018 new devices (untested) */ +#define MB5400_PID 0x178f +#define MB5100_PID 0x1790 +#define TS9100_PID 0x1820 +#define TR8500_PID 0x1823 +#define TR7500_PID 0x1824 +#define TS9500_PID 0x185c +#define LIDE400_PID 0x1912 /* tested */ +#define LIDE300_PID 0x1913 /* tested */ + +/* 2019 new devices (untested) */ +#define TS8100_PID 0x1821 +#define G3010_PID 0x183b +#define G4010_PID 0x183d +#define TS9180_PID 0x183e +#define TS8180_PID 0x183f +#define TS6180_PID 0x1840 +#define TR8580_PID 0x1841 +#define TS8130_PID 0x1842 +#define TS6130_PID 0x1843 +#define TR8530_PID 0x1844 +#define TR7530_PID 0x1845 +#define XK50_PID 0x1846 +#define XK70_PID 0x1847 +#define TR4500_PID 0x1854 +#define E4200_PID 0x1855 +#define TS6200_PID 0x1856 +#define TS6280_PID 0x1857 +#define TS6230_PID 0x1858 +#define TS8200_PID 0x1859 +#define TS8280_PID 0x185a +#define TS8230_PID 0x185b +#define TS9580_PID 0x185d +#define TR9530_PID 0x185e +#define XK80_PID 0x1873 /* Generation 4 XML messages that encapsulates the Pixma protocol messages */ #define XML_START_1 \ @@ -387,6 +435,12 @@ is_scanning_from_adfdup (pixma_t * s) return (s->param->source == PIXMA_SOURCE_ADFDUP); } +static int +is_scanning_jpeg (pixma_t *s) +{ + return s->param->mode_jpeg; +} + static int is_scanning_from_tpu (pixma_t * s) { @@ -441,7 +495,7 @@ static int send_cmd_start_calibrate_ccd_3 (pixma_t * s) { mp150_t *mp = (mp150_t *) s->subdriver; - + pixma_newcmd (&mp->cb, cmd_start_calibrate_ccd_3, 0, 0); mp->cb.buf[3] = 0x01; return pixma_exec (s, &mp->cb); @@ -469,7 +523,7 @@ static int has_paper (pixma_t * s) { mp150_t *mp = (mp150_t *) s->subdriver; - + if (is_scanning_from_adfdup (s)) return (mp->current_status[1] == 0 || mp->current_status[2] == 0); else @@ -512,19 +566,19 @@ select_source (pixma_t * s) data[0] = 1; data[1] = 1; break; - + case PIXMA_SOURCE_ADF: data[0] = 2; data[5] = 1; data[6] = 1; break; - + case PIXMA_SOURCE_ADFDUP: data[0] = 2; data[5] = 3; data[6] = 3; break; - + case PIXMA_SOURCE_TPU: data[0] = 4; data[1] = 2; @@ -656,7 +710,7 @@ get_cis_ccd_line_size (pixma_t * s) return ((s->param->wx ? s->param->line_size / s->param->w * s->param->wx : s->param->line_size) * ((is_ccd_grayscale (s) || is_ccd_lineart (s)) ? 3 : 1)); } - + static unsigned calc_shifting (pixma_t * s) { @@ -683,7 +737,7 @@ calc_shifting (pixma_t * s) { mp->color_shift = s->param->ydpi / ((s->param->ydpi < 1200) ? 150 : 75); - if (is_scanning_from_tpu (s)) + if (is_scanning_from_tpu (s)) mp->color_shift = s->param->ydpi / 75; /* If you're trying to decipher this color-shifting code, @@ -714,7 +768,7 @@ send_scan_param (pixma_t * s) mp150_t *mp = (mp150_t *) s->subdriver; uint8_t *data; unsigned raw_width = calc_raw_width (mp, s->param); - unsigned h = MIN (s->param->h + calc_shifting (s), + unsigned h = MIN (s->param->h + calc_shifting (s), s->cfg->height * s->param->ydpi / 75); /* TPU scan does not support lineart */ @@ -762,7 +816,14 @@ send_scan_param (pixma_t * s) data[0x02] = 0x03; data[0x03] = 0x03; } - data[0x05] = 0x01; /* This one also seen at 0. Don't know yet what's used for */ + if (is_scanning_jpeg (s)) + { + data[0x03] = 0x01; + } + else + { + data[0x05] = 0x01; /* This one also seen at 0. Don't know yet what's used for */ + } pixma_set_be16 (s->param->xdpi | 0x8000, data + 0x08); pixma_set_be16 (s->param->ydpi | 0x8000, data + 0x0a); /*PDBG (pixma_dbg (4, "*send_scan_param gen. 3+ ***** Setting: xdpi=%hi ydpi=%hi x=%i y=%i w=%i ***** \n", @@ -772,7 +833,7 @@ send_scan_param (pixma_t * s) pixma_set_be32 (raw_width, data + 0x14); pixma_set_be32 (h, data + 0x18); data[0x1c] = ((s->param->channels != 1) || is_ccd_grayscale (s) || is_ccd_lineart (s)) ? 0x08 : 0x04; - + #ifdef DEBUG_TPU_48 data[0x1d] = 24; #else @@ -783,7 +844,14 @@ send_scan_param (pixma_t * s) data[0x1f] = 0x01; /* This one also seen at 0. Don't know yet what's used for */ data[0x20] = 0xff; - data[0x21] = 0x81; + if (is_scanning_jpeg (s)) + { + data[0x21] = 0x83; + } + else + { + data[0x21] = 0x81; + } data[0x23] = 0x02; data[0x24] = 0x01; @@ -882,6 +950,7 @@ read_image_block (pixma_t * s, uint8_t * header, uint8_t * data) return datalen; memcpy (header, mp->cb.buf, hlen); + if (datalen >= hlen) { datalen -= hlen; @@ -959,12 +1028,14 @@ handle_interrupt (pixma_t * s, int timeout) * tt: target * rr: scan resolution * poll event with 'scanimage -A' */ - if (s->cfg->pid == MG5400_PID + if (s->cfg->pid == MG5300_PID + || s->cfg->pid == MG5400_PID || s->cfg->pid == MG6200_PID || s->cfg->pid == MG6300_PID || s->cfg->pid == MX520_PID || s->cfg->pid == MX720_PID || s->cfg->pid == MX920_PID + || s->cfg->pid == MB2300_PID || s->cfg->pid == MB5000_PID) /* button no. in buf[7] * size in buf[10] 01=A4; 02=Letter; 08=10x15; 09=13x18; 0b=auto @@ -977,6 +1048,15 @@ handle_interrupt (pixma_t * s, int timeout) if (buf[7] & 2) s->events = PIXMA_EV_BUTTON2 | buf[11] | buf[10]<<8 | buf[12]<<16; /* b/w scan */ } + else if (s->cfg->pid == LIDE300_PID + || s->cfg->pid == LIDE400_PID) + /* unknown value in buf[4] + * target in buf[0x13] + * always set button-1 */ + { + if (buf[0x13]) + s->events = PIXMA_EV_BUTTON1 | buf[0x13]; + } else /* button no. in buf[0] * original in buf[0] @@ -1037,8 +1117,8 @@ wait_until_ready (pixma_t * s) WAIT_INTERRUPT (1000); if (mp->generation >= 3) RET_IF_ERR (query_status_3 (s)); - else if (s->cfg->pid == MP600_PID || - s->cfg->pid == MP600R_PID || + else if (s->cfg->pid == MP600_PID || + s->cfg->pid == MP600R_PID || s->cfg->pid == MP800R_PID) RET_IF_ERR (query_status (s)); if (--tmo == 0) @@ -1052,8 +1132,8 @@ wait_until_ready (pixma_t * s) } static uint8_t * -shift_colors (uint8_t * dptr, uint8_t * sptr, - unsigned w, unsigned dpi, unsigned pid, unsigned c, +shift_colors (uint8_t * dptr, uint8_t * sptr, + unsigned w, unsigned dpi, unsigned pid, unsigned c, int * colshft, unsigned strshft) { unsigned i, sr, sg, sb, st; @@ -1064,7 +1144,7 @@ shift_colors (uint8_t * dptr, uint8_t * sptr, { /* stripes shift for MP800, MP800R at 2400 dpi */ st = (i % 2 == 0) ? strshft : 0; - + *sptr++ = *(dptr++ + sr + st); if (c == 6) *sptr++ = *(dptr++ + sr + st); *sptr++ = *(dptr++ + sg + st); @@ -1076,7 +1156,7 @@ shift_colors (uint8_t * dptr, uint8_t * sptr, } static void -reorder_pixels (uint8_t * linebuf, uint8_t * sptr, unsigned c, unsigned n, +reorder_pixels (uint8_t * linebuf, uint8_t * sptr, unsigned c, unsigned n, unsigned m, unsigned w, unsigned line_size) { unsigned i; @@ -1095,7 +1175,7 @@ pack_48_24_bpc (uint8_t * sptr, unsigned n) unsigned i; uint8_t *cptr, lsb; static uint8_t offset = 0; - + cptr = sptr; if (n % 2 != 0) PDBG (pixma_dbg (3, "WARNING: misaligned image.\n")); @@ -1109,9 +1189,9 @@ pack_48_24_bpc (uint8_t * sptr, unsigned n) } #endif -/* This function deals both with PIXMA CCD sensors producing shifted color +/* This function deals both with PIXMA CCD sensors producing shifted color * planes images, Grayscale CCD scan and Generation >= 3 high dpi images. - * Each complete line in mp->imgbuf is processed for shifting CCD sensor + * Each complete line in mp->imgbuf is processed for shifting CCD sensor * color planes, reordering pixels above 600 dpi for Generation >= 3, and * converting to Grayscale for CCD sensors. */ static unsigned @@ -1121,19 +1201,28 @@ post_process_image_data (pixma_t * s, pixma_imagebuf_t * ib) unsigned c, lines, line_size, n, m, cw, cx; uint8_t *sptr, *dptr, *gptr, *cptr; + if (s->param->mode_jpeg) + { + /* No post-processing, send raw JPEG data to main */ + ib->rptr = mp->imgbuf; + ib->rend = mp->data_left_ofs; + return 0; /* # of non processed bytes */ + } + + c = ((is_ccd_grayscale (s) || is_ccd_lineart (s)) ? 3 : s->param->channels) * ((s->param->software_lineart) ? 8 : s->param->depth) / 8; cw = c * s->param->w; cx = c * s->param->xs; - + if (mp->generation >= 3) n = s->param->xdpi / 600; else /* FIXME: maybe need different values for CIS and CCD sensors */ n = s->param->xdpi / 2400; - - if (s->cfg->pid == MP600_PID || s->cfg->pid == MP600R_PID) + + if (s->cfg->pid == MP600_PID || s->cfg->pid == MP600R_PID) n = s->param->xdpi / 1200; - + m = (n > 0) ? s->param->wx / n : 1; sptr = dptr = gptr = cptr = mp->imgbuf; line_size = get_cis_ccd_line_size (s); @@ -1153,38 +1242,33 @@ post_process_image_data (pixma_t * s, pixma_imagebuf_t * ib) /*PDBG (pixma_dbg (4, "*post_process_image_data***** Processing with c=%u, n=%u, m=%u, w=%i, line_size=%u ***** \n", c, n, m, s->param->wx, line_size));*/ if (s->cfg->pid != MG5300_PID && s->cfg->pid != MG6300_PID && c >= 3) - dptr = shift_colors (dptr, sptr, + dptr = shift_colors (dptr, sptr, s->param->wx, s->param->xdpi, s->cfg->pid, c, mp->shift, mp->stripe_shift); - - /* special image format for *most* devices at high dpi. - * MP220, MX360, MX370, MX890, MG5300 are exceptions */ + + /* special image format for *most* devices at high dpi. + * MP220, MX360 and generation 5 scanners are exceptions */ if (n > 0 && s->cfg->pid != MP220_PID + && s->cfg->pid != MP490_PID && s->cfg->pid != MX360_PID - && s->cfg->pid != MX370_PID - && s->cfg->pid != MX530_PID - && s->cfg->pid != MX890_PID - && s->cfg->pid != MX720_PID - && s->cfg->pid != MX920_PID - && s->cfg->pid != MG3100_PID - && s->cfg->pid != MG3500_PID - && s->cfg->pid != MG3600_PID - && s->cfg->pid != MG2100_PID - && s->cfg->pid != MG5300_PID - && s->cfg->pid != MG5400_PID - && s->cfg->pid != MG5500_PID - && s->cfg->pid != MG6300_PID - && s->cfg->pid != MG6400_PID - && s->cfg->pid != MG7100_PID - && s->cfg->pid != MG7500_PID - && s->cfg->pid != MG7700_PID - && s->cfg->pid != MB5000_PID) + && (mp->generation < 5 + /* generation 5 scanners *with* special image format */ + || s->cfg->pid == MG2200_PID + || s->cfg->pid == MG3200_PID + || s->cfg->pid == MG4200_PID + || s->cfg->pid == MG5600_PID + || s->cfg->pid == MG5700_PID + || s->cfg->pid == MG6200_PID + || s->cfg->pid == MP230_PID + || s->cfg->pid == MX470_PID + || s->cfg->pid == MX510_PID + || s->cfg->pid == MX520_PID)) reorder_pixels (mp->linebuf, sptr, c, n, m, s->param->wx, line_size); - + /* Crop line to selected borders */ memmove(cptr, sptr + cx, cw); - + /* Color / Gray to Lineart convert */ if (s->param->software_lineart) cptr = gptr = pixma_binarize_line (s->param, gptr, cptr, s->param->w, c); @@ -1237,10 +1321,13 @@ mp150_open (pixma_t * s) if (s->cfg->pid >= MP250_PID) mp->generation = 4; + if (s->cfg->pid >= MG2100_PID) /* this scanners generation doesn't need */ + mp->generation = 5; /* special image conversion @ high dpi */ + /* And exceptions to be added here */ if (s->cfg->pid == MP140_PID) mp->generation = 2; - + PDBG (pixma_dbg (3, "*mp150_open***** This is a generation %d scanner. *****\n", mp->generation)); /* TPU info data setup */ @@ -1253,7 +1340,7 @@ mp150_open (pixma_t * s) { query_status (s); handle_interrupt (s, 200); - if (mp->generation == 3 && has_ccd_sensor (s)) + if (mp->generation == 3 && has_ccd_sensor (s)) send_cmd_start_calibrate_ccd_3 (s); } return 0; @@ -1324,14 +1411,16 @@ mp150_check_param (pixma_t * s, pixma_scan_param_t * sp) sp->wx = calc_raw_width (mp, sp); sp->line_size = sp->w * sp->channels * (((sp->software_lineart) ? 8 : sp->depth) / 8); /* bytes per line per color after cropping */ /*PDBG (pixma_dbg (4, "*mp150_check_param***** Final scan width and line-size: %i, %i *****\n", sp->wx, sp->line_size));*/ - + /* Some exceptions here for particular devices */ /* Those devices can scan up to legal 14" with ADF, but A4 11.7" in flatbed */ /* PIXMA_CAP_ADF also works for PIXMA_CAP_ADFDUP */ if ((s->cfg->cap & PIXMA_CAP_ADF) && sp->source == PIXMA_SOURCE_FLATBED) sp->h = MIN (sp->h, 877 * sp->xdpi / 75); - - if (sp->source == PIXMA_SOURCE_TPU) + + if (sp->source == PIXMA_SOURCE_TPU + || s->cfg->pid == LIDE300_PID + || s->cfg->pid == LIDE400_PID) { uint8_t k; @@ -1340,10 +1429,10 @@ mp150_check_param (pixma_t * s, pixma_scan_param_t * sp) k = MAX (sp->xdpi, 300) / sp->xdpi; else k = MAX (sp->xdpi, 150) / sp->xdpi; - sp->x *= k; + sp->x *= k; sp->xs *= k; sp->y *= k; - sp->w *= k; + sp->w *= k; sp->wx *= k; sp->h *= k; sp->xdpi *= k; @@ -1354,7 +1443,7 @@ mp150_check_param (pixma_t * s, pixma_scan_param_t * sp) { uint8_t k = 1; - /* ADF/ADF duplex mode: max scan res is 600 dpi, at least for generation 4 */ + /* ADF/ADF duplex mode: max scan res is 600 dpi, at least for generation 4+ */ if (mp->generation >= 4) k = sp->xdpi / MIN (sp->xdpi, 600); sp->x /= k; @@ -1367,6 +1456,10 @@ mp150_check_param (pixma_t * s, pixma_scan_param_t * sp) sp->ydpi = sp->xdpi; } + sp->mode_jpeg = (s->cfg->cap & PIXMA_CAP_ADF_JPEG) && + (sp->source == PIXMA_SOURCE_ADF || + sp->source == PIXMA_SOURCE_ADFDUP); + /*PDBG (pixma_dbg (4, "*mp150_check_param***** Finally: channels=%u, depth=%u, x=%u, y=%u, w=%u, h=%u, xs=%u, wx=%u *****\n", sp->channels, sp->depth, sp->x, sp->y, sp->w, sp->h, sp->xs, sp->wx));*/ return 0; @@ -1381,9 +1474,15 @@ mp150_scan (pixma_t * s) if (mp->state != state_idle) return PIXMA_EBUSY; - /* Generation 4: send XML dialog */ + /* no paper inserted after first adf page => abort session */ + if (s->param->adf_pageid && is_scanning_from_adf(s) && mp->adf_state == state_idle) + { + return PIXMA_ENO_PAPER; + } + + /* Generation 4+: send XML dialog */ /* adf: first page or idle */ - if (mp->generation == 4 && mp->adf_state == state_idle) + if (mp->generation >= 4 && mp->adf_state == state_idle) { if (!send_xml_dialog (s, XML_START_1)) return PIXMA_EPROTO; @@ -1423,9 +1522,9 @@ mp150_scan (pixma_t * s) if (error < 0) return error; - /* Generation 4: send XML dialog */ + /* Generation 4+: send XML dialog */ /* adf: first page or idle */ - if (mp->generation == 4 && mp->adf_state == state_idle) + if (mp->generation >= 4 && mp->adf_state == state_idle) { if (!send_xml_dialog (s, XML_END)) return PIXMA_EPROTO; @@ -1442,14 +1541,14 @@ mp150_scan (pixma_t * s) { case PIXMA_ECANCELED: case PIXMA_EBUSY: - PDBG (pixma_dbg (2, "cmd e920 or d520 returned %s\n", + PDBG (pixma_dbg (2, "cmd e920 or d520 returned %s\n", pixma_strerror (error))); /* fall through */ case 0: query_status (s); break; default: - PDBG (pixma_dbg (1, "WARNING:cmd e920 or d520 failed %s\n", + PDBG (pixma_dbg (1, "WARNING:cmd e920 or d520 failed %s\n", pixma_strerror (error))); return error; } @@ -1496,7 +1595,7 @@ mp150_scan (pixma_t * s) error = select_source (s); if ((error >= 0) && (mp->generation >= 3) && has_ccd_sensor (s)) error = init_ccd_lamp_3 (s); - if ((error >= 0) && !is_scanning_from_tpu (s)) + if ((error >= 0) && !is_scanning_from_tpu (s) && !is_scanning_jpeg (s)) { int i; @@ -1511,8 +1610,6 @@ mp150_scan (pixma_t * s) PDBG (pixma_dbg (4, "*mp150_scan***** scan next sheet from ADF *****\n")); pixma_sleep (1000000); } - - if ((error >= 0) || (mp->generation >= 3)) mp->state = state_warmup; if (error >= 0) @@ -1610,7 +1707,7 @@ mp150_fill_buffer (pixma_t * s, pixma_imagebuf_t * ib) #endif bytes_received = pack_48_24_bpc (mp->imgbuf + mp->data_left_len, bytes_received); #endif -#endif +#endif /* Post-process the image data */ mp->data_left_ofs = mp->imgbuf + mp->data_left_len + bytes_received; mp->data_left_len = post_process_image_data (s, ib); @@ -1638,7 +1735,7 @@ mp150_finish_scan (pixma_t * s) /* Send the get TPU info message */ if (is_scanning_from_tpu (s) && mp->tpu_datalen == 0) send_get_tpu_info_3 (s); - /* FIXME: to process several pages ADF scan, must not send + /* FIXME: to process several pages ADF scan, must not send * abort_session and start_session between pages (last_block=0x28) */ if (mp->generation <= 2 || !is_scanning_from_adf (s) || mp->last_block == 0x38) { @@ -1647,8 +1744,8 @@ mp150_finish_scan (pixma_t * s) if (error < 0) PDBG (pixma_dbg (1, "WARNING:abort_session() failed %d\n", error)); - /* Generation 4: send XML end of scan dialog */ - if (mp->generation == 4) + /* Generation 4+: send XML end of scan dialog */ + if (mp->generation >= 4) { if (!send_xml_dialog (s, XML_END)) PDBG (pixma_dbg (1, "WARNING:XML_END dialog failed \n")); @@ -1793,7 +1890,7 @@ const pixma_config_t pixma_mp150_devices[] = { DEVICE ("Canon PIXMA MG5200", "MG5200", MG5200_PID, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG6100", "MG6100", MG6100_PID, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), - /* Latest devices (2011) Generation 4 CIS/CCD */ + /* Latest devices (2011) Generation 5 CIS/CCD */ DEVICE ("Canon PIXMA MG2100", "MG2100", MG2100_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG3100", "MG3100", MG3100_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG4100", "MG4100", MG4100_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), @@ -1802,7 +1899,7 @@ const pixma_config_t pixma_mp150_devices[] = { DEVICE ("Canon PIXMA MP493", "MP493", MP493_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA E500", "E500", E500_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), - /* Latest devices (2012) Generation 4 CIS */ + /* Latest devices (2012) Generation 5 CIS */ DEVICE ("Canon PIXMA MX370 Series", "MX370", MX370_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MX430 Series", "MX430", MX430_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MX510 Series", "MX510", MX510_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), @@ -1811,7 +1908,7 @@ const pixma_config_t pixma_mp150_devices[] = { DEVICE ("Canon PIXMA E600 Series", "E600", E600_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MG4200", "MG4200", MG4200_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), - /* Latest devices (2013) Generation 4 CIS */ + /* Latest devices (2013) Generation 5 CIS */ DEVICE ("Canon PIXMA E510", "E510", E510_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA E610", "E610", E610_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MP230", "MP230", MP230_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), @@ -1832,13 +1929,15 @@ const pixma_config_t pixma_mp150_devices[] = { DEVICE ("Canon PIXMA MG6500 Series", "MG6500", MG6500_PID, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG7100 Series", "MG7100", MG7100_PID, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), - /* Latest devices (2014) Generation 4 CIS */ + /* Latest devices (2014) Generation 5 CIS */ DEVICE ("Canon PIXMA MX470 Series", "MX470", MX470_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MX530 Series", "MX530", MX530_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon MAXIFY MB5000 Series", "MB5000", MB5000_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP), DEVICE ("Canon MAXIFY MB5300 Series", "MB5300", MB5300_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP), DEVICE ("Canon MAXIFY MB2000 Series", "MB2000", MB2000_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP), - DEVICE ("Canon MAXIFY MB2300 Series", "MB2300", MB2300_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP), + DEVICE ("Canon MAXIFY MB2100 Series", "MB2100", MB2100_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF | PIXMA_CAP_ADF_JPEG), + DEVICE ("Canon MAXIFY MB2300 Series", "MB2300", MB2300_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), + DEVICE ("Canon MAXIFY MB2700 Series", "MB2700", MB2700_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF | PIXMA_CAP_ADF_JPEG), DEVICE ("Canon PIXMA E400", "E400", E400_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA E560", "E560", E560_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG7500 Series", "MG7500", MG7500_PID, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), @@ -1847,7 +1946,7 @@ const pixma_config_t pixma_mp150_devices[] = { DEVICE ("Canon PIXMA MG2900 Series", "MG2900", MG2900_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA E460 Series", "E460", E460_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), - /* Latest devices (2015) Generation 4 CIS */ + /* Latest devices (2015) Generation 5 CIS */ DEVICE ("Canon PIXMA MX490 Series", "MX490", MX490_PID, 600, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA E480 Series", "E480", E480_PID, 600, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MG3600 Series", "MG3600", MG3600_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), @@ -1856,14 +1955,59 @@ const pixma_config_t pixma_mp150_devices[] = { DEVICE ("Canon PIXMA MG6800 Series", "MG6800", MG6800_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG5700 Series", "MG5700", MG5700_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), - /* Latest devices (2016) Generation 4 CIS */ - DEVICE ("Canon PIXMA TS9000 Series", "TS9000", TS9000_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), - DEVICE ("Canon PIXMA TS8000 Series", "TS8000", TS8000_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), - DEVICE ("Canon PIXMA TS6000 Series", "TS6000", TS6000_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), - DEVICE ("Canon PIXMA TS5000 Series", "TS5000", TS5000_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + /* Latest devices (2016) Generation 5 CIS */ + DEVICE ("Canon PIXMA G3000", "G3000", G3000_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA G2000", "G2000", G2000_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS9000 Series", "TS9000", TS9000_PID, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS8000 Series", "TS8000", TS8000_PID, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS6000 Series", "TS6000", TS6000_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS5000 Series", "TS5000", TS5000_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG3000 Series", "MG3000", MG3000_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA E470 Series", "E470", E470_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), - DEVICE ("Canon PIXMA G4000 Series", "G3000", G3000_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA E410 Series", "E410", E410_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + + /* Latest devices (2017) Generation 5 CIS */ + DEVICE ("Canon PIXMA G4000", "G4000", G4000_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS6100 Series", "TS6100", TS6100_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS5100 Series", "TS5100", TS5100_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS3100 Series", "TS3100", TS3100_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA E3100 Series", "E3100", E3100_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + + /* Latest devices (2018) Generation 5 CIS */ + DEVICE ("Canon MAXIFY MB5400 Series", "MB5400", MB5400_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP), + DEVICE ("Canon MAXIFY MB5100 Series", "MB5100", MB5100_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP), + DEVICE ("Canon PIXMA TS9100 Series", "TS9100", TS9100_PID, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TR8500 Series", "TR8500", TR8500_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), + DEVICE ("Canon PIXMA TR7500 Series", "TR7500", TR7500_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), + DEVICE ("Canon PIXMA TS9500 Series", "TS9500", TS9500_PID, 1200, 0, 600, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), + DEVICE ("CanoScan LiDE 400", "LIDE400", LIDE400_PID, 4800, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("CanoScan LiDE 300", "LIDE300", LIDE300_PID, 4800, 0, 0, 638, 877, PIXMA_CAP_CIS), + + /* Latest devices (2019) Generation 5 CIS */ + DEVICE ("Canon PIXMA TS8100 Series", "TS8100", TS8100_PID, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA G3010 Series", "G3010", G3010_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA G4010 Series", "G4010", G4010_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), + DEVICE ("Canon PIXMA TS9180 Series", "TS9180", TS9180_PID, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS8180 Series", "TS8180", TS8180_PID, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS6180 Series", "TS6180", TS6180_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TR8580 Series", "TR8580", TR8580_PID, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), + DEVICE ("Canon PIXMA TS8130 Series", "TS8130", TS8130_PID, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS6130 Series", "TS6130", TS6130_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TR8530 Series", "TR8530", TR8530_PID, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), + DEVICE ("Canon PIXMA TR7530 Series", "TR7530", TR7530_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), + DEVICE ("Canon PIXUS XK50 Series", "XK50", XK50_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXUS XK70 Series", "XK70", XK70_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TR4500 Series", "TR4500", TR4500_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), + DEVICE ("Canon PIXMA E4200 Series", "E4200", E4200_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), + DEVICE ("Canon PIXMA TS6200 Series", "TS6200", TS6200_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS6280 Series", "TS6280", TS6280_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS6230 Series", "TS6230", TS6230_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS8200 Series", "TS8200", TS8200_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS8280 Series", "TS8280", TS8280_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS8230 Series", "TS8230", TS8230_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("Canon PIXMA TS9580 Series", "TS9580", TS9580_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), + DEVICE ("Canon PIXMA TR9530 Series", "TR9530", TR9530_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), + DEVICE ("Canon PIXUS XK80 Series", "XK80", XK80_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), END_OF_DEVICE_LIST }; -- cgit v1.2.3