Gutenprint + CUPS backends for Dye Sublimation printers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
selphy_print/backend_shinkos2145.c

1265 lines
32 KiB

/*
* Shinko/Sinfonia CHC-S2145 CUPS backend -- libusb-1.0 version
*
* (c) 2013-2022 Solomon Peachy <pizza@shaftnet.org>
*
* Development of this backend was sponsored by:
*
* LiveLink Technology [ www.livelinktechnology.net ]
*
* 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/>.
*
* SPDX-License-Identifier: GPL-3.0+
*
*/
#define BACKEND shinkos2145_backend
#include "backend_common.h"
#include "backend_sinfonia.h"
enum {
S_IDLE = 0,
S_PRINTER_READY_CMD,
S_PRINTER_SENT_DATA,
S_FINISHED,
};
/* Structs for printer */
static int print_counts (uint8_t v) {
switch (v) {
case CODE_4x6:
return 700;
case CODE_3_5x5:
return 800;
case CODE_5x7:
return 400;
case CODE_6x9:
return 310;
case CODE_6x8:
return 350;
default:
return 700;
}
}
#if 0
#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
static char *s2145_print_modes(uint8_t v) {
switch (v) {
case PRINT_MODE_DEFAULT:
return "Default";
case PRINT_MODE_STD_GLOSSY:
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";
}
}
#endif
struct s2145_reset_cmd {
struct sinfonia_cmd_hdr hdr;
uint8_t target;
} __attribute__((packed));
#define RESET_PRINTER 0x03
#define RESET_USER_CURVE 0x04
struct s2145_readtone_cmd {
struct sinfonia_cmd_hdr hdr;
uint8_t curveid;
} __attribute__((packed));
#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
static const 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_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 ";
case FWINFO_TARGET_TABLES:
return "Tables ";
default:
return "Unknown ";
}
}
struct s2145_update_cmd {
struct sinfonia_cmd_hdr hdr;
uint8_t target;
uint32_t reserved;
uint32_t size;
} __attribute__((packed));
struct s2145_setunique_cmd {
struct sinfonia_cmd_hdr hdr;
uint8_t len;
uint8_t data[23]; /* Not necessarily all used. */
} __attribute__((packed));
static const 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 0x02:
return "Controller: EEPROM Verify";
case 0x04:
return "Controller: DSP Inactive";
case 0x05:
return "Controller: DSP Application Inactive";
case 0x06:
return "Controller: Main FW Data";
case 0x07:
return "Controller: Main FW Write";
case 0x08:
return "Controller: DSP FW Data";
case 0x09:
return "Controller: DSP FW Write";
case 0x0A:
return "Controller: 0A ASIC??";
case 0x0B:
return "Controller: 0B FPGA??";
case 0x0D:
return "Controller: Tone Curve Write";
case 0x16:
return "Controller: Invalid Parameter Table";
case 0x17:
return "Controller: Parameter Table Data";
case 0x18:
return "Controller: Parameter Table Write";
case 0x29:
return "Controller: DSP Communication";
case 0x2A:
return "Controller: DSP DMA Failure";
default:
return "Controller: Unknown";
}
case 0x02: /* "Mechanical Error" */
switch (minor) {
case 0x01:
return "Mechanical: Thermal Head (Upper Up)";
case 0x02:
return "Mechanical: Thermal Head (Head Up)";
case 0x03:
return "Mechanical: Thermal Head (Head Down)";
case 0x04:
return "Mechanical: Pinch Roller (Initialize)";
case 0x05:
return "Mechanical: Pinch Roller (Mode1)";
case 0x06:
return "Mechanical: Pinch Roller (Mode2)";
case 0x07:
return "Mechanical: Pinch Roller (Mode3)";
case 0x08:
return "Mechanical: Pinch Roller (Mode4)";
case 0x09:
return "Mechanical: Cutter (Right)";
case 0x0A:
return "Mechanical: Cutter (Left)";
case 0x0B:
return "Mechanical: Thermal Head (Head Down Recovery)";
default:
return "Mechanical: Unknown";
}
case 0x03: /* "Sensor Error" */
switch (minor) {
case 0x01:
return "Sensor: Thermal Head";
case 0x02:
return "Sensor: Pinch Roller";
case 0x03:
return "Sensor: Cutter Left";
case 0x04:
return "Sensor: Cutter Right";
case 0x05:
return "Sensor: Cutter Unknown";
case 0x08:
return "Sensor: Ribbon Encoder (Supply)";
case 0x09:
return "Sensor: Ribbon Encoder (Takeup)";
case 0x13:
return "Sensor: Thermal Head";
default:
return "Sensor: Unknown";
}
case 0x04: /* "Temperature Sensor Error" */
switch (minor) {
case 0x01:
return "Temp Sensor: Thermal Head High";
case 0x02:
return "Temp Sensor: Thermal Head Low";
case 0x03:
return "Temp Sensor: Environment High";
case 0x04:
return "Temp Sensor: Environment Low";
case 0x05:
return "Temp Sensor: Warmup Timed Out";
default:
return "Temp Sensor: Unknown";
}
case 0x5: /* "Paper Jam" */
switch (minor) {
case 0x01:
return "Paper Jam: Loading Leading Edge Off";
case 0x02:
return "Paper Jam: Loading Print Position On";
case 0x03:
return "Paper Jam: Loading Print Position Off";
case 0x04:
return "Paper Jam: Loading Print Position On";
case 0x05:
return "Paper Jam: Loading Leading Edge On";
case 0x11:
return "Paper Jam: Initializing Print Position Off";
case 0x12:
return "Paper Jam: Initializing Print Position On";
case 0x13:
return "Paper Jam: Initializing Leading Edge On";
case 0x14:
return "Paper Jam: Initializing Print Position On";
case 0x15:
return "Paper Jam: Initializing Print Position Off";
case 0x16:
return "Paper Jam: Initializing Print Position On";
case 0x21:
return "Paper Jam: Initializing Print Position On";
case 0x22:
return "Paper Jam: Rewinding Print Position On";
case 0x40:
return "Paper Jam: Pre-Printing Print Position Off";
case 0x41:
return "Paper Jam: Pre-Printing Print Position Off";
case 0x42:
return "Paper Jam: Printing Leading Edge Off";
case 0x43:
return "Paper Jam: After Returning Lead Edge Off";
case 0x44:
return "Paper Jam: After Printing Print Position Off";
case 0x45:
return "Paper Jam: After Printing Print Position On";