omapfb.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /*
  2. * File: drivers/video/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. #include <linux/fb.h>
  26. #include <linux/mutex.h>
  27. #include <linux/omapfb.h>
  28. #define OMAPFB_EVENT_READY 1
  29. #define OMAPFB_EVENT_DISABLED 2
  30. #define OMAP_LCDC_INV_VSYNC 0x0001
  31. #define OMAP_LCDC_INV_HSYNC 0x0002
  32. #define OMAP_LCDC_INV_PIX_CLOCK 0x0004
  33. #define OMAP_LCDC_INV_OUTPUT_EN 0x0008
  34. #define OMAP_LCDC_HSVS_RISING_EDGE 0x0010
  35. #define OMAP_LCDC_HSVS_OPPOSITE 0x0020
  36. #define OMAP_LCDC_SIGNAL_MASK 0x003f
  37. #define OMAP_LCDC_PANEL_TFT 0x0100
  38. #define OMAPFB_PLANE_XRES_MIN 8
  39. #define OMAPFB_PLANE_YRES_MIN 8
  40. struct omapfb_device;
  41. #define OMAPFB_PLANE_NUM 1
  42. struct omapfb_mem_region {
  43. u32 paddr;
  44. void __iomem *vaddr;
  45. unsigned long size;
  46. u8 type; /* OMAPFB_PLANE_MEM_* */
  47. enum omapfb_color_format format;/* OMAPFB_COLOR_* */
  48. unsigned format_used:1; /* Must be set when format is set.
  49. * Needed b/c of the badly chosen 0
  50. * base for OMAPFB_COLOR_* values
  51. */
  52. unsigned alloc:1; /* allocated by the driver */
  53. unsigned map:1; /* kernel mapped by the driver */
  54. };
  55. struct omapfb_mem_desc {
  56. int region_cnt;
  57. struct omapfb_mem_region region[OMAPFB_PLANE_NUM];
  58. };
  59. struct lcd_panel {
  60. const char *name;
  61. int config; /* TFT/STN, signal inversion */
  62. int bpp; /* Pixel format in fb mem */
  63. int data_lines; /* Lines on LCD HW interface */
  64. int x_res, y_res;
  65. int pixel_clock; /* In kHz */
  66. int hsw; /* Horizontal synchronization
  67. pulse width */
  68. int hfp; /* Horizontal front porch */
  69. int hbp; /* Horizontal back porch */
  70. int vsw; /* Vertical synchronization
  71. pulse width */
  72. int vfp; /* Vertical front porch */
  73. int vbp; /* Vertical back porch */
  74. int acb; /* ac-bias pin frequency */
  75. int pcd; /* pixel clock divider.
  76. Obsolete use pixel_clock instead */
  77. int (*init) (struct lcd_panel *panel,
  78. struct omapfb_device *fbdev);
  79. void (*cleanup) (struct lcd_panel *panel);
  80. int (*enable) (struct lcd_panel *panel);
  81. void (*disable) (struct lcd_panel *panel);
  82. unsigned long (*get_caps) (struct lcd_panel *panel);
  83. int (*set_bklight_level)(struct lcd_panel *panel,
  84. unsigned int level);
  85. unsigned int (*get_bklight_level)(struct lcd_panel *panel);
  86. unsigned int (*get_bklight_max) (struct lcd_panel *panel);
  87. int (*run_test) (struct lcd_panel *panel, int test_num);
  88. };
  89. struct extif_timings {
  90. int cs_on_time;
  91. int cs_off_time;
  92. int we_on_time;
  93. int we_off_time;
  94. int re_on_time;
  95. int re_off_time;
  96. int we_cycle_time;
  97. int re_cycle_time;
  98. int cs_pulse_width;
  99. int access_time;
  100. int clk_div;
  101. u32 tim[5]; /* set by extif->convert_timings */
  102. int converted;
  103. };
  104. struct lcd_ctrl_extif {
  105. int (*init) (struct omapfb_device *fbdev);
  106. void (*cleanup) (void);
  107. void (*get_clk_info) (u32 *clk_period, u32 *max_clk_div);
  108. unsigned long (*get_max_tx_rate)(void);
  109. int (*convert_timings) (struct extif_timings *timings);
  110. void (*set_timings) (const struct extif_timings *timings);
  111. void (*set_bits_per_cycle)(int bpc);
  112. void (*write_command) (const void *buf, unsigned int len);
  113. void (*read_data) (void *buf, unsigned int len);
  114. void (*write_data) (const void *buf, unsigned int len);
  115. void (*transfer_area) (int width, int height,
  116. void (callback)(void *data), void *data);
  117. int (*setup_tearsync) (unsigned pin_cnt,
  118. unsigned hs_pulse_time, unsigned vs_pulse_time,
  119. int hs_pol_inv, int vs_pol_inv, int div);
  120. int (*enable_tearsync) (int enable, unsigned line);
  121. unsigned long max_transmit_size;
  122. };
  123. struct omapfb_notifier_block {
  124. struct notifier_block nb;
  125. void *data;
  126. int plane_idx;
  127. };
  128. typedef int (*omapfb_notifier_callback_t)(struct notifier_block *,
  129. unsigned long event,
  130. void *fbi);
  131. struct lcd_ctrl {
  132. const char *name;
  133. void *data;
  134. int (*init) (struct omapfb_device *fbdev,
  135. int ext_mode,
  136. struct omapfb_mem_desc *req_md);
  137. void (*cleanup) (void);
  138. void (*bind_client) (struct omapfb_notifier_block *nb);
  139. void (*get_caps) (int plane, struct omapfb_caps *caps);
  140. int (*set_update_mode)(enum omapfb_update_mode mode);
  141. enum omapfb_update_mode (*get_update_mode)(void);
  142. int (*setup_plane) (int plane, int channel_out,
  143. unsigned long offset,
  144. int screen_width,
  145. int pos_x, int pos_y, int width,
  146. int height, int color_mode);
  147. int (*set_rotate) (int angle);
  148. int (*setup_mem) (int plane, size_t size,
  149. int mem_type, unsigned long *paddr);
  150. int (*mmap) (struct fb_info *info,
  151. struct vm_area_struct *vma);
  152. int (*set_scale) (int plane,
  153. int orig_width, int orig_height,
  154. int out_width, int out_height);
  155. int (*enable_plane) (int plane, int enable);
  156. int (*update_window) (struct fb_info *fbi,
  157. struct omapfb_update_window *win,
  158. void (*callback)(void *),
  159. void *callback_data);
  160. void (*sync) (void);
  161. void (*suspend) (void);
  162. void (*resume) (void);
  163. int (*run_test) (int test_num);
  164. int (*setcolreg) (u_int regno, u16 red, u16 green,
  165. u16 blue, u16 transp,
  166. int update_hw_mem);
  167. int (*set_color_key) (struct omapfb_color_key *ck);
  168. int (*get_color_key) (struct omapfb_color_key *ck);
  169. };
  170. enum omapfb_state {
  171. OMAPFB_DISABLED = 0,
  172. OMAPFB_SUSPENDED = 99,
  173. OMAPFB_ACTIVE = 100
  174. };
  175. struct omapfb_plane_struct {
  176. int idx;
  177. struct omapfb_plane_info info;
  178. enum omapfb_color_format color_mode;
  179. struct omapfb_device *fbdev;
  180. };
  181. struct omapfb_device {
  182. int state;
  183. int ext_lcdc; /* Using external
  184. LCD controller */
  185. struct mutex rqueue_mutex;
  186. int palette_size;
  187. u32 pseudo_palette[17];
  188. struct lcd_panel *panel; /* LCD panel */
  189. const struct lcd_ctrl *ctrl; /* LCD controller */
  190. const struct lcd_ctrl *int_ctrl; /* internal LCD ctrl */
  191. struct lcd_ctrl_extif *ext_if; /* LCD ctrl external
  192. interface */
  193. struct device *dev;
  194. struct fb_var_screeninfo new_var; /* for mode changes */
  195. struct omapfb_mem_desc mem_desc;
  196. struct fb_info *fb_info[OMAPFB_PLANE_NUM];
  197. struct platform_device *dssdev; /* dummy dev for clocks */
  198. };
  199. extern struct lcd_ctrl omap1_lcd_ctrl;
  200. extern void omapfb_register_panel(struct lcd_panel *panel);
  201. extern void omapfb_write_first_pixel(struct omapfb_device *fbdev, u16 pixval);
  202. extern void omapfb_notify_clients(struct omapfb_device *fbdev,
  203. unsigned long event);
  204. extern int omapfb_register_client(struct omapfb_notifier_block *nb,
  205. omapfb_notifier_callback_t callback,
  206. void *callback_data);
  207. extern int omapfb_unregister_client(struct omapfb_notifier_block *nb);
  208. extern int omapfb_update_window_async(struct fb_info *fbi,
  209. struct omapfb_update_window *win,
  210. void (*callback)(void *),
  211. void *callback_data);
  212. #endif /* __OMAPFB_H */