mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-13 01:40:36 +00:00
Kernel: Make Graphics device detection a bit more idomatic
This commit is contained in:
parent
e7012a9245
commit
d64d03e0d6
Notes:
sideshowbarker
2024-07-16 23:52:22 +09:00
Author: https://github.com/Hendiadyoin1 Commit: https://github.com/SerenityOS/serenity/commit/d64d03e0d6 Pull-request: https://github.com/SerenityOS/serenity/pull/21028 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/supercomputer7 ✅
2 changed files with 13 additions and 3 deletions
|
@ -93,6 +93,7 @@ static constexpr u16 msix_control_enable = 0x8000;
|
|||
|
||||
// Taken from https://pcisig.com/sites/default/files/files/PCI_Code-ID_r_1_11__v24_Jan_2019.pdf
|
||||
enum class ClassID {
|
||||
Legacy = 0x00,
|
||||
MassStorage = 0x01,
|
||||
Network = 0x02,
|
||||
Display = 0x03,
|
||||
|
@ -114,6 +115,14 @@ enum class ClassID {
|
|||
NonEssentialInstrumentation = 0x13,
|
||||
};
|
||||
|
||||
namespace Legacy {
|
||||
|
||||
enum class SubclassID {
|
||||
Any = 0x00,
|
||||
VGACompatible = 0x01
|
||||
};
|
||||
|
||||
}
|
||||
namespace MassStorage {
|
||||
|
||||
enum class SubclassID {
|
||||
|
@ -336,6 +345,7 @@ AK_TYPEDEF_DISTINCT_ORDERED_ID(u8, ClassCode);
|
|||
AK_MAKE_DISTINCT_NUMERIC_COMPARABLE_TO_ENUM(ClassCode, ClassID)
|
||||
|
||||
AK_TYPEDEF_DISTINCT_ORDERED_ID(u8, SubclassCode);
|
||||
AK_MAKE_DISTINCT_NUMERIC_COMPARABLE_TO_ENUM(SubclassCode, Legacy::SubclassID);
|
||||
AK_MAKE_DISTINCT_NUMERIC_COMPARABLE_TO_ENUM(SubclassCode, MassStorage::SubclassID);
|
||||
AK_MAKE_DISTINCT_NUMERIC_COMPARABLE_TO_ENUM(SubclassCode, Network::SubclassID);
|
||||
AK_MAKE_DISTINCT_NUMERIC_COMPARABLE_TO_ENUM(SubclassCode, Display::SubclassID);
|
||||
|
|
|
@ -110,14 +110,14 @@ static inline bool is_vga_compatible_pci_device(PCI::DeviceIdentifier const& dev
|
|||
{
|
||||
// Note: Check for Display Controller, VGA Compatible Controller or
|
||||
// Unclassified, VGA-Compatible Unclassified Device
|
||||
auto is_display_controller_vga_compatible = device_identifier.class_code().value() == 0x3 && device_identifier.subclass_code().value() == 0x0;
|
||||
auto is_general_pci_vga_compatible = device_identifier.class_code().value() == 0x0 && device_identifier.subclass_code().value() == 0x1;
|
||||
auto is_display_controller_vga_compatible = device_identifier.class_code() == PCI::ClassID::Display && device_identifier.subclass_code() == PCI::Display::SubclassID::VGA;
|
||||
auto is_general_pci_vga_compatible = device_identifier.class_code() == PCI::ClassID::Legacy && device_identifier.subclass_code() == PCI::Legacy::SubclassID::VGACompatible;
|
||||
return is_display_controller_vga_compatible || is_general_pci_vga_compatible;
|
||||
}
|
||||
|
||||
static inline bool is_display_controller_pci_device(PCI::DeviceIdentifier const& device_identifier)
|
||||
{
|
||||
return device_identifier.class_code().value() == 0x3;
|
||||
return device_identifier.class_code() == PCI::ClassID::Display;
|
||||
}
|
||||
|
||||
struct PCIGraphicsDriverInitializer {
|
||||
|
|
Loading…
Reference in a new issue