Home | History | Annotate | Download | only in default
      1 /*
      2  * Copyright 2018 The Android Open Source Project
      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 
     17 #include <sched.h>
     18 
     19 #include <android/hardware/graphics/composer/2.2/IComposer.h>
     20 #include <binder/ProcessState.h>
     21 #include <composer-passthrough/2.2/HwcLoader.h>
     22 #include <hidl/HidlTransportSupport.h>
     23 
     24 using android::hardware::graphics::composer::V2_2::IComposer;
     25 using android::hardware::graphics::composer::V2_2::passthrough::HwcLoader;
     26 
     27 int main() {
     28     // the conventional HAL might start binder services
     29     android::ProcessState::initWithDriver("/dev/vndbinder");
     30     android::ProcessState::self()->setThreadPoolMaxThreadCount(4);
     31     android::ProcessState::self()->startThreadPool();
     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     android::hardware::configureRpcThreadpool(4, true /* will join */);
     41 
     42     android::sp<IComposer> composer = HwcLoader::load();
     43     if (composer == nullptr) {
     44         return 1;
     45     }
     46     if (composer->registerAsService() != android::NO_ERROR) {
     47         ALOGE("failed to register service");
     48         return 1;
     49     }
     50 
     51     android::hardware::joinRpcThreadpool();
     52 
     53     ALOGE("service is terminating");
     54     return 1;
     55 }
     56