amlvideo: Optimize reduce latency of input frame [1/1]
authorshipeng.sun <shipeng.sun@amlogic.com>
Tue, 28 May 2019 11:42:22 +0000 (19:42 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Mon, 24 Jun 2019 02:49:27 +0000 (19:49 -0700)
PD#SWPL-8068
PD#SWPL-8069

Problem:
1. use select to polling frame.

Solution:
1. add when use video layer amlvideo support poll
2. add trace debug info

Verify:
Verify on marconi

Change-Id: Ib1ae87b4b7ab35b075bc357953abe43e3410232a
Signed-off-by: shipeng.sun <shipeng.sun@amlogic.com>
Signed-off-by: Tao Guo <tao.guo@amlogic.com>
drivers/amlogic/debug/meson_atrace.c
drivers/amlogic/media/video_processor/video_dev/amlvideo.c
drivers/amlogic/media/video_processor/video_dev/amlvideo.h
include/trace/events/meson_atrace.h

index 2e67dc6..28fe069 100644 (file)
@@ -33,6 +33,7 @@ struct {
        TAG_INFO(VDEC),
        TAG_INFO(TSYNC),
        TAG_INFO(IONVIDEO),
+       TAG_INFO(AMLVIDEO),
        { NULL, 0 }
 };
 
index cf63084..bc424e7 100644 (file)
@@ -54,6 +54,8 @@
 #include "amlvideo.h"
 
 #define AVMLVIDEO_MODULE_NAME "amlvideo"
+#define KERNEL_ATRACE_TAG KERNEL_ATRACE_TAG_AMLVIDEO
+#include <trace/events/meson_atrace.h>
 
 #define AMLVIDEO_INFO(fmt, args...) pr_info("amlvid:info: "fmt"", ## args)
 #define AMLVIDEO_DBG(fmt, args...) pr_debug("amlvid:dbg: "fmt"", ## args)
@@ -154,9 +156,12 @@ static struct vframe_s *amlvideo_vf_peek(void *op_arg)
 
 static struct vframe_s *amlvideo_vf_get(void *op_arg)
 {
+       struct vframe_s *vf;
        struct vivi_dev *dev = (struct vivi_dev *)op_arg;
 
-       return vfq_pop(&dev->q_ready);
+       vf = vfq_pop(&dev->q_ready);
+       ATRACE_COUNTER(dev->v4l2_dev.name, vfq_level(&dev->q_ready));
+       return vf;
 }
 
 static void amlvideo_vf_put(struct vframe_s *vf, void *op_arg)
@@ -297,6 +302,9 @@ static int video_receiver_event_fun(int type, void *data, void *private_data)
 
                vf_notify_receiver(dev->vf_provider_name,
                        VFRAME_EVENT_PROVIDER_RESET, data);
+       } else if (type == VFRAME_EVENT_PROVIDER_VFRAME_READY) {
+               if (vf_peek(dev->vf_receiver_name) != NULL)
+                       wake_up_interruptible(&dev->wq);
        }
        return 0;
 }
@@ -593,6 +601,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p)
                dev->vf->next_vf_pts = next_vf->pts;
 
        vfq_push(&dev->q_ready, dev->vf);
+       ATRACE_COUNTER(dev->v4l2_dev.name, vfq_level(&dev->q_ready));
        p->index = 0;
 
        p->timestamp.tv_sec = pts_us64 >> 32;
@@ -738,14 +747,21 @@ static unsigned int amlvideo_poll(struct file *file,
 {
        struct vivi_fh *fh = file->private_data;
        struct vivi_dev *dev = fh->dev;
-       struct videobuf_queue *q = &fh->vb_vidq;
 
        dprintk(dev, 1, "%s\n", __func__);
 
        if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
                return POLLERR;
 
-       return videobuf_poll_stream(file, q, wait);
+       if (vf_peek(dev->vf_receiver_name))
+               return POLL_IN | POLLRDNORM;
+
+       poll_wait(file, &dev->wq, wait);
+
+       if (vf_peek(dev->vf_receiver_name))
+               return POLL_IN | POLLRDNORM;
+       else
+               return 0;
 }
 
 static int amlvideo_close(struct file *file)
@@ -879,7 +895,7 @@ static int __init amlvideo_create_instance(int inst)
                goto free_dev;
 
        /* init video dma queues */
-
+       init_waitqueue_head(&dev->wq);
        INIT_LIST_HEAD(&dev->vidq.active);
        init_waitqueue_head(&dev->vidq.wq);
 
index 6d084d9..090e294 100644 (file)
@@ -89,6 +89,7 @@ struct vivi_dev {
        struct vframe_receiver_s video_vf_recv;
        u32 frame_num;
        struct v4l2_amlogic_parm am_parm;
+       wait_queue_head_t wq;
 };
 
 struct vivi_fh {
index 1baade7..ec5d502 100644 (file)
@@ -43,6 +43,7 @@ enum {
        KERNEL_ATRACE_TAG_VDEC,
        KERNEL_ATRACE_TAG_TSYNC,
        KERNEL_ATRACE_TAG_IONVIDEO,
+       KERNEL_ATRACE_TAG_AMLVIDEO,
        KERNEL_ATRACE_TAG_MAX = 64,
        KERNEL_ATRACE_TAG_ALL
 };