video: da8xx-fb: Add API to register wait for vsync callback
authorManjunathappa, Prakash <prakash.pm@ti.com>
Tue, 23 Aug 2011 09:42:36 +0000 (15:12 +0530)
committerVaibhav Hiremath <hvaibhav@ti.com>
Mon, 23 Jan 2012 19:13:56 +0000 (00:43 +0530)
This patch adds APIs to register and unregister wait for vsync
callback.

Signed-off-by: Manjunathappa, Prakash <prakash.pm@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
drivers/video/da8xx-fb.c
include/video/da8xx-fb.h

index 56badc0ecac689952ede99f5a674b71bdea593b1..d6792bd04b5c1eee0ad8f4c78016969b152f1d7a 100644 (file)
@@ -212,6 +212,9 @@ struct da8xx_panel {
        unsigned char   invert_pxl_clk; /* Invert Pixel clock */
 };
 
+static vsync_callback_t vsync_cb_handler;
+static void *vsync_cb_arg;
+
 static struct da8xx_panel known_lcd_panels[] = {
        /* Sharp LCD035Q3DG01 */
        [0] = {
@@ -724,6 +727,32 @@ static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config *cfg,
        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_handler = handler;
+               vsync_cb_arg = arg;
+       } 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)
 {
@@ -765,6 +794,8 @@ static irqreturn_t lcdc_irq_handler_rev02(int irq, void *arg)
                                   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) {
@@ -774,6 +805,8 @@ static irqreturn_t lcdc_irq_handler_rev02(int irq, void *arg)
                                   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);
                }
        }
 
index 9805905d299e0cc67052a79a35e05b9e1adbf56f..6a6a69fdd310e493be8809bc0e5b72dc51d4caac 100644 (file)
@@ -104,5 +104,9 @@ struct lcd_sync_arg {
 #define FBIPUT_HSYNC           _IOW('F', 9, int)
 #define FBIPUT_VSYNC           _IOW('F', 10, int)
 
+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 */