mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:37:35 +00:00
Kernel/Graphics: Bring back the mmap interface for DisplayConnectors
The mmap interface was removed when we introduced the DisplayConnector class, as it was quite unsafe to use and didn't handle switching between graphical and text modes safely. By using the SharedFramebufferVMObject, we are able to elegantly coordinate the switch by remapping the attached mmap'ed-Memory::Region(s) with different mappings, therefore, keeping WindowServer to think that the mappings it has are still valid, while they are going to a different physical range until we are back to the graphical mode (after a switch from text mode). Most drivers take advantage of the fact that we know where is the actual framebuffer in physical memory space, the SharedFramebufferVMObject is created with that information. However, the VirtIO driver is different in that aspect, because it relies on DMA transactions to show graphics on the framebuffer, so the SharedFramebufferVMObject is created with that mindset to support the arbitrary framebuffer location in physical memory space.
This commit is contained in:
parent
3d22917548
commit
e2ed6ef741
19 changed files with 309 additions and 341 deletions
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Devices/CharacterDevice.h>
|
||||
#include <Kernel/Memory/SharedFramebufferVMObject.h>
|
||||
#include <LibC/sys/ioctl_numbers.h>
|
||||
#include <LibEDID/EDID.h>
|
||||
|
||||
|
@ -99,6 +100,8 @@ public:
|
|||
|
||||
void set_display_mode(Badge<GraphicsManagement>, DisplayMode);
|
||||
|
||||
Memory::Region const& framebuffer_region() const { return *m_framebuffer_region; }
|
||||
|
||||
protected:
|
||||
void set_edid_bytes(Array<u8, 128> const& edid_bytes);
|
||||
|
||||
|
@ -112,8 +115,8 @@ protected:
|
|||
virtual ErrorOr<void> ioctl(OpenFileDescription&, unsigned request, Userspace<void*> arg) override final;
|
||||
virtual StringView class_name() const override final { return "DisplayConnector"sv; }
|
||||
|
||||
DisplayConnector();
|
||||
virtual ErrorOr<size_t> write_to_first_surface(u64 offset, UserOrKernelBuffer const&, size_t length) = 0;
|
||||
DisplayConnector(PhysicalAddress framebuffer_address, size_t framebuffer_resource_size, bool enable_write_combine_optimization);
|
||||
DisplayConnector(size_t framebuffer_resource_size, bool enable_write_combine_optimization);
|
||||
virtual void enable_console() = 0;
|
||||
virtual void disable_console() = 0;
|
||||
virtual ErrorOr<void> flush_first_surface() = 0;
|
||||
|
@ -135,10 +138,30 @@ protected:
|
|||
EDID::Parser::RawBytes m_edid_bytes {};
|
||||
bool m_edid_valid { false };
|
||||
|
||||
u8* framebuffer_data() { return m_framebuffer_data; }
|
||||
|
||||
private:
|
||||
DisplayConnector& operator=(DisplayConnector const&) = delete;
|
||||
DisplayConnector& operator=(DisplayConnector&&) = delete;
|
||||
DisplayConnector(DisplayConnector&&) = delete;
|
||||
|
||||
virtual void will_be_destroyed() override;
|
||||
virtual void after_inserting() override;
|
||||
|
||||
OwnPtr<Memory::Region> m_framebuffer_region;
|
||||
OwnPtr<Memory::Region> m_fake_writes_framebuffer_region;
|
||||
u8* m_framebuffer_data {};
|
||||
|
||||
bool const m_enable_write_combine_optimization { false };
|
||||
bool const m_framebuffer_at_arbitrary_physical_range { false };
|
||||
|
||||
protected:
|
||||
Optional<PhysicalAddress> const m_framebuffer_address;
|
||||
size_t const m_framebuffer_resource_size;
|
||||
|
||||
private:
|
||||
RefPtr<Memory::SharedFramebufferVMObject> m_shared_framebuffer_vmobject;
|
||||
|
||||
IntrusiveListNode<DisplayConnector, RefPtr<DisplayConnector>> m_list_node;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue