]> git.sur5r.net Git - u-boot/blobdiff - drivers/video/bcm2835.c
mtd: pxa3xx_nand: Correct null dereference
[u-boot] / drivers / video / bcm2835.c
index 58a616317a6a5c826edfbe47d38b9d65fa92c146..bff1fcb9eaf7eb9ed293b0a752051b9740dbf95e 100644 (file)
@@ -6,6 +6,8 @@
 
 #include <common.h>
 #include <lcd.h>
+#include <memalign.h>
+#include <phys2bus.h>
 #include <asm/arch/mbox.h>
 #include <asm/global_data.h>
 
@@ -14,6 +16,8 @@ DECLARE_GLOBAL_DATA_PTR;
 /* Global variables that lcd.c expects to exist */
 vidinfo_t panel_info;
 
+static u32 bcm2835_pitch;
+
 struct msg_query {
        struct bcm2835_mbox_hdr hdr;
        struct bcm2835_mbox_tag_physical_w_h physical_w_h;
@@ -30,13 +34,14 @@ struct msg_setup {
        struct bcm2835_mbox_tag_virtual_offset virtual_offset;
        struct bcm2835_mbox_tag_overscan overscan;
        struct bcm2835_mbox_tag_allocate_buffer allocate_buffer;
+       struct bcm2835_mbox_tag_pitch pitch;
        u32 end_tag;
 };
 
 void lcd_ctrl_init(void *lcdbase)
 {
-       ALLOC_ALIGN_BUFFER(struct msg_query, msg_query, 1, 16);
-       ALLOC_ALIGN_BUFFER(struct msg_setup, msg_setup, 1, 16);
+       ALLOC_CACHE_ALIGN_BUFFER(struct msg_query, msg_query, 1);
+       ALLOC_CACHE_ALIGN_BUFFER(struct msg_setup, msg_setup, 1);
        int ret;
        u32 w, h;
 
@@ -80,6 +85,7 @@ void lcd_ctrl_init(void *lcdbase)
        msg_setup->overscan.body.req.right = 0;
        BCM2835_MBOX_INIT_TAG(&msg_setup->allocate_buffer, ALLOCATE_BUFFER);
        msg_setup->allocate_buffer.body.req.alignment = 0x100;
+       BCM2835_MBOX_INIT_TAG_NO_REQ(&msg_setup->pitch, GET_PITCH);
 
        ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg_setup->hdr);
        if (ret) {
@@ -90,6 +96,7 @@ void lcd_ctrl_init(void *lcdbase)
 
        w = msg_setup->physical_w_h.body.resp.width;
        h = msg_setup->physical_w_h.body.resp.height;
+       bcm2835_pitch = msg_setup->pitch.body.resp.pitch;
 
        debug("bcm2835: Final resolution is %d x %d\n", w, h);
 
@@ -97,9 +104,16 @@ void lcd_ctrl_init(void *lcdbase)
        panel_info.vl_row = h;
        panel_info.vl_bpix = LCD_COLOR16;
 
-       gd->fb_base = msg_setup->allocate_buffer.body.resp.fb_address;
+       gd->fb_base = bus_to_phys(
+               msg_setup->allocate_buffer.body.resp.fb_address);
 }
 
 void lcd_enable(void)
 {
 }
+
+int lcd_get_size(int *line_length)
+{
+       *line_length = bcm2835_pitch;
+       return *line_length * panel_info.vl_row;
+}