Guest User

AOSP ICS 4.0.4 - /hardware/qcom/display/libqcomui/qcom_ui.h

a guest
Nov 27th, 2012
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.85 KB | None | 0 0
  1. /*
  2. * Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
  3.  
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are
  6. * met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above
  10. * copyright notice, this list of conditions and the following
  11. * disclaimer in the documentation and/or other materials provided
  12. * with the distribution.
  13. * * Neither the name of Code Aurora Forum, Inc. nor the names of its
  14. * contributors may be used to endorse or promote products derived
  15. * from this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
  18. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
  20. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
  21. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  22. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  23. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  24. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  25. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  26. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  27. * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. */
  29.  
  30. #ifndef INCLUDE_LIBQCOM_UI
  31. #define INCLUDE_LIBQCOM_UI
  32.  
  33. #include <cutils/native_handle.h>
  34. #include <ui/GraphicBuffer.h>
  35. #include <hardware/hwcomposer.h>
  36. #include <ui/Region.h>
  37. #include <EGL/egl.h>
  38. #include <utils/Singleton.h>
  39. #include <cutils/properties.h>
  40. #include "../libgralloc/gralloc_priv.h"
  41.  
  42. using namespace android;
  43. using android::sp;
  44. using android::GraphicBuffer;
  45.  
  46. #define HWC_BYPASS_INDEX_MASK 0x00000030
  47.  
  48. /*
  49. * Qcom specific Native Window perform operations
  50. */
  51. enum {
  52. NATIVE_WINDOW_SET_BUFFERS_SIZE = 0x10000000,
  53. NATIVE_WINDOW_UPDATE_BUFFERS_GEOMETRY = 0x20000000,
  54. NATIVE_WINDOW_SET_S3D_FORMAT = 0x40000000,
  55. };
  56.  
  57. // Enum containing the supported composition types
  58. enum {
  59. COMPOSITION_TYPE_GPU = 0,
  60. COMPOSITION_TYPE_MDP = 0x1,
  61. COMPOSITION_TYPE_C2D = 0x2,
  62. COMPOSITION_TYPE_CPU = 0x4,
  63. COMPOSITION_TYPE_DYN = 0x8
  64. };
  65.  
  66. /*
  67. * Layer Attributes
  68. */
  69. enum eLayerAttrib {
  70. LAYER_UPDATE_STATUS,
  71. LAYER_ASYNCHRONOUS_STATUS,
  72. };
  73.  
  74. /*
  75. * Layer Flags
  76. */
  77. enum {
  78. LAYER_UPDATING = 1<<0,
  79. LAYER_ASYNCHRONOUS = 1<<1,
  80. };
  81.  
  82. /*
  83. * Layer Transformation - refers to Layer::setGeometry()
  84. */
  85. #define SHIFT_SRC_TRANSFORM 4
  86. #define SRC_TRANSFORM_MASK 0x00F0
  87. #define FINAL_TRANSFORM_MASK 0x000F
  88.  
  89. /*
  90. * Flags set by the layer and sent to HWC
  91. */
  92. enum {
  93. HWC_LAYER_NOT_UPDATING = 0x00000002,
  94. HWC_LAYER_ASYNCHRONOUS = 0x00000004,
  95. HWC_USE_ORIGINAL_RESOLUTION = 0x10000000,
  96. HWC_DO_NOT_USE_OVERLAY = 0x20000000,
  97. HWC_COMP_BYPASS = 0x40000000,
  98. HWC_USE_EXT_ONLY = 0x80000000, //Layer displayed on external only
  99. HWC_USE_EXT_BLOCK = 0x01000000, //Layer displayed on external only
  100. HWC_BYPASS_RESERVE_0 = 0x00000010,
  101. HWC_BYPASS_RESERVE_1 = 0x00000020,
  102. };
  103.  
  104. enum HWCCompositionType {
  105. HWC_USE_GPU = HWC_FRAMEBUFFER, // This layer is to be handled by Surfaceflinger
  106. HWC_USE_OVERLAY = HWC_OVERLAY, // This layer is to be handled by the overlay
  107. HWC_USE_COPYBIT // This layer is to be handled by copybit
  108. };
  109.  
  110. enum external_display_type {
  111. EXT_TYPE_NONE,
  112. EXT_TYPE_HDMI,
  113. EXT_TYPE_WIFI
  114. };
  115.  
  116. /* Events to the Display HAL perform function
  117. As of now used for external display related such as
  118. connect, disconnect, orientation, video started etc.,
  119. */
  120. enum {
  121. EVENT_EXTERNAL_DISPLAY, // External display on/off Event
  122. EVENT_VIDEO_OVERLAY, // Video Overlay start/stop Event
  123. EVENT_ORIENTATION_CHANGE, // Orientation Change Event
  124. EVENT_OVERLAY_STATE_CHANGE, // Overlay State Change Event
  125. EVENT_OPEN_SECURE_START, // Start of secure session setup config by stagefright
  126. EVENT_OPEN_SECURE_END, // End of secure session setup config by stagefright
  127. EVENT_CLOSE_SECURE_START, // Start of secure session teardown config
  128. EVENT_CLOSE_SECURE_END, // End of secure session teardown config
  129. EVENT_RESET_POSTBUFFER, // Reset post framebuffer mutex
  130. EVENT_WAIT_POSTBUFFER, // Wait until post framebuffer returns
  131. EVENT_FORCE_COMPOSITION, // On/Off event for avoiding skip composition
  132. };
  133.  
  134. // Video information sent to framebuffer HAl
  135. // used for handling UI mirroring.
  136. enum {
  137. VIDEO_OVERLAY_ENDED = 0,
  138. VIDEO_2D_OVERLAY_STARTED,
  139. VIDEO_3D_OVERLAY_STARTED
  140. };
  141. /*
  142. * Structure to hold the buffer geometry
  143. */
  144. struct qBufGeometry {
  145. int width;
  146. int height;
  147. int format;
  148. void set(int w, int h, int f) {
  149. width = w;
  150. height = h;
  151. format = f;
  152. }
  153. };
  154.  
  155. class QCBaseLayer
  156. {
  157. // int mS3DFormat;
  158. int32_t mComposeS3DFormat;
  159. public:
  160. QCBaseLayer()
  161. {
  162. mComposeS3DFormat = 0;
  163. }
  164. enum { // S3D formats
  165. eS3D_SIDE_BY_SIDE = 0x10000,
  166. eS3D_TOP_BOTTOM = 0x20000
  167. };
  168. /*
  169. virtual status_t setStereoscopic3DFormat(int format) { mS3DFormat = format; return 0; }
  170. virtual int getStereoscopic3DFormat() const { return mS3DFormat; }
  171. */
  172. void setS3DComposeFormat (int32_t hints)
  173. {
  174. if (hints & HWC_HINT_DRAW_S3D_SIDE_BY_SIDE)
  175. mComposeS3DFormat = eS3D_SIDE_BY_SIDE;
  176. else if (hints & HWC_HINT_DRAW_S3D_TOP_BOTTOM)
  177. mComposeS3DFormat = eS3D_TOP_BOTTOM;
  178. else
  179. mComposeS3DFormat = 0;
  180. }
  181. int32_t needsS3DCompose () const { return mComposeS3DFormat; }
  182. };
  183.  
  184. /*
  185. * Function to check if the allocated buffer is of the correct size.
  186. * Reallocate the buffer with the correct size, if the size doesn't
  187. * match
  188. *
  189. * @param: handle of the allocated buffer
  190. * @param: requested size for the buffer
  191. * @param: usage flags
  192. *
  193. * return 0 on success
  194. */
  195. int checkBuffer(native_handle_t *buffer_handle, int size, int usage);
  196.  
  197. /*
  198. * Checks if the format is supported by the GPU.
  199. *
  200. * @param: format to check
  201. *
  202. * @return true if the format is supported by the GPU.
  203. */
  204. bool isGPUSupportedFormat(int format);
  205.  
  206. #ifdef DECIDE_TEXTURE_TARGET
  207. /*
  208. * Adreno is not optimized for GL_TEXTURE_EXTERNAL_OES
  209. * texure target. DO NOT choose TEXTURE_EXTERNAL_OES
  210. * target for RGB formats.
  211. *
  212. * Based on the pixel format, decide the texture target.
  213. *
  214. * @param : pixel format to check
  215. *
  216. * @return : GL_TEXTURE_2D for RGB formats, and
  217. * GL_TEXTURE_EXTERNAL_OES for YUV formats.
  218. *
  219. */
  220.  
  221. int decideTextureTarget (const int pixel_format);
  222. #endif
  223.  
  224. /*
  225. * Gets the number of arguments required for this operation.
  226. *
  227. * @param: operation whose argument count is required.
  228. *
  229. * @return -EINVAL if the operation is invalid.
  230. */
  231. int getNumberOfArgsForOperation(int operation);
  232.  
  233. /*
  234. * Checks if memory needs to be reallocated for this buffer.
  235. *
  236. * @param: Geometry of the current buffer.
  237. * @param: Required Geometry.
  238. * @param: Geometry of the updated buffer.
  239. *
  240. * @return True if a memory reallocation is required.
  241. */
  242. bool needNewBuffer(const qBufGeometry currentGeometry,
  243. const qBufGeometry requiredGeometry,
  244. const qBufGeometry updatedGeometry);
  245.  
  246. /*
  247. * Update the geometry of this buffer without reallocation.
  248. *
  249. * @param: buffer whose geometry needs to be updated.
  250. * @param: Updated buffer geometry
  251. */
  252. int updateBufferGeometry(sp<GraphicBuffer> buffer, const qBufGeometry bufGeometry);
  253.  
  254. /*
  255. * Update the S3D format of this buffer.
  256. *
  257. * @param: buffer whosei S3D format needs to be updated.
  258. * @param: Updated buffer S3D format
  259. */
  260. int updateBufferS3DFormat(sp<GraphicBuffer> buffer, const int s3dFormat);
  261.  
  262. /*
  263. * Updates the flags for the layer
  264. *
  265. * @param: Attribute
  266. * @param: Identifies if the attribute was enabled or disabled.
  267. * @param: current Layer flags.
  268. *
  269. * @return: Flags for the layer
  270. */
  271. int updateLayerQcomFlags(eLayerAttrib attribute, bool enable, int& currentFlags);
  272.  
  273. /*
  274. * Gets the per frame HWC flags for this layer.
  275. *
  276. * @param: current hwcl flags
  277. * @param: current layerFlags
  278. *
  279. * @return: the per frame flags.
  280. */
  281. int getPerFrameFlags(int hwclFlags, int layerFlags);
  282.  
  283. /*
  284. * Checks if FB is updated by this composition type
  285. *
  286. * @param: composition type
  287. * @return: true if FB is updated, false if not
  288. */
  289.  
  290. bool isUpdatingFB(HWCCompositionType compositionType);
  291.  
  292. /*
  293. * Get the current composition Type
  294. *
  295. * @return the compositon Type
  296. */
  297. int getCompositionType();
  298.  
  299. /*
  300. * Clear region implementation for C2D/MDP versions.
  301. *
  302. * @param: region to be cleared
  303. * @param: EGL Display
  304. * @param: EGL Surface
  305. *
  306. * @return 0 on success
  307. */
  308. int qcomuiClearRegion(Region region, EGLDisplay dpy, EGLSurface sur);
  309.  
  310. /*
  311. * Handles the externalDisplay event
  312. * HDMI has highest priority compared to WifiDisplay
  313. * Based on the current and the new display event, decides the
  314. * external display to be enabled
  315. *
  316. * @param: newEvent - new external event
  317. * @param: currEvent - currently enabled external event
  318. * @return: external display to be enabled
  319. *
  320. */
  321. external_display_type handleEventHDMI(external_display_type disp, int value,
  322. external_display_type currDispType);
  323. /*
  324. * Checks if layers need to be dumped based on system property "debug.sf.dump"
  325. * for raw dumps and "debug.sf.dump.png" for png dumps.
  326. *
  327. * For example, to dump 25 frames in raw format, do,
  328. * adb shell setprop debug.sf.dump 25
  329. * Layers are dumped in a time-stamped location: /data/sfdump*.
  330. *
  331. * To dump 10 frames in png format, do,
  332. * adb shell setprop debug.sf.dump.png 10
  333. * To dump another 25 or so frames in raw format, do,
  334. * adb shell setprop debug.sf.dump 26
  335. *
  336. * To turn off logcat logging of layer-info, set both properties to 0,
  337. * adb shell setprop debug.sf.dump.png 0
  338. * adb shell setprop debug.sf.dump 0
  339. *
  340. * @return: true if layers need to be dumped (or logcat-ed).
  341. */
  342. bool needToDumpLayers();
  343.  
  344. /*
  345. * Dumps a layer's info into logcat and its buffer into raw/png files.
  346. *
  347. * @param: moduleCompositionType - Composition type set in hwcomposer module.
  348. * @param: listFlags - Flags used in hwcomposer's list.
  349. * @param: layerIndex - Index of layer being dumped.
  350. * @param: hwLayers - Address of hwc_layer_t to log and dump.
  351. *
  352. */
  353. void dumpLayer(int moduleCompositionType, int listFlags, size_t layerIndex,
  354. hwc_layer_t hwLayers[]);
  355.  
  356. #endif // INCLUDE_LIBQCOM_UI
Advertisement
Add Comment
Please, Sign In to add comment