From dca9c2b9d3be14854f6019dc424acb4928884d13 Mon Sep 17 00:00:00 2001 From: Kevin Lange Date: Sat, 18 Feb 2017 22:19:35 +0900 Subject: [PATCH] Add an ioctl interface for setting video mode --- kernel/include/video.h | 1 + modules/lfbvideo.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/kernel/include/video.h b/kernel/include/video.h index d08993ce..a6fe0b57 100644 --- a/kernel/include/video.h +++ b/kernel/include/video.h @@ -5,6 +5,7 @@ #define IO_VID_DEPTH 0x5003 #define IO_VID_ADDR 0x5004 #define IO_VID_SIGNAL 0x5005 +#define IO_VID_SET 0x5006 #ifdef _KERNEL_ extern void lfb_set_resolution(uint16_t x, uint16_t y); diff --git a/modules/lfbvideo.c b/modules/lfbvideo.c index ecafd52f..6d1c0751 100644 --- a/modules/lfbvideo.c +++ b/modules/lfbvideo.c @@ -36,6 +36,8 @@ static uint16_t bochs_current_scroll(void); static pid_t display_change_recipient = 0; +void lfb_set_resolution(uint16_t x, uint16_t y); + /* * Address of the linear frame buffer. * This can move, so it's a pointer instead of @@ -43,6 +45,11 @@ static pid_t display_change_recipient = 0; */ uint8_t * lfb_vid_memory = (uint8_t *)0xE0000000; +struct vid_size { + uint32_t width; + uint32_t height; +}; + static int ioctl_vid(fs_node_t * node, int request, void * argp) { /* TODO: Make this actually support multiple video devices */ @@ -67,6 +74,10 @@ static int ioctl_vid(fs_node_t * node, int request, void * argp) { /* ioctl to register for a signal (vid device change? idk) on display change */ display_change_recipient = getpid(); return 0; + case IO_VID_SET: + validate(argp); + lfb_set_resolution(((struct vid_size *)argp)->width, ((struct vid_size *)argp)->height); + return 0; default: return -1; /* TODO EINV... something or other */ }