2023-04-21 16:18:15 +00:00
|
|
|
#include "fs/devices/FramebufferDevice.h"
|
|
|
|
#include "video/Framebuffer.h"
|
2023-04-21 16:25:53 +00:00
|
|
|
#include <bits/ioctl-defs.h>
|
2023-04-21 16:18:15 +00:00
|
|
|
#include <luna/CString.h>
|
|
|
|
|
2023-05-09 16:31:27 +00:00
|
|
|
Result<void> FramebufferDevice::create()
|
2023-04-21 16:18:15 +00:00
|
|
|
{
|
2023-05-09 16:31:27 +00:00
|
|
|
auto device = (SharedPtr<Device>)TRY(make_shared<FramebufferDevice>());
|
2023-05-17 17:40:37 +00:00
|
|
|
return DeviceRegistry::register_special_device(DeviceRegistry::Framebuffer, 0, device, "fb0", 0600);
|
2023-04-21 16:18:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result<usize> FramebufferDevice::read(u8*, usize, usize) const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Result<usize> FramebufferDevice::write(const u8* buf, usize offset, usize length)
|
|
|
|
{
|
|
|
|
if ((offset + length) > size()) length = size() - offset;
|
|
|
|
|
|
|
|
memcpy(Framebuffer::ptr() + offset, buf, length);
|
|
|
|
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
|
|
|
usize FramebufferDevice::size() const
|
|
|
|
{
|
|
|
|
return Framebuffer::size();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FramebufferDevice::blocking() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-04-21 16:25:53 +00:00
|
|
|
Result<u64> FramebufferDevice::ioctl(int request, void*)
|
2023-04-21 16:18:15 +00:00
|
|
|
{
|
2023-04-21 16:25:53 +00:00
|
|
|
switch (request)
|
|
|
|
{
|
|
|
|
case FB_GET_WIDTH: return (u64)Framebuffer::width();
|
|
|
|
case FB_GET_HEIGHT: return (u64)Framebuffer::height();
|
|
|
|
case FB_GET_SCANLINE: return (u64)Framebuffer::scanline();
|
|
|
|
default: return err(EINVAL);
|
|
|
|
}
|
2023-04-21 16:18:15 +00:00
|
|
|
}
|