* [PATCH v4l-utils] v4l-helpers.h: count mappings separately from buffers
@ 2019-08-13 13:14 Philipp Zabel
0 siblings, 0 replies; only message in thread
From: Philipp Zabel @ 2019-08-13 13:14 UTC (permalink / raw)
To: linux-media
This is required to avoid leaking mapped buffers when trying to unmap
after reqbufs(0), to test buffer orphaning.
Fixes: 6300b376cb3e ("v4l2-compliance: test orphaned buffer support");
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
utils/common/v4l-helpers.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/utils/common/v4l-helpers.h b/utils/common/v4l-helpers.h
index d12f2745ef23..c37124e41efe 100644
--- a/utils/common/v4l-helpers.h
+++ b/utils/common/v4l-helpers.h
@@ -1406,6 +1406,7 @@ struct v4l_queue {
unsigned type;
unsigned memory;
unsigned buffers;
+ unsigned mappings;
unsigned num_planes;
unsigned capabilities;
@@ -1432,6 +1433,7 @@ static inline void v4l_queue_init(struct v4l_queue *q,
static inline unsigned v4l_queue_g_type(const struct v4l_queue *q) { return q->type; }
static inline unsigned v4l_queue_g_memory(const struct v4l_queue *q) { return q->memory; }
static inline unsigned v4l_queue_g_buffers(const struct v4l_queue *q) { return q->buffers; }
+static inline unsigned v4l_queue_g_mappings(const struct v4l_queue *q) { return q->mappings; }
static inline unsigned v4l_queue_g_num_planes(const struct v4l_queue *q) { return q->num_planes; }
static inline unsigned v4l_queue_g_capabilities(const struct v4l_queue *q) { return q->capabilities; }
@@ -1452,7 +1454,7 @@ static inline void v4l_queue_s_mmapping(struct v4l_queue *q, unsigned index, uns
static inline void *v4l_queue_g_mmapping(const struct v4l_queue *q, unsigned index, unsigned plane)
{
- if (index >= v4l_queue_g_buffers(q) || plane >= v4l_queue_g_num_planes(q))
+ if (index >= v4l_queue_g_mappings(q) || plane >= v4l_queue_g_num_planes(q))
return NULL;
return q->mmappings[index][plane];
}
@@ -1591,6 +1593,7 @@ static inline int v4l_queue_mmap_bufs(struct v4l_fd *f,
v4l_queue_s_mmapping(q, b, p, m);
}
}
+ q->mappings = b;
return 0;
}
static inline int v4l_queue_munmap_bufs(struct v4l_fd *f, struct v4l_queue *q,
@@ -1602,7 +1605,7 @@ static inline int v4l_queue_munmap_bufs(struct v4l_fd *f, struct v4l_queue *q,
if (q->memory != V4L2_MEMORY_MMAP && q->memory != V4L2_MEMORY_DMABUF)
return 0;
- for (b = from; b < v4l_queue_g_buffers(q); b++) {
+ for (b = from; b < v4l_queue_g_mappings(q); b++) {
for (p = 0; p < v4l_queue_g_num_planes(q); p++) {
void *m = v4l_queue_g_mmapping(q, b, p);
@@ -1618,6 +1621,7 @@ static inline int v4l_queue_munmap_bufs(struct v4l_fd *f, struct v4l_queue *q,
v4l_queue_s_mmapping(q, b, p, NULL);
}
}
+ q->mappings = from;
return 0;
}
--
2.20.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-08-13 13:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-13 13:14 [PATCH v4l-utils] v4l-helpers.h: count mappings separately from buffers Philipp Zabel
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).