drivers: Replace set_vbe_mode_info_valid

Currently it's not possible to add multiple graphics driver into
one coreboot image. This patch series will fix this issue by providing
a single API that multiple graphics driver can use.

This is required for platforms that have two graphic cards, but
different graphic drivers, like Intel+Aspeed on server platforms or
Intel+Nvidia on consumer notebooks.

The goal is to remove duplicated fill_fb_framebuffer(), the advertisment
of multiple indepent framebuffers in coreboot tables, and better
runtime/build time graphic configuration options.

Replace set_vbe_mode_info_valid with fb_add_framebuffer_info or
fb_new_framebuffer_info_from_edid.

Change-Id: I95d1d62385a201c68c6c2527c023ad2292a235c5
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/39004
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
This commit is contained in:
Patrick Rudolph 2020-02-19 12:57:00 +01:00 committed by Hung-Te Lin
parent 6c04b353c5
commit 8b56c8c6b2
18 changed files with 45 additions and 81 deletions

View File

@ -6,6 +6,7 @@
#include <console/console.h> #include <console/console.h>
#include <edid.h> #include <edid.h>
#include <device/pci_def.h> #include <device/pci_def.h>
#include <framebuffer_info.h>
#include "ast_drv.h" #include "ast_drv.h"
@ -200,7 +201,7 @@ int ast_driver_framebuffer_init(struct drm_device *dev, int flags)
return ret; return ret;
} }
/* Updated edid for set_vbe_mode_info_valid */ /* Updated edid for fb_fill_framebuffer_info */
edid.x_resolution = edid.mode.ha; edid.x_resolution = edid.mode.ha;
edid.y_resolution = edid.mode.va; edid.y_resolution = edid.mode.va;
edid.framebuffer_bits_per_pixel = format.cpp[0] * 8; edid.framebuffer_bits_per_pixel = format.cpp[0] * 8;
@ -227,7 +228,7 @@ int ast_driver_framebuffer_init(struct drm_device *dev, int flags)
ast_hide_cursor(&crtc); ast_hide_cursor(&crtc);
/* Advertise new mode */ /* Advertise new mode */
set_vbe_mode_info_valid(&edid, fb.mmio_addr); fb_new_framebuffer_info_from_edid(&edid, fb.mmio_addr);
/* Clear display */ /* Clear display */
memset((void *)(uintptr_t)fb.mmio_addr, 0, edid.bytes_per_line * edid.y_resolution); memset((void *)(uintptr_t)fb.mmio_addr, 0, edid.bytes_per_line * edid.y_resolution);

View File

@ -1,7 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */ /* SPDX-License-Identifier: GPL-2.0-only */
#include <stdint.h> #include <stdint.h>
#include <edid.h>
#include <arch/io.h> #include <arch/io.h>
#include <console/console.h> #include <console/console.h>
#include <device/device.h> #include <device/device.h>
@ -10,6 +9,7 @@
#include <device/pci_ids.h> #include <device/pci_ids.h>
#include <pc80/vga.h> #include <pc80/vga.h>
#include <pc80/vga_io.h> #include <pc80/vga_io.h>
#include <framebuffer_info.h>
/* VGA init. We use the Bochs VESA VBE extensions */ /* VGA init. We use the Bochs VESA VBE extensions */
#define VBE_DISPI_IOPORT_INDEX 0x01CE #define VBE_DISPI_IOPORT_INDEX 0x01CE
@ -82,7 +82,6 @@ static struct resource res_legacy = {
static void bochs_init_linear_fb(struct device *dev) static void bochs_init_linear_fb(struct device *dev)
{ {
struct edid edid;
struct resource *res_fb, *res_io; struct resource *res_fb, *res_io;
int id, mem, bar; int id, mem, bar;
@ -139,13 +138,8 @@ static void bochs_init_linear_fb(struct device *dev)
bochs_vga_write(res_io, 0, 0x20); /* disable blanking */ bochs_vga_write(res_io, 0, 0x20); /* disable blanking */
/* setup coreboot framebuffer */ /* Advertise new mode */
edid.mode.ha = width; fb_add_framebuffer_info(res_fb->base, width, height, 4 * width, 32);
edid.mode.va = height;
edid.panel_bits_per_color = 8;
edid.panel_bits_per_pixel = 24;
edid_set_framebuffer_bits_per_pixel(&edid, 32, 0);
set_vbe_mode_info_valid(&edid, res_fb->base);
} }
static void bochs_init_text_mode(struct device *dev) static void bochs_init_text_mode(struct device *dev)

View File

@ -1,13 +1,13 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */ /* SPDX-License-Identifier: GPL-2.0-or-later */
#include <stdint.h> #include <stdint.h>
#include <edid.h>
#include <console/console.h> #include <console/console.h>
#include <device/device.h> #include <device/device.h>
#include <device/pci.h> #include <device/pci.h>
#include <device/pci_ops.h> #include <device/pci_ops.h>
#include <pc80/vga.h> #include <pc80/vga.h>
#include <pc80/vga_io.h> #include <pc80/vga_io.h>
#include <framebuffer_info.h>
static int width = CONFIG_DRIVERS_EMULATION_QEMU_BOCHS_XRES; static int width = CONFIG_DRIVERS_EMULATION_QEMU_BOCHS_XRES;
static int height = CONFIG_DRIVERS_EMULATION_QEMU_BOCHS_YRES; static int height = CONFIG_DRIVERS_EMULATION_QEMU_BOCHS_YRES;
@ -299,13 +299,7 @@ static void cirrus_init_linear_fb(struct device *dev)
vga_sr_write (CIRRUS_SR_EXTENDED_MODE, sr_ext); vga_sr_write (CIRRUS_SR_EXTENDED_MODE, sr_ext);
write_hidden_dac (hidden_dac); write_hidden_dac (hidden_dac);
struct edid edid; fb_add_framebuffer_info(addr, width, height, 4 * width, 32);
edid.mode.ha = width;
edid.mode.va = height;
edid.panel_bits_per_color = 8;
edid.panel_bits_per_pixel = 24;
edid_set_framebuffer_bits_per_pixel(&edid, 32, 0);
set_vbe_mode_info_valid(&edid, addr);
} }
static void cirrus_init_text_mode(struct device *dev) static void cirrus_init_text_mode(struct device *dev)

