From e2a590859ad4736ba1fe71be511e93bae6a64ed5 Mon Sep 17 00:00:00 2001 From: Dileep Marchya Date: Thu, 21 May 2015 13:29:05 -0700 Subject: [PATCH] sdm: Remove libsdmutils dependency on Android. - Make libsdmutils Android independent. - Rename debug_android.cpp to debug.cpp. - Fix compilation errors observed in linux environment. Change-Id: I19e275939b27f2f47949c5e17559eeadb09bdccf --- sdm/include/core/core_interface.h | 3 +- sdm/include/core/debug_interface.h | 11 +++- sdm/include/utils/constants.h | 5 ++ sdm/include/utils/debug.h | 5 +- sdm/include/utils/locker.h | 1 + sdm/libs/core/dump_impl.h | 2 +- sdm/libs/core/fb/hw_device.cpp | 48 ++++++++-------- sdm/libs/core/fb/hw_hdmi.cpp | 4 +- sdm/libs/core/fb/hw_info.cpp | 1 + sdm/libs/core/fb/hw_info.h | 1 - sdm/libs/core/fb/hw_primary.cpp | 7 ++- sdm/libs/hwc/hwc_debugger.cpp | 12 ++++ sdm/libs/hwc/hwc_debugger.h | 1 + sdm/libs/utils/Android.mk | 3 +- .../utils/{debug_android.cpp => debug.cpp} | 57 +++++++------------ 15 files changed, 86 insertions(+), 75 deletions(-) rename sdm/libs/utils/{debug_android.cpp => debug.cpp} (59%) diff --git a/sdm/include/core/core_interface.h b/sdm/include/core/core_interface.h index 882d0500..e1b38fad 100644 --- a/sdm/include/core/core_interface.h +++ b/sdm/include/core/core_interface.h @@ -42,8 +42,7 @@ #include "display_interface.h" #include "sdm_types.h" #include "buffer_allocator.h" - -class BufferSyncHandler; +#include "buffer_sync_handler.h" /*! @brief Display manager interface version. diff --git a/sdm/include/core/debug_interface.h b/sdm/include/core/debug_interface.h index ca6f81a0..f8e80b15 100644 --- a/sdm/include/core/debug_interface.h +++ b/sdm/include/core/debug_interface.h @@ -38,7 +38,7 @@ namespace sdm { /*! @brief This enum represents different modules/logical unit tags that a log message may be associated with. Client may use this to filter messages for dynamic logging. - @sa DisplayLogHandler + @sa DebugHandler */ enum DebugTag { kTagNone, //!< Debug log is not tagged. This type of logs should always be printed. @@ -101,6 +101,15 @@ class DebugHandler { */ virtual void EndTrace() = 0; + /*! @brief Method to get property value corresponding to give string. + + @param[in] property_name name of the property + @param[out] value value corresponding to the property name + + @return \link DisplayError \endlink +` */ + virtual DisplayError GetProperty(const char *property_name, int *value) = 0; + protected: virtual ~DebugHandler() { } }; diff --git a/sdm/include/utils/constants.h b/sdm/include/utils/constants.h index 75f845b0..b68604da 100644 --- a/sdm/include/utils/constants.h +++ b/sdm/include/utils/constants.h @@ -26,6 +26,11 @@ #define __CONSTANTS_H__ #include +#include + +#ifndef PRIu64 +#define PRIu64 "llu" +#endif #define INT(exp) static_cast(exp) #define FLOAT(exp) static_cast(exp) diff --git a/sdm/include/utils/debug.h b/sdm/include/utils/debug.h index 7f9209e3..478f623a 100644 --- a/sdm/include/utils/debug.h +++ b/sdm/include/utils/debug.h @@ -59,7 +59,6 @@ class Debug { debug_.debug_handler_ = debug_handler; } static inline DebugHandler* Get() { return debug_.debug_handler_; } - static inline bool IsVirtualDriver() { return debug_.virtual_driver_; } static uint32_t GetSimulationFlag(); static uint32_t GetHDMIResolution(); static uint32_t GetIdleTimeoutMs(); @@ -81,11 +80,13 @@ class Debug { virtual void BeginTrace(const char */*class_name*/, const char */*function_name*/, const char */*custom_string*/) { } virtual void EndTrace() { } + virtual DisplayError GetProperty(const char *property_name, int *value) { + return kErrorNotSupported; + } }; DefaultDebugHandler default_debug_handler_; DebugHandler *debug_handler_; - bool virtual_driver_; static Debug debug_; }; diff --git a/sdm/include/utils/locker.h b/sdm/include/utils/locker.h index 3bc92d3e..bc24ad5d 100644 --- a/sdm/include/utils/locker.h +++ b/sdm/include/utils/locker.h @@ -27,6 +27,7 @@ #include #include +#include #define SCOPE_LOCK(locker) Locker::ScopeLock lock(locker) #define SEQUENCE_ENTRY_SCOPE_LOCK(locker) Locker::SequenceEntryScopeLock lock(locker) diff --git a/sdm/libs/core/dump_impl.h b/sdm/libs/core/dump_impl.h index 123c5685..68e75841 100644 --- a/sdm/libs/core/dump_impl.h +++ b/sdm/libs/core/dump_impl.h @@ -49,7 +49,7 @@ class DumpImpl { static DumpImpl *dump_list_[kMaxDumpObjects]; static uint32_t dump_count_; - friend DumpInterface; + friend class DumpInterface; }; } // namespace sdm diff --git a/sdm/libs/core/fb/hw_device.cpp b/sdm/libs/core/fb/hw_device.cpp index b905c31c..4c6e5a54 100644 --- a/sdm/libs/core/fb/hw_device.cpp +++ b/sdm/libs/core/fb/hw_device.cpp @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include #include #include @@ -43,23 +45,12 @@ #define __CLASS__ "HWDevice" -#ifdef DISPLAY_CORE_VIRTUAL_DRIVER -extern int virtual_ioctl(int fd, int cmd, ...); -extern int virtual_open(const char *file_name, int access, ...); -extern int virtual_close(int fd); -extern int virtual_poll(struct pollfd *fds, nfds_t num, int timeout); -extern ssize_t virtual_pread(int fd, void *data, size_t count, off_t offset); -extern ssize_t virtual_pwrite(int fd, const void *data, size_t count, off_t offset); -extern FILE* virtual_fopen(const char *fname, const char *mode); -extern int virtual_fclose(FILE* fileptr); -extern ssize_t virtual_getline(char **lineptr, size_t *linelen, FILE *stream); -#endif - namespace sdm { HWDevice::HWDevice(BufferSyncHandler *buffer_sync_handler) : fb_node_index_(-1), fb_path_("/sys/devices/virtual/graphics/fb"), hotplug_enabled_(false), buffer_sync_handler_(buffer_sync_handler), synchronous_commit_(false) { +#ifndef SDM_VIRTUAL_DRIVER // Pointer to actual driver interfaces. ioctl_ = ::ioctl; open_ = ::open; @@ -70,20 +61,27 @@ HWDevice::HWDevice(BufferSyncHandler *buffer_sync_handler) fopen_ = ::fopen; fclose_ = ::fclose; getline_ = ::getline; +#else + // Point to virtual driver interfaces. + extern int virtual_ioctl(int fd, int cmd, ...); + extern int virtual_open(const char *file_name, int access, ...); + extern int virtual_close(int fd); + extern int virtual_poll(struct pollfd *fds, nfds_t num, int timeout); + extern ssize_t virtual_pread(int fd, void *data, size_t count, off_t offset); + extern ssize_t virtual_pwrite(int fd, const void *data, size_t count, off_t offset); + extern FILE* virtual_fopen(const char *fname, const char *mode); + extern int virtual_fclose(FILE* fileptr); + extern ssize_t virtual_getline(char **lineptr, size_t *linelen, FILE *stream); -#ifdef DISPLAY_CORE_VIRTUAL_DRIVER - // If debug property to use virtual driver is set, point to virtual driver interfaces. - if (Debug::IsVirtualDriver()) { - ioctl_ = virtual_ioctl; - open_ = virtual_open; - close_ = virtual_close; - poll_ = virtual_poll; - pread_ = virtual_pread; - pwrite_ = virtual_pwrite; - fopen_ = virtual_fopen; - fclose_ = virtual_fclose; - getline_ = virtual_getline; - } + ioctl_ = virtual_ioctl; + open_ = virtual_open; + close_ = virtual_close; + poll_ = virtual_poll; + pread_ = virtual_pread; + pwrite_ = virtual_pwrite; + fopen_ = virtual_fopen; + fclose_ = virtual_fclose; + getline_ = virtual_getline; #endif } diff --git a/sdm/libs/core/fb/hw_hdmi.cpp b/sdm/libs/core/fb/hw_hdmi.cpp index 1a5c5389..3abda13d 100644 --- a/sdm/libs/core/fb/hw_hdmi.cpp +++ b/sdm/libs/core/fb/hw_hdmi.cpp @@ -27,6 +27,8 @@ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include +#include #include #include #include @@ -382,7 +384,7 @@ HWScanSupport HWHDMI::MapHWScanSupport(uint32_t value) { void HWHDMI::ReadScanInfo() { int scan_info_file = -1; ssize_t len = -1; - char data[PAGE_SIZE] = {'\0'}; + char data[4096] = {'\0'}; snprintf(data, sizeof(data), "%s%d/scan_info", fb_path_, fb_node_index_); scan_info_file = open_(data, O_RDONLY); diff --git a/sdm/libs/core/fb/hw_info.cpp b/sdm/libs/core/fb/hw_info.cpp index b998a46b..2b8a49d3 100644 --- a/sdm/libs/core/fb/hw_info.cpp +++ b/sdm/libs/core/fb/hw_info.cpp @@ -23,6 +23,7 @@ */ #include "hw_info.h" +#include #include #include #include diff --git a/sdm/libs/core/fb/hw_info.h b/sdm/libs/core/fb/hw_info.h index 95f669f4..350c6ff7 100644 --- a/sdm/libs/core/fb/hw_info.h +++ b/sdm/libs/core/fb/hw_info.h @@ -25,7 +25,6 @@ #ifndef __HW_INFO_H__ #define __HW_INFO_H__ -#include #include #include #include "hw_info_interface.h" diff --git a/sdm/libs/core/fb/hw_primary.cpp b/sdm/libs/core/fb/hw_primary.cpp index cb4d8b28..4d1dad16 100644 --- a/sdm/libs/core/fb/hw_primary.cpp +++ b/sdm/libs/core/fb/hw_primary.cpp @@ -27,11 +27,14 @@ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include +#include +#include +#include #include #include -#include +#include #include -#include #include #include "hw_primary.h" diff --git a/sdm/libs/hwc/hwc_debugger.cpp b/sdm/libs/hwc/hwc_debugger.cpp index ab9309e9..6cbce3e1 100644 --- a/sdm/libs/hwc/hwc_debugger.cpp +++ b/sdm/libs/hwc/hwc_debugger.cpp @@ -28,6 +28,7 @@ */ #include +#include #include "hwc_debugger.h" @@ -123,5 +124,16 @@ void HWCDebugHandler::EndTrace() { atrace_end(ATRACE_TAG); } +DisplayError HWCDebugHandler::GetProperty(const char *property_name, int *value) { + char property[PROPERTY_VALUE_MAX]; + + if (property_get(property_name, property, NULL) > 0) { + *value = atoi(property); + return kErrorNone; + } + + return kErrorNotSupported; +} + } // namespace sdm diff --git a/sdm/libs/hwc/hwc_debugger.h b/sdm/libs/hwc/hwc_debugger.h index 61a1b6f4..480db225 100644 --- a/sdm/libs/hwc/hwc_debugger.h +++ b/sdm/libs/hwc/hwc_debugger.h @@ -68,6 +68,7 @@ class HWCDebugHandler : public DebugHandler { virtual void BeginTrace(const char *class_name, const char *function_name, const char *custom_string); virtual void EndTrace(); + virtual DisplayError GetProperty(const char *property_name, int *value); private: static HWCDebugHandler debug_handler_; diff --git a/sdm/libs/utils/Android.mk b/sdm/libs/utils/Android.mk index 57c20886..9de5c07e 100644 --- a/sdm/libs/utils/Android.mk +++ b/sdm/libs/utils/Android.mk @@ -7,7 +7,6 @@ LOCAL_C_INCLUDES := hardware/qcom/display/sdm/include/ LOCAL_CFLAGS := -Wno-missing-field-initializers -Wno-unused-parameter \ -Wconversion -Wall -Werror \ -DLOG_TAG=\"SDM\" -LOCAL_SHARED_LIBRARIES := libcutils -LOCAL_SRC_FILES := debug_android.cpp rect.cpp +LOCAL_SRC_FILES := debug.cpp rect.cpp include $(BUILD_SHARED_LIBRARY) diff --git a/sdm/libs/utils/debug_android.cpp b/sdm/libs/utils/debug.cpp similarity index 59% rename from sdm/libs/utils/debug_android.cpp rename to sdm/libs/utils/debug.cpp index f57d04d3..cce8174b 100644 --- a/sdm/libs/utils/debug_android.cpp +++ b/sdm/libs/utils/debug.cpp @@ -30,73 +30,54 @@ #include #include #include -#include -#include namespace sdm { Debug Debug::debug_; -Debug::Debug() : debug_handler_(&default_debug_handler_), virtual_driver_(false) { - char property[PROPERTY_VALUE_MAX]; - if (property_get("displaycore.virtualdriver", property, NULL) > 0) { - virtual_driver_ = (atoi(property) == 1); - } +Debug::Debug() : debug_handler_(&default_debug_handler_) { } uint32_t Debug::GetSimulationFlag() { - char property[PROPERTY_VALUE_MAX]; - if (property_get("debug.hwc.simulate", property, NULL) > 0) { - return atoi(property); - } + int value = 0; + debug_.debug_handler_->GetProperty("debug.hwc.simulate", &value); - return 0; + return value; } uint32_t Debug::GetHDMIResolution() { - char property[PROPERTY_VALUE_MAX]; - if (property_get("hw.hdmi.resolution", property, NULL) > 0) { - return atoi(property); - } + int value = 0; + debug_.debug_handler_->GetProperty("hw.hdmi.resolution", &value); - return 0; + return value; } uint32_t Debug::GetIdleTimeoutMs() { - char property[PROPERTY_VALUE_MAX]; - if (property_get("debug.mdpcomp.idletime", property, NULL) > 0) { - return atoi(property); - } + int value = IDLE_TIMEOUT_DEFAULT_MS; + debug_.debug_handler_->GetProperty("debug.mdpcomp.idletime", &value); - return IDLE_TIMEOUT_DEFAULT_MS; + return value; } bool Debug::IsRotatorDownScaleDisabled() { - char property[PROPERTY_VALUE_MAX]; - if (property_get("sdm.disable_rotator_downscaling", property, NULL) > 0) { - return (atoi(property) ? 0 : false, true); - } + int value = 0; + debug_.debug_handler_->GetProperty("sdm.disable_rotator_downscaling", &value); - return false; + return (value == 1); } bool Debug::IsDecimationDisabled() { - char property[PROPERTY_VALUE_MAX]; - if (property_get("sdm.disable_decimation", property, NULL) > 0) { - return (atoi(property) ? 0 : false, true); - } + int value = 0; + debug_.debug_handler_->GetProperty("sdm.disable_decimation", &value); - return false; + return (value == 1); } -// This property serves to disable/enable partial update bool Debug::IsPartialUpdateEnabled() { - char property[PROPERTY_VALUE_MAX]; - if (property_get("sdm.hwc.partial_update", property, NULL) > 0) { - return (atoi(property) ? 1 : true, false); - } + int value = 0; + debug_.debug_handler_->GetProperty("sdm.hwc.partial_update", &value); - return false; + return (value == 1); } } // namespace sdm