From patchwork Sun Nov 23 16:12:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 413431 X-Patchwork-Delegate: ijc@hellion.org.uk Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3929114011B for ; Mon, 24 Nov 2014 03:12:32 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6050D4B9E9; Sun, 23 Nov 2014 17:12:27 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LC4iK6h-B3zb; Sun, 23 Nov 2014 17:12:27 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0334D4B9E2; Sun, 23 Nov 2014 17:12:27 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BF3404B9E2 for ; Sun, 23 Nov 2014 17:12:23 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Q-JN491ijE10 for ; Sun, 23 Nov 2014 17:12:23 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by theia.denx.de (Postfix) with ESMTPS id 4681E4B9D3 for ; Sun, 23 Nov 2014 17:12:19 +0100 (CET) Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sANGCCdH020090 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 23 Nov 2014 11:12:12 -0500 Received: from shalem.localdomain.com (vpn1-4-254.ams2.redhat.com [10.36.4.254]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sANGCAeo011268; Sun, 23 Nov 2014 11:12:11 -0500 From: Hans de Goede To: Ian Campbell Date: Sun, 23 Nov 2014 17:12:09 +0100 Message-Id: <1416759129-13711-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH] sunxi: video: Add extra modes and allow selecting the mode via hdmi_mode env X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.13 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Add the following extra modes: 1280x720@50 1920x1080@60 1920x1200@60 And allow selecting them by setting (and then saving and rebooting) a hdmi_mode env variable to the name of the mode. Also make the reserved fb mem slightly larger to allow 1920x1200 to work. Signed-off-by: Hans de Goede --- drivers/video/sunxi_display.c | 91 +++++++++++++++++++++++++++++++++++++----- include/configs/sunxi-common.h | 2 +- 2 files changed, 81 insertions(+), 12 deletions(-) diff --git a/drivers/video/sunxi_display.c b/drivers/video/sunxi_display.c index 3060bee..349e36c 100644 --- a/drivers/video/sunxi_display.c +++ b/drivers/video/sunxi_display.c @@ -355,15 +355,14 @@ retry: } } -void *video_hw_init(void) +static void video_get_mode(char *modestr, struct fb_videomode *mode) { - static GraphicDevice *graphic_device = &sunxi_display.graphic_device; - /* - * Vesa standard 1024x768@60 - * 65.0 1024 1032 1176 1344 768 771 777 806 -hsync -vsync - */ - struct fb_videomode mode = { - .name = "1024x768", + const struct fb_videomode modes[] = { { + /* + * Vesa standard 1024x768@60 + * 65.0 1024 1032 1176 1344 768 771 777 806 -hsync -vsync + */ + .name = "1024x768@60", .refresh = 60, .xres = 1024, .yres = 768, @@ -377,7 +376,76 @@ void *video_hw_init(void) .sync = 0, .vmode = 0, .flag = 0, - }; + } , { + .name = "1280x720@50", + .refresh = 50, + .xres = 1280, + .yres = 720, + .pixclock = 74250, + .left_margin = 440, + .right_margin = 220, + .upper_margin = 20, + .lower_margin = 5, + .hsync_len = 40, + .vsync_len = 5, + .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + .vmode = FB_VMODE_NONINTERLACED, + .flag = 0, + } , { + .name = "1920x1080@60", + .refresh = 60, + .xres = 1920, + .yres = 1080, + .pixclock = 148500, + .left_margin = 88, + .right_margin = 148, + .upper_margin = 36, + .lower_margin = 4, + .hsync_len = 44, + .vsync_len = 5, + .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + .vmode = FB_VMODE_NONINTERLACED, + .flag = 0, + } , { + .name = "1920x1200@60", + .refresh = 60, + .xres = 1920, + .yres = 1200, + .pixclock = 154000, + .left_margin = 48, + .right_margin = 80, + .upper_margin = 26, + .lower_margin = 3, + .hsync_len = 32, + .vsync_len = 6, + .sync = FB_SYNC_HOR_HIGH_ACT, + .vmode = FB_VMODE_NONINTERLACED, + .flag = 0, + } }; + int i; + + if (!modestr) { + *mode = modes[0]; + return; + } + + for (i = 0; i < ARRAY_SIZE(modes); i++) { + if (strcmp(modes[i].name, modestr) == 0) + break; + } + if (i >= ARRAY_SIZE(modes)) { + eprintf("Mode %s not available, falling back to %s\n", + modestr, modes[0].name); + i = 0; + } + + *mode = modes[i]; +} + +void *video_hw_init(void) +{ + static GraphicDevice *graphic_device = &sunxi_display.graphic_device; + struct fb_videomode mode; int ret; memset(&sunxi_display, 0, sizeof(struct sunxi_display)); @@ -390,10 +458,11 @@ void *video_hw_init(void) if (!ret) return NULL; - printf("HDMI connected.\n"); sunxi_display.enabled = true; + video_get_mode(getenv("hdmi_mode"), &mode); + + printf("HDMI connected, setting up a %s console.\n", mode.name); - printf("Setting up a %s console.\n", mode.name); sunxi_engines_init(); sunxi_mode_set(&mode, gd->fb_base - CONFIG_SYS_SDRAM_BASE); diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h index 7b958f8..a6cdffb 100644 --- a/include/configs/sunxi-common.h +++ b/include/configs/sunxi-common.h @@ -202,7 +202,7 @@ * The amount of RAM that is reserved for the FB. This will not show up as * RAM to the kernel, but will be reclaimed by a KMS driver in future. */ -#define CONFIG_SUNXI_FB_SIZE (8 << 20) +#define CONFIG_SUNXI_FB_SIZE (9 << 20) /* Do we want to initialize a simple FB? */ #define CONFIG_VIDEO_DT_SIMPLEFB