Skip to content

Commit

Permalink
summary: add info about Canon vendor extension properties
Browse files Browse the repository at this point in the history
They only show up if the camera is in capturemode=on, see #1024.
  • Loading branch information
axxel authored and msmeissn committed Sep 23, 2024
1 parent 95dc881 commit f5e51fd
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
24 changes: 23 additions & 1 deletion camlibs/ptp2/library.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;i<x.DevicePropertiesSupported_len;i++)
di->DevicePropertiesSupported[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;
Expand Down Expand Up @@ -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.
Expand Down
23 changes: 22 additions & 1 deletion camlibs/ptp2/ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4847,6 +4847,27 @@ ptp_generic_getdevicepropdesc (PTPParams *params, uint32_t propcode, PTPDevicePr
ptp_free_devicepropdesc (&params->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;j<params->nrofcanon_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(&params->canon_props[j].dpd, &params->deviceproperties[i].desc);
goto done;
}

if ( (params->deviceinfo.VendorExtensionID == PTP_VENDOR_SONY) &&
ptp_operation_issupported(params, PTP_OC_SONY_SDIO_GetAllExtDevicePropInfo)
) {
Expand Down Expand Up @@ -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, &params->deviceproperties[i].desc));
goto done;
Expand Down
3 changes: 3 additions & 0 deletions camlibs/ptp2/ptp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f5e51fd

Please sign in to comment.