-
Notifications
You must be signed in to change notification settings - Fork 0
/
cta861_block.hh
62 lines (51 loc) · 2.14 KB
/
cta861_block.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright 2023 N-Nagorny
#pragma once
#include <array>
#include <memory>
#include <optional>
#include <vector>
#include "cta_data_block.hh"
#include "dtd.hh"
#include "hdmi_vendor_data_block.hh"
#define CTA861_EXT_TAG 0x02
#define CTA861_VERSION 3
namespace Edid {
#if (defined(__cplusplus) && __cplusplus >= 202002L)
template<typename T>
concept CtaDataBlockInterface = std::is_base_of_v<ICtaDataBlock, T>;
template<CtaDataBlockInterface... Ts>
using CtaDataBlockVariant = std::variant<Ts...>;
using CtaDataBlock = CtaDataBlockVariant<
#else
using CtaDataBlock = std::variant<
#endif
UnknownDataBlock,
VideoDataBlock, // [CTA-861-I] Section 7.5.1
AudioDataBlock, // [CTA-861-I] Section 7.5.2
SpeakerAllocationDataBlock, // [CTA-861-I] Section 7.5.3
YCbCr420CapabilityMapDataBlock, // [CTA-861-I] Section 7.5.11
HdmiVendorDataBlock, // [HDMI1.4b] Section 8.3.2
HdrStaticMetadataDataBlock, // [CTA-861-I] Section 7.5.13
VideoCapabilityDataBlock, // [CTA-861-I] Section 7.5.6
ColorimetryDataBlock // [CTA-861-I] Section 7.5.5
>;
using DataBlockCollection = std::vector<CtaDataBlock>;
// See CTA-861-G Section 7.5
struct Cta861Block {
bool underscan = false;
bool basic_audio = false;
bool ycbcr_444 = false;
bool ycbcr_422 = false;
DataBlockCollection data_block_collection;
std::vector<DetailedTimingDescriptor> detailed_timing_descriptors;
};
#define FIELDS(X) X.underscan, X.basic_audio, X.ycbcr_444, X.ycbcr_422, \
X.data_block_collection, X.detailed_timing_descriptors
TIED_COMPARISONS(Cta861Block, FIELDS)
#undef FIELDS
std::vector<uint8_t> generate_data_block_collection(const DataBlockCollection& collection);
std::array<uint8_t, EDID_BLOCK_SIZE> generate_cta861_block(const Cta861Block& cta861_block);
DataBlockCollection parse_data_block_collection(const std::vector<uint8_t>& collection);
Cta861Block parse_cta861_block(const std::array<uint8_t, EDID_BLOCK_SIZE>& cta861);
void print_cta861_block(std::ostream& os, const Cta861Block& cta861_block);
} // namespace Edid