-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedid.cpp
More file actions
64 lines (54 loc) · 1.63 KB
/
edid.cpp
File metadata and controls
64 lines (54 loc) · 1.63 KB
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
63
64
#include <iostream>
#include <sstream>
#include <iomanip>
#include "edid.h"
namespace schrandr {
Edid::Edid(uint8_t *edid, size_t array_length):
array_length_(array_length)
{
if ((array_length != EDID_v1) && (array_length_ != EDID_v2)) {
std::cout << "Invalid EDID! Expected Byte-Array of length "
<< std::to_string(EDID_v1) << " or "
<< std::to_string(EDID_v2) << " but got array of length "
<< std::to_string(array_length) << std::endl;
exit(1);
}
std::ostringstream oss;
for (int i = 0; i < array_length_; i++) {
oss << std::setw(2) << std::setfill('0') << std::hex << (int) edid[i];
}
edid_ = oss.str();
}
Edid::Edid(std::string edid):
edid_(edid)
{
array_length_ = edid.size() * 2;
}
Edid::Edid()
{}
std::string Edid::to_string()const
{
return edid_;
}
void Edid::set_edid(std::string edid)
{
edid_ = edid;
array_length_ = edid.size() * 2;
}
void Edid::set_edid(uint8_t *edid, size_t array_length)
{
if (array_length != array_length_) {
std::cout << "Invalid EDID!" << std::endl;
exit(1);
}
std::ostringstream oss;
for (int i = 0; i < array_length_; i++) {
oss << std::setw(2) << std::setfill('0') << std::hex << (int) edid[i];
}
edid_ = oss.str();
}
bool Edid::isDummy()
{
return edid_.empty();
}
}