omapfb.h 11 KB

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