ek6800/s1245: Support generic status queries.

master
Solomon Peachy 3 years ago
parent 131765cedc
commit beed73bc9d
  1. 2
      backend_kodak605.c
  2. 62
      backend_kodak6800.c
  3. 53
      backend_shinkos1245.c
  4. 2
      backend_shinkos2145.c
  5. 2
      backend_shinkos6145.c
  6. 2
      backend_shinkos6245.c

@ -854,7 +854,7 @@ static int kodak605_query_stats(void *vctx, struct printerstats *stats)
if (sinfonia_query_serno(ctx->dev.dev, ctx->dev.endp_up,
ctx->dev.endp_down, ctx->dev.iface,
ctx->serial, sizeof(stats->serial)))
ctx->serial, sizeof(ctx->serial)))
return CUPS_BACKEND_FAILED;
stats->serial = ctx->serial;

@ -95,6 +95,7 @@ struct kodak68x0_media_readback {
/* Private data structure */
struct kodak6800_ctx {
struct libusb_device_handle *dev;
int iface;
uint8_t endp_up;
uint8_t endp_down;
@ -109,6 +110,9 @@ struct kodak6800_ctx {
struct kodak68x0_status_readback sts;
char serial[32];
char fwver[32];
struct marker marker;
};
@ -546,6 +550,7 @@ static int kodak6800_query_serno(struct libusb_device_handle *dev, uint8_t endp_
.dev = dev,
.endp_up = endp_up,
.endp_down = endp_down,
.iface = iface,
};
int ret;
@ -554,8 +559,6 @@ static int kodak6800_query_serno(struct libusb_device_handle *dev, uint8_t endp_
uint8_t resp[33];
uint8_t req[16];
UNUSED(iface);
memset(req, 0, sizeof(req));
memset(resp, 0, sizeof(resp));
@ -684,11 +687,10 @@ static int kodak6800_attach(void *vctx, struct libusb_device_handle *dev, int ty
{
struct kodak6800_ctx *ctx = vctx;
UNUSED(iface);
ctx->dev = dev;
ctx->endp_up = endp_up;
ctx->endp_down = endp_down;
ctx->iface = iface;
ctx->type = type;
/* Ensure jobid is sane */
@ -1019,8 +1021,53 @@ static int kodak6800_query_markers(void *vctx, struct marker **markers, int *cou
ctx->marker.levelnow = ctx->sts.donor;
*markers = &ctx->marker;
*count = 1;
if (markers) *markers = &ctx->marker;
if (count) *count = 1;
return CUPS_BACKEND_OK;
}
static int kodak6800_query_stats(void *vctx, struct printerstats *stats)
{
struct kodak6800_ctx *ctx = vctx;
if (kodak6800_query_markers(ctx, NULL, NULL))
return CUPS_BACKEND_FAILED;
switch (ctx->type) {
case P_KODAK_6800:
stats->mfg = "Kodak";
stats->model = "6800";
break;
case P_KODAK_6850:
stats->mfg = "Kodak";
stats->model = "6850";
break;
default:
stats->mfg = "Unknown";
stats->model = "Unknown";
break;
}
if (kodak6800_query_serno(ctx->dev, ctx->endp_up,
ctx->endp_down, ctx->iface,
ctx->serial, sizeof(ctx->serial)))
return CUPS_BACKEND_FAILED;
stats->serial = ctx->serial;
snprintf(ctx->fwver, sizeof(ctx->fwver)-1,
"%d / %d", be16_to_cpu(ctx->sts.main_fw),
be16_to_cpu(ctx->sts.dsp_fw));
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";
stats->status[0] = strdup(sinfonia_1x45_status_str(ctx->sts.status1, ctx->sts.status2, ctx->sts.errcode));
stats->cnt_life[0] = be32_to_cpu(ctx->sts.lifetime);
return CUPS_BACKEND_OK;
}
@ -1036,7 +1083,7 @@ static const char *kodak6800_prefixes[] = {
/* Exported */
struct dyesub_backend kodak6800_backend = {
.name = "Kodak 6800/6850",
.version = "0.78" " (lib " LIBSINFONIA_VER ")",
.version = "0.79" " (lib " LIBSINFONIA_VER ")",
.uri_prefixes = kodak6800_prefixes,
.cmdline_usage = kodak6800_cmdline,
.cmdline_arg = kodak6800_cmdline_arg,
@ -1047,6 +1094,7 @@ struct dyesub_backend kodak6800_backend = {
.main_loop = kodak6800_main_loop,
.query_serno = kodak6800_query_serno,
.query_markers = kodak6800_query_markers,
.query_stats = kodak6800_query_stats,
.devices = {
{ USB_VID_KODAK, USB_PID_KODAK_6800, P_KODAK_6800, "Kodak", "kodak-6800"},
{ USB_VID_KODAK, USB_PID_KODAK_6850, P_KODAK_6850, "Kodak", "kodak-6850"},

@ -229,6 +229,7 @@ struct shinkos1245_ctx {
uint8_t endp_up;
uint8_t endp_down;
int type;
int iface;
uint8_t jobid;
@ -236,6 +237,9 @@ struct shinkos1245_ctx {
int num_medias;
int media_8x12;
char serial[32];
char fwver[32];
struct marker marker;
int tonecurve;
@ -945,11 +949,10 @@ static int shinkos1245_attach(void *vctx, struct libusb_device_handle *dev, int
{
struct shinkos1245_ctx *ctx = vctx;
UNUSED(iface);
ctx->dev = dev;
ctx->endp_up = endp_up;
ctx->endp_down = endp_down;
ctx->iface = iface;
ctx->type = type;
/* Ensure jobid is sane */
@ -1214,8 +1217,8 @@ static int shinkos1245_query_serno(struct libusb_device_handle *dev, uint8_t end
.dev = dev,
.endp_up = endp_up,
.endp_down = endp_down,
.iface = iface,
};
UNUSED(iface);
i = shinkos1245_get_printerid(&ctx, &resp);
if (i < 0)
@ -1245,8 +1248,45 @@ static int shinkos1245_query_markers(void *vctx, struct marker **markers, int *c
ctx->marker.levelnow = ctx->marker.levelmax - be32_to_cpu(status.counters.media);
*markers = &ctx->marker;
*count = 1;
if (markers) *markers = &ctx->marker;
if (markers) *count = 1;
return CUPS_BACKEND_OK;
}
static int shinkos1245_query_stats(void *vctx, struct printerstats *stats)
{
struct shinkos1245_ctx *ctx = vctx;
struct shinkos1245_resp_status status;
if (shinkos1245_query_markers(ctx, NULL, NULL))
return CUPS_BACKEND_FAILED;
if (shinkos1245_get_status(ctx, &status))
return CUPS_BACKEND_FAILED;
stats->mfg = "Sinfonia";
stats->model = "E1 / S1245";
if (shinkos1245_query_serno(ctx->dev, ctx->endp_up,
ctx->endp_down, ctx->iface,
ctx->serial, sizeof(ctx->serial)))
return CUPS_BACKEND_FAILED;
stats->serial = ctx->serial;
snprintf(ctx->fwver, sizeof(ctx->fwver)-1,
"%d / %d", be16_to_cpu(status.versions.main_control),
be16_to_cpu(status.versions.dsp_control));
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";
stats->status[0] = strdup(sinfonia_1x45_status_str(status.state.status1, status.state.status2, status.state.error));
stats->cnt_life[0] = be32_to_cpu(status.counters.lifetime);
return CUPS_BACKEND_OK;
}
@ -1266,7 +1306,7 @@ static const char *shinkos1245_prefixes[] = {
struct dyesub_backend shinkos1245_backend = {
.name = "Shinko/Sinfonia CHC-S1245/E1",
.version = "0.32" " (lib " LIBSINFONIA_VER ")",
.version = "0.33" " (lib " LIBSINFONIA_VER ")",
.uri_prefixes = shinkos1245_prefixes,
.cmdline_usage = shinkos1245_cmdline,
.cmdline_arg = shinkos1245_cmdline_arg,
@ -1277,6 +1317,7 @@ struct dyesub_backend shinkos1245_backend = {
.main_loop = shinkos1245_main_loop,
.query_serno = shinkos1245_query_serno,
.query_markers = shinkos1245_query_markers,
.query_stats = shinkos1245_query_stats,
.devices = {
{ USB_VID_SHINKO, USB_PID_SHINKO_S1245, P_SHINKO_S1245, NULL, "shinko-chcs1245"},
{ 0, 0, 0, NULL, NULL}

@ -1188,7 +1188,7 @@ static int shinkos2145_query_stats(void *vctx, struct printerstats *stats)
if (sinfonia_query_serno(ctx->dev.dev, ctx->dev.endp_up,
ctx->dev.endp_down, ctx->dev.iface,
ctx->serial, sizeof(stats->serial)))
ctx->serial, sizeof(ctx->serial)))
return CUPS_BACKEND_FAILED;
stats->serial = ctx->serial;

@ -1616,7 +1616,7 @@ static int shinkos6145_query_stats(void *vctx, struct printerstats *stats)
if (sinfonia_query_serno(ctx->dev.dev, ctx->dev.endp_up,
ctx->dev.endp_down, ctx->dev.iface,
ctx->serial, sizeof(stats->serial)))
ctx->serial, sizeof(ctx->serial)))
return CUPS_BACKEND_FAILED;
stats->serial = ctx->serial;

@ -1461,7 +1461,7 @@ static int shinkos6245_query_stats(void *vctx, struct printerstats *stats)
if (sinfonia_query_serno(ctx->dev.dev, ctx->dev.endp_up,
ctx->dev.endp_down, ctx->dev.iface,
ctx->serial, sizeof(stats->serial)))
ctx->serial, sizeof(ctx->serial)))
return CUPS_BACKEND_FAILED;
stats->serial = ctx->serial;

Loading…
Cancel
Save