From c4f0d4505e7d35185f675eadd90f8c8e1680eea8 Mon Sep 17 00:00:00 2001 From: Rolf Bensch Date: Wed, 24 Jun 2020 16:58:36 +0200 Subject: [PATCH 1/5] pixma_mp150: enable 48bit support for LiDE 400 --- backend/pixma/pixma_mp150.c | 45 ++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/backend/pixma/pixma_mp150.c b/backend/pixma/pixma_mp150.c index 88c8ea078..a7b37b12e 100644 --- a/backend/pixma/pixma_mp150.c +++ b/backend/pixma/pixma_mp150.c @@ -1225,19 +1225,38 @@ mp150_check_param (pixma_t * s, pixma_scan_param_t * sp) /* PDBG (pixma_dbg (4, "*mp150_check_param***** Initially: channels=%u, depth=%u, x=%u, y=%u, w=%u, h=%u, xs=%u, wx=%u, gamma=%f *****\n", sp->channels, sp->depth, sp->x, sp->y, sp->w, sp->h, sp->xs, sp->wx, sp->gamma)); */ - /* MP150 only supports 8 bit per channel in color and grayscale mode */ - if (sp->depth != 1) - { - sp->software_lineart = 0; - sp->depth = 8; - } - else - { - /* software lineart */ - sp->software_lineart = 1; - sp->depth = 1; + sp->channels = 3; + sp->software_lineart = 0; + switch (sp->mode) + { + /* standard scan modes + * 8 bit per channel in color and grayscale mode */ + case PIXMA_SCAN_MODE_GRAY: sp->channels = 1; - } + /* fall through */ + case PIXMA_SCAN_MODE_COLOR: + sp->depth = 8; + break; + /* extended scan modes for 48 bit flatbed scanners + * 16 bit per channel in color and grayscale mode */ + case PIXMA_SCAN_MODE_GRAY_16: + sp->channels = 1; + sp->depth = 16; + break; + case PIXMA_SCAN_MODE_COLOR_48: + sp->channels = 3; + sp->depth = 16; + break; + /* software lineart + * 1 bit per channel */ + case PIXMA_SCAN_MODE_LINEART: + sp->software_lineart = 1; + sp->channels = 1; + sp->depth = 1; + break; + default: + break; + } /* for software lineart w must be a multiple of 8 */ if (sp->software_lineart == 1 && sp->w % 8) @@ -1774,7 +1793,7 @@ const pixma_config_t pixma_mp150_devices[] = { DEVICE ("Canon PIXMA TR8500 Series", "TR8500", TR8500_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF | PIXMA_CAP_ADF_JPEG), DEVICE ("Canon PIXMA TR7500 Series", "TR7500", TR7500_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA TS9500 Series", "TS9500", TS9500_PID, 0, 1200, 0, 600, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), - DEVICE ("CanoScan LiDE 400", "LIDE400", LIDE400_PID, 300, 4800, 0, 0, 638, 877, PIXMA_CAP_CIS), + DEVICE ("CanoScan LiDE 400", "LIDE400", LIDE400_PID, 300, 4800, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_48BIT), DEVICE ("CanoScan LiDE 300", "LIDE300", LIDE300_PID, 300, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), /* Latest devices (2019) Generation 5 CIS */ From b0efdd89cbb4a6869d03629a2b5fb6cee16f955a Mon Sep 17 00:00:00 2001 From: Rolf Bensch Date: Mon, 6 Jul 2020 23:04:59 +0200 Subject: [PATCH 2/5] pixma_mp150: scan 48bit color and convert --- backend/pixma/pixma_mp150.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/backend/pixma/pixma_mp150.c b/backend/pixma/pixma_mp150.c index a7b37b12e..ccd7075f5 100644 --- a/backend/pixma/pixma_mp150.c +++ b/backend/pixma/pixma_mp150.c @@ -633,6 +633,12 @@ calc_raw_width (const mp150_t * mp, const pixma_scan_param_t * param) return raw_width; } +static int +is_gray_16 (pixma_t * s) +{ + return (s->param->mode == PIXMA_SCAN_MODE_GRAY_16); +} + static unsigned get_cis_line_size (pixma_t * s) { @@ -642,7 +648,9 @@ get_cis_line_size (pixma_t * s) __func__, s->param->line_size, s->param->w, s->param->wx, mp->scale));*/ return (s->param->wx ? s->param->line_size / s->param->w * s->param->wx - : s->param->line_size) * mp->scale; + : s->param->line_size) + * mp->scale + * (is_gray_16(s) ? 3 : 1); } static int @@ -707,10 +715,12 @@ send_scan_param (pixma_t * s) pixma_set_be32 (y, data + 0x10); pixma_set_be32 (wx, data + 0x14); pixma_set_be32 (h, data + 0x18); - data[0x1c] = (s->param->channels != 1) ? 0x08 : 0x04; + /*PDBG (pixma_dbg (4, "*send_scan_param gen. 3+ ***** Setting: channels=%hi depth=%hi ***** \n", + s->param->channels, s->param->depth));*/ + data[0x1c] = ((s->param->channels != 1) || (is_gray_16(s)) ? 0x08 : 0x04); data[0x1d] = ((s->param->software_lineart) ? 8 : s->param->depth) - * s->param->channels; /* bits per pixel */ + * (is_gray_16(s) ? 3 : 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; @@ -1066,7 +1076,7 @@ post_process_image_data (pixma_t * s, pixma_imagebuf_t * ib) } /* process image sizes */ - c = s->param->channels + c = (is_gray_16(s) ? 3 : s->param->channels) * ((s->param->software_lineart) ? 8 : s->param->depth) / 8; /* color channels count */ cw = c * s->param->w; /* image width */ cx = c * s->param->xs; /* x-offset */ @@ -1140,6 +1150,9 @@ 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 16bit gray */ + else if (is_gray_16(s)) + cptr = gptr = pixma_rgb_to_gray (gptr, cptr, s->param->w, c); else cptr += cw; } From 0f1850fe4fbb019f87aa62e94168b41a8faf459d Mon Sep 17 00:00:00 2001 From: Rolf Bensch Date: Mon, 6 Jul 2020 22:30:28 +0200 Subject: [PATCH 3/5] pixma: new parameter to set min. xdpi for 16-bit scans 16-bit scans have different min. scan resolutions: 75 and 150dpi --- backend/pixma/pixma.h | 3 ++- backend/pixma/pixma_imageclass.c | 2 +- backend/pixma/pixma_mp150.c | 1 + backend/pixma/pixma_mp730.c | 2 +- backend/pixma/pixma_mp750.c | 2 +- backend/pixma/pixma_mp800.c | 31 ++++++++++++++++--------------- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/backend/pixma/pixma.h b/backend/pixma/pixma.h index d23ca9a8c..4a77ef456 100644 --- a/backend/pixma/pixma.h +++ b/backend/pixma/pixma.h @@ -372,7 +372,8 @@ struct pixma_config_t uint16_t pid; /**< USB Product ID */ unsigned iface; /**< USB Interface number */ const pixma_scan_ops_t *ops; /**< Subdriver ops */ - unsigned min_xdpi; /**< Minimum horizontal resolution[DPI] */ + unsigned min_xdpi; /**< Minimum horizontal resolution[DPI] */ + unsigned min_xdpi_16;/**< Minimum horizontal resolution[DPI] for 16-bit scans */ unsigned xdpi; /**< Maximum horizontal resolution[DPI] */ unsigned ydpi; /**< Maximum vertical resolution[DPI] */ unsigned adftpu_min_dpi; /**< Maximum horizontal resolution[DPI] for adf/tpu diff --git a/backend/pixma/pixma_imageclass.c b/backend/pixma/pixma_imageclass.c index 737816826..be483b2a4 100644 --- a/backend/pixma/pixma_imageclass.c +++ b/backend/pixma/pixma_imageclass.c @@ -917,7 +917,7 @@ static const pixma_scan_ops_t pixma_iclass_ops = { 0x04a9, pid, /* vid pid */ \ 1, /* iface */ \ &pixma_iclass_ops, /* ops */ \ - 0, /* min_xdpi not used in this subdriver */ \ + 0, 0, /* min_xdpi & min_xdpi_16 not used in this subdriver */ \ dpi, dpi, /* xdpi, ydpi */ \ 0, /* adftpu_min_dpi not used in this subdriver */ \ adftpu_max_dpi, /* adftpu_max_dpi */ \ diff --git a/backend/pixma/pixma_mp150.c b/backend/pixma/pixma_mp150.c index ccd7075f5..0710f2e5e 100644 --- a/backend/pixma/pixma_mp150.c +++ b/backend/pixma/pixma_mp150.c @@ -1632,6 +1632,7 @@ static const pixma_scan_ops_t pixma_mp150_ops = { 0, /* iface */ \ &pixma_mp150_ops, /* ops */ \ min_dpi, /* min_xdpi */ \ + 0, /* min_xdpi_16 not used in this subdriver */ \ dpi, 2*(dpi), /* xdpi, ydpi */ \ adftpu_min_dpi, adftpu_max_dpi, /* adftpu_min_dpi, adftpu_max_dpi */ \ 0, 0, /* tpuir_min_dpi & tpuir_max_dpi not used in this subdriver */ \ diff --git a/backend/pixma/pixma_mp730.c b/backend/pixma/pixma_mp730.c index 7b3d6532f..fcc9ae874 100644 --- a/backend/pixma/pixma_mp730.c +++ b/backend/pixma/pixma_mp730.c @@ -815,7 +815,7 @@ static const pixma_scan_ops_t pixma_mp730_ops = { 0x04a9, pid, /* vid pid */ \ 1, /* iface */ \ &pixma_mp730_ops, /* ops */ \ - 0, /* min_xdpi not used in this subdriver */ \ + 0, 0, /* min_xdpi & min_xdpi_16 not used in this subdriver */ \ dpi, dpi, /* xdpi, ydpi */ \ 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 */ \ diff --git a/backend/pixma/pixma_mp750.c b/backend/pixma/pixma_mp750.c index 3d790efc4..cc1c3ad63 100644 --- a/backend/pixma/pixma_mp750.c +++ b/backend/pixma/pixma_mp750.c @@ -955,7 +955,7 @@ static const pixma_scan_ops_t pixma_mp750_ops = { 0x04a9, pid, /* vid pid */ \ 0, /* iface */ \ &pixma_mp750_ops, /* ops */ \ - 0, /* min_xdpi not used in this subdriver */ \ + 0, 0, /* min_xdpi & min_xdpi_16 not used in this subdriver */ \ dpi, 2*(dpi), /* xdpi, ydpi */ \ 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 */ \ diff --git a/backend/pixma/pixma_mp800.c b/backend/pixma/pixma_mp800.c index 3fa9d074b..b7cde8a4c 100644 --- a/backend/pixma/pixma_mp800.c +++ b/backend/pixma/pixma_mp800.c @@ -2375,13 +2375,14 @@ static const pixma_scan_ops_t pixma_mp800_ops = mp810_get_status }; -#define DEVICE(name, model, pid, dpi, adftpu_min_dpi, adftpu_max_dpi, tpuir_min_dpi, tpuir_max_dpi, w, h, cap) { \ +#define DEVICE(name, model, pid, min_dpi_16, dpi, adftpu_min_dpi, adftpu_max_dpi, tpuir_min_dpi, tpuir_max_dpi, w, h, cap) { \ name, /* name */ \ model, /* model */ \ CANON_VID, pid, /* vid pid */ \ 0, /* iface */ \ &pixma_mp800_ops, /* ops */ \ 0, /* min_xdpi not used in this subdriver */ \ + min_dpi_16, /* min_xdpi_16 */ \ 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 */ \ @@ -2393,42 +2394,42 @@ static const pixma_scan_ops_t pixma_mp800_ops = PIXMA_CAP_GAMMA_TABLE|PIXMA_CAP_EVENTS|cap \ } -#define END_OF_DEVICE_LIST DEVICE(NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0) +#define END_OF_DEVICE_LIST DEVICE(NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) 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_TPU | PIXMA_CAP_GT_4096), - DEVICE ("Canon PIXMA MP800R", "MP800R", MP800R_PID, 2400, 150, 0, 0, 0, 638, 877, PIXMA_CAP_TPU | PIXMA_CAP_GT_4096), - DEVICE ("Canon PIXMA MP830", "MP830", MP830_PID, 2400, 150, 0, 0, 0, 638, 877, PIXMA_CAP_ADFDUP | PIXMA_CAP_GT_4096), + DEVICE ("Canon PIXMA MP800", "MP800", MP800_PID, 0, 2400, 150, 0, 0, 0, 638, 877, PIXMA_CAP_TPU | PIXMA_CAP_GT_4096), + DEVICE ("Canon PIXMA MP800R", "MP800R", MP800R_PID, 0, 2400, 150, 0, 0, 0, 638, 877, PIXMA_CAP_TPU | PIXMA_CAP_GT_4096), + DEVICE ("Canon PIXMA MP830", "MP830", MP830_PID, 0, 2400, 150, 0, 0, 0, 638, 877, PIXMA_CAP_ADFDUP | PIXMA_CAP_GT_4096), /* 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), + DEVICE ("Canon PIXMA MP810", "MP810", MP810_PID, 0, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_TPU), + DEVICE ("Canon PIXMA MP960", "MP960", MP960_PID, 0, 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_TPU), + DEVICE ("Canon Pixma MP970", "MP970", MP970_PID, 0, 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_TPU /*| PIXMA_CAP_NEGATIVE*/ | PIXMA_CAP_48BIT), + DEVICE ("Canoscan 8800F", "8800F", CS8800F_PID, 150, 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_TPU), + DEVICE ("Canon MP980 series", "MP980", MP980_PID, 0, 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_TPU), + DEVICE ("Canon MP990 series", "MP990", MP990_PID, 0, 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_TPUIR /*| PIXMA_CAP_NEGATIVE*/ | PIXMA_CAP_48BIT), + DEVICE ("Canoscan 9000F", "9000F", CS9000F_PID, 150, 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_TPU), + DEVICE ("Canon PIXMA MG8100", "MG8100", MG8100_PID, 0, 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_TPU), + DEVICE ("Canon PIXMA MG8200", "MG8200", MG8200_PID, 0, 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_TPUIR | PIXMA_CAP_48BIT), + DEVICE ("Canoscan 9000F Mark II", "9000FMarkII", CS9000F_MII_PID, 150, 4800, 300, 9600, 600, 2400, 638, 877, PIXMA_CAP_TPUIR | PIXMA_CAP_48BIT), END_OF_DEVICE_LIST }; From 3a18629f1190d78c48241e061448d8d500a50c41 Mon Sep 17 00:00:00 2001 From: Rolf Bensch Date: Mon, 6 Jul 2020 22:31:48 +0200 Subject: [PATCH 4/5] pixma: in dpi list set min. scan resolution for 16-bit scans --- backend/pixma/pixma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/pixma/pixma.c b/backend/pixma/pixma.c index d7b7d5df0..fbea2a8e8 100644 --- a/backend/pixma/pixma.c +++ b/backend/pixma/pixma.c @@ -470,7 +470,7 @@ create_dpi_list (pixma_sane_t * ss) || ss->mode_map[OVAL (opt_mode).w] == PIXMA_SCAN_MODE_GRAY_16)) { /* 48 bits flatbed */ /*PDBG (pixma_dbg (4, "*create_dpi_list***** 48 bits flatbed mode\n"));*/ - min_dpi = 150; + min_dpi = (cfg->min_xdpi_16) ? cfg->min_xdpi_16 : 75; } /* set j for min. dpi From 8f93b4cc622c002b8b1dea63b1a210fc6dbfa210 Mon Sep 17 00:00:00 2001 From: Rolf Bensch Date: Mon, 6 Jul 2020 22:36:25 +0200 Subject: [PATCH 5/5] pixma_mp800: remove TODO for 16-bit scans mp800 scanners need min. 150dpi for 16-bit scans --- backend/pixma/pixma_mp800.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/backend/pixma/pixma_mp800.c b/backend/pixma/pixma_mp800.c index b7cde8a4c..942a45dea 100644 --- a/backend/pixma/pixma_mp800.c +++ b/backend/pixma/pixma_mp800.c @@ -2066,9 +2066,7 @@ static int mp810_check_param (pixma_t * s, pixma_scan_param_t * sp) k = MAX (sp->xdpi, 300) / sp->xdpi; else if (sp->source == PIXMA_SOURCE_TPU || sp->mode == PIXMA_SCAN_MODE_COLOR_48 || sp->mode == PIXMA_SCAN_MODE_GRAY_16) - /* TPU mode and 16 bit flatbed scans - * TODO: either the frontend (xsane) cannot handle 48 bit flatbed scans @ 75 dpi (prescan) - * or there is a bug in this subdriver */ + /* TPU mode and 16 bit flatbed scans */ k = MAX (sp->xdpi, 150) / sp->xdpi; else /* default */