v4l2-compliance: Add a test for DELETE_BUF ioctl
PATCH 1/1 v4l2-compliance: Add a test for DELETE_BUF ioctl
Add new test for DELETE_BUF ioctl.
It create a buffer and check if it could be remove from queue. It also check that removing non existing buffer or a queued buffer failed.
Signed-off-by Benjamin Gaignard <[email protected]>
--- include/linux/videodev2.h | 1 + utils/common/cv4l-helpers.h | 4 + utils/common/v4l-helpers.h | 13 ++ utils/v4l2-compliance/v4l2-compliance.cpp | 1 + utils/v4l2-compliance/v4l2-compliance.h | 1 + utils/v4l2-compliance/v4l2-test-buffers.cpp | 129 ++++++++++++++++++++ 6 files changed, 149 insertions(+)
include/linux/videodev2.h +1 -0
@@ -2631,6 +2631,7 @@ struct v4l2_create_buffers {#define VIDIOC_DBG_G_CHIP_INFO _IOWR('V', 102, struct v4l2_dbg_chip_info)#define VIDIOC_QUERY_EXT_CTRL _IOWR('V', 103, struct v4l2_query_ext_ctrl) +#define VIDIOC_DELETE_BUF _IOWR('V', 104, struct v4l2_buffer)/* Reminder: when adding new ioctls please add support for them to drivers/media/v4l2-core/v4l2-compat-ioctl32.c as well! */
utils/common/cv4l-helpers.h +4 -0
@@ -758,6 +758,10 @@ public: {return v4l_queue_reqbufs (fd->g_v4l_fd (), this, count, flags); } + int delete_buf(cv4l_fd *fd, unsigned index = 0) + { + return v4l_queue_delete_buf(fd->g_v4l_fd(), this, index); + }bool has_create_bufs (cv4l_fd *fd) const {return v4l_queue_has_create_bufs (fd->g_v4l_fd (), this);
utils/common/v4l-helpers.h +13 -0
@@ -1388,6 +1388,11 @@ static inline int v4l_buffer_prepare_buf(struct v4l_fd *f, struct v4l_buffer *bureturn v4l_ioctl (f,VIDIOC_PREPARE_BUF , &buf->buf); } +static inline int v4l_buffer_delete_buf (struct v4l_fd *f,struct v4l_buffer *buf) +{ +return v4l_ioctl (f,VIDIOC_DELETE_BUF , &buf->buf); +} +static inline int v4l_buffer_qbuf (struct v4l_fd *f,struct v4l_buffer *buf) {return v4l_ioctl (f,VIDIOC_QBUF , &buf->buf);
@@ -1490,6 +1495,14 @@ static inline void *v4l_queue_g_dataptr(const struct v4l_queue *q, unsigned indereturn v4l_queue_g_mmapping (q, index, plane); } +static inline int v4l_queue_delete_buf (struct v4l_fd *f,struct v4l_queue *q,unsigned index) +{ +struct v4l_buffer buf; + +v4l_buffer_init (&buf,v4l_queue_g_type (q),v4l_queue_g_memory (q), index); +return v4l_ioctl (f,VIDIOC_DELETE_BUF , &buf.buf); +} +static inline int v4l_queue_querybufs (struct v4l_fd *f,struct v4l_queue *q,unsigned from) {unsigned b, p;
utils/v4l2-compliance/v4l2-compliance.cpp +1 -0
@@ -1357,6 +1357,7 @@ void testNode(struct node &node, struct node &node_m2m_cap, struct node &expbuf_ printf("Buffer ioctls%s:\n", suffix); printf("\ttest VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: %s\n", ok(testReqBufs(&node))); + printf("\ttest VIDIOC_DELETE_BUF: %s\n", ok(testDeleteBuf(&node))); // Reopen after each streaming test to reset the streaming state // in case of any errors in the preceeding test. node.reopen();
utils/v4l2-compliance/v4l2-compliance.h +1 -0
@@ -377,6 +377,7 @@ int testReqBufs(struct node *node);int testReadWrite (struct node *node);int testExpBuf (struct node *node);int testBlockingWait (struct node *node); +int testDeleteBuf (struct node *node);// 32-bit architecture, 32/64-bit time_t tests int testTime32_64 (struct node *node);
utils/v4l2-compliance/v4l2-test-buffers.cpp +129 -0
135 lines not on this page · raw message
Signature · 1 line
2.39.2