From e34bdd143a88753f655f81d183e4388338ae4cce Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Thu, 4 May 2023 12:26:37 -0400 Subject: [PATCH] hiti: Log the detected heattable version This comes on the heels of adding a _lot_ of heattable decoding stuff Getting incrementally closer... --- backend_hiti.c | 176 ++++++++++++++++++++++--------------- hiti_data/README-hiti-data | 130 +++++++++++++++++---------- 2 files changed, 190 insertions(+), 116 deletions(-) diff --git a/backend_hiti.c b/backend_hiti.c index 05d156c..efea0de 100644 --- a/backend_hiti.c +++ b/backend_hiti.c @@ -325,6 +325,74 @@ struct hiti_heattable_hdr_v2 { #define HEATTABLE_S_SIZE 4167 + // size +#define HEATTABLE_V2_ID_Y 0x01 // 522 +#define HEATTABLE_V2_ID_M 0x02 // +#define HEATTABLE_V2_ID_C 0x03 // +#define HEATTABLE_V2_ID_DK 0x04 // +#define HEATTABLE_V2_ID_RK 0x10 // +#define HEATTABLE_V2_ID_R 0x11 // +#define HEATTABLE_V2_ID_L 0x12 // +#define HEATTABLE_V2_ID_FO 0x13 // +#define HEATTABLE_V2_ID_O 0x20 // +#define HEATTABLE_V2_ID_KO 0x21 // +#define HEATTABLE_V2_ID_MO 0x22 // +#define HEATTABLE_V2_ID_CVD 0x40 // 582 +#define HEATTABLE_V2_ID_VER_MAJOR 0x50 // 4 +#define HEATTABLE_V2_ID_VER_MINOR 0x51 // +#define HEATTABLE_V2_ID_CT_INVERT 0x80 // 2562 +#define HEATTABLE_V2_ID_CT_IDPASSPORT 0x81 // +#define HEATTABLE_V2_ID_CT_COMPENSATE 0x82 // +#define HEATTABLE_V2_ID_TC_COMPENSATE 0x90 // 26 +#define HEATTABLE_v2_ID_HAC_Y 0xa1 // 1540 +#define HEATTABLE_v2_ID_HAC_M 0xa2 // +#define HEATTABLE_v2_ID_HAC_C 0xa3 // +#define HEATTABLE_v2_ID_HAC_CK 0xa4 // +#define HEATTABLE_v2_ID_HAC_K_YMCKO 0xa5 // +#define HEATTABLE_v2_ID_HAC_RK 0xa6 // +#define HEATTABLE_v2_ID_HAC_O 0xa7 // +#define HEATTABLE_v2_ID_HAC_MO 0xa8 // +#define HEATTABLE_v2_ID_HAC_FO 0xa9 // +#define HEATTABLE_v2_ID_HAC_YMC 0xae // +#define HEATTABLE_v2_ID_HAC_ALL 0xaf // +#define HEATTABLE_v2_ID_LS_Y 0xb1 // 24 (Long Smear) +#define HEATTABLE_v2_ID_LS_M 0xb2 // +#define HEATTABLE_v2_ID_LS_C 0xb3 // +#define HEATTABLE_v2_ID_LS_CK 0xb4 // +#define HEATTABLE_v2_ID_LS_K_YMCKO 0xb5 // +#define HEATTABLE_v2_ID_LS_RK 0xb6 // +#define HEATTABLE_v2_ID_LS_O 0xb7 // +#define HEATTABLE_v2_ID_LS_MO 0xb8 // +#define HEATTABLE_v2_ID_LS_FO 0xb9 // +#define HEATTABLE_v2_ID_LS_YMC 0xbe // +#define HEATTABLE_v2_ID_LS_ALL 0xbf // +#define HEATTABLE_v2_ID_GL_Y 0xc1 // ?? (Ghost Line) +#define HEATTABLE_v2_ID_GL_M 0xc2 // +#define HEATTABLE_v2_ID_GL_C 0xc3 // +#define HEATTABLE_v2_ID_GL_CK 0xc4 // +#define HEATTABLE_v2_ID_GL_K_YMCKO 0xc5 // +#define HEATTABLE_v2_ID_GL_RK 0xc6 // +#define HEATTABLE_v2_ID_GL_O 0xc7 // +#define HEATTABLE_v2_ID_GL_MO 0xc8 // +#define HEATTABLE_v2_ID_GL_FO 0xc9 // +#define HEATTABLE_v2_ID_GL_YMC 0xce // +#define HEATTABLE_v2_ID_GL_ALL 0xcf // +#define HEATTABLE_v2_ID_EN_Y 0xd1 // 18 (Energy) +#define HEATTABLE_v2_ID_EN_M 0xd2 // +#define HEATTABLE_v2_ID_EN_C 0xd3 // +#define HEATTABLE_v2_ID_EN_CK 0xd4 // +#define HEATTABLE_v2_ID_EN_K_YMCKO 0xd5 // +#define HEATTABLE_v2_ID_EN_RK 0xd6 // +#define HEATTABLE_v2_ID_EN_O 0xd7 // +#define HEATTABLE_v2_ID_EN_MO 0xd8 // +#define HEATTABLE_v2_ID_EN_FO 0xd9 // +#define HEATTABLE_v2_ID_EN_YMC 0xde // +#define HEATTABLE_v2_ID_EN_ALL 0xdf // + +#define HEATTABLE_v2_ID_EMBEDDED 0xf0 // 2 +#define HEATTABLE_v2_ID_EMBEDDED_1 0x00 // varies +#define HEATTABLE_v2_ID_EMBEDDED_2 0x20 // varies + /* All fields are LE */ struct hiti_gpjobhdr { uint32_t cookie; /* "GPHT" */ @@ -540,6 +608,7 @@ static int hiti_query_markers(void *vctx, struct marker **markers, int *count); static int hiti_query_serno(struct dyesub_connection *conn, char *buf, int buf_len); static int hiti_read_heattable_v2(struct hiti_ctx *ctx, const char* fname); +static void *hiti_find_heattable_v2_entry(struct hiti_ctx *ctx, int id, size_t *len); static int hiti_docmd(struct hiti_ctx *ctx, uint16_t cmdid, uint8_t *buf, uint16_t buf_len, uint16_t *rsplen) { @@ -1694,7 +1763,7 @@ static const char* hiti_get_heat_file(struct hiti_ctx *ctx, uint8_t mode) case P_HITI_461: if (mediatype == 0x1000) { /* CHC media */ if (mode) { - // what mode does 'P' mean? + // XXX what aboput heatpcsn.bin switch(mediaver) { case 0: return "P461_heatqcsn.bin"; @@ -1717,7 +1786,6 @@ static const char* hiti_get_heat_file(struct hiti_ctx *ctx, uint8_t mode) break; case P_HITI_51X: if (mediatype == 0x1000) { /* CHC media */ - // what mode does 'P' (PC) match? if (mode) { switch(mediaver) { case 0: @@ -1768,7 +1836,7 @@ static const char* hiti_get_heat_file(struct hiti_ctx *ctx, uint8_t mode) } } } else { /* DNP media */ - // what mode does 'P' or 'R' (PH, RH) match? + // XXX heatpcra/heatphra.bin if (mode) { return "P51x_heatqhra.bin"; } else { @@ -1785,7 +1853,6 @@ static const char* hiti_get_heat_file(struct hiti_ctx *ctx, uint8_t mode) case P_HITI_720: if (mediatype == 0x1000) { /* CHC media */ if (mode) { - // what mode does 'P' (PC) match? switch(mediaver) { case 3: return "P72x_hea3qcrd.bin"; @@ -1819,8 +1886,7 @@ static const char* hiti_get_heat_file(struct hiti_ctx *ctx, uint8_t mode) } } } else { - // XXX heatpdre / heattdre - // what mode does 'P' match? and 'D' means what? + // XXX heatphrd/heatpcrd if (mode) { return "P72x_heatqhrd.bin"; } else { @@ -1829,7 +1895,6 @@ static const char* hiti_get_heat_file(struct hiti_ctx *ctx, uint8_t mode) } break; case P_HITI_750: - // what mode does 'P' (PC) match? if (mode) { switch(mediaver) { case 1: @@ -1848,18 +1913,20 @@ static const char* hiti_get_heat_file(struct hiti_ctx *ctx, uint8_t mode) return "P75x_heatqcrh.bin"; } } else { + // XXX heatpcrh.bin return "P75x_heattcrh.bin"; } break; case P_HITI_520: case P_HITI_525: // XXX anything? + // hea5pcri1/heatpcri1/heatpcri.bin default: return NULL; } } -static int hiti_send_heat_data(struct hiti_ctx *ctx, uint8_t mode, uint8_t matte) +static int hiti_send_heat_data_v1(struct hiti_ctx *ctx, uint8_t mode, uint8_t matte) { const char *fname = NULL; union { @@ -2513,7 +2580,7 @@ static int hiti_main_loop(void *vctx, const void *vjob, int wait_for_return) } if (ctx->conn->type == P_HITI_51X) { - ret = hiti_send_heat_data(ctx, job->hdr.quality, job->hdr.overcoat); + ret = hiti_send_heat_data_v1(ctx, job->hdr.quality, job->hdr.overcoat); if (ret) return CUPS_BACKEND_FAILED; @@ -2558,6 +2625,20 @@ static int hiti_main_loop(void *vctx, const void *vjob, int wait_for_return) ret = hiti_read_heattable_v2(ctx, fname); if (ret) return CUPS_BACKEND_FAILED; + + if (fname) { + uint32_t ver_maj; + uint32_t ver_min; + + void *dat; + size_t len; + + dat = hiti_find_heattable_v2_entry(ctx, HEATTABLE_V2_ID_VER_MAJOR, &len); + memcpy(&ver_maj, dat, sizeof(ver_maj)); + dat = hiti_find_heattable_v2_entry(ctx, HEATTABLE_V2_ID_VER_MINOR, &len); + memcpy(&ver_min, dat, sizeof(ver_min)); + INFO("Heattable file '%s' version %08x.%08x\n", fname, ver_maj, ver_min); + } // XXX send CMD_ESD_SHPTC (Heating Parameters & Tone Curve, ~7KB payload) instead? } } @@ -3129,6 +3210,19 @@ static int hiti_query_stats(void *vctx, struct printerstats *stats) return CUPS_BACKEND_OK; } +static void *hiti_find_heattable_v2_entry(struct hiti_ctx *ctx, int id, size_t *len) +{ + int i; + for (i = 0; i < ctx->num_heattable_entries ; i++) { + if (ctx->heattable_v2[i].type == id) { + *len = ctx->heattable_v2[i].len; + return ctx->heattable_v2[i].data; + } + } + *len = 0; + return NULL; +} + static int hiti_read_heattable_v2(struct hiti_ctx *ctx, const char* fname) { int len = 0; int ret; @@ -3208,7 +3302,7 @@ static const char *hiti_prefixes[] = { const struct dyesub_backend hiti_backend = { .name = "HiTi Photo Printers", - .version = "0.55", + .version = "0.57", .uri_prefixes = hiti_prefixes, .cmdline_usage = hiti_cmdline, .cmdline_arg = hiti_cmdline_arg, @@ -3293,66 +3387,4 @@ const struct dyesub_backend hiti_backend = { - Figure out what to send from v2 heattables - Appears to depend on proprietary library, bah. - Heattable v2 entires seen so far: - - ID LEN Descr - --------------------- - 01 522 Y (256*be16+10?) - 02 522 M - 03 522 C - 04 522 ? K maybe? (Card only) - - 10 522 ? (Card only) - 11 522 ? (Card only) - 13 522 ? (Card only) - 14 522 ? (Card only) - 15 522 ? (Card only) - - 20 522 OG - 22 522 OM (Not on card) - - 40 582 CVD - - 50 4 - 51 4 - - 80 2562 Y (256*double+256*u16+u16csum?) - 81 2562 M - 82 2562 C - - 90 26 - - a4 1540 ? Card only - a5 1540 ? Card only - a6 1540 ? Card only - a7 1540 M ? - a8 1540 C ? - a9 1540 ? Card only - aa 1540 ? Card only - ab 1540 ? Card only - ae 1540 Y ? - af 1540 Y+M+C (Only seen on its own) - - b7 24 M ? (bX not seen on Card pirnters) - b8 24 C ? - be 24 Y ? - bf 24 Y+M+C ? - - d4 98 ? Card only - d5 98 ? Card only - d6 98 ? Card only - d7 98 ? Card only - d9 98 ? Card only - da 90 ? Card only - db 98 ? card only - de 98 ? Card only - - f0 2 Only seen with an embedded table.. Always 01 00 - - 00 Varies Embedded table - 20 Varies Embedded table 2 - - Question: how do we know which embedded table to use? - ** embedded tables only seem present for CARD models. - */ diff --git a/hiti_data/README-hiti-data b/hiti_data/README-hiti-data index 24058a4..db372a3 100644 --- a/hiti_data/README-hiti-data +++ b/hiti_data/README-hiti-data @@ -1,17 +1,18 @@ -These '.bin' are either 3D LUTs or Heat Tables for various HiTi -printers. All files were extracted from public HiTi source code or +These '.bin' are either 3D LUTs or Heat Tables for various HiTi +printers. All files were extracted from public HiTi source code or binary driver releases. -Media type & Version are obtained via the CMD_ERDC_RRVC ("Read Ribbon Vendor Code") command. -16-bit word: +Media type & Version are obtained via the CMD_ERDC_RRVC ("Read Ribbon +Vendor Code") command. It return a 16-bit word: x0xx ||\\--- version (0-255) |\----- unknown (always zero?) \------ type/mfg (1 for CHC, 0 for DNP) (presumably others too?) -Some models (P461, maybe others?) do not support RRVC. At this time the mechanism to query -the ribbon mfg/etc is unknown; it might need to be manually specified. +Some models (P461, maybe others?) do not support RRVC. At this time the +mechanism to query the ribbon mfg/etc is unknown; it appears to need to +be manually specified. LUT filename Codes: @@ -93,7 +94,7 @@ Heat table types (Unknown formats): 1536 rj/rm -- ie Shinko-based printers presumably 3*512, RGB8->YMC16 maybe? - 4167 sl/sp/sn + 4167 sl/sn/sp(some) (Appears to be sent over as-is) 4232 sp (some) 88354 ?? re (some) @@ -104,10 +105,10 @@ Heat table types (Unknown formats): 535732 ?? db/da (some) 595552 ?? dc -Heat table types (Known formats): +Heat table version 1: 11108 ra (older) - SEHT2 * 5 (Y + M + C + Gloss + Matte) + SEHT2 * 5 (Y + M + C + O + OM) 256 doubles 2 byte checksum 30 bytes pad @@ -115,7 +116,7 @@ Heat table types (Known formats): 582 bytes 26 bytes pad 12917 ra (newer) - SEHT2 * 6 (Y + M + C + OG + OM + UNK ?) + SEHT2 * 6 (Y + M + C + O + OM + UNK ?) 5 byte header 256 doubles 2 byte checksum @@ -123,7 +124,7 @@ Heat table types (Known formats): 5 byte header 582 bytes -Heat table types (Partially known formats): +Heat table version 2: 12568 ?? rd(qc/qh/pc/ph) / rh(qc) /rk/ri/ri1 / re(some) these printers use ESD_SHPTC and ~7KB payload. @@ -137,38 +138,79 @@ Heat table types (Partially known formats): These are more complex. Data format: XX Number of data blobs, followed by XX headers: -NN NN MM ZZ ZZ OO OO OO OO -| | | \---------- 32-bit offset from file start (LE) -| | \---------------- Zero -| \------------------- Unknown (Data type?) -\------------------------- 16-bit Block ID (LE) +NN TT MM ZZ ZZ OO OO OO OO +| | | | \---------- 32-bit offset from file start (LE) +| | | \---------------- Zero +| | \------------------- Unknown (Data type?) +| \---------------------- 8-bit block ID +\------------------------- Unknown (Data type?) - Observed block types, and guesses + Observed block types, guesses, and binary decodes: - NNNN MM Length Meaning - - 0250 00 4 - 0251 00 4 - 0501 01 522 Y ? - 0502 01 522 M ? - 0503 01 522 C ? - 0520 01 522 O ? - 0522 01 522 OM ? - 2340 01 582 CVD data - 0180 05 2562 - 0181 05 2562 - 0182 05 2562 - 02af 03 1540 - 02ae 03 1540 - 02a7 03 1540 - 02a8 03 1540 - 0cbf 00 24 - 0cbe 00 24 - 0cb7 00 24 - 0cb8 00 24 - 0d90 00 26 - - 01f0 00 2 <- c? only - 18de 00 12732 <- c? only - 1900 2f 24114 <- c? only - 7520 42 34056 <- c? only + Type ID LEN Descr + ---------------------- + 05 01 522 Y (256*be16+10?) + 05 02 522 M + 05 03 522 C + 05 04 522 DK (Dye Black) + 05 10 522 RK (Resin Black) + 05 11 522 R + 05 12 522 L + 05 13 522 FO + 05 20 522 O (Normal Overcoat) + 05 21 522 KO + 05 22 522 MO (Matte Overcoat) + 23 40 582 CVD + 02 50 4 Main Version + 02 51 4 Minor Version + 01 80 2562 CT Invert + 01 81 2562 CT IDPassport + 01 82 2562 CT Compensation + 0d 90 26 TC Compensation + 02 a1 1540 HAC_Y + 02 a2 1540 HAC_M + 02 a3 1540 HAC_C + 02 a4 1540 HAC_DK + 02 a5 1540 HAC_K_YMCKO + 02 a6 1540 HAC_RK + 02 a7 1540 HAC_O + 02 a8 1540 HAC_MO + 02 a9 1540 HAC_FO + 02 ae 1540 HAC_YMC + 02 af 1540 HAC_ALL + 0c b1 24 LS_Y (Long Smear) + 0c b2 24 LS_M + 0c b3 24 LS_C + 0c b4 24 LS_DK + 0c b5 24 LS_K_YMCKO + 0c b6 24 LS_RK + 0c b7 24 LS_O + 0c b8 24 LS_MO + 0c b9 24 LS_FO + 0c be 24 LS_YMC + 0c bf 24 LS_ALL + c1 ??? GL_Y (Ghost Line) + c2 ??? GL_M + c3 ??? GL_C + c4 ??? GL_DK + c5 ??? GL_K_YMCKO + c6 ??? GL_RK + c7 ??? GL_O + c8 ??? GL_MO + c9 ??? GL_FO + ce ??? GL_YMC + cf ??? GL_ALL + 18 d1 12732 EN_Y (Energy) + 18 d2 12732 EN_M + 18 d3 12732 EN_C + 18 d4 12732 EN_DK + 18 d5 12732 EN_K_YMCKO + 18 d6 12732 EN_RK + 18 d7 12732 EN_O + 18 d8 12732 EN_MO + 18 d9 12732 EN_FO + 18 de 12732 EN_YMC + 18 df 12732 EN_ALL + 01 f0 2 Only seen with embedded table, always 01 00 + 19 00 Varies Embedded table + 75 20 Varies Embedded table 2