diff options
Diffstat (limited to 'src/cups/backend_shinkos6145.c')
-rw-r--r-- | src/cups/backend_shinkos6145.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/cups/backend_shinkos6145.c b/src/cups/backend_shinkos6145.c index 692a42c..e8d39b4 100644 --- a/src/cups/backend_shinkos6145.c +++ b/src/cups/backend_shinkos6145.c @@ -130,7 +130,7 @@ struct s6145_printjob_hdr { uint32_t unk19; uint32_t unk20; - uint32_t unk21; + uint32_t ext_flags; /* 0x00 in the official headers. 0x01 to mark inout data as YMC planar */ } __attribute__((packed)); /* "Image Correction Parameter" File */ @@ -259,7 +259,7 @@ struct shinkos6145_correctionparam { uint8_t pad[3948]; // @12436, null. } __attribute__((packed)); /* 16384 bytes */ -/* Private data stucture */ +/* Private data structure */ struct shinkos6145_ctx { struct libusb_device_handle *dev; uint8_t endp_up; @@ -276,7 +276,8 @@ struct shinkos6145_ctx { size_t datalen; uint8_t ribbon_type; - + uint8_t input_ymc; + uint16_t last_donor; uint16_t last_remain; uint16_t last_ribbon; @@ -365,7 +366,7 @@ static char *cmd_names(uint16_t v) { default: return "Unknown Command"; } -}; +} struct s6145_print_cmd { struct s6145_cmd_hdr hdr; @@ -780,7 +781,7 @@ static char *error_str(uint8_t v) { case ERROR_COMMS_TIMEOUT: return "Main Communication Timeout"; case ERROR_MAINT_NEEDED: - return "Maintainence Needed"; + return "Maintenance Needed"; case ERROR_BAD_COMMAND: return "Inappropriate Command"; case ERROR_PRINTER: @@ -1194,7 +1195,7 @@ static int get_status(struct shinkos6145_ctx *ctx) INFO(" Print Counts:\n"); INFO("\tSince Paper Changed:\t%08u\n", le32_to_cpu(resp->count_paper)); INFO("\tLifetime:\t\t%08u\n", le32_to_cpu(resp->count_lifetime)); - INFO("\tMaintainence:\t\t%08u\n", le32_to_cpu(resp->count_maint)); + INFO("\tMaintenance:\t\t%08u\n", le32_to_cpu(resp->count_maint)); INFO("\tPrint Head:\t\t%08u\n", le32_to_cpu(resp->count_head)); INFO(" Cutter Actuations:\t%08u\n", le32_to_cpu(resp->count_cutter)); INFO(" Ribbon Remaining:\t%08u\n", le32_to_cpu(resp->count_ribbon_left)); @@ -1229,7 +1230,7 @@ static int get_status(struct shinkos6145_ctx *ctx) return -1; INFO("Lifetime Distance: %08u inches\n", le32_to_cpu(resp2->lifetime_distance)); - INFO("Maintainence Distance: %08u inches\n", le32_to_cpu(resp2->maint_distance)); + INFO("Maintenance Distance: %08u inches\n", le32_to_cpu(resp2->maint_distance)); INFO("Head Distance: %08u inches\n", le32_to_cpu(resp2->head_distance)); /* Query various params */ @@ -2097,11 +2098,17 @@ static int shinkos6145_read_parse(void *vctx, int data_fd) { return CUPS_BACKEND_CANCEL; } + /* Extended spool format to re-purpose an unused header field. + When bit 0 is set, this tells the backend that the data is + already in planar YMC format (vs packed RGB) so we don't need + to do the conversion ourselves. Saves some processing overhead */ + ctx->input_ymc = le32_to_cpu(ctx->hdr.ext_flags) & 0x01; + if (ctx->databuf) { free(ctx->databuf); ctx->databuf = NULL; } - + ctx->datalen = le32_to_cpu(ctx->hdr.rows) * le32_to_cpu(ctx->hdr.columns) * 3; ctx->databuf = malloc(ctx->datalen); if (!ctx->databuf) { @@ -2320,10 +2327,8 @@ top: ctx->corrdata->width = cpu_to_le16(le32_to_cpu(ctx->hdr.columns)); ctx->corrdata->height = cpu_to_le16(le32_to_cpu(ctx->hdr.rows)); - /* Convert packed RGB to planar YMC */ - // XXX would it make more sense to have Gutenprint generate - // planar YMC data as an extension of the spooler format? - { + /* Convert packed RGB to planar YMC if necessary */ + if (!ctx->input_ymc) { int planelen = le16_to_cpu(ctx->corrdata->width) * le16_to_cpu(ctx->corrdata->height); uint8_t *databuf3 = malloc(ctx->datalen); @@ -2483,7 +2488,7 @@ static int shinkos6145_query_serno(struct libusb_device_handle *dev, uint8_t end struct dyesub_backend shinkos6145_backend = { .name = "Shinko/Sinfonia CHC-S6145", - .version = "0.21", + .version = "0.22", .uri_prefix = "shinkos6145", .cmdline_usage = shinkos6145_cmdline, .cmdline_arg = shinkos6145_cmdline_arg, |