]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - include/asm-arm/arch-omap/omapfb.h
7eade7be175e0d55b4cc3f74cf13a482d90a8961
[linux-2.6-omap-h63xx.git] / 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
130 #include <asm/arch/board.h>
131
132 #define OMAP_LCDC_INV_VSYNC             0x0001
133 #define OMAP_LCDC_INV_HSYNC             0x0002
134 #define OMAP_LCDC_INV_PIX_CLOCK         0x0004
135 #define OMAP_LCDC_INV_OUTPUT_EN         0x0008
136 #define OMAP_LCDC_HSVS_RISING_EDGE      0x0010
137 #define OMAP_LCDC_HSVS_OPPOSITE         0x0020
138
139 #define OMAP_LCDC_SIGNAL_MASK           0x003f
140
141 #define OMAP_LCDC_PANEL_TFT             0x0100
142
143 #ifdef CONFIG_ARCH_OMAP1
144 #define OMAPFB_PLANE_NUM                1
145 #else
146 #define OMAPFB_PLANE_NUM                3
147 #endif
148
149 struct omapfb_device;
150
151 struct lcd_panel {
152         const char      *name;
153         int             config;         /* TFT/STN, signal inversion */
154         int             bpp;            /* Pixel format in fb mem */
155         int             data_lines;     /* Lines on LCD HW interface */
156
157         int             x_res, y_res;
158         int             pixel_clock;    /* In kHz */
159         int             hsw;            /* Horizontal synchronization
160                                            pulse width */
161         int             hfp;            /* Horizontal front porch */
162         int             hbp;            /* Horizontal back porch */
163         int             vsw;            /* Vertical synchronization
164                                            pulse width */
165         int             vfp;            /* Vertical front porch */
166         int             vbp;            /* Vertical back porch */
167         int             acb;            /* ac-bias pin frequency */
168         int             pcd;            /* pixel clock divider.
169                                            Obsolete use pixel_clock instead */
170
171         int             (*init)         (struct omapfb_device *fbdev);
172         void            (*cleanup)      (void);
173         int             (*enable)       (void);
174         void            (*disable)      (void);
175         unsigned long   (*get_caps)     (void);
176         int             (*set_bklight_level)(unsigned int level);
177         unsigned int    (*get_bklight_level)(void);
178         unsigned int    (*get_bklight_max)  (void);
179         int             (*run_test)     (int test_num);
180 };
181
182 struct omapfb_device;
183
184 struct extif_timings {
185         int cs_on_time;
186         int cs_off_time;
187         int we_on_time;
188         int we_off_time;
189         int re_on_time;
190         int re_off_time;
191         int we_cycle_time;
192         int re_cycle_time;
193         int cs_pulse_width;
194         int access_time;
195
196         int clk_div;
197
198         u32 tim[5];             /* set by extif->convert_timings */
199
200         int converted;
201 };
202
203 struct lcd_ctrl_extif {
204         int  (*init)            (void);
205         void (*cleanup)         (void);
206         void (*get_clk_info)    (u32 *clk_period, u32 *max_clk_div);
207         int  (*convert_timings) (struct extif_timings *timings);
208         void (*set_timings)     (const struct extif_timings *timings);
209         void (*set_bits_per_cycle)(int bpc);
210         void (*write_command)   (const void *buf, unsigned int len);
211         void (*read_data)       (void *buf, unsigned int len);
212         void (*write_data)      (const void *buf, unsigned int len);
213         void (*transfer_area)   (int width, int height,
214                                  void (callback)(void * data), void *data);
215         unsigned long           max_transmit_size;
216 };
217
218 struct omapfb_notifier_block {
219         struct notifier_block   nb;
220         void                    *data;
221 };
222
223 typedef int (*omapfb_notifier_callback_t)(struct omapfb_notifier_block *,
224                                            unsigned long event,
225                                            struct omapfb_device *fbdev);
226
227 struct lcd_ctrl {
228         const char      *name;
229         void            *data;
230
231         int             (*init)           (struct omapfb_device *fbdev,
232                                            int ext_mode, int req_vram_size);
233         void            (*cleanup)        (void);
234         void            (*bind_client)    (struct omapfb_notifier_block *nb);
235         void            (*get_vram_layout)(unsigned long *size,
236                                            void **virt_base,
237                                            dma_addr_t *phys_base);
238         int             (*mmap)           (struct vm_area_struct *vma);
239         unsigned long   (*get_caps)       (void);
240         int             (*set_update_mode)(enum omapfb_update_mode mode);
241         enum omapfb_update_mode (*get_update_mode)(void);
242         int             (*setup_plane)    (int plane, int channel_out,
243                                            unsigned long offset,
244                                            int screen_width,
245                                            int pos_x, int pos_y, int width,
246                                            int height, int color_mode);
247         int             (*enable_plane)   (int plane, int enable);
248         int             (*update_window)  (struct omapfb_update_window *win,
249                                            void (*callback)(void *),
250                                            void *callback_data);
251         void            (*sync)           (void);
252         void            (*suspend)        (void);
253         void            (*resume)         (void);
254         int             (*run_test)       (int test_num);
255         int             (*setcolreg)      (u_int regno, u16 red, u16 green,
256                                            u16 blue, u16 transp,
257                                            int update_hw_mem);
258         int             (*set_color_key)  (struct omapfb_color_key *ck);
259
260 };
261
262 enum omapfb_state {
263         OMAPFB_DISABLED = 0,
264         OMAPFB_SUSPENDED= 99,
265         OMAPFB_ACTIVE   = 100
266 };
267
268 struct omapfb_device {
269         int                     state;
270         int                     ext_lcdc;               /* Using external
271                                                            LCD controller */
272         struct semaphore        rqueue_sema;
273
274         void                    *vram_virt_base;
275         dma_addr_t              vram_phys_base;
276         unsigned long           vram_size;
277
278         int                     color_mode;
279         int                     palette_size;
280         int                     mirror;
281         u32                     pseudo_palette[17];
282
283         struct lcd_panel        *panel;                 /* LCD panel */
284         struct lcd_ctrl         *ctrl;                  /* LCD controller */
285         struct lcd_ctrl         *int_ctrl;              /* internal LCD ctrl */
286         struct lcd_ctrl_extif   *ext_if;                /* LCD ctrl external
287                                                            interface */
288         struct fb_info          *fb_info;
289
290         struct device           *dev;
291 };
292
293 struct omapfb_platform_data {
294         struct omap_lcd_config   lcd;
295         struct omap_fbmem_config fbmem;
296 };
297
298 #define OMAPFB_EVENT_READY      1
299 #define OMAPFB_EVENT_DISABLED   2
300
301 #ifdef CONFIG_ARCH_OMAP1
302 extern struct lcd_ctrl omap1_lcd_ctrl;
303 #else
304 extern struct lcd_ctrl omap2_disp_ctrl;
305 #endif
306
307 extern void omapfb_register_panel(struct lcd_panel *panel);
308 extern void omapfb_write_first_pixel(struct omapfb_device *fbdev, u16 pixval);
309 extern void omapfb_notify_clients(struct omapfb_device *fbdev,
310                                   unsigned long event);
311 extern int  omapfb_register_client(struct omapfb_notifier_block *nb,
312                                     omapfb_notifier_callback_t callback,
313                                     void *callback_data);
314 extern int  omapfb_unregister_client(struct omapfb_notifier_block *nb);
315 extern int  omapfb_update_window_async(struct omapfb_update_window *win,
316                                         void (*callback)(void *),
317                                         void *callback_data);
318
319 /* in arch/arm/plat-omap/devices.c */
320 extern void omapfb_reserve_mem(void);
321
322 #endif /* __KERNEL__ */
323
324 #endif /* __OMAPFB_H */