omap: headers: Create headers necessary for compile under mach-omap1 and mach-omap2
[linux-2.6.git] / arch / arm / plat-omap / include / plat / omapfb.h
1 /*
2  * File: arch/arm/plat-omap/include/mach/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 <asm/ioctl.h>
28 #include <asm/types.h>
29
30 /* IOCTL commands. */
31
32 #define OMAP_IOW(num, dtype)    _IOW('O', num, dtype)
33 #define OMAP_IOR(num, dtype)    _IOR('O', num, dtype)
34 #define OMAP_IOWR(num, dtype)   _IOWR('O', num, dtype)
35 #define OMAP_IO(num)            _IO('O', num)
36
37 #define OMAPFB_MIRROR           OMAP_IOW(31, int)
38 #define OMAPFB_SYNC_GFX         OMAP_IO(37)
39 #define OMAPFB_VSYNC            OMAP_IO(38)
40 #define OMAPFB_SET_UPDATE_MODE  OMAP_IOW(40, int)
41 #define OMAPFB_GET_CAPS         OMAP_IOR(42, struct omapfb_caps)
42 #define OMAPFB_GET_UPDATE_MODE  OMAP_IOW(43, int)
43 #define OMAPFB_LCD_TEST         OMAP_IOW(45, int)
44 #define OMAPFB_CTRL_TEST        OMAP_IOW(46, int)
45 #define OMAPFB_UPDATE_WINDOW_OLD OMAP_IOW(47, struct omapfb_update_window_old)
46 #define OMAPFB_SET_COLOR_KEY    OMAP_IOW(50, struct omapfb_color_key)
47 #define OMAPFB_GET_COLOR_KEY    OMAP_IOW(51, struct omapfb_color_key)
48 #define OMAPFB_SETUP_PLANE      OMAP_IOW(52, struct omapfb_plane_info)
49 #define OMAPFB_QUERY_PLANE      OMAP_IOW(53, struct omapfb_plane_info)
50 #define OMAPFB_UPDATE_WINDOW    OMAP_IOW(54, struct omapfb_update_window)
51 #define OMAPFB_SETUP_MEM        OMAP_IOW(55, struct omapfb_mem_info)
52 #define OMAPFB_QUERY_MEM        OMAP_IOW(56, struct omapfb_mem_info)
53
54 #define OMAPFB_CAPS_GENERIC_MASK        0x00000fff
55 #define OMAPFB_CAPS_LCDC_MASK           0x00fff000
56 #define OMAPFB_CAPS_PANEL_MASK          0xff000000
57
58 #define OMAPFB_CAPS_MANUAL_UPDATE       0x00001000
59 #define OMAPFB_CAPS_TEARSYNC            0x00002000
60 #define OMAPFB_CAPS_PLANE_RELOCATE_MEM  0x00004000
61 #define OMAPFB_CAPS_PLANE_SCALE         0x00008000
62 #define OMAPFB_CAPS_WINDOW_PIXEL_DOUBLE 0x00010000
63 #define OMAPFB_CAPS_WINDOW_SCALE        0x00020000
64 #define OMAPFB_CAPS_WINDOW_OVERLAY      0x00040000
65 #define OMAPFB_CAPS_WINDOW_ROTATE       0x00080000
66 #define OMAPFB_CAPS_SET_BACKLIGHT       0x01000000
67
68 /* Values from DSP must map to lower 16-bits */
69 #define OMAPFB_FORMAT_MASK              0x00ff
70 #define OMAPFB_FORMAT_FLAG_DOUBLE       0x0100
71 #define OMAPFB_FORMAT_FLAG_TEARSYNC     0x0200
72 #define OMAPFB_FORMAT_FLAG_FORCE_VSYNC  0x0400
73 #define OMAPFB_FORMAT_FLAG_ENABLE_OVERLAY       0x0800
74 #define OMAPFB_FORMAT_FLAG_DISABLE_OVERLAY      0x1000
75
76 #define OMAPFB_EVENT_READY      1
77 #define OMAPFB_EVENT_DISABLED   2
78
79 #define OMAPFB_MEMTYPE_SDRAM            0
80 #define OMAPFB_MEMTYPE_SRAM             1
81 #define OMAPFB_MEMTYPE_MAX              1
82
83 enum omapfb_color_format {
84         OMAPFB_COLOR_RGB565 = 0,
85         OMAPFB_COLOR_YUV422,
86         OMAPFB_COLOR_YUV420,
87         OMAPFB_COLOR_CLUT_8BPP,
88         OMAPFB_COLOR_CLUT_4BPP,
89         OMAPFB_COLOR_CLUT_2BPP,
90         OMAPFB_COLOR_CLUT_1BPP,
91         OMAPFB_COLOR_RGB444,
92         OMAPFB_COLOR_YUY422,
93 };
94
95 struct omapfb_update_window {
96         __u32 x, y;
97         __u32 width, height;
98         __u32 format;
99         __u32 out_x, out_y;
100         __u32 out_width, out_height;
101         __u32 reserved[8];
102 };
103
104 struct omapfb_update_window_old {
105         __u32 x, y;
106         __u32 width, height;
107         __u32 format;
108 };
109
110 enum omapfb_plane {
111         OMAPFB_PLANE_GFX = 0,
112         OMAPFB_PLANE_VID1,
113         OMAPFB_PLANE_VID2,
114 };
115
116 enum omapfb_channel_out {
117         OMAPFB_CHANNEL_OUT_LCD = 0,
118         OMAPFB_CHANNEL_OUT_DIGIT,
119 };
120
121 struct omapfb_plane_info {
122         __u32 pos_x;
123         __u32 pos_y;
124         __u8  enabled;
125         __u8  channel_out;
126         __u8  mirror;
127         __u8  reserved1;
128         __u32 out_width;
129         __u32 out_height;
130         __u32 reserved2[12];
131 };
132
133 struct omapfb_mem_info {
134         __u32 size;
135         __u8  type;
136         __u8  reserved[3];
137 };
138
139 struct omapfb_caps {
140         __u32 ctrl;
141         __u32 plane_color;
142         __u32 wnd_color;
143 };
144
145 enum omapfb_color_key_type {
146         OMAPFB_COLOR_KEY_DISABLED = 0,
147         OMAPFB_COLOR_KEY_GFX_DST,
148         OMAPFB_COLOR_KEY_VID_SRC,
149 };
150
151 struct omapfb_color_key {
152         __u8  channel_out;
153         __u32 background;
154         __u32 trans_key;
155         __u8  key_type;
156 };
157
158 enum omapfb_update_mode {
159         OMAPFB_UPDATE_DISABLED = 0,
160         OMAPFB_AUTO_UPDATE,
161         OMAPFB_MANUAL_UPDATE
162 };
163
164 #ifdef __KERNEL__
165
166 #include <linux/completion.h>
167 #include <linux/interrupt.h>
168 #include <linux/fb.h>
169 #include <linux/mutex.h>
170
171 #include <plat/board.h>
172
173 #define OMAP_LCDC_INV_VSYNC             0x0001
174 #define OMAP_LCDC_INV_HSYNC             0x0002
175 #define OMAP_LCDC_INV_PIX_CLOCK         0x0004
176 #define OMAP_LCDC_INV_OUTPUT_EN         0x0008
177 #define OMAP_LCDC_HSVS_RISING_EDGE      0x0010
178 #define OMAP_LCDC_HSVS_OPPOSITE         0x0020
179
180 #define OMAP_LCDC_SIGNAL_MASK           0x003f
181
182 #define OMAP_LCDC_PANEL_TFT             0x0100
183
184 #define OMAPFB_PLANE_XRES_MIN           8
185 #define OMAPFB_PLANE_YRES_MIN           8
186
187 #ifdef CONFIG_ARCH_OMAP1
188 #define OMAPFB_PLANE_NUM                1
189 #else
190 #define OMAPFB_PLANE_NUM                3
191 #endif
192
193 struct omapfb_device;
194
195 struct lcd_panel {
196         const char      *name;
197         int             config;         /* TFT/STN, signal inversion */
198         int             bpp;            /* Pixel format in fb mem */
199         int             data_lines;     /* Lines on LCD HW interface */
200
201         int             x_res, y_res;
202         int             pixel_clock;    /* In kHz */
203         int             hsw;            /* Horizontal synchronization
204                                            pulse width */
205         int             hfp;            /* Horizontal front porch */
206         int             hbp;            /* Horizontal back porch */
207         int             vsw;            /* Vertical synchronization
208                                            pulse width */
209         int             vfp;            /* Vertical front porch */
210         int             vbp;            /* Vertical back porch */
211         int             acb;            /* ac-bias pin frequency */
212         int             pcd;            /* pixel clock divider.
213                                            Obsolete use pixel_clock instead */
214
215         int             (*init)         (struct lcd_panel *panel,
216                                          struct omapfb_device *fbdev);
217         void            (*cleanup)      (struct lcd_panel *panel);
218         int             (*enable)       (struct lcd_panel *panel);
219         void            (*disable)      (struct lcd_panel *panel);
220         unsigned long   (*get_caps)     (struct lcd_panel *panel);
221         int             (*set_bklight_level)(struct lcd_panel *panel,
222                                              unsigned int level);
223         unsigned int    (*get_bklight_level)(struct lcd_panel *panel);
224         unsigned int    (*get_bklight_max)  (struct lcd_panel *panel);
225         int             (*run_test)     (struct lcd_panel *panel, int test_num);
226 };
227
228 struct extif_timings {
229         int cs_on_time;
230         int cs_off_time;
231         int we_on_time;
232         int we_off_time;
233         int re_on_time;
234         int re_off_time;
235         int we_cycle_time;
236         int re_cycle_time;
237         int cs_pulse_width;
238         int access_time;
239
240         int clk_div;
241
242         u32 tim[5];             /* set by extif->convert_timings */
243
244         int converted;
245 };
246
247 struct lcd_ctrl_extif {
248         int  (*init)            (struct omapfb_device *fbdev);
249         void (*cleanup)         (void);
250         void (*get_clk_info)    (u32 *clk_period, u32 *max_clk_div);
251         unsigned long (*get_max_tx_rate)(void);
252         int  (*convert_timings) (struct extif_timings *timings);
253         void (*set_timings)     (const struct extif_timings *timings);
254         void (*set_bits_per_cycle)(int bpc);
255         void (*write_command)   (const void *buf, unsigned int len);
256         void (*read_data)       (void *buf, unsigned int len);
257         void (*write_data)      (const void *buf, unsigned int len);
258         void (*transfer_area)   (int width, int height,
259                                  void (callback)(void * data), void *data);
260         int  (*setup_tearsync)  (unsigned pin_cnt,
261                                  unsigned hs_pulse_time, unsigned vs_pulse_time,
262                                  int hs_pol_inv, int vs_pol_inv, int div);
263         int  (*enable_tearsync) (int enable, unsigned line);
264
265         unsigned long           max_transmit_size;
266 };
267
268 struct omapfb_notifier_block {
269         struct notifier_block   nb;
270         void                    *data;
271         int                     plane_idx;
272 };
273
274 typedef int (*omapfb_notifier_callback_t)(struct notifier_block *,
275                                           unsigned long event,
276                                           void *fbi);
277
278 struct omapfb_mem_region {
279         u32             paddr;
280         void __iomem    *vaddr;
281         unsigned long   size;
282         u8              type;           /* OMAPFB_PLANE_MEM_* */
283         unsigned        alloc:1;        /* allocated by the driver */
284         unsigned        map:1;          /* kernel mapped by the driver */
285 };
286
287 struct omapfb_mem_desc {
288         int                             region_cnt;
289         struct omapfb_mem_region        region[OMAPFB_PLANE_NUM];
290 };
291
292 struct lcd_ctrl {
293         const char      *name;
294         void            *data;
295
296         int             (*init)           (struct omapfb_device *fbdev,
297                                            int ext_mode,
298                                            struct omapfb_mem_desc *req_md);
299         void            (*cleanup)        (void);
300         void            (*bind_client)    (struct omapfb_notifier_block *nb);
301         void            (*get_caps)       (int plane, struct omapfb_caps *caps);
302         int             (*set_update_mode)(enum omapfb_update_mode mode);
303         enum omapfb_update_mode (*get_update_mode)(void);
304         int             (*setup_plane)    (int plane, int channel_out,
305                                            unsigned long offset,
306                                            int screen_width,
307                                            int pos_x, int pos_y, int width,
308                                            int height, int color_mode);
309         int             (*set_rotate)     (int angle);
310         int             (*setup_mem)      (int plane, size_t size,
311                                            int mem_type, unsigned long *paddr);
312         int             (*mmap)           (struct fb_info *info,
313                                            struct vm_area_struct *vma);
314         int             (*set_scale)      (int plane,
315                                            int orig_width, int orig_height,
316                                            int out_width, int out_height);
317         int             (*enable_plane)   (int plane, int enable);
318         int             (*update_window)  (struct fb_info *fbi,
319                                            struct omapfb_update_window *win,
320                                            void (*callback)(void *),
321                                            void *callback_data);
322         void            (*sync)           (void);
323         void            (*suspend)        (void);
324         void            (*resume)         (void);
325         int             (*run_test)       (int test_num);
326         int             (*setcolreg)      (u_int regno, u16 red, u16 green,
327                                            u16 blue, u16 transp,
328                                            int update_hw_mem);
329         int             (*set_color_key)  (struct omapfb_color_key *ck);
330         int             (*get_color_key)  (struct omapfb_color_key *ck);
331 };
332
333 enum omapfb_state {
334         OMAPFB_DISABLED = 0,
335         OMAPFB_SUSPENDED= 99,
336         OMAPFB_ACTIVE   = 100
337 };
338
339 struct omapfb_plane_struct {
340         int                             idx;
341         struct omapfb_plane_info        info;
342         enum omapfb_color_format        color_mode;
343         struct omapfb_device            *fbdev;
344 };
345
346 struct omapfb_device {
347         int                     state;
348         int                     ext_lcdc;               /* Using external
349                                                            LCD controller */
350         struct mutex            rqueue_mutex;
351
352         int                     palette_size;
353         u32                     pseudo_palette[17];
354
355         struct lcd_panel        *panel;                 /* LCD panel */
356         const struct lcd_ctrl   *ctrl;                  /* LCD controller */
357         const struct lcd_ctrl   *int_ctrl;              /* internal LCD ctrl */
358         struct lcd_ctrl_extif   *ext_if;                /* LCD ctrl external
359                                                            interface */
360         struct device           *dev;
361         struct fb_var_screeninfo        new_var;        /* for mode changes */
362
363         struct omapfb_mem_desc          mem_desc;
364         struct fb_info                  *fb_info[OMAPFB_PLANE_NUM];
365 };
366
367 struct omapfb_platform_data {
368         struct omap_lcd_config          lcd;
369         struct omapfb_mem_desc          mem_desc;
370         void                            *ctrl_platform_data;
371 };
372
373 #ifdef CONFIG_ARCH_OMAP1
374 extern struct lcd_ctrl omap1_lcd_ctrl;
375 #else
376 extern struct lcd_ctrl omap2_disp_ctrl;
377 #endif
378
379 extern void omapfb_reserve_sdram(void);
380 extern void omapfb_register_panel(struct lcd_panel *panel);
381 extern void omapfb_write_first_pixel(struct omapfb_device *fbdev, u16 pixval);
382 extern void omapfb_notify_clients(struct omapfb_device *fbdev,
383                                   unsigned long event);
384 extern int  omapfb_register_client(struct omapfb_notifier_block *nb,
385                                    omapfb_notifier_callback_t callback,
386                                    void *callback_data);
387 extern int  omapfb_unregister_client(struct omapfb_notifier_block *nb);
388 extern int  omapfb_update_window_async(struct fb_info *fbi,
389                                        struct omapfb_update_window *win,
390                                        void (*callback)(void *),
391                                        void *callback_data);
392
393 /* in arch/arm/plat-omap/fb.c */
394 extern void omapfb_set_ctrl_platform_data(void *pdata);
395
396 #endif /* __KERNEL__ */
397
398 #endif /* __OMAPFB_H */