2021-03-05 09:23:08 -03:00
|
|
|
/*
|
2022-01-21 11:15:46 -03:00
|
|
|
* Copyright (c) 2021-2022, Liav A. <liavalb@hotmail.co.il>
|
2021-03-05 09:23:08 -03:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2021-04-16 16:58:51 -03:00
|
|
|
#include <AK/NonnullOwnPtr.h>
|
2022-09-23 05:06:14 -03:00
|
|
|
#include <AK/Platform.h>
|
2021-03-05 09:23:08 -03:00
|
|
|
#include <AK/Types.h>
|
2022-09-23 05:06:14 -03:00
|
|
|
#if ARCH(I386) || ARCH(X86_64)
|
|
|
|
|
# include <Kernel/Arch/x86/VGA/IOArbiter.h>
|
|
|
|
|
#endif
|
2021-06-25 03:46:17 -03:00
|
|
|
#include <Kernel/Bus/PCI/Definitions.h>
|
2021-04-16 16:58:51 -03:00
|
|
|
#include <Kernel/Graphics/Console/Console.h>
|
Kernel/Graphics: Introduce the DisplayConnector class
The DisplayConnector class is meant to replace the FramebufferDevice
class. The advantage of this class over the FramebufferDevice class is:
1. It removes the mmap interface entirely. This interface is unsafe, as
multiple processes could try to use it, and when switching to and from
text console mode, there's no "good" way to revoke a memory mapping from
this interface, let alone when there are multiple processes that call
this interface. Therefore, in the DisplayConnector class there's no
implementation for this method at all.
2. The class uses a new real-world structure called ModeSetting, which
takes into account the fact that real hardware requires more than width,
height and pitch settings to mode-set the display resolution.
3. The class assumes all instances should supply some sort of EDID,
so it facilitates such mechanism to do so. Even if a given driver does
not know what is the actual EDID, it will ask to create default-generic
EDID blob.
3. This class shifts the responsibilies of switching between console
mode and graphical mode from a GraphicsAdapter to the DisplayConnector
class, so when doing the switch, the GraphicsManagement code actually
asks each DisplayConnector object to do the switch and doesn't rely on
the GraphicsAdapter objects at all.
2022-04-29 06:44:46 -03:00
|
|
|
#include <Kernel/Graphics/DisplayConnector.h>
|
2022-07-09 02:58:57 -03:00
|
|
|
#include <Kernel/Graphics/Generic/DisplayConnector.h>
|
2021-09-22 03:17:07 -03:00
|
|
|
#include <Kernel/Graphics/GenericGraphicsAdapter.h>
|
2021-07-07 10:51:33 -03:00
|
|
|
#include <Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h>
|
2022-08-19 15:53:40 -03:00
|
|
|
#include <Kernel/Library/NonnullLockRefPtr.h>
|
|
|
|
|
#include <Kernel/Library/NonnullLockRefPtrVector.h>
|
2021-08-06 05:45:34 -03:00
|
|
|
#include <Kernel/Memory/Region.h>
|
2021-03-05 09:23:08 -03:00
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
|
|
class GraphicsManagement {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
static GraphicsManagement& the();
|
|
|
|
|
static bool is_initialized();
|
|
|
|
|
bool initialize();
|
|
|
|
|
|
2021-05-16 15:03:33 -03:00
|
|
|
unsigned allocate_minor_device_number() { return m_current_minor_number++; };
|
2021-03-05 09:23:08 -03:00
|
|
|
GraphicsManagement();
|
|
|
|
|
|
Kernel/Graphics: Introduce the DisplayConnector class
The DisplayConnector class is meant to replace the FramebufferDevice
class. The advantage of this class over the FramebufferDevice class is:
1. It removes the mmap interface entirely. This interface is unsafe, as
multiple processes could try to use it, and when switching to and from
text console mode, there's no "good" way to revoke a memory mapping from
this interface, let alone when there are multiple processes that call
this interface. Therefore, in the DisplayConnector class there's no
implementation for this method at all.
2. The class uses a new real-world structure called ModeSetting, which
takes into account the fact that real hardware requires more than width,
height and pitch settings to mode-set the display resolution.
3. The class assumes all instances should supply some sort of EDID,
so it facilitates such mechanism to do so. Even if a given driver does
not know what is the actual EDID, it will ask to create default-generic
EDID blob.
3. This class shifts the responsibilies of switching between console
mode and graphical mode from a GraphicsAdapter to the DisplayConnector
class, so when doing the switch, the GraphicsManagement code actually
asks each DisplayConnector object to do the switch and doesn't rely on
the GraphicsAdapter objects at all.
2022-04-29 06:44:46 -03:00
|
|
|
void attach_new_display_connector(Badge<DisplayConnector>, DisplayConnector&);
|
|
|
|
|
void detach_display_connector(Badge<DisplayConnector>, DisplayConnector&);
|
|
|
|
|
|
2022-03-18 06:58:34 -03:00
|
|
|
void set_vga_text_mode_cursor(size_t console_width, size_t x, size_t y);
|
|
|
|
|
void disable_vga_text_mode_console_cursor();
|
2022-03-15 16:41:22 -03:00
|
|
|
void disable_vga_emulation_access_permanently();
|
|
|
|
|
|
2022-08-19 15:53:40 -03:00
|
|
|
LockRefPtr<Graphics::Console> console() const { return m_console; }
|
2022-01-29 18:08:05 -03:00
|
|
|
void set_console(Graphics::Console&);
|
2021-04-16 16:58:51 -03:00
|
|
|
|
|
|
|
|
void deactivate_graphical_mode();
|
|
|
|
|
void activate_graphical_mode();
|
2021-03-05 09:23:08 -03:00
|
|
|
|
|
|
|
|
private:
|
2022-03-18 06:58:34 -03:00
|
|
|
void enable_vga_text_mode_console_cursor();
|
2022-03-15 16:41:22 -03:00
|
|
|
|
2021-09-23 04:20:54 -03:00
|
|
|
bool determine_and_initialize_graphics_device(PCI::DeviceIdentifier const&);
|
2022-07-09 02:58:57 -03:00
|
|
|
|
|
|
|
|
void initialize_preset_resolution_generic_display_connector();
|
|
|
|
|
|
2022-08-19 15:53:40 -03:00
|
|
|
NonnullLockRefPtrVector<GenericGraphicsAdapter> m_graphics_devices;
|
|
|
|
|
LockRefPtr<Graphics::Console> m_console;
|
2021-04-16 16:58:51 -03:00
|
|
|
|
2022-04-30 09:53:02 -03:00
|
|
|
// Note: This is only used when booting with kernel commandline that includes "graphics_subsystem_mode=limited"
|
2022-08-19 15:53:40 -03:00
|
|
|
LockRefPtr<GenericDisplayConnector> m_preset_resolution_generic_display_connector;
|
2022-04-30 09:53:02 -03:00
|
|
|
|
2022-09-16 07:17:02 -03:00
|
|
|
LockRefPtr<DisplayConnector> m_platform_board_specific_display_connector;
|
|
|
|
|
|
2021-03-05 09:23:08 -03:00
|
|
|
unsigned m_current_minor_number { 0 };
|
2021-04-16 16:58:51 -03:00
|
|
|
|
2022-08-18 16:46:28 -03:00
|
|
|
SpinlockProtected<IntrusiveList<&DisplayConnector::m_list_node>> m_display_connector_nodes { LockRank::None };
|
2022-09-23 05:06:14 -03:00
|
|
|
#if ARCH(I386) || ARCH(X86_64)
|
|
|
|
|
OwnPtr<VGAIOArbiter> m_vga_arbiter;
|
|
|
|
|
#endif
|
2021-03-05 09:23:08 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|