Newer Raspberry Pi firmware has changed the framebuffer from BGR to RGB.

The method we use to set the pixel order (vcprop set pixel order) does
not seem to work, nor does querying the pixel order (vcprop get pixel order).

The firmware passes this information to the kernel by adding a
"bcm2708_fb.fbswap" kernel cmdline arg. 0=BGR, 1=RGB. If the parameter is
absent, assume we are running on old firmware and use BGR mode.
This commit is contained in:
jmcneill 2015-01-21 11:02:55 +00:00
parent c56adf4dde
commit d415dbe367
1 changed files with 17 additions and 16 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: rpi_machdep.c,v 1.55 2014/10/07 08:37:18 mlelstv Exp $ */
/* $NetBSD: rpi_machdep.c,v 1.56 2015/01/21 11:02:55 jmcneill Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rpi_machdep.c,v 1.55 2014/10/07 08:37:18 mlelstv Exp $");
__KERNEL_RCSID(0, "$NetBSD: rpi_machdep.c,v 1.56 2015/01/21 11:02:55 jmcneill Exp $");
#include "opt_evbarm_boardtype.h"
#include "opt_ddb.h"
@ -296,7 +296,6 @@ static struct __aligned(16) {
struct vcprop_tag_fbres vbt_res;
struct vcprop_tag_fbres vbt_vres;
struct vcprop_tag_fbdepth vbt_depth;
struct vcprop_tag_fbpixelorder vbt_pixelorder;
struct vcprop_tag_fbalpha vbt_alpha;
struct vcprop_tag_allocbuf vbt_allocbuf;
struct vcprop_tag_blankscreen vbt_blank;
@ -334,14 +333,6 @@ static struct __aligned(16) {
},
.bpp = 32,
},
.vbt_pixelorder = {
.tag = {
.vpt_tag = VCPROPTAG_SET_FB_PIXEL_ORDER,
.vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_pixelorder),
.vpt_rcode = VCPROPTAG_REQUEST,
},
.state = VCPROP_PIXEL_BGR,
},
.vbt_alpha = {
.tag = {
.vpt_tag = VCPROPTAG_SET_FB_ALPHA_MODE,
@ -750,6 +741,7 @@ rpi_fb_init(prop_dictionary_t dict, void *aux)
char *ptr;
int integer;
int error;
bool is_bgr = true;
if (get_bootconf_option(boot_args, "fb",
BOOTOPT_TYPE_STRING, &ptr)) {
@ -779,7 +771,6 @@ rpi_fb_init(prop_dictionary_t dict, void *aux)
!vcprop_tag_success_p(&vb_setfb.vbt_res.tag) ||
!vcprop_tag_success_p(&vb_setfb.vbt_vres.tag) ||
!vcprop_tag_success_p(&vb_setfb.vbt_depth.tag) ||
!vcprop_tag_success_p(&vb_setfb.vbt_pixelorder.tag) ||
!vcprop_tag_success_p(&vb_setfb.vbt_allocbuf.tag) ||
!vcprop_tag_success_p(&vb_setfb.vbt_blank.tag) ||
!vcprop_tag_success_p(&vb_setfb.vbt_pitch.tag)) {
@ -798,8 +789,6 @@ rpi_fb_init(prop_dictionary_t dict, void *aux)
vb_setfb.vbt_res.width, vb_setfb.vbt_res.height);
printf("%s: vwidth = %d vheight = %d\n", __func__,
vb_setfb.vbt_vres.width, vb_setfb.vbt_vres.height);
printf("%s: pixelorder = %d\n", __func__,
vb_setfb.vbt_pixelorder.state);
#endif
if (vb_setfb.vbt_allocbuf.address == 0 ||
@ -821,8 +810,20 @@ rpi_fb_init(prop_dictionary_t dict, void *aux)
vb_setfb.vbt_pitch.linebytes);
prop_dictionary_set_uint32(dict, "address",
vb_setfb.vbt_allocbuf.address);
if (vb_setfb.vbt_pixelorder.state == VCPROP_PIXEL_BGR)
prop_dictionary_set_bool(dict, "is_bgr", true);
/*
* Old firmware uses BGR. New firmware uses RGB. The get and set
* pixel order mailbox properties don't seem to work. The firmware
* adds a kernel cmdline option bcm2708_fb.fbswap=<0|1>, so use it
* to determine pixel order. 0 means BGR, 1 means RGB.
*
* See https://github.com/raspberrypi/linux/issues/514
*/
if (get_bootconf_option(boot_args, "bcm2708_fb.fbswap",
BOOTOPT_TYPE_INT, &integer)) {
is_bgr = integer == 0;
}
prop_dictionary_set_bool(dict, "is_bgr", is_bgr);
/* if "genfb.type=<n>" is passed in cmdline, override wsdisplay type */
if (get_bootconf_option(boot_args, "genfb.type",