/* 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 the head directory of libgphoto2, in the file 
 * COPYING.
 * Original of this file copyright Theodore Kilgore, 12/05/05.
 */ 
 
 
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. A more specific description of this camera can be 
found in README.9050. Still more recently, several cameras with USB ID 
0x2770:0x913D also came onto the market. These cameras also can be made to 
function with the same code base, in spite of some differences. They are 
more specifically described in README.913D.

The first camera which I knew of with USB ID 0x2770:0x905C 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 the SQ905C 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 one 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					Y
-- 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 on the camera does NOT count the 
	AVI frames as separate items, but thinks all of the frames are part 
	of one photo. Otherwise, the camera in fact sees the frames as 
	ordinary photos, so gphoto2 will give the actual count of all frames, 
	no matter whether photos or part of an AVI clip. Accordingly, gphoto2 
	will download the AVI frames as if they were ordinary photos and will
	sequentially number the frames in the course of numbering the photos
	which come out of the camera. The user can easily create a movie from 
	the AVI frames, using an animation program, such as the "animate" 
	command from the ImageMagick package. The default resolution for AVI 
	frames is always 320x240 regardless of the resolution setting chosen 
	for still photos. AVI mode will use compression if it otherwise 
	happens to be turned on. 

Notes:  

The 0x2770:0x9050 and 0x2770:913D cameras differ from the above description in 
some particulars. Please see the respective README files for details. 

Almost all 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. That is supported in the
kernel but 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.

WARNING about battery use:

In addition to all of the above limitations, the cameras use SDRAM for data
storage. Consequently, the batteries will be drained if one leaves them in
the camera when it is not being used.


WHAT GUI FRONTENDS DOES THIS CAMERA LIBRARY SUPPORT?

Gtkam seems to work well for me with this library, and also flphoto. 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 whichever 
one is your favorite. 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 
correct camera). 


NOTES  

1.	The program is set up to put out pictures in PPM or raw format. The OEM
program offers JPEGs. If the user desires JPEG output, then that can easily 
be done on Linux, using other software which exists independently from 
libgphoto2. 

2.	As of 01/20/2008, all raw files downloaded from these cameras will 
have a "footer" of length 16 bytes. This footer consists of the line from the 
camera's allocation table, which gives some information about the photo. The 
information includes a code for the resolution and compression setting
and some information which may be useful in the future relating to color and 
lighting. Unfortunately, the meaning of the color and lighting information is 
not well enough understood to be useful at this time, but it may be useful in 
the future, so why not preserve the information?

3.	 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. 


4. 	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.


5.	An experimental program for processing raw files into finished photos 
is available now, in gphoto2/trunk/playground/raw_converters/sq_raw_converter
Please try this program. If the results are good, I will incorporate the
routines used there directly into libgphot02/camlibs/digigr8. I like the
results, but they need testing.


6. 	The "High Compression" setting uses an unpublished compression 
algorithm. However, after serious effort the decompression seems to work 
pretty well. There are at this time (01/20/2008) no known issues with it. 

7. 	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. 


A NOTE ON CAPTURE AND ON CHANGING THE RESOLUTION SETTING FOR 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 which trips the shutter will simultaneously delete all frames 
on the camera. On the 0x905C cameras, capture works, 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/2005, 03/28/2007, 06/25/2007, 07/16/2007, 07/23/2007, 
01/21/2008, 01/22/2008, 01/12/2012)