Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6
[pandora-kernel.git] / drivers / staging / msm / msm_fb.h
1 /* Copyright (c) 2008-2009, Code Aurora Forum. All rights reserved.
2  *
3  * Redistribution and use in source and binary forms, with or without
4  * modification, are permitted provided that the following conditions are met:
5  *     * Redistributions of source code must retain the above copyright
6  *       notice, this list of conditions and the following disclaimer.
7  *     * Redistributions in binary form must reproduce the above copyright
8  *       notice, this list of conditions and the following disclaimer in the
9  *       documentation and/or other materials provided with the distribution.
10  *     * Neither the name of Code Aurora nor
11  *       the names of its contributors may be used to endorse or promote
12  *       products derived from this software without specific prior written
13  *       permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  */
28
29 #ifndef MSM_FB_H
30 #define MSM_FB_H
31
32 #include <linux/module.h>
33 #include <linux/kernel.h>
34 #include <linux/sched.h>
35 #include <linux/time.h>
36 #include <linux/init.h>
37 #include <linux/interrupt.h>
38 #include "linux/proc_fs.h"
39
40 #include <mach/hardware.h>
41 #include <linux/io.h>
42 #include <mach/board.h>
43
44 #include <asm/system.h>
45 #include <asm/mach-types.h>
46 #include <mach/memory.h>
47 #include <linux/semaphore.h>
48 #include <linux/spinlock.h>
49 #include <linux/workqueue.h>
50 #include <linux/hrtimer.h>
51
52 #include <linux/fb.h>
53
54 #ifdef CONFIG_HAS_EARLYSUSPEND
55 #include <linux/earlysuspend.h>
56 #endif
57
58 #include "msm_fb_panel.h"
59 #include "mdp.h"
60
61 #define MSM_FB_DEFAULT_PAGE_SIZE 2
62 #define MFD_KEY  0x11161126
63 #define MSM_FB_MAX_DEV_LIST 32
64
65 struct disp_info_type_suspend {
66         boolean op_enable;
67         boolean sw_refreshing_enable;
68         boolean panel_power_on;
69 };
70
71 struct msm_fb_data_type {
72         __u32 key;
73         __u32 index;
74         __u32 ref_cnt;
75         __u32 fb_page;
76
77         panel_id_type panel;
78         struct msm_panel_info panel_info;
79
80         DISP_TARGET dest;
81         struct fb_info *fbi;
82
83         boolean op_enable;
84         uint32 fb_imgType;
85         boolean sw_currently_refreshing;
86         boolean sw_refreshing_enable;
87         boolean hw_refresh;
88
89         MDPIBUF ibuf;
90         boolean ibuf_flushed;
91         struct timer_list refresh_timer;
92         struct completion refresher_comp;
93
94         boolean pan_waiting;
95         struct completion pan_comp;
96
97         /* vsync */
98         boolean use_mdp_vsync;
99         __u32 vsync_gpio;
100         __u32 total_lcd_lines;
101         __u32 total_porch_lines;
102         __u32 lcd_ref_usec_time;
103         __u32 refresh_timer_duration;
104
105         struct hrtimer dma_hrtimer;
106
107         boolean panel_power_on;
108         struct work_struct dma_update_worker;
109         struct semaphore sem;
110
111         struct timer_list vsync_resync_timer;
112         boolean vsync_handler_pending;
113         struct work_struct vsync_resync_worker;
114
115         ktime_t last_vsync_timetick;
116
117         __u32 *vsync_width_boundary;
118
119         unsigned int pmem_id;
120         struct disp_info_type_suspend suspend;
121
122         __u32 channel_irq;
123
124         struct mdp_dma_data *dma;
125         void (*dma_fnc) (struct msm_fb_data_type *mfd);
126         int (*cursor_update) (struct fb_info *info,
127                               struct fb_cursor *cursor);
128         int (*lut_update) (struct fb_info *info,
129                               struct fb_cmap *cmap);
130         int (*do_histogram) (struct fb_info *info,
131                               struct mdp_histogram *hist);
132         void *cursor_buf;
133         void *cursor_buf_phys;
134
135         void *cmd_port;
136         void *data_port;
137         void *data_port_phys;
138
139         __u32 bl_level;
140
141         struct platform_device *pdev;
142
143         __u32 var_xres;
144         __u32 var_yres;
145         __u32 var_pixclock;
146
147 #ifdef MSM_FB_ENABLE_DBGFS
148         struct dentry *sub_dir;
149 #endif
150
151 #ifdef CONFIG_HAS_EARLYSUSPEND
152         struct early_suspend early_suspend;
153         struct early_suspend mddi_early_suspend;
154         struct early_suspend mddi_ext_early_suspend;
155 #endif
156         u32 mdp_fb_page_protection;
157         int allow_set_offset;
158 };
159
160 struct dentry *msm_fb_get_debugfs_root(void);
161 void msm_fb_debugfs_file_create(struct dentry *root, const char *name,
162                                 u32 *var);
163 void msm_fb_set_backlight(struct msm_fb_data_type *mfd, __u32 bkl_lvl,
164                                 u32 save);
165
166 void msm_fb_add_device(struct platform_device *pdev);
167
168 int msm_fb_detect_client(const char *name);
169
170 #ifdef CONFIG_FB_BACKLIGHT
171 void msm_fb_config_backlight(struct msm_fb_data_type *mfd);
172 #endif
173
174 #endif /* MSM_FB_H */