00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __OMAPFB_H
00023 #define __OMAPFB_H
00024
00025 #include <linux/fb.h>
00026
00027 #include <asm/ioctl.h>
00028 #include <asm/types.h>
00029
00030
00031
00032 #define OMAP_IOW(num, dtype) _IOW('O', num, dtype)
00033 #define OMAP_IOR(num, dtype) _IOR('O', num, dtype)
00034 #define OMAP_IOWR(num, dtype) _IOWR('O', num, dtype)
00035 #define OMAP_IO(num) _IO('O', num)
00036
00037 #define OMAPFB_MIRROR OMAP_IOW(31, int)
00038 #define OMAPFB_SYNC_GFX OMAP_IO(37)
00039 #define OMAPFB_VSYNC OMAP_IO(38)
00040 #define OMAPFB_SET_UPDATE_MODE OMAP_IOW(40, int)
00041 #define OMAPFB_GET_CAPS OMAP_IOR(42, struct omapfb_caps)
00042 #define OMAPFB_GET_UPDATE_MODE OMAP_IOW(43, int)
00043 #define OMAPFB_LCD_TEST OMAP_IOW(45, int)
00044 #define OMAPFB_CTRL_TEST OMAP_IOW(46, int)
00045 #define OMAPFB_UPDATE_WINDOW_OLD OMAP_IOW(47, struct omapfb_update_window_old)
00046 #define OMAPFB_SET_COLOR_KEY OMAP_IOW(50, struct omapfb_color_key)
00047 #define OMAPFB_GET_COLOR_KEY OMAP_IOW(51, struct omapfb_color_key)
00048 #define OMAPFB_SETUP_PLANE OMAP_IOW(52, struct omapfb_plane_info)
00049 #define OMAPFB_QUERY_PLANE OMAP_IOW(53, struct omapfb_plane_info)
00050 #define OMAPFB_UPDATE_WINDOW OMAP_IOW(54, struct omapfb_update_window)
00051 #define OMAPFB_SETUP_MEM OMAP_IOW(55, struct omapfb_mem_info)
00052 #define OMAPFB_QUERY_MEM OMAP_IOW(56, struct omapfb_mem_info)
00053 #define OMAPFB_WAITFORVSYNC OMAP_IO(57)
00054 #define OMAPFB_MEMORY_READ OMAP_IOR(58, struct omapfb_memory_read)
00055 #define OMAPFB_GET_OVERLAY_COLORMODE OMAP_IOR(59, struct omapfb_ovl_colormode)
00056 #define OMAPFB_GET_VRAM_INFO OMAP_IOR(61, struct omapfb_vram_info)
00057
00058 #define OMAPFB_CAPS_GENERIC_MASK 0x00000fff
00059 #define OMAPFB_CAPS_LCDC_MASK 0x00fff000
00060 #define OMAPFB_CAPS_PANEL_MASK 0xff000000
00061
00062 #define OMAPFB_CAPS_MANUAL_UPDATE 0x00001000
00063 #define OMAPFB_CAPS_TEARSYNC 0x00002000
00064 #define OMAPFB_CAPS_PLANE_RELOCATE_MEM 0x00004000
00065 #define OMAPFB_CAPS_PLANE_SCALE 0x00008000
00066 #define OMAPFB_CAPS_WINDOW_PIXEL_DOUBLE 0x00010000
00067 #define OMAPFB_CAPS_WINDOW_SCALE 0x00020000
00068 #define OMAPFB_CAPS_WINDOW_OVERLAY 0x00040000
00069 #define OMAPFB_CAPS_WINDOW_ROTATE 0x00080000
00070 #define OMAPFB_CAPS_SET_BACKLIGHT 0x01000000
00071
00072
00073 #define OMAPFB_FORMAT_MASK 0x00ff
00074 #define OMAPFB_FORMAT_FLAG_DOUBLE 0x0100
00075 #define OMAPFB_FORMAT_FLAG_TEARSYNC 0x0200
00076 #define OMAPFB_FORMAT_FLAG_FORCE_VSYNC 0x0400
00077 #define OMAPFB_FORMAT_FLAG_ENABLE_OVERLAY 0x0800
00078 #define OMAPFB_FORMAT_FLAG_DISABLE_OVERLAY 0x1000
00079
00080 #define OMAPFB_EVENT_READY 1
00081 #define OMAPFB_EVENT_DISABLED 2
00082
00083 #define OMAPFB_MEMTYPE_SDRAM 0
00084 #define OMAPFB_MEMTYPE_SRAM 1
00085 #define OMAPFB_MEMTYPE_MAX 1
00086
00087 enum omapfb_color_format {
00088 OMAPFB_COLOR_RGB565 = 0,
00089 OMAPFB_COLOR_YUV422,
00090 OMAPFB_COLOR_YUV420,
00091 OMAPFB_COLOR_CLUT_8BPP,
00092 OMAPFB_COLOR_CLUT_4BPP,
00093 OMAPFB_COLOR_CLUT_2BPP,
00094 OMAPFB_COLOR_CLUT_1BPP,
00095 OMAPFB_COLOR_RGB444,
00096 OMAPFB_COLOR_YUY422,
00097
00098 OMAPFB_COLOR_ARGB16,
00099 OMAPFB_COLOR_RGB24U,
00100 OMAPFB_COLOR_RGB24P,
00101 OMAPFB_COLOR_ARGB32,
00102 OMAPFB_COLOR_RGBA32,
00103 OMAPFB_COLOR_RGBX32,
00104 };
00105
00106 struct omapfb_update_window {
00107 __u32 x, y;
00108 __u32 width, height;
00109 __u32 format;
00110 __u32 out_x, out_y;
00111 __u32 out_width, out_height;
00112 __u32 reserved[8];
00113 };
00114
00115 struct omapfb_update_window_old {
00116 __u32 x, y;
00117 __u32 width, height;
00118 __u32 format;
00119 };
00120
00121 enum omapfb_plane {
00122 OMAPFB_PLANE_GFX = 0,
00123 OMAPFB_PLANE_VID1,
00124 OMAPFB_PLANE_VID2,
00125 };
00126
00127 enum omapfb_channel_out {
00128 OMAPFB_CHANNEL_OUT_LCD = 0,
00129 OMAPFB_CHANNEL_OUT_DIGIT,
00130 };
00131
00132 #define OMAPFB_CLONE_ENABLED 0x4
00133 #define OMAPFB_CLONE_MASK 0x3
00134
00135 struct omapfb_plane_info {
00136 __u32 pos_x;
00137 __u32 pos_y;
00138 __u8 enabled;
00139 __u8 channel_out;
00140 __u8 mirror;
00141 __u8 clone_idx;
00142
00143
00144 __u32 out_width;
00145 __u32 out_height;
00146 __u32 reserved2[12];
00147 };
00148
00149 struct omapfb_mem_info {
00150 __u32 size;
00151 __u8 type;
00152 __u8 reserved[3];
00153 };
00154
00155 struct omapfb_caps {
00156 __u32 ctrl;
00157 __u32 plane_color;
00158 __u32 wnd_color;
00159 };
00160
00161 enum omapfb_color_key_type {
00162 OMAPFB_COLOR_KEY_DISABLED = 0,
00163 OMAPFB_COLOR_KEY_GFX_DST,
00164 OMAPFB_COLOR_KEY_VID_SRC,
00165 };
00166
00167 struct omapfb_color_key {
00168 __u8 channel_out;
00169 __u32 background;
00170 __u32 trans_key;
00171 __u8 key_type;
00172 };
00173
00174 enum omapfb_update_mode {
00175 OMAPFB_UPDATE_DISABLED = 0,
00176 OMAPFB_AUTO_UPDATE,
00177 OMAPFB_MANUAL_UPDATE
00178 };
00179
00180 struct omapfb_memory_read {
00181 __u16 x;
00182 __u16 y;
00183 __u16 w;
00184 __u16 h;
00185 size_t buffer_size;
00186 void __user *buffer;
00187 };
00188
00189 struct omapfb_ovl_colormode {
00190 __u8 overlay_idx;
00191 __u8 mode_idx;
00192 __u32 bits_per_pixel;
00193 __u32 nonstd;
00194 struct fb_bitfield red;
00195 struct fb_bitfield green;
00196 struct fb_bitfield blue;
00197 struct fb_bitfield transp;
00198 };
00199
00200 struct omapfb_vram_info {
00201 __u32 total;
00202 __u32 free;
00203 __u32 largest_free_block;
00204 __u32 reserved[5];
00205 };
00206
00207 #ifdef __KERNEL__
00208
00209 #include <linux/completion.h>
00210 #include <linux/interrupt.h>
00211 #include <linux/mutex.h>
00212
00213 #include <mach/board.h>
00214
00215 #define OMAP_LCDC_INV_VSYNC 0x0001
00216 #define OMAP_LCDC_INV_HSYNC 0x0002
00217 #define OMAP_LCDC_INV_PIX_CLOCK 0x0004
00218 #define OMAP_LCDC_INV_OUTPUT_EN 0x0008
00219 #define OMAP_LCDC_HSVS_RISING_EDGE 0x0010
00220 #define OMAP_LCDC_HSVS_OPPOSITE 0x0020
00221
00222 #define OMAP_LCDC_SIGNAL_MASK 0x003f
00223
00224 #define OMAP_LCDC_PANEL_TFT 0x0100
00225
00226 #define OMAPFB_PLANE_XRES_MIN 8
00227 #define OMAPFB_PLANE_YRES_MIN 8
00228
00229 #ifdef CONFIG_ARCH_OMAP1
00230 #define OMAPFB_PLANE_NUM 1
00231 #else
00232 #define OMAPFB_PLANE_NUM 3
00233 #endif
00234
00235 struct omapfb_device;
00236
00237 struct lcd_panel {
00238 const char *name;
00239 int config;
00240 int bpp;
00241 int data_lines;
00242
00243 int x_res, y_res;
00244 int pixel_clock;
00245 int hsw;
00246
00247 int hfp;
00248 int hbp;
00249 int vsw;
00250
00251 int vfp;
00252 int vbp;
00253 int acb;
00254 int pcd;
00255
00256
00257 int (*init) (struct lcd_panel *panel,
00258 struct omapfb_device *fbdev);
00259 void (*cleanup) (struct lcd_panel *panel);
00260 int (*enable) (struct lcd_panel *panel);
00261 void (*disable) (struct lcd_panel *panel);
00262 unsigned long (*get_caps) (struct lcd_panel *panel);
00263 int (*set_bklight_level)(struct lcd_panel *panel,
00264 unsigned int level);
00265 unsigned int (*get_bklight_level)(struct lcd_panel *panel);
00266 unsigned int (*get_bklight_max) (struct lcd_panel *panel);
00267 int (*run_test) (struct lcd_panel *panel, int test_num);
00268 };
00269
00270 struct extif_timings {
00271 int cs_on_time;
00272 int cs_off_time;
00273 int we_on_time;
00274 int we_off_time;
00275 int re_on_time;
00276 int re_off_time;
00277 int we_cycle_time;
00278 int re_cycle_time;
00279 int cs_pulse_width;
00280 int access_time;
00281
00282 int clk_div;
00283
00284 u32 tim[5];
00285
00286 int converted;
00287 };
00288
00289 struct lcd_ctrl_extif {
00290 int (*init) (struct omapfb_device *fbdev);
00291 void (*cleanup) (void);
00292 void (*get_clk_info) (u32 *clk_period, u32 *max_clk_div);
00293 unsigned long (*get_max_tx_rate)(void);
00294 int (*convert_timings) (struct extif_timings *timings);
00295 void (*set_timings) (const struct extif_timings *timings);
00296 void (*set_bits_per_cycle)(int bpc);
00297 void (*write_command) (const void *buf, unsigned int len);
00298 void (*read_data) (void *buf, unsigned int len);
00299 void (*write_data) (const void *buf, unsigned int len);
00300 void (*transfer_area) (int width, int height,
00301 void (callback)(void * data), void *data);
00302 int (*setup_tearsync) (unsigned pin_cnt,
00303 unsigned hs_pulse_time, unsigned vs_pulse_time,
00304 int hs_pol_inv, int vs_pol_inv, int div);
00305 int (*enable_tearsync) (int enable, unsigned line);
00306
00307 unsigned long max_transmit_size;
00308 };
00309
00310 struct omapfb_notifier_block {
00311 struct notifier_block nb;
00312 void *data;
00313 int plane_idx;
00314 };
00315
00316 typedef int (*omapfb_notifier_callback_t)(struct notifier_block *,
00317 unsigned long event,
00318 void *fbi);
00319
00320 struct omapfb_mem_region {
00321 u32 paddr;
00322 void __iomem *vaddr;
00323 unsigned long size;
00324 u8 type;
00325 enum omapfb_color_format format;
00326 unsigned format_used:1;
00327
00328
00329
00330 unsigned alloc:1;
00331 unsigned map:1;
00332 };
00333
00334 struct omapfb_mem_desc {
00335 int region_cnt;
00336 struct omapfb_mem_region region[OMAPFB_PLANE_NUM];
00337 };
00338
00339 struct lcd_ctrl {
00340 const char *name;
00341 void *data;
00342
00343 int (*init) (struct omapfb_device *fbdev,
00344 int ext_mode,
00345 struct omapfb_mem_desc *req_md);
00346 void (*cleanup) (void);
00347 void (*bind_client) (struct omapfb_notifier_block *nb);
00348 void (*get_caps) (int plane, struct omapfb_caps *caps);
00349 int (*set_update_mode)(enum omapfb_update_mode mode);
00350 enum omapfb_update_mode (*get_update_mode)(void);
00351 int (*setup_plane) (int plane, int enable,
00352 int channel_out,
00353 unsigned long baddr,
00354 int screen_width,
00355 int pos_x, int pos_y, int width,
00356 int height, int out_width,
00357 int out_height, int color_mode,
00358 int rotate);
00359 int (*setup_mem) (int plane, size_t size,
00360 int mem_type, unsigned long *paddr);
00361 int (*mmap) (struct fb_info *info,
00362 struct vm_area_struct *vma);
00363 int (*update_window) (struct fb_info *fbi,
00364 struct omapfb_update_window *win,
00365 void (*callback)(void *),
00366 void *callback_data);
00367 int (*sync) (enum omapfb_channel_out channel_out);
00368 void (*suspend) (void);
00369 void (*resume) (void);
00370 int (*run_test) (int test_num);
00371 int (*setcolreg) (u_int regno, u16 red, u16 green,
00372 u16 blue, u16 transp,
00373 int update_hw_mem);
00374 int (*set_color_key) (struct omapfb_color_key *ck);
00375 int (*get_color_key) (struct omapfb_color_key *ck);
00376 };
00377
00378 enum omapfb_state {
00379 OMAPFB_DISABLED = 0,
00380 OMAPFB_SUSPENDED= 99,
00381 OMAPFB_ACTIVE = 100
00382 };
00383
00384 struct omapfb_plane_struct {
00385 int idx;
00386 struct omapfb_plane_info info;
00387 enum omapfb_color_format color_mode;
00388 struct omapfb_device *fbdev;
00389 struct lcd_panel *panel;
00390 };
00391
00392 struct omapfb_device {
00393 int state;
00394 int ext_lcdc;
00395
00396 struct mutex rqueue_mutex;
00397
00398 int palette_size;
00399 u32 pseudo_palette[17];
00400
00401 struct lcd_panel *lcd_panel;
00402 const struct lcd_ctrl *ctrl;
00403 const struct lcd_ctrl *int_ctrl;
00404 struct lcd_ctrl_extif *ext_if;
00405
00406 struct lcd_panel *digital_panel;
00407
00408 struct device *dev;
00409 struct fb_var_screeninfo new_var;
00410
00411 struct omapfb_mem_desc mem_desc;
00412 struct fb_info *fb_info[OMAPFB_PLANE_NUM];
00413 };
00414
00415 struct omapfb_platform_data {
00416 struct omap_lcd_config lcd;
00417 struct omapfb_mem_desc mem_desc;
00418 void *ctrl_platform_data;
00419 };
00420
00421 #ifdef CONFIG_ARCH_OMAP1
00422 extern struct lcd_ctrl omap1_lcd_ctrl;
00423 #else
00424 extern struct lcd_ctrl omap2_disp_ctrl;
00425 #endif
00426
00427 extern void omapfb_set_platform_data(struct omapfb_platform_data *data);
00428
00429 extern void omapfb_reserve_sdram(void);
00430 extern void omapfb_register_panel(struct lcd_panel *panel);
00431 extern void omapfb_unregister_panel(struct lcd_panel *panel,
00432 struct omapfb_device *fbdev);
00433 extern void omapfb_write_first_pixel(struct omapfb_device *fbdev, u16 pixval);
00434 extern void omapfb_notify_clients(struct omapfb_device *fbdev,
00435 unsigned long event);
00436 extern int omapfb_register_client(struct omapfb_notifier_block *nb,
00437 omapfb_notifier_callback_t callback,
00438 void *callback_data);
00439 extern int omapfb_unregister_client(struct omapfb_notifier_block *nb);
00440 extern int omapfb_update_window_async(struct fb_info *fbi,
00441 struct omapfb_update_window *win,
00442 void (*callback)(void *),
00443 void *callback_data);
00444
00445
00446 extern void omapfb_set_ctrl_platform_data(void *pdata);
00447
00448 #endif
00449
00450 #endif