dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Stone <daniels@collabora.com>
To: dri-devel@lists.freedesktop.org
Subject: [PATCH libdrm] NOMERGE: Add drmModeGetFB2
Date: Fri, 23 Mar 2018 13:45:53 +0000	[thread overview]
Message-ID: <20180323134553.15993-5-daniels@collabora.com> (raw)
In-Reply-To: <20180323134553.15993-1-daniels@collabora.com>

Add a wrapper around the getfb2 ioctl, which returns extended
framebuffer information mirroring addfb2, including multiple planes and
modifiers.

This depends on unmerged kernel API so should not be merged.
---
 include/drm/drm.h |  1 +
 xf86drmMode.c     | 40 ++++++++++++++++++++++++++++++++++++++++
 xf86drmMode.h     | 15 +++++++++++++++
 3 files changed, 56 insertions(+)

diff --git a/include/drm/drm.h b/include/drm/drm.h
index f0bd91de..c0a35878 100644
--- a/include/drm/drm.h
+++ b/include/drm/drm.h
@@ -886,6 +886,7 @@ extern "C" {
 #define DRM_IOCTL_MODE_LIST_LESSEES	DRM_IOWR(0xC7, struct drm_mode_list_lessees)
 #define DRM_IOCTL_MODE_GET_LEASE	DRM_IOWR(0xC8, struct drm_mode_get_lease)
 #define DRM_IOCTL_MODE_REVOKE_LEASE	DRM_IOWR(0xC9, struct drm_mode_revoke_lease)
+#define DRM_IOCTL_MODE_GETFB2		DRM_IOWR(0xCA, struct drm_mode_fb_cmd2)
 
 /**
  * Device specific ioctls should only be in their respective headers
diff --git a/xf86drmMode.c b/xf86drmMode.c
index cf8e1eac..d8cf6a0c 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -1582,3 +1582,43 @@ drmModeRevokeLease(int fd, uint32_t lessee_id)
 		return 0;
 	return -errno;
 }
+
+drmModeFB2Ptr
+drmModeGetFB2(int fd, uint32_t fb_id)
+{
+	struct drm_mode_fb_cmd2 get;
+	drmModeFB2Ptr ret;
+	int err;
+
+	memclear(get);
+	get.fb_id = fb_id;
+
+	err = DRM_IOCTL(fd, DRM_IOCTL_MODE_GETFB2, &get);
+	if (err != 0)
+		return NULL;
+
+	ret = drmMalloc(sizeof(drmModeFB2));
+	if (!ret)
+		return NULL;
+
+	ret->fb_id = fb_id;
+	ret->width = get.width;
+	ret->height = get.height;
+	ret->pixel_format = get.pixel_format;
+	ret->flags = get.flags;
+	ret->modifier = get.modifier[0];
+	memcpy(ret->handles, get.handles, sizeof(uint32_t) * 4);
+	memcpy(ret->pitches, get.pitches, sizeof(uint32_t) * 4);
+	memcpy(ret->offsets, get.offsets, sizeof(uint32_t) * 4);
+
+	return ret;
+}
+
+void drmModeFreeFB2(drmModeFB2Ptr ptr)
+{
+	if (!ptr)
+		return;
+
+	/* we might add more frees later. */
+	drmFree(ptr);
+}
diff --git a/xf86drmMode.h b/xf86drmMode.h
index 3cd27aee..70741c77 100644
--- a/xf86drmMode.h
+++ b/xf86drmMode.h
@@ -223,6 +223,19 @@ typedef struct _drmModeFB {
 	uint32_t handle;
 } drmModeFB, *drmModeFBPtr;
 
+typedef struct _drmModeFB2 {
+	uint32_t fb_id;
+	uint32_t width, height;
+	uint32_t pixel_format; /* fourcc code from drm_fourcc.h */
+	uint32_t modifier; /* applies to all buffers */
+	uint32_t flags;
+
+	/* per-plane GEM handle; may be duplicate entries for multiple planes */
+	uint32_t handles[4];
+	uint32_t pitches[4]; /* bytes */
+	uint32_t offsets[4]; /* bytes */
+} drmModeFB2, *drmModeFB2Ptr;
+
 typedef struct drm_clip_rect drmModeClip, *drmModeClipPtr;
 
 typedef struct _drmModePropertyBlob {
@@ -341,6 +354,7 @@ typedef struct _drmModePlaneRes {
 extern void drmModeFreeModeInfo( drmModeModeInfoPtr ptr );
 extern void drmModeFreeResources( drmModeResPtr ptr );
 extern void drmModeFreeFB( drmModeFBPtr ptr );
+extern void drmModeFreeFB2( drmModeFB2Ptr ptr );
 extern void drmModeFreeCrtc( drmModeCrtcPtr ptr );
 extern void drmModeFreeConnector( drmModeConnectorPtr ptr );
 extern void drmModeFreeEncoder( drmModeEncoderPtr ptr );
@@ -360,6 +374,7 @@ extern drmModeResPtr drmModeGetResources(int fd);
  * Retrive information about framebuffer bufferId
  */
 extern drmModeFBPtr drmModeGetFB(int fd, uint32_t bufferId);
+extern drmModeFB2Ptr drmModeGetFB2(int fd, uint32_t bufferId);
 
 /**
  * Creates a new framebuffer with an buffer object as its scanout buffer.
-- 
2.16.2

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

  parent reply	other threads:[~2018-03-23 13:45 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-23 13:42 [PATCH 0/8] Add GetFB2 ioctl Daniel Stone
2018-03-23 13:45 ` [PATCH 1/4] drm/i915: Use intel_fb_obj() everywhere Daniel Stone
2018-03-23 13:45   ` [PATCH 2/4] drm/i915: Move GEM BO inside drm_framebuffer Daniel Stone
2018-03-23 14:42     ` [Intel-gfx] " Ville Syrjälä
2018-03-23 14:49       ` Daniel Stone
2018-05-17 13:18         ` [Intel-gfx] " Daniel Stone
2018-03-23 13:45   ` [PATCH 3/4] drm: Reshuffle getfb error returns Daniel Stone
2018-03-23 14:43     ` Ville Syrjälä
2018-03-23 13:45   ` [PATCH 4/4] drm: Add getfb2 ioctl Daniel Stone
2018-03-23 14:49     ` Ville Syrjälä
2018-03-23 17:00       ` Daniel Stone
2018-03-23 17:31         ` Ville Syrjälä
2018-03-24 10:12           ` Daniel Stone
2018-03-23 13:45   ` Daniel Stone [this message]
2018-03-23 13:46 ` [PATCH i-g-t 1/3] tests/kms_getfb: Split property-ID get into helper Daniel Stone
2018-03-23 13:46   ` [PATCH i-g-t 2/3] NOMERGE: Update DRM UAPI to latest kernel version Daniel Stone
2018-03-23 13:46   ` [PATCH i-g-t 3/3] tests/kms_getfb: Add getfb2 tests Daniel Stone
2018-03-23 15:01     ` [igt-dev] " Ville Syrjälä
2018-03-23 14:53   ` [PATCH i-g-t 1/3] tests/kms_getfb: Split property-ID get into helper Ville Syrjälä
2018-03-23 14:55     ` [igt-dev] " Daniel Stone
2018-03-23 13:51 ` [PATCH 0/8] Add GetFB2 ioctl Daniel Stone

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=20180323134553.15993-5-daniels@collabora.com \
    --to=daniels@collabora.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox