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 "isp_manager.h" 17 18 namespace OHOS::Camera { IspManager()19IspManager::IspManager() {} 20 IspManager(ManagerId managerId)21IspManager::IspManager(ManagerId managerId) : IManager(managerId) {} 22 ~IspManager()23IspManager::~IspManager() {} 24 CreateController(ControllerId controllerId,std::string hardwareName)25RetCode IspManager::CreateController(ControllerId controllerId, std::string hardwareName) 26 { 27 RetCode rc = RC_OK; 28 if (controllerId == DM_C_ISP) { 29 if (!CheckCameraIdList(hardwareName)) { 30 std::shared_ptr<IspController> isp = std::make_shared<IspController>(hardwareName); 31 if (isp == nullptr) { 32 return RC_ERROR; 33 } 34 rc = isp->Init(); 35 if (rc == RC_OK) { 36 ispList_.push_back(isp); 37 } 38 } 39 } 40 return rc; 41 } 42 GetController(ControllerId controllerId,std::string hardwareName)43std::shared_ptr<IController> IspManager::GetController(ControllerId controllerId, std::string hardwareName) 44 { 45 (void)controllerId; 46 if (ispList_.size() == 0) { 47 return nullptr; 48 } 49 for (auto iter = ispList_.cbegin(); iter != ispList_.cend(); iter++) { 50 if ((*iter)->GetName() == hardwareName) { 51 return *iter; 52 } 53 } 54 return nullptr; 55 } 56 PowerUp(std::string hardwareName)57RetCode IspManager::PowerUp(std::string hardwareName) 58 { 59 for (auto iter = ispList_.cbegin(); iter != ispList_.cend(); iter++) { 60 if ((*iter)->GetName() == hardwareName) { 61 return (*iter)->PowerUp(); 62 } 63 } 64 return RC_ERROR; 65 } 66 PowerDown(std::string hardwareName)67RetCode IspManager::PowerDown(std::string hardwareName) 68 { 69 for (auto iter = ispList_.cbegin(); iter != ispList_.cend(); iter++) { 70 if ((*iter)->GetName() == hardwareName) { 71 return (*iter)->PowerDown(); 72 } 73 } 74 return RC_ERROR; 75 } 76 Configure(std::shared_ptr<CameraMetadata> meta)77void IspManager::Configure(std::shared_ptr<CameraMetadata> meta) 78 { 79 if (ispList_.size() == 0) { 80 return; 81 } 82 for (auto iter = ispList_.cbegin(); iter != ispList_.cend(); iter++) { 83 (*iter)->Configure(meta); 84 } 85 } 86 Start(std::string hardwareName)87RetCode IspManager::Start(std::string hardwareName) 88 { 89 for (auto iter = ispList_.cbegin(); iter != ispList_.cend(); iter++) { 90 if ((*iter)->GetName() == hardwareName) { 91 return (*iter)->Start(); 92 } 93 } 94 return RC_ERROR; 95 } 96 Stop(std::string hardwareName)97RetCode IspManager::Stop(std::string hardwareName) 98 { 99 for (auto iter = ispList_.cbegin(); iter != ispList_.cend(); iter++) { 100 if ((*iter)->GetName() == hardwareName) { 101 return (*iter)->Stop(); 102 } 103 } 104 return RC_ERROR; 105 } 106 CheckCameraIdList(std::string hardwareName)107bool IspManager::CheckCameraIdList(std::string hardwareName) 108 { 109 if (ispList_.size() == 0) { 110 return false; 111 } 112 for (auto iter = ispList_.cbegin(); iter != ispList_.cend(); iter++) { 113 if ((*iter)->GetName() == hardwareName) { 114 return true; 115 } 116 } 117 return false; 118 } 119 } // namespace OHOS::Camera