1.1 --- a/stage2/jzlcd.c Wed Jun 10 16:06:38 2015 +0200
1.2 +++ b/stage2/jzlcd.c Wed Jun 10 17:34:49 2015 +0200
1.3 @@ -24,6 +24,9 @@
1.4 #include "jzlcd.h"
1.5 #include "board.h"
1.6
1.7 +#define ALIGN(x,a) __ALIGN_MASK((x),(typeof(x))(a)-1)
1.8 +#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
1.9 +
1.10 #define align2(n) (n)=((((n)+1)>>1)<<1)
1.11 #define align4(n) (n)=((((n)+3)>>2)<<2)
1.12 #define align8(n) (n)=((((n)+7)>>3)<<3)
1.13 @@ -37,13 +40,32 @@
1.14 return line_length * panel_info.vl_row;
1.15 }
1.16
1.17 +unsigned long lcd_setmem(unsigned long addr)
1.18 +{
1.19 + unsigned long size;
1.20 +
1.21 + size = lcd_get_size();
1.22 +
1.23 + /* Round up to nearest full page, or MMU section if defined */
1.24 + size = ALIGN(size, PAGE_SIZE);
1.25 + addr = ALIGN(addr - PAGE_SIZE + 1, PAGE_SIZE);
1.26 +
1.27 + /* Allocate pages for the frame buffer. */
1.28 + addr -= size;
1.29 +
1.30 + return addr;
1.31 +}
1.32 +
1.33 static int jz_lcd_init_mem(void *lcdbase, vidinfo_t *vid);
1.34 static void jz_lcd_desc_init(vidinfo_t *vid);
1.35 static int jz_lcd_hw_init(vidinfo_t *vid);
1.36
1.37 -void lcd_ctrl_init (void *lcdbase)
1.38 +void lcd_ctrl_init (void **lcdbase)
1.39 {
1.40 - jz_lcd_init_mem(lcdbase, &panel_info);
1.41 + /* Start from the top of memory and obtain a framebuffer region. */
1.42 + *lcdbase = (void *) lcd_setmem(get_memory_size());
1.43 +
1.44 + jz_lcd_init_mem(*lcdbase, &panel_info);
1.45 jz_lcd_desc_init(&panel_info);
1.46 jz_lcd_hw_init(&panel_info);
1.47 }
1.48 @@ -60,7 +82,7 @@
1.49 void lcd_disable (void)
1.50 {
1.51 REG_LCD_CTRL |= (1<<4); /* LCDCTRL.DIS, regular disable */
1.52 - /* REG_LCD_CTRL |= (1<<3); */ /* LCDCTRL.DIS, quikly disable */
1.53 + /* REG_LCD_CTRL |= (1<<3); */ /* LCDCTRL.DIS, quickly disable */
1.54 }
1.55
1.56 static int jz_lcd_init_mem(void *lcdbase, vidinfo_t *vid)
1.57 @@ -73,7 +95,6 @@
1.58 fbi->palette_size = 256;
1.59 palette_mem_size = fbi->palette_size * sizeof(u16);
1.60
1.61 - /* debug("jz_lcd.c palette_mem_size = 0x%08lx\n", (unsigned long) palette_mem_size); */
1.62 /* locate palette and descs at end of page following fb */
1.63 fbi->palette = (unsigned long)lcdbase + fb_size + PAGE_SIZE - palette_mem_size;
1.64