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