mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:57:44 +00:00
Everywhere: Purge all support and usage of framebuffer devices
Long live the DisplayConnector object!
This commit is contained in:
parent
aad968cc5e
commit
e301af8352
25 changed files with 90 additions and 995 deletions
|
@ -17,9 +17,8 @@
|
|||
|
||||
namespace WindowServer {
|
||||
|
||||
HardwareScreenBackend::HardwareScreenBackend(String device, bool display_connector_device_backed)
|
||||
HardwareScreenBackend::HardwareScreenBackend(String device)
|
||||
: m_device(move(device))
|
||||
, display_connector_device_backed(display_connector_device_backed)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -44,38 +43,26 @@ HardwareScreenBackend::~HardwareScreenBackend()
|
|||
m_framebuffer_fd = -1;
|
||||
}
|
||||
if (m_framebuffer) {
|
||||
if (!display_connector_device_backed)
|
||||
MUST(Core::System::munmap(m_framebuffer, m_size_in_bytes));
|
||||
else
|
||||
free(m_framebuffer);
|
||||
free(m_framebuffer);
|
||||
|
||||
m_framebuffer = nullptr;
|
||||
m_size_in_bytes = 0;
|
||||
}
|
||||
}
|
||||
|
||||
ErrorOr<void> HardwareScreenBackend::set_head_resolution(FBHeadResolution resolution)
|
||||
ErrorOr<void> HardwareScreenBackend::set_head_mode_setting(GraphicsHeadModeSetting mode_setting)
|
||||
{
|
||||
if (!display_connector_device_backed) {
|
||||
auto rc = fb_set_resolution(m_framebuffer_fd, &resolution);
|
||||
if (rc != 0)
|
||||
return Error::from_syscall("fb_set_resolution", rc);
|
||||
} else {
|
||||
GraphicsHeadModeSetting mode_setting;
|
||||
memset(&mode_setting, 0, sizeof(GraphicsHeadModeSetting));
|
||||
mode_setting.horizontal_active = resolution.width;
|
||||
mode_setting.vertical_active = resolution.height;
|
||||
mode_setting.horizontal_stride = resolution.pitch;
|
||||
auto rc = graphics_connector_set_head_mode_setting(m_framebuffer_fd, &mode_setting);
|
||||
|
||||
GraphicsHeadModeSetting requested_mode_setting = mode_setting;
|
||||
auto rc = graphics_connector_set_head_mode_setting(m_framebuffer_fd, &requested_mode_setting);
|
||||
if (rc != 0) {
|
||||
dbgln("Failed to set backend mode setting: falling back to safe resolution");
|
||||
rc = graphics_connector_set_safe_head_mode_setting(m_framebuffer_fd);
|
||||
if (rc != 0) {
|
||||
dbgln("Failed to set backend mode setting: falling back to safe resolution");
|
||||
rc = graphics_connector_set_safe_head_mode_setting(m_framebuffer_fd);
|
||||
if (rc != 0) {
|
||||
dbgln("Failed to set backend safe mode setting: aborting");
|
||||
return Error::from_syscall("graphics_connector_set_safe_head_mode_setting", rc);
|
||||
}
|
||||
dbgln("Failed to set backend mode setting: falling back to safe resolution - success.");
|
||||
dbgln("Failed to set backend safe mode setting: aborting");
|
||||
return Error::from_syscall("graphics_connector_set_safe_head_mode_setting", rc);
|
||||
}
|
||||
dbgln("Failed to set backend mode setting: falling back to safe resolution - success.");
|
||||
}
|
||||
|
||||
return {};
|
||||
|
@ -84,20 +71,13 @@ ErrorOr<void> HardwareScreenBackend::set_head_resolution(FBHeadResolution resolu
|
|||
ErrorOr<void> HardwareScreenBackend::unmap_framebuffer()
|
||||
{
|
||||
if (m_framebuffer) {
|
||||
if (!display_connector_device_backed) {
|
||||
size_t previous_size_in_bytes = m_size_in_bytes;
|
||||
return Core::System::munmap(m_framebuffer, previous_size_in_bytes);
|
||||
} else {
|
||||
free(m_framebuffer);
|
||||
}
|
||||
free(m_framebuffer);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> HardwareScreenBackend::write_all_contents(Gfx::IntRect const& virtual_rect)
|
||||
{
|
||||
if (!display_connector_device_backed)
|
||||
return {};
|
||||
lseek(m_framebuffer_fd, 0, SEEK_SET);
|
||||
write(m_framebuffer_fd, scanline(0, 0), virtual_rect.height() * m_pitch);
|
||||
if (m_can_set_head_buffer) {
|
||||
|
@ -113,80 +93,38 @@ ErrorOr<void> HardwareScreenBackend::write_all_contents(Gfx::IntRect const& virt
|
|||
|
||||
ErrorOr<void> HardwareScreenBackend::map_framebuffer()
|
||||
{
|
||||
if (!display_connector_device_backed) {
|
||||
FBHeadProperties properties;
|
||||
properties.head_index = 0;
|
||||
int rc = fb_get_head_properties(m_framebuffer_fd, &properties);
|
||||
if (rc != 0)
|
||||
return Error::from_syscall("fb_get_head_properties", rc);
|
||||
m_size_in_bytes = properties.buffer_length;
|
||||
|
||||
m_framebuffer = (Gfx::ARGB32*)TRY(Core::System::mmap(nullptr, m_size_in_bytes, PROT_READ | PROT_WRITE, MAP_SHARED, m_framebuffer_fd, 0));
|
||||
|
||||
if (m_can_set_head_buffer) {
|
||||
// Note: fall back to assuming the second buffer starts right after the last line of the first
|
||||
// Note: for now, this calculation works quite well, so need to defer it to another function
|
||||
// that does ioctl to figure out the correct offset. If a Framebuffer device ever happens to
|
||||
// to set the second buffer at different location than this, we might need to consider bringing
|
||||
// back a function with ioctl to check this.
|
||||
m_back_buffer_offset = static_cast<size_t>(properties.pitch) * properties.height;
|
||||
} else {
|
||||
m_back_buffer_offset = 0;
|
||||
}
|
||||
GraphicsHeadModeSetting mode_setting {};
|
||||
memset(&mode_setting, 0, sizeof(GraphicsHeadModeSetting));
|
||||
int rc = graphics_connector_get_head_mode_setting(m_framebuffer_fd, &mode_setting);
|
||||
if (rc != 0) {
|
||||
return Error::from_syscall("graphics_connector_get_head_mode_setting", rc);
|
||||
}
|
||||
m_size_in_bytes = mode_setting.horizontal_stride * mode_setting.vertical_active * 2;
|
||||
m_framebuffer = (Gfx::ARGB32*)malloc(m_size_in_bytes);
|
||||
if (m_can_set_head_buffer) {
|
||||
// Note: fall back to assuming the second buffer starts right after the last line of the first
|
||||
// Note: for now, this calculation works quite well, so need to defer it to another function
|
||||
// that does ioctl to figure out the correct offset. If a Framebuffer device ever happens to
|
||||
// to set the second buffer at different location than this, we might need to consider bringing
|
||||
// back a function with ioctl to check this.
|
||||
m_back_buffer_offset = static_cast<size_t>(mode_setting.horizontal_stride) * mode_setting.vertical_active;
|
||||
} else {
|
||||
GraphicsHeadModeSetting mode_setting {};
|
||||
memset(&mode_setting, 0, sizeof(GraphicsHeadModeSetting));
|
||||
int rc = graphics_connector_get_head_mode_setting(m_framebuffer_fd, &mode_setting);
|
||||
if (rc != 0) {
|
||||
return Error::from_syscall("graphics_connector_get_head_mode_setting", rc);
|
||||
}
|
||||
m_size_in_bytes = mode_setting.horizontal_stride * mode_setting.vertical_active * 2;
|
||||
m_framebuffer = (Gfx::ARGB32*)malloc(m_size_in_bytes);
|
||||
if (m_can_set_head_buffer) {
|
||||
// Note: fall back to assuming the second buffer starts right after the last line of the first
|
||||
// Note: for now, this calculation works quite well, so need to defer it to another function
|
||||
// that does ioctl to figure out the correct offset. If a Framebuffer device ever happens to
|
||||
// to set the second buffer at different location than this, we might need to consider bringing
|
||||
// back a function with ioctl to check this.
|
||||
m_back_buffer_offset = static_cast<size_t>(mode_setting.horizontal_stride) * mode_setting.vertical_active;
|
||||
} else {
|
||||
m_back_buffer_offset = 0;
|
||||
}
|
||||
m_back_buffer_offset = 0;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<FBHeadProperties> HardwareScreenBackend::get_head_properties()
|
||||
ErrorOr<GraphicsHeadModeSetting> HardwareScreenBackend::get_head_mode_setting()
|
||||
{
|
||||
if (!display_connector_device_backed) {
|
||||
FBHeadProperties properties;
|
||||
properties.head_index = 0;
|
||||
int rc = fb_get_head_properties(m_framebuffer_fd, &properties);
|
||||
if (rc != 0)
|
||||
return Error::from_syscall("fb_get_head_properties", rc);
|
||||
m_pitch = static_cast<int>(properties.pitch);
|
||||
return properties;
|
||||
} else {
|
||||
GraphicsHeadModeSetting mode_setting {};
|
||||
memset(&mode_setting, 0, sizeof(GraphicsHeadModeSetting));
|
||||
int rc = graphics_connector_get_head_mode_setting(m_framebuffer_fd, &mode_setting);
|
||||
if (rc != 0) {
|
||||
return Error::from_syscall("graphics_connector_get_head_mode_setting", rc);
|
||||
}
|
||||
m_pitch = mode_setting.horizontal_stride;
|
||||
// Note: We translate (for now, until Framebuffer devices are removed) the GraphicsHeadModeSetting
|
||||
// structure to FBHeadProperties.
|
||||
FBHeadProperties properties;
|
||||
properties.head_index = 0;
|
||||
properties.pitch = mode_setting.horizontal_stride;
|
||||
properties.width = mode_setting.horizontal_active;
|
||||
properties.height = mode_setting.vertical_active;
|
||||
properties.offset = 0;
|
||||
properties.buffer_length = mode_setting.horizontal_stride * mode_setting.vertical_active * 2;
|
||||
return properties;
|
||||
GraphicsHeadModeSetting mode_setting {};
|
||||
memset(&mode_setting, 0, sizeof(GraphicsHeadModeSetting));
|
||||
int rc = graphics_connector_get_head_mode_setting(m_framebuffer_fd, &mode_setting);
|
||||
if (rc != 0) {
|
||||
return Error::from_syscall("graphics_connector_get_head_mode_setting", rc);
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
m_pitch = mode_setting.horizontal_stride;
|
||||
return mode_setting;
|
||||
}
|
||||
|
||||
void HardwareScreenBackend::set_head_buffer(int head_index)
|
||||
|
|
|
@ -18,7 +18,7 @@ class HardwareScreenBackend : public ScreenBackend {
|
|||
public:
|
||||
virtual ~HardwareScreenBackend();
|
||||
|
||||
HardwareScreenBackend(String device, bool display_connector_device_backed);
|
||||
explicit HardwareScreenBackend(String device);
|
||||
|
||||
virtual ErrorOr<void> open() override;
|
||||
|
||||
|
@ -31,14 +31,13 @@ public:
|
|||
virtual ErrorOr<void> unmap_framebuffer() override;
|
||||
virtual ErrorOr<void> map_framebuffer() override;
|
||||
|
||||
virtual ErrorOr<void> set_head_resolution(FBHeadResolution) override;
|
||||
virtual ErrorOr<FBHeadProperties> get_head_properties() override;
|
||||
virtual ErrorOr<void> set_head_mode_setting(GraphicsHeadModeSetting) override;
|
||||
virtual ErrorOr<GraphicsHeadModeSetting> get_head_mode_setting() override;
|
||||
|
||||
virtual ErrorOr<void> write_all_contents(Gfx::IntRect const&) override;
|
||||
|
||||
String m_device {};
|
||||
int m_framebuffer_fd { -1 };
|
||||
bool const display_connector_device_backed { false };
|
||||
|
||||
Gfx::ARGB32* scanline(int buffer_index, int y) const
|
||||
{
|
||||
|
|
|
@ -231,7 +231,7 @@ bool Screen::open_device()
|
|||
|
||||
switch (info.mode) {
|
||||
case ScreenLayout::Screen::Mode::Device: {
|
||||
m_backend = make<HardwareScreenBackend>(info.device.value(), false);
|
||||
m_backend = make<HardwareScreenBackend>(info.device.value());
|
||||
auto return_value = m_backend->open();
|
||||
if (return_value.is_error()) {
|
||||
dbgln("Screen #{}: Failed to open backend: {}", index(), return_value.error());
|
||||
|
@ -241,17 +241,6 @@ bool Screen::open_device()
|
|||
set_resolution(true);
|
||||
return true;
|
||||
}
|
||||
case ScreenLayout::Screen::Mode::DisplayConnectorDevice: {
|
||||
m_backend = make<HardwareScreenBackend>(info.device.value(), true);
|
||||
auto return_value = m_backend->open();
|
||||
if (return_value.is_error()) {
|
||||
dbgln("Screen #{}: Failed to open display connector backend: {}", index(), return_value.error());
|
||||
return false;
|
||||
}
|
||||
|
||||
set_resolution(true);
|
||||
return true;
|
||||
}
|
||||
case ScreenLayout::Screen::Mode::Virtual: {
|
||||
m_backend = make<VirtualScreenBackend>();
|
||||
// Virtual device open should never fail.
|
||||
|
@ -335,9 +324,21 @@ bool Screen::set_resolution(bool initial)
|
|||
|
||||
ErrorOr<void> return_value = Error::from_errno(EINVAL);
|
||||
{
|
||||
// FIXME: Add multihead support for one framebuffer
|
||||
FBHeadResolution physical_resolution { 0, 0, info.resolution.width(), info.resolution.height() };
|
||||
return_value = m_backend->set_head_resolution(physical_resolution);
|
||||
GraphicsHeadModeSetting requested_mode_setting;
|
||||
memset(&requested_mode_setting, 0, sizeof(GraphicsHeadModeSetting));
|
||||
requested_mode_setting.horizontal_stride = info.resolution.width() * 4;
|
||||
requested_mode_setting.pixel_clock_in_khz = 0;
|
||||
requested_mode_setting.horizontal_active = info.resolution.width();
|
||||
requested_mode_setting.horizontal_front_porch_pixels = 0;
|
||||
requested_mode_setting.horizontal_sync_time_pixels = 0;
|
||||
requested_mode_setting.horizontal_blank_pixels = 0;
|
||||
requested_mode_setting.vertical_active = info.resolution.height();
|
||||
requested_mode_setting.vertical_front_porch_lines = 0;
|
||||
requested_mode_setting.vertical_sync_time_lines = 0;
|
||||
requested_mode_setting.vertical_blank_lines = 0;
|
||||
requested_mode_setting.horizontal_offset = 0;
|
||||
requested_mode_setting.vertical_offset = 0;
|
||||
return_value = m_backend->set_head_mode_setting(requested_mode_setting);
|
||||
}
|
||||
|
||||
dbgln_if(WSSCREEN_DEBUG, "Screen #{}: fb_set_resolution() - success", index());
|
||||
|
@ -347,8 +348,8 @@ bool Screen::set_resolution(bool initial)
|
|||
TRY(m_backend->unmap_framebuffer());
|
||||
TRY(m_backend->map_framebuffer());
|
||||
}
|
||||
auto properties = TRY(m_backend->get_head_properties());
|
||||
info.resolution = { properties.width, properties.height };
|
||||
auto mode_setting = TRY(m_backend->get_head_mode_setting());
|
||||
info.resolution = { mode_setting.horizontal_active, mode_setting.vertical_active };
|
||||
|
||||
update_virtual_rect();
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ public:
|
|||
|
||||
virtual ErrorOr<void> flush_framebuffer() = 0;
|
||||
|
||||
virtual ErrorOr<void> set_head_resolution(FBHeadResolution) = 0;
|
||||
virtual ErrorOr<FBHeadProperties> get_head_properties() = 0;
|
||||
virtual ErrorOr<void> set_head_mode_setting(GraphicsHeadModeSetting) = 0;
|
||||
virtual ErrorOr<GraphicsHeadModeSetting> get_head_mode_setting() = 0;
|
||||
|
||||
virtual ErrorOr<void> write_all_contents(Gfx::IntRect const&) { return {}; }
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ public:
|
|||
enum class Mode {
|
||||
Invalid,
|
||||
Device,
|
||||
DisplayConnectorDevice,
|
||||
Virtual,
|
||||
} mode;
|
||||
Optional<String> device;
|
||||
|
@ -43,7 +42,6 @@ public:
|
|||
switch (mode) {
|
||||
__ENUMERATE_MODE_ENUM(Invalid)
|
||||
__ENUMERATE_MODE_ENUM(Device)
|
||||
__ENUMERATE_MODE_ENUM(DisplayConnectorDevice)
|
||||
__ENUMERATE_MODE_ENUM(Virtual)
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
|
@ -61,8 +59,6 @@ public:
|
|||
bool normalize();
|
||||
bool load_config(Core::ConfigFile const& config_file, String* error_msg = nullptr);
|
||||
bool save_config(Core::ConfigFile& config_file, bool sync = true) const;
|
||||
// FIXME: Remove this once framebuffer devices are removed.
|
||||
bool try_auto_add_framebuffer(String const&);
|
||||
bool try_auto_add_display_connector(String const&);
|
||||
|
||||
// TODO: spaceship operator
|
||||
|
|
|
@ -239,8 +239,6 @@ bool ScreenLayout::load_config(const Core::ConfigFile& config_file, String* erro
|
|||
Screen::Mode mode { Screen::Mode::Invalid };
|
||||
if (str_mode == "Device") {
|
||||
mode = Screen::Mode::Device;
|
||||
} else if (str_mode == "DisplayConnectorDevice") {
|
||||
mode = Screen::Mode::DisplayConnectorDevice;
|
||||
} else if (str_mode == "Virtual") {
|
||||
mode = Screen::Mode::Virtual;
|
||||
}
|
||||
|
@ -250,7 +248,7 @@ bool ScreenLayout::load_config(const Core::ConfigFile& config_file, String* erro
|
|||
*this = {};
|
||||
return false;
|
||||
}
|
||||
auto device = (mode == Screen::Mode::Device || mode == Screen::Mode::DisplayConnectorDevice) ? config_file.read_entry(group_name, "Device") : Optional<String> {};
|
||||
auto device = (mode == Screen::Mode::Device) ? config_file.read_entry(group_name, "Device") : Optional<String> {};
|
||||
screens.append({ mode, device,
|
||||
{ config_file.read_num_entry(group_name, "Left"), config_file.read_num_entry(group_name, "Top") },
|
||||
{ config_file.read_num_entry(group_name, "Width"), config_file.read_num_entry(group_name, "Height") },
|
||||
|
@ -339,7 +337,7 @@ bool ScreenLayout::try_auto_add_display_connector(String const& device_path)
|
|||
}
|
||||
|
||||
auto append_screen = [&](Gfx::IntRect const& new_screen_rect) {
|
||||
screens.append({ .mode = Screen::Mode::DisplayConnectorDevice,
|
||||
screens.append({ .mode = Screen::Mode::Device,
|
||||
.device = device_path,
|
||||
.location = new_screen_rect.location(),
|
||||
.resolution = new_screen_rect.size(),
|
||||
|
@ -392,90 +390,6 @@ bool ScreenLayout::try_auto_add_display_connector(String const& device_path)
|
|||
return false;
|
||||
}
|
||||
|
||||
// FIXME: Remove this once framebuffer devices are removed.
|
||||
bool ScreenLayout::try_auto_add_framebuffer(String const& device_path)
|
||||
{
|
||||
int framebuffer_fd = open(device_path.characters(), O_RDWR | O_CLOEXEC);
|
||||
if (framebuffer_fd < 0) {
|
||||
int err = errno;
|
||||
dbgln("Error ({}) opening framebuffer device {}", err, device_path);
|
||||
return false;
|
||||
}
|
||||
ScopeGuard fd_guard([&] {
|
||||
close(framebuffer_fd);
|
||||
});
|
||||
// FIXME: Add multihead support for one framebuffer
|
||||
FBHeadResolution resolution {};
|
||||
memset(&resolution, 0, sizeof(FBHeadResolution));
|
||||
if (fb_get_resolution(framebuffer_fd, &resolution) < 0) {
|
||||
int err = errno;
|
||||
dbgln("Error ({}) querying resolution from framebuffer device {}", err, device_path);
|
||||
return false;
|
||||
}
|
||||
if (resolution.width == 0 || resolution.height == 0) {
|
||||
// Looks like the display is not turned on. Since we don't know what the desired
|
||||
// resolution should be, use the main display as reference.
|
||||
if (screens.is_empty())
|
||||
return false;
|
||||
auto& main_screen = screens[main_screen_index];
|
||||
resolution.width = main_screen.resolution.width();
|
||||
resolution.height = main_screen.resolution.height();
|
||||
}
|
||||
|
||||
auto append_screen = [&](Gfx::IntRect const& new_screen_rect) {
|
||||
screens.append({ .mode = Screen::Mode::Device,
|
||||
.device = device_path,
|
||||
.location = new_screen_rect.location(),
|
||||
.resolution = new_screen_rect.size(),
|
||||
.scale_factor = 1 });
|
||||
};
|
||||
|
||||
if (screens.is_empty()) {
|
||||
append_screen({ 0, 0, (int)resolution.width, (int)resolution.height });
|
||||
return true;
|
||||
}
|
||||
|
||||
auto original_screens = move(screens);
|
||||
screens = original_screens;
|
||||
ArmedScopeGuard screens_guard([&] {
|
||||
screens = move(original_screens);
|
||||
});
|
||||
|
||||
// Now that we know the current resolution, try to find a location that we can add onto
|
||||
// TODO: make this a little more sophisticated in case a more complex layout is already configured
|
||||
for (auto& screen : screens) {
|
||||
auto screen_rect = screen.virtual_rect();
|
||||
Gfx::IntRect new_screen_rect {
|
||||
screen_rect.right() + 1,
|
||||
screen_rect.top(),
|
||||
(int)resolution.width,
|
||||
(int)resolution.height
|
||||
};
|
||||
|
||||
bool collision = false;
|
||||
for (auto& other_screen : screens) {
|
||||
if (&screen == &other_screen)
|
||||
continue;
|
||||
if (other_screen.virtual_rect().intersects(new_screen_rect)) {
|
||||
collision = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!collision) {
|
||||
append_screen(new_screen_rect);
|
||||
if (is_valid()) {
|
||||
// We got lucky!
|
||||
screens_guard.disarm();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dbgln("Failed to add framebuffer device {} with resolution {}x{} to screen layout", device_path, resolution.width, resolution.height);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace IPC {
|
||||
|
|
|
@ -31,31 +31,35 @@ void VirtualScreenBackend::set_head_buffer(int index)
|
|||
m_first_buffer_active = index == 0;
|
||||
}
|
||||
|
||||
ErrorOr<void> VirtualScreenBackend::set_head_resolution(FBHeadResolution resolution)
|
||||
ErrorOr<void> VirtualScreenBackend::set_head_mode_setting(GraphicsHeadModeSetting mode_setting)
|
||||
{
|
||||
if (resolution.head_index != 0)
|
||||
return Error::from_string_literal("Only head index 0 is supported."sv);
|
||||
m_height = resolution.height;
|
||||
m_height = mode_setting.vertical_active;
|
||||
|
||||
if (resolution.pitch == 0)
|
||||
resolution.pitch = static_cast<int>(resolution.width * sizeof(Gfx::ARGB32));
|
||||
m_pitch = resolution.pitch;
|
||||
if (static_cast<int>(resolution.width * sizeof(Gfx::ARGB32)) != resolution.pitch)
|
||||
if (mode_setting.horizontal_stride == 0)
|
||||
mode_setting.horizontal_stride = static_cast<int>(mode_setting.horizontal_active * sizeof(Gfx::ARGB32));
|
||||
m_pitch = mode_setting.horizontal_stride;
|
||||
if (static_cast<int>(mode_setting.horizontal_active * sizeof(Gfx::ARGB32)) != mode_setting.horizontal_stride)
|
||||
return Error::from_string_literal("Unsupported pitch"sv);
|
||||
|
||||
m_width = resolution.width;
|
||||
m_width = mode_setting.horizontal_active;
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<FBHeadProperties> VirtualScreenBackend::get_head_properties()
|
||||
ErrorOr<GraphicsHeadModeSetting> VirtualScreenBackend::get_head_mode_setting()
|
||||
{
|
||||
return FBHeadProperties {
|
||||
.head_index = 0,
|
||||
.pitch = static_cast<unsigned>(m_pitch),
|
||||
.width = static_cast<unsigned>(m_width),
|
||||
.height = static_cast<unsigned>(m_height),
|
||||
.offset = static_cast<unsigned>(m_first_buffer_active ? 0 : m_back_buffer_offset),
|
||||
.buffer_length = static_cast<unsigned>(m_size_in_bytes),
|
||||
return GraphicsHeadModeSetting {
|
||||
.horizontal_stride = m_pitch,
|
||||
.pixel_clock_in_khz = 0,
|
||||
.horizontal_active = m_width,
|
||||
.horizontal_front_porch_pixels = 0,
|
||||
.horizontal_sync_time_pixels = 0,
|
||||
.horizontal_blank_pixels = 0,
|
||||
.vertical_active = m_height,
|
||||
.vertical_front_porch_lines = 0,
|
||||
.vertical_sync_time_lines = 0,
|
||||
.vertical_blank_lines = 0,
|
||||
.horizontal_offset = 0,
|
||||
.vertical_offset = 0,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -35,8 +35,8 @@ private:
|
|||
virtual ErrorOr<void> unmap_framebuffer() override;
|
||||
virtual ErrorOr<void> map_framebuffer() override;
|
||||
|
||||
virtual ErrorOr<void> set_head_resolution(FBHeadResolution) override;
|
||||
virtual ErrorOr<FBHeadProperties> get_head_properties() override;
|
||||
virtual ErrorOr<void> set_head_mode_setting(GraphicsHeadModeSetting) override;
|
||||
virtual ErrorOr<GraphicsHeadModeSetting> get_head_mode_setting() override;
|
||||
|
||||
int m_height { 0 };
|
||||
int m_width { 0 };
|
||||
|
|
|
@ -68,25 +68,6 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
WindowServer::ScreenLayout screen_layout;
|
||||
String error_msg;
|
||||
|
||||
// FIXME: Remove this once framebuffer devices are removed.
|
||||
auto add_unconfigured_framebuffer_devices = [&]() {
|
||||
// Enumerate the /dev/fbX devices and try to set up any ones we find that we haven't already used
|
||||
Core::DirIterator di("/dev", Core::DirIterator::SkipParentAndBaseDir);
|
||||
while (di.has_next()) {
|
||||
auto path = di.next_path();
|
||||
if (!path.starts_with("fb"))
|
||||
continue;
|
||||
auto full_path = String::formatted("/dev/{}", path);
|
||||
dbgln("{} :", full_path);
|
||||
if (!Core::File::is_device(full_path))
|
||||
continue;
|
||||
if (fb_devices_configured.find(full_path) != fb_devices_configured.end())
|
||||
continue;
|
||||
if (!screen_layout.try_auto_add_framebuffer(full_path))
|
||||
dbgln("Could not auto-add framebuffer device {} to screen layout", full_path);
|
||||
}
|
||||
};
|
||||
|
||||
auto add_unconfigured_display_connector_devices = [&]() {
|
||||
// Enumerate the /dev/fbX devices and try to set up any ones we find that we haven't already used
|
||||
Core::DirIterator di("/dev/gpu", Core::DirIterator::SkipParentAndBaseDir);
|
||||
|
@ -108,9 +89,6 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
screen_layout = {};
|
||||
fb_devices_configured = {};
|
||||
|
||||
// FIXME: Remove this once framebuffer devices are removed.
|
||||
add_unconfigured_framebuffer_devices();
|
||||
|
||||
add_unconfigured_display_connector_devices();
|
||||
if (!WindowServer::Screen::apply_layout(move(screen_layout), error_msg)) {
|
||||
dbgln("Failed to apply generated fallback screen layout: {}", error_msg);
|
||||
|
@ -123,12 +101,9 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
|
||||
if (screen_layout.load_config(*wm_config, &error_msg)) {
|
||||
for (auto& screen_info : screen_layout.screens)
|
||||
if (screen_info.mode == WindowServer::ScreenLayout::Screen::Mode::Device || screen_info.mode == WindowServer::ScreenLayout::Screen::Mode::DisplayConnectorDevice)
|
||||
if (screen_info.mode == WindowServer::ScreenLayout::Screen::Mode::Device)
|
||||
fb_devices_configured.set(screen_info.device.value());
|
||||
|
||||
// FIXME: Remove this once framebuffer devices are removed.
|
||||
add_unconfigured_framebuffer_devices();
|
||||
|
||||
add_unconfigured_display_connector_devices();
|
||||
|
||||
if (!WindowServer::Screen::apply_layout(move(screen_layout), error_msg)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue