summaryrefslogtreecommitdiff
path: root/sys/dev/video/fbdev.c
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-04-24 19:52:56 -0400
committerIan Moffett <ian@osmora.org>2024-04-24 19:52:56 -0400
commitd06eca1772190435e5dcb370db734653d3989bc8 (patch)
treedb09ef7b5b28f033a0313722516c0eae105b3bf3 /sys/dev/video/fbdev.c
parenteb5d1c92c4e79c04a9d2e0027728e1378ba61f49 (diff)
kernel: fbdev: Add framebuffer ioctl
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/dev/video/fbdev.c')
-rw-r--r--sys/dev/video/fbdev.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/sys/dev/video/fbdev.c b/sys/dev/video/fbdev.c
index 1f20ab6..af020a1 100644
--- a/sys/dev/video/fbdev.c
+++ b/sys/dev/video/fbdev.c
@@ -31,6 +31,8 @@
#include <sys/limine.h>
#include <sys/device.h>
#include <sys/driver.h>
+#include <sys/system.h>
+#include <sys/errno.h>
#include <dev/video/fbdev.h>
#include <vm/vm.h>
#include <fs/devfs.h>
@@ -45,6 +47,27 @@ static volatile struct limine_framebuffer_request framebuffer_req = {
static struct device *dev;
+static int
+fbdev_ioctl(struct device *dev, uint32_t cmd, uintptr_t arg)
+{
+ struct fbdev_info info = {
+ .width = FRAMEBUFFER->width,
+ .height = FRAMEBUFFER->height,
+ .pitch = FRAMEBUFFER->pitch,
+ .bits_per_pixel = FRAMEBUFFER->bpp
+ };
+
+ switch (cmd) {
+ case FBIOCTL_INFO:
+ copyout(&info, arg, sizeof(info));
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
static paddr_t
fbdev_mmap(struct device *dev, off_t off, vm_prot_t prot)
{
@@ -80,6 +103,7 @@ fbdev_init(void)
dev->read = NULL;
dev->write = NULL;
dev->mmap = fbdev_mmap;
+ dev->ioctl = fbdev_ioctl;
device_create(dev, device_alloc_major(), 1);
devfs_add_dev("fb", dev);