v4l2-ctl:Add Support for Touch
PATCH 1/1 v4l2-ctl:Add Support for Touch
Add support to verify V4L2_TCH_FMT_TU16 format touch inputs.
--- utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 4 ++++ utils/v4l2-ctl/v4l2-ctl-vidcap.cpp | 29 +++++++++++++++++++++++++++ utils/v4l2-ctl/v4l2-ctl.h | 1 + 3 files changed, 34 insertions(+)
utils/v4l2-ctl/v4l2-ctl-streaming.cpp +4 -0
@@ -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 ((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)
utils/v4l2-ctl/v4l2-ctl-vidcap.cpp +29 -0
@@ -358,3 +358,32 @@ void vidcap_list(cv4l_fd &fd) } } } + +#define VIVID_TCH_HEIGHT 24 +#define VIVID_TCH_WIDTH 14 + +struct vivid_touch_buf { + __u16 buf[VIVID_TCH_WIDTH * VIVID_TCH_HEIGHT]; + int test_pattern; +}; + +void print_touch_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q) +{ + struct vivid_touch_buf *vbuf; + int i=0; + + switch (fmt.g_pixelformat()) { + case V4L2_TCH_FMT_TU16: + vbuf = (vivid_touch_buf *)q.g_dataptr(buf.g_index(), 0); + fprintf(f, "Test Pattern: %d\n",vbuf->test_pattern); + fprintf(f, "TU16: "); + for (i = 0; i < (VIVID_TCH_HEIGHT*VIVID_TCH_WIDTH); i++) { + if (vbuf->buf[i]) + fprintf(f, "x: %d y: %d Pressure Value: %d\n", + i % VIVID_TCH_WIDTH, + i / VIVID_TCH_WIDTH, + vbuf->buf[i]); + } + break; + } +}
utils/v4l2-ctl/v4l2-ctl.h +1 -0
@@ -373,6 +373,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 );
Signature · 1 line
2.17.1
PATCH v2 1/1 v4l2-ctl:Add Support for Touch
Add support to verify V4L2_TCH_FMT_TU16 format touch inputs.
--- 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(+)
utils/v4l2-ctl/v4l2-ctl-streaming.cpp +4 -0
@@ -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)
utils/v4l2-ctl/v4l2-ctl-vidcap.cpp +25 -0
@@ -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; + } +}
utils/v4l2-ctl/v4l2-ctl.cpp +6 -0
@@ -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;
utils/v4l2-ctl/v4l2-ctl.h +2 -0
@@ -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 );
Signature · 1 line
2.17.1
PATCH v3 1/1 v4l2-ctl:Add Support for Touch
Add support to verify V4L2_TCH_FMT_TU16 format touch inputs.
--- utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 4 ++++ utils/v4l2-ctl/v4l2-ctl-vidcap.cpp | 22 ++++++++++++++++++++++ utils/v4l2-ctl/v4l2-ctl.h | 1 + 3 files changed, 27 insertions(+)
utils/v4l2-ctl/v4l2-ctl-streaming.cpp +4 -0
@@ -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 ((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)
utils/v4l2-ctl/v4l2-ctl-vidcap.cpp +22 -0
@@ -358,3 +358,25 @@ void vidcap_list(cv4l_fd &fd) } } } + +void print_touch_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q) +{ + __s16 *vbuf = NULL; + __u32 x, y, index; + + switch (fmt.g_pixelformat()) { + case V4L2_TCH_FMT_DELTA_TD16: + vbuf = (__s16*)q.g_dataptr(buf.g_index(), 0); + fprintf(f, "TD16:\n"); + if (fmt.g_width() < 64 || fmt.g_height() < 64) { + for (y = 0; y < fmt.g_height(); y++) { + for (x = 0; x < fmt.g_width() ; x++) { + index = x + fmt.g_width() * y; + fprintf(f, "%-3d ", vbuf[index]); + } + fprintf(f, "\n"); + } + } + break; + } +}
utils/v4l2-ctl/v4l2-ctl.h +1 -0
@@ -373,6 +373,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 );
Signature · 1 line
2.17.1
Quoted 1 line · Vandana BN
Add support to verify
V4L2_TCH_FMT_TU16format touch inputs.
Out of date commit msg: it's FMT_DELTA_TD16 that's supported.
Quoted 13 lines
Signed-off-by Vandana BN <[email protected]>--- utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 4 ++++ utils/v4l2-ctl/v4l2-ctl-vidcap.cpp | 22 ++++++++++++++++++++++ utils/v4l2-ctl/v4l2-ctl.h | 1 + 3 files changed, 27 insertions(+)utils/v4l2-ctl/v4l2-ctl-streaming.cpp +0
-0
utils/v4l2-ctl/v4l2-ctl-streaming.cpp static void print_concise_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, · line 600
Quoted 6 lines
utils/v4l2-ctl/v4l2-ctl-streaming.cpp +3
-0@@ -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 ((capabilities & V4L2_CAP_TOUCH) && buf.g_bytesused(0) && + !(buf.g_flags() & V4L2_BUF_FLAG_ERROR))
Do the width/height check here instead of in print_touch_buffer.
Quoted 12 lines
utils/v4l2-ctl/v4l2-ctl-streaming.cpp +1
-0+ print_touch_buffer(f, buf, fmt, q); } static void stream_buf_caps(cv4l_fd &fd, unsigned buftype)utils/v4l2-ctl/v4l2-ctl-vidcap.cpp +0
-0@@ -358,3 +358,25 @@ void vidcap_list(cv4l_fd &fd) } } }
utils/v4l2-ctl/v4l2-ctl-vidcap.cpp void vidcap_list(cv4l_fd &fd) · line 370
Quoted 10 lines
utils/v4l2-ctl/v4l2-ctl-vidcap.cpp +10
-0+ +void print_touch_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q) +{ + __s16 *vbuf = NULL; + __u32 x, y, index; + + switch (fmt.g_pixelformat()) { + case V4L2_TCH_FMT_DELTA_TD16: + vbuf = (__s16*)q.g_dataptr(buf.g_index(), 0); + fprintf(f, "TD16:\n");
Rather than doing this before showing the pattern, it is better to have this as a prefix at the start of each line. It's more compact.
utils/v4l2-ctl/v4l2-ctl-vidcap.cpp void vidcap_list(cv4l_fd &fd) · line 373
Quoted 3 lines
utils/v4l2-ctl/v4l2-ctl-vidcap.cpp +3
-0+ if (fmt.g_width() < 64 || fmt.g_height() < 64) { + for (y = 0; y < fmt.g_height(); y++) { + for (x = 0; x < fmt.g_width() ; x++) {
Space before ;
You can drop the index variable by just adding ', vbuf++' after the y++ and using *vbuf instead of vbuf[index]. You also need to use le16toh since the vbuf contents is little endian.
Regards,
Hans
Quoted 22 lines
utils/v4l2-ctl/v4l2-ctl-vidcap.cpp +9
-0+ index = x + fmt.g_width() * y; + fprintf(f, "%-3d ", vbuf[index]); + } + fprintf(f, "\n"); + } + } + break; + } +}utils/v4l2-ctl/v4l2-ctl.h +1
-0@@ -373,6 +373,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 );
PATCH v4 1/1 v4l2-ctl:Add Support for Touch
Add support to verify V4L2_TCH_FMT_DELTA_TD16 format touch inputs.
--- utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 5 +++++ utils/v4l2-ctl/v4l2-ctl-vidcap.cpp | 19 +++++++++++++++++++ utils/v4l2-ctl/v4l2-ctl.h | 1 + 3 files changed, 25 insertions(+)
utils/v4l2-ctl/v4l2-ctl-streaming.cpp +5 -0
@@ -595,6 +595,11 @@ 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 ((capabilities & V4L2_CAP_TOUCH) && buf.g_bytesused(0) && + !(buf.g_flags() & V4L2_BUF_FLAG_ERROR) && + (fmt.g_width() < 64 || fmt.g_height() < 64)) + print_touch_buffer(f, buf, fmt, q); } static void stream_buf_caps(cv4l_fd &fd, unsigned buftype)
utils/v4l2-ctl/v4l2-ctl-vidcap.cpp +19 -0
@@ -358,3 +358,22 @@ void vidcap_list(cv4l_fd &fd) } } } + +void print_touch_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q) +{ + __s16 *vbuf = NULL; + __u32 x, y; + + switch (fmt.g_pixelformat()) { + case V4L2_TCH_FMT_DELTA_TD16: + vbuf = (__s16*)q.g_dataptr(buf.g_index(), 0); + for (y = 0; y < fmt.g_height(); y++) { + fprintf(f, "TD16:"); + for (x = 0; x < fmt.g_width(); x++, vbuf++) { + fprintf(f, "%-3d ", (__s16)le16toh(*vbuf)); + } + fprintf(f, "\n"); + } + break; + } +}
utils/v4l2-ctl/v4l2-ctl.h +1 -0
@@ -373,6 +373,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 );
Signature · 1 line
2.17.1