Great, thanks Marcus!

Adam
________________________________
From: Marcus Meissner <mar...@jet.franken.de>
Sent: Sunday, November 11, 2018 10:48 AM
To: Horshack
Cc: gphoto-devel@lists.sourceforge.net
Subject: Re: [gphoto-devel] Request to add Nikon Z7 camera

Hi,

On Sat, Nov 10, 2018 at 06:08:38PM +0000, Horshack  wrote:
>
> I've been working on debugging the issue and believe I have a root cause. For 
> the Z7 Nikon uses a Vendor Extension ID of 0xffffffff rather than the 
> expected PTP_VENDOR_NIKON (0xa). I saw this in the dump generated by 
> print_debug_deviceinfo(), and confirmed that this is in fact the ID Nikon 
> intended to send by reviewing Nikon's MTP spec for the Z7 (spec downloadable 
> on Nikon's under NDA at https://sdk.nikonimaging.com/apply/).
>
> To fix this I modified fixup_cached_deviceinfo() to detect an ID of 
> 0xffffffff and change it to di->VendorExtensionID to PTP_VENDOR_NIKON. I'm 
> not familiar enough with the libgphoto2 codebase to make an official change 
> myself so perhaps one of the maintainers on this thread can do so? Here's the 
> code I added, with some surrounding code for context (look for the 
> "horshack-horshack" block):
>
> if (di->VendorExtensionID == PTP_VENDOR_FUJI) {
>         C_MEM (di->DevicePropertiesSupported = 
> realloc(di->DevicePropertiesSupported,sizeof(di->DevicePropertiesSupported[0])*(di->DevicePropertiesSupported_len
>  + 5)));
>         di->DevicePropertiesSupported[di->DevicePropertiesSupported_len+0] = 
> PTP_DPC_ExposureTime;
>         di->DevicePropertiesSupported[di->DevicePropertiesSupported_len+1] = 
> PTP_DPC_FNumber;
>         di->DevicePropertiesSupported[di->DevicePropertiesSupported_len+2] = 
> 0xd38c;    /* PC Mode */
>         di->DevicePropertiesSupported[di->DevicePropertiesSupported_len+3] = 
> 0xd171;    /* Focus control */
>         di->DevicePropertiesSupported[di->DevicePropertiesSupported_len+4] = 
> 0xd21c;    /* Needed for X-T2? */
>         di->DevicePropertiesSupported_len += 5;
>     }
>
>     /* Nikon DSLR hide its newer opcodes behind another vendor specific query,
>      * do that and merge it into the generic PTP deviceinfo. */
>     /* horshack-horshack */
>     if (di->VendorExtensionID == 0xffffffff && di->Manufacturer && 
> !strcmp(di->Manufacturer,"Nikon Corporation")) {
>         GP_LOG_D("Changing Vendor Extension ID from 0xffffffff to 
> PTP_VENDOR_NIKON");
>         di->VendorExtensionID = PTP_VENDOR_NIKON;
>     }
>     /* horshack-horshack */
>
>     if (di->VendorExtensionID == PTP_VENDOR_NIKON) {
>         unsigned int i;
>         unsigned int nikond;
>
>         /* Nikon V* and J* advertise the new Nikon stuff, but only do the 
> generic
>          * PTP capture. FIXME: could use flags. */
>         if (params->deviceinfo.Model && (

I adjusted another places that takes care of it, committed to git:

@@ -347,7 +349,9 @@ fixup_cached_deviceinfo (Camera *camera, PTPDeviceInfo *di) 
{
        }

        /* Newer Nikons (D40) say that they are MTP devices. Restore Nikon 
vendor extid. */
-       if (    (di->VendorExtensionID == PTP_VENDOR_MICROSOFT) &&
+       if (    (       (di->VendorExtensionID == PTP_VENDOR_MICROSOFT) ||
+                       (di->VendorExtensionID == PTP_VENDOR_MTP)
+               ) &&
                (camera->port->type == GP_PORT_USB) &&
                (a.usb_vendor == 0x4b0)
        ) {

Ciao, Marcus
_______________________________________________
Gphoto-devel mailing list
Gphoto-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gphoto-devel

Reply via email to