2 * File: arch/arm/plat-omap/include/mach/omapfb.h
4 * Framebuffer driver for TI OMAP boards
6 * Copyright (C) 2004 Nokia Corporation
7 * Author: Imre Deak <imre.deak@nokia.com>
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.
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.
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.
27 #include <asm/ioctl.h>
28 #include <asm/types.h>
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)
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 #define OMAPFB_WAITFORVSYNC OMAP_IO(57)
54 #define OMAPFB_MEMORY_READ OMAP_IOR(58, struct omapfb_memory_read)
56 #ifndef FBIO_WAITFORVSYNC
57 #define FBIO_WAITFORVSYNC _IOW('F', 0x20, u_int32_t)
60 #define OMAPFB_CAPS_GENERIC_MASK 0x00000fff
61 #define OMAPFB_CAPS_LCDC_MASK 0x00fff000
62 #define OMAPFB_CAPS_PANEL_MASK 0xff000000
64 #define OMAPFB_CAPS_MANUAL_UPDATE 0x00001000
65 #define OMAPFB_CAPS_TEARSYNC 0x00002000
66 #define OMAPFB_CAPS_PLANE_RELOCATE_MEM 0x00004000
67 #define OMAPFB_CAPS_PLANE_SCALE 0x00008000
68 #define OMAPFB_CAPS_WINDOW_PIXEL_DOUBLE 0x00010000
69 #define OMAPFB_CAPS_WINDOW_SCALE 0x00020000
70 #define OMAPFB_CAPS_WINDOW_OVERLAY 0x00040000
71 #define OMAPFB_CAPS_WINDOW_ROTATE 0x00080000
72 #define OMAPFB_CAPS_SET_BACKLIGHT 0x01000000
74 /* Values from DSP must map to lower 16-bits */
75 #define OMAPFB_FORMAT_MASK 0x00ff
76 #define OMAPFB_FORMAT_FLAG_DOUBLE 0x0100
77 #define OMAPFB_FORMAT_FLAG_TEARSYNC 0x0200
78 #define OMAPFB_FORMAT_FLAG_FORCE_VSYNC 0x0400
79 #define OMAPFB_FORMAT_FLAG_ENABLE_OVERLAY 0x0800
80 #define OMAPFB_FORMAT_FLAG_DISABLE_OVERLAY 0x1000
82 #define OMAPFB_EVENT_READY 1
83 #define OMAPFB_EVENT_DISABLED 2
85 #define OMAPFB_MEMTYPE_SDRAM 0
86 #define OMAPFB_MEMTYPE_SRAM 1
87 #define OMAPFB_MEMTYPE_MAX 1
89 enum omapfb_color_format {
90 OMAPFB_COLOR_RGB565 = 0,
93 OMAPFB_COLOR_CLUT_8BPP,
94 OMAPFB_COLOR_CLUT_4BPP,
95 OMAPFB_COLOR_CLUT_2BPP,
96 OMAPFB_COLOR_CLUT_1BPP,
101 OMAPFB_COLOR_RGB24U, /* RGB24, 32-bit container */
102 OMAPFB_COLOR_RGB24P, /* RGB24, 24-bit container */
108 struct omapfb_update_window {
113 __u32 out_width, out_height;
117 struct omapfb_update_window_old {
124 OMAPFB_PLANE_GFX = 0,
129 enum omapfb_channel_out {
130 OMAPFB_CHANNEL_OUT_LCD = 0,
131 OMAPFB_CHANNEL_OUT_DIGIT,
134 struct omapfb_plane_info {
146 struct omapfb_mem_info {
158 enum omapfb_color_key_type {
159 OMAPFB_COLOR_KEY_DISABLED = 0,
160 OMAPFB_COLOR_KEY_GFX_DST,
161 OMAPFB_COLOR_KEY_VID_SRC,
164 struct omapfb_color_key {
171 enum omapfb_update_mode {
172 OMAPFB_UPDATE_DISABLED = 0,
177 struct omapfb_memory_read {
188 #include <linux/completion.h>
189 #include <linux/interrupt.h>
190 #include <linux/fb.h>
191 #include <linux/mutex.h>
193 #include <mach/board.h>
195 #define OMAP_LCDC_INV_VSYNC 0x0001
196 #define OMAP_LCDC_INV_HSYNC 0x0002
197 #define OMAP_LCDC_INV_PIX_CLOCK 0x0004
198 #define OMAP_LCDC_INV_OUTPUT_EN 0x0008
199 #define OMAP_LCDC_HSVS_RISING_EDGE 0x0010
200 #define OMAP_LCDC_HSVS_OPPOSITE 0x0020
202 #define OMAP_LCDC_SIGNAL_MASK 0x003f
204 #define OMAP_LCDC_PANEL_TFT 0x0100
206 #define OMAPFB_PLANE_XRES_MIN 8
207 #define OMAPFB_PLANE_YRES_MIN 8
209 #ifdef CONFIG_ARCH_OMAP1
210 #define OMAPFB_PLANE_NUM 1
212 #define OMAPFB_PLANE_NUM 3
215 struct omapfb_device;
219 int config; /* TFT/STN, signal inversion */
220 int bpp; /* Pixel format in fb mem */
221 int data_lines; /* Lines on LCD HW interface */
224 int pixel_clock; /* In kHz */
225 int hsw; /* Horizontal synchronization
227 int hfp; /* Horizontal front porch */
228 int hbp; /* Horizontal back porch */
229 int vsw; /* Vertical synchronization
231 int vfp; /* Vertical front porch */
232 int vbp; /* Vertical back porch */
233 int acb; /* ac-bias pin frequency */
234 int pcd; /* pixel clock divider.
235 Obsolete use pixel_clock instead */
237 int (*init) (struct lcd_panel *panel,
238 struct omapfb_device *fbdev);
239 void (*cleanup) (struct lcd_panel *panel);
240 int (*enable) (struct lcd_panel *panel);
241 void (*disable) (struct lcd_panel *panel);
242 unsigned long (*get_caps) (struct lcd_panel *panel);
243 int (*set_bklight_level)(struct lcd_panel *panel,
245 unsigned int (*get_bklight_level)(struct lcd_panel *panel);
246 unsigned int (*get_bklight_max) (struct lcd_panel *panel);
247 int (*run_test) (struct lcd_panel *panel, int test_num);
250 struct extif_timings {
264 u32 tim[5]; /* set by extif->convert_timings */
269 struct lcd_ctrl_extif {
270 int (*init) (struct omapfb_device *fbdev);
271 void (*cleanup) (void);
272 void (*get_clk_info) (u32 *clk_period, u32 *max_clk_div);
273 unsigned long (*get_max_tx_rate)(void);
274 int (*convert_timings) (struct extif_timings *timings);
275 void (*set_timings) (const struct extif_timings *timings);
276 void (*set_bits_per_cycle)(int bpc);
277 void (*write_command) (const void *buf, unsigned int len);
278 void (*read_data) (void *buf, unsigned int len);
279 void (*write_data) (const void *buf, unsigned int len);
280 void (*transfer_area) (int width, int height,
281 void (callback)(void * data), void *data);
282 int (*setup_tearsync) (unsigned pin_cnt,
283 unsigned hs_pulse_time, unsigned vs_pulse_time,
284 int hs_pol_inv, int vs_pol_inv, int div);
285 int (*enable_tearsync) (int enable, unsigned line);
287 unsigned long max_transmit_size;
290 struct omapfb_notifier_block {
291 struct notifier_block nb;
296 typedef int (*omapfb_notifier_callback_t)(struct notifier_block *,
300 struct omapfb_mem_region {
304 u8 type; /* OMAPFB_PLANE_MEM_* */
305 enum omapfb_color_format format;/* OMAPFB_COLOR_* */
306 unsigned format_used:1; /* Must be set when format is set.
307 * Needed b/c of the badly chosen 0
308 * base for OMAPFB_COLOR_* values
310 unsigned alloc:1; /* allocated by the driver */
311 unsigned map:1; /* kernel mapped by the driver */
314 struct omapfb_mem_desc {
316 struct omapfb_mem_region region[OMAPFB_PLANE_NUM];
323 int (*init) (struct omapfb_device *fbdev,
325 struct omapfb_mem_desc *req_md);
326 void (*cleanup) (void);
327 void (*bind_client) (struct omapfb_notifier_block *nb);
328 void (*get_caps) (int plane, struct omapfb_caps *caps);
329 int (*set_update_mode)(enum omapfb_update_mode mode);
330 enum omapfb_update_mode (*get_update_mode)(void);
331 int (*setup_plane) (int plane, int channel_out,
332 unsigned long offset,
334 int pos_x, int pos_y, int width,
335 int height, int color_mode);
336 int (*set_rotate) (int angle);
337 int (*setup_mem) (int plane, size_t size,
338 int mem_type, unsigned long *paddr);
339 int (*mmap) (struct fb_info *info,
340 struct vm_area_struct *vma);
341 int (*set_scale) (int plane,
342 int orig_width, int orig_height,
343 int out_width, int out_height);
344 int (*enable_plane) (int plane, int enable);
345 int (*update_window) (struct fb_info *fbi,
346 struct omapfb_update_window *win,
347 void (*callback)(void *),
348 void *callback_data);
350 void (*suspend) (void);
351 void (*resume) (void);
352 int (*run_test) (int test_num);
353 int (*setcolreg) (u_int regno, u16 red, u16 green,
354 u16 blue, u16 transp,
356 int (*set_color_key) (struct omapfb_color_key *ck);
357 int (*get_color_key) (struct omapfb_color_key *ck);
362 OMAPFB_SUSPENDED= 99,
366 struct omapfb_plane_struct {
368 struct omapfb_plane_info info;
369 enum omapfb_color_format color_mode;
370 struct omapfb_device *fbdev;
373 struct omapfb_device {
375 int ext_lcdc; /* Using external
377 struct mutex rqueue_mutex;
380 u32 pseudo_palette[17];
382 struct lcd_panel *panel; /* LCD panel */
383 const struct lcd_ctrl *ctrl; /* LCD controller */
384 const struct lcd_ctrl *int_ctrl; /* internal LCD ctrl */
385 struct lcd_ctrl_extif *ext_if; /* LCD ctrl external
388 struct fb_var_screeninfo new_var; /* for mode changes */
390 struct omapfb_mem_desc mem_desc;
391 struct fb_info *fb_info[OMAPFB_PLANE_NUM];
394 struct omapfb_platform_data {
395 struct omap_lcd_config lcd;
396 struct omapfb_mem_desc mem_desc;
397 void *ctrl_platform_data;
400 #ifdef CONFIG_ARCH_OMAP1
401 extern struct lcd_ctrl omap1_lcd_ctrl;
403 extern struct lcd_ctrl omap2_disp_ctrl;
406 extern void omapfb_set_platform_data(struct omapfb_platform_data *data);
408 extern void omapfb_reserve_sdram(void);
409 extern void omapfb_register_panel(struct lcd_panel *panel);
410 extern void omapfb_write_first_pixel(struct omapfb_device *fbdev, u16 pixval);
411 extern void omapfb_notify_clients(struct omapfb_device *fbdev,
412 unsigned long event);
413 extern int omapfb_register_client(struct omapfb_notifier_block *nb,
414 omapfb_notifier_callback_t callback,
415 void *callback_data);
416 extern int omapfb_unregister_client(struct omapfb_notifier_block *nb);
417 extern int omapfb_update_window_async(struct fb_info *fbi,
418 struct omapfb_update_window *win,
419 void (*callback)(void *),
420 void *callback_data);
422 /* in arch/arm/plat-omap/fb.c */
423 extern void omapfb_set_ctrl_platform_data(void *pdata);
425 #endif /* __KERNEL__ */
427 #endif /* __OMAPFB_H */