|
| 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