1 /* 2 * Copyright (C) 2025 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 #pragma once 18 19 #if HAS_LIBDISPLAY_INFO 20 extern "C" { 21 #include <libdisplay-info/edid.h> 22 #include <libdisplay-info/info.h> 23 } 24 #endif 25 26 #include <ui/GraphicTypes.h> 27 28 #include "compositor/DisplayInfo.h" 29 #include "drm/DrmUnique.h" 30 31 namespace android { 32 33 // Stub wrapper class for edid parsing 34 class EdidWrapper { 35 public: 36 EdidWrapper() = default; 37 EdidWrapper(const EdidWrapper &) = delete; 38 virtual ~EdidWrapper() = default; 39 GetSupportedHdrTypes(std::vector<ui::Hdr> & types)40 virtual void GetSupportedHdrTypes(std::vector<ui::Hdr> &types) { 41 types.clear(); 42 }; GetHdrCapabilities(std::vector<ui::Hdr> & types,float *,float *,float *)43 virtual void GetHdrCapabilities(std::vector<ui::Hdr> &types, 44 float * /*max_luminance*/, 45 float * /*max_average_luminance*/, 46 float * /*min_luminance*/) { 47 GetSupportedHdrTypes(types); 48 }; GetColorModes(std::vector<Colormode> & color_modes)49 virtual void GetColorModes(std::vector<Colormode> &color_modes) { 50 color_modes.clear(); 51 }; GetDpiX()52 virtual int GetDpiX() { 53 return -1; 54 } GetDpiY()55 virtual int GetDpiY() { 56 return -1; 57 } 58 59 virtual auto GetBoundsMm() -> std::pair<int32_t, int32_t> { 60 return {-1, -1}; 61 } 62 }; 63 64 #if HAS_LIBDISPLAY_INFO 65 // Wrapper class for that uses libdisplay-info to parse edids 66 class LibdisplayEdidWrapper final : public EdidWrapper { 67 public: 68 LibdisplayEdidWrapper() = delete; ~LibdisplayEdidWrapper()69 ~LibdisplayEdidWrapper() override { 70 di_info_destroy(info_); 71 } 72 static auto Create(DrmModePropertyBlobUnique blob) 73 -> std::unique_ptr<LibdisplayEdidWrapper>; 74 75 void GetSupportedHdrTypes(std::vector<ui::Hdr> &types) override; 76 77 void GetHdrCapabilities(std::vector<ui::Hdr> &types, 78 float *max_luminance, 79 float *max_average_luminance, 80 float *min_luminance) override; 81 82 void GetColorModes(std::vector<Colormode> &color_modes) override; 83 84 auto GetDpiX() -> int override; 85 auto GetDpiY() -> int override; 86 87 auto GetBoundsMm() -> std::pair<int32_t, int32_t> override; 88 89 private: LibdisplayEdidWrapper(di_info * info)90 LibdisplayEdidWrapper(di_info *info) : info_(std::move(info)) { 91 } 92 93 std::pair<int32_t, int32_t> GetDpi(); 94 95 di_info *info_{}; 96 }; 97 #endif 98 99 } // namespace android 100