8c0898a9d626266e6c669f990e42c6c640549c99
[openwrt/openwrt.git] / target / linux / omap / patches-4.1 / 0343-video-da8xx-fb-Add-API-to-register-wait-for-vsync-ca.patch
1 From 9a1a810516ae9cb3259b898b6879901c5b44fa90 Mon Sep 17 00:00:00 2001
2 From: Prathap M S <msprathap@ti.com>
3 Date: Mon, 2 Sep 2013 12:05:23 +0530
4 Subject: [PATCH 343/752] video: da8xx-fb: Add API to register wait for vsync
5 callback
6
7 This patch adds APIs to register and unregister wait for vsync callback.
8 This is derived from commit id 2d44302545da24fd22912d964102bc31a7489e97
9 This commit id was part of 3.2 kernel sources.
10
11 Signed-off-by: Prathap M S <msprathap@ti.com>
12 ---
13 drivers/video/fbdev/da8xx-fb.c | 33 +++++++++++++++++++++++++++++++++
14 include/video/da8xx-fb.h | 4 ++++
15 2 files changed, 37 insertions(+)
16
17 --- a/drivers/video/fbdev/da8xx-fb.c
18 +++ b/drivers/video/fbdev/da8xx-fb.c
19 @@ -197,6 +197,9 @@ static struct fb_fix_screeninfo da8xx_fb
20 .accel = FB_ACCEL_NONE
21 };
22
23 +static vsync_callback_t vsync_cb_handler;
24 +static void *vsync_cb_arg;
25 +
26 static struct fb_videomode known_lcd_panels[] = {
27 /* Sharp LCD035Q3DG01 */
28 [0] = {
29 @@ -831,6 +834,32 @@ static int lcd_init(struct da8xx_fb_par
30 return 0;
31 }
32
33 +int register_vsync_cb(vsync_callback_t handler, void *arg, int idx)
34 +{
35 + if ((vsync_cb_handler == NULL) && (vsync_cb_arg == NULL)) {
36 + vsync_cb_arg = arg;
37 + vsync_cb_handler = handler;
38 + } else {
39 + return -EEXIST;
40 + }
41 +
42 + return 0;
43 +}
44 +EXPORT_SYMBOL(register_vsync_cb);
45 +
46 +int unregister_vsync_cb(vsync_callback_t handler, void *arg, int idx)
47 +{
48 + if ((vsync_cb_handler == handler) && (vsync_cb_arg == arg)) {
49 + vsync_cb_handler = NULL;
50 + vsync_cb_arg = NULL;
51 + } else {
52 + return -ENXIO;
53 + }
54 +
55 + return 0;
56 +}
57 +EXPORT_SYMBOL(unregister_vsync_cb);
58 +
59 /* IRQ handler for version 2 of LCDC */
60 static irqreturn_t lcdc_irq_handler_rev02(int irq, void *arg)
61 {
62 @@ -868,6 +897,8 @@ static irqreturn_t lcdc_irq_handler_rev0
63 LCD_DMA_FRM_BUF_CEILING_ADDR_0_REG);
64 par->vsync_flag = 1;
65 wake_up_interruptible(&par->vsync_wait);
66 + if (vsync_cb_handler)
67 + vsync_cb_handler(vsync_cb_arg);
68 }
69
70 if (stat & LCD_END_OF_FRAME1) {
71 @@ -943,6 +974,8 @@ static irqreturn_t lcdc_irq_handler_rev0
72 LCD_DMA_FRM_BUF_CEILING_ADDR_1_REG);
73 par->vsync_flag = 1;
74 wake_up_interruptible(&par->vsync_wait);
75 + if (vsync_cb_handler)
76 + vsync_cb_handler(vsync_cb_arg);
77 }
78 }
79
80 --- a/include/video/da8xx-fb.h
81 +++ b/include/video/da8xx-fb.h
82 @@ -91,5 +91,9 @@ struct lcd_sync_arg {
83 /* Proprietary FB_SYNC_ flags */
84 #define FB_SYNC_CLK_INVERT 0x40000000
85
86 +typedef void (*vsync_callback_t)(void *arg);
87 +int register_vsync_cb(vsync_callback_t handler, void *arg, int idx);
88 +int unregister_vsync_cb(vsync_callback_t handler, void *arg, int idx);
89 +
90 #endif /* ifndef DA8XX_FB_H */
91