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.
This commit is contained in:
Liav A 2021-09-21 09:43:06 +03:00 committed by Idan Horowitz
parent fb0ed2ae46
commit a9538b5879
Notes: sideshowbarker 2024-07-18 01:51:24 +09:00
7 changed files with 12 additions and 17 deletions

View file

@ -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()

View file

@ -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;

View file

@ -15,15 +15,8 @@
namespace Kernel {
class GraphicsDevice : public RefCounted<GraphicsDevice> {
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;

View file

@ -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<VGACompatibleAdapter>(adapter);
}

View file

@ -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;

View file

@ -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;

View file

@ -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;