all: Unified approach to extra_vid/pid/type

This required a modification to all attach() methods.

Also, fix canonselphy's parsing/attachment code.
This commit is contained in:
Solomon Peachy 2015-08-12 22:56:29 -04:00
parent f67a8f8ea5
commit de8a32424c
15 changed files with 182 additions and 90 deletions

View File

@ -37,6 +37,8 @@
#include "backend_common.h"
#define P_ES40_CP790 (P_END + 1) // used for detection only
/* Exported */
#define USB_VID_CANON 0x04a9
#define USB_PID_CANON_CP10 0x304A
@ -291,13 +293,6 @@ static struct printer_data selphy_printers[] = {
.paper_code_offset = -1,
.error_detect = es3_error_detect,
},
/* PLACEHOLDER FOR DETECTION PURPOSES ONLY */
{ .type = P_ES40_CP790,
.model = "SELPHY ES40/CP790",
.init_length = 16,
.foot_length = 12,
.pgcode_offset = 2,
},
{ .type = P_ES40,
.model = "SELPHY ES40",
.init_length = 16,
@ -504,6 +499,7 @@ struct canonselphy_ctx {
struct libusb_device_handle *dev;
uint8_t endp_up;
uint8_t endp_down;
int type;
struct printer_data *printer;
@ -546,6 +542,8 @@ static void *canonselphy_init(void)
return ctx;
}
extern struct dyesub_backend canonselphy_backend;
static void canonselphy_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
@ -562,25 +560,11 @@ static void canonselphy_attach(void *vctx, struct libusb_device_handle *dev,
device = libusb_get_device(dev);
libusb_get_device_descriptor(device, &desc);
/* Special cases for some models */
if (ctx->printer->type == P_ES40_CP790) {
int i;
int printer_type = -1;
if (desc.idProduct == USB_PID_CANON_CP790)
printer_type = P_CP790;
else if (desc.idProduct == USB_PID_CANON_ES40)
printer_type = P_ES40;
ctx->type = lookup_printer_type(&canonselphy_backend,
desc.idVendor, desc.idProduct);
for (i = 0; selphy_printers[i].type != -1; i++) {
if (selphy_printers[i].type == printer_type) {
ctx->printer = &selphy_printers[i];
break;
}
}
} else if (desc.idProduct == USB_PID_CANON_CP900) {
if (desc.idProduct == USB_PID_CANON_CP900)
ctx->cp900 = 1;
}
}
static void canonselphy_teardown(void *vctx) {
@ -626,6 +610,15 @@ static int canonselphy_early_parse(void *vctx, int data_fd)
}
printer_type = parse_printjob(ctx->buffer, &ctx->bw_mode, &ctx->plane_len);
/* Special cases for some models */
if (printer_type == P_ES40_CP790) {
if (ctx->type == P_CP790)
printer_type = P_CP790;
else
printer_type = P_ES40;
}
/* Look up the printer entry */
for (i = 0; selphy_printers[i].type != -1; i++) {
if (selphy_printers[i].type == printer_type) {
ctx->printer = &selphy_printers[i];
@ -636,6 +629,10 @@ static int canonselphy_early_parse(void *vctx, int data_fd)
ERROR("Unrecognized printjob file format!\n");
return -1;
}
if (ctx->printer->type != ctx->type) {
ERROR("Printer/Job mismatch (%d/%d)\n", ctx->type, ctx->printer->type);
return -1;
}
ctx->plane_len += 12; /* Add in plane header length! */
if (ctx->printer->pgcode_offset != -1)
@ -660,9 +657,6 @@ static int canonselphy_read_parse(void *vctx, int data_fd)
i = canonselphy_early_parse(ctx, data_fd);
if (i < 0)
return i;
if (ctx->printer->type != i) {
ERROR("Job/Printer mismatch (%d/%d)\n", i, ctx->printer->type);
}
if (ctx->header) {
free(ctx->header);
@ -801,7 +795,7 @@ top:
/* Make sure paper/ribbon is correct */
if (ctx->paper_code != -1) {
if (ctx->printer->type == P_CP_XXX) {
if (ctx->type == P_CP_XXX) {
uint8_t pc = rdbuf[ctx->printer->paper_code_offset];
if (((pc >> 4) & 0xf) != (ctx->paper_code & 0x0f)) {
@ -832,7 +826,7 @@ top:
return CUPS_BACKEND_HOLD; /* Hold this job, don't stop queue */
}
}
} else if (ctx->printer->type == P_CP790) {
} else if (ctx->type == P_CP790) {
uint8_t ribbon = rdbuf[4] >> 4;
uint8_t paper = rdbuf[5];
@ -986,7 +980,7 @@ struct dyesub_backend canonselphy_backend = {
{ USB_VID_CANON, USB_PID_CANON_CP760, P_CP_XXX, ""},
{ USB_VID_CANON, USB_PID_CANON_CP770, P_CP_XXX, ""},
{ USB_VID_CANON, USB_PID_CANON_CP780, P_CP_XXX, ""},
{ USB_VID_CANON, USB_PID_CANON_CP790, P_ES40_CP790, ""},
{ USB_VID_CANON, USB_PID_CANON_CP790, P_CP790, ""},
{ USB_VID_CANON, USB_PID_CANON_CP800, P_CP_XXX, ""},
{ USB_VID_CANON, USB_PID_CANON_CP810, P_CP_XXX, ""},
{ USB_VID_CANON, USB_PID_CANON_CP900, P_CP_XXX, ""},
@ -995,7 +989,7 @@ struct dyesub_backend canonselphy_backend = {
{ USB_VID_CANON, USB_PID_CANON_ES20, P_ES2_20, ""},
{ USB_VID_CANON, USB_PID_CANON_ES3, P_ES3_30, ""},
{ USB_VID_CANON, USB_PID_CANON_ES30, P_ES3_30, ""},
{ USB_VID_CANON, USB_PID_CANON_ES40, P_ES40_CP790, ""},
{ USB_VID_CANON, USB_PID_CANON_ES40, P_ES40, ""},
{ 0, 0, 0, ""}
}
};

View File

@ -68,6 +68,7 @@ struct cw01_ctx {
struct libusb_device_handle *dev;
uint8_t endp_up;
uint8_t endp_down;
int type;
uint8_t *databuf;
struct cw01_spool_hdr hdr;
@ -292,16 +293,26 @@ static void *cw01_init(void)
return ctx;
}
extern struct dyesub_backend cw01_backend;
static void cw01_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
struct cw01_ctx *ctx = vctx;
struct libusb_device *device;
struct libusb_device_descriptor desc;
UNUSED(jobid);
ctx->dev = dev;
ctx->endp_up = endp_up;
ctx->endp_down = endp_down;
device = libusb_get_device(dev);
libusb_get_device_descriptor(device, &desc);
ctx->type = lookup_printer_type(&cw01_backend,
desc.idVendor, desc.idProduct);
}
static void cw01_teardown(void *vctx) {

View File

@ -27,7 +27,7 @@
#include "backend_common.h"
#define BACKEND_VERSION "0.58"
#define BACKEND_VERSION "0.59"
#ifndef URI_PREFIX
#error "Must Define URI_PREFIX"
#endif
@ -540,6 +540,20 @@ abort:
return found;
}
extern struct dyesub_backend updr150_backend;
extern struct dyesub_backend kodak6800_backend;
extern struct dyesub_backend kodak605_backend;
extern struct dyesub_backend kodak1400_backend;
extern struct dyesub_backend shinkos1245_backend;
extern struct dyesub_backend shinkos2145_backend;
extern struct dyesub_backend shinkos6145_backend;
extern struct dyesub_backend shinkos6245_backend;
extern struct dyesub_backend canonselphy_backend;
extern struct dyesub_backend mitsu70x_backend;
extern struct dyesub_backend mitsu9550_backend;
extern struct dyesub_backend dnpds40_backend;
extern struct dyesub_backend cw01_backend;
static struct dyesub_backend *backends[] = {
&canonselphy_backend,
&kodak6800_backend,
@ -1079,3 +1093,26 @@ done:
return ret;
}
int lookup_printer_type(struct dyesub_backend *backend, uint16_t idVendor, uint16_t idProduct)
{
int i;
int type = -1;
for (i = 0 ; backend->devices[i].vid ; i++) {
if (extra_pid != -1 &&
extra_vid != -1 &&
extra_type != -1) {
if (backend->devices[i].type == extra_type &&
extra_vid == idVendor &&
extra_pid == idProduct) {
return extra_type;
}
}
if (idVendor == backend->devices[i].vid &&
idProduct == backend->devices[i].pid) {
return backend->devices[i].type;
}
}
return type;
}

View File

@ -91,7 +91,6 @@ enum {
P_ES1,
P_ES2_20,
P_ES3_30,
P_ES40_CP790,
P_ES40,
P_CP790,
P_CP_XXX,
@ -107,7 +106,9 @@ enum {
P_SONY_UPDR150,
P_SONY_UPCR10,
P_MITSU_D70X,
P_MITSU_K60,
P_MITSU_9550,
P_MITSU_9550S,
P_DNP_DS40,
P_DNP_DS80,
P_CITIZEN_CW01,
@ -145,6 +146,7 @@ int send_data(struct libusb_device_handle *dev, uint8_t endp,
uint8_t *buf, int len);
int read_data(struct libusb_device_handle *dev, uint8_t endp,
uint8_t *buf, int buflen, int *readlen);
int lookup_printer_type(struct dyesub_backend *backend, uint16_t idVendor, uint16_t idProduct);
/* Global data */
extern int terminate;
@ -154,21 +156,6 @@ extern int extra_vid;
extern int extra_pid;
extern int extra_type;
/* External data */
extern struct dyesub_backend updr150_backend;
extern struct dyesub_backend kodak6800_backend;
extern struct dyesub_backend kodak605_backend;
extern struct dyesub_backend kodak1400_backend;
extern struct dyesub_backend shinkos1245_backend;
extern struct dyesub_backend shinkos2145_backend;
extern struct dyesub_backend shinkos6145_backend;
extern struct dyesub_backend shinkos6245_backend;
extern struct dyesub_backend canonselphy_backend;
extern struct dyesub_backend mitsu70x_backend;
extern struct dyesub_backend mitsu9550_backend;
extern struct dyesub_backend dnpds40_backend;
extern struct dyesub_backend cw01_backend;
/* CUPS compatibility */
#define CUPS_BACKEND_OK 0 /* Sucess */
#define CUPS_BACKEND_FAILED 1 /* Failed to print use CUPS policy */

View File

@ -315,6 +315,8 @@ static void *dnpds40_init(void)
((ctx->ver_major > (__major)) || \
(ctx->ver_major == (__major) && ctx->ver_minor >= (__minor)))
extern struct dyesub_backend dnpds40_backend;
static void dnpds40_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
@ -331,6 +333,9 @@ static void dnpds40_attach(void *vctx, struct libusb_device_handle *dev,
device = libusb_get_device(dev);
libusb_get_device_descriptor(device, &desc);
ctx->type = lookup_printer_type(&dnpds40_backend,
desc.idVendor, desc.idProduct);
{
/* Get Firmware Version */
struct dnpds40_cmd cmd;
@ -400,9 +405,8 @@ static void dnpds40_attach(void *vctx, struct libusb_device_handle *dev,
#endif
/* Per-printer options */
switch (desc.idProduct) {
case USB_PID_DNP_DS40:
ctx->type = P_DNP_DS40;
switch (ctx->type) {
case P_DNP_DS40:
ctx->supports_6x9 = 1;
if (FW_VER_CHECK(1,30))
ctx->supports_matte = 1;
@ -413,20 +417,17 @@ static void dnpds40_attach(void *vctx, struct libusb_device_handle *dev,
if (FW_VER_CHECK(1,51))
ctx->supports_fullcut = 1;
break;
case USB_PID_DNP_DS80:
ctx->type = P_DNP_DS80;
case P_DNP_DS80:
if (FW_VER_CHECK(1,30))
ctx->supports_matte = 1;
break;
case USB_PID_DNP_DSRX1:
ctx->type = P_DNP_DSRX1;
case P_DNP_DSRX1:
ctx->supports_matte = 1;
ctx->supports_mqty_default = 1; // 1.10 does. Maybe older too?
if (FW_VER_CHECK(1,10))
ctx->supports_2x6 = 1;
break;
case USB_PID_DNP_DS620:
ctx->type = P_DNP_DS620;
case P_DNP_DS620:
ctx->supports_matte = 1;
ctx->supports_2x6 = 1;
ctx->supports_fullcut = 1;
@ -440,7 +441,7 @@ static void dnpds40_attach(void *vctx, struct libusb_device_handle *dev,
ctx->supports_6x9 = ctx->supports_6x4_5 = 1;
break;
default:
ERROR("Unknown USB PID...\n");
ERROR("Unknown vid/pid %04x/%04x (%d)\n", desc.idVendor, desc.idProduct, ctx->type);
return;
}
}

View File

@ -77,6 +77,7 @@ struct kodak1400_ctx {
struct libusb_device_handle *dev;
uint8_t endp_up;
uint8_t endp_down;
int type;
struct kodak1400_hdr hdr;
uint8_t *plane_r;
@ -291,18 +292,27 @@ static void *kodak1400_init(void)
return ctx;
}
extern struct dyesub_backend kodak1400_backend;
static void kodak1400_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
struct kodak1400_ctx *ctx = vctx;
struct libusb_device *device;
struct libusb_device_descriptor desc;
UNUSED(jobid);
ctx->dev = dev;
ctx->endp_up = endp_up;
ctx->endp_down = endp_down;
}
device = libusb_get_device(dev);
libusb_get_device_descriptor(device, &desc);
ctx->type = lookup_printer_type(&kodak1400_backend,
desc.idVendor, desc.idProduct);
}
static void kodak1400_teardown(void *vctx) {
struct kodak1400_ctx *ctx = vctx;

View File

@ -74,6 +74,7 @@ struct kodak605_ctx {
struct libusb_device_handle *dev;
uint8_t endp_up;
uint8_t endp_down;
int type;
struct kodak605_hdr hdr;
uint8_t *databuf;
@ -104,6 +105,8 @@ static void *kodak605_init(void)
return ctx;
}
extern struct dyesub_backend kodak605_backend;
static void kodak605_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
@ -119,7 +122,9 @@ static void kodak605_attach(void *vctx, struct libusb_device_handle *dev,
device = libusb_get_device(dev);
libusb_get_device_descriptor(device, &desc);
ctx->type = lookup_printer_type(&kodak605_backend,
desc.idVendor, desc.idProduct);
}
static void kodak605_teardown(void *vctx) {

View File

@ -651,6 +651,8 @@ static void *kodak6800_init(void)
return ctx;
}
extern struct dyesub_backend kodak6800_backend;
static void kodak6800_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
@ -667,11 +669,8 @@ static void kodak6800_attach(void *vctx, struct libusb_device_handle *dev,
device = libusb_get_device(dev);
libusb_get_device_descriptor(device, &desc);
/* Map out device type */
if (desc.idProduct == USB_PID_KODAK_6850)
ctx->type = P_KODAK_6850;
else
ctx->type = P_KODAK_6800;
ctx->type = lookup_printer_type(&kodak6800_backend,
desc.idVendor, desc.idProduct);
}
static void kodak6800_teardown(void *vctx) {

View File

@ -49,14 +49,13 @@ struct mitsu70x_ctx {
struct libusb_device_handle *dev;
uint8_t endp_up;
uint8_t endp_down;
int type;
uint8_t *databuf;
int datalen;
uint16_t rows;
uint16_t cols;
int k60;
};
/* Program states */
@ -139,6 +138,8 @@ static void *mitsu70x_init(void)
return ctx;
}
extern struct dyesub_backend mitsu70x_backend;
static void mitsu70x_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
@ -155,12 +156,8 @@ static void mitsu70x_attach(void *vctx, struct libusb_device_handle *dev,
device = libusb_get_device(dev);
libusb_get_device_descriptor(device, &desc);
if (desc.idProduct == USB_PID_MITSU_K60)
ctx->k60 = 1;
if (desc.idProduct == USB_PID_KODAK305)
ctx->k60 = 1;
ctx->type = lookup_printer_type(&mitsu70x_backend,
desc.idVendor, desc.idProduct);
}
@ -424,7 +421,7 @@ top:
INFO("Sending header sequence\n");
/* K60 may require fixups */
if (ctx->k60) {
if (ctx->type == P_MITSU_K60) {
struct mitsu70x_hdr *hdr = (struct mitsu70x_hdr*) (ctx->databuf + sizeof(struct mitsu70x_hdr));
/* K60 only has a lower deck */
hdr->deck = 1;
@ -608,9 +605,9 @@ struct dyesub_backend mitsu70x_backend = {
.query_serno = mitsu70x_query_serno,
.devices = {
{ USB_VID_MITSU, USB_PID_MITSU_D70X, P_MITSU_D70X, ""},
{ USB_VID_MITSU, USB_PID_MITSU_K60, P_MITSU_D70X, ""},
{ USB_VID_MITSU, USB_PID_MITSU_K60, P_MITSU_K60, ""},
// { USB_VID_MITSU, USB_PID_MITSU_D80, P_MITSU_D70X, ""},
{ USB_VID_KODAK, USB_PID_KODAK305, P_MITSU_D70X, ""},
{ USB_VID_KODAK, USB_PID_KODAK305, P_MITSU_K60, ""},
{ 0, 0, 0, ""}
}
};

View File

@ -46,6 +46,7 @@ struct mitsu9550_ctx {
struct libusb_device_handle *dev;
uint8_t endp_up;
uint8_t endp_down;
int type;
uint8_t *databuf;
int datalen;
@ -150,6 +151,8 @@ static void *mitsu9550_init(void)
return ctx;
}
extern struct dyesub_backend mitsu9550_backend;
static void mitsu9550_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
@ -166,8 +169,8 @@ static void mitsu9550_attach(void *vctx, struct libusb_device_handle *dev,
device = libusb_get_device(dev);
libusb_get_device_descriptor(device, &desc);
if (desc.idProduct == USB_PID_MITSU_9550DS)
ctx->is_s_variant = 1;
ctx->type = lookup_printer_type(&mitsu9550_backend,
desc.idVendor, desc.idProduct);
}
@ -334,7 +337,7 @@ static int mitsu9550_main_loop(void *vctx, int copies) {
ptr = ctx->databuf;
top:
if (ctx->is_s_variant) {
if (ctx->type == P_MITSU_9550S) {
int num;
/* Send "unknown 1" command */
@ -399,7 +402,7 @@ top:
/* Now it's time for the actual print job! */
if (ctx->is_s_variant) {
if (ctx->type == P_MITSU_9550S) {
cmd.cmd[0] = 0x1b;
cmd.cmd[1] = 0x44;
cmd.cmd[2] = 0;
@ -457,7 +460,7 @@ top:
(uint8_t*) ptr, sizeof(struct mitsu9550_hdr3))))
return CUPS_BACKEND_FAILED;
ptr += sizeof(struct mitsu9550_hdr3);
if (!ctx->is_s_variant) {
if (ctx->type != P_MITSU_9550S) {
// XXX need to investigate what hdr4 is about
if ((ret = send_data(ctx->dev, ctx->endp_down,
(uint8_t*) ptr, sizeof(struct mitsu9550_hdr4))))
@ -465,7 +468,7 @@ top:
}
ptr += sizeof(struct mitsu9550_hdr4);
if (ctx->is_s_variant) {
if (ctx->type == P_MITSU_9550S) {
/* Send "start data" command */
cmd.cmd[0] = 0x1b;
cmd.cmd[1] = 0x5a;
@ -540,7 +543,7 @@ top:
}
}
if (ctx->is_s_variant) {
if (ctx->type == P_MITSU_9550S) {
/* Send "end data" command */
cmd.cmd[0] = 0x1b;
cmd.cmd[1] = 0x50;
@ -787,7 +790,7 @@ struct dyesub_backend mitsu9550_backend = {
.query_serno = mitsu9550_query_serno,
.devices = {
{ USB_VID_MITSU, USB_PID_MITSU_9550D, P_MITSU_9550, ""},
{ USB_VID_MITSU, USB_PID_MITSU_9550DS, P_MITSU_9550, ""},
{ USB_VID_MITSU, USB_PID_MITSU_9550DS, P_MITSU_9550S, ""},
{ 0, 0, 0, ""}
}
};

View File

@ -402,6 +402,8 @@ struct shinkos1245_ctx {
struct libusb_device_handle *dev;
uint8_t endp_up;
uint8_t endp_down;
int type;
uint8_t jobid;
struct s1245_printjob_hdr hdr;
@ -1257,15 +1259,25 @@ static void *shinkos1245_init(void)
return ctx;
}
extern struct dyesub_backend shinkos1245_backend;
static void shinkos1245_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
struct shinkos1245_ctx *ctx = vctx;
struct libusb_device *device;
struct libusb_device_descriptor desc;
ctx->dev = dev;
ctx->endp_up = endp_up;
ctx->endp_down = endp_down;
device = libusb_get_device(dev);
libusb_get_device_descriptor(device, &desc);
ctx->type = lookup_printer_type(&shinkos1245_backend,
desc.idVendor, desc.idProduct);
/* Ensure jobid is sane */
ctx->jobid = (jobid & 0x7f) + 1;
}

View File

@ -94,6 +94,8 @@ struct shinkos2145_ctx {
struct libusb_device_handle *dev;
uint8_t endp_up;
uint8_t endp_down;
int type;
uint8_t jobid;
struct s2145_printjob_hdr hdr;
@ -1414,15 +1416,25 @@ static void *shinkos2145_init(void)
return ctx;
}
extern struct dyesub_backend shinkos2145_backend;
static void shinkos2145_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
struct shinkos2145_ctx *ctx = vctx;
struct libusb_device *device;
struct libusb_device_descriptor desc;
ctx->dev = dev;
ctx->endp_up = endp_up;
ctx->endp_down = endp_down;
device = libusb_get_device(dev);
libusb_get_device_descriptor(device, &desc);
ctx->type = lookup_printer_type(&shinkos2145_backend,
desc.idVendor, desc.idProduct);
/* Ensure jobid is sane */
ctx->jobid = (jobid & 0x7f) + 1;
}

View File

@ -98,6 +98,8 @@ struct shinkos6145_ctx {
struct libusb_device_handle *dev;
uint8_t endp_up;
uint8_t endp_down;
int type;
uint8_t jobid;
struct s6145_printjob_hdr hdr;
@ -1498,15 +1500,25 @@ static void *shinkos6145_init(void)
return ctx;
}
extern struct dyesub_backend shinkos6145_backend;
static void shinkos6145_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
struct shinkos6145_ctx *ctx = vctx;
struct libusb_device *device;
struct libusb_device_descriptor desc;
ctx->dev = dev;
ctx->endp_up = endp_up;
ctx->endp_down = endp_down;
device = libusb_get_device(dev);
libusb_get_device_descriptor(device, &desc);
ctx->type = lookup_printer_type(&shinkos6145_backend,
desc.idVendor, desc.idProduct);
/* Ensure jobid is sane */
ctx->jobid = (jobid & 0x7f) + 1;
}

View File

@ -93,6 +93,8 @@ struct shinkos6245_ctx {
struct libusb_device_handle *dev;
uint8_t endp_up;
uint8_t endp_down;
int type;
uint8_t jobid;
struct s6245_printjob_hdr hdr;
@ -1492,14 +1494,24 @@ static void *shinkos6245_init(void)
return ctx;
}
extern struct dyesub_backend shinkos6245_backend;
static void shinkos6245_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
struct shinkos6245_ctx *ctx = vctx;
struct libusb_device *device;
struct libusb_device_descriptor desc;
ctx->dev = dev;
ctx->endp_up = endp_up;
ctx->endp_down = endp_down;
device = libusb_get_device(dev);
libusb_get_device_descriptor(device, &desc);
ctx->type = lookup_printer_type(&shinkos6245_backend,
desc.idVendor, desc.idProduct);
/* Ensure jobid is sane */
ctx->jobid = (jobid & 0x7f) + 1;

View File

@ -48,12 +48,12 @@ struct updr150_ctx {
struct libusb_device_handle *dev;
uint8_t endp_up;
uint8_t endp_down;
int type;
uint8_t *databuf;
int datalen;
uint32_t copies_offset;
uint8_t type;
};
static void* updr150_init(void)
@ -67,6 +67,8 @@ static void* updr150_init(void)
return ctx;
}
extern struct dyesub_backend updr150_backend;
static void updr150_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
@ -82,11 +84,9 @@ static void updr150_attach(void *vctx, struct libusb_device_handle *dev,
device = libusb_get_device(dev);
libusb_get_device_descriptor(device, &desc);
if (desc.idProduct == USB_PID_SONY_UPDR150 ||
desc.idProduct == USB_PID_SONY_UPDR200)
ctx->type = P_SONY_UPDR150;
else
ctx->type = P_SONY_UPCR10; // XXX
ctx->type = lookup_printer_type(&updr150_backend,
desc.idVendor, desc.idProduct);
ctx->copies_offset = 0;
}