From patchwork Fri Mar 13 16:20:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 11437369 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F6BA1667 for ; Fri, 13 Mar 2020 16:21:14 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 584A92072C for ; Fri, 13 Mar 2020 16:21:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 584A92072C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E69A16EC10; Fri, 13 Mar 2020 16:21:10 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 513696EC11; Fri, 13 Mar 2020 16:21:09 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Mar 2020 09:21:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,549,1574150400"; d="scan'208";a="232466764" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by orsmga007.jf.intel.com with SMTP; 13 Mar 2020 09:21:06 -0700 Received: by stinkbox (sSMTP sendmail emulation); Fri, 13 Mar 2020 18:21:05 +0200 From: Ville Syrjala To: dri-devel@lists.freedesktop.org Date: Fri, 13 Mar 2020 18:20:48 +0200 Message-Id: <20200313162054.16009-4-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200313162054.16009-1-ville.syrjala@linux.intel.com> References: <20200313162054.16009-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 3/9] drm/edid: Remove idx==1 assumptions from all over the DispID parsing 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 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Ville Syrjälä The fact that the DispID starts at byte offset 1 is due to the DispID coming from and EDID extension block (the first byte being the extesion block tag). Instead of hadrdocoding that idx==1 assumptions all over let's just have drm_find_displayid_extension() return it since it actually knows what it's talking about. If at some point someone comes across a DispID which is not embedded inside an EDID the function that returns the new type of DispID can return it's own byte offset without having to updated all the code. TODO: should probably just get rid of that idx thing altogether and just return the thing we want directly. Signed-off-by: Ville Syrjälä --- drivers/gpu/drm/drm_edid.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index b269cd7f7679..3f9e659199af 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -3212,15 +3212,22 @@ static u8 *drm_find_edid_extension(const struct edid *edid, int ext_id) } -static u8 *drm_find_displayid_extension(const struct edid *edid) +static u8 *drm_find_displayid_extension(const struct edid *edid, int *idx) { - return drm_find_edid_extension(edid, DISPLAYID_EXT); + u8 *displayid = drm_find_edid_extension(edid, DISPLAYID_EXT); + + if (!displayid) + return NULL; + + *idx = 1; + + return displayid; } static u8 *drm_find_cea_extension(const struct edid *edid) { int ret; - int idx = 1; + int idx; int length = EDID_LENGTH; struct displayid_block *block; u8 *cea; @@ -3232,7 +3239,7 @@ static u8 *drm_find_cea_extension(const struct edid *edid) return cea; /* CEA blocks can also be found embedded in a DisplayID block */ - displayid = drm_find_displayid_extension(edid); + displayid = drm_find_displayid_extension(edid, &idx); if (!displayid) return NULL; @@ -5182,12 +5189,12 @@ static int add_displayid_detailed_modes(struct drm_connector *connector, { u8 *displayid; int ret; - int idx = 1; + int idx; int length = EDID_LENGTH; struct displayid_block *block; int num_modes = 0; - displayid = drm_find_displayid_extension(edid); + displayid = drm_find_displayid_extension(edid, &idx); if (!displayid) return 0; @@ -5837,17 +5844,11 @@ static int drm_parse_tiled_block(struct drm_connector *connector, } static int drm_parse_display_id(struct drm_connector *connector, - u8 *displayid, int length, - bool is_edid_extension) + u8 *displayid, int length, int idx) { - /* if this is an EDID extension the first byte will be 0x70 */ - int idx = 0; struct displayid_block *block; int ret; - if (is_edid_extension) - idx = 1; - ret = validate_displayid(displayid, length, idx); if (ret) return ret; @@ -5881,15 +5882,17 @@ static void drm_get_displayid(struct drm_connector *connector, struct edid *edid) { void *displayid = NULL; + int idx; int ret; + connector->has_tile = false; - displayid = drm_find_displayid_extension(edid); + displayid = drm_find_displayid_extension(edid, &idx); if (!displayid) { /* drop reference to any tile group we had */ goto out_drop_ref; } - ret = drm_parse_display_id(connector, displayid, EDID_LENGTH, true); + ret = drm_parse_display_id(connector, displayid, EDID_LENGTH, idx); if (ret < 0) goto out_drop_ref; if (!connector->has_tile)