View File

@ -96,8 +96,6 @@ enum edid_status {
int decode_edid(unsigned char *edid, int size, struct edid *out); int decode_edid(unsigned char *edid, int size, struct edid *out);
void edid_set_framebuffer_bits_per_pixel(struct edid *edid, int fb_bpp, void edid_set_framebuffer_bits_per_pixel(struct edid *edid, int fb_bpp,
int row_byte_alignment); int row_byte_alignment);
struct fb_info *set_vbe_mode_info_valid(const struct edid *edid, uintptr_t fb_addr);
void set_vbe_framebuffer_orientation(enum lb_fb_orientation orientation);
int set_display_mode(struct edid *edid, enum edid_modes mode); int set_display_mode(struct edid *edid, enum edid_modes mode);
#endif /* EDID_H */ #endif /* EDID_H */

View File

@ -19,4 +19,8 @@ struct fb_info *fb_add_framebuffer_info(uintptr_t fb_addr, uint32_t x_resolution
void fb_set_orientation(struct fb_info *info, void fb_set_orientation(struct fb_info *info,
enum lb_fb_orientation orientation); enum lb_fb_orientation orientation);
struct edid;
struct fb_info *fb_new_framebuffer_info_from_edid(const struct edid *edid,
uintptr_t fb_addr);
#endif /* __FRAMEBUFFER_INFO_H_ */ #endif /* __FRAMEBUFFER_INFO_H_ */

View File

@ -153,7 +153,8 @@ void fb_set_orientation(struct fb_info *info, enum lb_fb_orientation orientation
/* /*
* Take an edid, and create a framebuffer. * Take an edid, and create a framebuffer.
*/ */
struct fb_info *set_vbe_mode_info_valid(const struct edid *edid, uintptr_t fb_addr) struct fb_info *fb_new_framebuffer_info_from_edid(const struct edid *edid,
uintptr_t fb_addr)
{ {
return fb_add_framebuffer_info(fb_addr, edid->x_resolution, edid->y_resolution, return fb_add_framebuffer_info(fb_addr, edid->x_resolution, edid->y_resolution,
edid->bytes_per_line, edid->framebuffer_bits_per_pixel); edid->bytes_per_line, edid->framebuffer_bits_per_pixel);

View File

@ -4,15 +4,14 @@
#include <device/device.h> #include <device/device.h>
#include <cbmem.h> #include <cbmem.h>
#include <halt.h> #include <halt.h>
#include <edid.h>
#include <device/mmio.h> #include <device/mmio.h>
#include <ramdetect.h> #include <ramdetect.h>
#include <symbols.h> #include <symbols.h>
#include <framebuffer_info.h>
static void init_gfx(void) static void init_gfx(void)
{ {
uint32_t *pl111; uint32_t *pl111;
struct edid edid;
/* width is at most 4096 */ /* width is at most 4096 */
/* height is at most 1024 */ /* height is at most 1024 */
int width = 800, height = 600; int width = 800, height = 600;
@ -28,12 +27,7 @@ static void init_gfx(void)
write32(pl111 + 10, 0xff); write32(pl111 + 10, 0xff);
write32(pl111 + 6, (5 << 1) | 0x801); write32(pl111 + 6, (5 << 1) | 0x801);
edid.framebuffer_bits_per_pixel = 32; fb_add_framebuffer_info(framebuffer, width, height, 4 * width, 32);
edid.bytes_per_line = width * 4;
edid.x_resolution = width;
edid.y_resolution = height;
set_vbe_mode_info_valid(&edid, framebuffer);
} }
static void mainboard_enable(struct device *dev) static void mainboard_enable(struct device *dev)

View File

@ -8,6 +8,7 @@
#include <device/mmio.h> #include <device/mmio.h>
#include <drivers/analogix/anx7625/anx7625.h> #include <drivers/analogix/anx7625/anx7625.h>
#include <edid.h> #include <edid.h>
#include <framebuffer_info.h>
#include <gpio.h> #include <gpio.h>
#include <soc/ddp.h> #include <soc/ddp.h>
#include <soc/dpm.h> #include <soc/dpm.h>
@ -124,7 +125,7 @@ static bool configure_display(void)
return false; return false;
} }
mtk_ddp_mode_set(&edid); mtk_ddp_mode_set(&edid);
set_vbe_mode_info_valid(&edid, 0); fb_new_framebuffer_info_from_edid(&edid, (uintptr_t)0);
return true; return true;
} }

View File

@ -7,7 +7,6 @@
#include <device/device.h> #include <device/device.h>
#include <device/i2c_simple.h> #include <device/i2c_simple.h>
#include <drivers/ti/tps65090/tps65090.h> #include <drivers/ti/tps65090/tps65090.h>
#include <edid.h>
#include <soc/clk.h> #include <soc/clk.h>
#include <soc/dp.h> #include <soc/dp.h>
#include <soc/dp-core.h> #include <soc/dp-core.h>
@ -18,6 +17,7 @@
#include <soc/tmu.h> #include <soc/tmu.h>
#include <soc/usb.h> #include <soc/usb.h>
#include <symbols.h> #include <symbols.h>
#include <framebuffer_info.h>
#include "exynos5250.h" #include "exynos5250.h"
@ -28,15 +28,6 @@
#define DRAM_SIZE CONFIG_DRAM_SIZE_MB #define DRAM_SIZE CONFIG_DRAM_SIZE_MB
#define DRAM_END (DRAM_START + DRAM_SIZE) /* plus one... */ #define DRAM_END (DRAM_START + DRAM_SIZE) /* plus one... */
static struct edid edid = {
.mode.ha = 1366,
.mode.va = 768,
.framebuffer_bits_per_pixel = 16,
.x_resolution = 1366,
.y_resolution = 768,
.bytes_per_line = 2 * 1366
};
/* TODO: transplanted DP stuff, clean up once we have something that works */ /* TODO: transplanted DP stuff, clean up once we have something that works */
static enum exynos5_gpio_pin dp_pd_l = GPIO_Y25; /* active low */ static enum exynos5_gpio_pin dp_pd_l = GPIO_Y25; /* active low */
static enum exynos5_gpio_pin dp_rst_l = GPIO_X15; /* active low */ static enum exynos5_gpio_pin dp_rst_l = GPIO_X15; /* active low */
@ -263,7 +254,7 @@ static void mainboard_init(struct device *dev)
sdmmc_vdd(); sdmmc_vdd();
set_vbe_mode_info_valid(&edid, (uintptr_t)fb_addr); fb_add_framebuffer_info((uintptr_t)fb_addr, 1366, 768, 2 * 1366, 16);
lcd_vdd(); lcd_vdd();

View File

@ -169,7 +169,7 @@ static bool configure_display(void)
return false; return false;
} }
mtk_ddp_mode_set(edid); mtk_ddp_mode_set(edid);
struct fb_info *info = set_vbe_mode_info_valid(edid, 0); struct fb_info *info = fb_new_framebuffer_info_from_edid(edid, 0);
if (info) if (info)
fb_set_orientation(info, panel->s->orientation); fb_set_orientation(info, panel->s->orientation);

