From c91e11c05885a62a9c3ef2bb5af5834edde959c9 Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Wed, 6 Apr 2022 11:38:04 -0700 Subject: Make changing resolution easier --- README.md | 3 ++- include/graphics/lfb.h | 2 +- kernel/graphics/lfb.c | 17 +++++++---------- kernel/sys/core.c | 2 +- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 098d8ca..25ce762 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,8 @@ Headers for files in `usr/` are expected in `include/usr/`. They can then be inc Currently, if you build Jobbed without modifying anything, it will generate the RTOS core testing suite. This testing suite outputs the tracing, thread switch, low and high priority thread creation, mutex creation, mutex destruction, mutex locking contention, mutex locking non-contention, mutex unlocking, semaphore waiting, semaphore signalling at zero, semaphore signalling non-zero timings to a 1920x1080 display output. -Currently the graphics driver expects this resolution of display. If you have another resolution, this can be changed in `kernel/graphics/lfb.c` by modifying `SCR_WIDTH` and `SCR_HEIGHT`. +Currently the graphics driver expects this resolution of display. +If you have another resolution, this can be changed in `kernel/sys/core.c` by modifying `lfb_init(1920, 1080)` to `lfb_init(YOUR WIDTH, YOUR HEIGHT)`. ### C++ C++ sources in this directory are expected to work with a few missing features such as the `new` and `delete` keywords since memory is not dynamically allocated on the system. diff --git a/include/graphics/lfb.h b/include/graphics/lfb.h index 8184959..dec9aad 100644 --- a/include/graphics/lfb.h +++ b/include/graphics/lfb.h @@ -6,7 +6,7 @@ #define DRAW64(x,y,v) draw_hex32(x,y,v>>32);draw_hex32(x+8,y,v); -void lfb_init(void); +void lfb_init(unsigned long w, unsigned long h); void lfb_showpicture(void); void clear_screen(void); diff --git a/kernel/graphics/lfb.c b/kernel/graphics/lfb.c index 8c41b1c..e76fccb 100644 --- a/kernel/graphics/lfb.c +++ b/kernel/graphics/lfb.c @@ -7,13 +7,10 @@ unsigned char *lfb; /* raw frame buffer address */ -#define SCR_WIDTH 1920 -#define SCR_HEIGHT 1080 - /** * Set screen resolution */ -void lfb_init(void) +void lfb_init(unsigned long w, unsigned long h) { mbox[0] = 35*4; mbox[1] = MBOX_REQUEST; @@ -21,14 +18,14 @@ void lfb_init(void) mbox[2] = 0x48003; //set phy wh mbox[3] = 8; mbox[4] = 8; - mbox[5] = SCR_WIDTH; //FrameBufferInfo.width - mbox[6] = SCR_HEIGHT; //FrameBufferInfo.height + mbox[5] = w; //FrameBufferInfo.width + mbox[6] = h; //FrameBufferInfo.height mbox[7] = 0x48004; //set virt wh mbox[8] = 8; mbox[9] = 8; - mbox[10] = SCR_WIDTH; //FrameBufferInfo.virtual_width - mbox[11] = SCR_HEIGHT; //FrameBufferInfo.virtual_height + mbox[10] = w; //FrameBufferInfo.virtual_width + mbox[11] = h; //FrameBufferInfo.virtual_height mbox[12] = 0x48009; //set virt offset mbox[13] = 8; @@ -92,8 +89,8 @@ void lfb_showpicture(void) clear_screen(); #define FWIDTH 240 #define FHEIGHT 80 - draw_cbox(SCR_WIDTH-FWIDTH, SCR_HEIGHT-FHEIGHT*2, FWIDTH, FHEIGHT, 0x0057b7); - draw_cbox(SCR_WIDTH-FWIDTH, SCR_HEIGHT-FHEIGHT, FWIDTH, FHEIGHT, 0xffd700); + draw_cbox(gwidth-FWIDTH, gheight-FHEIGHT*2, FWIDTH, FHEIGHT, 0x0057b7); + draw_cbox(gwidth-FWIDTH, gheight-FHEIGHT, FWIDTH, FHEIGHT, 0xffd700); } void draw_cpixel(unsigned int lx, unsigned int ly, unsigned int c) diff --git a/kernel/sys/core.c b/kernel/sys/core.c index 551d741..2169b7e 100644 --- a/kernel/sys/core.c +++ b/kernel/sys/core.c @@ -29,7 +29,7 @@ void sysinit(void) store32(0x00, GPU_INTERRUPTS_ROUTING); // Graphics Initialize - lfb_init(); + lfb_init(1920, 1080); lfb_showpicture(); // Initialize Memory Management Unit -- cgit v1.2.1