Sasha McIntosh | f8c1411 | 2024-12-11 12:03:32 -0500 | [diff] [blame] | 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 | |
Sasha McIntosh | f8c1411 | 2024-12-11 12:03:32 -0500 | [diff] [blame] | 19 | #if HAS_LIBDISPLAY_INFO |
| 20 | extern "C" { |
| 21 | #include <libdisplay-info/info.h> |
| 22 | } |
| 23 | #endif |
| 24 | |
Sasha McIntosh | f9062b6 | 2024-11-12 10:55:06 -0500 | [diff] [blame] | 25 | #include <ui/GraphicTypes.h> |
| 26 | |
Sasha McIntosh | 851ea4d | 2024-12-04 17:14:55 -0500 | [diff] [blame] | 27 | #include "compositor/DisplayInfo.h" |
Sasha McIntosh | f8c1411 | 2024-12-11 12:03:32 -0500 | [diff] [blame] | 28 | #include "drm/DrmUnique.h" |
Sasha McIntosh | f8c1411 | 2024-12-11 12:03:32 -0500 | [diff] [blame] | 29 | |
| 30 | namespace android { |
| 31 | |
| 32 | // Stub wrapper class for edid parsing |
| 33 | class EdidWrapper { |
| 34 | public: |
| 35 | EdidWrapper() = default; |
| 36 | EdidWrapper(const EdidWrapper &) = delete; |
| 37 | virtual ~EdidWrapper() = default; |
Sasha McIntosh | f9062b6 | 2024-11-12 10:55:06 -0500 | [diff] [blame] | 38 | |
| 39 | virtual void GetSupportedHdrTypes(std::vector<ui::Hdr> &types) { |
| 40 | types.clear(); |
| 41 | }; |
| 42 | virtual void GetHdrCapabilities(std::vector<ui::Hdr> &types, |
| 43 | const float * /*max_luminance*/, |
| 44 | const float * /*max_average_luminance*/, |
| 45 | const float * /*min_luminance*/) { |
| 46 | GetSupportedHdrTypes(types); |
| 47 | }; |
Sasha McIntosh | 851ea4d | 2024-12-04 17:14:55 -0500 | [diff] [blame] | 48 | virtual void GetColorModes(std::vector<Colormode> &color_modes) { |
| 49 | color_modes.clear(); |
| 50 | }; |
Sasha McIntosh | f8c1411 | 2024-12-11 12:03:32 -0500 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | #if HAS_LIBDISPLAY_INFO |
| 54 | // Wrapper class for that uses libdisplay-info to parse edids |
| 55 | class LibdisplayEdidWrapper final : public EdidWrapper { |
| 56 | public: |
| 57 | LibdisplayEdidWrapper() = delete; |
Sasha McIntosh | f8c1411 | 2024-12-11 12:03:32 -0500 | [diff] [blame] | 58 | ~LibdisplayEdidWrapper() override { |
| 59 | di_info_destroy(info_); |
| 60 | } |
| 61 | static auto Create(DrmModePropertyBlobUnique blob) |
Sasha McIntosh | f9062b6 | 2024-11-12 10:55:06 -0500 | [diff] [blame] | 62 | -> std::unique_ptr<LibdisplayEdidWrapper>; |
Sasha McIntosh | f8c1411 | 2024-12-11 12:03:32 -0500 | [diff] [blame] | 63 | |
Sasha McIntosh | f9062b6 | 2024-11-12 10:55:06 -0500 | [diff] [blame] | 64 | void GetSupportedHdrTypes(std::vector<ui::Hdr> &types) override; |
Sasha McIntosh | f8c1411 | 2024-12-11 12:03:32 -0500 | [diff] [blame] | 65 | |
Sasha McIntosh | f9062b6 | 2024-11-12 10:55:06 -0500 | [diff] [blame] | 66 | void GetHdrCapabilities(std::vector<ui::Hdr> &types, |
| 67 | const float *max_luminance, |
| 68 | const float *max_average_luminance, |
| 69 | const float *min_luminance) override; |
Sasha McIntosh | f8c1411 | 2024-12-11 12:03:32 -0500 | [diff] [blame] | 70 | |
Sasha McIntosh | 851ea4d | 2024-12-04 17:14:55 -0500 | [diff] [blame] | 71 | void GetColorModes(std::vector<Colormode> &color_modes) override; |
| 72 | |
Sasha McIntosh | f8c1411 | 2024-12-11 12:03:32 -0500 | [diff] [blame] | 73 | private: |
Sasha McIntosh | f9062b6 | 2024-11-12 10:55:06 -0500 | [diff] [blame] | 74 | LibdisplayEdidWrapper(di_info *info) : info_(std::move(info)) { |
| 75 | } |
| 76 | |
Sasha McIntosh | f8c1411 | 2024-12-11 12:03:32 -0500 | [diff] [blame] | 77 | di_info *info_{}; |
| 78 | }; |
| 79 | #endif |
| 80 | |
| 81 | } // namespace android |