diff options
author | Didier Raboud <odyx@debian.org> | 2017-01-22 10:36:11 +0100 |
---|---|---|
committer | Didier Raboud <odyx@debian.org> | 2017-01-22 10:36:11 +0100 |
commit | 7bd83d89975d166521a0b326b64b4cad80117750 (patch) | |
tree | d303f82c5651a20c507e69d9a8bb37a845492feb /src/cups/backend_mitsu70x.c | |
parent | 54a135b87201e48d4da4894a61b81a8c6fe46d26 (diff) |
New upstream version 5.2.12
Diffstat (limited to 'src/cups/backend_mitsu70x.c')
-rw-r--r-- | src/cups/backend_mitsu70x.c | 146 |
1 files changed, 95 insertions, 51 deletions
diff --git a/src/cups/backend_mitsu70x.c b/src/cups/backend_mitsu70x.c index 16099ba..a0ab482 100644 --- a/src/cups/backend_mitsu70x.c +++ b/src/cups/backend_mitsu70x.c @@ -108,7 +108,7 @@ typedef int (*send_image_dataFN)(struct BandImage *out, void *context, #define USB_VID_MITSU 0x06D3 #define USB_PID_MITSU_D70X 0x3B30 #define USB_PID_MITSU_K60 0x3B31 -//#define USB_PID_MITSU_D80 XXXXXX +#define USB_PID_MITSU_D80 0x3B36 #define USB_VID_KODAK 0x040a #define USB_PID_KODAK305 0x404f //#define USB_VID_FUJIFILM XXXXXX @@ -137,8 +137,6 @@ struct mitsu70x_ctx { uint16_t last_donor_u; int num_decks; - int supports_jobs_query; - char *laminatefname; char *lutfname; char *cpcfname; @@ -180,14 +178,16 @@ struct mitsu70x_jobstatus { uint8_t reserved[6]; } __attribute__((packed)); +struct mitsu70x_job { + uint16_t id; /* BE */ + uint8_t status[4]; +} __attribute__((packed)); + +#define NUM_JOBS 170 + struct mitsu70x_jobs { uint8_t hdr[4]; /* E4 56 31 31 */ - uint16_t dummy; - uint16_t jobid_0; /* BE */ - uint8_t job0_status[4]; - uint16_t jobid_1; /* BE */ - uint8_t job1_status[4]; - // XXX are there more? + struct mitsu70x_job jobs[NUM_JOBS]; } __attribute__((packed)); #define TEMPERATURE_NORMAL 0x00 @@ -288,9 +288,9 @@ struct mitsu70x_jobs { struct mitsu70x_status_deck { uint8_t mecha_status[2]; - uint8_t temperature; + uint8_t temperature; /* D70 family only, K60 no */ uint8_t error_status[3]; - uint8_t rsvd_a[10]; + uint8_t rsvd_a[10]; /* K60 family [1] == temperature? [3:6] == lifetime prints in BCD */ uint8_t media_brand; uint8_t media_type; @@ -298,9 +298,7 @@ struct mitsu70x_status_deck { uint16_t capacity; /* media capacity */ uint16_t remain; /* media remaining */ uint8_t rsvd_c[2]; - - uint16_t rsvd_d; - uint16_t prints; /* lifetime prints on deck? */ + uint8_t lifetime_prints[4]; /* lifetime prints on deck + 10, in BCD! */ uint16_t rsvd_e[17]; } __attribute__((packed)); @@ -316,12 +314,15 @@ struct mitsu70x_printerstatus_resp { uint8_t unk[34]; int16_t model[6]; /* LE, UTF-16 */ int16_t serno[6]; /* LE, UTF-16 */ - struct mitsu70x_status_ver vers[7]; // components are 'LMFTR??' + struct mitsu70x_status_ver vers[7]; // components are 'MLRTF' uint8_t null[8]; struct mitsu70x_status_deck lower; struct mitsu70x_status_deck upper; } __attribute__((packed)); +#define EK305_0104_M_CSUM 0x2878 /* 1.04 316F8 3 2878 */ +#define MD70X_0112_M_CSUM 0x9FC3 /* 1.12 316W1 1 9FC3 */ + struct mitsu70x_memorystatus_resp { uint8_t hdr[3]; /* E4 56 33 */ uint8_t memory; @@ -588,14 +589,24 @@ static char *mitsu70x_errors(uint8_t *err) static const char *mitsu70x_media_types(uint8_t brand, uint8_t type) { - if (brand == 0xff && type == 0x02) - return "CKD746 (4x6)"; + if (brand == 0xff && type == 0x01) + return "CK-D735 (3.5x5)"; + else if (brand == 0xff && type == 0x02) + return "CK-D746 (4x6)"; + else if (brand == 0xff && type == 0x04) + return "CK-D757 (5x7)"; + else if (brand == 0xff && type == 0x05) + return "CK-D769 (6x9)"; else if (brand == 0xff && type == 0x0f) - return "CKD768 (6x8)"; + return "CK-D768 (6x8)"; + else if (brand == 0x6c && type == 0x84) + return "Kodak 5R (5x7)"; else if (brand == 0x6c && type == 0x8f) return "Kodak 6R (6x8)"; + else if (brand == 0x61 && type == 0x84) + return "CK-K57R (5x7)"; else if (brand == 0x61 && type == 0x8f) - return "CKK76R (6x8)"; + return "CK-K76R (6x8)"; else return "Unknown"; } @@ -640,12 +651,6 @@ static void mitsu70x_attach(void *vctx, struct libusb_device_handle *dev, ctx->last_donor_l = ctx->last_donor_u = 65535; - if (ctx->type == P_KODAK_305 || - ctx->type == P_MITSU_K60) - ctx->supports_jobs_query = 0; - else - ctx->supports_jobs_query = 1; - /* Attempt to open the library */ #if defined(WITH_DYNAMIC) INFO("Attempting to load image processing library\n"); @@ -1036,6 +1041,7 @@ static int mitsu70x_get_jobstatus(struct mitsu70x_ctx *ctx, struct mitsu70x_jobs return 0; } +#if 0 static int mitsu70x_get_jobs(struct mitsu70x_ctx *ctx, struct mitsu70x_jobs *resp) { uint8_t cmdbuf[CMDBUF_LEN]; @@ -1068,6 +1074,7 @@ static int mitsu70x_get_jobs(struct mitsu70x_ctx *ctx, struct mitsu70x_jobs *res return 0; } +#endif static int mitsu70x_get_memorystatus(struct mitsu70x_ctx *ctx, struct mitsu70x_memorystatus_resp *resp) { @@ -1213,7 +1220,6 @@ static int mitsu70x_main_loop(void *vctx, int copies) struct mitsu70x_ctx *ctx = vctx; struct mitsu70x_jobstatus jobstatus; struct mitsu70x_printerstatus_resp resp; - struct mitsu70x_jobs jobs; struct mitsu70x_hdr *hdr; int ret; @@ -1290,6 +1296,15 @@ top: mitsu70x_media_types(resp.lower.media_brand, resp.lower.media_type)); ATTR("marker-types=ribbonWax\n"); } + + /* FW sanity checking */ + if (ctx->type == P_KODAK_305) { + if (be16_to_cpu(resp.vers[0].checksum) != EK305_0104_M_CSUM) + WARNING("Printer FW out of date. Highly recommend upgrading EK305 to v1.04!\n"); + } else if (ctx->type == P_MITSU_D70X) { + if (be16_to_cpu(resp.vers[0].checksum) != MD70X_0112_M_CSUM) + WARNING("Printer FW out of date. Highly recommend upgrading D70/D707 to v1.12!\n"); + } skip_status: /* Perform memory status query */ @@ -1313,21 +1328,29 @@ skip_status: } } +#if 0 /* Make sure we don't have any jobid collisions */ - if (ctx->supports_jobs_query) { + { + int i; + struct mitsu70x_jobs jobs; + ret = mitsu70x_get_jobs(ctx, &jobs); if (ret) return CUPS_BACKEND_FAILED; - while (ctx->jobid == be16_to_cpu(jobs.jobid_0) || - ctx->jobid == be16_to_cpu(jobs.jobid_1)) { - ctx->jobid++; - if (!ctx->jobid) + for (i = 0 ; i < NUM_JOBS ; i++) { + if (jobs.jobs[0].id == 0) + break; + if (ctx->jobid == be16_to_cpu(jobs.jobs[0].id)) { ctx->jobid++; + if (!ctx->jobid) + ctx->jobid++; + i = -1; + } } - } else { - while(!ctx->jobid || ctx->jobid == be16_to_cpu(jobstatus.jobid)) - ctx->jobid++; } +#endif + while(!ctx->jobid || ctx->jobid == be16_to_cpu(jobstatus.jobid)) + ctx->jobid++; /* Set jobid */ hdr->jobid = cpu_to_be16(ctx->jobid); @@ -1489,7 +1512,7 @@ skip_status: static void mitsu70x_dump_printerstatus(struct mitsu70x_printerstatus_resp *resp) { - unsigned int i; + uint32_t i; INFO("Model : "); for (i = 0 ; i < 6 ; i++) { @@ -1503,12 +1526,20 @@ static void mitsu70x_dump_printerstatus(struct mitsu70x_printerstatus_resp *resp DEBUG2("\n"); for (i = 0 ; i < 7 ; i++) { char buf[7]; + char type; if (resp->vers[i].ver[5] == '@') /* "DUMMY@" */ continue; memcpy(buf, resp->vers[i].ver, 6); buf[6] = 0; - INFO("Component #%u ID: %s (checksum %04x)\n", - i, buf, be16_to_cpu(resp->vers[i].checksum)); + if (i == 0) type = 'M'; + else if (i == 1) type = 'L'; + else if (i == 2) type = 'R'; + else if (i == 3) type = 'T'; + else if (i == 4) type = 'F'; + else type = i + 0x30; + + INFO("FW Component: %c %s (%04x)\n", + type, buf, be16_to_cpu(resp->vers[i].checksum)); } INFO("Lower Mechanical Status: %s\n", @@ -1526,7 +1557,11 @@ static void mitsu70x_dump_printerstatus(struct mitsu70x_printerstatus_resp *resp INFO("Lower Prints remaining: %03d/%03d\n", be16_to_cpu(resp->lower.remain), be16_to_cpu(resp->lower.capacity)); -// INFO("Lower Lifetime prints: %d\n", be16_to_cpu(resp->lower.prints)); + + i = packed_bcd_to_uint32((char*)resp->lower.lifetime_prints, 4); + if (i) + i-= 10; + INFO("Lower Lifetime prints: %u\n", i); if (resp->upper.mecha_status[0] != MECHA_STATUS_INIT) { INFO("Upper Mechanical Status: %s\n", @@ -1544,13 +1579,20 @@ static void mitsu70x_dump_printerstatus(struct mitsu70x_printerstatus_resp *resp INFO("Upper Prints remaining: %03d/%03d\n", be16_to_cpu(resp->upper.remain), be16_to_cpu(resp->upper.capacity)); + + i = packed_bcd_to_uint32((char*)resp->upper.lifetime_prints, 4); + if (i) + i-= 10; + INFO("Upper Lifetime prints: %u\n", i); } } static int mitsu70x_query_status(struct mitsu70x_ctx *ctx) { struct mitsu70x_printerstatus_resp resp; +#if 0 struct mitsu70x_jobs jobs; +#endif struct mitsu70x_jobstatus jobstatus; int ret; @@ -1574,19 +1616,21 @@ top: if (!ret) mitsu70x_dump_printerstatus(&resp); - if (ctx->supports_jobs_query) { - ret = mitsu70x_get_jobs(ctx, &jobs); - if (!ret) { - INFO("JOB0 ID : %06u\n", jobs.jobid_0); - INFO("JOB0 status : %s\n", mitsu70x_jobstatuses(jobs.job0_status)); - INFO("JOB1 ID : %06u\n", jobs.jobid_1); - INFO("JOB1 status : %s\n", mitsu70x_jobstatuses(jobs.job1_status)); - // XXX are there more? + INFO("JOB00 ID : %06u\n", jobstatus.jobid); + INFO("JOB00 status : %s\n", mitsu70x_jobstatuses(jobstatus.job_status)); + +#if 0 + ret = mitsu70x_get_jobs(ctx, &jobs); + if (!ret) { + int i; + for (i = 0 ; i < NUM_JOBS ; i++) { + if (jobs.jobs[i].id == 0) + break; + INFO("JOB%02d ID : %06u\n", i, jobs.jobs[i].id); + INFO("JOB%02d status : %s\n", i, mitsu70x_jobstatuses(jobs.jobs[i].status)); } - } else { - INFO("JOB0 ID : %06u\n", jobstatus.jobid); - INFO("JOB0 status : %s\n", mitsu70x_jobstatuses(jobstatus.job_status)); } +#endif done: return ret; @@ -1658,7 +1702,7 @@ static int mitsu70x_cmdline_arg(void *vctx, int argc, char **argv) /* Exported */ struct dyesub_backend mitsu70x_backend = { .name = "Mitsubishi CP-D70/D707/K60/D80", - .version = "0.51", + .version = "0.55", .uri_prefix = "mitsu70x", .cmdline_usage = mitsu70x_cmdline, .cmdline_arg = mitsu70x_cmdline_arg, @@ -1671,7 +1715,7 @@ struct dyesub_backend mitsu70x_backend = { .devices = { { USB_VID_MITSU, USB_PID_MITSU_D70X, P_MITSU_D70X, ""}, { USB_VID_MITSU, USB_PID_MITSU_K60, P_MITSU_K60, ""}, -// { USB_VID_MITSU, USB_PID_MITSU_D80, P_MITSU_D80, ""}, + { USB_VID_MITSU, USB_PID_MITSU_D80, P_MITSU_D80, ""}, { USB_VID_KODAK, USB_PID_KODAK305, P_KODAK_305, ""}, // { USB_VID_FUJIFILM, USB_PID_FUJI_ASK300, P_FUJI_ASK300, ""}, { 0, 0, 0, ""} |