From: shuze.ma Date: Tue, 17 Apr 2018 07:03:45 +0000 (+0800) Subject: osd: support hw vsync [1/1] X-Git-Tag: khadas-vims-v0.9.6-release~2023 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6aa8abc6e1cff39339a54bb11863522557462429;p=platform%2Fkernel%2Flinux-amlogic.git osd: support hw vsync [1/1] PD#163001: osd: support hw vsync Change-Id: I1e7f158b8cbc9434165745f77274ae353cfae342 Signed-off-by: shuze.ma --- diff --git a/drivers/amlogic/media/osd/osd_fb.c b/drivers/amlogic/media/osd/osd_fb.c index d03dbea..371ccfc 100644 --- a/drivers/amlogic/media/osd/osd_fb.c +++ b/drivers/amlogic/media/osd/osd_fb.c @@ -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); diff --git a/drivers/amlogic/media/osd/osd_fb.h b/drivers/amlogic/media/osd/osd_fb.h index aecc4a2..c3a6c53 100644 --- a/drivers/amlogic/media/osd/osd_fb.h +++ b/drivers/amlogic/media/osd/osd_fb.h @@ -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; diff --git a/drivers/amlogic/media/osd/osd_hw.c b/drivers/amlogic/media/osd/osd_hw.c index 69e3ddd..caf1a54 100644 --- a/drivers/amlogic/media/osd/osd_hw.c +++ b/drivers/amlogic/media/osd/osd_hw.c @@ -28,6 +28,7 @@ #include #include #include +#include /* 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) diff --git a/drivers/amlogic/media/osd/osd_hw.h b/drivers/amlogic/media/osd/osd_hw.h index 7b06f22..60d6dbd 100644 --- a/drivers/amlogic/media/osd/osd_hw.h +++ b/drivers/amlogic/media/osd/osd_hw.h @@ -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); diff --git a/drivers/amlogic/media/osd/osd_rdma.c b/drivers/amlogic/media/osd/osd_rdma.c index 306d049..cefd785 100644 --- a/drivers/amlogic/media/osd/osd_rdma.c +++ b/drivers/amlogic/media/osd/osd_rdma.c @@ -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++; {