All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
To: dri-devel@lists.freedesktop.org
Cc: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
Subject: [PATCH 04/14] drm: qxl: Expose creation of universal primary plane
Date: Wed, 15 Feb 2017 19:39:57 -0200	[thread overview]
Message-ID: <20170215214007.10004-5-krisman@collabora.co.uk> (raw)
In-Reply-To: <20170215214007.10004-1-krisman@collabora.co.uk>

Let's expose the primary plane initialization inside the qxl driver in
preparation for universal planes and atomic.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
---
 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)
-- 
2.11.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2017-02-15 21:40 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-15 21:39 [PATCH 00/14] qxl atomic modesetting Gabriel Krisman Bertazi
2017-02-15 21:39 ` [PATCH 01/14] drm: qxl: Drop device flags attribute Gabriel Krisman Bertazi
2017-02-17 19:46   ` Gustavo Padovan
2017-02-15 21:39 ` [PATCH 02/14] drm: qxl: Consolidate bo reservation when pinning Gabriel Krisman Bertazi
2017-02-17 19:58   ` Gustavo Padovan
2017-02-15 21:39 ` [PATCH 03/14] drm: qxl: Don't initialize vblank support Gabriel Krisman Bertazi
2017-02-15 21:39 ` Gabriel Krisman Bertazi [this message]
2017-02-15 21:39 ` [PATCH 05/14] drm: qxl: Atomic phase 1: convert cursor to universal plane Gabriel Krisman Bertazi
2017-02-15 21:39 ` [PATCH 06/14] drm: qxl: Atomic phase 1: Use drm_plane_helpers for primary plane Gabriel Krisman Bertazi
2017-02-15 21:40 ` [PATCH 07/14] drm: qxl: Atomic phase 1: Implement mode_set_nofb Gabriel Krisman Bertazi
2017-02-15 21:40 ` [PATCH 08/14] drm: qxl: Atomic phase 1: Don't unpin primary when disabling crtc Gabriel Krisman Bertazi
2017-02-15 21:40 ` [PATCH 09/14] drm: qxl: Atomic phase 2: Wire up state object handlers Gabriel Krisman Bertazi
2017-02-15 21:40 ` [PATCH 10/14] drm: qxl: Atomic phase 2: Use drm_atomic_set_fb_for_plane helper Gabriel Krisman Bertazi
2017-02-15 21:40 ` [PATCH 11/14] drm: qxl: Atomic phase 3: Use atomic handlers for planes Gabriel Krisman Bertazi
2017-02-15 21:40 ` [PATCH 12/14] drm: qxl: Atomic phase 3: Wire up atomic set_config helper Gabriel Krisman Bertazi
2017-02-15 21:40 ` [PATCH 13/14] drm: qxl: Atomic phase 3: Wire up atomic page_flip helper Gabriel Krisman Bertazi
2017-02-15 21:40 ` [PATCH 14/14] drm: qxl: Enable atomic modesetting ioctl Gabriel Krisman Bertazi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170215214007.10004-5-krisman@collabora.co.uk \
    --to=krisman@collabora.co.uk \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.