Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4606873pxj; Wed, 12 May 2021 09:07:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVBZGm6ZfdF+1IDM3UsaTnpL9dpBgllyObnf+H9fhCQwOPoNFO6dRqreaZHP7kGhgnNZIy X-Received: by 2002:aca:c488:: with SMTP id u130mr26768636oif.0.1620835679218; Wed, 12 May 2021 09:07:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620835679; cv=none; d=google.com; s=arc-20160816; b=Gu05Aef0gnwkT91YX8ROzpYEnN5BixAryTKNlshHipUoifvNY84mxQOt9P4QbTeWVB Trt6NKKdEvmmxDejw72ue4a1chrpKuxlyLfkt1Sd9cZLFjHKEdQXMg4WmaWa+ZXrXWTO cdhhQBGKqJnzXES81SNR/H/ePPZLccOBlnjBHkbmOPn/FDvzl/nSmny6E4qyd21BgQrj Fdoaf4pHvyZk5q36LWlvitvON0d80s9IecldrGq81HulRP9i/fJ09JwFwdEbVQLudYUE YQbQx7Oeo+a13F+9Xm+My5/XLmWt6TlbBMe3X2oN1N+RdC/JvX8klnvJZ6lcvAMkw25y EGvA== 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=EmQwK6ITX/dqFmtoNt3wIGFUFT8qycG+FXtyTT+qEBM=; b=KZtrBoAwjoGtbgD+i5lRsZFO4fCPO7gccZZSYgPBqVI/EHZmmjEIB867yqUNDofbdQ pLpxXYIt352MFTT8SrLhtwylNeNRg/BMzLjVf8mK8UcTVcQZtyEnkvyaa/JphCSB7c0C 6mZzDz+Rx3cmYR+O7VdFKhUCmGJqK77xM9fTM99VBQKH0ZlThasmsN5kESTHLK0d+/qA Ut7puPKG0hHdPhi/Jd9l6HIXBw5uIT5/ZaXtDirl3FLLWjBOz311xp7ILLmzuUlfGwun W2RG4WouxWFmPBeVSKBbOIsOSzoUmFswrlOEgtdK2EbwN9LPFRVIn66idBocjt6GDPFB WDRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=p74zlJoK; 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 l4si282104otr.250.2021.05.12.09.07.45; Wed, 12 May 2021 09:07:59 -0700 (PDT) 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=p74zlJoK; 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 S238541AbhELQFY (ORCPT + 99 others); Wed, 12 May 2021 12:05:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:40754 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235573AbhELP2d (ORCPT ); Wed, 12 May 2021 11:28:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5013E61C27; Wed, 12 May 2021 15:13:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832435; bh=M6wxldWro+LDiAbiNlw5P8o2FCKwC5wvXY9QUtYVyeU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p74zlJoKiW5FUS3ZCw3NiYIpa6dwk2FpJRyFy9Z2gDju0kwYxkghT4XUHrEp0MOXk Db6CXN8LqGAk5tOIOEE9o1WoPmGaX7hMPaRfXhfagCih1q02OIIDhO/0TepczEb9gh GcVaPG9qkiyFFiiSOQPyvpRRWuYQOQSsA0VsyMUQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marek Vasut , Yannick Fertre , Alexandre Torgue , Antonio Borneo , Benjamin Gaignard , Maxime Coquelin , Philippe Cornu , Sam Ravnborg , Vincent Abriou , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Yannick Fertre , Philippe Cornu , Sasha Levin Subject: [PATCH 5.10 278/530] drm/stm: Fix bus_flags handling Date: Wed, 12 May 2021 16:46:28 +0200 Message-Id: <20210512144828.945976888@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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: Marek Vasut [ Upstream commit 99e360442f223dd40fc23ae07c7a263836fd27e6 ] The drm_display_mode_to_videomode() does not populate DISPLAY_FLAGS_DE_LOW or DISPLAY_FLAGS_PIXDATA_NEGEDGE flags in struct videomode. Therefore, no matter what polarity the next bridge or display might require, these flags are never set, and thus the LTDC GCR_DEPOL and GCR_PCPOL bits are never set and the LTDC behaves as if both DISPLAY_FLAGS_PIXDATA_POSEDGE and DISPLAY_FLAGS_DE_HIGH were always set. The fix for this problem is taken almost verbatim from MXSFB driver. In case there is a bridge attached to the LTDC, the bridge might have extra polarity requirements, so extract bus_flags from the bridge and use them for LTDC configuration. Otherwise, extract bus_flags from the connector, which is the display. Fixes: b759012c5fa7 ("drm/stm: Add STM32 LTDC driver") Signed-off-by: Marek Vasut Signed-off-by: Yannick Fertre Cc: Alexandre Torgue Cc: Antonio Borneo Cc: Benjamin Gaignard Cc: Maxime Coquelin Cc: Philippe Cornu Cc: Sam Ravnborg Cc: Vincent Abriou Cc: Yannick Fertre Cc: linux-arm-kernel@lists.infradead.org Cc: linux-stm32@st-md-mailman.stormreply.com To: dri-devel@lists.freedesktop.org Tested-by: Yannick Fertre Signed-off-by: Philippe Cornu Link: https://patchwork.freedesktop.org/patch/msgid/20210127110756.125570-1-marex@denx.de Signed-off-by: Sasha Levin --- drivers/gpu/drm/stm/ltdc.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c index 6e28f707092f..62488ac14923 100644 --- a/drivers/gpu/drm/stm/ltdc.c +++ b/drivers/gpu/drm/stm/ltdc.c @@ -525,13 +525,42 @@ static void ltdc_crtc_mode_set_nofb(struct drm_crtc *crtc) { struct ltdc_device *ldev = crtc_to_ltdc(crtc); struct drm_device *ddev = crtc->dev; + struct drm_connector_list_iter iter; + struct drm_connector *connector = NULL; + struct drm_encoder *encoder = NULL; + struct drm_bridge *bridge = NULL; struct drm_display_mode *mode = &crtc->state->adjusted_mode; struct videomode vm; u32 hsync, vsync, accum_hbp, accum_vbp, accum_act_w, accum_act_h; u32 total_width, total_height; + u32 bus_flags = 0; u32 val; int ret; + /* get encoder from crtc */ + drm_for_each_encoder(encoder, ddev) + if (encoder->crtc == crtc) + break; + + if (encoder) { + /* get bridge from encoder */ + list_for_each_entry(bridge, &encoder->bridge_chain, chain_node) + if (bridge->encoder == encoder) + break; + + /* Get the connector from encoder */ + drm_connector_list_iter_begin(ddev, &iter); + drm_for_each_connector_iter(connector, &iter) + if (connector->encoder == encoder) + break; + drm_connector_list_iter_end(&iter); + } + + if (bridge && bridge->timings) + bus_flags = bridge->timings->input_bus_flags; + else if (connector) + bus_flags = connector->display_info.bus_flags; + if (!pm_runtime_active(ddev->dev)) { ret = pm_runtime_get_sync(ddev->dev); if (ret) { @@ -567,10 +596,10 @@ static void ltdc_crtc_mode_set_nofb(struct drm_crtc *crtc) if (vm.flags & DISPLAY_FLAGS_VSYNC_HIGH) val |= GCR_VSPOL; - if (vm.flags & DISPLAY_FLAGS_DE_LOW) + if (bus_flags & DRM_BUS_FLAG_DE_LOW) val |= GCR_DEPOL; - if (vm.flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE) + if (bus_flags & DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE) val |= GCR_PCPOL; reg_update_bits(ldev->regs, LTDC_GCR, -- 2.30.2