selphy_print/backend_shinkos6145.c

2113 lines
58 KiB
C
Raw Normal View History

/*
* Shinko/Sinfonia CHC-S6145 CUPS backend -- libusb-1.0 version
*
* (c) 2015-2020 Solomon Peachy <pizza@shaftnet.org>
*
* Low-level documentation was provided by Sinfonia. Thank you!
*
* The latest version of this program can be found at:
*
* https://git.shaftnet.org/cgit/selphy_print.git
*
* 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
* along with this program; if not, see <https://www.gnu.org/licenses/>.
*
* An additional permission is granted, under the GPLv3 section 7, to combine
* and/or redistribute this program with the proprietary libS6145ImageProcess
* and S2245IP libraries, providing you have *written permission* from Sinfonia
* Technology Co. LTD to use and/or redistribute that library.
*
2016-01-04 23:03:50 -05:00
* You must still adhere to all other terms of the license to this program
* (ie GPLv3) and the license of the libS6145ImageProcess/S2245IP libraries.
2017-07-10 20:15:56 -04:00
*
* SPDX-License-Identifier: GPL-3.0+ with special exception
*
2016-01-30 00:01:07 -05:00
*/
2019-09-28 11:05:42 -04:00
#define BACKEND shinkos6145_backend
#include "backend_common.h"
#include "backend_sinfonia.h"
#include <time.h>
#include <stdbool.h>
#ifndef WITH_DYNAMIC
#warning "No dynamic loading support!"
#endif
/* Image processing library function prototypes */
typedef void (*dump_announceFN)(FILE *fp);
typedef int (*ImageProcessingFN)(unsigned char *, unsigned short *, void *);
typedef int (*ImageAvrCalcFN)(unsigned char *, unsigned short, unsigned short, unsigned char *);
#define LIB6145_NAME "libS6145ImageProcess" DLL_SUFFIX // Official library
#define LIB6145_NAME_RE "libS6145ImageReProcess" DLL_SUFFIX // Reimplemented library
#define S6145_CORRDATA_HEADDOTS_OFFSET 8834
#define S6145_CORRDATA_WIDTH_OFFSET 12432
#define S6145_CORRDATA_HEIGHT_OFFSET 12434
#define S6145_CORRDATA_EXTRA_LEN 4
#define S2245_CORRDATA_HEADER_MODE_OFFSET (64+7)
typedef bool (*ip_imageProcFN)(uint16_t *destData, uint8_t *srcInRgb,
uint16_t width, uint16_t height, void *srcIpp);
typedef bool (*ip_checkIppFN)(uint16_t width, uint16_t height, void *srcIpp);
typedef bool (*ip_getMemorySizeFN)(uint32_t *szMemory,
uint16_t width, uint16_t height,
void *srcIpp);
#define LIB2245_NAME "libS2245ImageProcess" DLL_SUFFIX // Official library
#define LIB2245_NAME_RE "libS2245ImageReProcess" DLL_SUFFIX // Reimplemented library
enum {
S_IDLE = 0,
S_PRINTER_READY_CMD,
S_PRINTER_SENT_DATA,
S_FINISHED,
};
/* Structs for printer */
struct s6145_print_cmd {
struct sinfonia_cmd_hdr hdr;
uint8_t id;
uint16_t count;
uint16_t columns;
uint16_t rows;
uint8_t media; /* reserved in docs, but brava21 uses this */
uint8_t combo_wait;
uint8_t reserved[6];
uint8_t unk_1; /* Brava 21 sets this to 1 */
uint8_t method;
2017-07-10 20:15:56 -04:00
uint8_t image_avg;
} __attribute__((packed));
struct s6245_errorlog_resp {
struct sinfonia_status_hdr hdr;
uint16_t error_count; // @10
uint8_t reserved_12; // @12
uint8_t error_major; // @13
uint8_t error_minor; // @14
uint8_t reserved_15; // @15
uint16_t ribbon_remain; // @16 /* 4x6 */
uint8_t reserved_18[2];// @18
uint16_t boot_fw_ver; // @20
uint16_t main_fw_ver; // @22
uint16_t dsp_fw_ver; // @24
uint16_t tables_ver; // @26
uint32_t print_counter; // @28
uint8_t unkb[42]; // @32
/* on 6245 series, these additional fields:
uint8_t ribbon_takeup_diameter;
uint8_t ribbon_supply_diameter;
uint8_t time_sec;
uint8_t time_min;
uint8_t time_hour;
uint8_t time_day;
uint8_t time_month;
uint8_t time_year;
uint8_t printer_thermistor;
uint8_t head_thermistor;
uint8_t printer_humidity;
uint8_t status;
uint16_t image_cols;
uint16_t image_rows;
*/
} __attribute__((packed));
STATIC_ASSERT(sizeof(struct s6245_errorlog_resp) == 74);
enum {
PARAM_UNK_10 = 0x10, // 2245 = 0x7b
PARAM_UNK_11 = 0x11, // 2245 = 0x72
PARAM_OC_PRINT = 0x20, // 6145
PARAM_UNK_31 = 0x31, // 2245 = 0x64
PARAM_UNK_32 = 0x32, // 2245 = 0x64
PARAM_UNK_33 = 0x33, // 2245 = 0x64
PARAM_UNK_34 = 0x34, // 2245 = 0x00
PARAM_UNK_35 = 0x35, // 2245 = 0x00
PARAM_UNK_36 = 0x36, // 2245 = 0x00
PARAM_PAPER_PRESV = 0x3d, // 6145
PARAM_DRIVER_MODE = 0x3e,
PARAM_PAPER_MODE = 0x3f,
PARAM_UNK_40 = 0x40, // 2245 = 0xff
PARAM_UNK_41 = 0x41, // 2245 = 0x00
PARAM_REGION_CODE = 0x53, // 6145
PARAM_SLEEP_TIME = 0x54, // 6145
PARAM_UNK_70 = 0x70, // 2245 = 0x22f8
PARAM_UNK_71 = 0x71, // 2245 = 0x01
PARAM_UNK_91 = 0x91, // 2245 = 0xfffffffc
PARAM_UNK_92 = 0x92, // 2245 = 0x00
PARAM_UNK_93 = 0x93, // 2245 = 0x06
PARAM_UNK_A0 = 0xa0, // 2245 = 0x01
PARAM_UNK_A1 = 0xa1, // 2245 = 0xffffffff
PARAM_UNK_A2 = 0xa2, // 2245 = 0xffffffff
PARAM_UNK_A3 = 0xa3, // 2245 = 0xffffffff
PARAM_UNK_A4 = 0xa4, // 2245 = 0xffffffff
PARAM_UNK_A5 = 0xa5, // 2245 = 0x42
PARAM_UNK_A6 = 0xa6, // 2245 = 0x00
PARAM_UNK_A7 = 0xa7, // 2245 = 0x01
PARAM_UNK_A8 = 0xa8, // 2245 = 0x01
PARAM_UNK_B0 = 0xb0, // 2245 = 0x1a
PARAM_UNK_B1 = 0xb1, // 2245 = 0x70
PARAM_UNK_DC = 0xdc, // 2245 = 0x00
PARAM_UNK_DD = 0xdd, // 2245 = 0x0c
PARAM_UNK_DE = 0xde, // 2245 = 0x32
PARAM_UNK_DF = 0xdf, // 2245 = 0x00
PARAM_UNK_E1 = 0xe1, // 2245 = 0x33
PARAM_UNK_E2 = 0xe2, // 2245 = 0x33
PARAM_UNK_E4 = 0xe4, // 2245 = 0x78
PARAM_UNK_E5 = 0xe5, // 2245 = 0x33
PARAM_UNK_E6 = 0xe6, // 2245 = 0x0194
PARAM_UNK_E7 = 0xe7, // 2245 = 0x0194
PARAM_UNK_E8 = 0xe8, // 2245 = 0x00
PARAM_UNK_E9 = 0xe9, // 2245 = 0x00
PARAM_UNK_EA = 0xea, // 2245 = 0x33
PARAM_UNK_EB = 0xeb, // 2245 = 0x0194
};
static const struct sinfonia_param s6145_params[] =
{
{ PARAM_OC_PRINT, "Overcoat Mode" },
{ PARAM_PAPER_PRESV, "Paper Preserve Mode" },
{ PARAM_DRIVER_MODE, "Driver Mode/Wizard" },
{ PARAM_PAPER_MODE, "Paper Load Mode" },
{ PARAM_SLEEP_TIME, "Sleep Time" },
{ PARAM_REGION_CODE, "Region Code" },
};
#define s6145_params_num (sizeof(s6145_params) / sizeof(struct sinfonia_param))
static const struct sinfonia_param s2245_params[] =
{
{ PARAM_DRIVER_MODE, "Driver Mode/Wizard" },
{ PARAM_PAPER_MODE, "Paper Load Mode" },
};
#define s2245_params_num (sizeof(s2245_params) / sizeof(struct sinfonia_param))
// CHC-S6145
#define PARAM_OC_PRINT_OFF 0x00000001
#define PARAM_OC_PRINT_GLOSS 0x00000002
#define PARAM_OC_PRINT_MATTE 0x00000003
// CHC-S6145-5A
#define PARAM_PRINTM_OC_OFF 0x00000001
#define PARAM_PRINTM_OC_GLOSS 0x00000002
#define PARAM_PRINTM_OC_MATTE 0x00000012
#define PARAM_PRINTM_STD 0x00000000
#define PARAM_PRINTM_FINE 0x00000004
#define PARAM_PRINTM_FAST 0x00000008
// S6145 (ALL)
#define PARAM_PAPER_PRESV_OFF 0x00000000
#define PARAM_PAPER_PRESV_ON 0x00000001
// S6145 (ALL), S2245
#define PARAM_DRIVER_WIZOFF 0x00000000
#define PARAM_DRIVER_WIZON 0x00000001
#define PARAM_PAPER_NOCUT 0x00000000
#define PARAM_PAPER_CUTLOAD 0x00000001
// S6145
#define PARAM_SLEEP_5MIN 0x00000000
#define PARAM_SLEEP_15MIN 0x00000001
#define PARAM_SLEEP_30MIN 0x00000002
#define PARAM_SLEEP_60MIN 0x00000003
#define PARAM_SLEEP_120MIN 0x00000004
#define PARAM_SLEEP_240MIN 0x00000005
static const char *s6145_error_codes(uint8_t major, uint8_t minor)
{
switch(major) {
case 0x01: /* "Controller Error" */
switch(minor) {
case 0x01:
return "Controller: EEPROM Write Timeout";
case 0x0A:
return "Controller: Invalid Print Parameter Table";
case 0x0C:
return "Controller: Print Parameter Table Mismatch";
case 0x0F:
return "Controller: Main FW Checksum";
case 0x10:
return "Controller: Flash Write Failed";
case 0x13:
return "Controller: Print Parameter Table Checksum";
case 0x14:
return "Controller: Print Parameter Table Write Failed";
case 0x15:
return "Controller: User Tone Curve Write Failed";
case 0x16:
return "Controller: MSP Communication";
case 0x17:
return "Controller: THV Autotuning";
case 0x18:
return "Controller: THV Value Out of Range";
case 0x19:
return "Controller: Thermal Head";
case 0x1A:
return "Controller: Wake from Power Save Failed";
default:
return "Controller: Unknown";
}
case 0x02: /* "Mechanical Error" */
switch (minor) {
case 0x01:
return "Mechanical: Pinch Head Home";
case 0x02:
return "Mechanical: Pinch Head (position 1)";
case 0x03:
return "Mechanical: Pinch Head (position 2)";
case 0x04:
return "Mechanical: Pinch Head (position 3)";
case 0x0B:
return "Mechanical: Cutter (Right)";
case 0x0C:
return "Mechanical: Cutter (Left)";
default:
return "Mechanical: Unknown";
}
case 0x03: /* "Sensor Error" */
switch (minor) {
case 0x01:
return "Sensor: Head Up";
case 0x02:
return "Sensor: Head Down";
case 0x0B:
return "Sensor: Cutter Left";
case 0x0C:
return "Sensor: Cutter Right";
case 0x0D:
return "Sensor: Cutter Left+Right";
case 0x15:
return "Sensor: Head Up Unstable";
case 0x16:
return "Sensor: Head Down Unstable";
case 0x17:
return "Sensor: Cutter Left Unstable";
case 0x18:
return "Sensor: Cutter Right Unstable";
case 0x19:
return "Sensor: Cover Open Unstable";
case 0x1E:
return "Sensor: Ribbon Mark (Cyan)";
case 0x1F:
return "Sensor: Ribbon Mark (OC)";
default:
return "Sensor: Unknown";
}
case 0x04: /* "Temperature Sensor Error" */
switch (minor) {
case 0x01:
return "Temp Sensor: Thermal Head Low";
case 0x02:
return "Temp Sensor: Thermal Head High";
case 0x05:
return "Temp Sensor: Environment Low";
case 0x06:
return "Temp Sensor: Environment High";
case 0x07:
return "Temp Sensor: Preheat";
case 0x08:
return "Temp Sensor: Thermal Protect";
default:
return "Temp Sensor: Unknown";
}
case 0x5: /* "Paper Jam" */
switch (minor) {
case 0x01:
return "Paper Jam: Loading Paper Top On";
case 0x02:
return "Paper Jam: Loading Print Position On";
case 0x03:
return "Paper Jam: Loading Print Position Off";
case 0x04:
return "Paper Jam: Loading Paper Top Off";
case 0x05:
return "Paper Jam: Loading Cut Print Position Off";
case 0x0C:
return "Paper Jam: Initializing Print Position Off";
case 0x0D:
return "Paper Jam: Initializing Print Position On";
case 0x15:
return "Paper Jam: Printing Print Position Off";
case 0x16:
return "Paper Jam: Printing Paper Top On";
case 0x17:
return "Paper Jam: Printing Paper Top Off";
case 0x1F:
return "Paper Jam: Precut Print Position Off";
case 0x20:
return "Paper Jam: Precut Print Position On";
2017-07-10 20:15:56 -04:00
case 0x29:
return "Paper Jam: Printing Paper Top On";
case 0x2A:
return "Paper Jam: Printing Pre-Yellow Print Position Off";
case 0x2B:
return "Paper Jam: Printing Yellow Print Position Off";
case 0x2C:
return "Paper Jam: Printing Yellow Print Position On";
case 0x2D:
return "Paper Jam: Printing Pre-Magenta Print Position Off";
case 0x2E:
return "Paper Jam: Printing Magenta Print Position On";
case 0x2F:
return "Paper Jam: Printing Magenta Print Position Off";
case 0x30:
return "Paper Jam: Printing Pre-Cyan Print Position Off";
case 0x31:
return "Paper Jam: Printing Cyan Print Position On";
case 0x32:
return "Paper Jam: Printing Cyan Print Position Off";
case 0x33:
return "Paper Jam: Printing Pre-OC Print Position Off";
case 0x34:
return "Paper Jam: Printing OC Print Position On";
case 0x35:
return "Paper Jam: Printing OC Print Position Off";
case 0x36:
return "Paper Jam: Cut Print Position Off";
case 0x37:
return "Paper Jam: Home Position Off";
case 0x38:
return "Paper Jam: Paper Top Off";
case 0x39:
return "Paper Jam: Print Position On";
case 0x51:
return "Paper Jam: Paper Empty On, Top On, Position On";
case 0x52:
return "Paper Jam: Paper Empty On, Top On, Position Off";
case 0x54:
2015-11-17 19:28:09 -05:00
return "Paper Jam: Paper Empty On, Top Off, Position Off";
case 0x60:
return "Paper Jam: Cutter Right";
case 0x61:
return "Paper Jam: Cutter Left";
default:
return "Paper Jam: Unknown";
}
case 0x06: /* User Error */
switch (minor) {
case 0x01:
return "Drawer Unit Open";
case 0x02:
return "Incorrect Ribbon";
case 0x04:
return "Ribbon Empty";
case 0x08:
return "No Paper";
case 0x0C:
return "Paper End";
default:
return "Unknown";
}
default:
return "Unknown";
}
}
static const char *s2245_error_codes(uint8_t major, uint8_t minor)
{
switch(major) {
case 0x01: /* "Controller Error" */
switch(minor) {
case 0x01:
return "Controller: EEPROM Write Timeout";
case 0x0A:
return "Controller: Invalid Print Parameter Table";
case 0x0C:
return "Controller: Print Parameter Table Mismatch";
case 0x0F:
return "Controller: Main FW Data Error";
case 0x10:
return "Controller: Main FW Write Failed";
case 0x13:
return "Controller: Print Parameter Table Checksum";
case 0x14:
return "Controller: Print Parameter Table Write Failed";
case 0x15:
return "Controller: User Tone Curve Write Failed";
case 0x16:
return "Controller: MSP Communication";
case 0x19:
return "Controller: Thermal Head";
default:
return "Controller: Unknown";
}
case 0x02: /* "Mechanical Error" */
switch (minor) {
case 0x01:
return "Mechanical: Pinch Head Home";
case 0x02:
return "Mechanical: Pinch Head (position 1)";
case 0x03:
return "Mechanical: Pinch Head (position 2)";
case 0x04:
return "Mechanical: Pinch Head (position 3)";
case 0x05:
return "Mechanical: Pinch Head (position 4)";
case 0x14:
return "Mechanical: Cutter (Left-Right)";
case 0x15:
return "Mechanical: Cutter (Right-Left)";
default:
return "Mechanical: Unknown";
}
case 0x03: /* "Sensor Error" */
switch (minor) {
case 0x01:
return "Sensor: Cutter Left+Right";
case 0x02:
return "Sensor: Cutter Left drove";
case 0x03:
return "Sensor: Cutter Right drove";
case 0x1E:
return "Sensor: Left Front Lock";
case 0x1F:
return "Sensor: Right Front Lock";
case 0x20:
return "Sensor: Cutter Left";
case 0x21:
return "Sensor: Cutter Right";
case 0x22:
return "Sensor: Left Head/Pinch";
case 0x23:
return "Sensor: Right Head/Pinch";
case 0x24:
return "Sensor: Head/Pinch Encoder";
case 0x25:
return "Sensor: Supply Ribbon Encoder";
default:
return "Sensor: Unknown";
}
case 0x04: /* "Temperature Sensor Error" */
switch (minor) {
case 0x01:
return "Temp Sensor: Thermal Head Low";
case 0x02:
return "Temp Sensor: Thermal Head High";
case 0x05:
return "Temp Sensor: Environment Low";
case 0x06:
return "Temp Sensor: Environment High";
case 0x07:
return "Temp Sensor: Preheat";
case 0x08:
return "Temp Sensor: Thermal Protect";
default:
return "Temp Sensor: Unknown";
}
case 0x5: /* "Paper Jam" */
switch (minor) {
case 0x01:
return "Paper Jam: Paper Not Detected";
case 0x02:
return "Paper Jam: Pinch Roller Fail";
case 0x10:
return "Paper Jam: Print Position Sensor on";
case 0x11:
return "Paper Jam: Print Position Sensor off";
case 0x12:
return "Paper Jam: Paper End Sensor on";
case 0x13:
return "Paper Jam: Paper Cut";
case 0x30:
return "Paper Jam: Print Position Sensor early";
case 0x31:
return "Paper Jam: Print Position Sensor on";
case 0x32:
return "Paper Jam: Print Position Sensor off";
case 0x40:
return "Paper Jam: Cutter Left-Right";
case 0x41:
return "Paper Jam: Cutter Right-Left";
case 0x51:
return "Paper Jam: Paper End On, Position Off";
case 0x52:
return "Paper Jam: Paper End Off, Position On";
case 0x53:
return "Paper Jam: Paper End On, Position On";
default:
return "Paper Jam: Unknown";
}
case 0x06: /* User Error */
switch (minor) {
case 0x01:
return "Cover Open";
case 0x02:
return "Cover Not Closed";
case 0x03:
return "Incorrect Ribbon";
case 0x04:
return "Ribbon End";
case 0x07:
return "No Paper";
case 0x08:
return "Paper End";
case 0x0D:
return "No Ribbon";
case 0x0E:
return "Ribbon Rewind Failure";
case 0x0F:
return "Ribbon Sense Failure";
case 0x20:
return "THV Tuning";
case 0x21:
return "THV Not Tuned";
default:
return "Unknown";
}
default:
return "Unknown";
}
}
#define RIBBON_NONE 0x00
#define RIBBON_4x6 0x01
#define RIBBON_3_5x5 0x02
#define RIBBON_5x7 0x03
#define RIBBON_6x8 0x04
#define RIBBON_6x9 0x05
#define RIBBON_89x60mm 0x01
static int ribbon_sizes (uint8_t v, uint8_t is_card, uint8_t is_2245) {
if (is_card) {
return 450;
}
switch (v) {
case RIBBON_4x6:
if (is_2245)
return 900;
else
return 300;
case RIBBON_3_5x5:
return 340;
case RIBBON_5x7:
return 170;
case RIBBON_6x8:
if (is_2245)
return 450;
else
return 150;
case RIBBON_6x9:
return 130; // XXX guessed
default:
if (is_2245)
return 450;
else
return 300;
}
}
static const char *print_ribbons (uint8_t v, uint8_t is_card) {
if (is_card) {
if (v == RIBBON_89x60mm)
return "89x60mm";
else if (v == RIBBON_NONE)
return "None";
else
return "Unknown";
}
switch (v) {
case RIBBON_NONE:
return "None";
case RIBBON_4x6:
return "4x6";
case RIBBON_3_5x5:
return "3.5x5";
case RIBBON_5x7:
return "5x7";
case RIBBON_6x8:
return "6x8";
case RIBBON_6x9:
return "6x9";
default:
return "Unknown";
}
}
struct s6145_imagecorr_resp {
struct sinfonia_status_hdr hdr;
uint16_t total_size;
} __attribute__((packed));
struct s2245_imagecorr_req {
struct sinfonia_cmd_hdr hdr;
uint8_t options;
uint8_t flags;
uint8_t null[10];
} __attribute__((packed));
#define S2245_IMAGECORR_FLAG_CONTOUR_ENH 0x01
struct s2245_imagecorr_resp {
struct sinfonia_status_hdr hdr;
uint32_t total_size;
} __attribute__((packed));
struct s6145_imagecorr_data {
uint8_t remain_pkt;
uint8_t return_size; /* Always 0x10 */
2015-11-16 23:04:13 -05:00
uint8_t data[16];
} __attribute__((packed));
/* Private data structure */
struct shinkos6145_ctx {
struct sinfonia_usbdev dev;
uint8_t jobid;
uint8_t image_avg[3]; /* YMC */
char serial[32];
char fwver[32];
int is_card; /* card printer model */
struct marker marker;
struct sinfonia_6x45_mediainfo_resp media;
uint8_t *eeprom;
size_t eepromlen;
void *dl_handle;
dump_announceFN DumpAnnounce;
ImageProcessingFN ImageProcessing;
ImageAvrCalcFN ImageAvrCalc;
ip_imageProcFN ip_imageProc;
ip_checkIppFN ip_checkIpp;
ip_getMemorySizeFN ip_getMemorySize;
void *corrdata; /* Correction table */
uint16_t corrdatalen;
};
static const char *s2245_drivermodes(uint8_t val);
static int shinkos2245_get_imagecorr(struct shinkos6145_ctx *ctx, uint8_t options);
static int shinkos6145_get_imagecorr(struct shinkos6145_ctx *ctx);
static int shinkos6145_get_eeprom(struct shinkos6145_ctx *ctx);
static int get_status(struct shinkos6145_ctx *ctx)
{
struct sinfonia_cmd_hdr cmd;
struct sinfonia_status_resp resp;
struct sinfonia_getextcounter_resp resp2;
int ret, num = 0;
2015-11-17 19:28:09 -05:00
uint32_t val;
cmd.cmd = cpu_to_le16(SINFONIA_CMD_GETSTATUS);
cmd.len = cpu_to_le16(0);
if ((ret = sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp), &num)) < 0) {
return ret;
}
INFO("Printer Status: 0x%02x (%s)\n", resp.hdr.status,
sinfonia_status_str(resp.hdr.status));
if (resp.hdr.status == ERROR_PRINTER) {
if(resp.hdr.error == ERROR_NONE)
resp.hdr.error = resp.hdr.status;
INFO(" Error 0x%02x (%s) 0x%02x/0x%02x (%s)\n",
resp.hdr.error,
sinfonia_error_str(resp.hdr.error),
resp.hdr.printer_major,
resp.hdr.printer_minor, ctx->dev.error_codes(resp.hdr.printer_major, resp.hdr.printer_minor));
}
if (le16_to_cpu(resp.hdr.payload_len) != (sizeof(struct sinfonia_status_resp) - sizeof(struct sinfonia_status_hdr)))
return -1;
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("\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));
INFO("Bank 1: 0x%02x (%s) Job %03u @ %03u/%03u (%03u remaining)\n",
resp.bank1_status, sinfonia_bank_statuses(resp.bank1_status),
resp.bank1_printid,
le16_to_cpu(resp.bank1_finished),
le16_to_cpu(resp.bank1_specified),
le16_to_cpu(resp.bank1_remaining));
INFO("Bank 2: 0x%02x (%s) Job %03u @ %03u/%03u (%03u remaining)\n",
resp.bank2_status, sinfonia_bank_statuses(resp.bank1_status),
resp.bank2_printid,
le16_to_cpu(resp.bank2_finished),
le16_to_cpu(resp.bank2_specified),
le16_to_cpu(resp.bank2_remaining));
INFO("Tonecurve Status: 0x%02x (%s)\n", resp.tonecurve_status, sinfonia_tonecurve_statuses(resp.tonecurve_status));
/* Query Extended counters */
cmd.cmd = cpu_to_le16(SINFONIA_CMD_EXTCOUNTER);
cmd.len = cpu_to_le16(0);
if ((ret = sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp2, sizeof(resp2),
&num))) {
return ret;
}
if (le16_to_cpu(resp2.hdr.payload_len) != (sizeof(struct sinfonia_getextcounter_resp) - sizeof(struct sinfonia_status_hdr)))
return -1;
INFO("Lifetime Distance: %08u inches\n", le32_to_cpu(resp2.lifetime_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));
2017-07-10 20:15:56 -04:00
2015-11-17 19:28:09 -05:00
/* Query various params */
if (ctx->dev.conn->type == P_SHINKO_S6145D) {
if ((ret = sinfonia_getparam(&ctx->dev, PARAM_REGION_CODE, &val))) {
ERROR("Failed to execute command\n");
return ret;
}
INFO("Region Code: %#x\n", val);
}
if (ctx->dev.conn->type != P_SHINKO_S2245) {
if ((ret = sinfonia_getparam(&ctx->dev, PARAM_PAPER_PRESV, &val))) {
ERROR("Failed to execute command\n");
return ret;
}
INFO("Paper Preserve mode: %s\n", (val ? "On" : "Off"));
2015-11-17 19:28:09 -05:00
}
if ((ret = sinfonia_getparam(&ctx->dev, PARAM_DRIVER_MODE, &val))) {
2015-11-17 19:28:09 -05:00
ERROR("Failed to execute command\n");
return ret;
}
if (ctx->dev.conn->type != P_SHINKO_S2245) {
INFO("Driver mode: %s\n", s2245_drivermodes(val));
} else {
INFO("Driver mode: %s\n", (val ? "On" : "Off"));
}
2015-11-17 19:28:09 -05:00
if ((ret = sinfonia_getparam(&ctx->dev, PARAM_PAPER_MODE, &val))) {
2015-11-17 19:28:09 -05:00
ERROR("Failed to execute command\n");
return ret;
}
2015-11-17 19:35:17 -05:00
INFO("Paper load mode: %s\n", (val ? "Cut" : "No Cut"));
2015-11-17 19:28:09 -05:00
if (ctx->dev.conn->type != P_SHINKO_S2245) {
if ((ret = sinfonia_getparam(&ctx->dev, PARAM_SLEEP_TIME, &val))) {
ERROR("Failed to execute command\n");
return ret;
}
if (val == 0)
val = 5;
else if (val == 1)
val = 15;
else if (val == 2)
val = 30;
else if (val == 3)
val = 60;
else if (val == 4)
val = 120;
else if (val >= 5)