omapfb.h 6.7 KB

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