/* * Copyright 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include #include #include #include #include #include #include #include #include #include "Common.h" #include "DrmMode.h" #include "DrmProperty.h" #include "EdidInfo.h" namespace aidl::android::hardware::graphics::composer3::impl { // A "cable" to the display (HDMI, DisplayPort, etc). class DrmConnector { public: static std::unique_ptr create(::android::base::borrowed_fd drmFd, uint32_t connectorId); ~DrmConnector(){}; uint32_t getId() const { return mId; } uint32_t getWidth() const; uint32_t getHeight() const; uint32_t getDpiX() const; uint32_t getDpiY() const; float getRefreshRate() const; uint32_t getRefreshRateUint() const { return (uint32_t)(getRefreshRate() + 0.5f); } bool isConnected() const { return mStatus == DRM_MODE_CONNECTED; } std::optional> getEdid() const { return mEdid; } const DrmProperty& getCrtcProperty() const { return mCrtc; } const DrmMode* getDefaultMode() const { return mModes[0].get(); } bool update(::android::base::borrowed_fd drmFd); private: DrmConnector(uint32_t id) : mId(id) {} std::optional loadEdid(::android::base::borrowed_fd drmFd); const uint32_t mId; drmModeConnection mStatus = DRM_MODE_UNKNOWNCONNECTION; std::optional mWidthMillimeters; std::optional mHeightMillimeters; std::vector> mModes; DrmProperty mCrtc; DrmProperty mEdidProp; std::optional> mEdid; static const auto& GetPropertiesMap() { static const auto* sMap = []() { return new DrmPropertyMemberMap{ {"CRTC_ID", &DrmConnector::mCrtc}, {"EDID", &DrmConnector::mEdidProp}, }; }(); return *sMap; } }; } // namespace aidl::android::hardware::graphics::composer3::impl