From patchwork Sat May 25 22:41:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilia Mirkin X-Patchwork-Id: 10961141 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C864013AD for ; Sat, 25 May 2019 22:41:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7BD728AA0 for ; Sat, 25 May 2019 22:41:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AAA2528AA4; Sat, 25 May 2019 22:41:57 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 3776828AA0 for ; Sat, 25 May 2019 22:41:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DCA8A6E192; Sat, 25 May 2019 22:41:54 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1365F6E180; Sat, 25 May 2019 22:41:54 +0000 (UTC) Received: by mail-qk1-x742.google.com with SMTP id o2so12512749qkb.3; Sat, 25 May 2019 15:41:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=+yKyBBW3VlIp68lvhpwOuf/tvlXYJWdEHBcOUHyH3L8=; b=rUlCnFAGfLN7FIzrMZh8mpurk748zCLQaa1V43tVlgBmTGcd4O6XPSlWDrQ7s4JJuJ nptCij3lBBS2uMoHrhZrKJGk7FNMXLcZH1Odw/OaNXrRMFgSSoH8oBT8C39fhnfE1QzL vuOe7NbXQw78b2PSke02OCQY2BMqOmQgyahUKAkgKFGNX3nRX+afl4kF/1d4RCma1PWV W8pzaJ6emPg4TAqeZRisVq3eo45h0I0uAgfLLGNHZvvHlEWJTmXVfBSbeXscHrrmN+WB YwPzsA0qP3BeMW2LUicGGxFxNU0FW7PcWxG++SQLkKKcL0S/vmlHmTmnBJL5LRwlBcl6 ybhQ== X-Gm-Message-State: APjAAAVQQZjOKBLyhS4N5wURVoolUQ/1y9TopbYoX/stPEpBBNYXitO7 CejYDqoAMN0Sks8Dw+kI9lw= X-Google-Smtp-Source: APXvYqyR2hJBL8RrfPHWNAlmBTd4V3743jcZhSsXO0CI3/1EpoVynqfPX/fV99SqKSTPL9dmAW8jrw== X-Received: by 2002:a05:620a:624:: with SMTP id 4mr5068222qkv.15.1558824113184; Sat, 25 May 2019 15:41:53 -0700 (PDT) Received: from athos.fios-router.home (pool-173-68-20-215.nycmny.fios.verizon.net. [173.68.20.215]) by smtp.gmail.com with ESMTPSA id 102sm1576876qte.52.2019.05.25.15.41.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 May 2019 15:41:52 -0700 (PDT) From: Ilia Mirkin To: bskeggs@redhat.com Subject: [PATCH 1/2] drm/nouveau/disp/nv50-: force scaler for any non-default LVDS/eDP modes Date: Sat, 25 May 2019 18:41:48 -0400 Message-Id: <20190525224149.4652-1-imirkin@alum.mit.edu> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+yKyBBW3VlIp68lvhpwOuf/tvlXYJWdEHBcOUHyH3L8=; b=Ug8Rqv0ud7UW/ILBmlrQnFX1docQ0cd0d+jL2kC7mi485joZSK9GPXL0iOUiPXstmj iVU4B8km4KyCH9eYA+hoXK6q1km7wsUe1CNKNsTr7dpJcdY0b8Ks8WukLXkb7or1Hn85 igcCWyxUlFGsy7iYpJYX/ezG0SSdJvAF35cJ/3OqprhCdlosmktgnCrGLGkI84NEQIhw wD30SaeNOTfLdDkkSs08M3b7o8oVie4JVOaG2eKb9olnMqAwZrT7xc9KJ94wCWo5HXuY ViKoAXvER04DghJTEnbtgkFA2ZRDY03ES1zIVL92C4aivF9dkAbMGz07+5Yv2lsptNmV ntDw== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Higher layers tend to add a lot of modes not actually in the EDID, such as the standard DMT modes. Changing this would be extremely intrusive to everyone, so just force the scaler more often. There are no practical cases we're aware of where a LVDS/eDP panel has multiple resolutions exposed, and i915 already does it this way. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110660 Signed-off-by: Ilia Mirkin --- Untested for now, hoping that the bugzilla filer will test it out. Seems obvious though. drivers/gpu/drm/nouveau/dispnv50/disp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c index 134701a837c8..ef8d7a71564a 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c @@ -322,8 +322,13 @@ nv50_outp_atomic_check_view(struct drm_encoder *encoder, switch (connector->connector_type) { case DRM_MODE_CONNECTOR_LVDS: case DRM_MODE_CONNECTOR_eDP: - /* Force use of scaler for non-EDID modes. */ - if (adjusted_mode->type & DRM_MODE_TYPE_DRIVER) + /* Don't force scaler for EDID modes with + * same size as the native one (e.g. different + * refresh rate) + */ + if (adjusted_mode->hdisplay == native_mode->hdisplay && + adjusted_mode->vdisplay == native_mode->vdisplay && + adjusted_mode->type & DRM_MODE_TYPE_DRIVER) break; mode = native_mode; asyc->scaler.full = true; From patchwork Sat May 25 22:41:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilia Mirkin X-Patchwork-Id: 10961143 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C946113AD for ; Sat, 25 May 2019 22:42:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B946F28AA0 for ; Sat, 25 May 2019 22:42:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ADA1528AA4; Sat, 25 May 2019 22:42:00 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 5B48328AA0 for ; Sat, 25 May 2019 22:42:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 52DFD6E193; Sat, 25 May 2019 22:41:59 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by gabe.freedesktop.org (Postfix) with ESMTPS id C30446E193; Sat, 25 May 2019 22:41:55 +0000 (UTC) Received: by mail-qk1-x743.google.com with SMTP id z6so12791517qkl.10; Sat, 25 May 2019 15:41:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=wDArQINw8ELzPUebApXhBW7+seMGLb3SgCZP5Ql0H6Y=; b=F8+JkM3oTWhfrSZUlvaJNEUGa9sNlkfwZvORKEWTr7kuoNtceTbsyDLBu/3CvvkD2t mH8qAa2OMMFFt/E0s8aZXUdoONKsV2TlY8/vQ1yVLYW5iFlbOEw/Uj4rgMUJoE85OAng FOO4XUtKorLJIkRyJSZqoyfnTHa4sdvJp/pExdtmvjoL1R2zZoHzGUmmOIS3HQM7Gi4l FwEeZDp+V3+y0P5RszMZ763HKDreFIbDcMnqd/9Cu05D3PueDTNOIELgiSyDULsYg2vU /dqi9Zte39kUbumTvg7z950Oby8nGfTrn2IgJL9rhstil7LhZc5YIu016YpmS2Kr1jVh k3kw== X-Gm-Message-State: APjAAAWLAIef6oMQrMcxs0k1UsnBd7Pc4gYEMgnC2X7STS+Nx/TorhkO m7w+F+8KjcovHfaGYlCSy78= X-Google-Smtp-Source: APXvYqyXPBVykIL2KpussrJZpxhkHFac4dvDwxIUAid2H7bdyEU0KfSHanMxbufvVupcl/HnWpiRDA== X-Received: by 2002:ae9:e50f:: with SMTP id w15mr3645373qkf.297.1558824114925; Sat, 25 May 2019 15:41:54 -0700 (PDT) Received: from athos.fios-router.home (pool-173-68-20-215.nycmny.fios.verizon.net. [173.68.20.215]) by smtp.gmail.com with ESMTPSA id 102sm1576876qte.52.2019.05.25.15.41.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 May 2019 15:41:53 -0700 (PDT) From: Ilia Mirkin To: bskeggs@redhat.com Subject: [PATCH 2/2] drm/nouveau/disp/nv50-: fix center/aspect-corrected scaling Date: Sat, 25 May 2019 18:41:49 -0400 Message-Id: <20190525224149.4652-2-imirkin@alum.mit.edu> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190525224149.4652-1-imirkin@alum.mit.edu> References: <20190525224149.4652-1-imirkin@alum.mit.edu> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wDArQINw8ELzPUebApXhBW7+seMGLb3SgCZP5Ql0H6Y=; b=hn7RAbnLiunf11fW5kbXqZdnJ3Q4jMMcbeykzhp1vnr7ES3JUdXYw71CU24/qTDbFQ 7nRYNrTcZThibjx3hAjGHNs4Ss+j8bQgkGKmPU3KxbvnbfuRDFbZiqIdwO4T2oUht2S5 ZlaLyAz7BhwgB0wcxdGWaoDn3ogpeuB/LZmotVVRW+/OA+fowCfiNBgaVrEWBDqV4USf yv6/C0zAljsXTUrsSZ+sVT9CSN2feulEOxcVqJq+8pCtia0rc38L9F30mUd2mfr1VANL BlmmuFn7clIHLgcVNMiVuuSrd6XddO4C8Hx47f5Gk4hkWGF35jIPQiV9KqaJdRUb1RBE s3Nw== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- Tested on a 1920x1200-native screen with a 640x480 mode (got letter boxes on the side) and 720x400 mode (got letter boxes on top/bottom). 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 ac97ebce5b35..e2207990d3cc 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; }