common: Allow CORRTABLE_PATH to be overrided at runtime.

master
Solomon Peachy 3 years ago
parent e3120aa9bc
commit 494a188f1a
  1. 9
      Makefile
  2. 3
      README
  3. 15
      backend_common.c
  4. 1
      backend_common.h
  5. 63
      backend_hiti.c
  6. 14
      backend_mitsu.c
  7. 8
      backend_mitsu.h
  8. 60
      backend_mitsu70x.c
  9. 11
      backend_mitsu9550.c
  10. 19
      backend_mitsud90.c
  11. 2
      hiti_data/README.data
  12. 13
      lib70x/data/README.data

@ -80,7 +80,7 @@ CFLAGS += -Wall -Wextra -Wformat-security -funit-at-a-time -g -Og -D_FORTIFY_SOU
LDFLAGS += $(shell pkg-config --libs libusb-1.0)
CPPFLAGS += $(shell pkg-config --cflags libusb-1.0)
# CPPFLAGS += -DLIBUSB_PRE_1_0_10
CPPFLAGS += -DURI_PREFIX=\"$(BACKEND_NAME)\" $(OLD_URI)
CPPFLAGS += -DURI_PREFIX=\"$(BACKEND_NAME)\" $(OLD_URI) -DCORRTABLE_PATH=\"$(BACKEND_DATA_DIR)\"
LIBLDFLAGS = -g -shared
# List of backends
@ -143,7 +143,7 @@ testgp_%: dyesub_backend
LD_LIBRARY_PATH=lib70x:lib6145:$(LD_LIBRARY_PATH) STP_VERBOSE=$(STP_VERBOSE) STP_PARALLEL=$(CPUS) ./regression-gp.pl regression-gp.csv $(subst testgp_,,$@)
cppcheck:
$(CPPCHECK) -q -v --std=c99 --enable=all --suppress=variableScope --suppress=selfAssignment --suppress=unusedStructMember -I. -I/usr/include -DCORRTABLE_PATH=\"$(BACKEND_DATA_DIR)\" $(CPPFLAGS) $(SOURCES) $(LIB70X_SOURCES) $(LIBS6145_SOURCES)
$(CPPCHECK) -q -v --std=c99 --enable=all --suppress=variableScope --suppress=selfAssignment --suppress=unusedStructMember -I. -I/usr/include $(CPPFLAGS) $(SOURCES) $(LIB70X_SOURCES) $(LIBS6145_SOURCES)
install:
$(MKDIR) -p $(CUPS_BACKEND_DIR)
@ -182,11 +182,6 @@ endif
# Backend-specific joy:
$(SINFONIA_BACKENDS_O): backend_sinfonia.h
$(MITSU_BACKENDS_O): backend_mitsu.h
backend_mitsu.o: CPPFLAGS += -DCORRTABLE_PATH=\"$(BACKEND_DATA_DIR)\"
backend_mitsu70x.o: CPPFLAGS += -DCORRTABLE_PATH=\"$(BACKEND_DATA_DIR)\"
backend_mitsu9550.o: CPPFLAGS += -DCORRTABLE_PATH=\"$(BACKEND_DATA_DIR)\"
backend_hiti.o: CPPFLAGS += -DCORRTABLE_PATH=\"$(BACKEND_DATA_DIR)\"
backend_mitsud90.o: CPPFLAGS += -DCORRTABLE_PATH=\"$(BACKEND_DATA_DIR)\"
# Library joy:
%.$(LIB_SUFFIX): CFLAGS += -fPIC --no-strict-overflow

@ -315,6 +315,9 @@
MAX_XFER_SIZE=32768 XFER_TIMEOUT=30000 backend filename
To change the location of backend data at runtime, set CORRTABLE_PATH
to the appropriate directory.
Finally, BACKEND_QUIET can be set to a non-zero value to silence all
output other than warnings and errors.

