1d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema/* 2d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* Copyright (c) 2014 - 2018, The Linux Foundation. All rights reserved. 3d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* 4d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* Redistribution and use in source and binary forms, with or without 5d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* modification, are permitted provided that the following conditions are 6d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* met: 7d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* * Redistributions of source code must retain the above copyright 8d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* notice, this list of conditions and the following disclaimer. 9d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* * Redistributions in binary form must reproduce the above 10d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* copyright notice, this list of conditions and the following 11d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* disclaimer in the documentation and/or other materials provided 12d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* with the distribution. 13d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* * Neither the name of The Linux Foundation nor the names of its 14d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* contributors may be used to endorse or promote products derived 15d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* from this software without specific prior written permission. 16d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* 17d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 18d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 20d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 21d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 26d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema*/ 29d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema 30d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema#ifndef __DEBUG_H__ 31d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema#define __DEBUG_H__ 32d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema 33d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema#include <stdint.h> 34d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema#include <core/sdm_types.h> 35d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema#include <core/debug_interface.h> 36d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema#include <core/display_interface.h> 37d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema#include <display_properties.h> 38d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema 39d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema#define DLOG(tag, method, format, ...) Debug::Get()->method(tag, __CLASS__ "::%s: " format, \ 40d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema __FUNCTION__, ##__VA_ARGS__) 41d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema 42d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema#define DLOGE_IF(tag, format, ...) DLOG(tag, Error, format, ##__VA_ARGS__) 43d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema#define DLOGW_IF(tag, format, ...) DLOG(tag, Warning, format, ##__VA_ARGS__) 44d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema#define DLOGI_IF(tag, format, ...) DLOG(tag, Info, format, ##__VA_ARGS__) 45d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema#define DLOGD_IF(tag, format, ...) DLOG(tag, Debug, format, ##__VA_ARGS__) 46d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema#define DLOGV_IF(tag, format, ...) DLOG(tag, Verbose, format, ##__VA_ARGS__) 47d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema 48d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema#define DLOGE(format, ...) DLOGE_IF(kTagNone, format, ##__VA_ARGS__) 49d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema#define DLOGD(format, ...) DLOGD_IF(kTagNone, format, ##__VA_ARGS__) 50d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema#define DLOGW(format, ...) DLOGW_IF(kTagNone, format, ##__VA_ARGS__) 51d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema#define DLOGI(format, ...) DLOGI_IF(kTagNone, format, ##__VA_ARGS__) 52d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema#define DLOGV(format, ...) DLOGV_IF(kTagNone, format, ##__VA_ARGS__) 53d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema 54d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema#define DTRACE_BEGIN(custom_string) Debug::Get()->BeginTrace(__CLASS__, __FUNCTION__, custom_string) 55d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema#define DTRACE_END() Debug::Get()->EndTrace() 56d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema#define DTRACE_SCOPED() ScopeTracer <Debug> scope_tracer(__CLASS__, __FUNCTION__) 57d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema 58d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennemanamespace sdm { 59d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema 60d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennemaclass Debug { 61d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema public: 62d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema static inline void SetDebugHandler(DebugHandler *debug_handler) { 63d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema debug_.debug_handler_ = debug_handler; 64d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema } 65d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema static inline DebugHandler* Get() { return debug_.debug_handler_; } 66d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema static int GetSimulationFlag(); 67d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema static int GetHDMIResolution(); 68d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema static void GetIdleTimeoutMs(uint32_t *active_ms, uint32_t *inactive_ms); 69d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema static int GetBootAnimLayerCount(); 70d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema static bool IsRotatorDownScaleDisabled(); 71d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema static bool IsDecimationDisabled(); 72d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema static int GetMaxPipesPerMixer(DisplayType display_type); 73d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema static int GetMaxUpscale(); 74d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema static bool IsVideoModeEnabled(); 75d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema static bool IsRotatorUbwcDisabled(); 76d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema static bool IsRotatorSplitDisabled(); 77d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema static bool IsScalarDisabled(); 78d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema static bool IsUbwcTiledFrameBuffer(); 79d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema static bool IsAVRDisabled(); 80d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema static bool IsExtAnimDisabled(); 81d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema static bool IsPartialSplitDisabled(); 82d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema static DisplayError GetMixerResolution(uint32_t *width, uint32_t *height); 83d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema static int GetExtMaxlayers(); 84d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema static bool GetProperty(const char *property_name, char *value); 85d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema static bool SetProperty(const char *property_name, const char *value); 86d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema 87d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema private: 88d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema Debug(); 89d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema 90d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema // By default, drop any log messages/traces coming from Display manager. It will be overriden by 91d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema // Display manager client when core is successfully initialized. 92d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema class DefaultDebugHandler : public DebugHandler { 93d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema public: 94d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema virtual void Error(DebugTag /*tag*/, const char */*format*/, ...) { } 95d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema virtual void Warning(DebugTag /*tag*/, const char */*format*/, ...) { } 96d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema virtual void Info(DebugTag /*tag*/, const char */*format*/, ...) { } 97d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema virtual void Debug(DebugTag /*tag*/, const char */*format*/, ...) { } 98d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema virtual void Verbose(DebugTag /*tag*/, const char */*format*/, ...) { } 99d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema virtual void BeginTrace(const char */*class_name*/, const char */*function_name*/, 100d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema const char */*custom_string*/) { } 101d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema virtual void EndTrace() { } 102d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema virtual DisplayError GetProperty(const char */*property_name*/, int */*value*/) { 103d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema return kErrorNotSupported; 104d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema } 105d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema virtual DisplayError GetProperty(const char */*property_name*/, char */*value*/) { 106d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema return kErrorNotSupported; 107d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema } 108d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema virtual DisplayError SetProperty(const char */*property_name*/, const char */*value*/) { 109d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema return kErrorNotSupported; 110d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema } 111d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema }; 112d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema 113d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema DefaultDebugHandler default_debug_handler_; 114d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema DebugHandler *debug_handler_; 115d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema static Debug debug_; 116d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema}; 117d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema 118d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema} // namespace sdm 119d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema 120d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema#endif // __DEBUG_H__ 121d39a514dd0540cf47e121775a77e9ac1b578bdb1Ben Fennema 122