omapfb.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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, enum omapfb_update_mode)
  34. #define OMAPFB_GET_CAPS OMAP_IOR(42, unsigned long)
  35. #define OMAPFB_GET_UPDATE_MODE OMAP_IOW(43, enum omapfb_update_mode)
  36. #define OMAPFB_LCD_TEST OMAP_IOW(45, int)
  37. #define OMAPFB_CTRL_TEST OMAP_IOW(46, int)
  38. #define OMAPFB_UPDATE_WINDOW OMAP_IOW(47, struct omapfb_update_window)
  39. #define OMAPFB_SETUP_PLANE OMAP_IOW(48, struct omapfb_setup_plane)
  40. #define OMAPFB_ENABLE_PLANE OMAP_IOW(49, struct omapfb_enable_plane)
  41. #define OMAPFB_SET_COLOR_KEY OMAP_IOW(50, struct omapfb_color_key)
  42. #define OMAPFB_CAPS_GENERIC_MASK 0x00000fff
  43. #define OMAPFB_CAPS_LCDC_MASK 0x00fff000
  44. #define OMAPFB_CAPS_PANEL_MASK 0xff000000
  45. #define OMAPFB_CAPS_MANUAL_UPDATE 0x00001000
  46. #define OMAPFB_CAPS_SET_BACKLIGHT 0x01000000
  47. /* Values from DSP must map to lower 16-bits */
  48. #define OMAPFB_FORMAT_MASK 0x00ff
  49. #define OMAPFB_FORMAT_FLAG_DOUBLE 0x0100
  50. enum omapfb_color_format {
  51. OMAPFB_COLOR_RGB565 = 0,
  52. OMAPFB_COLOR_YUV422,
  53. OMAPFB_COLOR_YUV420,
  54. OMAPFB_COLOR_CLUT_8BPP,
  55. OMAPFB_COLOR_CLUT_4BPP,
  56. OMAPFB_COLOR_CLUT_2BPP,
  57. OMAPFB_COLOR_CLUT_1BPP,
  58. };
  59. struct omapfb_update_window {
  60. u32 x, y;
  61. u32 width, height;
  62. u32 format;
  63. };
  64. enum omapfb_plane {
  65. OMAPFB_PLANE_GFX = 0,
  66. OMAPFB_PLANE_VID1,
  67. OMAPFB_PLANE_VID2,
  68. };
  69. enum omapfb_channel_out {
  70. OMAPFB_CHANNEL_OUT_LCD = 0,
  71. OMAPFB_CHANNEL_OUT_DIGIT,
  72. };
  73. struct omapfb_setup_plane {
  74. u8 plane;
  75. u8 channel_out;
  76. u32 offset;
  77. u32 pos_x, pos_y;
  78. u32 width, height;
  79. u32 color_mode;
  80. };
  81. struct omapfb_enable_plane {
  82. u8 plane;
  83. u8 enable;
  84. };
  85. enum omapfb_color_key_type {
  86. OMAPFB_COLOR_KEY_DISABLED = 0,
  87. OMAPFB_COLOR_KEY_GFX_DST,
  88. OMAPFB_COLOR_KEY_VID_SRC,
  89. };
  90. struct omapfb_color_key {
  91. u8 channel_out;
  92. u32 background;
  93. u32 trans_key;
  94. u8 key_type;
  95. };
  96. enum omapfb_update_mode {
  97. OMAPFB_UPDATE_DISABLED = 0,
  98. OMAPFB_AUTO_UPDATE,
  99. OMAPFB_MANUAL_UPDATE
  100. };
  101. #ifdef __KERNEL__
  102. #include <linux/completion.h>
  103. #include <linux/interrupt.h>
  104. #include <linux/fb.h>
  105. #define OMAP_LCDC_INV_VSYNC 0x0001
  106. #define OMAP_LCDC_INV_HSYNC 0x0002
  107. #define OMAP_LCDC_INV_PIX_CLOCK 0x0004
  108. #define OMAP_LCDC_INV_OUTPUT_EN 0x0008
  109. #define OMAP_LCDC_HSVS_RISING_EDGE 0x0010
  110. #define OMAP_LCDC_HSVS_OPPOSITE 0x0020
  111. #define OMAP_LCDC_SIGNAL_MASK 0x003f
  112. #define OMAP_LCDC_PANEL_TFT 0x0100
  113. #ifdef CONFIG_ARCH_OMAP1
  114. #define OMAPFB_PLANE_NUM 1
  115. #else
  116. #define OMAPFB_PLANE_NUM 3
  117. #endif
  118. struct omapfb_device;
  119. struct lcd_panel {
  120. const char *name;
  121. int config; /* TFT/STN, signal inversion */
  122. int bpp; /* Pixel format in fb mem */
  123. int data_lines; /* Lines on LCD HW interface */
  124. int x_res, y_res;
  125. int pixel_clock; /* In kHz */
  126. int hsw; /* Horizontal synchronization
  127. pulse width */
  128. int hfp; /* Horizontal front porch */
  129. int hbp; /* Horizontal back porch */
  130. int vsw; /* Vertical synchronization
  131. pulse width */
  132. int vfp; /* Vertical front porch */
  133. int vbp; /* Vertical back porch */
  134. int acb; /* ac-bias pin frequency */
  135. int pcd; /* pixel clock divider.
  136. Obsolete use pixel_clock instead */
  137. int (*init) (struct omapfb_device *fbdev);
  138. void (*cleanup) (void);
  139. int (*enable) (void);
  140. void (*disable) (void);
  141. unsigned long (*get_caps) (void);
  142. int (*set_bklight_level)(unsigned int level);
  143. unsigned int (*get_bklight_level)(void);
  144. unsigned int (*get_bklight_max) (void);
  145. int (*run_test) (int test_num);
  146. };
  147. struct omapfb_device;
  148. struct extif_timings {
  149. int cs_on_time;
  150. int cs_off_time;
  151. int we_on_time;
  152. int we_off_time;
  153. int re_on_time;
  154. int re_off_time;
  155. int we_cycle_time;
  156. int re_cycle_time;
  157. int cs_pulse_width;
  158. int access_time;
  159. };
  160. struct lcd_ctrl_extif {
  161. int (*init) (void);
  162. void (*cleanup) (void);
  163. void (*set_timings) (const struct extif_timings *timings);
  164. void (*write_command) (u32 cmd);
  165. u32 (*read_data) (void);
  166. void (*write_data) (u32 data);
  167. void (*transfer_area) (int width, int height,
  168. void (callback)(void * data), void *data);
  169. };
  170. struct lcd_ctrl {
  171. const char *name;
  172. void *data;
  173. int (*init) (struct omapfb_device *fbdev,
  174. int ext_mode, int req_vram_size);
  175. void (*cleanup) (void);
  176. void (*get_vram_layout)(unsigned long *size,
  177. void **virt_base,
  178. dma_addr_t *phys_base);
  179. unsigned long (*get_caps) (void);
  180. int (*set_update_mode)(enum omapfb_update_mode mode);
  181. enum omapfb_update_mode (*get_update_mode)(void);
  182. int (*setup_plane) (int plane, int channel_out,
  183. unsigned long offset,
  184. int screen_width,
  185. int pos_x, int pos_y, int width,
  186. int height, int color_mode);
  187. int (*enable_plane) (int plane, int enable);
  188. int (*update_window) (struct omapfb_update_window *win,
  189. void (*callback)(void *),
  190. void *callback_data);
  191. void (*sync) (void);
  192. void (*suspend) (void);
  193. void (*resume) (void);
  194. int (*run_test) (int test_num);
  195. int (*setcolreg) (u_int regno, u16 red, u16 green,
  196. u16 blue, u16 transp,
  197. int update_hw_mem);
  198. int (*set_color_key) (struct omapfb_color_key *ck);
  199. };
  200. enum omapfb_state {
  201. OMAPFB_DISABLED = 0,
  202. OMAPFB_SUSPENDED= 99,
  203. OMAPFB_ACTIVE = 100
  204. };
  205. struct omapfb_device {
  206. int state;
  207. int ext_lcdc; /* Using external
  208. LCD controller */
  209. struct semaphore rqueue_sema;
  210. void *vram_virt_base;
  211. dma_addr_t vram_phys_base;
  212. unsigned long vram_size;
  213. int color_mode;
  214. int palette_size;
  215. int mirror;
  216. u32 pseudo_palette[17];
  217. struct lcd_panel *panel; /* LCD panel */
  218. struct lcd_ctrl *ctrl; /* LCD controller */
  219. struct lcd_ctrl *int_ctrl; /* internal LCD ctrl */
  220. struct lcd_ctrl_extif *ext_if; /* LCD ctrl external
  221. interface */
  222. struct fb_info *fb_info;
  223. struct device *dev;
  224. };
  225. extern struct lcd_panel h3_panel;
  226. extern struct lcd_panel h2_panel;
  227. extern struct lcd_panel p2_panel;
  228. extern struct lcd_panel osk_panel;
  229. extern struct lcd_panel innovator1610_panel;
  230. extern struct lcd_panel innovator1510_panel;
  231. #ifdef CONFIG_ARCH_OMAP1
  232. extern struct lcd_ctrl omap1_lcd_ctrl;
  233. #else
  234. extern struct lcd_ctrl omap2_disp_ctrl;
  235. #endif
  236. extern void omapfb_write_first_pixel(struct omapfb_device *fbdev, u16 pixval);
  237. #endif /* __KERNEL__ */
  238. #endif /* __OMAPFB_H */