summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2008-03-22 18:11:58 +0000
committerMarcus Meissner <marcus@jet.franken.de>2008-03-22 18:11:58 +0000
commit1e25977ac86913d6092d75d93f4a7a34846f544a (patch)
tree0d2395e4bfd2f0e8aca3733abb48f91559d7555c
parent3e216000636943be733401cfc9e57562eaab7dae (diff)
downloadlibgphoto2-1e25977ac86913d6092d75d93f4a7a34846f544a.tar.gz
merged from trunk
git-svn-id: https://svn.code.sf.net/p/gphoto/code/branches/libgphoto2-2_4/libgphoto2@11015 67ed7778-7388-44ab-90cf-0a291f65f57c
-rw-r--r--camlibs/digigr8/ChangeLog47
-rw-r--r--camlibs/digigr8/Makefile-files9
-rw-r--r--camlibs/digigr8/README.digigr8258
-rw-r--r--camlibs/digigr8/digi_postprocess.c3
-rw-r--r--camlibs/digigr8/digigr8.c31
-rw-r--r--camlibs/digigr8/digigr8.h4
-rw-r--r--camlibs/digigr8/library.c123
7 files changed, 157 insertions, 318 deletions
diff --git a/camlibs/digigr8/ChangeLog b/camlibs/digigr8/ChangeLog
index cea86df68..e307ae843 100644
--- a/camlibs/digigr8/ChangeLog
+++ b/camlibs/digigr8/ChangeLog
@@ -1,3 +1,50 @@
+2008-01-23 Theodore Kilgore <kilgota@auburn.edu>
+ * library.c: camera_capture_preview() revised to be in line with recent
+ revisions of gphoto2. Also digi_init() is now not called unless needed,
+ because camera_capture_preview() does not need it. Functions which need
+ it now check init_done and ask for digi_init() if init_done is still 0.
+ * digigr8.c: init_done parameter is set now to 1 in digi_init().
+ * digigr8.h: init_done parameter added to CameraPrivateLibrary.
+
+2008-01-22 Theodore Kilgore <kilgota@auburn.edu>
+ * digi_postprocess.c: Fixed memory leak in second-stage decompression
+ function.
+ * README.*: Refers to the raw file converter, added today in
+ gphoto/trunk/playground/raw_converters/sq_raw_converter
+
+2008-01-21 Theodore Kilgore <kilgota@auburn.edu>
+ * library.c: Raw files now carry a 16 byte footer consisting of the
+ allocation table's line for the corresponding photo. This is done to
+ facilitate development of a standalone raw processor; information is
+ now saved in the raw file concerning the compression and resolution
+ settings, as well as certain information which may become useful for
+ doing color balance, brightness, and contrast adjustments.
+ * README.digigr8: Renamed README.905C.
+ * README.9050: Split from README.digigr8.
+
+
+2007-12-27 Theodore Kilgore <kilgota@auburn.edu>
+ * library.c: Added Jazz JDC9, reported by
+ Victor Hodge <vhodge@sympatico.ca>.
+
+2007-12-23 Theodore Kilgore <kilgota@auburn.edu>
+ * library.c: Added Sakar no. 92045 Spiderman, reported by
+ Martin Laberge <mlsoft@videotron.ca>.
+
+2007-10-16 Theodore Kilgore <kilgota@auburn.edu>
+ * library.c: Several cameras from Sakar added to list.
+
+2007-09-04 Theodore Kilgore <kilgota@auburn.edu>
+ * library.c: ZINA Mini Digital Keychain Camera, reported by
+ Alvin Austin <alvin.austin@gmail.com>
+
+2007-08-24 Theodore Kilgore <kilgota@auburn.edu>
+ * library.c: Suprema Digital Keychain Camera added, which has
+ new product ID 0x913D, and is able to delete individual photos.
+ * digigr8.c: changes required here, too, to support individual
+ photo deletion.
+
+
2007-07-23 Theodore Kilgore <kilgota@auburn.edu>
* README.digigr8: Notes on how to change the capture-preview
resolution setting added.
diff --git a/camlibs/digigr8/Makefile-files b/camlibs/digigr8/Makefile-files
index 7dba28933..3d0168cd1 100644
--- a/camlibs/digigr8/Makefile-files
+++ b/camlibs/digigr8/Makefile-files
@@ -1,6 +1,9 @@
-EXTRA_DIST += digigr8/README.digigr8
-camlibdoc_DATA += digigr8/README.digigr8
-
+EXTRA_DIST += digigr8/README.905C
+EXTRA_DIST += digigr8/README.9050
+EXTRA_DIST += digigr8/README.913D
+camlibdoc_DATA += digigr8/README.905C
+camlibdoc_DATA += digigr8/README.9050
+camlibdoc_DATA += digigr8/README.913D
EXTRA_LTLIBRARIES += digigr8.la
digigr8_la_SOURCES = \
diff --git a/camlibs/digigr8/README.digigr8 b/camlibs/digigr8/README.digigr8
deleted file mode 100644
index c993d7597..000000000
--- a/camlibs/digigr8/README.digigr8
+++ /dev/null
@@ -1,258 +0,0 @@
-/* This is the README file for libgphoto2/camlibs/digigr8. This README is an
- * integral part of the libgphoto2/camlibs/digigr8 library source code and is
- * distributed with that source code under the LGPL license. a copy of which
- * license may be seen in any of the source files in libgphoto2/camlibs/digigr8,
- * or in the head directory of libgphoto2.
- */
-
-
-INTRODUCTION:
-
-The cameras supported here have a controller chip from S&Q Technologies.
-They have USB Vendor:Product number 0x2770:0x905c. These cameras are cheap
-and basic. Their functioning resembles that of the cameras supported by the
-sq905 camera library, but is a bit different. More recently (07/11/2007) I
-have discovered a camera with Product ID 0x9050 which will also function with
-the same driver library. I will describe it further at the end of this document.
-
-The first camera which I knew of with this USB ID was the Digigr8 from
-RadioShack. Hence comes the name of this camera library. Several more cameras
-have since been reported, including one which has the same make/model painted
-on the plastic case as that of a camera which previously used an sq905 chip
-and used the sq905 Vendor:Product number instead of this one. SQ Technologies
-seems to have discontinued the SQ905 and this chip is apparently its successor.
-
-For information about additional cameras with the same USB ID, I am totally
-dependent on reports from users and testers. If you have another 0x2770:0x905c
-camera and want it to work and it currently does not, then I will be very glad
-to hear from you. Saying this a different way: further progress with your
-camera will depend upon your input. If on the other hand your camera does work
-and is not explicitly listed, I would still like to know about it for the sake
-of completeness. I will give it an explicit line listing in library.c and I
-will credit you as the finder of the camera, in the ChangeLog file.
-
-
-WHAT CHIP IS ACTUALLY IN THESE CAMERAS?
-
-I do not know. I did not take mine apart to look inside. (update) Someone has
-reported to me that he did take his camera apart, and it really is an SQ905C
-chip inside.
-
-WHAT FEATURES DO THESE CAMERAS HAVE, AND WHAT DOES THIS DRIVER SUPPORT?
-
- FEATURE LIST SUPPORTED (Y/N/Part)
--- USB connection to computer
--- High resolution 640x480, uncompressed Y
--- Low resolution 320x240, uncompressed Y
--- High resolution 640x480, compressed Y
--- Low resolution 320x240, compressed Y
--- Ability to "switch" resolution between pictures Y
--- Ability to download all pictures on camera Y
--- Ability to download the first k pictures, where
- k is less than the number on the camera Y
--- Ability to download individual photos Y (faked, but works)
--- Shoot a frame and save image to computer Y
--- Internal battery, which recharges through the USB port (some models)
-
--------------------------------------------------------------------------
-The following things can be done with button-pushes on the camera:
--------------------------------------------------------------------------
--- Frequency filter for use in artificial light. Can be set
- to cancel 60hz or 50hz interference.
--- Delete all, delete last, resolution setting, compression mode setting.
--- "Clip" mode will shoot three frames. The camera "sees" these frames as
- ordinary photos. Also the photo counter on the LED counts them.
--- "AVI" mode shoots until the shutter button is released, or until the
- camera is full. The photo counter does NOT count the AVI frames,
- but thinks all of the frames are part of one photo. Otherwise, the
- camera sees the frames as ordinary photos, so gphoto2 will give the
- actual count of all frames, whether photos or part of an AVI clip,
- Also gphoto2 will download the AVI frames as if they were ordinary
- photos. Apparently, AVI frames are always 320x240 regardless of the
- resolution setting. AVI mode does honor the compression setting,
- though, if it happens to be turned on. However, compressed AVI
- processing is _not_ implemented at this time.
-
-Notes:
-
-One camera has been discovered, in July 2007, to which the above list does
-not correspond. See the section "More concerning the newly discovered
-0x2770:0x9050 camera".
-
-The only known cameras supported by the camlibs/digigr8 have a 640x480
-high-resolution setting and a 320x240 low-resolution setting. If your
-0x2770:0x905c camera uses another resolution setting, then it might still
-work. There is some similarity with the sq905 cameras, and I kept that part
-of the code here. Specifically, if the camera has 352x288 and 176x144
-resolution settings, these might work but are not tested (Note added July 2007:
-the code for 352x288 _does_ continue to work; see below). If your camera does
-not work due to unknown resolution settings, then the new resolution settings
-need to be listed in digigr8.c in digi_get_picture_width (). Please report any
-such problem. I will ask you to run a gphoto2 command in debug mode and we can
-easily find the information we need -- which information, understand, I do not
-possess unless you share it with me.
-
-The pictures obtained on the uncompressed settings can often be superior to
-those obtained using the software which came with the camera, but not
-always. Generally, considering that they are cheap, low resolution cameras,
-these cameras give relatively good pictures.
-
-The digigr8 cameras can also function as webcams, but that is outside the
-scope of gphoto2.
-
-
-HARDWARE LIMITATIONS AND CONSTRAINTS
-
-The SQ905C chip, like the SQ905 before it, is a minimalist controller chip; if
-any of its functionality at all were removed, it would probably be impossible to
-use it to run a digital camera. To program around the limitations of the chip,
-therefore, is a special challenge. Here are some examples.
-
-1. The manufacturer's driver will do nothing but to download all photos
-on the camera, and display them, keeping temporary copies in C:\TEMP, to be
-deleted when the camera access program is closed. After downloading everything,
-then, the OEM program allows the user to "select" and to "save" any or all of
-the photos which have, in fact, already been downloaded (indeed the displayed
-"thumbnails" came from the files in C:\TEMP, too). Now, gphoto2 does not
-operate thus, has preconceived notions about how any respectable camera should
-act, and regards such a primitive camera controller chip as an untamed beast.
-Thus, many of the gphoto2 functions will not work unless, through a bit of
-fakery which involves downloading data and throwing it away and on some
-occasions resetting the camera, this primitive behavior is somewhat improved.
-That all has to be done in the driver, with fakery invisible to the user. These
-remarks apply not only to getting thumbnails, but also to many other gphoto2
-options as well. See item 2.
-
-2. The camera's data storage provides only sequential access, not
-random access. In other words, it acts as though it were a tape drive
-instead of a disk. Worse, it's like a tape drive with no fast forward and
-no rewind controls. The constraints which this places are obvious. It means
-for example that to download all the photos on the camera to display thumbnails
-requires the camera to be reset afterwards, because that is the only way to do
-the "rewind" required before any of the photos can be accessed again. It also
-menas that "gphoto2 -p 2" would NOT download the second photo on the camera,
-unless the support for it is so written as to download the first photo, then
-the second photo, and to process only the second one, having consigned the
-data from the first photo to /dev/null. The camera simply cannot do better.
-The gphoto2 -p 2 command option does work, of course, but only because the
-necessary jury-rigging has been built into the download function.
-
-3. Considering the way the communication protocols of these cameras
-seem to work, it would seem nearly impossible to copy any data to the camera
-for storage and transport. The camera clearly does not have files on it,
-only data addresses. And the camera does not keep time. For similar
-reasons, it would also seem impossible to delete a photo from the camera by
-action of software on the computer. The camera itself supports two choices for
-deletion: delete the last photo taken, or delete all. Each action is
-performed by an appropriate sequence of button pushes on the camera.
-
-
-WHAT GUI FRONTENDS DOES THIS CAMERA LIBRARY SUPPORT?
-
-Gtkam seems to work well for me with this library. Some of the other various
-frontends do not seem to work quite so well for me. But one of them may work
-nicely for you, and you are hereby encouraged to try it. If you want to use
-either gtkam or digikam, you are encouraged to read the camera's manual (in
-gtkam, right-click on the name of the camera in the left panel, after starting
-the program and having chosen the right camera).
-
-
-NOTES
-
-1. The program is set up to put out pictures in PPM or raw format. The OEM
-program offers JPEGs, which the user can easily create on Linux, using other
-software which exists independently from libgphoto2.
-
-2. The gamma setting (actually seems to be one over gamma) used for
-the construction of PPM image files has been obtained by trial and error. It
-seems to work very well for outdoor pictures, but the setting is a
-compromise between what happens with outdoor photos and what happens with
-indoor photos. Conceivably, the program could support a choice between two
-or more gamma settings, optimizing for different conditions.
-
-3. A still-experimental postprocessing routine is added, to provide
-some sharpening and color correction for different lighting conditions. The
-routine can easily be turned off if one wishes, and because it is
-experimental you may so wish. To disable it, just comment out the line in
-get_file_func ( ) in library.c where the function digi_postprocess ( ) is
-called. Then do "make install" to install your change.
-
-4. The "High Compression" setting uses an unpublished compression
-algorithm; decompression seems now to work pretty well.
-
-5. Please get back to me with reports about other SQ cameras (any cameras
-with Vendor number 0x2770), with their specifications (what it says in the OEM
-manual about resolution and number of pictures, as well as make and model, and
-whether it works or not with any libgphoto2 driver or not, would be enough),
-and with a log file if it seems it is supposed to work but there are problems.
-
-
-More concerning the newly discovered 0x2770:0x9050 camera:
-
-This camera is the "Disney pix micro," found at KB Toys. Its functionality
-is very basic. On the package it says the camera is able to take 20 photos, but
-in fact the number of photos is variable. For, they are all compressed. Since
-the compression algorithm is the same as that in the 0x905C cameras, this new
-camera is quite usable, for what it is. Resolution for this camera is fixed at
-352x288 and can not be adjusted. In fact, the only thing on the camera which
-can be controlled at all, aside from snapping photos one at a time, is to
-delete photos one at a time or to delete all. To delete one photo with the
-delete button on the camera, press the button. To delete all, hold it down
-longer. The camera has no clip option, no delayed-shooting option, and no
-multi-frame clips intended for AVI images. However, the camera will do
-software deletion of all photos using the option gphoto2 -D, while for the
-other cameras supported in camlibs/digigr8 the gphoto2 -D option does nothing
-at all. However:
-
-The USB command to delete is the same as the command to shoot a frame
-(gphoto2 option is --capture-preview). If you shoot a frame with the Disney
-pix micro, it will deledte whatever photos are on the camera !!!
-
-
-A note on capture:
-
-These cameras will perform "gphoto2 --capture-preview" which means, to shoot a
-frame and download it to the computer immediately. On the 0x9050 camera, the
-same USB command is what is used to delete all frames on the camera. On the
-0x905C cameras, the capture function works, too, but will not affect whatever
-is on the camera. The default resolution setting for capture with all these
-cameras is 320x240. For those cameras which will do 640x480 resolution in
-still photo mode, there is a tweak which can cause the camera to do the
-capture at 640x480 as well. It is as follows:
-
-Look through the code in camlibs/library.c for the capture function. You will
-see a USB command in which the digit 0x1440 appears. Change that to 0x2840 and
-re-compile and re-install. It is also possible to get 160x120 resolution, but
-that is not so interesting. Evidently, the "40" means to do capture, and the
-previous two digits are the resolution setting in hexadecimal, with the final
-"0" removed. For example, 640=0x280 -> 0x2840 and 320=0x140 -> 0x1440 (which,
-again, is the default setting). I am not sure what would happen if the
-resolution setting here is too high for the camera (the known 0x9050 camera
-will only do 352x288 at max resolution in still mode, for instance). Therefore,
-this tweak is not implemented. However, it does work for me with those cameras
-for which it works. It should be repeated, too, that this tweak is not
-documented by any manufacturer and is not available in the OEM driver for any
-of these cameras.
-
-
-WARRANTY?
-
- Absolutely not. No warranty. Never. Not responsible for any actual
- or potential damage or consequences to anyone or to the equipment of
- anyone for using this program, whether the alleged damage or alleged
- consequences are claimed to be real, imaginary, direct, collateral,
- for pain and suffering, or are claimed to be inflicted upon any
- "third party" who is not the user or installer of the program. The
- program has been written for my pleasure and to broaden and deepen
- my knowledge of computer hardware and software. The program has not
- been written with the immediate expectation of financial gain or
- profit on my part, nor has it been commissioned for pay. It is
- presumed that any end-user of this program will have access to the
- source code of the program and can judge for himself or herself
- whether he/she wishes to use it or not, or can consult someone with
- appropriate expertise to make such a judgment.
-
-
-Theodore Kilgore
-12/05/05
-(revised 12/29/05, 03/28/07, 06/25/07, 07/16/07, 07/23/07) \ No newline at end of file
diff --git a/camlibs/digigr8/digi_postprocess.c b/camlibs/digigr8/digi_postprocess.c
index fd7534710..2f09aa4f6 100644
--- a/camlibs/digigr8/digi_postprocess.c
+++ b/camlibs/digigr8/digi_postprocess.c
@@ -207,6 +207,9 @@ digi_second_decompress (unsigned char *uncomp, unsigned char *in,
templine_blue[i] = tempval;
}
}
+ free(templine_green);
+ free(templine_red);
+ free(templine_blue);
return 0;
}
diff --git a/camlibs/digigr8/digigr8.c b/camlibs/digigr8/digigr8.c
index a4e858bf2..5418d3d25 100644
--- a/camlibs/digigr8/digigr8.c
+++ b/camlibs/digigr8/digigr8.c
@@ -7,7 +7,8 @@
* Copyright (c) 2005 Theodore Kilgore <kilgota@auburn.edu>
* Camera library support under libgphoto2.1.1 for camera(s)
* with chipset from Service & Quality Technologies, Taiwan.
- * The chip supported by this driver is suspected to be the SQ914,
+ * Cameras supported by this driver have Product ID 0x905C, 0x9050, or.
+ * 0x913D.
*
* Licensed under GNU Lesser General Public License, as part of Gphoto
* camera support project. For a copy of the license, see the file
@@ -40,11 +41,12 @@ int
digi_init (GPPort *port, CameraPrivateLibrary *priv)
{
char c[0x14];
- int i;
- unsigned char *catalog = malloc(0x4000);
+ int i,j=0;
+ unsigned char *catalog = calloc(0x4010,1);
unsigned char *catalog_tmp;
if (!catalog) return GP_ERROR_NO_MEMORY;
+
SQWRITE (port, 0x0c, 0x14f4, 0x0, NULL, 0);
SQREAD (port, 0x0c, 0xf5, 0x00, c, 0x14);
SQWRITE (port, 0x0c, 0x1440, 0x110f, NULL, 0);
@@ -58,12 +60,26 @@ digi_init (GPPort *port, CameraPrivateLibrary *priv)
digi_reset (port);
/* The first occurence of a zero denotes end of files entries */
- for (i=0; i<0x4000 && catalog[i]; i+=16) ;
+ for (i=0; i<0x4000 && catalog[i]; i+=16);
priv->nb_entries = i>>4;
- catalog_tmp = realloc(catalog, i);
+ catalog_tmp = realloc(catalog, i+16);
+ memset (catalog_tmp+i, 0, 16);
if (i) {
- if (catalog_tmp) priv->catalog = catalog_tmp;
- else priv->catalog = catalog;
+ /*
+ * 0x913c cameras allow individual photo deletion. This causes
+ * the relevant catalog line to start with 0x64. So the related
+ * lines of config data must be removed, and the deleted
+ * images need to be cast out from the count.
+ */
+
+ for (j=0; j<i; j+=16) {
+ if ((!catalog[j])||(catalog_tmp[j] == 0x64)) {
+ memcpy(catalog_tmp+j, catalog_tmp+j+16, i+16-j);
+ priv->nb_entries -- ;
+ }
+ }
+ if (catalog_tmp) priv->catalog = catalog_tmp;
+ else priv->catalog = catalog;
} else {
priv->catalog = NULL; /* We just have freed catalog_tmp */
}
@@ -71,6 +87,7 @@ digi_init (GPPort *port, CameraPrivateLibrary *priv)
digi_reset (port);
priv->last_fetched_entry = -1;
+ priv->init_done=1;
return GP_OK;
}
diff --git a/camlibs/digigr8/digigr8.h b/camlibs/digigr8/digigr8.h
index 104dd05a0..af5202af1 100644
--- a/camlibs/digigr8/digigr8.h
+++ b/camlibs/digigr8/digigr8.h
@@ -6,7 +6,8 @@
* Copyright (c) 2005 Theodore Kilgore <kilgota@auburn.edu>
* Camera library support under libgphoto2.1.1 for camera(s)
* with chipset from Service & Quality Technologies, Taiwan.
- * The chip supported by this driver is suspected to be the SQ914,
+ * Cameras supported by this driver have Product ID 0x905C, 0x9050, or
+ * 0x913D.
*
* Licensed under GNU Lesser General Public License, as part of Gphoto
* camera support project. For a copy of the license, see the file
@@ -23,6 +24,7 @@ struct _CameraPrivateLibrary {
int nb_entries;
int last_fetched_entry;
int delete_all;
+ unsigned char init_done;
};
diff --git a/camlibs/digigr8/library.c b/camlibs/digigr8/library.c
index 44db7e831..497054ccc 100644
--- a/camlibs/digigr8/library.c
+++ b/camlibs/digigr8/library.c
@@ -60,10 +60,28 @@ static const struct {
{"Che-Ez Snap SNAP-U", GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770, 0x905c},
{"DC-N130t", GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770, 0x905C},
{"Soundstar TDC-35", GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770, 0x905c},
- {"Nexxtech Mini Digital Camera", GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770, 0x905c},
+ {"Nexxtech Mini Digital Camera", GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770,
+ 0x905c},
{"Vivitar Vivicam35", GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770, 0x905c},
{"Praktica Slimpix", GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770, 0x905c},
+ {"ZINA Mini Digital Keychain Camera", GP_DRIVER_STATUS_EXPERIMENTAL,
+ 0x2770, 0x905c},
+ {"Pixie Princess Jelly-Soft", GP_DRIVER_STATUS_EXPERIMENTAL,
+ 0x2770, 0x905c},
+ {"Sakar Micro Digital 2428x", GP_DRIVER_STATUS_EXPERIMENTAL,
+ 0x2770, 0x905c},
+ {"Jazz JDC9", GP_DRIVER_STATUS_EXPERIMENTAL,
+ 0x2770, 0x905c},
{"Disney pix micro", GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770, 0x9050},
+ {"Suprema Digital Keychain Camera", GP_DRIVER_STATUS_EXPERIMENTAL,
+ 0x2770, 0x913d},
+ {"Sakar 28290 and 28292 Digital Concepts Styleshot",
+ GP_DRIVER_STATUS_EXPERIMENTAL,
+ 0x2770, 0x913d},
+ {"Sakar 23070 Crayola Digital Camera", GP_DRIVER_STATUS_EXPERIMENTAL,
+ 0x2770, 0x913d},
+ {"Sakar 92045 Spiderman", GP_DRIVER_STATUS_EXPERIMENTAL,
+ 0x2770, 0x913d},
{NULL,0,0,0}
};
@@ -106,6 +124,8 @@ camera_abilities (CameraAbilitiesList *list)
static int
camera_summary (Camera *camera, CameraText *summary, GPContext *context)
{
+ if(!camera->pl->init_done)
+ digi_init (camera->port, camera->pl);
sprintf (summary->text,_("Your USB camera seems to have an SQ905C chipset.\n"
"The total number of pictures in it is %i\n"
),
@@ -119,24 +139,26 @@ static int camera_manual (Camera *camera, CameraText *manual, GPContext *context
{
strcpy(manual->text,
_(
- "For cameras with SQ905C Technologies chip.\n"
- "Photos will be saved in PPM format.\n\n"
+ "For cameras with insides from S&Q Technologies, which have the \n"
+ "USB Vendor ID 0x2770 and Product ID 0x905C, 0x9050, or 0x913D\n"
+ "Photos are saved in PPM format.\n\n"
"Some of these cameras allow software deletion of all photos.\n"
- "Others do not, depending on the chip revision. \n"
- "If deletion does work, then gphoto2 -- capture image will \n"
- "have the side-effect that it also deletes what is on the camera.\n"
- "Uploading of data to the camera not supported by hardware.\n"
+ "Others do not. No supported camera can do capture-image. All\n"
+ "can do capture-preview (image captured and sent to computer).\n"
+ "If deletion does work for your camera, then capture-preview will\n"
+ "have the side-effect that it also deletes what is on the camera.\n\n"
+ "File uploading and deletion of individual photos by use of a\n"
+ "software command are not supported by the hardware in these\n"
+ "cameras.\n"
));
-
return (GP_OK);
}
-
static int
camera_about (Camera *camera, CameraText *about, GPContext *context)
{
- strcpy (about->text, _("sq905C generic driver\n"
+ strcpy (about->text, _("sq905C generic driver\n"
"Theodore Kilgore <kilgota@auburn.edu>\n"));
return GP_OK;
@@ -151,6 +173,8 @@ file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
{
Camera *camera = data;
int n;
+ if(!camera->pl->init_done)
+ digi_init (camera->port, camera->pl);
GP_DEBUG ("List files in %s\n", folder);
n = camera->pl->nb_entries;
gp_list_populate(list, "pict%03i.ppm", n);
@@ -175,6 +199,10 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
unsigned char gtable[256];
int size;
+ if(!camera->pl->init_done)
+ digi_init (camera->port, camera->pl);
+
+
/* Get the entry number of the photo on the camera */
k = gp_filesystem_number (camera->fs, "/", filename, context);
@@ -205,6 +233,11 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
default: h = 288; break;
}
b = digi_get_data_size (camera->pl, k);
+ if (!b) {
+ GP_DEBUG("Photo number %i deleted?\n",k+1);
+ camera->pl->last_fetched_entry = k;
+ return GP_OK;
+ }
data = malloc (w*h);
if(!data) return GP_ERROR_NO_MEMORY;
@@ -216,17 +249,21 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
size = b;
gp_file_set_mime_type (file, GP_MIME_RAW);
gp_file_set_name (file, filename);
- gp_file_set_data_and_size (file, (char *)data, size);
+ gp_file_append(file, (char *)data, size);
+ /* Save photo's catalog entry as a footer for the raw file */
+ gp_file_append(file, (char *)camera->pl->catalog + k*0x10, 0x10);
/* Reset camera when done, for more graceful exit. */
if (k +1 == camera->pl->nb_entries) {
- digi_rewind (camera->port, camera->pl);
+ digi_rewind (camera->port, camera->pl);
}
+ free(data);
return(GP_OK);
}
-
+
/*
* Now put the data into a PPM image file.
*/
+
ppm = malloc (w * h * 3 + 256); /* room for data + header */
if (!ppm) {
status = GP_ERROR_NO_MEMORY;
@@ -240,7 +277,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
size = strlen ((char *)ppm);
ptr = ppm + size;
size = size + (w * h * 3);
- GP_DEBUG ("size = %i\n", size);
+ GP_DEBUG ("size = %i\n", size);
p_data = malloc( w*h );
if (!p_data) {
status = GP_ERROR_NO_MEMORY;
@@ -262,7 +299,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
gp_file_set_data_and_size (file, (char *)ppm, size);
/* Reset camera when done, for more graceful exit. */
if (k +1 == camera->pl->nb_entries) {
- digi_rewind (camera->port, camera->pl);
+ digi_rewind (camera->port, camera->pl);
}
end:
free(data);
@@ -283,7 +320,6 @@ delete_all_func (CameraFilesystem *fs, const char *folder, void *data,
static int
camera_capture_preview (Camera *camera, CameraFile *file, GPContext *context)
-
{
unsigned char get_size[0x50];
unsigned char *raw_data;
@@ -296,52 +332,48 @@ camera_capture_preview (Camera *camera, CameraFile *file, GPContext *context)
int h = 240;
int b;
- digi_reset (camera->port);
- gp_port_usb_msg_write (camera->port, 0x0c, 0x1440, 0x110f, NULL, 0);
- gp_port_read(camera->port, (char *)get_size, 0x50);
- GP_DEBUG("get_size[0x40] = 0x%x\n", get_size[0x40]);
- b = get_size[0x40]+(get_size[0x41]*0x100);
+ digi_reset (camera->port);
+ gp_port_usb_msg_write (camera->port, 0x0c, 0x1440, 0x110f, NULL, 0);
+ gp_port_read(camera->port, (char *)get_size, 0x50);
+ GP_DEBUG("get_size[0x40] = 0x%x\n", get_size[0x40]);
+ b = get_size[0x40]+(get_size[0x41]*0x100);
GP_DEBUG("b = 0x%x\n", b);
raw_data = malloc(b);
if(!raw_data) {
- free(raw_data);
- return GP_ERROR_NO_MEMORY;
- }
- gp_port_read(camera->port, (char *)raw_data, b);
+ free(raw_data);
+ return GP_ERROR_NO_MEMORY;
+ }
+ gp_port_read(camera->port, (char *)raw_data, b);
frame_data = malloc(w*h);
if (!frame_data) {
free(frame_data);
return GP_ERROR_NO_MEMORY;
- }
- digi_decompress (frame_data, raw_data, w, h);
-
+ }
+ digi_decompress (frame_data, raw_data, w, h);
+ free(raw_data);
/* Now put the data into a PPM image file. */
-
ppm = malloc (w * h * 3 + 256);
if (!ppm) { return GP_ERROR_NO_MEMORY; }
- sprintf ((char *)ppm,
+ sprintf ((char *)ppm,
"P6\n"
"# CREATOR: gphoto2, SQ905C library\n"
"%d %d\n"
"255\n", w, h);
- ptr = ppm + strlen ((char*)ppm);
+ ptr = ppm + strlen ((char*)ppm);
size = strlen ((char*)ppm) + (w * h * 3);
GP_DEBUG ("size = %i\n", size);
gp_bayer_decode (frame_data, w , h , ptr, BAYER_TILE_BGGR);
-
-
- gp_gamma_fill_table (gtable, .5);
+ free(frame_data);
+ gp_gamma_fill_table (gtable, .65);
gp_gamma_correct_single (gtable, ptr, w * h);
- gp_file_set_mime_type (file, GP_MIME_PPM);
- gp_file_set_name (file, filename);
- gp_file_set_data_and_size (file, (char *)ppm, size);
+ gp_file_set_mime_type (file, GP_MIME_PPM);
+ gp_file_set_name (file, filename);
+ gp_file_set_data_and_size (file, (char *)ppm, size);
digi_reset(camera->port);
-
return (GP_OK);
}
-
/*************** Exit and Initialization Functions ******************/
static int
@@ -355,7 +387,6 @@ camera_exit (Camera *camera, GPContext *context)
free (camera->pl);
camera->pl = NULL;
}
-
return GP_OK;
}
@@ -383,7 +414,7 @@ camera_init(Camera *camera, GPContext *context)
camera->functions->capture_preview
= camera_capture_preview;
camera->functions->exit = camera_exit;
-
+
GP_DEBUG ("Initializing the camera\n");
ret = gp_port_get_settings(camera->port,&settings);
@@ -405,15 +436,9 @@ camera_init(Camera *camera, GPContext *context)
default:
camera->pl->delete_all = 0;
}
+ camera->pl->init_done=0;
-
- /* Connect to the camera */
- ret = digi_init (camera->port, camera->pl);
- if (ret != GP_OK) {
- free(camera->pl);
- return ret;
- };
-
+ /* Do digi_init() only if needed for the requested operation. */
return GP_OK;
}