sinfonia: More cleanups:

* Command execution error handling revamped
 * Centralized parameter lists
 * Figuring out parameters for EK8810 and EK7000
master
Solomon Peachy 3 years ago
parent f25126a156
commit 6c7881679d
  1. 88
      backend_kodak605.c
  2. 36
      backend_shinkos2145.c
  3. 34
      backend_shinkos6145.c
  4. 125
      backend_shinkos6245.c
  5. 59
      backend_sinfonia.c
  6. 13
      backend_sinfonia.h

@ -94,22 +94,59 @@ struct kodak605_status {
/*@76*/ uint8_t null_3[1]; /* EK7000 only */
} __attribute__((packed));
/* Parameter IDs recognized on EK7000:
No idea what any of these are yet!
01
11 12 13 14
21 22 23 24 25
2f
41 42 43 44 45 46 47 48
81 82 83 84
91 92 93 94
a0 a1 a2 a3 a4 a5 a6 a7 a8 a9
c1 c2 c3 c4
f1 f2 f3 f4
*/
static const struct sinfonia_param ek7000_params[] =
{
{ 0x01, "Unknown_01" }, // 00000001
{ 0x11, "Unknown_11" }, // 00000001
{ 0x12, "Matte Gloss" }, // 00000069
{ 0x13, "Matte Degloss Black" }, // 000000c3
{ 0x14, "Matte Degloss White" }, // 000000cd
{ 0x21, "Exit Speed With Sorter 4x6" }, // 000003e8
{ 0x22, "Exit Speed With Sorter 8x6" }, // 0000041a
{ 0x23, "Exit Speed With Backprinting" }, // 00000152
{ 0x24, "Exit Speed Without PPAC 4x6" }, // 0000044c
{ 0x25, "Exit Speed Without PPAC 8x6" }, // 0000044c
{ 0x2f, "Unknown_2f" }, // 00000320
{ 0x41, "Unknown_41" }, // 0000006d
{ 0x42, "Unknown_42" }, // 00000051
{ 0x43, "Unknown_43" }, // 0000003b
{ 0x44, "Unknown_44" }, // 00000082
{ 0x45, "Unknown_45" }, // 00000000
{ 0x46, "Unknown_46" }, // 00000000
{ 0x47, "Unknown_47" }, // 00000028
{ 0x48, "Unknown_48" }, // 00000002
{ 0x81, "Unknown_81" }, // ffffffff
{ 0x82, "Unknown_82" }, // fffffffe
{ 0x83, "Unknown_83" }, // ffffffee
{ 0x84, "Unknown_84" }, // 00000001
{ 0x91, "Unknown_91" }, // 0000006c
{ 0x92, "Unknown_92" }, // 00000077
{ 0x93, "Unknown_93" }, // 00000067
{ 0x94, "Unknown_94" }, // 00000076
{ 0xa0, "Unknown_a0" }, // 00000005
{ 0xa1, "Unknown_a1" }, // 00000000
{ 0xa2, "Unknown_a2" }, // 00000010
{ 0xa3, "Unknown_a3" }, // 0000003b
{ 0xa4, "Unknown_a4" }, // 0000003b
{ 0xa5, "Thermal Protect Lamination" }, // 0000003e
{ 0xa6, "Unknown_a6" }, // 00000001
{ 0xa7, "Unknown_a7" }, // 00000014
{ 0xa8, "Unknown_a8" }, // 00000001
{ 0xa9, "Unknown_a9" }, // ffffffff
{ 0xc1, "Unknown_c1" }, // 00000002
{ 0xc2, "Unknown_c2" }, // 000000c8
{ 0xc3, "Unknown_c3" }, // 000000c8
{ 0xc4, "Unknown_c4" }, // 00000200
{ 0xf1, "Unknown_f1" }, // 00000068
{ 0xf2, "Unknown_f2" }, // 00000068
{ 0xf3, "Unknown_f3" }, // 00000094
{ 0xf4, "Unknown_f4" }, // 00000068
};
#define ek7000_params_num (sizeof(ek7000_params) / sizeof(struct sinfonia_param))
/* Private data structure */
struct kodak605_ctx {
@ -309,11 +346,11 @@ static int kodak605_get_status(struct kodak605_ctx *ctx, struct kodak605_status
if ((ret = sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)sts, sizeof(*sts), &num)) < 0) {
(uint8_t*)sts, sizeof(*sts), &num))) {
return ret;
}
return 0;
return CUPS_BACKEND_OK;
}
static void *kodak605_init(void)
@ -341,6 +378,11 @@ static int kodak605_attach(void *vctx, struct libusb_device_handle *dev, int typ
ctx->dev.type = type;
ctx->dev.error_codes = &error_codes;
if (ctx->dev.type != P_KODAK_605) {
ctx->dev.params = ek7000_params;
ctx->dev.params_count = ek7000_params_num;
}
/* Make sure jobid is sane */
ctx->jobid = jobid & 0x7f;
if (!ctx->jobid)
@ -501,7 +543,7 @@ static int kodak605_main_loop(void *vctx, const void *vjob) {
if ((ret = sinfonia_docmd(&ctx->dev,
(uint8_t*)&bp, sizeof(bp),
(uint8_t*)&sts.hdr, sizeof(sts.hdr),
&num)) < 0) {
&num))) {
return ret;
}
offset += 44;
@ -515,7 +557,7 @@ static int kodak605_main_loop(void *vctx, const void *vjob) {
if ((ret = sinfonia_docmd(&ctx->dev,
(uint8_t*)&bp, sizeof(bp),
(uint8_t*)&sts.hdr, sizeof(sts.hdr),
&num)) < 0) {
&num))) {
return ret;
}
offset += 44;
@ -542,7 +584,7 @@ retry_print:
if ((ret = sinfonia_docmd(&ctx->dev,
(uint8_t*)&hdr, sizeof(hdr),
(uint8_t*)&sts.hdr, sizeof(sts.hdr),
&num)) < 0) {
&num))) {
return ret;
}
@ -765,7 +807,7 @@ static int kodak605_cmdline_arg(void *vctx, int argc, char **argv)
if (j) return j;
}
return 0;
return CUPS_BACKEND_OK;
}
static int kodak605_query_markers(void *vctx, struct marker **markers, int *count)
@ -794,7 +836,7 @@ static const char *kodak605_prefixes[] = {
/* Exported */
struct dyesub_backend kodak605_backend = {
.name = "Kodak 605/70xx",
.version = "0.50" " (lib " LIBSINFONIA_VER ")",
.version = "0.51" " (lib " LIBSINFONIA_VER ")",
.uri_prefixes = kodak605_prefixes,
.cmdline_usage = kodak605_cmdline,
.cmdline_arg = kodak605_cmdline_arg,

@ -422,7 +422,7 @@ static int get_status(struct shinkos2145_ctx *ctx)
if ((ret = sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp),
&num)) < 0) {
&num))) {
return ret;
}
@ -438,7 +438,7 @@ static int get_status(struct shinkos2145_ctx *ctx)
resp.hdr.printer_minor, error_codes(resp.hdr.printer_major, resp.hdr.printer_minor));
}
if (le16_to_cpu(resp.hdr.payload_len) != (sizeof(struct s2145_status_resp) - sizeof(struct sinfonia_status_hdr)))
return 0;
return CUPS_BACKEND_OK;
INFO(" Print Counts:\n");
INFO("\tSince Paper Changed:\t%08u\n", le32_to_cpu(resp.count_paper));
@ -463,7 +463,7 @@ static int get_status(struct shinkos2145_ctx *ctx)
INFO("Tonecurve Status: 0x%02x (%s)\n", resp.tonecurve_status, sinfonia_tonecurve_statuses(resp.tonecurve_status));
return 0;
return CUPS_BACKEND_OK;
}
static int get_fwinfo(struct shinkos2145_ctx *ctx)
@ -485,7 +485,7 @@ static int get_fwinfo(struct shinkos2145_ctx *ctx)
if ((ret = sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp),
&num)) < 0) {
&num))) {
continue;
}
@ -502,7 +502,7 @@ static int get_fwinfo(struct shinkos2145_ctx *ctx)
le16_to_cpu(resp.checksum));
#endif
}
return 0;
return CUPS_BACKEND_OK;
}
static void dump_mediainfo(struct s2145_mediainfo_resp *resp)
@ -533,7 +533,7 @@ static int get_user_string(struct shinkos2145_ctx *ctx)
if ((ret = sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp),
&num)) < 0) {
&num))) {
return ret;
}
@ -543,7 +543,7 @@ static int get_user_string(struct shinkos2145_ctx *ctx)
resp.hdr.payload_len = 23;
resp.data[resp.hdr.payload_len] = 0;
INFO("Unique String: '%s'\n", resp.data);
return 0;
return CUPS_BACKEND_OK;
}
static int set_user_string(struct shinkos2145_ctx *ctx, char *str)
@ -568,11 +568,11 @@ static int set_user_string(struct shinkos2145_ctx *ctx, char *str)
if ((ret = sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, cmd.len + 1 + sizeof(cmd.hdr),
(uint8_t*)&resp, sizeof(resp),
&num)) < 0) {
&num))) {
return ret;
}
return 0;
return CUPS_BACKEND_OK;
}
static int reset_curve(struct shinkos2145_ctx *ctx, int target)
@ -590,11 +590,11 @@ static int reset_curve(struct shinkos2145_ctx *ctx, int target)
if ((ret = sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp),
&num)) < 0) {
&num))) {
return ret;
}
return 0;
return CUPS_BACKEND_OK;
}
@ -619,7 +619,7 @@ static int get_tonecurve(struct shinkos2145_ctx *ctx, int type, char *fname)
if ((ret = sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp),
&num)) < 0) {
&num))) {
return ret;
}
@ -720,7 +720,7 @@ static int set_tonecurve(struct shinkos2145_ctx *ctx, int target, char *fname)
if ((ret = sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp),
&num)) < 0) {
&num))) {
goto done;
}
@ -823,7 +823,7 @@ int shinkos2145_cmdline_arg(void *vctx, int argc, char **argv)
if (j) return j;
}
return 0;
return CUPS_BACKEND_OK;
}
static void *shinkos2145_init(void)
@ -974,7 +974,7 @@ top:
if ((ret = sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&sts, sizeof(sts),
&num)) < 0) {
&num))) {
return CUPS_BACKEND_FAILED;
}
@ -1041,7 +1041,7 @@ top:
if ((ret = sinfonia_docmd(&ctx->dev,
(uint8_t*)&print, sizeof(print),
(uint8_t*)&sts, sizeof(sts),
&num)) < 0) {
&num))) {
return ret;
}
@ -1126,7 +1126,7 @@ static int shinkos2145_query_serno(struct libusb_device_handle *dev, uint8_t end
if ((ret = sinfonia_docmd(&sdev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp),
&num)) < 0) {
&num))) {
return ret;
}
@ -1179,7 +1179,7 @@ static const char *shinkos2145_prefixes[] = {
struct dyesub_backend shinkos2145_backend = {
.name = "Shinko/Sinfonia CHC-S2145/S2",
.version = "0.62" " (lib " LIBSINFONIA_VER ")",
.version = "0.63" " (lib " LIBSINFONIA_VER ")",
.uri_prefixes = shinkos2145_prefixes,
.cmdline_usage = shinkos2145_cmdline,
.cmdline_arg = shinkos2145_cmdline_arg,

@ -244,6 +244,18 @@ struct s6145_print_cmd {
#define PARAM_REGION_CODE 0x53 // Brava 21 only?
#define PARAM_SLEEP_TIME 0x54
static const struct sinfonia_param s6145_params[] =
{
{ PARAM_OC_PRINT, "Overcoat Mode" },
{ PARAM_PAPER_PRESV, "Paper Preserve Mode" },
{ PARAM_DRIVER_MODE, "Driver Mode/Wizard" },
{ PARAM_PAPER_MODE, "Paper Load Mode" },
{ PARAM_SLEEP_TIME, "Sleep Time" },
{ PARAM_REGION_CODE, "Region Code" },
};
#define s6145_params_num (sizeof(s6145_params) / sizeof(struct sinfonia_param))
#define PARAM_OC_PRINT_OFF 0x00000001
#define PARAM_OC_PRINT_GLOSS 0x00000002
@ -634,7 +646,7 @@ static int get_status(struct shinkos6145_ctx *ctx)
if ((ret = sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp2, sizeof(resp2),
&num)) < 0) {
&num))) {
return ret;
}
if (le16_to_cpu(resp2.hdr.payload_len) != (sizeof(struct sinfonia_getextcounter_resp) - sizeof(struct sinfonia_status_hdr)))
@ -692,7 +704,7 @@ static int get_status(struct shinkos6145_ctx *ctx)
INFO("Sleep delay: %u minutes\n", val);
return 0;
return CUPS_BACKEND_OK;
}
static void dump_mediainfo(struct sinfonia_6x45_mediainfo_resp *resp)
@ -790,7 +802,7 @@ static int shinkos6145_get_imagecorr(struct shinkos6145_ctx *ctx)
if ((ret = sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp),
&num)) < 0) {
&num))) {
goto done;
}
@ -845,7 +857,7 @@ static int shinkos6145_get_eeprom(struct shinkos6145_ctx *ctx)
if ((ret = sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp),
&num)) < 0) {
&num))) {
goto done;
}
@ -965,7 +977,7 @@ int shinkos6145_cmdline_arg(void *vctx, int argc, char **argv)
if (j) return j;
}
return 0;
return CUPS_BACKEND_OK;
}
static void *shinkos6145_init(void)
@ -993,6 +1005,12 @@ static int shinkos6145_attach(void *vctx, struct libusb_device_handle *dev, int
ctx->dev.type = type;
ctx->dev.error_codes = &error_codes;
if (type == P_SHINKO_S6145 ||
type == P_SHINKO_S6145D) {
ctx->dev.params = s6145_params;
ctx->dev.params_count = s6145_params_num;
}
/* Attempt to open the library */
#if defined(WITH_DYNAMIC)
INFO("Attempting to load image processing library\n");
@ -1285,7 +1303,7 @@ top:
if ((ret = sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&sts, sizeof(sts),
&num)) < 0) {
&num))) {
return CUPS_BACKEND_FAILED;
}
@ -1420,7 +1438,7 @@ top:
if ((ret = sinfonia_docmd(&ctx->dev,
(uint8_t*)&print, sizeof(print),
(uint8_t*)&sts, sizeof(sts),
&num)) < 0) {
&num))) {
return ret;
}
@ -1525,7 +1543,7 @@ static const char *shinkos6145_prefixes[] = {
struct dyesub_backend shinkos6145_backend = {
.name = "Shinko/Sinfonia CHC-S6145/CS2/S2245/S3",
.version = "0.42" " (lib " LIBSINFONIA_VER ")",
.version = "0.43" " (lib " LIBSINFONIA_VER ")",
.uri_prefixes = shinkos6145_prefixes,
.cmdline_usage = shinkos6145_cmdline,
.cmdline_arg = shinkos6145_cmdline_arg,

@ -67,30 +67,80 @@ struct s6245_print_cmd {
uint8_t reserved2;
} __attribute__((packed));
/* Parameter IDs recognized on EK8810
No idea what any of these are yet!
01
11 12 13 14
21 22 23 24 25
2f
41 42 43 44 45 46 47 48
61 62 63 64
81 82 83 84
8a 8b 8c 8d
91 92 93
a0 a1 a2 a3 a4 a5 a6 a7 a8 a9
c1 c2 c3 c4
f1 f2 f3 f4
*/
static const struct sinfonia_param ek8810_params[] =
{
{ 0x01, "Unknown_01" }, // 00000001
{ 0x11, "Unknown_11" }, // 00000001
{ 0x12, "? Matte Gloss" }, // 00000069
{ 0x13, "? Matte Degloss Black" }, // 000000c3
{ 0x14, "? Matte Degloss White" }, // 000000cd
{ 0x21, "Unknown_21" }, // 000003e8
{ 0x22, "Unknown_22" }, // 0000041a
{ 0x23, "Unknown_23" }, // 00000152
{ 0x24, "Unknown_24" }, // 0000044c
{ 0x25, "Unknown_25" }, // 0000044c
{ 0x2f, "Unknown_2f" }, // 00000320
{ 0x41, "Unknown_41" }, // 0000005d
{ 0x42, "Unknown_42" }, // 00000048
{ 0x43, "Unknown_43" }, // 0000007c
{ 0x44, "Unknown_44" }, // 00000088
{ 0x45, "Unknown_45" }, // 00000000
{ 0x46, "Unknown_46" }, // 00000002
{ 0x47, "Unknown_47" }, // 00000063
{ 0x48, "Unknown_48" }, // 00000008
{ 0x61, "Unknown_61" }, // 00000050
{ 0x62, "Unknown_62" }, // 00000031
{ 0x63, "Unknown_63" }, // 00000030
{ 0x64, "Unknown_64" }, // 00000030
{ 0x81, "Unknown_81" }, // ffffffff
{ 0x82, "Unknown_82" }, // fffffff9
{ 0x83, "Unknown_83" }, // fffffffc
{ 0x84, "Unknown_84" }, // 00000002
{ 0x8a, "Unknown_8a" }, // 00000005
{ 0x8b, "Unknown_8b" }, // 00000005
{ 0x8c, "Unknown_8c" }, // 00000000
{ 0x8d, "Unknown_8d" }, // 00000000
{ 0x91, "Unknown_91" }, // 0000007e
{ 0x92, "Unknown_92" }, // 0000007d
{ 0x93, "Unknown_93" }, // 00000077
{ 0xa0, "Unknown_a0" }, // 00000005
{ 0xa1, "Unknown_a1" }, // 00000000
{ 0xa2, "Unknown_a2" }, // 00000008
{ 0xa3, "Unknown_a3" }, // 00000030
{ 0xa4, "Unknown_a4" }, // 00000030
{ 0xa5, "? Thermal Protect Lamination" }, // 00000046
{ 0xa6, "Unknown_a6" }, // 00000001
{ 0xa7, "Unknown_a7" }, // 00000014
{ 0xa8, "Unknown_a8" }, // 00000001
{ 0xa9, "Unknown_a9" }, // ffffffff
{ 0xc1, "Unknown_c1" }, // 00000002
{ 0xc2, "Unknown_c2" }, // 000000c8
{ 0xc3, "Unknown_c3" }, // 000000c8
{ 0xc4, "Unknown_c4" }, // 000004d0
{ 0xf1, "Unknown_f1" }, // 00000022
{ 0xf2, "Unknown_f2" }, // 00000022
{ 0xf3, "Unknown_f3" }, // 00000047
{ 0xf4, "Unknown_f4" }, // 00000022
};
#define ek8810_params_num (sizeof(ek8810_params) / sizeof(struct sinfonia_param))
#define PARAM_DRIVER_MODE 0x3e
#define PARAM_PAPER_MODE 0x3f
#define PARAM_SLEEP_TIME 0x54
static const struct sinfonia_param s6245_params[] =
{
{ PARAM_DRIVER_MODE, "Driver Mode/Wizard" },
{ PARAM_PAPER_MODE, "Paper Load Mode" },
{ PARAM_SLEEP_TIME, "Sleep Time" },
};
#define s6245_params_num (sizeof(s6245_params) / sizeof(struct sinfonia_param))
#define PARAM_DRIVER_WIZOFF 0x00000000
#define PARAM_DRIVER_WIZON 0x00000001
@ -681,7 +731,7 @@ static int get_status(struct shinkos6245_ctx *ctx)
if ((ret = sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*) &resp, sizeof(resp),
&num)) < 0) {
&num))) {
return ret;
}
@ -696,8 +746,10 @@ static int get_status(struct shinkos6245_ctx *ctx)
resp.hdr.printer_major,
resp.hdr.printer_minor, ctx->dev.error_codes(resp.hdr.printer_major, resp.hdr.printer_minor));
}
/* Sanity checking */
if (le16_to_cpu(resp.hdr.payload_len) != (sizeof(struct s6245_status_resp) - sizeof(struct sinfonia_status_hdr)))
return 0;
return CUPS_BACKEND_OK;
INFO(" Print Counts:\n");
INFO("\tSince Paper Changed:\t%08u\n", le32_to_cpu(resp.count_paper));
@ -726,7 +778,7 @@ static int get_status(struct shinkos6245_ctx *ctx)
/* Query Extended counters */
if (ctx->dev.type == P_KODAK_8810)
return 0; /* Kodak 8810 returns 12 bytes of garbage. */
return CUPS_BACKEND_OK; /* Kodak 8810 returns 12 bytes of garbage. */
cmd.cmd = cpu_to_le16(SINFONIA_CMD_EXTCOUNTER);
cmd.len = cpu_to_le16(0);
@ -734,18 +786,18 @@ static int get_status(struct shinkos6245_ctx *ctx)
if ((ret = sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp2, sizeof(resp2),
&num)) < 0) {
&num))) {
return ret;
}
if (le16_to_cpu(resp2.hdr.payload_len) < 12)
return 0;
return CUPS_BACKEND_OK;
INFO("Lifetime Distance: %08u inches\n", le32_to_cpu(resp2.lifetime_distance));
INFO("Maintenance Distance: %08u inches\n", le32_to_cpu(resp2.maint_distance));
INFO("Head Distance: %08u inches\n", le32_to_cpu(resp2.head_distance));
return 0;
return CUPS_BACKEND_OK;
}
static int get_errorlog(struct shinkos6245_ctx *ctx)
@ -765,7 +817,7 @@ static int get_errorlog(struct shinkos6245_ctx *ctx)
if ((ret = sinfonia_docmd(&ctx->dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp),
&num)) < 0) {
&num))) {
return ret;
}
@ -783,7 +835,7 @@ static int get_errorlog(struct shinkos6245_ctx *ctx)
resp.printer_thermistor, resp.head_thermistor, resp.printer_humidity);
} while (++i < le16_to_cpu(resp.error_count));
return 0;
return CUPS_BACKEND_OK;
}
static void dump_mediainfo(struct sinfonia_6x45_mediainfo_resp *resp)
@ -913,7 +965,7 @@ int shinkos6245_cmdline_arg(void *vctx, int argc, char **argv)
if (j) return j;
}
return 0;
return CUPS_BACKEND_OK;
}
static void *shinkos6245_init(void)
@ -938,10 +990,15 @@ static int shinkos6245_attach(void *vctx, struct libusb_device_handle *dev, int
ctx->dev.endp_down = endp_down;
ctx->dev.type = type;
if (type == P_KODAK_8810)
if (type == P_KODAK_8810) {
ctx->dev.error_codes = &ek8810_error_codes;
else
ctx->dev.params = ek8810_params;
ctx->dev.params_count = ek8810_params_num;
} else {
ctx->dev.error_codes = &s6245_error_codes;
ctx->dev.params = s6245_params;
ctx->dev.params_count = s6245_params_num;
}
/* Ensure jobid is sane */
ctx->jobid = jobid & 0x7f;
@ -1090,7 +1147,7 @@ static int shinkos6245_main_loop(void *vctx, const void *vjob) {
if ((ret = sinfonia_docmd(&ctx->dev,
cmdbuf, sizeof(*settime),
(uint8_t*)&resp, sizeof(resp),
&num)) < 0) {
&num))) {
return CUPS_BACKEND_FAILED;
}
if (resp.result != RESULT_SUCCESS) {
@ -1115,7 +1172,7 @@ top:
if ((ret = sinfonia_docmd(&ctx->dev,
cmdbuf, sizeof(*cmd),
(uint8_t*)&sts, sizeof(sts),
&num)) < 0) {
&num))) {
return CUPS_BACKEND_FAILED;
}
@ -1181,7 +1238,7 @@ top:
if ((ret = sinfonia_docmd(&ctx->dev,
cmdbuf, sizeof(*print),
(uint8_t*)&resp, sizeof(resp),
&num)) < 0) {
&num))) {
return ret;
}
@ -1281,7 +1338,7 @@ static const char *shinkos6245_prefixes[] = {
struct dyesub_backend shinkos6245_backend = {
.name = "Sinfonia CHC-S6245 / Kodak 8810",
.version = "0.27" " (lib " LIBSINFONIA_VER ")",
.version = "0.28" " (lib " LIBSINFONIA_VER ")",
.uri_prefixes = shinkos6245_prefixes,
.cmdline_usage = shinkos6245_cmdline,
.cmdline_arg = shinkos6245_cmdline_arg,

@ -368,7 +368,7 @@ int sinfonia_docmd(struct sinfonia_usbdev *usbh,
goto fail;
}
return 0;
return CUPS_BACKEND_OK;
fail:
ERROR("Failed to execute %s command\n", sinfonia_cmd_names(cmdhdr->cmd));
return ret;
@ -386,11 +386,11 @@ int sinfonia_flashled(struct sinfonia_usbdev *usbh)
if ((ret = sinfonia_docmd(usbh,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp),
&num)) < 0) {
&num))) {
return ret;
}
return 0;
return CUPS_BACKEND_OK;
}
int sinfonia_canceljob(struct sinfonia_usbdev *usbh, int id)
@ -407,11 +407,11 @@ int sinfonia_canceljob(struct sinfonia_usbdev *usbh, int id)
if ((ret = sinfonia_docmd(usbh,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp),
&num)) < 0) {
&num))) {
return ret;
}
return 0;
return CUPS_BACKEND_OK;
}
int sinfonia_getparam(struct sinfonia_usbdev *usbh, int target, uint32_t *param)
@ -429,11 +429,26 @@ int sinfonia_getparam(struct sinfonia_usbdev *usbh, int target, uint32_t *param)
if ((ret = sinfonia_docmd(usbh,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp),
&num)) < 0) {
&num))) {
// ERROR("Unable to query param id %02x: %s\n",
// target, sinfonia_paramname(usbh, target));
return ret;
}
*param = le32_to_cpu(resp.param);
return ret;
return CUPS_BACKEND_OK;
}
const char *sinfonia_paramname(struct sinfonia_usbdev *usbh,
int id)
{
int i;
for (i = 0 ; i < usbh->params_count ; i++) {
if (usbh->params[i].id == id)
return usbh->params[i].descr;
}
return "Unknown/Not Found!";
}
int sinfonia_dumpallparams(struct sinfonia_usbdev *usbh)
@ -445,7 +460,7 @@ int sinfonia_dumpallparams(struct sinfonia_usbdev *usbh)
ret = sinfonia_getparam(usbh, i, &param);
if (ret)
continue;
DEBUG("%02x: %08x\n", i, param);
DEBUG("%02x (%s): %08x\n", i, sinfonia_paramname(usbh, i), param);
}
return CUPS_BACKEND_OK;
}
@ -466,10 +481,12 @@ int sinfonia_setparam(struct sinfonia_usbdev *usbh, int target, uint32_t param)
if ((ret = sinfonia_docmd(usbh,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp),
&num)) < 0) {
&num))) {
// ERROR("Unable to query param id %02x: %s\n",
// target, sinfonia_paramname(usbh, target));
}
return ret;
return CUPS_BACKEND_OK;
}
int sinfonia_getfwinfo(struct sinfonia_usbdev *usbh)
@ -494,7 +511,7 @@ int sinfonia_getfwinfo(struct sinfonia_usbdev *usbh)
if ((ret = sinfonia_docmd(usbh,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp),
&num)) < 0) {
&num))) {
continue;
}
@ -514,7 +531,7 @@ int sinfonia_getfwinfo(struct sinfonia_usbdev *usbh)
le16_to_cpu(resp.checksum));
#endif
}
return 0;
return CUPS_BACKEND_OK;
}
int sinfonia_geterrorlog(struct sinfonia_usbdev *usbh)
@ -532,7 +549,7 @@ int sinfonia_geterrorlog(struct sinfonia_usbdev *usbh)
if ((ret = sinfonia_docmd(usbh,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp),
&num)) < 0) {
&num))) {
return ret;
}
@ -546,7 +563,7 @@ int sinfonia_geterrorlog(struct sinfonia_usbdev *usbh)
resp.items[i].major, resp.items[i].minor,
usbh->error_codes(resp.items[i].major, resp.items[i].minor));
}
return 0;
return CUPS_BACKEND_OK;
}
int sinfonia_resetcurve(struct sinfonia_usbdev *usbh, int target, int id)
@ -563,11 +580,11 @@ int sinfonia_resetcurve(struct sinfonia_usbdev *usbh, int target, int id)
if ((ret = sinfonia_docmd(usbh,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp),
&num)) < 0) {
&num))) {
return ret;
}
return 0;
return CUPS_BACKEND_OK;
}
int sinfonia_gettonecurve(struct sinfonia_usbdev *usbh, int type, char *fname)
@ -594,7 +611,7 @@ int sinfonia_gettonecurve(struct sinfonia_usbdev *usbh, int type, char *fname)
if ((ret = sinfonia_docmd(usbh,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp),
&num)) < 0) {
&num))) {
return ret;
}
@ -662,11 +679,11 @@ int sinfonia_button_set(struct sinfonia_usbdev *dev, int enable)
if ((ret = sinfonia_docmd(dev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&cmd, sizeof(resp),
&num)) < 0) {
&num))) {
return ret;
}
return 0;
return CUPS_BACKEND_OK;
}
int sinfonia_settonecurve(struct sinfonia_usbdev *usbh, int target, char *fname)
@ -712,7 +729,7 @@ int sinfonia_settonecurve(struct sinfonia_usbdev *usbh, int target, char *fname)
if ((ret = sinfonia_docmd(usbh,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp),
&num)) < 0) {
&num))) {
return ret;
}
@ -781,7 +798,7 @@ int sinfonia_query_serno(struct libusb_device_handle *dev, uint8_t endp_up, uint
if ((ret = sinfonia_docmd(&sdev,
(uint8_t*)&cmd, sizeof(cmd),
(uint8_t*)&resp, sizeof(resp),
&num)) < 0) {
&num))) {
return ret;
}

