2020-01-22 11:25:06 -05:00
|
|
|
/*
|
2024-01-05 12:09:41 -05:00
|
|
|
* Shinko/Sinfonia CHC-S2145 CUPS backend
|
2013-07-06 10:14:06 -04:00
|
|
|
*
|
2024-01-20 17:59:48 -05:00
|
|
|
* (c) 2013-2024 Solomon Peachy <pizza@shaftnet.org>
|
2013-07-06 10:14:06 -04:00
|
|
|
*
|
2013-07-06 19:08:17 -04:00
|
|
|
* Development of this backend was sponsored by:
|
2013-12-17 08:30:37 -05:00
|
|
|
*
|
2013-07-06 19:08:17 -04:00
|
|
|
* LiveLink Technology [ www.livelinktechnology.net ]
|
2013-12-17 08:30:37 -05:00
|
|
|
*
|
2013-07-06 10:14:06 -04:00
|
|
|
* The latest version of this program can be found at:
|
|
|
|
*
|
2024-05-29 20:34:43 -04:00
|
|
|
* https://git.shaftnet.org/gitea/slp/selphy_print.git
|
2013-07-06 10:14:06 -04:00
|
|
|
*
|
|
|
|
* 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
|
2020-01-17 16:50:56 -05:00
|
|
|
* along with this program; if not, see <https://www.gnu.org/licenses/>.
|
2013-07-06 10:14:06 -04:00
|
|
|
*
|
2017-11-17 13:34:26 -05:00
|
|
|
* SPDX-License-Identifier: GPL-3.0+
|
|
|
|
*
|
2013-07-06 10:14:06 -04:00
|
|
|
*/
|
|
|
|
|
2015-08-13 21:09:56 -04:00
|
|
|
#define BACKEND shinkos2145_backend
|
2013-07-06 10:14:06 -04:00
|
|
|
|
2015-08-13 21:09:56 -04:00
|
|
|
#include "backend_common.h"
|
2019-05-13 10:29:00 -04:00
|
|
|
#include "backend_sinfonia.h"
|
2013-07-06 10:14:06 -04:00
|
|
|
|
|
|
|
enum {
|
|
|
|
S_IDLE = 0,
|
|
|
|
S_PRINTER_READY_CMD,
|
|
|
|
S_PRINTER_SENT_DATA,
|
|
|
|
S_FINISHED,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Structs for printer */
|
2016-08-19 18:00:23 -04:00
|
|
|
static int print_counts (uint8_t v) {
|
|
|
|
switch (v) {
|
2019-05-13 10:41:28 -04:00
|
|
|
case CODE_4x6:
|
2016-08-19 18:00:23 -04:00
|
|
|
return 700;
|
2019-05-13 10:41:28 -04:00
|
|
|
case CODE_3_5x5:
|
2016-08-19 18:00:23 -04:00
|
|
|
return 800;
|
2019-05-13 10:41:28 -04:00
|
|
|
case CODE_5x7:
|
2016-08-19 18:00:23 -04:00
|
|
|
return 400;
|
2019-05-13 10:41:28 -04:00
|
|
|
case CODE_6x9:
|
2016-08-19 18:00:23 -04:00
|
|
|
return 310;
|
2019-05-13 10:41:28 -04:00
|
|
|
case CODE_6x8:
|
2016-08-19 18:00:23 -04:00
|
|
|
return 350;
|
|
|
|
default:
|
|
|
|
return 700;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-25 22:04:43 -04:00
|
|
|
#if 0
|
2013-07-06 18:56:19 -04:00
|
|
|
#define PRINT_MODE_DEFAULT 0x01
|
|
|
|
#define PRINT_MODE_STD_GLOSSY 0x02
|
|
|
|
#define PRINT_MODE_FINE_GLOSSY 0x03
|
|
|
|
#define PRINT_MODE_STD_MATTE 0x04
|
|
|
|
#define PRINT_MODE_FINE_MATTE 0x05
|
|
|
|
#define PRINT_MODE_STD_EGLOSSY 0x06
|
|
|
|
#define PRINT_MODE_FINE_EGLOSSY 0x07
|
|
|
|
|
2019-05-25 22:04:43 -04:00
|
|
|
static char *s2145_print_modes(uint8_t v) {
|
2013-07-16 23:00:50 -04:00
|
|
|
switch (v) {
|
|
|
|
case PRINT_MODE_DEFAULT:
|
|
|
|
return "Default";
|
2019-05-25 22:04:43 -04:00
|
|
|
case PRINT_MODE_STD_GLOSSY:
|
2013-07-16 23:00:50 -04:00
|
|
|
return "Std Glossy";
|
|
|
|
case PRINT_MODE_FINE_GLOSSY:
|
|
|
|
return "Fine Glossy";
|
|
|
|
case PRINT_MODE_STD_MATTE:
|
|
|
|
return "Std Matte";
|
|
|
|
case PRINT_MODE_FINE_MATTE:
|
|
|
|
return "Fine Matte";
|
|
|
|
case PRINT_MODE_STD_EGLOSSY:
|
|
|
|
return "Std ExGlossy";
|
|
|
|
case PRINT_MODE_FINE_EGLOSSY:
|
|
|
|
return "Fine ExGlossy";
|
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
}
|
2013-07-18 22:10:56 -04:00
|
|
|
#endif
|
2013-07-06 18:56:19 -04:00
|
|
|
|
2013-07-06 10:14:06 -04:00
|
|
|
struct s2145_reset_cmd {
|
2019-05-12 23:41:04 -04:00
|
|
|
struct sinfonia_cmd_hdr hdr;
|
2013-07-06 10:14:06 -04:00
|
|
|
uint8_t target;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2013-07-06 15:12:45 -04:00
|
|
|
#define RESET_PRINTER 0x03
|
|
|
|
#define RESET_USER_CURVE 0x04
|
|
|
|
|
2013-07-06 10:14:06 -04:00
|
|
|
struct s2145_readtone_cmd {
|
2019-05-12 23:41:04 -04:00
|
|
|
struct sinfonia_cmd_hdr hdr;
|
2013-07-06 10:14:06 -04:00
|
|
|
uint8_t curveid;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2013-07-06 15:12:45 -04:00
|
|
|
#define FWINFO_TARGET_MAIN_BOOT 0x01
|
|
|
|
#define FWINFO_TARGET_MAIN_APP 0x02
|
|
|
|
#define FWINFO_TARGET_DSP_BOOT 0x03
|
|
|
|
#define FWINFO_TARGET_DSP_APP 0x04
|
|
|
|
#define FWINFO_TARGET_USB_BOOT 0x05
|
|
|
|
#define FWINFO_TARGET_USB_APP 0x06
|
|
|
|
#define FWINFO_TARGET_TABLES 0x07
|
|
|
|
|
2020-03-24 18:22:39 -04:00
|
|
|
static const char *fwinfo_targets (uint8_t v) {
|
2013-07-16 23:00:50 -04:00
|
|
|
switch (v) {
|
|
|
|
case FWINFO_TARGET_MAIN_BOOT:
|
|
|
|
return "Main Boot";
|
|
|
|
case FWINFO_TARGET_MAIN_APP:
|
|
|
|
return "Main App ";
|
|
|
|
case FWINFO_TARGET_DSP_BOOT:
|
|
|
|
return "DSP Boot ";
|
|
|
|
case FWINFO_TARGET_DSP_APP:
|
|
|
|
return "DSP App ";
|
|
|
|
case FWINFO_TARGET_USB_BOOT:
|
|
|
|
return "USB Boot ";
|
|
|
|
case FWINFO_TARGET_USB_APP:
|
|
|
|
return "USB App ";
|
2017-07-10 20:15:56 -04:00
|
|
|
case FWINFO_TARGET_TABLES:
|
2013-07-16 23:00:50 -04:00
|
|
|
return "Tables ";
|
|
|
|
default:
|
|
|
|
return "Unknown ";
|
|
|
|
}
|
|
|
|
}
|
2013-07-06 18:56:19 -04:00
|
|
|
|
2013-07-06 10:14:06 -04:00
|
|
|
struct s2145_update_cmd {
|
2019-05-12 23:41:04 -04:00
|
|
|
struct sinfonia_cmd_hdr hdr;
|
2013-07-06 10:14:06 -04:00
|
|
|
uint8_t target;
|
|
|
|
uint32_t reserved;
|
|
|
|
uint32_t size;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct s2145_setunique_cmd {
|
2019-05-12 23:41:04 -04:00
|
|
|
struct sinfonia_cmd_hdr hdr;
|
2013-07-06 10:14:06 -04:00
|
|
|
uint8_t len;
|
|
|
|
uint8_t data[23]; /* Not necessarily all used. */
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2019-05-24 23:49:51 -04:00
|
|
|
static const char *error_codes(uint8_t major, uint8_t minor)
|
2013-07-24 21:52:16 -04:00
|
|
|
{
|
|
|
|
switch(major) {
|
2015-02-24 23:39:57 -05:00
|
|
|
case 0x01: /* "Controller Error" */
|
2013-07-24 21:52:16 -04:00
|
|
|
switch(minor) {
|
|
|
|
case 0x01:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: EEPROM Write Timeout";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x02:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: EEPROM Verify";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x04:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: DSP Inactive";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x05:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: DSP Application Inactive";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x06:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: Main FW Data";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x07:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: Main FW Write";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x08:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: DSP FW Data";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x09:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: DSP FW Write";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x0A:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: 0A ASIC??";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x0B:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: 0B FPGA??";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x0D:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: Tone Curve Write";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x16:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: Invalid Parameter Table";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x17:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: Parameter Table Data";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x18:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: Parameter Table Write";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x29:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: DSP Communication";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x2A:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Controller: DSP DMA Failure";
|
2013-07-24 21:52:16 -04:00
|
|
|
default:
|
|
|
|
return "Controller: Unknown";
|
|
|
|
}
|
2015-02-24 23:39:57 -05:00
|
|
|
case 0x02: /* "Mechanical Error" */
|
2013-07-24 21:52:16 -04:00
|
|
|
switch (minor) {
|
|
|
|
case 0x01:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Mechanical: Thermal Head (Upper Up)";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x02:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Mechanical: Thermal Head (Head Up)";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x03:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Mechanical: Thermal Head (Head Down)";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x04:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Mechanical: Pinch Roller (Initialize)";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x05:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Mechanical: Pinch Roller (Mode1)";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x06:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Mechanical: Pinch Roller (Mode2)";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x07:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Mechanical: Pinch Roller (Mode3)";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x08:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Mechanical: Pinch Roller (Mode4)";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x09:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Mechanical: Cutter (Right)";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x0A:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Mechanical: Cutter (Left)";
|
|
|
|
case 0x0B:
|
|
|
|
return "Mechanical: Thermal Head (Head Down Recovery)";
|
2013-07-24 21:52:16 -04:00
|
|
|
default:
|
|
|
|
return "Mechanical: Unknown";
|
|
|
|
}
|
2015-02-24 23:39:57 -05:00
|
|
|
case 0x03: /* "Sensor Error" */
|
2013-07-24 21:52:16 -04:00
|
|
|
switch (minor) {
|
|
|
|
case 0x01:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Sensor: Thermal Head";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x02:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Sensor: Pinch Roller";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x03:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Sensor: Cutter Left";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x04:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Sensor: Cutter Right";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x05:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Sensor: Cutter Unknown";
|
|
|
|
case 0x08:
|
|
|
|
return "Sensor: Ribbon Encoder (Supply)";
|
|
|
|
case 0x09:
|
|
|
|
return "Sensor: Ribbon Encoder (Takeup)";
|
|
|
|
case 0x13:
|
|
|
|
return "Sensor: Thermal Head";
|
2013-07-24 21:52:16 -04:00
|
|
|
default:
|
|
|
|
return "Sensor: Unknown";
|
|
|
|
}
|
2015-02-24 23:39:57 -05:00
|
|
|
case 0x04: /* "Temperature Sensor Error" */
|
2013-07-24 21:52:16 -04:00
|
|
|
switch (minor) {
|
|
|
|
case 0x01:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Temp Sensor: Thermal Head High";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x02:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Temp Sensor: Thermal Head Low";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x03:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Temp Sensor: Environment High";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x04:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Temp Sensor: Environment Low";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x05:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Temp Sensor: Warmup Timed Out";
|
2013-07-24 21:52:16 -04:00
|
|
|
default:
|
|
|
|
return "Temp Sensor: Unknown";
|
|
|
|
}
|
2015-02-24 23:39:57 -05:00
|
|
|
case 0x5: /* "Paper Jam" */
|
2013-07-24 21:52:16 -04:00
|
|
|
switch (minor) {
|
|
|
|
case 0x01:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Loading Leading Edge Off";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x02:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Loading Print Position On";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x03:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Loading Print Position Off";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x04:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Loading Print Position On";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x05:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Loading Leading Edge On";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x11:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Initializing Print Position Off";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x12:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Initializing Print Position On";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x13:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Initializing Leading Edge On";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x14:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Initializing Print Position On";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x15:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Initializing Print Position Off";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x16:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Initializing Print Position On";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x21:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Initializing Print Position On";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x22:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Rewinding Print Position On";
|
|
|
|
case 0x40:
|
|
|
|
return "Paper Jam: Pre-Printing Print Position Off";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x41:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Pre-Printing Print Position Off";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x42:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Printing Leading Edge Off";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x43:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: After Returning Lead Edge Off";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x44:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: After Printing Print Position Off";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x45:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: After Printing Print Position On";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x46:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: After Printing Print Position On";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x47:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: After Printing Print Position Off";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x49:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Printing Lost Ribbon Mark";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x4A:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Printing Ribbon Cut";
|
|
|
|
case 0x4D:
|
|
|
|
return "Paper Jam: Printing Lost M Mark";
|
|
|
|
case 0x4E:
|
|
|
|
return "Paper Jam: Printing Lost C Mark";
|
|
|
|
case 0x4F:
|
|
|
|
return "Paper Jam: Printing Lost OP Mark";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x61:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Initializing Lead Edge On";
|
2013-07-24 21:52:16 -04:00
|
|
|
case 0x62:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Paper Jam: Initizlizing Print Position On";
|
|
|
|
case 0x64:
|
|
|
|
return "Paper Jam: Initizlizing Paper Size On";
|
2013-07-24 21:52:16 -04:00
|
|
|
default:
|
|
|
|
return "Paper Jam: Unknown";
|
|
|
|
}
|
2015-02-24 23:39:57 -05:00
|
|
|
case 0x06: /* User Error */
|
2013-07-24 21:52:16 -04:00
|
|
|
switch (minor) {
|
2015-02-24 23:39:57 -05:00
|
|
|
case 0x01:
|
|
|
|
return "Front Cover Open";
|
|
|
|
case 0x02:
|
|
|
|
return "Incorrect Ribbon";
|
|
|
|
case 0x03:
|
|
|
|
return "No Ribbon";
|
|
|
|
case 0x04:
|
|
|
|
return "Mismatched Ribbon";
|
|
|
|
case 0x05:
|
|
|
|
return "Mismatched Paper";
|
|
|
|
case 0x06:
|
|
|
|
return "Paper Empty";
|
|
|
|
case 0x08:
|
|
|
|
return "No Paper";
|
|
|
|
case 0x09:
|
|
|
|
return "Take Out Paper";
|
|
|
|
case 0x0A:
|
|
|
|
return "Cover Open Error";
|
|
|
|
case 0x0B:
|
|
|
|
return "Thermal Head Damaged";
|
|
|
|
case 0x0C:
|
|
|
|
return "Thermal Head Recovery";
|
2013-07-24 21:52:16 -04:00
|
|
|
default:
|
2015-02-24 23:39:57 -05:00
|
|
|
return "Unknown";
|
2013-07-24 21:52:16 -04:00
|
|
|
}
|
|
|
|
default:
|
2013-07-25 18:19:24 -04:00
|
|
|
return "Unknown";
|
2013-07-24 21:52:16 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-06 10:14:06 -04:00
|
|
|
struct s2145_status_resp {
|
2019-05-12 23:41:04 -04:00
|
|
|
struct sinfonia_status_hdr hdr;
|
2013-07-06 10:14:06 -04:00
|
|
|
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;
|
|
|
|
uint8_t bank1_printid;
|
|
|
|
uint8_t bank2_printid;
|
|
|
|
uint16_t bank1_remaining;
|
|
|
|
uint16_t bank1_finished;
|
|
|
|
uint16_t bank1_specified;
|
|
|
|
uint8_t bank1_status;
|
|
|
|
uint16_t bank2_remaining;
|
|
|
|
uint16_t bank2_finished;
|
|
|
|
uint16_t bank2_specified;
|
|
|
|
uint8_t bank2_status;
|
|
|
|
uint8_t tonecurve_status;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct s2145_readtone_resp {
|
2019-05-12 23:41:04 -04:00
|
|
|
struct sinfonia_status_hdr hdr;
|
2013-07-06 20:29:30 -04:00
|
|
|
uint16_t total_size;
|
2013-07-06 10:14:06 -04:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct s2145_mediainfo_resp {
|
2019-05-12 23:41:04 -04:00
|
|
|
struct sinfonia_status_hdr hdr;
|
2013-07-06 10:14:06 -04:00
|
|
|
uint8_t count;
|
2019-05-13 10:41:28 -04:00
|
|
|
struct sinfonia_mediainfo_item items[10]; /* Not all necessarily used */
|
2013-07-06 10:14:06 -04:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct s2145_modelname_resp {
|
2019-05-12 23:41:04 -04:00
|
|
|
struct sinfonia_status_hdr hdr;
|
2013-07-06 10:14:06 -04:00
|
|
|
uint8_t vendor[4];
|
|
|
|
uint8_t product[4];
|
|
|
|
uint8_t modelname[40];
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2013-07-06 14:11:41 -04:00
|
|
|
struct s2145_getunique_resp {
|
2019-05-12 23:41:04 -04:00
|
|
|
struct sinfonia_status_hdr hdr;
|
2013-07-06 14:11:41 -04:00
|
|
|
uint8_t data[24]; /* Not necessarily all used. */
|
|
|
|
} __attribute__((packed));
|
2013-07-06 10:14:06 -04:00
|
|
|
|
2018-04-27 15:40:09 -04:00
|
|
|
/* Private data structure */
|
|
|
|
struct shinkos2145_ctx {
|
2019-05-24 23:49:51 -04:00
|
|
|
struct sinfonia_usbdev dev;
|
2018-04-27 15:40:09 -04:00
|
|
|
|
|
|
|
uint8_t jobid;
|
|
|
|
|
2019-12-13 19:54:50 -05:00
|
|
|
char serial[32];
|
|
|
|
char fwver[32];
|
|
|
|
|
2018-04-27 15:40:09 -04:00
|
|
|
struct s2145_mediainfo_resp media;
|
|
|
|
struct marker marker;
|
|
|
|
int media_code;
|
|
|
|
};
|
|
|
|
|
2013-07-18 22:10:56 -04:00
|
|
|
static int get_status(struct shinkos2145_ctx *ctx)
|
2013-07-16 23:00:50 -04:00
|
|
|
{
|
2019-05-12 23:41:04 -04:00
|
|
|
struct sinfonia_cmd_hdr cmd;
|
2019-05-13 10:41:28 -04:00
|
|
|
struct s2145_status_resp resp;
|
2013-07-16 23:00:50 -04:00
|
|
|
int ret, num = 0;
|
|
|
|
|
2019-05-13 10:41:28 -04:00
|
|
|
cmd.cmd = cpu_to_le16(SINFONIA_CMD_GETSTATUS);
|
2013-07-16 23:00:50 -04:00
|
|
|
cmd.len = cpu_to_le16(0);
|
|
|
|
|
2019-05-24 23:49:51 -04:00
|
|
|
if ((ret = sinfonia_docmd(&ctx->dev,
|
2013-07-16 23:00:50 -04:00
|
|
|
(uint8_t*)&cmd, sizeof(cmd),
|
2019-05-13 10:41:28 -04:00
|
|
|
(uint8_t*)&resp, sizeof(resp),
|
2019-09-21 23:03:05 -04:00
|
|
|
&num))) {
|
2013-07-24 13:49:43 -04:00
|
|
|
return ret;
|
2013-07-16 23:00:50 -04:00
|
|
|
}
|
|
|
|
|
2019-05-13 10:41:28 -04:00
|
|
|
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;
|
2013-07-25 18:17:49 -04:00
|
|
|
INFO(" Error 0x%02x (%s) 0x%02x/0x%02x (%s)\n",
|
2019-05-13 10:41:28 -04:00
|
|
|
resp.hdr.error,
|
|
|
|
sinfonia_error_str(resp.hdr.error),
|
|
|
|
resp.hdr.printer_major,
|
|
|
|
resp.hdr.printer_minor, error_codes(resp.hdr.printer_major, resp.hdr.printer_minor));
|
2013-07-25 18:17:49 -04:00
|
|
|
}
|
2019-05-13 10:41:28 -04:00
|
|
|
if (le16_to_cpu(resp.hdr.payload_len) != (sizeof(struct s2145_status_resp) - sizeof(struct sinfonia_status_hdr)))
|
2019-09-21 23:03:05 -04:00
|
|
|
return CUPS_BACKEND_OK;
|
2013-07-06 12:48:19 -04:00
|
|
|
|
2013-07-16 18:13:10 -04:00
|
|
|
INFO(" Print Counts:\n");
|
2019-05-13 10:41:28 -04:00
|
|
|
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));
|
2014-02-11 20:11:33 -05:00
|
|
|
INFO("Bank 1: 0x%02x (%s) Job %03u @ %03u/%03u (%03u remaining)\n",
|
2019-05-13 10:41:28 -04:00
|
|
|
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));
|
2013-07-06 13:39:00 -04:00
|
|
|
|
2016-08-21 10:23:00 -04:00
|
|
|
INFO("Bank 2: 0x%02x (%s) Job %03u @ %03u/%03u (%03u remaining)\n",
|
2019-05-13 10:41:28 -04:00
|
|
|
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));
|
2013-07-06 13:39:00 -04:00
|
|
|
|
2019-05-13 10:41:28 -04:00
|
|
|
INFO("Tonecurve Status: 0x%02x (%s)\n", resp.tonecurve_status, sinfonia_tonecurve_statuses(resp.tonecurve_status));
|
2013-07-06 13:39:00 -04:00
|
|
|
|
2019-09-21 23:03:05 -04:00
|
|
|
return CUPS_BACKEND_OK;
|
2013-07-06 12:48:19 -04:00
|
|
|
}
|
|
|
|
|
2013-07-18 22:10:56 -04:00
|
|
|
static int get_fwinfo(struct shinkos2145_ctx *ctx)
|
2013-07-06 12:48:19 -04:00
|
|
|
{
|
2019-05-12 23:41:04 -04:00
|
|
|
struct sinfonia_fwinfo_cmd cmd;
|
2019-05-13 10:41:28 -04:00
|
|
|
struct sinfonia_fwinfo_resp resp;
|
2014-02-11 20:11:33 -05:00
|
|
|
int num = 0;
|
2013-07-06 13:39:00 -04:00
|
|
|
int i;
|
|
|
|
|
2019-05-13 10:41:28 -04:00
|
|
|
cmd.hdr.cmd = cpu_to_le16(SINFONIA_CMD_FWINFO);
|
2013-07-06 13:39:00 -04:00
|
|
|
cmd.hdr.len = cpu_to_le16(1);
|
|
|
|
|
|
|
|
INFO("FW Information:\n");
|
|
|
|
|
2013-07-16 23:00:50 -04:00
|
|
|
for (i = FWINFO_TARGET_MAIN_BOOT ; i <= FWINFO_TARGET_TABLES ; i++) {
|
2014-02-11 20:11:33 -05:00
|
|
|
int ret;
|
2013-07-06 13:39:00 -04:00
|
|
|
cmd.target = i;
|
2013-07-16 23:00:50 -04:00
|
|
|
|
2019-05-24 23:49:51 -04:00
|
|
|
if ((ret = sinfonia_docmd(&ctx->dev,
|
2013-07-16 23:00:50 -04:00
|
|
|
(uint8_t*)&cmd, sizeof(cmd),
|
2019-05-13 10:41:28 -04:00
|
|
|
(uint8_t*)&resp, sizeof(resp),
|
2019-09-21 23:03:05 -04:00
|
|
|
&num))) {
|
2013-07-06 13:39:00 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-05-13 10:41:28 -04:00
|
|
|
if (le16_to_cpu(resp.hdr.payload_len) != (sizeof(struct sinfonia_fwinfo_resp) - sizeof(struct sinfonia_status_hdr)))
|
2013-07-06 13:39:00 -04:00
|
|
|
continue;
|
2016-08-19 17:40:12 -04:00
|
|
|
|
2013-07-16 23:00:50 -04:00
|
|
|
INFO(" %s\t ver %02x.%02x\n", fwinfo_targets(i),
|
2019-05-13 10:41:28 -04:00
|
|
|
resp.major, resp.minor);
|
2013-07-06 13:39:00 -04:00
|
|
|
#if 0
|
2019-05-13 10:41:28 -04:00
|
|
|
INFO(" name: '%s'\n", resp.name);
|
|
|
|
INFO(" type: '%s'\n", resp.type);
|
|
|
|
INFO(" date: '%s'\n", resp.date);
|
|
|
|
INFO(" version: %02x.%02x (CRC %04x)\n", resp.major, resp.minor,
|
|
|
|
le16_to_cpu(resp.checksum));
|
2013-07-06 13:39:00 -04:00
|
|
|
#endif
|
|
|
|
}
|
2019-09-21 23:03:05 -04:00
|
|
|
return CUPS_BACKEND_OK;
|
2013-07-06 12:48:19 -04:00
|
|
|
}
|
|
|
|
|
2018-04-27 15:40:09 -04:00
|
|
|
static void dump_mediainfo(struct s2145_mediainfo_resp *resp)
|
2013-07-06 12:48:19 -04:00
|
|
|
{
|
|
|
|
int i;
|
2013-07-06 13:39:00 -04:00
|
|
|
|
2016-08-21 10:23:00 -04:00
|
|
|
INFO("Supported Media Information: %u entries:\n", resp->count);
|
2013-07-14 17:37:48 -04:00
|
|
|
for (i = 0 ; i < resp->count ; i++) {
|
2019-05-12 12:55:57 -04:00
|
|
|
INFO(" %02d: C 0x%02x (%s), %04ux%04u, P 0x%02x (%s)\n", i,
|
2019-05-13 10:41:28 -04:00
|
|
|
resp->items[i].code,
|
|
|
|
sinfonia_print_codes(resp->items[i].code, 0),
|
2019-05-06 13:38:09 -04:00
|
|
|
resp->items[i].columns,
|
|
|
|
resp->items[i].rows,
|
2019-05-13 10:41:28 -04:00
|
|
|
resp->items[i].method,
|
|
|
|
sinfonia_print_methods(resp->items[i].method));
|
2013-07-06 13:39:00 -04:00
|
|
|
}
|
2013-07-06 12:48:19 -04:00
|
|
|
}
|
|
|
|
|
2016-08-19 17:40:12 -04:00
|
|
|
static int get_user_string(struct shinkos2145_ctx *ctx)
|
2013-07-06 14:11:41 -04:00
|
|
|
{
|
2019-05-12 23:41:04 -04:00
|
|
|
struct sinfonia_cmd_hdr cmd;
|
2019-05-13 10:41:28 -04:00
|
|
|
struct s2145_getunique_resp resp;
|
2013-07-06 14:11:41 -04:00
|
|
|
int ret, num = 0;
|
|
|
|
|
2019-05-13 10:41:28 -04:00
|
|
|
cmd.cmd = cpu_to_le16(SINFONIA_CMD_GETUNIQUE);
|
2013-07-06 14:11:41 -04:00
|
|
|
cmd.len = cpu_to_le16(0);
|
|
|
|
|
2019-05-24 23:49:51 -04:00
|
|
|
if ((ret = sinfonia_docmd(&ctx->dev,
|
2013-07-16 23:00:50 -04:00
|
|
|
(uint8_t*)&cmd, sizeof(cmd),
|
2019-05-13 10:41:28 -04:00
|
|
|
(uint8_t*)&resp, sizeof(resp),
|
2019-09-21 23:03:05 -04:00
|
|
|
&num))) {
|
2013-07-24 13:49:43 -04:00
|
|
|
return ret;
|
2013-07-06 14:11:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Null-terminate */
|
2019-05-13 10:41:28 -04:00
|
|
|
resp.hdr.payload_len = le16_to_cpu(resp.hdr.payload_len);
|
|
|
|
if (resp.hdr.payload_len > 23)
|
|
|
|
resp.hdr.payload_len = 23;
|
|
|
|
resp.data[resp.hdr.payload_len] = 0;
|
|
|
|
INFO("Unique String: '%s'\n", resp.data);
|
2019-09-21 23:03:05 -04:00
|
|
|
return CUPS_BACKEND_OK;
|
2013-07-06 14:11:41 -04:00
|
|
|
}
|
|
|
|
|
2023-11-01 14:11:58 -04:00
|
|
|
static int set_user_string(struct shinkos2145_ctx *ctx, const char *str)
|
2013-07-06 14:11:41 -04:00
|
|
|
{
|
|
|
|
struct s2145_setunique_cmd cmd;
|
2019-05-13 10:41:28 -04:00
|
|
|
struct sinfonia_status_hdr resp;
|
2013-07-06 14:11:41 -04:00
|
|
|
int ret, num = 0;
|
|
|
|
|
|
|
|
if (str) {
|
|
|
|
cmd.len = strlen(str);
|
|
|
|
if (cmd.len > 23)
|
|
|
|
cmd.len = 23;
|
|
|
|
memset(cmd.data, 0, sizeof(cmd.data));
|
|
|
|
strncpy((char*)cmd.data, str, cmd.len);
|
|
|
|
} else {
|
|
|
|
cmd.len = 0;
|
|
|
|
}
|
|
|
|
|
2019-05-13 10:41:28 -04:00
|
|
|
cmd.hdr.cmd = cpu_to_le16(SINFONIA_CMD_SETUNIQUE);
|
2013-07-06 14:11:41 -04:00
|
|
|
cmd.hdr.len = cpu_to_le16(cmd.len + 1);
|
|
|
|
|
2019-05-24 23:49:51 -04:00
|
|
|
if ((ret = sinfonia_docmd(&ctx->dev,
|
2013-07-16 23:00:50 -04:00
|
|
|
(uint8_t*)&cmd, cmd.len + 1 + sizeof(cmd.hdr),
|
2019-05-13 10:41:28 -04:00
|
|
|
(uint8_t*)&resp, sizeof(resp),
|
2019-09-21 23:03:05 -04:00
|
|
|
&num))) {
|
2013-07-24 13:49:43 -04:00
|
|
|
return ret;
|
2013-07-06 14:11:41 -04:00
|
|
|
}
|
|
|
|
|
2019-09-21 23:03:05 -04:00
|
|
|
return CUPS_BACKEND_OK;
|
2013-07-06 14:11:41 -04:00
|
|
|
}
|
|
|
|
|
2013-08-20 20:02:10 -04:00
|
|
|
static int reset_curve(struct shinkos2145_ctx *ctx, int target)
|
2013-07-06 15:12:45 -04:00
|
|
|
{
|
|
|
|
struct s2145_reset_cmd cmd;
|
2019-05-13 10:41:28 -04:00
|
|
|
struct sinfonia_status_hdr resp;
|
|
|
|
|
2013-07-06 15:12:45 -04:00
|
|
|
int ret, num = 0;
|
|
|
|
|
|
|
|
cmd.target = target;
|
|
|
|
|
2019-05-13 10:41:28 -04:00
|
|
|
cmd.hdr.cmd = cpu_to_le16(SINFONIA_CMD_RESET);
|
2013-07-06 15:12:45 -04:00
|
|
|
cmd.hdr.len = cpu_to_le16(1);
|
|
|
|
|
2019-05-24 23:49:51 -04:00
|
|
|
if ((ret = sinfonia_docmd(&ctx->dev,
|
2013-07-16 23:00:50 -04:00
|
|
|
(uint8_t*)&cmd, sizeof(cmd),
|
2019-05-13 10:41:28 -04:00
|
|
|
(uint8_t*)&resp, sizeof(resp),
|
2019-09-21 23:03:05 -04:00
|
|
|
&num))) {
|
2013-07-24 13:49:43 -04:00
|
|
|
return ret;
|
2013-07-06 15:12:45 -04:00
|
|
|
}
|
|
|
|
|
2019-09-21 23:03:05 -04:00
|
|
|
return CUPS_BACKEND_OK;
|
2013-07-06 15:12:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-10 20:15:56 -04:00
|
|
|
static int get_tonecurve(struct shinkos2145_ctx *ctx |