Add support to verify V4L2_TCH_FMT_TU16 format touch inputs. Signed-off-by: Vandana BN <bnvandana@xxxxxxxxx> --- utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 4 ++++ utils/v4l2-ctl/v4l2-ctl-vidcap.cpp | 25 +++++++++++++++++++++++++ utils/v4l2-ctl/v4l2-ctl.cpp | 6 ++++++ utils/v4l2-ctl/v4l2-ctl.h | 2 ++ 4 files changed, 37 insertions(+) diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp index 184bfd64..e85f8833 100644 --- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp @@ -595,6 +595,10 @@ static void print_concise_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, if (v4l_type_is_meta(buf.g_type()) && buf.g_bytesused(0) && !(buf.g_flags() & V4L2_BUF_FLAG_ERROR)) print_meta_buffer(f, buf, fmt, q); + + if (is_vivid && (capabilities & V4L2_CAP_TOUCH) && buf.g_bytesused(0) && + !(buf.g_flags() & V4L2_BUF_FLAG_ERROR)) + print_touch_buffer(f, buf, fmt, q); } static void stream_buf_caps(cv4l_fd &fd, unsigned buftype) diff --git a/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp b/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp index 3a29251a..500cb587 100644 --- a/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp @@ -358,3 +358,28 @@ void vidcap_list(cv4l_fd &fd) } } } + +void print_touch_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q) +{ + __u16 *vbuf = NULL; + __u32 i=0; + bool val = false; + + switch (fmt.g_pixelformat()) { + case V4L2_TCH_FMT_TU16: + vbuf = (__u16*)q.g_dataptr(buf.g_index(), 0); + fprintf(f, "TU16: "); + for (i = 0; i < (fmt.g_width() * fmt.g_height()); i++) { + if (vbuf[i]) { + fprintf(f, "Pressure Value: %d @ %dx%d\n", + vbuf[i], + i % fmt.g_width(), + i / fmt.g_height()); + val = true; + } + } + if (!val) + fprintf(f, "\n"); + break; + } +} diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp index aa4742c5..da8c3c40 100644 --- a/utils/v4l2-ctl/v4l2-ctl.cpp +++ b/utils/v4l2-ctl/v4l2-ctl.cpp @@ -66,6 +66,7 @@ unsigned out_priv_magic; bool is_multiplanar; __u32 vidcap_buftype; __u32 vidout_buftype; +bool is_vivid; static struct option long_options[] = { {"list-audio-inputs", no_argument, 0, OptListAudioInputs}, @@ -1111,6 +1112,7 @@ int main(int argc, char **argv) int media_fd = -1; bool is_subdev = false; std::string media_bus_info; + std::string driver; /* command args */ int ch; @@ -1334,6 +1336,10 @@ int main(int argc, char **argv) fprintf(stderr, "%s: not a v4l2 node\n", device); exit(1); } + + driver = (const char *)vcap.driver; + is_vivid = driver == "vivid"; + capabilities = vcap.capabilities; if (capabilities & V4L2_CAP_DEVICE_CAPS) capabilities = vcap.device_caps; diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h index b0f65e9b..fca17c97 100644 --- a/utils/v4l2-ctl/v4l2-ctl.h +++ b/utils/v4l2-ctl/v4l2-ctl.h @@ -275,6 +275,7 @@ extern bool is_multiplanar; extern __u32 vidcap_buftype; extern __u32 vidout_buftype; extern int verbose; +extern bool is_vivid; typedef struct { unsigned flag; @@ -373,6 +374,7 @@ int vidcap_get_and_update_fmt(cv4l_fd &_fd, struct v4l2_format &vfmt); void vidcap_set(cv4l_fd &fd); void vidcap_get(cv4l_fd &fd); void vidcap_list(cv4l_fd &fd); +void print_touch_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q); // v4l2-ctl-vidout.cpp void vidout_usage(void); -- 2.17.1