Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp5850729ybn; Sun, 29 Sep 2019 07:04:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqxRQVy5ycMKNih6z+GuewsRPD8EwIn4YqnxgaxnBwFuiqQd/c5EehQfZjY1lsBoI+fjrFDr X-Received: by 2002:a17:906:c4b:: with SMTP id t11mr15410199ejf.131.1569765864438; Sun, 29 Sep 2019 07:04:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569765864; cv=none; d=google.com; s=arc-20160816; b=LVjs3rBBjbhkKda3WZDwKtX5d7fWLXGcRGTrz+FT/em+oKAhezSPYk3MMLFatGktPB 9rrLPlpBcjglwSsUjY1apJwkxeanshhCXcmrNJn+LBg/5z7X4T1aIJu8G9DfEy7vhiFQ McI585cHupfqS5/4p8DbGYuQElqSxJxJb+KBls1GVc1phI2LaSqyOCnsEKn7p1CNVi33 uLkFSgUdzgvZiieP07O0wb0PcAu41r8VXMBJcRI7S0g0/jZ+3aoOaHQ0K4TVX6LegKnf Rx8D0uEHDcmjHYYCFelyhQDmhF94WnffEpO9BOOhb9Hr2cIN5hHx9PtV9pDaIXj/6KeJ 1APw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=c6BNb3GLYHboebNEw5eMxiM2NjPEeXxssR/6qcASuXE=; b=y8/s1OIcX6115yPX/sS/YG44zIFrWlKO5QFyZzd1FN8zLeAB7xo1+UTrg74Zfs0loG sV8qidvInafC+9tOX1PZmnu9rc+H5WJQmxSVaMqPiH9qdfQWIj/XS68bNuXlIZLS7xy2 OpN7oN3hy60OQzmGVbnuzDzoe2Va+fTG8Ydduw0IQjxyu/McAxvFFcUIQvDufE4BpTIZ vyZLafIVfVSFWZMKdW1840iuYzDqDLVbFJW3f8W/ysUJH7WoFjHYqD8GW2dniJXVT0pW 3Zforu1zij2FkE98zDYCn0VGEUfJjGf9Oe3jdlM9b4xCYDu3UCCC2mKe+90TOuuatCaP 4jDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=n643buit; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g37si5286114edg.59.2019.09.29.07.03.58; Sun, 29 Sep 2019 07:04:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=n643buit; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730240AbfI2OCd (ORCPT + 99 others); Sun, 29 Sep 2019 10:02:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:45262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730220AbfI2OCb (ORCPT ); Sun, 29 Sep 2019 10:02:31 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A06682082F; Sun, 29 Sep 2019 14:02:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569765751; bh=M3/SmVArOA7JBk5QAHOoRMcoDkCTQfWxfBebZbq2kkQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n643buitx5JwcLqG1egBPsXuca7rvCDU4dzb7TcgvgdfK/LM1J4uB4HDToWrOVuYC VNONK/wtfFBfCxuflEGZSVe5XKHGmHnoFZ5/87ogMyaNB2pJmMIkA2Cghmzz3UyK3i 6lw+jk0i1HH28COAmvPqqtVhnr6bzyA1to6plLPk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilia Mirkin , Ben Skeggs , Sasha Levin Subject: [PATCH 5.2 39/45] drm/nouveau/disp/nv50-: fix center/aspect-corrected scaling Date: Sun, 29 Sep 2019 15:56:07 +0200 Message-Id: <20190929135033.149716277@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190929135024.387033930@linuxfoundation.org> References: <20190929135024.387033930@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ilia Mirkin [ Upstream commit 533f4752407543f488a9118d817b8c504352b6fb ] Previously center scaling would get scaling applied to it (when it was only supposed to center the image), and aspect-corrected scaling did not always correctly pick whether to reduce width or height for a particular combination of inputs/outputs. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110660 Signed-off-by: Ilia Mirkin Signed-off-by: Ben Skeggs Signed-off-by: Sasha Levin --- drivers/gpu/drm/nouveau/dispnv50/head.c | 28 +++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/nouveau/dispnv50/head.c b/drivers/gpu/drm/nouveau/dispnv50/head.c index 06ee23823a689..acfafc4bda0e1 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/head.c +++ b/drivers/gpu/drm/nouveau/dispnv50/head.c @@ -169,14 +169,34 @@ nv50_head_atomic_check_view(struct nv50_head_atom *armh, */ switch (mode) { case DRM_MODE_SCALE_CENTER: - asyh->view.oW = min((u16)umode->hdisplay, asyh->view.oW); - asyh->view.oH = min((u16)umode_vdisplay, asyh->view.oH); - /* fall-through */ + /* NOTE: This will cause scaling when the input is + * larger than the output. + */ + asyh->view.oW = min(asyh->view.iW, asyh->view.oW); + asyh->view.oH = min(asyh->view.iH, asyh->view.oH); + break; case DRM_MODE_SCALE_ASPECT: - if (asyh->view.oH < asyh->view.oW) { + /* Determine whether the scaling should be on width or on + * height. This is done by comparing the aspect ratios of the + * sizes. If the output AR is larger than input AR, that means + * we want to change the width (letterboxed on the + * left/right), otherwise on the height (letterboxed on the + * top/bottom). + * + * E.g. 4:3 (1.333) AR image displayed on a 16:10 (1.6) AR + * screen will have letterboxes on the left/right. However a + * 16:9 (1.777) AR image on that same screen will have + * letterboxes on the top/bottom. + * + * inputAR = iW / iH; outputAR = oW / oH + * outputAR > inputAR is equivalent to oW * iH > iW * oH + */ + if (asyh->view.oW * asyh->view.iH > asyh->view.iW * asyh->view.oH) { + /* Recompute output width, i.e. left/right letterbox */ u32 r = (asyh->view.iW << 19) / asyh->view.iH; asyh->view.oW = ((asyh->view.oH * r) + (r / 2)) >> 19; } else { + /* Recompute output height, i.e. top/bottom letterbox */ u32 r = (asyh->view.iH << 19) / asyh->view.iW; asyh->view.oH = ((asyh->view.oW * r) + (r / 2)) >> 19; } -- 2.20.1