From daae33d9070f0f4a22734ae49c20fdf70f05a0f9 Mon Sep 17 00:00:00 2001
From: Robert Nelson <robertcnelson@gmail.com>
Date: Wed, 18 Dec 2013 12:05:16 -0600
Subject: [PATCH 4/5] hack: port da8xx changes from ti 3.12 repo

Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
---
 drivers/video/da8xx-fb.c |   33 +++++++++++++++++++++++++++++++++
 include/video/da8xx-fb.h |    4 ++++
 2 files changed, 37 insertions(+)

Index: linux-3.12.36-rt50-r4s2/drivers/video/da8xx-fb.c
===================================================================
@ linux-3.12.36-rt50-r4s2/drivers/video/da8xx-fb.c:201 @ static struct fb_fix_screeninfo da8xx_fb
 	.accel = FB_ACCEL_NONE
 };
 
+static vsync_callback_t vsync_cb_handler;
+static void *vsync_cb_arg;
+
 static struct fb_videomode known_lcd_panels[] = {
 	/* Sharp LCD035Q3DG01 */
 	[0] = {
@ linux-3.12.36-rt50-r4s2/drivers/video/da8xx-fb.c:831 @ static int lcd_init(struct da8xx_fb_par
 	return 0;
 }
 
+int register_vsync_cb(vsync_callback_t handler, void *arg, int idx)
+{
+	if ((vsync_cb_handler == NULL) && (vsync_cb_arg == NULL)) {
+		vsync_cb_arg = arg;
+		vsync_cb_handler = handler;
+	} else {
+		return -EEXIST;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(register_vsync_cb);
+
+int unregister_vsync_cb(vsync_callback_t handler, void *arg, int idx)
+{
+	if ((vsync_cb_handler == handler) && (vsync_cb_arg == arg)) {
+		vsync_cb_handler = NULL;
+		vsync_cb_arg = NULL;
+	} else {
+		return -ENXIO;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(unregister_vsync_cb);
+
 /* IRQ handler for version 2 of LCDC */
 static irqreturn_t lcdc_irq_handler_rev02(int irq, void *arg)
 {
@ linux-3.12.36-rt50-r4s2/drivers/video/da8xx-fb.c:894 @ static irqreturn_t lcdc_irq_handler_rev0
 				   LCD_DMA_FRM_BUF_CEILING_ADDR_0_REG);
 			par->vsync_flag = 1;
 			wake_up_interruptible(&par->vsync_wait);
+			if (vsync_cb_handler)
+				vsync_cb_handler(vsync_cb_arg);
 		}
 
 		if (stat & LCD_END_OF_FRAME1) {
@ linux-3.12.36-rt50-r4s2/drivers/video/da8xx-fb.c:906 @ static irqreturn_t lcdc_irq_handler_rev0
 				   LCD_DMA_FRM_BUF_CEILING_ADDR_1_REG);
 			par->vsync_flag = 1;
 			wake_up_interruptible(&par->vsync_wait);
+			if (vsync_cb_handler)
+				vsync_cb_handler(vsync_cb_arg);
 		}
 
 		/* Set only when controller is disabled and at the end of
Index: linux-3.12.36-rt50-r4s2/include/video/da8xx-fb.h
===================================================================
--- linux-3.12.36-rt50-r4s2.orig/include/video/da8xx-fb.h
+++ linux-3.12.36-rt50-r4s2/include/video/da8xx-fb.h
@ linux-3.12.36-rt50-r4s2/drivers/video/da8xx-fb.c:94 @ struct lcd_sync_arg {
 /* Proprietary FB_SYNC_ flags */
 #define FB_SYNC_CLK_INVERT 0x40000000
 
+typedef void (*vsync_callback_t)(void *arg);
+int register_vsync_cb(vsync_callback_t handler, void *arg, int idx);
+int unregister_vsync_cb(vsync_callback_t handler, void *arg, int idx);
+
 #endif  /* ifndef DA8XX_FB_H */