From: Andre Heider <a.heider@gmail.com>
To: barebox@lists.infradead.org
Subject: [PATCH 6/6] ARM: rpi: add support for simplefb
Date: Thu, 24 Oct 2013 22:23:46 +0200 [thread overview]
Message-ID: <1382646226-24871-7-git-send-email-a.heider@gmail.com> (raw)
In-Reply-To: <1382646226-24871-1-git-send-email-a.heider@gmail.com>
Setup a framebuffer using the mailbox driver and register it as
simplefb.
Signed-off-by: Andre Heider <a.heider@gmail.com>
---
arch/arm/boards/raspberry-pi/rpi.c | 84 ++++++++++++++++++++++++++++++++++++++
1 file changed, 84 insertions(+)
diff --git a/arch/arm/boards/raspberry-pi/rpi.c b/arch/arm/boards/raspberry-pi/rpi.c
index 06c43f3..3e9d62b 100644
--- a/arch/arm/boards/raspberry-pi/rpi.c
+++ b/arch/arm/boards/raspberry-pi/rpi.c
@@ -22,6 +22,7 @@
#include <envfs.h>
#include <asm/armlinux.h>
#include <generated/mach-types.h>
+#include <video/simplefb.h>
#include <mach/core.h>
#include <mach/mbox.h>
@@ -38,6 +39,25 @@ struct msg_get_clock_rate {
u32 end_tag;
};
+struct msg_fb_query {
+ struct bcm2835_mbox_hdr hdr;
+ struct bcm2835_mbox_tag_physical_w_h physical_w_h;
+ u32 end_tag;
+};
+
+struct msg_fb_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_allocate_buffer allocate_buffer;
+ struct bcm2835_mbox_tag_pitch pitch;
+ u32 end_tag;
+};
+
static int rpi_get_arm_mem(u32 *size)
{
BCM2835_MBOX_STACK_ALIGN(struct msg_get_arm_mem, msg);
@@ -79,6 +99,69 @@ static int rpi_register_clkdev(u32 clock_id, const char *name)
return 0;
}
+#ifdef CONFIG_DRIVER_VIDEO_SIMPLEFB
+static int rpi_fb_init(void)
+{
+ BCM2835_MBOX_STACK_ALIGN(struct msg_fb_query, msg_query);
+ BCM2835_MBOX_STACK_ALIGN(struct msg_fb_setup, msg_setup);
+ u32 w, h, stride, fb_address, fb_size;
+ int ret;
+
+ BCM2835_MBOX_INIT_HDR(msg_query);
+ BCM2835_MBOX_INIT_TAG_NO_REQ(&msg_query->physical_w_h,
+ GET_PHYSICAL_W_H);
+ ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg_query->hdr);
+ if (ret) {
+ printf("could not query display resolution\n");
+ return ret;
+ }
+
+ w = msg_query->physical_w_h.body.resp.width;
+ h = msg_query->physical_w_h.body.resp.height;
+
+ 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 = w;
+ msg_setup->physical_w_h.body.req.height = h;
+ BCM2835_MBOX_INIT_TAG(&msg_setup->virtual_w_h, SET_VIRTUAL_W_H);
+ msg_setup->virtual_w_h.body.req.width = w;
+ msg_setup->virtual_w_h.body.req.height = h;
+ BCM2835_MBOX_INIT_TAG(&msg_setup->depth, SET_DEPTH);
+ msg_setup->depth.body.req.bpp = 16;
+ BCM2835_MBOX_INIT_TAG(&msg_setup->pixel_order, SET_PIXEL_ORDER);
+ msg_setup->pixel_order.body.req.order = BCM2835_MBOX_PIXEL_ORDER_BGR;
+ BCM2835_MBOX_INIT_TAG(&msg_setup->alpha_mode, SET_ALPHA_MODE);
+ msg_setup->alpha_mode.body.req.alpha = BCM2835_MBOX_ALPHA_MODE_IGNORED;
+ 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->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("could not configure display\n");
+ return ret;
+ }
+
+ w = msg_setup->physical_w_h.body.resp.width;
+ h = msg_setup->physical_w_h.body.resp.height;
+ stride = msg_setup->pitch.body.resp.pitch;
+ fb_address = msg_setup->allocate_buffer.body.resp.fb_address;
+ fb_size = msg_setup->allocate_buffer.body.resp.fb_size;
+
+ add_simplefb_device(w, h, stride, SIMPLEFB_R5G6B5, fb_address, fb_size);
+
+ return 0;
+}
+#else
+static inline int rpi_fb_init(void)
+{
+ return -ENODEV;
+}
+#endif
+
static int rpi_mem_init(void)
{
u32 size = 0;
@@ -141,6 +224,7 @@ static int rpi_devices_init(void)
{
armlinux_set_architecture(MACH_TYPE_BCM2708);
armlinux_set_bootparams((void *)(0x00000100));
+ rpi_fb_init();
rpi_env_init();
return 0;
}
--
1.8.3.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-10-24 20:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-24 20:23 [PATCH 0/6] simple framebuffer driver with RPi support Andre Heider
2013-10-24 20:23 ` [PATCH 1/6] fb: add a stride value to struct fb_info Andre Heider
2013-10-25 10:58 ` Jean-Christophe PLAGNIOL-VILLARD
2013-10-25 11:51 ` Andre Heider
2013-10-25 23:04 ` Sascha Hauer
2013-10-24 20:23 ` [PATCH 2/6] gui: convert graphic utils to respect the stride value Andre Heider
2013-10-24 20:23 ` [PATCH 3/6] gui: convert the bmp renderer " Andre Heider
2013-10-24 20:23 ` [PATCH 4/6] video: add a simple framebuffer driver Andre Heider
2013-10-24 20:23 ` [PATCH 5/6] ARM: bcm2835: add missing mbox overscan response field Andre Heider
2013-10-24 20:23 ` Andre Heider [this message]
2013-10-25 7:56 ` [PATCH 0/6] simple framebuffer driver with RPi support Andre Heider
2013-10-25 23:51 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1382646226-24871-7-git-send-email-a.heider@gmail.com \
--to=a.heider@gmail.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.