selphy_print/backend_mitsud90.c

2891 lines
81 KiB
C
Raw Permalink Normal View History

/*
* Mitsubishi CP-D90DW Photo Printer CUPS backend
*
* (c) 2019-2024 Solomon Peachy <pizza@shaftnet.org>
*
* The latest version of this program can be found at:
*
* https://git.shaftnet.org/cgit/selphy_print.git
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <https://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0+
*
*/
#define BACKEND mitsud90_backend
#include "backend_common.h"
#include "backend_mitsu.h"
/* CPM1 stuff */
#define CPM1_LAMINATE_STRIDE 1852
#define CPM1_LAMINATE_FILE "M1_MAT02.raw"
#define CPM1_CPC_FNAME "CPM1_N1.csv"
#define CPM1_CPC_G1_FNAME "CPM1_G1.csv"
#define CPM1_CPC_G5_FNAME "CPM1_G5.csv"
#define CPM1_CPC_G5_VIVID_FNAME "CPM1_G5_vivid.csv"
#define CPM1_LUT_FNAME "CPM1_NL.lut"
/* D90 LUT for when we are doing panoramas */
#define CPD90_LUT_FNAME "CPD90L01.lut"
#define CPD90_CPC_FNAME "CPD90_N1.csv"
#define CPD90_CPC_3_1_FNAME "CP90_3_1.csv"
#define CPD90_CPC_3_2_FNAME "CP90_3_2.csv"
/* ASK500 stuff -- Note the lack of LUT or G5_vivid! */
#define ASK5_LAMINATE_FILE "ASK5_MAT.raw"
#define ASK5_CPC_FNAME "ASK5_N1.csv"
#define ASK5_CPC_G1_FNAME "ASK5_G1.csv"
#define ASK5_CPC_G5_FNAME "ASK5_G5.csv"
/* Printer data structures */
#define COM_STATUS_TYPE_MODEL 0x01 // 10, null-terminated ASCII. 'CPD90D'
2023-07-11 14:28:44 -04:00
#define W5K_STATUS_TYPE_MODEL 0x01 // 5, ASCII, non-terminated: 'W5000'
#define COM_STATUS_TYPE_x02 0x02 // 1, 0x5f ?
#define CM1_STATUS_TYPE_ISERIAL 0x03 // 24, full iSerial string in UTF16(LE)
#define CM1_STATUS_TYPE_SERIAL 0x04 // 6, serial number only (ascii)
#define W5K_STATUS_TYPE_SERIAL 0x06 // 8, 36 30 31 34 30 35 43 20 (601405M )
#define W5K_STATUS_TYPE_x07 0x07 // 6, 30 38 46 35 46 37 (08F5F7)
#define W5K_STATUS_TYPE_x08 0x08 // 9, 00 00 00 00 00 00 00 00 00
#define W5K_STATUS_TYPE_x09 0x09 // 9, 00 00 00 00 00 00 00 00 00
#define CM1_STATUS_TYPE_FW_0a 0x0a // 8, 34 34 38 41 31 32 29 f4 (448A12)
#define COM_STATUS_TYPE_FW_LOADER 0x0b // 8, 34 31 34 42 31 31 a7 de (414D11)
#define COM_STATUS_TYPE_FW_MAIN 0x0c // 8, 34 31 35 41 38 31 86 bf (415A81)
#define COM_STATUS_TYPE_FW_FPGA 0x0d // 8, 34 31 36 41 35 31 dc 8a (416A51)
#define COM_STATUS_TYPE_FW_TBL 0x0e // 8, 34 31 37 45 31 31 e7 e6 (417E11)
#define COM_STATUS_TYPE_FW_TAG 0x0f // 8, 34 31 38 41 31 32 6c 64 (418A12)
#define W5K_STATUS_TYPE_FW_LUT 0x10 // 8, 33 37 30 41 32 34 91 22 (370A24)
#define COM_STATUS_TYPE_FW_SATIN 0x11 // 8, 34 32 31 51 31 31 74 f2 (421Q11)
#define W5K_STATUS_TYPE_FW_12 0x12 // 8, 30 30 30 30 30 30 30 30 (000000)
#define COM_STATUS_TYPE_FW_MECH 0x13 // 8, 34 31 39 45 31 31 15 bf (419E11) NOT W5K
#define W5K_STATUS_TYPE_x15 0x15 // 2, 00 00
#define COM_STATUS_TYPE_ERROR 0x16 // 11 (see below)
#define COM_STATUS_TYPE_MECHA 0x17 // 2 (see below)
#define W5K_STAUTS_TYPE_x1a 0x1a // 1, 00 (error flag? 0x10 seems to be a
#define COM_STATUS_TYPE_x1e 0x1e // 1, power state or time? (x00)
#define COM_STATUS_TYPE_TEMP 0x1f // 1 (see below)
#define W5K_STATUS_TYPE_x20 0x20 // 1, 00
#define COM_STATUS_TYPE_x22 0x22 // 2, all 0 (NOT W5K)
#define W5K_STATUS_TYPE_x23 0x23 // 16, all 0
#define W5K_STATUS_TYPE_x24 0x24 // 26, all 0
#define W5K_STATUS_TYPE_x25 0x25 // 16, all 0
#define COM_STATUS_TYPE_JOBID 0x28 // 2, _next_ Job ID.
#define COM_STATUS_TYPE_INKID 0x29 // 8, e0 07 00 00 21 e6 b3 22 or e0 07 80 96 3f 28 12 2d or e0 07 00 00 2b e8 db bd
#define COM_STATUS_TYPE_MEDIA 0x2a // 10 (see below)
#define COM_STATUS_TYPE_x2b 0x2b // 2, all 0
#define W5K_STATUS_TYPE_INKID2 0x2b // 8, 0c 57 dc 00 [a1 18] 00 00
#define COM_STATUS_TYPE_x2c 0x2c // 2, 00 56 (D90) 00 23 (M1)
#define W5K_STATUS_TYPE_x2c 0x2c // 12,06 00 00 00 00 00 00 00 40 54 33 01
#define W5K_STATUS_TYPE_x2d 0x2d // 4, all 0
#define W5K_STATUS_TYPE_x30 0x30 // 2, all 0
#define W5K_STATUS_TYPE_x31 0x31 // 2, 00 44
#define W5K_STATUS_TYPE_x33 0x33 // 12, all 0
#define W5K_STATUS_TYPE_x34 0x34 // 2, 00 4f
#define W5K_STATUS_TYPE_x35 0x35 // 2, 02
#define W5K_STATUS_TYPE_x37 0x37 // 2, 02
#define W5K_STATUS_CNT_HEAD 0x3d // 4
#define W5K_STATUS_CNT_SERVICE 0x3e // 4
#define W5K_STATUS_CNT_PRINTED 0x3f // 4
#define W5K_STATUS_TYPE_x40 0x40 // 4, 00 00 3f b0 (seen it go up and down)
#define W5K_STATUS_TYPE_x45 0x45 // 4, 00 00 00 84 (counter?) <-- incremetns one per print
#define W5K_STATUS_TYPE_DENSITY 0x46 // 2
#define W5K_STATUS_TYPE_TPHR 0x4b // 2 // Thermal Print Head Resistance
#define W5K_STATUS_TYPE_TPHSN 0x4c // 8 // Thermal Print Head Serno (ASCII, non-terminated)
#define W5K_STATUS_TYPE_x52 0x52 // 1, 42
#define W5K_STATUS_CNT_CUTTER 0x5b
#define W5K_STATUS_CNT_SLITTER 0x60
#define COM_STATUS_TYPE_x65 0x65 // 50, see below (sensors?)
#define W5K_STATUS_TYPE_x65 0x65 // 54, see below
#define W5K_STATUS_TYPE_LENGTHS 0x6f // 16, BLANKLENA_s16, BLANKLENB_s16, 00 00, MARGINLEN s16, 00 00, CUTLEN_s16, 00 00 00 00
#define W5K_STATUS_TYPE_x70 0x70 // 16, 0a 07 ff 0b 00 00 00 00 00 00 00 00 00 00 00 00
#define W5K_STATUS_TYPE_MOTOR3 0x71 // 16, NN NN NN NN TT TT TT TT 00 00 00 00 00 00 00 00
#define W5K_STATUS_TYPE_MOTOR5 0x72 // 16, NN NN NN NN TT TT TT TT 00 00 00 00 00 00 00 00
#define W5K_STATUS_TYPE_MOTOR1 0x73 // 4, CC CC CC CC
#define D90_STATUS_TYPE_ISEREN 0x82 // 1, 80 (iserial disabled)
#define COM_STATUS_TYPE_x83 0x83 // 1, 00
#define W5K_STATUS_TYPE_x83 0x83 // 2, 00 80
#define D90_STATUS_TYPE_x84 0x84 // 1, 00
#define W5K_STATUS_TYPE_x84 0x84 // 2, 00 0a
#define D90_STATUS_TYPE_x85 0x85 // 2, 00 ?? BE, wait time? combined total of 5.
#define W5K_STATUS_TYPE_x85 0x85 // 2, 00 04
#define W5K_STATUS_TYPE_x86 0x86 // 2, 01 2c
#define W5K_STATUS_TYPE_DMAXY 0x87 // 1
#define W5K_STATUS_TYPE_DMINY 0x88 // 1
#define W5K_STATUS_TYPE_DMAXM 0x89 // 1
#define W5K_STATUS_TYPE_DMINM 0x8a // 1
#define W5K_STATUS_TYPE_DMAXC 0x8b // 1
#define W5K_STATUS_TYPE_DMINC 0x8c // 1
#define W5K_STATUS_TYPE_LUT 0x8d // 120, 53 4c 54 41 58 32 37 30 -- "SLTAX270" for older media type (vs "SLTA7180" for new media type), followed by 14 more entries for B1-7/C1-7
#define W5K_STATUS_TYPE_x8e 0x8e // 8, all ff
#define W5K_STATUS_TYPE_x97 0x97 // 2, 00 01
#define W5K_STATUS_TYPE_xc0 0xc0 // 1, 00
#define W5K_STATUS_TYPE_xc1 0xc1 // 1, 00
#define W5K_STATUS_TYPE_xc2 0xc2 // 1, 00
#define W5K_STATUS_TYPE_xc3 0xc3 // 1, 00
#define W5K_STATUS_TYPE_xc4 0xc4 // 1, 00
#define W5K_STATUS_TYPE_xc5 0xc5 // 1, 00
#define W5K_STATUS_TYPE_xc6 0xc6 // 1, 00
#define W5K_STATUS_TYPE_xc7 0xc7 // 1, 00
#define W5K_STATUS_TYPE_xc8 0xc8 // 1, 00
#define W5K_STATUS_TYPE_xc9 0xc9 // 1, 00
#define W5K_STATUS_TYPE_xca 0xca // 1, 00
#define W5K_STATUS_TYPE_xcb 0xcb // 1, 00
#define W5K_STATUS_TYPE_xcf 0xcf // 1, 00
struct mitsud90_fw_resp_single {
uint8_t version[6];
uint16_t csum;
2018-09-17 21:32:15 -04:00
} __attribute__((packed));
struct mitsud90_media_resp {
uint8_t hdr[4]; /* e4 47 44 30 */
struct {
uint8_t brand;
uint8_t type;
uint8_t unk_a[2];
uint16_t capacity; /* BE */
uint16_t remain; /* BE */
uint8_t unk_b[2];
} __attribute__((packed)) media; /* COM_STATUS_TYPE_MEDIA */
} __attribute__((packed));
struct mitsud90_status_resp {
uint8_t hdr[4]; /* e4 47 44 30 */
/* COM_STATUS_TYPE_ERROR */
uint8_t code[2]; /* 00 is ok, nonzero is error */
uint8_t unk[9];
/* COM_STATUS_TYPE_MECHA */
uint8_t mecha[2];
/* COM_STATUS_TYPE_TEMP */
uint8_t temp;
} __attribute__((packed));
struct mitsud90_info_resp {
uint8_t hdr[4]; /* e4 47 44 30 */
uint8_t model[10];
uint8_t x02;
struct mitsud90_fw_resp_single fw_vers[7];
uint8_t x1e;
uint8_t x22[2];
uint16_t jobid;
uint8_t inkid[8];
uint8_t x2b[2];
uint8_t x2c[2];
uint8_t x65[50];
uint8_t iserial;
uint8_t x83;
uint8_t x84;
} __attribute__((packed));
struct mitsud90_fwver_resp {
uint8_t hdr[4]; /* e4 47 44 30 */
struct mitsud90_fw_resp_single fw_ver;
} __attribute((packed));
struct mitsum1_info_resp {
uint8_t hdr[4]; /* e4 47 44 30 */
uint8_t model[10];
uint8_t x02;
struct mitsud90_fw_resp_single fw_vers[8];
uint8_t x1e;
uint8_t x22[2];
uint16_t jobid;
uint8_t inkid[8];
uint8_t x2b[2];
uint8_t x2c[2];
uint8_t x65[50];
uint8_t x83;
} __attribute__((packed));
struct mitsuw5k_info_resp {
uint8_t hdr[4]; /* e4 47 44 30 */
2023-07-11 14:28:44 -04:00
uint8_t model[5];
uint8_t x02;
2023-07-11 14:39:58 -04:00
struct mitsud90_fw_resp_single fw_vers[7];
uint8_t x1a;
uint8_t x1e;
uint8_t inkid[8];
uint8_t x2b[8];
uint8_t x2c[12];
uint32_t cnt_head;
uint32_t cnt_service;
uint32_t cnt_printed;
uint32_t cnt_cutter;
uint32_t cnt_slitter;
2023-07-12 15:41:52 -04:00
#if 0
uint32_t x40;
uint32_t x45;
uint8_t x65[54];
uint8_t x83[2];
uint8_t x84[2];
2023-07-11 14:39:58 -04:00
#endif
} __attribute__((packed));
#define D90_MECHA_STATUS_IDLE 0x00
#define W5K_MECHA_STATUS_PRINTING 0x20
#define D90_MECHA_STATUS_PRINTING 0x50
#define D90_MECHA_STATUS_INIT 0x80
#define D90_MECHA_STATUS_INIT_FEEDCUT 0x10
#define D90_MECHA_STATUS_PRINT_FEEDING 0x10 // feeding ?
#define D90_MECHA_STATUS_PRINT_x20 0x20 // ??
#define D90_MECHA_STATUS_PRINT_PRE_Y 0x21 // pre Y ?
#define D90_MECHA_STATUS_PRINT_Y 0x22 // Y ?
#define D90_MECHA_STATUS_PRINT_PRE_M 0x23 // pre M ?
#define D90_MECHA_STATUS_PRINT_M 0x24 // M ?
#define D90_MECHA_STATUS_PRINT_PRE_C 0x25 // pre C ? guess!
#define D90_MECHA_STATUS_PRINT_C 0x26 // C ?
#define D90_MECHA_STATUS_PRINT_PRE_OC 0x27 // pre OC ? guess!
#define D90_MECHA_STATUS_PRINT_OC 0x28 // O C?
#define D90_MECHA_STATUS_PRINT_x2f 0x2f // ??
#define D90_MECHA_STATUS_PRINT_x38 0x38 // eject ?
#define D90_ERROR_STATUS_OK 0x00
#define D90_ERROR_STATUS_OK_WARMING 0x40
#define D90_ERROR_STATUS_OK_COOLING 0x80
#define D90_ERROR_STATUS_RIBBON 0x21
#define D90_ERROR_STATUS_PAPER 0x22
#define D90_ERROR_STATUS_PAP_RIB 0x23
#define D90_ERROR_STATUS_OPEN 0x29
struct mitsud90_job_query {
uint8_t hdr[4]; /* 1b 47 44 31 */
uint16_t jobid; /* BE */
} __attribute__((packed));
struct mitsud90_job_resp {
uint8_t hdr[4]; /* e4 47 44 31 */
uint8_t unk1;
uint8_t unk2;
uint16_t unk3;
} __attribute__((packed));
struct mitsud90_job_hdr {
uint8_t hdr[6]; /* 1b 53 50 30 00 33 */
uint16_t cols; /* BE */
uint16_t rows; /* BE */
uint8_t waittime; /* 0-100 */
uint8_t unk[3]; /* 00 00 01 */ // XXX 00 01 might be the jobid?
uint8_t margincut; /* 1 for enabled, 0 for disabled */
uint8_t numcuts; /* # of cuts (0-3) but 0-8 legal */
/*@0x10*/
struct {
uint16_t position; // BE, @ center
uint8_t margincut; /* 0 for double cut, 1 for single */
uint8_t zeropad;
} cutlist[8] __attribute__((packed)); /* 3 is current legal max */
/*@x30*/uint8_t overcoat; /* 0 glossy, matte is 2 (D90) or 3 (M1) */
uint8_t quality; /* 0 is automatic, 5 is "fast" on M1 */
uint8_t colorcorr; /* Always 1 on M1 */
uint8_t sharp_h; /* Always 0 on M1 */
uint8_t sharp_v; /* Always 0 on M1 */
2021-06-26 00:35:05 -04:00
uint8_t zero_b[5]; /* 0 on D90, on M1, zero_b[3] is the not-raw flag */
struct {
/* @x3a */ uint8_t on; /* 0x01 when pano is on / always 0x02 on M1 / 0x03 on D90 panorama that needs backend processing */
2021-06-26 00:35:05 -04:00
uint8_t zero_a;
uint8_t total; /* 2 or 3 */
uint8_t page; /* 1, 2, 3 */
uint16_t rows; /* always 0x097c (BE), ie 2428 ie 8" print */
/* @x40 */ uint16_t rows2; /* Always 0x30 less than pano_rows */
uint16_t zero_b; /* 0x0000 */
uint16_t overlap; /* always 0x0258, ie 600 or 2 inches */
uint8_t unk[4]; /* 00 0c 00 06 */
} pano __attribute__((packed));
2021-06-26 00:35:05 -04:00
uint8_t zero_c[6];
/*@x50*/uint8_t unk_m1; /* 00 on d90 & m1 Linux, 01 on m1 (windows) */
uint8_t rgbrate; /* M1 only, see below */
uint8_t oprate; /* M1 only, see below */
uint8_t zero_fill[429];
2018-05-14 15:20:33 -04:00
} __attribute__((packed));
struct mitsud90_plane_hdr {
uint8_t hdr[6]; /* 1b 5a 54 01 00 09 */
uint16_t origin_cols; /* Leave at 0 */
uint16_t origin_rows; /* Leave at 0 */
uint16_t cols; /* BE */
uint16_t rows; /* BE */
uint8_t zero_a[6];
uint16_t lamcols; /* BE (M1 only, OC=3) should be cols+origin_cols */
uint16_t lamrows; /* BE (M1 only, OC=3) should be rows+origin_rows+12 */
uint8_t zero_b[8];
uint8_t unk_m1[8]; /* 07 e4 02 19 xx xx xx 00 always incrementing. timestamp? Only seen from win-generated jobs? */
uint8_t zero_fill[472];
} __attribute__((packed));
struct mitsud90_job_footer {
uint8_t hdr[4]; /* 1b 42 51 31 */
uint16_t seconds; /* BE, 0x0005 by default (windows), 0x00ff means don't wait */
} __attribute__((packed));
struct mitsud90_memcheck {
uint8_t hdr[6]; /* 1b 47 44 33 00 33 */
uint16_t cols; /* BE */
uint16_t rows; /* BE */
uint8_t waittime; /* 0-100 */
uint8_t unk[3]; /* 00 00 01 */
uint8_t zero_fill[498];
} __attribute__((packed));
struct mitsud90_memcheck_resp {
uint8_t hdr[4]; /* e4 47 44 43 */
uint8_t size_bad; /* 0x00 is ok */
uint8_t mem_bad; /* 0x00 is ok */
} __attribute__((packed));
struct mitsuw5k_job_hdr {
uint8_t hdr[4]; // 1b 53 50 30
uint16_t cols;
uint16_t rows;
uint8_t cuts; // 0-2
uint16_t cut1;
uint16_t cut2;
uint8_t single; // 1:single page, 0:duplex
uint8_t finish; // 0:gloss, 1:semi-gloss 2:matte
uint8_t finishback; // 0:gloss, 1:semi-gloss, 2:matte, ff:none
uint8_t unk[2]; // XXX 01 00, 01 01, 01 02 seen on windows driver, latter two with duplex of some sort. 00 00 hardcoded with linux driver.
uint8_t colorconv; // 1: off, 0: internal
uint8_t sharp_H; // 0-8 or 0xff (ie printer)
uint8_t sharp_V; // 0-8 or 0xff (ie printer)
/*@21*/ uint8_t pad[512-21];
} __attribute__((packed));
struct mitsuw5k_plane_hdr {
int8_t hdr[4]; // 1b 5a 54 01
uint8_t zero[4];
uint16_t cols;
uint16_t rows;
uint8_t zero2;
uint8_t printout; // 1 to start printing
uint8_t zero3;
/*@15*/ uint8_t pad[512-15];
} __attribute__((packed));
struct mitsud90_generic_hdr { /* See GENERIC GET/SET below */
uint8_t hdr[3]; /* 1b 61 36 */
uint8_t getset; /* 36 get, 30 set */
uint8_t type[2]; /* 41 be, 45 ba, etc */
uint32_t len; /* Payload len, BE */
uint8_t index[4]; /* 00 00 ?? ?? */
uint8_t term1[4]; /* ff ff ?? ?? */
uint8_t term2[4]; /* ff ff ?? ?? */
} __attribute((packed));
struct mitsum1_errorlog_item {
uint8_t unk[256];
/* Printer dumps: 0000000 0000 0000 0000000000 0000 00 */
} __attribute((packed));
struct mitsum1_getinfo_resp {
struct mitsud90_generic_hdr hdr; /* @ 0 */
uint32_t cnt_prints; /* @ 22 */
uint32_t cnt_total;
uint32_t cnt_unka; // increased by 97 for a single 8" print
uint32_t cnt_cutter;
uint32_t cnt_unkb[25];
uint8_t unk[1472-29*4]; /* @ 138 */
struct mitsum1_errorlog_item items[20]; /* @1494 */
/* End @6614 bytes */
} __attribute((packed));
static const char *mitsud90_mecha_statuses(const uint8_t *code)
{
switch (code[0]) {
case D90_MECHA_STATUS_IDLE:
return "Idle";
case W5K_MECHA_STATUS_PRINTING:
// codes seen:
// 22 30 31 32 33 34 35 37 38 <-- Side A?
// 42 50 51 52 53 55 57 58 <-- Side B?
// 60 <-- Finish?
return "Printing (Unknown)";
case D90_MECHA_STATUS_PRINTING:
switch (code[1]) {
case D90_MECHA_STATUS_PRINT_FEEDING:
case D90_MECHA_STATUS_PRINT_x20: // XXX
return "Feeding Media";
case D90_MECHA_STATUS_PRINT_PRE_Y:
case D90_MECHA_STATUS_PRINT_Y:
return "Printing Yellow";
case D90_MECHA_STATUS_PRINT_PRE_M:
case D90_MECHA_STATUS_PRINT_M:
return "Printing Magenta";
case D90_MECHA_STATUS_PRINT_PRE_C:
case D90_MECHA_STATUS_PRINT_C:
return "Printing Cyan";
case D90_MECHA_STATUS_PRINT_PRE_OC:
case D90_MECHA_STATUS_PRINT_OC:
return "Applying Overcoat";
case D90_MECHA_STATUS_PRINT_x2f:
case D90_MECHA_STATUS_PRINT_x38:
return "Ejecting Media?"; // XXX
default:
return "Printing (Unknown)";
}
case D90_MECHA_STATUS_INIT:
if (code[1] == D90_MECHA_STATUS_INIT_FEEDCUT)
return "Feed & Cut paper";
else
return "Initializing";
default:
return "Unknown";
}
}
static const char *mitsud90_error_codes(const uint8_t *code)
{
switch(code[0]) {
case D90_ERROR_STATUS_OK:
if (code[1] & D90_ERROR_STATUS_OK_WARMING)
return "Heating";
else if (code[1] & D90_ERROR_STATUS_OK_COOLING)
return "Cooling Down";
else
return "Idle";
case D90_ERROR_STATUS_RIBBON:
switch (code[1]) {
case 0x00:
return "Ribbon exhausted";
case 0x10:
return "Insufficient remaining ribbon";
case 0x20:
return "Ribbon Cue Timeout";
case 0x30:
return "Cannot Cue Ribbon";
case 0x90:
return "No ribbon";
default:
return "Unknown Ribbon Error";
}
case D90_ERROR_STATUS_PAPER:
switch (code[1]) {
case 0x00:
return "No paper";
case 0x02:
return "Paper exhausted";
default:
return "Unknown Paper Error";
}
case D90_ERROR_STATUS_PAP_RIB:
switch (code[1]) {
case 0x00:
return "Ribbon/Paper mismatch";
case 0x90:
return "Ribbon/Job mismatch";
default:
return "Unknown ribbon match error";
}
case 0x26:
return "Illegal Ribbon";
case 0x28:
return "Cut Bin Missing";
case D90_ERROR_STATUS_OPEN:
switch (code[1]) {
case 0x00:
return "Printer Open during Stop";
case 0x10:
return "Printer Open during Initialization";
case 0x90:
return "Printer Open during Printing";
default:
return "Unknown Door error";
}
case 0x2f:
return "Printer turned off during printing";
case 0x31:
return "Ink feed stop";
case 0x32:
return "Ink Skip 1 timeout";
case 0x33:
return "Ink Skip 2 timeout";
case 0x34:
return "Ink Sticking";
case 0x35:
return "Ink return stop";
case 0x36:
return "Ink Rewind timeout";
case 0x37:
return "Winding sensing error";
case 0x40:
case 0x41:
case 0x42:
case 0x43:
case 0x44:
return "Paper Jam";
case 0x60:
if (code[1] == 0x20)
return "Preheat error";
else if (code[1] == 0x04)
return "Humidity sensor error";
else if (code[1] & 0x1f)
return "Thermistor error";
else
return "Unknown error";
case 0x61:
if (code[1] == 0x00)
return "Color Sensor Error";
else if (code[1] & 0x10)
return "Matte OP Error";
else
return "Unknown error";
case 0x62:
return "Data Transfer error";
case 0x63:
return "EEPROM error";
case 0x64:
return "Flash access error";
case 0x65:
return "FPGA configuration error";
case 0x66:
return "Power voltage Error";
case 0x67:
return "RFID access error";
case 0x68:
if (code[1] == 0x00)
return "Fan Lock Error";
else if (code[1] == 0x90)
return "MDA Error";
else
return "Unknown error";
case 0x69:
if (code[1] == 0x10)
return "DDR Error";
else if (code[1] == 0x00)
return "Firmware Error";
else
return "Unknown error";
case 0x70:
case 0x71:
case 0x73:
case 0x74:
case 0x75:
return "Mechanical Error (check ribbon and power cycle)";
case 0x82:
return "USB Timeout";
case 0x83:
return "Illegal paper size";
case 0x84:
return "Illegal parameter";
case 0x85:
return "Job Cancel";
case 0x89:
return "Last Job Error";
default:
return "Unknown";
}
}
static void mitsud90_dump_status(struct mitsud90_status_resp *resp)
{
INFO("Error Status: %s (%02x %02x) -- %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
mitsud90_error_codes(resp->code),
resp->code[0], resp->code[1],
resp->unk[0], resp->unk[1], resp->unk[2], resp->unk[3],
resp->unk[4], resp->unk[5], resp->unk[6], resp->unk[7],
resp->unk[8]);
INFO("Printer Status: %s (%02x %02x)\n",
mitsud90_mecha_statuses(resp->mecha),
resp->mecha[0], resp->mecha[1]);
INFO("Temperature Status: %s\n",
mitsu_temperatures(resp->temp));
}
/* Private data structure */
struct mitsud90_printjob {
struct dyesub_job_common common;
uint8_t *databuf;
uint32_t datalen;
int is_raw;
int is_pano;
int is_duplex;
int m1_colormode;
struct mitsud90_job_hdr hdr;
2020-03-03 19:21:47 -05:00
int has_footer;
struct mitsud90_job_footer footer;
int has_start;
};
struct mitsud90_ctx {
struct dyesub_connection *conn;
struct marker marker;
struct mitsud90_media_resp media;
2023-07-11 14:44:41 -04:00
char serno[9]; /* 8+null */
char fwver_main[7]; /* 6+null */
char fwver_mech[7]; /* 6+null */
/* Used in parsing.. */
2018-05-14 15:20:33 -04:00
struct mitsud90_job_footer holdover;
int holdover_on;
int duplex_on;
int pano_page;
/* For the CP-M1 family */
struct mitsu_lib lib;
};
static int mitsud90_query_media(struct mitsud90_ctx *ctx, struct mitsud90_media_resp *resp)
{
uint8_t cmdbuf[8];
uint8_t cmdlen = 0;
int ret, num;
cmdbuf[cmdlen++] = 0x1b;
cmdbuf[cmdlen++] = 0x47;
cmdbuf[cmdlen++] = 0x44;
cmdbuf[cmdlen++] = 0x30;
if (ctx->conn->type != P_MITSU_W5000) {
cmdbuf[cmdlen++] = 0;
cmdbuf[cmdlen++] = 0;
}
cmdbuf[cmdlen++] = 0x01; /* Number of commands */
cmdbuf[cmdlen++] = COM_STATUS_TYPE_MEDIA;
if ((ret = send_data(ctx->conn,
cmdbuf, cmdlen)))
return ret;
memset(resp, 0, sizeof(*resp));
ret = read_data(ctx->conn,
(uint8_t*) resp, sizeof(*resp), &num);
if (ret < 0)
return ret;
if (num != sizeof(*resp)) {
ERROR("Short Read! (%d/%d)\n", num, (int)sizeof(*resp));
return 4;
}
return CUPS_BACKEND_OK;
}
static int mitsud90_query_status(struct mitsud90_ctx *ctx, struct mitsud90_status_resp *resp)
{
uint8_t cmdbuf[10];
uint8_t cmdlen = 0;
int ret, num;
cmdbuf[cmdlen++] = 0x1b;
cmdbuf[cmdlen++] = 0x47;
cmdbuf[cmdlen++] = 0x44;
cmdbuf[cmdlen++] = 0x30;
if (ctx->conn->type != P_MITSU_W5000) {
cmdbuf[cmdlen++] = 0;
cmdbuf[cmdlen++] = 0;
}
cmdbuf[cmdlen++] = 0x03; /* Number of commands */
cmdbuf[cmdlen++] = COM_STATUS_TYPE_ERROR;
cmdbuf[cmdlen++] = COM_STATUS_TYPE_MECHA;
cmdbuf[cmdlen++] = COM_STATUS_TYPE_TEMP;
if ((ret = send_data(ctx->conn,
cmdbuf, cmdlen)))
return ret;
memset(resp, 0, sizeof(*resp));
ret = read_data(ctx->conn,
(uint8_t*) resp, sizeof(*resp), &num);
if (ret < 0)
return ret;
if (num != sizeof(*resp)) {
ERROR("Short Read! (%d/%d)\n", num, (int)sizeof(*resp));
return 4;