1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "hdi_device_interface.h" 17 #include <vector> 18 #include "display_common.h" 19 #include "drm_device.h" 20 #include "fb_device.h" 21 namespace OHOS { 22 namespace HDI { 23 namespace DISPLAY { DiscoveryDevice()24std::vector<std::shared_ptr<HdiDeviceInterface>> HdiDeviceInterface::DiscoveryDevice() 25 { 26 DISPLAY_LOGD(); 27 int ret; 28 std::vector<std::shared_ptr<HdiDeviceInterface>> devices; 29 std::shared_ptr<HdiDeviceInterface> drmDevice = DrmDevice::Create(); 30 if (drmDevice != nullptr) { 31 ret = drmDevice->Init(); 32 if (ret == DISPLAY_SUCCESS) { 33 DISPLAY_LOGD("drm device init success"); 34 devices.push_back(std::move(drmDevice)); 35 return devices; 36 } else { 37 DISPLAY_LOGE("drm device init failed"); 38 } 39 } 40 std::shared_ptr<HdiDeviceInterface> fbDevice = FbDevice::Create(); 41 if (fbDevice != nullptr) { 42 ret = fbDevice->Init(); 43 if (ret == DISPLAY_SUCCESS) { 44 DISPLAY_LOGD("fd device init success"); 45 devices.push_back(std::move(fbDevice)); 46 } else { 47 DISPLAY_LOGE("fd device init failed"); 48 } 49 } 50 return devices; 51 } 52 } 53 } 54 }