Changeset View
Changeset View
Standalone View
Standalone View
src/edid.cpp
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Line(s) | 58 | Private(const Private &other): | |||
---|---|---|---|---|---|
71 | blue(other.blue), | 71 | blue(other.blue), | ||
72 | white(other.white) | 72 | white(other.white) | ||
73 | { | 73 | { | ||
74 | } | 74 | } | ||
75 | 75 | | |||
76 | bool parse(const QByteArray &data); | 76 | bool parse(const QByteArray &data); | ||
77 | int edidGetBit(int in, int bit) const; | 77 | int edidGetBit(int in, int bit) const; | ||
78 | int edidGetBits(int in, int begin, int end) const; | 78 | int edidGetBits(int in, int begin, int end) const; | ||
79 | double edidDecodeFraction(int high, int low) const; | 79 | float edidDecodeFraction(int high, int low) const; | ||
80 | QString edidParseString(const quint8 *data) const; | 80 | QString edidParseString(const quint8 *data) const; | ||
81 | 81 | | |||
82 | bool valid; | 82 | bool valid; | ||
83 | QString monitorName; | 83 | QString monitorName; | ||
84 | QString vendorName; | 84 | QString vendorName; | ||
85 | QString serialNumber; | 85 | QString serialNumber; | ||
86 | QString eisaId; | 86 | QString eisaId; | ||
87 | QString checksum; | 87 | QString checksum; | ||
▲ Show 20 Lines • Show All 299 Lines • ▼ Show 20 Line(s) | |||||
387 | 387 | | |||
388 | int Edid::Private::edidGetBits(int in, int begin, int end) const | 388 | int Edid::Private::edidGetBits(int in, int begin, int end) const | ||
389 | { | 389 | { | ||
390 | int mask = (1 << (end - begin + 1)) - 1; | 390 | int mask = (1 << (end - begin + 1)) - 1; | ||
391 | 391 | | |||
392 | return (in >> begin) & mask; | 392 | return (in >> begin) & mask; | ||
393 | } | 393 | } | ||
394 | 394 | | |||
395 | double Edid::Private::edidDecodeFraction(int high, int low) const | 395 | float Edid::Private::edidDecodeFraction(int high, int low) const | ||
396 | { | 396 | { | ||
397 | double result = 0.0; | 397 | float result = 0.0; | ||
398 | int i; | | |||
399 | 398 | | |||
400 | high = (high << 2) | low; | 399 | high = (high << 2) | low; | ||
401 | for (i = 0; i < 10; ++i) { | 400 | for (int i = 0; i < 10; ++i) { | ||
402 | result += edidGetBit(high, i) * pow(2, i - 10); | 401 | result += edidGetBit(high, i) * pow(2, i - 10); | ||
403 | } | 402 | } | ||
404 | return result; | 403 | return result; | ||
405 | } | 404 | } | ||
406 | 405 | | |||
407 | QString Edid::Private::edidParseString(const quint8 *data) const | 406 | QString Edid::Private::edidParseString(const quint8 *data) const | ||
408 | { | 407 | { | ||
409 | /* this is always 13 bytes, but we can't guarantee it's null | 408 | /* this is always 13 bytes, but we can't guarantee it's null | ||
410 | * terminated or not junk. */ | 409 | * terminated or not junk. */ | ||
411 | auto text = QString::fromLocal8Bit(reinterpret_cast<const char*>(data), 13); | 410 | auto text = QString::fromLocal8Bit(reinterpret_cast<const char*>(data), 13); | ||
412 | 411 | | |||
413 | // Remove newlines, extra spaces and stuff | 412 | // Remove newlines, extra spaces and stuff | ||
414 | return text.simplified(); | 413 | return text.simplified(); | ||
415 | } | 414 | } |