Re: [PATCH v3] v4l2-ctl:Add Support for Touch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
> ---
>  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);
> 




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux