From patchwork Mon Mar 21 21:38:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 87836 X-Patchwork-Delegate: agust@denx.de 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 BC456B6EE9 for ; Tue, 22 Mar 2011 08:54:39 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 685DB280D5; Mon, 21 Mar 2011 22:54:38 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 P30ja6Lfsf3P; Mon, 21 Mar 2011 22:54:38 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B025C280BE; Mon, 21 Mar 2011 22:54:36 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D7E54280C6 for ; Mon, 21 Mar 2011 22:54:34 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 LC27W3ffmu80 for ; Mon, 21 Mar 2011 22:54:34 +0100 (CET) X-Greylist: delayed 903 seconds by postgrey-1.27 at theia; Mon, 21 Mar 2011 22:54:32 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 AM1EHSOBE004.bigfish.com (mail-am1.bigfish.com [213.199.180.138]) by theia.denx.de (Postfix) with ESMTPS id 05E5F280BE for ; Mon, 21 Mar 2011 22:54:32 +0100 (CET) Received: from mail110-am1-R.bigfish.com (10.3.201.250) by AM1EHSOBE004.bigfish.com (10.3.204.24) with Microsoft SMTP Server id 14.1.225.22; Mon, 21 Mar 2011 21:39:29 +0000 Received: from mail110-am1 (localhost.localdomain [127.0.0.1]) by mail110-am1-R.bigfish.com (Postfix) with ESMTP id 094947480B7; Mon, 21 Mar 2011 21:39:29 +0000 (UTC) X-SpamScore: 3 X-BigFish: VS3(zzzz1202hzz8275bhz2dh2a8h668h80ak61h) X-Spam-TCS-SCL: 0:0 X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPVD:NLI; H:mail.freescale.net; RD:none; EFVD:NLI Received: from mail110-am1 (localhost.localdomain [127.0.0.1]) by mail110-am1 (MessageSwitch) id 1300743568506034_31570; Mon, 21 Mar 2011 21:39:28 +0000 (UTC) Received: from AM1EHSMHS017.bigfish.com (unknown [10.3.201.250]) by mail110-am1.bigfish.com (Postfix) with ESMTP id 77D671C8804C; Mon, 21 Mar 2011 21:39:28 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by AM1EHSMHS017.bigfish.com (10.3.207.155) with Microsoft SMTP Server (TLS) id 14.1.225.22; Mon, 21 Mar 2011 21:39:28 +0000 Received: from az33smr01.freescale.net (10.64.34.199) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server id 14.1.270.2; Mon, 21 Mar 2011 16:38:52 -0500 Received: from efes.am.freescale.net (efes.am.freescale.net [10.82.123.3]) by az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id p2LLcpjV016175; Mon, 21 Mar 2011 16:38:51 -0500 (CDT) From: Timur Tabi To: , , , Date: Mon, 21 Mar 2011 16:38:49 -0500 Message-ID: <1300743530-6829-1-git-send-email-timur@freescale.com> X-Mailer: git-send-email 1.7.3.4 MIME-Version: 1.0 X-OriginatorOrg: freescale.com Subject: [U-Boot] [PATCH 1/2] video: parse the video-mode environment variable X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Add function video_get_video_mode(), which parses the "video-mode" environment variable and returns each of its components. The format matches the video= command-line option used for Linux: video-mode=:x-@<,option=string> The video driver, ignored by U-Boot The X resolution (in pixels) to use. The Y resolution (in pixels) to use. The color depth (in bits) to use. The frequency (in Hz) to use. A comma-separated list of device-specific options Signed-off-by: Timur Tabi --- doc/README.video | 19 +++++++++++++ drivers/video/videomodes.c | 64 ++++++++++++++++++++++++++++++++++++++++++++ drivers/video/videomodes.h | 3 ++ 3 files changed, 86 insertions(+), 0 deletions(-) diff --git a/doc/README.video b/doc/README.video index 34e199c..0c04bea 100644 --- a/doc/README.video +++ b/doc/README.video @@ -28,3 +28,22 @@ The driver has been tested with the following configurations: - MPC823FADS with AD7176 on a PAL TV (YCbYCr) - arsenio@tin.it - GENIETV with AD7177 on a PAL TV (YCbYCr) - arsenio@tin.it + + +"video-mode" environment variable +=============================== + +The 'video-mode' environment variable can be used to enable and configure +some video drivers. The format matches the video= command-line option used +for Linux: + + video-mode=:x-@<,option=string> + + The video driver name, ignored by U-Boot + The X resolution (in pixels) to use. + The Y resolution (in pixels) to use. + The color depth (in bits) to use. + The frequency (in Hz) to use. + A comma-separated list of device-specific options + +Example: video-mode=fslfb:1280x1024-32@60,monitor=dvi diff --git a/drivers/video/videomodes.c b/drivers/video/videomodes.c index d27ce1d..6fe5811 100644 --- a/drivers/video/videomodes.c +++ b/drivers/video/videomodes.c @@ -1,6 +1,7 @@ /* * (C) Copyright 2004 * Pierre Aubert, Staubli Faverges , + * Copyright 2011 Freescale Semiconductor, Inc. * * See file CREDITS for list of people who contributed to this * project. @@ -73,6 +74,8 @@ ****************************************************************************/ #include +#include + #include "videomodes.h" const struct ctfb_vesa_modes vesa_modes[VESA_MODES_COUNT] = { @@ -206,3 +209,64 @@ int video_get_params (struct ctfb_res_modes *pPar, char *penv) } return bpp; } + +/* + * Parse the 'video-mode' environment variable + * + * Example: "video-mode=fslfb:1280x1024-32@60,monitor=dvi". See + * doc/README.video for more information on how to set the variable. + * + * @xres: returned value of X-resolution + * @yres: returned value of Y-resolution + * @depth: returned value of color depth + * @freq: returned value of monitor frequency + * @options: pointer to any remaining options, or NULL + * + * Returns 1 if valid values were found, 0 otherwise + */ +int video_get_video_mode(unsigned int *xres, unsigned int *yres, + unsigned int *depth, unsigned int *freq, const char **options) +{ + char *p = getenv("video-mode"); + if (!p) + return 0; + + /* Skip over the driver name, which we don't care about. */ + p = strchr(p, ':'); + if (!p) + return 0; + + /* Get the X-resolution*/ + while (*p && !isdigit(*p)) + p++; + *xres = simple_strtoul(p, &p, 10); + if (!*xres) + return 0; + + /* Get the Y-resolution */ + while (*p && !isdigit(*p)) + p++; + *yres = simple_strtoul(p, &p, 10); + if (!*yres) + return 0; + + /* Get the depth */ + while (*p && !isdigit(*p)) + p++; + *depth = simple_strtoul(p, &p, 10); + if (!*depth) + return 0; + + /* Get the frequency */ + while (*p && !isdigit(*p)) + p++; + *freq = simple_strtoul(p, &p, 10); + if (!*freq) + return 0; + + /* Find the extra options, if any */ + p = strchr(p, ','); + *options = p ? p + 1 : NULL; + + return 1; +} diff --git a/drivers/video/videomodes.h b/drivers/video/videomodes.h index 0d7c335..e546ab4 100644 --- a/drivers/video/videomodes.h +++ b/drivers/video/videomodes.h @@ -86,3 +86,6 @@ extern const struct ctfb_vesa_modes vesa_modes[]; extern const struct ctfb_res_modes res_mode_init[]; int video_get_params (struct ctfb_res_modes *pPar, char *penv); + +int video_get_video_mode(unsigned int *xres, unsigned int *yres, + unsigned int *depth, unsigned int *freq, const char **options);