xref: /aosp_15_r20/frameworks/native/libs/ui/include/ui/DisplayIdentification.h (revision 38e8c45f13ce32b0dcecb25141ffecaf386fa17f)
1 /*
2  * Copyright 2018 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 <array>
20 #include <cstdint>
21 #include <optional>
22 #include <string>
23 #include <string_view>
24 #include <vector>
25 
26 #include <ui/DeviceProductInfo.h>
27 #include <ui/DisplayId.h>
28 #include <ui/Size.h>
29 
30 #define LEGACY_DISPLAY_TYPE_PRIMARY 0
31 #define LEGACY_DISPLAY_TYPE_EXTERNAL 1
32 
33 namespace android {
34 
35 using DisplayIdentificationData = std::vector<uint8_t>;
36 
37 struct DetailedTimingDescriptor {
38     ui::Size pixelSizeCount;
39     ui::Size physicalSizeInMm;
40 };
41 
42 struct DisplayIdentificationInfo {
43     PhysicalDisplayId id;
44     std::string name;
45     std::optional<DeviceProductInfo> deviceProductInfo;
46     std::optional<DetailedTimingDescriptor> preferredDetailedTimingDescriptor;
47 };
48 
49 struct ExtensionBlock {
50     uint8_t tag;
51     uint8_t revisionNumber;
52 };
53 
54 struct HdmiPhysicalAddress {
55     // The address describes the path from the display sink in the network of connected HDMI
56     // devices. The format of the address is "a.b.c.d". For example, address 2.1.0.0 means we are
57     // connected to port 1 of a device which is connected to port 2 of the sink.
58     uint8_t a, b, c, d;
59 };
60 
61 struct HdmiVendorDataBlock {
62     HdmiPhysicalAddress physicalAddress;
63 };
64 
65 struct Cea861ExtensionBlock : ExtensionBlock {
66     std::optional<HdmiVendorDataBlock> hdmiVendorDataBlock;
67 };
68 
69 struct Edid {
70     uint16_t manufacturerId;
71     uint16_t productId;
72     std::optional<uint64_t> hashedBlockZeroSerialNumberOpt;
73     std::optional<uint64_t> hashedDescriptorBlockSerialNumberOpt;
74     PnpId pnpId;
75     uint32_t modelHash;
76     std::string_view displayName;
77     uint8_t manufactureOrModelYear;
78     uint8_t manufactureWeek;
79     ui::Size physicalSizeInCm;
80     std::optional<Cea861ExtensionBlock> cea861Block;
81     std::optional<DetailedTimingDescriptor> preferredDetailedTimingDescriptor;
82 };
83 
84 bool isEdid(const DisplayIdentificationData&);
85 std::optional<Edid> parseEdid(const DisplayIdentificationData&);
86 std::optional<PnpId> getPnpId(uint16_t manufacturerId);
87 std::optional<PnpId> getPnpId(PhysicalDisplayId);
88 
89 std::optional<DisplayIdentificationInfo> parseDisplayIdentificationData(
90         uint8_t port, const DisplayIdentificationData&);
91 
92 PhysicalDisplayId getVirtualDisplayId(uint32_t id);
93 
94 } // namespace android
95