summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2017-04-16 21:18:54 +0200
committerMarcus Meissner <marcus@jet.franken.de>2017-04-16 21:18:54 +0200
commit28ce91dc8df2bd903648097839d63a883526faa8 (patch)
tree369ea15f09f1a3cc065b8776d36eff3ac91a03e8
parent32c5ca6fe8709f83e41fa1a7cc5471be193277b4 (diff)
downloadlibgphoto2-28ce91dc8df2bd903648097839d63a883526faa8.tar.gz
First draft of EOS M support. Taken from @coderliss initial
investigations and integrated into the current framework https://github.com/gphoto/libgphoto2/issues/58
-rw-r--r--camlibs/ptp2/config.c21
-rw-r--r--camlibs/ptp2/library.c219
-rw-r--r--camlibs/ptp2/ptp-private.h9
3 files changed, 151 insertions, 98 deletions
diff --git a/camlibs/ptp2/config.c b/camlibs/ptp2/config.c
index c812d1911..15bb55258 100644
--- a/camlibs/ptp2/config.c
+++ b/camlibs/ptp2/config.c
@@ -453,6 +453,20 @@ camera_prepare_canon_eos_capture(Camera *camera, GPContext *context) {
/* Get the second bulk set of 0x9116 property data */
C_PTP (ptp_check_eos_events (params));
params->eos_captureenabled = 1;
+
+ if (is_canon_eos_m (params)) {
+ PTPPropertyValue ct_val;
+
+ GP_LOG_D ("EOS M detected");
+
+ C_PTP (ptp_canon_eos_seteventmode(params, 2));
+ ct_val.u16 = 0x0008;
+ C_PTP (ptp_canon_eos_setdevicepropvalue (params, PTP_DPC_CANON_EOS_EVFOutputDevice, &ct_val, PTP_DTC_UINT16));
+
+ usleep(1000*1000); /* 1 second */
+
+ C_PTP (ptp_check_eos_events (params));
+ }
return GP_OK;
}
@@ -522,6 +536,13 @@ camera_unprepare_canon_eos_capture(Camera *camera, GPContext *context) {
/* just in case we had autofocus running */
CR (ptp_canon_eos_afcancel(params));
+ if (is_canon_eos_m (params)) {
+ PTPPropertyValue ct_val;
+
+ ct_val.u16 = 0x0000;
+ C_PTP (ptp_canon_eos_setdevicepropvalue (params, PTP_DPC_CANON_EOS_EVFOutputDevice, &ct_val, PTP_DTC_UINT16));
+ }
+
/* then emits 911b and 911c ... not done yet ... */
CR (camera_canon_eos_update_capture_target(camera, context, 1));
diff --git a/camlibs/ptp2/library.c b/camlibs/ptp2/library.c
index b30ce4931..a8c554f28 100644
--- a/camlibs/ptp2/library.c
+++ b/camlibs/ptp2/library.c
@@ -2642,7 +2642,7 @@ camera_capture_preview (Camera *camera, CameraFile *file, GPContext *context)
continue;
case 9:
case 1:
- case 11:
+ case 11:
if (len > (size-(xdata-data))) {
len = size;
GP_LOG_E ("len=%d larger than rest size %ld", len, (size-(xdata-data)));
@@ -2651,7 +2651,7 @@ camera_capture_preview (Camera *camera, CameraFile *file, GPContext *context)
gp_file_append ( file, (char*)xdata+8, len-8 );
/* type 1 is JPEG (regular), type 9 is in movie mode */
- gp_file_set_mime_type (file, (type==1) ? GP_MIME_JPEG : GP_MIME_RAW);
+ gp_file_set_mime_type (file, ((type == 1) || (type == 11)) ? GP_MIME_JPEG : GP_MIME_RAW);
/* Add an arbitrary file name so caller won't crash */
gp_file_set_name (file, "preview.jpg");
@@ -3289,73 +3289,82 @@ camera_canon_eos_capture (Camera *camera, CameraCaptureType type, CameraFilePath
capture_start = time_now();
if (ptp_operation_issupported(params, PTP_OC_CANON_EOS_RemoteReleaseOn)) {
- struct timeval focus_start;
- int manualfocus = 0, foundfocusinfo = 0;
- PTPDevicePropDesc dpd;
-
- /* are we in manual focus mode ... value would be 3 */
- if (PTP_RC_OK == ptp_canon_eos_getdevicepropdesc (params, PTP_DPC_CANON_EOS_FocusMode, &dpd)) {
- if ((dpd.DataType == PTP_DTC_UINT16) && (dpd.CurrentValue.u16 == 3)) {
- manualfocus = 1;
- /* will do 1 pass through the focusing loop for good measure */
- GP_LOG_D("detected manual focus. skipping focus detection logic");
+ if (!is_canon_eos_m (params)) {
+ /* Regular EOS */
+ struct timeval focus_start;
+ int manualfocus = 0, foundfocusinfo = 0;
+ PTPDevicePropDesc dpd;
+
+ /* are we in manual focus mode ... value would be 3 */
+ if (PTP_RC_OK == ptp_canon_eos_getdevicepropdesc (params, PTP_DPC_CANON_EOS_FocusMode, &dpd)) {
+ if ((dpd.DataType == PTP_DTC_UINT16) && (dpd.CurrentValue.u16 == 3)) {
+ manualfocus = 1;
+ /* will do 1 pass through the focusing loop for good measure */
+ GP_LOG_D("detected manual focus. skipping focus detection logic");
+ }
}
- }
- ret = GP_OK;
- /* half press now - initiate focusing and wait for result */
- C_PTP_REP_MSG (ptp_canon_eos_remotereleaseon (params, 1, 0), _("Canon EOS Half-Press failed"));
-
- focus_start = time_now();
- do {
- int foundevents = 0;
+ ret = GP_OK;
+ /* half press now - initiate focusing and wait for result */
+ C_PTP_REP_MSG (ptp_canon_eos_remotereleaseon (params, 1, 0), _("Canon EOS Half-Press failed"));
- C_PTP_REP_MSG (ptp_check_eos_events (params), _("Canon EOS Get Changes failed"));
- while (ptp_get_one_eos_event (params, &entry)) {
- foundevents = 1;
- GP_LOG_D("focusing - read event type %d", entry.type);
- if (entry.type == PTP_CANON_EOS_CHANGES_TYPE_FOCUSINFO) {
- GP_LOG_D("focusinfo content: %s", entry.u.info);
- foundfocusinfo = 1;
- if (strstr(entry.u.info,"0000200")) {
- gp_context_error (context, _("Canon EOS Capture failed to release: Perhaps no focus?"));
- ret = GP_ERROR;
- }
- }
- if ( (entry.type == PTP_CANON_EOS_CHANGES_TYPE_PROPERTY) &&
- (entry.u.propid == PTP_DPC_CANON_EOS_FocusInfoEx)
- ) {
- if (PTP_RC_OK == ptp_canon_eos_getdevicepropdesc (params, PTP_DPC_CANON_EOS_FocusInfoEx, &dpd)) {
- GP_LOG_D("focusinfo prop content: %s", dpd.CurrentValue.str);
+ focus_start = time_now();
+ do {
+ int foundevents = 0;
+
+ C_PTP_REP_MSG (ptp_check_eos_events (params), _("Canon EOS Get Changes failed"));
+ while (ptp_get_one_eos_event (params, &entry)) {
+ foundevents = 1;
+ GP_LOG_D("focusing - read event type %d", entry.type);
+ if (entry.type == PTP_CANON_EOS_CHANGES_TYPE_FOCUSINFO) {
+ GP_LOG_D("focusinfo content: %s", entry.u.info);
foundfocusinfo = 1;
- /* FIXME: detect no focus? */
+ if (strstr(entry.u.info,"0000200")) {
+ gp_context_error (context, _("Canon EOS Capture failed to release: Perhaps no focus?"));
+ ret = GP_ERROR;
+ }
+ }
+ if ( (entry.type == PTP_CANON_EOS_CHANGES_TYPE_PROPERTY) &&
+ (entry.u.propid == PTP_DPC_CANON_EOS_FocusInfoEx)
+ ) {
+ if (PTP_RC_OK == ptp_canon_eos_getdevicepropdesc (params, PTP_DPC_CANON_EOS_FocusInfoEx, &dpd)) {
+ GP_LOG_D("focusinfo prop content: %s", dpd.CurrentValue.str);
+ foundfocusinfo = 1;
+ /* FIXME: detect no focus? */
+ }
}
}
+ /* We found focus information, so half way pressing has finished! */
+ if (foundfocusinfo)
+ break;
+ /* for manual focus, at least wait until we get events */
+ if (manualfocus && foundevents)
+ break;
+ } while (waiting_for_timeout (&back_off_wait, focus_start, 2*1000)); /* wait 2 seconds for focus */
+
+ if (!foundfocusinfo && !manualfocus) {
+ GP_LOG_E("no focus info?\n");
}
- /* We found focus information, so half way pressing has finished! */
- if (foundfocusinfo)
- break;
- /* for manual focus, at least wait until we get events */
- if (manualfocus && foundevents)
- break;
- } while (waiting_for_timeout (&back_off_wait, focus_start, 2*1000)); /* wait 2 seconds for focus */
+ if (ret != GP_OK) {
+ C_PTP_REP_MSG (ptp_canon_eos_remotereleaseoff (params, 1), _("Canon EOS Half-Release failed"));
+ return ret;
+ }
+ /* full press now */
- if (!foundfocusinfo && !manualfocus) {
- GP_LOG_E("no focus info?\n");
- }
- if (ret != GP_OK) {
+ C_PTP_REP_MSG (ptp_canon_eos_remotereleaseon (params, 2, 0), _("Canon EOS Full-Press failed"));
+ /* no event check between */
+ /* full release now */
+ C_PTP_REP_MSG (ptp_canon_eos_remotereleaseoff (params, 2), _("Canon EOS Full-Release failed"));
+ ptp_check_eos_events (params);
+
+ /* half release now */
C_PTP_REP_MSG (ptp_canon_eos_remotereleaseoff (params, 1), _("Canon EOS Half-Release failed"));
- return ret;
+ } else {
+ /* Canon EOS M series */
+ C_PTP_REP_MSG (ptp_canon_eos_remotereleaseon (params, 3, 0), _("Canon EOS M Full-Press failed"));
+ /* full release now */
+ C_PTP_REP_MSG (ptp_canon_eos_remotereleaseoff (params, 3), _("Canon EOS M Full-Release failed"));
+ ptp_check_eos_events (params);
}
- /* full press now */
-
- C_PTP_REP_MSG (ptp_canon_eos_remotereleaseon (params, 2, 0), _("Canon EOS Full-Press failed"));
- /* no event check between */
- /* full release now */
- C_PTP_REP_MSG (ptp_canon_eos_remotereleaseoff (params, 2), _("Canon EOS Full-Release failed"));
- ptp_check_eos_events (params);
-
- /* half release now */
- C_PTP_REP_MSG (ptp_canon_eos_remotereleaseoff (params, 1), _("Canon EOS Half-Release failed"));
} else {
C_PTP_REP_MSG (ptp_canon_eos_capture (params, &result),
_("Canon EOS Capture failed"));
@@ -4163,12 +4172,13 @@ out:
static int
camera_trigger_capture (Camera *camera, GPContext *context)
{
- PTPParams *params = &camera->pl->params;
+ PTPParams *params = &camera->pl->params;
uint16_t ret;
- char buf[1024];
- int sdram = 0;
- int af = 1;
+ char buf[1024];
+ int sdram = 0;
+ int af = 1;
+ GP_LOG_D ("camera_trigger_capture");
SET_CONTEXT_P(params, context);
@@ -4311,46 +4321,54 @@ camera_trigger_capture (Camera *camera, GPContext *context)
return GP_ERROR_CAMERA_BUSY;
ret = GP_OK;
- /* half press now - initiate focusing and wait for result */
- C_PTP_REP_MSG (ptp_canon_eos_remotereleaseon (params, 1, 0), _("Canon EOS Half-Press failed"));
- do {
- PTPCanon_changes_entry entry;
- int foundfocusinfo = 0;
+ if (!is_canon_eos_m(params)) {
+ /* half press now - initiate focusing and wait for result */
+ C_PTP_REP_MSG (ptp_canon_eos_remotereleaseon (params, 1, 0), _("Canon EOS Half-Press failed"));
- C_PTP_REP_MSG (ptp_check_eos_events (params),
- _("Canon EOS Get Changes failed"));
- oneloop = 0;
- while (ptp_get_one_eos_event (params, &entry)) {
- oneloop = 1;
- GP_LOG_D("focusing - read event type %d", entry.type);
- if (entry.type == PTP_CANON_EOS_CHANGES_TYPE_FOCUSINFO) {
- GP_LOG_D("focusinfo content: %s", entry.u.info);
- foundfocusinfo = 1;
- if (strstr(entry.u.info,"0000200")) {
- gp_context_error (context, _("Canon EOS Capture failed to release: Perhaps no focus?"));
- ret = GP_ERROR;
+ do {
+ PTPCanon_changes_entry entry;
+ int foundfocusinfo = 0;
+
+ C_PTP_REP_MSG (ptp_check_eos_events (params),
+ _("Canon EOS Get Changes failed"));
+ oneloop = 0;
+ while (ptp_get_one_eos_event (params, &entry)) {
+ oneloop = 1;
+ GP_LOG_D("focusing - read event type %d", entry.type);
+ if (entry.type == PTP_CANON_EOS_CHANGES_TYPE_FOCUSINFO) {
+ GP_LOG_D("focusinfo content: %s", entry.u.info);
+ foundfocusinfo = 1;
+ if (strstr(entry.u.info,"0000200")) {
+ gp_context_error (context, _("Canon EOS Capture failed to release: Perhaps no focus?"));
+ ret = GP_ERROR;
+ }
}
}
+ if (foundfocusinfo)
+ break;
+ } while (oneloop);
+
+ if (ret != GP_OK) {
+ C_PTP_REP_MSG (ptp_canon_eos_remotereleaseoff (params, 1), _("Canon EOS Half-Release failed"));
+ return ret;
}
- if (foundfocusinfo)
- break;
- } while (oneloop);
+ /* full press now */
- if (ret != GP_OK) {
+ C_PTP_REP_MSG (ptp_canon_eos_remotereleaseon (params, 2, 0), _("Canon EOS Full-Press failed"));
+ /* no event check between */
+ /* full release now */
+ C_PTP_REP_MSG (ptp_canon_eos_remotereleaseoff (params, 2), _("Canon EOS Full-Release failed"));
+ ptp_check_eos_events (params);
+
+ /* half release now */
C_PTP_REP_MSG (ptp_canon_eos_remotereleaseoff (params, 1), _("Canon EOS Half-Release failed"));
- return ret;
+ } else {
+ C_PTP_REP_MSG (ptp_canon_eos_remotereleaseon (params, 3, 0), _("Canon EOS M Full-Press failed"));
+ /* full release now */
+ C_PTP_REP_MSG (ptp_canon_eos_remotereleaseoff (params, 3), _("Canon EOS M Full-Release failed"));
+ ptp_check_eos_events (params);
}
- /* full press now */
-
- C_PTP_REP_MSG (ptp_canon_eos_remotereleaseon (params, 2, 0), _("Canon EOS Full-Press failed"));
- /* no event check between */
- /* full release now */
- C_PTP_REP_MSG (ptp_canon_eos_remotereleaseoff (params, 2), _("Canon EOS Full-Release failed"));
- ptp_check_eos_events (params);
-
- /* half release now */
- C_PTP_REP_MSG (ptp_canon_eos_remotereleaseoff (params, 1), _("Canon EOS Half-Release failed"));
return GP_OK;
}
@@ -7921,8 +7939,13 @@ camera_init (Camera *camera, GPContext *context)
)
return chdk_init (camera, context);
- if (ptp_operation_issupported(params, PTP_OC_CANON_EOS_SetRemoteMode))
- C_PTP (ptp_canon_eos_setremotemode(params, 1));
+ if (ptp_operation_issupported(params, PTP_OC_CANON_EOS_SetRemoteMode)) {
+ if (is_canon_eos_m(params)) {
+ C_PTP (ptp_canon_eos_setremotemode(params, 0x15));
+ } else {
+ C_PTP (ptp_canon_eos_setremotemode(params, 1));
+ }
+ }
break;
case PTP_VENDOR_NIKON:
if (ptp_operation_issupported(params, PTP_OC_NIKON_CurveDownload))
diff --git a/camlibs/ptp2/ptp-private.h b/camlibs/ptp2/ptp-private.h
index f24bb37f5..91e086e1c 100644
--- a/camlibs/ptp2/ptp-private.h
+++ b/camlibs/ptp2/ptp-private.h
@@ -21,6 +21,8 @@
/* ptp2 camlib private functions */
#include <gphoto2/gphoto2-library.h>
+#include <string.h>
+
/* config.c */
int camera_get_config (Camera *camera, CameraWidget **window, GPContext *context);
int camera_get_config_list (Camera *camera, CameraList *list, GPContext *context);
@@ -107,6 +109,13 @@ inline static int log_on_ptp_error_helper( int _r, const char* _func, const char
}\
} while (0)
+static inline int
+is_canon_eos_m(PTPParams *params) {
+ if (params->deviceinfo.VendorExtensionID != PTP_VENDOR_CANON) return 0;
+ if (!ptp_operation_issupported(params, PTP_OC_CANON_EOS_SetRemoteMode)) return 0;
+ return strchr(params->deviceinfo.Model, 'M') != NULL;
+}
+
struct _CameraPrivateLibrary {
PTPParams params;