| Dennis Tsiang | 33f0ece | 2023-11-29 12:45:04 +0000 | [diff] [blame] | 1 | /* | 
| Drew Davenport | 5951b11 | 2024-08-05 09:44:27 -0600 | [diff] [blame] | 2 | * Copyright 2024, The Android Open Source Project | 
| Dennis Tsiang | 33f0ece | 2023-11-29 12:45:04 +0000 | [diff] [blame] | 3 | * | 
|  | 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 Davenport | 5951b11 | 2024-08-05 09:44:27 -0600 | [diff] [blame] | 17 | #define LOG_TAG "drmhwc" | 
|  | 18 | #define ATRACE_TAG (ATRACE_TAG_GRAPHICS | ATRACE_TAG_HAL) | 
|  | 19 |  | 
| Dennis Tsiang | 33f0ece | 2023-11-29 12:45:04 +0000 | [diff] [blame] | 20 | #include <android/binder_manager.h> | 
|  | 21 | #include <android/binder_process.h> | 
|  | 22 | #include <binder/ProcessState.h> | 
|  | 23 | #include <sched.h> | 
|  | 24 |  | 
|  | 25 | #include "Composer.h" | 
|  | 26 | #include "utils/log.h" | 
|  | 27 |  | 
|  | 28 | using aidl::android::hardware::graphics::composer3::impl::Composer; | 
|  | 29 |  | 
|  | 30 | int main(int /*argc*/, char* argv[]) { | 
|  | 31 | (void)argv; | 
|  | 32 | ALOGI("hwc3-drm starting up"); | 
|  | 33 |  | 
|  | 34 | // same as SF main thread | 
|  | 35 | struct sched_param param = {0}; | 
|  | 36 | param.sched_priority = 2; | 
|  | 37 | if (sched_setscheduler(0, SCHED_FIFO | SCHED_RESET_ON_FORK, ¶m) != 0) { | 
|  | 38 | ALOGE("Couldn't set SCHED_FIFO: %d", errno); | 
|  | 39 | } | 
|  | 40 |  | 
|  | 41 | auto composer = ndk::SharedRefBase::make<Composer>(); | 
|  | 42 | if (!composer) { | 
|  | 43 | ALOGE("Failed to create composer"); | 
|  | 44 | return -ENOMEM; | 
|  | 45 | } | 
|  | 46 |  | 
|  | 47 | const std::string instance = std::string() + Composer::descriptor + | 
|  | 48 | "/default"; | 
|  | 49 | ALOGI("HWC3 service name %s", instance.c_str()); | 
|  | 50 | auto status = AServiceManager_addServiceWithFlags( | 
|  | 51 | composer->asBinder().get(), instance.c_str(), | 
|  | 52 | AServiceManager_AddServiceFlag::ADD_SERVICE_ALLOW_ISOLATED); | 
|  | 53 | if (status != STATUS_OK) { | 
|  | 54 | ALOGE("Failed to register service. Error %d", (int)status); | 
|  | 55 | return -EINVAL; | 
|  | 56 | } | 
|  | 57 |  | 
|  | 58 | ABinderProcess_joinThreadPool(); | 
|  | 59 | return EXIT_FAILURE;  // should not reach | 
|  | 60 | } |