From d0e465456eedd7d39442a82fe3b2186784a9ff60 Mon Sep 17 00:00:00 2001 From: Nickey Yang Date: Thu, 27 Apr 2017 09:37:20 +0800 Subject: cbgfx: Add portrait screen support cbgfx currently does not support portrait screen which height >width. so add it. Change-Id: I66fee6d73654e736a2db4a3d191f030c52a23e0d Signed-off-by: Nickey Yang Reviewed-on: https://review.coreboot.org/19474 Tested-by: build bot (Jenkins) Reviewed-by: Julius Werner --- payloads/libpayload/drivers/video/graphics.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'payloads/libpayload/drivers/video/graphics.c') diff --git a/payloads/libpayload/drivers/video/graphics.c b/payloads/libpayload/drivers/video/graphics.c index 4a8792c151..d4eaa09997 100644 --- a/payloads/libpayload/drivers/video/graphics.c +++ b/payloads/libpayload/drivers/video/graphics.c @@ -154,18 +154,18 @@ static int cbgfx_init(void) screen.offset.x = 0; screen.offset.y = 0; - /* Calculate canvas size & offset, assuming the screen is landscape */ + /* Calculate canvas size & offset. Canvas is always square. */ if (screen.size.height > screen.size.width) { - const int bpl = fbinfo->bytes_per_line; - LOG("Portrait screen not supported, forcing square image!\n"); - memset(fbaddr + screen.size.width * bpl, 0, - (screen.size.height - screen.size.width) * bpl); - screen.size.height = screen.size.width; + canvas.size.height = screen.size.width; + canvas.size.width = canvas.size.height; + canvas.offset.x = 0; + canvas.offset.y = (screen.size.height - canvas.size.height) / 2; + } else { + canvas.size.height = screen.size.height; + canvas.size.width = canvas.size.height; + canvas.offset.x = (screen.size.width - canvas.size.width) / 2; + canvas.offset.y = 0; } - canvas.size.height = screen.size.height; - canvas.size.width = canvas.size.height; - canvas.offset.x = (screen.size.width - canvas.size.width) / 2; - canvas.offset.y = 0; initialized = 1; LOG("cbgfx initialized: screen:width=%d, height=%d, offset=%d canvas:width=%d, height=%d, offset=%d\n", -- cgit v1.2.3