Fb can configure resolution

This commit is contained in:
Mathieu Maret 2022-03-20 21:44:11 +01:00 committed by Mathieu Maret
parent 36a21f97c0
commit ad5210eb86
3 changed files with 10 additions and 7 deletions

10
fb.c
View File

@ -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;

2
fb.h
View File

@ -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);

View File

@ -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;