diff options
-rw-r--r-- | src/ptp-pack.c | 63 | ||||
-rw-r--r-- | src/ptp.c | 478 | ||||
-rw-r--r-- | src/ptp.h | 30 |
3 files changed, 541 insertions, 30 deletions
diff --git a/src/ptp-pack.c b/src/ptp-pack.c index e3e9a2c..5df73d0 100644 --- a/src/ptp-pack.c +++ b/src/ptp-pack.c @@ -2129,7 +2129,7 @@ ptp_unpack_CANON_changes (PTPParams *params, unsigned char* data, unsigned int d break; } - ptp_debug (params, "event %d: EOS prop %04x desc record, datasize %d, propxtype %d", i, proptype, size-PTP_ece_Prop_Desc_Data, propxtype); + ptp_debug (params, "event %d: EOS prop %04x (%s) desc record, datasize %d, propxtype %d", i, proptype, ptp_get_property_description (params, proptype), size-PTP_ece_Prop_Desc_Data, propxtype); for (j=0;j<params->nrofcanon_props;j++) if (params->canon_props[j].proptype == proptype) break; @@ -2217,7 +2217,7 @@ ptp_unpack_CANON_changes (PTPParams *params, unsigned char* data, unsigned int d ptp_debug (params, "size %d is smaller than %d", size, PTP_ece_Prop_Val_Data); break; } - ptp_debug (params, "event %d: EOS prop %04x info record, datasize is %d", i, proptype, size-PTP_ece_Prop_Val_Data); + ptp_debug (params, "event %d: EOS prop %04x (%s) info record, datasize is %d", i, proptype, ptp_get_property_description(params,proptype), size-PTP_ece_Prop_Val_Data); for (j=0;j<params->nrofcanon_props;j++) if (params->canon_props[j].proptype == proptype) break; @@ -2867,6 +2867,65 @@ ptp_unpack_Nikon_EC (PTPParams *params, unsigned char* data, unsigned int len, P } } +/* + * PTP USB Event container unpack for Nikon events, 2nd generation. + */ +#define PTP_nikon_ec_ex_Length 0 +#define PTP_nikon_ec_ex_Code 2 + +static inline int +ptp_unpack_Nikon_EC_EX (PTPParams *params, unsigned char* data, unsigned int len, PTPContainer **ec, unsigned int *cnt) +{ + unsigned int i, offset; + + *ec = NULL; + if (data == NULL) + return 0; + if (len < PTP_nikon_ec_ex_Code) + return 0; + *cnt = dtoh16a(&data[PTP_nikon_ec_ex_Length]); + if (*cnt > (len-PTP_nikon_ec_ex_Code)/4) { /* broken cnt? simple first check ... due to dynamic size, we need to do more later */ + *cnt = 0; + return 0; + } + if (!*cnt) + return 1; + + *ec = malloc(sizeof(PTPContainer)*(*cnt)); + offset = PTP_nikon_ec_ex_Code+sizeof(uint16_t); + + for (i=0;i<*cnt;i++) { + memset(&(*ec)[i],0,sizeof(PTPContainer)); + if (len - offset < 4) { + free (*ec); + *ec = NULL; + *cnt = 0; + return 0; + } + (*ec)[i].Code = dtoh16a(&data[offset]); + (*ec)[i].Nparam = dtoh16a(&data[offset+2]); + ptp_debug (params, "nikon eventex %d: code 0x%04x, params %d", i, (*ec)[i].Code, (*ec)[i].Nparam); + if ( ((*ec)[i].Nparam > 5) || + (len < ((*ec)[i].Nparam*sizeof(uint32_t)) + 4 + offset) + ) { + free (*ec); + *ec = NULL; + *cnt = 0; + return 0; + } + switch ((*ec)[i].Nparam) { + case 5: (*ec)[i].Param5 = dtoh32a(&data[offset+4+sizeof(uint32_t)*4]);/* fallthrough */ + case 4: (*ec)[i].Param4 = dtoh32a(&data[offset+4+sizeof(uint32_t)*3]);/* fallthrough */ + case 3: (*ec)[i].Param3 = dtoh32a(&data[offset+4+sizeof(uint32_t)*2]);/* fallthrough */ + case 2: (*ec)[i].Param2 = dtoh32a(&data[offset+4+sizeof(uint32_t)*1]);/* fallthrough */ + case 1: (*ec)[i].Param1 = dtoh32a(&data[offset+4]); + /* fallthrough */ + case 0: break; + } + offset += (*ec)[i].Nparam*sizeof(uint32_t) + 4; + } + return 1; +} static inline uint32_t ptp_pack_EK_text(PTPParams *params, PTPEKTextParams *text, unsigned char **data) { @@ -1881,6 +1881,32 @@ ptp_getpartialobject_to_handler (PTPParams* params, uint32_t handle, uint32_t of } /** + * ptp_nikon_getpartialobjectex: + * params: PTPParams* + * handle - Object handle + * offset - 64bit offset into object + * maxbytes - 64bit maximum of bytes to read + * handler - a ptp pata handler + * + * Get object 'handle' from device and send the data to the + * data handler. Start from offset and read at most maxbytes. + * + * Return values: Some PTP_RC_* code. + **/ +uint16_t +ptp_nikon_getpartialobjectex (PTPParams* params, uint32_t handle, uint64_t offset, + uint64_t maxbytes, unsigned char** object, + uint32_t *len) +{ + PTPContainer ptp; + + /* casts due to varargs otherwise pushing 64bit values on the stack */ + PTP_CNT_INIT(ptp, PTP_OC_NIKON_GetPartialObjectEx, handle, ((uint32_t)offset & 0xFFFFFFFF), (uint32_t)(offset >> 32), ((uint32_t)maxbytes & 0xFFFFFFFF), (uint32_t)(maxbytes >> 32)); + return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, object, len); +} + + +/** * ptp_getthumb: * params: PTPParams* * handle - Object handle @@ -1921,6 +1947,39 @@ ptp_nikon_getlargethumb (PTPParams* params, uint32_t handle, unsigned char** obj } /** + * ptp_nikon_getobjectsize: + * params: PTPParams* + * handle - Object handle + * objectsize - size of object + * + * Get the 64bit objectsize for object 'handle' from device and store the size in objectsize + * allocated 'object'. This function is Nikon specific. + * + * Return values: Some PTP_RC_* code. + **/ +uint16_t +ptp_nikon_getobjectsize (PTPParams* params, uint32_t handle, uint64_t *objectsize) +{ + PTPContainer ptp; + unsigned char *data = NULL; + unsigned int size = 0; + + *objectsize = 0; + + PTP_CNT_INIT(ptp, PTP_OC_NIKON_GetObjectSize, handle); + CHECK_PTP_RC (ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size)); + + if (size < 8) { + free (data); + return PTP_RC_GeneralError; + } + + *objectsize = dtoh64ap(params, data); + free (data); + return PTP_RC_OK; +} + +/** * ptp_deleteobject: * params: PTPParams* * handle - object handle @@ -2967,31 +3026,53 @@ ptp_check_event (PTPParams *params) PTPContainer event; uint16_t ret; - /* Method offered by Nikon DSLR, Nikon 1, and some older Nikon Coolpix P* - * The Nikon Coolpix P2 however does not return anything. So if we never get - * events from here, use the ptp "interrupt" method */ - if ( (params->deviceinfo.VendorExtensionID == PTP_VENDOR_NIKON) && - ptp_operation_issupported(params, PTP_OC_NIKON_GetEvent) - ) { - unsigned int evtcnt = 0, i; - PTPContainer *xevent = NULL; - - ret = ptp_nikon_check_event(params, &xevent, &evtcnt); - if (ret != PTP_RC_OperationNotSupported) - CHECK_PTP_RC(ret); - - if (evtcnt) { - for (i = 0; i < evtcnt; i++) - handle_event_internal (params, &xevent[i]); - params->events = realloc(params->events, sizeof(PTPContainer)*(evtcnt+params->nrofevents)); - memcpy (¶ms->events[params->nrofevents],xevent,evtcnt*sizeof(PTPContainer)); - params->nrofevents += evtcnt; - params->event90c7works = 1; + if (params->deviceinfo.VendorExtensionID == PTP_VENDOR_NIKON) { + if (ptp_operation_issupported(params, PTP_OC_NIKON_GetEventEx)) { + unsigned int evtcnt = 0, i; + PTPContainer *xevent = NULL; + + ret = ptp_nikon_check_eventex(params, &xevent, &evtcnt); + if (ret != PTP_RC_OperationNotSupported) + CHECK_PTP_RC(ret); + + if (evtcnt) { + for (i = 0; i < evtcnt; i++) + handle_event_internal (params, &xevent[i]); + params->events = realloc(params->events, sizeof(PTPContainer)*(evtcnt+params->nrofevents)); + memcpy (¶ms->events[params->nrofevents],xevent,evtcnt*sizeof(PTPContainer)); + params->nrofevents += evtcnt; + params->event90c7works = 1; + } + free (xevent); + if (params->event90c7works) + return PTP_RC_OK; + /* fall through to generic event handling */ + } else { + /* Method offered by Nikon DSLR, Nikon 1, and some older Nikon Coolpix P* + * The Nikon Coolpix P2 however does not return anything. So if we never get + * events from here, use the ptp "interrupt" method */ + if (ptp_operation_issupported(params, PTP_OC_NIKON_GetEvent)) { + unsigned int evtcnt = 0, i; + PTPContainer *xevent = NULL; + + ret = ptp_nikon_check_event(params, &xevent, &evtcnt); + if (ret != PTP_RC_OperationNotSupported) + CHECK_PTP_RC(ret); + + if (evtcnt) { + for (i = 0; i < evtcnt; i++) + handle_event_internal (params, &xevent[i]); + params->events = realloc(params->events, sizeof(PTPContainer)*(evtcnt+params->nrofevents)); + memcpy (¶ms->events[params->nrofevents],xevent,evtcnt*sizeof(PTPContainer)); + params->nrofevents += evtcnt; + params->event90c7works = 1; + } + free (xevent); + if (params->event90c7works) + return PTP_RC_OK; + /* fall through to generic event handling */ + } } - free (xevent); - if (params->event90c7works) - return PTP_RC_OK; - /* fall through to generic event handling */ } /* should not get here ... EOS has no normal PTP events and another queue handling. */ if ( (params->deviceinfo.VendorExtensionID == PTP_VENDOR_CANON) && @@ -3058,7 +3139,6 @@ ptp_wait_event (PTPParams *params) return ret; } - int ptp_get_one_event(PTPParams *params, PTPContainer *event) { @@ -3076,6 +3156,63 @@ ptp_get_one_event(PTPParams *params, PTPContainer *event) } /** + * ptp_get_one_event_by_type: + * + * Check if one specific event has appeared in the queue, and return it back to us, and remove it from the queue. + + * params: PTPParams* in: params + * code in: event code + * event out: event container + * + * Return values: 1 if removed, 0 if not. + */ +int +ptp_get_one_event_by_type(PTPParams *params, uint16_t code, PTPContainer *event) +{ + unsigned int i; + + if (!params->nrofevents) + return 0; + for (i=0;i<params->nrofevents;i++) { + if (params->events[i].Code == code) { + memcpy (event, params->events+i, sizeof(PTPContainer)); + memmove (params->events+i, params->events+i+1, sizeof(PTPContainer)*(params->nrofevents-i-1)); + /* do not realloc on shrink. */ + params->nrofevents--; + if (!params->nrofevents) { + free (params->events); + params->events = NULL; + } + return 1; + } + } + return 0; +} + +/** + * ptp_have_event: + * + * Check if one specific event has appeared in the queue, without draining it. + * + * params: PTPParams* in: params + * code in: event code + * + * Return values: 1 if removed, 0 if not. + */ +int +ptp_have_event(PTPParams *params, uint16_t code) +{ + unsigned int i; + + if (!params->nrofevents) + return 0; + for (i=0;i<params->nrofevents;i++) + if (params->events[i].Code == code) + return 1; + return 0; +} + +/** * ptp_canon_eos_getevent: * * This retrieves configuration status/updates/changes @@ -4317,7 +4454,8 @@ ptp_canon_eos_get_viewfinder_image (PTPParams* params, unsigned char **data, uns { PTPContainer ptp; - PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_GetViewFinderData, 0x00100000 /* from trace */); + /* Saw 3 arguments ... 0x00200000 for EOS1000D, also used 0x00100000 */ + PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_GetViewFinderData, 0x00200000 /* from trace */, 0, 0); return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); } @@ -4326,7 +4464,8 @@ ptp_canon_eos_get_viewfinder_image_handler (PTPParams* params, PTPDataHandler*ha { PTPContainer ptp; - PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_GetViewFinderData, 0x00100000 /* from trace */); + /* Saw 3 arguments ... 0x00200000 for EOS1000D, also used 0x00100000 */ + PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_GetViewFinderData, 0x00200000 /* from trace */, 0, 0); return ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, handler); } @@ -4358,6 +4497,33 @@ ptp_nikon_check_event (PTPParams* params, PTPContainer** event, unsigned int* ev } /** + * ptp_nikon_check_eventex: + * + * This command checks the event queue on the Nikon. + * + * params: PTPParams* + * PTPUSBEventContainer **event - list of usb events. + * int *evtcnt - number of usb events in event structure. + * + * Return values: Some PTP_RC_* code. + * + **/ +uint16_t +ptp_nikon_check_eventex (PTPParams* params, PTPContainer** event, unsigned int* evtcnt) +{ + PTPContainer ptp; + unsigned char *data = NULL; + unsigned int size; + + PTP_CNT_INIT(ptp, PTP_OC_NIKON_GetEventEx); + *evtcnt = 0; + CHECK_PTP_RC(ptp_transaction (params, &ptp, PTP_DP_GETDATA, 0, &data, &size)); + ptp_unpack_Nikon_EC_EX (params, data, size, event, evtcnt); + free (data); + return PTP_RC_OK; +} + +/** * ptp_nikon_getptpipinfo: * * This command gets the ptpip info data. @@ -5543,6 +5709,239 @@ ptp_get_property_description(PTPParams* params, uint16_t dpc) {PTP_DPC_CANON_TypeOfSupportedSlideShow, N_("Type of Slideshow")}, {PTP_DPC_CANON_AverageFilesizes,N_("Average Filesizes")}, {PTP_DPC_CANON_ModelID, N_("Model ID")}, + {PTP_DPC_CANON_EOS_FixedMovie, N_("EOS Fixed Movie Switch")}, + + {PTP_DPC_CANON_EOS_PowerZoomPosition,"EOS_PowerZoomPosition"}, + {PTP_DPC_CANON_EOS_StrobeSettingSimple,"EOS_StrobeSettingSimple"}, + {PTP_DPC_CANON_EOS_ConnectTrigger,"EOS_ConnectTrigger"}, + {PTP_DPC_CANON_EOS_ChangeCameraMode,"EOS_ChangeCameraMode"}, + {PTP_DPC_CANON_EOS_Aperture,"EOS_Aperture"}, + {PTP_DPC_CANON_EOS_ShutterSpeed,"EOS_ShutterSpeed"}, + {PTP_DPC_CANON_EOS_ISOSpeed,"EOS_ISOSpeed"}, + {PTP_DPC_CANON_EOS_ExpCompensation,"EOS_ExpCompensation"}, + {PTP_DPC_CANON_EOS_AutoExposureMode,"EOS_AutoExposureMode"}, + {PTP_DPC_CANON_EOS_DriveMode,"EOS_DriveMode"}, + {PTP_DPC_CANON_EOS_MeteringMode,"EOS_MeteringMode"}, + {PTP_DPC_CANON_EOS_FocusMode,"EOS_FocusMode"}, + {PTP_DPC_CANON_EOS_WhiteBalance,"EOS_WhiteBalance"}, + {PTP_DPC_CANON_EOS_ColorTemperature,"EOS_ColorTemperature"}, + {PTP_DPC_CANON_EOS_WhiteBalanceAdjustA,"EOS_WhiteBalanceAdjustA"}, + {PTP_DPC_CANON_EOS_WhiteBalanceAdjustB,"EOS_WhiteBalanceAdjustB"}, + {PTP_DPC_CANON_EOS_WhiteBalanceXA,"EOS_WhiteBalanceXA"}, + {PTP_DPC_CANON_EOS_WhiteBalanceXB,"EOS_WhiteBalanceXB"}, + {PTP_DPC_CANON_EOS_ColorSpace,"EOS_ColorSpace"}, + {PTP_DPC_CANON_EOS_PictureStyle,"EOS_PictureStyle"}, + {PTP_DPC_CANON_EOS_BatteryPower,"EOS_BatteryPower"}, + {PTP_DPC_CANON_EOS_BatterySelect,"EOS_BatterySelect"}, + {PTP_DPC_CANON_EOS_CameraTime,"EOS_CameraTime"}, + {PTP_DPC_CANON_EOS_AutoPowerOff,"EOS_AutoPowerOff"}, + {PTP_DPC_CANON_EOS_Owner,"EOS_Owner"}, + {PTP_DPC_CANON_EOS_ModelID,"EOS_ModelID"}, + {PTP_DPC_CANON_EOS_PTPExtensionVersion,"EOS_PTPExtensionVersion"}, + {PTP_DPC_CANON_EOS_DPOFVersion,"EOS_DPOFVersion"}, + {PTP_DPC_CANON_EOS_AvailableShots,"EOS_AvailableShots"}, + {PTP_DPC_CANON_EOS_CaptureDestination,"EOS_CaptureDestination"}, + {PTP_DPC_CANON_EOS_BracketMode,"EOS_BracketMode"}, + {PTP_DPC_CANON_EOS_CurrentStorage,"EOS_CurrentStorage"}, + {PTP_DPC_CANON_EOS_CurrentFolder,"EOS_CurrentFolder"}, + {PTP_DPC_CANON_EOS_ImageFormat,"EOS_ImageFormat"}, + {PTP_DPC_CANON_EOS_ImageFormatCF,"EOS_ImageFormatCF"}, + {PTP_DPC_CANON_EOS_ImageFormatSD,"EOS_ImageFormatSD"}, + {PTP_DPC_CANON_EOS_ImageFormatExtHD,"EOS_ImageFormatExtHD"}, + {PTP_DPC_CANON_EOS_RefocusState,"EOS_RefocusState"}, + {PTP_DPC_CANON_EOS_CameraNickname,"EOS_CameraNickname"}, + {PTP_DPC_CANON_EOS_StroboSettingExpCompositionControl,"EOS_StroboSettingExpCompositionControl"}, + {PTP_DPC_CANON_EOS_ConnectStatus,"EOS_ConnectStatus"}, + {PTP_DPC_CANON_EOS_LensBarrelStatus,"EOS_LensBarrelStatus"}, + {PTP_DPC_CANON_EOS_SilentShutterSetting,"EOS_SilentShutterSetting"}, + {PTP_DPC_CANON_EOS_LV_AF_EyeDetect,"EOS_LV_AF_EyeDetect"}, + {PTP_DPC_CANON_EOS_AutoTransMobile,"EOS_AutoTransMobile"}, + {PTP_DPC_CANON_EOS_URLSupportFormat,"EOS_URLSupportFormat"}, + {PTP_DPC_CANON_EOS_SpecialAcc,"EOS_SpecialAcc"}, + {PTP_DPC_CANON_EOS_CompressionS,"EOS_CompressionS"}, + {PTP_DPC_CANON_EOS_CompressionM1,"EOS_CompressionM1"}, + {PTP_DPC_CANON_EOS_CompressionM2,"EOS_CompressionM2"}, + {PTP_DPC_CANON_EOS_CompressionL,"EOS_CompressionL"}, + {PTP_DPC_CANON_EOS_IntervalShootSetting,"EOS_IntervalShootSetting"}, + {PTP_DPC_CANON_EOS_IntervalShootState,"EOS_IntervalShootState"}, + {PTP_DPC_CANON_EOS_PushMode,"EOS_PushMode"}, + {PTP_DPC_CANON_EOS_LvCFilterKind,"EOS_LvCFilterKind"}, + {PTP_DPC_CANON_EOS_AEModeDial,"EOS_AEModeDial"}, + {PTP_DPC_CANON_EOS_AEModeCustom,"EOS_AEModeCustom"}, + {PTP_DPC_CANON_EOS_MirrorUpSetting,"EOS_MirrorUpSetting"}, + {PTP_DPC_CANON_EOS_HighlightTonePriority,"EOS_HighlightTonePriority"}, + {PTP_DPC_CANON_EOS_AFSelectFocusArea,"EOS_AFSelectFocusArea"}, + {PTP_DPC_CANON_EOS_HDRSetting,"EOS_HDRSetting"}, + {PTP_DPC_CANON_EOS_TimeShootSetting,"EOS_TimeShootSetting"}, + {PTP_DPC_CANON_EOS_NFCApplicationInfo,"EOS_NFCApplicationInfo"}, + {PTP_DPC_CANON_EOS_PCWhiteBalance1,"EOS_PCWhiteBalance1"}, + {PTP_DPC_CANON_EOS_PCWhiteBalance2,"EOS_PCWhiteBalance2"}, + {PTP_DPC_CANON_EOS_PCWhiteBalance3,"EOS_PCWhiteBalance3"}, + {PTP_DPC_CANON_EOS_PCWhiteBalance4,"EOS_PCWhiteBalance4"}, + {PTP_DPC_CANON_EOS_PCWhiteBalance5,"EOS_PCWhiteBalance5"}, + {PTP_DPC_CANON_EOS_MWhiteBalance,"EOS_MWhiteBalance"}, + {PTP_DPC_CANON_EOS_MWhiteBalanceEx,"EOS_MWhiteBalanceEx"}, + {PTP_DPC_CANON_EOS_PowerZoomSpeed,"EOS_PowerZoomSpeed"}, + {PTP_DPC_CANON_EOS_NetworkServerRegion,"EOS_NetworkServerRegion"}, + {PTP_DPC_CANON_EOS_GPSLogCtrl,"EOS_GPSLogCtrl"}, + {PTP_DPC_CANON_EOS_GPSLogListNum,"EOS_GPSLogListNum"}, + {PTP_DPC_CANON_EOS_UnknownPropD14D,"EOS_UnknownPropD14D"}, + {PTP_DPC_CANON_EOS_PictureStyleStandard,"EOS_PictureStyleStandard"}, + {PTP_DPC_CANON_EOS_PictureStylePortrait,"EOS_PictureStylePortrait"}, + {PTP_DPC_CANON_EOS_PictureStyleLandscape,"EOS_PictureStyleLandscape"}, + {PTP_DPC_CANON_EOS_PictureStyleNeutral,"EOS_PictureStyleNeutral"}, + {PTP_DPC_CANON_EOS_PictureStyleFaithful,"EOS_PictureStyleFaithful"}, + {PTP_DPC_CANON_EOS_PictureStyleBlackWhite,"EOS_PictureStyleBlackWhite"}, + {PTP_DPC_CANON_EOS_PictureStyleAuto,"EOS_PictureStyleAuto"}, + {PTP_DPC_CANON_EOS_PictureStyleExStandard,"EOS_PictureStyleExStandard"}, + {PTP_DPC_CANON_EOS_PictureStyleExPortrait,"EOS_PictureStyleExPortrait"}, + {PTP_DPC_CANON_EOS_PictureStyleExLandscape,"EOS_PictureStyleExLandscape"}, + {PTP_DPC_CANON_EOS_PictureStyleExNeutral,"EOS_PictureStyleExNeutral"}, + {PTP_DPC_CANON_EOS_PictureStyleExFaithful,"EOS_PictureStyleExFaithful"}, + {PTP_DPC_CANON_EOS_PictureStyleExBlackWhite,"EOS_PictureStyleExBlackWhite"}, + {PTP_DPC_CANON_EOS_PictureStyleExAuto,"EOS_PictureStyleExAuto"}, + {PTP_DPC_CANON_EOS_PictureStyleExFineDetail,"EOS_PictureStyleExFineDetail"}, + {PTP_DPC_CANON_EOS_PictureStyleUserSet1,"EOS_PictureStyleUserSet1"}, + {PTP_DPC_CANON_EOS_PictureStyleUserSet2,"EOS_PictureStyleUserSet2"}, + {PTP_DPC_CANON_EOS_PictureStyleUserSet3,"EOS_PictureStyleUserSet3"}, + {PTP_DPC_CANON_EOS_PictureStyleExUserSet1,"EOS_PictureStyleExUserSet1"}, + {PTP_DPC_CANON_EOS_PictureStyleExUserSet2,"EOS_PictureStyleExUserSet2"}, + {PTP_DPC_CANON_EOS_PictureStyleExUserSet3,"EOS_PictureStyleExUserSet3"}, + {PTP_DPC_CANON_EOS_MovieAVModeFine,"EOS_MovieAVModeFine"}, + {PTP_DPC_CANON_EOS_ShutterReleaseCounter,"EOS_ShutterReleaseCounter"}, + {PTP_DPC_CANON_EOS_AvailableImageSize,"EOS_AvailableImageSize"}, + {PTP_DPC_CANON_EOS_ErrorHistory,"EOS_ErrorHistory"}, + {PTP_DPC_CANON_EOS_LensExchangeHistory,"EOS_LensExchangeHistory"}, + {PTP_DPC_CANON_EOS_StroboExchangeHistory,"EOS_StroboExchangeHistory"}, + {PTP_DPC_CANON_EOS_PictureStyleParam1,"EOS_PictureStyleParam1"}, + {PTP_DPC_CANON_EOS_PictureStyleParam2,"EOS_PictureStyleParam2"}, + {PTP_DPC_CANON_EOS_PictureStyleParam3,"EOS_PictureStyleParam3"}, + {PTP_DPC_CANON_EOS_MovieRecordVolumeLine,"EOS_MovieRecordVolumeLine"}, + {PTP_DPC_CANON_EOS_NetworkCommunicationMode,"EOS_NetworkCommunicationMode"}, + {PTP_DPC_CANON_EOS_CanonLogGamma,"EOS_CanonLogGamma"}, + {PTP_DPC_CANON_EOS_SmartphoneShowImageConfig,"EOS_SmartphoneShowImageConfig"}, + {PTP_DPC_CANON_EOS_HighISOSettingNoiseReduction,"EOS_HighISOSettingNoiseReduction"}, + {PTP_DPC_CANON_EOS_MovieServoAF,"EOS_MovieServoAF"}, + {PTP_DPC_CANON_EOS_ContinuousAFValid,"EOS_ContinuousAFValid"}, + {PTP_DPC_CANON_EOS_Attenuator,"EOS_Attenuator"}, + {PTP_DPC_CANON_EOS_UTCTime,"EOS_UTCTime"}, + {PTP_DPC_CANON_EOS_Timezone,"EOS_Timezone"}, + {PTP_DPC_CANON_EOS_Summertime,"EOS_Summertime"}, + {PTP_DPC_CANON_EOS_FlavorLUTParams,"EOS_FlavorLUTParams"}, + {PTP_DPC_CANON_EOS_CustomFunc1,"EOS_CustomFunc1"}, + {PTP_DPC_CANON_EOS_CustomFunc2,"EOS_CustomFunc2"}, + {PTP_DPC_CANON_EOS_CustomFunc3,"EOS_CustomFunc3"}, + {PTP_DPC_CANON_EOS_CustomFunc4,"EOS_CustomFunc4"}, + {PTP_DPC_CANON_EOS_CustomFunc5,"EOS_CustomFunc5"}, + {PTP_DPC_CANON_EOS_CustomFunc6,"EOS_CustomFunc6"}, + {PTP_DPC_CANON_EOS_CustomFunc7,"EOS_CustomFunc7"}, + {PTP_DPC_CANON_EOS_CustomFunc8,"EOS_CustomFunc8"}, + {PTP_DPC_CANON_EOS_CustomFunc9,"EOS_CustomFunc9"}, + {PTP_DPC_CANON_EOS_CustomFunc10,"EOS_CustomFunc10"}, + {PTP_DPC_CANON_EOS_CustomFunc11,"EOS_CustomFunc11"}, + {PTP_DPC_CANON_EOS_CustomFunc12,"EOS_CustomFunc12"}, + {PTP_DPC_CANON_EOS_CustomFunc13,"EOS_CustomFunc13"}, + {PTP_DPC_CANON_EOS_CustomFunc14,"EOS_CustomFunc14"}, + {PTP_DPC_CANON_EOS_CustomFunc15,"EOS_CustomFunc15"}, + {PTP_DPC_CANON_EOS_CustomFunc16,"EOS_CustomFunc16"}, + {PTP_DPC_CANON_EOS_CustomFunc17,"EOS_CustomFunc17"}, + {PTP_DPC_CANON_EOS_CustomFunc18,"EOS_CustomFunc18"}, + {PTP_DPC_CANON_EOS_CustomFunc19,"EOS_CustomFunc19"}, + {PTP_DPC_CANON_EOS_CustomFunc19,"EOS_CustomFunc19"}, + {PTP_DPC_CANON_EOS_InnerDevelop,"EOS_InnerDevelop"}, + {PTP_DPC_CANON_EOS_MultiAspect,"EOS_MultiAspect"}, + {PTP_DPC_CANON_EOS_MovieSoundRecord,"EOS_MovieSoundRecord"}, + {PTP_DPC_CANON_EOS_MovieRecordVolume,"EOS_MovieRecordVolume"}, + {PTP_DPC_CANON_EOS_WindCut,"EOS_WindCut"}, + {PTP_DPC_CANON_EOS_ExtenderType,"EOS_ExtenderType"}, + {PTP_DPC_CANON_EOS_OLCInfoVersion,"EOS_OLCInfoVersion"}, + {PTP_DPC_CANON_EOS_UnknownPropD19A,"EOS_UnknownPropD19A"}, + {PTP_DPC_CANON_EOS_UnknownPropD19C,"EOS_UnknownPropD19C"}, + {PTP_DPC_CANON_EOS_UnknownPropD19D,"EOS_UnknownPropD19D"}, + {PTP_DPC_CANON_EOS_GPSDeviceActive,"EOS_GPSDeviceActive"}, + {PTP_DPC_CANON_EOS_CustomFuncEx,"EOS_CustomFuncEx"}, + {PTP_DPC_CANON_EOS_MyMenu,"EOS_MyMenu"}, + {PTP_DPC_CANON_EOS_MyMenuList,"EOS_MyMenuList"}, + {PTP_DPC_CANON_EOS_WftStatus,"EOS_WftStatus"}, + {PTP_DPC_CANON_EOS_WftInputTransmission,"EOS_WftInputTransmission"}, + {PTP_DPC_CANON_EOS_HDDirectoryStructure,"EOS_HDDirectoryStructure"}, + {PTP_DPC_CANON_EOS_BatteryInfo,"EOS_BatteryInfo"}, + {PTP_DPC_CANON_EOS_AdapterInfo,"EOS_AdapterInfo"}, + {PTP_DPC_CANON_EOS_LensStatus,"EOS_LensStatus"}, + {PTP_DPC_CANON_EOS_QuickReviewTime,"EOS_QuickReviewTime"}, + {PTP_DPC_CANON_EOS_CardExtension,"EOS_CardExtension"}, + {PTP_DPC_CANON_EOS_TempStatus,"EOS_TempStatus"}, + {PTP_DPC_CANON_EOS_ShutterCounter,"EOS_ShutterCounter"}, + {PTP_DPC_CANON_EOS_SpecialOption,"EOS_SpecialOption"}, + {PTP_DPC_CANON_EOS_PhotoStudioMode,"EOS_PhotoStudioMode"}, + {PTP_DPC_CANON_EOS_SerialNumber,"EOS_SerialNumber"}, + {PTP_DPC_CANON_EOS_EVFOutputDevice,"EOS_EVFOutputDevice"}, + {PTP_DPC_CANON_EOS_EVFMode,"EOS_EVFMode"}, + {PTP_DPC_CANON_EOS_DepthOfFieldPreview,"EOS_DepthOfFieldPreview"}, + {PTP_DPC_CANON_EOS_EVFSharpness,"EOS_EVFSharpness"}, + {PTP_DPC_CANON_EOS_EVFWBMode,"EOS_EVFWBMode"}, + {PTP_DPC_CANON_EOS_EVFClickWBCoeffs,"EOS_EVFClickWBCoeffs"}, + {PTP_DPC_CANON_EOS_EVFColorTemp,"EOS_EVFColorTemp"}, + {PTP_DPC_CANON_EOS_ExposureSimMode,"EOS_ExposureSimMode"}, + {PTP_DPC_CANON_EOS_EVFRecordStatus,"EOS_EVFRecordStatus"}, + {PTP_DPC_CANON_EOS_LvAfSystem,"EOS_LvAfSystem"}, + {PTP_DPC_CANON_EOS_MovSize,"EOS_MovSize"}, + {PTP_DPC_CANON_EOS_LvViewTypeSelect,"EOS_LvViewTypeSelect"}, + {PTP_DPC_CANON_EOS_MirrorDownStatus,"EOS_MirrorDownStatus"}, + {PTP_DPC_CANON_EOS_MovieParam,"EOS_MovieParam"}, + {PTP_DPC_CANON_EOS_MirrorLockupState,"EOS_MirrorLockupState"}, + {PTP_DPC_CANON_EOS_FlashChargingState,"EOS_FlashChargingState"}, + {PTP_DPC_CANON_EOS_AloMode,"EOS_AloMode"}, + {PTP_DPC_CANON_EOS_OneShotRawOn,"EOS_OneShotRawOn"}, + {PTP_DPC_CANON_EOS_ErrorForDisplay,"EOS_ErrorForDisplay"}, + {PTP_DPC_CANON_EOS_AEModeMovie,"EOS_AEModeMovie"}, + {PTP_DPC_CANON_EOS_BuiltinStroboMode,"EOS_BuiltinStroboMode"}, + {PTP_DPC_CANON_EOS_StroboDispState,"EOS_StroboDispState"}, + {PTP_DPC_CANON_EOS_StroboETTL2Metering,"EOS_StroboETTL2Metering"}, + {PTP_DPC_CANON_EOS_ContinousAFMode,"EOS_ContinousAFMode"}, + {PTP_DPC_CANON_EOS_MovieParam2,"EOS_MovieParam2"}, + {PTP_DPC_CANON_EOS_StroboSettingExpComposition,"EOS_StroboSettingExpComposition"}, + {PTP_DPC_CANON_EOS_MovieParam3,"EOS_MovieParam3"}, + {PTP_DPC_CANON_EOS_MovieParam4,"EOS_MovieParam4"}, + {PTP_DPC_CANON_EOS_LVMedicalRotate,"EOS_LVMedicalRotate"}, + {PTP_DPC_CANON_EOS_Artist,"EOS_Artist"}, + {PTP_DPC_CANON_EOS_Copyright,"EOS_Copyright"}, + {PTP_DPC_CANON_EOS_BracketValue,"EOS_BracketValue"}, + {PTP_DPC_CANON_EOS_FocusInfoEx,"EOS_FocusInfoEx"}, + {PTP_DPC_CANON_EOS_DepthOfField,"EOS_DepthOfField"}, + {PTP_DPC_CANON_EOS_Brightness,"EOS_Brightness"}, + {PTP_DPC_CANON_EOS_LensAdjustParams,"EOS_LensAdjustParams"}, + {PTP_DPC_CANON_EOS_EFComp,"EOS_EFComp"}, + {PTP_DPC_CANON_EOS_LensName,"EOS_LensName"}, + {PTP_DPC_CANON_EOS_AEB,"EOS_AEB"}, + {PTP_DPC_CANON_EOS_StroboSetting,"EOS_StroboSetting"}, + {PTP_DPC_CANON_EOS_StroboWirelessSetting,"EOS_StroboWirelessSetting"}, + {PTP_DPC_CANON_EOS_StroboFiring,"EOS_StroboFiring"}, + {PTP_DPC_CANON_EOS_LensID,"EOS_LensID"}, + {PTP_DPC_CANON_EOS_LCDBrightness,"EOS_LCDBrightness"}, + {PTP_DPC_CANON_EOS_CADarkBright,"EOS_CADarkBright"}, + {PTP_DPC_CANON_EOS_CAssistPreset,"EOS_CAssistPreset"}, + {PTP_DPC_CANON_EOS_CAssistBrightness,"EOS_CAssistBrightness"}, + {PTP_DPC_CANON_EOS_CAssistContrast,"EOS_CAssistContrast"}, + {PTP_DPC_CANON_EOS_CAssistSaturation,"EOS_CAssistSaturation"}, + {PTP_DPC_CANON_EOS_CAssistColorBA,"EOS_CAssistColorBA"}, + {PTP_DPC_CANON_EOS_CAssistColorMG,"EOS_CAssistColorMG"}, + {PTP_DPC_CANON_EOS_CAssistMonochrome,"EOS_CAssistMonochrome"}, + {PTP_DPC_CANON_EOS_FocusShiftSetting,"EOS_FocusShiftSetting"}, + {PTP_DPC_CANON_EOS_MovieSelfTimer,"EOS_MovieSelfTimer"}, + {PTP_DPC_CANON_EOS_Clarity,"EOS_Clarity"}, + {PTP_DPC_CANON_EOS_2GHDRSetting,"EOS_2GHDRSetting"}, + {PTP_DPC_CANON_EOS_MovieParam5,"EOS_MovieParam5"}, + {PTP_DPC_CANON_EOS_HDRViewAssistModeRec,"EOS_HDRViewAssistModeRec"}, + {PTP_DPC_CANON_EOS_PropFinderAFFrame,"EOS_PropFinderAFFrame"}, + {PTP_DPC_CANON_EOS_VariableMovieRecSetting,"EOS_VariableMovieRecSetting"}, + {PTP_DPC_CANON_EOS_PropAutoRotate,"EOS_PropAutoRotate"}, + {PTP_DPC_CANON_EOS_MFPeakingSetting,"EOS_MFPeakingSetting"}, + {PTP_DPC_CANON_EOS_MovieSpatialOversampling,"EOS_MovieSpatialOversampling"}, + {PTP_DPC_CANON_EOS_MovieCropMode,"EOS_MovieCropMode"}, + {PTP_DPC_CANON_EOS_ShutterType,"EOS_ShutterType"}, + {PTP_DPC_CANON_EOS_WFTBatteryPower,"EOS_WFTBatteryPower"}, + {PTP_DPC_CANON_EOS_BatteryInfoEx,"EOS_BatteryInfoEx"}, {0,NULL} }; @@ -7743,6 +8142,11 @@ ptp_opcode_trans_t ptp_opcode_nikon_trans[] = { {PTP_OC_NIKON_GetManualSettingLensData,"GetManualSettingLensData"}, {PTP_OC_NIKON_PowerZoomByFocalLength,"PowerZoomByFocalLength"}, {PTP_OC_NIKON_ActiveSelectionControl,"ActiveSelectionControl"}, + {PTP_OC_NIKON_ChangeMonitorOff,"ChangeMonitorOff"}, + {PTP_OC_NIKON_InitiatePixelMapping,"InitiatePixelMapping"}, + {PTP_OC_NIKON_GetObjectsMetaData,"GetObjectsMetaData"}, + {PTP_OC_NIKON_ChangeApplicationMode,"ChangeApplicationMode"}, + {PTP_OC_NIKON_ResetMenu,"ResetMenu"}, }; ptp_opcode_trans_t ptp_opcode_canon_trans[] = { @@ -8103,6 +8507,8 @@ struct { {PTP_EC_Nikon_SBRemoved, PTP_VENDOR_NIKON, "Nikon_SBRemoved"}, {PTP_EC_Nikon_SBAttrChanged, PTP_VENDOR_NIKON, "Nikon_SBAttrChanged"}, {PTP_EC_Nikon_SBGroupAttrChanged, PTP_VENDOR_NIKON, "Nikon_SBGroupAttrChanged"}, + {PTP_EC_Nikon_1stCaptureComplete, PTP_VENDOR_NIKON, "Nikon_1stCaptureComplete"}, + {PTP_EC_Nikon_MirrorUpCancelComplete, PTP_VENDOR_NIKON, "Nikon_MirrorUpCancelComplete"}, {PTP_EC_Sony_ObjectAdded, PTP_VENDOR_SONY, "Sony_ObjectAdded"}, {PTP_EC_Sony_ObjectRemoved, PTP_VENDOR_SONY, "Sony_ObjectRemoved"}, @@ -8573,6 +8979,24 @@ ptp_object_want (PTPParams *params, uint32_t handle, unsigned int want, PTPObjec if (ob->oi.ParentObject == handle) ob->oi.ParentObject = 0; + /* Detect if the file is larger than 4GB ... indicator is size 0xffffffff ... + * In that case explicitly request the MTP object proplist to get the right size */ + if (ob->oi.ObjectCompressedSize == 0xffffffffUL) { + uint64_t newsize; + if ( (params->deviceinfo.VendorExtensionID == PTP_VENDOR_NIKON) && + ptp_operation_issupported(params,PTP_OC_NIKON_GetObjectSize) && + (PTP_RC_OK == ptp_nikon_getobjectsize(params, handle, &newsize)) + ) { + ob->oi.ObjectCompressedSize = newsize; + goto read64bit; + } + /* more methods like e.g. for Canon */ + /* if not try MTP method */ + want |= PTPOBJECT_MTPPROPLIST_LOADED; + params->device_flags |= DEVICE_FLAG_PROPLIST_OVERRIDES_OI; /* FIXME: wild hack so below code works, needs review. */ +read64bit: ; + } + /* Apple iOS X does that for the root folder. */ if ((ob->oi.ParentObject == ob->oi.StorageID)) { PTPObject *parentob; @@ -441,6 +441,10 @@ typedef struct _PTPIPHeader PTPIPHeader; #define PTP_OC_CANON_EOS_SetRequestOLCInfoGroup 0x913D #define PTP_OC_CANON_EOS_SetRequestRollingPitchingLevel 0x913E /* 1 arg: onoff? */ /* 3 args, 0x21201020, 0x110, 0x1000000 (potentially reverse order) */ + +/* EOS M6 Mark2: opargs: 0x01000000, 0x000001020, 0 (supportkind, modelid ?), + response args: 0x00000811, 0x00000001 */ + #define PTP_OC_CANON_EOS_GetCameraSupport 0x913F #define PTP_OC_CANON_EOS_SetRating 0x9140 /* 2 args, objectid, rating? */ #define PTP_OC_CANON_EOS_RequestInnerDevelopStart 0x9141 /* 2 args: 1 type, 1 object? */ @@ -586,6 +590,7 @@ typedef struct _PTPIPHeader PTPIPHeader; #define PTP_OC_NIKON_ActiveSelectionControl 0x941f #define PTP_OC_NIKON_SaveCameraSetting 0x9420 #define PTP_OC_NIKON_GetObjectSize 0x9421 /* param: objecthandle, returns 64bit objectsize as DATA */ +#define PTP_OC_NIKON_ChangeMonitorOff 0x9422 #define PTP_OC_NIKON_GetLiveViewCompressedSize 0x9423 #define PTP_OC_NIKON_StartTracking 0x9424 #define PTP_OC_NIKON_EndTracking 0x9425 @@ -593,6 +598,10 @@ typedef struct _PTPIPHeader PTPIPHeader; #define PTP_OC_NIKON_GetLiveViewImageEx 0x9428 #define PTP_OC_NIKON_GetPartialObjectEx 0x9431 /* p1: objecthandle, p2: offset lower 32bit, p3: offset higher 32bit, p4: maxsize lower 32bit, p5: maxsize upper 32bit, response is r1: lower 32bit, r2: higher 32bit */ #define PTP_OC_NIKON_GetManualSettingLensData 0x9432 +#define PTP_OC_NIKON_InitiatePixelMapping 0x9433 +#define PTP_OC_NIKON_GetObjectsMetaData 0x9434 +#define PTP_OC_NIKON_ChangeApplicationMode 0x9435 +#define PTP_OC_NIKON_ResetMenu 0x9436 /* From Nikon V1 Trace */ @@ -1211,6 +1220,8 @@ typedef struct _PTPIPHeader PTPIPHeader; #define PTP_EC_Nikon_AdvancedTransfer 0xC103 #define PTP_EC_Nikon_PreviewImageAdded 0xC104 #define PTP_EC_Nikon_MovieRecordInterrupted 0xC105 /* e1: errocode, e2: recordkind */ +#define PTP_EC_Nikon_1stCaptureComplete 0xC106 /* 1st phase of mirror up is complete */ +#define PTP_EC_Nikon_MirrorUpCancelComplete 0xC107 /* mirror up canceling is complete */ #define PTP_EC_Nikon_MovieRecordComplete 0xC108 /* e1: recordkind */ #define PTP_EC_Nikon_MovieRecordStarted 0xC10A /* e1: recordkind */ #define PTP_EC_Nikon_PictureControlAdjustChanged 0xC10B /* e1: picctrlitem e2: shootingmode */ @@ -3636,7 +3647,7 @@ struct _PTPParams { /* PTP: the current event queue */ PTPContainer *events; - int nrofevents; + unsigned int nrofevents; /* Capture count for SDRAM capture style images */ unsigned int capcnt; @@ -3907,7 +3918,9 @@ uint16_t ptp_check_event (PTPParams *params); uint16_t ptp_check_event_queue (PTPParams *params); uint16_t ptp_wait_event (PTPParams *params); uint16_t ptp_add_event (PTPParams *params, PTPContainer *evt); +int ptp_have_event(PTPParams *params, uint16_t code); int ptp_get_one_event (PTPParams *params, PTPContainer *evt); +int ptp_get_one_event_by_type(PTPParams *params, uint16_t code, PTPContainer *event); uint16_t ptp_check_eos_events (PTPParams *params); int ptp_get_one_eos_event (PTPParams *params, PTPCanon_changes_entry *entry); @@ -4242,6 +4255,8 @@ uint16_t ptp_nikon_curve_download (PTPParams* params, unsigned char **data, unsigned int *size); uint16_t ptp_nikon_getlargethumb (PTPParams *params, uint32_t handle, unsigned char** object, unsigned int *len); +uint16_t ptp_nikon_getobjectsize (PTPParams* params, uint32_t handle, uint64_t *objectsize); +uint16_t ptp_nikon_getpartialobjectex (PTPParams* params, uint32_t handle, uint64_t offset, uint64_t maxbytes, unsigned char** object, uint32_t *len); uint16_t ptp_nikon_getptpipinfo (PTPParams* params, unsigned char **data, unsigned int *size); uint16_t ptp_nikon_getwifiprofilelist (PTPParams* params); uint16_t ptp_nikon_writewifiprofile (PTPParams* params, PTPNIKONWifiProfile* profile); @@ -4289,6 +4304,18 @@ uint16_t ptp_sony_9281 (PTPParams* params, uint32_t param1); **/ #define ptp_nikon_changecameramode(params,mode) ptp_generic_no_data(params,PTP_OC_NIKON_ChangeCameraMode,1,mode) /** + * ptp_nikon_changeapplicationmeramode: + * + * This command can switch the camera between PC control and remote mode. + * + * params: PTPParams* + * uint32_t mode - mode + * + * Return values: Some PTP_RC_* code. + * + **/ +#define ptp_nikon_changeapplicationmode(params,mode) ptp_generic_no_data(params,PTP_OC_NIKON_ChangeApplicationMode,1,mode) +/** * ptp_nikon_terminatecapture: * * This command appears to terminate a longer capture @@ -4487,6 +4514,7 @@ uint16_t ptp_nikon_get_preview_image (PTPParams* params, unsigned char**, unsign **/ #define ptp_nikon_end_liveview(params) ptp_generic_no_data(params,PTP_OC_NIKON_EndLiveView,0) uint16_t ptp_nikon_check_event (PTPParams* params, PTPContainer **evt, unsigned int *evtcnt); +uint16_t ptp_nikon_check_eventex (PTPParams* params, PTPContainer **evt, unsigned int *evtcnt); uint16_t ptp_nikon_getfileinfoinblock (PTPParams* params, uint32_t p1, uint32_t p2, uint32_t p3, unsigned char **data, unsigned int *size); /** |