Changeset View
Changeset View
Standalone View
Standalone View
src/edid.cpp
Show All 12 Lines | |||||
13 | * Lesser General Public License for more details. * | 13 | * Lesser General Public License for more details. * | ||
14 | * * | 14 | * * | ||
15 | * You should have received a copy of the GNU Lesser General Public * | 15 | * You should have received a copy of the GNU Lesser General Public * | ||
16 | * License along with this library; if not, write to the Free Software * | 16 | * License along with this library; if not, write to the Free Software * | ||
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * | 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * | ||
18 | *************************************************************************************/ | 18 | *************************************************************************************/ | ||
19 | 19 | | |||
20 | #include "edid.h" | 20 | #include "edid.h" | ||
21 | #include "edid_p.h" | ||||
21 | #include "debug_p.h" | 22 | #include "debug_p.h" | ||
22 | 23 | | |||
23 | #include <math.h> | 24 | #include <math.h> | ||
24 | 25 | | |||
25 | #include <QCryptographicHash> | 26 | #include <QCryptographicHash> | ||
26 | #include <QFile> | 27 | #include <QFile> | ||
27 | #include <QStringList> | 28 | #include <QStringList> | ||
28 | #include <QStringBuilder> | 29 | #include <QStringBuilder> | ||
Show All 11 Lines | |||||
40 | #define GCM_DESCRIPTOR_COLOR_MANAGEMENT_DATA 0xf9 | 41 | #define GCM_DESCRIPTOR_COLOR_MANAGEMENT_DATA 0xf9 | ||
41 | #define GCM_DESCRIPTOR_ALPHANUMERIC_DATA_STRING 0xfe | 42 | #define GCM_DESCRIPTOR_ALPHANUMERIC_DATA_STRING 0xfe | ||
42 | #define GCM_DESCRIPTOR_COLOR_POINT 0xfb | 43 | #define GCM_DESCRIPTOR_COLOR_POINT 0xfb | ||
43 | 44 | | |||
44 | #define PNP_IDS "/usr/share/hwdata/pnp.ids" | 45 | #define PNP_IDS "/usr/share/hwdata/pnp.ids" | ||
45 | 46 | | |||
46 | using namespace KScreen; | 47 | using namespace KScreen; | ||
47 | 48 | | |||
48 | class Edid::Private | | |||
49 | { | | |||
50 | public: | | |||
51 | Private(): | | |||
52 | valid(false), | | |||
53 | width(0), | | |||
54 | height(0), | | |||
55 | gamma(0) | | |||
56 | { } | | |||
57 | | ||||
58 | Private(const Private &other): | | |||
59 | valid(other.valid), | | |||
60 | monitorName(other.monitorName), | | |||
61 | vendorName(other.vendorName), | | |||
62 | serialNumber(other.serialNumber), | | |||
63 | eisaId(other.eisaId), | | |||
64 | checksum(other.checksum), | | |||
65 | pnpId(other.pnpId), | | |||
66 | width(other.width), | | |||
67 | height(other.height), | | |||
68 | gamma(other.gamma), | | |||
69 | red(other.red), | | |||
70 | green(other.green), | | |||
71 | blue(other.blue), | | |||
72 | white(other.white) | | |||
73 | { | | |||
74 | } | | |||
75 | | ||||
76 | bool parse(const QByteArray &data); | | |||
77 | int edidGetBit(int in, int bit) const; | | |||
78 | int edidGetBits(int in, int begin, int end) const; | | |||
79 | double edidDecodeFraction(int high, int low) const; | | |||
80 | QString edidParseString(const quint8 *data) const; | | |||
81 | | ||||
82 | bool valid; | | |||
83 | QString monitorName; | | |||
84 | QString vendorName; | | |||
85 | QString serialNumber; | | |||
86 | QString eisaId; | | |||
87 | QString checksum; | | |||
88 | QString pnpId; | | |||
89 | uint width; | | |||
90 | uint height; | | |||
91 | qreal gamma; | | |||
92 | QQuaternion red; | | |||
93 | QQuaternion green; | | |||
94 | QQuaternion blue; | | |||
95 | QQuaternion white; | | |||
96 | }; | | |||
97 | | ||||
98 | | ||||
99 | Edid::Edid() | 49 | Edid::Edid() | ||
100 | : QObject() | 50 | : QObject() | ||
101 | , d(new Private()) | 51 | , d(new Private()) | ||
102 | { | 52 | { | ||
103 | } | 53 | } | ||
104 | 54 | | |||
105 | Edid::Edid(const QByteArray &data, QObject *parent) | 55 | Edid::Edid(const QByteArray &data, QObject *parent) | ||
106 | : QObject(parent) | 56 | : QObject(parent) | ||
Show All 22 Lines | |||||
129 | { | 79 | { | ||
130 | return d->valid; | 80 | return d->valid; | ||
131 | } | 81 | } | ||
132 | 82 | | |||
133 | QString Edid::deviceId(const QString &fallbackName) const | 83 | QString Edid::deviceId(const QString &fallbackName) const | ||
134 | { | 84 | { | ||
135 | QString id = QLatin1String("xrandr"); | 85 | QString id = QLatin1String("xrandr"); | ||
136 | // if no info was added check if the fallbacName is provided | 86 | // if no info was added check if the fallbacName is provided | ||
137 | if (vendor().isNull() && name().isNull() && serial().isNull()) { | 87 | if (vendor().isEmpty() && name().isEmpty() && serial().isEmpty()) { | ||
138 | if (!fallbackName.isEmpty()) { | 88 | if (!fallbackName.isEmpty()) { | ||
139 | id.append(QLatin1Char('-') % fallbackName); | 89 | id.append(QLatin1Char('-') % fallbackName); | ||
140 | } else { | 90 | } else { | ||
141 | // all info we have are empty strings | 91 | // all info we have are empty strings | ||
142 | id.append(QLatin1String("-unknown")); | 92 | id.append(QLatin1String("-unknown")); | ||
143 | } | 93 | } | ||
144 | } else if (d->valid) { | 94 | } else if (d->valid) { | ||
145 | if (!vendor().isNull()) { | 95 | if (!vendor().isEmpty()) { | ||
146 | id.append(QLatin1Char('-') % vendor()); | 96 | id.append(QLatin1Char('-') % vendor()); | ||
147 | } | 97 | } | ||
148 | if (!name().isNull()) { | 98 | if (!name().isEmpty()) { | ||
149 | id.append(QLatin1Char('-') % name()); | 99 | id.append(QLatin1Char('-') % name()); | ||
150 | } | 100 | } | ||
151 | if (!serial().isNull()) { | 101 | if (!serial().isEmpty()) { | ||
152 | id.append(QLatin1Char('-') % serial()); | 102 | id.append(QLatin1Char('-') % serial()); | ||
153 | } | 103 | } | ||
154 | } | 104 | } | ||
155 | 105 | | |||
156 | return id; | 106 | return id; | ||
157 | } | 107 | } | ||
158 | 108 | | |||
159 | QString Edid::name() const | 109 | QString Edid::name() const | ||
▲ Show 20 Lines • Show All 260 Lines • Show Last 20 Lines |