From fc93b4db26f52b7de209e74af70caf234aabe665 Mon Sep 17 00:00:00 2001 From: Korobov Nikita Date: Sun, 9 Jul 2017 20:49:53 +0300 Subject: [PATCH] [MINOR] The framebuffer driver changed for mailbox --- minix/drivers/system/mailbox/main.c | 21 +++++------ .../drivers/video/fb/arch/earm/fb_arch_rpi.c | 36 +++++++------------ 2 files changed, 24 insertions(+), 33 deletions(-) diff --git a/minix/drivers/system/mailbox/main.c b/minix/drivers/system/mailbox/main.c index 0ece60025..763b9a727 100644 --- a/minix/drivers/system/mailbox/main.c +++ b/minix/drivers/system/mailbox/main.c @@ -97,6 +97,17 @@ static ssize_t m_read(devminor_t minor, u64_t position, endpoint_t endpt, if (minor != MAILBOX_DEV) return(EIO); + + uint8_t *buf = (int8_t *)mbox_read(MBOX_PROP); + r = sys_safecopyto(endpt, grant, 0, (vir_bytes)buf, size); + if (r != OK) { + log_warn(&log, "mailbox: sys_safecopyto failed for proc %d, grant %d\n", + endpt, grant); + return r; + } + + mbox_flush(); + return(OK); } @@ -174,18 +185,8 @@ static ssize_t m_write(devminor_t minor, u64_t position, endpoint_t endpt, if (wait_irq() < 0) { log_warn(&log, "can't wait interrupt from mbox\n"); return(ETIME); - } else { - buf = (int8_t *)mbox_read(MBOX_PROP); - r = sys_safecopyto(endpt, grant, 0, (vir_bytes)buf, *(int *)msg); - if (r != OK) { - log_warn(&log, "mailbox: sys_safecopyto failed for proc %d, grant %d\n", - endpt, grant); - return r; - } } - mbox_flush(); - return(OK); } diff --git a/minix/drivers/video/fb/arch/earm/fb_arch_rpi.c b/minix/drivers/video/fb/arch/earm/fb_arch_rpi.c index cb0e452dd..75b1f9df8 100644 --- a/minix/drivers/video/fb/arch/earm/fb_arch_rpi.c +++ b/minix/drivers/video/fb/arch/earm/fb_arch_rpi.c @@ -16,6 +16,13 @@ #include #include #include + +#include + +#include +#include +#include + #include "dss.h" #include "fb.h" @@ -180,6 +187,10 @@ arch_configure_display(int minor) if (!initialized) return; if (minor != 0) return; + int fd = open("/dev/mailbox", O_RDWR, 0777); + if (fd < 0) + panic("Unable to open mailbox device"); + /* Fill mailbox property tags buffer */ mboxbuffer_vir[0] = 4096; mboxbuffer_vir[1] = 0; @@ -203,8 +214,8 @@ arch_configure_display(int minor) mboxbuffer_vir[19] = 4096; mboxbuffer_vir[20] = 0; /* end tag */ - writemailbox(8, mboxbuffer_phys + 0x40000000); - readmailbox(8); + write(fd, mboxbuffer_vir, 4096); + read(fd, mboxbuffer_vir, 4096); if (mboxbuffer_vir[1] != 0x80000000) panic("Unable to configure framebuffer"); @@ -296,7 +307,6 @@ arch_fb_init(int minor, struct edid_info *info) { int r; u32_t rdispc; - struct minix_mem_range mr; if (minor != 0) return ENXIO; /* We support only one minor */ @@ -309,26 +319,6 @@ arch_fb_init(int minor, struct edid_info *info) initialized = 1; - /* Configure mailbox memory access */ - mr.mr_base = MAILBOX_BASE; - mr.mr_limit = mr.mr_base + 0x1000; - if (sys_privctl(SELF, SYS_PRIV_ADD_MEM, &mr) != OK) { - panic("Unable to request access to mailbox memory"); - } - - mbox_phys_base = (vir_bytes) vm_map_phys(SELF, (void *) MAILBOX_BASE, - 0x1000); - - if (mbox_phys_base == (vir_bytes) MAP_FAILED) { - panic("Unable to map mailbox memory"); - } - - /* Configure mailbox buffer */ - mboxbuffer_vir = (u32_t*) alloc_contig(0x1000, 0, &mboxbuffer_phys); - if (mboxbuffer_vir == (u32_t*) MAP_FAILED) { - panic("Unable to allocate contiguous memory for mailbox buffer\n"); - } - /* Configure buffer settings and turn on LCD/Digital */ arch_configure_display(minor);