PageRenderTime 15ms CodeModel.GetById 3ms RepoModel.GetById 1ms app.codeStats 0ms

/drivers/video/omap2/dsscomp/dsscomp.h

https://bitbucket.org/slukk/jb-tsm-kernel-4.2
C Header | 208 lines | 136 code | 24 blank | 48 comment | 10 complexity | 7fe3c696f4fe548533ba945a6edbb2f5 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
  1. /*
  2. * linux/drivers/video/omap2/dsscomp/base.c
  3. *
  4. * DSS Composition basic operation support
  5. *
  6. * Copyright (C) 2011 Texas Instruments, Inc
  7. * Author: Lajos Molnar <molnar@ti.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 version 2 as published by
  11. * the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but WITHOUT
  14. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  16. * more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along with
  19. * this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef _DSSCOMP_H
  22. #define _DSSCOMP_H
  23. #include <linux/miscdevice.h>
  24. #include <linux/debugfs.h>
  25. #include <linux/seq_file.h>
  26. #ifdef CONFIG_DSSCOMP_DEBUG_LOG
  27. #include <linux/hrtimer.h>
  28. #endif
  29. #define MAX_OVERLAYS 5
  30. #define MAX_MANAGERS 3
  31. #define MAX_DISPLAYS 4
  32. #define DEBUG_OVERLAYS (1 << 0)
  33. #define DEBUG_COMPOSITIONS (1 << 1)
  34. #define DEBUG_PHASES (1 << 2)
  35. #define DEBUG_WAITS (1 << 3)
  36. #define DEBUG_GRALLOC_PHASES (1 << 4)
  37. /*
  38. * Utility macros
  39. */
  40. #define ZERO(c) memset(&c, 0, sizeof(c))
  41. #define ZEROn(c, n) memset(c, 0, sizeof(*c) * n)
  42. #define DEV(c) (c->dev.this_device)
  43. /**
  44. * DSS Composition Device Driver
  45. *
  46. * @dev: misc device base
  47. * @dbgfs: debugfs hook
  48. */
  49. struct dsscomp_dev {
  50. struct miscdevice dev;
  51. struct dentry *dbgfs;
  52. /* cached DSS objects */
  53. u32 num_ovls;
  54. struct omap_overlay *ovls[MAX_OVERLAYS];
  55. u32 num_mgrs;
  56. struct omap_overlay_manager *mgrs[MAX_MANAGERS];
  57. u32 num_displays;
  58. struct omap_dss_device *displays[MAX_DISPLAYS];
  59. struct notifier_block state_notifiers[MAX_DISPLAYS];
  60. };
  61. extern int debug;
  62. #ifdef CONFIG_DEBUG_FS
  63. extern struct mutex dbg_mtx;
  64. extern struct list_head dbg_comps;
  65. #define DO_IF_DEBUG_FS(cmd) { \
  66. mutex_lock(&dbg_mtx); \
  67. cmd; \
  68. mutex_unlock(&dbg_mtx); \
  69. }
  70. #else
  71. #define DO_IF_DEBUG_FS(cmd)
  72. #endif
  73. enum dsscomp_state {
  74. DSSCOMP_STATE_ACTIVE = 0xAC54156E,
  75. DSSCOMP_STATE_APPLYING = 0xB554C591,
  76. DSSCOMP_STATE_APPLIED = 0xB60504C1,
  77. DSSCOMP_STATE_PROGRAMMED = 0xC0520652,
  78. DSSCOMP_STATE_DISPLAYED = 0xD15504CA,
  79. };
  80. struct dsscomp_data {
  81. enum dsscomp_state state;
  82. /*
  83. * :TRICKY: before applying, overlays used in a composition are stored
  84. * in ovl_mask and the other masks are empty. Once composition is
  85. * applied, blank is set to see if all overlays are to be disabled on
  86. * this composition, any disabled overlays in the composition are set in
  87. * ovl_dmask, and ovl_mask is updated to include ALL overlays that are
  88. * actually on the display - even if they are not part of the
  89. * composition. The reason: we use ovl_mask to see if an overlay is used
  90. * or planned to be used on a manager. We update ovl_mask when
  91. * composition is programmed (removing the disabled overlays).
  92. */
  93. bool blank; /* true if all overlays are to be disabled */
  94. u32 ovl_mask; /* overlays used on this frame */
  95. u32 ovl_dmask; /* overlays disabled on this frame */
  96. u32 ix; /* manager index that this frame is on */
  97. struct dsscomp_setup_mgr_data frm;
  98. struct dss2_ovl_info ovls[5];
  99. void (*extra_cb)(void *data, int status);
  100. void *extra_cb_data;
  101. bool must_apply; /* whether composition must be applied */
  102. #ifdef CONFIG_DEBUG_FS
  103. struct list_head dbg_q;
  104. u32 dbg_used;
  105. struct {
  106. u32 t, state;
  107. } dbg_log[8];
  108. #endif
  109. };
  110. struct dsscomp_sync_obj {
  111. int state;
  112. int fd;
  113. atomic_t refs;
  114. };
  115. /*
  116. * Kernel interface
  117. */
  118. int dsscomp_queue_init(struct dsscomp_dev *cdev);
  119. void dsscomp_queue_exit(void);
  120. void dsscomp_gralloc_init(struct dsscomp_dev *cdev);
  121. void dsscomp_gralloc_exit(void);
  122. int dsscomp_gralloc_queue_ioctl(struct dsscomp_setup_dispc_data *d);
  123. int dsscomp_wait(struct dsscomp_sync_obj *sync, enum dsscomp_wait_phase phase,
  124. int timeout);
  125. int dsscomp_state_notifier(struct notifier_block *nb,
  126. unsigned long arg, void *ptr);
  127. /* basic operation - if not using queues */
  128. int set_dss_ovl_info(struct dss2_ovl_info *oi);
  129. int set_dss_mgr_info(struct dss2_mgr_info *mi, struct omapdss_ovl_cb *cb);
  130. struct omap_overlay_manager *find_dss_mgr(int display_ix);
  131. void swap_rb_in_ovl_info(struct dss2_ovl_info *oi);
  132. void swap_rb_in_mgr_info(struct dss2_mgr_info *mi);
  133. /*
  134. * Debug functions
  135. */
  136. void dump_ovl_info(struct dsscomp_dev *cdev, struct dss2_ovl_info *oi);
  137. void dump_comp_info(struct dsscomp_dev *cdev, struct dsscomp_setup_mgr_data *d,
  138. const char *phase);
  139. void dump_total_comp_info(struct dsscomp_dev *cdev,
  140. struct dsscomp_setup_dispc_data *d,
  141. const char *phase);
  142. const char *dsscomp_get_color_name(enum omap_color_mode m);
  143. void dsscomp_dbg_comps(struct seq_file *s);
  144. void dsscomp_dbg_gralloc(struct seq_file *s);
  145. #define log_state_str(s) (\
  146. (s) == DSSCOMP_STATE_ACTIVE ? "ACTIVE" : \
  147. (s) == DSSCOMP_STATE_APPLYING ? "APPLY'N" : \
  148. (s) == DSSCOMP_STATE_APPLIED ? "APPLIED" : \
  149. (s) == DSSCOMP_STATE_PROGRAMMED ? "PROGR'D" : \
  150. (s) == DSSCOMP_STATE_DISPLAYED ? "DISPL'D" : "INVALID")
  151. #define log_status_str(ev) ( \
  152. ((ev) & DSS_COMPLETION_CHANGED) ? "CHANGED" : \
  153. (ev) == DSS_COMPLETION_DISPLAYED ? "DISPLAYED" : \
  154. (ev) == DSS_COMPLETION_PROGRAMMED ? "PROGRAMMED" : \
  155. (ev) == DSS_COMPLETION_TORN ? "TORN" : \
  156. (ev) == DSS_COMPLETION_RELEASED ? "RELEASED" : \
  157. ((ev) & DSS_COMPLETION_RELEASED) ? "ECLIPSED" : "???")
  158. #ifdef CONFIG_DSSCOMP_DEBUG_LOG
  159. extern struct dbg_event_t {
  160. u32 ms, a1, a2, ix;
  161. void *data;
  162. const char *fmt;
  163. } dbg_events[128];
  164. extern u32 dbg_event_ix;
  165. void dsscomp_dbg_events(struct seq_file *s);
  166. #endif
  167. static inline
  168. void __log_event(u32 ix, u32 ms, void *data, const char *fmt, u32 a1, u32 a2)
  169. {
  170. #ifdef CONFIG_DSSCOMP_DEBUG_LOG
  171. if (!ms)
  172. ms = ktime_to_ms(ktime_get());
  173. dbg_events[dbg_event_ix].ms = ms;
  174. dbg_events[dbg_event_ix].data = data;
  175. dbg_events[dbg_event_ix].fmt = fmt;
  176. dbg_events[dbg_event_ix].a1 = a1;
  177. dbg_events[dbg_event_ix].a2 = a2;
  178. dbg_events[dbg_event_ix].ix = ix;
  179. dbg_event_ix = (dbg_event_ix + 1) % ARRAY_SIZE(dbg_events);
  180. #endif
  181. }
  182. #define log_event(ix, ms, data, fmt, a1, a2) \
  183. DO_IF_DEBUG_FS(__log_event(ix, ms, data, fmt, a1, a2))
  184. #endif