mitsu70x: Distinguish between jobs that we processed vs those submitted as raw

The library code to write the image data to the printer reverses the
row data in the buffer, but pre-rendered jobs are already in the
correct order.
This commit is contained in:
Solomon Peachy 2024-03-18 08:44:58 -04:00
parent ee741aa9f6
commit 23019c1558
1 changed files with 21 additions and 9 deletions

View File

@ -1733,7 +1733,7 @@ top:
return CUPS_BACKEND_OK;
}
static int d70_library_callback(void *context, void *buffer, uint32_t len)
static int d70_library_dout_callback(void *context, void *buffer, uint32_t len)
{
uint32_t chunk = len;
uint32_t offset = 0;
@ -1870,7 +1870,7 @@ static int mitsu70x_main_loop(void *vctx, const void *vjob, int wait_for_return)
ret = be16_to_cpu(hdr->lamcols) * be16_to_cpu(hdr->lamrows) * 2;
memset(job->databuf + job->datalen, 0, job->matte - ret);
}
job->raw_format = 1;
job->raw_format = 2;
bypass:
/* Bypass */
@ -2076,13 +2076,25 @@ top:
sizeof(struct mitsu70x_hdr))))
return CUPS_BACKEND_FAILED;
/* Library handles sending data -- in REVERSE row order! */
if (ctx->lib.SendImageData(&ctx->output, ctx, d70_library_callback))
return CUPS_BACKEND_FAILED;
if (job->matte)
if (d70_library_callback(ctx, job->databuf + job->datalen - job->matte, job->matte))
if (job->raw_format == 2) {
/* When we use the library to generate raw data, it needs to be
sent in reverse row order, so use the library to _send_ it too */
if (ctx->lib.SendImageData(&ctx->output, ctx, d70_library_dout_callback))
return CUPS_BACKEND_FAILED;
if (job->matte)
if (d70_library_dout_callback(ctx, job->databuf + job->datalen - job->matte, job->matte))
return CUPS_BACKEND_FAILED;
} else {
/* Pre-rendered jobs are already in the correct row order,
so we can send the data ourselves. Note that K60 and EK305
need data sent in 256K chunks, but the first chunk is
reduced by the length of the 512-byte header */
int chunk = CHUNK_LEN - sizeof(struct mitsu70x_hdr);
int sent = sizeof(struct mitsu70x_hdr);
d70_library_dout_callback(ctx, job->databuf + sent, chunk);
sent += chunk;
d70_library_dout_callback(ctx, job->databuf + sent, job->datalen - sent);
}
/* Then wait for completion, if so desired.. */
INFO("Waiting for printer to acknowledge completion\n");
@ -2603,7 +2615,7 @@ static const char *mitsu70x_prefixes[] = {
/* Exported */
const struct dyesub_backend mitsu70x_backend = {
.name = "Mitsubishi CP-D70 family",
.version = "0.111" " (lib " LIBMITSU_VER ")",
.version = "0.112" " (lib " LIBMITSU_VER ")",
.flags = BACKEND_FLAG_DUMMYPRINT,
.uri_prefixes = mitsu70x_prefixes,
.cmdline_usage = mitsu70x_cmdline,