1
0

pl11[01]: Dynamically allocate framebuffer instead of assuming 0x200000

This commit is contained in:
Aaron Lindsay 2012-10-02 23:12:16 -04:00
parent 5a836d0af5
commit 53863654c3
2 changed files with 46 additions and 14 deletions

View File

@ -20,12 +20,13 @@
#include <types.h>
#include <framebuffer.h>
#include <mm.h>
#include <math.h>
#define PL110_CR_EN 0x001
#define PL110_CR_PWR 0x800
#define PL110_IOBASE 0xc0000000
#define PL110_PALBASE (PL110_IOBASE + 0x200)
#define PL110_FB_BASE 0x200000;
struct pl110_control {
uint32 volatile timing0; //0
@ -41,12 +42,27 @@ struct pl110_control {
struct fbdev pl110_fb_device;
int pl110_init(struct fb *f, unsigned int color_depth) {
unsigned int width, height;
unsigned int fb_size, power;
struct pl110_control *plio = (struct pl110_control*)PL110_IOBASE;
struct page *p;
/* 640x480 pixels */
width = 640;
height = 480;
plio->timing0 = 0x3f1f3f9c;
plio->timing1 = 0x080b61df;
plio->upbase = PL110_FB_BASE;
/* Allocate memory for framebuffer */
fb_size = width * height * (color_depth / 8);
power = log(fb_size) - log(MM_PAGE_SIZE);
if ((unsigned int)1<<power < fb_size)
power++;
p = mm_get_free_pages(power);
if (!p)
return -1;
plio->upbase = (uint32)p->address;
if (color_depth == FB_COLOR_DEPTH_8) {
plio->control = 0x1827;
@ -61,11 +77,11 @@ int pl110_init(struct fb *f, unsigned int color_depth) {
}
f->device = &pl110_fb_device;
f->device->fbaddr = (void*)PL110_FB_BASE;
f->width = 640;
f->device->pixelwidth = 640;
f->height = 480;
f->device->pixelheight = 480;
f->device->fbaddr = (void*)plio->upbase;
f->width = width;
f->device->pixelwidth = width;
f->height = height;
f->device->pixelheight = height;
f->color_depth = color_depth;
f->device->color_depth = color_depth;

View File

@ -20,12 +20,13 @@
#include <types.h>
#include <framebuffer.h>
#include <mm.h>
#include <math.h>
#define PL111_CR_EN 0x001
#define PL111_CR_PWR 0x800
#define PL111_IOBASE 0x10020000
#define PL111_PALBASE (PL111_IOBASE + 0x200)
#define PL111_FB_BASE 0x200000;
struct pl111_control {
uint32 volatile timing0; //0
@ -40,12 +41,27 @@ struct pl111_control {
struct fbdev pl111_fb_device;
int pl111_init(struct fb *f, unsigned int color_depth) {
unsigned int width, height;
unsigned int fb_size, power;
struct pl111_control *plio = (struct pl111_control*)PL111_IOBASE;
struct page *p;
/* 640x480 pixels */
width = 640;
height = 480;
plio->timing0 = 0x3f1f3f9c;
plio->timing1 = 0x080b61df;
plio->upbase = PL111_FB_BASE;
/* Allocate memory for framebuffer */
fb_size = width * height * (color_depth / 8);
power = log(fb_size) - log(MM_PAGE_SIZE);
if ((unsigned int)1<<power < fb_size)
power++;
p = mm_get_free_pages(power);
if (!p)
return -1;
plio->upbase = (uint32)p->address;
if (color_depth == FB_COLOR_DEPTH_8) {
plio->control = 0x1827;
@ -60,11 +76,11 @@ int pl111_init(struct fb *f, unsigned int color_depth) {
}
f->device = &pl111_fb_device;
f->device->fbaddr = (void*)PL111_FB_BASE;
f->width = 640;
f->device->pixelwidth = 640;
f->height = 480;
f->device->pixelheight = 480;
f->device->fbaddr = (void*)plio->upbase;
f->width = width;
f->device->pixelwidth = width;
f->height = height;
f->device->pixelheight = height;
f->color_depth = color_depth;
f->device->color_depth = color_depth;