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