mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
LibEDID: Store manufacturer id instead of allocating on each call
This also let's us use a KString instead of a string when we're in the Kernel, which opens the path for OOM-failure propagation.
This commit is contained in:
parent
4a15ed6164
commit
13f5d1c037
2 changed files with 10 additions and 10 deletions
|
@ -480,6 +480,12 @@ ErrorOr<void> Parser::parse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u16 packed_id = read_be(&raw_edid().vendor.manufacturer_id);
|
||||||
|
m_legacy_manufacturer_id[0] = (char)((u16)'A' + ((packed_id >> 10) & 0x1f) - 1);
|
||||||
|
m_legacy_manufacturer_id[1] = (char)((u16)'A' + ((packed_id >> 5) & 0x1f) - 1);
|
||||||
|
m_legacy_manufacturer_id[2] = (char)((u16)'A' + (packed_id & 0x1f) - 1);
|
||||||
|
m_legacy_manufacturer_id[3] = '\0';
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -555,16 +561,9 @@ StringView Parser::version() const
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
String Parser::legacy_manufacturer_id() const
|
StringView Parser::legacy_manufacturer_id() const
|
||||||
{
|
{
|
||||||
u16 packed_id = read_be(&raw_edid().vendor.manufacturer_id);
|
return m_legacy_manufacturer_id;
|
||||||
char id[4] = {
|
|
||||||
(char)((u16)'A' + ((packed_id >> 10) & 0x1f) - 1),
|
|
||||||
(char)((u16)'A' + ((packed_id >> 5) & 0x1f) - 1),
|
|
||||||
(char)((u16)'A' + (packed_id & 0x1f) - 1),
|
|
||||||
'\0'
|
|
||||||
};
|
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef KERNEL
|
#ifndef KERNEL
|
||||||
|
|
|
@ -88,7 +88,7 @@ public:
|
||||||
static ErrorOr<Parser> from_framebuffer_device(String const&, size_t);
|
static ErrorOr<Parser> from_framebuffer_device(String const&, size_t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
String legacy_manufacturer_id() const;
|
StringView legacy_manufacturer_id() const;
|
||||||
#ifndef KERNEL
|
#ifndef KERNEL
|
||||||
String manufacturer_name() const;
|
String manufacturer_name() const;
|
||||||
#endif
|
#endif
|
||||||
|
@ -453,6 +453,7 @@ private:
|
||||||
#else
|
#else
|
||||||
String m_version;
|
String m_version;
|
||||||
#endif
|
#endif
|
||||||
|
char m_legacy_manufacturer_id[4] {};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue