From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ABECAC433EF for ; Thu, 2 Jun 2022 16:55:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 28C901131D6; Thu, 2 Jun 2022 16:55:04 +0000 (UTC) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 956BD1131DA; Thu, 2 Jun 2022 16:55:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654188903; x=1685724903; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=iyThZ2RE5TwDQxms0c58y2qP+P2qE/Rx94W3sVuQMq0=; b=R/4Dii2cPCW9N2MiH79gBI/fNfiKO12ShL+EHMlsS0L4Uqhi3BrlAlPr RaEFK+8x6EbLsb8JIezlEvP4lyD3OYtKiup6Pb54yG8l6cNYWkVrQdTwB 6mZVRsnlFuOaE0ddZysx4iw6bh7RFsOUuY8azwMqIHa1IzAaMSD3c3mye vUP5hG0eOQnNWTvLmQuEIluiecnZVltPpLxXLvjJugSFz/+CKdZiQZB/3 5UVRGFP8SKEGUK92IeQTkcL1zCXWXYE6WF7Vc7uYsJc9YdIRl8pkpQ68Y b5voqUDnBGhhyFoyLHLsiRRvlK2ssQLvN8iUo4SBNVfvB2MfCP1IJl5xo A==; X-IronPort-AV: E=McAfee;i="6400,9594,10366"; a="336665923" X-IronPort-AV: E=Sophos;i="5.91,271,1647327600"; d="scan'208";a="336665923" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2022 09:55:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,271,1647327600"; d="scan'208";a="577596142" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.163]) by orsmga007.jf.intel.com with SMTP; 02 Jun 2022 09:55:00 -0700 Received: by stinkbox (sSMTP sendmail emulation); Thu, 02 Jun 2022 19:54:59 +0300 Date: Thu, 2 Jun 2022 19:54:59 +0300 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Jani Nikula Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Patchwork-Hint: comment Subject: Re: [Intel-gfx] [PATCH v1 01/13] drm/edid: add block count and data helper functions for drm_edid X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Tue, May 24, 2022 at 01:39:23PM +0300, Jani Nikula wrote: > Add drm_edid based block count and data access helper functions that > take the EDID allocated size into account. > > At the moment, the allocated size should always match the EDID size > indicated by the extension count, but this will change in the future. > > Signed-off-by: Jani Nikula > --- > drivers/gpu/drm/drm_edid.c | 42 +++++++++++++++++++++++++++++++------- > 1 file changed, 35 insertions(+), 7 deletions(-) > > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c > index 929fc0e46751..682d954a9e42 100644 > --- a/drivers/gpu/drm/drm_edid.c > +++ b/drivers/gpu/drm/drm_edid.c > @@ -1613,6 +1613,35 @@ static const void *edid_extension_block_data(const struct edid *edid, int index) > return edid_block_data(edid, index + 1); > } > > +static int drm_edid_block_count(const struct drm_edid *drm_edid) > +{ > + int num_blocks; > + > + /* Starting point */ > + num_blocks = edid_block_count(drm_edid->edid); > + > + /* Limit by allocated size */ > + num_blocks = min(num_blocks, (int)drm_edid->size / EDID_LENGTH); Hmm. Is there a particular reason we couldn't just always return drm_edid->size/EDID_LENGTH here? That is, why would we not set drm_edid->size to always reflect the actual size of the EDID? > + > + return num_blocks; > +} > + > +static int drm_edid_extension_block_count(const struct drm_edid *drm_edid) > +{ > + return drm_edid_block_count(drm_edid) - 1; > +} > + > +static const void *drm_edid_block_data(const struct drm_edid *drm_edid, int index) > +{ > + return edid_block_data(drm_edid->edid, index); > +} > + > +static const void *drm_edid_extension_block_data(const struct drm_edid *drm_edid, > + int index) > +{ > + return edid_extension_block_data(drm_edid->edid, index); > +} > + > /* > * Initializer helper for legacy interfaces, where we have no choice but to > * trust edid size. Not for general purpose use. > @@ -1665,8 +1694,8 @@ static const void *__drm_edid_iter_next(struct drm_edid_iter *iter) > if (!iter->drm_edid) > return NULL; > > - if (iter->index < edid_block_count(iter->drm_edid->edid)) > - block = edid_block_data(iter->drm_edid->edid, iter->index++); > + if (iter->index < drm_edid_block_count(iter->drm_edid)) > + block = drm_edid_block_data(iter->drm_edid, iter->index++); > > return block; > } > @@ -3574,22 +3603,21 @@ static int add_detailed_modes(struct drm_connector *connector, > const u8 *drm_find_edid_extension(const struct drm_edid *drm_edid, > int ext_id, int *ext_index) > { > - const struct edid *edid = drm_edid ? drm_edid->edid : NULL; > const u8 *edid_ext = NULL; > int i; > > /* No EDID or EDID extensions */ > - if (!edid || !edid_extension_block_count(edid)) > + if (!drm_edid || !drm_edid_extension_block_count(drm_edid)) > return NULL; > > /* Find CEA extension */ > - for (i = *ext_index; i < edid_extension_block_count(edid); i++) { > - edid_ext = edid_extension_block_data(edid, i); > + for (i = *ext_index; i < drm_edid_extension_block_count(drm_edid); i++) { > + edid_ext = drm_edid_extension_block_data(drm_edid, i); > if (edid_block_tag(edid_ext) == ext_id) > break; > } > > - if (i >= edid_extension_block_count(edid)) > + if (i >= drm_edid_extension_block_count(drm_edid)) > return NULL; > > *ext_index = i + 1; > -- > 2.30.2 -- Ville Syrjälä Intel