diff options
author | Marcus Meissner <marcus@jet.franken.de> | 2016-10-09 11:20:07 +0200 |
---|---|---|
committer | Marcus Meissner <marcus@jet.franken.de> | 2016-10-09 11:23:26 +0200 |
commit | b8c87d8a2a50a3c04eb05600815ce9a7d7f80265 (patch) | |
tree | 5fd6b93078972d2ed9be438928030d6217267f8a | |
parent | ec0218827fb3cbb10fda0c86178ee888c4037aeb (diff) | |
download | libgphoto2-b8c87d8a2a50a3c04eb05600815ce9a7d7f80265.tar.gz |
sony: debug property changes
sony: change the wait on shutterpressing to be waiting for 0xd213 changes
sony: also check events for newobject addition
sony: a bit more debugging
supplements https://github.com/gphoto/libgphoto2/pull/88
-rw-r--r-- | camlibs/ptp2/library.c | 58 | ||||
-rw-r--r-- | camlibs/ptp2/ptp.c | 29 | ||||
-rw-r--r-- | camlibs/ptp2/ptp.h | 3 |
3 files changed, 85 insertions, 5 deletions
diff --git a/camlibs/ptp2/library.c b/camlibs/ptp2/library.c index 4f6ab5f21..e4c5586f4 100644 --- a/camlibs/ptp2/library.c +++ b/camlibs/ptp2/library.c @@ -3031,6 +3031,8 @@ capturetriggered: if (!newobject) newobject = 0xffff0001; + CR (gp_port_set_timeout (camera->port, normal_timeout)); + /* This loop handles single and burst capture. * It also handles SDRAM and also CARD capture. * In Burst/SDRAM we need to download everything at once @@ -3682,8 +3684,38 @@ camera_sony_capture (Camera *camera, CameraCaptureType type, CameraFilePath *pat propval.u16 = 2; C_PTP (ptp_sony_setdevicecontrolvalueb (params, PTP_DPC_SONY_Capture, &propval, PTP_DTC_UINT16)); - /* keep the shutter held for only 50ms so we don't take more than one photo in high-speed mode */ - usleep(50000); + /* Now hold down the shutter button for a bit. We probably need to hold it as long as it takes to + * get focus, indicated by the 0xD213 property. But hold it for at most 1 second. + */ + + GP_LOG_D ("holding down shutterbutton"); + event_start = time_now(); + do { + /* needed on older cameras like the a58, check for events ... */ + C_PTP (ptp_check_event (params)); + if (ptp_get_one_event(params, &event)) { + GP_LOG_D ("during event.code=%04x Param1=%08x", event.Code, event.Param1); + if ( (event.Code == PTP_EC_Sony_PropertyChanged) && + (event.Param1 == PTP_DPC_SONY_FocusFound) + ) { + GP_LOG_D ("SONY FocusFound change received, 0xd213... ending press"); + break; + } + } + + /* Alternative code in case we miss the event */ + + C_PTP (ptp_sony_getalldevicepropdesc (params)); /* avoid caching */ + C_PTP (ptp_generic_getdevicepropdesc (params, PTP_DPC_SONY_FocusFound, &dpd)); + GP_LOG_D ("DEBUG== 0xd213 after shutter press = %d", dpd.CurrentValue.u8); + /* if prop 0xd213 = 2, the focus seems to be achieved */ + if (dpd.CurrentValue.u8 == 2) { + GP_LOG_D ("SONY Property change seen, 0xd213... ending press"); + break; + } + + } while (time_since (event_start) < 1000); + GP_LOG_D ("releasing shutterbutton"); /* release full-press */ propval.u16 = 1; @@ -3693,17 +3725,35 @@ camera_sony_capture (Camera *camera, CameraCaptureType type, CameraFilePath *pat propval.u16 = 1; C_PTP (ptp_sony_setdevicecontrolvalueb (params, PTP_DPC_SONY_AutoFocus, &propval, PTP_DTC_UINT16)); - + GP_LOG_D ("waiting for image availability"); event_start = time_now(); do { + /* needed on older cameras like the a58, check for events ... */ + C_PTP (ptp_check_event (params)); + if (ptp_get_one_event(params, &event)) { + GP_LOG_D ("during event.code=%04x Param1=%08x", event.Code, event.Param1); + if (event.Code == PTP_EC_Sony_ObjectAdded) { + newobject = event.Param1; + if (dual) + ptp_add_event (params, &event); + GP_LOG_D ("SONY ObjectAdded received, ending wait"); + break; + } + } + + C_PTP (ptp_sony_getalldevicepropdesc (params)); /* avoid caching */ C_PTP (ptp_generic_getdevicepropdesc (params, PTP_DPC_SONY_ObjectInMemory, &dpd)); GP_LOG_D ("DEBUG== 0xd215 after capture = %d", dpd.CurrentValue.u16); /* if prop 0xd215 > 0x8000, the object in RAM is available at location 0xffffc001 */ - if(dpd.CurrentValue.u16 > 0x8000) break; + if (dpd.CurrentValue.u16 > 0x8000) { + GP_LOG_D ("SONY ObjectInMemory count change seen, ending wait"); + break; + } /* 30 seconds are maximum capture time currently, so use 30 seconds + 5 seconds image saving at most. */ } while (time_since (event_start) < 35000); + GP_LOG_D ("ending image availability"); if (!newobject) { GP_LOG_E("no object found during event polling. try the 0xffffc001 object id"); diff --git a/camlibs/ptp2/ptp.c b/camlibs/ptp2/ptp.c index 47c9060a9..8c210750f 100644 --- a/camlibs/ptp2/ptp.c +++ b/camlibs/ptp2/ptp.c @@ -2878,6 +2878,35 @@ ptp_sony_getalldevicepropdesc (PTPParams* params) if (params->deviceproperties[i].desc.DevicePropertyCode == propcode) break; + /* debug output to see what changes */ + if (i != params->nrofdeviceproperties) { + switch (dpd.DataType) { + case PTP_DTC_INT8: +#define CHECK_CHANGED(type) \ + if (params->deviceproperties[i].desc.CurrentValue.type != dpd.CurrentValue.type) \ + ptp_debug (params, "ptp_sony_getalldevicepropdesc: %04x: value %d -> %d", propcode, params->deviceproperties[i].desc.CurrentValue.type, dpd.CurrentValue.type); + CHECK_CHANGED(i8); + break; + case PTP_DTC_UINT8: + CHECK_CHANGED(u8); + break; + case PTP_DTC_UINT16: + CHECK_CHANGED(u16); + break; + case PTP_DTC_INT16: + CHECK_CHANGED(i16); + break; + case PTP_DTC_INT32: + CHECK_CHANGED(i32); + break; + case PTP_DTC_UINT32: + CHECK_CHANGED(u32); + break; + default: + break; + } + } + if (i == params->nrofdeviceproperties) { params->deviceproperties = realloc(params->deviceproperties,(i+1)*sizeof(params->deviceproperties[0])); memset(¶ms->deviceproperties[i],0,sizeof(params->deviceproperties[0])); diff --git a/camlibs/ptp2/ptp.h b/camlibs/ptp2/ptp.h index fd7823621..a0da4ed10 100644 --- a/camlibs/ptp2/ptp.h +++ b/camlibs/ptp2/ptp.h @@ -2068,7 +2068,8 @@ typedef struct _PTPCanonEOSDeviceInfo { #define PTP_DPC_SONY_ColorTemp 0xD20F #define PTP_DPC_SONY_CCFilter 0xD210 #define PTP_DPC_SONY_AspectRatio 0xD211 -#define PTP_DPC_SONY_ObjectInMemory 0xD215 /* used to signal when to retrieve new object */ +#define PTP_DPC_SONY_FocusFound 0xD213 /* seems to be signaled (1->2) when focus is achieved */ +#define PTP_DPC_SONY_ObjectInMemory 0xD215 /* used to signal when to retrieve new object */ #define PTP_DPC_SONY_ExposeIndex 0xD216 #define PTP_DPC_SONY_PictureEffect 0xD21B #define PTP_DPC_SONY_ABFilter 0xD21C |