From ad5210eb86a1192ffca11ec09947be460b6830c2 Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Sun, 20 Mar 2022 21:44:11 +0100 Subject: [PATCH] Fb can configure resolution --- fb.c | 10 +++++----- fb.h | 2 +- hello.c | 5 ++++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/fb.c b/fb.c index 3af3682..5a20090 100644 --- a/fb.c +++ b/fb.c @@ -28,7 +28,7 @@ extern volatile unsigned char _binary_font_psf_start; static struct fbst fb; -unsigned char *fb_init() +unsigned char *fb_init(int width, int height) { // sending many tags at once mbox[0] = 35 * 4; @@ -36,13 +36,13 @@ unsigned char *fb_init() mbox[2] = MBOX_TAG_FBSETPHYS; // set phy wh mbox[3] = 8; mbox[4] = 0; - mbox[5] = 1920; // FrameBufferInfo.width - mbox[6] = 1080; // FrameBufferInfo.height + mbox[5] = width; // FrameBufferInfo.width + mbox[6] = height; // FrameBufferInfo.height mbox[7] = MBOX_TAG_FBSETVIRT; // set virt wh mbox[8] = 8; mbox[9] = 0; - mbox[10] = 1920; // FrameBufferInfo.virtual_width - mbox[11] = 1080; // FrameBufferInfo.virtual_height + mbox[10] = width; // FrameBufferInfo.virtual_width + mbox[11] = height; // FrameBufferInfo.virtual_height mbox[12] = MBOX_TAG_FBSETOFF; // set virt offset mbox[13] = 8; mbox[14] = 0; diff --git a/fb.h b/fb.h index a04a65b..0dd7326 100644 --- a/fb.h +++ b/fb.h @@ -8,6 +8,6 @@ struct fbst { unsigned int isrgb; }; -unsigned char *fb_init(); +unsigned char *fb_init(int width, int height); struct fbst * fb_get(); void fb_print(int x, int y, char *s); diff --git a/hello.c b/hello.c index c00efa0..335027d 100644 --- a/hello.c +++ b/hello.c @@ -3,13 +3,16 @@ #include "uart.h" #include "utils.h" +#define FB_WIDTH 640 +#define FB_HEIGHT 480 + int kernelmain(void) { struct fbst *fb; unsigned char *ptr; uart_init(); - if (fb_init() == 0) { + if (fb_init(FB_WIDTH, FB_HEIGHT) == 0) { puts("Fail to init framebuffer"); } mbox[0] = 8 * 4;