1
2
3
4
5
6
7
8
9
10
11 #ifndef __OMAPFB_H
12 #define __OMAPFB_H
13
14 #include <linux/fb.h>
15 #include <linux/mutex.h>
16 #include <linux/omapfb.h>
17
18 #define OMAPFB_EVENT_READY 1
19 #define OMAPFB_EVENT_DISABLED 2
20
21 #define OMAP_LCDC_INV_VSYNC 0x0001
22 #define OMAP_LCDC_INV_HSYNC 0x0002
23 #define OMAP_LCDC_INV_PIX_CLOCK 0x0004
24 #define OMAP_LCDC_INV_OUTPUT_EN 0x0008
25 #define OMAP_LCDC_HSVS_RISING_EDGE 0x0010
26 #define OMAP_LCDC_HSVS_OPPOSITE 0x0020
27
28 #define OMAP_LCDC_SIGNAL_MASK 0x003f
29
30 #define OMAP_LCDC_PANEL_TFT 0x0100
31
32 #define OMAPFB_PLANE_XRES_MIN 8
33 #define OMAPFB_PLANE_YRES_MIN 8
34
35 struct omapfb_device;
36
37 #define OMAPFB_PLANE_NUM 1
38
39 struct omapfb_mem_region {
40 u32 paddr;
41 void __iomem *vaddr;
42 unsigned long size;
43 u8 type;
44 enum omapfb_color_format format;
45 unsigned format_used:1;
46
47
48
49 unsigned alloc:1;
50 unsigned map:1;
51 };
52
53 struct omapfb_mem_desc {
54 int region_cnt;
55 struct omapfb_mem_region region[OMAPFB_PLANE_NUM];
56 };
57
58 struct lcd_panel {
59 const char *name;
60 int config;
61 int bpp;
62 int data_lines;
63
64 int x_res, y_res;
65 int pixel_clock;
66 int hsw;
67
68 int hfp;
69 int hbp;
70 int vsw;
71
72 int vfp;
73 int vbp;
74 int acb;
75 int pcd;
76
77
78 int (*init) (struct lcd_panel *panel,
79 struct omapfb_device *fbdev);
80 void (*cleanup) (struct lcd_panel *panel);
81 int (*enable) (struct lcd_panel *panel);
82 void (*disable) (struct lcd_panel *panel);
83 unsigned long (*get_caps) (struct lcd_panel *panel);
84 int (*set_bklight_level)(struct lcd_panel *panel,
85 unsigned int level);
86 unsigned int (*get_bklight_level)(struct lcd_panel *panel);
87 unsigned int (*get_bklight_max) (struct lcd_panel *panel);
88 int (*run_test) (struct lcd_panel *panel, int test_num);
89 };
90
91 struct extif_timings {
92 int cs_on_time;
93 int cs_off_time;
94 int we_on_time;
95 int we_off_time;
96 int re_on_time;
97 int re_off_time;
98 int we_cycle_time;
99 int re_cycle_time;
100 int cs_pulse_width;
101 int access_time;
102
103 int clk_div;
104
105 u32 tim[5];
106
107 int converted;
108 };
109
110 struct lcd_ctrl_extif {
111 int (*init) (struct omapfb_device *fbdev);
112 void (*cleanup) (void);
113 void (*get_clk_info) (u32 *clk_period, u32 *max_clk_div);
114 unsigned long (*get_max_tx_rate)(void);
115 int (*convert_timings) (struct extif_timings *timings);
116 void (*set_timings) (const struct extif_timings *timings);
117 void (*set_bits_per_cycle)(int bpc);
118 void (*write_command) (const void *buf, unsigned int len);
119 void (*read_data) (void *buf, unsigned int len);
120 void (*write_data) (const void *buf, unsigned int len);
121 void (*transfer_area) (int width, int height,
122 void (callback)(void *data), void *data);
123 int (*setup_tearsync) (unsigned pin_cnt,
124 unsigned hs_pulse_time, unsigned vs_pulse_time,
125 int hs_pol_inv, int vs_pol_inv, int div);
126 int (*enable_tearsync) (int enable, unsigned line);
127
128 unsigned long max_transmit_size;
129 };
130
131 struct omapfb_notifier_block {
132 struct notifier_block nb;
133 void *data;
134 int plane_idx;
135 };
136
137 typedef int (*omapfb_notifier_callback_t)(struct notifier_block *,
138 unsigned long event,
139 void *fbi);
140
141 struct lcd_ctrl {
142 const char *name;
143 void *data;
144
145 int (*init) (struct omapfb_device *fbdev,
146 int ext_mode,
147 struct omapfb_mem_desc *req_md);
148 void (*cleanup) (void);
149 void (*bind_client) (struct omapfb_notifier_block *nb);
150 void (*get_caps) (int plane, struct omapfb_caps *caps);
151 int (*set_update_mode)(enum omapfb_update_mode mode);
152 enum omapfb_update_mode (*get_update_mode)(void);
153 int (*setup_plane) (int plane, int channel_out,
154 unsigned long offset,
155 int screen_width,
156 int pos_x, int pos_y, int width,
157 int height, int color_mode);
158 int (*set_rotate) (int angle);
159 int (*setup_mem) (int plane, size_t size,
160 int mem_type, unsigned long *paddr);
161 int (*mmap) (struct fb_info *info,
162 struct vm_area_struct *vma);
163 int (*set_scale) (int plane,
164 int orig_width, int orig_height,
165 int out_width, int out_height);
166 int (*enable_plane) (int plane, int enable);
167 int (*update_window) (struct fb_info *fbi,
168 struct omapfb_update_window *win,
169 void (*callback)(void *),
170 void *callback_data);
171 void (*sync) (void);
172 void (*suspend) (void);
173 void (*resume) (void);
174 int (*run_test) (int test_num);
175 int (*setcolreg) (u_int regno, u16 red, u16 green,
176 u16 blue, u16 transp,
177 int update_hw_mem);
178 int (*set_color_key) (struct omapfb_color_key *ck);
179 int (*get_color_key) (struct omapfb_color_key *ck);
180 };
181
182 enum omapfb_state {
183 OMAPFB_DISABLED = 0,
184 OMAPFB_SUSPENDED = 99,
185 OMAPFB_ACTIVE = 100
186 };
187
188 struct omapfb_plane_struct {
189 int idx;
190 struct omapfb_plane_info info;
191 enum omapfb_color_format color_mode;
192 struct omapfb_device *fbdev;
193 };
194
195 struct omapfb_device {
196 int state;
197 int ext_lcdc;
198
199 struct mutex rqueue_mutex;
200
201 int palette_size;
202 u32 pseudo_palette[17];
203
204 struct lcd_panel *panel;
205 const struct lcd_ctrl *ctrl;
206 const struct lcd_ctrl *int_ctrl;
207 struct lcd_ctrl_extif *ext_if;
208
209 struct device *dev;
210 struct fb_var_screeninfo new_var;
211
212 struct omapfb_mem_desc mem_desc;
213 struct fb_info *fb_info[OMAPFB_PLANE_NUM];
214
215 struct platform_device *dssdev;
216 };
217
218 extern struct lcd_ctrl omap1_lcd_ctrl;
219
220 extern void omapfb_register_panel(struct lcd_panel *panel);
221 extern void omapfb_write_first_pixel(struct omapfb_device *fbdev, u16 pixval);
222 extern void omapfb_notify_clients(struct omapfb_device *fbdev,
223 unsigned long event);
224 extern int omapfb_register_client(struct omapfb_notifier_block *nb,
225 omapfb_notifier_callback_t callback,
226 void *callback_data);
227 extern int omapfb_unregister_client(struct omapfb_notifier_block *nb);
228 extern int omapfb_update_window_async(struct fb_info *fbi,
229 struct omapfb_update_window *win,
230 void (*callback)(void *),
231 void *callback_data);
232
233 #endif