2020-01-18 09:38:21 +01:00
|
|
|
/*
|
2021-03-05 14:23:08 +02:00
|
|
|
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
|
2020-01-18 09:38:21 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
2019-08-18 14:54:52 +10:00
|
|
|
#pragma once
|
|
|
|
|
2021-04-16 22:58:51 +03:00
|
|
|
#include <AK/NonnullOwnPtr.h>
|
2019-08-18 14:54:52 +10:00
|
|
|
#include <AK/Types.h>
|
2021-09-22 17:13:12 +03:00
|
|
|
#include <Kernel/Graphics/GenericFramebufferDevice.h>
|
2021-09-22 09:17:07 +03:00
|
|
|
#include <Kernel/Graphics/GenericGraphicsAdapter.h>
|
2021-08-22 01:37:17 +02:00
|
|
|
#include <Kernel/Locking/Spinlock.h>
|
2021-08-06 10:45:34 +02:00
|
|
|
#include <Kernel/Memory/AnonymousVMObject.h>
|
2020-05-16 12:00:04 +02:00
|
|
|
#include <Kernel/PhysicalAddress.h>
|
2019-08-18 14:54:52 +10:00
|
|
|
|
2020-02-16 01:27:42 +01:00
|
|
|
namespace Kernel {
|
|
|
|
|
2021-09-22 17:13:12 +03:00
|
|
|
class FramebufferDevice final : public GenericFramebufferDevice {
|
2021-09-11 09:19:20 +03:00
|
|
|
friend class DeviceManagement;
|
|
|
|
|
2019-08-18 14:54:52 +10:00
|
|
|
public:
|
2021-09-22 17:13:12 +03:00
|
|
|
static NonnullRefPtr<FramebufferDevice> create(const GenericGraphicsAdapter&, PhysicalAddress, size_t, size_t, size_t);
|
2021-05-22 09:51:55 +03:00
|
|
|
|
2021-11-08 00:51:39 +01:00
|
|
|
virtual ErrorOr<Memory::Region*> mmap(Process&, OpenFileDescription&, Memory::VirtualRange const&, u64 offset, int prot, bool shared) override;
|
2019-08-18 14:54:52 +10:00
|
|
|
|
2021-09-22 17:13:12 +03:00
|
|
|
virtual void deactivate_writes() override;
|
|
|
|
virtual void activate_writes() override;
|
2021-03-05 14:23:08 +02:00
|
|
|
|
2021-11-08 00:51:39 +01:00
|
|
|
virtual ErrorOr<void> try_to_initialize() override;
|
2021-03-05 14:23:08 +02:00
|
|
|
|
2021-09-22 17:13:12 +03:00
|
|
|
virtual bool multihead_support() const override { return false; }
|
|
|
|
virtual bool flushing_support() const override { return false; }
|
|
|
|
virtual bool partial_flushing_support() const override { return false; }
|
|
|
|
virtual size_t heads_count() const override { return 1; }
|
2021-11-08 00:51:39 +01:00
|
|
|
virtual ErrorOr<size_t> buffer_length(size_t head) const override;
|
|
|
|
virtual ErrorOr<size_t> pitch(size_t head) const override;
|
|
|
|
virtual ErrorOr<size_t> height(size_t head) const override;
|
|
|
|
virtual ErrorOr<size_t> width(size_t head) const override;
|
|
|
|
virtual ErrorOr<size_t> vertical_offset(size_t head) const override;
|
2021-11-20 17:10:57 +01:00
|
|
|
virtual ErrorOr<bool> vertical_offsetted(size_t head) const override;
|
2021-09-21 09:26:14 +03:00
|
|
|
|
2021-09-11 09:19:20 +03:00
|
|
|
private:
|
2021-11-08 00:51:39 +01:00
|
|
|
virtual ErrorOr<void> set_head_resolution(size_t head, size_t width, size_t height, size_t pitch) override;
|
|
|
|
virtual ErrorOr<void> set_head_buffer(size_t head, bool second_buffer) override;
|
|
|
|
virtual ErrorOr<void> flush_head_buffer(size_t head) override;
|
|
|
|
virtual ErrorOr<void> flush_rectangle(size_t head, FBRect const&) override;
|
2021-09-10 14:44:46 +03:00
|
|
|
|
2021-09-22 17:13:12 +03:00
|
|
|
FramebufferDevice(const GenericGraphicsAdapter&, PhysicalAddress, size_t, size_t, size_t);
|
2019-08-18 14:54:52 +10:00
|
|
|
|
|
|
|
PhysicalAddress m_framebuffer_address;
|
2020-04-29 09:35:19 +02:00
|
|
|
size_t m_framebuffer_pitch { 0 };
|
|
|
|
size_t m_framebuffer_width { 0 };
|
|
|
|
size_t m_framebuffer_height { 0 };
|
2021-04-16 22:58:51 +03:00
|
|
|
|
2021-09-05 10:02:03 -07:00
|
|
|
Spinlock m_activation_lock;
|
2021-09-22 17:13:12 +03:00
|
|
|
mutable Mutex m_buffer_offset_lock;
|
2021-04-16 22:58:51 +03:00
|
|
|
|
2021-08-06 13:49:36 +02:00
|
|
|
RefPtr<Memory::AnonymousVMObject> m_real_framebuffer_vmobject;
|
|
|
|
RefPtr<Memory::AnonymousVMObject> m_swapped_framebuffer_vmobject;
|
|
|
|
OwnPtr<Memory::Region> m_real_framebuffer_region;
|
|
|
|
OwnPtr<Memory::Region> m_swapped_framebuffer_region;
|
2021-04-16 22:58:51 +03:00
|
|
|
|
2021-05-20 21:28:18 +03:00
|
|
|
bool m_graphical_writes_enabled { true };
|
|
|
|
|
2021-08-06 13:49:36 +02:00
|
|
|
RefPtr<Memory::AnonymousVMObject> m_userspace_real_framebuffer_vmobject;
|
|
|
|
Memory::Region* m_userspace_framebuffer_region { nullptr };
|
2021-05-22 09:51:55 +03:00
|
|
|
|
|
|
|
size_t m_y_offset { 0 };
|
2019-08-18 14:54:52 +10:00
|
|
|
};
|
2020-02-16 01:27:42 +01:00
|
|
|
|
|
|
|
}
|