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
|
|
|
|
|
2019-09-06 15:34:26 +02:00
|
|
|
#include <AK/String.h>
|
2019-08-18 14:54:52 +10:00
|
|
|
#include <AK/Types.h>
|
|
|
|
#include <Kernel/Devices/BlockDevice.h>
|
2021-03-05 14:23:08 +02:00
|
|
|
#include <Kernel/Graphics/GraphicsDevice.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-03-05 14:23:08 +02:00
|
|
|
class FramebufferDevice : public BlockDevice {
|
2019-08-18 14:54:52 +10:00
|
|
|
AK_MAKE_ETERNAL
|
|
|
|
public:
|
2020-05-23 13:17:58 +02:00
|
|
|
virtual int ioctl(FileDescription&, unsigned request, FlatPtr arg) override;
|
2021-03-18 22:57:25 +01:00
|
|
|
virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, u64 offset, int prot, bool shared) override;
|
2019-08-18 14:54:52 +10:00
|
|
|
|
2020-12-25 19:01:19 +02:00
|
|
|
// ^Device
|
|
|
|
virtual mode_t required_mode() const override { return 0660; }
|
2021-01-21 18:49:56 +01:00
|
|
|
virtual String device_name() const override;
|
2020-12-25 19:01:19 +02:00
|
|
|
|
2021-03-05 14:23:08 +02:00
|
|
|
virtual size_t framebuffer_size_in_bytes() const { return m_framebuffer_pitch * m_framebuffer_height; }
|
|
|
|
|
|
|
|
virtual ~FramebufferDevice() {};
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual bool set_resolution(size_t framebuffer_width, size_t framebuffer_height, size_t framebuffer_pitch);
|
|
|
|
|
|
|
|
FramebufferDevice(PhysicalAddress, size_t, size_t, size_t);
|
|
|
|
|
|
|
|
virtual bool can_read(const FileDescription&, size_t) const override final { return true; }
|
|
|
|
virtual bool can_write(const FileDescription&, size_t) const override final { return true; }
|
|
|
|
virtual void start_request(AsyncBlockDeviceRequest& request) override final { request.complete(AsyncDeviceRequest::Failure); }
|
2021-03-17 13:18:51 +01:00
|
|
|
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override { return -EINVAL; }
|
|
|
|
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return -EINVAL; }
|
2019-08-18 14:54:52 +10:00
|
|
|
|
2021-03-05 14:23:08 +02:00
|
|
|
protected:
|
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 };
|
2019-08-18 14:54:52 +10:00
|
|
|
};
|
2020-02-16 01:27:42 +01:00
|
|
|
|
|
|
|
}
|