Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp305393pxa; Wed, 12 Aug 2020 02:26:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwoYvaXpx87dHgGttA80Avq1m91NQd2voam3Iqv/XQii8Y/LLogCmhsqj01tM72Wq9B1XkC X-Received: by 2002:a05:6402:899:: with SMTP id e25mr29538480edy.311.1597224393879; Wed, 12 Aug 2020 02:26:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597224393; cv=none; d=google.com; s=arc-20160816; b=cEaUsXO17Bpw2cRCoajRuUauOQebOobc9lLicZqyw12rPI7s1boeuFhJfBmLJGENju AEEr318UE6sp/vL15LkgBlGeoVDSiHXncVN2HR7O7SfN4glxRUlwKDtwZ6GQ0jRy4yrA DRYPrHX0NcGM8mqdQTKHgmLWhwtv3Zql+raoVqBA8dyXasrb9UHA/orFhmr1vEl8h1bD aJbIyeSX1D0BI63jF/UHopk0vIpG3lqYZHiWKzFXQigF4sB8It2pGgt6CxsFno4jQ5YQ 81sdB6rUU/q6bfoihnglKzur2tDBzZ6IPJSZnA52rycpaUfr48H9OLgG5hxAzjBdkIrt 77rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Nqn+SCbB+Ow5iQ0TNJqZ4fTgzWWwqUxWr/j2IkCVn9c=; b=vTpqLckEU5tpdoxw0lD1cJpv097akp1vO3MeiLwlU76aPYTELTviOgAj/NG5uKy+R9 g3bKvjBZUdZqNlNQ4Npfl5yDG8pihX6dPZSF5hIU1kt0O3C7HVDvPSNb73qUSSvD3uXV 68UEXDUwZZzkx3lyhu+/HwIK09EpM8PhrmkG3+h4PUlii3cjaBZ4Me3Yq60YA4YxZRkL GVI6upNaB6ahwYoMAjRX2snpBCnVzLirhE8WyZ5PYS4iY6XLqvnVohE2xK1HX8t4Pj3c 8uAv6Sim+bgjzTtUeDCV+MmVkkUuNBZVDCYmMQhpk1ev3yZ+toljLSWB+aQsPEJfEskZ u1dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=RNDEHMva; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 39si926035edq.552.2020.08.12.02.26.11; Wed, 12 Aug 2020 02:26:33 -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 (test mode) header.i=@ideasonboard.com header.s=mail header.b=RNDEHMva; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727820AbgHLJWe (ORCPT + 99 others); Wed, 12 Aug 2020 05:22:34 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:48174 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726255AbgHLJWe (ORCPT ); Wed, 12 Aug 2020 05:22:34 -0400 Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CC848595; Wed, 12 Aug 2020 11:22:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1597224151; bh=WxR0bD/qesCEzDS1TUdLg+fPZgf/ua764mXYDcrsEP4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RNDEHMva105JzWO24cpP4ermJi5VqV6dodewcVqPLcIDJ/pBO+/p5kzEZaKMhjYGN 9EGTF3SHWxD+Wgc0hSWdWx9mT/q3jm/vhQgPReZnx373MefyA335m7BAw6Vrn//yMi O/R/sFrA1PcdzDNmsEZzARurxNHIUFcs4cXZphEU= Date: Wed, 12 Aug 2020 12:22:17 +0300 From: Laurent Pinchart To: Algea Cao Cc: a.hajda@samsung.com, kuankuan.y@gmail.com, hjc@rock-chips.com, tzimmermann@suse.de, dri-devel@lists.freedesktop.org, sam@ravnborg.org, airlied@linux.ie, heiko@sntech.de, jernej.skrabec@siol.net, laurent.pinchart+renesas@ideasonboard.com, jonas@kwiboo.se, mripard@kernel.org, darekm@google.com, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, cychiang@chromium.org, linux-kernel@vger.kernel.org, narmstrong@baylibre.com, jbrunet@baylibre.com, maarten.lankhorst@linux.intel.com, daniel@ffwll.ch Subject: Re: [PATCH 2/6] drm: bridge: dw-hdmi: Implement connector atomic_begin/atomic_flush Message-ID: <20200812092217.GC6057@pendragon.ideasonboard.com> References: <20200812083120.743-1-algea.cao@rock-chips.com> <20200812083433.934-1-algea.cao@rock-chips.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200812083433.934-1-algea.cao@rock-chips.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Algea, Thank you for the patch. On Wed, Aug 12, 2020 at 04:34:33PM +0800, Algea Cao wrote: > Introduce dw_hdmi_connector_atomic_begin() and > dw_hdmi_connector_atomic_flush() to implement connector > atomic_begin/atomic_flush. When enc_out_bus_format or > enc_in_bus_format changed, dw_hdmi_setup is called. > > To avoid screen flash when updating bus format, it's need > to send AVMUTE flag to make screen black, and clear flag > after bus format updated. > > Signed-off-by: Algea Cao > --- > > drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 65 +++++++++++++++++++++++ > drivers/gpu/drm/bridge/synopsys/dw-hdmi.h | 4 ++ > 2 files changed, 69 insertions(+) > > diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c > index 6148a022569a..a1a81fc768c2 100644 > --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c > +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c > @@ -108,6 +108,8 @@ struct hdmi_vmode { > }; > > struct hdmi_data_info { > + unsigned int prev_enc_in_bus_format; > + unsigned int prev_enc_out_bus_format; > unsigned int enc_in_bus_format; > unsigned int enc_out_bus_format; > unsigned int enc_in_encoding; > @@ -116,6 +118,7 @@ struct hdmi_data_info { > unsigned int hdcp_enable; > struct hdmi_vmode video_mode; > bool rgb_limited_range; > + bool update; > }; > > struct dw_hdmi_i2c { > @@ -2401,6 +2404,60 @@ static int dw_hdmi_connector_get_modes(struct drm_connector *connector) > return ret; > } > > +static void > +dw_hdmi_connector_atomic_begin(struct drm_connector *connector, > + struct drm_connector_state *conn_state) > +{ > + struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi, > + connector); > + unsigned int enc_in_bus_fmt = hdmi->hdmi_data.enc_in_bus_format; > + unsigned int enc_out_bus_fmt = hdmi->hdmi_data.enc_out_bus_format; > + unsigned int prev_enc_in_bus_fmt = > + hdmi->hdmi_data.prev_enc_in_bus_format; > + unsigned int prev_enc_out_bus_fmt = > + hdmi->hdmi_data.prev_enc_out_bus_format; > + > + if (!conn_state->crtc) > + return; > + > + if (!hdmi->hdmi_data.video_mode.mpixelclock) > + return; > + > + if (enc_in_bus_fmt != prev_enc_in_bus_fmt || > + enc_out_bus_fmt != prev_enc_out_bus_fmt) { > + hdmi->hdmi_data.update = true; > + hdmi_writeb(hdmi, HDMI_FC_GCP_SET_AVMUTE, HDMI_FC_GCP); > + /* Add delay to make av mute work on sink*/ > + msleep(50); > + } else { > + hdmi->hdmi_data.update = false; > + } > +} > + > +static void > +dw_hdmi_connector_atomic_flush(struct drm_connector *connector, > + struct drm_connector_state *conn_state) > +{ > + struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi, > + connector); > + > + if (!conn_state->crtc) > + return; > + > + DRM_DEBUG("%s\n", __func__); > + > + if (hdmi->hdmi_data.update) { > + dw_hdmi_setup(hdmi, hdmi->curr_conn, &hdmi->previous_mode); > + /* > + * Before clear AVMUTE, delay is needed to > + * prevent display flash. > + */ > + msleep(50); > + hdmi_writeb(hdmi, HDMI_FC_GCP_CLEAR_AVMUTE, HDMI_FC_GCP); > + hdmi->hdmi_data.update = false; > + } > +} > + > static bool hdr_metadata_equal(const struct drm_connector_state *old_state, > const struct drm_connector_state *new_state) > { > @@ -2465,6 +2522,8 @@ static const struct drm_connector_funcs dw_hdmi_connector_funcs = { > static const struct drm_connector_helper_funcs dw_hdmi_connector_helper_funcs = { > .get_modes = dw_hdmi_connector_get_modes, > .atomic_check = dw_hdmi_connector_atomic_check, > + .atomic_begin = dw_hdmi_connector_atomic_begin, > + .atomic_flush = dw_hdmi_connector_atomic_flush, > }; > > static int dw_hdmi_connector_create(struct dw_hdmi *hdmi) > @@ -2778,6 +2837,12 @@ static int dw_hdmi_bridge_atomic_check(struct drm_bridge *bridge, > { > struct dw_hdmi *hdmi = bridge->driver_private; > > + hdmi->hdmi_data.prev_enc_out_bus_format = > + hdmi->hdmi_data.enc_out_bus_format; > + > + hdmi->hdmi_data.prev_enc_in_bus_format = > + hdmi->hdmi_data.enc_in_bus_format; > + > hdmi->hdmi_data.enc_out_bus_format = > bridge_state->output_bus_cfg.format; > .atomic_check() isn't allowed to change the device state, neither the hardware state, nor the software state stored in struct dw_hdmi. You essentially need to treat the drm_bridge and dw_hdmi as const in the .atomic_check() operation. > diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.h b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.h > index 1999db05bc3b..05182418efbb 100644 > --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.h > +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.h > @@ -842,6 +842,10 @@ enum { > HDMI_FC_AVICONF3_QUANT_RANGE_LIMITED = 0x00, > HDMI_FC_AVICONF3_QUANT_RANGE_FULL = 0x04, > > +/* HDMI_FC_GCP */ > + HDMI_FC_GCP_SET_AVMUTE = 0x2, > + HDMI_FC_GCP_CLEAR_AVMUTE = 0x1, > + > /* FC_DBGFORCE field values */ > HDMI_FC_DBGFORCE_FORCEAUDIO = 0x10, > HDMI_FC_DBGFORCE_FORCEVIDEO = 0x1, -- Regards, Laurent Pinchart