summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2012-04-01 10:41:14 +0000
committerMarcus Meissner <marcus@jet.franken.de>2012-04-01 10:41:14 +0000
commita90b42ef09e006e2b54bacc1954daeb09fdf63ed (patch)
tree9c96acfac3e5ab655b58a653c5292296944b2983
parent5dfe5c1e36074e309648a532dd9c8c86c45ffca7 (diff)
downloadlibgphoto2-a90b42ef09e006e2b54bacc1954daeb09fdf63ed.tar.gz
in table16 lookup mode, when setting, check for duplicate values
and use the one in the enumeration git-svn-id: https://svn.code.sf.net/p/gphoto/code/branches/libgphoto2-2_4/libgphoto2@13956 67ed7778-7388-44ab-90cf-0a291f65f57c
-rw-r--r--camlibs/ptp2/config.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/camlibs/ptp2/config.c b/camlibs/ptp2/config.c
index b3c6a521c..c8782a8db 100644
--- a/camlibs/ptp2/config.c
+++ b/camlibs/ptp2/config.c
@@ -635,7 +635,9 @@ _get_Generic16Table(CONFIG_GET_ARGS, struct deviceproptableu16* tbl, int tblsize
static int
_put_Generic16Table(CONFIG_PUT_ARGS, struct deviceproptableu16* tbl, int tblsize) {
char *value;
- int i, ret, intval;
+ int i, ret, intval, j;
+ int foundvalue = 0;
+ uint16_t u16val = 0;
ret = gp_widget_get_value (widget, &value);
if (ret != GP_OK)
@@ -644,10 +646,31 @@ _put_Generic16Table(CONFIG_PUT_ARGS, struct deviceproptableu16* tbl, int tblsize
if (!strcmp(_(tbl[i].label),value) &&
((tbl[i].vendor_id == 0) || (tbl[i].vendor_id == camera->pl->params.deviceinfo.VendorExtensionID))
) {
- propval->u16 = tbl[i].value;
- return GP_OK;
+ u16val = tbl[i].value;
+ foundvalue = 1;
+
+ if (dpd->FormFlag & PTP_DPFF_Enumeration) {
+ for (j = 0; j<dpd->FORM.Enum.NumberOfValues; j++) {
+ if (u16val == dpd->FORM.Enum.SupportedValue[j].u16) {
+ gp_log (GP_LOG_DEBUG, "ptp2/_put_Generic16Table", "FOUND right value for %s in the enumeration at val %d", value, u16val);
+ propval->u16 = u16val;
+ return GP_OK;
+ }
+ }
+ gp_log (GP_LOG_DEBUG, "ptp2/_put_Generic16Table", "did not find the right value for %s in the enumeration at val %d... continuing", value, u16val);
+ /* continue looking, but with this value as fallback */
+ } else {
+ gp_log (GP_LOG_DEBUG, "ptp2/_put_Generic16Table", "not an enumeration ... return %s as %d", value, u16val);
+ propval->u16 = u16val;
+ return GP_OK;
+ }
}
}
+ gp_log (GP_LOG_DEBUG, "ptp2/_put_Generic16Table", "Using fallback, not found in enum... return %s as %d", value, u16val);
+ if (foundvalue) {
+ propval->u16 = u16val;
+ return GP_OK;
+ }
if (!sscanf(value, _("Unknown value %04x"), &intval)) {
gp_log (GP_LOG_ERROR, "ptp2/config", "failed to find value %s in list", value);
return (GP_ERROR);
@@ -3328,8 +3351,8 @@ static struct deviceproptableu16 canon_aperture[] = {
{ "3.5", 0x0024, 0 },
{ "3.5", 0x0025, 0 }, /* (1/3)? */
{ "4", 0x0028, 0 },
- { "4.5", 0x002b, 0 }, /* (1/3)? */
{ "4.5", 0x002c, 0 },
+ { "4.5", 0x002b, 0 }, /* (1/3)? */
{ "5", 0x002d, 0 }, /* 5.6 (1/3)??? */
{ "5.6", 0x0030, 0 },
{ "6.3", 0x0033, 0 },