If given, report fixed point values as floating point values. Signed-off-by: Hans Verkuil <hverkuil-cisco@xxxxxxxxx> --- utils/v4l2-ctl/v4l2-ctl-common.cpp | 6 ++++++ utils/v4l2-ctl/v4l2-ctl.cpp | 1 + utils/v4l2-ctl/v4l2-ctl.h | 1 + 3 files changed, 8 insertions(+) diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp b/utils/v4l2-ctl/v4l2-ctl-common.cpp index 4b3308f3..15de0a7f 100644 --- a/utils/v4l2-ctl/v4l2-ctl-common.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp @@ -99,6 +99,7 @@ void common_usage() " -r, --subset <ctrl>[,<offset>,<size>]+\n" " the subset of the N-dimensional array to get/set for control <ctrl>,\n" " for every dimension an (<offset>, <size>) tuple is given.\n" + " --float report fixed-point control values as floating point\n" #ifndef NO_LIBV4L2 " -w, --wrapper use the libv4l2 wrapper library.\n" #endif @@ -443,6 +444,11 @@ static void print_fp(__s64 v, unsigned int fraction_bits) if (!f) { printf("%lld", i); + } else if (options[OptFloat]) { + if (fraction_bits <= 16) + printf("%.8f", (double)v / (1ULL << fraction_bits)); + else + printf("%.8g", (double)v / (1ULL << fraction_bits)); } else if (fraction_bits < 20) { __u64 div = 1ULL << fraction_bits; diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp index fb03675e..7d9f2a17 100644 --- a/utils/v4l2-ctl/v4l2-ctl.cpp +++ b/utils/v4l2-ctl/v4l2-ctl.cpp @@ -142,6 +142,7 @@ static struct option long_options[] = { {"silent", no_argument, nullptr, OptSilent}, {"verbose", no_argument, nullptr, OptVerbose}, {"log-status", no_argument, nullptr, OptLogStatus}, + {"float", no_argument, nullptr, OptFloat}, {"get-fmt-overlay", no_argument, nullptr, OptGetOverlayFormat}, {"set-fmt-overlay", optional_argument, nullptr, OptSetOverlayFormat}, {"try-fmt-overlay", optional_argument, nullptr, OptTryOverlayFormat}, diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h index b9e7c352..f453a5d3 100644 --- a/utils/v4l2-ctl/v4l2-ctl.h +++ b/utils/v4l2-ctl/v4l2-ctl.h @@ -142,6 +142,7 @@ enum Option { OptLogStatus, OptVerbose, OptSilent, + OptFloat, OptGetSlicedVbiCap, OptGetSlicedVbiOutCap, OptGetFBuf, -- 2.42.0