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