* [PATCH 1/6] fb: add a stride value to struct fb_info
2013-10-24 20:23 [PATCH 0/6] simple framebuffer driver with RPi support Andre Heider
@ 2013-10-24 20:23 ` Andre Heider
2013-10-25 10:58 ` Jean-Christophe PLAGNIOL-VILLARD
2013-10-24 20:23 ` [PATCH 2/6] gui: convert graphic utils to respect the stride value Andre Heider
` (5 subsequent siblings)
6 siblings, 1 reply; 12+ messages in thread
From: Andre Heider @ 2013-10-24 20:23 UTC (permalink / raw)
To: barebox
Add support for framebuffers with noncontiguous horizontal lines.
Video drivers can set this value if the hardware requires it.
In case a driver does not set it, the current value of
xres * (bpp / 8) is used instead.
Signed-off-by: Andre Heider <a.heider@gmail.com>
---
drivers/video/fb.c | 11 +++++++++--
include/fb.h | 1 +
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/video/fb.c b/drivers/video/fb.c
index 420e4e3..e80fab9 100644
--- a/drivers/video/fb.c
+++ b/drivers/video/fb.c
@@ -72,12 +72,16 @@ static int fb_setup_mode(struct device_d *dev, struct param_d *param,
info->xres = info->mode->xres;
info->yres = info->mode->yres;
+ info->stride = 0;
ret = info->fbops->fb_activate_var(info);
+ if (!info->stride)
+ info->stride = info->xres * (info->bits_per_pixel >> 3);
+
if (!ret) {
dev->resource[0].start = (resource_size_t)info->screen_base;
- info->cdev.size = info->xres * info->yres * (info->bits_per_pixel >> 3);
+ info->cdev.size = info->stride * info->yres;
dev->resource[0].end = dev->resource[0].start + info->cdev.size - 1;
dev_param_set_generic(dev, param, val);
} else
@@ -122,9 +126,12 @@ int register_framebuffer(struct fb_info *info)
dev = &info->dev;
+ if (!info->stride)
+ info->stride = info->xres * (info->bits_per_pixel >> 3);
+
info->cdev.ops = &fb_ops;
info->cdev.name = asprintf("fb%d", id);
- info->cdev.size = info->xres * info->yres * (info->bits_per_pixel >> 3);
+ info->cdev.size = info->stride * info->yres;
info->cdev.dev = dev;
info->cdev.priv = info;
dev->resource = xzalloc(sizeof(struct resource));
diff --git a/include/fb.h b/include/fb.h
index df4ba8e..ba46954 100644
--- a/include/fb.h
+++ b/include/fb.h
@@ -94,6 +94,7 @@ struct fb_info {
u32 xres; /* visible resolution */
u32 yres;
u32 bits_per_pixel; /* guess what */
+ u32 stride; /* number of bytes in each line */
u32 grayscale; /* != 0 Graylevels instead of colors */
--
1.8.3.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/6] fb: add a stride value to struct fb_info
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
0 siblings, 2 replies; 12+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-10-25 10:58 UTC (permalink / raw)
To: Andre Heider; +Cc: barebox
On 22:23 Thu 24 Oct , Andre Heider wrote:
> Add support for framebuffers with noncontiguous horizontal lines.
>
> Video drivers can set this value if the hardware requires it.
> In case a driver does not set it, the current value of
> xres * (bpp / 8) is used instead.
we never use this in linux ever
so do not do this in barebox either
Best Regards,
J.
>
> Signed-off-by: Andre Heider <a.heider@gmail.com>
> ---
> drivers/video/fb.c | 11 +++++++++--
> include/fb.h | 1 +
> 2 files changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/video/fb.c b/drivers/video/fb.c
> index 420e4e3..e80fab9 100644
> --- a/drivers/video/fb.c
> +++ b/drivers/video/fb.c
> @@ -72,12 +72,16 @@ static int fb_setup_mode(struct device_d *dev, struct param_d *param,
>
> info->xres = info->mode->xres;
> info->yres = info->mode->yres;
> + info->stride = 0;
>
> ret = info->fbops->fb_activate_var(info);
>
> + if (!info->stride)
> + info->stride = info->xres * (info->bits_per_pixel >> 3);
> +
> if (!ret) {
> dev->resource[0].start = (resource_size_t)info->screen_base;
> - info->cdev.size = info->xres * info->yres * (info->bits_per_pixel >> 3);
> + info->cdev.size = info->stride * info->yres;
> dev->resource[0].end = dev->resource[0].start + info->cdev.size - 1;
> dev_param_set_generic(dev, param, val);
> } else
> @@ -122,9 +126,12 @@ int register_framebuffer(struct fb_info *info)
>
> dev = &info->dev;
>
> + if (!info->stride)
> + info->stride = info->xres * (info->bits_per_pixel >> 3);
> +
> info->cdev.ops = &fb_ops;
> info->cdev.name = asprintf("fb%d", id);
> - info->cdev.size = info->xres * info->yres * (info->bits_per_pixel >> 3);
> + info->cdev.size = info->stride * info->yres;
> info->cdev.dev = dev;
> info->cdev.priv = info;
> dev->resource = xzalloc(sizeof(struct resource));
> diff --git a/include/fb.h b/include/fb.h
> index df4ba8e..ba46954 100644
> --- a/include/fb.h
> +++ b/include/fb.h
> @@ -94,6 +94,7 @@ struct fb_info {
> u32 xres; /* visible resolution */
> u32 yres;
> u32 bits_per_pixel; /* guess what */
> + u32 stride; /* number of bytes in each line */
>
> u32 grayscale; /* != 0 Graylevels instead of colors */
>
> --
> 1.8.3.2
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/6] fb: add a stride value to struct fb_info
2013-10-25 10:58 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2013-10-25 11:51 ` Andre Heider
2013-10-25 23:04 ` Sascha Hauer
1 sibling, 0 replies; 12+ messages in thread
From: Andre Heider @ 2013-10-25 11:51 UTC (permalink / raw)
To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox
On Fri, Oct 25, 2013 at 12:58:27PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 22:23 Thu 24 Oct , Andre Heider wrote:
> > Add support for framebuffers with noncontiguous horizontal lines.
> >
> > Video drivers can set this value if the hardware requires it.
> > In case a driver does not set it, the current value of
> > xres * (bpp / 8) is used instead.
>
> we never use this in linux ever
>
> so do not do this in barebox either
I assume you mean the provided fallback value?
And consequently converting all drivers to set the introduced stride
value themselves?
In that case, I considered doing that. I just don't have the hardware to
test all the drivers that's going to touch.
Thanks,
Andre
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/6] fb: add a stride value to struct fb_info
2013-10-25 10:58 ` Jean-Christophe PLAGNIOL-VILLARD
2013-10-25 11:51 ` Andre Heider
@ 2013-10-25 23:04 ` Sascha Hauer
1 sibling, 0 replies; 12+ messages in thread
From: Sascha Hauer @ 2013-10-25 23:04 UTC (permalink / raw)
To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox
On Fri, Oct 25, 2013 at 12:58:27PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 22:23 Thu 24 Oct , Andre Heider wrote:
> > Add support for framebuffers with noncontiguous horizontal lines.
> >
> > Video drivers can set this value if the hardware requires it.
> > In case a driver does not set it, the current value of
> > xres * (bpp / 8) is used instead.
>
> we never use this in linux ever
>
> so do not do this in barebox either
Liunux has this value aswell. It's just called line_length there. As we
mostly resemble the fbdev API we should name it like this in barebox
aswell.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 2/6] gui: convert graphic utils to respect the stride value
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-24 20:23 ` Andre Heider
2013-10-24 20:23 ` [PATCH 3/6] gui: convert the bmp renderer " Andre Heider
` (4 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Andre Heider @ 2013-10-24 20:23 UTC (permalink / raw)
To: barebox
Signed-off-by: Andre Heider <a.heider@gmail.com>
---
lib/gui/graphic_utils.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/gui/graphic_utils.c b/lib/gui/graphic_utils.c
index 95687df..9d80fe4 100644
--- a/lib/gui/graphic_utils.c
+++ b/lib/gui/graphic_utils.c
@@ -167,18 +167,18 @@ void rgba_blend(struct fb_info *info, struct image *img, void* buf, int height,
{
unsigned char *adr;
int x, y;
- int xres;
+ int stride;
int img_byte_per_pixel = 3;
void *image;
if (is_rgba)
img_byte_per_pixel++;
- xres = info->xres;
+ stride = info->stride;
for (y = 0; y < height; y++) {
- adr = buf + ((y + starty) * xres + startx) *
- (info->bits_per_pixel >> 3);
+ adr = buf + (y + starty) * stride +
+ startx * (info->bits_per_pixel >> 3);
image = img->data + (y * img->width *img_byte_per_pixel);
for (x = 0; x < width; x++) {
@@ -219,7 +219,7 @@ int fb_open(const char * fbdev, struct screen *sc, bool offscreen)
sc->s.y = 0;
sc->s.width = sc->info.xres;
sc->s.height = sc->info.yres;
- sc->fbsize = sc->s.width * sc->s.height * (sc->info.bits_per_pixel >> 3);
+ sc->fbsize = sc->info.stride * sc->s.height;
if (offscreen) {
/* Don't fail if malloc fails, just continue rendering directly
--
1.8.3.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/6] gui: convert the bmp renderer to respect the stride value
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-24 20:23 ` [PATCH 2/6] gui: convert graphic utils to respect the stride value Andre Heider
@ 2013-10-24 20:23 ` Andre Heider
2013-10-24 20:23 ` [PATCH 4/6] video: add a simple framebuffer driver Andre Heider
` (3 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Andre Heider @ 2013-10-24 20:23 UTC (permalink / raw)
To: barebox
Signed-off-by: Andre Heider <a.heider@gmail.com>
---
lib/gui/bmp.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/gui/bmp.c b/lib/gui/bmp.c
index 6bf8cd0..bb4de12 100644
--- a/lib/gui/bmp.c
+++ b/lib/gui/bmp.c
@@ -78,8 +78,8 @@ static int bmp_renderer(struct screen *sc, struct surface *s, struct image *img)
image = (char *)bmp +
le32_to_cpu(bmp->header.data_offset);
image += (img->height - y - 1) * img->width * (bits_per_pixel >> 3);
- adr = buf + ((y + starty) * sc->s.width + startx) *
- (sc->info.bits_per_pixel >> 3);
+ adr = buf + (y + starty) * sc->info.stride +
+ startx * (sc->info.bits_per_pixel >> 3);
for (x = 0; x < width; x++) {
int pixel;
@@ -100,8 +100,8 @@ static int bmp_renderer(struct screen *sc, struct surface *s, struct image *img)
image = (char *)bmp +
le32_to_cpu(bmp->header.data_offset);
image += (img->height - y - 1) * img->width * (bits_per_pixel >> 3);
- adr = buf + ((y + starty) * sc->s.width + startx) *
- (sc->info.bits_per_pixel >> 3);
+ adr = buf + (y + starty) * sc->info.stride +
+ startx * (sc->info.bits_per_pixel >> 3);
for (x = 0; x < width; x++) {
char *pixel;
--
1.8.3.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 4/6] video: add a simple framebuffer driver
2013-10-24 20:23 [PATCH 0/6] simple framebuffer driver with RPi support Andre Heider
` (2 preceding siblings ...)
2013-10-24 20:23 ` [PATCH 3/6] gui: convert the bmp renderer " Andre Heider
@ 2013-10-24 20:23 ` Andre Heider
2013-10-24 20:23 ` [PATCH 5/6] ARM: bcm2835: add missing mbox overscan response field Andre Heider
` (2 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Andre Heider @ 2013-10-24 20:23 UTC (permalink / raw)
To: barebox
This architecture independend driver implements a framebuffer driver
based on a raw memory region that may be rendered to.
It is the counterpart of the kernel driver with the same name.
Platforms can configure display devices to scan out from such a memory
region and set it up with a single function call.
Doing so provides a framebuffer driver for barebox and a configuration
of the corresponding kernel driver through device tree.
Signed-off-by: Andre Heider <a.heider@gmail.com>
---
drivers/video/Kconfig | 12 +++
drivers/video/Makefile | 1 +
drivers/video/simplefb.c | 224 +++++++++++++++++++++++++++++++++++++++++++++++
include/video/simplefb.h | 21 +++++
4 files changed, 258 insertions(+)
create mode 100644 drivers/video/simplefb.c
create mode 100644 include/video/simplefb.h
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 0639d9c..9afa7e8 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -71,4 +71,16 @@ config DRIVER_VIDEO_PXA
Add support for the frame buffer device found on the PXA270
CPU.
+config DRIVER_VIDEO_SIMPLEFB
+ bool "Simple framebuffer support"
+ depends on OFTREE
+ depends on ARCH_BCM2835
+ help
+ Say Y if you want support for a simple frame-buffer.
+
+ This driver provides the framebuffer configuration to the kernel
+ through device tree.
+
+ The corresponding kernel driver has to be enabled to use this feature.
+
endif
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 67169d1..0da7c2b 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -9,3 +9,4 @@ obj-$(CONFIG_DRIVER_VIDEO_S3C24XX) += s3c24xx.o
obj-$(CONFIG_DRIVER_VIDEO_PXA) += pxa.o
obj-$(CONFIG_DRIVER_VIDEO_SDL) += sdl.o
obj-$(CONFIG_DRIVER_VIDEO_OMAP) += omap.o
+obj-$(CONFIG_DRIVER_VIDEO_SIMPLEFB) += simplefb.o
diff --git a/drivers/video/simplefb.c b/drivers/video/simplefb.c
new file mode 100644
index 0000000..f096c36
--- /dev/null
+++ b/drivers/video/simplefb.c
@@ -0,0 +1,224 @@
+/*
+ * SimpleFB driver
+ *
+ * Copyright (C) 2013 Andre Heider
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <errno.h>
+#include <malloc.h>
+#include <xfuncs.h>
+#include <common.h>
+#include <init.h>
+#include <stdio.h>
+#include <driver.h>
+#include <fb.h>
+
+#include <video/simplefb.h>
+
+struct simplefb_platform_data {
+ u32 width;
+ u32 height;
+ u32 stride;
+ enum simplefb_format format;
+ struct fb_info fbi;
+ struct fb_videomode mode;
+};
+
+struct device_d *add_simplefb_device(u32 width, u32 height, u32 stride,
+ enum simplefb_format format,
+ resource_size_t start,
+ resource_size_t size)
+{
+ struct simplefb_platform_data *pdata;
+ struct device_d *dev;
+
+ pdata = xzalloc(sizeof *pdata);
+ pdata->width = width;
+ pdata->height = height;
+ pdata->stride = stride;
+ pdata->format = format;
+
+ dev = add_generic_device("simplefb", DEVICE_ID_SINGLE,
+ NULL, start, size,
+ IORESOURCE_MEM, pdata);
+
+ if (!dev)
+ free(pdata);
+
+ return dev;
+}
+
+struct simplefb_info {
+ enum simplefb_format id;
+ const char *compatible;
+ u32 bpp;
+ struct fb_bitfield red;
+ struct fb_bitfield green;
+ struct fb_bitfield blue;
+};
+
+/*
+ * These values have to match the kernel's simplefb driver.
+ * See Documentation/devicetree/bindings/video/simple-framebuffer.txt
+ */
+static const struct simplefb_info simplefb_infos[] = {
+ {
+ .id = SIMPLEFB_R5G6B5,
+ .compatible = "r5g6b5",
+ .bpp = 16,
+ .red = { .length = 5, .offset = 11 },
+ .green = { .length = 6, .offset = 5 },
+ .blue = { .length = 5, .offset = 0 },
+ },
+};
+
+static const struct simplefb_info *simplefb_get_info(enum simplefb_format id)
+{
+ u32 i;
+
+ for (i = 0; i < ARRAY_SIZE(simplefb_infos); ++i)
+ if (simplefb_infos[i].id == id)
+ return &simplefb_infos[i];
+
+ return NULL;
+}
+
+static int simplefb_create_node(struct device_node *root,
+ const struct simplefb_platform_data *pdata,
+ const struct resource *res)
+{
+ const char compat[] = "simple-framebuffer";
+ const char disabled[] = "disabled";
+ const char okay[] = "okay";
+ const struct simplefb_info *info;
+ struct device_node *node;
+ u32 cells[2];
+ int ret;
+
+ info = simplefb_get_info(pdata->format);
+ if (!info)
+ return -EINVAL;
+
+ node = of_create_node(root, "/framebuffer");
+ if (!node)
+ return -ENOMEM;
+
+ ret = of_set_property(node, "status", disabled,
+ strlen(disabled) + 1, 1);
+ if (ret < 0)
+ return ret;
+
+ ret = of_set_property(node, "compatible", compat, sizeof(compat), 1);
+ if (ret)
+ return ret;
+
+ cells[0] = cpu_to_be32(res->start);
+ cells[1] = cpu_to_be32(resource_size(res));
+ ret = of_set_property(node, "reg", cells, sizeof(cells[0]) * 2, 1);
+ if (ret < 0)
+ return ret;
+
+ cells[0] = cpu_to_be32(pdata->width);
+ ret = of_set_property(node, "width", cells, sizeof(cells[0]), 1);
+ if (ret < 0)
+ return ret;
+
+ cells[0] = cpu_to_be32(pdata->height);
+ ret = of_set_property(node, "height", cells, sizeof(cells[0]), 1);
+ if (ret < 0)
+ return ret;
+
+ cells[0] = cpu_to_be32(pdata->stride);
+ ret = of_set_property(node, "stride", cells, sizeof(cells[0]), 1);
+ if (ret < 0)
+ return ret;
+
+ ret = of_set_property(node, "format", info->compatible,
+ strlen(info->compatible) + 1, 1);
+ if (ret < 0)
+ return ret;
+
+ return of_set_property(node, "status", okay, strlen(okay) + 1, 1);
+}
+
+static int simplefb_of_fixup(struct device_node *root)
+{
+ struct device_d *dev;
+ struct simplefb_platform_data *pdata;
+ struct resource *res;
+
+ dev = get_device_by_name("simplefb");
+ if (!dev)
+ return 0;
+
+ pdata = dev->platform_data;
+ if (!pdata)
+ return 0;
+
+ res = dev_get_resource(dev, 0);
+ if (!res)
+ return 0;
+
+ simplefb_create_node(root, pdata, res);
+
+ return 0;
+}
+
+static void simplefb_enable(struct fb_info *info)
+{
+}
+
+static void simplefb_disable(struct fb_info *info)
+{
+}
+
+static struct fb_ops simplefb_ops = {
+ .fb_enable = simplefb_enable,
+ .fb_disable = simplefb_disable,
+};
+
+static int simplefb_probe(struct device_d *dev)
+{
+ struct simplefb_platform_data *pdata = dev->platform_data;
+ const struct simplefb_info *info;
+ struct resource *res;
+ int ret;
+
+ info = simplefb_get_info(pdata->format);
+ if (!info)
+ return -EINVAL;
+
+ res = dev_get_resource(dev, 0);
+ if (!res)
+ return -EINVAL;
+
+ pdata->fbi.fbops = &simplefb_ops;
+ pdata->fbi.screen_base = (void *)res->start;
+ pdata->fbi.xres = pdata->width;
+ pdata->fbi.yres = pdata->height;
+ pdata->fbi.bits_per_pixel = info->bpp;
+ pdata->fbi.stride = pdata->stride;
+ pdata->fbi.red = info->red;
+ pdata->fbi.green = info->green;
+ pdata->fbi.blue = info->blue;
+
+ pdata->fbi.mode = &pdata->mode;
+ pdata->fbi.mode->xres = pdata->width;
+ pdata->fbi.mode->yres = pdata->height;
+
+ ret = register_framebuffer(&pdata->fbi);
+ if (ret < 0)
+ return ret;
+
+ of_register_fixup(simplefb_of_fixup);
+
+ return 0;
+}
+
+static struct driver_d simplefb_driver = {
+ .name = "simplefb",
+ .probe = simplefb_probe,
+};
+device_platform_driver(simplefb_driver);
diff --git a/include/video/simplefb.h b/include/video/simplefb.h
new file mode 100644
index 0000000..5949046
--- /dev/null
+++ b/include/video/simplefb.h
@@ -0,0 +1,21 @@
+/*
+ * SimpleFB driver
+ *
+ * Copyright (C) 2013 Andre Heider
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef SIMPLEFB_H
+#define SIMPLEFB_H
+
+enum simplefb_format {
+ SIMPLEFB_R5G6B5
+};
+
+struct device_d *add_simplefb_device(u32 width, u32 height, u32 stride,
+ enum simplefb_format format,
+ resource_size_t start,
+ resource_size_t size);
+
+#endif
--
1.8.3.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 5/6] ARM: bcm2835: add missing mbox overscan response field
2013-10-24 20:23 [PATCH 0/6] simple framebuffer driver with RPi support Andre Heider
` (3 preceding siblings ...)
2013-10-24 20:23 ` [PATCH 4/6] video: add a simple framebuffer driver Andre Heider
@ 2013-10-24 20:23 ` Andre Heider
2013-10-24 20:23 ` [PATCH 6/6] ARM: rpi: add support for simplefb Andre Heider
2013-10-25 7:56 ` [PATCH 0/6] simple framebuffer driver with RPi support Andre Heider
6 siblings, 0 replies; 12+ messages in thread
From: Andre Heider @ 2013-10-24 20:23 UTC (permalink / raw)
To: barebox
Add the missing "right" field to struct bcm2835_mbox_tag_overscan.
Signed-off-by: Andre Heider <a.heider@gmail.com>
---
arch/arm/mach-bcm2835/include/mach/mbox.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm/mach-bcm2835/include/mach/mbox.h b/arch/arm/mach-bcm2835/include/mach/mbox.h
index 6c36389..fb8a9bf 100644
--- a/arch/arm/mach-bcm2835/include/mach/mbox.h
+++ b/arch/arm/mach-bcm2835/include/mach/mbox.h
@@ -355,6 +355,7 @@ struct bcm2835_mbox_tag_overscan {
u32 top;
u32 bottom;
u32 left;
+ u32 right;
} resp;
} body;
};
--
1.8.3.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 6/6] ARM: rpi: add support for simplefb
2013-10-24 20:23 [PATCH 0/6] simple framebuffer driver with RPi support Andre Heider
` (4 preceding siblings ...)
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
2013-10-25 7:56 ` [PATCH 0/6] simple framebuffer driver with RPi support Andre Heider
6 siblings, 0 replies; 12+ messages in thread
From: Andre Heider @ 2013-10-24 20:23 UTC (permalink / raw)
To: barebox
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/6] simple framebuffer driver with RPi support
2013-10-24 20:23 [PATCH 0/6] simple framebuffer driver with RPi support Andre Heider
` (5 preceding siblings ...)
2013-10-24 20:23 ` [PATCH 6/6] ARM: rpi: add support for simplefb Andre Heider
@ 2013-10-25 7:56 ` Andre Heider
2013-10-25 23:51 ` Sascha Hauer
6 siblings, 1 reply; 12+ messages in thread
From: Andre Heider @ 2013-10-25 7:56 UTC (permalink / raw)
To: barebox
On Thu, Oct 24, 2013 at 10:23:40PM +0200, Andre Heider wrote:
> This set adds a common simple framebuffer driver for platforms which choose
> to support it. RPi support is part of this set.
>
> The driver serves two functions:
> * a framebuffer driver for barebox
> * pass an active framebuffer configuration to a loaded kernel
Pondering over this again, this is probably the wrong approach. There's
no need for a distinct simplefb driver for barebox, bcm2835 can have its own
fb driver like everyone else, and the simplefb configuration for the
kernel can be done independent of the fb barebox driver in use...
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/6] simple framebuffer driver with RPi support
2013-10-25 7:56 ` [PATCH 0/6] simple framebuffer driver with RPi support Andre Heider
@ 2013-10-25 23:51 ` Sascha Hauer
0 siblings, 0 replies; 12+ messages in thread
From: Sascha Hauer @ 2013-10-25 23:51 UTC (permalink / raw)
To: Andre Heider; +Cc: barebox
On Fri, Oct 25, 2013 at 09:56:51AM +0200, Andre Heider wrote:
> On Thu, Oct 24, 2013 at 10:23:40PM +0200, Andre Heider wrote:
> > This set adds a common simple framebuffer driver for platforms which choose
> > to support it. RPi support is part of this set.
> >
> > The driver serves two functions:
> > * a framebuffer driver for barebox
> > * pass an active framebuffer configuration to a loaded kernel
>
> Pondering over this again, this is probably the wrong approach. There's
> no need for a distinct simplefb driver for barebox, bcm2835 can have its own
> fb driver like everyone else,
Right,
> and the simplefb configuration for the
> kernel can be done independent of the fb barebox driver in use...
Yes.
I think we should have an option whether a framebuffer should be kept
enabled when starting a kernel. If yes, then we have to resever the
memory for the framebuffer and create the simplefb node. If not, we have
to disable the framebuffer.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 12+ messages in thread