[igt-dev] [PATCH i-g-t] lib: Rework __kms_addfb() function
Rodrigo Siqueira
rodrigosiqueiramelo at gmail.com
Wed Apr 3 22:24:39 UTC 2019
The function __kms_addfb() and drmModeAddFB2WithModifiers() have a
similar code. Due to this similarity, this commit replace part of the
code inside __kms_addfb() by using drmModeAddFB2WithModifiers().
Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo at gmail.com>
---
lib/ioctl_wrappers.c | 27 ++++++---------------------
1 file changed, 6 insertions(+), 21 deletions(-)
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 39920f87..4240d138 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -46,6 +46,7 @@
#include <sys/utsname.h>
#include <termios.h>
#include <errno.h>
+#include <xf86drmMode.h>
#include "drmtest.h"
#include "i915_drm.h"
@@ -1479,29 +1480,13 @@ int __kms_addfb(int fd, uint32_t handle,
uint32_t strides[4], uint32_t offsets[4],
int num_planes, uint32_t flags, uint32_t *buf_id)
{
- struct drm_mode_fb_cmd2 f;
- int ret, i;
+ uint32_t handles[4] = {handle};
+ uint64_t modifiers[4] = {modifier};
if (flags & DRM_MODE_FB_MODIFIERS)
igt_require_fb_modifiers(fd);
- memset(&f, 0, sizeof(f));
-
- f.width = width;
- f.height = height;
- f.pixel_format = pixel_format;
- f.flags = flags;
-
- for (i = 0; i < num_planes; i++) {
- f.handles[i] = handle;
- f.modifier[i] = modifier;
- f.pitches[i] = strides[i];
- f.offsets[i] = offsets[i];
- }
-
- ret = igt_ioctl(fd, DRM_IOCTL_MODE_ADDFB2, &f);
-
- *buf_id = f.fb_id;
-
- return ret < 0 ? -errno : ret;
+ return drmModeAddFB2WithModifiers(fd, width, height, pixel_format,
+ handles, strides, offsets, modifiers,
+ buf_id, flags);
}
--
2.21.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/igt-dev/attachments/20190403/19d8b1d1/attachment.sig>
More information about the igt-dev
mailing list