Skip to content

Commit

Permalink
hwc: HWC 2.0 implementation
Browse files Browse the repository at this point in the history
Add HWCLayer, HWCCallbacks and implement HWC2 layer functionality.

Change-Id: Ic7764e72f4cae534e68764df4cf80eb3db982071
  • Loading branch information
naseer committed Apr 28, 2016
1 parent c14b208 commit b92e73f
Show file tree
Hide file tree
Showing 22 changed files with 5,707 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CMakeLists.txt
.idea/
.editorconfig
.clang-complete
2 changes: 1 addition & 1 deletion Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ display-hals := libgralloc libcopybit liblight libmemtrack libqservice libqdutil
display-hals += hdmi_cec

sdm-libs := sdm/libs
display-hals += $(sdm-libs)/utils $(sdm-libs)/core $(sdm-libs)/hwc
display-hals += $(sdm-libs)/utils $(sdm-libs)/core $(sdm-libs)/hwc $(sdm-libs)/hwc2

ifeq ($(call is-vendor-board-platform,QCOM),true)
include $(call all-named-subdir-makefiles,$(display-hals))
Expand Down
2 changes: 2 additions & 0 deletions common.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#Common headers
display_top := $(call my-dir)

use_hwc2 := false

common_includes := $(display_top)/libqdutils
common_includes += $(display_top)/libqservice
common_includes += $(display_top)/libcopybit
Expand Down
13 changes: 13 additions & 0 deletions sdm/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
Language: Cpp
BasedOnStyle: Google
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortBlocksOnASingleLine: false
ColumnLimit: 100
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
DerivePointerAlignment: false
PointerAlignment: Right
#ReflowComments: false
1 change: 1 addition & 0 deletions sdm/include/utils/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#define DLOGV_IF(tag, format, ...) DLOG(tag, Verbose, format, ##__VA_ARGS__)

#define DLOGE(format, ...) DLOGE_IF(kTagNone, format, ##__VA_ARGS__)
#define DLOGD(format, ...) DLOGD_IF(kTagNone, format, ##__VA_ARGS__)
#define DLOGW(format, ...) DLOGW_IF(kTagNone, format, ##__VA_ARGS__)
#define DLOGI(format, ...) DLOGI_IF(kTagNone, format, ##__VA_ARGS__)
#define DLOGV(format, ...) DLOGV_IF(kTagNone, format, ##__VA_ARGS__)
Expand Down
2 changes: 2 additions & 0 deletions sdm/libs/hwc/Android.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/../../../common.mk
ifeq ($(use_hwc2),false)

LOCAL_MODULE := hwcomposer.$(TARGET_BOARD_PLATFORM)
LOCAL_MODULE_RELATIVE_PATH := hw
Expand Down Expand Up @@ -30,3 +31,4 @@ LOCAL_SRC_FILES := hwc_session.cpp \
cpuhint.cpp

include $(BUILD_SHARED_LIBRARY)
endif
37 changes: 37 additions & 0 deletions sdm/libs/hwc2/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/../../../common.mk

ifeq ($(use_hwc2),true)

LOCAL_MODULE := hwcomposer.$(TARGET_BOARD_PLATFORM)
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES := $(common_includes)

LOCAL_CFLAGS := -Wno-missing-field-initializers -Wno-unused-parameter \
-std=c++11 -fcolor-diagnostics\
-DLOG_TAG=\"SDM\" $(common_flags) \
-I $(display_top)/sdm/libs/hwc
LOCAL_CLANG := true

LOCAL_SHARED_LIBRARIES := libsdmcore libqservice libbinder libhardware libhardware_legacy \
libutils libcutils libsync libmemalloc libqdutils libdl \
libpowermanager libsdmutils libc++

LOCAL_SRC_FILES := hwc_session.cpp \
hwc_display.cpp \
hwc_display_primary.cpp \
hwc_display_external.cpp \
hwc_display_virtual.cpp \
../hwc/hwc_debugger.cpp \
../hwc/hwc_buffer_allocator.cpp \
../hwc/hwc_buffer_sync_handler.cpp \
hwc_color_manager.cpp \
hwc_layers.cpp \
hwc_callbacks.cpp \
../hwc/blit_engine_c2d.cpp \
../hwc/cpuhint.cpp

include $(BUILD_SHARED_LIBRARY)
endif
76 changes: 76 additions & 0 deletions sdm/libs/hwc2/hwc_callbacks.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Copyright (c) 2016, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <utils/constants.h>
#include <utils/debug.h>
#include "hwc_callbacks.h"

#define __CLASS__ "HWCCallbacks"

namespace sdm {

void HWCCallbacks::Hotplug(hwc2_display_t display, HWC2::Connection state) {
if (hotplug_) {
hotplug_(hotplug_data_, display, INT32(state));
}
}

void HWCCallbacks::Refresh(hwc2_display_t display) {
if (refresh_) {
refresh_(refresh_data_, display);
}
}

void HWCCallbacks::Vsync(hwc2_display_t display, int64_t timestamp) {
if (vsync_) {
vsync_(vsync_data_, display, timestamp);
}
}

HWC2::Error HWCCallbacks::Register(HWC2::Callback descriptor, hwc2_callback_data_t callback_data,
hwc2_function_pointer_t pointer) {
switch (descriptor) {
case HWC2::Callback::Hotplug:
hotplug_data_ = callback_data;
hotplug_ = reinterpret_cast<HWC2_PFN_HOTPLUG>(pointer);
break;
case HWC2::Callback::Refresh:
refresh_data_ = callback_data;
refresh_ = reinterpret_cast<HWC2_PFN_REFRESH>(pointer);
break;
case HWC2::Callback::Vsync:
vsync_data_ = callback_data;
vsync_ = reinterpret_cast<HWC2_PFN_VSYNC>(pointer);
break;
default:
return HWC2::Error::BadParameter;
}
return HWC2::Error::None;
}

} // namespace sdm
61 changes: 61 additions & 0 deletions sdm/libs/hwc2/hwc_callbacks.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2016, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef __HWC_CALLBACKS_H__
#define __HWC_CALLBACKS_H__

#define HWC2_INCLUDE_STRINGIFICATION
#define HWC2_USE_CPP11
#include <hardware/hwcomposer2.h>
#undef HWC2_INCLUDE_STRINGIFICATION
#undef HWC2_USE_CPP11

namespace sdm {

class HWCCallbacks {
public:
void Hotplug(hwc2_display_t display, HWC2::Connection state);
void Refresh(hwc2_display_t display);
void Vsync(hwc2_display_t display, int64_t timestamp);
HWC2::Error Register(HWC2::Callback, hwc2_callback_data_t callback_data,
hwc2_function_pointer_t pointer);

private:
hwc2_callback_data_t hotplug_data_ = nullptr;
hwc2_callback_data_t refresh_data_ = nullptr;
hwc2_callback_data_t vsync_data_ = nullptr;

HWC2_PFN_HOTPLUG hotplug_ = nullptr;
HWC2_PFN_REFRESH refresh_ = nullptr;
HWC2_PFN_VSYNC vsync_ = nullptr;
};

} // namespace sdm

#endif // __HWC_CALLBACKS_H__
Loading

0 comments on commit b92e73f

Please sign in to comment.