fix gpio interrupt-cells property on AM335x
[openwrt/openwrt.git] / target / linux / omap / patches-3.12 / 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/da8xx-fb.c | 33 +++++++++++++++++++++++++++++++++
14 include/video/da8xx-fb.h | 4 ++++
15 2 files changed, 37 insertions(+)
16
17 diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
18 index c534d45..77dc477 100644
19 --- a/drivers/video/da8xx-fb.c
20 +++ b/drivers/video/da8xx-fb.c
21 @@ -235,6 +235,9 @@ static struct fb_fix_screeninfo da8xx_fb_fix = {
22 .accel = FB_ACCEL_NONE
23 };
24
25 +static vsync_callback_t vsync_cb_handler;
26 +static void *vsync_cb_arg;
27 +
28 static struct fb_videomode known_lcd_panels[] = {
29 /* Sharp LCD035Q3DG01 */
30 [0] = {
31 @@ -916,6 +919,32 @@ static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config *cfg,
32 return 0;
33 }
34
35 +int register_vsync_cb(vsync_callback_t handler, void *arg, int idx)
36 +{
37 + if ((vsync_cb_handler == NULL) && (vsync_cb_arg == NULL)) {
38 + vsync_cb_arg = arg;
39 + vsync_cb_handler = handler;
40 + } else {
41 + return -EEXIST;
42 + }
43 +
44 + return 0;
45 +}
46 +EXPORT_SYMBOL(register_vsync_cb);
47 +
48 +int unregister_vsync_cb(vsync_callback_t handler, void *arg, int idx)
49 +{
50 + if ((vsync_cb_handler == handler) && (vsync_cb_arg == arg)) {
51 + vsync_cb_handler = NULL;
52 + vsync_cb_arg = NULL;
53 + } else {
54 + return -ENXIO;
55 + }
56 +
57 + return 0;
58 +}
59 +EXPORT_SYMBOL(unregister_vsync_cb);
60 +
61 /* IRQ handler for version 2 of LCDC */
62 static irqreturn_t lcdc_irq_handler_rev02(int irq, void *arg)
63 {
64 @@ -953,6 +982,8 @@ static irqreturn_t lcdc_irq_handler_rev02(int irq, void *arg)
65 LCD_DMA_FRM_BUF_CEILING_ADDR_0_REG);
66 par->vsync_flag = 1;
67 wake_up_interruptible(&par->vsync_wait);
68 + if (vsync_cb_handler)
69 + vsync_cb_handler(vsync_cb_arg);
70 }
71
72 if (stat & LCD_END_OF_FRAME1) {
73 @@ -1028,6 +1059,8 @@ static irqreturn_t lcdc_irq_handler_rev01(int irq, void *arg)
74 LCD_DMA_FRM_BUF_CEILING_ADDR_1_REG);
75 par->vsync_flag = 1;
76 wake_up_interruptible(&par->vsync_wait);
77 + if (vsync_cb_handler)
78 + vsync_cb_handler(vsync_cb_arg);
79 }
80 }
81
82 diff --git a/include/video/da8xx-fb.h b/include/video/da8xx-fb.h
83 index 74c986a..2a0c739 100644
84 --- a/include/video/da8xx-fb.h
85 +++ b/include/video/da8xx-fb.h
86 @@ -106,5 +106,9 @@ void da8xx_register_encoder(struct da8xx_encoder *encoder);
87 void da8xx_unregister_encoder(struct da8xx_encoder *encoder);
88
89
90 +typedef void (*vsync_callback_t)(void *arg);
91 +int register_vsync_cb(vsync_callback_t handler, void *arg, int idx);
92 +int unregister_vsync_cb(vsync_callback_t handler, void *arg, int idx);
93 +
94 #endif /* ifndef DA8XX_FB_H */
95
96 --
97 1.7.10.4
98