From be72bf3889dfc76f34953b009adf6473bdce2a1e Mon Sep 17 00:00:00 2001 From: Till Adam Date: Fri, 15 Aug 2003 20:14:49 +0000 Subject: [PATCH] Remove obsolete camlib. git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@6644 67ed7778-7388-44ab-90cf-0a291f65f57c --- camlibs/benq/.cvsignore | 10 - camlibs/benq/ChangeLog | 9 - camlibs/benq/Makefile.am | 12 - camlibs/benq/README | 20 - camlibs/benq/benq.c | 208 ----- camlibs/benq/benq.h | 41 - camlibs/benq/library.c | 238 ------ camlibs/gsmart/.cvsignore | 6 - camlibs/gsmart/ChangeLog | 86 --- camlibs/gsmart/Makefile.am | 13 - camlibs/gsmart/README | 58 -- camlibs/gsmart/gsmart-avi-header.h | 76 -- camlibs/gsmart/gsmart-jpeg-header.h | 273 ------- camlibs/gsmart/gsmart-registers.h | 84 -- camlibs/gsmart/gsmart.c | 1020 ------------------------- camlibs/gsmart/gsmart.h | 83 -- camlibs/gsmart/library.c | 448 ----------- camlibs/spca504_flash/.cvsignore | 10 - camlibs/spca504_flash/ChangeLog | 20 - camlibs/spca504_flash/Makefile.am | 12 - camlibs/spca504_flash/README | 24 - camlibs/spca504_flash/library.c | 264 ------- camlibs/spca504_flash/spca504_flash.c | 407 ---------- camlibs/spca504_flash/spca504_flash.h | 47 -- 24 files changed, 3469 deletions(-) delete mode 100644 camlibs/benq/.cvsignore delete mode 100644 camlibs/benq/ChangeLog delete mode 100644 camlibs/benq/Makefile.am delete mode 100644 camlibs/benq/README delete mode 100644 camlibs/benq/benq.c delete mode 100644 camlibs/benq/benq.h delete mode 100644 camlibs/benq/library.c delete mode 100644 camlibs/gsmart/.cvsignore delete mode 100644 camlibs/gsmart/ChangeLog delete mode 100644 camlibs/gsmart/Makefile.am delete mode 100644 camlibs/gsmart/README delete mode 100644 camlibs/gsmart/gsmart-avi-header.h delete mode 100644 camlibs/gsmart/gsmart-jpeg-header.h delete mode 100644 camlibs/gsmart/gsmart-registers.h delete mode 100644 camlibs/gsmart/gsmart.c delete mode 100644 camlibs/gsmart/gsmart.h delete mode 100644 camlibs/gsmart/library.c delete mode 100644 camlibs/spca504_flash/.cvsignore delete mode 100644 camlibs/spca504_flash/ChangeLog delete mode 100644 camlibs/spca504_flash/Makefile.am delete mode 100644 camlibs/spca504_flash/README delete mode 100644 camlibs/spca504_flash/library.c delete mode 100644 camlibs/spca504_flash/spca504_flash.c delete mode 100644 camlibs/spca504_flash/spca504_flash.h diff --git a/camlibs/benq/.cvsignore b/camlibs/benq/.cvsignore deleted file mode 100644 index b0ff7a469..000000000 --- a/camlibs/benq/.cvsignore +++ /dev/null @@ -1,10 +0,0 @@ -*~ .*~ -*.lo -*.la -.libs -.deps -Makefile -Makefile.in -*.patch -protocol.xml -crw diff --git a/camlibs/benq/ChangeLog b/camlibs/benq/ChangeLog deleted file mode 100644 index 1e90b3608..000000000 --- a/camlibs/benq/ChangeLog +++ /dev/null @@ -1,9 +0,0 @@ -Mon Jan 20 20:45:15 2003 Till Adam - - * remove unused exit handler - * write the current date and time to the cam in init, to sync it. It seems - to require that occasionally to be able to keep time. - -Sam Jan 18 22:00:10 2003 Till Adam - - * initial import diff --git a/camlibs/benq/Makefile.am b/camlibs/benq/Makefile.am deleted file mode 100644 index 02e7d26d5..000000000 --- a/camlibs/benq/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -camlib_LTLIBRARIES = libgphoto2_benq.la - -INCLUDES = \ - -I$(top_srcdir)/intl \ - -I$(top_srcdir)/libgphoto2_port/libgphoto2_port \ - -I$(top_srcdir)/libgphoto2 \ - -I$(top_builddir)/libgphoto2 - -libgphoto2_benq_la_SOURCES = benq.c \ - benq.h library.c -libgphoto2_benq_la_LDFLAGS = -module -avoid-version -libgphoto2_benq_la_LIBADD = $(top_builddir)/libgphoto2/libgphoto2.la diff --git a/camlibs/benq/README b/camlibs/benq/README deleted file mode 100644 index d56e65ba6..000000000 --- a/camlibs/benq/README +++ /dev/null @@ -1,20 +0,0 @@ -What is it? ------------ -This is a camlib supporting the Benq DC1300 camera and possibly others. It was -implemented using information obtained by sniffing the usb bus on Windows, -disassembling the windows driver dll's and some guesswork. - -Features --------- -It currently supports downloading of images and deleting all files on the -camera. - -Author -------- -Till Adam - -Thanks ------- -Johan Nilsson made windows snoops, tested the -early versions and helped debug them. Without him, this would not have been -possible. diff --git a/camlibs/benq/benq.c b/camlibs/benq/benq.c deleted file mode 100644 index e882b5fc9..000000000 --- a/camlibs/benq/benq.c +++ /dev/null @@ -1,208 +0,0 @@ -/****************************************************************/ -/* benq.c - Gphoto2 library for Benq DC1300 cameras and friends */ -/* */ -/* Author: Till Adam */ -/* */ -/* This library is free software; you can redistribute it */ -/* and/or modify it under the terms of the GNU Library General */ -/* Public License as published by the Free Software Foundation; */ -/* either version 2 of the License, or (at your option) any */ -/* later version. */ -/* */ -/* This library is distributed in the hope that it will be */ -/* useful, but WITHOUT ANY WARRANTY; without even the implied */ -/* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR */ -/* PURPOSE. See the GNU Library General Public License for */ -/* more details. */ -/* */ -/* You should have received a copy of the GNU Library General */ -/* Public License along with this library; if not, write to the */ -/* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */ -/* Boston, MA 02111-1307, USA. */ -/****************************************************************/ -#include "config.h" -#include -#include -#include -#include "benq.h" - -#include -#include -#include - -#define GP_MODULE "benq" - -static int -benq_wait_for_ready(GPPort *port) -{ - int timeout = 30; - uint8_t ready = 0; - while (timeout--) { - sleep(1); - CHECK (gp_port_usb_msg_read (port, 0x21, 0x0000, 0x0000, - (char*)&ready, 0x01)); - if (ready) - return GP_OK; - } - return GP_ERROR; -} - -int -benq_get_TOC(CameraPrivateLibrary *pl, int *filecount) -{ - uint16_t n_toc_entries; - int toc_size = 0; - - CHECK (gp_port_usb_msg_read (pl->gpdev, 0x54, 0x0000, 0x0000, - (char*)&n_toc_entries, 0x02)); - *filecount = n_toc_entries; - - if (n_toc_entries == 0) - return GP_OK; - - /* Request the TOC */ - CHECK (gp_port_usb_msg_read (pl->gpdev, 0x54, n_toc_entries, 0x0001, - NULL, 0x00)); - - /* slurp it in. Supposedly there's 32 bytes in each entry. */ - toc_size = n_toc_entries * 32; - /* align */ - if (toc_size % 512 != 0) - toc_size = ((toc_size / 512) + 1) * 512; - - if (pl->toc) - free (pl->toc); - pl->toc = malloc(toc_size); - if (!pl->toc) - return GP_ERROR_NO_MEMORY; - CHECK (benq_wait_for_ready(pl->gpdev)); - CHECK (gp_port_read (pl->gpdev, pl->toc, toc_size)); - - return GP_OK; -} - -int -benq_get_filecount (GPPort *port, int *filecount) -{ - uint16_t response = 0; - CHECK (gp_port_usb_msg_read (port, 0x54, 0x0000, 0x0000, - (char*)&response, 0x02)); - *filecount = response; - return GP_OK; -} - -int -benq_delete_all (GPPort *port) -{ - CHECK (gp_port_usb_msg_write (port, 0x52, 0x0, 0x0, NULL, 0x0)); - return GP_OK; -} - -int -benq_get_file_name (CameraPrivateLibrary *lib, int index, char *name) -{ - uint8_t *p; - - p = lib->toc + index*32; - memcpy (name, p, 8); - name[8] = '.'; - memcpy (name+9, p+8, 3); - name[12] = '\0'; - return GP_OK; -} - -int -benq_get_file_size (CameraPrivateLibrary *lib, int index, int *size) -{ - uint8_t *p; - - p = lib->toc + index*32; - *size = (p[0x1c] & 0xff) - + (p[0x1d] & 0xff) * 0x100 - + (p[0x1e] & 0xff) * 0x10000 - + (p[0x1f] & 0xff) * 0x1000000; - - return GP_OK; -} - -int -benq_get_file (CameraPrivateLibrary *lib, GPContext *context, - uint8_t ** data, unsigned int *len, int index, int thumbnail) -{ - uint32_t file_size = 0, aligned_size = 0; - uint32_t addr = 0; - uint8_t *p, *buf; - - p = lib->toc + index*32; - - aligned_size = file_size = - (p[0x1c] & 0xff) - + (p[0x1d] & 0xff) * 0x100 - + (p[0x1e] & 0xff) * 0x10000; - - addr = (p[0x18] & 0xff) - + (p[0x19] & 0xff) * 0x100 - + (p[0x1a] & 0xff) * 0x10000 - + (p[0x1b] & 0xff) * 0x1000000; - - /* Trigger download of image data */ - CHECK (gp_port_usb_msg_write (lib->gpdev, - 0x54, index+1, 0x0002, NULL, 0x00)); - /* align */ - if (file_size % 16384 != 0) - aligned_size = ((file_size / 16384) + 1) * 16384; - - buf = malloc (aligned_size); - if (!buf) - return GP_ERROR_NO_MEMORY; - - CHECK (benq_wait_for_ready(lib->gpdev)); - CHECK (gp_port_read (lib->gpdev, buf, aligned_size)); - - *data = buf; - *len = file_size; - return GP_OK; -} - -int -benq_init (GPPort *port, GPContext *context) -{ - uint8_t bytes[7]; - time_t t; - struct tm *ftm; - int i; - - /* firmware detection */ - CHECK (gp_port_usb_msg_read (port, 0x20, 0x0000, 0x0000, bytes, 0x01)); - CHECK (gp_port_usb_msg_read (port, 0x20, 0x0000, 0x0000, bytes, 0x05)); - - CHECK (gp_port_usb_msg_read (port, 0x21, 0x0000, 0x0000, bytes, 0x01)); - - /* - * The cam is supposed to sync up with the computer time here - * somehow, or at least that's what we think. - */ - - time(&t); - ftm = localtime(&t); - - bytes[0] = ftm->tm_sec; - bytes[1] = ftm->tm_min; - bytes[2] = ftm->tm_hour; - bytes[3] = 0; /* what is that? either 0x0 or 0x6 */ - bytes[4] = ftm->tm_mday; - bytes[5] = ftm->tm_mon+1; - bytes[6] = ftm->tm_year-100; /* stupido. Year is 1900 + tm_year. - We need two digits only. */ - - - GP_DEBUG("Timestamp: %4d-%02d-%02d %2d:%02d:%02d", - ftm->tm_year+1900,ftm->tm_mon+1,ftm->tm_mday, - ftm->tm_hour,ftm->tm_min,ftm->tm_sec); - - for (i=0;i<7;i++) - CHECK (gp_port_usb_msg_write (port, 0x29, 0x0000, i, - bytes+i, 0x01)); - - return GP_OK; -} diff --git a/camlibs/benq/benq.h b/camlibs/benq/benq.h deleted file mode 100644 index 817dde889..000000000 --- a/camlibs/benq/benq.h +++ /dev/null @@ -1,41 +0,0 @@ -/* benq.h - * - * This library is free software; you can redistribute and/or - * modify it inder the terms of the GNU Lesser Genreral Public - * License as publiced by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warrenty of - * MERCHANTABULITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * lesser General Public License for more details. - * - * Author: Till Adam - */ - -#ifndef __BENQ_H__ -#define __BENQ_H__ - -#include -#include -#include - -#define CHECK(result) {int res; res = result; if (res < 0) return (res);} - -struct _CameraPrivateLibrary -{ - GPPort *gpdev; - uint8_t *toc; -}; - -int benq_init(GPPort *port, GPContext *context); - -int benq_get_TOC(CameraPrivateLibrary *pl, int *filecount); -int benq_get_file_name(CameraPrivateLibrary *pl, int index, char *name); -int benq_get_file (CameraPrivateLibrary *lib, GPContext *context, - uint8_t **buf, unsigned int *len, int index, int thumbnail); -int benq_get_file_size(CameraPrivateLibrary *pl, int index, int *size); -int benq_get_filecount(GPPort *port, int *filecount); -int benq_delete_all (GPPort *port); -#endif - diff --git a/camlibs/benq/library.c b/camlibs/benq/library.c deleted file mode 100644 index 6b9dc3b6d..000000000 --- a/camlibs/benq/library.c +++ /dev/null @@ -1,238 +0,0 @@ -/****************************************************************/ -/*library.c - Gphoto2 library for Benq DC1300 cameras and */ -/* friends */ -/* */ -/* Author: Till Adam */ -/* */ -/* This library is free software; you can redistribute it */ -/* and/or modify it under the terms of the GNU Library General */ -/* Public License as published by the Free Software Foundation; */ -/* either version 2 of the License, or (at your option) any */ -/* later version. */ -/* */ -/* This library is distributed in the hope that it will be */ -/* useful, but WITHOUT ANY WARRANTY; without even the implied */ -/* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR */ -/* PURPOSE. See the GNU Library General Public License for */ -/* more details. */ -/* */ -/* You should have received a copy of the GNU Library General */ -/* Public License along with this library; if not, write to the */ -/* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */ -/* Boston, MA 02111-1307, USA. */ -/****************************************************************/ - -#include "config.h" - -#include "benq.h" - -#include -#include -#include - -#include -#include - -#define GP_MODULE "benq" - -#ifdef ENABLE_NLS -# include -# undef _ -# define _(String) dgettext (GETTEXT_PACKAGE, String) -# ifdef gettext_noop -# define N_(String) gettext_noop (String) -# else -# define N_(String) (String) -# endif -#else -# define _(String) (String) -# define N_(String) (String) -#endif - -struct models -{ - char *name; - unsigned short idVendor; - unsigned short idProduct; -} -models[] = -{ - {"Benq:DC1300", 0x04a5, 0x3003}, - { NULL, 0, 0} -}; - -static int delete_all_func (CameraFilesystem *fs, const char *folder, - void *data, GPContext *context); - - -int -camera_id (CameraText *id) -{ - strcpy (id->text, "benq"); - return (GP_OK); -} - -int -camera_abilities (CameraAbilitiesList *list) -{ - int i; - CameraAbilities a; - - for (i = 0; models[i].name; i++) { - memset (&a, 0, sizeof (CameraAbilities)); - strcpy (a.model, models[i].name); - a.status = GP_DRIVER_STATUS_EXPERIMENTAL; - a.port = GP_PORT_USB; - a.speed[0] = 0; - a.usb_vendor = models[i].idVendor; - a.usb_product = models[i].idProduct; - a.operations = GP_OPERATION_NONE; - a.folder_operations = GP_FOLDER_OPERATION_NONE; - a.file_operations = GP_FILE_OPERATION_DELETE; - gp_abilities_list_append (list, a); - } - return GP_OK; -} - - -static int -file_list_func (CameraFilesystem *fs, const char *folder, - CameraList *list, void *data, GPContext *context) -{ - - Camera *camera = data; - int i = 0, filecount = 0; - char temp_file[14]; - - CHECK (benq_get_TOC(camera->pl, &filecount)); - for (i=0; ipl, i, temp_file)); - gp_list_append (list, temp_file, NULL); - } - - return GP_OK; -} - - -static int -get_file_func (CameraFilesystem *fs, const char *folder, - const char *filename, CameraFileType type, - CameraFile *file, void *user_data, GPContext *context) -{ - Camera *camera = user_data; - unsigned char *data = NULL; - int size, number; - - CHECK (number = - gp_filesystem_number (camera->fs, folder, filename, context)); - switch (type) { - case GP_FILE_TYPE_NORMAL: - CHECK (benq_get_file (camera->pl, context, - &data, &size, number, 0)); - break; - case GP_FILE_TYPE_PREVIEW: - CHECK (benq_get_file (camera->pl, context, - &data, &size, number, 1)); - CHECK (gp_file_set_mime_type (file, GP_MIME_BMP)); - break; - default: - return GP_ERROR_NOT_SUPPORTED; - } - - if (!data) - return GP_ERROR; - - CHECK (gp_file_set_data_and_size (file, data, size)); - CHECK (gp_file_set_name (file, filename)); - - return GP_OK; -} - -static int -camera_about (Camera *camera, CameraText *about, GPContext *context) -{ - strcpy (about->text, - ("benq camlib\n" - "Author: Till Adam\n \n")); - return GP_OK; -} - -static int -get_info_func (CameraFilesystem *fs, const char *folder, const char *filename, - CameraFileInfo *info, void *data, GPContext *context) -{ - Camera *camera = data; - int n, filecount; - unsigned int size; - char name[14]; - - /* Get the file number from the CameraFileSystem */ - CHECK (n = - gp_filesystem_number (camera->fs, folder, filename, context)); - - CHECK (benq_get_TOC(camera->pl, &filecount)); - CHECK (benq_get_file_name(camera->pl, n, name)); - CHECK (benq_get_file_size(camera->pl, n, &size)); - - info->file.fields = GP_FILE_INFO_NAME | GP_FILE_INFO_SIZE; - strncpy (info->file.name, name, sizeof (info->file.name)); - info->file.size = size; - - return GP_OK; -} - -static int -delete_all_func (CameraFilesystem *fs, const char *folder, void *data, - GPContext *context) -{ - Camera *camera = data; - - CHECK (benq_delete_all (camera->port)); - return GP_OK; -} - -int -camera_init (Camera *camera, GPContext *context) -{ - GPPortSettings settings; - int ret = 0; - - camera->functions->about = camera_about; - switch (camera->port->type) { - case GP_PORT_USB: - ret = gp_port_get_settings (camera->port, &settings); - if (ret < 0) - return ret; - settings.usb.inep = 0x82; - settings.usb.outep = 0x03; - settings.usb.config = 1; - settings.usb.interface = 1; - settings.usb.altsetting = 0; - ret = gp_port_set_settings (camera->port, settings); - if (ret < 0) - return ret; - break; - case GP_PORT_SERIAL: - return GP_ERROR_IO_SUPPORTED_SERIAL; - default: - return GP_ERROR_NOT_SUPPORTED; - } - CHECK (benq_init (camera->port, context)); - - camera->pl = malloc (sizeof (CameraPrivateLibrary)); - if (!camera->pl) - return (GP_ERROR_NO_MEMORY); - - memset (camera->pl, 0, sizeof (CameraPrivateLibrary)); - camera->pl->gpdev = camera->port; - - gp_filesystem_set_info_funcs (camera->fs, get_info_func, NULL, camera); - gp_filesystem_set_list_funcs (camera->fs, file_list_func, NULL, camera); - gp_filesystem_set_file_funcs (camera->fs, get_file_func, NULL, camera); - gp_filesystem_set_folder_funcs - (camera->fs, NULL, delete_all_func, NULL, NULL, camera); - - - return GP_OK; -} diff --git a/camlibs/gsmart/.cvsignore b/camlibs/gsmart/.cvsignore deleted file mode 100644 index 09980ae6b..000000000 --- a/camlibs/gsmart/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la diff --git a/camlibs/gsmart/ChangeLog b/camlibs/gsmart/ChangeLog deleted file mode 100644 index 65864ab6e..000000000 --- a/camlibs/gsmart/ChangeLog +++ /dev/null @@ -1,86 +0,0 @@ -Fri Jan 24 12:15:01 2003 Till Adam - - * fix thumbnail colors for low res images. Ported from a patch by - Mark Zimmerman for the spca504_flash camlib - -Don Jan 16 23:34:21 2003 Till Adam - - * add avi support for the Maxell and related models - -Don Jan 16 20:44:22 2003 Till Adam - - * add experimental support for the Maxell Max Pocket cam with a slightly - different firmware - * bump version number to 0.4 - -Sam Dez 07 21:04:46 2002 Till Adam - - * the lowest res of the mini is a different format, cope with that - * fix cases where the number of frames advertised by one of the fat pages of - an avi exceed the total number of frames it has - (Reported by Gerd Flaig ) - -Tue Nov 05 12:17:30 2002 Till Adam - - * return unssuported for avi downloading and small and large image - resolutions if the bridge is a SPCA500 (gsmart mini). - -Sat Oct 19 22:52:34 2002 Till Adam - - * another patch from Piotr Pawlow which omits the standard - huffmann tables in the mjpeg thereby reducing them in size. This seems - to be a standard extension of the mjpeg "standard" and works with the - players I've tested - -Mon Oct 14 20:32:08 2002 Till Adam - - * move jpeg creation into function - * add experimental support for the "gsmart mini" - * bump version number to 0.3 - * driver status for the spca504a based is now TESTING - * patch from Piotr Pawlow adding an index to downloaded - avi's and fixing a few bugs. - * endianess fixes - -Wed Oct 09 19:58:01 2002 Till Adam - - * add experimental support for the "gSmart mini 3" and "So. Show 301" - * (identical to the gSmart mini 2) - -Tue Oct 08 22:14:04 2002 Till Adam - - * add support for avi downloading - -2002-10-03 Lutz Müller - - * Makefile.am: -I$(top_builddir)/libgphoto2 - -Sam Aug 31 20:15:03 2002 Till Adam - - * return name in the file_info as well. Fixes kamera kio-slave - * endianess fix reported by Carl Lunde - * spelling fix - -Thu Aug 22 20:46:02 2002 Till Adam - - * add support for avi thumbnails - -Tue Aug 13 21:37:08 2002 Till Adam - - * add a little timeout after deletion of a file. The camera ignores - successive deletes otherwise. - -Tue Aug 13 14:13:27 2002 Till Adam - - * disallow deletion of anything but the last file on the camera - -Sat Aug 10 19:03:31 2002 Till Adam - - * remove debugging calls - * allocate space for GsmartFile structures dynamically - * sprintf -> snprintf, strcpy -> strncpy, fprintf -> gp_context_error - * make internally used functions static and remove them from gsmart.h - -Mon Aug 05 00:01:06 2002 Till Adam - - * initial release of the module diff --git a/camlibs/gsmart/Makefile.am b/camlibs/gsmart/Makefile.am deleted file mode 100644 index 1d5ee4de5..000000000 --- a/camlibs/gsmart/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -camlib_LTLIBRARIES = libgphoto2_gsmart.la - -INCLUDES = \ - -I$(top_srcdir)/intl \ - -I$(top_srcdir)/libgphoto2_port/libgphoto2_port \ - -I$(top_srcdir)/libgphoto2 \ - -I$(top_builddir)/libgphoto2 - -libgphoto2_gsmart_la_SOURCES = gsmart.c gsmart.h library.c \ - gsmart-jpeg-header.h gsmart-registers.h \ - gsmart-avi-header.h -libgphoto2_gsmart_la_LDFLAGS = -module -avoid-version -libgphoto2_gsmart_la_LIBADD = $(top_builddir)/libgphoto2/libgphoto2.la diff --git a/camlibs/gsmart/README b/camlibs/gsmart/README deleted file mode 100644 index 55f226ab6..000000000 --- a/camlibs/gsmart/README +++ /dev/null @@ -1,58 +0,0 @@ -Mustek gSmart mini - -This driver is based on the windows driver source for the gSmart mini 2 kindly -provided by Mustek. It is known to work with the following camera models: - -Mustek gSmart mini -Mustek gSmart mini 2 -Mustek gSmart mini 3 -So. Show 301 (identical to the mini 3) -Aiptek 1.3 mega PocketCam -Maxell Max Pocket - -If you want to hack on this module, or have questions or suggestions, -don't hesitate to email me: - - Till Adam ---------------------------------------------------------------- -NOTE ----- -The cameras always delete the last file on them, no matter what file number is -passed to it for deletion. It is impossible to delete a specific image or -movie on the camera. - ----------------------------------------------------------------- -TODO ----- -The cameras of this series are based on the spca504a and spca500 chip -manufactured by Sunplus. Both chips are capable of streaming, so there's a -project working on video4linux support for them. spca50x.sourceforge.net - ------------------------------------------------------------------ -Thanks -------- -Special thanks go to Bjorn Borud who extorted the above -mentioned sources for the windows driver from Mustek and to Buster Lee at -Mustek for being helpful and responsive. - -Special thanks also to Tim Sampson , who made the -support for spca500 based cams (such as the gsmart mini) possible by boldly -trying out my untested alpha versions. - -Adam Pribyl helped debugging the lowest resolution -of the gsmart mini and had to put his cam in the fridge (!) several times in -the process. Brave man. ;) - -Michel Xhaard helped add support for the Maxell Max Pocket -with patches and testing. Thanks a lot. - -Very special thanks to Piotr Pawlow for adding avi index -functionality and fixing a few bugs. - -Also thanks to the following people for testing and feedback: - -Torfinn Ingolfsen -Mikael Nilsson -Miah Gregory -Soenke Reimers -Gerd Flaig diff --git a/camlibs/gsmart/gsmart-avi-header.h b/camlibs/gsmart/gsmart-avi-header.h deleted file mode 100644 index ead84338c..000000000 --- a/camlibs/gsmart/gsmart-avi-header.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef __GSMART_AVI_HEADER_H -#define __GSMART_AVI_HEADER_H - -#define GSMART_AVI_FRAME_HEADER_LENGTH 8 -uint8_t GsmartAviFrameHeader[GSMART_AVI_FRAME_HEADER_LENGTH] = { - 0x30, 0x30, 0x64, 0x63, // 00dc - 0x00, 0x00, 0x00, 0x00 // size of frame -}; - -#define GSMART_AVI_HEADER_LENGTH 224 -uint8_t GsmartAviHeader[GSMART_AVI_HEADER_LENGTH] = { - /* -- RIFF HEADER -- */ - 0x52, 0x49, 0x46, 0x46, // 0x00; RIFF - 0x00, 0x00, 0x00, 0x00, // 0x04; number of bytes following - 0x41, 0x56, 0x49, 0x20, // 0x08; AVI - 0x4C, 0x49, 0x53, 0x54, // 0x0c; LIST - 0xC0, 0x00, 0x00, 0x00, // 0x10; length of list in bytes - 0x68, 0x64, 0x72, 0x6C, // 0x14; hdrl - 0x61, 0x76, 0x69, 0x68, // 0x18; avih - 0x38, 0x00, 0x00, 0x00, // 0x1c; number of bytes to follow - 0xb5, 0x8c, 0x01, 0x00, // 0x20; microseconds per frame - 0x00, 0x00, 0x06, 0x00, // 0x24; max bytes per second - 0x00, 0x00, 0x00, 0x00, // 0x28; PaddingGranularity (whatever that might be) - // Other sources call it 'reserved' - 0x10, 0x00, 0x01, 0x00, // 0x2c; flags, WASCAPTUREFILE | HASINDEX - 0x00, 0x00, 0x00, 0x00, // 0x30; total frames - 0x00, 0x00, 0x00, 0x00, // 0x34: initial frames - 0x01, 0x00, 0x00, 0x00, // 0x38: number of streams - 0x00, 0x00, 0x00, 0x00, // 0x3c: suggested buffer size - 0x40, 0x01, 0x00, 0x00, // 0x40: width - 0xf0, 0x00, 0x00, 0x00, // 0x44: height - 0x00, 0x00, 0x00, 0x00, // 0x48: some reserved long values - 0x00, 0x00, 0x00, 0x00, // 0x4c: - 0x00, 0x00, 0x00, 0x00, // 0x50: - 0x00, 0x00, 0x00, 0x00, // 0x54: - /* -- video stream list -- */ - 0x4C, 0x49, 0x53, 0x54, // 0x58: LIST - 0x74, 0x00, 0x00, 0x00, // 0x5c: length of list in bytes - 0x73, 0x74, 0x72, 0x6C, // 0x60: strl - /* -- video stream header -- */ - 0x73, 0x74, 0x72, 0x68, // 0x64: strh - 0x38, 0x00, 0x00, 0x00, // 0x68: # of bytes to follow - 0x76, 0x69, 0x64, 0x73, // 0x6c: vids - 0x4D, 0x4A, 0x50, 0x47, // 0x70: MJPG - 0x00, 0x00, 0x00, 0x00, // 0x74: some more reserved longs - 0x00, 0x00, 0x00, 0x00, // 0x78: - 0x00, 0x00, 0x00, 0x00, // 0x7c: - 0x33, 0x18, 0x00, 0x00, // 0x80: ms_per_frame scale - 0x48, 0xEE, 0x00, 0x00, // 0x84: Rate: Rate/Scale == samples/second - 0x00, 0x00, 0x00, 0x00, // 0x88: start - 0x00, 0x00, 0x00, 0x00, // 0x8c: length (video_frames) - 0x00, 0x00, 0x00, 0x00, // 0x90: suggested buffer size - 0xFF, 0xFF, 0xFF, 0xFF, // 0x94: quality - 0x00, 0x00, 0x00, 0x00, // 0x98: sample size - 0x00, 0x00, 0x00, 0x00, // 0x9c: frame - 0x00, 0x00, 0x00, 0x00, // 0xa0: frame - /* -- video stream format -- */ - 0x73, 0x74, 0x72, 0x66, // 0xa4: strf - 0x28, 0x00, 0x00, 0x00, // 0xa8: number of bytes to follow (40) - 0x28, 0x00, 0x00, 0x00, // 0xac: size (dito) - 0x40, 0x01, 0x00, 0x00, // 0xb0: width - 0xf0, 0x00, 0x00, 0x00, // 0xb4: height - 0x01, 0x00, 0x0C, 0x00, // 0xb8: planes(1) : count(24) - 0x4D, 0x4A, 0x50, 0x47, // 0xbc: encoder MJPG - 0x00, 0xC2, 0x01, 0x00, // 0xc0: Size image - 0x00, 0x00, 0x00, 0x00, // 0xc4: XPelsPerMeter - 0x00, 0x00, 0x00, 0x00, // 0xc8: YPelsPerMeter - 0x00, 0x00, 0x00, 0x00, // 0xcc: Number of colors used - 0x00, 0x00, 0x00, 0x00, // 0xd0: Number of colors important - /* do we have to pad with JUNK here ? */ - 0x4C, 0x49, 0x53, 0x54, // 0xd4: LIST - 0x00, 0x00, 0x00, 0x00, // 0xd8: size of list - 0x6D, 0x6F, 0x76, 0x69 // 0xda: movi -}; - -#endif /* __GSMART_AVI_HEADER_H */ diff --git a/camlibs/gsmart/gsmart-jpeg-header.h b/camlibs/gsmart/gsmart-jpeg-header.h deleted file mode 100644 index 4c091d51c..000000000 --- a/camlibs/gsmart/gsmart-jpeg-header.h +++ /dev/null @@ -1,273 +0,0 @@ -#ifndef __GSMART_JPEG_HEADER_H -#define __GSMART_JPEG_HEADER_H - -/* - * Start from 0 -> 588 - * 7 - 70 : Quantization Table[0] - * 72 - 135 : Quantization Table[1] - */ -#define GSMART_JPG_DEFAULT_HEADER_PART1_LENGTH 136 -#define GSMART_JPG_DEFAULT_HEADER_PART2_LENGTH 420 -#define GSMART_JPG_DEFAULT_HEADER_PART3_LENGTH 33 -#define GSMART_JPG_DEFAULT_HEADER_LENGTH 589 - -uint8_t GsmartJPGDefaultHeaderPart1[GSMART_JPG_DEFAULT_HEADER_PART1_LENGTH] = { - //SOI(Start of Image) - 0xFF,0xD8, - //DQT(Define Quantization Table) - 0xFF,0xDB, - 0x00,0x84, - 0x00, - 0x05,0x03,0x04,0x04,0x04,0x03,0x05,0x04,0x04,0x04,0x06,0x05,0x05,0x06,0x08,0x0D, - 0x08,0x08,0x07,0x07,0x08,0x10,0x0C,0x0C,0x0A,0x0D,0x14,0x11,0x15,0x14,0x13,0x11, - 0x13,0x13,0x16,0x18,0x1F,0x1A,0x16,0x17,0x1E,0x17,0x13,0x13,0x1B,0x25,0x1C,0x1E, - 0x20,0x21,0x23,0x23,0x23,0x15,0x1A,0x27,0x29,0x26,0x22,0x29,0x1F,0x22,0x23,0X22, - 0X01, - 0x05,0x06,0x06,0x08,0x07,0x08,0x10,0x08,0x08,0x10,0x22,0x16,0x13,0x16,0x22,0x22, - 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22, - 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22, - 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22 -}; -uint8_t GsmartJPGDefaultHeaderPart2[GSMART_JPG_DEFAULT_HEADER_PART2_LENGTH] = { - //DHT(Define Huffman Table) - 0xFF,0xC4, - 0x01,0xA2, - 0x00,0x00,0x01,0x05,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x01,0x00,0x03, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01, - 0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x10,0x00,0x02,0x01,0x03,0x03, - 0x02,0x04,0x03,0x05,0x05,0x04,0x04,0x00,0x00,0x01,0x7D,0x01,0x02,0x03,0x00,0x04, - 0x11,0x05,0x12,0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07,0x22,0x71,0x14,0x32,0x81, - 0x91,0xA1,0x08,0x23,0x42,0xB1,0xC1,0x15,0x52,0xD1,0xF0,0x24,0x33,0x62,0x72,0x82, - 0x09,0x0A,0x16,0x17,0x18,0x19,0x1A,0x25,0x26,0x27,0x28,0x29,0x2A,0x34,0x35,0x36, - 0x37,0x38,0x39,0x3A,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x53,0x54,0x55,0x56, - 0x57,0x58,0x59,0x5A,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x73,0x74,0x75,0x76, - 0x77,0x78,0x79,0x7A,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x92,0x93,0x94,0x95, - 0x96,0x97,0x98,0x99,0x9A,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xB2,0xB3, - 0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA, - 0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7, - 0xE8,0xE9,0xEA,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0x11,0x00,0x02, - 0x01,0x02,0x04,0x04,0x03,0x04,0x07,0x05,0x04,0x04,0x00,0x01,0x02,0x77,0x00,0x01, - 0x02,0x03,0x11,0x04,0x05,0x21,0x31,0x06,0x12,0x41,0x51,0x07,0x61,0x71,0x13,0x22, - 0x32,0x81,0x08,0x14,0x42,0x91,0xA1,0xB1,0xC1,0x09,0x23,0x33,0x52,0xF0,0x15,0x62, - 0x72,0xD1,0x0A,0x16,0x24,0x34,0xE1,0x25,0xF1,0x17,0x18,0x19,0x1A,0x26,0x27,0x28, - 0x29,0x2A,0x35,0x36,0x37,0x38,0x39,0x3A,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A, - 0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A, - 0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89, - 0x8A,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7, - 0xA8,0xA9,0xAA,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xC2,0xC3,0xC4,0xC5, - 0xC6,0xC7,0xC8,0xC9,0xCA,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xE2,0xE3, - 0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA -}; -/* - * 5 - 6 : Image Height(H Byte,L Byte) - * 7 - 8 : Image Width(H Byte,L Byte) - */ -uint8_t GsmartJPGDefaultHeaderPart3[GSMART_JPG_DEFAULT_HEADER_PART3_LENGTH] = { - //SOFn(Start of Frame) - 0xFF,0xC0, - 0x00,0x11, - 0x08,0x00,0x78,0x00,0xA0,0x03,0x01,0x21,0x00,0x02,0x11,0x01,0x03,0x11,0x01, - //SOS(Start of Scan) - 0xFF,0xDA, - 0x00,0x0C, - 0x03,0x01,0x00,0x02,0x11,0x03,0x11,0x00,0x3F,0x00 -}; - -uint8_t GsmartQTable[20][64]= -{ - // index 0, Q50 - { 16, 11, 12, 14, 12, 10, 16, 14, 13, 14, 18, 17, 16, 19, 24, 40, - 26, 24, 22, 22, 24, 49, 35, 37, 29, 40, 58, 51, 61, 60, 57, 51, - 56, 55, 64, 72, 92, 78, 64, 68, 87, 69, 55, 56, 80,109, 81, 87, - 95, 98,103,104,103, 62, 77,113,121,112,100,120, 92,101,103, 99 }, - { 17, 18, 18, 24, 21, 24, 47, 26, 26, 47, 99, 66, 56, 66, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99 }, - - // index 1, Q70 - { 10, 7, 7, 8, 7, 6, 10, 8, 8, 8, 11, 10, 10, 11, 14, 24, - 16, 14, 13, 13, 14, 29, 21, 22, 17, 24, 35, 31, 37, 36, 34, 31, - 34, 33, 38, 43, 55, 47, 38, 41, 52, 41, 33, 34, 48, 65, 49, 52, - 57, 59, 62, 62, 62, 37, 46, 68, 73, 67, 60, 72, 55, 61, 62, 59 }, - { 10, 11, 11, 14, 13, 14, 28, 16, 16, 28, 59, 40, 34, 40, 59, 59, - 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, - 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, - 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59 }, - - // index 2, Q80 - { 6, 4, 5, 6, 5, 4, 6, 6, 5, 6, 7, 7, 6, 8, 10, 16, - 10, 10, 9, 9, 10, 20, 14, 15, 12, 16, 23, 20, 24, 24, 23, 20, - 22, 22, 26, 29, 37, 31, 26, 27, 35, 28, 22, 22, 32, 44, 32, 35, - 38, 39, 41, 42, 41, 25, 31, 45, 48, 45, 40, 48, 37, 40, 41, 40 }, - { 7, 7, 7, 10, 8, 10, 19, 10, 10, 19, 40, 26, 22, 26, 40, 40, - 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, - 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, - 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 }, - - // index 3, Q85 - { 5, 3, 4, 4, 4, 3, 5, 4, 4, 4, 5, 5, 5, 6, 7, 12, - 8, 7, 7, 7, 7, 15, 11, 11, 9, 12, 17, 15, 18, 18, 17, 15, - 17, 17, 19, 22, 28, 23, 19, 20, 26, 21, 17, 17, 24, 33, 24, 26, - 29, 29, 31, 31, 31, 19, 23, 34, 36, 34, 30, 36, 28, 30, 31, 30 }, - { 5, 5, 5, 7, 6, 7, 14, 8, 8, 14, 30, 20, 17, 20, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30 }, - - // index 4, Q90 - { 3, 2, 2, 3, 2, 2, 3, 3, 3, 3, 4, 3, 3, 4, 5, 8, - 5, 5, 4, 4, 5, 10, 7, 7, 6, 8, 12, 10, 12, 12, 11, 10, - 11, 11, 13, 14, 18, 16, 13, 14, 17, 14, 11, 11, 16, 22, 16, 17, - 19, 20, 21, 21, 21, 12, 15, 23, 24, 22, 20, 24, 18, 20, 21, 20 }, - { 3, 4, 4, 5, 4, 5, 9, 5, 5, 9, 20, 13, 11, 13, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20 }, - - // index 5, Q60 - { 13, 9, 10, 11, 10, 8, 13, 11, 10, 11, 14, 14, 13, 15, 19, 32, - 21, 19, 18, 18, 19, 39, 28, 30, 23, 32, 46, 41, 49, 48, 46, 41, - 45, 44, 51, 58, 74, 62, 51, 54, 70, 55, 44, 45, 64, 87, 65, 70, - 76, 78, 82, 83, 82, 50, 62, 90, 97, 90, 80, 96, 74, 81, 82, 79 }, - { 14, 14, 14, 19, 17, 19, 38, 21, 21, 38, 79, 53, 45, 53, 79, 79, - 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, - 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, - 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79 }, - - // index 6, Q25 - { 32, 22, 24, 28, 24, 20, 32, 28, 26, 28, 36, 34, 32, 38, 48, 80, - 52, 48, 44, 44, 48, 98, 70, 74, 58, 80,116,102,122,120,114,102, - 112,110,128,144,184,156,128,136,174,138,110,112,160,218,162,174, - 190,196,206,208,206,124,154,226,242,224,200,240,184,202,206,198 }, - { 34, 36, 36, 48, 42, 48, 94, 52, 52, 94,198,132,112,132,198,198, - 198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,198, - 198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,198, - 198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,198 }, - - // index 7, Q95 - { 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 2, 2, 2, 4, - 3, 2, 2, 2, 2, 5, 4, 4, 3, 4, 6, 5, 6, 6, 6, 5, - 6, 6, 6, 7, 9, 8, 6, 7, 9, 7, 6, 6, 8, 11, 8, 9, - 10, 10, 10, 10, 10, 6, 8, 11, 12, 11, 10, 12, 9, 10, 10, 10 }, - { 2, 2, 2, 2, 2, 2, 5, 3, 3, 5, 10, 7, 6, 7, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }, - - // index 8, Q93 - { 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 3, 2, 2, 3, 3, 6, - 4, 3, 3, 3, 3, 7, 5, 5, 4, 6, 8, 7, 9, 8, 8, 7, - 8, 8, 9, 10, 13, 11, 9, 10, 12, 10, 8, 8, 11, 15, 11, 12, - 13, 14, 14, 15, 14, 9, 11, 16, 17, 16, 14, 17, 13, 14, 14, 14 }, - { 2, 3, 3, 3, 3, 3, 7, 4, 4, 7, 14, 9, 8, 9, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 }, - - // index 9, Q40 - { 20, 14, 15, 18, 15, 13, 20, 18, 16, 18, 23, 21, 20, 24, 30, 50, - 33, 30, 28, 28, 30, 61, 44, 46, 36, 50, 73, 64, 76, 75, 71, 64, - 70, 69, 80, 90,115, 98, 80, 85,109, 86, 69, 70,100,136,101,109, - 119,123,129,130,129, 78, 96,141,151,140,125,150,115,126,129,124 }, - { 21, 23, 23, 30, 26, 30, 59, 33, 33, 59,124, 83, 70, 83,124,124, - 124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,124, - 124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,124, - 124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,124 } -}; - -uint8_t GsmartOriginal_QTable_4NF_M[18][64]= //not Z-Z -{ - // index 0, Q50 - { 16, 11, 10, 16, 24, 40, 51, 61, 12, 12, 14, 19, 26, 58, 60, 55, - 14, 13, 16, 24, 40, 57, 69, 56, 14, 17, 22, 29, 51, 87, 80, 62, - 18, 22, 37, 56, 68,109,103, 77, 24, 35, 55, 64, 81,104,113, 92, - 49, 64, 78, 87,103,121,120,101, 72, 92, 95, 98,112,100,103, 99 }, - { 17, 18, 24, 47, 99, 99, 99, 99, 18, 21, 26, 66, 99, 99, 99, 99, - 24, 26, 56, 99, 99, 99, 99, 99, 47, 66, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99 }, - - // index 1, Q70 - { 10, 7, 6, 10, 14, 24, 31, 37, 7, 7, 8, 11, 16, 35, 36, 33, - 8, 8, 10, 14, 24, 34, 41, 34, 8, 10, 13, 17, 31, 52, 48, 37, - 11, 13, 22, 34, 41, 65, 62, 46, 14, 21, 33, 38, 49, 62, 68, 55, - 29, 38, 47, 52, 62, 73, 72, 61, 43, 55, 57, 59, 67, 60, 62, 59 }, - { 10, 11, 14, 28, 59, 59, 59, 59, 11, 13, 16, 40, 59, 59, 59, 59, - 14, 16, 34, 59, 59, 59, 59, 59, 28, 40, 59, 59, 59, 59, 59, 59, - 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, - 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59 }, - - // index 2, Q80 - { 6, 4, 4, 6, 10, 16, 20, 24, 5, 5, 6, 8, 10, 23, 24, 22, - 6, 5, 6, 10, 16, 23, 28, 22, 6, 7, 9, 12, 20, 35, 32, 25, - 7, 9, 15, 22, 27, 44, 41, 31, 10, 14, 22, 26, 32, 42, 45, 37, - 20, 26, 31, 35, 41, 48, 48, 40, 29, 37, 38, 39, 45, 40, 41, 40 }, - { 7, 7, 10, 19, 40, 40, 40, 40, 7, 8, 10, 26, 40, 40, 40, 40, - 10, 10, 22, 40, 40, 40, 40, 40, 19, 26, 40, 40, 40, 40, 40, 40, - 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, - 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 }, - - // index 3, Q85 - { 5, 3, 3, 5, 7, 12, 15, 18, 4, 4, 4, 6, 8, 17, 18, 17, - 4, 4, 5, 7, 12, 17, 21, 17, 4, 5, 7, 9, 15, 26, 24, 19, - 5, 7, 11, 17, 20, 33, 31, 23, 7, 11, 17, 19, 24, 31, 34, 28, - 15, 19, 23, 26, 31, 36, 36, 30, 22, 28, 29, 29, 34, 30, 31, 30 }, - { 5, 5, 7, 14, 30, 30, 30, 30, 5, 6, 8, 20, 30, 30, 30, 30, - 7, 8, 17, 30, 30, 30, 30, 30, 14, 20, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30 }, - - // index 4, Q90 - { 3, 2, 2, 3, 5, 8, 10, 12, 2, 2, 3, 4, 5, 12, 12, 11, - 3, 3, 3, 5, 8, 11, 14, 11, 3, 3, 4, 6, 10, 17, 16, 12, - 4, 4, 7, 11, 14, 22, 21, 15, 5, 7, 11, 13, 16, 21, 23, 18, - 10, 13, 16, 17, 21, 24, 24, 20, 14, 18, 19, 20, 22, 20, 21, 20 }, - { 3, 4, 5, 9, 20, 20, 20, 20, 4, 4, 5, 13, 20, 20, 20, 20, - 5, 5, 11, 20, 20, 20, 20, 20, 9, 13, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20 }, - - // index 5, Q60 - { 13, 9, 8, 13, 19, 32, 41, 49, 10, 10, 11, 15, 21, 46, 48, 44, - 11, 10, 13, 19, 32, 46, 55, 45, 11, 14, 18, 23, 41, 70, 64, 50, - 14, 18, 30, 45, 54, 87, 82, 62, 19, 28, 44, 51, 65, 83, 90, 74, - 39, 51, 62, 70, 82, 97, 96, 81, 58, 74, 76, 78, 90, 80, 82, 79 }, - { 14, 14, 19, 38, 79, 79, 79, 79, 14, 17, 21, 53, 79, 79, 79, 79, - 19, 21, 45, 79, 79, 79, 79, 79, 38, 53, 79, 79, 79, 79, 79, 79, - 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, - 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79 }, - - // index 6, Q25 - { 32, 22, 20, 32, 48, 80,102,122, 24, 24, 28, 38, 52,116,120,110, - 28, 26, 32, 48, 80,114,138,112, 28, 34, 44, 58,102,174,160,124, - 36, 44, 74,112,136,218,206,154, 48, 70,110,128,162,208,226,184, - 98,128,156,174,206,242,240,202,144,184,190,196,224,200,206,198 }, - { 34, 36, 48, 94,198,198,198,198, 36, 42, 52,132,198,198,198,198, - 48, 52,112,198,198,198,198,198, 94,132,198,198,198,198,198,198, - 198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,198, - 198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,198 }, - - // index 7, Q95 - { 2, 1, 1, 2, 2, 4, 5, 6, 1, 1, 1, 2, 3, 6, 6, 6, - 1, 1, 2, 2, 4, 6, 7, 6, 1, 2, 2, 3, 5, 9, 8, 6, - 2, 2, 4, 6, 7, 11, 10, 8, 2, 4, 6, 6, 8, 10, 11, 9, - 5, 6, 8, 9, 10, 12, 12, 10, 7, 9, 10, 10, 11, 10, 10, 10 }, - { 2, 2, 2, 5, 10, 10, 10, 10, 2, 2, 3, 7, 10, 10, 10, 10, - 2, 3, 6, 10, 10, 10, 10, 10, 5, 7, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }, - - // index 8, Q93 - { 2, 2, 1, 2, 3, 6, 7, 9, 2, 2, 2, 3, 4, 8, 8, 8, - 2, 2, 2, 3, 6, 8, 10, 8, 2, 2, 3, 4, 7, 12, 11, 9, - 3, 3, 5, 8, 10, 15, 14, 11, 3, 5, 8, 9, 11, 15, 16, 13, - 7, 9, 11, 12, 14, 17, 17, 14, 10, 13, 13, 14, 16, 14, 14, 14 }, - { 2, 3, 3, 7, 14, 14, 14, 14, 3, 3, 4, 9, 14, 14, 14, 14, - 3, 4, 8, 14, 14, 14, 14, 14, 7, 9, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 } -}; - -#endif /* __GSMART_JPEG_HEADER_H */ diff --git a/camlibs/gsmart/gsmart-registers.h b/camlibs/gsmart/gsmart-registers.h deleted file mode 100644 index 4b1292781..000000000 --- a/camlibs/gsmart/gsmart-registers.h +++ /dev/null @@ -1,84 +0,0 @@ -/****************************************************************/ -/* gsmart-registers.h - Gphoto2 library for the Mustek gSmart */ -/* mini 2 */ -/* */ -/* Copyright © 2002 Till Adam */ -/* */ -/* Author: Till Adam */ -/* */ -/* This library is free software; you can redistribute it */ -/* and/or modify it under the terms of the GNU Library General */ -/* Public License as published by the Free Software Foundation; */ -/* either version 2 of the License, or (at your option) any */ -/* later version. */ -/* */ -/* This library is distributed in the hope that it will be */ -/* useful, but WITHOUT ANY WARRANTY; without even the implied */ -/* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR */ -/* PURPOSE. See the GNU Library General Public License for */ -/* more details. */ -/* */ -/* You should have received a copy of the GNU Library General */ -/* Public License along with this library; if not, write to the */ -/* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */ -/* Boston, MA 02111-1307, USA. */ -/****************************************************************/ - -#ifndef __GSMART_REGISTERS_H__ -#define __GSMART_REGISTERS_H__ - - -/* ---- Register ---- */ -#define GSMART_REG_CamMode 0x2000 -/* ---- CamMode Value ---- */ -typedef enum -{ - GSMART_CamMode_Idle = 0, - GSMART_CamMode_DSC = 1, - GSMART_CamMode_VideoClip = 2, - GSMART_CamMode_PcCamera = 3, - GSMART_CamMode_Upload = 4 -} -GsmartCamMode; - -#define GSMART_REG_PbSrc 0x2301 -/* ---- PbSrc Value ---- */ -#define GSMART_DramUsb 0x13 - -#define GSMART_REG_AutoPbSize 0x2306 - -#define GSMART_REG_DramType 0x2705 - -#define GSMART_REG_ImageType 0x270c - -#define GSMART_REG_SdramSizeL 0x2710 /* Size [7:0] */ -#define GSMART_REG_SdramSizeM 0x2711 /* Size [15:8] */ -#define GSMART_REG_SdramSizeH 0x2712 /* Size [21:16] */ - -#define GSMART_REG_VlcAddressL 0x2713 -#define GSMART_REG_VlcAddressM 0x2714 -#define GSMART_REG_VlcAddressH 0x2715 - -#define GSMART_REG_MemWidthL 0x2720 -#define GSMART_REG_MemWidthH 0x2721 - -#define GSMART_REG_MemHeightL 0x2722 -#define GSMART_REG_MemHeightH 0x2723 - -#define GSMART_REG_Trigger 0x27a1 -/* ---- Trigger bit Value ---- */ -#define GSMART_TrigDramFifo 2 - -#define GSMART_REG_JFIF 0x2884 - -#define GSMART_REG_CompSizeL 0x2887 -#define GSMART_REG_CompSizeM 0x2888 -#define GSMART_REG_CompSizeH 0x2889 - -#define GSMART_REG_I2C_wIndex 0x2a08 -#define GSMART_REG_I2C_wValue 0x2a10 -#define GSMART_REG_I2C_rValue 0x2a30 -#define GSMART_REG_I2C_rStatus 0x2a06 - - -#endif /* __GSMART_REGISTERS_H__ */ diff --git a/camlibs/gsmart/gsmart.c b/camlibs/gsmart/gsmart.c deleted file mode 100644 index fbd3b95d0..000000000 --- a/camlibs/gsmart/gsmart.c +++ /dev/null @@ -1,1020 +0,0 @@ -/****************************************************************/ -/* gsmart.c - Gphoto2 library for the Mustek gSmart mini 2 */ -/* */ -/* Copyright © 2002 Till Adam */ -/* */ -/* Author: Till Adam */ -/* */ -/* This library is free software; you can redistribute it */ -/* and/or modify it under the terms of the GNU Library General */ -/* Public License as published by the Free Software Foundation; */ -/* either version 2 of the License, or (at your option) any */ -/* later version. */ -/* */ -/* This library is distributed in the hope that it will be */ -/* useful, but WITHOUT ANY WARRANTY; without even the implied */ -/* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR */ -/* PURPOSE. See the GNU Library General Public License for */ -/* more details. */ -/* */ -/* You should have received a copy of the GNU Library General */ -/* Public License along with this library; if not, write to the */ -/* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */ -/* Boston, MA 02111-1307, USA. */ -/****************************************************************/ -#include "config.h" - -#include -#include -#include -#include -#include - -#include "gsmart.h" -#include "gsmart-registers.h" -#include "gsmart-jpeg-header.h" -#include "gsmart-avi-header.h" - -#ifdef ENABLE_NLS -# include -# undef _ -# define _(String) dgettext (GETTEXT_PACKAGE, String) -# ifdef gettext_noop -# define N_(String) gettext_noop (String) -# else -# define N_(String) (String) -# endif -#else -# define textdomain(String) (String) -# define gettext(String) (String) -# define dgettext(Domain,Message) (Message) -# define dcgettext(Domain,Message,Type) (Message) -# define bindtextdomain(Domain,Directory) (Domain) -# define _(String) (String) -# define N_(String) (String) -#endif - -#define GP_MODULE "gsmartmini" -static int gsmart_mode_set_idle (CameraPrivateLibrary * lib); -static int gsmart_is_idle (CameraPrivateLibrary * lib); -static int gsmart_mode_set_download (CameraPrivateLibrary * lib); -static int gsmart_download_data (CameraPrivateLibrary * lib, uint32_t start, - unsigned int size, uint8_t * buf); -static int gsmart_get_FATs (CameraPrivateLibrary * lib); -static int gsmart_get_file_count_and_fat_count (CameraPrivateLibrary * lib); -static int yuv2rgb (int y, int u, int v, int *r, int *g, int *b); -static void create_jpeg_from_data (uint8_t * dst, uint8_t * src, int qIndex, - int w, int h, uint8_t format, - int original_size, int *size, - int omit_huffman_table, int omit_escape); -static inline uint8_t *put_dword (uint8_t * ptr, uint32_t value); -static int gsmart_get_avi_thumbnail (CameraPrivateLibrary * lib, - uint8_t ** buf, unsigned int *len, - struct GsmartFile *g_file); -static int gsmart_get_image_thumbnail (CameraPrivateLibrary * lib, - uint8_t ** buf, unsigned int *len, - struct GsmartFile *g_file); -static int gsmart_get_avi (CameraPrivateLibrary * lib, uint8_t ** buf, - unsigned int *len, struct GsmartFile *g_file); -static int gsmart_get_image (CameraPrivateLibrary * lib, uint8_t ** buf, - unsigned int *len, struct GsmartFile *g_file); - -int -gsmart_get_file_count_and_fat_count (CameraPrivateLibrary * lib) -{ - uint8_t theFat504B[256]; - - lib->num_fats = 0; - - if (lib->bridge == GSMART_BRIDGE_SPCA504B) { - while (1) { /* assume dramtype=4 */ - CHECK (gsmart_download_data - (lib, 0x7fff80 - lib->num_fats * 0x80, - FLASH_PAGE_SIZE, theFat504B)); - if (theFat504B[0] == 0xFF) - break; - - if (theFat504B[0] == 0x08 || theFat504B[0] == 0x00) - lib->num_files++; - - lib->num_fats++; - } - } else { - uint8_t lower, upper; - - CHECK (gp_port_usb_msg_write (lib->gpdev, 0x5, 0, 0, NULL, 0)); - sleep (1); - CHECK (gp_port_usb_msg_read - (lib->gpdev, 0, 0, 0xe15, - (uint8_t *) & lib->num_files, 1)); - LE32TOH (lib->num_files); - - /* get fatscount */ - CHECK (gp_port_usb_msg_write - (lib->gpdev, 0x05, 0x0000, 0x0008, NULL, 0)); - - /* The spca500 is a little slower */ - if (lib->bridge == GSMART_BRIDGE_SPCA504A) - sleep (0.1); - else if (lib->bridge == GSMART_BRIDGE_SPCA500) - sleep (1.0); - - CHECK (gp_port_usb_msg_read - (lib->gpdev, 0, 0, 0x0e19, (uint8_t *) & lower, 1)); - CHECK (gp_port_usb_msg_read - (lib->gpdev, 0, 0, 0x0e20, (uint8_t *) & upper, 1)); - - lib->num_fats = ((upper & 0xFF << 8) | (lower & 0xFF)); - LE32TOH (lib->num_fats); - - } - - return (GP_OK); -} - -int -gsmart_delete_file (CameraPrivateLibrary * lib, unsigned int index) -{ - struct GsmartFile *g_file; - uint16_t fat_index; - - CHECK (gsmart_get_file_info (lib, index, &g_file)); - - if (lib->bridge == GSMART_BRIDGE_SPCA500) - fat_index = 0x70FF - g_file->fat_start - 1; - else /* if (lib->bridge == GSMART_BRIDGE_SPCA504A) */ - fat_index = 0xD8000 - g_file->fat_start - 1; - - CHECK (gp_port_usb_msg_write - (lib->gpdev, 0x06, fat_index, 0x0007, NULL, 0)); - sleep (1); - - /* Reread fats the next time it is accessed */ - lib->dirty = 1; - - return GP_OK; -} - -int -gsmart_delete_all (CameraPrivateLibrary * lib) -{ - if (lib->bridge == GSMART_BRIDGE_SPCA504B) { - CHECK (gp_port_usb_msg_write - (lib->gpdev, 0x71, 0x0000, 0x0000, NULL, 0)); - - } else { - CHECK (gp_port_usb_msg_write - (lib->gpdev, 0x02, 0x0000, 0x0005, NULL, 0)); - } - sleep (3); - - /* Reread fats the next time it is accessed */ - lib->dirty = 1; - return GP_OK; -} - -int -gsmart_request_file (CameraPrivateLibrary * lib, uint8_t ** buf, - unsigned int *len, unsigned int number, int *type) -{ - struct GsmartFile *g_file; - - CHECK (gsmart_get_file_info (lib, number, &g_file)); - - *type = g_file->mime_type; - if (g_file->mime_type == GSMART_FILE_TYPE_AVI) - return (gsmart_get_avi (lib, buf, len, g_file)); - else - return (gsmart_get_image (lib, buf, len, g_file)); -} - -int -gsmart_get_image (CameraPrivateLibrary * lib, uint8_t ** buf, - unsigned int *len, struct GsmartFile *g_file) -{ - uint8_t *p, *lp_jpg; - uint8_t qIndex, format; - uint32_t start; - uint8_t *mybuf; - int size, o_size, file_size; - int omit_escape = 0; - - p = g_file->fat; - - /* get the position in memory where the image is */ - start = (p[1] & 0xff) + (p[2] & 0xff) * 0x100; - start *= 128; - - /* decode the image size */ - if (lib->bridge == GSMART_BRIDGE_SPCA504A) { - o_size = size = - (p[13] & 0xff) * 0x10000 + (p[12] & 0xff) * 0x100 + - (p[11] & 0xff); - qIndex = p[7] & 0x07; - } else if (lib->bridge == GSMART_BRIDGE_SPCA504B) { - o_size = size = - (p[13] & 0xff) * 0x10000 + (p[12] & 0xff) * 0x100 + - (p[11] & 0xff); - omit_escape = 1; - qIndex = p[10] & 0x07; - } else { /* if (lib->bridge == GSMART_BRIDGE_SPCA500) */ - o_size = size = (p[5] & 0xff) * 0x100 + (p[6] & 0xff) * 0x10000; - qIndex = p[7] & 0x07; - } - format = 0x21; - - /* align */ - if (size % 64 != 0) - size = ((size / 64) + 1) * 64; - - file_size = size + GSMART_JPG_DEFAULT_HEADER_LENGTH + 1024 * 10; - - /* slurp in the image */ - mybuf = malloc (size); - if (!mybuf) - return GP_ERROR_NO_MEMORY; - - if (lib->bridge == GSMART_BRIDGE_SPCA504A - || lib->bridge == GSMART_BRIDGE_SPCA504B) { - CHECK (gsmart_download_data (lib, start, size, mybuf)); - } else if (lib->bridge == GSMART_BRIDGE_SPCA500) { - /* find the file index on the camera */ - int index; - - index = (g_file->fat - lib->fats) / FLASH_PAGE_SIZE; - gsmart_reset (lib); - /* trigger upload of image at that index */ - CHECK (gp_port_usb_msg_write (lib->gpdev, 0x06, - 0x70FF - index, 0x01, NULL, 0)); - sleep (1); - CHECK (gp_port_read (lib->gpdev, mybuf, size)); - /* the smallest ones are in a different format */ - if ((p[20] & 0xff) == 2) - format = 0x22; - } - /* now build a jpeg */ - lp_jpg = malloc (file_size); - if (!lp_jpg) - return GP_ERROR_NO_MEMORY; - - create_jpeg_from_data (lp_jpg, mybuf, qIndex, g_file->width, - g_file->height, format, o_size, &file_size, - 0, omit_escape); - - free (mybuf); - lp_jpg = realloc (lp_jpg, file_size); - *buf = lp_jpg; - *len = file_size; - - return (GP_OK); -} - -int -gsmart_get_avi (CameraPrivateLibrary * lib, uint8_t ** buf, - unsigned int *len, struct GsmartFile *g_file) -{ - int i, j, length; - int frame_count = 0, frames_per_fat = 0, fn = 0; - int size = 0; - int frame_width, frame_height; - int file_size; - int index_size; - uint32_t frame_size = 0; - uint32_t total_frame_size = 0; - uint32_t start = 0; - uint8_t *p, *mybuf, *avi, *start_of_file, *start_of_frame, *data; - uint8_t qIndex; - uint8_t *avi_index, *avi_index_ptr; - uint8_t index_item[16]; - - /* FIXME */ - if (lib->bridge == GSMART_BRIDGE_SPCA500) - return GP_ERROR_NOT_SUPPORTED; - - p = g_file->fat; - - if (lib->bridge == GSMART_BRIDGE_SPCA504B) - qIndex = p[10] & 0x07; - else - qIndex = p[7] & 0x07; - - avi = mybuf = start_of_file = data = NULL; - - /* get the position in memory where the movie is */ - start = (p[1] & 0xff) + (p[2] & 0xff) * 0x100; - start *= 128; - - /* Frame w and h and qIndex dont change, so just use the values - * of the first frame */ - frame_width = (p[8] & 0xFF) * 16; - frame_height = (p[9] & 0xFF) * 16; - - /* Each movie consists of a number of frames, and can have more than - * one fat page. Iterate over all fat pages for this movie and count - * all frames in all fats. Same for size. */ - for (i = g_file->fat_start; i <= g_file->fat_end; i++) { - frames_per_fat = (p[49] & 0xFF) * 0x100 + (p[48] & 0xFF); - frame_count += frames_per_fat; - size += (p[13] & 0xFF) * 0x10000 + (p[12] & 0xFF) * 0x100 + - (p[11] & 0xFF); - if (frames_per_fat < 60) - break; - p += FLASH_PAGE_SIZE; - } - /* align */ - size = (size + 63) & 0xffffffc0; - - /* mem for index */ - index_size = frame_count * 16; - avi_index_ptr = avi_index = malloc (index_size); - if (!avi_index) - return GP_ERROR_NO_MEMORY; - - /* slurp in the movie */ - mybuf = malloc (size); - if (!mybuf) { - free (avi_index); - return GP_ERROR_NO_MEMORY; - } - - CHECK (gsmart_download_data (lib, start, size, mybuf)); - - /* Now write our data to a file with an avi header */ - file_size = size + GSMART_AVI_HEADER_LENGTH - + (GSMART_JPG_DEFAULT_HEADER_LENGTH * frame_count) - + 8 + index_size /* for index chunk */ - + 1024 * 10 * frame_count; - - avi = malloc (file_size); - if (!avi) - return GP_ERROR_NO_MEMORY; - - start_of_file = avi; - - /* prepare index item */ - put_dword (index_item, 0x63643030); /* 00dc */ - put_dword (index_item + 4, 0x10); // KEYFRAME - - /* copy the header from the template */ - memcpy (avi, GsmartAviHeader, GSMART_AVI_HEADER_LENGTH); - avi += GSMART_AVI_HEADER_LENGTH; - - /* Reset to the first fat */ - p = g_file->fat; - data = mybuf; - - /* Iterate over fats and frames in each fat and build a jpeg for - * each frame. Add the jpeg to the avi and write an index entry. */ - for (i = g_file->fat_start; i <= g_file->fat_end; i++) { - frames_per_fat = ((p[49] & 0xFF) * 0x100 + (p[48] & 0xFF)); - - /* frames per fat might be lying, so double check how - many frames were already processed */ - if (frames_per_fat > 60 || frames_per_fat == 0 - || fn + frames_per_fat > frame_count) - break; - - for (j = 0; j < frames_per_fat; j++) { - frame_size = ((p[52 + j * 3] & 0xFF) * 0x10000) - + ((p[51 + j * 3] & 0xFF) * 0x100) + - (p[50 + j * 3] & 0xFF); - - memcpy (avi, GsmartAviFrameHeader, - GSMART_AVI_FRAME_HEADER_LENGTH); - - avi += GSMART_AVI_FRAME_HEADER_LENGTH; - start_of_frame = avi; - - /* jpeg starts here */ - create_jpeg_from_data (avi, data, qIndex, frame_width, - frame_height, 0x22, frame_size, - &length, 1, 0); - - data += (frame_size + 7) & 0xfffffff8; - avi += length; - /* Make sure the next frame is aligned */ - if ((avi - start_of_frame) % 2 != 0) - avi++; - - /* Now we know the real frame size after escaping and - * adding the EOI marker. Put it in the frame header. */ - frame_size = avi - start_of_frame; - put_dword (start_of_frame - 4, frame_size); - put_dword (index_item + 8, - start_of_frame - start_of_file - - GSMART_AVI_HEADER_LENGTH - 4); - put_dword (index_item + 12, frame_size); - memcpy (avi_index_ptr, index_item, 16); - avi_index_ptr += 16; - fn++; - } - p += FLASH_PAGE_SIZE; - } - total_frame_size = avi - (start_of_file + GSMART_AVI_HEADER_LENGTH - 4); - put_dword (start_of_file + GSMART_AVI_HEADER_LENGTH - 8, - total_frame_size); - - avi = put_dword (avi, 0x31786469); /* idx1 */ - avi = put_dword (avi, index_size); - memcpy (avi, avi_index, index_size); - avi += index_size; - free (avi_index); - put_dword (start_of_file + 0x30, frame_count); - put_dword (start_of_file + 0x8c, frame_count); - - /* And reuse total_frame_size for the file size RIFF marker at offset - * 4 */ - total_frame_size = avi - (start_of_file + 4); - put_dword (start_of_file + 4, total_frame_size); - - free (mybuf); - start_of_file = realloc (start_of_file, avi - start_of_file); - *buf = start_of_file; - *len = avi - start_of_file; - return (GP_OK); -} - -int -gsmart_request_thumbnail (CameraPrivateLibrary * lib, uint8_t ** buf, - unsigned int *len, unsigned int number, int *type) -{ - struct GsmartFile *g_file; - - CHECK (gsmart_get_file_info (lib, number, &g_file)); - - *type = g_file->mime_type; - if (g_file->mime_type == GSMART_FILE_TYPE_AVI) { - return (gsmart_get_avi_thumbnail (lib, buf, len, g_file)); - } else { - - /* the spca500 stores the quality in p[20], the rest of them - * in [p40]. We need to check for the smallest resolution of - * the mini, since resolution does not have thumbnails. - * Download the full image instead. - * Low: 320x240 2 - * Middle: 640x480 0 - * High: 1024x768 (interpolated) 1*/ - if (lib->bridge == GSMART_BRIDGE_SPCA500 - && (g_file->fat[20] & 0xFF) == 2) { - return (gsmart_get_image (lib, buf, len, g_file)); - - } else { - return (gsmart_get_image_thumbnail - (lib, buf, len, g_file)); - } - } -} - - -static int -gsmart_get_avi_thumbnail (CameraPrivateLibrary * lib, uint8_t ** buf, - unsigned int *len, struct GsmartFile *g_file) -{ - uint8_t *p, *lp_jpg; - uint8_t qIndex; - uint32_t start; - uint8_t *mybuf; - int size, o_size, file_size; - int w, h; - - /* FIXME */ - if (lib->bridge == GSMART_BRIDGE_SPCA500 - || lib->bridge == GSMART_BRIDGE_SPCA504B) - return GP_ERROR_NOT_SUPPORTED; - - p = g_file->fat; - - /* get the position in memory where the image is */ - start = (p[1] & 0xff) + (p[2] & 0xff) * 0x100; - start *= 128; - - /* decode the image size */ - o_size = size = - (p[52] & 0xff) * 0x10000 + (p[51] & 0xff) * 0x100 + - (p[50] & 0xff); - qIndex = p[7] & 0x07; - w = (int) ((p[8] & 0xFF) * 16); - h = (int) ((p[9] & 0xFF) * 16); - - /* align */ - if (size % 64 != 0) - size = ((size / 64) + 1) * 64; - - file_size = size + GSMART_JPG_DEFAULT_HEADER_LENGTH + 1024 * 10; - - /* slurp in the image */ - mybuf = malloc (size); - if (!mybuf) - return GP_ERROR_NO_MEMORY; - - CHECK (gsmart_download_data (lib, start, size, mybuf)); - - /* now build a jpeg */ - lp_jpg = malloc (file_size); - if (!lp_jpg) - return GP_ERROR_NO_MEMORY; - - create_jpeg_from_data (lp_jpg, mybuf, qIndex, g_file->width, - g_file->height, 0x22, o_size, &file_size, 0, 0); - free (mybuf); - lp_jpg = realloc (lp_jpg, file_size); - *buf = lp_jpg; - *len = file_size; - - return (GP_OK); -} - - -static int -gsmart_get_image_thumbnail (CameraPrivateLibrary * lib, uint8_t ** buf, - unsigned int *len, struct GsmartFile *g_file) -{ - unsigned int size; - uint8_t *p; - uint32_t start; - uint8_t *mybuf = NULL; - uint8_t *tmp; - unsigned int t_width, t_height; - uint8_t *yuv_p; - uint8_t *rgb_p; - int headerlength; - - p = g_file->fat; - - start = (p[3] & 0xff) + (p[4] & 0xff) * 0x100; - start *= 128; - - size = g_file->width * g_file->height * 2 / 64; - t_width = g_file->width / 8; - t_height = g_file->height / 8; - /* Adjust the headerlenght */ - headerlength = 13; - if (t_width > 99) headerlength++; - if (t_height > 99) headerlength++; - - /* align */ - if (size % 64 != 0) - size = ((size / 64) + 1) * 64; - - mybuf = malloc (size); - - if (lib->bridge == GSMART_BRIDGE_SPCA504A - || lib->bridge == GSMART_BRIDGE_SPCA504B) { - CHECK (gsmart_download_data (lib, start, size, mybuf)); - } else if (lib->bridge == GSMART_BRIDGE_SPCA500) { - /* find the file index on the camera */ - int index; - - index = (g_file->fat - lib->fats) / FLASH_PAGE_SIZE; - gsmart_reset (lib); - /* trigger upload of thumbnail at that index */ - CHECK (gp_port_usb_msg_write (lib->gpdev, 0x06, - 0x70FF - index, 0x09, NULL, 0)); - sleep (1); - CHECK (gp_port_read (lib->gpdev, mybuf, size)); - } - *len = t_width * t_height * 3 + headerlength; - *len += 45; - *buf = malloc (*len); - if (!*buf) - return (GP_ERROR_NO_MEMORY); - - tmp = *buf; - snprintf (tmp, *len, "P6 %d %d 255\n", t_width, t_height); - tmp += headerlength; - - yuv_p = mybuf; - rgb_p = tmp; - while (yuv_p < mybuf + size) { - unsigned int u, v, y, y2; - unsigned int r, g, b; - - y = yuv_p[0]; - y2 = yuv_p[1]; - u = yuv_p[2]; - v = yuv_p[3]; - - CHECK (yuv2rgb (y, u, v, &r, &g, &b)); - *rgb_p++ = r; - *rgb_p++ = g; - *rgb_p++ = b; - - CHECK (yuv2rgb (y2, u, v, &r, &g, &b)); - *rgb_p++ = r; - *rgb_p++ = g; - *rgb_p++ = b; - - yuv_p += 4; - } - - free (mybuf); - return (GP_OK); -} - - -int -gsmart_get_info (CameraPrivateLibrary * lib) -{ - unsigned int index; - uint8_t *p; - uint32_t start_page, end_page; - uint8_t file_type; - - GP_DEBUG ("* gsmart_get_info"); - CHECK (gsmart_get_file_count_and_fat_count (lib)); - if (lib->num_files > 0) { - CHECK (gsmart_get_FATs (lib)); - - index = lib->files[lib->num_files - 1].fat_end; - p = lib->fats + FLASH_PAGE_SIZE * index; - /* p now points to the fat of the last image of the last file */ - - file_type = p[0]; - start_page = ((p[2] & 0xFF) << 8) | (p[1] & 0xFF); - end_page = start_page + (((p[6] & 0xFF) << 8) | (p[5] & 0xFF)); - if (file_type == GSMART_FILE_TYPE_IMAGE) - end_page = end_page + 0xA0; - - lib->size_used = (end_page - 0x2800) * FLASH_PAGE_SIZE; - } else - lib->size_used = 0; - - lib->size_free = - 16 * 1024 * 1024 - 0x2800 * FLASH_PAGE_SIZE - lib->size_used; - lib->dirty = 0; - - return GP_OK; -} - -int -gsmart_get_file_info (CameraPrivateLibrary * lib, unsigned int index, - struct GsmartFile **g_file) -{ - if (lib->dirty) - CHECK (gsmart_get_info (lib)); - *g_file = &(lib->files[index]); - return GP_OK; -} - -int -gsmart_get_firmware_revision (CameraPrivateLibrary * lib) -{ - uint8_t firmware = 0; - - CHECK (gp_port_usb_msg_read (lib->gpdev, 0x20, 0x0, 0x0, &firmware, 1)); - return firmware; -} - -int -gsmart_reset (CameraPrivateLibrary * lib) -{ - GP_DEBUG ("* gsmart_reset"); - if (lib->bridge == GSMART_BRIDGE_SPCA500) { - /* This is not reset but "Change Mode to Idle (Clear Buffer)" - * Cant hurt, I guess. */ - CHECK (gp_port_usb_msg_write - (lib->gpdev, 0x02, 0x0000, 0x07, NULL, 0)); - } else if (lib->bridge == GSMART_BRIDGE_SPCA504A) { - CHECK (gp_port_usb_msg_write - (lib->gpdev, 0x02, 0x0000, 0x0003, NULL, 0)); - } else if (lib->bridge == GSMART_BRIDGE_SPCA504B) { - CHECK (gp_port_usb_msg_write(lib->gpdev, 0, 1, - GSMART_REG_AutoPbSize, NULL, 0)); - CHECK (gp_port_usb_msg_write(lib->gpdev, 0, 0, - 0x0d04, NULL, 0)); - CHECK (gp_port_usb_msg_write(lib->gpdev, 0x1e, 0, 0, NULL, 0)); - } - sleep (1); - return GP_OK; -} - -int -gsmart_capture (CameraPrivateLibrary * lib) -{ - sleep (2); - CHECK (gp_port_usb_msg_write - (lib->gpdev, 0x06, 0x0000, 0x0003, NULL, 0)); - sleep (3); - return GP_OK; -} - -static int -gsmart_mode_set_idle (CameraPrivateLibrary * lib) -{ - CHECK (gp_port_usb_msg_write - (lib->gpdev, 0, GSMART_CamMode_Idle, GSMART_REG_CamMode, NULL, - 0)); - return GP_OK; -} - -static int -gsmart_is_idle (CameraPrivateLibrary * lib) -{ - int mode; - - CHECK (gp_port_usb_msg_read - (lib->gpdev, 0, 0, GSMART_REG_CamMode, (uint8_t *) & mode, 1)); - return mode == GSMART_CamMode_Idle ? 1 : 0; -} - -static int -gsmart_mode_set_download (CameraPrivateLibrary * lib) -{ - CHECK (gp_port_usb_msg_write - (lib->gpdev, 0, GSMART_CamMode_Upload, GSMART_REG_CamMode, NULL, - 0)); - return GP_OK; -} - -static int -gsmart_download_data (CameraPrivateLibrary * lib, uint32_t start, - unsigned int size, uint8_t * buf) -{ - - uint8_t foo; - uint8_t vlcAddressL, vlcAddressM, vlcAddressH; - - if (!gsmart_is_idle (lib)) - gsmart_mode_set_idle (lib); - - gsmart_mode_set_download (lib); - - foo = size & 0xFF; - CHECK (gp_port_usb_msg_write (lib->gpdev, 0, foo, - GSMART_REG_SdramSizeL, NULL, 0)); - foo = (size >> 8) & 0xFF; - CHECK (gp_port_usb_msg_write (lib->gpdev, 0, foo, - GSMART_REG_SdramSizeM, NULL, 0)); - foo = (size >> 16) & 0xFF; - CHECK (gp_port_usb_msg_write (lib->gpdev, 0, foo, - GSMART_REG_SdramSizeH, NULL, 0)); - - CHECK (gp_port_usb_msg_read - (lib->gpdev, 0, 0, GSMART_REG_VlcAddressL, - (uint8_t *) & vlcAddressL, 1)); - CHECK (gp_port_usb_msg_read - (lib->gpdev, 0, 0, GSMART_REG_VlcAddressM, - (uint8_t *) & vlcAddressM, 1)); - CHECK (gp_port_usb_msg_read - (lib->gpdev, 0, 0, GSMART_REG_VlcAddressH, - (uint8_t *) & vlcAddressH, 1)); - - foo = start & 0xFF; - CHECK (gp_port_usb_msg_write - (lib->gpdev, 0, foo, GSMART_REG_VlcAddressL, NULL, 0)); - foo = (start >> 8) & 0xFF; - CHECK (gp_port_usb_msg_write - (lib->gpdev, 0, foo, GSMART_REG_VlcAddressM, NULL, 0)); - foo = (start >> 16) & 0xFF; - CHECK (gp_port_usb_msg_write - (lib->gpdev, 0, foo, GSMART_REG_VlcAddressH, NULL, 0)); - - /* Set mode to ram -> usb */ - CHECK (gp_port_usb_msg_write - (lib->gpdev, 0, GSMART_DramUsb, GSMART_REG_PbSrc, NULL, 0)); - /* and pull the trigger */ - CHECK (gp_port_usb_msg_write - (lib->gpdev, 0, GSMART_TrigDramFifo, GSMART_REG_Trigger, NULL, - 0)); - - CHECK (gp_port_read (lib->gpdev, buf, size)); - - CHECK (gp_port_usb_msg_write - (lib->gpdev, 0, vlcAddressL, GSMART_REG_VlcAddressL, NULL, 0)); - CHECK (gp_port_usb_msg_write - (lib->gpdev, 0, vlcAddressM, GSMART_REG_VlcAddressM, NULL, 0)); - CHECK (gp_port_usb_msg_write - (lib->gpdev, 0, vlcAddressH, GSMART_REG_VlcAddressH, NULL, 0)); - - gsmart_mode_set_idle (lib); - return GP_OK; -} - -static int -gsmart_get_FATs (CameraPrivateLibrary * lib) -{ - uint8_t dramtype, type; - unsigned int index = 0; - unsigned int file_index = 0; - uint8_t *p = NULL; - uint8_t buf[14]; - - /* Reset image and movie counter */ - lib->num_images = lib->num_movies = 0; - - if (lib->fats) { - free (lib->fats); - lib->fats = NULL; - } - - if (lib->files) { - free (lib->files); - lib->files = NULL; - } - - lib->fats = malloc (lib->num_fats * FLASH_PAGE_SIZE); - lib->files = malloc (lib->num_files * sizeof (struct GsmartFile)); - - p = lib->fats; - if (lib->bridge == GSMART_BRIDGE_SPCA504A - || lib->bridge == GSMART_BRIDGE_SPCA504B) { - if (!gsmart_is_idle (lib)) - gsmart_mode_set_idle (lib); - - gsmart_mode_set_download (lib); - - CHECK (gp_port_usb_msg_write - (lib->gpdev, 0x00, 0x0001, GSMART_REG_AutoPbSize, NULL, - 0)); - CHECK (gp_port_usb_msg_read - (lib->gpdev, 0, 0, GSMART_REG_DramType, - (uint8_t *) & dramtype, 1)); - - dramtype &= 0xFF; - - while (index < lib->num_fats) { - switch (dramtype) { - case 4: /* 128 Mbit */ - CHECK (gsmart_download_data - (lib, 0x7fff80 - index * 0x80, - FLASH_PAGE_SIZE, p)); - break; - case 3: /* 64 Mbit */ - CHECK (gsmart_download_data - (lib, 0x3fff80 - index * 0x80, - FLASH_PAGE_SIZE, p)); - break; - default: - break; - } - if (p[0] == 0xFF) - break; - - index++; - p += FLASH_PAGE_SIZE; - } - } else if (lib->bridge == GSMART_BRIDGE_SPCA500) { - /* for the spca500, download the whole fat in one go. */ - gsmart_reset (lib); - CHECK (gp_port_usb_msg_write - (lib->gpdev, 0x05, 0x00, 0x07, NULL, 0)); - sleep (1); - CHECK (gp_port_read - (lib->gpdev, lib->fats, - lib->num_fats * FLASH_PAGE_SIZE)); - } - - p = lib->fats; - index = 0; - - while (index < lib->num_fats) { - - type = p[0]; - /* While the spca504a indicates start of avi as 0x08 and cont. - * of avi as 0x80, the spca500 uses 0x03 for both. Each frame - * gets its own fat table with a sequence number at p[18]. */ - if ((type == 0x80) || (type == 0x03 && (p[18] != 0x00))) { - /* continuation of an avi */ - lib->files[file_index - 1].fat_end = index; - } else { - /* its an image */ - if (type == 0x00 || type == 0x01) { - snprintf (buf, 13, "Image%03d.jpg", - ++lib->num_images); - lib->files[file_index].mime_type = - GSMART_FILE_TYPE_IMAGE; - } else if ((type == 0x08) || (type == 0x03)) { - /* its the start of an avi */ - snprintf (buf, 13, "Movie%03d.avi", - ++lib->num_movies); - lib->files[file_index].mime_type = - GSMART_FILE_TYPE_AVI; - } - lib->files[file_index].fat = p; - lib->files[file_index].fat_start = index; - lib->files[file_index].fat_end = index; - lib->files[file_index].name = strdup (buf); - if (lib->bridge == GSMART_BRIDGE_SPCA504A - || lib->bridge == GSMART_BRIDGE_SPCA504B) { - lib->files[file_index].width = - (p[8] & 0xFF) * 16; - lib->files[file_index].height = - (p[9] & 0xFF) * 16; - } else if (lib->bridge == GSMART_BRIDGE_SPCA500) { - int w, h; - - if (p[20] == 2) { - w = 320; - h = 240; - } else { - w = 640; - h = 480; - } - lib->files[file_index].width = w; - lib->files[file_index].height = h; - } - file_index++; - } - p += FLASH_PAGE_SIZE; - index++; - } - return GP_OK; -} - -static int -yuv2rgb (int y, int u, int v, int *_r, int *_g, int *_b) -{ - double r, g, b; - - r = (char) y + 128 + 1.402 * (char) v; - g = (char) y + 128 - 0.34414 * (char) u - 0.71414 * (char) v; - b = (char) y + 128 + 1.772 * (char) u; - - if (r > 255) - r = 255; - if (g > 255) - g = 255; - if (b > 255) - b = 255; - if (r < 0) - r = 0; - if (g < 0) - g = 0; - if (b < 0) - b = 0; - - *_r = r; - *_g = g; - *_b = b; - - return GP_OK; -} - -static void -create_jpeg_from_data (uint8_t * dst, uint8_t * src, int qIndex, int w, - int h, uint8_t format, int o_size, int *size, - int omit_huffman_table, int omit_escape) -{ - - int i = 0; - uint8_t *start; - uint8_t value; - - start = dst; - /* copy the header from the template */ - memcpy (dst, GsmartJPGDefaultHeaderPart1, - GSMART_JPG_DEFAULT_HEADER_PART1_LENGTH); - - /* modify quantization table */ - memcpy (dst + 7, GsmartQTable[qIndex * 2], 64); - memcpy (dst + 72, GsmartQTable[qIndex * 2 + 1], 64); - - dst += GSMART_JPG_DEFAULT_HEADER_PART1_LENGTH; - - /* copy Huffman table */ - if (!omit_huffman_table) { - memcpy (dst, GsmartJPGDefaultHeaderPart2, - GSMART_JPG_DEFAULT_HEADER_PART2_LENGTH); - dst += GSMART_JPG_DEFAULT_HEADER_PART2_LENGTH; - } - memcpy (dst, GsmartJPGDefaultHeaderPart3, - GSMART_JPG_DEFAULT_HEADER_PART3_LENGTH); - - /* modify the image width, height */ - *(dst + 8) = w & 0xFF; //Image width low byte - *(dst + 7) = w >> 8 & 0xFF; //Image width high byte - *(dst + 6) = h & 0xFF; //Image height low byte - *(dst + 5) = h >> 8 & 0xFF; //Image height high byte - - /* set the format */ - *(dst + 11) = format; - - /* point to real JPG compress data start position and copy */ - dst += GSMART_JPG_DEFAULT_HEADER_PART3_LENGTH; - - for (i = 0; i < o_size; i++) { - value = *(src + i) & 0xFF; - *(dst) = value; - dst++; - - if (value == 0xFF && !omit_escape) { - *(dst) = 0x00; - dst++; - } - } - /* Add end of image marker */ - *(dst++) = 0xFF; - *(dst++) = 0xD9; - - *size = dst - start; -} - -static inline uint8_t * -put_dword (uint8_t * ptr, uint32_t value) -{ - ptr[0] = (value & 0xff); - ptr[1] = (value & 0xff00) >> 8; - ptr[2] = (value & 0xff0000) >> 16; - ptr[3] = (value & 0xff000000) >> 24; - return ptr + 4; -} diff --git a/camlibs/gsmart/gsmart.h b/camlibs/gsmart/gsmart.h deleted file mode 100644 index d78233961..000000000 --- a/camlibs/gsmart/gsmart.h +++ /dev/null @@ -1,83 +0,0 @@ -/****************************************************************/ -/* gsmart.h - Gphoto2 library for the Mustek gSmart mini 2 */ -/* */ -/* Copyright © 2002 Till Adam */ -/* */ -/* Author: Till Adam */ -/* */ -/* This library is free software; you can redistribute it */ -/* and/or modify it under the terms of the GNU Library General */ -/* Public License as published by the Free Software Foundation; */ -/* either version 2 of the License, or (at your option) any */ -/* later version. */ -/* */ -/* This library is distributed in the hope that it will be */ -/* useful, but WITHOUT ANY WARRANTY; without even the implied */ -/* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR */ -/* PURPOSE. See the GNU Library General Public License for */ -/* more details. */ -/* */ -/* You should have received a copy of the GNU Library General */ -/* Public License along with this library; if not, write to the */ -/* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */ -/* Boston, MA 02111-1307, USA. */ -/****************************************************************/ - -#ifndef __GSMART_H__ -#define __GSMART_H__ -#include <_stdint.h> -#include - -#define FLASH_PAGE_SIZE 0x100 -#define GSMART_FILE_TYPE_IMAGE 0x00 -#define GSMART_FILE_TYPE_AVI 0x01 - -#define CHECK(result) {int res; res = result; if (res < 0) return (res);} - -struct GsmartFile -{ - char *name; - int width; - int height; - int fat_start; - int fat_end; - uint8_t *fat; - int mime_type; -}; - -typedef enum { - GSMART_BRIDGE_SPCA500, - GSMART_BRIDGE_SPCA504A, - GSMART_BRIDGE_SPCA504B -} GsmartBridgeChip; - -struct _CameraPrivateLibrary -{ - GPPort *gpdev; - GsmartBridgeChip bridge; - int dirty; - int num_files; - int num_images; - int num_movies; - int num_fats; - int size_used; - int size_free; - uint8_t *fats; - struct GsmartFile *files; -}; - -int gsmart_reset (CameraPrivateLibrary * lib); -int gsmart_capture (CameraPrivateLibrary * lib); -int gsmart_get_info (CameraPrivateLibrary * lib); -int gsmart_delete_file (CameraPrivateLibrary * lib, unsigned int index); -int gsmart_delete_all (CameraPrivateLibrary * lib); -int gsmart_get_file_info (CameraPrivateLibrary * lib, unsigned int index, - struct GsmartFile **file); -int gsmart_get_firmware_revision (CameraPrivateLibrary *lib); -int gsmart_request_file (CameraPrivateLibrary * lib, uint8_t ** buf, - unsigned int *len, unsigned int number, int *type); -int gsmart_request_thumbnail (CameraPrivateLibrary * lib, uint8_t ** buf, - unsigned int *len, unsigned int number, int *type); - - -#endif /* __GSMART_H__ */ diff --git a/camlibs/gsmart/library.c b/camlibs/gsmart/library.c deleted file mode 100644 index d6271d123..000000000 --- a/camlibs/gsmart/library.c +++ /dev/null @@ -1,448 +0,0 @@ -/****************************************************************/ -/* library.c - Gphoto2 library for the Mustek gSmart mini 2 */ -/* */ -/* Copyright © 2002 Till Adam */ -/* */ -/* Author: Till Adam */ -/* */ -/* This library is free software; you can redistribute it */ -/* and/or modify it under the terms of the GNU Library General */ -/* Public License as published by the Free Software Foundation; */ -/* either version 2 of the License, or (at your option) any */ -/* later version. */ -/* */ -/* This library is distributed in the hope that it will be */ -/* useful, but WITHOUT ANY WARRANTY; without even the implied */ -/* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR */ -/* PURPOSE. See the GNU Library General Public License for */ -/* more details. */ -/* */ -/* You should have received a copy of the GNU Library General */ -/* Public License along with this library; if not, write to the */ -/* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */ -/* Boston, MA 02111-1307, USA. */ -/****************************************************************/ - -#include "config.h" - -#include -#include -#include - -#include - -#ifdef ENABLE_NLS -# include -# undef _ -# define _(String) dgettext (GETTEXT_PACKAGE, String) -# ifdef gettext_noop -# define N_(String) gettext_noop (String) -# else -# define N_(String) (String) -# endif -#else -# define _(String) (String) -# define N_(String) (String) -#endif - -#include "gsmart.h" - -#define GP_MODULE "gsmartmini" -#define TIMEOUT 5000 - -#define GSMART_VERSION "0.3" -#define GSMART_LAST_MOD "08/09/02 - 23:14:11" - -/* forward declarations */ -static int file_list_func (CameraFilesystem *fs, const char *folder, - CameraList *list, void *data, GPContext *context); -static int get_file_func (CameraFilesystem *fs, const char *folder, - const char *filename, CameraFileType type, - CameraFile *file, void *user_data, - GPContext *context); - -static int delete_file_func (CameraFilesystem *fs, const char *folder, - const char *filename, void *data, - GPContext *context); -static int delete_all_func (CameraFilesystem *fs, const char *folder, - void *data, GPContext *context); -static int get_info_func (CameraFilesystem *fs, const char *folder, - const char *filename, CameraFileInfo *info, - void *data, GPContext *context); - -/* define what cameras we support */ -static struct -{ - char *model; - int usb_vendor; - int usb_product; - GsmartBridgeChip bridge; -} -models[] = -{ - { - "Mustek:gSmart mini", 0x055f, 0xc220, GSMART_BRIDGE_SPCA500} - , { - "Mustek:gSmart mini 2", 0x055f, 0xc420, GSMART_BRIDGE_SPCA504A} - , { - "Mustek:gSmart mini 3", 0x055f, 0xc520, GSMART_BRIDGE_SPCA504A} - , { - "So.:Show 301", 0x0ec7, 0x1008, GSMART_BRIDGE_SPCA504A} - , { - "Aiptek:1.3 mega PocketCam", 0x04fc, 0x504b, GSMART_BRIDGE_SPCA504B} - , { - "Maxwell:Max Pocket", 0x04fc, 0x504b, GSMART_BRIDGE_SPCA504B} - , { - NULL, 0, 0} -}; - -int -camera_id (CameraText *id) -{ - strcpy (id->text, "gsmartmini"); - return (GP_OK); -} - -int -camera_abilities (CameraAbilitiesList *list) -{ - int x = 0; - char *ptr; - CameraAbilities a; - - ptr = models[x].model; - while (ptr) { - memset (&a, 0, sizeof (a)); - strcpy (a.model, ptr); - a.port = GP_PORT_USB; - a.speed[0] = 0; - - if (models[x].bridge == GSMART_BRIDGE_SPCA504A) { - a.operations = GP_OPERATION_CAPTURE_IMAGE; - a.status = GP_DRIVER_STATUS_TESTING; - } else { - a.status = GP_DRIVER_STATUS_EXPERIMENTAL; - } - a.file_operations = - GP_FILE_OPERATION_PREVIEW | GP_FILE_OPERATION_DELETE; - - a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL; - - a.usb_vendor = models[x].usb_vendor; - a.usb_product = models[x].usb_product; - - gp_abilities_list_append (list, a); - - ptr = models[++x].model; - } - - return (GP_OK); -} - -static int -camera_capture (Camera *camera, CameraCaptureType type, - CameraFilePath * path, GPContext *context) -{ - struct GsmartFile *file; - CameraAbilities a; - - /* Not all our cameras support capture */ - gp_camera_get_abilities (camera, &a); - if (!a.operations & GP_OPERATION_CAPTURE_IMAGE) - return GP_ERROR_NOT_SUPPORTED; - - CHECK (gsmart_capture (camera->pl)); - CHECK (gsmart_get_info (camera->pl)); - CHECK (gsmart_get_file_info - (camera->pl, camera->pl->num_files - 1, &file)); - - /* Now tell the frontend where to look for the image */ - strncpy (path->folder, "/", sizeof (path->folder) - 1); - path->folder[sizeof (path->folder) - 1] = '\0'; - strncpy (path->name, file->name, sizeof (path->name) - 1); - path->name[sizeof (path->name) - 1] = '\0'; - - CHECK (gp_filesystem_append - (camera->fs, path->folder, path->name, context)); - return GP_OK; -} - - -static int -camera_exit (Camera *camera, GPContext *context) -{ - if (camera->pl) { - if (camera->pl->fats) { - free (camera->pl->fats); - camera->pl->fats = NULL; - } - if (camera->pl->files) { - free (camera->pl->files); - camera->pl->files = NULL; - } - - free (camera->pl); - camera->pl = NULL; - } - return (GP_OK); -} - -static int -camera_summary (Camera *camera, CameraText *summary, GPContext *context) -{ - char tmp[1024]; - - /* possibly get # pics, mem free, etc. if needed */ - if (camera->pl->dirty) - CHECK (gsmart_get_info (camera->pl)); - - snprintf (tmp, sizeof (tmp), - "Files: %d\n Images: %4d\n Movies: %4d\nSpace used: %8d\nSpace free: %8d\n", - camera->pl->num_files, camera->pl->num_images, - camera->pl->num_movies, camera->pl->size_used, - camera->pl->size_free); - strcat (summary->text, tmp); - - return (GP_OK); -} - -static int -camera_about (Camera *camera, CameraText *about, GPContext *context) -{ - strcpy (about->text, - _("gsmart library v" GSMART_VERSION - " " GSMART_LAST_MOD "\n" - "Till Adam \n" - "Support for the Mustek gSmart mini series of digital " - "cameras based on several other gphoto2 camlib modules and " - "the windows driver source kindly provided by Mustek.\n" - "\n")); - - return (GP_OK); -} - -int -camera_init (Camera *camera, GPContext *context) -{ - int ret; - int x = 0; - char *model; - - GPPortSettings settings; - CameraAbilities abilities; - - /* First, set up all the function pointers */ - camera->functions->exit = camera_exit; - camera->functions->summary = camera_summary; - camera->functions->about = camera_about; - camera->functions->capture = camera_capture; - - CHECK (gp_port_get_settings (camera->port, &settings)); - switch (camera->port->type) { - case GP_PORT_USB: - settings.usb.inep = 0x82; - settings.usb.outep = 0x03; - settings.usb.config = 1; - settings.usb.interface = 0; - settings.usb.altsetting = 0; - - CHECK (gp_port_set_settings (camera->port, settings)); - CHECK (gp_port_set_timeout (camera->port, TIMEOUT)); - - break; - default: - gp_context_error (context, - _("Unsupported port type: %d. " - "This driver only works with USB " - "cameras.\n"), camera->port->type); - return (GP_ERROR); - break; - } - - camera->pl = malloc (sizeof (CameraPrivateLibrary)); - if (!camera->pl) - return (GP_ERROR_NO_MEMORY); - memset (camera->pl, 0, sizeof (CameraPrivateLibrary)); - camera->pl->gpdev = camera->port; - camera->pl->dirty = 1; - - /* What bridge chip is inside the camera? The Gsmart mini is spca500 - * based, while the others have a spca504a */ - gp_camera_get_abilities (camera, &abilities); - model = models[x].model; - while (model) { - if (!strcmp (model, abilities.model)) { - camera->pl->bridge = models[x].bridge; - break; - } - model = models[++x].model; - } - - ret = gsmart_reset (camera->pl); - - if (ret < 0) { - gp_context_error (context, _("Could not reset camera.\n")); - free (camera->pl); - camera->pl = NULL; - - return (ret); - } - - /* Set up the CameraFilesystem */ - CHECK (gp_filesystem_set_list_funcs - (camera->fs, file_list_func, NULL, camera)); - CHECK (gp_filesystem_set_file_funcs - (camera->fs, get_file_func, delete_file_func, camera)); - CHECK (gp_filesystem_set_info_funcs - (camera->fs, get_info_func, NULL, camera)); - CHECK (gp_filesystem_set_folder_funcs - (camera->fs, NULL, delete_all_func, NULL, NULL, camera)); - - return (GP_OK); -} - - -static int -file_list_func (CameraFilesystem *fs, const char *folder, - CameraList *list, void *data, GPContext *context) -{ - - Camera *camera = data; - int i; - char temp_file[14]; - - if (camera->pl->dirty) - CHECK (gsmart_get_info (camera->pl)); - - for (i = 0; i < camera->pl->num_files; i++) { - strncpy (temp_file, camera->pl->files[i].name, 12); - temp_file[12] = 0; - gp_list_append (list, temp_file, NULL); - } - - return GP_OK; -} - - -static int -get_file_func (CameraFilesystem *fs, const char *folder, - const char *filename, CameraFileType type, - CameraFile *file, void *user_data, GPContext *context) -{ - - Camera *camera = user_data; - unsigned char *data = NULL; - int size, number, filetype; - - CHECK (number = - gp_filesystem_number (camera->fs, folder, filename, context)); - switch (type) { - case GP_FILE_TYPE_NORMAL: - CHECK (gsmart_request_file - (camera->pl, &data, &size, number, &filetype)); - if (filetype == GSMART_FILE_TYPE_IMAGE) { - CHECK (gp_file_set_mime_type - (file, GP_MIME_JPEG)); - } else if (filetype == GSMART_FILE_TYPE_AVI) { - CHECK (gp_file_set_mime_type - (file, GP_MIME_AVI)); - } - break; - case GP_FILE_TYPE_PREVIEW: - CHECK (gsmart_request_thumbnail - (camera->pl, &data, &size, number, &filetype)); - if (filetype == GSMART_FILE_TYPE_IMAGE) { - CHECK (gp_file_set_mime_type - (file, GP_MIME_BMP)); - } else if (filetype == GSMART_FILE_TYPE_AVI) { - CHECK (gp_file_set_mime_type - (file, GP_MIME_JPEG)); - } - - break; - default: - return GP_ERROR_NOT_SUPPORTED; - } - - if (!data) - return GP_ERROR; - - CHECK (gp_file_set_data_and_size (file, data, size)); - CHECK (gp_file_set_name (file, filename)); - - return GP_OK; -} - -static int -get_info_func (CameraFilesystem *fs, const char *folder, - const char *filename, CameraFileInfo *info, void *data, - GPContext *context) -{ - Camera *camera = data; - int n; - struct GsmartFile *file; - - /* Get the file number from the CameraFileSystem */ - CHECK (n = - gp_filesystem_number (camera->fs, folder, filename, context)); - - CHECK (gsmart_get_file_info (camera->pl, n, &file)); - - info->file.fields = - GP_FILE_INFO_NAME | GP_FILE_INFO_TYPE | GP_FILE_INFO_WIDTH | - GP_FILE_INFO_HEIGHT; - strncpy (info->file.name, filename, sizeof (info->file.name)); - if (file->mime_type == GSMART_FILE_TYPE_IMAGE) { - strcpy (info->file.type, GP_MIME_JPEG); - info->preview.width = 160; - info->preview.height = 120; - } else if (file->mime_type == GSMART_FILE_TYPE_AVI) { - strcpy (info->file.type, GP_MIME_AVI); - info->preview.width = 320; - info->preview.height = 240; - } - info->file.width = file->width; - info->file.height = file->height; - - info->preview.fields = - GP_FILE_INFO_TYPE | GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT; - strcpy (info->preview.type, GP_MIME_BMP); - - return (GP_OK); -} - -static int -delete_file_func (CameraFilesystem *fs, const char *folder, - const char *filename, void *data, GPContext *context) -{ - Camera *camera = data; - int n, c; - - /* Get the file number from the CameraFileSystem */ - CHECK (n = - gp_filesystem_number (camera->fs, folder, filename, context)); - CHECK (c = gp_filesystem_count (camera->fs, folder, context)); - if (n + 1 != c) { - const char *name; - - gp_filesystem_name (fs, "/", c - 1, &name, context); - gp_context_error (context, - _ - ("Your camera does only support deleting the " - "last file on the camera. In this case, this " - "is file '%s'."), name); - return (GP_ERROR); - } - CHECK (gsmart_delete_file (camera->pl, n)); - return GP_OK; -} - -static int -delete_all_func (CameraFilesystem *fs, const char *folder, void *data, - GPContext *context) -{ - Camera *camera = data; - - CHECK (gsmart_delete_all (camera->pl)); - return GP_OK; -} diff --git a/camlibs/spca504_flash/.cvsignore b/camlibs/spca504_flash/.cvsignore deleted file mode 100644 index b0ff7a469..000000000 --- a/camlibs/spca504_flash/.cvsignore +++ /dev/null @@ -1,10 +0,0 @@ -*~ .*~ -*.lo -*.la -.libs -.deps -Makefile -Makefile.in -*.patch -protocol.xml -crw diff --git a/camlibs/spca504_flash/ChangeLog b/camlibs/spca504_flash/ChangeLog deleted file mode 100644 index 930463d1f..000000000 --- a/camlibs/spca504_flash/ChangeLog +++ /dev/null @@ -1,20 +0,0 @@ -Fre Jan 24 11:47:04 2003 Till Adam - * apply patch by Mark Zimmermann - fixing thumbnails for low res images - -Fri Jan 24 08:15:59 2003 Till Adam - * apply patch by Mark Zimmermann - fixing reporting of preview height - -2002-11-26 Colin Marquardt - - * library.c (camera_about): Make sure author names are 7bit ASCII only. - -Son Nov 10 21:19:16 2002 Till Adam - * import into gphoto cvs - -Sam Nov 02 20:09:06 2002 Till Adam - * implement -n, -L and -P - -Fri Oct 25 17:32:26 2002 Till Adam - * start of camlib diff --git a/camlibs/spca504_flash/Makefile.am b/camlibs/spca504_flash/Makefile.am deleted file mode 100644 index a1b741e2f..000000000 --- a/camlibs/spca504_flash/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -camlib_LTLIBRARIES = libgphoto2_spca504_flash.la - -INCLUDES = \ - -I$(top_srcdir)/intl \ - -I$(top_srcdir)/libgphoto2_port/libgphoto2_port \ - -I$(top_srcdir)/libgphoto2 \ - -I$(top_builddir)/libgphoto2 - -libgphoto2_spca504_flash_la_SOURCES = spca504_flash.c \ - spca504_flash.h library.c -libgphoto2_spca504_flash_la_LDFLAGS = -module -avoid-version -libgphoto2_spca504_flash_la_LIBADD = $(top_builddir)/libgphoto2/libgphoto2.la diff --git a/camlibs/spca504_flash/README b/camlibs/spca504_flash/README deleted file mode 100644 index 26ab895e7..000000000 --- a/camlibs/spca504_flash/README +++ /dev/null @@ -1,24 +0,0 @@ -This camlib supports the following cameras: - -Aiptek Pencam -Medion MD 5319 (Aldi-Cam) -nisis Quickpix Qp3 - -There are probably others with this chip and flash storage which we dont know -about. They should also work. - -It owes everything to the work of Mark Zimmermann whose -pencamread tool I have simply ported to a gphoto2 camlib. The macam driver by -Matthias Krauß was also helpfull. All features are theirs, all bugs are mine. - -I dont own a camera of this type, so I had to rely on Armin Janssen - to tirelessly produce usb snoops, test and give feedback. -Without Armin this would not have been possible, so if you own a camera that -is supported by this driver consider sending him an email and thanking him for -risking his cam so yours works on linux ;). - -Thanks also to Martyn Ranyard for testing and reporting -success with the nisis Quickpix Qp3. He also helped debug the beginnings of -avi support. - -Till Adam diff --git a/camlibs/spca504_flash/library.c b/camlibs/spca504_flash/library.c deleted file mode 100644 index 4102f8dc6..000000000 --- a/camlibs/spca504_flash/library.c +++ /dev/null @@ -1,264 +0,0 @@ -/****************************************************************/ -/* library.c - Gphoto2 library for cameras with a sunplus */ -/* spca504 chip and flash memory */ -/* */ -/* */ -/* Authors: Till Adam */ -/* */ -/* based on work done by: */ -/* Mark A. Zimmerman */ -/* */ -/* This library is free software; you can redistribute it */ -/* and/or modify it under the terms of the GNU Library General */ -/* Public License as published by the Free Software Foundation; */ -/* either version 2 of the License, or (at your option) any */ -/* later version. */ -/* */ -/* This library is distributed in the hope that it will be */ -/* useful, but WITHOUT ANY WARRANTY; without even the implied */ -/* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR */ -/* PURPOSE. See the GNU Library General Public License for */ -/* more details. */ -/* */ -/* You should have received a copy of the GNU Library General */ -/* Public License along with this library; if not, write to the */ -/* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */ -/* Boston, MA 02111-1307, USA. */ -/****************************************************************/ - -#include "config.h" - -#include "spca504_flash.h" - -#include -#include -#include - -#include -#include - -#define GP_MODULE "spca504_flash" - -#ifdef ENABLE_NLS -# include -# undef _ -# define _(String) dgettext (GETTEXT_PACKAGE, String) -# ifdef gettext_noop -# define N_(String) gettext_noop (String) -# else -# define N_(String) (String) -# endif -#else -# define _(String) (String) -# define N_(String) (String) -#endif - -struct models -{ - char *name; - unsigned short idVendor; - unsigned short idProduct; - char serial; -} -models[] = -{ - {"Aiptek:Pencam", 0x04fc, 0x504a, 0}, - {"Medion:MD 5319", 0x04fc, 0x504a, 0}, - {"nisis:Quickpix Qp3", 0x04fc, 0x504a, 0}, - {"Trust:Spyc@m 500F FLASH", 0x04fc, 0x504a, 0} - , { - NULL, 0, 0, 0} -}; - -int -camera_id (CameraText *id) -{ - strcpy (id->text, "spca504_flash"); - return (GP_OK); -} - -int -camera_abilities (CameraAbilitiesList *list) -{ - int i; - CameraAbilities a; - - for (i = 0; models[i].name; i++) { - memset (&a, 0, sizeof (CameraAbilities)); - strcpy (a.model, models[i].name); - a.status = GP_DRIVER_STATUS_EXPERIMENTAL; - a.port = GP_PORT_USB; - a.speed[0] = 0; - a.usb_vendor = models[i].idVendor; - a.usb_product = models[i].idProduct; - a.operations = GP_OPERATION_NONE; - a.folder_operations = GP_FOLDER_OPERATION_NONE; - a.file_operations = GP_FILE_OPERATION_PREVIEW; - gp_abilities_list_append (list, a); - } - return GP_OK; -} - -static int -camera_exit (Camera *camera, GPContext *context) -{ - int ret; - - ret = spca504_flash_close (camera->port, context); - return ret; -} - -static int -file_list_func (CameraFilesystem *fs, const char *folder, - CameraList *list, void *data, GPContext *context) -{ - - Camera *camera = data; - int i = 0, filecount = 0; - char temp_file[14]; - - CHECK (spca504_flash_get_TOC(camera->pl, &filecount)); - for (i=0; ipl, i, temp_file)); - gp_list_append (list, temp_file, NULL); - } - - return GP_OK; -} - - -static int -get_file_func (CameraFilesystem *fs, const char *folder, - const char *filename, CameraFileType type, - CameraFile *file, void *user_data, GPContext *context) -{ - Camera *camera = user_data; - unsigned char *data = NULL; - int size, number; - - CHECK (number = - gp_filesystem_number (camera->fs, folder, filename, context)); - switch (type) { - case GP_FILE_TYPE_NORMAL: - CHECK (spca504_flash_get_file (camera->pl, context, - &data, &size, number, 0)); - break; - case GP_FILE_TYPE_PREVIEW: - CHECK (spca504_flash_get_file (camera->pl, context, - &data, &size, number, 1)); - CHECK (gp_file_set_mime_type (file, GP_MIME_BMP)); - break; - default: - return GP_ERROR_NOT_SUPPORTED; - } - - if (!data) - return GP_ERROR; - - CHECK (gp_file_set_data_and_size (file, data, size)); - CHECK (gp_file_set_name (file, filename)); - - return GP_OK; -} - -static int -camera_summary (Camera *camera, CameraText *summary, GPContext *context) -{ - return GP_ERROR_NOT_SUPPORTED; -} - -static int -camera_manual (Camera *camera, CameraText *manual, GPContext *context) -{ - strcpy (manual->text, _("Manual Not Implemented Yet")); - return GP_OK; -} - -static int -camera_about (Camera *camera, CameraText *about, GPContext *context) -{ - /* Translators: please translate "Krauss" to "Krauß" if possible. */ - strcpy (about->text, - _ - ("spca504_flash camlib\n Authors: Till Adam\n \nbased on work by Matthias Krauss\nand Mark A. Zimmerman ")); - return GP_OK; -} -static int -get_info_func (CameraFilesystem *fs, const char *folder, const char *filename, - CameraFileInfo *info, void *data, GPContext *context) -{ - Camera *camera = data; - int n, filecount; - int w, h; - char name[14]; - - /* Get the file number from the CameraFileSystem */ - CHECK (n = - gp_filesystem_number (camera->fs, folder, filename, context)); - - CHECK (spca504_flash_get_TOC(camera->pl, &filecount)); - CHECK (spca504_flash_get_file_name(camera->pl, n, name)); - CHECK (spca504_flash_get_file_dimensions(camera->pl, n, &w, &h)); - - info->file.fields = - GP_FILE_INFO_NAME | GP_FILE_INFO_TYPE | GP_FILE_INFO_WIDTH | - GP_FILE_INFO_HEIGHT; - strncpy (info->file.name, name, sizeof (info->file.name)); - strcpy (info->file.type, GP_MIME_JPEG); - info->file.width = w; - info->file.height = h; - - info->preview.fields = - GP_FILE_INFO_TYPE | GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT; - info->preview.width = w/8; - info->preview.height = h/8; - strcpy (info->preview.type, GP_MIME_BMP); - return GP_OK; -} - - -int -camera_init (Camera *camera, GPContext *context) -{ - GPPortSettings settings; - int ret = 0; - - camera->functions->exit = camera_exit; - camera->functions->summary = camera_summary; - camera->functions->manual = camera_manual; - camera->functions->about = camera_about; - switch (camera->port->type) { - case GP_PORT_USB: - ret = gp_port_get_settings (camera->port, &settings); - if (ret < 0) - return ret; - settings.usb.inep = 0x82; - settings.usb.outep = 0x03; - settings.usb.config = 1; - settings.usb.interface = 1; - settings.usb.altsetting = 0; - ret = gp_port_set_settings (camera->port, settings); - if (ret < 0) - return ret; - break; - case GP_PORT_SERIAL: - return GP_ERROR_IO_SUPPORTED_SERIAL; - default: - return GP_ERROR_NOT_SUPPORTED; - } - CHECK (spca504_flash_init (camera->port, context)); - - camera->pl = malloc (sizeof (CameraPrivateLibrary)); - if (!camera->pl) - return (GP_ERROR_NO_MEMORY); - - memset (camera->pl, 0, sizeof (CameraPrivateLibrary)); - camera->pl->gpdev = camera->port; - camera->pl->dirty = 1; - - gp_filesystem_set_info_funcs (camera->fs, get_info_func, NULL, camera); - gp_filesystem_set_list_funcs (camera->fs, file_list_func, NULL, camera); - gp_filesystem_set_file_funcs (camera->fs, get_file_func, NULL, camera); - return GP_OK; -} diff --git a/camlibs/spca504_flash/spca504_flash.c b/camlibs/spca504_flash/spca504_flash.c deleted file mode 100644 index e7a224f08..000000000 --- a/camlibs/spca504_flash/spca504_flash.c +++ /dev/null @@ -1,407 +0,0 @@ -/****************************************************************/ -/* spca504_flash.c - Gphoto2 library for cameras with a sunplus */ -/* spca504 chip and flash memory */ -/* */ -/* */ -/* Authors: Till Adam */ -/* */ -/* based on work done by: */ -/* Mark A. Zimmerman */ -/* */ -/* This library is free software; you can redistribute it */ -/* and/or modify it under the terms of the GNU Library General */ -/* Public License as published by the Free Software Foundation; */ -/* either version 2 of the License, or (at your option) any */ -/* later version. */ -/* */ -/* This library is distributed in the hope that it will be */ -/* useful, but WITHOUT ANY WARRANTY; without even the implied */ -/* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR */ -/* PURPOSE. See the GNU Library General Public License for */ -/* more details. */ -/* */ -/* You should have received a copy of the GNU Library General */ -/* Public License along with this library; if not, write to the */ -/* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */ -/* Boston, MA 02111-1307, USA. */ -/****************************************************************/ -#include "config.h" -#include -#include -#include -#include <_stdint.h> -#include "spca504_flash.h" - -#include -#include -#include - -#define GP_MODULE "spca504_flash" - -static int yuv2rgb (int y, int u, int v, int *_r, int *_g, int *_b); - -static int -spca504_flash_wait_for_ready(GPPort *port) -{ - /* FIXME tweak this. What is reasonable? 30 s seems a bit long */ - int timeout = 30; - uint8_t ready = 0; - while (timeout--) { - sleep(1); - CHECK (gp_port_usb_msg_read (port, 0x0b, 0x0000, 0x0004, - (char*)&ready, 0x01)); - if (ready) - return GP_OK; - } - return GP_ERROR; -} - -int -spca504_flash_get_TOC(CameraPrivateLibrary *pl, int *filecount) -{ - uint16_t n_toc_entries; - int toc_size = 0; - - if (!pl->dirty) - return GP_OK; - CHECK (gp_port_usb_msg_read (pl->gpdev, 0x0b, 0x0000, 0x0000, - (char*)&n_toc_entries, 0x02)); - /* Each file gets two toc entries, one for the image, one for the - * thumbnail */ - *filecount = n_toc_entries/2; - - /* If empty, return now */ - if (n_toc_entries == 0) - return GP_OK; - - /* Request the TOC */ - CHECK (gp_port_usb_msg_read (pl->gpdev, 0x0a, n_toc_entries, 0x000c, - NULL, 0x00)); - - /* slurp it in. Supposedly there's 32 bytes in each entry. */ - toc_size = n_toc_entries * 32; - /* align */ - if (toc_size % 512 != 0) - toc_size = ((toc_size / 512) + 1) * 512; - - if (pl->toc) - free (pl->toc); - pl->toc = malloc(toc_size); - if (!pl->toc) - return GP_ERROR_NO_MEMORY; - CHECK (spca504_flash_wait_for_ready(pl->gpdev)); - CHECK (gp_port_read (pl->gpdev, pl->toc, toc_size)); - - pl->dirty = 0; - return GP_OK; -} - - -int -spca504_flash_get_filecount (GPPort *port, int *filecount) -{ - uint16_t response = 0; - CHECK (gp_port_usb_msg_read (port, 0x0b, 0x0000, 0x0000, - (char*)&response, 0x02)); - /* Each file gets two toc entries, one for the image, one for the - * thumbnail */ - *filecount = response/2; - return GP_OK; -} - -int -spca504_flash_get_file_name (CameraPrivateLibrary *lib, int index, char *name) -{ - uint8_t *p; - - p = lib->toc + index*2*32; - memcpy (name, p, 8); - name[8] = '.'; - memcpy (name+9, p+8, 3); - name[12] = '\0'; - return GP_OK; -} - -int -spca504_flash_get_file_dimensions (CameraPrivateLibrary *lib, int index, int *w, int *h) -{ - uint8_t *p; - - p = lib->toc + index*2*32; - *w = (p[0x0c] & 0xff) + (p[0x0d] & 0xff) * 0x100; - *h = (p[0x0e] & 0xff) + (p[0x0f] & 0xff) * 0x100; - return GP_OK; -} - -int -spca504_flash_get_file_size (CameraPrivateLibrary *lib, int index, int *size) -{ - uint8_t *p; - - p = lib->toc + index*2*32; - *size = (p[0x1c] & 0xff) - + (p[0x1d] & 0xff) * 0x100 - + (p[0x1e] & 0xff) * 0x10000 - + (p[0x1f] & 0xff) * 0x1000000; - - return GP_OK; -} - -int -spca504_flash_get_file (CameraPrivateLibrary *lib, GPContext *context, - uint8_t ** data, unsigned int *len, int index, int thumbnail) -{ - uint32_t file_size = 0, aligned_size = 0; - uint32_t addr = 0; - uint8_t *p, *buf; - uint8_t *tmp, *rgb_p, *yuv_p; - - if (thumbnail) { - p = lib->toc + (index*2+1) * 32; - } else { - p = lib->toc + index*2*32; - } - - aligned_size = file_size = - (p[0x1c] & 0xff) - + (p[0x1d] & 0xff) * 0x100 - + (p[0x1e] & 0xff) * 0x10000; - - addr = (p[0x18] & 0xff) - + (p[0x19] & 0xff) * 0x100 - + (p[0x1a] & 0xff) * 0x10000 - + (p[0x1b] & 0xff) * 0x1000000; - - /* Trigger download of image data */ - if (thumbnail) { - CHECK (gp_port_usb_msg_write (lib->gpdev, - 0x0c, index+1, 0x0006, NULL, 0x00)); - } else { - CHECK (gp_port_usb_msg_write (lib->gpdev, - 0x0a, index+1, 0x000d, NULL, 0x00)); - } - /* align */ - if (file_size % 16384 != 0) - aligned_size = ((file_size / 16384) + 1) * 16384; - - buf = malloc (aligned_size); - if (!buf) - return GP_ERROR_NO_MEMORY; - - CHECK (spca504_flash_wait_for_ready(lib->gpdev)); - CHECK (gp_port_read (lib->gpdev, buf, aligned_size)); - /* For images, we are done now, thumbnails need to be converted from - * yuv to rgb and a pbm header added. */ - if (thumbnail) { - int alloc_size, true_size, w, h, hdrlen; - uint8_t *p2 = lib->toc + index*2*32; - - /* thumbnails are generated from dc coefficients and are - * therefor w/8 x h/8 - * Since the dimensions of the thumbnail in the TOC are - * always [0,0], Use the TOC entry for the full image. - */ - w = ((p2[0x0c] & 0xff) + (p2[0x0d] & 0xff) * 0x100) / 8; - h = ((p2[0x0e] & 0xff) + (p2[0x0f] & 0xff) * 0x100) / 8; - - /* Allow for a long header; get the true length later. - */ - hdrlen = 15; - alloc_size = w * h * 3 + hdrlen; - tmp = malloc (alloc_size); - if (!tmp) - return GP_ERROR_NO_MEMORY; - - /* Write the header and get its length. Then, verify that - * we allocated enough memory. - * This should never fail; it would be nice to have an error - * code like GP_ERROR_CAMLIB_INTERNAL for cases like this. - */ - hdrlen = snprintf(tmp, alloc_size, "P6 %d %d 255\n", w, h); - true_size = w * h * 3 + hdrlen; - if ( true_size > alloc_size ) - return GP_ERROR; - - yuv_p = buf; - rgb_p = tmp + hdrlen; - while (yuv_p < buf + file_size) { - unsigned int u, v, y, y2; - unsigned int r, g, b; - - y = yuv_p[0]; - y2 = yuv_p[1]; - u = yuv_p[2]; - v = yuv_p[3]; - - CHECK (yuv2rgb (y, u, v, &r, &g, &b)); - *rgb_p++ = r; - *rgb_p++ = g; - *rgb_p++ = b; - - CHECK (yuv2rgb (y2, u, v, &r, &g, &b)); - *rgb_p++ = r; - *rgb_p++ = g; - *rgb_p++ = b; - - yuv_p += 4; - } - free (buf); - *data = tmp; - *len = true_size; - } else { - *data = buf; - *len = file_size; - } - return GP_OK; -} - - -/* - * Deinit camera - */ -int -spca504_flash_close (GPPort *port, GPContext *context) -{ - CHECK (gp_port_usb_msg_write (port, 0x00, 0x01, 0x2306, NULL, 0x00)); - CHECK (gp_port_usb_msg_write (port, 0x00, 0x00, 0x0d04, NULL, 0x00)); - return GP_OK; -} - -/* - * Initialize the camera and write the jpeg registers. Read them back in to - * check whether the values are set correctly (wtf?) - */ -int -spca504_flash_init (GPPort *port, GPContext *context) -{ - struct JPREG { - int reg; - int val; - }; - struct JPREG jpReg[] = { - { 0x2800, 0x0005 }, { 0x2840, 0x0005 }, - { 0x2801, 0x0003 }, { 0x2841, 0x0005 }, - { 0x2802, 0x0003 }, { 0x2842, 0x0007 }, - { 0x2803, 0x0005 }, { 0x2843, 0x000e }, - { 0x2804, 0x0007 }, { 0x2844, 0x001e }, - { 0x2805, 0x000c }, { 0x2845, 0x001e }, - { 0x2806, 0x000f }, { 0x2846, 0x001e }, - { 0x2807, 0x0012 }, { 0x2847, 0x001e }, - { 0x2808, 0x0004 }, { 0x2848, 0x0005 }, - { 0x2809, 0x0004 }, { 0x2849, 0x0006 }, - { 0x280a, 0x0004 }, { 0x284a, 0x0008 }, - { 0x280b, 0x0006 }, { 0x284b, 0x0014 }, - { 0x280c, 0x0008 }, { 0x284c, 0x001e }, - { 0x280d, 0x0011 }, { 0x284d, 0x001e }, - { 0x280e, 0x0012 }, { 0x284e, 0x001e }, - { 0x280f, 0x0011 }, { 0x284f, 0x001e }, - { 0x2810, 0x0004 }, { 0x2850, 0x0007 }, - { 0x2811, 0x0004 }, { 0x2851, 0x0008 }, - { 0x2812, 0x0005 }, { 0x2852, 0x0011 }, - { 0x2813, 0x0007 }, { 0x2853, 0x001e }, - { 0x2814, 0x000c }, { 0x2854, 0x001e }, - { 0x2815, 0x0011 }, { 0x2855, 0x001e }, - { 0x2816, 0x0015 }, { 0x2856, 0x001e }, - { 0x2817, 0x0011 }, { 0x2857, 0x001e }, - { 0x2818, 0x0004 }, { 0x2858, 0x000e }, - { 0x2819, 0x0005 }, { 0x2859, 0x0014 }, - { 0x281a, 0x0007 }, { 0x285a, 0x001e }, - { 0x281b, 0x0009 }, { 0x285b, 0x001e }, - { 0x281c, 0x000f }, { 0x285c, 0x001e }, - { 0x281d, 0x001a }, { 0x285d, 0x001e }, - { 0x281e, 0x0018 }, { 0x285e, 0x001e }, - { 0x281f, 0x0013 }, { 0x285f, 0x001e }, - { 0x2820, 0x0005 }, { 0x2860, 0x001e }, - { 0x2821, 0x0007 }, { 0x2861, 0x001e }, - { 0x2822, 0x000b }, { 0x2862, 0x001e }, - { 0x2823, 0x0011 }, { 0x2863, 0x001e }, - { 0x2824, 0x0014 }, { 0x2864, 0x001e }, - { 0x2825, 0x0021 }, { 0x2865, 0x001e }, - { 0x2826, 0x001f }, { 0x2866, 0x001e }, - { 0x2827, 0x0017 }, { 0x2867, 0x001e }, - { 0x2828, 0x0007 }, { 0x2868, 0x001e }, - { 0x2829, 0x000b }, { 0x2869, 0x001e }, - { 0x282a, 0x0011 }, { 0x286a, 0x001e }, - { 0x282b, 0x0013 }, { 0x286b, 0x001e }, - { 0x282c, 0x0018 }, { 0x286c, 0x001e }, - { 0x282d, 0x001f }, { 0x286d, 0x001e }, - { 0x282e, 0x0022 }, { 0x286e, 0x001e }, - { 0x282f, 0x001c }, { 0x286f, 0x001e }, - { 0x2830, 0x000f }, { 0x2870, 0x001e }, - { 0x2831, 0x0013 }, { 0x2871, 0x001e }, - { 0x2832, 0x0017 }, { 0x2872, 0x001e }, - { 0x2833, 0x001a }, { 0x2873, 0x001e }, - { 0x2834, 0x001f }, { 0x2874, 0x001e }, - { 0x2835, 0x0024 }, { 0x2875, 0x001e }, - { 0x2836, 0x0024 }, { 0x2876, 0x001e }, - { 0x2837, 0x001e }, { 0x2877, 0x001e }, - { 0x2838, 0x0016 }, { 0x2878, 0x001e }, - { 0x2839, 0x001c }, { 0x2879, 0x001e }, - { 0x283a, 0x001d }, { 0x287a, 0x001e }, - { 0x283b, 0x001d }, { 0x287b, 0x001e }, - { 0x283c, 0x0022 }, { 0x287c, 0x001e }, - { 0x283d, 0x001e }, { 0x287d, 0x001e }, - { 0x283e, 0x001f }, { 0x287e, 0x001e }, - { 0x283f, 0x001e }, { 0x287f, 0x001e } - }; - - int len = sizeof (jpReg) / sizeof (jpReg[0]); - uint8_t bytes[4]; - int i; - - CHECK (gp_port_usb_msg_write (port, 0x00, 0x0000, 0x2000, NULL, 0x00)); - CHECK (gp_port_usb_msg_write (port, 0x00, 0x0013, 0x2301, NULL, 0x00)); - CHECK (gp_port_usb_msg_write (port, 0x00, 0x0001, 0x2883, NULL, 0x00)); - - for (i=0 ; i 255) - r = 255; - if (g > 255) - g = 255; - if (b > 255) - b = 255; - if (r < 0) - r = 0; - if (g < 0) - g = 0; - if (b < 0) - b = 0; - - *_r = r; - *_g = g; - *_b = b; - - return GP_OK; -} diff --git a/camlibs/spca504_flash/spca504_flash.h b/camlibs/spca504_flash/spca504_flash.h deleted file mode 100644 index 828d6accb..000000000 --- a/camlibs/spca504_flash/spca504_flash.h +++ /dev/null @@ -1,47 +0,0 @@ -/* spca504_flash.h - * - * This library is free software; you can redistribute and/or - * modify it inder the terms of the GNU Lesser Genreral Public - * License as publiced by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warrenty of - * MERCHANTABULITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * lesser General Public License for more details. - * - * Author: Till Adam - * based on work by: Mark A. Zimmerman - */ - -#ifndef __SPCA504_FLASH_H__ -#define __SPCA504_FLASH_H__ - -#include <_stdint.h> -#include -#include - -#define CHECK(result) {int res; res = result; if (res < 0) return (res);} - -struct _CameraPrivateLibrary -{ - GPPort *gpdev; - uint8_t *toc; - int dirty :1; -}; - - - -int spca504_flash_init(GPPort *port, GPContext *context); -int spca504_flash_close(GPPort *port, GPContext *context); - -int spca504_flash_get_TOC(CameraPrivateLibrary *pl, int *filecount); -int spca504_flash_get_file_name(CameraPrivateLibrary *pl, int index, char *name); -int spca504_flash_get_file_dimensions(CameraPrivateLibrary *pl, int index, - int *w, int *h); -int spca504_flash_get_file (CameraPrivateLibrary *lib, GPContext *context, - uint8_t **buf, unsigned int *len, int index, int thumbnail); -int spca504_flash_get_file_size(CameraPrivateLibrary *pl, int index, int *size); -int spca504_flash_get_filecount(GPPort *port, int *filecount); -#endif -