fix white-space and indentation inconsistencies (second round)

This is basically a continuation of the work from #1002 but her for the
camlibs directory. The purpose was to replace spaces as a means for
indentation with tab characters.

Note: there are some files which are still offending the general
rule but are (mostly) consistent within themselves. I let them be for
the moment. Fixing them would basically replace the whole file.

Also: there are still a ton of whitespace related inconsistencies like
"x=10" vs "x = 10" or "func(10)" vs "func (10)".

This is a whitespace only change (if you include newlines as whitespace).
This commit is contained in:
axxel
2024-09-14 18:26:05 +02:00
committed by Marcus Meissner
parent e68b3ea37b
commit f41df32817
123 changed files with 5139 additions and 5244 deletions

View File

@@ -74,15 +74,15 @@ adc65_ping(Camera *camera) {
static int static int
adc65_file_count (Camera *camera) { adc65_file_count (Camera *camera) {
unsigned char cmd, resp[65538]; unsigned char cmd, resp[65538];
int ret; int ret;
GP_DEBUG("Getting the number of pictures."); GP_DEBUG("Getting the number of pictures.");
cmd = 0x00; cmd = 0x00;
ret = adc65_exchange(camera, &cmd, 1, resp, 65538); ret = adc65_exchange(camera, &cmd, 1, resp, 65538);
if (ret < 2) /* must have at least a 2 byte reply */ if (ret < 2) /* must have at least a 2 byte reply */
return ret; return ret;
return resp[1] - 1; return resp[1] - 1;
} }
static char * static char *
@@ -102,7 +102,7 @@ adc65_read_data (Camera *camera, unsigned char *cmd, int cmd_size, int data_type
/* get the picture */ /* get the picture */
ret = adc65_exchange (camera, cmd, cmd_size, resp, 2); ret = adc65_exchange (camera, cmd, cmd_size, resp, 2);
if (ret < 2) if (ret < 2)
return NULL; return NULL;
us = malloc (65536); us = malloc (65536);
if (!us) if (!us)
@@ -224,23 +224,23 @@ get_file_func ( CameraFilesystem *fs, const char *folder,
CameraFile *file, void *user_data, GPContext *context) CameraFile *file, void *user_data, GPContext *context)
{ {
Camera *camera = user_data; Camera *camera = user_data;
int size, num; int size, num;
char *data; char* data;
gp_file_set_mime_type (file, GP_MIME_PPM); gp_file_set_mime_type (file, GP_MIME_PPM);
num = gp_filesystem_number (fs, folder, filename, context); num = gp_filesystem_number (fs, folder, filename, context);
if (num < 0) if (num < 0)
return num; return num;
data = adc65_read_picture (camera, num, &size); data = adc65_read_picture (camera, num, &size);
if (!data) if (!data)
return GP_ERROR; return GP_ERROR;
return gp_file_append (file,data,size); return gp_file_append (file, data, size);
} }
static int static int
camera_about (Camera *camera, CameraText *about, GPContext *context) { camera_about (Camera *camera, CameraText *about, GPContext *context) {
strcpy (about->text, _("Adc65\nBenjamin Moos <benjamin@psnw.com>")); strcpy (about->text, _("Adc65\nBenjamin Moos <benjamin@psnw.com>"));
return GP_OK; return GP_OK;
} }
static CameraFilesystemFuncs fsfuncs = { static CameraFilesystemFuncs fsfuncs = {

View File

@@ -233,8 +233,8 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
result[19] = 0x00; result[19] = 0x00;
memmove(&result[20], memmove(&result[20],
&result[app1len + 4], &result[app1len + 4],
(unsigned int)(size - app1len - 4)); (unsigned int)(size - app1len - 4));
size = size - app1len + 20 + 4; size = size - app1len + 20 + 4;
@@ -439,8 +439,8 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
result[19] = 0x00; result[19] = 0x00;
memmove(&result[20], memmove(&result[20],
&result[app1len + 4], &result[app1len + 4],
(unsigned int)(size - app1len - 4)); (unsigned int)(size - app1len - 4));
size = size - app1len + 24; size = size - app1len + 24;
@@ -664,10 +664,10 @@ camera_init (Camera *camera, GPContext *context)
GP_DEBUG(" * camera_init()"); GP_DEBUG(" * camera_init()");
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->exit = camera_exit; camera->functions->exit = camera_exit;
camera->functions->summary = camera_summary; camera->functions->summary = camera_summary;
camera->functions->about = camera_about; camera->functions->about = camera_about;
/* Now, tell the filesystem where to get lists, files and info */ /* Now, tell the filesystem where to get lists, files and info */
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);

View File

@@ -49,27 +49,27 @@ int aox_init (GPPort *port, Model *model, Info *info)
READ(port, 1, 0, 0, c,0x10); READ(port, 1, 0, 0, c,0x10);
WRITE(port, 8, 1, 0, c, 0x10); WRITE(port, 8, 1, 0, c, 0x10);
READ(port, 0xff, 0x07, 0xfffc, c, 4); /* Returns version number, apparently */ READ(port, 0xff, 0x07, 0xfffc, c, 4); /* Returns version number, apparently */
READ(port, 0x06, 0x0, 0x0, c, 2); READ(port, 0x06, 0x0, 0x0, c, 2);
READ(port, 0x04, 0x1, 0x1, (char *)lo, 2); READ(port, 0x04, 0x1, 0x1, (char*)lo, 2);
GP_DEBUG("%02x %02x number of lo-res pics\n", lo[0],lo[1]); GP_DEBUG("%02x %02x number of lo-res pics\n", lo[0], lo[1]);
/* We need to keep this information. We presume that /* We need to keep this information. We presume that
* more than 255 pictures is impossible with this camera. * more than 255 pictures is impossible with this camera.
*/ */
memcpy (info, &lo[0], 1); memcpy (info, &lo[0], 1);
READ(port, 0x04, 0x2, 0x1, c, 2); READ(port, 0x04, 0x2, 0x1, c, 2);
READ(port, 0x04, 0x3, 0x1, c, 2); READ(port, 0x04, 0x3, 0x1, c, 2);
READ(port, 0x04, 0x4, 0x1, c, 2); READ(port, 0x04, 0x4, 0x1, c, 2);
READ(port, 0x04, 0x5, 0x1, (char *)hi, 2); READ(port, 0x04, 0x5, 0x1, (char*)hi, 2);
GP_DEBUG("%02i %02i number of hi-res pics\n", hi[0], hi[1]); GP_DEBUG("%02i %02i number of hi-res pics\n", hi[0], hi[1]);
/* This information, too. */ /* This information, too. */
memcpy (info +1, &hi[0], 1); memcpy (info + 1, &hi[0], 1);
READ(port, 0x04, 0x6, 0x1, c, 2); /* "Completion" flag.*/ READ(port, 0x04, 0x6, 0x1, c, 2); /* "Completion" flag.*/
GP_DEBUG("info[0] = 0x%x\n", info[0]); GP_DEBUG("info[0] = 0x%x\n", info[0]);
GP_DEBUG("info[1] = 0x%x\n", info[1]); GP_DEBUG("info[1] = 0x%x\n", info[1]);
GP_DEBUG("Leaving aox_init\n"); GP_DEBUG("Leaving aox_init\n");
return GP_OK; return GP_OK;
} }
@@ -89,16 +89,16 @@ int aox_get_picture_size (GPPort *port, int lo, int hi, int n, int k)
{ {
unsigned char c[4]; unsigned char c[4];
unsigned int size; unsigned int size;
memset (c,0,4); memset (c,0,4);
GP_DEBUG("Running aox_get_picture_size for aox_pic%03i\n", k+1); GP_DEBUG("Running aox_get_picture_size for aox_pic%03i\n", k+1);
if ( ( (lo) && ( n ==k ) && (k ==0)) ) { if ( ( (lo) && ( n ==k ) && (k ==0)) ) {
READ(port, 0x04, 0x1, 0x1, (char *)c, 2); READ(port, 0x04, 0x1, 0x1, (char *)c, 2);
} }
if ( ( (hi) && ( n < k ) && (n == 0)) ) { if ( ( (hi) && ( n < k ) && (n == 0)) ) {
READ(port, 0x04, 0x5, 0x1, (char *)c, 2); READ(port, 0x04, 0x5, 0x1, (char *)c, 2);
} }
READ(port, 0x05, n+1, 0x1, (char *)c, 4); READ(port, 0x05, n+1, 0x1, (char *)c, 4);
size = (int)c[0] + (int)c[1]*0x100 + (int)c[2]*0x10000; size = (int)c[0] + (int)c[1]*0x100 + (int)c[2]*0x10000;
@@ -113,21 +113,21 @@ static int aox_read_data (GPPort *port, char *data, int size)
{ {
int MAX_BULK = 0x1000; int MAX_BULK = 0x1000;
while(size > 0) { while (size > 0) {
int len = (size>MAX_BULK)?MAX_BULK:size; int len = (size > MAX_BULK) ? MAX_BULK : size;
gp_port_read (port, data, len); /* 0x84 = EP IN NEEDED HERE.*/ gp_port_read (port, data, len); /* 0x84 = EP IN NEEDED HERE.*/
data += len; data += len;
size -= len; size -= len;
} }
return 1; return 1;
} }
int aox_read_picture_data (GPPort *port, char *data, int size, int n) { int aox_read_picture_data (GPPort *port, char *data, int size, int n) {
char c[4]; char c[4];
memset(c,0,4); memset(c,0,4);
READ(port, 0x06, n+1, 0x1, c, 4); READ(port, 0x06, n + 1, 0x1, c, 4);
aox_read_data (port, data , size); aox_read_data (port, data, size);
return GP_OK; return GP_OK;
} }

View File

@@ -56,81 +56,81 @@ struct _CameraPrivateLibrary {
}; };
static struct { static struct {
char *name; char *name;
CameraDriverStatus status; CameraDriverStatus status;
unsigned short idVendor; unsigned short idVendor;
unsigned short idProduct; unsigned short idProduct;
} models[] = { } models[] = {
{"Concord EyeQMini_1", GP_DRIVER_STATUS_EXPERIMENTAL, 0x03e8, 0x2182}, {"Concord EyeQMini_1", GP_DRIVER_STATUS_EXPERIMENTAL, 0x03e8, 0x2182},
{"Concord EyeQMini_2", GP_DRIVER_STATUS_EXPERIMENTAL, 0x03e8, 0x2180}, {"Concord EyeQMini_2", GP_DRIVER_STATUS_EXPERIMENTAL, 0x03e8, 0x2180},
{"D-MAX DM3588", GP_DRIVER_STATUS_EXPERIMENTAL, 0x03e8, 0x2130}, {"D-MAX DM3588", GP_DRIVER_STATUS_EXPERIMENTAL, 0x03e8, 0x2130},
{NULL,0,0,0} {NULL,0,0,0}
}; };
int int
camera_id (CameraText *id) camera_id (CameraText *id)
{ {
strcpy (id->text, "Aox chipset camera"); strcpy (id->text, "Aox chipset camera");
return GP_OK; return GP_OK;
} }
int int
camera_abilities (CameraAbilitiesList *list) camera_abilities (CameraAbilitiesList *list)
{ {
int i; int i;
CameraAbilities a; CameraAbilities a;
for (i = 0; models[i].name; i++) { for (i = 0; models[i].name; i++) {
memset (&a, 0, sizeof(a)); memset (&a, 0, sizeof(a));
strcpy (a.model, models[i].name); strcpy (a.model, models[i].name);
a.status = models[i].status; a.status = models[i].status;
a.port = GP_PORT_USB; a.port = GP_PORT_USB;
a.speed[0] = 0; a.speed[0] = 0;
a.usb_vendor = models[i].idVendor; a.usb_vendor = models[i].idVendor;
a.usb_product= models[i].idProduct; a.usb_product = models[i].idProduct;
if (a.status == GP_DRIVER_STATUS_EXPERIMENTAL) if (a.status == GP_DRIVER_STATUS_EXPERIMENTAL)
a.operations = GP_OPERATION_NONE; a.operations = GP_OPERATION_NONE;
else else
a.operations = GP_OPERATION_CAPTURE_IMAGE; a.operations = GP_OPERATION_CAPTURE_IMAGE;
a.folder_operations = GP_FOLDER_OPERATION_NONE; a.folder_operations = GP_FOLDER_OPERATION_NONE;
a.file_operations = GP_FILE_OPERATION_PREVIEW; a.file_operations = GP_FILE_OPERATION_PREVIEW;
gp_abilities_list_append (list, a); gp_abilities_list_append (list, a);
} }
return GP_OK; return GP_OK;
} }
static int static int
camera_summary (Camera *camera, CameraText *summary, GPContext *context) camera_summary (Camera *camera, CameraText *summary, GPContext *context)
{ {
int num_lo_pics =aox_get_num_lo_pics(camera->pl->info); int num_lo_pics = aox_get_num_lo_pics(camera->pl->info);
int num_hi_pics =aox_get_num_hi_pics(camera->pl->info); int num_hi_pics = aox_get_num_hi_pics(camera->pl->info);
sprintf (summary->text,_("Your USB camera has an Aox chipset.\n" sprintf (summary->text, _("Your USB camera has an Aox chipset.\n"
"Number of lo-res PICs = %i\n" "Number of lo-res PICs = %i\n"
"Number of hi-res PICs = %i\n" "Number of hi-res PICs = %i\n"
"Number of PICs = %i\n" "Number of PICs = %i\n"
), num_lo_pics, num_hi_pics, num_lo_pics+num_hi_pics); ), num_lo_pics, num_hi_pics, num_lo_pics + num_hi_pics);
return GP_OK; return GP_OK;
} }
static int static int
camera_about (Camera *camera, CameraText *about, GPContext *context) camera_about (Camera *camera, CameraText *about, GPContext *context)
{ {
strcpy (about->text, _("Aox generic driver\n" strcpy (about->text, _("Aox generic driver\n"
"Theodore Kilgore <kilgota@auburn.edu>\n")); "Theodore Kilgore <kilgota@auburn.edu>\n"));
return GP_OK; return GP_OK;
} }
/*************** File and Downloading Functions *******************/ /*************** File and Downloading Functions *******************/
static int static int
file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
void *data, GPContext *context) void *data, GPContext *context)
{ {
Camera *camera = data; Camera *camera = data;
int num_lo_pics = aox_get_num_lo_pics (camera->pl->info); int num_lo_pics = aox_get_num_lo_pics (camera->pl->info);
int num_hi_pics = aox_get_num_hi_pics (camera->pl->info); int num_hi_pics = aox_get_num_hi_pics (camera->pl->info);
int n = num_hi_pics + num_lo_pics; int n = num_hi_pics + num_lo_pics;
@@ -148,7 +148,7 @@ file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
snprintf( name, sizeof(name), "aox_pic%03i.ppm", i+1 ); snprintf( name, sizeof(name), "aox_pic%03i.ppm", i+1 );
gp_list_append(list, name, NULL); gp_list_append(list, name, NULL);
} }
return GP_OK; return GP_OK;
} }
static int static int
@@ -156,7 +156,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
CameraFileType type, CameraFile *file, void *user_data, CameraFileType type, CameraFile *file, void *user_data,
GPContext *context) GPContext *context)
{ {
Camera *camera = user_data; Camera *camera = user_data;
/* The camera will always download the low-resolution pictures first, if any. /* The camera will always download the low-resolution pictures first, if any.
* As those are compressed, they are not of fixed size. Unfortunately, the * As those are compressed, they are not of fixed size. Unfortunately, the
@@ -166,7 +166,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
* resolution pictures are just Bayer data; their headers will be discarded. * resolution pictures are just Bayer data; their headers will be discarded.
*/ */
int i, j, k, n, num_lo_pics, num_hi_pics, w = 0, h = 0; int i, j, k, n, num_lo_pics, num_hi_pics, w = 0, h = 0;
unsigned char temp; unsigned char temp;
unsigned char *data; unsigned char *data;
unsigned char *p_data = NULL; unsigned char *p_data = NULL;
@@ -204,7 +204,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
data = malloc(len); data = malloc(len);
if (!data) { if (!data) {
printf("Malloc failed\n"); return 0;} printf("Malloc failed\n"); return 0;}
aox_read_picture_data (camera->port, (char *)data, len, n); aox_read_picture_data (camera->port, (char *)data, len, n);
switch (type) { switch (type) {
case GP_FILE_TYPE_EXIF: case GP_FILE_TYPE_EXIF:
@@ -229,19 +229,19 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
/* Stripping useless header */ /* Stripping useless header */
p_data = data + 0x98; p_data = data + 0x98;
/* Picture is mirror-imaged.*/ /* Picture is mirror-imaged.*/
for (i = 0; i < h; ++i) { for (i = 0; i < h; ++i) {
for (j = 0 ; j < w/2; j++) { for (j = 0; j < w / 2; j++) {
temp = p_data[w*i +j]; temp = p_data[w * i + j];
p_data[w*i +j] = p_data[w*i+ w -1 -j]; p_data[w * i + j] = p_data[w * i + w - 1 - j];
p_data[w*i + w - 1 - j] = temp; p_data[w * i + w - 1 - j] = temp;
} }
} }
/* Not only this, but some columns are /* Not only this, but some columns are
* interchanged, too. */ * interchanged, too. */
for (i = 0; i < w*h/4; i++) { for (i = 0; i < w*h/4; i++) {
temp = p_data[4*i +1]; temp = p_data[4 * i + 1];
p_data[4*i + 1] = p_data[4*i+2]; p_data[4 * i + 1] = p_data[4 * i + 2];
p_data[4*i+2] = temp; p_data[4 * i + 2] = temp;
} }
/* And now create a ppm file, with our own header */ /* And now create a ppm file, with our own header */
header_len = snprintf(header, 127, header_len = snprintf(header, 127,
@@ -256,16 +256,14 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
return GP_ERROR_NO_MEMORY; return GP_ERROR_NO_MEMORY;
} }
if (camera->pl->model == AOX_MODEL_DMAX) if (camera->pl->model == AOX_MODEL_DMAX)
gp_bayer_decode (p_data, w, h, gp_bayer_decode (p_data, w, h, output, BAYER_TILE_RGGB);
output, BAYER_TILE_RGGB);
else else
gp_bayer_decode (p_data, w, h, gp_bayer_decode (p_data, w, h, output, BAYER_TILE_GRBG);
output, BAYER_TILE_GRBG);
/* gamma correction of .70 may not be optimal. */ /* gamma correction of .70 may not be optimal. */
gp_gamma_fill_table (gtable, .65); gp_gamma_fill_table (gtable, .65);
gp_gamma_correct_single (gtable, output, w * h); gp_gamma_correct_single (gtable, output, w * h);
gp_file_set_mime_type (file, GP_MIME_PPM); gp_file_set_mime_type (file, GP_MIME_PPM);
gp_file_append (file, header, header_len); gp_file_append (file, header, header_len);
gp_file_append (file, (char *)output, 3*w*h); gp_file_append (file, (char *)output, 3*w*h);
} }
free (data); free (data);
@@ -317,9 +315,9 @@ camera_init(Camera *camera, GPContext *context)
ret = gp_port_get_settings(camera->port,&settings); ret = gp_port_get_settings(camera->port,&settings);
if (ret < 0) return ret; if (ret < 0) return ret;
ret = gp_camera_get_abilities(camera,&abilities); ret = gp_camera_get_abilities(camera, &abilities);
if (ret < 0) return ret; if (ret < 0) return ret;
GP_DEBUG("product number is 0x%x\n", abilities.usb_product); GP_DEBUG("product number is 0x%x\n", abilities.usb_product);
switch (camera->port->type) { switch (camera->port->type) {
case GP_PORT_SERIAL: case GP_PORT_SERIAL:
@@ -342,7 +340,7 @@ camera_init(Camera *camera, GPContext *context)
GP_DEBUG("inep = %x\n", settings.usb.inep); GP_DEBUG("inep = %x\n", settings.usb.inep);
GP_DEBUG("outep = %x\n", settings.usb.outep); GP_DEBUG("outep = %x\n", settings.usb.outep);
/* Tell the CameraFilesystem where to get lists from */ /* Tell the CameraFilesystem where to get lists from */
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
camera->pl = malloc (sizeof (CameraPrivateLibrary)); camera->pl = malloc (sizeof (CameraPrivateLibrary));

View File

@@ -1264,7 +1264,7 @@ ax203_encode_image(Camera *camera, int **src, char *dest, unsigned int dest_size
free (jpeg_dest); free (jpeg_dest);
/* Round size up to a multiple of 256 because of ax3003 /* Round size up to a multiple of 256 because of ax3003
abfs size granularity. */ abfs size granularity. */
return (jpeg_size + 0xff) & ~0xff; return (jpeg_size + 0xff) & ~0xff;
#else #else
return GP_ERROR_NOT_SUPPORTED; return GP_ERROR_NOT_SUPPORTED;
#endif #endif

View File

@@ -403,8 +403,8 @@ storage_info_func (CameraFilesystem *fs,
imagesize = ax203_filesize (camera); imagesize = ax203_filesize (camera);
if (imagesize) { if (imagesize) {
sinfo->fields |= GP_STORAGEINFO_FREESPACEIMAGES; sinfo->fields |= GP_STORAGEINFO_FREESPACEIMAGES;
sinfo->freeimages = free / imagesize; sinfo->freeimages = free / imagesize;
} }
return GP_OK; return GP_OK;

View File

@@ -108,17 +108,17 @@ barbie_ping(GPPort *port) {
static int static int
barbie_file_count (GPPort *port) { barbie_file_count (GPPort *port) {
unsigned char cmd[4], resp[4]; unsigned char cmd[4], resp[4];
GP_DEBUG ("Getting the number of pictures..."); GP_DEBUG ("Getting the number of pictures...");
memcpy(cmd, packet_1, 4); memcpy(cmd, packet_1, 4);
cmd[COMMAND_BYTE] = 'I'; cmd[COMMAND_BYTE] = 'I';
cmd[DATA1_BYTE] = 0; cmd[DATA1_BYTE] = 0;
if (barbie_exchange(port, cmd, 4, resp, 4) != 1) if (barbie_exchange(port, cmd, 4, resp, 4) != 1)
return (0); return (0);
return (resp[DATA1_BYTE]); return (resp[DATA1_BYTE]);
} }
static unsigned char * static unsigned char *
@@ -240,53 +240,53 @@ barbie_read_picture(GPPort *port, int picture_number, int get_thumbnail, CameraF
/* GPhoto specific stuff */ /* GPhoto specific stuff */
static char *models[] = { static char *models[] = {
"Barbie", "Barbie",
"Nick Click", "Nick Click",
"WWF", "WWF",
"Hot Wheels", "Hot Wheels",
NULL NULL
}; };
int int
camera_id (CameraText *id) camera_id (CameraText *id)
{ {
strcpy(id->text, "barbie"); strcpy(id->text, "barbie");
return (GP_OK); return (GP_OK);
} }
int int
camera_abilities (CameraAbilitiesList *list) camera_abilities (CameraAbilitiesList *list)
{ {
int x=0; int x=0;
CameraAbilities a; CameraAbilities a;
while (models[x]) { while (models[x]) {
/* Fill in the appropriate flags/data */ /* Fill in the appropriate flags/data */
memset (&a, 0, sizeof(a)); memset (&a, 0, sizeof(a));
strcpy(a.model, models[x]); strcpy(a.model, models[x]);
a.status = GP_DRIVER_STATUS_PRODUCTION; a.status = GP_DRIVER_STATUS_PRODUCTION;
a.port = GP_PORT_SERIAL; a.port = GP_PORT_SERIAL;
a.speed[0] = 57600; a.speed[0] = 57600;
a.speed[1] = 0; a.speed[1] = 0;
a.operations = GP_OPERATION_NONE; a.operations = GP_OPERATION_NONE;
a.file_operations = GP_FILE_OPERATION_PREVIEW; a.file_operations = GP_FILE_OPERATION_PREVIEW;
a.folder_operations = GP_FOLDER_OPERATION_NONE; a.folder_operations = GP_FOLDER_OPERATION_NONE;
/* Append it to the list */ /* Append it to the list */
gp_abilities_list_append(list, a); gp_abilities_list_append(list, a);
x++; x++;
} }
return (GP_OK); return (GP_OK);
} }
static int static int
file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
void *data, GPContext *context) void *data, GPContext *context)
{ {
Camera *camera = data; Camera *camera = data;
return gp_list_populate (list, "mattel%02i.ppm", barbie_file_count (camera->port)); return gp_list_populate (list, "mattel%02i.ppm", barbie_file_count (camera->port));
} }
static int static int
@@ -295,67 +295,67 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
GPContext *context) GPContext *context)
{ {
Camera *camera = user_data; Camera *camera = user_data;
int num; int num;
/* Retrieve the number of the photo on the camera */ /* Retrieve the number of the photo on the camera */
num = gp_filesystem_number (camera->fs, "/", filename, context); num = gp_filesystem_number (camera->fs, "/", filename, context);
if (num < GP_OK) if (num < GP_OK)
return num; return num;
gp_file_set_mime_type (file, GP_MIME_PPM); gp_file_set_mime_type (file, GP_MIME_PPM);
switch (type) { switch (type) {
case GP_FILE_TYPE_NORMAL: case GP_FILE_TYPE_NORMAL:
return barbie_read_picture (camera->port, num, 0, file); return barbie_read_picture (camera->port, num, 0, file);
break; break;
case GP_FILE_TYPE_PREVIEW: case GP_FILE_TYPE_PREVIEW:
return barbie_read_picture (camera->port, num, 1, file); return barbie_read_picture (camera->port, num, 1, file);
break; break;
default: default:
return GP_ERROR_NOT_SUPPORTED; return GP_ERROR_NOT_SUPPORTED;
} }
return GP_ERROR_NOT_SUPPORTED; return GP_ERROR_NOT_SUPPORTED;
} }
#if 0 #if 0
int camera_capture (Camera *camera, int capture_type, CameraFilePath *path) { int camera_capture (Camera *camera, int capture_type, CameraFilePath *path) {
char cmd[4], resp[4]; char cmd[4], resp[4];
memcpy(cmd, packet_1, 4); memcpy(cmd, packet_1, 4);
cmd[COMMAND_BYTE] = 'G'; cmd[COMMAND_BYTE] = 'G';
cmd[DATA1_BYTE] = 0x40; cmd[DATA1_BYTE] = 0x40;
if (barbie_exchange(cmd, 4, resp, 4) == 0) if (barbie_exchange(cmd, 4, resp, 4) == 0)
return (0); return (0);
cmd[COMMAND_BYTE] = 'Y'; cmd[COMMAND_BYTE] = 'Y';
cmd[DATA1_BYTE] = 0; cmd[DATA1_BYTE] = 0;
if (barbie_exchange(cmd, 4, resp, 4) == 0) if (barbie_exchange(cmd, 4, resp, 4) == 0)
return (0); return (0);
return(resp[DATA1_BYTE] == 0? GP_OK: GP_ERROR); return(resp[DATA1_BYTE] == 0 ? GP_OK : GP_ERROR);
return (GP_ERROR); return (GP_ERROR);
} }
#endif #endif
static int static int
camera_summary (Camera *camera, CameraText *summary, GPContext *context) camera_summary (Camera *camera, CameraText *summary, GPContext *context)
{ {
int num; int num;
char *firm; char *firm;
num = barbie_file_count (camera->port); num = barbie_file_count (camera->port);
firm = (char*)barbie_read_firmware (camera->port); firm = (char*)barbie_read_firmware (camera->port);
sprintf(summary->text, _("Number of pictures: %i\nFirmware Version: %s"), num,firm); sprintf(summary->text, _("Number of pictures: %i\nFirmware Version: %s"), num, firm);
free(firm); free(firm);
return GP_OK; return GP_OK;
} }
static int static int
camera_about (Camera *camera, CameraText *about, GPContext *context) camera_about (Camera *camera, CameraText *about, GPContext *context)
{ {
strcpy (about->text,_("Barbie/HotWheels/WWF\nScott Fritzinger <scottf@unr.edu>\nAndreas Meyer <ahm@spies.com>\nPete Zaitcev <zaitcev@metabyte.com>\n\nReverse engineering of image data by:\nJeff Laing <jeffl@SPATIALinfo.com>\n\nImplemented using documents found on\nthe web. Permission given by Vision.")); strcpy (about->text, _("Barbie/HotWheels/WWF\nScott Fritzinger <scottf@unr.edu>\nAndreas Meyer <ahm@spies.com>\nPete Zaitcev <zaitcev@metabyte.com>\n\nReverse engineering of image data by:\nJeff Laing <jeffl@SPATIALinfo.com>\n\nImplemented using documents found on\nthe web. Permission given by Vision."));
return GP_OK; return GP_OK;
} }
static CameraFilesystemFuncs fsfuncs = { static CameraFilesystemFuncs fsfuncs = {
@@ -367,26 +367,26 @@ int
camera_init (Camera *camera, GPContext *context) camera_init (Camera *camera, GPContext *context)
{ {
GPPortSettings settings; GPPortSettings settings;
int res; int res;
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->summary = camera_summary; camera->functions->summary = camera_summary;
camera->functions->about = camera_about; camera->functions->about = camera_about;
/* Set up the CameraFilesystem */ /* Set up the CameraFilesystem */
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
/* Set up the port */ /* Set up the port */
gp_port_set_timeout (camera->port, 5000); gp_port_set_timeout (camera->port, 5000);
gp_port_get_settings (camera->port, &settings); gp_port_get_settings (camera->port, &settings);
settings.serial.speed = 57600; settings.serial.speed = 57600;
settings.serial.bits = 8; settings.serial.bits = 8;
settings.serial.parity = 0; settings.serial.parity = 0;
settings.serial.stopbits= 1; settings.serial.stopbits= 1;
gp_port_set_settings (camera->port, settings); gp_port_set_settings (camera->port, settings);
res = barbie_ping (camera->port); res = barbie_ping (camera->port);
if (res) if (res)
return (GP_OK); return (GP_OK);
return (GP_ERROR); return (GP_ERROR);
} }

View File

@@ -513,8 +513,7 @@ struct _CameraPrivateLibrary
int remote_control; /* is the camera currently under USB control? */ int remote_control; /* is the camera currently under USB control? */
canonCaptureSizeClass capture_size; /* Size class for remote- canonCaptureSizeClass capture_size; /* Size class for remote-captured images */
captured images */
unsigned int body_id; /* hardware serial number for some cameras */ unsigned int body_id; /* hardware serial number for some cameras */

View File

@@ -78,8 +78,8 @@ extern long int timezone;
static const struct canonCaptureSizeClassStruct captureSizeArray[] = { static const struct canonCaptureSizeClassStruct captureSizeArray[] = {
{CAPTURE_COMPATIBILITY, N_("Compatibility Mode")}, {CAPTURE_COMPATIBILITY, N_("Compatibility Mode")},
{CAPTURE_THUMB, N_("Thumbnail")}, {CAPTURE_THUMB, N_("Thumbnail")},
{CAPTURE_FULL_IMAGE, N_("Full Image")}, {CAPTURE_FULL_IMAGE, N_("Full Image")},
{0, NULL} {0, NULL}
}; };
@@ -103,62 +103,62 @@ static const struct canonIsoStateStruct isoStateArray[] = {
}; };
static const struct canonShutterSpeedStateStruct shutterSpeedStateArray[] = { static const struct canonShutterSpeedStateStruct shutterSpeedStateArray[] = {
{SHUTTER_SPEED_BULB, N_("Bulb")}, {SHUTTER_SPEED_BULB, N_("Bulb")},
{SHUTTER_SPEED_30_SEC,"30"}, {SHUTTER_SPEED_30_SEC,"30"},
{SHUTTER_SPEED_25_SEC,"25"}, {SHUTTER_SPEED_25_SEC,"25"},
{SHUTTER_SPEED_20_SEC,"20"}, {SHUTTER_SPEED_20_SEC,"20"},
{SHUTTER_SPEED_15_SEC,"15"}, {SHUTTER_SPEED_15_SEC,"15"},
{SHUTTER_SPEED_13_SEC,"13"}, {SHUTTER_SPEED_13_SEC,"13"},
{SHUTTER_SPEED_10_SEC,"10"}, {SHUTTER_SPEED_10_SEC,"10"},
{SHUTTER_SPEED_8_SEC,"8"}, {SHUTTER_SPEED_8_SEC,"8"},
{SHUTTER_SPEED_6_SEC,"6"}, {SHUTTER_SPEED_6_SEC,"6"},
{SHUTTER_SPEED_5_SEC,"5"}, {SHUTTER_SPEED_5_SEC,"5"},
{SHUTTER_SPEED_4_SEC,"4"}, {SHUTTER_SPEED_4_SEC,"4"},
{SHUTTER_SPEED_3_2_SEC,"3.2"}, {SHUTTER_SPEED_3_2_SEC,"3.2"},
{SHUTTER_SPEED_2_5_SEC,"2.5"}, {SHUTTER_SPEED_2_5_SEC,"2.5"},
{SHUTTER_SPEED_2_SEC,"2"}, {SHUTTER_SPEED_2_SEC,"2"},
{SHUTTER_SPEED_1_6_SEC,"1.6"}, {SHUTTER_SPEED_1_6_SEC,"1.6"},
{SHUTTER_SPEED_1_3_SEC,"1.3"}, {SHUTTER_SPEED_1_3_SEC,"1.3"},
{SHUTTER_SPEED_1_SEC,"1"}, {SHUTTER_SPEED_1_SEC,"1"},
{SHUTTER_SPEED_0_8_SEC,"0.8"}, {SHUTTER_SPEED_0_8_SEC,"0.8"},
{SHUTTER_SPEED_0_6_SEC,"0.6"}, {SHUTTER_SPEED_0_6_SEC,"0.6"},
{SHUTTER_SPEED_0_5_SEC,"0.5"}, {SHUTTER_SPEED_0_5_SEC,"0.5"},
{SHUTTER_SPEED_0_4_SEC,"0.4"}, {SHUTTER_SPEED_0_4_SEC,"0.4"},
{SHUTTER_SPEED_0_3_SEC,"0.3"}, {SHUTTER_SPEED_0_3_SEC,"0.3"},
{SHUTTER_SPEED_1_4,"1/4"}, {SHUTTER_SPEED_1_4,"1/4"},
{SHUTTER_SPEED_1_5,"1/5"}, {SHUTTER_SPEED_1_5,"1/5"},
{SHUTTER_SPEED_1_6,"1/6"}, {SHUTTER_SPEED_1_6,"1/6"},
{SHUTTER_SPEED_1_8,"1/8"}, {SHUTTER_SPEED_1_8,"1/8"},
{SHUTTER_SPEED_1_10,"1/10"}, {SHUTTER_SPEED_1_10,"1/10"},
{SHUTTER_SPEED_1_13,"1/13"}, {SHUTTER_SPEED_1_13,"1/13"},
{SHUTTER_SPEED_1_15,"1/15"}, {SHUTTER_SPEED_1_15,"1/15"},
{SHUTTER_SPEED_1_20,"1/20"}, {SHUTTER_SPEED_1_20,"1/20"},
{SHUTTER_SPEED_1_25,"1/25"}, {SHUTTER_SPEED_1_25,"1/25"},
{SHUTTER_SPEED_1_30,"1/30"}, {SHUTTER_SPEED_1_30,"1/30"},
{SHUTTER_SPEED_1_40,"1/40"}, {SHUTTER_SPEED_1_40,"1/40"},
{SHUTTER_SPEED_1_50,"1/50"}, {SHUTTER_SPEED_1_50,"1/50"},
{SHUTTER_SPEED_1_60,"1/60"}, {SHUTTER_SPEED_1_60,"1/60"},
{SHUTTER_SPEED_1_80,"1/80"}, {SHUTTER_SPEED_1_80,"1/80"},
{SHUTTER_SPEED_1_100,"1/100"}, {SHUTTER_SPEED_1_100,"1/100"},
{SHUTTER_SPEED_1_125,"1/125"}, {SHUTTER_SPEED_1_125,"1/125"},
{SHUTTER_SPEED_1_160,"1/160"}, {SHUTTER_SPEED_1_160,"1/160"},
{SHUTTER_SPEED_1_200,"1/200"}, {SHUTTER_SPEED_1_200,"1/200"},
{SHUTTER_SPEED_1_250,"1/250"}, {SHUTTER_SPEED_1_250,"1/250"},
{SHUTTER_SPEED_1_320,"1/320"}, {SHUTTER_SPEED_1_320,"1/320"},
{SHUTTER_SPEED_1_400,"1/400"}, {SHUTTER_SPEED_1_400,"1/400"},
{SHUTTER_SPEED_1_500,"1/500"}, {SHUTTER_SPEED_1_500,"1/500"},
{SHUTTER_SPEED_1_640,"1/640"}, {SHUTTER_SPEED_1_640,"1/640"},
{SHUTTER_SPEED_1_800,"1/800"}, {SHUTTER_SPEED_1_800,"1/800"},
{SHUTTER_SPEED_1_1000,"1/1000"}, {SHUTTER_SPEED_1_1000,"1/1000"},
{SHUTTER_SPEED_1_1250,"1/1250"}, {SHUTTER_SPEED_1_1250,"1/1250"},
{SHUTTER_SPEED_1_1600,"1/1600"}, {SHUTTER_SPEED_1_1600,"1/1600"},
{SHUTTER_SPEED_1_2000,"1/2000"}, {SHUTTER_SPEED_1_2000,"1/2000"},
{SHUTTER_SPEED_1_2500,"1/2500"}, {SHUTTER_SPEED_1_2500,"1/2500"},
{SHUTTER_SPEED_1_3200,"1/3200"}, {SHUTTER_SPEED_1_3200,"1/3200"},
{SHUTTER_SPEED_1_4000,"1/4000"}, {SHUTTER_SPEED_1_4000,"1/4000"},
{SHUTTER_SPEED_1_5000,"1/5000"}, {SHUTTER_SPEED_1_5000,"1/5000"},
{SHUTTER_SPEED_1_6400,"1/6400"}, {SHUTTER_SPEED_1_6400,"1/6400"},
{SHUTTER_SPEED_1_8000,"1/8000"}, {SHUTTER_SPEED_1_8000,"1/8000"},
{0, NULL}, {0, NULL},
}; };
@@ -196,10 +196,10 @@ static const struct canonApertureStateStruct apertureStateArray[] = {
}; };
static const struct canonFocusModeStateStruct focusModeStateArray[] = { static const struct canonFocusModeStateStruct focusModeStateArray[] = {
{AUTO_FOCUS_ONE_SHOT, N_("Auto focus: one-shot")}, {AUTO_FOCUS_ONE_SHOT, N_("Auto focus: one-shot")},
{AUTO_FOCUS_AI_SERVO, N_("Auto focus: AI servo")}, {AUTO_FOCUS_AI_SERVO, N_("Auto focus: AI servo")},
{AUTO_FOCUS_AI_FOCUS, N_("Auto focus: AI focus")}, {AUTO_FOCUS_AI_FOCUS, N_("Auto focus: AI focus")},
{MANUAL_FOCUS, N_("Manual focus")}, {MANUAL_FOCUS, N_("Manual focus")},
{0, NULL}, {0, NULL},
}; };
@@ -1200,46 +1200,45 @@ get_last_file (Camera *camera, char *directory, char *destname,
int t; int t;
GP_DEBUG ("get_last_file()"); GP_DEBUG ("get_last_file()");
if(directory[1] == ':') { if (directory[1] == ':') {
/* gp_file_list_folder() needs absolute filenames /* gp_file_list_folder() needs absolute filenames
starting with '/' */ starting with '/' */
GP_DEBUG ("get_last_file(): replacing '%c:%c' by '/'", GP_DEBUG ("get_last_file(): replacing '%c:%c' by '/'",
directory[0], directory[2]); directory[0], directory[2]);
sprintf(dir2, "/%s", &directory[3]); sprintf(dir2, "/%s", &directory[3]);
directory = dir2; directory = dir2;
} }
gp_list_new(&list); gp_list_new(&list);
if(getdirectory) { if (getdirectory) {
CHECK_RESULT (gp_filesystem_list_folders (fs, directory, list, context)); CHECK_RESULT (gp_filesystem_list_folders (fs, directory, list, context));
GP_DEBUG ("get_last_file(): %d folders", list->count); GP_DEBUG ("get_last_file(): %d folders", list->count);
} else {
CHECK_RESULT (gp_filesystem_list_files (fs, directory, list, context));
GP_DEBUG ("get_last_file(): %d files", list->count);
} }
else { for (t=0;t<list->count;t++)
CHECK_RESULT (gp_filesystem_list_files (fs, directory, list, context));
GP_DEBUG ("get_last_file(): %d files", list->count);
}
for(t=0;t<list->count;t++)
{ {
char* name = list->entry[t].name; char* name = list->entry[t].name;
if(getdirectory) if (getdirectory)
GP_DEBUG ("get_last_file(): folder: %s", name); GP_DEBUG ("get_last_file(): folder: %s", name);
else else
GP_DEBUG ("get_last_file(): file: %s", name); GP_DEBUG ("get_last_file(): file: %s", name);
/* we search only for directories of the form [0-9]{3}CANON... */ /* we search only for directories of the form [0-9]{3}CANON... */
if(getdirectory && ((strlen (name)!=8) || if (getdirectory && ((strlen (name)!=8) ||
(!isdigit(name[0]) || (!isdigit(name[0]) ||
!isdigit(name[1]) || !isdigit(name[1]) ||
!isdigit(name[2])) || strcmp(&name[3],"CANON"))) !isdigit(name[2])) || strcmp(&name[3], "CANON")))
continue; continue;
/* ...and only for files similar to AUT_[0-9]{4} */ /* ...and only for files similar to AUT_[0-9]{4} */
if(!getdirectory && (!isdigit(name[6]) || if (!getdirectory && (!isdigit(name[6]) ||
!isdigit(name[7]))) !isdigit(name[7])))
continue; continue;
if(!result[0] || strcmp((list->entry[t].name)+4, result+4) > 0) if (!result[0] || strcmp((list->entry[t].name)+4, result+4) > 0)
strcpy(result, list->entry[t].name); strcpy(result, list->entry[t].name);
} }
gp_list_free(list); gp_list_free(list);
@@ -1692,7 +1691,7 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context)
/* DSLRs have only "Manual" Zoom */ /* DSLRs have only "Manual" Zoom */
if ( camera->pl->md->id_str && !strstr(camera->pl->md->id_str,"EOS") && !strstr(camera->pl->md->id_str,"Rebel")) { if (camera->pl->md->id_str && !strstr(camera->pl->md->id_str, "EOS") && !strstr(camera->pl->md->id_str, "Rebel")) {
/* Zoom level */ /* Zoom level */
gp_widget_new (GP_WIDGET_RANGE, _("Zoom"), &t); gp_widget_new (GP_WIDGET_RANGE, _("Zoom"), &t);
gp_widget_set_name (t, "zoom"); gp_widget_set_name (t, "zoom");
@@ -1902,7 +1901,7 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context)
res = canon_int_get_time (camera, &camtime, context); res = canon_int_get_time (camera, &camtime, context);
if (res == GP_OK) { if (res == GP_OK) {
strftime (formatted_camera_time, sizeof (formatted_camera_time), strftime (formatted_camera_time, sizeof (formatted_camera_time),
"%Y-%m-%d %H:%M:%S", gmtime (&camtime)); "%Y-%m-%d %H:%M:%S", gmtime (&camtime));
gp_widget_set_value (t, formatted_camera_time); gp_widget_set_value (t, formatted_camera_time);
} else { } else {
gp_widget_set_value (t, _("Error")); gp_widget_set_value (t, _("Error"));
@@ -1974,7 +1973,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_widget_get_child_by_label (window, _("Owner Name"), &w); gp_widget_get_child_by_label (window, _("Owner Name"), &w);
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &wvalue); gp_widget_get_value (w, &wvalue);
if (!check_readiness (camera, context)) { if (!check_readiness (camera, context)) {
gp_context_status (context, _("Camera unavailable")); gp_context_status (context, _("Camera unavailable"));
@@ -1988,7 +1987,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_widget_get_child_by_label (window, _("Capture Size Class"), &w); gp_widget_get_child_by_label (window, _("Capture Size Class"), &w);
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &wvalue); gp_widget_get_value (w, &wvalue);
i = 0; i = 0;
@@ -2006,7 +2005,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
} }
/* Enable remote control, if not already enabled */ /* Enable remote control, if not already enabled */
if (!camera->pl->remote_control) { if (!camera->pl->remote_control) {
res = canon_int_start_remote_control (camera, context); res = canon_int_start_remote_control (camera, context);
if (res != GP_OK) if (res != GP_OK)
@@ -2015,7 +2014,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_widget_get_child_by_label (window, _("ISO Speed"), &w); gp_widget_get_child_by_label (window, _("ISO Speed"), &w);
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &wvalue); gp_widget_get_value (w, &wvalue);
if (!check_readiness (camera, context)) { if (!check_readiness (camera, context)) {
gp_context_status (context, _("Camera unavailable")); gp_context_status (context, _("Camera unavailable"));
@@ -2045,7 +2044,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_widget_get_child_by_label (window, _("Shooting mode"), &w); gp_widget_get_child_by_label (window, _("Shooting mode"), &w);
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &wvalue); gp_widget_get_value (w, &wvalue);
if (!check_readiness (camera, context)) { if (!check_readiness (camera, context)) {
gp_context_status (context, _("Camera unavailable")); gp_context_status (context, _("Camera unavailable"));
@@ -2075,7 +2074,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_widget_get_child_by_label (window, _("Shutter Speed"), &w); gp_widget_get_child_by_label (window, _("Shutter Speed"), &w);
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &wvalue); gp_widget_get_value (w, &wvalue);
if (!check_readiness (camera, context)) { if (!check_readiness (camera, context)) {
gp_context_status (context, _("Camera unavailable")); gp_context_status (context, _("Camera unavailable"));
@@ -2104,7 +2103,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_widget_get_child_by_label (window, _("Aperture"), &w); gp_widget_get_child_by_label (window, _("Aperture"), &w);
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &wvalue); gp_widget_get_value (w, &wvalue);
if (!check_readiness (camera, context)) { if (!check_readiness (camera, context)) {
gp_context_status (context, _("Camera unavailable")); gp_context_status (context, _("Camera unavailable"));
@@ -2134,7 +2133,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
unsigned char expbias; unsigned char expbias;
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &wvalue); gp_widget_get_value (w, &wvalue);
if (!check_readiness (camera, context)) { if (!check_readiness (camera, context)) {
gp_context_status (context, _("Camera unavailable")); gp_context_status (context, _("Camera unavailable"));
@@ -2163,7 +2162,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_widget_get_child_by_label (window, _("Image Format"), &w); gp_widget_get_child_by_label (window, _("Image Format"), &w);
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &wvalue); gp_widget_get_value (w, &wvalue);
if (!check_readiness (camera, context)) { if (!check_readiness (camera, context)) {
gp_context_status (context, _("Camera unavailable")); gp_context_status (context, _("Camera unavailable"));
@@ -2192,7 +2191,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_widget_get_child_by_label (window, _("Focus Mode"), &w); gp_widget_get_child_by_label (window, _("Focus Mode"), &w);
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &wvalue); gp_widget_get_value (w, &wvalue);
if (!check_readiness (camera, context)) { if (!check_readiness (camera, context)) {
gp_context_status (context, _("Camera unavailable")); gp_context_status (context, _("Camera unavailable"));
@@ -2222,7 +2221,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
/* Beep */ /* Beep */
gp_widget_get_child_by_label (window, _("Beep"), &w); gp_widget_get_child_by_label (window, _("Beep"), &w);
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &wvalue); gp_widget_get_value (w, &wvalue);
if (!check_readiness (camera, context)) { if (!check_readiness (camera, context)) {
gp_context_status (context, _("Camera unavailable")); gp_context_status (context, _("Camera unavailable"));
@@ -2251,13 +2250,13 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
/* DSLRs have only "Manual" Zoom */ /* DSLRs have only "Manual" Zoom */
if ( camera->pl->md->id_str && !strstr(camera->pl->md->id_str,"EOS") && !strstr(camera->pl->md->id_str,"Rebel")) { if (camera->pl->md->id_str && !strstr(camera->pl->md->id_str, "EOS") && !strstr(camera->pl->md->id_str, "Rebel")) {
/* Zoom */ /* Zoom */
gp_widget_get_child_by_label (window, _("Zoom"), &w); gp_widget_get_child_by_label (window, _("Zoom"), &w);
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
float zoom; float zoom;
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &zoom); gp_widget_get_value (w, &zoom);
if (!check_readiness (camera, context)) { if (!check_readiness (camera, context)) {
gp_context_status (context, _("Camera unavailable")); gp_context_status (context, _("Camera unavailable"));
@@ -2273,7 +2272,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
/* Aperture */ /* Aperture */
gp_widget_get_child_by_label (window, _("Aperture"), &w); gp_widget_get_child_by_label (window, _("Aperture"), &w);
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &wvalue); gp_widget_get_value (w, &wvalue);
if (!check_readiness (camera, context)) { if (!check_readiness (camera, context)) {
gp_context_status (context, _("Camera unavailable")); gp_context_status (context, _("Camera unavailable"));
@@ -2303,7 +2302,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
/* Flash mode */ /* Flash mode */
gp_widget_get_child_by_label (window, _("Flash Mode"), &w); gp_widget_get_child_by_label (window, _("Flash Mode"), &w);
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &wvalue); gp_widget_get_value (w, &wvalue);
if (!check_readiness (camera, context)) { if (!check_readiness (camera, context)) {
gp_context_status (context, _("Camera unavailable")); gp_context_status (context, _("Camera unavailable"));
@@ -2333,7 +2332,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_widget_get_child_by_label (window, _("Synchronize camera date and time with PC"), &w); gp_widget_get_child_by_label (window, _("Synchronize camera date and time with PC"), &w);
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &wvalue); gp_widget_get_value (w, &wvalue);
if (!check_readiness (camera, context)) { if (!check_readiness (camera, context)) {
gp_context_status (context, _("Camera unavailable")); gp_context_status (context, _("Camera unavailable"));
@@ -2349,7 +2348,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_widget_get_child_by_label (window, _("List all files"), &w); gp_widget_get_child_by_label (window, _("List all files"), &w);
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
/* XXXXX mark CameraFS as dirty */ /* XXXXX mark CameraFS as dirty */
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &val); gp_widget_get_value (w, &val);
camera->pl->list_all_files = val; camera->pl->list_all_files = val;
sprintf (str, "%d", val); sprintf (str, "%d", val);
@@ -2362,7 +2361,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
#ifdef CANON_EXPERIMENTAL_UPLOAD #ifdef CANON_EXPERIMENTAL_UPLOAD
gp_widget_get_child_by_label (window, _("Keep filename on upload"), &w); gp_widget_get_child_by_label (window, _("Keep filename on upload"), &w);
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &camera->pl->upload_keep_filename); gp_widget_get_value (w, &camera->pl->upload_keep_filename);
GP_DEBUG ("New config value for \"Keep filename on upload\": %i", GP_DEBUG ("New config value for \"Keep filename on upload\": %i",
camera->pl->upload_keep_filename); camera->pl->upload_keep_filename);

View File

@@ -269,8 +269,8 @@ QVpicattr (Camera *camera, int n, unsigned char *picattr)
cmd[0] = 'D'; cmd[0] = 'D';
cmd[1] = 'Y'; cmd[1] = 'Y';
cmd[2] = STX; cmd[2] = STX;
cmd[3] = n+1; cmd[3] = n+1;
CR (QVsend (camera, cmd, 4, &b, 1)); CR (QVsend (camera, cmd, 4, &b, 1));
*picattr = b; *picattr = b;
@@ -386,33 +386,33 @@ QVcapture (Camera *camera)
int int
QVstatus (Camera *camera, char *status) QVstatus (Camera *camera, char *status)
{ {
unsigned char cmd[3]; unsigned char cmd[3];
cmd[0] = 'D'; cmd[0] = 'D';
cmd[1] = 'S'; cmd[1] = 'S';
cmd[2] = STX; cmd[2] = STX;
CR (QVsend (camera, cmd, 3, (unsigned char *)status, 2)); CR (QVsend (camera, cmd, 3, (unsigned char *)status, 2));
return (GP_OK); return (GP_OK);
} }
int int
QVreset (Camera *camera) QVreset (Camera *camera)
{ {
unsigned char cmd[2]; unsigned char cmd[2];
cmd[0] = 'Q'; cmd[0] = 'Q';
cmd[1] = 'R'; cmd[1] = 'R';
CR (QVsend (camera, cmd, 2, NULL, 0)); CR (QVsend (camera, cmd, 2, NULL, 0));
return (GP_OK); return (GP_OK);
} }
int int
QVsetspeed (Camera *camera, int speed) QVsetspeed (Camera *camera, int speed)
{ {
unsigned char cmd[3]; unsigned char cmd[3];
gp_port_settings settings; gp_port_settings settings;
cmd[0] = 'C'; cmd[0] = 'C';
cmd[1] = 'B'; cmd[1] = 'B';
@@ -426,9 +426,9 @@ QVsetspeed (Camera *camera, int speed)
} }
CR (QVsend (camera, cmd, 3, NULL, 0)); CR (QVsend (camera, cmd, 3, NULL, 0));
CR (gp_port_get_settings (camera->port, &settings)); CR (gp_port_get_settings (camera->port, &settings));
settings.serial.speed = speed; settings.serial.speed = speed;
CR (gp_port_set_settings (camera->port, settings)); CR (gp_port_set_settings (camera->port, settings));
CR (QVping (camera)); CR (QVping (camera));

View File

@@ -111,8 +111,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
long int camSize = 0; long int camSize = 0;
/* Get the number of the picture from the filesystem */ /* Get the number of the picture from the filesystem */
CHECK_RESULT (n = gp_filesystem_number (camera->fs, folder, filename, CHECK_RESULT (n = gp_filesystem_number (camera->fs, folder, filename, context));
context));
/* Prepare the transaction */ /* Prepare the transaction */
CHECK_RESULT (QVpicattr (camera, n, &attr)); CHECK_RESULT (QVpicattr (camera, n, &attr));
@@ -149,25 +148,24 @@ static int
delete_file_func (CameraFilesystem *fs, const char *folder, delete_file_func (CameraFilesystem *fs, const char *folder,
const char *filename, void *data, GPContext *context) const char *filename, void *data, GPContext *context)
{ {
Camera *camera = data; Camera *camera = data;
int nr ; int nr ;
CameraFileInfo info; CameraFileInfo info;
nr = gp_filesystem_number(fs, folder, filename, context); nr = gp_filesystem_number(fs, folder, filename, context);
if (nr < 0) if (nr < 0)
return nr; return nr;
CHECK_RESULT (get_info_func(fs, folder, filename, &info, data, context)); CHECK_RESULT (get_info_func(fs, folder, filename, &info, data, context));
if (info.file.permissions == GP_FILE_PERM_READ) { if (info.file.permissions == GP_FILE_PERM_READ) {
gp_context_error(context, _("Image %s is delete protected."), gp_context_error(context, _("Image %s is delete protected."), filename);
filename); return (GP_ERROR);
return (GP_ERROR); }
}
CHECK_RESULT (QVdelete (camera, nr)); CHECK_RESULT (QVdelete (camera, nr));
return GP_OK; return GP_OK;
} }
static int static int
@@ -234,10 +232,10 @@ get_info_func (CameraFilesystem *fs, const char *folder, const char *file,
info->preview.size = size_thumb; info->preview.size = size_thumb;
CHECK_RESULT (QVpicattr (camera, n, &attr)); CHECK_RESULT (QVpicattr (camera, n, &attr));
if (attr&1) if (attr&1)
info->file.permissions = GP_FILE_PERM_READ; info->file.permissions = GP_FILE_PERM_READ;
else else
info->file.permissions = GP_FILE_PERM_ALL; info->file.permissions = GP_FILE_PERM_ALL;
return (GP_OK); return (GP_OK);
} }
@@ -245,33 +243,33 @@ get_info_func (CameraFilesystem *fs, const char *folder, const char *file,
static int static int
camera_config_get (Camera *camera, CameraWidget **window, GPContext *context) camera_config_get (Camera *camera, CameraWidget **window, GPContext *context)
{ {
CameraWidget *child; CameraWidget *child;
float battery; float battery;
char status[2]; char status[2];
char t[1024]; char t[1024];
gp_widget_new (GP_WIDGET_WINDOW, _("Camera Configuration"), window); gp_widget_new (GP_WIDGET_WINDOW, _("Camera Configuration"), window);
CHECK_RESULT (QVbattery (camera, &battery)); CHECK_RESULT (QVbattery (camera, &battery));
gp_widget_new (GP_WIDGET_TEXT, _("Battery"), &child); gp_widget_new (GP_WIDGET_TEXT, _("Battery"), &child);
gp_widget_set_name (child, "battery"); gp_widget_set_name (child, "battery");
snprintf(t,sizeof(t),"%.1f V",battery); snprintf(t,sizeof(t),"%.1f V",battery);
gp_widget_set_value (child, t); gp_widget_set_value (child, t);
gp_widget_append (*window, child); gp_widget_append (*window, child);
CHECK_RESULT (QVstatus (camera, status)); CHECK_RESULT (QVstatus (camera, status));
gp_widget_new (GP_WIDGET_RADIO, _("Brightness"), &child); gp_widget_new (GP_WIDGET_RADIO, _("Brightness"), &child);
gp_widget_set_name (child, "brightness"); gp_widget_set_name (child, "brightness");
gp_widget_add_choice (child, _("Too bright")); gp_widget_add_choice (child, _("Too bright"));
gp_widget_add_choice (child, _("Too dark")); gp_widget_add_choice (child, _("Too dark"));
gp_widget_add_choice (child, _("OK")); gp_widget_add_choice (child, _("OK"));
if (status[0]&0x80) strcpy (t, _("Too bright")); if (status[0]&0x80) strcpy (t, _("Too bright"));
else if (status[0]&0x40) strcpy (t, _("Too dark")); else if (status[0]&0x40) strcpy (t, _("Too dark"));
else strcpy (t, _("OK")); else strcpy (t, _("OK"));
gp_widget_set_value (child, t); gp_widget_set_value (child, t);
gp_widget_append (*window, child); gp_widget_append (*window, child);
return (GP_OK); return (GP_OK);
} }
static int static int
@@ -321,12 +319,12 @@ camera_init (Camera *camera, GPContext *context)
gp_port_settings settings; gp_port_settings settings;
int selected_speed; int selected_speed;
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->get_config = camera_config_get; camera->functions->get_config = camera_config_get;
camera->functions->capture = camera_capture; camera->functions->capture = camera_capture;
camera->functions->summary = camera_summary; camera->functions->summary = camera_summary;
camera->functions->exit = camera_exit; camera->functions->exit = camera_exit;
camera->functions->about = camera_about; camera->functions->about = camera_about;
/* Now, tell the filesystem where to get lists and info */ /* Now, tell the filesystem where to get lists and info */
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);

View File

@@ -148,10 +148,10 @@ clicksmart_read_pic_data (CameraPrivateLibrary *priv, GPPort *port,
gp_port_usb_msg_interface_write(port, 6, 0x1fff - n, 1, NULL, 0); gp_port_usb_msg_interface_write(port, 6, 0x1fff - n, 1, NULL, 0);
c = 0; c = 0;
while (c != 1){ while (c != 1) {
int r; int r;
if ((r = CLICKSMART_READ_STATUS (port, &c)) < GP_OK) if ((r = CLICKSMART_READ_STATUS (port, &c)) < GP_OK)
return r; return r;
} }
/* Get the size of the data and calculate the size to download, which /* Get the size of the data and calculate the size to download, which
* is the next multiple of 0x100. Only for the hi-res photos is the * is the next multiple of 0x100. Only for the hi-res photos is the
@@ -160,9 +160,9 @@ clicksmart_read_pic_data (CameraPrivateLibrary *priv, GPPort *port,
size=(priv->catalog[16*n + 12] * 0x100)+(priv->catalog[16*n + 11]); size=(priv->catalog[16*n + 12] * 0x100)+(priv->catalog[16*n + 11]);
if (size == 0) /* for lo-res photos the above calculation gives 0 */ if (size == 0) /* for lo-res photos the above calculation gives 0 */
size = (priv->catalog[16*n + 5] * 0x100); size = (priv->catalog[16*n + 5] * 0x100);
if (size == 0) /* this means data corruption */ if (size == 0) /* this means data corruption */
return GP_ERROR; return GP_ERROR;
remainder = size%0x200; remainder = size%0x200;
@@ -171,10 +171,10 @@ clicksmart_read_pic_data (CameraPrivateLibrary *priv, GPPort *port,
if (!*data) return GP_ERROR; if (!*data) return GP_ERROR;
/* Download the data */ /* Download the data */
while (offset < size-remainder) { while (offset < size-remainder) {
GP_DEBUG("offset: %x\n", offset); GP_DEBUG("offset: %x\n", offset);
if (gp_port_read(port, (char *)*data + offset, 0x200) < GP_OK) if (gp_port_read(port, (char *)*data + offset, 0x200) < GP_OK)
break; break;
offset = offset + 0x200; offset = offset + 0x200;
} }
remainder=((remainder+0xff)/0x100)*0x100; remainder=((remainder+0xff)/0x100)*0x100;
@@ -215,7 +215,7 @@ clicksmart_reset (GPPort *port)
gp_port_usb_msg_interface_write(port, 0, 2, CS_CH_READY, NULL, 0); gp_port_usb_msg_interface_write(port, 0, 2, CS_CH_READY, NULL, 0);
CLICKSMART_READ (port, CS_CH_CLEAR, &c); CLICKSMART_READ (port, CS_CH_CLEAR, &c);
CLICKSMART_READ (port, CS_CH_CLEAR, &c); CLICKSMART_READ (port, CS_CH_CLEAR, &c);
return GP_OK; return GP_OK;
} }
/* create_jpeg_from_data adapted from camlibs/spca50x */ /* create_jpeg_from_data adapted from camlibs/spca50x */
@@ -223,7 +223,7 @@ clicksmart_reset (GPPort *port)
int create_jpeg_from_data (unsigned char * dst, unsigned char * src, int create_jpeg_from_data (unsigned char * dst, unsigned char * src,
int qIndex, int w, int h, unsigned char format, int qIndex, int w, int h, unsigned char format,
int o_size, int *size, int o_size, int *size,
int omit_huffman_table, int omit_escape) int omit_huffman_table, int omit_escape)
{ {
int i = 0; int i = 0;
unsigned char *start; unsigned char *start;
@@ -241,9 +241,9 @@ int create_jpeg_from_data (unsigned char * dst, unsigned char * src,
/* copy Huffman table */ /* copy Huffman table */
if (!omit_huffman_table) { if (!omit_huffman_table) {
memcpy (dst, SPCA50xJPGDefaultHeaderPart2, memcpy (dst, SPCA50xJPGDefaultHeaderPart2,
SPCA50X_JPG_DEFAULT_HEADER_PART2_LENGTH); SPCA50X_JPG_DEFAULT_HEADER_PART2_LENGTH);
dst += SPCA50X_JPG_DEFAULT_HEADER_PART2_LENGTH; dst += SPCA50X_JPG_DEFAULT_HEADER_PART2_LENGTH;
} }
memcpy (dst, SPCA50xJPGDefaultHeaderPart3, memcpy (dst, SPCA50xJPGDefaultHeaderPart3,
SPCA50X_JPG_DEFAULT_HEADER_PART3_LENGTH); SPCA50X_JPG_DEFAULT_HEADER_PART3_LENGTH);

View File

@@ -48,59 +48,59 @@
#define GP_MODULE "clicksmart310" #define GP_MODULE "clicksmart310"
static const struct { static const struct {
char *name; char *name;
CameraDriverStatus status; CameraDriverStatus status;
unsigned short idVendor; unsigned short idVendor;
unsigned short idProduct; unsigned short idProduct;
} models[] = { } models[] = {
{"Logitech Clicksmart 310", GP_DRIVER_STATUS_TESTING, 0x46d, 0x0900}, {"Logitech Clicksmart 310", GP_DRIVER_STATUS_TESTING, 0x46d, 0x0900},
{NULL,0,0,0} {NULL,0,0,0}
}; };
int int
camera_id (CameraText *id) camera_id (CameraText *id)
{ {
strcpy (id->text, "Logitech Clicksmart 310"); strcpy (id->text, "Logitech Clicksmart 310");
return GP_OK; return GP_OK;
} }
int int
camera_abilities (CameraAbilitiesList *list) camera_abilities (CameraAbilitiesList *list)
{ {
int i; int i;
CameraAbilities a; CameraAbilities a;
for (i = 0; models[i].name; i++) { for (i = 0; models[i].name; i++) {
memset (&a, 0, sizeof(a)); memset (&a, 0, sizeof(a));
strcpy (a.model, models[i].name); strcpy (a.model, models[i].name);
a.status = models[i].status; a.status = models[i].status;
a.port = GP_PORT_USB; a.port = GP_PORT_USB;
a.speed[0] = 0; a.speed[0] = 0;
a.usb_vendor = models[i].idVendor; a.usb_vendor = models[i].idVendor;
a.usb_product= models[i].idProduct; a.usb_product= models[i].idProduct;
a.operations = GP_OPERATION_NONE; a.operations = GP_OPERATION_NONE;
a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL; a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL;
; ;
a.file_operations = GP_FILE_OPERATION_PREVIEW a.file_operations = GP_FILE_OPERATION_PREVIEW
+ GP_FILE_OPERATION_RAW; + GP_FILE_OPERATION_RAW;
gp_abilities_list_append (list, a); gp_abilities_list_append (list, a);
} }
return GP_OK; return GP_OK;
} }
static int static int
camera_summary (Camera *camera, CameraText *summary, GPContext *context) camera_summary (Camera *camera, CameraText *summary, GPContext *context)
{ {
sprintf (summary->text,ngettext( sprintf (summary->text, ngettext(
"Your Logitech Clicksmart 310 has %i picture in it.\n", "Your Logitech Clicksmart 310 has %i picture in it.\n",
"Your Logitech Clicksmart 310 has %i pictures in it.\n", "Your Logitech Clicksmart 310 has %i pictures in it.\n",
camera->pl->num_pics camera->pl->num_pics
), ),
camera->pl->num_pics); camera->pl->num_pics);
return GP_OK; return GP_OK;
} }
@@ -135,10 +135,10 @@ static int camera_manual (Camera *camera, CameraText *manual, GPContext *context
static int static int
camera_about (Camera *camera, CameraText *about, GPContext *context) camera_about (Camera *camera, CameraText *about, GPContext *context)
{ {
strcpy (about->text, _("Logitech Clicksmart 310 driver\n" strcpy (about->text, _("Logitech Clicksmart 310 driver\n"
"Theodore Kilgore <kilgota@auburn.edu>\n")); "Theodore Kilgore <kilgota@auburn.edu>\n"));
return GP_OK; return GP_OK;
} }
/*************** File and Downloading Functions *******************/ /*************** File and Downloading Functions *******************/
@@ -148,10 +148,10 @@ static int
file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
void *data, GPContext *context) void *data, GPContext *context)
{ {
Camera *camera = data; Camera *camera = data;
int n; int n;
GP_DEBUG ("List files in %s\n", folder); GP_DEBUG ("List files in %s\n", folder);
n = camera->pl->num_pics; n = camera->pl->num_pics;
gp_list_populate(list, "cs%03i.jpeg", n); gp_list_populate(list, "cs%03i.jpeg", n);
return GP_OK; return GP_OK;
} }
@@ -162,7 +162,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
CameraFileType type, CameraFile *file, void *user_data, CameraFileType type, CameraFile *file, void *user_data,
GPContext *context) GPContext *context)
{ {
Camera *camera = user_data; Camera *camera = user_data;
int w=0, h=0, b=0; int w=0, h=0, b=0;
int k, res; int k, res;
unsigned char *data; unsigned char *data;
@@ -171,7 +171,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
unsigned char jpeg_format; unsigned char jpeg_format;
/* Get the entry number of the photo on the camera */ /* Get the entry number of the photo on the camera */
k = gp_filesystem_number (camera->fs, "/", filename, context); k = gp_filesystem_number (camera->fs, "/", filename, context);
if (GP_FILE_TYPE_EXIF==type) return GP_ERROR_FILE_EXISTS; if (GP_FILE_TYPE_EXIF==type) return GP_ERROR_FILE_EXISTS;
@@ -180,7 +180,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
res = clicksmart_get_res_setting (camera->pl, k); res = clicksmart_get_res_setting (camera->pl, k);
switch (res) { switch (res) {
case 0: w = 352; case 0: w = 352;
h = 288; h = 288;
jpeg_format = JPEG_CIF_FORMAT; jpeg_format = JPEG_CIF_FORMAT;
@@ -202,10 +202,10 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
if (GP_FILE_TYPE_RAW == type) { /* type is GP_FILE_TYPE_RAW */ if (GP_FILE_TYPE_RAW == type) { /* type is GP_FILE_TYPE_RAW */
gp_file_set_mime_type (file, GP_MIME_RAW); gp_file_set_mime_type (file, GP_MIME_RAW);
gp_file_set_data_and_size (file, (char *)data, b); gp_file_set_data_and_size (file, (char *)data, b);
/* Reset camera when done, for more graceful exit. */ /* Reset camera when done, for more graceful exit. */
if (k +1 == camera->pl->num_pics) { if (k +1 == camera->pl->num_pics) {
clicksmart_reset (camera->port); clicksmart_reset (camera->port);
} }
return GP_OK; return GP_OK;
} }
@@ -225,13 +225,13 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
GP_DEBUG("width: %d, height: %d, data size: %d\n", w, h, b); GP_DEBUG("width: %d, height: %d, data size: %d\n", w, h, b);
create_jpeg_from_data (jpeg_out, data, 3, w, h, jpeg_format, create_jpeg_from_data (jpeg_out, data, 3, w, h, jpeg_format,
b, &file_size, 0, 0); b, &file_size, 0, 0);
gp_file_set_mime_type (file, GP_MIME_JPEG); gp_file_set_mime_type (file, GP_MIME_JPEG);
gp_file_set_data_and_size (file, (char *)jpeg_out, file_size); gp_file_set_data_and_size (file, (char *)jpeg_out, file_size);
/* Reset camera when done, for more graceful exit. */ /* Reset camera when done, for more graceful exit. */
if (k +1 == camera->pl->num_pics) { if (k +1 == camera->pl->num_pics) {
clicksmart_reset (camera->port); clicksmart_reset (camera->port);
} }
free(data); free(data);
return GP_OK; return GP_OK;
@@ -276,10 +276,10 @@ camera_init(Camera *camera, GPContext *context)
int ret = 0; int ret = 0;
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->summary = camera_summary; camera->functions->summary = camera_summary;
camera->functions->manual = camera_manual; camera->functions->manual = camera_manual;
camera->functions->about = camera_about; camera->functions->about = camera_about;
camera->functions->exit = camera_exit; camera->functions->exit = camera_exit;
GP_DEBUG ("Initializing the camera\n"); GP_DEBUG ("Initializing the camera\n");
@@ -303,7 +303,7 @@ camera_init(Camera *camera, GPContext *context)
ret = gp_port_set_settings(camera->port,settings); ret = gp_port_set_settings(camera->port,settings);
if (ret < 0) return ret; if (ret < 0) return ret;
/* Tell the CameraFilesystem where to get lists from */ /* Tell the CameraFilesystem where to get lists from */
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
camera->pl = malloc (sizeof (CameraPrivateLibrary)); camera->pl = malloc (sizeof (CameraPrivateLibrary));
if (!camera->pl) return GP_ERROR_NO_MEMORY; if (!camera->pl) return GP_ERROR_NO_MEMORY;

View File

@@ -53,18 +53,18 @@ digi_first_decompress (unsigned char *output, unsigned char *input,
unsigned int bit_counter = 8; unsigned int bit_counter = 8;
unsigned int cycles = 0; unsigned int cycles = 0;
int table[9] = { -1, 0, 2, 6, 0x0e, 0x0e, 0x0e, 0x0e, 0xfb}; int table[9] = { -1, 0, 2, 6, 0x0e, 0x0e, 0x0e, 0x0e, 0xfb};
unsigned char lookup_table[16] unsigned char lookup_table[16] =
={0, 2, 6, 0x0e, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, {0, 2, 6, 0x0e, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4,
0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb}; 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb};
unsigned char translator[16] = unsigned char translator[16] =
{8, 7, 9, 6, 10, 11, 12, 13, 14, 15, 5, 4, 3, 2, 1, 0}; {8, 7, 9, 6, 10, 11, 12, 13, 14, 15, 5, 4, 3, 2, 1, 0};
GP_DEBUG ("Running first_decompress.\n"); GP_DEBUG ("Running first_decompress.\n");
nibble_to_keep[0] = 0; nibble_to_keep[0] = 0;
nibble_to_keep[1] = 0; nibble_to_keep[1] = 0;
while (bytes_done < outputsize) { while (bytes_done < outputsize) {
while (parity < 2 ) { while (parity < 2 ) {
while ( lookup > table[cycles]) { while ( lookup > table[cycles]) {
if (bit_counter == 8) { if (bit_counter == 8) {
input_byte = input[bytes_used]; input_byte = input[bytes_used];

View File

@@ -357,8 +357,7 @@ camera_capture_preview(Camera *camera, CameraFile *file, GPContext *context)
gp_port_read(camera->port, (char *)get_size, 0x50); gp_port_read(camera->port, (char *)get_size, 0x50);
GP_DEBUG("get_size[0x40] = 0x%x\n", get_size[0x40]); GP_DEBUG("get_size[0x40] = 0x%x\n", get_size[0x40]);
lighting = get_size[0x48]; lighting = get_size[0x48];
b = get_size[0x40] | get_size[0x41] << 8 | get_size[0x42] << 16 b = get_size[0x40] | get_size[0x41] << 8 | get_size[0x42] << 16 | get_size[0x43]<<24;
| get_size[0x43]<<24;
GP_DEBUG("b = 0x%x\n", b); GP_DEBUG("b = 0x%x\n", b);
raw_data = malloc(b); raw_data = malloc(b);
@@ -393,7 +392,7 @@ camera_capture_preview(Camera *camera, CameraFile *file, GPContext *context)
GP_DEBUG ("size = %i\n", size); GP_DEBUG ("size = %i\n", size);
gp_ahd_decode (frame_data, w , h , ptr, BAYER_TILE_BGGR); gp_ahd_decode (frame_data, w , h , ptr, BAYER_TILE_BGGR);
free(frame_data); free(frame_data);
if (lighting < 0x40) { if (lighting < 0x40) {
GP_DEBUG( GP_DEBUG(
"Low light condition. Default gamma. No white balance.\n"); "Low light condition. Default gamma. No white balance.\n");
gp_gamma_fill_table (gtable, .65); gp_gamma_fill_table (gtable, .65);
@@ -441,7 +440,7 @@ camera_init(Camera *camera, GPContext *context)
/* Now, set up all the function pointers */ /* Now, set up all the function pointers */
camera->functions->summary = camera_summary; camera->functions->summary = camera_summary;
camera->functions->manual = camera_manual; camera->functions->manual = camera_manual;
camera->functions->about = camera_about; camera->functions->about = camera_about;
camera->functions->capture_preview camera->functions->capture_preview
= camera_capture_preview; = camera_capture_preview;

View File

@@ -313,7 +313,7 @@ static int get_file_func(CameraFilesystem *fs, const char *folder,
switch (type) { switch (type) {
case GP_FILE_TYPE_NORMAL: case GP_FILE_TYPE_NORMAL:
GP_DEBUG("digita/get_file_func: Getting picture"); GP_DEBUG("digita/get_file_func: Getting picture");
data = digita_file_get(camera, folder, filename, 0, &buflen, context); data = digita_file_get(camera, folder, filename, 0, &buflen, context);
break; break;
case GP_FILE_TYPE_PREVIEW: case GP_FILE_TYPE_PREVIEW:
GP_DEBUG("digita/get_file_func: Getting thumbnail"); GP_DEBUG("digita/get_file_func: Getting thumbnail");
@@ -407,18 +407,18 @@ static int digita_file_delete(Camera *camera, const char *folder,
if (digita_get_file_list(camera->pl) < 0) if (digita_get_file_list(camera->pl) < 0)
return 0; return 0;
return GP_OK; return GP_OK;
} }
static int delete_file_func(CameraFilesystem *fs, const char *folder, static int delete_file_func(CameraFilesystem *fs, const char *folder,
const char *filename, void *user_data, GPContext *context) const char *filename, void *user_data, GPContext *context)
{ {
Camera *camera = user_data; Camera *camera = user_data;
if (folder[0] == '/') if (folder[0] == '/')
folder++; folder++;
return digita_file_delete(camera, folder, filename, context); return digita_file_delete(camera, folder, filename, context);
} }
static CameraFilesystemFuncs fsfuncs = { static CameraFilesystemFuncs fsfuncs = {

View File

@@ -82,17 +82,17 @@ Dimera_Preview( long *size, Camera *camera, GPContext *context );
/* Gphoto2 */ /* Gphoto2 */
struct _CameraPrivateLibrary { struct _CameraPrivateLibrary {
unsigned exposure; unsigned exposure;
int auto_exposure; int auto_exposure;
int auto_flash; int auto_flash;
}; };
static const char *models[] = { static const char *models[] = {
"Mustek:VDC-3500", "Mustek:VDC-3500",
"Relisys:Dimera 3500", "Relisys:Dimera 3500",
"Trust:DC-3500", "Trust:DC-3500",
NULL NULL
}; };
@@ -376,14 +376,14 @@ static int camera_capture (Camera *camera, CameraCaptureType type, CameraFilePat
} }
static int camera_capture_preview(Camera *camera, CameraFile *file, GPContext *context) { static int camera_capture_preview(Camera *camera, CameraFile *file, GPContext *context) {
long size; long size;
uint8_t *data; uint8_t *data;
gp_file_set_mime_type (file, GP_MIME_PGM); gp_file_set_mime_type (file, GP_MIME_PGM);
data = Dimera_Preview( &size, camera, context); data = Dimera_Preview (&size, camera, context);
if (!data) if (!data)
return GP_ERROR; return GP_ERROR;
return gp_file_set_data_and_size (file, (char *)data, size); return gp_file_set_data_and_size (file, (char *)data, size);
} }
@@ -860,7 +860,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_widget_get_child_by_label (window, _("Exposure level on preview"), &w); gp_widget_get_child_by_label (window, _("Exposure level on preview"), &w);
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &wvalue); gp_widget_get_value (w, &wvalue);
camera->pl->exposure = MAX(MIN_EXPOSURE,MIN(MAX_EXPOSURE,atoi(wvalue))); camera->pl->exposure = MAX(MIN_EXPOSURE,MIN(MAX_EXPOSURE,atoi(wvalue)));
gp_setting_set ("dimera3500", "exposure", wvalue); gp_setting_set ("dimera3500", "exposure", wvalue);
@@ -869,7 +869,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_widget_get_child_by_label (window, _("Automatic exposure adjustment on preview"), &w); gp_widget_get_child_by_label (window, _("Automatic exposure adjustment on preview"), &w);
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &val); gp_widget_get_value (w, &val);
camera->pl->auto_exposure = val; camera->pl->auto_exposure = val;
sprintf(str, "%d", val); sprintf(str, "%d", val);
@@ -879,7 +879,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_widget_get_child_by_label (window, _("Automatic flash on capture"), &w); gp_widget_get_child_by_label (window, _("Automatic flash on capture"), &w);
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &val); gp_widget_get_value (w, &val);
camera->pl->auto_flash = val; camera->pl->auto_flash = val;
sprintf(str, "%d", val); sprintf(str, "%d", val);
@@ -901,18 +901,18 @@ static CameraFilesystemFuncs fsfuncs = {
int camera_init (Camera *camera, GPContext *context) { int camera_init (Camera *camera, GPContext *context) {
GPPortSettings settings; GPPortSettings settings;
int ret, selected_speed; int ret, selected_speed;
char buf[1024]; char buf[1024];
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->exit = camera_exit; camera->functions->exit = camera_exit;
camera->functions->capture = camera_capture; camera->functions->capture = camera_capture;
camera->functions->capture_preview = camera_capture_preview; camera->functions->capture_preview = camera_capture_preview;
camera->functions->summary = camera_summary; camera->functions->summary = camera_summary;
camera->functions->manual = camera_manual; camera->functions->manual = camera_manual;
camera->functions->about = camera_about; camera->functions->about = camera_about;
camera->functions->get_config = camera_get_config; camera->functions->get_config = camera_get_config;
camera->functions->set_config = camera_set_config; camera->functions->set_config = camera_set_config;
/* Get the settings and remember the selected speed */ /* Get the settings and remember the selected speed */
gp_port_get_settings (camera->port, &settings); gp_port_get_settings (camera->port, &settings);
@@ -926,77 +926,77 @@ int camera_init (Camera *camera, GPContext *context) {
return (GP_ERROR_NO_MEMORY); return (GP_ERROR_NO_MEMORY);
} }
/* Set the default exposure */ /* Set the default exposure */
if (gp_setting_get ("dimera3500", "exposure", buf) == GP_OK) if (gp_setting_get ("dimera3500", "exposure", buf) == GP_OK)
camera->pl->exposure = atoi(buf); camera->pl->exposure = atoi(buf);
else else
camera->pl->exposure = DEFAULT_EXPOSURE; camera->pl->exposure = DEFAULT_EXPOSURE;
/* Set automatic exposure enable setting for capture preview mode */ /* Set automatic exposure enable setting for capture preview mode */
if (gp_setting_get ("dimera3500", "auto_exposure", buf) == GP_OK) if (gp_setting_get ("dimera3500", "auto_exposure", buf) == GP_OK)
camera->pl->auto_exposure = atoi(buf); camera->pl->auto_exposure = atoi(buf);
else else
camera->pl->auto_exposure = 1; camera->pl->auto_exposure = 1;
/* Set flag to use flash, if necessary, when capturing picture */ /* Set flag to use flash, if necessary, when capturing picture */
if (gp_setting_get ("dimera3500", "auto_flash", buf) == GP_OK) if (gp_setting_get ("dimera3500", "auto_flash", buf) == GP_OK)
camera->pl->auto_flash = atoi(buf); camera->pl->auto_flash = atoi(buf);
else else
camera->pl->auto_flash = 1; camera->pl->auto_flash = 1;
GP_DEBUG("Opening port"); GP_DEBUG("Opening port");
if ( (ret = mesa_port_open(camera->port)) != GP_OK) if ((ret = mesa_port_open(camera->port)) != GP_OK)
{ {
gp_log(GP_LOG_ERROR, "dimera/dimera3500", "Camera Open Failed"); gp_log(GP_LOG_ERROR, "dimera/dimera3500", "Camera Open Failed");
free (camera->pl); free (camera->pl);
camera->pl = NULL; camera->pl = NULL;
gp_context_error (context, _("Problem opening port")); gp_context_error (context, _("Problem opening port"));
return ret; return ret;
} }
GP_DEBUG("Resetting camera"); GP_DEBUG("Resetting camera");
if ( (ret = mesa_reset(camera->port)) != GP_OK ) if ((ret = mesa_reset(camera->port)) != GP_OK)
{ {
gp_log(GP_LOG_ERROR, "dimera/dimera3500", "Camera Reset Failed"); gp_log(GP_LOG_ERROR, "dimera/dimera3500", "Camera Reset Failed");
free (camera->pl); free (camera->pl);
camera->pl = NULL; camera->pl = NULL;
gp_context_error (context, _("Problem resetting camera")); gp_context_error (context, _("Problem resetting camera"));
return ret; return ret;
} }
GP_DEBUG("Setting speed"); GP_DEBUG("Setting speed");
if ( (ret = mesa_set_speed(camera->port, selected_speed)) != GP_OK ) if ((ret = mesa_set_speed(camera->port, selected_speed)) != GP_OK)
{ {
gp_log(GP_LOG_ERROR, "dimera/dimera3500", "Camera Speed Setting Failed"); gp_log(GP_LOG_ERROR, "dimera/dimera3500", "Camera Speed Setting Failed");
free (camera->pl); free (camera->pl);
camera->pl = NULL; camera->pl = NULL;
gp_context_error (context, _("Problem setting camera communication speed")); gp_context_error (context, _("Problem setting camera communication speed"));
return ret; return ret;
} }
GP_DEBUG("Checking for modem"); GP_DEBUG("Checking for modem");
switch ( ret = mesa_modem_check(camera->port) ) switch (ret = mesa_modem_check(camera->port))
{ {
case GP_ERROR_IO: case GP_ERROR_IO:
case GP_ERROR_TIMEOUT: case GP_ERROR_TIMEOUT:
gp_log(GP_LOG_ERROR, "dimera/dimera3500", "No or Unknown Response"); gp_log(GP_LOG_ERROR, "dimera/dimera3500", "No or Unknown Response");
free (camera->pl); free (camera->pl);
camera->pl = NULL; camera->pl = NULL;
gp_context_error (context, _("No response from camera")); gp_context_error (context, _("No response from camera"));
return GP_ERROR_TIMEOUT; return GP_ERROR_TIMEOUT;
case GP_ERROR_MODEL_NOT_FOUND: case GP_ERROR_MODEL_NOT_FOUND:
gp_log(GP_LOG_ERROR, "dimera/dimera3500", "Probably a modem"); gp_log(GP_LOG_ERROR, "dimera/dimera3500", "Probably a modem");
free (camera->pl); free (camera->pl);
camera->pl = NULL; camera->pl = NULL;
gp_context_error (context, _("Looks like a modem, not a camera")); gp_context_error (context, _("Looks like a modem, not a camera"));
return GP_ERROR_MODEL_NOT_FOUND; return GP_ERROR_MODEL_NOT_FOUND;
case GP_OK: case GP_OK:
break; break;
default: default:
/* Hopefully, gp_camera_set_error was called for this error */ /* Hopefully, gp_camera_set_error was called for this error */
return ret; return ret;
} }
/* Tell the filesystem where to get listings and info from */ /* Tell the filesystem where to get listings and info from */
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
return (GP_OK); return (GP_OK);

View File

@@ -125,60 +125,60 @@ static const char *
get_mime_type (const char *filename) get_mime_type (const char *filename)
{ {
char *dot; char *dot;
int x=0; int x=0;
dot = strrchr(filename, '.'); dot = strrchr(filename, '.');
if (dot) { if (dot) {
for (x = 0; mime_table[x].extension; x++) { for (x = 0; mime_table[x].extension; x++) {
if (!strcasecmp (mime_table[x].extension, dot+1)) if (!strcasecmp (mime_table[x].extension, dot+1))
return (mime_table[x].mime_type); return (mime_table[x].mime_type);
} }
} }
return (NULL); return (NULL);
} }
int camera_id (CameraText *id) int camera_id (CameraText *id)
{ {
strcpy(id->text, "directory"); strcpy(id->text, "directory");
return (GP_OK); return (GP_OK);
} }
int camera_abilities (CameraAbilitiesList *list) int camera_abilities (CameraAbilitiesList *list)
{ {
CameraAbilities a; CameraAbilities a;
memset(&a, 0, sizeof(a)); memset(&a, 0, sizeof(a));
strcpy(a.model, "Directory Browse"); strcpy(a.model, "Directory Browse");
a.status = GP_DRIVER_STATUS_PRODUCTION; a.status = GP_DRIVER_STATUS_PRODUCTION;
a.port = GP_PORT_DISK; a.port = GP_PORT_DISK;
a.speed[0] = 0; a.speed[0] = 0;
a.operations = GP_OPERATION_NONE; a.operations = GP_OPERATION_NONE;
#ifdef DEBUG #ifdef DEBUG
a.file_operations = GP_FILE_OPERATION_PREVIEW | a.file_operations = GP_FILE_OPERATION_PREVIEW |
GP_FILE_OPERATION_DELETE | GP_FILE_OPERATION_DELETE |
GP_FILE_OPERATION_EXIF; GP_FILE_OPERATION_EXIF;
#else #else
a.file_operations = GP_FILE_OPERATION_DELETE | a.file_operations = GP_FILE_OPERATION_DELETE |
GP_FILE_OPERATION_EXIF; GP_FILE_OPERATION_EXIF;
#endif #endif
a.folder_operations = GP_FOLDER_OPERATION_MAKE_DIR | a.folder_operations = GP_FOLDER_OPERATION_MAKE_DIR |
GP_FOLDER_OPERATION_REMOVE_DIR | GP_FOLDER_OPERATION_REMOVE_DIR |
GP_FOLDER_OPERATION_PUT_FILE; GP_FOLDER_OPERATION_PUT_FILE;
gp_abilities_list_append(list, a); gp_abilities_list_append(list, a);
/* Since "Directory Browse" is hardcoded in clients, /* Since "Directory Browse" is hardcoded in clients,
* better also add a new name here. * better also add a new name here.
*/ */
strcpy(a.model, "Mass Storage Camera"); strcpy(a.model, "Mass Storage Camera");
gp_abilities_list_append(list, a); gp_abilities_list_append(list, a);
return (GP_OK); return (GP_OK);
} }
static int static int
@@ -395,9 +395,9 @@ get_info_func (CameraFilesystem *fs, const char *folder, const char *file,
return (GP_ERROR); return (GP_ERROR);
} }
info->preview.fields = GP_FILE_INFO_NONE; info->preview.fields = GP_FILE_INFO_NONE;
info->file.fields = GP_FILE_INFO_SIZE | info->file.fields = GP_FILE_INFO_SIZE |
GP_FILE_INFO_TYPE | GP_FILE_INFO_PERMISSIONS | GP_FILE_INFO_TYPE | GP_FILE_INFO_PERMISSIONS |
GP_FILE_INFO_MTIME; GP_FILE_INFO_MTIME;
info->file.mtime = st.st_mtime; info->file.mtime = st.st_mtime;
@@ -406,12 +406,12 @@ get_info_func (CameraFilesystem *fs, const char *folder, const char *file,
info->file.permissions |= GP_FILE_PERM_READ; info->file.permissions |= GP_FILE_PERM_READ;
if (st.st_mode & S_IWUSR) if (st.st_mode & S_IWUSR)
info->file.permissions |= GP_FILE_PERM_DELETE; info->file.permissions |= GP_FILE_PERM_DELETE;
info->file.size = st.st_size; info->file.size = st.st_size;
mime_type = get_mime_type (file); mime_type = get_mime_type (file);
if (!mime_type) if (!mime_type)
mime_type = GP_MIME_UNKNOWN; mime_type = GP_MIME_UNKNOWN;
strcpy (info->file.type, mime_type); strcpy (info->file.type, mime_type);
return (GP_OK); return (GP_OK);
} }
static int static int
@@ -446,10 +446,10 @@ set_info_func (CameraFilesystem *fs, const char *folder, const char *file,
#if 0 /* implement this using new api -Marcus */ #if 0 /* implement this using new api -Marcus */
if (info.file.fields & GP_FILE_INFO_NAME) { if (info.file.fields & GP_FILE_INFO_NAME) {
if (!strcasecmp (info.file.name, file)) if (!strcasecmp (info.file.name, file))
return (GP_OK); return (GP_OK);
/* We really have to rename the poor file... */ /* We really have to rename the poor file... */
if (strlen (folder) == 1) { if (strlen (folder) == 1) {
snprintf (path_old, sizeof (path_old), "/%s", snprintf (path_old, sizeof (path_old), "/%s",
file); file);
@@ -461,29 +461,29 @@ set_info_func (CameraFilesystem *fs, const char *folder, const char *file,
snprintf (path_new, sizeof (path_new), "%s/%s", snprintf (path_new, sizeof (path_new), "%s/%s",
folder, info.file.name); folder, info.file.name);
} }
retval = rename (path_old, path_new); retval = rename (path_old, path_new);
if (retval != 0) { if (retval != 0) {
switch (errno) { switch (errno) {
case EISDIR: case EISDIR:
return (GP_ERROR_DIRECTORY_EXISTS); return (GP_ERROR_DIRECTORY_EXISTS);
case EEXIST: case EEXIST:
return (GP_ERROR_FILE_EXISTS); return (GP_ERROR_FILE_EXISTS);
case EINVAL: case EINVAL:
return (GP_ERROR_BAD_PARAMETERS); return (GP_ERROR_BAD_PARAMETERS);
case EIO: case EIO:
return (GP_ERROR_IO); return (GP_ERROR_IO);
case ENOMEM: case ENOMEM:
return (GP_ERROR_NO_MEMORY); return (GP_ERROR_NO_MEMORY);
case ENOENT: case ENOENT:
return (GP_ERROR_FILE_NOT_FOUND); return (GP_ERROR_FILE_NOT_FOUND);
default: default:
return (GP_ERROR); return (GP_ERROR);
} }
} }
} }
#endif #endif
return (GP_OK); return (GP_OK);
} }
static int static int
@@ -491,7 +491,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
CameraFileType type, CameraFile *file, void *user_data, CameraFileType type, CameraFile *file, void *user_data,
GPContext *context) GPContext *context)
{ {
char path[1024]; char path[1024];
int result = GP_OK; int result = GP_OK;
struct stat stbuf; struct stat stbuf;
int fd, id; int fd, id;
@@ -589,19 +589,19 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
static int static int
camera_manual (Camera *camera, CameraText *manual, GPContext *context) camera_manual (Camera *camera, CameraText *manual, GPContext *context)
{ {
strcpy (manual->text, _("The Directory Browse \"camera\" lets " strcpy (manual->text, _("The Directory Browse \"camera\" lets "
"you index photos on your hard drive.")); "you index photos on your hard drive."));
return (GP_OK); return (GP_OK);
} }
static int static int
camera_about (Camera *camera, CameraText *about, GPContext *context) camera_about (Camera *camera, CameraText *about, GPContext *context)
{ {
strcpy (about->text, _("Directory Browse Mode - written " strcpy (about->text, _("Directory Browse Mode - written "
"by Scott Fritzinger <scottf@unr.edu>.")); "by Scott Fritzinger <scottf@unr.edu>."));
return (GP_OK); return (GP_OK);
} }
static int static int
@@ -783,8 +783,8 @@ static CameraFilesystemFuncs fsfuncs = {
int int
camera_init (Camera *camera, GPContext *context) camera_init (Camera *camera, GPContext *context)
{ {
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->manual = camera_manual; camera->functions->manual = camera_manual;
camera->functions->about = camera_about; camera->functions->about = camera_about;
return gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); return gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
} }

View File

@@ -110,7 +110,7 @@ bool dp_init_calibration(Camera *camera, bool force)
int i, j; int i, j;
if (camera->pl->lut) if (camera->pl->lut)
return true; return true;
lut_file = malloc(64 + strlen(getenv("HOME"))); lut_file = malloc(64 + strlen(getenv("HOME")));
if (!lut_file) if (!lut_file)

View File

@@ -157,90 +157,90 @@ camera_config_get (Camera *camera, CameraWidget **window, GPContext *context)
gp_widget_new (GP_WIDGET_SECTION, _("Mono mode"), &section); gp_widget_new (GP_WIDGET_SECTION, _("Mono mode"), &section);
gp_widget_append (*window, section); gp_widget_append (*window, section);
gp_widget_new (GP_WIDGET_RADIO, _("Depth"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("Depth"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("Mono (b/w)")); gp_widget_add_choice (widget, _("Mono (b/w)"));
gp_widget_add_choice (widget, _("Grey (4bpp)")); gp_widget_add_choice (widget, _("Grey (4bpp)"));
gp_widget_add_choice (widget, _("Grey (8bpp)")); gp_widget_add_choice (widget, _("Grey (8bpp)"));
switch(camera->pl->profile[0x80]) { switch (camera->pl->profile[0x80]) {
case 0x00: gp_widget_set_value (widget, _("Mono (b/w)")); break; case 0x00: gp_widget_set_value (widget, _("Mono (b/w)")); break;
case 0x01: gp_widget_set_value (widget, _("Grey (4bpp)")); break; case 0x01: gp_widget_set_value (widget, _("Grey (4bpp)")); break;
case 0x02: gp_widget_set_value (widget, _("Grey (8bpp)")); break; case 0x02: gp_widget_set_value (widget, _("Grey (8bpp)")); break;
} }
gp_widget_new (GP_WIDGET_RADIO, _("Lo Resolution"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("Lo Resolution"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("100 DPI")); gp_widget_add_choice (widget, _("100 DPI"));
gp_widget_add_choice (widget, _("200 DPI")); gp_widget_add_choice (widget, _("200 DPI"));
switch(camera->pl->profile[0x81]) { switch (camera->pl->profile[0x81]) {
case RES_100DPI: gp_widget_set_value (widget, _("100 DPI")); break; case RES_100DPI: gp_widget_set_value (widget, _("100 DPI")); break;
case RES_200DPI: gp_widget_set_value (widget, _("200 DPI")); break; case RES_200DPI: gp_widget_set_value (widget, _("200 DPI")); break;
} }
gp_widget_new (GP_WIDGET_RADIO, _("Hi Resolution"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("Hi Resolution"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("200 DPI")); gp_widget_add_choice (widget, _("200 DPI"));
gp_widget_add_choice (widget, _("400 DPI")); gp_widget_add_choice (widget, _("400 DPI"));
switch(camera->pl->profile[0x82]) { switch (camera->pl->profile[0x82]) {
case RES_200DPI: gp_widget_set_value (widget, _("200 DPI")); break; case RES_200DPI: gp_widget_set_value (widget, _("200 DPI")); break;
case RES_400DPI: gp_widget_set_value (widget, _("400 DPI")); break; case RES_400DPI: gp_widget_set_value (widget, _("400 DPI")); break;
} }
gp_widget_new (GP_WIDGET_SECTION, _("Color Document mode"), &section); gp_widget_new (GP_WIDGET_SECTION, _("Color Document mode"), &section);
gp_widget_append (*window, section); gp_widget_append (*window, section);
gp_widget_new (GP_WIDGET_RADIO, _("Depth"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("Depth"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("NQ (12bpp)")); gp_widget_add_choice (widget, _("NQ (12bpp)"));
switch(camera->pl->profile[0x83]) { switch (camera->pl->profile[0x83]) {
case 0x04: gp_widget_set_value (widget, _("NQ (12bpp)")); break; case 0x04: gp_widget_set_value (widget, _("NQ (12bpp)")); break;
} }
gp_widget_new (GP_WIDGET_RADIO, _("Lo Resolution"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("Lo Resolution"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("100 DPI")); gp_widget_add_choice (widget, _("100 DPI"));
gp_widget_add_choice (widget, _("200 DPI")); gp_widget_add_choice (widget, _("200 DPI"));
switch(camera->pl->profile[0x84]) { switch (camera->pl->profile[0x84]) {
case RES_100DPI: gp_widget_set_value (widget, _("100 DPI")); break; case RES_100DPI: gp_widget_set_value (widget, _("100 DPI")); break;
case RES_200DPI: gp_widget_set_value (widget, _("200 DPI")); break; case RES_200DPI: gp_widget_set_value (widget, _("200 DPI")); break;
} }
gp_widget_new (GP_WIDGET_RADIO, _("Hi Resolution"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("Hi Resolution"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("200 DPI")); gp_widget_add_choice (widget, _("200 DPI"));
gp_widget_add_choice (widget, _("400 DPI")); gp_widget_add_choice (widget, _("400 DPI"));
switch(camera->pl->profile[0x85]) { switch (camera->pl->profile[0x85]) {
case RES_200DPI: gp_widget_set_value (widget, _("200 DPI")); break; case RES_200DPI: gp_widget_set_value (widget, _("200 DPI")); break;
case RES_400DPI: gp_widget_set_value (widget, _("400 DPI")); break; case RES_400DPI: gp_widget_set_value (widget, _("400 DPI")); break;
} }
gp_widget_new (GP_WIDGET_SECTION, _("Color Photo mode"), &section); gp_widget_new (GP_WIDGET_SECTION, _("Color Photo mode"), &section);
gp_widget_append (*window, section); gp_widget_append (*window, section);
gp_widget_new (GP_WIDGET_RADIO, _("Depth"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("Depth"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("HQ (24bpp)")); gp_widget_add_choice (widget, _("HQ (24bpp)"));
switch(camera->pl->profile[0x86]) { switch (camera->pl->profile[0x86]) {
case 0x08: gp_widget_set_value (widget, _("HQ (24bpp)")); break; case 0x08: gp_widget_set_value (widget, _("HQ (24bpp)")); break;
} }
gp_widget_new (GP_WIDGET_RADIO, _("Lo Resolution"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("Lo Resolution"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("100 DPI")); gp_widget_add_choice (widget, _("100 DPI"));
gp_widget_add_choice (widget, _("200 DPI")); gp_widget_add_choice (widget, _("200 DPI"));
switch(camera->pl->profile[0x87]) { switch (camera->pl->profile[0x87]) {
case RES_100DPI: gp_widget_set_value (widget, _("100 DPI")); break; case RES_100DPI: gp_widget_set_value (widget, _("100 DPI")); break;
case RES_200DPI: gp_widget_set_value (widget, _("200 DPI")); break; case RES_200DPI: gp_widget_set_value (widget, _("200 DPI")); break;
} }
gp_widget_new (GP_WIDGET_RADIO, _("Hi Resolution"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("Hi Resolution"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("200 DPI")); gp_widget_add_choice (widget, _("200 DPI"));
gp_widget_add_choice (widget, _("400 DPI")); gp_widget_add_choice (widget, _("400 DPI"));
switch(camera->pl->profile[0x88]) { switch (camera->pl->profile[0x88]) {
case RES_200DPI: gp_widget_set_value (widget, _("200 DPI")); break; case RES_200DPI: gp_widget_set_value (widget, _("200 DPI")); break;
case RES_400DPI: gp_widget_set_value (widget, _("400 DPI")); break; case RES_400DPI: gp_widget_set_value (widget, _("400 DPI")); break;
} }
return GP_OK; return GP_OK;
} }
@@ -654,12 +654,12 @@ camera_init (Camera *camera, GPContext *context)
{ {
char buf[64]; char buf[64];
camera->functions->exit = camera_exit; camera->functions->exit = camera_exit;
camera->functions->get_config = camera_config_get; camera->functions->get_config = camera_config_get;
camera->functions->set_config = camera_config_set; camera->functions->set_config = camera_config_set;
camera->functions->summary = camera_summary; camera->functions->summary = camera_summary;
camera->functions->manual = camera_manual; camera->functions->manual = camera_manual;
camera->functions->about = camera_about; camera->functions->about = camera_about;
gp_filesystem_set_funcs(camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs(camera->fs, &fsfuncs, camera);

View File

@@ -62,10 +62,10 @@ static char* enigma13_static_toc=NULL;
static int enigma13_about (Camera *camera, CameraText *about, GPContext *context) static int enigma13_about (Camera *camera, CameraText *about, GPContext *context)
{ {
strcpy (about->text, _("Download program for Digital Dream Enigma 1.3. " strcpy (about->text, _("Download program for Digital Dream Enigma 1.3. "
"by <olivier@aixmarseille.com>, and adapted from spca50x driver. " "by <olivier@aixmarseille.com>, and adapted from spca50x driver. "
"Thank you, spca50x team, it was easy to port your driver on this cam! ")); "Thank you, spca50x team, it was easy to port your driver on this cam! "));
return (GP_OK); return (GP_OK);
} }
@@ -78,17 +78,16 @@ static int enigma13_about (Camera *camera, CameraText *about, GPContext *context
*/ */
static int enigma13_detect_storage_type (Camera *camera) static int enigma13_detect_storage_type (Camera *camera)
{ {
int i; int i;
char buf[3]; char buf[3];
for (i=0;i<3;i++) for (i=0;i<3;i++)
{ {
CHECK (gp_port_usb_msg_read (camera->port, 0x28, 0x0000, CHECK (gp_port_usb_msg_read (camera->port, 0x28, 0x0000, i, &buf[i], 0x01));
i, &buf[i], 0x01)); }
} gp_log(GP_LOG_DEBUG, "enigma13","Camera storage information sdram: 0x%x flash 0x%x card: 0x%x\n"
gp_log(GP_LOG_DEBUG, "enigma13","Camera storage information sdram: 0x%x flash 0x%x card: 0x%x\n" , buf[0], buf[1], buf[2]);
, buf[0], buf[1], buf[2]); return GP_OK;
return GP_OK;
} }
#endif #endif
@@ -106,11 +105,11 @@ static int
enigma13_flash_delete_all(CameraFilesystem *fs, const char *folder, void *data, enigma13_flash_delete_all(CameraFilesystem *fs, const char *folder, void *data,
GPContext *context) GPContext *context)
{ {
Camera *cam; Camera *cam;
gp_log(GP_LOG_DEBUG, "enigma13","Delete all files"); gp_log(GP_LOG_DEBUG, "enigma13", "Delete all files");
cam = data; cam = data;
CHECK (gp_port_usb_msg_write (cam->port, 0x52, 0x0, 0x0, NULL, 0x0) ); CHECK (gp_port_usb_msg_write (cam->port, 0x52, 0x0, 0x0, NULL, 0x0));
return GP_OK; return GP_OK;
} }
@@ -124,17 +123,15 @@ enigma13_flash_delete_all(CameraFilesystem *fs, const char *folder, void *data,
*/ */
static int enigma13_wait_for_ready(Camera *camera) static int enigma13_wait_for_ready(Camera *camera)
{ {
int timeout = ENIGMA13_WAIT_FOR_READY_TIMEOUT_S; int timeout = ENIGMA13_WAIT_FOR_READY_TIMEOUT_S;
char ready = 1; char ready = 1;
while (timeout--) { while (timeout--) {
sleep(1); sleep(1);
CHECK (gp_port_usb_msg_read (camera->port, CHECK (gp_port_usb_msg_read (camera->port, 0x21, 0x0000, 0x0000, (char*)&ready, 0x01));
0x21, 0x0000, 0x0000, if (ready==0)
(char*)&ready, 0x01)); return GP_OK;
if (ready==0) }
return GP_OK; return GP_ERROR;
}
return GP_ERROR;
} }
@@ -148,14 +145,12 @@ static int enigma13_wait_for_ready(Camera *camera)
*/ */
static int enigma13_get_filecount (Camera *camera, int *filecount) static int enigma13_get_filecount (Camera *camera, int *filecount)
{ {
uint16_t response = 0; uint16_t response = 0;
CHECK(enigma13_wait_for_ready(camera)); CHECK(enigma13_wait_for_ready(camera));
CHECK (gp_port_usb_msg_read (camera->port, CHECK (gp_port_usb_msg_read (camera->port, 0x54, 0x0000, 0x0000, (char*)&response, 0x02));
0x54, 0x0000, 0x0000, le16toh (response);
(char*)&response, 0x02)); *filecount = response;
le16toh (response); return GP_OK;
*filecount = response;
return GP_OK;
} }
#endif #endif
@@ -169,52 +164,44 @@ static int enigma13_get_filecount (Camera *camera, int *filecount)
*/ */
static int enigma13_get_toc(Camera *camera, int *filecount, char** toc) static int enigma13_get_toc(Camera *camera, int *filecount, char** toc)
{ {
char* flash_toc=NULL; char* flash_toc=NULL;
int toc_size = 0; int toc_size = 0;
char buf[10]; char buf[10];
uint16_t response = 0; uint16_t response = 0;
int ret=1; int ret=1;
CHECK(enigma13_wait_for_ready(camera)); CHECK(enigma13_wait_for_ready(camera));
CHECK (gp_port_usb_msg_read (camera->port, CHECK (gp_port_usb_msg_read (camera->port, 0x54, 0x0000, 0x0000, (char*)&response, 0x02));
0x54, 0x0000, 0x0000, le16toh (response);
(char*)&response, 0x02)); *filecount = response;
le16toh (response);
*filecount = response;
/* Calc toc size */ /* Calc toc size */
toc_size = (response) * 0x20; toc_size = (response) * 0x20;
if (toc_size % 0x200 != 0) if (toc_size % 0x200 != 0)
toc_size = ((toc_size / 0x200) + 1) * 0x200; toc_size = ((toc_size / 0x200) + 1) * 0x200;
CHECK(enigma13_wait_for_ready(camera)); CHECK(enigma13_wait_for_ready(camera));
CHECK (gp_port_usb_msg_write (camera->port, 0x54, CHECK (gp_port_usb_msg_write (camera->port, 0x54, response, 0x0001, NULL, 0x0000));
response, 0x0001, /* Wait until cam is ready to send the T.O.C */
NULL, 0x0000));
/* Wait until cam is ready to send the T.O.C */
usleep(ENIGMA13_WAIT_TOC_DELAY_MS * 1000); usleep(ENIGMA13_WAIT_TOC_DELAY_MS * 1000);
CHECK (gp_port_usb_msg_read (camera->port, 0x21, CHECK (gp_port_usb_msg_read (camera->port, 0x21, 0x0000, 0x0000, buf, 0x01));
0x0000, 0x0000, if (buf[0]!=0x41) return GP_ERROR;
buf, 0x01));
if (buf[0]!=0x41) return GP_ERROR;
CHECK (gp_port_usb_msg_read (camera->port, 0x21, CHECK (gp_port_usb_msg_read (camera->port, 0x21, 0x0000, 0x0002, buf, 0x01));
0x0000, 0x0002, if (buf[0]!=0x01) return GP_ERROR;
buf, 0x01));
if (buf[0]!=0x01) return GP_ERROR;
flash_toc = (char*)malloc(toc_size); flash_toc = (char*)malloc(toc_size);
if (!flash_toc) if (!flash_toc)
return GP_ERROR_NO_MEMORY; return GP_ERROR_NO_MEMORY;
ret=gp_port_read (camera->port, flash_toc, toc_size); ret=gp_port_read (camera->port, flash_toc, toc_size);
*toc= flash_toc; *toc= flash_toc;
gp_log(GP_LOG_DEBUG, "enigma13","Byte transferred :%d ", ret); gp_log(GP_LOG_DEBUG, "enigma13","Byte transferred :%d ", ret);
return ret; return ret;
} }
@@ -313,12 +300,12 @@ static int file_list_func (CameraFilesystem *fs, const char *folder, CameraList
{ {
Camera *camera = data; Camera *camera = data;
int i, numpics; int i, numpics;
char tmp[20]; char tmp[20];
CHECK(enigma13_get_toc(camera,&numpics,&enigma13_static_toc)); CHECK(enigma13_get_toc(camera,&numpics,&enigma13_static_toc));
for ( i=0; i < numpics; i=i+2 ) { for ( i=0; i < numpics; i=i+2 ) {
sprintf(tmp,"sunp%04d.jpg",(i/2)); sprintf(tmp,"sunp%04d.jpg",(i/2));
gp_list_append( list, tmp, NULL); gp_list_append( list, tmp, NULL);
} }
return (GP_OK); return (GP_OK);
@@ -337,30 +324,30 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
Camera *camera = data; Camera *camera = data;
int image_no, result; int image_no, result;
char* img_data=NULL; char* img_data=NULL;
int img_size=-1; int img_size=-1;
image_no = gp_filesystem_number(fs, folder, filename, context); image_no = gp_filesystem_number(fs, folder, filename, context);
gp_log(GP_LOG_DEBUG, "enigma13","Index of image %d is %s",image_no, filename); gp_log(GP_LOG_DEBUG, "enigma13","Index of image %d is %s",image_no, filename);
switch (type) { switch (type) {
case GP_FILE_TYPE_NORMAL: case GP_FILE_TYPE_NORMAL:
{ {
gp_log(GP_LOG_DEBUG, "enigma13","Downloading raw image"); gp_log(GP_LOG_DEBUG, "enigma13","Downloading raw image");
CHECK(enigma13_download_img(camera, enigma13_static_toc, image_no, &img_data, &img_size)); CHECK(enigma13_download_img(camera, enigma13_static_toc, image_no, &img_data, &img_size));
result = gp_file_append( file, img_data, img_size); result = gp_file_append( file, img_data, img_size);
break; break;
} }
default: default:
result = GP_ERROR_NOT_SUPPORTED; result = GP_ERROR_NOT_SUPPORTED;
break; break;
} }
if (result < 0) if (result < 0)
return result; return result;
return (GP_OK); return (GP_OK);
} }
int int
@@ -400,16 +387,16 @@ camera_init (Camera *camera, GPContext *context)
{ {
GPPortSettings settings; GPPortSettings settings;
camera->functions->about = enigma13_about; camera->functions->about = enigma13_about;
CHECK(gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera)); CHECK(gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera));
CHECK(gp_port_get_settings( camera->port, &settings)); CHECK(gp_port_get_settings( camera->port, &settings));
settings.usb.inep = 0x82; settings.usb.inep = 0x82;
settings.usb.outep = 0x03; settings.usb.outep = 0x03;
settings.usb.config = 1; settings.usb.config = 1;
settings.usb.interface = 0; settings.usb.interface = 0;
settings.usb.altsetting = 0; settings.usb.altsetting = 0;
CHECK(gp_port_set_timeout (camera->port, ENIGMA13_USB_TIMEOUT_MS)); CHECK(gp_port_set_timeout (camera->port, ENIGMA13_USB_TIMEOUT_MS));
CHECK(gp_port_set_settings( camera->port, settings)); CHECK(gp_port_set_settings( camera->port, settings));
return GP_OK; return GP_OK;

View File

@@ -121,38 +121,38 @@ static int
fuji_send (Camera *camera, unsigned char *cmd, unsigned int cmd_len, fuji_send (Camera *camera, unsigned char *cmd, unsigned int cmd_len,
unsigned char last, GPContext *context) unsigned char last, GPContext *context)
{ {
unsigned char b[1024], check; unsigned char b[1024], check;
unsigned int i; unsigned int i;
/* Send header */ /* Send header */
b[0] = ESC; b[0] = ESC;
b[1] = STX; b[1] = STX;
CR (gp_port_write (camera->port, (char *)b, 2)); CR (gp_port_write (camera->port, (char *)b, 2));
/* /*
* Escape the data we are going to send. * Escape the data we are going to send.
* Calculate the checksum. * Calculate the checksum.
*/ */
check = (last ? ETX : ETB); check = (last ? ETX : ETB);
memcpy (b, cmd, cmd_len); memcpy (b, cmd, cmd_len);
for (i = 0; i < cmd_len; i++) { for (i = 0; i < cmd_len; i++) {
check ^= b[i]; check ^= b[i];
if (b[i] == ESC) { if (b[i] == ESC) {
memmove (b + i + 1, b + i, cmd_len - i); memmove (b + i + 1, b + i, cmd_len - i);
b[i] = ESC; b[i] = ESC;
i++; i++;
cmd_len++; cmd_len++;
} }
} }
/* Send data */ /* Send data */
CR (gp_port_write (camera->port, (char *)b, cmd_len)); CR (gp_port_write (camera->port, (char *)b, cmd_len));
/* Send footer */ /* Send footer */
b[0] = ESC; b[0] = ESC;
b[1] = (last ? ETX : ETB); b[1] = (last ? ETX : ETB);
b[2] = check; b[2] = check;
CR (gp_port_write (camera->port, (char *)b, 3)); CR (gp_port_write (camera->port, (char *)b, 3));
return (GP_OK); return (GP_OK);
} }
@@ -300,8 +300,7 @@ fuji_transmit (Camera *camera, unsigned char *cmd, unsigned int cmd_len,
*/ */
p = ((*buf_len > 1024) ? 1 : 0); p = ((*buf_len > 1024) ? 1 : 0);
if (p) if (p)
id = gp_context_progress_start (context, *buf_len, id = gp_context_progress_start (context, *buf_len, _("Downloading..."));
_("Downloading..."));
*buf_len = 0; *buf_len = 0;
retries = 0; retries = 0;
while (!last) { while (!last) {
@@ -310,7 +309,7 @@ fuji_transmit (Camera *camera, unsigned char *cmd, unsigned int cmd_len,
retries++; retries++;
while (gp_port_read (camera->port, (char *)&c, 1) >= 0); while (gp_port_read (camera->port, (char *)&c, 1) >= 0);
if (++retries > 2) if (++retries > 2)
return (r); return (r);
GP_DEBUG ("Retrying..."); GP_DEBUG ("Retrying...");
c = NAK; c = NAK;
CR (gp_port_write (camera->port, (char *)&c, 1)); CR (gp_port_write (camera->port, (char *)&c, 1));
@@ -842,22 +841,22 @@ fuji_get_cmds (Camera *camera, unsigned char *cmds, GPContext *context)
static int get_picture_info(int num,char *name,CameraPrivateLibrary *camdata){ static int get_picture_info(int num,char *name,CameraPrivateLibrary *camdata){
DBG("Getting name..."); DBG("Getting name...");
strncpy(name,fuji_picture_name(num),100); strncpy(name, fuji_picture_name(num), 100);
DBG2("%s\n",name); DBG2("%s\n", name);
/* /*
* To find the picture number, go to the first digit. According to * To find the picture number, go to the first digit. According to
* recent Exif specs, n_off can be either 3 or 4. * recent Exif specs, n_off can be either 3 or 4.
*/ */
if (camdata->has_cmd[FUJI_SIZE]) fuji_size=fuji_picture_size(num); if (camdata->has_cmd[FUJI_SIZE]) fuji_size=fuji_picture_size(num);
else { else {
fuji_size=70000; /* this is an overestimation for DS7 */ fuji_size=70000; /* this is an overestimation for DS7 */
DBG2("Image size not obtained, guessing %d",fuji_size); DBG2("Image size not obtained, guessing %d", fuji_size);
}; };
return (fuji_size); return (fuji_size);
}; };
static void get_picture_list (FujiData *fjd) static void get_picture_list (FujiData *fjd)
@@ -875,10 +874,10 @@ static void get_picture_list (FujiData *fjd)
}; };
for (i = 1; i <= pictures; i++) { for (i = 1; i <= pictures; i++) {
DBG("Getting name..."); DBG("Getting name...");
name = strdup(fuji_picture_name(i)); name = strdup(fuji_picture_name(i));
pinfo[i].name = name; pinfo[i].name = name;
DBG2("%s\n",name); DBG2("%s\n",name);
@@ -905,7 +904,7 @@ static int download_picture(int n,int thumb,CameraFile *file,CameraPrivateLibrar
DBG3("download_picture: %d,%s",n,thumb?"thumb":"pic"); DBG3("download_picture: %d,%s",n,thumb?"thumb":"pic");
if (!thumb) { if (!thumb) {
fuji_size=get_picture_info(n,name,fjd); fuji_size=get_picture_info(n,name,fjd);
DBG3("Info %3d %12s ", n, name); DBG3("Info %3d %12s ", n, name);
} }
else fuji_size=10500; /* Probably not same for all cams, better way ? */ else fuji_size=10500; /* Probably not same for all cams, better way ? */

View File

@@ -28,7 +28,7 @@ enum _FujiCmd {
FUJI_CMD_PIC_GET = 0x02, FUJI_CMD_PIC_GET = 0x02,
FUJI_CMD_PIC_GET_THUMB = 0x00, FUJI_CMD_PIC_GET_THUMB = 0x00,
FUJI_CMD_SPEED = 0x07, FUJI_CMD_SPEED = 0x07,
FUJI_CMD_VERSION = 0x09, FUJI_CMD_VERSION = 0x09,
FUJI_CMD_PIC_NAME = 0x0a, FUJI_CMD_PIC_NAME = 0x0a,
FUJI_CMD_PIC_COUNT = 0x0b, FUJI_CMD_PIC_COUNT = 0x0b,
@@ -40,30 +40,30 @@ enum _FujiCmd {
FUJI_CMD_UNKNOWN4 = 0x11, /* Figure this out! */ FUJI_CMD_UNKNOWN4 = 0x11, /* Figure this out! */
FUJI_CMD_UNKNOWN5 = 0x13, /* Figure this out! */ FUJI_CMD_UNKNOWN5 = 0x13, /* Figure this out! */
FUJI_CMD_PIC_SIZE = 0x17, FUJI_CMD_PIC_SIZE = 0x17,
FUJI_CMD_PIC_DEL = 0x19, FUJI_CMD_PIC_DEL = 0x19,
FUJI_CMD_AVAIL_MEM = 0x1b, FUJI_CMD_AVAIL_MEM = 0x1b,
FUJI_CMD_UNKNOWN10 = 0x20, /* Figure this out! */ FUJI_CMD_UNKNOWN10 = 0x20, /* Figure this out! */
FUJI_CMD_UNKNOWN11 = 0x22, /* Figure this out! */ FUJI_CMD_UNKNOWN11 = 0x22, /* Figure this out! */
FUJI_CMD_TAKE = 0x27, FUJI_CMD_TAKE = 0x27,
FUJI_CMD_MODEL = 0x29, FUJI_CMD_MODEL = 0x29,
FUJI_CMD_UNKNOWN13 = 0x2a, /* Figure this out! */ FUJI_CMD_UNKNOWN13 = 0x2a, /* Figure this out! */
FUJI_CMD_UNKNOWN14 = 0x2b, /* Figure this out! */ FUJI_CMD_UNKNOWN14 = 0x2b, /* Figure this out! */
FUJI_CMD_UNKNOWN15 = 0x2e, /* Figure this out! */ FUJI_CMD_UNKNOWN15 = 0x2e, /* Figure this out! */
/* Flash related commands */ /* Flash related commands */
FUJI_CMD_FLASH_GET = 0x30, FUJI_CMD_FLASH_GET = 0x30,
FUJI_CMD_FLASH_SET = 0x32, FUJI_CMD_FLASH_SET = 0x32,
FUJI_CMD_FLASH_CHARGE = 0x34, FUJI_CMD_FLASH_CHARGE = 0x34,
FUJI_CMD_CMDS_VALID = 0x4c, FUJI_CMD_CMDS_VALID = 0x4c,
FUJI_CMD_UNKNOWN16 = 0x51, /* Figure this out! */ FUJI_CMD_UNKNOWN16 = 0x51, /* Figure this out! */
FUJI_CMD_PREVIEW = 0x64, FUJI_CMD_PREVIEW = 0x64,
/* Configurable settings */ /* Configurable settings */
FUJI_CMD_ID_GET = 0x80, FUJI_CMD_ID_GET = 0x80,

View File

@@ -67,25 +67,25 @@ struct _CameraPrivateLibrary {
}; };
static const struct { static const struct {
FujiCmd command; FujiCmd command;
const char *name; const char *name;
} Commands[] = { } Commands[] = {
{FUJI_CMD_PIC_GET, "get picture"}, {FUJI_CMD_PIC_GET, "get picture"},
{FUJI_CMD_PIC_GET_THUMB, "get thumbnail"}, {FUJI_CMD_PIC_GET_THUMB, "get thumbnail"},
{FUJI_CMD_SPEED, "change speed"}, {FUJI_CMD_SPEED, "change speed"},
{FUJI_CMD_VERSION, "get version"}, {FUJI_CMD_VERSION, "get version"},
{FUJI_CMD_PIC_NAME, "get name of picture"}, {FUJI_CMD_PIC_NAME, "get name of picture"},
{FUJI_CMD_PIC_COUNT, "get number of pictures"}, {FUJI_CMD_PIC_COUNT, "get number of pictures"},
{FUJI_CMD_PIC_SIZE, "get size of picture"}, {FUJI_CMD_PIC_SIZE, "get size of picture"},
{FUJI_CMD_PIC_DEL, "delete picture"}, {FUJI_CMD_PIC_DEL, "delete picture"},
{FUJI_CMD_TAKE, "capture picture"}, {FUJI_CMD_TAKE, "capture picture"},
{FUJI_CMD_FLASH_GET, "get flash mode"}, {FUJI_CMD_FLASH_GET, "get flash mode"},
{FUJI_CMD_FLASH_SET, "set flash mode"}, {FUJI_CMD_FLASH_SET, "set flash mode"},
{FUJI_CMD_FLASH_CHARGE, "charge flash"}, {FUJI_CMD_FLASH_CHARGE, "charge flash"},
{FUJI_CMD_CMDS_VALID, "list valid commands"}, {FUJI_CMD_CMDS_VALID, "list valid commands"},
{FUJI_CMD_PREVIEW, "capture preview"}, {FUJI_CMD_PREVIEW, "capture preview"},
{FUJI_CMD_DATE_GET, "get date"}, {FUJI_CMD_DATE_GET, "get date"},
{0, NULL}}; {0, NULL} };
static const char * static const char *
cmd_get_name (FujiCmd command) cmd_get_name (FujiCmd command)
@@ -384,10 +384,9 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
const char *id; const char *id;
/* Date & Time */ /* Date & Time */
if ((gp_widget_get_child_by_label (window, _("Date & Time"), if ((gp_widget_get_child_by_label (window, _("Date & Time"), &widget) >= 0) &&
&widget) >= 0) && gp_widget_changed (widget)) {
gp_widget_changed (widget)) { gp_widget_set_changed (widget, 0);
gp_widget_set_changed (widget, 0);
CR (gp_widget_get_value (widget, &t)); CR (gp_widget_get_value (widget, &t));
tm = localtime (&t); tm = localtime (&t);
date.year = tm->tm_year; date.year = tm->tm_year;
@@ -402,7 +401,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
/* ID */ /* ID */
if ((gp_widget_get_child_by_label (window, _("ID"), &widget) >= 0) && if ((gp_widget_get_child_by_label (window, _("ID"), &widget) >= 0) &&
gp_widget_changed (widget)) { gp_widget_changed (widget)) {
gp_widget_set_changed (widget, 0); gp_widget_set_changed (widget, 0);
CR (gp_widget_get_value (widget, &id)); CR (gp_widget_get_value (widget, &id));
CR (fuji_id_set (camera, id, context)); CR (fuji_id_set (camera, id, context));
} }

View File

@@ -161,8 +161,7 @@ gsmart300_request_file (CameraPrivateLibrary * lib, CameraFile *file,
if (!mybuf) if (!mybuf)
return GP_ERROR_NO_MEMORY; return GP_ERROR_NO_MEMORY;
ret = gsmart300_download_data (lib, __GS300_PIC, g_file->index, ret = gsmart300_download_data (lib, __GS300_PIC, g_file->index, flash_size, mybuf);
flash_size, mybuf);
if (ret < GP_OK) { if (ret < GP_OK) {
free (mybuf); free (mybuf);
return ret; return ret;
@@ -258,8 +257,7 @@ gsmart300_get_image_thumbnail (CameraPrivateLibrary * lib, CameraFile *file,
mybuf = malloc (size); mybuf = malloc (size);
if (!mybuf) if (!mybuf)
return (GP_ERROR_NO_MEMORY); return (GP_ERROR_NO_MEMORY);
ret = gsmart300_download_data (lib, __GS300_THUMB, g_file->index, ret = gsmart300_download_data (lib, __GS300_THUMB, g_file->index, size, mybuf);
size, mybuf);
if (ret < GP_OK) { if (ret < GP_OK) {
free (mybuf); free (mybuf);
return ret; return ret;
@@ -393,14 +391,12 @@ gsmart300_get_FATs (CameraPrivateLibrary * lib)
p = lib->fats; p = lib->fats;
while (index < lib->num_files) { while (index < lib->num_files) {
CHECK (gsmart300_download_data (lib, __GS300_FAT, index, CHECK (gsmart300_download_data (lib, __GS300_FAT, index, FLASH_PAGE_SIZE_300, p));
FLASH_PAGE_SIZE_300, p));
if (p[0] == 0xFF) if (p[0] == 0xFF)
break; break;
type = p[0]; type = p[0];
if (type == 0x00) { if (type == 0x00) {
lib->files[file_index].mime_type = lib->files[file_index].mime_type = GSMART_FILE_TYPE_IMAGE;
GSMART_FILE_TYPE_IMAGE;
lib->files[file_index].index = index; lib->files[file_index].index = index;
lib->files[file_index].fat = p; lib->files[file_index].fat = p;
lib->files[file_index].width = (p[8] & 0xFF) * 16; lib->files[file_index].width = (p[8] & 0xFF) * 16;

View File

@@ -260,15 +260,14 @@ get_file_func (CameraFilesystem *fs, const char *folder,
Camera *camera = user_data; Camera *camera = user_data;
int number, filetype; int number, filetype;
CHECK (number = gp_filesystem_number (camera->fs, folder, filename, CHECK (number = gp_filesystem_number (camera->fs, folder, filename, context));
context));
switch (type) { switch (type) {
case GP_FILE_TYPE_NORMAL: case GP_FILE_TYPE_NORMAL:
CHECK (gsmart300_request_file (camera->pl, file, number)); CHECK (gsmart300_request_file (camera->pl, file, number));
break; break;
case GP_FILE_TYPE_PREVIEW: case GP_FILE_TYPE_PREVIEW:
CHECK (gsmart300_request_thumbnail CHECK (gsmart300_request_thumbnail
(camera->pl, file, number, &filetype)); (camera->pl, file, number, &filetype));
if (filetype == GSMART_FILE_TYPE_IMAGE) { if (filetype == GSMART_FILE_TYPE_IMAGE) {
CHECK (gp_file_set_mime_type (file, GP_MIME_BMP)); CHECK (gp_file_set_mime_type (file, GP_MIME_BMP));
} }
@@ -289,8 +288,7 @@ get_info_func (CameraFilesystem *fs, const char *folder,
struct GsmartFile *file; struct GsmartFile *file;
/* Get the file number from the CameraFileSystem */ /* Get the file number from the CameraFileSystem */
CHECK (n = gp_filesystem_number (camera->fs, folder, filename, CHECK (n = gp_filesystem_number (camera->fs, folder, filename, context));
context));
CHECK (gsmart300_get_file_info (camera->pl, n, &file)); CHECK (gsmart300_get_file_info (camera->pl, n, &file));
@@ -321,17 +319,16 @@ delete_file_func (CameraFilesystem *fs, const char *folder,
int n, c; int n, c;
/* Get the file number from the CameraFileSystem */ /* Get the file number from the CameraFileSystem */
CHECK (n = gp_filesystem_number (camera->fs, folder, filename, CHECK (n = gp_filesystem_number (camera->fs, folder, filename, context));
context));
CHECK (c = gp_filesystem_count (camera->fs, folder, context)); CHECK (c = gp_filesystem_count (camera->fs, folder, context));
if (n + 1 != c) { if (n + 1 != c) {
const char *name; const char *name;
gp_filesystem_name (fs, "/", c - 1, &name, context); gp_filesystem_name (fs, "/", c - 1, &name, context);
gp_context_error (context, gp_context_error (context,
_("Your camera only supports deleting " _("Your camera only supports deleting "
"the last file on the camera. In this " "the last file on the camera. In this "
"case, this is file '%s'."), name); "case, this is file '%s'."), name);
return (GP_ERROR); return (GP_ERROR);
} }
CHECK (gsmart300_delete_file (camera->pl, n)); CHECK (gsmart300_delete_file (camera->pl, n));

View File

@@ -54,59 +54,58 @@
#define GP_MODULE "iclick" #define GP_MODULE "iclick"
static struct { static struct {
char *name; char *name;
CameraDriverStatus status; CameraDriverStatus status;
unsigned short idVendor; unsigned short idVendor;
unsigned short idProduct; unsigned short idProduct;
} models[] = { } models[] = {
{"iClick 5X", GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770, 0x9153}, {"iClick 5X", GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770, 0x9153},
{NULL,0,0,0} {NULL,0,0,0}
}; };
int int
camera_id (CameraText *id) camera_id (CameraText *id)
{ {
strcpy (id->text, "iClick 5X"); strcpy (id->text, "iClick 5X");
return GP_OK; return GP_OK;
} }
int int
camera_abilities (CameraAbilitiesList *list) camera_abilities (CameraAbilitiesList *list)
{ {
int i; int i;
CameraAbilities a; CameraAbilities a;
for (i = 0; models[i].name; i++) { for (i = 0; models[i].name; i++) {
memset (&a, 0, sizeof(a)); memset (&a, 0, sizeof(a));
strcpy (a.model, models[i].name); strcpy (a.model, models[i].name);
a.status = models[i].status; a.status = models[i].status;
a.port = GP_PORT_USB; a.port = GP_PORT_USB;
a.speed[0] = 0; a.speed[0] = 0;
a.usb_vendor = models[i].idVendor; a.usb_vendor = models[i].idVendor;
a.usb_product= models[i].idProduct; a.usb_product= models[i].idProduct;
if (a.status == GP_DRIVER_STATUS_EXPERIMENTAL) if (a.status == GP_DRIVER_STATUS_EXPERIMENTAL)
a.operations = GP_OPERATION_NONE; a.operations = GP_OPERATION_NONE;
else else
a.operations = GP_OPERATION_CAPTURE_PREVIEW; a.operations = GP_OPERATION_CAPTURE_PREVIEW;
a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL; a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL;
a.file_operations = GP_FILE_OPERATION_PREVIEW + GP_FILE_OPERATION_RAW; a.file_operations = GP_FILE_OPERATION_PREVIEW + GP_FILE_OPERATION_RAW;
gp_abilities_list_append (list, a); gp_abilities_list_append (list, a);
} }
return GP_OK; return GP_OK;
} }
static int static int
camera_summary (Camera *camera, CameraText *summary, GPContext *context) camera_summary (Camera *camera, CameraText *summary, GPContext *context)
{ {
sprintf (summary->text,_("Your USB camera is an iClick 5X.\n" sprintf (summary->text, _("Your USB camera is an iClick 5X.\n"
"The total number of pictures taken is %i\n"), "The total number of pictures taken is %i\n"),
camera->pl->nb_entries);
camera->pl->nb_entries); return GP_OK;
return GP_OK;
} }
static int camera_manual (Camera *camera, CameraText *manual, GPContext *context) static int camera_manual (Camera *camera, CameraText *manual, GPContext *context)
@@ -131,10 +130,10 @@ static int camera_manual (Camera *camera, CameraText *manual, GPContext *context
static int static int
camera_about (Camera *camera, CameraText *about, GPContext *context) camera_about (Camera *camera, CameraText *about, GPContext *context)
{ {
strcpy (about->text, _("iClick 5X driver\n" strcpy (about->text, _("iClick 5X driver\n"
"Theodore Kilgore <kilgota@auburn.edu>\n")); "Theodore Kilgore <kilgota@auburn.edu>\n"));
return GP_OK; return GP_OK;
} }
/*************** File and Downloading Functions *******************/ /*************** File and Downloading Functions *******************/
@@ -144,7 +143,7 @@ static int
file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
void *data, GPContext *context) void *data, GPContext *context)
{ {
Camera *camera = data; Camera *camera = data;
int i; int i;
unsigned char buf[1024]; unsigned char buf[1024];
GP_DEBUG ("List files in %s\n", folder); GP_DEBUG ("List files in %s\n", folder);
@@ -166,7 +165,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
CameraFileType type, CameraFile *file, void *user_data, CameraFileType type, CameraFile *file, void *user_data,
GPContext *context) GPContext *context)
{ {
Camera *camera = user_data; Camera *camera = user_data;
int entry, w, h; /* frame; */ int entry, w, h; /* frame; */
unsigned char *frame_data, *frame_ptr; unsigned char *frame_data, *frame_ptr;
unsigned char *ppm, *ptr; unsigned char *ppm, *ptr;
@@ -259,7 +258,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
case GP_FILE_TYPE_RAW: case GP_FILE_TYPE_RAW:
gp_file_set_mime_type (file, GP_MIME_RAW); gp_file_set_mime_type (file, GP_MIME_RAW);
gp_file_adjust_name_for_mime_type (file); gp_file_adjust_name_for_mime_type (file);
gp_file_set_data_and_size (file, (char *)frame_data, datasize); gp_file_set_data_and_size (file, (char *)frame_data, datasize);
return (GP_OK); return (GP_OK);
default: default:
return GP_ERROR_NOT_SUPPORTED; return GP_ERROR_NOT_SUPPORTED;
@@ -297,7 +296,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
gp_file_set_mime_type (file, GP_MIME_PPM); gp_file_set_mime_type (file, GP_MIME_PPM);
gp_file_set_data_and_size (file, (char *)ppm, ppmsize); gp_file_set_data_and_size (file, (char *)ppm, ppmsize);
free (frame_data); free (frame_data);
return GP_OK; return GP_OK;
} }
@@ -333,10 +332,10 @@ camera_init(Camera *camera, GPContext *context)
int ret = 0; int ret = 0;
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->summary = camera_summary; camera->functions->summary = camera_summary;
camera->functions->manual = camera_manual; camera->functions->manual = camera_manual;
camera->functions->about = camera_about; camera->functions->about = camera_about;
camera->functions->exit = camera_exit; camera->functions->exit = camera_exit;
GP_DEBUG ("Initializing the camera\n"); GP_DEBUG ("Initializing the camera\n");
@@ -346,7 +345,7 @@ camera_init(Camera *camera, GPContext *context)
ret = gp_port_set_settings(camera->port,settings); ret = gp_port_set_settings(camera->port,settings);
if (ret < 0) return ret; if (ret < 0) return ret;
/* Tell the CameraFilesystem where to get lists from */ /* Tell the CameraFilesystem where to get lists from */
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
camera->pl = malloc (sizeof (CameraPrivateLibrary)); camera->pl = malloc (sizeof (CameraPrivateLibrary));

View File

@@ -273,25 +273,25 @@ static CameraFilesystemFuncs fsfuncs = {
int camera_init (Camera *camera, GPContext *context) int camera_init (Camera *camera, GPContext *context)
{ {
gp_port_settings settings; gp_port_settings settings;
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->manual = camera_manual; camera->functions->manual = camera_manual;
camera->functions->about = camera_about; camera->functions->about = camera_about;
camera->functions->get_config = camera_config_get; camera->functions->get_config = camera_config_get;
camera->functions->set_config = camera_config_set; camera->functions->set_config = camera_config_set;
/* Configure port */ /* Configure port */
gp_port_set_timeout(camera->port, 1000); gp_port_set_timeout(camera->port, 1000);
gp_port_get_settings(camera->port, &settings); gp_port_get_settings(camera->port, &settings);
settings.serial.speed = 115200; settings.serial.speed = 115200;
settings.serial.bits = 8; settings.serial.bits = 8;
settings.serial.parity = 0; settings.serial.parity = 0;
settings.serial.stopbits= 1; settings.serial.stopbits= 1;
gp_port_set_settings(camera->port, settings); gp_port_set_settings(camera->port, settings);
/* Set up the filesystem */ /* Set up the filesystem */
gp_filesystem_set_funcs(camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs(camera->fs, &fsfuncs, camera);
/* test camera */ /* test camera */
return jd11_ping(camera->port); return jd11_ping(camera->port);
} }

View File

@@ -41,42 +41,42 @@
#if 0 #if 0
static int static int
dread(GPPort *port, caddr_t buf, int xsize) { dread(GPPort *port, caddr_t buf, int xsize) {
int i; int i;
int ret = gp_port_read(port,buf,xsize); int ret = gp_port_read(port, buf, xsize);
if (ret == -1) { if (ret == -1) {
perror("dread"); perror("dread");
return -1; return -1;
} }
fprintf(stderr,"dread[%d]:",ret); fprintf(stderr, "dread[%d]:", ret);
for (i=0;i<ret;i++) fprintf(stderr,"%02x,",buf[i]); for (i=0;i<ret;i++) fprintf(stderr, "%02x,", buf[i]);
fprintf(stderr,"\n"); fprintf(stderr, "\n");
return ret; return ret;
} }
static int static int
dwrite(GPPort*port, caddr_t buf, int xsize) { dwrite(GPPort*port, caddr_t buf, int xsize) {
int i; int i;
int ret = gp_port_write(port,buf,xsize); int ret = gp_port_write(port, buf, xsize);
if (ret < GP_OK) { if (ret < GP_OK) {
perror("dwrite"); perror("dwrite");
return -1; return -1;
} }
fprintf(stderr,"dwrite[%d/%d]:",xsize,ret); fprintf(stderr, "dwrite[%d/%d]:", xsize, ret);
for (i=0;i<xsize;i++) fprintf(stderr,"%02x,",buf[i]); for (i=0;i<xsize;i++) fprintf(stderr, "%02x,", buf[i]);
fprintf(stderr,"\n"); fprintf(stderr, "\n");
return ret; return ret;
} }
#endif #endif
#define READ(port,buf,len) gp_port_read(port,(char*)(buf),len) #define READ(port,buf,len) gp_port_read(port,(char*)(buf),len)
#define WRITE(port,buf,len) gp_port_write(port,(char*)(buf),len) #define WRITE(port,buf,len) gp_port_write(port,(char*)(buf),len)
static int _send_cmd(GPPort *port,unsigned short cmd) { static int _send_cmd(GPPort *port, unsigned short cmd) {
unsigned char buf[2]; unsigned char buf[2];
buf[0] = cmd>>8; buf[0] = cmd>>8;
buf[1] = cmd&0xff; buf[1] = cmd&0xff;
return WRITE(port,buf,2); return WRITE(port, buf, 2);
} }
static int _read_cmd(GPPort *port,unsigned short *xcmd) { static int _read_cmd(GPPort *port,unsigned short *xcmd) {
@@ -109,29 +109,29 @@ static void _dump_buf(unsigned char *buf,int size) {
#endif #endif
static int _send_cmd_2(GPPort *port,unsigned short cmd, unsigned short *xcmd) { static int _send_cmd_2(GPPort *port, unsigned short cmd, unsigned short *xcmd) {
unsigned char buf[2]; unsigned char buf[2];
int ret, tries = 3; int ret, tries = 3;
*xcmd = 0x4242; *xcmd = 0x4242;
while (tries--) { while (tries--) {
int i = 0; int i = 0;
buf[0] = cmd>>8; buf[0] = cmd>>8;
buf[1] = cmd&0xff; buf[1] = cmd&0xff;
ret = WRITE(port,buf,2); ret = WRITE(port, buf, 2);
do { do {
if (1==(ret=READ(port,buf,1))) { if (1==(ret=READ(port, buf, 1))) {
if (buf[0]==0xff) { if (buf[0]==0xff) {
if (1==READ(port,buf+1,1)) { if (1==READ(port, buf+1, 1)) {
*xcmd = (buf[0] << 8)| buf[1]; *xcmd = (buf[0] << 8)| buf[1];
return GP_OK; return GP_OK;
} }
}
} else {
return ret;
} }
} else { } while (i++<3);
return ret; }
} return GP_ERROR_IO;
} while (i++<3);
}
return GP_ERROR_IO;
} }
int jd11_ping(GPPort *port) { int jd11_ping(GPPort *port) {
@@ -140,12 +140,12 @@ int jd11_ping(GPPort *port) {
int ret,tries = 3; int ret,tries = 3;
while (tries--) { while (tries--) {
ret = GP_ERROR_IO; ret = GP_ERROR_IO;
while (1==READ(port,buf,1)) while (1==READ(port, buf, 1))
/* drain input queue before PING */; /* drain input queue before PING */;
ret=_send_cmd_2(port,0xff08,&xcmd); ret=_send_cmd_2(port, 0xff08, &xcmd);
if ((ret>=GP_OK) && (xcmd==0xfff1)) if ((ret>=GP_OK) && (xcmd==0xfff1))
return GP_OK; return GP_OK;
} }
return ret; return ret;
} }
@@ -155,18 +155,18 @@ jd11_get_rgb(GPPort *port,float *red, float *green, float *blue) {
char buf[10]; char buf[10];
int ret=GP_OK,tries=0,curread=0; int ret=GP_OK,tries=0,curread=0;
_send_cmd(port,0xffa7); _send_cmd(port, 0xffa7);
while ((curread<10) && (tries++<30)) { while ((curread<10) && (tries++<30)) {
ret=READ(port,buf+curread,sizeof(buf)-curread); ret=READ(port, buf+curread, sizeof(buf)-curread);
if (ret < 0) if (ret < 0)
continue; continue;
if (ret == 0) if (ret == 0)
break; break;
curread+=ret; curread+=ret;
} }
if(curread<10) { if (curread<10) {
fprintf(stderr,"%d returned bytes on float query.\n",ret); fprintf(stderr, "%d returned bytes on float query.\n", ret);
return GP_ERROR_IO; return GP_ERROR_IO;
} }
/*_dump_buf(buf,10);*/ /*_dump_buf(buf,10);*/
*green = buf[1]+buf[2]*0.1+buf[3]*0.01; *green = buf[1]+buf[2]*0.1+buf[3]*0.01;
@@ -201,9 +201,9 @@ jd11_select_index(GPPort *port) { /* select index */
ret = _send_cmd_2(port,0xffa4,&xcmd); ret = _send_cmd_2(port,0xffa4,&xcmd);
if (ret < GP_OK) if (ret < GP_OK)
return ret; return ret;
if (xcmd!=0xff01) if (xcmd!=0xff01)
return GP_ERROR_IO; return GP_ERROR_IO;
return GP_OK; return GP_OK;
} }
@@ -211,11 +211,11 @@ int
jd11_select_image(GPPort *port,int nr) { /* select image <nr> */ jd11_select_image(GPPort *port,int nr) { /* select image <nr> */
unsigned short xcmd; unsigned short xcmd;
_send_cmd(port,0xffa1); _send_cmd(port, 0xffa1);
_send_cmd(port,0xff00|nr); _send_cmd(port, 0xff00|nr);
_read_cmd(port,&xcmd); _read_cmd(port, &xcmd);
if (xcmd != 0xff01) if (xcmd != 0xff01)
return GP_ERROR_IO; return GP_ERROR_IO;
return GP_OK; return GP_OK;
} }
@@ -224,7 +224,7 @@ jd11_set_bulb_exposure(GPPort *port,int i) {
unsigned short xcmd; unsigned short xcmd;
if ((i<1) || (i>9)) if ((i<1) || (i>9))
return GP_ERROR_BAD_PARAMETERS; return GP_ERROR_BAD_PARAMETERS;
_send_cmd(port,0xffa9); _send_cmd(port,0xffa9);
_send_cmd(port,0xff00|i); _send_cmd(port,0xff00|i);
@@ -275,26 +275,26 @@ jd11_imgsize(GPPort *port) {
int ret; int ret;
int i=0,curread=0; int i=0,curread=0;
_send_cmd(port,0xfff0); _send_cmd(port, 0xfff0);
do { do {
ret=READ(port,&buf[curread],10-curread); ret=READ(port, &buf[curread], 10-curread);
if (ret>0) if (ret>0)
curread+=ret; curread+=ret;
usleep(1000); usleep(1000);
} while ((i++<20) && (curread<10)); } while ((i++<20) && (curread<10));
/*_dump_buf(buf,curread);*/ /*_dump_buf(buf,curread);*/
if (!curread) /* We get 0 bytes return for 0 images. */ if (!curread) /* We get 0 bytes return for 0 images. */
return 0; return 0;
ret=strtol(&buf[2],NULL,16); ret=strtol(&buf[2], NULL, 16);
return ret; return ret;
} }
static int static int
getpacket(GPPort *port,unsigned char *buf, int expect) { getpacket(GPPort *port,unsigned char *buf, int expect) {
int curread = 0, csum = 0; int curread = 0, csum = 0;
int tries = 0; int tries = 0;
if (expect == 200) if (expect == 200)
expect++; expect++;
while (tries++<5) { while (tries++<5) {
int i=0,ret; int i=0,ret;
@@ -308,11 +308,11 @@ getpacket(GPPort *port,unsigned char *buf, int expect) {
usleep(100); usleep(100);
} while ((i++<2) && (curread<expect)); } while ((i++<2) && (curread<expect));
if (curread!=expect) { if (curread!=expect) {
if (!curread) if (!curread)
return 0; return 0;
_send_cmd(port,0xfff3); _send_cmd(port, 0xfff3);
curread = csum = 0; curread = csum = 0;
continue; continue;
} }
/*printf("curread is %d\n",curread);*/ /*printf("curread is %d\n",curread);*/
/*printf("PACKET:");_dump_buf(buf,curread);*/ /*printf("PACKET:");_dump_buf(buf,curread);*/
@@ -343,213 +343,212 @@ jd11_erase_all(GPPort *port) {
*/ */
int int
jd11_index_reader(GPPort *port, CameraFilesystem *fs, GPContext *context) { jd11_index_reader(GPPort *port, CameraFilesystem *fs, GPContext *context) {
int i, id, count, xsize, curread=0, ret=0; int i, id, count, xsize, curread=0, ret=0;
unsigned char *indexbuf; unsigned char *indexbuf;
ret = jd11_select_index(port); ret = jd11_select_index(port);
if (ret != GP_OK) if (ret != GP_OK)
return ret; return ret;
xsize = jd11_imgsize(port); xsize = jd11_imgsize(port);
if (!xsize) { /* shortcut, no reading needed */ if (!xsize) { /* shortcut, no reading needed */
return GP_OK;
}
count = xsize/(64*48);
xsize = count * (64*48);
indexbuf = malloc(xsize);
if (!indexbuf) return GP_ERROR_NO_MEMORY;
id = gp_context_progress_start (context, xsize,
_("Downloading thumbnail..."));
_send_cmd(port, 0xfff1);
while (curread < xsize) {
int readsize = xsize-curread;
if (readsize>200) readsize = 200;
ret=getpacket(port, indexbuf+curread, readsize);
if (ret==0)
break;
curread+=ret;
if (ret<200)
break;
gp_context_progress_update (context, id, curread);
if (gp_context_cancel (context) == GP_CONTEXT_FEEDBACK_CANCEL) {
/* What to do...Just free the stuff we allocated for now.*/
free(indexbuf);
return GP_ERROR_CANCEL;
}
_send_cmd(port, 0xfff1);
}
gp_context_progress_stop (context, id);
for (i=0;i<count;i++) {
CameraFile *file;
char fn[20];
unsigned char *src;
unsigned char thumb[64*48];
int y;
CameraFileInfo info;
ret = gp_file_new(&file);
if (ret!=GP_OK) {
free(indexbuf);
return ret;
}
sprintf(fn, "image%02i.pgm", i);
gp_file_set_mime_type(file, GP_MIME_PGM);
gp_file_append(file, THUMBHEADER, strlen(THUMBHEADER));
src = indexbuf+(i*64*48);
for (y=0;y<48;y++) {
int x, off = 64*y;
for (x=0;x<64;x++)
thumb[47*64-off+(63-x)] = src[off+x];
}
ret = gp_file_append(file, (char*)thumb, sizeof(thumb));
if (ret != GP_OK) {
free(indexbuf);
gp_file_free (file);
return ret;
}
ret = gp_filesystem_append(fs, "/", fn, context);
if (ret != GP_OK) {
/* should perhaps remove the entry again */
free(indexbuf);
gp_file_free (file);
return ret;
}
ret = gp_filesystem_set_file_noop(fs, "/", fn, GP_FILE_TYPE_PREVIEW, file, context);
if (ret != GP_OK) {
free(indexbuf);
return ret;
}
memset (&info, 0, sizeof (info));
/* we also get the fs info for free, so just set it */
info.file.fields = GP_FILE_INFO_TYPE |
GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT |
GP_FILE_INFO_SIZE;
strcpy(info.file.type, GP_MIME_PNM);
info.file.width = 640;
info.file.height = 480;
info.file.size = 640*480*3+strlen(IMGHEADER);
info.preview.fields = GP_FILE_INFO_TYPE |
GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT |
GP_FILE_INFO_SIZE;
strcpy(info.preview.type, GP_MIME_PGM);
info.preview.width = 64;
info.preview.height = 48;
info.preview.size = 64*48+strlen(THUMBHEADER);
ret = gp_filesystem_set_info_noop(fs, "/", fn, info, context);
}
free(indexbuf);
return GP_OK; return GP_OK;
}
count = xsize/(64*48);
xsize = count * (64*48);
indexbuf = malloc(xsize);
if (!indexbuf) return GP_ERROR_NO_MEMORY;
id = gp_context_progress_start (context, xsize,
_("Downloading thumbnail..."));
_send_cmd(port,0xfff1);
while (curread < xsize) {
int readsize = xsize-curread;
if (readsize>200) readsize = 200;
ret=getpacket(port,indexbuf+curread,readsize);
if (ret==0)
break;
curread+=ret;
if (ret<200)
break;
gp_context_progress_update (context, id, curread);
if (gp_context_cancel (context) == GP_CONTEXT_FEEDBACK_CANCEL) {
/* What to do...Just free the stuff we allocated for now.*/
free(indexbuf);
return GP_ERROR_CANCEL;
}
_send_cmd(port,0xfff1);
}
gp_context_progress_stop (context, id);
for (i=0;i<count;i++) {
CameraFile *file;
char fn[20];
unsigned char *src;
unsigned char thumb[64*48];
int y;
CameraFileInfo info;
ret = gp_file_new(&file);
if (ret!=GP_OK) {
free(indexbuf);
return ret;
}
sprintf(fn,"image%02i.pgm",i);
gp_file_set_mime_type(file, GP_MIME_PGM);
gp_file_append(file, THUMBHEADER, strlen(THUMBHEADER));
src = indexbuf+(i*64*48);
for (y=0;y<48;y++) {
int x,off = 64*y;
for (x=0;x<64;x++)
thumb[47*64-off+(63-x)] = src[off+x];
}
ret = gp_file_append(file,(char*)thumb,sizeof(thumb));
if (ret != GP_OK) {
free(indexbuf);
gp_file_free (file);
return ret;
}
ret = gp_filesystem_append(fs, "/", fn, context);
if (ret != GP_OK) {
/* should perhaps remove the entry again */
free(indexbuf);
gp_file_free (file);
return ret;
}
ret = gp_filesystem_set_file_noop(fs, "/", fn, GP_FILE_TYPE_PREVIEW, file, context);
if (ret != GP_OK) {
free(indexbuf);
return ret;
}
memset (&info, 0, sizeof (info));
/* we also get the fs info for free, so just set it */
info.file.fields = GP_FILE_INFO_TYPE |
GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT |
GP_FILE_INFO_SIZE;
strcpy(info.file.type,GP_MIME_PNM);
info.file.width = 640;
info.file.height = 480;
info.file.size = 640*480*3+strlen(IMGHEADER);
info.preview.fields = GP_FILE_INFO_TYPE |
GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT |
GP_FILE_INFO_SIZE;
strcpy(info.preview.type,GP_MIME_PGM);
info.preview.width = 64;
info.preview.height = 48;
info.preview.size = 64*48+strlen(THUMBHEADER);
ret = gp_filesystem_set_info_noop(fs, "/", fn, info, context);
}
free(indexbuf);
return GP_OK;
} }
static int static int
serial_image_reader(Camera *camera,CameraFile *file,int nr,unsigned char ***imagebufs,int *sizes, GPContext *context) { serial_image_reader(Camera *camera, CameraFile *file, int nr, unsigned char ***imagebufs, int *sizes, GPContext *context) {
int picnum,curread,ret=0; int picnum, curread, ret=0;
GPPort *port = camera->port; GPPort *port = camera->port;
unsigned int id; unsigned int id;
jd11_select_image(port,nr); jd11_select_image(port, nr);
*imagebufs = (unsigned char**)malloc(3*sizeof(unsigned char*)); *imagebufs = (unsigned char**)malloc(3*sizeof(unsigned char*));
for (picnum=0;picnum<3;picnum++) { for (picnum=0;picnum<3;picnum++) {
curread=0; curread=0;
sizes[picnum] = jd11_imgsize(port); sizes[picnum] = jd11_imgsize(port);
(*imagebufs)[picnum]=(unsigned char*)malloc(sizes[picnum]+400); (*imagebufs)[picnum]=(unsigned char*)malloc(sizes[picnum]+400);
_send_cmd(port,0xfff1); _send_cmd(port, 0xfff1);
id = gp_context_progress_start (context, sizes[picnum], id = gp_context_progress_start (context, sizes[picnum],
_("Downloading data...")); _("Downloading data..."));
while (curread<sizes[picnum]) { while (curread<sizes[picnum]) {
int readsize = sizes[picnum]-curread; int readsize = sizes[picnum]-curread;
if (readsize > 200) readsize = 200; if (readsize > 200) readsize = 200;
ret=getpacket(port,(*imagebufs)[picnum]+curread,readsize); ret=getpacket(port, (*imagebufs)[picnum]+curread, readsize);
if (ret==0) if (ret==0)
break; break;
curread+=ret; curread+=ret;
if (ret<200) if (ret<200)
break; break;
gp_context_progress_update (context, id, curread); gp_context_progress_update (context, id, curread);
if (gp_context_cancel (context) == GP_CONTEXT_FEEDBACK_CANCEL) { if (gp_context_cancel (context) == GP_CONTEXT_FEEDBACK_CANCEL) {
int j; int j;
/* What to do ... Just free the stuff we allocated for now. */ /* What to do ... Just free the stuff we allocated for now. */
for (j=0;j<picnum;j++) for (j=0;j<picnum;j++)
free((*imagebufs)[picnum]); free((*imagebufs)[picnum]);
free(*imagebufs); free(*imagebufs);
return GP_ERROR_CANCEL; return GP_ERROR_CANCEL;
} }
_send_cmd(port,0xfff1); _send_cmd(port, 0xfff1);
}
gp_context_progress_stop (context, id);
} }
gp_context_progress_stop (context, id); return GP_OK;
}
return GP_OK;
} }
int int
jd11_get_image_full( jd11_get_image_full(Camera *camera, CameraFile*file, int nr, int raw, GPContext *context)
Camera *camera, CameraFile*file, int nr, int raw, GPContext *context {
) { unsigned char *s, *uncomp[3], **imagebufs;
unsigned char *s,*uncomp[3],**imagebufs; int ret, sizes[3];
int ret,sizes[3]; unsigned char *data;
unsigned char *data; int h;
int h;
ret = serial_image_reader(camera,file,nr,&imagebufs,sizes, context); ret = serial_image_reader(camera, file, nr, &imagebufs, sizes, context);
if (ret!=GP_OK) if (ret!=GP_OK)
return ret; return ret;
uncomp[0] = malloc(320*480); uncomp[0] = malloc(320*480);
uncomp[1] = malloc(320*480/2); uncomp[1] = malloc(320*480/2);
uncomp[2] = malloc(320*480/2); uncomp[2] = malloc(320*480/2);
if (sizes[0]!=115200) { if (sizes[0]!=115200) {
picture_decomp_v1(imagebufs[0],uncomp[0],320,480); picture_decomp_v1(imagebufs[0], uncomp[0], 320, 480);
picture_decomp_v1(imagebufs[1],uncomp[1],320,480/2); picture_decomp_v1(imagebufs[1], uncomp[1], 320, 480/2);
picture_decomp_v1(imagebufs[2],uncomp[2],320,480/2); picture_decomp_v1(imagebufs[2], uncomp[2], 320, 480/2);
} else { } else {
picture_decomp_v2(imagebufs[0],uncomp[0],320,480); picture_decomp_v2(imagebufs[0], uncomp[0], 320, 480);
picture_decomp_v2(imagebufs[1],uncomp[1],320,480/2); picture_decomp_v2(imagebufs[1], uncomp[1], 320, 480/2);
picture_decomp_v2(imagebufs[2],uncomp[2],320,480/2); picture_decomp_v2(imagebufs[2], uncomp[2], 320, 480/2);
} }
gp_file_append(file, IMGHEADER, strlen(IMGHEADER)); gp_file_append(file, IMGHEADER, strlen(IMGHEADER));
data = malloc(640*480*3); data = malloc(640*480*3);
if (!data) { if (!data) {
free(uncomp[0]);free(uncomp[1]);free(uncomp[2]); free(uncomp[0]);free(uncomp[1]);free(uncomp[2]);
free(imagebufs[0]);free(imagebufs[1]);free(imagebufs[2]);free(imagebufs); free(imagebufs[0]);free(imagebufs[1]);free(imagebufs[2]);free(imagebufs);
return GP_ERROR_NO_MEMORY; return GP_ERROR_NO_MEMORY;
} }
if (!raw) { if (!raw) {
unsigned char *bayerpre; unsigned char *bayerpre;
s = bayerpre = malloc(640*480); s = bayerpre = malloc(640*480);
/* note that picture is upside down and left<->right mirrored */ /* note that picture is upside down and left<->right mirrored */
for (h=480;h--;) { for (h=480;h--;) {
int w; int w;
for (w=320;w--;) { for (w=320;w--;) {
if (h&1) { if (h&1) {
/* G B G B G B G B G */ /* G B G B G B G B G */
*s++ = uncomp[0][h*320+w]; *s++ = uncomp[0][h*320+w];
*s++ = uncomp[2][(h/2)*320+w]; *s++ = uncomp[2][(h/2)*320+w];
} else { } else {
/* R G R G R G R G R */ /* R G R G R G R G R */
*s++ = uncomp[1][(h/2)*320+w]; *s++ = uncomp[1][(h/2)*320+w];
*s++ = uncomp[0][h*320+w]; *s++ = uncomp[0][h*320+w];
}
}
}
/*gp_bayer_decode(bayerpre,640,480,data,BAYER_TILE_GRBG);*/
gp_ahd_decode(bayerpre, 640, 480, data, BAYER_TILE_GRBG);
free(bayerpre);
} else {
s=data;
for (h=480;h--;) { /* upside down */
int w;
for (w=640;w--;) { /* right to left */
/* and images are in green red blue */
*s++=uncomp[1][(h/2)*320+(w/2)];
*s++=uncomp[0][h*320+(w/2)];
*s++=uncomp[2][(h/2)*320+(w/2)];
}
} }
}
} }
/*gp_bayer_decode(bayerpre,640,480,data,BAYER_TILE_GRBG);*/ free(uncomp[0]);free(uncomp[1]);free(uncomp[2]);
gp_ahd_decode(bayerpre,640,480,data,BAYER_TILE_GRBG); free(imagebufs[0]);free(imagebufs[1]);free(imagebufs[2]);free(imagebufs);
free(bayerpre); gp_file_append(file, (char*)data, 640*480*3);
} else { free(data);
s=data; return GP_OK;
for (h=480;h--;) { /* upside down */
int w;
for (w=640;w--;) { /* right to left */
/* and images are in green red blue */
*s++=uncomp[1][(h/2)*320+(w/2)];
*s++=uncomp[0][h*320+(w/2)];
*s++=uncomp[2][(h/2)*320+(w/2)];
}
}
}
free(uncomp[0]);free(uncomp[1]);free(uncomp[2]);
free(imagebufs[0]);free(imagebufs[1]);free(imagebufs[2]);free(imagebufs);
gp_file_append(file, (char*)data, 640*480*3);
free(data);
return GP_OK;
} }

View File

@@ -136,14 +136,14 @@ jl2005a_read_picture_data (Camera *camera, GPPort *port,
* downloading them. There is only a starting point and an indicator * downloading them. There is only a starting point and an indicator
* for each frame. * for each frame.
*/ */
gp_port_write (port, "\xab\x00", 2); gp_port_write (port, "\xab\x00", 2);
gp_port_write (port, "\xa1\x04", 2); gp_port_write (port, "\xa1\x04", 2);
gp_port_write (port, "\xab\x00", 2); gp_port_write (port, "\xab\x00", 2);
gp_port_write (port, "\xa2\x08", 2); gp_port_write (port, "\xa2\x08", 2);
gp_port_write (port, "\xab\x00", 2); gp_port_write (port, "\xab\x00", 2);
gp_port_write (port, "\xa1\x05", 2); gp_port_write (port, "\xa1\x05", 2);
gp_port_write (port, "\xab\x00", 2); gp_port_write (port, "\xab\x00", 2);
gp_port_write (port, "\xa2\x08", 2); gp_port_write (port, "\xa2\x08", 2);
/* Switch the inep over to 0x81. */ /* Switch the inep over to 0x81. */
set_usb_in_endpoint (camera, 0x81); set_usb_in_endpoint (camera, 0x81);

View File

@@ -112,7 +112,7 @@ static int camera_manual (Camera *camera, CameraText *manual, GPContext *context
{ {
strcpy(manual->text, strcpy(manual->text,
_( _(
"This driver supports cameras with Jeilin jl2005a chip \n" "This driver supports cameras with Jeilin jl2005a chip \n"
"These cameras do not support deletion of photos, nor uploading\n" "These cameras do not support deletion of photos, nor uploading\n"
"of data. \n" "of data. \n"
"Decoding of compressed photos may or may not work well\n" "Decoding of compressed photos may or may not work well\n"
@@ -130,7 +130,7 @@ static int
camera_about (Camera *camera, CameraText *about, GPContext *context) camera_about (Camera *camera, CameraText *about, GPContext *context)
{ {
strcpy (about->text, _("jl2005a camera library\n" strcpy (about->text, _("jl2005a camera library\n"
"Theodore Kilgore <kilgota@auburn.edu>\n")); "Theodore Kilgore <kilgota@auburn.edu>\n"));
return GP_OK; return GP_OK;
} }

View File

@@ -453,7 +453,7 @@ camera_init (Camera *camera, GPContext *context)
int ret = 0; int ret = 0;
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->manual = camera_manual; camera->functions->manual = camera_manual;
camera->functions->summary = camera_summary; camera->functions->summary = camera_summary;
camera->functions->about = camera_about; camera->functions->about = camera_about;
camera->functions->exit = camera_exit; camera->functions->exit = camera_exit;

View File

@@ -300,7 +300,7 @@ static int delete_file_func (CameraFilesystem *fs, const char *folder,
static int camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path, GPContext *context) { static int camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path, GPContext *context) {
CameraList *list; CameraList *list;
int count; int count;
const char* name; const char* name;
if (type != GP_CAPTURE_IMAGE) if (type != GP_CAPTURE_IMAGE)
return (GP_ERROR_NOT_SUPPORTED); return (GP_ERROR_NOT_SUPPORTED);
@@ -323,53 +323,51 @@ static int camera_capture (Camera *camera, CameraCaptureType type, CameraFilePat
CHECK_RESULT (gp_filesystem_append (camera->fs, CHECK_RESULT (gp_filesystem_append (camera->fs,
path->folder, path->folder,
path->name, context)); path->name, context));
return (GP_OK); return (GP_OK);
} }
static int camera_summary (Camera *camera, CameraText *summary, static int camera_summary (Camera *camera, CameraText *summary, GPContext *context)
GPContext *context)
{ {
static char summary_string[2048] = ""; static char summary_string[2048] = "";
char buff[1024]; char buff[1024];
Kodak_dc120_status status; Kodak_dc120_status status;
if (dc120_get_status (camera, &status, context)) if (dc120_get_status (camera, &status, context))
{ {
strcpy(summary_string,"Kodak DC120\n"); strcpy(summary_string, "Kodak DC120\n");
snprintf(buff,1024,"Camera Identification: %s\n",status.camera_id); snprintf(buff, 1024, "Camera Identification: %s\n", status.camera_id);
strcat(summary_string,buff); strcat(summary_string, buff);
snprintf(buff,1024,"Camera Type: %d\n",status.camera_type_id); snprintf(buff, 1024, "Camera Type: %d\n", status.camera_type_id);
strcat(summary_string,buff); strcat(summary_string, buff);
snprintf(buff,1024,"Firmware: %d.%d\n",status.firmware_major,status.firmware_minor); snprintf(buff, 1024, "Firmware: %d.%d\n", status.firmware_major, status.firmware_minor);
strcat(summary_string,buff); strcat(summary_string, buff);
snprintf(buff,1024,"Battery Status: %d\n",status.batteryStatusId); snprintf(buff, 1024, "Battery Status: %d\n", status.batteryStatusId);
strcat(summary_string,buff); strcat(summary_string, buff);
snprintf(buff,1024,"AC Status: %d\n",status.acStatusId); snprintf(buff, 1024, "AC Status: %d\n", status.acStatusId);
strcat(summary_string,buff); strcat(summary_string, buff);
strftime(buff,1024,"Time: %a, %d %b %Y %T\n",localtime((time_t *)&status.time)); strftime(buff, 1024, "Time: %a, %d %b %Y %T\n", localtime((time_t *)&status.time));
strcat(summary_string,buff); strcat(summary_string, buff);
snprintf(buff,1024,"Total Pictures Taken: %d\n", snprintf(buff, 1024, "Total Pictures Taken: %d\n",
status.taken_pict_mem + status.taken_pict_card ); status.taken_pict_mem + status.taken_pict_card);
strcat(summary_string,buff); strcat(summary_string, buff);
} }
strcpy(summary->text, summary_string); strcpy(summary->text, summary_string);
return (GP_OK); return (GP_OK);
} }
static int camera_manual (Camera *camera, CameraText *manual, static int camera_manual (Camera *camera, CameraText *manual, GPContext *context)
GPContext *context)
{ {
strcpy (manual->text, strcpy (manual->text,
_("The Kodak DC120 camera uses the KDC file format " _("The Kodak DC120 camera uses the KDC file format "
@@ -401,41 +399,41 @@ static CameraFilesystemFuncs fsfuncs = {
int camera_init (Camera *camera, GPContext *context) { int camera_init (Camera *camera, GPContext *context) {
GPPortSettings settings; GPPortSettings settings;
int speed; int speed;
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->capture = camera_capture; camera->functions->capture = camera_capture;
camera->functions->summary = camera_summary; camera->functions->summary = camera_summary;
camera->functions->manual = camera_manual; camera->functions->manual = camera_manual;
camera->functions->about = camera_about; camera->functions->about = camera_about;
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
/* Configure the port (remember the speed) */ /* Configure the port (remember the speed) */
gp_port_get_settings (camera->port, &settings); gp_port_get_settings (camera->port, &settings);
speed = settings.serial.speed; speed = settings.serial.speed;
settings.serial.speed = 9600; settings.serial.speed = 9600;
settings.serial.bits = 8; settings.serial.bits = 8;
settings.serial.parity = 0; settings.serial.parity = 0;
settings.serial.stopbits = 1; settings.serial.stopbits = 1;
gp_port_set_settings (camera->port, settings); gp_port_set_settings (camera->port, settings);
gp_port_set_timeout (camera->port, TIMEOUT); gp_port_set_timeout (camera->port, TIMEOUT);
/* Reset the camera to 9600 */ /* Reset the camera to 9600 */
gp_port_send_break (camera->port, 2); gp_port_send_break (camera->port, 2);
/* Wait for it to update */ /* Wait for it to update */
usleep(1500 * 1000); usleep(1500 * 1000);
if (dc120_set_speed (camera, speed) == GP_ERROR) { if (dc120_set_speed (camera, speed) == GP_ERROR) {
return (GP_ERROR); return (GP_ERROR);
} }
/* Try to talk after speed change */ /* Try to talk after speed change */
if (dc120_get_status(camera, NULL, context) == GP_ERROR) { if (dc120_get_status(camera, NULL, context) == GP_ERROR) {
return (GP_ERROR); return (GP_ERROR);
} }
return (GP_OK); return (GP_OK);
} }

View File

@@ -59,14 +59,14 @@ dc120_packet_new (int command_byte) {
*/ */
static int static int
dc120_response_ok (unsigned char response) { dc120_response_ok (unsigned char response) {
/* This is stupid. how do you get a constant of type signed char?? (Ralf) */ /* This is stupid. how do you get a constant of type signed char?? (Ralf) */
if( response == 0x00 || /* Command completed */ if (response == 0x00 || /* Command completed */
response == 0x10 || /* Command ready */ response == 0x10 || /* Command ready */
response == 0xd1 || /* Command received (ACK) */ response == 0xd1 || /* Command received (ACK) */
response == 0xd2 ) /* Correct packet */ response == 0xd2 ) /* Correct packet */
return (GP_OK); return (GP_OK);
else else
return (GP_ERROR); return (GP_ERROR);
} }
/** Writes a packet to the port. /** Writes a packet to the port.
@@ -169,21 +169,21 @@ read_data_write_again:
/* Do some command-specific stuff */ /* Do some command-specific stuff */
switch (cmd_packet[0]) { switch (cmd_packet[0]) {
case 0x4A: case 0x4A:
/* Set size and num_packets for camera filenames*/ /* Set size and num_packets for camera filenames*/
if (packets_received==1) if (packets_received==1)
*size = ((unsigned char)packet[0] * 256 + *size = ((unsigned char)packet[0] * 256 +
(unsigned char)packet[1])* 20 + 2; (unsigned char)packet[1])* 20 + 2;
num_packets = (*size + block_size-1) / block_size; num_packets = (*size + block_size-1) / block_size;
break; break;
case 0x64: case 0x64:
case 0x54: case 0x54:
/* If thumbnail, cancel rest of image transfer */ /* If thumbnail, cancel rest of image transfer */
if ((num_packets == 16)&&(packets_received==16)) if ((num_packets == 16)&&(packets_received==16))
p[0] = CANCL; p[0] = CANCL;
/* No break on purpose */ /* No break on purpose */
break; break;
default: default:
/* Nada */ /* Nada */
break; break;
} }
@@ -194,10 +194,10 @@ read_data_write_again:
/* Copy in data */ /* Copy in data */
if (packets_received == num_packets) if (packets_received == num_packets)
bytes_received = *size - ((num_packets-1) * block_size); bytes_received = *size - ((num_packets-1) * block_size);
else else
bytes_received = block_size; bytes_received = block_size;
gp_file_append(file, packet, bytes_received ); gp_file_append(file, packet, bytes_received);
} }
} }
@@ -295,66 +295,66 @@ int dc120_get_status (Camera *camera, Kodak_dc120_status *status, GPContext *con
size = 256; size = 256;
retval = dc120_packet_read_data(camera, file, p, &size, 256, context); retval = dc120_packet_read_data(camera, file, p, &size, 256, context);
if( retval == (GP_OK) && status != NULL ) if (retval == (GP_OK) && status != NULL)
{ {
const char *data; const char *data;
long unsigned int lsize; long unsigned int lsize;
gp_file_get_data_and_size( file, &data, &lsize ); gp_file_get_data_and_size(file, &data, &lsize);
if( lsize<122 ) { if (lsize<122) {
gp_file_free (file); gp_file_free (file);
free (p); free (p);
return (GP_ERROR); return (GP_ERROR);
} }
memset((char*)status,0,sizeof(*status)); memset((char*)status, 0, sizeof(*status));
status->camera_type_id = data[1]; status->camera_type_id = data[1];
status->firmware_major = data[2]; status->firmware_major = data[2];
status->firmware_minor = data[3]; status->firmware_minor = data[3];
status->batteryStatusId = data[8]; status->batteryStatusId = data[8];
status->acStatusId = data[9]; status->acStatusId = data[9];
/* seconds since unix epoc */ /* seconds since unix epoc */
status->time = CAMERA_EPOC + ( status->time = CAMERA_EPOC + (
data[12] * 0x1000000 + data[12] * 0x1000000 +
data[13] * 0x10000 + data[13] * 0x10000 +
data[14] * 0x100 + data[14] * 0x100 +
data[15]) / 2; data[15]) / 2;
status->af_mode = data[16] & 0x0f; status->af_mode = data[16] & 0x0f;
status->zoom_mode = (data[16] & 0x30)>>4; status->zoom_mode = (data[16] & 0x30)>>4;
status->flash_charged = data[18]; status->flash_charged = data[18];
status->compression_mode_id = data[19]; status->compression_mode_id = data[19];
status->flash_mode = data[20]; status->flash_mode = data[20];
status->exposure_compensation = (data[2]&0x40?-1:1) * (data[21] & 0x3f); status->exposure_compensation = (data[2]&0x40 ? -1 : 1) * (data[21] & 0x3f);
status->light_value = data[22]; status->light_value = data[22];
status->manual_exposure = data[23]; status->manual_exposure = data[23];
status->exposure_time = (data[24] * 0x1000000 + status->exposure_time = (data[24] * 0x1000000 +
data[25] * 0x10000 + data[25] * 0x10000 +
data[26] * 0x100 + data[26] * 0x100 +
data[27]) / 2; data[27]) / 2;
status->shutter_delay = data[29]; status->shutter_delay = data[29];
status->memory_card = data[30]; status->memory_card = data[30];
status->front_cover = data[31]; status->front_cover = data[31];
status->date_format = data[32]; status->date_format = data[32];
status->time_format = data[33]; status->time_format = data[33];
status->distance_format = data[34]; status->distance_format = data[34];
status->taken_pict_mem = data[36] * 0x100 + data[37]; status->taken_pict_mem = data[36] * 0x100 + data[37];
for( i=0; i<4; i++ ) { for (i=0; i<4; i++) {
status->remaining_pic_mem[i] = status->remaining_pic_mem[i] =
data[46+i*2] * 0x100 + data[46+i*2] * 0x100 +
data[47+i*2]; data[47+i*2];
} }
status->taken_pict_card = data[56] * 0x100 + data[57]; status->taken_pict_card = data[56] * 0x100 + data[57];
for( i=0; i<4; i++ ) { for (i=0; i<4; i++) {
status->remaining_pic_card[i] = status->remaining_pic_card[i] =
data[66+i*2] * 0x100 + data[66+i*2] * 0x100 +
data[67+i*2]; data[67+i*2];
} }
strncpy( status->card_id, data + 77, 32 ); strncpy(status->card_id, data + 77, 32);
strncpy( status->camera_id, data + 90, 32 ); strncpy(status->camera_id, data + 90, 32);
} }
gp_file_free(file); gp_file_free(file);
@@ -431,11 +431,11 @@ int dc120_get_filenames (Camera *camera, int from_card, int album_number, Camera
gp_file_get_data_and_size (file, &file_data, &file_size); gp_file_get_data_and_size (file, &file_data, &file_size);
x=2; x=2;
while (x < size) { while (x < size) {
if( file_data[x] != '\0' ) { if (file_data[x] != '\0') {
strncpy(buf, (char*) &file_data[x], 11); strncpy(buf, (char*)&file_data[x], 11);
buf[7] = '.'; buf[7] = '.';
buf[11] = '\0'; buf[11] = '\0';
gp_list_append(list, buf, NULL); gp_list_append(list, buf, NULL);
} }
x += 20; x += 20;
} }
@@ -483,8 +483,8 @@ static int dc120_get_file_preview (Camera *camera, CameraFile *file, int file_nu
static int dc120_get_file (Camera *camera, CameraFile *file, int file_number, char *cmd_packet, int *size, GPContext *context) static int dc120_get_file (Camera *camera, CameraFile *file, int file_number, char *cmd_packet, int *size, GPContext *context)
{ {
CameraFile *size_file; /* file used to determine the filesize */ CameraFile *size_file; /* file used to determine the filesize */
char *p; char *p;
const char *file_data; const char *file_data;
long unsigned int file_size; long unsigned int file_size;
unsigned int offset; unsigned int offset;
@@ -508,12 +508,12 @@ static int dc120_get_file (Camera *camera, CameraFile *file, int file_number, ch
gp_file_get_data_and_size (size_file, &file_data, &file_size); gp_file_get_data_and_size (size_file, &file_data, &file_size);
offset = 2 + (file_number-1) * 20; offset = 2 + (file_number-1) * 20;
if( file_size < (offset+19) ) if (file_size < (offset+19))
{ {
gp_file_free(size_file); gp_file_free(size_file);
free (p); free (p);
return (GP_ERROR); return (GP_ERROR);
} }
*size = (unsigned char)file_data[offset + 16] * 256*256*256 + *size = (unsigned char)file_data[offset + 16] * 256*256*256 +
(unsigned char)file_data[offset + 17] * 256*256 + (unsigned char)file_data[offset + 17] * 256*256 +
@@ -525,7 +525,7 @@ static int dc120_get_file (Camera *camera, CameraFile *file, int file_number, ch
free (p); free (p);
if (dc120_packet_read_data(camera, file, cmd_packet, size, 1024, context)==GP_ERROR) if (dc120_packet_read_data(camera, file, cmd_packet, size, 1024, context)==GP_ERROR)
return (GP_ERROR); return (GP_ERROR);
return (GP_OK); return (GP_OK);
@@ -544,12 +544,12 @@ static int dc120_wait_for_completion (Camera *camera, GPContext *context) {
retval = dc120_packet_read(camera, p, 1); retval = dc120_packet_read(camera, p, 1);
switch (retval) { switch (retval) {
case GP_ERROR: case GP_ERROR:
return (GP_ERROR); return (GP_ERROR);
break; break;
case GP_ERROR_TIMEOUT: case GP_ERROR_TIMEOUT:
break; break;
default: default:
done = 1; done = 1;
} }
gp_context_progress_update (context, id, x); gp_context_progress_update (context, id, x);
@@ -596,19 +596,19 @@ int dc120_file_action (Camera *camera, int action, int from_card, int album_numb
p[4] = album_number; p[4] = album_number;
switch (action) { switch (action) {
case DC120_ACTION_PREVIEW: case DC120_ACTION_PREVIEW:
p[0] = (from_card? 0x64 : 0x54); p[0] = (from_card ? 0x64 : 0x54);
retval = dc120_get_file_preview(camera, file, file_number, p, &size, context); retval = dc120_get_file_preview(camera, file, file_number, p, &size, context);
break; break;
case DC120_ACTION_IMAGE: case DC120_ACTION_IMAGE:
p[0] = (from_card? 0x64 : 0x54); p[0] = (from_card ? 0x64 : 0x54);
retval = dc120_get_file(camera, file, file_number, p, &size, context); retval = dc120_get_file(camera, file, file_number, p, &size, context);
break; break;
case DC120_ACTION_DELETE: case DC120_ACTION_DELETE:
p[0] = (from_card? 0x7B : 0x7A); p[0] = (from_card ? 0x7B : 0x7A);
retval = dc120_delete_file(camera, p, context); retval = dc120_delete_file(camera, p, context);
break; break;
default: default:
retval = GP_ERROR; retval = GP_ERROR;
} }
free(p); free(p);
@@ -617,20 +617,18 @@ int dc120_file_action (Camera *camera, int action, int from_card, int album_numb
int dc120_capture (Camera *camera, CameraFilePath *path, GPContext *context) int dc120_capture (Camera *camera, CameraFilePath *path, GPContext *context)
{ {
int retval; int retval;
char *p = dc120_packet_new(0x77); char *p = dc120_packet_new(0x77);
/* Take the picture to Flash memory */ /* Take the picture to Flash memory */
if (dc120_packet_write(camera, p, 8, 1) == GP_ERROR) { if (dc120_packet_write(camera, p, 8, 1) == GP_ERROR) {
retval = (GP_ERROR); retval = (GP_ERROR);
} } else if (dc120_wait_for_completion(camera, context) == GP_ERROR) {
else if ( dc120_wait_for_completion(camera, context) == GP_ERROR ) { retval = (GP_ERROR);
retval = (GP_ERROR); } else {
} retval = (GP_OK);
else { }
retval = (GP_OK);
}
free( p ); free(p);
return retval; return retval;
} }

View File

@@ -122,7 +122,7 @@ static int delete_file_func (CameraFilesystem *fs, const char *folder,
static int get_info_func (CameraFilesystem *fs, const char *folder, const char *file, static int get_info_func (CameraFilesystem *fs, const char *folder, const char *file,
CameraFileInfo *info, void *data, GPContext *context) CameraFileInfo *info, void *data, GPContext *context)
{ {
Camera *camera = data; Camera *camera = data;
dc210_picture_info picinfo; dc210_picture_info picinfo;
if (dc210_get_picture_info_by_name(camera, &picinfo, file) == GP_ERROR) if (dc210_get_picture_info_by_name(camera, &picinfo, file) == GP_ERROR)
@@ -186,10 +186,10 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context)
gp_widget_new (GP_WIDGET_SECTION, _("File"), &section); gp_widget_new (GP_WIDGET_SECTION, _("File"), &section);
gp_widget_append (*window, section); gp_widget_append (*window, section);
gp_widget_new (GP_WIDGET_RADIO, _("File type"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("File type"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("JPEG")); gp_widget_add_choice (widget, _("JPEG"));
gp_widget_add_choice (widget, _("FlashPix")); gp_widget_add_choice (widget, _("FlashPix"));
switch (status.file_type){ switch (status.file_type){
case DC210_FILE_TYPE_JPEG: case DC210_FILE_TYPE_JPEG:
@@ -199,10 +199,10 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context)
}; };
gp_widget_get_value (widget, &wvalue); gp_widget_get_value (widget, &wvalue);
gp_widget_new (GP_WIDGET_RADIO, _("File resolution"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("File resolution"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("640 x 480")); gp_widget_add_choice (widget, _("640 x 480"));
gp_widget_add_choice (widget, _("1152 x 864")); gp_widget_add_choice (widget, _("1152 x 864"));
switch (status.resolution){ switch (status.resolution){
case DC210_FILE_640: case DC210_FILE_640:
@@ -214,11 +214,11 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context)
}; };
gp_widget_get_value (widget, &wvalue); gp_widget_get_value (widget, &wvalue);
gp_widget_new (GP_WIDGET_MENU, _("File compression"), &widget); gp_widget_new (GP_WIDGET_MENU, _("File compression"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("Low (best quality)")); gp_widget_add_choice (widget, _("Low (best quality)"));
gp_widget_add_choice (widget, _("Medium (better quality)")); gp_widget_add_choice (widget, _("Medium (better quality)"));
gp_widget_add_choice (widget, _("High (good quality)")); gp_widget_add_choice (widget, _("High (good quality)"));
switch (status.compression_type){ switch (status.compression_type){
case DC210_LOW_COMPRESSION: case DC210_LOW_COMPRESSION:
@@ -233,14 +233,14 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context)
gp_widget_new (GP_WIDGET_SECTION, _("Capture"), &section); gp_widget_new (GP_WIDGET_SECTION, _("Capture"), &section);
gp_widget_append (*window, section); gp_widget_append (*window, section);
gp_widget_new (GP_WIDGET_MENU, _("Zoom"), &widget); gp_widget_new (GP_WIDGET_MENU, _("Zoom"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, "58 mm"); /* no need to translate strings with SI units! */ gp_widget_add_choice (widget, "58 mm"); /* no need to translate strings with SI units! */
gp_widget_add_choice (widget, "51 mm"); gp_widget_add_choice (widget, "51 mm");
gp_widget_add_choice (widget, "41 mm"); gp_widget_add_choice (widget, "41 mm");
gp_widget_add_choice (widget, "34 mm"); gp_widget_add_choice (widget, "34 mm");
gp_widget_add_choice (widget, "29 mm"); gp_widget_add_choice (widget, "29 mm");
gp_widget_add_choice (widget, _("Macro")); gp_widget_add_choice (widget, _("Macro"));
switch (status.zoom){ switch (status.zoom){
case DC210_ZOOM_58: case DC210_ZOOM_58:
@@ -258,19 +258,19 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context)
}; };
gp_widget_get_value (widget, &wvalue); gp_widget_get_value (widget, &wvalue);
gp_widget_new (GP_WIDGET_MENU, _("Exposure compensation"), &widget); gp_widget_new (GP_WIDGET_MENU, _("Exposure compensation"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
for (i = 0; i < sizeof(exp_comp)/sizeof(*exp_comp); i++){ for (i = 0; i < sizeof(exp_comp)/sizeof(*exp_comp); i++){
gp_widget_add_choice (widget, exp_comp[i]); gp_widget_add_choice (widget, exp_comp[i]);
if ((unsigned int)(status.exp_compensation + 4) == i) if ((unsigned int)(status.exp_compensation + 4) == i)
gp_widget_set_value (widget, exp_comp[i]); gp_widget_set_value (widget, exp_comp[i]);
}; };
gp_widget_new (GP_WIDGET_RADIO, _("Flash"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("Flash"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("Auto")); gp_widget_add_choice (widget, _("Auto"));
gp_widget_add_choice (widget, _("Force")); gp_widget_add_choice (widget, _("Force"));
gp_widget_add_choice (widget, _("None")); gp_widget_add_choice (widget, _("None"));
switch (status.flash){ switch (status.flash){
case DC210_FLASH_AUTO: case DC210_FLASH_AUTO:
@@ -282,10 +282,10 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context)
}; };
gp_widget_get_value (widget, &wvalue); gp_widget_get_value (widget, &wvalue);
gp_widget_new (GP_WIDGET_RADIO, _("Red eye flash"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("Red eye flash"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("On")); gp_widget_add_choice (widget, _("On"));
gp_widget_add_choice (widget, _("Off")); gp_widget_add_choice (widget, _("Off"));
if (status.preflash) if (status.preflash)
gp_widget_set_value (widget, _("On")); gp_widget_set_value (widget, _("On"));
@@ -296,15 +296,15 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context)
gp_widget_new (GP_WIDGET_SECTION, _("Other"), &section); gp_widget_new (GP_WIDGET_SECTION, _("Other"), &section);
gp_widget_append (*window, section); gp_widget_append (*window, section);
gp_widget_new (GP_WIDGET_BUTTON, "Set time to system time", &widget); gp_widget_new (GP_WIDGET_BUTTON, "Set time to system time", &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_set_value (widget, dc210_system_time_callback); gp_widget_set_value (widget, dc210_system_time_callback);
gp_widget_set_info (widget, _("Set clock in camera")); gp_widget_set_info (widget, _("Set clock in camera"));
gp_camera_get_abilities(camera, &abilities); gp_camera_get_abilities(camera, &abilities);
gp_port_get_settings (camera->port, &settings); gp_port_get_settings (camera->port, &settings);
gp_widget_new (GP_WIDGET_MENU, _("Port speed"), &widget); gp_widget_new (GP_WIDGET_MENU, _("Port speed"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
for (i = 0; i < sizeof(abilities.speed); i++){ for (i = 0; i < sizeof(abilities.speed); i++){
if (abilities.speed[i] == 0) break; if (abilities.speed[i] == 0) break;
snprintf(stringbuffer, 12, "%d", abilities.speed[i]); snprintf(stringbuffer, 12, "%d", abilities.speed[i]);
@@ -313,13 +313,13 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context)
gp_widget_set_value (widget, stringbuffer); gp_widget_set_value (widget, stringbuffer);
}; };
gp_widget_new (GP_WIDGET_TEXT, _("Album name"), &widget); gp_widget_new (GP_WIDGET_TEXT, _("Album name"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_set_value (widget, status.album_name); gp_widget_set_value (widget, status.album_name);
gp_widget_set_info (widget, _("Name to set on card when formatting.")); gp_widget_set_info (widget, _("Name to set on card when formatting."));
gp_widget_new (GP_WIDGET_BUTTON, _("Format compact flash"), &widget); gp_widget_new (GP_WIDGET_BUTTON, _("Format compact flash"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_set_value (widget, dc210_format_callback); gp_widget_set_value (widget, dc210_format_callback);
gp_widget_set_info (widget, _("Format card and set album name.")); gp_widget_set_info (widget, _("Format card and set album name."));
@@ -327,20 +327,20 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context)
gp_widget_new (GP_WIDGET_SECTION, _("Debug"), &section); gp_widget_new (GP_WIDGET_SECTION, _("Debug"), &section);
gp_widget_append (*window, section); gp_widget_append (*window, section);
gp_widget_new (GP_WIDGET_TEXT, "Parameter 1", &widget); gp_widget_new (GP_WIDGET_TEXT, "Parameter 1", &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_set_value (widget, "0"); gp_widget_set_value (widget, "0");
gp_widget_new (GP_WIDGET_TEXT, "Parameter 2", &widget); gp_widget_new (GP_WIDGET_TEXT, "Parameter 2", &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_set_value (widget, "0"); gp_widget_set_value (widget, "0");
gp_widget_new (GP_WIDGET_TEXT, "Parameter 3", &widget); gp_widget_new (GP_WIDGET_TEXT, "Parameter 3", &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_set_value (widget, "0"); gp_widget_set_value (widget, "0");
gp_widget_new (GP_WIDGET_BUTTON, "Execute debug command", &widget); gp_widget_new (GP_WIDGET_BUTTON, "Execute debug command", &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_set_value (widget, dc210_debug_callback); gp_widget_set_value (widget, dc210_debug_callback);
gp_widget_set_info (widget, _("Execute predefined command\nwith parameter values.")); gp_widget_set_info (widget, _("Execute predefined command\nwith parameter values."));
#endif #endif
@@ -357,7 +357,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_widget_get_child_by_label (window, _("File type"), &w); gp_widget_get_child_by_label (window, _("File type"), &w);
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &wvalue); gp_widget_get_value (w, &wvalue);
if (wvalue[0] == 'J') if (wvalue[0] == 'J')
dc210_set_file_type(camera, DC210_FILE_TYPE_JPEG); dc210_set_file_type(camera, DC210_FILE_TYPE_JPEG);
@@ -367,7 +367,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_widget_get_child_by_label (window, _("File resolution"), &w); gp_widget_get_child_by_label (window, _("File resolution"), &w);
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &wvalue); gp_widget_get_value (w, &wvalue);
switch(wvalue[0]){ switch(wvalue[0]){
case '6': case '6':
@@ -381,7 +381,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_widget_get_child_by_label (window, _("File compression"), &w); gp_widget_get_child_by_label (window, _("File compression"), &w);
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &wvalue); gp_widget_get_value (w, &wvalue);
switch(wvalue[0]){ switch(wvalue[0]){
case 'L': case 'L':
@@ -397,7 +397,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_widget_get_child_by_label (window, _("Zoom"), &w); gp_widget_get_child_by_label (window, _("Zoom"), &w);
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &wvalue); gp_widget_get_value (w, &wvalue);
switch(wvalue[0]){ switch(wvalue[0]){
case '5': case '5':
@@ -423,7 +423,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_widget_get_child_by_label (window, _("Exposure compensation"), &w); gp_widget_get_child_by_label (window, _("Exposure compensation"), &w);
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &wvalue); gp_widget_get_value (w, &wvalue);
for (i = 0; i < sizeof(exp_comp)/sizeof(*exp_comp); i++){ for (i = 0; i < sizeof(exp_comp)/sizeof(*exp_comp); i++){
if (strncmp(wvalue, exp_comp[i], 4) == 0){ if (strncmp(wvalue, exp_comp[i], 4) == 0){
@@ -435,7 +435,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_widget_get_child_by_label (window, _("Port speed"), &w); gp_widget_get_child_by_label (window, _("Port speed"), &w);
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &wvalue); gp_widget_get_value (w, &wvalue);
dc210_set_speed(camera, atoi(wvalue)); dc210_set_speed(camera, atoi(wvalue));
}; };
@@ -443,8 +443,8 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
gp_widget_get_child_by_label (window, _("Flash"), &w); gp_widget_get_child_by_label (window, _("Flash"), &w);
gp_widget_get_child_by_label (window, _("Red eye flash"), &w2); gp_widget_get_child_by_label (window, _("Red eye flash"), &w2);
if (gp_widget_changed (w) || gp_widget_changed(w2)) { if (gp_widget_changed (w) || gp_widget_changed(w2)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_set_changed (w2, 0); gp_widget_set_changed (w2, 0);
gp_widget_get_value (w, &wvalue); gp_widget_get_value (w, &wvalue);
gp_widget_get_value (w2, &w2value); gp_widget_get_value (w2, &w2value);
switch(wvalue[0]){ switch(wvalue[0]){
@@ -479,7 +479,7 @@ static int camera_capture (Camera *camera, CameraCaptureType type, CameraFilePat
} }
static int camera_capture_preview (Camera* camera, CameraFile* file, GPContext *context){ static int camera_capture_preview (Camera* camera, CameraFile* file, GPContext *context){
/* this function is to slow; don't export it */ /* this function is to slow; don't export it */
int fatal_error = 0; int fatal_error = 0;
if (dc210_take_picture(camera, context) == GP_ERROR) return GP_ERROR; if (dc210_take_picture(camera, context) == GP_ERROR) return GP_ERROR;
@@ -492,150 +492,148 @@ static int camera_capture_preview (Camera* camera, CameraFile* file, GPContext *
}; };
static int camera_summary (Camera *camera, CameraText *summary, static int camera_summary (Camera *camera, CameraText *summary, GPContext *context)
GPContext *context)
{ {
static char summary_string[2048] = ""; static char summary_string[2048] = "";
char buff[1024]; char buff[1024];
dc210_status status; dc210_status status;
if (GP_OK == dc210_get_status (camera, &status)) if (GP_OK == dc210_get_status (camera, &status))
{ {
strcpy(summary_string,"Kodak DC210\n"); strcpy(summary_string, "Kodak DC210\n");
snprintf(buff,1024,_("Pictures in camera: %d\n"), snprintf(buff, 1024, _("Pictures in camera: %d\n"),
status.numPicturesInCamera); status.numPicturesInCamera);
strcat(summary_string,buff); strcat(summary_string, buff);
snprintf(buff,1024,_("There is space for another\n %d low compressed\n %d medium compressed or\n %d high compressed pictures\n"), snprintf(buff, 1024, _("There is space for another\n %d low compressed\n %d medium compressed or\n %d high compressed pictures\n"),
status.remainingLow, status.remainingMedium, status.remainingHigh); status.remainingLow, status.remainingMedium, status.remainingHigh);
strcat(summary_string,buff); strcat(summary_string, buff);
snprintf(buff,1024,_("Total pictures taken: %d\n"), snprintf(buff, 1024, _("Total pictures taken: %d\n"),
status.totalPicturesTaken); status.totalPicturesTaken);
strcat(summary_string,buff); strcat(summary_string, buff);
snprintf(buff,1024,_("Total flashes fired: %d\n"), snprintf(buff, 1024, _("Total flashes fired: %d\n"),
status.totalFlashesFired); status.totalFlashesFired);
strcat(summary_string,buff); strcat(summary_string, buff);
snprintf(buff,1024,_("Firmware: %d.%d\n"),status.firmwareMajor,status.firmwareMinor); snprintf(buff, 1024, _("Firmware: %d.%d\n"), status.firmwareMajor, status.firmwareMinor);
strcat(summary_string,buff); strcat(summary_string, buff);
switch (status.file_type){ switch (status.file_type) {
case DC210_FILE_TYPE_JPEG: case DC210_FILE_TYPE_JPEG:
snprintf(buff, 1024, _("Filetype: JPEG (")); break; snprintf(buff, 1024, _("Filetype: JPEG (")); break;
case DC210_FILE_TYPE_FPX: case DC210_FILE_TYPE_FPX:
snprintf(buff, 1024, _("Filetype: FlashPix (")); break; snprintf(buff, 1024, _("Filetype: FlashPix (")); break;
}; };
strcat(summary_string, buff); strcat(summary_string, buff);
switch (status.compression_type){ switch (status.compression_type) {
case DC210_LOW_COMPRESSION: case DC210_LOW_COMPRESSION:
snprintf(buff, 1024, _("low compression, ")); break; snprintf(buff, 1024, _("low compression, ")); break;
case DC210_MEDIUM_COMPRESSION: case DC210_MEDIUM_COMPRESSION:
snprintf(buff, 1024, _("medium compression, ")); break; snprintf(buff, 1024, _("medium compression, ")); break;
case DC210_HIGH_COMPRESSION: case DC210_HIGH_COMPRESSION:
snprintf(buff, 1024, _("high compression, ")); break; snprintf(buff, 1024, _("high compression, ")); break;
default: default:
snprintf(buff, 1024, _("unknown compression %d, "), status.compression_type); break; snprintf(buff, 1024, _("unknown compression %d, "), status.compression_type); break;
}; };
strcat(summary_string, buff); strcat(summary_string, buff);
switch (status.resolution){ switch (status.resolution) {
case DC210_FILE_640: case DC210_FILE_640:
snprintf(buff, 1024, "640x480 pixel)\n"); break; snprintf(buff, 1024, "640x480 pixel)\n"); break;
case DC210_FILE_1152: case DC210_FILE_1152:
snprintf(buff, 1024, "1152x864 pixel)\n"); break; snprintf(buff, 1024, "1152x864 pixel)\n"); break;
default: default:
snprintf(buff, 1024, _("unknown resolution %d)\n"), status.resolution); break; snprintf(buff, 1024, _("unknown resolution %d)\n"), status.resolution); break;
}; };
strcat(summary_string, buff); strcat(summary_string, buff);
/* battery check still doesn't work */ /* battery check still doesn't work */
/* switch (status.battery){ /* switch (status.battery){
case 0: snprintf(buff,1024,"Battery charge is good\n"); break; case 0: snprintf(buff,1024,"Battery charge is good\n"); break;
case 1: snprintf(buff,1024,"Battery charge is low\n"); break; case 1: snprintf(buff,1024,"Battery charge is low\n"); break;
case 2: snprintf(buff,1024,"Battery is not charged\n"); break; case 2: snprintf(buff,1024,"Battery is not charged\n"); break;
}; };
strcat(summary_string,buff);*/ strcat(summary_string,buff);*/
if (status.acstatus) if (status.acstatus)
snprintf(buff,1024,_("AC adapter is connected.\n")); snprintf(buff, 1024, _("AC adapter is connected.\n"));
else
snprintf(buff,1024,_("AC adapter is not connected.\n"));
strcat(summary_string,buff);
/* time string, do not change the % escapes */
strftime(buff,1024,_("Time: %a, %d %b %Y %T\n"),
localtime((time_t *)&status.time));
strcat(summary_string,buff);
switch (status.zoom){
case DC210_ZOOM_58:
snprintf(buff, 1024, _("Zoom: 58 mm\n")); break;
case DC210_ZOOM_51:
snprintf(buff, 1024, _("Zoom: 51 mm\n")); break;
case DC210_ZOOM_41:
snprintf(buff, 1024, _("Zoom: 41 mm\n")); break;
case DC210_ZOOM_34:
snprintf(buff, 1024, _("Zoom: 34 mm\n")); break;
case DC210_ZOOM_29:
snprintf(buff, 1024, _("Zoom: 29 mm\n")); break;
case DC210_ZOOM_MACRO:
snprintf(buff, 1024, _("Zoom: macro\n")); break;
default:
snprintf(buff, 1024, _("Unknown zoom mode %d\n"),
status.zoom); break;
};
strcat(summary_string,buff);
if (status.exp_compensation > -5 && status.exp_compensation < 4)
snprintf(buff, 1024, _("Exposure compensation: %s\n"), exp_comp[status.exp_compensation + 4]);
else
snprintf(buff, 1024, _("Exposure compensation: %d\n"), status.exp_compensation);
strcat(summary_string,buff);
switch (status.flash){
case DC210_FLASH_AUTO:
snprintf(buff, 1024, _("Flash mode: auto, ")); break;
case DC210_FLASH_FORCE:
snprintf(buff, 1024, _("Flash mode: force, ")); break;
case DC210_FLASH_NONE:
snprintf(buff, 1024, _("Flash mode: off\n")); break;
default:
snprintf(buff, 1024, _("Unknown flash mode %d, "),
status.flash); break;
};
strcat(summary_string,buff);
if (status.flash != DC210_FLASH_NONE){
if (status.preflash)
/* trans: continuation of "Flash mode:" line */
snprintf(buff,1024,_("red eye flash on.\n"));
else else
/* trans: continuation of "Flash mode:" line */ snprintf(buff, 1024, _("AC adapter is not connected.\n"));
snprintf(buff,1024,_("red eye flash off.\n")); strcat(summary_string, buff);
strcat(summary_string,buff);
/* time string, do not change the % escapes */
strftime(buff, 1024, _("Time: %a, %d %b %Y %T\n"),
localtime((time_t *)&status.time));
strcat(summary_string, buff);
switch (status.zoom) {
case DC210_ZOOM_58:
snprintf(buff, 1024, _("Zoom: 58 mm\n")); break;
case DC210_ZOOM_51:
snprintf(buff, 1024, _("Zoom: 51 mm\n")); break;
case DC210_ZOOM_41:
snprintf(buff, 1024, _("Zoom: 41 mm\n")); break;
case DC210_ZOOM_34:
snprintf(buff, 1024, _("Zoom: 34 mm\n")); break;
case DC210_ZOOM_29:
snprintf(buff, 1024, _("Zoom: 29 mm\n")); break;
case DC210_ZOOM_MACRO:
snprintf(buff, 1024, _("Zoom: macro\n")); break;
default:
snprintf(buff, 1024, _("Unknown zoom mode %d\n"),
status.zoom); break;
};
strcat(summary_string, buff);
if (status.exp_compensation > -5 && status.exp_compensation < 4)
snprintf(buff, 1024, _("Exposure compensation: %s\n"), exp_comp[status.exp_compensation + 4]);
else
snprintf(buff, 1024, _("Exposure compensation: %d\n"), status.exp_compensation);
strcat(summary_string, buff);
switch (status.flash) {
case DC210_FLASH_AUTO:
snprintf(buff, 1024, _("Flash mode: auto, ")); break;
case DC210_FLASH_FORCE:
snprintf(buff, 1024, _("Flash mode: force, ")); break;
case DC210_FLASH_NONE:
snprintf(buff, 1024, _("Flash mode: off\n")); break;
default:
snprintf(buff, 1024, _("Unknown flash mode %d, "),
status.flash); break;
};
strcat(summary_string, buff);
if (status.flash != DC210_FLASH_NONE) {
if (status.preflash)
/* trans: continuation of "Flash mode:" line */
snprintf(buff, 1024, _("red eye flash on.\n"));
else
/* trans: continuation of "Flash mode:" line */
snprintf(buff, 1024, _("red eye flash off.\n"));
strcat(summary_string, buff);
};
if (status.card_status.open == 0)
snprintf(buff, 1024, _("No card in camera.\n"));
else
snprintf(buff, 1024, _("Card name: %s\nFree space on card: %d kB\n"),
status.album_name,
status.card_status.space);
strcat(summary_string, buff);
} else {
DC210_DEBUG("Couldn't get summary for camera\n");
}; };
if (status.card_status.open == 0) strcpy(summary->text, summary_string);
snprintf(buff, 1024, _("No card in camera.\n"));
else
snprintf(buff,1024, _("Card name: %s\nFree space on card: %d kB\n"),
status.album_name,
status.card_status.space);
strcat(summary_string,buff); return (GP_OK);
}
else{
DC210_DEBUG("Couldn't get summary for camera\n");
};
strcpy(summary->text, summary_string);
return (GP_OK);
} }
@@ -671,20 +669,20 @@ int camera_init (Camera *camera, GPContext *context) {
DC210_DEBUG("Initializing camera.\n"); DC210_DEBUG("Initializing camera.\n");
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->get_config = camera_get_config; camera->functions->get_config = camera_get_config;
camera->functions->set_config = camera_set_config; camera->functions->set_config = camera_set_config;
camera->functions->capture = camera_capture; camera->functions->capture = camera_capture;
camera->functions->capture_preview = camera_capture_preview; camera->functions->capture_preview = camera_capture_preview;
camera->functions->summary = camera_summary; camera->functions->summary = camera_summary;
camera->functions->manual = camera_manual; camera->functions->manual = camera_manual;
camera->functions->about = camera_about; camera->functions->about = camera_about;
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
if (dc210_init_port (camera) == GP_ERROR) return GP_ERROR; if (dc210_init_port (camera) == GP_ERROR) return GP_ERROR;
if (dc210_open_card (camera) == GP_ERROR) return GP_ERROR; if (dc210_open_card (camera) == GP_ERROR) return GP_ERROR;
return (GP_OK); return (GP_OK);
} }
/****************************************************************************/ /****************************************************************************/

View File

@@ -82,11 +82,11 @@ typedef struct {
dc210_zoom_type zoom; dc210_zoom_type zoom;
char flash_charged; char flash_charged;
dc210_compression_type compression_type; dc210_compression_type compression_type;
signed char exp_compensation; signed char exp_compensation;
dc210_flash_type flash; dc210_flash_type flash;
char preflash; char preflash;
dc210_resolution_type resolution; dc210_resolution_type resolution;
dc210_file_type_type file_type; dc210_file_type_type file_type;
int totalPicturesTaken; int totalPicturesTaken;
int totalFlashesFired; int totalFlashesFired;
int numPicturesInCamera; int numPicturesInCamera;

View File

@@ -47,9 +47,8 @@ static char oldstatus[DC210_STATUS_SIZE];
****************************************************************************/ ****************************************************************************/
static void cfa2ppm static void cfa2ppm (CameraFile * file) {
(CameraFile * file)
{
/* this is a very quick and dirty hack to convert cfa into ppm */ /* this is a very quick and dirty hack to convert cfa into ppm */
unsigned char buf[THUMBHEIGHT][THUMBWIDTH]; unsigned char buf[THUMBHEIGHT][THUMBWIDTH];
unsigned char rgb[THUMBHEIGHT][THUMBWIDTH][3]; unsigned char rgb[THUMBHEIGHT][THUMBWIDTH][3];
@@ -138,9 +137,8 @@ static void cfa2ppm
/* Utility procedures for command execution */ /* Utility procedures for command execution */
static void dc210_cmd_init static void dc210_cmd_init (char * cmd, unsigned char command_byte) {
(char * cmd, unsigned char command_byte)
{
/* utility procedure to initialize a command string */ /* utility procedure to initialize a command string */
memset (cmd, 0, 8); memset (cmd, 0, 8);
@@ -150,9 +148,8 @@ static void dc210_cmd_init
}; };
static void dc210_cmd_packet_init static void dc210_cmd_packet_init (char * cmd_packet, const char * filename) {
(char * cmd_packet, const char * filename)
{
/* prepare command packet */ /* prepare command packet */
memset (cmd_packet, 0x00, DC210_CMD_DATA_SIZE); memset (cmd_packet, 0x00, DC210_CMD_DATA_SIZE);
memset (cmd_packet + 48, 0xFF, 8); memset (cmd_packet + 48, 0xFF, 8);
@@ -163,9 +160,8 @@ static void dc210_cmd_packet_init
}; };
static int dc210_write_single_char static int dc210_write_single_char (Camera *camera, unsigned char response) {
(Camera *camera, unsigned char response)
{
/* utility procedure to write a single character */ /* utility procedure to write a single character */
int i; int i;
@@ -179,9 +175,7 @@ static int dc210_write_single_char
}; };
static int dc210_read_single_char static int dc210_read_single_char (Camera *camera, unsigned char * response) {
(Camera *camera, unsigned char * response)
{
/* utility procedure to read a single character */ /* utility procedure to read a single character */
@@ -211,9 +205,7 @@ static int dc210_read_single_char
/* Command execution */ /* Command execution */
static int dc210_execute_command static int dc210_execute_command (Camera *camera, char *cmd) {
(Camera *camera, char *cmd)
{
/* This procedure sends a command to the camera and /* This procedure sends a command to the camera and
waits for acknowledgement. Calling procedures have waits for acknowledgement. Calling procedures have
@@ -221,7 +213,7 @@ static int dc210_execute_command
there are three possible follow ups: there are three possible follow ups:
- Read a DC210_COMMAND_COMPLETE in case of - Read a DC210_COMMAND_COMPLETE in case of
simple commands simple commands
- Send an additional command package in case of - Send an additional command package in case of
sophisticated commands sophisticated commands
- Read data from the camera - Read data from the camera
But all this depends on the command and should not But all this depends on the command and should not
@@ -285,9 +277,7 @@ static int dc210_execute_command
/* appropriate actions to a command */ /* appropriate actions to a command */
static int dc210_write_command_packet static int dc210_write_command_packet (Camera * camera, char * data) {
(Camera * camera, char * data)
{
unsigned char checksum; unsigned char checksum;
int i, error; int i, error;
@@ -331,9 +321,8 @@ static int dc210_write_command_packet
}; };
static int dc210_wait_for_response static int dc210_wait_for_response (Camera *camera, int expect_busy, GPContext *context) {
(Camera *camera, int expect_busy, GPContext *context)
{
/* Waits for a command to finish. /* Waits for a command to finish.
Expects either a timeout, a DC210_BUSY, Expects either a timeout, a DC210_BUSY,
a DC210_COMMAND_COMPLETE or a a DC210_COMMAND_COMPLETE or a
@@ -346,155 +335,151 @@ static int dc210_wait_for_response
int progress_id = 0; int progress_id = 0;
if (context) if (context)
progress_id = gp_context_progress_start (context, expect_busy, _("Waiting...")); progress_id = gp_context_progress_start (context, expect_busy, _("Waiting..."));
while (1){ while (1) {
error = dc210_read_single_char(camera, &response); error = dc210_read_single_char(camera, &response);
if (error < 0){ if (error < 0) {
if (context) if (context)
gp_context_progress_stop (context, progress_id); gp_context_progress_stop (context, progress_id);
return error; return error;
}; };
switch (response){ switch (response) {
case DC210_BUSY: case DC210_BUSY:
/* wait a little bit longer */ /* wait a little bit longer */
if (context && counter <= expect_busy) if (context && counter <= expect_busy)
gp_context_progress_update (context, progress_id, counter++); gp_context_progress_update (context, progress_id, counter++);
break; break;
case DC210_COMMAND_COMPLETE: case DC210_COMMAND_COMPLETE:
case DC210_PACKET_FOLLOWING: case DC210_PACKET_FOLLOWING:
if (context) if (context)
gp_context_progress_stop (context, progress_id); gp_context_progress_stop (context, progress_id);
return response; return response;
break; break;
default: default:
if (context) if (context)
gp_context_progress_stop (context, progress_id); gp_context_progress_stop (context, progress_id);
DC210_DEBUG("Command terminated with errorcode 0x%02X.\n", response); DC210_DEBUG("Command terminated with errorcode 0x%02X.\n", response);
return GP_ERROR; return GP_ERROR;
}; };
}; };
}; };
static int dc210_read_single_block static int dc210_read_single_block (Camera *camera, unsigned char * b, int blocksize) {
(Camera *camera, unsigned char * b, int blocksize)
{
int i, k, error; int i, k, error;
char cs_read, cs_computed; char cs_read, cs_computed;
for (i = 0; i < RETRIES; i++){ for (i = 0; i < RETRIES; i++) {
if (dc210_wait_for_response(camera, 0, NULL) != DC210_PACKET_FOLLOWING) if (dc210_wait_for_response(camera, 0, NULL) != DC210_PACKET_FOLLOWING)
return GP_ERROR; return GP_ERROR;
error = 1; error = 1;
for (k = 0; k < RETRIES; k++){ for (k = 0; k < RETRIES; k++) {
if (gp_port_read(camera->port, (char *)b, blocksize) < 0){ if (gp_port_read(camera->port, (char *)b, blocksize) < 0) {
continue; continue;
}; };
error = 0; error = 0;
break; break;
}; };
if (error) return GP_ERROR; if (error) return GP_ERROR;
if (dc210_read_single_char(camera, (unsigned char *)&cs_read) < 0) if (dc210_read_single_char(camera, (unsigned char *)&cs_read) < 0)
return GP_ERROR; return GP_ERROR;
cs_computed = 0; cs_computed = 0;
for (k = 0 ; k < blocksize; k++) for (k = 0; k < blocksize; k++)
cs_computed ^= b[k]; cs_computed ^= b[k];
if (cs_computed == cs_read){ if (cs_computed == cs_read) {
dc210_write_single_char(camera, DC210_CORRECT_PACKET); dc210_write_single_char(camera, DC210_CORRECT_PACKET);
return GP_OK; return GP_OK;
}; };
dc210_write_single_char(camera, DC210_ILLEGAL_PACKET); dc210_write_single_char(camera, DC210_ILLEGAL_PACKET);
}; };
return GP_ERROR; return GP_ERROR;
}; };
static int dc210_read_to_file static int dc210_read_to_file (Camera *camera, CameraFile * f, int blocksize, long int expectsize, GPContext *context) {
(Camera *camera, CameraFile * f, int blocksize, long int expectsize, GPContext *context)
{
int packets, k, l, fatal_error, packet_following; int packets, k, l, fatal_error, packet_following;
unsigned int progress_id = 0; unsigned int progress_id = 0;
unsigned char cs_read, cs_computed; unsigned char cs_read, cs_computed;
unsigned char * b; unsigned char * b;
int blocks = expectsize / blocksize; int blocks = expectsize / blocksize;
int remaining = expectsize % blocksize; int remaining = expectsize % blocksize;
if (NULL == (b = malloc(blocksize))) return GP_ERROR; if (NULL == (b = malloc(blocksize))) return GP_ERROR;
if (remaining) blocks++; if (remaining) blocks++;
if (context) if (context)
progress_id = gp_context_progress_start (context, blocks, _("Getting data...")); progress_id = gp_context_progress_start (context, blocks, _("Getting data..."));
fatal_error = 0; fatal_error = 0;
packets = 0; packets = 0;
packet_following = dc210_wait_for_response(camera, 0, NULL); packet_following = dc210_wait_for_response(camera, 0, NULL);
while (DC210_PACKET_FOLLOWING == packet_following){ while (DC210_PACKET_FOLLOWING == packet_following) {
fatal_error = 1; fatal_error = 1;
for (k = 0; k < RETRIES; k++){ for (k = 0; k < RETRIES; k++) {
/* read packet */ /* read packet */
if (gp_port_read(camera->port, (char *)b, blocksize) < 0){ if (gp_port_read(camera->port, (char *)b, blocksize) < 0) {
dc210_write_single_char(camera, DC210_ILLEGAL_PACKET); dc210_write_single_char(camera, DC210_ILLEGAL_PACKET);
packet_following = dc210_wait_for_response(camera, 0, NULL); packet_following = dc210_wait_for_response(camera, 0, NULL);
continue; continue;
}; };
/* read checksum */ /* read checksum */
if (dc210_read_single_char(camera, &cs_read) == GP_ERROR){ if (dc210_read_single_char(camera, &cs_read) == GP_ERROR) {
free(b); free(b);
return GP_ERROR; return GP_ERROR;
}; };
/* test checksum */ /* test checksum */
cs_computed = 0; cs_computed = 0;
for (l = 0 ; l < blocksize; l++) for (l = 0; l < blocksize; l++)
cs_computed ^= b[l]; cs_computed ^= b[l];
if (cs_computed != cs_read){ if (cs_computed != cs_read) {
dc210_write_single_char(camera, DC210_ILLEGAL_PACKET); dc210_write_single_char(camera, DC210_ILLEGAL_PACKET);
packet_following = dc210_wait_for_response(camera, 0, NULL); packet_following = dc210_wait_for_response(camera, 0, NULL);
continue; continue;
}; };
/* append to file */ /* append to file */
if (packets == blocks - 1 && remaining) if (packets == blocks - 1 && remaining)
gp_file_append(f, (char *)b, remaining); gp_file_append(f, (char *)b, remaining);
else else
gp_file_append(f, (char *)b, blocksize); gp_file_append(f, (char *)b, blocksize);
/* request next packet */ /* request next packet */
dc210_write_single_char(camera, DC210_CORRECT_PACKET); dc210_write_single_char(camera, DC210_CORRECT_PACKET);
packet_following = dc210_wait_for_response(camera, 0, NULL); packet_following = dc210_wait_for_response(camera, 0, NULL);
fatal_error = 0; fatal_error = 0;
if (context) if (context)
gp_context_progress_update (context, progress_id, packets); gp_context_progress_update (context, progress_id, packets);
packets++; packets++;
break; break;
}; };
if (fatal_error) break; if (fatal_error) break;
}; };
if (packet_following < 0) if (packet_following < 0)
fatal_error = 1; fatal_error = 1;
if (context) if (context)
gp_context_progress_stop (context, progress_id); gp_context_progress_stop (context, progress_id);
free(b); free(b);
if (fatal_error) return GP_ERROR; if (fatal_error) return GP_ERROR;
return GP_OK; return GP_OK;
}; };
@@ -506,7 +491,7 @@ static int dc210_read_to_file
/***** Set procedures *****/ /***** Set procedures *****/
static int dc210_set_option (Camera * camera, char command, unsigned int value, int valuesize){ static int dc210_set_option (Camera * camera, char command, unsigned int value, int valuesize) {
char cmd[8]; char cmd[8];
dc210_cmd_init(cmd, command); dc210_cmd_init(cmd, command);
@@ -539,15 +524,15 @@ static int dc210_set_option (Camera * camera, char command, unsigned int value,
}; };
int dc210_set_compression (Camera * camera, dc210_compression_type compression){ int dc210_set_compression (Camera * camera, dc210_compression_type compression) {
return dc210_set_option(camera, DC210_SET_QUALITY, compression, 1); return dc210_set_option(camera, DC210_SET_QUALITY, compression, 1);
}; };
int dc210_set_flash (Camera * camera, dc210_flash_type flash, char preflash){ int dc210_set_flash (Camera * camera, dc210_flash_type flash, char preflash) {
if (flash != DC210_FLASH_NONE && preflash){ if (flash != DC210_FLASH_NONE && preflash) {
return dc210_set_option(camera, DC210_SET_FLASH, flash + 3, 1); return dc210_set_option(camera, DC210_SET_FLASH, flash + 3, 1);
} }
else else
@@ -555,25 +540,25 @@ int dc210_set_flash (Camera * camera, dc210_flash_type flash, char preflash){
}; };
int dc210_set_zoom (Camera * camera, dc210_zoom_type zoom){ int dc210_set_zoom (Camera * camera, dc210_zoom_type zoom) {
return dc210_set_option(camera, DC210_SET_ZOOM, zoom, 1); return dc210_set_option(camera, DC210_SET_ZOOM, zoom, 1);
}; };
int dc210_set_file_type (Camera * camera, dc210_file_type_type file_type){ int dc210_set_file_type (Camera * camera, dc210_file_type_type file_type) {
return dc210_set_option(camera, DC210_SET_FILE_TYPE, file_type, 1); return dc210_set_option(camera, DC210_SET_FILE_TYPE, file_type, 1);
}; };
int dc210_set_resolution (Camera * camera, dc210_resolution_type res){ int dc210_set_resolution (Camera * camera, dc210_resolution_type res) {
return dc210_set_option(camera, DC210_SET_RESOLUTION, res, 1); return dc210_set_option(camera, DC210_SET_RESOLUTION, res, 1);
}; };
int dc210_set_delay (Camera * camera){ int dc210_set_delay (Camera * camera) {
/* This function works, but I do no have the slightest idea, /* This function works, but I do no have the slightest idea,
what the effect is / should be. what the effect is / should be.
@@ -584,7 +569,7 @@ int dc210_set_delay (Camera * camera){
}; };
int dc210_set_exp_compensation (Camera * camera, signed int compensation){ int dc210_set_exp_compensation (Camera * camera, signed int compensation) {
unsigned char param = abs(compensation); unsigned char param = abs(compensation);
@@ -594,100 +579,100 @@ int dc210_set_exp_compensation (Camera * camera, signed int compensation){
}; };
int dc210_system_time_callback (Camera * camera, CameraWidget * widget, GPContext * context){ int dc210_system_time_callback (Camera * camera, CameraWidget * widget, GPContext * context) {
return dc210_set_option(camera, DC210_SET_TIME, (time(NULL) - CAMERA_SET_EPOC) << 1, 4); return dc210_set_option(camera, DC210_SET_TIME, (time(NULL) - CAMERA_SET_EPOC) << 1, 4);
}; };
static int dc210_format_card (Camera * camera, char * album_name, GPContext * context){ static int dc210_format_card (Camera * camera, char * album_name, GPContext * context) {
char data[DC210_CMD_DATA_SIZE]; char data[DC210_CMD_DATA_SIZE];
char cmd[8]; char cmd[8];
char * subst; char * subst;
unsigned char answer[16]; unsigned char answer[16];
unsigned char checksum_read, checksum; unsigned char checksum_read, checksum;
int i; int i;
memset (data, 0, DC210_CMD_DATA_SIZE); memset (data, 0, DC210_CMD_DATA_SIZE);
/* Make the album name acceptable - we need at least 8 characters /* Make the album name acceptable - we need at least 8 characters
which are not blank and there are no blanks allowed before the which are not blank and there are no blanks allowed before the
last character. last character.
*/ */
if (album_name != NULL && strlen(album_name) > 0){ if (album_name != NULL && strlen(album_name) > 0) {
strncpy(data, album_name, 11); strncpy(data, album_name, 11);
/* substitute blanks in the first 8 characters*/ /* substitute blanks in the first 8 characters*/
while (NULL != (subst = strchr(data, ' '))) *subst = '_'; while (NULL != (subst = strchr(data, ' '))) *subst = '_';
if (strlen(data) < 8) strncat(data, "________", 8 - strlen(data)); if (strlen(data) < 8) strncat(data, "________", 8 - strlen(data));
}; };
DC210_DEBUG("Album name is '%s'\n", data); DC210_DEBUG("Album name is '%s'\n", data);
dc210_cmd_init(cmd, DC210_CARD_FORMAT); dc210_cmd_init(cmd, DC210_CARD_FORMAT);
dc210_execute_command(camera, cmd); dc210_execute_command(camera, cmd);
dc210_write_command_packet(camera, data); dc210_write_command_packet(camera, data);
if (dc210_wait_for_response(camera, 3, context) != DC210_PACKET_FOLLOWING) return GP_ERROR; if (dc210_wait_for_response(camera, 3, context) != DC210_PACKET_FOLLOWING) return GP_ERROR;
gp_port_read(camera->port, (char *)answer, 16); gp_port_read(camera->port, (char *)answer, 16);
gp_port_read(camera->port, (char *)&checksum_read, 1); gp_port_read(camera->port, (char *)&checksum_read, 1);
checksum = 0; checksum = 0;
for (i = 0; i < 16; i++) checksum ^= answer[i]; for (i = 0; i < 16; i++) checksum ^= answer[i];
if (checksum_read != checksum) return GP_ERROR; if (checksum_read != checksum) return GP_ERROR;
DC210_DEBUG("Flash card formatted.\n"); DC210_DEBUG("Flash card formatted.\n");
if (dc210_write_single_char(camera, DC210_CORRECT_PACKET) == GP_ERROR) return GP_ERROR; if (dc210_write_single_char(camera, DC210_CORRECT_PACKET) == GP_ERROR) return GP_ERROR;
if (dc210_wait_for_response(camera, 0, NULL) != DC210_COMMAND_COMPLETE) return GP_ERROR; if (dc210_wait_for_response(camera, 0, NULL) != DC210_COMMAND_COMPLETE) return GP_ERROR;
gp_filesystem_reset(camera->fs); gp_filesystem_reset(camera->fs);
return GP_OK; return GP_OK;
}; };
static int dc210_get_card_status (Camera * camera, dc210_card_status * card_status){ static int dc210_get_card_status (Camera * camera, dc210_card_status * card_status) {
char cmd[8]; char cmd[8];
unsigned char answer[16]; unsigned char answer[16];
unsigned char checksum_read, checksum; unsigned char checksum_read, checksum;
int i; int i;
card_status->open = 0; card_status->open = 0;
card_status->program = 0; card_status->program = 0;
card_status->space = 0; card_status->space = 0;
dc210_cmd_init(cmd, DC210_CARD_STATUS); dc210_cmd_init(cmd, DC210_CARD_STATUS);
dc210_execute_command(camera, cmd); dc210_execute_command(camera, cmd);
if (dc210_wait_for_response(camera, 0, NULL) != DC210_PACKET_FOLLOWING) return GP_ERROR; if (dc210_wait_for_response(camera, 0, NULL) != DC210_PACKET_FOLLOWING) return GP_ERROR;
gp_port_read(camera->port, (char *)answer, 16); gp_port_read(camera->port, (char *)answer, 16);
gp_port_read(camera->port, (char *)&checksum_read, 1); gp_port_read(camera->port, (char *)&checksum_read, 1);
checksum = 0; checksum = 0;
for (i = 0; i < 16; i++) checksum ^= answer[i]; for (i = 0; i < 16; i++) checksum ^= answer[i];
if (checksum_read != checksum) if (checksum_read != checksum)
DC210_DEBUG("Error reading card status.\n"); DC210_DEBUG("Error reading card status.\n");
else else
DC210_DEBUG("Card status correctly read.\n"); DC210_DEBUG("Card status correctly read.\n");
if (answer[0] & 0x08) card_status->open = 1; if (answer[0] & 0x08) card_status->open = 1;
DC210_DEBUG("Card status open is %d\n", card_status->open); DC210_DEBUG("Card status open is %d\n", card_status->open);
card_status->program = answer[1] * 0x100 + answer[2]; card_status->program = answer[1] * 0x100 + answer[2];
/* set the space in kb */ /* set the space in kb */
card_status->space = (answer[3] * 0x1000000 + answer[4] * 0x10000 + answer[5] * 0x100 + answer[6]) / 1024; card_status->space = (answer[3] * 0x1000000 + answer[4] * 0x10000 + answer[5] * 0x100 + answer[6]) / 1024;
if (dc210_write_single_char(camera, DC210_CORRECT_PACKET) == GP_ERROR) return GP_ERROR; if (dc210_write_single_char(camera, DC210_CORRECT_PACKET) == GP_ERROR) return GP_ERROR;
if (dc210_wait_for_response(camera, 0, NULL) != DC210_COMMAND_COMPLETE) return GP_ERROR; if (dc210_wait_for_response(camera, 0, NULL) != DC210_COMMAND_COMPLETE) return GP_ERROR;
return GP_OK; return GP_OK;
}; };
int dc210_format_callback(Camera * camera, CameraWidget * widget, GPContext * context){ int dc210_format_callback(Camera * camera, CameraWidget * widget, GPContext * context) {
CameraWidget * window; CameraWidget * window;
char * album_name; char * album_name;
@@ -701,19 +686,19 @@ int dc210_format_callback(Camera * camera, CameraWidget * widget, GPContext * co
}; };
static int dc210_check_battery (Camera *camera){ static int dc210_check_battery (Camera *camera) {
char cmd[8]; char cmd[8];
dc210_cmd_init(cmd, DC210_CHECK_BATTERY); dc210_cmd_init(cmd, DC210_CHECK_BATTERY);
if (dc210_execute_command(camera, cmd) == GP_ERROR) return GP_ERROR; if (dc210_execute_command(camera, cmd) == GP_ERROR) return GP_ERROR;
if (dc210_wait_for_response(camera, 0, NULL) != DC210_COMMAND_COMPLETE) return GP_ERROR; if (dc210_wait_for_response(camera, 0, NULL) != DC210_COMMAND_COMPLETE) return GP_ERROR;
return GP_OK; return GP_OK;
}; };
int dc210_init_port (Camera *camera){ int dc210_init_port (Camera *camera) {
/* sending a break command resets the /* sending a break command resets the
speed to 9600 */ speed to 9600 */
@@ -820,27 +805,24 @@ int dc210_set_speed (Camera *camera, int speed) {
/****** Picture actions *****/ /****** Picture actions *****/
int dc210_take_picture int dc210_take_picture (Camera * camera, GPContext * context)
(Camera * camera, GPContext * context)
{ {
char cmd[8]; char cmd[8];
dc210_cmd_init(cmd, DC210_TAKE_PICTURE); dc210_cmd_init(cmd, DC210_TAKE_PICTURE);
if (dc210_execute_command(camera, cmd) == GP_ERROR) return GP_ERROR; if (dc210_execute_command(camera, cmd) == GP_ERROR) return GP_ERROR;
switch (dc210_wait_for_response(camera, 5, context)){ switch (dc210_wait_for_response(camera, 5, context)) {
/* we allow a timeout error here and check the result via status */ /* we allow a timeout error here and check the result via status */
case DC210_COMMAND_COMPLETE: case DC210_COMMAND_COMPLETE:
case GP_ERROR_TIMEOUT: return GP_OK; break; case GP_ERROR_TIMEOUT: return GP_OK; break;
default: return GP_ERROR; break; default: return GP_ERROR; break;
}; };
return GP_ERROR; return GP_ERROR;
}; };
int dc210_delete_picture int dc210_delete_picture (Camera * camera, unsigned int picno) {
(Camera * camera, unsigned int picno)
{
char cmd[8]; char cmd[8];
unsigned int pic_offset = picno - 1; unsigned int pic_offset = picno - 1;
@@ -856,27 +838,23 @@ int dc210_delete_picture
}; };
int dc210_delete_last_picture int dc210_delete_last_picture (Camera * camera) {
(Camera * camera )
{
dc210_status status; dc210_status status;
if (dc210_get_status(camera, &status) == GP_ERROR) if (dc210_get_status(camera, &status) == GP_ERROR)
return GP_ERROR; return GP_ERROR;
if (0 == status.numPicturesInCamera) if (0 == status.numPicturesInCamera)
return GP_ERROR; return GP_ERROR;
return dc210_delete_picture(camera, status.numPicturesInCamera); return dc210_delete_picture(camera, status.numPicturesInCamera);
}; };
int dc210_delete_picture_by_name int dc210_delete_picture_by_name (Camera * camera, const char * filename ) {
(Camera * camera, const char * filename )
{
char cmd[8]; char cmd[8];
char cmd_packet[DC210_CMD_DATA_SIZE]; char cmd_packet[DC210_CMD_DATA_SIZE];
dc210_cmd_init(cmd, DC210_CARD_FILE_DEL); dc210_cmd_init(cmd, DC210_CARD_FILE_DEL);
@@ -887,12 +865,9 @@ int dc210_delete_picture_by_name
if (dc210_wait_for_response(camera, 0, NULL) != DC210_COMMAND_COMPLETE) return GP_ERROR; if (dc210_wait_for_response(camera, 0, NULL) != DC210_COMMAND_COMPLETE) return GP_ERROR;
return GP_OK; return GP_OK;
}; };
int dc210_download_last_picture int dc210_download_last_picture (Camera * camera, CameraFile *file, dc210_picture_type type, GPContext *context) {
(Camera * camera, CameraFile *file, dc210_picture_type type, GPContext *context)
{
dc210_status status; dc210_status status;
dc210_picture_info picinfo; dc210_picture_info picinfo;
@@ -910,9 +885,7 @@ int dc210_download_last_picture
}; };
int dc210_open_card int dc210_open_card (Camera * camera) {
(Camera * camera)
{
char cmd[8]; char cmd[8];
dc210_card_status card_status; dc210_card_status card_status;
@@ -944,11 +917,9 @@ static int dc210_close_card
}; };
#endif #endif
int dc210_download_picture_by_name int dc210_download_picture_by_name (Camera * camera, CameraFile *file, const char *filename, dc210_picture_type type, GPContext *context) {
(Camera * camera, CameraFile *file, const char *filename, dc210_picture_type type, GPContext *context)
{
char cmd[8]; char cmd[8];
char cmd_packet[DC210_CMD_DATA_SIZE]; char cmd_packet[DC210_CMD_DATA_SIZE];
dc210_picture_info picinfo; dc210_picture_info picinfo;

View File

@@ -57,7 +57,7 @@ static const struct camera_to_usb {
{ "Kodak:DC280", 0x040A, 0x0130 }, { "Kodak:DC280", 0x040A, 0x0130 },
{ "Kodak:DC3400", 0x040A, 0x0132 }, { "Kodak:DC3400", 0x040A, 0x0132 },
{ "Kodak:DC5000", 0x040A, 0x0131 }, { "Kodak:DC5000", 0x040A, 0x0131 },
{ NULL, 0, 0 } { NULL, 0, 0 }
}; };
/* /*
@@ -69,29 +69,29 @@ int
camera_abilities (CameraAbilitiesList *list) camera_abilities (CameraAbilitiesList *list)
{ {
CameraAbilities a; CameraAbilities a;
int i; int i;
for (i = 0; camera_to_usb[i].name; i++) for (i = 0; camera_to_usb[i].name; i++)
{ {
memset (&a, 0, sizeof (a)); memset (&a, 0, sizeof (a));
strcpy(a.model, camera_to_usb[i].name); strcpy(a.model, camera_to_usb[i].name);
a.status = GP_DRIVER_STATUS_PRODUCTION; a.status = GP_DRIVER_STATUS_PRODUCTION;
a.port = GP_PORT_SERIAL | GP_PORT_USB; a.port = GP_PORT_SERIAL | GP_PORT_USB;
a.speed[0] = 9600; a.speed[0] = 9600;
a.speed[1] = 19200; a.speed[1] = 19200;
a.speed[2] = 38400; a.speed[2] = 38400;
a.speed[3] = 57600; a.speed[3] = 57600;
a.speed[4] = 115200; a.speed[4] = 115200;
a.speed[5] = 0; a.speed[5] = 0;
a.usb_vendor = camera_to_usb[i].idVendor; a.usb_vendor = camera_to_usb[i].idVendor;
a.usb_product = camera_to_usb[i].idProduct; a.usb_product = camera_to_usb[i].idProduct;
a.operations = GP_OPERATION_CAPTURE_IMAGE; a.operations = GP_OPERATION_CAPTURE_IMAGE;
a.file_operations = GP_FILE_OPERATION_DELETE | a.file_operations = GP_FILE_OPERATION_DELETE |
GP_FILE_OPERATION_PREVIEW; GP_FILE_OPERATION_PREVIEW;
a.folder_operations = GP_FOLDER_OPERATION_NONE; a.folder_operations = GP_FOLDER_OPERATION_NONE;
gp_abilities_list_append(list, a); gp_abilities_list_append(list, a);
} }
return (GP_OK); return (GP_OK);
} }
@@ -148,7 +148,7 @@ delete_file_func (CameraFilesystem *fs, const char *folder,
Camera *camera = data; Camera *camera = data;
return (dc240_file_action (camera, DC240_ACTION_DELETE, NULL, folder, return (dc240_file_action (camera, DC240_ACTION_DELETE, NULL, folder,
filename, context)); filename, context));
} }
static int static int
@@ -176,38 +176,38 @@ camera_capture (Camera *camera, CameraCaptureType type,
static int static int
camera_summary (Camera *camera, CameraText *summary, GPContext *context) camera_summary (Camera *camera, CameraText *summary, GPContext *context)
{ {
char buf [32 * 1024]; char buf[32 * 1024];
char temp [1024]; char temp[1024];
int retval; int retval;
DC240StatusTable table; DC240StatusTable table;
retval = dc240_get_status (camera, &table, context); retval = dc240_get_status (camera, &table, context);
if (retval == GP_OK) { if (retval == GP_OK) {
sprintf (buf, _("Model: Kodak %s\n"), dc240_convert_type_to_camera(table.cameraType)); sprintf (buf, _("Model: Kodak %s\n"), dc240_convert_type_to_camera(table.cameraType));
sprintf (temp, _("Firmware version: %d.%02d\n"), table.fwVersInt, table.fwVersDec); sprintf (temp, _("Firmware version: %d.%02d\n"), table.fwVersInt, table.fwVersDec);
strcat (buf, temp); strcat (buf, temp);
sprintf (temp, _("Battery status: %s, AC Adapter: %s\n"), sprintf (temp, _("Battery status: %s, AC Adapter: %s\n"),
dc240_get_battery_status_str(table.battStatus), dc240_get_battery_status_str(table.battStatus),
dc240_get_ac_status_str(table.acAdapter)); dc240_get_ac_status_str(table.acAdapter));
strcat (buf, temp); strcat (buf, temp);
sprintf (temp, _("Number of pictures: %d\n"), table.numPict); sprintf (temp, _("Number of pictures: %d\n"), table.numPict);
strcat (buf, temp); strcat (buf, temp);
sprintf (temp, _("Space remaining: High: %d, Medium: %d, Low: %d\n"), sprintf (temp, _("Space remaining: High: %d, Medium: %d, Low: %d\n"),
table.remPictHigh, table.remPictMed, table.remPictLow); table.remPictHigh, table.remPictMed, table.remPictLow);
strcat (buf, temp); strcat (buf, temp);
sprintf (temp, _("Memory card status (%d): %s\n"), table.memCardStatus, sprintf (temp, _("Memory card status (%d): %s\n"), table.memCardStatus,
dc240_get_memcard_status_str(table.memCardStatus)); dc240_get_memcard_status_str(table.memCardStatus));
strcat (buf, temp); strcat (buf, temp);
sprintf (temp, _("Total pictures captured: %d, Flashes fired: %d\n"), sprintf (temp, _("Total pictures captured: %d, Flashes fired: %d\n"),
table.totalPictTaken, table.totalStrobeFired); table.totalPictTaken, table.totalStrobeFired);
strcat (buf, temp); strcat (buf, temp);
strcpy(summary->text, buf); strcpy(summary->text, buf);
} }
return retval; return retval;
} }
static int static int

View File

@@ -478,23 +478,23 @@ int camera_init (Camera *camera, GPContext *context)
if (!camera->pl) if (!camera->pl)
return (GP_ERROR_NO_MEMORY); return (GP_ERROR_NO_MEMORY);
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->exit = camera_exit; camera->functions->exit = camera_exit;
camera->functions->manual = camera_manual; camera->functions->manual = camera_manual;
camera->functions->about = camera_about; camera->functions->about = camera_about;
/* Set up the CameraFilesystem */ /* Set up the CameraFilesystem */
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
/* initialize the camera */ /* initialize the camera */
ret = init (camera); ret = init (camera);
if (ret < 0) { if (ret < 0) {
free (camera->pl); free (camera->pl);
camera->pl = NULL; camera->pl = NULL;
return (ret); return (ret);
} }
ret = dc3200_keep_alive (camera); ret = dc3200_keep_alive (camera);
if (ret < 0) { if (ret < 0) {
free (camera->pl); free (camera->pl);
camera->pl = NULL; camera->pl = NULL;

View File

@@ -195,9 +195,9 @@ int dc3200_setup(Camera *camera)
*/ */
/* command to get the picture /* command to get the picture
unsigned char get_pkt[DEF_PACKET_LEN] = {0x01, calc_seqnum(), 0x80, 0x00, 0x20, 0x03, 26 + strlen(filename), unsigned char get_pkt[DEF_PACKET_LEN] = {0x01, calc_seqnum(), 0x80, 0x00, 0x20, 0x03, 26 + strlen(filename),
0xC1, 0x50, 0x00, 0x00, 0x00, 0x00, 19 + strlen(filename), 0xC1, 0x50, 0x00, 0x00, 0x00, 0x00, 19 + strlen(filename),
0x04, 0x01, 0x00, 0x01, 0x01, 0x04, 0x60, 0x10, 0x00, 0x01, 0x00, 0x05, 0x04, 0x01, 0x00, 0x01, 0x01, 0x04, 0x60, 0x10, 0x00, 0x01, 0x00, 0x05,
0x00, 0x00, 0x00, 2 + strlen(filename), 0x01}; 0x00, 0x00, 0x00, 2 + strlen(filename), 0x01};
*/ */
int dc3200_get_data(Camera *camera, unsigned char **data, unsigned long *data_len, int command, const char *folder, const char *filename) int dc3200_get_data(Camera *camera, unsigned char **data, unsigned long *data_len, int command, const char *folder, const char *filename)

View File

@@ -75,7 +75,7 @@ ez200_init (GPPort *port, Model *model, Info *info) {
READ(port, PICTURE, 0, 0, &c, 1); READ(port, PICTURE, 0, 0, &c, 1);
memcpy (info, &c, 1); memcpy (info, &c, 1);
GP_DEBUG("number of pics : %i", c); GP_DEBUG("number of pics : %i", c);
return GP_OK; return GP_OK;
} }
/* quit photo mode */ /* quit photo mode */
@@ -91,7 +91,7 @@ ez200_exit (GPPort *port) {
static int static int
ez200_get_picture_size (GPPort *port, int n) { ez200_get_picture_size (GPPort *port, int n) {
unsigned char c[4]; unsigned char c[4];
unsigned int size = 0; unsigned int size = 0;
memset (c,0,sizeof(c)); memset (c,0,sizeof(c));
GP_DEBUG("Running ez200_get_picture_size"); GP_DEBUG("Running ez200_get_picture_size");
@@ -112,12 +112,12 @@ ez200_read_data (GPPort *port, char *data, int size) {
/* Read Data by blocks */ /* Read Data by blocks */
while(size > 0) { while(size > 0) {
int len = (size>MAX_BULK)?MAX_BULK:size; int len = (size>MAX_BULK)?MAX_BULK:size;
ret = gp_port_read (port, data, len); ret = gp_port_read (port, data, len);
if (ret < GP_OK) return ret; if (ret < GP_OK) return ret;
data += len; data += len;
size -= len; size -= len;
} }
return GP_OK; return GP_OK;
} }
static int static int
@@ -126,8 +126,8 @@ ez200_read_picture_data (GPPort *port, char *data, int size, int n) {
memset(c,0,sizeof(c)); memset(c,0,sizeof(c));
/* ask picture n transfert */ /* ask picture n transfert */
READ(port, PICTURE, n, 1, c, 3); READ(port, PICTURE, n, 1, c, 3);
return ez200_read_data (port, data, size); return ez200_read_data (port, data, size);
} }
@@ -145,55 +145,55 @@ struct _CameraPrivateLibrary {
}; };
static const struct { static const struct {
char *name; char *name;
CameraDriverStatus status; CameraDriverStatus status;
unsigned short idVendor; unsigned short idVendor;
unsigned short idProduct; unsigned short idProduct;
} models[] = { } models[] = {
{"Kodak EZ200", GP_DRIVER_STATUS_PRODUCTION, 0x040a, 0x0300}, {"Kodak EZ200", GP_DRIVER_STATUS_PRODUCTION, 0x040a, 0x0300},
{NULL,0,0,0} {NULL,0,0,0}
}; };
int int
camera_id (CameraText *id) camera_id (CameraText *id)
{ {
strcpy (id->text, "Kodak EZ200 camera"); strcpy (id->text, "Kodak EZ200 camera");
return GP_OK; return GP_OK;
} }
int int
camera_abilities (CameraAbilitiesList *list) camera_abilities (CameraAbilitiesList *list)
{ {
int i; int i;
CameraAbilities a; CameraAbilities a;
for (i = 0; models[i].name; i++) { for (i = 0; models[i].name; i++) {
memset (&a, 0, sizeof(a)); memset (&a, 0, sizeof(a));
strcpy (a.model, models[i].name); strcpy (a.model, models[i].name);
a.status = models[i].status; a.status = models[i].status;
a.port = GP_PORT_USB; a.port = GP_PORT_USB;
a.usb_vendor = models[i].idVendor; a.usb_vendor = models[i].idVendor;
a.usb_product= models[i].idProduct; a.usb_product= models[i].idProduct;
a.operations = GP_OPERATION_NONE; a.operations = GP_OPERATION_NONE;
a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL; a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL;
a.file_operations = GP_FILE_OPERATION_NONE; a.file_operations = GP_FILE_OPERATION_NONE;
gp_abilities_list_append (list, a); gp_abilities_list_append (list, a);
} }
return GP_OK; return GP_OK;
} }
static int static int
camera_summary (Camera *camera, CameraText *summary, GPContext *context) { camera_summary (Camera *camera, CameraText *summary, GPContext *context) {
sprintf (summary->text,_("Your USB camera is a Kodak EZ200.\n" sprintf (summary->text, _("Your USB camera is a Kodak EZ200.\n"
"Number of PICs = %i\n" "Number of PICs = %i\n"
), ez200_get_num_pics(camera->pl->info)); ), ez200_get_num_pics(camera->pl->info));
return GP_OK; return GP_OK;
} }
static int static int
camera_about (Camera *camera, CameraText *about, GPContext *context) { camera_about (Camera *camera, CameraText *about, GPContext *context) {
strcpy (about->text, _("Kodak EZ200 driver\nBucas Jean-Francois <jfbucas@tuxfamily.org>\n")); strcpy (about->text, _("Kodak EZ200 driver\nBucas Jean-Francois <jfbucas@tuxfamily.org>\n"));
return GP_OK; return GP_OK;
} }
/* /*
@@ -207,19 +207,18 @@ camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path,
WRITE(camera->port,0,0x8003,0,NULL,0); WRITE(camera->port,0,0x8003,0,NULL,0);
WRITE(camera->port,5,0x0000,0,NULL,0); WRITE(camera->port,5,0x0000,0,NULL,0);
return GP_OK; return GP_OK;
} }
*/ */
static int static int
delete_all_func (CameraFilesystem *fs, const char *folder, void *data, delete_all_func (CameraFilesystem *fs, const char *folder, void *data, GPContext *context) {
GPContext *context) { Camera *camera = data;
Camera *camera = data;
WRITE (camera->port, ERASE, 0, 1, NULL, 0); WRITE (camera->port, ERASE, 0, 1, NULL, 0);
ez200_wait_status_ok(camera->port); ez200_wait_status_ok(camera->port);
return GP_OK; return GP_OK;
} }
static int static int
@@ -235,8 +234,8 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
CameraFileType type, CameraFile *file, void *user_data, CameraFileType type, CameraFile *file, void *user_data,
GPContext *context) GPContext *context)
{ {
Camera *camera = user_data; Camera *camera = user_data;
int n, len, ret; int n, len, ret;
char *data, *data_start; char *data, *data_start;
n = gp_filesystem_number(camera->fs, "/", filename, context); n = gp_filesystem_number(camera->fs, "/", filename, context);
@@ -253,7 +252,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
data_start = data + (HEADER_SIZE - DATA_HEADER_SIZE); data_start = data + (HEADER_SIZE - DATA_HEADER_SIZE);
GP_DEBUG("data - data_start : %p %p : %lx",data, data_start, (long) (data_start - data)); GP_DEBUG("data - data_start : %p %p : %lx",data, data_start, (long) (data_start - data));
ret = ez200_read_picture_data (camera->port, data_start, len, n); ret = ez200_read_picture_data (camera->port, data_start, len, n);
if (ret < GP_OK) return ret; if (ret < GP_OK) return ret;
ret = ez200_read_picture_header (camera->port, data); ret = ez200_read_picture_header (camera->port, data);
if (ret < GP_OK) return ret; if (ret < GP_OK) return ret;
@@ -326,7 +325,7 @@ camera_init(Camera *camera, GPContext *context)
GP_DEBUG("inep = %x", settings.usb.inep); GP_DEBUG("inep = %x", settings.usb.inep);
GP_DEBUG("outep = %x", settings.usb.outep); GP_DEBUG("outep = %x", settings.usb.outep);
/* Tell the CameraFilesystem where to get lists from */ /* Tell the CameraFilesystem where to get lists from */
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
camera->pl = calloc (1, sizeof (CameraPrivateLibrary)); camera->pl = calloc (1, sizeof (CameraPrivateLibrary));

File diff suppressed because it is too large Load Diff

View File

@@ -429,11 +429,11 @@ while (read < rbs_internal) {
* these, it now downloads images etc. * these, it now downloads images etc.
*/ */
#ifndef LESSER_ESCAPES #ifndef LESSER_ESCAPES
if ((*buf == STX) || (*buf == ETX) || (*buf == ENQ ) || if ((*buf == STX) || (*buf == ETX) || (*buf == ENQ) ||
(*buf == ACK) || (*buf == XOFF) || (*buf == XON) || (*buf == ACK) || (*buf == XOFF) || (*buf == XON) ||
(*buf == NACK) || (*buf == ETB)) { (*buf == NACK) || (*buf == ETB)) {
#else /* LESSER_ESCAPES */ #else /* LESSER_ESCAPES */
if ((*buf == STX) || (*buf == XOFF) || (*buf == XON)) { if ((*buf == STX) || (*buf == XOFF) || (*buf == XON)) {
#endif /* LESSER_ESCAPES */ #endif /* LESSER_ESCAPES */
GP_DEBUG ("Wrong ESC masking!"); GP_DEBUG ("Wrong ESC masking!");
error_flag = 1; error_flag = 1;
@@ -610,7 +610,7 @@ l_send_receive (
/* Send data. */ /* Send data. */
CHECK (l_send (p, c, send_buffer, send_buffer_size)); CHECK (l_send (p, c, send_buffer, send_buffer_size));
/* Receive data. */ /* Receive data. */
if (image_buffer_size) if (image_buffer_size)
*receive_buffer_size = *image_buffer_size; *receive_buffer_size = *image_buffer_size;
CHECK (l_receive (p, c, receive_buffer, receive_buffer_size, CHECK (l_receive (p, c, receive_buffer, receive_buffer_size,
@@ -620,7 +620,7 @@ l_send_receive (
if ((*receive_buffer_size > 1) && if ((*receive_buffer_size > 1) &&
(((*receive_buffer)[0] == send_buffer[0]) && (((*receive_buffer)[0] == send_buffer[0]) &&
((*receive_buffer)[1] == send_buffer[1]))) ((*receive_buffer)[1] == send_buffer[1])))
return (GP_OK); return (GP_OK);
/* We didn't receive control data yet. */ /* We didn't receive control data yet. */
*image_buffer = *receive_buffer; *image_buffer = *receive_buffer;

View File

@@ -337,7 +337,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
GP_DEBUG ("*** ENTER: get_file_func ***"); GP_DEBUG ("*** ENTER: get_file_func ***");
image_no = gp_filesystem_number(fs, folder, filename, context); image_no = gp_filesystem_number(fs, folder, filename, context);
if (image_no < 0) return image_no; if (image_no < 0) return image_no;
/* Search the image informations */ /* Search the image informations */
@@ -425,7 +425,7 @@ delete_file_func (CameraFilesystem *fs, const char *folder,
GP_DEBUG ("*** ENTER: delete_file_func ***"); GP_DEBUG ("*** ENTER: delete_file_func ***");
image_no = gp_filesystem_number(fs, folder, filename, context); image_no = gp_filesystem_number(fs, folder, filename, context);
if (image_no < 0) return image_no; if (image_no < 0) return image_no;
image_no++; image_no++;
@@ -676,7 +676,7 @@ get_info_func (CameraFilesystem *fs, const char *folder, const char *filename,
GP_DEBUG ("*** ENTER: get_info_func ***"); GP_DEBUG ("*** ENTER: get_info_func ***");
image_no = gp_filesystem_number(fs, folder, filename, context); image_no = gp_filesystem_number(fs, folder, filename, context);
if (image_no < 0) if (image_no < 0)
return image_no; return image_no;
image_no++; image_no++;
@@ -723,8 +723,8 @@ camera_get_config (Camera* camera, CameraWidget** window, GPContext *context)
{ {
unsigned char cmd[2], buf[INFO_BUFFER]; unsigned char cmd[2], buf[INFO_BUFFER];
int ret; int ret;
CameraWidget *widget; CameraWidget *widget;
CameraWidget *section; CameraWidget *section;
time_t timestamp=0; time_t timestamp=0;
float value_float; float value_float;
@@ -753,357 +753,354 @@ camera_get_config (Camera* camera, CameraWidget** window, GPContext *context)
/* Window creation */ /* Window creation */
gp_widget_new (GP_WIDGET_WINDOW, _("Konica Configuration"), window); gp_widget_new (GP_WIDGET_WINDOW, _("Konica Configuration"), window);
/************************/ /************************/
/* Persistent Settings */ /* Persistent Settings */
/************************/ /************************/
gp_widget_new (GP_WIDGET_SECTION, _("Persistent Settings"), &section); gp_widget_new (GP_WIDGET_SECTION, _("Persistent Settings"), &section);
gp_widget_append (*window, section); gp_widget_append (*window, section);
/* Date */ /* Date */
gp_widget_new (GP_WIDGET_DATE, _("Date and Time"), &widget); gp_widget_new (GP_WIDGET_DATE, _("Date and Time"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_set_value (widget, &timestamp); gp_widget_set_value (widget, &timestamp);
/* Auto Off Time */ /* Auto Off Time */
gp_widget_new (GP_WIDGET_RANGE, _("Auto Off Time"), &widget); gp_widget_new (GP_WIDGET_RANGE, _("Auto Off Time"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_set_range (widget, 1, 255, 1); gp_widget_set_range (widget, 1, 255, 1);
value_float = ((buf[AUTO_OFF_PTR] << 8) + buf[AUTO_OFF_PTR+1]) / 60; value_float = ((buf[AUTO_OFF_PTR] << 8) + buf[AUTO_OFF_PTR+1]) / 60;
gp_widget_set_value (widget, &value_float); gp_widget_set_value (widget, &value_float);
/* Resolution */ /* Resolution */
gp_widget_new (GP_WIDGET_RADIO, _("Resolution"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("Resolution"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("Low")); gp_widget_add_choice (widget, _("Low"));
gp_widget_add_choice (widget, _("Medium")); gp_widget_add_choice (widget, _("Medium"));
gp_widget_add_choice (widget, _("High")); gp_widget_add_choice (widget, _("High"));
switch (buf[RESOLUTION_PTR]) { switch (buf[RESOLUTION_PTR]) {
case 1: case 1:
gp_widget_set_value (widget, _("High")); gp_widget_set_value (widget, _("High"));
break; break;
case 2: case 2:
gp_widget_set_value (widget, _("Low")); gp_widget_set_value (widget, _("Low"));
break; break;
case 0: case 0:
gp_widget_set_value (widget, _("Medium")); gp_widget_set_value (widget, _("Medium"));
break; break;
} }
/* LCD */ /* LCD */
gp_widget_new (GP_WIDGET_RADIO, _("LCD"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("LCD"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("On")); gp_widget_add_choice (widget, _("On"));
gp_widget_add_choice (widget, _("Off")); gp_widget_add_choice (widget, _("Off"));
switch (buf[LCD_STATE_PTR]) { switch (buf[LCD_STATE_PTR]) {
case 0: case 0:
gp_widget_set_value (widget, _("On")); gp_widget_set_value (widget, _("On"));
break; break;
case 1: case 1:
gp_widget_set_value (widget, _("Off")); gp_widget_set_value (widget, _("Off"));
break; break;
} }
/* Icons */ /* Icons */
gp_widget_new (GP_WIDGET_RADIO, _("Icons"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("Icons"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("On")); gp_widget_add_choice (widget, _("On"));
gp_widget_add_choice (widget, _("Off")); gp_widget_add_choice (widget, _("Off"));
switch (buf[ICON_STATE_PTR]) { switch (buf[ICON_STATE_PTR]) {
case 0: case 0:
gp_widget_set_value (widget, _("On")); gp_widget_set_value (widget, _("On"));
break; break;
case 1: case 1:
gp_widget_set_value (widget, _("Off")); gp_widget_set_value (widget, _("Off"));
break; break;
} }
/****************/ /****************/
/* Localization */ /* Localization */
/****************/ /****************/
gp_widget_new (GP_WIDGET_SECTION, _("Localization"), &section); gp_widget_new (GP_WIDGET_SECTION, _("Localization"), &section);
gp_widget_append (*window, section); gp_widget_append (*window, section);
/* Date format */ /* Date format */
gp_widget_new (GP_WIDGET_MENU, _("Date Format"), &widget); gp_widget_new (GP_WIDGET_MENU, _("Date Format"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("Month/Day/Year")); gp_widget_add_choice (widget, _("Month/Day/Year"));
gp_widget_add_choice (widget, _("Day/Month/Year")); gp_widget_add_choice (widget, _("Day/Month/Year"));
gp_widget_add_choice (widget, _("Year/Month/Day")); gp_widget_add_choice (widget, _("Year/Month/Day"));
switch (buf[DATE_FORMAT_PTR]) { switch (buf[DATE_FORMAT_PTR]) {
case 0: case 0:
gp_widget_set_value (widget, _("Month/Day/Year")); gp_widget_set_value (widget, _("Month/Day/Year"));
break; break;
case 1: case 1:
gp_widget_set_value (widget, _("Day/Month/Year")); gp_widget_set_value (widget, _("Day/Month/Year"));
break; break;
case 2: case 2:
gp_widget_set_value (widget, _("Year/Month/Day")); gp_widget_set_value (widget, _("Year/Month/Day"));
break; break;
} }
/********************************/ /********************************/
/* Session-persistent Settings */ /* Session-persistent Settings */
/********************************/ /********************************/
gp_widget_new (GP_WIDGET_SECTION, _("Session-persistent Settings"), gp_widget_new (GP_WIDGET_SECTION, _("Session-persistent Settings"),
&section); &section);
gp_widget_append (*window, section); gp_widget_append (*window, section);
/* Flash */ /* Flash */
gp_widget_new (GP_WIDGET_RADIO, _("Flash"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("Flash"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("Off")); gp_widget_add_choice (widget, _("Off"));
gp_widget_add_choice (widget, _("On")); gp_widget_add_choice (widget, _("On"));
gp_widget_add_choice (widget, _("On, red-eye reduction")); gp_widget_add_choice (widget, _("On, red-eye reduction"));
gp_widget_add_choice (widget, _("Auto")); gp_widget_add_choice (widget, _("Auto"));
gp_widget_add_choice (widget, _("Auto, red-eye reduction")); gp_widget_add_choice (widget, _("Auto, red-eye reduction"));
switch (buf[FLASH_STATE_PTR]) { switch (buf[FLASH_STATE_PTR]) {
case 2: case 2:
gp_widget_set_value (widget, _("Off")); gp_widget_set_value (widget, _("Off"));
break; break;
case 1: case 1:
if (buf[RED_EYE_STATE_PTR] == 1) if (buf[RED_EYE_STATE_PTR] == 1)
gp_widget_set_value (widget, gp_widget_set_value (widget, _("On, red-eye reduction"));
_("On, red-eye reduction")); else
else gp_widget_set_value (widget, _("On"));
gp_widget_set_value (widget, _("On")); break;
break; case 0:
case 0: if (buf[RED_EYE_STATE_PTR] == 1)
if (buf[RED_EYE_STATE_PTR] == 1) gp_widget_set_value (widget, _("Auto, red-eye reduction"));
gp_widget_set_value (widget, else
_("Auto, red-eye reduction")); gp_widget_set_value (widget, _("Auto"));
else break;
gp_widget_set_value (widget, _("Auto"));
break;
}
/* Exposure */
gp_widget_new (GP_WIDGET_RANGE, _("Exposure"), &widget);
gp_widget_append (section, widget);
gp_widget_set_range (widget, -2, 2, 0.1);
switch(buf[EXPOSURE_TIME_PTR]) {
case 0:
value_float = 0;
break;
case 1:
value_float = 0.3;
break;
case 2:
value_float = 0.5;
break;
case 3:
value_float = 0.8;
break;
case 4:
value_float = 1.0;
break;
case 5:
value_float = 1.3;
break;
case 6:
value_float = 1.5;
break;
case 7:
value_float = 1.8;
break;
case 8:
value_float = 2.0;
break;
case 0xF8:
value_float = -2.0;
break;
case 0xF9:
value_float = -1.8;
break;
case 0xFA:
value_float = -1.5;
break;
case 0xFB:
value_float = -1.3;
break;
case 0xFC:
value_float = -1.0;
break;
case 0xFD:
value_float = -0.8;
break;
case 0xFE:
value_float = -0.5;
break;
case 0xFF:
value_float = -0.3;
break;
} }
gp_widget_set_value (widget, &value_float);
/* Focus */ /* Exposure */
gp_widget_new (GP_WIDGET_RADIO, _("Focus"), &widget); gp_widget_new (GP_WIDGET_RANGE, _("Exposure"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("2.0 m")); gp_widget_set_range (widget, -2, 2, 0.1);
switch (buf[EXPOSURE_TIME_PTR]) {
case 0:
value_float = 0;
break;
case 1:
value_float = 0.3;
break;
case 2:
value_float = 0.5;
break;
case 3:
value_float = 0.8;
break;
case 4:
value_float = 1.0;
break;
case 5:
value_float = 1.3;
break;
case 6:
value_float = 1.5;
break;
case 7:
value_float = 1.8;
break;
case 8:
value_float = 2.0;
break;
case 0xF8:
value_float = -2.0;
break;
case 0xF9:
value_float = -1.8;
break;
case 0xFA:
value_float = -1.5;
break;
case 0xFB:
value_float = -1.3;
break;
case 0xFC:
value_float = -1.0;
break;
case 0xFD:
value_float = -0.8;
break;
case 0xFE:
value_float = -0.5;
break;
case 0xFF:
value_float = -0.3;
break;
}
gp_widget_set_value (widget, &value_float);
/* Focus */
gp_widget_new (GP_WIDGET_RADIO, _("Focus"), &widget);
gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("2.0 m"));
gp_widget_add_choice (widget, _("0.5 m")); gp_widget_add_choice (widget, _("0.5 m"));
gp_widget_add_choice (widget, _("0.1 m")); gp_widget_add_choice (widget, _("0.1 m"));
gp_widget_add_choice (widget, _("Auto")); gp_widget_add_choice (widget, _("Auto"));
switch (buf[FOCUS_PTR]) { switch (buf[FOCUS_PTR]) {
case 0: case 0:
gp_widget_set_value (widget, _("Auto")); gp_widget_set_value (widget, _("Auto"));
break; break;
case 1: case 1:
gp_widget_set_value (widget, _("2.0 m")); gp_widget_set_value (widget, _("2.0 m"));
break; break;
case 2: case 2:
gp_widget_set_value (widget, _("0.5 m")); gp_widget_set_value (widget, _("0.5 m"));
break; break;
case 3: case 3:
gp_widget_set_value (widget, _("0.1 m")); gp_widget_set_value (widget, _("0.1 m"));
break; break;
} }
/* white balance */ /* white balance */
gp_widget_new (GP_WIDGET_RADIO, _("White balance"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("White balance"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("Office")); gp_widget_add_choice (widget, _("Office"));
gp_widget_add_choice (widget, _("Daylight")); gp_widget_add_choice (widget, _("Daylight"));
gp_widget_add_choice (widget, _("Auto")); gp_widget_add_choice (widget, _("Auto"));
switch (buf[WHITE_BALANCE_PTR]) { switch (buf[WHITE_BALANCE_PTR]) {
case 0: case 0:
gp_widget_set_value (widget, _("Auto")); gp_widget_set_value (widget, _("Auto"));
break; break;
case 1: case 1:
gp_widget_set_value (widget, _("Daylight")); gp_widget_set_value (widget, _("Daylight"));
break; break;
case 2: case 2:
gp_widget_set_value (widget, _("Office")); gp_widget_set_value (widget, _("Office"));
break; break;
} }
/* Sharpness */ /* Sharpness */
gp_widget_new (GP_WIDGET_RADIO, _("Sharpness"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("Sharpness"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("Sharp")); gp_widget_add_choice (widget, _("Sharp"));
gp_widget_add_choice (widget, _("Soft")); gp_widget_add_choice (widget, _("Soft"));
gp_widget_add_choice (widget, _("Auto")); gp_widget_add_choice (widget, _("Auto"));
switch (buf[SHARPNESS_PTR]) { switch (buf[SHARPNESS_PTR]) {
case 0: case 0:
gp_widget_set_value (widget, _("Auto")); gp_widget_set_value (widget, _("Auto"));
break; break;
case 1: case 1:
gp_widget_set_value (widget, _("Sharp")); gp_widget_set_value (widget, _("Sharp"));
break; break;
case 2: case 2:
gp_widget_set_value (widget, _("Soft")); gp_widget_set_value (widget, _("Soft"));
break; break;
} }
/* Color */ /* Color */
gp_widget_new (GP_WIDGET_RADIO, _("Color"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("Color"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("Light")); gp_widget_add_choice (widget, _("Light"));
gp_widget_add_choice (widget, _("Deep")); gp_widget_add_choice (widget, _("Deep"));
gp_widget_add_choice (widget, _("Black and White")); gp_widget_add_choice (widget, _("Black and White"));
gp_widget_add_choice (widget, _("Sepia")); gp_widget_add_choice (widget, _("Sepia"));
gp_widget_add_choice (widget, _("Auto")); gp_widget_add_choice (widget, _("Auto"));
switch (buf[COLOR_PTR]) { switch (buf[COLOR_PTR]) {
case 0: case 0:
gp_widget_set_value (widget, _("Auto")); gp_widget_set_value (widget, _("Auto"));
break; break;
case 1: case 1:
gp_widget_set_value (widget, _("Light")); gp_widget_set_value (widget, _("Light"));
break; break;
case 2: case 2:
gp_widget_set_value (widget, _("Deep")); gp_widget_set_value (widget, _("Deep"));
break; break;
case 3: case 3:
gp_widget_set_value (widget, _("Black and White")); gp_widget_set_value (widget, _("Black and White"));
break; break;
case 4: case 4:
gp_widget_set_value (widget, _("Sepia")); gp_widget_set_value (widget, _("Sepia"));
break; break;
} }
/* Macro */ /* Macro */
gp_widget_new (GP_WIDGET_RADIO, _("Macro"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("Macro"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("On")); gp_widget_add_choice (widget, _("On"));
gp_widget_add_choice (widget, _("Off")); gp_widget_add_choice (widget, _("Off"));
switch (buf[MACRO_PTR]) { switch (buf[MACRO_PTR]) {
case 0: case 0:
gp_widget_set_value (widget, _("Off")); gp_widget_set_value (widget, _("Off"));
break; break;
case 1: case 1:
gp_widget_set_value (widget, _("On")); gp_widget_set_value (widget, _("On"));
break; break;
} }
/* Zoom */ /* Zoom */
gp_widget_new (GP_WIDGET_RADIO, _("Zoom"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("Zoom"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("On")); gp_widget_add_choice (widget, _("On"));
gp_widget_add_choice (widget, _("Off")); gp_widget_add_choice (widget, _("Off"));
switch (buf[ZOOM_PTR]) { switch (buf[ZOOM_PTR]) {
case 0: case 0:
gp_widget_set_value (widget, _("Off")); gp_widget_set_value (widget, _("Off"));
break; break;
case 1: case 1:
gp_widget_set_value (widget, _("On")); gp_widget_set_value (widget, _("On"));
break; break;
} }
/* Capture */ /* Capture */
gp_widget_new (GP_WIDGET_RADIO, _("Capture"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("Capture"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("Single")); gp_widget_add_choice (widget, _("Single"));
gp_widget_add_choice (widget, _("Sequence 9")); gp_widget_add_choice (widget, _("Sequence 9"));
switch (buf[CAPTURE_TYPE_PTR]) { switch (buf[CAPTURE_TYPE_PTR]) {
case 0: case 0:
gp_widget_set_value (widget, _("Single")); gp_widget_set_value (widget, _("Single"));
break; break;
case 1: case 1:
gp_widget_set_value (widget, _("Sequence 9")); gp_widget_set_value (widget, _("Sequence 9"));
break; break;
} }
/* Date display */ /* Date display */
gp_widget_new (GP_WIDGET_RADIO, _("Date display"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("Date display"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("Anywhere")); gp_widget_add_choice (widget, _("Anywhere"));
gp_widget_add_choice (widget, _("Play mode")); gp_widget_add_choice (widget, _("Play mode"));
gp_widget_add_choice (widget, _("Record mode")); gp_widget_add_choice (widget, _("Record mode"));
gp_widget_add_choice (widget, _("Everywhere")); gp_widget_add_choice (widget, _("Everywhere"));
switch (buf[REC_DATE_DISP_PTR]) { switch (buf[REC_DATE_DISP_PTR]) {
case 0: case 0:
if (buf[PLAY_DATE_DISP_PTR] == 0) if (buf[PLAY_DATE_DISP_PTR] == 0)
gp_widget_set_value (widget, _("Play mode")); gp_widget_set_value (widget, _("Play mode"));
else else
gp_widget_set_value (widget, _("Anywhere")); gp_widget_set_value (widget, _("Anywhere"));
break; break;
case 1: case 1:
if (buf[PLAY_DATE_DISP_PTR] == 0) if (buf[PLAY_DATE_DISP_PTR] == 0)
gp_widget_set_value (widget, _("Everywhere")); gp_widget_set_value (widget, _("Everywhere"));
else else
gp_widget_set_value (widget, _("Record mode")); gp_widget_set_value (widget, _("Record mode"));
break; break;
} }
/************************/ /************************/
/* Volatile Settings */ /* Volatile Settings */
/************************/ /************************/
gp_widget_new (GP_WIDGET_SECTION, _("Volatile Settings"), &section); gp_widget_new (GP_WIDGET_SECTION, _("Volatile Settings"), &section);
gp_widget_append (*window, section); gp_widget_append (*window, section);
/* Self Timer */ /* Self Timer */
gp_widget_new (GP_WIDGET_RADIO, _("Self Timer"), &widget); gp_widget_new (GP_WIDGET_RADIO, _("Self Timer"), &widget);
gp_widget_append (section, widget); gp_widget_append (section, widget);
gp_widget_add_choice (widget, _("Self Timer (next picture only)")); gp_widget_add_choice (widget, _("Self Timer (next picture only)"));
gp_widget_add_choice (widget, _("Normal")); gp_widget_add_choice (widget, _("Normal"));
switch (buf[TIMER_PTR]) { switch (buf[TIMER_PTR]) {
case 1: case 1:
gp_widget_set_value (widget, _("Self Timer (" gp_widget_set_value (widget, _("Self Timer (next picture only)"));
"next picture only)")); break;
break; case 0:
case 0: gp_widget_set_value (widget, _("Normal"));
gp_widget_set_value (widget, _("Normal")); break;
break; }
}
return (GP_OK); return (GP_OK);
} }
@@ -1153,18 +1150,18 @@ camera_summary (Camera *camera, CameraText *text, GPContext *context)
timestamp = (unsigned int)timestamp + (8*365 + 2*366)*24*3600-3600; timestamp = (unsigned int)timestamp + (8*365 + 2*366)*24*3600-3600;
tmp = *localtime(&timestamp); tmp = *localtime(&timestamp);
switch (buf[DATE_FORMAT_PTR]) { switch (buf[DATE_FORMAT_PTR]) {
case 1: case 1:
snprintf(date_disp,sizeof(date_disp),_("DD/MM/YYYY")); snprintf(date_disp, sizeof(date_disp), _("DD/MM/YYYY"));
strftime(date,sizeof(date),"%d/%m/%Y %H:%M",&tmp); strftime(date, sizeof(date), "%d/%m/%Y %H:%M", &tmp);
break; break;
case 2: case 2:
strftime(date,sizeof(date),"%Y/%m/%d %H:%M",&tmp); strftime(date, sizeof(date), "%Y/%m/%d %H:%M", &tmp);
snprintf(date_disp,sizeof(date_disp),_("YYYY/MM/DD")); snprintf(date_disp, sizeof(date_disp), _("YYYY/MM/DD"));
break; break;
default: default:
strftime(date,sizeof(date),"%m/%d/%Y %H:%M",&tmp); strftime(date, sizeof(date), "%m/%d/%Y %H:%M", &tmp);
snprintf(date_disp,sizeof(date_disp),_("MM/DD/YYYY")); snprintf(date_disp, sizeof(date_disp), _("MM/DD/YYYY"));
break; break;
} }
snprintf(text->text, sizeof(text->text), snprintf(text->text, sizeof(text->text),
_("Model: %s\n" _("Model: %s\n"
@@ -1272,12 +1269,12 @@ camera_init (Camera *camera, GPContext *context)
char cmd[3], buf[1]; char cmd[3], buf[1];
/* First, set up all the function pointers. */ /* First, set up all the function pointers. */
camera->functions->capture = camera_capture; camera->functions->capture = camera_capture;
camera->functions->about = camera_about; camera->functions->about = camera_about;
camera->functions->get_config = camera_get_config; camera->functions->get_config = camera_get_config;
camera->functions->set_config = camera_set_config; camera->functions->set_config = camera_set_config;
camera->functions->summary = camera_summary; camera->functions->summary = camera_summary;
camera->functions->manual = camera_manual; camera->functions->manual = camera_manual;
/* Now, tell the filesystem where to get lists, files and info */ /* Now, tell the filesystem where to get lists, files and info */

View File

@@ -255,10 +255,10 @@ camera_init (Camera *camera, GPContext *context)
int ret; int ret;
GPPortSettings settings; GPPortSettings settings;
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->exit = camera_exit; camera->functions->exit = camera_exit;
camera->functions->capture = camera_capture; camera->functions->capture = camera_capture;
camera->functions->about = camera_about; camera->functions->about = camera_about;
/* Now, tell the filesystem where to get lists, files and info */ /* Now, tell the filesystem where to get lists, files and info */
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);

View File

@@ -109,15 +109,15 @@ int largan_open (Camera * camera)
{ {
int ret; int ret;
ret = largan_get_num_pict (camera); ret = largan_get_num_pict (camera);
if (ret < 0){ if (ret < 0) {
ret = purge_camera (camera); ret = purge_camera (camera);
if (ret == GP_ERROR) { if (ret == GP_ERROR) {
return ret; return ret;
} }
ret = wakeup_camera (camera); ret = wakeup_camera (camera);
} }
return ret; /* here: number of pictures */ return ret; /* here: number of pictures */
} }
/* /*
@@ -160,21 +160,21 @@ int largan_get_pict (Camera * camera, largan_pict_type type,
uint32_t pict_size; /* size of the picture as returned by the camera */ uint32_t pict_size; /* size of the picture as returned by the camera */
switch (type) { switch (type) {
case LARGAN_PICT: case LARGAN_PICT:
param = 0x01; param = 0x01;
break; break;
case LARGAN_THUMBNAIL: case LARGAN_THUMBNAIL:
param = 0x00; param = 0x00;
break; break;
default: default:
GP_DEBUG ("largan_get_pict(): wrong picture type requested !\n"); GP_DEBUG ("largan_get_pict(): wrong picture type requested !\n");
return GP_ERROR; return GP_ERROR;
} }
ret = largan_send_command (camera, LARGAN_GET_PICT_CMD, param, index); ret = largan_send_command (camera, LARGAN_GET_PICT_CMD, param, index);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
ret = largan_recv_reply (camera, &reply, &code, NULL); ret = largan_recv_reply (camera, &reply, &code, NULL);
/* here we have to receive 7 bytes back /* here we have to receive 7 bytes back
the 2nd contains 00 for thumbnail or 01 for original picture the 2nd contains 00 for thumbnail or 01 for original picture
the 3rd contains the picturenumber for an original picture the 3rd contains the picturenumber for an original picture
@@ -183,26 +183,26 @@ int largan_get_pict (Camera * camera, largan_pict_type type,
bytes 4 5 6 7 contain the number of byte coming in the datastream */ bytes 4 5 6 7 contain the number of byte coming in the datastream */
/* the 1st and the 2nd byte are read here */ /* the 1st and the 2nd byte are read here */
if (ret < 0) { if (ret < 0) {
/* clean up and give it a 2nd chance */ /* clean up and give it a 2nd chance */
wakeup_camera (camera); wakeup_camera (camera);
largan_send_command (camera, LARGAN_GET_PICT_CMD, param, index); largan_send_command (camera, LARGAN_GET_PICT_CMD, param, index);
GP_DEBUG ("largan_get_pict(): command sent 2nd time\n"); GP_DEBUG ("largan_get_pict(): command sent 2nd time\n");
ret = largan_recv_reply (camera, &reply, &code, NULL); ret = largan_recv_reply (camera, &reply, &code, NULL);
if (ret < 0) { if (ret < 0) {
/* clean up and give it even a 3rd chance */ /* clean up and give it even a 3rd chance */
wakeup_camera (camera); wakeup_camera (camera);
sleep (5); sleep (5);
largan_send_command (camera, LARGAN_GET_PICT_CMD, param, index); largan_send_command (camera, LARGAN_GET_PICT_CMD, param, index);
GP_DEBUG ("largan_get_pict(): command sent 3rd time\n"); GP_DEBUG ("largan_get_pict(): command sent 3rd time\n");
ret = largan_recv_reply (camera, &reply, &code, NULL); ret = largan_recv_reply (camera, &reply, &code, NULL);
if (ret < 0) { if (ret < 0) {
GP_DEBUG ("largan_get_pict(): timeout after command sent 3rd time\n"); GP_DEBUG ("largan_get_pict(): timeout after command sent 3rd time\n");
return ret; /* timeout after 3rd trial */ return ret; /* timeout after 3rd trial */
} }
} }
} }
if ((reply != LARGAN_GET_PICT_CMD) || ((code != 0x01) && (code != 0x00))) { if ((reply != LARGAN_GET_PICT_CMD) || ((code != 0x01) && (code != 0x00))) {
GP_DEBUG ("largan_get_pict(): code != 0x01 && 0x00\n"); GP_DEBUG ("largan_get_pict(): code != 0x01 && 0x00\n");
return GP_ERROR; return GP_ERROR;
} }
@@ -265,7 +265,7 @@ int largan_get_pict (Camera * camera, largan_pict_type type,
} }
default: default:
GP_DEBUG ("largan_get_pict(): type not LARGAN_PICT nor LARGAN_THUMBNAIL\n"); GP_DEBUG ("largan_get_pict(): type not LARGAN_PICT nor LARGAN_THUMBNAIL\n");
return GP_ERROR; return GP_ERROR;
} }
return GP_OK; return GP_OK;
} }

View File

@@ -72,13 +72,13 @@ int lg_gsm_init (GPPort *port, Model *model, Info *info)
/*GP_DEBUG("info[20] = 0x%x\n", firmware[26]);*/ /*GP_DEBUG("info[20] = 0x%x\n", firmware[26]);*/
GP_DEBUG("Leaving lg_gsm_init\n"); GP_DEBUG("Leaving lg_gsm_init\n");
return GP_OK; return GP_OK;
} }
unsigned int lg_gsm_get_picture_size (GPPort *port, int pic) unsigned int lg_gsm_get_picture_size (GPPort *port, int pic)
{ {
unsigned int size; unsigned int size;
/* example : list photos 2 & 3: 0x04000800000040000000 /* example : list photos 2 & 3: 0x04000800000040000000
+ 0100 : from + 0100 : from
+ 0200 : to + 0200 : to
@@ -206,7 +206,7 @@ int lg_gsm_read_picture_data (GPPort *port, char *data, unsigned int datasize, u
READ(port, oknok, 6); READ(port, oknok, 6);
GP_DEBUG("Leaving lg_gsm_read_picture_data\n"); GP_DEBUG("Leaving lg_gsm_read_picture_data\n");
return GP_OK; return GP_OK;
} }
int lg_gsm_list_files (GPPort *port, CameraList *list) int lg_gsm_list_files (GPPort *port, CameraList *list)
@@ -270,5 +270,5 @@ int lg_gsm_list_files (GPPort *port, CameraList *list)
GP_DEBUG("Leaving lg_gsm_list_files\n"); GP_DEBUG("Leaving lg_gsm_list_files\n");
return GP_OK; return GP_OK;
} }

View File

@@ -51,20 +51,20 @@ struct _CameraPrivateLibrary {
}; };
static struct { static struct {
char *name; char *name;
CameraDriverStatus status; CameraDriverStatus status;
unsigned short idVendor; unsigned short idVendor;
unsigned short idProduct; unsigned short idProduct;
} models[] = { } models[] = {
{"LG T5100", GP_DRIVER_STATUS_EXPERIMENTAL, 0x1004, 0x6005}, {"LG T5100", GP_DRIVER_STATUS_EXPERIMENTAL, 0x1004, 0x6005},
{NULL,0,0,0} {NULL,0,0,0}
}; };
int int
camera_id (CameraText *id) camera_id (CameraText *id)
{ {
strcpy (id->text, "LG GSM camera"); strcpy (id->text, "LG GSM camera");
return GP_OK; return GP_OK;
} }
int int
@@ -113,9 +113,9 @@ camera_summary (Camera *camera, CameraText *summary, GPContext *context)
static int static int
camera_about (Camera *camera, CameraText *about, GPContext *context) camera_about (Camera *camera, CameraText *about, GPContext *context)
{ {
strcpy (about->text, _("LG GSM generic driver\n" strcpy (about->text, _("LG GSM generic driver\n"
"Guillaume Bedot <littletux@zarb.org>\n")); "Guillaume Bedot <littletux@zarb.org>\n"));
return GP_OK; return GP_OK;
} }
/*************** File and Downloading Functions *******************/ /*************** File and Downloading Functions *******************/
@@ -137,7 +137,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
{ {
Camera *camera = user_data; Camera *camera = user_data;
int k; int k;
char *data; char *data;
unsigned int len; unsigned int len;
@@ -191,9 +191,9 @@ camera_init(Camera *camera, GPContext *context)
int ret = 0; int ret = 0;
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->summary = camera_summary; camera->functions->summary = camera_summary;
camera->functions->about = camera_about; camera->functions->about = camera_about;
camera->functions->exit = camera_exit; camera->functions->exit = camera_exit;
GP_DEBUG ("Initializing the camera\n"); GP_DEBUG ("Initializing the camera\n");
ret = gp_port_get_settings(camera->port,&settings); ret = gp_port_get_settings(camera->port,&settings);
@@ -201,17 +201,17 @@ camera_init(Camera *camera, GPContext *context)
return ret; return ret;
switch (camera->port->type) { switch (camera->port->type) {
case GP_PORT_SERIAL: case GP_PORT_SERIAL:
return GP_ERROR; return GP_ERROR;
case GP_PORT_USB: case GP_PORT_USB:
settings.usb.config = 1; settings.usb.config = 1;
settings.usb.altsetting = 0; settings.usb.altsetting = 0;
settings.usb.interface = 1; settings.usb.interface = 1;
settings.usb.inep = 0x81; settings.usb.inep = 0x81;
settings.usb.outep =0x02; settings.usb.outep =0x02;
break; break;
default: default:
return GP_ERROR; return GP_ERROR;
} }
ret = gp_port_set_settings(camera->port,settings); ret = gp_port_set_settings(camera->port,settings);
@@ -222,7 +222,7 @@ camera_init(Camera *camera, GPContext *context)
GP_DEBUG("inep = %x\n", settings.usb.inep); GP_DEBUG("inep = %x\n", settings.usb.inep);
GP_DEBUG("outep = %x\n", settings.usb.outep); GP_DEBUG("outep = %x\n", settings.usb.outep);
/* Tell the CameraFilesystem where to get lists from */ /* Tell the CameraFilesystem where to get lists from */
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
camera->pl = malloc (sizeof (CameraPrivateLibrary)); camera->pl = malloc (sizeof (CameraPrivateLibrary));

View File

@@ -430,8 +430,8 @@ static void Set_ISO(Camera *camera,const char * ISOValue) {
static char* static char*
generic_setting_getter(Camera *camera, char *type) { generic_setting_getter(Camera *camera, char *type) {
char *result, *s; char *result, *s;
xmlDocPtr docin; xmlDocPtr docin;
xmlNodePtr docroot, output; xmlNodePtr docroot, output;
xmlAttr *attr; xmlAttr *attr;
char url[50]; char url[50];
@@ -725,8 +725,8 @@ static char*
GetPixRange(Camera *camera, int start, int num) { GetPixRange(Camera *camera, int start, int num) {
long NumPix; long NumPix;
int numreadint; int numreadint;
xmlDocPtr docin, docin2; xmlDocPtr docin, docin2;
xmlNodePtr docroot, docroot2, output, output2, next; xmlNodePtr docroot, docroot2, output, output2, next;
xmlChar *xchar, *numread; xmlChar *xchar, *numread;
char* SoapMsg; char* SoapMsg;
CURL *curl; CURL *curl;
@@ -1089,15 +1089,15 @@ static struct aperturemap {
static int static int
camera_config_get (Camera *camera, CameraWidget **window, GPContext *context) camera_config_get (Camera *camera, CameraWidget **window, GPContext *context)
{ {
CameraWidget *widget,*section; CameraWidget *widget,*section;
int valset; int valset;
unsigned int i; unsigned int i;
char *val; char *val;
switchToRecMode (camera); switchToRecMode (camera);
gp_widget_new (GP_WIDGET_WINDOW, _("Lumix Configuration"), window); gp_widget_new (GP_WIDGET_WINDOW, _("Lumix Configuration"), window);
gp_widget_set_name (*window, "config"); gp_widget_set_name (*window, "config");
gp_widget_new (GP_WIDGET_SECTION, _("Camera Settings"), &section); gp_widget_new (GP_WIDGET_SECTION, _("Camera Settings"), &section);
gp_widget_set_name (section, "settings"); gp_widget_set_name (section, "settings");
@@ -1367,14 +1367,14 @@ camera_config_set (Camera *camera, CameraWidget *window, GPContext *context)
static int static int
strend(const char *s, const char *t) strend(const char *s, const char *t)
{ {
size_t ls = strlen(s); // find length of s size_t ls = strlen(s); // find length of s
size_t lt = strlen(t); // find length of t size_t lt = strlen(t); // find length of t
if (ls >= lt) // check if t can fit in s if (ls >= lt) // check if t can fit in s
{ {
// point s to where t should start and compare the strings from there // point s to where t should start and compare the strings from there
return (0 == memcmp(t, s + (ls - lt), lt)); return (0 == memcmp(t, s + (ls - lt), lt));
} }
return 0; // t was longer than s return 0; // t was longer than s
} }
static char* static char*
@@ -1383,33 +1383,33 @@ processNode(xmlTextReaderPtr reader) {
char* lookupImgtag=""; char* lookupImgtag="";
switch (ReadoutMode) { switch (ReadoutMode) {
case 0 : //'jpg case 0: //'jpg
lookupImgtag = "CAM_RAW_JPG"; lookupImgtag = "CAM_RAW_JPG";
break; break;
case 1 :// 'raw case 1:// 'raw
lookupImgtag = "CAM_RAW"; lookupImgtag = "CAM_RAW";
break; break;
case 2 ://'thumb case 2://'thumb
lookupImgtag = "CAM_LRGTN"; lookupImgtag = "CAM_LRGTN";
break; break;
} }
const xmlChar *name; const xmlChar *name;
name = xmlTextReaderConstName(reader); name = xmlTextReaderConstName(reader);
if (name == NULL) if (name == NULL)
name = BAD_CAST "--"; name = BAD_CAST "--";
if (xmlTextReaderNodeType(reader) == 1) { // Element if (xmlTextReaderNodeType(reader) == 1) { // Element
while (xmlTextReaderMoveToNextAttribute(reader)) { while (xmlTextReaderMoveToNextAttribute(reader)) {
if (strend((char*)xmlTextReaderConstValue(reader),lookupImgtag)) { if (strend((char*)xmlTextReaderConstValue(reader), lookupImgtag)) {
xmlTextReaderRead(reader); xmlTextReaderRead(reader);
ret = (char*)xmlTextReaderConstValue(reader); ret = (char*)xmlTextReaderConstValue(reader);
printf("the image file is %s\n" ,ret); printf("the image file is %s\n", ret);
}
} }
} }
} return ret;
return ret;
} }
/* /*
@@ -1469,61 +1469,61 @@ case RAW:
*/ */
static int static int
add_objectid_and_upload (Camera *camera, CameraFilePath *path, GPContext *context, char *ximage, size_t size) { add_objectid_and_upload (Camera *camera, CameraFilePath *path, GPContext *context, char *ximage, size_t size) {
int ret; int ret;
CameraFile *file = NULL; CameraFile *file = NULL;
CameraFileInfo info; CameraFileInfo info;
ret = gp_file_new(&file); ret = gp_file_new(&file);
if (ret!=GP_OK) return ret; if (ret!=GP_OK) return ret;
gp_file_set_mtime (file, time(NULL)); gp_file_set_mtime (file, time(NULL));
strcpy(info.file.type, GP_MIME_JPEG); strcpy(info.file.type, GP_MIME_JPEG);
GP_LOG_D ("setting size"); GP_LOG_D ("setting size");
ret = gp_file_set_data_and_size(file, ximage, size); ret = gp_file_set_data_and_size(file, ximage, size);
if (ret != GP_OK) { if (ret != GP_OK) {
gp_file_free (file); gp_file_free (file);
return ret; return ret;
} }
GP_LOG_D ("append to fs"); GP_LOG_D ("append to fs");
ret = gp_filesystem_append(camera->fs, path->folder, path->name, context); ret = gp_filesystem_append(camera->fs, path->folder, path->name, context);
if (ret != GP_OK) { if (ret != GP_OK) {
gp_file_free (file); gp_file_free (file);
return ret; return ret;
} }
GP_LOG_D ("adding filedata to fs"); GP_LOG_D ("adding filedata to fs");
ret = gp_filesystem_set_file_noop(camera->fs, path->folder, path->name, GP_FILE_TYPE_NORMAL, file, context); ret = gp_filesystem_set_file_noop(camera->fs, path->folder, path->name, GP_FILE_TYPE_NORMAL, file, context);
if (ret != GP_OK) { if (ret != GP_OK) {
gp_file_free (file); gp_file_free (file);
return ret; return ret;
} }
/* We have now handed over the file, disclaim responsibility by unref. */ /* We have now handed over the file, disclaim responsibility by unref. */
gp_file_unref (file); gp_file_unref (file);
/* we also get the fs info for free, so just set it */ /* we also get the fs info for free, so just set it */
info.file.fields = GP_FILE_INFO_TYPE | info.file.fields = GP_FILE_INFO_TYPE |
/*GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT |*/ /*GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT |*/
GP_FILE_INFO_SIZE /*| GP_FILE_INFO_MTIME */ ; GP_FILE_INFO_SIZE /*| GP_FILE_INFO_MTIME */;
strcpy(info.file.type, GP_MIME_JPEG); strcpy(info.file.type, GP_MIME_JPEG);
info.preview.fields = 0; /* so far none */ info.preview.fields = 0; /* so far none */
/* /*
info.file.width = oi->ImagePixWidth; info.file.width = oi->ImagePixWidth;
info.file.height = oi->ImagePixHeight; info.file.height = oi->ImagePixHeight;
info.file.size = oi->ObjectCompressedSize; info.file.size = oi->ObjectCompressedSize;
info.file.mtime = time(NULL); info.file.mtime = time(NULL);
info.preview.fields = GP_FILE_INFO_TYPE | info.preview.fields = GP_FILE_INFO_TYPE |
GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT | GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT |
GP_FILE_INFO_SIZE; GP_FILE_INFO_SIZE;
strcpy_mime (info.preview.type, params->deviceinfo.VendorExtensionID, oi->ThumbFormat); strcpy_mime (info.preview.type, params->deviceinfo.VendorExtensionID, oi->ThumbFormat);
info.preview.width = oi->ThumbPixWidth; info.preview.width = oi->ThumbPixWidth;
info.preview.height = oi->ThumbPixHeight; info.preview.height = oi->ThumbPixHeight;
info.preview.size = oi->ThumbCompressedSize; info.preview.size = oi->ThumbCompressedSize;
*/ */
GP_LOG_D ("setting fileinfo in fs"); GP_LOG_D ("setting fileinfo in fs");
return gp_filesystem_set_info_noop(camera->fs, path->folder, path->name, info, context); return gp_filesystem_set_info_noop(camera->fs, path->folder, path->name, info, context);
} }
static int static int
@@ -1540,10 +1540,10 @@ ReadImageFromCamera(Camera *camera, CameraFilePath *path, GPContext *context) {
reader = xmlReaderForDoc((xmlChar*)GetPixRange(camera,NumberPix(camera)-1,1), NULL,"noname.xml", XML_PARSE_DTDATTR | /* default DTD attributes */ XML_PARSE_NOENT); reader = xmlReaderForDoc((xmlChar*)GetPixRange(camera,NumberPix(camera)-1,1), NULL,"noname.xml", XML_PARSE_DTDATTR | /* default DTD attributes */ XML_PARSE_NOENT);
ret = xmlTextReaderRead(reader); ret = xmlTextReaderRead(reader);
while (ret == 1) { while (ret == 1) {
imageURL = processNode(reader); imageURL = processNode(reader);
if (strlen(imageURL)) if (strlen(imageURL))
break; break;
ret = xmlTextReaderRead(reader); ret = xmlTextReaderRead(reader);
} }
GP_DEBUG("the image URL is %s\n",imageURL); GP_DEBUG("the image URL is %s\n",imageURL);

View File

@@ -55,12 +55,12 @@ struct _CameraPrivateLibrary {
}; };
static const struct { static const struct {
char *name; char *name;
CameraDriverStatus status; CameraDriverStatus status;
unsigned short idVendor; unsigned short idVendor;
unsigned short idProduct; unsigned short idProduct;
} models[] = { } models[] = {
{"Aiptek PenCam VGA+", GP_DRIVER_STATUS_TESTING, 0x08ca, 0x0111}, {"Aiptek PenCam VGA+", GP_DRIVER_STATUS_TESTING, 0x08ca, 0x0111},
{"Trust Spyc@m 100", GP_DRIVER_STATUS_TESTING, 0x08ca, 0x0110}, {"Trust Spyc@m 100", GP_DRIVER_STATUS_TESTING, 0x08ca, 0x0110},
{"Emprex PCD3600", GP_DRIVER_STATUS_EXPERIMENTAL, 0x093a, 0x010f}, {"Emprex PCD3600", GP_DRIVER_STATUS_EXPERIMENTAL, 0x093a, 0x010f},
{"Vivitar Vivicam 55", GP_DRIVER_STATUS_EXPERIMENTAL, 0x093a, 0x010f}, {"Vivitar Vivicam 55", GP_DRIVER_STATUS_EXPERIMENTAL, 0x093a, 0x010f},
@@ -86,34 +86,34 @@ static const struct {
int int
camera_id (CameraText *id) camera_id (CameraText *id)
{ {
strcpy (id->text, "Aiptek PenCam VGA+"); strcpy (id->text, "Aiptek PenCam VGA+");
return GP_OK; return GP_OK;
} }
int int
camera_abilities (CameraAbilitiesList *list) camera_abilities (CameraAbilitiesList *list)
{ {
int i; int i;
CameraAbilities a; CameraAbilities a;
for (i = 0; models[i].name; i++) { for (i = 0; models[i].name; i++) {
memset (&a, 0, sizeof(a)); memset (&a, 0, sizeof(a));
strcpy (a.model, models[i].name); strcpy (a.model, models[i].name);
a.status = models[i].status; a.status = models[i].status;
a.port = GP_PORT_USB; a.port = GP_PORT_USB;
a.speed[0] = 0; a.speed[0] = 0;
a.usb_vendor = models[i].idVendor; a.usb_vendor = models[i].idVendor;
a.usb_product= models[i].idProduct; a.usb_product= models[i].idProduct;
if (a.status == GP_DRIVER_STATUS_EXPERIMENTAL) if (a.status == GP_DRIVER_STATUS_EXPERIMENTAL)
a.operations = GP_OPERATION_NONE; a.operations = GP_OPERATION_NONE;
else else
a.operations = GP_OPERATION_CAPTURE_IMAGE; a.operations = GP_OPERATION_CAPTURE_IMAGE;
a.folder_operations = GP_FOLDER_OPERATION_NONE; a.folder_operations = GP_FOLDER_OPERATION_NONE;
a.file_operations = GP_FILE_OPERATION_PREVIEW a.file_operations = GP_FILE_OPERATION_PREVIEW
| GP_FILE_OPERATION_RAW; | GP_FILE_OPERATION_RAW;
gp_abilities_list_append (list, a); gp_abilities_list_append (list, a);
} }
return GP_OK; return GP_OK;
} }
static int static int
@@ -121,20 +121,20 @@ camera_summary (Camera *camera, CameraText *summary, GPContext *context)
{ {
int num_pics = mars_get_num_pics(camera->pl->info); int num_pics = mars_get_num_pics(camera->pl->info);
sprintf (summary->text,ngettext( sprintf (summary->text, ngettext(
"Mars MR97310 camera.\nThere is %i photo in it.\n", "Mars MR97310 camera.\nThere is %i photo in it.\n",
"Mars MR97310 camera.\nThere are %i photos in it.\n", "Mars MR97310 camera.\nThere are %i photos in it.\n",
num_pics), num_pics num_pics), num_pics
); );
return GP_OK; return GP_OK;
} }
static int camera_manual (Camera *camera, CameraText *manual, GPContext *context) static int camera_manual (Camera *camera, CameraText *manual, GPContext *context)
{ {
strcpy(manual->text, strcpy(manual->text,
_( _(
"This driver supports cameras with Mars MR97310 chip (and direct\n" "This driver supports cameras with Mars MR97310 chip (and direct\n"
"equivalents ??Pixart PACx07?\?).\n" "equivalents ??Pixart PACx07?\?).\n"
"These cameras do not support deletion of photos, nor uploading\n" "These cameras do not support deletion of photos, nor uploading\n"
"of data.\n" "of data.\n"
"Decoding of compressed photos may or may not work well\n" "Decoding of compressed photos may or may not work well\n"
@@ -151,9 +151,9 @@ static int camera_manual (Camera *camera, CameraText *manual, GPContext *context
static int static int
camera_about (Camera *camera, CameraText *about, GPContext *context) camera_about (Camera *camera, CameraText *about, GPContext *context)
{ {
strcpy (about->text, _("Mars MR97310 camera library\n" strcpy (about->text, _("Mars MR97310 camera library\n"
"Theodore Kilgore <kilgota@auburn.edu>\n")); "Theodore Kilgore <kilgota@auburn.edu>\n"));
return GP_OK; return GP_OK;
} }
/*************** File and Downloading Functions *******************/ /*************** File and Downloading Functions *******************/
@@ -162,7 +162,7 @@ static int
file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
void *data, GPContext *context) void *data, GPContext *context)
{ {
Camera *camera = data; Camera *camera = data;
int i = 0, n; int i = 0, n;
char name[30]; char name[30];
@@ -172,9 +172,9 @@ file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
sprintf (name, "mr%03isnd.wav", i+1); sprintf (name, "mr%03isnd.wav", i+1);
} else } else
sprintf (name, "mr%03ipic.ppm", i+1); sprintf (name, "mr%03ipic.ppm", i+1);
gp_list_append (list, name, NULL); gp_list_append (list, name, NULL);
} }
return GP_OK; return GP_OK;
} }
static int static int
@@ -192,10 +192,10 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
CameraFileType type, CameraFile *file, void *user_data, CameraFileType type, CameraFile *file, void *user_data,
GPContext *context) GPContext *context)
{ {
Camera *camera = user_data; Camera *camera = user_data;
int w=0, h = 0, b = 0, k; int w=0, h = 0, b = 0, k;
unsigned char *data; unsigned char *data;
unsigned char *ppm; unsigned char *ppm;
unsigned char *p_data = NULL; unsigned char *p_data = NULL;
unsigned char gtable[256], photo_code, res_code, compressed; unsigned char gtable[256], photo_code, res_code, compressed;
unsigned char audio = 0; unsigned char audio = 0;
@@ -203,21 +203,21 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
int size = 0, raw_size = 0; int size = 0, raw_size = 0;
float gamma_factor; float gamma_factor;
GP_DEBUG ("Downloading pictures!\n"); GP_DEBUG ("Downloading pictures!\n");
/* These are cheap cameras. There ain't no EXIF data. */ /* These are cheap cameras. There ain't no EXIF data. */
if (GP_FILE_TYPE_EXIF == type) return GP_ERROR_FILE_EXISTS; if (GP_FILE_TYPE_EXIF == type) return GP_ERROR_FILE_EXISTS;
/* Get the number of the photo on the camera */ /* Get the number of the photo on the camera */
k = gp_filesystem_number (camera->fs, "/", filename, context); k = gp_filesystem_number (camera->fs, "/", filename, context);
/* Determine the resolution setting from the PAT table */ /* Determine the resolution setting from the PAT table */
photo_code = camera->pl->info[8*k]; photo_code = camera->pl->info[8*k];
res_code = photo_code & 0x0f; res_code = photo_code & 0x0f;
/* Compression presence or absence is seen here, and is given again /* Compression presence or absence is seen here, and is given again
* by the camera, in the header of raw data for each photo. * by the camera, in the header of raw data for each photo.
*/ */
compressed = (photo_code >> 4) & 2; compressed = (photo_code >> 4) & 2;
switch (res_code) { switch (res_code) {
case 0: w = 176; h = 144; break; case 0: w = 176; h = 144; break;
case 1: audio = 1; break; case 1: audio = 1; break;
@@ -235,30 +235,30 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
b = ((b+ 0x1b0)/0x2000 + 1) * 0x2000; b = ((b+ 0x1b0)/0x2000 + 1) * 0x2000;
if (w*h > b) { if (w*h > b) {
GP_DEBUG ("w=%d, h=%d, w*h=%d, bytes read=%d\n", w,h,w*h,b); GP_DEBUG ("w=%d, h=%d, w*h=%d, bytes read=%d\n", w, h, w*h, b);
return GP_ERROR_CORRUPTED_DATA; return GP_ERROR_CORRUPTED_DATA;
} }
data = calloc (b,1); data = calloc (b, 1);
if (!data) return GP_ERROR_NO_MEMORY; if (!data) return GP_ERROR_NO_MEMORY;
GP_DEBUG ("buffersize= %i = 0x%x bytes\n", b,b); GP_DEBUG ("buffersize= %i = 0x%x bytes\n", b, b);
mars_read_picture_data (camera, camera->pl->info, mars_read_picture_data (camera, camera->pl->info,
camera->port, (char *)data, b, k); camera->port, (char *)data, b, k);
/* The first 128 bytes are junk, so we toss them.*/ /* The first 128 bytes are junk, so we toss them.*/
memmove(data, data+128, b - 128); memmove(data, data+128, b - 128);
if (audio) { if (audio) {
p_data = malloc (raw_size+256); p_data = malloc (raw_size+256);
if (!p_data) {free (data); return GP_ERROR_NO_MEMORY;} if (!p_data) { free (data); return GP_ERROR_NO_MEMORY; }
memset (p_data, 0, raw_size+256); memset (p_data, 0, raw_size+256);
sprintf ((char *)p_data, "RIFF"); sprintf ((char *)p_data, "RIFF");
p_data[4] = (raw_size+36)&0xff; p_data[4] = (raw_size+36)&0xff;
p_data[5] = ((raw_size+36)>>8)&0xff; p_data[5] = ((raw_size+36)>>8)&0xff;
p_data[6] = ((raw_size+36)>>16)&0xff; p_data[6] = ((raw_size+36)>>16)&0xff;
p_data[7] = ((raw_size+36)>>24)&0xff; p_data[7] = ((raw_size+36)>>24)&0xff;
sprintf ((char *)p_data+8, "WAVE");\ sprintf ((char *)p_data+8, "WAVE");
sprintf ((char *)p_data+12, "fmt "); sprintf ((char *)p_data+12, "fmt ");
p_data[16] = 0x10; p_data[16] = 0x10;
p_data[20] = 1; p_data[20] = 1;
p_data[22] = 1; p_data[22] = 1;
@@ -268,14 +268,14 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
p_data[29] = 0x1F; p_data[29] = 0x1F;
p_data[32] = 1; p_data[32] = 1;
p_data[34] = 8; p_data[34] = 8;
sprintf ((char *)p_data+36, "data"); sprintf ((char *)p_data+36, "data");
p_data[40] = (raw_size)&0xff; p_data[40] = (raw_size)&0xff;
p_data[41] = ((raw_size)>>8)&0xff; p_data[41] = ((raw_size)>>8)&0xff;
p_data[42] = ((raw_size)>>16)&0xff; p_data[42] = ((raw_size)>>16)&0xff;
p_data[43] = ((raw_size)>>24)&0xff; p_data[43] = ((raw_size)>>24)&0xff;
memcpy (p_data+44, data, raw_size); memcpy (p_data+44, data, raw_size);
gp_file_set_mime_type(file, GP_MIME_WAV); gp_file_set_mime_type(file, GP_MIME_WAV);
gp_file_set_data_and_size(file, (char *)p_data , raw_size+44); gp_file_set_data_and_size(file, (char *)p_data, raw_size+44);
return GP_OK; return GP_OK;
} }
@@ -314,7 +314,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
ppm = malloc (w * h * 3 + 256); /* Data + header */ ppm = malloc (w * h * 3 + 256); /* Data + header */
if (!ppm) {free (p_data); return GP_ERROR_NO_MEMORY;} if (!ppm) {free (p_data); return GP_ERROR_NO_MEMORY;}
memset (ppm, 0, w * h * 3 + 256); memset (ppm, 0, w * h * 3 + 256);
sprintf ((char *)ppm, sprintf ((char *)ppm,
"P6\n" "P6\n"
"# CREATOR: gphoto2, Mars library\n" "# CREATOR: gphoto2, Mars library\n"
"%d %d\n" "%d %d\n"
@@ -326,11 +326,11 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
gp_gamma_fill_table (gtable, gamma_factor ); gp_gamma_fill_table (gtable, gamma_factor );
gp_gamma_correct_single (gtable, ptr, w * h); gp_gamma_correct_single (gtable, ptr, w * h);
mars_white_balance (ptr, w*h, 1.4, gamma_factor); mars_white_balance (ptr, w*h, 1.4, gamma_factor);
gp_file_set_mime_type (file, GP_MIME_PPM); gp_file_set_mime_type (file, GP_MIME_PPM);
gp_file_set_data_and_size (file, (char *)ppm, size); gp_file_set_data_and_size (file, (char *)ppm, size);
free (p_data); free (p_data);
return GP_OK; return GP_OK;
} }
/*************** Exit and Initialization Functions ******************/ /*************** Exit and Initialization Functions ******************/
@@ -360,7 +360,7 @@ camera_init(Camera *camera, GPContext *context)
int ret = 0; int ret = 0;
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->manual = camera_manual; camera->functions->manual = camera_manual;
camera->functions->summary = camera_summary; camera->functions->summary = camera_summary;
camera->functions->about = camera_about; camera->functions->about = camera_about;
camera->functions->exit = camera_exit; camera->functions->exit = camera_exit;
@@ -370,19 +370,19 @@ camera_init(Camera *camera, GPContext *context)
if (ret < 0) return ret; if (ret < 0) return ret;
switch (camera->port->type) { switch (camera->port->type) {
case GP_PORT_SERIAL: case GP_PORT_SERIAL:
return ( GP_ERROR ); return (GP_ERROR);
case GP_PORT_USB: case GP_PORT_USB:
settings.usb.config = 1; settings.usb.config = 1;
settings.usb.altsetting = 0; settings.usb.altsetting = 0;
settings.usb.interface = 0; settings.usb.interface = 0;
/* settings.usb.inep = 0x82; */ /* settings.usb.inep = 0x82; */
/* inep 0x83 used for commands. Switch to 0x82 for data! */ /* inep 0x83 used for commands. Switch to 0x82 for data! */
settings.usb.inep = 0x83; settings.usb.inep = 0x83;
settings.usb.outep = 0x04; settings.usb.outep = 0x04;
break; break;
default: default:
return ( GP_ERROR ); return (GP_ERROR);
} }
ret = gp_port_set_settings(camera->port,settings); ret = gp_port_set_settings(camera->port,settings);
@@ -392,7 +392,7 @@ camera_init(Camera *camera, GPContext *context)
GP_DEBUG("inep = %x\n", settings.usb.inep); GP_DEBUG("inep = %x\n", settings.usb.inep);
GP_DEBUG("outep = %x\n", settings.usb.outep); GP_DEBUG("outep = %x\n", settings.usb.outep);
/* Tell the CameraFilesystem where to get lists from */ /* Tell the CameraFilesystem where to get lists from */
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
camera->pl = malloc (sizeof (CameraPrivateLibrary)); camera->pl = malloc (sizeof (CameraPrivateLibrary));

View File

@@ -76,7 +76,7 @@ mars_init (Camera *camera, GPPort *port, Info *info)
* camera reports 0x02 it is "jammed" and we must clear it. * camera reports 0x02 it is "jammed" and we must clear it.
*/ */
m_read(port, c, 16); m_read(port, c, 16);
if (c[0] == 0x02) { if (c[0] == 0x02) {
gp_port_write(port, "\x19", 1); gp_port_write(port, "\x19", 1);
gp_port_read(port, c, 16); gp_port_read(port, c, 16);
@@ -97,7 +97,7 @@ mars_init (Camera *camera, GPPort *port, Info *info)
memmove(info, info + 144, 0x1f70); /* Saving config */ memmove(info, info + 144, 0x1f70); /* Saving config */
GP_DEBUG("Leaving mars_init\n"); GP_DEBUG("Leaving mars_init\n");
return GP_OK; return GP_OK;
} }
int int
@@ -123,7 +123,7 @@ mars_get_pic_data_size (Info *info, int n)
} }
static int static int
set_usb_in_endpoint (Camera *camera, int inep) set_usb_in_endpoint (Camera *camera, int inep)
{ {
GPPortSettings settings; GPPortSettings settings;
gp_port_get_settings ( camera ->port, &settings); gp_port_get_settings ( camera ->port, &settings);
@@ -134,18 +134,18 @@ set_usb_in_endpoint (Camera *camera, int inep)
static int static int
mars_read_data (GPPort *port, char *data, int size) mars_read_data (GPPort *port, char *data, int size)
{ {
int MAX_BULK = 0x2000; int MAX_BULK = 0x2000;
int len = 0; int len = 0;
while(size > 0) { while(size > 0) {
len = (size>MAX_BULK)?MAX_BULK:size; len = (size>MAX_BULK)?MAX_BULK:size;
gp_port_read (port, data, len); gp_port_read (port, data, len);
data += len; data += len;
size -= len; size -= len;
} }
return 1; return 1;
} }
int int
@@ -247,63 +247,63 @@ int mars_decompress (unsigned char *inp, unsigned char *outp, int width,
/* first two pixels in first two rows are stored as raw 8-bit */ /* first two pixels in first two rows are stored as raw 8-bit */
if (row < 2) { if (row < 2) {
GET_CODE; GET_CODE;
bitpos += 8; bitpos += 8;
*outp++ = code; *outp++ = code;
GET_CODE; GET_CODE;
bitpos += 8; bitpos += 8;
*outp++ = code; *outp++ = code;
col += 2; col += 2;
} }
while (col < width) { while (col < width) {
/* get bitcode */ /* get bitcode */
GET_CODE; GET_CODE;
/* update bit position */ /* update bit position */
bitpos += table[code].len; bitpos += table[code].len;
/* calculate pixel value */ /* calculate pixel value */
if (table[code].is_abs) { if (table[code].is_abs) {
/* get 5 more bits and use them as absolute value */ /* get 5 more bits and use them as absolute value */
GET_CODE; GET_CODE;
val = (code & 0xF8); val = (code & 0xF8);
bitpos += 5; bitpos += 5;
}else { } else {
/* value is relative to top or left pixel */ /* value is relative to top or left pixel */
val = table[code].val; val = table[code].val;
lp = outp[-2]; lp = outp[-2];
if (row > 1) { if (row > 1) {
if (col > 1) if (col > 1)
tlp = outp[-2*width-2]; tlp = outp[-2*width-2];
tp = outp[-2*width]; tp = outp[-2*width];
if (col < width-2) if (col < width-2)
trp = outp[-2*width+2]; trp = outp[-2*width+2];
} }
if (row < 2) { if (row < 2) {
/* top row: relative to left pixel */ /* top row: relative to left pixel */
val += lp; val += lp;
}else if (col < 2) { } else if (col < 2) {
/* left column: relative to top pixel */ /* left column: relative to top pixel */
/* initial estimate */ /* initial estimate */
val += (tp + trp)/2; val += (tp + trp)/2;
}else if (col > width - 3) { } else if (col > width - 3) {
/* left column: relative to top pixel */ /* left column: relative to top pixel */
val += (tp + lp + tlp +1)/3; val += (tp + lp + tlp +1)/3;
/* main area: average of left and top pixel */ /* main area: average of left and top pixel */
}else { } else {
/* initial estimate for predictor */ /* initial estimate for predictor */
tlp>>=1; tlp>>=1;
trp>>=1; trp>>=1;
val += (lp + tp + tlp + trp +1)/3; val += (lp + tp + tlp + trp +1)/3;
} }
}
/* store pixel */
*outp++ = CLAMP(val);
col++;
} }
/* store pixel */
*outp++ = CLAMP(val);
col++;
}
} }
return GP_OK; return GP_OK;
} }
@@ -342,7 +342,7 @@ mars_routine (Info *info, GPPort *port, char param, int n)
memset(c,0,sizeof(c)); memset(c,0,sizeof(c));
/*Routine used in initialization, photo download, and reset. */ /*Routine used in initialization, photo download, and reset. */
m_read(port, c, 16); m_read(port, c, 16);
m_command(port, start, 2, c); m_command(port, start, 2, c);
m_command(port, do_something, 2, c); m_command(port, do_something, 2, c);
m_command(port, address1, 2, c); m_command(port, address1, 2, c);
@@ -350,8 +350,8 @@ mars_routine (Info *info, GPPort *port, char param, int n)
c[0] = 0; c[0] = 0;
gp_port_write(port, address2, 2); gp_port_write(port, address2, 2);
/* Moving the memory cursor to the given address? */ /* Moving the memory cursor to the given address? */
while (( c[0] != 0xa) ) { while ((c[0] != 0xa)) {
if (m_read(port, c, 16) < 16) if (m_read(port, c, 16) < 16)
break; break;
} }

View File

@@ -429,13 +429,13 @@ int camera_init (Camera *camera, GPContext *context)
{ {
GPPortSettings settings; GPPortSettings settings;
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->exit = camera_exit; camera->functions->exit = camera_exit;
camera->functions->capture = camera_capture; camera->functions->capture = camera_capture;
camera->functions->summary = camera_summary; camera->functions->summary = camera_summary;
camera->functions->about = camera_about; camera->functions->about = camera_about;
GP_DEBUG( "initializing the camera"); GP_DEBUG ("initializing the camera");
camera->pl = malloc (sizeof (CameraPrivateLibrary)); camera->pl = malloc (sizeof (CameraPrivateLibrary));
if (!camera->pl) if (!camera->pl)
@@ -444,35 +444,35 @@ int camera_init (Camera *camera, GPContext *context)
camera->pl->dev = camera->port; camera->pl->dev = camera->port;
/* Configure the port */ /* Configure the port */
gp_port_set_timeout(camera->port, 5000); gp_port_set_timeout(camera->port, 5000);
gp_port_get_settings(camera->port, &settings); gp_port_get_settings(camera->port, &settings);
settings.serial.speed = 38400; settings.serial.speed = 38400;
settings.serial.bits = 8; settings.serial.bits = 8;
settings.serial.parity = 0; settings.serial.parity = 0;
settings.serial.stopbits = 1; settings.serial.stopbits = 1;
gp_port_set_settings(camera->port, settings); gp_port_set_settings(camera->port, settings);
if ( dimagev_get_camera_data(camera->pl) < GP_OK ) { if (dimagev_get_camera_data(camera->pl) < GP_OK) {
GP_DEBUG( "camera_init::unable to get current camera data"); GP_DEBUG("camera_init::unable to get current camera data");
free (camera->pl); free (camera->pl);
camera->pl = NULL; camera->pl = NULL;
return GP_ERROR_IO; return GP_ERROR_IO;
} }
if ( dimagev_get_camera_status(camera->pl) < GP_OK ) { if (dimagev_get_camera_status(camera->pl) < GP_OK) {
GP_DEBUG( "camera_init::unable to get current camera status"); GP_DEBUG("camera_init::unable to get current camera status");
free (camera->pl); free (camera->pl);
camera->pl = NULL; camera->pl = NULL;
return GP_ERROR_IO; return GP_ERROR_IO;
} }
/* Apparently, trying to set the clock now leaves the camera in an /* Apparently, trying to set the clock now leaves the camera in an
unstable state. Skipping it for now. */ unstable state. Skipping it for now. */
/* if ( dimagev_set_date(camera->pl) < GP_OK ) { /* if ( dimagev_set_date(camera->pl) < GP_OK ) {
GP_DEBUG( "camera_init::unable to set camera to system time"); GP_DEBUG( "camera_init::unable to set camera to system time");
} */ } */
/* Set up the filesystem */ /* Set up the filesystem */
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
return GP_OK; return GP_OK;
} }

View File

@@ -57,7 +57,7 @@ int mdc800_io_sendCommand_with_retry (GPPort *port,unsigned char* command, unsig
while (try < maxtries) while (try < maxtries)
{ {
usleep(MDC800_DEFAULT_COMMAND_RETRY_DELAY*1000); usleep(MDC800_DEFAULT_COMMAND_RETRY_DELAY*1000);
if (port->type == GP_PORT_USB) if (port->type == GP_PORT_USB)
ret=mdc800_usb_sendCommand(port,command, buffer, length ); ret=mdc800_usb_sendCommand(port,command, buffer, length );
else else

View File

@@ -304,14 +304,14 @@ static CameraFilesystemFuncs fsfuncs = {
int int
camera_init (Camera *camera, GPContext *context) camera_init (Camera *camera, GPContext *context)
{ {
/* First, set up all the function pointers */ /* First, set up all the function pointers */
/* camera->functions->exit = camera_exit; */ /* camera->functions->exit = camera_exit; */
camera->functions->get_config = camera_config_get; camera->functions->get_config = camera_config_get;
camera->functions->set_config = camera_config_set; camera->functions->set_config = camera_config_set;
camera->functions->capture = camera_capture; camera->functions->capture = camera_capture;
camera->functions->summary = camera_summary; camera->functions->summary = camera_summary;
camera->functions->manual = camera_manual; camera->functions->manual = camera_manual;
camera->functions->about = camera_about; camera->functions->about = camera_about;
/* Now, tell the filesystem where to get lists, files and info */ /* Now, tell the filesystem where to get lists, files and info */
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
@@ -319,13 +319,13 @@ camera_init (Camera *camera, GPContext *context)
/* Configure port */ /* Configure port */
gp_port_set_timeout(camera->port,MDC800_DEFAULT_COMMAND_RETRY_DELAY); gp_port_set_timeout(camera->port,MDC800_DEFAULT_COMMAND_RETRY_DELAY);
if (camera->port->type == GP_PORT_SERIAL) { if (camera->port->type == GP_PORT_SERIAL) {
GPPortSettings settings; GPPortSettings settings;
gp_port_get_settings(camera->port, &settings); gp_port_get_settings(camera->port, &settings);
settings.serial.speed = 57600; settings.serial.speed = 57600;
settings.serial.bits = 8; settings.serial.bits = 8;
settings.serial.parity = 0; settings.serial.parity = 0;
settings.serial.stopbits= 1; settings.serial.stopbits= 1;
gp_port_set_settings(camera->port, settings); gp_port_set_settings(camera->port, settings);
} }
return mdc800_openCamera(camera); return mdc800_openCamera(camera);
} }

View File

@@ -263,11 +263,11 @@ void mdc800_createDialog (void )
/* done with the widgets */ /* done with the widgets */
toggle = gtk_toggle_button_new(); toggle = gtk_toggle_button_new();
gtk_widget_show(toggle); gtk_widget_show(toggle);
gtk_widget_hide(toggle); gtk_widget_hide(toggle);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(mdc800_dialog.dialog)->action_area), gtk_box_pack_start(GTK_BOX(GTK_DIALOG(mdc800_dialog.dialog)->action_area),
toggle, TRUE, TRUE, 0); toggle, TRUE, TRUE, 0);
mdc800_dialog.save_button = gtk_button_new_with_label("Save"); mdc800_dialog.save_button = gtk_button_new_with_label("Save");
gtk_widget_show(mdc800_dialog.save_button); gtk_widget_show(mdc800_dialog.save_button);
@@ -359,7 +359,7 @@ int mdc800_setupDialog (void)
/* Baudrate */ /* Baudrate */
if (!mdc800_io_using_usb) { if (!mdc800_io_using_usb) {
int speed; int speed;
mdc800_getSpeed(camera,&speed); mdc800_getSpeed (camera, &speed);
mdc800_ComboBox_SetEntry (mdc800_dialog.baud, mdc800_baud_rate_string, speed); mdc800_ComboBox_SetEntry (mdc800_dialog.baud, mdc800_baud_rate_string, speed);
} }
@@ -408,12 +408,12 @@ int mdc800_setupConfig (void)
value = mdc800_ComboBox_GetEntry (mdc800_dialog.light, mdc800_wb_string,4); value = mdc800_ComboBox_GetEntry (mdc800_dialog.light, mdc800_wb_string,4);
switch (value) switch (value)
{ {
case 0: value=1; break; case 0: value=1; break;
case 1: value=2; break; case 1: value=2; break;
case 2: value=4; break; case 2: value=4; break;
case 3: value=8; break; case 3: value=8; break;
default: default:
return -1; return -1;
} }
if (!mdc800_setWB (value)) if (!mdc800_setWB (value))
return -1; return -1;
@@ -422,9 +422,9 @@ int mdc800_setupConfig (void)
/* Set LCD ON/OFF... */ /* Set LCD ON/OFF... */
if (GTK_WIDGET_STATE(mdc800_dialog.lcd_on) == GTK_STATE_ACTIVE) if (GTK_WIDGET_STATE(mdc800_dialog.lcd_on) == GTK_STATE_ACTIVE)
mdc800_enableLCD (1); mdc800_enableLCD (1);
else else
mdc800_enableLCD (0); mdc800_enableLCD (0);
update_progress(62); update_progress(62);

View File

@@ -49,193 +49,193 @@ static const char
int dsc1_sendcmd(Camera *camera, uint8_t cmd, void *data, int size) { int dsc1_sendcmd(Camera *camera, uint8_t cmd, void *data, int size) {
int i; int i;
DEBUG_PRINT_MEDIUM(("Sending command: 0x%02x, data size: %i.", cmd, size)); DEBUG_PRINT_MEDIUM(("Sending command: 0x%02x, data size: %i.", cmd, size));
memset(camera->pl->buf, 0, DSC_BUFSIZE); memset(camera->pl->buf, 0, DSC_BUFSIZE);
memcpy(camera->pl->buf, c_prefix, 12); memcpy(camera->pl->buf, c_prefix, 12);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
camera->pl->buf[DSC1_BUF_SIZE + i] = (uint8_t)(size >> 8*(3 - i)); camera->pl->buf[DSC1_BUF_SIZE + i] = (uint8_t)(size >> 8*(3 - i));
camera->pl->buf[DSC1_BUF_CMD] = cmd; camera->pl->buf[DSC1_BUF_CMD] = cmd;
if (DSC_BUFSIZE - DSC1_BUF_DATA <= size) { if (DSC_BUFSIZE - DSC1_BUF_DATA <= size) {
RETURN_ERROR(EDSCOVERFL) RETURN_ERROR(EDSCOVERFL)
/* overflow */ /* overflow */
} }
if (data && 0 < size) if (data && 0 < size)
memcpy(&camera->pl->buf[DSC1_BUF_DATA], data, size); memcpy(&camera->pl->buf[DSC1_BUF_DATA], data, size);
return gp_port_write(camera->port, camera->pl->buf, 17 + size); return gp_port_write(camera->port, camera->pl->buf, 17 + size);
} }
int dsc1_retrcmd(Camera *camera) { int dsc1_retrcmd(Camera *camera) {
int result = GP_ERROR; int result = GP_ERROR;
int s; int s;
if ((s = gp_port_read(camera->port, camera->pl->buf, 17)) == GP_ERROR) if ((s = gp_port_read(camera->port, camera->pl->buf, 17)) == GP_ERROR)
return GP_ERROR; return GP_ERROR;
/* Make sense in debug only. Done on gp_port level. /* Make sense in debug only. Done on gp_port level.
if (0 < s) if (0 < s)
dsc_dumpmem(camera->pl->buf, s); dsc_dumpmem(camera->pl->buf, s);
*/ */
if (s != 17 || memcmp(camera->pl->buf, r_prefix, 12) != 0 ) if (s != 17 || memcmp(camera->pl->buf, r_prefix, 12) != 0 )
RETURN_ERROR(EDSCBADRSP) RETURN_ERROR(EDSCBADRSP)
/* bad response */ /* bad response */
else else
result = camera->pl->buf[DSC1_BUF_CMD]; result = camera->pl->buf[DSC1_BUF_CMD];
camera->pl->size = camera->pl->size =
(uint32_t)camera->pl->buf[DSC1_BUF_SIZE + 3] | (uint32_t)camera->pl->buf[DSC1_BUF_SIZE + 3] |
((uint8_t)camera->pl->buf[DSC1_BUF_SIZE + 2] << 8) | ((uint8_t)camera->pl->buf[DSC1_BUF_SIZE + 2] << 8) |
((uint8_t)camera->pl->buf[DSC1_BUF_SIZE + 1] << 16) | ((uint8_t)camera->pl->buf[DSC1_BUF_SIZE + 1] << 16) |
((uint8_t)camera->pl->buf[DSC1_BUF_SIZE] << 24); ((uint8_t)camera->pl->buf[DSC1_BUF_SIZE] << 24);
if (DSC_BUFSIZE < camera->pl->size) { if (DSC_BUFSIZE < camera->pl->size) {
RETURN_ERROR(EDSCOVERFL); RETURN_ERROR(EDSCOVERFL);
/* overflow */ /* overflow */
} }
if (gp_port_read(camera->port, camera->pl->buf, camera->pl->size) != camera->pl->size) if (gp_port_read(camera->port, camera->pl->buf, camera->pl->size) != camera->pl->size)
return GP_ERROR; return GP_ERROR;
DEBUG_PRINT_MEDIUM(("Retrieved command: %i.", result)); DEBUG_PRINT_MEDIUM(("Retrieved command: %i.", result));
return result; return result;
} }
int dsc1_setbaudrate(Camera *camera, int speed) { int dsc1_setbaudrate(Camera *camera, int speed) {
GPPortSettings settings; GPPortSettings settings;
uint8_t s_bps; uint8_t s_bps;
int result; int result;
DEBUG_PRINT_MEDIUM(("Setting baud rate to: %i.", speed)); DEBUG_PRINT_MEDIUM(("Setting baud rate to: %i.", speed));
switch (speed) { switch (speed) {
case 9600: case 9600:
s_bps = 0x02; s_bps = 0x02;
break; break;
case 19200: case 19200:
s_bps = 0x0d; s_bps = 0x0d;
break; break;
case 38400: case 38400:
s_bps = 0x01; s_bps = 0x01;
break; break;
case 57600: case 57600:
s_bps = 0x03; s_bps = 0x03;
break; break;
case 115200: case 115200:
s_bps = 0x00; s_bps = 0x00;
break; break;
default: default:
RETURN_ERROR(EDSCBPSRNG); RETURN_ERROR(EDSCBPSRNG);
} }
if (dsc1_sendcmd(camera, DSC1_CMD_SET_BAUD, &s_bps, 1) != GP_OK) if (dsc1_sendcmd(camera, DSC1_CMD_SET_BAUD, &s_bps, 1) != GP_OK)
return GP_ERROR; return GP_ERROR;
if (dsc1_retrcmd(camera) != DSC1_RSP_OK) if (dsc1_retrcmd(camera) != DSC1_RSP_OK)
RETURN_ERROR(EDSCBADRSP); RETURN_ERROR(EDSCBADRSP);
/* bad response */ /* bad response */
sleep(DSC_PAUSE/2); sleep(DSC_PAUSE/2);
CHECK (gp_port_get_settings(camera->port, &settings)); CHECK (gp_port_get_settings(camera->port, &settings));
settings.serial.speed = speed; settings.serial.speed = speed;
CHECK (gp_port_set_settings(camera->port, settings)); CHECK (gp_port_set_settings(camera->port, settings));
DEBUG_PRINT_MEDIUM(("Baudrate set to: %i.", speed)); DEBUG_PRINT_MEDIUM(("Baudrate set to: %i.", speed));
return GP_OK; return GP_OK;
} }
int dsc1_getmodel(Camera *camera) { int dsc1_getmodel(Camera *camera) {
static const char response[3] = { 'D', 'S', 'C' }; static const char response[3] = { 'D', 'S', 'C' };
DEBUG_PRINT_MEDIUM(("Getting camera model.")); DEBUG_PRINT_MEDIUM(("Getting camera model."));
if (dsc1_sendcmd(camera, DSC1_CMD_GET_MODEL, NULL, 0) != GP_OK) if (dsc1_sendcmd(camera, DSC1_CMD_GET_MODEL, NULL, 0) != GP_OK)
return GP_ERROR; return GP_ERROR;
if (dsc1_retrcmd(camera) != DSC1_RSP_MODEL || if (dsc1_retrcmd(camera) != DSC1_RSP_MODEL ||
memcmp(camera->pl->buf, response, 3) != 0) memcmp(camera->pl->buf, response, 3) != 0)
RETURN_ERROR(EDSCBADRSP); RETURN_ERROR(EDSCBADRSP);
/* bad response */ /* bad response */
DEBUG_PRINT_MEDIUM(("Camera model is: %c.", camera->pl->buf[3])); DEBUG_PRINT_MEDIUM(("Camera model is: %c.", camera->pl->buf[3]));
switch (camera->pl->buf[3]) { switch (camera->pl->buf[3]) {
case '1': case '1':
return DSC1; return DSC1;
case '2': case '2':
return DSC2; return DSC2;
default: default:
return 0; return 0;
} }
return GP_ERROR; return GP_ERROR;
} }
void dsc_dumpmem(void *buf, int size) { void dsc_dumpmem(void *buf, int size) {
int i; int i;
fprintf(stderr, "\nMemory dump: size: %i, contents:\n", size); fprintf(stderr, "\nMemory dump: size: %i, contents:\n", size);
for (i = 0; i < size; i ++) for (i = 0; i < size; i++)
fprintf( fprintf(
stderr, stderr,
*((char*)buf + i) >= 32 && *((char*)buf + i) >= 32 &&
*((char*)buf + i) < 127 ? "%c" : "\\x%02x", *((char*)buf + i) < 127 ? "%c" : "\\x%02x",
(uint8_t)*((char*)buf + i) (uint8_t)*((char*)buf + i)
); );
fprintf(stderr, "\n\n"); fprintf(stderr, "\n\n");
} }
const char *dsc_strerror(int error) { const char *dsc_strerror(int error) {
static const char * const errorlist[] = { static const char * const errorlist[] = {
"Unknown error code", "Unknown error code",
"Baud rate out of range", "Baud rate out of range",
"Bad image number", "Bad image number",
"Bad response", "Bad response",
"Bad camera model", "Bad camera model",
"Overflow" "Overflow"
}; };
if (error == EDSCSERRNO) if (error == EDSCSERRNO)
return strerror(errno); return strerror(errno);
if (error < 1 || EDSCMAXERR < error) if (error < 1 || EDSCMAXERR < error)
return errorlist[EDSCUNKNWN]; return errorlist[EDSCUNKNWN];
return errorlist[error]; return errorlist[error];
} }
char *dsc_msgprintf(char *format, ...) { char *dsc_msgprintf(char *format, ...) {
va_list pvar; va_list pvar;
static char msg[512]; static char msg[512];
va_start(pvar, format); va_start(pvar, format);
vsprintf(msg, format, pvar); vsprintf(msg, format, pvar);
va_end(pvar); va_end(pvar);
return msg; return msg;
} }
void dsc_errorprint(int error, char *file, int line) { void dsc_errorprint(int error, char *file, int line) {

View File

@@ -95,24 +95,24 @@ void dsc_errorprint(int error, char *file, int line);
/* Pre-procesor macros for verbose messaging and debugging */ /* Pre-procesor macros for verbose messaging and debugging */
#define DEBUG_PRINT_LOW(ARGS) \ #define DEBUG_PRINT_LOW(ARGS) \
GP_DEBUG( "%s: %s", __FILE__, dsc_msgprintf ARGS ); GP_DEBUG( "%s: %s", __FILE__, dsc_msgprintf ARGS );
#define DEBUG_PRINT_MEDIUM(ARGS) \ #define DEBUG_PRINT_MEDIUM(ARGS) \
GP_DEBUG( "%s: %s", __FILE__, dsc_msgprintf ARGS ); GP_DEBUG( "%s: %s", __FILE__, dsc_msgprintf ARGS );
#define DEBUG_PRINT_HIGH(ARGS) \ #define DEBUG_PRINT_HIGH(ARGS) \
GP_DEBUG( "%s: %s", __FILE__, dsc_msgprintf ARGS ); GP_DEBUG( "%s: %s", __FILE__, dsc_msgprintf ARGS );
#define RETURN_ERROR(ERROR) { \ #define RETURN_ERROR(ERROR) { \
dsc_errorprint(ERROR, __FILE__, __LINE__); \ dsc_errorprint(ERROR, __FILE__, __LINE__); \
return GP_ERROR; \ return GP_ERROR; \
} }
#define CHECK(OPERATION) \ #define CHECK(OPERATION) \
if ((result = OPERATION) < 0) { \ if ((result = OPERATION) < 0) { \
dsc_errorprint(EDSCSERRNO, __FILE__, __LINE__); \ dsc_errorprint(EDSCSERRNO, __FILE__, __LINE__); \
return result; \ return result; \
} }
/* End of dc.h */ /* End of dc.h */

View File

@@ -138,7 +138,7 @@ static int dsc1_delete(Camera *camera, uint8_t index) {
static int dsc1_selectimage(Camera *camera, uint8_t index) static int dsc1_selectimage(Camera *camera, uint8_t index)
{ {
int size = 0; int size = 0;
DEBUG_PRINT_MEDIUM(("Selecting image: %i.", index)); DEBUG_PRINT_MEDIUM(("Selecting image: %i.", index));
@@ -332,7 +332,7 @@ int camera_id (CameraText *id) {
int camera_abilities (CameraAbilitiesList *list) { int camera_abilities (CameraAbilitiesList *list) {
CameraAbilities a; CameraAbilities a;
int result; int result;
memset (&a, 0, sizeof(a)); memset (&a, 0, sizeof(a));
strcpy(a.model, "Panasonic:DC1000"); strcpy(a.model, "Panasonic:DC1000");
@@ -486,7 +486,7 @@ static int delete_file_func (CameraFilesystem *fs, const char *folder,
/* index is the 0-based image number on the camera */ /* index is the 0-based image number on the camera */
CHECK (index = gp_filesystem_number (camera->fs, folder, filename, CHECK (index = gp_filesystem_number (camera->fs, folder, filename,
context)); context));
index++; index++;
return dsc1_delete(camera, index); return dsc1_delete(camera, index);
} }
@@ -511,12 +511,12 @@ static CameraFilesystemFuncs fsfuncs = {
int camera_init (Camera *camera, GPContext *context) { int camera_init (Camera *camera, GPContext *context) {
int ret, selected_speed; int ret, selected_speed;
GPPortSettings settings; GPPortSettings settings;
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->exit = camera_exit; camera->functions->exit = camera_exit;
camera->functions->about = camera_about; camera->functions->about = camera_about;
camera->pl = malloc (sizeof (CameraPrivateLibrary)); camera->pl = malloc (sizeof (CameraPrivateLibrary));
if (!camera->pl) if (!camera->pl)
@@ -529,14 +529,14 @@ int camera_init (Camera *camera, GPContext *context) {
} }
/* Configure the port (remember the selected speed) */ /* Configure the port (remember the selected speed) */
gp_port_set_timeout(camera->port, 5000); gp_port_set_timeout(camera->port, 5000);
gp_port_get_settings(camera->port, &settings); gp_port_get_settings(camera->port, &settings);
selected_speed = settings.serial.speed; selected_speed = settings.serial.speed;
settings.serial.speed = 9600; /* hand shake speed */ settings.serial.speed = 9600; /* hand shake speed */
settings.serial.bits = 8; settings.serial.bits = 8;
settings.serial.parity = 0; settings.serial.parity = 0;
settings.serial.stopbits = 1; settings.serial.stopbits = 1;
gp_port_set_settings(camera->port, settings); gp_port_set_settings(camera->port, settings);
/* Set up the filesystem */ /* Set up the filesystem */
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);

View File

@@ -50,221 +50,221 @@
static uint8_t dsc2_checksum(char *buffer, int size) { static uint8_t dsc2_checksum(char *buffer, int size) {
int checksum = 0; int checksum = 0;
int i; int i;
for (i = 1; i < size - 2; i++) { for (i = 1; i < size - 2; i++) {
checksum += buffer[i]; checksum += buffer[i];
checksum %= 0x100; checksum %= 0x100;
} }
return checksum; return checksum;
} }
/* dsc2_sendcmd - send command with data to DSC */ /* dsc2_sendcmd - send command with data to DSC */
static int dsc2_sendcmd(Camera *camera, uint8_t cmd, long int data, uint8_t sequence) { static int dsc2_sendcmd(Camera *camera, uint8_t cmd, long int data, uint8_t sequence) {
unsigned int i; unsigned int i;
DEBUG_PRINT_MEDIUM(("Sending command: 0x%02x, data: %i, sequence: %i.", cmd, data, sequence)); DEBUG_PRINT_MEDIUM(("Sending command: 0x%02x, data: %i, sequence: %i.", cmd, data, sequence));
memset(camera->pl->buf, 0, 16); memset(camera->pl->buf, 0, 16);
camera->pl->buf[0] = 0x08; camera->pl->buf[0] = 0x08;
camera->pl->buf[1] = sequence; camera->pl->buf[1] = sequence;
camera->pl->buf[2] = 0xff - sequence; camera->pl->buf[2] = 0xff - sequence;
camera->pl->buf[3] = cmd; camera->pl->buf[3] = cmd;
for (i = 0; i < sizeof(data); i++) for (i = 0; i < sizeof(data); i++)
camera->pl->buf[4 + i] = (uint8_t)(data >> 8*i); camera->pl->buf[4 + i] = (uint8_t)(data >> 8*i);
camera->pl->buf[14] = dsc2_checksum(camera->pl->buf, 16); camera->pl->buf[14] = dsc2_checksum(camera->pl->buf, 16);
return gp_port_write(camera->port, camera->pl->buf, 16); return gp_port_write(camera->port, camera->pl->buf, 16);
} }
/* dsc2_retrcmd - retrieve command and its data from DSC */ /* dsc2_retrcmd - retrieve command and its data from DSC */
static int dsc2_retrcmd(Camera *camera) { static int dsc2_retrcmd(Camera *camera) {
int result = GP_ERROR; int result = GP_ERROR;
int s; int s;
if ((s = gp_port_read(camera->port, camera->pl->buf, 16)) == GP_ERROR) if ((s = gp_port_read(camera->port, camera->pl->buf, 16)) == GP_ERROR)
return GP_ERROR; return GP_ERROR;
/* Make sense in debug only. Done on gp_port level. /* Make sense in debug only. Done on gp_port level.
if (0 < s) if (0 < s)
dsc_dumpmem(camera->pl->buf, s); dsc_dumpmem(camera->pl->buf, s);
*/ */
if (s != 16 || camera->pl->buf[DSC2_BUF_BASE] != 0x08 || if (s != 16 || camera->pl->buf[DSC2_BUF_BASE] != 0x08 ||
camera->pl->buf[DSC2_BUF_SEQ] != 0xff - (uint8_t)camera->pl->buf[DSC2_BUF_SEQC]) { camera->pl->buf[DSC2_BUF_SEQ] != 0xff - (uint8_t)camera->pl->buf[DSC2_BUF_SEQC]) {
RETURN_ERROR(EDSCBADRSP); RETURN_ERROR(EDSCBADRSP);
/* bad response */ /* bad response */
} }
else else
result = camera->pl->buf[DSC2_BUF_CMD]; result = camera->pl->buf[DSC2_BUF_CMD];
DEBUG_PRINT_MEDIUM(("Retrieved command: %i.", result)); DEBUG_PRINT_MEDIUM(("Retrieved command: %i.", result));
return result; return result;
} }
/* dsc2_connect - try hand shake with camera and establish connection */ /* dsc2_connect - try hand shake with camera and establish connection */
static int dsc2_connect(Camera *camera, int speed) { static int dsc2_connect(Camera *camera, int speed) {
DEBUG_PRINT_MEDIUM(("Connecting camera with speed: %i.", speed)); DEBUG_PRINT_MEDIUM(("Connecting camera with speed: %i.", speed));
if (dsc1_setbaudrate(camera, speed) != GP_OK) if (dsc1_setbaudrate(camera, speed) != GP_OK)
return GP_ERROR; return GP_ERROR;
if (dsc1_getmodel(camera) != DSC2) if (dsc1_getmodel(camera) != DSC2)
RETURN_ERROR(EDSCBADDSC); RETURN_ERROR(EDSCBADDSC);
/* bad camera model */ /* bad camera model */
if (dsc2_sendcmd(camera, DSC2_CMD_CONNECT, 0, 0) != GP_OK) if (dsc2_sendcmd(camera, DSC2_CMD_CONNECT, 0, 0) != GP_OK)
return GP_ERROR; return GP_ERROR;
if (dsc2_retrcmd(camera) != DSC2_RSP_OK) if (dsc2_retrcmd(camera) != DSC2_RSP_OK)
RETURN_ERROR(EDSCBADRSP); RETURN_ERROR(EDSCBADRSP);
/* bad response */ /* bad response */
DEBUG_PRINT_MEDIUM(("Camera connected successfully.")); DEBUG_PRINT_MEDIUM(("Camera connected successfully."));
return GP_OK; return GP_OK;
} }
/* dsc2_disconnect - reset camera, free buffers and close files */ /* dsc2_disconnect - reset camera, free buffers and close files */
static int dsc2_disconnect(Camera *camera) { static int dsc2_disconnect(Camera *camera) {
DEBUG_PRINT_MEDIUM(("Disconnecting the camera.")); DEBUG_PRINT_MEDIUM(("Disconnecting the camera."));
if (dsc2_sendcmd(camera, DSC2_CMD_RESET, 0, 0) != GP_OK) if (dsc2_sendcmd(camera, DSC2_CMD_RESET, 0, 0) != GP_OK)
return GP_ERROR; return GP_ERROR;
if (dsc2_retrcmd(camera) != DSC2_RSP_OK) if (dsc2_retrcmd(camera) != DSC2_RSP_OK)
RETURN_ERROR(EDSCBADRSP) RETURN_ERROR(EDSCBADRSP)
/* bad response */ /* bad response */
else else
sleep(DSC_PAUSE); /* let camera to redraw its screen */ sleep(DSC_PAUSE); /* let camera to redraw its screen */
DEBUG_PRINT_MEDIUM(("Camera disconnected.")); DEBUG_PRINT_MEDIUM(("Camera disconnected."));
return GP_OK; return GP_OK;
} }
/* dsc2_getindex - retrieve the number of images stored in camera memory */ /* dsc2_getindex - retrieve the number of images stored in camera memory */
static int dsc2_getindex(Camera *camera) { static int dsc2_getindex(Camera *camera) {
int result = GP_ERROR; int result = GP_ERROR;
DEBUG_PRINT_MEDIUM(("Retrieving the number of images.")); DEBUG_PRINT_MEDIUM(("Retrieving the number of images."));
if (dsc2_sendcmd(camera, DSC2_CMD_GET_INDEX, 0, 0) != GP_OK) if (dsc2_sendcmd(camera, DSC2_CMD_GET_INDEX, 0, 0) != GP_OK)
return GP_ERROR; return GP_ERROR;
if (dsc2_retrcmd(camera) == DSC2_RSP_INDEX) if (dsc2_retrcmd(camera) == DSC2_RSP_INDEX)
result = result =
((uint32_t)camera->pl->buf[DSC2_BUF_DATA]) | ((uint32_t)camera->pl->buf[DSC2_BUF_DATA]) |
((uint8_t)camera->pl->buf[DSC2_BUF_DATA + 1] << 8) | ((uint8_t)camera->pl->buf[DSC2_BUF_DATA + 1] << 8) |
((uint8_t)camera->pl->buf[DSC2_BUF_DATA + 2] << 16) | ((uint8_t)camera->pl->buf[DSC2_BUF_DATA + 2] << 16) |
((uint8_t)camera->pl->buf[DSC2_BUF_DATA + 3] << 24); ((uint8_t)camera->pl->buf[DSC2_BUF_DATA + 3] << 24);
else else
RETURN_ERROR(EDSCBADRSP); RETURN_ERROR(EDSCBADRSP);
/* bad response */ /* bad response */
DEBUG_PRINT_MEDIUM(("Number of images: %i", result)); DEBUG_PRINT_MEDIUM(("Number of images: %i", result));
return result; return result;
} }
/* dsc2_delete - delete image #index from camera memory */ /* dsc2_delete - delete image #index from camera memory */
static int dsc2_delete(Camera *camera, int index) { static int dsc2_delete(Camera *camera, int index) {
DEBUG_PRINT_MEDIUM(("Deleting image: %i.", index)); DEBUG_PRINT_MEDIUM(("Deleting image: %i.", index));
if (index < 1) if (index < 1)
RETURN_ERROR(EDSCBADNUM); RETURN_ERROR(EDSCBADNUM);
/* bad image number */ /* bad image number */
if (dsc2_sendcmd(camera, DSC2_CMD_DELETE, index, 0) != GP_OK) if (dsc2_sendcmd(camera, DSC2_CMD_DELETE, index, 0) != GP_OK)
return GP_ERROR; return GP_ERROR;
if (dsc2_retrcmd(camera) != DSC2_RSP_OK) if (dsc2_retrcmd(camera) != DSC2_RSP_OK)
RETURN_ERROR(EDSCBADRSP); RETURN_ERROR(EDSCBADRSP);
/* bad response */ /* bad response */
DEBUG_PRINT_MEDIUM(("Image: %i deleted.", index)); DEBUG_PRINT_MEDIUM(("Image: %i deleted.", index));
return GP_OK; return GP_OK;
} }
/* dsc2_selectimage - select image to download, return its size */ /* dsc2_selectimage - select image to download, return its size */
static int dsc2_selectimage(Camera *camera, int index, int thumbnail) { static int dsc2_selectimage(Camera *camera, int index, int thumbnail) {
int size = 0; int size = 0;
DEBUG_PRINT_MEDIUM(("Selecting image: %i, thumbnail: %i.", index, thumbnail)); DEBUG_PRINT_MEDIUM(("Selecting image: %i, thumbnail: %i.", index, thumbnail));
if (index < 1) if (index < 1)
RETURN_ERROR(EDSCBADNUM); RETURN_ERROR(EDSCBADNUM);
/* bad image number */ /* bad image number */
if (thumbnail == DSC_THUMBNAIL) { if (thumbnail == DSC_THUMBNAIL) {
if (dsc2_sendcmd(camera, DSC2_CMD_THUMB, index, 0) != GP_OK) if (dsc2_sendcmd(camera, DSC2_CMD_THUMB, index, 0) != GP_OK)
return GP_ERROR; return GP_ERROR;
} else { } else {
if (dsc2_sendcmd(camera, DSC2_CMD_SELECT, index, 0) != GP_OK) if (dsc2_sendcmd(camera, DSC2_CMD_SELECT, index, 0) != GP_OK)
return GP_ERROR; return GP_ERROR;
} }
if (dsc2_retrcmd(camera) != DSC2_RSP_IMGSIZE) if (dsc2_retrcmd(camera) != DSC2_RSP_IMGSIZE)
RETURN_ERROR(EDSCBADRSP); RETURN_ERROR(EDSCBADRSP);
/* bad response */ /* bad response */
size = ((uint32_t)camera->pl->buf[DSC2_BUF_DATA]) | size = ((uint32_t)camera->pl->buf[DSC2_BUF_DATA]) |
((uint8_t)camera->pl->buf[DSC2_BUF_DATA + 1] << 8) | ((uint8_t)camera->pl->buf[DSC2_BUF_DATA + 1] << 8) |
((uint8_t)camera->pl->buf[DSC2_BUF_DATA + 2] << 16) | ((uint8_t)camera->pl->buf[DSC2_BUF_DATA + 2] << 16) |
((uint8_t)camera->pl->buf[DSC2_BUF_DATA + 3] << 24); ((uint8_t)camera->pl->buf[DSC2_BUF_DATA + 3] << 24);
DEBUG_PRINT_MEDIUM(("Selected image: %i, thumbnail: %i, size: %i.", index, thumbnail, size)); DEBUG_PRINT_MEDIUM(("Selected image: %i, thumbnail: %i, size: %i.", index, thumbnail, size));
return size; return size;
} }
/* gp_port_readimageblock - read #block block (1024 bytes) of an image into buf */ /* gp_port_readimageblock - read #block block (1024 bytes) of an image into buf */
static int dsc2_readimageblock(Camera *camera, int block, char *buffer) { static int dsc2_readimageblock(Camera *camera, int block, char *buffer) {
DEBUG_PRINT_MEDIUM(("Reading image block: %i.", block)); DEBUG_PRINT_MEDIUM(("Reading image block: %i.", block));
if (dsc2_sendcmd(camera, DSC2_CMD_GET_DATA, block, block) != GP_OK) if (dsc2_sendcmd(camera, DSC2_CMD_GET_DATA, block, block) != GP_OK)
return GP_ERROR; return GP_ERROR;
if (gp_port_read(camera->port, camera->pl->buf, DSC_BUFSIZE) != DSC_BUFSIZE) if (gp_port_read(camera->port, camera->pl->buf, DSC_BUFSIZE) != DSC_BUFSIZE)
RETURN_ERROR(EDSCBADRSP); RETURN_ERROR(EDSCBADRSP);
/* bad response */ /* bad response */
if ((uint8_t)camera->pl->buf[0] != 1 || if ((uint8_t)camera->pl->buf[0] != 1 ||
(uint8_t)camera->pl->buf[1] != block || (uint8_t)camera->pl->buf[1] != block ||
(uint8_t)camera->pl->buf[2] != 0xff - block || (uint8_t)camera->pl->buf[2] != 0xff - block ||
(uint8_t)camera->pl->buf[3] != DSC2_RSP_DATA || (uint8_t)camera->pl->buf[3] != DSC2_RSP_DATA ||
(uint8_t)camera->pl->buf[DSC_BUFSIZE - 2] != dsc2_checksum(camera->pl->buf, DSC_BUFSIZE)) (uint8_t)camera->pl->buf[DSC_BUFSIZE - 2] != dsc2_checksum(camera->pl->buf, DSC_BUFSIZE))
RETURN_ERROR(EDSCBADRSP); RETURN_ERROR(EDSCBADRSP);
/* bad response */ /* bad response */
if (buffer) if (buffer)
memcpy(buffer, &camera->pl->buf[4], DSC_BLOCKSIZE); memcpy(buffer, &camera->pl->buf[4], DSC_BLOCKSIZE);
DEBUG_PRINT_MEDIUM(("Block: %i read in.", block)); DEBUG_PRINT_MEDIUM(("Block: %i read in.", block));
return DSC_BLOCKSIZE; return DSC_BLOCKSIZE;
} }
/* dsc2_readimage - read #index image or thumbnail and return its contents */ /* dsc2_readimage - read #index image or thumbnail and return its contents */
@@ -272,38 +272,38 @@ static int dsc2_readimageblock(Camera *camera, int block, char *buffer) {
#if 0 #if 0
static char *dsc2_readimage(Camera *camera, int index, int thumbnail, int *size) { static char *dsc2_readimage(Camera *camera, int index, int thumbnail, int *size) {
char kind[16]; char kind[16];
int blocks, i; int blocks, i;
char *buffer = NULL; char *buffer = NULL;
DEBUG_PRINT_MEDIUM(("Reading image: %i, thumbnail: %i.", index, thumbnail)); DEBUG_PRINT_MEDIUM(("Reading image: %i, thumbnail: %i.", index, thumbnail));
if ((*size = dsc2_selectimage(camera, index, thumbnail)) < 0) if ((*size = dsc2_selectimage(camera, index, thumbnail)) < 0)
return NULL; return NULL;
if (thumbnail == DSC_THUMBNAIL) if (thumbnail == DSC_THUMBNAIL)
strcpy(kind, "thumbnail"); strcpy(kind, "thumbnail");
else else
strcpy(kind, "image"); strcpy(kind, "image");
if (!(buffer = (char*)malloc(*size))) { if (!(buffer = (char*)malloc(*size))) {
DEBUG_PRINT_MEDIUM(("Failed to allocate memory for %s data.", kind)); DEBUG_PRINT_MEDIUM(("Failed to allocate memory for %s data.", kind));
return NULL; return NULL;
} }
blocks = (*size - 1)/DSC_BLOCKSIZE + 1; blocks = (*size - 1)/DSC_BLOCKSIZE + 1;
for (i = 0; i < blocks; i++) { for (i = 0; i < blocks; i++) {
if (dsc2_readimageblock(camera, i, &buffer[i*DSC_BLOCKSIZE]) == GP_ERROR) { if (dsc2_readimageblock(camera, i, &buffer[i*DSC_BLOCKSIZE]) == GP_ERROR) {
DEBUG_PRINT_MEDIUM(("Error during %s transfer.", kind)); DEBUG_PRINT_MEDIUM(("Error during %s transfer.", kind));
free(buffer); free(buffer);
return NULL; return NULL;
} }
} }
DEBUG_PRINT_MEDIUM(("Image: %i read in.", index)); DEBUG_PRINT_MEDIUM(("Image: %i read in.", index));
return buffer; return buffer;
} }
#endif #endif
@@ -311,50 +311,50 @@ static char *dsc2_readimage(Camera *camera, int index, int thumbnail, int *size)
static int dsc2_setimagesize(Camera *camera, int size) { static int dsc2_setimagesize(Camera *camera, int size) {
DEBUG_PRINT_MEDIUM(("Setting image size to: %i.", size)); DEBUG_PRINT_MEDIUM(("Setting image size to: %i.", size));
if (dsc2_sendcmd(camera, DSC2_CMD_SET_SIZE, size, 0) != GP_OK) if (dsc2_sendcmd(camera, DSC2_CMD_SET_SIZE, size, 0) != GP_OK)
return GP_ERROR; return GP_ERROR;
if (dsc2_retrcmd(camera) != DSC2_RSP_OK) if (dsc2_retrcmd(camera) != DSC2_RSP_OK)
RETURN_ERROR(EDSCBADRSP); RETURN_ERROR(EDSCBADRSP);
/* bad response */ /* bad response */
DEBUG_PRINT_MEDIUM(("Image size set to: %i.", size)); DEBUG_PRINT_MEDIUM(("Image size set to: %i.", size));
return GP_OK; return GP_OK;
} }
/* gp_port_writeimageblock - write size bytes from buffer rounded to 1024 bytes to camera */ /* gp_port_writeimageblock - write size bytes from buffer rounded to 1024 bytes to camera */
static int dsc2_writeimageblock(Camera *camera, int block, char *buffer, int size) { static int dsc2_writeimageblock(Camera *camera, int block, char *buffer, int size) {
DEBUG_PRINT_MEDIUM(("Writing image block: %i.", block)); DEBUG_PRINT_MEDIUM(("Writing image block: %i.", block));
memset(camera->pl->buf, 0, DSC_BUFSIZE); memset(camera->pl->buf, 0, DSC_BUFSIZE);
camera->pl->buf[0] = 0x01; camera->pl->buf[0] = 0x01;
camera->pl->buf[1] = block; camera->pl->buf[1] = block;
camera->pl->buf[2] = 0xff - block; camera->pl->buf[2] = 0xff - block;
camera->pl->buf[3] = DSC2_CMD_SEND_DATA; camera->pl->buf[3] = DSC2_CMD_SEND_DATA;
if (DSC_BLOCKSIZE < size) if (DSC_BLOCKSIZE < size)
size = DSC_BLOCKSIZE; size = DSC_BLOCKSIZE;
memcpy(&camera->pl->buf[4], buffer, size); memcpy(&camera->pl->buf[4], buffer, size);
camera->pl->buf[DSC_BUFSIZE - 2] = dsc2_checksum(camera->pl->buf, DSC_BUFSIZE); camera->pl->buf[DSC_BUFSIZE - 2] = dsc2_checksum(camera->pl->buf, DSC_BUFSIZE);
if (gp_port_write(camera->port, camera->pl->buf, DSC_BUFSIZE) != GP_OK) if (gp_port_write(camera->port, camera->pl->buf, DSC_BUFSIZE) != GP_OK)
return GP_ERROR; return GP_ERROR;
if (dsc2_retrcmd(camera) != DSC2_RSP_OK) if (dsc2_retrcmd(camera) != DSC2_RSP_OK)
RETURN_ERROR(EDSCBADRSP); RETURN_ERROR(EDSCBADRSP);
/* bad response */ /* bad response */
DEBUG_PRINT_MEDIUM(("Block: %i of size: %i written.", block, size)); DEBUG_PRINT_MEDIUM(("Block: %i of size: %i written.", block, size));
return GP_OK; return GP_OK;
} }
/* dsc2_writeimage - write an image to camera memory, size bytes at buffer */ /* dsc2_writeimage - write an image to camera memory, size bytes at buffer */
@@ -362,28 +362,28 @@ static int dsc2_writeimageblock(Camera *camera, int block, char *buffer, int siz
#if 0 #if 0
static int dsc2_writeimage(Camera *camera, char *buffer, int size) { static int dsc2_writeimage(Camera *camera, char *buffer, int size) {
int blocks, blocksize, i; int blocks, blocksize, i;
DEBUG_PRINT_MEDIUM(("Writing an image of size: %i.", size)); DEBUG_PRINT_MEDIUM(("Writing an image of size: %i.", size));
if ((dsc2_setimagesize(camera, size)) != GP_OK) if ((dsc2_setimagesize(camera, size)) != GP_OK)
return GP_ERROR; return GP_ERROR;
blocks = (size - 1)/DSC_BLOCKSIZE + 1; blocks = (size - 1)/DSC_BLOCKSIZE + 1;
for (i = 0; i < blocks; i++) { for (i = 0; i < blocks; i++) {
blocksize = size - i*DSC_BLOCKSIZE; blocksize = size - i*DSC_BLOCKSIZE;
if (DSC_BLOCKSIZE < blocksize) if (DSC_BLOCKSIZE < blocksize)
blocksize = DSC_BLOCKSIZE; blocksize = DSC_BLOCKSIZE;
if (dsc2_writeimageblock(camera, i, &buffer[i*DSC_BLOCKSIZE], blocksize) != GP_OK) { if (dsc2_writeimageblock(camera, i, &buffer[i*DSC_BLOCKSIZE], blocksize) != GP_OK) {
DEBUG_PRINT_MEDIUM(("Error during image transfer.")); DEBUG_PRINT_MEDIUM(("Error during image transfer."));
return GP_ERROR; return GP_ERROR;
} }
} }
DEBUG_PRINT_MEDIUM(("Image written successfully.")); DEBUG_PRINT_MEDIUM(("Image written successfully."));
return GP_OK; return GP_OK;
} }
#endif #endif
@@ -392,18 +392,18 @@ static int dsc2_writeimage(Camera *camera, char *buffer, int size) {
#if 0 #if 0
static int dsc2_preview(Camera *camera, int index) { static int dsc2_preview(Camera *camera, int index) {
if (index < 1) if (index < 1)
RETURN_ERROR(EDSCBADNUM); RETURN_ERROR(EDSCBADNUM);
/* bad image number */ /* bad image number */
if (dsc2_sendcmd(camera, DSC2_CMD_PREVIEW, index, 0) != GP_OK) if (dsc2_sendcmd(camera, DSC2_CMD_PREVIEW, index, 0) != GP_OK)
return GP_ERROR; return GP_ERROR;
if (dsc2_retrcmd(camera) != DSC2_RSP_OK) if (dsc2_retrcmd(camera) != DSC2_RSP_OK)
RETURN_ERROR(EDSCBADRSP); RETURN_ERROR(EDSCBADRSP);
/* bad response */ /* bad response */
return GP_OK; return GP_OK;
} }
#endif #endif
@@ -413,86 +413,86 @@ static int dsc2_preview(Camera *camera, int index) {
int camera_id (CameraText *id) { int camera_id (CameraText *id) {
strcpy(id->text, "panasonic-dc1580"); strcpy(id->text, "panasonic-dc1580");
return (GP_OK); return (GP_OK);
} }
int camera_abilities (CameraAbilitiesList *list) { int camera_abilities (CameraAbilitiesList *list) {
CameraAbilities a; CameraAbilities a;
char *models[] = { char *models[] = {
"Panasonic:DC1580", "Panasonic:DC1580",
"Nikon:CoolPix 600", "Nikon:CoolPix 600",
NULL }; NULL };
int i = 0, result; int i = 0, result;
while (models[i]) { while (models[i]) {
memset(&a, 0, sizeof(a)); memset(&a, 0, sizeof(a));
a.status = GP_DRIVER_STATUS_PRODUCTION; a.status = GP_DRIVER_STATUS_PRODUCTION;
strcpy(a.model, models[i]); strcpy(a.model, models[i]);
a.port = GP_PORT_SERIAL; a.port = GP_PORT_SERIAL;
a.speed[0] = 9600; a.speed[0] = 9600;
a.speed[1] = 19200; a.speed[1] = 19200;
a.speed[2] = 38400; a.speed[2] = 38400;
a.speed[3] = 57600; a.speed[3] = 57600;
a.speed[4] = 115200; a.speed[4] = 115200;
a.speed[5] = 0; a.speed[5] = 0;
a.operations = GP_OPERATION_NONE; a.operations = GP_OPERATION_NONE;
a.file_operations = GP_FILE_OPERATION_DELETE | a.file_operations = GP_FILE_OPERATION_DELETE |
GP_FILE_OPERATION_PREVIEW; GP_FILE_OPERATION_PREVIEW;
a.folder_operations = GP_FOLDER_OPERATION_PUT_FILE; a.folder_operations = GP_FOLDER_OPERATION_PUT_FILE;
CHECK (gp_abilities_list_append(list, a)); CHECK (gp_abilities_list_append(list, a));
i++; i++;
} }
return GP_OK; return GP_OK;
} }
static int camera_exit (Camera *camera, GPContext *context) { static int camera_exit (Camera *camera, GPContext *context) {
gp_context_status(context, _("Disconnecting camera.")); gp_context_status(context, _("Disconnecting camera."));
dsc2_disconnect(camera); dsc2_disconnect(camera);
free (camera->pl->buf); free (camera->pl->buf);
camera->pl->buf = NULL; camera->pl->buf = NULL;
free (camera->pl); free (camera->pl);
camera->pl = NULL; camera->pl = NULL;
return (GP_OK); return (GP_OK);
} }
static int file_list_func (CameraFilesystem *fs, const char *folder, static int file_list_func (CameraFilesystem *fs, const char *folder,
CameraList *list, void *data, GPContext *context) { CameraList *list, void *data, GPContext *context) {
Camera *camera = data; Camera *camera = data;
int count, result; int count, result;
CHECK (count = dsc2_getindex(camera)); CHECK (count = dsc2_getindex(camera));
CHECK (gp_list_populate(list, DSC_FILENAMEFMT, count)); CHECK (gp_list_populate(list, DSC_FILENAMEFMT, count));
return GP_OK; return GP_OK;
} }
static int get_info_func (CameraFilesystem *fs, const char *folder, static int get_info_func (CameraFilesystem *fs, const char *folder,
const char *filename, CameraFileInfo *info, const char *filename, CameraFileInfo *info,
void *data, GPContext *context) { void *data, GPContext *context) {
Camera *camera = data; Camera *camera = data;
int index, result; int index, result;
/* index is the 0-based image number on the camera */ /* index is the 0-based image number on the camera */
CHECK (index = gp_filesystem_number(camera->fs, folder, filename, context)); CHECK (index = gp_filesystem_number(camera->fs, folder, filename, context));
index++; index++;
info->file.fields = GP_FILE_INFO_TYPE | GP_FILE_INFO_SIZE; info->file.fields = GP_FILE_INFO_TYPE | GP_FILE_INFO_SIZE;
strcpy(info->file.type, GP_MIME_JPEG); strcpy(info->file.type, GP_MIME_JPEG);
info->file.size = dsc2_selectimage(camera, index, DSC_FULLIMAGE); info->file.size = dsc2_selectimage(camera, index, DSC_FULLIMAGE);
info->preview.fields = GP_FILE_INFO_TYPE | GP_FILE_INFO_SIZE; info->preview.fields = GP_FILE_INFO_TYPE | GP_FILE_INFO_SIZE;
strcpy(info->preview.type, GP_MIME_JPEG); strcpy(info->preview.type, GP_MIME_JPEG);
info->preview.size = dsc2_selectimage(camera, index, DSC_THUMBNAIL); info->preview.size = dsc2_selectimage(camera, index, DSC_THUMBNAIL);
return GP_OK; return GP_OK;
} }
static int get_file_func (CameraFilesystem *fs, const char *folder, static int get_file_func (CameraFilesystem *fs, const char *folder,
@@ -500,14 +500,14 @@ static int get_file_func (CameraFilesystem *fs, const char *folder,
CameraFile *file, void *data, GPContext *context) { CameraFile *file, void *data, GPContext *context) {
Camera *camera = data; Camera *camera = data;
int index, i, size, blocks, result; int index, i, size, blocks, result;
unsigned int id; unsigned int id;
gp_context_status(context, _("Downloading %s."), filename); gp_context_status(context, _("Downloading %s."), filename);
/* index is the 0-based image number on the camera */ /* index is the 0-based image number on the camera */
CHECK (index = gp_filesystem_number(camera->fs, folder, filename, context)); CHECK (index = gp_filesystem_number(camera->fs, folder, filename, context));
index++; index++;
switch (type) { switch (type) {
case GP_FILE_TYPE_PREVIEW: case GP_FILE_TYPE_PREVIEW:
@@ -524,19 +524,19 @@ static int get_file_func (CameraFilesystem *fs, const char *folder,
CHECK (gp_file_set_mime_type(file, GP_MIME_JPEG)); CHECK (gp_file_set_mime_type(file, GP_MIME_JPEG));
blocks = (size - 1)/DSC_BLOCKSIZE + 1; blocks = (size - 1)/DSC_BLOCKSIZE + 1;
id = gp_context_progress_start (context, blocks, _("Getting data...")); id = gp_context_progress_start (context, blocks, _("Getting data..."));
for (i = 0; i < blocks; i++) { for (i = 0; i < blocks; i++) {
CHECK (dsc2_readimageblock(camera, i, NULL)); CHECK (dsc2_readimageblock(camera, i, NULL));
CHECK (gp_file_append(file, &camera->pl->buf[4], DSC_BLOCKSIZE)); CHECK (gp_file_append(file, &camera->pl->buf[4], DSC_BLOCKSIZE));
gp_context_progress_update (context, id, i + 1); gp_context_progress_update (context, id, i + 1);
if (gp_context_cancel (context) == GP_CONTEXT_FEEDBACK_CANCEL) if (gp_context_cancel (context) == GP_CONTEXT_FEEDBACK_CANCEL)
return (GP_ERROR_CANCEL); return (GP_ERROR_CANCEL);
} }
gp_context_progress_stop (context, id); gp_context_progress_stop (context, id);
return GP_OK; return GP_OK;
} }
static int put_file_func (CameraFilesystem *fs, const char *folder, const char *name, static int put_file_func (CameraFilesystem *fs, const char *folder, const char *name,
@@ -544,38 +544,38 @@ static int put_file_func (CameraFilesystem *fs, const char *folder, const char *
GPContext *context) { GPContext *context) {
Camera *camera = user_data; Camera *camera = user_data;
int blocks, blocksize, i, result; int blocks, blocksize, i, result;
const char *data; const char *data;
long unsigned int size; long unsigned int size;
unsigned int id; unsigned int id;
gp_context_status(context, _("Uploading image: %s."), name); gp_context_status(context, _("Uploading image: %s."), name);
/* We can not figure out file type, at least by now. (? curious, mime type -Marcus) /* We can not figure out file type, at least by now. (? curious, mime type -Marcus)
if (strcmp(file->type, "image/jpg") != 0) { if (strcmp(file->type, "image/jpg") != 0) {
dsc_print_message(camera, "JPEG image format allowed only."); dsc_print_message(camera, "JPEG image format allowed only.");
return GP_ERROR; return GP_ERROR;
} }
*/ */
gp_file_get_data_and_size (file, &data, &size); gp_file_get_data_and_size (file, &data, &size);
if (size > DSC_MAXIMAGESIZE) { if (size > DSC_MAXIMAGESIZE) {
gp_context_message (context, _("File size is %ld bytes. " gp_context_message (context, _("File size is %ld bytes. "
"The size of the largest file possible to " "The size of the largest file possible to "
"upload is: %i bytes."), size, "upload is: %i bytes."), size,
DSC_MAXIMAGESIZE); DSC_MAXIMAGESIZE);
return GP_ERROR; return GP_ERROR;
} }
if ((result = dsc2_setimagesize(camera, size)) != GP_OK) return result; if ((result = dsc2_setimagesize(camera, size)) != GP_OK) return result;
blocks = (size - 1)/DSC_BLOCKSIZE + 1; blocks = (size - 1)/DSC_BLOCKSIZE + 1;
id = gp_context_progress_start (context, blocks, _("Uploading...")); id = gp_context_progress_start (context, blocks, _("Uploading..."));
for (i = 0; i < blocks; i++) { for (i = 0; i < blocks; i++) {
blocksize = size - i*DSC_BLOCKSIZE; blocksize = size - i*DSC_BLOCKSIZE;
if (DSC_BLOCKSIZE < blocksize) if (DSC_BLOCKSIZE < blocksize)
blocksize = DSC_BLOCKSIZE; blocksize = DSC_BLOCKSIZE;
result = dsc2_writeimageblock(camera, i, result = dsc2_writeimageblock(camera, i,
(char*)&data[i*DSC_BLOCKSIZE], (char*)&data[i*DSC_BLOCKSIZE],
blocksize); blocksize);
@@ -584,10 +584,10 @@ static int put_file_func (CameraFilesystem *fs, const char *folder, const char *
gp_context_progress_update (context, id, i + 1); gp_context_progress_update (context, id, i + 1);
if (gp_context_cancel (context) == GP_CONTEXT_FEEDBACK_CANCEL) if (gp_context_cancel (context) == GP_CONTEXT_FEEDBACK_CANCEL)
return (GP_ERROR_CANCEL); return (GP_ERROR_CANCEL);
} }
gp_context_progress_stop (context, id); gp_context_progress_stop (context, id);
return GP_OK; return GP_OK;
} }
static int delete_file_func (CameraFilesystem *fs, const char *folder, static int delete_file_func (CameraFilesystem *fs, const char *folder,
@@ -595,26 +595,26 @@ static int delete_file_func (CameraFilesystem *fs, const char *folder,
GPContext *context) { GPContext *context) {
Camera *camera = data; Camera *camera = data;
int index, result; int index, result;
gp_context_status(context, _("Deleting image %s."), filename); gp_context_status(context, _("Deleting image %s."), filename);
/* index is the 0-based image number on the camera */ /* index is the 0-based image number on the camera */
CHECK (index = gp_filesystem_number (camera->fs, folder, filename, context)); CHECK (index = gp_filesystem_number (camera->fs, folder, filename, context));
index++; index++;
return dsc2_delete(camera, index); return dsc2_delete(camera, index);
} }
static int camera_about (Camera *camera, CameraText *about, GPContext *context) static int camera_about (Camera *camera, CameraText *about, GPContext *context)
{ {
strcpy(about->text, strcpy(about->text,
_("Panasonic DC1580 gPhoto2 library\n" _("Panasonic DC1580 gPhoto2 library\n"
"Mariusz Zynel <mariusz@mizar.org>\n\n" "Mariusz Zynel <mariusz@mizar.org>\n\n"
"Based on dc1000 program written by\n" "Based on dc1000 program written by\n"
"Fredrik Roubert <roubert@df.lth.se> and\n" "Fredrik Roubert <roubert@df.lth.se> and\n"
"Galen Brooks <galen@nine.com>.")); "Galen Brooks <galen@nine.com>."));
return (GP_OK); return (GP_OK);
} }
static CameraFilesystemFuncs fsfuncs = { static CameraFilesystemFuncs fsfuncs = {
@@ -627,12 +627,12 @@ static CameraFilesystemFuncs fsfuncs = {
int camera_init (Camera *camera, GPContext *context) int camera_init (Camera *camera, GPContext *context)
{ {
GPPortSettings settings; GPPortSettings settings;
int result, selected_speed; int result, selected_speed;
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->exit = camera_exit; camera->functions->exit = camera_exit;
camera->functions->about = camera_about; camera->functions->about = camera_about;
camera->pl = malloc (sizeof (CameraPrivateLibrary)); camera->pl = malloc (sizeof (CameraPrivateLibrary));
if (!camera->pl) if (!camera->pl)
@@ -649,15 +649,15 @@ int camera_init (Camera *camera, GPContext *context)
/* Configure the port (and remember the speed) */ /* Configure the port (and remember the speed) */
CHECK (gp_port_get_settings (camera->port, &settings)); CHECK (gp_port_get_settings (camera->port, &settings));
selected_speed = settings.serial.speed; selected_speed = settings.serial.speed;
settings.serial.speed = 9600; /* hand shake speed */ settings.serial.speed = 9600; /* hand shake speed */
settings.serial.bits = 8; settings.serial.bits = 8;
settings.serial.parity = 0; settings.serial.parity = 0;
settings.serial.stopbits = 1; settings.serial.stopbits = 1;
CHECK (gp_port_set_settings (camera->port, settings)); CHECK (gp_port_set_settings (camera->port, settings));
CHECK (gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera)); CHECK (gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera));
/* Connect with the selected speed */ /* Connect with the selected speed */
return dsc2_connect(camera, selected_speed); return dsc2_connect(camera, selected_speed);
} }
/* End of dc1580.c */ /* End of dc1580.c */

View File

@@ -142,7 +142,7 @@ static int l859_disconnect(Camera *camera) {
if (l859_sendcmd(camera, L859_CMD_RESET) != GP_OK) if (l859_sendcmd(camera, L859_CMD_RESET) != GP_OK)
return GP_ERROR; return GP_ERROR;
if (gp_port_read(camera->port, camera->pl->buf, 1) == GP_ERROR) if (gp_port_read(camera->port, camera->pl->buf, 1) == GP_ERROR)
return GP_ERROR; return GP_ERROR;
GP_DEBUG ("Camera disconnected."); GP_DEBUG ("Camera disconnected.");
@@ -614,13 +614,13 @@ static CameraFilesystemFuncs fsfuncs = {
int camera_init (Camera *camera, GPContext *context) { int camera_init (Camera *camera, GPContext *context) {
int ret; int ret;
GPPortSettings settings; GPPortSettings settings;
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->exit = camera_exit; camera->functions->exit = camera_exit;
camera->functions->summary = camera_summary; camera->functions->summary = camera_summary;
camera->functions->manual = camera_manual; camera->functions->manual = camera_manual;
camera->functions->about = camera_about; camera->functions->about = camera_about;
/* Allocate memory for a read/write buffer */ /* Allocate memory for a read/write buffer */
@@ -628,19 +628,19 @@ int camera_init (Camera *camera, GPContext *context) {
if (!camera->pl) if (!camera->pl)
return (GP_ERROR_NO_MEMORY); return (GP_ERROR_NO_MEMORY);
gp_port_set_timeout (camera->port, 2000); gp_port_set_timeout (camera->port, 2000);
gp_port_get_settings(camera->port, &settings); gp_port_get_settings(camera->port, &settings);
camera->pl->speed = settings.serial.speed; camera->pl->speed = settings.serial.speed;
settings.serial.speed = 9600; /* hand shake speed */ settings.serial.speed = 9600; /* hand shake speed */
settings.serial.bits = 8; settings.serial.bits = 8;
settings.serial.parity = 0; settings.serial.parity = 0;
settings.serial.stopbits = 1; settings.serial.stopbits = 1;
gp_port_set_settings(camera->port, settings); gp_port_set_settings(camera->port, settings);
/* Set up the filesystem */ /* Set up the filesystem */
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
ret = l859_connect (camera); ret = l859_connect (camera);
if (ret < 0) { if (ret < 0) {
free (camera->pl); free (camera->pl);
camera->pl = NULL; camera->pl = NULL;

View File

@@ -115,53 +115,53 @@ camera_abilities (CameraAbilitiesList *list)
strcpy (a.model, "Pentax:K30"); strcpy (a.model, "Pentax:K30");
a.usb_vendor = 0x25fb; a.usb_vendor = 0x25fb;
a.usb_product = 0x0132; a.usb_product = 0x0132;
if (GP_OK != (ret = gp_abilities_list_append (list, a))) if (GP_OK != (ret = gp_abilities_list_append (list, a)))
return ret; return ret;
strcpy (a.model, "Pentax:K5II"); strcpy (a.model, "Pentax:K5II");
a.usb_vendor = 0x25fb; a.usb_vendor = 0x25fb;
a.usb_product = 0x0148; a.usb_product = 0x0148;
if (GP_OK != (ret = gp_abilities_list_append (list, a))) if (GP_OK != (ret = gp_abilities_list_append (list, a)))
return ret; return ret;
/* TommyLimKW @ Twitter */ /* TommyLimKW @ Twitter */
strcpy (a.model, "Pentax:K5IIs"); strcpy (a.model, "Pentax:K5IIs");
a.usb_vendor = 0x25fb; a.usb_vendor = 0x25fb;
a.usb_product = 0x014a; a.usb_product = 0x014a;
if (GP_OK != (ret = gp_abilities_list_append (list, a))) if (GP_OK != (ret = gp_abilities_list_append (list, a)))
return ret; return ret;
strcpy (a.model, "Pentax:K3"); strcpy (a.model, "Pentax:K3");
a.usb_vendor = 0x25fb; a.usb_vendor = 0x25fb;
a.usb_product = 0x0164; a.usb_product = 0x0164;
if (GP_OK != (ret = gp_abilities_list_append (list, a))) if (GP_OK != (ret = gp_abilities_list_append (list, a)))
return ret; return ret;
strcpy (a.model, "Pentax:K1"); strcpy (a.model, "Pentax:K1");
a.usb_vendor = 0x25fb; a.usb_vendor = 0x25fb;
a.usb_product = 0x0178; a.usb_product = 0x0178;
if (GP_OK != (ret = gp_abilities_list_append (list, a))) if (GP_OK != (ret = gp_abilities_list_append (list, a)))
return ret; return ret;
strcpy (a.model, "Pentax:K3II"); strcpy (a.model, "Pentax:K3II");
a.usb_vendor = 0x25fb; a.usb_vendor = 0x25fb;
a.usb_product = 0x017a; a.usb_product = 0x017a;
if (GP_OK != (ret = gp_abilities_list_append (list, a))) if (GP_OK != (ret = gp_abilities_list_append (list, a)))
return ret; return ret;
/* Keld Henningsen <drawsacircle@hotmail.com> */ /* Keld Henningsen <drawsacircle@hotmail.com> */
strcpy (a.model, "Pentax:K70"); strcpy (a.model, "Pentax:K70");
a.usb_vendor = 0x25fb; a.usb_vendor = 0x25fb;
a.usb_product = 0x017c; a.usb_product = 0x017c;
if (GP_OK != (ret = gp_abilities_list_append (list, a))) if (GP_OK != (ret = gp_abilities_list_append (list, a)))
return ret; return ret;
/* fifu7fi@gmail.com */ /* fifu7fi@gmail.com */
strcpy (a.model, "Pentax:KP"); strcpy (a.model, "Pentax:KP");
a.usb_vendor = 0x25fb; a.usb_vendor = 0x25fb;
a.usb_product = 0x017e; a.usb_product = 0x017e;
if (GP_OK != (ret = gp_abilities_list_append (list, a))) if (GP_OK != (ret = gp_abilities_list_append (list, a)))
return ret; return ret;
/* https://github.com/asalamon74/pktriggercord/issues/21 */ /* https://github.com/asalamon74/pktriggercord/issues/21 */
strcpy (a.model, "Pentax:K1II"); strcpy (a.model, "Pentax:K1II");
@@ -181,25 +181,25 @@ camera_abilities (CameraAbilitiesList *list)
int scsi_write(GPPort *port, uint8_t *cmd, uint32_t cmdLen, int scsi_write(GPPort *port, uint8_t *cmd, uint32_t cmdLen,
uint8_t *buf, uint32_t bufLen) { uint8_t *buf, uint32_t bufLen) {
int ret; int ret;
char sense_buffer[32]; char sense_buffer[32];
ret = gp_port_send_scsi_cmd (port, 1, (char*)cmd, cmdLen, ret = gp_port_send_scsi_cmd (port, 1, (char*)cmd, cmdLen,
sense_buffer, sizeof(sense_buffer), (char*)buf, bufLen); sense_buffer, sizeof(sense_buffer), (char*)buf, bufLen);
if (ret == GP_OK) return PSLR_OK; if (ret == GP_OK) return PSLR_OK;
return PSLR_SCSI_ERROR; return PSLR_SCSI_ERROR;
} }
int scsi_read(GPPort *port, uint8_t *cmd, uint32_t cmdLen, int scsi_read(GPPort *port, uint8_t *cmd, uint32_t cmdLen,
uint8_t *buf, uint32_t bufLen) uint8_t *buf, uint32_t bufLen)
{ {
int ret; int ret;
char sense_buffer[32]; char sense_buffer[32];
ret = gp_port_send_scsi_cmd (port, 0, (char*)cmd, cmdLen, ret = gp_port_send_scsi_cmd (port, 0, (char*)cmd, cmdLen,
sense_buffer, sizeof(sense_buffer), (char*)buf, bufLen); sense_buffer, sizeof(sense_buffer), (char*)buf, bufLen);
if (ret == GP_OK) return bufLen; if (ret == GP_OK) return bufLen;
return -PSLR_SCSI_ERROR; return -PSLR_SCSI_ERROR;
} }
void close_drive(GPPort **port) { void close_drive(GPPort **port) {
@@ -328,7 +328,7 @@ camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path,
const char *mimes[2]; const char *mimes[2];
int buftypes[2], jpegres[2], nrofdownloads = 1; int buftypes[2], jpegres[2], nrofdownloads = 1;
char *fns[2], *lastfn = NULL; char *fns[2], *lastfn = NULL;
struct timeval event_start; struct timeval event_start;
gp_log (GP_LOG_DEBUG, "pentax", "camera_capture"); gp_log (GP_LOG_DEBUG, "pentax", "camera_capture");
@@ -471,7 +471,7 @@ static int
camera_wait_for_event (Camera *camera, int timeout, camera_wait_for_event (Camera *camera, int timeout,
CameraEventType *eventtype, void **eventdata, CameraEventType *eventtype, void **eventdata,
GPContext *context) { GPContext *context) {
struct timeval event_start; struct timeval event_start;
CameraFilePath *path; CameraFilePath *path;
pslr_handle_t p = &camera->pl->pslr; pslr_handle_t p = &camera->pl->pslr;
int ret, length; int ret, length;
@@ -829,12 +829,12 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
int i, resolution = -1; int i, resolution = -1;
int *valid_resolutions; int *valid_resolutions;
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
valid_resolutions = pslr_get_model_jpeg_resolutions (&camera->pl->pslr); valid_resolutions = pslr_get_model_jpeg_resolutions (&camera->pl->pslr);
gp_widget_get_value (w, &sval); gp_widget_get_value (w, &sval);
for (i = 0; i < MAX_RESOLUTION_SIZE; i++) for (i = 0; i < MAX_RESOLUTION_SIZE; i++)
{ {
int foo; int foo;
sscanf(sval, "%d", &foo); sscanf(sval, "%d", &foo);
@@ -854,7 +854,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
if ((ret == GP_OK) && gp_widget_changed (w)) { if ((ret == GP_OK) && gp_widget_changed (w)) {
pslr_exposure_mode_t exposuremode; pslr_exposure_mode_t exposuremode;
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &sval); gp_widget_get_value (w, &sval);
exposuremode = PSLR_EXPOSURE_MODE_MAX; exposuremode = PSLR_EXPOSURE_MODE_MAX;
@@ -879,7 +879,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
if ((ret == GP_OK) && gp_widget_changed (w)) { if ((ret == GP_OK) && gp_widget_changed (w)) {
int iso; int iso;
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &sval); gp_widget_get_value (w, &sval);
if (sscanf(sval, "%d", &iso)) { if (sscanf(sval, "%d", &iso)) {
/* pslr_set_iso(&camera->pl->pslr, iso); */ /* pslr_set_iso(&camera->pl->pslr, iso); */
@@ -910,7 +910,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
/* FIXME: decoding is strange. the UI shows number of stars /* FIXME: decoding is strange. the UI shows number of stars
* on k20d: 4 stars = 3, 3 stars = 0, 2 stars = 1, 1 star = 2 * on k20d: 4 stars = 3, 3 stars = 0, 2 stars = 1, 1 star = 2
*/ */
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &sval); gp_widget_get_value (w, &sval);
if (sscanf(sval, "%d", &qual)) { if (sscanf(sval, "%d", &qual)) {
pslr_set_jpeg_stars (&camera->pl->pslr, qual); pslr_set_jpeg_stars (&camera->pl->pslr, qual);
@@ -923,7 +923,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
if ((ret == GP_OK) && gp_widget_changed (w)) { if ((ret == GP_OK) && gp_widget_changed (w)) {
pslr_rational_t speed; pslr_rational_t speed;
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &sval); gp_widget_get_value (w, &sval);
if (sscanf(sval, "%d/%d", &speed.nom, &speed.denom)) { if (sscanf(sval, "%d/%d", &speed.nom, &speed.denom)) {
pslr_set_shutter(&camera->pl->pslr, speed); pslr_set_shutter(&camera->pl->pslr, speed);
@@ -946,7 +946,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
pslr_rational_t aperture; pslr_rational_t aperture;
int apt1,apt2; int apt1,apt2;
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &sval); gp_widget_get_value (w, &sval);
if (sscanf(sval, "%d.%d", &apt1, &apt2)) { if (sscanf(sval, "%d.%d", &apt1, &apt2)) {
if (apt1<11) { if (apt1<11) {
@@ -983,7 +983,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
return GP_ERROR; return GP_ERROR;
} }
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
gp_widget_get_value (w, &bulb); gp_widget_get_value (w, &bulb);
pslr_bulb (&camera->pl->pslr, bulb); pslr_bulb (&camera->pl->pslr, bulb);

View File

@@ -504,9 +504,9 @@ camera_init (Camera *camera, GPContext *context)
CameraAbilities abilities; CameraAbilities abilities;
int result; int result;
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->exit = camera_exit; camera->functions->exit = camera_exit;
camera->functions->about = camera_about; camera->functions->about = camera_about;
camera->functions->summary = camera_summary; camera->functions->summary = camera_summary;
/* Now, tell the filesystem where to get lists and info */ /* Now, tell the filesystem where to get lists and info */

View File

@@ -912,13 +912,13 @@ camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path,
return (GP_ERROR); return (GP_ERROR);
/* Set the filename */ /* Set the filename */
sprintf (path->name, camera->pl->filespec, num); sprintf (path->name, camera->pl->filespec, num);
strcpy (path->folder, "/"); strcpy (path->folder, "/");
CHECK_RESULT (gp_filesystem_append (camera->fs, "/", path->name, CHECK_RESULT (gp_filesystem_append (camera->fs, "/", path->name,
context)); context));
return (GP_OK); return (GP_OK);
} }
static int static int

View File

@@ -636,16 +636,16 @@ pdc700_set_date (Camera *camera, time_t time, GPContext *context)
static int static int
pdc700_capture (Camera *camera, GPContext *context) pdc700_capture (Camera *camera, GPContext *context)
{ {
unsigned char cmd[5], buf[1024]; unsigned char cmd[5], buf[1024];
unsigned int buf_len = 0; unsigned int buf_len = 0;
int r = 0; int r = 0;
int try; int try;
PDCInfo info; PDCInfo info;
cmd[3] = PDC700_CAPTURE; cmd[3] = PDC700_CAPTURE;
cmd[4] = 0; cmd[4] = 0;
CR (pdc700_transmit (camera, cmd, 5, buf, &buf_len, context)); CR (pdc700_transmit (camera, cmd, 5, buf, &buf_len, context));
/* /*
* This is rather hackish. The camera needs a little time to recover * This is rather hackish. The camera needs a little time to recover
@@ -654,10 +654,10 @@ pdc700_capture (Camera *camera, GPContext *context)
* I'm leaving this ugly-but-works junk here for now. * I'm leaving this ugly-but-works junk here for now.
*/ */
for (try = 0; try < 10; try++) for (try = 0; try < 10; try++)
if ((r = pdc700_info(camera, &info, context)) == GP_OK) if ((r = pdc700_info(camera, &info, context)) == GP_OK)
break; break;
return r; return r;
}; };
static int static int
@@ -746,7 +746,7 @@ camera_abilities (CameraAbilitiesList *list)
a.speed[3] = 57600; a.speed[3] = 57600;
a.speed[4] = 115200; a.speed[4] = 115200;
a.operations = GP_OPERATION_CAPTURE_IMAGE | a.operations = GP_OPERATION_CAPTURE_IMAGE |
GP_OPERATION_CONFIG; GP_OPERATION_CONFIG;
a.file_operations = GP_FILE_OPERATION_DELETE | a.file_operations = GP_FILE_OPERATION_DELETE |
GP_FILE_OPERATION_PREVIEW; GP_FILE_OPERATION_PREVIEW;
a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL; a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL;
@@ -1182,10 +1182,10 @@ camera_init (Camera *camera, GPContext *context)
GPPortSettings settings; GPPortSettings settings;
int speeds[] = {115200, 9600, 57600, 19200, 38400}; int speeds[] = {115200, 9600, 57600, 19200, 38400};
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->capture = camera_capture; camera->functions->capture = camera_capture;
camera->functions->summary = camera_summary; camera->functions->summary = camera_summary;
camera->functions->about = camera_about; camera->functions->about = camera_about;
camera->functions->get_config = camera_get_config; camera->functions->get_config = camera_get_config;
camera->functions->set_config = camera_set_config; camera->functions->set_config = camera_set_config;

View File

@@ -10678,7 +10678,7 @@ _put_nikon_create_wifi_profile (CONFIG_PUT_ARGS)
if (!gp_widget_changed (subwidget)) if (!gp_widget_changed (subwidget))
continue; continue;
gp_widget_set_changed (subwidget, FALSE); gp_widget_set_changed (subwidget, FALSE);
ret = cursub->putfunc (camera, subwidget, NULL, NULL, NULL); ret = cursub->putfunc (camera, subwidget, NULL, NULL, NULL);
} }

View File

@@ -1451,7 +1451,7 @@ ptp_pack_OPL (PTPParams *params, MTPProperties *props, int nrofprops, unsigned c
packedpropstypes[noitems]= propitr->datatype; packedpropstypes[noitems]= propitr->datatype;
totalsize += sizeof(uint16_t); totalsize += sizeof(uint16_t);
/* Add each property to be sent. */ /* Add each property to be sent. */
packedpropslens[noitems] = ptp_pack_DPV (params, &propitr->propval, &packedprops[noitems], propitr->datatype); packedpropslens[noitems] = ptp_pack_DPV (params, &propitr->propval, &packedprops[noitems], propitr->datatype);
totalsize += packedpropslens[noitems]; totalsize += packedpropslens[noitems];
noitems ++; noitems ++;
propitr ++; propitr ++;

View File

@@ -3706,11 +3706,11 @@ typedef struct _PTPParams PTPParams;
typedef uint16_t (* PTPDataGetFunc) (PTPParams* params, void*priv, typedef uint16_t (* PTPDataGetFunc) (PTPParams* params, void*priv,
unsigned long wantlen, unsigned long wantlen,
unsigned char *data, unsigned long *gotlen); unsigned char *data, unsigned long *gotlen);
typedef uint16_t (* PTPDataPutFunc) (PTPParams* params, void*priv, typedef uint16_t (* PTPDataPutFunc) (PTPParams* params, void*priv,
unsigned long sendlen, unsigned long sendlen,
unsigned char *data); unsigned char *data);
typedef struct _PTPDataHandler { typedef struct _PTPDataHandler {
PTPDataGetFunc getfunc; PTPDataGetFunc getfunc;
PTPDataPutFunc putfunc; PTPDataPutFunc putfunc;
@@ -3727,7 +3727,7 @@ typedef uint16_t (* PTPIOSendData) (PTPParams* params, PTPContainer* ptp,
typedef uint16_t (* PTPIOGetResp) (PTPParams* params, PTPContainer* resp); typedef uint16_t (* PTPIOGetResp) (PTPParams* params, PTPContainer* resp);
typedef uint16_t (* PTPIOGetData) (PTPParams* params, PTPContainer* ptp, typedef uint16_t (* PTPIOGetData) (PTPParams* params, PTPContainer* ptp,
PTPDataHandler *putter); PTPDataHandler *putter);
typedef uint16_t (* PTPIOCancelReq) (PTPParams* params, uint32_t transaction_id); typedef uint16_t (* PTPIOCancelReq) (PTPParams* params, uint32_t transaction_id);
typedef uint16_t (* PTPIODevStatReq) (PTPParams* params); typedef uint16_t (* PTPIODevStatReq) (PTPParams* params);
@@ -3923,7 +3923,7 @@ uint16_t ptp_usb_senddata (PTPParams* params, PTPContainer* ptp,
uint64_t size, PTPDataHandler *handler); uint64_t size, PTPDataHandler *handler);
uint16_t ptp_usb_getresp (PTPParams* params, PTPContainer* resp); uint16_t ptp_usb_getresp (PTPParams* params, PTPContainer* resp);
uint16_t ptp_usb_getdata (PTPParams* params, PTPContainer* ptp, uint16_t ptp_usb_getdata (PTPParams* params, PTPContainer* ptp,
PTPDataHandler *handler); PTPDataHandler *handler);
uint16_t ptp_usb_event_async (PTPParams *params, PTPEventCbFn cb, void *user_data); uint16_t ptp_usb_event_async (PTPParams *params, PTPEventCbFn cb, void *user_data);
uint16_t ptp_usb_event_wait (PTPParams* params, PTPContainer* event); uint16_t ptp_usb_event_wait (PTPParams* params, PTPContainer* event);
uint16_t ptp_usb_event_check (PTPParams* params, PTPContainer* event); uint16_t ptp_usb_event_check (PTPParams* params, PTPContainer* event);
@@ -3943,7 +3943,7 @@ uint16_t ptp_ptpip_senddata (PTPParams* params, PTPContainer* ptp,
uint64_t size, PTPDataHandler *handler); uint64_t size, PTPDataHandler *handler);
uint16_t ptp_ptpip_getresp (PTPParams* params, PTPContainer* resp); uint16_t ptp_ptpip_getresp (PTPParams* params, PTPContainer* resp);
uint16_t ptp_ptpip_getdata (PTPParams* params, PTPContainer* ptp, uint16_t ptp_ptpip_getdata (PTPParams* params, PTPContainer* ptp,
PTPDataHandler *handler); PTPDataHandler *handler);
uint16_t ptp_ptpip_event_wait (PTPParams* params, PTPContainer* event); uint16_t ptp_ptpip_event_wait (PTPParams* params, PTPContainer* event);
uint16_t ptp_ptpip_event_check (PTPParams* params, PTPContainer* event); uint16_t ptp_ptpip_event_check (PTPParams* params, PTPContainer* event);
uint16_t ptp_ptpip_event_check_queue (PTPParams* params, PTPContainer* event); uint16_t ptp_ptpip_event_check_queue (PTPParams* params, PTPContainer* event);
@@ -3955,7 +3955,7 @@ uint16_t ptp_fujiptpip_senddata (PTPParams* params, PTPContainer* ptp,
uint64_t size, PTPDataHandler *handler); uint64_t size, PTPDataHandler *handler);
uint16_t ptp_fujiptpip_getresp (PTPParams* params, PTPContainer* resp); uint16_t ptp_fujiptpip_getresp (PTPParams* params, PTPContainer* resp);
uint16_t ptp_fujiptpip_getdata (PTPParams* params, PTPContainer* ptp, uint16_t ptp_fujiptpip_getdata (PTPParams* params, PTPContainer* ptp,
PTPDataHandler *handler); PTPDataHandler *handler);
uint16_t ptp_fujiptpip_event_wait (PTPParams* params, PTPContainer* event); uint16_t ptp_fujiptpip_event_wait (PTPParams* params, PTPContainer* event);
uint16_t ptp_fujiptpip_event_check (PTPParams* params, PTPContainer* event); uint16_t ptp_fujiptpip_event_check (PTPParams* params, PTPContainer* event);
uint16_t ptp_fujiptpip_event_check_queue(PTPParams* params, PTPContainer* event); uint16_t ptp_fujiptpip_event_check_queue(PTPParams* params, PTPContainer* event);

View File

@@ -378,10 +378,10 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
break; break;
case GP_FILE_TYPE_EXIF: case GP_FILE_TYPE_EXIF:
msg = _("Downloading EXIF data..."); msg = _("Downloading EXIF data...");
if (!strstr(filename,".JPG") && !strstr(filename,".jpg")) { if (!strstr(filename, ".JPG") && !strstr(filename, ".jpg")) {
gp_context_error (context,_("No EXIF data available for %s."), gp_context_error (context, _("No EXIF data available for %s."),
filename); filename);
ret = GP_ERROR_FILE_NOT_FOUND; ret = GP_ERROR_FILE_NOT_FOUND;
goto out; goto out;
} }
cmd = aprintf("-SRET %s", filename); cmd = aprintf("-SRET %s", filename);
@@ -397,9 +397,9 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
if (seek == -2) { if (seek == -2) {
/* FIXME: pretty bad, the camera has some time out problems /* FIXME: pretty bad, the camera has some time out problems
* if this happens */ * if this happens */
gp_context_error (context,_("No EXIF data available for %s."), gp_context_error (context, _("No EXIF data available for %s."),
filename); filename);
ret = GP_ERROR_FILE_NOT_FOUND; ret = GP_ERROR_FILE_NOT_FOUND;
g3_channel_read(camera->port, &channel, &reply, &len); /* reply */ g3_channel_read(camera->port, &channel, &reply, &len); /* reply */
goto out; goto out;
} }
@@ -844,7 +844,7 @@ file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
time = (ubuf[n*32+14]) | (ubuf[n*32+15]<<8); time = (ubuf[n*32+14]) | (ubuf[n*32+15]<<8);
/* from kernel fs/fat/, time_dos2unix. */ /* from kernel fs/fat/, time_dos2unix. */
month = ((date >> 5) - 1) & 15; month = ((date >> 5) - 1) & 15;
year = date >> 9; year = date >> 9;
info.file.mtime = info.file.mtime =
(time & 31)*2+60*((time >> 5) & 63)+ (time & 31)*2+60*((time >> 5) & 63)+
@@ -885,18 +885,18 @@ camera_init (Camera *camera, GPContext *context)
/*char *buf;*/ /*char *buf;*/
GPPortSettings settings; GPPortSettings settings;
/* First, set up all the needed function pointers */ /* First, set up all the needed function pointers */
camera->functions->summary = camera_summary; camera->functions->summary = camera_summary;
camera->functions->about = camera_about; camera->functions->about = camera_about;
/* Now, tell the filesystem where to get lists, files and info */ /* Now, tell the filesystem where to get lists, files and info */
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
gp_port_get_settings(camera->port, &settings); gp_port_get_settings(camera->port, &settings);
settings.usb.inep = 0x81; settings.usb.inep = 0x81;
settings.usb.outep = 0x02; settings.usb.outep = 0x02;
settings.usb.intep = 0x83; settings.usb.intep = 0x83;
gp_port_set_settings(camera->port, settings); gp_port_set_settings(camera->port, settings);
/* /*
* The port is already provided with camera->port (and * The port is already provided with camera->port (and
* already open). You just have to use functions like * already open). You just have to use functions like

View File

@@ -117,7 +117,7 @@ file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
static int static int
get_info_func (CameraFilesystem *fs, const char *folder, const char *filename, get_info_func (CameraFilesystem *fs, const char *folder, const char *filename,
CameraFileInfo *info, void *data, GPContext *context) CameraFileInfo *info, void *data, GPContext *context)
{ {
Camera *camera = data; Camera *camera = data;
int n; int n;
@@ -234,7 +234,7 @@ camera_summary (Camera *camera, CameraText *about, GPContext *context)
camera->pl->model); camera->pl->model);
sprintf (about->text, _("Model: %s\n" sprintf (about->text, _("Model: %s\n"
"Memory: %d byte(s) of %d available"), "Memory: %d byte(s) of %d available"),
model, avail_mem, total_mem); model, avail_mem, total_mem);
return (GP_OK); return (GP_OK);
@@ -392,9 +392,9 @@ static struct {
const char *__v = NULL; \ const char *__v = NULL; \
unsigned int __i; \ unsigned int __i; \
\ \
CR (gp_widget_get_child_by_name (wi, Name, &__w)); \ CR (gp_widget_get_child_by_name (wi, Name, &__w)); \
if (gp_widget_changed (__w)) { \ if (gp_widget_changed (__w)) { \
gp_widget_set_changed (__w, 0); \ gp_widget_set_changed (__w, 0); \
CR (gp_widget_get_value (__w, &__v)); \ CR (gp_widget_get_value (__w, &__v)); \
for (__i = 0; __i < N_ELEMENTS (ricoh_##n##s); __i++) \ for (__i = 0; __i < N_ELEMENTS (ricoh_##n##s); __i++) \
if (!strcmp (__v, _(ricoh_##n##s[__i].name))) { \ if (!strcmp (__v, _(ricoh_##n##s[__i].name))) { \
@@ -465,7 +465,7 @@ camera_set_config (Camera *c, CameraWidget *window, GPContext *co)
/* Copyright */ /* Copyright */
CR (gp_widget_get_child_by_name (window, "copyright", &w)); CR (gp_widget_get_child_by_name (window, "copyright", &w));
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
CR (gp_widget_get_value (w, &v_char)); CR (gp_widget_get_value (w, &v_char));
CR (ricoh_set_copyright (c, co, v_char)); CR (ricoh_set_copyright (c, co, v_char));
} }
@@ -473,7 +473,7 @@ camera_set_config (Camera *c, CameraWidget *window, GPContext *co)
/* Date */ /* Date */
CR (gp_widget_get_child_by_name (window, "date", &w)); CR (gp_widget_get_child_by_name (window, "date", &w));
if (gp_widget_changed (w)) { if (gp_widget_changed (w)) {
gp_widget_set_changed (w, 0); gp_widget_set_changed (w, 0);
CR (gp_widget_get_value (w, &time)); CR (gp_widget_get_value (w, &time));
CR (ricoh_set_date (c, co, time)); CR (ricoh_set_date (c, co, time));
} }

View File

@@ -147,7 +147,7 @@ static int
ricoh_recv (Camera *camera, GPContext *context, unsigned char *cmd, ricoh_recv (Camera *camera, GPContext *context, unsigned char *cmd,
unsigned char *number, unsigned char *data, unsigned char *len) unsigned char *number, unsigned char *data, unsigned char *len)
{ {
unsigned char buf[6]; unsigned char buf[6];
unsigned char r, i, ii, last_dle; unsigned char r, i, ii, last_dle;
unsigned int crc = 0; unsigned int crc = 0;
@@ -269,13 +269,13 @@ ricoh_transmit (Camera *camera, GPContext *context, unsigned char cmd,
const unsigned char *data, unsigned char len, const unsigned char *data, unsigned char len,
unsigned char *ret_data, unsigned char *ret_len) unsigned char *ret_data, unsigned char *ret_len)
{ {
unsigned char ret_cmd; unsigned char ret_cmd;
unsigned int r = 0; unsigned int r = 0;
int result; int result;
while (1) { while (1) {
CR (ricoh_send (camera, context, cmd, 0, data, len)); CR (ricoh_send (camera, context, cmd, 0, data, len));
result = ricoh_recv (camera, context, &ret_cmd, NULL, result = ricoh_recv (camera, context, &ret_cmd, NULL,
ret_data, ret_len); ret_data, ret_len);
switch (result) { switch (result) {
case GP_ERROR_TIMEOUT: case GP_ERROR_TIMEOUT:
@@ -352,14 +352,14 @@ ricoh_transmit (Camera *camera, GPContext *context, unsigned char cmd,
gp_context_error (context, _("An unknown error occurred. " gp_context_error (context, _("An unknown error occurred. "
"Please contact %s."), MAIL_GPHOTO_DEVEL); "Please contact %s."), MAIL_GPHOTO_DEVEL);
return (GP_ERROR); return (GP_ERROR);
} }
/* Success! We don't need the first two bytes any more. */ /* Success! We don't need the first two bytes any more. */
*ret_len -= 2; *ret_len -= 2;
if (*ret_len > 0) if (*ret_len > 0)
memmove (ret_data, ret_data + 2, *ret_len); memmove (ret_data, ret_data + 2, *ret_len);
return (GP_OK); return (GP_OK);
} }
int int

View File

@@ -99,7 +99,7 @@ int ricoh_get_cam_mem (Camera *camera, GPContext *context, int *mem);
int ricoh_get_cam_amem (Camera *camera, GPContext *context, int *mem); int ricoh_get_cam_amem (Camera *camera, GPContext *context, int *mem);
int ricoh_get_copyright (Camera *camera, GPContext *context, int ricoh_get_copyright (Camera *camera, GPContext *context,
const char **copyright); const char **copyright);
int ricoh_set_copyright (Camera *camera, GPContext *context, int ricoh_set_copyright (Camera *camera, GPContext *context,
const char *copyright); const char *copyright);

View File

@@ -177,18 +177,18 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
CHECK_RESULT (SDSC_send (camera->port, SDSC_NEXT)); CHECK_RESULT (SDSC_send (camera->port, SDSC_NEXT));
CHECK_RESULT (SDSC_send (camera->port, SDSC_START)); CHECK_RESULT (SDSC_send (camera->port, SDSC_START));
CHECK_RESULT (SDSC_receive (camera->port, buffer, SDSC_INFOSIZE)); CHECK_RESULT (SDSC_receive (camera->port, buffer, SDSC_INFOSIZE));
if (!strcmp((char*)buffer,filename)) if (!strcmp((char*)buffer, filename))
break; break;
if (is_null(buffer)) { /* skipped to the end of the camera? */ if (is_null(buffer)) { /* skipped to the end of the camera? */
/* Since we start at a random position, we wrap around. */ /* Since we start at a random position, we wrap around. */
continue; continue;
} }
/* We are at the first item again, so break. */ /* We are at the first item again, so break. */
if (havefirst && !strcmp((char*)first,(char*)buffer)) if (havefirst && !strcmp((char*)first, (char*)buffer))
return GP_ERROR_BAD_PARAMETERS; return GP_ERROR_BAD_PARAMETERS;
if (!havefirst) { if (!havefirst) {
havefirst = 1; havefirst = 1;
strcpy((char*)first,(char*)buffer); strcpy((char*)first, (char*)buffer);
} }
} }
/* The buffer header has /* The buffer header has
@@ -214,9 +214,9 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
return result; return result;
gp_file_append(file,(char *)buffer,SDSC_BLOCKSIZE); gp_file_append(file,(char *)buffer,SDSC_BLOCKSIZE);
curread += SDSC_BLOCKSIZE; curread += SDSC_BLOCKSIZE;
gp_context_progress_update(context, pid, curread); gp_context_progress_update(context, pid, curread);
if (gp_context_cancel(context) == GP_CONTEXT_FEEDBACK_CANCEL) if (gp_context_cancel(context) == GP_CONTEXT_FEEDBACK_CANCEL)
return GP_ERROR_CANCEL; return GP_ERROR_CANCEL;
CHECK_RESULT (SDSC_send (camera->port, SDSC_BINARY)); CHECK_RESULT (SDSC_send (camera->port, SDSC_BINARY));
} }
gp_context_progress_stop(context, pid); gp_context_progress_stop(context, pid);
@@ -289,7 +289,7 @@ get_info_func (CameraFilesystem *fs, const char *folder, const char *filename,
strcpy(info->file.type,GP_MIME_JPEG); strcpy(info->file.type,GP_MIME_JPEG);
sscanf((char *)buffer+12,"%lld",(long long int *)&info->file.size); sscanf((char *)buffer+12,"%lld",(long long int *)&info->file.size);
return GP_OK; return GP_OK;
} }
/* We are at the first item again */ /* We are at the first item again */
if (havefirst && !strcmp((char*)first,(char*)buffer)) if (havefirst && !strcmp((char*)first,(char*)buffer))
break; break;
@@ -312,8 +312,8 @@ camera_init (Camera *camera, GPContext *context)
{ {
GPPortSettings settings; GPPortSettings settings;
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->about = camera_about; camera->functions->about = camera_about;
/* Now, tell the filesystem where to get lists and info */ /* Now, tell the filesystem where to get lists and info */
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);

View File

@@ -459,26 +459,25 @@ sierra_write_packet (Camera *camera, char *packet, GPContext *context)
static int static int
sierra_clear_usb_halt(Camera *camera) sierra_clear_usb_halt(Camera *camera)
{ {
if ((camera->port->type == GP_PORT_USB) &&
if ( (camera->port->type == GP_PORT_USB) && !(camera->pl->flags & SIERRA_WRAP_USB_MASK) &&
!(camera->pl->flags & SIERRA_WRAP_USB_MASK) && !(camera->pl->flags & SIERRA_NO_USB_CLEAR))
!(camera->pl->flags & SIERRA_NO_USB_CLEAR) )
gp_port_usb_clear_halt(camera->port, GP_PORT_USB_ENDPOINT_IN); gp_port_usb_clear_halt(camera->port, GP_PORT_USB_ENDPOINT_IN);
return (GP_OK); return (GP_OK);
} }
static int static int
sierra_write_nak (Camera *camera, GPContext *context) sierra_write_nak (Camera *camera, GPContext *context)
{ {
char buf[4096]; char buf[4096];
int ret; int ret;
GP_DEBUG ("* sierra_write_nack"); GP_DEBUG ("* sierra_write_nack");
buf[0] = SIERRA_PACKET_NAK; buf[0] = SIERRA_PACKET_NAK;
ret = sierra_write_packet (camera, buf, context); ret = sierra_write_packet (camera, buf, context);
sierra_clear_usb_halt(camera); sierra_clear_usb_halt(camera);
return (ret); return (ret);
} }
/** /**
@@ -798,10 +797,10 @@ sierra_transmit_ack (Camera *camera, char *packet, GPContext *context)
} }
/* /*
* The camera has ended this session and * The camera has ended this session and
* reverted the speed back to 19200. Reinitialize * reverted the speed back to 19200. Reinitialize
* the connection. * the connection.
*/ */
CHECK (sierra_init (camera, context)); CHECK (sierra_init (camera, context));
CHECK (sierra_set_speed (camera, SIERRA_SPEED_19200, CHECK (sierra_set_speed (camera, SIERRA_SPEED_19200,
context)); context));
@@ -931,15 +930,15 @@ sierra_init (Camera *camera, GPContext *context)
} }
static struct { static struct {
SierraSpeed speed; SierraSpeed speed;
int bit_rate; int bit_rate;
} SierraSpeeds[] = { } SierraSpeeds[] = {
{SIERRA_SPEED_9600 , 9600}, {SIERRA_SPEED_9600 , 9600},
{SIERRA_SPEED_19200 , 19200}, {SIERRA_SPEED_19200 , 19200},
{SIERRA_SPEED_38400 , 38400}, {SIERRA_SPEED_38400 , 38400},
{SIERRA_SPEED_57600 , 57600}, {SIERRA_SPEED_57600 , 57600},
{SIERRA_SPEED_115200, 115200}, {SIERRA_SPEED_115200, 115200},
{0, 0} {0, 0}
}; };
int int
@@ -1204,7 +1203,7 @@ sierra_set_string_register (Camera *camera, int reg, const char *s,
} }
int sierra_get_string_register (Camera *camera, int reg, int fnumber, int sierra_get_string_register (Camera *camera, int reg, int fnumber,
CameraFile *file, unsigned char *b, CameraFile *file, unsigned char *b,
unsigned int *b_len, GPContext *context) unsigned int *b_len, GPContext *context)
{ {
unsigned char p[34816]; unsigned char p[34816];

View File

@@ -137,7 +137,7 @@ camera_cam_desc_get_widget (Camera *camera, CameraRegisterType *reg_p,
return (GP_ERROR); return (GP_ERROR);
} }
GP_DEBUG ("... '%s'.", gp_result_as_string (ret)); GP_DEBUG ("... '%s'.", gp_result_as_string (ret));
if (ret < 0) { if (ret < 0) {
return (ret); return (ret);
} }
@@ -170,7 +170,7 @@ camera_cam_desc_get_widget (Camera *camera, CameraRegisterType *reg_p,
if (((reg_desc_p->reg_widget_type == GP_WIDGET_RADIO) || if (((reg_desc_p->reg_widget_type == GP_WIDGET_RADIO) ||
(reg_desc_p->reg_widget_type == GP_WIDGET_MENU)) && (reg_desc_p->reg_widget_type == GP_WIDGET_MENU)) &&
!gp_widget_changed (child)) { !gp_widget_changed (child)) {
gp_widget_set_changed (child, FALSE); gp_widget_set_changed (child, FALSE);
sprintf (buff, _("%lld (unknown)"), (long long)reg_p->reg_value); sprintf (buff, _("%lld (unknown)"), (long long)reg_p->reg_value);
gp_widget_add_choice (child, buff); gp_widget_add_choice (child, buff);
gp_widget_set_value (child, buff); gp_widget_set_value (child, buff);
@@ -366,10 +366,9 @@ camera_cam_desc_set_widget (Camera *camera, CameraRegisterType *reg_p,
if ((gp_widget_get_child_by_label (window, if ((gp_widget_get_child_by_label (window,
_(reg_desc_p->regs_long_name), &child) >= 0) && _(reg_desc_p->regs_long_name), &child) >= 0) &&
gp_widget_changed (child)) { gp_widget_changed (child)) {
gp_widget_set_changed (child, FALSE); gp_widget_set_changed (child, FALSE);
gp_widget_get_value (child, &value_in); gp_widget_get_value (child, &value_in);
for (vind = 0; vind < reg_desc_p->reg_val_name_cnt; for (vind = 0; vind < reg_desc_p->reg_val_name_cnt; vind++) {
vind++) {
ret = camera_cam_desc_set_value (camera, reg_p, ret = camera_cam_desc_set_value (camera, reg_p,
reg_desc_p, reg_desc_p,
&reg_desc_p->regs_value_names[vind], &reg_desc_p->regs_value_names[vind],
@@ -422,8 +421,8 @@ camera_set_config_cam_desc (Camera *camera, CameraWidget *window,
GP_DEBUG ("%s registers", cam_desc->regset[wind].window_name); GP_DEBUG ("%s registers", cam_desc->regset[wind].window_name);
for (rind = 0; rind < cam_desc->regset[wind].reg_cnt; rind++) { for (rind = 0; rind < cam_desc->regset[wind].reg_cnt; rind++) {
camera_cam_desc_set_widget (camera, camera_cam_desc_set_widget (camera,
&cam_desc->regset[wind].regs[rind], window, &cam_desc->regset[wind].regs[rind], window,
context); context);
} }
} }
return (GP_OK); return (GP_OK);

File diff suppressed because it is too large Load Diff

View File

@@ -738,18 +738,18 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
unsigned char *xdata, *ydata; unsigned char *xdata, *ydata;
if (strcmp(folder,"/")) if (strcmp(folder, "/"))
return GP_ERROR_BAD_PARAMETERS; return GP_ERROR_BAD_PARAMETERS;
image_no = gp_filesystem_number(fs, folder, filename, context); image_no = gp_filesystem_number(fs, folder, filename, context);
/* size */ /* size */
do { do {
gp_port_usb_msg_read (camera->port, 1, image_no , 1, reply, 8); gp_port_usb_msg_read (camera->port, 1, image_no , 1, reply, 8);
} while(reply[0]!=0); } while(reply[0]!=0);
picsize = reply[1] | (reply[2] << 8) | ( reply[3] << 16); picsize = reply[1] | (reply[2] << 8) | ( reply[3] << 16);
/* Setup bulk transfer */ /* Setup bulk transfer */
do { do {
gp_port_usb_msg_read (camera->port, 2, image_no , 0, reply, 6); gp_port_usb_msg_read (camera->port, 2, image_no , 0, reply, 6);
} while(reply[0]!=0); } while(reply[0]!=0);

View File

@@ -45,19 +45,17 @@
#define BLINK2_GET_FIRMWARE_ID 0x18 #define BLINK2_GET_FIRMWARE_ID 0x18
static int static int
blink2_getnumpics( blink2_getnumpics (GPPort *port, GPContext *context, unsigned int *numpics) {
GPPort *port, GPContext *context, unsigned int *numpics unsigned char buf[2];
) { int ret;
unsigned char buf[2];
int ret;
ret = gp_port_usb_msg_read(port, BLINK2_GET_NUMPICS, 0x03, 0, (char*)buf, 2); ret = gp_port_usb_msg_read(port, BLINK2_GET_NUMPICS, 0x03, 0, (char*)buf, 2);
if (ret < GP_OK) if (ret < GP_OK)
return ret; return ret;
gp_log(GP_LOG_DEBUG, "blink2","ret is %d", ret); gp_log(GP_LOG_DEBUG, "blink2", "ret is %d", ret);
if (ret < 2) return GP_ERROR_IO_READ; if (ret < 2) return GP_ERROR_IO_READ;
*numpics = (buf[0]<<8) | buf[1]; *numpics = (buf[0]<<8) | buf[1];
return GP_OK; return GP_OK;
} }
#ifdef HAVE_LIBJPEG #ifdef HAVE_LIBJPEG
@@ -65,17 +63,17 @@ blink2_getnumpics(
static void _jpeg_init_source(j_decompress_ptr cinfo) { } static void _jpeg_init_source(j_decompress_ptr cinfo) { }
static boolean _jpeg_fill_input_buffer(j_decompress_ptr cinfo) { static boolean _jpeg_fill_input_buffer(j_decompress_ptr cinfo) {
fprintf(stderr,"(), should not get here.\n"); fprintf(stderr, "(), should not get here.\n");
return FALSE; return FALSE;
} }
static void _jpeg_skip_input_data(j_decompress_ptr cinfo,long num_bytes) { static void _jpeg_skip_input_data(j_decompress_ptr cinfo, long num_bytes) {
fprintf(stderr,"(%ld), should not get here.\n",num_bytes); fprintf(stderr, "(%ld), should not get here.\n", num_bytes);
} }
static boolean _jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired) { static boolean _jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired) {
fprintf(stderr,"(desired=%d), should not get here.\n",desired); fprintf(stderr, "(desired=%d), should not get here.\n", desired);
return FALSE; return FALSE;
} }
static void _jpeg_term_source(j_decompress_ptr cinfo) { } static void _jpeg_term_source(j_decompress_ptr cinfo) { }
#endif #endif
@@ -182,18 +180,18 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
} }
free(xbuf); free(xbuf);
image_no = gp_filesystem_number(fs, folder, filename, context); image_no = gp_filesystem_number(fs, folder, filename, context);
if(image_no < 0) { if(image_no < 0) {
free(addrs); free(addrs);
return image_no; return image_no;
} }
if (image_no < 0 || (unsigned int)image_no >= numpics) { if (image_no < 0 || (unsigned int)image_no >= numpics) {
free(addrs); free(addrs);
gp_log(GP_LOG_DEBUG, "blink2","image %d requested, but only %d pics on camera?", image_no, numpics); gp_log(GP_LOG_DEBUG, "blink2","image %d requested, but only %d pics on camera?", image_no, numpics);
return GP_ERROR; return GP_ERROR;
} }
switch (type) { switch (type) {
case GP_FILE_TYPE_NORMAL: case GP_FILE_TYPE_NORMAL:
#ifdef HAVE_LIBJPEG #ifdef HAVE_LIBJPEG
{ {
char *convline,*convline2,*rawline; char *convline,*convline2,*rawline;
@@ -205,9 +203,9 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
memset( buf, 0, sizeof(buf)); memset( buf, 0, sizeof(buf));
if (addrs[image_no].type) if (addrs[image_no].type)
gp_file_set_mime_type (file, GP_MIME_AVI); gp_file_set_mime_type (file, GP_MIME_AVI);
else else
gp_file_set_mime_type (file, GP_MIME_JPEG); gp_file_set_mime_type (file, GP_MIME_JPEG);
start = addrs[image_no].start; start = addrs[image_no].start;
len = addrs[image_no].len; len = addrs[image_no].len;
@@ -302,23 +300,23 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
free(convline); free(convline);
free(rawline); free(rawline);
free(jpegdata); free(jpegdata);
gp_file_set_mime_type (file, GP_MIME_PPM); gp_file_set_mime_type (file, GP_MIME_PPM);
jpeg_destroy_decompress(&dinfo); jpeg_destroy_decompress(&dinfo);
break; break;
} }
#else #else
/* fall through to raw mode if no libjpeg */ /* fall through to raw mode if no libjpeg */
#endif #endif
case GP_FILE_TYPE_RAW: { case GP_FILE_TYPE_RAW: {
char buf2[4096]; char buf2[4096];
unsigned int start, len; unsigned int start, len;
unsigned int curread; unsigned int curread;
memset( buf, 0, sizeof(buf)); memset( buf, 0, sizeof(buf));
if (addrs[image_no].type) if (addrs[image_no].type)
gp_file_set_mime_type (file, GP_MIME_AVI); gp_file_set_mime_type (file, GP_MIME_AVI);
else else
gp_file_set_mime_type (file, GP_MIME_JPEG); gp_file_set_mime_type (file, GP_MIME_JPEG);
start = addrs[image_no].start; start = addrs[image_no].start;
len = addrs[image_no].len; len = addrs[image_no].len;
@@ -329,7 +327,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
buf[4] = (len >> 24) & 0xff; buf[4] = (len >> 24) & 0xff;
buf[5] = (len >> 16) & 0xff; buf[5] = (len >> 16) & 0xff;
buf[6] = (len >> 8) & 0xff; buf[6] = (len >> 8) & 0xff;
buf[7] = len & 0xff; buf[7] = len & 0xff;
result = gp_port_usb_msg_write(camera->port,BLINK2_GET_MEMORY,0x03,0,(char*)buf,8); result = gp_port_usb_msg_write(camera->port,BLINK2_GET_MEMORY,0x03,0,(char*)buf,8);
if (result < GP_OK) if (result < GP_OK)
break; break;
@@ -349,21 +347,20 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
if (result < GP_OK) if (result < GP_OK)
break; break;
} while (len>0); } while (len>0);
break;
}
default:
result = GP_ERROR_NOT_SUPPORTED;
break; break;
} }
default:
result = GP_ERROR_NOT_SUPPORTED;
break;
}
free(addrs); free(addrs);
if (result < 0) if (result < 0)
return result; return result;
return (GP_OK); return (GP_OK);
} }
static int static int
delete_all_func (CameraFilesystem *fs, const char *folder, void *data, delete_all_func (CameraFilesystem *fs, const char *folder, void *data, GPContext *context)
GPContext *context)
{ {
Camera *camera = data; Camera *camera = data;
int ret; int ret;
@@ -373,12 +370,11 @@ delete_all_func (CameraFilesystem *fs, const char *folder, void *data,
if (ret < GP_OK) if (ret < GP_OK)
return ret; return ret;
if (ret < 1) return GP_ERROR_IO_READ; if (ret < 1) return GP_ERROR_IO_READ;
return GP_OK; return GP_OK;
} }
static int static int
camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path, camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path, GPContext *context)
GPContext *context)
{ {
int ret; int ret;
unsigned int oldnumpics, numpics; unsigned int oldnumpics, numpics;
@@ -405,9 +401,9 @@ camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path,
return ret; return ret;
if (numpics == oldnumpics) if (numpics == oldnumpics)
return (GP_ERROR); return (GP_ERROR);
strcpy (path->folder,"/"); strcpy (path->folder, "/");
sprintf (path->name,"image%04d.pnm",numpics-1); sprintf (path->name, "image%04d.pnm", numpics-1);
return (GP_OK); return (GP_OK);
} }
@@ -459,7 +455,7 @@ camera_init (Camera *camera, GPContext *context)
int ret; int ret;
GPPortSettings settings; GPPortSettings settings;
camera->functions->capture = camera_capture; camera->functions->capture = camera_capture;
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
gp_port_get_settings( camera->port, &settings); gp_port_get_settings( camera->port, &settings);

View File

@@ -678,8 +678,8 @@ static CameraFilesystemFuncs fsfuncs = {
int int
camera_init (Camera *camera, GPContext *context) camera_init (Camera *camera, GPContext *context)
{ {
camera->functions->exit = camera_exit; camera->functions->exit = camera_exit;
camera->functions->about = camera_about; camera->functions->about = camera_about;
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
return web2_init(camera->port, context); return web2_init(camera->port, context);
} }

View File

@@ -61,7 +61,7 @@ static const struct smal_cameras {
{ "Fuji:Axia Eyeplate", USB_VENDOR_ID_SMAL, USB_DEVICE_ID_ULTRAPOCKET }, { "Fuji:Axia Eyeplate", USB_VENDOR_ID_SMAL, USB_DEVICE_ID_ULTRAPOCKET },
{ "Logitech:Pocket Digital", USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_POCKETDIGITAL }, { "Logitech:Pocket Digital", USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_POCKETDIGITAL },
{ "SMaL:Ultra-Pocket", USB_VENDOR_ID_SMAL, USB_DEVICE_ID_ULTRAPOCKET }, { "SMaL:Ultra-Pocket", USB_VENDOR_ID_SMAL, USB_DEVICE_ID_ULTRAPOCKET },
{ "Radioshack:Flatfoto", USB_VENDOR_ID_SMAL, USB_DEVICE_ID_FLATFOTO }, { "Radioshack:Flatfoto", USB_VENDOR_ID_SMAL, USB_DEVICE_ID_FLATFOTO },
{ "Creative:CardCam", USB_VENDOR_ID_CREATIVE, USB_DEVICE_ID_CARDCAM }, { "Creative:CardCam", USB_VENDOR_ID_CREATIVE, USB_DEVICE_ID_CARDCAM },
{ NULL, 0, 0 } { NULL, 0, 0 }
}; };
@@ -69,118 +69,117 @@ static const struct smal_cameras {
int int
camera_abilities (CameraAbilitiesList *list) camera_abilities (CameraAbilitiesList *list)
{ {
CameraAbilities a; CameraAbilities a;
int i; int i;
memset(&a, 0, sizeof(a)); memset(&a, 0, sizeof(a));
a.status = GP_DRIVER_STATUS_EXPERIMENTAL; /* highly! */ a.status = GP_DRIVER_STATUS_EXPERIMENTAL; /* highly! */
a.port = GP_PORT_USB; a.port = GP_PORT_USB;
a.speed[0] = 0; a.speed[0] = 0;
a.operations = GP_OPERATION_NONE; a.operations = GP_OPERATION_NONE;
a.file_operations = GP_FILE_OPERATION_DELETE; a.file_operations = GP_FILE_OPERATION_DELETE;
a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL; a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL;
for (i = 0; smal_cameras[i].name; i++) { for (i = 0; smal_cameras[i].name; i++) {
strcpy(a.model, smal_cameras[i].name); strcpy(a.model, smal_cameras[i].name);
a.usb_vendor = smal_cameras[i].idVendor; a.usb_vendor = smal_cameras[i].idVendor;
a.usb_product = smal_cameras[i].idProduct; a.usb_product = smal_cameras[i].idProduct;
gp_abilities_list_append(list, a); gp_abilities_list_append(list, a);
} }
return (GP_OK); return (GP_OK);
} }
static int static int
camera_exit (Camera *camera, GPContext *context) camera_exit (Camera *camera, GPContext *context)
{ {
if (camera->pl) { if (camera->pl) {
free(camera->pl); free(camera->pl);
camera->pl = NULL; camera->pl = NULL;
} }
return ultrapocket_exit(camera->port, context); return ultrapocket_exit(camera->port, context);
} }
static int static int
get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
CameraFileType type, CameraFile *file, void *user_data, CameraFileType type, CameraFile *file, void *user_data,
GPContext *context) GPContext *context)
{ {
Camera *camera = user_data; Camera *camera = user_data;
int size,image_no,result; int size, image_no, result;
unsigned char *data; unsigned char *data;
image_no = gp_filesystem_number(fs, folder, filename, context); image_no = gp_filesystem_number(fs, folder, filename, context);
if (image_no < GP_OK) if (image_no < GP_OK)
return image_no; return image_no;
switch (type) { switch (type) {
case GP_FILE_TYPE_NORMAL: case GP_FILE_TYPE_NORMAL:
result = ultrapocket_getpicture(camera,context,&data,&size,filename); result = ultrapocket_getpicture(camera, context, &data, &size, filename);
gp_file_set_mime_type (file, GP_MIME_PPM); gp_file_set_mime_type (file, GP_MIME_PPM);
break; break;
case GP_FILE_TYPE_RAW: case GP_FILE_TYPE_RAW:
result = ultrapocket_getrawpicture(camera, context, result = ultrapocket_getrawpicture(camera, context,
&data, &size, filename); &data, &size, filename);
gp_file_set_mime_type (file, GP_MIME_PPM); gp_file_set_mime_type (file, GP_MIME_PPM);
break; break;
case GP_FILE_TYPE_PREVIEW: case GP_FILE_TYPE_PREVIEW:
default: default:
return (GP_ERROR_NOT_SUPPORTED); return (GP_ERROR_NOT_SUPPORTED);
} }
if (result < 0) if (result < 0)
return result; return result;
CHECK_RESULT(gp_file_set_data_and_size (file, (char *)data, size)); CHECK_RESULT(gp_file_set_data_and_size (file, (char *)data, size));
return (GP_OK); return (GP_OK);
} }
static int static int
delete_file_func (CameraFilesystem *fs, const char *folder, delete_file_func (CameraFilesystem *fs, const char *folder,
const char *filename, void *data, GPContext *context) const char *filename, void *data, GPContext *context)
{ {
Camera *camera = data; Camera *camera = data;
int image_no; int image_no;
image_no = gp_filesystem_number(fs, folder, filename, context); image_no = gp_filesystem_number(fs, folder, filename, context);
if (image_no < GP_OK) if (image_no < GP_OK)
return image_no; return image_no;
CHECK_RESULT(ultrapocket_deletefile(camera, filename)); CHECK_RESULT(ultrapocket_deletefile(camera, filename));
return (GP_OK); return (GP_OK);
} }
static int static int
delete_all_func (CameraFilesystem *fs, const char* folder, void *data, delete_all_func (CameraFilesystem *fs, const char* folder, void *data, GPContext *context)
GPContext *context)
{ {
Camera *camera = data; Camera *camera = data;
if (strcmp (folder, "/")) if (strcmp (folder, "/"))
return (GP_ERROR_DIRECTORY_NOT_FOUND); return (GP_ERROR_DIRECTORY_NOT_FOUND);
return ultrapocket_deleteall(camera); return ultrapocket_deleteall(camera);
} }
static int static int
camera_about (Camera *camera, CameraText *about, GPContext *context) camera_about (Camera *camera, CameraText *about, GPContext *context)
{ {
strcpy (about->text, _("Smal Ultrapocket\n" strcpy (about->text, _("Smal Ultrapocket\n"
"Lee Benfield <lee@benf.org>\n" "Lee Benfield <lee@benf.org>\n"
"Driver for accessing the Smal Ultrapocket camera, and OEM versions (slimshot)")); "Driver for accessing the Smal Ultrapocket camera, and OEM versions (slimshot)"));
return (GP_OK); return (GP_OK);
} }
static int static int
file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
void *data, GPContext *context) void *data, GPContext *context)
{ {
Camera *camera = data; Camera *camera = data;
int count, result; int count, result;
result = ultrapocket_getpicsoverview(camera, context, &count, list); result = ultrapocket_getpicsoverview(camera, context, &count, list);
if (result != GP_OK) if (result != GP_OK)
return result; return result;
return (GP_OK); return (GP_OK);
} }
static CameraFilesystemFuncs fsfuncs = { static CameraFilesystemFuncs fsfuncs = {
@@ -193,55 +192,55 @@ static CameraFilesystemFuncs fsfuncs = {
int int
camera_init (Camera *camera, GPContext *context) camera_init (Camera *camera, GPContext *context)
{ {
CameraAbilities cab; CameraAbilities cab;
up_badge_type badge; up_badge_type badge;
camera->functions->exit = camera_exit; camera->functions->exit = camera_exit;
camera->functions->about = camera_about; camera->functions->about = camera_about;
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
badge = BADGE_UNKNOWN; badge = BADGE_UNKNOWN;
gp_camera_get_abilities(camera, &cab); gp_camera_get_abilities(camera, &cab);
switch (cab.usb_vendor) { switch (cab.usb_vendor) {
case USB_VENDOR_ID_SMAL: case USB_VENDOR_ID_SMAL:
case USB_VENDOR_ID_CREATIVE: case USB_VENDOR_ID_CREATIVE:
switch (cab.usb_product) { switch (cab.usb_product) {
case USB_DEVICE_ID_ULTRAPOCKET: case USB_DEVICE_ID_ULTRAPOCKET:
/* could be an axia eyeplate or a slimshot /* could be an axia eyeplate or a slimshot
* figure it out later, when we get the image * figure it out later, when we get the image
* catalogue. * catalogue.
*/ */
badge = BADGE_GENERIC; badge = BADGE_GENERIC;
break; break;
case USB_DEVICE_ID_FLATFOTO: case USB_DEVICE_ID_FLATFOTO:
badge = BADGE_FLATFOTO; badge = BADGE_FLATFOTO;
break; break;
case USB_DEVICE_ID_CARDCAM: case USB_DEVICE_ID_CARDCAM:
badge = BADGE_CARDCAM; badge = BADGE_CARDCAM;
break; break;
default: default:
break; break;
}
break;
case USB_VENDOR_ID_LOGITECH:
switch (cab.usb_product) {
case USB_DEVICE_ID_POCKETDIGITAL:
badge = BADGE_LOGITECH_PD;
break;
default:
break;
}
break;
default:
break;
} }
break;
case USB_VENDOR_ID_LOGITECH: if (badge == BADGE_UNKNOWN) {
switch (cab.usb_product) { /* can't happen. Otherwise, how'd we get to camera_init, neh? */
case USB_DEVICE_ID_POCKETDIGITAL: return GP_ERROR;
badge = BADGE_LOGITECH_PD;
break;
default:
break;
} }
break;
default:
break;
}
if (badge == BADGE_UNKNOWN) { camera->pl = malloc (sizeof (CameraPrivateLibrary));
/* can't happen. Otherwise, how'd we get to camera_init, neh? */ camera->pl->up_type = badge;
return GP_ERROR; /* don't need to do any exciting init stuff until we get pic numbers */
} return GP_OK;
camera->pl = malloc (sizeof (CameraPrivateLibrary));
camera->pl->up_type = badge;
/* don't need to do any exciting init stuff until we get pic numbers */
return GP_OK;
} }

View File

@@ -160,7 +160,7 @@ static int
file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
void *data, GPContext *context) void *data, GPContext *context)
{ {
Camera *camera = data; Camera *camera = data;
int i = 0; int i = 0;
char name[16]; char name[16];
int(avitype); int(avitype);
@@ -366,25 +366,25 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
sonix_decode (frame_data, sonix_decode (frame_data,
data+offset+CAM_OFFSET, w, h); data+offset+CAM_OFFSET, w, h);
sonix_cols_reverse(frame_data, w, h); sonix_cols_reverse(frame_data, w, h);
gp_ahd_decode(frame_data, w, h, ptr+ gp_ahd_decode(frame_data, w, h, ptr+
SAKAR_AVI_FRAME_HEADER_LENGTH, SAKAR_AVI_FRAME_HEADER_LENGTH,
BAYER_TILE_GBRG); BAYER_TILE_GBRG);
break; break;
case DECOMP: case DECOMP:
sonix_decode (frame_data, sonix_decode (frame_data,
data+offset+CAM_OFFSET, w, h); data+offset+CAM_OFFSET, w, h);
sonix_rows_reverse(frame_data, w, h); sonix_rows_reverse(frame_data, w, h);
gp_ahd_decode(frame_data, w, h, ptr+ gp_ahd_decode(frame_data, w, h, ptr+
SAKAR_AVI_FRAME_HEADER_LENGTH, SAKAR_AVI_FRAME_HEADER_LENGTH,
BAYER_TILE_GRBG); BAYER_TILE_GRBG);
break; break;
default: default:
memcpy(frame_data, data + offset memcpy(frame_data, data + offset
+CAM_OFFSET, frame_size); +CAM_OFFSET, frame_size);
sonix_rows_reverse(frame_data, w, h); sonix_rows_reverse(frame_data, w, h);
gp_ahd_decode(frame_data, w, h, ptr+ gp_ahd_decode(frame_data, w, h, ptr+
SAKAR_AVI_FRAME_HEADER_LENGTH, SAKAR_AVI_FRAME_HEADER_LENGTH,
BAYER_TILE_GRBG); BAYER_TILE_GRBG);
} }
white_balance(ptr+SAKAR_AVI_FRAME_HEADER_LENGTH, white_balance(ptr+SAKAR_AVI_FRAME_HEADER_LENGTH,
w * h, 1.2); w * h, 1.2);
@@ -431,15 +431,15 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
if (camera->pl->post&REVERSE) { if (camera->pl->post&REVERSE) {
sonix_decode (p_data, data+CAM_OFFSET, w, h); sonix_decode (p_data, data+CAM_OFFSET, w, h);
sonix_byte_reverse(p_data, w*h); sonix_byte_reverse(p_data, w*h);
gp_ahd_decode(p_data, w, h, ptr, BAYER_TILE_BGGR); gp_ahd_decode(p_data, w, h, ptr, BAYER_TILE_BGGR);
break; break;
case DECOMP: case DECOMP:
sonix_decode (p_data, data+CAM_OFFSET, w, h); sonix_decode (p_data, data+CAM_OFFSET, w, h);
gp_ahd_decode(p_data, w, h, ptr, BAYER_TILE_RGGB); gp_ahd_decode(p_data, w, h, ptr, BAYER_TILE_RGGB);
break; break;
default: default:
memcpy (p_data, data+CAM_OFFSET, w*h); memcpy (p_data, data+CAM_OFFSET, w*h);
gp_ahd_decode(p_data, w, h, ptr, BAYER_TILE_RGGB); gp_ahd_decode(p_data, w, h, ptr, BAYER_TILE_RGGB);
} }
free (p_data); free (p_data);
white_balance(ptr, w * h, 1.2); white_balance(ptr, w * h, 1.2);
@@ -458,7 +458,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
free(data); free(data);
return GP_ERROR_NOT_SUPPORTED; return GP_ERROR_NOT_SUPPORTED;
} }
return GP_OK; return GP_OK;
} }
static int static int
@@ -567,8 +567,8 @@ camera_init(Camera *camera, GPContext *context)
GP_DEBUG("product number is 0x%x\n", abilities.usb_product); GP_DEBUG("product number is 0x%x\n", abilities.usb_product);
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->capture = camera_capture; camera->functions->capture = camera_capture;
camera->functions->manual = camera_manual; camera->functions->manual = camera_manual;
camera->functions->summary = camera_summary; camera->functions->summary = camera_summary;
camera->functions->about = camera_about; camera->functions->about = camera_about;
camera->functions->exit = camera_exit; camera->functions->exit = camera_exit;

View File

@@ -515,8 +515,8 @@ white_balance (unsigned char *data, unsigned int size, float saturation)
x += htable_g[r]; x += htable_g[r];
x += htable_b[r]; x += htable_b[r];
} }
gamma = sqrt((double) (x ) / (double) (size * 2)); gamma = sqrt((double) (x ) / (double) (size * 2));
GP_DEBUG("Provisional gamma correction = %1.2f\n", gamma); GP_DEBUG("Provisional gamma correction = %1.2f\n", gamma);
if(gamma < .1) { if(gamma < .1) {
new_gamma = .50; new_gamma = .50;
@@ -526,8 +526,8 @@ white_balance (unsigned char *data, unsigned int size, float saturation)
new_gamma = 0.60; new_gamma = 0.60;
else else
new_gamma = gamma; new_gamma = gamma;
if (new_gamma > 1.2) new_gamma = 1.2; if (new_gamma > 1.2) new_gamma = 1.2;
GP_DEBUG("Gamma correction = %1.2f\n", new_gamma); GP_DEBUG("Gamma correction = %1.2f\n", new_gamma);
gp_gamma_fill_table(gtable, new_gamma); gp_gamma_fill_table(gtable, new_gamma);
gp_gamma_correct_single(gtable,data,size); gp_gamma_correct_single(gtable,data,size);

View File

@@ -202,7 +202,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
case GP_FILE_TYPE_NORMAL: case GP_FILE_TYPE_NORMAL:
if (file_type == SONY_FILE_MPEG) { if (file_type == SONY_FILE_MPEG) {
rc = sony_mpeg_get(camera, num, file, context); rc = sony_mpeg_get(camera, num, file, context);
} }
else { else {
rc = sony_image_get(camera, num, file, context); rc = sony_image_get(camera, num, file, context);
} }

View File

@@ -308,7 +308,7 @@ sony_packet_write(Camera * camera, Packet * p)
GP_DEBUG( GP_DEBUG(
"sony_packet_write()"); "sony_packet_write()");
/** /**
* This usleep is necessary when using (relatively) fast CPUs, * This usleep is necessary when using (relatively) fast CPUs,
* as P4 2Ghz. Without it gphoto2 stops with a segmentation fault * as P4 2Ghz. Without it gphoto2 stops with a segmentation fault
* and the --debug message sony_packet_validate: invalid sequence * and the --debug message sony_packet_validate: invalid sequence

View File

@@ -20,11 +20,9 @@
#define CAMLIBS_SOUNDVISION_COMMANDS_H #define CAMLIBS_SOUNDVISION_COMMANDS_H
int32_t soundvision_send_command(uint32_t command, uint32_t argument, int32_t soundvision_send_command(uint32_t command, uint32_t argument, CameraPrivateLibrary *dev);
CameraPrivateLibrary *dev);
int32_t soundvision_send_file_command(const char *filename, int32_t soundvision_send_file_command(const char *filename, CameraPrivateLibrary *dev);
CameraPrivateLibrary *dev);
int32_t soundvision_read(CameraPrivateLibrary *dev, void *buffer, int len); int32_t soundvision_read(CameraPrivateLibrary *dev, void *buffer, int len);

View File

@@ -57,16 +57,15 @@
struct _CameraPrivateLibrary { struct _CameraPrivateLibrary {
GPPort *gpdev; GPPort *gpdev;
int device_type; int device_type;
int reset_times,odd_command; int reset_times, odd_command;
int num_pictures; int num_pictures;
char *file_list; char *file_list;
}; };
/* commands.c */ /* commands.c */
int32_t soundvision_send_command(uint32_t command, uint32_t argument, int32_t soundvision_send_command(uint32_t command, uint32_t argument, CameraPrivateLibrary *dev);
CameraPrivateLibrary *dev);
int soundvision_reset(CameraPrivateLibrary *dev, char *revision, char *status); int soundvision_reset(CameraPrivateLibrary *dev, char *revision, char *status);
int soundvision_get_revision(CameraPrivateLibrary *dev,char *revision); int soundvision_get_revision(CameraPrivateLibrary *dev,char *revision);
@@ -93,10 +92,10 @@ int agfa_capture(CameraPrivateLibrary *dev, CameraFilePath *path);
int agfa_delete_picture(CameraPrivateLibrary *dev, const char *filename); int agfa_delete_picture(CameraPrivateLibrary *dev, const char *filename);
int agfa_get_file_list(CameraPrivateLibrary *dev); int agfa_get_file_list(CameraPrivateLibrary *dev);
int agfa_get_pic(CameraPrivateLibrary *dev, const char *filename, int agfa_get_pic(CameraPrivateLibrary *dev, const char *filename,
unsigned char *data,int size); unsigned char *data,int size);
int agfa_get_pic_size(CameraPrivateLibrary *dev, const char *filename); int agfa_get_pic_size(CameraPrivateLibrary *dev, const char *filename);
int agfa_get_thumb(CameraPrivateLibrary *dev, const char *filename, int agfa_get_thumb(CameraPrivateLibrary *dev, const char *filename,
unsigned char *data,int size); unsigned char *data,int size);
int agfa_get_thumb_size(CameraPrivateLibrary *dev, const char *filename); int agfa_get_thumb_size(CameraPrivateLibrary *dev, const char *filename);
@@ -113,10 +112,10 @@ int tiger_capture(CameraPrivateLibrary *dev, CameraFilePath *path);
int tiger_get_mem(CameraPrivateLibrary *dev, int *num_pics, int *mem_total, int *mem_free); int tiger_get_mem(CameraPrivateLibrary *dev, int *num_pics, int *mem_total, int *mem_free);
int tiger_get_file_list(CameraPrivateLibrary *dev); int tiger_get_file_list(CameraPrivateLibrary *dev);
int tiger_get_pic(CameraPrivateLibrary *dev, const char *filename, int tiger_get_pic(CameraPrivateLibrary *dev, const char *filename,
unsigned char *data,int size); unsigned char *data,int size);
int tiger_get_pic_size(CameraPrivateLibrary *dev, const char *filename); int tiger_get_pic_size(CameraPrivateLibrary *dev, const char *filename);
int tiger_get_thumb(CameraPrivateLibrary *dev, const char *filename, int tiger_get_thumb(CameraPrivateLibrary *dev, const char *filename,
unsigned char *data,int size); unsigned char *data,int size);
int tiger_get_thumb_size(CameraPrivateLibrary *dev, const char *filename); int tiger_get_thumb_size(CameraPrivateLibrary *dev, const char *filename);
#endif /* !defined(CAMLIBS_SOUNDVISION_SOUNDVISION_H) */ #endif /* !defined(CAMLIBS_SOUNDVISION_SOUNDVISION_H) */

View File

@@ -105,14 +105,14 @@ models[] =
{"Aiptek:Smart Megacam", 0x04fc, 0x504b, {"Aiptek:Smart Megacam", 0x04fc, 0x504b,
BRIDGE_SPCA504, 0 }, BRIDGE_SPCA504, 0 },
{"Benq:DC1300", 0x04a5, 0x3003, {"Benq:DC1300", 0x04a5, 0x3003,
BRIDGE_SPCA504, 0 }, BRIDGE_SPCA504, 0 },
/* Some other 500a cams with flash */ /* Some other 500a cams with flash */
{"Trust:Familycam 300", 0x084d, 0x0003, {"Trust:Familycam 300", 0x084d, 0x0003,
BRIDGE_SPCA500, SPCA50X_FLASH}, BRIDGE_SPCA500, SPCA50X_FLASH},
{"D-Link:DSC 350+", 0x084d, 0x0003, {"D-Link:DSC 350+", 0x084d, 0x0003,
BRIDGE_SPCA500, SPCA50X_FLASH}, BRIDGE_SPCA500, SPCA50X_FLASH},
{"Minton:S-Cam F5", 0x084d, 0x0003, {"Minton:S-Cam F5", 0x084d, 0x0003,
BRIDGE_SPCA500, SPCA50X_FLASH}, BRIDGE_SPCA500, SPCA50X_FLASH},
{"PureDigital:Ritz Disposable", 0x04fc, 0xffff, {"PureDigital:Ritz Disposable", 0x04fc, 0xffff,
BRIDGE_SPCA504B_PD, SPCA50X_FLASH}, BRIDGE_SPCA504B_PD, SPCA50X_FLASH},
{NULL, 0, 0, 0, 0} {NULL, 0, 0, 0, 0}
@@ -141,7 +141,7 @@ camera_abilities (CameraAbilitiesList *list)
a.status = GP_DRIVER_STATUS_TESTING; a.status = GP_DRIVER_STATUS_TESTING;
a.file_operations = GP_FILE_OPERATION_PREVIEW a.file_operations = GP_FILE_OPERATION_PREVIEW
| GP_FILE_OPERATION_DELETE; | GP_FILE_OPERATION_DELETE;
a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL; a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL;
@@ -155,8 +155,8 @@ camera_abilities (CameraAbilitiesList *list)
a.operations = GP_OPERATION_CAPTURE_IMAGE; a.operations = GP_OPERATION_CAPTURE_IMAGE;
} }
if (models[x].bridge == BRIDGE_SPCA504B_PD) { if (models[x].bridge == BRIDGE_SPCA504B_PD) {
a.operations = GP_OPERATION_CAPTURE_IMAGE; a.operations = GP_OPERATION_CAPTURE_IMAGE;
} }
if (models[x].bridge == BRIDGE_SPCA500) { if (models[x].bridge == BRIDGE_SPCA500) {
/* TEST enable capture for the DSC-350 style cams */ /* TEST enable capture for the DSC-350 style cams */
if (a.usb_vendor == 0x084d) { if (a.usb_vendor == 0x084d) {

View File

@@ -345,7 +345,7 @@ spca50x_flash_get_file_name (CameraPrivateLibrary *pl, int index, char *name)
memset (p, 0, sizeof(p)); memset (p, 0, sizeof(p));
/* dsc350 - get the file info, so we can set the file type /* dsc350 - get the file info, so we can set the file type
correctly */ correctly */
spca500_flash_84D_get_file_info (pl, index, &w, &h, &type, &size); spca500_flash_84D_get_file_info (pl, index, &w, &h, &type, &size);
if (type < 3){ /* for single images */ if (type < 3){ /* for single images */
snprintf (p, sizeof(p), "Img%03d.jpg", (index + 1)); snprintf (p, sizeof(p), "Img%03d.jpg", (index + 1));

View File

@@ -50,8 +50,8 @@ static int spca50x_mode_set_download (CameraPrivateLibrary * lib);
static int spca50x_download_data (CameraPrivateLibrary * lib, uint32_t start, static int spca50x_download_data (CameraPrivateLibrary * lib, uint32_t start,
unsigned int size, uint8_t * buf); unsigned int size, uint8_t * buf);
static int spca50x_get_FATs (CameraPrivateLibrary * lib, int dramtype); static int spca50x_get_FATs (CameraPrivateLibrary * lib, int dramtype);
static int spca50x_sdram_get_file_count_and_fat_count static int spca50x_sdram_get_file_count_and_fat_count (
(CameraPrivateLibrary * lib, int dramtype); CameraPrivateLibrary * lib, int dramtype);
static int spca50x_get_avi_thumbnail (CameraPrivateLibrary * lib, static int spca50x_get_avi_thumbnail (CameraPrivateLibrary * lib,
uint8_t ** buf, unsigned int *len, uint8_t ** buf, unsigned int *len,
struct SPCA50xFile *g_file); struct SPCA50xFile *g_file);
@@ -67,7 +67,7 @@ static inline uint8_t *put_dword (uint8_t * ptr, uint32_t value);
static int static int
spca50x_sdram_get_fat_page (CameraPrivateLibrary * lib, int index, spca50x_sdram_get_fat_page (CameraPrivateLibrary * lib, int index,
int dramtype, uint8_t *p) int dramtype, uint8_t *p)
{ {
switch (dramtype) { switch (dramtype) {
case 4: /* 128 Mbit */ case 4: /* 128 Mbit */
@@ -92,7 +92,7 @@ spca50x_sdram_get_fat_page (CameraPrivateLibrary * lib, int index,
static int static int
spca50x_sdram_get_file_count_and_fat_count (CameraPrivateLibrary * lib, spca50x_sdram_get_file_count_and_fat_count (CameraPrivateLibrary * lib,
int dramtype) int dramtype)
{ {
uint8_t theFat[256]; uint8_t theFat[256];
@@ -128,7 +128,7 @@ spca50x_sdram_get_file_count_and_fat_count (CameraPrivateLibrary * lib,
} else { } else {
while (1) { while (1) {
CHECK (spca50x_sdram_get_fat_page (lib, lib->num_fats, CHECK (spca50x_sdram_get_fat_page (lib, lib->num_fats,
dramtype, theFat)); dramtype, theFat));
if (theFat[0] == 0xFF) if (theFat[0] == 0xFF)
break; break;

View File

@@ -180,7 +180,7 @@ spca50x_capture (CameraPrivateLibrary * lib)
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
sleep (2); sleep (2);
#endif #endif
CHECK (gp_port_usb_msg_write CHECK (gp_port_usb_msg_write
(lib->gpdev, 0x06, 0x0000, 0x0003, NULL, 0)); (lib->gpdev, 0x06, 0x0000, 0x0003, NULL, 0));
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
sleep (3); sleep (3);

View File

@@ -73,9 +73,9 @@ static const struct {
{"Precision Mini Digital Camera", {"Precision Mini Digital Camera",
GP_DRIVER_STATUS_PRODUCTION , 0x2770 , 0x9120}, GP_DRIVER_STATUS_PRODUCTION , 0x2770 , 0x9120},
{"iConcepts digital camera" , {"iConcepts digital camera" ,
GP_DRIVER_STATUS_PRODUCTION , 0x2770 , 0x9120}, GP_DRIVER_STATUS_PRODUCTION , 0x2770 , 0x9120},
{"Sakar Kidz Cam 86379", GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770, {"Sakar Kidz Cam 86379",
0x9120}, GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770, 0x9120},
{"ViviCam3350", GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770, 0x9120}, {"ViviCam3350", GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770, 0x9120},
{"ViviCam5B", GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770, 0x9120}, {"ViviCam5B", GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770, 0x9120},
{"DC-N130ta", GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770, 0x9120}, {"DC-N130ta", GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770, 0x9120},
@@ -140,8 +140,8 @@ camera_summary (Camera *camera, CameraText *summary, GPContext *context)
return GP_OK; return GP_OK;
} }
static int camera_manual (Camera *camera, CameraText *manual, static int
GPContext *context) camera_manual (Camera *camera, CameraText *manual, GPContext *context)
{ {
strcpy(manual->text, strcpy(manual->text,
_( _(
@@ -184,7 +184,7 @@ camera_about (Camera *camera, CameraText *about, GPContext *context)
static int static int
file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
void *data, GPContext *context) void *data, GPContext *context)
{ {
Camera *camera = data; Camera *camera = data;
int i,n; int i,n;
@@ -212,7 +212,7 @@ file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
static int static int
folder_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, folder_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
void *data, GPContext *context) void *data, GPContext *context)
{ {
Camera *camera = data; Camera *camera = data;
int i,n; int i,n;
@@ -229,7 +229,7 @@ folder_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
static int static int
get_info_func (CameraFilesystem *fs, const char *folder, const char *file, get_info_func (CameraFilesystem *fs, const char *folder, const char *file,
CameraFileInfo *info, void *data, GPContext *context) CameraFileInfo *info, void *data, GPContext *context)
{ {
memset (info, 0, sizeof(CameraFileInfo)); memset (info, 0, sizeof(CameraFileInfo));
/* FIXME: fill in some stuff? */ /* FIXME: fill in some stuff? */
@@ -413,7 +413,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
memcpy (rawdata, frame_data, size); memcpy (rawdata, frame_data, size);
memcpy (rawdata+size,camera->pl->catalog+16*entry,16); memcpy (rawdata+size,camera->pl->catalog+16*entry,16);
gp_file_set_mime_type (file, GP_MIME_RAW); gp_file_set_mime_type (file, GP_MIME_RAW);
gp_file_set_data_and_size (file, (char *)rawdata, size+16); gp_file_set_data_and_size (file, (char *)rawdata, size+16);
} }
/* Reset camera when done, for more graceful exit. */ /* Reset camera when done, for more graceful exit. */
if ((!(is_in_clip)&&(entry +1 == camera->pl->nb_entries)) if ((!(is_in_clip)&&(entry +1 == camera->pl->nb_entries))
@@ -424,8 +424,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
} }
static int static int
delete_all_func (CameraFilesystem *fs, const char *folder, void *data, delete_all_func (CameraFilesystem *fs, const char *folder, void *data, GPContext *context)
GPContext *context)
{ {
Camera *camera = data; Camera *camera = data;
@@ -452,7 +451,7 @@ camera_capture_preview (Camera *camera, CameraFile *file, GPContext *context)
return GP_ERROR_NO_MEMORY; return GP_ERROR_NO_MEMORY;
} }
sq_access_reg(camera->port, CAPTURE); sq_access_reg(camera->port, CAPTURE);
sq_read_picture_data (camera->port, camera->pl->last_fetched_data, b); sq_read_picture_data (camera->port, camera->pl->last_fetched_data, b);
frame_data = camera->pl->last_fetched_data + 0x40; frame_data = camera->pl->last_fetched_data + 0x40;
sq_preprocess(camera->pl->model, 1, 0, frame_data, w, h); sq_preprocess(camera->pl->model, 1, 0, frame_data, w, h);
@@ -490,7 +489,7 @@ camera_capture_preview (Camera *camera, CameraFile *file, GPContext *context)
gp_file_set_data_and_size (file, (char *)ppm, size); gp_file_set_data_and_size (file, (char *)ppm, size);
sq_reset(camera->port); sq_reset(camera->port);
sq_access_reg(camera->port, CAPTURE); sq_access_reg(camera->port, CAPTURE);
sq_reset(camera->port); sq_reset(camera->port);
return (GP_OK); return (GP_OK);

View File

@@ -44,7 +44,7 @@
static int static int
decode_panel (unsigned char *panel_out, unsigned char *panel, decode_panel (unsigned char *panel_out, unsigned char *panel,
int panelwidth, int height, int color); int panelwidth, int height, int color);
int int
sq_decompress (SQModel model, unsigned char *output, unsigned char *data, sq_decompress (SQModel model, unsigned char *output, unsigned char *data,
@@ -107,13 +107,13 @@ sq_decompress (SQModel model, unsigned char *output, unsigned char *data,
switch(model) { switch(model) {
case(SQ_MODEL_MAGPIX): case(SQ_MODEL_MAGPIX):
case(SQ_MODEL_POCK_CAM): case(SQ_MODEL_POCK_CAM):
for (i = 0; i < h; i++) { for (i = 0; i < h; i++) {
for (m = 0 ; m < w/2; m++) { for (m = 0; m < w/2; m++) {
temp = output[w*i +m]; temp = output[w*i +m];
output[w*i + m] = output[w*i + w -1 -m]; output[w*i + m] = output[w*i + w -1 -m];
output[w*i + w - 1 - m] = temp; output[w*i + w - 1 - m] = temp;
} }
} }
break; break;
default: ; /* default is "do nothing" */ default: ; /* default is "do nothing" */
} }
@@ -163,7 +163,7 @@ int decode_panel (unsigned char *panel_out, unsigned char *panel,
tempval = (temp_line[2*i]) + diff; tempval = (temp_line[2*i]) + diff;
else else
tempval = (temp_line[2*i] tempval = (temp_line[2*i]
+ panel_out[m*panelwidth+2*i-1])/2 + diff; + panel_out[m*panelwidth+2*i-1])/2 + diff;
tempval = MIN(tempval, 0xff); tempval = MIN(tempval, 0xff);
tempval = MAX(tempval, 0); tempval = MAX(tempval, 0);
panel_out[m*panelwidth+2*i] = tempval; panel_out[m*panelwidth+2*i] = tempval;
@@ -193,7 +193,7 @@ int decode_panel (unsigned char *panel_out, unsigned char *panel,
tempval = (temp_line[0]+temp_line[1])/2 + diff; tempval = (temp_line[0]+temp_line[1])/2 + diff;
else else
tempval = (temp_line[2*i+1] tempval = (temp_line[2*i+1]
+ panel_out[2*m*panelwidth+2*i-1])/2 + diff; + panel_out[2*m*panelwidth+2*i-1])/2 + diff;
tempval = MIN(tempval, 0xff); tempval = MIN(tempval, 0xff);
tempval = MAX(tempval, 0); tempval = MAX(tempval, 0);
panel_out[2*m*panelwidth+2*i] = tempval; panel_out[2*m*panelwidth+2*i] = tempval;

View File

@@ -254,25 +254,25 @@ sq_preprocess (SQModel model, int comp_ratio, unsigned char is_in_clip,
if (!is_in_clip) { if (!is_in_clip) {
/* Turning the picture right-side up. */ /* Turning the picture right-side up. */
for (i = 0; i < b/2; ++i) { for (i = 0; i < b/2; ++i) {
temp = data[i]; temp = data[i];
data[i] = data[b -1 -i]; data[i] = data[b -1 -i];
data[b - 1 - i] = temp; data[b - 1 - i] = temp;
} }
/* But clip frames are already right-side-up */ /* But clip frames are already right-side-up */
} }
/* /*
* POCK_CAM needs de-mirror-imaging, too. But if a photo is * POCK_CAM needs de-mirror-imaging, too. But if a photo is
* compressed we de-mirror after decompression, so not here. * compressed we de-mirror after decompression, so not here.
*/ */
if ((model == SQ_MODEL_POCK_CAM) && (comp_ratio == 1)) { if ((model == SQ_MODEL_POCK_CAM) && (comp_ratio == 1)) {
for (i = 0; i < h; i++) { for (i = 0; i < h; i++) {
for (m = 0 ; m < w/2; m++) { for (m = 0; m < w/2; m++) {
temp = data[w*i +m]; temp = data[w*i +m];
data[w*i + m] = data[w*i + w -1 -m]; data[w*i + m] = data[w*i + w -1 -m];
data[w*i + w - 1 - m] = temp; data[w*i + w - 1 - m] = temp;
} }
} }
} }
return GP_OK; return GP_OK;
} }

View File

@@ -830,9 +830,9 @@ st2205_init(Camera *camera)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, } { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, }
}; };
const int uncompressed_firmware_checksums[] = { const int uncompressed_firmware_checksums[] = {
0x00ab02fc, /* Frame 96x64 from blokker (Netherlands) */ 0x00ab02fc, /* Frame 96x64 from blokker (Netherlands) */
0x00aa8060, /* Blokker frame with picframe hacked firmware */ 0x00aa8060, /* Blokker frame with picframe hacked firmware */
0 }; 0 };
GP_DEBUG ("st2205_init called"); GP_DEBUG ("st2205_init called");

View File

@@ -200,7 +200,7 @@ static int
delete_all_func (CameraFilesystem *fs, const char* folder, void *data, delete_all_func (CameraFilesystem *fs, const char* folder, void *data,
GPContext *context) GPContext *context)
{ {
Camera *camera = data; Camera *camera = data;
if (strcmp (folder, "/")) if (strcmp (folder, "/"))
return (GP_ERROR_DIRECTORY_NOT_FOUND); return (GP_ERROR_DIRECTORY_NOT_FOUND);
return stv0674_delete_all(camera->port); return stv0674_delete_all(camera->port);
@@ -214,38 +214,38 @@ static CameraFilesystemFuncs fsfuncs = {
int camera_init (Camera *camera, GPContext *context) int camera_init (Camera *camera, GPContext *context)
{ {
GPPortSettings settings; GPPortSettings settings;
int ret; int ret;
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->summary = camera_summary; camera->functions->summary = camera_summary;
camera->functions->about = camera_about; camera->functions->about = camera_about;
camera->functions->capture_preview = camera_capture_preview; camera->functions->capture_preview = camera_capture_preview;
camera->functions->capture = camera_capture; camera->functions->capture = camera_capture;
gp_port_get_settings(camera->port, &settings); gp_port_get_settings(camera->port, &settings);
switch(camera->port->type) { switch (camera->port->type) {
case GP_PORT_USB: case GP_PORT_USB:
/* Modify the default settings the core parsed */ /* Modify the default settings the core parsed */
settings.usb.altsetting=1;/* we need to use interface 0 setting 1 */ settings.usb.altsetting=1;/* we need to use interface 0 setting 1 */
settings.usb.inep=2; settings.usb.inep=2;
settings.usb.intep=3; settings.usb.intep=3;
settings.usb.outep=5; settings.usb.outep=5;
/* Use the defaults the core parsed */ /* Use the defaults the core parsed */
break; break;
default: default:
return (GP_ERROR_UNKNOWN_PORT); return (GP_ERROR_UNKNOWN_PORT);
break; break;
} }
ret = gp_port_set_settings (camera->port, settings); ret = gp_port_set_settings (camera->port, settings);
if (ret != GP_OK) { if (ret != GP_OK) {
gp_context_error (context, _("Could not apply USB settings")); gp_context_error (context, _("Could not apply USB settings"));
return ret; return ret;
} }
/* Set up the filesystem */ /* Set up the filesystem */
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
/* test camera */ /* test camera */
return stv0674_ping(camera->port); return stv0674_ping(camera->port);
} }

View File

@@ -38,84 +38,84 @@
#define new(ctype, ccount) calloc(ccount, sizeof(ctype)) #define new(ctype, ccount) calloc(ccount, sizeof(ctype))
static void static void
compute_luts (int sharpen_percent, int *pos_lut, int *neg_lut ) compute_luts (int sharpen_percent, int *pos_lut, int *neg_lut)
{ {
int i; /* Looping var */ int i; /* Looping var */
int fact; /* 1 - sharpness */ int fact; /* 1 - sharpness */
fact = 100 - sharpen_percent; fact = 100 - sharpen_percent;
if (fact < 1) if (fact < 1)
fact = 1; fact = 1;
for (i = 0; i < 256; i ++) for (i = 0; i < 256; i++)
{ {
pos_lut[i] = (800 * i) / fact; pos_lut[i] = (800 * i) / fact;
neg_lut[i] = (4 + pos_lut[i] - (i << 3)) >> 3; neg_lut[i] = (4 + pos_lut[i] - (i << 3)) >> 3;
}; };
} }
/** 'rgb_filter()' - Sharpen RGB pixels. **/ /** 'rgb_filter()' - Sharpen RGB pixels. **/
static void rgb_filter (int width, /* I - Width of line in pixels */ static void rgb_filter (int width, /* I - Width of line in pixels */
int *pos_lut, int *pos_lut,
int *neg_lut, int *neg_lut,
unsigned char *src, /* I - Source line */ unsigned char *src, /* I - Source line */
unsigned char *dst, /* O - Destination line */ unsigned char *dst, /* O - Destination line */
long int *neg0, /* I - Top negative coefficient line */ long int *neg0, /* I - Top negative coefficient line */
long int *neg1, /* I - Middle negative coefficient line */ long int *neg1, /* I - Middle negative coefficient line */
long int *neg2) /* I - Bottom negative coefficient line */ long int *neg2) /* I - Bottom negative coefficient line */
{ {
long int pixel; /* New pixel value */ long int pixel; /* New pixel value */
*dst++ = *src++; *dst++ = *src++;
*dst++ = *src++; *dst++ = *src++;
*dst++ = *src++; *dst++ = *src++;
width -= 2; width -= 2;
while (width > 0) while (width > 0)
{ {
pixel = (pos_lut[*src++] - neg0[-3] - neg0[0] - neg0[3] - pixel = (pos_lut[*src++] - neg0[-3] - neg0[0] - neg0[3] -
neg1[-3] - neg1[3] - neg1[-3] - neg1[3] -
neg2[-3] - neg2[0] - neg2[3]); neg2[-3] - neg2[0] - neg2[3]);
pixel = (pixel + 4) >> 3; pixel = (pixel + 4) >> 3;
if (pixel < 0) if (pixel < 0)
*dst++ = 0; *dst++ = 0;
else if (pixel < 255) else if (pixel < 255)
*dst++ = pixel; *dst++ = pixel;
else else
*dst++ = 255; *dst++ = 255;
pixel = (pos_lut[*src++] - neg0[-2] - neg0[1] - neg0[4] - pixel = (pos_lut[*src++] - neg0[-2] - neg0[1] - neg0[4] -
neg1[-2] - neg1[4] - neg1[-2] - neg1[4] -
neg2[-2] - neg2[1] - neg2[4]); neg2[-2] - neg2[1] - neg2[4]);
pixel = (pixel + 4) >> 3; pixel = (pixel + 4) >> 3;
if (pixel < 0) if (pixel < 0)
*dst++ = 0; *dst++ = 0;
else if (pixel < 255) else if (pixel < 255)
*dst++ = pixel; *dst++ = pixel;
else else
*dst++ = 255; *dst++ = 255;
pixel = (pos_lut[*src++] - neg0[-1] - neg0[2] - neg0[5] - pixel = (pos_lut[*src++] - neg0[-1] - neg0[2] - neg0[5] -
neg1[-1] - neg1[5] - neg1[-1] - neg1[5] -
neg2[-1] - neg2[2] - neg2[5]); neg2[-1] - neg2[2] - neg2[5]);
pixel = (pixel + 4) >> 3; pixel = (pixel + 4) >> 3;
if (pixel < 0) if (pixel < 0)
*dst++ = 0; *dst++ = 0;
else if (pixel < 255) else if (pixel < 255)
*dst++ = pixel; *dst++ = pixel;
else else
*dst++ = 255; *dst++ = 255;
neg0 += 3; neg0 += 3;
neg1 += 3; neg1 += 3;
neg2 += 3; neg2 += 3;
width --; width--;
}; };
*dst++ = *src++; *dst++ = *src++;
*dst++ = *src++; *dst++ = *src++;
*dst++ = *src++; *dst++ = *src++;
} }
/** 'sharpen()' - Sharpen an image using a convolution filter. **/ /** 'sharpen()' - Sharpen an image using a convolution filter. **/
@@ -123,94 +123,92 @@ void sharpen(int width, int height,
unsigned char *src_region, unsigned char *dest_region, unsigned char *src_region, unsigned char *dest_region,
int sharpen_percent int sharpen_percent
) { ) {
unsigned char *src_rows[4], /* Source pixel rows */ unsigned char *src_rows[4], /* Source pixel rows */
*src_ptr, /* Current source pixel */ *src_ptr, /* Current source pixel */
*dst_row; /* Destination pixel row */ *dst_row; /* Destination pixel row */
long int *neg_rows[4], /* Negative coefficient rows */ long int *neg_rows[4], /* Negative coefficient rows */
*neg_ptr; /* Current negative coefficient */ *neg_ptr; /* Current negative coefficient */
int i, /* Looping vars */ int i, /* Looping vars */
y, /* Current location in image */ y, /* Current location in image */
row, /* Current row in src_rows */ row, /* Current row in src_rows */
count, /* Current number of filled src_rows */ count, /* Current number of filled src_rows */
pitch; /* Byte width of the image */ pitch; /* Byte width of the image */
int img_bpp=3; /* Bytes-per-pixel in image */ int img_bpp=3; /* Bytes-per-pixel in image */
int neg_lut[256]; /* Negative coefficient LUT */ int neg_lut[256]; /* Negative coefficient LUT */
int pos_lut[256]; /* Positive coefficient LUT */ int pos_lut[256]; /* Positive coefficient LUT */
compute_luts (sharpen_percent,pos_lut,neg_lut); compute_luts (sharpen_percent, pos_lut, neg_lut);
pitch = width * img_bpp; pitch = width * img_bpp;
for (row = 0; row < 4; row ++) for (row = 0; row < 4; row++)
{
src_rows[row] = new (unsigned char, pitch);
neg_rows[row] = new (long int, pitch);
}
dst_row = new (unsigned char, pitch);
/** Pre-load the first row for the filter... **/
memcpy(src_rows[0], src_region, pitch);
for (i = pitch, src_ptr = src_rows[0], neg_ptr = neg_rows[0];
i > 0; i --, src_ptr ++, neg_ptr ++)
*neg_ptr = neg_lut[*src_ptr];
row = 1;
count = 1;
/** Sharpen... **/
for (y = 0; y < height; y ++)
{
/** Load the next pixel row... **/
if ((y + 1) < height)
{ {
/** Check to see if our src_rows[] array is overflowing yet... **/ src_rows[row] = new (unsigned char, pitch);
if (count >= 3) neg_rows[row] = new (long int, pitch);
count --;
/** Grab the next row... **/
memcpy(src_rows[row], (src_region + pitch*(y+1)), pitch);
for (i = pitch, src_ptr = src_rows[row], neg_ptr = neg_rows[row];
i > 0; i --, src_ptr ++, neg_ptr ++)
*neg_ptr = neg_lut[*src_ptr];
count ++;
row = (row + 1) & 3;
}
else
{
/** No more pixels at the bottom... Drop the oldest samples... **/
count --;
} }
/** Now sharpen pixels and save the results... **/ dst_row = new (unsigned char, pitch);
if (count == 3) /** Pre-load the first row for the filter... **/
memcpy(src_rows[0], src_region, pitch);
for (i = pitch, src_ptr = src_rows[0], neg_ptr = neg_rows[0];
i > 0; i--, src_ptr++, neg_ptr++)
*neg_ptr = neg_lut[*src_ptr];
row = 1;
count = 1;
/** Sharpen... **/
for (y = 0; y < height; y++)
{ {
rgb_filter(width, pos_lut, neg_lut, /** Load the next pixel row... **/
src_rows[(row + 2) & 3], dst_row, if ((y + 1) < height)
neg_rows[(row + 1) & 3] + img_bpp, {
neg_rows[(row + 2) & 3] + img_bpp, /** Check to see if our src_rows[] array is overflowing yet... **/
neg_rows[(row + 3) & 3] + img_bpp); if (count >= 3)
count--;
/** Set the row... **/ /** Grab the next row... **/
memcpy((dest_region + pitch*y), dst_row, pitch); memcpy(src_rows[row], (src_region + pitch*(y+1)), pitch);
}
else if (count == 2) for (i = pitch, src_ptr = src_rows[row], neg_ptr = neg_rows[row];
i > 0; i--, src_ptr++, neg_ptr++)
*neg_ptr = neg_lut[*src_ptr];
count++;
row = (row + 1) & 3;
} else
{
/** No more pixels at the bottom... Drop the oldest samples... **/
count--;
}
/** Now sharpen pixels and save the results... **/
if (count == 3)
{
rgb_filter(width, pos_lut, neg_lut,
src_rows[(row + 2) & 3], dst_row,
neg_rows[(row + 1) & 3] + img_bpp,
neg_rows[(row + 2) & 3] + img_bpp,
neg_rows[(row + 3) & 3] + img_bpp);
/** Set the row... **/
memcpy((dest_region + pitch*y), dst_row, pitch);
} else if (count == 2)
{
if (y == 0) /* first row */
memcpy((dest_region), src_rows[0], pitch);
else /* last row */
memcpy((dest_region + pitch*(y)), src_rows[(height-1)&3], pitch);
}
} /* for */
/** OK, we're done. Free all memory used... **/
for (row = 0; row < 4; row++)
{ {
if (y == 0) /* first row */ free (src_rows[row]);
memcpy((dest_region), src_rows[0], pitch); free (neg_rows[row]);
else /* last row */
memcpy((dest_region + pitch*(y)), src_rows[(height-1)&3], pitch);
} }
} /* for */ free (dst_row);
/** OK, we're done. Free all memory used... **/
for (row = 0; row < 4; row ++)
{
free (src_rows[row]);
free (neg_rows[row]);
}
free (dst_row);
} }

View File

@@ -28,26 +28,26 @@
void bayer_unshuffle_preview(unsigned int w, unsigned int h, unsigned int scale, unsigned char *raw, unsigned char *output) void bayer_unshuffle_preview(unsigned int w, unsigned int h, unsigned int scale, unsigned char *raw, unsigned char *output)
{ {
int x, y, nx, ny; int x, y, nx, ny;
int colour; int rgb[3]; int colour; int rgb[3];
int nw = w >> scale; int nw = w >> scale;
int nh = h >> scale; int nh = h >> scale;
int incr = 1<<scale; int incr = 1<<scale;
for (ny = 0; ny < nh; ++ny, raw += w<<scale) { for (ny = 0; ny < nh; ++ny, raw += w<<scale) {
for (nx = 0; nx < nw; ++nx, output += 3) { for (nx = 0; nx < nw; ++nx, output += 3) {
rgb[0] = 0; rgb[1] = 0; rgb[2] = 0; rgb[0] = 0; rgb[1] = 0; rgb[2] = 0;
for (y = 0; y < incr; ++y) { for (y = 0; y < incr; ++y) {
for (x = 0; x < incr; ++x) { for (x = 0; x < incr; ++x) {
colour = 1 - (x&1) + (y&1); colour = 1 - (x&1) + (y&1);
rgb[colour] += raw[y*w + (nx<<(scale-1))+(x>>1) + ((x&1)? 0: (w>>1))]; rgb[colour] += raw[y*w + (nx<<(scale-1))+(x>>1) + ((x&1) ? 0 : (w>>1))];
}
}
output[0] = rgb[0]>>(2*scale-2);
output[1] = rgb[1]>>(2*scale-1);
output[2] = rgb[2]>>(2*scale-2);
} }
}
output[0] = rgb[0]>>(2*scale-2);
output[1] = rgb[1]>>(2*scale-1);
output[2] = rgb[2]>>(2*scale-2);
} }
}
} }
/****** gamma correction from trans[], plus hardcoded white balance */ /****** gamma correction from trans[], plus hardcoded white balance */
@@ -100,100 +100,100 @@ static const rgbgamma gampar[6][3] = {
void light_enhance(unsigned int vw, unsigned int vh, unsigned int coarse, unsigned int fine, void light_enhance(unsigned int vw, unsigned int vh, unsigned int coarse, unsigned int fine,
unsigned char avg_pix, unsigned char *output) unsigned char avg_pix, unsigned char *output)
{ {
unsigned long int i; unsigned long int i;
int lt=3; /* 3 is auto */ int lt=3; /* 3 is auto */
/* float wb[3][3]; */ /* float wb[3][3]; */
unsigned char trans[3][256]; unsigned char trans[3][256];
unsigned char col; unsigned char col;
/* int tmp1, tmp2, tmp3, whitex=20, whitey=20, j, k; */ /* int tmp1, tmp2, tmp3, whitex=20, whitey=20, j, k; */
double brightness = 1.00; /* FIXME: configurable? */ double brightness = 1.00; /* FIXME: configurable? */
/* fprintf(stderr, "(FineExp=%i CoarseExp=%i => filter=", fine, coarse); */ /* fprintf(stderr, "(FineExp=%i CoarseExp=%i => filter=", fine, coarse); */
#if 0 #if 0
if (fine >= (coarse<<1)) { if (fine >= (coarse<<1)) {
lt = 0; lt = 0;
/* fprintf(stderr, "natural)\n"); */ /* fprintf(stderr, "natural)\n"); */
} else if (((fine<<1) < coarse) && (coarse < 400)) { } else if (((fine<<1) < coarse) && (coarse < 400)) {
lt = 2; lt = 2;
/* fprintf(stderr, "incandescent)\n"); */ /* fprintf(stderr, "incandescent)\n"); */
} else { } else {
lt = 1; lt = 1;
/* fprintf(stderr, "fluorescent)\n"); */ /* fprintf(stderr, "fluorescent)\n"); */
} }
wb[0][0] = 1.08 * x; wb[0][1] = 1.00 * x; wb[0][2] = 0.95 * x; /* natural */ wb[0][0] = 1.08 * x; wb[0][1] = 1.00 * x; wb[0][2] = 0.95 * x; /* natural */
wb[1][0] = 1.00 * x; wb[1][1] = 1.00 * x; wb[1][2] = 1.00 * x; /* fluorescent */ wb[1][0] = 1.00 * x; wb[1][1] = 1.00 * x; wb[1][2] = 1.00 * x; /* fluorescent */
wb[2][0] = 0.90 * x; wb[2][1] = 1.00 * x; wb[2][2] = 1.11 * x; /* incandescent */ wb[2][0] = 0.90 * x; wb[2][1] = 1.00 * x; wb[2][2] = 1.11 * x; /* incandescent */
#else #else
if (fine > coarse) { if (fine > coarse) {
lt = 0; /* fprintf (stderr, "cold)\n"); */ lt = 0; /* fprintf (stderr, "cold)\n"); */
} else if (coarse < 100) { } else if (coarse < 100) {
lt = 1; /* fprintf (stderr, "coldish)\n"); */ lt = 1; /* fprintf (stderr, "coldish)\n"); */
} else if (coarse < 200) { } else if (coarse < 200) {
lt = 2; /* fprintf (stderr, "mid)\n"); */ lt = 2; /* fprintf (stderr, "mid)\n"); */
} else if (coarse < 400) { } else if (coarse < 400) {
lt = 3; /* fprintf (stderr, "warmish)\n"); */ lt = 3; /* fprintf (stderr, "warmish)\n"); */
} else if (avg_pix < 94) { } else if (avg_pix < 94) {
lt = 4; /* fprintf (stderr, "warm)\n"); */ lt = 4; /* fprintf (stderr, "warm)\n"); */
} else { } else {
lt = 5; /* fprintf (stderr, "warm, bright)\n"); */ lt = 5; /* fprintf (stderr, "warm, bright)\n"); */
} }
#endif #endif
#if 0 #if 0
/* find white pixel */ /* find white pixel */
for (j=0;j<vh;j++) for (j=0;j<vh;j++)
{
for (k=0; k<vw; k++)
{ {
i = (j*vw + k)*3; for (k=0; k<vw; k++)
tmp1 = abs(*(output+i) - *(output+i+1)); {
tmp2 = abs(*(output+i) - *(output+i+2)); i = (j*vw + k)*3;
tmp3 = abs(*(output+i+1) - *(output+i+2)); tmp1 = abs(*(output+i) - *(output+i+1));
if ((tmp1<16) && (tmp2<16) && (tmp3<16) && (*(output+i)>=160)) { tmp2 = abs(*(output+i) - *(output+i+2));
whitex = k; whitey = j; tmp3 = abs(*(output+i+1) - *(output+i+2));
break; if ((tmp1<16) && (tmp2<16) && (tmp3<16) && (*(output+i)>=160)) {
} whitex = k; whitey = j;
break;
}
}
} }
}
#endif #endif
for (col = 0; col < 3; col++) { for (col = 0; col < 3; col++) {
double y; double y;
const rgbgamma *gp = gampar[lt] + col; const rgbgamma *gp = gampar[lt] + col;
for(i=0; i<256; ++i) { for (i=0; i<256; ++i) {
if (i < ZERO0) if (i < ZERO0)
y = 0; y = 0;
else if (i < ZERO1) else if (i < ZERO1)
y = 1; y = 1;
else else
y = brightness * gp->ampl * (2 + pow((i-ZERO1)/((double)254-ZERO1),gp->gamma) * 253.5); y = brightness * gp->ampl * (2 + pow((i-ZERO1)/((double)254-ZERO1), gp->gamma) * 253.5);
if (y > 255.0) if (y > 255.0)
y = 255.0; y = 255.0;
trans[col][i] = (unsigned char) y; trans[col][i] = (unsigned char)y;
}
} }
}
for (i=0;i<(vw*vh*3);i+=3) for (i=0;i<(vw*vh*3);i+=3)
{ {
int r,g,b; int r, g, b;
r = *(output+i); r = *(output+i);
g = *(output+i+1); g = *(output+i+1);
b = *(output+i+2); b = *(output+i+2);
/* this (adjusting white) isn't quite right yet, so I turned it off */ /* this (adjusting white) isn't quite right yet, so I turned it off */
if ( 0 && (abs(r-g) < 8) && if (0 && (abs(r-g) < 8) &&
(abs(r-b) < 8) && (abs(r-b) < 8) &&
(abs(b-g) < 8)) { (abs(b-g) < 8)) {
int v = trans[1][(r+b+g+1)/3]; int v = trans[1][(r+b+g+1)/3];
*(output+i) = (unsigned char) (v); *(output+i) = (unsigned char)(v);
*(output+i+1) = (unsigned char) (v); *(output+i+1) = (unsigned char)(v);
*(output+i+2) = (unsigned char) (v); *(output+i+2) = (unsigned char)(v);
fprintf(stderr,"Adjusting white\n"); fprintf(stderr, "Adjusting white\n");
} else { /* this is OK */ } else { /* this is OK */
*(output+i) = trans[0][r]; *(output+i) = trans[0][r];
*(output+i+1) = trans[1][g]; *(output+i+1) = trans[1][g];
*(output+i+2) = trans[2][b]; *(output+i+2) = trans[2][b];
} }
} /* for */ } /* for */
} /* light_enhance */ } /* light_enhance */

View File

@@ -41,7 +41,7 @@ static const struct camera_to_usb {
unsigned short idProduct; unsigned short idProduct;
int serial; int serial;
} camera_to_usb[] = { } camera_to_usb[] = {
/* http://www.vvl.co.uk/products/co-processors/680/680.htm */ /* http://www.vvl.co.uk/products/co-processors/680/680.htm */
{ "STM:USB Dual-mode camera", 0x0553, 0x0202, 1 }, { "STM:USB Dual-mode camera", 0x0553, 0x0202, 1 },
{ "STV0680", 0x0553, 0x0202, 1 }, { "STV0680", 0x0553, 0x0202, 1 },
@@ -270,61 +270,59 @@ static int
delete_all_func (CameraFilesystem *fs, const char* folder, void *data, delete_all_func (CameraFilesystem *fs, const char* folder, void *data,
GPContext *context) GPContext *context)
{ {
Camera *camera = data; Camera *camera = data;
if (strcmp (folder, "/")) if (strcmp (folder, "/"))
return (GP_ERROR_DIRECTORY_NOT_FOUND); return (GP_ERROR_DIRECTORY_NOT_FOUND);
return stv0680_delete_all(camera->port); return stv0680_delete_all(camera->port);
} }
static int static int
storage_info_func (CameraFilesystem *fs, storage_info_func (CameraFilesystem *fs, CameraStorageInformation **sinfos,
CameraStorageInformation **sinfos, int *nrofsinfos, void *data, GPContext *context)
int *nrofsinfos, {
void *data, GPContext *context Camera *camera = (Camera*)data;
) { GPPort *port = camera->port;
Camera *camera = (Camera*)data; struct stv680_camera_info caminfo;
GPPort *port = camera->port; struct stv680_image_info imginfo;
struct stv680_camera_info caminfo; int ret;
struct stv680_image_info imginfo; CameraStorageInformation *sinfo;
int ret;
CameraStorageInformation *sinfo;
/* Get Camera Information */ /* Get Camera Information */
if ((ret = stv0680_try_cmd(port, CMDID_GET_CAMERA_INFO, if ((ret = stv0680_try_cmd(port, CMDID_GET_CAMERA_INFO,
0, (void*)&caminfo, sizeof(caminfo)) < 0)) 0, (void*)&caminfo, sizeof(caminfo)) < 0))
return ret; return ret;
sinfo = malloc(sizeof(CameraStorageInformation)); sinfo = malloc(sizeof(CameraStorageInformation));
if (!sinfo) return GP_ERROR_NO_MEMORY; if (!sinfo) return GP_ERROR_NO_MEMORY;
*sinfos = sinfo; *sinfos = sinfo;
*nrofsinfos = 1; *nrofsinfos = 1;
sinfo->fields = GP_STORAGEINFO_BASE; sinfo->fields = GP_STORAGEINFO_BASE;
strcpy(sinfo->basedir, "/"); strcpy(sinfo->basedir, "/");
sinfo->fields |= GP_STORAGEINFO_ACCESS; sinfo->fields |= GP_STORAGEINFO_ACCESS;
sinfo->access = GP_STORAGEINFO_AC_READONLY_WITH_DELETE; sinfo->access = GP_STORAGEINFO_AC_READONLY_WITH_DELETE;
sinfo->fields |= GP_STORAGEINFO_STORAGETYPE; sinfo->fields |= GP_STORAGEINFO_STORAGETYPE;
sinfo->type = GP_STORAGEINFO_ST_FIXED_RAM; sinfo->type = GP_STORAGEINFO_ST_FIXED_RAM;
sinfo->fields |= GP_STORAGEINFO_FILESYSTEMTYPE; sinfo->fields |= GP_STORAGEINFO_FILESYSTEMTYPE;
sinfo->fstype = GP_STORAGEINFO_FST_GENERICFLAT; sinfo->fstype = GP_STORAGEINFO_FST_GENERICFLAT;
sinfo->fields |= GP_STORAGEINFO_MAXCAPACITY; sinfo->fields |= GP_STORAGEINFO_MAXCAPACITY;
if (caminfo.hardware_config & HWCONFIG_MEMSIZE_16MBIT) if (caminfo.hardware_config & HWCONFIG_MEMSIZE_16MBIT)
sinfo->capacitykbytes = 16*1024/8; sinfo->capacitykbytes = 16*1024/8;
else else
sinfo->capacitykbytes = 64*1024/8; sinfo->capacitykbytes = 64*1024/8;
if ((ret = stv0680_try_cmd(port, CMDID_GET_IMAGE_INFO, 0, if ((ret = stv0680_try_cmd(port, CMDID_GET_IMAGE_INFO, 0,
(void*)&imginfo, sizeof(imginfo))!=GP_OK)) (void*)&imginfo, sizeof(imginfo))!=GP_OK))
return ret; return ret;
sinfo->fields |= GP_STORAGEINFO_FREESPACEIMAGES; sinfo->fields |= GP_STORAGEINFO_FREESPACEIMAGES;
sinfo->freeimages = sinfo->freeimages =
((imginfo.maximages[0]<<8)|imginfo.maximages[1]) - ((imginfo.maximages[0]<<8)|imginfo.maximages[1]) -
((imginfo.index[0]<<8)|imginfo.index[1]); ((imginfo.index[0]<<8)|imginfo.index[1]);
return GP_OK; return GP_OK;
} }
@@ -339,20 +337,20 @@ int camera_init (Camera *camera, GPContext *context)
{ {
GPPortSettings settings; GPPortSettings settings;
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->summary = camera_summary; camera->functions->summary = camera_summary;
camera->functions->about = camera_about; camera->functions->about = camera_about;
camera->functions->capture_preview = camera_capture_preview; camera->functions->capture_preview = camera_capture_preview;
camera->functions->capture = camera_capture; camera->functions->capture = camera_capture;
gp_port_get_settings(camera->port, &settings); gp_port_get_settings(camera->port, &settings);
switch(camera->port->type) { switch(camera->port->type) {
case GP_PORT_SERIAL: case GP_PORT_SERIAL:
gp_port_set_timeout(camera->port, 1000); gp_port_set_timeout(camera->port, 1000);
settings.serial.speed = 115200; settings.serial.speed = 115200;
settings.serial.bits = 8; settings.serial.bits = 8;
settings.serial.parity = 0; settings.serial.parity = 0;
settings.serial.stopbits = 1; settings.serial.stopbits = 1;
break; break;
case GP_PORT_USB: case GP_PORT_USB:
/* Use the defaults the core parsed */ /* Use the defaults the core parsed */
@@ -366,6 +364,6 @@ int camera_init (Camera *camera, GPContext *context)
/* Set up the filesystem */ /* Set up the filesystem */
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
/* test camera */ /* test camera */
return stv0680_ping(camera->port); return stv0680_ping(camera->port);
} }

View File

@@ -167,8 +167,8 @@ struct stv680_user_info {
#define STV0680_VGA_HEIGHT 484 #define STV0680_VGA_HEIGHT 484
int stv0680_try_cmd(GPPort *port, unsigned char cmd, int stv0680_try_cmd(GPPort *port, unsigned char cmd,
unsigned short data, unsigned short data,
unsigned char *response, unsigned char response_len); unsigned char *response, unsigned char response_len);
#endif /* !defined(CAMLIBS_STV0680_STV0680_H) */ #endif /* !defined(CAMLIBS_STV0680_STV0680_H) */

View File

@@ -50,23 +50,23 @@
static const struct static const struct
{ {
char *model; char *model;
int usb_vendor; int usb_vendor;
int usb_product; int usb_product;
} models[]= { } models[]= {
{"Traveler:SX330z",USB_VENDOR_TRAVELER,USB_PRODUCT_SX330Z}, {"Traveler:SX330z",USB_VENDOR_TRAVELER,USB_PRODUCT_SX330Z},
{"Maginon:SX330z",USB_VENDOR_TRAVELER,USB_PRODUCT_SX330Z}, {"Maginon:SX330z",USB_VENDOR_TRAVELER,USB_PRODUCT_SX330Z},
{"Skanhex:SX-330z",USB_VENDOR_TRAVELER,USB_PRODUCT_SX330Z}, {"Skanhex:SX-330z",USB_VENDOR_TRAVELER,USB_PRODUCT_SX330Z},
{"Medion:MD 9700",USB_VENDOR_TRAVELER,USB_PRODUCT_MD9700}, {"Medion:MD 9700",USB_VENDOR_TRAVELER,USB_PRODUCT_MD9700},
{"Jenoptik:JD-3300z3",USB_VENDOR_TRAVELER,USB_PRODUCT_SX330Z}, {"Jenoptik:JD-3300z3",USB_VENDOR_TRAVELER,USB_PRODUCT_SX330Z},
{"Traveler:SX410z",USB_VENDOR_TRAVELER,USB_PRODUCT_SX410Z}, {"Traveler:SX410z",USB_VENDOR_TRAVELER,USB_PRODUCT_SX410Z},
{"Concord:EyeQ 4330",USB_VENDOR_TRAVELER,USB_PRODUCT_SX410Z}, {"Concord:EyeQ 4330",USB_VENDOR_TRAVELER,USB_PRODUCT_SX410Z},
{"Jenoptik:JD-4100z3",USB_VENDOR_TRAVELER,USB_PRODUCT_SX410Z}, {"Jenoptik:JD-4100z3",USB_VENDOR_TRAVELER,USB_PRODUCT_SX410Z},
{"Medion:MD 6000",USB_VENDOR_TRAVELER,USB_PRODUCT_SX410Z}, {"Medion:MD 6000",USB_VENDOR_TRAVELER,USB_PRODUCT_SX410Z},
{"Maginon SX-410z",USB_VENDOR_TRAVELER,USB_PRODUCT_SX410Z}, {"Maginon SX-410z",USB_VENDOR_TRAVELER,USB_PRODUCT_SX410Z},
{"Lifetec:LT 5995",USB_VENDOR_TRAVELER,USB_PRODUCT_SX410Z}, {"Lifetec:LT 5995",USB_VENDOR_TRAVELER,USB_PRODUCT_SX410Z},
{NULL,0,0} {NULL,0,0}
}; };
@@ -76,25 +76,25 @@ static const struct
int int
camera_abilities (CameraAbilitiesList *list) camera_abilities (CameraAbilitiesList *list)
{ {
int i; int i;
CameraAbilities a; CameraAbilities a;
for(i=0;models[i].model;i++) for (i=0;models[i].model;i++)
{ {
memset(&a,0,sizeof(CameraAbilities)); memset(&a, 0, sizeof(CameraAbilities));
strcpy(a.model,models[i].model); strcpy(a.model, models[i].model);
a.usb_vendor = models[i].usb_vendor; a.usb_vendor = models[i].usb_vendor;
a.usb_product = models[i].usb_product; a.usb_product = models[i].usb_product;
a.status = GP_DRIVER_STATUS_EXPERIMENTAL; a.status = GP_DRIVER_STATUS_EXPERIMENTAL;
a.port = GP_PORT_USB; a.port = GP_PORT_USB;
a.speed[0] = 0; a.speed[0] = 0;
a.operations = GP_OPERATION_NONE; a.operations = GP_OPERATION_NONE;
a.file_operations = GP_FILE_OPERATION_PREVIEW| a.file_operations = GP_FILE_OPERATION_PREVIEW|
GP_FILE_OPERATION_DELETE| GP_FILE_OPERATION_DELETE|
GP_FILE_OPERATION_EXIF; GP_FILE_OPERATION_EXIF;
a.folder_operations = GP_FOLDER_OPERATION_NONE; a.folder_operations = GP_FOLDER_OPERATION_NONE;
CR(gp_abilities_list_append(list,a)); CR(gp_abilities_list_append(list, a));
} /* all models... */ } /* all models... */
return(GP_OK); return(GP_OK);
} /* camera_abilities */ } /* camera_abilities */
@@ -190,14 +190,14 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
* Delete file function (working ..) * Delete file function (working ..)
*/ */
static int static int
del_file_func(CameraFilesystem *fs,const char *folder,const char *filename, del_file_func(CameraFilesystem *fs, const char *folder, const char *filename,
void *user_data,GPContext *context) void *user_data, GPContext *context)
{ {
Camera *camera=user_data; Camera *camera=user_data;
/*int id;*/ /*int id;*/
if (strcmp(folder,"/")) return(GP_ERROR_DIRECTORY_NOT_FOUND); if (strcmp(folder, "/")) return(GP_ERROR_DIRECTORY_NOT_FOUND);
GP_DEBUG("Deleting : %s",filename); GP_DEBUG("Deleting : %s", filename);
return(sx330z_delete_file(camera,context,filename)); return(sx330z_delete_file(camera, context, filename));
} /* delete file func */ } /* delete file func */
@@ -207,24 +207,21 @@ del_file_func(CameraFilesystem *fs,const char *folder,const char *filename,
int int
camera_id(CameraText *id) camera_id(CameraText *id)
{ {
strcpy(id->text,"Traveler SX330z"); strcpy(id->text, "Traveler SX330z");
return (GP_OK); return (GP_OK);
} /* camera id */ } /* camera id */
/* /*
* Camera about * Camera about
*/ */
static int static int
camera_about(Camera *camera,CameraText *about,GPContext *context) camera_about(Camera *camera, CameraText *about, GPContext *context)
{ {
strcpy(about->text,_("(Traveler) SX330z Library (And other Aldi-cams).\n" strcpy(about->text, _("(Traveler) SX330z Library (And other Aldi-cams).\n"
"Even other Vendors like Jenoptik, Skanhex, Maginon should work.\n" "Even other Vendors like Jenoptik, Skanhex, Maginon should work.\n"
"Please send bugreports and comments.\n" "Please send bugreports and comments.\n"
"Dominik Kuhlen <kinimod@users.sourceforge.net>\n")); "Dominik Kuhlen <kinimod@users.sourceforge.net>\n"));
return(GP_OK); return(GP_OK);
} /* camera about */ } /* camera about */
@@ -235,9 +232,9 @@ camera_about(Camera *camera,CameraText *about,GPContext *context)
int int
camera_exit(Camera *camera, GPContext *context) camera_exit(Camera *camera, GPContext *context)
{ {
if (camera->pl) if (camera->pl)
free(camera->pl); free(camera->pl);
return(GP_OK); return(GP_OK);
} }
@@ -251,35 +248,35 @@ static CameraFilesystemFuncs fsfuncs = {
* OK, lets get serious ! * OK, lets get serious !
*/ */
int int
camera_init(Camera *camera,GPContext *context) camera_init(Camera *camera, GPContext *context)
{ {
GPPortSettings settings; GPPortSettings settings;
CameraAbilities abilities; CameraAbilities abilities;
/* try to contact the camera ...*/ /* try to contact the camera ...*/
/*CR(gp_port_get_settings(camera->port,&settings));*/ /*CR(gp_port_get_settings(camera->port,&settings));*/
camera->functions->about=camera_about; camera->functions->about=camera_about;
camera->functions->exit=camera_exit; camera->functions->exit=camera_exit;
gp_port_get_settings(camera->port,&settings); gp_port_get_settings(camera->port, &settings);
if (camera->port->type!=GP_PORT_USB) if (camera->port->type!=GP_PORT_USB)
{ {
gp_context_error(context,_("sx330z is USB only")); gp_context_error(context, _("sx330z is USB only"));
return(GP_ERROR_UNKNOWN_PORT); return(GP_ERROR_UNKNOWN_PORT);
} }
/* GP_DEBUG("camera_init : in = %x",camera->port->settings.usb.inep);*/ /* GP_DEBUG("camera_init : in = %x",camera->port->settings.usb.inep);*/
CR(gp_port_set_settings(camera->port,settings)); CR(gp_port_set_settings(camera->port, settings));
CR(gp_port_set_timeout(camera->port,TIMEOUT)); CR(gp_port_set_timeout(camera->port, TIMEOUT));
CR(gp_filesystem_set_funcs(camera->fs, &fsfuncs, camera)); CR(gp_filesystem_set_funcs(camera->fs, &fsfuncs, camera));
camera->pl=malloc(sizeof(CameraPrivateLibrary)); camera->pl=malloc(sizeof(CameraPrivateLibrary));
if (!camera->pl) if (!camera->pl)
return(GP_ERROR_NO_MEMORY); return(GP_ERROR_NO_MEMORY);
CR(gp_camera_get_abilities(camera, &abilities)); CR(gp_camera_get_abilities(camera, &abilities));
camera->pl->usb_product=abilities.usb_product; /* some models differ in Thumbnail size */ camera->pl->usb_product=abilities.usb_product; /* some models differ in Thumbnail size */
/* GP_DEBUG("sx330z Camera_init : sx init %04x",camera->pl->usb_product); */ /* GP_DEBUG("sx330z Camera_init : sx init %04x",camera->pl->usb_product); */
return(sx330z_init(camera,context)); return(sx330z_init(camera, context));
} /* camera init */ } /* camera init */

View File

@@ -503,15 +503,15 @@ CameraFilesystemFuncs fsfuncs = {
int int
camera_init (Camera *camera, GPContext *context) camera_init (Camera *camera, GPContext *context)
{ {
/* First, set up all the function pointers */ /* First, set up all the function pointers */
camera->functions->exit = camera_exit; camera->functions->exit = camera_exit;
camera->functions->get_config = camera_config_get; camera->functions->get_config = camera_config_get;
camera->functions->set_config = camera_config_set; camera->functions->set_config = camera_config_set;
camera->functions->capture = camera_capture; camera->functions->capture = camera_capture;
camera->functions->capture_preview = camera_capture_preview; camera->functions->capture_preview = camera_capture_preview;
camera->functions->summary = camera_summary; camera->functions->summary = camera_summary;
camera->functions->manual = camera_manual; camera->functions->manual = camera_manual;
camera->functions->about = camera_about; camera->functions->about = camera_about;
/* Now, tell the filesystem where to get lists, files and info */ /* Now, tell the filesystem where to get lists, files and info */
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);

Some files were not shown because too many files have changed in this diff Show More