[PATCH weston 9/9] clients/simple-dmabuf-drm: use tiled frame data with modifiers
Varad Gautam
varadgautam at gmail.com
Thu Nov 17 11:56:03 UTC 2016
From: Varad Gautam <varad.gautam at collabora.com>
fill the dmabuf with valid DRM_FORMAT_NV12 +
DRM_FORMAT_MOD_SAMSUNG_64_32_TILE frame data before importing to display
a non-gibberish pattern when importing with modifiers.
Signed-off-by: Varad Gautam <varad.gautam at collabora.com>
---
clients/simple-dmabuf-drm.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c
index 9205138..c2b9ad0 100644
--- a/clients/simple-dmabuf-drm.c
+++ b/clients/simple-dmabuf-drm.c
@@ -23,6 +23,7 @@
*/
#include "config.h"
+#include "simple-dmabuf-drm-data.h"
#include <stdint.h>
#include <stdio.h>
@@ -51,6 +52,7 @@
#include "fullscreen-shell-unstable-v1-client-protocol.h"
#include "linux-dmabuf-unstable-v1-client-protocol.h"
+extern const unsigned nv12_tiled[];
struct buffer;
struct display {
@@ -247,15 +249,22 @@ fill_content(struct buffer *my_buf)
{
int x = 0, y = 0;
uint32_t *pix;
- int scale_w = my_buf->format == DRM_FORMAT_NV12 ? 4 : 1;
assert(my_buf->mmap);
- for (y = 0; y < my_buf->height; y++) {
- pix = (uint32_t *)(my_buf->mmap + y * my_buf->stride);
- for (x = 0; x < my_buf->width / scale_w; x++) {
- *pix++ = (0xff << 24) | ((x % 256) << 16) |
- ((y % 256) << 8) | 0xf0;
+ if (my_buf->format == DRM_FORMAT_NV12) {
+ pix = (uint32_t *) my_buf->mmap;
+ for (y = 0; y < my_buf->height; y++)
+ memcpy(&pix[y * my_buf->width / 4],
+ &nv12_tiled[my_buf->width * y / 4],
+ my_buf->width);
+ }
+ else {
+ for (y = 0; y < my_buf->height; y++) {
+ pix = (uint32_t *)(my_buf->mmap + y * my_buf->stride);
+ for (x = 0; x < my_buf->width; x++)
+ *pix++ = (0xff << 24) | ((x % 256) << 16) |
+ ((y % 256) << 8) | 0xf0;
}
}
}
--
2.6.2
More information about the wayland-devel
mailing list