Commit | Line | Data |
---|---|---|
9ad5897c | 1 | /* |
91773a00 | 2 | * File: drivers/video/omap/omapfb.h |
9ad5897c TL |
3 | * |
4 | * Framebuffer driver for TI OMAP boards | |
5 | * | |
6 | * Copyright (C) 2004 Nokia Corporation | |
7 | * Author: Imre Deak <imre.deak@nokia.com> | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify it | |
10 | * under the terms of the GNU General Public License as published by the | |
11 | * Free Software Foundation; either version 2 of the License, or (at your | |
12 | * option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, but | |
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | * General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License along | |
20 | * with this program; if not, write to the Free Software Foundation, Inc., | |
21 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
22 | */ | |
23 | ||
24 | #ifndef __OMAPFB_H | |
25 | #define __OMAPFB_H | |
26 | ||
9ad5897c | 27 | #include <linux/fb.h> |
0dc5e77c | 28 | #include <linux/mutex.h> |
91773a00 | 29 | #include <linux/omapfb.h> |
0dc5e77c | 30 | |
91773a00 TV |
31 | #define OMAPFB_EVENT_READY 1 |
32 | #define OMAPFB_EVENT_DISABLED 2 | |
9ad5897c TL |
33 | |
34 | #define OMAP_LCDC_INV_VSYNC 0x0001 | |
35 | #define OMAP_LCDC_INV_HSYNC 0x0002 | |
36 | #define OMAP_LCDC_INV_PIX_CLOCK 0x0004 | |
37 | #define OMAP_LCDC_INV_OUTPUT_EN 0x0008 | |
38 | #define OMAP_LCDC_HSVS_RISING_EDGE 0x0010 | |
39 | #define OMAP_LCDC_HSVS_OPPOSITE 0x0020 | |
40 | ||
41 | #define OMAP_LCDC_SIGNAL_MASK 0x003f | |
42 | ||
43 | #define OMAP_LCDC_PANEL_TFT 0x0100 | |
44 | ||
f4e4c324 TL |
45 | #define OMAPFB_PLANE_XRES_MIN 8 |
46 | #define OMAPFB_PLANE_YRES_MIN 8 | |
47 | ||
9ad5897c TL |
48 | struct omapfb_device; |
49 | ||
8f5e35a7 | 50 | #define OMAPFB_PLANE_NUM 1 |
8f5e35a7 TV |
51 | |
52 | struct omapfb_mem_region { | |
53 | u32 paddr; | |
54 | void __iomem *vaddr; | |
55 | unsigned long size; | |
56 | u8 type; /* OMAPFB_PLANE_MEM_* */ | |
57 | enum omapfb_color_format format;/* OMAPFB_COLOR_* */ | |
58 | unsigned format_used:1; /* Must be set when format is set. | |
59 | * Needed b/c of the badly chosen 0 | |
60 | * base for OMAPFB_COLOR_* values | |
61 | */ | |
62 | unsigned alloc:1; /* allocated by the driver */ | |
63 | unsigned map:1; /* kernel mapped by the driver */ | |
64 | }; | |
65 | ||
66 | struct omapfb_mem_desc { | |
67 | int region_cnt; | |
68 | struct omapfb_mem_region region[OMAPFB_PLANE_NUM]; | |
69 | }; | |
70 | ||
9ad5897c TL |
71 | struct lcd_panel { |
72 | const char *name; | |
73 | int config; /* TFT/STN, signal inversion */ | |
74 | int bpp; /* Pixel format in fb mem */ | |
75 | int data_lines; /* Lines on LCD HW interface */ | |
76 | ||
77 | int x_res, y_res; | |
78 | int pixel_clock; /* In kHz */ | |
79 | int hsw; /* Horizontal synchronization | |
80 | pulse width */ | |
81 | int hfp; /* Horizontal front porch */ | |
82 | int hbp; /* Horizontal back porch */ | |
83 | int vsw; /* Vertical synchronization | |
84 | pulse width */ | |
85 | int vfp; /* Vertical front porch */ | |
86 | int vbp; /* Vertical back porch */ | |
87 | int acb; /* ac-bias pin frequency */ | |
88 | int pcd; /* pixel clock divider. | |
89 | Obsolete use pixel_clock instead */ | |
90 | ||
f4e4c324 TL |
91 | int (*init) (struct lcd_panel *panel, |
92 | struct omapfb_device *fbdev); | |
93 | void (*cleanup) (struct lcd_panel *panel); | |
94 | int (*enable) (struct lcd_panel *panel); | |
95 | void (*disable) (struct lcd_panel *panel); | |
96 | unsigned long (*get_caps) (struct lcd_panel *panel); | |
97 | int (*set_bklight_level)(struct lcd_panel *panel, | |
98 | unsigned int level); | |
99 | unsigned int (*get_bklight_level)(struct lcd_panel *panel); | |
100 | unsigned int (*get_bklight_max) (struct lcd_panel *panel); | |
101 | int (*run_test) (struct lcd_panel *panel, int test_num); | |
9ad5897c TL |
102 | }; |
103 | ||
9ad5897c TL |
104 | struct extif_timings { |
105 | int cs_on_time; | |
106 | int cs_off_time; | |
107 | int we_on_time; | |
108 | int we_off_time; | |
109 | int re_on_time; | |
110 | int re_off_time; | |
111 | int we_cycle_time; | |
112 | int re_cycle_time; | |
113 | int cs_pulse_width; | |
114 | int access_time; | |
0dc5e77c TL |
115 | |
116 | int clk_div; | |
117 | ||
118 | u32 tim[5]; /* set by extif->convert_timings */ | |
119 | ||
120 | int converted; | |
9ad5897c TL |
121 | }; |
122 | ||
123 | struct lcd_ctrl_extif { | |
f4e4c324 | 124 | int (*init) (struct omapfb_device *fbdev); |
9ad5897c | 125 | void (*cleanup) (void); |
0dc5e77c | 126 | void (*get_clk_info) (u32 *clk_period, u32 *max_clk_div); |
b01d96d6 | 127 | unsigned long (*get_max_tx_rate)(void); |
0dc5e77c | 128 | int (*convert_timings) (struct extif_timings *timings); |
9ad5897c | 129 | void (*set_timings) (const struct extif_timings *timings); |
0dc5e77c TL |
130 | void (*set_bits_per_cycle)(int bpc); |
131 | void (*write_command) (const void *buf, unsigned int len); | |
132 | void (*read_data) (void *buf, unsigned int len); | |
133 | void (*write_data) (const void *buf, unsigned int len); | |
9ad5897c | 134 | void (*transfer_area) (int width, int height, |
91773a00 | 135 | void (callback)(void *data), void *data); |
b01d96d6 KS |
136 | int (*setup_tearsync) (unsigned pin_cnt, |
137 | unsigned hs_pulse_time, unsigned vs_pulse_time, | |
138 | int hs_pol_inv, int vs_pol_inv, int div); | |
139 | int (*enable_tearsync) (int enable, unsigned line); | |
f4e4c324 | 140 | |
0dc5e77c | 141 | unsigned long max_transmit_size; |
9ad5897c TL |
142 | }; |
143 | ||
0dc5e77c TL |
144 | struct omapfb_notifier_block { |
145 | struct notifier_block nb; | |
146 | void *data; | |
f4e4c324 | 147 | int plane_idx; |
0dc5e77c TL |
148 | }; |
149 | ||
f4e4c324 TL |
150 | typedef int (*omapfb_notifier_callback_t)(struct notifier_block *, |
151 | unsigned long event, | |
152 | void *fbi); | |
153 | ||
9ad5897c TL |
154 | struct lcd_ctrl { |
155 | const char *name; | |
156 | void *data; | |
157 | ||
158 | int (*init) (struct omapfb_device *fbdev, | |
f4e4c324 TL |
159 | int ext_mode, |
160 | struct omapfb_mem_desc *req_md); | |
9ad5897c | 161 | void (*cleanup) (void); |
0dc5e77c | 162 | void (*bind_client) (struct omapfb_notifier_block *nb); |
b01d96d6 | 163 | void (*get_caps) (int plane, struct omapfb_caps *caps); |
9ad5897c TL |
164 | int (*set_update_mode)(enum omapfb_update_mode mode); |
165 | enum omapfb_update_mode (*get_update_mode)(void); | |
166 | int (*setup_plane) (int plane, int channel_out, | |
167 | unsigned long offset, | |
168 | int screen_width, | |
169 | int pos_x, int pos_y, int width, | |
170 | int height, int color_mode); | |
646e3ed1 | 171 | int (*set_rotate) (int angle); |
b01d96d6 KS |
172 | int (*setup_mem) (int plane, size_t size, |
173 | int mem_type, unsigned long *paddr); | |
174 | int (*mmap) (struct fb_info *info, | |
175 | struct vm_area_struct *vma); | |
f4e4c324 TL |
176 | int (*set_scale) (int plane, |
177 | int orig_width, int orig_height, | |
178 | int out_width, int out_height); | |
9ad5897c | 179 | int (*enable_plane) (int plane, int enable); |
f4e4c324 TL |
180 | int (*update_window) (struct fb_info *fbi, |
181 | struct omapfb_update_window *win, | |
9ad5897c TL |
182 | void (*callback)(void *), |
183 | void *callback_data); | |
184 | void (*sync) (void); | |
185 | void (*suspend) (void); | |
186 | void (*resume) (void); | |
187 | int (*run_test) (int test_num); | |
188 | int (*setcolreg) (u_int regno, u16 red, u16 green, | |
189 | u16 blue, u16 transp, | |
190 | int update_hw_mem); | |
191 | int (*set_color_key) (struct omapfb_color_key *ck); | |
f4e4c324 | 192 | int (*get_color_key) (struct omapfb_color_key *ck); |
9ad5897c TL |
193 | }; |
194 | ||
195 | enum omapfb_state { | |
91773a00 TV |
196 | OMAPFB_DISABLED = 0, |
197 | OMAPFB_SUSPENDED = 99, | |
198 | OMAPFB_ACTIVE = 100 | |
9ad5897c TL |
199 | }; |
200 | ||
f4e4c324 TL |
201 | struct omapfb_plane_struct { |
202 | int idx; | |
203 | struct omapfb_plane_info info; | |
204 | enum omapfb_color_format color_mode; | |
205 | struct omapfb_device *fbdev; | |
206 | }; | |
207 | ||
9ad5897c TL |
208 | struct omapfb_device { |
209 | int state; | |
91773a00 TV |
210 | int ext_lcdc; /* Using external |
211 | LCD controller */ | |
0dc5e77c | 212 | struct mutex rqueue_mutex; |
9ad5897c | 213 | |
9ad5897c | 214 | int palette_size; |
9ad5897c TL |
215 | u32 pseudo_palette[17]; |
216 | ||
217 | struct lcd_panel *panel; /* LCD panel */ | |
020f9706 RK |
218 | const struct lcd_ctrl *ctrl; /* LCD controller */ |
219 | const struct lcd_ctrl *int_ctrl; /* internal LCD ctrl */ | |
9ad5897c TL |
220 | struct lcd_ctrl_extif *ext_if; /* LCD ctrl external |
221 | interface */ | |
9ad5897c | 222 | struct device *dev; |
b01d96d6 | 223 | struct fb_var_screeninfo new_var; /* for mode changes */ |
f4e4c324 TL |
224 | |
225 | struct omapfb_mem_desc mem_desc; | |
226 | struct fb_info *fb_info[OMAPFB_PLANE_NUM]; | |
f778a12d TV |
227 | |
228 | struct platform_device *dssdev; /* dummy dev for clocks */ | |
9ad5897c TL |
229 | }; |
230 | ||
9ad5897c | 231 | extern struct lcd_ctrl omap1_lcd_ctrl; |
9ad5897c | 232 | |
0dc5e77c | 233 | extern void omapfb_register_panel(struct lcd_panel *panel); |
9ad5897c | 234 | extern void omapfb_write_first_pixel(struct omapfb_device *fbdev, u16 pixval); |
0dc5e77c TL |
235 | extern void omapfb_notify_clients(struct omapfb_device *fbdev, |
236 | unsigned long event); | |
237 | extern int omapfb_register_client(struct omapfb_notifier_block *nb, | |
f4e4c324 TL |
238 | omapfb_notifier_callback_t callback, |
239 | void *callback_data); | |
0dc5e77c | 240 | extern int omapfb_unregister_client(struct omapfb_notifier_block *nb); |
f4e4c324 TL |
241 | extern int omapfb_update_window_async(struct fb_info *fbi, |
242 | struct omapfb_update_window *win, | |
243 | void (*callback)(void *), | |
244 | void *callback_data); | |
0dc5e77c | 245 | |
9ad5897c | 246 | #endif /* __OMAPFB_H */ |