From 66415cd2091ae4367cc0c06b0a584d03892138b4 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Tue, 19 Oct 2021 18:42:57 -0400 Subject: [PATCH] Remove dumb-framebuffer handling logic from the VESA driver. This reverts commit a0db7ef2729955d83f002b51034f0dedd39b4a0a. This reverts commit 40cdf7d607211c5f27854cd3048ac00e8baf20ab. This reverts commit 2ff22d6734176a2cf93a05c6842f69ef59d27a26. This reverts commit b9eacd390dbdf776561062b324dab4c6f5a0dc80. This partially reverts commit 5ae7ac5fd9957b3ff9faf211fd66976170c21b2c. This was all added in the run-up to the removal of the framebuffer driver, or was added since then to enhance framebuffer-only support in that driver. Change-Id: I32ab8199f22cf6846545ae19e943c98012b2a1d0 Reviewed-on: https://review.haiku-os.org/c/haiku/+/4615 Reviewed-by: waddlesplash --- build/jam/images/definitions/minimum | 8 ++-- src/add-ons/accelerants/vesa/accelerant.cpp | 21 ++------- src/add-ons/accelerants/vesa/mode.cpp | 46 ++----------------- .../graphics/framebuffer/framebuffer.cpp | 2 +- .../kernel/drivers/graphics/vesa/driver.cpp | 7 ++- .../kernel/drivers/graphics/vesa/vesa.cpp | 23 ++-------- 6 files changed, 25 insertions(+), 82 deletions(-) diff --git a/build/jam/images/definitions/minimum b/build/jam/images/definitions/minimum index 71053d69a8..9b102fdab1 100644 --- a/build/jam/images/definitions/minimum +++ b/build/jam/images/definitions/minimum @@ -143,7 +143,8 @@ SYSTEM_NETWORK_PROTOCOLS = ; SYSTEM_ADD_ONS_ACCELERANTS = [ FFilterByBuildFeatures - x86,x86_64,riscv64 @{ + framebuffer.accelerant + x86,x86_64 @{ vesa.accelerant }@ # x86,x86_64,riscv64 riscv64 @{ @@ -174,9 +175,10 @@ SYSTEM_ADD_ONS_DRIVERS_AUDIO = ; SYSTEM_ADD_ONS_DRIVERS_AUDIO_OLD = ; SYSTEM_ADD_ONS_DRIVERS_GRAPHICS = [ FFilterByBuildFeatures - x86,x86_64,riscv64 @{ + framebuffer + x86,x86_64 @{ vesa - }@ # x86,x86_64,riscv64 + }@ # x86,x86_64 riscv64 @{ radeon_hd }@ # riscv64 diff --git a/src/add-ons/accelerants/vesa/accelerant.cpp b/src/add-ons/accelerants/vesa/accelerant.cpp index 0597719e8c..afde7f7220 100644 --- a/src/add-ons/accelerants/vesa/accelerant.cpp +++ b/src/add-ons/accelerants/vesa/accelerant.cpp @@ -1,6 +1,5 @@ /* * Copyright 2005-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved. - * Copyright 2016-207, Jessica Hamilton, jessica.l.hamilton@gmail.com. * Distributed under the terms of the MIT License. */ @@ -67,11 +66,8 @@ init_common(int device, bool isClone) if (status < B_OK) return status; - if (gInfo->shared_info->vesa_mode_count == 0) - gInfo->vesa_modes = NULL; - else - gInfo->vesa_modes = (vesa_mode *)((uint8 *)gInfo->shared_info - + gInfo->shared_info->vesa_mode_offset); + gInfo->vesa_modes = (vesa_mode *)((uint8 *)gInfo->shared_info + + gInfo->shared_info->vesa_mode_offset); infoDeleter.Detach(); sharedDeleter.Detach(); @@ -191,16 +187,9 @@ status_t vesa_get_accelerant_device_info(accelerant_device_info *info) { info->version = B_ACCELERANT_VERSION; - - // TODO: provide some more insight here... - if (gInfo->vesa_modes != NULL) { - strcpy(info->name, "VESA driver"); - strcpy(info->chipset, "VESA"); - } else { - strcpy(info->name, "Framebuffer"); - strcpy(info->chipset, ""); - } - + strcpy(info->name, "VESA Driver"); + strcpy(info->chipset, "VESA"); + // ToDo: provide some more insight here... strcpy(info->serial_no, "None"); #if 0 diff --git a/src/add-ons/accelerants/vesa/mode.cpp b/src/add-ons/accelerants/vesa/mode.cpp index 9db0514684..8dedbcd6fa 100644 --- a/src/add-ons/accelerants/vesa/mode.cpp +++ b/src/add-ons/accelerants/vesa/mode.cpp @@ -53,16 +53,6 @@ is_mode_supported(display_mode* mode) { vesa_mode* modes = gInfo->vesa_modes; - if (modes == NULL) { - // we're a UEFI framebuffer, just confirm it's our current mode - const display_mode ¤t = gInfo->shared_info->current_mode; - return mode->virtual_width == current.virtual_width - && mode->virtual_height == current.virtual_height - && mode->h_display_start == current.h_display_start - && mode->v_display_start == current.v_display_start - && mode->space == current.space; - } - for (uint32 i = gInfo->shared_info->vesa_mode_count; i-- > 0;) { // search mode in VESA mode list // TODO: list is ordered, we could use binary search @@ -85,20 +75,12 @@ create_mode_list(void) { const color_space kVesaSpaces[] = {B_RGB32_LITTLE, B_RGB24_LITTLE, B_RGB16_LITTLE, B_RGB15_LITTLE, B_CMAP8}; - const color_space kUefiSpaces[] = { - (color_space)gInfo->shared_info->current_mode.space - }; uint32 initialModesCount = 0; - bool vesaAvailable = gInfo->vesa_modes != NULL; // Add initial VESA modes. - display_mode* initialModes = NULL; - if (vesaAvailable) { - initialModes = (display_mode*)malloc( - sizeof(display_mode) * gInfo->shared_info->vesa_mode_count); - } - + display_mode* initialModes = (display_mode*)malloc( + sizeof(display_mode) * gInfo->shared_info->vesa_mode_count); if (initialModes != NULL) { initialModesCount = gInfo->shared_info->vesa_mode_count; vesa_mode* vesaModes = gInfo->vesa_modes; @@ -109,28 +91,12 @@ create_mode_list(void) fill_display_mode(vesaModes[i].width, vesaModes[i].height, &initialModes[i]); } - } else { - // UEFI doesn't give us any VESA modes - initialModes = (display_mode*)malloc(sizeof(display_mode)); - if (initialModes != NULL) { - initialModesCount = 1; - - display_mode &mode = gInfo->shared_info->current_mode; - - compute_display_timing(mode.virtual_width, mode.virtual_height, - 60, false, &initialModes[0].timing); - fill_display_mode(mode.virtual_width, mode.virtual_height, - &initialModes[0]); - } } - const color_space *colorSpaces = vesaAvailable ? kVesaSpaces : kUefiSpaces; - size_t colorSpaceCount = vesaAvailable ? - sizeof(kVesaSpaces) / sizeof(kVesaSpaces[0]) : 1; - gInfo->mode_list_area = create_display_modes("vesa modes", gInfo->shared_info->has_edid ? &gInfo->shared_info->edid_info : NULL, - initialModes, initialModesCount, colorSpaces, colorSpaceCount, + initialModes, initialModesCount, + kVesaSpaces, sizeof(kVesaSpaces) / sizeof(kVesaSpaces[0]), is_mode_supported, &gInfo->mode_list, &gInfo->shared_info->mode_count); free(initialModes); @@ -197,10 +163,6 @@ vesa_set_display_mode(display_mode* _mode) return B_BAD_VALUE; vesa_mode* modes = gInfo->vesa_modes; - if (modes == NULL) - return B_UNSUPPORTED; - // UEFI has no VESA modes - for (uint32 i = gInfo->shared_info->vesa_mode_count; i-- > 0;) { // search mode in VESA mode list // TODO: list is ordered, we could use binary search diff --git a/src/add-ons/kernel/drivers/graphics/framebuffer/framebuffer.cpp b/src/add-ons/kernel/drivers/graphics/framebuffer/framebuffer.cpp index e732f1c5a8..4c9c5c2cab 100644 --- a/src/add-ons/kernel/drivers/graphics/framebuffer/framebuffer.cpp +++ b/src/add-ons/kernel/drivers/graphics/framebuffer/framebuffer.cpp @@ -166,7 +166,7 @@ framebuffer_init(framebuffer_info& info) info.shared_area = create_area("framebuffer shared info", (void**)&info.shared_info, B_ANY_KERNEL_ADDRESS, ROUND_TO_PAGE_SIZE(sharedSize), B_FULL_LOCK, - B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA | B_USER_CLONEABLE_AREA); + B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA | B_CLONEABLE_AREA); if (info.shared_area < 0) return info.shared_area; diff --git a/src/add-ons/kernel/drivers/graphics/vesa/driver.cpp b/src/add-ons/kernel/drivers/graphics/vesa/driver.cpp index 9babf4f23e..9e041de649 100644 --- a/src/add-ons/kernel/drivers/graphics/vesa/driver.cpp +++ b/src/add-ons/kernel/drivers/graphics/vesa/driver.cpp @@ -53,7 +53,12 @@ init_hardware(void) { TRACE((DEVICE_NAME ": init_hardware()\n")); - return get_boot_item(FRAME_BUFFER_BOOT_INFO, NULL) != NULL ? B_OK : B_ERROR; + // If we don't have the VESA mode info, then we have a + // dumb framebuffer, in which case we bail, and leave it + // up to the framebuffer driver to handle. + return (get_boot_item(VESA_MODES_BOOT_INFO, NULL) != NULL + && get_boot_item(FRAME_BUFFER_BOOT_INFO, NULL) != NULL) + ? B_OK : B_ERROR; } diff --git a/src/add-ons/kernel/drivers/graphics/vesa/vesa.cpp b/src/add-ons/kernel/drivers/graphics/vesa/vesa.cpp index b605f88ca5..e5b4cc2430 100644 --- a/src/add-ons/kernel/drivers/graphics/vesa/vesa.cpp +++ b/src/add-ons/kernel/drivers/graphics/vesa/vesa.cpp @@ -289,13 +289,7 @@ remap_frame_buffer(vesa_info& info, addr_t physicalBase, uint32 width, if (!info.complete_frame_buffer_mapped) { addr_t base = physicalBase; size_t size = bytesPerRow * height; - -#ifdef __riscv - // HACK: Prevent NULL framebuffer pointers from getting to userland - bool remap = true; -#else bool remap = !initializing; -#endif if (info.physical_frame_buffer_size != 0) { // we can map the complete frame buffer @@ -408,12 +402,10 @@ vesa_init(vesa_info& info) memcpy(&sharedInfo.edid_info, edidInfo, sizeof(edid1_info)); } - if (modes != NULL) { - vbe_get_dpms_capabilities(info.vbe_dpms_capabilities, - sharedInfo.dpms_capabilities); - if (bufferInfo->depth <= 8) - vbe_set_bits_per_gun(info, 8); - } + vbe_get_dpms_capabilities(info.vbe_dpms_capabilities, + sharedInfo.dpms_capabilities); + if (bufferInfo->depth <= 8) + vbe_set_bits_per_gun(info, 8); dprintf(DEVICE_NAME ": vesa_init() completed successfully!\n"); return B_OK; @@ -465,7 +457,6 @@ vesa_set_display_mode(vesa_info& info, uint32 mode) status = remap_frame_buffer(info, modeInfo.physical_base, modeInfo.width, modeInfo.height, modeInfo.bits_per_pixel, modeInfo.bytes_per_row, false); - if (status == B_OK) { // Update shared frame buffer information info.shared_info->current_mode.virtual_width = modeInfo.width; @@ -486,9 +477,6 @@ vesa_get_dpms_mode(vesa_info& info, uint32& mode) mode = B_DPMS_ON; // we always return a valid mode - if (info.modes == NULL) - return B_ERROR; - // Prepare BIOS environment bios_state* state; status_t status = vbe_call_prepare(&state); @@ -526,9 +514,6 @@ out: status_t vesa_set_dpms_mode(vesa_info& info, uint32 mode) { - if (info.modes == NULL) - return B_ERROR; - // Only let supported modes through mode &= info.shared_info->dpms_capabilities;