View File

@ -18,6 +18,7 @@
#include <soc/pll.h> #include <soc/pll.h>
#include <soc/usb.h> #include <soc/usb.h>
#include <vendorcode/google/chromeos/chromeos.h> #include <vendorcode/google/chromeos/chromeos.h>
#include <framebuffer_info.h>
enum { enum {
CODEC_I2C_BUS = 0, CODEC_I2C_BUS = 0,
@ -224,7 +225,7 @@ static void display_startup(void)
} }
mtk_ddp_mode_set(&edid); mtk_ddp_mode_set(&edid);
set_vbe_mode_info_valid(&edid, (uintptr_t)0); fb_new_framebuffer_info_from_edid(&edid, (uintptr_t)0);
} }
static void mainboard_init(struct device *dev) static void mainboard_init(struct device *dev)

View File

@ -9,7 +9,6 @@
#include <device/i2c_simple.h> #include <device/i2c_simple.h>
#include <drivers/parade/ps8625/ps8625.h> #include <drivers/parade/ps8625/ps8625.h>
#include <ec/google/chromeec/ec.h> #include <ec/google/chromeec/ec.h>
#include <edid.h>
#include <soc/tmu.h> #include <soc/tmu.h>
#include <soc/clk.h> #include <soc/clk.h>
#include <soc/cpu.h> #include <soc/cpu.h>
@ -23,20 +22,12 @@
#include <string.h> #include <string.h>
#include <symbols.h> #include <symbols.h>
#include <vbe.h> #include <vbe.h>
#include <framebuffer_info.h>
/* convenient shorthand (in MB) */ /* convenient shorthand (in MB) */
#define DRAM_START ((uintptr_t)_dram/MiB) #define DRAM_START ((uintptr_t)_dram/MiB)
#define DRAM_SIZE CONFIG_DRAM_SIZE_MB #define DRAM_SIZE CONFIG_DRAM_SIZE_MB
static struct edid edid = {
.mode.ha = 1366,
.mode.va = 768,
.framebuffer_bits_per_pixel = 16,
.x_resolution = 1366,
.y_resolution = 768,
.bytes_per_line = 2 * 1366
};
/* from the fdt */ /* from the fdt */
static struct vidinfo vidinfo = { static struct vidinfo vidinfo = {
.vl_freq = 60, .vl_freq = 60,
@ -402,7 +393,7 @@ static void mainboard_init(struct device *dev)
sdmmc_vdd(); sdmmc_vdd();
set_vbe_mode_info_valid(&edid, (uintptr_t)fb_addr); fb_add_framebuffer_info((uintptr_t)fb_addr, 1366, 768, 2 * 1366, 16);
/* /*
* The reset value for FIMD SYSMMU register MMU_CTRL:0x14640000 * The reset value for FIMD SYSMMU register MMU_CTRL:0x14640000

View File

@ -6,6 +6,7 @@
#include <device/device.h> #include <device/device.h>
#include <device/i2c_simple.h> #include <device/i2c_simple.h>
#include <drivers/ti/sn65dsi86bridge/sn65dsi86bridge.h> #include <drivers/ti/sn65dsi86bridge/sn65dsi86bridge.h>
#include <framebuffer_info.h>
#include <soc/display/mipi_dsi.h> #include <soc/display/mipi_dsi.h>
#include <soc/display/mdssreg.h> #include <soc/display/mdssreg.h>
#include <soc/qupv3_config.h> #include <soc/qupv3_config.h>
@ -105,7 +106,7 @@ static void display_startup(void)
/* Configure backlight */ /* Configure backlight */
gpio_output(GPIO_BACKLIGHT_ENABLE, 1); gpio_output(GPIO_BACKLIGHT_ENABLE, 1);
display_init(&ed); display_init(&ed);
set_vbe_mode_info_valid(&ed, (uintptr_t)0); fb_new_framebuffer_info_from_edid(&ed, (uintptr_t)0);
} else } else
printk(BIOS_INFO, "Skipping display init.\n"); printk(BIOS_INFO, "Skipping display init.\n");
} }

