trigger capture for canon powershot testing
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@13635 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
@@ -158,6 +158,9 @@ camera_prepare_canon_powershot_capture(Camera *camera, GPContext *context) {
|
||||
} else
|
||||
gp_log (GP_LOG_DEBUG, "ptp", "No expected mode change event.");
|
||||
}
|
||||
|
||||
/* FIXME: Marcus: wait for the 0xC00C Canon event? also apparently sent by the SX100IS */
|
||||
|
||||
/* Reget device info, they change on the Canons. */
|
||||
ptp_getdeviceinfo(&camera->pl->params, &camera->pl->params.deviceinfo);
|
||||
fixup_cached_deviceinfo (camera, &camera->pl->params.deviceinfo);
|
||||
|
||||
@@ -1423,6 +1423,13 @@ camera_abilities (CameraAbilitiesList *list)
|
||||
strchr(models[i].model,'D')
|
||||
)
|
||||
a.operations |= GP_OPERATION_TRIGGER_CAPTURE;
|
||||
#if 0
|
||||
/* SX 100 IS ... works in sdram, not in card mode */
|
||||
if ( (models[i].usb_vendor == 0x4a9) &&
|
||||
(models[i].usb_product == 0x315e)
|
||||
)
|
||||
a.operations |= GP_OPERATION_TRIGGER_CAPTURE;
|
||||
#endif
|
||||
}
|
||||
if (models[i].device_flags & PTP_CAP_PREVIEW)
|
||||
a.operations |= GP_OPERATION_CAPTURE_PREVIEW;
|
||||
@@ -2637,13 +2644,93 @@ camera_trigger_capture (Camera *camera, GPContext *context)
|
||||
} while (params->eos_camerastatus == 1);
|
||||
return GP_OK;
|
||||
}
|
||||
#if 0
|
||||
if ( (params->deviceinfo.VendorExtensionID == PTP_VENDOR_CANON) &&
|
||||
ptp_operation_issupported(params, PTP_OC_CANON_InitiateCaptureInMemory)
|
||||
) {
|
||||
return camera_canon_capture (camera, type, path, context);
|
||||
}
|
||||
uint16_t xmode;
|
||||
int viewfinderwason = 0;
|
||||
PTPPropertyValue propval;
|
||||
|
||||
if (!ptp_property_issupported(params, PTP_DPC_CANON_FlashMode)) {
|
||||
/* did not call --set-config capture=on, do it for user */
|
||||
ret = camera_prepare_capture (camera, context);
|
||||
if (ret != GP_OK)
|
||||
return ret;
|
||||
if (!ptp_property_issupported(params, PTP_DPC_CANON_FlashMode)) {
|
||||
gp_context_error (context,
|
||||
_("Sorry, initializing your camera did not work. Please report this."));
|
||||
return GP_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
if (ptp_property_issupported(params, PTP_DPC_CANON_CaptureTransferMode)) {
|
||||
if ((GP_OK == gp_setting_get("ptp2","capturetarget",buf)) && !strcmp(buf,"sdram"))
|
||||
propval.u16 = xmode = CANON_TRANSFER_MEMORY;
|
||||
else
|
||||
propval.u16 = xmode = CANON_TRANSFER_CARD;
|
||||
|
||||
if (xmode == CANON_TRANSFER_CARD) {
|
||||
PTPStorageIDs storageids;
|
||||
|
||||
ret = ptp_getstorageids(params, &storageids);
|
||||
if (ret == PTP_RC_OK) {
|
||||
int k, stgcnt = 0;
|
||||
for (k=0;k<storageids.n;k++) {
|
||||
if (!(storageids.Storage[k] & 0xffff)) continue;
|
||||
if (storageids.Storage[k] == 0x80000001) continue;
|
||||
stgcnt++;
|
||||
}
|
||||
if (!stgcnt) {
|
||||
gp_log (GP_LOG_DEBUG, "ptp", "Assuming no CF card present - switching to MEMORY Transfer.");
|
||||
propval.u16 = xmode = CANON_TRANSFER_MEMORY;
|
||||
}
|
||||
free (storageids.Storage);
|
||||
}
|
||||
}
|
||||
ret = ptp_setdevicepropvalue(params, PTP_DPC_CANON_CaptureTransferMode, &propval, PTP_DTC_UINT16);
|
||||
if (ret != PTP_RC_OK)
|
||||
gp_log (GP_LOG_DEBUG, "ptp", "setdevicepropvalue CaptureTransferMode failed, %x", ret);
|
||||
}
|
||||
|
||||
if (params->canon_viewfinder_on) { /* disable during capture ... reenable later on. */
|
||||
ret = ptp_canon_viewfinderoff (params);
|
||||
if (ret != PTP_RC_OK) {
|
||||
gp_context_error (context, _("Canon disable viewfinder failed: %d"), ret);
|
||||
SET_CONTEXT_P(params, NULL);
|
||||
return translate_ptp_result (ret);
|
||||
}
|
||||
viewfinderwason = 1;
|
||||
params->canon_viewfinder_on = 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* FIXME: For now, to avoid flash during debug */
|
||||
propval.u8 = 0;
|
||||
ret = ptp_setdevicepropvalue(params, PTP_DPC_CANON_FlashMode, &propval, PTP_DTC_UINT8);
|
||||
#endif
|
||||
while (1) {
|
||||
ret = ptp_canon_initiatecaptureinmemory (params);
|
||||
if (ret == PTP_RC_OK)
|
||||
break;
|
||||
if (ret == PTP_RC_DeviceBusy) {
|
||||
gp_log (GP_LOG_DEBUG, "ptp/trigger_capture", "Canon Powershot busy ... retrying...");
|
||||
gp_context_idle (context);
|
||||
ptp_check_event (params);
|
||||
usleep(10000); /* 10 ms ... fixme: perhaps experimental backoff? */
|
||||
continue;
|
||||
}
|
||||
if (ret != PTP_RC_OK) {
|
||||
gp_context_error (context, _("Canon Capture failed: %x"), ret);
|
||||
return translate_ptp_result (ret);
|
||||
}
|
||||
return GP_OK;
|
||||
}
|
||||
gp_log (GP_LOG_DEBUG, "ptp/trigger_capture", "Canon Powershot capture triggered...");
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
if ( (params->deviceinfo.VendorExtensionID == PTP_VENDOR_CANON) &&
|
||||
ptp_operation_issupported(params, PTP_OC_CANON_EOS_RemoteRelease)
|
||||
) {
|
||||
@@ -2827,6 +2914,42 @@ camera_wait_for_event (Camera *camera, int timeout,
|
||||
CPR (context, ptp_check_event (params));
|
||||
if (ptp_get_one_event(params, &event)) {
|
||||
gp_log (GP_LOG_DEBUG, "ptp","canon event: nparam=0x%X, C=0x%X, trans_id=0x%X, p1=0x%X, p2=0x%X, p3=0x%X", event.Nparam,event.Code,event.Transaction_ID, event.Param1, event.Param2, event.Param3);
|
||||
switch (event.Code) {
|
||||
case PTP_EC_CANON_RequestObjectTransfer: {
|
||||
CameraFilePath *path;
|
||||
PTPObjectInfo oi;
|
||||
|
||||
newobject = event.Param1;
|
||||
gp_log (GP_LOG_DEBUG, "ptp", "PTP_EC_CANON_RequestObjectTransfer, object handle=0x%X.",newobject);
|
||||
/* FIXME: handle multiple images (as in BurstMode) */
|
||||
ret = ptp_getobjectinfo (params, newobject, &oi);
|
||||
if (ret != PTP_RC_OK) return translate_ptp_result (ret);
|
||||
|
||||
if (oi.ParentObject != 0) {
|
||||
ret = add_object (camera, newobject, context);
|
||||
if (ret != GP_OK)
|
||||
return ret;
|
||||
path = malloc (sizeof(CameraFilePath));
|
||||
strcpy (path->name, oi.Filename);
|
||||
sprintf (path->folder,"/"STORAGE_FOLDER_PREFIX"%08lx/",(unsigned long)oi.StorageID);
|
||||
get_folder_from_handle (camera, oi.StorageID, oi.ParentObject, path->folder);
|
||||
/* delete last / or we get confused later. */
|
||||
path->folder[ strlen(path->folder)-1 ] = '\0';
|
||||
gp_filesystem_append (camera->fs, path->folder, path->name, context);
|
||||
|
||||
} else {
|
||||
path = malloc (sizeof(CameraFilePath));
|
||||
sprintf (path->folder,"/"STORAGE_FOLDER_PREFIX"%08lx",(unsigned long)oi.StorageID);
|
||||
sprintf (path->name, "capt%04d.jpg", capcnt++);
|
||||
add_objectid_and_upload (camera, path, context, newobject, &oi);
|
||||
}
|
||||
*eventdata = path;
|
||||
*eventtype = GP_EVENT_FILE_ADDED;
|
||||
return GP_OK;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
goto handleregular;
|
||||
}
|
||||
if (_timeout_passed (&event_start, timeout))
|
||||
|
||||
Reference in New Issue
Block a user