osd: support hw vsync [1/1]
authorshuze.ma <shuze.ma@amlogic.com>
Tue, 17 Apr 2018 07:03:45 +0000 (15:03 +0800)
committerYixun Lan <yixun.lan@amlogic.com>
Mon, 21 May 2018 08:42:18 +0000 (01:42 -0700)
PD#163001: osd: support hw vsync

Change-Id: I1e7f158b8cbc9434165745f77274ae353cfae342
Signed-off-by: shuze.ma <shuze.ma@amlogic.com>
drivers/amlogic/media/osd/osd_fb.c
drivers/amlogic/media/osd/osd_fb.h
drivers/amlogic/media/osd/osd_hw.c
drivers/amlogic/media/osd/osd_hw.h
drivers/amlogic/media/osd/osd_rdma.c

index d03dbea..371ccfc 100644 (file)
@@ -720,7 +720,8 @@ static int osd_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
        u32 block_windows[8] = {0};
        u32 block_mode;
        u32 hwc_enable;
-       unsigned long ret;
+       int ret;
+       s64 vsync_timestamp;
        u32 flush_rate;
        int out_fen_fd;
        int xoffset, yoffset;
@@ -1026,10 +1027,12 @@ static int osd_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
                        ? -EFAULT : 0;
                break;
 #endif
+
        case FBIO_WAITFORVSYNC:
-               osd_wait_vsync_event();
-               ret = copy_to_user(argp, &ret, sizeof(u32));
+               vsync_timestamp = osd_wait_vsync_event();
+               ret = copy_to_user(argp, &vsync_timestamp, sizeof(s64));
                break;
+
        case FBIOPUT_OSD_CURSOR:
 #ifdef CONFIG_AMLOGIC_MEDIA_FB_OSD2_CURSOR
                osd_cursor(info, &cursor);
index aecc4a2..c3a6c53 100644 (file)
@@ -29,6 +29,7 @@
 
 #define OSD_COUNT (HW_OSD_COUNT)
 #define INVALID_BPP_ITEM {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+#define FBIO_WAITFORVSYNC       _IOW('F', 0x20, __u32)
 
 struct osd_fb_dev_s {
        struct mutex lock;
index 69e3ddd..caf1a54 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/file.h>
 #include <linux/list.h>
 #include <linux/kthread.h>
+#include <linux/ktime.h>
 /* Android Headers */
 
 /* Amlogic sync headers */
@@ -87,6 +88,7 @@ static DEFINE_MUTEX(osd_mutex);
 static DECLARE_WAIT_QUEUE_HEAD(osd_vsync_wq);
 
 static bool vsync_hit;
+static bool user_vsync_hit;
 static bool osd_update_window_axis;
 static int osd_afbc_dec_enable;
 static int ext_canvas_id[HW_OSD_COUNT];
@@ -390,7 +392,7 @@ static void osd_put_fenceobj(struct fence *fence)
 #endif
 
 static int pxp_mode;
-
+s64 timestamp;
 
 static unsigned int osd_h_filter_mode = 1;
 #define CANVAS_ALIGNED(x)      (((x) + 31) & ~31)
@@ -1104,19 +1106,21 @@ void osd_update_3d_mode(void)
 
 static inline void wait_vsync_wakeup(void)
 {
-       vsync_hit = true;
-       wake_up_interruptible(&osd_vsync_wq);
+       user_vsync_hit = vsync_hit = true;
+       wake_up_interruptible_all(&osd_vsync_wq);
 }
 
 void osd_update_vsync_hit(void)
 {
-       if (!vsync_hit) {
+       ktime_t stime;
+
+       stime = ktime_get();
+       timestamp = stime.tv64;
 #ifdef FIQ_VSYNC
                fiq_bridge_pulse_trigger(&osd_hw.fiq_handle_item);
 #else
                wait_vsync_wakeup();
 #endif
-       }
 }
 
 /* the return stride unit is 128bit(16bytes) */
@@ -1656,16 +1660,21 @@ void osd_wait_vsync_hw(void)
        }
 }
 
-s32 osd_wait_vsync_event(void)
+s64 osd_wait_vsync_event(void)
 {
        unsigned long timeout;
 
-       vsync_hit = false;
-       /* waiting for 1000ms. */
-       timeout = msecs_to_jiffies(1000);
-       wait_event_interruptible_timeout(osd_vsync_wq, vsync_hit, timeout);
+       user_vsync_hit = false;
 
-       return 0;
+       if (pxp_mode)
+               timeout = msecs_to_jiffies(50);
+       else
+               timeout = msecs_to_jiffies(1000);
+
+       /* waiting for 10ms. */
+       wait_event_interruptible_timeout(osd_vsync_wq, user_vsync_hit, timeout);
+
+       return timestamp;
 }
 
 static int is_interlaced(struct vinfo_s *vinfo)
index 7b06f22..60d6dbd 100644 (file)
@@ -119,7 +119,7 @@ extern int osd_sync_request_render(u32 index, u32 yres,
        struct sync_req_render_s *request,
        u32 phys_addr);
 extern int osd_sync_do_hwc(u32 width, u32 height);
-extern s32  osd_wait_vsync_event(void);
+extern s64  osd_wait_vsync_event(void);
 extern void osd_cursor_hw(u32 index, s16 x, s16 y, s16 xstart, s16 ystart,
                          u32 osd_w, u32 osd_h);
 extern void osd_init_scan_mode(void);
index 306d049..cefd785 100644 (file)
@@ -975,10 +975,10 @@ static void osd_rdma_irq(void *arg)
        rdma_status = osd_reg_read(RDMA_STATUS);
        debug_rdma_status = rdma_status;
        OSD_RDMA_STATUS_CLEAR_REJECT;
+       osd_update_vsync_hit();
        reset_rdma_table();
        osd_update_scan_mode();
        osd_update_3d_mode();
-       osd_update_vsync_hit();
        osd_hw_reset();
        rdma_irq_count++;
        {