Merge branch 'pixma/separate_ccd_from_cis'

merge-requests/224/head
Rolf Bensch 2019-10-22 19:40:06 +02:00
commit 7db4449fa0
7 zmienionych plików z 104 dodań i 367 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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 */

Wyświetl plik

@ -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
};

Wyświetl plik

@ -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 <stdio.h>
@ -101,9 +97,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
@ -336,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
@ -355,15 +342,10 @@ 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;
@ -441,12 +423,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)
{
@ -466,19 +442,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);
}
@ -487,17 +457,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);
}
@ -545,13 +506,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)
{
@ -579,40 +533,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)
{
@ -684,82 +610,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));
}
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)
{
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;
}
return (2 * mp->color_shift + mp->stripe_shift);
return (s->param->wx ? s->param->line_size / s->param->w * s->param->wx
: s->param->line_size);
}
static int
@ -768,14 +623,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),
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;
}
unsigned h = s->cfg->height * s->param->ydpi / 75;
if (mp->generation <= 2)
{
@ -790,10 +638,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;
@ -804,12 +652,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))
{
@ -832,15 +674,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;
@ -1075,32 +912,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)
{
@ -1115,8 +926,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)
{
@ -1128,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)
@ -1165,32 +951,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)
{
@ -1207,14 +970,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)
@ -1222,26 +985,19 @@ 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;
/*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 */
@ -1269,9 +1025,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;
}
@ -1327,9 +1080,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;
@ -1337,8 +1087,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;
}
@ -1367,12 +1115,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
{
@ -1415,17 +1157,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;
@ -1531,33 +1269,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)
@ -1590,17 +1301,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 */
@ -1642,8 +1349,8 @@ 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);
proc_buf_size = (2 * calc_shifting (s) + 2) * line_size;
line_size = get_cis_line_size (s);
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)
@ -1696,15 +1403,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);
@ -1729,9 +1427,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)
@ -1803,7 +1498,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 \
}
@ -1818,11 +1513,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),
@ -1880,14 +1570,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),

Wyświetl plik

@ -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)
};

Wyświetl plik

@ -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;
@ -2323,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,
@ -2340,11 +2380,12 @@ 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 */ \
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 */ \
@ -2353,35 +2394,40 @@ 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),
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_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
};

Wyświetl plik

@ -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