xref: /aosp_15_r20/external/minigbm/cros_gralloc/gralloc4/CrosGralloc4AllocatorService.cc (revision d95af8df99a05bcb8679a54dc3ab8e5cd312b38e)
1*d95af8dfSAndroid Build Coastguard Worker /*
2*d95af8dfSAndroid Build Coastguard Worker  * Copyright 2020 The Chromium OS Authors. All rights reserved.
3*d95af8dfSAndroid Build Coastguard Worker  * Use of this source code is governed by a BSD-style license that can be
4*d95af8dfSAndroid Build Coastguard Worker  * found in the LICENSE file.
5*d95af8dfSAndroid Build Coastguard Worker  */
6*d95af8dfSAndroid Build Coastguard Worker 
7*d95af8dfSAndroid Build Coastguard Worker #define LOG_TAG "AllocatorService"
8*d95af8dfSAndroid Build Coastguard Worker 
9*d95af8dfSAndroid Build Coastguard Worker #include <hidl/LegacySupport.h>
10*d95af8dfSAndroid Build Coastguard Worker 
11*d95af8dfSAndroid Build Coastguard Worker #include "cros_gralloc/gralloc4/CrosGralloc4Allocator.h"
12*d95af8dfSAndroid Build Coastguard Worker 
13*d95af8dfSAndroid Build Coastguard Worker using android::sp;
14*d95af8dfSAndroid Build Coastguard Worker using android::hardware::configureRpcThreadpool;
15*d95af8dfSAndroid Build Coastguard Worker using android::hardware::joinRpcThreadpool;
16*d95af8dfSAndroid Build Coastguard Worker using android::hardware::graphics::mapper::V4_0::Error;
17*d95af8dfSAndroid Build Coastguard Worker 
main(int,char **)18*d95af8dfSAndroid Build Coastguard Worker int main(int, char**) {
19*d95af8dfSAndroid Build Coastguard Worker     sp<CrosGralloc4Allocator> allocator = new CrosGralloc4Allocator();
20*d95af8dfSAndroid Build Coastguard Worker     if (allocator->init() != Error::NONE) {
21*d95af8dfSAndroid Build Coastguard Worker         ALOGE("Failed to initialize IAllocator 4.0 service.");
22*d95af8dfSAndroid Build Coastguard Worker         return -EINVAL;
23*d95af8dfSAndroid Build Coastguard Worker     }
24*d95af8dfSAndroid Build Coastguard Worker 
25*d95af8dfSAndroid Build Coastguard Worker     configureRpcThreadpool(4, true /* callerWillJoin */);
26*d95af8dfSAndroid Build Coastguard Worker     if (allocator->registerAsService() != android::NO_ERROR) {
27*d95af8dfSAndroid Build Coastguard Worker         ALOGE("Failed to register graphics IAllocator 4.0 service.");
28*d95af8dfSAndroid Build Coastguard Worker         return -EINVAL;
29*d95af8dfSAndroid Build Coastguard Worker     }
30*d95af8dfSAndroid Build Coastguard Worker 
31*d95af8dfSAndroid Build Coastguard Worker     ALOGI("IAllocator 4.0 service is initialized.");
32*d95af8dfSAndroid Build Coastguard Worker     android::hardware::joinRpcThreadpool();
33*d95af8dfSAndroid Build Coastguard Worker     ALOGI("IAllocator 4.0 service is terminating.");
34*d95af8dfSAndroid Build Coastguard Worker     return 0;
35*d95af8dfSAndroid Build Coastguard Worker }
36