8
8
* License as published by the Free Software Foundation; either
9
9
* version 2 of the License, or (at your option) any later version.
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
14
* Lesser General Public License for more details.
16
16
* You should have received a copy of the GNU Lesser General Public
17
17
* License along with this library; if not, write to the
49
49
#define GP_MODULE "jl2005c"
53
53
CameraDriverStatus status;
54
unsigned short idVendor;
55
unsigned short idProduct;
54
unsigned short idVendor;
55
unsigned short idProduct;
57
57
{" JL2005B/C/D camera", GP_DRIVER_STATUS_EXPERIMENTAL, 0x0979, 0x0227},
58
{"Argus DC1512e", GP_DRIVER_STATUS_EXPERIMENTAL, 0x0979, 0x0227},
58
{"Argus DC1512e", GP_DRIVER_STATUS_EXPERIMENTAL, 0x0979, 0x0227},
59
59
{"Amazing Spiderman", GP_DRIVER_STATUS_EXPERIMENTAL, 0x0979, 0x0227},
60
60
{"Aries ATC-0017", GP_DRIVER_STATUS_EXPERIMENTAL, 0x0979, 0x0227},
61
{"Sakar no. 75379", GP_DRIVER_STATUS_EXPERIMENTAL, 0x0979, 0x0227},
61
{"Sakar no. 75379", GP_DRIVER_STATUS_EXPERIMENTAL, 0x0979, 0x0227},
62
62
{"Sakar no. 81890", GP_DRIVER_STATUS_EXPERIMENTAL, 0x0979, 0x0227},
63
63
{"Sakar Nickelodeon iCarly no. 88061", GP_DRIVER_STATUS_EXPERIMENTAL,
67
67
{"Sakar no. 91379", GP_DRIVER_STATUS_EXPERIMENTAL, 0x0979, 0x0227},
68
68
{"Sakar no. 98379", GP_DRIVER_STATUS_EXPERIMENTAL, 0x0979, 0x0227},
69
{"Sakar Kidz-Cam no. 88379", GP_DRIVER_STATUS_EXPERIMENTAL,
71
{"Sakar clipshot no. 1169x", GP_DRIVER_STATUS_EXPERIMENTAL,
73
{"Sakar Sticker Wizard no. 59379", GP_DRIVER_STATUS_EXPERIMENTAL,
69
{"Sakar Kidz-Cam no. 88379", GP_DRIVER_STATUS_EXPERIMENTAL,
71
{"Sakar clipshot no. 1169x", GP_DRIVER_STATUS_EXPERIMENTAL,
73
{"Sakar Sticker Wizard no. 59379", GP_DRIVER_STATUS_EXPERIMENTAL,
75
75
{"Sakar Star Wars kit no. 92022", GP_DRIVER_STATUS_EXPERIMENTAL,
77
77
{"Jazwares Star Wars no. 15256", GP_DRIVER_STATUS_EXPERIMENTAL,
79
{"Argus Bean Sprout", GP_DRIVER_STATUS_EXPERIMENTAL,
79
{"Argus Bean Sprout", GP_DRIVER_STATUS_EXPERIMENTAL,
81
81
{"Global Point Clipster", GP_DRIVER_STATUS_EXPERIMENTAL,
83
83
{"Global Point 3 in 1 Digital Fun Graffiti 00044",
87
87
GP_DRIVER_STATUS_EXPERIMENTAL, 0x0979, 0x0227},
88
88
{"Vivitar Freelance", GP_DRIVER_STATUS_EXPERIMENTAL,
90
{"Sakar Hello Kitty no. 94009", GP_DRIVER_STATUS_EXPERIMENTAL,
94
96
camera_id (CameraText *id)
96
98
strcpy (id->text, "JL2005B/C/D camera");
101
103
camera_abilities (CameraAbilitiesList *list)
106
for (i = 0; models[i].name; i++) {
107
memset (&a, 0, sizeof(a));
108
strcpy (a.model, models[i].name);
109
a.status = models[i].status;
110
a.port = GP_PORT_USB;
112
a.usb_vendor = models[i].idVendor;
113
a.usb_product= models[i].idProduct;
114
if (a.status == GP_DRIVER_STATUS_EXPERIMENTAL)
108
for (i = 0; models[i].name; i++) {
109
memset (&a, 0, sizeof(a));
110
strcpy (a.model, models[i].name);
111
a.status = models[i].status;
112
a.port = GP_PORT_USB;
114
a.usb_vendor = models[i].idVendor;
115
a.usb_product= models[i].idProduct;
116
if (a.status == GP_DRIVER_STATUS_EXPERIMENTAL)
115
117
a.operations = GP_OPERATION_NONE;
117
119
a.operations = GP_OPERATION_CAPTURE_IMAGE;
118
120
a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL;
119
a.file_operations = GP_FILE_OPERATION_PREVIEW
120
+ GP_FILE_OPERATION_RAW;
121
gp_abilities_list_append (list, a);
121
a.file_operations = GP_FILE_OPERATION_PREVIEW
122
+ GP_FILE_OPERATION_RAW;
123
gp_abilities_list_append (list, a);
131
133
GP_DEBUG("camera->pl->nb_entries = %i\n",camera->pl->nb_entries);
132
134
sprintf(summary->text,
133
135
_("This camera contains a Jeilin JL2005%c chipset.\n"
134
"The number of photos in it is %i. \n"),
135
camera->pl->model, num_pics);
136
"The number of photos in it is %i. \n"),
137
camera->pl->model, num_pics);
140
142
camera_manual (Camera *camera, CameraText *manual, GPContext *context)
144
146
"This driver supports cameras with Jeilin JL2005B or C or D chip \n"
145
147
"These cameras do not support deletion of photos, nor uploading\n"
159
161
strcpy (about->text, _("jl2005bcd camera library\n"
160
162
"Theodore Kilgore <kilgota@auburn.edu>\n"));
164
166
/*************** File and Downloading Functions *******************/
167
169
file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
168
void *data, GPContext *context)
170
void *data, GPContext *context)
170
Camera *camera = data;
172
Camera *camera = data;
172
174
n = camera->pl->nb_entries;
173
gp_list_populate (list, "jl_%03i.ppm", n);
175
gp_list_populate (list, "jl_%03i.ppm", n);
178
180
get_info_func (CameraFilesystem *fs, const char *folder, const char *filename,
179
CameraFileInfo *info, void *data, GPContext *context)
181
CameraFileInfo *info, void *data, GPContext *context)
181
183
info->file.fields = GP_FILE_INFO_TYPE;
182
184
strcpy (info->file.type, GP_MIME_PPM);
188
190
get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
189
CameraFileType type, CameraFile *file, void *user_data,
191
CameraFileType type, CameraFile *file, void *user_data,
192
Camera *camera = user_data;
194
Camera *camera = user_data;
193
195
int w, h = 0, b = 0, k;
194
196
unsigned char *pic_data, *pic_buffer, *pic_output = NULL;
195
197
int HEADERSIZE=16;
205
207
if (GP_FILE_TYPE_EXIF == type) return GP_ERROR_FILE_EXISTS;
207
209
/* Get the number of the photo on the camera */
208
k = gp_filesystem_number (camera->fs, "/", filename, context);
210
k = gp_filesystem_number (camera->fs, "/", filename, context);
209
211
h = camera->pl->table[16 * k + 4] << 3;
210
212
w = camera->pl->table[16 * k + 5] << 3;
212
214
GP_DEBUG ("height is %i\n", h);
214
216
b = jl2005c_get_pic_data_size(camera->pl, camera->pl->table, k);
215
GP_DEBUG("b = %i = 0x%x bytes\n", b,b);
216
start_of_photo = jl2005c_get_start_of_photo(camera->pl,
217
GP_DEBUG("b = %i = 0x%x bytes\n", b, b);
218
start_of_photo = jl2005c_get_start_of_photo(camera->pl,
217
219
camera->pl->table, k);
218
220
GP_DEBUG("start_of_photo number %i = 0x%lx \n", k,start_of_photo);
219
221
pic_buffer = malloc(b + HEADERSIZE);
220
222
if (!pic_buffer) return GP_ERROR_NO_MEMORY;
221
223
memset(pic_buffer, 0, b + HEADERSIZE);
222
GP_DEBUG ("buffersize b+16 = %i = 0x%x bytes\n", b+16,b+16);
224
GP_DEBUG("buffersize b + 16 = %i = 0x%x bytes\n", b + 16, b + 16);
223
225
/* Copy info line for photo from allocation table, as header */
224
226
memcpy(pic_buffer, camera->pl->table + 16 * k, 16);
225
pic_data = pic_buffer+HEADERSIZE;
227
pic_data = pic_buffer + HEADERSIZE;
228
230
* Camera can download in blocks of 0xfa00, with only the last block
239
241
GP_DEBUG ("no cache memory allocated!\n");
240
242
return GP_ERROR_NO_MEMORY;
243
/* Is there data in the cache, or not? If yes, read from it into the
245
/* Is there data in the cache, or not? If yes, read from it into the
244
246
* current photo, immediately. Update settings. But first two sanity
248
250
if (start_of_photo < camera->pl->bytes_put_away) {
249
251
GP_DEBUG("photo number %i starts in a funny place!\n",k);
250
252
/* We need to start all over again to get this photo. */
251
jl2005c_reset(camera, camera->port);
253
jl2005c_reset (camera, camera->port);
252
254
jl2005c_init (camera, camera->port, camera->pl);
254
if (start_of_photo+b > camera->pl->total_data_in_camera) {
256
if (start_of_photo + b > camera->pl->total_data_in_camera) {
255
257
GP_DEBUG ("Photo runs past end of data. Exiting. \n");
256
258
GP_DEBUG ("Block size may be wrong for this camera\n");
257
259
return (GP_ERROR);
260
262
* This while loop is entered if the photo number k-1 was not requested
261
* and thus has not been downloaded. The camera's rudimentary hardware
263
* and thus has not been downloaded. The camera's rudimentary hardware
262
264
* obliges us to download all data consecutively and toss whatever
263
265
* portion of said data that we do not intend to use. The rudimentary
264
266
* hardware also does not like to stop downloading at the end of one
279
281
GP_DEBUG("downloadsize = 0x%x\n", downloadsize);
280
282
if (downloadsize)
281
283
jl2005c_read_data (
283
(char *) camera->pl->data_cache,
285
(char *) camera->pl->data_cache,
285
287
camera->pl->bytes_read_from_camera += downloadsize;
288
camera->pl->bytes_put_away=start_of_photo;
290
camera->pl->bytes_put_away = start_of_photo;
290
292
if (camera->pl->bytes_read_from_camera > start_of_photo) {
291
293
if(start_of_photo + b <= camera->pl->bytes_read_from_camera) {
292
294
memcpy(pic_data, camera->pl->data_cache
293
295
+ (start_of_photo % MAX_DLSIZE)
295
297
camera->pl->bytes_put_away += b;
297
299
* Photo data is contained in what is already
299
* Jump immediately to process the photo.
301
* Jump immediately to process the photo.
302
304
/* Photo starts in one 0xfa00-sized download and ends
304
filled = camera->pl->bytes_read_from_camera
306
filled = camera->pl->bytes_read_from_camera
305
307
- start_of_photo;
307
309
memcpy(pic_data, camera->pl->data_cache
308
310
+ (start_of_photo % MAX_DLSIZE),
311
313
camera->pl->bytes_put_away += filled;
321
323
GP_DEBUG("downloadsize = 0x%x\n", downloadsize);
322
324
if (downloadsize)
323
325
jl2005c_read_data (
325
(char *) camera->pl->data_cache,
327
(char *) camera->pl->data_cache,
327
329
camera->pl->bytes_read_from_camera += downloadsize;
329
331
if (camera->pl->bytes_read_from_camera >=
330
332
start_of_photo + b ) {
331
333
GP_DEBUG("THIS ONE?\n");
332
memcpy(pic_data+filled, camera->pl->data_cache,
334
memcpy(pic_data + filled, camera->pl->data_cache,
334
336
camera->pl->bytes_put_away += b - filled;
337
339
GP_DEBUG("THIS ONE??\n");
338
340
if (!downloadsize)
347
349
if (type == GP_FILE_TYPE_RAW) {
348
350
gp_file_set_mime_type(file, GP_MIME_RAW);
349
gp_file_set_data_and_size(file, (char *)pic_buffer , b+16 );
351
gp_file_set_data_and_size(file, (char *)pic_buffer, b + 16);
351
353
#ifdef HAVE_LIBJPEG
352
354
} else if (type == GP_FILE_TYPE_PREVIEW) {
385
387
return GP_ERROR_NOT_SUPPORTED;
391
393
delete_all_func (CameraFilesystem *fs, const char *folder, void *data,
392
394
GPContext *context)
394
Camera *camera = data;
396
GP_DEBUG(" * delete_all_func()");
397
jl2005c_delete_all(camera, camera->port);
396
Camera *camera = data;
398
GP_DEBUG(" * delete_all_func()");
399
jl2005c_delete_all(camera, camera->port);
427
camera_init(Camera *camera, GPContext *context)
429
camera_init (Camera *camera, GPContext *context)
429
431
GPPortSettings settings;
432
434
/* First, set up all the function pointers */
433
435
camera->functions->manual = camera_manual;
434
camera->functions->summary = camera_summary;
435
camera->functions->about = camera_about;
436
camera->functions->exit = camera_exit;
436
camera->functions->summary = camera_summary;
437
camera->functions->about = camera_about;
438
camera->functions->exit = camera_exit;
438
440
GP_DEBUG ("Initializing the camera\n");
439
441
ret = gp_port_get_settings(camera->port,&settings);
440
442
if (ret < 0) return ret;
457
459
ret = gp_port_set_settings(camera->port,settings);
458
if (ret < 0) return ret;
460
if (ret < 0) return ret;
460
462
GP_DEBUG("interface = %i\n", settings.usb.interface);
461
GP_DEBUG("inep = %x\n", settings.usb.inep);
463
GP_DEBUG("inep = %x\n", settings.usb.inep);
462
464
GP_DEBUG("outep = %x\n", settings.usb.outep);
464
/* Tell the CameraFilesystem where to get lists from */
466
/* Tell the CameraFilesystem where to get lists from */
465
467
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
467
469
camera->pl = malloc (sizeof (CameraPrivateLibrary));
474
476
camera->pl->data_reg_opened = 0;
475
477
camera->pl->data_cache = NULL;
476
478
camera->pl->init_done = 0;
477
jl2005c_init (camera,camera->port, camera->pl);
479
jl2005c_init (camera, camera->port, camera->pl);