diff options
author | Linus Walleij <triad@df.lth.se> | 2008-12-14 01:07:30 +0000 |
---|---|---|
committer | Linus Walleij <triad@df.lth.se> | 2008-12-14 01:07:30 +0000 |
commit | d1e14e0bbcafc75c885ee26cc80ba6204664c257 (patch) | |
tree | be2438efe2ebe06eba92c734e547fdd988293c7b | |
parent | 2a84ca43f10d3fc1fc0bdab3d9dc7f602deb7c9f (diff) | |
download | libmtp-d1e14e0bbcafc75c885ee26cc80ba6204664c257.tar.gz |
Refactor and shape up debug calls, bring in upstreams updates.
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | src/libmtp.c | 60 | ||||
-rw-r--r-- | src/libusb-glue.c | 28 | ||||
-rw-r--r-- | src/ptp.c | 346 | ||||
-rw-r--r-- | src/ptp.h | 27 |
5 files changed, 389 insertions, 75 deletions
@@ -8,6 +8,9 @@ http://gphoto.svn.sourceforge.net/viewvc/gphoto/trunk/m4/ * configure.ac: fix the renamed _stdint.h too. * Doxyfile.in: some config option got obsolete. + * libmtp.c: start to use PTP error redirection to the libmtp error stack. + This also makes it possible to stop the annoying debug prints. + * libusb-glue.c: dito. 2008-12-02 Linus Walleij <triad@df.lth.se> diff --git a/src/libmtp.c b/src/libmtp.c index a51df56..18dec5f 100644 --- a/src/libmtp.c +++ b/src/libmtp.c @@ -55,6 +55,9 @@ #include <io.h> #endif +/* To enable PTP level debug prints (all ptp_debug(...)), switch on this */ +//#define ENABLE_PTP_DEBUG + /* * This is a mapping between libmtp internal MTP filetypes and * the libgphoto2/PTP equivalent defines. We need this because @@ -854,6 +857,50 @@ LIBMTP_mtpdevice_t *LIBMTP_Get_First_Device(void) } /** + * Overriding debug function. + * This way we can disable debug prints. + */ +static void +#ifdef __GNUC__ +__attribute__((__format__(printf,2,0))) +#endif +LIBMTP_ptp_debug(void *data, const char *format, va_list args) +{ +#ifdef ENABLE_PTP_DEBUG + vfprintf (stderr, format, args); + fflush (stderr); +#endif +} + +/** + * Overriding error function. + * This way we can capture all error etc to our errorstack. + */ +static void +#ifdef __GNUC__ +__attribute__((__format__(printf,2,0))) +#endif +LIBMTP_ptp_error(void *data, const char *format, va_list args) +{ + // if (data == NULL) { + vfprintf (stderr, format, args); + fflush (stderr); + /* + FIXME: find out how we shall get the device here. + } else { + PTP_USB *ptp_usb = data; + LIBMTP_mtpdevice_t *device = ...; + char buf[2048]; + + vsnprintf (buf, sizeof (buf), format, args); + add_error_to_errorstack(device, + LIBMTP_ERROR_PTP_LAYER, + buf); + } + */ +} + +/** * This function opens a device from a raw device. It is the * preferred way to access devices in the new interface where * several devices can come and go as the library is working @@ -893,6 +940,11 @@ LIBMTP_mtpdevice_t *LIBMTP_Open_Raw_Device(LIBMTP_raw_device_t *rawdevice) return NULL; } memset(current_params, 0, sizeof(PTPParams)); + /* This will be a pointer to PTP_USB later */ + current_params->data = NULL; + /* Set upp local debug and error functions */ + current_params->debug_func = LIBMTP_ptp_debug; + current_params->error_func = LIBMTP_ptp_error; /* Clear all handlers */ current_params->handles.Handler = NULL; current_params->objectinfo = NULL; @@ -950,14 +1002,14 @@ LIBMTP_mtpdevice_t *LIBMTP_Open_Raw_Device(LIBMTP_raw_device_t *rawdevice) PTP_OPC_ObjectSize, current_params->deviceinfo.ImageFormats[i], &opd) != PTP_RC_OK) { - printf("LIBMTP PANIC: create_usb_mtp_devices(): " + printf("LIBMTP PANIC: " "could not inspect object property descriptions!\n"); } else { if (opd.DataType == PTP_DTC_UINT32) { if (bs == 0) { bs = 32; } else if (bs != 32) { - printf("LIBMTP PANIC: create_usb_mtp_devices(): " + printf("LIBMTP PANIC: " "different objects support different object sizes!\n"); bs = 0; break; @@ -966,14 +1018,14 @@ LIBMTP_mtpdevice_t *LIBMTP_Open_Raw_Device(LIBMTP_raw_device_t *rawdevice) if (bs == 0) { bs = 64; } else if (bs != 64) { - printf("LIBMTP PANIC: create_usb_mtp_devices(): " + printf("LIBMTP PANIC: " "different objects support different object sizes!\n"); bs = 0; break; } } else { // Ignore if other size. - printf("LIBMTP PANIC: create_usb_mtp_devices(): " + printf("LIBMTP PANIC: " "awkward object size data type: %04x\n", opd.DataType); bs = 0; break; diff --git a/src/libusb-glue.c b/src/libusb-glue.c index cb65246..d7cab1d 100644 --- a/src/libusb-glue.c +++ b/src/libusb-glue.c @@ -43,7 +43,7 @@ #include "ptp-pack.c" -/* To enable debug prints, switch on this */ +/* To enable debug prints for USB stuff, switch on this */ //#define ENABLE_USB_BULK_DEBUG /* Default USB timeout length. This can be overridden as needed @@ -589,8 +589,8 @@ char const * const get_playlist_extension(PTP_USB *ptp_usb) return default_pl_extension; } -void -ptp_debug (PTPParams *params, const char *format, ...) +static void +libusb_glue_debug (PTPParams *params, const char *format, ...) { va_list args; @@ -607,7 +607,7 @@ ptp_debug (PTPParams *params, const char *format, ...) } static void -ptp_error (PTPParams *params, const char *format, ...) +libusb_glue_error (PTPParams *params, const char *format, ...) { va_list args; @@ -985,7 +985,7 @@ ptp_usb_sendreq (PTPParams* params, PTPContainer* req) ret = PTP_ERROR_IO; } if (written != towrite && ret != PTP_ERROR_CANCEL && ret != PTP_ERROR_IO) { - ptp_error (params, + libusb_glue_error (params, "PTP: request code 0x%04x sending req wrote only %ld bytes instead of %d", req->Code, written, towrite ); @@ -1111,7 +1111,7 @@ ptp_usb_getdata (PTPParams* params, PTPContainer* ptp, PTPDataHandler *handler) } if (dtoh16(usbdata.code)!=ptp->Code) { if (FLAG_IGNORE_HEADER_ERRORS(ptp_usb)) { - ptp_debug (params, "ptp2/ptp_usb_getdata: detected a broken " + libusb_glue_debug (params, "ptp2/ptp_usb_getdata: detected a broken " "PTP header, code field insane, expect problems! (But continuing)"); // Repair the header, so it won't wreak more havoc, don't just ignore it. // Typically these two fields will be broken. @@ -1125,7 +1125,7 @@ ptp_usb_getdata (PTPParams* params, PTPContainer* ptp, PTPDataHandler *handler) // getting data. It appears Windows ignores the contents of this // field entirely. if (ret < PTP_RC_Undefined || ret > PTP_RC_SpecificationOfDestinationUnsupported) { - ptp_debug (params, "ptp2/ptp_usb_getdata: detected a broken " + libusb_glue_debug (params, "ptp2/ptp_usb_getdata: detected a broken " "PTP header, code field insane."); ret = PTP_ERROR_IO; } @@ -1181,7 +1181,7 @@ ptp_usb_getdata (PTPParams* params, PTPContainer* ptp, PTPDataHandler *handler) /* Ignore reading one extra byte if device flags have been set */ } else if(!FLAG_NO_ZERO_READS(ptp_usb) && (rlen - dtoh32(usbdata.length) == 1)) { - ptp_debug (params, "ptp2/ptp_usb_getdata: read %d bytes " + libusb_glue_debug (params, "ptp2/ptp_usb_getdata: read %d bytes " "too much, expect problems!", rlen - dtoh32(usbdata.length)); } @@ -1266,7 +1266,7 @@ ptp_usb_getresp (PTPParams* params, PTPContainer* resp) // after a NULL packet when it should send the response. This code ignores // such illegal packets. while (ret==PTP_RC_OK && rlen<PTP_USB_BULK_HDR_LEN && usbresp.length==0) { - ptp_debug (params, "ptp_usb_getresp: detected short response " + libusb_glue_debug (params, "ptp_usb_getresp: detected short response " "of %d bytes, expect problems! (re-reading " "response), rlen"); ret = ptp_usb_getpacket(params, &usbresp, &rlen); @@ -1285,7 +1285,7 @@ ptp_usb_getresp (PTPParams* params, PTPContainer* resp) printf("%04x\n", ret); #endif if (ret!=PTP_RC_OK) { -/* ptp_error (params, +/* libusb_glue_error (params, "PTP: request code 0x%04x getting resp error 0x%04x", resp->Code, ret);*/ return ret; @@ -1296,7 +1296,7 @@ ptp_usb_getresp (PTPParams* params, PTPContainer* resp) resp->Transaction_ID=dtoh32(usbresp.trans_id); if (FLAG_IGNORE_HEADER_ERRORS(ptp_usb)) { if (resp->Transaction_ID != params->transaction_id-1) { - ptp_debug (params, "ptp_usb_getresp: detected a broken " + libusb_glue_debug (params, "ptp_usb_getresp: detected a broken " "PTP header, transaction ID insane, expect " "problems! (But continuing)"); // Repair the header, so it won't wreak more havoc. @@ -1349,13 +1349,13 @@ ptp_usb_event (PTPParams* params, PTPContainer* event, int wait) break; } if (ret!=PTP_RC_OK) { - ptp_error (params, + libusb_glue_error (params, "PTP: reading event an error 0x%04x occurred", ret); return PTP_ERROR_IO; } rlen = result; if (rlen < 8) { - ptp_error (params, + libusb_glue_error (params, "PTP: reading event an short read of %ld bytes occurred", rlen); return PTP_ERROR_IO; } @@ -1402,8 +1402,6 @@ static int init_ptp_usb (PTPParams* params, PTP_USB* ptp_usb, struct usb_device* { usb_dev_handle *device_handle; - params->error_func=NULL; - params->debug_func=NULL; params->sendreq_func=ptp_usb_sendreq; params->senddata_func=ptp_usb_senddata; params->getresp_func=ptp_usb_getresp; @@ -1614,24 +1614,25 @@ ptp_canon_viewfinderoff (PTPParams* params) } /** - * ptp_canon_aeafawb: + * ptp_canon_reset_aeafawb: * params: PTPParams* - * uint32_t p1 - Yet unknown parameter, - * value 7 works + * uint32_t flags - what shall be reset. + * 1 - autoexposure + * 2 - autofocus + * 4 - autowhitebalance * - * Called AeAfAwb (auto exposure, focus, white balance) + * Called "Reset AeAfAwb" (auto exposure, focus, white balance) * * Return values: Some PTP_RC_* code. - * **/ uint16_t -ptp_canon_aeafawb (PTPParams* params, uint32_t p1) +ptp_canon_reset_aeafawb (PTPParams* params, uint32_t flags) { PTPContainer ptp; PTP_CNT_INIT(ptp); ptp.Code=PTP_OC_CANON_DoAeAfAwb; - ptp.Param1=p1; + ptp.Param1=flags; ptp.Nparam=1; return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL); } @@ -2370,6 +2371,27 @@ ptp_nikon_capture (PTPParams* params, uint32_t x) } /** + * ptp_nikon_capture_sdram: + * + * This command captures a picture on the Nikon. + * + * params: PTPParams* + * + * Return values: Some PTP_RC_* code. + * + **/ +uint16_t +ptp_nikon_capture_sdram (PTPParams* params) +{ + PTPContainer ptp; + + PTP_CNT_INIT(ptp); + ptp.Code=PTP_OC_NIKON_AfCaptureSDRAM; + ptp.Nparam=0; + return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL); +} + +/** * ptp_nikon_check_event: * * This command checks the event queue on the Nikon. @@ -3250,6 +3272,18 @@ ptp_get_property_description(PTPParams* params, uint16_t dpc) uint16_t dpc; const char *txt; } ptp_device_properties_Nikon[] = { + {PTP_DPC_NIKON_ShootingBank, /* 0xD010 */ + N_("Shooting Bank")}, + {PTP_DPC_NIKON_ShootingBankNameA, /* 0xD011 */ + N_("Shooting Bank Name A")}, + {PTP_DPC_NIKON_ShootingBankNameB, /* 0xD012 */ + N_("Shooting Bank Name B")}, + {PTP_DPC_NIKON_ShootingBankNameC, /* 0xD013 */ + N_("Shooting Bank Name C")}, + {PTP_DPC_NIKON_ShootingBankNameD, /* 0xD014 */ + N_("Shooting Bank Name D")}, + {PTP_DPC_NIKON_RawCompression, /* 0xD016 */ + N_("Raw Compression")}, {PTP_DPC_NIKON_WhiteBalanceAutoBias, /* 0xD017 */ N_("Auto White Balance Bias")}, {PTP_DPC_NIKON_WhiteBalanceTungstenBias, /* 0xD018 */ @@ -3360,6 +3394,7 @@ ptp_get_property_description(PTPParams* params, uint16_t dpc) N_("Bracket Order")}, {PTP_DPC_NIKON_E8AutoBracketSelection, /* 0xD07b */ N_("Auto Bracket Selection")}, + {PTP_DPC_NIKON_BracketingSet, N_("NIKON Auto Bracketing Set")}, /* 0xD07C */ {PTP_DPC_NIKON_F1CenterButtonShootingMode, /* 0xD080 */ N_("Center Button Shooting Mode")}, {PTP_DPC_NIKON_CenterButtonPlaybackMode, /* 0xD081 */ @@ -3382,6 +3417,10 @@ ptp_get_property_description(PTPParams* params, uint16_t dpc) N_("Buttons and Dials")}, {PTP_DPC_NIKON_NoCFCard, /* 0xD08a */ N_("No CF Card Release")}, + {PTP_DPC_NIKON_ImageCommentString, /* 0xD090 */ + N_("Image Comment String")}, + {PTP_DPC_NIKON_ImageCommentAttach, /* 0xD091 */ + N_("Image Comment Attach")}, {PTP_DPC_NIKON_ImageRotation, /* 0xD092 */ N_("Image Rotation")}, {PTP_DPC_NIKON_Bracketing, /* 0xD0c0 */ @@ -3390,68 +3429,79 @@ ptp_get_property_description(PTPParams* params, uint16_t dpc) N_("Exposure Bracketing Distance")}, {PTP_DPC_NIKON_BracketingProgram, /* 0xD0c2 */ N_("Exposure Bracketing Number")}, + {PTP_DPC_NIKON_WhiteBalanceBracketStep, N_("NIKON White Balance Bracket Step")}, /* 0xD0C4 */ + {PTP_DPC_NIKON_LensID, /* 0xD0E0 */ + N_("Lens ID")}, + {PTP_DPC_NIKON_FocalLengthMin, /* 0xD0E3 */ + N_("Min. Focal Length")}, + {PTP_DPC_NIKON_FocalLengthMax, /* 0xD0E4 */ + N_("Max. Focal Length")}, + {PTP_DPC_NIKON_MaxApAtMinFocalLength, /* 0xD0E5 */ + N_("Max. Aperture at Min. Focal Length")}, + {PTP_DPC_NIKON_MaxApAtMaxFocalLength, /* 0xD0E6 */ + N_("Max. Aperture at Max. Focal Length")}, + {PTP_DPC_NIKON_ExposureTime, /* 0xD100 */ + N_("Nikon Exposure Time")}, + {PTP_DPC_NIKON_ACPower, N_("AC Power")}, /* 0xD101 */ + {PTP_DPC_NIKON_MaximumShots, /* 0xD103 */ + N_("Maximum Shots")}, + {PTP_DPC_NIKON_AFLLock, N_("NIKON AF-L Locked")},/* 0xD104 */ + {PTP_DPC_NIKON_AutoExposureLock, /* 0xD105 */ + N_("Auto Exposure Lock")}, + {PTP_DPC_NIKON_AutoFocusLock, /* 0xD106 */ + N_("Auto Focus Lock")}, {PTP_DPC_NIKON_AutofocusLCDTopMode2, /* 0xD107 */ N_("AF LCD Top Mode 2")}, {PTP_DPC_NIKON_AutofocusArea, /* 0xD108 */ N_("Active AF Sensor")}, {PTP_DPC_NIKON_LightMeter, /* 0xD10a */ N_("Exposure Meter")}, + {PTP_DPC_NIKON_CameraOrientation, /* 0xD10e */ + N_("Camera Orientation")}, {PTP_DPC_NIKON_ExposureApertureLock, /* 0xD111 */ N_("Exposure Aperture Lock")}, - {PTP_DPC_NIKON_MaximumShots, /* 0xD103 */ - N_("Maximum Shots")}, + {PTP_DPC_NIKON_FlashExposureCompensation, /* 0xD126 */ + N_("Flash Exposure Compensation")}, {PTP_DPC_NIKON_OptimizeImage, /* 0xD140 */ N_("Optimize Image")}, {PTP_DPC_NIKON_Saturation, /* 0xD142 */ N_("Saturation")}, - {PTP_DPC_NIKON_CSMMenu, /* 0xD180 */ - N_("CSM Menu")}, - {PTP_DPC_NIKON_BeepOff, + {PTP_DPC_NIKON_BeepOff, /* 0xD160 */ N_("AF Beep Mode")}, - {PTP_DPC_NIKON_AutofocusMode, + {PTP_DPC_NIKON_AutofocusMode, /* 0xD161 */ N_("Autofocus Mode")}, - {PTP_DPC_NIKON_AFAssist, + {PTP_DPC_NIKON_AFAssist, /* 0xD163 */ N_("AF Assist Lamp")}, - {PTP_DPC_NIKON_PADVPMode, + {PTP_DPC_NIKON_PADVPMode, /* 0xD164 */ N_("Auto ISO P/A/DVP Setting")}, - {PTP_DPC_NIKON_ImageReview, + {PTP_DPC_NIKON_ImageReview, /* 0xD165 */ N_("Image Review")}, - {PTP_DPC_NIKON_GridDisplay, - N_("Viewfinder Grid Display")}, - {PTP_DPC_NIKON_AFAreaIllumination, + {PTP_DPC_NIKON_AFAreaIllumination, /* 0xD166 */ N_("AF Area Illumination")}, - {PTP_DPC_NIKON_FlashMode, + {PTP_DPC_NIKON_FlashMode, /* 0xD167 */ N_("Flash Mode")}, - {PTP_DPC_NIKON_FlashModeManualPower, - N_("Flash Mode Manual Power")}, - {PTP_DPC_NIKON_FlashSign, + {PTP_DPC_NIKON_FlashCommanderMode, /* 0xD168 */ + N_("Flash Commander Mode")}, + {PTP_DPC_NIKON_FlashSign, /* 0xD169 */ N_("Flash Sign")}, - {PTP_DPC_NIKON_FlashExposureCompensation, - N_("Flash Exposure Compensation")}, - {PTP_DPC_NIKON_RemoteTimeout, + {PTP_DPC_NIKON_RemoteTimeout, /* 0xD16B */ N_("Remote Timeout")}, - {PTP_DPC_NIKON_ImageCommentString, - N_("Image Comment String")}, - {PTP_DPC_NIKON_FlashOpen, + {PTP_DPC_NIKON_GridDisplay, /* 0xD16C */ + N_("Viewfinder Grid Display")}, + {PTP_DPC_NIKON_FlashModeManualPower, /* 0xD16D */ + N_("Flash Mode Manual Power")}, + {PTP_DPC_NIKON_FlashModeCommanderPower, /* 0xD16E */ + N_("Flash Mode Commander Power")}, + {PTP_DPC_NIKON_CSMMenu, /* 0xD180 */ + N_("CSM Menu")}, + {PTP_DPC_NIKON_BracketingFramesAndSteps, /* 0xD190 */ + N_("Bracketing Frames and Steps")}, + {PTP_DPC_NIKON_LowLight, /* 0xD1B0 */ + N_("Low Light")}, + {PTP_DPC_NIKON_FlashOpen, /* 0xD1C0 */ N_("Flash Open")}, - {PTP_DPC_NIKON_FlashCharged, + {PTP_DPC_NIKON_FlashCharged, /* 0xD1C1 */ N_("Flash Charged")}, - {PTP_DPC_NIKON_LensID, - N_("Lens ID")}, - {PTP_DPC_NIKON_FocalLengthMin, - N_("Min. Focal Length")}, - {PTP_DPC_NIKON_FocalLengthMax, - N_("Max. Focal Length")}, - {PTP_DPC_NIKON_MaxApAtMinFocalLength, - N_("Max. Aperture at Min. Focal Length")}, - {PTP_DPC_NIKON_MaxApAtMaxFocalLength, - N_("Max. Aperture at Max. Focal Length")}, - {PTP_DPC_NIKON_LowLight, - N_("Low Light")}, - {PTP_DPC_NIKON_ACPower, N_("AC Power")}, - {PTP_DPC_NIKON_BracketingSet, N_("NIKON Auto Bracketing Set")}, - {PTP_DPC_NIKON_WhiteBalanceBracketStep, N_("NIKON White Balance Bracket Step")}, - {PTP_DPC_NIKON_AFLLock, N_("NIKON AF-L Locked")}, {0,NULL} }; struct { @@ -3712,14 +3762,31 @@ ptp_render_property_value(PTPParams* params, uint16_t dpc, {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 83, "AF Nikkor 80-200mm 1:2.8 D ED"}, {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 118, "AF Nikkor 50mm 1:1.8 D"}, {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 127, "AF-S Nikkor 18-70mm 1:3.5-4.5G ED DX"}, + {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 139, "AF-S Nikkor 18-200mm 1:3.5-5.6 GED DX VR"}, + {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 147, "AF-S Nikkor 24-70mm 1:2.8G ED DX"}, + {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 154, "AF-S Nikkor 18-55mm 1:3.5-F5.6G DX VR"}, + + {PTP_DPC_NIKON_MonitorOff, PTP_VENDOR_NIKON, 0, N_("10 seconds")}, + {PTP_DPC_NIKON_MonitorOff, PTP_VENDOR_NIKON, 1, N_("20 seconds")}, + {PTP_DPC_NIKON_MonitorOff, PTP_VENDOR_NIKON, 2, N_("1 minute")}, + {PTP_DPC_NIKON_MonitorOff, PTP_VENDOR_NIKON, 3, N_("5 minutes")}, + {PTP_DPC_NIKON_MonitorOff, PTP_VENDOR_NIKON, 4, N_("10 minutes")}, + {PTP_DPC_NIKON_MonitorOff, PTP_VENDOR_NIKON, 5, N_("5 seconds")}, /* d80 observed */ + PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_LowLight,PTP_VENDOR_NIKON), PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_CSMMenu,PTP_VENDOR_NIKON), PTP_VENDOR_VAL_RBOOL(PTP_DPC_NIKON_BeepOff,PTP_VENDOR_NIKON), + {PTP_DPC_NIKON_CameraOrientation, PTP_VENDOR_NIKON, 0, "0'"}, + {PTP_DPC_NIKON_CameraOrientation, PTP_VENDOR_NIKON, 1, "270'"}, + {PTP_DPC_NIKON_CameraOrientation, PTP_VENDOR_NIKON, 2, "90'"}, + {PTP_DPC_NIKON_CameraOrientation, PTP_VENDOR_NIKON, 3, "180'"}, + /* Canon stuff */ - PTP_VENDOR_VAL_RBOOL(PTP_DPC_CANON_AssistLight,PTP_VENDOR_CANON), + PTP_VENDOR_VAL_BOOL(PTP_DPC_CANON_AssistLight,PTP_VENDOR_CANON), PTP_VENDOR_VAL_RBOOL(PTP_DPC_CANON_RotationScene,PTP_VENDOR_CANON), PTP_VENDOR_VAL_RBOOL(PTP_DPC_CANON_BeepMode,PTP_VENDOR_CANON), + PTP_VENDOR_VAL_BOOL(PTP_DPC_CANON_Beep,PTP_VENDOR_CANON), {PTP_DPC_CANON_RotationAngle, PTP_VENDOR_CANON, 0, "0'"}, {PTP_DPC_CANON_RotationAngle, PTP_VENDOR_CANON, 3, "270'"}, @@ -3737,6 +3804,191 @@ ptp_render_property_value(PTPParams* params, uint16_t dpc, {PTP_DPC_CANON_BatteryStatus, PTP_VENDOR_CANON, 2, N_("Warning Level 1")}, {PTP_DPC_CANON_BatteryStatus, PTP_VENDOR_CANON, 3, N_("Emergency")}, {PTP_DPC_CANON_BatteryStatus, PTP_VENDOR_CANON, 4, N_("Warning Level 0")}, + + {PTP_DPC_CANON_ImageQuality, PTP_VENDOR_CANON, 0, N_("Undefined")}, + {PTP_DPC_CANON_ImageQuality, PTP_VENDOR_CANON, 1, N_("Economy")}, + {PTP_DPC_CANON_ImageQuality, PTP_VENDOR_CANON, 2, N_("Normal")}, + {PTP_DPC_CANON_ImageQuality, PTP_VENDOR_CANON, 3, N_("Fine")}, + {PTP_DPC_CANON_ImageQuality, PTP_VENDOR_CANON, 4, N_("Lossless")}, + {PTP_DPC_CANON_ImageQuality, PTP_VENDOR_CANON, 5, N_("SuperFine")}, + + {PTP_DPC_CANON_FullViewFileFormat, PTP_VENDOR_CANON, 0, N_("Undefined")}, + {PTP_DPC_CANON_FullViewFileFormat, PTP_VENDOR_CANON, 1, N_("JPEG")}, + {PTP_DPC_CANON_FullViewFileFormat, PTP_VENDOR_CANON, 2, N_("CRW")}, + + {PTP_DPC_CANON_ImageSize, PTP_VENDOR_CANON, 0, N_("Large")}, + {PTP_DPC_CANON_ImageSize, PTP_VENDOR_CANON, 1, N_("Medium 1")}, + {PTP_DPC_CANON_ImageSize, PTP_VENDOR_CANON, 2, N_("Small")}, + {PTP_DPC_CANON_ImageSize, PTP_VENDOR_CANON, 3, N_("Medium 2")}, + {PTP_DPC_CANON_ImageSize, PTP_VENDOR_CANON, 7, N_("Medium 3")}, + + {PTP_DPC_CANON_SelfTime, PTP_VENDOR_CANON, 0, N_("Not used")}, + {PTP_DPC_CANON_SelfTime, PTP_VENDOR_CANON, 100, N_("10 seconds")}, + {PTP_DPC_CANON_SelfTime, PTP_VENDOR_CANON, 20, N_("2 seconds")}, + + {PTP_DPC_CANON_FlashMode, PTP_VENDOR_CANON, 0, N_("Off")}, + {PTP_DPC_CANON_FlashMode, PTP_VENDOR_CANON, 1, N_("Auto")}, + {PTP_DPC_CANON_FlashMode, PTP_VENDOR_CANON, 2, N_("On")}, + {PTP_DPC_CANON_FlashMode, PTP_VENDOR_CANON, 3, N_("Red Eye Suppression")}, + {PTP_DPC_CANON_FlashMode, PTP_VENDOR_CANON, 4, N_("Low Speed Synchronization")}, + {PTP_DPC_CANON_FlashMode, PTP_VENDOR_CANON, 5, N_("Auto + Red Eye Suppression")}, + {PTP_DPC_CANON_FlashMode, PTP_VENDOR_CANON, 6, N_("On + Red Eye Suppression")}, + + {PTP_DPC_CANON_ShootingMode, PTP_VENDOR_CANON, 0, N_("Auto")}, + {PTP_DPC_CANON_ShootingMode, PTP_VENDOR_CANON, 1, N_("P")}, + {PTP_DPC_CANON_ShootingMode, PTP_VENDOR_CANON, 2, N_("Tv")}, + {PTP_DPC_CANON_ShootingMode, PTP_VENDOR_CANON, 3, N_("Av")}, + {PTP_DPC_CANON_ShootingMode, PTP_VENDOR_CANON, 4, N_("M")}, + {PTP_DPC_CANON_ShootingMode, PTP_VENDOR_CANON, 5, N_("A_DEP")}, + {PTP_DPC_CANON_ShootingMode, PTP_VENDOR_CANON, 6, N_("M_DEP")}, + {PTP_DPC_CANON_ShootingMode, PTP_VENDOR_CANON, 7, N_("Bulb")}, + /* more actually */ + + {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 0, N_("Auto")}, + {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 1, N_("Manual")}, + {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 2, N_("Distant View")}, + {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 3, N_("High-Speed Shutter")}, + {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 4, N_("Low-Speed Shutter")}, + {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 5, N_("Night View")}, + {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 6, N_("Grayscale")}, + {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 7, N_("Sepia")}, + {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 8, N_("Portrait")}, + {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 9, N_("Sports")}, + {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 10, N_("Macro")}, + {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 11, N_("Monochrome")}, + {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 12, N_("Pan Focus")}, + {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 13, N_("Neutral")}, + {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 14, N_("Soft")}, + + {PTP_DPC_CANON_DriveMode, PTP_VENDOR_CANON, 0, N_("Single-Frame Shooting")}, + {PTP_DPC_CANON_DriveMode, PTP_VENDOR_CANON, 1, N_("Continuous Shooting")}, + {PTP_DPC_CANON_DriveMode, PTP_VENDOR_CANON, 2, N_("Timer (Single) Shooting")}, + {PTP_DPC_CANON_DriveMode, PTP_VENDOR_CANON, 4, N_("Continuous Low-speed Shooting")}, + {PTP_DPC_CANON_DriveMode, PTP_VENDOR_CANON, 5, N_("Continuous High-speed Shooting")}, + + {PTP_DPC_CANON_EZoom, PTP_VENDOR_CANON, 0, N_("Off")}, + {PTP_DPC_CANON_EZoom, PTP_VENDOR_CANON, 1, N_("2x")}, + {PTP_DPC_CANON_EZoom, PTP_VENDOR_CANON, 2, N_("4x")}, + {PTP_DPC_CANON_EZoom, PTP_VENDOR_CANON, 3, N_("Smooth")}, + + {PTP_DPC_CANON_MeteringMode, PTP_VENDOR_CANON, 0, N_("Center-weighted Metering")}, + {PTP_DPC_CANON_MeteringMode, PTP_VENDOR_CANON, 1, N_("Spot Metering")}, + {PTP_DPC_CANON_MeteringMode, PTP_VENDOR_CANON, 2, N_("Average Metering")}, + {PTP_DPC_CANON_MeteringMode, PTP_VENDOR_CANON, 3, N_("Evaluative Metering")}, + {PTP_DPC_CANON_MeteringMode, PTP_VENDOR_CANON, 4, N_("Partial Metering")}, + {PTP_DPC_CANON_MeteringMode, PTP_VENDOR_CANON, 5, N_("Center-weighted Average Metering")}, + {PTP_DPC_CANON_MeteringMode, PTP_VENDOR_CANON, 6, N_("Spot Metering Interlocked with AF Frame")}, + {PTP_DPC_CANON_MeteringMode, PTP_VENDOR_CANON, 7, N_("Multi-Spot Metering")}, + + {PTP_DPC_CANON_AFDistance, PTP_VENDOR_CANON, 0, N_("Manual")}, + {PTP_DPC_CANON_AFDistance, PTP_VENDOR_CANON, 1, N_("Auto")}, + {PTP_DPC_CANON_AFDistance, PTP_VENDOR_CANON, 2, N_("Unknown")}, + {PTP_DPC_CANON_AFDistance, PTP_VENDOR_CANON, 3, N_("Zone Focus (Close-up)")}, + {PTP_DPC_CANON_AFDistance, PTP_VENDOR_CANON, 4, N_("Zone Focus (Very Close)")}, + {PTP_DPC_CANON_AFDistance, PTP_VENDOR_CANON, 5, N_("Zone Focus (Close)")}, + {PTP_DPC_CANON_AFDistance, PTP_VENDOR_CANON, 6, N_("Zone Focus (Medium)")}, + {PTP_DPC_CANON_AFDistance, PTP_VENDOR_CANON, 7, N_("Zone Focus (Far)")}, + + {PTP_DPC_CANON_FocusingPoint, PTP_VENDOR_CANON, 0, N_("Invalid")}, + {PTP_DPC_CANON_FocusingPoint, PTP_VENDOR_CANON, 0x1000, N_("Focusing Point on Center Only, Manual")}, + {PTP_DPC_CANON_FocusingPoint, PTP_VENDOR_CANON, 0x1001, N_("Focusing Point on Center Only, Auto")}, + {PTP_DPC_CANON_FocusingPoint, PTP_VENDOR_CANON, 0x3000, N_("Multiple Focusing Points (No Specification), Manual")}, + {PTP_DPC_CANON_FocusingPoint, PTP_VENDOR_CANON, 0x3001, N_("Multiple Focusing Points, Auto")}, + {PTP_DPC_CANON_FocusingPoint, PTP_VENDOR_CANON, 0x3002, N_("Multiple Focusing Points (Right)")}, + {PTP_DPC_CANON_FocusingPoint, PTP_VENDOR_CANON, 0x3003, N_("Multiple Focusing Points (Center)")}, + {PTP_DPC_CANON_FocusingPoint, PTP_VENDOR_CANON, 0x3004, N_("Multiple Focusing Points (Left)")}, + + {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 0, N_("Auto")}, + {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 1, N_("Daylight")}, + {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 2, N_("Cloudy")}, + {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 3, N_("Tungsten")}, + {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 4, N_("Fluorescent")}, + {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 6, N_("Preset")}, + {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 7, N_("Fluorescent H")}, + {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 9, N_("Color Temperature")}, + {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 10, N_("Custom Whitebalance PC-1")}, + {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 11, N_("Custom Whitebalance PC-2")}, + {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 12, N_("Custom Whitebalance PC-3")}, + {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 13, N_("Missing Number")}, + {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 14, N_("Fluorescent H")}, /* dup? */ + + {PTP_DPC_CANON_SlowShutterSetting, PTP_VENDOR_CANON, 0, N_("Off")}, + {PTP_DPC_CANON_SlowShutterSetting, PTP_VENDOR_CANON, 1, N_("Night View")}, + {PTP_DPC_CANON_SlowShutterSetting, PTP_VENDOR_CANON, 2, N_("On")}, + {PTP_DPC_CANON_SlowShutterSetting, PTP_VENDOR_CANON, 3, N_("Low-speed shutter function not available")}, + + {PTP_DPC_CANON_AFMode, PTP_VENDOR_CANON, 0, N_("Single Shot")}, + {PTP_DPC_CANON_AFMode, PTP_VENDOR_CANON, 1, N_("AI Servo")}, + {PTP_DPC_CANON_AFMode, PTP_VENDOR_CANON, 2, N_("AI Focus")}, + {PTP_DPC_CANON_AFMode, PTP_VENDOR_CANON, 3, N_("Manual")}, + {PTP_DPC_CANON_AFMode, PTP_VENDOR_CANON, 4, N_("Continuous")}, + + PTP_VENDOR_VAL_BOOL(PTP_DPC_CANON_ImageStabilization,PTP_VENDOR_CANON), + + {PTP_DPC_CANON_Contrast, PTP_VENDOR_CANON, -2, N_("Low 2")}, + {PTP_DPC_CANON_Contrast, PTP_VENDOR_CANON, -1, N_("Low")}, + {PTP_DPC_CANON_Contrast, PTP_VENDOR_CANON, 0, N_("Standard")}, + {PTP_DPC_CANON_Contrast, PTP_VENDOR_CANON, 1, N_("High")}, + {PTP_DPC_CANON_Contrast, PTP_VENDOR_CANON, 2, N_("High 2")}, + + {PTP_DPC_CANON_ColorGain, PTP_VENDOR_CANON, -2, N_("Low 2")}, + {PTP_DPC_CANON_ColorGain, PTP_VENDOR_CANON, -1, N_("Low")}, + {PTP_DPC_CANON_ColorGain, PTP_VENDOR_CANON, 0, N_("Standard")}, + {PTP_DPC_CANON_ColorGain, PTP_VENDOR_CANON, 1, N_("High")}, + {PTP_DPC_CANON_ColorGain, PTP_VENDOR_CANON, 2, N_("High 2")}, + + {PTP_DPC_CANON_Sharpness, PTP_VENDOR_CANON, -2, N_("Low 2")}, + {PTP_DPC_CANON_Sharpness, PTP_VENDOR_CANON, -1, N_("Low")}, + {PTP_DPC_CANON_Sharpness, PTP_VENDOR_CANON, 0, N_("Standard")}, + {PTP_DPC_CANON_Sharpness, PTP_VENDOR_CANON, 1, N_("High")}, + {PTP_DPC_CANON_Sharpness, PTP_VENDOR_CANON, 2, N_("High 2")}, + + {PTP_DPC_CANON_Sensitivity, PTP_VENDOR_CANON, 0, N_("Standard")}, + {PTP_DPC_CANON_Sensitivity, PTP_VENDOR_CANON, 1, N_("Upper 1")}, + {PTP_DPC_CANON_Sensitivity, PTP_VENDOR_CANON, 2, N_("Upper 2")}, + + {PTP_DPC_CANON_ParameterSet, PTP_VENDOR_CANON, 0x08, N_("Standard Development Parameters")}, + {PTP_DPC_CANON_ParameterSet, PTP_VENDOR_CANON, 0x10, N_("Development Parameters 1")}, + {PTP_DPC_CANON_ParameterSet, PTP_VENDOR_CANON, 0x20, N_("Development Parameters 2")}, + {PTP_DPC_CANON_ParameterSet, PTP_VENDOR_CANON, 0x40, N_("Development Parameters 3")}, + + {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x00, N_("Auto")}, + {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x28, "6"}, + {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x30, "12"}, + {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x38, "25"}, + {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x40, "50"}, + {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x43, "64"}, + {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x48, "100"}, + {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x50, "200"}, + {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x58, "400"}, + {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x60, "800"}, + {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x68, "1600"}, + {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x70, "3200"}, + {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x78, "6400"}, + + /* 0xd01d - PTP_DPC_CANON_Aperture */ + /* 0xd01e - PTP_DPC_CANON_ShutterSpeed */ + /* 0xd01f - PTP_DPC_CANON_ExpCompensation */ + /* 0xd020 - PTP_DPC_CANON_FlashCompensation */ + /* 0xd021 - PTP_DPC_CANON_AEBExposureCompensation */ + /* 0xd023 - PTP_DPC_CANON_AvOpen */ + /* 0xd024 - PTP_DPC_CANON_AvMax */ + + {PTP_DPC_CANON_CameraOutput, PTP_VENDOR_CANON, 0, N_("Undefined")}, + {PTP_DPC_CANON_CameraOutput, PTP_VENDOR_CANON, 1, N_("LCD")}, + {PTP_DPC_CANON_CameraOutput, PTP_VENDOR_CANON, 2, N_("Video OUT")}, + {PTP_DPC_CANON_CameraOutput, PTP_VENDOR_CANON, 3, N_("Off")}, + + {PTP_DPC_CANON_MlSpotPos, PTP_VENDOR_CANON, 0, N_("MlSpotPosCenter")}, + {PTP_DPC_CANON_MlSpotPos, PTP_VENDOR_CANON, 1, N_("MlSpotPosAfLink")}, + + {PTP_DPC_CANON_PhotoEffect, PTP_VENDOR_CANON, 0, N_("Off")}, + {PTP_DPC_CANON_PhotoEffect, PTP_VENDOR_CANON, 1, N_("Vivid")}, + {PTP_DPC_CANON_PhotoEffect, PTP_VENDOR_CANON, 2, N_("Neutral")}, + {PTP_DPC_CANON_PhotoEffect, PTP_VENDOR_CANON, 3, N_("Soft")}, + {PTP_DPC_CANON_PhotoEffect, PTP_VENDOR_CANON, 4, N_("Sepia")}, + {PTP_DPC_CANON_PhotoEffect, PTP_VENDOR_CANON, 5, N_("Monochrome")}, + {0, 0, 0, NULL} }; for (i=0; ptp_value_trans[i].dpc!=0; i++) { @@ -345,12 +345,17 @@ typedef struct _PTPIPHeader PTPIPHeader; #define PTP_OC_NIKON_SetProfileData 0x9009 #define PTP_OC_NIKON_AdvancedTransfer 0x9010 #define PTP_OC_NIKON_GetFileInfoInBlock 0x9011 -#define PTP_OC_NIKON_Capture 0x90C0 -#define PTP_OC_NIKON_SetControlMode 0x90C2 -#define PTP_OC_NIKON_CurveDownload 0x90C5 -#define PTP_OC_NIKON_CurveUpload 0x90C6 -#define PTP_OC_NIKON_CheckEvent 0x90C7 -#define PTP_OC_NIKON_DeviceReady 0x90C8 +#define PTP_OC_NIKON_Capture 0x90C0 /* 1 param, no data */ +#define PTP_OC_NIKON_AfDrive 0x90C1 /* no params, no data */ +#define PTP_OC_NIKON_SetControlMode 0x90C2 /* 1 param, no data */ +#define PTP_OC_NIKON_DelImageSDRAM 0x90C3 /* no params, no data */ +#define PTP_OC_NIKON_CurveDownload 0x90C5 /* 1 param, data in */ +#define PTP_OC_NIKON_CurveUpload 0x90C6 /* 1 param, data out */ +#define PTP_OC_NIKON_CheckEvent 0x90C7 /* no params, data in */ +#define PTP_OC_NIKON_DeviceReady 0x90C8 /* no params, no data */ +#define PTP_OC_NIKON_SetPreWBData 0x90C9 /* 3 params, data out */ + /* 0x90CA */ +#define PTP_OC_NIKON_AfCaptureSDRAM 0x90CB /* no params, no data */ #define PTP_OC_NIKON_GetDevicePTPIPInfo 0x90E0 /* Microsoft / MTP extension codes */ @@ -1114,8 +1119,8 @@ typedef struct _PTPCanon_Property { #define CANON_TRANSFER_SAVE_THUMBNAIL_TO_DEVICE 0x0004 #define CANON_TRANSFER_SAVE_IMAGE_TO_DEVICE 0x0008 /* we use those values: */ -#define CANON_TRANSFER_MEMORY 3 -#define CANON_TRANSFER_CARD 15 +#define CANON_TRANSFER_MEMORY (2|1) +#define CANON_TRANSFER_CARD (8|4|1) #define PTP_DPC_CANON_Zoom 0xD02A #define PTP_DPC_CANON_NamePrefix 0xD02B @@ -1727,7 +1732,10 @@ uint16_t ptp_canon_endshootingmode (PTPParams* params); uint16_t ptp_canon_viewfinderon (PTPParams* params); uint16_t ptp_canon_viewfinderoff (PTPParams* params); -uint16_t ptp_canon_aeafawb (PTPParams* params, uint32_t p1); +#define PTP_CANON_RESET_AE 0x1 +#define PTP_CANON_RESET_AF 0x2 +#define PTP_CANON_RESET_AWB 0x4 +uint16_t ptp_canon_reset_aeafawb (PTPParams* params, uint32_t flags); uint16_t ptp_canon_checkevent (PTPParams* params, PTPUSBEventContainer* event, int* isevent); uint16_t ptp_canon_focuslock (PTPParams* params); @@ -1777,6 +1785,7 @@ uint16_t ptp_nikon_writewifiprofile (PTPParams* params, PTPNIKONWifiProfile* pro uint16_t ptp_nikon_deletewifiprofile (PTPParams* params, uint32_t profilenr); uint16_t ptp_nikon_setcontrolmode (PTPParams* params, uint32_t mode); uint16_t ptp_nikon_capture (PTPParams* params, uint32_t x); +uint16_t ptp_nikon_capture_sdram (PTPParams* params); uint16_t ptp_nikon_check_event (PTPParams* params, PTPUSBEventContainer **evt, int *evtcnt); uint16_t ptp_nikon_getfileinfoinblock (PTPParams* params, uint32_t p1, uint32_t p2, uint32_t p3, unsigned char **data, unsigned int *size); |