From 58ca79ccd634f0c586cc3ef4743a50482edd20a7 Mon Sep 17 00:00:00 2001 From: axxel Date: Mon, 23 Sep 2024 13:28:48 +0200 Subject: [PATCH] summary: add info about Canon vendor extension properties They only show up if the camera is in capturemode=on, see #1024. --- camlibs/ptp2/library.c | 24 +++++++++++++++++++++++- camlibs/ptp2/ptp.c | 23 ++++++++++++++++++++++- camlibs/ptp2/ptp.h | 3 +++ 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/camlibs/ptp2/library.c b/camlibs/ptp2/library.c index 6c8bd86b4..4754d7ae5 100644 --- a/camlibs/ptp2/library.c +++ b/camlibs/ptp2/library.c @@ -380,6 +380,25 @@ fixup_cached_deviceinfo (Camera *camera, PTPDeviceInfo *di) { di->VendorExtensionID = PTP_VENDOR_GP_OLYMPUS_OMD; } + /* Canon EOS */ + if ( di->VendorExtensionID == PTP_VENDOR_CANON && + ptp_operation_issupported(params, PTP_OC_CANON_EOS_GetDeviceInfoEx && + params->eos_captureenabled) + ) { + PTPCanonEOSDeviceInfo x; + + if (PTP_RC_OK == LOG_ON_PTP_E (ptp_canon_eos_getdeviceinfo (params, &x))) { + C_MEM (di->DevicePropertiesSupported = realloc(di->DevicePropertiesSupported, + (di->DevicePropertiesSupported_len + x.DevicePropertiesSupported_len) * sizeof(di->DevicePropertiesSupported[0]))); + for (unsigned i=0;iDevicePropertiesSupported[di->DevicePropertiesSupported_len + i] = x.DevicePropertiesSupported[i]; + di->DevicePropertiesSupported_len += x.DevicePropertiesSupported_len; + ptp_free_EOS_DI (&x); + } + + LOG_ON_PTP_E (ptp_check_eos_events(params)); + } + if (di->VendorExtensionID == PTP_VENDOR_FUJI) { C_MEM (di->DevicePropertiesSupported = realloc(di->DevicePropertiesSupported,sizeof(di->DevicePropertiesSupported[0])*(di->DevicePropertiesSupported_len + 72))); di->DevicePropertiesSupported[di->DevicePropertiesSupported_len+0] = PTP_DPC_ExposureTime; @@ -7942,9 +7961,12 @@ camera_summary (Camera* camera, CameraText* summary, GPContext *context) unsigned int dpc = pdi.DevicePropertiesSupported[i]; const char *propname = ptp_get_property_description (params, dpc); + /* drop the "EOS_" prefix */ + if (propname && strncmp(propname, "EOS_", 4) == 0) + propname += 4; /* string registered for i18n in ptp.c. */ - APPEND_TXT ("%-25s (%04x): ", propname ? _(propname) : _("[Unknown Property]"), dpc); + APPEND_TXT ("%-25s (%04x): ", propname ? _(propname) : N_("[Unknown Property]"), dpc); /* Do not read the 0xd201 property (found on Creative Zen series). * It seems to cause hangs. diff --git a/camlibs/ptp2/ptp.c b/camlibs/ptp2/ptp.c index 62dabc083..6b584a2a4 100644 --- a/camlibs/ptp2/ptp.c +++ b/camlibs/ptp2/ptp.c @@ -4847,6 +4847,27 @@ ptp_generic_getdevicepropdesc (PTPParams *params, uint32_t propcode, PTPDevicePr ptp_free_devicepropdesc (¶ms->deviceproperties[i].desc); } + if (!ptp_is_vendor_extension_prop(propcode)) + goto generic; + + if ( (params->deviceinfo.VendorExtensionID == PTP_VENDOR_CANON) && + ptp_operation_issupported(params, PTP_OC_CANON_EOS_RequestDevicePropValue) + ) { + unsigned j; + for (j=0;jnrofcanon_props;j++) + if (params->canon_props[j].proptype == propcode) + break; + if (j == params->nrofcanon_props) { + ptp_debug (params, "Canon EOS property %04x not found", propcode); + if ((propcode & 0xFF00) == 0xD100 || (propcode & 0xFF00) == 0xD200) + return PTP_RC_DevicePropNotSupported; + else + goto generic; + } + duplicate_DevicePropDesc(¶ms->canon_props[j].dpd, ¶ms->deviceproperties[i].desc); + goto done; + } + if ( (params->deviceinfo.VendorExtensionID == PTP_VENDOR_SONY) && ptp_operation_issupported(params, PTP_OC_SONY_SDIO_GetAllExtDevicePropInfo) ) { @@ -4882,7 +4903,7 @@ ptp_generic_getdevicepropdesc (PTPParams *params, uint32_t propcode, PTPDevicePr goto done; } - +generic: if (ptp_operation_issupported(params, PTP_OC_GetDevicePropDesc)) { CHECK_PTP_RC(ptp_getdevicepropdesc (params, propcode, ¶ms->deviceproperties[i].desc)); goto done; diff --git a/camlibs/ptp2/ptp.h b/camlibs/ptp2/ptp.h index abda0e3f4..752ea38ad 100644 --- a/camlibs/ptp2/ptp.h +++ b/camlibs/ptp2/ptp.h @@ -4834,6 +4834,9 @@ void ptp_error (PTPParams *params, const char *format, ...) const char* ptp_bytes2str (const uint8_t *data, int data_size, const char *fmt); void ptp_debug_data (PTPParams *params, const uint8_t *data, int size); +static inline int ptp_is_vendor_extension_prop(uint32_t propcode) { + return (propcode & PTP_DPC_EXTENSION_MASK) == PTP_DPC_EXTENSION; +} const char* ptp_data_type_name(PTPParams* params, uint32_t dt); const char* ptp_get_property_description(PTPParams* params, uint32_t dpc);