• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2012-2013, Linux Foundation. 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 Linux Foundation 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 HWC_DUMP_LAYERS_H
31 #define HWC_DUMP_LAYERS_H
32 
33 #include <gralloc_priv.h>
34 #include <comptype.h>
35 #include <hardware/hwcomposer.h>
36 
37 namespace qhwc {
38 
39 class HwcDebug {
40 private:
41 
42 // Using static variables for layer dumping since "property_set("debug.sf.dump",
43 // property)" does not work.
44   int mDumpCntLimRaw;
45   int mDumpCntrRaw;
46   char mDumpPropStrRaw[PROPERTY_VALUE_MAX];
47   char mDumpDirRaw[PATH_MAX];
48   int mDumpCntLimPng;
49   int mDumpCntrPng;
50   char mDumpPropStrPng[PROPERTY_VALUE_MAX];
51   char mDumpDirPng[PATH_MAX];
52   uint32_t mDpy;
53   char mDisplayName[PROPERTY_VALUE_MAX];
54   char mDumpPropKeyDisplayType[PROPERTY_KEY_MAX];
55   static bool sDumpEnable;
56 
57 public:
58     HwcDebug(uint32_t dpy);
~HwcDebug()59     ~HwcDebug() {};
60 
61     /*
62      * Dump layers for debugging based on "debug.sf.dump*" system property.
63      * See needToDumpLayers() for usage.
64      *
65      * @param: list - The HWC layer-list to dump.
66      *
67      */
68     void dumpLayers(hwc_display_contents_1_t* list);
69 
70 /*
71  * Checks if layers need to be dumped based on system property "debug.sf.dump"
72  * for raw dumps and "debug.sf.dump.png" for png dumps.
73  *
74  * Note: Set "debug.sf.dump.primary" or "debug.sf.dump.external" as true
75  * in the device's /system/build.prop file to enable layer logging/capturing
76  * feature for primary or external respectively. The feature is disabled by
77  * default to avoid per-frame property_get() calls.
78  *
79  * To turn on layer dump, set "debug.sf.dump.enable" to true in build.prop.
80  * By default debug.sf.dump.primary will be set to true for user convenience.
81  *
82  * To turn on layer dump for primary, do,
83  *     adb shell setprop debug.sf.dump.primary true
84  *
85  * To turn on layer dump for external, do,
86  *     adb shell setprop debug.sf.dump.external true
87  *
88  * For example, to dump 25 frames in raw format, do,
89  *     adb shell setprop debug.sf.dump 25
90  * Layers are dumped in a time-stamped location: /data/sfdump*.
91  *
92  * To dump 10 frames in png format, do,
93  *     adb shell setprop debug.sf.dump.png 10
94  * To dump another 25 or so frames in raw format, do,
95  *     adb shell setprop debug.sf.dump 26
96  *
97  * To turn off logcat logging of layer-info, set both properties to 0,
98  *     adb shell setprop debug.sf.dump.png 0
99  *     adb shell setprop debug.sf.dump 0
100  *
101  * @return: true if layers need to be dumped (or logcat-ed).
102  */
103 bool needToDumpLayers();
104 
105 /*
106  * Log a few per-frame hwc properties into logcat.
107  *
108  * @param: listFlags - Flags used in hwcomposer's list.
109  *
110  */
111 void logHwcProps(uint32_t listFlags);
112 
113 /*
114  * Log a layer's info into logcat.
115  *
116  * @param: layerIndex - Index of layer being dumped.
117  * @param: hwLayers - Address of hwc_layer_1_t to log and dump.
118  *
119  */
120 void logLayer(size_t layerIndex, hwc_layer_1_t hwLayers[]);
121 
122 /*
123  * Dumps a layer buffer into raw/png files.
124  *
125  * @param: layerIndex - Index of layer being dumped.
126  * @param: hwLayers - Address of hwc_layer_1_t to log and dump.
127  *
128  */
129 void dumpLayer(size_t layerIndex, hwc_layer_1_t hwLayers[]);
130 
131 void getHalPixelFormatStr(int format, char pixelformatstr[]);
132 };
133 
134 } // namespace qhwc
135 
136 #endif /* HWC_DUMP_LAYERS_H */
137