From patchwork Thu Jul 26 16:17:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru-Cosmin Gheorghe X-Patchwork-Id: 10546113 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 818A9112E for ; Thu, 26 Jul 2018 16:18:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6808E2B886 for ; Thu, 26 Jul 2018 16:18:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59A682B88E; Thu, 26 Jul 2018 16:18:34 +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=BAD_ENC_HEADER,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 ECBA52B886 for ; Thu, 26 Jul 2018 16:18:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ED52B6E7B2; Thu, 26 Jul 2018 16:18:32 +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-eopbgr10058.outbound.protection.outlook.com [40.107.1.58]) by gabe.freedesktop.org (Postfix) with ESMTPS id 780886E7C4 for ; Thu, 26 Jul 2018 16:18:31 +0000 (UTC) Received: from e114479-lin.cambridge.arm.com (217.140.96.140) by DB6PR0802MB2552.eurprd08.prod.outlook.com (2603:10a6:4:a1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.20; Thu, 26 Jul 2018 16:18:27 +0000 From: Alexandru Gheorghe To: seanpaul@chromium.org, airlied@linux.ie, dri-devel@lists.freedesktop.org, liviu.dudau@arm.com, brian.starkey@arm.com, malidp@foss.arm.com, ville.syrjala@linux.intel.com, daniel@ffwll.ch, gustavo@padovan.org, maarten.lankhorst@linux.intel.com, alexander.deucher@amd.com, christian.koenig@amd.com, David1.Zhou@amd.com, harry.wentland@amd.com, andrey.grodzovsky@amd.com, Tony.Cheng@amd.com, sunpeng.li@amd.com, shirish.s@amd.com, boris.brezillon@bootlin.com, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, inki.dae@samsung.com, jy0922.shim@samsung.com, sw0312.kim@samsung.com, kyungmin.park@samsung.com, kgene@kernel.org, krzk@kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, p.zabel@pengutronix.de, laurent.pinchart@ideasonboard.com, maxime.ripard@bootlin.com, wens@csie.org, eric@anholt.net, linux-graphics-maintainer@vmware.com, syeh@vmware.com, thellstrom@vmware.com Subject: [PATCH v2 01/10] drm/atomic: Add __drm_atomic_helper_plane_reset Date: Thu, 26 Jul 2018 17:17:47 +0100 Message-Id: <20180726161756.1794-2-alexandru-cosmin.gheorghe@arm.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180726161756.1794-1-alexandru-cosmin.gheorghe@arm.com> References: <20180726161756.1794-1-alexandru-cosmin.gheorghe@arm.com> MIME-Version: 1.0 X-Originating-IP: [217.140.96.140] X-ClientProxiedBy: AM0PR07CA0031.eurprd07.prod.outlook.com (2603:10a6:208:ac::44) To DB6PR0802MB2552.eurprd08.prod.outlook.com (2603:10a6:4:a1::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fcd5840e-af78-4e89-9b0e-08d5f3136c5f X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600073)(711020)(4618075)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:DB6PR0802MB2552; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0802MB2552; 3:wqaV7SZwBTiiI0I1cX7m24AvV50TvZK2MmrdCmenWelEkOPUbZkW0ONCiXJiqtm2Pv1VMDHWt3h5oEUan+OSSclAFcwFwnP60M0xDGX+PbHcSNPCdKrX63uChhf0LgVJc2VMH1RrPXbO7oCt/RQrb+JykFGK6SgiBrAicZrr1grXI9PGaM1cuLN2TLjgj2GHQXJf4VOtdSfe7nPWSxEDc5OcGOj6zzrrirfL22b/uKowr5VXBDnCG7TlR6BD5f4u; 25:WGQg/18uBCnmhNJejQ60X3JFFJPY1ygan7Os6Vl9LTdCjAvq6J/YuDUIG9O6Ivb6azIfaB1jzHcNwsoydTES4hK3Bvsy1AZoLTDPXPJ/58DxUdKnq52jtjz37ZS3zSq3R0+5rfJPWS6iuFV/SoJF+r9a90fgq2KlfLsCTOo1L64kTkDUiERBHBsnFQj3hskE+C10TZ/UOBvZ26wxtxUHVPz2EoshO+yGQ2mW9Rs5wc1nVIZ8bmEb7HyCR2XV9bMov0mN/nZYxL/I+BteMwDkrMyGZgqIADa9jYzaWiI6FRxqC8pQ2I8SY92kxYcy2BPbW+nlqquHnHQH4NU/YxNc8A==; 31:02iz13OnCo8QZI/ihuujXeycxhsC+ny6To9vUV4u5jgWBJsRV/yTLRSjyQ9t/8BxqMaFy720PM6LUIzljK7Z9JloS8wjuo6uKCqOtTePXeHXyO7imqx0pxTlaC+uSNauZFJcClI5/P/gtwWMpLLZg5dIkkdBUs5FWaXX0kxXXm7wH2ZpbmWU8Y91G4uIT8GYJhdcMXo3thKlDrBr+e2qD1j38w/Ktt/Qpkdw7vN9Md8= X-MS-TrafficTypeDiagnostic: DB6PR0802MB2552: NoDisclaimer: True X-Microsoft-Exchange-Diagnostics: 1; DB6PR0802MB2552; 20:W/DAeMZb15xX+M+4kITNPvS5m+XmAp1b6asYaSvs0oIWPefFCYF9UgGusfsfe4m9mf44wx4eIxznJvg+kAtcqLc3CIs3pXSDIWvLXnaoG7QEzIXdjHGAdS9+ZirlZQh5zPE7/5QuxhSvlZ8VcTdsyc2cTVT/sv4dMn0/URiiDTQ3eJqVZ48SwPOyMnwyhiz8mwcVpBE8rQ1KfR1AGIY8NoxLuGJXdTrxR4qRJUB566QH5UZdOTAq87XlrUut0wb88xPT8drXo4MSsBIXgv+dQAsbwBazKvrTmtAgX2QCzT1AihMZHve5sFP4dCms30d41P9rXB1Z6M3lOK+quU13dw==; 4:p2jYrR7pdvBF0hi2/AGPyJ/l29svBZoPbGLdFwTuIGSkBxChlnmBJyyO05cWnrEBGnNTqWxMznSetlQg58h4pya0inxDpyLZYPHwuFl0x8GqeUWSQ6Q5Mqhtg+Me6R7K4cGCumaTdnx1qUNGF4ieqh9iBbf5kcI7niaOcxsTpAIVODvPIb00uqNKjVkn16H5C+atXx3NR6fcFs19QwV3Aw/d1KkzRGoaNxO3nV+YUxL9XIYzl5ZDwYjsmcRs/KlBnfnXAd11Ui7QXanQmTxQACz/Z+jrI7ut4ydll3fIbaspmMB9xu5cDwlKlTkeX40O X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:DB6PR0802MB2552; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0802MB2552; X-Forefront-PRVS: 07459438AA X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(136003)(346002)(396003)(376002)(366004)(189003)(199004)(105586002)(305945005)(36756003)(8676002)(478600001)(476003)(2616005)(81156014)(81166006)(486006)(97736004)(50226002)(16586007)(68736007)(316002)(72206003)(956004)(25786009)(7736002)(66066001)(106356001)(47776003)(6486002)(52116002)(2906002)(86362001)(446003)(1076002)(50466002)(7406005)(11346002)(7696005)(3846002)(51416003)(6666003)(48376002)(53936002)(6116002)(386003)(26005)(8936002)(5660300001)(4326008)(76176011)(16526019)(7416002)(186003)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0802MB2552; H:e114479-lin.cambridge.arm.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-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB6PR0802MB2552; 23:kpq+xSZ9NV+6SgaD0Vwf+SicPxFnlbox7lyW4ze?= wn0pEfSQQ2rLKsmIj268Kkc+HGiTVnwHz6jWGXDxAvhHPozafd35oJl6CDlAaVpAM14obi5eWpjugC4txG4b973f6sjwClHYVHlnSF5fPG1YdJcnhgRcJzembdkbFAuoZAte2qaudr+iEO4UBofJR3lr2b0tQLoBKSx53wMxywkGiYenIIUIHgq+kDHeD3tSOliBfcWebjiOwnAbpmwM3YaBYCepZ1dC3H8LVgRWJGZ4zU/fJCf4kXhDIr33q8/1V45Oun5EwHSguzw5h05l2aecXUdV7Aib+4fZSU4GqtBA27v0tWWzOk9qxrwTqBIkMeQmiUg81SFTb5tEI+q0GfND4Yd4qg4yqWIkkWm3ZD4LxjSoThyiWJiOZuA+2b8dfm7UYGENQzSuPKI9TfHc1eDIF6UxRQZD6FuhCbZPfl0Ya/HIjDUSgi1y8UERUBWsZrpdwT07K8YyJfPZq2Hf6Of1fXI31Vm0inwmgMzmhOrPr8rL6e9w3BfRB7lSiK55x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-Exchange-Diagnostics: 1; DB6PR0802MB2552; 6:UgidXKD7a/sozSZZCNIVidXlM1jCf3TkohJq+ZSLySEgdxVwYXHtLfix9l04Tnlrb14FnZA2zLChA1WFdZttzzUgGwI2JUBeMnLkFUKdJJQWvoZEYY5eRMhvIPQM88sF0t7y36loBUIptKJtwCQcyE3+tcXKqGtNQywlPi+r4ntQy0jm3/Z3QtPJEvv39Gu0KLfUcmtBZaA5uf/HbZYy3sqjYSvnJMMuSE9kdK2pnXWp0/wmZui/UT9w495ja2SRtJa1RXyIDDiFpQD8U/7QTLKrdsfbF2ZNghCoBCN0LsPT71dbfCwv9oYniiDVFtfV5uQdNeSuNjZIUZkbJncw4qDFSE5P3OTLnr1zo+/VuXbgXSGQW2iEBV8Lefq7FpqZaohDEoHFpI7cUcOsOQ6XNc+h2oNM0JusvVFfhrg0Xc4xSNmOZZJEW5Z+Ewx+ymLtzPWA4msNgm8VvcvestsrRA==; 5:RsErnf8l+TB98TMwKOq3t1MSCsncTXczBRkn1SJqkdIBlBQLPk95BLwtg7V/J8ARgL+FXtUutJu9kgCy4+fEY0cRBaeN1y9V7UKxCXq+iQWHtDAdumY+O69G1vZYxbSNyIG8z5fQf3jw7PO/ONOrpn9bj1w21KwPiDQxUK0cYjw=; 7:4FFFS6WTBN+S7NBboXYZsfZXXE6W16t9MnOV7UTsr2kufqsRV13bRlj26DRBgf6PF9Poeh2AMpWYAXN0PK4Z+g6QuqAjhKZmjbBR5Hmf2KF0i9K/1xKKYYigdiaCwa6GDyWrVfvQuCcFQ7rPLLjJc7Lt2xWBHv+qSAOWcyRrt5BTg0a24IBD6fGx0vzXSPAkD7pYIp/gxDIZzgLNEzDKTVjtqAxGBAF65/SJsE5qPOt6oAGzbWNNyem3lWpLxcND SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jul 2018 16:18:27.6664 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fcd5840e-af78-4e89-9b0e-08d5f3136c5f X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2552 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@arm.com, Alexandru Gheorghe Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP There are a lot of drivers that subclass drm_plane_state, all of them duplicate the code that links toghether the plane with plane_state. On top of that, drivers that enable core properties also have to duplicate the code for initializing the properties to their default values, which in all cases are the same as the defaults from core. Change since v1: - Make it consistent with the other helpers and require that both plane and state not be NULL, suggested by Boris Brezillon and Philipp Zabel. Signed-off-by: Alexandru Gheorghe Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/drm_atomic_helper.c | 31 ++++++++++++++++++++--------- include/drm/drm_atomic_helper.h | 2 ++ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 866a2cc72ef6..7f5aafc5b1a0 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -3552,6 +3552,26 @@ void drm_atomic_helper_crtc_destroy_state(struct drm_crtc *crtc, } EXPORT_SYMBOL(drm_atomic_helper_crtc_destroy_state); +/** + * __drm_atomic_helper_plane_reset - resets planes state to default values + * @plane: plane object, must not be NULL + * @state: atomic plane state, must not be NULL + * + * Initializes plane state to default. This is useful for drivers that subclass + * the plane state. + */ +void __drm_atomic_helper_plane_reset(struct drm_plane *plane, + struct drm_plane_state *state) +{ + state->plane = plane; + state->rotation = DRM_MODE_ROTATE_0; + /* Reset the alpha value to fully opaque if it matters */ + if (plane->alpha_property) + state->alpha = plane->alpha_property->values[1]; + plane->state = state; +} +EXPORT_SYMBOL(__drm_atomic_helper_plane_reset); + /** * drm_atomic_helper_plane_reset - default &drm_plane_funcs.reset hook for planes * @plane: drm plane @@ -3566,15 +3586,8 @@ void drm_atomic_helper_plane_reset(struct drm_plane *plane) kfree(plane->state); plane->state = kzalloc(sizeof(*plane->state), GFP_KERNEL); - - if (plane->state) { - plane->state->plane = plane; - plane->state->rotation = DRM_MODE_ROTATE_0; - - /* Reset the alpha value to fully opaque if it matters */ - if (plane->alpha_property) - plane->state->alpha = plane->alpha_property->values[1]; - } + if (plane->state) + __drm_atomic_helper_plane_reset(plane, plane->state); } EXPORT_SYMBOL(drm_atomic_helper_plane_reset); diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h index 99e2a5297c69..f4c7ed876c97 100644 --- a/include/drm/drm_atomic_helper.h +++ b/include/drm/drm_atomic_helper.h @@ -156,6 +156,8 @@ void __drm_atomic_helper_crtc_destroy_state(struct drm_crtc_state *state); void drm_atomic_helper_crtc_destroy_state(struct drm_crtc *crtc, struct drm_crtc_state *state); +void __drm_atomic_helper_plane_reset(struct drm_plane *plane, + struct drm_plane_state *state); void drm_atomic_helper_plane_reset(struct drm_plane *plane); void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane, struct drm_plane_state *state);