summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2023-03-17 15:23:31 +0200
committerLinus Groh <mail@linusgroh.de>2023-03-19 00:19:06 +0000
commit3337a5722a3416639718047c172be00d332546c5 (patch)
tree53a48f7719ed2680ef7b9697c8518410db78ad32
parent657bc71247681d1e7cdd73591f87ab03163113a1 (diff)
downloadserenity-3337a5722a3416639718047c172be00d332546c5.zip
Kernel: Simplify VirtIOGPU attach_physical_range_to_framebuffer method
According to the specification, modesetting can be invoked with no need for flushing the framebuffer nor with DMA to transfer the framebuffer rendering.
-rw-r--r--Kernel/Graphics/VirtIOGPU/DisplayConnector.cpp59
-rw-r--r--Kernel/Graphics/VirtIOGPU/DisplayConnector.h2
-rw-r--r--Kernel/Graphics/VirtIOGPU/GraphicsAdapter.cpp6
3 files changed, 0 insertions, 67 deletions
diff --git a/Kernel/Graphics/VirtIOGPU/DisplayConnector.cpp b/Kernel/Graphics/VirtIOGPU/DisplayConnector.cpp
index d63d389678..0a4d32f46d 100644
--- a/Kernel/Graphics/VirtIOGPU/DisplayConnector.cpp
+++ b/Kernel/Graphics/VirtIOGPU/DisplayConnector.cpp
@@ -185,65 +185,6 @@ void VirtIODisplayConnector::clear_to_black()
}
}
-void VirtIODisplayConnector::draw_ntsc_test_pattern(Badge<VirtIOGraphicsAdapter>)
-{
- constexpr u8 colors[12][4] = {
- { 0xff, 0xff, 0xff, 0xff }, // White
- { 0x00, 0xff, 0xff, 0xff }, // Primary + Composite colors
- { 0xff, 0xff, 0x00, 0xff },
- { 0x00, 0xff, 0x00, 0xff },
- { 0xff, 0x00, 0xff, 0xff },
- { 0x00, 0x00, 0xff, 0xff },
- { 0xff, 0x00, 0x00, 0xff },
- { 0xba, 0x01, 0x5f, 0xff }, // Dark blue
- { 0x8d, 0x3d, 0x00, 0xff }, // Purple
- { 0x22, 0x22, 0x22, 0xff }, // Shades of gray
- { 0x10, 0x10, 0x10, 0xff },
- { 0x00, 0x00, 0x00, 0xff },
- };
- size_t width = m_display_info.rect.width;
- size_t height = m_display_info.rect.height;
- u8* data = framebuffer_data();
- // Draw NTSC test card
- for (size_t i = 0; i < 2; ++i) {
- for (size_t y = 0; y < height; ++y) {
- for (size_t x = 0; x < width; ++x) {
- size_t color = 0;
- if (3 * y < 2 * height) {
- // Top 2/3 of image is 7 vertical stripes of color spectrum
- color = (7 * x) / width;
- } else if (4 * y < 3 * height) {
- // 2/3 mark to 3/4 mark is backwards color spectrum alternating with black
- auto segment = (7 * x) / width;
- color = segment % 2 ? 10 : 6 - segment;
- } else {
- if (28 * x < 5 * width) {
- color = 8;
- } else if (28 * x < 10 * width) {
- color = 0;
- } else if (28 * x < 15 * width) {
- color = 7;
- } else if (28 * x < 20 * width) {
- color = 10;
- } else if (7 * x < 6 * width) {
- // Grayscale gradient
- color = 26 - ((21 * x) / width);
- } else {
- // Solid black
- color = 10;
- }
- }
- u8* pixel = &data[4 * (y * width + x)];
- for (int i = 0; i < 4; ++i) {
- pixel[i] = colors[color][i];
- }
- }
- }
- data = data + (width * height * sizeof(u32));
- }
- dbgln_if(VIRTIO_DEBUG, "Finish drawing the pattern");
-}
-
ErrorOr<void> VirtIODisplayConnector::flush_displayed_image(Graphics::VirtIOGPU::Protocol::Rect const& dirty_rect, bool main_buffer)
{
VERIFY(m_graphics_adapter->operation_lock().is_locked());
diff --git a/Kernel/Graphics/VirtIOGPU/DisplayConnector.h b/Kernel/Graphics/VirtIOGPU/DisplayConnector.h
index 3ae4591abc..a8ee840aab 100644
--- a/Kernel/Graphics/VirtIOGPU/DisplayConnector.h
+++ b/Kernel/Graphics/VirtIOGPU/DisplayConnector.h
@@ -37,8 +37,6 @@ public:
Graphics::VirtIOGPU::ScanoutID scanout_id() const { return m_scanout_id; }
Graphics::VirtIOGPU::Protocol::DisplayInfoResponse::Display display_information(Badge<VirtIOGraphicsAdapter>) const;
- void draw_ntsc_test_pattern(Badge<VirtIOGraphicsAdapter>);
-
void initialize_console(Badge<VirtIOGraphicsAdapter>);
private:
diff --git a/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.cpp b/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.cpp
index f41f30873e..aec358685f 100644
--- a/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.cpp
+++ b/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.cpp
@@ -121,12 +121,6 @@ ErrorOr<void> VirtIOGraphicsAdapter::attach_physical_range_to_framebuffer(VirtIO
TRY(ensure_backing_storage(buffer.resource_id, connector.framebuffer_region(), buffer.framebuffer_offset, framebuffer_size));
// 3. Use VIRTIO_GPU_CMD_SET_SCANOUT to link the framebuffer to a display scanout.
TRY(set_scanout_resource(connector.scanout_id(), buffer.resource_id, display_info.rect));
- // 4. Render our test pattern
- connector.draw_ntsc_test_pattern({});
- // 5. Use VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D to update the host resource from guest memory.
- TRY(transfer_framebuffer_data_to_host(connector.scanout_id(), buffer.resource_id, display_info.rect));
- // 6. Use VIRTIO_GPU_CMD_RESOURCE_FLUSH to flush the updated resource to the display.
- TRY(flush_displayed_image(buffer.resource_id, display_info.rect));
// Make sure we constrain the existing dirty rect (if any)
if (buffer.dirty_rect.width != 0 || buffer.dirty_rect.height != 0) {