2019-09-10 14:34:58 -04:00
|
|
|
/*
|
|
|
|
* HiTi Photo Printer CUPS backend -- libusb-1.0 version
|
|
|
|
*
|
2023-03-17 13:15:45 -04:00
|
|
|
* (c) 2019-2023 Solomon Peachy <pizza@shaftnet.org>
|
2019-09-10 14:34:58 -04:00
|
|
|
*
|
|
|
|
* The latest version of this program can be found at:
|
|
|
|
*
|
2021-01-23 10:47:01 -05:00
|
|
|
* https://git.shaftnet.org/cgit/selphy_print.git
|
2019-09-10 14:34:58 -04:00
|
|
|
*
|
|
|
|
* 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
|
2020-01-17 16:50:56 -05:00
|
|
|
* along with this program; if not, see <https://www.gnu.org/licenses/>.
|
2019-09-10 14:34:58 -04:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-3.0+
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define BACKEND hiti_backend
|
|
|
|
|
|
|
|
#include "backend_common.h"
|
|
|
|
|
2019-10-01 21:24:49 -04:00
|
|
|
/* For Integration into gutenprint */
|
|
|
|
#if defined(HAVE_CONFIG_H)
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2020-03-24 19:33:20 -04:00
|
|
|
// We should use nanosleep everywhere properly.
|
|
|
|
#define __usleep(__x) { struct timespec t = { 0, (__x) * 1000 } ; nanosleep (&t, NULL); }
|
|
|
|
|
2019-09-10 14:34:58 -04:00
|
|
|
/* Private structures */
|
|
|
|
struct hiti_cmd {
|
|
|
|
uint8_t hdr; /* 0xa5 */
|
|
|
|
uint16_t len; /* (BE) everything after this field, minimum 3, max 6 */
|
2021-04-13 12:18:08 -04:00
|
|
|
uint8_t status; /* see CMD_STATUS_* */
|
2019-09-10 14:34:58 -04:00
|
|
|
uint16_t cmd; /* CMD_* (BE) */
|
|
|
|
uint8_t payload[]; /* 0-3 items */
|
2019-09-28 15:32:29 -04:00
|
|
|
} __attribute__((packed));
|
2019-09-10 14:34:58 -04:00
|
|
|
|
2023-03-31 12:13:04 -04:00
|
|
|
#define CMD_STATUS_ERR 0x80
|
|
|
|
#define CMD_STATUS_OK (0x40 | 0x10)
|
|
|
|
|
|
|
|
// XXX lower 4 bits are sub-status, unknown.
|
|
|
|
|
|
|
|
// Success
|
|
|
|
// 0x01 Seen with ERDC_RLC on p51x
|
|
|
|
// 0x02 Seen with EPC_SP on p51x, sometimes?
|
|
|
|
// 0x03 Seen with RDC_RS on p461
|
|
|
|
|
|
|
|
// Errors
|
2023-05-02 10:32:13 -04:00
|
|
|
// 0x08 Seen with EFM_RD on p51x, EFD_CHS on p525, ERDC_RRVC on p461
|
2023-03-31 12:13:04 -04:00
|
|
|
// 0x0b Seen with ESD_SEHT2 on p51x
|
2021-04-13 12:18:08 -04:00
|
|
|
|
2019-09-10 14:34:58 -04:00
|
|
|
/* Request Device Characteristics */
|
|
|
|
#define CMD_RDC_RS 0x0100 /* Request Summary */
|
2023-04-14 14:06:08 -04:00
|
|
|
#define CMD_RDC_ROC 0x0104 /* Request Option Characteristics (1 resp on p52x, not on p51x, 16 on p461 */
|
2019-09-10 14:34:58 -04:00
|
|
|
|
|
|
|
/* Printer Configuratio Control */
|
2019-10-01 21:24:49 -04:00
|
|
|
#define CMD_PCC_RP 0x0301 /* Reset Printer (1 arg) */
|
2023-04-23 17:28:58 -04:00
|
|
|
#define CMD_RCC_UNK 0x0310 /* XX Unknown */
|
2022-10-20 20:56:40 -04:00
|
|
|
#define CMD_PCC_STP 0x030F /* Set Target Printer (1 arg) XXX -- 00 == master or 01 == slave ? Or maybe it's a bank select for CMD_EFM_RNV? */
|
2019-09-10 14:34:58 -04:00
|
|
|
|
|
|
|
/* Request Device Status */
|
2021-04-13 12:06:58 -04:00
|
|
|
#define CMD_RDS_RSS 0x0400 /* Request Status Summary */
|
2019-09-10 14:34:58 -04:00
|
|
|
#define CMD_RDS_RIS 0x0401 /* Request Input Status */
|
|
|
|
#define CMD_RDS_RIA 0x0403 /* Request Input Alert */
|
|
|
|
#define CMD_RDS_RJA 0x0405 /* Request Jam Alert */
|
|
|
|
#define CMD_RDS_ROIRA 0x0406 /* Request Operator Intervention Alert */
|
|
|
|
#define CMD_RDS_RW 0x0407 /* Request Warnings */
|
|
|
|
#define CMD_RDS_DSRA 0x0408 /* Request Device Serviced Alerts */
|
|
|
|
#define CMD_RDS_SA 0x040A /* Request Service Alerts */
|
2022-06-09 13:24:13 -04:00
|
|
|
#define CMD_RDS_RPS 0x040B /* Request Printer Statistics */
|
2022-06-12 11:13:31 -04:00
|
|
|
#define CMD_RDS_RSUS 0x040C /* Request Supplies Status */
|
2019-09-10 14:34:58 -04:00
|
|
|
|
|
|
|
/* Job Control */
|
2019-10-01 21:24:49 -04:00
|
|
|
#define CMD_JC_SJ 0x0500 /* Start Job (3 arg) */
|
2019-10-01 07:12:36 -04:00
|
|
|
#define CMD_JC_EJ 0x0501 /* End Job (3 arg) */
|
2023-04-14 10:07:59 -04:00
|
|
|
#define CMD_JC_QJC 0x0502 /* Query Job Completed (5 arg) XX 6 byte resp (most), 2 (p461) */
|
2019-10-01 22:36:29 -04:00
|
|
|
#define CMD_JC_QQA 0x0503 /* Query Jobs Queued or Active (3 arg) */
|
2019-10-01 21:24:49 -04:00
|
|
|
#define CMD_JC_RSJ 0x0510 /* Resume Suspended Job (3 arg) XX */
|
2019-09-10 14:34:58 -04:00
|
|
|
|
|
|
|
/* Extended Read Device Characteristics */
|
|
|
|
#define CMD_ERDC_RS 0x8000 /* Request Summary */
|
|
|
|
#define CMD_ERDC_RCC 0x8001 /* Read Calibration Charcteristics */
|
2021-04-12 19:51:07 -04:00
|
|
|
#define CMD_ERDC_RPC 0x8005 /* Request Print Count (1 arg, 8 (51x) or 4 (52x,7xx) resp) */
|
2023-04-14 10:07:59 -04:00
|
|
|
#define CMD_ERDC_RLC 0x8006 /* Request LED calibration (10 on 52x, 6 on 461 */
|
2019-09-10 14:34:58 -04:00
|
|
|
#define CMD_ERDC_RSN 0x8007 /* Read Serial Number (1 arg) */
|
2019-10-05 20:01:07 -04:00
|
|
|
#define CMD_ERDC_C_RPCS 0x8008 /* CS Request Printer Correction Status */
|
2023-04-14 10:07:59 -04:00
|
|
|
#define CMD_ERDC_CTV 0x8008 /* Color Table Version XXX p51x, string (14 byte reply?), error on p461 */
|
2019-09-10 14:34:58 -04:00
|
|
|
#define CMD_ERDC_RPIDM 0x8009 /* Request PID and Model Code */
|
2023-04-23 17:28:58 -04:00
|
|
|
#define CMD_ERDC_UNKA 0x800A /* XX Unknown */
|
|
|
|
#define CMD_ERDC_UNKF 0x800D /* XX Unknown (1 arg) */
|
2019-09-10 14:34:58 -04:00
|
|
|
#define CMD_ERDC_RTLV 0x800E /* Request T/L Voltage */
|
|
|
|
#define CMD_ERDC_RRVC 0x800F /* Read Ribbon Vendor Code */
|
2023-05-02 10:32:13 -04:00
|
|
|
#define CMD_ERDC_UNK0 0x8010 /* Used when printer doesn't support RRVC? */
|
|
|
|
#define CMD_ERDC_UNK1 0x8011 /* Unknown Query RE, 1 arg == QUALITY? */
|
2019-10-03 09:44:22 -04:00
|
|
|
#define CMD_ERDC_RHA 0x801C /* Read Highlight Adjustment (6 resp) RE */
|
2019-09-10 14:34:58 -04:00
|
|
|
|
|
|
|
// 8008 seen in Windows Comm @ 3211 (0 len response)
|
2022-10-21 17:31:25 -04:00
|
|
|
// 800c seen on p51x (4 byte response 00 87 00 02)
|
2019-10-01 21:24:49 -04:00
|
|
|
// 8011 seen in Windows Comm @ 3369 (1 arg req (always 00), 4 len response)
|
2019-09-10 14:34:58 -04:00
|
|
|
|
|
|
|
/* Extended Format Data */
|
2019-09-27 22:50:45 -04:00
|
|
|
#define CMD_EFD_SF 0x8100 /* Sublimation Format */
|
2023-03-17 13:10:48 -04:00
|
|
|
#define CMD_EFD_CHS 0x8101 /* Color & Heating Setting (2 arg) -- Not P525 */
|
2019-10-05 20:01:07 -04:00
|
|
|
#define CMD_EFD_C_CHS 0x8102 /* CS Color Heating Setting (3 arg) */
|
|
|
|
#define CMD_EFD_C_SIID 0x8103 /* CS Set Input ID (1 arg) */
|
2019-09-10 14:34:58 -04:00
|
|
|
|
|
|
|
/* Extended Page Control */
|
|
|
|
#define CMD_EPC_SP 0x8200 /* Start Page */
|
|
|
|
#define CMD_EPC_EP 0x8201 /* End Page */
|
|
|
|
#define CMD_EPC_SYP 0x8202 /* Start Yellow Plane */
|
|
|
|
#define CMD_EPC_SMP 0x8204 /* Start Magenta Plane */
|
|
|
|
#define CMD_EPC_SCP 0x8206 /* Start Cyan Plane */
|
|
|
|
|
2019-10-05 20:01:07 -04:00
|
|
|
#define CMD_EPC_C_SYP 0x8202 /* CS Start Yellow Page */
|
|
|
|
#define CMD_EPC_C_SMP 0x8203 /* CS Start Magenta Page */
|
|
|
|
#define CMD_EPC_C_SCP 0x8204 /* CS Start Cyan Page */
|
|
|
|
#define CMD_EPC_C_SBP 0x8205 /* CS Start Black Page */
|
|
|
|
#define CMD_EPC_C_SKP 0x8206 /* CS Start K Resin Page */
|
|
|
|
#define CMD_EPC_C_SLP 0x8207 /* CS Start Lamination Page */
|
|
|
|
#define CMD_EPC_C_SOP 0x8208 /* CS Start Overcoat Page */
|
|
|
|
#define CMD_EPC_C_SY2P 0x8209 /* CS Start Yellow2 Page */
|
|
|
|
#define CMD_EPC_C_SM2P 0x820A /* CS Start Magenta2 Page */
|
|
|
|
#define CMD_EPC_C_SC2P 0x820B /* CS Start Cyan2 Page */
|
|
|
|
#define CMD_EPC_C_SB2P 0x820C /* CS Start Black2 Page */
|
|
|
|
#define CMD_EPC_C_SK2P 0x820D /* CS Start K Resin2 Page */
|
|
|
|
#define CMD_EPC_C_SL2P 0x820E /* CS Start Lamination2 Page */
|
|
|
|
#define CMD_EPC_C_SO2P 0x820F /* CS Start Overcoat2 Page */
|
|
|
|
|
2019-09-10 14:34:58 -04:00
|
|
|
/* Extended Send Data */
|
2020-03-09 23:11:49 -04:00
|
|
|
#define CMD_ESD_SEHT2 0x8303 /* Send Ext Heating Table (2 arg) */
|
2019-09-10 14:34:58 -04:00
|
|
|
#define CMD_ESD_SEHT 0x8304 /* Send Ext Heating Table XX */
|
2023-04-23 11:49:46 -04:00
|
|
|
#define CMD_ESD_UNK6 0x8306 /* Unknown, seen in FW update (1 byte payload) */
|
|
|
|
#define CMD_ESD_UNK7 0x8307 /* Unknown, seen in FW update (no payload) */
|
|
|
|
#define CMD_ESD_UNK8 0x8308 /* FW update payload (256 or 0xfc00 byte payload) */
|
2019-09-27 22:50:45 -04:00
|
|
|
#define CMD_ESD_SEPD 0x8309 /* Send Ext Print Data (2 arg) + struct */
|
2023-04-23 17:28:58 -04:00
|
|
|
#define CMD_ESD_SHCI 0x830A /* Unknown, seen on P51x (4 byte payload) */
|
2023-04-16 20:48:51 -04:00
|
|
|
#define CMD_ESD_SHPTC 0x830B /* Send Heating Parameters & Tone Curve XX (4167 byte payload on p461) */
|
2019-10-05 20:01:07 -04:00
|
|
|
#define CMD_ESD_C_SHPTC 0x830C /* CS Send Heating Parameters & Tone Curve XX (n arg) */
|
2019-09-10 14:34:58 -04:00
|
|
|
|
|
|
|
/* Extended Flash/NVram */
|
2023-04-23 17:28:58 -04:00
|
|
|
#define CMD_EFM_UNK3 0x8403 /* Write NVRAM, maybe? */
|
2022-10-22 22:03:21 -04:00
|
|
|
#define CMD_EFM_RNV 0x8405 /* Read NVRam (1 arg) -- arg is offset, 1 byte resp of data @ that offset. -- P51x */
|
2023-04-23 17:28:58 -04:00
|
|
|
#define CMD_EFM_UNK6 0x8406 /* Write NVRAM, maybe? */
|
2022-10-20 20:56:40 -04:00
|
|
|
#define CMD_EFM_RD 0x8408 /* Read single location (2 byte offset arg, 1 byte of data @ that offset -- not P51x */
|
2023-04-23 17:28:58 -04:00
|
|
|
#define CMD_EFM_UNKC 0x840C /* Write NVRAM, maybe? */
|
2019-10-03 09:44:22 -04:00
|
|
|
#define CMD_EFM_SHA 0x840E /* Set Highlight Adjustment (5 arg) -- XXX RE */
|
2019-09-10 14:34:58 -04:00
|
|
|
|
2023-04-23 17:28:58 -04:00
|
|
|
#define CMD_ERD_RTCV 0x8702 /* XX No idea what this does */
|
|
|
|
|
2019-10-05 20:01:07 -04:00
|
|
|
/* Extended Security Control */
|
|
|
|
#define CMD_ESC_SP 0x8900 /* Set Password */
|
|
|
|
#define CMD_ESC_SSM 0x8901 /* Set Security Mode */
|
|
|
|
|
|
|
|
/* Extended Debug Mode */
|
2020-03-09 23:11:49 -04:00
|
|
|
#define CMD_EDM_CVD 0xE002 /* Common Voltage Drop Values (n arg) */
|
2019-09-10 14:34:58 -04:00
|
|
|
#define CMD_EDM_CPP 0xE023 /* Clean Paper Path (1 arg) XX */
|
2023-05-02 10:32:13 -04:00
|
|
|
#define CMD_EDM_UNK 0xE028 /* XX Called if ERC_RTCV is supported. */
|
2019-10-05 20:01:07 -04:00
|
|
|
#define CMD_EDM_C_MC2CES 0xE02E /* CS Move card to Contact Encoder Station */
|
|
|
|
#define CMD_EDM_C_MC2MES 0xE02F /* CS Move card to Mag Encoder Station */
|
|
|
|
#define CMD_EDM_C_MC2CLES 0xE030 /* CS Move card to ContactLess Encoder Station */
|
|
|
|
#define CMD_EDM_C_MC2EB 0xE031 /* CS Move card to Eject Box */
|
|
|
|
#define CMD_EDM_C_MC2H 0xE037 /* CS Move card to Hopper */
|
2019-09-10 14:34:58 -04:00
|
|
|
|
2023-04-23 17:28:58 -04:00
|
|
|
#define CMD_UNK_UNK 0xE200
|
|
|
|
|
2019-10-01 21:24:49 -04:00
|
|
|
/* CMD_PCC_RP */
|
|
|
|
#define RESET_PRINTER 0x01
|
|
|
|
#define RESET_SOFT 0x02
|
|
|
|
|
2019-10-03 09:44:22 -04:00
|
|
|
/* 801C --> 0 args
|
2022-06-20 23:29:25 -04:00
|
|
|
<-- 6 bytes: 00 YY MM CC 00 00 (YMC is +- 31 decimal)
|
2019-10-03 09:44:22 -04:00
|
|
|
|
2022-06-20 23:29:25 -04:00
|
|
|
840E --> 5 args: YY MM CC 00 00 (YMC is +- 31 decimal)
|
2019-10-03 09:44:22 -04:00
|
|
|
<-- 1 arg: 00 (success, presumably)
|
|
|
|
|
2020-02-04 08:40:54 -05:00
|
|
|
Highlight Correction. Unclear if it's used by printer or by "driver"
|
|
|
|
|
2019-10-03 09:44:22 -04:00
|
|
|
*/
|
|
|
|
|
2019-09-10 14:34:58 -04:00
|
|
|
/* CMD_ERDC_RCC */
|
|
|
|
struct hiti_calibration {
|
|
|
|
uint8_t horiz;
|
|
|
|
uint8_t vert;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
/* CMD_ERDC_RPIDM */
|
|
|
|
struct hiti_rpidm {
|
|
|
|
uint16_t usb_pid; /* BE */
|
|
|
|
uint8_t region; /* See hiti_regions */
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
/* CMD_EDRC_RS */
|
|
|
|
struct hiti_erdc_rs { /* All are BIG endian */
|
|
|
|
uint8_t unk; // 1e == 30, but struct is 29 length.
|
2023-04-22 11:51:22 -04:00
|
|
|
uint16_t stride; /* Head width: 1920 (6" models) 1280 (4" models) */
|
2019-09-10 14:34:58 -04:00
|
|
|
uint16_t dpi_cols; /* fixed at 300 */
|
|
|
|
uint16_t dpi_rows; /* fixed at 300 */
|
|
|
|
uint16_t cols; /* 1844 for 6" media */
|
|
|
|
uint16_t rows; /* 1240 for 6x4" media */
|
2022-10-21 17:31:25 -04:00
|
|
|
uint8_t unk2[18]; // ff ff 4b 4b 4b 4b af 3c 4f 7b 19 08 5c 0a b4 64 af af (p520l)
|
|
|
|
// 55 a0 96 96 96 96 d2 78 0e 3f 6e 08 5c 09 82 40 d2 a0 (p510s)
|
2023-04-14 10:07:59 -04:00
|
|
|
// ff ff 0f 0f 0f 0f 7d 14 4f 7b 20 00 00 00 00 20 7d 64 (p461)
|
2019-09-10 14:34:58 -04:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
2019-10-01 21:24:49 -04:00
|
|
|
/* CMD_JC_* */
|
|
|
|
struct hiti_job {
|
|
|
|
uint8_t lun; /* Logical Unit Number. Leave at 0 */
|
|
|
|
uint16_t jobid; /* BE */
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2020-01-16 09:41:03 -05:00
|
|
|
/* CMD_JC_QQA */
|
|
|
|
#define MAX_JOBS 4
|
|
|
|
struct hiti_job_qqa {
|
|
|
|
uint8_t count; /* 0-MAX_JOBS */
|
|
|
|
struct {
|
|
|
|
struct hiti_job job;
|
|
|
|
uint8_t status;
|
|
|
|
} row[MAX_JOBS]; /* Four jobs max outstanding */
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
#define QQA_STATUS_PRINTING 0x00
|
|
|
|
#define QQA_STATUS_WAITING 0x01
|
|
|
|
#define QQA_STATUS_SUSPENDED 0x03
|
2022-10-01 21:10:30 -04:00
|
|
|
#define QQA_STATUS_ERROR 0x80 // ???
|
2020-01-16 09:41:03 -05:00
|
|
|
|
2019-10-01 21:24:49 -04:00
|
|
|
/* CMD_JC_QJC */
|
|
|
|
struct hiti_jc_qjc {
|
|
|
|
uint8_t lun; /* Logical Unit Number. Leave at 0 */
|
|
|
|
uint16_t jobid; /* BE */
|
|
|
|
uint16_t jobid2; /* BE, set to 1? */
|
|
|
|
} __attribute__((packed));
|
|
|
|
// repsonse is 6 bytes.
|
|
|
|
|
2023-04-14 10:07:59 -04:00
|
|
|
// Roll Type:
|
|
|
|
// 5x3.5 1547 1072
|
|
|
|
// 6x4 1844 1240
|
|
|
|
// 6x9 1844 2740
|
|
|
|
// 6x8/2 1844 2492
|
|
|
|
// 6x8 1844 2434
|
|
|
|
// 5x7 1548 2140
|
|
|
|
// 5x7/2 1548 2152
|
|
|
|
// 6x4/2 1844 1248
|
2019-10-01 21:24:49 -04:00
|
|
|
// 6x6 1844 1844
|
|
|
|
// 5x5 1540 1540 ? (1548?)
|
|
|
|
// 6x5 1844 1544
|
|
|
|
// 6x2 1844 ????
|
2019-09-30 21:19:33 -04:00
|
|
|
|
2023-04-14 10:07:59 -04:00
|
|
|
// Sheet type:
|
|
|
|
// 6x4 1818 1280
|
|
|
|
|
2019-09-30 21:19:33 -04:00
|
|
|
#define PRINT_TYPE_6x4 0
|
|
|
|
#define PRINT_TYPE_5x7 2
|
|
|
|
#define PRINT_TYPE_6x8 3
|
|
|
|
#define PRINT_TYPE_6x9 6
|
|
|
|
#define PRINT_TYPE_6x9_2UP 7
|
|
|
|
#define PRINT_TYPE_5x3_5 8
|
|
|
|
#define PRINT_TYPE_6x4_2UP 9
|
|
|
|
#define PRINT_TYPE_6x2 10
|
2019-09-27 22:50:45 -04:00
|
|
|
#define PRINT_TYPE_5x7_2UP 11
|
2019-09-10 14:34:58 -04:00
|
|
|
|
2022-06-23 16:29:40 -04:00
|
|
|
struct hiti_heattable_v1a { /* P51x (older) */
|
2022-05-26 12:52:05 -04:00
|
|
|
uint8_t y[2050]; /* 256 doubles, plus 2 byte checksum? */
|
2020-03-09 23:11:49 -04:00
|
|
|
uint8_t pad0[30];
|
|
|
|
uint8_t m[2050];
|
|
|
|
uint8_t pad1[30];
|
|
|
|
uint8_t c[2050];
|
|
|
|
uint8_t pad2[30];
|
2021-02-26 22:04:20 -05:00
|
|
|
uint8_t o[2050]; /* Overcoat Glossy */
|
2020-03-09 23:11:49 -04:00
|
|
|
uint8_t pad3[30];
|
2021-02-26 22:04:20 -05:00
|
|
|
uint8_t om[2050]; /* Overcoat Matte */
|
2020-03-09 23:11:49 -04:00
|
|
|
uint8_t pad4[30];
|
2022-06-23 16:29:40 -04:00
|
|
|
uint8_t cvd[582]; /* 58 u16 * 5 (y/m/c/o/om) + 2 byte checksum? */
|
2020-03-09 23:11:49 -04:00
|
|
|
uint8_t pad5[26];
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2022-06-23 16:29:40 -04:00
|
|
|
STATIC_ASSERT(sizeof(struct hiti_heattable_v1a) == 11008);
|
|
|
|
|
2022-10-27 05:17:40 -04:00
|
|
|
struct hiti_heattable_v1b_hdr {
|
|
|
|
uint8_t type;
|
|
|
|
uint32_t len; /* Length in 16-bit words, LE */
|
|
|
|
} __attribute((packed));
|
|
|
|
|
2022-06-23 16:29:40 -04:00
|
|
|
struct hiti_heattable_v1b { /* P51x (newer) */
|
2022-10-27 05:17:40 -04:00
|
|
|
struct hiti_heattable_v1b_hdr y_hdr; // 01 01 04 00 00
|
2022-06-23 16:29:40 -04:00
|
|
|
uint8_t y[2050]; /* 256 doubles, 2 checksum */
|
2022-10-27 05:17:40 -04:00
|
|
|
struct hiti_heattable_v1b_hdr m_hdr; // 02 01 04 00 00
|
2022-06-23 16:29:40 -04:00
|
|
|
uint8_t m[2050]; /* 256 doubles, 2 checksum */
|
2022-10-27 05:17:40 -04:00
|
|
|
struct hiti_heattable_v1b_hdr c_hdr; // 03 01 04 00 00
|
2022-06-23 16:29:40 -04:00
|
|
|
uint8_t c[2050]; /* 256 doubles, 2 checksum */
|
2022-10-27 05:17:40 -04:00
|
|
|
struct hiti_heattable_v1b_hdr o_hdr; // 04 01 04 00 00
|
2022-06-23 16:29:40 -04:00
|
|
|
uint8_t o[2050]; /* 256 doubles, 2 checksum */
|
2022-10-27 05:17:40 -04:00
|
|
|
struct hiti_heattable_v1b_hdr om_hdr; // 05 01 04 00 00
|
2022-06-23 16:29:40 -04:00
|
|
|
uint8_t om[2050]; /* 256 doubles, 2 checksum */
|
2022-10-27 05:17:40 -04:00
|
|
|
struct hiti_heattable_v1b_hdr u_hdr; // 07 01 04 00 00
|
2022-06-23 16:29:40 -04:00
|
|
|
uint8_t u[2050]; /* 256 doubles, 2 checksum */ // unknown purpose
|
2022-10-27 05:17:40 -04:00
|
|
|
struct hiti_heattable_v1b_hdr cvd_hdr; // 08 23 01 00 00
|
2022-06-23 16:29:40 -04:00
|
|
|
uint8_t cvd[582]; /* 58 u16 * 5 (y/m/c/o/om) + 2 byte checksum? */
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
STATIC_ASSERT(sizeof(struct hiti_heattable_v1b) == 12917);
|
2020-03-09 23:11:49 -04:00
|
|
|
|
2022-06-26 00:47:06 -04:00
|
|
|
/* All fields are little endian */
|
|
|
|
struct hiti_heattable_entry_v2 {
|
2022-10-28 00:27:03 -04:00
|
|
|
uint8_t type;
|
|
|
|
uint32_t len; /* in 16-bit words */
|
2022-06-26 00:47:06 -04:00
|
|
|
uint32_t offset;
|
|
|
|
} __attribute((packed));
|
|
|
|
|
|
|
|
struct hiti_heattable_hdr_v2 {
|
|
|
|
uint8_t num_headers;
|
|
|
|
struct hiti_heattable_entry_v2 entries[];
|
|
|
|
} __attribute((packed));
|
|
|
|
|
|
|
|
#define HEATTABLE_V2_MAX_SIZE (1024*128)
|
|
|
|
|
2023-06-05 22:26:09 -04:00
|
|
|
#define HEATTABLE_S_SIZE 4167 /* P461, P310, and some P32x */
|
|
|
|
#define HEATTABLE_S2_SIZE 4232 /* Some P32x */
|
2023-04-16 20:48:51 -04:00
|
|
|
|
2023-05-04 12:26:37 -04:00
|
|
|
// 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
|
|
|
|
|
2019-09-30 21:19:33 -04:00
|
|
|
/* All fields are LE */
|
|
|
|
struct hiti_gpjobhdr {
|
2019-10-01 17:57:33 -04:00
|
|
|
uint32_t cookie; /* "GPHT" */
|
2019-09-30 21:19:33 -04:00
|
|
|
uint32_t hdr_len; /* Including the whole thing */
|
2020-02-04 08:40:54 -05:00
|
|
|
uint32_t model; /* Model family, in decimal */
|
2019-09-30 21:19:33 -04:00
|
|
|
uint32_t cols;
|
|
|
|
uint32_t rows;
|
|
|
|
uint32_t col_dpi;
|
|
|
|
uint32_t row_dpi;
|
|
|
|
uint32_t copies;
|
2019-10-23 21:45:31 -04:00
|
|
|
uint32_t quality; /* 0 for std, 1 for fine */
|
|
|
|
uint32_t code; /* PRINT_TYPE_* */
|
|
|
|
uint32_t overcoat; /* 1 for matte, 0 for glossy */
|
2020-02-04 08:40:54 -05:00
|
|
|
uint32_t payload_flag; /* See PAYLOAD_FLAG_* */
|
2019-09-30 21:19:33 -04:00
|
|
|
uint32_t payload_len;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2020-02-04 08:40:54 -05:00
|
|
|
#define PAYLOAD_FLAG_YMCPLANAR 0x01
|
|
|
|
#define PAYLOAD_FLAG_NOCORRECT 0x02
|
2023-04-24 14:47:03 -04:00
|
|
|
#define PAYLOAD_FLAG_MEDIAVER 0x03
|
2019-10-01 17:57:33 -04:00
|
|
|
|
2019-09-30 21:19:33 -04:00
|
|
|
#define HDR_COOKIE 0x54485047
|
|
|
|
|
2019-10-05 20:01:07 -04:00
|
|
|
/* CMD_EFD_SF for non-CS systems */
|
2019-09-10 14:34:58 -04:00
|
|
|
struct hiti_efd_sf {
|
|
|
|
/*@0 */ uint8_t mediaType; /* PRINT_TYPE_?? */
|
|
|
|
/*@1 */ uint16_t cols_res; /* BE, always 300dpi */
|
|
|
|
/*@3 */ uint16_t rows_res; /* BE, always 300dpi */
|
2019-09-27 22:50:45 -04:00
|
|
|
/*@5 */ uint16_t cols; /* BE */
|
|
|
|
/*@7 */ uint16_t rows; /* BE */
|
2019-09-10 14:34:58 -04:00
|
|
|
/*@9 */ int8_t rows_offset; /* Has to do with H_Offset calibration */
|
|
|
|
/*@10*/ int8_t cols_offset; /* Has to do wiwth V_Offset calibration */
|
2023-06-01 20:31:03 -04:00
|
|
|
/*@11*/ uint8_t colorSeq; /* See SF_COLORSEQ_* */
|
2019-09-10 14:34:58 -04:00
|
|
|
/*@12*/ uint8_t copies;
|
2023-06-01 20:31:03 -04:00
|
|
|
/*@13*/ uint8_t printMode; /* See SF_PRINTMODE_* */
|
2023-04-22 11:51:22 -04:00
|
|
|
/*@14*/ uint8_t zero[4]; /* P461 only */
|
2019-09-10 14:34:58 -04:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
2023-06-01 20:31:03 -04:00
|
|
|
/* SF_COLORSEQ is actually:
|
|
|
|
|
|
|
|
Y 0x01
|
|
|
|
M 0x02
|
|
|
|
C 0x04
|
|
|
|
DK 0x08 (Dye Black)
|
|
|
|
RK 0x10 (Resin Black)
|
|
|
|
OM 0x20 (NOT CSxxx models)
|
|
|
|
O 0x80 (On CSxx, means there is an explicit O plane)
|
|
|
|
*/
|
|
|
|
#define SF_COLORSEQ_YMCO 0x87
|
|
|
|
#define SF_COLORSEQ_MATTE 0xC0
|
|
|
|
|
|
|
|
#define SF_PRINTMODE_NORMAL 0x00
|
|
|
|
#define SF_PRINTMODE_SPLITK 0x01 /* CSxxx only */
|
|
|
|
#define SF_PRINTMODE_FINE 0x02 /* For P5xx/P7xx only */
|
|
|
|
#define SF_PRINTMODE_BASE 0x08 /* For P5xx/P7xx only */
|
|
|
|
#define SF_PRINTMODE_OBHEAT 0x10 /* Onboard Heat Comp, CSxxx only */
|
|
|
|
|
2019-09-10 14:34:58 -04:00
|
|
|
/* CMD_ESD_SEPD -- Note it's different from the usual command flow */
|
|
|
|
struct hiti_extprintdata {
|
|
|
|
uint8_t hdr; /* 0xa5 */
|
|
|
|
uint16_t len; /* 24bit data length (+8) in BE format, first two bytes */
|
2021-04-13 12:06:58 -04:00
|
|
|
uint8_t status; /* 0x50 */
|
2019-09-10 14:34:58 -04:00
|
|
|
uint16_t cmd; /* 0x8309, BE */
|
|
|
|
uint8_t lenb; /* LSB of length */
|
|
|
|
uint16_t startLine; /* Starting line number, BE */
|
|
|
|
uint16_t numLines; /* Number of lines in block, BE, 3000 max. */
|
|
|
|
uint8_t payload[]; /* ie data length bytes */
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2020-03-09 23:11:49 -04:00
|
|
|
/* CMD_ESD_SEHT2 -- Note it's different from the usual command flow */
|
|
|
|
struct hiti_seht2 {
|
|
|
|
uint8_t hdr; /* 0xa5 */
|
|
|
|
uint16_t len; /* 24-bit data length (+5) in BE format, first two bytes */
|
2021-04-13 12:06:58 -04:00
|
|
|
uint8_t status; /* 0x50 */
|
2020-03-09 23:11:49 -04:00
|
|
|
uint16_t cmd; /* 0x8303, BE */
|
|
|
|
uint8_t lenb; /* LSB of length */
|
|
|
|
uint8_t plane;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2019-09-10 14:34:58 -04:00
|
|
|
/* All multi-byte fields here are LE */
|
|
|
|
struct hiti_matrix {
|
|
|
|
/*@00*/ uint8_t row0[16]; // all 00
|
|
|
|
|
|
|
|
/*@10*/ uint8_t row1[6]; // 01 00 00 00 00 00
|
|
|
|
uint16_t cuttercount;
|
|
|
|
uint8_t align_v;
|
|
|
|
uint8_t aligh_h;
|
|
|
|
uint8_t row1_2[6]; // all 00
|
|
|
|
|
|
|
|
/*@20*/ uint8_t row2[16]; // no idea
|
|
|
|
|
|
|
|
/*@30*/ uint8_t error_index0; /* Value % 31 == NEWEST. Count back */
|
|
|
|
uint8_t errorcode[31];
|
|
|
|
|
|
|
|
/*@50*/ uint8_t row5[16]; // all 00, except [8] which is a5.
|
|
|
|
/*@60*/ char serno[16]; /* device serial number */
|
|
|
|
|
|
|
|
/*@70*/ uint16_t unclean_prints;
|
|
|
|
uint16_t cleanat[15]; // XX Guess?
|
|
|
|
|
|
|
|
/*@90*/ uint16_t supply_motor;
|
|
|
|
uint16_t take_motor;
|
|
|
|
uint8_t row9[12]; // all 00 except last, which is 0xa5
|
|
|
|
|
|
|
|
/*@a0*/ uint16_t errorcount[31];
|
2022-10-22 22:03:21 -04:00
|
|
|
uint8_t rowd[2]; // seems to be 00 cc ?
|
2019-09-10 14:34:58 -04:00
|
|
|
|
|
|
|
/*@e0*/ uint16_t tpc_4x6;
|
|
|
|
uint16_t tpc_5x7;
|
|
|
|
uint16_t tpc_6x8;
|
|
|
|
uint16_t tpc_6x9;
|
|
|
|
uint8_t unk_rowe[8]; // all 00
|
|
|
|
|
|
|
|
/*@f0*/ uint16_t apc_4x6;
|
|
|
|
uint16_t apc_5x7;
|
|
|
|
uint16_t apc_6x8;
|
|
|
|
uint16_t apc_6x9;
|
|
|
|
uint8_t unk_rowf[4]; // all 00
|
|
|
|
uint8_t tphv_a;
|
|
|
|
uint8_t tphv_d;
|
|
|
|
uint8_t unk_rowf2[2]; // all 00
|
2022-10-22 22:03:21 -04:00
|
|
|
|
|
|
|
/*@100*/uint8_t unk_row10[16];
|
|
|
|
/*@110*/uint8_t unk_row11[16];
|
|
|
|
/*@120*/uint8_t unk_row12[16];
|
|
|
|
/*@130*/uint8_t unk_row13[16];
|
|
|
|
/*@140*/uint8_t unk_row14[16];
|
|
|
|
/*@150*/uint8_t unk_row15[16];
|
|
|
|
/*@160*/uint8_t unk_row16[16];
|
|
|
|
/*@170*/uint8_t unk_row17[16];
|
|
|
|
/*@180*/uint8_t unk_row18[16];
|
|
|
|
/*@190*/uint8_t unk_row19[16];
|
|
|
|
/*@1a0*/uint8_t unk_row1a[16];
|
|
|
|
/*@1b0*/uint8_t unk_row1b[16];
|
|
|
|
/*@1c0*/uint8_t unk_row1c[16];
|
|
|
|
/*@1d0*/uint8_t unk_row1d[16];
|
|
|
|
/*@1e0*/uint8_t unk_row1e[16];
|
|
|
|
/*@1f0*/uint8_t unk_row1f[16];
|
|
|
|
/*@200*/
|
2019-09-10 14:34:58 -04:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
2022-10-22 22:03:21 -04:00
|
|
|
STATIC_ASSERT(sizeof(struct hiti_matrix) == 512);
|
|
|
|
|
2022-09-16 14:55:01 -04:00
|
|
|
struct hiti_ribbon {
|
2023-04-14 10:07:59 -04:00
|
|
|
uint16_t unk; // 01 08 (p461)
|
2022-09-16 14:55:01 -04:00
|
|
|
uint8_t type; /* RIBBON_TYPE_XXX */
|
2023-04-14 10:07:59 -04:00
|
|
|
uint16_t unk2; // 00 07 (p461)
|
2022-09-16 14:55:01 -04:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
#define RIBBON_TYPE_4x6 0x01
|
|
|
|
#define RIBBON_TYPE_5x7 0x02
|
|
|
|
#define RIBBON_TYPE_6x9 0x03
|
|
|
|
#define RIBBON_TYPE_6x8 0x04
|
|
|
|
|
|
|
|
struct hiti_paper {
|
|
|
|
uint8_t unk;
|
|
|
|
uint8_t type; /* PAPER_TYPE_XXX */
|
|
|
|
uint16_t unk2;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2023-04-14 10:07:59 -04:00
|
|
|
#define PAPER_TYPE_X4INCH 0xf0 // XXX hack
|
2022-09-16 14:55:01 -04:00
|
|
|
#define PAPER_TYPE_5INCH 0x02
|
|
|
|
#define PAPER_TYPE_6INCH 0x01
|
|
|
|
#define PAPER_TYPE_NONE 0x00
|
|
|
|
|
2019-09-10 14:34:58 -04:00
|
|
|
/* Private data structure */
|
|
|
|
struct hiti_printjob {
|
2021-09-30 14:52:11 -04:00
|
|
|
struct dyesub_job_common common;
|
2021-04-14 07:44:58 -04:00
|
|
|
|
2019-09-10 14:34:58 -04:00
|
|
|
uint8_t *databuf;
|
|
|
|
uint32_t datalen;
|
|
|
|
|
2019-09-30 21:19:33 -04:00
|
|
|
struct hiti_gpjobhdr hdr;
|
2019-09-10 14:34:58 -04:00
|
|
|
|
|
|
|
int blocks;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hiti_ctx {
|
2020-08-11 20:27:26 -04:00
|
|
|
struct dyesub_connection *conn;
|
|
|
|
|
2019-09-10 14:34:58 -04:00
|
|
|
int jobid;
|
2022-10-29 10:27:51 -04:00
|
|
|
int nodata;
|
2019-09-10 14:34:58 -04:00
|
|
|
|
2019-12-13 15:24:35 -05:00
|
|
|
char serno[32];
|
|
|
|
|
2021-04-12 19:51:07 -04:00
|
|
|
int erdc_rpc_len;
|
|
|
|
|
2019-09-10 14:34:58 -04:00
|
|
|
struct marker marker;
|
|
|
|
char version[256];
|
|
|
|
char id[256];
|
2022-10-22 22:03:21 -04:00
|
|
|
uint8_t matrix[512]; // XXX convert to struct matrix */
|
2022-09-16 14:55:01 -04:00
|
|
|
struct hiti_ribbon ribbon;
|
|
|
|
struct hiti_paper paper;
|
2019-09-10 14:34:58 -04:00
|
|
|
struct hiti_calibration calibration;
|
|
|
|
uint8_t led_calibration[10]; // XXX convert to struct
|
2019-10-03 21:05:18 -04:00
|
|
|
uint8_t unk_8010[15]; // XXX
|
2019-09-27 22:50:45 -04:00
|
|
|
struct hiti_erdc_rs erdc_rs;
|
2021-04-08 08:00:52 -04:00
|
|
|
uint8_t hilight_adj[6]; // XXX convert to struct, not P51x!
|
2019-09-10 14:34:58 -04:00
|
|
|
uint8_t rtlv[2]; /* XXX figure out conversion/math? */
|
|
|
|
struct hiti_rpidm rpidm;
|
2023-06-01 20:31:03 -04:00
|
|
|
uint16_t ribbonvendor; // see below.
|
2019-09-10 14:34:58 -04:00
|
|
|
uint32_t media_remain; // XXX could be array?
|
2022-06-26 00:47:06 -04:00
|
|
|
|
|
|
|
uint8_t *heattable_buf;
|
|
|
|
struct hiti_heattable_v2 {
|
2022-10-28 00:27:03 -04:00
|
|
|
uint8_t type;
|
|
|
|
uint8_t *data;
|
2022-06-26 00:47:06 -04:00
|
|
|
uint32_t len;
|
|
|
|
} *heattable_v2;
|
|
|
|
uint8_t num_heattable_entries;
|
2019-09-10 14:34:58 -04:00
|
|
|
};
|
|
|
|
|
2023-06-01 20:31:03 -04:00
|
|
|
#define RRVC_VENDOR_MASK 0xf000
|
|
|
|
#define RRVC_VERSION_MASK 0x003f
|
|
|
|
|
2019-09-10 14:34:58 -04:00
|
|
|
/* Prototypes */
|
2019-10-01 21:24:49 -04:00
|
|
|
static int hiti_doreset(struct hiti_ctx *ctx, uint8_t type);
|
2020-01-16 09:41:03 -05:00
|
|
|
static int hiti_query_job_qa(struct hiti_ctx *ctx, struct hiti_job *jobid, struct hiti_job_qqa *resp);
|
2019-10-01 07:12:36 -04:00
|
|
|
static int hiti_query_status(struct hiti_ctx *ctx, uint8_t *sts, uint32_t *err);
|
2019-09-10 14:34:58 -04:00
|
|
|
static int hiti_query_version(struct hiti_ctx *ctx);
|
|
|
|
static int hiti_query_matrix(struct hiti_ctx *ctx);
|
2022-10-20 20:56:40 -04:00
|
|
|
static int hiti_query_matrix_51x(struct hiti_ctx *ctx);
|
2019-09-10 14:34:58 -04:00
|
|
|
static int hiti_query_supplies(struct hiti_ctx *ctx);
|
|
|
|
static int hiti_query_tphv(struct hiti_ctx *ctx);
|
|
|
|
static int hiti_query_statistics(struct hiti_ctx *ctx);
|
|
|
|
static int hiti_query_calibration(struct hiti_ctx *ctx);
|
|
|
|
static int hiti_query_led_calibration(struct hiti_ctx *ctx);
|
|
|
|
static int hiti_query_ribbonvendor(struct hiti_ctx *ctx);
|
2019-09-27 22:50:45 -04:00
|
|
|
static int hiti_query_summary(struct hiti_ctx *ctx, struct hiti_erdc_rs *rds);
|
2019-09-10 14:34:58 -04:00
|
|
|
static int hiti_query_rpidm(struct hiti_ctx *ctx);
|
2019-10-03 09:44:22 -04:00
|
|
|
static int hiti_query_hilightadj(struct hiti_ctx *ctx);
|
2019-10-03 21:05:18 -04:00
|
|
|
static int hiti_query_unk8010(struct hiti_ctx *ctx);
|
2021-04-12 19:51:07 -04:00
|
|
|
static int hiti_query_counter(struct hiti_ctx *ctx, uint8_t arg, uint32_t *resp, int num);
|
2019-09-10 14:34:58 -04:00
|
|
|
static int hiti_query_markers(void *vctx, struct marker **markers, int *count);
|
|
|
|
|
2020-08-11 20:27:26 -04:00
|
|
|
static int hiti_query_serno(struct dyesub_connection *conn, char *buf, int buf_len);
|
2022-10-28 00:27:03 -04:00
|
|
|
static int hiti_read_heattable_v2(struct hiti_ctx *ctx, const char* fname);
|
2023-05-04 12:26:37 -04:00
|
|
|
static void *hiti_find_heattable_v2_entry(struct hiti_ctx *ctx, int id, size_t *len);
|
2019-12-13 15:24:35 -05:00
|
|
|
|
2019-09-10 14:34:58 -04:00
|
|
|
static int hiti_docmd(struct hiti_ctx *ctx, uint16_t cmdid, uint8_t *buf, uint16_t buf_len, uint16_t *rsplen)
|
|
|
|
{
|
2019-09-28 15:32:29 -04:00
|
|
|
uint8_t cmdbuf[2048];
|
2019-09-10 14:34:58 -04:00
|
|
|
struct hiti_cmd *cmd = (struct hiti_cmd *)cmdbuf;
|
|
|
|
int ret, num = 0;
|
|
|
|
|
|
|
|
cmd->hdr = 0xa5;
|
2019-09-28 15:32:29 -04:00
|
|
|
cmd->len = cpu_to_be16(buf_len + 3);
|
2021-04-13 12:18:08 -04:00
|
|
|
cmd->status = CMD_STATUS_OK;
|
2019-09-10 14:34:58 -04:00
|
|
|
cmd->cmd = cpu_to_be16(cmdid);
|
|
|
|
if (buf && buf_len)
|
|
|
|
memcpy(cmd->payload, buf, buf_len);
|
|
|
|
|
|
|
|
/* Send over command */
|
2020-08-11 20:27:26 -04:00
|
|
|
if ((ret = send_data(ctx->conn, (uint8_t*) cmd, buf_len + 3 + 3))) {
|
2019-09-10 14:34:58 -04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-03-24 19:33:20 -04:00
|
|
|
__usleep(10*1000);
|
2019-10-01 23:43:07 -04:00
|
|
|
|
2019-09-10 14:34:58 -04:00
|
|
|
/* Read back command */
|
2022-06-18 18:16:26 -04:00
|
|
|
ret = read_data(ctx->conn, cmdbuf, 6, &num);
|
2019-09-10 14:34:58 -04:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (num != 6) {
|
|
|
|
ERROR("CMD Readback length mismatch (%d vs %d)!\n", num, 6);
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compensate for hdr len */
|
2019-09-30 21:19:33 -04:00
|
|
|
num = be16_to_cpu(cmd->len) - 3;
|
|
|
|
|
2019-10-01 07:12:36 -04:00
|
|
|
if (num > *rsplen) {
|
|
|
|
ERROR("Response too long for buffer (%d vs %d)!\n", num, *rsplen);
|
2019-09-30 21:19:33 -04:00
|
|
|
*rsplen = 0;
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
}
|
|
|
|
|
2021-04-08 08:05:33 -04:00
|
|
|
/* Check response */
|
2023-03-31 12:13:04 -04:00
|
|
|
if (cmd->status & CMD_STATUS_ERR) {
|
2021-04-08 08:05:33 -04:00
|
|
|
ERROR("Command %04x failed, code %02x\n", cmdid, cmd->status);
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
}
|
|
|
|
|
2019-09-30 21:19:33 -04:00
|
|
|
*rsplen = num;
|
2019-09-10 14:34:58 -04:00
|
|
|
|
|
|
|
return CUPS_BACKEND_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hiti_docmd_resp(struct hiti_ctx *ctx, uint16_t cmdid,
|
|
|
|
uint8_t *buf, uint8_t buf_len,
|
|
|
|
uint8_t *respbuf, uint16_t *resplen)
|
|
|
|
{
|
|
|
|
int ret, num = 0;
|
2019-09-30 21:19:33 -04:00
|
|
|
uint16_t cmd_resp_len = *resplen;
|
2019-09-10 14:34:58 -04:00
|
|
|
|
|
|
|
ret = hiti_docmd(ctx, cmdid, buf, buf_len, &cmd_resp_len);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (cmd_resp_len > *resplen) {
|
|
|
|
ERROR("Response too long! (%d vs %d)\n", cmd_resp_len, *resplen);
|
|
|
|
*resplen = 0;
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
}
|
|
|
|
|
2020-03-24 19:33:20 -04:00
|
|
|
__usleep(10*1000);
|
2019-10-01 23:43:07 -04:00
|
|
|
|
2019-09-10 14:34:58 -04:00
|
|
|
/* Read back the data*/
|
2022-06-18 18:16:26 -04:00
|
|
|
int remain = *resplen;
|
|
|
|
int total = 0;
|
|
|
|
do {
|
|
|
|
ret = read_data(ctx->conn, respbuf + total, remain, &num);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
total += num;
|
|
|
|
remain -= num;
|
|
|
|
} while (remain > 0 && num == 64);
|
2019-09-10 14:34:58 -04:00
|
|
|
|
|
|
|
/* Sanity check */
|
2022-06-18 18:16:26 -04:00
|
|
|
if (total > *resplen) {
|
|
|
|
ERROR("Response too long for buffer (%d vs %d)!\n", total, *resplen);
|
2019-09-10 14:34:58 -04:00
|
|
|
*resplen = 0;
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
}
|
|
|
|
|
2022-06-18 18:16:26 -04:00
|
|
|
*resplen = total;
|
2019-09-10 14:34:58 -04:00
|
|
|
|
|
|
|
return CUPS_BACKEND_OK;
|
|
|
|
}
|
|
|
|
|
2023-04-22 11:51:22 -04:00
|
|
|
static int hiti_shptc(struct hiti_ctx *ctx, uint8_t *buf, uint16_t buf_len)
|
|
|
|
{
|
|
|
|
uint8_t cmdbuf[sizeof(struct hiti_cmd)];
|
|
|
|
struct hiti_cmd *cmd = (struct hiti_cmd *)cmdbuf;
|
|
|
|
int ret, num = 0;
|
|
|
|
|
|
|
|
cmd->hdr = 0xa5;
|
|
|
|
cmd->len = cpu_to_be16(buf_len + 3);
|
|
|
|
cmd->status = CMD_STATUS_OK;
|
|
|
|
cmd->cmd = cpu_to_be16(CMD_ESD_SHPTC);
|
|
|
|
|
|
|
|
/* Send over command */
|
|
|
|
if ((ret = send_data(ctx->conn, (uint8_t*) cmd, sizeof(*cmd)))) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
__usleep(10*1000);
|
|
|
|
|
|
|
|
/* Read back command */
|
|
|
|
ret = read_data(ctx->conn, cmdbuf, 6, &num);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (num != 6) {
|
|
|
|
ERROR("CMD Readback length mismatch (%d vs %d)!\n", num, 6);
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = send_data(ctx->conn, buf, buf_len);
|
|
|
|
if (ret)
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
return CUPS_BACKEND_OK;
|
|
|
|
}
|
|
|
|
|
2019-09-10 14:34:58 -04:00
|
|
|
static int hiti_sepd(struct hiti_ctx *ctx, uint32_t buf_len,
|
|
|
|
uint16_t startLine, uint16_t numLines)
|
|
|
|
{
|
|
|
|
uint8_t cmdbuf[sizeof(struct hiti_extprintdata)];
|
|