summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2018-01-21 21:36:29 -0500
committerSolomon Peachy <pizza@shaftnet.org>2018-01-21 21:36:29 -0500
commit91f531c2efdef86006e4732251f6fd36482ff1a6 (patch)
treed671a9aeab7db678b5c88265affe60366b07c7e9
parenta722a18ca01e61b09c85ec23d81e3877fa5e5d67 (diff)
downloadselphy_print-91f531c2efdef86006e4732251f6fd36482ff1a6.tar.gz
selphy_print-91f531c2efdef86006e4732251f6fd36482ff1a6.tar.bz2
selphy_print-91f531c2efdef86006e4732251f6fd36482ff1a6.zip
mitsu9550: Support reading the 9810/9820 lamination data from disk.
...It's how the official mistu drivers do things!
-rw-r--r--Makefile1
-rw-r--r--backend_mitsu9550.c81
-rw-r--r--lib70x/data/M98MATTE.raw1
3 files changed, 80 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 64f4c4d..2801bd7 100644
--- a/Makefile
+++ b/Makefile
@@ -60,6 +60,7 @@ SOURCES = backend_common.c $(addsuffix .c,$(addprefix backend_,$(BACKENDS)))
# Backend-specific joy:
backend_mitsu70x.o: CPPFLAGS += -DCORRTABLE_PATH=\"$(BACKEND_DATA_DIR)\" -include lib70x/libMitsuD70ImageReProcess.h
+backend_mitsu9550.o: CPPFLAGS += -DCORRTABLE_PATH=\"$(BACKEND_DATA_DIR)\"
# And now the rules!
.PHONY: clean all install cppcheck
diff --git a/backend_mitsu9550.c b/backend_mitsu9550.c
index 08d9958..932bd06 100644
--- a/backend_mitsu9550.c
+++ b/backend_mitsu9550.c
@@ -55,6 +55,17 @@
//#define USB_PID_MITSU_9810D XXXXXX
//#define USB_PID_MITSU_9820DS XXXXXX
+#ifndef CORRTABLE_PATH
+#ifdef PACKAGE_DATA_DIR
+#define CORRTABLE_PATH PACKAGE_DATA_DIR "/backend_data"
+#else
+#error "Must define CORRTABLE_PATH or PACKAGE_DATA_DIR!"
+#endif
+#endif
+
+#define MITSU_M98xx_LAMINATE_FILE CORRTABLE_PATH "M98MATTE.raw"
+#define LAMINATE_STRIDE 1868
+
/* Spool file structures */
/* Print parameters1 */
@@ -63,7 +74,7 @@ struct mitsu9550_hdr1 {
uint8_t unk[10]; /* 00 0a 10 00 [...] */
uint16_t cols; /* BE */
uint16_t rows; /* BE */
- uint8_t matte; /* CP9810 only. 01 for matte, 00 glossy */
+ uint8_t matte; /* CP9810/9820 only. 01 for matte, 00 glossy */
uint8_t null[31];
} __attribute__((packed));
@@ -401,6 +412,11 @@ hdr_done:
return CUPS_BACKEND_FAILED;
}
+ /* Back off the data to read if the backend generates the matte data internally */
+ if (ctx->hdr1.matte == 0x80) {
+ remain -= planelen + sizeof(struct mitsu9550_plane) + sizeof(struct mitsu9550_cmd);
+ }
+
/* Load up the data blocks.*/
while(1) {
/* Note that 'buf' needs to be already filled here! */
@@ -454,7 +470,7 @@ hdr_done:
ctx->datalen += 4;
/* Unless we have a matte plane following, we're done */
- if (!ctx->hdr1.matte)
+ if (ctx->hdr1.matte != 0x01)
break;
planelen = sizeof(buf);
} else {
@@ -479,6 +495,65 @@ hdr_done:
ctx->hdr1.matte = 0;
}
+ /* If the backend has to generate the matte data... */
+ if (ctx->hdr1.matte == 0x80) {
+ int fd;
+ uint32_t j;
+
+ DEBUG("Reading %d bytes of matte data from disk (%d/%d)\n", be16_to_cpu(ctx->hdr1.cols) * be16_to_cpu(ctx->hdr1.rows), be16_to_cpu(ctx->hdr1.cols), LAMINATE_STRIDE);
+ fd = open(MITSU_M98xx_LAMINATE_FILE, O_RDONLY);
+ if (fd < 0) {
+ WARNING("Unable to open matte lamination data file '%s'\n", MITSU_M98xx_LAMINATE_FILE);
+ ctx->hdr1.matte = 0;
+ goto done;
+ }
+
+ /* Fill in the lamination plane header */
+ struct mitsu9550_plane *matte = (struct mitsu9550_plane *)(ctx->databuf + ctx->datalen);
+ matte->cmd[0] = 0x1b;
+ matte->cmd[1] = 0x5a;
+ matte->cmd[2] = 0x54;
+ matte->cmd[3] = 0x10;
+ matte->row_offset = 0;
+ matte->null = 0;
+ matte->cols = ctx->hdr1.cols;
+ matte->rows = ctx->hdr1.rows;
+ ctx->datalen += sizeof(struct mitsu9550_plane);
+
+ /* Read in the matte data plane */
+ for (j = 0 ; j < be16_to_cpu(ctx->hdr1.rows) ; j++) {
+ remain = LAMINATE_STRIDE * 2;
+
+ /* Read one row of lamination data at a time */
+ while (remain) {
+ i = read(fd, ctx->databuf + ctx->datalen, remain);
+ if (i < 0)
+ return CUPS_BACKEND_CANCEL;
+ if (i == 0) {
+ /* We hit EOF, restart from beginning */
+ lseek(fd, 0, SEEK_SET);
+ continue;
+ }
+ ctx->datalen += i;
+ remain -= i;
+ }
+ /* Back off the buffer so we "wrap" on the print row. */
+ ctx->datalen -= ((LAMINATE_STRIDE - ctx->hdr1.cols) * 2);
+ }
+ /* We're done! */
+ close(fd);
+
+ /* Set laminate header to a sane value */
+ ctx->hdr1.matte = 0x01;
+
+ /* Fill in the lamination plane footer */
+ ctx->databuf[ctx->datalen++] = 0x1b;
+ ctx->databuf[ctx->datalen++] = 0x50;
+ ctx->databuf[ctx->datalen++] = 0x56;
+ ctx->databuf[ctx->datalen++] = 0x00;
+ }
+
+done:
return CUPS_BACKEND_OK;
}
@@ -1196,7 +1271,7 @@ static int mitsu9550_cmdline_arg(void *vctx, int argc, char **argv)
/* Exported */
struct dyesub_backend mitsu9550_backend = {
.name = "Mitsubishi CP-9xxx family",
- .version = "0.29",
+ .version = "0.30",
.uri_prefix = "mitsu9550",
.cmdline_usage = mitsu9550_cmdline,
.cmdline_arg = mitsu9550_cmdline_arg,
diff --git a/lib70x/data/M98MATTE.raw b/lib70x/data/M98MATTE.raw
new file mode 100644
index 0000000..af35c7a
--- /dev/null
+++ b/lib70x/data/M98MATTE.raw
@@ -0,0 +1 @@
+33s3c3333c3cSSccSc3cc3cccc3S3c33SS3scccs3ccccc33cc3333S3sc33c3c333c3cccc3c33cscc3c3c3333S3c3333sc33csSc3S333cc33cccc3cc333c333cc33cc333ccS3cccSccS3c33SS3c3c3cc33ccs33scc33sc3c33c3ccc33cS33cc3cc3S3c3cs33scS33cc3cc3c33s3sc3c33c33s333cc33cc3S3c3cc33ccScccc333cc333S333c3sc33cS33333cs3c3c33c3c333sS3ccccccc333STTSTSSSdT4SSS4S4d4S4dTdTSSS4dTSTS4SST4TTSSdTSSTTTTT44dS4ddT4dddSTSTTTSddSSSTSSdTTSTdTS44dSSTdTdTSdSdS4S4TSST44TTdSSSSd4dST4T44TTdd44SSS44d$$ddtdEdEdtt$$d$tdddd$$$ddtdddddd$$ddddd$dd$ddd$ttddddd$ddddt$ddd$dtddt$$$ttdtt$dddtdtd$ddddd$ddttdEEdddtddd$d$$$t$dddddddd$E$t$ddddd$tddEt$dtdtd$$dtEdd$$ddddddddddtEdt$ddt$d$tEddt$ddddEetUtttttUttuetdeeeueeettettttttttUttutueeeeUtedetddettddddtdeetutttutUtteUuuedddeUedteeuttUtdetetttUueudddtettttdutttedduUUedtUdeUuuUuudeUUdtUdtdtUudettdeetteetttttuttteuuttteetteeeutteeeteudddddeddeedd54UUUUU5U4U55UUUUEU555UU454454UUUE55555U5454U4E55U555U554UUU5EUU555U45555U5E4554U554EE55U44EEE5UUUfUU45545U5f5UUU44UU54fUEUU5555E5544UUU55U5EUUUU555445555UU444U55fU55EUUU54UU45U55UUfUUU45555EUEEEEE55U5555U45UUU555U4555U55U55U5UUUU5555fU4UUUUUUUUUUUUUUU45fUU55UUUUU45U44UU4U55UU55U4fU55555EE444UU44UUUU55%tF6VVF6FtVVFFV6ttFFttt%6FtFVF%6%tFF%%FtVV%6F6%%FtF6%tF%%%FtV%%tt%FFFF6FV6%tFt%%6V6tF%t6%tttFV6V6tt%%%%t6tFttV6VF%%tV%FtFVt%tFFFt%F6tV%FFtVFF%%%VFVttFFt6t%%tFVFFFVF%%F%FtFV6VF6VVFFFt%F%t%FeuUeeeUUgUUeeeeeegUeeeeeUUeUUUeeeUeuUuuueuUUUuuuguuUgUUUUUUUeeeeeegeeuueueguueeUUuuuUeeUueeeeeeeeUeeeeUeeUeeeeeUueuUUeUeUUeeeeeeeUUUeeeuuUuuUUUUeueUUUeUeeeeUUFFffffFFfFFfFVfffffFFVffVfFVVFFFfVfffFFFFFfFfVffFVFFFFFfFFFVfFFFFfFfFFFVFVFFFFFFFfFVVFVfFffffFfFFffFFfFffffFFFFfFffFFfVfFFfFFffFFFffFFFfFffFffffffVfFFfFfFfFFVFfffffFFFffFffFfFVffffFfffFFFffFFffFFfffFfFffFfFfVFfFFVfFfFFFFfFFFfffFfFFFfFFWgggggWWggggggWgWWgggggWWgWggggggggggWWggWWggWgWgWggggWggggWWggggggggWgWgWggggggWgWgg&&E&&&&EE&&&E&&&EEE&&&&EEEE&&E&&EEEEE&EE&EEE&EE&&EEEEE&&EEE&EE&E&&&&&&EEE&E&&&EEEEE&EEEF666eF6e666eF666666FFe66e666666ee66e666666e6eF66eeeee66e66FF66FF66FeeFe66e6e6666FFF666e6eF6FF66ee66666666F666e6eF666666e666F66eeFe6FFFe66e6Fe6e66F6e66e6eeee666e6eF66FFFFFF666Fe666F666e6e666666ee66Fee6e6666FFFFFe6FF77GfGfGVG7f777ffGGGffV7G7ffGfGGG7777GffGGG7GGG7fffGf7V7Gf77VG77GGfGfGfGff7fGfff7V7GG7f7777Vfffff77GGfGff77GGGfffGGffff77Gf7ffGGGGGf77GfGG7GGfV777GGfGG77f7V7VfGG77Gf77Gf7ff7GG7VffV77VfGGG77fV7ffGGG77Gf77fff7Gffff77GfVfGGG7VV777777VVfGfG7fGf7ff77fGf777ffGGffGG7fG77VVV7777fGGGfGffGGGG7f7f7GGVV77fffff777GGffff7Gf7777fV7777fV7ffGffG7Vf7f7fVVfG77fGfV7fGGfGVVf77V7GffGGGffGGffGGG7f7777G7Gf777GGGfG7G7VV7G77777V7GGGfGGVVff7fGff77GfGV777fGgwwggwwwwgggwgwwgwwwwwwgwggwwwwgwwwgwggwgggwwwwwggwwwwwwgwgwgwgggggwggwwgwwwwwwwgwwgwwwgggwgwwwwwwgwwgwwwgwwwwgggggwwggggwwwggwwgwwwwgwwwgggwwggggwggwwwggwwwwwwwwgggwwgwwwwwgwwggwwwggwgwwgwwggwwwwwwwggwggwggggggwwggggwgwwwwwwwwwgg'77''''''7''7'&'777777'''7'&'''''7'7&'''77''''777&'&''777&''&''77&7''&77'7'&'&&''''&''&77''&''&&'&7'&''&&&&''7''&'&&'&'7&&'777'&''77''7777'&'777&'&&&&''&777&'&''7'7''''777&77'''&&7'7''7777''''&&'6GGG76G6GGG6G6GG6G6G7GG6G7G6GGG76G77GGGGG677GGG67666G6777776G76GGGG76G6G766G7GGG667GG6GGGG66GG6GG6G6GGGG676GG6GGGGG77GG77G7G6766GG677G66GGGG6G6GGGGGGGG6GGG6G6G66G7767GGG77G66GG67GG777G7GG766GGGGWFWWWFWWFWFWWWWWWWWWWWWFWWWFWFWWWFFFFWWWWFFWWFWWFWFFFWWFWWWWWWWWFWWWWWFWFWWWFWWFFWWFWFWWWFWWWWWWWWWFWFFFWFWWFWWFWWWWWWFWWFWWWWWWWWWFWWWWWFWWWWWFFWFWWFFWWWWWWFWWWWWWWWWWWWWFWWFWWWWFFFWFWFWWWWFWFFWWWWWWWWFFWFFWFFWWWWFFFWWWWWWWWWWWFWWWWWWWFWFWWFFFWWWWWWWWFWWWFWWWWWWWWFFWWWWWFFWFFWWWWWFFFWFWWFWWWFFWFWWWWWWFWWWWFWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWFFWFFWFFFWWWFWWWWFWFFFWFWFWWWWWWFFWWFFWWWWFWWWWWWWWFWFFWFWFFWWWWWWWWWgggVggggVggggggVggVVggVgVggggggggVVgVgVVgggggggggVggggVgVVgVgVVVVVVgVVVgVgggggggVgggggVggggVgVgVgggggggVVgggggggggggggggVgggggggVVgggggVggVVgggggggVVVggggVggggVgggggggggggggVgggggVgVVgVgggggggVVVggggggVggggwwfwfwffwffwwwfffwfffwwwwwffffffwffffwwwwwwffffffffffffwwwwwwwwwwfwfwffffwfffwfffffffwffwffwwwwwffffwwwwfwwwfwfwwwwwwfwwwwfwwwwwwwwwwwwfwwffwwwffwwfwwwffffwfwwwwfwfwwwfwwwwwfwwwfwwwwwwwwwwfwwwwwfwfwwwwwfffwwwwwwwwffwfwfwwwwfwfwwwwwffwwwwwfwwffwfwfffffwwwwwwwwwwwwwfwfwffwwwwwwwwfwwwwwwffwfwwwwwwfffwwwwfwwwwwfwwfwwwwwwwwwfwwfvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv