drm_hwcomposer: Use __ANDROID_API__ instead of PLATFORM_SDK_VERSION
__ANDROID_API__ definition is available by default in AOSP and NDK.
It also exported by standard system clang when the user sets
the '-target <ARCH>-linux-android<LEVEL>' compiler flag.
Reason for this change is integration of meson build script, where
otherwise the user has to provide the API level manually.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
diff --git a/.ci/Makefile b/.ci/Makefile
index ea9e85b..66922be 100644
--- a/.ci/Makefile
+++ b/.ci/Makefile
@@ -7,7 +7,7 @@
OUT_DIR := /tmp/drm_hwcomposer/build
SRC_DIR := .
-CXXFLAGS := -fPIC -Wall -Wextra -Werror -DPLATFORM_SDK_VERSION=31 -D__ANDROID_API__=31
+CXXFLAGS := -fPIC -Wall -Wextra -Werror -D__ANDROID_API__=31
CXXFLAGS += -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
CXXFLAGS += -fvisibility-inlines-hidden -std=gnu++17 -DHWC2_USE_CPP11 -DHWC2_INCLUDE_STRINGIFICATION -fno-rtti
diff --git a/Android.bp b/Android.bp
index a55e070..92e2bc3 100644
--- a/Android.bp
+++ b/Android.bp
@@ -68,12 +68,6 @@
"-std=c++17",
],
- product_variables: {
- platform_sdk_version: {
- cflags: ["-DPLATFORM_SDK_VERSION=%d"],
- },
- },
-
relative_install_path: "hw",
vendor: true,
}
diff --git a/bufferinfo/BufferInfoGetter.cpp b/bufferinfo/BufferInfoGetter.cpp
index 5716176..726b4eb 100644
--- a/bufferinfo/BufferInfoGetter.cpp
+++ b/bufferinfo/BufferInfoGetter.cpp
@@ -18,7 +18,7 @@
#include "BufferInfoGetter.h"
-#if PLATFORM_SDK_VERSION >= 30
+#if __ANDROID_API__ >= 30
#include "BufferInfoMapperMetadata.h"
#endif
@@ -38,7 +38,7 @@
BufferInfoGetter *BufferInfoGetter::GetInstance() {
static std::unique_ptr<BufferInfoGetter> inst;
if (!inst) {
-#if PLATFORM_SDK_VERSION >= 30 && defined(USE_IMAPPER4_METADATA_API)
+#if __ANDROID_API__ >= 30 && defined(USE_IMAPPER4_METADATA_API)
inst.reset(BufferInfoMapperMetadata::CreateInstance());
if (!inst) {
ALOGW(
diff --git a/bufferinfo/BufferInfoMapperMetadata.cpp b/bufferinfo/BufferInfoMapperMetadata.cpp
index bdacb74..823d28a 100644
--- a/bufferinfo/BufferInfoMapperMetadata.cpp
+++ b/bufferinfo/BufferInfoMapperMetadata.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#if PLATFORM_SDK_VERSION >= 30
+#if __ANDROID_API__ >= 30
#define LOG_TAG "hwc-bufferinfo-mappermetadata"
diff --git a/hwc2_device/DrmHwcTwo.cpp b/hwc2_device/DrmHwcTwo.cpp
index 4accb07..6facac3 100644
--- a/hwc2_device/DrmHwcTwo.cpp
+++ b/hwc2_device/DrmHwcTwo.cpp
@@ -196,7 +196,7 @@
vsync_callback_ = std::make_pair(HWC2_PFN_VSYNC(function), data);
break;
}
-#if PLATFORM_SDK_VERSION > 29
+#if __ANDROID_API__ > 29
case HWC2::Callback::Vsync_2_4: {
vsync_2_4_callback_ = std::make_pair(HWC2_PFN_VSYNC_2_4(function), data);
break;
@@ -239,7 +239,7 @@
hwc2_display_t displayid, int64_t timestamp,
[[maybe_unused]] uint32_t vsync_period) const {
/* vsync callback */
-#if PLATFORM_SDK_VERSION > 29
+#if __ANDROID_API__ > 29
if (vsync_2_4_callback_.first != nullptr &&
vsync_2_4_callback_.second != nullptr) {
vsync_2_4_callback_.first(vsync_2_4_callback_.second, displayid, timestamp,
@@ -255,7 +255,7 @@
void DrmHwcTwo::SendVsyncPeriodTimingChangedEventToClient(
[[maybe_unused]] hwc2_display_t displayid,
[[maybe_unused]] int64_t timestamp) const {
-#if PLATFORM_SDK_VERSION > 29
+#if __ANDROID_API__ > 29
hwc_vsync_period_change_timeline_t timeline = {
.newVsyncAppliedTimeNanos = timestamp,
.refreshRequired = false,
diff --git a/hwc2_device/DrmHwcTwo.h b/hwc2_device/DrmHwcTwo.h
index 29f61da..7a65853 100644
--- a/hwc2_device/DrmHwcTwo.h
+++ b/hwc2_device/DrmHwcTwo.h
@@ -30,7 +30,7 @@
std::pair<HWC2_PFN_HOTPLUG, hwc2_callback_data_t> hotplug_callback_{};
std::pair<HWC2_PFN_VSYNC, hwc2_callback_data_t> vsync_callback_{};
-#if PLATFORM_SDK_VERSION > 29
+#if __ANDROID_API__ > 29
std::pair<HWC2_PFN_VSYNC_2_4, hwc2_callback_data_t> vsync_2_4_callback_{};
std::pair<HWC2_PFN_VSYNC_PERIOD_TIMING_CHANGED, hwc2_callback_data_t>
period_timing_changed_callback_{};
diff --git a/hwc2_device/HwcDisplay.cpp b/hwc2_device/HwcDisplay.cpp
index cfef776..115b61a 100644
--- a/hwc2_device/HwcDisplay.cpp
+++ b/hwc2_device/HwcDisplay.cpp
@@ -322,7 +322,7 @@
kUmPerInch / mm_height)
: -1;
break;
-#if PLATFORM_SDK_VERSION > 29
+#if __ANDROID_API__ > 29
case HWC2::Attribute::ConfigGroup:
/* Dispite ConfigGroup is a part of HWC2.4 API, framework
* able to request it even if service @2.1 is used */
@@ -772,7 +772,7 @@
(int32_t *)(outVsyncPeriod));
}
-#if PLATFORM_SDK_VERSION > 29
+#if __ANDROID_API__ > 29
HWC2::Error HwcDisplay::GetDisplayConnectionType(uint32_t *outType) {
if (IsInHeadlessMode()) {
*outType = static_cast<uint32_t>(HWC2::DisplayConnectionType::Internal);
@@ -850,7 +850,7 @@
}
#endif
-#if PLATFORM_SDK_VERSION > 28
+#if __ANDROID_API__ > 28
HWC2::Error HwcDisplay::GetDisplayIdentificationData(uint8_t *outPort,
uint32_t *outDataSize,
uint8_t *outData) {
@@ -895,9 +895,9 @@
return HWC2::Error::Unsupported;
}
-#endif /* PLATFORM_SDK_VERSION > 28 */
+#endif /* __ANDROID_API__ > 28 */
-#if PLATFORM_SDK_VERSION > 27
+#if __ANDROID_API__ > 27
HWC2::Error HwcDisplay::GetRenderIntents(
int32_t mode, uint32_t *outNumIntents,
@@ -933,7 +933,7 @@
return HWC2::Error::None;
}
-#endif /* PLATFORM_SDK_VERSION > 27 */
+#endif /* __ANDROID_API__ > 27 */
const Backend *HwcDisplay::backend() const {
return backend_.get();
diff --git a/hwc2_device/HwcDisplay.h b/hwc2_device/HwcDisplay.h
index 40c90a3..0334470 100644
--- a/hwc2_device/HwcDisplay.h
+++ b/hwc2_device/HwcDisplay.h
@@ -68,12 +68,12 @@
uint32_t *num_elements, hwc2_layer_t *layers,
int32_t *layer_requests);
HWC2::Error GetDisplayType(int32_t *type);
-#if PLATFORM_SDK_VERSION > 27
+#if __ANDROID_API__ > 27
HWC2::Error GetRenderIntents(int32_t mode, uint32_t *outNumIntents,
int32_t *outIntents);
HWC2::Error SetColorModeWithIntent(int32_t mode, int32_t intent);
#endif
-#if PLATFORM_SDK_VERSION > 28
+#if __ANDROID_API__ > 28
HWC2::Error GetDisplayIdentificationData(uint8_t *outPort,
uint32_t *outDataSize,
uint8_t *outData);
@@ -82,7 +82,7 @@
HWC2::Error GetDisplayBrightnessSupport(bool *supported);
HWC2::Error SetDisplayBrightness(float);
#endif
-#if PLATFORM_SDK_VERSION > 29
+#if __ANDROID_API__ > 29
HWC2::Error GetDisplayConnectionType(uint32_t *outType);
HWC2::Error SetActiveConfigWithConstraints(
diff --git a/hwc2_device/hwc2_device.cpp b/hwc2_device/hwc2_device.cpp
index 2242391..87a7705 100644
--- a/hwc2_device/hwc2_device.cpp
+++ b/hwc2_device/hwc2_device.cpp
@@ -244,7 +244,7 @@
return ToHook<HWC2_PFN_VALIDATE_DISPLAY>(
DisplayHook<decltype(&HwcDisplay::ValidateDisplay),
&HwcDisplay::ValidateDisplay, uint32_t *, uint32_t *>);
-#if PLATFORM_SDK_VERSION > 27
+#if __ANDROID_API__ > 27
case HWC2::FunctionDescriptor::GetRenderIntents:
return ToHook<HWC2_PFN_GET_RENDER_INTENTS>(
DisplayHook<decltype(&HwcDisplay::GetRenderIntents),
@@ -255,7 +255,7 @@
DisplayHook<decltype(&HwcDisplay::SetColorModeWithIntent),
&HwcDisplay::SetColorModeWithIntent, int32_t, int32_t>);
#endif
-#if PLATFORM_SDK_VERSION > 28
+#if __ANDROID_API__ > 28
case HWC2::FunctionDescriptor::GetDisplayIdentificationData:
return ToHook<HWC2_PFN_GET_DISPLAY_IDENTIFICATION_DATA>(
DisplayHook<decltype(&HwcDisplay::GetDisplayIdentificationData),
@@ -274,8 +274,8 @@
return ToHook<HWC2_PFN_SET_DISPLAY_BRIGHTNESS>(
DisplayHook<decltype(&HwcDisplay::SetDisplayBrightness),
&HwcDisplay::SetDisplayBrightness, float>);
-#endif /* PLATFORM_SDK_VERSION > 28 */
-#if PLATFORM_SDK_VERSION > 29
+#endif /* __ANDROID_API__ > 28 */
+#if __ANDROID_API__ > 29
case HWC2::FunctionDescriptor::GetDisplayConnectionType:
return ToHook<HWC2_PFN_GET_DISPLAY_CONNECTION_TYPE>(
DisplayHook<decltype(&HwcDisplay::GetDisplayConnectionType),