From patchwork Sat Aug 4 16:15:21 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: 10555781 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 38A7B157D for ; Sat, 4 Aug 2018 16:15:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28C1B29C72 for ; Sat, 4 Aug 2018 16:15:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C5A029CF5; Sat, 4 Aug 2018 16:15:58 +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 B083529C0C for ; Sat, 4 Aug 2018 16:15:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B43E16E125; Sat, 4 Aug 2018 16:15:55 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0615.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe1f::615]) by gabe.freedesktop.org (Postfix) with ESMTPS id DD7346E125 for ; Sat, 4 Aug 2018 16:15:53 +0000 (UTC) Received: from e114479-lin.cambridge.arm.com (217.140.106.49) by AM5PR0802MB2547.eurprd08.prod.outlook.com (2603:10a6:203:a0::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.14; Sat, 4 Aug 2018 16:15:50 +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 v3 01/10] drm/atomic: Add __drm_atomic_helper_plane_reset Date: Sat, 4 Aug 2018 17:15:21 +0100 Message-Id: <20180804161530.12275-2-alexandru-cosmin.gheorghe@arm.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180804161530.12275-1-alexandru-cosmin.gheorghe@arm.com> References: <20180804161530.12275-1-alexandru-cosmin.gheorghe@arm.com> MIME-Version: 1.0 X-Originating-IP: [217.140.106.49] X-ClientProxiedBy: DB6P189CA0005.EURP189.PROD.OUTLOOK.COM (2603:10a6:6:2e::18) To AM5PR0802MB2547.eurprd08.prod.outlook.com (2603:10a6:203:a0::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8bb54d92-c0cd-42e2-6ade-08d5fa258c5c X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM5PR0802MB2547; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0802MB2547; 3:Yt1I0UgWw8LFFRMl8dTAdE3cbYBGAdcd8fsIdI5USV5Grzgg46ArymqJe6H3jfWe9PFejfv4xPPqiy5bSVOpu552e3+YG5HteYD7FlXpuXXB1kCBTjoX7jOdP75dUxcKdDj0j9+9MAjVQwjTjQtMiz8MDwF9yLwml8t+bt/J/CodFEZUii5lqV+beOoQImDG+SvdEW2Lf+CrFX4BZB11zMqodW8NuLcy5ECCNXC/30bbay+dBxCyPkpv1KVAI77n; 25:kPc8ThlTrZhN2PWghqgszRtHLtLKh/pogtxyTCGTGf8YMvWb6GxwQ9BoiB42VhdX6DYMIKu0H6TYR2sSo5kmgJ8e0SXsT9f8+eb6rKXeBeBHZa/5bZtb8gQtosoG5dJWnVhJG8hgNbsgbaoPlras13mQvDJpIjcZSQ0L4RkYXEkifGJjQMovkGM8U6Z36bydr5G88iuNah/zKEWbcWCK6PEK2mnkHK2fYqv8ANkf9dcVTflUFXOWvRIIUSlZm2bAoDVabYMHQfRPE1sshFt8slLg0A2J6/or32qPEjJs5Ulnad6IVV9jEk/oW7Wp22lss+FgW+8oE+kMdBkOepA7gw==; 31:8wo4HqPAdjYNXgXK4AC+dtWhN3NzKxttl6fV7zVsWxRZG9uHSKOLUXIePpa5PC0MJ5GmOYxwt23u5K1qZR9pPdPqoxFhxIXt41xlvHqvq8qPJz7az3UM1mio3OuVDbi6/T1KbkoGsE8Dpe/ooY5ztRdnQ9dJ2b02htskrDP57h4zrGEzL8WlEqDF9KGm6rvnGDOlt61bBUOSGFPkFfkqnajNjJ97iU4QTS+6n2OKXRM= X-MS-TrafficTypeDiagnostic: AM5PR0802MB2547: NoDisclaimer: True X-Microsoft-Exchange-Diagnostics: 1; AM5PR0802MB2547; 20:4skip7kFG3gogbadjReOrrNPYrSbdgXC1q0gVNgxM42bjQOHlnD9W8LkXmnqnc7A/Rxg8iyA/dBVzJlbYuADqbqouQJWX6843ZEuHb3kT7tenDLl0RuQSmQ+gS9cPfR4EFVETQZQgjXPTayYILoM/nRDt4c+uYwS2VOZqst3D6OjpAg0Sj9ETv1fd5oB1wDcZ3zWefY5VHR5oHrXt+9DXPrObz+JR9AXoowS7CbxNVr/9/gD+gNm0ACimIkrg2AM6WrlPDYQ2F30ghpQcG7Cw7J96mPx1Pz4O14+JQQ5VsknI3GJhq8oJtjRFlftUV4xIWOEjSTlzs0LqPU0OBau5w==; 4:ZcU/HKvNgSuvH5vBwMOpMT3XjL9xxqGq+FbtgoM04mwLMSpm1oGqyHxKDoxJFBHutfnnPiWSR9XdwGPS3i5IygT5n8trnnMT2HaoQg11AhwLDQYlHOoDoGZIILitIxgZDxtoX3BFcpcaSZQYXv/D+eFpuorCJYbBjv46T06nJNsETtTdDLJYUiP5HTtV/OwmNgAwFdAQf9gr+3D5qEdn1wIKgOn+r+bKo/fdPyw9fYFg4Q2YBPMK99SRwpEO24nyc256Iw8yH4YCuDI6fx490Kc81kW9qpZZTtr2mQrIg9PQEPssnOmf+/m7up9U1Ymy 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)(3231311)(944501410)(52105095)(10201501046)(93006095)(93001095)(3002001)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:AM5PR0802MB2547; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0802MB2547; X-Forefront-PRVS: 0754F7E325 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(366004)(396003)(376002)(136003)(39860400002)(189003)(199004)(51416003)(86362001)(76176011)(7736002)(4326008)(66066001)(47776003)(52116002)(97736004)(7696005)(305945005)(25786009)(16526019)(186003)(105586002)(6116002)(3846002)(956004)(106356001)(7416002)(5660300001)(446003)(1076002)(11346002)(26005)(6666003)(2616005)(7406005)(478600001)(53936002)(72206003)(68736007)(486006)(8936002)(36756003)(50226002)(316002)(50466002)(81166006)(476003)(16586007)(81156014)(48376002)(386003)(2906002)(8676002)(6486002)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0802MB2547; 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; AM5PR0802MB2547; 23:I+tm0ryqu1AdglF5kY6LgH9v+Dj1Khz+vG97sSB?= wkOx+fCmvHLVaaonWwE+aXzjbRxRZsWLVfgniB/XzQ6A1cxdJAx9ZT4J1rMZkXfp3ll6BgB/THH6DecOMn9zakA1OfS/+YMYzHFNGS8cqzsJwYCDWGCly52M511TLcRFBM1Oqp54ktUnNh2tq0r/oeVserw9zkx4WpE0CwwnJBF4x6luhV2ivDiS6cChbo0GyJ3VRUhqaS1dxsueMEScyxStNF6xRed1E5sznyTsr8WlXqv6uRPqHb9EHsnGGqJybZNppligAwQuSzOJ9CqEg7EIugppDzIVf9QpAE2mqPabBQx/SYh+5NdiDuOZHyFbf4EWUXX1LF52J+rSr981+/wKixargG1wQzNcHk5VprKQl4no0xnZt57uRnzJBxGW2fg7WXQ7PwDUaOlkp0ubvs0HoPoLcAEzzgVmXJhh/3HoD2eVIpcAUHeTlMqjlA0S3v9BEobbSJHxdXo7ZsE6CEq2Xt6bs9YsTo+cSmq+G1wD9PXPZm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KegOFcp4YqBM2b5Viy9ZSc1o7U= X-Microsoft-Exchange-Diagnostics: 1; AM5PR0802MB2547; 6:g5c3xYwYU4UlbbKv+jl2BLq+WIfLD1s1+1zj8v3GY4lcZHjdhm9WMyfxRUJUMilNX4S3Omkm2BhZnKlVP1Ek7jm9Efo+HFNjjvd9KpZ1tGTQ6nZZ9sAzU0i/pH+iX0gA4gbFVy7M/VHMAqwSBTzcwboOrOl9Bhk4Th9hethnlI5FvK/VcVmZ3H1fUgJ6xxlsXmxohaCo2gfr0264l+/ukBAN8CAZ2NMtCo264C01S0mxOwiJ5CoRw6wc9ECPamxItJyOgXMIF7JyBY3Xlej6eJQDcTI7nAuEK282XxmgrtZE6SUSTHONtmTIKxQ/pzpArJovGpvSYpIQGI5j7m4/lM9dydorx0icMHAiVVX1p+9sirnMpnEY0hWMppz08tc6O4YZA+Pv79TyHYw6itdL/2YtB9zmvWjyBWOV3CdCKon01kRFsZMyr0/3gZGG6xIDD+o1S3ZaA8F4EXDc6KPQTg==; 5:aY35QMmQv0GUTmMmXU9Ls7tANnYDkt/XZLrO4TJNU9/8wvPmDizJk8DPpedjWdoveiFe3bWrp4pSqzNhZPbRKuyHKQf8iuoYObO1HxGA2N1Rrx88t++cQFku60J5PqZ9lyCt2DcFcdAKb2cVIwYPd2iHLItsV3XR/+yCq/UTjSI=; 7:hLW+d9xEF3c9tQjSMu3PeoUv6X2ZRL1nsbu6GozUNxNymkymw2z+R+nQB8jSfY6rjevA24rCdN0SVQMCaXTApGA838J3VLkXP28Sh04gMQFKQqI1nUYSEhc5pvJhAODB7Wt/nDcu37IIcoTFQUbXdMlx9LDaer0a1lBQUmMkQ49VPNgAGW4iqm2pR/rzUCzGTFomBef4yI+iA4F45BefX7ehIE/ncAdbn1EoDZxtXSAKTg98qmL9JV50vqET4T6j SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2018 16:15:50.6464 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8bb54d92-c0cd-42e2-6ade-08d5fa258c5c X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0802MB2547 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 together 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. Reviewed-by: Laurent Pinchart Signed-off-by: Alexandru Gheorghe Reviewed-by: Philipp Zabel --- drivers/gpu/drm/drm_atomic_helper.c | 33 +++++++++++++++++++++-------- include/drm/drm_atomic_helper.h | 2 ++ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 866a2cc72ef6..6dd5036545ec 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -3552,6 +3552,28 @@ 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 +3588,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);