blob: 4ba2622cc142803422a20cda69f4bad5076ebfd6 [file] [log] [blame]
Tony Lindgren9ad58972005-11-10 14:26:53 +00001/*
2 * File: include/asm-arm/arch-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/* IOCTL commands. */
28
29#define OMAP_IOW(num, dtype) _IOW('O', num, dtype)
30#define OMAP_IOR(num, dtype) _IOR('O', num, dtype)
31#define OMAP_IOWR(num, dtype) _IOWR('O', num, dtype)
32#define OMAP_IO(num) _IO('O', num)
33
34#define OMAPFB_MIRROR OMAP_IOW(31, int)
35#define OMAPFB_SYNC_GFX OMAP_IO(37)
36#define OMAPFB_VSYNC OMAP_IO(38)
37#define OMAPFB_SET_UPDATE_MODE OMAP_IOW(40, enum omapfb_update_mode)
38#define OMAPFB_GET_CAPS OMAP_IOR(42, unsigned long)
39#define OMAPFB_GET_UPDATE_MODE OMAP_IOW(43, enum omapfb_update_mode)
40#define OMAPFB_LCD_TEST OMAP_IOW(45, int)
41#define OMAPFB_CTRL_TEST OMAP_IOW(46, int)
42#define OMAPFB_UPDATE_WINDOW OMAP_IOW(47, struct omapfb_update_window)
43#define OMAPFB_SETUP_PLANE OMAP_IOW(48, struct omapfb_setup_plane)
44#define OMAPFB_ENABLE_PLANE OMAP_IOW(49, struct omapfb_enable_plane)
45#define OMAPFB_SET_COLOR_KEY OMAP_IOW(50, struct omapfb_color_key)
46
47#define OMAPFB_CAPS_GENERIC_MASK 0x00000fff
48#define OMAPFB_CAPS_LCDC_MASK 0x00fff000
49#define OMAPFB_CAPS_PANEL_MASK 0xff000000
50
51#define OMAPFB_CAPS_MANUAL_UPDATE 0x00001000
52#define OMAPFB_CAPS_SET_BACKLIGHT 0x01000000
53
54/* Values from DSP must map to lower 16-bits */
55#define OMAPFB_FORMAT_MASK 0x00ff
56#define OMAPFB_FORMAT_FLAG_DOUBLE 0x0100
57
58enum omapfb_color_format {
59 OMAPFB_COLOR_RGB565 = 0,
60 OMAPFB_COLOR_YUV422,
61 OMAPFB_COLOR_YUV420,
62 OMAPFB_COLOR_CLUT_8BPP,
63 OMAPFB_COLOR_CLUT_4BPP,
64 OMAPFB_COLOR_CLUT_2BPP,
65 OMAPFB_COLOR_CLUT_1BPP,
66};
67
68struct omapfb_update_window {
69 u32 x, y;
70 u32 width, height;
71 u32 format;
72};
73
74enum omapfb_plane {
75 OMAPFB_PLANE_GFX = 0,
76 OMAPFB_PLANE_VID1,
77 OMAPFB_PLANE_VID2,
78};
79
80enum omapfb_channel_out {
81 OMAPFB_CHANNEL_OUT_LCD = 0,
82 OMAPFB_CHANNEL_OUT_DIGIT,
83};
84
85struct omapfb_setup_plane {
86 u8 plane;
87 u8 channel_out;
88 u32 offset;
89 u32 pos_x, pos_y;
90 u32 width, height;
91 u32 color_mode;
92};
93
94struct omapfb_enable_plane {
95 u8 plane;
96 u8 enable;
97};
98
99enum omapfb_color_key_type {
100 OMAPFB_COLOR_KEY_DISABLED = 0,
101 OMAPFB_COLOR_KEY_GFX_DST,
102 OMAPFB_COLOR_KEY_VID_SRC,
103};
104
105struct omapfb_color_key {
106 u8 channel_out;
107 u32 background;
108 u32 trans_key;
109 u8 key_type;
110};
111
112enum omapfb_update_mode {
113 OMAPFB_UPDATE_DISABLED = 0,
114 OMAPFB_AUTO_UPDATE,
115 OMAPFB_MANUAL_UPDATE
116};
117
118#ifdef __KERNEL__
119
120#include <linux/completion.h>
121#include <linux/interrupt.h>
122#include <linux/fb.h>
123
124#define OMAP_LCDC_INV_VSYNC 0x0001
125#define OMAP_LCDC_INV_HSYNC 0x0002
126#define OMAP_LCDC_INV_PIX_CLOCK 0x0004
127#define OMAP_LCDC_INV_OUTPUT_EN 0x0008
128#define OMAP_LCDC_HSVS_RISING_EDGE 0x0010
129#define OMAP_LCDC_HSVS_OPPOSITE 0x0020
130
131#define OMAP_LCDC_SIGNAL_MASK 0x003f
132
133#define OMAP_LCDC_PANEL_TFT 0x0100
134
135#ifdef CONFIG_ARCH_OMAP1
136#define OMAPFB_PLANE_NUM 1
137#else
138#define OMAPFB_PLANE_NUM 3
139#endif
140
141struct omapfb_device;
142
143struct lcd_panel {
144 const char *name;
145 int config; /* TFT/STN, signal inversion */
146 int bpp; /* Pixel format in fb mem */
147 int data_lines; /* Lines on LCD HW interface */
148
149 int x_res, y_res;
150 int pixel_clock; /* In kHz */
151 int hsw; /* Horizontal synchronization
152 pulse width */
153 int hfp; /* Horizontal front porch */
154 int hbp; /* Horizontal back porch */
155 int vsw; /* Vertical synchronization
156 pulse width */
157 int vfp; /* Vertical front porch */
158 int vbp; /* Vertical back porch */
159 int acb; /* ac-bias pin frequency */
160 int pcd; /* pixel clock divider.
161 Obsolete use pixel_clock instead */
162
163 int (*init) (struct omapfb_device *fbdev);
164 void (*cleanup) (void);
165 int (*enable) (void);
166 void (*disable) (void);
167 unsigned long (*get_caps) (void);
168 int (*set_bklight_level)(unsigned int level);
169 unsigned int (*get_bklight_level)(void);
170 unsigned int (*get_bklight_max) (void);
171 int (*run_test) (int test_num);
172};
173
174struct omapfb_device;
175
176struct extif_timings {
177 int cs_on_time;
178 int cs_off_time;
179 int we_on_time;
180 int we_off_time;
181 int re_on_time;
182 int re_off_time;
183 int we_cycle_time;
184 int re_cycle_time;
185 int cs_pulse_width;
186 int access_time;
187};
188
189struct lcd_ctrl_extif {
190 int (*init) (void);
191 void (*cleanup) (void);
192 void (*set_timings) (const struct extif_timings *timings);
193 void (*write_command) (u32 cmd);
194 u32 (*read_data) (void);
195 void (*write_data) (u32 data);
196 void (*transfer_area) (int width, int height,
197 void (callback)(void * data), void *data);
198};
199
200struct lcd_ctrl {
201 const char *name;
202 void *data;
203
204 int (*init) (struct omapfb_device *fbdev,
205 int ext_mode, int req_vram_size);
206 void (*cleanup) (void);
207 void (*get_vram_layout)(unsigned long *size,
208 void **virt_base,
209 dma_addr_t *phys_base);
210 unsigned long (*get_caps) (void);
211 int (*set_update_mode)(enum omapfb_update_mode mode);
212 enum omapfb_update_mode (*get_update_mode)(void);
213 int (*setup_plane) (int plane, int channel_out,
214 unsigned long offset,
215 int screen_width,
216 int pos_x, int pos_y, int width,
217 int height, int color_mode);
218 int (*enable_plane) (int plane, int enable);
219 int (*update_window) (struct omapfb_update_window *win,
220 void (*callback)(void *),
221 void *callback_data);
222 void (*sync) (void);
223 void (*suspend) (void);
224 void (*resume) (void);
225 int (*run_test) (int test_num);
226 int (*setcolreg) (u_int regno, u16 red, u16 green,
227 u16 blue, u16 transp,
228 int update_hw_mem);
229 int (*set_color_key) (struct omapfb_color_key *ck);
230
231};
232
233enum omapfb_state {
234 OMAPFB_DISABLED = 0,
235 OMAPFB_SUSPENDED= 99,
236 OMAPFB_ACTIVE = 100
237};
238
239struct omapfb_device {
240 int state;
241 int ext_lcdc; /* Using external
242 LCD controller */
243 struct semaphore rqueue_sema;
244
245 void *vram_virt_base;
246 dma_addr_t vram_phys_base;
247 unsigned long vram_size;
248
249 int color_mode;
250 int palette_size;
251 int mirror;
252 u32 pseudo_palette[17];
253
254 struct lcd_panel *panel; /* LCD panel */
255 struct lcd_ctrl *ctrl; /* LCD controller */
256 struct lcd_ctrl *int_ctrl; /* internal LCD ctrl */
257 struct lcd_ctrl_extif *ext_if; /* LCD ctrl external
258 interface */
259 struct fb_info *fb_info;
260
261 struct device *dev;
262};
263
264extern struct lcd_panel h3_panel;
265extern struct lcd_panel h2_panel;
266extern struct lcd_panel p2_panel;
267extern struct lcd_panel osk_panel;
268extern struct lcd_panel innovator1610_panel;
269extern struct lcd_panel innovator1510_panel;
270
271#ifdef CONFIG_ARCH_OMAP1
272extern struct lcd_ctrl omap1_lcd_ctrl;
273#else
274extern struct lcd_ctrl omap2_disp_ctrl;
275#endif
276
277extern void omapfb_write_first_pixel(struct omapfb_device *fbdev, u16 pixval);
278
279#endif /* __KERNEL__ */
280
281#endif /* __OMAPFB_H */