public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mihail Atanassov <Mihail.Atanassov@arm.com>
To: "Lowry Li (Arm Technology China)" <Lowry.Li@arm.com>
Cc: Brian Starkey <Brian.Starkey@arm.com>,
	Liviu Dudau <Liviu.Dudau@arm.com>,
	"james qian wang (Arm Technology China)"
	<james.qian.wang@arm.com>,
	"maarten.lankhorst@linux.intel.com" 
	<maarten.lankhorst@linux.intel.com>,
	"seanpaul@chromium.org" <seanpaul@chromium.org>,
	"airlied@linux.ie" <airlied@linux.ie>,
	"Julien Yin (Arm Technology China)" <Julien.Yin@arm.com>,
	"Jonathan Chai (Arm Technology China)" <Jonathan.Chai@arm.com>,
	Ayan Halder <Ayan.Halder@arm.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	nd <nd@arm.com>
Subject: Re: [PATCH] drm/komeda: Set output color depth for output
Date: Tue, 8 Oct 2019 11:18:56 +0000	[thread overview]
Message-ID: <3803267.CWkr2XGRCA@e123338-lin> (raw)
In-Reply-To: <20191008102818.GB16398@lowli01-ThinkStation-P300>

On Tuesday, 8 October 2019 11:28:24 BST Lowry Li (Arm Technology China) wrote:
> Hi Brian,
> On Tue, Oct 08, 2019 at 09:36:09AM +0000, Brian Starkey wrote:
> > Hi Lowry,
> > 
> > On Tue, Oct 08, 2019 at 09:17:52AM +0000, Lowry Li (Arm Technology China) wrote:
> > > Set color_depth according to connector->bpc.
> > > 
> > > Signed-off-by: Lowry Li (Arm Technology China) <lowry.li@arm.com>
> > > ---
> > >  .../arm/display/komeda/d71/d71_component.c    |  1 +
> > >  .../gpu/drm/arm/display/komeda/komeda_crtc.c  | 20 +++++++++++++++++++
> > >  .../gpu/drm/arm/display/komeda/komeda_kms.h   |  2 ++
> > >  .../drm/arm/display/komeda/komeda_pipeline.h  |  1 +
> > >  .../display/komeda/komeda_pipeline_state.c    | 19 ++++++++++++++++++
> > >  .../arm/display/komeda/komeda_wb_connector.c  |  4 ++++
> > >  6 files changed, 47 insertions(+)
> > > 
> > > diff --git a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> > > index c3d29c0b051b..27cdb03573c1 100644
> > > --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> > > +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> > > @@ -951,6 +951,7 @@ static void d71_improc_update(struct komeda_component *c,
> > >  			       to_d71_input_id(state, index));
> > >  
> > >  	malidp_write32(reg, BLK_SIZE, HV_SIZE(st->hsize, st->vsize));
> > > +	malidp_write32(reg, IPS_DEPTH, st->color_depth);
> > >  }
> > >  
> > >  static void d71_improc_dump(struct komeda_component *c, struct seq_file *sf)
> > > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> > > index 75263d8cd0bd..baa986b70876 100644
> > > --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> > > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> > > @@ -17,6 +17,26 @@
> > >  #include "komeda_dev.h"
> > >  #include "komeda_kms.h"
> > >  
> > > +void komeda_crtc_get_color_config(struct drm_crtc_state *crtc_st,
> > > +				  u32 *color_depths)
> > > +{
> > > +	struct drm_connector *conn;
> > > +	struct drm_connector_state *conn_st;
> > > +	int i, min_bpc = 31, conn_bpc = 0;
> > > +
> > > +	for_each_new_connector_in_state(crtc_st->state, conn, conn_st, i) {
> > > +		if (conn_st->crtc != crtc_st->crtc)
> > > +			continue;
> > > +
> > > +		conn_bpc = conn->display_info.bpc ? conn->display_info.bpc : 8;
> > 
> > We can have multiple connectors on a single CRTC (e.g. normal +
> > writeback), so what's the expected behaviour here in that case?
> > 
> > > +
> > > +		if (conn_bpc < min_bpc)
> > > +			min_bpc = conn_bpc;
> > > +	}
> > > +
> > > +	*color_depths = GENMASK(conn_bpc, 0);
> > > +}
> > > +
> > >  static void komeda_crtc_update_clock_ratio(struct komeda_crtc_state *kcrtc_st)
> > >  {
> > >  	u64 pxlclk, aclk;
> > > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
> > > index 45c498e15e7a..a42503451b5d 100644
> > > --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
> > > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
> > > @@ -166,6 +166,8 @@ static inline bool has_flip_h(u32 rot)
> > >  		return !!(rotation & DRM_MODE_REFLECT_X);
> > >  }
> > >  
> > > +void komeda_crtc_get_color_config(struct drm_crtc_state *crtc_st,
> > > +				  u32 *color_depths);
> > >  unsigned long komeda_crtc_get_aclk(struct komeda_crtc_state *kcrtc_st);
> > >  
> > >  int komeda_kms_setup_crtcs(struct komeda_kms_dev *kms, struct komeda_dev *mdev);
> > > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
> > > index b322f52ba8f2..7653f134a8eb 100644
> > > --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
> > > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
> > > @@ -323,6 +323,7 @@ struct komeda_improc {
> > >  
> > >  struct komeda_improc_state {
> > >  	struct komeda_component_state base;
> > > +	u8 color_depth;
> > >  	u16 hsize, vsize;
> > >  };
> > >  
> > > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> > > index 0ba9c6aa3708..e68e8f85ab27 100644
> > > --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> > > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> > > @@ -743,6 +743,7 @@ komeda_improc_validate(struct komeda_improc *improc,
> > >  		       struct komeda_data_flow_cfg *dflow)
> > >  {
> > >  	struct drm_crtc *crtc = kcrtc_st->base.crtc;
> > > +	struct drm_crtc_state *crtc_st = &kcrtc_st->base;
> > >  	struct komeda_component_state *c_st;
> > >  	struct komeda_improc_state *st;
> > >  
> > > @@ -756,6 +757,24 @@ komeda_improc_validate(struct komeda_improc *improc,
> > >  	st->hsize = dflow->in_w;
> > >  	st->vsize = dflow->in_h;
> > >  
> > > +	if (drm_atomic_crtc_needs_modeset(crtc_st)) {
> > > +		u32 output_depths;
> > > +		u32 avail_depths;
> > > +
> > > +		komeda_crtc_get_color_config(crtc_st,
> > > +					     &output_depths);
> > > +
> > > +		avail_depths = output_depths & improc->supported_color_depths;
> > > +		if (avail_depths == 0) {
> > > +			DRM_DEBUG_ATOMIC("No available color depths, conn depths: 0x%x & display: 0x%x\n",
> > > +					 output_depths,
> > > +					 improc->supported_color_depths);
> > > +			return -EINVAL;
> > > +		}
> > > +
> > > +		st->color_depth = __fls(avail_depths);
> > > +	}
> > > +
> > >  	komeda_component_add_input(&st->base, &dflow->input, 0);
> > >  	komeda_component_set_output(&dflow->input, &improc->base, 0);
> > >  
> > > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c b/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c
> > > index 2851cac94d86..740a81250630 100644
> > > --- a/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c
> > > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c
> > > @@ -142,6 +142,7 @@ static int komeda_wb_connector_add(struct komeda_kms_dev *kms,
> > >  	struct komeda_dev *mdev = kms->base.dev_private;
> > >  	struct komeda_wb_connector *kwb_conn;
> > >  	struct drm_writeback_connector *wb_conn;
> > > +	struct drm_display_info *info;
> > >  	u32 *formats, n_formats = 0;
> > >  	int err;
> > >  
> > > @@ -171,6 +172,9 @@ static int komeda_wb_connector_add(struct komeda_kms_dev *kms,
> > >  
> > >  	drm_connector_helper_add(&wb_conn->base, &komeda_wb_conn_helper_funcs);
> > >  
> > > +	info = &kwb_conn->base.base.display_info;
> > > +	info->bpc = __fls(kcrtc->master->improc->supported_color_depths);
> > > +
> > 
> > The IPS color depth doesn't really apply to writeback. Maybe we should
> > just skip the writeback connector?
> > 
> > Thanks,
> > -Brian
> > 
> Yes, the color depth not apply to writeback. We adds it because:
> 
> In the komeda_crtc_get_color_config() will loop all connectors of CRTC
> including the wb_conn, since crtc always has wb_conn. If not setting
> here, wb_conn->bpc will be set it to 8bit forcely in komeda_crtc_get_color_config() which will lead crtc bpc to 8bits all the time. So we are setting the
> largest supported depth to kwb_conn->bpc here.
> 
I agree with Brian here, it sounds like you need to fix
komeda_crtc_get_color_config() rather than putting in arcane bpc
values and invoking spooky action. Connectors have a type [1], so
it's easy to filter WB connectors out of the loop.

[1] e.g. DRM_MODE_CONNECTOR_WRITEBACK in this case.

> > >  	kcrtc->wb_conn = kwb_conn;
> > >  
> > >  	return 0;
> 


-- 
Mihail




  reply	other threads:[~2019-10-08 11:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-08  9:17 [PATCH] drm/komeda: Set output color depth for output Lowry Li (Arm Technology China)
2019-10-08  9:35 ` Mihail Atanassov
2019-10-08 10:18   ` Lowry Li (Arm Technology China)
2019-10-08  9:36 ` Brian Starkey
2019-10-08 10:28   ` Lowry Li (Arm Technology China)
2019-10-08 11:18     ` Mihail Atanassov [this message]
2019-10-09  7:33       ` Lowry Li (Arm Technology China)
  -- strict thread matches above, loose matches on Subject: below --
2019-10-12  6:26 Lowry Li (Arm Technology China)
2019-10-12  6:50 Lowry Li (Arm Technology China)
2019-10-14  9:54 ` Mihail Atanassov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3803267.CWkr2XGRCA@e123338-lin \
    --to=mihail.atanassov@arm.com \
    --cc=Ayan.Halder@arm.com \
    --cc=Brian.Starkey@arm.com \
    --cc=Jonathan.Chai@arm.com \
    --cc=Julien.Yin@arm.com \
    --cc=Liviu.Dudau@arm.com \
    --cc=Lowry.Li@arm.com \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=james.qian.wang@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=nd@arm.com \
    --cc=seanpaul@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox