blob: 07fe49878892c1e141d5fe6466d86588b4886613 [file] [log] [blame]
Tomi Valkeinen91773a02009-08-03 15:06:36 +03001/*
2 * File: drivers/video/omap/omapfb.h
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
27#include <linux/fb.h>
28#include <linux/mutex.h>
29#include <linux/omapfb.h>
30
31#define OMAPFB_EVENT_READY 1
32#define OMAPFB_EVENT_DISABLED 2
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
45#define OMAPFB_PLANE_XRES_MIN 8
46#define OMAPFB_PLANE_YRES_MIN 8
47
48struct omapfb_device;
49
Tomi Valkeinen8f5e35a2011-09-20 14:43:14 +030050#ifdef CONFIG_ARCH_OMAP1
51#define OMAPFB_PLANE_NUM 1
52#else
53#define OMAPFB_PLANE_NUM 3
54#endif
55
56struct omapfb_mem_region {
57 u32 paddr;
58 void __iomem *vaddr;
59 unsigned long size;
60 u8 type; /* OMAPFB_PLANE_MEM_* */
61 enum omapfb_color_format format;/* OMAPFB_COLOR_* */
62 unsigned format_used:1; /* Must be set when format is set.
63 * Needed b/c of the badly chosen 0
64 * base for OMAPFB_COLOR_* values
65 */
66 unsigned alloc:1; /* allocated by the driver */
67 unsigned map:1; /* kernel mapped by the driver */
68};
69
70struct omapfb_mem_desc {
71 int region_cnt;
72 struct omapfb_mem_region region[OMAPFB_PLANE_NUM];
73};
74
Tomi Valkeinen91773a02009-08-03 15:06:36 +030075struct lcd_panel {
76 const char *name;
77 int config; /* TFT/STN, signal inversion */
78 int bpp; /* Pixel format in fb mem */
79 int data_lines; /* Lines on LCD HW interface */
80
81 int x_res, y_res;
82 int pixel_clock; /* In kHz */
83 int hsw; /* Horizontal synchronization
84 pulse width */
85 int hfp; /* Horizontal front porch */
86 int hbp; /* Horizontal back porch */
87 int vsw; /* Vertical synchronization
88 pulse width */
89 int vfp; /* Vertical front porch */
90 int vbp; /* Vertical back porch */
91 int acb; /* ac-bias pin frequency */
92 int pcd; /* pixel clock divider.
93 Obsolete use pixel_clock instead */
94
95 int (*init) (struct lcd_panel *panel,
96 struct omapfb_device *fbdev);
97 void (*cleanup) (struct lcd_panel *panel);
98 int (*enable) (struct lcd_panel *panel);
99 void (*disable) (struct lcd_panel *panel);
100 unsigned long (*get_caps) (struct lcd_panel *panel);
101 int (*set_bklight_level)(struct lcd_panel *panel,
102 unsigned int level);
103 unsigned int (*get_bklight_level)(struct lcd_panel *panel);
104 unsigned int (*get_bklight_max) (struct lcd_panel *panel);
105 int (*run_test) (struct lcd_panel *panel, int test_num);
106};
107
108struct extif_timings {
109 int cs_on_time;
110 int cs_off_time;
111 int we_on_time;
112 int we_off_time;
113 int re_on_time;
114 int re_off_time;
115 int we_cycle_time;
116 int re_cycle_time;
117 int cs_pulse_width;
118 int access_time;
119
120 int clk_div;
121
122 u32 tim[5]; /* set by extif->convert_timings */
123
124 int converted;
125};
126
127struct lcd_ctrl_extif {
128 int (*init) (struct omapfb_device *fbdev);
129 void (*cleanup) (void);
130 void (*get_clk_info) (u32 *clk_period, u32 *max_clk_div);
131 unsigned long (*get_max_tx_rate)(void);
132 int (*convert_timings) (struct extif_timings *timings);
133 void (*set_timings) (const struct extif_timings *timings);
134 void (*set_bits_per_cycle)(int bpc);
135 void (*write_command) (const void *buf, unsigned int len);
136 void (*read_data) (void *buf, unsigned int len);
137 void (*write_data) (const void *buf, unsigned int len);
138 void (*transfer_area) (int width, int height,
139 void (callback)(void *data), void *data);
140 int (*setup_tearsync) (unsigned pin_cnt,
141 unsigned hs_pulse_time, unsigned vs_pulse_time,
142 int hs_pol_inv, int vs_pol_inv, int div);
143 int (*enable_tearsync) (int enable, unsigned line);
144
145 unsigned long max_transmit_size;
146};
147
148struct omapfb_notifier_block {
149 struct notifier_block nb;
150 void *data;
151 int plane_idx;
152};
153
154typedef int (*omapfb_notifier_callback_t)(struct notifier_block *,
155 unsigned long event,
156 void *fbi);
157
158struct lcd_ctrl {
159 const char *name;
160 void *data;
161
162 int (*init) (struct omapfb_device *fbdev,
163 int ext_mode,
164 struct omapfb_mem_desc *req_md);
165 void (*cleanup) (void);
166 void (*bind_client) (struct omapfb_notifier_block *nb);
167 void (*get_caps) (int plane, struct omapfb_caps *caps);
168 int (*set_update_mode)(enum omapfb_update_mode mode);
169 enum omapfb_update_mode (*get_update_mode)(void);
170 int (*setup_plane) (int plane, int channel_out,
171 unsigned long offset,
172 int screen_width,
173 int pos_x, int pos_y, int width,
174 int height, int color_mode);
175 int (*set_rotate) (int angle);
176 int (*setup_mem) (int plane, size_t size,
177 int mem_type, unsigned long *paddr);
178 int (*mmap) (struct fb_info *info,
179 struct vm_area_struct *vma);
180 int (*set_scale) (int plane,
181 int orig_width, int orig_height,
182 int out_width, int out_height);
183 int (*enable_plane) (int plane, int enable);
184 int (*update_window) (struct fb_info *fbi,
185 struct omapfb_update_window *win,
186 void (*callback)(void *),
187 void *callback_data);
188 void (*sync) (void);
189 void (*suspend) (void);
190 void (*resume) (void);
191 int (*run_test) (int test_num);
192 int (*setcolreg) (u_int regno, u16 red, u16 green,
193 u16 blue, u16 transp,
194 int update_hw_mem);
195 int (*set_color_key) (struct omapfb_color_key *ck);
196 int (*get_color_key) (struct omapfb_color_key *ck);
197};
198
199enum omapfb_state {
200 OMAPFB_DISABLED = 0,
201 OMAPFB_SUSPENDED = 99,
202 OMAPFB_ACTIVE = 100
203};
204
205struct omapfb_plane_struct {
206 int idx;
207 struct omapfb_plane_info info;
208 enum omapfb_color_format color_mode;
209 struct omapfb_device *fbdev;
210};
211
212struct omapfb_device {
213 int state;
214 int ext_lcdc; /* Using external
215 LCD controller */
216 struct mutex rqueue_mutex;
217
218 int palette_size;
219 u32 pseudo_palette[17];
220
221 struct lcd_panel *panel; /* LCD panel */
222 const struct lcd_ctrl *ctrl; /* LCD controller */
223 const struct lcd_ctrl *int_ctrl; /* internal LCD ctrl */
224 struct lcd_ctrl_extif *ext_if; /* LCD ctrl external
225 interface */
226 struct device *dev;
227 struct fb_var_screeninfo new_var; /* for mode changes */
228
229 struct omapfb_mem_desc mem_desc;
230 struct fb_info *fb_info[OMAPFB_PLANE_NUM];
Tomi Valkeinenf778a122009-12-16 13:18:07 +0200231
232 struct platform_device *dssdev; /* dummy dev for clocks */
Tomi Valkeinen91773a02009-08-03 15:06:36 +0300233};
234
Tomi Valkeinen91773a02009-08-03 15:06:36 +0300235extern struct lcd_ctrl omap1_lcd_ctrl;
Tomi Valkeinen91773a02009-08-03 15:06:36 +0300236
237extern void omapfb_register_panel(struct lcd_panel *panel);
238extern void omapfb_write_first_pixel(struct omapfb_device *fbdev, u16 pixval);
239extern void omapfb_notify_clients(struct omapfb_device *fbdev,
240 unsigned long event);
241extern int omapfb_register_client(struct omapfb_notifier_block *nb,
242 omapfb_notifier_callback_t callback,
243 void *callback_data);
244extern int omapfb_unregister_client(struct omapfb_notifier_block *nb);
245extern int omapfb_update_window_async(struct fb_info *fbi,
246 struct omapfb_update_window *win,
247 void (*callback)(void *),
248 void *callback_data);
249
250#endif /* __OMAPFB_H */