Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3386431pxb; Mon, 17 Jan 2022 19:18:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBFZ9ra8aCx2pJ+94zLudB1DUvEiJCMb0UXEsEPH0WOVk9vj2+Oh7Ny1RGH7+IADitmd2F X-Received: by 2002:aa7:9a0c:0:b0:4bb:7b30:ead with SMTP id w12-20020aa79a0c000000b004bb7b300eadmr24279361pfj.78.1642475882759; Mon, 17 Jan 2022 19:18:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642475882; cv=none; d=google.com; s=arc-20160816; b=rSwjbARGDIo4t1sy3wMQhBXwaciyKqwUkIYW6zlMWrcrs41suOSuP2CdHNenEL9uLk 5Qx+OWdb2N2Y/eM+GNQhzgaxh1yAydmLx5hyzGT3f5IBzB+TPJEonkWf/Q33Z8TXsCtz SiOJPqBrv50Mq3gU254i0CJy1arORqdGj68r0NQUSHRGZHsOcsv6DxGkUT6h49aKTToX JMApTLmk61HIulerF0+bImA+K2OStkEWr2kV4gQEjhFi76cHgOobcwa0RDXKJRpV8bcf QkE3pkbnZyuhP3O9te+Idl1/yvCi2k3esmOVa6KPSDyHhDkR1dQUrR/AktMOuXbbdWJe gg1A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=g9R0nZ0ru5XjW4h9s3coL8OVTE4kJVisIq4uR/rBNN0=; b=z7UyY4hyFEN/D5U7vobNpozTMwzHmP0vglw63LL+0RdEcLyPF+G/V8W7CIz2NY8XeQ sUkqv+LLEw+a9sxiI8HYac4M27fgCJU0Eh3rkDopFltt0D4b3P3I1p3GSoqVB8hgAqHO SKe+HiOwkRTIXVTLuGHNmASY5VIZ3yOWC9KapnQZ3MptpPrayTIjZXYOR9YNRJoe4hTS 8td16Cs0yLcpiZe9wFg8e6L/6Bf5UFxLkawC7gFDSEpwszo82YZj2QHoo3dBuZuOnmQr h+tsgOlZR8LocvAPpUJPOBut30rmi7Pe/SxBnR444FEgRj3WaqsDwX9okFmetrW7qieC gehw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t4PT4Qh4; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q8si14658372pfl.248.2022.01.17.19.17.49; Mon, 17 Jan 2022 19:18:02 -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=@kernel.org header.s=k20201202 header.b=t4PT4Qh4; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244998AbiARC2I (ORCPT + 99 others); Mon, 17 Jan 2022 21:28:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244942AbiARC0G (ORCPT ); Mon, 17 Jan 2022 21:26:06 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A41F0C061362; Mon, 17 Jan 2022 18:24:43 -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 ams.source.kernel.org (Postfix) with ESMTPS id 69C83B81239; Tue, 18 Jan 2022 02:24:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29BDCC36AF5; Tue, 18 Jan 2022 02:24:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642472681; bh=DTFUkXLNCr018LWSCZK9D1Uv6h36WaZyXht8Fz71pEg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t4PT4Qh4Rzi8YZ0acPnELUtbebwcAstkGdUXRLo6zXRkPkdxsJnJ4Y+VoyJiEc5e3 Tvtawf7pEvf5uL1CTmMgsVNLdUsm6gI4s2dznJ7N/v82WW73BnVmh5kYFSO2K+T3+p iBcPD8zN/xkSouZVj81txyFyA7DVXOZbF+DE2cOCkERYTWJByzuPW9szSr+VtSAH4d Y6U456Y9GLsuPOnBZQEUxHwuOG5U5j3ZNhWaAkMzb1wvWqYiMwiBvjP5iOUaR5eoDX 6P5SjOqOvY5ix/6av+hfcXe9kK5TDxqhdKcGi1QZ2z45VhixCGL2F818zjCwsabi9a 5ZonDmYUAZVTw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Laurent Pinchart , Sasha Levin , laurent.pinchart@ideasonboard.com, kieran.bingham+renesas@ideasonboard.com, airlied@linux.ie, daniel@ffwll.ch, dri-devel@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org Subject: [PATCH AUTOSEL 5.16 096/217] drm: rcar-du: Fix CRTC timings when CMM is used Date: Mon, 17 Jan 2022 21:17:39 -0500 Message-Id: <20220118021940.1942199-96-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220118021940.1942199-1-sashal@kernel.org> References: <20220118021940.1942199-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 5672830ca184d..ee6ba74627a21 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; @@ -298,10 +299,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); @@ -836,6 +842,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)) @@ -843,9 +850,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