blob: 867d1a025e33647687924551bb4204b8c45d7e04 [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
19#define LOG_TAG "drmhwc"
20
21#if HAS_LIBDISPLAY_INFO
22extern "C" {
23#include <libdisplay-info/info.h>
24}
25#endif
26
Sasha McIntoshf9062b62024-11-12 10:55:06 -050027#include <ui/GraphicTypes.h>
28
Sasha McIntoshf8c14112024-12-11 12:03:32 -050029#include "drm/DrmUnique.h"
30#include "utils/log.h"
31
32namespace android {
33
34// Stub wrapper class for edid parsing
35class EdidWrapper {
36 public:
37 EdidWrapper() = default;
38 EdidWrapper(const EdidWrapper &) = delete;
39 virtual ~EdidWrapper() = default;
Sasha McIntoshf9062b62024-11-12 10:55:06 -050040
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 McIntoshf8c14112024-12-11 12:03:32 -050050};
51
52#if HAS_LIBDISPLAY_INFO
53// Wrapper class for that uses libdisplay-info to parse edids
54class LibdisplayEdidWrapper final : public EdidWrapper {
55 public:
56 LibdisplayEdidWrapper() = delete;
Sasha McIntoshf8c14112024-12-11 12:03:32 -050057 ~LibdisplayEdidWrapper() override {
58 di_info_destroy(info_);
59 }
60 static auto Create(DrmModePropertyBlobUnique blob)
Sasha McIntoshf9062b62024-11-12 10:55:06 -050061 -> std::unique_ptr<LibdisplayEdidWrapper>;
Sasha McIntoshf8c14112024-12-11 12:03:32 -050062
Sasha McIntoshf9062b62024-11-12 10:55:06 -050063 void GetSupportedHdrTypes(std::vector<ui::Hdr> &types) override;
Sasha McIntoshf8c14112024-12-11 12:03:32 -050064
Sasha McIntoshf9062b62024-11-12 10:55:06 -050065 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 McIntoshf8c14112024-12-11 12:03:32 -050069
70 private:
Sasha McIntoshf9062b62024-11-12 10:55:06 -050071 LibdisplayEdidWrapper(di_info *info) : info_(std::move(info)) {
72 }
73
Sasha McIntoshf8c14112024-12-11 12:03:32 -050074 di_info *info_{};
75};
76#endif
77
78} // namespace android