@ -28,11 +28,19 @@
#include <errno.h>
#include <signal.h>
#define BACKEND_VERSION "0.104"
#define BACKEND_VERSION "0.105"
#ifndef URI_PREFIX
#error "Must Define URI_PREFIX"
#endif
#ifndef CORRTABLE_PATH
#ifdef PACKAGE_DATA_DIR
#define CORRTABLE_PATH PACKAGE_DATA_DIR "/backend_data"
#else
#error "Must define CORRTABLE_PATH or PACKAGE_DATA_DIR!"
#endif
#endif
#define URB_XFER_SIZE (64*1024)
#define XFER_TIMEOUT 15000
@ -50,11 +58,12 @@ int extra_type = -1;
int ncopies = 1;
int collate = 0;
int test_mode = 0;
int old_uri = 0;
int quiet = 0;
const char *corrtable_path = CORRTABLE_PATH;
static int max_xfer_size = URB_XFER_SIZE;
static int xfer_timeout = XFER_TIMEOUT;
static int old_uri = 0;
/* Support Functions */
int backend_claim_interface(struct libusb_device_handle *dev, int iface,
@ -1281,6 +1290,8 @@ int main (int argc, char **argv)
test_mode = atoi(getenv("TEST_MODE"));
if (getenv("OLD_URI_SCHEME"))
old_uri = atoi(getenv("OLD_URI_SCHEME"));
if (getenv("CORRTABLE_PATH"))
corrtable_path = getenv("CORRTABLE_PATH");
if (test_mode >= TEST_MODE_NOATTACH && (extra_vid == -1 || extra_pid == -1)) {
ERROR("Must specify EXTRA_VID, EXTRA_PID in test mode > 1!\n");

@ -304,6 +304,7 @@ extern int ncopies;
extern int collate;
extern int test_mode;
extern int quiet;
extern const char *corrtable_path;
enum {
TEST_MODE_NONE = 0,

@ -33,14 +33,6 @@
#include <config.h>
#endif
#ifndef CORRTABLE_PATH
#ifdef PACKAGE_DATA_DIR
#define CORRTABLE_PATH PACKAGE_DATA_DIR "/backend_data"
#else
#error "Must define CORRTABLE_PATH or PACKAGE_DATA_DIR!"
#endif
#endif
/* Private structures */
struct hiti_cmd {
uint8_t hdr; /* 0xa5 */
@ -959,7 +951,7 @@ static void hiti_cleanup_job(const void *vjob) {
static uint8_t *hiti_get_correction_data(struct hiti_ctx *ctx, uint8_t mode)
{
char *fname;
const char *fname;
uint8_t *buf;
int ret, len;
@ -971,104 +963,104 @@ static uint8_t *hiti_get_correction_data(struct hiti_ctx *ctx, uint8_t mode)
case P_HITI_51X:
if (!mediatype) {
if (mode) {
fname = CORRTABLE_PATH "/P51x_CMQPra.bin";
fname = "P51x_CMQPra.bin";
break;
} else {
fname = CORRTABLE_PATH "/P51x_CMPPra.bin";
fname = "P51x_CMPPra.bin";
break;
}
} else {
if (mode) {
switch(mediaver) {
case 0:
fname = CORRTABLE_PATH "/P51x_CCQPra.bin";
fname = "P51x_CCQPra.bin";
break;
case 1:
fname = CORRTABLE_PATH "/P51x_CCQP1ra.bin";
fname = "P51x_CCQP1ra.bin";
break;
case 2:
fname = CORRTABLE_PATH "/P51x_CCQP2ra.bin";
fname = "P51x_CCQP2ra.bin";
break;
case 3:
default:
fname = CORRTABLE_PATH "/P51x_CCQP3ra.bin";
fname = "P51x_CCQP3ra.bin";
break;
}
} else {
switch(mediaver) {
case 0:
fname = CORRTABLE_PATH "/P51x_CCPPra.bin";
fname = "P51x_CCPPra.bin";
break;
case 1:
fname = CORRTABLE_PATH "/P51x_CCPP1ra.bin";
fname = "P51x_CCPP1ra.bin";
break;
case 2:
fname = CORRTABLE_PATH "/P51x_CCPP2ra.bin";
fname = "P51x_CCPP2ra.bin";
break;
case 3:
default:
fname = CORRTABLE_PATH "/P51x_CCPP3ra.bin";
fname = "P51x_CCPP3ra.bin";
break;
}
}
}
break;
case P_HITI_52X:
fname = CORRTABLE_PATH "/P52x_CCPPri.bin";
fname = "P52x_CCPPri.bin";
break;
case P_HITI_720:
if (!mediatype) {
if (mode) {
fname = CORRTABLE_PATH "/P72x_CMQPrd.bin";
fname = "P72x_CMQPrd.bin";
break;
} else {
fname = CORRTABLE_PATH "/P72x_CMPPrd.bin";
fname = "P72x_CMPPrd.bin";
break;
}
} else {
if (mode) {
switch(mediaver) {
case 0:
fname = CORRTABLE_PATH "/P72x_CCQPrd.bin";
fname = "P72x_CCQPrd.bin";
break;
case 1:
fname = CORRTABLE_PATH "/P72x_CCQP1rd.bin";
fname = "P72x_CCQP1rd.bin";
break;
case 2:
fname = CORRTABLE_PATH "/P72x_CCQP2rd.bin";
fname = "P72x_CCQP2rd.bin";
break;
case 3:
fname = CORRTABLE_PATH "/P72x_CCQP3rd.bin";
fname = "P72x_CCQP3rd.bin";
break;
case 4:
default:
fname = CORRTABLE_PATH "/P72x_CCQP4rd.bin";
fname = "P72x_CCQP4rd.bin";
break;
}
} else {
switch(mediaver) {
case 0:
fname = CORRTABLE_PATH "/P72x_CCPPrd.bin";
fname = "P72x_CCPPrd.bin";
break;
case 1:
fname = CORRTABLE_PATH "/P72x_CCPP1rd.bin";
fname = "P72x_CCPP1rd.bin";
break;
case 2:
fname = CORRTABLE_PATH "/P72x_CCPP2rd.bin";
fname = "P72x_CCPP2rd.bin";
break;
case 3:
fname = CORRTABLE_PATH "/P72x_CCPP3rd.bin";
fname = "P72x_CCPP3rd.bin";
break;
case 4:
default:
fname = CORRTABLE_PATH "/P72x_CCPP4rd.bin";
fname = "P72x_CCPP4rd.bin";
break;
}
}
}
break;
case P_HITI_750:
fname = CORRTABLE_PATH "/P75x_CCPPri.bin";
fname = "P75x_CCPPri.bin";
break;
default:
fname = NULL;
@ -1083,7 +1075,10 @@ static uint8_t *hiti_get_correction_data(struct hiti_ctx *ctx, uint8_t mode)
return NULL;
}
ret = dyesub_read_file(fname, buf, CORRECTION_FILE_SIZE, &len);
char full[2048];
snprintf(full, sizeof(full), "%s/%s", corrtable_path, fname);
ret = dyesub_read_file(full, buf, CORRECTION_FILE_SIZE, &len);
if (ret) {
free(buf);
return NULL;

@ -132,23 +132,26 @@ int mitsu_apply3dlut(struct mitsu_lib *lib, char *lutfname, uint8_t *databuf,
int rgb_bgr)
{
#if defined(WITH_DYNAMIC)
char full[2048];
int i;
if (!lutfname)
return CUPS_BACKEND_OK;
snprintf(full, sizeof(full), "%s/%s", corrtable_path, lutfname);
if (!lib->lut) {
uint8_t *buf = malloc(LUT_LEN);
if (!buf) {
ERROR("Memory allocation failure!\n");
return CUPS_BACKEND_RETRY_CURRENT;
}
if ((i = dyesub_read_file(lutfname, buf, LUT_LEN, NULL)))
if ((i = dyesub_read_file(full, buf, LUT_LEN, NULL)))
return i;
lib->lut = lib->Load3DColorTable(buf);
free(buf);
if (!lib->lut) {
ERROR("Unable to parse LUT file '%s'!\n", lutfname);
ERROR("Unable to parse LUT file '%s'!\n", full);
return CUPS_BACKEND_CANCEL;
}
}
@ -167,11 +170,14 @@ int mitsu_readlamdata(const char *fname, uint16_t lamstride,
{
int i, j, fd;
int remain = cols * rows * bpp;
char full[2048];
snprintf(full, sizeof(full), "%s/%s", corrtable_path, fname);
DEBUG("Reading %d bytes of matte data from disk (%d/%d)\n", cols * rows * bpp, cols, lamstride);
fd = open(fname, O_RDONLY);
fd = open(full, O_RDONLY);
if (fd < 0) {
ERROR("Unable to open matte lamination data file '%s'\n", fname);
ERROR("Unable to open matte lamination data file '%s'\n", full);
return CUPS_BACKEND_CANCEL;
}

@ -76,14 +76,6 @@ typedef void (*CP98xx_DestroyDataFN)(const struct mitsu98xx_data *data);
/* Image processing library function prototypes */
#define LIB_NAME_RE "libMitsuD70ImageReProcess" DLL_SUFFIX
#ifndef CORRTABLE_PATH
#ifdef PACKAGE_DATA_DIR
#define CORRTABLE_PATH PACKAGE_DATA_DIR "/backend_data"
#else
#error "Must define CORRTABLE_PATH or PACKAGE_DATA_DIR!"
#endif
#endif
struct mitsu_lib {
void *dl_handle;
lib70x_getapiversionFN GetAPIVersion;

@ -929,32 +929,32 @@ repeat:
/* Figure out the correction data table to use */
if (ctx->type == P_MITSU_D70X) {
job->laminatefname = CORRTABLE_PATH "/D70MAT01.raw";
job->lutfname = CORRTABLE_PATH "/CPD70L01.lut";
job->laminatefname = "D70MAT01.raw";
job->lutfname = "CPD70L01.lut";
if (mhdr.speed == 3) {
job->cpcfname = CORRTABLE_PATH "/CPD70S01.cpc";
job->cpcfname = "CPD70S01.cpc";
} else if (mhdr.speed == 4) {
job->cpcfname = CORRTABLE_PATH "/CPD70U01.cpc";
job->cpcfname = "CPD70U01.cpc";
} else {
job->cpcfname = CORRTABLE_PATH "/CPD70N01.cpc";
job->cpcfname = "CPD70N01.cpc";
}
if (mhdr.hdr[3] != 0x01) {
WARNING("Print job has wrong submodel specifier (%x)\n", mhdr.hdr[3]);
mhdr.hdr[3] = 0x01;
}
} else if (ctx->type == P_MITSU_D80) {
job->laminatefname = CORRTABLE_PATH "/D80MAT01.raw";
job->lutfname = CORRTABLE_PATH "/CPD80L01.lut";
job->laminatefname = "D80MAT01.raw";
job->lutfname = "CPD80L01.lut";
if (mhdr.speed == 3) {
job->cpcfname = CORRTABLE_PATH "/CPD80S01.cpc";
job->ecpcfname = CORRTABLE_PATH "/CPD80E01.cpc";
job->cpcfname = "CPD80S01.cpc";
job->ecpcfname = "CPD80E01.cpc";
} else if (mhdr.speed == 4) {
job->cpcfname = CORRTABLE_PATH "/CPD80U01.cpc";
job->cpcfname = "CPD80U01.cpc";
job->ecpcfname = NULL;
} else {
job->cpcfname = CORRTABLE_PATH "/CPD80N01.cpc";
job->cpcfname = "CPD80N01.cpc";
job->ecpcfname = NULL;
}
if (mhdr.hdr[3] != 0x01) {
@ -962,28 +962,28 @@ repeat:
mhdr.hdr[3] = 0x01;
}
} else if (ctx->type == P_MITSU_K60) {
job->laminatefname = CORRTABLE_PATH "/S60MAT02.raw";
job->lutfname = CORRTABLE_PATH "/CPS60L01.lut";
job->laminatefname = "S60MAT02.raw";
job->lutfname = "CPS60L01.lut";
if (mhdr.speed == 3 || mhdr.speed == 4) {
mhdr.speed = 4; /* Ultra Fine */
job->cpcfname = CORRTABLE_PATH "/CPS60T03.cpc";
job->cpcfname = "CPS60T03.cpc";
} else {
job->cpcfname = CORRTABLE_PATH "/CPS60T01.cpc";
job->cpcfname = "CPS60T01.cpc";
}
if (mhdr.hdr[3] != 0x00) {
WARNING("Print job has wrong submodel specifier (%x)\n", mhdr.hdr[3]);
mhdr.hdr[3] = 0x00;
}
} else if (ctx->type == P_KODAK_305) {
job->laminatefname = CORRTABLE_PATH "/EK305MAT.raw"; // Same as K60
job->lutfname = CORRTABLE_PATH "/EK305L01.lut";
job->laminatefname = "EK305MAT.raw"; // Same as K60
job->lutfname = "EK305L01.lut";
if (mhdr.speed == 3 || mhdr.speed == 4) {
mhdr.speed = 4; /* Ultra Fine */
job->cpcfname = CORRTABLE_PATH "/EK305T03.cpc";
job->cpcfname = "EK305T03.cpc";
} else {
job->cpcfname = CORRTABLE_PATH "/EK305T01.cpc";
job->cpcfname = "EK305T01.cpc";
}
// XXX what about using K60 media if we read back the proper code?
if (mhdr.hdr[3] != 0x90) {
@ -991,13 +991,13 @@ repeat:
mhdr.hdr[3] = 0x90;
}
} else if (ctx->type == P_FUJI_ASK300) {
job->laminatefname = CORRTABLE_PATH "/ASK300M2.raw"; /* Same as D70 */
job->laminatefname = "ASK300M2.raw"; /* Same as D70 */
job->lutfname = NULL; /* Printer does not come with external LUT */
if (mhdr.speed == 3 || mhdr.speed == 4) {
mhdr.speed = 3; /* Super Fine */
job->cpcfname = CORRTABLE_PATH "/ASK300T3.cpc";
job->cpcfname = "ASK300T3.cpc";
} else {
job->cpcfname = CORRTABLE_PATH "/ASK300T1.cpc";
job->cpcfname = "ASK300T1.cpc";
}
if (mhdr.hdr[3] != 0x80) {
WARNING("Print job has wrong submodel specifier (%x)\n", mhdr.hdr[3]);
@ -1531,25 +1531,33 @@ static int mitsu70x_main_loop(void *vctx, const void *vjob)
/* Load in the CPC file, if needed */
if (job->cpcfname && job->cpcfname != ctx->last_cpcfname) {
char full[2048];
ctx->last_cpcfname = job->cpcfname;
if (ctx->lib.cpcdata)
ctx->lib.DestroyCPCData(ctx->lib.cpcdata);
ctx->lib.cpcdata = ctx->lib.GetCPCData(job->cpcfname);
snprintf(full, sizeof(full), "%s/%s", corrtable_path, job->cpcfname);
ctx->lib.cpcdata = ctx->lib.GetCPCData(full);
if (!ctx->lib.cpcdata) {
ERROR("Unable to load CPC file '%s'\n", job->cpcfname);
ERROR("Unable to load CPC file '%s'\n", full);
return CUPS_BACKEND_CANCEL;
}
}
/* Load in the secondary CPC, if needed */
if (job->ecpcfname != ctx->last_ecpcfname) {
char full[2048];
ctx->last_ecpcfname = job->ecpcfname;
if (ctx->lib.ecpcdata)
ctx->lib.DestroyCPCData(ctx->lib.ecpcdata);
snprintf(full, sizeof(full), "%s/%s", corrtable_path, job->ecpcfname);
if (job->ecpcfname) {
ctx->lib.ecpcdata = ctx->lib.GetCPCData(job->ecpcfname);
ctx->lib.ecpcdata = ctx->lib.GetCPCData(full);
if (!ctx->lib.ecpcdata) {
ERROR("Unable to load CPC file '%s'\n", job->cpcfname);
ERROR("Unable to load CPC file '%s'\n", full);
return CUPS_BACKEND_CANCEL;
}
} else {

@ -34,9 +34,9 @@
#include <config.h>
#endif
#define MITSU_M98xx_LAMINATE_FILE CORRTABLE_PATH "/M98MATTE.raw"
#define MITSU_M98xx_DATATABLE_FILE CORRTABLE_PATH "/M98TABLE.dat"
#define MITSU_M98xx_LUT_FILE CORRTABLE_PATH "/M98XXL01.lut"
#define MITSU_M98xx_LAMINATE_FILE "M98MATTE.raw"
#define MITSU_M98xx_DATATABLE_FILE "M98TABLE.dat"
#define MITSU_M98xx_LUT_FILE "M98XXL01.lut"
#define LAMINATE_STRIDE 1868
/* USB VIDs and PIDs */
@ -456,8 +456,11 @@ hdr_done:
/* Read in CP98xx data tables if necessary */
if (ctx->is_98xx && !job->is_raw && !ctx->m98xxdata) {
char full[2048];
snprintf(full, sizeof(full), "%s/%s", corrtable_path, MITSU_M98xx_DATATABLE_FILE);
DEBUG("Reading in 98xx data from disk\n");
ctx->m98xxdata = ctx->lib.CP98xx_GetData(MITSU_M98xx_DATATABLE_FILE);
ctx->m98xxdata = ctx->lib.CP98xx_GetData(full);
if (!ctx->m98xxdata) {
ERROR("Unable to read 98xx data table file '%s'\n", MITSU_M98xx_DATATABLE_FILE);
}

@ -34,11 +34,11 @@
/* CPM1 stuff */
#define CPM1_LAMINATE_STRIDE 1852
#define CPM1_LAMINATE_FILE CORRTABLE_PATH "/M1_MAT02.raw"
#define CPM1_CPC_FNAME CORRTABLE_PATH "/CPM1_N1.csv"
#define CPM1_CPC_G1_FNAME CORRTABLE_PATH "/CPM1_G1.csv"
#define CPM1_CPC_G5_FNAME CORRTABLE_PATH "/CPM1_G5.csv"
#define CPM1_LUT_FNAME CORRTABLE_PATH "/CPM1_NL.lut"
#define CPM1_LAMINATE_FILE "M1_MAT02.raw"
#define CPM1_CPC_FNAME "CPM1_N1.csv"
#define CPM1_CPC_G1_FNAME "CPM1_G1.csv"
#define CPM1_CPC_G5_FNAME "CPM1_G5.csv"
#define CPM1_LUT_FNAME "CPM1_NL.lut"
/* Printer data structures */
@ -1785,7 +1785,10 @@ static struct M1CPCData *get_M1CPCData(const char *filename,
data = malloc(sizeof(*data));
if (!data)
return NULL;
f = fopen(gammafilename, "r");
snprintf(buf, sizeof(buf), "%s/%s", corrtable_path, gammafilename);
f = fopen(buf, "r");
if (!f)
goto done_free;
@ -1820,8 +1823,10 @@ static struct M1CPCData *get_M1CPCData(const char *filename,
fclose(f);
snprintf(buf, sizeof(buf), "%s/%s", corrtable_path, filename);
/* Now for the CPC Data */
f = fopen(filename, "r");
f = fopen(buf, "r");
if (!f)
goto done_free;

@ -0,0 +1,2 @@
These '.bin' files represent 3D LUTs for various HiTi printers. All
files were extracted from within various HiTi driver source or binaries.

@ -2,14 +2,17 @@ There are three sets of files here:
*.lut -- Color Lookup tables
*.raw -- Matte lamination data
*.cpc -- Data tables
*.cpc -- Data tables (CSV)
*.dat -- Data tables (binary)
All files were directly copied from the data files bundled with the
Windows drivers of the following printers:
Windows or Mac drivers of the following printers:
Fujifilm ASK-300
Kodak 305
Mitsubishi CP9800/9810
Mitsubishi CP-D70DW/D707-DW
Mitsubishi CP-K60DW-S
Mitsubishi CP-D80DW
Kodak 305
Fujifilm ASK-300
Mitsubishi CP-M1

Loading…
Cancel
Save