From patchwork Wed Feb 15 21:39:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 9575101 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3A6796045F for ; Wed, 15 Feb 2017 21:40:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E8F42851B for ; Wed, 15 Feb 2017 21:40:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2376828544; Wed, 15 Feb 2017 21:40:50 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY 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 BD8F42851B for ; Wed, 15 Feb 2017 21:40:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DF9866E9ED; Wed, 15 Feb 2017 21:40:48 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9B08C6E9EC for ; Wed, 15 Feb 2017 21:40:47 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 0A14A26128C From: Gabriel Krisman Bertazi To: dri-devel@lists.freedesktop.org Subject: [PATCH 04/14] drm: qxl: Expose creation of universal primary plane Date: Wed, 15 Feb 2017 19:39:57 -0200 Message-Id: <20170215214007.10004-5-krisman@collabora.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170215214007.10004-1-krisman@collabora.co.uk> References: <20170215214007.10004-1-krisman@collabora.co.uk> Cc: Gabriel Krisman Bertazi X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Let's expose the primary plane initialization inside the qxl driver in preparation for universal planes and atomic. Signed-off-by: Gabriel Krisman Bertazi --- drivers/gpu/drm/qxl/qxl_display.c | 71 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c index 2f53b48af56b..a01036090b5c 100644 --- a/drivers/gpu/drm/qxl/qxl_display.c +++ b/drivers/gpu/drm/qxl/qxl_display.c @@ -789,18 +789,87 @@ static const struct drm_crtc_helper_funcs qxl_crtc_helper_funcs = { .commit = qxl_crtc_commit, }; +static const uint32_t qxl_primary_plane_formats[] = { + DRM_FORMAT_XRGB8888, + DRM_FORMAT_ARGB8888, +}; + +static const struct drm_plane_funcs qxl_primary_plane_funcs = { + .update_plane = drm_primary_helper_update, + .disable_plane = drm_primary_helper_disable, + .destroy = drm_primary_helper_destroy, +}; + +static struct drm_plane *qxl_create_plane(struct qxl_device *qdev, + unsigned int possible_crtcs, + enum drm_plane_type type) +{ + const struct drm_plane_helper_funcs *helper_funcs = NULL; + struct drm_plane *plane; + const struct drm_plane_funcs *funcs; + const uint32_t *formats; + int num_formats; + int err; + + if (type == DRM_PLANE_TYPE_PRIMARY) { + funcs = &qxl_primary_plane_funcs; + formats = qxl_primary_plane_formats; + num_formats = ARRAY_SIZE(qxl_primary_plane_formats); + } else { + return ERR_PTR(-EINVAL); + } + + plane = kzalloc(sizeof(*plane), GFP_KERNEL); + if (!plane) + return ERR_PTR(-ENOMEM); + + err = drm_universal_plane_init(&qdev->ddev, plane, possible_crtcs, + funcs, formats, num_formats, + type, NULL); + if (err) + goto free_plane; + + drm_plane_helper_add(plane, helper_funcs); + + return plane; + +free_plane: + kfree(plane); + return ERR_PTR(-EINVAL); +} + static int qdev_crtc_init(struct drm_device *dev, int crtc_id) { struct qxl_crtc *qxl_crtc; + struct drm_plane *primary; + struct qxl_device *qdev = dev->dev_private; + int r; qxl_crtc = kzalloc(sizeof(struct qxl_crtc), GFP_KERNEL); if (!qxl_crtc) return -ENOMEM; - drm_crtc_init(dev, &qxl_crtc->base, &qxl_crtc_funcs); + primary = qxl_create_plane(qdev, 1 << crtc_id, DRM_PLANE_TYPE_PRIMARY); + if (IS_ERR(primary)) { + r = -ENOMEM; + goto free_mem; + } + + r = drm_crtc_init_with_planes(dev, &qxl_crtc->base, primary, NULL, + &qxl_crtc_funcs, NULL); + if (r) + goto clean_primary; + qxl_crtc->index = crtc_id; drm_crtc_helper_add(&qxl_crtc->base, &qxl_crtc_helper_funcs); return 0; + +clean_primary: + drm_plane_cleanup(primary); + kfree(primary); +free_mem: + kfree(qxl_crtc); + return r; } static void qxl_enc_dpms(struct drm_encoder *encoder, int mode)