X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=rpikern;a=blobdiff_plain;f=src%2Fvideo.c;fp=src%2Fvideo.c;h=9b552dcfb77ee0245efc316385ca0986c4989134;hp=33b740f09ce28788a5d86d8968479fa1e4383cca;hb=32ccc707bc0821d7ff4248fe9f58e92e9c6ebef9;hpb=203b43a75a028e9238307bd6e73768eb8e942071 diff --git a/src/video.c b/src/video.c index 33b740f..9b552dc 100644 --- a/src/video.c +++ b/src/video.c @@ -1,68 +1,18 @@ #include "config.h" +#include #include #include +#include "rpi.h" #include "video.h" -#include "serial.h" #include "mem.h" -#define MBOX_READ_REG (*(volatile uint32_t*)(IO_BASE | 0xb880)) -#define MBOX_POLL_REG (*(volatile uint32_t*)(IO_BASE | 0xb890)) -#define MBOX_SENDER_REG (*(volatile uint32_t*)(IO_BASE | 0xb894)) -#define MBOX_STATUS_REG (*(volatile uint32_t*)(IO_BASE | 0xb898)) -#define MBOX_CFG_REG (*(volatile uint32_t*)(IO_BASE | 0xb89c)) -#define MBOX_WRITE_REG (*(volatile uint32_t*)(IO_BASE | 0xb8a0)) - -#define MBOX_STAT_WRBUSY 0x80000000 -#define MBOX_STAT_RDBUSY 0x40000000 - -struct vc_fbinfo { - uint32_t phys_width, phys_height; - uint32_t virt_width, virt_height; - uint32_t pitch; /* filled by videocore */ - uint32_t depth; - uint32_t x, y; - void *addr; /* filled by videocore */ - uint32_t size; /* filled by videocore */ -}; - -void mbox_write(int mbox, uint32_t msg); -uint32_t mbox_read(int mbox); - -static struct vc_fbinfo fbinf __attribute__((aligned(16))); +/* needs to by 16-byte aligned, because the address we send over the mailbox + * interface, will have its 4 least significant bits masked off and taken over + * by the mailbox id + */ +static uint8_t propbuf[64] __attribute__((aligned(16))); int video_init(void) { - memset(&fbinf, 0, sizeof fbinf); - fbinf.phys_width = fbinf.virt_width = 1024; - fbinf.phys_height = fbinf.virt_height = 600; - fbinf.depth = 32; - fbinf.x = fbinf.y = 0; - - mbox_write(1, MEM_BUS_COHERENT(&fbinf)); - if(mbox_read(1) != 0) { - ser_printstr("Failed to initialize display\n"); - return -1; - } - - ser_printstr("Video init successful\n"); - memset(fbinf.addr, 0, fbinf.size); return 0; } - -void mbox_write(int mbox, uint32_t msg) -{ - while(MBOX_STATUS_REG & MBOX_STAT_WRBUSY); - MBOX_WRITE_REG = (msg & 0xfffffff0) | mbox; -} - -uint32_t mbox_read(int mbox) -{ - uint32_t msg; - - do { - while(MBOX_STATUS_REG & MBOX_STAT_RDBUSY); - msg = MBOX_READ_REG; - } while((msg & 0xf) != mbox); - - return msg & 0xfffffff0; -}