blob: 30124d708a6a3008fc0383f378b38ba724270239 [file] [log] [blame]
Sasha McIntoshf8c14112024-12-11 12:03:32 -05001/*
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 McIntoshf8c14112024-12-11 12:03:32 -050019#if HAS_LIBDISPLAY_INFO
20extern "C" {
21#include <libdisplay-info/info.h>
22}
23#endif
24
Sasha McIntoshf9062b62024-11-12 10:55:06 -050025#include <ui/GraphicTypes.h>
26
Sasha McIntosh851ea4d2024-12-04 17:14:55 -050027#include "compositor/DisplayInfo.h"
Sasha McIntoshf8c14112024-12-11 12:03:32 -050028#include "drm/DrmUnique.h"
Sasha McIntoshf8c14112024-12-11 12:03:32 -050029
30namespace android {
31
32// Stub wrapper class for edid parsing
33class EdidWrapper {
34 public:
35 EdidWrapper() = default;
36 EdidWrapper(const EdidWrapper &) = delete;
37 virtual ~EdidWrapper() = default;
Sasha McIntoshf9062b62024-11-12 10:55:06 -050038
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 McIntosh851ea4d2024-12-04 17:14:55 -050048 virtual void GetColorModes(std::vector<Colormode> &color_modes) {
49 color_modes.clear();
50 };
Sasha McIntoshf8c14112024-12-11 12:03:32 -050051};
52
53#if HAS_LIBDISPLAY_INFO
54// Wrapper class for that uses libdisplay-info to parse edids
55class LibdisplayEdidWrapper final : public EdidWrapper {
56 public:
57 LibdisplayEdidWrapper() = delete;
Sasha McIntoshf8c14112024-12-11 12:03:32 -050058 ~LibdisplayEdidWrapper() override {
59 di_info_destroy(info_);
60 }
61 static auto Create(DrmModePropertyBlobUnique blob)
Sasha McIntoshf9062b62024-11-12 10:55:06 -050062 -> std::unique_ptr<LibdisplayEdidWrapper>;
Sasha McIntoshf8c14112024-12-11 12:03:32 -050063
Sasha McIntoshf9062b62024-11-12 10:55:06 -050064 void GetSupportedHdrTypes(std::vector<ui::Hdr> &types) override;
Sasha McIntoshf8c14112024-12-11 12:03:32 -050065
Sasha McIntoshf9062b62024-11-12 10:55:06 -050066 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 McIntoshf8c14112024-12-11 12:03:32 -050070
Sasha McIntosh851ea4d2024-12-04 17:14:55 -050071 void GetColorModes(std::vector<Colormode> &color_modes) override;
72
Sasha McIntoshf8c14112024-12-11 12:03:32 -050073 private:
Sasha McIntoshf9062b62024-11-12 10:55:06 -050074 LibdisplayEdidWrapper(di_info *info) : info_(std::move(info)) {
75 }
76
Sasha McIntoshf8c14112024-12-11 12:03:32 -050077 di_info *info_{};
78};
79#endif
80
81} // namespace android