From a9538b5879e910f26f3b2ac205ad8999d762192b Mon Sep 17 00:00:00 2001 From: Liav A Date: Tue, 21 Sep 2021 09:43:06 +0300 Subject: [PATCH] Kernel/Graphics: Convert type method => bool vga compatible method We never used that type method except in initialization in GraphicsManagement, and we used it there to query whether the device is VGA compatible or not. --- Kernel/Graphics/Bochs/GraphicsAdapter.cpp | 6 ++---- Kernel/Graphics/Bochs/GraphicsAdapter.h | 3 ++- Kernel/Graphics/GraphicsDevice.h | 9 ++------- Kernel/Graphics/GraphicsManagement.cpp | 2 +- Kernel/Graphics/Intel/NativeGraphicsAdapter.h | 1 - Kernel/Graphics/VGACompatibleAdapter.h | 3 ++- Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h | 5 +++-- 7 files changed, 12 insertions(+), 17 deletions(-) diff --git a/Kernel/Graphics/Bochs/GraphicsAdapter.cpp b/Kernel/Graphics/Bochs/GraphicsAdapter.cpp index 75a63346034..479be5ba1d5 100644 --- a/Kernel/Graphics/Bochs/GraphicsAdapter.cpp +++ b/Kernel/Graphics/Bochs/GraphicsAdapter.cpp @@ -132,11 +132,9 @@ UNMAP_AFTER_INIT void BochsGraphicsAdapter::initialize_framebuffer_devices() VERIFY(!m_framebuffer_device->initialize().is_error()); } -GraphicsDevice::Type BochsGraphicsAdapter::type() const +bool BochsGraphicsAdapter::vga_compatible() const { - if (m_is_vga_capable) - return Type::VGACompatible; - return Type::Bochs; + return m_is_vga_capable; } void BochsGraphicsAdapter::unblank() diff --git a/Kernel/Graphics/Bochs/GraphicsAdapter.h b/Kernel/Graphics/Bochs/GraphicsAdapter.h index fdbf069dbbf..2f936eab390 100644 --- a/Kernel/Graphics/Bochs/GraphicsAdapter.h +++ b/Kernel/Graphics/Bochs/GraphicsAdapter.h @@ -36,13 +36,14 @@ public: virtual bool modesetting_capable() const override { return true; } virtual bool double_framebuffering_capable() const override { return true; } + virtual bool vga_compatible() const override; + private: // ^GraphicsDevice virtual bool try_to_set_resolution(size_t output_port_index, size_t width, size_t height) override; virtual bool set_y_offset(size_t output_port_index, size_t y) override; virtual void initialize_framebuffer_devices() override; - virtual Type type() const override; virtual void enable_consoles() override; virtual void disable_consoles() override; diff --git a/Kernel/Graphics/GraphicsDevice.h b/Kernel/Graphics/GraphicsDevice.h index 6928985c431..697da69a574 100644 --- a/Kernel/Graphics/GraphicsDevice.h +++ b/Kernel/Graphics/GraphicsDevice.h @@ -15,15 +15,8 @@ namespace Kernel { class GraphicsDevice : public RefCounted { public: - enum class Type { - VGACompatible, - Bochs, - SVGA, - Raw - }; virtual ~GraphicsDevice() = default; virtual void initialize_framebuffer_devices() = 0; - virtual Type type() const = 0; virtual void enable_consoles() = 0; virtual void disable_consoles() = 0; bool consoles_enabled() const { return m_consoles_enabled; } @@ -32,6 +25,8 @@ public: virtual bool modesetting_capable() const = 0; virtual bool double_framebuffering_capable() const = 0; + virtual bool vga_compatible() const = 0; + virtual bool try_to_set_resolution(size_t output_port_index, size_t width, size_t height) = 0; virtual bool set_y_offset(size_t output_port_index, size_t y) = 0; diff --git a/Kernel/Graphics/GraphicsManagement.cpp b/Kernel/Graphics/GraphicsManagement.cpp index 55f7cbca543..e1e759bcb15 100644 --- a/Kernel/Graphics/GraphicsManagement.cpp +++ b/Kernel/Graphics/GraphicsManagement.cpp @@ -133,7 +133,7 @@ UNMAP_AFTER_INIT bool GraphicsManagement::determine_and_initialize_graphics_devi // Note: If IO space is enabled, this VGA adapter is operating in VGA mode. // Note: If no other VGA adapter is attached as m_vga_adapter, we should attach it then. - if (!m_vga_adapter && PCI::is_io_space_enabled(device_identifier.address()) && adapter->type() == GraphicsDevice::Type::VGACompatible) { + if (!m_vga_adapter && PCI::is_io_space_enabled(device_identifier.address()) && adapter->vga_compatible()) { dbgln("Graphics adapter @ {} is operating in VGA mode", device_identifier.address()); m_vga_adapter = static_ptr_cast(adapter); } diff --git a/Kernel/Graphics/Intel/NativeGraphicsAdapter.h b/Kernel/Graphics/Intel/NativeGraphicsAdapter.h index f71a097bd02..8abf7ed147b 100644 --- a/Kernel/Graphics/Intel/NativeGraphicsAdapter.h +++ b/Kernel/Graphics/Intel/NativeGraphicsAdapter.h @@ -115,7 +115,6 @@ private: // ^GraphicsDevice virtual void initialize_framebuffer_devices() override; - virtual Type type() const override { return Type::VGACompatible; } bool pipe_a_enabled() const; bool pipe_b_enabled() const; diff --git a/Kernel/Graphics/VGACompatibleAdapter.h b/Kernel/Graphics/VGACompatibleAdapter.h index 523b4eb4528..4b1fbd30c9f 100644 --- a/Kernel/Graphics/VGACompatibleAdapter.h +++ b/Kernel/Graphics/VGACompatibleAdapter.h @@ -28,6 +28,8 @@ public: virtual bool modesetting_capable() const override { return false; } virtual bool double_framebuffering_capable() const override { return false; } + virtual bool vga_compatible() const override final { return true; } + virtual bool try_to_set_resolution(size_t output_port_index, size_t width, size_t height) override; virtual bool set_y_offset(size_t output_port_index, size_t y) override; @@ -39,7 +41,6 @@ private: // ^GraphicsDevice virtual void initialize_framebuffer_devices() override; - virtual Type type() const override { return Type::VGACompatible; } virtual void enable_consoles() override; virtual void disable_consoles() override; diff --git a/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h b/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h index 8ebaf78e724..69d3f35230e 100644 --- a/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h +++ b/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h @@ -22,12 +22,13 @@ public: virtual bool framebuffer_devices_initialized() const override { return m_created_framebuffer_devices; } + // FIXME: There's a VirtIO VGA GPU variant, so we should consider that + virtual bool vga_compatible() const override { return false; } + private: explicit GraphicsAdapter(PCI::DeviceIdentifier const&); virtual void initialize_framebuffer_devices() override; - virtual Type type() const override { return Type::Raw; } - virtual void enable_consoles() override; virtual void disable_consoles() override;