From a486a91dfb770da86d40db8ec95068861c30de9f Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Fri, 28 Feb 2020 23:24:28 -0500 Subject: [PATCH] mitsu: Enhance media type reporting to handle per-model variations --- backend_mitsu.c | 84 ++++++++++++++++++++++++++++------------------ backend_mitsu.h | 4 +-- backend_mitsu70x.c | 8 ++--- backend_mitsud90.c | 4 +-- 4 files changed, 60 insertions(+), 40 deletions(-) diff --git a/backend_mitsu.c b/backend_mitsu.c index ac5fce0..81485d8 100644 --- a/backend_mitsu.c +++ b/backend_mitsu.c @@ -220,45 +220,65 @@ const char *mitsu_temperatures(uint8_t temp) return "Unknown Temperature Status"; } -const char *mitsu_media_types(uint8_t brand, uint8_t type) +const char *mitsu_media_types(int printer, uint8_t brand, uint8_t type) { - 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 "CK-D768/CK-D868 (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 "CK-K76R (6x8)"; - else if (brand == 0x7a && type == 0x01) - return "RL-CF900 (3.5x5)"; - else if (brand == 0x7a && type == 0x02) - return "RK-CF800/4R (4x6)"; - else if (brand == 0x7a && type == 0x04) - return "R2L-CF460/5R (5x7)"; - else if (brand == 0x7a && type == 0x0f) - return "R68-CF400/6R (6x8)"; - else - return "Unknown"; + UNUSED(printer); + + if (brand == 0xff) { /* Mitsubishi */ + if (printer == P_MITSU_M1) { + if (type == 0x02) + return "CK-M46S (4x6)"; + else if (type == 0x04) + return "CK-M57S (5x7)"; + else if (type == 0x0f) + return "CK-M68S (6x8)"; + } else if (printer == P_MITSU_D80) { + if (type == 0x0f) + return "CK-D868 (6x8)"; + } else if (printer == P_MITSU_D90) { + if (type == 0x0f) + return "CK-D768/CK-D868 (6x8)"; + } + + /* Mitsu D70, and D90 fallthrough */ + if (type == 0x01) + return "CK-D735 (3.5x5)"; + else if (type == 0x02) + return "CK-D746 (4x6)"; + else if (type == 0x04) + return "CK-D757 (5x7)"; + else if (type == 0x05) + return "CK-D769 (6x9)"; + else if (type == 0x0f) + return "CK-D768 (6x8)"; + } else if (brand == 0x61) { /* Mitsubishi (K60 series) */ + if (type == 0x84) + return "CK-K57R (5x7)"; + else if (type == 0x8f) + return "CK-K76R (6x8)"; + } else if (brand == 0x6c) { /* Kodak */ + if (type == 0x84) + return "Kodak 5R (5x7)"; + else if (type == 0x8f) + return "Kodak 6R (6x8)"; + } else if (brand == 0x7a) { /* Fujifilm*/ + if (type == 0x01) + return "RL-CF900 (3.5x5)"; + else if (type == 0x02) + return "RK-CF800/4R (4x6)"; + else if (type == 0x04) + return "R2L-CF460/5R (5x7)"; + else if (type == 0x0f) + return "R68-CF400/6R (6x8)"; + } + + return "Unknown"; // Also CK-D715, CK-D718, CK-D720, CK-D723 (4x6,5x8,6x8,6x9) for D70-S model // CK-D746-U for D70-U model // CK-D820 (6x8) for D80-S model // D90 can use _all_ of these types except for the -U! - // CK-M57S (5x7 for M1) - // CK-M68S (6x8 for M1) - // CK-M46S (6x4 for M1) // CK-M15S (6x4 for M15) // CK-M18S (5x7 for M15) // CK-M20S (6x8 for M15) diff --git a/backend_mitsu.h b/backend_mitsu.h index dae9b2f..53b801f 100644 --- a/backend_mitsu.h +++ b/backend_mitsu.h @@ -71,7 +71,7 @@ typedef void (*CP98xx_DestroyDataFN)(const struct mitsu98xx_data *data); #define REQUIRED_LIB_APIVERSION 5 -#define LIBMITSU_VER "0.04" +#define LIBMITSU_VER "0.05" /* Image processing library function prototypes */ #define LIB_NAME_RE "libMitsuD70ImageReProcess" DLL_SUFFIX @@ -112,4 +112,4 @@ int mitsu_readlamdata(const char *fname, uint16_t lamstride, #define TEMPERATURE_COOLING 0x80 const char *mitsu_temperatures(uint8_t temp); -const char *mitsu_media_types(uint8_t brand, uint8_t type); +const char *mitsu_media_types(int printer, uint8_t brand, uint8_t type); diff --git a/backend_mitsu70x.c b/backend_mitsu70x.c index 44eb04d..fbeaec2 100644 --- a/backend_mitsu70x.c +++ b/backend_mitsu70x.c @@ -639,7 +639,7 @@ static int mitsu70x_attach(void *vctx, struct libusb_device_handle *dev, int typ /* Set up markers */ ctx->marker[0].color = "#00FFFF#FF00FF#FFFF00"; - ctx->marker[0].name = mitsu_media_types(resp.lower.media_brand, resp.lower.media_type); + ctx->marker[0].name = mitsu_media_types(ctx->type, resp.lower.media_brand, resp.lower.media_type); ctx->marker[0].numtype = resp.lower.media_type; ctx->marker[0].levelmax = be16_to_cpu(resp.lower.capacity); ctx->marker[0].levelnow = be16_to_cpu(resp.lower.remain); @@ -647,7 +647,7 @@ static int mitsu70x_attach(void *vctx, struct libusb_device_handle *dev, int typ if (ctx->num_decks == 2) { ctx->marker[1].color = "#00FFFF#FF00FF#FFFF00"; - ctx->marker[1].name = mitsu_media_types(resp.upper.media_brand, resp.upper.media_type); + ctx->marker[1].name = mitsu_media_types(ctx->type, resp.upper.media_brand, resp.upper.media_type); ctx->marker[1].numtype = resp.upper.media_type; ctx->marker[1].levelmax = be16_to_cpu(resp.upper.capacity); ctx->marker[1].levelnow = be16_to_cpu(resp.upper.remain); @@ -2020,7 +2020,7 @@ static void mitsu70x_dump_printerstatus(struct mitsu70x_ctx *ctx, INFO("Lower Mechanical Status: %s\n", mitsu70x_mechastatus(resp->lower.mecha_status)); INFO("Lower Media Type: %s (%02x/%02x)\n", - mitsu_media_types(resp->lower.media_brand, resp->lower.media_type), + mitsu_media_types(ctx->type, resp->lower.media_brand, resp->lower.media_type), resp->lower.media_brand, resp->lower.media_type); INFO("Lower Prints Remaining: %03d/%03d\n", @@ -2042,7 +2042,7 @@ static void mitsu70x_dump_printerstatus(struct mitsu70x_ctx *ctx, INFO("Upper Mechanical Status: %s\n", mitsu70x_mechastatus(resp->upper.mecha_status)); INFO("Upper Media Type: %s (%02x/%02x)\n", - mitsu_media_types(resp->upper.media_brand, resp->upper.media_type), + mitsu_media_types(ctx->type, resp->upper.media_brand, resp->upper.media_type), resp->upper.media_brand, resp->upper.media_type); INFO("Upper Prints Remaining: %03d/%03d\n", diff --git a/backend_mitsud90.c b/backend_mitsud90.c index dd728b9..0b7f20d 100644 --- a/backend_mitsud90.c +++ b/backend_mitsud90.c @@ -606,7 +606,7 @@ static int mitsud90_attach(void *vctx, struct libusb_device_handle *dev, int typ ctx->marker.color = "#00FFFF#FF00FF#FFFF00"; ctx->marker.numtype = resp.media.type; - ctx->marker.name = mitsu_media_types(resp.media.brand, resp.media.type); + ctx->marker.name = mitsu_media_types(ctx->type, resp.media.brand, resp.media.type); ctx->marker.levelmax = be16_to_cpu(resp.media.capacity); ctx->marker.levelnow = be16_to_cpu(resp.media.remain); @@ -1101,7 +1101,7 @@ static int mitsud90_get_media(struct mitsud90_ctx *ctx) return CUPS_BACKEND_FAILED; INFO("Media Type: %s (%02x/%02x)\n", - mitsu_media_types(resp.media.brand, resp.media.type), + mitsu_media_types(ctx->type, resp.media.brand, resp.media.type), resp.media.brand, resp.media.type); INFO("Prints Remaining: %03d/%03d\n",