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
This commit is contained in:
Dileep Marchya
2015-05-21 13:29:05 -07:00
committed by Gerrit - the friendly Code Review server
parent ec01c56d96
commit e2a590859a
15 changed files with 86 additions and 75 deletions

View File

@@ -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.

View File

@@ -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() { }
};

View File

@@ -26,6 +26,11 @@
#define __CONSTANTS_H__
#include <stdlib.h>
#include <inttypes.h>
#ifndef PRIu64
#define PRIu64 "llu"
#endif
#define INT(exp) static_cast<int>(exp)
#define FLOAT(exp) static_cast<float>(exp)

View File

@@ -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_;
};

View File

@@ -27,6 +27,7 @@
#include <stdint.h>
#include <pthread.h>
#include <sys/time.h>
#define SCOPE_LOCK(locker) Locker::ScopeLock lock(locker)
#define SEQUENCE_ENTRY_SCOPE_LOCK(locker) Locker::SequenceEntryScopeLock lock(locker)

View File

@@ -49,7 +49,7 @@ class DumpImpl {
static DumpImpl *dump_list_[kMaxDumpObjects];
static uint32_t dump_count_;
friend DumpInterface;
friend class DumpInterface;
};
} // namespace sdm

View File

@@ -31,6 +31,8 @@
#include <ctype.h>
#include <math.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <inttypes.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -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,10 +61,18 @@ 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;
@@ -83,7 +82,6 @@ HWDevice::HWDevice(BufferSyncHandler *buffer_sync_handler)
fopen_ = virtual_fopen;
fclose_ = virtual_fclose;
getline_ = virtual_getline;
}
#endif
}

View File

@@ -27,6 +27,8 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <unistd.h>
#include <string.h>
#include <sys/ioctl.h>
#include <ctype.h>
#include <utils/debug.h>
@@ -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);

View File

@@ -23,6 +23,7 @@
*/
#include "hw_info.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

View File

@@ -25,7 +25,6 @@
#ifndef __HW_INFO_H__
#define __HW_INFO_H__
#include <inttypes.h>
#include <core/sdm_types.h>
#include <private/hw_info_types.h>
#include "hw_info_interface.h"

View File

@@ -27,11 +27,14 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <unistd.h>
#include <string.h>
#include <pthread.h>
#include <fcntl.h>
#include <sys/prctl.h>
#include <sys/ioctl.h>
#include <pthread.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <fcntl.h>
#include <utils/debug.h>
#include "hw_primary.h"

View File

@@ -28,6 +28,7 @@
*/
#include <utils/constants.h>
#include <cutils/properties.h>
#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

View File

@@ -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_;

View File

@@ -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)

View File

@@ -30,73 +30,54 @@
#include <stdlib.h>
#include <utils/debug.h>
#include <utils/constants.h>
#include <cutils/log.h>
#include <cutils/properties.h>
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 (value == 1);
}
return false;
}
// 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