omapfb.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. /*
  2. * File: include/asm-arm/arch-omap/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. /* IOCTL commands. */
  26. #define OMAP_IOW(num, dtype) _IOW('O', num, dtype)
  27. #define OMAP_IOR(num, dtype) _IOR('O', num, dtype)
  28. #define OMAP_IOWR(num, dtype) _IOWR('O', num, dtype)
  29. #define OMAP_IO(num) _IO('O', num)
  30. #define OMAPFB_MIRROR OMAP_IOW(31, int)
  31. #define OMAPFB_SYNC_GFX OMAP_IO(37)
  32. #define OMAPFB_VSYNC OMAP_IO(38)
  33. #define OMAPFB_SET_UPDATE_MODE OMAP_IOW(40, int)
  34. #define OMAPFB_UPDATE_WINDOW_OLD OMAP_IOW(41, struct omapfb_update_window_old)
  35. #define OMAPFB_GET_CAPS OMAP_IOR(42, unsigned long)
  36. #define OMAPFB_GET_UPDATE_MODE OMAP_IOW(43, int)
  37. #define OMAPFB_LCD_TEST OMAP_IOW(45, int)
  38. #define OMAPFB_CTRL_TEST OMAP_IOW(46, int)
  39. #define OMAPFB_UPDATE_WINDOW OMAP_IOW(47, struct omapfb_update_window)
  40. #define OMAPFB_SETUP_PLANE OMAP_IOW(48, struct omapfb_setup_plane)
  41. #define OMAPFB_ENABLE_PLANE OMAP_IOW(49, struct omapfb_enable_plane)
  42. #define OMAPFB_SET_COLOR_KEY OMAP_IOW(50, struct omapfb_color_key)
  43. #define OMAPFB_CAPS_GENERIC_MASK 0x00000fff
  44. #define OMAPFB_CAPS_LCDC_MASK 0x00fff000
  45. #define OMAPFB_CAPS_PANEL_MASK 0xff000000
  46. #define OMAPFB_CAPS_MANUAL_UPDATE 0x00001000
  47. #define OMAPFB_CAPS_SET_BACKLIGHT 0x01000000
  48. /* Values from DSP must map to lower 16-bits */
  49. #define OMAPFB_FORMAT_MASK 0x00ff
  50. #define OMAPFB_FORMAT_FLAG_DOUBLE 0x0100
  51. enum omapfb_color_format {
  52. OMAPFB_COLOR_RGB565 = 0,
  53. OMAPFB_COLOR_YUV422,
  54. OMAPFB_COLOR_YUV420,
  55. OMAPFB_COLOR_CLUT_8BPP,
  56. OMAPFB_COLOR_CLUT_4BPP,
  57. OMAPFB_COLOR_CLUT_2BPP,
  58. OMAPFB_COLOR_CLUT_1BPP,
  59. };
  60. struct omapfb_update_window {
  61. __u32 x, y;
  62. __u32 width, height;
  63. __u32 format;
  64. };
  65. struct omapfb_update_window_old {
  66. __u32 x, y;
  67. __u32 width, height;
  68. };
  69. enum omapfb_plane {
  70. OMAPFB_PLANE_GFX = 0,
  71. OMAPFB_PLANE_VID1,
  72. OMAPFB_PLANE_VID2,
  73. };
  74. enum omapfb_channel_out {
  75. OMAPFB_CHANNEL_OUT_LCD = 0,
  76. OMAPFB_CHANNEL_OUT_DIGIT,
  77. };
  78. struct omapfb_setup_plane {
  79. __u8 plane;
  80. __u8 channel_out;
  81. __u32 offset;
  82. __u32 pos_x, pos_y;
  83. __u32 width, height;
  84. __u32 color_mode;
  85. };
  86. struct omapfb_enable_plane {
  87. __u8 plane;
  88. __u8 enable;
  89. };
  90. enum omapfb_color_key_type {
  91. OMAPFB_COLOR_KEY_DISABLED = 0,
  92. OMAPFB_COLOR_KEY_GFX_DST,
  93. OMAPFB_COLOR_KEY_VID_SRC,
  94. };
  95. struct omapfb_color_key {
  96. __u8 channel_out;
  97. __u32 background;
  98. __u32 trans_key;
  99. __u8 key_type;
  100. };
  101. enum omapfb_update_mode {
  102. OMAPFB_UPDATE_DISABLED = 0,
  103. OMAPFB_AUTO_UPDATE,
  104. OMAPFB_MANUAL_UPDATE
  105. };
  106. #ifdef __KERNEL__
  107. #include <linux/completion.h>
  108. #include <linux/interrupt.h>
  109. #include <linux/fb.h>
  110. #include <linux/mutex.h>
  111. #include <asm/arch/board.h>
  112. #define OMAP_LCDC_INV_VSYNC 0x0001
  113. #define OMAP_LCDC_INV_HSYNC 0x0002
  114. #define OMAP_LCDC_INV_PIX_CLOCK 0x0004
  115. #define OMAP_LCDC_INV_OUTPUT_EN 0x0008
  116. #define OMAP_LCDC_HSVS_RISING_EDGE 0x0010
  117. #define OMAP_LCDC_HSVS_OPPOSITE 0x0020
  118. #define OMAP_LCDC_SIGNAL_MASK 0x003f
  119. #define OMAP_LCDC_PANEL_TFT 0x0100
  120. #ifdef CONFIG_ARCH_OMAP1
  121. #define OMAPFB_PLANE_NUM 1
  122. #else
  123. #define OMAPFB_PLANE_NUM 3
  124. #endif
  125. struct omapfb_device;
  126. struct lcd_panel {
  127. const char *name;
  128. int config; /* TFT/STN, signal inversion */
  129. int bpp; /* Pixel format in fb mem */
  130. int data_lines; /* Lines on LCD HW interface */
  131. int x_res, y_res;
  132. int pixel_clock; /* In kHz */
  133. int hsw; /* Horizontal synchronization
  134. pulse width */
  135. int hfp; /* Horizontal front porch */
  136. int hbp; /* Horizontal back porch */
  137. int vsw; /* Vertical synchronization
  138. pulse width */
  139. int vfp; /* Vertical front porch */
  140. int vbp; /* Vertical back porch */
  141. int acb; /* ac-bias pin frequency */
  142. int pcd; /* pixel clock divider.
  143. Obsolete use pixel_clock instead */
  144. int (*init) (struct omapfb_device *fbdev);
  145. void (*cleanup) (void);
  146. int (*enable) (void);
  147. void (*disable) (void);
  148. unsigned long (*get_caps) (void);
  149. int (*set_bklight_level)(unsigned int level);
  150. unsigned int (*get_bklight_level)(void);
  151. unsigned int (*get_bklight_max) (void);
  152. int (*run_test) (int test_num);
  153. };
  154. struct omapfb_device;
  155. struct extif_timings {
  156. int cs_on_time;
  157. int cs_off_time;
  158. int we_on_time;
  159. int we_off_time;
  160. int re_on_time;
  161. int re_off_time;
  162. int we_cycle_time;
  163. int re_cycle_time;
  164. int cs_pulse_width;
  165. int access_time;
  166. int clk_div;
  167. u32 tim[5]; /* set by extif->convert_timings */
  168. int converted;
  169. };
  170. struct lcd_ctrl_extif {
  171. int (*init) (void);
  172. void (*cleanup) (void);
  173. void (*get_clk_info) (u32 *clk_period, u32 *max_clk_div);
  174. int (*convert_timings) (struct extif_timings *timings);
  175. void (*set_timings) (const struct extif_timings *timings);
  176. void (*set_bits_per_cycle)(int bpc);
  177. void (*write_command) (const void *buf, unsigned int len);
  178. void (*read_data) (void *buf, unsigned int len);
  179. void (*write_data) (const void *buf, unsigned int len);
  180. void (*transfer_area) (int width, int height,
  181. void (callback)(void * data), void *data);
  182. unsigned long max_transmit_size;
  183. };
  184. struct omapfb_notifier_block {
  185. struct notifier_block nb;
  186. void *data;
  187. };
  188. typedef int (*omapfb_notifier_callback_t)(struct omapfb_notifier_block *,
  189. unsigned long event,
  190. struct omapfb_device *fbdev);
  191. struct lcd_ctrl {
  192. const char *name;
  193. void *data;
  194. int (*init) (struct omapfb_device *fbdev,
  195. int ext_mode, int req_vram_size);
  196. void (*cleanup) (void);
  197. void (*bind_client) (struct omapfb_notifier_block *nb);
  198. void (*get_vram_layout)(unsigned long *size,
  199. void **virt_base,
  200. dma_addr_t *phys_base);
  201. int (*mmap) (struct vm_area_struct *vma);
  202. unsigned long (*get_caps) (void);
  203. int (*set_update_mode)(enum omapfb_update_mode mode);
  204. enum omapfb_update_mode (*get_update_mode)(void);
  205. int (*setup_plane) (int plane, int channel_out,
  206. unsigned long offset,
  207. int screen_width,
  208. int pos_x, int pos_y, int width,
  209. int height, int color_mode);
  210. int (*enable_plane) (int plane, int enable);
  211. int (*update_window) (struct omapfb_update_window *win,
  212. void (*callback)(void *),
  213. void *callback_data);
  214. void (*sync) (void);
  215. void (*suspend) (void);
  216. void (*resume) (void);
  217. int (*run_test) (int test_num);
  218. int (*setcolreg) (u_int regno, u16 red, u16 green,
  219. u16 blue, u16 transp,
  220. int update_hw_mem);
  221. int (*set_color_key) (struct omapfb_color_key *ck);
  222. };
  223. enum omapfb_state {
  224. OMAPFB_DISABLED = 0,
  225. OMAPFB_SUSPENDED= 99,
  226. OMAPFB_ACTIVE = 100
  227. };
  228. struct omapfb_device {
  229. int state;
  230. int ext_lcdc; /* Using external
  231. LCD controller */
  232. struct mutex rqueue_mutex;
  233. void *vram_virt_base;
  234. dma_addr_t vram_phys_base;
  235. unsigned long vram_size;
  236. int color_mode;
  237. int palette_size;
  238. int mirror;
  239. u32 pseudo_palette[17];
  240. struct lcd_panel *panel; /* LCD panel */
  241. struct lcd_ctrl *ctrl; /* LCD controller */
  242. struct lcd_ctrl *int_ctrl; /* internal LCD ctrl */
  243. struct lcd_ctrl_extif *ext_if; /* LCD ctrl external
  244. interface */
  245. struct fb_info *fb_info;
  246. struct device *dev;
  247. };
  248. struct omapfb_platform_data {
  249. struct omap_lcd_config lcd;
  250. struct omap_fbmem_config fbmem;
  251. };
  252. #define OMAPFB_EVENT_READY 1
  253. #define OMAPFB_EVENT_DISABLED 2
  254. #ifdef CONFIG_ARCH_OMAP1
  255. extern struct lcd_ctrl omap1_lcd_ctrl;
  256. #else
  257. extern struct lcd_ctrl omap2_disp_ctrl;
  258. #endif
  259. extern void omapfb_register_panel(struct lcd_panel *panel);
  260. extern void omapfb_write_first_pixel(struct omapfb_device *fbdev, u16 pixval);
  261. extern void omapfb_notify_clients(struct omapfb_device *fbdev,
  262. unsigned long event);
  263. extern int omapfb_register_client(struct omapfb_notifier_block *nb,
  264. omapfb_notifier_callback_t callback,
  265. void *callback_data);
  266. extern int omapfb_unregister_client(struct omapfb_notifier_block *nb);
  267. extern int omapfb_update_window_async(struct omapfb_update_window *win,
  268. void (*callback)(void *),
  269. void *callback_data);
  270. /* in arch/arm/plat-omap/devices.c */
  271. extern void omapfb_reserve_mem(void);
  272. #endif /* __KERNEL__ */
  273. #endif /* __OMAPFB_H */