diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2020-02-29 00:04:43 -0500 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2020-02-29 00:04:43 -0500 |
commit | 83ab376540512fe48ae13cf8c7f75ce917bff88b (patch) | |
tree | b6dc3d554d7f8568b46ddf34a2ffbbb5c1e4318f /backend_mitsud90.c | |
parent | be8cf539f085c1a185050c2dbbc823d1eee9755b (diff) | |
download | selphy_print-83ab376540512fe48ae13cf8c7f75ce917bff88b.tar.gz selphy_print-83ab376540512fe48ae13cf8c7f75ce917bff88b.tar.bz2 selphy_print-83ab376540512fe48ae13cf8c7f75ce917bff88b.zip |
mitsu_m1: More fixes with job parsing
Diffstat (limited to 'backend_mitsud90.c')
-rw-r--r-- | backend_mitsud90.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/backend_mitsud90.c b/backend_mitsud90.c index 4584104..66a5da5 100644 --- a/backend_mitsud90.c +++ b/backend_mitsud90.c @@ -736,14 +736,30 @@ static int mitsud90_read_parse(void *vctx, const void **vjob, int data_fd, int c return CUPS_BACKEND_CANCEL; } + /* More sanity checks */ + if (job->hdr.pano.pano_on && ctx->type != P_MITSU_M1) { + ERROR("Unable to handle panorama jobs yet\n"); + mitsud90_cleanup_job(job); + return CUPS_BACKEND_CANCEL; + } + + /* How many pixels do we need to read? */ + remain = be16_to_cpu(job->hdr.cols) * be16_to_cpu(job->hdr.rows) * 3; + if (ctx->type == P_MITSU_M1) { // check header for special TBD flag job->is_raw = 1; // XXX fixed for now. // clear TBD flag in header.. + + /* If it's a raw M1 job, the pixels are 2 bytes each */ + if (job->is_raw) + remain *= 2; } + /* Add in the plane header */ + remain += sizeof(struct mitsud90_plane_hdr); + /* Now read in the rest */ - remain = sizeof(struct mitsud90_plane_hdr) + be16_to_cpu(job->hdr.cols) * be16_to_cpu(job->hdr.rows) * 3; while(remain) { i = read(data_fd, job->databuf + job->datalen, remain); if (i == 0) { @@ -758,7 +774,7 @@ static int mitsud90_read_parse(void *vctx, const void **vjob, int data_fd, int c remain -= i; } - /* Read in the footer. Hopefully. */ + /* Read in the footer. Hopefully... */ remain = sizeof(struct mitsud90_job_footer); i = read(data_fd, job->databuf + job->datalen, remain); if (i == 0) { @@ -782,13 +798,6 @@ static int mitsud90_read_parse(void *vctx, const void **vjob, int data_fd, int c ctx->holdover_on = 0; } - /* Sanity check */ - if (job->hdr.pano.pano_on && ctx->type != P_MITSU_M1) { - ERROR("Unable to handle panorama jobs yet\n"); - mitsud90_cleanup_job(job); - return CUPS_BACKEND_CANCEL; - } - /* CP-M1 has... other considerations */ if (ctx->type == P_MITSU_M1 && !job->is_raw) { if (!ctx->lib.dl_handle) { @@ -1601,7 +1610,7 @@ static const char *mitsud90_prefixes[] = { /* Exported */ struct dyesub_backend mitsud90_backend = { .name = "Mitsubishi CP-D90/CP-M1", - .version = "0.20" " (lib " LIBMITSU_VER ")", + .version = "0.21" " (lib " LIBMITSU_VER ")", .uri_prefixes = mitsud90_prefixes, .cmdline_arg = mitsud90_cmdline_arg, .cmdline_usage = mitsud90_cmdline, |