While there's a control to allow setting it at runtime, as the
control handler is per file handler, only the application setting
the m2m device can change it. As this is a custom control, it is
unlikely that existing apps would be able to set it.

Due to that, and due to the fact that v4l2-mem2mem serializes all
accesses to a m2m device, trying to setup two GStreamer
v4l2videoconvert instance at the same time will cause frame drops.

So, add an alternate way of setting its default via a modprobe parameter.

Signed-off-by: Mauro Carvalho Chehab <mchehab+sams...@kernel.org>
---
 drivers/media/platform/vim2m.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/vim2m.c b/drivers/media/platform/vim2m.c
index a9e43070567e..0e7814b2327e 100644
--- a/drivers/media/platform/vim2m.c
+++ b/drivers/media/platform/vim2m.c
@@ -41,6 +41,12 @@ static unsigned debug;
 module_param(debug, uint, 0644);
 MODULE_PARM_DESC(debug, "activates debug info");
 
+/* Default transaction time in msec */
+static unsigned default_transtime = 40; /* Max 25 fps */
+module_param(default_transtime, uint, 0644);
+MODULE_PARM_DESC(default_transtime, "default transaction time in ms");
+
+
 #define MIN_W 32
 #define MIN_H 32
 #define MAX_W 640
@@ -58,9 +64,6 @@ MODULE_PARM_DESC(debug, "activates debug info");
 /* In bytes, per queue */
 #define MEM2MEM_VID_MEM_LIMIT  (16 * 1024 * 1024)
 
-/* Default transaction time in msec */
-#define MEM2MEM_DEF_TRANSTIME  40
-
 /* Flags that indicate processing mode */
 #define MEM2MEM_HFLIP  (1 << 0)
 #define MEM2MEM_VFLIP  (1 << 1)
@@ -764,6 +767,8 @@ static int vim2m_s_ctrl(struct v4l2_ctrl *ctrl)
 
        case V4L2_CID_TRANS_TIME_MSEC:
                ctx->transtime = ctrl->val;
+               if (ctx->transtime < 1)
+                       ctx->transtime = 1;
                break;
 
        case V4L2_CID_TRANS_NUM_BUFS:
@@ -961,12 +966,11 @@ static int queue_init(void *priv, struct vb2_queue 
*src_vq, struct vb2_queue *ds
        return vb2_queue_init(dst_vq);
 }
 
-static const struct v4l2_ctrl_config vim2m_ctrl_trans_time_msec = {
+static struct v4l2_ctrl_config vim2m_ctrl_trans_time_msec = {
        .ops = &vim2m_ctrl_ops,
        .id = V4L2_CID_TRANS_TIME_MSEC,
        .name = "Transaction Time (msec)",
        .type = V4L2_CTRL_TYPE_INTEGER,
-       .def = MEM2MEM_DEF_TRANSTIME,
        .min = 1,
        .max = 10001,
        .step = 1,
@@ -1008,6 +1012,8 @@ static int vim2m_open(struct file *file)
        v4l2_ctrl_handler_init(hdl, 4);
        v4l2_ctrl_new_std(hdl, &vim2m_ctrl_ops, V4L2_CID_HFLIP, 0, 1, 1, 0);
        v4l2_ctrl_new_std(hdl, &vim2m_ctrl_ops, V4L2_CID_VFLIP, 0, 1, 1, 0);
+
+       vim2m_ctrl_trans_time_msec.def = default_transtime;
        v4l2_ctrl_new_custom(hdl, &vim2m_ctrl_trans_time_msec, NULL);
        v4l2_ctrl_new_custom(hdl, &vim2m_ctrl_trans_num_bufs, NULL);
        if (hdl->error) {
-- 
2.20.1

Reply via email to