media: mem2mem: Require capture and output mutexes to match

Currently, all the mem2mem driver either use a single mutex
to lock the capture and output videobuf2 queues, or don't
set any mutex.

This means the mutexes match, and so the mem2mem framework
is able to set the m2m context lock.

Enforce this by making it mandatory for drivers to set
the same capture and output mutex, or not set any mutex at all.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
Ezequiel Garcia 2018-10-18 14:02:20 -04:00 committed by Mauro Carvalho Chehab
parent fe5a2bbb63
commit 913f3ec280
1 changed files with 7 additions and 5 deletions

View File

@ -908,12 +908,14 @@ struct v4l2_m2m_ctx *v4l2_m2m_ctx_init(struct v4l2_m2m_dev *m2m_dev,
if (ret)
goto err;
/*
* If both queues use same mutex assign it as the common buffer
* queues lock to the m2m context. This lock is used in the
* v4l2_m2m_ioctl_* helpers.
* Both queues should use same the mutex to lock the m2m context.
* This lock is used in some v4l2_m2m_* helpers.
*/
if (out_q_ctx->q.lock == cap_q_ctx->q.lock)
m2m_ctx->q_lock = out_q_ctx->q.lock;
if (WARN_ON(out_q_ctx->q.lock != cap_q_ctx->q.lock)) {
ret = -EINVAL;
goto err;
}
m2m_ctx->q_lock = out_q_ctx->q.lock;
return m2m_ctx;
err: