omapdss.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2016 Texas Instruments Incorporated - https://www.ti.com/
  4. * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
  5. */
  6. #ifndef __OMAP_DRM_DSS_H
  7. #define __OMAP_DRM_DSS_H
  8. #include <drm/drm_color_mgmt.h>
  9. #include <drm/drm_crtc.h>
  10. #include <drm/drm_mode.h>
  11. #include <linux/device.h>
  12. #include <linux/interrupt.h>
  13. #include <linux/list.h>
  14. #include <linux/platform_data/omapdss.h>
  15. #include <video/videomode.h>
  16. #define DISPC_IRQ_FRAMEDONE (1 << 0)
  17. #define DISPC_IRQ_VSYNC (1 << 1)
  18. #define DISPC_IRQ_EVSYNC_EVEN (1 << 2)
  19. #define DISPC_IRQ_EVSYNC_ODD (1 << 3)
  20. #define DISPC_IRQ_ACBIAS_COUNT_STAT (1 << 4)
  21. #define DISPC_IRQ_PROG_LINE_NUM (1 << 5)
  22. #define DISPC_IRQ_GFX_FIFO_UNDERFLOW (1 << 6)
  23. #define DISPC_IRQ_GFX_END_WIN (1 << 7)
  24. #define DISPC_IRQ_PAL_GAMMA_MASK (1 << 8)
  25. #define DISPC_IRQ_OCP_ERR (1 << 9)
  26. #define DISPC_IRQ_VID1_FIFO_UNDERFLOW (1 << 10)
  27. #define DISPC_IRQ_VID1_END_WIN (1 << 11)
  28. #define DISPC_IRQ_VID2_FIFO_UNDERFLOW (1 << 12)
  29. #define DISPC_IRQ_VID2_END_WIN (1 << 13)
  30. #define DISPC_IRQ_SYNC_LOST (1 << 14)
  31. #define DISPC_IRQ_SYNC_LOST_DIGIT (1 << 15)
  32. #define DISPC_IRQ_WAKEUP (1 << 16)
  33. #define DISPC_IRQ_SYNC_LOST2 (1 << 17)
  34. #define DISPC_IRQ_VSYNC2 (1 << 18)
  35. #define DISPC_IRQ_VID3_END_WIN (1 << 19)
  36. #define DISPC_IRQ_VID3_FIFO_UNDERFLOW (1 << 20)
  37. #define DISPC_IRQ_ACBIAS_COUNT_STAT2 (1 << 21)
  38. #define DISPC_IRQ_FRAMEDONE2 (1 << 22)
  39. #define DISPC_IRQ_FRAMEDONEWB (1 << 23)
  40. #define DISPC_IRQ_FRAMEDONETV (1 << 24)
  41. #define DISPC_IRQ_WBBUFFEROVERFLOW (1 << 25)
  42. #define DISPC_IRQ_WBUNCOMPLETEERROR (1 << 26)
  43. #define DISPC_IRQ_SYNC_LOST3 (1 << 27)
  44. #define DISPC_IRQ_VSYNC3 (1 << 28)
  45. #define DISPC_IRQ_ACBIAS_COUNT_STAT3 (1 << 29)
  46. #define DISPC_IRQ_FRAMEDONE3 (1 << 30)
  47. struct dispc_device;
  48. struct drm_connector;
  49. struct dss_device;
  50. struct dss_lcd_mgr_config;
  51. struct hdmi_avi_infoframe;
  52. struct omap_drm_private;
  53. struct omap_dss_device;
  54. struct snd_aes_iec958;
  55. struct snd_cea_861_aud_if;
  56. enum omap_display_type {
  57. OMAP_DISPLAY_TYPE_NONE = 0,
  58. OMAP_DISPLAY_TYPE_DPI = 1 << 0,
  59. OMAP_DISPLAY_TYPE_DBI = 1 << 1,
  60. OMAP_DISPLAY_TYPE_SDI = 1 << 2,
  61. OMAP_DISPLAY_TYPE_DSI = 1 << 3,
  62. OMAP_DISPLAY_TYPE_VENC = 1 << 4,
  63. OMAP_DISPLAY_TYPE_HDMI = 1 << 5,
  64. OMAP_DISPLAY_TYPE_DVI = 1 << 6,
  65. };
  66. enum omap_plane_id {
  67. OMAP_DSS_GFX = 0,
  68. OMAP_DSS_VIDEO1 = 1,
  69. OMAP_DSS_VIDEO2 = 2,
  70. OMAP_DSS_VIDEO3 = 3,
  71. OMAP_DSS_WB = 4,
  72. };
  73. enum omap_channel {
  74. OMAP_DSS_CHANNEL_LCD = 0,
  75. OMAP_DSS_CHANNEL_DIGIT = 1,
  76. OMAP_DSS_CHANNEL_LCD2 = 2,
  77. OMAP_DSS_CHANNEL_LCD3 = 3,
  78. OMAP_DSS_CHANNEL_WB = 4,
  79. };
  80. enum omap_color_mode {
  81. _UNUSED_,
  82. };
  83. enum omap_dss_load_mode {
  84. OMAP_DSS_LOAD_CLUT_AND_FRAME = 0,
  85. OMAP_DSS_LOAD_CLUT_ONLY = 1,
  86. OMAP_DSS_LOAD_FRAME_ONLY = 2,
  87. OMAP_DSS_LOAD_CLUT_ONCE_FRAME = 3,
  88. };
  89. enum omap_dss_trans_key_type {
  90. OMAP_DSS_COLOR_KEY_GFX_DST = 0,
  91. OMAP_DSS_COLOR_KEY_VID_SRC = 1,
  92. };
  93. enum omap_dss_signal_level {
  94. OMAPDSS_SIG_ACTIVE_LOW,
  95. OMAPDSS_SIG_ACTIVE_HIGH,
  96. };
  97. enum omap_dss_signal_edge {
  98. OMAPDSS_DRIVE_SIG_FALLING_EDGE,
  99. OMAPDSS_DRIVE_SIG_RISING_EDGE,
  100. };
  101. enum omap_dss_venc_type {
  102. OMAP_DSS_VENC_TYPE_COMPOSITE,
  103. OMAP_DSS_VENC_TYPE_SVIDEO,
  104. };
  105. enum omap_dss_rotation_type {
  106. OMAP_DSS_ROT_NONE = 0,
  107. OMAP_DSS_ROT_TILER = 1 << 0,
  108. };
  109. enum omap_overlay_caps {
  110. OMAP_DSS_OVL_CAP_SCALE = 1 << 0,
  111. OMAP_DSS_OVL_CAP_GLOBAL_ALPHA = 1 << 1,
  112. OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA = 1 << 2,
  113. OMAP_DSS_OVL_CAP_ZORDER = 1 << 3,
  114. OMAP_DSS_OVL_CAP_POS = 1 << 4,
  115. OMAP_DSS_OVL_CAP_REPLICATION = 1 << 5,
  116. };
  117. enum omap_dss_output_id {
  118. OMAP_DSS_OUTPUT_DPI = 1 << 0,
  119. OMAP_DSS_OUTPUT_DBI = 1 << 1,
  120. OMAP_DSS_OUTPUT_SDI = 1 << 2,
  121. OMAP_DSS_OUTPUT_DSI1 = 1 << 3,
  122. OMAP_DSS_OUTPUT_DSI2 = 1 << 4,
  123. OMAP_DSS_OUTPUT_VENC = 1 << 5,
  124. OMAP_DSS_OUTPUT_HDMI = 1 << 6,
  125. };
  126. struct omap_dss_cpr_coefs {
  127. s16 rr, rg, rb;
  128. s16 gr, gg, gb;
  129. s16 br, bg, bb;
  130. };
  131. struct omap_overlay_info {
  132. dma_addr_t paddr;
  133. dma_addr_t p_uv_addr; /* for NV12 format */
  134. u16 screen_width;
  135. u16 width;
  136. u16 height;
  137. u32 fourcc;
  138. u8 rotation;
  139. enum omap_dss_rotation_type rotation_type;
  140. u16 pos_x;
  141. u16 pos_y;
  142. u16 out_width; /* if 0, out_width == width */
  143. u16 out_height; /* if 0, out_height == height */
  144. u8 global_alpha;
  145. u8 pre_mult_alpha;
  146. u8 zorder;
  147. enum drm_color_encoding color_encoding;
  148. enum drm_color_range color_range;
  149. };
  150. struct omap_overlay_manager_info {
  151. u32 default_color;
  152. enum omap_dss_trans_key_type trans_key_type;
  153. u32 trans_key;
  154. bool trans_enabled;
  155. bool partial_alpha_enabled;
  156. bool cpr_enable;
  157. struct omap_dss_cpr_coefs cpr_coefs;
  158. };
  159. struct omap_dss_writeback_info {
  160. u32 paddr;
  161. u32 p_uv_addr;
  162. u16 buf_width;
  163. u16 width;
  164. u16 height;
  165. u32 fourcc;
  166. u8 rotation;
  167. enum omap_dss_rotation_type rotation_type;
  168. u8 pre_mult_alpha;
  169. };
  170. struct omapdss_dsi_ops {
  171. int (*update)(struct omap_dss_device *dssdev);
  172. bool (*is_video_mode)(struct omap_dss_device *dssdev);
  173. };
  174. struct omap_dss_device {
  175. struct device *dev;
  176. struct dss_device *dss;
  177. struct drm_bridge *bridge;
  178. struct drm_bridge *next_bridge;
  179. struct drm_panel *panel;
  180. struct list_head list;
  181. /*
  182. * DSS type that this device generates (for DSS internal devices) or
  183. * requires (for external encoders, connectors and panels). Must be a
  184. * non-zero (different than OMAP_DISPLAY_TYPE_NONE) value.
  185. */
  186. enum omap_display_type type;
  187. const char *name;
  188. const struct omapdss_dsi_ops *dsi_ops;
  189. u32 bus_flags;
  190. /* OMAP DSS output specific fields */
  191. /* DISPC channel for this output */
  192. enum omap_channel dispc_channel;
  193. /* output instance */
  194. enum omap_dss_output_id id;
  195. /* port number in DT */
  196. unsigned int of_port;
  197. };
  198. struct dss_pdata {
  199. struct dss_device *dss;
  200. };
  201. void omapdss_device_register(struct omap_dss_device *dssdev);
  202. void omapdss_device_unregister(struct omap_dss_device *dssdev);
  203. struct omap_dss_device *omapdss_device_get(struct omap_dss_device *dssdev);
  204. void omapdss_device_put(struct omap_dss_device *dssdev);
  205. struct omap_dss_device *omapdss_find_device_by_node(struct device_node *node);
  206. int omapdss_device_connect(struct dss_device *dss,
  207. struct omap_dss_device *dst);
  208. void omapdss_device_disconnect(struct dss_device *dss,
  209. struct omap_dss_device *dst);
  210. int omap_dss_get_num_overlay_managers(void);
  211. int omap_dss_get_num_overlays(void);
  212. #define for_each_dss_output(d) \
  213. while ((d = omapdss_device_next_output(d)) != NULL)
  214. struct omap_dss_device *omapdss_device_next_output(struct omap_dss_device *from);
  215. int omapdss_device_init_output(struct omap_dss_device *out,
  216. struct drm_bridge *local_bridge);
  217. void omapdss_device_cleanup_output(struct omap_dss_device *out);
  218. typedef void (*omap_dispc_isr_t) (void *arg, u32 mask);
  219. int omap_dispc_register_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
  220. int omap_dispc_unregister_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
  221. int omapdss_compat_init(void);
  222. void omapdss_compat_uninit(void);
  223. enum dss_writeback_channel {
  224. DSS_WB_LCD1_MGR = 0,
  225. DSS_WB_LCD2_MGR = 1,
  226. DSS_WB_TV_MGR = 2,
  227. DSS_WB_OVL0 = 3,
  228. DSS_WB_OVL1 = 4,
  229. DSS_WB_OVL2 = 5,
  230. DSS_WB_OVL3 = 6,
  231. DSS_WB_LCD3_MGR = 7,
  232. };
  233. void omap_crtc_dss_start_update(struct omap_drm_private *priv,
  234. enum omap_channel channel);
  235. void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable);
  236. int omap_crtc_dss_enable(struct omap_drm_private *priv, enum omap_channel channel);
  237. void omap_crtc_dss_disable(struct omap_drm_private *priv, enum omap_channel channel);
  238. void omap_crtc_dss_set_timings(struct omap_drm_private *priv,
  239. enum omap_channel channel,
  240. const struct videomode *vm);
  241. void omap_crtc_dss_set_lcd_config(struct omap_drm_private *priv,
  242. enum omap_channel channel,
  243. const struct dss_lcd_mgr_config *config);
  244. int omap_crtc_dss_register_framedone(
  245. struct omap_drm_private *priv, enum omap_channel channel,
  246. void (*handler)(void *), void *data);
  247. void omap_crtc_dss_unregister_framedone(
  248. struct omap_drm_private *priv, enum omap_channel channel,
  249. void (*handler)(void *), void *data);
  250. void dss_mgr_set_timings(struct omap_dss_device *dssdev,
  251. const struct videomode *vm);
  252. void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev,
  253. const struct dss_lcd_mgr_config *config);
  254. int dss_mgr_enable(struct omap_dss_device *dssdev);
  255. void dss_mgr_disable(struct omap_dss_device *dssdev);
  256. void dss_mgr_start_update(struct omap_dss_device *dssdev);
  257. int dss_mgr_register_framedone_handler(struct omap_dss_device *dssdev,
  258. void (*handler)(void *), void *data);
  259. void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev,
  260. void (*handler)(void *), void *data);
  261. struct dispc_device *dispc_get_dispc(struct dss_device *dss);
  262. bool omapdss_stack_is_ready(void);
  263. void omapdss_gather_components(struct device *dev);
  264. int omap_dss_init(void);
  265. void omap_dss_exit(void);
  266. #endif /* __OMAP_DRM_DSS_H */