Received: by 2002:ab2:7a09:0:b0:1f8:46dc:890e with SMTP id k9csp82055lqo; Wed, 15 May 2024 08:17:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWn3ARMyJwLXeRAoIW2hEmmLxPHlRvmclvSrCp7m4sEigDHeEtZqi6TephYQfhoBQS33/PngmQfyeZ00FsCie9cBqD1k3tmf6+tGD9LRg== X-Google-Smtp-Source: AGHT+IFu7zA28mG+SWwuzvBbFWLtHWniOcgYOxPVPdzfnTHfCd2bblvFFjXJ4UTYuj9Qk857wxmq X-Received: by 2002:a05:620a:5638:b0:792:bf2f:377c with SMTP id af79cd13be357-792c75f364emr1772743085a.50.1715786242280; Wed, 15 May 2024 08:17:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715786242; cv=pass; d=google.com; s=arc-20160816; b=I65z1Cf/nOjylaSXXgXoTlVLoo67iXp5TtOHVXBlnjiHyCdlmJJFT1iVdkKZKoF3Ko j/GBi9uWJ6Du8M2S1+oFn/jCko9h32HIb0qjNdB48mfU2mDxMp3/ni1xmlUFzJZXoRUo ecP4ucx/2goc8xhK4iUz8wp/E8QOK5ZjGQxxPanNojZ/tZmZ9HktLXSkDgU2+Hc0Q0e2 rKNAHyZdboM+tJLe1W3jHjH7CPNWa3YZTnTIw5FD6oITxTxauidLnhiFBi6EMAxPy2AT Zq97pgt7EbAuuyW2ZYOsCXYo3H/o8noPFg536lcJMmiXGYRyiUwfU7S6aafK22MQyvkm +FiQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Z9DhrYZzp/EIYZ8abLcnEA0fy1NH812BKWTrOUW8L5k=; fh=gHhLz/4mlOp3BMNHAj14gi+uI7rCvrn5AnhcG5s20nQ=; b=xKGuJDlC8qRVQo2WoB76kFhc5gdlD8/Wi29q0JFSlcj5SnG8kpHRmzhhVz0KIadQbW k62HRViuIm2ctucqYD2Jpy+jFXSvgnq1IrkldU5rYg/znEGQOeQofF7RnIXfLPs8MlCJ 1zjwqK0lz3bJP+wwhxtHxFIUClMHK2XbUZOnXiqdaseydJsiOgvcLt+wOE1KVaqdlU3Y gTIOZkfUc1GNOZIXGttwxs2nElYDkIDNPpFFg7zWRa1POGZvr8bRKMJs1NxFqjQykqhO IE0T8FElDMPt2XkNoRZ/VLGblyjk+wzGws2jfwjOEKvh9cKmNv2f6agLnpMY9cPAXiI9 QBrg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Lr7SPNX2; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-180056-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180056-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-792bf278031si1378375885a.73.2024.05.15.08.17.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 08:17:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-180056-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Lr7SPNX2; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-180056-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180056-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E81761C21030 for ; Wed, 15 May 2024 15:17:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7239D155753; Wed, 15 May 2024 15:17:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Lr7SPNX2" Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 490EB62A02 for ; Wed, 15 May 2024 15:17:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715786235; cv=none; b=Mri3cIjhTpFUUjzNMVQcvwA8E+Er6/eYe1RG+963Bm9JOofuJXUrjEUS+99sYozLN17/oYd7HLSVF9BKLOvoXkqMHTDzhXRBv/niINLkQoKJ3ac/mgv1wmsEJp/IkIgluPT+siR7ip+3mwLnletpkGwBwdMy+rRHuYE1SV7nxkA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715786235; c=relaxed/simple; bh=JygM0wi++CYnqmfN6Lmj9gMrZY+Usd3FTL4ZUxg5yC0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=f5SN44bwsRr063ZNA7AUySX5UKd7iUS8ePwhf0YXHJa7m3dYcr3XC89Ig1DGe4uqzLzx3/5oW8hAmtjw/iu/QPdjFR0CU8vbEJ5bdLyTYo+7XPMnZW3H4X2tCfYMCNNvcD/k31psNldRBTD8lJK0zJd6dHhq/9owpIFYgoff+zU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Lr7SPNX2; arc=none smtp.client-ip=209.85.167.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-51f0602bc58so7012248e87.0 for ; Wed, 15 May 2024 08:17:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715786230; x=1716391030; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=Z9DhrYZzp/EIYZ8abLcnEA0fy1NH812BKWTrOUW8L5k=; b=Lr7SPNX2jct3kth+Vqt2D+tobUqylGaoaCVzw31Rcq3NmvB397LnCmZr7WateiQMR5 ZA2tEhFEaMi08lyUn5DaZsNTBfcDVbMV5oZ54ggYFGjMu45JJAtWAo+GLoKg3uA62RiC B8eKb60gHtozt7mN8FknIbwmZTEKa2bO3WxIQT4fpXBHYrG4/YULYXdo9cHa2O2LXbEZ mVtTwAReymDUhZ+bDhUg3/tdVfRLo5ZjtS5rO3McRP166ZFOCKBx6vdmG9smYazD29/w t3zFfWz4pAP3Z80huvHPJHZ89S3aNxoFo05ouwyDdMAkIDxlxjbwFOg/HVsFi8EWXTgt 77sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715786230; x=1716391030; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Z9DhrYZzp/EIYZ8abLcnEA0fy1NH812BKWTrOUW8L5k=; b=RYqZRyGWbZEg6C/R2TLvOWsQMXA5QQ+JgTN5bTgIcOKBpXpwXgikiEFn6VCW10ca1y fKydnteMNd8H2g6Y4WIC8b5AN6eHow/PrSPz+4no+Zj6ven9pE/ISaaqVwaxcGK3naJh DCz2SHYcjTusITX384MWB+WVYkIRCjwx7j/+/dVFIGa/bZqBxawfaZHfBzWpG85vAsqD HVQmmWByVIZHs8uc3i6HWMwE53X0UUpPSzmtM8jJVKJ2h+L9pt3WPWJkZrt4NDbQO/dz Q9vMo91AyNt8aIt0wHcOqpxmCjDWu0YJ2lML63a5Ll3JPPuAqrrwacP5xzUliyjeo9o2 IUUg== X-Forwarded-Encrypted: i=1; AJvYcCXCL5aCHFfppZn0DsjMyRyh1rdvS4kv820bIyX6FS6tG3/odJjlx2t/lcksuu0mCA4T6HQdgTGnL9vTUjHME7XQVd3obykH/apYc2xV X-Gm-Message-State: AOJu0YxhqXKDJrYhoSs8sVAHPhzFA2qCQjyQ/TZc9YB8WUv9CwxbUQNL gTtXwus55/Cb9jLy3I8cW6xk5y407d14ClwrLy8xyegX5fOlrxol9gDy/J4EvpY= X-Received: by 2002:a05:6512:33d2:b0:51f:5f6d:3fba with SMTP id 2adb3069b0e04-521e126be71mr7515859e87.27.1715786230365; Wed, 15 May 2024 08:17:10 -0700 (PDT) Received: from eriador.lumag.spb.ru (dzdbxzyyyyyyyyyyyykxt-3.rev.dnainternet.fi. [2001:14ba:a0c3:3a00::227]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-521f38d8784sm2543785e87.191.2024.05.15.08.17.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 08:17:09 -0700 (PDT) Date: Wed, 15 May 2024 18:17:08 +0300 From: Dmitry Baryshkov To: Keith Zhao Cc: "devicetree@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" , "linux-riscv@lists.infradead.org" , "aou@eecs.berkeley.edu" , "suijingfeng@loongson.cn" , "tzimmermann@suse.de" , "paul.walmsley@sifive.com" , "mripard@kernel.org" , Xingyu Wu , Jack Zhu , "palmer@dabbelt.com" , "krzysztof.kozlowski+dt@linaro.org" , William Qiu , Shengyang Chen , Changhuang Liang Subject: Re: [v3 6/6] drm/vs: simple encoder Message-ID: References: <20231204123315.28456-1-keith.zhao@starfivetech.com> <20231204123315.28456-7-keith.zhao@starfivetech.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Wed, May 15, 2024 at 10:07:27AM +0000, Keith Zhao wrote: > > > > -----Original Message----- > > From: Dmitry Baryshkov > > Sent: 2023年12月5日 21:19 > > To: Keith Zhao > > Cc: devicetree@vger.kernel.org; dri-devel@lists.freedesktop.org; > > linux-kernel@vger.kernel.org; linux-riscv@lists.infradead.org; > > aou@eecs.berkeley.edu; suijingfeng@loongson.cn; tzimmermann@suse.de; > > paul.walmsley@sifive.com; mripard@kernel.org; Xingyu Wu > > ; Jack Zhu ; > > palmer@dabbelt.com; krzysztof.kozlowski+dt@linaro.org; William Qiu > > ; Shengyang Chen > > ; Changhuang Liang > > > > Subject: Re: [v3 6/6] drm/vs: simple encoder > > > > On Tue, 5 Dec 2023 at 15:14, Dmitry Baryshkov > > wrote: > > > > > > On Mon, 4 Dec 2023 at 14:33, Keith Zhao > > wrote: > > > > > > > > add simple encoder for dsi bridge > > > > > > This doesn't look like a proper commit message. > > > > > > > > > > > Signed-off-by: Keith Zhao > > > > --- > > > > drivers/gpu/drm/verisilicon/Makefile | 4 +- > > > > drivers/gpu/drm/verisilicon/vs_drv.c | 2 + > > > > drivers/gpu/drm/verisilicon/vs_simple_enc.c | 195 > > > > ++++++++++++++++++++ drivers/gpu/drm/verisilicon/vs_simple_enc.h | > > > > 23 +++ > > > > 4 files changed, 223 insertions(+), 1 deletion(-) create mode > > > > 100644 drivers/gpu/drm/verisilicon/vs_simple_enc.c > > > > create mode 100644 drivers/gpu/drm/verisilicon/vs_simple_enc.h > > > > > > > > diff --git a/drivers/gpu/drm/verisilicon/Makefile > > > > b/drivers/gpu/drm/verisilicon/Makefile > > > > index 71fadafcee13..cd5d0a90bcfe 100644 > > > > --- a/drivers/gpu/drm/verisilicon/Makefile > > > > +++ b/drivers/gpu/drm/verisilicon/Makefile > > > > @@ -5,6 +5,8 @@ vs_drm-objs := vs_dc_hw.o \ > > > > vs_crtc.o \ > > > > vs_drv.o \ > > > > vs_modeset.o \ > > > > - vs_plane.o > > > > + vs_plane.o \ > > > > + vs_simple_enc.o > > > > + > > > > vs_drm-$(CONFIG_DRM_VERISILICON_STARFIVE_HDMI) += > > starfive_hdmi.o > > > > obj-$(CONFIG_DRM_VERISILICON) += vs_drm.o diff --git > > > > a/drivers/gpu/drm/verisilicon/vs_drv.c > > > > b/drivers/gpu/drm/verisilicon/vs_drv.c > > > > index d7e5199fe293..946f137ab124 100644 > > > > --- a/drivers/gpu/drm/verisilicon/vs_drv.c > > > > +++ b/drivers/gpu/drm/verisilicon/vs_drv.c > > > > @@ -23,6 +23,7 @@ > > > > #include "vs_drv.h" > > > > #include "vs_modeset.h" > > > > #include "vs_dc.h" > > > > +#include "vs_simple_enc.h" > > > > > > > > #define DRV_NAME "verisilicon" > > > > #define DRV_DESC "Verisilicon DRM driver" > > > > @@ -217,6 +218,7 @@ static struct platform_driver *drm_sub_drivers[] > > > > = { #ifdef CONFIG_DRM_VERISILICON_STARFIVE_HDMI > > > > &starfive_hdmi_driver, > > > > #endif > > > > + &simple_encoder_driver, > > > > }; > > > > > > > > static struct component_match *vs_drm_match_add(struct device *dev) > > > > diff --git a/drivers/gpu/drm/verisilicon/vs_simple_enc.c > > > > b/drivers/gpu/drm/verisilicon/vs_simple_enc.c > > > > new file mode 100644 > > > > index 000000000000..c5a8d82bc469 > > > > --- /dev/null > > > > +++ b/drivers/gpu/drm/verisilicon/vs_simple_enc.c > > > > @@ -0,0 +1,195 @@ > > > > +// SPDX-License-Identifier: GPL-2.0 > > > > +/* > > > > + * Copyright (C) 2020 VeriSilicon Holdings Co., Ltd. > > > > + */ > > > > +#include > > > > +#include > > > > +#include > > > > + > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include #include > > > > + > > > > +#include "vs_crtc.h" > > > > +#include "vs_simple_enc.h" > > > > + > > > > +static const struct simple_encoder_priv dsi_priv = { > > > > > > Please use proper prefix for all the struct and function names. > > > vs_simple_encoder sounds better. Or vs_dsi_encoder. > > > > > > > + .encoder_type = DRM_MODE_ENCODER_DSI }; > > > > + > > > > +static inline struct simple_encoder *to_simple_encoder(struct > > > > +drm_encoder *enc) { > > > > + return container_of(enc, struct simple_encoder, encoder); } > > > > + > > > > +static int encoder_parse_dt(struct device *dev) { > > > > + struct simple_encoder *simple = dev_get_drvdata(dev); > > > > + unsigned int args[2]; > > > > + > > > > + simple->dss_regmap = > > syscon_regmap_lookup_by_phandle_args(dev->of_node, > > > > + > > "starfive,syscon", > > > > + > > 2, > > > > + args); > > > > + > > > > + if (IS_ERR(simple->dss_regmap)) { > > > > + return dev_err_probe(dev, > > PTR_ERR(simple->dss_regmap), > > > > + "getting the regmap > > failed\n"); > > > > + } > > > > + > > > > + simple->offset = args[0]; > > > > + simple->mask = args[1]; > > > > + > > > > + return 0; > > > > +} > > > > + > > > > +void encoder_atomic_enable(struct drm_encoder *encoder, > > > > + struct drm_atomic_state *state) { > > > > + struct simple_encoder *simple = to_simple_encoder(encoder); > > > > + > > > > + regmap_update_bits(simple->dss_regmap, simple->offset, > > simple->mask, > > > > + simple->mask); } > > > > + > > > > +int encoder_atomic_check(struct drm_encoder *encoder, > > > > + struct drm_crtc_state *crtc_state, > > > > + struct drm_connector_state *conn_state) { > > > > + struct vs_crtc_state *vs_crtc_state = > > to_vs_crtc_state(crtc_state); > > > > + struct drm_connector *connector = conn_state->connector; > > > > + int ret = 0; > > > > + > > > > + struct drm_bridge *first_bridge = > > drm_bridge_chain_get_first_bridge(encoder); > > > > + struct drm_bridge_state *bridge_state = ERR_PTR(-EINVAL); > > > > + > > > > + vs_crtc_state->encoder_type = encoder->encoder_type; > > > > + > > > > + if (first_bridge && first_bridge->funcs->atomic_duplicate_state) > > > > + bridge_state = > > > > + drm_atomic_get_bridge_state(crtc_state->state, first_bridge); > > > > > > Please don't poke into others' playground. This should go into your > > > DSI bridge's atomic_check() instead. > > > > Hmm. And you can not use vs_crtc_state from your bridge. Actually this design > > makes me wonder, how does your hardware work? Is it possible to send the DSI > > commands to the panel? > > > Hi Dmitry: > 1、 This fun is used to check the media bus format whether in support list , if not , this mode will be invalid, > I just used the bridge api to get the media bus format. (sync with the input bridge(connector) bus format) > 2、 the bridge doesn't care the vs_crtc_state, just do their own drm_bridge_funcs ->atomic_check, > or it will be impossible to make this dsi encoder to fit dsi bridge driver. > 3、 hardware work : > encoder_atomic_check get the media bus format and update it to vs_crtc_state-> output_fmt, > during the crtc_enable , it will write the output_fmt to hardware . > > 4、 to send dsi command to panel , It is only relevant to dsi controllers and panel driver (bridge and panel ), > It does not involve the logic associated with encoder and crtc Do you have a pointer to your DSI bridge driver somewhere (a preliminary version is ok, if it's not ready yet for upstream submission). From the current design it seems that there is no need for a separate 'simple' encoder. Instead it might be easier/better to transform your DSI bridge driver into an encoder driver, especially as you are prety flexible in the component connections. > > https://elixir.bootlin.com/linux/v6.6.30/source/drivers/gpu/drm/mxsfb/lcdif_kms.c#L457 > Do the similar logic -- With best wishes Dmitry