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