sinfonia: Support generic stats query across most models.

(Everything but the s1245)
master
Solomon Peachy 3 years ago
parent 8168777679
commit 131765cedc
  1. 1
      backend_common.h
  2. 82
      backend_kodak605.c
  3. 77
      backend_shinkos2145.c
  4. 113
      backend_shinkos6145.c
  5. 96
      backend_shinkos6245.c

@ -146,6 +146,7 @@ enum {
P_HITI_52X,
P_HITI_720,
P_HITI_750,
P_HITI_910,
P_KODAK_1400_805,
P_KODAK_305,
P_KODAK_605,

@ -146,6 +146,9 @@ struct kodak605_ctx {
struct kodak605_media_list *media;
char serial[32];
char fwver[32];
struct marker marker;
};
@ -813,8 +816,80 @@ static int kodak605_query_markers(void *vctx, struct marker **markers, int *coun
ctx->marker.levelnow = sts.donor;
*markers = &ctx->marker;
*count = 1;
if (markers) *markers = &ctx->marker;
if (count) *count = 1;
return CUPS_BACKEND_OK;
}
static int kodak605_query_stats(void *vctx, struct printerstats *stats)
{
struct kodak605_ctx *ctx = vctx;
struct kodak605_status status;
if (kodak605_query_markers(ctx, NULL, NULL))
return CUPS_BACKEND_FAILED;
if (kodak605_get_status(ctx, &status))
return CUPS_BACKEND_FAILED;
switch (ctx->dev.type) {
case P_KODAK_605:
stats->mfg = "Kodak";
stats->model = "605";
break;
case P_KODAK_7000:
stats->mfg = "Kodak";
stats->model = "7000";
break;
case P_KODAK_701X:
stats->mfg = "Kodak";
stats->model = "7010/7015";
break;
default:
stats->mfg = "Unknown";
stats->model = "Unknown";
break;
}
if (sinfonia_query_serno(ctx->dev.dev, ctx->dev.endp_up,
ctx->dev.endp_down, ctx->dev.iface,
ctx->serial, sizeof(stats->serial)))
return CUPS_BACKEND_FAILED;
stats->serial = ctx->serial;
{
struct sinfonia_fwinfo_cmd cmd;
struct sinfonia_fwinfo_resp resp;
int num = 0;
cmd.hdr.cmd = cpu_to_le16(SINFONIA_CMD_FWINFO);
cmd.hdr.len = cpu_to_le16(1);
cmd.target = FWINFO_TARGET_MAIN_APP;
if (sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp),
&num))
return CUPS_BACKEND_FAILED;
snprintf(ctx->fwver, sizeof(ctx->fwver)-1,
"%d.%d", resp.major, resp.minor);
stats->fwver = ctx->fwver;
}
stats->decks = 1;
stats->mediatype[0] = ctx->marker.name;
stats->levelmax[0] = ctx->marker.levelmax;
stats->levelnow[0] = ctx->marker.levelnow;
stats->name[0] = "Roll";
if (status.hdr.status == ERROR_PRINTER) {
if(status.hdr.error == ERROR_NONE)
status.hdr.error = status.hdr.status;
stats->status[0] = strdup(sinfonia_error_str(status.hdr.error));
} else {
stats->status[0] = strdup(sinfonia_status_str(status.hdr.status));
}
stats->cnt_life[0] = le32_to_cpu(status.ctr_life);
return CUPS_BACKEND_OK;
}
@ -828,7 +903,7 @@ static const char *kodak605_prefixes[] = {
/* Exported */
struct dyesub_backend kodak605_backend = {
.name = "Kodak 605/70xx",
.version = "0.53" " (lib " LIBSINFONIA_VER ")",
.version = "0.54" " (lib " LIBSINFONIA_VER ")",
.uri_prefixes = kodak605_prefixes,
.cmdline_usage = kodak605_cmdline,
.cmdline_arg = kodak605_cmdline_arg,
@ -838,6 +913,7 @@ struct dyesub_backend kodak605_backend = {
.read_parse = kodak605_read_parse,
.main_loop = kodak605_main_loop,
.query_markers = kodak605_query_markers,
.query_stats = kodak605_query_stats,
.devices = {
{ USB_VID_KODAK, USB_PID_KODAK_605, P_KODAK_605, "Kodak", "kodak-605"},
{ USB_VID_KODAK, USB_PID_KODAK_7000, P_KODAK_7000, "Kodak", "kodak-7000"},

@ -395,6 +395,9 @@ struct shinkos2145_ctx {
uint8_t jobid;
char serial[32];
char fwver[32];
struct s2145_mediainfo_resp media;
struct marker marker;
int media_code;
@ -1152,8 +1155,75 @@ static int shinkos2145_query_markers(void *vctx, struct marker **markers, int *c
ctx->marker.levelnow = ctx->marker.levelmax - le32_to_cpu(sts.count_ribbon_left);
*markers = &ctx->marker;
*count = 1;
if (markers) *markers = &ctx->marker;
if (count) *count = 1;
return CUPS_BACKEND_OK;
}
static int shinkos2145_query_stats(void *vctx, struct printerstats *stats)
{
struct shinkos2145_ctx *ctx = vctx;
struct sinfonia_cmd_hdr cmd;
struct s2145_status_resp status;
int num;
if (shinkos2145_query_markers(ctx, NULL, NULL))
return CUPS_BACKEND_FAILED;
/* Query Status */
cmd.cmd = cpu_to_le16(SINFONIA_CMD_GETSTATUS);
cmd.len = cpu_to_le16(0);
if (sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&status, sizeof(status),
&num)) {
return CUPS_BACKEND_FAILED;
}
stats->mfg = "Sinfonia";
stats->model = "S2 / S2145";
if (sinfonia_query_serno(ctx->dev.dev, ctx->dev.endp_up,
ctx->dev.endp_down, ctx->dev.iface,
ctx->serial, sizeof(stats->serial)))
return CUPS_BACKEND_FAILED;
stats->serial = ctx->serial;
{
struct sinfonia_fwinfo_cmd cmd;
struct sinfonia_fwinfo_resp resp;
int num = 0;
cmd.hdr.cmd = cpu_to_le16(SINFONIA_CMD_FWINFO);
cmd.hdr.len = cpu_to_le16(1);
cmd.target = FWINFO_TARGET_MAIN_APP;
if (sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp),
&num))
return CUPS_BACKEND_FAILED;
snprintf(ctx->fwver, sizeof(ctx->fwver)-1,
"%d.%d", resp.major, resp.minor);
stats->fwver = ctx->fwver;
}
stats->decks = 1;
stats->mediatype[0] = ctx->marker.name;
stats->levelmax[0] = ctx->marker.levelmax;
stats->levelnow[0] = ctx->marker.levelnow;
stats->name[0] = "Roll";
if (status.hdr.status == ERROR_PRINTER) {
if(status.hdr.error == ERROR_NONE)
status.hdr.error = status.hdr.status;
stats->status[0] = strdup(sinfonia_error_str(status.hdr.error));
} else {
stats->status[0] = strdup(sinfonia_status_str(status.hdr.status));
}
stats->cnt_life[0] = le32_to_cpu(status.count_lifetime);
return CUPS_BACKEND_OK;
}
@ -1173,7 +1243,7 @@ static const char *shinkos2145_prefixes[] = {
struct dyesub_backend shinkos2145_backend = {
.name = "Shinko/Sinfonia CHC-S2145/S2",
.version = "0.64" " (lib " LIBSINFONIA_VER ")",
.version = "0.65" " (lib " LIBSINFONIA_VER ")",
.uri_prefixes = shinkos2145_prefixes,
.cmdline_usage = shinkos2145_cmdline,
.cmdline_arg = shinkos2145_cmdline_arg,
@ -1184,6 +1254,7 @@ struct dyesub_backend shinkos2145_backend = {
.main_loop = shinkos2145_main_loop,
.query_serno = shinkos2145_query_serno,
.query_markers = shinkos2145_query_markers,
.query_stats = shinkos2145_query_stats,
.devices = {
{ USB_VID_SHINKO, USB_PID_SHINKO_S2145, P_SHINKO_S2145, NULL, "shinko-chc2145"},
{ 0, 0, 0, NULL, NULL}

@ -558,6 +558,9 @@ struct shinkos6145_ctx {
uint8_t image_avg[3]; /* CMY */
char serial[32];
char fwver[32];
struct marker marker;
struct sinfonia_6x45_mediainfo_resp media;
@ -1534,12 +1537,13 @@ static int shinkos6145_query_markers(void *vctx, struct marker **markers, int *c
ctx->marker.levelnow = le32_to_cpu(sts.count_ribbon_left);
*markers = &ctx->marker;
*count = 1;
if (markers) *markers = &ctx->marker;
if (count) *count = 1;
return CUPS_BACKEND_OK;
}
/* Exported */
#define USB_VID_SHINKO 0x10CE
#define USB_PID_SHINKO_S6145 0x0019
@ -1550,6 +1554,108 @@ static int shinkos6145_query_markers(void *vctx, struct marker **markers, int *c
#define USB_VID_HITI 0x0D16
#define USB_PID_HITI_M610 0x0010
static int shinkos6145_query_stats(void *vctx, struct printerstats *stats)
{
struct shinkos6145_ctx *ctx = vctx;
struct sinfonia_cmd_hdr cmd;
struct s6145_status_resp status;
int num;
uint16_t usbID = 0xffff;
if (shinkos6145_query_markers(ctx, NULL, NULL))
return CUPS_BACKEND_FAILED;
/* Query Status */
cmd.cmd = cpu_to_le16(SINFONIA_CMD_GETSTATUS);
cmd.len = cpu_to_le16(0);
if (sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&status, sizeof(status),
&num)) {
return CUPS_BACKEND_FAILED;
}
/* Query USB ID */
{
struct libusb_device_descriptor desc;
struct libusb_device *dev;
dev = libusb_get_device(ctx->dev.dev);
libusb_get_device_descriptor(dev, &desc);
usbID = desc.idProduct;
}
switch (ctx->dev.type) {
case P_SHINKO_S6145:
stats->mfg = "Sinfonia";
stats->model = "CS2 / S6145";
break;
case P_SHINKO_S6145D:
stats->mfg = "Ciaat";
stats->model = "Brava 21";
break;
case P_SHINKO_S2245:
stats->mfg = "Sinfonia";
stats->model = "S3 / S2245";
break;
default:
if (usbID == USB_PID_KA_6900) {
stats->mfg = "Kodak";
stats->model = "6900";
} else if (usbID == USB_PID_HITI_M610) {
stats->mfg = "HiTi";
stats->model = "M610";
} else {
stats->mfg = "Unknown";
stats->model = "Unknown";
}
break;
}
if (sinfonia_query_serno(ctx->dev.dev, ctx->dev.endp_up,
ctx->dev.endp_down, ctx->dev.iface,
ctx->serial, sizeof(stats->serial)))
return CUPS_BACKEND_FAILED;
stats->serial = ctx->serial;
{
struct sinfonia_fwinfo_cmd cmd;
struct sinfonia_fwinfo_resp resp;
int num = 0;
cmd.hdr.cmd = cpu_to_le16(SINFONIA_CMD_FWINFO);
cmd.hdr.len = cpu_to_le16(1);
cmd.target = FWINFO_TARGET_MAIN_APP;
if (sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp),
&num))
return CUPS_BACKEND_FAILED;
snprintf(ctx->fwver, sizeof(ctx->fwver)-1,
"%d.%d", resp.major, resp.minor);
stats->fwver = ctx->fwver;
}
stats->decks = 1;
stats->mediatype[0] = ctx->marker.name;
stats->levelmax[0] = ctx->marker.levelmax;
stats->levelnow[0] = ctx->marker.levelnow;
stats->name[0] = "Roll";
if (status.hdr.status == ERROR_PRINTER) {
if(status.hdr.error == ERROR_NONE)
status.hdr.error = status.hdr.status;
stats->status[0] = strdup(sinfonia_error_str(status.hdr.error));
} else {
stats->status[0] = strdup(sinfonia_status_str(status.hdr.status));
}
stats->cnt_life[0] = le32_to_cpu(status.count_lifetime);
return CUPS_BACKEND_OK;
}
static const char *shinkos6145_prefixes[] = {
"sinfonia-chcs6145", "ciaat-brava-21",
"sinfonia-chcs2245", "hiti-m610", "kodak-6900",
@ -1562,7 +1668,7 @@ static const char *shinkos6145_prefixes[] = {
struct dyesub_backend shinkos6145_backend = {
.name = "Shinko/Sinfonia CHC-S6145/CS2/S2245/S3",
.version = "0.46" " (lib " LIBSINFONIA_VER ")",
.version = "0.47" " (lib " LIBSINFONIA_VER ")",
.uri_prefixes = shinkos6145_prefixes,
.cmdline_usage = shinkos6145_cmdline,
.cmdline_arg = shinkos6145_cmdline_arg,
@ -1574,6 +1680,7 @@ struct dyesub_backend shinkos6145_backend = {
.main_loop = shinkos6145_main_loop,
.query_serno = sinfonia_query_serno,
.query_markers = shinkos6145_query_markers,
.query_stats = shinkos6145_query_stats,
.devices = {
{ USB_VID_SHINKO, USB_PID_SHINKO_S6145, P_SHINKO_S6145, NULL, "sinfonia-chcs6145"},
{ USB_VID_SHINKO, USB_PID_SHINKO_S6145D, P_SHINKO_S6145D, NULL, "ciaat-brava-21"},

@ -704,6 +704,9 @@ struct shinkos6245_ctx {
struct marker marker;
char serial[32];
char fwver[32];
struct sinfonia_6x45_mediainfo_resp media;
};
@ -1133,7 +1136,7 @@ static int shinkos6245_main_loop(void *vctx, const void *vjob) {
copies = job->copies;
/* Cap copies */
// XXX 120 for 8x10 media, 100 for 8x12 media (S6245)
// XXX 120 for 8x10 media, 100 for 8x12 media (S6245 / P910L)
// 250 for 8x12, 300 for 8x10 (Kodak 8810)
if (copies > 120)
copies = 120;
@ -1410,8 +1413,90 @@ static int shinkos6245_query_markers(void *vctx, struct marker **markers, int *c
ctx->marker.levelnow = le32_to_cpu(status.count_ribbon_left);
*markers = &ctx->marker;
*count = 1;
if (markers) *markers = &ctx->marker;
if (count) *count = 1;
return CUPS_BACKEND_OK;
}
static int shinkos6245_query_stats(void *vctx, struct printerstats *stats)
{
struct shinkos6245_ctx *ctx = vctx;
struct sinfonia_cmd_hdr cmd;
struct s6245_status_resp status;
int num;
if (shinkos6245_query_markers(ctx, NULL, NULL))
return CUPS_BACKEND_FAILED;
/* Query Status */
cmd.cmd = cpu_to_le16(SINFONIA_CMD_GETSTATUS);
cmd.len = cpu_to_le16(0);
if (sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&status, sizeof(status),
&num)) {
return CUPS_BACKEND_FAILED;
}
switch (ctx->dev.type) {
case P_SHINKO_S6245:
stats->mfg = "Sinfonia";
stats->model = "CE1 / S6245";
break;
case P_HITI_910:
stats->mfg = "HiTi";
stats->model = "P910L";
break;
case P_KODAK_8810:
stats->mfg = "Kodak";
stats->model = "8810";
break;
default:
stats->mfg = "Unknown";
stats->model = "Unknown";
break;
}
if (sinfonia_query_serno(ctx->dev.dev, ctx->dev.endp_up,
ctx->dev.endp_down, ctx->dev.iface,
ctx->serial, sizeof(stats->serial)))
return CUPS_BACKEND_FAILED;
stats->serial = ctx->serial;
{
struct sinfonia_fwinfo_cmd cmd;
struct sinfonia_fwinfo_resp resp;
int num = 0;
cmd.hdr.cmd = cpu_to_le16(SINFONIA_CMD_FWINFO);
cmd.hdr.len = cpu_to_le16(1);
cmd.target = FWINFO_TARGET_MAIN_APP;
if (sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp),
&num))
return CUPS_BACKEND_FAILED;
snprintf(ctx->fwver, sizeof(ctx->fwver)-1,
"%d.%d", resp.major, resp.minor);
stats->fwver = ctx->fwver;
}
stats->decks = 1;
stats->mediatype[0] = ctx->marker.name;
stats->levelmax[0] = ctx->marker.levelmax;
stats->levelnow[0] = ctx->marker.levelnow;
stats->name[0] = "Roll";
if (status.hdr.status == ERROR_PRINTER) {
if(status.hdr.error == ERROR_NONE)
status.hdr.error = status.hdr.status;
stats->status[0] = strdup(sinfonia_error_str(status.hdr.error));
} else {
stats->status[0] = strdup(sinfonia_status_str(status.hdr.status));
}
stats->cnt_life[0] = le32_to_cpu(status.count_lifetime);
return CUPS_BACKEND_OK;
}
@ -1435,7 +1520,7 @@ static const char *shinkos6245_prefixes[] = {
struct dyesub_backend shinkos6245_backend = {
.name = "Sinfonia CHC-S6245 / Kodak 8810",
.version = "0.31" " (lib " LIBSINFONIA_VER ")",
.version = "0.32" " (lib " LIBSINFONIA_VER ")",
.uri_prefixes = shinkos6245_prefixes,
.cmdline_usage = shinkos6245_cmdline,
.cmdline_arg = shinkos6245_cmdline_arg,
@ -1446,9 +1531,10 @@ struct dyesub_backend shinkos6245_backend = {
.main_loop = shinkos6245_main_loop,
.query_serno = sinfonia_query_serno,
.query_markers = shinkos6245_query_markers,
.query_stats = shinkos6245_query_stats,
.devices = {
{ USB_VID_SHINKO, USB_PID_SHINKO_S6245, P_SHINKO_S6245, NULL, "shinfonia-chcs6245"},
{ USB_VID_HITI, USB_PID_HITI_P910L, P_SHINKO_S6245, NULL, "hiti-p910l"},
{ USB_VID_HITI, USB_PID_HITI_P910L, P_HITI_910, NULL, "hiti-p910l"},
{ USB_VID_KODAK, USB_PID_KODAK_8810, P_KODAK_8810, NULL, "kodak-8810"},
{ 0, 0, 0, NULL, NULL}
}

Loading…
Cancel
Save