[PATCH] Generic BUG for i386
[linux-2.6] / include / asm-arm / arch-omap / omapfb.h
1 /*
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, int)
38 #define OMAPFB_UPDATE_WINDOW_OLD OMAP_IOW(41, struct omapfb_update_window_old)
39 #define OMAPFB_GET_CAPS         OMAP_IOR(42, unsigned long)
40 #define OMAPFB_GET_UPDATE_MODE  OMAP_IOW(43, int)
41 #define OMAPFB_LCD_TEST         OMAP_IOW(45, int)
42 #define OMAPFB_CTRL_TEST        OMAP_IOW(46, int)
43 #define OMAPFB_UPDATE_WINDOW    OMAP_IOW(47, struct omapfb_update_window)
44 #define OMAPFB_SETUP_PLANE      OMAP_IOW(48, struct omapfb_setup_plane)
45 #define OMAPFB_ENABLE_PLANE     OMAP_IOW(49, struct omapfb_enable_plane)
46 #define OMAPFB_SET_COLOR_KEY    OMAP_IOW(50, struct omapfb_color_key)
47
48 #define OMAPFB_CAPS_GENERIC_MASK        0x00000fff
49 #define OMAPFB_CAPS_LCDC_MASK           0x00fff000
50 #define OMAPFB_CAPS_PANEL_MASK          0xff000000
51
52 #define OMAPFB_CAPS_MANUAL_UPDATE       0x00001000
53 #define OMAPFB_CAPS_SET_BACKLIGHT       0x01000000
54
55 /* Values from DSP must map to lower 16-bits */
56 #define OMAPFB_FORMAT_MASK         0x00ff
57 #define OMAPFB_FORMAT_FLAG_DOUBLE  0x0100
58
59 enum omapfb_color_format {
60         OMAPFB_COLOR_RGB565 = 0,
61         OMAPFB_COLOR_YUV422,
62         OMAPFB_COLOR_YUV420,
63         OMAPFB_COLOR_CLUT_8BPP,
64         OMAPFB_COLOR_CLUT_4BPP,
65         OMAPFB_COLOR_CLUT_2BPP,
66         OMAPFB_COLOR_CLUT_1BPP,
67 };
68
69 struct omapfb_update_window {
70         __u32 x, y;
71         __u32 width, height;
72         __u32 format;
73 };
74
75 struct omapfb_update_window_old {
76         __u32 x, y;
77         __u32 width, height;
78 };
79
80 enum omapfb_plane {
81         OMAPFB_PLANE_GFX = 0,
82         OMAPFB_PLANE_VID1,
83         OMAPFB_PLANE_VID2,
84 };
85
86 enum omapfb_channel_out {
87         OMAPFB_CHANNEL_OUT_LCD = 0,
88         OMAPFB_CHANNEL_OUT_DIGIT,
89 };
90
91 struct omapfb_setup_plane {
92         __u8  plane;
93         __u8  channel_out;
94         __u32 offset;
95         __u32 pos_x, pos_y;
96         __u32 width, height;
97         __u32 color_mode;
98 };
99
100 struct omapfb_enable_plane {
101         __u8  plane;
102         __u8  enable;
103 };
104
105 enum omapfb_color_key_type {
106         OMAPFB_COLOR_KEY_DISABLED = 0,
107         OMAPFB_COLOR_KEY_GFX_DST,
108         OMAPFB_COLOR_KEY_VID_SRC,
109 };
110
111 struct omapfb_color_key {
112         __u8  channel_out;
113         __u32 background;
114         __u32 trans_key;
115         __u8  key_type;
116 };
117
118 enum omapfb_update_mode {
119         OMAPFB_UPDATE_DISABLED = 0,
120         OMAPFB_AUTO_UPDATE,
121         OMAPFB_MANUAL_UPDATE
122 };
123
124 #ifdef __KERNEL__
125
126 #include <linux/completion.h>
127 #include <linux/interrupt.h>
128 #include <linux/fb.h>
129 #include <linux/mutex.h>
130
131 #include <asm/arch/board.h>
132
133 #define OMAP_LCDC_INV_VSYNC             0x0001
134 #define OMAP_LCDC_INV_HSYNC             0x0002
135 #define OMAP_LCDC_INV_PIX_CLOCK         0x0004
136 #define OMAP_LCDC_INV_OUTPUT_EN         0x0008
137 #define OMAP_LCDC_HSVS_RISING_EDGE      0x0010
138 #define OMAP_LCDC_HSVS_OPPOSITE         0x0020
139
140 #define OMAP_LCDC_SIGNAL_MASK           0x003f
141
142 #define OMAP_LCDC_PANEL_TFT             0x0100
143
144 #ifdef CONFIG_ARCH_OMAP1
145 #define OMAPFB_PLANE_NUM                1
146 #else
147 #define OMAPFB_PLANE_NUM                3
148 #endif
149
150 struct omapfb_device;
151
152 struct lcd_panel {
153         const char      *name;
154         int             config;         /* TFT/STN, signal inversion */
155         int             bpp;            /* Pixel format in fb mem */
156         int             data_lines;     /* Lines on LCD HW interface */
157
158         int             x_res, y_res;
159         int             pixel_clock;    /* In kHz */
160         int             hsw;            /* Horizontal synchronization
161                                            pulse width */
162         int             hfp;            /* Horizontal front porch */
163         int             hbp;            /* Horizontal back porch */
164         int             vsw;            /* Vertical synchronization
165                                            pulse width */
166         int             vfp;            /* Vertical front porch */
167         int             vbp;            /* Vertical back porch */
168         int             acb;            /* ac-bias pin frequency */
169         int             pcd;            /* pixel clock divider.
170                                            Obsolete use pixel_clock instead */
171
172         int             (*init)         (struct omapfb_device *fbdev);
173         void            (*cleanup)      (void);
174         int             (*enable)       (void);
175         void            (*disable)      (void);
176         unsigned long   (*get_caps)     (void);
177         int             (*set_bklight_level)(unsigned int level);
178         unsigned int    (*get_bklight_level)(void);
179         unsigned int    (*get_bklight_max)  (void);
180         int             (*run_test)     (int test_num);
181 };
182
183 struct omapfb_device;
184
185 struct extif_timings {
186         int cs_on_time;
187         int cs_off_time;
188         int we_on_time;
189         int we_off_time;
190         int re_on_time;
191         int re_off_time;
192         int we_cycle_time;
193         int re_cycle_time;
194         int cs_pulse_width;
195         int access_time;
196
197         int clk_div;
198
199         u32 tim[5];             /* set by extif->convert_timings */
200
201         int converted;
202 };
203
204 struct lcd_ctrl_extif {
205         int  (*init)            (void);
206         void (*cleanup)         (void);
207         void (*get_clk_info)    (u32 *clk_period, u32 *max_clk_div);
208         int  (*convert_timings) (struct extif_timings *timings);
209         void (*set_timings)     (const struct extif_timings *timings);
210         void (*set_bits_per_cycle)(int bpc);
211         void (*write_command)   (const void *buf, unsigned int len);
212         void (*read_data)       (void *buf, unsigned int len);
213         void (*write_data)      (const void *buf, unsigned int len);
214         void (*transfer_area)   (int width, int height,
215                                  void (callback)(void * data), void *data);
216         unsigned long           max_transmit_size;
217 };
218
219 struct omapfb_notifier_block {
220         struct notifier_block   nb;
221         void                    *data;
222 };
223
224 typedef int (*omapfb_notifier_callback_t)(struct omapfb_notifier_block *,
225                                            unsigned long event,
226                                            struct omapfb_device *fbdev);
227
228 struct lcd_ctrl {
229         const char      *name;
230         void            *data;
231
232         int             (*init)           (struct omapfb_device *fbdev,
233                                            int ext_mode, int req_vram_size);
234         void            (*cleanup)        (void);
235         void            (*bind_client)    (struct omapfb_notifier_block *nb);
236         void            (*get_vram_layout)(unsigned long *size,
237                                            void **virt_base,
238                                            dma_addr_t *phys_base);
239         int             (*mmap)           (struct vm_area_struct *vma);
240         unsigned long   (*get_caps)       (void);
241         int             (*set_update_mode)(enum omapfb_update_mode mode);
242         enum omapfb_update_mode (*get_update_mode)(void);
243         int             (*setup_plane)    (int plane, int channel_out,
244                                            unsigned long offset,
245                                            int screen_width,
246                                            int pos_x, int pos_y, int width,
247                                            int height, int color_mode);
248         int             (*enable_plane)   (int plane, int enable);
249         int             (*update_window)  (struct omapfb_update_window *win,
250                                            void (*callback)(void *),
251                                            void *callback_data);
252         void            (*sync)           (void);
253         void            (*suspend)        (void);
254         void            (*resume)         (void);
255         int             (*run_test)       (int test_num);
256         int             (*setcolreg)      (u_int regno, u16 red, u16 green,
257                                            u16 blue, u16 transp,
258                                            int update_hw_mem);
259         int             (*set_color_key)  (struct omapfb_color_key *ck);
260
261 };
262
263 enum omapfb_state {
264         OMAPFB_DISABLED = 0,
265         OMAPFB_SUSPENDED= 99,
266         OMAPFB_ACTIVE   = 100
267 };
268
269 struct omapfb_device {
270         int                     state;
271         int                     ext_lcdc;               /* Using external
272                                                            LCD controller */
273         struct mutex            rqueue_mutex;
274
275         void                    *vram_virt_base;
276         dma_addr_t              vram_phys_base;
277         unsigned long           vram_size;
278
279         int                     color_mode;
280         int                     palette_size;
281         int                     mirror;
282         u32                     pseudo_palette[17];
283
284         struct lcd_panel        *panel;                 /* LCD panel */
285         struct lcd_ctrl         *ctrl;                  /* LCD controller */
286         struct lcd_ctrl         *int_ctrl;              /* internal LCD ctrl */
287         struct lcd_ctrl_extif   *ext_if;                /* LCD ctrl external
288                                                            interface */
289         struct fb_info          *fb_info;
290
291         struct device           *dev;
292 };
293
294 struct omapfb_platform_data {
295         struct omap_lcd_config   lcd;
296         struct omap_fbmem_config fbmem;
297 };
298
299 #define OMAPFB_EVENT_READY      1
300 #define OMAPFB_EVENT_DISABLED   2
301
302 #ifdef CONFIG_ARCH_OMAP1
303 extern struct lcd_ctrl omap1_lcd_ctrl;
304 #else
305 extern struct lcd_ctrl omap2_disp_ctrl;
306 #endif
307
308 extern void omapfb_register_panel(struct lcd_panel *panel);
309 extern void omapfb_write_first_pixel(struct omapfb_device *fbdev, u16 pixval);
310 extern void omapfb_notify_clients(struct omapfb_device *fbdev,
311                                   unsigned long event);
312 extern int  omapfb_register_client(struct omapfb_notifier_block *nb,
313                                     omapfb_notifier_callback_t callback,
314                                     void *callback_data);
315 extern int  omapfb_unregister_client(struct omapfb_notifier_block *nb);
316 extern int  omapfb_update_window_async(struct omapfb_update_window *win,
317                                         void (*callback)(void *),
318                                         void *callback_data);
319
320 /* in arch/arm/plat-omap/devices.c */
321 extern void omapfb_reserve_mem(void);
322
323 #endif /* __KERNEL__ */
324
325 #endif /* __OMAPFB_H */