Index: patches/02_check_ptp_operation_support.patch |
diff --git a/patches/02_check_ptp_operation_support.patch b/patches/02_check_ptp_operation_support.patch |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2338fefe562c2eab4faa9e13891916dd2d0de42c |
--- /dev/null |
+++ b/patches/02_check_ptp_operation_support.patch |
@@ -0,0 +1,98 @@ |
+Index: src/libmtp.c |
+=================================================================== |
+--- src/libmtp.c (revision 148597) |
++++ src/libmtp.c (working copy) |
+@@ -1144,6 +1144,9 @@ |
+ int supported = 0; |
+ uint16_t ptp_prop = map_libmtp_property_to_ptp_property(property); |
+ |
++ if (!ptp_operation_issupported(device->params, PTP_OC_MTP_GetObjectPropsSupported)) |
++ return 0; |
++ |
+ ret = ptp_mtp_getobjectpropssupported(device->params, map_libmtp_type_to_ptp_type(filetype), &propcnt, &props); |
+ if (ret != PTP_RC_OK) { |
+ add_ptp_error_to_errorstack(device, ret, "LIBMTP_Is_Property_Supported(): could not get properties supported."); |
+@@ -1974,40 +1977,42 @@ |
+ } |
+ |
+ /* Determine if the object size supported is 32 or 64 bit wide */ |
+- for (i=0;i<current_params->deviceinfo.ImageFormats_len;i++) { |
+- PTPObjectPropDesc opd; |
++ if (ptp_operation_issupported(current_params,PTP_OC_MTP_GetObjectPropsSupported)) { |
++ for (i=0;i<current_params->deviceinfo.ImageFormats_len;i++) { |
++ PTPObjectPropDesc opd; |
+ |
+- if (ptp_mtp_getobjectpropdesc(current_params, |
+- PTP_OPC_ObjectSize, |
+- current_params->deviceinfo.ImageFormats[i], |
+- &opd) != PTP_RC_OK) { |
+- LIBMTP_ERROR("LIBMTP PANIC: " |
+- "could not inspect object property descriptions!\n"); |
+- } else { |
+- if (opd.DataType == PTP_DTC_UINT32) { |
+- if (bs == 0) { |
+- bs = 32; |
+- } else if (bs != 32) { |
+- LIBMTP_ERROR("LIBMTP PANIC: " |
+- "different objects support different object sizes!\n"); |
+- bs = 0; |
+- break; |
+- } |
+- } else if (opd.DataType == PTP_DTC_UINT64) { |
+- if (bs == 0) { |
+- bs = 64; |
+- } else if (bs != 64) { |
+- LIBMTP_ERROR("LIBMTP PANIC: " |
+- "different objects support different object sizes!\n"); |
+- bs = 0; |
+- break; |
+- } |
++ if (ptp_mtp_getobjectpropdesc(current_params, |
++ PTP_OPC_ObjectSize, |
++ current_params->deviceinfo.ImageFormats[i], |
++ &opd) != PTP_RC_OK) { |
++ LIBMTP_ERROR("LIBMTP PANIC: " |
++ "could not inspect object property descriptions!\n"); |
+ } else { |
+- // Ignore if other size. |
+- LIBMTP_ERROR("LIBMTP PANIC: " |
+- "awkward object size data type: %04x\n", opd.DataType); |
+- bs = 0; |
+- break; |
++ if (opd.DataType == PTP_DTC_UINT32) { |
++ if (bs == 0) { |
++ bs = 32; |
++ } else if (bs != 32) { |
++ LIBMTP_ERROR("LIBMTP PANIC: " |
++ "different objects support different object sizes!\n"); |
++ bs = 0; |
++ break; |
++ } |
++ } else if (opd.DataType == PTP_DTC_UINT64) { |
++ if (bs == 0) { |
++ bs = 64; |
++ } else if (bs != 64) { |
++ LIBMTP_ERROR("LIBMTP PANIC: " |
++ "different objects support different object sizes!\n"); |
++ bs = 0; |
++ break; |
++ } |
++ } else { |
++ // Ignore if other size. |
++ LIBMTP_ERROR("LIBMTP PANIC: " |
++ "awkward object size data type: %04x\n", opd.DataType); |
++ bs = 0; |
++ break; |
++ } |
+ } |
+ } |
+ } |
+@@ -4107,7 +4112,7 @@ |
+ break; |
+ } |
+ } |
+- } else { |
++ } else if (ptp_operation_issupported(params,PTP_OC_MTP_GetObjectPropsSupported)) { |
+ uint16_t *props = NULL; |
+ uint32_t propcnt = 0; |
+ int ret; |