summaryrefslogtreecommitdiff
path: root/camlibs/toshiba
diff options
context:
space:
mode:
authorSean Bruno <sean.bruno@dsl-only.net>2004-07-17 02:58:53 +0000
committerSean Bruno <sean.bruno@dsl-only.net>2004-07-17 02:58:53 +0000
commit7858a81536321c8851599a95cb0b57ec3a98dd15 (patch)
treef22ce715b58118cb5562b031a43293a1200964c9 /camlibs/toshiba
parent69210df2e4e37785336bc0570835edd6ad0936c8 (diff)
downloadlibgphoto2-7858a81536321c8851599a95cb0b57ec3a98dd15.tar.gz
Initial work done to add support for PDR-M65, this file compiles, but the library is not functional.
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@7244 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'camlibs/toshiba')
-rw-r--r--camlibs/toshiba/pdrm65/library.c61
-rw-r--r--camlibs/toshiba/pdrm65/pdrm65.c103
-rw-r--r--camlibs/toshiba/pdrm65/pdrm65.h5
3 files changed, 139 insertions, 30 deletions
diff --git a/camlibs/toshiba/pdrm65/library.c b/camlibs/toshiba/pdrm65/library.c
index 2acaa7c7f..136b676aa 100644
--- a/camlibs/toshiba/pdrm65/library.c
+++ b/camlibs/toshiba/pdrm65/library.c
@@ -1,6 +1,6 @@
/* template.c
*
- * Copyright © 2001 Lutz Müller <lutz@users.sourceforge.net>
+ * Copyright 2001 Lutz Mller <lutz@users.sourceforge.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -18,7 +18,8 @@
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
-
+#include "pdrm65.h"
+#include <string.h>
#include <gphoto2-library.h>
#include <gphoto2-result.h>
@@ -70,7 +71,7 @@ camera_abilities (CameraAbilitiesList *list)
static int
camera_exit (Camera *camera, GPContext *context)
{
- return (GP_OK);
+ return (GP_ERROR_NOT_SUPPORTED);
}
static int
@@ -78,14 +79,16 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
CameraFileType type, CameraFile *file, void *data,
GPContext *context)
{
+ int ret = GP_OK;
Camera *camera = data;
-
+
+ //ret = pdrm65_get_all_pictures(camera->port);
/*
* Get the file from the camera. Use gp_file_set_mime_type,
* gp_file_set_data_and_size, etc.
*/
- return (GP_OK);
+ return (ret);
}
static int
@@ -99,7 +102,7 @@ put_file_func (CameraFilesystem *fs, const char *folder, CameraFile *file,
* gp_file_get_name, etc.
*/
- return (GP_OK);
+ return (GP_ERROR_NOT_SUPPORTED);
}
static int
@@ -110,7 +113,7 @@ delete_file_func (CameraFilesystem *fs, const char *folder,
/* Delete the file from the camera. */
- return (GP_OK);
+ return (GP_ERROR_NOT_SUPPORTED);
}
static int
@@ -124,7 +127,7 @@ delete_all_func (CameraFilesystem *fs, const char *folder, void *data,
* such a functionality, just don't implement this function.
*/
- return (GP_OK);
+ return (GP_ERROR_NOT_SUPPORTED);
}
static int
@@ -134,7 +137,7 @@ camera_config_get (Camera *camera, CameraWidget **window, GPContext *context)
/* Append your sections and widgets here. */
- return (GP_OK);
+ return (GP_ERROR_NOT_SUPPORTED);
}
static int
@@ -144,7 +147,7 @@ camera_config_set (Camera *camera, CameraWidget *window, GPContext *context)
* Check if the widgets' values have changed. If yes, tell the camera.
*/
- return (GP_OK);
+ return (GP_ERROR_NOT_SUPPORTED);
}
static int
@@ -157,7 +160,7 @@ camera_capture_preview (Camera *camera, CameraFile *file, GPContext *context)
* disk. If your camera does, please delete it from the camera.
*/
- return (GP_OK);
+ return (GP_ERROR_NOT_SUPPORTED);
}
static int
@@ -169,7 +172,7 @@ camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path,
* out the path.
*/
- return (GP_OK);
+ return (GP_ERROR_NOT_SUPPORTED);
}
static int
@@ -180,7 +183,7 @@ camera_summary (Camera *camera, CameraText *summary, GPContext *context)
* state of the camera (like pictures taken, etc.).
*/
- return (GP_OK);
+ return (GP_ERROR_NOT_SUPPORTED);
}
static int
@@ -191,18 +194,18 @@ camera_manual (Camera *camera, CameraText *manual, GPContext *context)
* to use the camera or the driver, this is the place to do.
*/
- return (GP_OK);
+ return (GP_ERROR_NOT_SUPPORTED);
}
static int
camera_about (Camera *camera, CameraText *about, GPContext *context)
{
- strcpy (about->text, _("Library Name\n"
- "YOUR NAME <email@somewhere.com>\n"
- "Quick description of the library.\n"
- "No more than 5 lines if possible."));
+ strcpy (about->text, _("Toshiba PDR-M65\n"
+ "Sean Bruno <sean.bruno@dsl-only.net>\n"
+ "Library for the Toshiba PDR-M65\n"
+ "USB interface."));
- return (GP_OK);
+ return (GP_ERROR_NOT_SUPPORTED);
}
static int
@@ -213,7 +216,7 @@ get_info_func (CameraFilesystem *fs, const char *folder, const char *filename,
/* Get the file info here and write it into <info> */
- return (GP_OK);
+ return (GP_ERROR_NOT_SUPPORTED);
}
static int
set_info_func (CameraFilesystem *fs, const char *folder, const char *file,
@@ -223,7 +226,7 @@ set_info_func (CameraFilesystem *fs, const char *folder, const char *file,
/* Set the file info here from <info> */
- return (GP_OK);
+ return (GP_ERROR_NOT_SUPPORTED);
}
@@ -235,7 +238,7 @@ folder_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
/* List your folders here */
- return (GP_OK);
+ return (GP_ERROR_NOT_SUPPORTED);
}
static int
@@ -243,16 +246,17 @@ file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
void *data, GPContext *context)
{
Camera *camera = data;
-
+ int ret = GP_OK;
/* List your files here */
-
- return (GP_OK);
+ ret = pdrm65_get_filenames(camera->port, list);
+ return (ret);
}
int
camera_init (Camera *camera, GPContext *context)
{
- /* First, set up all the function pointers */
+ int ret = GP_OK;
+ /* First, set up all the function pointers */
camera->functions->exit = camera_exit;
camera->functions->get_config = camera_config_get;
camera->functions->set_config = camera_config_set;
@@ -282,6 +286,7 @@ camera_init (Camera *camera, GPContext *context)
* Once you have configured the port, you should check if a
* connection to the camera can be established.
*/
-
- return (GP_OK);
+ ret = pdrm65_init(camera->port);
+
+ return (ret);
}
diff --git a/camlibs/toshiba/pdrm65/pdrm65.c b/camlibs/toshiba/pdrm65/pdrm65.c
index 805cf4e5f..c4473155b 100644
--- a/camlibs/toshiba/pdrm65/pdrm65.c
+++ b/camlibs/toshiba/pdrm65/pdrm65.c
@@ -1,6 +1,105 @@
#include "pdrm65.h"
+#define GP_MODULE "setting"
-int main()
+int pdrm65_init(GPPort *port)
{
- return (GP_OK);
+ unsigned char out_buf[1024];
+ unsigned char in_buf[1024];
+ //int timeout = 50;
+ int ret = GP_OK;
+ char ok = 0x06;
+ gp_port_set_timeout(port,1000);
+ memset(out_buf, 0, sizeof(out_buf));
+ memset(in_buf, 0, sizeof(in_buf));
+ /* exactly what windows driver does */
+ //gp_port_usb_msg_read (port, 0x01, PDRM11_CMD_READY, 0, buf, 4);
+ out_buf[0] = 0x1b;
+ out_buf[1] = 0x43;
+ out_buf[2] = 0x02;
+ out_buf[3] = 0x00;
+ out_buf[4] = 0x04;
+ out_buf[5] = 0x1b;
+ out_buf[6] = 0x1f;
+ out_buf[7] = 0x00;
+ gp_port_write(port, out_buf, 8);
+ gp_port_read (port, in_buf, 11);
+ gp_port_write(port, &ok, 1);
+
+ //out_buf[0-3]=0x1b 43 02 00
+ out_buf[4]=0x01;
+ out_buf[5]=0x02;
+ out_buf[6]=0x03;
+ //out_buf[7]=0x00
+ gp_port_write(port, out_buf, 8);
+ gp_port_read (port, in_buf, 10);
+ gp_port_write(port, &ok, 1);
+
+ //out_buf[0-3]=0x1b 43 02 00
+ out_buf[4] = 0x04;
+ out_buf[5] = 0x1b;
+ out_buf[6] = 0x1f;
+ //out_buf[7]=0x00
+ gp_port_write(port, out_buf, 8);
+ gp_port_read (port, in_buf, 11);
+ //in_buf[4-7] == "SI15"
+ gp_port_write(port, &ok, 1);
+
+ //out_buf[0-3]=0x1b 43 02 00
+ out_buf[4]=0x04;
+ out_buf[5]=0x16;
+ out_buf[6]=0x1a;
+ //out_buf[7]=0x00
+ gp_port_write(port, out_buf, 8);
+ gp_port_read (port, in_buf, 14);
+ //in_buf[4-10] == "PDR-M65
+ gp_port_write(port, &ok, 1);
+
+ return(ret);
+}
+int pdrm65_get_filenames(GPPort *port, CameraList *list)
+{
+
+ uint32_t numPics;
+ char out_buf[1024];
+ char in_buf[1024];
+ char ok = 0x06;
+ out_buf[0] = 0x1b;
+ out_buf[1] = 0x43;
+ out_buf[2] = 0x02;
+ out_buf[3] = 0x00;
+ out_buf[4] = 0x01;
+ out_buf[5] = 0x0a;
+ out_buf[6] = 0x0b;
+ out_buf[7] = 0x00;
+
+ gp_port_set_timeout(port, 10000);
+ gp_port_write(port, out_buf, 8);
+ gp_port_read (port, in_buf, 9);
+ /* trying to remain endian friendly */
+ gp_port_write(port, &ok, 1);
+
+ numPics = le16atoh(&in_buf[3]) + (le16atoh(&in_buf[4]) * 256);
+ GP_DEBUG("found %d pictures", numPics);
+
+
+#if 0
+ for(i=1; i<numPics+1; i++) {
+ CHECK( pdrm11_select_file(port, i) );
+
+ CHECK(gp_port_usb_msg_read(port, 0x01, 0xe600, i, buf, 14));
+
+ /* the filename is 12 chars starting at the third byte */
+ CHECK(gp_port_usb_msg_read(port, 0x01, PDRM11_CMD_GET_FILENAME, i, buf, 26));
+ for(j=0; j<12; j+=2) {
+ name[j] = buf[j+2+1];
+ name[j+1] = buf[j+2];
+ }
+ name[12] = '\0';
+
+ GP_DEBUG(name);
+ gp_list_append(list, name, NULL);
+ }
+
+#endif
+ return(GP_OK);
}
diff --git a/camlibs/toshiba/pdrm65/pdrm65.h b/camlibs/toshiba/pdrm65/pdrm65.h
index 7cecc4fd0..2974bc44b 100644
--- a/camlibs/toshiba/pdrm65/pdrm65.h
+++ b/camlibs/toshiba/pdrm65/pdrm65.h
@@ -1,2 +1,7 @@
#include <gphoto2.h>
+#include <string.h>
+#include <gphoto2-endian.h>
+
+int pdrm65_init(GPPort *);
+int pdrm65_get_filenames(GPPort *, CameraList *);