mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
Kernel: Clean up VirtIOGPU class interfaces
This commit is contained in:
parent
d9330c42fa
commit
2845c6753e
3 changed files with 26 additions and 29 deletions
|
@ -93,7 +93,7 @@ void FrameBufferDevice::transfer_framebuffer_data_to_host(Protocol::Rect const&
|
||||||
|
|
||||||
void FrameBufferDevice::flush_dirty_window(Protocol::Rect const& dirty_rect, Buffer& buffer)
|
void FrameBufferDevice::flush_dirty_window(Protocol::Rect const& dirty_rect, Buffer& buffer)
|
||||||
{
|
{
|
||||||
m_gpu.flush_dirty_window(m_scanout, dirty_rect, buffer.resource_id);
|
m_gpu.flush_dirty_rectangle(m_scanout, dirty_rect, buffer.resource_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameBufferDevice::flush_displayed_image(Protocol::Rect const& dirty_rect, Buffer& buffer)
|
void FrameBufferDevice::flush_displayed_image(Protocol::Rect const& dirty_rect, Buffer& buffer)
|
||||||
|
|
|
@ -261,10 +261,10 @@ void GPU::populate_virtio_gpu_request_header(Protocol::ControlHeader& header, Pr
|
||||||
header.padding = 0;
|
header.padding = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU::flush_dirty_window(ScanoutID scanout, Protocol::Rect const& dirty_rect, ResourceID resource_id)
|
void GPU::flush_dirty_rectangle(ScanoutID scanout_id, Protocol::Rect const& dirty_rect, ResourceID resource_id)
|
||||||
{
|
{
|
||||||
MutexLocker locker(m_operation_lock);
|
MutexLocker locker(m_operation_lock);
|
||||||
transfer_framebuffer_data_to_host(scanout, dirty_rect, resource_id);
|
transfer_framebuffer_data_to_host(scanout_id, dirty_rect, resource_id);
|
||||||
flush_displayed_image(dirty_rect, resource_id);
|
flush_displayed_image(dirty_rect, resource_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,21 +43,7 @@ public:
|
||||||
GPU(PCI::Address);
|
GPU(PCI::Address);
|
||||||
virtual ~GPU() override;
|
virtual ~GPU() override;
|
||||||
|
|
||||||
void flush_dirty_window(ScanoutID, Protocol::Rect const& dirty_rect, ResourceID);
|
|
||||||
|
|
||||||
auto& display_info(ScanoutID scanout) const
|
|
||||||
{
|
|
||||||
VERIFY(scanout.value() < VIRTIO_GPU_MAX_SCANOUTS);
|
|
||||||
return m_scanouts[scanout.value()].display_info;
|
|
||||||
}
|
|
||||||
auto& display_info(ScanoutID scanout)
|
|
||||||
{
|
|
||||||
VERIFY(scanout.value() < VIRTIO_GPU_MAX_SCANOUTS);
|
|
||||||
return m_scanouts[scanout.value()].display_info;
|
|
||||||
}
|
|
||||||
|
|
||||||
void create_framebuffer_devices();
|
void create_framebuffer_devices();
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
IterationDecision for_each_framebuffer(F f)
|
IterationDecision for_each_framebuffer(F f)
|
||||||
{
|
{
|
||||||
|
@ -77,22 +63,39 @@ public:
|
||||||
return m_scanouts[m_default_scanout.value().value()].console;
|
return m_scanouts[m_default_scanout.value().value()].console;
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
auto& display_info(ScanoutID scanout) const
|
||||||
|
{
|
||||||
|
VERIFY(scanout.value() < VIRTIO_GPU_MAX_SCANOUTS);
|
||||||
|
return m_scanouts[scanout.value()].display_info;
|
||||||
|
}
|
||||||
|
auto& display_info(ScanoutID scanout)
|
||||||
|
{
|
||||||
|
VERIFY(scanout.value() < VIRTIO_GPU_MAX_SCANOUTS);
|
||||||
|
return m_scanouts[scanout.value()].display_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
void flush_dirty_rectangle(ScanoutID, Protocol::Rect const& dirty_rect, ResourceID);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
struct Scanout {
|
||||||
|
RefPtr<FrameBufferDevice> framebuffer;
|
||||||
|
RefPtr<Console> console;
|
||||||
|
Protocol::DisplayInfoResponse::Display display_info {};
|
||||||
|
};
|
||||||
|
|
||||||
virtual bool handle_device_config_change() override;
|
virtual bool handle_device_config_change() override;
|
||||||
virtual void handle_queue_update(u16 queue_index) override;
|
virtual void handle_queue_update(u16 queue_index) override;
|
||||||
|
u32 get_pending_events();
|
||||||
|
void clear_pending_events(u32 event_bitmask);
|
||||||
|
|
||||||
auto& operation_lock() { return m_operation_lock; }
|
auto& operation_lock() { return m_operation_lock; }
|
||||||
|
ResourceID allocate_resource_id();
|
||||||
|
|
||||||
|
PhysicalAddress start_of_scratch_space() const { return m_scratch_space->physical_page(0)->paddr(); }
|
||||||
AK::BinaryBufferWriter create_scratchspace_writer()
|
AK::BinaryBufferWriter create_scratchspace_writer()
|
||||||
{
|
{
|
||||||
return { Bytes(m_scratch_space->vaddr().as_ptr(), m_scratch_space->size()) };
|
return { Bytes(m_scratch_space->vaddr().as_ptr(), m_scratch_space->size()) };
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 get_pending_events();
|
|
||||||
void clear_pending_events(u32 event_bitmask);
|
|
||||||
|
|
||||||
ResourceID allocate_resource_id();
|
|
||||||
PhysicalAddress start_of_scratch_space() const { return m_scratch_space->physical_page(0)->paddr(); }
|
|
||||||
void synchronous_virtio_gpu_command(PhysicalAddress buffer_start, size_t request_size, size_t response_size);
|
void synchronous_virtio_gpu_command(PhysicalAddress buffer_start, size_t request_size, size_t response_size);
|
||||||
void populate_virtio_gpu_request_header(Protocol::ControlHeader& header, Protocol::CommandType ctrl_type, u32 flags = 0);
|
void populate_virtio_gpu_request_header(Protocol::ControlHeader& header, Protocol::CommandType ctrl_type, u32 flags = 0);
|
||||||
|
|
||||||
|
@ -105,17 +108,11 @@ private:
|
||||||
void transfer_framebuffer_data_to_host(ScanoutID scanout, Protocol::Rect const& rect, ResourceID resource_id);
|
void transfer_framebuffer_data_to_host(ScanoutID scanout, Protocol::Rect const& rect, ResourceID resource_id);
|
||||||
void flush_displayed_image(Protocol::Rect const& dirty_rect, ResourceID resource_id);
|
void flush_displayed_image(Protocol::Rect const& dirty_rect, ResourceID resource_id);
|
||||||
|
|
||||||
struct Scanout {
|
|
||||||
RefPtr<FrameBufferDevice> framebuffer;
|
|
||||||
RefPtr<Console> console;
|
|
||||||
Protocol::DisplayInfoResponse::Display display_info {};
|
|
||||||
};
|
|
||||||
Optional<ScanoutID> m_default_scanout;
|
Optional<ScanoutID> m_default_scanout;
|
||||||
size_t m_num_scanouts { 0 };
|
size_t m_num_scanouts { 0 };
|
||||||
Scanout m_scanouts[VIRTIO_GPU_MAX_SCANOUTS];
|
Scanout m_scanouts[VIRTIO_GPU_MAX_SCANOUTS];
|
||||||
|
|
||||||
Configuration const* m_device_configuration { nullptr };
|
Configuration const* m_device_configuration { nullptr };
|
||||||
|
|
||||||
ResourceID m_resource_id_counter { 0 };
|
ResourceID m_resource_id_counter { 0 };
|
||||||
|
|
||||||
// Synchronous commands
|
// Synchronous commands
|
||||||
|
|
Loading…
Add table
Reference in a new issue