shinko: MEDIA_TYPE_* definitions are common, and unify EK68x0 + S1245 errors

This commit is contained in:
Solomon Peachy 2019-05-12 12:55:57 -04:00
parent bed955d1ce
commit 63384d9657
9 changed files with 339 additions and 587 deletions

View File

@ -155,7 +155,7 @@ static int send_plane(struct kodak1400_ctx *ctx,
return 0; return 0;
} }
#define UPDATE_SIZE 1552 #define TONE_CURVE_SIZE 1552
static int kodak1400_set_tonecurve(struct kodak1400_ctx *ctx, char *fname) static int kodak1400_set_tonecurve(struct kodak1400_ctx *ctx, char *fname)
{ {
libusb_device_handle *dev = ctx->dev; libusb_device_handle *dev = ctx->dev;
@ -168,7 +168,7 @@ static int kodak1400_set_tonecurve(struct kodak1400_ctx *ctx, char *fname)
INFO("Set Tone Curve from '%s'\n", fname); INFO("Set Tone Curve from '%s'\n", fname);
uint16_t *data = malloc(UPDATE_SIZE); uint16_t *data = malloc(TONE_CURVE_SIZE);
if (!data) { if (!data) {
ERROR("Memory Allocation Failure!\n"); ERROR("Memory Allocation Failure!\n");
@ -176,17 +176,17 @@ static int kodak1400_set_tonecurve(struct kodak1400_ctx *ctx, char *fname)
} }
/* Read in file */ /* Read in file */
if ((ret = dyesub_read_file(fname, data, UPDATE_SIZE, NULL))) { if ((ret = dyesub_read_file(fname, data, TONE_CURVE_SIZE, NULL))) {
ERROR("Failed to read Tone Curve file\n"); ERROR("Failed to read Tone Curve file\n");
goto done; goto done;
} }
/* Byteswap data to printer's format */ /* Byteswap data to printer's format */
for (ret = 0; ret < (UPDATE_SIZE-16)/2 ; ret++) { for (ret = 0; ret < (TONE_CURVE_SIZE-16)/2 ; ret++) {
data[ret] = cpu_to_le16(be16_to_cpu(data[ret])); data[ret] = cpu_to_le16(be16_to_cpu(data[ret]));
} }
/* Null-terminate */ /* Null-terminate */
memset(data + (UPDATE_SIZE-16)/2, 0, 16); memset(data + (TONE_CURVE_SIZE-16)/2, 0, 16);
/* Clear tables */ /* Clear tables */
memset(cmdbuf, 0, sizeof(cmdbuf)); memset(cmdbuf, 0, sizeof(cmdbuf));
@ -221,14 +221,14 @@ static int kodak1400_set_tonecurve(struct kodak1400_ctx *ctx, char *fname)
cmdbuf[2] = 0x02; cmdbuf[2] = 0x02;
cmdbuf[3] = 0x03; cmdbuf[3] = 0x03;
cmdbuf[4] = 0x06; cmdbuf[4] = 0x06;
cmdbuf[5] = 0x10; /* 06 10 == UPDATE_SIZE */ cmdbuf[5] = 0x10; /* 06 10 == TONE_CURVE_SIZE */
if ((ret = send_data(dev, endp_down, if ((ret = send_data(dev, endp_down,
cmdbuf, 6))) cmdbuf, 6)))
goto done; goto done;
/* Send the payload over */ /* Send the payload over */
if ((ret = send_data(dev, endp_down, if ((ret = send_data(dev, endp_down,
(uint8_t *) data, UPDATE_SIZE))) (uint8_t *) data, TONE_CURVE_SIZE)))
goto done; goto done;
/* get the response */ /* get the response */

View File

@ -688,18 +688,18 @@ static int kodak605_set_tonecurve(struct kodak605_ctx *ctx, char *fname)
uint8_t respbuf[16]; uint8_t respbuf[16];
int ret, num = 0; int ret, num = 0;
uint16_t *data = malloc(UPDATE_SIZE); uint16_t *data = malloc(TONE_CURVE_SIZE);
INFO("Set Tone Curve from '%s'\n", fname); INFO("Set Tone Curve from '%s'\n", fname);
/* Read in file */ /* Read in file */
if ((ret = dyesub_read_file(fname, data, UPDATE_SIZE, NULL))) { if ((ret = dyesub_read_file(fname, data, TONE_CURVE_SIZE, NULL))) {
ERROR("Failed to read Tone Curve file\n"); ERROR("Failed to read Tone Curve file\n");
goto done; goto done;
} }
/* Byteswap data to printer's format */ /* Byteswap data to printer's format */
for (ret = 0; ret < (UPDATE_SIZE/2) ; ret++) { for (ret = 0; ret < (TONE_CURVE_SIZE/2) ; ret++) {
data[ret] = cpu_to_le16(be16_to_cpu(data[ret])); data[ret] = cpu_to_le16(be16_to_cpu(data[ret]));
} }

View File

@ -44,6 +44,7 @@
#define BACKEND kodak6800_backend #define BACKEND kodak6800_backend
#include "backend_common.h" #include "backend_common.h"
#include "backend_shinko.h"
#define USB_VID_KODAK 0x040A #define USB_VID_KODAK 0x040A
#define USB_PID_KODAK_6800 0x4021 #define USB_PID_KODAK_6800 0x4021
@ -75,9 +76,9 @@ struct kodak68x0_status_readback {
uint8_t errtype; /* seen 0x00 or 0xd0 */ uint8_t errtype; /* seen 0x00 or 0xd0 */
uint8_t donor; /* Percentage, 0-100 */ uint8_t donor; /* Percentage, 0-100 */
uint16_t main_boot; /* Always 003 */ uint16_t main_boot; /* Always 003 */
uint16_t main_fw; /* seen 652, 656, 670, 671 (6850) and 232 (6800) */ uint16_t main_fw; /* seen 6xx/8xx (6850) and 2xx/3xx/4xx (6800) */
uint16_t dsp_boot; /* Always 001 */ uint16_t dsp_boot; /* Always 001 */
uint16_t dsp_fw; /* Seen 540, 541, 560 (6850) and 131 (6800) */ uint16_t dsp_fw; /* Seen 5xx (6850) and 1xx (6800) */
uint8_t b1_jobid; uint8_t b1_jobid;
uint8_t b2_jobid; uint8_t b2_jobid;
uint16_t b1_remain; /* Remaining prints in job */ uint16_t b1_remain; /* Remaining prints in job */
@ -89,111 +90,6 @@ struct kodak68x0_status_readback {
uint8_t curve_status; /* Always seems to be 0x00 */ uint8_t curve_status; /* Always seems to be 0x00 */
} __attribute__((packed)); } __attribute__((packed));
enum {
CMD_CODE_OK = 1,
CMD_CODE_BAD = 2,
};
enum {
STATUS_PRINTING = 1,
STATUS_IDLE = 2,
};
enum {
STATE_STATUS1_STANDBY = 1,
STATE_STATUS1_ERROR = 2,
STATE_STATUS1_WAIT = 3,
};
#define STATE_STANDBY_STATUS2 0x0
enum {
WAIT_STATUS2_INIT = 0,
WAIT_STATUS2_RIBBON = 1,
WAIT_STATUS2_THERMAL = 2,
WAIT_STATUS2_OPERATING = 3,
WAIT_STATUS2_BUSY = 4,
};
#define ERROR_STATUS2_CTRL_CIRCUIT (0x80000000)
#define ERROR_STATUS2_MECHANISM_CTRL (0x40000000)
#define ERROR_STATUS2_SENSOR (0x00002000)
#define ERROR_STATUS2_COVER_OPEN (0x00001000)
#define ERROR_STATUS2_TEMP_SENSOR (0x00000200)
#define ERROR_STATUS2_PAPER_JAM (0x00000100)
#define ERROR_STATUS2_PAPER_EMPTY (0x00000040)
#define ERROR_STATUS2_RIBBON_ERR (0x00000010)
enum {
CTRL_CIR_ERROR_EEPROM1 = 0x01,
CTRL_CIR_ERROR_EEPROM2 = 0x02,
CTRL_CIR_ERROR_DSP = 0x04,
CTRL_CIR_ERROR_CRC_MAIN = 0x06,
CTRL_CIR_ERROR_DL_MAIN = 0x07,
CTRL_CIR_ERROR_CRC_DSP = 0x08,
CTRL_CIR_ERROR_DL_DSP = 0x09,
CTRL_CIR_ERROR_ASIC = 0x0a,
CTRL_CIR_ERROR_DRAM = 0x0b,
CTRL_CIR_ERROR_DSPCOMM = 0x29,
};
enum {
MECH_ERROR_HEAD_UP = 0x01,
MECH_ERROR_HEAD_DOWN = 0x02,
MECH_ERROR_MAIN_PINCH_UP = 0x03,
MECH_ERROR_MAIN_PINCH_DOWN = 0x04,
MECH_ERROR_SUB_PINCH_UP = 0x05,
MECH_ERROR_SUB_PINCH_DOWN = 0x06,
MECH_ERROR_FEEDIN_PINCH_UP = 0x07,
MECH_ERROR_FEEDIN_PINCH_DOWN = 0x08,
MECH_ERROR_FEEDOUT_PINCH_UP = 0x09,
MECH_ERROR_FEEDOUT_PINCH_DOWN = 0x0a,
MECH_ERROR_CUTTER_LR = 0x0b,
MECH_ERROR_CUTTER_RL = 0x0c,
};
enum {
SENSOR_ERROR_CUTTER = 0x05,
SENSOR_ERROR_HEAD_DOWN = 0x09,
SENSOR_ERROR_HEAD_UP = 0x0a,
SENSOR_ERROR_MAIN_PINCH_DOWN = 0x0b,
SENSOR_ERROR_MAIN_PINCH_UP = 0x0c,
SENSOR_ERROR_FEED_PINCH_DOWN = 0x0d,
SENSOR_ERROR_FEED_PINCH_UP = 0x0e,
SENSOR_ERROR_EXIT_PINCH_DOWN = 0x0f,
SENSOR_ERROR_EXIT_PINCH_UP = 0x10,
SENSOR_ERROR_LEFT_CUTTER = 0x11,
SENSOR_ERROR_RIGHT_CUTTER = 0x12,
SENSOR_ERROR_CENTER_CUTTER = 0x13,
SENSOR_ERROR_UPPER_CUTTER = 0x14,
SENSOR_ERROR_PAPER_FEED_COVER = 0x15,
};
enum {
TEMP_SENSOR_ERROR_HEAD_HIGH = 0x01,
TEMP_SENSOR_ERROR_HEAD_LOW = 0x02,
TEMP_SENSOR_ERROR_ENV_HIGH = 0x03,
TEMP_SENSOR_ERROR_ENV_LOW = 0x04,
};
enum {
COVER_OPEN_ERROR_UPPER = 0x01,
COVER_OPEN_ERROR_LOWER = 0x02,
};
enum {
PAPER_EMPTY_ERROR = 0x00,
};
enum {
RIBBON_ERROR = 0x00,
};
enum {
CURVE_TABLE_STATUS_INITIAL = 0x00,
CURVE_TABLE_STATUS_USERSET = 0x01,
CURVE_TABLE_STATUS_CURRENT = 0x02,
};
struct kodak6800_printsize { struct kodak6800_printsize {
uint8_t hdr; /* Always 0x06 */ uint8_t hdr; /* Always 0x06 */
@ -425,153 +321,6 @@ static int kodak68x0_reset(struct kodak6800_ctx *ctx)
return 0; return 0;
} }
/* Structure dumps */
static char *kodak68x0_status_str(struct kodak68x0_status_readback *resp)
{
switch(resp->status1) {
case STATE_STATUS1_STANDBY:
return "Standby (Ready)";
case STATE_STATUS1_WAIT:
switch (be32_to_cpu(resp->status2)) {
case WAIT_STATUS2_INIT:
return "Wait (Initializing)";
case WAIT_STATUS2_RIBBON:
return "Wait (Ribbon Winding)";
case WAIT_STATUS2_THERMAL:
return "Wait (Thermal Protection)";
case WAIT_STATUS2_OPERATING:
return "Wait (Operating)";
case WAIT_STATUS2_BUSY:
return "Wait (Busy)";
default:
return "Wait (Unknown)";
}
case STATE_STATUS1_ERROR:
switch (be32_to_cpu(resp->status2)) {
case ERROR_STATUS2_CTRL_CIRCUIT:
switch (resp->errcode) {
case CTRL_CIR_ERROR_EEPROM1:
return "Error (EEPROM1)";
case CTRL_CIR_ERROR_EEPROM2:
return "Error (EEPROM2)";
case CTRL_CIR_ERROR_DSP:
return "Error (DSP)";
case CTRL_CIR_ERROR_CRC_MAIN:
return "Error (Main CRC)";
case CTRL_CIR_ERROR_DL_MAIN:
return "Error (Main Download)";
case CTRL_CIR_ERROR_CRC_DSP:
return "Error (DSP CRC)";
case CTRL_CIR_ERROR_DL_DSP:
return "Error (DSP Download)";
case CTRL_CIR_ERROR_ASIC:
return "Error (ASIC)";
case CTRL_CIR_ERROR_DRAM:
return "Error (DRAM)";
case CTRL_CIR_ERROR_DSPCOMM:
return "Error (DSP Communincation)";
default:
return "Error (Unknown Circuit)";
}
case ERROR_STATUS2_MECHANISM_CTRL:
switch (resp->errcode) {
case MECH_ERROR_HEAD_UP:
return "Error (Head Up Mechanism)";
case MECH_ERROR_HEAD_DOWN:
return "Error (Head Down Mechanism)";
case MECH_ERROR_MAIN_PINCH_UP:
return "Error (Main Pinch Up Mechanism)";
case MECH_ERROR_MAIN_PINCH_DOWN:
return "Error (Main Pinch Down Mechanism)";
case MECH_ERROR_SUB_PINCH_UP:
return "Error (Sub Pinch Up Mechanism)";
case MECH_ERROR_SUB_PINCH_DOWN:
return "Error (Sub Pinch Down Mechanism)";
case MECH_ERROR_FEEDIN_PINCH_UP:
return "Error (Feed-in Pinch Up Mechanism)";
case MECH_ERROR_FEEDIN_PINCH_DOWN:
return "Error (Feed-in Pinch Down Mechanism)";
case MECH_ERROR_FEEDOUT_PINCH_UP:
return "Error (Feed-out Pinch Up Mechanism)";
case MECH_ERROR_FEEDOUT_PINCH_DOWN:
return "Error (Feed-out Pinch Down Mechanism)";
case MECH_ERROR_CUTTER_LR:
return "Error (Left->Right Cutter)";
case MECH_ERROR_CUTTER_RL:
return "Error (Right->Left Cutter)";
default:
return "Error (Unknown Mechanism)";
}
case ERROR_STATUS2_SENSOR:
switch (resp->errcode) {
case SENSOR_ERROR_CUTTER:
return "Error (Cutter Sensor)";
case SENSOR_ERROR_HEAD_DOWN:
return "Error (Head Down Sensor)";
case SENSOR_ERROR_HEAD_UP:
return "Error (Head Up Sensor)";
case SENSOR_ERROR_MAIN_PINCH_DOWN:
return "Error (Main Pinch Down Sensor)";
case SENSOR_ERROR_MAIN_PINCH_UP:
return "Error (Main Pinch Up Sensor)";
case SENSOR_ERROR_FEED_PINCH_DOWN:
return "Error (Feed Pinch Down Sensor)";
case SENSOR_ERROR_FEED_PINCH_UP:
return "Error (Feed Pinch Up Sensor)";
case SENSOR_ERROR_EXIT_PINCH_DOWN:
return "Error (Exit Pinch Up Sensor)";
case SENSOR_ERROR_EXIT_PINCH_UP:
return "Error (Exit Pinch Up Sensor)";
case SENSOR_ERROR_LEFT_CUTTER:
return "Error (Left Cutter Sensor)";
case SENSOR_ERROR_RIGHT_CUTTER:
return "Error (Right Cutter Sensor)";
case SENSOR_ERROR_CENTER_CUTTER:
return "Error (Center Cutter Sensor)";
case SENSOR_ERROR_UPPER_CUTTER:
return "Error (Upper Cutter Sensor)";
case SENSOR_ERROR_PAPER_FEED_COVER:
return "Error (Paper Feed Cover)";
default:
return "Error (Unknown Sensor)";
}
case ERROR_STATUS2_COVER_OPEN:
switch (resp->errcode) {
case COVER_OPEN_ERROR_UPPER:
return "Error (Upper Cover Open)";
case COVER_OPEN_ERROR_LOWER:
return "Error (Lower Cover Open)";
default:
return "Error (Unknown Cover Open)";
}
case ERROR_STATUS2_TEMP_SENSOR:
switch (resp->errcode) {
case TEMP_SENSOR_ERROR_HEAD_HIGH:
return "Error (Head Temperature High)";
case TEMP_SENSOR_ERROR_HEAD_LOW:
return "Error (Head Temperature Low)";
case TEMP_SENSOR_ERROR_ENV_HIGH:
return "Error (Environmental Temperature High)";
case TEMP_SENSOR_ERROR_ENV_LOW:
return "Error (Environmental Temperature Low)";
default:
return "Error (Unknown Temperature)";
}
case ERROR_STATUS2_PAPER_JAM:
return "Error (Paper Jam)";
case ERROR_STATUS2_PAPER_EMPTY:
return "Error (Paper Empty)";
case ERROR_STATUS2_RIBBON_ERR:
return "Error (Ribbon)";
default:
return "Error (Unknown)";
}
default:
return "Unknown!";
}
}
static void kodak68x0_dump_status(struct kodak6800_ctx *ctx, struct kodak68x0_status_readback *status) static void kodak68x0_dump_status(struct kodak6800_ctx *ctx, struct kodak68x0_status_readback *status)
{ {
char *detail; char *detail;
@ -590,8 +339,8 @@ static void kodak68x0_dump_status(struct kodak6800_ctx *ctx, struct kodak68x0_st
INFO("Printer Status : %s\n", detail); INFO("Printer Status : %s\n", detail);
INFO("Printer State : %s # %02x %08x %02x\n", INFO("Printer State : %s # %02x %08x %02x\n",
kodak68x0_status_str(status), sinfonia_1x45_status_str(status->status1, status->status2, status->errcode),
status->status1, be32_to_cpu(status->status2), status->errcode); status->status1, status->status2, status->errcode);
INFO("Bank 1 ID: %u\n", status->b1_jobid); INFO("Bank 1 ID: %u\n", status->b1_jobid);
INFO("\tPrints: %d/%d complete\n", INFO("\tPrints: %d/%d complete\n",
@ -676,11 +425,12 @@ static int kodak6800_get_status(struct kodak6800_ctx *ctx,
return -99; return -99;
} }
/* Byteswap important stuff */
status->status2 = be32_to_cpu(status->status2);
return 0; return 0;
} }
#define UPDATE_SIZE 1536
static int kodak6800_get_tonecurve(struct kodak6800_ctx *ctx, char *fname) static int kodak6800_get_tonecurve(struct kodak6800_ctx *ctx, char *fname)
{ {
uint8_t cmdbuf[16]; uint8_t cmdbuf[16];
@ -688,7 +438,7 @@ static int kodak6800_get_tonecurve(struct kodak6800_ctx *ctx, char *fname)
int ret, num = 0; int ret, num = 0;
int i; int i;
uint16_t *data = malloc(UPDATE_SIZE); uint16_t *data = malloc(TONE_CURVE_SIZE);
if (!data) { if (!data) {
ERROR("Memory Allocation Failure\n"); ERROR("Memory Allocation Failure\n");
return -1; return -1;
@ -786,7 +536,7 @@ static int kodak6800_set_tonecurve(struct kodak6800_ctx *ctx, char *fname)
int ret, num = 0; int ret, num = 0;
int remain; int remain;
uint16_t *data = malloc(UPDATE_SIZE); uint16_t *data = malloc(TONE_CURVE_SIZE);
uint8_t *ptr; uint8_t *ptr;
if (!data) { if (!data) {
@ -797,13 +547,13 @@ static int kodak6800_set_tonecurve(struct kodak6800_ctx *ctx, char *fname)
INFO("Set Tone Curve from '%s'\n", fname); INFO("Set Tone Curve from '%s'\n", fname);
/* Read in file */ /* Read in file */
if ((ret = dyesub_read_file(fname, data, UPDATE_SIZE, NULL))) { if ((ret = dyesub_read_file(fname, data, TONE_CURVE_SIZE, NULL))) {
ERROR("Failed to read Tone Curve file\n"); ERROR("Failed to read Tone Curve file\n");
goto done; goto done;
} }
/* Byteswap data to printer's format */ /* Byteswap data to printer's format */
for (ret = 0; ret < (UPDATE_SIZE)/2 ; ret++) { for (ret = 0; ret < (TONE_CURVE_SIZE)/2 ; ret++) {
data[ret] = cpu_to_le16(be16_to_cpu(data[ret])); data[ret] = cpu_to_le16(be16_to_cpu(data[ret]));
} }
@ -844,7 +594,7 @@ static int kodak6800_set_tonecurve(struct kodak6800_ctx *ctx, char *fname)
} }
ptr = (uint8_t*) data; ptr = (uint8_t*) data;
remain = UPDATE_SIZE; remain = TONE_CURVE_SIZE;
while (remain > 0) { while (remain > 0) {
int count = remain > 63 ? 63 : remain; int count = remain > 63 ? 63 : remain;
@ -1256,8 +1006,8 @@ static int kodak6800_main_loop(void *vctx, const void *vjob) {
if (ctx->sts.status1 == STATE_STATUS1_ERROR) { if (ctx->sts.status1 == STATE_STATUS1_ERROR) {
INFO("Printer State: %s # %02x %08x %02x\n", INFO("Printer State: %s # %02x %08x %02x\n",
kodak68x0_status_str(&ctx->sts), sinfonia_1x45_status_str(ctx->sts.status1, ctx->sts.status2, ctx->sts.errcode),
ctx->sts.status1, be32_to_cpu(ctx->sts.status2), ctx->sts.errcode); ctx->sts.status1, ctx->sts.status2, ctx->sts.errcode);
return CUPS_BACKEND_FAILED; return CUPS_BACKEND_FAILED;
} }
@ -1318,8 +1068,8 @@ static int kodak6800_main_loop(void *vctx, const void *vjob) {
if (ctx->sts.status1 == STATE_STATUS1_ERROR) { if (ctx->sts.status1 == STATE_STATUS1_ERROR) {
INFO("Printer State: %s # %02x %08x %02x\n", INFO("Printer State: %s # %02x %08x %02x\n",
kodak68x0_status_str(&ctx->sts), sinfonia_1x45_status_str(ctx->sts.status1, ctx->sts.status2, ctx->sts.errcode),
ctx->sts.status1, be32_to_cpu(ctx->sts.status2), ctx->sts.errcode); ctx->sts.status1, ctx->sts.status2, ctx->sts.errcode);
return CUPS_BACKEND_FAILED; return CUPS_BACKEND_FAILED;
} }

View File

@ -216,3 +216,160 @@ char *sinfonia_error_str(uint8_t v) {
return "Unknown"; return "Unknown";
} }
} }
char *media_types(uint8_t v) {
switch (v) {
case MEDIA_TYPE_UNKNOWN:
return "Unknown";
case MEDIA_TYPE_PAPER:
return "Paper";
default:
return "Unknown";
}
}
/* Below are for S1145 (EK68xx) and S1245 only! */
char *sinfonia_1x45_status_str(uint8_t status1, uint32_t status2, uint8_t error)
{
switch(status1) {
case STATE_STATUS1_STANDBY:
return "Standby (Ready)";
case STATE_STATUS1_WAIT:
switch (status2) {
case WAIT_STATUS2_INIT:
return "Wait (Initializing)";
case WAIT_STATUS2_RIBBON:
return "Wait (Ribbon Winding)";
case WAIT_STATUS2_THERMAL:
return "Wait (Thermal Protection)";
case WAIT_STATUS2_OPERATING:
return "Wait (Operating)";
case WAIT_STATUS2_BUSY:
return "Wait (Busy)";
default:
return "Wait (Unknown)";
}
case STATE_STATUS1_ERROR:
switch (status2) {
case ERROR_STATUS2_CTRL_CIRCUIT:
switch (error) {
case CTRL_CIR_ERROR_EEPROM1:
return "Error (EEPROM1)";
case CTRL_CIR_ERROR_EEPROM2:
return "Error (EEPROM2)";
case CTRL_CIR_ERROR_DSP:
return "Error (DSP)";
case CTRL_CIR_ERROR_CRC_MAIN:
return "Error (Main CRC)";
case CTRL_CIR_ERROR_DL_MAIN:
return "Error (Main Download)";
case CTRL_CIR_ERROR_CRC_DSP:
return "Error (DSP CRC)";
case CTRL_CIR_ERROR_DL_DSP:
return "Error (DSP Download)";
case CTRL_CIR_ERROR_ASIC:
return "Error (ASIC)";
case CTRL_CIR_ERROR_DRAM:
return "Error (DRAM)";
case CTRL_CIR_ERROR_DSPCOMM:
return "Error (DSP Communincation)";
default:
return "Error (Unknown Circuit)";
}
case ERROR_STATUS2_MECHANISM_CTRL:
switch (error) {
case MECH_ERROR_HEAD_UP:
return "Error (Head Up Mechanism)";
case MECH_ERROR_HEAD_DOWN:
return "Error (Head Down Mechanism)";
case MECH_ERROR_MAIN_PINCH_UP:
return "Error (Main Pinch Up Mechanism)";
case MECH_ERROR_MAIN_PINCH_DOWN:
return "Error (Main Pinch Down Mechanism)";
case MECH_ERROR_SUB_PINCH_UP:
return "Error (Sub Pinch Up Mechanism)";
case MECH_ERROR_SUB_PINCH_DOWN:
return "Error (Sub Pinch Down Mechanism)";
case MECH_ERROR_FEEDIN_PINCH_UP:
return "Error (Feed-in Pinch Up Mechanism)";
case MECH_ERROR_FEEDIN_PINCH_DOWN:
return "Error (Feed-in Pinch Down Mechanism)";
case MECH_ERROR_FEEDOUT_PINCH_UP:
return "Error (Feed-out Pinch Up Mechanism)";
case MECH_ERROR_FEEDOUT_PINCH_DOWN:
return "Error (Feed-out Pinch Down Mechanism)";
case MECH_ERROR_CUTTER_LR:
return "Error (Left->Right Cutter)";
case MECH_ERROR_CUTTER_RL:
return "Error (Right->Left Cutter)";
default:
return "Error (Unknown Mechanism)";
}
case ERROR_STATUS2_SENSOR:
switch (error) {
case SENSOR_ERROR_CUTTER:
return "Error (Cutter Sensor)";
case SENSOR_ERROR_HEAD_DOWN:
return "Error (Head Down Sensor)";
case SENSOR_ERROR_HEAD_UP:
return "Error (Head Up Sensor)";
case SENSOR_ERROR_MAIN_PINCH_DOWN:
return "Error (Main Pinch Down Sensor)";
case SENSOR_ERROR_MAIN_PINCH_UP:
return "Error (Main Pinch Up Sensor)";
case SENSOR_ERROR_FEED_PINCH_DOWN:
return "Error (Feed Pinch Down Sensor)";
case SENSOR_ERROR_FEED_PINCH_UP:
return "Error (Feed Pinch Up Sensor)";
case SENSOR_ERROR_EXIT_PINCH_DOWN:
return "Error (Exit Pinch Up Sensor)";
case SENSOR_ERROR_EXIT_PINCH_UP:
return "Error (Exit Pinch Up Sensor)";
case SENSOR_ERROR_LEFT_CUTTER:
return "Error (Left Cutter Sensor)";
case SENSOR_ERROR_RIGHT_CUTTER:
return "Error (Right Cutter Sensor)";
case SENSOR_ERROR_CENTER_CUTTER:
return "Error (Center Cutter Sensor)";
case SENSOR_ERROR_UPPER_CUTTER:
return "Error (Upper Cutter Sensor)";
case SENSOR_ERROR_PAPER_FEED_COVER:
return "Error (Paper Feed Cover)";
default:
return "Error (Unknown Sensor)";
}
case ERROR_STATUS2_COVER_OPEN:
switch (error) {
case COVER_OPEN_ERROR_UPPER:
return "Error (Upper Cover Open)";
case COVER_OPEN_ERROR_LOWER:
return "Error (Lower Cover Open)";
default:
return "Error (Unknown Cover Open)";
}
case ERROR_STATUS2_TEMP_SENSOR:
switch (error) {
case TEMP_SENSOR_ERROR_HEAD_HIGH:
return "Error (Head Temperature High)";
case TEMP_SENSOR_ERROR_HEAD_LOW:
return "Error (Head Temperature Low)";
case TEMP_SENSOR_ERROR_ENV_HIGH:
return "Error (Environmental Temperature High)";
case TEMP_SENSOR_ERROR_ENV_LOW:
return "Error (Environmental Temperature Low)";
default:
return "Error (Unknown Temperature)";
}
case ERROR_STATUS2_PAPER_JAM:
return "Error (Paper Jam)";
case ERROR_STATUS2_PAPER_EMPTY:
return "Error (Paper Empty)";
case ERROR_STATUS2_RIBBON_ERR:
return "Error (Ribbon)";
default:
return "Error (Unknown)";
}
default:
return "Unknown!";
}
}

View File

@ -77,7 +77,7 @@ char *sinfonia_bank_statuses(uint8_t v);
each is 256 entries of 11-bit data padded to 16-bits. each is 256 entries of 11-bit data padded to 16-bits.
Printer expects LE data. We use BE data on disk. Printer expects LE data. We use BE data on disk.
*/ */
#define UPDATE_SIZE 0x600 #define TONE_CURVE_SIZE 0x600
char *sinfonia_update_targets (uint8_t v); char *sinfonia_update_targets (uint8_t v);
#define TONECURVE_INIT 0x00 #define TONECURVE_INIT 0x00
@ -102,3 +102,121 @@ struct sinfonia_error_item {
#define ERROR_BUFFER_FULL 0x21 #define ERROR_BUFFER_FULL 0x21
char *sinfonia_error_str(uint8_t v); char *sinfonia_error_str(uint8_t v);
enum {
MEDIA_TYPE_UNKNOWN = 0x00,
MEDIA_TYPE_PAPER = 0x01,
};
char *media_types(uint8_t v);
/* ********** Below are for the old S1145 (EK68xx) and S1245 only! */
enum {
CMD_CODE_OK = 1,
CMD_CODE_BAD = 2,
};
enum {
STATUS_PRINTING = 1,
STATUS_IDLE = 2,
};
enum {
STATE_STATUS1_STANDBY = 1,
STATE_STATUS1_ERROR = 2,
STATE_STATUS1_WAIT = 3,
};
#define STATE_STANDBY_STATUS2 0x0
enum {
WAIT_STATUS2_INIT = 0,
WAIT_STATUS2_RIBBON = 1,
WAIT_STATUS2_THERMAL = 2,
WAIT_STATUS2_OPERATING = 3,
WAIT_STATUS2_BUSY = 4,
};
#define ERROR_STATUS2_CTRL_CIRCUIT (0x80000000)
#define ERROR_STATUS2_MECHANISM_CTRL (0x40000000)
#define ERROR_STATUS2_SENSOR (0x00002000)
#define ERROR_STATUS2_COVER_OPEN (0x00001000)
#define ERROR_STATUS2_TEMP_SENSOR (0x00000200)
#define ERROR_STATUS2_PAPER_JAM (0x00000100)
#define ERROR_STATUS2_PAPER_EMPTY (0x00000040)
#define ERROR_STATUS2_RIBBON_ERR (0x00000010)
enum {
CTRL_CIR_ERROR_EEPROM1 = 0x01,
CTRL_CIR_ERROR_EEPROM2 = 0x02,
CTRL_CIR_ERROR_DSP = 0x04,
CTRL_CIR_ERROR_CRC_MAIN = 0x06,
CTRL_CIR_ERROR_DL_MAIN = 0x07,
CTRL_CIR_ERROR_CRC_DSP = 0x08,
CTRL_CIR_ERROR_DL_DSP = 0x09,
CTRL_CIR_ERROR_ASIC = 0x0a,
CTRL_CIR_ERROR_DRAM = 0x0b,
CTRL_CIR_ERROR_DSPCOMM = 0x29,
};
enum {
MECH_ERROR_HEAD_UP = 0x01,
MECH_ERROR_HEAD_DOWN = 0x02,
MECH_ERROR_MAIN_PINCH_UP = 0x03,
MECH_ERROR_MAIN_PINCH_DOWN = 0x04,
MECH_ERROR_SUB_PINCH_UP = 0x05,
MECH_ERROR_SUB_PINCH_DOWN = 0x06,
MECH_ERROR_FEEDIN_PINCH_UP = 0x07,
MECH_ERROR_FEEDIN_PINCH_DOWN = 0x08,
MECH_ERROR_FEEDOUT_PINCH_UP = 0x09,
MECH_ERROR_FEEDOUT_PINCH_DOWN = 0x0a,
MECH_ERROR_CUTTER_LR = 0x0b,
MECH_ERROR_CUTTER_RL = 0x0c,
};
enum {
SENSOR_ERROR_CUTTER = 0x05,
SENSOR_ERROR_HEAD_DOWN = 0x09,
SENSOR_ERROR_HEAD_UP = 0x0a,
SENSOR_ERROR_MAIN_PINCH_DOWN = 0x0b,
SENSOR_ERROR_MAIN_PINCH_UP = 0x0c,
SENSOR_ERROR_FEED_PINCH_DOWN = 0x0d,
SENSOR_ERROR_FEED_PINCH_UP = 0x0e,
SENSOR_ERROR_EXIT_PINCH_DOWN = 0x0f,
SENSOR_ERROR_EXIT_PINCH_UP = 0x10,
SENSOR_ERROR_LEFT_CUTTER = 0x11,
SENSOR_ERROR_RIGHT_CUTTER = 0x12,
SENSOR_ERROR_CENTER_CUTTER = 0x13,
SENSOR_ERROR_UPPER_CUTTER = 0x14,
SENSOR_ERROR_PAPER_FEED_COVER = 0x15,
};
enum {
TEMP_SENSOR_ERROR_HEAD_HIGH = 0x01,
TEMP_SENSOR_ERROR_HEAD_LOW = 0x02,
TEMP_SENSOR_ERROR_ENV_HIGH = 0x03,
TEMP_SENSOR_ERROR_ENV_LOW = 0x04,
};
enum {
COVER_OPEN_ERROR_UPPER = 0x01,
COVER_OPEN_ERROR_LOWER = 0x02,
};
enum {
PAPER_EMPTY_ERROR = 0x00,
};
enum {
RIBBON_ERROR = 0x00,
};
enum {
CURVE_TABLE_STATUS_INITIAL = 0x00,
CURVE_TABLE_STATUS_USERSET = 0x01,
CURVE_TABLE_STATUS_CURRENT = 0x02,
};
char *sinfonia_1x45_status_str(uint8_t status1, uint32_t status2, uint8_t error);

View File

@ -170,113 +170,6 @@ struct shinkos1245_resp_status {
uint8_t curve_status; uint8_t curve_status;
} __attribute__((packed)); } __attribute__((packed));
enum {
CMD_CODE_OK = 1,
CMD_CODE_BAD = 2,
};
enum {
STATUS_PRINTING = 1,
STATUS_IDLE = 2,
};
enum {
STATE_STATUS1_STANDBY = 1,
STATE_STATUS1_ERROR = 2,
STATE_STATUS1_WAIT = 3,
};
#define STATE_STANDBY_STATUS2 0x0
enum {
WAIT_STATUS2_INIT = 0,
WAIT_STATUS2_RIBBON = 1,
WAIT_STATUS2_THERMAL = 2,
WAIT_STATUS2_OPERATING = 3,
WAIT_STATUS2_BUSY = 4,
};
#define ERROR_STATUS2_CTRL_CIRCUIT (0x80000000)
#define ERROR_STATUS2_MECHANISM_CTRL (0x40000000)
#define ERROR_STATUS2_SENSOR (0x00002000)
#define ERROR_STATUS2_COVER_OPEN (0x00001000)
#define ERROR_STATUS2_TEMP_SENSOR (0x00000200)
#define ERROR_STATUS2_PAPER_JAM (0x00000100)
#define ERROR_STATUS2_PAPER_EMPTY (0x00000040)
#define ERROR_STATUS2_RIBBON_ERR (0x00000010)
enum {
CTRL_CIR_ERROR_EEPROM1 = 0x01,
CTRL_CIR_ERROR_EEPROM2 = 0x02,
CTRL_CIR_ERROR_DSP = 0x04,
CTRL_CIR_ERROR_CRC_MAIN = 0x06,
CTRL_CIR_ERROR_DL_MAIN = 0x07,
CTRL_CIR_ERROR_CRC_DSP = 0x08,
CTRL_CIR_ERROR_DL_DSP = 0x09,
CTRL_CIR_ERROR_ASIC = 0x0a,
CTRL_CIR_ERROR_DRAM = 0x0b,
CTRL_CIR_ERROR_DSPCOMM = 0x29,
};
enum {
MECH_ERROR_HEAD_UP = 0x01,
MECH_ERROR_HEAD_DOWN = 0x02,
MECH_ERROR_MAIN_PINCH_UP = 0x03,
MECH_ERROR_MAIN_PINCH_DOWN = 0x04,
MECH_ERROR_SUB_PINCH_UP = 0x05,
MECH_ERROR_SUB_PINCH_DOWN = 0x06,
MECH_ERROR_FEEDIN_PINCH_UP = 0x07,
MECH_ERROR_FEEDIN_PINCH_DOWN = 0x08,
MECH_ERROR_FEEDOUT_PINCH_UP = 0x09,
MECH_ERROR_FEEDOUT_PINCH_DOWN = 0x0a,
MECH_ERROR_CUTTER_LR = 0x0b,
MECH_ERROR_CUTTER_RL = 0x0c,
};
enum {
SENSOR_ERROR_CUTTER = 0x05,
SENSOR_ERROR_HEAD_DOWN = 0x09,
SENSOR_ERROR_HEAD_UP = 0x0a,
SENSOR_ERROR_MAIN_PINCH_DOWN = 0x0b,
SENSOR_ERROR_MAIN_PINCH_UP = 0x0c,
SENSOR_ERROR_FEED_PINCH_DOWN = 0x0d,
SENSOR_ERROR_FEED_PINCH_UP = 0x0e,
SENSOR_ERROR_EXIT_PINCH_DOWN = 0x0f,
SENSOR_ERROR_EXIT_PINCH_UP = 0x10,
SENSOR_ERROR_LEFT_CUTTER = 0x11,
SENSOR_ERROR_RIGHT_CUTTER = 0x12,
SENSOR_ERROR_CENTER_CUTTER = 0x13,
SENSOR_ERROR_UPPER_CUTTER = 0x14,
SENSOR_ERROR_PAPER_FEED_COVER = 0x15,
};
enum {
TEMP_SENSOR_ERROR_HEAD_HIGH = 0x01,
TEMP_SENSOR_ERROR_HEAD_LOW = 0x02,
TEMP_SENSOR_ERROR_ENV_HIGH = 0x03,
TEMP_SENSOR_ERROR_ENV_LOW = 0x04,
};
enum {
COVER_OPEN_ERROR_UPPER = 0x01,
COVER_OPEN_ERROR_LOWER = 0x02,
};
enum {
PAPER_EMPTY_ERROR = 0x00,
};
enum {
RIBBON_ERROR = 0x00,
};
enum {
CURVE_TABLE_STATUS_INITIAL = 0x00,
CURVE_TABLE_STATUS_USERSET = 0x01,
CURVE_TABLE_STATUS_CURRENT = 0x02,
};
/* Query media info */ /* Query media info */
struct shinkos1245_cmd_getmedia { struct shinkos1245_cmd_getmedia {
struct shinkos1245_cmd_hdr hdr; struct shinkos1245_cmd_hdr hdr;
@ -302,10 +195,6 @@ struct shinkos1245_resp_media {
struct shinkos1245_mediadesc data[NUM_MEDIAS]; struct shinkos1245_mediadesc data[NUM_MEDIAS];
} __attribute__((packed)); } __attribute__((packed));
enum {
MEDIA_TYPE_UNKNOWN = 0x00,
MEDIA_TYPE_PAPER = 0x01,
};
enum { enum {
PRINT_TYPE_STANDARD = 0x00, PRINT_TYPE_STANDARD = 0x00,
@ -363,7 +252,6 @@ enum {
PARAM_TABLE_FINE = 2, PARAM_TABLE_FINE = 2,
}; };
#define TONE_CURVE_SIZE 1536
#define TONE_CURVE_DATA_BLOCK_SIZE 64 #define TONE_CURVE_DATA_BLOCK_SIZE 64
/* Query Model information */ /* Query Model information */
@ -488,6 +376,9 @@ static int shinkos1245_get_status(struct shinkos1245_ctx *ctx,
return -99; return -99;
} }
/* Byteswap important stuff */
resp->state.status2 = be32_to_cpu(resp->state.status2);
return 0; return 0;
} }
@ -692,153 +583,6 @@ static int shinkos1245_get_matte(struct shinkos1245_ctx *ctx,
return 0; return 0;
} }
/* Structure dumps */
static char *shinkos1245_status_str(struct shinkos1245_resp_status *resp)
{
switch(resp->state.status1) {
case STATE_STATUS1_STANDBY:
return "Standby (Ready)";
case STATE_STATUS1_WAIT:
switch (resp->state.status2) {
case WAIT_STATUS2_INIT:
return "Wait (Initializing)";
case WAIT_STATUS2_RIBBON:
return "Wait (Ribbon Winding)";
case WAIT_STATUS2_THERMAL:
return "Wait (Thermal Protection)";
case WAIT_STATUS2_OPERATING:
return "Wait (Operating)";
case WAIT_STATUS2_BUSY:
return "Wait (Busy)";
default:
return "Wait (Unknown)";
}
case STATE_STATUS1_ERROR:
switch (resp->state.status2) {
case ERROR_STATUS2_CTRL_CIRCUIT:
switch (resp->state.error) {
case CTRL_CIR_ERROR_EEPROM1:
return "Error (EEPROM1)";
case CTRL_CIR_ERROR_EEPROM2:
return "Error (EEPROM2)";
case CTRL_CIR_ERROR_DSP:
return "Error (DSP)";
case CTRL_CIR_ERROR_CRC_MAIN:
return "Error (Main CRC)";
case CTRL_CIR_ERROR_DL_MAIN:
return "Error (Main Download)";
case CTRL_CIR_ERROR_CRC_DSP:
return "Error (DSP CRC)";
case CTRL_CIR_ERROR_DL_DSP:
return "Error (DSP Download)";
case CTRL_CIR_ERROR_ASIC:
return "Error (ASIC)";
case CTRL_CIR_ERROR_DRAM:
return "Error (DRAM)";
case CTRL_CIR_ERROR_DSPCOMM:
return "Error (DSP Communincation)";
default:
return "Error (Unknown Circuit)";
}
case ERROR_STATUS2_MECHANISM_CTRL:
switch (resp->state.error) {
case MECH_ERROR_HEAD_UP:
return "Error (Head Up Mechanism)";
case MECH_ERROR_HEAD_DOWN:
return "Error (Head Down Mechanism)";
case MECH_ERROR_MAIN_PINCH_UP:
return "Error (Main Pinch Up Mechanism)";
case MECH_ERROR_MAIN_PINCH_DOWN:
return "Error (Main Pinch Down Mechanism)";
case MECH_ERROR_SUB_PINCH_UP:
return "Error (Sub Pinch Up Mechanism)";
case MECH_ERROR_SUB_PINCH_DOWN:
return "Error (Sub Pinch Down Mechanism)";
case MECH_ERROR_FEEDIN_PINCH_UP:
return "Error (Feed-in Pinch Up Mechanism)";
case MECH_ERROR_FEEDIN_PINCH_DOWN:
return "Error (Feed-in Pinch Down Mechanism)";
case MECH_ERROR_FEEDOUT_PINCH_UP:
return "Error (Feed-out Pinch Up Mechanism)";
case MECH_ERROR_FEEDOUT_PINCH_DOWN:
return "Error (Feed-out Pinch Down Mechanism)";
case MECH_ERROR_CUTTER_LR:
return "Error (Left->Right Cutter)";
case MECH_ERROR_CUTTER_RL:
return "Error (Right->Left Cutter)";
default:
return "Error (Unknown Mechanism)";
}
case ERROR_STATUS2_SENSOR:
switch (resp->state.error) {
case SENSOR_ERROR_CUTTER:
return "Error (Cutter Sensor)";
case SENSOR_ERROR_HEAD_DOWN:
return "Error (Head Down Sensor)";
case SENSOR_ERROR_HEAD_UP:
return "Error (Head Up Sensor)";
case SENSOR_ERROR_MAIN_PINCH_DOWN:
return "Error (Main Pinch Down Sensor)";
case SENSOR_ERROR_MAIN_PINCH_UP:
return "Error (Main Pinch Up Sensor)";
case SENSOR_ERROR_FEED_PINCH_DOWN:
return "Error (Feed Pinch Down Sensor)";
case SENSOR_ERROR_FEED_PINCH_UP:
return "Error (Feed Pinch Up Sensor)";
case SENSOR_ERROR_EXIT_PINCH_DOWN:
return "Error (Exit Pinch Up Sensor)";
case SENSOR_ERROR_EXIT_PINCH_UP:
return "Error (Exit Pinch Up Sensor)";
case SENSOR_ERROR_LEFT_CUTTER:
return "Error (Left Cutter Sensor)";
case SENSOR_ERROR_RIGHT_CUTTER:
return "Error (Right Cutter Sensor)";
case SENSOR_ERROR_CENTER_CUTTER:
return "Error (Center Cutter Sensor)";
case SENSOR_ERROR_UPPER_CUTTER:
return "Error (Upper Cutter Sensor)";
case SENSOR_ERROR_PAPER_FEED_COVER:
return "Error (Paper Feed Cover)";
default:
return "Error (Unknown Sensor)";
}
case ERROR_STATUS2_COVER_OPEN:
switch (resp->state.error) {
case COVER_OPEN_ERROR_UPPER:
return "Error (Upper Cover Open)";
case COVER_OPEN_ERROR_LOWER:
return "Error (Lower Cover Open)";
default:
return "Error (Unknown Cover Open)";
}
case ERROR_STATUS2_TEMP_SENSOR:
switch (resp->state.error) {
case TEMP_SENSOR_ERROR_HEAD_HIGH:
return "Error (Head Temperature High)";
case TEMP_SENSOR_ERROR_HEAD_LOW:
return "Error (Head Temperature Low)";
case TEMP_SENSOR_ERROR_ENV_HIGH:
return "Error (Environmental Temperature High)";
case TEMP_SENSOR_ERROR_ENV_LOW:
return "Error (Environmental Temperature Low)";
default:
return "Error (Unknown Temperature)";
}
case ERROR_STATUS2_PAPER_JAM:
return "Error (Paper Jam)";
case ERROR_STATUS2_PAPER_EMPTY:
return "Error (Paper Empty)";
case ERROR_STATUS2_RIBBON_ERR:
return "Error (Ribbon)";
default:
return "Error (Unknown)";
}
default:
return "Unknown!";
}
}
static char* shinkos1245_tonecurves(int type, int table) static char* shinkos1245_tonecurves(int type, int table)
{ {
switch (type) { switch (type) {
@ -892,10 +636,8 @@ static void shinkos1245_dump_status(struct shinkos1245_ctx *ctx,
INFO("Printer Status: %s\n", detail); INFO("Printer Status: %s\n", detail);
/* Byteswap */ /* Byteswap */
sts->state.status2 = be32_to_cpu(sts->state.status2);
INFO("Printer State: %s # %02x %08x %02x\n", INFO("Printer State: %s # %02x %08x %02x\n",
shinkos1245_status_str(sts), sinfonia_1x45_status_str(sts->state.status1, sts->state.status2, sts->state.error),
sts->state.status1, sts->state.status2, sts->state.error); sts->state.status1, sts->state.status2, sts->state.error);
INFO("Counters:\n"); INFO("Counters:\n");
INFO("\tLifetime : %u\n", be32_to_cpu(sts->counters.lifetime)); INFO("\tLifetime : %u\n", be32_to_cpu(sts->counters.lifetime));
@ -1426,7 +1168,7 @@ top:
#if 0 // XXX is this necessary #if 0 // XXX is this necessary
if (status1.state.status1 == STATE_STATUS1_WAIT) { if (status1.state.status1 == STATE_STATUS1_WAIT) {
INFO("Printer busy: %s\n", INFO("Printer busy: %s\n",
shinkos1245_status_str(&status1)); sinfonia_1x45_status_str(status1.state.status1, status1.state.status2, status1.state.error));
break; break;
} }
#endif #endif
@ -1543,7 +1285,7 @@ printer_error:
status1.state.status2 = be32_to_cpu(status1.state.status2); status1.state.status2 = be32_to_cpu(status1.state.status2);
ERROR("Printer Error: %s # %02x %08x %02x\n", ERROR("Printer Error: %s # %02x %08x %02x\n",
shinkos1245_status_str(&status1), sinfonia_1x45_status_str(status1.state.status1, status1.state.status2, status1.state.error),
status1.state.status1, status1.state.status2, status1.state.error); status1.state.status1, status1.state.status2, status1.state.error);
return CUPS_BACKEND_FAILED; return CUPS_BACKEND_FAILED;

View File

@ -320,7 +320,7 @@ struct s2145_update_cmd {
uint32_t size; uint32_t size;
} __attribute__((packed)); } __attribute__((packed));
#define UPDATE_SIZE 0x600 #define TONE_CURVE_SIZE 0x600
struct s2145_setunique_cmd { struct s2145_setunique_cmd {
struct s2145_cmd_hdr hdr; struct s2145_cmd_hdr hdr;
@ -649,20 +649,6 @@ struct s2145_mediainfo_item {
uint8_t reserved[3]; uint8_t reserved[3];
} __attribute__((packed)); } __attribute__((packed));
#define MEDIA_TYPE_UNKNOWN 0x00
#define MEDIA_TYPE_PAPER 0x01
static char *media_types(uint8_t v) {
switch (v) {
case MEDIA_TYPE_UNKNOWN:
return "Unknown";
case MEDIA_TYPE_PAPER:
return "Paper";
default:
return "Unknown";
}
}
struct s2145_mediainfo_resp { struct s2145_mediainfo_resp {
struct s2145_status_hdr hdr; struct s2145_status_hdr hdr;
uint8_t count; uint8_t count;
@ -888,11 +874,10 @@ static void dump_mediainfo(struct s2145_mediainfo_resp *resp)
INFO("Supported Media Information: %u entries:\n", resp->count); INFO("Supported Media Information: %u entries:\n", resp->count);
for (i = 0 ; i < resp->count ; i++) { for (i = 0 ; i < resp->count ; i++) {
INFO(" %02d: C 0x%02x (%s), %04ux%04u, M 0x%02x (%s), P 0x%02x (%s)\n", i, INFO(" %02d: C 0x%02x (%s), %04ux%04u, P 0x%02x (%s)\n", i,
resp->items[i].code, print_sizes(resp->items[i].code), resp->items[i].code, print_sizes(resp->items[i].code),
resp->items[i].columns, resp->items[i].columns,
resp->items[i].rows, resp->items[i].rows,
resp->items[i].media_type, media_types(resp->items[i].media_type),
resp->items[i].print_method, print_methods(resp->items[i].print_method)); resp->items[i].print_method, print_methods(resp->items[i].print_method));
} }
} }
@ -1049,7 +1034,7 @@ static int get_tonecurve(struct shinkos2145_ctx *ctx, int type, char *fname)
int ret, num = 0; int ret, num = 0;
uint8_t *data; uint8_t *data;
uint16_t curves[UPDATE_SIZE] = { 0 } ; uint16_t curves[TONE_CURVE_SIZE] = { 0 } ;
int i,j; int i,j;
@ -1103,11 +1088,11 @@ static int get_tonecurve(struct shinkos2145_ctx *ctx, int type, char *fname)
goto done; goto done;
} }
for (i = 0 ; i < UPDATE_SIZE; i++) { for (i = 0 ; i < TONE_CURVE_SIZE; i++) {
/* Byteswap appropriately */ /* Byteswap appropriately */
curves[i] = cpu_to_be16(le16_to_cpu(curves[i])); curves[i] = cpu_to_be16(le16_to_cpu(curves[i]));
} }
ret = write(tc_fd, curves, UPDATE_SIZE * sizeof(uint16_t)); ret = write(tc_fd, curves, TONE_CURVE_SIZE * sizeof(uint16_t));
if (ret < 0) if (ret < 0)
ERROR("Can't write curve file\n"); ERROR("Can't write curve file\n");
else else
@ -1130,35 +1115,35 @@ static int set_tonecurve(struct shinkos2145_ctx *ctx, int target, char *fname)
INFO("Set %s Tone Curve from '%s'\n", sinfonia_update_targets(target), fname); INFO("Set %s Tone Curve from '%s'\n", sinfonia_update_targets(target), fname);
uint16_t *data = malloc(UPDATE_SIZE * sizeof(uint16_t)); uint16_t *data = malloc(TONE_CURVE_SIZE * sizeof(uint16_t));
if (!data) { if (!data) {
ERROR("Memory allocation failure! (%d bytes)\n", ERROR("Memory allocation failure! (%d bytes)\n",
UPDATE_SIZE); TONE_CURVE_SIZE);
return -1; return -1;
} }
/* Read in file */ /* Read in file */
if ((ret = dyesub_read_file(fname, data, UPDATE_SIZE, NULL))) { if ((ret = dyesub_read_file(fname, data, TONE_CURVE_SIZE, NULL))) {
ERROR("Failed to read Tone Curve file\n"); ERROR("Failed to read Tone Curve file\n");
goto done; goto done;
} }
/* Byteswap data to local CPU.. */ /* Byteswap data to local CPU.. */
for (ret = 0; ret < UPDATE_SIZE ; ret++) { for (ret = 0; ret < TONE_CURVE_SIZE ; ret++) {
data[ret] = be16_to_cpu(data[ret]); data[ret] = be16_to_cpu(data[ret]);
} }
/* Set up command */ /* Set up command */
cmd.target = target; cmd.target = target;
cmd.reserved = 0; cmd.reserved = 0;
cmd.size = cpu_to_le32(UPDATE_SIZE * sizeof(uint16_t)); cmd.size = cpu_to_le32(TONE_CURVE_SIZE * sizeof(uint16_t));
cmd.hdr.cmd = cpu_to_le16(S2145_CMD_UPDATE); cmd.hdr.cmd = cpu_to_le16(S2145_CMD_UPDATE);
cmd.hdr.len = cpu_to_le16(sizeof(struct s2145_update_cmd)-sizeof(cmd.hdr)); cmd.hdr.len = cpu_to_le16(sizeof(struct s2145_update_cmd)-sizeof(cmd.hdr));
/* Byteswap data to format printer is expecting.. */ /* Byteswap data to format printer is expecting.. */
for (ret = 0; ret < UPDATE_SIZE ; ret++) { for (ret = 0; ret < TONE_CURVE_SIZE ; ret++) {
data[ret] = cpu_to_le16(data[ret]); data[ret] = cpu_to_le16(data[ret]);
} }
@ -1172,7 +1157,7 @@ static int set_tonecurve(struct shinkos2145_ctx *ctx, int target, char *fname)
/* Sent transfer */ /* Sent transfer */
if ((ret = send_data(ctx->dev, ctx->endp_down, if ((ret = send_data(ctx->dev, ctx->endp_down,
(uint8_t *) data, UPDATE_SIZE * sizeof(uint16_t)))) { (uint8_t *) data, TONE_CURVE_SIZE * sizeof(uint16_t)))) {
goto done; goto done;
} }

View File

@ -1451,7 +1451,7 @@ static int get_tonecurve(struct shinkos6145_ctx *ctx, int type, char *fname)
int ret, num = 0; int ret, num = 0;
uint8_t *data; uint8_t *data;
uint16_t curves[UPDATE_SIZE] = { 0 }; uint16_t curves[TONE_CURVE_SIZE] = { 0 };
int i,j; int i,j;
@ -1505,11 +1505,11 @@ static int get_tonecurve(struct shinkos6145_ctx *ctx, int type, char *fname)
goto done; goto done;
} }
for (i = 0 ; i < UPDATE_SIZE; i++) { for (i = 0 ; i < TONE_CURVE_SIZE; i++) {
/* Byteswap appropriately */ /* Byteswap appropriately */
curves[i] = cpu_to_be16(le16_to_cpu(curves[i])); curves[i] = cpu_to_be16(le16_to_cpu(curves[i]));
} }
write(tc_fd, curves, UPDATE_SIZE * sizeof(uint16_t)); write(tc_fd, curves, TONE_CURVE_SIZE * sizeof(uint16_t));
close(tc_fd); close(tc_fd);
} }
@ -1526,20 +1526,20 @@ static int set_tonecurve(struct shinkos6145_ctx *ctx, int target, char *fname)
INFO("Set %s Tone Curve from '%s'\n", sinfonia_update_targets(target), fname); INFO("Set %s Tone Curve from '%s'\n", sinfonia_update_targets(target), fname);
uint16_t *data = malloc(UPDATE_SIZE * sizeof(uint16_t)); uint16_t *data = malloc(TONE_CURVE_SIZE * sizeof(uint16_t));
if (!data) { if (!data) {
ERROR("Memory Allocation Failure!\n"); ERROR("Memory Allocation Failure!\n");
return -1; return -1;
} }
/* Read in file */ /* Read in file */
if ((ret = dyesub_read_file(fname, data, UPDATE_SIZE * sizeof(uint16_t), NULL))) { if ((ret = dyesub_read_file(fname, data, TONE_CURVE_SIZE * sizeof(uint16_t), NULL))) {
ERROR("Failed to read Tone Curve file\n"); ERROR("Failed to read Tone Curve file\n");
goto done; goto done;
} }
/* Byteswap data to local CPU.. */ /* Byteswap data to local CPU.. */
for (ret = 0; ret < UPDATE_SIZE ; ret++) { for (ret = 0; ret < TONE_CURVE_SIZE ; ret++) {
data[ret] = be16_to_cpu(data[ret]); data[ret] = be16_to_cpu(data[ret]);
} }
@ -1547,13 +1547,13 @@ static int set_tonecurve(struct shinkos6145_ctx *ctx, int target, char *fname)
cmd.target = target; cmd.target = target;
cmd.reserved[0] = cmd.reserved[1] = cmd.reserved[2] = 0; cmd.reserved[0] = cmd.reserved[1] = cmd.reserved[2] = 0;
cmd.reset = 0; cmd.reset = 0;
cmd.size = cpu_to_le32(UPDATE_SIZE * sizeof(uint16_t)); cmd.size = cpu_to_le32(TONE_CURVE_SIZE * sizeof(uint16_t));
cmd.hdr.cmd = cpu_to_le16(S6145_CMD_UPDATE); cmd.hdr.cmd = cpu_to_le16(S6145_CMD_UPDATE);
cmd.hdr.len = cpu_to_le16(sizeof(struct s6145_update_cmd)-sizeof(cmd.hdr)); cmd.hdr.len = cpu_to_le16(sizeof(struct s6145_update_cmd)-sizeof(cmd.hdr));
/* Byteswap data to format printer is expecting.. */ /* Byteswap data to format printer is expecting.. */
for (ret = 0; ret < UPDATE_SIZE ; ret++) { for (ret = 0; ret < TONE_CURVE_SIZE ; ret++) {
data[ret] = cpu_to_le16(data[ret]); data[ret] = cpu_to_le16(data[ret]);
} }
@ -1567,7 +1567,7 @@ static int set_tonecurve(struct shinkos6145_ctx *ctx, int target, char *fname)
/* Sent transfer */ /* Sent transfer */
if ((ret = send_data(ctx->dev, ctx->endp_down, if ((ret = send_data(ctx->dev, ctx->endp_down,
(uint8_t *) data, UPDATE_SIZE * sizeof(uint16_t)))) { (uint8_t *) data, TONE_CURVE_SIZE * sizeof(uint16_t)))) {
goto done; goto done;
} }

View File

@ -1135,7 +1135,7 @@ static int get_tonecurve(struct shinkos6245_ctx *ctx, int type, char *fname)
int ret, num = 0; int ret, num = 0;
uint8_t *data; uint8_t *data;
uint16_t curves[UPDATE_SIZE] = { 0 }; uint16_t curves[TONE_CURVE_SIZE] = { 0 };
int i,j; int i,j;
@ -1189,11 +1189,11 @@ static int get_tonecurve(struct shinkos6245_ctx *ctx, int type, char *fname)
goto done; goto done;
} }
for (i = 0 ; i < UPDATE_SIZE; i++) { for (i = 0 ; i < TONE_CURVE_SIZE; i++) {
/* Byteswap appropriately */ /* Byteswap appropriately */
curves[i] = cpu_to_be16(le16_to_cpu(curves[i])); curves[i] = cpu_to_be16(le16_to_cpu(curves[i]));
} }
write(tc_fd, curves, UPDATE_SIZE * sizeof(uint16_t)); write(tc_fd, curves, TONE_CURVE_SIZE * sizeof(uint16_t));
close(tc_fd); close(tc_fd);
} }
@ -1210,20 +1210,20 @@ static int set_tonecurve(struct shinkos6245_ctx *ctx, int target, char *fname)
INFO("Set %s Tone Curve from '%s'\n", sinfonia_update_targets(target), fname); INFO("Set %s Tone Curve from '%s'\n", sinfonia_update_targets(target), fname);
uint16_t *data = malloc(UPDATE_SIZE * sizeof(uint16_t)); uint16_t *data = malloc(TONE_CURVE_SIZE * sizeof(uint16_t));
if (!data) { if (!data) {
ERROR("Memory Allocation Failure!\n"); ERROR("Memory Allocation Failure!\n");
return -1; return -1;
} }
/* Read in file */ /* Read in file */
if ((ret = dyesub_read_file(fname, data, UPDATE_SIZE * sizeof(uint16_t), NULL))) { if ((ret = dyesub_read_file(fname, data, TONE_CURVE_SIZE * sizeof(uint16_t), NULL))) {
ERROR("Failed to read Tone Curve file\n"); ERROR("Failed to read Tone Curve file\n");
goto done; goto done;
} }
/* Byteswap data to local CPU.. */ /* Byteswap data to local CPU.. */
for (ret = 0; ret < UPDATE_SIZE ; ret++) { for (ret = 0; ret < TONE_CURVE_SIZE ; ret++) {
data[ret] = be16_to_cpu(data[ret]); data[ret] = be16_to_cpu(data[ret]);
} }
@ -1231,13 +1231,13 @@ static int set_tonecurve(struct shinkos6245_ctx *ctx, int target, char *fname)
cmd.target = target; cmd.target = target;
cmd.reserved[0] = cmd.reserved[1] = cmd.reserved[2] = 0; cmd.reserved[0] = cmd.reserved[1] = cmd.reserved[2] = 0;
cmd.reset = 0; cmd.reset = 0;
cmd.size = cpu_to_le32(UPDATE_SIZE * sizeof(uint16_t)); cmd.size = cpu_to_le32(TONE_CURVE_SIZE * sizeof(uint16_t));
cmd.hdr.cmd = cpu_to_le16(S6245_CMD_UPDATE); cmd.hdr.cmd = cpu_to_le16(S6245_CMD_UPDATE);
cmd.hdr.len = cpu_to_le16(sizeof(struct s6245_update_cmd)-sizeof(cmd.hdr)); cmd.hdr.len = cpu_to_le16(sizeof(struct s6245_update_cmd)-sizeof(cmd.hdr));
/* Byteswap data to format printer is expecting.. */ /* Byteswap data to format printer is expecting.. */
for (ret = 0; ret < UPDATE_SIZE ; ret++) { for (ret = 0; ret < TONE_CURVE_SIZE ; ret++) {
data[ret] = cpu_to_le16(data[ret]); data[ret] = cpu_to_le16(data[ret]);
} }
@ -1251,7 +1251,7 @@ static int set_tonecurve(struct shinkos6245_ctx *ctx, int target, char *fname)
/* Sent transfer */ /* Sent transfer */
if ((ret = send_data(ctx->dev, ctx->endp_down, if ((ret = send_data(ctx->dev, ctx->endp_down,
(uint8_t *) data, UPDATE_SIZE * sizeof(uint16_t)))) { (uint8_t *) data, TONE_CURVE_SIZE * sizeof(uint16_t)))) {
goto done; goto done;
} }