summaryrefslogtreecommitdiff
path: root/media-libs/raspberrypi-userland
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /media-libs/raspberrypi-userland
reinit the tree, so we can have metadata
Diffstat (limited to 'media-libs/raspberrypi-userland')
-rw-r--r--media-libs/raspberrypi-userland/Manifest13
-rw-r--r--media-libs/raspberrypi-userland/files/04raspberrypi-userland3
-rw-r--r--media-libs/raspberrypi-userland/files/92-local-vchiq-permissions.rules3
-rw-r--r--media-libs/raspberrypi-userland/files/bcm_host.pc10
-rw-r--r--media-libs/raspberrypi-userland/files/egl.pc11
-rw-r--r--media-libs/raspberrypi-userland/files/glesv2.pc11
-rw-r--r--media-libs/raspberrypi-userland/files/next-resource-handle.patch207
-rw-r--r--media-libs/raspberrypi-userland/files/raspberrypi-userland-9999-gentoo.patch15
-rw-r--r--media-libs/raspberrypi-userland/metadata.xml15
-rw-r--r--media-libs/raspberrypi-userland/raspberrypi-userland-0_pre20160424.ebuild109
-rw-r--r--media-libs/raspberrypi-userland/raspberrypi-userland-9999.ebuild44
11 files changed, 441 insertions, 0 deletions
diff --git a/media-libs/raspberrypi-userland/Manifest b/media-libs/raspberrypi-userland/Manifest
new file mode 100644
index 000000000000..dd63a1eb7d5a
--- /dev/null
+++ b/media-libs/raspberrypi-userland/Manifest
@@ -0,0 +1,13 @@
+AUX 04raspberrypi-userland 80 SHA256 95e985fe34667c47dd73e0ad674e46bcbc0f411fd26e95edda5d853790eabfd1 SHA512 fc934a7aa367dcd787c9158d07f59866b8e04034928303a949b2c4fa45577afcc0b31c5a3e7b08defcfc040e601a51728fc5ccd9a6c0dd60e2c1cb2fd00107d9 WHIRLPOOL 5dfeb9134775876833ea8cd3ecb3b222c6dbe993202e75032159752706f68bf6a358a2de2431fa81a97de06dff250eaeae14296508d28f7a7b3b0bc0cbd9629b
+AUX 92-local-vchiq-permissions.rules 142 SHA256 44f6eadcbb0293f1ce8c7acbe7d561f6e9b277f997aaafd3a91168bb07b926c5 SHA512 b0e430adf65ccde1c3199c59e876293ffa1821a70f7d60057bb4990108fe21604e6d8c11dbdd74de50ad1fd5fad5e579ad35fb172a62ccef26bd2ff9bed5aba4 WHIRLPOOL 45bcd3fbca54592a6b9cf61ab60fb9f6ac2819fcbe2c41a2a0329188e197d9319df2da1b7c54f15bc6da91f5d495df45b074e73db792b34e19616c0ffb23ed9d
+AUX bcm_host.pc 338 SHA256 29fd320790e6031041d40154db3bdf2f734e4ae813955d824992ae8c55250044 SHA512 d13ebe21288fc8cb29643a3564415006899490334c8a2d4601632d5a7b681e1f1ee97cc7b8d6b8840b28432dc8dd0b090e0c592dc07c99e3cc72ad9fbce0933b WHIRLPOOL 5a9ba1221259d689a5d3851a1ff011443c0c549aa0f385e1ed93904247c9ad01515a748f9c5f1f9eba68b29fa0bfe1813f17e772c9e50a7985a0a1b42f0482ca
+AUX egl.pc 227 SHA256 3a8b24e821c7553fa568961b5b58f96081d0664c3d719e566c8b5a34b54e72e9 SHA512 15e2cdf73be35640a951a7e841963902bb056d96025b52c1551359ec7671baf710699c642a08a5543d52d27f424d900e2fd1d584976a056a54a20116b59a21f6 WHIRLPOOL 42c874e3be38780342e54c19eec6bafca56db74f020aa7a3a963c08933647e1d39463fd756db331553163e7663ef7017edd5be4b193e8037038b758bbc325782
+AUX glesv2.pc 230 SHA256 8c8eb257586eb5e6c3c218d3593df3d1be3bf1601c4f5e97873a5dd5539e6554 SHA512 a821afcf22d52ea48b4b94b3f4317553bed2ed2e1aadee2862b4d925ee3c78cc0d3a023c62842758de5c2b168dfc8b1ba6838ccb9b0749aef9fc782aa33fa8ec WHIRLPOOL d7deb0402d92db6424b34230045cf9d13fbee4facc1dc6850da686b42be7c8b769bc31523c7abcbf7a620d7560c0b4b3dde7e7958bb3031738fda5ad01407c84
+AUX next-resource-handle.patch 12535 SHA256 73f62905618d929eea77c9d81855cbc37f47823996242d598b0eaa080d7e2b12 SHA512 f0368ffff54f989f2541f1891fe3b244d9ff4f2fc464adf2387c04045aca2f1e1f35622d2bd6c6d42e9581c45c417d1961e235b063d892b17e7dbe3e4724f5c5 WHIRLPOOL 4afd1c794a7e986841ac29acb33f47ac8db6ab79a880e0cb0085a21ee8f14264f252477510479a93322a205e8306421cf69c19ffb18a48aedda82525555a9d4d
+AUX raspberrypi-userland-9999-gentoo.patch 679 SHA256 fb23424269946621a0366a0d4005feebcaf23ba498089e2dd374b66bc395ec36 SHA512 b655256358338ad2c1504953d219dac6cae4bde50c376fb64813f7f62a0197474cad3ce3ae9f6b9c8eeb3b0582f368be6eaaa66b94030eb5a099cab758c4dc4e WHIRLPOOL 3153ee6945d143af38d97145f764568283b2d4f5c020cf4be2e4e5c478598a8a0fc7c105444b441ac35bd262c02d09a45fac4a18be435acf7546ae5656ca5225
+DIST raspberrypi-userland-0_pre20160424.tar.gz 32933952 SHA256 e040448cec34b9cea0072977397391af3131b2b43b057beba2ecf8b098d70b77 SHA512 04a71837b1247ecbbe479b3b09b5705638a9e576dc99a1ab2200727509195a4a2f2a9b184e3c23ce3933a3236b260afc8bd2b75bc218567b386445bdd8208a5b WHIRLPOOL 95d6472d2f64e047d296cbebc122fe62eb392f861ad069e5a092a2d5710e7f85824e7a69e68d5af68d91b567c973b7e8b95135bf8b5a0bcfa58b683b35a8ed44
+EBUILD raspberrypi-userland-0_pre20160424.ebuild 3280 SHA256 b4e8433c7bea3ac80778f1695e48aba3e3197657b130f41dadb86918c391ee39 SHA512 f1fca6c1cf73336d482c4cd400667e22d6493402fa23389e62e40af86dc605af98dddee39b5f553fc33cc03c766f40b8009f41c8af004d540e28b01a8bb24ac1 WHIRLPOOL 2cb0f8b8a16cc86fecac2ee4f26ee8b3971ec760b03b6f917b906e52e0d57f91932c70ef8f63a3a7a4289fccd89311cc85a8a7b94670ae22f66142877637df88
+EBUILD raspberrypi-userland-9999.ebuild 829 SHA256 d9e87dd4572b7fcd0eaca7a56d99bfa9e7bc5e587590e33e5885aa2a41fe8e6e SHA512 0d070ec48cfc746c315f49a75c59bbe9bbb597ec73682e91a7f829984924e4cc637c4a38d97ea4803e0960872499a711fd93653cbc745a83dae86015caae9632 WHIRLPOOL b0c0d57d5eaed1b74c743330d71f42eb7318179c79d98da1bc1e2dc7b0369f1d572cea663de3db95efebdb7e732e791abcb1007f3263f452a37368b3e5179251
+MISC ChangeLog 4947 SHA256 e3efa36000fc45e3ff1bf59181e4e9609645e1c37f8415438aa5e950843e8215 SHA512 3b2991dd9bd7e520acf62d4dd301bba4a48611df0befe741016aa4df63cca41b5e84136a1e0a7123a5b98747f03f690c9c0ae8403fad81e0599d24d069a2c042 WHIRLPOOL b26da0b80a3df65c3d76b9c607cd4e4b4fd1bd900b639fbdb88739f304eb5ab366e919fc7d187cc9655446969bd327532acef349a384b8a9d804738775329e08
+MISC ChangeLog-2015 2133 SHA256 f2106b17f331a96bd161bc72175b2d2a7f852e7f0bf07df83ed33c76dfa00f58 SHA512 856acd758be3192c6e09e36826c55148b5056535b38e5caf6ea2839cc79b35fd76f598207c19c7e43b1b725d5a760d77303ae7046a152acb523a77ec9f20d814 WHIRLPOOL a2e4f8837a18ef6e621062b7969847b50f9577233960902ede1b9fb73a098df5e1a3ac3313ba84eabc2310e175216da74270db1764245acb4f4846c32131ede1
+MISC metadata.xml 459 SHA256 5318aeec0283686c22745e9f4ad550186516cc29cb937727685f51c72b3bdf6c SHA512 0424eda38137b1e4b2b74645e83cc8ea6038dc59f6d6a9b51043a81543283bc25cc8e82ca85d9a97f20423af095c5516f8c9c72f84bd1b1d63c3beb3e3f000b9 WHIRLPOOL 607853a4e33a324d675438b60cca8a03c1f309b590f6977f3d62acb3269d526b1444908a69336413be71a0b54f4c3ee6ba28a06d3202ba2a45643d11cd3b12b4
diff --git a/media-libs/raspberrypi-userland/files/04raspberrypi-userland b/media-libs/raspberrypi-userland/files/04raspberrypi-userland
new file mode 100644
index 000000000000..17b493b1814e
--- /dev/null
+++ b/media-libs/raspberrypi-userland/files/04raspberrypi-userland
@@ -0,0 +1,3 @@
+PKG_CONFIG_PATH='/opt/vc/lib/pkgconfig'
+PATH='/opt/vc/bin'
+LDPATH='/opt/vc/lib'
diff --git a/media-libs/raspberrypi-userland/files/92-local-vchiq-permissions.rules b/media-libs/raspberrypi-userland/files/92-local-vchiq-permissions.rules
new file mode 100644
index 000000000000..fd95502940a5
--- /dev/null
+++ b/media-libs/raspberrypi-userland/files/92-local-vchiq-permissions.rules
@@ -0,0 +1,3 @@
+SUBSYSTEM=="vchiq",GROUP="video",MODE="0660"
+SUBSYSTEM=="vc-sm",GROUP="video",MODE="0660"
+SUBSYSTEM=="bcm2708_vcio",GROUP="video",MODE="0660"
diff --git a/media-libs/raspberrypi-userland/files/bcm_host.pc b/media-libs/raspberrypi-userland/files/bcm_host.pc
new file mode 100644
index 000000000000..7627ae87105b
--- /dev/null
+++ b/media-libs/raspberrypi-userland/files/bcm_host.pc
@@ -0,0 +1,10 @@
+prefix=/opt/vc
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: bcm_host
+Description: Broadcom VideoCore host API library
+Version: 1
+Libs: -L${libdir} -lbcm_host -lvcos -lvchiq_arm
+Cflags: -I${includedir} -I${includedir}/interface/vmcs_host/linux -I${includedir}/interface/vcos/pthreads -DUSE_VCHIQ_ARM
diff --git a/media-libs/raspberrypi-userland/files/egl.pc b/media-libs/raspberrypi-userland/files/egl.pc
new file mode 100644
index 000000000000..56bf1e07e93b
--- /dev/null
+++ b/media-libs/raspberrypi-userland/files/egl.pc
@@ -0,0 +1,11 @@
+prefix=/opt/vc
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: EGL
+Description: Fake EGL package for RPi
+Version: 10
+Requires: bcm_host glesv2
+Libs: -L${libdir} -lEGL
+Cflags: -I${includedir}
diff --git a/media-libs/raspberrypi-userland/files/glesv2.pc b/media-libs/raspberrypi-userland/files/glesv2.pc
new file mode 100644
index 000000000000..04d61c21cea3
--- /dev/null
+++ b/media-libs/raspberrypi-userland/files/glesv2.pc
@@ -0,0 +1,11 @@
+prefix=/opt/vc
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: GLESv2
+Description: Fake GL ES 2 package for RPi
+Version: 10
+Requires: bcm_host
+Libs: -L${libdir} -lGLESv2
+Cflags: -I${includedir}
diff --git a/media-libs/raspberrypi-userland/files/next-resource-handle.patch b/media-libs/raspberrypi-userland/files/next-resource-handle.patch
new file mode 100644
index 000000000000..45e1a494b2c8
--- /dev/null
+++ b/media-libs/raspberrypi-userland/files/next-resource-handle.patch
@@ -0,0 +1,207 @@
+From 825c3236e5908ff003644abd870bfe98e82722b2 Mon Sep 17 00:00:00 2001
+From: Dom Cobley <dc4@broadcom.com>
+Date: Tue, 9 Jul 2013 09:26:26 -0400
+Subject: [PATCH] Allow applications to set next resource handle
+
+This patch adds provisions in userland to
+let apps callers set the next rendereing dispmanx resource.
+It's useful for implementing, say, a buffer carousel.
+---
+ interface/khronos/common/khrn_client_rpc.h | 2 ++
+ interface/khronos/common/khrn_int_ids.h | 2 ++
+ interface/khronos/egl/egl_client.c | 30 +++++++++++++++++++++++++++---
+ interface/khronos/egl/egl_client_surface.c | 24 +++++++++++++++++++++++-
+ interface/khronos/egl/egl_client_surface.h | 3 ++-
+ interface/khronos/egl/egl_int_impl.h | 5 +++--
+ 6 files changed, 59 insertions(+), 7 deletions(-)
+
+diff --git a/interface/khronos/common/khrn_client_rpc.h b/interface/khronos/common/khrn_client_rpc.h
+index 418aa67..a7557a8 100644
+--- a/interface/khronos/common/khrn_client_rpc.h
++++ b/interface/khronos/common/khrn_client_rpc.h
+@@ -683,6 +683,7 @@ static INLINE void rpc_call18(CLIENT_THREAD_STATE_T *thread, uint32_t id, uint32
+ static INLINE void rpc_call13_out_ctrl(CLIENT_THREAD_STATE_T *thread,uint32_t id, uint32_t p0, uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4, uint32_t p5, uint32_t p6, uint32_t p7, uint32_t p8, uint32_t p9, uint32_t p10, uint32_t p11, void *out) { rpc_begin(thread); RPC_CALL(thread, id, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); rpc_recv(thread, out, NULL, (RPC_RECV_FLAG_T)(RPC_RECV_FLAG_CTRL | RPC_RECV_FLAG_LEN)); rpc_end(thread); }
+ static INLINE void rpc_call14_out_ctrl(CLIENT_THREAD_STATE_T *thread,uint32_t id, uint32_t p0, uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4, uint32_t p5, uint32_t p6, uint32_t p7, uint32_t p8, uint32_t p9, uint32_t p10, uint32_t p11, uint32_t p12, void *out) { rpc_begin(thread); RPC_CALL(thread, id, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); rpc_recv(thread, out, NULL, (RPC_RECV_FLAG_T)(RPC_RECV_FLAG_CTRL | RPC_RECV_FLAG_LEN)); rpc_end(thread); }
+ static INLINE void rpc_call15_out_ctrl(CLIENT_THREAD_STATE_T *thread,uint32_t id, uint32_t p0, uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4, uint32_t p5, uint32_t p6, uint32_t p7, uint32_t p8, uint32_t p9, uint32_t p10, uint32_t p11, uint32_t p12, uint32_t p13, void *out) { rpc_begin(thread); RPC_CALL(thread, id, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); rpc_recv(thread, out, NULL, (RPC_RECV_FLAG_T)(RPC_RECV_FLAG_CTRL | RPC_RECV_FLAG_LEN)); rpc_end(thread); }
++static INLINE void rpc_call16_out_ctrl(CLIENT_THREAD_STATE_T *thread,uint32_t id, uint32_t p0, uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4, uint32_t p5, uint32_t p6, uint32_t p7, uint32_t p8, uint32_t p9, uint32_t p10, uint32_t p11, uint32_t p12, uint32_t p13, uint32_t p14, void *out) { rpc_begin(thread); RPC_CALL(thread, id, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14); rpc_recv(thread, out, NULL, (RPC_RECV_FLAG_T)(RPC_RECV_FLAG_CTRL | RPC_RECV_FLAG_LEN)); rpc_end(thread); }
+ #endif
+
+ #define RPC_CALL1_OUT_CTRL(fn, thread, id, out) rpc_call1_out_ctrl(thread, id, out)
+@@ -700,6 +701,7 @@ static INLINE void rpc_call18(CLIENT_THREAD_STATE_T *thread, uint32_t id, uint32
+ #define RPC_CALL13_OUT_CTRL(fn, thread, id, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, out) rpc_call13_out_ctrl(thread, id, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, out)
+ #define RPC_CALL14_OUT_CTRL(fn, thread, id, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, out) rpc_call14_out_ctrl(thread, id, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, out)
+ #define RPC_CALL15_OUT_CTRL(fn, thread, id, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, out) rpc_call15_out_ctrl(thread, id, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, out)
++#define RPC_CALL16_OUT_CTRL(fn, thread, id, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, out) rpc_call16_out_ctrl(thread, id, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, out)
+
+ # if !defined(__SYMBIAN32__) //use functions defined in khrpc.cpp
+ static INLINE uint32_t rpc_call1_out_ctrl_res(CLIENT_THREAD_STATE_T *thread,uint32_t id, void *out) { uint32_t res; rpc_begin(thread); RPC_CALL(thread, id); res = rpc_recv(thread, out, NULL, (RPC_RECV_FLAG_T)(RPC_RECV_FLAG_RES | RPC_RECV_FLAG_CTRL | RPC_RECV_FLAG_LEN)); rpc_end(thread); return res; }
+diff --git a/interface/khronos/common/khrn_int_ids.h b/interface/khronos/common/khrn_int_ids.h
+index 8378f4a..ec961e0 100644
+--- a/interface/khronos/common/khrn_int_ids.h
++++ b/interface/khronos/common/khrn_int_ids.h
+@@ -367,6 +367,7 @@
+ */
+
+ #define EGLINTCREATESURFACE_ID 0x4000
++#define EGLINTCREATESURFACE_ID_V2 0x4100
+ #define EGLINTCREATEGLES11_ID 0x4001
+ #define EGLINTCREATEGLES20_ID 0x4002
+ #define EGLINTCREATEVG_ID 0x4003
+@@ -377,6 +378,7 @@
+ #define EGLINTMAKECURRENT_ID 0x4008
+ #define EGLINTFLUSHANDWAIT_ID 0x4009
+ #define EGLINTSWAPBUFFERS_ID 0x400a
++#define EGLINTSWAPBUFFERS_ID_V2 0x410a
+ #define EGLINTSELECTMIPMAP_ID 0x400b
+ #define EGLINTFLUSH_ID 0x400c
+ #define EGLINTGETCOLORDATA_ID 0x400d
+diff --git a/interface/khronos/egl/egl_client.c b/interface/khronos/egl/egl_client.c
+index fd07eb6..e902d19 100644
+--- a/interface/khronos/egl/egl_client.c
++++ b/interface/khronos/egl/egl_client.c
+@@ -162,6 +162,17 @@
+ void egl_gl_flush_callback(bool wait);
+ void egl_vg_flush_callback(bool wait);
+
++#include "interface/vmcs_host/vc_dispmanx_types.h"
++/**HACKHACK - give us the ability to inject a DispmanX
++ * resource handle into the CreateWindowSurface and
++ * SwapBuffers calls */
++static DISPMANX_RESOURCE_HANDLE_T next_resource_handle;
++
++EGLAPI EGLBoolean EGLAPIENTRY eglSetNextResourceHandle(DISPMANX_RESOURCE_HANDLE_T handle)
++{
++ next_resource_handle = handle;
++}
++
+ /*
+ TODO: do an RPC call to make sure the Khronos vll is loaded (and that it stays loaded until eglTerminate)
+ Also affects global image (and possibly others?)
+@@ -643,7 +654,8 @@ EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig c
+ false,
+ EGL_NO_TEXTURE,
+ EGL_NO_TEXTURE,
+- 0, 0);
++ 0, 0,
++ next_resource_handle);
+
+ if (surface) {
+ if (khrn_pointer_map_insert(&process->surfaces, process->next_surface, surface)) {
+@@ -888,7 +900,7 @@ EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig
+ mipmap_texture,
+ texture_format,
+ texture_target,
+- 0, 0);
++ 0, 0, 0);
+
+ if (surface) {
+ if (khrn_pointer_map_insert(&process->surfaces, process->next_surface, surface)) {
+@@ -1030,7 +1042,7 @@ EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig c
+ false,
+ EGL_NO_TEXTURE,
+ EGL_NO_TEXTURE,
+- pixmap, ((server_handle[0] == 0) && (server_handle[1] == (uint32_t)(-1))) ? NULL : server_handle);
++ pixmap, ((server_handle[0] == 0) && (server_handle[1] == (uint32_t)(-1))) ? NULL : server_handle, 0);
+
+ if (surface) {
+ if (khrn_pointer_map_insert(&process->surfaces, process->next_surface, surface)) {
+@@ -2302,6 +2314,18 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surf)
+
+ vcos_log_trace("eglSwapBuffers server call");
+
++ if (next_resource_handle)
++ RPC_CALL7(eglIntSwapBuffers_impl,
++ thread,
++ EGLINTSWAPBUFFERS_ID_V2,
++ RPC_UINT(surface->serverbuffer),
++ RPC_UINT(surface->width),
++ RPC_UINT(surface->height),
++ RPC_UINT(surface->internal_handle),
++ RPC_UINT(surface->swap_behavior == EGL_BUFFER_PRESERVED ? 1 : 0),
++ RPC_UINT(khrn_platform_get_window_position(surface->win)),
++ RPC_INT(next_resource_handle));
++ else
+ RPC_CALL6(eglIntSwapBuffers_impl,
+ thread,
+ EGLINTSWAPBUFFERS_ID,
+diff --git a/interface/khronos/egl/egl_client_surface.c b/interface/khronos/egl/egl_client_surface.c
+index cda5943..0be56c5 100644
+--- a/interface/khronos/egl/egl_client_surface.c
++++ b/interface/khronos/egl/egl_client_surface.c
+@@ -314,7 +314,8 @@ EGL_SURFACE_T *egl_surface_create(
+ EGLenum texture_format,
+ EGLenum texture_target,
+ EGLNativePixmapType pixmap,
+- const uint32_t *pixmap_server_handle)
++ const uint32_t *pixmap_server_handle,
++ DISPMANX_RESOURCE_HANDLE_T next_resource_handle)
+ {
+ KHRN_IMAGE_FORMAT_T color;
+ KHRN_IMAGE_FORMAT_T depth;
+@@ -473,6 +474,27 @@ EGL_SURFACE_T *egl_surface_create(
+ #endif
+ uint32_t results[3];
+
++ if (next_resource_handle)
++ RPC_CALL16_OUT_CTRL(eglIntCreateSurface_impl,
++ thread,
++ EGLINTCREATESURFACE_ID_V2,
++ RPC_UINT(serverwin),
++ RPC_UINT(buffers),
++ RPC_UINT(width),
++ RPC_UINT(height),
++ RPC_UINT(color),
++ RPC_UINT(depth),
++ RPC_UINT(mask),
++ RPC_UINT(multi),
++ RPC_UINT(largest_pbuffer),
++ RPC_UINT(mipmap_texture),
++ RPC_UINT(config_depth_bits),
++ RPC_UINT(config_stencil_bits),
++ RPC_UINT(sem_name),
++ RPC_UINT(type),
++ RPC_INT(next_resource_handle),
++ results);
++ else
+ RPC_CALL15_OUT_CTRL(eglIntCreateSurface_impl,
+ thread,
+ EGLINTCREATESURFACE_ID,
+diff --git a/interface/khronos/egl/egl_client_surface.h b/interface/khronos/egl/egl_client_surface.h
+index c99d44c..b5bf70a 100644
+--- a/interface/khronos/egl/egl_client_surface.h
++++ b/interface/khronos/egl/egl_client_surface.h
+@@ -322,7 +322,8 @@ extern EGL_SURFACE_T *egl_surface_create(
+ EGLenum texture_format,
+ EGLenum texture_target,
+ EGLNativePixmapType pixmap,
+- const uint32_t *pixmap_server_handle);
++ const uint32_t *pixmap_server_handle,
++ DISPMANX_RESOURCE_HANDLE_T next_resource_handle);
+ extern EGL_SURFACE_T *egl_surface_from_vg_image(
+ VGImage vg_handle,
+ EGLSurface name,
+diff --git a/interface/khronos/egl/egl_int_impl.h b/interface/khronos/egl/egl_int_impl.h
+index 8a5734c..51b3580 100644
+--- a/interface/khronos/egl/egl_int_impl.h
++++ b/interface/khronos/egl/egl_int_impl.h
+@@ -56,7 +56,8 @@
+ uint32_t config_stencil_bits,
+ uint32_t sem,
+ uint32_t type,
+- uint32_t *results))
++ uint32_t *results,
++ DISPMANX_RESOURCE_HANDLE_T next_resource_handle))
+
+ FN(int, eglIntCreatePbufferFromVGImage_impl, (
+ VGImage vg_handle,
+@@ -110,7 +111,7 @@
+ FN(int, eglIntFlushAndWait_impl, (uint32_t flushgl, uint32_t flushvg))
+ FN(void, eglIntFlush_impl, (uint32_t flushgl, uint32_t flushvg))
+
+-FN(void, eglIntSwapBuffers_impl, (EGL_SURFACE_ID_T s, uint32_t width, uint32_t height, uint32_t handle, uint32_t preserve, uint32_t position))
++FN(void, eglIntSwapBuffers_impl, (EGL_SURFACE_ID_T s, uint32_t width, uint32_t height, uint32_t handle, uint32_t preserve, uint32_t position, DISPMANX_RESOURCE_HANDLE_T new_back_buffer))
+ FN(void, eglIntSelectMipmap_impl, (EGL_SURFACE_ID_T s, int level))
+
+ FN(void, eglIntGetColorData_impl, (EGL_SURFACE_ID_T s, KHRN_IMAGE_FORMAT_T format, uint32_t width, uint32_t height, int32_t stride, uint32_t y_offset, void *data))
+--
+1.8.5.1
diff --git a/media-libs/raspberrypi-userland/files/raspberrypi-userland-9999-gentoo.patch b/media-libs/raspberrypi-userland/files/raspberrypi-userland-9999-gentoo.patch
new file mode 100644
index 000000000000..a5e60554cd13
--- /dev/null
+++ b/media-libs/raspberrypi-userland/files/raspberrypi-userland-9999-gentoo.patch
@@ -0,0 +1,15 @@
+--- raspberrypi-userland-9999/host_applications/linux/apps/dtoverlay/CMakeLists.txt.old 2017-02-04 19:01:38.944537134 +0100
++++ raspberrypi-userland-9999/host_applications/linux/apps/dtoverlay/CMakeLists.txt 2017-02-04 19:02:09.634401479 +0100
+@@ -22,12 +22,4 @@
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dtparam DESTINATION bin)
+
+ set(DTOVERLAY_SCRIPTS dtoverlay-pre dtoverlay-post)
+-foreach(_script ${DTOVERLAY_SCRIPTS})
+- add_custom_command(
+- TARGET dtoverlay
+- COMMAND ${CMAKE_COMMAND}
+- -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${_script}
+- ${CMAKE_BINARY_DIR}/../../bin/${_script}
+- )
+-endforeach()
+ install(PROGRAMS ${DTOVERLAY_SCRIPTS} DESTINATION bin)
diff --git a/media-libs/raspberrypi-userland/metadata.xml b/media-libs/raspberrypi-userland/metadata.xml
new file mode 100644
index 000000000000..3f36d197951a
--- /dev/null
+++ b/media-libs/raspberrypi-userland/metadata.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="person">
+ <email>chithanh@gentoo.org</email>
+ <name>Chí-Thanh Christopher Nguyễn</name>
+ </maintainer>
+ <maintainer type="person">
+ <email>tupone@gentoo.org</email>
+ <name>Tupone Alfredo</name>
+ </maintainer>
+ <upstream>
+ <remote-id type="github">raspberrypi/userland</remote-id>
+ </upstream>
+</pkgmetadata>
diff --git a/media-libs/raspberrypi-userland/raspberrypi-userland-0_pre20160424.ebuild b/media-libs/raspberrypi-userland/raspberrypi-userland-0_pre20160424.ebuild
new file mode 100644
index 000000000000..ddbbd294d3a3
--- /dev/null
+++ b/media-libs/raspberrypi-userland/raspberrypi-userland-0_pre20160424.ebuild
@@ -0,0 +1,109 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit cmake-utils
+
+DESCRIPTION="Raspberry Pi userspace tools and libraries"
+HOMEPAGE="https://github.com/raspberrypi/userland"
+
+if [[ ${PV} == 9999* ]]; then
+ inherit git-2
+ EGIT_REPO_URI="https://github.com/${PN/-//}.git"
+ SRC_URI=""
+else
+ GIT_COMMIT="dff5760"
+ SRC_URI="https://github.com/raspberrypi/userland/tarball/${GIT_COMMIT} -> ${P}.tar.gz"
+ KEYWORDS="arm"
+ S="${WORKDIR}/raspberrypi-userland-${GIT_COMMIT}"
+fi
+
+RDEPEND="
+ !media-libs/raspberrypi-userland-bin
+ wayland? ( dev-libs/wayland )"
+
+DEPEND="
+ ${RDEPEND}
+ wayland? ( virtual/pkgconfig )"
+
+IUSE="examples wayland"
+LICENSE="BSD"
+SLOT="0"
+
+# TODO:
+# * port vcfiled init script
+# * stuff is still installed to hardcoded /opt/vc location, investigate whether
+# anything else depends on it being there
+# * live ebuild
+
+src_unpack() {
+ if [[ ${PV} == 9999* ]]; then
+ git-2_src_unpack
+ else
+ default
+ fi
+}
+
+src_prepare() {
+ # init script for Debian, not useful on Gentoo
+ sed -i "/DESTINATION \/etc\/init.d/,+2d" interface/vmcs_host/linux/vcfiled/CMakeLists.txt || die
+
+ # wayland egl support
+ epatch "${FILESDIR}"/next-resource-handle.patch
+}
+
+src_install() {
+ cmake-utils_src_install
+
+ # provide OpenGL ES v1 according to https://github.com/raspberrypi/firmware/issues/78
+ dosym libGLESv2.so /opt/vc/lib/libGLESv1_CM.so
+
+ doenvd "${FILESDIR}"/04${PN}
+
+ insinto /lib/udev/rules.d
+ doins "${FILESDIR}"/92-local-vchiq-permissions.rules
+
+ # enable dynamic switching of the GL implementation
+ dodir /usr/lib/opengl
+ dosym ../../../opt/vc /usr/lib/opengl/${PN}
+
+ # tell eselect opengl that we do not have libGL
+ touch "${ED}"/opt/vc/.gles-only || die
+
+ insinto /opt/vc/lib/pkgconfig
+ doins "${FILESDIR}"/bcm_host.pc
+ doins "${FILESDIR}"/egl.pc
+ doins "${FILESDIR}"/glesv2.pc
+ if use wayland; then
+ # Missing wayland-egl version from the patch; claim 9.0 (a mesa version) for now, so gst-plugins-bad wayland-egl check is happy
+ sed -i -e 's/Version: /Version: 9.0/' "${ED}/opt/vc/lib/pkgconfig/wayland-egl.pc" || die
+ doins "${ED}"/opt/vc/lib/pkgconfig/wayland-egl.pc # Maybe move?
+ fi
+
+ # some #include instructions are wrong so we need to fix them
+ einfo "Fixing #include \"vcos_platform_types.h\""
+ for file in $(grep -l "#include \"vcos_platform_types.h\"" "${D}"/opt/vc/include/* -r); do
+ einfo " Fixing file ${file}"
+ sed -i "s%#include \"vcos_platform_types.h\"%#include \"interface/vcos/pthreads/vcos_platform_types.h\"%g" ${file} || die
+ done
+
+ einfo "Fixing #include \"vcos_platform.h\""
+ for file in $(grep -l "#include \"vcos_platform.h\"" "${D}"/opt/vc/include/* -r); do
+ einfo " Fixing file ${file}"
+ sed -i "s%#include \"vcos_platform.h\"%#include \"interface/vcos/pthreads/vcos_platform.h\"%g" ${file} || die
+ done
+
+ einfo "Fixing #include \"vchost_config.h\""
+ for file in $(grep -l "#include \"vchost_config.h\"" "${D}"/opt/vc/include/* -r); do
+ einfo " Fixing file ${file}"
+ sed -i "s%#include \"vchost_config.h\"%#include \"interface/vmcs_host/linux/vchost_config.h\"%g" ${file} || die
+ done
+
+ if use examples; then
+ dodir /usr/share/doc/${PF}/examples
+ mv "${D}"/opt/vc/src/hello_pi "${D}"/usr/share/doc/${PF}/examples/ || die
+ fi
+
+ rm -rfv "${D}"/opt/vc/src || die
+}
diff --git a/media-libs/raspberrypi-userland/raspberrypi-userland-9999.ebuild b/media-libs/raspberrypi-userland/raspberrypi-userland-9999.ebuild
new file mode 100644
index 000000000000..99b348863247
--- /dev/null
+++ b/media-libs/raspberrypi-userland/raspberrypi-userland-9999.ebuild
@@ -0,0 +1,44 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+inherit cmake-utils flag-o-matic git-r3
+
+DESCRIPTION="Raspberry Pi userspace tools and libraries"
+HOMEPAGE="https://github.com/raspberrypi/userland"
+SRC_URI=""
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS=""
+IUSE=""
+
+DEPEND=""
+RDEPEND=""
+
+EGIT_REPO_URI="https://github.com/raspberrypi/userland"
+
+PATCHES=( "${FILESDIR}"/${P}-gentoo.patch )
+
+pkg_setup() {
+ append-ldflags $(no-as-needed)
+}
+
+src_configure() {
+ local mycmakeargs=(
+ -DVMCS_INSTALL_PREFIX="/usr"
+ )
+
+ cmake-utils_src_configure
+}
+
+src_install() {
+ cmake-utils_src_install
+
+ insinto /lib/udev/rules.d
+ doins "${FILESDIR}"/92-local-vchiq-permissions.rules
+
+ dodir /usr/share/doc/${PF}
+ mv "${D}"/usr/src/hello_pi "${D}"/usr/share/doc/${PF}/
+ rmdir "${D}"/usr/src
+}