]> git.sur5r.net Git - u-boot/blobdiff - arch/arm/mach-bcm283x/msg.c
armv7: Add workaround for USB erratum A-008997
[u-boot] / arch / arm / mach-bcm283x / msg.c
index 17266c01a69b7b9fc7c25fa35d9bbfbd7239f7a2..92e93ad9e55b24031c8c75d6525bdcf5941bf317 100644 (file)
@@ -27,6 +27,20 @@ struct msg_query {
        u32 end_tag;
 };
 
+struct msg_setup {
+       struct bcm2835_mbox_hdr hdr;
+       struct bcm2835_mbox_tag_physical_w_h physical_w_h;
+       struct bcm2835_mbox_tag_virtual_w_h virtual_w_h;
+       struct bcm2835_mbox_tag_depth depth;
+       struct bcm2835_mbox_tag_pixel_order pixel_order;
+       struct bcm2835_mbox_tag_alpha_mode alpha_mode;
+       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;
+};
+
 int bcm2835_power_on_module(u32 module)
 {
        ALLOC_CACHE_ALIGN_BUFFER(struct msg_set_power_state, msg_pwr, 1);
@@ -91,3 +105,50 @@ int bcm2835_get_video_size(int *widthp, int *heightp)
 
        return 0;
 }
+
+int bcm2835_set_video_params(int *widthp, int *heightp, int depth_bpp,
+                            int pixel_order, int alpha_mode, ulong *fb_basep,
+                            ulong *fb_sizep, int *pitchp)
+{
+       ALLOC_CACHE_ALIGN_BUFFER(struct msg_setup, msg_setup, 1);
+       int ret;
+
+       BCM2835_MBOX_INIT_HDR(msg_setup);
+       BCM2835_MBOX_INIT_TAG(&msg_setup->physical_w_h, SET_PHYSICAL_W_H);
+       msg_setup->physical_w_h.body.req.width = *widthp;
+       msg_setup->physical_w_h.body.req.height = *heightp;
+       BCM2835_MBOX_INIT_TAG(&msg_setup->virtual_w_h, SET_VIRTUAL_W_H);
+       msg_setup->virtual_w_h.body.req.width = *widthp;
+       msg_setup->virtual_w_h.body.req.height = *heightp;
+       BCM2835_MBOX_INIT_TAG(&msg_setup->depth, SET_DEPTH);
+       msg_setup->depth.body.req.bpp = 32;
+       BCM2835_MBOX_INIT_TAG(&msg_setup->pixel_order, SET_PIXEL_ORDER);
+       msg_setup->pixel_order.body.req.order = pixel_order;
+       BCM2835_MBOX_INIT_TAG(&msg_setup->alpha_mode, SET_ALPHA_MODE);
+       msg_setup->alpha_mode.body.req.alpha = alpha_mode;
+       BCM2835_MBOX_INIT_TAG(&msg_setup->virtual_offset, SET_VIRTUAL_OFFSET);
+       msg_setup->virtual_offset.body.req.x = 0;
+       msg_setup->virtual_offset.body.req.y = 0;
+       BCM2835_MBOX_INIT_TAG(&msg_setup->overscan, SET_OVERSCAN);
+       msg_setup->overscan.body.req.top = 0;
+       msg_setup->overscan.body.req.bottom = 0;
+       msg_setup->overscan.body.req.left = 0;
+       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) {
+               printf("bcm2835: Could not configure display\n");
+               return ret;
+       }
+       *widthp = msg_setup->physical_w_h.body.resp.width;
+       *heightp = msg_setup->physical_w_h.body.resp.height;
+       *pitchp = msg_setup->pitch.body.resp.pitch;
+       *fb_basep = bus_to_phys(
+                       msg_setup->allocate_buffer.body.resp.fb_address);
+       *fb_sizep = msg_setup->allocate_buffer.body.resp.fb_size;
+
+       return 0;
+}