From patchwork Thu Jul 4 06:30:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Qian Wang X-Patchwork-Id: 11031043 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 02AD4112C for ; Thu, 4 Jul 2019 06:31:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E641928A20 for ; Thu, 4 Jul 2019 06:31:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6F4128A44; Thu, 4 Jul 2019 06:31:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 17BA128A20 for ; Thu, 4 Jul 2019 06:31:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6854E6E264; Thu, 4 Jul 2019 06:31:04 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-ve1eur03on0613.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe09::613]) by gabe.freedesktop.org (Postfix) with ESMTPS id 999BF6E264 for ; Thu, 4 Jul 2019 06:31:02 +0000 (UTC) Received: from VE1PR08MB5006.eurprd08.prod.outlook.com (10.255.159.31) by VE1PR08MB5229.eurprd08.prod.outlook.com (10.255.27.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2032.20; Thu, 4 Jul 2019 06:30:59 +0000 Received: from VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::4062:a380:35ba:11d1]) by VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::4062:a380:35ba:11d1%3]) with mapi id 15.20.2032.019; Thu, 4 Jul 2019 06:30:59 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" Subject: [PATCH 2/6] drm/komeda: Add side by side plane_state split Thread-Topic: [PATCH 2/6] drm/komeda: Add side by side plane_state split Thread-Index: AQHVMjILVxnNgDqtCU+ikD0xeBTFCg== Date: Thu, 4 Jul 2019 06:30:59 +0000 Message-ID: <20190704063011.7431-3-james.qian.wang@arm.com> References: <20190704063011.7431-1-james.qian.wang@arm.com> In-Reply-To: <20190704063011.7431-1-james.qian.wang@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [113.29.88.7] x-clientproxiedby: HK0PR03CA0022.apcprd03.prod.outlook.com (2603:1096:203:2e::34) To VE1PR08MB5006.eurprd08.prod.outlook.com (2603:10a6:803:113::31) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 137dd5a0-e497-4ea8-1ac6-08d700492d74 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:VE1PR08MB5229; x-ms-traffictypediagnostic: VE1PR08MB5229: x-microsoft-antispam-prvs: nodisclaimer: True x-ms-oob-tlc-oobclassifiers: OLM:4502; x-forefront-prvs: 0088C92887 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(39860400002)(366004)(396003)(376002)(346002)(189003)(199004)(76176011)(6506007)(66066001)(110136005)(386003)(54906003)(103116003)(2906002)(316002)(186003)(86362001)(2201001)(52116002)(55236004)(99286004)(26005)(102836004)(6486002)(50226002)(25786009)(478600001)(71200400001)(71190400001)(6512007)(6436002)(4326008)(68736007)(53936002)(14454004)(2616005)(476003)(486006)(36756003)(30864003)(446003)(11346002)(81166006)(8676002)(256004)(81156014)(8936002)(305945005)(7736002)(66946007)(6116002)(73956011)(66476007)(66556008)(64756008)(66446008)(3846002)(2501003)(5660300002)(1076003); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB5229; H:VE1PR08MB5006.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 6VyUWhQwc3AuSaaMugNy7pdGBTxGxEs52amLcDxEhWzX+KBD6L4HkGFDxFFxKAz+waSe5dz7ZhfVC6xmmZyjVV7p3koRkPXF+hZtHM2OeFklKakRL66nO5xWizAgjDAJv4d9k6y/DfoVEcbwsFEpz5MVVVeURyBsGHmfs8Su3PSBSjBm4ZeN+YXYbnlTj9J19VU6Sv0M3yjn0MRdw0bxWrXL20DPG+UZo9kRr7QoJeAbzph1Z9hZUBKC5HksEf5f6FIlrssiaGJ9w1XtdJAwMsYbwYgc1ijAdn4pmtYFURrwTta3mGFCaV7EHURVxGdTIPSoeTL416nHUzsxaWK2s1wwA+5qBg+HKGVgggYipmtB4POzGU6YxE7/7MAKe9t33mszBtfVX/iHIMDp9kS1gpQ23b14+DfaKiFSdioQ6Jk= MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 137dd5a0-e497-4ea8-1ac6-08d700492d74 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Jul 2019 06:30:59.6467 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: james.qian.wang@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5229 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eVJmM650iZrJXShIkidsXZ6RIhGHrmzctzH2PLmRtrY=; b=E/xouiEKyNU9TBg/w0Z2jgEfu6BkkTA2zYse4J58QrnrAL7bV3yctzgv+pK/JIxYRuxTq66fJ5xBtSho4IaZtNYz5LZwRhaOkxh3MlJDAO1wGQUgkyEhRYja66xrQSEijyunSuf4oO+36lhDt5Hs/LRs/wNjLVKV9Y+UT4yY/YI= X-Mailman-Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd , Ayan Halder , "Oscar Zhang \(Arm Technology China\)" , "Tiannan Zhu \(Arm Technology China\)" , "Jonathan Chai \(Arm Technology China\)" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "Julien Yin \(Arm Technology China\)" , "Channing Chen \(Arm Technology China\)" , "james qian wang \(Arm Technology China\)" , "Yiqi Kang \(Arm Technology China\)" , "thomas Sun \(Arm Technology China\)" , "Lowry Li \(Arm Technology China\)" , Ben Davis Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 separately master pipeline for left part, slave for right. 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/full display frame, komeda will help to split the plane configuration to 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 slave pipeline. 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. 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. 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(-) -- 2.20.1 diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h index 6d3745bb8c1d..aa7c0fefa47e 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h @@ -511,6 +511,20 @@ komeda_component_pickup_output(struct komeda_component *c, u32 avail_comps) return komeda_pipeline_get_first_component(c->pipeline, avail_inputs); } +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; @@ -522,22 +536,27 @@ int komeda_build_layer_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_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); +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); 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 9123284c98a1..c08d59ae7090 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c @@ -1102,6 +1102,194 @@ int komeda_build_layer_split_data_flow(struct komeda_layer *left, return err; } +/* 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 configuration 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 = *m_dflow; + struct komeda_data_flow_cfg *slave = *s_dflow; + u32 disp_end = master->out_x + master->out_w; + u16 boundary; + + pipeline_composition_size(kcrtc_st, &boundary, NULL); + + if (disp_end <= boundary) { + /* the master viewport only located in master side, no need + * slave anymore + */ + *s_dflow = NULL; + } else if ((master->out_x < boundary) && (disp_end > boundary)) { + /* the master viewport across two pipelines, split it */ + bool flip_h = has_flip_h(master->rot); + bool r90 = drm_rotation_90_or_270(master->rot); + u32 src_x = master->in_x; + u32 src_y = master->in_y; + u32 src_w = master->in_w; + u32 src_h = 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 = boundary - master->out_x; + slave->out_w = disp_end - boundary; + slave->out_x = 0; + + if (r90) { + master->in_h = master->out_w; + slave->in_h = slave->out_w; + + if (flip_h) + master->in_y = src_y + src_h - master->in_h; + else + slave->in_y = src_y + src_h - slave->in_h; + } else { + master->in_w = master->out_w; + slave->in_w = slave->out_w; + + /* on flip_h, the left display content from the right-source */ + if (flip_h) + master->in_x = src_w + src_x - master->in_w; + else + slave->in_x = src_w + src_x - slave->in_w; + } + } else if (master->out_x >= boundary) { + /* disp_rect only locate in right part, move the dflow to slave */ + master->out_x -= boundary; + *s_dflow = master; + *m_dflow = 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 right part frame.\n"); + return -EINVAL; + } + + /* slave->disp_rect locate in the right part */ + slave->out_x -= boundary; + + return 0; +} + +/* On side by side mode, The full display frame will be split to two parts + * (Left/Right), and each part will be handled by a single pipeline separately, + * master pipeline for left part, slave for right. + * + * 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/full + * display frame, komeda will help to split the plane configuration to 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 slave + * pipeline. + * + * 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. + * + * 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 the 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 = to_kcrtc(kcrtc_st->base.crtc); + struct drm_plane *plane = kplane_st->base.plane; + struct komeda_data_flow_cfg temp, *master_dflow, *slave_dflow; + struct komeda_layer *master, *slave; + bool master_plane = layer->base.pipeline == 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 = layer; + slave = layer->sbs_slave; + master_dflow = dflow; + slave_dflow = &temp; + err = komeda_split_sbs_master_data_flow(kcrtc_st, + &master_dflow, &slave_dflow); + } else { + master = NULL; + slave = layer; + master_dflow = NULL; + slave_dflow = dflow; + err = 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 = komeda_build_layer_split_data_flow(master, + kplane_st, kcrtc_st, master_dflow); + else + err = 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 = komeda_build_layer_split_data_flow(slave, + kplane_st, kcrtc_st, slave_dflow); + else + err = 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 a5625f46120f..436dda1ca6dd 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c @@ -81,6 +81,7 @@ komeda_plane_atomic_check(struct drm_plane *plane, struct komeda_plane_state *kplane_st = to_kplane_st(state); struct komeda_layer *layer = 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; @@ -98,13 +99,17 @@ komeda_plane_atomic_check(struct drm_plane *plane, if (!crtc_st->active) return 0; + kcrtc = to_kcrtc(crtc_st->crtc); kcrtc_st = to_kcrtc_st(crtc_st); err = komeda_plane_init_data_flow(state, kcrtc_st, &dflow); if (err) return err; - if (dflow.en_split) + if (kcrtc->side_by_side) + err = komeda_build_layer_sbs_data_flow(layer, + kplane_st, kcrtc_st, &dflow); + else if (dflow.en_split) err = komeda_build_layer_split_data_flow(layer, kplane_st, kcrtc_st, &dflow); else