2013-06-27 22:45:32 -04:00
|
|
|
/*
|
2024-01-05 12:09:41 -05:00
|
|
|
* Kodak 6800/6850 Photo Printer CUPS backend
|
2013-06-27 22:45:32 -04:00
|
|
|
*
|
2024-01-20 17:59:48 -05:00
|
|
|
* (c) 2013-2024 Solomon Peachy <pizza@shaftnet.org>
|
2013-06-27 22:45:32 -04:00
|
|
|
*
|
2014-06-03 20:43:31 -04:00
|
|
|
* Development of this backend was sponsored by:
|
|
|
|
*
|
|
|
|
* LiveLink Technology [ www.livelinktechnology.net ]
|
|
|
|
*
|
2013-06-27 22:45:32 -04:00
|
|
|
* The latest version of this program can be found at:
|
2014-01-13 05:41:48 -05:00
|
|
|
*
|
2024-05-29 20:34:43 -04:00
|
|
|
* https://git.shaftnet.org/gitea/slp/selphy_print.git
|
2014-01-13 05:41:48 -05:00
|
|
|
*
|
2013-06-27 22:45:32 -04:00
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the Free
|
|
|
|
* Software Foundation; either version 3 of the License, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2020-01-17 16:50:56 -05:00
|
|
|
* along with this program; if not, see <https://www.gnu.org/licenses/>.
|
2013-06-27 22:45:32 -04:00
|
|
|
*
|
2017-11-17 13:34:26 -05:00
|
|
|
* SPDX-License-Identifier: GPL-3.0+
|
|
|
|
*
|
2013-06-27 22:45:32 -04:00
|
|
|
*/
|
|
|
|
|
2015-08-13 21:09:56 -04:00
|
|
|
#define BACKEND kodak6800_backend
|
|
|
|
|
2013-07-18 18:03:40 -04:00
|
|
|
#include "backend_common.h"
|
2019-05-13 10:29:00 -04:00
|
|
|
#include "backend_sinfonia.h"
|
2013-07-18 18:03:40 -04:00
|
|
|
|
2013-07-18 20:32:44 -04:00
|
|
|
/* File header */
|
|
|
|
struct kodak6800_hdr {
|
2015-08-25 18:09:51 -04:00
|
|
|
uint8_t hdr[7]; /* Always 03 1b 43 48 43 0a 00 */
|
|
|
|
uint8_t jobid; /* Non-zero */
|
|
|
|
uint16_t copies; /* BE, in BCD format (1-9999) */
|
2013-07-18 20:32:44 -04:00
|
|
|
uint16_t columns; /* BE */
|
|
|
|
uint16_t rows; /* BE */
|
2019-05-11 22:06:47 -04:00
|
|
|
uint8_t size; /* media size; 0x06 for 6x8, 0x00 for 6x4, 0x07 for 5x7 */
|
2013-07-18 20:32:44 -04:00
|
|
|
uint8_t laminate; /* 0x01 to laminate, 0x00 for not */
|
2019-05-11 22:06:47 -04:00
|
|
|
uint8_t method; /* 0x00 or 0x01 (for 4x6 on 6x8 media), 0x21 for 2x6, 0x23 for 3x6 */
|
2014-04-12 12:41:09 -04:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct kodak68x0_status_readback {
|
2014-07-09 19:31:49 -04:00
|
|
|
uint8_t hdr; /* Always 01 */
|
2015-08-25 18:09:51 -04:00
|
|
|
uint8_t status; /* STATUS_* */
|
|
|
|
uint8_t status1; /* STATUS1_* */
|
|
|
|
uint32_t status2; /* STATUS2_* */
|
2014-12-05 22:01:36 -05:00
|
|
|
uint8_t errcode; /* Error ## */
|
2015-08-25 18:09:51 -04:00
|
|
|
uint32_t lifetime; /* Lifetime Prints (BE) */
|
|
|
|
uint32_t maint; /* Maint Prints (BE) */
|
2019-05-11 22:06:47 -04:00
|
|
|
uint32_t media; /* Media Prints (6850), Unknown (6800) (BE) */
|
|
|
|
uint32_t cutter; /* Cutter Actuations (BE) */
|
2014-12-05 22:01:36 -05:00
|
|
|
uint8_t nullB[2];
|
2015-08-25 18:09:51 -04:00
|
|
|
uint8_t errtype; /* seen 0x00 or 0xd0 */
|
|
|
|
uint8_t donor; /* Percentage, 0-100 */
|
|
|
|
uint16_t main_boot; /* Always 003 */
|
2019-05-12 12:55:57 -04:00
|
|
|
uint16_t main_fw; /* seen 6xx/8xx (6850) and 2xx/3xx/4xx (6800) */
|
2015-08-25 18:09:51 -04:00
|
|
|
uint16_t dsp_boot; /* Always 001 */
|
2019-05-12 12:55:57 -04:00
|
|
|
uint16_t dsp_fw; /* Seen 5xx (6850) and 1xx (6800) */
|
2015-08-25 18:09:51 -04:00
|
|
|
uint8_t b1_jobid;
|
|
|
|
uint8_t b2_jobid;
|
|
|
|
uint16_t b1_remain; /* Remaining prints in job */
|
|
|
|
uint16_t b1_complete; /* Completed prints in job */
|
|
|
|
uint16_t b1_total; /* Total prints in job */
|
|
|
|
uint16_t b2_remain; /* Remaining prints in job */
|
|
|
|
uint16_t b2_complete; /* Completed prints in job */
|
|
|
|
uint16_t b2_total; /* Total prints in job */
|
|
|
|
uint8_t curve_status; /* Always seems to be 0x00 */
|
2014-04-12 12:41:09 -04:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
2019-05-11 22:06:47 -04:00
|
|
|
#define MAX_MEDIAS 16
|
2014-06-02 22:16:28 -04:00
|
|
|
|
2014-04-12 12:41:09 -04:00
|
|
|
struct kodak68x0_media_readback {
|
|
|
|
uint8_t hdr; /* Always 0x01 */
|
2016-06-20 21:43:59 -04:00
|
|
|
uint8_t type; /* Media code, KODAK68x0_MEDIA_xxx */
|
2014-04-26 20:20:07 -04:00
|
|
|
uint8_t null[5];
|
2014-04-12 12:41:09 -04:00
|
|
|
uint8_t count; /* Always 0x04 (6800) or 0x06 (6850)? */
|
2019-05-13 10:41:28 -04:00
|
|
|
struct sinfonia_mediainfo_item sizes[];
|
2013-07-18 20:32:44 -04:00
|
|
|
} __attribute__((packed));
|
2013-07-18 18:03:40 -04:00
|
|
|
|
|
|
|
#define CMDBUF_LEN 17
|
|
|
|
|
2017-05-05 08:06:28 -04:00
|
|
|
/* Private data structure */
|
2013-07-18 18:03:40 -04:00
|
|
|
struct kodak6800_ctx {
|
2020-08-11 20:27:26 -04:00
|
|
|
struct dyesub_connection *conn;
|
2013-07-18 18:03:40 -04:00
|
|
|
|
2019-05-11 22:06:47 -04:00
|
|
|
int supports_sub4x6;
|
2015-08-23 19:11:59 -04:00
|
|
|
|
2015-08-25 18:09:51 -04:00
|
|
|
uint8_t jobid;
|
|
|
|
|
2019-05-14 22:30:28 -04:00
|
|
|
struct sinfonia_mediainfo_item sizes[MAX_MEDIAS];
|
2019-05-11 22:06:47 -04:00
|
|
|
uint8_t media_count;
|
|
|
|
uint8_t media_type;
|
|
|
|
|
|
|
|
struct kodak68x0_status_readback sts;
|
2014-10-04 11:55:56 -04:00
|
|
|
|
2019-12-17 13:18:11 -05:00
|
|
|
char serial[32];
|
|
|
|
char fwver[32];
|
|
|
|
|
2018-04-27 15:40:09 -04:00
|
|
|
struct marker marker;
|
2013-07-18 18:03:40 -04:00
|
|
|
};
|
2015-08-27 21:14:09 -04:00
|
|
|
|
|
|
|
/* Baseline commands */
|
|
|
|
static int kodak6800_do_cmd(struct kodak6800_ctx *ctx,
|
2023-11-01 14:11:58 -04:00
|
|
|
const void *cmd, int cmd_len,
|
2019-05-14 22:30:28 -04:00
|
|
|
void *resp, int resp_len,
|
|
|
|
int *actual_len)
|
2015-08-27 21:14:09 -04:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Write command */
|
2020-08-11 20:27:26 -04:00
|
|
|
if ((ret = send_data(ctx->conn,
|
2015-08-27 21:14:09 -04:00
|
|
|
cmd, cmd_len)))
|
|
|
|
return (ret < 0) ? ret : -99;
|
|
|
|
|
|
|
|
/* Read response */
|
2020-08-11 20:27:26 -04:00
|
|
|
ret = read_data(ctx->conn,
|
2015-08-27 21:14:09 -04:00
|
|
|
resp, resp_len, actual_len);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2019-12-12 07:15:25 -05:00
|
|
|
return CUPS_BACKEND_OK;
|
2015-08-27 21:14:09 -04:00
|
|
|
}
|
2013-06-27 23:02:34 -04:00
|
|
|
|
2019-05-14 22:30:28 -04:00
|
|
|
static void kodak68x0_dump_mediainfo(struct sinfonia_mediainfo_item *sizes,
|
|
|
|
uint8_t media_count, uint8_t media_type)
|
|
|
|
{
|
2014-04-12 12:41:09 -04:00
|
|
|
int i;
|
2019-05-12 23:41:04 -04:00
|
|
|
|
|
|
|
if (media_type == KODAK6_MEDIA_NONE) {
|
2015-08-25 22:58:38 -04:00
|
|
|
INFO("No Media Loaded\n");
|
2015-08-24 22:24:46 -04:00
|
|
|
return;
|
|
|
|
}
|
2019-05-12 23:41:04 -04:00
|
|
|
kodak6_dumpmediacommon(media_type);
|
2015-08-24 22:24:46 -04:00
|
|
|
|
2015-08-25 22:58:38 -04:00
|
|
|
INFO("Legal print sizes:\n");
|
2019-05-11 22:06:47 -04:00
|
|
|
for (i = 0 ; i < media_count ; i++) {
|
|
|
|
INFO("\t%d: %dx%d (%02x)\n", i,
|
2019-07-13 10:38:05 -04:00
|
|
|
sizes[i].columns,
|
|
|
|
sizes[i].rows,
|
2019-05-11 22:06:47 -04:00
|
|
|
sizes[i].method);
|
2014-04-12 12:41:09 -04:00
|
|
|
}
|
2015-08-25 22:58:38 -04:00
|
|
|
INFO("\n");
|
2014-04-12 12:41:09 -04:00
|
|
|
}
|
|
|
|
|
2019-09-01 19:41:58 -04:00
|
|
|
static void kodak6800_fillhdr(uint8_t *req, uint8_t cmd)
|
|
|
|
{
|
|
|
|
req[0] = 0x03; /* CMD type */
|
|
|
|
req[1] = 0x1b; /* ESC */
|
|
|
|
req[2] = 0x43; /* C */
|
|
|
|
req[3] = 0x48; /* H */
|
|
|
|
req[4] = 0x43; /* C */
|
|
|
|
req[5] = cmd; /* Commmand code */
|
|
|
|
}
|
|
|
|
|
2019-05-14 22:30:28 -04:00
|
|
|
#define MAX_MEDIA_LEN (sizeof(struct kodak68x0_media_readback) + MAX_MEDIAS * sizeof(struct sinfonia_mediainfo_item))
|
|
|
|
|
2019-05-11 22:06:47 -04:00
|
|
|
static int kodak6800_get_mediainfo(struct kodak6800_ctx *ctx)
|
2014-04-12 12:41:09 -04:00
|
|
|
{
|
2019-05-11 22:06:47 -04:00
|
|
|
struct kodak68x0_media_readback *media;
|
2014-04-12 12:41:09 -04:00
|
|
|
uint8_t req[16];
|
2019-05-11 22:06:47 -04:00
|
|
|
int ret, num, i, j;
|
2014-04-12 12:41:09 -04:00
|
|
|
|
|
|
|
memset(req, 0, sizeof(req));
|
2019-05-11 22:06:47 -04:00
|
|
|
media = malloc(MAX_MEDIA_LEN);
|
|
|
|
if (!media) {
|
|
|
|
ERROR("Memory allocation failure!\n");
|
|
|
|
return CUPS_BACKEND_RETRY_CURRENT;
|
|
|
|
}
|
2014-04-12 12:41:09 -04:00
|
|
|
|
2019-05-11 22:06:47 -04:00
|
|
|
for (j = 0 ; j < 2 ; j ++) {
|
|
|
|
memset(media, 0, sizeof(*media));
|
2019-09-01 19:41:58 -04:00
|
|
|
kodak6800_fillhdr(req, 0x1a);
|
2019-05-11 22:06:47 -04:00
|
|
|
req[6] = j;
|
2014-10-04 11:55:56 -04:00
|
|
|
|
2019-05-11 22:06:47 -04:00
|
|
|
/* Issue command and get response */
|
|
|
|
if ((ret = kodak6800_do_cmd(ctx, req, sizeof(req),
|
|
|
|
media, MAX_MEDIA_LEN,
|
2019-05-26 13:05:41 -04:00
|
|
|
&num))) {
|
|
|
|
free(media);
|
2019-05-11 22:06:47 -04:00
|
|
|
return ret;
|
2019-05-26 13:05:41 -04:00
|
|
|
}
|
2019-05-11 22:06:47 -04:00
|
|
|
|
|
|
|
/* Validate proper response */
|
|
|
|
if (media->hdr != CMD_CODE_OK ||
|
|
|
|
media->null[0] != 0x00) {
|
|
|
|
ERROR("Unexpected response from media query!\n");
|
2019-05-26 13:05:41 -04:00
|
|
|
free(media);
|
2019-05-11 22:06:47 -04:00
|
|
|
return CUPS_BACKEND_STOP;
|
|
|
|
}
|
|
|
|
ctx->media_type = media->type;
|
|
|
|
|
|
|
|
for (i = 0; i < media->count ; i++) {
|
2019-05-13 10:41:28 -04:00
|
|
|
memcpy(&ctx->sizes[ctx->media_count], &media->sizes[i], sizeof(struct sinfonia_mediainfo_item));
|
2019-07-13 10:38:05 -04:00
|
|
|
ctx->sizes[ctx->media_count].rows = be16_to_cpu(ctx->sizes[ctx->media_count].rows);
|
|
|
|
ctx->sizes[ctx->media_count].columns = be16_to_cpu(ctx->sizes[ctx->media_count].columns);
|
2019-05-11 22:06:47 -04:00
|
|
|
ctx->media_count++;
|
|
|
|
}
|
|
|
|
if (i < 6)
|
|
|
|
break;
|
2014-10-04 11:55:56 -04:00
|
|
|
}
|
|
|
|
|
2019-05-12 08:17:56 -04:00
|
|
|
free(media);
|
2019-05-11 22:06:47 -04:00
|
|
|
return CUPS_BACKEND_OK;
|
2014-04-12 12:41:09 -04:00
|
|
|
}
|
2013-06-27 22:45:32 -04:00
|
|
|
|
2015-08-25 18:09:51 -04:00
|
|
|
static int kodak68x0_canceljob(struct kodak6800_ctx *ctx,
|
|
|
|
int id)
|
2015-08-24 22:24:46 -04:00
|
|
|
{
|
2015-08-25 18:09:51 -04:00
|
|
|
uint8_t req[16];
|
|
|
|
int ret, num;
|
|
|
|
|
|
|
|
memset(req, 0, sizeof(req));
|
2019-09-01 19:41:58 -04:00
|
|
|
kodak6800_fillhdr(req, 0x13);
|
2015-08-25 18:09:51 -04:00
|
|
|
req[6] = id;
|
|
|
|
|
2015-08-27 21:14:09 -04:00
|
|
|
/* Issue command and get response */
|
|
|
|
if ((ret = kodak6800_do_cmd(ctx, req, sizeof(req),
|
2019-05-11 22:06:47 -04:00
|
|
|
&ctx->sts, sizeof(ctx->sts),
|
2015-08-27 21:14:09 -04:00
|
|
|
&num)))
|
2015-08-25 18:09:51 -04:00
|
|
|
return ret;
|
|
|
|
|
2015-08-27 21:14:09 -04:00
|
|
|
/* Validate proper response */
|
2019-05-11 22:06:47 -04:00
|
|
|
if (ctx->sts.hdr != CMD_CODE_OK) {
|
2015-08-27 21:14:09 -04:00
|
|
|
ERROR("Unexpected response from job cancel!\n");
|
|
|
|
return -99;
|
2015-08-24 22:24:46 -04:00
|
|
|
}
|
2015-08-27 21:14:09 -04:00
|
|
|
|
2019-12-12 07:15:25 -05:00
|
|
|
return CUPS_BACKEND_OK;
|
2015-08-25 18:09:51 -04:00
|
|
|
}
|
|
|
|
|
2016-06-28 10:28:42 -04:00
|
|
|
static int kodak68x0_reset(struct kodak6800_ctx *ctx)
|
|
|
|
{
|
|
|
|
uint8_t req[16];
|
|
|
|
int ret, num;
|
|
|
|
|
|
|
|
memset(req, 0, sizeof(req));
|
2019-09-01 19:41:58 -04:00
|
|
|
kodak6800_fillhdr(req, 0xc0);
|
2016-06-28 10:28:42 -04:00
|
|
|
|
|
|
|
/* Issue command and get response */
|
|
|
|
if ((ret = kodak6800_do_cmd(ctx, req, sizeof(req),
|
2019-05-11 22:06:47 -04:00
|
|
|
&ctx->sts, sizeof(ctx->sts),
|
2016-06-28 10:28:42 -04:00
|
|
|
&num)))
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* Validate proper response */
|
2019-05-11 22:06:47 -04:00
|
|
|
if (ctx->sts.hdr != CMD_CODE_OK) {
|
2016-06-28 10:28:42 -04:00
|
|
|
ERROR("Unexpected response from job cancel!\n");
|
|
|
|
return -99;
|
|
|
|
}
|
|
|
|
|
2019-12-12 07:15:25 -05:00
|
|
|
return CUPS_BACKEND_OK;
|
2016-06-28 10:28:42 -04:00
|
|
|
}
|
|
|
|
|
2014-10-04 11:55:56 -04:00
|
|
|
static void kodak68x0_dump_status(struct kodak6800_ctx *ctx, struct kodak68x0_status_readback *status)
|
2014-06-02 22:16:28 -04:00
|
|
|
{
|
2020-03-24 18:22:39 -04:00
|
|
|
const char *detail;
|
2015-08-25 18:09:51 -04:00
|
|
|
|
|
|
|
switch (status->status) {
|
|
|
|
case STATUS_PRINTING:
|
|
|
|
detail = "Printing";
|
|
|
|
break;
|
|
|
|
case STATUS_IDLE:
|
|
|
|
detail = "Idle";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
detail = "Unknown";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
INFO("Printer Status : %s\n", detail);
|
|
|
|
|
|
|
|
INFO("Printer State : %s # %02x %08x %02x\n",
|
2019-05-12 12:55:57 -04:00
|
|
|
sinfonia_1x45_status_str(status->status1, status->status2, status->errcode),
|
|
|
|
status->status1, status->status2, status->errcode);
|
2015-08-25 18:09:51 -04:00
|
|
|
|
2016-08-21 10:23:00 -04:00
|
|
|
INFO("Bank 1 ID: %u\n", status->b1_jobid);
|
2015-08-25 18:09:51 -04:00
|
|
|
INFO("\tPrints: %d/%d complete\n",
|
|
|
|
be16_to_cpu(status->b1_complete), be16_to_cpu(status->b1_total));
|
2016-08-21 10:23:00 -04:00
|
|
|
INFO("Bank 2 ID: %u\n", status->b2_jobid);
|
2015-08-25 18:09:51 -04:00
|
|
|
INFO("\tPrints: %d/%d complete\n",
|
|
|
|
be16_to_cpu(status->b2_complete), be16_to_cpu(status->b2_total));
|
|
|
|
|
2015-08-27 21:41:47 -04:00
|
|
|
switch (status->curve_status) {
|
|
|
|
case CURVE_TABLE_STATUS_INITIAL:
|
|
|
|
detail = "Initial/Default";
|
|
|
|
break;
|
|
|
|
case CURVE_TABLE_STATUS_USERSET:
|
|
|
|
detail = "User Stored";
|
|
|
|
break;
|
|
|
|
case CURVE_TABLE_STATUS_CURRENT:
|
|
|
|
detail = "Current";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
detail = "Unknown";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
INFO("Tone Curve Status: %s\n", detail);
|
|
|
|
|
2015-08-25 18:09:51 -04:00
|
|
|
INFO("Counters:\n");
|
2016-08-21 10:23:00 -04:00
|
|
|
INFO("\tLifetime : %u\n", be32_to_cpu(status->lifetime));
|
|
|
|
INFO("\tThermal Head : %u\n", be32_to_cpu(status->maint));
|
|
|
|
INFO("\tCutter : %u\n", be32_to_cpu(status->cutter));
|
2015-08-24 22:24:46 -04:00
|
|
|
|
2020-08-11 20:27:26 -04:00
|
|
|
if (ctx->conn->type == P_KODAK_6850) {
|
2019-09-08 21:33:30 -04:00
|
|
|
int max = kodak6_mediamax(ctx->media_type);
|
2015-08-25 18:09:51 -04:00
|
|
|
|
2016-08-21 10:23:00 -04:00
|
|
|
INFO("\tMedia : %u\n", be32_to_cpu(status->media));
|
2015-08-25 18:09:51 -04:00
|
|
|
|
2014-10-04 11:55:56 -04:00
|
|
|
if (max) {
|
2019-05-14 23:06:39 -04:00
|
|
|
INFO("\t Remaining : %u\n", max - be32_to_cpu(status->media));
|
2014-10-04 11:55:56 -04:00
|
|
|
} else {
|
2016-08-17 20:32:48 -04:00
|
|
|
INFO("\t Remaining : Unknown\n");
|
2014-10-04 11:55:56 -04:00
|
|
|
}
|
|
|
|
}
|
2016-08-17 20:32:48 -04:00
|
|
|
INFO("Main FW version : %d\n", be16_to_cpu(status->main_fw));
|
|
|
|
INFO("DSP FW version : %d\n", be16_to_cpu(status->dsp_fw));
|
2016-08-21 10:23:00 -04:00
|
|
|
INFO("Donor : %u%%\n", status->donor);
|
2015-08-25 18:09:51 -04:00
|
|
|
INFO("\n");
|
2014-06-02 22:16:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int kodak6800_get_status(struct kodak6800_ctx *ctx,
|
|
|
|
struct kodak68x0_status_readback *status)
|
|
|
|
{
|
|
|
|
uint8_t req[16];
|
|
|
|
int ret, num;
|
|
|
|
|
|
|
|
memset(req, 0, sizeof(req));
|
|
|
|
memset(status, 0, sizeof(*status));
|
|
|
|
|
2019-09-01 19:41:58 -04:00
|
|
|
kodak6800_fillhdr(req, 0x03);
|
2014-06-02 22:16:28 -04:00
|
|
|
|
2015-08-27 21:14:09 -04:00
|
|
|
/* Issue command and get response */
|
|
|
|
if ((ret = kodak6800_do_cmd(ctx, req, sizeof(req),
|
|
|
|
status, sizeof(*status),
|
|
|
|
&num)))
|
2014-06-02 22:16:28 -04:00
|
|
|
return ret;
|
|
|
|
|
2015-08-27 21:14:09 -04:00
|
|
|
/* Validate proper response */
|
2015-08-27 21:41:47 -04:00
|
|
|
if (status->hdr != CMD_CODE_OK) {
|
2014-07-08 21:31:10 -04:00
|
|
|
ERROR("Unexpected response from status query!\n");
|
2015-08-27 21:14:09 -04:00
|
|
|
return -99;
|
2014-06-02 22:16:28 -04:00
|
|
|
}
|
|
|
|
|
2019-05-12 12:55:57 -04:00
|
|
|
/* Byteswap important stuff */
|
|
|
|
status->status2 = be32_to_cpu(status->status2);
|
|
|
|
|
2019-12-12 07:15:25 -05:00
|
|
|
return CUPS_BACKEND_OK;
|
2014-06-02 22:16:28 -04:00
|
|
|
}
|
|
|
|
|
2019-08-30 10:33:20 -04:00
|
|
|
static int kodak6800_get_tonecurve(struct kodak6800_ctx *ctx, uint8_t curve, char *fname)
|
2013-07-08 21:59:51 -04:00
|
|
|
{
|
|
|
|
uint8_t cmdbuf[16];
|
|
|
|
uint8_t respbuf[64];
|
|
|
|
int ret, num = 0;
|
|
|
|
int i;
|
|
|
|
|
2019-09-22 23:26:55 -04:00
|
|
|
uint16_t *data = malloc(TONE_CURVE_SIZE * sizeof(uint16_t));
|
2015-06-23 20:32:41 -04:00
|
|
|
if (!data) {
|
|
|
|
ERROR("Memory Allocation Failure\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2013-07-08 21:59:51 -04:00
|
|
|
|
|
|
|
INFO("Dump Tone Curve to '%s'\n", fname);
|
|
|
|
|
|
|
|
/* Initial Request */
|
2019-09-01 19:41:58 -04:00
|
|
|
kodak6800_fillhdr(cmdbuf, 0x0c);
|
2013-07-08 21:59:51 -04:00
|
|
|
cmdbuf[6] = 0x54;
|
|
|
|
cmdbuf[7] = 0x4f;
|
|
|
|
cmdbuf[8] = 0x4e;
|
|
|
|
cmdbuf[9] = 0x45;
|
|
|
|
cmdbuf[10] = 0x72;
|
2019-08-30 10:33:20 -04:00
|
|
|
cmdbuf[11] = curve;
|
|
|
|
cmdbuf[12] = PARAM_TABLE_NONE;
|
2013-07-08 21:59:51 -04:00
|
|
|
cmdbuf[13] = 0x00;
|
|
|
|
cmdbuf[14] = 0x00;
|
|
|
|
cmdbuf[15] = 0x00;
|
|
|
|
|
2018-04-27 10:17:16 -04:00
|
|
|
respbuf[0] = 0xff;
|
2015-08-27 21:14:09 -04:00
|
|
|
/* Issue command and get response */
|
|
|
|
if ((ret = kodak6800_do_cmd(ctx, cmdbuf, sizeof(cmdbuf),
|
|
|
|
respbuf, sizeof(respbuf),
|
|
|
|
&num)))
|
|
|
|
|
|
|
|
/* Validate proper response */
|
2015-08-27 21:41:47 -04:00
|
|
|
if (respbuf[0] != CMD_CODE_OK) {
|
2015-08-27 21:14:09 -04:00
|
|
|
ERROR("Unexpected response from tonecurve query!\n");
|
2015-09-13 09:56:27 -04:00
|
|
|
ret = -99;
|
|
|
|
goto done;
|
2013-07-08 21:59:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Then we can poll the data */
|
2019-09-01 19:41:58 -04:00
|
|
|
kodak6800_fillhdr(cmdbuf, 0x0c);
|
2013-07-08 21:59:51 -04:00
|
|
|
cmdbuf[6] = 0x54;
|
|
|
|
cmdbuf[7] = 0x4f;
|
|
|
|
cmdbuf[8] = 0x4e;
|
|
|
|
cmdbuf[9] = 0x45;
|
|
|
|
cmdbuf[10] = 0x20;
|
|
|
|
for (i = 0 ; i < 24 ; i++) {
|
2015-08-27 21:14:09 -04:00
|
|
|
/* Issue command and get response */
|
|
|
|
if ((ret = kodak6800_do_cmd(ctx, cmdbuf, sizeof(cmdbuf),
|
|
|
|
respbuf, sizeof(respbuf),
|
|
|
|
&num)))
|
2014-02-11 20:11:33 -05:00
|
|
|
goto done;
|
|
|
|
|
2013-12-21 22:55:33 -05:00
|
|
|
if (num != 64) {
|
|
|
|
ERROR("Short read! (%d/%d)\n", num, 51);
|
2014-02-11 20:11:33 -05:00
|
|
|
ret = 4;
|
|
|
|
goto done;
|
2013-07-08 21:59:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy into buffer */
|
|
|
|
memcpy(((uint8_t*)data)+i*64, respbuf, 64);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Open file and write it out */
|
|
|
|
{
|
2013-11-25 09:09:29 -05:00
|
|
|
int tc_fd = open(fname, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR);
|
2014-02-11 20:11:33 -05:00
|
|
|
if (tc_fd < 0) {
|
|
|
|
ret = 4;
|
|
|
|
goto done;
|
|
|
|
}
|
2013-11-25 09:09:29 -05:00
|
|
|
|
2019-09-22 23:26:55 -04:00
|
|
|
for (i = 0 ; i < TONE_CURVE_SIZE; i++) {
|
2013-07-08 21:59:51 -04:00
|
|
|
/* Byteswap appropriately */
|
|
|
|
data[i] = cpu_to_be16(le16_to_cpu(data[i]));
|
2019-07-15 23:35:54 -04:00
|
|
|
ret = write(tc_fd, &data[i], sizeof(uint16_t));
|
2013-07-08 21:59:51 -04:00
|
|
|
}
|
|
|
|
close(tc_fd);
|
|
|
|
}
|
|
|
|
|
2014-02-11 20:11:33 -05:00
|
|
|
done:
|
2013-07-08 21:59:51 -04:00
|
|
|
/* We're done */
|
|
|
|
free(data);
|
|
|
|
|
2015-07-04 11:03:52 -04:00
|
|
|
return ret;
|
2013-07-08 21:59:51 -04:00
|
|
|
}
|
|
|
|
|
2019-08-30 10:33:20 -04:00
|
|
|
static int kodak6800_set_tonecurve(struct kodak6800_ctx *ctx, uint8_t curve, char *fname)
|
2013-07-08 22:33:54 -04:00
|
|
|
{
|
|
|
|
uint8_t cmdbuf[64];
|
|
|
|
uint8_t respbuf[64];
|
|
|
|
int ret, num = 0;
|
|
|
|
int remain;
|
|
|
|
|
2019-09-22 23:26:55 -04:00
|
|
|
uint16_t *data = malloc(TONE_CURVE_SIZE * sizeof(uint16_t));
|
2013-07-08 22:33:54 -04:00
|
|
|
uint8_t *ptr;
|
|
|
|
|
2015-06-23 20:32:41 -04:00
|
|
|
if (!data) {
|
|
|
|
ERROR("Memory Allocation Failure\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2015-08-25 18:09:51 -04:00
|
|
|
|
2013-07-08 22:33:54 -04:00
|
|
|
INFO("Set Tone Curve from '%s'\n", fname);
|
|
|
|
|
|
|
|
/* Read in file */
|
2019-09-22 23:26:55 -04:00
|
|
|
if ((ret = dyesub_read_file(fname, data, TONE_CURVE_SIZE * sizeof(uint16_t), NULL))) {
|
2019-01-13 15:44:29 -05:00
|
|
|
ERROR("Failed to read Tone Curve file\n");
|
2014-02-11 20:11:33 -05:00
|
|
|
goto done;
|
|
|
|
}
|
2013-07-08 22:33:54 -04:00
|
|
|
|
|
|
|
/* Byteswap data to printer's format */
|
2019-09-22 23:26:55 -04:00
|
|
|
for (ret = 0; ret < TONE_CURVE_SIZE ; ret++) {
|
2013-07-08 22:33:54 -04:00
|
|
|
data[ret] = cpu_to_le16(be16_to_cpu(data[ret]));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initial Request */
|
2019-09-01 19:41:58 -04:00
|
|
|
kodak6800_fillhdr(cmdbuf, 0x0c);
|
2013-07-08 22:33:54 -04:00
|
|
|
cmdbuf[6] = 0x54;
|
|
|
|
cmdbuf[7] = 0x4f;
|
|
|
|
cmdbuf[8] = 0x4e;
|
|
|
|
cmdbuf[9] = 0x45;
|
|
|
|
cmdbuf[10] = 0x77;
|
2019-08-30 10:33:20 -04:00
|
|
|
cmdbuf[11] = curve;
|
|
|
|
cmdbuf[12] = PARAM_TABLE_NONE;
|
2013-07-08 22:33:54 -04:00
|
|
|
cmdbuf[13] = 0x00;
|
|
|
|
cmdbuf[14] = 0x00;
|
|
|
|
cmdbuf[15] = 0x00;
|
|
|
|
|
2015-08-27 21:14:09 -04:00
|
|
|
/* Issue command and get response */
|
|
|
|
if ((ret = kodak6800_do_cmd(ctx, cmdbuf, sizeof(cmdbuf),
|
|
|
|
respbuf, sizeof(respbuf),
|
|
|
|
&num)))
|
2015-08-25 18:09:51 -04:00
|
|
|
|
2015-08-27 21:14:09 -04:00
|
|
|
/* Validate proper response */
|
2013-12-21 22:55:33 -05:00
|
|
|
if (num != 51) {
|
|
|
|
ERROR("Short read! (%d/%d)\n", num, 51);
|
2014-02-11 20:11:33 -05:00
|
|
|
ret = 4;
|
|
|
|
goto done;
|
2013-07-08 22:33:54 -04:00
|
|
|
}
|
|
|
|
|
2015-08-27 21:41:47 -04:00
|
|
|
if (respbuf[0] != CMD_CODE_OK) {
|
2015-08-27 21:14:09 -04:00
|
|
|
ERROR("Unexpected response from tonecurve set!\n");
|
2015-09-13 09:56:27 -04:00
|
|
|
ret = -99;
|
|
|
|
goto done;
|
2015-08-27 21:14:09 -04:00
|
|
|
}
|
|
|
|
|
2013-07-08 22:33:54 -04:00
|
|
|
ptr = (uint8_t*) data;
|
2019-09-22 23:26:55 -04:00
|
|
|
remain = TONE_CURVE_SIZE * sizeof(uint16_t);
|
2013-07-08 22:33:54 -04:00
|
|
|
while (remain > 0) {
|
|
|
|
int count = remain > 63 ? 63 : remain;
|
|
|
|
|
|
|
|
cmdbuf[0] = 0x03;
|
|
|
|
memcpy(cmdbuf+1, ptr, count);
|
|
|
|
|
|
|
|
remain -= count;
|
|
|
|
ptr += count;
|
|
|
|
|
2015-08-27 21:14:09 -04:00
|
|
|
/* Issue command and get response */
|
|
|
|
if ((ret = kodak6800_do_cmd(ctx, cmdbuf, count + 1,
|
|
|
|
respbuf, sizeof(respbuf),
|
|
|
|
&num)))
|
2013-12-21 22:55:33 -05:00
|
|
|
|
|
|
|
if (num != 51) {
|
|
|
|
ERROR("Short read! (%d/%d)\n", num, 51);
|
2014-02-11 20:11:33 -05:00
|
|
|
ret = 4;
|
|
|
|
goto done;
|
2013-07-08 22:33:54 -04:00
|
|
|
}
|
2015-08-27 21:41:47 -04:00
|
|
|
if (respbuf[0] != CMD_CODE_OK) {
|
2015-08-27 21:14:09 -04:00
|
|
|
ERROR("Unexpected response from tonecurve set!\n");
|
2015-09-13 09:56:27 -04:00
|
|
|
ret = -99;
|
|
|
|
goto done;
|
2015-08-27 21:14:09 -04:00
|
|
|
}
|
2013-07-08 22:33:54 -04:00
|
|
|
};
|
2015-08-27 21:14:09 -04:00
|
|
|
|
2014-02-11 20:11:33 -05:00
|
|
|
done:
|
2013-07-08 22:33:54 -04:00
|
|
|
/* We're done */
|
|
|
|
free(data);
|
2014-02-11 20:11:33 -05:00
|
|
|
return ret;
|
2013-07-08 22:33:54 -04:00
|
|
|
}
|
|
|
|
|
2020-08-11 20:27:26 -04:00
|
|
|
static int kodak6800_query_serno(struct dyesub_connection *conn, char *buf, int buf_len)
|
2014-04-12 12:41:09 -04:00
|
|
|
{
|
2015-08-27 21:14:09 -04:00
|
|
|
struct kodak6800_ctx ctx = {
|
2020-08-11 20:27:26 -04:00
|
|
|
.conn = conn,
|
2015-08-27 21:14:09 -04:00
|
|
|
};
|
|
|
|
|
2014-04-12 12:41:09 -04:00
|
|
|
int ret;
|
|
|
|
int num;
|
|
|
|
|
|
|
|
uint8_t resp[33];
|
|
|
|
uint8_t req[16];
|
|
|
|
|
|
|
|
memset(req, 0, sizeof(req));
|
|
|
|
memset(resp, 0, sizeof(resp));
|
|
|
|
|
2019-09-01 19:41:58 -04:00
|
|
|
kodak6800_fillhdr(req, 0x12);
|
2014-04-12 12:41:09 -04:00
|
|
|
|
2015-08-27 21:14:09 -04:00
|
|
|
/* Issue command and get response */
|
|
|
|
if ((ret = kodak6800_do_cmd(&ctx, req, sizeof(req),
|
|
|
|
resp, sizeof(resp),
|
|
|
|
&num)))
|
2014-04-12 12:41:09 -04:00
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (num != 32) {
|
|
|
|
ERROR("Short read! (%d/%d)\n", num, 32);
|
2015-08-27 21:14:09 -04:00
|
|
|
return -2;
|
2014-04-12 12:41:09 -04:00
|
|
|
}
|
2015-08-27 21:14:09 -04:00
|
|
|
|
2014-04-12 12:41:09 -04:00
|
|
|
strncpy(buf, (char*)resp+24, buf_len);
|
|
|
|
buf[buf_len-1] = 0;
|
|
|
|
|
2019-12-12 07:15:25 -05:00
|
|
|
return CUPS_BACKEND_OK;
|
2014-04-12 12:41:09 -04:00
|
|
|
}
|
|
|
|
|
2016-08-18 21:03:53 -04:00
|
|
|
static int kodak6850_send_unk(struct kodak6800_ctx *ctx)
|
2014-07-09 19:31:49 -04:00
|
|
|
{
|
2015-08-27 21:14:09 -04:00
|
|
|
uint8_t cmdbuf[16];
|
2014-07-09 19:31:49 -04:00
|
|
|
uint8_t rdbuf[64];
|
|
|
|
int ret = 0, num = 0;
|
|
|
|
|
2015-08-27 21:14:09 -04:00
|
|
|
memset(cmdbuf, 0, sizeof(cmdbuf));
|
2019-09-01 19:41:58 -04:00
|
|
|
kodak6800_fillhdr(cmdbuf, 0x4c);
|
2015-08-25 18:09:51 -04:00
|
|
|
|
2015-08-27 21:14:09 -04:00
|
|
|
/* Issue command and get response */
|
|
|
|
if ((ret = kodak6800_do_cmd(ctx, cmdbuf, sizeof(cmdbuf),
|
|
|
|
rdbuf, sizeof(rdbuf),
|
|
|
|
&num)))
|
|
|
|
return -1;
|
2015-08-25 18:09:51 -04:00
|
|
|
|
2014-07-09 19:31:49 -04:00
|
|
|
if (num != 51) {
|
2015-08-27 21:14:09 -04:00
|
|
|
ERROR("Short read! (%d/%d)\n", num, 51);
|
2014-07-09 19:31:49 -04:00
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
}
|
2015-08-25 18:09:51 -04:00
|
|
|
|
2015-08-27 21:41:47 -04:00
|
|
|
if (rdbuf[0] != CMD_CODE_OK ||
|
2014-07-09 19:31:49 -04:00
|
|
|
rdbuf[2] != 0x43) {
|
|
|
|
ERROR("Unexpected response from printer init!\n");
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
}
|
2015-08-25 18:09:51 -04:00
|
|
|
|
2014-07-09 19:31:49 -04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-02-10 20:10:36 -05:00
|
|
|
static void kodak6800_cmdline(void)
|
2013-06-27 22:45:32 -04:00
|
|
|
{
|
2019-08-30 10:33:20 -04:00
|
|
|
DEBUG("\t\t[ -c filename ] # Get user/NV tone curve\n");
|
|
|
|
DEBUG("\t\t[ -C filename ] # Set user/NV tone curve\n");
|
|
|
|
DEBUG("\t\t[ -l filename ] # Get current tone curve\n");
|
|
|
|
DEBUG("\t\t[ -L filename ] # Set current tone curve\n");
|
2014-04-12 12:41:09 -04:00
|
|
|
DEBUG("\t\t[ -m ] # Query media\n");
|
2014-06-02 22:16:28 -04:00
|
|
|
DEBUG("\t\t[ -s ] # Query status\n");
|
2016-06-28 10:28:42 -04:00
|
|
|
DEBUG("\t\t[ -R ] # Reset printer\n");
|
2017-07-10 20:15:56 -04:00
|
|
|
DEBUG("\t\t[ -X jobid ] # Cancel Job\n");
|
2013-07-18 18:03:40 -04:00
|
|
|
}
|
2013-06-27 22:45:32 -04:00
|
|
|
|
2014-02-10 20:10:36 -05:00
|
|
|
static int kodak6800_cmdline_arg(void *vctx, int argc, char **argv)
|
2013-07-18 18:03:40 -04:00
|
|
|
{
|
|
|
|
struct kodak6800_ctx *ctx = vctx;
|
2014-02-11 22:45:14 -05:00
|
|
|
int i, j = 0;
|
2013-06-27 22:45:32 -04:00
|
|
|
|
2015-08-24 17:28:10 -04:00
|
|
|
if (!ctx)
|
|
|
|
return -1;
|
|
|
|
|
2019-08-30 10:33:20 -04:00
|
|
|
while ((i = getopt(argc, argv, GETOPT_LIST_GLOBAL "C:c:L:l:mRsX:")) >= 0) {
|
2014-02-10 20:10:36 -05:00
|