From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RvDnm-00053E-BL for mharc-grub-devel@gnu.org; Wed, 08 Feb 2012 15:07:38 -0500 Received: from eggs.gnu.org ([140.186.70.92]:58901) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvDni-000523-Mh for grub-devel@gnu.org; Wed, 08 Feb 2012 15:07:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RvDng-0004WR-Ii for grub-devel@gnu.org; Wed, 08 Feb 2012 15:07:34 -0500 Received: from mail-we0-f169.google.com ([74.125.82.169]:56297) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvDng-0004WD-Bj for grub-devel@gnu.org; Wed, 08 Feb 2012 15:07:32 -0500 Received: by wera13 with SMTP id a13so857286wer.0 for ; Wed, 08 Feb 2012 12:07:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=/xpiul5MyGHWuuHgzkvDi8d3s2drLh0ZQwy6pfnMO1M=; b=aDC3WrWD35+RU+pts8EK7XrqlVAlD/LHvwHYOKmVBVt/kjPfiXBkza2qxJ9TA/OLn1 xLFwdTpdI0flGO7m2q1peIi4y6dBXkiS/EDkfkc58VHX/CV0Ww+riZsntie0COGO3IzD IinwriQDKMDkoRVWQlhreATl0sPnE2gfN8Jzw= Received: by 10.180.99.100 with SMTP id ep4mr43084927wib.7.1328731651418; Wed, 08 Feb 2012 12:07:31 -0800 (PST) Received: from debian.x201.phnet (202-41.62-81.cust.bluewin.ch. [81.62.41.202]) by mx.google.com with ESMTPS id q7sm2204262wix.5.2012.02.08.12.07.29 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 08 Feb 2012 12:07:30 -0800 (PST) Message-ID: <4F32D600.2060104@gmail.com> Date: Wed, 08 Feb 2012 21:07:28 +0100 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20120104 Icedove/8.0 MIME-Version: 1.0 To: The development of GNU GRUB Subject: Re: [PATCH 4/4] Add support for getting EDID via EFI References: <1328719918-4789-1-git-send-email-mjg@redhat.com> <1328719918-4789-5-git-send-email-mjg@redhat.com> In-Reply-To: <1328719918-4789-5-git-send-email-mjg@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.125.82.169 Cc: Matthew Garrett X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Feb 2012 20:07:36 -0000 On 08.02.2012 17:51, Matthew Garrett wrote: > EFI gives a couple of defined methods for retrieving the EDID, so make use > of them. Some Apple devices don't provide these but do stash the EDID in an > nvram variable - grab it from there if it exists. > --- > ChangeLog | 8 +++++ > grub-core/video/efi_gop.c | 69 +++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 77 insertions(+), 0 deletions(-) > > diff --git a/ChangeLog b/ChangeLog > index 26d779b..d46b3d1 100644 > --- a/ChangeLog > +++ b/ChangeLog > @@ -1,5 +1,13 @@ > 2012-02-08 Matthew Garrett > > + } > + > + grub_memcpy (&edid_info, edid->edid, sizeof(edid_info)); > + This code may copy more than actually present. You need to take minimum of both length and fill the rest with zeros > + return GRUB_ERR_NONE; > +} > + > +static grub_err_t > +grub_gop_get_preferred_mode (unsigned int *width, unsigned int *height) > +{ > + struct grub_video_edid_info edid_info; > + > + if (grub_video_gop_get_edid(&edid_info) == GRUB_ERR_NONE) > + { > + if (grub_video_edid_checksum (&edid_info) == GRUB_ERR_NONE > + && grub_video_edid_preferred_mode (&edid_info, width, height) > + == GRUB_ERR_NONE) > + return GRUB_ERR_NONE; > + else > + grub_dprintf("video", "invalid edid"); > + } > + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "cannot get preferred mode"); Please reuse the error which actually happened. E.g: err = grub_video_gop_get_edid(&edid_info); if (err) return err; err = grub_video_edid_checksum (&edid_info); if (err) return err; ... > +} > + > +static grub_err_t > grub_video_gop_setup (unsigned int width, unsigned int height, > unsigned int mode_type, > unsigned int mode_mask __attribute__ ((unused))) > @@ -268,10 +319,18 @@ grub_video_gop_setup (unsigned int width, unsigned int height, > unsigned bpp; > int found = 0; > unsigned long long best_volume = 0; > + int preferred_mode = 0; > > depth = (mode_type& GRUB_VIDEO_MODE_TYPE_DEPTH_MASK) > >> GRUB_VIDEO_MODE_TYPE_DEPTH_POS; > > + if (width == 0&& height == 0) > + { > + grub_gop_get_preferred_mode (&width,&height); > + if (grub_errno == GRUB_ERR_NONE) > + preferred_mode = 1; > + } > + You need to discard error if you continue > /* Keep current mode if possible. */ > if (gop->mode->info) > { > @@ -306,6 +365,15 @@ grub_video_gop_setup ( -- Regards Vladimir 'φ-coder/phcoder' Serbinenko