Merge branch 'mf4660_1'

merge-requests/1/head
Nicolas Martin 2009-09-05 10:49:43 +02:00
commit 9b870096e0
1 zmienionych plików z 37 dodań i 26 usunięć

Wyświetl plik

@ -247,32 +247,36 @@ send_scan_param (pixma_t * s)
static int static int
request_image_block (pixma_t * s, unsigned flag, uint8_t * info, request_image_block (pixma_t * s, unsigned flag, uint8_t * info,
unsigned *size) unsigned * size, uint8_t * data, unsigned * datalen)
{ {
iclass_t *mf = (iclass_t *) s->subdriver; iclass_t *mf = (iclass_t *) s->subdriver;
int error; int error;
unsigned expected_len;
const int hlen = 2 + 6;
memset (mf->cb.buf, 0, 11); memset (mf->cb.buf, 0, 11);
pixma_set_be16 (cmd_read_image, mf->cb.buf); pixma_set_be16 (cmd_read_image, mf->cb.buf);
mf->cb.buf[8] = flag; mf->cb.buf[8] = flag;
mf->cb.buf[10] = 0x06; mf->cb.buf[10] = 0x06;
mf->cb.reslen = pixma_cmd_transaction (s, mf->cb.buf, 11, mf->cb.buf, 8); expected_len = (s->cfg->pid == MF4600_PID) ? 512 : hlen;
mf->cb.expected_reslen = 0; mf->cb.reslen = pixma_cmd_transaction (s, mf->cb.buf, 11, mf->cb.buf, expected_len);
error = pixma_check_result (&mf->cb); if (mf->cb.reslen >= hlen)
if (error >= 0)
{ {
if (mf->cb.reslen == 8) *info = mf->cb.buf[2];
{ *size = pixma_get_be16 (mf->cb.buf + 6); /* 16bit size */
*info = mf->cb.buf[2]; error = 0;
*size = pixma_get_be16 (mf->cb.buf + 6);
/* could it be 32bit? */ if (s->cfg->pid == MF4600_PID)
/* *size = pixma_get_be32 (mf->cb.buf + 4); */ { /* 32bit size */
} *datalen = mf->cb.reslen - hlen;
else *size = (*datalen + hlen == 512) ? pixma_get_be32 (mf->cb.buf + 4) - *datalen : 0;
{ memcpy (data, mf->cb.buf + hlen, *datalen);
error = PIXMA_EPROTO;
} }
} }
else
{
error = PIXMA_EPROTO;
}
return error; return error;
} }
@ -280,11 +284,13 @@ static int
read_image_block (pixma_t * s, uint8_t * data, unsigned size) read_image_block (pixma_t * s, uint8_t * data, unsigned size)
{ {
int error; int error;
unsigned chunksize, count = 0; unsigned maxchunksize, chunksize, count = 0;
maxchunksize = MAX_CHUNK_SIZE * ((s->cfg->pid == MF4600_PID) ? 4 : 1);
while (size) while (size)
{ {
if (size >= MAX_CHUNK_SIZE) if (size >= maxchunksize)
chunksize = MAX_CHUNK_SIZE; chunksize = maxchunksize;
else if (size < MIN_CHUNK_SIZE) else if (size < MIN_CHUNK_SIZE)
chunksize = size; chunksize = size;
else else
@ -492,7 +498,7 @@ iclass_scan (pixma_t * s)
if (error >= 0) if (error >= 0)
error = send_scan_param (s); error = send_scan_param (s);
if (error >= 0) if (error >= 0)
error = request_image_block (s, 0, &ignore, &ignore2); error = request_image_block (s, 0, &ignore, &ignore2, &ignore, &ignore2);
if (error < 0) if (error < 0)
{ {
iclass_finish_scan (s); iclass_finish_scan (s);
@ -508,7 +514,7 @@ iclass_fill_buffer (pixma_t * s, pixma_imagebuf_t * ib)
{ {
int error, n; int error, n;
iclass_t *mf = (iclass_t *) s->subdriver; iclass_t *mf = (iclass_t *) s->subdriver;
unsigned block_size, lines_size; unsigned block_size, lines_size, first_block_size;
uint8_t info; uint8_t info;
/* /*
@ -530,7 +536,11 @@ iclass_fill_buffer (pixma_t * s, pixma_imagebuf_t * ib)
return 0; return 0;
} }
error = request_image_block (s, 4, &info, &block_size); first_block_size = 0;
error = request_image_block (s, 4, &info, &block_size,
mf->blkptr + mf->blk_len, &first_block_size);
/* add current block to remainder of previous */
mf->blk_len += first_block_size;
if (error < 0) if (error < 0)
{ {
/* NOTE: seen in traffic logs but don't know the meaning. */ /* NOTE: seen in traffic logs but don't know the meaning. */
@ -554,7 +564,7 @@ iclass_fill_buffer (pixma_t * s, pixma_imagebuf_t * ib)
handle_interrupt (s, 100); handle_interrupt (s, 100);
} }
} }
while (block_size == 0); while (block_size == 0 && first_block_size == 0);
error = read_image_block (s, mf->blkptr + mf->blk_len, block_size); error = read_image_block (s, mf->blkptr + mf->blk_len, block_size);
block_size = error; block_size = error;
@ -567,9 +577,10 @@ iclass_fill_buffer (pixma_t * s, pixma_imagebuf_t * ib)
n = mf->blk_len / s->param->line_size; n = mf->blk_len / s->param->line_size;
if (n != 0) if (n != 0)
{ {
if (s->param->channels != 1) if (s->param->channels != 1 &&
s->cfg->pid != MF4600_PID)
{ {
/* color */ /* color and not MF46xx */
pack_rgb (mf->blkptr, n, mf->raw_width, mf->lineptr); pack_rgb (mf->blkptr, n, mf->raw_width, mf->lineptr);
} }
else else
@ -579,8 +590,8 @@ iclass_fill_buffer (pixma_t * s, pixma_imagebuf_t * ib)
} }
lines_size = n * s->param->line_size; lines_size = n * s->param->line_size;
/* cull remainder and shift left */ /* cull remainder and shift left */
mf->blk_len -= block_size; mf->blk_len -= lines_size;
memcpy (mf->blkptr, mf->blkptr + block_size, mf->blk_len); memcpy (mf->blkptr, mf->blkptr + lines_size, mf->blk_len);
} }
} }
while (n == 0); while (n == 0);