Page MenuHomeFreeBSD

D61766.1795428560.diff
No OneTemporary

Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None

D61766.1795428560.diff

diff --git a/sys/arm/broadcom/bcm2835/bcm2835_fbd.c b/sys/arm/broadcom/bcm2835/bcm2835_fbd.c
--- a/sys/arm/broadcom/bcm2835/bcm2835_fbd.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_fbd.c
@@ -103,6 +103,10 @@
return (ENXIO);
}
+ /* Not fatal: without it the colors keep the default layout. */
+ fb->pixel_order = BCM2835_MBOX_PIXEL_ORDER_UNKNOWN;
+ (void)bcm2835_mbox_fb_get_pixel_order(fb);
+
return (0);
}
@@ -132,19 +136,36 @@
sc->info.fb_memattr = VM_MEMATTR_WRITE_COMBINING;
#endif
- if (sc->fbswap) {
- switch (sc->info.fb_bpp) {
- case 24:
+ switch (sc->info.fb_bpp) {
+ case 24:
+ if (sc->fbswap) {
vt_config_cons_colors(&sc->info,
COLOR_FORMAT_RGB, 0xff, 0, 0xff, 8, 0xff, 16);
sc->info.fb_cmsize = 16;
+ }
+ break;
+ case 32:
+ /*
+ * The order of the pixels is the pixel order that was
+ * requested through the mailbox (U-Boot asks for RGB)
+ * combined with framebuffer_swap in config.txt, which the
+ * firmware reports as bcm2708_fb.fbswap=1 in the bootargs
+ * (it is the default). The firmware inverts the requested
+ * order relative to framebuffer_swap: when the two differ
+ * the red component is in bits 16-23, which is the default
+ * layout of vt(4), when they are the same it is in bits
+ * 0-7. The firmware does not report the resulting order
+ * itself.
+ */
+ if (fb.pixel_order == BCM2835_MBOX_PIXEL_ORDER_UNKNOWN)
break;
- case 32:
+ if ((fb.pixel_order == BCM2835_MBOX_PIXEL_ORDER_RGB) ==
+ (sc->fbswap != 0)) {
vt_config_cons_colors(&sc->info,
- COLOR_FORMAT_RGB, 0xff, 16, 0xff, 8, 0xff, 0);
+ COLOR_FORMAT_RGB, 0xff, 0, 0xff, 8, 0xff, 16);
sc->info.fb_cmsize = 16;
- break;
}
+ break;
}
fbd = device_add_child(sc->dev, "fbd", device_get_unit(sc->dev));
@@ -162,8 +183,9 @@
device_printf(sc->dev, "%dx%d(%dx%d@%d,%d) %dbpp\n", fb.xres, fb.yres,
fb.vxres, fb.vyres, fb.xoffset, fb.yoffset, fb.bpp);
device_printf(sc->dev,
- "fbswap: %d, pitch %d, base 0x%08x, screen_size %d\n",
- sc->fbswap, fb.pitch, fb.base, fb.size);
+ "fbswap: %d, pixel order: %d, pitch %d, base 0x%08x, "
+ "screen_size %d\n", sc->fbswap, (int)fb.pixel_order, fb.pitch,
+ fb.base, fb.size);
return (0);
}
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_mbox.c b/sys/arm/broadcom/bcm2835/bcm2835_mbox.c
--- a/sys/arm/broadcom/bcm2835/bcm2835_mbox.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_mbox.c
@@ -550,6 +550,26 @@
return (err);
}
+int
+bcm2835_mbox_fb_get_pixel_order(struct bcm2835_fb_config *fb)
+{
+ int err;
+ struct msg_fb_get_pixel_order msg;
+
+ memset(&msg, 0, sizeof(msg));
+ msg.hdr.buf_size = sizeof(msg);
+ msg.hdr.code = BCM2835_MBOX_CODE_REQ;
+ BCM2835_MBOX_INIT_TAG(&msg.pixel_order, GET_PIXEL_ORDER);
+ msg.pixel_order.tag_hdr.val_len = 0;
+ msg.end_tag = 0;
+
+ err = bcm2835_mbox_property(&msg, sizeof(msg));
+ if (err == 0)
+ fb->pixel_order = msg.pixel_order.body.resp.order;
+
+ return (err);
+}
+
int
bcm2835_mbox_fb_init(struct bcm2835_fb_config *fb)
{
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_mbox_prop.h b/sys/arm/broadcom/bcm2835/bcm2835_mbox_prop.h
--- a/sys/arm/broadcom/bcm2835/bcm2835_mbox_prop.h
+++ b/sys/arm/broadcom/bcm2835/bcm2835_mbox_prop.h
@@ -322,6 +322,24 @@
} body;
};
+#define BCM2835_MBOX_TAG_GET_PIXEL_ORDER 0x00040006
+#define BCM2835_MBOX_TAG_SET_PIXEL_ORDER 0x00048006
+
+#define BCM2835_MBOX_PIXEL_ORDER_BGR 0
+#define BCM2835_MBOX_PIXEL_ORDER_RGB 1
+
+struct bcm2835_mbox_tag_pixel_order {
+ struct bcm2835_mbox_tag_hdr tag_hdr;
+ union {
+ struct {
+ uint32_t order;
+ } req;
+ struct {
+ uint32_t order;
+ } resp;
+ } body;
+};
+
#define BCM2835_MBOX_TAG_GET_ALPHA_MODE 0x00040007
#define BCM2835_MBOX_TAG_SET_ALPHA_MODE 0x00048007
@@ -424,8 +442,12 @@
uint32_t pitch;
uint32_t base;
uint32_t size;
+ uint32_t pixel_order; /* BCM2835_MBOX_PIXEL_ORDER_*, or _UNKNOWN */
};
+/* Not a firmware value: the pixel order could not be read. */
+#define BCM2835_MBOX_PIXEL_ORDER_UNKNOWN 0xffffffff
+
struct msg_fb_get_w_h {
struct bcm2835_mbox_hdr hdr;
struct bcm2835_mbox_tag_fb_w_h physical_w_h;
@@ -442,6 +464,14 @@
int bcm2835_mbox_fb_get_bpp(struct bcm2835_fb_config *);
+struct msg_fb_get_pixel_order {
+ struct bcm2835_mbox_hdr hdr;
+ struct bcm2835_mbox_tag_pixel_order pixel_order;
+ uint32_t end_tag;
+};
+
+int bcm2835_mbox_fb_get_pixel_order(struct bcm2835_fb_config *);
+
struct msg_fb_setup {
struct bcm2835_mbox_hdr hdr;
struct bcm2835_mbox_tag_fb_w_h physical_w_h;

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 23, 10:09 AM (13 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41872701
Default Alt Text
D61766.1795428560.diff (4 KB)

Event Timeline