From patchwork Mon Dec 24 09:15:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Qian Wang X-Patchwork-Id: 10742119 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 72FFC6C5 for ; Mon, 24 Dec 2018 09:15:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 600F328F9E for ; Mon, 24 Dec 2018 09:15:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 541DF28FA6; Mon, 24 Dec 2018 09:15:48 +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 DBA2A28F9E for ; Mon, 24 Dec 2018 09:15:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 176F26E541; Mon, 24 Dec 2018 09:15:47 +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-eopbgr50049.outbound.protection.outlook.com [40.107.5.49]) by gabe.freedesktop.org (Postfix) with ESMTPS id 071966E541 for ; Mon, 24 Dec 2018 09:15:45 +0000 (UTC) Received: from AM3PR08MB0611.eurprd08.prod.outlook.com (10.163.188.149) by AM3PR08MB0183.eurprd08.prod.outlook.com (10.161.35.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1446.19; Mon, 24 Dec 2018 09:15:38 +0000 Received: from AM3PR08MB0611.eurprd08.prod.outlook.com ([fe80::3c73:534c:9c6e:352d]) by AM3PR08MB0611.eurprd08.prod.outlook.com ([fe80::3c73:534c:9c6e:352d%2]) with mapi id 15.20.1446.026; Mon, 24 Dec 2018 09:15:38 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau Subject: [PATCH 1/5] drm: Add drm_atomic_get_old/new_private_obj_state Thread-Topic: [PATCH 1/5] drm: Add drm_atomic_get_old/new_private_obj_state Thread-Index: AQHUm2k7dLlsBhK6bkSDIihp6zn3UA== Date: Mon, 24 Dec 2018 09:15:37 +0000 Message-ID: <20181224091450.2643-2-james.qian.wang@arm.com> References: <20181224091450.2643-1-james.qian.wang@arm.com> In-Reply-To: <20181224091450.2643-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: SY2PR01CA0039.ausprd01.prod.outlook.com (2603:10c6:1:15::27) To AM3PR08MB0611.eurprd08.prod.outlook.com (2a01:111:e400:c408::21) x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM3PR08MB0183; 6:Q2x8UgeqDMOe10YATUkhjXfNmmyzDD4xoi3EzN9HcV+R3ou4hGAMC31un6uUT0TtGPT17l0WXxn/6gNocUmt9DaCcP/Vj0YIgRSHxbYvJ3205CWSVohOZlcsCIqnMghIrG3WqsymSAq66jqyB7uKDdIws5buZfWIi+If/BTmnSUb0mkCOv/FANyTkFJ5VJf4bkAZPFpdkMkEIomrTbJY1U5adoD8fq+fIoT6LG356u0FNcCfg8F/ijUe5mQxvF8Xk/ANfRiZiWYZBcKeN7UeK7sDoDQR+J2quYbFHXfwVpjI/erzoUoyGaKn6tpTlEGWetBSPlq+n3otqaGBk+5STxXns+r3Ul9gc88eUyDK3WF35wnImRp5J9hONAp9EnVMr/KrRQaZ6Xri3dXkad3vxXm4vn8VHhvakcUubrAM5PBhKWUAz8cngHleGCU1VOzOUyjb+w+7mImU/yKMQI4gYw==; 5:q16hE6199FQI0hYP5lDPAunfRVquGyyWFxKu04n5BI7y/pOpbK+TAf7gPAqKH69pqWy46INXrNFZJQzo5dxFxLWBkvLSNM6yvR4K02WDQsW1aixCYXclML6mv5MWmZ9Zf/dh5MlSGvZsyIYqIXgN/RIrRZtzOVWq0tdAKWMW4DE=; 7:Np/fuQe65mQbXm7O7CDS/5VcRb/wCvaxwwTIxk1EHuFNYRTtAXcIjtFSAwLEktqcmJWSYV0ljicC3sfQ+ul3pJkOkdCJ+uU7prp8FenxXLNX4eMwDTAA2fDa8TFF5Kc4NCscNgwYTtqODHeVLk1ADA== x-ms-office365-filtering-correlation-id: 6a452ab9-f452-4897-baf6-08d669805e13 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM3PR08MB0183; x-ms-traffictypediagnostic: AM3PR08MB0183: nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(908002)(999002)(5005026)(6040522)(2401047)(8121501046)(10201501046)(93006095)(93001095)(3231475)(944501520)(52105112)(3002001)(6055026)(6041310)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:AM3PR08MB0183; BCL:0; PCL:0; RULEID:; SRVR:AM3PR08MB0183; x-forefront-prvs: 0896BFCE6C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(396003)(366004)(39850400004)(346002)(376002)(189003)(199004)(5660300001)(54906003)(7736002)(37006003)(256004)(14444005)(6862004)(4326008)(316002)(55236004)(386003)(86362001)(106356001)(14454004)(6506007)(186003)(99286004)(2906002)(105586002)(8936002)(97736004)(76176011)(36756003)(476003)(2616005)(71200400001)(478600001)(1076003)(6486002)(486006)(81156014)(71190400001)(3846002)(26005)(52116002)(68736007)(6116002)(6436002)(11346002)(8676002)(446003)(25786009)(305945005)(102836004)(103116003)(6636002)(81166006)(53936002)(6512007)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR08MB0183; H:AM3PR08MB0611.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: QquWOpGJM0iOt5ptzRnSevgGeVDzMEFV08e9CbXlGGHLXcgJawobSCjlogSKOIbTPN7JsVEw67K+A3VuZ5DTKfuCsSvWEHAvcPDDmosDdgSG5+fSu7ySFjYCqF24LWDcN0jAH7viikcKG9+FUN2rL8+CPFZ8fTOm94qjMSTOq2C/PdTYMSlUImWl0T4u84awae2gNb2rdJ2ijtFYJw3A2lhnZSLj8nuSTXrI3y2BsBQlThx6fQkMLKsKAqq2xP3YRNB0xMKjsqcZVxh1/+c2AZ+4IA1WM5JreOuji2jblgfbt8J9Gh71/zeiHTkviR0s spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6a452ab9-f452-4897-baf6-08d669805e13 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Dec 2018 09:15:37.8558 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR08MB0183 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 , "Tiannan Zhu \(Arm Technology China\)" , "airlied@linux.ie" , "Jonathan Chai \(Arm Technology China\)" , Alexandru-Cosmin Gheorghe , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "Julien Yin \(Arm Technology China\)" , "yamada.masahiro@socionext.com" , "james qian wang \(Arm Technology China\)" , "malidp@foss.arm.com" , "Yiqi Kang \(Arm Technology China\)" , "maxime.ripard@bootlin.com" , "thomas Sun \(Arm Technology China\)" , "Jin Gao \(Arm Technology China\)" , "Lowry Li \(Arm Technology China\)" , "sean@poorly.run" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This pair of functions return the old/new private object state for the given private_obj, or NULL if the private_obj is not part of the global atomic state. Reviewed-by: Alexandru Gheorghe Signed-off-by: James (Qian) Wang --- drivers/gpu/drm/drm_atomic.c | 45 +++++++++++++++++++++++++++++++++++- include/drm/drm_atomic.h | 6 +++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 9ac26437051b..6ff29f3862fc 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -764,6 +764,50 @@ drm_atomic_get_private_obj_state(struct drm_atomic_state *state, } EXPORT_SYMBOL(drm_atomic_get_private_obj_state); +/** + * drm_atomic_get_old_private_obj_state + * @state: global atomic state object + * @obj: private_obj to grab + * + * This function returns the old private object state for the given private_obj, + * or NULL if the private_obj is not part of the global atomic state. + */ +struct drm_private_state * +drm_atomic_get_old_private_obj_state(struct drm_atomic_state *state, + struct drm_private_obj *obj) +{ + int i; + + for (i = 0; i < state->num_private_objs; i++) + if (obj == state->private_objs[i].ptr) + return state->private_objs[i].old_state; + + return NULL; +} +EXPORT_SYMBOL(drm_atomic_get_old_private_obj_state); + +/** + * drm_atomic_get_new_private_obj_state + * @state: global atomic state object + * @obj: private_obj to grab + * + * This function returns the new private object state for the given private_obj, + * or NULL if the private_obj is not part of the global atomic state. + */ +struct drm_private_state * +drm_atomic_get_new_private_obj_state(struct drm_atomic_state *state, + struct drm_private_obj *obj) +{ + int i; + + for (i = 0; i < state->num_private_objs; i++) + if (obj == state->private_objs[i].ptr) + return state->private_objs[i].new_state; + + return NULL; +} +EXPORT_SYMBOL(drm_atomic_get_new_private_obj_state); + /** * drm_atomic_get_connector_state - get connector state * @state: global atomic state object @@ -1203,4 +1247,3 @@ int drm_atomic_debugfs_init(struct drm_minor *minor) minor->debugfs_root, minor); } #endif - diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h index f9b35834c45d..beb7b7fb6067 100644 --- a/include/drm/drm_atomic.h +++ b/include/drm/drm_atomic.h @@ -408,6 +408,12 @@ void drm_atomic_private_obj_fini(struct drm_private_obj *obj); struct drm_private_state * __must_check drm_atomic_get_private_obj_state(struct drm_atomic_state *state, struct drm_private_obj *obj); +struct drm_private_state * +drm_atomic_get_old_private_obj_state(struct drm_atomic_state *state, + struct drm_private_obj *obj); +struct drm_private_state * +drm_atomic_get_new_private_obj_state(struct drm_atomic_state *state, + struct drm_private_obj *obj); /** * drm_atomic_get_existing_crtc_state - get crtc state, if it exists From patchwork Mon Dec 24 09:15:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Qian Wang X-Patchwork-Id: 10742121 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 7598214DE for ; Mon, 24 Dec 2018 09:15:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6413C28F9E for ; Mon, 24 Dec 2018 09:15:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5743028FA6; Mon, 24 Dec 2018 09:15:55 +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 58F9E28F9E for ; Mon, 24 Dec 2018 09:15:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7969E6E545; Mon, 24 Dec 2018 09:15:53 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10082.outbound.protection.outlook.com [40.107.1.82]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2BEB46E545 for ; Mon, 24 Dec 2018 09:15:52 +0000 (UTC) Received: from AM3PR08MB0611.eurprd08.prod.outlook.com (10.163.188.149) by AM3PR08MB0183.eurprd08.prod.outlook.com (10.161.35.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1446.19; Mon, 24 Dec 2018 09:15:49 +0000 Received: from AM3PR08MB0611.eurprd08.prod.outlook.com ([fe80::3c73:534c:9c6e:352d]) by AM3PR08MB0611.eurprd08.prod.outlook.com ([fe80::3c73:534c:9c6e:352d%2]) with mapi id 15.20.1446.026; Mon, 24 Dec 2018 09:15:49 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau Subject: [PATCH 2/5] drm/komeda: Add komeda_pipeline/component_get_state_and_set_user Thread-Topic: [PATCH 2/5] drm/komeda: Add komeda_pipeline/component_get_state_and_set_user Thread-Index: AQHUm2lCeELNQHzQ80OmA4uEgAdeNA== Date: Mon, 24 Dec 2018 09:15:48 +0000 Message-ID: <20181224091450.2643-3-james.qian.wang@arm.com> References: <20181224091450.2643-1-james.qian.wang@arm.com> In-Reply-To: <20181224091450.2643-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: SY2PR01CA0039.ausprd01.prod.outlook.com (2603:10c6:1:15::27) To AM3PR08MB0611.eurprd08.prod.outlook.com (2a01:111:e400:c408::21) x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM3PR08MB0183; 6:B1PyX/cUXQ+u9SCdqU7dGWvewFzV2jYpVnX2cBgxT1nZqTvlhzPU9JiV/YAcBlO7I9Utmr6bP4mgHgymEijv/QX+6uxWyyZHIl1U488coys4neM/jNcJqkEnZ5fICuTzZbLNym6PiRww3XRmJt6xJn3KS4fQX8r2LZxogBGs7nmSAwUTSNRXsTXhksQXCF1SkEFlluAw+bvyN8SrNeDpcUOLmYbj9NBedT8H48XWx83l4vTNpr4gRIMtsLb4dZ28YrNDsQz3FEijP1U1HBx2fMnegSBdDYTn7a3jOFrtFEJKnHhGSqI6TtIjcUlg/B5dfCGuulwmToyHz5fK9e9XHuiTzr4XU3GWSyym3p4iA5zQCmYLKuxxuwNGQPzAVT4z8lMifdslTQc5BxsDWfysFd3hKbsAHIM/wbAqYKvvf2LtXahNEeSI/rqCMuoDJD7XAm8LQfPKAHZcLp2ysWCz8w==; 5:QqmynkiYPv8UGPKs+rY3hvUlWZ3wxR507hrs9F3nMEPHe+3ltDWOojtTZF98vXtYa6dWuH28mF80+Ysbux0iqqcY2AlTh/IZnaY0FPTmIdTgwHBIrZj3SHfNW6U2u+WjJvdhjM96F6oaUHaRLXIZM2uBzT73vWcz1n3eAF43Sd8=; 7:c9fz/T9ttil4BC9gRDTCOx5EEAlE6scZZZeH/eP+rbBPAkUMBb/JueeCXQUASfba4XTpay1x1l6KlGbqEybSkYXBkMm6JRQjUX0lrnMtIoFvCvBZPSlHbF0Kkl/n1VCfCXVLTKtF6rNfXCs3eytpeQ== x-ms-office365-filtering-correlation-id: 821e39d3-9aaa-4bd9-505e-08d6698064a6 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM3PR08MB0183; x-ms-traffictypediagnostic: AM3PR08MB0183: nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(908002)(999002)(5005026)(6040522)(2401047)(8121501046)(10201501046)(93006095)(93001095)(3231475)(944501520)(52105112)(3002001)(6055026)(6041310)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:AM3PR08MB0183; BCL:0; PCL:0; RULEID:; SRVR:AM3PR08MB0183; x-forefront-prvs: 0896BFCE6C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(396003)(366004)(39850400004)(346002)(376002)(189003)(199004)(5660300001)(575784001)(54906003)(7736002)(37006003)(256004)(14444005)(6862004)(4326008)(316002)(55236004)(386003)(86362001)(106356001)(14454004)(6506007)(186003)(99286004)(2906002)(105586002)(8936002)(97736004)(76176011)(36756003)(476003)(2616005)(71200400001)(478600001)(1076003)(6486002)(486006)(81156014)(71190400001)(3846002)(26005)(52116002)(68736007)(6116002)(6436002)(11346002)(8676002)(446003)(25786009)(305945005)(102836004)(103116003)(6636002)(81166006)(53936002)(6512007)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR08MB0183; H:AM3PR08MB0611.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: IfPBLmFiHOxaIJYyIN3fzuDsTgqiO0OWui1HGaXNMk+1BFJ4VqutYOclekLo/PdtobUx5EBDj8euSNd+HKDM3hG5F/W13uAsfzF4wrGz4mPekTftyjYuK9jvQO4x4ippS9TbHIKL4HcN+//Rbqfc8w7KWnwPuJwXdztgYVCxqjdBNYM1jiglA+4FEGPk4YTMKqP7Tc80fABGsoFhB3/SzcIOIiJqsLSm3tAE2rfekuBYmmY7GCE9zJG1agImILMTBbpUL25GJU/ZXC1YRGy/I/33umwmuuMrczid8b64FI4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 821e39d3-9aaa-4bd9-505e-08d6698064a6 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Dec 2018 09:15:48.8808 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR08MB0183 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 , "Tiannan Zhu \(Arm Technology China\)" , "airlied@linux.ie" , "Jonathan Chai \(Arm Technology China\)" , Alexandru-Cosmin Gheorghe , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "Julien Yin \(Arm Technology China\)" , "yamada.masahiro@socionext.com" , "james qian wang \(Arm Technology China\)" , "malidp@foss.arm.com" , "Yiqi Kang \(Arm Technology China\)" , "maxime.ripard@bootlin.com" , "thomas Sun \(Arm Technology China\)" , "Jin Gao \(Arm Technology China\)" , "Lowry Li \(Arm Technology China\)" , "sean@poorly.run" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP get_state_and_set_user packed get_state and set_user into one function, which get pipeline/component state for a specific pipeline/component, if success set the user to it. Signed-off-by: James (Qian) Wang --- drivers/gpu/drm/arm/display/komeda/Makefile | 1 + .../drm/arm/display/komeda/komeda_pipeline.c | 2 + .../drm/arm/display/komeda/komeda_pipeline.h | 7 + .../display/komeda/komeda_pipeline_state.c | 148 ++++++++++++++++++ 4 files changed, 158 insertions(+) create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c diff --git a/drivers/gpu/drm/arm/display/komeda/Makefile b/drivers/gpu/drm/arm/display/komeda/Makefile index d593125236ae..62bd1bff66a3 100644 --- a/drivers/gpu/drm/arm/display/komeda/Makefile +++ b/drivers/gpu/drm/arm/display/komeda/Makefile @@ -9,6 +9,7 @@ komeda-y := \ komeda_dev.o \ komeda_format_caps.o \ komeda_pipeline.o \ + komeda_pipeline_state.o \ komeda_framebuffer.o \ komeda_kms.o \ komeda_crtc.o \ diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.c b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.c index 611e8c53e248..1c9205d0e61b 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.c @@ -34,6 +34,8 @@ komeda_pipeline_add(struct komeda_dev *mdev, size_t size, pipe->id = mdev->n_pipelines; pipe->funcs = funcs; + drm_modeset_lock_init(&pipe->mutex); + mdev->pipelines[mdev->n_pipelines] = pipe; mdev->n_pipelines++; diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h index 4f98fdb21557..201fcf074fa1 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h @@ -295,6 +295,13 @@ struct komeda_pipeline_funcs { struct komeda_pipeline { /** @obj: link pipeline as private obj of drm_atomic_state */ struct drm_private_obj obj; + + /** + * @mutex: + * + * protects pipeline_state, since pipeline can be shared between crtcs + */ + struct drm_modeset_lock mutex; /** @mdev: the parent komeda_dev */ struct komeda_dev *mdev; /** @pxlclk: pixel clock */ diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c new file mode 100644 index 000000000000..7ce006b9e5f7 --- /dev/null +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c @@ -0,0 +1,148 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * (C) COPYRIGHT 2018 ARM Limited. All rights reserved. + * Author: James.Qian.Wang + * + */ +#include +#include "komeda_dev.h" +#include "komeda_kms.h" +#include "komeda_pipeline.h" + +static inline bool is_switching_user(void *old, void *new) +{ + if (!old || !new) + return false; + + return old != new; +} + +struct komeda_pipeline_state * +komeda_pipeline_get_state(struct komeda_pipeline *pipe, + struct drm_atomic_state *state) +{ + struct drm_private_state *priv_st; + int err; + + WARN_ON(!state->acquire_ctx); + + priv_st = drm_atomic_get_new_private_obj_state(state, &pipe->obj); + if (priv_st) + return priv_to_pipe_st(priv_st); + + err = drm_modeset_lock(&pipe->mutex, state->acquire_ctx); + if (err) + return ERR_PTR(err); + + priv_st = drm_atomic_get_private_obj_state(state, &pipe->obj); + if (IS_ERR(priv_st)) + return ERR_CAST(priv_st); + + return priv_to_pipe_st(priv_st); +} + +/* Assign a pipeline crtc */ +struct komeda_pipeline_state * +komeda_pipeline_get_state_and_set_crtc(struct komeda_pipeline *pipe, + struct drm_atomic_state *state, + struct drm_crtc *crtc) +{ + struct komeda_pipeline_state *st; + + st = komeda_pipeline_get_state(pipe, state); + if (IS_ERR(st)) + return st; + + if (is_switching_user(crtc, st->crtc)) { + DRM_DEBUG_ATOMIC("CRTC%d required pipeline%d is busy.\n", + drm_crtc_index(crtc), pipe->id); + return ERR_PTR(-EBUSY); + } + + /* pipeline only can be disabled when the it is free or unused */ + if (!crtc && st->active_comps) { + DRM_DEBUG_ATOMIC("Disabling a busy pipeline:%d.\n", pipe->id); + return ERR_PTR(-EBUSY); + } + + st->crtc = crtc; + + if (crtc) { + struct komeda_crtc_state *kcrtc_st; + + kcrtc_st = to_kcrtc_st(drm_atomic_get_new_crtc_state(state, + crtc)); + + kcrtc_st->active_pipes |= BIT(pipe->id); + kcrtc_st->affected_pipes |= BIT(pipe->id); + } + return st; +} + +static struct komeda_component_state * +komeda_component_get_state(struct komeda_component *c, + struct drm_atomic_state *state) +{ + WARN_ON(!drm_modeset_is_locked(&c->pipeline->mutex)); + + return priv_to_comp_st(drm_atomic_get_private_obj_state(state, + &c->obj)); +} + +/** + * komeda_component_get_state_and_set_user() + * + * @c: component to get state and set user + * @state: global atomic state + * @user: direct user, the binding user + * @crtc: the CRTC user, the big boss :) + * + * This function accepts two users: + * - The direct user: can be plane/crtc/wb_connector depends on component + * - The big boss (CRTC) + * CRTC is the big boss (the final user), because all component resources + * eventually will be assigned to CRTC, like the layer will be binding to + * kms_plane, but kms plane will be binding to a CRTC eventually. + * + * The big boss (CRTC) is for pipeline assignment, since &komeda_component isn't + * independent and can be assigned to CRTC freely, but belongs to a specific + * pipeline, only pipeline can be shared between crtc, and pipeline as a whole + * (include all the internal components) assigned to a specific CRTC. + * + * So when set a user to komeda_component, need first to check the status of + * component->pipeline to see if the pipeline is available on this specific + * CRTC. if the pipeline is busy (assigned to another CRTC), even the required + * component is free, the component still cannot be assigned to the direct user. + */ +static struct komeda_component_state * +komeda_component_get_state_and_set_user(struct komeda_component *c, + struct drm_atomic_state *state, + void *user, + struct drm_crtc *crtc) +{ + struct komeda_pipeline_state *pipe_st; + struct komeda_component_state *st; + + /* First check if the pipeline is available */ + pipe_st = komeda_pipeline_get_state_and_set_crtc(c->pipeline, + state, crtc); + if (IS_ERR(pipe_st)) + return ERR_CAST(pipe_st); + + st = komeda_component_get_state(c, state); + if (IS_ERR(st)) + return st; + + /* check if the component has been occupied */ + if (is_switching_user(user, st->binding_user)) { + DRM_DEBUG_ATOMIC("required %s is busy.\n", c->name); + return ERR_PTR(-EBUSY); + } + + st->binding_user = user; + /* mark the component as active if user is valid */ + if (st->binding_user) + pipe_st->active_comps |= BIT(c->id); + + return st; +} From patchwork Mon Dec 24 09:16:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Qian Wang X-Patchwork-Id: 10742123 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 746A06C5 for ; Mon, 24 Dec 2018 09:16:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 639D728FA6 for ; Mon, 24 Dec 2018 09:16:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 57E5D28FAA; Mon, 24 Dec 2018 09:16:13 +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 D418828FA6 for ; Mon, 24 Dec 2018 09:16:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D83146E546; Mon, 24 Dec 2018 09:16:11 +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-eopbgr50049.outbound.protection.outlook.com [40.107.5.49]) by gabe.freedesktop.org (Postfix) with ESMTPS id 476696E546 for ; Mon, 24 Dec 2018 09:16:09 +0000 (UTC) Received: from AM3PR08MB0611.eurprd08.prod.outlook.com (10.163.188.149) by AM3PR08MB0183.eurprd08.prod.outlook.com (10.161.35.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1446.19; Mon, 24 Dec 2018 09:16:00 +0000 Received: from AM3PR08MB0611.eurprd08.prod.outlook.com ([fe80::3c73:534c:9c6e:352d]) by AM3PR08MB0611.eurprd08.prod.outlook.com ([fe80::3c73:534c:9c6e:352d%2]) with mapi id 15.20.1446.026; Mon, 24 Dec 2018 09:16:00 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau Subject: [PATCH 3/5] drm/arm/komeda: Initialize komeda component as drm private object Thread-Topic: [PATCH 3/5] drm/arm/komeda: Initialize komeda component as drm private object Thread-Index: AQHUm2lJ5spMUqHclESHdnLDQsI9ag== Date: Mon, 24 Dec 2018 09:16:00 +0000 Message-ID: <20181224091450.2643-4-james.qian.wang@arm.com> References: <20181224091450.2643-1-james.qian.wang@arm.com> In-Reply-To: <20181224091450.2643-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: SY2PR01CA0039.ausprd01.prod.outlook.com (2603:10c6:1:15::27) To AM3PR08MB0611.eurprd08.prod.outlook.com (2a01:111:e400:c408::21) x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM3PR08MB0183; 6:T7Vt/sBXn410jFUlbKLR1n/Cpm7S0OvazPocEUDqBc7iAuHVhgdoqqLWr507pjP4fdUa/t8mL4sonbZqc+BnkEO6WPOB8GZudIJSEb00blfTM/ac2VsaTk49o4E830Bb0eqaWoiUQJZxgChHvtMYwr0hYmRwuSHB/lqSLEN84Mjrl4GVUF/15OG2A5UsbquDendajWygRez8aex20ip+znkxckVdAk1o3Zwyi+fWiFBZHAxI4OoxBlSUxZ3Xb1gI9uT58+cmpOl8V/m3MYJ0j6/67Nq4KRkqS971+mGb3q3nDqAB01HYx5W9+oXZOufseAGSLTXUlcKHozL7RE5/veT66awN255lBvgs7EhlBWuFdZpE6t0zl/e0D2lCacI73UJgsDA3YjGBWKOK7whecRmPmC1IXrIWgR2/BkCcVII13bq3mn7bSzhkj4Wa4shtUTh4fpVXQjM2uL0q1NI0yg==; 5:D13wmqr53Q9iEbsqa9YBAPW9MFReJ9vaRq+0gVo46X8VeytsY0D7AmuD68dsbrABiZVjkYGHxXdUmh8Lbfzs1lfrpH+RbKs7oLFNyr2+toNeXUis3UpWkX549vuyVlTUmy5kqefitATlwAD8ypoUxeoHpX0WecjPnki6nI7nEU8=; 7:k383mFlvSJxXg4TvsKLCGpG1ppql2JLK+LppAT+dBSh1/d0Iqn8RhSHmUXCUUegVkpf0+jp38jhJpKEuZje82JVz6zCksNJpoQnap2gBbCRIhdtsANr28LNaHNCgPXD8200M9xrwP93R7Hy90DySeA== x-ms-office365-filtering-correlation-id: bf3b7917-f5f0-4a70-3b24-08d669806b5f x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM3PR08MB0183; x-ms-traffictypediagnostic: AM3PR08MB0183: nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(908002)(999002)(5005026)(6040522)(2401047)(8121501046)(10201501046)(93006095)(93001095)(3231475)(944501520)(52105112)(3002001)(6055026)(6041310)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:AM3PR08MB0183; BCL:0; PCL:0; RULEID:; SRVR:AM3PR08MB0183; x-forefront-prvs: 0896BFCE6C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(396003)(366004)(39850400004)(346002)(376002)(189003)(199004)(5660300001)(575784001)(54906003)(7736002)(37006003)(256004)(6862004)(4326008)(316002)(55236004)(386003)(86362001)(106356001)(14454004)(6506007)(186003)(99286004)(2906002)(105586002)(8936002)(97736004)(76176011)(36756003)(476003)(2616005)(71200400001)(478600001)(1076003)(6486002)(486006)(81156014)(71190400001)(3846002)(26005)(52116002)(68736007)(6116002)(6436002)(11346002)(8676002)(446003)(25786009)(305945005)(102836004)(103116003)(6636002)(81166006)(53936002)(6512007)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR08MB0183; H:AM3PR08MB0611.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: 0/cRy/sJO5en+R/+TC0EMUDQwLVNBnfTYPtDxWE1/eyJmnVebICehi3cyxlbPe+Xo1wwWZsZLFIveyTL81JoWTys5RvoItHpdkTHoyQYn9dt70qOsntFItFPXwlIL2ZE6p7qV6g0ufVeck4bgYsUI2UXAyHOAnWN7+8cywlkAu6EWCgQWbM3u0yQXwD5kfSY86Nt+lJ6lpKWm5On7Ma7G+Zzl1KVeeVEpiSnDy+C5WInQAhaRwFZg50itN/097FUP5s4/whRMDETYOJLfVsy3GIojBCc4qib/lPZbXQ/fPG5vXfSX1TWaOjAMYslt7A4 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: bf3b7917-f5f0-4a70-3b24-08d669806b5f X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Dec 2018 09:16:00.1630 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR08MB0183 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 , "Tiannan Zhu \(Arm Technology China\)" , "airlied@linux.ie" , "Jonathan Chai \(Arm Technology China\)" , Alexandru-Cosmin Gheorghe , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "Julien Yin \(Arm Technology China\)" , "yamada.masahiro@socionext.com" , "james qian wang \(Arm Technology China\)" , "malidp@foss.arm.com" , "Yiqi Kang \(Arm Technology China\)" , "maxime.ripard@bootlin.com" , "thomas Sun \(Arm Technology China\)" , "Jin Gao \(Arm Technology China\)" , "Lowry Li \(Arm Technology China\)" , "sean@poorly.run" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Initialize koemda_layer, komeda_compiz, komeda_improc and komeda_timing_ctrlr as drm private object, then track komeda private component state by drm_atomic_state. Signed-off-by: James (Qian) Wang --- .../arm/display/komeda/komeda_private_obj.c | 200 +++++++++++++++++- 1 file changed, 198 insertions(+), 2 deletions(-) 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 9edfd6ab0c12..c5b42fc4f904 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_private_obj.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_private_obj.c @@ -7,6 +7,184 @@ #include "komeda_dev.h" #include "komeda_kms.h" +static void +komeda_component_state_reset(struct komeda_component_state *st) +{ + st->binding_user = NULL; + st->affected_inputs = st->active_inputs; + st->active_inputs = 0; + st->changed_active_inputs = 0; +} + +static struct drm_private_state * +komeda_layer_atomic_duplicate_state(struct drm_private_obj *obj) +{ + struct komeda_layer_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_layer_atomic_destroy_state(struct drm_private_obj *obj, + struct drm_private_state *state) +{ + struct komeda_layer_state *st = to_layer_st(priv_to_comp_st(state)); + + kfree(st); +} + +static const struct drm_private_state_funcs komeda_layer_obj_funcs = { + .atomic_duplicate_state = komeda_layer_atomic_duplicate_state, + .atomic_destroy_state = komeda_layer_atomic_destroy_state, +}; + +static int komeda_layer_obj_add(struct komeda_layer *layer) +{ + struct komeda_layer_state *st; + + st = kzalloc(sizeof(*st), GFP_KERNEL); + if (!st) + return -ENOMEM; + + st->base.component = &layer->base; + drm_atomic_private_obj_init(&layer->base.obj, &st->base.obj, + &komeda_layer_obj_funcs); + return 0; +} + +static struct drm_private_state * +komeda_compiz_atomic_duplicate_state(struct drm_private_obj *obj) +{ + struct komeda_compiz_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_compiz_atomic_destroy_state(struct drm_private_obj *obj, + struct drm_private_state *state) +{ + kfree(to_compiz_st(priv_to_comp_st(state))); +} + +static const struct drm_private_state_funcs komeda_compiz_obj_funcs = { + .atomic_duplicate_state = komeda_compiz_atomic_duplicate_state, + .atomic_destroy_state = komeda_compiz_atomic_destroy_state, +}; + +static int komeda_compiz_obj_add(struct komeda_compiz *compiz) +{ + struct komeda_compiz_state *st; + + st = kzalloc(sizeof(*st), GFP_KERNEL); + if (!st) + return -ENOMEM; + + st->base.component = &compiz->base; + drm_atomic_private_obj_init(&compiz->base.obj, &st->base.obj, + &komeda_compiz_obj_funcs); + + return 0; +} + +static struct drm_private_state * +komeda_improc_atomic_duplicate_state(struct drm_private_obj *obj) +{ + struct komeda_improc_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_improc_atomic_destroy_state(struct drm_private_obj *obj, + struct drm_private_state *state) +{ + kfree(to_improc_st(priv_to_comp_st(state))); +} + +static const struct drm_private_state_funcs komeda_improc_obj_funcs = { + .atomic_duplicate_state = komeda_improc_atomic_duplicate_state, + .atomic_destroy_state = komeda_improc_atomic_destroy_state, +}; + +static int komeda_improc_obj_add(struct komeda_improc *improc) +{ + struct komeda_improc_state *st; + + st = kzalloc(sizeof(*st), GFP_KERNEL); + if (!st) + return -ENOMEM; + + st->base.component = &improc->base; + drm_atomic_private_obj_init(&improc->base.obj, &st->base.obj, + &komeda_improc_obj_funcs); + + return 0; +} + +static struct drm_private_state * +komeda_timing_ctrlr_atomic_duplicate_state(struct drm_private_obj *obj) +{ + struct komeda_timing_ctrlr_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_timing_ctrlr_atomic_destroy_state(struct drm_private_obj *obj, + struct drm_private_state *state) +{ + kfree(to_ctrlr_st(priv_to_comp_st(state))); +} + +static const struct drm_private_state_funcs komeda_timing_ctrlr_obj_funcs = { + .atomic_duplicate_state = komeda_timing_ctrlr_atomic_duplicate_state, + .atomic_destroy_state = komeda_timing_ctrlr_atomic_destroy_state, +}; + +static int komeda_timing_ctrlr_obj_add(struct komeda_timing_ctrlr *ctrlr) +{ + struct komeda_compiz_state *st; + + st = kzalloc(sizeof(*st), GFP_KERNEL); + if (!st) + return -ENOMEM; + + st->base.component = &ctrlr->base; + drm_atomic_private_obj_init(&ctrlr->base.obj, &st->base.obj, + &komeda_timing_ctrlr_obj_funcs); + + return 0; +} + static struct drm_private_state * komeda_pipeline_atomic_duplicate_state(struct drm_private_obj *obj) { @@ -55,7 +233,7 @@ int komeda_kms_add_private_objs(struct komeda_kms_dev *kms, struct komeda_dev *mdev) { struct komeda_pipeline *pipe; - int i, err; + int i, j, err; for (i = 0; i < mdev->n_pipelines; i++) { pipe = mdev->pipelines[i]; @@ -64,7 +242,23 @@ int komeda_kms_add_private_objs(struct komeda_kms_dev *kms, if (err) return err; - /* Add component */ + for (j = 0; j < pipe->n_layers; j++) { + err = komeda_layer_obj_add(pipe->layers[j]); + if (err) + return err; + } + + err = komeda_compiz_obj_add(pipe->compiz); + if (err) + return err; + + err = komeda_improc_obj_add(pipe->improc); + if (err) + return err; + + err = komeda_timing_ctrlr_obj_add(pipe->ctrlr); + if (err) + return err; } return 0; @@ -78,11 +272,13 @@ void komeda_kms_cleanup_private_objs(struct komeda_dev *mdev) for (i = 0; i < mdev->n_pipelines; i++) { pipe = mdev->pipelines[i]; + dp_for_each_set_bit(id, pipe->avail_comps) { c = komeda_pipeline_get_component(pipe, id); drm_atomic_private_obj_fini(&c->obj); } + drm_atomic_private_obj_fini(&pipe->obj); } } From patchwork Mon Dec 24 09:16:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Qian Wang X-Patchwork-Id: 10742125 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 2909814DE for ; Mon, 24 Dec 2018 09:16:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1684028FA5 for ; Mon, 24 Dec 2018 09:16:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A97828FA9; Mon, 24 Dec 2018 09:16:18 +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 5003528FA5 for ; Mon, 24 Dec 2018 09:16:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7EB0A6E547; Mon, 24 Dec 2018 09:16:16 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10052.outbound.protection.outlook.com [40.107.1.52]) by gabe.freedesktop.org (Postfix) with ESMTPS id 247C96E54C for ; Mon, 24 Dec 2018 09:16:15 +0000 (UTC) Received: from AM3PR08MB0611.eurprd08.prod.outlook.com (10.163.188.149) by AM3PR08MB0183.eurprd08.prod.outlook.com (10.161.35.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1446.19; Mon, 24 Dec 2018 09:16:11 +0000 Received: from AM3PR08MB0611.eurprd08.prod.outlook.com ([fe80::3c73:534c:9c6e:352d]) by AM3PR08MB0611.eurprd08.prod.outlook.com ([fe80::3c73:534c:9c6e:352d%2]) with mapi id 15.20.1446.026; Mon, 24 Dec 2018 09:16:11 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau Subject: [PATCH 4/5] drm/komeda: Add komeda_build_layer_data_flow Thread-Topic: [PATCH 4/5] drm/komeda: Add komeda_build_layer_data_flow Thread-Index: AQHUm2lPP+YTnvFnVUO+YotBgRrcsA== Date: Mon, 24 Dec 2018 09:16:11 +0000 Message-ID: <20181224091450.2643-5-james.qian.wang@arm.com> References: <20181224091450.2643-1-james.qian.wang@arm.com> In-Reply-To: <20181224091450.2643-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: SY2PR01CA0039.ausprd01.prod.outlook.com (2603:10c6:1:15::27) To AM3PR08MB0611.eurprd08.prod.outlook.com (2a01:111:e400:c408::21) x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM3PR08MB0183; 6:96oDFwHzuhY0SiKghCiz+BWvGI0usVfS7hMlH1YmLw9dJoqvCkdkBUifbsvVJf9QALYyBNEAQuijbQ8USRpxygJbBxmNDWMVtuRdkLs2QeveqGRFoVddykwu0aEttNtzdVK+B9X1/6CaGZLQKxzro2qtFGth6LL5UG6YSjtl8KSZyRLrF41AU4F2puv6Sg9FmDs99kUPqeR9h3xXr6PeSdED7u9ENzTKB7DyNHZXUclAV8v7AqkwXFEj1m2H/dF+/BzQ1Jvj/4vOIJlUvHaVFqpRtBGdIZ0TTPq/AjjUMsrAnQwgZ1SZsFB+9mN/2LmsxH0YQGuf3lpVCcnXglbD12FcK76MQ5wajUTELsD+vIYPzNHZld2PJ9XwG8mNmQ1DR/aQcK9Ow+tc81eVa+ZGwl0NULyhE9F9vr+bWJn0Iy4gcx+f1Ff2mvlXg0vZlywGSYsTP2I0W2CJGm3isVHQZQ==; 5:du+UxJJsEGbZ2Hss6lRWmcnJ3NTaoDcu9i8vA9QPD3jVYjUn9FlvN5TV1RQQ8hmkJ2Ya7/4SSAibfZsApxBArmcdcYhAm2Mifg4CYfXNSaW/UPAwYpyu2HArbqndViTEK/rY4rh2piRqQkbvP/ZCWtANVbNqWpL0KF5rYcO5/EE=; 7:0s4WEn+srrcWMBW1Zzx+2hxHEtuXqh6HdXGxrmGms5aDMu3Y4gqYlOmXfo+go3v0tLtrmghXvAO/iYp7lEaw6vytfzlNwIMV9v4NeSxR0O8WewmGH2fe3OwhUgF1QT3qgrxtDL1J4Z3UjgRXxIixiw== x-ms-office365-filtering-correlation-id: 2af3305e-5671-495b-52c2-08d6698071ec x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM3PR08MB0183; x-ms-traffictypediagnostic: AM3PR08MB0183: nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(908002)(999002)(5005026)(6040522)(2401047)(8121501046)(10201501046)(93006095)(93001095)(3231475)(944501520)(52105112)(3002001)(6055026)(6041310)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:AM3PR08MB0183; BCL:0; PCL:0; RULEID:; SRVR:AM3PR08MB0183; x-forefront-prvs: 0896BFCE6C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(396003)(366004)(39850400004)(346002)(376002)(189003)(199004)(5660300001)(54906003)(7736002)(37006003)(256004)(14444005)(6862004)(4326008)(316002)(55236004)(386003)(86362001)(106356001)(14454004)(6506007)(186003)(99286004)(2906002)(105586002)(8936002)(97736004)(76176011)(36756003)(476003)(2616005)(71200400001)(478600001)(1076003)(6486002)(486006)(81156014)(71190400001)(3846002)(26005)(52116002)(68736007)(6116002)(6436002)(11346002)(8676002)(446003)(25786009)(305945005)(102836004)(103116003)(6636002)(81166006)(53936002)(6512007)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR08MB0183; H:AM3PR08MB0611.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: NjiliOni3pg4RMECRdUf5Ct+WL1jW2MQIU7UEXoQOrntFKwTNbGj39hFZHdR7A7fcYsbT6DwncVSoN2FdsLPoonrMckPmHjKBqxLwYt2b3kkiVRV+HBw2mZj25aTV2jnAAeyNy5aT+5KdqN1yMSP5Tcx2hlR+mdVSUYs8m6RGQ/uhyeLQJlG35lk84j6mR2KgUI1glSVjt1bfqzMA8qxTj0L0cruYuhryXJzGfbDC0p71oejLHFw7ZHzw1D3bLqdEZHA8SQ3dm6/1B4G+rHfMrJN9UhyWo15DJiW//tQweGGpR6jwqQFghEJAEZsdRES spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2af3305e-5671-495b-52c2-08d6698071ec X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Dec 2018 09:16:11.2871 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR08MB0183 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 , "Tiannan Zhu \(Arm Technology China\)" , "airlied@linux.ie" , "Jonathan Chai \(Arm Technology China\)" , Alexandru-Cosmin Gheorghe , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "Julien Yin \(Arm Technology China\)" , "yamada.masahiro@socionext.com" , "james qian wang \(Arm Technology China\)" , "malidp@foss.arm.com" , "Yiqi Kang \(Arm Technology China\)" , "maxime.ripard@bootlin.com" , "thomas Sun \(Arm Technology China\)" , "Jin Gao \(Arm Technology China\)" , "Lowry Li \(Arm Technology China\)" , "sean@poorly.run" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP build_layer_data_flow builds a input pipeline according to plane_state. and in this initial stage only added this simplest pipeline usage: Layer -> compiz The scaler and layer_split will be added in the future. Signed-off-by: James (Qian) Wang --- .../drm/arm/display/komeda/komeda_pipeline.h | 24 ++ .../display/komeda/komeda_pipeline_state.c | 260 ++++++++++++++++++ 2 files changed, 284 insertions(+) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h index 201fcf074fa1..c78edfc6ed5b 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h @@ -280,6 +280,21 @@ struct komeda_timing_ctrlr_state { struct komeda_component_state base; }; +/* Why define A separated structure but not use plane_state directly ? + * 1. Komeda supports layer_split which means a plane_state can be split and + * handled by two layers, one layer only handle half of plane image. + * 2. Fix up the user properties according to HW's capabilities, like user + * set rotation to R180, but HW only supports REFLECT_X+Y. the rot here is + * after drm_rotation_simplify() + */ +struct komeda_layer_viewport { + u16 in_x, in_y, in_w, in_h; + u32 out_x, out_y, out_w, out_h; + u32 rot; + int blending_zorder; + u8 pixel_blend_mode, layer_alpha; +}; + /** struct komeda_pipeline_funcs */ struct komeda_pipeline_funcs { /* dump_register: Optional, dump registers to seq_file */ @@ -391,4 +406,13 @@ komeda_component_add(struct komeda_pipeline *pipe, void komeda_component_destroy(struct komeda_dev *mdev, struct komeda_component *c); +struct komeda_plane_state; +struct komeda_crtc_state; + +int komeda_build_layer_data_flow(struct komeda_layer *layer, + struct komeda_component_output *dflow, + struct komeda_plane_state *kplane_st, + struct komeda_crtc_state *kcrtc_st, + struct komeda_layer_viewport *vp); + #endif /* _KOMEDA_PIPELINE_H_*/ 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 7ce006b9e5f7..b98163211cfd 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c @@ -8,6 +8,7 @@ #include "komeda_dev.h" #include "komeda_kms.h" #include "komeda_pipeline.h" +#include "komeda_framebuffer.h" static inline bool is_switching_user(void *old, void *new) { @@ -89,6 +90,18 @@ komeda_component_get_state(struct komeda_component *c, &c->obj)); } +static struct komeda_component_state * +komeda_component_get_old_state(struct komeda_component *c, + struct drm_atomic_state *state) +{ + struct drm_private_state *priv_st; + + priv_st = drm_atomic_get_old_private_obj_state(state, &c->obj); + if (priv_st) + return priv_to_comp_st(priv_st); + return NULL; +} + /** * komeda_component_get_state_and_set_user() * @@ -146,3 +159,250 @@ komeda_component_get_state_and_set_user(struct komeda_component *c, return st; } + +static void +komeda_component_add_input(struct komeda_component_state *state, + struct komeda_component_output *input, + int idx) +{ + struct komeda_component *c = state->component; + + WARN_ON((idx < 0 || idx >= c->max_active_inputs)); + + /* since the inputs[i] is only valid when it is active. So if a input[i] + * is a newly enabled input which switches from disable to enable, then + * the old inputs[i] is undefined (NOT zeroed), we can not rely on + * memcmp, but directly mark it changed + */ + if (!has_bit(idx, state->affected_inputs) || + memcmp(&state->inputs[idx], input, sizeof(*input))) { + memcpy(&state->inputs[idx], input, sizeof(*input)); + state->changed_active_inputs |= BIT(idx); + } + state->active_inputs |= BIT(idx); + state->affected_inputs |= BIT(idx); +} + +static int +komeda_component_check_input(struct komeda_component_state *state, + struct komeda_component_output *input, + int idx) +{ + struct komeda_component *c = state->component; + + if ((idx < 0) || (idx >= c->max_active_inputs)) { + DRM_DEBUG_ATOMIC("%s invalid input id: %d.\n", c->name, idx); + return -EINVAL; + } + + if (has_bit(idx, state->active_inputs)) { + DRM_DEBUG_ATOMIC("%s required input_id: %d has been occupied already.\n", + c->name, idx); + return -EINVAL; + } + + return 0; +} + +static void +komeda_component_set_output(struct komeda_component_output *output, + struct komeda_component *comp, + u8 output_port) +{ + output->component = comp; + output->output_port = output_port; +} + +#define component_validate_private(x, st) \ +({ \ + struct komeda_component *c = &((x)->base); \ + int err = 0; \ + \ + if (c->funcs->validate) \ + err = c->funcs->validate(c, &((st)->base)); \ + err; \ +}) + +static int +komeda_layer_check_cfg(struct komeda_layer *layer, + struct komeda_plane_state *kplane_st, + struct komeda_layer_viewport *view) +{ + if (!in_range(&layer->hsize_in, view->in_w)) { + DRM_DEBUG_ATOMIC("src_w: %d is out of range.\n", view->in_w); + return -EINVAL; + } + + if (!in_range(&layer->vsize_in, view->in_h)) { + DRM_DEBUG_ATOMIC("src_h: %d is out of range.\n", view->in_h); + return -EINVAL; + } + + return 0; +} + +int komeda_layer_validate(struct komeda_layer *layer, + struct komeda_component_output *input, + struct komeda_plane_state *kplane_st, + struct komeda_layer_viewport *view) +{ + struct drm_plane_state *plane_st = &kplane_st->base; + struct drm_framebuffer *fb = plane_st->fb; + struct komeda_fb *kfb = to_kfb(fb); + struct komeda_component_state *c_st; + struct komeda_layer_state *st; + int i, err; + + err = komeda_layer_check_cfg(layer, kplane_st, view); + if (err) + return err; + + c_st = komeda_component_get_state_and_set_user(&layer->base, + plane_st->state, plane_st->plane, plane_st->crtc); + if (IS_ERR(c_st)) + return PTR_ERR(c_st); + + st = to_layer_st(c_st); + + st->rot = view->rot; + st->hsize = kfb->aligned_w; + st->vsize = kfb->aligned_h; + + for (i = 0; i < fb->format->num_planes; i++) + st->addr[i] = komeda_fb_get_pixel_addr(kfb, view->in_x, + view->in_y, i); + + err = component_validate_private(layer, st); + if (err) + return err; + + komeda_component_set_output(input, &layer->base, 0); + + return 0; +} + +static void pipeline_composition_size(struct komeda_crtc_state *kcrtc_st, + u16 *hsize, u16 *vsize) +{ + struct drm_display_mode *m = &kcrtc_st->base.adjusted_mode; + + if (hsize) + *hsize = m->hdisplay; + if (vsize) + *vsize = m->vdisplay; +} + +int komeda_compiz_set_input(struct komeda_compiz *compiz, + struct komeda_component_output *input, + struct komeda_crtc_state *kcrtc_st, + struct komeda_layer_viewport *vp) +{ + struct drm_atomic_state *drm_st = kcrtc_st->base.state; + struct komeda_component_state *c_st, *old_st; + struct komeda_compiz_input_cfg *cin; + u16 compiz_w, compiz_h; + int idx = vp->blending_zorder; + + pipeline_composition_size(kcrtc_st, &compiz_w, &compiz_h); + /* check display rect */ + if ((vp->out_x + vp->out_w > compiz_w) || + (vp->out_y + vp->out_h > compiz_h) || + vp->out_w == 0 || vp->out_h == 0) { + DRM_DEBUG_ATOMIC("invalid disp rect [x=%d, y=%d, w=%d, h=%d]\n", + vp->out_x, vp->out_y, vp->out_w, vp->out_h); + return -EINVAL; + } + + c_st = komeda_component_get_state_and_set_user(&compiz->base, drm_st, + kcrtc_st->base.crtc, kcrtc_st->base.crtc); + if (IS_ERR(c_st)) + return PTR_ERR(c_st); + + if (komeda_component_check_input(c_st, input, idx)) + return -EINVAL; + + cin = &(to_compiz_st(c_st)->cins[idx]); + + cin->hsize = vp->out_w; + cin->vsize = vp->out_h; + cin->hoffset = vp->out_x; + cin->voffset = vp->out_y; + cin->pixel_blend_mode = vp->pixel_blend_mode; + cin->layer_alpha = vp->layer_alpha; + + old_st = komeda_component_get_old_state(&compiz->base, drm_st); + WARN_ON(!old_st); + + /* compare with old to check if this input has been changed */ + if (memcmp(&(to_compiz_st(old_st)->cins[idx]), cin, sizeof(*cin))) + c_st->changed_active_inputs |= BIT(idx); + + komeda_component_add_input(c_st, input, idx); + + return 0; +} + +int komeda_compiz_validate(struct komeda_compiz *compiz, + struct komeda_component_output *input, + struct komeda_crtc_state *state, + struct komeda_layer_viewport *vp) +{ + struct komeda_component_state *c_st; + struct komeda_compiz_state *st; + + c_st = komeda_component_get_state_and_set_user(&compiz->base, + state->base.state, state->base.crtc, state->base.crtc); + if (IS_ERR(c_st)) + return PTR_ERR(c_st); + + st = to_compiz_st(c_st); + + pipeline_composition_size(state, &st->hsize, &st->vsize); + + komeda_component_set_output(input, &compiz->base, 0); + + /* compiz output dflow will be fed to the next pipeline stage, prepare + * the viewport configuration for the next stage + */ + if (vp) { + vp->in_w = st->hsize; + vp->in_h = st->vsize; + vp->out_w = vp->in_w; + vp->out_h = vp->in_h; + /* the output data of compiz doesn't have alpha, it only can be + * used as bottom layer when blend it with master layers + */ + vp->pixel_blend_mode = DRM_MODE_BLEND_PIXEL_NONE; + vp->layer_alpha = 0xFF; + vp->blending_zorder = 0; + } + + return 0; +} + +int komeda_build_layer_data_flow(struct komeda_layer *layer, + struct komeda_component_output *dflow, + struct komeda_plane_state *kplane_st, + struct komeda_crtc_state *kcrtc_st, + struct komeda_layer_viewport *vp) +{ + struct drm_plane *plane = kplane_st->base.plane; + struct komeda_pipeline *pipe = layer->base.pipeline; + int err; + + DRM_DEBUG_ATOMIC("%s handling [PLANE:%d:%s]: " + "src[x/y:%d/%d, w/h:%d/%d] disp[x/y:%d/%d, w/h:%d/%d]", + layer->base.name, plane->base.id, plane->name, + vp->in_x, vp->in_y, vp->in_w, vp->in_h, + vp->out_x, vp->out_y, vp->out_w, vp->out_h); + + memset(dflow, 0, sizeof(*dflow)); + + err = komeda_layer_validate(layer, dflow, kplane_st, vp); + if (err) + return err; + + err = komeda_compiz_set_input(pipe->compiz, dflow, kcrtc_st, vp); + + return err; +} From patchwork Mon Dec 24 09:16:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Qian Wang X-Patchwork-Id: 10742129 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 BF6096C5 for ; Mon, 24 Dec 2018 09:16:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AED2A28FA5 for ; Mon, 24 Dec 2018 09:16:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A22D028FA9; Mon, 24 Dec 2018 09:16:27 +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 3336C28FA5 for ; Mon, 24 Dec 2018 09:16:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 594966E54C; Mon, 24 Dec 2018 09:16:26 +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-eopbgr50063.outbound.protection.outlook.com [40.107.5.63]) by gabe.freedesktop.org (Postfix) with ESMTPS id 51C5C6E54C for ; Mon, 24 Dec 2018 09:16:25 +0000 (UTC) Received: from AM3PR08MB0611.eurprd08.prod.outlook.com (10.163.188.149) by AM3PR08MB0183.eurprd08.prod.outlook.com (10.161.35.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1446.19; Mon, 24 Dec 2018 09:16:22 +0000 Received: from AM3PR08MB0611.eurprd08.prod.outlook.com ([fe80::3c73:534c:9c6e:352d]) by AM3PR08MB0611.eurprd08.prod.outlook.com ([fe80::3c73:534c:9c6e:352d%2]) with mapi id 15.20.1446.026; Mon, 24 Dec 2018 09:16:22 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau Subject: [PATCH 5/5] drm/komeda: Add komeda_plane/plane_helper_funcs Thread-Topic: [PATCH 5/5] drm/komeda: Add komeda_plane/plane_helper_funcs Thread-Index: AQHUm2lW2VHhssSqN0G4mdVQH4ekOw== Date: Mon, 24 Dec 2018 09:16:22 +0000 Message-ID: <20181224091450.2643-6-james.qian.wang@arm.com> References: <20181224091450.2643-1-james.qian.wang@arm.com> In-Reply-To: <20181224091450.2643-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: SY2PR01CA0039.ausprd01.prod.outlook.com (2603:10c6:1:15::27) To AM3PR08MB0611.eurprd08.prod.outlook.com (2a01:111:e400:c408::21) x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM3PR08MB0183; 6:57uAXk9t7s+qeRPXx8qoMsywMBxEplrR0jKrz9Nv47EjmfdodzohZnviWRv20mj9qUWckn7zsbaBm/0O2WCFL5xThkhmf20D5VAEbpCJB0ziAHtiGt2RoYnn4h+hyKqNEIf0D+4qVJ5osRMReiAx4Hidr1m/10XrxTORGPIF3lSH3M2Cu2oufGJwnDF4uQB3RMMemVfvUIn+W+m6ZwjO3CjkK1RUMS253p2UdMCwT32IuI+8J8wyOIBQ+2YxI3/4zKrf6WUFdbER15pUux0uqyvKOxgYMgF/9XTYSEOdW13fuk85eiQSNTXFrMjggrtlEUn/N9SWNXGgbsr3TvSBPMJo0MHg/CytD+a2TNF2b0C06oI13ZduoiOj2Y/Hn4eVW+MwQTGWb04ftaJIgJNg7Y6cJyKE+oh1e00qsJYwOq6rdlO2jrAiJD5uACtoX+svIzUm4BCtII21NHhCcVW5Ow==; 5:JM+Lc1AjY/P73KlIFVJBPYjC+IZpDT0DQvEgAsQnEzadxsaF05NhfFk62pEbI92r7twtqiDzZEZQwp31uDSLIwBDeblrftiBzjjFIxpWqZ/EjQZAI5Pr0fF15PCrwXdEOMivTA/Xdwc2Tf9DVqXYHGoec5ZDg/ouuvgbCC/QLmA=; 7:w/45rHemOmNvUMA7flV50z1q/DI/ChcNWSHRZaSUM/jvN2/UdwMBZEdMmOswgt782ckJXdROu81BgPq1mOfYvxkDR8kt0iKofKxqDMJnpBfx9xb0TkvgYW5GtymFJrFWKs6GEziVAwr7+NcxrOqbBw== x-ms-office365-filtering-correlation-id: a8c5d520-dba2-4ace-dab5-08d669807886 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM3PR08MB0183; x-ms-traffictypediagnostic: AM3PR08MB0183: nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(908002)(999002)(5005026)(6040522)(2401047)(8121501046)(10201501046)(93006095)(93001095)(3231475)(944501520)(52105112)(3002001)(6055026)(6041310)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:AM3PR08MB0183; BCL:0; PCL:0; RULEID:; SRVR:AM3PR08MB0183; x-forefront-prvs: 0896BFCE6C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(396003)(366004)(39850400004)(346002)(376002)(189003)(199004)(5660300001)(54906003)(7736002)(37006003)(256004)(14444005)(6862004)(4326008)(316002)(55236004)(386003)(86362001)(106356001)(14454004)(6506007)(186003)(99286004)(2906002)(105586002)(8936002)(97736004)(76176011)(36756003)(476003)(2616005)(71200400001)(478600001)(1076003)(6486002)(486006)(81156014)(71190400001)(3846002)(26005)(52116002)(68736007)(6116002)(6436002)(11346002)(8676002)(446003)(25786009)(305945005)(102836004)(103116003)(6636002)(81166006)(53936002)(6512007)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR08MB0183; H:AM3PR08MB0611.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: sKCdyduL+1SZ3asyZG7wtSkAc6uXIAXiK0xdA0u/0z7RtPHcTd4i1djYZfUjLLFTZbFBhFZO33SAAk3wFCjUmstQTtFeAVPjDQ+fjgWLJGZkz4zvyPf8srMDEoC08QcsjwulCDjPOk/KzawUqQ6h+hAGIVI38VJnA4qEvWWFWNVOvhRTk0RJMLkCtqMGgomLZyqlbDfGuGCYf61FLN3w+KdxB3iHgve/jTRZiPIojbjEvzAYsC10fPTRQpBDynbjTsyfS1aSLx+OieBgklH3ffUtgVMp26k5XXe49lsB18SeKs9gtDQfPcVilaIcc6RE spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: a8c5d520-dba2-4ace-dab5-08d669807886 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Dec 2018 09:16:22.2121 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR08MB0183 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 , "Tiannan Zhu \(Arm Technology China\)" , "airlied@linux.ie" , "Jonathan Chai \(Arm Technology China\)" , Alexandru-Cosmin Gheorghe , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "Julien Yin \(Arm Technology China\)" , "yamada.masahiro@socionext.com" , "james qian wang \(Arm Technology China\)" , "malidp@foss.arm.com" , "Yiqi Kang \(Arm Technology China\)" , "maxime.ripard@bootlin.com" , "thomas Sun \(Arm Technology China\)" , "Jin Gao \(Arm Technology China\)" , "Lowry Li \(Arm Technology China\)" , "sean@poorly.run" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Per komeda design KMS-plane maps to komeda layer input pipeline. komeda_plane_atomic_check is for building a komeda layer input pipeline. And KMS-plane is only a user of komeda resources. so there is no real HW update for plane, but all HW update will be handled in crtc->flush. Signed-off-by: James (Qian) Wang --- .../gpu/drm/arm/display/komeda/komeda_plane.c | 129 ++++++++++++++++++ 1 file changed, 129 insertions(+) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c index 0a4953a9a909..522bdddd0600 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c @@ -10,7 +10,83 @@ #include "komeda_dev.h" #include "komeda_kms.h" +int komeda_prepare_viewport(struct drm_plane_state *st, + struct komeda_layer_viewport *view) +{ + struct drm_framebuffer *fb = st->fb; + + memset(view, 0, sizeof(*view)); + + view->blending_zorder = st->zpos; + + /* if format doesn't have alpha, fix blend mode to PIXEL_NONE */ + view->pixel_blend_mode = fb->format->has_alpha ? + st->pixel_blend_mode : DRM_MODE_BLEND_PIXEL_NONE; + view->layer_alpha = st->alpha >> 8; + + view->out_x = st->crtc_x; + view->out_y = st->crtc_y; + view->out_w = st->crtc_w; + view->out_h = st->crtc_h; + + view->in_x = st->src_x >> 16; + view->in_y = st->src_y >> 16; + view->in_w = st->src_w >> 16; + view->in_h = st->src_h >> 16; + + return 0; +} + +int komeda_plane_atomic_check(struct drm_plane *plane, + struct drm_plane_state *state) +{ + struct komeda_plane *kplane = to_kplane(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_layer_viewport view; + struct komeda_component_output dflow; + int err; + + if (!state->crtc || !state->fb) + return 0; + + crtc_st = drm_atomic_get_crtc_state(state->state, state->crtc); + if (!crtc_st->enable) { + DRM_DEBUG_ATOMIC("Cannot update plane on a disabled CRTC.\n"); + return -EINVAL; + } + + /* crtc is inactive, skip the resource assignment */ + if (!crtc_st->active) + return 0; + + kcrtc = to_kcrtc(state->crtc); + kcrtc_st = to_kcrtc_st(crtc_st); + + err = komeda_prepare_viewport(state, &view); + if (err) + return err; + + err = komeda_build_layer_data_flow(layer, &dflow, + kplane_st, kcrtc_st, &view); + + return err; +} + +/* plane doesn't represent a real HW, so there is no HW update for plane. + * komeda handles all the HW update in crtc->atomic_flush + */ +void komeda_plane_atomic_update(struct drm_plane *plane, + struct drm_plane_state *old_state) +{ +} + static const struct drm_plane_helper_funcs komeda_plane_helper_funcs = { + .atomic_check = komeda_plane_atomic_check, + .atomic_update = komeda_plane_atomic_update, }; static void komeda_plane_destroy(struct drm_plane *plane) @@ -20,7 +96,60 @@ static void komeda_plane_destroy(struct drm_plane *plane) kfree(to_kplane(plane)); } +static void komeda_plane_reset(struct drm_plane *plane) +{ + struct komeda_plane_state *state; + struct komeda_plane *kplane = to_kplane(plane); + + if (plane->state) + __drm_atomic_helper_plane_destroy_state(plane->state); + + kfree(plane->state); + plane->state = NULL; + + state = kzalloc(sizeof(*state), GFP_KERNEL); + if (state) { + state->base.rotation = DRM_MODE_ROTATE_0; + state->base.pixel_blend_mode = DRM_MODE_BLEND_PREMULTI; + state->base.alpha = DRM_BLEND_ALPHA_OPAQUE; + state->base.zpos = kplane->layer->base.id; + plane->state = &state->base; + plane->state->plane = plane; + } +} + +static struct drm_plane_state * +komeda_plane_atomic_duplicate_state(struct drm_plane *plane) +{ + struct komeda_plane_state *new; + + if (WARN_ON(!plane->state)) + return NULL; + + new = kzalloc(sizeof(*new), GFP_KERNEL); + if (!new) + return NULL; + + __drm_atomic_helper_plane_duplicate_state(plane, &new->base); + + return &new->base; +} + +static void +komeda_plane_atomic_destroy_state(struct drm_plane *plane, + struct drm_plane_state *state) +{ + __drm_atomic_helper_plane_destroy_state(state); + kfree(to_kplane_st(state)); +} + static const struct drm_plane_funcs komeda_plane_funcs = { + .update_plane = drm_atomic_helper_update_plane, + .disable_plane = drm_atomic_helper_disable_plane, + .destroy = komeda_plane_destroy, + .reset = komeda_plane_reset, + .atomic_duplicate_state = komeda_plane_atomic_duplicate_state, + .atomic_destroy_state = komeda_plane_atomic_destroy_state, }; /* for komeda, which is pipeline can be share between crtcs */