omapfb.h 11 KB

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