Initial revision of SMaL Ultra-Pocket camera driver by Lee Benfield
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@6088 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
11
camlibs/smal/ChangeLog
Normal file
11
camlibs/smal/ChangeLog
Normal file
@@ -0,0 +1,11 @@
|
||||
2003-01-06 Lee Benfield <lee@benf.org>
|
||||
|
||||
Version 0.01
|
||||
|
||||
2003-01-13 LB
|
||||
|
||||
Version 0.02
|
||||
|
||||
- Added support for different header types in returned image as observed
|
||||
by Vasileios Zografos, on @xia (different faceplate from mine).
|
||||
|
||||
10
camlibs/smal/Makefile.am
Normal file
10
camlibs/smal/Makefile.am
Normal file
@@ -0,0 +1,10 @@
|
||||
camlibdir = $(libdir)/gphoto2/$(VERSION)
|
||||
camlib_LTLIBRARIES = libgphoto2_smal.la
|
||||
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir)/libgphoto2_port/libgphoto2_port \
|
||||
-I$(top_srcdir)/libgphoto2
|
||||
|
||||
libgphoto2_smal_la_SOURCES = smal.c ultrapocket.c smal.h ultrapocket.h
|
||||
libgphoto2_smal_la_LDFLAGS = -module -avoid-version
|
||||
libgphoto2_smal_la_LIBADD = $(top_builddir)/libgphoto2/libgphoto2.la
|
||||
31
camlibs/smal/README
Normal file
31
camlibs/smal/README
Normal file
@@ -0,0 +1,31 @@
|
||||
Smal Ultrapocket
|
||||
(fuji @xia slimshot)
|
||||
___________________________________________________________________
|
||||
|
||||
This driver is based on packet sniffs of protocol observed under
|
||||
Windows 2000, and is known to be incomplete. Minimal functionality
|
||||
is implemented as of the Experimental version.
|
||||
|
||||
RAW images as retrieved from the camera require a not insignificant
|
||||
amount of post processing. Enabling #DO_GAMMA in ultrapocket.h
|
||||
helps, but more work is required.
|
||||
___________________________________________________________________
|
||||
|
||||
The author takes no responsibility for damage to your camera from
|
||||
using this driver. Use at your own risk.
|
||||
___________________________________________________________________
|
||||
|
||||
TODO:
|
||||
|
||||
- Battery status
|
||||
- Firmware information
|
||||
- Current resolution information
|
||||
- Determine what (if anything) the camera passes as image
|
||||
modification parameters (Gamma, etc).
|
||||
___________________________________________________________________
|
||||
|
||||
Author: Lee Benfield (lee@benf.org)
|
||||
Thanks: Vasileios Zografos, Dave Scott
|
||||
|
||||
This code borrows heavily from the sipix web2 driver available with
|
||||
gphoto. Thanks, guys ;)
|
||||
184
camlibs/smal/smal.c
Normal file
184
camlibs/smal/smal.c
Normal file
@@ -0,0 +1,184 @@
|
||||
/* smal.c
|
||||
*
|
||||
* Copyright (C) 2003 Lee Benfield <lee@benf.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gphoto2-library.h>
|
||||
#include <gphoto2-result.h>
|
||||
#include <bayer.h>
|
||||
#include <gamma.h>
|
||||
|
||||
#include "ultrapocket.h"
|
||||
#include "smal.h"
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# undef _
|
||||
# define _(String) dgettext (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
|
||||
|
||||
int
|
||||
camera_id (CameraText *id)
|
||||
{
|
||||
strcpy(id->text, "Smal:Ultrapocket");
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int
|
||||
camera_abilities (CameraAbilitiesList *list)
|
||||
{
|
||||
CameraAbilities a;
|
||||
|
||||
memset(&a, 0, sizeof(a));
|
||||
strcpy(a.model, "Smal:Ultrapocket");
|
||||
a.status = GP_DRIVER_STATUS_EXPERIMENTAL; /* highly! */
|
||||
a.port = GP_PORT_USB;
|
||||
a.speed[0] = 0;
|
||||
a.usb_vendor = USB_VENDOR_ID_SMAL;
|
||||
a.usb_product = USB_DEVICE_ID_ULTRAPOCKET;
|
||||
a.operations = GP_OPERATION_NONE;
|
||||
a.file_operations = GP_FILE_OPERATION_DELETE;
|
||||
a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL;
|
||||
gp_abilities_list_append(list, a);
|
||||
/* fuji @xia slimshot is just a rebranded SmAL Ultrapocket */
|
||||
/* LB: 01/03 - not quite - it's got a different header */
|
||||
strcpy(a.model, "Fuji:Slimshot");
|
||||
gp_abilities_list_append(list, a);
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
static int
|
||||
camera_exit (Camera *camera, GPContext *context)
|
||||
{
|
||||
return ultrapocket_exit(camera->port, context);
|
||||
}
|
||||
|
||||
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;
|
||||
int size,image_no,result;
|
||||
unsigned char *data;
|
||||
|
||||
image_no = gp_filesystem_number(fs, folder, filename, context);
|
||||
if (image_no < GP_OK)
|
||||
return image_no;
|
||||
|
||||
gp_file_set_name (file, filename);
|
||||
|
||||
switch (type) {
|
||||
case GP_FILE_TYPE_NORMAL:
|
||||
result = ultrapocket_getpicture(camera->port,context,&data,&size,filename);
|
||||
gp_file_set_mime_type (file, GP_MIME_PPM);
|
||||
break;
|
||||
case GP_FILE_TYPE_RAW:
|
||||
#if 0
|
||||
return GP_ERROR;
|
||||
result = ultrapocket_getpicture(camera->port,context,file);
|
||||
gp_file_set_mime_type (file, GP_MIME_RAW);
|
||||
break;
|
||||
#endif
|
||||
case GP_FILE_TYPE_PREVIEW:
|
||||
default:
|
||||
return (GP_ERROR_NOT_SUPPORTED);
|
||||
}
|
||||
if (result < 0)
|
||||
return result;
|
||||
|
||||
CHECK_RESULT(gp_file_set_data_and_size (file, data, size));
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
static int
|
||||
delete_file_func (CameraFilesystem *fs, const char *folder,
|
||||
const char *filename, void *data, GPContext *context)
|
||||
{
|
||||
Camera *camera = data;
|
||||
int image_no;
|
||||
|
||||
image_no = gp_filesystem_number(fs, folder, filename, context);
|
||||
if (image_no < GP_OK)
|
||||
return image_no;
|
||||
|
||||
CHECK_RESULT(ultrapocket_deletefile(camera->port, filename));
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
static int
|
||||
delete_all_func (CameraFilesystem *fs, const char* folder, void *data,
|
||||
GPContext *context)
|
||||
{
|
||||
Camera *camera = data;
|
||||
if (strcmp (folder, "/"))
|
||||
return (GP_ERROR_DIRECTORY_NOT_FOUND);
|
||||
return ultrapocket_deleteall(&camera->port);
|
||||
}
|
||||
|
||||
static int
|
||||
camera_about (Camera *camera, CameraText *about, GPContext *context)
|
||||
{
|
||||
strcpy (about->text, _("Smal Ultrapocket\n"
|
||||
"Lee Benfield <lee@benf.org>\n"
|
||||
"Driver for accessing the Smal Ultrapocket camera, and OEM versions (slimshot)"));
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
static int
|
||||
file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
|
||||
void *data, GPContext *context)
|
||||
{
|
||||
Camera *camera = data;
|
||||
int count, result;
|
||||
|
||||
result = ultrapocket_getpicsoverview(&camera->port, context, &count, list);
|
||||
if (result != GP_OK)
|
||||
return result;
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int
|
||||
camera_init (Camera *camera, GPContext *context)
|
||||
{
|
||||
camera->functions->exit = camera_exit;
|
||||
camera->functions->about = camera_about;
|
||||
gp_filesystem_set_list_funcs (camera->fs, file_list_func,NULL, camera);
|
||||
gp_filesystem_set_file_funcs (camera->fs, get_file_func,delete_file_func, camera);
|
||||
gp_filesystem_set_folder_funcs (camera->fs,NULL,delete_all_func, NULL,NULL,camera);
|
||||
|
||||
/* don't need to do any exciting init stuff until we get pic numbers */
|
||||
return GP_OK;
|
||||
}
|
||||
27
camlibs/smal/smal.h
Normal file
27
camlibs/smal/smal.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/* smal.h
|
||||
*
|
||||
* Copyright (C) 2003 Lee Benfield <lee@benf.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser 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 __SMAL_H__
|
||||
|
||||
#define __SMAL_H__ 1
|
||||
|
||||
#define USB_VENDOR_ID_SMAL 0x0dca
|
||||
#define USB_DEVICE_ID_ULTRAPOCKET 0x0002
|
||||
|
||||
#endif
|
||||
352
camlibs/smal/ultrapocket.c
Normal file
352
camlibs/smal/ultrapocket.c
Normal file
@@ -0,0 +1,352 @@
|
||||
/* ultrapocket.c
|
||||
*
|
||||
* Copyright (C) 2003 Lee Benfield <lee@benf.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gphoto2-port-log.h>
|
||||
#include <gphoto2-library.h>
|
||||
#include <gphoto2-result.h>
|
||||
#include <bayer.h>
|
||||
#include <gamma.h>
|
||||
|
||||
#include "ultrapocket.h"
|
||||
#include "smal.h"
|
||||
|
||||
#define GP_MODULE "Smal Ultrapocket"
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# undef _
|
||||
# define _(String) dgettext (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
|
||||
|
||||
static int
|
||||
ultrapocket_command(GPPort *port, int iswrite, unsigned char *data, int datasize) {
|
||||
int ret;
|
||||
if (iswrite)
|
||||
ret = gp_port_write(port,data,datasize);
|
||||
else
|
||||
ret = gp_port_read(port,data,datasize);
|
||||
|
||||
if (ret>=GP_OK)
|
||||
ret=GP_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
ultrapocket_exit(GPPort *port, GPContext *context) {
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
int
|
||||
ultrapocket_getpicture(GPPort *port, GPContext *context, unsigned char **pdata, int *size, const char *filename)
|
||||
{
|
||||
unsigned char command[0x10] = { 0x11, 0x01, 0x00, 0x49, 0x4d, 0x47, 0,0,0,0, 0x2e, 0x52, 0x41, 0x57, 0x00, 0x00 };
|
||||
char ppmheader[100];
|
||||
unsigned char retdata[0x1000];
|
||||
unsigned char header[42];
|
||||
unsigned char *rawdata,*outdata;
|
||||
int width, height, outsize, result, imgstart;
|
||||
smal_img_type styp;
|
||||
int ptc,pc,pmmhdr_len, id;
|
||||
#if DO_GAMMA
|
||||
unsigned char gtable[256];
|
||||
#endif
|
||||
|
||||
memcpy(command+6, filename+3, 4); /* the id of the image to transfer */
|
||||
|
||||
CHECK_RESULT(ultrapocket_command(port, 1, command, 0x10));
|
||||
|
||||
/* the first packet has the header in it, plus the start of the data */
|
||||
CHECK_RESULT(ultrapocket_command(port, 0, retdata, 0x1000));
|
||||
memcpy(header, retdata, 41);
|
||||
styp = header[3];
|
||||
|
||||
switch (styp) {
|
||||
case TYPE_QVGA:
|
||||
/* 24 packets, including one already got */
|
||||
ptc = 24;
|
||||
width = 320;
|
||||
height = 240;
|
||||
imgstart = 0x29;
|
||||
break;
|
||||
case TYPE_VGA:
|
||||
/* 80 including one already got. */
|
||||
ptc = 80;
|
||||
width = 640;
|
||||
height = 480;
|
||||
imgstart = 0x29;
|
||||
break;
|
||||
case TYPE_QVGA_BH:
|
||||
ptc = 24;
|
||||
width = 320;
|
||||
height = 240;
|
||||
imgstart = 0x100;
|
||||
break;
|
||||
case TYPE_VGA_BH:
|
||||
ptc = 80;
|
||||
width = 640;
|
||||
height = 480;
|
||||
imgstart = 0x100;
|
||||
break;
|
||||
default:
|
||||
return GP_ERROR;
|
||||
}
|
||||
rawdata = malloc(0x1000 * ptc * sizeof(char));
|
||||
if (!rawdata) return (GP_ERROR_NO_MEMORY);
|
||||
|
||||
/* show how far we've got on the current image */
|
||||
id = gp_context_progress_start(context, ptc-1, _("Downloading image..."));
|
||||
|
||||
memcpy(rawdata, retdata, 0x1000 * sizeof(char));
|
||||
for (pc=1;pc<ptc;pc++) {
|
||||
CHECK_RESULT(ultrapocket_command(port, 0, retdata, 0x1000));
|
||||
gp_context_progress_update(context, id, pc);
|
||||
memcpy(rawdata + (pc * 0x1000), retdata, 0x1000 * sizeof(char));
|
||||
}
|
||||
gp_context_progress_stop(context, id);
|
||||
|
||||
sprintf (ppmheader, "P6\n"
|
||||
"# CREATOR: gphoto2, ultrapocket library\n"
|
||||
"%d %d\n"
|
||||
"255\n", width, height);
|
||||
|
||||
/* Allocate memory for Interpolated ppm image */
|
||||
pmmhdr_len = strlen(ppmheader);
|
||||
outsize = (width+4) * height * 3 + pmmhdr_len + 1;
|
||||
outdata = malloc(outsize);
|
||||
if (!outdata)
|
||||
return (GP_ERROR_NO_MEMORY);
|
||||
|
||||
/* Set header */
|
||||
strcpy(outdata, ppmheader);
|
||||
|
||||
/* Decode and interpolate the Bayer Mask */
|
||||
result = gp_bayer_decode((rawdata+imgstart), width+4, height,
|
||||
&outdata[pmmhdr_len], 2 );
|
||||
|
||||
/* and chop the spare 4 pixels off the RHS */
|
||||
for (pc=1;pc<height;pc++) {
|
||||
memmove(outdata + pmmhdr_len + (width * 3 * pc), outdata + pmmhdr_len + ((width+4) * 3 * pc), width*3);
|
||||
}
|
||||
/* modify outsize to refect trim */
|
||||
outsize = width * height * 3 + pmmhdr_len + 1;
|
||||
|
||||
free(rawdata);
|
||||
if (result < 0) {
|
||||
free (outdata);
|
||||
return (result);
|
||||
}
|
||||
|
||||
#if DO_GAMMA
|
||||
gp_gamma_fill_table( gtable, 0.5 );
|
||||
gp_gamma_correct_single( gtable, &outdata[pmmhdr_len], height * width );
|
||||
#endif
|
||||
|
||||
*pdata = outdata;
|
||||
*size = outsize;
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
ultrapocket_reset(GPPort **pport)
|
||||
{
|
||||
GPPortInfo oldpi;
|
||||
GPPort *port = *pport;
|
||||
unsigned char cmdbuf[0x10];
|
||||
GP_DEBUG ("First connect since camera was used - need to reset cam");
|
||||
|
||||
/*
|
||||
* this resets the ultrapocket. Messy, but it's what the windows
|
||||
* software does. We only reset if it's been plugged in since
|
||||
* last reset.
|
||||
*/
|
||||
memset(cmdbuf, 0, 16);
|
||||
cmdbuf[0] = 0x28;
|
||||
cmdbuf[1] = 0x01;
|
||||
CHECK_RESULT(ultrapocket_command(port, 1, cmdbuf, 0x10));
|
||||
//--------------
|
||||
sleep(2); /* This should do - _might_ need increasing */
|
||||
CHECK_RESULT(gp_port_get_info(port, &oldpi));
|
||||
CHECK_RESULT(gp_port_free(port));
|
||||
CHECK_RESULT(gp_port_new(&port));
|
||||
CHECK_RESULT(gp_port_set_info(port, oldpi));
|
||||
CHECK_RESULT(gp_port_usb_find_device (port, USB_VENDOR_ID_SMAL, USB_DEVICE_ID_ULTRAPOCKET));
|
||||
CHECK_RESULT(gp_port_open(port));
|
||||
*pport = port;
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
int
|
||||
ultrapocket_getpicsoverview(
|
||||
GPPort **pport, GPContext *context,
|
||||
int *numpics, CameraList *list
|
||||
) {
|
||||
GPPort *port = *pport;
|
||||
unsigned char command[0x10];
|
||||
unsigned char retbuf[0x1000];
|
||||
int x,y;
|
||||
int np = 0;
|
||||
char fn[20];
|
||||
int picid;
|
||||
int reset_needed;
|
||||
|
||||
memset(command, 0, 16);
|
||||
command[0] = 0x12;
|
||||
|
||||
CHECK_RESULT(ultrapocket_command(port, 1, command, 0x10));
|
||||
|
||||
CHECK_RESULT(ultrapocket_command(port, 0, retbuf, 0x1000));
|
||||
np = *(unsigned char*)(retbuf + 0x104);
|
||||
for (y=0;y<np;y++) {
|
||||
picid = retbuf[0x106+y*2] + (retbuf[0x107+y*2] << 8);
|
||||
sprintf(fn, "IMG%4.4d.PPM",picid);
|
||||
gp_list_append(list, fn, NULL);
|
||||
}
|
||||
reset_needed = (*(retbuf + 2) & UP_FLAG_NEEDS_RESET);
|
||||
for (x=0;x<7;x++) CHECK_RESULT(ultrapocket_command(port, 0, retbuf, 0x1000));
|
||||
|
||||
/* Who knows what's in all these packets? ... only SmAL! */
|
||||
/* The windows driver gets all of this guff - since the camera functions just fine
|
||||
* without them, I'm going to ignore it for now
|
||||
*/
|
||||
#if COPY_WINDOWS_DRIVER
|
||||
//--------------
|
||||
memset(command, 0, 16);
|
||||
command[0] = 0x31;
|
||||
command[1] = 0x01;
|
||||
CHECK_RESULT(ultrapocket_command(port, 1, command, 0x10));
|
||||
for (x=0;x<8;x++) { CHECK_RESULT(ultrapocket_command(port, 0, retbuf, 0x1000));}
|
||||
//--------------
|
||||
memset(command, 0, 16);
|
||||
command[0] = 0x12;
|
||||
CHECK_RESULT(ultrapocket_command(port, 1, command, 0x10));
|
||||
for (x=0;x<8;x++) { CHECK_RESULT(ultrapocket_command(port, 0, retbuf, 0x1000));}
|
||||
//--------------
|
||||
memset(command, 0, 16);
|
||||
command[0] = 0x31;
|
||||
command[1] = 0x01;
|
||||
CHECK_RESULT(ultrapocket_command(port, 1, command, 0x10));
|
||||
for (x=0;x<8;x++) { CHECK_RESULT(ultrapocket_command(port, 0, retbuf, 0x1000));}
|
||||
//--------------
|
||||
memset(command, 0, 16);
|
||||
command[0] = 0x30;
|
||||
command[1] = 0x01;
|
||||
CHECK_RESULT(ultrapocket_command(port, 1, command, 0x10));
|
||||
for (x=0;x<16;x++) { CHECK_RESULT(ultrapocket_command(port, 0, retbuf, 0x1000));}
|
||||
//--------------
|
||||
memset(command, 0, 16);
|
||||
command[0] = 0x29;
|
||||
command[1] = 0x01;
|
||||
CHECK_RESULT(ultrapocket_command(port, 1, command, 0x10));
|
||||
for (x=0;x<8;x++) { CHECK_RESULT(ultrapocket_command(port, 0, retbuf, 0x1000));}
|
||||
//--------------
|
||||
#endif
|
||||
|
||||
if (reset_needed) {
|
||||
CHECK_RESULT(ultrapocket_reset(pport));
|
||||
port = *pport;
|
||||
}
|
||||
|
||||
#if COPY_WINDOWS_DRIVER
|
||||
memset(command, 0, 16);
|
||||
command[0] = 0x12;
|
||||
CHECK_RESULT(ultrapocket_command(port, 1, command, 0x10));
|
||||
for (x=0;x<8;x++) { CHECK_RESULT(ultrapocket_command(port, 0, retbuf, 0x1000));}
|
||||
//--------------
|
||||
memset(command, 0, 16);
|
||||
command[0] = 0x31;
|
||||
command[1] = 0x01;
|
||||
CHECK_RESULT(ultrapocket_command(port, 1, command, 0x10));
|
||||
for (x=0;x<8;x++) { CHECK_RESULT(ultrapocket_command(port, 0, retbuf, 0x1000));}
|
||||
//--------------
|
||||
memset(command, 0, 16);
|
||||
command[0] = 0x12;
|
||||
CHECK_RESULT(ultrapocket_command(port, 1, command, 0x10));
|
||||
for (x=0;x<8;x++) { CHECK_RESULT(ultrapocket_command(port, 0, retbuf, 0x1000));}
|
||||
//--------------
|
||||
memset(command, 0, 16);
|
||||
command[0] = 0x31;
|
||||
command[1] = 0x01;
|
||||
CHECK_RESULT(ultrapocket_command(port, 1, command, 0x10));
|
||||
for (x=0;x<8;x++) { CHECK_RESULT(ultrapocket_command(port, 0, retbuf, 0x1000));}
|
||||
//--------------
|
||||
#endif
|
||||
|
||||
*numpics = np;
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
/* The windows software doesn't allow one to delete a file without deleting previous
|
||||
* ones.
|
||||
*
|
||||
* Careful!
|
||||
*/
|
||||
int
|
||||
ultrapocket_deletefile(GPPort *port, const char *filename)
|
||||
{
|
||||
unsigned char command[0x10] = { 0x22, 0x01, 0x00, 0x49, 0x4d, 0x47, 0,0,0,0, 0x2e, 0x52, 0x41, 0x57, 0x00, 0x00 };
|
||||
memcpy(command+6, filename+3, 4); /* the id of the image to delete */
|
||||
|
||||
CHECK_RESULT(ultrapocket_command(port, 1, command, 0x10));
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
int
|
||||
ultrapocket_deleteall(GPPort **pport)
|
||||
{
|
||||
unsigned char command[0x10];
|
||||
unsigned char retbuf[0x1000];
|
||||
int x,reset_needed = 0;
|
||||
GPPort *port = *pport;
|
||||
|
||||
memset(command, 0, 16);
|
||||
command[0] = 0x12;
|
||||
|
||||
CHECK_RESULT(ultrapocket_command(port, 1, command, 0x10));
|
||||
|
||||
CHECK_RESULT(ultrapocket_command(port, 0, retbuf, 0x1000));
|
||||
reset_needed = (*(retbuf + 2) & UP_FLAG_NEEDS_RESET);
|
||||
for (x=0;x<7;x++) CHECK_RESULT(ultrapocket_command(port, 0, retbuf, 0x1000));
|
||||
|
||||
if (reset_needed) {
|
||||
CHECK_RESULT(ultrapocket_reset(pport));
|
||||
port = *pport;
|
||||
}
|
||||
|
||||
memset(command, 0, 0x10);
|
||||
command[0] = 0x18;
|
||||
command[1] = 0x01;
|
||||
CHECK_RESULT(ultrapocket_command(port, 1, command, 0x10));
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
56
camlibs/smal/ultrapocket.h
Normal file
56
camlibs/smal/ultrapocket.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* ultrapocket.h
|
||||
*
|
||||
* Copyright (C) 2003 Lee Benfield <lee@benf.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser 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 __ULTRAPOCKET_H__
|
||||
|
||||
#define __ULTRAPOCKET_H__ 1
|
||||
|
||||
#include <gphoto2-library.h>
|
||||
#include <gphoto2-result.h>
|
||||
|
||||
#ifndef CHECK_RESULT
|
||||
#define CHECK_RESULT(result) {int r = (result); if (r < 0) return (r);}
|
||||
#endif
|
||||
|
||||
#define UP_FLAG_NEEDS_RESET 0x80
|
||||
|
||||
/* The windows driver downloads a bunch of info from the camera the use of
|
||||
* which I can't see. Unless you want it, don't get it.
|
||||
*/
|
||||
#define COPY_WINDOWS_DRIVER 0
|
||||
/* The windows software does a _lot_ of touching up of the images.
|
||||
* For now, until I figure out what that involves, just do a bit of gamma
|
||||
* correction
|
||||
*/
|
||||
#define DO_GAMMA 0
|
||||
|
||||
typedef enum ultrapocket_IMG_TYPE {
|
||||
TYPE_QVGA = 0,
|
||||
TYPE_VGA = 1,
|
||||
TYPE_QVGA_BH = 2,
|
||||
TYPE_VGA_BH = 3
|
||||
} smal_img_type;
|
||||
|
||||
int ultrapocket_getpicsoverview(GPPort **pport, GPContext *context,int *numpics, CameraList *list);
|
||||
int ultrapocket_exit(GPPort *port, GPContext *context);
|
||||
int ultrapocket_getpicture(GPPort *port, GPContext *context, unsigned char **pdata, int *size, const char *filename);
|
||||
int ultrapocket_deletefile(GPPort *port, const char *filename);
|
||||
int ultrapocket_deleteall(GPPort **pport);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user