* [PATCH] v4l2-ctl:Add Support for Touch
@ 2019-11-08 7:12 Vandana BN
2019-11-13 11:23 ` [PATCH v2] " Vandana BN
0 siblings, 1 reply; 5+ messages in thread
From: Vandana BN @ 2019-11-08 7:12 UTC (permalink / raw)
To: linux-media, linux-kernel-mentees; +Cc: hverkuil, Vandana BN
Add support to verify V4L2_TCH_FMT_TU16 format touch inputs.
Signed-off-by: Vandana BN <bnvandana@gmail.com>
---
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(+)
diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index 184bfd64..191a18c5 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 ((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..99945248 100644
--- a/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp
@@ -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;
+ }
+}
diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
index b0f65e9b..b31be7f5 100644
--- a/utils/v4l2-ctl/v4l2-ctl.h
+++ b/utils/v4l2-ctl/v4l2-ctl.h
@@ -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);
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2] v4l2-ctl:Add Support for Touch
2019-11-08 7:12 [PATCH] v4l2-ctl:Add Support for Touch Vandana BN
@ 2019-11-13 11:23 ` Vandana BN
2019-11-15 13:21 ` [PATCH v3] " Vandana BN
0 siblings, 1 reply; 5+ messages in thread
From: Vandana BN @ 2019-11-13 11:23 UTC (permalink / raw)
To: linux-media; +Cc: hverkuil, Vandana BN
Add support to verify V4L2_TCH_FMT_TU16 format touch inputs.
Signed-off-by: Vandana BN <bnvandana@gmail.com>
---
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3] v4l2-ctl:Add Support for Touch
2019-11-13 11:23 ` [PATCH v2] " Vandana BN
@ 2019-11-15 13:21 ` Vandana BN
2019-11-19 9:38 ` Hans Verkuil
0 siblings, 1 reply; 5+ messages in thread
From: Vandana BN @ 2019-11-15 13:21 UTC (permalink / raw)
To: linux-media; +Cc: hverkuil, Vandana BN
Add support to verify V4L2_TCH_FMT_TU16 format touch inputs.
Signed-off-by: Vandana BN <bnvandana@gmail.com>
---
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(+)
diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index 184bfd64..191a18c5 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 ((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..af96afdc 100644
--- a/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp
@@ -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;
+ }
+}
diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
index b0f65e9b..b31be7f5 100644
--- a/utils/v4l2-ctl/v4l2-ctl.h
+++ b/utils/v4l2-ctl/v4l2-ctl.h
@@ -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);
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3] v4l2-ctl:Add Support for Touch
2019-11-15 13:21 ` [PATCH v3] " Vandana BN
@ 2019-11-19 9:38 ` Hans Verkuil
2019-11-23 18:36 ` [PATCH v4] " Vandana BN
0 siblings, 1 reply; 5+ messages in thread
From: Hans Verkuil @ 2019-11-19 9:38 UTC (permalink / raw)
To: Vandana BN, linux-media
On 11/15/19 2:21 PM, Vandana BN wrote:
> Add support to verify V4L2_TCH_FMT_TU16 format touch inputs.
Out of date commit msg: it's FMT_DELTA_TD16 that's supported.
>
> Signed-off-by: Vandana BN <bnvandana@gmail.com>
> ---
> 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(+)
>
> diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> index 184bfd64..191a18c5 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 ((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.
> + 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..af96afdc 100644
> --- a/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp
> +++ b/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp
> @@ -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");
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.
> + 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
> + index = x + fmt.g_width() * y;
> + fprintf(f, "%-3d ", vbuf[index]);
> + }
> + fprintf(f, "\n");
> + }
> + }
> + break;
> + }
> +}
> diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
> index b0f65e9b..b31be7f5 100644
> --- a/utils/v4l2-ctl/v4l2-ctl.h
> +++ b/utils/v4l2-ctl/v4l2-ctl.h
> @@ -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);
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v4] v4l2-ctl:Add Support for Touch
2019-11-19 9:38 ` Hans Verkuil
@ 2019-11-23 18:36 ` Vandana BN
0 siblings, 0 replies; 5+ messages in thread
From: Vandana BN @ 2019-11-23 18:36 UTC (permalink / raw)
To: hverkuil, linux-media; +Cc: Vandana BN
Add support to verify V4L2_TCH_FMT_DELTA_TD16 format touch inputs.
Signed-off-by: Vandana BN <bnvandana@gmail.com>
---
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(+)
diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index 184bfd64..47addc41 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -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)
diff --git a/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp b/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp
index 3a29251a..538ece3e 100644
--- a/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp
@@ -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;
+ }
+}
diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
index b0f65e9b..b31be7f5 100644
--- a/utils/v4l2-ctl/v4l2-ctl.h
+++ b/utils/v4l2-ctl/v4l2-ctl.h
@@ -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);
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-11-23 18:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-08 7:12 [PATCH] v4l2-ctl:Add Support for Touch Vandana BN
2019-11-13 11:23 ` [PATCH v2] " Vandana BN
2019-11-15 13:21 ` [PATCH v3] " Vandana BN
2019-11-19 9:38 ` Hans Verkuil
2019-11-23 18:36 ` [PATCH v4] " Vandana BN
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).