summaryrefslogtreecommitdiff
path: root/graphics/gphoto2/patches/patch-af
blob: 2e13ec65707ba1f7041e3caebd9c56c4f8ad6c0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
$NetBSD: patch-af,v 1.1 2001/07/08 21:45:33 veego Exp $

--- camlibs/kodak/dc240/dc240.c	Mon Mar 26 19:25:46 2001
+++ camlibs/kodak/dc240/dc240.c	Sun Jul  8 23:35:55 2001
@@ -29,13 +29,33 @@
 	return (GP_OK);
 }
 
+struct camera_to_usb {
+	char *name;
+	unsigned short idVendor;
+	unsigned short idProduct;
+} camera_to_usb[] = {
+	{ "Kodak DC240", 0x040A, 0x0120 },
+	{ "Kodak DC280", 0x040A, 0x0130 },
+	{ "Kodak DC3400", 0x040A, 0x0132 },
+	{ "Kodak DC5000", 0x040A, 0x0131 },
+        { NULL, 0, 0 }
+};
+
+/*
+  Abilities are based upon what we can do with a DC240.
+  Later cameras have a superset of the DC240 feature and are not
+  currently supported.
+ */
 int camera_abilities (CameraAbilitiesList *list) 
 {
 	CameraAbilities *a;
+        int i;
 
+        for (i = 0; camera_to_usb[i].name; i++)
+        {
 	a = gp_abilities_new();
 
-	strcpy(a->model, "Kodak DC240");
+            strcpy(a->model, camera_to_usb[i].name);
 	a->port     = GP_PORT_SERIAL | GP_PORT_USB;
 	a->speed[0] = 9600;
 	a->speed[1] = 19200;
@@ -43,20 +63,38 @@
 	a->speed[3] = 57600;
 	a->speed[4] = 115200;
 	a->speed[5] = 0;
-        a->usb_vendor  = 0x040A;
-        a->usb_product = 0x0120;
+            a->usb_vendor  = camera_to_usb[i].idVendor;
+            a->usb_product = camera_to_usb[i].idProduct;
 	a->operations        = 	GP_OPERATION_CAPTURE_IMAGE;
 	a->file_operations   = 	GP_FILE_OPERATION_DELETE | 
 				GP_FILE_OPERATION_PREVIEW;
 	a->folder_operations = 	GP_FOLDER_OPERATION_NONE;
 
 	gp_abilities_list_append(list, a);
-
+        }
 	return (GP_OK);
 }
 
+static short find_usb_device_id (const char *model, unsigned short *idVendor, 
+                             unsigned short *idProduct)
+{
+    short i;
+    for (i = 0; i < sizeof (camera_to_usb) / sizeof (struct camera_to_usb); i++)
+    {
+        if (strcmp (model, camera_to_usb[i].name) == 0)
+        {
+            *idVendor = camera_to_usb[i].idVendor;
+            *idProduct = camera_to_usb[i].idProduct;
+            return 1;
+        }
+    }
+
+    return 0;
+}
+
 int camera_init (Camera *camera) 
 {
+    unsigned short usb_vendor, usb_product;
     int ret;
     gp_port_settings settings;
     DC240Data *dd;
@@ -100,7 +138,12 @@
             free(dd);
             return (GP_ERROR);
         }
-        if (gp_port_usb_find_device(dd->dev, 0x040A, 0x0120) == GP_ERROR) {
+        if (find_usb_device_id (camera->model, &usb_vendor, &usb_product) == 0) {
+            gp_port_free(dd->dev);
+            free (dd);
+            return (GP_ERROR);
+        }
+        if (gp_port_usb_find_device(dd->dev, usb_vendor, usb_product) == GP_ERROR) {
             gp_port_free(dd->dev);
             free (dd);
             return (GP_ERROR);
@@ -260,7 +303,7 @@
 	strcpy (about->text, 
 		_("Kodak DC240 Camera Library\n"
 		"Scott Fritzinger <scottf@gphoto.net>\n"
-		"Camera Library for the Kodak DC240 camera.\n"
+		"Camera Library for the Kodak DC240, DC260, DC3400 and DC5000 cameras.\n"
 		"Rewritten and updated for gPhoto2."));
 
 	return (GP_OK);