From patchwork Mon Jun 10 10:15:55 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: 10984605 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 191E91398 for ; Mon, 10 Jun 2019 10:16:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 094EF2876D for ; Mon, 10 Jun 2019 10:16:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1BF028774; Mon, 10 Jun 2019 10:16:01 +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 59BE72876D for ; Mon, 10 Jun 2019 10:16:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4007F890BA; Mon, 10 Jun 2019 10:16:00 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80042.outbound.protection.outlook.com [40.107.8.42]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9FB1B890BA for ; Mon, 10 Jun 2019 10:15:58 +0000 (UTC) Received: from VE1PR08MB5006.eurprd08.prod.outlook.com (10.255.159.31) by VE1PR08MB4975.eurprd08.prod.outlook.com (10.255.158.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1965.13; Mon, 10 Jun 2019 10:15:56 +0000 Received: from VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::206b:5cf6:97e:1358]) by VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::206b:5cf6:97e:1358%7]) with mapi id 15.20.1943.026; Mon, 10 Jun 2019 10:15:56 +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 v2 1/3] drm/komeda: Add component komeda_merger Thread-Topic: [PATCH v2 1/3] drm/komeda: Add component komeda_merger Thread-Index: AQHVH3V9bRM1IMPBGEKYG4wQK/dbSQ== Date: Mon, 10 Jun 2019 10:15:55 +0000 Message-ID: <20190610101528.25942-2-james.qian.wang@arm.com> References: <20190610101528.25942-1-james.qian.wang@arm.com> In-Reply-To: <20190610101528.25942-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: HK2PR02CA0140.apcprd02.prod.outlook.com (2603:1096:202:16::24) To VE1PR08MB5006.eurprd08.prod.outlook.com (2603:10a6:803:113::31) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: accdd3df-04e5-4076-7434-08d6ed8c9fe8 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:VE1PR08MB4975; x-ms-traffictypediagnostic: VE1PR08MB4975: nodisclaimer: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-forefront-prvs: 0064B3273C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(39860400002)(136003)(366004)(376002)(346002)(199004)(189003)(3846002)(8676002)(76176011)(81156014)(316002)(110136005)(103116003)(53936002)(186003)(26005)(81166006)(6436002)(71200400001)(55236004)(68736007)(2501003)(4326008)(66946007)(2906002)(478600001)(8936002)(99286004)(25786009)(50226002)(6512007)(66066001)(305945005)(6506007)(386003)(486006)(5660300002)(54906003)(2201001)(66476007)(66446008)(102836004)(66556008)(64756008)(6116002)(52116002)(11346002)(7736002)(476003)(446003)(6486002)(36756003)(2616005)(86362001)(14444005)(73956011)(256004)(1076003)(14454004)(71190400001); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4975; H:VE1PR08MB5006.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX: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: MBeGEtk+eVetEEOGtQlYAAn7Ah6y2mTa6HAQv68A3h9yJ/ET7gP2HYq4K7oL1g4uw+VUBEKIrtsWDDY/pVuCBJOayCj02wX9tZJosgbaDX4I6vBgUTmKIzr1ObSymOwJERTrnV09VsOupTE1pacT2cy1gwnLCK3UgVpE/wQCZktPvV4mLhgqQqYTZ94P5SOscSOKshSDhX4fydD4wGYwbVCzfFwvUIxY82cKP7tEhQ9ZnihUc+M+t6yn6wow6ooqY5fYSyGoQIQXbPKDyrY+Jg+drH3m5v0rRZV0ElDVUJdC8rxYuaiJOfP5R97uv/fZ6Gjsyy09TLwhEV0wFAv4vtwwokEfnkW4yC+2CcJyBEwFNzeDCbUfyUksjLZUphUHOSt5abKRgvPHyNwD5//m8Tn/iyjGLzatOhG5Tvfft7Q= MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: accdd3df-04e5-4076-7434-08d6ed8c9fe8 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Jun 2019 10:15:55.9416 (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: VE1PR08MB4975 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=e4K2DzVhijvz3ZKCn84qy16ZteGvFmsilyNuAONQ1Q4=; b=RiT6w5UEXijztxsaHxRzZgDV6zikdbW81Yylx5ljwzO70DXuukpO4kAL0b4gxERiDv8Ij6frm0SVnUpQs8n7g4qfArXECB6b3tFyZmBxz5R3FB/MkTem637QuKTdzBkiYhclrVdEWTaFhALuOHk/uoHbFSwDRWwPOw4APYgAG60= 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 Introduce a new component komeda_merger, because D71 HW supports to split a whole image to two half parts and does the scaling independently. Merger merges two separate results to one, and output it to compositor or wb_layer For this patch: - Add the definition of komeda_merger/merger_state - Report and initialize komeda_merger according to the D71 HW. v2: Rebase Signed-off-by: James Qian Wang (Arm Technology China) --- .../arm/display/komeda/d71/d71_component.c | 74 +++++++++++++++++++ .../drm/arm/display/komeda/komeda_pipeline.c | 3 + .../drm/arm/display/komeda/komeda_pipeline.h | 18 ++++- .../arm/display/komeda/komeda_private_obj.c | 49 ++++++++++++ 4 files changed, 143 insertions(+), 1 deletion(-) -- 2.17.1 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 c5185ce062a4..71f58bf1e880 100644 --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c @@ -767,6 +767,77 @@ static int d71_downscaling_clk_check(struct komeda_pipeline *pipe, 0 : -EINVAL; } +static void d71_merger_update(struct komeda_component *c, + struct komeda_component_state *state) +{ + struct komeda_merger_state *st = to_merger_st(state); + u32 __iomem *reg = c->reg; + u32 index; + + for_each_changed_input(state, index) + malidp_write32(reg, MG_INPUT_ID0 + index * 4, + to_d71_input_id(&state->inputs[index])); + + malidp_write32(reg, MG_SIZE, HV_SIZE(st->hsize_merged, + st->vsize_merged)); + malidp_write32(reg, BLK_CONTROL, BLK_CTRL_EN); +} + +static void d71_merger_dump(struct komeda_component *c, struct seq_file *sf) +{ + u32 v; + + dump_block_header(sf, c->reg); + + get_values_from_reg(c->reg, MG_INPUT_ID0, 1, &v); + seq_printf(sf, "MG_INPUT_ID0:\t\t0x%X\n", v); + + get_values_from_reg(c->reg, MG_INPUT_ID1, 1, &v); + seq_printf(sf, "MG_INPUT_ID1:\t\t0x%X\n", v); + + get_values_from_reg(c->reg, BLK_CONTROL, 1, &v); + seq_printf(sf, "MG_CONTROL:\t\t0x%X\n", v); + + get_values_from_reg(c->reg, MG_SIZE, 1, &v); + seq_printf(sf, "MG_SIZE:\t\t0x%X\n", v); +} + +static const struct komeda_component_funcs d71_merger_funcs = { + .update = d71_merger_update, + .disable = d71_component_disable, + .dump_register = d71_merger_dump, +}; + +static int d71_merger_init(struct d71_dev *d71, + struct block_header *blk, u32 __iomem *reg) +{ + struct komeda_component *c; + struct komeda_merger *merger; + u32 pipe_id, comp_id; + + get_resources_id(blk->block_info, &pipe_id, &comp_id); + + c = komeda_component_add(&d71->pipes[pipe_id]->base, sizeof(*merger), + comp_id, + BLOCK_INFO_INPUT_ID(blk->block_info), + &d71_merger_funcs, + MG_NUM_INPUTS_IDS, get_valid_inputs(blk), + MG_NUM_OUTPUTS_IDS, reg, + "CU%d_MERGER", pipe_id); + + if (IS_ERR(c)) { + DRM_ERROR("Failed to initialize merger.\n"); + return PTR_ERR(c); + } + + merger = to_merger(c); + + set_range(&merger->hsize_merged, 4, 4032); + set_range(&merger->vsize_merged, 4, 4096); + + return 0; +} + static void d71_improc_update(struct komeda_component *c, struct komeda_component_state *state) { @@ -992,7 +1063,10 @@ int d71_probe_block(struct d71_dev *d71, break; case D71_BLK_TYPE_CU_SPLITTER: + break; + case D71_BLK_TYPE_CU_MERGER: + err = d71_merger_init(d71, blk, reg); break; case D71_BLK_TYPE_DOU: diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.c b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.c index f4882c1b70d7..543ecc80703f 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.c @@ -91,6 +91,9 @@ komeda_pipeline_get_component_pos(struct komeda_pipeline *pipe, int id) case KOMEDA_COMPONENT_SCALER1: pos = to_cpos(pipe->scalers[id - KOMEDA_COMPONENT_SCALER0]); break; + case KOMEDA_COMPONENT_MERGER: + pos = to_cpos(pipe->merger); + break; case KOMEDA_COMPONENT_IPS0: case KOMEDA_COMPONENT_IPS1: temp = mdev->pipelines[id - KOMEDA_COMPONENT_IPS0]; diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h index 1a9b2cf8061a..20e6f7a78d12 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h @@ -276,6 +276,18 @@ struct komeda_compiz_state { struct komeda_compiz_input_cfg cins[KOMEDA_COMPONENT_N_INPUTS]; }; +struct komeda_merger { + struct komeda_component base; + struct malidp_range hsize_merged; + struct malidp_range vsize_merged; +}; + +struct komeda_merger_state { + struct komeda_component_state base; + u16 hsize_merged; + u16 vsize_merged; +}; + struct komeda_improc { struct komeda_component base; u32 supported_color_formats; /* DRM_RGB/YUV444/YUV420*/ @@ -357,6 +369,8 @@ struct komeda_pipeline { struct komeda_scaler *scalers[KOMEDA_PIPELINE_MAX_SCALERS]; /** @compiz: compositor */ struct komeda_compiz *compiz; + /** @merger: merger */ + struct komeda_merger *merger; /** @wb_layer: writeback layer */ struct komeda_layer *wb_layer; /** @improc: post image processor */ @@ -399,17 +413,19 @@ struct komeda_pipeline_state { #define to_layer(c) container_of(c, struct komeda_layer, base) #define to_compiz(c) container_of(c, struct komeda_compiz, base) #define to_scaler(c) container_of(c, struct komeda_scaler, base) +#define to_merger(c) container_of(c, struct komeda_merger, base) #define to_improc(c) container_of(c, struct komeda_improc, base) #define to_ctrlr(c) container_of(c, struct komeda_timing_ctrlr, base) #define to_layer_st(c) container_of(c, struct komeda_layer_state, base) #define to_compiz_st(c) container_of(c, struct komeda_compiz_state, base) #define to_scaler_st(c) container_of(c, struct komeda_scaler_state, base) +#define to_merger_st(c) container_of(c, struct komeda_merger_state, base) #define to_improc_st(c) container_of(c, struct komeda_improc_state, base) #define to_ctrlr_st(c) container_of(c, struct komeda_timing_ctrlr_state, base) #define priv_to_comp_st(o) container_of(o, struct komeda_component_state, obj) -#define priv_to_pipe_st(o) container_of(o, struct komeda_pipeline_state, obj) +#define priv_to_pipe_st(o) container_of(o, struct komeda_pipeline_state, obj) /* pipeline APIs */ struct komeda_pipeline * diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_private_obj.c b/drivers/gpu/drm/arm/display/komeda/komeda_private_obj.c index bac90ab8fdc9..0f4e1f601ce0 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_private_obj.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_private_obj.c @@ -146,6 +146,49 @@ static int komeda_compiz_obj_add(struct komeda_kms_dev *kms, return 0; } +static struct drm_private_state * +komeda_merger_atomic_duplicate_state(struct drm_private_obj *obj) +{ + struct komeda_merger_state *st; + + st = kmemdup(obj->state, sizeof(*st), GFP_KERNEL); + if (!st) + return NULL; + + komeda_component_state_reset(&st->base); + __drm_atomic_helper_private_obj_duplicate_state(obj, &st->base.obj); + + return &st->base.obj; +} + +static void komeda_merger_atomic_destroy_state(struct drm_private_obj *obj, + struct drm_private_state *state) +{ + kfree(to_merger_st(priv_to_comp_st(state))); +} + +static const struct drm_private_state_funcs komeda_merger_obj_funcs = { + .atomic_duplicate_state = komeda_merger_atomic_duplicate_state, + .atomic_destroy_state = komeda_merger_atomic_destroy_state, +}; + +static int komeda_merger_obj_add(struct komeda_kms_dev *kms, + struct komeda_merger *merger) +{ + struct komeda_merger_state *st; + + st = kzalloc(sizeof(*st), GFP_KERNEL); + if (!st) + return -ENOMEM; + + st->base.component = &merger->base; + drm_atomic_private_obj_init(&kms->base, + &merger->base.obj, &st->base.obj, + &komeda_merger_obj_funcs); + + return 0; +} + static struct drm_private_state * komeda_improc_atomic_duplicate_state(struct drm_private_obj *obj) { @@ -311,6 +354,12 @@ int komeda_kms_add_private_objs(struct komeda_kms_dev *kms, if (err) return err; + if (pipe->merger) { + err = komeda_merger_obj_add(kms, pipe->merger); + if (err) + return err; + } + err = komeda_improc_obj_add(kms, pipe->improc); if (err) return err;