all: Move USB device IDs into respective backends.

This is also untested.
This commit is contained in:
Solomon Peachy 2013-07-18 23:39:36 -04:00
parent 587dd52247
commit 2730a145d4
7 changed files with 135 additions and 117 deletions

View File

@ -27,94 +27,11 @@
#include "backend_common.h"
#define BACKEND_VERSION "0.10"
#define BACKEND_VERSION "0.11"
#ifndef URI_PREFIX
#define URI_PREFIX "gutenprint+usb"
#endif
#define USB_VID_CANON 0x04a9
#define USB_PID_CANON_CP10 0x304A
#define USB_PID_CANON_CP100 0x3063
#define USB_PID_CANON_CP200 0x307C
#define USB_PID_CANON_CP220 0x30BD
#define USB_PID_CANON_CP300 0x307D
#define USB_PID_CANON_CP330 0x30BE
#define USB_PID_CANON_CP400 0x30F6
#define USB_PID_CANON_CP500 0x30F5
#define USB_PID_CANON_CP510 0x3128
#define USB_PID_CANON_CP520 520 // XXX 316f? 3172? (related to cp740/cp750)
#define USB_PID_CANON_CP530 0x31b1
#define USB_PID_CANON_CP600 0x310B
#define USB_PID_CANON_CP710 0x3127
#define USB_PID_CANON_CP720 0x3143
#define USB_PID_CANON_CP730 0x3142
#define USB_PID_CANON_CP740 0x3171
#define USB_PID_CANON_CP750 0x3170
#define USB_PID_CANON_CP760 0x31AB
#define USB_PID_CANON_CP770 0x31AA
#define USB_PID_CANON_CP780 0x31DD
#define USB_PID_CANON_CP790 790 // XXX 31ed? 31ef? (related to es40)
#define USB_PID_CANON_CP800 0x3214
#define USB_PID_CANON_CP810 0x3256
#define USB_PID_CANON_CP900 0x3255
#define USB_PID_CANON_ES1 0x3141
#define USB_PID_CANON_ES2 0x3185
#define USB_PID_CANON_ES20 0x3186
#define USB_PID_CANON_ES3 0x31AF
#define USB_PID_CANON_ES30 0x31B0
#define USB_PID_CANON_ES40 0x31EE
#define USB_VID_SONY 0x054C
#define USB_PID_SONY_UPDR150 0x01E8
#define USB_VID_KODAK 0x040A
#define USB_PID_KODAK_6800 0x4021
#define USB_PID_KODAK_1400 0x4022
#define USB_PID_KODAK_805 0x4034
#define USB_VID_SHINKO 0x10CE
#define USB_PID_SHINKO_S2145 0x000E
static struct device_id devices[] = {
{ USB_VID_CANON, USB_PID_CANON_CP10, P_CP10, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP100, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP200, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP220, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP300, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP330, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP400, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP500, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP510, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP520, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP530, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP600, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP710, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP720, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP730, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP740, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP750, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP760, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP770, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP780, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP790, P_ES40_CP790, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP800, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP810, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP900, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_ES1, P_ES1, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_ES2, P_ES2_20, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_ES20, P_ES2_20, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_ES3, P_ES3_30, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_ES30, P_ES3_30, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_ES40, P_ES40_CP790, "Canon"},
{ USB_VID_KODAK, USB_PID_KODAK_6800, P_KODAK_6800, "Kodak"},
{ USB_VID_KODAK, USB_PID_KODAK_1400, P_KODAK_1400_805, "Kodak"},
{ USB_VID_KODAK, USB_PID_KODAK_805, P_KODAK_1400_805, "Kodak"},
{ USB_VID_SHINKO, USB_PID_SHINKO_S2145, P_SHINKO_S2145, ""},
{ USB_VID_SONY, USB_PID_SONY_UPDR150, P_SONY_UPDR150, ""},
};
/* Support Functions */
#define ID_BUF_SIZE 2048
@ -293,6 +210,15 @@ abort:
return found;
}
static struct dyesub_backend *backends[] = {
&canonselphy_backend,
&kodak6800_backend,
&kodak1400_backend,
&shinkos2145_backend,
&updr150_backend,
NULL,
};
static int find_and_enumerate(struct libusb_context *ctx,
struct libusb_device ***list,
char *match_serno,
@ -300,7 +226,7 @@ static int find_and_enumerate(struct libusb_context *ctx,
int scan_only)
{
int num;
int i, j;
int i, j, k;
int found = -1;
/* Enumerate and find suitable device */
@ -311,15 +237,19 @@ static int find_and_enumerate(struct libusb_context *ctx,
int match = 0;
libusb_get_device_descriptor((*list)[i], &desc);
for (j = 0 ; j < sizeof(devices)/sizeof(struct device_id) ; j++) {
if (desc.idVendor == devices[j].vid &&
desc.idProduct == devices[j].pid) {
for (k = 0 ; backends[k] ; k++) {
for (j = 0 ; backends[k]->devices[j].vid ; j++) {
if (desc.idVendor == backends[k]->devices[j].vid &&
desc.idProduct == backends[k]->devices[j].pid) {
match = 1;
if (printer_type && printer_type == devices[j].type)
if (printer_type && printer_type == backends[k]->devices[j].type)
found = i;
break;
}
}
}
if (!match) {
if (getenv("EXTRA_PID") && getenv("EXTRA_TYPE") && getenv("EXTRA_VID")) {
@ -339,7 +269,7 @@ static int find_and_enumerate(struct libusb_context *ctx,
continue;
found = print_scan_output((*list)[i], &desc,
URI_PREFIX, devices[j].manuf_str,
URI_PREFIX, backends[k]->devices[j].manuf_str,
found, (found == i),
scan_only, match_serno);
}
@ -347,15 +277,6 @@ static int find_and_enumerate(struct libusb_context *ctx,
return found;
}
static struct dyesub_backend *backends[] = {
&canonselphy_backend,
&kodak6800_backend,
&kodak1400_backend,
&shinkos2145_backend,
&updr150_backend,
NULL,
};
static struct dyesub_backend *find_backend(char *uri_prefix)
{
int i;

View File

@ -78,20 +78,6 @@
#define cpu_to_be16 be16_to_cpu
#define cpu_to_be32 be32_to_cpu
/* Backend Functions */
struct dyesub_backend {
char *name;
char *version;
char *uri_prefix;
void (*cmdline_usage)(char *caller);
void *(*init)(struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid);
void (*teardown)(void *ctx);
int (*cmdline_arg)(void *ctx, int run, char *arg1, char *arg2);
int (*read_parse)(void *ctx, int data_fd);
int (*main_loop)(void *ctx, int copies);
};
/* To enumerate supported devices */
enum {
P_ANY = 0,
@ -115,6 +101,22 @@ struct device_id {
char *manuf_str;
};
/* Backend Functions */
struct dyesub_backend {
char *name;
char *version;
char *uri_prefix;
void (*cmdline_usage)(char *caller);
void *(*init)(struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid);
void (*teardown)(void *ctx);
int (*cmdline_arg)(void *ctx, int run, char *arg1, char *arg2);
int (*read_parse)(void *ctx, int data_fd);
int (*main_loop)(void *ctx, int copies);
struct device_id devices[];
};
/* Exported functions */
int send_data(struct libusb_device_handle *dev, uint8_t endp,
uint8_t *buf, int len);

View File

@ -541,6 +541,10 @@ top:
}
/* Exported */
#define USB_VID_KODAK 0x040A
#define USB_PID_KODAK_1400 0x4022
#define USB_PID_KODAK_805 0x4034
struct dyesub_backend kodak1400_backend = {
.name = "Kodak 1400/805",
.version = "0.21",
@ -551,6 +555,11 @@ struct dyesub_backend kodak1400_backend = {
.teardown = kodak1400_teardown,
.read_parse = kodak1400_read_parse,
.main_loop = kodak1400_main_loop,
.devices = {
{ USB_VID_KODAK, USB_PID_KODAK_1400, P_KODAK_1400_805, "Kodak"},
{ USB_VID_KODAK, USB_PID_KODAK_805, P_KODAK_1400_805, "Kodak"},
{ 0, 0, 0, ""}
}
};
/* Kodak 1400/805 data format

View File

@ -516,6 +516,9 @@ top:
}
/* Exported */
#define USB_VID_KODAK 0x040A
#define USB_PID_KODAK_6800 0x4021
struct dyesub_backend kodak6800_backend = {
.name = "Kodak 6800",
.version = "0.15",
@ -526,6 +529,10 @@ struct dyesub_backend kodak6800_backend = {
.teardown = kodak6800_teardown,
.read_parse = kodak6800_read_parse,
.main_loop = kodak6800_main_loop,
.devices = {
{ USB_VID_KODAK, USB_PID_KODAK_6800, P_KODAK_6800, "Kodak"},
{ 0, 0, 0, ""}
}
};
/* Kodak 6800/6850 data format

View File

@ -580,6 +580,38 @@ top:
}
/* Exported */
#define USB_VID_CANON 0x04a9
#define USB_PID_CANON_CP10 0x304A
#define USB_PID_CANON_CP100 0x3063
#define USB_PID_CANON_CP200 0x307C
#define USB_PID_CANON_CP220 0x30BD
#define USB_PID_CANON_CP300 0x307D
#define USB_PID_CANON_CP330 0x30BE
#define USB_PID_CANON_CP400 0x30F6
#define USB_PID_CANON_CP500 0x30F5
#define USB_PID_CANON_CP510 0x3128
#define USB_PID_CANON_CP520 520 // XXX 316f? 3172? (related to cp740/cp750)
#define USB_PID_CANON_CP530 0x31b1
#define USB_PID_CANON_CP600 0x310B
#define USB_PID_CANON_CP710 0x3127
#define USB_PID_CANON_CP720 0x3143
#define USB_PID_CANON_CP730 0x3142
#define USB_PID_CANON_CP740 0x3171
#define USB_PID_CANON_CP750 0x3170
#define USB_PID_CANON_CP760 0x31AB
#define USB_PID_CANON_CP770 0x31AA
#define USB_PID_CANON_CP780 0x31DD
#define USB_PID_CANON_CP790 790 // XXX 31ed? 31ef? (related to es40)
#define USB_PID_CANON_CP800 0x3214
#define USB_PID_CANON_CP810 0x3256
#define USB_PID_CANON_CP900 0x3255
#define USB_PID_CANON_ES1 0x3141
#define USB_PID_CANON_ES2 0x3185
#define USB_PID_CANON_ES20 0x3186
#define USB_PID_CANON_ES3 0x31AF
#define USB_PID_CANON_ES30 0x31B0
#define USB_PID_CANON_ES40 0x31EE
struct dyesub_backend canonselphy_backend = {
.name = "Canon SELPHY CP/ES",
.version = "0.57",
@ -588,6 +620,39 @@ struct dyesub_backend canonselphy_backend = {
.teardown = canonselphy_teardown,
.read_parse = canonselphy_read_parse,
.main_loop = canonselphy_main_loop,
.devices = {
{ USB_VID_CANON, USB_PID_CANON_CP10, P_CP10, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP100, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP200, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP220, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP300, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP330, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP400, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP500, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP510, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP520, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP530, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP600, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP710, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP720, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP730, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP740, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP750, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP760, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP770, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP780, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP790, P_ES40_CP790, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP800, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP810, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_CP900, P_CP_XXX, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_ES1, P_ES1, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_ES2, P_ES2_20, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_ES20, P_ES2_20, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_ES3, P_ES3_30, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_ES30, P_ES3_30, "Canon"},
{ USB_VID_CANON, USB_PID_CANON_ES40, P_ES40_CP790, "Canon"},
{ 0, 0, 0, ""}
}
};
/*

View File

@ -1353,6 +1353,9 @@ printer_error:
}
/* Exported */
#define USB_VID_SHINKO 0x10CE
#define USB_PID_SHINKO_S2145 0x000E
struct dyesub_backend shinkos2145_backend = {
.name = "Shinko/Sinfonia CHC-S2145",
.version = "0.17",
@ -1363,6 +1366,10 @@ struct dyesub_backend shinkos2145_backend = {
.teardown = shinkos2145_teardown,
.read_parse = shinkos2145_read_parse,
.main_loop = shinkos2145_main_loop,
.devices = {
{ USB_VID_SHINKO, USB_PID_SHINKO_S2145, P_SHINKO_S2145, ""},
{ 0, 0, 0, ""}
}
};
/* CHC-S2145 data format

View File

@ -152,6 +152,9 @@ top:
}
/* Exported */
#define USB_VID_SONY 0x054C
#define USB_PID_SONY_UPDR150 0x01E8
struct dyesub_backend updr150_backend = {
.name = "Sony UP-DR150",
.version = "0.05",
@ -161,6 +164,10 @@ struct dyesub_backend updr150_backend = {
.teardown = updr150_teardown,
.read_parse = updr150_read_parse,
.main_loop = updr150_main_loop,
.devices = {
{ USB_VID_SONY, USB_PID_SONY_UPDR150, P_SONY_UPDR150, ""},
{ 0, 0, 0, ""}
}
};
/* Sony UP-DR150 Spool file format