summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-01-16 09:41:03 -0500
committerSolomon Peachy <pizza@shaftnet.org>2020-01-16 10:06:07 -0500
commitb6e2916fe0efc5b66a9637357b4ab152c8ab27b3 (patch)
treeb6a39e3610f893398f4976c79c001c317e88ef75
parent255537996f4cc6c4b508625571d719d7b5dc1b76 (diff)
downloadselphy_print-b6e2916fe0efc5b66a9637357b4ab152c8ab27b3.tar.gz
selphy_print-b6e2916fe0efc5b66a9637357b4ab152c8ab27b3.tar.bz2
selphy_print-b6e2916fe0efc5b66a9637357b4ab152c8ab27b3.zip
hiti: Support job pipelining, and much improved job control.
-rw-r--r--backend_hiti.c105
1 files changed, 53 insertions, 52 deletions
diff --git a/backend_hiti.c b/backend_hiti.c
index cd7f460..1143b85 100644
--- a/backend_hiti.c
+++ b/backend_hiti.c
@@ -190,6 +190,20 @@ struct hiti_job {
uint16_t jobid; /* BE */
} __attribute__((packed));
+/* CMD_JC_QQA */
+#define MAX_JOBS 4
+struct hiti_job_qqa {
+ uint8_t count; /* 0-MAX_JOBS */
+ struct {
+ struct hiti_job job;
+ uint8_t status;
+ } row[MAX_JOBS]; /* Four jobs max outstanding */
+} __attribute__((packed));
+
+#define QQA_STATUS_PRINTING 0x00
+#define QQA_STATUS_WAITING 0x01
+#define QQA_STATUS_SUSPENDED 0x03
+
/* CMD_JC_QJC */
struct hiti_jc_qjc {
uint8_t lun; /* Logical Unit Number. Leave at 0 */
@@ -355,7 +369,7 @@ struct hiti_ctx {
/* Prototypes */
static int hiti_doreset(struct hiti_ctx *ctx, uint8_t type);
-static int hiti_query_job_qa(struct hiti_ctx *ctx, struct hiti_job *jobid);
+static int hiti_query_job_qa(struct hiti_ctx *ctx, struct hiti_job *jobid, struct hiti_job_qqa *resp);
static int hiti_query_status(struct hiti_ctx *ctx, uint8_t *sts, uint32_t *err);
static int hiti_query_version(struct hiti_ctx *ctx);
static int hiti_query_matrix(struct hiti_ctx *ctx);
@@ -519,12 +533,24 @@ static const char *hiti_status(uint8_t *sts)
return "Resend Data";
else if (sts[0] & STATUS0_BUSY)
return "Busy";
+ else if (sts[0] & STATUS0_POWERON)
+ return "Powering On";
else if (sts[0] == STATUS_IDLE)
- return "Idle";
+ return "Accepting Jobs";
else
return "Unknown";
}
+static const char *hiti_jobstatuses(uint8_t code)
+{
+ switch (code) {
+ case QQA_STATUS_PRINTING: return "Printing";
+ case QQA_STATUS_WAITING: return "Waiting";
+ case QQA_STATUS_SUSPENDED: return "Suspended";
+ default: return "Unknown";
+ }
+}
+
#define RIBBON_TYPE_4x6 0x01
#define RIBBON_TYPE_5x7 0x02
#define RIBBON_TYPE_6x9 0x03
@@ -779,38 +805,18 @@ static int hiti_get_info(struct hiti_ctx *ctx)
}
/* Use jobid of 0 for "any" */
-static int hiti_query_job_qa(struct hiti_ctx *ctx, struct hiti_job *jobid)
+static int hiti_query_job_qa(struct hiti_ctx *ctx, struct hiti_job *jobid, struct hiti_job_qqa *resp)
{
int ret;
- uint16_t len = 16;
- uint8_t buf[17]; /* Enough for four jobs */
- int i;
+ uint16_t len = sizeof(*resp);
- buf[0] = 0;
+ resp->count = 0;
ret = hiti_docmd_resp(ctx, CMD_JC_QQA,
(uint8_t*) jobid, sizeof(*jobid),
- buf, &len);
+ (uint8_t*) resp, &len);
if (ret)
return ret;
- /* Clear job ID.. */
- jobid->jobid = 0;
-
- for (i = 0 ; i < buf[0] ; i++) {
- // is jobid + status
- // status of 3 is suspended.
- // status of 0 is active.
-
- if (buf[4*i + 4] == 0)
- memcpy(jobid, &buf[4*i+1], sizeof(*jobid));
-
-#if 0
- INFO("Job %02x %02x %02x => %02x\n",
- buf[4*i + 1], buf[4*i + 2],
- buf[4*i + 3], buf[4*i + 4]);
-#endif
- }
-
return CUPS_BACKEND_OK;
}
@@ -818,7 +824,8 @@ static int hiti_get_status(struct hiti_ctx *ctx)
{
uint8_t sts[3];
uint32_t err = 0;
- int ret;
+ int ret, i;
+ struct hiti_job_qqa qqa;
hiti_query_markers(ctx, NULL, NULL);
ret = hiti_query_status(ctx, sts, &err);
@@ -841,9 +848,15 @@ static int hiti_get_status(struct hiti_ctx *ctx)
/* Find out if we have any jobs outstanding */
struct hiti_job job = { 0 };
- hiti_query_job_qa(ctx, &job);
+ hiti_query_job_qa(ctx, &job, &qqa);
+ for (i = 0 ; i < qqa.count ; i++) {
+ INFO("JobID %02x %04x (%s)\n",
+ qqa.row[i].job.lun,
+ be16_to_cpu(qqa.row[i].job.jobid),
+ hiti_jobstatuses(qqa.row[i].status));
+ }
- // XXX other shit.../
+ // XXX other shit...?
return CUPS_BACKEND_OK;
}
@@ -1556,23 +1569,13 @@ static int hiti_main_loop(void *vctx, const void *vjob)
if (err) {
ERROR("Printer reported alert: %08x (%s)\n",
err, hiti_errors(err));
- return CUPS_BACKEND_FAILED;
+ return CUPS_BACKEND_STOP;
}
- /* If we're idle, proceed */
+ /* If we're able to accept jobs, proceed */
if (!(sts[0] & (STATUS0_POWERON|STATUS0_BUSY)))
break;
- jobid.lun = 0;
- jobid.jobid = 0;
- ret = hiti_query_job_qa(ctx, &jobid);
- if (ret)
- return ret;
-
- /* If we have no active job.. proceed! */
- if (jobid.jobid == 0)
- break;
-
sleep(1);
} while(1);
@@ -1723,6 +1726,7 @@ resend_c:
INFO("Waiting for printer acknowledgement\n");
do {
+ struct hiti_job_qqa qqa;
sleep(1);
ret = hiti_query_status(ctx, sts, &err);
@@ -1735,22 +1739,20 @@ resend_c:
return CUPS_BACKEND_FAILED;
}
- /* If we're idle, proceed! */
- if (!(sts[0] & (STATUS0_POWERON|STATUS0_BUSY)))
+ if (fast_return) {
+ INFO("Fast return mode enabled.\n");
break;
+ }
- ret = hiti_query_job_qa(ctx, &jobid);
+ /* See if our job is done.. */
+ ret = hiti_query_job_qa(ctx, &jobid, &qqa);
if (ret)
return ret;
/* If our job is complete.. */
- if (jobid.jobid == 0)
+ if (qqa.count == 0 || qqa.row[0].job.jobid == 0)
break;
- if (fast_return) {
- INFO("Fast return mode enabled.\n");
- break;
- }
} while(1);
INFO("Print complete\n");
@@ -2170,7 +2172,7 @@ static const char *hiti_prefixes[] = {
struct dyesub_backend hiti_backend = {
.name = "HiTi Photo Printers",
- .version = "0.18",
+ .version = "0.19",
.uri_prefixes = hiti_prefixes,
.cmdline_usage = hiti_cmdline,
.cmdline_arg = hiti_cmdline_arg,
@@ -2196,8 +2198,7 @@ struct dyesub_backend hiti_backend = {
- Confirm 6x2" print dimensions (windows?)
- Confirm 5" media works properly
- Figure out stats/counters for non-4x6 sizes
- - Job status & control (QJC, RSJ, QQA)
- - Figure out occasional data transfer hang (related to FW bug?)
+ - Job control (QJC, RSJ) -- and canceling?
- Set highlight adjustment & H/V alignment from cmdline
- Figure out if driver needs to consume highlight adjustment (ie feed into gamma correction?)
- Figure out Windows spool format (probably never)