Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp374779pxj; Fri, 7 May 2021 10:28:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfLNk///u/OkvAQ5M2m9+xm0IkNhr9fwk7ZJngqRy/E4SI8cFP43izXDTe99gWqUU1aarT X-Received: by 2002:aa7:8c59:0:b029:28e:9093:cd4d with SMTP id e25-20020aa78c590000b029028e9093cd4dmr11144561pfd.25.1620408506412; Fri, 07 May 2021 10:28:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620408506; cv=none; d=google.com; s=arc-20160816; b=glUSE2DoJXTae2sI+eeO36LcqytkanpqUvQUyR0IXsjNOVbZ48I3UqpkXtmCEmDE/Z ERbkmkqgwgqch2RIywV6AjknECHAU1lIy1bPvEfVf//wZAxqasmSDijgz+MSUFPHtMYm ykhen0/ytBz3P9Mz4UsVDuXCwPeCS7w6hjMtCyGshrllsPG8en3l2u7RK5tOPKo9lBsD eMJ019wvlmF4jTno2os5k7R/H3qb1ps7c3jvSbQGUNHaCktA8EDef/Hh3ax8LA/Qre/C CE4OqvF/pUoPSFjrj0f0CBHscw6JBuP/91aeUIiQEZVwELyDjVYnf/wAHZeTvtf+orbS Mv4g== 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:dkim-signature; bh=borrIZ8w7kAn6eeyppaiVPtd3HiHizxW//+VZhV4w18=; b=aaGNyH26zRSD2Z5W86ikaS2Rjqx05mrFn+nTAbJ9JZcLIkXcXuXpbetvw6MrsC+B5/ NiZfna1oJ0ZLkinjmtwoagCLdrzGOHEVASdg19KqaCgodBi0N7xwKA3+LFMVsA7A3+G2 VV0rvbMR7jkzti94mL0Xu3OVwy7vx3bGjanOBBk+4cb5VQBYTz04MhtCAF2ngQPyIwKF nuXTcsoV9qCMO/wrdw74jDuItRiCRPwCHJkSMGZaY9OpFa25UI8XsjZs9n79xAJSB5ap Gde8Y8TrYKyXhjWhPTMj5VKaPjaQt1HPRRuhWD9GlKNaYiUt3zOqZ6/fjaw3J8n7N2df G+xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b=OTga3Pa9; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=RQN1poOu; 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=cerno.tech Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q14si7518623pfk.166.2021.05.07.10.28.14; Fri, 07 May 2021 10:28:26 -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=@cerno.tech header.s=fm2 header.b=OTga3Pa9; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=RQN1poOu; 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=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237915AbhEGPHu (ORCPT + 99 others); Fri, 7 May 2021 11:07:50 -0400 Received: from wnew4-smtp.messagingengine.com ([64.147.123.18]:39493 "EHLO wnew4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237857AbhEGPHT (ORCPT ); Fri, 7 May 2021 11:07:19 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id D0C417ED; Fri, 7 May 2021 11:06:18 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 07 May 2021 11:06:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=borrIZ8w7kAn6 eeyppaiVPtd3HiHizxW//+VZhV4w18=; b=OTga3Pa9d4+aV7H2N9lNplVyP+K/O yEcIs2cWkWx0n6ZPob1QFtM6atBEQqeMLHw04viUuCebpjTAouSP/7dpwiDfDc0A cmN1BO/cQqkn9jum6YHIgv2jjpKKw808JqqzI+lgnzby2QMzNPSW/Kx9bEn9IYeQ 6cOYIEAkNtwbinkLFFq+3RGeT9CbJBWDriOuYkMz4InIXtPPZvwUcZW+6QIjqpk1 YddYwqFKboI7rynHwHclLaf47Oie082uWRYzZqgQbtdkjBiFbUASuburJ+W48OR0 jBB0cLy+KHJJDORgHgAvEAvmaKk3EOwOg57dZpMgWfGcE4SzkloujhMCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=borrIZ8w7kAn6eeyppaiVPtd3HiHizxW//+VZhV4w18=; b=RQN1poOu A+C7jDDO9GSxGUatW42tt53l2T03b4XLJa8htXY5n4kc74gWqk09xBVE0g5wwBir oenBqBzn7peXwMjq9QBU+yIiuFxZpHdX6nJNM71CPiujPNyFPGYZcFoVvETZ94aO zuLaZvv14y5oxFiXlZGs+FGn3IuM8/a0RHbllEj1sFmzFmt8+E814ZGplJ1uiIiR M7caiL8vDsqGRr7MhL7hCe0NNhcCAxQtG/JNEMs+Xy2f2CJ4o8OgrBc1DGPLfOtW APVg7AT8jkrH5uWFhy+wv4vsQJCwXVDw6TK5JY3xraWTiu+w9+E8Qx4gpAPpaNc2 mYkUxUiiV6x/0g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdegvddgkeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecukfhppeeltddrkeelrdeikedrjeeinecuvehluhhsthgvrhfuihiivgepudenuc frrghrrghmpehmrghilhhfrhhomhepmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 7 May 2021 11:06:16 -0400 (EDT) From: Maxime Ripard To: Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , dri-devel@lists.freedesktop.org, Daniel Vetter , David Airlie Cc: Eric Anholt , Nicolas Saenz Julienne , bcm-kernel-feedback-list@broadcom.com, linux-rpi-kernel@lists.infradead.org, Dave Stevenson , Phil Elwell , Tim Gover , Dom Cobley , linux-kernel@vger.kernel.org Subject: [PATCH v4 11/12] drm/vc4: hdmi: Add a workqueue to set scrambling Date: Fri, 7 May 2021 17:05:14 +0200 Message-Id: <20210507150515.257424-12-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210507150515.257424-1-maxime@cerno.tech> References: <20210507150515.257424-1-maxime@cerno.tech> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It looks like some displays (like the LG 27UL850-W) don't enable the scrambling when the HDMI driver enables it. However, if we set later the scrambler enable bit, the display will work as expected. Let's create delayed work queue to periodically look at the display scrambling status, and if it's not set yet try to enable it again. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_hdmi.c | 25 +++++++++++++++++++++++++ drivers/gpu/drm/vc4/vc4_hdmi.h | 2 ++ 2 files changed, 27 insertions(+) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index bda12fea0dce..4fa7ea419594 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -482,6 +482,8 @@ static bool vc4_hdmi_supports_scrambling(struct drm_encoder *encoder, return true; } +#define SCRAMBLING_POLLING_DELAY_MS 1000 + static void vc4_hdmi_enable_scrambling(struct drm_encoder *encoder) { struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; @@ -498,6 +500,9 @@ static void vc4_hdmi_enable_scrambling(struct drm_encoder *encoder) HDMI_WRITE(HDMI_SCRAMBLER_CTL, HDMI_READ(HDMI_SCRAMBLER_CTL) | VC5_HDMI_SCRAMBLER_CTL_ENABLE); + + queue_delayed_work(system_wq, &vc4_hdmi->scrambling_work, + msecs_to_jiffies(SCRAMBLING_POLLING_DELAY_MS)); } static void vc4_hdmi_disable_scrambling(struct drm_encoder *encoder) @@ -516,6 +521,9 @@ static void vc4_hdmi_disable_scrambling(struct drm_encoder *encoder) if (crtc && !vc4_hdmi_mode_needs_scrambling(&crtc->mode)) return; + if (delayed_work_pending(&vc4_hdmi->scrambling_work)) + cancel_delayed_work_sync(&vc4_hdmi->scrambling_work); + HDMI_WRITE(HDMI_SCRAMBLER_CTL, HDMI_READ(HDMI_SCRAMBLER_CTL) & ~VC5_HDMI_SCRAMBLER_CTL_ENABLE); @@ -523,6 +531,22 @@ static void vc4_hdmi_disable_scrambling(struct drm_encoder *encoder) drm_scdc_set_high_tmds_clock_ratio(vc4_hdmi->ddc, false); } +static void vc4_hdmi_scrambling_wq(struct work_struct *work) +{ + struct vc4_hdmi *vc4_hdmi = container_of(to_delayed_work(work), + struct vc4_hdmi, + scrambling_work); + + if (drm_scdc_get_scrambling_status(vc4_hdmi->ddc)) + return; + + drm_scdc_set_high_tmds_clock_ratio(vc4_hdmi->ddc, true); + drm_scdc_set_scrambling(vc4_hdmi->ddc, true); + + queue_delayed_work(system_wq, &vc4_hdmi->scrambling_work, + msecs_to_jiffies(SCRAMBLING_POLLING_DELAY_MS)); +} + static void vc4_hdmi_encoder_post_crtc_disable(struct drm_encoder *encoder, struct drm_atomic_state *state) { @@ -2031,6 +2055,7 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) vc4_hdmi = devm_kzalloc(dev, sizeof(*vc4_hdmi), GFP_KERNEL); if (!vc4_hdmi) return -ENOMEM; + INIT_DELAYED_WORK(&vc4_hdmi->scrambling_work, vc4_hdmi_scrambling_wq); dev_set_drvdata(dev, vc4_hdmi); encoder = &vc4_hdmi->encoder.base.base; diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.h b/drivers/gpu/drm/vc4/vc4_hdmi.h index 3cd021136402..00efcf291c5a 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.h +++ b/drivers/gpu/drm/vc4/vc4_hdmi.h @@ -126,6 +126,8 @@ struct vc4_hdmi { struct vc4_hdmi_encoder encoder; struct drm_connector connector; + struct delayed_work scrambling_work; + struct i2c_adapter *ddc; void __iomem *hdmicore_regs; void __iomem *hd_regs; -- 2.31.1