From patchwork Thu May 2 16:10:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Davis X-Patchwork-Id: 10927285 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 1F3481395 for ; Thu, 2 May 2019 16:10:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0ED4E20855 for ; Thu, 2 May 2019 16:10:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02CD120501; Thu, 2 May 2019 16:10:16 +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 463F720499 for ; Thu, 2 May 2019 16:10:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 644008970E; Thu, 2 May 2019 16:10:13 +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-eopbgr140084.outbound.protection.outlook.com [40.107.14.84]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2FCFF89700 for ; Thu, 2 May 2019 16:10:11 +0000 (UTC) Received: from VI1PR0801MB1935.eurprd08.prod.outlook.com (10.173.73.149) by VI1PR0801MB2080.eurprd08.prod.outlook.com (10.173.75.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1856.11; Thu, 2 May 2019 16:10:09 +0000 Received: from VI1PR0801MB1935.eurprd08.prod.outlook.com ([fe80::ec0c:910f:7b71:aff4]) by VI1PR0801MB1935.eurprd08.prod.outlook.com ([fe80::ec0c:910f:7b71:aff4%7]) with mapi id 15.20.1856.008; Thu, 2 May 2019 16:10:09 +0000 From: Ben Davis To: "dri-devel@lists.freedesktop.org" Subject: [PATCH v4 1/2] drm: Add writeback_dest_x,y,w,h properties Thread-Topic: [PATCH v4 1/2] drm: Add writeback_dest_x,y,w,h properties Thread-Index: AQHVAQGDKQyFqqQxLkerU+Fz0XpoAg== Date: Thu, 2 May 2019 16:10:09 +0000 Message-ID: <1556813386-18823-2-git-send-email-ben.davis@arm.com> References: <1556813386-18823-1-git-send-email-ben.davis@arm.com> In-Reply-To: <1556813386-18823-1-git-send-email-ben.davis@arm.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [217.140.106.53] x-clientproxiedby: LO2P123CA0018.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:a6::30) To VI1PR0801MB1935.eurprd08.prod.outlook.com (2603:10a6:800:89::21) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.7.4 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 9a4ca712-00a3-41a1-964f-08d6cf18a5d1 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(4618075)(2017052603328)(7193020); SRVR:VI1PR0801MB2080; x-ms-traffictypediagnostic: VI1PR0801MB2080: nodisclaimer: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:359; x-forefront-prvs: 0025434D2D x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(366004)(39860400002)(136003)(346002)(396003)(189003)(199004)(5660300002)(76176011)(14454004)(52116002)(305945005)(6512007)(54906003)(6116002)(71190400001)(6486002)(3846002)(66446008)(73956011)(66946007)(64756008)(66556008)(66476007)(53936002)(7736002)(71200400001)(2906002)(26005)(5640700003)(2351001)(6436002)(50226002)(99286004)(316002)(8936002)(386003)(81156014)(6506007)(8676002)(102836004)(14444005)(256004)(86362001)(478600001)(44832011)(2501003)(81166006)(476003)(2616005)(186003)(446003)(11346002)(68736007)(486006)(36756003)(4326008)(6916009)(72206003)(66066001)(25786009)(5024004)(142933001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0801MB2080; H:VI1PR0801MB1935.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: Zb4GIMDG0pxsOWRF+Cj7w0gpDRAmiFTB60vbTV7umOWTSkhGsc/3qx2JN3ZulS7HBQOvSR6rIo6DRktI1O14C672cEhp7VKiVcw6RVfW1DeSOs3waTcNGqhaG0Qu9DtvwJHsO3io2U/OY0I+r56o2QSknL8iHUW1EJOW2IASRhlXhaPuP+xdkcyxBdkCbNxmU1dfnDt9ipY2FJZh1GdTG6vCx/tcSf/mlaqlat27J3FBMlOZ3QRqxBd/iCUB8ET29E1Hp/fnyMB9hFpf87PINaKSFvtRFaPbBB9Ujdf+PdLOB0cjUE35AmbEXB/Gd79mImgBvZl1dy8PL9xf8Fb5m8TDbX6XVuU+CMf0RX9IKggA+y7+0t1yHwrc7D/OcgFx58RF3NdrKO2Dhgg001omINAn+7H6FjQOmcc/EO03jTs= MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9a4ca712-00a3-41a1-964f-08d6cf18a5d1 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 May 2019 16:10:09.1057 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB2080 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RuE5x2/q/4Teoro44psVv54GvLB8LZNyWjKg0YMKyV0=; b=NURRssf7EzgE1aqtGq/g8iZqA+ccz8Lj1DKGRqgJI+vWEkVBQTzwvW4cYB26yE+F4y1MJHl6pzqJKS8lzseMc5ffn2iaUyLdmJ52bWsyBn7rJvFONlXqpgPCYgZOkeP+baACGfHinoJsP97u0U9q7h4jgY68ai75l0ZyZe6yk0Y= X-Mailman-Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Ben.Davis@arm.com; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "airlied@linux.ie" , Liviu Dudau , "linux-kernel@vger.kernel.org" , "maxime.ripard@bootlin.com" , nd , "sean@poorly.run" , Ben Davis Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add new properties to specify x,y coordinates and width and height for writeback. These are reset to 0 on duplicating state to provide robustness against accidental scaling. Signed-off-by: Ben Davis Reviewed-by: Liviu Dudau --- drivers/gpu/drm/drm_atomic_state_helper.c | 6 +++ drivers/gpu/drm/drm_atomic_uapi.c | 17 ++++++++ drivers/gpu/drm/drm_writeback.c | 66 +++++++++++++++++++++++++++++++ include/drm/drm_connector.h | 23 +++++++++++ include/drm/drm_mode_config.h | 20 ++++++++++ 5 files changed, 132 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c index 25a95b9..5973ca3 100644 --- a/drivers/gpu/drm/drm_atomic_state_helper.c +++ b/drivers/gpu/drm/drm_atomic_state_helper.c @@ -382,6 +382,12 @@ __drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector, /* Don't copy over a writeback job, they are used only once */ state->writeback_job = NULL; + + /* Auto clear writeback coordinates, should only be used once */ + state->writeback_dest_x = 0; + state->writeback_dest_y = 0; + state->writeback_dest_w = 0; + state->writeback_dest_h = 0; } EXPORT_SYMBOL(__drm_atomic_helper_connector_duplicate_state); diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index d520a04..7d3fb7f 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -765,6 +765,14 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector, return -EINVAL; } state->content_protection = val; + } else if (property == config->prop_writeback_dest_x) { + state->writeback_dest_x = val; + } else if (property == config->prop_writeback_dest_y) { + state->writeback_dest_y = val; + } else if (property == config->prop_writeback_dest_w) { + state->writeback_dest_w = val; + } else if (property == config->prop_writeback_dest_h) { + state->writeback_dest_h = val; } else if (property == config->writeback_fb_id_property) { struct drm_framebuffer *fb = drm_framebuffer_lookup(dev, NULL, val); int ret = drm_atomic_set_writeback_fb_for_connector(state, fb); @@ -837,6 +845,15 @@ drm_atomic_connector_get_property(struct drm_connector *connector, *val = state->scaling_mode; } else if (property == connector->content_protection_property) { *val = state->content_protection; + } else if (property == config->prop_writeback_dest_x) { + /* Auto clear wb co-ordinates to prevent accidental scaling */ + *val = 0; + } else if (property == config->prop_writeback_dest_y) { + *val = 0; + } else if (property == config->prop_writeback_dest_w) { + *val = 0; + } else if (property == config->prop_writeback_dest_h) { + *val = 0; } else if (property == config->writeback_fb_id_property) { /* Writeback framebuffer is one-shot, write and forget */ *val = 0; diff --git a/drivers/gpu/drm/drm_writeback.c b/drivers/gpu/drm/drm_writeback.c index c20e6fe..7c53abd 100644 --- a/drivers/gpu/drm/drm_writeback.c +++ b/drivers/gpu/drm/drm_writeback.c @@ -74,6 +74,30 @@ * applications making use of writeback connectors *always* retrieve an * out-fence for the commit and use it appropriately. * From userspace, this property will always read as zero. + * + * "WRITEBACK_DEST_X": + * The x-coordinate to write back onto the output writeback framebuffer. + * 0 acts as default. If non-zero the composition will be translated + * horizontally in the buffer by the amount specified. This is the case + * even if not scaling on writeback. + * + * "WRITEBACK_DEST_Y": + * The y-coordinate to write back onto the output writeback framebuffer. + * 0 acts as default. If non-zero the composition will be translated + * vertically in the buffer by the amount specified. This is the case even + * if not scaling on writeback. + * + * "WRITEBACK_DEST_W": + * The width of the composition to write back. 0 acts as default. If + * non-zero the composition will be scaled to match the given width. + * If scaling both WRITEBACK_DEST_W and WRITEBACK_DEST_H should be + * set as non-zero. + * + * "WRITEBACK_DEST_H": + * The height of the composition to write back. 0 acts as default. If + * non-zero the composition will be scaled to match the given height. + * If scaling both WRITEBACK_DEST_W and WRITEBACK_DEST_H should be + * set as non-zero. */ #define fence_to_wb_connector(x) container_of(x->lock, \ @@ -141,6 +165,38 @@ static int create_writeback_properties(struct drm_device *dev) dev->mode_config.writeback_out_fence_ptr_property = prop; } + if (!dev->mode_config.prop_writeback_dest_x) { + prop = drm_property_create_range(dev, DRM_MODE_PROP_ATOMIC, + "WRITEBACK_DEST_X", 0, UINT_MAX); + if (!prop) + return -ENOMEM; + dev->mode_config.prop_writeback_dest_x = prop; + } + + if (!dev->mode_config.prop_writeback_dest_y) { + prop = drm_property_create_range(dev, DRM_MODE_PROP_ATOMIC, + "WRITEBACK_DEST_Y", 0, UINT_MAX); + if (!prop) + return -ENOMEM; + dev->mode_config.prop_writeback_dest_y = prop; + } + + if (!dev->mode_config.prop_writeback_dest_w) { + prop = drm_property_create_range(dev, DRM_MODE_PROP_ATOMIC, + "WRITEBACK_DEST_W", 0, UINT_MAX); + if (!prop) + return -ENOMEM; + dev->mode_config.prop_writeback_dest_w = prop; + } + + if (!dev->mode_config.prop_writeback_dest_h) { + prop = drm_property_create_range(dev, DRM_MODE_PROP_ATOMIC, + "WRITEBACK_DEST_H", 0, UINT_MAX); + if (!prop) + return -ENOMEM; + dev->mode_config.prop_writeback_dest_h = prop; + } + return 0; } @@ -225,6 +281,16 @@ int drm_writeback_connector_init(struct drm_device *dev, drm_object_attach_property(&connector->base, config->writeback_pixel_formats_property, blob->base.id); + + drm_object_attach_property(&connector->base, + config->prop_writeback_dest_x, 0); + drm_object_attach_property(&connector->base, + config->prop_writeback_dest_y, 0); + drm_object_attach_property(&connector->base, + config->prop_writeback_dest_w, 0); + drm_object_attach_property(&connector->base, + config->prop_writeback_dest_h, 0); + wb_connector->pixel_formats_blob_ptr = blob; return 0; diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 8fe22ab..4c7701e 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -515,6 +515,25 @@ struct drm_connector_state { */ struct drm_writeback_job *writeback_job; + /** @writeback_dest_x: x coord to write plane to on wb buffer + * The written back composition will be translated by this + * amount horizontally on the output buffer. + */ + /** @writeback_dest_y: y coord to write plane to on wb buffer + * The written back composition will be translated by this + * amount vertically on the output buffer. + */ + /** @writeback_dest_w: width of plane to write to wb buffer + * The written back composition will be scaled to match this + * height dimension on the output buffer. Ignored if 0. + */ + /** @writeback_dest_h: height of plane to write to wb buffer + * The written back composition will be scaled to match this + * width dimension on the output buffer. Ignored if 0. + */ + uint32_t writeback_dest_x, writeback_dest_y, + writeback_dest_w, writeback_dest_h; + /** * @max_requested_bpc: Connector property to limit the maximum bit * depth of the pixels. @@ -704,6 +723,10 @@ struct drm_connector_funcs { * cleaned up by calling the @atomic_destroy_state hook in this * structure. * + * State relating to writeback including writeback_job and + * writeback_dest_x,y,w,h is not intended to be reused and so will not + * be duplicated and will instead be reset to NULL/0 respectively. + * * This callback is mandatory for atomic drivers. * * Atomic drivers which don't subclass &struct drm_connector_state should use diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h index 7f60e8e..40ce4a8 100644 --- a/include/drm/drm_mode_config.h +++ b/include/drm/drm_mode_config.h @@ -622,6 +622,26 @@ struct drm_mode_config { */ struct drm_property *prop_crtc_h; /** + * @prop_writeback_dest_x: Writeback connector property for the crtc + * output destination position in the writeback buffer. + */ + struct drm_property *prop_writeback_dest_x; + /** + * @prop_writeback_dest_y: Writeback connector property for the crtc + * output destination position in the writeback buffer. + */ + struct drm_property *prop_writeback_dest_y; + /** + * @prop_writeback_dest_w: Writeback connector property for the crtc + * output destination position in the writeback buffer. + */ + struct drm_property *prop_writeback_dest_w; + /** + * @prop_writeback_dest_h: Writeback connector property for the crtc + * output destination position in the writeback buffer. + */ + struct drm_property *prop_writeback_dest_h; + /** * @prop_fb_id: Default atomic plane property to specify the * &drm_framebuffer. */