blob: d91ce9e309a178e774c8b39c546f53083ec22153 [file] [log] [blame]
Dennis Tsiang33f0ece2023-11-29 12:45:04 +00001/*
Drew Davenport5951b112024-08-05 09:44:27 -06002 * Copyright 2024, The Android Open Source Project
Dennis Tsiang33f0ece2023-11-29 12:45:04 +00003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Drew Davenport5951b112024-08-05 09:44:27 -060017#define LOG_TAG "drmhwc"
18#define ATRACE_TAG (ATRACE_TAG_GRAPHICS | ATRACE_TAG_HAL)
19
Dennis Tsiang33f0ece2023-11-29 12:45:04 +000020#include <android/binder_manager.h>
21#include <android/binder_process.h>
Dennis Tsiang33f0ece2023-11-29 12:45:04 +000022#include <sched.h>
23
24#include "Composer.h"
25#include "utils/log.h"
26
27using aidl::android::hardware::graphics::composer3::impl::Composer;
28
29int main(int /*argc*/, char* argv[]) {
30 (void)argv;
31 ALOGI("hwc3-drm starting up");
32
33 // same as SF main thread
34 struct sched_param param = {0};
35 param.sched_priority = 2;
36 if (sched_setscheduler(0, SCHED_FIFO | SCHED_RESET_ON_FORK, &param) != 0) {
37 ALOGE("Couldn't set SCHED_FIFO: %d", errno);
38 }
39
40 auto composer = ndk::SharedRefBase::make<Composer>();
41 if (!composer) {
42 ALOGE("Failed to create composer");
43 return -ENOMEM;
44 }
45
46 const std::string instance = std::string() + Composer::descriptor +
47 "/default";
48 ALOGI("HWC3 service name %s", instance.c_str());
49 auto status = AServiceManager_addServiceWithFlags(
50 composer->asBinder().get(), instance.c_str(),
51 AServiceManager_AddServiceFlag::ADD_SERVICE_ALLOW_ISOLATED);
52 if (status != STATUS_OK) {
53 ALOGE("Failed to register service. Error %d", (int)status);
54 return -EINVAL;
55 }
56
57 ABinderProcess_joinThreadPool();
58 return EXIT_FAILURE; // should not reach
59}