diff options
author | Theodore Kilgore <kilgota@auburn.edu> | 2003-11-20 01:24:04 +0000 |
---|---|---|
committer | Theodore Kilgore <kilgota@auburn.edu> | 2003-11-20 01:24:04 +0000 |
commit | f00d62b0ec2528b893497f8056227eaaf6b467b9 (patch) | |
tree | 4ce7e694c30e553b840377d63a689eec731a7633 /camlibs/aox/aox.c | |
parent | 0545e549b8ab40d884bcb046485694c212f7ff7a (diff) | |
download | libgphoto2-f00d62b0ec2528b893497f8056227eaaf6b467b9.tar.gz |
*** empty log message ***
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@6929 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'camlibs/aox/aox.c')
-rw-r--r-- | camlibs/aox/aox.c | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/camlibs/aox/aox.c b/camlibs/aox/aox.c new file mode 100644 index 000000000..8160a4ea5 --- /dev/null +++ b/camlibs/aox/aox.c @@ -0,0 +1,131 @@ +/* aox.c + * + * Copyright (C) 2003 Theodore Kilgore <kilgota@auburn.edu> + * + * 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 <errno.h> +#include <fcntl.h> +#include <string.h> + +#include <gphoto2.h> +#include <gphoto2-port.h> + +#include "aox.h" + +#define GP_MODULE "aox" + +#define WRITE gp_port_usb_msg_write +#define READ gp_port_usb_msg_read + + +int aox_init (GPPort *port, Model *model, Info *info) +{ + unsigned char c[4]; + memset(c,0,sizeof(c)); + unsigned char hi[2]; + memset (hi,0,2); + unsigned char lo[2]; + memset (lo,0,2); + + GP_DEBUG("Running aox_init\n"); + + READ(port, 1, 0, 0, c,0x10); + WRITE(port, 8, 1, 0, c, 0x10); + READ(port, 0xff, 0x07, 0xfffc, c, 4); /* Returns version number, apparently */ + READ(port, 0x06, 0x0, 0x0, c, 2); + READ(port, 0x04, 0x1, 0x1, lo, 2); + GP_DEBUG("%02x %02x number of lo-res pics\n", lo[0],lo[1]); + /* We need to keep this information. We presume that + * more than 255 pictures is impossible with this camera. + */ + memcpy (info, &lo[0], 1); + READ(port, 0x04, 0x2, 0x1, c, 2); + READ(port, 0x04, 0x3, 0x1, c, 2); + READ(port, 0x04, 0x4, 0x1, c, 2); + READ(port, 0x04, 0x5, 0x1, hi, 2); + GP_DEBUG("%02i %02i number of hi-res pics\n", hi[0], hi[1]); + /* This information, too. */ + memcpy (info +1, &hi[0], 1); + READ(port, 0x04, 0x6, 0x1, c, 2); /* "Completion" flag.*/ + GP_DEBUG("info[0] = 0x%x\n", info[0]); + GP_DEBUG("info[1] = 0x%x\n", info[1]); + GP_DEBUG("Leaving aox_init\n"); + + return GP_OK; +} + +int aox_get_num_lo_pics (Info *info) +{ + GP_DEBUG("Running aox_get_num_lo_pics\n"); + return info[0]; +} + +int aox_get_num_hi_pics (Info *info) +{ + GP_DEBUG("Running aox_get_num_hi_pics\n"); + return info[1]; +} + +int aox_get_picture_size (GPPort *port, int lo, int hi, int n, int k) +{ + GP_DEBUG("Running aox_get_picture_size\n"); + + unsigned char c[4]; + memset (c,0,4); + unsigned int size; + + if ( ( (lo) && ( n ==k ) && (k ==0)) ) { + READ(port, 0x04, 0x1, 0x1, c, 2); + } + if ( ( (hi) && ( n < k ) && (n == 0)) ) { + READ(port, 0x04, 0x5, 0x1, c, 2); + } + READ(port, 0x05, n+1, 0x1, c, 4); + size = (int)c[0] + (int)c[1]*0x100 + (int)c[2]*0x10000; + GP_DEBUG(" size of picture %i is 0x%x\n", k, size); + if ( (size >= 0xfffff ) ) {return GP_ERROR;} + GP_DEBUG("Leaving aox_get_picture_size\n"); + + return size; +} + +int aox_read_data (GPPort *port, char *data, int size) +{ + int MAX_BULK = 0x1000; + + while(size > 0) { + int len = (size>MAX_BULK)?MAX_BULK:size; + gp_port_read (port, data, len); /* 0x84 = EP IN NEEDED HERE.*/ + data += len; + size -= len; + } + return 1; +} + +int aox_read_picture_data (GPPort *port, char *data, int size, int n) { + char c[4]; + memset(c,0,4); + + READ(port, 0x06, n+1, 0x1, c, 4); + aox_read_data (port, data , size); + + return GP_OK; +} |