3 * Copyright (C) 2001-2004 Mariusz Woloszyn <emsi@ipartners.pl>
4 * Copyright (C) 2003-2012 Marcus Meissner <marcus@jet.franken.de>
5 * Copyright (C) 2006-2008 Linus Walleij <triad@df.lth.se>
6 * Copyright (C) 2007 Tero Saarni <tero.saarni@gmail.com>
7 * Copyright (C) 2009 Axel Waggershauser <awagger@web.de>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301 USA
27 #endif /* TIZEN_EXT */
33 # include <libxml/parser.h>
45 # define _(String) dgettext (PACKAGE, String)
47 # define N_(String) gettext_noop (String)
49 # define N_(String) (String)
52 # define textdomain(String) (String)
53 # define gettext(String) (String)
54 # define dgettext(Domain,Message) (Message)
55 # define dcgettext(Domain,Message,Type) (Message)
56 # define bindtextdomain(Domain,Directory) (Domain)
57 # define _(String) (String)
58 # define N_(String) (String)
61 #define CHECK_PTP_RC(result) {uint16_t r=(result); if (r!=PTP_RC_OK) return r;}
63 #define PTP_CNT_INIT(cnt) {memset(&cnt,0,sizeof(cnt));}
65 static uint16_t ptp_exit_recv_memory_handler (PTPDataHandler*,unsigned char**,unsigned long*);
66 static uint16_t ptp_init_recv_memory_handler(PTPDataHandler*);
67 static uint16_t ptp_init_send_memory_handler(PTPDataHandler*,unsigned char*,unsigned long len);
68 static uint16_t ptp_exit_send_memory_handler (PTPDataHandler *handler);
71 ptp_debug (PTPParams *params, const char *format, ...)
75 va_start (args, format);
76 if (params->debug_func!=NULL)
77 params->debug_func (params->data, format, args);
80 vfprintf (stderr, format, args);
81 fprintf (stderr,"\n");
88 ptp_error (PTPParams *params, const char *format, ...)
92 va_start (args, format);
93 if (params->error_func!=NULL)
94 params->error_func (params->data, format, args);
97 vfprintf (stderr, format, args);
98 fprintf (stderr,"\n");
104 /* Pack / unpack functions */
106 #include "ptp-pack.c"
108 /* major PTP functions */
110 /* Transaction data phase description */
111 #define PTP_DP_NODATA 0x0000 /* no data phase */
112 #define PTP_DP_SENDDATA 0x0001 /* sending data */
113 #define PTP_DP_GETDATA 0x0002 /* receiving data */
114 #define PTP_DP_DATA_MASK 0x00ff /* data phase mask */
119 * PTPContainer* ptp - general ptp container
120 * uint16_t flags - lower 8 bits - data phase description
121 * unsigned int sendlen - senddata phase data length
122 * char** data - send or receive data buffer pointer
123 * int* recvlen - receive data length
125 * Performs PTP transaction. ptp is a PTPContainer with appropriate fields
126 * filled in (i.e. operation code and parameters). It's up to caller to do
128 * The flags decide thether the transaction has a data phase and what is its
129 * direction (send or receive).
130 * If transaction is sending data the sendlen should contain its length in
131 * bytes, otherwise it's ignored.
132 * The data should contain an address of a pointer to data going to be sent
133 * or is filled with such a pointer address if data are received depending
134 * od dataphase direction (send or received) or is beeing ignored (no
136 * The memory for a pointer should be preserved by the caller, if data are
137 * beeing retreived the appropriate amount of memory is beeing allocated
138 * (the caller should handle that!).
140 * Return values: Some PTP_RC_* code.
141 * Upon success PTPContainer* ptp contains PTP Response Phase container with
142 * all fields filled in.
145 ptp_transaction_new (PTPParams* params, PTPContainer* ptp,
146 uint16_t flags, uint64_t sendlen,
147 PTPDataHandler *handler
152 if ((params==NULL) || (ptp==NULL))
153 return PTP_ERROR_BADPARAM;
156 ptp->Transaction_ID=params->transaction_id++;
157 ptp->SessionID=params->session_id;
159 CHECK_PTP_RC(params->sendreq_func (params, ptp));
160 /* is there a dataphase? */
161 switch (flags&PTP_DP_DATA_MASK) {
162 case PTP_DP_SENDDATA:
165 ret = params->senddata_func(params, ptp,
167 if (ret == PTP_ERROR_CANCEL) {
168 ret = params->cancelreq_func(params,
169 params->transaction_id-1);
170 if (ret == PTP_RC_OK)
171 ret = PTP_ERROR_CANCEL;
173 if (ret != PTP_RC_OK)
180 ret = params->getdata_func(params, ptp, handler);
181 if (ret == PTP_ERROR_CANCEL) {
182 ret = params->cancelreq_func(params,
183 params->transaction_id-1);
184 if (ret == PTP_RC_OK)
185 ret = PTP_ERROR_CANCEL;
187 if (ret != PTP_RC_OK)
194 return PTP_ERROR_BADPARAM;
200 ret = params->getresp_func(params, ptp);
201 if (ret == PTP_ERROR_RESP_EXPECTED) {
202 ptp_debug (params,"PTP: response expected but not got, retrying.");
206 if (ret != PTP_RC_OK)
209 if (ptp->Transaction_ID < params->transaction_id-1) {
212 "PTP: Sequence number mismatch %d vs expected %d, suspecting old reply.",
213 ptp->Transaction_ID, params->transaction_id-1
217 if (ptp->Transaction_ID != params->transaction_id-1) {
218 /* try to clean up potential left overs from previous session */
219 if ((cmd == PTP_OC_OpenSession) && tries)
222 "PTP: Sequence number mismatch %d vs expected %d.",
223 ptp->Transaction_ID, params->transaction_id-1
225 return PTP_ERROR_BADPARAM;
232 /* memory data get/put handler */
235 unsigned long size, curoff;
236 } PTPMemHandlerPrivate;
239 memory_getfunc(PTPParams* params, void* private,
240 unsigned long wantlen, unsigned char *data,
241 unsigned long *gotlen
243 PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)private;
244 unsigned long tocopy = wantlen;
246 if (priv->curoff + tocopy > priv->size)
247 tocopy = priv->size - priv->curoff;
248 memcpy (data, priv->data + priv->curoff, tocopy);
249 priv->curoff += tocopy;
255 memory_putfunc(PTPParams* params, void* private,
256 unsigned long sendlen, unsigned char *data,
257 unsigned long *putlen
259 PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)private;
261 if (priv->curoff + sendlen > priv->size) {
262 priv->data = realloc (priv->data, priv->curoff+sendlen);
264 return PTP_RC_GeneralError;
265 priv->size = priv->curoff + sendlen;
267 memcpy (priv->data + priv->curoff, data, sendlen);
268 priv->curoff += sendlen;
273 /* init private struct for receiving data. */
275 ptp_init_recv_memory_handler(PTPDataHandler *handler) {
276 PTPMemHandlerPrivate* priv;
277 priv = malloc (sizeof(PTPMemHandlerPrivate));
279 return PTP_RC_GeneralError;
280 handler->priv = priv;
281 handler->getfunc = memory_getfunc;
282 handler->putfunc = memory_putfunc;
289 /* init private struct and put data in for sending data.
290 * data is still owned by caller.
293 ptp_init_send_memory_handler(PTPDataHandler *handler,
294 unsigned char *data, unsigned long len
296 PTPMemHandlerPrivate* priv;
297 priv = malloc (sizeof(PTPMemHandlerPrivate));
299 return PTP_RC_GeneralError;
300 handler->priv = priv;
301 handler->getfunc = memory_getfunc;
302 handler->putfunc = memory_putfunc;
309 /* free private struct + data */
311 ptp_exit_send_memory_handler (PTPDataHandler *handler) {
312 PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)handler->priv;
313 /* data is owned by caller */
318 /* hand over our internal data to caller */
320 ptp_exit_recv_memory_handler (PTPDataHandler *handler,
321 unsigned char **data, unsigned long *size
323 PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)handler->priv;
330 /* fd data get/put handler */
333 } PTPFDHandlerPrivate;
336 fd_getfunc(PTPParams* params, void* private,
337 unsigned long wantlen, unsigned char *data,
338 unsigned long *gotlen
340 PTPFDHandlerPrivate* priv = (PTPFDHandlerPrivate*)private;
343 got = read (priv->fd, data, wantlen);
347 return PTP_RC_GeneralError;
352 fd_putfunc(PTPParams* params, void* private,
353 unsigned long sendlen, unsigned char *data,
354 unsigned long *putlen
357 PTPFDHandlerPrivate* priv = (PTPFDHandlerPrivate*)private;
359 written = write (priv->fd, data, sendlen);
363 return PTP_RC_GeneralError;
368 ptp_init_fd_handler(PTPDataHandler *handler, int fd) {
369 PTPFDHandlerPrivate* priv;
370 priv = malloc (sizeof(PTPFDHandlerPrivate));
372 return PTP_RC_GeneralError;
373 handler->priv = priv;
374 handler->getfunc = fd_getfunc;
375 handler->putfunc = fd_putfunc;
381 ptp_exit_fd_handler (PTPDataHandler *handler) {
382 PTPFDHandlerPrivate* priv = (PTPFDHandlerPrivate*)handler->priv;
387 /* Old style transaction, based on memory */
389 ptp_transaction (PTPParams* params, PTPContainer* ptp,
390 uint16_t flags, uint64_t sendlen,
391 unsigned char **data, unsigned int *recvlen
393 PTPDataHandler handler;
396 switch (flags & PTP_DP_DATA_MASK) {
397 case PTP_DP_SENDDATA:
398 ret = ptp_init_send_memory_handler (&handler, *data, sendlen);
399 if (ret != PTP_RC_OK) return ret;
402 ret = ptp_init_recv_memory_handler (&handler);
403 if (ret != PTP_RC_OK) return ret;
407 ret = ptp_transaction_new (params, ptp, flags, sendlen, &handler);
408 switch (flags & PTP_DP_DATA_MASK) {
409 case PTP_DP_SENDDATA:
410 ptp_exit_send_memory_handler (&handler);
412 case PTP_DP_GETDATA: {
414 ptp_exit_recv_memory_handler (&handler, data, &len);
426 * PTP operation functions
428 * all ptp_ functions should take integer parameters
429 * in host byte order!
437 * Gets device info dataset and fills deviceinfo structure.
439 * Return values: Some PTP_RC_* code.
442 ptp_getdeviceinfo (PTPParams* params, PTPDeviceInfo* deviceinfo)
447 unsigned char* di=NULL;
448 PTPDataHandler handler;
450 ptp_init_recv_memory_handler (&handler);
452 ptp.Code=PTP_OC_GetDeviceInfo;
455 ret=ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, &handler);
456 ptp_exit_recv_memory_handler (&handler, &di, &len);
457 if (!di) ret = PTP_RC_GeneralError;
458 if (ret == PTP_RC_OK) ptp_unpack_DI(params, di, deviceinfo, len);
464 ptp_canon_eos_getdeviceinfo (PTPParams* params, PTPCanonEOSDeviceInfo*di)
468 PTPDataHandler handler;
472 ptp_init_recv_memory_handler (&handler);
474 ptp.Code=PTP_OC_CANON_EOS_GetDeviceInfoEx;
478 ret=ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, &handler);
479 ptp_exit_recv_memory_handler (&handler, &data, &len);
480 if (ret == PTP_RC_OK) ptp_unpack_EOS_DI(params, data, di, len);
487 traverse_tree (PTPParams *params, int depth, xmlNodePtr node) {
495 xx = malloc (depth * 4 + 1);
496 memset (xx, ' ', depth*4);
499 n = xmlChildElementCount (node);
503 fprintf(stderr,"%snode %s\n", xx,next->name);
504 fprintf(stderr,"%selements %d\n", xx,n);
505 xchar = xmlNodeGetContent (next);
506 fprintf(stderr,"%scontent %s\n", xx,xchar);
507 traverse_tree (params, depth+1,xmlFirstElementChild (next));
508 } while ((next = xmlNextElementSibling (next)));
514 parse_9301_cmd_tree (PTPParams *params, xmlNodePtr node, PTPDeviceInfo *di) {
519 next = xmlFirstElementChild (node);
522 next = xmlNextElementSibling (next);
524 di->OperationsSupported_len = cnt;
525 di->OperationsSupported = malloc (cnt*sizeof(di->OperationsSupported[0]));
527 next = xmlFirstElementChild (node);
531 sscanf((char*)next->name, "c%04x", &p);
532 ptp_debug( params, "cmd %s / 0x%04x", next->name, p);
533 di->OperationsSupported[cnt++] = p;
534 next = xmlNextElementSibling (next);
540 parse_9301_value (PTPParams *params, const char *str, uint16_t type, PTPPropertyValue *propval) {
544 if (!sscanf(str,"%08x", &x)) {
545 ptp_debug( params, "could not parse uint32 %s", str);
546 return PTP_RC_GeneralError;
548 ptp_debug( params, "\t%d", x);
554 if (!sscanf(str,"%08x", &x)) {
555 ptp_debug( params, "could not parse int32 %s", str);
556 return PTP_RC_GeneralError;
558 ptp_debug( params, "\t%d", x);
564 if (!sscanf(str,"%04x", &x)) {
565 ptp_debug( params, "could not parse uint16 %s", str);
566 return PTP_RC_GeneralError;
568 ptp_debug( params, "\t%d", x);
574 if (!sscanf(str,"%04x", &x)) {
575 ptp_debug( params, "could not parse int16 %s", str);
576 return PTP_RC_GeneralError;
578 ptp_debug( params, "\t%d", x);
584 if (!sscanf(str,"%02x", &x)) {
585 ptp_debug( params, "could not parse uint8 %s", str);
586 return PTP_RC_GeneralError;
588 ptp_debug( params, "\t%d", x);
594 if (!sscanf(str,"%02x", &x)) {
595 ptp_debug( params, "could not parse int8 %s", str);
596 return PTP_RC_GeneralError;
598 ptp_debug( params, "\t%d", x);
602 case 65535: { /* string */
605 /* ascii ptp string, 1 byte length, little endian 16 bit chars */
606 if (sscanf(str,"%02x", &len)) {
608 char *xstr = malloc(len+1);
609 for (i=0;i<len;i++) {
611 if (sscanf(str+2+i*4,"%04x", &xc)) {
614 cx = ((xc>>8) & 0xff) | ((xc & 0xff) << 8);
619 ptp_debug( params, "\t%s", xstr);
623 ptp_debug( params, "string %s not parseable!", str);
624 return PTP_RC_GeneralError;
631 ptp_debug( params, "unhandled data type %d!", type);
632 return PTP_RC_GeneralError;
638 parse_9301_propdesc (PTPParams *params, xmlNodePtr next, PTPDevicePropDesc *dpd) {
642 return PTP_RC_GeneralError;
644 ptp_debug (params, "parse_9301_propdesc");
645 dpd->FormFlag = PTP_DPFF_None;
646 dpd->GetSet = PTP_DPGS_Get;
648 if (!strcmp((char*)next->name,"type")) { /* propdesc.DataType */
649 if (!sscanf((char*)xmlNodeGetContent (next), "%04x", &type)) {
650 ptp_debug( params, "\ttype %s not parseable?",xmlNodeGetContent (next));
653 ptp_debug( params, "type 0x%x", type);
654 dpd->DataType = type;
657 if (!strcmp((char*)next->name,"attribute")) { /* propdesc.GetSet */
660 if (!sscanf((char*)xmlNodeGetContent (next), "%02x", &attr)) {
661 ptp_debug( params, "\tattr %s not parseable",xmlNodeGetContent (next));
664 ptp_debug( params, "attribute 0x%x", attr);
668 if (!strcmp((char*)next->name,"default")) { /* propdesc.FactoryDefaultValue */
669 ptp_debug( params, "default value");
670 parse_9301_value (params, (char*)xmlNodeGetContent (next), type, &dpd->FactoryDefaultValue);
673 if (!strcmp((char*)next->name,"value")) { /* propdesc.CurrentValue */
674 ptp_debug( params, "current value");
675 parse_9301_value (params, (char*)xmlNodeGetContent (next), type, &dpd->CurrentValue);
678 if (!strcmp((char*)next->name,"enum")) { /* propdesc.FORM.Enum */
682 ptp_debug( params, "enum");
683 dpd->FormFlag = PTP_DPFF_Enumeration;
684 s = (char*)xmlNodeGetContent (next);
691 dpd->FORM.Enum.NumberOfValues = n;
692 dpd->FORM.Enum.SupportedValue = malloc (n * sizeof(PTPPropertyValue));
693 s = (char*)xmlNodeGetContent (next);
696 parse_9301_value (params, s, type, &dpd->FORM.Enum.SupportedValue[i]); /* should turn ' ' into \0? */
700 } while (s && (i<n));
703 if (!strcmp((char*)next->name,"range")) { /* propdesc.FORM.Enum */
704 char *s = (char*)xmlNodeGetContent (next);
705 dpd->FormFlag = PTP_DPFF_Range;
706 ptp_debug( params, "range");
707 parse_9301_value (params, s, type, &dpd->FORM.Range.MinimumValue); /* should turn ' ' into \0? */
711 parse_9301_value (params, s, type, &dpd->FORM.Range.MaximumValue); /* should turn ' ' into \0? */
715 parse_9301_value (params, s, type, &dpd->FORM.Range.StepSize); /* should turn ' ' into \0? */
719 ptp_debug (params, "\tpropdescvar: %s", next->name);
720 traverse_tree (params, 3, next);
721 } while ((next = xmlNextElementSibling (next)));
726 parse_9301_prop_tree (PTPParams *params, xmlNodePtr node, PTPDeviceInfo *di) {
732 next = xmlFirstElementChild (node);
735 next = xmlNextElementSibling (next);
738 di->DevicePropertiesSupported_len = cnt;
739 di->DevicePropertiesSupported = malloc (cnt*sizeof(di->DevicePropertiesSupported[0]));
741 next = xmlFirstElementChild (node);
744 PTPDevicePropDesc dpd;
746 sscanf((char*)next->name, "p%04x", &p);
747 ptp_debug( params, "prop %s / 0x%04x", next->name, p);
748 parse_9301_propdesc (params, xmlFirstElementChild (next), &dpd);
749 dpd.DevicePropertyCode = p;
750 di->DevicePropertiesSupported[cnt++] = p;
752 /* add to cache of device propdesc */
753 for (i=0;i<params->nrofdeviceproperties;i++)
754 if (params->deviceproperties[i].desc.DevicePropertyCode == p)
756 if (i == params->nrofdeviceproperties) {
758 params->deviceproperties = malloc(sizeof(params->deviceproperties[0]));
760 params->deviceproperties = realloc(params->deviceproperties,(i+1)*sizeof(params->deviceproperties[0]));
761 memset(¶ms->deviceproperties[i],0,sizeof(params->deviceproperties[0]));
762 params->nrofdeviceproperties++;
764 ptp_free_devicepropdesc (¶ms->deviceproperties[i].desc);
766 /* FIXME: free old entry */
767 /* we are not using dpd, so copy it directly to the cache */
768 time( ¶ms->deviceproperties[i].timestamp);
769 params->deviceproperties[i].desc = dpd;
771 next = xmlNextElementSibling (next);
777 parse_9301_event_tree (PTPParams *params, xmlNodePtr node, PTPDeviceInfo *di) {
782 next = xmlFirstElementChild (node);
785 next = xmlNextElementSibling (next);
787 di->EventsSupported_len = cnt;
788 di->EventsSupported = malloc (cnt*sizeof(di->EventsSupported[0]));
790 next = xmlFirstElementChild (node);
794 sscanf((char*)next->name, "e%04x", &p);
795 ptp_debug( params, "event %s / 0x%04x", next->name, p);
796 di->EventsSupported[cnt++] = p;
797 next = xmlNextElementSibling (next);
803 parse_9301_tree (PTPParams *params, xmlNodePtr node, PTPDeviceInfo *di) {
806 next = xmlFirstElementChild (node);
808 if (!strcmp ((char*)next->name, "cmd")) {
809 parse_9301_cmd_tree (params, next, di);
810 next = xmlNextElementSibling (next);
813 if (!strcmp ((char*)next->name, "prop")) {
814 parse_9301_prop_tree (params, next, di);
815 next = xmlNextElementSibling (next);
818 if (!strcmp ((char*)next->name, "event")) {
819 parse_9301_event_tree (params, next, di);
820 next = xmlNextElementSibling (next);
823 fprintf (stderr,"9301: unhandled type %s\n", next->name);
824 next = xmlNextElementSibling (next);
826 /*traverse_tree (0, node);*/
831 ptp_olympus_parse_output_xml(PTPParams* params, char*data, int len, xmlNodePtr *code) {
833 xmlNodePtr docroot, output, next;
838 docin = xmlReadMemory ((char*)data, len, "http://gphoto.org/", "utf-8", 0);
839 if (!docin) return PTP_RC_GeneralError;
840 docroot = xmlDocGetRootElement (docin);
843 return PTP_RC_GeneralError;
846 if (strcmp((char*)docroot->name,"x3c")) {
847 ptp_debug (params, "olympus: docroot is not x3c, but %s", docroot->name);
849 return PTP_RC_GeneralError;
851 if (xmlChildElementCount(docroot) != 1) {
852 ptp_debug (params, "olympus: x3c: expected 1 child, got %ld", xmlChildElementCount(docroot));
854 return PTP_RC_GeneralError;
856 output = xmlFirstElementChild (docroot);
857 if (strcmp((char*)output->name, "output") != 0) {
858 ptp_debug (params, "olympus: x3c node: expected child 'output', but got %s", (char*)output->name);
860 return PTP_RC_GeneralError;
862 next = xmlFirstElementChild (output);
864 result = PTP_RC_GeneralError;
867 if (!strcmp((char*)next->name,"result")) {
870 xchar = xmlNodeGetContent (next);
871 if (!sscanf((char*)xchar,"%04x",&result))
872 ptp_debug (params, "failed scanning result from %s", xchar);
873 ptp_debug (params, "ptp result is 0x%04x", result);
874 next = xmlNextElementSibling (next);
877 if (sscanf((char*)next->name,"c%x", &xcode)) {
878 ptp_debug (params, "ptp code node found %s", (char*)next->name);
880 next = xmlNextElementSibling (next);
883 ptp_debug (params, "unhandled node %s", (char*)next->name);
884 next = xmlNextElementSibling (next);
887 if (result != PTP_RC_OK) {
896 ptp_olympus_getdeviceinfo (PTPParams* params, PTPDeviceInfo *di)
901 PTPDataHandler handler;
906 memset (di, 0, sizeof(PTPDeviceInfo));
907 ptp_init_recv_memory_handler (&handler);
910 ptp.Code = PTP_OC_OLYMPUS_GetDeviceInfo;
914 ret=ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, &handler);
916 ptp_exit_recv_memory_handler (&handler, &data, &len);
918 ret = ptp_olympus_parse_output_xml(params,(char*)data,len,&code);
919 if (ret != PTP_RC_OK)
922 ret = parse_9301_tree (params, code, di);
924 xmlFreeDoc(code->doc);
927 return PTP_RC_GeneralError;
932 ptp_olympus_opensession (PTPParams* params, unsigned char**data, unsigned long *len)
936 PTPDataHandler handler;
938 ptp_init_recv_memory_handler (&handler);
940 ptp.Code = PTP_OC_OLYMPUS_OpenSession;
944 ret=ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, &handler);
945 ptp_exit_recv_memory_handler (&handler, data, len);
950 ptp_olympus_getcameraid (PTPParams* params, unsigned char**data, unsigned long *len)
954 PTPDataHandler handler;
956 ptp_init_recv_memory_handler (&handler);
958 ptp.Code = PTP_OC_OLYMPUS_GetCameraID;
962 ret=ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, &handler);
963 ptp_exit_recv_memory_handler (&handler, data, len);
968 * ptp_generic_no_data:
971 * n_param count of parameters
972 * ... variable argument list ...
974 * Emits a generic PTP command without any data transfer.
976 * Return values: Some PTP_RC_* code.
979 ptp_generic_no_data (PTPParams* params, uint16_t code, unsigned int n_param, ...)
986 return PTP_RC_InvalidParameter;
992 va_start(args, n_param);
993 for( i=0; i<n_param; ++i )
994 (&ptp.Param1)[i] = va_arg(args, uint32_t);
997 return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
1002 * params: PTPParams*
1003 * session - session number
1005 * Establishes a new session.
1007 * Return values: Some PTP_RC_* code.
1010 ptp_opensession (PTPParams* params, uint32_t session)
1015 ptp_debug(params,"PTP: Opening session");
1017 /* SessonID field of the operation dataset should always
1018 be set to 0 for OpenSession request! */
1019 params->session_id=0x00000000;
1020 /* TransactionID should be set to 0 also! */
1021 params->transaction_id=0x0000000;
1022 /* zero out response packet buffer */
1023 params->response_packet = NULL;
1024 params->response_packet_size = 0;
1025 /* no split headers */
1026 params->split_header_data = 0;
1029 ptp.Code=PTP_OC_OpenSession;
1032 ret=ptp_transaction_new(params, &ptp, PTP_DP_NODATA, 0, NULL);
1033 /* now set the global session id to current session number */
1034 params->session_id=session;
1039 ptp_free_devicepropvalue(uint16_t dt, PTPPropertyValue* dpd) {
1041 case PTP_DTC_INT8: case PTP_DTC_UINT8:
1042 case PTP_DTC_UINT16: case PTP_DTC_INT16:
1043 case PTP_DTC_UINT32: case PTP_DTC_INT32:
1044 case PTP_DTC_UINT64: case PTP_DTC_INT64:
1045 case PTP_DTC_UINT128: case PTP_DTC_INT128:
1046 /* Nothing to free */
1048 case PTP_DTC_AINT8: case PTP_DTC_AUINT8:
1049 case PTP_DTC_AUINT16: case PTP_DTC_AINT16:
1050 case PTP_DTC_AUINT32: case PTP_DTC_AINT32:
1051 case PTP_DTC_AUINT64: case PTP_DTC_AINT64:
1052 case PTP_DTC_AUINT128: case PTP_DTC_AINT128:
1064 ptp_free_devicepropdesc(PTPDevicePropDesc* dpd)
1068 ptp_free_devicepropvalue (dpd->DataType, &dpd->FactoryDefaultValue);
1069 ptp_free_devicepropvalue (dpd->DataType, &dpd->CurrentValue);
1070 switch (dpd->FormFlag) {
1071 case PTP_DPFF_Range:
1072 ptp_free_devicepropvalue (dpd->DataType, &dpd->FORM.Range.MinimumValue);
1073 ptp_free_devicepropvalue (dpd->DataType, &dpd->FORM.Range.MaximumValue);
1074 ptp_free_devicepropvalue (dpd->DataType, &dpd->FORM.Range.StepSize);
1076 case PTP_DPFF_Enumeration:
1077 if (dpd->FORM.Enum.SupportedValue) {
1078 for (i=0;i<dpd->FORM.Enum.NumberOfValues;i++)
1079 ptp_free_devicepropvalue (dpd->DataType, dpd->FORM.Enum.SupportedValue+i);
1080 free (dpd->FORM.Enum.SupportedValue);
1083 dpd->DataType = PTP_DTC_UNDEF;
1084 dpd->FormFlag = PTP_DPFF_None;
1089 ptp_free_objectpropdesc(PTPObjectPropDesc* opd)
1093 ptp_free_devicepropvalue (opd->DataType, &opd->FactoryDefaultValue);
1094 switch (opd->FormFlag) {
1097 case PTP_OPFF_Range:
1098 ptp_free_devicepropvalue (opd->DataType, &opd->FORM.Range.MinimumValue);
1099 ptp_free_devicepropvalue (opd->DataType, &opd->FORM.Range.MaximumValue);
1100 ptp_free_devicepropvalue (opd->DataType, &opd->FORM.Range.StepSize);
1102 case PTP_OPFF_Enumeration:
1103 if (opd->FORM.Enum.SupportedValue) {
1104 for (i=0;i<opd->FORM.Enum.NumberOfValues;i++)
1105 ptp_free_devicepropvalue (opd->DataType, opd->FORM.Enum.SupportedValue+i);
1106 free (opd->FORM.Enum.SupportedValue);
1109 case PTP_OPFF_DateTime:
1110 case PTP_OPFF_FixedLengthArray:
1111 case PTP_OPFF_RegularExpression:
1112 case PTP_OPFF_ByteArray:
1113 case PTP_OPFF_LongString:
1114 /* Ignore these presently, we cannot unpack them, so there is nothing to be freed. */
1117 fprintf (stderr, "Unknown OPFF type %d\n", opd->FormFlag);
1125 * params: PTPParams*
1127 * Frees all data within the PTPParams struct.
1129 * Return values: Some PTP_RC_* code.
1132 ptp_free_params (PTPParams *params) {
1135 if (params->cameraname) free (params->cameraname);
1136 if (params->wifi_profiles) free (params->wifi_profiles);
1137 for (i=0;i<params->nrofobjects;i++)
1138 ptp_free_object (¶ms->objects[i]);
1139 free (params->objects);
1140 free (params->events);
1141 for (i=0;i<params->nrofcanon_props;i++) {
1142 free (params->canon_props[i].data);
1143 ptp_free_devicepropdesc (¶ms->canon_props[i].dpd);
1145 free (params->canon_props);
1146 free (params->backlogentries);
1148 for (i=0;i<params->nrofdeviceproperties;i++)
1149 ptp_free_devicepropdesc (¶ms->deviceproperties[i].desc);
1150 free (params->deviceproperties);
1152 ptp_free_DI (¶ms->deviceinfo);
1156 * ptp_getststorageids:
1157 * params: PTPParams*
1159 * Gets array of StorageIDs and fills the storageids structure.
1161 * Return values: Some PTP_RC_* code.
1164 ptp_getstorageids (PTPParams* params, PTPStorageIDs* storageids)
1169 unsigned char* sids=NULL;
1172 ptp.Code=PTP_OC_GetStorageIDs;
1175 ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &sids, &len);
1176 if (ret == PTP_RC_OK) ptp_unpack_SIDs(params, sids, storageids, len);
1182 * ptp_getststorageinfo:
1183 * params: PTPParams*
1184 * storageid - StorageID
1186 * Gets StorageInfo dataset of desired storage and fills storageinfo
1189 * Return values: Some PTP_RC_* code.
1192 ptp_getstorageinfo (PTPParams* params, uint32_t storageid,
1193 PTPStorageInfo* storageinfo)
1197 unsigned char* si=NULL;
1201 ptp.Code=PTP_OC_GetStorageInfo;
1202 ptp.Param1=storageid;
1205 ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &si, &len);
1206 if (ret == PTP_RC_OK) ptp_unpack_SI(params, si, storageinfo, len);
1212 * ptp_getobjecthandles:
1213 * params: PTPParams*
1214 * storage - StorageID
1215 * objectformatcode - ObjectFormatCode (optional)
1216 * associationOH - ObjectHandle of Association for
1217 * wich a list of children is desired
1219 * objecthandles - pointer to structute
1221 * Fills objecthandles with structure returned by device.
1223 * Return values: Some PTP_RC_* code.
1226 ptp_getobjecthandles (PTPParams* params, uint32_t storage,
1227 uint32_t objectformatcode, uint32_t associationOH,
1228 PTPObjectHandles* objecthandles)
1232 unsigned char* oh=NULL;
1236 ptp.Code=PTP_OC_GetObjectHandles;
1238 ptp.Param2=objectformatcode;
1239 ptp.Param3=associationOH;
1242 ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &oh, &len);
1243 if (ret == PTP_RC_OK) {
1244 ptp_unpack_OH(params, oh, objecthandles, len);
1246 if ((storage == 0xffffffff) &&
1248 (associationOH == 0xffffffff)
1249 #else /* TIZEN_EXT */
1250 (objectformatcode == 0) &&
1251 (associationOH == 0)
1252 #endif /* TIZEN_EXT */
1254 /* When we query all object handles on all stores and
1255 * get an error -> just handle it as "0 handles".
1257 objecthandles->Handler = NULL;
1258 objecthandles->n = 0;
1267 ptp_getfilesystemmanifest (PTPParams* params, uint32_t storage,
1268 uint32_t objectformatcode, uint32_t associationOH,
1269 unsigned char** data)
1276 ptp.Code=PTP_OC_GetFilesystemManifest;
1278 ptp.Param2=objectformatcode;
1279 ptp.Param3=associationOH;
1282 ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, &len);
1287 * ptp_getnumobjects:
1288 * params: PTPParams*
1289 * storage - StorageID
1290 * objectformatcode - ObjectFormatCode (optional)
1291 * associationOH - ObjectHandle of Association for
1292 * wich a list of children is desired
1294 * numobs - pointer to uint32_t that takes number of objects
1296 * Fills numobs with number of objects on device.
1298 * Return values: Some PTP_RC_* code.
1301 ptp_getnumobjects (PTPParams* params, uint32_t storage,
1302 uint32_t objectformatcode, uint32_t associationOH,
1309 ptp.Code=PTP_OC_GetNumObjects;
1311 ptp.Param2=objectformatcode;
1312 ptp.Param3=associationOH;
1314 ret=ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
1315 if (ret == PTP_RC_OK) {
1316 if (ptp.Nparam >= 1)
1317 *numobs = ptp.Param1;
1319 ret = PTP_RC_GeneralError;
1325 * ptp_eos_bulbstart:
1326 * params: PTPParams*
1328 * Starts EOS Bulb capture.
1330 * Return values: Some PTP_RC_* code.
1333 ptp_canon_eos_bulbstart (PTPParams* params)
1339 ptp.Code = PTP_OC_CANON_EOS_BulbStart;
1341 ret = ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
1342 if ((ret == PTP_RC_OK) && (ptp.Nparam >= 1) && ((ptp.Param1 & 0x7000) == 0x2000))
1349 * params: PTPParams*
1352 * This starts a EOS400D style capture. You have to use the
1353 * get_eos_events to find out what resulted.
1354 * The return value is "0" for all OK, and "1" for capture failed. (not fully confirmed)
1356 * Return values: Some PTP_RC_* code.
1359 ptp_canon_eos_capture (PTPParams* params, uint32_t *result)
1365 ptp.Code = PTP_OC_CANON_EOS_RemoteRelease;
1368 ret = ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
1369 if ((ret == PTP_RC_OK) && (ptp.Nparam >= 1))
1370 *result = ptp.Param1;
1375 * ptp_canon_eos_bulbend:
1376 * params: PTPParams*
1378 * Starts EOS Bulb capture.
1380 * Return values: Some PTP_RC_* code.
1383 ptp_canon_eos_bulbend (PTPParams* params)
1389 ptp.Code = PTP_OC_CANON_EOS_BulbEnd;
1391 ret = ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
1392 if ((ret == PTP_RC_OK) && (ptp.Nparam >= 1) && ((ptp.Param1 & 0x7000) == 0x2000))
1398 * ptp_getobjectinfo:
1399 * params: PTPParams*
1400 * handle - Object handle
1401 * objectinfo - pointer to objectinfo that is returned
1403 * Get objectinfo structure for handle from device.
1405 * Return values: Some PTP_RC_* code.
1408 ptp_getobjectinfo (PTPParams* params, uint32_t handle,
1409 PTPObjectInfo* objectinfo)
1413 unsigned char* oi=NULL;
1417 ptp.Code=PTP_OC_GetObjectInfo;
1421 ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &oi, &len);
1422 if (ret == PTP_RC_OK) ptp_unpack_OI(params, oi, objectinfo, len);
1429 * params: PTPParams*
1430 * handle - Object handle
1431 * object - pointer to data area
1433 * Get object 'handle' from device and store the data in newly
1434 * allocated 'object'.
1436 * Return values: Some PTP_RC_* code.
1439 ptp_getobject (PTPParams* params, uint32_t handle, unsigned char** object)
1445 ptp.Code=PTP_OC_GetObject;
1449 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, object, &len);
1453 * ptp_getobject_to_handler:
1454 * params: PTPParams*
1455 * handle - Object handle
1456 * PTPDataHandler* - pointer datahandler
1458 * Get object 'handle' from device and store the data in newly
1459 * allocated 'object'.
1461 * Return values: Some PTP_RC_* code.
1464 ptp_getobject_to_handler (PTPParams* params, uint32_t handle, PTPDataHandler *handler)
1469 ptp.Code=PTP_OC_GetObject;
1472 return ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, handler);
1476 * ptp_getobject_tofd:
1477 * params: PTPParams*
1478 * handle - Object handle
1479 * fd - File descriptor to write() to
1481 * Get object 'handle' from device and write the data to the
1482 * given file descriptor.
1484 * Return values: Some PTP_RC_* code.
1487 ptp_getobject_tofd (PTPParams* params, uint32_t handle, int fd)
1490 PTPDataHandler handler;
1493 ptp_init_fd_handler (&handler, fd);
1495 ptp.Code=PTP_OC_GetObject;
1498 ret = ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, &handler);
1499 ptp_exit_fd_handler (&handler);
1504 * ptp_getpartialobject:
1505 * params: PTPParams*
1506 * handle - Object handle
1507 * offset - Offset into object
1508 * maxbytes - Maximum of bytes to read
1509 * object - pointer to data area
1510 * len - pointer to returned length
1512 * Get object 'handle' from device and store the data in newly
1513 * allocated 'object'. Start from offset and read at most maxbytes.
1515 * Return values: Some PTP_RC_* code.
1518 ptp_getpartialobject (PTPParams* params, uint32_t handle, uint32_t offset,
1519 uint32_t maxbytes, unsigned char** object,
1525 ptp.Code=PTP_OC_GetPartialObject;
1528 ptp.Param3=maxbytes;
1531 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, object, len);
1536 * params: PTPParams*
1537 * handle - Object handle
1538 * object - pointer to data area
1540 * Get thumb for object 'handle' from device and store the data in newly
1541 * allocated 'object'.
1543 * Return values: Some PTP_RC_* code.
1546 ptp_getthumb (PTPParams* params, uint32_t handle, unsigned char** object, unsigned int *len)
1551 ptp.Code=PTP_OC_GetThumb;
1555 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, object, len);
1560 * params: PTPParams*
1561 * handle - object handle
1562 * ofc - object format code (optional)
1564 * Deletes desired objects.
1566 * Return values: Some PTP_RC_* code.
1569 ptp_deleteobject (PTPParams* params, uint32_t handle, uint32_t ofc)
1575 ptp.Code=PTP_OC_DeleteObject;
1579 ret = ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
1580 if (ret != PTP_RC_OK) {
1583 /* If the object is cached and could be removed, cleanse cache. */
1584 ptp_remove_object_from_cache(params, handle);
1589 * ptp_sendobjectinfo:
1590 * params: PTPParams*
1591 * uint32_t* store - destination StorageID on Responder
1592 * uint32_t* parenthandle - Parent ObjectHandle on responder
1593 * uint32_t* handle - see Return values
1594 * PTPObjectInfo* objectinfo- ObjectInfo that is to be sent
1596 * Sends ObjectInfo of file that is to be sent via SendFileObject.
1598 * Return values: Some PTP_RC_* code.
1599 * Upon success : uint32_t* store - Responder StorageID in which
1600 * object will be stored
1601 * uint32_t* parenthandle- Responder Parent ObjectHandle
1602 * in which the object will be stored
1603 * uint32_t* handle - Responder's reserved ObjectHandle
1604 * for the incoming object
1607 ptp_sendobjectinfo (PTPParams* params, uint32_t* store,
1608 uint32_t* parenthandle, uint32_t* handle,
1609 PTPObjectInfo* objectinfo)
1613 unsigned char* oidata=NULL;
1617 ptp.Code=PTP_OC_SendObjectInfo;
1619 ptp.Param2=*parenthandle;
1622 size=ptp_pack_OI(params, objectinfo, &oidata);
1623 ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &oidata, NULL);
1626 *parenthandle=ptp.Param2;
1633 * params: PTPParams*
1634 * char* object - contains the object that is to be sent
1635 * uint64_t size - object size
1637 * Sends object to Responder.
1639 * Return values: Some PTP_RC_* code.
1643 ptp_sendobject (PTPParams* params, unsigned char* object, uint64_t size)
1648 ptp.Code=PTP_OC_SendObject;
1651 return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &object, NULL);
1655 * ptp_sendobject_from_handler:
1656 * params: PTPParams*
1657 * PTPDataHandler* - File descriptor to read() object from
1658 * uint64_t size - File/object size
1660 * Sends object from file descriptor by consecutive reads from this
1663 * Return values: Some PTP_RC_* code.
1666 ptp_sendobject_from_handler (PTPParams* params, PTPDataHandler *handler, uint64_t size)
1671 ptp.Code=PTP_OC_SendObject;
1673 return ptp_transaction_new(params, &ptp, PTP_DP_SENDDATA, size, handler);
1678 * ptp_sendobject_fromfd:
1679 * params: PTPParams*
1680 * fd - File descriptor to read() object from
1681 * uint64_t size - File/object size
1683 * Sends object from file descriptor by consecutive reads from this
1686 * Return values: Some PTP_RC_* code.
1689 ptp_sendobject_fromfd (PTPParams* params, int fd, uint64_t size)
1692 PTPDataHandler handler;
1695 ptp_init_fd_handler (&handler, fd);
1697 ptp.Code=PTP_OC_SendObject;
1699 ret = ptp_transaction_new(params, &ptp, PTP_DP_SENDDATA, size, &handler);
1700 ptp_exit_fd_handler (&handler);
1704 #define PROPCACHE_TIMEOUT 5 /* seconds */
1707 ptp_getdevicepropdesc (PTPParams* params, uint16_t propcode,
1708 PTPDevicePropDesc* devicepropertydesc)
1713 unsigned char* dpd=NULL;
1717 ptp.Code = PTP_OC_GetDevicePropDesc;
1718 ptp.Param1 = propcode;
1721 ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &dpd, &len);
1723 if (ret == PTP_RC_OK) {
1724 if (params->device_flags & DEVICE_FLAG_OLYMPUS_XML_WRAPPED) {
1728 ret = ptp_olympus_parse_output_xml (params,(char*)dpd,len,&code);
1729 if (ret == PTP_RC_OK) {
1732 if ( (xmlChildElementCount(code) == 1) &&
1733 (!strcmp((char*)code->name,"c1014"))
1735 code = xmlFirstElementChild (code);
1737 if ( (sscanf((char*)code->name,"p%x", &x)) &&
1740 ret = parse_9301_propdesc (params, xmlFirstElementChild (code), devicepropertydesc);
1741 xmlFreeDoc(code->doc);
1745 ptp_debug(params,"failed to parse output xml, ret %x?", ret);
1749 ptp_unpack_DPD(params, dpd, devicepropertydesc, len);
1758 ptp_getdevicepropvalue (PTPParams* params, uint16_t propcode,
1759 PTPPropertyValue* value, uint16_t datatype)
1763 unsigned int len, offset;
1764 unsigned char* dpv=NULL;
1768 ptp.Code=PTP_OC_GetDevicePropValue;
1769 ptp.Param1=propcode;
1772 ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &dpv, &len);
1773 if (ret == PTP_RC_OK) {
1774 int ret2 = ptp_unpack_DPV(params, dpv, &offset, len, value, datatype);
1776 ptp_debug (params, "ptp_getdevicepropvalue: unpacking DPV failed");
1777 ret = PTP_RC_GeneralError;
1785 ptp_setdevicepropvalue (PTPParams* params, uint16_t propcode,
1786 PTPPropertyValue *value, uint16_t datatype)
1791 unsigned char* dpv=NULL;
1794 ptp.Code=PTP_OC_SetDevicePropValue;
1795 ptp.Param1=propcode;
1797 size=ptp_pack_DPV(params, value, &dpv, datatype);
1798 ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &dpv, NULL);
1804 * ptp_ek_sendfileobjectinfo:
1805 * params: PTPParams*
1806 * uint32_t* store - destination StorageID on Responder
1807 * uint32_t* parenthandle - Parent ObjectHandle on responder
1808 * uint32_t* handle - see Return values
1809 * PTPObjectInfo* objectinfo- ObjectInfo that is to be sent
1811 * Sends ObjectInfo of file that is to be sent via SendFileObject.
1813 * Return values: Some PTP_RC_* code.
1814 * Upon success : uint32_t* store - Responder StorageID in which
1815 * object will be stored
1816 * uint32_t* parenthandle- Responder Parent ObjectHandle
1817 * in which the object will be stored
1818 * uint32_t* handle - Responder's reserved ObjectHandle
1819 * for the incoming object
1822 ptp_ek_sendfileobjectinfo (PTPParams* params, uint32_t* store,
1823 uint32_t* parenthandle, uint32_t* handle,
1824 PTPObjectInfo* objectinfo)
1828 unsigned char* oidata=NULL;
1832 ptp.Code=PTP_OC_EK_SendFileObjectInfo;
1834 ptp.Param2=*parenthandle;
1837 size=ptp_pack_OI(params, objectinfo, &oidata);
1838 ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &oidata, NULL);
1841 *parenthandle=ptp.Param2;
1848 * params: PTPParams*
1849 * char** serial - contains the serial number of the camera
1850 * uint32_t* size - contains the string length
1852 * Gets the serial number from the device. (ptp serial)
1854 * Return values: Some PTP_RC_* code.
1858 ptp_ek_getserial (PTPParams* params, unsigned char **data, unsigned int *size)
1863 ptp.Code = PTP_OC_EK_GetSerial;
1865 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size);
1870 * params: PTPParams*
1871 * char* serial - contains the new serial number
1872 * uint32_t size - string length
1874 * Sets the serial number of the device. (ptp serial)
1876 * Return values: Some PTP_RC_* code.
1880 ptp_ek_setserial (PTPParams* params, unsigned char *data, unsigned int size)
1885 ptp.Code = PTP_OC_EK_SetSerial;
1887 return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL);
1890 /* unclear what it does yet */
1892 ptp_ek_9007 (PTPParams* params, unsigned char **data, unsigned int *size)
1899 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size);
1902 /* unclear what it does yet */
1904 ptp_ek_9009 (PTPParams* params, uint32_t *p1, uint32_t *p2)
1912 ret = ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
1918 /* unclear yet, but I guess it returns the info from 9008 */
1920 ptp_ek_900c (PTPParams* params, unsigned char **data, unsigned int *size)
1927 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size);
1928 /* returned data is 16bit,16bit,32bit,32bit */
1933 * params: PTPParams*
1934 * PTPEKTextParams* - contains the texts to display.
1936 * Displays the specified texts on the TFT of the camera.
1938 * Return values: Some PTP_RC_* code.
1942 ptp_ek_settext (PTPParams* params, PTPEKTextParams *text)
1947 unsigned char *data;
1950 ptp.Code = PTP_OC_EK_SetText;
1952 if (0 == (size = ptp_pack_EK_text(params, text, &data)))
1953 return PTP_ERROR_BADPARAM;
1954 ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL);
1960 * ptp_ek_sendfileobject:
1961 * params: PTPParams*
1962 * char* object - contains the object that is to be sent
1963 * uint32_t size - object size
1965 * Sends object to Responder.
1967 * Return values: Some PTP_RC_* code.
1971 ptp_ek_sendfileobject (PTPParams* params, unsigned char* object, uint32_t size)
1976 ptp.Code=PTP_OC_EK_SendFileObject;
1979 return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &object, NULL);
1983 * ptp_ek_sendfileobject_from_handler:
1984 * params: PTPParams*
1985 * PTPDataHandler* handler - contains the handler of the object that is to be sent
1986 * uint32_t size - object size
1988 * Sends object to Responder.
1990 * Return values: Some PTP_RC_* code.
1994 ptp_ek_sendfileobject_from_handler (PTPParams* params, PTPDataHandler*handler, uint32_t size)
1999 ptp.Code=PTP_OC_EK_SendFileObject;
2001 return ptp_transaction_new(params, &ptp, PTP_DP_SENDDATA, size, handler);
2004 /*************************************************************************
2006 * Canon PTP extensions support
2008 * (C) Nikolai Kopanygin 2003
2010 *************************************************************************/
2014 * ptp_canon_getpartialobjectinfo:
2015 * params: PTPParams*
2016 * uint32_t handle - ObjectHandle
2017 * uint32_t p2 - Not fully understood parameter
2018 * 0 - returns full size
2019 * 1 - returns thumbnail size (or EXIF?)
2021 * Gets form the responder the size of the specified object.
2023 * Return values: Some PTP_RC_* code.
2024 * Upon success : uint32_t* size - The object size
2025 * uint32_t* rp2 - Still unknown return parameter
2026 * (perhaps upper 32bit of size)
2031 ptp_canon_getpartialobjectinfo (PTPParams* params, uint32_t handle, uint32_t p2,
2032 uint32_t* size, uint32_t* rp2)
2038 ptp.Code=PTP_OC_CANON_GetPartialObjectInfo;
2042 ret=ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
2049 * ptp_canon_get_mac_address:
2050 * params: PTPParams*
2052 * Gets the MAC address of the wireless transmitter.
2054 * Return values: Some PTP_RC_* code.
2055 * Upon success : unsigned char* mac - The MAC address
2059 ptp_canon_get_mac_address (PTPParams* params, unsigned char **mac)
2062 unsigned int size = 0;
2065 ptp.Code=PTP_OC_CANON_GetMACAddress;
2068 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, mac, &size);
2072 * ptp_canon_get_directory:
2073 * params: PTPParams*
2075 * Gets the full directory of the camera.
2077 * Return values: Some PTP_RC_* code.
2078 * Upon success : PTPObjectHandles *handles - filled out with handles
2079 * PTPObjectInfo **oinfos - allocated array of PTP Object Infos
2080 * uint32_t **flags - allocated array of CANON Flags
2084 ptp_canon_get_directory (PTPParams* params,
2085 PTPObjectHandles *handles,
2086 PTPObjectInfo **oinfos, /* size(handles->n) */
2087 uint32_t **flags /* size(handles->n) */
2090 unsigned char *dir = NULL;
2091 unsigned int size = 0;
2095 ptp.Code=PTP_OC_CANON_GetDirectory;
2097 ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &dir, &size);
2098 if (ret != PTP_RC_OK)
2100 ret = ptp_unpack_canon_directory(params, dir, ptp.Param1, handles, oinfos, flags);
2106 * ptp_canon_gettreeinfo:
2107 * params: PTPParams*
2110 * Switches the camera display to on and lets the user
2111 * select what to transfer. Sends a 0xc011 event when started
2112 * and 0xc013 if direct transfer aborted.
2114 * Return values: Some PTP_RC_* code.
2118 ptp_canon_gettreeinfo (PTPParams* params, uint32_t *out)
2124 ptp.Code = PTP_OC_CANON_GetTreeInfo;
2127 ret = ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
2128 if ((ret == PTP_RC_OK) && (ptp.Nparam>0))
2134 * ptp_canon_getpairinginfo:
2135 * params: PTPParams*
2138 * Get the pairing information.
2140 * Return values: Some PTP_RC_* code.
2144 ptp_canon_getpairinginfo (PTPParams* params, uint32_t nr, unsigned char **data, unsigned int *size)
2150 ptp.Code = PTP_OC_CANON_GetPairingInfo;
2155 ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size);
2156 if (ret != PTP_RC_OK)
2162 * ptp_canon_get_target_handles:
2163 * params: PTPParams*
2164 * PTPCanon_directtransfer_entry **out
2165 * unsigned int *outsize
2167 * Retrieves direct transfer entries specifying the images to transfer
2168 * from the camera (to be retrieved after 0xc011 event).
2170 * Return values: Some PTP_RC_* code.
2174 ptp_canon_gettreesize (PTPParams* params,
2175 PTPCanon_directtransfer_entry **entries, unsigned int *cnt)
2179 unsigned char *out = NULL, *cur;
2180 unsigned int i, size;
2183 ptp.Code = PTP_OC_CANON_GetTreeSize;
2185 ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &out, &size);
2186 if (ret != PTP_RC_OK)
2188 *cnt = dtoh32a(out);
2189 *entries = malloc(sizeof(PTPCanon_directtransfer_entry)*(*cnt));
2192 return PTP_RC_GeneralError;
2195 for (i=0;i<*cnt;i++) {
2197 (*entries)[i].oid = dtoh32a(cur);
2198 (*entries)[i].str = ptp_unpack_string(params, cur, 4, &len);
2199 cur += 4+(cur[4]*2+1);
2206 * ptp_canon_checkevent:
2207 * params: PTPParams*
2209 * The camera has a FIFO stack, in which it accumulates events.
2210 * Partially these events are communicated also via the USB interrupt pipe
2211 * according to the PTP USB specification, partially not.
2212 * This operation returns from the device a block of data, empty,
2213 * if the event stack is empty, or filled with an event's data otherwise.
2214 * The event is removed from the stack in the latter case.
2215 * The Remote Capture app sends this command to the camera all the time
2216 * of connection, filling with it the gaps between other operations.
2218 * Return values: Some PTP_RC_* code.
2219 * Upon success : PTPUSBEventContainer* event - is filled with the event data
2221 * int *isevent - returns 1 in case of event
2225 ptp_canon_checkevent (PTPParams* params, PTPContainer* event, int* isevent)
2229 unsigned char *evdata = NULL;
2234 ptp.Code=PTP_OC_CANON_CheckEvent;
2237 ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &evdata, &len);
2239 if (ret == PTP_RC_OK) {
2240 ptp_unpack_EC(params, evdata, event, len);
2249 ptp_add_event (PTPParams *params, PTPContainer *evt) {
2250 if (params->nrofevents)
2251 params->events = realloc(params->events, sizeof(PTPContainer)*(params->nrofevents+1));
2253 params->events = malloc(sizeof(PTPContainer)*1);
2254 memcpy (¶ms->events[params->nrofevents],evt,1*sizeof(PTPContainer));
2255 params->nrofevents += 1;
2260 ptp_check_event (PTPParams *params) {
2264 if ( (params->deviceinfo.VendorExtensionID == PTP_VENDOR_NIKON) &&
2265 ptp_operation_issupported(params, PTP_OC_NIKON_CheckEvent)
2267 unsigned int evtcnt;
2268 PTPContainer *xevent = NULL;
2270 ret = ptp_nikon_check_event(params, &xevent, &evtcnt);
2271 if (ret != PTP_RC_OK)
2275 if (params->nrofevents)
2276 params->events = realloc(params->events, sizeof(PTPContainer)*(evtcnt+params->nrofevents));
2278 params->events = malloc(sizeof(PTPContainer)*evtcnt);
2279 memcpy (¶ms->events[params->nrofevents],xevent,evtcnt*sizeof(PTPContainer));
2280 params->nrofevents += evtcnt;
2285 /* should not get here ... EOS has no normal PTP events and another queue handling. */
2286 if ( (params->deviceinfo.VendorExtensionID == PTP_VENDOR_CANON) &&
2287 ptp_operation_issupported(params, PTP_OC_CANON_EOS_GetEvent)
2292 if ( (params->deviceinfo.VendorExtensionID == PTP_VENDOR_CANON) &&
2293 ptp_operation_issupported(params, PTP_OC_CANON_CheckEvent)
2297 ret = ptp_canon_checkevent (params,&event,&isevent);
2302 /* Event Emulate Mode 0 (unset) and 1-5 get interrupt events. 6-7 does not. */
2303 if (params->canon_event_mode > 5)
2306 /* FIXME: fallthrough or return? */
2308 /* the libusb 1 on darwin currently does not like polling
2309 * for interrupts, they have no timeout for it. 2010/08/23
2310 * Check back in 2011 or so. -Marcus
2315 ret = params->event_check(params,&event);
2318 if (ret == PTP_RC_OK) {
2319 ptp_debug (params, "event: nparams=0x%X, code=0x%X, trans_id=0x%X, p1=0x%X, p2=0x%X, p3=0x%X", event.Nparam,event.Code,event.Transaction_ID, event.Param1, event.Param2, event.Param3);
2320 ptp_add_event (params, &event);
2322 if (ret == PTP_ERROR_TIMEOUT) /* ok, just new events */
2328 ptp_get_one_event(PTPParams *params, PTPContainer *event) {
2329 if (!params->nrofevents)
2331 memcpy (event, params->events, sizeof(PTPContainer));
2332 memmove (params->events, params->events+1, sizeof(PTPContainer)*(params->nrofevents-1));
2333 /* do not realloc on shrink. */
2334 params->nrofevents--;
2335 if (!params->nrofevents) {
2336 free (params->events);
2337 params->events = NULL;
2343 * ptp_canon_eos_getevent:
2345 * This retrieves configuration status/updates/changes
2346 * on EOS cameras. It reads a datablock which has a list of variable
2349 * params: PTPParams*
2351 * Return values: Some PTP_RC_* code.
2355 ptp_canon_eos_getevent (PTPParams* params, PTPCanon_changes_entry **entries, int *nrofentries)
2359 unsigned int size = 0;
2360 unsigned char *data = NULL;
2365 ptp.Code = PTP_OC_CANON_EOS_GetEvent;
2367 ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size);
2368 if (ret != PTP_RC_OK) return ret;
2369 *nrofentries = ptp_unpack_CANON_changes(params,data,size,entries);
2375 ptp_check_eos_events (PTPParams *params) {
2377 PTPCanon_changes_entry *entries = NULL, *nentries;
2378 int nrofentries = 0;
2380 while (1) { /* call it repeatedly until the camera does not report any */
2381 ret = ptp_canon_eos_getevent (params, &entries, &nrofentries);
2382 if (ret != PTP_RC_OK)
2387 if (params->nrofbacklogentries) {
2388 nentries = realloc(params->backlogentries,sizeof(entries[0])*(params->nrofbacklogentries+nrofentries));
2390 return PTP_RC_GeneralError;
2391 params->backlogentries = nentries;
2392 memcpy (nentries+params->nrofbacklogentries, entries, nrofentries*sizeof(entries[0]));
2393 params->nrofbacklogentries += nrofentries;
2396 params->backlogentries = entries;
2397 params->nrofbacklogentries = nrofentries;
2404 ptp_get_one_eos_event (PTPParams *params, PTPCanon_changes_entry *entry) {
2405 if (!params->nrofbacklogentries)
2407 memcpy (entry, params->backlogentries, sizeof(*entry));
2408 if (params->nrofbacklogentries > 1) {
2409 memmove (params->backlogentries,params->backlogentries+1,sizeof(*entry)*(params->nrofbacklogentries-1));
2410 params->nrofbacklogentries--;
2412 free (params->backlogentries);
2413 params->backlogentries = NULL;
2414 params->nrofbacklogentries = 0;
2421 ptp_canon_eos_getdevicepropdesc (PTPParams* params, uint16_t propcode,
2422 PTPDevicePropDesc *dpd)
2426 for (i=0;i<params->nrofcanon_props;i++)
2427 if (params->canon_props[i].proptype == propcode)
2429 if (params->nrofcanon_props == i)
2430 return PTP_RC_Undefined;
2431 memcpy (dpd, ¶ms->canon_props[i].dpd, sizeof (*dpd));
2432 if (dpd->FormFlag == PTP_DPFF_Enumeration) {
2433 /* need to duplicate the Enumeration alloc */
2434 dpd->FORM.Enum.SupportedValue = malloc (sizeof (PTPPropertyValue)*dpd->FORM.Enum.NumberOfValues);
2435 memcpy (dpd->FORM.Enum.SupportedValue,
2436 params->canon_props[i].dpd.FORM.Enum.SupportedValue,
2437 sizeof (PTPPropertyValue)*dpd->FORM.Enum.NumberOfValues
2440 if (dpd->DataType == PTP_DTC_STR) {
2441 dpd->FactoryDefaultValue.str = strdup( params->canon_props[i].dpd.FactoryDefaultValue.str );
2442 dpd->CurrentValue.str = strdup( params->canon_props[i].dpd.CurrentValue.str );
2450 ptp_canon_eos_getstorageids (PTPParams* params, PTPStorageIDs* storageids)
2453 unsigned int len = 0;
2455 unsigned char* sids=NULL;
2458 ptp.Code = PTP_OC_CANON_EOS_GetStorageIDs;
2460 ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &sids, &len);
2461 if (ret == PTP_RC_OK) ptp_unpack_SIDs(params, sids, storageids, len);
2467 ptp_canon_eos_getstorageinfo (PTPParams* params, uint32_t p1, unsigned char **data, unsigned int *size)
2475 ptp.Code = PTP_OC_CANON_EOS_GetStorageInfo;
2478 ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size);
2479 /* FIXME: do stuff with data */
2484 ptp_canon_eos_getobjectinfoex (
2485 PTPParams* params, uint32_t storageid, uint32_t oid, uint32_t unk,
2486 PTPCANONFolderEntry **entries, unsigned int *nrofentries
2489 unsigned int i, size = 0;
2490 unsigned char *data, *xdata;
2495 ptp.Code = PTP_OC_CANON_EOS_GetObjectInfoEx;
2497 ptp.Param1 = storageid;
2500 ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size);
2501 if (ret != PTP_RC_OK)
2509 *nrofentries = dtoh32a(data);
2510 *entries = malloc(*nrofentries * sizeof(PTPCANONFolderEntry));
2513 return PTP_RC_GeneralError;
2516 xdata = data+sizeof(uint32_t);
2517 for (i=0;i<*nrofentries;i++) {
2518 ptp_unpack_Canon_EOS_FE (params, &xdata[4], &((*entries)[i]));
2519 xdata += dtoh32a(xdata);
2526 * ptp_canon_eos_getpartialobject:
2528 * This retrieves a part of an PTP object which you specify as object id.
2529 * The id originates from 0x9116 call.
2530 * After finishing it, we seem to need to call ptp_canon_eos_enddirecttransfer.
2532 * params: PTPParams*
2534 * offset The offset where to start the data transfer
2535 * xsize Size in bytes of the transfer to do
2536 * data Pointer that receives the malloc()ed memory of the transfer.
2538 * Return values: Some PTP_RC_* code.
2542 ptp_canon_eos_getpartialobject (PTPParams* params, uint32_t oid, uint32_t offset, uint32_t xsize, unsigned char**data)
2545 unsigned int size = 0;
2549 ptp.Code = PTP_OC_CANON_EOS_GetPartialObject;
2552 ptp.Param2 = offset;
2554 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, &size);
2558 ptp_canon_eos_setdevicepropvalueex (PTPParams* params, unsigned char* data, unsigned int size)
2563 ptp.Code = PTP_OC_CANON_EOS_SetDevicePropValueEx;
2565 return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL);
2569 ptp_canon_eos_setdevicepropvalue (PTPParams* params,
2570 uint16_t propcode, PTPPropertyValue *value, uint16_t datatype
2574 unsigned int i, size;
2575 unsigned char *data;
2578 ptp.Code = PTP_OC_CANON_EOS_SetDevicePropValueEx;
2580 for (i=0;i<params->nrofcanon_props;i++)
2581 if (params->canon_props[i].proptype == propcode)
2583 if (params->nrofcanon_props == i)
2584 return PTP_RC_Undefined;
2587 case PTP_DPC_CANON_EOS_ImageFormat:
2588 case PTP_DPC_CANON_EOS_ImageFormatCF:
2589 case PTP_DPC_CANON_EOS_ImageFormatSD:
2590 case PTP_DPC_CANON_EOS_ImageFormatExtHD:
2591 /* special handling of ImageFormat properties */
2592 size = 8 + ptp_pack_EOS_ImageFormat( params, NULL, value->u16 );
2593 data = malloc( size );
2594 if (!data) return PTP_RC_GeneralError;
2595 params->canon_props[i].dpd.CurrentValue.u16 = value->u16;
2596 ptp_pack_EOS_ImageFormat( params, data + 8, value->u16 );
2598 case PTP_DPC_CANON_EOS_CustomFuncEx:
2599 /* special handling of CustomFuncEx properties */
2600 ptp_debug (params, "ptp2/ptp_canon_eos_setdevicepropvalue: setting EOS prop %x to %s",propcode,value->str);
2601 size = 8 + ptp_pack_EOS_CustomFuncEx( params, NULL, value->str );
2602 data = malloc( size );
2603 if (!data) return PTP_RC_GeneralError;
2604 params->canon_props[i].dpd.CurrentValue.str = strdup( value->str );
2605 ptp_pack_EOS_CustomFuncEx( params, data + 8, value->str );
2608 if (datatype != PTP_DTC_STR) {
2609 data = calloc(sizeof(uint32_t),3);
2610 if (!data) return PTP_RC_GeneralError;
2611 size = sizeof(uint32_t)*3;
2613 size = strlen(value->str) + 1 + 8;
2614 data = calloc(sizeof(char),size);
2615 if (!data) return PTP_RC_GeneralError;
2620 /*fprintf (stderr, "%x -> %d\n", propcode, value->u8);*/
2621 htod8a(&data[8], value->u8);
2622 params->canon_props[i].dpd.CurrentValue.u8 = value->u8;
2624 case PTP_DTC_UINT16:
2626 /*fprintf (stderr, "%x -> %d\n", propcode, value->u16);*/
2627 htod16a(&data[8], value->u16);
2628 params->canon_props[i].dpd.CurrentValue.u16 = value->u16;
2631 case PTP_DTC_UINT32:
2632 /*fprintf (stderr, "%x -> %d\n", propcode, value->u32);*/
2633 htod32a(&data[8], value->u32);
2634 params->canon_props[i].dpd.CurrentValue.u32 = value->u32;
2637 strcpy((char*)data + 8, value->str);
2638 free (params->canon_props[i].dpd.CurrentValue.str);
2639 params->canon_props[i].dpd.CurrentValue.str = strdup(value->str);
2644 htod32a(&data[0], size);
2645 htod32a(&data[4], propcode);
2647 ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL);
2653 * ptp_canon_getpartialobject:
2655 * This operation is used to read from the device a data
2656 * block of an object from a specified offset.
2658 * params: PTPParams*
2659 * uint32_t handle - the handle of the requested object
2660 * uint32_t offset - the offset in bytes from the beginning of the object
2661 * uint32_t size - the requested size of data block to read
2662 * uint32_t pos - 1 for the first block, 2 - for a block in the middle,
2663 * 3 - for the last block
2665 * Return values: Some PTP_RC_* code.
2666 * char **block - the pointer to the block of data read
2667 * uint32_t* readnum - the number of bytes read
2671 ptp_canon_getpartialobject (PTPParams* params, uint32_t handle,
2672 uint32_t offset, uint32_t size,
2673 uint32_t pos, unsigned char** block,
2678 unsigned char *data=NULL;
2682 ptp.Code=PTP_OC_CANON_GetPartialObjectEx;
2689 ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &len);
2690 if (ret==PTP_RC_OK) {
2692 *readnum=ptp.Param1;
2698 * ptp_canon_getviewfinderimage:
2700 * This operation can be used to read the image which is currently
2701 * in the camera's viewfinder. The image size is 320x240, format is JPEG.
2702 * Of course, prior to calling this operation, one must turn the viewfinder
2703 * on with the CANON_ViewfinderOn command.
2704 * Invoking this operation many times, one can get live video from the camera!
2706 * params: PTPParams*
2708 * Return values: Some PTP_RC_* code.
2709 * char **image - the pointer to the read image
2710 * unit32_t *size - the size of the image in bytes
2714 ptp_canon_getviewfinderimage (PTPParams* params, unsigned char** image, uint32_t* size)
2721 ptp.Code=PTP_OC_CANON_GetViewfinderImage;
2723 ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, image, &len);
2724 if (ret==PTP_RC_OK) *size=ptp.Param1;
2729 * ptp_canon_getchanges:
2731 * This is an interesting operation, about the effect of which I am not sure.
2732 * This command is called every time when a device property has been changed
2733 * with the SetDevicePropValue operation, and after some other operations.
2734 * This operation reads the array of Device Properties which have been changed
2735 * by the previous operation.
2736 * Probably, this operation is even required to make those changes work.
2738 * params: PTPParams*
2740 * Return values: Some PTP_RC_* code.
2741 * uint16_t** props - the pointer to the array of changed properties
2742 * uint32_t* propnum - the number of elements in the *props array
2746 ptp_canon_getchanges (PTPParams* params, uint16_t** props, uint32_t* propnum)
2750 unsigned char* data=NULL;
2754 ptp.Code=PTP_OC_CANON_GetChanges;
2757 ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &len);
2758 if (ret == PTP_RC_OK)
2759 *propnum=ptp_unpack_uint16_t_array(params,data,0,props);
2765 * ptp_canon_getobjectinfo:
2767 * This command reads a specified object's record in a device's filesystem,
2768 * or the records of all objects belonging to a specified folder (association).
2770 * params: PTPParams*
2771 * uint32_t store - StorageID,
2772 * uint32_t p2 - Yet unknown (0 value works OK)
2773 * uint32_t parent - Parent Object Handle
2774 * # If Parent Object Handle is 0xffffffff,
2775 * # the Parent Object is the top level folder.
2776 * uint32_t handle - Object Handle
2777 * # If Object Handle is 0, the records of all objects
2778 * # belonging to the Parent Object are read.
2779 * # If Object Handle is not 0, only the record of this
2782 * Return values: Some PTP_RC_* code.
2783 * PTPCANONFolderEntry** entries - the pointer to the folder entry array
2784 * uint32_t* entnum - the number of elements of the array
2788 ptp_canon_getobjectinfo (PTPParams* params, uint32_t store, uint32_t p2,
2789 uint32_t parent, uint32_t handle,
2790 PTPCANONFolderEntry** entries, uint32_t* entnum)
2794 unsigned char *data = NULL;
2798 ptp.Code=PTP_OC_CANON_GetObjectInfoEx;
2805 ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &len);
2806 if (ret == PTP_RC_OK) {
2809 *entries=calloc(*entnum, sizeof(PTPCANONFolderEntry));
2810 if (*entries!=NULL) {
2811 for(i=0; i<(*entnum); i++)
2812 ptp_unpack_Canon_FE(params,
2813 data+i*PTP_CANON_FolderEntryLen,
2816 ret=PTP_ERROR_IO; /* Cannot allocate memory */
2824 * ptp_canon_get_objecthandle_by_name:
2826 * This command looks up the specified object on the camera.
2828 * Format is "A:\\PATH".
2830 * The 'A' is the VolumeLabel from GetStorageInfo,
2831 * my IXUS has "A" for the card and "V" for internal memory.
2833 * params: PTPParams*
2834 * char* name - path name
2836 * Return values: Some PTP_RC_* code.
2837 * uint32_t *oid - PTP object id.
2841 ptp_canon_get_objecthandle_by_name (PTPParams* params, char* name, uint32_t* objectid)
2845 unsigned char *data = NULL;
2849 ptp.Code=PTP_OC_CANON_GetObjectHandleByName;
2852 data = malloc (2*(strlen(name)+1)+2);
2853 memset (data, 0, 2*(strlen(name)+1)+2);
2854 ptp_pack_string (params, name, data, 0, &len);
2855 ret=ptp_transaction (params, &ptp, PTP_DP_SENDDATA, (len+1)*2+1, &data, NULL);
2857 *objectid = ptp.Param1;
2862 * ptp_canon_get_customize_data:
2864 * This command downloads the specified theme slot, including jpegs
2867 * params: PTPParams*
2868 * uint32_t themenr - nr of theme
2870 * Return values: Some PTP_RC_* code.
2871 * unsigned char **data - pointer to data pointer
2872 * unsigned int *size - size of data returned
2876 ptp_canon_get_customize_data (PTPParams* params, uint32_t themenr,
2877 unsigned char **data, unsigned int *size)
2884 ptp.Code = PTP_OC_CANON_GetCustomizeData;
2885 ptp.Param1 = themenr;
2887 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size);
2892 ptp_nikon_curve_download (PTPParams* params, unsigned char **data, unsigned int *size) {
2897 ptp.Code = PTP_OC_NIKON_CurveDownload;
2899 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size);
2903 * ptp_sony_sdioconnect:
2905 * This changes modes of the camera
2907 * params: PTPParams*
2909 * Return values: Some PTP_RC_* code.
2913 ptp_sony_sdioconnect (PTPParams* params, uint32_t p1, uint32_t p2, uint32_t p3) {
2916 unsigned char *xdata = NULL;
2920 ptp.Code = PTP_OC_SONY_SDIOConnect;
2925 ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &xdata, &xsize);
2930 * ptp_sony_get_vendorpropcodes:
2932 * This command downloads the vendor specific property codes.
2934 * params: PTPParams*
2936 * Return values: Some PTP_RC_* code.
2937 * unsigned char **data - pointer to data pointer
2938 * unsigned int *size - size of data returned
2942 ptp_sony_get_vendorpropcodes (PTPParams* params, uint16_t **props, unsigned int *size) {
2945 unsigned char *xdata = NULL;
2951 ptp.Code = PTP_OC_SONY_GetSDIOGetExtDeviceInfo;
2953 ptp.Param1 = 0xc8; /* unclear */
2954 ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &xdata, &xsize);
2955 /* first 16 bit is 0xc8 0x00, then an array of 16 bit PTP ids */
2956 if (ret == PTP_RC_OK)
2957 *size = ptp_unpack_uint16_t_array(params,xdata+2,0,props);
2963 ptp_sony_getdevicepropdesc (PTPParams* params, uint16_t propcode, PTPDevicePropDesc *dpd) {
2966 unsigned char *xdata = NULL;
2967 unsigned int xsize,len = 0;
2970 ptp.Code = PTP_OC_SONY_GetDevicePropdesc;
2972 ptp.Param1 = propcode;
2973 ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &xdata, &xsize);
2974 /* first 16 bit is 0xc8 0x00, then an array of 16 bit PTP ids */
2975 if (ret == PTP_RC_OK)
2976 ret = ptp_unpack_Sony_DPD(params,xdata,dpd,xsize,&len)?PTP_RC_OK:PTP_RC_GeneralError;
2982 ptp_sony_getalldevicepropdesc (PTPParams* params)
2986 unsigned char *data = NULL , *dpddata;
2987 uint32_t size = 0, readlen;
2988 PTPDevicePropDesc dpd;
2991 ptp.Code = PTP_OC_SONY_GetAllDevicePropData;
2993 ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size);
2994 if (ret != PTP_RC_OK)
2996 dpddata = data+8; /* nr of entries 32bit, 0 32bit */
3002 if (!ptp_unpack_Sony_DPD (params, dpddata, &dpd, size, &readlen))
3005 propcode = dpd.DevicePropertyCode;
3007 for (i=0;i<params->nrofdeviceproperties;i++)
3008 if (params->deviceproperties[i].desc.DevicePropertyCode == propcode)
3011 if (i == params->nrofdeviceproperties) {
3013 params->deviceproperties = malloc(sizeof(params->deviceproperties[0]));
3015 params->deviceproperties = realloc(params->deviceproperties,(i+1)*sizeof(params->deviceproperties[0]));
3016 memset(¶ms->deviceproperties[i],0,sizeof(params->deviceproperties[0]));
3017 params->nrofdeviceproperties++;
3019 ptp_free_devicepropdesc (¶ms->deviceproperties[i].desc);
3021 params->deviceproperties[i].desc = dpd;
3023 ptp_debug (params, "dpd.DevicePropertyCode %04x, readlen %d, getset %d", dpd.DevicePropertyCode, readlen, dpd.GetSet);
3024 switch (dpd.DataType) {
3026 ptp_debug (params, "value %d/%x", dpd.CurrentValue.i8, dpd.CurrentValue.i8);
3029 ptp_debug (params, "value %d/%x", dpd.CurrentValue.u8, dpd.CurrentValue.u8);
3031 case PTP_DTC_UINT16:
3032 ptp_debug (params, "value %d/%x", dpd.CurrentValue.u16, dpd.CurrentValue.u16);
3035 ptp_debug (params, "value %d/%x", dpd.CurrentValue.i16, dpd.CurrentValue.i16);
3038 ptp_debug (params, "value %d/%x", dpd.CurrentValue.i32, dpd.CurrentValue.i32);
3040 case PTP_DTC_UINT32:
3041 ptp_debug (params, "value %d/%x", dpd.CurrentValue.u32, dpd.CurrentValue.u32);
3044 ptp_debug (params, "unknown type %x", dpd.DataType);
3056 ptp_sony_setdevicecontrolvaluea (PTPParams* params, uint16_t propcode,
3057 PTPPropertyValue *value, uint16_t datatype)
3062 unsigned char* dpv=NULL;
3065 ptp.Code = PTP_OC_SONY_SetControlDeviceA;
3066 ptp.Param1 = propcode;
3068 size = ptp_pack_DPV(params, value, &dpv, datatype);
3069 ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &dpv, NULL);
3075 ptp_sony_setdevicecontrolvalueb (PTPParams* params, uint16_t propcode,
3076 PTPPropertyValue *value, uint16_t datatype)
3081 unsigned char* dpv=NULL;
3084 ptp.Code = PTP_OC_SONY_SetControlDeviceB;
3085 ptp.Param1 = propcode;
3087 size = ptp_pack_DPV(params, value, &dpv, datatype);
3088 ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &dpv, NULL);
3094 * ptp_generic_getdevicepropdesc:
3096 * This command gets a propertydesc.
3097 * If a vendor specific property desc query is available, it uses that.
3098 * If not, it falls back to the generic PTP getdevicepropdesc.
3100 * params: PTPParams*
3102 * PTPDevicePropDesc *dpd
3104 * Return values: Some PTP_RC_* code.
3107 /* Cache time in seconds. Should perhaps be more granular... */
3111 ptp_generic_getdevicepropdesc (PTPParams *params, uint16_t propcode, PTPDevicePropDesc *dpd)
3117 for (i=0;i<params->nrofdeviceproperties;i++)
3118 if (params->deviceproperties[i].desc.DevicePropertyCode == propcode)
3120 if (i == params->nrofdeviceproperties) {
3122 params->deviceproperties = malloc(sizeof(params->deviceproperties[0]));
3124 params->deviceproperties = realloc(params->deviceproperties,(i+1)*sizeof(params->deviceproperties[0]));
3125 memset(¶ms->deviceproperties[i],0,sizeof(params->deviceproperties[0]));
3126 params->nrofdeviceproperties++;
3129 if (params->deviceproperties[i].desc.DataType != PTP_DTC_UNDEF) {
3131 if ((now - params->deviceproperties[i].timestamp) <= CACHETIME) {
3132 duplicate_DevicePropDesc(¶ms->deviceproperties[i].desc, dpd);
3135 /* free cached entry as we will refetch it. */
3136 ptp_free_devicepropdesc (¶ms->deviceproperties[i].desc);
3139 if ( (params->deviceinfo.VendorExtensionID == PTP_VENDOR_SONY) &&
3140 ptp_operation_issupported(params, PTP_OC_SONY_GetAllDevicePropData)
3142 ret = ptp_sony_getalldevicepropdesc (params);
3143 if (ret != PTP_RC_OK)
3146 for (i=0;i<params->nrofdeviceproperties;i++)
3147 if (params->deviceproperties[i].desc.DevicePropertyCode == propcode)
3150 params->deviceproperties[i].timestamp = now;
3151 duplicate_DevicePropDesc(¶ms->deviceproperties[i].desc, dpd);
3154 if ( (params->deviceinfo.VendorExtensionID == PTP_VENDOR_SONY) &&
3155 ptp_operation_issupported(params, PTP_OC_SONY_GetDevicePropdesc)
3157 ret = ptp_sony_getdevicepropdesc (params, propcode, ¶ms->deviceproperties[i].desc);
3158 if (ret != PTP_RC_OK)
3162 params->deviceproperties[i].timestamp = now;
3163 duplicate_DevicePropDesc(¶ms->deviceproperties[i].desc, dpd);
3168 if (ptp_operation_issupported(params, PTP_OC_GetDevicePropDesc)) {
3169 ret = ptp_getdevicepropdesc (params, propcode, ¶ms->deviceproperties[i].desc);
3170 if (ret != PTP_RC_OK)
3174 params->deviceproperties[i].timestamp = now;
3175 duplicate_DevicePropDesc(¶ms->deviceproperties[i].desc, dpd);
3183 * ptp_generic_setdevicepropvalue:
3185 * This command sets a property value, device specific.
3187 * params: PTPParams*
3189 * PTPDevicePropertyValue *value
3192 * Return values: Some PTP_RC_* code.
3196 ptp_generic_setdevicepropvalue (PTPParams* params, uint16_t propcode,
3197 PTPPropertyValue *value, uint16_t datatype)
3199 /* FIXME: change the cache? hmm */
3200 if ( (params->deviceinfo.VendorExtensionID == PTP_VENDOR_SONY) &&
3201 ptp_operation_issupported(params, PTP_OC_SONY_SetControlDeviceB)
3203 return ptp_sony_setdevicecontrolvaluea (params, propcode, value, datatype);
3204 return ptp_setdevicepropvalue (params, propcode, value, datatype);
3208 * ptp_nikon_get_vendorpropcodes:
3210 * This command downloads the vendor specific property codes.
3212 * params: PTPParams*
3214 * Return values: Some PTP_RC_* code.
3215 * unsigned char **data - pointer to data pointer
3216 * unsigned int *size - size of data returned
3220 ptp_nikon_get_vendorpropcodes (PTPParams* params, uint16_t **props, unsigned int *size) {
3223 unsigned char *xdata = NULL;
3229 ptp.Code = PTP_OC_NIKON_GetVendorPropCodes;
3231 ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &xdata, &xsize);
3232 if (ret == PTP_RC_OK)
3233 *size = ptp_unpack_uint16_t_array(params,xdata,0,props);
3239 ptp_nikon_getfileinfoinblock ( PTPParams* params,
3240 uint32_t p1, uint32_t p2, uint32_t p3,
3241 unsigned char **data, unsigned int *size
3247 ptp.Code = PTP_OC_NIKON_GetFileInfoInBlock;
3252 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size);
3256 * ptp_nikon_get_liveview_image:
3258 * This command gets a LiveView image from newer Nikons DSLRs.
3260 * params: PTPParams*
3262 * Return values: Some PTP_RC_* code.
3266 ptp_nikon_get_liveview_image (PTPParams* params, unsigned char **data, unsigned int *size)
3271 ptp.Code=PTP_OC_NIKON_GetLiveViewImg;
3273 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size);
3277 * ptp_nikon_get_preview_image:
3279 * This command gets a Preview image from newer Nikons DSLRs.
3281 * params: PTPParams*
3283 * Return values: Some PTP_RC_* code.
3287 ptp_nikon_get_preview_image (PTPParams* params, unsigned char **xdata, unsigned int *xsize,
3294 ptp.Code=PTP_OC_NIKON_GetPreviewImg;
3297 * pdslrdashboard passes 3 parameters:
3298 * objectid, minimum size, maximum size
3300 ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, xdata, xsize);
3301 if (ret == PTP_RC_OK) {
3303 *handle = ptp.Param1;
3309 * ptp_canon_eos_get_viewfinder_image:
3311 * This command gets a Viewfinder image from newer Nikons DSLRs.
3313 * params: PTPParams*
3315 * Return values: Some PTP_RC_* code.
3319 ptp_canon_eos_get_viewfinder_image (PTPParams* params, unsigned char **data, unsigned int *size)
3324 ptp.Code=PTP_OC_CANON_EOS_GetViewFinderData;
3326 ptp.Param1=0x00100000; /* from trace */
3327 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size);
3331 ptp_canon_eos_get_viewfinder_image_handler (PTPParams* params, PTPDataHandler*handler)
3336 ptp.Code=PTP_OC_CANON_EOS_GetViewFinderData;
3338 ptp.Param1=0x00100000; /* from trace */
3339 return ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, handler);
3343 * ptp_nikon_check_event:
3345 * This command checks the event queue on the Nikon.
3347 * params: PTPParams*
3348 * PTPUSBEventContainer **event - list of usb events.
3349 * int *evtcnt - number of usb events in event structure.
3351 * Return values: Some PTP_RC_* code.
3355 ptp_nikon_check_event (PTPParams* params, PTPContainer** event, unsigned int* evtcnt)
3359 unsigned char *data = NULL;
3360 unsigned int size = 0;
3363 ptp.Code=PTP_OC_NIKON_CheckEvent;
3366 ret = ptp_transaction (params, &ptp, PTP_DP_GETDATA, 0, &data, &size);
3367 if (ret == PTP_RC_OK) {
3368 ptp_unpack_Nikon_EC (params, data, size, event, evtcnt);
3375 * ptp_nikon_getptpipinfo:
3377 * This command gets the ptpip info data.
3379 * params: PTPParams*
3380 * unsigned char *data - data
3381 * unsigned int size - size of returned data
3383 * Return values: Some PTP_RC_* code.
3387 ptp_nikon_getptpipinfo (PTPParams* params, unsigned char **data, unsigned int *size)
3392 ptp.Code=PTP_OC_NIKON_GetDevicePTPIPInfo;
3394 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size);
3398 * ptp_nikon_getwifiprofilelist:
3400 * This command gets the wifi profile list.
3402 * params: PTPParams*
3404 * Return values: Some PTP_RC_* code.
3408 ptp_nikon_getwifiprofilelist (PTPParams* params)
3411 unsigned char* data;
3420 ptp.Code=PTP_OC_NIKON_GetProfileAllData;
3424 CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size));
3426 if (size < 2) return PTP_RC_Undefined; /* FIXME: Add more precise error code */
3428 params->wifi_profiles_version = data[0];
3429 params->wifi_profiles_number = data[1];
3430 if (params->wifi_profiles)
3431 free(params->wifi_profiles);
3433 params->wifi_profiles = malloc(params->wifi_profiles_number*sizeof(PTPNIKONWifiProfile));
3434 memset(params->wifi_profiles, 0, params->wifi_profiles_number*sizeof(PTPNIKONWifiProfile));
3438 while (profn < params->wifi_profiles_number && pos < size) {
3439 if (pos+6 >= size) return PTP_RC_Undefined;
3440 params->wifi_profiles[profn].id = data[pos++];
3441 params->wifi_profiles[profn].valid = data[pos++];
3443 n = dtoh32a(&data[pos]);
3445 if (pos+n+4 >= size) return PTP_RC_Undefined;
3446 strncpy(params->wifi_profiles[profn].profile_name, (char*)&data[pos], n);
3447 params->wifi_profiles[profn].profile_name[16] = '\0';
3450 params->wifi_profiles[profn].display_order = data[pos++];
3451 params->wifi_profiles[profn].device_type = data[pos++];
3452 params->wifi_profiles[profn].icon_type = data[pos++];
3454 buffer = ptp_unpack_string(params, data, pos, &len);
3455 strncpy(params->wifi_profiles[profn].creation_date, buffer, sizeof(params->wifi_profiles[profn].creation_date));
3458 if (pos+1 >= size) return PTP_RC_Undefined;
3459 /* FIXME: check if it is really last usage date */
3460 buffer = ptp_unpack_string(params, data, pos, &len);
3461 strncpy(params->wifi_profiles[profn].lastusage_date, buffer, sizeof(params->wifi_profiles[profn].lastusage_date));
3464 if (pos+5 >= size) return PTP_RC_Undefined;
3466 n = dtoh32a(&data[pos]);
3468 if (pos+n >= size) return PTP_RC_Undefined;
3469 strncpy(params->wifi_profiles[profn].essid, (char*)&data[pos], n);
3470 params->wifi_profiles[profn].essid[32] = '\0';
3477 PTPNIKONWifiProfile test;
3478 memset(&test, 0, sizeof(PTPNIKONWifiProfile));
3479 strcpy(test.profile_name, "MyTest");
3481 strcpy(test.essid, "nikon");
3482 test.ip_address = 10 + 11 << 16 + 11 << 24;
3483 test.subnet_mask = 24;
3484 test.access_mode = 1;
3485 test.wifi_channel = 1;
3488 ptp_nikon_writewifiprofile(params, &test);
3495 * ptp_nikon_writewifiprofile:
3497 * This command gets the ptpip info data.
3499 * params: PTPParams*
3500 * unsigned int profilenr - profile number
3501 * unsigned char *data - data
3502 * unsigned int size - size of returned data
3504 * Return values: Some PTP_RC_* code.
3508 ptp_nikon_writewifiprofile (PTPParams* params, PTPNIKONWifiProfile* profile)
3510 unsigned char guid[16];
3513 unsigned char buffer[1024];
3514 unsigned char* data = buffer;
3520 ptp_nikon_getptpipguid(guid);
3522 if (!params->wifi_profiles)
3523 CHECK_PTP_RC(ptp_nikon_getwifiprofilelist(params));
3525 for (i = 0; i < params->wifi_profiles_number; i++) {
3526 if (!params->wifi_profiles[i].valid) {
3527 profilenr = params->wifi_profiles[i].id;
3532 if (profilenr == -1) {
3533 /* No free profile! */
3534 return PTP_RC_StoreFull;
3537 memset(buffer, 0, 1024);
3539 buffer[0x00] = 0x64; /* Version */
3542 htod32a(&buffer[0x01], 17);
3543 /* 16 as third parameter, so there will always be a null-byte in the end */
3544 strncpy((char*)&buffer[0x05], profile->profile_name, 16);
3546 buffer[0x16] = 0x00; /* Display order */
3547 buffer[0x17] = profile->device_type;
3548 buffer[0x18] = profile->icon_type;
3550 /* FIXME: Creation date: put a real date here */
3551 ptp_pack_string(params, "19990909T090909", data, 0x19, &len);
3554 memcpy(&buffer[0x3A],&profile->ip_address,sizeof(profile->ip_address));
3555 /**((unsigned int*)&buffer[0x3A]) = profile->ip_address; *//* Do not reverse bytes */
3556 buffer[0x3E] = profile->subnet_mask;
3557 memcpy(&buffer[0x3F],&profile->gateway_address,sizeof(profile->gateway_address));
3558 /**((unsigned int*)&buffer[0x3F]) = profile->gateway_address; */ /* Do not reverse bytes */
3559 buffer[0x43] = profile->address_mode;
3561 /* Wifi parameters */
3562 buffer[0x44] = profile->access_mode;
3563 buffer[0x45] = profile->wifi_channel;
3565 htod32a(&buffer[0x46], 33); /* essid */
3566 /* 32 as third parameter, so there will always be a null-byte in the end */
3567 strncpy((char*)&buffer[0x4A], profile->essid, 32);
3569 buffer[0x6B] = profile->authentification;
3570 buffer[0x6C] = profile->encryption;
3571 htod32a(&buffer[0x6D], 64);
3572 for (i = 0; i < 64; i++) {
3573 buffer[0x71+i] = profile->key[i];
3575 buffer[0xB1] = profile->key_nr;
3576 memcpy(&buffer[0xB2], guid, 16);
3578 switch(profile->encryption) {
3579 case 1: /* WEP 64bit */
3580 htod16a(&buffer[0xC2], 5); /* (64-24)/8 = 5 */
3582 case 2: /* WEP 128bit */
3583 htod16a(&buffer[0xC2], 13); /* (128-24)/8 = 13 */
3586 htod16a(&buffer[0xC2], 0);
3591 ptp.Code=PTP_OC_NIKON_SendProfileData;
3593 ptp.Param1=profilenr;
3594 return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL);
3598 * ptp_mtp_getobjectpropssupported:
3600 * This command gets the object properties possible from the device.
3602 * params: PTPParams*
3603 * uint ofc - object format code
3604 * unsigned int *propnum - number of elements in returned array
3605 * uint16_t *props - array of supported properties
3607 * Return values: Some PTP_RC_* code.
3611 ptp_mtp_getobjectpropssupported (PTPParams* params, uint16_t ofc,
3612 uint32_t *propnum, uint16_t **props
3616 unsigned char *data = NULL;
3617 unsigned int size = 0;
3620 ptp.Code=PTP_OC_MTP_GetObjectPropsSupported;
3623 ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size);
3624 if (ret == PTP_RC_OK)
3625 *propnum=ptp_unpack_uint16_t_array(params,data,0,props);
3631 * ptp_mtp_getobjectpropdesc:
3633 * This command gets the object property description.
3635 * params: PTPParams*
3636 * uint16_t opc - object property code
3637 * uint16_t ofc - object format code
3639 * Return values: Some PTP_RC_* code.
3643 ptp_mtp_getobjectpropdesc (
3644 PTPParams* params, uint16_t opc, uint16_t ofc, PTPObjectPropDesc *opd
3648 unsigned char *data = NULL;
3649 unsigned int size = 0;
3652 ptp.Code=PTP_OC_MTP_GetObjectPropDesc;
3656 ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size);
3657 if (ret == PTP_RC_OK)
3658 ptp_unpack_OPD (params, data, opd, size);
3664 * ptp_mtp_getobjectpropvalue:
3666 * This command gets the object properties of an object handle.
3668 * params: PTPParams*
3669 * uint32_t objectid - object format code
3670 * uint16_t opc - object prop code
3672 * Return values: Some PTP_RC_* code.
3676 ptp_mtp_getobjectpropvalue (
3677 PTPParams* params, uint32_t oid, uint16_t opc,
3678 PTPPropertyValue *value, uint16_t datatype
3682 unsigned char *data = NULL;
3683 unsigned int size = 0;
3684 unsigned int offset = 0;
3687 ptp.Code=PTP_OC_MTP_GetObjectPropValue;
3691 ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size);
3692 if (ret == PTP_RC_OK) {
3693 int ret2 = ptp_unpack_DPV(params, data, &offset, size, value, datatype);
3695 ptp_debug (params, "ptp_mtp_getobjectpropvalue: unpacking DPV failed");
3696 ret = PTP_RC_GeneralError;
3704 * ptp_mtp_setobjectpropvalue:
3706 * This command gets the object properties of an object handle.
3708 * params: PTPParams*
3709 * uint32_t objectid - object format code
3710 * uint16_t opc - object prop code
3712 * Return values: Some PTP_RC_* code.
3716 ptp_mtp_setobjectpropvalue (
3717 PTPParams* params, uint32_t oid, uint16_t opc,
3718 PTPPropertyValue *value, uint16_t datatype
3722 unsigned char *data = NULL;
3726 ptp.Code=PTP_OC_MTP_SetObjectPropValue;
3730 size = ptp_pack_DPV(params, value, &data, datatype);
3731 ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL);
3737 ptp_mtp_getobjectreferences (PTPParams* params, uint32_t handle, uint32_t** ohArray, uint32_t* arraylen)
3741 unsigned char* dpv=NULL;
3742 unsigned int dpvlen = 0;
3745 ptp.Code=PTP_OC_MTP_GetObjectReferences;
3748 ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &dpv, &dpvlen);
3749 if (ret == PTP_RC_OK) {
3750 /* Sandisk Sansa skips the DATA phase, but returns OK as response.
3751 * this will gives us a NULL here. Handle it. -Marcus */
3752 if ((dpv == NULL) || (dpvlen == 0)) {
3756 *arraylen = ptp_unpack_uint32_t_array(params, dpv, 0, ohArray);
3764 ptp_mtp_setobjectreferences (PTPParams* params, uint32_t handle, uint32_t* ohArray, uint32_t arraylen)
3769 unsigned char* dpv=NULL;
3772 ptp.Code = PTP_OC_MTP_SetObjectReferences;
3773 ptp.Param1 = handle;
3775 size = ptp_pack_uint32_t_array(params, ohArray, arraylen, &dpv);
3776 ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, (unsigned char **)&dpv, NULL);
3782 ptp_mtp_getobjectproplist (PTPParams* params, uint32_t handle, MTPProperties **props, int *nrofprops)
3786 unsigned char* opldata = NULL;
3787 unsigned int oplsize;
3790 ptp.Code = PTP_OC_MTP_GetObjPropList;
3791 ptp.Param1 = handle;
3792 ptp.Param2 = 0x00000000U; /* 0x00000000U should be "all formats" */
3793 ptp.Param3 = 0xFFFFFFFFU; /* 0xFFFFFFFFU should be "all properties" */
3794 ptp.Param4 = 0x00000000U;
3795 ptp.Param5 = 0xFFFFFFFFU; /* means - return full tree below the Param1 handle */
3797 ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &opldata, &oplsize);
3798 if (ret == PTP_RC_OK) *nrofprops = ptp_unpack_OPL(params, opldata, props, oplsize);
3799 if (opldata != NULL)
3805 ptp_mtp_getobjectproplist_single (PTPParams* params, uint32_t handle, MTPProperties **props, int *nrofprops)
3809 unsigned char* opldata = NULL;
3810 unsigned int oplsize;
3813 ptp.Code = PTP_OC_MTP_GetObjPropList;
3814 ptp.Param1 = handle;
3815 ptp.Param2 = 0x00000000U; /* 0x00000000U should be "all formats" */
3816 ptp.Param3 = 0xFFFFFFFFU; /* 0xFFFFFFFFU should be "all properties" */
3817 ptp.Param4 = 0x00000000U;
3818 ptp.Param5 = 0x00000000U; /* means - return single tree below the Param1 handle */
3820 ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &opldata, &oplsize);
3821 if (ret == PTP_RC_OK) *nrofprops = ptp_unpack_OPL(params, opldata, props, oplsize);
3822 if (opldata != NULL)
3828 ptp_mtp_sendobjectproplist (PTPParams* params, uint32_t* store, uint32_t* parenthandle, uint32_t* handle,
3829 uint16_t objecttype, uint64_t objectsize, MTPProperties *props, int nrofprops)
3833 unsigned char* opldata=NULL;
3837 ptp.Code = PTP_OC_MTP_SendObjectPropList;
3838 ptp.Param1 = *store;
3839 ptp.Param2 = *parenthandle;
3840 ptp.Param3 = (uint32_t) objecttype;
3841 ptp.Param4 = (uint32_t) (objectsize >> 32);
3842 ptp.Param5 = (uint32_t) (objectsize & 0xffffffffU);
3845 /* Set object handle to 0 for a new object */
3846 oplsize = ptp_pack_OPL(params,props,nrofprops,&opldata);
3847 ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, oplsize, &opldata, NULL);
3849 *store = ptp.Param1;
3850 *parenthandle = ptp.Param2;
3851 *handle = ptp.Param3;
3857 ptp_mtp_setobjectproplist (PTPParams* params, MTPProperties *props, int nrofprops)
3861 unsigned char* opldata=NULL;
3865 ptp.Code = PTP_OC_MTP_SetObjPropList;
3868 oplsize = ptp_pack_OPL(params,props,nrofprops,&opldata);
3869 ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, oplsize, &opldata, NULL);
3876 ptp_mtpz_sendwmdrmpdapprequest (PTPParams* params, unsigned char *appcertmsg, uint32_t size)
3881 ptp.Code=PTP_OC_MTP_WMDRMPD_SendWMDRMPDAppRequest;
3882 return ptp_transaction (params, &ptp, PTP_DP_SENDDATA, size, &appcertmsg, NULL);
3886 ptp_mtpz_getwmdrmpdappresponse (PTPParams* params, unsigned char **response, uint32_t *size)
3891 ptp.Code = PTP_OC_MTP_WMDRMPD_GetWMDRMPDAppResponse;
3894 return ptp_transaction (params, &ptp, PTP_DP_GETDATA, 0, response, size);
3897 /****** CHDK interface ******/
3900 ptp_chdk_get_memory(PTPParams* params, int start, int num, unsigned char **buf)
3905 ptp.Code=PTP_OC_CHDK;
3907 ptp.Param1=PTP_CHDK_GetMemory;
3910 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, buf, NULL);
3914 ptp_chdk_set_memory_long(PTPParams* params, int addr, int val)
3917 unsigned char *buf = (unsigned char *) &val; /* FIXME ... endianness? */
3920 ptp.Code=PTP_OC_CHDK;
3922 ptp.Param1=PTP_CHDK_SetMemory;
3925 return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, 4, &buf, NULL);
3929 int ptp_chdk_upload(PTPParams* params, char *local_fn, char *remote_fn)
3935 unsigned file_len,data_len,file_name_len;
3938 ptp.Code=PTP_OC_CHDK;
3940 ptp.Param1=PTP_CHDK_UploadFile;
3942 f = fopen(local_fn,"rb");
3945 ptp_error(params,"could not open file \'%s\'",local_fn);
3949 fseek(f,0,SEEK_END);
3950 file_len = ftell(f);
3951 fseek(f,0,SEEK_SET);
3953 file_name_len = strlen(remote_fn);
3954 data_len = 4 + file_name_len + file_len;
3955 buf = malloc(data_len);
3956 memcpy(buf,&file_name_len,4);
3957 memcpy(buf+4,remote_fn,file_name_len);
3958 fread(buf+4+file_name_len,1,file_len,f);
3962 ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, data_len, &buf, NULL);
3966 if ( ret != PTP_RC_OK )
3968 ptp_error(params,"unexpected return code 0x%x",ret);
3974 static uint16_t gd_to_file(PTPParams* params, PTPGetdataParams *gdparams, unsigned len, unsigned char *bytes) {
3975 FILE *f = (FILE *)gdparams->handler_data;
3976 size_t count=fwrite(bytes,1,len,f);
3978 return PTP_ERROR_IO;
3983 int ptp_chdk_download(PTPParams* params, char *remote_fn, char *local_fn)
3987 PTPGetdataParams gdparams;
3990 f = fopen(local_fn,"wb");
3993 ptp_error(params,"could not open file \'%s\'",local_fn);
3998 ptp.Code=PTP_OC_CHDK;
4000 ptp.Param1=PTP_CHDK_TempData;
4002 ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, strlen(remote_fn), &remote_fn, NULL);
4003 if ( ret != PTP_RC_OK )
4005 ptp_error(params,"unexpected return code 0x%x",ret);
4011 ptp.Code=PTP_OC_CHDK;
4013 ptp.Param1=PTP_CHDK_DownloadFile;
4015 PTP_CNT_INIT(gdparams);
4017 gdparams.handler = gd_to_file;
4018 gdparams.block_size = 0; // default
4019 gdparams.handler_data = f;
4020 ret=ptp_getdata_transaction(params, &ptp, &gdparams);
4022 if ( ret != PTP_RC_OK )
4024 ptp_error(params,"unexpected return code 0x%x",ret);
4033 * Preliminary remote capture over USB code. Corresponding CHDK code is in the ptp-remote-capture-test
4034 * This is under development and should not be included in builds for general distribution
4037 * isready: 0: not ready, lowest 2 bits: available image formats, 0x10000000: error
4040 ptp_chdk_rcisready(PTPParams* params, int *isready, int *imgnum)
4046 ptp.Code=PTP_OC_CHDK;
4048 ptp.Param1=PTP_CHDK_RemoteCaptureIsReady;
4050 ret=ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
4051 if ( ret != PTP_RC_OK )
4053 *isready=ptp.Param1;
4059 ptp_chdk_rcgetchunk(PTPParams* params, int fmt, ptp_chdk_rc_chunk *chunk)
4065 ptp.Code=PTP_OC_CHDK;
4067 ptp.Param1=PTP_CHDK_RemoteCaptureGetData;
4068 ptp.Param2=fmt; //get chunk
4075 // TODO should allow ptp_getdata_transaction to send chunks directly to file, or to mem
4076 ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &chunk->data, NULL);
4077 if ( ret != PTP_RC_OK )
4079 chunk->size = ptp.Param1;
4080 chunk->last = (ptp.Param2 == 0);
4081 chunk->offset = ptp.Param3; //-1 for none
4086 ptp_chdk_exec_lua(PTPParams* params, char *script, int flags, int *script_id, int *status)
4092 ptp.Code=PTP_OC_CHDK;
4094 ptp.Param1=PTP_CHDK_ExecuteScript;
4095 ptp.Param2=PTP_CHDK_SL_LUA | flags;
4097 r = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, strlen(script)+1, (unsigned char**)&script, NULL);
4099 if ( r != PTP_RC_OK ) {
4104 *script_id = ptp.Param1;
4105 *status = ptp.Param2;
4106 //return (*status == PTP_CHDK_S_ERRTYPE_NONE);
4107 if (*status == PTP_CHDK_S_ERRTYPE_NONE)
4115 ptp_chdk_get_version(PTPParams* params, int *major, int *minor)
4121 ptp.Code=PTP_OC_CHDK;
4123 ptp.Param1=PTP_CHDK_Version;
4124 r=ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
4125 if ( r != PTP_RC_OK )
4127 *major = ptp.Param1;
4128 *minor = ptp.Param2;
4133 ptp_chdk_get_script_status(PTPParams* params, unsigned *status)
4139 ptp.Code=PTP_OC_CHDK;
4141 ptp.Param1=PTP_CHDK_ScriptStatus;
4142 r=ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
4143 if ( r != PTP_RC_OK )
4145 *status = ptp.Param1;
4149 ptp_chdk_get_script_support(PTPParams* params, unsigned *status)
4155 ptp.Code=PTP_OC_CHDK;
4157 ptp.Param1=PTP_CHDK_ScriptSupport;
4158 r=ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
4159 if ( r != PTP_RC_OK )
4161 *status = ptp.Param1;
4166 ptp_chdk_write_script_msg(PTPParams* params, char *data, unsigned size, int target_script_id, int *status)
4171 // a zero length data phase appears to do bad things, camera stops responding to PTP
4173 ptp_error(params,"zero length message not allowed");
4178 ptp.Code=PTP_OC_CHDK;
4180 ptp.Param1=PTP_CHDK_WriteScriptMsg;
4181 ptp.Param2=target_script_id;
4183 r=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, (unsigned char**)&data, NULL);
4184 if ( r != PTP_RC_OK ) {
4188 *status = ptp.Param1;
4192 ptp_chdk_read_script_msg(PTPParams* params, ptp_chdk_script_msg **msg)
4196 unsigned char *data = NULL;
4199 ptp.Code=PTP_OC_CHDK;
4201 ptp.Param1=PTP_CHDK_ReadScriptMsg;
4205 /* camera will always send data, otherwise getdata will cause problems */
4206 r=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, NULL);
4207 if ( r != PTP_RC_OK )
4210 /* for convenience, always allocate an extra byte and null it*/
4211 *msg = malloc(sizeof(ptp_chdk_script_msg) + ptp.Param4 + 1);
4212 (*msg)->type = ptp.Param1;
4213 (*msg)->subtype = ptp.Param2;
4214 (*msg)->script_id = ptp.Param3;
4215 (*msg)->size = ptp.Param4;
4216 memcpy((*msg)->data,data,(*msg)->size);
4217 (*msg)->data[(*msg)->size] = 0;
4223 ptp_chdk_get_live_data(PTPParams* params, unsigned flags, unsigned char **data, unsigned int *data_size) {
4226 unsigned int real_size = 0;
4230 ptp.Code=PTP_OC_CHDK;
4232 ptp.Param1=PTP_CHDK_GetDisplayData;
4238 r = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, &real_size);
4239 if ( r != PTP_RC_OK )
4241 *data_size = ptp.Param1;
4246 ptp_chdk_call_function(PTPParams* params, int *args, int size, int *ret)
4252 ptp.Code=PTP_OC_CHDK;
4254 ptp.Param1=PTP_CHDK_CallFunction;
4255 r=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size*sizeof(int), (unsigned char **) &args, NULL);
4256 if ( r != PTP_RC_OK )
4267 * Android MTP Extensions
4271 * ptp_android_getpartialobject64:
4272 * params: PTPParams*
4273 * handle - Object handle
4274 * offset - Offset into object
4275 * maxbytes - Maximum of bytes to read
4276 * object - pointer to data area
4277 * len - pointer to returned length
4279 * Get object 'handle' from device and store the data in newly
4280 * allocated 'object'. Start from offset and read at most maxbytes.
4282 * This is a 64bit offset version of the standard GetPartialObject.
4284 * Return values: Some PTP_RC_* code.
4287 ptp_android_getpartialobject64 (PTPParams* params, uint32_t handle, uint64_t offset,
4288 uint32_t maxbytes, unsigned char** object,
4294 ptp.Code=PTP_OC_ANDROID_GetPartialObject64;
4296 ptp.Param2=offset & 0xFFFFFFFF;
4297 ptp.Param3=offset >> 32;
4298 ptp.Param4=maxbytes;
4301 return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, object, len);
4305 ptp_android_sendpartialobject (PTPParams* params, uint32_t handle, uint64_t offset,
4306 unsigned char* object, uint32_t len)
4312 ptp.Code=PTP_OC_ANDROID_SendPartialObject;
4314 ptp.Param2=offset & 0xFFFFFFFF;
4315 ptp.Param3=offset >> 32;
4320 * MtpServer.cpp is buggy: it uses write() without offset
4321 * rather than pwrite to send the data for data coming with
4324 params->split_header_data = 1;
4325 err=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, len, &object, NULL);
4326 params->split_header_data = 0;
4332 /* Non PTP protocol functions */
4333 /* devinfo testing functions */
4336 ptp_event_issupported(PTPParams* params, uint16_t event)
4340 for (;i<params->deviceinfo.EventsSupported_len;i++) {
4341 if (params->deviceinfo.EventsSupported[i]==event)
4349 ptp_property_issupported(PTPParams* params, uint16_t property)
4353 for (i=0;i<params->deviceinfo.DevicePropertiesSupported_len;i++)
4354 if (params->deviceinfo.DevicePropertiesSupported[i]==property)
4360 ptp_free_objectinfo (PTPObjectInfo *oi)
4363 free (oi->Filename); oi->Filename = NULL;
4364 free (oi->Keywords); oi->Keywords = NULL;
4368 ptp_free_object (PTPObject *ob)
4373 ptp_free_objectinfo (&ob->oi);
4374 for (i=0;i<ob->nrofmtpprops;i++)
4375 ptp_destroy_object_prop(&ob->mtpprops[i]);
4380 ptp_strerror(uint16_t error) {
4383 /* PTP error descriptions */
4388 {PTP_RC_Undefined, N_("PTP: Undefined Error")},
4389 {PTP_RC_OK, N_("PTP: OK!")},
4390 {PTP_RC_GeneralError, N_("PTP: General Error")},
4391 {PTP_RC_SessionNotOpen, N_("PTP: Session Not Open")},
4392 {PTP_RC_InvalidTransactionID, N_("PTP: Invalid Transaction ID")},
4393 {PTP_RC_OperationNotSupported, N_("PTP: Operation Not Supported")},
4394 {PTP_RC_ParameterNotSupported, N_("PTP: Parameter Not Supported")},
4395 {PTP_RC_IncompleteTransfer, N_("PTP: Incomplete Transfer")},
4396 {PTP_RC_InvalidStorageId, N_("PTP: Invalid Storage ID")},
4397 {PTP_RC_InvalidObjectHandle, N_("PTP: Invalid Object Handle")},
4398 {PTP_RC_DevicePropNotSupported, N_("PTP: Device Prop Not Supported")},
4399 {PTP_RC_InvalidObjectFormatCode, N_("PTP: Invalid Object Format Code")},
4400 {PTP_RC_StoreFull, N_("PTP: Store Full")},
4401 {PTP_RC_ObjectWriteProtected, N_("PTP: Object Write Protected")},
4402 {PTP_RC_StoreReadOnly, N_("PTP: Store Read Only")},
4403 {PTP_RC_AccessDenied, N_("PTP: Access Denied")},
4404 {PTP_RC_NoThumbnailPresent, N_("PTP: No Thumbnail Present")},
4405 {PTP_RC_SelfTestFailed, N_("PTP: Self Test Failed")},
4406 {PTP_RC_PartialDeletion, N_("PTP: Partial Deletion")},
4407 {PTP_RC_StoreNotAvailable, N_("PTP: Store Not Available")},
4408 {PTP_RC_SpecificationByFormatUnsupported,
4409 N_("PTP: Specification By Format Unsupported")},
4410 {PTP_RC_NoValidObjectInfo, N_("PTP: No Valid Object Info")},
4411 {PTP_RC_InvalidCodeFormat, N_("PTP: Invalid Code Format")},
4412 {PTP_RC_UnknownVendorCode, N_("PTP: Unknown Vendor Code")},
4413 {PTP_RC_CaptureAlreadyTerminated,
4414 N_("PTP: Capture Already Terminated")},
4415 {PTP_RC_DeviceBusy, N_("PTP: Device Busy")},
4416 {PTP_RC_InvalidParentObject, N_("PTP: Invalid Parent Object")},
4417 {PTP_RC_InvalidDevicePropFormat, N_("PTP: Invalid Device Prop Format")},
4418 {PTP_RC_InvalidDevicePropValue, N_("PTP: Invalid Device Prop Value")},
4419 {PTP_RC_InvalidParameter, N_("PTP: Invalid Parameter")},
4420 {PTP_RC_SessionAlreadyOpened, N_("PTP: Session Already Opened")},
4421 {PTP_RC_TransactionCanceled, N_("PTP: Transaction Canceled")},
4422 {PTP_RC_SpecificationOfDestinationUnsupported,
4423 N_("PTP: Specification Of Destination Unsupported")},
4424 {PTP_RC_EK_FilenameRequired, N_("PTP: EK Filename Required")},
4425 {PTP_RC_EK_FilenameConflicts, N_("PTP: EK Filename Conflicts")},
4426 {PTP_RC_EK_FilenameInvalid, N_("PTP: EK Filename Invalid")},
4428 {PTP_ERROR_IO, N_("PTP: I/O error")},
4429 {PTP_ERROR_BADPARAM, N_("PTP: Error: bad parameter")},
4430 {PTP_ERROR_DATA_EXPECTED, N_("PTP: Protocol error, data expected")},
4431 {PTP_ERROR_RESP_EXPECTED, N_("PTP: Protocol error, response expected")},
4435 for (i=0; ptp_errors[i].txt!=NULL; i++)
4436 if (ptp_errors[i].n == error)
4437 return ptp_errors[i].txt;
4442 ptp_perror(PTPParams* params, uint16_t error) {
4443 const char *txt = ptp_strerror(error);
4445 ptp_error(params, txt);
4449 ptp_get_property_description(PTPParams* params, uint16_t dpc)
4452 /* Device Property descriptions */
4456 } ptp_device_properties[] = {
4457 {PTP_DPC_Undefined, N_("Undefined PTP Property")},
4458 {PTP_DPC_BatteryLevel, N_("Battery Level")},
4459 {PTP_DPC_FunctionalMode, N_("Functional Mode")},
4460 {PTP_DPC_ImageSize, N_("Image Size")},
4461 {PTP_DPC_CompressionSetting, N_("Compression Setting")},
4462 {PTP_DPC_WhiteBalance, N_("White Balance")},
4463 {PTP_DPC_RGBGain, N_("RGB Gain")},
4464 {PTP_DPC_FNumber, N_("F-Number")},
4465 {PTP_DPC_FocalLength, N_("Focal Length")},
4466 {PTP_DPC_FocusDistance, N_("Focus Distance")},
4467 {PTP_DPC_FocusMode, N_("Focus Mode")},
4468 {PTP_DPC_ExposureMeteringMode, N_("Exposure Metering Mode")},
4469 {PTP_DPC_FlashMode, N_("Flash Mode")},
4470 {PTP_DPC_ExposureTime, N_("Exposure Time")},
4471 {PTP_DPC_ExposureProgramMode, N_("Exposure Program Mode")},
4472 {PTP_DPC_ExposureIndex,
4473 N_("Exposure Index (film speed ISO)")},
4474 {PTP_DPC_ExposureBiasCompensation,
4475 N_("Exposure Bias Compensation")},
4476 {PTP_DPC_DateTime, N_("Date & Time")},
4477 {PTP_DPC_CaptureDelay, N_("Pre-Capture Delay")},
4478 {PTP_DPC_StillCaptureMode, N_("Still Capture Mode")},
4479 {PTP_DPC_Contrast, N_("Contrast")},
4480 {PTP_DPC_Sharpness, N_("Sharpness")},
4481 {PTP_DPC_DigitalZoom, N_("Digital Zoom")},
4482 {PTP_DPC_EffectMode, N_("Effect Mode")},
4483 {PTP_DPC_BurstNumber, N_("Burst Number")},
4484 {PTP_DPC_BurstInterval, N_("Burst Interval")},
4485 {PTP_DPC_TimelapseNumber, N_("Timelapse Number")},
4486 {PTP_DPC_TimelapseInterval, N_("Timelapse Interval")},
4487 {PTP_DPC_FocusMeteringMode, N_("Focus Metering Mode")},
4488 {PTP_DPC_UploadURL, N_("Upload URL")},
4489 {PTP_DPC_Artist, N_("Artist")},
4490 {PTP_DPC_CopyrightInfo, N_("Copyright Info")},
4496 } ptp_device_properties_EK[] = {
4497 {PTP_DPC_EK_ColorTemperature, N_("Color Temperature")},
4498 {PTP_DPC_EK_DateTimeStampFormat,
4499 N_("Date Time Stamp Format")},
4500 {PTP_DPC_EK_BeepMode, N_("Beep Mode")},
4501 {PTP_DPC_EK_VideoOut, N_("Video Out")},
4502 {PTP_DPC_EK_PowerSaving, N_("Power Saving")},
4503 {PTP_DPC_EK_UI_Language, N_("UI Language")},
4510 } ptp_device_properties_Canon[] = {
4511 {PTP_DPC_CANON_BeepMode, N_("Beep Mode")},
4512 {PTP_DPC_CANON_BatteryKind, N_("Battery Type")},
4513 {PTP_DPC_CANON_BatteryStatus, N_("Battery Mode")},
4514 {PTP_DPC_CANON_UILockType, N_("UILockType")},
4515 {PTP_DPC_CANON_CameraMode, N_("Camera Mode")},
4516 {PTP_DPC_CANON_ImageQuality, N_("Image Quality")},
4517 {PTP_DPC_CANON_FullViewFileFormat, N_("Full View File Format")},
4518 {PTP_DPC_CANON_ImageSize, N_("Image Size")},
4519 {PTP_DPC_CANON_SelfTime, N_("Self Time")},
4520 {PTP_DPC_CANON_FlashMode, N_("Flash Mode")},
4521 {PTP_DPC_CANON_Beep, N_("Beep")},
4522 {PTP_DPC_CANON_ShootingMode, N_("Shooting Mode")},
4523 {PTP_DPC_CANON_ImageMode, N_("Image Mode")},
4524 {PTP_DPC_CANON_DriveMode, N_("Drive Mode")},
4525 {PTP_DPC_CANON_EZoom, N_("Zoom")},
4526 {PTP_DPC_CANON_MeteringMode, N_("Metering Mode")},
4527 {PTP_DPC_CANON_AFDistance, N_("AF Distance")},
4528 {PTP_DPC_CANON_FocusingPoint, N_("Focusing Point")},
4529 {PTP_DPC_CANON_WhiteBalance, N_("White Balance")},
4530 {PTP_DPC_CANON_SlowShutterSetting, N_("Slow Shutter Setting")},
4531 {PTP_DPC_CANON_AFMode, N_("AF Mode")},
4532 {PTP_DPC_CANON_ImageStabilization, N_("Image Stabilization")},
4533 {PTP_DPC_CANON_Contrast, N_("Contrast")},
4534 {PTP_DPC_CANON_ColorGain, N_("Color Gain")},
4535 {PTP_DPC_CANON_Sharpness, N_("Sharpness")},
4536 {PTP_DPC_CANON_Sensitivity, N_("Sensitivity")},
4537 {PTP_DPC_CANON_ParameterSet, N_("Parameter Set")},
4538 {PTP_DPC_CANON_ISOSpeed, N_("ISO Speed")},
4539 {PTP_DPC_CANON_Aperture, N_("Aperture")},
4540 {PTP_DPC_CANON_ShutterSpeed, N_("Shutter Speed")},
4541 {PTP_DPC_CANON_ExpCompensation, N_("Exposure Compensation")},
4542 {PTP_DPC_CANON_FlashCompensation, N_("Flash Compensation")},
4543 {PTP_DPC_CANON_AEBExposureCompensation, N_("AEB Exposure Compensation")},
4544 {PTP_DPC_CANON_AvOpen, N_("Av Open")},
4545 {PTP_DPC_CANON_AvMax, N_("Av Max")},
4546 {PTP_DPC_CANON_FocalLength, N_("Focal Length")},
4547 {PTP_DPC_CANON_FocalLengthTele, N_("Focal Length Tele")},
4548 {PTP_DPC_CANON_FocalLengthWide, N_("Focal Length Wide")},
4549 {PTP_DPC_CANON_FocalLengthDenominator, N_("Focal Length Denominator")},
4550 {PTP_DPC_CANON_CaptureTransferMode, N_("Capture Transfer Mode")},
4551 {PTP_DPC_CANON_Zoom, N_("Zoom")},
4552 {PTP_DPC_CANON_NamePrefix, N_("Name Prefix")},
4553 {PTP_DPC_CANON_SizeQualityMode, N_("Size Quality Mode")},
4554 {PTP_DPC_CANON_SupportedThumbSize, N_("Supported Thumb Size")},
4555 {PTP_DPC_CANON_SizeOfOutputDataFromCamera, N_("Size of Output Data from Camera")},
4556 {PTP_DPC_CANON_SizeOfInputDataToCamera, N_("Size of Input Data to Camera")},
4557 {PTP_DPC_CANON_RemoteAPIVersion,N_("Remote API Version")},
4558 {PTP_DPC_CANON_FirmwareVersion, N_("Firmware Version")},
4559 {PTP_DPC_CANON_CameraModel, N_("Camera Model")},
4560 {PTP_DPC_CANON_CameraOwner, N_("Camera Owner")},
4561 {PTP_DPC_CANON_UnixTime, N_("UNIX Time")},
4562 {PTP_DPC_CANON_CameraBodyID, N_("Camera Body ID")},
4563 {PTP_DPC_CANON_CameraOutput, N_("Camera Output")},
4564 {PTP_DPC_CANON_DispAv, N_("Disp Av")},
4565 {PTP_DPC_CANON_AvOpenApex, N_("Av Open Apex")},
4566 {PTP_DPC_CANON_DZoomMagnification, N_("Digital Zoom Magnification")},
4567 {PTP_DPC_CANON_MlSpotPos, N_("Ml Spot Position")},
4568 {PTP_DPC_CANON_DispAvMax, N_("Disp Av Max")},
4569 {PTP_DPC_CANON_AvMaxApex, N_("Av Max Apex")},
4570 {PTP_DPC_CANON_EZoomStartPosition, N_("EZoom Start Position")},
4571 {PTP_DPC_CANON_FocalLengthOfTele, N_("Focal Length Tele")},
4572 {PTP_DPC_CANON_EZoomSizeOfTele, N_("EZoom Size of Tele")},
4573 {PTP_DPC_CANON_PhotoEffect, N_("Photo Effect")},
4574 {PTP_DPC_CANON_AssistLight, N_("Assist Light")},
4575 {PTP_DPC_CANON_FlashQuantityCount, N_("Flash Quantity Count")},
4576 {PTP_DPC_CANON_RotationAngle, N_("Rotation Angle")},
4577 {PTP_DPC_CANON_RotationScene, N_("Rotation Scene")},
4578 {PTP_DPC_CANON_EventEmulateMode,N_("Event Emulate Mode")},
4579 {PTP_DPC_CANON_DPOFVersion, N_("DPOF Version")},
4580 {PTP_DPC_CANON_TypeOfSupportedSlideShow, N_("Type of Slideshow")},
4581 {PTP_DPC_CANON_AverageFilesizes,N_("Average Filesizes")},
4582 {PTP_DPC_CANON_ModelID, N_("Model ID")},
4589 } ptp_device_properties_Nikon[] = {
4590 {PTP_DPC_NIKON_ShootingBank, /* 0xD010 */
4591 N_("Shooting Bank")},
4592 {PTP_DPC_NIKON_ShootingBankNameA, /* 0xD011 */
4593 N_("Shooting Bank Name A")},
4594 {PTP_DPC_NIKON_ShootingBankNameB, /* 0xD012 */
4595 N_("Shooting Bank Name B")},
4596 {PTP_DPC_NIKON_ShootingBankNameC, /* 0xD013 */
4597 N_("Shooting Bank Name C")},
4598 {PTP_DPC_NIKON_ShootingBankNameD, /* 0xD014 */
4599 N_("Shooting Bank Name D")},
4600 {PTP_DPC_NIKON_ResetBank0, /* 0xD015 */
4601 N_("Reset Bank 0")},
4602 {PTP_DPC_NIKON_RawCompression, /* 0xD016 */
4603 N_("Raw Compression")},
4604 {PTP_DPC_NIKON_WhiteBalanceAutoBias, /* 0xD017 */
4605 N_("Auto White Balance Bias")},
4606 {PTP_DPC_NIKON_WhiteBalanceTungstenBias, /* 0xD018 */
4607 N_("Tungsten White Balance Bias")},
4608 {PTP_DPC_NIKON_WhiteBalanceFluorescentBias, /* 0xD019 */
4609 N_("Fluorescent White Balance Bias")},
4610 {PTP_DPC_NIKON_WhiteBalanceDaylightBias, /* 0xD01a */
4611 N_("Daylight White Balance Bias")},
4612 {PTP_DPC_NIKON_WhiteBalanceFlashBias, /* 0xD01b */
4613 N_("Flash White Balance Bias")},
4614 {PTP_DPC_NIKON_WhiteBalanceCloudyBias, /* 0xD01c */
4615 N_("Cloudy White Balance Bias")},
4616 {PTP_DPC_NIKON_WhiteBalanceShadeBias, /* 0xD01d */
4617 N_("Shady White Balance Bias")},
4618 {PTP_DPC_NIKON_WhiteBalanceColorTemperature, /* 0xD01e */
4619 N_("White Balance Colour Temperature")},
4620 {PTP_DPC_NIKON_WhiteBalancePresetNo, /* 0xD01f */
4621 N_("White Balance Preset Number")},
4622 {PTP_DPC_NIKON_WhiteBalancePresetName0, /* 0xD020 */
4623 N_("White Balance Preset Name 0")},
4624 {PTP_DPC_NIKON_WhiteBalancePresetName1, /* 0xD021 */
4625 N_("White Balance Preset Name 1")},
4626 {PTP_DPC_NIKON_WhiteBalancePresetName2, /* 0xD022 */
4627 N_("White Balance Preset Name 2")},
4628 {PTP_DPC_NIKON_WhiteBalancePresetName3, /* 0xD023 */
4629 N_("White Balance Preset Name 3")},
4630 {PTP_DPC_NIKON_WhiteBalancePresetName4, /* 0xD024 */
4631 N_("White Balance Preset Name 4")},
4632 {PTP_DPC_NIKON_WhiteBalancePresetVal0, /* 0xD025 */
4633 N_("White Balance Preset Value 0")},
4634 {PTP_DPC_NIKON_WhiteBalancePresetVal1, /* 0xD026 */
4635 N_("White Balance Preset Value 1")},
4636 {PTP_DPC_NIKON_WhiteBalancePresetVal2, /* 0xD027 */
4637 N_("White Balance Preset Value 2")},
4638 {PTP_DPC_NIKON_WhiteBalancePresetVal3, /* 0xD028 */
4639 N_("White Balance Preset Value 3")},
4640 {PTP_DPC_NIKON_WhiteBalancePresetVal4, /* 0xD029 */
4641 N_("White Balance Preset Value 4")},
4642 {PTP_DPC_NIKON_ImageSharpening, /* 0xD02a */
4644 {PTP_DPC_NIKON_ToneCompensation, /* 0xD02b */
4645 N_("Tone Compensation")},
4646 {PTP_DPC_NIKON_ColorModel, /* 0xD02c */
4648 {PTP_DPC_NIKON_HueAdjustment, /* 0xD02d */
4649 N_("Hue Adjustment")},
4650 {PTP_DPC_NIKON_NonCPULensDataFocalLength, /* 0xD02e */
4651 N_("Lens Focal Length (Non CPU)")},
4652 {PTP_DPC_NIKON_NonCPULensDataMaximumAperture, /* 0xD02f */
4653 N_("Lens Maximum Aperture (Non CPU)")},
4654 {PTP_DPC_NIKON_ShootingMode, /* 0xD030 */
4655 N_("Shooting Mode")},
4656 {PTP_DPC_NIKON_JPEG_Compression_Policy, /* 0xD031 */
4657 N_("JPEG Compression Policy")},
4658 {PTP_DPC_NIKON_ColorSpace, /* 0xD032 */
4660 {PTP_DPC_NIKON_AutoDXCrop, /* 0xD033 */
4661 N_("Auto DX Crop")},
4662 {PTP_DPC_NIKON_FlickerReduction, /* 0xD034 */
4663 N_("Flicker Reduction")},
4664 {PTP_DPC_NIKON_RemoteMode, /* 0xD035 */
4666 {PTP_DPC_NIKON_VideoMode, /* 0xD036 */
4668 {PTP_DPC_NIKON_EffectMode, /* 0xD037 */
4670 {PTP_DPC_NIKON_CSMMenuBankSelect, /* 0xD040 */
4671 "PTP_DPC_NIKON_CSMMenuBankSelect"},
4672 {PTP_DPC_NIKON_MenuBankNameA, /* 0xD041 */
4673 N_("Menu Bank Name A")},
4674 {PTP_DPC_NIKON_MenuBankNameB, /* 0xD042 */
4675 N_("Menu Bank Name B")},
4676 {PTP_DPC_NIKON_MenuBankNameC, /* 0xD043 */
4677 N_("Menu Bank Name C")},
4678 {PTP_DPC_NIKON_MenuBankNameD, /* 0xD044 */
4679 N_("Menu Bank Name D")},
4680 {PTP_DPC_NIKON_ResetBank, /* 0xD045 */
4681 N_("Reset Menu Bank")},
4682 {PTP_DPC_NIKON_A1AFCModePriority, /* 0xD048 */
4683 "PTP_DPC_NIKON_A1AFCModePriority"},
4684 {PTP_DPC_NIKON_A2AFSModePriority, /* 0xD049 */
4685 "PTP_DPC_NIKON_A2AFSModePriority"},
4686 {PTP_DPC_NIKON_A3GroupDynamicAF, /* 0xD04a */
4687 "PTP_DPC_NIKON_A3GroupDynamicAF"},
4688 {PTP_DPC_NIKON_A4AFActivation, /* 0xD04b */
4689 "PTP_DPC_NIKON_A4AFActivation"},
4690 {PTP_DPC_NIKON_FocusAreaIllumManualFocus, /* 0xD04c */
4691 "PTP_DPC_NIKON_FocusAreaIllumManualFocus"},
4692 {PTP_DPC_NIKON_FocusAreaIllumContinuous, /* 0xD04d */
4693 "PTP_DPC_NIKON_FocusAreaIllumContinuous"},
4694 {PTP_DPC_NIKON_FocusAreaIllumWhenSelected, /* 0xD04e */
4695 "PTP_DPC_NIKON_FocusAreaIllumWhenSelected"},
4696 {PTP_DPC_NIKON_FocusAreaWrap, /* 0xD04f */
4697 N_("Focus Area Wrap")},
4698 {PTP_DPC_NIKON_VerticalAFON, /* 0xD050 */
4699 N_("Vertical AF On")},
4700 {PTP_DPC_NIKON_AFLockOn, /* 0xD051 */
4702 {PTP_DPC_NIKON_FocusAreaZone, /* 0xD052 */
4703 N_("Focus Area Zone")},
4704 {PTP_DPC_NIKON_EnableCopyright, /* 0xD053 */
4705 N_("Enable Copyright")},
4706 {PTP_DPC_NIKON_ISOAuto, /* 0xD054 */
4708 {PTP_DPC_NIKON_EVISOStep, /* 0xD055 */
4709 N_("Exposure ISO Step")},
4710 {PTP_DPC_NIKON_EVStep, /* 0xD056 */
4711 N_("Exposure Step")},
4712 {PTP_DPC_NIKON_EVStepExposureComp, /* 0xD057 */
4713 N_("Exposure Compensation (EV)")},
4714 {PTP_DPC_NIKON_ExposureCompensation, /* 0xD058 */
4715 N_("Exposure Compensation")},
4716 {PTP_DPC_NIKON_CenterWeightArea, /* 0xD059 */
4717 N_("Centre Weight Area")},
4718 {PTP_DPC_NIKON_ExposureBaseMatrix, /* 0xD05A */
4719 N_("Exposure Base Matrix")},
4720 {PTP_DPC_NIKON_ExposureBaseCenter, /* 0xD05B */
4721 N_("Exposure Base Center")},
4722 {PTP_DPC_NIKON_ExposureBaseSpot, /* 0xD05C */
4723 N_("Exposure Base Spot")},
4724 {PTP_DPC_NIKON_LiveViewAFArea, /* 0xD05D */
4725 N_("Live View AF Area")},
4726 {PTP_DPC_NIKON_AELockMode, /* 0xD05E */
4727 N_("Exposure Lock")},
4728 {PTP_DPC_NIKON_AELAFLMode, /* 0xD05F */
4730 {PTP_DPC_NIKON_LiveViewAFFocus, /* 0xD061 */
4731 N_("Live View AF Focus")},
4732 {PTP_DPC_NIKON_MeterOff, /* 0xD062 */
4733 N_("Auto Meter Off Time")},
4734 {PTP_DPC_NIKON_SelfTimer, /* 0xD063 */
4735 N_("Self Timer Delay")},
4736 {PTP_DPC_NIKON_MonitorOff, /* 0xD064 */
4737 N_("LCD Off Time")},
4738 {PTP_DPC_NIKON_ImgConfTime, /* 0xD065 */
4739 N_("Img Conf Time")},
4740 {PTP_DPC_NIKON_AutoOffTimers, /* 0xD066 */
4741 N_("Auto Off Timers")},
4742 {PTP_DPC_NIKON_AngleLevel, /* 0xD067 */
4744 {PTP_DPC_NIKON_D1ShootingSpeed, /* 0xD068 */
4745 N_("Shooting Speed")},
4746 {PTP_DPC_NIKON_D2MaximumShots, /* 0xD069 */
4747 N_("Maximum Shots")},
4748 {PTP_DPC_NIKON_ExposureDelayMode, /* 0xD06A */
4749 N_("Exposure delay mode")},
4750 {PTP_DPC_NIKON_LongExposureNoiseReduction, /* 0xD06B */
4751 N_("Long Exposure Noise Reduction")},
4752 {PTP_DPC_NIKON_FileNumberSequence, /* 0xD06C */
4753 N_("File Number Sequencing")},
4754 {PTP_DPC_NIKON_ControlPanelFinderRearControl, /* 0xD06D */
4755 "PTP_DPC_NIKON_ControlPanelFinderRearControl"},
4756 {PTP_DPC_NIKON_ControlPanelFinderViewfinder, /* 0xD06E */
4757 "PTP_DPC_NIKON_ControlPanelFinderViewfinder"},
4758 {PTP_DPC_NIKON_D7Illumination, /* 0xD06F */
4759 N_("LCD Illumination")},
4760 {PTP_DPC_NIKON_NrHighISO, /* 0xD070 */
4761 N_("High ISO noise reduction")},
4762 {PTP_DPC_NIKON_SHSET_CH_GUID_DISP, /* 0xD071 */
4763 N_("On screen tips")},
4764 {PTP_DPC_NIKON_ArtistName, /* 0xD072 */
4766 {PTP_DPC_NIKON_CopyrightInfo, /* 0xD073 */
4767 N_("Copyright Information")},
4768 {PTP_DPC_NIKON_FlashSyncSpeed, /* 0xD074 */
4769 N_("Flash Sync. Speed")},
4770 {PTP_DPC_NIKON_FlashShutterSpeed, /* 0xD075 */
4771 N_("Flash Shutter Speed")},
4772 {PTP_DPC_NIKON_E3AAFlashMode, /* 0xD076 */
4774 {PTP_DPC_NIKON_E4ModelingFlash, /* 0xD077 */
4775 N_("Modeling Flash")},
4776 {PTP_DPC_NIKON_BracketSet, /* 0xD078 */
4778 {PTP_DPC_NIKON_E6ManualModeBracketing, /* 0xD079 */
4779 N_("Manual Mode Bracketing")},
4780 {PTP_DPC_NIKON_BracketOrder, /* 0xD07A */
4781 N_("Bracket Order")},
4782 {PTP_DPC_NIKON_E8AutoBracketSelection, /* 0xD07B */
4783 N_("Auto Bracket Selection")},
4784 {PTP_DPC_NIKON_BracketingSet, N_("NIKON Auto Bracketing Set")}, /* 0xD07C */
4785 {PTP_DPC_NIKON_F1CenterButtonShootingMode, /* 0xD080 */
4786 N_("Center Button Shooting Mode")},
4787 {PTP_DPC_NIKON_CenterButtonPlaybackMode, /* 0xD081 */
4788 N_("Center Button Playback Mode")},
4789 {PTP_DPC_NIKON_F2Multiselector, /* 0xD082 */
4790 N_("Multiselector")},
4791 {PTP_DPC_NIKON_F3PhotoInfoPlayback, /* 0xD083 */
4792 N_("Photo Info. Playback")},
4793 {PTP_DPC_NIKON_F4AssignFuncButton, /* 0xD084 */
4794 N_("Assign Func. Button")},
4795 {PTP_DPC_NIKON_F5CustomizeCommDials, /* 0xD085 */
4796 N_("Customise Command Dials")},
4797 {PTP_DPC_NIKON_ReverseCommandDial, /* 0xD086 */
4798 N_("Reverse Command Dial")},
4799 {PTP_DPC_NIKON_ApertureSetting, /* 0xD087 */
4800 N_("Aperture Setting")},
4801 {PTP_DPC_NIKON_MenusAndPlayback, /* 0xD088 */
4802 N_("Menus and Playback")},
4803 {PTP_DPC_NIKON_F6ButtonsAndDials, /* 0xD089 */
4804 N_("Buttons and Dials")},
4805 {PTP_DPC_NIKON_NoCFCard, /* 0xD08A */
4806 N_("No CF Card Release")},
4807 {PTP_DPC_NIKON_CenterButtonZoomRatio, /* 0xD08B */
4808 N_("Center Button Zoom Ratio")},
4809 {PTP_DPC_NIKON_FunctionButton2, /* 0xD08C */
4810 N_("Function Button 2")},
4811 {PTP_DPC_NIKON_AFAreaPoint, /* 0xD08D */
4812 N_("AF Area Point")},
4813 {PTP_DPC_NIKON_NormalAFOn, /* 0xD08E */
4814 N_("Normal AF On")},
4815 {PTP_DPC_NIKON_CleanImageSensor, /* 0xD08F */
4816 N_("Clean Image Sensor")},
4817 {PTP_DPC_NIKON_ImageCommentString, /* 0xD090 */
4818 N_("Image Comment String")},
4819 {PTP_DPC_NIKON_ImageCommentEnable, /* 0xD091 */
4820 N_("Image Comment Enable")},
4821 {PTP_DPC_NIKON_ImageRotation, /* 0xD092 */
4822 N_("Image Rotation")},
4823 {PTP_DPC_NIKON_ManualSetLensNo, /* 0xD093 */
4824 N_("Manual Set Lens Number")},
4825 {PTP_DPC_NIKON_MovScreenSize, /* 0xD0A0 */
4826 N_("Movie Screen Size")},
4827 {PTP_DPC_NIKON_MovVoice, /* 0xD0A1 */
4829 {PTP_DPC_NIKON_MovMicrophone, /* 0xD0A2 */
4830 N_("Movie Microphone")},
4831 {PTP_DPC_NIKON_MovFileSlot, /* 0xD0A3 */
4832 N_("Movie Card Slot")},
4833 {PTP_DPC_NIKON_ManualMovieSetting, /* 0xD0A6 */
4834 N_("Manual Movie Setting")},
4835 {PTP_DPC_NIKON_MonitorOffDelay, /* 0xD0B3 */
4836 N_("Monitor Off Delay")},
4837 {PTP_DPC_NIKON_Bracketing, /* 0xD0C0 */
4838 N_("Bracketing Enable")},
4839 {PTP_DPC_NIKON_AutoExposureBracketStep, /* 0xD0C1 */
4840 N_("Exposure Bracketing Step")},
4841 {PTP_DPC_NIKON_AutoExposureBracketProgram, /* 0xD0C2 */
4842 N_("Exposure Bracketing Program")},
4843 {PTP_DPC_NIKON_AutoExposureBracketCount, /* 0xD0C3 */
4844 N_("Auto Exposure Bracket Count")},
4845 {PTP_DPC_NIKON_WhiteBalanceBracketStep, N_("White Balance Bracket Step")}, /* 0xD0C4 */
4846 {PTP_DPC_NIKON_WhiteBalanceBracketProgram, N_("White Balance Bracket Program")}, /* 0xD0C5 */
4847 {PTP_DPC_NIKON_LensID, /* 0xD0E0 */
4849 {PTP_DPC_NIKON_LensSort, /* 0xD0E1 */
4851 {PTP_DPC_NIKON_LensType, /* 0xD0E2 */
4853 {PTP_DPC_NIKON_FocalLengthMin, /* 0xD0E3 */
4854 N_("Min. Focal Length")},
4855 {PTP_DPC_NIKON_FocalLengthMax, /* 0xD0E4 */
4856 N_("Max. Focal Length")},
4857 {PTP_DPC_NIKON_MaxApAtMinFocalLength, /* 0xD0E5 */
4858 N_("Max. Aperture at Min. Focal Length")},
4859 {PTP_DPC_NIKON_MaxApAtMaxFocalLength, /* 0xD0E6 */
4860 N_("Max. Aperture at Max. Focal Length")},
4861 {PTP_DPC_NIKON_FinderISODisp, /* 0xD0F0 */
4862 N_("Finder ISO Display")},
4863 {PTP_DPC_NIKON_AutoOffPhoto, /* 0xD0F2 */
4864 N_("Auto Off Photo")},
4865 {PTP_DPC_NIKON_AutoOffMenu, /* 0xD0F3 */
4866 N_("Auto Off Menu")},
4867 {PTP_DPC_NIKON_AutoOffInfo, /* 0xD0F4 */
4868 N_("Auto Off Info")},
4869 {PTP_DPC_NIKON_SelfTimerShootNum, /* 0xD0F5 */
4870 N_("Self Timer Shot Number")},
4871 {PTP_DPC_NIKON_VignetteCtrl, /* 0xD0F7 */
4872 N_("Vignette Control")},
4873 {PTP_DPC_NIKON_AutoDistortionControl, /* 0xD0F8 */
4874 N_("Auto Distortion Control")},
4875 {PTP_DPC_NIKON_SceneMode, /* 0xD0F9 */
4877 {PTP_DPC_NIKON_ExposureTime, /* 0xD100 */
4878 N_("Nikon Exposure Time")},
4879 {PTP_DPC_NIKON_ACPower, N_("AC Power")}, /* 0xD101 */
4880 {PTP_DPC_NIKON_WarningStatus, N_("Warning Status")},/* 0xD102 */
4881 {PTP_DPC_NIKON_MaximumShots, /* 0xD103 */
4882 N_("Maximum Shots")},
4883 {PTP_DPC_NIKON_AFLockStatus, N_("AF Locked")},/* 0xD104 */
4884 {PTP_DPC_NIKON_AELockStatus, N_("AE Locked")},/* 0xD105 */
4885 {PTP_DPC_NIKON_FVLockStatus, N_("FV Locked")},/* 0xD106 */
4886 {PTP_DPC_NIKON_AutofocusLCDTopMode2, /* 0xD107 */
4887 N_("AF LCD Top Mode 2")},
4888 {PTP_DPC_NIKON_AutofocusArea, /* 0xD108 */
4889 N_("Active AF Sensor")},
4890 {PTP_DPC_NIKON_FlexibleProgram, /* 0xD109 */
4891 N_("Flexible Program")},
4892 {PTP_DPC_NIKON_LightMeter, /* 0xD10A */
4893 N_("Exposure Meter")},
4894 {PTP_DPC_NIKON_RecordingMedia, /* 0xD10B */
4895 N_("Recording Media")},
4896 {PTP_DPC_NIKON_USBSpeed, /* 0xD10C */
4898 {PTP_DPC_NIKON_CCDNumber, /* 0xD10D */
4899 N_("CCD Serial Number")},
4900 {PTP_DPC_NIKON_CameraOrientation, /* 0xD10E */
4901 N_("Camera Orientation")},
4902 {PTP_DPC_NIKON_GroupPtnType, /* 0xD10F */
4903 N_("Group PTN Type")},
4904 {PTP_DPC_NIKON_FNumberLock, /* 0xD110 */
4905 N_("FNumber Lock")},
4906 {PTP_DPC_NIKON_ExposureApertureLock, /* 0xD111 */
4907 N_("Exposure Aperture Lock")},
4908 {PTP_DPC_NIKON_TVLockSetting, /* 0xD112 */
4909 N_("TV Lock Setting")},
4910 {PTP_DPC_NIKON_AVLockSetting, /* 0xD113 */
4911 N_("AV Lock Setting")},
4912 {PTP_DPC_NIKON_IllumSetting, /* 0xD114 */
4913 N_("Illum Setting")},
4914 {PTP_DPC_NIKON_FocusPointBright, /* 0xD115 */
4915 N_("Focus Point Bright")},
4916 {PTP_DPC_NIKON_ExternalFlashAttached, /* 0xD120 */
4917 N_("External Flash Attached")},
4918 {PTP_DPC_NIKON_ExternalFlashStatus, /* 0xD121 */
4919 N_("External Flash Status")},
4920 {PTP_DPC_NIKON_ExternalFlashSort, /* 0xD122 */
4921 N_("External Flash Sort")},
4922 {PTP_DPC_NIKON_ExternalFlashMode, /* 0xD123 */
4923 N_("External Flash Mode")},
4924 {PTP_DPC_NIKON_ExternalFlashCompensation, /* 0xD124 */
4925 N_("External Flash Compensation")},
4926 {PTP_DPC_NIKON_NewExternalFlashMode, /* 0xD125 */
4927 N_("External Flash Mode")},
4928 {PTP_DPC_NIKON_FlashExposureCompensation, /* 0xD126 */
4929 N_("Flash Exposure Compensation")},
4930 {PTP_DPC_NIKON_HDRMode, /* 0xD130 */
4932 {PTP_DPC_NIKON_HDRHighDynamic, /* 0xD131 */
4933 N_("HDR High Dynamic")},
4934 {PTP_DPC_NIKON_HDRSmoothing, /* 0xD132 */
4935 N_("HDR Smoothing")},
4936 {PTP_DPC_NIKON_OptimizeImage, /* 0xD140 */
4937 N_("Optimize Image")},
4938 {PTP_DPC_NIKON_Saturation, /* 0xD142 */
4940 {PTP_DPC_NIKON_BW_FillerEffect, /* 0xD143 */
4941 N_("BW Filler Effect")},
4942 {PTP_DPC_NIKON_BW_Sharpness, /* 0xD144 */
4943 N_("BW Sharpness")},
4944 {PTP_DPC_NIKON_BW_Contrast, /* 0xD145 */
4946 {PTP_DPC_NIKON_BW_Setting_Type, /* 0xD146 */
4947 N_("BW Setting Type")},
4948 {PTP_DPC_NIKON_Slot2SaveMode, /* 0xD148 */
4949 N_("Slot 2 Save Mode")},
4950 {PTP_DPC_NIKON_RawBitMode, /* 0xD149 */
4951 N_("Raw Bit Mode")},
4952 {PTP_DPC_NIKON_ActiveDLighting, /* 0xD14E */
4953 N_("Active D-Lighting")},
4954 {PTP_DPC_NIKON_FlourescentType, /* 0xD14F */
4955 N_("Flourescent Type")},
4956 {PTP_DPC_NIKON_TuneColourTemperature, /* 0xD150 */
4957 N_("Tune Colour Temperature")},
4958 {PTP_DPC_NIKON_TunePreset0, /* 0xD151 */
4959 N_("Tune Preset 0")},
4960 {PTP_DPC_NIKON_TunePreset1, /* 0xD152 */
4961 N_("Tune Preset 1")},
4962 {PTP_DPC_NIKON_TunePreset2, /* 0xD153 */
4963 N_("Tune Preset 2")},
4964 {PTP_DPC_NIKON_TunePreset3, /* 0xD154 */
4965 N_("Tune Preset 3")},
4966 {PTP_DPC_NIKON_TunePreset4, /* 0xD155 */
4967 N_("Tune Preset 4")},
4968 {PTP_DPC_NIKON_BeepOff, /* 0xD160 */
4969 N_("AF Beep Mode")},
4970 {PTP_DPC_NIKON_AutofocusMode, /* 0xD161 */
4971 N_("Autofocus Mode")},
4972 {PTP_DPC_NIKON_AFAssist, /* 0xD163 */
4973 N_("AF Assist Lamp")},
4974 {PTP_DPC_NIKON_PADVPMode, /* 0xD164 */
4975 N_("Auto ISO P/A/DVP Setting")},
4976 {PTP_DPC_NIKON_ImageReview, /* 0xD165 */
4977 N_("Image Review")},
4978 {PTP_DPC_NIKON_AFAreaIllumination, /* 0xD166 */
4979 N_("AF Area Illumination")},
4980 {PTP_DPC_NIKON_FlashMode, /* 0xD167 */
4982 {PTP_DPC_NIKON_FlashCommanderMode, /* 0xD168 */
4983 N_("Flash Commander Mode")},
4984 {PTP_DPC_NIKON_FlashSign, /* 0xD169 */
4986 {PTP_DPC_NIKON_ISO_Auto, /* 0xD16A */
4988 {PTP_DPC_NIKON_RemoteTimeout, /* 0xD16B */
4989 N_("Remote Timeout")},
4990 {PTP_DPC_NIKON_GridDisplay, /* 0xD16C */
4991 N_("Viewfinder Grid Display")},
4992 {PTP_DPC_NIKON_FlashModeManualPower, /* 0xD16D */
4993 N_("Flash Mode Manual Power")},
4994 {PTP_DPC_NIKON_FlashModeCommanderPower, /* 0xD16E */
4995 N_("Flash Mode Commander Power")},
4996 {PTP_DPC_NIKON_AutoFP, /* 0xD16F */
4998 {PTP_DPC_NIKON_CSMMenu, /* 0xD180 */
5000 {PTP_DPC_NIKON_WarningDisplay, /* 0xD181 */
5001 N_("Warning Display")},
5002 {PTP_DPC_NIKON_BatteryCellKind, /* 0xD182 */
5003 N_("Battery Cell Kind")},
5004 {PTP_DPC_NIKON_ISOAutoHiLimit, /* 0xD183 */
5005 N_("ISO Auto High Limit")},
5006 {PTP_DPC_NIKON_DynamicAFArea, /* 0xD184 */
5007 N_("Dynamic AF Area")},
5008 {PTP_DPC_NIKON_ContinuousSpeedHigh, /* 0xD186 */
5009 N_("Continuous Speed High")},
5010 {PTP_DPC_NIKON_InfoDispSetting, /* 0xD187 */
5011 N_("Info Disp Setting")},
5012 {PTP_DPC_NIKON_PreviewButton, /* 0xD189 */
5013 N_("Preview Button")},
5014 {PTP_DPC_NIKON_PreviewButton2, /* 0xD18A */
5015 N_("Preview Button 2")},
5016 {PTP_DPC_NIKON_AEAFLockButton2, /* 0xD18B */
5017 N_("AEAF Lock Button 2")},
5018 {PTP_DPC_NIKON_IndicatorDisp, /* 0xD18D */
5019 N_("Indicator Display")},
5020 {PTP_DPC_NIKON_CellKindPriority, /* 0xD18E */
5021 N_("Cell Kind Priority")},
5022 {PTP_DPC_NIKON_BracketingFramesAndSteps, /* 0xD190 */
5023 N_("Bracketing Frames and Steps")},
5024 {PTP_DPC_NIKON_LiveViewMode, /* 0xD1A0 */
5025 N_("Live View Mode")},
5026 {PTP_DPC_NIKON_LiveViewDriveMode, /* 0xD1A1 */
5027 N_("Live View Drive Mode")},
5028 {PTP_DPC_NIKON_LiveViewStatus, /* 0xD1A2 */
5029 N_("Live View Status")},
5030 {PTP_DPC_NIKON_LiveViewImageZoomRatio, /* 0xD1A3 */
5031 N_("Live View Image Zoom Ratio")},
5032 {PTP_DPC_NIKON_LiveViewProhibitCondition, /* 0xD1A4 */
5033 N_("Live View Prohibit Condition")},
5034 {PTP_DPC_NIKON_ExposureDisplayStatus, /* 0xD1B0 */
5035 N_("Exposure Display Status")},
5036 {PTP_DPC_NIKON_ExposureIndicateStatus, /* 0xD1B1 */
5037 N_("Exposure Indicate Status")},
5038 {PTP_DPC_NIKON_InfoDispErrStatus, /* 0xD1B2 */
5039 N_("Info Display Error Status")},
5040 {PTP_DPC_NIKON_ExposureIndicateLightup, /* 0xD1B3 */
5041 N_("Exposure Indicate Lightup")},
5042 {PTP_DPC_NIKON_FlashOpen, /* 0xD1C0 */
5044 {PTP_DPC_NIKON_FlashCharged, /* 0xD1C1 */
5045 N_("Flash Charged")},
5046 {PTP_DPC_NIKON_FlashMRepeatValue, /* 0xD1D0 */
5047 N_("Flash MRepeat Value")},
5048 {PTP_DPC_NIKON_FlashMRepeatCount, /* 0xD1D1 */
5049 N_("Flash MRepeat Count")},
5050 {PTP_DPC_NIKON_FlashMRepeatInterval, /* 0xD1D2 */
5051 N_("Flash MRepeat Interval")},
5052 {PTP_DPC_NIKON_FlashCommandChannel, /* 0xD1D3 */
5053 N_("Flash Command Channel")},
5054 {PTP_DPC_NIKON_FlashCommandSelfMode, /* 0xD1D4 */
5055 N_("Flash Command Self Mode")},
5056 {PTP_DPC_NIKON_FlashCommandSelfCompensation, /* 0xD1D5 */
5057 N_("Flash Command Self Compensation")},
5058 {PTP_DPC_NIKON_FlashCommandSelfValue, /* 0xD1D6 */
5059 N_("Flash Command Self Value")},
5060 {PTP_DPC_NIKON_FlashCommandAMode, /* 0xD1D7 */
5061 N_("Flash Command A Mode")},
5062 {PTP_DPC_NIKON_FlashCommandACompensation, /* 0xD1D8 */
5063 N_("Flash Command A Compensation")},
5064 {PTP_DPC_NIKON_FlashCommandAValue, /* 0xD1D9 */
5065 N_("Flash Command A Value")},
5066 {PTP_DPC_NIKON_FlashCommandBMode, /* 0xD1DA */
5067 N_("Flash Command B Mode")},
5068 {PTP_DPC_NIKON_FlashCommandBCompensation, /* 0xD1DB */
5069 N_("Flash Command B Compensation")},
5070 {PTP_DPC_NIKON_FlashCommandBValue, /* 0xD1DC */
5071 N_("Flash Command B Value")},
5072 {PTP_DPC_NIKON_ActivePicCtrlItem, /* 0xD200 */
5073 N_("Active Pic Ctrl Item")},
5074 {PTP_DPC_NIKON_ChangePicCtrlItem, /* 0xD201 */
5075 N_("Change Pic Ctrl Item")},
5081 } ptp_device_properties_MTP[] = {
5082 {PTP_DPC_MTP_SecureTime, N_("Secure Time")}, /* D101 */
5083 {PTP_DPC_MTP_DeviceCertificate, N_("Device Certificate")}, /* D102 */
5084 {PTP_DPC_MTP_RevocationInfo, N_("Revocation Info")}, /* D103 */
5085 {PTP_DPC_MTP_SynchronizationPartner, /* D401 */
5086 N_("Synchronization Partner")},
5087 {PTP_DPC_MTP_DeviceFriendlyName, /* D402 */
5088 N_("Friendly Device Name")},
5089 {PTP_DPC_MTP_VolumeLevel, N_("Volume Level")}, /* D403 */
5090 {PTP_DPC_MTP_DeviceIcon, N_("Device Icon")}, /* D405 */
5091 {PTP_DPC_MTP_SessionInitiatorInfo, N_("Session Initiator Info")},/* D406 */
5092 {PTP_DPC_MTP_PerceivedDeviceType, N_("Perceived Device Type")},/* D407 */
5093 {PTP_DPC_MTP_PlaybackRate, N_("Playback Rate")}, /* D410 */
5094 {PTP_DPC_MTP_PlaybackObject, N_("Playback Object")}, /* D411 */
5095 {PTP_DPC_MTP_PlaybackContainerIndex, /* D412 */
5096 N_("Playback Container Index")},
5097 {PTP_DPC_MTP_PlaybackPosition, N_("Playback Position")}, /* D413 */
5098 {PTP_DPC_MTP_PlaysForSureID, N_("PlaysForSure ID")}, /* D131 (?) */
5104 } ptp_device_properties_FUJI[] = {
5105 {PTP_DPC_FUJI_ColorTemperature, N_("Color Temperature")}, /* 0xD017 */
5106 {PTP_DPC_FUJI_Quality, N_("Quality")}, /* 0xD018 */
5107 {PTP_DPC_FUJI_Quality, N_("Release Mode")}, /* 0xD201 */
5108 {PTP_DPC_FUJI_Quality, N_("Focus Areas")}, /* 0xD206 */
5109 {PTP_DPC_FUJI_Quality, N_("AE Lock")}, /* 0xD213 */
5110 {PTP_DPC_FUJI_Quality, N_("Aperture")}, /* 0xD218 */
5111 {PTP_DPC_FUJI_Quality, N_("Shutter Speed")}, /* 0xD219 */
5115 for (i=0; ptp_device_properties[i].txt!=NULL; i++)
5116 if (ptp_device_properties[i].dpc==dpc)
5117 return (ptp_device_properties[i].txt);
5119 if (params->deviceinfo.VendorExtensionID==PTP_VENDOR_MICROSOFT
5120 || params->deviceinfo.VendorExtensionID==PTP_VENDOR_MTP)
5121 for (i=0; ptp_device_properties_MTP[i].txt!=NULL; i++)
5122 if (ptp_device_properties_MTP[i].dpc==dpc)
5123 return (ptp_device_properties_MTP[i].txt);
5125 if (params->deviceinfo.VendorExtensionID==PTP_VENDOR_EASTMAN_KODAK)
5126 for (i=0; ptp_device_properties_EK[i].txt!=NULL; i++)
5127 if (ptp_device_properties_EK[i].dpc==dpc)
5128 return (ptp_device_properties_EK[i].txt);
5130 if (params->deviceinfo.VendorExtensionID==PTP_VENDOR_CANON)
5131 for (i=0; ptp_device_properties_Canon[i].txt!=NULL; i++)
5132 if (ptp_device_properties_Canon[i].dpc==dpc)
5133 return (ptp_device_properties_Canon[i].txt);
5135 if (params->deviceinfo.VendorExtensionID==PTP_VENDOR_NIKON)
5136 for (i=0; ptp_device_properties_Nikon[i].txt!=NULL; i++)
5137 if (ptp_device_properties_Nikon[i].dpc==dpc)
5138 return (ptp_device_properties_Nikon[i].txt);
5140 if (params->deviceinfo.VendorExtensionID==PTP_VENDOR_FUJI)
5141 for (i=0; ptp_device_properties_FUJI[i].txt!=NULL; i++)
5142 if (ptp_device_properties_FUJI[i].dpc==dpc)
5143 return (ptp_device_properties_FUJI[i].txt);
5149 _value_to_num(PTPPropertyValue *data, uint16_t dt) {
5150 if (dt == PTP_DTC_STR) {
5153 return atol(data->str);
5155 if (dt & PTP_DTC_ARRAY_MASK) {
5167 case PTP_DTC_UINT16:
5171 case PTP_DTC_UINT32:
5187 #define PTP_VAL_BOOL(dpc) {dpc, 0, N_("Off")}, {dpc, 1, N_("On")}
5188 #define PTP_VENDOR_VAL_BOOL(dpc,vendor) {dpc, vendor, 0, N_("Off")}, {dpc, vendor, 1, N_("On")}
5189 #define PTP_VENDOR_VAL_RBOOL(dpc,vendor) {dpc, vendor, 0, N_("On")}, {dpc, vendor, 1, N_("Off")}
5190 #define PTP_VENDOR_VAL_YN(dpc,vendor) {dpc, vendor, 0, N_("No")}, {dpc, vendor, 1, N_("Yes")}
5193 ptp_render_property_value(PTPParams* params, uint16_t dpc,
5194 PTPDevicePropDesc *dpd, unsigned int length, char *out)
5205 } ptp_value_trans[] = {
5206 {PTP_DPC_BatteryLevel, 0, 1.0, 0.0, "%.0f%%"}, /* 5001 */
5207 {PTP_DPC_FNumber, 0, 0.01, 0.0, "f/%.2g"}, /* 5007 */
5208 {PTP_DPC_FocalLength, 0, 0.01, 0.0, "%.0f mm"}, /* 5008 */
5209 {PTP_DPC_FocusDistance, 0, 0.01, 0.0, "%.0f mm"}, /* 5009 */
5210 {PTP_DPC_ExposureTime, 0, 0.00001, 0.0, "%.2g sec"}, /* 500D */
5211 {PTP_DPC_ExposureIndex, 0, 1.0, 0.0, "ISO %.0f"}, /* 500F */
5212 {PTP_DPC_ExposureBiasCompensation, 0, 0.001, 0.0, N_("%.1f stops")},/* 5010 */
5213 {PTP_DPC_CaptureDelay, 0, 0.001, 0.0, "%.1fs"}, /* 5012 */
5214 {PTP_DPC_DigitalZoom, 0, 0.1, 0.0, "%.1f"}, /* 5016 */
5215 {PTP_DPC_BurstInterval, 0, 0.001, 0.0, "%.1fs"}, /* 5019 */
5217 /* Nikon device properties */
5218 {PTP_DPC_NIKON_LightMeter, PTP_VENDOR_NIKON, 0.08333, 0.0, N_("%.1f stops")},/* D10A */
5219 {PTP_DPC_NIKON_FlashExposureCompensation, PTP_VENDOR_NIKON, 0.16666, 0.0, N_("%.1f stops")}, /* D126 */
5220 {PTP_DPC_NIKON_CenterWeightArea, PTP_VENDOR_NIKON, 2.0, 6.0, N_("%.0f mm")},/* D059 */
5221 {PTP_DPC_NIKON_FocalLengthMin, PTP_VENDOR_NIKON, 0.01, 0.0, "%.0f mm"}, /* D0E3 */
5222 {PTP_DPC_NIKON_FocalLengthMax, PTP_VENDOR_NIKON, 0.01, 0.0, "%.0f mm"}, /* D0E4 */
5223 {PTP_DPC_NIKON_MaxApAtMinFocalLength, PTP_VENDOR_NIKON, 0.01, 0.0, "f/%.2g"}, /* D0E5 */
5224 {PTP_DPC_NIKON_MaxApAtMaxFocalLength, PTP_VENDOR_NIKON, 0.01, 0.0, "f/%.2g"}, /* D0E6 */
5225 {PTP_DPC_NIKON_ExternalFlashCompensation, PTP_VENDOR_NIKON, 1.0/6.0, 0.0,"%.0f"}, /* D124 */
5226 {PTP_DPC_NIKON_ExposureIndicateStatus, PTP_VENDOR_NIKON, 0.08333, 0.0, N_("%.1f stops")},/* D1B1 - FIXME: check if correct. */
5227 {PTP_DPC_NIKON_AngleLevel, PTP_VENDOR_NIKON, 1.0/65536, 0.0, "%.1f'"},/* 0xD067 */
5228 {0, 0, 0.0, 0.0, NULL}
5236 } ptp_value_list[] = {
5237 {PTP_DPC_CompressionSetting, 0, 0, N_("JPEG Basic")}, /* 5004 */
5238 {PTP_DPC_CompressionSetting, 0, 1, N_("JPEG Norm")},
5239 {PTP_DPC_CompressionSetting, 0, 2, N_("JPEG Fine")},
5240 {PTP_DPC_CompressionSetting, 0, 4, N_("RAW")},
5241 {PTP_DPC_CompressionSetting, 0, 5, N_("RAW + JPEG Basic")},
5242 {PTP_DPC_WhiteBalance, 0, 1, N_("Manual")},
5243 {PTP_DPC_WhiteBalance, 0, 2, N_("Automatic")}, /* 5005 */
5244 {PTP_DPC_WhiteBalance, 0, 3, N_("One-push Automatic")},
5245 {PTP_DPC_WhiteBalance, 0, 4, N_("Daylight")},
5246 {PTP_DPC_WhiteBalance, 0, 5, N_("Fluorescent")},
5247 {PTP_DPC_WhiteBalance, 0, 6, N_("Incandescent")},
5248 {PTP_DPC_WhiteBalance, 0, 7, N_("Flash")},
5249 {PTP_DPC_WhiteBalance, PTP_VENDOR_NIKON, 32784, N_("Cloudy")},
5250 {PTP_DPC_WhiteBalance, PTP_VENDOR_NIKON, 32785, N_("Shade")},
5251 {PTP_DPC_WhiteBalance, PTP_VENDOR_NIKON, 32786, N_("Color Temperature")},
5252 {PTP_DPC_WhiteBalance, PTP_VENDOR_NIKON, 32787, N_("Preset")},
5253 {PTP_DPC_FocusMode, 0, 1, N_("Manual Focus")}, /* 500A */
5254 {PTP_DPC_FocusMode, 0, 2, N_("Automatic")},
5255 {PTP_DPC_FocusMode, 0, 3, N_("Automatic Macro (close-up)")},
5256 {PTP_DPC_FocusMode, PTP_VENDOR_NIKON, 32784, "AF-S"},
5257 {PTP_DPC_FocusMode, PTP_VENDOR_NIKON, 32785, "AF-C"},
5258 {PTP_DPC_FocusMode, PTP_VENDOR_NIKON, 32786, "AF-A"},
5259 {PTP_DPC_ExposureMeteringMode, 0, 1, N_("Average")}, /* 500B */
5260 {PTP_DPC_ExposureMeteringMode, 0, 2, N_("Center Weighted Average")},
5261 {PTP_DPC_ExposureMeteringMode, 0, 3, N_("Multi-spot")},
5262 {PTP_DPC_ExposureMeteringMode, 0, 4, N_("Center-spot")},
5263 {PTP_DPC_FlashMode, 0, 0, N_("Undefined")}, /* 500C */
5264 {PTP_DPC_FlashMode, 0, 1, N_("Automatic flash")},
5265 {PTP_DPC_FlashMode, 0, 2, N_("Flash off")},
5266 {PTP_DPC_FlashMode, 0, 3, N_("Fill flash")},
5267 {PTP_DPC_FlashMode, 0, 4, N_("Automatic Red-eye Reduction")},
5268 {PTP_DPC_FlashMode, 0, 5, N_("Red-eye fill flash")},
5269 {PTP_DPC_FlashMode, 0, 6, N_("External sync")},
5270 {PTP_DPC_FlashMode, PTP_VENDOR_NIKON, 32784, N_("Auto")},
5271 {PTP_DPC_FlashMode, PTP_VENDOR_NIKON, 32785, N_("Auto Slow Sync")},
5272 {PTP_DPC_FlashMode, PTP_VENDOR_NIKON, 32786, N_("Rear Curtain Sync + Slow Sync")},
5273 {PTP_DPC_FlashMode, PTP_VENDOR_NIKON, 32787, N_("Red-eye Reduction + Slow Sync")},
5274 {PTP_DPC_ExposureProgramMode, 0, 1, "M"}, /* 500E */
5275 {PTP_DPC_ExposureProgramMode, 0, 3, "A"},
5276 {PTP_DPC_ExposureProgramMode, 0, 4, "S"},
5277 {PTP_DPC_ExposureProgramMode, 0, 2, "P"},
5278 {PTP_DPC_ExposureProgramMode, PTP_VENDOR_NIKON, 32784, N_("Auto")},
5279 {PTP_DPC_ExposureProgramMode, PTP_VENDOR_NIKON, 32785, N_("Portrait")},
5280 {PTP_DPC_ExposureProgramMode, PTP_VENDOR_NIKON, 32786, N_("Landscape")},
5281 {PTP_DPC_ExposureProgramMode, PTP_VENDOR_NIKON, 32787, N_("Macro")},
5282 {PTP_DPC_ExposureProgramMode, PTP_VENDOR_NIKON, 32788, N_("Sports")},
5283 {PTP_DPC_ExposureProgramMode, PTP_VENDOR_NIKON, 32790, N_("Night Landscape")},
5284 {PTP_DPC_ExposureProgramMode, PTP_VENDOR_NIKON, 32789, N_("Night Portrait")},
5285 {PTP_DPC_StillCaptureMode, 0, 1, N_("Single Shot")}, /* 5013 */
5286 {PTP_DPC_StillCaptureMode, 0, 2, N_("Power Wind")},
5287 {PTP_DPC_StillCaptureMode, 0, 3, N_("Timelapse")},
5288 {PTP_DPC_StillCaptureMode, PTP_VENDOR_NIKON, 32784, N_("Continuous Low Speed")},
5289 {PTP_DPC_StillCaptureMode, PTP_VENDOR_NIKON, 32785, N_("Timer")},
5290 {PTP_DPC_StillCaptureMode, PTP_VENDOR_NIKON, 32787, N_("Remote")},
5291 {PTP_DPC_StillCaptureMode, PTP_VENDOR_NIKON, 32787, N_("Mirror Up")},
5292 {PTP_DPC_StillCaptureMode, PTP_VENDOR_NIKON, 32788, N_("Timer + Remote")},
5293 {PTP_DPC_FocusMeteringMode, 0, 1, N_("Centre-spot")}, /* 501C */
5294 {PTP_DPC_FocusMeteringMode, 0, 2, N_("Multi-spot")},
5295 {PTP_DPC_FocusMeteringMode, PTP_VENDOR_NIKON, 32784, N_("Single Area")},
5296 {PTP_DPC_FocusMeteringMode, PTP_VENDOR_NIKON, 32785, N_("Closest Subject")},
5297 {PTP_DPC_FocusMeteringMode, PTP_VENDOR_NIKON, 32786, N_("Group Dynamic")},
5300 /* Nikon specific device properties */
5301 {PTP_DPC_NIKON_ImageSharpening, PTP_VENDOR_NIKON, 0, N_("Auto")}, /* D02A */
5302 {PTP_DPC_NIKON_ImageSharpening, PTP_VENDOR_NIKON, 1, N_("Normal")},
5303 {PTP_DPC_NIKON_ImageSharpening, PTP_VENDOR_NIKON, 2, N_("Low")},
5304 {PTP_DPC_NIKON_ImageSharpening, PTP_VENDOR_NIKON, 3, N_("Medium Low")},
5305 {PTP_DPC_NIKON_ImageSharpening, PTP_VENDOR_NIKON, 4, N_("Medium high")},
5306 {PTP_DPC_NIKON_ImageSharpening, PTP_VENDOR_NIKON, 5, N_("High")},
5307 {PTP_DPC_NIKON_ImageSharpening, PTP_VENDOR_NIKON, 6, N_("None")},
5309 {PTP_DPC_NIKON_ToneCompensation, PTP_VENDOR_NIKON, 0, N_("Auto")}, /* D02B */
5310 {PTP_DPC_NIKON_ToneCompensation, PTP_VENDOR_NIKON, 1, N_("Normal")},
5311 {PTP_DPC_NIKON_ToneCompensation, PTP_VENDOR_NIKON, 2, N_("Low contrast")},
5312 {PTP_DPC_NIKON_ToneCompensation, PTP_VENDOR_NIKON, 3, N_("Medium Low")},
5313 {PTP_DPC_NIKON_ToneCompensation, PTP_VENDOR_NIKON, 4, N_("Medium High")},
5314 {PTP_DPC_NIKON_ToneCompensation, PTP_VENDOR_NIKON, 5, N_("High control")},
5315 {PTP_DPC_NIKON_ToneCompensation, PTP_VENDOR_NIKON, 6, N_("Custom")},
5317 {PTP_DPC_NIKON_ColorModel, PTP_VENDOR_NIKON, 0, "sRGB"}, /* D02C */
5318 {PTP_DPC_NIKON_ColorModel, PTP_VENDOR_NIKON, 1, "AdobeRGB"},
5319 {PTP_DPC_NIKON_ColorModel, PTP_VENDOR_NIKON, 2, "sRGB"},
5321 PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_AutoDXCrop,PTP_VENDOR_NIKON), /* D033 */
5323 PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_FocusAreaWrap,PTP_VENDOR_NIKON), /* D04F */
5325 PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_EnableCopyright,PTP_VENDOR_NIKON), /* D053 */
5326 PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_ISOAuto,PTP_VENDOR_NIKON), /* D054 */
5328 /* FIXME! this is not ISO Auto (which is a bool) Perhaps ISO Auto Time?*/
5329 {PTP_DPC_NIKON_ISOAuto, PTP_VENDOR_NIKON, 0, "1/125"}, /* D054 */
5330 {PTP_DPC_NIKON_ISOAuto, PTP_VENDOR_NIKON, 1, "1/60"},
5331 {PTP_DPC_NIKON_ISOAuto, PTP_VENDOR_NIKON, 2, "1/30"},
5332 {PTP_DPC_NIKON_ISOAuto, PTP_VENDOR_NIKON, 3, "1/15"},
5333 {PTP_DPC_NIKON_ISOAuto, PTP_VENDOR_NIKON, 4, "1/8"},
5334 {PTP_DPC_NIKON_ISOAuto, PTP_VENDOR_NIKON, 5, "1/4"},
5335 {PTP_DPC_NIKON_ISOAuto, PTP_VENDOR_NIKON, 6, "1/2"},
5336 {PTP_DPC_NIKON_ISOAuto, PTP_VENDOR_NIKON, 7, "1"},
5337 {PTP_DPC_NIKON_ISOAuto, PTP_VENDOR_NIKON, 8, "2"},
5338 {PTP_DPC_NIKON_ISOAuto, PTP_VENDOR_NIKON, 9, "4"},
5339 {PTP_DPC_NIKON_ISOAuto, PTP_VENDOR_NIKON, 10, "8"},
5340 {PTP_DPC_NIKON_ISOAuto, PTP_VENDOR_NIKON, 11, "15"},
5341 {PTP_DPC_NIKON_ISOAuto, PTP_VENDOR_NIKON, 12, "30"},
5343 {PTP_DPC_NIKON_EVStep, PTP_VENDOR_NIKON, 0, "1/3"}, /* D056 */
5344 {PTP_DPC_NIKON_EVStep, PTP_VENDOR_NIKON, 1, "1/2"},
5346 PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_ExposureCompensation,PTP_VENDOR_NIKON),/*D058 */
5347 PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_AELockMode,PTP_VENDOR_NIKON), /* D05E */
5349 {PTP_DPC_NIKON_AELAFLMode, PTP_VENDOR_NIKON, 0, N_("AE/AF Lock")}, /* D05F */
5350 {PTP_DPC_NIKON_AELAFLMode, PTP_VENDOR_NIKON, 1, N_("AF Lock only")},
5351 {PTP_DPC_NIKON_AELAFLMode, PTP_VENDOR_NIKON, 2, N_("AE Lock only")},
5352 {PTP_DPC_NIKON_AELAFLMode, PTP_VENDOR_NIKON, 3, N_("AF Lock Hold")},
5353 {PTP_DPC_NIKON_AELAFLMode, PTP_VENDOR_NIKON, 4, N_("AF On")},
5354 {PTP_DPC_NIKON_AELAFLMode, PTP_VENDOR_NIKON, 5, N_("Flash Lock")},
5356 {PTP_DPC_NIKON_MeterOff, PTP_VENDOR_NIKON, 0, N_("4 seconds")}, /* D062 */
5357 {PTP_DPC_NIKON_MeterOff, PTP_VENDOR_NIKON, 1, N_("6 seconds")},
5358 {PTP_DPC_NIKON_MeterOff, PTP_VENDOR_NIKON, 2, N_("8 seconds")},
5359 {PTP_DPC_NIKON_MeterOff, PTP_VENDOR_NIKON, 3, N_("16 seconds")},
5360 {PTP_DPC_NIKON_MeterOff, PTP_VENDOR_NIKON, 4, N_("30 minutes")},
5361 {PTP_DPC_NIKON_MeterOff, PTP_VENDOR_NIKON, 5, N_("30 seconds")},
5363 {PTP_DPC_NIKON_SelfTimer, PTP_VENDOR_NIKON, 0, N_("2 seconds")}, /* D063 */
5364 {PTP_DPC_NIKON_SelfTimer, PTP_VENDOR_NIKON, 1, N_("5 seconds")},
5365 {PTP_DPC_NIKON_SelfTimer, PTP_VENDOR_NIKON, 2, N_("10 seconds")},
5366 {PTP_DPC_NIKON_SelfTimer, PTP_VENDOR_NIKON, 3, N_("20 seconds")},
5368 {PTP_DPC_NIKON_MonitorOff, PTP_VENDOR_NIKON, 0, N_("10 seconds")}, /* D064 */
5369 {PTP_DPC_NIKON_MonitorOff, PTP_VENDOR_NIKON, 1, N_("20 seconds")},
5370 {PTP_DPC_NIKON_MonitorOff, PTP_VENDOR_NIKON, 2, N_("1 minute")},
5371 {PTP_DPC_NIKON_MonitorOff, PTP_VENDOR_NIKON, 3, N_("5 minutes")},
5372 {PTP_DPC_NIKON_MonitorOff, PTP_VENDOR_NIKON, 4, N_("10 minutes")},
5373 {PTP_DPC_NIKON_MonitorOff, PTP_VENDOR_NIKON, 5, N_("5 seconds")}, /* d80 observed */
5375 PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_ExposureDelayMode,PTP_VENDOR_NIKON), /* D06A */
5376 PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_LongExposureNoiseReduction,PTP_VENDOR_NIKON), /* D06B */
5377 PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_FileNumberSequence,PTP_VENDOR_NIKON), /* D06C */
5378 PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_D7Illumination,PTP_VENDOR_NIKON), /* D06F */
5380 PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_SHSET_CH_GUID_DISP,PTP_VENDOR_NIKON), /* D071 */
5382 {PTP_DPC_NIKON_FlashShutterSpeed, PTP_VENDOR_NIKON, 0, "1/60s"}, /* D075 */
5383 {PTP_DPC_NIKON_FlashShutterSpeed, PTP_VENDOR_NIKON, 1, "1/30s"},
5384 {PTP_DPC_NIKON_FlashShutterSpeed, PTP_VENDOR_NIKON, 2, "1/15s"},
5385 {PTP_DPC_NIKON_FlashShutterSpeed, PTP_VENDOR_NIKON, 3, "1/8s"},
5386 {PTP_DPC_NIKON_FlashShutterSpeed, PTP_VENDOR_NIKON, 4, "1/4s"},
5387 {PTP_DPC_NIKON_FlashShutterSpeed, PTP_VENDOR_NIKON, 5, "1/2s"},
5388 {PTP_DPC_NIKON_FlashShutterSpeed, PTP_VENDOR_NIKON, 6, "1s"},
5389 {PTP_DPC_NIKON_FlashShutterSpeed, PTP_VENDOR_NIKON, 7, "2s"},
5390 {PTP_DPC_NIKON_FlashShutterSpeed, PTP_VENDOR_NIKON, 8, "4s"},
5391 {PTP_DPC_NIKON_FlashShutterSpeed, PTP_VENDOR_NIKON, 9, "8s"},
5392 {PTP_DPC_NIKON_FlashShutterSpeed, PTP_VENDOR_NIKON, 10, "15s"},
5393 {PTP_DPC_NIKON_FlashShutterSpeed, PTP_VENDOR_NIKON, 11, "30s"},
5395 PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_E4ModelingFlash,PTP_VENDOR_NIKON), /* D077 */
5397 {PTP_DPC_NIKON_BracketSet, PTP_VENDOR_NIKON, 0, N_("AE & Flash")}, /* D078 */
5398 {PTP_DPC_NIKON_BracketSet, PTP_VENDOR_NIKON, 1, N_("AE only")},
5399 {PTP_DPC_NIKON_BracketSet, PTP_VENDOR_NIKON, 2, N_("Flash only")},
5400 {PTP_DPC_NIKON_BracketSet, PTP_VENDOR_NIKON, 3, N_("WB bracketing")},
5402 {PTP_DPC_NIKON_BracketOrder, PTP_VENDOR_NIKON, 0, N_("MTR > Under")}, /* D07A */
5403 {PTP_DPC_NIKON_BracketOrder, PTP_VENDOR_NIKON, 1, N_("Under > MTR")},
5405 {PTP_DPC_NIKON_F1CenterButtonShootingMode, PTP_VENDOR_NIKON, 0, N_("Reset focus point to center")}, /* D080 */
5406 {PTP_DPC_NIKON_F1CenterButtonShootingMode, PTP_VENDOR_NIKON, 1, N_("Highlight active focus point")},
5407 {PTP_DPC_NIKON_F1CenterButtonShootingMode, PTP_VENDOR_NIKON, 2, N_("Unused")},
5409 PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_F3PhotoInfoPlayback,PTP_VENDOR_NIKON),/* D083 */
5410 PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_F5CustomizeCommDials,PTP_VENDOR_NIKON),/* D085 */
5411 PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_ReverseCommandDial,PTP_VENDOR_NIKON), /* D086 */
5412 PTP_VENDOR_VAL_RBOOL(PTP_DPC_NIKON_F6ButtonsAndDials,PTP_VENDOR_NIKON), /* D089 */
5413 PTP_VENDOR_VAL_RBOOL(PTP_DPC_NIKON_NoCFCard,PTP_VENDOR_NIKON), /* D08A */
5414 PTP_VENDOR_VAL_RBOOL(PTP_DPC_NIKON_AFAreaPoint,PTP_VENDOR_NIKON), /* D08D */
5416 PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_ImageCommentEnable,PTP_VENDOR_NIKON), /* D091 */
5417 PTP_VENDOR_VAL_RBOOL(PTP_DPC_NIKON_ImageRotation,PTP_VENDOR_NIKON), /* D092 */
5419 PTP_VENDOR_VAL_RBOOL(PTP_DPC_NIKON_MovVoice,PTP_VENDOR_NIKON), /* D0A1 */
5421 PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_Bracketing,PTP_VENDOR_NIKON), /* D0C0 */
5423 /* http://www.rottmerhusen.com/objektives/lensid/nikkor.html is complete */
5424 {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 0, N_("Unknown")}, /* D0E0 */
5425 {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 38, "Sigma 70-300mm 1:4-5.6 D APO Macro"},
5426 {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 83, "AF Nikkor 80-200mm 1:2.8 D ED"},
5427 {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 118, "AF Nikkor 50mm 1:1.8 D"},
5428 {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 127, "AF-S Nikkor 18-70mm 1:3.5-4.5G ED DX"},
5429 {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 139, "AF-S Nikkor 18-200mm 1:3.5-5.6 GED DX VR"},
5430 {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 147, "AF-S Nikkor 24-70mm 1:2.8G ED DX"},
5431 {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 154, "AF-S Nikkor 18-55mm 1:3.5-F5.6G DX VR"},
5432 {PTP_DPC_NIKON_LensID, PTP_VENDOR_NIKON, 159, "AF-S Nikkor 35mm 1:1.8G DX"},
5433 {PTP_DPC_NIKON_FinderISODisp, PTP_VENDOR_NIKON, 0, "Show ISO sensitivity"},/* 0xD0F0 */
5434 {PTP_DPC_NIKON_FinderISODisp, PTP_VENDOR_NIKON, 1, "Show ISO/Easy ISO"},
5435 {PTP_DPC_NIKON_FinderISODisp, PTP_VENDOR_NIKON, 2, "Show frame count"},
5437 {PTP_DPC_NIKON_RawCompression, PTP_VENDOR_NIKON, 0, N_("Lossless")}, /* D016 */
5438 {PTP_DPC_NIKON_RawCompression, PTP_VENDOR_NIKON, 1, N_("Lossy")},
5440 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_ACPower,PTP_VENDOR_NIKON), /* D101 */
5441 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_AFLockStatus,PTP_VENDOR_NIKON), /* D104 */
5442 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_AELockStatus,PTP_VENDOR_NIKON), /* D105 */
5443 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_FVLockStatus,PTP_VENDOR_NIKON), /* D106 */
5445 {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 0, N_("Centre")}, /* D108 */
5446 {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 1, N_("Top")},
5447 {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 2, N_("Bottom")},
5448 {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 3, N_("Left")},
5449 {PTP_DPC_NIKON_AutofocusArea, PTP_VENDOR_NIKON, 4, N_("Right")},
5451 {PTP_DPC_NIKON_RecordingMedia, PTP_VENDOR_NIKON, 0, N_("Card")}, /* D10B */
5452 {PTP_DPC_NIKON_RecordingMedia, PTP_VENDOR_NIKON, 1, N_("SDRam")},
5454 {PTP_DPC_NIKON_USBSpeed, PTP_VENDOR_NIKON, 0, N_("USB 1.1")}, /* D10C */
5455 {PTP_DPC_NIKON_USBSpeed, PTP_VENDOR_NIKON, 1, N_("USB 2.0")},
5457 {PTP_DPC_NIKON_CameraOrientation, PTP_VENDOR_NIKON, 0, "0'"}, /* D10E */
5458 {PTP_DPC_NIKON_CameraOrientation, PTP_VENDOR_NIKON, 1, "270'"},
5459 {PTP_DPC_NIKON_CameraOrientation, PTP_VENDOR_NIKON, 2, "90'"},
5460 {PTP_DPC_NIKON_CameraOrientation, PTP_VENDOR_NIKON, 3, "180'"},
5462 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_FNumberLock,PTP_VENDOR_NIKON), /* D110 */
5463 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_ExposureApertureLock,PTP_VENDOR_NIKON), /* D111 */
5464 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_TVLockSetting,PTP_VENDOR_NIKON), /* D112 */
5465 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_AVLockSetting,PTP_VENDOR_NIKON), /* D113 */
5467 {PTP_DPC_NIKON_IllumSetting,PTP_VENDOR_NIKON,0,N_("LCD Backlight")}, /* D114 */
5468 {PTP_DPC_NIKON_IllumSetting,PTP_VENDOR_NIKON,1,N_("LCD Backlight and Info Display")},
5470 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_ExternalFlashAttached,PTP_VENDOR_NIKON),/* D120 */
5471 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_ExternalFlashStatus,PTP_VENDOR_NIKON), /* D121 */
5473 {PTP_DPC_NIKON_OptimizeImage, PTP_VENDOR_NIKON, 0, N_("Normal")}, /* D140 */
5474 {PTP_DPC_NIKON_OptimizeImage, PTP_VENDOR_NIKON, 1, N_("Vivid")},
5475 {PTP_DPC_NIKON_OptimizeImage, PTP_VENDOR_NIKON, 2, N_("Sharper")},
5476 {PTP_DPC_NIKON_OptimizeImage, PTP_VENDOR_NIKON, 3, N_("Softer")},
5477 {PTP_DPC_NIKON_OptimizeImage, PTP_VENDOR_NIKON, 4, N_("Direct Print")},
5478 {PTP_DPC_NIKON_OptimizeImage, PTP_VENDOR_NIKON, 5, N_("Portrait")},
5479 {PTP_DPC_NIKON_OptimizeImage, PTP_VENDOR_NIKON, 6, N_("Landscape")},
5480 {PTP_DPC_NIKON_OptimizeImage, PTP_VENDOR_NIKON, 7, N_("Custom")},
5482 {PTP_DPC_NIKON_Saturation, PTP_VENDOR_NIKON, 0, N_("Normal")}, /* D142 */
5483 {PTP_DPC_NIKON_Saturation, PTP_VENDOR_NIKON, 1, N_("Moderate")},
5484 {PTP_DPC_NIKON_Saturation, PTP_VENDOR_NIKON, 2, N_("Enhanced")},
5486 PTP_VENDOR_VAL_RBOOL(PTP_DPC_NIKON_BeepOff,PTP_VENDOR_NIKON), /* D160 */
5488 {PTP_DPC_NIKON_AutofocusMode, PTP_VENDOR_NIKON, 0, N_("AF-S")}, /* D161 */
5489 {PTP_DPC_NIKON_AutofocusMode, PTP_VENDOR_NIKON, 1, N_("AF-C")},
5490 {PTP_DPC_NIKON_AutofocusMode, PTP_VENDOR_NIKON, 2, N_("AF-A")},
5491 {PTP_DPC_NIKON_AutofocusMode, PTP_VENDOR_NIKON, 3, N_("MF (fixed)")},
5492 {PTP_DPC_NIKON_AutofocusMode, PTP_VENDOR_NIKON, 4, N_("MF (selection)")},
5494 PTP_VENDOR_VAL_RBOOL(PTP_DPC_NIKON_AFAssist,PTP_VENDOR_NIKON), /* D163 */
5496 {PTP_DPC_NIKON_PADVPMode, PTP_VENDOR_NIKON, 0, "1/125"}, /* D164 */
5497 {PTP_DPC_NIKON_PADVPMode, PTP_VENDOR_NIKON, 1, "1/60"},
5498 {PTP_DPC_NIKON_PADVPMode, PTP_VENDOR_NIKON, 2, "1/30"},
5499 {PTP_DPC_NIKON_PADVPMode, PTP_VENDOR_NIKON, 3, "1/15"},
5500 {PTP_DPC_NIKON_PADVPMode, PTP_VENDOR_NIKON, 4, "1/8"},
5501 {PTP_DPC_NIKON_PADVPMode, PTP_VENDOR_NIKON, 5, "1/4"},
5502 {PTP_DPC_NIKON_PADVPMode, PTP_VENDOR_NIKON, 6, "1/2"},
5503 {PTP_DPC_NIKON_PADVPMode, PTP_VENDOR_NIKON, 7, "1"},
5504 {PTP_DPC_NIKON_PADVPMode, PTP_VENDOR_NIKON, 8, "2"},
5505 {PTP_DPC_NIKON_PADVPMode, PTP_VENDOR_NIKON, 9, "4"},
5506 {PTP_DPC_NIKON_PADVPMode, PTP_VENDOR_NIKON, 10, "8"},
5507 {PTP_DPC_NIKON_PADVPMode, PTP_VENDOR_NIKON, 11, "15"},
5508 {PTP_DPC_NIKON_PADVPMode, PTP_VENDOR_NIKON, 12, "30"},
5510 PTP_VENDOR_VAL_RBOOL(PTP_DPC_NIKON_ImageReview,PTP_VENDOR_NIKON), /* D165 */
5512 {PTP_DPC_NIKON_AFAreaIllumination, PTP_VENDOR_NIKON, 0, N_("Auto")}, /* D166 */
5513 {PTP_DPC_NIKON_AFAreaIllumination, PTP_VENDOR_NIKON, 1, N_("Off")},
5514 {PTP_DPC_NIKON_AFAreaIllumination, PTP_VENDOR_NIKON, 2, N_("On")},
5516 {PTP_DPC_NIKON_FlashMode, PTP_VENDOR_NIKON, 0, "iTTL"}, /* D167 */
5517 {PTP_DPC_NIKON_FlashMode, PTP_VENDOR_NIKON, 1, N_("Manual")},
5518 {PTP_DPC_NIKON_FlashMode, PTP_VENDOR_NIKON, 2, N_("Commander")},
5520 {PTP_DPC_NIKON_FlashCommanderMode, PTP_VENDOR_NIKON, 0, N_("TTL")}, /* D168 */
5521 {PTP_DPC_NIKON_FlashCommanderMode, PTP_VENDOR_NIKON, 1, N_("Auto Aperture")},
5522 {PTP_DPC_NIKON_FlashCommanderMode, PTP_VENDOR_NIKON, 2, N_("Full Manual")},
5524 PTP_VENDOR_VAL_RBOOL(PTP_DPC_NIKON_FlashSign,PTP_VENDOR_NIKON), /* D169 */
5526 {PTP_DPC_NIKON_RemoteTimeout, PTP_VENDOR_NIKON, 0, N_("1 min")}, /* D16B */
5527 {PTP_DPC_NIKON_RemoteTimeout, PTP_VENDOR_NIKON, 1, N_("5 mins")},
5528 {PTP_DPC_NIKON_RemoteTimeout, PTP_VENDOR_NIKON, 2, N_("10 mins")},
5529 {PTP_DPC_NIKON_RemoteTimeout, PTP_VENDOR_NIKON, 3, N_("15 mins")},
5531 PTP_VENDOR_VAL_BOOL(PTP_DPC_NIKON_GridDisplay,PTP_VENDOR_NIKON), /* D16C */
5533 {PTP_DPC_NIKON_FlashModeManualPower, PTP_VENDOR_NIKON, 0, N_("Full")}, /* D16D */
5534 {PTP_DPC_NIKON_FlashModeManualPower, PTP_VENDOR_NIKON, 1, "1/2"},
5535 {PTP_DPC_NIKON_FlashModeManualPower, PTP_VENDOR_NIKON, 2, "1/4"},
5536 {PTP_DPC_NIKON_FlashModeManualPower, PTP_VENDOR_NIKON, 3, "1/8"},
5537 {PTP_DPC_NIKON_FlashModeManualPower, PTP_VENDOR_NIKON, 4, "1/16"},
5539 {PTP_DPC_NIKON_FlashModeCommanderPower, PTP_VENDOR_NIKON, 0, N_("Full")},/* D16E */
5540 {PTP_DPC_NIKON_FlashModeCommanderPower, PTP_VENDOR_NIKON, 1, "1/2"},
5541 {PTP_DPC_NIKON_FlashModeCommanderPower, PTP_VENDOR_NIKON, 2, "1/4"},
5542 {PTP_DPC_NIKON_FlashModeCommanderPower, PTP_VENDOR_NIKON, 3, "1/8"},
5543 {PTP_DPC_NIKON_FlashModeCommanderPower, PTP_VENDOR_NIKON, 4, "1/16"},
5544 {PTP_DPC_NIKON_FlashModeCommanderPower, PTP_VENDOR_NIKON, 5, "1/32"},
5545 {PTP_DPC_NIKON_FlashModeCommanderPower, PTP_VENDOR_NIKON, 6, "1/64"},
5546 {PTP_DPC_NIKON_FlashModeCommanderPower, PTP_VENDOR_NIKON, 7, "1/128"},
5548 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_CSMMenu,PTP_VENDOR_NIKON), /* D180 */
5549 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_WarningDisplay,PTP_VENDOR_NIKON), /* D181 */
5551 {PTP_DPC_NIKON_BatteryCellKind, PTP_VENDOR_NIKON, 0, "LR6 (AA alkaline)"},/* D182 */
5552 {PTP_DPC_NIKON_BatteryCellKind, PTP_VENDOR_NIKON, 1, "HR6 (AA Ni-Mh)"},
5553 {PTP_DPC_NIKON_BatteryCellKind, PTP_VENDOR_NIKON, 2, "FR6 (AA Lithium)"},
5554 {PTP_DPC_NIKON_BatteryCellKind, PTP_VENDOR_NIKON, 3, "ZR6 (AA Ni-Mn)"},
5556 {PTP_DPC_NIKON_ISOAutoHiLimit, PTP_VENDOR_NIKON, 0, "400"}, /* D183 */
5557 {PTP_DPC_NIKON_ISOAutoHiLimit, PTP_VENDOR_NIKON, 1, "800"},
5558 {PTP_DPC_NIKON_ISOAutoHiLimit, PTP_VENDOR_NIKON, 2, "1600"},
5559 {PTP_DPC_NIKON_ISOAutoHiLimit, PTP_VENDOR_NIKON, 3, "3200"},
5560 {PTP_DPC_NIKON_ISOAutoHiLimit, PTP_VENDOR_NIKON, 4, "Hi 1"},
5561 {PTP_DPC_NIKON_ISOAutoHiLimit, PTP_VENDOR_NIKON, 5, "Hi 2"},
5563 {PTP_DPC_NIKON_InfoDispSetting, PTP_VENDOR_NIKON, 0, N_("Auto")}, /* 0xD187 */
5564 {PTP_DPC_NIKON_InfoDispSetting, PTP_VENDOR_NIKON, 1, N_("Dark on light")},
5565 {PTP_DPC_NIKON_InfoDispSetting, PTP_VENDOR_NIKON, 2, N_("Light on dark")},
5567 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_IndicatorDisp,PTP_VENDOR_NIKON), /* D18D */
5569 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_LiveViewStatus,PTP_VENDOR_NIKON), /* D1A2 */
5571 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_ExposureDisplayStatus,PTP_VENDOR_NIKON),/* D1B0 */
5572 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_InfoDispErrStatus,PTP_VENDOR_NIKON), /* D1B2 */
5573 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_ExposureIndicateLightup,PTP_VENDOR_NIKON),/* D1B3 */
5575 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_FlashOpen,PTP_VENDOR_NIKON), /* D1C0 */
5576 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_FlashCharged,PTP_VENDOR_NIKON), /* D1C1 */
5578 PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_ManualMovieSetting,PTP_VENDOR_NIKON), /* 0xD0A6 */
5580 {PTP_DPC_NIKON_FlickerReduction, PTP_VENDOR_NIKON, 0, "50Hz"}, /* 0xD034 */
5581 {PTP_DPC_NIKON_FlickerReduction, PTP_VENDOR_NIKON, 1, "60Hz"},
5583 {PTP_DPC_NIKON_RemoteMode, PTP_VENDOR_NIKON, 0, N_("Delayed Remote")}, /* 0xD035 */
5584 {PTP_DPC_NIKON_RemoteMode, PTP_VENDOR_NIKON, 1, N_("Quick Response")}, /* 0xD035 */
5585 {PTP_DPC_NIKON_RemoteMode, PTP_VENDOR_NIKON, 2, N_("Remote Mirror Up")},/* 0xD035 */
5587 {PTP_DPC_NIKON_MonitorOffDelay, PTP_VENDOR_NIKON, 0, "5min"}, /* 0xD0b3 */
5588 {PTP_DPC_NIKON_MonitorOffDelay, PTP_VENDOR_NIKON, 1, "10min"}, /* 0xD0b3 */
5589 {PTP_DPC_NIKON_MonitorOffDelay, PTP_VENDOR_NIKON, 2, "15min"}, /* 0xD0b3 */
5590 {PTP_DPC_NIKON_MonitorOffDelay, PTP_VENDOR_NIKON, 3, "20min"}, /* 0xD0b3 */
5591 {PTP_DPC_NIKON_MonitorOffDelay, PTP_VENDOR_NIKON, 4, "30min"}, /* 0xD0b3 */
5595 PTP_VENDOR_VAL_BOOL(PTP_DPC_CANON_AssistLight,PTP_VENDOR_CANON),
5596 PTP_VENDOR_VAL_RBOOL(PTP_DPC_CANON_RotationScene,PTP_VENDOR_CANON),
5597 PTP_VENDOR_VAL_RBOOL(PTP_DPC_CANON_BeepMode,PTP_VENDOR_CANON),
5598 PTP_VENDOR_VAL_BOOL(PTP_DPC_CANON_Beep,PTP_VENDOR_CANON),
5600 {PTP_DPC_CANON_RotationAngle, PTP_VENDOR_CANON, 0, "0'"},
5601 {PTP_DPC_CANON_RotationAngle, PTP_VENDOR_CANON, 3, "270'"},
5602 {PTP_DPC_CANON_RotationAngle, PTP_VENDOR_CANON, 1, "90'"},
5604 {PTP_DPC_CANON_BatteryKind, PTP_VENDOR_CANON, 0, N_("Unknown")},
5605 {PTP_DPC_CANON_BatteryKind, PTP_VENDOR_CANON, 1, N_("AC")},
5606 {PTP_DPC_CANON_BatteryKind, PTP_VENDOR_CANON, 2, N_("Lithium Ion")},
5607 {PTP_DPC_CANON_BatteryKind, PTP_VENDOR_CANON, 3, N_("Nickel hydride")},
5608 {PTP_DPC_CANON_BatteryKind, PTP_VENDOR_CANON, 4, N_("Nickel cadmium")},
5609 {PTP_DPC_CANON_BatteryKind, PTP_VENDOR_CANON, 5, N_("Alkalium manganese")},
5611 {PTP_DPC_CANON_BatteryStatus, PTP_VENDOR_CANON, 0, N_("Undefined")},
5612 {PTP_DPC_CANON_BatteryStatus, PTP_VENDOR_CANON, 1, N_("Normal")},
5613 {PTP_DPC_CANON_BatteryStatus, PTP_VENDOR_CANON, 2, N_("Warning Level 1")},
5614 {PTP_DPC_CANON_BatteryStatus, PTP_VENDOR_CANON, 3, N_("Emergency")},
5615 {PTP_DPC_CANON_BatteryStatus, PTP_VENDOR_CANON, 4, N_("Warning Level 0")},
5617 {PTP_DPC_CANON_ImageQuality, PTP_VENDOR_CANON, 0, N_("Undefined")},
5618 {PTP_DPC_CANON_ImageQuality, PTP_VENDOR_CANON, 1, N_("Economy")},
5619 {PTP_DPC_CANON_ImageQuality, PTP_VENDOR_CANON, 2, N_("Normal")},
5620 {PTP_DPC_CANON_ImageQuality, PTP_VENDOR_CANON, 3, N_("Fine")},
5621 {PTP_DPC_CANON_ImageQuality, PTP_VENDOR_CANON, 4, N_("Lossless")},
5622 {PTP_DPC_CANON_ImageQuality, PTP_VENDOR_CANON, 5, N_("SuperFine")},
5624 {PTP_DPC_CANON_FullViewFileFormat, PTP_VENDOR_CANON, 0, N_("Undefined")},
5625 {PTP_DPC_CANON_FullViewFileFormat, PTP_VENDOR_CANON, 1, N_("JPEG")},
5626 {PTP_DPC_CANON_FullViewFileFormat, PTP_VENDOR_CANON, 2, N_("CRW")},
5628 {PTP_DPC_CANON_ImageSize, PTP_VENDOR_CANON, 0, N_("Large")},
5629 {PTP_DPC_CANON_ImageSize, PTP_VENDOR_CANON, 1, N_("Medium 1")},
5630 {PTP_DPC_CANON_ImageSize, PTP_VENDOR_CANON, 2, N_("Small")},
5631 {PTP_DPC_CANON_ImageSize, PTP_VENDOR_CANON, 3, N_("Medium 2")},
5632 {PTP_DPC_CANON_ImageSize, PTP_VENDOR_CANON, 7, N_("Medium 3")},
5634 {PTP_DPC_CANON_SelfTime, PTP_VENDOR_CANON, 0, N_("Not used")},
5635 {PTP_DPC_CANON_SelfTime, PTP_VENDOR_CANON, 100, N_("10 seconds")},
5636 {PTP_DPC_CANON_SelfTime, PTP_VENDOR_CANON, 20, N_("2 seconds")},
5638 {PTP_DPC_CANON_FlashMode, PTP_VENDOR_CANON, 0, N_("Off")},
5639 {PTP_DPC_CANON_FlashMode, PTP_VENDOR_CANON, 1, N_("Auto")},
5640 {PTP_DPC_CANON_FlashMode, PTP_VENDOR_CANON, 2, N_("On")},
5641 {PTP_DPC_CANON_FlashMode, PTP_VENDOR_CANON, 3, N_("Red Eye Suppression")},
5642 {PTP_DPC_CANON_FlashMode, PTP_VENDOR_CANON, 4, N_("Low Speed Synchronization")},
5643 {PTP_DPC_CANON_FlashMode, PTP_VENDOR_CANON, 5, N_("Auto + Red Eye Suppression")},
5644 {PTP_DPC_CANON_FlashMode, PTP_VENDOR_CANON, 6, N_("On + Red Eye Suppression")},
5646 {PTP_DPC_CANON_ShootingMode, PTP_VENDOR_CANON, 0, N_("Auto")},
5647 {PTP_DPC_CANON_ShootingMode, PTP_VENDOR_CANON, 1, N_("P")},
5648 {PTP_DPC_CANON_ShootingMode, PTP_VENDOR_CANON, 2, N_("Tv")},
5649 {PTP_DPC_CANON_ShootingMode, PTP_VENDOR_CANON, 3, N_("Av")},
5650 {PTP_DPC_CANON_ShootingMode, PTP_VENDOR_CANON, 4, N_("M")},
5651 {PTP_DPC_CANON_ShootingMode, PTP_VENDOR_CANON, 5, N_("A_DEP")},
5652 {PTP_DPC_CANON_ShootingMode, PTP_VENDOR_CANON, 6, N_("M_DEP")},
5653 {PTP_DPC_CANON_ShootingMode, PTP_VENDOR_CANON, 7, N_("Bulb")},
5656 {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 0, N_("Auto")},
5657 {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 1, N_("Manual")},
5658 {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 2, N_("Distant View")},
5659 {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 3, N_("High-Speed Shutter")},
5660 {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 4, N_("Low-Speed Shutter")},
5661 {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 5, N_("Night View")},
5662 {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 6, N_("Grayscale")},
5663 {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 7, N_("Sepia")},
5664 {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 8, N_("Portrait")},
5665 {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 9, N_("Sports")},
5666 {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 10, N_("Macro")},
5667 {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 11, N_("Monochrome")},
5668 {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 12, N_("Pan Focus")},
5669 {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 13, N_("Neutral")},
5670 {PTP_DPC_CANON_ImageMode, PTP_VENDOR_CANON, 14, N_("Soft")},
5672 {PTP_DPC_CANON_DriveMode, PTP_VENDOR_CANON, 0, N_("Single-Frame Shooting")},
5673 {PTP_DPC_CANON_DriveMode, PTP_VENDOR_CANON, 1, N_("Continuous Shooting")},
5674 {PTP_DPC_CANON_DriveMode, PTP_VENDOR_CANON, 2, N_("Timer (Single) Shooting")},
5675 {PTP_DPC_CANON_DriveMode, PTP_VENDOR_CANON, 4, N_("Continuous Low-speed Shooting")},
5676 {PTP_DPC_CANON_DriveMode, PTP_VENDOR_CANON, 5, N_("Continuous High-speed Shooting")},
5678 {PTP_DPC_CANON_EZoom, PTP_VENDOR_CANON, 0, N_("Off")},
5679 {PTP_DPC_CANON_EZoom, PTP_VENDOR_CANON, 1, N_("2x")},
5680 {PTP_DPC_CANON_EZoom, PTP_VENDOR_CANON, 2, N_("4x")},
5681 {PTP_DPC_CANON_EZoom, PTP_VENDOR_CANON, 3, N_("Smooth")},
5683 {PTP_DPC_CANON_MeteringMode, PTP_VENDOR_CANON, 0, N_("Center-weighted Metering")},
5684 {PTP_DPC_CANON_MeteringMode, PTP_VENDOR_CANON, 1, N_("Spot Metering")},
5685 {PTP_DPC_CANON_MeteringMode, PTP_VENDOR_CANON, 2, N_("Average Metering")},
5686 {PTP_DPC_CANON_MeteringMode, PTP_VENDOR_CANON, 3, N_("Evaluative Metering")},
5687 {PTP_DPC_CANON_MeteringMode, PTP_VENDOR_CANON, 4, N_("Partial Metering")},
5688 {PTP_DPC_CANON_MeteringMode, PTP_VENDOR_CANON, 5, N_("Center-weighted Average Metering")},
5689 {PTP_DPC_CANON_MeteringMode, PTP_VENDOR_CANON, 6, N_("Spot Metering Interlocked with AF Frame")},
5690 {PTP_DPC_CANON_MeteringMode, PTP_VENDOR_CANON, 7, N_("Multi-Spot Metering")},
5692 {PTP_DPC_CANON_AFDistance, PTP_VENDOR_CANON, 0, N_("Manual")},
5693 {PTP_DPC_CANON_AFDistance, PTP_VENDOR_CANON, 1, N_("Auto")},
5694 {PTP_DPC_CANON_AFDistance, PTP_VENDOR_CANON, 2, N_("Unknown")},
5695 {PTP_DPC_CANON_AFDistance, PTP_VENDOR_CANON, 3, N_("Zone Focus (Close-up)")},
5696 {PTP_DPC_CANON_AFDistance, PTP_VENDOR_CANON, 4, N_("Zone Focus (Very Close)")},
5697 {PTP_DPC_CANON_AFDistance, PTP_VENDOR_CANON, 5, N_("Zone Focus (Close)")},
5698 {PTP_DPC_CANON_AFDistance, PTP_VENDOR_CANON, 6, N_("Zone Focus (Medium)")},
5699 {PTP_DPC_CANON_AFDistance, PTP_VENDOR_CANON, 7, N_("Zone Focus (Far)")},
5701 {PTP_DPC_CANON_FocusingPoint, PTP_VENDOR_CANON, 0, N_("Invalid")},
5702 {PTP_DPC_CANON_FocusingPoint, PTP_VENDOR_CANON, 0x1000, N_("Focusing Point on Center Only, Manual")},
5703 {PTP_DPC_CANON_FocusingPoint, PTP_VENDOR_CANON, 0x1001, N_("Focusing Point on Center Only, Auto")},
5704 {PTP_DPC_CANON_FocusingPoint, PTP_VENDOR_CANON, 0x3000, N_("Multiple Focusing Points (No Specification), Manual")},
5705 {PTP_DPC_CANON_FocusingPoint, PTP_VENDOR_CANON, 0x3001, N_("Multiple Focusing Points, Auto")},
5706 {PTP_DPC_CANON_FocusingPoint, PTP_VENDOR_CANON, 0x3002, N_("Multiple Focusing Points (Right)")},
5707 {PTP_DPC_CANON_FocusingPoint, PTP_VENDOR_CANON, 0x3003, N_("Multiple Focusing Points (Center)")},
5708 {PTP_DPC_CANON_FocusingPoint, PTP_VENDOR_CANON, 0x3004, N_("Multiple Focusing Points (Left)")},
5710 {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 0, N_("Auto")},
5711 {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 1, N_("Daylight")},
5712 {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 2, N_("Cloudy")},
5713 {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 3, N_("Tungsten")},
5714 {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 4, N_("Fluorescent")},
5715 {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 6, N_("Preset")},
5716 {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 7, N_("Fluorescent H")},
5717 {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 9, N_("Color Temperature")},
5718 {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 10, N_("Custom Whitebalance PC-1")},
5719 {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 11, N_("Custom Whitebalance PC-2")},
5720 {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 12, N_("Custom Whitebalance PC-3")},
5721 {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 13, N_("Missing Number")},
5722 {PTP_DPC_CANON_WhiteBalance, PTP_VENDOR_CANON, 14, N_("Fluorescent H")}, /* dup? */
5724 {PTP_DPC_CANON_SlowShutterSetting, PTP_VENDOR_CANON, 0, N_("Off")},
5725 {PTP_DPC_CANON_SlowShutterSetting, PTP_VENDOR_CANON, 1, N_("Night View")},
5726 {PTP_DPC_CANON_SlowShutterSetting, PTP_VENDOR_CANON, 2, N_("On")},
5727 {PTP_DPC_CANON_SlowShutterSetting, PTP_VENDOR_CANON, 3, N_("Low-speed shutter function not available")},
5729 {PTP_DPC_CANON_AFMode, PTP_VENDOR_CANON, 0, N_("Single Shot")},
5730 {PTP_DPC_CANON_AFMode, PTP_VENDOR_CANON, 1, N_("AI Servo")},
5731 {PTP_DPC_CANON_AFMode, PTP_VENDOR_CANON, 2, N_("AI Focus")},
5732 {PTP_DPC_CANON_AFMode, PTP_VENDOR_CANON, 3, N_("Manual")},
5733 {PTP_DPC_CANON_AFMode, PTP_VENDOR_CANON, 4, N_("Continuous")},
5735 PTP_VENDOR_VAL_BOOL(PTP_DPC_CANON_ImageStabilization,PTP_VENDOR_CANON),
5737 {PTP_DPC_CANON_Contrast, PTP_VENDOR_CANON, -2, N_("Low 2")},
5738 {PTP_DPC_CANON_Contrast, PTP_VENDOR_CANON, -1, N_("Low")},
5739 {PTP_DPC_CANON_Contrast, PTP_VENDOR_CANON, 0, N_("Standard")},
5740 {PTP_DPC_CANON_Contrast, PTP_VENDOR_CANON, 1, N_("High")},
5741 {PTP_DPC_CANON_Contrast, PTP_VENDOR_CANON, 2, N_("High 2")},
5743 {PTP_DPC_CANON_ColorGain, PTP_VENDOR_CANON, -2, N_("Low 2")},
5744 {PTP_DPC_CANON_ColorGain, PTP_VENDOR_CANON, -1, N_("Low")},
5745 {PTP_DPC_CANON_ColorGain, PTP_VENDOR_CANON, 0, N_("Standard")},
5746 {PTP_DPC_CANON_ColorGain, PTP_VENDOR_CANON, 1, N_("High")},
5747 {PTP_DPC_CANON_ColorGain, PTP_VENDOR_CANON, 2, N_("High 2")},
5749 {PTP_DPC_CANON_Sharpness, PTP_VENDOR_CANON, -2, N_("Low 2")},
5750 {PTP_DPC_CANON_Sharpness, PTP_VENDOR_CANON, -1, N_("Low")},
5751 {PTP_DPC_CANON_Sharpness, PTP_VENDOR_CANON, 0, N_("Standard")},
5752 {PTP_DPC_CANON_Sharpness, PTP_VENDOR_CANON, 1, N_("High")},
5753 {PTP_DPC_CANON_Sharpness, PTP_VENDOR_CANON, 2, N_("High 2")},
5755 {PTP_DPC_CANON_Sensitivity, PTP_VENDOR_CANON, 0, N_("Standard")},
5756 {PTP_DPC_CANON_Sensitivity, PTP_VENDOR_CANON, 1, N_("Upper 1")},
5757 {PTP_DPC_CANON_Sensitivity, PTP_VENDOR_CANON, 2, N_("Upper 2")},
5759 {PTP_DPC_CANON_ParameterSet, PTP_VENDOR_CANON, 0x08, N_("Standard Development Parameters")},
5760 {PTP_DPC_CANON_ParameterSet, PTP_VENDOR_CANON, 0x10, N_("Development Parameters 1")},
5761 {PTP_DPC_CANON_ParameterSet, PTP_VENDOR_CANON, 0x20, N_("Development Parameters 2")},
5762 {PTP_DPC_CANON_ParameterSet, PTP_VENDOR_CANON, 0x40, N_("Development Parameters 3")},
5764 {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x00, N_("Auto")},
5765 {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x28, "6"},
5766 {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x30, "12"},
5767 {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x38, "25"},
5768 {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x40, "50"},
5769 {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x43, "64"},
5770 {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x48, "100"},
5771 {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x50, "200"},
5772 {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x58, "400"},
5773 {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x60, "800"},
5774 {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x68, "1600"},
5775 {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x70, "3200"},
5776 {PTP_DPC_CANON_ISOSpeed, PTP_VENDOR_CANON, 0x78, "6400"},
5778 /* 0xd01d - PTP_DPC_CANON_Aperture */
5779 /* 0xd01e - PTP_DPC_CANON_ShutterSpeed */
5780 /* 0xd01f - PTP_DPC_CANON_ExpCompensation */
5781 /* 0xd020 - PTP_DPC_CANON_FlashCompensation */
5782 /* 0xd021 - PTP_DPC_CANON_AEBExposureCompensation */
5783 /* 0xd023 - PTP_DPC_CANON_AvOpen */
5784 /* 0xd024 - PTP_DPC_CANON_AvMax */
5786 {PTP_DPC_CANON_CameraOutput, PTP_VENDOR_CANON, 0, N_("Undefined")},
5787 {PTP_DPC_CANON_CameraOutput, PTP_VENDOR_CANON, 1, N_("LCD")},
5788 {PTP_DPC_CANON_CameraOutput, PTP_VENDOR_CANON, 2, N_("Video OUT")},
5789 {PTP_DPC_CANON_CameraOutput, PTP_VENDOR_CANON, 3, N_("Off")},
5791 {PTP_DPC_CANON_MlSpotPos, PTP_VENDOR_CANON, 0, N_("MlSpotPosCenter")},
5792 {PTP_DPC_CANON_MlSpotPos, PTP_VENDOR_CANON, 1, N_("MlSpotPosAfLink")},
5794 {PTP_DPC_CANON_PhotoEffect, PTP_VENDOR_CANON, 0, N_("Off")},
5795 {PTP_DPC_CANON_PhotoEffect, PTP_VENDOR_CANON, 1, N_("Vivid")},
5796 {PTP_DPC_CANON_PhotoEffect, PTP_VENDOR_CANON, 2, N_("Neutral")},
5797 {PTP_DPC_CANON_PhotoEffect, PTP_VENDOR_CANON, 3, N_("Soft")},
5798 {PTP_DPC_CANON_PhotoEffect, PTP_VENDOR_CANON, 4, N_("Sepia")},
5799 {PTP_DPC_CANON_PhotoEffect, PTP_VENDOR_CANON, 5, N_("Monochrome")},
5803 for (i=0; ptp_value_trans[i].dpc!=0; i++) {
5804 if ((ptp_value_trans[i].dpc == dpc) &&
5805 (((ptp_value_trans[i].dpc & 0xf000) == 0x5000) ||
5806 (ptp_value_trans[i].vendor == params->deviceinfo.VendorExtensionID))
5808 double value = _value_to_num(&(dpd->CurrentValue), dpd->DataType);
5810 return snprintf(out, length,
5811 _(ptp_value_trans[i].format),
5812 value * ptp_value_trans[i].coef +
5813 ptp_value_trans[i].bias);
5817 kval = _value_to_num(&(dpd->CurrentValue), dpd->DataType);
5818 for (i=0; ptp_value_list[i].dpc!=0; i++) {
5819 if ((ptp_value_list[i].dpc == dpc) &&
5820 (((ptp_value_list[i].dpc & 0xf000) == 0x5000) ||
5821 (ptp_value_list[i].vendor == params->deviceinfo.VendorExtensionID)) &&
5822 (ptp_value_list[i].key==kval)
5824 return snprintf(out, length, "%s", _(ptp_value_list[i].value));
5827 if (params->deviceinfo.VendorExtensionID==PTP_VENDOR_MICROSOFT
5828 || params->deviceinfo.VendorExtensionID==PTP_VENDOR_MTP) {
5830 case PTP_DPC_MTP_SynchronizationPartner:
5831 case PTP_DPC_MTP_DeviceFriendlyName:
5832 return snprintf(out, length, "%s", dpd->CurrentValue.str);
5833 case PTP_DPC_MTP_SecureTime:
5834 case PTP_DPC_MTP_DeviceCertificate: {
5835 /* FIXME: Convert to use unicode demux functions */
5836 for (i=0;(i<dpd->CurrentValue.a.count) && (i<length);i++)
5837 out[i] = dpd->CurrentValue.a.v[i].u16;
5838 if ( dpd->CurrentValue.a.count &&
5839 (dpd->CurrentValue.a.count < length)) {
5840 out[dpd->CurrentValue.a.count-1] = 0;
5841 return dpd->CurrentValue.a.count-1;
5859 } ptp_ofc_trans[] = {
5860 {PTP_OFC_Undefined,"Undefined Type"},
5861 {PTP_OFC_Defined,"Defined Type"},
5862 {PTP_OFC_Association,"Association/Directory"},
5863 {PTP_OFC_Script,"Script"},
5864 {PTP_OFC_Executable,"Executable"},
5865 {PTP_OFC_Text,"Text"},
5866 {PTP_OFC_HTML,"HTML"},
5867 {PTP_OFC_DPOF,"DPOF"},
5868 {PTP_OFC_AIFF,"AIFF"},
5869 {PTP_OFC_WAV,"MS Wave"},
5870 {PTP_OFC_MP3,"MP3"},
5871 {PTP_OFC_AVI,"MS AVI"},
5872 {PTP_OFC_MPEG,"MPEG"},
5873 {PTP_OFC_ASF,"ASF"},
5874 {PTP_OFC_QT,"Apple Quicktime"},
5875 {PTP_OFC_EXIF_JPEG,"JPEG"},
5876 {PTP_OFC_TIFF_EP,"TIFF EP"},
5877 {PTP_OFC_FlashPix,"FlashPix"},
5878 {PTP_OFC_BMP,"BMP"},
5879 {PTP_OFC_CIFF,"CIFF"},
5880 {PTP_OFC_GIF,"GIF"},
5881 {PTP_OFC_JFIF,"JFIF"},
5882 {PTP_OFC_PCD,"PCD"},
5883 {PTP_OFC_PICT,"PICT"},
5884 {PTP_OFC_PNG,"PNG"},
5885 {PTP_OFC_TIFF,"TIFF"},
5886 {PTP_OFC_TIFF_IT,"TIFF_IT"},
5887 {PTP_OFC_JP2,"JP2"},
5888 {PTP_OFC_JPX,"JPX"},
5889 {PTP_OFC_DNG,"DNG"},
5895 } ptp_ofc_mtp_trans[] = {
5896 {PTP_OFC_MTP_MediaCard,N_("Media Card")},
5897 {PTP_OFC_MTP_MediaCardGroup,N_("Media Card Group")},
5898 {PTP_OFC_MTP_Encounter,N_("Encounter")},
5899 {PTP_OFC_MTP_EncounterBox,N_("Encounter Box")},
5900 {PTP_OFC_MTP_M4A,N_("M4A")},
5901 {PTP_OFC_MTP_Firmware,N_("Firmware")},
5902 {PTP_OFC_MTP_WindowsImageFormat,N_("Windows Image Format")},
5903 {PTP_OFC_MTP_UndefinedAudio,N_("Undefined Audio")},
5904 {PTP_OFC_MTP_WMA,"WMA"},
5905 {PTP_OFC_MTP_OGG,"OGG"},
5906 {PTP_OFC_MTP_AAC,"AAC"},
5907 {PTP_OFC_MTP_AudibleCodec,N_("Audible.com Codec")},
5908 {PTP_OFC_MTP_FLAC,"FLAC"},
5909 {PTP_OFC_MTP_SamsungPlaylist,N_("Samsung Playlist")},
5910 {PTP_OFC_MTP_UndefinedVideo,N_("Undefined Video")},
5911 {PTP_OFC_MTP_WMV,"WMV"},
5912 {PTP_OFC_MTP_MP4,"MP4"},
5913 {PTP_OFC_MTP_MP2,"MP2"},
5914 {PTP_OFC_MTP_3GP,"3GP"},
5915 {PTP_OFC_MTP_UndefinedCollection,N_("Undefined Collection")},
5916 {PTP_OFC_MTP_AbstractMultimediaAlbum,N_("Abstract Multimedia Album")},
5917 {PTP_OFC_MTP_AbstractImageAlbum,N_("Abstract Image Album")},
5918 {PTP_OFC_MTP_AbstractAudioAlbum,N_("Abstract Audio Album")},
5919 {PTP_OFC_MTP_AbstractVideoAlbum,N_("Abstract Video Album")},
5920 {PTP_OFC_MTP_AbstractAudioVideoPlaylist,N_("Abstract Audio Video Playlist")},
5921 {PTP_OFC_MTP_AbstractContactGroup,N_("Abstract Contact Group")},
5922 {PTP_OFC_MTP_AbstractMessageFolder,N_("Abstract Message Folder")},
5923 {PTP_OFC_MTP_AbstractChapteredProduction,N_("Abstract Chaptered Production")},
5924 {PTP_OFC_MTP_AbstractAudioPlaylist,N_("Abstract Audio Playlist")},
5925 {PTP_OFC_MTP_AbstractVideoPlaylist,N_("Abstract Video Playlist")},
5926 {PTP_OFC_MTP_AbstractMediacast,N_("Abstract Mediacast")},
5927 {PTP_OFC_MTP_WPLPlaylist,N_("WPL Playlist")},
5928 {PTP_OFC_MTP_M3UPlaylist,N_("M3U Playlist")},
5929 {PTP_OFC_MTP_MPLPlaylist,N_("MPL Playlist")},
5930 {PTP_OFC_MTP_ASXPlaylist,N_("ASX Playlist")},
5931 {PTP_OFC_MTP_PLSPlaylist,N_("PLS Playlist")},
5932 {PTP_OFC_MTP_UndefinedDocument,N_("Undefined Document")},
5933 {PTP_OFC_MTP_AbstractDocument,N_("Abstract Document")},
5934 {PTP_OFC_MTP_XMLDocument,N_("XMLDocument")},
5935 {PTP_OFC_MTP_MSWordDocument,N_("Microsoft Word Document")},
5936 {PTP_OFC_MTP_MHTCompiledHTMLDocument,N_("MHT Compiled HTML Document")},
5937 {PTP_OFC_MTP_MSExcelSpreadsheetXLS,N_("Microsoft Excel Spreadsheet (.xls)")},
5938 {PTP_OFC_MTP_MSPowerpointPresentationPPT,N_("Microsoft Powerpoint (.ppt)")},
5939 {PTP_OFC_MTP_UndefinedMessage,N_("Undefined Message")},
5940 {PTP_OFC_MTP_AbstractMessage,N_("Abstract Message")},
5941 {PTP_OFC_MTP_UndefinedContact,N_("Undefined Contact")},
5942 {PTP_OFC_MTP_AbstractContact,N_("Abstract Contact")},
5943 {PTP_OFC_MTP_vCard2,N_("vCard2")},
5944 {PTP_OFC_MTP_vCard3,N_("vCard3")},
5945 {PTP_OFC_MTP_UndefinedCalendarItem,N_("Undefined Calendar Item")},
5946 {PTP_OFC_MTP_AbstractCalendarItem,N_("Abstract Calendar Item")},
5947 {PTP_OFC_MTP_vCalendar1,N_("vCalendar1")},
5948 {PTP_OFC_MTP_vCalendar2,N_("vCalendar2")},
5949 {PTP_OFC_MTP_UndefinedWindowsExecutable,N_("Undefined Windows Executable")},
5950 {PTP_OFC_MTP_MediaCast,N_("Media Cast")},
5951 {PTP_OFC_MTP_Section,N_("Section")},
5955 ptp_render_ofc(PTPParams* params, uint16_t ofc, int spaceleft, char *txt)
5959 if (!(ofc & 0x8000)) {
5960 for (i=0;i<sizeof(ptp_ofc_trans)/sizeof(ptp_ofc_trans[0]);i++)
5961 if (ofc == ptp_ofc_trans[i].ofc)
5962 return snprintf(txt, spaceleft, "%s", _(ptp_ofc_trans[i].format));
5964 switch (params->deviceinfo.VendorExtensionID) {
5965 case PTP_VENDOR_EASTMAN_KODAK:
5967 case PTP_OFC_EK_M3U:
5968 return snprintf (txt, spaceleft,"M3U");
5973 case PTP_VENDOR_CANON:
5975 case PTP_OFC_CANON_CRW:
5976 return snprintf (txt, spaceleft,"CRW");
5981 case PTP_VENDOR_MICROSOFT:
5982 case PTP_VENDOR_MTP:
5983 for (i=0;i<sizeof(ptp_ofc_mtp_trans)/sizeof(ptp_ofc_mtp_trans[0]);i++)
5984 if (ofc == ptp_ofc_mtp_trans[i].ofc)
5985 return snprintf(txt, spaceleft, "%s", _(ptp_ofc_mtp_trans[i].format));
5990 return snprintf (txt, spaceleft,_("Unknown(%04x)"), ofc);
5996 } ptp_opcode_trans[] = {
5997 {PTP_OC_Undefined,N_("Undefined")},
5998 {PTP_OC_GetDeviceInfo,N_("get device info")},
5999 {PTP_OC_OpenSession,N_("Open session")},
6000 {PTP_OC_CloseSession,N_("Close session")},
6001 {PTP_OC_GetStorageIDs,N_("Get storage IDs")},
6002 {PTP_OC_GetStorageInfo,N_("Get storage info")},
6003 {PTP_OC_GetNumObjects,N_("Get number of objects")},
6004 {PTP_OC_GetObjectHandles,N_("Get object handles")},
6005 {PTP_OC_GetObjectInfo,N_("Get object info")},
6006 {PTP_OC_GetObject,N_("Get object")},
6007 {PTP_OC_GetThumb,N_("Get thumbnail")},
6008 {PTP_OC_DeleteObject,N_("Delete object")},
6009 {PTP_OC_SendObjectInfo,N_("Send object info")},
6010 {PTP_OC_SendObject,N_("Send object")},
6011 {PTP_OC_InitiateCapture,N_("Initiate capture")},
6012 {PTP_OC_FormatStore,N_("Format storage")},
6013 {PTP_OC_ResetDevice,N_("Reset device")},
6014 {PTP_OC_SelfTest,N_("Self test device")},
6015 {PTP_OC_SetObjectProtection,N_("Set object protection")},
6016 {PTP_OC_PowerDown,N_("Power down device")},
6017 {PTP_OC_GetDevicePropDesc,N_("Get device property description")},
6018 {PTP_OC_GetDevicePropValue,N_("Get device property value")},
6019 {PTP_OC_SetDevicePropValue,N_("Set device property value")},
6020 {PTP_OC_ResetDevicePropValue,N_("Reset device property value")},
6021 {PTP_OC_TerminateOpenCapture,N_("Terminate open capture")},
6022 {PTP_OC_MoveObject,N_("Move object")},
6023 {PTP_OC_CopyObject,N_("Copy object")},
6024 {PTP_OC_GetPartialObject,N_("Get partial object")},
6025 {PTP_OC_InitiateOpenCapture,N_("Initiate open capture")}
6031 } ptp_opcode_mtp_trans[] = {
6032 {PTP_OC_MTP_GetObjectPropsSupported,N_("Get object properties supported")},
6033 {PTP_OC_MTP_GetObjectPropDesc,N_("Get object property description")},
6034 {PTP_OC_MTP_GetObjectPropValue,N_("Get object property value")},
6035 {PTP_OC_MTP_SetObjectPropValue,N_("Set object property value")},
6036 {PTP_OC_MTP_GetObjPropList,N_("Get object property list")},
6037 {PTP_OC_MTP_SetObjPropList,N_("Set object property list")},
6038 {PTP_OC_MTP_GetInterdependendPropdesc,N_("Get interdependent property description")},
6039 {PTP_OC_MTP_SendObjectPropList,N_("Send object property list")},
6040 {PTP_OC_MTP_GetObjectReferences,N_("Get object references")},
6041 {PTP_OC_MTP_SetObjectReferences,N_("Set object references")},
6042 {PTP_OC_MTP_UpdateDeviceFirmware,N_("Update device firmware")},
6043 {PTP_OC_MTP_Skip,N_("Skip to next position in playlist")},
6045 /* WMDRMPD Extensions */
6046 {PTP_OC_MTP_WMDRMPD_GetSecureTimeChallenge,N_("Get secure time challenge")},
6047 {PTP_OC_MTP_WMDRMPD_GetSecureTimeResponse,N_("Get secure time response")},
6048 {PTP_OC_MTP_WMDRMPD_SetLicenseResponse,N_("Set license response")},
6049 {PTP_OC_MTP_WMDRMPD_GetSyncList,N_("Get sync list")},
6050 {PTP_OC_MTP_WMDRMPD_SendMeterChallengeQuery,N_("Send meter challenge query")},
6051 {PTP_OC_MTP_WMDRMPD_GetMeterChallenge,N_("Get meter challenge")},
6052 {PTP_OC_MTP_WMDRMPD_SetMeterResponse,N_("Get meter response")},
6053 {PTP_OC_MTP_WMDRMPD_CleanDataStore,N_("Clean data store")},
6054 {PTP_OC_MTP_WMDRMPD_GetLicenseState,N_("Get license state")},
6055 {PTP_OC_MTP_WMDRMPD_SendWMDRMPDCommand,N_("Send WMDRM-PD Command")},
6056 {PTP_OC_MTP_WMDRMPD_SendWMDRMPDRequest,N_("Send WMDRM-PD Request")},
6058 /* WMPPD Extensions */
6059 {PTP_OC_MTP_WMPPD_ReportAddedDeletedItems,N_("Report Added/Deleted Items")},
6060 {PTP_OC_MTP_WMPPD_ReportAcquiredItems,N_("Report Acquired Items")},
6061 {PTP_OC_MTP_WMPPD_PlaylistObjectPref,N_("Get transferable playlist types")},
6063 /* WMDRMPD Extensions... these have no identifiers associated with them */
6064 {PTP_OC_MTP_WMDRMPD_SendWMDRMPDAppRequest,N_("Send WMDRM-PD Application Request")},
6065 {PTP_OC_MTP_WMDRMPD_GetWMDRMPDAppResponse,N_("Get WMDRM-PD Application Response")},
6066 {PTP_OC_MTP_WMDRMPD_EnableTrustedFilesOperations,N_("Enable trusted file operations")},
6067 {PTP_OC_MTP_WMDRMPD_DisableTrustedFilesOperations,N_("Disable trusted file operations")},
6068 {PTP_OC_MTP_WMDRMPD_EndTrustedAppSession,N_("End trusted application session")},
6070 /* AAVT Extensions */
6071 {PTP_OC_MTP_AAVT_OpenMediaSession,N_("Open Media Session")},
6072 {PTP_OC_MTP_AAVT_CloseMediaSession,N_("Close Media Session")},
6073 {PTP_OC_MTP_AAVT_GetNextDataBlock,N_("Get Next Data Block")},
6074 {PTP_OC_MTP_AAVT_SetCurrentTimePosition,N_("Set Current Time Position")},
6076 /* WMDRMND Extensions */
6077 {PTP_OC_MTP_WMDRMND_SendRegistrationRequest,N_("Send Registration Request")},
6078 {PTP_OC_MTP_WMDRMND_GetRegistrationResponse,N_("Get Registration Response")},
6079 {PTP_OC_MTP_WMDRMND_GetProximityChallenge,N_("Get Proximity Challenge")},
6080 {PTP_OC_MTP_WMDRMND_SendProximityResponse,N_("Send Proximity Response")},
6081 {PTP_OC_MTP_WMDRMND_SendWMDRMNDLicenseRequest,N_("Send WMDRM-ND License Request")},
6082 {PTP_OC_MTP_WMDRMND_GetWMDRMNDLicenseResponse,N_("Get WMDRM-ND License Response")},
6084 /* WiFi Provisioning MTP Extension Codes (microsoft.com/WPDWCN: 1.0) */
6085 {PTP_OC_MTP_WPDWCN_ProcessWFCObject,N_("Process WFC Object")},
6087 /* Android Direct I/O Extensions */
6088 {PTP_OC_ANDROID_GetPartialObject64,N_("Get Partial Object (64bit Offset)")},
6089 {PTP_OC_ANDROID_SendPartialObject,N_("Send Partial Object")},
6090 {PTP_OC_ANDROID_TruncateObject,N_("Truncate Object")},
6091 {PTP_OC_ANDROID_BeginEditObject,N_("Begin Edit Object")},
6092 {PTP_OC_ANDROID_EndEditObject,N_("End Edit Object")},
6096 ptp_render_opcode(PTPParams* params, uint16_t opcode, int spaceleft, char *txt)
6100 if (!(opcode & 0x8000)) {
6101 for (i=0;i<sizeof(ptp_opcode_trans)/sizeof(ptp_opcode_trans[0]);i++)
6102 if (opcode == ptp_opcode_trans[i].opcode)
6103 return snprintf(txt, spaceleft, "%s", _(ptp_opcode_trans[i].name));
6105 switch (params->deviceinfo.VendorExtensionID) {
6106 case PTP_VENDOR_MICROSOFT:
6107 case PTP_VENDOR_MTP:
6108 for (i=0;i<sizeof(ptp_opcode_mtp_trans)/sizeof(ptp_opcode_mtp_trans[0]);i++)
6109 if (opcode == ptp_opcode_mtp_trans[i].opcode)
6110 return snprintf(txt, spaceleft, "%s", _(ptp_opcode_mtp_trans[i].name));
6115 return snprintf (txt, spaceleft,_("Unknown (%04x)"), opcode);
6122 } ptp_opc_trans[] = {
6123 {PTP_OPC_StorageID,"StorageID"},
6124 {PTP_OPC_ObjectFormat,"ObjectFormat"},
6125 {PTP_OPC_ProtectionStatus,"ProtectionStatus"},
6126 {PTP_OPC_ObjectSize,"ObjectSize"},
6127 {PTP_OPC_AssociationType,"AssociationType"},
6128 {PTP_OPC_AssociationDesc,"AssociationDesc"},
6129 {PTP_OPC_ObjectFileName,"ObjectFileName"},
6130 {PTP_OPC_DateCreated,"DateCreated"},
6131 {PTP_OPC_DateModified,"DateModified"},
6132 {PTP_OPC_Keywords,"Keywords"},
6133 {PTP_OPC_ParentObject,"ParentObject"},
6134 {PTP_OPC_AllowedFolderContents,"AllowedFolderContents"},
6135 {PTP_OPC_Hidden,"Hidden"},
6136 {PTP_OPC_SystemObject,"SystemObject"},
6137 {PTP_OPC_PersistantUniqueObjectIdentifier,"PersistantUniqueObjectIdentifier"},
6138 {PTP_OPC_SyncID,"SyncID"},
6139 {PTP_OPC_PropertyBag,"PropertyBag"},
6140 {PTP_OPC_Name,"Name"},
6141 {PTP_OPC_CreatedBy,"CreatedBy"},
6142 {PTP_OPC_Artist,"Artist"},
6143 {PTP_OPC_DateAuthored,"DateAuthored"},
6144 {PTP_OPC_Description,"Description"},
6145 {PTP_OPC_URLReference,"URLReference"},
6146 {PTP_OPC_LanguageLocale,"LanguageLocale"},
6147 {PTP_OPC_CopyrightInformation,"CopyrightInformation"},
6148 {PTP_OPC_Source,"Source"},
6149 {PTP_OPC_OriginLocation,"OriginLocation"},
6150 {PTP_OPC_DateAdded,"DateAdded"},
6151 {PTP_OPC_NonConsumable,"NonConsumable"},
6152 {PTP_OPC_CorruptOrUnplayable,"CorruptOrUnplayable"},
6153 {PTP_OPC_ProducerSerialNumber,"ProducerSerialNumber"},
6154 {PTP_OPC_RepresentativeSampleFormat,"RepresentativeSampleFormat"},
6155 {PTP_OPC_RepresentativeSampleSize,"RepresentativeSampleSize"},
6156 {PTP_OPC_RepresentativeSampleHeight,"RepresentativeSampleHeight"},
6157 {PTP_OPC_RepresentativeSampleWidth,"RepresentativeSampleWidth"},
6158 {PTP_OPC_RepresentativeSampleDuration,"RepresentativeSampleDuration"},
6159 {PTP_OPC_RepresentativeSampleData,"RepresentativeSampleData"},
6160 {PTP_OPC_Width,"Width"},
6161 {PTP_OPC_Height,"Height"},
6162 {PTP_OPC_Duration,"Duration"},
6163 {PTP_OPC_Rating,"Rating"},
6164 {PTP_OPC_Track,"Track"},
6165 {PTP_OPC_Genre,"Genre"},
6166 {PTP_OPC_Credits,"Credits"},
6167 {PTP_OPC_Lyrics,"Lyrics"},
6168 {PTP_OPC_SubscriptionContentID,"SubscriptionContentID"},
6169 {PTP_OPC_ProducedBy,"ProducedBy"},
6170 {PTP_OPC_UseCount,"UseCount"},
6171 {PTP_OPC_SkipCount,"SkipCount"},
6172 {PTP_OPC_LastAccessed,"LastAccessed"},
6173 {PTP_OPC_ParentalRating,"ParentalRating"},
6174 {PTP_OPC_MetaGenre,"MetaGenre"},
6175 {PTP_OPC_Composer,"Composer"},
6176 {PTP_OPC_EffectiveRating,"EffectiveRating"},
6177 {PTP_OPC_Subtitle,"Subtitle"},
6178 {PTP_OPC_OriginalReleaseDate,"OriginalReleaseDate"},
6179 {PTP_OPC_AlbumName,"AlbumName"},
6180 {PTP_OPC_AlbumArtist,"AlbumArtist"},
6181 {PTP_OPC_Mood,"Mood"},
6182 {PTP_OPC_DRMStatus,"DRMStatus"},
6183 {PTP_OPC_SubDescription,"SubDescription"},
6184 {PTP_OPC_IsCropped,"IsCropped"},
6185 {PTP_OPC_IsColorCorrected,"IsColorCorrected"},
6186 {PTP_OPC_ImageBitDepth,"ImageBitDepth"},
6187 {PTP_OPC_Fnumber,"Fnumber"},
6188 {PTP_OPC_ExposureTime,"ExposureTime"},
6189 {PTP_OPC_ExposureIndex,"ExposureIndex"},
6190 {PTP_OPC_DisplayName,"DisplayName"},
6191 {PTP_OPC_BodyText,"BodyText"},
6192 {PTP_OPC_Subject,"Subject"},
6193 {PTP_OPC_Priority,"Priority"},
6194 {PTP_OPC_GivenName,"GivenName"},
6195 {PTP_OPC_MiddleNames,"MiddleNames"},
6196 {PTP_OPC_FamilyName,"FamilyName"},
6198 {PTP_OPC_Prefix,"Prefix"},
6199 {PTP_OPC_Suffix,"Suffix"},
6200 {PTP_OPC_PhoneticGivenName,"PhoneticGivenName"},
6201 {PTP_OPC_PhoneticFamilyName,"PhoneticFamilyName"},
6202 {PTP_OPC_EmailPrimary,"EmailPrimary"},
6203 {PTP_OPC_EmailPersonal1,"EmailPersonal1"},
6204 {PTP_OPC_EmailPersonal2,"EmailPersonal2"},
6205 {PTP_OPC_EmailBusiness1,"EmailBusiness1"},
6206 {PTP_OPC_EmailBusiness2,"EmailBusiness2"},
6207 {PTP_OPC_EmailOthers,"EmailOthers"},
6208 {PTP_OPC_PhoneNumberPrimary,"PhoneNumberPrimary"},
6209 {PTP_OPC_PhoneNumberPersonal,"PhoneNumberPersonal"},
6210 {PTP_OPC_PhoneNumberPersonal2,"PhoneNumberPersonal2"},
6211 {PTP_OPC_PhoneNumberBusiness,"PhoneNumberBusiness"},
6212 {PTP_OPC_PhoneNumberBusiness2,"PhoneNumberBusiness2"},
6213 {PTP_OPC_PhoneNumberMobile,"PhoneNumberMobile"},
6214 {PTP_OPC_PhoneNumberMobile2,"PhoneNumberMobile2"},
6215 {PTP_OPC_FaxNumberPrimary,"FaxNumberPrimary"},
6216 {PTP_OPC_FaxNumberPersonal,"FaxNumberPersonal"},
6217 {PTP_OPC_FaxNumberBusiness,"FaxNumberBusiness"},
6218 {PTP_OPC_PagerNumber,"PagerNumber"},
6219 {PTP_OPC_PhoneNumberOthers,"PhoneNumberOthers"},
6220 {PTP_OPC_PrimaryWebAddress,"PrimaryWebAddress"},
6221 {PTP_OPC_PersonalWebAddress,"PersonalWebAddress"},
6222 {PTP_OPC_BusinessWebAddress,"BusinessWebAddress"},
6223 {PTP_OPC_InstantMessengerAddress,"InstantMessengerAddress"},
6224 {PTP_OPC_InstantMessengerAddress2,"InstantMessengerAddress2"},
6225 {PTP_OPC_InstantMessengerAddress3,"InstantMessengerAddress3"},
6226 {PTP_OPC_PostalAddressPersonalFull,"PostalAddressPersonalFull"},
6227 {PTP_OPC_PostalAddressPersonalFullLine1,"PostalAddressPersonalFullLine1"},
6228 {PTP_OPC_PostalAddressPersonalFullLine2,"PostalAddressPersonalFullLine2"},
6229 {PTP_OPC_PostalAddressPersonalFullCity,"PostalAddressPersonalFullCity"},
6230 {PTP_OPC_PostalAddressPersonalFullRegion,"PostalAddressPersonalFullRegion"},
6231 {PTP_OPC_PostalAddressPersonalFullPostalCode,"PostalAddressPersonalFullPostalCode"},
6232 {PTP_OPC_PostalAddressPersonalFullCountry,"PostalAddressPersonalFullCountry"},
6233 {PTP_OPC_PostalAddressBusinessFull,"PostalAddressBusinessFull"},
6234 {PTP_OPC_PostalAddressBusinessLine1,"PostalAddressBusinessLine1"},
6235 {PTP_OPC_PostalAddressBusinessLine2,"PostalAddressBusinessLine2"},
6236 {PTP_OPC_PostalAddressBusinessCity,"PostalAddressBusinessCity"},
6237 {PTP_OPC_PostalAddressBusinessRegion,"PostalAddressBusinessRegion"},
6238 {PTP_OPC_PostalAddressBusinessPostalCode,"PostalAddressBusinessPostalCode"},
6239 {PTP_OPC_PostalAddressBusinessCountry,"PostalAddressBusinessCountry"},
6240 {PTP_OPC_PostalAddressOtherFull,"PostalAddressOtherFull"},
6241 {PTP_OPC_PostalAddressOtherLine1,"PostalAddressOtherLine1"},
6242 {PTP_OPC_PostalAddressOtherLine2,"PostalAddressOtherLine2"},
6243 {PTP_OPC_PostalAddressOtherCity,"PostalAddressOtherCity"},
6244 {PTP_OPC_PostalAddressOtherRegion,"PostalAddressOtherRegion"},
6245 {PTP_OPC_PostalAddressOtherPostalCode,"PostalAddressOtherPostalCode"},
6246 {PTP_OPC_PostalAddressOtherCountry,"PostalAddressOtherCountry"},
6247 {PTP_OPC_OrganizationName,"OrganizationName"},
6248 {PTP_OPC_PhoneticOrganizationName,"PhoneticOrganizationName"},
6249 {PTP_OPC_Role,"Role"},
6250 {PTP_OPC_Birthdate,"Birthdate"},
6251 {PTP_OPC_MessageTo,"MessageTo"},
6252 {PTP_OPC_MessageCC,"MessageCC"},
6253 {PTP_OPC_MessageBCC,"MessageBCC"},
6254 {PTP_OPC_MessageRead,"MessageRead"},
6255 {PTP_OPC_MessageReceivedTime,"MessageReceivedTime"},
6256 {PTP_OPC_MessageSender,"MessageSender"},
6257 {PTP_OPC_ActivityBeginTime,"ActivityBeginTime"},
6258 {PTP_OPC_ActivityEndTime,"ActivityEndTime"},
6259 {PTP_OPC_ActivityLocation,"ActivityLocation"},
6260 {PTP_OPC_ActivityRequiredAttendees,"ActivityRequiredAttendees"},
6261 {PTP_OPC_ActivityOptionalAttendees,"ActivityOptionalAttendees"},
6262 {PTP_OPC_ActivityResources,"ActivityResources"},
6263 {PTP_OPC_ActivityAccepted,"ActivityAccepted"},
6264 {PTP_OPC_Owner,"Owner"},
6265 {PTP_OPC_Editor,"Editor"},
6266 {PTP_OPC_Webmaster,"Webmaster"},
6267 {PTP_OPC_URLSource,"URLSource"},
6268 {PTP_OPC_URLDestination,"URLDestination"},
6269 {PTP_OPC_TimeBookmark,"TimeBookmark"},
6270 {PTP_OPC_ObjectBookmark,"ObjectBookmark"},
6271 {PTP_OPC_ByteBookmark,"ByteBookmark"},
6272 {PTP_OPC_LastBuildDate,"LastBuildDate"},
6273 {PTP_OPC_TimetoLive,"TimetoLive"},
6274 {PTP_OPC_MediaGUID,"MediaGUID"},
6275 {PTP_OPC_TotalBitRate,"TotalBitRate"},
6276 {PTP_OPC_BitRateType,"BitRateType"},
6277 {PTP_OPC_SampleRate,"SampleRate"},
6278 {PTP_OPC_NumberOfChannels,"NumberOfChannels"},
6279 {PTP_OPC_AudioBitDepth,"AudioBitDepth"},
6280 {PTP_OPC_ScanDepth,"ScanDepth"},
6281 {PTP_OPC_AudioWAVECodec,"AudioWAVECodec"},
6282 {PTP_OPC_AudioBitRate,"AudioBitRate"},
6283 {PTP_OPC_VideoFourCCCodec,"VideoFourCCCodec"},
6284 {PTP_OPC_VideoBitRate,"VideoBitRate"},
6285 {PTP_OPC_FramesPerThousandSeconds,"FramesPerThousandSeconds"},
6286 {PTP_OPC_KeyFrameDistance,"KeyFrameDistance"},
6287 {PTP_OPC_BufferSize,"BufferSize"},
6288 {PTP_OPC_EncodingQuality,"EncodingQuality"},
6289 {PTP_OPC_EncodingProfile,"EncodingProfile"},
6290 {PTP_OPC_BuyFlag,"BuyFlag"},
6294 ptp_render_mtp_propname(uint16_t propid, int spaceleft, char *txt) {
6296 for (i=0;i<sizeof(ptp_opc_trans)/sizeof(ptp_opc_trans[0]);i++)
6297 if (propid == ptp_opc_trans[i].id)
6298 return snprintf(txt, spaceleft, "%s", ptp_opc_trans[i].name);
6299 return snprintf (txt, spaceleft,"unknown(%04x)", propid);
6303 * Allocate and default-initialize a few object properties.
6306 ptp_get_new_object_prop_entry(MTPProperties **props, int *nrofprops) {
6307 MTPProperties *newprops;
6308 MTPProperties *prop;
6310 if (*props == NULL) {
6311 newprops = malloc(sizeof(MTPProperties)*(*nrofprops+1));
6313 newprops = realloc(*props,sizeof(MTPProperties)*(*nrofprops+1));
6315 if (newprops == NULL)
6317 prop = &newprops[*nrofprops];
6318 prop->property = PTP_OPC_StorageID; /* Should be "unknown" */
6319 prop->datatype = PTP_DTC_UNDEF;
6320 prop->ObjectHandle = 0x00000000U;
6321 prop->propval.str = NULL;
6323 (*props) = newprops;
6329 ptp_destroy_object_prop(MTPProperties *prop)
6334 if (prop->datatype == PTP_DTC_STR && prop->propval.str != NULL)
6335 free(prop->propval.str);
6336 else if ((prop->datatype == PTP_DTC_AINT8 || prop->datatype == PTP_DTC_AINT16 ||
6337 prop->datatype == PTP_DTC_AINT32 || prop->datatype == PTP_DTC_AINT64 || prop->datatype == PTP_DTC_AINT128 ||
6338 prop->datatype == PTP_DTC_AUINT8 || prop->datatype == PTP_DTC_AUINT16 ||
6339 prop->datatype == PTP_DTC_AUINT32 || prop->datatype == PTP_DTC_AUINT64 || prop->datatype == PTP_DTC_AUINT128)
6340 && prop->propval.a.v != NULL)
6341 free(prop->propval.a.v);
6345 ptp_destroy_object_prop_list(MTPProperties *props, int nrofprops)
6348 MTPProperties *prop = props;
6350 for (i=0;i<nrofprops;i++,prop++)
6351 ptp_destroy_object_prop(prop);
6356 * Find a certain object property in the cache, i.e. a certain metadata
6357 * item for a certain object handle.
6360 ptp_find_object_prop_in_cache(PTPParams *params, uint32_t const handle, uint32_t const attribute_id)
6363 MTPProperties *prop;
6367 ret = ptp_object_find (params, handle, &ob);
6368 if (ret != PTP_RC_OK)
6370 prop = ob->mtpprops;
6371 for (i=0;i<ob->nrofmtpprops;i++) {
6372 if (attribute_id == prop->property)
6380 ptp_remove_object_from_cache(PTPParams *params, uint32_t handle)
6386 ret = ptp_object_find (params, handle, &ob);
6387 if (ret != PTP_RC_OK)
6389 i = ob-params->objects;
6390 /* remove object from object info cache */
6391 ptp_free_object (ob);
6393 if (i < params->nrofobjects-1)
6394 memmove (ob,ob+1,(params->nrofobjects-1-i)*sizeof(PTPObject));
6395 params->nrofobjects--;
6396 /* We use less memory than before so this shouldn't fail */
6397 params->objects = realloc(params->objects, sizeof(PTPObject)*params->nrofobjects);
6400 static int _cmp_ob (const void *a, const void *b) {
6401 PTPObject *oa = (PTPObject*)a;
6402 PTPObject *ob = (PTPObject*)b;
6404 return oa->oid - ob->oid;
6408 ptp_objects_sort (PTPParams *params) {
6409 qsort (params->objects, params->nrofobjects, sizeof(PTPObject), _cmp_ob);
6412 /* Binary search in objects. Needs "objects" to be a sorted by objectid list! */
6414 ptp_object_find (PTPParams *params, uint32_t handle, PTPObject **retob) {
6418 *retob = bsearch (&tmpob, params->objects, params->nrofobjects, sizeof(tmpob), _cmp_ob);
6420 return PTP_RC_GeneralError;
6424 /* Binary search in objects + insert of not found. Needs "objects" to be a sorted by objectid list! */
6426 ptp_object_find_or_insert (PTPParams *params, uint32_t handle, PTPObject **retob) {
6427 unsigned int begin, end, cursor;
6428 unsigned int insertat;
6431 if (!handle) return PTP_RC_GeneralError;
6433 if (!params->nrofobjects) {
6434 params->objects = calloc(1,sizeof(PTPObject));
6435 params->nrofobjects = 1;
6436 params->objects[0].oid = handle;
6437 *retob = ¶ms->objects[0];
6441 end = params->nrofobjects-1;
6442 /*ptp_debug (params, "searching %08x, total=%d", handle, params->nrofobjects);*/
6444 cursor = (end-begin)/2+begin;
6445 /*ptp_debug (params, "ob %d: %08x [%d-%d]", cursor, params->objects[cursor].oid, begin, end);*/
6446 if (params->objects[cursor].oid == handle) {
6447 *retob = ¶ms->objects[cursor];
6450 if (params->objects[cursor].oid < handle)
6454 if ((end - begin) <= 1)
6457 if (params->objects[begin].oid == handle) {
6458 *retob = ¶ms->objects[begin];
6461 if (params->objects[end].oid == handle) {
6462 *retob = ¶ms->objects[end];
6465 if ((begin == 0) && (handle < params->objects[0].oid)) {
6468 if ((end == params->nrofobjects-1) && (handle > params->objects[end].oid))
6473 /*ptp_debug (params, "inserting oid %x at [%x,%x], begin=%d, end=%d, insertat=%d\n", handle, params->objects[begin].oid, params->objects[end].oid, begin, end, insertat);*/
6474 newobs = realloc (params->objects, sizeof(PTPObject)*(params->nrofobjects+1));
6475 if (!newobs) return PTP_RC_GeneralError;
6476 params->objects = newobs;
6477 if (insertat<params->nrofobjects)
6478 memmove (¶ms->objects[insertat+1],¶ms->objects[insertat],(params->nrofobjects-insertat)*sizeof(PTPObject));
6479 memset(¶ms->objects[insertat],0,sizeof(PTPObject));
6480 params->objects[insertat].oid = handle;
6481 *retob = ¶ms->objects[insertat];
6482 params->nrofobjects++;
6487 ptp_object_want (PTPParams *params, uint32_t handle, unsigned int want, PTPObject **retob) {
6490 /*Camera *camera = ((PTPData *)params->data)->camera;*/
6492 /* If GetObjectInfo is broken, force GetPropList */
6493 if (params->device_flags & DEVICE_FLAG_PROPLIST_OVERRIDES_OI)
6494 want |= PTPOBJECT_MTPPROPLIST_LOADED;
6498 ptp_debug (params, "ptp_object_want: querying handle 0?\n");
6499 return PTP_RC_GeneralError;
6501 ret = ptp_object_find_or_insert (params, handle, &ob);
6502 if (ret != PTP_RC_OK)
6503 return PTP_RC_GeneralError;
6505 /* Do we have all of it already? */
6506 if ((ob->flags & want) == want)
6509 #define X (PTPOBJECT_OBJECTINFO_LOADED|PTPOBJECT_STORAGEID_LOADED|PTPOBJECT_PARENTOBJECT_LOADED)
6510 if ((want & X) && ((ob->flags & X) != X)) {
6511 uint32_t saveparent = 0;
6513 /* One EOS issue, where getobjecthandles(root) returns obs without root flag. */
6514 if (ob->flags & PTPOBJECT_PARENTOBJECT_LOADED)
6515 saveparent = ob->oi.ParentObject;
6517 ret = ptp_getobjectinfo (params, handle, &ob->oi);
6518 if (ret != PTP_RC_OK) {
6519 /* kill it from the internal list ... */
6520 ptp_remove_object_from_cache(params, handle);
6523 if (!ob->oi.Filename) ob->oi.Filename=strdup("<none>");
6524 if (ob->flags & PTPOBJECT_PARENTOBJECT_LOADED)
6525 ob->oi.ParentObject = saveparent;
6527 /* Second EOS issue, 0x20000000 has 0x20000000 as parent */
6528 if (ob->oi.ParentObject == handle)
6529 ob->oi.ParentObject = 0;
6531 /* Read out the canon special flags */
6532 if ((params->deviceinfo.VendorExtensionID == PTP_VENDOR_CANON) &&
6533 ptp_operation_issupported(params,PTP_OC_CANON_GetObjectInfoEx)) {
6534 PTPCANONFolderEntry *ents = NULL;
6535 uint32_t numents = 0;
6537 ret = ptp_canon_getobjectinfo(params,
6539 ob->oi.ParentObject,handle,
6542 if ((ret == PTP_RC_OK) && (numents >= 1))
6543 ob->canon_flags = ents[0].Flags;
6550 if ( (want & PTPOBJECT_MTPPROPLIST_LOADED) &&
6551 (!(ob->flags & PTPOBJECT_MTPPROPLIST_LOADED))
6554 MTPProperties *props = NULL;
6556 if (params->device_flags & DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST) {
6557 want &= ~PTPOBJECT_MTPPROPLIST_LOADED;
6560 /* Microsoft/MTP has fast directory retrieval. */
6561 if (!ptp_operation_issupported(params,PTP_OC_MTP_GetObjPropList)) {
6562 want &= ~PTPOBJECT_MTPPROPLIST_LOADED;
6566 ptp_debug (params, "ptp2/mtpfast: reading mtp proplist of %08x", handle);
6567 /* We just want this one object, not all at once. */
6568 ret = ptp_mtp_getobjectproplist_single (params, handle, &props, &nrofprops);
6569 if (ret != PTP_RC_OK)
6571 ob->mtpprops = props;
6572 ob->nrofmtpprops = nrofprops;
6574 /* Override the ObjectInfo data with data from properties */
6575 if (params->device_flags & DEVICE_FLAG_PROPLIST_OVERRIDES_OI) {
6577 MTPProperties *prop = ob->mtpprops;
6579 for (i=0;i<ob->nrofmtpprops;i++,prop++) {
6580 /* in case we got all subtree objects */
6581 if (prop->ObjectHandle != handle) continue;
6583 switch (prop->property) {
6584 case PTP_OPC_StorageID:
6585 ob->oi.StorageID = prop->propval.u32;
6587 case PTP_OPC_ObjectFormat:
6588 ob->oi.ObjectFormat = prop->propval.u16;
6590 case PTP_OPC_ProtectionStatus:
6591 ob->oi.ProtectionStatus = prop->propval.u16;
6593 case PTP_OPC_ObjectSize:
6594 if (prop->datatype == PTP_DTC_UINT64) {
6595 if (prop->propval.u64 > 0xFFFFFFFFU)
6596 ob->oi.ObjectCompressedSize = 0xFFFFFFFFU;
6598 ob->oi.ObjectCompressedSize = (uint32_t)prop->propval.u64;
6599 } else if (prop->datatype == PTP_DTC_UINT32) {
6600 ob->oi.ObjectCompressedSize = prop->propval.u32;
6603 case PTP_OPC_AssociationType:
6604 ob->oi.AssociationType = prop->propval.u16;
6606 case PTP_OPC_AssociationDesc:
6607 ob->oi.AssociationDesc = prop->propval.u32;
6609 case PTP_OPC_ObjectFileName:
6610 if (prop->propval.str) {
6611 free(ob->oi.Filename);
6612 ob->oi.Filename = strdup(prop->propval.str);
6615 case PTP_OPC_DateCreated:
6616 ob->oi.CaptureDate = ptp_unpack_PTPTIME(prop->propval.str);
6618 case PTP_OPC_DateModified:
6619 ob->oi.ModificationDate = ptp_unpack_PTPTIME(prop->propval.str);
6621 case PTP_OPC_Keywords:
6622 if (prop->propval.str) {
6623 free(ob->oi.Keywords);
6624 ob->oi.Keywords = strdup(prop->propval.str);
6627 case PTP_OPC_ParentObject:
6628 ob->oi.ParentObject = prop->propval.u32;
6637 PTPObjectInfo oinfo;
6639 memset (&oinfo,0,sizeof(oinfo));
6640 /* hmm, not necessary ... only if we would use it */
6641 for (j=0;j<nrofprops;j++) {
6643 switch (xpl->property) {
6644 case PTP_OPC_ParentObject:
6645 if (xpl->datatype != PTP_DTC_UINT32) {
6646 ptp_debug (params, "ptp2/mtpfast: parentobject has type 0x%x???", xpl->datatype);
6649 oinfo.ParentObject = xpl->propval.u32;
6650 ptp_debug (params, "ptp2/mtpfast: parent 0x%x", xpl->propval.u32);
6652 case PTP_OPC_ObjectFormat:
6653 if (xpl->datatype != PTP_DTC_UINT16) {
6654 ptp_debug (params, "ptp2/mtpfast: objectformat has type 0x%x???", xpl->datatype);
6657 oinfo.ObjectFormat = xpl->propval.u16;
6658 ptp_debug (params, "ptp2/mtpfast: ofc 0x%x", xpl->propval.u16);
6660 case PTP_OPC_ObjectSize:
6661 switch (xpl->datatype) {
6662 case PTP_DTC_UINT32:
6663 oinfo.ObjectCompressedSize = xpl->propval.u32;
6665 case PTP_DTC_UINT64:
6666 oinfo.ObjectCompressedSize = xpl->propval.u64;
6669 ptp_debug (params, "ptp2/mtpfast: objectsize has type 0x%x???", xpl->datatype);
6672 ptp_debug (params, "ptp2/mtpfast: objectsize %u", xpl->propval.u32);
6674 case PTP_OPC_StorageID:
6675 if (xpl->datatype != PTP_DTC_UINT32) {
6676 ptp_debug (params, "ptp2/mtpfast: storageid has type 0x%x???", xpl->datatype);
6679 oinfo.StorageID = xpl->propval.u32;
6680 ptp_debug (params, "ptp2/mtpfast: storageid 0x%x", xpl->propval.u32);
6682 case PTP_OPC_ProtectionStatus:/*UINT16*/
6683 if (xpl->datatype != PTP_DTC_UINT16) {
6684 ptp_debug (params, "ptp2/mtpfast: protectionstatus has type 0x%x???", xpl->datatype);
6687 oinfo.ProtectionStatus = xpl->propval.u16;
6688 ptp_debug (params, "ptp2/mtpfast: protection 0x%x", xpl->propval.u16);
6690 case PTP_OPC_ObjectFileName:
6691 if (xpl->datatype != PTP_DTC_STR) {
6692 ptp_debug (params, "ptp2/mtpfast: filename has type 0x%x???", xpl->datatype);
6695 if (xpl->propval.str) {
6696 ptp_debug (params, "ptp2/mtpfast: filename %s", xpl->propval.str);
6697 oinfo.Filename = strdup(xpl->propval.str);
6699 oinfo.Filename = NULL;
6702 case PTP_OPC_DateCreated:
6703 if (xpl->datatype != PTP_DTC_STR) {
6704 ptp_debug (params, "ptp2/mtpfast: datecreated has type 0x%x???", xpl->datatype);
6707 ptp_debug (params, "ptp2/mtpfast: capturedate %s", xpl->propval.str);
6708 oinfo.CaptureDate = ptp_unpack_PTPTIME (xpl->propval.str);
6710 case PTP_OPC_DateModified:
6711 if (xpl->datatype != PTP_DTC_STR) {
6712 ptp_debug (params, "ptp2/mtpfast: datemodified has type 0x%x???", xpl->datatype);
6715 ptp_debug (params, "ptp2/mtpfast: moddate %s", xpl->propval.str);
6716 oinfo.ModificationDate = ptp_unpack_PTPTIME (xpl->propval.str);
6719 if ((xpl->property & 0xfff0) == 0xdc00)
6720 ptp_debug (params, "ptp2/mtpfast:case %x type %x unhandled", xpl->property, xpl->datatype);
6724 if (!oinfo.Filename)
6725 /* i have one such file on my Creative */
6726 oinfo.Filename = strdup("<null>");
6728 ob->flags |= PTPOBJECT_MTPPROPLIST_LOADED;
6731 if ((ob->flags & want) == want)
6733 ptp_debug (params, "ptp_object_want: oid 0x%08x, want flags %x, have only %x?", handle, want, ob->flags);
6734 return PTP_RC_GeneralError;
6739 ptp_add_object_to_cache(PTPParams *params, uint32_t handle)
6742 return ptp_object_want (params, handle, PTPOBJECT_OBJECTINFO_LOADED|PTPOBJECT_MTPPROPLIST_LOADED, &ob);