]> git.ipfire.org Git - people/ms/u-boot.git/blame - drivers/video/bcm2835.c
video: bcm2835: fix build issues
[people/ms/u-boot.git] / drivers / video / bcm2835.c
CommitLineData
6be3c9fc
SW
1/*
2 * (C) Copyright 2012 Stephen Warren
3 *
4 * See file CREDITS for list of people who contributed to this
5 * project.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */
17
18#include <common.h>
19#include <lcd.h>
20#include <asm/arch/mbox.h>
21#include <asm/global_data.h>
22
23DECLARE_GLOBAL_DATA_PTR;
24
25/* Global variables that lcd.c expects to exist */
6be3c9fc 26vidinfo_t panel_info;
6be3c9fc
SW
27
28struct msg_query {
29 struct bcm2835_mbox_hdr hdr;
30 struct bcm2835_mbox_tag_physical_w_h physical_w_h;
31 u32 end_tag;
32};
33
34struct msg_setup {
35 struct bcm2835_mbox_hdr hdr;
36 struct bcm2835_mbox_tag_physical_w_h physical_w_h;
37 struct bcm2835_mbox_tag_virtual_w_h virtual_w_h;
38 struct bcm2835_mbox_tag_depth depth;
39 struct bcm2835_mbox_tag_pixel_order pixel_order;
40 struct bcm2835_mbox_tag_alpha_mode alpha_mode;
41 struct bcm2835_mbox_tag_virtual_offset virtual_offset;
42 struct bcm2835_mbox_tag_overscan overscan;
43 struct bcm2835_mbox_tag_allocate_buffer allocate_buffer;
44 u32 end_tag;
45};
46
47void lcd_ctrl_init(void *lcdbase)
48{
49 ALLOC_ALIGN_BUFFER(struct msg_query, msg_query, 1, 16);
50 ALLOC_ALIGN_BUFFER(struct msg_setup, msg_setup, 1, 16);
51 int ret;
52 u32 w, h;
53
54 debug("bcm2835: Query resolution...\n");
55
56 BCM2835_MBOX_INIT_HDR(msg_query);
57 BCM2835_MBOX_INIT_TAG_NO_REQ(&msg_query->physical_w_h,
58 GET_PHYSICAL_W_H);
59 ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg_query->hdr);
60 if (ret) {
61 printf("bcm2835: Could not query display resolution\n");
62 /* FIXME: How to disable the LCD to prevent errors? hang()? */
63 return;
64 }
65
66 w = msg_query->physical_w_h.body.resp.width;
67 h = msg_query->physical_w_h.body.resp.height;
68
69 debug("bcm2835: Setting up display for %d x %d\n", w, h);
70
71 BCM2835_MBOX_INIT_HDR(msg_setup);
72 BCM2835_MBOX_INIT_TAG(&msg_setup->physical_w_h, SET_PHYSICAL_W_H);
73 msg_setup->physical_w_h.body.req.width = w;
74 msg_setup->physical_w_h.body.req.height = h;
75 BCM2835_MBOX_INIT_TAG(&msg_setup->virtual_w_h, SET_VIRTUAL_W_H);
76 msg_setup->virtual_w_h.body.req.width = w;
77 msg_setup->virtual_w_h.body.req.height = h;
78 BCM2835_MBOX_INIT_TAG(&msg_setup->depth, SET_DEPTH);
79 msg_setup->depth.body.req.bpp = 16;
80 BCM2835_MBOX_INIT_TAG(&msg_setup->pixel_order, SET_PIXEL_ORDER);
81 msg_setup->pixel_order.body.req.order = BCM2835_MBOX_PIXEL_ORDER_BGR;
82 BCM2835_MBOX_INIT_TAG(&msg_setup->alpha_mode, SET_ALPHA_MODE);
83 msg_setup->alpha_mode.body.req.alpha = BCM2835_MBOX_ALPHA_MODE_IGNORED;
84 BCM2835_MBOX_INIT_TAG(&msg_setup->virtual_offset, SET_VIRTUAL_OFFSET);
85 msg_setup->virtual_offset.body.req.x = 0;
86 msg_setup->virtual_offset.body.req.y = 0;
87 BCM2835_MBOX_INIT_TAG(&msg_setup->overscan, SET_OVERSCAN);
88 msg_setup->overscan.body.req.top = 0;
89 msg_setup->overscan.body.req.bottom = 0;
90 msg_setup->overscan.body.req.left = 0;
91 msg_setup->overscan.body.req.right = 0;
92 BCM2835_MBOX_INIT_TAG(&msg_setup->allocate_buffer, ALLOCATE_BUFFER);
93 msg_setup->allocate_buffer.body.req.alignment = 0x100;
94
95 ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg_setup->hdr);
96 if (ret) {
97 printf("bcm2835: Could not configure display\n");
98 /* FIXME: How to disable the LCD to prevent errors? hang()? */
99 return;
100 }
101
102 w = msg_setup->physical_w_h.body.resp.width;
103 h = msg_setup->physical_w_h.body.resp.height;
104
105 debug("bcm2835: Final resolution is %d x %d\n", w, h);
106
107 panel_info.vl_col = w;
108 panel_info.vl_row = h;
109 panel_info.vl_bpix = LCD_COLOR16;
110
111 gd->fb_base = msg_setup->allocate_buffer.body.resp.fb_address;
6be3c9fc
SW
112}
113
114void lcd_enable(void)
115{
116}