Skip to content

Commit

Permalink
fixup cached deviceinfo in regards to the MTP -> Vendor transitions
Browse files Browse the repository at this point in the history
even on rereading


git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@11069 67ed7778-7388-44ab-90cf-0a291f65f57c
  • Loading branch information
msmeissn committed Mar 31, 2008
1 parent 496c3dc commit 8273ac6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
5 changes: 5 additions & 0 deletions camlibs/ptp2/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,14 @@ camera_prepare_canon_powershot_capture(Camera *camera, GPContext *context) {

ret = ptp_getdeviceinfo (params, &params->deviceinfo);
ret = ptp_getdeviceinfo (params, &params->deviceinfo);
fixup_cached_deviceinfo (camera);

ret = ptp_getdevicepropvalue(params, PTP_DPC_CANON_SizeOfOutputDataFromCamera, &propval, PTP_DTC_UINT32);
gp_log (GP_LOG_DEBUG, "ptp", "prop PTP_DPC_CANON_SizeOfOutputDataFromCamera value is 0x%8x, ret %d\n",propval.u32, ret);
ret = ptp_getdevicepropvalue(params, PTP_DPC_CANON_SizeOfInputDataToCamera, &propval, PTP_DTC_UINT32);
gp_log (GP_LOG_DEBUG, "ptp", "prop PTP_DPC_CANON_SizeOfInputDataToCamera value is 0x%8X, ret %d\n",propval.u32,ret);
ret = ptp_getdeviceinfo (params, &params->deviceinfo);
fixup_cached_deviceinfo (camera);
ret = ptp_getdevicepropvalue(params, PTP_DPC_CANON_EventEmulateMode, &propval, PTP_DTC_UINT16);
gp_log (GP_LOG_DEBUG, "ptp","prop 0xd045 value is 0x%4x, ret %d\n",propval.u16,ret);

Expand Down Expand Up @@ -138,6 +140,7 @@ camera_prepare_canon_powershot_capture(Camera *camera, GPContext *context) {
}
/* Reget device info, they change on the Canons. */
ptp_getdeviceinfo(&camera->pl->params, &camera->pl->params.deviceinfo);
fixup_cached_deviceinfo (camera);
gp_port_set_timeout (camera->port, oldtimeout);
return GP_OK;
}
Expand Down Expand Up @@ -192,6 +195,7 @@ camera_prepare_canon_eos_capture(Camera *camera, GPContext *context) {
gp_log (GP_LOG_ERROR,"ptp2_prepare_eos_capture", "getdeviceinfo failed!");
return GP_ERROR;
}
fixup_cached_deviceinfo (camera);
ret = ptp_canon_eos_getstorageids(params, &sids);
if (ret != PTP_RC_OK) {
gp_log (GP_LOG_ERROR,"ptp2_prepare_eos_capture", "9101 failed!");
Expand Down Expand Up @@ -268,6 +272,7 @@ camera_unprepare_canon_powershot_capture(Camera *camera, GPContext *context) {
}
/* Reget device info, they change on the Canons. */
ptp_getdeviceinfo(&camera->pl->params, &camera->pl->params.deviceinfo);
fixup_cached_deviceinfo (camera);
return GP_OK;
}

Expand Down
36 changes: 22 additions & 14 deletions camlibs/ptp2/library.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,26 @@ translate_ptp_result (short result)
}
}

void
fixup_cached_deviceinfo (Camera *camera) {
CameraAbilities a;

gp_camera_get_abilities(camera, &a);
/* Newer Canons say that they are MTP devices. Restore Canon vendor extid. */
if ( (camera->pl->params.deviceinfo.VendorExtensionID == PTP_VENDOR_MICROSOFT) &&
(camera->port->type == GP_PORT_USB) &&
(a.usb_vendor == 0x4a9)
)
camera->pl->params.deviceinfo.VendorExtensionID = PTP_VENDOR_CANON;

/* Newer Nikons (D40) say that they are MTP devices. Restore Nikon vendor extid. */
if ( (camera->pl->params.deviceinfo.VendorExtensionID == PTP_VENDOR_MICROSOFT) &&
(camera->port->type == GP_PORT_USB) &&
(a.usb_vendor == 0x4b0)
)
camera->pl->params.deviceinfo.VendorExtensionID = PTP_VENDOR_NIKON;
}

static struct {
const char *model;
unsigned short usb_vendor;
Expand Down Expand Up @@ -2267,7 +2287,7 @@ camera_summary (Camera* camera, CameraText* summary, GPContext *context)
* the available properties in capture mode.
*/
CPR(context, ptp_getdeviceinfo(&camera->pl->params, &pdi));

fixup_cached_deviceinfo(camera);
for (i=0;i<pdi.DevicePropertiesSupported_len;i++) {
PTPDevicePropDesc dpd;
unsigned int dpc = pdi.DevicePropertiesSupported[i];
Expand Down Expand Up @@ -4275,19 +4295,7 @@ camera_init (Camera *camera, GPContext *context)
CPR(context, ptp_getdeviceinfo(&camera->pl->params,
&camera->pl->params.deviceinfo));

/* Newer Canons say that they are MTP devices. Restore Canon vendor extid. */
if ( (camera->pl->params.deviceinfo.VendorExtensionID == PTP_VENDOR_MICROSOFT) &&
(camera->port->type == GP_PORT_USB) &&
(a.usb_vendor == 0x4a9)
)
camera->pl->params.deviceinfo.VendorExtensionID = PTP_VENDOR_CANON;

/* Newer Nikons (D40) say that they are MTP devices. Restore Nikon vendor extid. */
if ( (camera->pl->params.deviceinfo.VendorExtensionID == PTP_VENDOR_MICROSOFT) &&
(camera->port->type == GP_PORT_USB) &&
(a.usb_vendor == 0x4b0)
)
camera->pl->params.deviceinfo.VendorExtensionID = PTP_VENDOR_NIKON;
fixup_cached_deviceinfo (camera);

GP_DEBUG ("Device info:");
GP_DEBUG ("Manufacturer: %s",camera->pl->params.deviceinfo.Manufacturer);
Expand Down
1 change: 1 addition & 0 deletions camlibs/ptp2/ptp-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ int camera_unprepare_capture (Camera *camera, GPContext *context);
/* library.c */
void report_result (GPContext *context, short result, short vendor);
int translate_ptp_result (short result);
void fixup_cached_deviceinfo (Camera *camera);

struct _CameraPrivateLibrary {
PTPParams params;
Expand Down

0 comments on commit 8273ac6

Please sign in to comment.