From patchwork Tue Dec 12 03:32:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 13488474 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1C783C4332F for ; Tue, 12 Dec 2023 03:33:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 38D3810E147; Tue, 12 Dec 2023 03:33:18 +0000 (UTC) Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7808B10E147 for ; Tue, 12 Dec 2023 03:33:15 +0000 (UTC) Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-7b7020f03c9so214379639f.3 for ; Mon, 11 Dec 2023 19:33:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702351994; x=1702956794; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=3W+vl1pPQ5xbJbOBYqTUjLnDDv5t03VNIfECEsk3uHs=; b=hjKvtY8ZT3s/npSoq1UfxJHB81LCY32JSg8WliMmUuDztcZh0DJHuZOsEFAf7lPAY5 qxm5p7ObNbKkQIhlkC+XBVpuD9cImQtOFJOHzH4reNQW4OwouoVPJUdHZf1iBFHv1TXK S/enTGAdp1gMOm5ezScQtQ2iTnu870UFpAVt8RNDTfiFu9hel36vaYYVmKJqEQS0I2p+ 1iJMug1uLxShIQdmITx8SERSc+EjqKK2jzEk5ghp4o1FKpQczpJ/gpAkjEyO91IIsC57 aOdrW1k+iVWDBK8sz5RBuMT/fU7TKtgYCXd2kVxcBL8nkKTEl9+dC+hUkTlOffPvL0H4 G9qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702351994; x=1702956794; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3W+vl1pPQ5xbJbOBYqTUjLnDDv5t03VNIfECEsk3uHs=; b=wRZwa3R9D00w6iGd2vtkzCdQX3YemDTfKo3BprEvsixB0e2sQGJPvuXvvaNFJ210UZ X8+JKgFbXZULtjXv+q2wjVPghA64Bwy8N2PTcYf1pPavgkyeqzIOru8BuxT1nyDx8okd L1Kde1ZF+igvyKa7DXEHB8+QDUKQ6QsgFcN+1yUvATSh1Gxb/v6vYJWiBvHUloOEIU0M bB1zy9ByWjwyuZocSPj89Z8bDbPsbJ+h0+Iq9sNbOpRwlvq8cXOv7Cr45LcsNmhWn9G4 k25ISTGioEh6JPpE7ce5cZLrSjmMQESntpFN8BqJXZUDmicQdfyQJQDQ8NamGyfDoHqC thhQ== X-Gm-Message-State: AOJu0YzIc8UhKVE4ACXv/YevaRy8VadicfTJgzsRFEL7FXL9m9gB8bUm 6+Jxot9yYScbbQltCLSuegn+Iu5SFZF7vA== X-Google-Smtp-Source: AGHT+IEQ2n6XFLN8H7+WSHX07ery6GbeFJs7zpiGoluH51/YRfXyjf+FLjsQ2RJap6WxnQE6JL1qIg== X-Received: by 2002:a05:6602:274d:b0:7b7:e9f:b93f with SMTP id b13-20020a056602274d00b007b70e9fb93fmr6164628ioe.0.1702351994112; Mon, 11 Dec 2023 19:33:14 -0800 (PST) Received: from aford-System-Version.lan ([2601:447:d002:5be:6068:4690:ab38:4373]) by smtp.gmail.com with ESMTPSA id y23-20020a5e8717000000b007b457153a6bsm2590049ioj.28.2023.12.11.19.33.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 19:33:13 -0800 (PST) From: Adam Ford To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/2] drm/bridge: samsung-dsim: Set P divider based on min/max of fin pll Date: Mon, 11 Dec 2023 21:32:58 -0600 Message-Id: <20231212033259.189718-1-aford173@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , Neil Armstrong , Robert Foss , Thomas Zimmermann , Jonas Karlman , Laurent Pinchart , aford@beaconembedded.com, Jernej Skrabec , Marco Felsch , Michael Tretter , Jagan Teki , Andrzej Hajda , Adam Ford , linux-kernel@vger.kernel.org, Marek Szyprowski Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The P divider should be set based on the min and max values of the fin pll which may vary between different platforms. These ranges are defined per platform, but hard-coded values were used instead which resulted in a smaller range available on the i.MX8M[MNP] than what was possible. Fixes: 846307185f0f ("drm/bridge: samsung-dsim: update PLL reference clock") Signed-off-by: Adam Ford Reviewed-by: Frieder Schrempf Tested-by: Frieder Schrempf diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c index be5914caa17d..239d253a7d71 100644 --- a/drivers/gpu/drm/bridge/samsung-dsim.c +++ b/drivers/gpu/drm/bridge/samsung-dsim.c @@ -573,8 +573,8 @@ static unsigned long samsung_dsim_pll_find_pms(struct samsung_dsim *dsi, u16 _m, best_m; u8 _s, best_s; - p_min = DIV_ROUND_UP(fin, (12 * MHZ)); - p_max = fin / (6 * MHZ); + p_min = DIV_ROUND_UP(fin, (driver_data->pll_fin_max * MHZ)); + p_max = fin / (driver_data->pll_fin_min * MHZ); for (_p = p_min; _p <= p_max; ++_p) { for (_s = 0; _s <= 5; ++_s) { From patchwork Tue Dec 12 03:32:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 13488475 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 64149C4167D for ; Tue, 12 Dec 2023 03:33:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2350810E164; Tue, 12 Dec 2023 03:33:21 +0000 (UTC) Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1BDB910E147 for ; Tue, 12 Dec 2023 03:33:17 +0000 (UTC) Received: by mail-io1-xd2c.google.com with SMTP id ca18e2360f4ac-7b70de199f6so141209839f.2 for ; Mon, 11 Dec 2023 19:33:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702351996; x=1702956796; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nYInYE6vgyZ8xggSLq7h777qBlps2bVu+HQMH76x0n0=; b=BptQeh0MnT67y28l7NPwP000s/LjNnZzlKJyz1mTd7sDhUrJKGagIQRwWZQxrFrmCE 1O/QjwP43teLxIY2Lr6o7rUZOKJh/82IWMkSWyr3ivPSub+6hEi0BEzWcBkdpWO00QP0 y6dy8vZFg29FUChLUFEVJs/UalH4aOl6yk2jRKl/bEMgekyHXbfrOCdv08ACYQS2QK0i CQxBh5uIj4kq8PlIxVH/N+Uc8op8c2ljVPIHZvfUStWv/ceU5iLxNRTo4EHuFFm0v+Mi GMQAf4BTaFhap2fZoce4YEQHscTolaVaq05MKTOt+H3ZG1UFOFLmz9RRC3EMCCmTShGY 2bjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702351996; x=1702956796; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nYInYE6vgyZ8xggSLq7h777qBlps2bVu+HQMH76x0n0=; b=vaeFlDud816CpjLuxew9ZH6mdgrACr2Y1wVeS7FCCGNluv5GgDsO+OaolKt5v5ZuTk OeyM00RudLj2aDtdZ1ic6hxkDf0cMmy1tI+3pdx2KZkU6Nk/xjbFQ/K+L4V6YECwA9hP 8ohmbr+/vbixmZIY0Gj12K17v9iXuGnF2Ks2TOEJmAeRXCrh4QXLCBUGk9fEFklCPJpS YXXI/9suWeyqa8ABUtuOlBL7QZaadv7MEiYXIoMDfrEO8iD2pujNcE0VRYpXxOXAKCsh 46STWpkhjm0h5h6ugh36iz+kFz+Ghlt0WmLhY6CX6pWhr9Z3TvPljfbE6ZCQ/7z+xelG 29SQ== X-Gm-Message-State: AOJu0YwKQ6Jnqm6F9u6F3ZpK6SV54Xb3vgbCkM6bgCmd9xgLjFJdFHD2 CqBwOw40CYLiMth6/iRO1PXr3ZAPdKvGpQ== X-Google-Smtp-Source: AGHT+IG08MJ0IJU3QFb5acFcJOPuXxUtZCYC4nz6t5BQKhDRpUHFrucdvKe0afj1ildqn1g7OvRgBA== X-Received: by 2002:a5e:a916:0:b0:7b7:19e3:a645 with SMTP id c22-20020a5ea916000000b007b719e3a645mr5176094iod.20.1702351995800; Mon, 11 Dec 2023 19:33:15 -0800 (PST) Received: from aford-System-Version.lan ([2601:447:d002:5be:6068:4690:ab38:4373]) by smtp.gmail.com with ESMTPSA id y23-20020a5e8717000000b007b457153a6bsm2590049ioj.28.2023.12.11.19.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 19:33:15 -0800 (PST) From: Adam Ford To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/2] drm/bridge: samsung-dsim: Fix porch calcalcuation rounding Date: Mon, 11 Dec 2023 21:32:59 -0600 Message-Id: <20231212033259.189718-2-aford173@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231212033259.189718-1-aford173@gmail.com> References: <20231212033259.189718-1-aford173@gmail.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , Neil Armstrong , Jernej Skrabec , Robert Foss , Thomas Zimmermann , Jonas Karlman , Laurent Pinchart , aford@beaconembedded.com, Frieder Schrempf , Michael Tretter , Jagan Teki , Andrzej Hajda , Marco Felsch , Adam Ford , linux-kernel@vger.kernel.org, Marek Szyprowski Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" When using video sync pulses, the HFP, HBP, and HSA are divided between the available lanes if there is more than one lane. For certain timings and lane configurations, the HFP may not be evenly divisible. If the HFP is rounded down, it ends up being too small which can cause some monitors to not sync properly. In these instances, adjust htotal and hsync to round the HFP up, and recalculate the htotal. Tested-by: Frieder Schrempf # Kontron BL i.MX8MM with HDMI monitor Signed-off-by: Adam Ford diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c index 239d253a7d71..f5795da1d8bb 100644 --- a/drivers/gpu/drm/bridge/samsung-dsim.c +++ b/drivers/gpu/drm/bridge/samsung-dsim.c @@ -1628,6 +1628,27 @@ static int samsung_dsim_atomic_check(struct drm_bridge *bridge, adjusted_mode->flags |= (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC); } + /* + * When using video sync pulses, the HFP, HBP, and HSA are divided between + * the available lanes if there is more than one lane. For certain + * timings and lane configurations, the HFP may not be evenly divisible. + * If the HFP is rounded down, it ends up being too small which can cause + * some monitors to not sync properly. In these instances, adjust htotal + * and hsync to round the HFP up, and recalculate the htotal. Through trial + * and error, it appears that the HBP and HSA do not appearto need the same + * correction that HFP does. + */ + if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE && dsi->lanes > 1) { + int hfp = adjusted_mode->hsync_start - adjusted_mode->hdisplay; + int remainder = hfp % dsi->lanes; + + if (remainder) { + adjusted_mode->hsync_start += remainder; + adjusted_mode->hsync_end += remainder; + adjusted_mode->htotal += remainder; + } + } + return 0; }