Quellcode durchsuchen

Kernel/Graphics: Ensure we set BGR format of bochs-display if supported

Instead of blindly forcing BGR format on the bochs-display device, let's
ensure we do that only on QEMU bochs-display and not on VirtualBox
graphics adapter too.
Liav A vor 3 Jahren
Ursprung
Commit
38bddca378

+ 13 - 1
Kernel/Graphics/Bochs/GraphicsAdapter.cpp

@@ -19,6 +19,8 @@
 #define VBE_DISPI_IOPORT_INDEX 0x01CE
 #define VBE_DISPI_IOPORT_DATA 0x01CF
 
+#define VBE_DISPI_ID5 0xB0C5
+
 #define VBE_DISPI_INDEX_ID 0x0
 #define VBE_DISPI_INDEX_XRES 0x1
 #define VBE_DISPI_INDEX_YRES 0x2
@@ -156,6 +158,14 @@ static u16 get_register_with_io(u16 index)
     return IO::in16(VBE_DISPI_IOPORT_DATA);
 }
 
+BochsGraphicsAdapter::IndexID BochsGraphicsAdapter::index_id() const
+{
+    if (m_io_required) {
+        return get_register_with_io(0);
+    }
+    return m_registers->bochs_regs.index_id;
+}
+
 void BochsGraphicsAdapter::set_resolution_registers_via_io(size_t width, size_t height)
 {
     dbgln_if(BXVGA_DEBUG, "BochsGraphicsAdapter resolution registers set to - {}x{}", width, height);
@@ -184,7 +194,9 @@ void BochsGraphicsAdapter::set_resolution_registers(size_t width, size_t height)
     m_registers->bochs_regs.enable = VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED;
     full_memory_barrier();
     m_registers->bochs_regs.bank = 0;
-    set_framebuffer_to_little_endian_format();
+    if (index_id().value() == VBE_DISPI_ID5) {
+        set_framebuffer_to_little_endian_format();
+    }
 }
 
 bool BochsGraphicsAdapter::try_to_set_resolution(size_t output_port_index, size_t width, size_t height)

+ 5 - 0
Kernel/Graphics/Bochs/GraphicsAdapter.h

@@ -25,6 +25,9 @@ class BochsGraphicsAdapter final : public GraphicsDevice
     AK_MAKE_ETERNAL
     friend class GraphicsManagement;
 
+private:
+    TYPEDEF_DISTINCT_ORDERED_ID(u16, IndexID);
+
 public:
     static NonnullRefPtr<BochsGraphicsAdapter> initialize(PCI::Address);
     virtual ~BochsGraphicsAdapter() = default;
@@ -46,6 +49,8 @@ private:
 
     explicit BochsGraphicsAdapter(PCI::Address);
 
+    IndexID index_id() const;
+
     void set_safe_resolution();
     void unblank();