From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.132.183.28, mailfrom: lersek@redhat.com) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Fri, 24 May 2019 02:40:57 -0700 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C61459451; Fri, 24 May 2019 09:40:47 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-245.rdu2.redhat.com [10.10.120.245]) by smtp.corp.redhat.com (Postfix) with ESMTP id 16D4417CDD; Fri, 24 May 2019 09:40:44 +0000 (UTC) Subject: Re: [PATCH V4 2/2] MdeModulePkg/GraphicsConsoleDxe: Initialize the output mode To: Zhichao Gao , devel@edk2.groups.io Cc: Jian J Wang , Hao Wu , Ray Ni , Star Zeng , Liming Gao , Sean Brogan , Michael Turner , Bret Barkelew References: <20190524024009.31600-1-zhichao.gao@intel.com> <20190524024009.31600-3-zhichao.gao@intel.com> From: "Laszlo Ersek" Message-ID: <67d7f12a-6c30-2922-74ac-a16790d0150c@redhat.com> Date: Fri, 24 May 2019 11:40:44 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190524024009.31600-3-zhichao.gao@intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 24 May 2019 09:40:52 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 05/24/19 04:40, Zhichao Gao wrote: > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1412 > > Original logic: > Connect the graphics device -> connect it as graphics consoles > and initialize its parameters(Mode = -1, invalid) -> connect it > as console spliter and add the device to the list(use SetMode to > set mode to the user defined mode or the best mode the devices > supported if the mode is invalid. *clear the screen at this phase*) > > Changed logic: > Connect the graphics device -> connect it as graphics consoles > and initialize its parameters(initialize the mode to the user > defined mode or the best mode. *directly set the mode value without > using SetMode, that would not clear the screen) -> connect it as > console spliter and add the device to the list(use SetMode to set > mode to the user defined mode or the best mode the devices supported > if the mode is invalid. *now the mode is already set, so it would > not clear the screen*). > > Also remove the section of SetMode for debug version. > > Impact: as the text mode may not be an invalid value, the SetMode > may have no chance to be called during reconnect the graphics device. > That means the screen may not be cleaned after finishing reconnect > operation. There is one common condition: shell command "recoonect -r". > > Cc: Jian J Wang > Cc: Hao Wu > Cc: Ray Ni > Cc: Star Zeng > Cc: Liming Gao > Cc: Sean Brogan > Cc: Michael Turner > Cc: Bret Barkelew > Cc: Laszlo Ersek > Signed-off-by: Zhichao Gao > --- > .../GraphicsConsoleDxe/GraphicsConsole.c | 42 ++++++++++++++----- > .../GraphicsConsoleDxe/GraphicsConsoleDxe.inf | 2 + > 2 files changed, 34 insertions(+), 10 deletions(-) > > diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c > index 26ea19f300..c042451a9b 100644 > --- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c > +++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c > @@ -1,7 +1,7 @@ > /** @file > This is the main routine for initializing the Graphics Console support routines. > > -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
> +Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent > > **/ > @@ -384,6 +384,12 @@ GraphicsConsoleControllerDriverStart ( > EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *Mode; > UINTN SizeOfInfo; > EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info; > + INT32 PreferMode; > + INT32 Index; > + UINTN Column; > + UINTN Row; > + UINTN DefaultColumn; > + UINTN DefaultRow; > > ModeNumber = 0; > > @@ -567,16 +573,32 @@ GraphicsConsoleControllerDriverStart ( > // > Private->SimpleTextOutputMode.MaxMode = (INT32) MaxMode; > > - DEBUG_CODE_BEGIN (); > - Status = GraphicsConsoleConOutSetMode (&Private->SimpleTextOutput, 0); > - if (EFI_ERROR (Status)) { > - goto Error; > - } > - Status = GraphicsConsoleConOutOutputString (&Private->SimpleTextOutput, (CHAR16 *)L"Graphics Console Started\n\r"); > - if (EFI_ERROR (Status)) { > - goto Error; > + // > + // Initialize the Mode of graphics console devices > + // > + PreferMode = -1; > + DefaultColumn = PcdGet32 (PcdConOutColumn); > + DefaultRow = PcdGet32 (PcdConOutRow); > + Column = 0; > + Row = 0; > + for (Index = 0; Index < (INT32)MaxMode; Index++) { > + if (DefaultColumn != 0 && DefaultRow != 0) { > + if ((Private->ModeData[Index].Columns == DefaultColumn) && > + (Private->ModeData[Index].Rows == DefaultRow)) { > + PreferMode = Index; > + break; > + } > + } else { > + if ((Private->ModeData[Index].Columns > Column) && > + (Private->ModeData[Index].Rows > Row)) { > + Column = Private->ModeData[Index].Columns; > + Row = Private->ModeData[Index].Rows; > + PreferMode = Index; > + } > } > - DEBUG_CODE_END (); > + } > + Private->SimpleTextOutput.Mode->Mode = (INT32)PreferMode; > + DEBUG ((DEBUG_INFO, "Graphics Console Started, Mode: %d\n", PreferMode)); > > // > // Install protocol interfaces for the Graphics Console device. > diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf > index f7caa65aa9..bcfd306eee 100644 > --- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf > +++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf > @@ -65,6 +65,8 @@ > [Pcd] > gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution ## SOMETIMES_CONSUMES > gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution ## SOMETIMES_CONSUMES > + gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow ## SOMETIMES_CONSUMES > + gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn ## SOMETIMES_CONSUMES > > [UserExtensions.TianoCore."ExtraFiles"] > GraphicsConsoleDxeExtra.uni > Acked-by: Laszlo Ersek