hiti: Matrix table (aka nvram) is actually 512 bytes

This commit is contained in:
Solomon Peachy 2022-10-22 22:03:21 -04:00
parent 498fde721d
commit adc7d669a1
1 changed files with 43 additions and 8 deletions

View File

@ -134,7 +134,7 @@ struct hiti_cmd {
#define CMD_ESD_C_SHPTC 0x830C /* CS Send Heating Parameters & Tone Curve XX (n arg) */
/* Extended Flash/NVram */
#define CMD_EFM_RNV 0x8405 /* Read NVRam (1 arg) -- arg is offset, 1 byte resp of data @ that offset. -- All newer than P51x */
#define CMD_EFM_RNV 0x8405 /* Read NVRam (1 arg) -- arg is offset, 1 byte resp of data @ that offset. -- P51x */
#define CMD_EFM_RD 0x8408 /* Read single location (2 byte offset arg, 1 byte of data @ that offset -- not P51x */
#define CMD_EFM_SHA 0x840E /* Set Highlight Adjustment (5 arg) -- XXX RE */
@ -376,7 +376,7 @@ struct hiti_matrix {
uint8_t row9[12]; // all 00 except last, which is 0xa5
/*@a0*/ uint16_t errorcount[31];
uint8_t unk_rowd[2]; // seems to be 00 cc ?
uint8_t rowd[2]; // seems to be 00 cc ?
/*@e0*/ uint16_t tpc_4x6;
uint16_t tpc_5x7;
@ -392,9 +392,28 @@ struct hiti_matrix {
uint8_t tphv_a;
uint8_t tphv_d;
uint8_t unk_rowf2[2]; // all 00
/* @100 */
/*@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*/
} __attribute__((packed));
STATIC_ASSERT(sizeof(struct hiti_matrix) == 512);
struct hiti_ribbon {
uint16_t unk;
uint8_t type; /* RIBBON_TYPE_XXX */
@ -440,7 +459,7 @@ struct hiti_ctx {
struct marker marker;
char version[256];
char id[256];
uint8_t matrix[256]; // XXX convert to struct matrix */
uint8_t matrix[512]; // XXX convert to struct matrix */
struct hiti_ribbon ribbon;
struct hiti_paper paper;
struct hiti_calibration calibration;
@ -900,7 +919,7 @@ static int hiti_get_info(struct hiti_ctx *ctx)
{
int i;
DEBUG("MAT ");
for (i = 0 ; i < 256 ; i++) {
for (i = 0 ; i < 512 ; i++) {
if (i != 0 && (i % 16 == 0)) {
DEBUG2("\n");
DEBUG(" ");
@ -2559,7 +2578,7 @@ static int hiti_query_matrix(struct hiti_ctx *ctx)
int i;
uint16_t len = 1;
for (i = 0 ; i < 256 ; i++) {
for (i = 0 ; i < 512 ; i++) {
uint16_t offset = cpu_to_be16(i);
ret = hiti_docmd_resp(ctx, CMD_EFM_RD, (uint8_t*)&offset, sizeof(offset), &ctx->matrix[i], &len);
@ -2576,14 +2595,30 @@ static int hiti_query_matrix_51x(struct hiti_ctx *ctx)
int i;
uint16_t len = 1;
for (i = 0 ; i < 256 ; i++) {
uint8_t offset = i;
uint8_t lun = 0;
ret = hiti_docmd(ctx, CMD_PCC_STP, (uint8_t*)&lun, sizeof(lun), &len);
if (ret)
return ret;
for (i = 0 ; i < 512 ; i++) {
uint8_t offset = i % 256;
if (i == 256) {
lun = 1;
ret = hiti_docmd(ctx, CMD_PCC_STP, (uint8_t*)&lun, sizeof(lun), &len);
if (ret)
return ret;
}
ret = hiti_docmd_resp(ctx, CMD_EFM_RNV, (uint8_t*)&offset, sizeof(offset), &ctx->matrix[i], &len);
if (ret)
return ret;
}
lun = 0;
ret = hiti_docmd(ctx, CMD_PCC_STP, (uint8_t*)&lun, sizeof(lun), &len);
if (ret)
return ret;
return CUPS_BACKEND_OK;
}