Skip to content

Commit e3cc6b3

Browse files
committed
enable h3c hdr
Tracked-On: OAM-134123 Change-Id: I5be22c0c6c846607fc128f51becee16a41bcbecc Signed-off-by: Kanli Hu <kanli.hu@intel.com>
1 parent 5d0f38d commit e3cc6b3

File tree

4 files changed

+212
-3
lines changed

4 files changed

+212
-3
lines changed

Android.bp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ filegroup {
102102
"hwc2_device/hwc2_device.cpp",
103103

104104
"utils/LibdisplayEdidWrapper.cpp",
105+
"utils/H3CdisplayEdidWrapper.cpp",
105106
"utils/fd.cpp",
106107
"utils/properties.cpp",
107108
"utils/intel_blit.cpp",

drm/DrmConnector.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "DrmDevice.h"
3131
#include "compositor/DisplayInfo.h"
3232
#include "utils/log.h"
33+
#include "utils/EdidWrapperH3C.h"
3334

3435
#ifndef DRM_MODE_CONNECTOR_SPI
3536
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
@@ -85,10 +86,16 @@ auto DrmConnector::CreateInstance(DrmDevice &dev, uint32_t connector_id,
8586
void DrmConnector::UpdateEdidWrapper() {
8687
UpdateEdidProperty();
8788
#if HAS_LIBDISPLAY_INFO
88-
auto edid = LibdisplayEdidWrapper::Create(GetEdidBlob());
89-
edid_wrapper_ = edid ? std::move(edid) : std::make_unique<EdidWrapper>();
89+
auto edid = H3CdisplayEdidWrapper::Create(GetEdidBlob());
90+
if (edid) {
91+
edid_wrapper_ = edid ? std::move(edid) : std::make_unique<EdidWrapper>();
92+
} else {
93+
auto edid_new = LibdisplayEdidWrapper::Create(GetEdidBlob());
94+
edid_wrapper_ = edid_new ? std::move(edid_new) : std::make_unique<EdidWrapper>();
95+
}
9096
#else
91-
edid_wrapper_ = std::make_unique<EdidWrapper>();
97+
auto edid = H3CdisplayEdidWrapper::Create(GetEdidBlob());
98+
edid_wrapper_ = edid ? std::move(edid) : std::make_unique<EdidWrapper>();
9299
#endif
93100
}
94101

utils/EdidWrapperH3C.h

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
#include <ui/GraphicTypes.h>
20+
#include <ui/ColorSpace.h>
21+
22+
#include "EdidWrapper.h"
23+
24+
namespace android {
25+
26+
// Wrapper class for that uses hack H3Cdisplay-info to parse edids
27+
class H3CdisplayEdidWrapper final : public EdidWrapper {
28+
public:
29+
H3CdisplayEdidWrapper() = delete;
30+
~H3CdisplayEdidWrapper() override {
31+
}
32+
static auto Create(DrmModePropertyBlobUnique blob)
33+
-> std::unique_ptr<H3CdisplayEdidWrapper>;
34+
35+
void GetSupportedHdrTypes(std::vector<ui::Hdr> &types) override;
36+
37+
void GetHdrCapabilities(std::vector<ui::Hdr> &types,
38+
float *max_luminance,
39+
float *max_average_luminance,
40+
float *min_luminance) override;
41+
42+
void GetColorModes(std::vector<Colormode> &color_modes) override;
43+
44+
auto GetDpiX() -> int override;
45+
auto GetDpiY() -> int override;
46+
47+
auto GetBoundsMm() -> std::pair<int32_t, int32_t> override;
48+
49+
void GetColorGamut(
50+
std::array<float2, 3> &primaries, float2 &whitepoint) override;
51+
52+
private:
53+
H3CdisplayEdidWrapper(void *date, size_t length);
54+
55+
std::pair<int32_t, int32_t> GetDpi();
56+
57+
static constexpr int32_t kWidthPixels = 2880;
58+
static constexpr int32_t kHeightPixels = 1800;
59+
static constexpr int32_t kWidthMm = 301;
60+
static constexpr int32_t kHeightMm = 189;
61+
static constexpr float kMaxLuminance = 507.5f;
62+
static constexpr float kMaxAvgLuminance = 507.5f;
63+
static constexpr float kMinLuminance = 0.004f;
64+
};
65+
66+
} // namespace android

utils/H3CdisplayEdidWrapper.cpp

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
/*
2+
* Copyright (C) 2024 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+
#include <cstddef>
18+
#define LOG_TAG "drmhwc"
19+
20+
#include "utils/EdidWrapper.h"
21+
#include "utils/EdidWrapperH3C.h"
22+
#include "utils/log.h"
23+
24+
namespace android {
25+
auto H3CdisplayEdidWrapper::Create(DrmModePropertyBlobUnique blob)
26+
-> std::unique_ptr<H3CdisplayEdidWrapper> {
27+
if (!blob)
28+
return nullptr;
29+
30+
void *data = blob->data;
31+
uint32_t length = blob->length;
32+
if (length < 256) {
33+
return nullptr;
34+
}
35+
36+
uint8_t *cta_ext_blk = static_cast<uint8_t *>(data) + 0x80;
37+
38+
if (cta_ext_blk[0x00] == 0x70
39+
&& cta_ext_blk[0x01] == 0x20
40+
&& cta_ext_blk[0x08] == 0x94
41+
&& cta_ext_blk[0x09] == 0x0b
42+
&& cta_ext_blk[0x0a] == 0xd5) {
43+
ALOGI("kanli create H3C edid wrapper");
44+
return std::unique_ptr<H3CdisplayEdidWrapper>(
45+
new H3CdisplayEdidWrapper(data, length));
46+
}
47+
48+
return nullptr;
49+
}
50+
51+
void H3CdisplayEdidWrapper::GetSupportedHdrTypes(std::vector<ui::Hdr> &types) {
52+
types.clear();
53+
types.emplace_back(ui::Hdr::HDR10);
54+
//types.emplace_back(ui::Hdr::HLG);
55+
//types.emplace_back(ui::Hdr::HDR10_PLUS);
56+
}
57+
58+
void H3CdisplayEdidWrapper::GetHdrCapabilities(
59+
std::vector<ui::Hdr> &types,
60+
float *max_luminance,
61+
float *max_average_luminance,
62+
float *min_luminance) {
63+
GetSupportedHdrTypes(types);
64+
65+
*max_luminance = kMaxLuminance;
66+
*max_average_luminance = kMaxAvgLuminance;
67+
*min_luminance = kMinLuminance;
68+
}
69+
70+
void H3CdisplayEdidWrapper::GetColorModes(std::vector<Colormode> &color_modes) {
71+
color_modes.clear();
72+
color_modes.emplace_back(Colormode::kNative);
73+
//color_modes.emplace_back(Colormode::kSrgb);
74+
//color_modes.emplace_back(Colormode::kDisplayP3);
75+
color_modes.emplace_back(Colormode::kDisplayBt2020);
76+
}
77+
78+
auto H3CdisplayEdidWrapper::GetDpiX() -> int {
79+
return GetDpi().first;
80+
}
81+
82+
auto H3CdisplayEdidWrapper::GetDpiY() -> int {
83+
return GetDpi().second;
84+
}
85+
86+
auto H3CdisplayEdidWrapper::GetBoundsMm() -> std::pair<int32_t, int32_t> {
87+
return {kWidthMm, kHeightMm};
88+
}
89+
90+
auto H3CdisplayEdidWrapper::GetDpi() -> std::pair<int32_t, int32_t> {
91+
int32_t kUmPerInch = 25400;
92+
return {kWidthPixels * kUmPerInch / (kWidthMm * 1000),
93+
kHeightPixels * kUmPerInch / (kHeightMm * 1000)};
94+
}
95+
96+
void H3CdisplayEdidWrapper::GetColorGamut(
97+
std::array<float2, 3> &primaries, float2 &whitepoint) {
98+
int sdr_config = 0;
99+
if (sdr_config) {
100+
primaries[0].x = 0.640;
101+
primaries[0].y = 0.330;
102+
primaries[1].x = 0.300;
103+
primaries[1].y = 0.600;
104+
primaries[2].x = 0.150;
105+
primaries[2].y = 0.060;
106+
107+
whitepoint.x = 0.313;
108+
whitepoint.y = 0.329;
109+
} else {
110+
primaries[0].x = 0.684;
111+
primaries[0].y = 0.316;
112+
primaries[1].x = 0.245;
113+
primaries[1].y = 0.730;
114+
primaries[2].x = 0.139;
115+
primaries[2].y = 0.042;
116+
117+
whitepoint.x = 0.313;
118+
whitepoint.y = 0.329;
119+
}
120+
121+
ALOGI("print ColorGamut:");
122+
ALOGI(" red %f %f" ,primaries[0].x, primaries[0].y);
123+
ALOGI(" grean %f %f" ,primaries[1].x, primaries[1].y);
124+
ALOGI(" blue %f %f" ,primaries[2].x, primaries[2].y);
125+
ALOGI(" write %f %f" ,whitepoint.x, whitepoint.y);
126+
127+
128+
return;
129+
}
130+
131+
132+
H3CdisplayEdidWrapper::H3CdisplayEdidWrapper(void *date, size_t length) {
133+
134+
}
135+
} // namespace android

0 commit comments

Comments
 (0)