From f61cd0f85f2f4b4a370e6bf6079f04d2af4b4d0f Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Sun, 23 Feb 2014 20:45:52 +0000 Subject: [PATCH] load the opcodes for the sony from the extended opcode handler git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@14793 67ed7778-7388-44ab-90cf-0a291f65f57c --- camlibs/ptp2/library.c | 60 ++++++++++++++++++++++++++++++++++++++++++ camlibs/ptp2/ptp.c | 34 +++++++++++++++++++++++- camlibs/ptp2/ptp.h | 13 +++++++++ 3 files changed, 106 insertions(+), 1 deletion(-) diff --git a/camlibs/ptp2/library.c b/camlibs/ptp2/library.c index de4d09c4d..be1277bc9 100644 --- a/camlibs/ptp2/library.c +++ b/camlibs/ptp2/library.c @@ -452,6 +452,66 @@ fixup_cached_deviceinfo (Camera *camera, PTPDeviceInfo *di) { di->OperationsSupported[di->OperationsSupported_len+1] = PTP_OC_NIKON_AfCaptureSDRAM; di->OperationsSupported_len+=2; } +#endif + } + + /* Sony DSLR also hide its newer opcodes behind another vendor specific query, + * do that and merge it into the generic PTP deviceinfo. */ + if (di->VendorExtensionID == PTP_VENDOR_SONY) { + unsigned int i; + + if (ptp_operation_issupported(&camera->pl->params, PTP_OC_SONY_GetSDIOGetExtDeviceInfo)) { + int opcodes = 0, propcodes = 0, events = 0, j,k,l; + uint16_t *xprops; + unsigned int xsize; + uint16_t ret; + + ret = ptp_sony_get_vendorpropcodes (&camera->pl->params, &xprops, &xsize); + if (ret != PTP_RC_OK) { + gp_log (GP_LOG_ERROR, "ptp2/fixup", "ptp_sony_get_vendorpropcodes() failed with 0x%04x", ret); + return; + } + for (i=0;iDevicePropertiesSupported = realloc(di->DevicePropertiesSupported,sizeof(di->DevicePropertiesSupported[0])*(di->DevicePropertiesSupported_len + propcodes)); + di->OperationsSupported = realloc(di->OperationsSupported, sizeof(di->OperationsSupported[0])*(di->OperationsSupported_len + opcodes)); + di->EventsSupported = realloc(di->EventsSupported, sizeof(di->EventsSupported[0])*(di->EventsSupported_len + events)); + j = 0; k = 0; l = 0; + for (i=0;iOperationsSupported[(k++)+di->OperationsSupported_len] = xprops[i]; + break; + case 0x4000: + di->EventsSupported[(l++)+di->EventsSupported_len] = xprops[i]; + break; + case 0x5000: + di->DevicePropertiesSupported[(j++)+di->DevicePropertiesSupported_len] = xprops[i]; + break; + default: + break; + } + } + di->DevicePropertiesSupported_len += propcodes; + di->EventsSupported_len += events; + di->OperationsSupported_len += opcodes; + free (xprops); + } +#if 0 + if (!ptp_operation_issupported(&camera->pl->params, 0x9207)) { + di->OperationsSupported = realloc(di->OperationsSupported,sizeof(di->OperationsSupported[0])*(di->OperationsSupported_len + 2)); + di->OperationsSupported[di->OperationsSupported_len+0] = PTP_OC_NIKON_Capture; + di->OperationsSupported[di->OperationsSupported_len+1] = PTP_OC_NIKON_AfCaptureSDRAM; + di->OperationsSupported_len+=2; + } #endif } #if 0 /* Marcus: not regular ptp properties, not queryable via getdevicepropertyvalue */ diff --git a/camlibs/ptp2/ptp.c b/camlibs/ptp2/ptp.c index f80128e49..8b3f6072c 100644 --- a/camlibs/ptp2/ptp.c +++ b/camlibs/ptp2/ptp.c @@ -2855,7 +2855,39 @@ ptp_nikon_curve_download (PTPParams* params, unsigned char **data, unsigned int } /** - * ptp_canon_get_vendorpropcodes: + * ptp_sony_get_vendorpropcodes: + * + * This command downloads the vendor specific property codes. + * + * params: PTPParams* + * + * Return values: Some PTP_RC_* code. + * unsigned char **data - pointer to data pointer + * unsigned int *size - size of data returned + * + **/ +uint16_t +ptp_sony_get_vendorpropcodes (PTPParams* params, uint16_t **props, unsigned int *size) { + PTPContainer ptp; + uint16_t ret; + unsigned char *xdata = NULL; + unsigned int xsize; + + *props = NULL; + *size = 0; + PTP_CNT_INIT(ptp); + ptp.Code = PTP_OC_SONY_GetSDIOGetExtDeviceInfo; + ptp.Nparam = 1; + ptp.Param1 = 0xc8; /* unclear */ + ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &xdata, &xsize); + /* first 16 bit is 0xc8 0x00, then an array of 16 bit PTP ids */ + if (ret == PTP_RC_OK) + *size = ptp_unpack_uint16_t_array(params,xdata+2,0,props); + free (xdata); + return ret; +} +/** + * ptp_nikon_get_vendorpropcodes: * * This command downloads the vendor specific property codes. * diff --git a/camlibs/ptp2/ptp.h b/camlibs/ptp2/ptp.h index 580fa4100..76f7df822 100644 --- a/camlibs/ptp2/ptp.h +++ b/camlibs/ptp2/ptp.h @@ -497,8 +497,19 @@ typedef struct _PTPIPHeader PTPIPHeader; #define PTP_OC_CASIO_GET_THUMBNAIL 0x9026 /* Sony stuff */ +/* 9201: + * 3 params: 1,0,0 ; IN: data 8 bytes all 0 + * or: + * 3 params: 2,0,0 ; IN: data 8 bytes all 0 + * or + * 3 params: 3,0,0,: IN: data 8 butes all 0 + */ #define PTP_OC_SONY_SDIOConnect 0x9201 +/* 9202: 1 param, 0xc8; IN data: + * 16 bit: 0xc8 + * ptp array 32 bit: index, 16 bit values of propcodes */ #define PTP_OC_SONY_GetSDIOGetExtDeviceInfo 0x9202 + #define PTP_OC_SONY_GetDevicePropdesc 0x9203 #define PTP_OC_SONY_GetDevicePropertyValue 0x9204 #define PTP_OC_SONY_SetControlDeviceA 0x9205 @@ -2827,6 +2838,8 @@ uint16_t ptp_nikon_curve_download (PTPParams* params, uint16_t ptp_nikon_getptpipinfo (PTPParams* params, unsigned char **data, unsigned int *size); uint16_t ptp_nikon_getwifiprofilelist (PTPParams* params); uint16_t ptp_nikon_writewifiprofile (PTPParams* params, PTPNIKONWifiProfile* profile); + +uint16_t ptp_sony_get_vendorpropcodes (PTPParams* params, uint16_t **props, unsigned int *size); /** * ptp_nikon_deletewifiprofile: *