2015-07-26 23:05:21 -04:00
|
|
|
/*
|
|
|
|
* Shinko/Sinfonia CHC-S6145 CUPS backend -- libusb-1.0 version
|
|
|
|
*
|
2018-02-22 06:02:49 -05:00
|
|
|
* (c) 2015-2018 Solomon Peachy <pizza@shaftnet.org>
|
2015-07-26 23:05:21 -04:00
|
|
|
*
|
2015-08-29 14:47:25 -04:00
|
|
|
* Low-level documentation was provided by Sinfonia. Thank you!
|
2015-07-26 23:05:21 -04:00
|
|
|
*
|
|
|
|
* The latest version of this program can be found at:
|
|
|
|
*
|
|
|
|
* http://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, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* [http://www.gnu.org/licenses/gpl-3.0.html]
|
|
|
|
*
|
2015-08-29 14:47:25 -04:00
|
|
|
* An additional permission is granted, under the GPLv3 section 7, to combine
|
|
|
|
* and/or redistribute this program with the proprietary libS6145ImageProcess
|
|
|
|
* library, 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 library.
|
2017-07-10 20:15:56 -04:00
|
|
|
*
|
2017-11-17 13:34:26 -05:00
|
|
|
* SPDX-License-Identifier: GPL-3.0+ with special exception
|
|
|
|
*
|
2016-01-30 00:01:07 -05:00
|
|
|
*/
|
2015-07-26 23:05:21 -04:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2016-01-13 11:42:23 -05:00
|
|
|
#include <errno.h>
|
2015-07-26 23:05:21 -04:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
2016-04-10 09:29:49 -04:00
|
|
|
/* For Integration into gutenprint */
|
|
|
|
#if defined(HAVE_CONFIG_H)
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2016-01-31 18:17:25 -05:00
|
|
|
#if defined(USE_DLOPEN)
|
|
|
|
#define WITH_DYNAMIC
|
2016-01-14 15:00:18 -05:00
|
|
|
#include <dlfcn.h>
|
2017-07-10 20:15:56 -04:00
|
|
|
#define DL_INIT() do {} while(0)
|
2016-01-31 18:17:25 -05:00
|
|
|
#define DL_OPEN(__x) dlopen(__x, RTLD_NOW)
|
|
|
|
#define DL_SYM(__x, __y) dlsym(__x, __y)
|
|
|
|
#define DL_CLOSE(__x) dlclose(__x)
|
|
|
|
#define DL_EXIT() do {} while(0)
|
|
|
|
#elif defined(USE_LTDL)
|
|
|
|
#define WITH_DYNAMIC
|
|
|
|
#include <ltdl.h>
|
|
|
|
#define DL_INIT() lt_dlinit()
|
|
|
|
#define DL_OPEN(__x) lt_dlopen(__x)
|
|
|
|
#define DL_SYM(__x, __y) lt_dlsym(__x, __y)
|
|
|
|
#define DL_CLOSE(__x) do {} while(0)
|
|
|
|
#define DL_EXIT() lt_dlexit()
|
|
|
|
#else
|
|
|
|
#define DL_INIT() do {} while(0)
|
|
|
|
#define DL_CLOSE(__x) do {} while(0)
|
|
|
|
#define DL_EXIT() do {} while(0)
|
|
|
|
#warning "No dynamic loading support!"
|
|
|
|
#endif
|
2016-01-14 15:00:18 -05:00
|
|
|
|
2015-08-13 21:09:56 -04:00
|
|
|
#define BACKEND shinkos6145_backend
|
|
|
|
|
2015-07-26 23:05:21 -04:00
|
|
|
#include "backend_common.h"
|
|
|
|
|
2016-01-14 15:00:18 -05:00
|
|
|
/* Image processing library function prototypes */
|
|
|
|
typedef int (*ImageProcessingFN)(unsigned char *, unsigned short *, void *);
|
|
|
|
typedef int (*ImageAvrCalcFN)(unsigned char *, unsigned short, unsigned short, unsigned char *);
|
|
|
|
|
2016-01-17 16:58:10 -05:00
|
|
|
#define LIB_NAME "libS6145ImageProcess.so" // Official library
|
|
|
|
#define LIB_NAME_RE "libS6145ImageReProcess.so" // Reimplemented library
|
2015-07-26 23:05:21 -04:00
|
|
|
|
|
|
|
enum {
|
|
|
|
S_IDLE = 0,
|
|
|
|
S_PRINTER_READY_CMD,
|
|
|
|
S_PRINTER_SENT_DATA,
|
|
|
|
S_FINISHED,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Structure of printjob header. All fields are LITTLE ENDIAN */
|
|
|
|
struct s6145_printjob_hdr {
|
|
|
|
uint32_t len1; /* Fixed at 0x10 */
|
|
|
|
uint32_t model; /* Equal to the printer model (eg '6245' or '1245' decimal) */
|
|
|
|
uint32_t media_w; /* 0x02 for 5", 0x03 for 6" */
|
|
|
|
uint32_t unk3; /* Fixed at 0x01 */
|
|
|
|
|
|
|
|
uint32_t len2; /* Fixed at 0x64 */
|
|
|
|
uint32_t unk5;
|
2015-07-27 21:22:25 -04:00
|
|
|
uint32_t media; /* 0x08 5x5, 0x03 5x7, 0x07 2x6, 0x00 4x6, 0x06 6x6/6x6+6x2/4x6*2/6x8 */
|
2015-07-26 23:05:21 -04:00
|
|
|
uint32_t unk6;
|
|
|
|
|
2015-08-16 21:57:17 -04:00
|
|
|
uint32_t method; /* 0x00 normal, 0x02 4x6*2, 0x04 2x6*2, 0x05 6x6+2x6 */
|
2015-07-26 23:05:21 -04:00
|
|
|
uint32_t qual; /* 0x00 default, 0x01 std */
|
2015-07-27 21:22:25 -04:00
|
|
|
uint32_t oc_mode; /* 0x00 default, 0x01 off, 0x02 glossy, 0x03 matte */
|
2015-07-26 23:05:21 -04:00
|
|
|
uint32_t unk8;
|
|
|
|
|
|
|
|
uint32_t unk9;
|
|
|
|
uint32_t columns;
|
|
|
|
uint32_t rows;
|
|
|
|
uint32_t copies;
|
|
|
|
|
|
|
|
uint32_t unk10;
|
|
|
|
uint32_t unk11;
|
|
|
|
uint32_t unk12;
|
|
|
|
uint32_t unk13;
|
|
|
|
|
|
|
|
uint32_t unk14;
|
|
|
|
uint32_t unk15;
|
|
|
|
uint32_t dpi; /* Fixed at '300' (decimal) */
|
|
|
|
uint32_t unk16;
|
|
|
|
|
|
|
|
uint32_t unk17;
|
|
|
|
uint32_t unk18;
|
|
|
|
uint32_t unk19;
|
|
|
|
uint32_t unk20;
|
|
|
|
|
2017-03-29 10:20:53 -04:00
|
|
|
uint32_t ext_flags; /* 0x00 in the official headers. 0x01 to mark inout data as YMC planar */
|
2015-07-26 23:05:21 -04:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
2015-08-16 14:50:26 -04:00
|
|
|
/* "Image Correction Parameter" File */
|
2015-08-19 19:41:15 -04:00
|
|
|
// 128 bytes total, apparently an array of 32-bit values
|
2015-12-10 00:19:34 -05:00
|
|
|
struct tankParamTable {
|
|
|
|
uint32_t trdTankSize;
|
|
|
|
uint32_t sndTankSize;
|
|
|
|
uint32_t fstTankSize;
|
|
|
|
uint32_t trdTankIniEnergy;
|
|
|
|
uint32_t sndTankIniEnergy;
|
|
|
|
uint32_t fstTankIniEnergy;
|
|
|
|
uint32_t trdTrdConductivity;
|
|
|
|
uint32_t sndSndConductivity;
|
|
|
|
uint32_t fstFstConductivity;
|
|
|
|
uint32_t outTrdConductivity;
|
|
|
|
uint32_t trdSndConductivity;
|
|
|
|
uint32_t sndFstConductivity;
|
|
|
|
uint32_t fstOutConductivity;
|
|
|
|
uint32_t plusMaxEnergy;
|
|
|
|
uint32_t minusMaxEnergy;
|
2017-07-10 20:15:56 -04:00
|
|
|
uint32_t plusMaxEnergyPreRead;
|
|
|
|
uint32_t minusMaxEnergyPreRead;
|
2015-12-10 00:19:34 -05:00
|
|
|
uint32_t preReadLevelDiff;
|
|
|
|
uint32_t rsvd[14]; // null?
|
2015-08-19 19:41:15 -04:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
2015-08-16 14:50:26 -04:00
|
|
|
struct shinkos6145_correctionparam {
|
2015-12-10 00:19:34 -05:00
|
|
|
uint16_t pulseTransTable_Y[256]; // @0
|
|
|
|
uint16_t pulseTransTable_M[256]; // @512
|
|
|
|
uint16_t pulseTransTable_C[256]; // @1024
|
|
|
|
uint16_t pulseTransTable_O[256]; // @1536
|
|
|
|
|
|
|
|
uint16_t lineHistCoefTable_Y[256]; // @2048
|
|
|
|
uint16_t lineHistCoefTable_M[256]; // @2560
|
|
|
|
uint16_t lineHistCoefTable_C[256]; // @3072
|
|
|
|
uint16_t lineHistCoefTable_O[256]; // @3584
|
|
|
|
|
|
|
|
uint16_t lineCorrectEnvA_Y; // @4096
|
|
|
|
uint16_t lineCorrectEnvA_M; // @4098
|
|
|
|
uint16_t lineCorrectEnvA_C; // @4100
|
|
|
|
uint16_t lineCorrectEnvA_O; // @4102
|
|
|
|
|
|
|
|
uint16_t lineCorrectEnvB_Y; // @4104
|
|
|
|
uint16_t lineCorrectEnvB_M; // @4106
|
|
|
|
uint16_t lineCorrectEnvB_C; // @4108
|
|
|
|
uint16_t lineCorrectEnvB_O; // @4110
|
|
|
|
|
|
|
|
uint16_t lineCorrectEnvC_Y; // @4112
|
|
|
|
uint16_t lineCorrectEnvC_M; // @4114
|
|
|
|
uint16_t lineCorrectEnvC_C; // @4116
|
|
|
|
uint16_t lineCorrectEnvC_O; // @4118
|
|
|
|
|
|
|
|
uint32_t lineCorrectSlice_Y; // @4120
|
|
|
|
uint32_t lineCorrectSlice_M; // @4124
|
|
|
|
uint32_t lineCorrectSlice_C; // @4128
|
|
|
|
uint32_t lineCorrectSlice_O; // @4132
|
|
|
|
|
|
|
|
uint32_t lineCorrectSlice1Line_Y; // @4136
|
|
|
|
uint32_t lineCorrectSlice1Line_M; // @4140
|
|
|
|
uint32_t lineCorrectSlice1Line_C; // @4144
|
|
|
|
uint32_t lineCorrectSlice1Line_O; // @4148
|
|
|
|
|
|
|
|
uint32_t lineCorrectPulseMax_Y; // @4152 [array]
|
|
|
|
uint32_t lineCorrectPulseMax_M; // @4156 [array]
|
|
|
|
uint32_t lineCorrectPulseMax_C; // @4160 [array]
|
|
|
|
uint32_t lineCorrectPulseMax_O; // @4164 [array]
|
|
|
|
|
|
|
|
struct tankParamTable tableTankParam_Y; // @4168
|
|
|
|
struct tankParamTable tableTankParam_M; // @4296
|
|
|
|
struct tankParamTable tableTankParam_C; // @4424
|
|
|
|
struct tankParamTable tableTankParam_O; // @4552
|
|
|
|
|
|
|
|
uint16_t tankPlusMaxEnergyTable_Y[256]; // @4680
|
|
|
|
uint16_t tankPlusMaxEnergyTable_M[256]; // @5192
|
|
|
|
uint16_t tankPlusMaxEnergyTable_C[256]; // @5704
|
|
|
|
uint16_t tankPlusMaxEnergyTable_O[256]; // @6216
|
|
|
|
|
|
|
|
uint16_t tankMinusMaxEnergy_Y[256]; // @6728
|
|
|
|
uint16_t tankMinusMaxEnergy_M[256]; // @7240
|
|
|
|
uint16_t tankMinusMaxEnergy_C[256]; // @7752
|
|
|
|
uint16_t tankMinusMaxEnergy_O[256]; // @8264
|
|
|
|
|
|
|
|
uint16_t printMaxPulse_Y; // @8776
|
|
|
|
uint16_t printMaxPulse_M; // @8778
|
|
|
|
uint16_t printMaxPulse_C; // @8780
|
|
|
|
uint16_t printMaxPulse_O; // @8782
|
|
|
|
|
2016-01-02 09:32:00 -05:00
|
|
|
uint16_t mtfWeightH_Y; // @8784
|
|
|
|
uint16_t mtfWeightH_M; // @8786
|
|
|
|
uint16_t mtfWeightH_C; // @8788
|
|
|
|
uint16_t mtfWeightH_O; // @8790
|
2015-12-10 00:19:34 -05:00
|
|
|
|
2016-01-02 09:32:00 -05:00
|
|
|
uint16_t mtfWeightV_Y; // @8792
|
|
|
|
uint16_t mtfWeightV_M; // @8794
|
|
|
|
uint16_t mtfWeightV_C; // @8796
|
|
|
|
uint16_t mtfWeightV_O; // @8798
|
2015-12-10 00:19:34 -05:00
|
|
|
|
|
|
|
uint16_t mtfSlice_Y; // @8800
|
|
|
|
uint16_t mtfSlice_M; // @8802
|
|
|
|
uint16_t mtfSlice_C; // @8804
|
|
|
|
uint16_t mtfSlice_O; // @8806
|
|
|
|
|
2016-01-02 09:32:00 -05:00
|
|
|
uint16_t val_1; // @8808 // 1 enables linepreprintprocess
|
|
|
|
uint16_t val_2; // @8810 // 1 enables ctankprocess
|
2015-12-10 00:19:34 -05:00
|
|
|
uint16_t printOpLevel; // @8812
|
|
|
|
uint16_t matteMode; // @8814 // 1 for matte
|
|
|
|
|
2016-01-02 09:32:00 -05:00
|
|
|
uint16_t randomBase[4]; // @8816 [use lower byte of each]
|
2015-12-10 00:19:34 -05:00
|
|
|
|
|
|
|
uint16_t matteSize; // @8824
|
|
|
|
uint16_t matteGloss; // @8826
|
|
|
|
uint16_t matteDeglossBlk; // @8828
|
|
|
|
uint16_t matteDeglossWht; // @8830
|
|
|
|
|
|
|
|
uint16_t printSideOffset; // @8832
|
|
|
|
uint16_t headDots; // @8834 [always 0x0780, ie 1920. print width
|
|
|
|
|
|
|
|
uint16_t SideEdgeCoefTable[128]; // @8836
|
|
|
|
uint8_t rsvd_2[256]; // @9092, null?
|
|
|
|
uint16_t SideEdgeLvCoefTable[256]; // @9348
|
|
|
|
uint8_t rsvd_3[2572]; // @9860, null?
|
|
|
|
|
2016-01-02 09:32:00 -05:00
|
|
|
/* User-supplied data */
|
2015-08-16 14:50:26 -04:00
|
|
|
uint16_t width; // @12432
|
|
|
|
uint16_t height; // @12434
|
2016-01-02 09:32:00 -05:00
|
|
|
uint8_t pad[3948]; // @12436, null.
|
2015-08-16 14:50:26 -04:00
|
|
|
} __attribute__((packed)); /* 16384 bytes */
|
|
|
|
|
2015-07-26 23:05:21 -04:00
|
|
|
/* Structs for printer */
|
|
|
|
struct s6145_cmd_hdr {
|
|
|
|
uint16_t cmd;
|
|
|
|
uint16_t len; /* Not including this header */
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
#define S6145_CMD_GETSTATUS 0x0001
|
|
|
|
#define S6145_CMD_MEDIAINFO 0x0002
|
|
|
|
#define S6145_CMD_ERRORLOG 0x0004
|
|
|
|
#define S6145_CMD_GETPARAM 0x0005
|
|
|
|
#define S6145_CMD_GETSERIAL 0x0006
|
|
|
|
#define S6145_CMD_PRINTSTAT 0x0007
|
|
|
|
#define S6145_CMD_EXTCOUNTER 0x0008
|
2016-01-03 21:57:39 -05:00
|
|
|
#define S6145_CMD_MEMORYBANK 0x000A // Brava 21 only?
|
2015-07-26 23:05:21 -04:00
|
|
|
|
|
|
|
#define S6145_CMD_PRINTJOB 0x4001
|
|
|
|
#define S6145_CMD_CANCELJOB 0x4002
|
|
|
|
#define S6145_CMD_FLASHLED 0x4003
|
|
|
|
#define S6145_CMD_RESET 0x4004
|
|
|
|
#define S6145_CMD_READTONE 0x4005
|
|
|
|
#define S6145_CMD_SETPARAM 0x4007
|
|
|
|
|
|
|
|
#define S6145_CMD_GETCORR 0x400D
|
|
|
|
#define S6145_CMD_GETEEPROM 0x400E
|
|
|
|
#define S6145_CMD_SETEEPROM 0x400F
|
|
|
|
|
|
|
|
#define S6145_CMD_FWINFO 0xC003
|
|
|
|
#define S6145_CMD_UPDATE 0xC004
|
|
|
|
|
|
|
|
static char *cmd_names(uint16_t v) {
|
|
|
|
switch (le16_to_cpu(v)) {
|
|
|
|
case S6145_CMD_GETSTATUS:
|
|
|
|
return "Get Status";
|
|
|
|
case S6145_CMD_MEDIAINFO:
|
|
|
|
return "Get Media Info";
|
|
|
|
case S6145_CMD_ERRORLOG:
|
|
|
|
return "Get Error Log";
|
|
|
|
case S6145_CMD_GETPARAM:
|
|
|
|
return "Get Parameter";
|
|
|
|
case S6145_CMD_GETSERIAL:
|
2017-07-10 20:15:56 -04:00
|
|
|
return "Get Serial Number";
|
2015-07-26 23:05:21 -04:00
|
|
|
case S6145_CMD_PRINTSTAT:
|
|
|
|
return "Get Print ID Status";
|
|
|
|
case S6145_CMD_EXTCOUNTER:
|
|
|
|
return "Get Extended Counters";
|
|
|
|
case S6145_CMD_PRINTJOB:
|
|
|
|
return "Print";
|
|
|
|
case S6145_CMD_CANCELJOB:
|
|
|
|
return "Cancel Print";
|
|
|
|
case S6145_CMD_FLASHLED:
|
|
|
|
return "Flash LEDs";
|
|
|
|
case S6145_CMD_RESET:
|
|
|
|
return "Reset";
|
|
|
|
case S6145_CMD_READTONE:
|
|
|
|
return "Read Tone Curve";
|
|
|
|
case S6145_CMD_SETPARAM:
|
|
|
|
return "Set Parameter";
|
|
|
|
case S6145_CMD_GETCORR:
|
|
|
|
return "Get Image Correction Parameter";
|
|
|
|
case S6145_CMD_GETEEPROM:
|
|
|
|
return "Get EEPROM Backup Parameter";
|
|
|
|
case S6145_CMD_SETEEPROM:
|
|
|
|
return "Set EEPROM Backup Parameter";
|
|
|
|
case S6145_CMD_FWINFO:
|
|
|
|
return "Get Firmware Info";
|
|
|
|
case S6145_CMD_UPDATE:
|
|
|
|
return "Update";
|
|
|
|
default:
|
|
|
|
return "Unknown Command";
|
|
|
|
}
|
2016-12-15 09:37:31 -05:00
|
|
|
}
|
2015-07-26 23:05:21 -04:00
|
|
|
|
|
|
|
struct s6145_print_cmd {
|
|
|
|
struct s6145_cmd_hdr hdr;
|
|
|
|
uint8_t id;
|
|
|
|
uint16_t count;
|
|
|
|
uint16_t columns;
|
|
|
|
uint16_t rows;
|
2015-12-17 21:50:47 -05:00
|
|
|
uint8_t media; /* reserved in docs, but brava21 uses this */
|
2015-07-26 23:05:21 -04:00
|
|
|
uint8_t combo_wait;
|
2015-12-17 21:50:47 -05:00
|
|
|
uint8_t reserved[6];
|
|
|
|
uint8_t unk_1; /* Brava 21 sets this to 1 */
|
2015-07-26 23:05:21 -04:00
|
|
|
uint8_t method;
|
2017-07-10 20:15:56 -04:00
|
|
|
uint8_t image_avg;
|
2015-07-26 23:05:21 -04:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
#define PRINT_MODE_NO_OC 0x01
|
|
|
|
#define PRINT_MODE_GLOSSY 0x02
|
|
|
|
#define PRINT_MODE_MATTE 0x03
|
|
|
|
|
2016-01-13 19:44:50 -05:00
|
|
|
#if 0
|
2015-07-26 23:05:21 -04:00
|
|
|
static char *print_modes(uint8_t v) {
|
|
|
|
switch (v) {
|
|
|
|
case PRINT_MODE_NO_OC:
|
|
|
|
return "No Overcoat";
|
|
|
|
case PRINT_MODE_GLOSSY:
|
|
|
|
return "Glossy";
|
|
|
|
case PRINT_MODE_MATTE:
|
|
|
|
return "Matte";
|
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
}
|
2016-01-13 19:44:50 -05:00
|
|
|
#endif
|
2015-07-26 23:05:21 -04:00
|
|
|
|
|
|
|
#define PRINT_METHOD_STD 0x00
|
|
|
|
#define PRINT_METHOD_COMBO_2 0x02
|
|
|
|
#define PRINT_METHOD_SPLIT 0x04
|
|
|
|
#define PRINT_METHOD_DOUBLE 0x08
|
|
|
|
#define PRINT_METHOD_NOTRIM 0x80
|
|
|
|
|
2017-07-10 20:15:56 -04:00
|
|
|
static char *print_methods (uint8_t v) {
|
2015-07-26 23:05:21 -04:00
|
|
|
switch (v & 0xf) {
|
|
|
|
case PRINT_METHOD_STD:
|
|
|
|
return "Standard";
|
|
|
|
case PRINT_METHOD_COMBO_2:
|
|
|
|
return "2up";
|
|
|
|
case PRINT_METHOD_SPLIT:
|
2015-08-16 21:57:17 -04:00
|
|
|
return "Split";
|
2015-07-26 23:05:21 -04:00
|
|
|
case PRINT_METHOD_DOUBLE:
|
2015-08-16 21:57:17 -04:00
|
|
|
return "Double";
|
2015-07-26 23:05:21 -04:00
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct s6145_cancel_cmd {
|
|
|
|
struct s6145_cmd_hdr hdr;
|
|
|
|
uint8_t id;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct s6145_reset_cmd {
|
|
|
|
struct s6145_cmd_hdr hdr;
|
|
|
|
uint8_t target;
|
|
|
|
uint8_t curveid;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
#define RESET_PRINTER 0x03
|
|
|
|
#define RESET_TONE_CURVE 0x04
|
|
|
|
|
|
|
|
#define TONE_CURVE_ID 0x01
|
|
|
|
|
|
|
|
struct s6145_readtone_cmd {
|
|
|
|
struct s6145_cmd_hdr hdr;
|
|
|
|
uint8_t target;
|
|
|
|
uint8_t curveid;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
#define READ_TONE_CURVE_USER 0x01
|
|
|
|
#define READ_TONE_CURVE_CURR 0x02
|
|
|
|
|
|
|
|
struct s6145_setparam_cmd {
|
|
|
|
struct s6145_cmd_hdr hdr;
|
|
|
|
uint8_t target;
|
|
|
|
uint32_t param;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2015-11-17 21:47:11 -05:00
|
|
|
#define PARAM_OC_PRINT 0x20
|
2015-07-26 23:05:21 -04:00
|
|
|
#define PARAM_PAPER_PRESV 0x3d
|
|
|
|
#define PARAM_DRIVER_MODE 0x3e
|
|
|
|
#define PARAM_PAPER_MODE 0x3f
|
2016-01-03 21:57:39 -05:00
|
|
|
#define PARAM_REGION_CODE 0x53 // Brava 21 only?
|
2015-07-26 23:05:21 -04:00
|
|
|
#define PARAM_SLEEP_TIME 0x54
|
|
|
|
|
2016-01-03 21:57:39 -05:00
|
|
|
|
2015-11-17 21:47:11 -05:00
|
|
|
#define PARAM_OC_PRINT_OFF 0x00000001
|
|
|
|
#define PARAM_OC_PRINT_GLOSS 0x00000002
|
|
|
|
#define PARAM_OC_PRINT_MATTE 0x00000003
|
2015-07-26 23:05:21 -04:00
|
|
|
|
|
|
|
#define PARAM_PAPER_PRESV_OFF 0x00000000
|
|
|
|
#define PARAM_PAPER_PRESV_ON 0x00000001
|
|
|
|
|
|
|
|
#define PARAM_DRIVER_WIZOFF 0x00000000
|
|
|
|
#define PARAM_DRIVER_WIZON 0x00000001
|
|
|
|
|
|
|
|
#define PARAM_PAPER_NOCUT 0x00000000
|
|
|
|
#define PARAM_PAPER_CUTLOAD 0x00000001
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
|
struct s6145_seteeprom_cmd {
|
|
|
|
struct s6145_cmd_hdr hdr;
|
|
|
|
uint8_t data[256]; /* Maxlen */
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct s6145_errorlog_cmd {
|
|
|
|
struct s6145_cmd_hdr hdr;
|
|
|
|
uint16_t index; /* 0 is latest */
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct s6145_getparam_cmd {
|
|
|
|
struct s6145_cmd_hdr hdr;
|
|
|
|
uint8_t target;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct s6145_getprintidstatus_cmd {
|
|
|
|
struct s6145_cmd_hdr hdr;
|
|
|
|
uint8_t id;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct s6145_fwinfo_cmd {
|
|
|
|
struct s6145_cmd_hdr hdr;
|
|
|
|
uint8_t target;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
#define FWINFO_TARGET_MAIN_BOOT 0x01
|
|
|
|
#define FWINFO_TARGET_MAIN_APP 0x02
|
|
|
|
#define FWINFO_TARGET_PRINT_TABLES 0x03
|
|
|
|
#define FWINFO_TARGET_DSP 0x04
|
|
|
|
|
|
|
|
static char *fwinfo_targets (uint8_t v) {
|
|
|
|
switch (v) {
|
|
|
|
case FWINFO_TARGET_MAIN_BOOT:
|
|
|
|
return "Main Boot ";
|
|
|
|
case FWINFO_TARGET_MAIN_APP:
|
|
|
|
return "Main App ";
|
|
|
|
case FWINFO_TARGET_DSP:
|
|
|
|
return "DSP ";
|
|
|
|
case FWINFO_TARGET_PRINT_TABLES:
|
|
|
|
return "Print Tables";
|
|
|
|
default:
|
|
|
|
return "Unknown ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct s6145_update_cmd {
|
|
|
|
struct s6145_cmd_hdr hdr;
|
|
|
|
uint8_t target;
|
|
|
|
uint8_t curve_id;
|
|
|
|
uint8_t reset; // ??
|
|
|
|
uint8_t reserved[3];
|
|
|
|
uint32_t size;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
#define UPDATE_TARGET_USER 0x03
|
|
|
|
#define UPDATE_TARGET_CURRENT 0x04
|
|
|
|
|
|
|
|
static char *update_targets (uint8_t v) {
|
|
|
|
switch (v) {
|
|
|
|
case UPDATE_TARGET_USER:
|
|
|
|
return "User";
|
|
|
|
case UPDATE_TARGET_CURRENT:
|
|
|
|
return "Current";
|
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define UPDATE_SIZE 0x600
|
|
|
|
/* Update is three channels, Y, M, C;
|
|
|
|
each is 256 entries of 11-bit data padded to 16-bits.
|
|
|
|
Printer expects LE data. We use BE data on disk.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct s6145_status_hdr {
|
|
|
|
uint8_t result;
|
|
|
|
uint8_t error;
|
|
|
|
uint8_t printer_major;
|
|
|
|
uint8_t printer_minor;
|
|
|
|
uint8_t reserved[3];
|
|
|
|
uint8_t status;
|
|
|
|
uint16_t payload_len;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
#define RESULT_SUCCESS 0x01
|
|
|
|
#define RESULT_FAIL 0x02
|
|
|
|
|
|
|
|
#define ERROR_NONE 0x00
|
|
|
|
#define ERROR_INVALID_PARAM 0x01
|
|
|
|
#define ERROR_MAIN_APP_INACTIVE 0x02
|
|
|
|
#define ERROR_COMMS_TIMEOUT 0x03
|
|
|
|
#define ERROR_MAINT_NEEDED 0x04
|
|
|
|
#define ERROR_BAD_COMMAND 0x05
|
|
|
|
#define ERROR_PRINTER 0x11
|
|
|
|
#define ERROR_BUFFER_FULL 0x21
|
|
|
|
|
|
|
|
static char *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
|
|
|
|
2015-07-26 23:05:21 -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";
|
2015-07-26 23:05:21 -04:00
|
|
|
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 char *error_str(uint8_t v) {
|
|
|
|
switch (v) {
|
|
|
|
case ERROR_NONE:
|
|
|
|
return "None";
|
|
|
|
case ERROR_INVALID_PARAM:
|
|
|
|
return "Invalid Command Parameter";
|
|
|
|
case ERROR_MAIN_APP_INACTIVE:
|
|
|
|
return "Main App Inactive";
|
|
|
|
case ERROR_COMMS_TIMEOUT:
|
|
|
|
return "Main Communication Timeout";
|
|
|
|
case ERROR_MAINT_NEEDED:
|
2017-05-05 08:06:28 -04:00
|
|
|
return "Maintenance Needed";
|
2015-07-26 23:05:21 -04:00
|
|
|
case ERROR_BAD_COMMAND:
|
|
|
|
return "Inappropriate Command";
|
|
|
|
case ERROR_PRINTER:
|
|
|
|
return "Printer Error";
|
|
|
|
case ERROR_BUFFER_FULL:
|
|
|
|
return "Buffer Full";
|
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define STATUS_READY 0x00
|
|
|
|
#define STATUS_INIT_CPU 0x31
|
|
|
|
#define STATUS_INIT_RIBBON 0x32
|
|
|
|
#define STATUS_INIT_PAPER 0x33
|
|
|
|
#define STATUS_THERMAL_PROTECT 0x34
|
|
|
|
#define STATUS_USING_PANEL 0x35
|
|
|
|
#define STATUS_SELF_DIAG 0x36
|
|
|
|
#define STATUS_DOWNLOADING 0x37
|
|
|
|
|
|
|
|
#define STATUS_FEEDING_PAPER 0x61
|
|
|
|
#define STATUS_PRE_HEAT 0x62
|
|
|
|
#define STATUS_PRINT_Y 0x63
|
|
|
|
#define STATUS_BACK_FEED_Y 0x64
|
|
|
|
#define STATUS_PRINT_M 0x65
|
|
|
|
#define STATUS_BACK_FEED_M 0x66
|
|
|
|
#define STATUS_PRINT_C 0x67
|
|
|
|
#define STATUS_BACK_FEED_C 0x68
|
|
|
|
#define STATUS_PRINT_OP 0x69
|
|
|
|
#define STATUS_PAPER_CUT 0x6A
|
|
|
|
#define STATUS_PAPER_EJECT 0x6B
|
|
|
|
#define STATUS_BACK_FEED_E 0x6C
|
|
|
|
|
|
|
|
static char *status_str(uint8_t v) {
|
|
|
|
switch (v) {
|
|
|
|
case STATUS_READY:
|
|
|
|
return "Ready";
|
|
|
|
case STATUS_INIT_CPU:
|
|
|
|
return "Initializing CPU";
|
|
|
|
case STATUS_INIT_RIBBON:
|
|
|
|
return "Initializing Ribbon";
|
|
|
|
case STATUS_INIT_PAPER:
|
|
|
|
return "Loading Paper";
|
|
|
|
case STATUS_THERMAL_PROTECT:
|
|
|
|
return "Thermal Protection";
|
|
|
|
case STATUS_USING_PANEL:
|
|
|
|
return "Using Operation Panel";
|
|
|
|
case STATUS_SELF_DIAG:
|
|
|
|
return "Processing Self Diagnosis";
|
|
|
|
case STATUS_DOWNLOADING:
|
|
|
|
return "Processing Download";
|
|
|
|
case STATUS_FEEDING_PAPER:
|
|
|
|
return "Feeding Paper";
|
|
|
|
case STATUS_PRE_HEAT:
|
|
|
|
return "Pre-Heating";
|
|
|
|
case STATUS_PRINT_Y:
|
|
|
|
return "Printing Yellow";
|
|
|
|
case STATUS_BACK_FEED_Y:
|
|
|
|
return "Back-Feeding - Yellow Complete";
|
|
|
|
case STATUS_PRINT_M:
|
|
|
|
return "Printing Magenta";
|
|
|
|
case STATUS_BACK_FEED_M:
|
|
|
|
return "Back-Feeding - Magenta Complete";
|
|
|
|
case STATUS_PRINT_C:
|
|
|
|
return "Printing Cyan";
|
|
|
|
case STATUS_BACK_FEED_C:
|
|
|
|
return "Back-Feeding - Cyan Complete";
|
|
|
|
case STATUS_PRINT_OP:
|
|
|
|
return "Laminating";
|
|
|
|
case STATUS_PAPER_CUT:
|
|
|
|
return "Cutting Paper";
|
|
|
|
case STATUS_PAPER_EJECT:
|
|
|
|
return "Ejecting Paper";
|
|
|
|
case STATUS_BACK_FEED_E:
|
|
|
|
return "Back-Feeding - Ejected";
|
|
|
|
case ERROR_PRINTER:
|
|
|
|
return "Printer Error";
|
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct s6145_status_resp {
|
|
|
|
struct s6145_status_hdr hdr;
|
|
|
|
uint32_t count_lifetime;
|
|
|
|
uint32_t count_maint;
|
|
|
|
uint32_t count_paper;
|
|
|
|
uint32_t count_cutter;
|
|
|
|
uint32_t count_head;
|
|
|
|
uint32_t count_ribbon_left;
|
|
|
|
uint32_t reserved;
|
2016-08-19 17:40:12 -04:00
|
|
|
|
2015-07-26 23:05:21 -04:00
|
|
|
uint8_t bank1_printid;
|
|
|
|
uint16_t bank1_remaining;
|
|
|
|
uint16_t bank1_finished;
|
|
|
|
uint16_t bank1_specified;
|
|
|
|
uint8_t bank1_status;
|
2016-08-19 17:40:12 -04:00
|
|
|
|
2015-07-26 23:05:21 -04:00
|
|
|
uint8_t bank2_printid;
|
|
|
|
uint16_t bank2_remaining;
|
|
|
|
uint16_t bank2_finished;
|
|
|
|
uint16_t bank2_specified;
|
|
|
|
uint8_t bank2_status;
|
|
|
|
|
|
|
|
uint8_t reserved2[16];
|
|
|
|
uint8_t tonecurve_status;
|
2016-08-19 17:40:12 -04:00
|
|
|
uint8_t reserved3[6];
|
2015-07-26 23:05:21 -04:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
#define BANK_STATUS_FREE 0x00
|
|
|
|
#define BANK_STATUS_XFER 0x01
|
|
|
|
#define BANK_STATUS_FULL 0x02
|
|
|
|
#define BANK_STATUS_PRINTING 0x12
|
|
|
|
|
|
|
|
static char *bank_statuses(uint8_t v)
|
|
|
|
{
|
|
|
|
switch (v) {
|
|
|
|
case BANK_STATUS_FREE:
|
|
|
|
return "Free";
|
|
|
|
case BANK_STATUS_XFER:
|
|
|
|
return "Xfer";
|
|
|
|
case BANK_STATUS_FULL:
|
|
|
|
return "Full";
|
|
|
|
case BANK_STATUS_PRINTING:
|
|
|
|
return "Printing";
|
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TONECURVE_INIT 0x00
|
|
|
|
#define TONECURVE_USER 0x01
|
|
|
|
#define TONECURVE_CURRENT 0x02
|
|
|
|
|
|
|
|
static char *tonecurve_statuses (uint8_t v)
|
|
|
|
{
|
|
|
|
switch(v) {
|
|
|
|
case 0:
|
|
|
|
return "Initial";
|
|
|
|
case 1:
|
|
|
|
return "UserSet";
|
|
|
|
case 2:
|
|
|
|
return "Current";
|
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct s6145_geteeprom_resp {
|
|
|
|
struct s6145_status_hdr hdr;
|
|
|
|
uint8_t data[256];
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct s6145_readtone_resp {
|
|
|
|
struct s6145_status_hdr hdr;
|
|
|
|
uint16_t total_size;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct s6145_mediainfo_item {
|
|
|
|
uint8_t media_code;
|
|
|
|
uint16_t columns;
|
|
|
|
uint16_t rows;
|
|
|
|
uint8_t reserved;
|
|
|
|
uint8_t print_method; /* PRINT_METHOD_* */
|
|
|
|
uint8_t reserved2[3];
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
#define MEDIA_4x6 0x00
|
|
|
|
#define MEDIA_3_5x5 0x01
|
|
|
|
#define MEDIA_5x7 0x03
|
|
|
|
#define MEDIA_6x9 0x05
|
|
|
|
#define MEDIA_6x8 0x06
|
|
|
|
#define MEDIA_2x6 0x07
|
2015-12-17 21:50:47 -05:00
|
|
|
#define MEDIA_6x6 0x08
|
2016-08-22 12:36:12 -04:00
|
|
|
#define MEDIA_89x60mm 0x10
|
|
|
|
#define MEDIA_89x59mm 0x11
|
|
|
|
#define MEDIA_89x58mm 0x12
|
|
|
|
#define MEDIA_89x57mm 0x13
|
|
|
|
#define MEDIA_89x56mm 0x14
|
|
|
|
#define MEDIA_89x55mm 0x15
|
2015-07-26 23:05:21 -04:00
|
|
|
|
2016-08-19 17:40:12 -04:00
|
|
|
static char *print_sizes (uint8_t v) {
|
2015-07-26 23:05:21 -04:00
|
|
|
switch (v) {
|
|
|
|
case MEDIA_4x6:
|
|
|
|
return "4x6";
|
|
|
|
case MEDIA_3_5x5:
|
|
|
|
return "3.5x5";
|
|
|
|
case MEDIA_5x7:
|
|
|
|
return "5x7";
|
|
|
|
case MEDIA_6x9:
|
|
|
|
return "6x9";
|
|
|
|
case MEDIA_6x8:
|
|
|
|
return "6x8";
|
|
|
|
case MEDIA_2x6:
|
|
|
|
return "2x6";
|
2015-12-17 21:50:47 -05:00
|
|
|
case MEDIA_6x6:
|
|
|
|
return "6x6";
|
2016-08-22 12:36:12 -04:00
|
|
|
case MEDIA_89x60mm:
|
|
|
|
return "89x60mm";
|
|
|
|
case MEDIA_89x59mm:
|
|
|
|
return "89x59mm";
|
|
|
|
case MEDIA_89x58mm:
|
|
|
|
return "89x58mm";
|
|
|
|
case MEDIA_89x57mm:
|
|
|
|
return "89x57mm";
|
|
|
|
case MEDIA_89x56mm:
|
|
|
|
return "89x56mm";
|
|
|
|
case MEDIA_89x55mm:
|
|
|
|
return "89x55mm";
|
2015-07-26 23:05:21 -04:00
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-16 18:23:43 -04:00
|
|
|
#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
|
2016-08-22 12:36:12 -04:00
|
|
|
// XXX what about 89xXXXmm ribbons?
|
2015-08-16 18:23:43 -04:00
|
|
|
|
2016-08-19 17:40:12 -04:00
|
|
|
static int ribbon_sizes (uint8_t v) {
|
|
|
|
switch (v) {
|
|
|
|
case RIBBON_4x6:
|
|
|
|
return 300;
|
|
|
|
case RIBBON_3_5x5:
|
|
|
|
return 340;
|
|
|
|
case RIBBON_5x7:
|
|
|
|
return 170;
|
|
|
|
case RIBBON_6x8:
|
|
|
|
return 150;
|
|
|
|
case RIBBON_6x9:
|
|
|
|
return 130; // XXX guessed
|
2016-08-22 12:36:12 -04:00
|
|
|
// XXX 89x??? rubbons.
|
2016-08-19 17:40:12 -04:00
|
|
|
default:
|
|
|
|
return 300; // don't want 0.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *print_ribbons (uint8_t v) {
|
2015-08-16 18:23:43 -04:00
|
|
|
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";
|
2017-07-10 20:15:56 -04:00
|
|
|
// XXX 89x??? rubbons.
|
2015-08-16 18:23:43 -04:00
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-26 23:05:21 -04:00
|
|
|
struct s6145_mediainfo_resp {
|
|
|
|
struct s6145_status_hdr hdr;
|
2015-08-16 18:23:43 -04:00
|
|
|
uint8_t ribbon;
|
|
|
|
uint8_t reserved;
|
2015-07-26 23:05:21 -04:00
|
|
|
uint8_t count;
|
|
|
|
struct s6145_mediainfo_item items[10]; /* Not all necessarily used */
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct s6145_error_item {
|
|
|
|
uint8_t major;
|
|
|
|
uint8_t minor;
|
|
|
|
uint32_t print_counter;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct s6145_errorlog_resp {
|