From: Mihail Atanassov Subject: Re: [PATCH v3 2/6] drm/komeda: Add side by side plane_state split Date: Fri, 15 Nov 2019 00:00:01 +0000 Message-ID: <2843645.837eivR4I8@e123338-lin> References: <20191114083658.27237-1-james.qian.wang@arm.com> <20191114083658.27237-3-james.qian.wang@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <20191114083658.27237-3-james.qian.wang@arm.com> Content-Language: en-US Content-ID: <7D1CD7616721B640B0FC00B6AF507145@eurprd08.prod.outlook.com> Sender: linux-kernel-owner@vger.kernel.org To: "james qian wang (Arm Technology China)" Cc: nd , Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" , "Jonathan Chai (Arm Technology China)" , "Julien Yin (Arm Technology China)" , "Thomas Sun (Arm Technology China)" , "Lowry Li (Arm Technology China)" , Ayan Halder , "Tiannan Zhu (Arm Technology China)" , "Yiqi Kang (Arm Technology China)" nd , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" List-Id: dri-devel@lists.freedesktop.org On Thursday, 14 November 2019 08:37:31 GMT james qian wang (Arm Technology = China) wrote: > On side by side mode, The full display frame will be split into two parts > (Left/Right), and each part will be handled by a single pipeline separate= ly > master pipeline for left part, slave for right. >=20 > To simplify the usage and implementation, komeda use the following scheme > to do the side by side split > 1. The planes also have been grouped into two classes: > master-planes and slave-planes. > 2. The master plane can display its image on any location of the final/fu= ll > display frame, komeda will help to split the plane configuration to tw= o > parts and fed them into master and slave pipelines. > 3. The slave plane only can put its display rect on the right part of the > final display frame, and its data is only can be fed into the slave > pipeline. >=20 > From the perspective of resource usage and assignment: > The master plane can use the resources from the master pipeline and slave > pipeline both, but slave plane only can use the slave pipeline resources. >=20 > With such scheme, the usage of master planes are same as the none > side_by_side mode. user can easily skip the slave planes and no need to > consider side_by_side for them. >=20 > Signed-off-by: James Qian Wang (Arm Technology China) > --- > .../drm/arm/display/komeda/komeda_pipeline.h | 33 ++- > .../display/komeda/komeda_pipeline_state.c | 188 ++++++++++++++++++ > .../gpu/drm/arm/display/komeda/komeda_plane.c | 7 +- > 3 files changed, 220 insertions(+), 8 deletions(-) >=20 > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h b/drive= rs/gpu/drm/arm/display/komeda/komeda_pipeline.h > index 20a076cce635..4c0946fbaac1 100644 > --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h > @@ -521,6 +521,20 @@ komeda_component_pickup_output(struct komeda_compone= nt *c, u32 avail_comps) > return komeda_pipeline_get_first_component(c->pipeline, avail_inputs); > } > =20 > +static inline const char * > +komeda_data_flow_msg(struct komeda_data_flow_cfg *config) > +{ > + static char str[128]; > + > + snprintf(str, sizeof(str), > + "rot: %x src[x/y:%d/%d, w/h:%d/%d] disp[x/y:%d/%d, w/h:%d/%d]", > + config->rot, > + config->in_x, config->in_y, config->in_w, config->in_h, > + config->out_x, config->out_y, config->out_w, config->out_h); > + > + return str; > +} > + > struct komeda_plane_state; > struct komeda_crtc_state; > struct komeda_crtc; > @@ -532,22 +546,27 @@ int komeda_build_layer_data_flow(struct komeda_laye= r *layer, > struct komeda_plane_state *kplane_st, > struct komeda_crtc_state *kcrtc_st, > struct komeda_data_flow_cfg *dflow); > -int komeda_build_wb_data_flow(struct komeda_layer *wb_layer, > - struct drm_connector_state *conn_st, > - struct komeda_crtc_state *kcrtc_st, > - struct komeda_data_flow_cfg *dflow); > -int komeda_build_display_data_flow(struct komeda_crtc *kcrtc, > - struct komeda_crtc_state *kcrtc_st); > - > int komeda_build_layer_split_data_flow(struct komeda_layer *left, > struct komeda_plane_state *kplane_st, > struct komeda_crtc_state *kcrtc_st, > struct komeda_data_flow_cfg *dflow); > +int komeda_build_layer_sbs_data_flow(struct komeda_layer *layer, > + struct komeda_plane_state *kplane_st, > + struct komeda_crtc_state *kcrtc_st, > + struct komeda_data_flow_cfg *dflow); > + > +int komeda_build_wb_data_flow(struct komeda_layer *wb_layer, > + struct drm_connector_state *conn_st, > + struct komeda_crtc_state *kcrtc_st, > + struct komeda_data_flow_cfg *dflow); > int komeda_build_wb_split_data_flow(struct komeda_layer *wb_layer, > struct drm_connector_state *conn_st, > struct komeda_crtc_state *kcrtc_st, > struct komeda_data_flow_cfg *dflow); > =20 > +int komeda_build_display_data_flow(struct komeda_crtc *kcrtc, > + struct komeda_crtc_state *kcrtc_st); > + > int komeda_release_unclaimed_resources(struct komeda_pipeline *pipe, > struct komeda_crtc_state *kcrtc_st); > =20 > 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 0930234abb9d..5de0d231a1c3 100644 > --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c > @@ -1130,6 +1130,194 @@ int komeda_build_layer_split_data_flow(struct kom= eda_layer *left, > return err; > } > =20 > +/* split func will split configuration of master plane to two layer data > + * flows, which will be fed into master and slave pipeline then. > + * NOTE: @m_dflow is first used as input argument to pass the configurat= ion of > + * master_plane. when the split is done, @*m_dflow @*s_dflow are the > + * output data flow for pipeline. > + */ > +static int > +komeda_split_sbs_master_data_flow(struct komeda_crtc_state *kcrtc_st, > + struct komeda_data_flow_cfg **m_dflow, > + struct komeda_data_flow_cfg **s_dflow) > +{ > + struct komeda_data_flow_cfg *master =3D *m_dflow; > + struct komeda_data_flow_cfg *slave =3D *s_dflow; > + u32 disp_end =3D master->out_x + master->out_w; > + u16 boundary; > + > + pipeline_composition_size(kcrtc_st, &boundary, NULL); > + > + if (disp_end <=3D boundary) { > + /* the master viewport only located in master side, no need > + * slave anymore > + */ > + *s_dflow =3D NULL; > + } else if ((master->out_x < boundary) && (disp_end > boundary)) { > + /* the master viewport across two pipelines, split it */ > + bool flip_h =3D has_flip_h(master->rot); > + bool r90 =3D drm_rotation_90_or_270(master->rot); > + u32 src_x =3D master->in_x; > + u32 src_y =3D master->in_y; > + u32 src_w =3D master->in_w; > + u32 src_h =3D master->in_h; > + > + if (master->en_scaling || master->en_img_enhancement) { > + DRM_DEBUG_ATOMIC("sbs doesn't support to split a scaling image.\n"); > + return -EINVAL; > + } > + > + memcpy(slave, master, sizeof(*master)); > + > + /* master for left part of display, slave for the right part */ > + /* split the disp_rect */ > + master->out_w =3D boundary - master->out_x; > + slave->out_w =3D disp_end - boundary; > + slave->out_x =3D 0; > + > + if (r90) { > + master->in_h =3D master->out_w; > + slave->in_h =3D slave->out_w; > + > + if (flip_h) > + master->in_y =3D src_y + src_h - master->in_h; > + else > + slave->in_y =3D src_y + src_h - slave->in_h; > + } else { > + master->in_w =3D master->out_w; > + slave->in_w =3D slave->out_w; > + > + /* on flip_h, the left display content from the right-source */ > + if (flip_h) > + master->in_x =3D src_w + src_x - master->in_w; > + else > + slave->in_x =3D src_w + src_x - slave->in_w; It really bugs me that the order here is w/x/w but in the block above it's y/h/h. > + } > + } else if (master->out_x >=3D boundary) { > + /* disp_rect only locate in right part, move the dflow to slave */ > + master->out_x -=3D boundary; > + *s_dflow =3D master; > + *m_dflow =3D NULL; > + } > + > + return 0; > +} > + > +static int > +komeda_split_sbs_slave_data_flow(struct komeda_crtc_state *kcrtc_st, > + struct komeda_data_flow_cfg *slave) > +{ > + u16 boundary; > + > + pipeline_composition_size(kcrtc_st, &boundary, NULL); > + > + if (slave->out_x < boundary) { > + DRM_DEBUG_ATOMIC("SBS Slave plane is only allowed to configure the rig= ht part frame.\n"); > + return -EINVAL; > + } > + > + /* slave->disp_rect locate in the right part */ > + slave->out_x -=3D boundary; > + > + return 0; > +} > + > +/* On side by side mode, The full display frame will be split to two par= ts > + * (Left/Right), and each part will be handled by a single pipeline sepa= rately, > + * master pipeline for left part, slave for right. > + * > + * To simplify the usage and implementation, komeda use the following sc= heme > + * to do the side by side split > + * 1. The planes also have been grouped into two classes: > + * master-planes and slave-planes. > + * 2. The master plane can display its image on any location of the fina= l/full > + * display frame, komeda will help to split the plane configuration t= o two > + * parts and fed them into master and slave pipelines. > + * 3. The slave plane only can put its display rect on the right part of= the > + * final display frame, and its data is only can be fed into the slav= e > + * pipeline. > + * > + * From the perspective of resource usage and assignment: > + * The master plane can use the resources from the master pipeline and s= lave > + * pipeline both, but slave plane only can use the slave pipeline resour= ces. > + * > + * With such scheme, the usage of master planes are same as the none > + * side_by_side mode. user can easily skip the slave planes and no need = to > + * consider side_by_side for them. > + * > + * NOTE: side_by_side split is occurred on pipeline level which split th= e plane > + * data flow into pipelines, but the layer split is a pipeline > + * internal split which splits the data flow into pipeline layers. > + * So komeda still supports to apply a further layer split to the sbs > + * split data flow. > + */ > +int komeda_build_layer_sbs_data_flow(struct komeda_layer *layer, > + struct komeda_plane_state *kplane_st, > + struct komeda_crtc_state *kcrtc_st, > + struct komeda_data_flow_cfg *dflow) > +{ > + struct komeda_crtc *kcrtc =3D to_kcrtc(kcrtc_st->base.crtc); > + struct drm_plane *plane =3D kplane_st->base.plane; > + struct komeda_data_flow_cfg temp, *master_dflow, *slave_dflow; > + struct komeda_layer *master, *slave; > + bool master_plane =3D layer->base.pipeline =3D=3D kcrtc->master; > + int err; > + > + DRM_DEBUG_ATOMIC("SBS prepare %s-[PLANE:%d:%s]: %s.\n", > + master_plane ? "Master" : "Slave", > + plane->base.id, plane->name, > + komeda_data_flow_msg(dflow)); > + > + if (master_plane) { > + master =3D layer; > + slave =3D layer->sbs_slave; > + master_dflow =3D dflow; > + slave_dflow =3D &temp; > + err =3D komeda_split_sbs_master_data_flow(kcrtc_st, > + &master_dflow, &slave_dflow); > + } else { > + master =3D NULL; > + slave =3D layer; > + master_dflow =3D NULL; > + slave_dflow =3D dflow; > + err =3D komeda_split_sbs_slave_data_flow(kcrtc_st, slave_dflow); > + } > + > + if (err) > + return err; > + > + if (master_dflow) { > + DRM_DEBUG_ATOMIC("SBS Master-%s assigned: %s\n", > + master->base.name, komeda_data_flow_msg(master_dflow)); > + > + if (master_dflow->en_split) > + err =3D komeda_build_layer_split_data_flow(master, > + kplane_st, kcrtc_st, master_dflow); > + else > + err =3D komeda_build_layer_data_flow(master, > + kplane_st, kcrtc_st, master_dflow); > + > + if (err) > + return err; > + } > + > + if (slave_dflow) { > + DRM_DEBUG_ATOMIC("SBS Slave-%s assigned: %s\n", > + slave->base.name, komeda_data_flow_msg(slave_dflow)); > + > + if (slave_dflow->en_split) > + err =3D komeda_build_layer_split_data_flow(slave, > + kplane_st, kcrtc_st, slave_dflow); > + else > + err =3D komeda_build_layer_data_flow(slave, > + kplane_st, kcrtc_st, slave_dflow); > + if (err) > + return err; > + } > + > + return 0; > +} > + > /* writeback data path: compiz -> scaler -> wb_layer -> memory */ > int komeda_build_wb_data_flow(struct komeda_layer *wb_layer, > struct drm_connector_state *conn_st, > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c b/drivers/= gpu/drm/arm/display/komeda/komeda_plane.c > index 98e915e325dd..2644f0727570 100644 > --- a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c > @@ -77,6 +77,7 @@ komeda_plane_atomic_check(struct drm_plane *plane, > struct komeda_plane_state *kplane_st =3D to_kplane_st(state); > struct komeda_layer *layer =3D kplane->layer; > struct drm_crtc_state *crtc_st; > + struct komeda_crtc *kcrtc; > struct komeda_crtc_state *kcrtc_st; > struct komeda_data_flow_cfg dflow; > int err; > @@ -94,13 +95,17 @@ komeda_plane_atomic_check(struct drm_plane *plane, > if (!crtc_st->active) > return 0; > =20 > + kcrtc =3D to_kcrtc(crtc_st->crtc); > kcrtc_st =3D to_kcrtc_st(crtc_st); > =20 > err =3D komeda_plane_init_data_flow(state, kcrtc_st, &dflow); > if (err) > return err; > =20 > - if (dflow.en_split) > + if (kcrtc->side_by_side) > + err =3D komeda_build_layer_sbs_data_flow(layer, > + kplane_st, kcrtc_st, &dflow); > + else if (dflow.en_split) > err =3D komeda_build_layer_split_data_flow(layer, > kplane_st, kcrtc_st, &dflow); > else >=20 --=20 Mihail