View File

@ -19,6 +19,7 @@
#include <pc80/vga_io.h> #include <pc80/vga_io.h>
#include <commonlib/helpers.h> #include <commonlib/helpers.h>
#include <types.h> #include <types.h>
#include <framebuffer_info.h>
#include "i945.h" #include "i945.h"
#include "chip.h" #include "chip.h"
@ -358,7 +359,7 @@ static int intel_gma_init_lvds(struct northbridge_intel_i945_config *conf,
(void *)pgfx, hactive * vactive * 4); (void *)pgfx, hactive * vactive * 4);
memset((void *)pgfx, 0x00, hactive * vactive * 4); memset((void *)pgfx, 0x00, hactive * vactive * 4);
set_vbe_mode_info_valid(&edid, pgfx); fb_new_framebuffer_info_from_edid(&edid, pgfx);
} else { } else {
vga_misc_write(0x67); vga_misc_write(0x67);

View File

@ -14,6 +14,7 @@
#include <soc/nvidia/tegra/pwm.h> #include <soc/nvidia/tegra/pwm.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <framebuffer_info.h>
#include "chip.h" #include "chip.h"
@ -312,10 +313,9 @@ void display_startup(struct device *dev)
/* tell depthcharge ... /* tell depthcharge ...
*/ */
struct edid edid; const uint32_t bytes_per_line = ALIGN_UP(config->xres *
edid.mode.va = config->yres; DIV_ROUND_UP(config->framebuffer_bits_per_pixel, 8), 32);
edid.mode.ha = config->xres;
edid_set_framebuffer_bits_per_pixel(&edid, fb_add_framebuffer_info(framebuffer_base_mb*MiB, config->xres, config->yres,
config->framebuffer_bits_per_pixel, 32); bytes_per_line, config->framebuffer_bits_per_pixel);
set_vbe_mode_info_valid(&edid, (uintptr_t)(framebuffer_base_mb*MiB));
} }

View File

@ -3,10 +3,10 @@
#include <console/console.h> #include <console/console.h>
#include <device/mmio.h> #include <device/mmio.h>
#include <stdint.h> #include <stdint.h>
#include <edid.h>
#include <device/device.h> #include <device/device.h>
#include <soc/nvidia/tegra/dc.h> #include <soc/nvidia/tegra/dc.h>
#include <soc/display.h> #include <soc/display.h>
#include <framebuffer_info.h>
#include "chip.h" #include "chip.h"
@ -212,19 +212,9 @@ int tegra_dc_init(struct display_controller *disp_ctrl)
void pass_mode_info_to_payload( void pass_mode_info_to_payload(
struct soc_nvidia_tegra210_config *config) struct soc_nvidia_tegra210_config *config)
{ {
struct edid edid; const uint32_t bytes_per_line = ALIGN_UP(config->display_xres *
DIV_ROUND_UP(config->framebuffer_bits_per_pixel, 8), 64);
edid.mode.va = config->display_yres; /* The framebuffer address is zero to let the payload allocate it */
edid.mode.ha = config->display_xres; fb_add_framebuffer_info(0, config->display_xres, config->display_yres,
edid_set_framebuffer_bits_per_pixel(&edid, bytes_per_line, config->framebuffer_bits_per_pixel);
config->framebuffer_bits_per_pixel, 64);
printk(BIOS_INFO, "%s: bytes_per_line: %d, bits_per_pixel: %d\n "
" x_res x y_res: %d x %d, size: %d\n",
__func__, edid.bytes_per_line,
edid.framebuffer_bits_per_pixel,
edid.x_resolution, edid.y_resolution,
(edid.bytes_per_line * edid.y_resolution));
set_vbe_mode_info_valid(&edid, 0);
} }

View File

@ -17,6 +17,7 @@
#include <soc/grf.h> #include <soc/grf.h>
#include <soc/soc.h> #include <soc/soc.h>
#include <soc/vop.h> #include <soc/vop.h>
#include <framebuffer_info.h>
#include "chip.h" #include "chip.h"
@ -124,5 +125,5 @@ void rk_display_init(struct device *dev, u32 lcdbase, unsigned long fb_size)
break; break;
} }
set_vbe_mode_info_valid(&edid, (uintptr_t)lcdbase); fb_new_framebuffer_info_from_edid(&edid, (uintptr_t)lcdbase);
} }

View File

@ -18,6 +18,7 @@
#include <soc/mipi.h> #include <soc/mipi.h>
#include <soc/soc.h> #include <soc/soc.h>
#include <soc/vop.h> #include <soc/vop.h>
#include <framebuffer_info.h>
#include "chip.h" #include "chip.h"
@ -160,7 +161,7 @@ retry_edp:
break; break;
} }
mainboard_power_on_backlight(); mainboard_power_on_backlight();
set_vbe_mode_info_valid(&edid, (uintptr_t)0); fb_new_framebuffer_info_from_edid(&edid, (uintptr_t)0);
return; return;
} }