aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Stratiienko <r.stratiienko@gmail.com>2021-03-09 21:56:50 +0200
committerRoman Stratiienko <r.stratiienko@gmail.com>2021-04-06 12:12:17 +0300
commitd21071f7d5eaa8385fac8eabee73c17d2868775d (patch)
treef8bb981801ab2d880c92a47e2f5c0e61cbfbb1b4
parent6a7ac12a2fdd6e82ed6f4e64899236794363ac06 (diff)
downloaddrm_hwcomposer-d21071f7d5eaa8385fac8eabee73c17d2868775d.tar.gz
drm_hwcomposer: CI: Increase coverage
Add the following files to the build: backend/BackendClient.cpp backend/Backend.cpp backend/BackendManager.cpp backend/BackendRCarDu.cpp bufferinfo/legacy/BufferInfoImagination.cpp bufferinfo/legacy/BufferInfoLibdrm.cpp bufferinfo/legacy/BufferInfoMaliHisi.cpp bufferinfo/legacy/BufferInfoMaliMediatek.cpp bufferinfo/legacy/BufferInfoMaliMeson.cpp bufferinfo/legacy/BufferInfoMinigbm.cpp compositor/DrmDisplayComposition.cpp compositor/DrmDisplayCompositor.cpp compositor/Planner.cpp drm/DrmGenericImporter.cpp DrmHwcTwo.cpp drm/ResourceManager.cpp drm/VSyncWorker.cpp tests/worker_test.cpp utils/autolock.cpp Files 'bufferinfo/BufferInfoMapperMetadata.cpp' and 'utils/hwcutils.cpp' require a lot of additional headers, therefore move them out of the scope of this commit. 'utils/gralloc.h' isn't planned to use in pure-linux builds, therefore remove it from 'utils' and put it into '.ci/android_headers/hardware/' Fix minor tidy fails. Fix linux build fails (missing includes) due to differences between libc and bionic. Comment-out some sections in 'tests/test_include' which aren't used by drm_hwc but causing build failures for CI due to missing dependencies. Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com> Reviewed-by: Matvii Zorin <matvii.zorin@globallogic.com>
-rw-r--r--.ci/.common.sh25
-rwxr-xr-x.ci/.gitlab-ci-clang-tidy-coarse.sh2
-rwxr-xr-x.ci/.gitlab-ci-clang-tidy-fine.sh3
-rw-r--r--.ci/android_headers/hardware/gralloc.h2
-rw-r--r--.ci/android_headers/hardware/hwcomposer2.h7
-rw-r--r--.ci/android_headers/ndk/sync.h6
-rw-r--r--.gitlab-ci.yml2
-rw-r--r--DrmHwcTwo.cpp68
-rw-r--r--backend/Backend.cpp8
-rw-r--r--backend/BackendClient.cpp4
-rw-r--r--backend/BackendManager.cpp5
-rw-r--r--backend/BackendRCarDu.cpp4
-rw-r--r--bufferinfo/BufferInfoGetter.h2
-rw-r--r--bufferinfo/BufferInfoMapperMetadata.cpp3
-rw-r--r--bufferinfo/legacy/BufferInfoImagination.cpp2
-rw-r--r--bufferinfo/legacy/BufferInfoLibdrm.cpp5
-rw-r--r--bufferinfo/legacy/BufferInfoMaliHisi.cpp4
-rw-r--r--bufferinfo/legacy/BufferInfoMaliMediatek.cpp4
-rw-r--r--bufferinfo/legacy/BufferInfoMaliMeson.cpp4
-rw-r--r--bufferinfo/legacy/BufferInfoMinigbm.cpp2
-rw-r--r--compositor/DrmDisplayComposition.cpp2
-rw-r--r--compositor/DrmDisplayCompositor.cpp2
-rw-r--r--compositor/DrmDisplayCompositor.h1
-rw-r--r--compositor/Planner.cpp3
-rw-r--r--compositor/Planner.h3
-rw-r--r--drm/DrmGenericImporter.cpp5
-rw-r--r--drm/ResourceManager.cpp5
-rw-r--r--drm/VSyncWorker.cpp1
-rw-r--r--drm/VSyncWorker.h1
-rw-r--r--tests/test_include/cros_gralloc_handle.h53
-rw-r--r--tests/test_include/gralloc_helper.h3
-rw-r--r--tests/test_include/gralloc_priv.h2
-rw-r--r--tests/test_include/img_gralloc1_public.h6
-rw-r--r--tests/worker_test.cpp21
-rw-r--r--utils/autolock.cpp3
-rw-r--r--utils/gralloc.h68
-rw-r--r--utils/log.h3
37 files changed, 193 insertions, 151 deletions
diff --git a/.ci/.common.sh b/.ci/.common.sh
index fce6eee..93f7f95 100644
--- a/.ci/.common.sh
+++ b/.ci/.common.sh
@@ -1,21 +1,42 @@
-INCLUDE_DIRS="-I. -I../libdrm/include/drm -Iinclude -I/usr/include/libdrm -I./.ci/android_headers"
+INCLUDE_DIRS="-I. -I../libdrm/include/drm -Iinclude -I/usr/include/libdrm -I./.ci/android_headers -I./tests/test_include"
CLANG="clang++-11"
CLANG_TIDY="clang-tidy-11"
-CXXARGS="-fPIC -Wall -Werror -DPLATFORM_SDK_VERSION=30 -Wsign-promo -Wimplicit-fallthrough"
+CXXARGS="-fPIC -Wall -Werror -DPLATFORM_SDK_VERSION=30 -D__ANDROID_API__=30 -Wsign-promo -Wimplicit-fallthrough"
CXXARGS+=" -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -Wno-gnu-include-next "
CXXARGS+=" -fvisibility-inlines-hidden -std=gnu++17 -DHWC2_USE_CPP11 -DHWC2_INCLUDE_STRINGIFICATION -fexceptions -fno-rtti"
BUILD_FILES=(
+backend/BackendClient.cpp
+backend/Backend.cpp
+backend/BackendManager.cpp
+backend/BackendRCarDu.cpp
bufferinfo/BufferInfoGetter.cpp
+#bufferinfo/BufferInfoMapperMetadata.cpp
+bufferinfo/legacy/BufferInfoImagination.cpp
+bufferinfo/legacy/BufferInfoLibdrm.cpp
+bufferinfo/legacy/BufferInfoMaliHisi.cpp
+bufferinfo/legacy/BufferInfoMaliMediatek.cpp
+bufferinfo/legacy/BufferInfoMaliMeson.cpp
+bufferinfo/legacy/BufferInfoMinigbm.cpp
+compositor/DrmDisplayComposition.cpp
+compositor/DrmDisplayCompositor.cpp
+compositor/Planner.cpp
drm/DrmConnector.cpp
drm/DrmCrtc.cpp
drm/DrmDevice.cpp
drm/DrmEncoder.cpp
drm/DrmEventListener.cpp
+drm/DrmGenericImporter.cpp
drm/DrmMode.cpp
drm/DrmPlane.cpp
drm/DrmProperty.cpp
+DrmHwcTwo.cpp
+drm/ResourceManager.cpp
+drm/VSyncWorker.cpp
+tests/worker_test.cpp
+utils/autolock.cpp
+#utils/hwcutils.cpp
utils/Worker.cpp
)
diff --git a/.ci/.gitlab-ci-clang-tidy-coarse.sh b/.ci/.gitlab-ci-clang-tidy-coarse.sh
index 4ecf19e..de0c024 100755
--- a/.ci/.gitlab-ci-clang-tidy-coarse.sh
+++ b/.ci/.gitlab-ci-clang-tidy-coarse.sh
@@ -35,5 +35,5 @@ set -xe
for source in "${TIDY_FILES[@]}"
do
- $CLANG_TIDY $source --checks=$TIDY_COARSE_CHECKS -- -x c++ $INCLUDE_DIRS
+ $CLANG_TIDY $source --checks=$TIDY_COARSE_CHECKS -- -x c++ $INCLUDE_DIRS $CXXARGS
done
diff --git a/.ci/.gitlab-ci-clang-tidy-fine.sh b/.ci/.gitlab-ci-clang-tidy-fine.sh
index fdc0883..644f621 100755
--- a/.ci/.gitlab-ci-clang-tidy-fine.sh
+++ b/.ci/.gitlab-ci-clang-tidy-fine.sh
@@ -3,7 +3,6 @@
. ./.ci/.common.sh
TIDY_FILES=(
-utils/gralloc.h
utils/log.h
utils/properties.h
)
@@ -12,5 +11,5 @@ set -xe
for source in "${TIDY_FILES[@]}"
do
- $CLANG_TIDY $source -- -x c++ $INCLUDE_DIRS
+ $CLANG_TIDY $source -- -x c++ $INCLUDE_DIRS $CXXARGS
done
diff --git a/.ci/android_headers/hardware/gralloc.h b/.ci/android_headers/hardware/gralloc.h
index 1193b1f..260140e 100644
--- a/.ci/android_headers/hardware/gralloc.h
+++ b/.ci/android_headers/hardware/gralloc.h
@@ -29,7 +29,9 @@
#include <cutils/native_handle.h>
#include <hardware/hardware.h>
+#if 0 /* Header below is not used by drm_hwcomposer */
#include <hardware/fb.h>
+#endif
__BEGIN_DECLS
diff --git a/.ci/android_headers/hardware/hwcomposer2.h b/.ci/android_headers/hardware/hwcomposer2.h
index a10f526..df5670f 100644
--- a/.ci/android_headers/hardware/hwcomposer2.h
+++ b/.ci/android_headers/hardware/hwcomposer2.h
@@ -24,6 +24,13 @@
#include "hwcomposer_defs.h"
+/* Missing in glibc, pull from BIONIC */
+#if defined(__cplusplus)
+#define __BIONIC_CAST(_k,_t,_v) (_k<_t>(_v))
+#else
+#define __BIONIC_CAST(_k,_t,_v) ((_t) (_v))
+#endif
+
__BEGIN_DECLS
/*
diff --git a/.ci/android_headers/ndk/sync.h b/.ci/android_headers/ndk/sync.h
index dcc35f3..2ca389b 100644
--- a/.ci/android_headers/ndk/sync.h
+++ b/.ci/android_headers/ndk/sync.h
@@ -67,7 +67,7 @@ __BEGIN_DECLS
*
* Available since API level 26.
*/
-int32_t sync_merge(const char* name, int32_t fd1, int32_t fd2) __INTRODUCED_IN(26);
+int32_t sync_merge(const char* name, int32_t fd1, int32_t fd2) /* __INTRODUCED_IN(26) */;
/**
* Retrieve detailed information about a sync file and its fences.
@@ -76,7 +76,7 @@ int32_t sync_merge(const char* name, int32_t fd1, int32_t fd2) __INTRODUCED_IN(2
*
* Available since API level 26.
*/
-struct sync_file_info* sync_file_info(int32_t fd) __INTRODUCED_IN(26);
+struct sync_file_info* sync_file_info(int32_t fd) /* __INTRODUCED_IN(26) */;
/**
* Get the array of fence infos from the sync file's info.
@@ -100,7 +100,7 @@ static inline struct sync_fence_info* sync_get_fence_info(const struct sync_file
*
* Available since API level 26.
*/
-void sync_file_info_free(struct sync_file_info* info) __INTRODUCED_IN(26);
+void sync_file_info_free(struct sync_file_info* info) /* __INTRODUCED_IN(26) */;
#endif /* __ANDROID_API__ >= 26 */
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7fd7367..04eb6c5 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,7 +2,7 @@ image: ubuntu:20.10
before_script:
- apt-get --quiet update --yes >/dev/null
- - apt-get --quiet install --yes clang-11 clang-tidy-11 clang-format-11 git libdrm-dev blueprint-tools >/dev/null
+ - apt-get --quiet install --yes clang-11 clang-tidy-11 clang-format-11 git libdrm-dev blueprint-tools libgtest-dev >/dev/null
stages:
- build
diff --git a/DrmHwcTwo.cpp b/DrmHwcTwo.cpp
index c2de931..056b167 100644
--- a/DrmHwcTwo.cpp
+++ b/DrmHwcTwo.cpp
@@ -19,18 +19,20 @@
#include "DrmHwcTwo.h"
-#include <cutils/properties.h>
#include <hardware/hardware.h>
#include <hardware/hwcomposer2.h>
-#include <log/log.h>
#include <sync/sync.h>
#include <cinttypes>
+#include <iostream>
+#include <sstream>
#include <string>
#include "backend/BackendManager.h"
#include "bufferinfo/BufferInfoGetter.h"
#include "compositor/DrmDisplayComposition.h"
+#include "utils/log.h"
+#include "utils/properties.h"
namespace android {
@@ -59,8 +61,8 @@ HWC2::Error DrmHwcTwo::CreateDisplay(hwc2_display_t displ,
ALOGE("Failed to get crtc for display %d", static_cast<int>(displ));
return HWC2::Error::BadDisplay;
}
- std::vector<DrmPlane *> display_planes;
- for (auto &plane : drm->planes()) {
+ auto display_planes = std::vector<DrmPlane *>();
+ for (const auto &plane : drm->planes()) {
if (plane->GetCrtcSupported(*crtc))
display_planes.push_back(plane.get());
}
@@ -84,8 +86,8 @@ HWC2::Error DrmHwcTwo::Init() {
}
}
- auto &drm_devices = resource_manager_.getDrmDevices();
- for (auto &device : drm_devices) {
+ const auto &drm_devices = resource_manager_.getDrmDevices();
+ for (const auto &device : drm_devices) {
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
device->RegisterHotplugHandler(new DrmHotplugHandler(this, device.get()));
}
@@ -120,35 +122,33 @@ std::string DrmHwcTwo::HwcDisplay::DumpDelta(
return "No stats yet";
double ratio = 1.0 - double(delta.gpu_pixops_) / double(delta.total_pixops_);
- return (std::stringstream()
- << " Total frames count: " << delta.total_frames_ << "\n"
- << " Failed to test commit frames: " << delta.failed_kms_validate_
- << "\n"
- << " Failed to commit frames: " << delta.failed_kms_present_ << "\n"
- << ((delta.failed_kms_present_ > 0)
- ? " !!! Internal failure, FIX it please\n"
- : "")
- << " Flattened frames: " << delta.frames_flattened_ << "\n"
- << " Pixel operations (free units)"
- << " : [TOTAL: " << delta.total_pixops_
- << " / GPU: " << delta.gpu_pixops_ << "]\n"
- << " Composition efficiency: " << ratio)
- .str();
+ std::stringstream ss;
+ ss << " Total frames count: " << delta.total_frames_ << "\n"
+ << " Failed to test commit frames: " << delta.failed_kms_validate_ << "\n"
+ << " Failed to commit frames: " << delta.failed_kms_present_ << "\n"
+ << ((delta.failed_kms_present_ > 0)
+ ? " !!! Internal failure, FIX it please\n"
+ : "")
+ << " Flattened frames: " << delta.frames_flattened_ << "\n"
+ << " Pixel operations (free units)"
+ << " : [TOTAL: " << delta.total_pixops_ << " / GPU: " << delta.gpu_pixops_
+ << "]\n"
+ << " Composition efficiency: " << ratio;
+
+ return ss.str();
}
std::string DrmHwcTwo::HwcDisplay::Dump() {
- auto out = (std::stringstream()
- << "- Display on: " << connector_->name() << "\n"
- << " Flattening state: " << compositor_.GetFlatteningState()
- << "\n"
- << "Statistics since system boot:\n"
- << DumpDelta(total_stats_) << "\n\n"
- << "Statistics since last dumpsys request:\n"
- << DumpDelta(total_stats_.minus(prev_stats_)) << "\n\n")
- .str();
+ std::stringstream ss;
+ ss << "- Display on: " << connector_->name() << "\n"
+ << " Flattening state: " << compositor_.GetFlatteningState() << "\n"
+ << "Statistics since system boot:\n"
+ << DumpDelta(total_stats_) << "\n\n"
+ << "Statistics since last dumpsys request:\n"
+ << DumpDelta(total_stats_.minus(prev_stats_)) << "\n\n";
memcpy(&prev_stats_, &total_stats_, sizeof(Stats));
- return out;
+ return ss.str();
}
void DrmHwcTwo::Dump(uint32_t *outSize, char *outBuffer) {
@@ -185,8 +185,8 @@ HWC2::Error DrmHwcTwo::RegisterCallback(int32_t descriptor,
switch (static_cast<HWC2::Callback>(descriptor)) {
case HWC2::Callback::Hotplug: {
SetHotplugCallback(data, function);
- auto &drm_devices = resource_manager_.getDrmDevices();
- for (auto &device : drm_devices)
+ const auto &drm_devices = resource_manager_.getDrmDevices();
+ for (const auto &device : drm_devices)
HandleInitialHotplugState(device.get());
break;
}
@@ -1187,7 +1187,7 @@ void DrmHwcTwo::HandleDisplayHotplug(hwc2_display_t displayid, int state) {
}
void DrmHwcTwo::HandleInitialHotplugState(DrmDevice *drmDevice) {
- for (auto &conn : drmDevice->connectors()) {
+ for (const auto &conn : drmDevice->connectors()) {
if (conn->state() != DRM_MODE_CONNECTED)
continue;
HandleDisplayHotplug(conn->display(), conn->state());
@@ -1195,7 +1195,7 @@ void DrmHwcTwo::HandleInitialHotplugState(DrmDevice *drmDevice) {
}
void DrmHwcTwo::DrmHotplugHandler::HandleEvent(uint64_t timestamp_us) {
- for (auto &conn : drm_->connectors()) {
+ for (const auto &conn : drm_->connectors()) {
drmModeConnection old_state = conn->state();
drmModeConnection cur_state = conn->UpdateModes()
? DRM_MODE_UNKNOWNCONNECTION
diff --git a/backend/Backend.cpp b/backend/Backend.cpp
index 3505385..9e9e2b9 100644
--- a/backend/Backend.cpp
+++ b/backend/Backend.cpp
@@ -16,6 +16,8 @@
#include "Backend.h"
+#include <climits>
+
#include "BackendManager.h"
#include "bufferinfo/BufferInfoGetter.h"
@@ -117,7 +119,7 @@ std::tuple<int, size_t> Backend::GetClientLayers(
int client_start = -1;
size_t client_size = 0;
- for (auto &[z_order, layer] : z_map) {
+ for (const auto &[z_order, layer] : z_map) {
if (IsClientLayer(display, layer)) {
if (client_start < 0)
client_start = (int)z_order;
@@ -137,7 +139,9 @@ bool Backend::IsClientLayer(DrmHwcTwo::HwcDisplay *display,
display->resource_manager()->ForcedScalingWithGpu());
}
-// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
+// clang-format off
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables, cert-err58-cpp)
REGISTER_BACKEND("generic", Backend);
+// clang-format on
} // namespace android
diff --git a/backend/BackendClient.cpp b/backend/BackendClient.cpp
index bef536a..49963b8 100644
--- a/backend/BackendClient.cpp
+++ b/backend/BackendClient.cpp
@@ -30,7 +30,9 @@ HWC2::Error BackendClient::ValidateDisplay(DrmHwcTwo::HwcDisplay *display,
return HWC2::Error::HasChanges;
}
-// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
+// clang-format off
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables, cert-err58-cpp)
REGISTER_BACKEND("client", BackendClient);
+// clang-format on
} // namespace android
diff --git a/backend/BackendManager.cpp b/backend/BackendManager.cpp
index a346d46..7b89761 100644
--- a/backend/BackendManager.cpp
+++ b/backend/BackendManager.cpp
@@ -18,11 +18,12 @@
#include "BackendManager.h"
-#include <cutils/properties.h>
-#include <log/log.h>
+#include "utils/log.h"
+#include "utils/properties.h"
namespace android {
+// NOLINTNEXTLINE(cert-err58-cpp)
const std::vector<std::string> BackendManager::kClientDevices = {
"kirin",
"mediatek-drm",
diff --git a/backend/BackendRCarDu.cpp b/backend/BackendRCarDu.cpp
index 6585406..b012797 100644
--- a/backend/BackendRCarDu.cpp
+++ b/backend/BackendRCarDu.cpp
@@ -40,7 +40,9 @@ bool BackendRCarDu::IsClientLayer(DrmHwcTwo::HwcDisplay *display,
return Backend::IsClientLayer(display, layer);
}
-// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
+// clang-format off
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables, cert-err58-cpp)
REGISTER_BACKEND("rcar-du", BackendRCarDu);
+// clang-format on
} // namespace android \ No newline at end of file
diff --git a/bufferinfo/BufferInfoGetter.h b/bufferinfo/BufferInfoGetter.h
index c1dc74a..60ca985 100644
--- a/bufferinfo/BufferInfoGetter.h
+++ b/bufferinfo/BufferInfoGetter.h
@@ -18,10 +18,10 @@
#define ANDROID_BUFFERINFOGETTER_H_
#include <drm/drm_fourcc.h>
+#include <hardware/gralloc.h>
#include "drm/DrmDevice.h"
#include "drmhwcgralloc.h"
-#include "utils/gralloc.h"
#ifndef DRM_FORMAT_INVALID
#define DRM_FORMAT_INVALID 0
diff --git a/bufferinfo/BufferInfoMapperMetadata.cpp b/bufferinfo/BufferInfoMapperMetadata.cpp
index 516c7e1..23a9072 100644
--- a/bufferinfo/BufferInfoMapperMetadata.cpp
+++ b/bufferinfo/BufferInfoMapperMetadata.cpp
@@ -21,13 +21,14 @@
#include "BufferInfoMapperMetadata.h"
#include <drm/drm_fourcc.h>
-#include <log/log.h>
#include <ui/GraphicBufferMapper.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
#include <cinttypes>
+#include "utils/log.h"
+
namespace android {
BufferInfoGetter *BufferInfoMapperMetadata::CreateInstance() {
diff --git a/bufferinfo/legacy/BufferInfoImagination.cpp b/bufferinfo/legacy/BufferInfoImagination.cpp
index b3c1d33..d646072 100644
--- a/bufferinfo/legacy/BufferInfoImagination.cpp
+++ b/bufferinfo/legacy/BufferInfoImagination.cpp
@@ -18,10 +18,10 @@
#include "BufferInfoImagination.h"
-#include <log/log.h>
#include <xf86drm.h>
#include "img_gralloc1_public.h"
+#include "utils/log.h"
namespace android {
diff --git a/bufferinfo/legacy/BufferInfoLibdrm.cpp b/bufferinfo/legacy/BufferInfoLibdrm.cpp
index 1953e36..52f792f 100644
--- a/bufferinfo/legacy/BufferInfoLibdrm.cpp
+++ b/bufferinfo/legacy/BufferInfoLibdrm.cpp
@@ -18,13 +18,14 @@
#include "BufferInfoLibdrm.h"
-#include <cutils/properties.h>
#include <gralloc_handle.h>
#include <hardware/gralloc.h>
-#include <log/log.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
+#include "utils/log.h"
+#include "utils/properties.h"
+
namespace android {
LEGACY_BUFFER_INFO_GETTER(BufferInfoLibdrm);
diff --git a/bufferinfo/legacy/BufferInfoMaliHisi.cpp b/bufferinfo/legacy/BufferInfoMaliHisi.cpp
index ddb12ab..5fc413a 100644
--- a/bufferinfo/legacy/BufferInfoMaliHisi.cpp
+++ b/bufferinfo/legacy/BufferInfoMaliHisi.cpp
@@ -18,13 +18,13 @@
#include "BufferInfoMaliHisi.h"
-#include <log/log.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
#include <cinttypes>
#include "gralloc_priv.h"
+#include "utils/log.h"
#define MALI_ALIGN(value, base) (((value) + ((base)-1)) & ~((base)-1))
@@ -70,7 +70,7 @@ int BufferInfoMaliHisi::ConvertBoInfo(buffer_handle_t handle,
hwc_drm_bo_t *bo) {
bool is_rgb = false;
- auto *hnd = (private_handle_t const *)handle;
+ const auto *hnd = (private_handle_t const *)handle;
if (!hnd)
return -EINVAL;
diff --git a/bufferinfo/legacy/BufferInfoMaliMediatek.cpp b/bufferinfo/legacy/BufferInfoMaliMediatek.cpp
index f6e0ac5..7e6f3a8 100644
--- a/bufferinfo/legacy/BufferInfoMaliMediatek.cpp
+++ b/bufferinfo/legacy/BufferInfoMaliMediatek.cpp
@@ -19,7 +19,6 @@
#include "BufferInfoMaliMediatek.h"
#include <hardware/gralloc.h>
-#include <log/log.h>
#include <stdatomic.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
@@ -27,6 +26,7 @@
#include <cinttypes>
#include "gralloc_priv.h"
+#include "utils/log.h"
namespace android {
@@ -34,7 +34,7 @@ LEGACY_BUFFER_INFO_GETTER(BufferInfoMaliMediatek);
int BufferInfoMaliMediatek::ConvertBoInfo(buffer_handle_t handle,
hwc_drm_bo_t *bo) {
- auto *hnd = (private_handle_t const *)handle;
+ const auto *hnd = (private_handle_t const *)handle;
if (!hnd)
return -EINVAL;
diff --git a/bufferinfo/legacy/BufferInfoMaliMeson.cpp b/bufferinfo/legacy/BufferInfoMaliMeson.cpp
index ad10203..9daf542 100644
--- a/bufferinfo/legacy/BufferInfoMaliMeson.cpp
+++ b/bufferinfo/legacy/BufferInfoMaliMeson.cpp
@@ -18,13 +18,13 @@
#include "BufferInfoMaliMeson.h"
-#include <log/log.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
#include <cinttypes>
#include "gralloc_priv.h"
+#include "utils/log.h"
namespace android {
@@ -63,7 +63,7 @@ uint64_t BufferInfoMaliMeson::ConvertGrallocFormatToDrmModifiers(
int BufferInfoMaliMeson::ConvertBoInfo(buffer_handle_t handle,
hwc_drm_bo_t *bo) {
- auto *hnd = (private_handle_t const *)handle;
+ const auto *hnd = (private_handle_t const *)handle;
if (!hnd)
return -EINVAL;
diff --git a/bufferinfo/legacy/BufferInfoMinigbm.cpp b/bufferinfo/legacy/BufferInfoMinigbm.cpp
index f5e661f..d030dff 100644
--- a/bufferinfo/legacy/BufferInfoMinigbm.cpp
+++ b/bufferinfo/legacy/BufferInfoMinigbm.cpp
@@ -18,11 +18,11 @@
#include "BufferInfoMinigbm.h"
-#include <log/log.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
#include "cros_gralloc_handle.h"
+#include "utils/log.h"
#define DRM_FORMAT_YVU420_ANDROID fourcc_code('9', '9', '9', '7')
diff --git a/compositor/DrmDisplayComposition.cpp b/compositor/DrmDisplayComposition.cpp
index ef151a1..31d8693 100644
--- a/compositor/DrmDisplayComposition.cpp
+++ b/compositor/DrmDisplayComposition.cpp
@@ -18,7 +18,6 @@
#include "DrmDisplayComposition.h"
-#include <log/log.h>
#include <sync/sync.h>
#include <xf86drmMode.h>
@@ -29,6 +28,7 @@
#include "DrmDisplayCompositor.h"
#include "Planner.h"
#include "drm/DrmDevice.h"
+#include "utils/log.h"
namespace android {
diff --git a/compositor/DrmDisplayCompositor.cpp b/compositor/DrmDisplayCompositor.cpp
index 2cc0da5..fd60f97 100644
--- a/compositor/DrmDisplayCompositor.cpp
+++ b/compositor/DrmDisplayCompositor.cpp
@@ -20,7 +20,6 @@
#include "DrmDisplayCompositor.h"
#include <drm/drm_mode.h>
-#include <log/log.h>
#include <pthread.h>
#include <sched.h>
#include <sync/sync.h>
@@ -36,6 +35,7 @@
#include "drm/DrmDevice.h"
#include "drm/DrmPlane.h"
#include "utils/autolock.h"
+#include "utils/log.h"
namespace android {
diff --git a/compositor/DrmDisplayCompositor.h b/compositor/DrmDisplayCompositor.h
index 8660a6d..9ce91b7 100644
--- a/compositor/DrmDisplayCompositor.h
+++ b/compositor/DrmDisplayCompositor.h
@@ -21,6 +21,7 @@
#include <hardware/hwcomposer.h>
#include <pthread.h>
+#include <functional>
#include <memory>
#include <sstream>
#include <tuple>
diff --git a/compositor/Planner.cpp b/compositor/Planner.cpp
index b6f10d2..58db2ea 100644
--- a/compositor/Planner.cpp
+++ b/compositor/Planner.cpp
@@ -18,9 +18,10 @@
#include "Planner.h"
-#include <log/log.h>
+#include <algorithm>
#include "drm/DrmDevice.h"
+#include "utils/log.h"
namespace android {
diff --git a/compositor/Planner.h b/compositor/Planner.h
index 09034ff..5d448a4 100644
--- a/compositor/Planner.h
+++ b/compositor/Planner.h
@@ -21,6 +21,7 @@
#include <hardware/hwcomposer.h>
#include <map>
+#include <memory>
#include <vector>
#include "compositor/DrmDisplayComposition.h"
@@ -99,7 +100,7 @@ class Planner {
std::vector<DrmPlane *> *overlay_planes);
template <typename T, typename... A>
- void AddStage(A &&... args) {
+ void AddStage(A &&...args) {
stages_.emplace_back(
std::unique_ptr<PlanStage>(new T(std::forward(args)...)));
}
diff --git a/drm/DrmGenericImporter.cpp b/drm/DrmGenericImporter.cpp
index 893eb8d..0cbe601 100644
--- a/drm/DrmGenericImporter.cpp
+++ b/drm/DrmGenericImporter.cpp
@@ -18,15 +18,16 @@
#include "DrmGenericImporter.h"
-#include <cutils/properties.h>
#include <gralloc_handle.h>
#include <hardware/gralloc.h>
-#include <log/log.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
#include <cinttypes>
+#include "utils/log.h"
+#include "utils/properties.h"
+
namespace android {
DrmGenericImporter::DrmGenericImporter(DrmDevice *drm) : drm_(drm) {
diff --git a/drm/ResourceManager.cpp b/drm/ResourceManager.cpp
index 50c33aa..f8e9cab 100644
--- a/drm/ResourceManager.cpp
+++ b/drm/ResourceManager.cpp
@@ -18,13 +18,14 @@
#include "ResourceManager.h"
-#include <cutils/properties.h>
+#include <fcntl.h>
#include <sys/stat.h>
#include <sstream>
#include "bufferinfo/BufferInfoGetter.h"
#include "utils/log.h"
+#include "utils/properties.h"
namespace android {
@@ -115,7 +116,7 @@ bool ResourceManager::IsKMSDev(const char *path) {
if (fd < 0)
return false;
- auto res = drmModeGetResources(fd);
+ auto *res = drmModeGetResources(fd);
if (!res) {
close(fd);
return false;
diff --git a/drm/VSyncWorker.cpp b/drm/VSyncWorker.cpp
index e9f4f9c..25eeeab 100644
--- a/drm/VSyncWorker.cpp
+++ b/drm/VSyncWorker.cpp
@@ -22,6 +22,7 @@
#include <xf86drmMode.h>
#include <cstdlib>
+#include <cstring>
#include <ctime>
#include "utils/log.h"
diff --git a/drm/VSyncWorker.h b/drm/VSyncWorker.h
index 76f2854..b43918c 100644
--- a/drm/VSyncWorker.h
+++ b/drm/VSyncWorker.h
@@ -22,6 +22,7 @@
#include <hardware/hwcomposer2.h>
#include <stdint.h>
+#include <atomic>
#include <map>
#include "DrmDevice.h"
diff --git a/tests/test_include/cros_gralloc_handle.h b/tests/test_include/cros_gralloc_handle.h
new file mode 100644
index 0000000..d77d777
--- /dev/null
+++ b/tests/test_include/cros_gralloc_handle.h
@@ -0,0 +1,53 @@
+// clang-format off
+/*
+ * Copyright 2016 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef CROS_GRALLOC_HANDLE_H
+#define CROS_GRALLOC_HANDLE_H
+
+#include <cstdint>
+#include <cutils/native_handle.h>
+
+#define DRV_MAX_PLANES 4
+#define DRV_MAX_FDS (DRV_MAX_PLANES + 1)
+
+struct cros_gralloc_handle : public native_handle_t {
+ /*
+ * File descriptors must immediately follow the native_handle_t base and used file
+ * descriptors must be packed at the beginning of this array to work with
+ * native_handle_clone().
+ *
+ * This field contains 'num_planes' plane file descriptors followed by an optional metadata
+ * reserved region file descriptor if 'reserved_region_size' is greater than zero.
+ */
+ int32_t fds[DRV_MAX_FDS];
+ uint32_t strides[DRV_MAX_PLANES];
+ uint32_t offsets[DRV_MAX_PLANES];
+ uint32_t sizes[DRV_MAX_PLANES];
+ uint32_t id;
+ uint32_t width;
+ uint32_t height;
+ uint32_t format; /* DRM format */
+ uint32_t tiling;
+ uint64_t format_modifier;
+ uint64_t use_flags; /* Buffer creation flags */
+ uint32_t magic;
+ uint32_t pixel_stride;
+ int32_t droid_format;
+ int32_t usage; /* Android usage. */
+ uint32_t num_planes;
+ uint64_t reserved_region_size;
+ uint64_t total_size; /* Total allocation size */
+ /*
+ * Name is a null terminated char array located at handle->base.data[handle->name_offset].
+ */
+ uint32_t name_offset;
+} __attribute__((packed));
+
+typedef const struct cros_gralloc_handle *cros_gralloc_handle_t;
+
+#endif
+// clang-format on
diff --git a/tests/test_include/gralloc_helper.h b/tests/test_include/gralloc_helper.h
index e65fc1c..b6cd24d 100644
--- a/tests/test_include/gralloc_helper.h
+++ b/tests/test_include/gralloc_helper.h
@@ -21,7 +21,8 @@
#define GRALLOC_HELPER_H_
#include <sys/mman.h>
-#include <android/log.h>
+#include <sys/user.h>
+#include "utils/log.h"
#ifndef AWAR
#define AWAR(fmt, args...) \
diff --git a/tests/test_include/gralloc_priv.h b/tests/test_include/gralloc_priv.h
index 2cfae7f..e771a69 100644
--- a/tests/test_include/gralloc_priv.h
+++ b/tests/test_include/gralloc_priv.h
@@ -28,7 +28,7 @@
#include <unistd.h>
#include <sys/mman.h>
#include <cutils/native_handle.h>
-#include <utils/Log.h>
+#include "utils/log.h"
#if GRALLOC_USE_GRALLOC1_API
#include <hardware/gralloc1.h>
diff --git a/tests/test_include/img_gralloc1_public.h b/tests/test_include/img_gralloc1_public.h
index 5305845..aef435f 100644
--- a/tests/test_include/img_gralloc1_public.h
+++ b/tests/test_include/img_gralloc1_public.h
@@ -30,7 +30,9 @@
*/
#include <hardware/gralloc.h>
+#if 0 /* Header below is not used by drm_hwcomposer */
#include <hardware/memtrack.h>
+#endif
#define ALIGN(x,a) (((x) + (a) - 1L) & ~((a) - 1L))
#define HW_ALIGN 16
@@ -161,6 +163,8 @@ typedef struct IMG_buffer_format_public_t
}
IMG_buffer_format_public_t;
+#if 0 /* Not used by drm_hwcomposer but require additional dependencies */
+
typedef struct
{
/* Base memtrack record, copied to caller */
@@ -207,6 +211,8 @@ typedef struct IMG_gralloc_module_public_t
}
IMG_gralloc_module_public_t;
+#endif
+
/**
* pixel format definitions
*/
diff --git a/tests/worker_test.cpp b/tests/worker_test.cpp
index cb6275e..d1eb2b3 100644
--- a/tests/worker_test.cpp
+++ b/tests/worker_test.cpp
@@ -8,17 +8,13 @@
using android::Worker;
struct TestWorker : public Worker {
- TestWorker()
- : Worker("test-worker", HAL_PRIORITY_URGENT_DISPLAY),
- value(0),
- enabled_(false) {
- }
+ TestWorker() : Worker("test-worker", HAL_PRIORITY_URGENT_DISPLAY){};
int Init() {
return InitWorker();
}
- void Routine() {
+ void Routine() override {
Lock();
if (!enabled_) {
int ret = WaitForSignalOrExitLocked();
@@ -47,16 +43,17 @@ struct TestWorker : public Worker {
Signal();
}
- int value;
+ // NOLINTNEXTLINE: should not be public
+ int value{};
private:
- bool enabled_;
+ bool enabled_{};
};
struct WorkerTest : public testing::Test {
TestWorker worker;
- virtual void SetUp() {
+ void SetUp() override {
worker.Init();
}
@@ -65,7 +62,8 @@ struct WorkerTest : public testing::Test {
}
};
-TEST_F(WorkerTest, test_worker) {
+// NOLINTNEXTLINE: required by gtest macros
+TEST_F(WorkerTest, TestWorker) {
// already isInitialized so should succeed
ASSERT_TRUE(worker.initialized());
@@ -102,7 +100,8 @@ TEST_F(WorkerTest, test_worker) {
ASSERT_FALSE(worker.initialized());
}
-TEST_F(WorkerTest, exit_while_running) {
+// NOLINTNEXTLINE: required by gtest macros
+TEST_F(WorkerTest, ExitWhileRunning) {
worker.Control(true);
std::this_thread::sleep_for(std::chrono::milliseconds(50));
diff --git a/utils/autolock.cpp b/utils/autolock.cpp
index 4b5cd7e..3342e46 100644
--- a/utils/autolock.cpp
+++ b/utils/autolock.cpp
@@ -19,11 +19,12 @@
#include "autolock.h"
-#include <log/log.h>
#include <pthread.h>
#include <cerrno>
+#include "utils/log.h"
+
namespace android {
int AutoLock::Lock() {
diff --git a/utils/gralloc.h b/utils/gralloc.h
deleted file mode 100644
index 1bf08ee..0000000
--- a/utils/gralloc.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef UTILS_GRALLOC_H_
-#define UTILS_GRALLOC_H_
-
-#ifdef ANDROID
-#include <hardware/gralloc.h>
-#else
-
-/* STUBS */
-
-#include <cstdint>
-
-using buffer_handle_t = int;
-
-// NOLINTNEXTLINE(readability-identifier-naming)
-constexpr auto GRALLOC_HARDWARE_MODULE_ID = "gralloc";
-
-enum {
- HAL_PIXEL_FORMAT_RGBA_8888 = 1, // NOLINT(readability-identifier-naming)
- HAL_PIXEL_FORMAT_RGBX_8888 = 2, // NOLINT(readability-identifier-naming)
- HAL_PIXEL_FORMAT_RGB_888 = 3, // NOLINT(readability-identifier-naming)
- HAL_PIXEL_FORMAT_RGB_565 = 4, // NOLINT(readability-identifier-naming)
- HAL_PIXEL_FORMAT_BGRA_8888 = 5, // NOLINT(readability-identifier-naming)
- HAL_PIXEL_FORMAT_RGBA_FP16 = 22, // NOLINT(readability-identifier-naming)
- HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 34, // NOLINT(readability-identifier-naming)
- HAL_PIXEL_FORMAT_RGBA_1010102 = 43, // NOLINT(readability-identifier-naming)
- HAL_PIXEL_FORMAT_YV12 = 842094169, // NOLINT(readability-identifier-naming)
-};
-
-// NOLINTNEXTLINE(readability-identifier-naming)
-struct hw_module_t {
- uint32_t tag{};
- uint16_t module_api_version{};
- uint16_t hal_api_version{};
- const char *id{};
- const char *name{};
- const char *author{};
- void *dso{};
-};
-
-// NOLINTNEXTLINE(readability-identifier-naming)
-struct gralloc_module_t {
- hw_module_t common;
-};
-
-auto inline hw_get_module(const char * /*id*/,
- const struct hw_module_t ** /*module*/) -> int {
- return -1;
-}
-
-#endif
-
-#endif
diff --git a/utils/log.h b/utils/log.h
index 1fe4713..a48d2e7 100644
--- a/utils/log.h
+++ b/utils/log.h
@@ -7,6 +7,9 @@
#else
+#include <cinttypes>
+#include <cstdio>
+
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define ALOGE(args...) printf("ERR: " args)
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)