Home | History | Annotate | Download | only in linux
      1 /*
      2  * File: include/linux/omapfb.h
      3  *
      4  * Framebuffer driver for TI OMAP boards
      5  *
      6  * Copyright (C) 2004 Nokia Corporation
      7  * Author: Imre Deak <imre.deak (at) 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 __LINUX_OMAPFB_H__
     25 #define __LINUX_OMAPFB_H__
     26 
     27 #include <linux/fb.h>
     28 #include <linux/ioctl.h>
     29 #include <linux/types.h>
     30 
     31 /* IOCTL commands. */
     32 
     33 #define OMAP_IOW(num, dtype)	_IOW('O', num, dtype)
     34 #define OMAP_IOR(num, dtype)	_IOR('O', num, dtype)
     35 #define OMAP_IOWR(num, dtype)	_IOWR('O', num, dtype)
     36 #define OMAP_IO(num)		_IO('O', num)
     37 
     38 #define OMAPFB_MIRROR		OMAP_IOW(31, int)
     39 #define OMAPFB_SYNC_GFX		OMAP_IO(37)
     40 #define OMAPFB_VSYNC		OMAP_IO(38)
     41 #define OMAPFB_SET_UPDATE_MODE	OMAP_IOW(40, int)
     42 #define OMAPFB_GET_CAPS		OMAP_IOR(42, struct omapfb_caps)
     43 #define OMAPFB_GET_UPDATE_MODE	OMAP_IOW(43, int)
     44 #define OMAPFB_LCD_TEST		OMAP_IOW(45, int)
     45 #define OMAPFB_CTRL_TEST	OMAP_IOW(46, int)
     46 #define OMAPFB_UPDATE_WINDOW_OLD OMAP_IOW(47, struct omapfb_update_window_old)
     47 #define OMAPFB_SET_COLOR_KEY	OMAP_IOW(50, struct omapfb_color_key)
     48 #define OMAPFB_GET_COLOR_KEY	OMAP_IOW(51, struct omapfb_color_key)
     49 #define OMAPFB_SETUP_PLANE	OMAP_IOW(52, struct omapfb_plane_info)
     50 #define OMAPFB_QUERY_PLANE	OMAP_IOW(53, struct omapfb_plane_info)
     51 #define OMAPFB_UPDATE_WINDOW	OMAP_IOW(54, struct omapfb_update_window)
     52 #define OMAPFB_SETUP_MEM	OMAP_IOW(55, struct omapfb_mem_info)
     53 #define OMAPFB_QUERY_MEM	OMAP_IOW(56, struct omapfb_mem_info)
     54 #define OMAPFB_WAITFORVSYNC	OMAP_IO(57)
     55 #define OMAPFB_MEMORY_READ	OMAP_IOR(58, struct omapfb_memory_read)
     56 #define OMAPFB_GET_OVERLAY_COLORMODE OMAP_IOR(59, struct omapfb_ovl_colormode)
     57 #define OMAPFB_WAITFORGO	OMAP_IO(60)
     58 #define OMAPFB_GET_VRAM_INFO	OMAP_IOR(61, struct omapfb_vram_info)
     59 #define OMAPFB_SET_TEARSYNC	OMAP_IOW(62, struct omapfb_tearsync_info)
     60 #define OMAPFB_GET_DISPLAY_INFO	OMAP_IOR(63, struct omapfb_display_info)
     61 #define OMAPFB_ENABLEVSYNC	OMAP_IOW(64, int)
     62 
     63 #define OMAPFB_CAPS_GENERIC_MASK	0x00000fff
     64 #define OMAPFB_CAPS_LCDC_MASK		0x00fff000
     65 #define OMAPFB_CAPS_PANEL_MASK		0xff000000
     66 
     67 #define OMAPFB_CAPS_MANUAL_UPDATE	0x00001000
     68 #define OMAPFB_CAPS_TEARSYNC		0x00002000
     69 #define OMAPFB_CAPS_PLANE_RELOCATE_MEM	0x00004000
     70 #define OMAPFB_CAPS_PLANE_SCALE		0x00008000
     71 #define OMAPFB_CAPS_WINDOW_PIXEL_DOUBLE	0x00010000
     72 #define OMAPFB_CAPS_WINDOW_SCALE	0x00020000
     73 #define OMAPFB_CAPS_WINDOW_OVERLAY	0x00040000
     74 #define OMAPFB_CAPS_WINDOW_ROTATE	0x00080000
     75 #define OMAPFB_CAPS_SET_BACKLIGHT	0x01000000
     76 
     77 /* Values from DSP must map to lower 16-bits */
     78 #define OMAPFB_FORMAT_MASK		0x00ff
     79 #define OMAPFB_FORMAT_FLAG_DOUBLE	0x0100
     80 #define OMAPFB_FORMAT_FLAG_TEARSYNC	0x0200
     81 #define OMAPFB_FORMAT_FLAG_FORCE_VSYNC	0x0400
     82 #define OMAPFB_FORMAT_FLAG_ENABLE_OVERLAY	0x0800
     83 #define OMAPFB_FORMAT_FLAG_DISABLE_OVERLAY	0x1000
     84 
     85 #define OMAPFB_MEMTYPE_SDRAM		0
     86 #define OMAPFB_MEMTYPE_SRAM		1
     87 #define OMAPFB_MEMTYPE_MAX		1
     88 
     89 #define OMAPFB_MEM_IDX_ENABLED	0x80
     90 #define OMAPFB_MEM_IDX_MASK	0x7f
     91 
     92 enum omapfb_color_format {
     93 	OMAPFB_COLOR_RGB565 = 0,
     94 	OMAPFB_COLOR_YUV422,
     95 	OMAPFB_COLOR_YUV420,
     96 	OMAPFB_COLOR_CLUT_8BPP,
     97 	OMAPFB_COLOR_CLUT_4BPP,
     98 	OMAPFB_COLOR_CLUT_2BPP,
     99 	OMAPFB_COLOR_CLUT_1BPP,
    100 	OMAPFB_COLOR_RGB444,
    101 	OMAPFB_COLOR_YUY422,
    102 
    103 	OMAPFB_COLOR_ARGB16,
    104 	OMAPFB_COLOR_RGB24U,	/* RGB24, 32-bit container */
    105 	OMAPFB_COLOR_RGB24P,	/* RGB24, 24-bit container */
    106 	OMAPFB_COLOR_ARGB32,
    107 	OMAPFB_COLOR_RGBA32,
    108 	OMAPFB_COLOR_RGBX32,
    109 };
    110 
    111 struct omapfb_update_window {
    112 	__u32 x, y;
    113 	__u32 width, height;
    114 	__u32 format;
    115 	__u32 out_x, out_y;
    116 	__u32 out_width, out_height;
    117 	__u32 reserved[8];
    118 };
    119 
    120 struct omapfb_update_window_old {
    121 	__u32 x, y;
    122 	__u32 width, height;
    123 	__u32 format;
    124 };
    125 
    126 enum omapfb_plane {
    127 	OMAPFB_PLANE_GFX = 0,
    128 	OMAPFB_PLANE_VID1,
    129 	OMAPFB_PLANE_VID2,
    130 };
    131 
    132 enum omapfb_channel_out {
    133 	OMAPFB_CHANNEL_OUT_LCD = 0,
    134 	OMAPFB_CHANNEL_OUT_DIGIT,
    135 };
    136 
    137 struct omapfb_plane_info {
    138 	__u32 pos_x;
    139 	__u32 pos_y;
    140 	__u8  enabled;
    141 	__u8  channel_out;
    142 	__u8  mirror;
    143 	__u8  mem_idx;
    144 	__u32 out_width;
    145 	__u32 out_height;
    146 	__u32 reserved2[12];
    147 };
    148 
    149 struct omapfb_mem_info {
    150 	__u32 size;
    151 	__u8  type;
    152 	__u8  reserved[3];
    153 };
    154 
    155 struct omapfb_caps {
    156 	__u32 ctrl;
    157 	__u32 plane_color;
    158 	__u32 wnd_color;
    159 };
    160 
    161 enum omapfb_color_key_type {
    162 	OMAPFB_COLOR_KEY_DISABLED = 0,
    163 	OMAPFB_COLOR_KEY_GFX_DST,
    164 	OMAPFB_COLOR_KEY_VID_SRC,
    165 };
    166 
    167 struct omapfb_color_key {
    168 	__u8  channel_out;
    169 	__u32 background;
    170 	__u32 trans_key;
    171 	__u8  key_type;
    172 };
    173 
    174 enum omapfb_update_mode {
    175 	OMAPFB_UPDATE_DISABLED = 0,
    176 	OMAPFB_AUTO_UPDATE,
    177 	OMAPFB_MANUAL_UPDATE
    178 };
    179 
    180 struct omapfb_memory_read {
    181 	__u16 x;
    182 	__u16 y;
    183 	__u16 w;
    184 	__u16 h;
    185 	size_t buffer_size;
    186 	void __user *buffer;
    187 };
    188 
    189 struct omapfb_ovl_colormode {
    190 	__u8 overlay_idx;
    191 	__u8 mode_idx;
    192 	__u32 bits_per_pixel;
    193 	__u32 nonstd;
    194 	struct fb_bitfield red;
    195 	struct fb_bitfield green;
    196 	struct fb_bitfield blue;
    197 	struct fb_bitfield transp;
    198 };
    199 
    200 struct omapfb_vram_info {
    201 	__u32 total;
    202 	__u32 free;
    203 	__u32 largest_free_block;
    204 	__u32 reserved[5];
    205 };
    206 
    207 struct omapfb_tearsync_info {
    208 	__u8 enabled;
    209 	__u8 reserved1[3];
    210 	__u16 line;
    211 	__u16 reserved2;
    212 };
    213 
    214 struct omapfb_display_info {
    215 	__u16 xres;
    216 	__u16 yres;
    217 	__u32 width;	/* phys width of the display in micrometers */
    218 	__u32 height;	/* phys height of the display in micrometers */
    219 	__u32 reserved[5];
    220 };
    221 
    222 #ifdef __KERNEL__
    223 
    224 #include <plat/board.h>
    225 
    226 #ifdef CONFIG_ARCH_OMAP1
    227 #define OMAPFB_PLANE_NUM		1
    228 #else
    229 #define OMAPFB_PLANE_NUM		3
    230 #endif
    231 
    232 struct omapfb_mem_region {
    233 	u32		paddr;
    234 	void __iomem	*vaddr;
    235 	unsigned long	size;
    236 	u8		type;		/* OMAPFB_PLANE_MEM_* */
    237 	enum omapfb_color_format format;/* OMAPFB_COLOR_* */
    238 	unsigned	format_used:1;	/* Must be set when format is set.
    239 					 * Needed b/c of the badly chosen 0
    240 					 * base for OMAPFB_COLOR_* values
    241 					 */
    242 	unsigned	alloc:1;	/* allocated by the driver */
    243 	unsigned	map:1;		/* kernel mapped by the driver */
    244 };
    245 
    246 struct omapfb_mem_desc {
    247 	int				region_cnt;
    248 	struct omapfb_mem_region	region[OMAPFB_PLANE_NUM];
    249 };
    250 
    251 struct omapfb_platform_data {
    252 	struct omap_lcd_config		lcd;
    253 	struct omapfb_mem_desc		mem_desc;
    254 	void				*ctrl_platform_data;
    255 };
    256 
    257 /* in arch/arm/plat-omap/fb.c */
    258 extern void omapfb_set_platform_data(struct omapfb_platform_data *data);
    259 extern void omapfb_set_ctrl_platform_data(void *pdata);
    260 extern void omapfb_reserve_sdram_memblock(void);
    261 
    262 /* helper methods that may be used by other modules */
    263 enum omap_color_mode;
    264 struct omap_video_timings;
    265 int omapfb_mode_to_dss_mode(struct fb_var_screeninfo *var,
    266 			enum omap_color_mode *mode);
    267 void omapfb_fb2dss_timings(struct fb_videomode *fb_timings,
    268 			struct omap_video_timings *dss_timings);
    269 void omapfb_dss2fb_timings(struct omap_video_timings *dss_timings,
    270 			struct fb_videomode *fb_timings);
    271 
    272 #endif
    273 
    274 #endif /* __OMAPFB_H */
    275