From patchwork Wed Sep 25 13:55:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ville Syrjala X-Patchwork-Id: 11160791 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 5EC2014ED for ; Wed, 25 Sep 2019 14:15:42 +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 4683621D7B for ; Wed, 25 Sep 2019 14:15:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4683621D7B 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 C0DDB6EBCF; Wed, 25 Sep 2019 14:15:41 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 75601891D6 for ; Wed, 25 Sep 2019 14:15:38 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Sep 2019 07:15:38 -0700 X-ExtLoopCount2: 2 from 10.237.72.174 X-IronPort-AV: E=Sophos;i="5.64,548,1559545200"; d="scan'208";a="201259353" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by orsmga002.jf.intel.com with SMTP; 25 Sep 2019 07:15:35 -0700 Received: by stinkbox (sSMTP sendmail emulation); Wed, 25 Sep 2019 17:15:35 +0300 Resent-From: Ville =?iso-8859-1?q?Syrj=E4l=E4?= Resent-Date: Wed, 25 Sep 2019 17:15:35 +0300 Resent-Message-ID: <20190925141535.GF1208@intel.com> Resent-To: intel-gfx@lists.freedesktop.org X-Original-To: ville.syrjala@linux.intel.com Delivered-To: ville.syrjala@linux.intel.com Received: from linux.intel.com [10.54.29.200] by stinkbox.fi.intel.com with IMAP (fetchmail-6.3.26) for (single-drop); Wed, 25 Sep 2019 17:01:57 +0300 (EEST) Received: from orsmga007.jf.intel.com (orsmga007.jf.intel.com [10.7.209.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by linux.intel.com (Postfix) with ESMTPS id 2077B5802B1 for ; Wed, 25 Sep 2019 06:55:20 -0700 (PDT) X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,548,1559545200"; d="scan'208";a="179820406" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by orsmga007.jf.intel.com with SMTP; 25 Sep 2019 06:55:17 -0700 Received: by stinkbox (sSMTP sendmail emulation); Wed, 25 Sep 2019 16:55:16 +0300 From: Ville Syrjala To: dri-devel@lists.freedesktop.org Date: Wed, 25 Sep 2019 16:55:02 +0300 Message-Id: <20190925135502.24055-5-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190925135502.24055-1-ville.syrjala@linux.intel.com> References: <20190925135502.24055-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v3 4/4] drm/edid: Make sure the CEA mode arrays have the correct amount of modes X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfc@freedesktop.org, Hans Verkuil Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Ville Syrjälä We depend on a specific relationship between the VIC number and the index in the CEA mode arrays. Assert that the arrays have the excpected size to make sure we've not accidentally left holes in them. v2: Pimp the BUILD_BUG_ON()s Cc: Hans Verkuil Cc: Shashank Sharma Signed-off-by: Ville Syrjälä --- drivers/gpu/drm/drm_edid.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 0007004d3221..06cac8e2afc2 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -3209,6 +3209,9 @@ static u8 *drm_find_cea_extension(const struct edid *edid) static const struct drm_display_mode *cea_mode_for_vic(u8 vic) { + BUILD_BUG_ON(1 + ARRAY_SIZE(edid_cea_modes_1) - 1 != 127); + BUILD_BUG_ON(193 + ARRAY_SIZE(edid_cea_modes_193) - 1 != 219); + if (vic >= 1 && vic < 1 + ARRAY_SIZE(edid_cea_modes_1)) return &edid_cea_modes_1[vic - 1]; if (vic >= 193 && vic < 193 + ARRAY_SIZE(edid_cea_modes_193))