android_external_minigbm/cros_gralloc/aidl/Main.cpp
Jason Macnak 7d0aa67904 gralloc: Adds Minigbm AIDL allocator
The switch from HIDL to AIDL does not introduce any new interface
methods.

Bug: b/223410512
Test: cvd start
Test: vts -m VtsHalGraphicsAllocatorAidl_TargetTest
Test: vts -m VtsHalGraphicsMapperV4_0Target
Test: cvd start --gpu_mode=gfxstream
Test: vts -m VtsHalGraphicsAllocatorAidl_TargetTest
Test: vts -m VtsHalGraphicsMapperV4_0Target
Change-Id: Idd114498c79bd48502e370c6144d8f08693e3781
2022-03-10 14:42:35 -08:00

44 lines
No EOL
1.3 KiB
C++

/*
* Copyright 2022 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.
*/
#include "Allocator.h"
#include <android-base/logging.h>
#include <android/binder_manager.h>
#include <android/binder_process.h>
#include <log/log.h>
using aidl::android::hardware::graphics::allocator::impl::Allocator;
int main(int /*argc*/, char** /*argv*/) {
ALOGI("Minigbm AIDL allocator starting up...");
// same as SF main thread
struct sched_param param = {0};
param.sched_priority = 2;
if (sched_setscheduler(0, SCHED_FIFO | SCHED_RESET_ON_FORK, &param) != 0) {
ALOGI("%s: failed to set priority: %s", __FUNCTION__, strerror(errno));
}
auto allocator = ndk::SharedRefBase::make<Allocator>();
CHECK(allocator != nullptr);
if (!allocator->init()) {
ALOGE("Failed to initialize Minigbm AIDL allocator.");
return EXIT_FAILURE;
}
const std::string instance = std::string() + Allocator::descriptor + "/default";
binder_status_t status =
AServiceManager_addService(allocator->asBinder().get(), instance.c_str());
CHECK_EQ(status, STATUS_OK);
ABinderProcess_setThreadPoolMaxThreadCount(4);
ABinderProcess_startThreadPool();
ABinderProcess_joinThreadPool();
return EXIT_FAILURE;
}