From patchwork Tue Aug 30 05:00:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nabendu Maiti X-Patchwork-Id: 9304821 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4E5B8607F0 for ; Tue, 30 Aug 2016 04:49:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A08628AC0 for ; Tue, 30 Aug 2016 04:49:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F02728AC4; Tue, 30 Aug 2016 04:49:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DF2FF28AC0 for ; Tue, 30 Aug 2016 04:49:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E0A986E594; Tue, 30 Aug 2016 04:49:14 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id CAE7F6E584 for ; Tue, 30 Aug 2016 04:49:12 +0000 (UTC) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 29 Aug 2016 21:49:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.30,254,1470726000"; d="scan'208"; a="1043215665" Received: from dispdev.iind.intel.com ([10.223.25.80]) by orsmga002.jf.intel.com with ESMTP; 29 Aug 2016 21:49:12 -0700 From: Nabendu Maiti To: intel-gfx@lists.freedesktop.org Date: Tue, 30 Aug 2016 10:30:57 +0530 Message-Id: <1472533261-30306-4-git-send-email-nabendu.bikash.maiti@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1472533261-30306-1-git-send-email-nabendu.bikash.maiti@intel.com> References: <1472533261-30306-1-git-send-email-nabendu.bikash.maiti@intel.com> Subject: [Intel-gfx] [PATCH 3/7] drm/i915: Panel fitting calculation for GEN9 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP No boundary condition was checked while calculating pipe scaler size in pch_panel_fitting(), which might result in blank out or corruptions for invalid values. This patch fixes this by adding appropriate checks and calculation for each fitting mode. Signed-off-by: Nabendu Maiti --- drivers/gpu/drm/i915/intel_panel.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c index 96c65d7..b5ea1b6 100644 --- a/drivers/gpu/drm/i915/intel_panel.c +++ b/drivers/gpu/drm/i915/intel_panel.c @@ -107,18 +107,36 @@ intel_pch_panel_fitting(struct intel_crtc *intel_crtc, { const struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode; int x = 0, y = 0, width = 0, height = 0; + bool downscale = false; /* Native modes don't need fitting */ if (adjusted_mode->crtc_hdisplay == pipe_config->pipe_src_w && adjusted_mode->crtc_vdisplay == pipe_config->pipe_src_h) goto done; + /* Downscale pfiter */ + if (IS_GEN9(intel_crtc->base.dev) && + (adjusted_mode->hdisplay < pipe_config->pipe_src_w || + adjusted_mode->vdisplay < pipe_config->pipe_src_h)) + downscale = true; + switch (fitting_mode) { case DRM_MODE_SCALE_CENTER: width = pipe_config->pipe_src_w; height = pipe_config->pipe_src_h; x = (adjusted_mode->crtc_hdisplay - width + 1)/2; y = (adjusted_mode->crtc_vdisplay - height + 1)/2; + + if (downscale) { + if (x < 0) { + x = 0; + width = adjusted_mode->hdisplay; + } + if (y < 0) { + y = 0; + height = adjusted_mode->vdisplay; + } + } break; case DRM_MODE_SCALE_ASPECT: @@ -132,14 +150,26 @@ intel_pch_panel_fitting(struct intel_crtc *intel_crtc, width = scaled_height / pipe_config->pipe_src_h; if (width & 1) width++; - x = (adjusted_mode->crtc_hdisplay - width + 1) / 2; + if (adjusted_mode->hdisplay > width) { + x = (adjusted_mode->hdisplay - + width + 1) / 2; + } else if (downscale) { + width = adjusted_mode->hdisplay; + x = 0; + } y = 0; height = adjusted_mode->crtc_vdisplay; } else if (scaled_width < scaled_height) { /* letter */ height = scaled_width / pipe_config->pipe_src_w; if (height & 1) height++; - y = (adjusted_mode->crtc_vdisplay - height + 1) / 2; + if (adjusted_mode->vdisplay > height) { + y = (adjusted_mode->vdisplay - + height + 1) / 2; + } else if (downscale) { + height = adjusted_mode->vdisplay; + y = 0; + } x = 0; width = adjusted_mode->crtc_hdisplay; } else {