From 97cd2e10bb6149cbdaab8fc306ea2761aa83f972 Mon Sep 17 00:00:00 2001 From: Rolf Bensch Date: Tue, 22 Oct 2019 17:46:01 +0200 Subject: [PATCH 1/6] pixma_mp750: all scanners have ccd --- backend/pixma_mp750.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/pixma_mp750.c b/backend/pixma_mp750.c index 5bd6ef0a6..db6c1aa4c 100644 --- a/backend/pixma_mp750.c +++ b/backend/pixma_mp750.c @@ -959,12 +959,13 @@ static const pixma_scan_ops_t pixma_mp750_ops = { 0, 0, /* adftpu_min_dpi & adftpu_max_dpi not used in this subdriver */ \ 0, 0, /* tpuir_min_dpi & tpuir_max_dpi not used in this subdriver */ \ 637, 877, /* width, height */ \ - PIXMA_CAP_GRAY|PIXMA_CAP_EVENTS|cap \ + PIXMA_CAP_CCD| /* all scanners with CCD */ \ + PIXMA_CAP_GRAY|PIXMA_CAP_EVENTS|cap \ } const pixma_config_t pixma_mp750_devices[] = { - DEVICE ("Canon PIXMA MP750", "MP750", MP750_PID, 2400, PIXMA_CAP_CCD | PIXMA_CAP_ADF), - DEVICE ("Canon PIXMA MP760/770", "MP760/770", MP760_PID, 2400, PIXMA_CAP_CCD | PIXMA_CAP_TPU), - DEVICE ("Canon PIXMA MP780/790", "MP780/790", MP780_PID, 2400, PIXMA_CAP_CCD | PIXMA_CAP_ADF), + DEVICE ("Canon PIXMA MP750", "MP750", MP750_PID, 2400, PIXMA_CAP_ADF), + DEVICE ("Canon PIXMA MP760/770", "MP760/770", MP760_PID, 2400, PIXMA_CAP_TPU), + DEVICE ("Canon PIXMA MP780/790", "MP780/790", MP780_PID, 2400, PIXMA_CAP_ADF), DEVICE (NULL, NULL, 0, 0, 0) }; From 657f1d8e26f0259f380c11aa16cdcfc00249648a Mon Sep 17 00:00:00 2001 From: Rolf Bensch Date: Tue, 22 Oct 2019 17:46:19 +0200 Subject: [PATCH 2/6] pixma_mp810: all scanners have ccd --- backend/pixma_mp810.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/backend/pixma_mp810.c b/backend/pixma_mp810.c index 561507b53..7c3549fab 100644 --- a/backend/pixma_mp810.c +++ b/backend/pixma_mp810.c @@ -2345,6 +2345,7 @@ static const pixma_scan_ops_t pixma_mp810_ops = adftpu_min_dpi, adftpu_max_dpi, /* adftpu_min_dpi, adftpu_max_dpi */ \ tpuir_min_dpi, tpuir_max_dpi, /* tpuir_min_dpi, tpuir_max_dpi */ \ w, h, /* width, height */ \ + PIXMA_CAP_CCD| /* all scanners with CCD*/ \ PIXMA_CAP_EASY_RGB| \ PIXMA_CAP_GRAY| /* all scanners with software grayscale */ \ PIXMA_CAP_LINEART| /* all scanners with software lineart */ \ @@ -2356,32 +2357,32 @@ static const pixma_scan_ops_t pixma_mp810_ops = const pixma_config_t pixma_mp810_devices[] = { /* Generation 2: CCD */ - DEVICE ("Canon PIXMA MP810", "MP810", MP810_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_CCD | PIXMA_CAP_TPU), - DEVICE ("Canon PIXMA MP960", "MP960", MP960_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_CCD | PIXMA_CAP_TPU), + DEVICE ("Canon PIXMA MP810", "MP810", MP810_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_TPU), + DEVICE ("Canon PIXMA MP960", "MP960", MP960_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_TPU), /* Generation 3 CCD not managed as Generation 2 */ - DEVICE ("Canon Pixma MP970", "MP970", MP970_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_CCD | PIXMA_CAP_TPU), + DEVICE ("Canon Pixma MP970", "MP970", MP970_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_TPU), /* Flatbed scanner CCD (2007) */ - DEVICE ("Canoscan 8800F", "8800F", CS8800F_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_CCD | PIXMA_CAP_TPU /*| PIXMA_CAP_NEGATIVE*/ | PIXMA_CAP_48BIT), + DEVICE ("Canoscan 8800F", "8800F", CS8800F_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_TPU /*| PIXMA_CAP_NEGATIVE*/ | PIXMA_CAP_48BIT), /* PIXMA 2008 vintage CCD */ - DEVICE ("Canon MP980 series", "MP980", MP980_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_CCD | PIXMA_CAP_TPU), + DEVICE ("Canon MP980 series", "MP980", MP980_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_TPU), /* Generation 4 CCD */ - DEVICE ("Canon MP990 series", "MP990", MP990_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_CCD | PIXMA_CAP_TPU), + DEVICE ("Canon MP990 series", "MP990", MP990_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_TPU), /* Flatbed scanner (2010) */ - DEVICE ("Canoscan 9000F", "9000F", CS9000F_PID, 4800, 300, 9600, 600, 2400, 638, 877, PIXMA_CAP_CCD | PIXMA_CAP_TPUIR /*| PIXMA_CAP_NEGATIVE*/ | PIXMA_CAP_48BIT), + DEVICE ("Canoscan 9000F", "9000F", CS9000F_PID, 4800, 300, 9600, 600, 2400, 638, 877, PIXMA_CAP_TPUIR /*| PIXMA_CAP_NEGATIVE*/ | PIXMA_CAP_48BIT), /* Latest devices (2010) Generation 4 CCD untested */ - DEVICE ("Canon PIXMA MG8100", "MG8100", MG8100_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_CCD | PIXMA_CAP_TPU), + DEVICE ("Canon PIXMA MG8100", "MG8100", MG8100_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_TPU), /* Latest devices (2011) Generation 4 CCD untested */ - DEVICE ("Canon PIXMA MG8200", "MG8200", MG8200_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_CCD | PIXMA_CAP_TPU), + DEVICE ("Canon PIXMA MG8200", "MG8200", MG8200_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_TPU), /* Flatbed scanner (2013) */ - DEVICE ("Canoscan 9000F Mark II", "9000FMarkII", CS9000F_MII_PID, 4800, 300, 9600, 600, 2400, 638, 877, PIXMA_CAP_CCD | PIXMA_CAP_TPUIR | PIXMA_CAP_48BIT), + DEVICE ("Canoscan 9000F Mark II", "9000FMarkII", CS9000F_MII_PID, 4800, 300, 9600, 600, 2400, 638, 877, PIXMA_CAP_TPUIR | PIXMA_CAP_48BIT), END_OF_DEVICE_LIST }; From 83a0a1c55f973db2d4fb7ce9d664477e46516651 Mon Sep 17 00:00:00 2001 From: Rolf Bensch Date: Tue, 22 Oct 2019 18:03:33 +0200 Subject: [PATCH 3/6] pixma_mp150: move ccd scanners => pixma_mp810 --- backend/pixma_mp150.c | 44 +--------------------------------------- backend/pixma_mp810.c | 47 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 44 deletions(-) diff --git a/backend/pixma_mp150.c b/backend/pixma_mp150.c index 958687997..7fd9ff3b1 100644 --- a/backend/pixma_mp150.c +++ b/backend/pixma_mp150.c @@ -101,9 +101,6 @@ #define MP450_PID 0x170b #define MP500_PID 0x170c #define MP530_PID 0x1712 -#define MP800_PID 0x170d -#define MP800R_PID 0x170e -#define MP830_PID 0x1713 /* Generation 2 */ #define MP160_PID 0x1714 @@ -723,39 +720,6 @@ calc_shifting (pixma_t * s) switch (s->cfg->pid) { - case MP800_PID: - case MP800R_PID: - case MP830_PID: - if (s->param->xdpi == 2400) - { - if (is_scanning_from_tpu(s)) - mp->stripe_shift = 6; - else - mp->stripe_shift = 3; - } - if (s->param->ydpi > 75) - { - mp->color_shift = s->param->ydpi / ((s->param->ydpi < 1200) ? 150 : 75); - - if (is_scanning_from_tpu (s)) - mp->color_shift = s->param->ydpi / 75; - - /* If you're trying to decipher this color-shifting code, - the following line is where the magic is revealed. */ - mp->shift[1] = mp->color_shift * get_cis_ccd_line_size (s); - if (is_scanning_from_adf (s)) - { /* ADF */ - mp->shift[0] = 0; - mp->shift[2] = 2 * mp->shift[1]; - } - else - { /* Flatbed or TPU */ - mp->shift[0] = 2 * mp->shift[1]; - mp->shift[2] = 0; - } - } - break; - default: /* Default, and all CIS devices */ break; } @@ -1115,8 +1079,7 @@ wait_until_ready (pixma_t * s) if (mp->generation >= 3) RET_IF_ERR (query_status_3 (s)); else if (s->cfg->pid == MP600_PID || - s->cfg->pid == MP600R_PID || - s->cfg->pid == MP800R_PID) + s->cfg->pid == MP600R_PID) RET_IF_ERR (query_status (s)); if (--tmo == 0) { @@ -1818,11 +1781,6 @@ const pixma_config_t pixma_mp150_devices[] = { DEVICE ("Canon PIXMA MP500", "MP500", MP500_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP530", "MP530", MP530_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), - /* Generation 1: CCD */ - DEVICE ("Canon PIXMA MP800", "MP800", MP800_PID, 2400, 150, 0, 638, 877, PIXMA_CAP_CCD | PIXMA_CAP_TPU), - DEVICE ("Canon PIXMA MP800R", "MP800R", MP800R_PID, 2400, 150, 0, 638, 877, PIXMA_CAP_CCD | PIXMA_CAP_TPU), - DEVICE ("Canon PIXMA MP830", "MP830", MP830_PID, 2400, 150, 0, 638, 877, PIXMA_CAP_CCD | PIXMA_CAP_ADFDUP), - /* Generation 2: CIS */ DEVICE ("Canon PIXMA MP140", "MP140", MP140_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP160", "MP160", MP160_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), diff --git a/backend/pixma_mp810.c b/backend/pixma_mp810.c index 7c3549fab..c81f35daa 100644 --- a/backend/pixma_mp810.c +++ b/backend/pixma_mp810.c @@ -96,6 +96,11 @@ #define CANON_VID 0x04a9 +/* Generation 1 */ +#define MP800_PID 0x170d +#define MP800R_PID 0x170e +#define MP830_PID 0x1713 + /* Generation 2 */ #define MP810_PID 0x171a #define MP960_PID 0x171b @@ -575,6 +580,39 @@ static unsigned calc_shifting (pixma_t * s) switch (s->cfg->pid) { + case MP800_PID: + case MP800R_PID: + case MP830_PID: + if (s->param->xdpi == 2400) + { + if (is_scanning_from_tpu(s)) + mp->stripe_shift = 6; + else + mp->stripe_shift = 3; + } + if (s->param->ydpi > 75) + { + mp->color_shift = s->param->ydpi / ((s->param->ydpi < 1200) ? 150 : 75); + + if (is_scanning_from_tpu (s)) + mp->color_shift = s->param->ydpi / 75; + + /* If you're trying to decipher this color-shifting code, + the following line is where the magic is revealed. */ + mp->shift[1] = mp->color_shift * get_cis_ccd_line_size (s); + if (is_scanning_from_adf (s)) + { /* ADF */ + mp->shift[0] = 0; + mp->shift[2] = 2 * mp->shift[1]; + } + else + { /* Flatbed or TPU */ + mp->shift[0] = 2 * mp->shift[1]; + mp->shift[2] = 0; + } + } + break; + case MP970_PID: /* MP970 at 4800 dpi */ case CS8800F_PID: /* CanoScan 8800F at 4800 dpi */ if (s->param->xdpi == 4800) @@ -1209,6 +1247,8 @@ static int 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 == MP800R_PID) + RET_IF_ERR (query_status (s)); if (--tmo == 0) { PDBG(pixma_dbg (1, "WARNING: Timed out in wait_until_ready()\n")); @@ -1782,7 +1822,7 @@ static int mp810_open (pixma_t * s) mp->imgbuf = buf + CMDBUF_SIZE; /* General rules for setting Pixma protocol generation # */ - mp->generation = (s->cfg->pid >= MP810_PID) ? 2 : 1; /* no generation 1 devices anyway, but keep similar to pixma_mp150.c file */ + mp->generation = (s->cfg->pid >= MP810_PID) ? 2 : 1; if (s->cfg->pid >= MP970_PID) mp->generation = 3; @@ -2356,6 +2396,11 @@ static const pixma_scan_ops_t pixma_mp810_ops = const pixma_config_t pixma_mp810_devices[] = { + /* Generation 1: CCD */ + DEVICE ("Canon PIXMA MP800", "MP800", MP800_PID, 2400, 150, 0, 0, 0, 638, 877, PIXMA_CAP_CCD | PIXMA_CAP_TPU), + DEVICE ("Canon PIXMA MP800R", "MP800R", MP800R_PID, 2400, 150, 0, 0, 0, 638, 877, PIXMA_CAP_CCD | PIXMA_CAP_TPU), + DEVICE ("Canon PIXMA MP830", "MP830", MP830_PID, 2400, 150, 0, 0, 0, 638, 877, PIXMA_CAP_CCD | PIXMA_CAP_ADFDUP), + /* Generation 2: CCD */ DEVICE ("Canon PIXMA MP810", "MP810", MP810_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_TPU), DEVICE ("Canon PIXMA MP960", "MP960", MP960_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_TPU), From 1b8fe029a256d6ef4202838a1c69fc2e9307daa7 Mon Sep 17 00:00:00 2001 From: Rolf Bensch Date: Tue, 22 Oct 2019 19:10:53 +0200 Subject: [PATCH 4/6] pixma_mp150: remove unused code unused scanner functions: ccd, tpu --- backend/pixma_mp150.c | 273 +++++------------------------------------- 1 file changed, 29 insertions(+), 244 deletions(-) diff --git a/backend/pixma_mp150.c b/backend/pixma_mp150.c index 7fd9ff3b1..c8a23721d 100644 --- a/backend/pixma_mp150.c +++ b/backend/pixma_mp150.c @@ -49,10 +49,6 @@ 4. cancel using ctrl-c (must send abort command) */ -#define TPU_48 /* uncomment to activate TPU scan at 48 bits */ -/*#define DEBUG_TPU_48*/ /* uncomment to debug 48 bits TPU on a non TPU device */ -/*#define DEBUG_TPU_24*/ /* uncomment to debug 24 bits TPU on a non TPU device */ - #include "../include/sane/config.h" #include @@ -333,15 +329,9 @@ enum mp150_cmd_t cmd_read_image = 0xd420, cmd_error_info = 0xff20, - cmd_start_calibrate_ccd_3 = 0xd520, - cmd_end_calibrate_ccd_3 = 0xd720, cmd_scan_param_3 = 0xd820, cmd_scan_start_3 = 0xd920, cmd_status_3 = 0xda20, - cmd_get_tpu_info_3 = 0xf520, - cmd_set_tpu_info_3 = 0xea20, - - cmd_e920 = 0xe920 /* seen in MP800 */ }; typedef struct mp150_t @@ -352,15 +342,13 @@ typedef struct mp150_t uint8_t current_status[16]; unsigned last_block; uint8_t generation; - /* for Generation 3 and CCD shift */ + /* for Generation 3 shift */ uint8_t *linebuf; uint8_t *data_left_ofs; unsigned data_left_len; int shift[3]; unsigned color_shift; unsigned stripe_shift; - uint8_t tpu_datalen; - uint8_t tpu_data[0x40]; uint8_t adf_state; /* handle adf scanning */ } mp150_t; @@ -438,12 +426,6 @@ is_scanning_jpeg (pixma_t *s) return s->param->mode_jpeg; } -static int -is_scanning_from_tpu (pixma_t * s) -{ - return (s->param->source == PIXMA_SOURCE_TPU); -} - static int send_xml_dialog (pixma_t * s, const char * xml_message) { @@ -463,19 +445,13 @@ send_xml_dialog (pixma_t * s, const char * xml_message) return (strcasestr ((const char *) mp->cb.buf, XML_OK) != NULL); } -static void -new_cmd_tpu_msg (pixma_t *s, pixma_cmdbuf_t * cb, uint16_t cmd) -{ - pixma_newcmd (cb, cmd, 0, 0); - cb->buf[3] = (is_scanning_from_tpu (s)) ? 0x01 : 0x00; -} - static int start_session (pixma_t * s) { mp150_t *mp = (mp150_t *) s->subdriver; - new_cmd_tpu_msg (s, &mp->cb, cmd_start_session); + pixma_newcmd (&mp->cb, cmd_start_session, 0, 0); + mp->cb.buf[3] = 0x00; return pixma_exec (s, &mp->cb); } @@ -484,17 +460,8 @@ start_scan_3 (pixma_t * s) { mp150_t *mp = (mp150_t *) s->subdriver; - new_cmd_tpu_msg (s, &mp->cb, cmd_scan_start_3); - return pixma_exec (s, &mp->cb); -} - -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; + pixma_newcmd (&mp->cb, cmd_scan_start_3, 0, 0); + mp->cb.buf[3] = 0x00; return pixma_exec (s, &mp->cb); } @@ -542,13 +509,6 @@ abort_session (pixma_t * s) return pixma_exec_short_cmd (s, &mp->cb, cmd_abort_session); } -static int -send_cmd_e920 (pixma_t * s) -{ - mp150_t *mp = (mp150_t *) s->subdriver; - return pixma_exec_short_cmd (s, &mp->cb, cmd_e920); -} - static int select_source (pixma_t * s) { @@ -576,40 +536,12 @@ select_source (pixma_t * s) data[6] = 3; break; - case PIXMA_SOURCE_TPU: - data[0] = 4; - data[1] = 2; - break; + default: + return PIXMA_EPROTO; } return pixma_exec (s, &mp->cb); } -static int -send_get_tpu_info_3 (pixma_t * s) -{ - mp150_t *mp = (mp150_t *) s->subdriver; - uint8_t *data; - int error; - - data = pixma_newcmd (&mp->cb, cmd_get_tpu_info_3, 0, 0x34); - RET_IF_ERR (pixma_exec (s, &mp->cb)); - memcpy (mp->tpu_data, data, 0x34); - return error; -} - -static int -send_set_tpu_info (pixma_t * s) -{ - mp150_t *mp = (mp150_t *) s->subdriver; - uint8_t *data; - - if (mp->tpu_datalen == 0) - return 0; - data = pixma_newcmd (&mp->cb, cmd_set_tpu_info_3, 0x34, 0); - memcpy (data, mp->tpu_data, 0x34); - return pixma_exec (s, &mp->cb); -} - static int send_gamma_table (pixma_t * s) { @@ -681,31 +613,11 @@ calc_raw_width (const mp150_t * mp, const pixma_scan_param_t * param) return raw_width; } -static int -has_ccd_sensor (pixma_t * s) -{ - return ((s->cfg->cap & PIXMA_CAP_CCD) != 0); -} - -static int -is_ccd_grayscale (pixma_t * s) -{ - return (has_ccd_sensor (s) && (s->param->channels == 1) && !s->param->software_lineart); -} - -static int -is_ccd_lineart (pixma_t * s) -{ - return (has_ccd_sensor (s) && s->param->software_lineart); -} - -/* CCD sensors don't have neither a Grayscale mode nor a Lineart mode, - * but use color mode instead */ static unsigned -get_cis_ccd_line_size (pixma_t * s) +get_cis_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)); + return (s->param->wx ? s->param->line_size / s->param->w * s->param->wx + : s->param->line_size); } static unsigned @@ -735,12 +647,6 @@ send_scan_param (pixma_t * s) unsigned h = MIN (s->param->h + calc_shifting (s), s->cfg->height * s->param->ydpi / 75); - /* TPU scan does not support lineart */ - if (is_scanning_from_tpu (s) && is_ccd_lineart (s)) - { - return PIXMA_ENOTSUP; - } - if (mp->generation <= 2) { /*PDBG (pixma_dbg (4, "*send_scan_param gen. 1-2 ***** Setting: xdpi=%hi ydpi=%hi x=%i y=%i w=%i ***** \n", @@ -754,10 +660,10 @@ send_scan_param (pixma_t * s) pixma_set_be32 (s->param->y, data + 0x0c); pixma_set_be32 (raw_width, data + 0x10); pixma_set_be32 (h, data + 0x14); - data[0x18] = ((s->param->channels != 1) || is_ccd_grayscale (s) || is_ccd_lineart (s)) ? 0x08 : 0x04; + data[0x18] = (s->param->channels != 1) ? 0x08 : 0x04; data[0x19] = ((s->param->software_lineart) ? 8 : s->param->depth) - * ((is_ccd_grayscale (s) || is_ccd_lineart (s)) ? 3 : s->param->channels); /* bits per pixel */ - data[0x1a] = (is_scanning_from_tpu (s) ? 1 : 0); + * s->param->channels; /* bits per pixel */ + data[0x1a] = 0; data[0x20] = 0xff; data[0x23] = 0x81; data[0x26] = 0x02; @@ -768,12 +674,6 @@ send_scan_param (pixma_t * s) data = pixma_newcmd (&mp->cb, cmd_scan_param_3, 0x38, 0); data[0x00] = (is_scanning_from_adf (s)) ? 0x02 : 0x01; data[0x01] = 0x01; - if (is_scanning_from_tpu (s)) - { - data[0x00] = 0x04; - data[0x01] = 0x02; - data[0x1e] = 0x02; - } data[0x02] = 0x01; if (is_scanning_from_adfdup (s)) { @@ -796,15 +696,10 @@ send_scan_param (pixma_t * s) pixma_set_be32 (s->param->y, data + 0x10); 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; + data[0x1c] = (s->param->channels != 1) ? 0x08 : 0x04; -#ifdef DEBUG_TPU_48 - data[0x1d] = 24; -#else - data[0x1d] = (is_scanning_from_tpu (s)) ? 48 - : (((s->param->software_lineart) ? 8 : s->param->depth) - * ((is_ccd_grayscale (s) || is_ccd_lineart (s)) ? 3 : s->param->channels)); /* bits per pixel */ -#endif + data[0x1d] = ((s->param->software_lineart) ? 8 : s->param->depth) + * s->param->channels; /* bits per pixel */ data[0x1f] = 0x01; /* This one also seen at 0. Don't know yet what's used for */ data[0x20] = 0xff; @@ -1039,32 +934,6 @@ handle_interrupt (pixma_t * s, int timeout) return 1; } -static int -init_ccd_lamp_3 (pixma_t * s) -{ - mp150_t *mp = (mp150_t *) s->subdriver; - uint8_t *data; - int error, status_len, tmo; - - status_len = 8; - RET_IF_ERR (query_status (s)); - RET_IF_ERR (query_status (s)); - RET_IF_ERR (send_cmd_start_calibrate_ccd_3 (s)); - RET_IF_ERR (query_status (s)); - tmo = 20; /* like Windows driver, CCD lamp adjustment */ - while (--tmo >= 0) - { - data = pixma_newcmd (&mp->cb, cmd_end_calibrate_ccd_3, 0, status_len); - RET_IF_ERR (pixma_exec (s, &mp->cb)); - memcpy (mp->current_status, data, status_len); - PDBG (pixma_dbg (3, "Lamp status: %u , timeout in: %u\n", data[0], tmo)); - if (mp->current_status[0] == 3 || !is_scanning_from_tpu (s)) - break; - WAIT_INTERRUPT (1000); - } - return error; -} - static int wait_until_ready (pixma_t * s) { @@ -1128,32 +997,9 @@ reorder_pixels (uint8_t * linebuf, uint8_t * sptr, unsigned c, unsigned n, memcpy (sptr, linebuf, line_size); } -#ifndef TPU_48 -static unsigned -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")); - for (i = 0; i < n; i += 2) - { - /* offset = 1 + (offset % 3); */ - lsb = *sptr++; - *cptr++ = ((*sptr++) << offset) | lsb >> (8 - offset); - } - return (n / 2); -} -#endif - -/* 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 - * color planes, reordering pixels above 600 dpi for Generation >= 3, and - * converting to Grayscale for CCD sensors. */ +/* This function deals with Generation >= 3 high dpi images. + * Each complete line in mp->imgbuf is processed for reordering pixels above + * 600 dpi for Generation >= 3. */ static unsigned post_process_image_data (pixma_t * s, pixma_imagebuf_t * ib) { @@ -1170,14 +1016,14 @@ post_process_image_data (pixma_t * s, pixma_imagebuf_t * ib) } - c = ((is_ccd_grayscale (s) || is_ccd_lineart (s)) ? 3 : s->param->channels) + c = 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 */ + else n = s->param->xdpi / 2400; if (s->cfg->pid == MP600_PID || s->cfg->pid == MP600R_PID) @@ -1185,7 +1031,7 @@ post_process_image_data (pixma_t * s, pixma_imagebuf_t * ib) m = (n > 0) ? s->param->wx / n : 1; sptr = dptr = gptr = cptr = mp->imgbuf; - line_size = get_cis_ccd_line_size (s); + line_size = get_cis_line_size (s); /*PDBG (pixma_dbg (4, "*post_process_image_data***** ----- Set n=%u, m=%u, line_size=%u ----- ***** \n", n, m, line_size));*/ lines = (mp->data_left_ofs - mp->imgbuf) / line_size; @@ -1232,9 +1078,6 @@ post_process_image_data (pixma_t * s, pixma_imagebuf_t * ib) /* Color / Gray to Lineart convert */ if (s->param->software_lineart) cptr = gptr = pixma_binarize_line (s->param, gptr, cptr, s->param->w, c); - /* Color to Grayscale convert for CCD sensor */ - else if (is_ccd_grayscale (s)) - cptr = gptr = pixma_rgb_to_gray (gptr, cptr, s->param->w, c); else cptr += cw; } @@ -1290,9 +1133,6 @@ mp150_open (pixma_t * s) PDBG (pixma_dbg (3, "*mp150_open***** This is a generation %d scanner. *****\n", mp->generation)); - /* TPU info data setup */ - mp->tpu_datalen = 0; - /* adf scanning */ mp->adf_state = state_idle; @@ -1300,8 +1140,6 @@ mp150_open (pixma_t * s) { query_status (s); handle_interrupt (s, 200); - if (mp->generation == 3 && has_ccd_sensor (s)) - send_cmd_start_calibrate_ccd_3 (s); } return 0; } @@ -1330,12 +1168,6 @@ mp150_check_param (pixma_t * s, pixma_scan_param_t * sp) { sp->software_lineart = 0; sp->depth = 8; -#ifdef TPU_48 -#ifndef DEBUG_TPU_48 - if (sp->source == PIXMA_SOURCE_TPU) -#endif - sp->depth = 16; /* TPU in 16 bits mode */ -#endif } else { @@ -1378,17 +1210,13 @@ mp150_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); - if (sp->source == PIXMA_SOURCE_TPU - || s->cfg->pid == LIDE300_PID + if (s->cfg->pid == LIDE300_PID || s->cfg->pid == LIDE400_PID) { uint8_t k; /* TPU mode: lowest res is 150 or 300 dpi */ - if (mp->generation >= 3) - k = MAX (sp->xdpi, 300) / sp->xdpi; - else - k = MAX (sp->xdpi, 150) / sp->xdpi; + k = MAX (sp->xdpi, 300) / sp->xdpi; sp->x *= k; sp->xs *= k; sp->y *= k; @@ -1494,33 +1322,6 @@ mp150_scan (pixma_t * s) } } - if (has_ccd_sensor (s) && (mp->generation <= 2)) - { - error = send_cmd_e920 (s); - switch (error) - { - case PIXMA_ECANCELED: - case PIXMA_EBUSY: - 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", - pixma_strerror (error))); - return error; - } - tmo = 3; /* like Windows driver, CCD calibration ? */ - while (--tmo >= 0) - { - WAIT_INTERRUPT (1000); - PDBG (pixma_dbg (2, "CCD Calibration ends in %d sec.\n", tmo)); - } - /* pixma_sleep(2000000); */ - } - tmo = 10; /* adf: first page or idle */ if (mp->generation <= 2 || mp->adf_state == state_idle) @@ -1553,17 +1354,13 @@ mp150_scan (pixma_t * s) mp->state = state_warmup; if ((error >= 0) && (mp->generation <= 2)) 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) && !is_scanning_jpeg (s)) + if ((error >= 0) && !is_scanning_jpeg (s)) { int i; for (i = (mp->generation >= 3) ? 3 : 1 ; i > 0 && error >= 0; i--) error = send_gamma_table (s); } - else if (error >= 0) /* in TPU mode, for gen 1, 2, and 3 */ - error = send_set_tpu_info (s); } else /* ADF pageid != 0 and gen3 or above */ { /* next sheet from ADF */ @@ -1605,7 +1402,7 @@ mp150_fill_buffer (pixma_t * s, pixma_imagebuf_t * ib) mp->state = state_scanning; mp->last_block = 0; - line_size = get_cis_ccd_line_size (s); + line_size = get_cis_line_size (s); proc_buf_size = (2 * calc_shifting (s) + 2) * line_size; mp->cb.buf = realloc (mp->cb.buf, CMDBUF_SIZE + IMAGE_BLOCK_SIZE + proc_buf_size); @@ -1659,15 +1456,6 @@ mp150_fill_buffer (pixma_t * s, pixma_imagebuf_t * ib) { /* no image data at this moment. */ pixma_sleep (10000); } - /* For TPU at 48 bits/pixel to output at 24 bits/pixel */ -#ifndef DEBUG_TPU_48 -#ifndef TPU_48 -#ifndef DEBUG_TPU_24 - if (is_scanning_from_tpu (s)) -#endif - bytes_received = pack_48_24_bpc (mp->imgbuf + mp->data_left_len, bytes_received); -#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); @@ -1692,9 +1480,6 @@ mp150_finish_scan (pixma_t * s) case state_scanning: case state_warmup: case state_finished: - /* 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 * abort_session and start_session between pages (last_block=0x28) */ if (mp->generation <= 2 || !is_scanning_from_adf (s) || mp->last_block == 0x38) @@ -1766,7 +1551,7 @@ static const pixma_scan_ops_t pixma_mp150_ops = { 0, 0, /* tpuir_min_dpi & tpuir_max_dpi not used in this subdriver */ \ w, h, /* width, height */ \ PIXMA_CAP_EASY_RGB| \ - PIXMA_CAP_GRAY| /* CIS with native grayscale and CCD with software grayscale */ \ + PIXMA_CAP_GRAY| /* CIS with native grayscale */ \ PIXMA_CAP_LINEART| /* all scanners with software lineart */ \ PIXMA_CAP_GAMMA_TABLE|PIXMA_CAP_EVENTS|cap \ } @@ -1838,14 +1623,14 @@ const pixma_config_t pixma_mp150_devices[] = { DEVICE ("Canon PIXMA MP250", "MP250", MP250_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP270", "MP270", MP270_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), - /* Latest devices (2010) Generation 4 CIS/CCD */ + /* Latest devices (2010) Generation 4 CIS */ DEVICE ("Canon PIXMA MP280", "MP280", MP280_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), /* TODO: 1200dpi doesn't work yet */ DEVICE ("Canon PIXMA MP495", "MP495", MP495_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG5100", "MG5100", MG5100_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), 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 5 CIS/CCD */ + /* Latest devices (2011) Generation 5 CIS */ 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), From fc300be715eeee3b719824b694a660672de99d78 Mon Sep 17 00:00:00 2001 From: Rolf Bensch Date: Tue, 22 Oct 2019 19:23:18 +0200 Subject: [PATCH 5/6] pixma_mp150: remove (ccd) color shifting --- backend/pixma_mp150.c | 61 +++---------------------------------------- 1 file changed, 4 insertions(+), 57 deletions(-) diff --git a/backend/pixma_mp150.c b/backend/pixma_mp150.c index c8a23721d..fe83fba54 100644 --- a/backend/pixma_mp150.c +++ b/backend/pixma_mp150.c @@ -346,9 +346,6 @@ typedef struct mp150_t uint8_t *linebuf; uint8_t *data_left_ofs; unsigned data_left_len; - int shift[3]; - unsigned color_shift; - unsigned stripe_shift; uint8_t adf_state; /* handle adf scanning */ } mp150_t; @@ -620,32 +617,13 @@ get_cis_line_size (pixma_t * s) : s->param->line_size); } -static unsigned -calc_shifting (pixma_t * s) -{ - mp150_t *mp = (mp150_t *) s->subdriver; - - /* If stripes shift needed (CCD devices), how many pixels shift */ - mp->stripe_shift = 0; - /* If color plane shift (CCD devices), how many pixels shift */ - mp->color_shift = mp->shift[0] = mp->shift[1] = mp->shift[2] = 0; - - switch (s->cfg->pid) - { - default: /* Default, and all CIS devices */ - break; - } - return (2 * mp->color_shift + mp->stripe_shift); -} - static int 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), - s->cfg->height * s->param->ydpi / 75); + unsigned h = s->cfg->height * s->param->ydpi / 75; if (mp->generation <= 2) { @@ -960,30 +938,6 @@ wait_until_ready (pixma_t * s) return 0; } -static uint8_t * -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; - UNUSED(dpi); - UNUSED(pid); - sr = colshft[0]; sg = colshft[1]; sb = colshft[2]; - for (i = 0; i < w; i++) - { - /* 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); - if (c == 6) *sptr++ = *(dptr++ + sg + st); - *sptr++ = *(dptr++ + sb + st); - if (c == 6) *sptr++ = *(dptr++ + sb + st); - } - return dptr; -} - static void reorder_pixels (uint8_t * linebuf, uint8_t * sptr, unsigned c, unsigned n, unsigned m, unsigned w, unsigned line_size) @@ -1035,22 +989,15 @@ post_process_image_data (pixma_t * s, pixma_imagebuf_t * ib) /*PDBG (pixma_dbg (4, "*post_process_image_data***** ----- Set n=%u, m=%u, line_size=%u ----- ***** \n", n, m, line_size));*/ lines = (mp->data_left_ofs - mp->imgbuf) / line_size; - /*PDBG (pixma_dbg (4, "*post_process_image_data***** lines = %i > 2 * mp->color_shift + mp->stripe_shift = %i ***** \n", - lines, 2 * mp->color_shift + mp->stripe_shift));*/ - if (lines > 2 * mp->color_shift + mp->stripe_shift) + /*PDBG (pixma_dbg (4, "*post_process_image_data***** lines = %i ***** \n", lines));*/ + if (lines > 0) { unsigned i; - lines -= 2 * mp->color_shift + mp->stripe_shift; for (i = 0; i < lines; i++, sptr += line_size) { - /* Color plane and stripes shift needed by e.g. CCD */ /*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, - 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 and generation 5 scanners are exceptions */ @@ -1403,7 +1350,7 @@ mp150_fill_buffer (pixma_t * s, pixma_imagebuf_t * ib) mp->last_block = 0; line_size = get_cis_line_size (s); - proc_buf_size = (2 * calc_shifting (s) + 2) * line_size; + proc_buf_size = 2 * line_size; mp->cb.buf = realloc (mp->cb.buf, CMDBUF_SIZE + IMAGE_BLOCK_SIZE + proc_buf_size); if (!mp->cb.buf) From ab0314399a26b470d7f601a69649f7ce7975d1c0 Mon Sep 17 00:00:00 2001 From: Rolf Bensch Date: Tue, 22 Oct 2019 19:32:07 +0200 Subject: [PATCH 6/6] pixma_mp810: rename => pixma_mp800 1st ccd scanner in pixma_mp810 is MP800 --- backend/Makefile.am | 2 +- backend/pixma.h | 2 +- backend/pixma_common.c | 4 ++-- backend/{pixma_mp810.c => pixma_mp800.c} | 6 +++--- backend/pixma_rename.h | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) rename backend/{pixma_mp810.c => pixma_mp800.c} (99%) diff --git a/backend/Makefile.am b/backend/Makefile.am index c9dac45a9..95714080c 100644 --- a/backend/Makefile.am +++ b/backend/Makefile.am @@ -865,7 +865,7 @@ libsane_pint_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=pint libsane_pint_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_pint_la_LIBADD = $(COMMON_LIBS) libpint.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo -libpixma_la_SOURCES = pixma.c pixma.h pixma_io_sanei.c pixma_io.h pixma_common.c pixma_common.h pixma_mp150.c pixma_mp730.c pixma_mp750.c pixma_mp810.c pixma_imageclass.c pixma_bjnp.c pixma_bjnp.h pixma_bjnp_private.h pixma_rename.h +libpixma_la_SOURCES = pixma.c pixma.h pixma_io_sanei.c pixma_io.h pixma_common.c pixma_common.h pixma_mp150.c pixma_mp730.c pixma_mp750.c pixma_mp800.c pixma_imageclass.c pixma_bjnp.c pixma_bjnp.h pixma_bjnp_private.h pixma_rename.h libpixma_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=pixma nodist_libsane_pixma_la_SOURCES = pixma-s.c diff --git a/backend/pixma.h b/backend/pixma.h index 93cdf9c9f..572ff6774 100644 --- a/backend/pixma.h +++ b/backend/pixma.h @@ -313,7 +313,7 @@ struct pixma_scan_param_t /** Flag indicating whether the offset correction for TPU scans * was already performed (to avoid repeated corrections). - * Currently only used in pixma_mp810.c sub-driver */ + * Currently only used in pixma_mp800.c sub-driver */ unsigned tpu_offset_added; /* Flag indicating if data from scanner will be in JPEG format */ diff --git a/backend/pixma_common.c b/backend/pixma_common.c index 82c4fde55..22f093e9e 100644 --- a/backend/pixma_common.c +++ b/backend/pixma_common.c @@ -69,14 +69,14 @@ extern const pixma_config_t pixma_mp150_devices[]; extern const pixma_config_t pixma_mp750_devices[]; extern const pixma_config_t pixma_mp730_devices[]; -extern const pixma_config_t pixma_mp810_devices[]; +extern const pixma_config_t pixma_mp800_devices[]; extern const pixma_config_t pixma_iclass_devices[]; static const pixma_config_t *const pixma_devices[] = { pixma_mp150_devices, pixma_mp750_devices, pixma_mp730_devices, - pixma_mp810_devices, + pixma_mp800_devices, pixma_iclass_devices, NULL }; diff --git a/backend/pixma_mp810.c b/backend/pixma_mp800.c similarity index 99% rename from backend/pixma_mp810.c rename to backend/pixma_mp800.c index c81f35daa..d8d3d71b2 100644 --- a/backend/pixma_mp810.c +++ b/backend/pixma_mp800.c @@ -2363,7 +2363,7 @@ static int mp810_get_status (pixma_t * s, pixma_device_status_t * status) return 0; } -static const pixma_scan_ops_t pixma_mp810_ops = +static const pixma_scan_ops_t pixma_mp800_ops = { mp810_open, mp810_close, @@ -2380,7 +2380,7 @@ static const pixma_scan_ops_t pixma_mp810_ops = model, /* model */ \ CANON_VID, pid, /* vid pid */ \ 0, /* iface */ \ - &pixma_mp810_ops, /* ops */ \ + &pixma_mp800_ops, /* ops */ \ dpi, 2*(dpi), /* xdpi, ydpi */ \ adftpu_min_dpi, adftpu_max_dpi, /* adftpu_min_dpi, adftpu_max_dpi */ \ tpuir_min_dpi, tpuir_max_dpi, /* tpuir_min_dpi, tpuir_max_dpi */ \ @@ -2394,7 +2394,7 @@ static const pixma_scan_ops_t pixma_mp810_ops = #define END_OF_DEVICE_LIST DEVICE(NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0) -const pixma_config_t pixma_mp810_devices[] = +const pixma_config_t pixma_mp800_devices[] = { /* Generation 1: CCD */ DEVICE ("Canon PIXMA MP800", "MP800", MP800_PID, 2400, 150, 0, 0, 0, 638, 877, PIXMA_CAP_CCD | PIXMA_CAP_TPU), diff --git a/backend/pixma_rename.h b/backend/pixma_rename.h index ce68ed39e..ad3d96025 100644 --- a/backend/pixma_rename.h +++ b/backend/pixma_rename.h @@ -81,7 +81,7 @@ #define pixma_mp150_devices sanei_pixma_mp150_devices #define pixma_mp730_devices sanei_pixma_mp730_devices #define pixma_mp750_devices sanei_pixma_mp750_devices -#define pixma_mp810_devices sanei_pixma_mp810_devices +#define pixma_mp800_devices sanei_pixma_mp800_devices #define pixma_iclass_devices sanei_pixma_iclass_devices #define pixma_newcmd sanei_pixma_newcmd #define pixma_open sanei_pixma_open