This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: v4l2-ctl: fix array handling
Author:  Hans Verkuil <[email protected]>
Date:    Thu Nov 6 12:54:55 2014 +0100

Both printing and setting of array controls was wrong. Handling subsets was
also completely broken since it used the wrong key in the subset map.

Signed-off-by: Hans Verkuil <[email protected]>
(cherry picked from commit 1b0fc6cb7256f44f73e6f2db4a82707bcc13e7fe)

 utils/v4l2-ctl/v4l2-ctl-common.cpp |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=d3f6a3628ebdd70d7e80b3a03dfa6c3d477b35b6

diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp 
b/utils/v4l2-ctl/v4l2-ctl-common.cpp
index dd8faef..1a5d067 100644
--- a/utils/v4l2-ctl/v4l2-ctl-common.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp
@@ -207,7 +207,7 @@ static void list_devices()
        }
 }
 
-static std::string name2var(char *name)
+static std::string name2var(const char *name)
 {
        std::string s;
        int add_underscore = 0;
@@ -735,10 +735,12 @@ static bool fill_subset(const struct v4l2_query_ext_ctrl 
&qc, ctrl_subset &subse
                subset.size[d] = qc.dims[d];
        }
 
-       if (ctrl_subsets.find(qc.name) != ctrl_subsets.end()) {
+       std::string s = name2var(qc.name);
+
+       if (ctrl_subsets.find(s) != ctrl_subsets.end()) {
                unsigned ss_dims;
 
-               subset = ctrl_subsets[qc.name];
+               subset = ctrl_subsets[s];
                for (ss_dims = 0; ss_dims < V4L2_CTRL_MAX_DIMS && 
subset.size[ss_dims]; ss_dims++) ;
                if (ss_dims != qc.nr_of_dims) {
                        fprintf(stderr, "expected %d dimensions but --subset 
specified %d\n",
@@ -807,8 +809,9 @@ void common_set(int fd)
                                if (fill_subset(qc, subset))
                                        return;
 
-                               for (d = 0; d < qc.nr_of_dims; d++) {
-                                       divide[d] = qc.dims[d];
+                               divide[qc.nr_of_dims - 1] = 1;
+                               for (d = 0; d < qc.nr_of_dims - 1; d++) {
+                                       divide[d] = qc.dims[d + 1];
                                        for (i = 0; i < d; i++)
                                                divide[i] *= divide[d];
                                }
@@ -897,8 +900,9 @@ static void print_array(const struct v4l2_query_ext_ctrl 
&qc, void *p)
        if (fill_subset(qc, subset))
                return;
 
-       for (d = 0; d < qc.nr_of_dims; d++) {
-               divide[d] = qc.dims[d];
+       divide[qc.nr_of_dims - 1] = 1;
+       for (d = 0; d < qc.nr_of_dims - 1; d++) {
+               divide[d] = qc.dims[d + 1];
                for (i = 0; i < d; i++)
                        divide[i] *= divide[d];
        }
@@ -906,7 +910,7 @@ static void print_array(const struct v4l2_query_ext_ctrl 
&qc, void *p)
        from = subset.offset[qc.nr_of_dims - 1];
        to = subset.offset[qc.nr_of_dims - 1] + subset.size[qc.nr_of_dims - 1] 
- 1;
 
-       for (unsigned idx = 0; idx < qc.elems / qc.dims[qc.nr_of_dims - 1]; 
idx++) {
+       for (unsigned idx = 0; idx < qc.elems; idx += qc.dims[qc.nr_of_dims - 
1]) {
                for (d = 0; d < qc.nr_of_dims - 1; d++) {
                        unsigned i = (idx / divide[d]) % qc.dims[d];
 

_______________________________________________
linuxtv-commits mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to