@ -27,7 +27,7 @@
*
*/
#define LIBSINFONIA_VER "0.11"
#define LIBSINFONIA_VER "0.12"
#define SINFONIA_HDR1_LEN 0x10
#define SINFONIA_HDR2_LEN 0x64
@ -69,6 +69,13 @@ int sinfonia_raw18_read_parse(int data_fd, struct sinfonia_printjob *job);
int sinfonia_raw28_read_parse(int data_fd, struct sinfonia_printjob *job);
void sinfonia_cleanup_job(const void *vjob);
/* mapping param IDs to names */
struct sinfonia_param {
const uint8_t id;
const char *descr;
};
/* Common usb functions */
struct sinfonia_usbdev {
struct libusb_device_handle *dev;
@ -76,6 +83,9 @@ struct sinfonia_usbdev {
uint8_t endp_down;
int type;
const struct sinfonia_param *params;
int params_count;
char const *(*error_codes)(uint8_t major, uint8_t minor);
};
int sinfonia_docmd(struct sinfonia_usbdev *usbh,
@ -95,6 +105,7 @@ int sinfonia_button_set(struct sinfonia_usbdev *dev, int enable);
int sinfonia_query_serno(struct libusb_device_handle *dev, uint8_t endp_up, uint8_t endp_down, char *buf, int buf_len);
int sinfonia_dumpallparams(struct sinfonia_usbdev *usbh);
const char *sinfonia_paramname(struct sinfonia_usbdev *usbh, int id);
#define BANK_STATUS_FREE 0x00
#define BANK_STATUS_XFER 0x01

Loading…
Cancel
Save