Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3712425pxb; Mon, 24 Jan 2022 16:05:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJwVRi3cG3RXekJm2Vn28Jr2j0NhnXIkM+8+TOzm593if13GlUkoP9HVQWb1Horaf9ChAgUC X-Received: by 2002:a17:902:ba8c:b0:14a:f110:84e1 with SMTP id k12-20020a170902ba8c00b0014af11084e1mr16383075pls.7.1643069103830; Mon, 24 Jan 2022 16:05:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643069103; cv=none; d=google.com; s=arc-20160816; b=ICr0MLDI8XQ21wDIZSYIHnuJl6BPfGQTJd3A0fqU3+kDVP5GMiXUYuU1LTn7yKKz// gDBNLxslp+dk+gfEQVHn9I2jntQp43xtZwoTQd2XPweuXCKOLfWjcRgvAN4Ajve8FF1a L9Bb28H8mxgfja1ZF7rmQSjTbUg5BwzcGQmCxP8w1Dd99aCXikGIEdI8RD38CkJ/L0Cv 1p9TUbHcwZdIYi3fszgE/KiCGa6KpFAPYqQ7Amlv+2piHVEffFx8H9r7p4RuncYjtl53 FD5MyGXQ1em8fH48z7Zxtdgdv+UCXkH0lkS6RaChQjOojvw6KS36LXtHg0EITwgFSw4o Ivhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=u7C++CsP9D+vfNAbRwGaI1qjkf36qlP0nQlO3uCO/pU=; b=fN3wHV4XOAL9ZMjCug2OX+v/81C+03pXJWXzGaIBSBTknb2L4kJS39PObV5u4G9j53 1Sn2IecqkKn67LC5Epp6P3q+yF9pEfL9lviC8atlUP4Vby7ObAVvdnpeP5jelnkNrGoG SWD/qERE8K6MVeOPgVo5xR5gtZS8EfV322C1R0Nv5uFtvXejUTZa2H990AOZs/zg+RSR 95WGHv02950NGY2X2U25MphTKIxzm+WiJBJ60W5DLdeRkutPgcHa33oiCu13b35WE5e5 MKBdIWUS6tBVN0GXJYeOLhnKRuJOMzPG7tolI5piqLGhrO0BGYgu5iZkvCmMtvEjmZ1v lLJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pT3VfVKn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q10si17497535pfu.205.2022.01.24.16.04.50; Mon, 24 Jan 2022 16:05:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pT3VfVKn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2367771AbiAXX4a (ORCPT + 99 others); Mon, 24 Jan 2022 18:56:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1846413AbiAXXPz (ORCPT ); Mon, 24 Jan 2022 18:15:55 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50C84C0604CE; Mon, 24 Jan 2022 13:24:05 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E3ABC61320; Mon, 24 Jan 2022 21:24:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7EB7C340E4; Mon, 24 Jan 2022 21:24:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059444; bh=TH+ekF/q/S4B463GdM+Q95pPIb/BpaQu6eM3YQyRVhg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pT3VfVKn+sgdzUmeyzhbRHcY2h+F1/VLXHA43kjXuNp+NhAB7eKkCxlkSdkgI7fZi oStaB5PA2ov8Fy9ZtKTph5poREiNJzEX5JQAGMjABFKxkiB+3e6vkDw89ex2jHYfFh BqaEa6tm2mcA/Vgo8Ntcrtq8TTeoXrbKaF3/J7Jk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Laurent Pinchart , Sasha Levin Subject: [PATCH 5.16 0616/1039] drm: rcar-du: Fix CRTC timings when CMM is used Date: Mon, 24 Jan 2022 19:40:05 +0100 Message-Id: <20220124184146.042359307@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Laurent Pinchart [ Upstream commit f0ce591dc9a97067c6e783a2eaccd22c5476144d ] When the CMM is enabled, an offset of 25 pixels must be subtracted from the HDS (horizontal display start) and HDE (horizontal display end) registers. Fix the timings calculation, and take this into account in the mode validation. This fixes a visible horizontal offset in the image with VGA monitors. HDMI monitors seem to be generally more tolerant to incorrect timings, but may be affected too. Signed-off-by: Laurent Pinchart Signed-off-by: Sasha Levin --- drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c index 5236f917cc68d..f361a604337f6 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c @@ -215,6 +215,7 @@ static void rcar_du_crtc_set_display_timing(struct rcar_du_crtc *rcrtc) const struct drm_display_mode *mode = &rcrtc->crtc.state->adjusted_mode; struct rcar_du_device *rcdu = rcrtc->dev; unsigned long mode_clock = mode->clock * 1000; + unsigned int hdse_offset; u32 dsmr; u32 escr; @@ -299,10 +300,15 @@ static void rcar_du_crtc_set_display_timing(struct rcar_du_crtc *rcrtc) | DSMR_DIPM_DISP | DSMR_CSPM; rcar_du_crtc_write(rcrtc, DSMR, dsmr); + hdse_offset = 19; + if (rcrtc->group->cmms_mask & BIT(rcrtc->index % 2)) + hdse_offset += 25; + /* Display timings */ - rcar_du_crtc_write(rcrtc, HDSR, mode->htotal - mode->hsync_start - 19); + rcar_du_crtc_write(rcrtc, HDSR, mode->htotal - mode->hsync_start - + hdse_offset); rcar_du_crtc_write(rcrtc, HDER, mode->htotal - mode->hsync_start + - mode->hdisplay - 19); + mode->hdisplay - hdse_offset); rcar_du_crtc_write(rcrtc, HSWR, mode->hsync_end - mode->hsync_start - 1); rcar_du_crtc_write(rcrtc, HCR, mode->htotal - 1); @@ -837,6 +843,7 @@ rcar_du_crtc_mode_valid(struct drm_crtc *crtc, struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc); struct rcar_du_device *rcdu = rcrtc->dev; bool interlaced = mode->flags & DRM_MODE_FLAG_INTERLACE; + unsigned int min_sync_porch; unsigned int vbp; if (interlaced && !rcar_du_has(rcdu, RCAR_DU_FEATURE_INTERLACED)) @@ -844,9 +851,14 @@ rcar_du_crtc_mode_valid(struct drm_crtc *crtc, /* * The hardware requires a minimum combined horizontal sync and back - * porch of 20 pixels and a minimum vertical back porch of 3 lines. + * porch of 20 pixels (when CMM isn't used) or 45 pixels (when CMM is + * used), and a minimum vertical back porch of 3 lines. */ - if (mode->htotal - mode->hsync_start < 20) + min_sync_porch = 20; + if (rcrtc->group->cmms_mask & BIT(rcrtc->index % 2)) + min_sync_porch += 25; + + if (mode->htotal - mode->hsync_start < min_sync_porch) return MODE_HBLANK_NARROW; vbp = (mode->vtotal - mode->vsync_end) / (interlaced ? 2 : 1); -- 2.34.1