summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2019-09-28 10:54:10 -0400
committerSolomon Peachy <pizza@shaftnet.org>2019-09-28 10:54:10 -0400
commita06a81d1e98166f0cd5b5ef634ae41ec83366873 (patch)
tree9ba72de4b97f13f7e5bcaf703ee70a935957dd7d
parent49ed0497a99c337138d8492e00c1a3368c997567 (diff)
downloadselphy_print-a06a81d1e98166f0cd5b5ef634ae41ec83366873.tar.gz
selphy_print-a06a81d1e98166f0cd5b5ef634ae41ec83366873.tar.bz2
selphy_print-a06a81d1e98166f0cd5b5ef634ae41ec83366873.zip
all: Report up the low-level media ID as a PPD attribute.
(Needs changes to Gutenprint in order to be useful...)
-rw-r--r--backend_canonselphy.c15
-rw-r--r--backend_canonselphyneo.c1
-rw-r--r--backend_common.c8
-rw-r--r--backend_common.h2
-rw-r--r--backend_dnpds40.c2
-rw-r--r--backend_hiti.c1
-rw-r--r--backend_kodak1400.c1
-rw-r--r--backend_kodak605.c1
-rw-r--r--backend_kodak6800.c1
-rw-r--r--backend_magicard.c1
-rw-r--r--backend_mitsu70x.c2
-rw-r--r--backend_mitsu9550.c1
-rw-r--r--backend_mitsud90.c1
-rw-r--r--backend_mitsup95d.c1
-rw-r--r--backend_shinkos1245.c1
-rw-r--r--backend_shinkos2145.c1
-rw-r--r--backend_shinkos6145.c1
-rw-r--r--backend_shinkos6245.c1
-rw-r--r--backend_sonyupd.c1
-rw-r--r--backend_sonyupdneo.c3
20 files changed, 39 insertions, 7 deletions
diff --git a/backend_canonselphy.c b/backend_canonselphy.c
index c9510f8..3573edb 100644
--- a/backend_canonselphy.c
+++ b/backend_canonselphy.c
@@ -95,10 +95,10 @@ struct printer_data {
int8_t paper_code_offset; /* Offset in readback for paper type */
int8_t paper_code_offset2; /* Offset in readback for paper type (2nd) */
uint8_t (*error_detect)(uint8_t *rdbuf);
- char *(*pgcode_names)(uint8_t *rdbuf, struct printer_data *printer);
+ char *(*pgcode_names)(uint8_t *rdbuf, struct printer_data *printer, int *numtype);
};
-static char *generic_pgcode_names(uint8_t *rdbuf, struct printer_data *printer)
+static char *generic_pgcode_names(uint8_t *rdbuf, struct printer_data *printer, int *numtype)
{
uint8_t pgcode = 0, pgcode2 = 0;
@@ -107,6 +107,8 @@ static char *generic_pgcode_names(uint8_t *rdbuf, struct printer_data *printer)
if (printer->paper_code_offset2 != -1)
pgcode2 = rdbuf[printer->paper_code_offset2];
+ *numtype = pgcode & 0xf;
+
switch(pgcode & 0xf) {
case 0x01: return "P";
case 0x02: return "L";
@@ -237,11 +239,12 @@ static uint8_t cp790_error_detect(uint8_t *rdbuf)
return 0;
}
-static char *cp10_pgcode_names(uint8_t *rdbuf, struct printer_data *printer)
+static char *cp10_pgcode_names(uint8_t *rdbuf, struct printer_data *printer, int *numtype)
{
UNUSED(rdbuf);
UNUSED(printer);
+ *numtype = 3;
return "C"; /* Printer only supports one media type */
}
@@ -580,7 +583,7 @@ static int canonselphy_get_status(struct canonselphy_ctx *ctx)
if (ret < 0)
return CUPS_BACKEND_FAILED;
- INFO("Media type: %s\n", ctx->printer->pgcode_names? ctx->printer->pgcode_names(rdbuf, ctx->printer) : "Unknown");
+ INFO("Media type: %s\n", ctx->printer->pgcode_names? ctx->printer->pgcode_names(rdbuf, ctx->printer, &ret) : "Unknown");
ctx->printer->error_detect(rdbuf);
return CUPS_BACKEND_OK;
@@ -665,11 +668,13 @@ static int canonselphy_attach(void *vctx, struct libusb_device_handle *dev, int
ctx->marker.levelnow = 0; /* Out of media */
else
ctx->marker.levelnow = -3; /* Unknown but OK */
- ctx->marker.name = ctx->printer->pgcode_names? ctx->printer->pgcode_names(rdbuf, ctx->printer) : "Unknown";
+
+ ctx->marker.name = ctx->printer->pgcode_names? ctx->printer->pgcode_names(rdbuf, ctx->printer, &ctx->marker.numtype) : "Unknown";
} else {
// XXX handle MEDIA_CODE at some point.
// we don't do any error checking here.
ctx->marker.name = "Unknown";
+ ctx->marker.numtype = -1;
}
return CUPS_BACKEND_OK;
diff --git a/backend_canonselphyneo.c b/backend_canonselphyneo.c
index 905728d..4b0f7de 100644
--- a/backend_canonselphyneo.c
+++ b/backend_canonselphyneo.c
@@ -233,6 +233,7 @@ static int selphyneo_attach(void *vctx, struct libusb_device_handle *dev, int ty
ctx->marker.color = "#00FFFF#FF00FF#FFFF00";
ctx->marker.name = selphynew_pgcodes(rdback.data[6]);
+ ctx->marker.numtype = rdback.data[6];
ctx->marker.levelmax = -1;
if (rdback.data[2]) {
ctx->marker.levelnow = 0;
diff --git a/backend_common.c b/backend_common.c
index 9f7f6e1..00921e4 100644
--- a/backend_common.c
+++ b/backend_common.c
@@ -30,7 +30,7 @@
#include "backend_common.h"
#include <errno.h>
-#define BACKEND_VERSION "0.95"
+#define BACKEND_VERSION "0.96"
#ifndef URI_PREFIX
#error "Must Define URI_PREFIX"
#endif
@@ -1468,6 +1468,12 @@ minimal:
}
DEBUG2("\n");
}
+
+ if (full) {
+ for (i = 0 ; i < marker_count ; i++) {
+ PPD("stpMediaID=%d\n", markers[i].numtype);
+ }
+ }
}
int dyesub_read_file(const char *filename, void *databuf, int datalen,
diff --git a/backend_common.h b/backend_common.h
index a987380..af783ee 100644
--- a/backend_common.h
+++ b/backend_common.h
@@ -52,6 +52,7 @@
#define INFO( ... ) do { if (!quiet) fprintf(stderr, "INFO: " __VA_ARGS__ ); } while(0)
#define WARNING( ... ) do { fprintf(stderr, "WARNING: " __VA_ARGS__ ); } while(0)
#define ERROR( ... ) do { fprintf(stderr, "ERROR: " __VA_ARGS__ ); sleep(1); } while (0)
+#define PPD( ... ) do { fprintf(stderr, "PPD: " __VA_ARGS__ ); sleep(1); } while (0)
#if (__BYTE_ORDER == __LITTLE_ENDIAN)
#define le64_to_cpu(__x) __x
@@ -184,6 +185,7 @@ struct marker {
const char *name; /* Eg "CK9015 (4x6)" */
int levelmax; /* Max media count, eg '600', or '-1' */
int levelnow; /* Remaining media, -3, -2, -1, 0..N. See CUPS. */
+ int numtype; /* Numerical type, (-1 for unknown) */
};
#define BACKEND_FLAG_JOBLIST 0x00000001
diff --git a/backend_dnpds40.c b/backend_dnpds40.c
index 3831961..4b4b287 100644
--- a/backend_dnpds40.c
+++ b/backend_dnpds40.c
@@ -1230,6 +1230,7 @@ static int dnpds40_attach(void *vctx, struct libusb_device_handle *dev, int type
/* Fill out marker structure */
ctx->marker[0].color = "#00FFFF#FF00FF#FFFF00";
ctx->marker[0].name = dnpds40_media_types(ctx->media);
+ ctx->marker[0].numtype = ctx->media;
ctx->marker[0].levelmax = ctx->media_count_new;
ctx->marker[0].levelnow = -2;
ctx->marker_count = 1;
@@ -1237,6 +1238,7 @@ static int dnpds40_attach(void *vctx, struct libusb_device_handle *dev, int type
if (ctx->type == P_DNP_DS80D) {
ctx->marker[1].color = "#00FFFF#FF00FF#FFFF00";
ctx->marker[1].name = dnpds80_duplex_media_types(ctx->duplex_media);
+ ctx->marker[1].numtype = ctx->duplex_media;
ctx->marker[1].levelmax = ctx->marker[0].levelmax/2;
ctx->marker[1].levelnow = -2;
ctx->marker_count++;
diff --git a/backend_hiti.c b/backend_hiti.c
index d06102a..e4ddf05 100644
--- a/backend_hiti.c
+++ b/backend_hiti.c
@@ -683,6 +683,7 @@ static int hiti_attach(void *vctx, struct libusb_device_handle *dev, int type,
ctx->marker.color = "#00FFFF#FF00FF#FFFF00";
ctx->marker.name = hiti_ribbontypes(ctx->supplies[2]);
+ ctx->marker.numtype = ctx->supplies[2];
ctx->marker.levelmax = hiti_ribboncounts(ctx->supplies[2]);
ctx->marker.levelnow = 0;
diff --git a/backend_kodak1400.c b/backend_kodak1400.c
index cd5cc49..a2f9e13 100644
--- a/backend_kodak1400.c
+++ b/backend_kodak1400.c
@@ -309,6 +309,7 @@ static int kodak1400_attach(void *vctx, struct libusb_device_handle *dev, int ty
ctx->marker.color = "#00FFFF#FF00FF#FFFF00";
ctx->marker.name = "Unknown";
+ ctx->marker.numtype = -1;
ctx->marker.levelmax = -1;
ctx->marker.levelnow = -2;
diff --git a/backend_kodak605.c b/backend_kodak605.c
index 2a6f4cd..5a3e194 100644
--- a/backend_kodak605.c
+++ b/backend_kodak605.c
@@ -404,6 +404,7 @@ static int kodak605_attach(void *vctx, struct libusb_device_handle *dev, int typ
ctx->marker.color = "#00FFFF#FF00FF#FFFF00";
ctx->marker.name = kodak6_mediatypes(ctx->media->type);
+ ctx->marker.numtype = ctx->media->type;
ctx->marker.levelmax = 100; /* Ie percentage */
ctx->marker.levelnow = -2;
diff --git a/backend_kodak6800.c b/backend_kodak6800.c
index 40897ca..c2daa54 100644
--- a/backend_kodak6800.c
+++ b/backend_kodak6800.c
@@ -749,6 +749,7 @@ static int kodak6800_attach(void *vctx, struct libusb_device_handle *dev, int ty
ctx->marker.color = "#00FFFF#FF00FF#FFFF00";
ctx->marker.name = kodak6_mediatypes(ctx->media_type);
+ ctx->marker.numtype = ctx->media_type;
ctx->marker.levelmax = 100; /* Ie percentage */
ctx->marker.levelnow = -2;
diff --git a/backend_magicard.c b/backend_magicard.c
index 3e8c894..adafd52 100644
--- a/backend_magicard.c
+++ b/backend_magicard.c
@@ -460,6 +460,7 @@ static int magicard_attach(void *vctx, struct libusb_device_handle *dev, int typ
ctx->marker.color = "#00FFFF#FF00FF#FFFF00"; // XXX YMCK too!
ctx->marker.name = "Unknown"; // LC1/LC3/LC6/LC8
+ ctx->marker.numtype = -1;
ctx->marker.levelmax = -1;
ctx->marker.levelnow = -2;
diff --git a/backend_mitsu70x.c b/backend_mitsu70x.c
index 140b3b6..f738dcf 100644
--- a/backend_mitsu70x.c
+++ b/backend_mitsu70x.c
@@ -819,6 +819,7 @@ static int mitsu70x_attach(void *vctx, struct libusb_device_handle *dev, int typ
/* Set up markers */
ctx->marker[0].color = "#00FFFF#FF00FF#FFFF00";
ctx->marker[0].name = mitsu70x_media_types(resp.lower.media_brand, resp.lower.media_type);
+ ctx->marker[0].numtype = resp.lower.media_type;
ctx->marker[0].levelmax = be16_to_cpu(resp.lower.capacity);
ctx->marker[0].levelnow = be16_to_cpu(resp.lower.remain);
ctx->medias[0] = resp.lower.media_type & 0xf;
@@ -826,6 +827,7 @@ static int mitsu70x_attach(void *vctx, struct libusb_device_handle *dev, int typ
if (ctx->num_decks == 2) {
ctx->marker[1].color = "#00FFFF#FF00FF#FFFF00";
ctx->marker[1].name = mitsu70x_media_types(resp.upper.media_brand, resp.upper.media_type);
+ ctx->marker[1].numtype = resp.upper.media_type;
ctx->marker[1].levelmax = be16_to_cpu(resp.upper.capacity);
ctx->marker[1].levelnow = be16_to_cpu(resp.upper.remain);
ctx->medias[1] = resp.upper.media_type & 0xf;
diff --git a/backend_mitsu9550.c b/backend_mitsu9550.c
index 6b444d3..529de70 100644
--- a/backend_mitsu9550.c
+++ b/backend_mitsu9550.c
@@ -509,6 +509,7 @@ skip:
ctx->marker.color = "#00FFFF#FF00FF#FFFF00";
ctx->marker.name = mitsu9550_media_types(media.type, ctx->is_s);
+ ctx->marker.numtype = media.type;
ctx->marker.levelmax = be16_to_cpu(media.max);
ctx->marker.levelnow = be16_to_cpu(media.remain);
diff --git a/backend_mitsud90.c b/backend_mitsud90.c
index c39257b..96c0827 100644
--- a/backend_mitsud90.c
+++ b/backend_mitsud90.c
@@ -543,6 +543,7 @@ static int mitsud90_attach(void *vctx, struct libusb_device_handle *dev, int typ
}
ctx->marker.color = "#00FFFF#FF00FF#FFFF00";
+ ctx->marker.numtype = resp.media.type;
ctx->marker.name = mitsu70x_media_types(resp.media.brand, resp.media.type);
ctx->marker.levelmax = be16_to_cpu(resp.media.capacity);
ctx->marker.levelnow = be16_to_cpu(resp.media.remain);
diff --git a/backend_mitsup95d.c b/backend_mitsup95d.c
index 22f406f..88b0406 100644
--- a/backend_mitsup95d.c
+++ b/backend_mitsup95d.c
@@ -154,6 +154,7 @@ static int mitsup95d_attach(void *vctx, struct libusb_device_handle *dev, int ty
ctx->marker.color = "#000000"; /* Ie black! */
ctx->marker.name = "Unknown";
+ ctx->marker.numtype = -1;
ctx->marker.levelmax = -1;
ctx->marker.levelnow = -2;
diff --git a/backend_shinkos1245.c b/backend_shinkos1245.c
index 9c868ad..2360a40 100644
--- a/backend_shinkos1245.c
+++ b/backend_shinkos1245.c
@@ -983,6 +983,7 @@ static int shinkos1245_attach(void *vctx, struct libusb_device_handle *dev, int
}
ctx->marker.color = "#00FFFF#FF00FF#FFFF00";
ctx->marker.name = ctx->media_8x12 ? "8x12" : "8x10";
+ ctx->marker.numtype = ctx->media_8x12;
ctx->marker.levelmax = ctx->media_8x12 ? 230 : 280;
ctx->marker.levelnow = -2;
diff --git a/backend_shinkos2145.c b/backend_shinkos2145.c
index e13ccd0..7a6394c 100644
--- a/backend_shinkos2145.c
+++ b/backend_shinkos2145.c
@@ -897,6 +897,7 @@ static int shinkos2145_attach(void *vctx, struct libusb_device_handle *dev, int
ctx->marker.color = "#00FFFF#FF00FF#FFFF00";
ctx->marker.name = sinfonia_print_codes(ctx->media_code, 0);
+ ctx->marker.numtype = ctx->media_code;
ctx->marker.levelmax = media_prints;
ctx->marker.levelnow = -2;
diff --git a/backend_shinkos6145.c b/backend_shinkos6145.c
index d0617b6..fb60690 100644
--- a/backend_shinkos6145.c
+++ b/backend_shinkos6145.c
@@ -1055,6 +1055,7 @@ static int shinkos6145_attach(void *vctx, struct libusb_device_handle *dev, int
ctx->marker.color = "#00FFFF#FF00FF#FFFF00";
ctx->marker.name = print_ribbons(ctx->media.ribbon_code);
+ ctx->marker.numtype = ctx->media.ribbon_code;
ctx->marker.levelmax = ribbon_sizes(ctx->media.ribbon_code);
ctx->marker.levelnow = -2;
diff --git a/backend_shinkos6245.c b/backend_shinkos6245.c
index 4d1fba0..ee419d6 100644
--- a/backend_shinkos6245.c
+++ b/backend_shinkos6245.c
@@ -1021,6 +1021,7 @@ static int shinkos6245_attach(void *vctx, struct libusb_device_handle *dev, int
ctx->marker.color = "#00FFFF#FF00FF#FFFF00";
ctx->marker.name = ribbon_sizes(ctx->media.ribbon_code);
+ ctx->marker.numtype = ctx->media.ribbon_code;
ctx->marker.levelmax = 100;
ctx->marker.levelnow = -2;
diff --git a/backend_sonyupd.c b/backend_sonyupd.c
index 11d6c31..5c9bb52 100644
--- a/backend_sonyupd.c
+++ b/backend_sonyupd.c
@@ -129,6 +129,7 @@ static int upd_attach(void *vctx, struct libusb_device_handle *dev, int type,
}
ctx->marker.name = "Unknown";
+ ctx->marker.numtype = -1;
ctx->marker.levelmax = -1;
ctx->marker.levelnow = -2;
diff --git a/backend_sonyupdneo.c b/backend_sonyupdneo.c
index 4e27a85..4a9a744 100644
--- a/backend_sonyupdneo.c
+++ b/backend_sonyupdneo.c
@@ -46,7 +46,7 @@ struct updneo_printjob {
uint8_t *databuf;
int datalen;
- int copies_offset;
+// int copies_offset; // XXX eventually implement
int payload_offset;
int copies;
@@ -99,6 +99,7 @@ static int updneo_attach(void *vctx, struct libusb_device_handle *dev, int type,
}
ctx->marker.name = "Unknown";
+ ctx->marker.numtype = -1;
ctx->marker.levelmax = -1;
ctx->marker.levelnow = -2;