126e4beaaSAndrew GeisslerFrom 3c1566e9c3b356cfcd8327fed0e537ed978c8e78 Mon Sep 17 00:00:00 2001 21a4b7ee2SBrad BishopFrom: Tomeu Vizoso <tomeu.vizoso@collabora.com> 31a4b7ee2SBrad BishopDate: Tue, 1 Oct 2013 13:19:20 +0200 426e4beaaSAndrew GeisslerSubject: [PATCH] wayland: Add support for the Wayland winsys 51a4b7ee2SBrad Bishop 61a4b7ee2SBrad Bishop* Adds EGL_WL_bind_wayland_display extension 71a4b7ee2SBrad Bishop* Adds wayland-egl library 81a4b7ee2SBrad Bishop* Adds wl_dispmanx_buffer protocol extension 91a4b7ee2SBrad Bishop 101a4b7ee2SBrad BishopTODO: Check that platform_get_dimensions() returning swapchain_count == 1 is correct 111a4b7ee2SBrad Bishop 121a4b7ee2SBrad BishopTODO: Remove the requirement of passing a valid DispmanX element handle to 131a4b7ee2SBrad Bishopthe SwapBuffers and CreateSurface RPC calls. This will remove the need to open 141a4b7ee2SBrad Bishopa DispmanX display from the clients. 151a4b7ee2SBrad Bishop 161a4b7ee2SBrad BishopTODO: wl_dispmanx_server_buffer should probably be defined in a 171a4b7ee2SBrad Bishopprivate header that can be included from EGL and vc_* instead of in 181a4b7ee2SBrad Bishopvc_vchi_dispmanx.h 191a4b7ee2SBrad Bishop 201a4b7ee2SBrad BishopSigned-off-by: Khem Raj <raj.khem@gmail.com> 211a4b7ee2SBrad Bishop--- 22*520786ccSPatrick WilliamsUpstream-Status: Pending 23*520786ccSPatrick Williams 241a4b7ee2SBrad Bishop .gitignore | 1 + 251a4b7ee2SBrad Bishop CMakeLists.txt | 11 + 261a4b7ee2SBrad Bishop README.md | 4 + 271a4b7ee2SBrad Bishop buildme | 10 +- 285d59ec7eSAndrew Geissler .../linux/apps/raspicam/CMakeLists.txt | 2 +- 291a4b7ee2SBrad Bishop interface/khronos/CMakeLists.txt | 54 +++- 301a4b7ee2SBrad Bishop interface/khronos/common/khrn_client.c | 15 ++ 311a4b7ee2SBrad Bishop interface/khronos/common/khrn_client.h | 10 + 321a4b7ee2SBrad Bishop interface/khronos/common/khrn_client_mangle.h | 3 + 331a4b7ee2SBrad Bishop .../khronos/common/khrn_client_platform.h | 8 + 341a4b7ee2SBrad Bishop .../khronos/common/khrn_client_unmangle.h | 3 + 351a4b7ee2SBrad Bishop .../common/linux/khrn_client_platform_linux.c | 115 +++++++- 361a4b7ee2SBrad Bishop interface/khronos/common/linux/khrn_wayland.c | 215 +++++++++++++++ 371a4b7ee2SBrad Bishop .../common/linux/khrn_wayland.h} | 46 +--- 381a4b7ee2SBrad Bishop interface/khronos/egl/egl_client.c | 92 +++++-- 391a4b7ee2SBrad Bishop interface/khronos/egl/egl_client_get_proc.c | 11 + 401a4b7ee2SBrad Bishop interface/khronos/egl/egl_client_surface.c | 42 ++- 411a4b7ee2SBrad Bishop interface/khronos/egl/egl_client_surface.h | 38 ++- 421a4b7ee2SBrad Bishop interface/khronos/egl/egl_int_impl.h | 2 +- 431a4b7ee2SBrad Bishop interface/khronos/ext/egl_wayland.c | 246 ++++++++++++++++++ 441a4b7ee2SBrad Bishop interface/khronos/include/EGL/eglext.h | 23 ++ 451a4b7ee2SBrad Bishop .../khronos/wayland-egl/wayland-egl-priv.h | 53 ++++ 461a4b7ee2SBrad Bishop interface/khronos/wayland-egl/wayland-egl.c | 59 +++++ 471a4b7ee2SBrad Bishop .../khronos/wayland-egl/wayland-egl.pc.in | 10 + 4826e4beaaSAndrew Geissler interface/vmcs_host/CMakeLists.txt | 13 +- 491a4b7ee2SBrad Bishop interface/vmcs_host/vc_dispmanx.h | 10 + 501a4b7ee2SBrad Bishop interface/vmcs_host/vc_vchi_dispmanx.c | 42 +++ 511a4b7ee2SBrad Bishop interface/vmcs_host/vc_vchi_dispmanx.h | 15 ++ 521a4b7ee2SBrad Bishop interface/wayland/dispmanx.xml | 123 +++++++++ 531a4b7ee2SBrad Bishop makefiles/cmake/Wayland.cmake | 72 +++++ 5426e4beaaSAndrew Geissler 30 files changed, 1253 insertions(+), 95 deletions(-) 551a4b7ee2SBrad Bishop create mode 100644 interface/khronos/common/linux/khrn_wayland.c 561a4b7ee2SBrad Bishop copy interface/{vmcs_host/vc_vchi_dispmanx.h => khronos/common/linux/khrn_wayland.h} (56%) 571a4b7ee2SBrad Bishop create mode 100644 interface/khronos/ext/egl_wayland.c 581a4b7ee2SBrad Bishop create mode 100644 interface/khronos/wayland-egl/wayland-egl-priv.h 591a4b7ee2SBrad Bishop create mode 100644 interface/khronos/wayland-egl/wayland-egl.c 601a4b7ee2SBrad Bishop create mode 100644 interface/khronos/wayland-egl/wayland-egl.pc.in 611a4b7ee2SBrad Bishop create mode 100644 interface/wayland/dispmanx.xml 621a4b7ee2SBrad Bishop create mode 100644 makefiles/cmake/Wayland.cmake 631a4b7ee2SBrad Bishop 641a4b7ee2SBrad Bishopdiff --git a/.gitignore b/.gitignore 651a4b7ee2SBrad Bishopindex 63570f1..1459436 100644 661a4b7ee2SBrad Bishop--- a/.gitignore 671a4b7ee2SBrad Bishop+++ b/.gitignore 681a4b7ee2SBrad Bishop@@ -30,3 +30,4 @@ build/ 691a4b7ee2SBrad Bishop *.pts 701a4b7ee2SBrad Bishop *.ppm 711a4b7ee2SBrad Bishop *.mkv 721a4b7ee2SBrad Bishop+*~ 731a4b7ee2SBrad Bishopdiff --git a/CMakeLists.txt b/CMakeLists.txt 745d59ec7eSAndrew Geisslerindex fe67fc8..80337b2 100644 751a4b7ee2SBrad Bishop--- a/CMakeLists.txt 761a4b7ee2SBrad Bishop+++ b/CMakeLists.txt 775d59ec7eSAndrew Geissler@@ -24,6 +24,17 @@ include(makefiles/cmake/global_settings.cmake) 781a4b7ee2SBrad Bishop include(makefiles/cmake/arm-linux.cmake) 791a4b7ee2SBrad Bishop include(makefiles/cmake/vmcs.cmake) 801a4b7ee2SBrad Bishop 811a4b7ee2SBrad Bishop+if (BUILD_WAYLAND) 821a4b7ee2SBrad Bishop+ include(makefiles/cmake/Wayland.cmake) 831a4b7ee2SBrad Bishop+ 841a4b7ee2SBrad Bishop+ # Find Wayland libraries 851a4b7ee2SBrad Bishop+ find_package(PkgConfig) 861a4b7ee2SBrad Bishop+ pkg_check_modules(WAYLAND_CLIENT wayland-client REQUIRED) 871a4b7ee2SBrad Bishop+ pkg_check_modules(WAYLAND_SERVER wayland-server REQUIRED) 881a4b7ee2SBrad Bishop+ 891a4b7ee2SBrad Bishop+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBUILD_WAYLAND") 901a4b7ee2SBrad Bishop+endif() 911a4b7ee2SBrad Bishop+ 921a4b7ee2SBrad Bishop enable_language(ASM) 931a4b7ee2SBrad Bishop 941a4b7ee2SBrad Bishop # Global include paths 951a4b7ee2SBrad Bishopdiff --git a/README.md b/README.md 9615ae2509SBrad Bishopindex 404e4d4..97a6b8f 100644 971a4b7ee2SBrad Bishop--- a/README.md 981a4b7ee2SBrad Bishop+++ b/README.md 9915ae2509SBrad Bishop@@ -8,3 +8,7 @@ https://github.com/raspberrypi/tools/tree/master/arm-bcm2708/gcc-linaro-arm-linu 10015ae2509SBrad Bishop Whilst 64-bit userspace is not officially supported, some of the libraries will work for it. To cross compile, install gcc-aarch64-linux-gnu and g++-aarch64-linux-gnu first. For both native and cross compiles, add the option ```--aarch64``` to the buildme command. 1011a4b7ee2SBrad Bishop 10219323693SBrad Bishop Note that this repository does not contain the source for the edidparser and vcdbg binaries due to licensing restrictions. 1031a4b7ee2SBrad Bishop+ 1041a4b7ee2SBrad Bishop+To build support for the Wayland winsys in EGL, execute the buildme script like this: 1051a4b7ee2SBrad Bishop+ 1061a4b7ee2SBrad Bishop+$ BUILD_WAYLAND=1 ./buildme. 1071a4b7ee2SBrad Bishopdiff --git a/buildme b/buildme 108062316f1SAndrew Geisslerindex 9e2d405..7b8c0d6 100755 1091a4b7ee2SBrad Bishop--- a/buildme 1101a4b7ee2SBrad Bishop+++ b/buildme 11115ae2509SBrad Bishop@@ -17,6 +17,10 @@ fi 1121a4b7ee2SBrad Bishop 1131a4b7ee2SBrad Bishop BUILDSUBDIR=`echo $BUILDTYPE | tr '[A-Z]' '[a-z]'`; 1141a4b7ee2SBrad Bishop 1151a4b7ee2SBrad Bishop+if [ -n "$BUILD_WAYLAND" ]; then 1161a4b7ee2SBrad Bishop+ WAYLAND_VARS="-DBUILD_WAYLAND=TRUE" 1171a4b7ee2SBrad Bishop+fi 1181a4b7ee2SBrad Bishop+ 11915ae2509SBrad Bishop if [ $ARCH = "armv6l" ] || [ $ARCH = "armv7l" ] || [ $ARCH = "aarch64" ]; then 1201a4b7ee2SBrad Bishop # Native compile on the Raspberry Pi 1211a4b7ee2SBrad Bishop mkdir -p build/raspberry/$BUILDSUBDIR 12215ae2509SBrad Bishop@@ -41,9 +45,13 @@ elif [ "$1" = "--native" ]; then 1231a4b7ee2SBrad Bishop make -j `nproc` $* 1241a4b7ee2SBrad Bishop else 1251a4b7ee2SBrad Bishop # Cross compile on a more capable machine 1261a4b7ee2SBrad Bishop+ if [ -n "$BUILD_WAYLAND" ]; then 1271a4b7ee2SBrad Bishop+ # Use wayland-scanner from the build platform 1281a4b7ee2SBrad Bishop+ WAYLAND_VARS+=" -DWAYLAND_SCANNER_EXECUTABLE:FILEPATH=/usr/bin/wayland-scanner" 1291a4b7ee2SBrad Bishop+ fi 1301a4b7ee2SBrad Bishop mkdir -p build/arm-linux/$BUILDSUBDIR 1311a4b7ee2SBrad Bishop pushd build/arm-linux/$BUILDSUBDIR 13215ae2509SBrad Bishop- cmake -DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE -DCMAKE_BUILD_TYPE=$BUILDTYPE -DARM64=$ARM64 ../../.. 13315ae2509SBrad Bishop+ cmake -DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE -DCMAKE_BUILD_TYPE=$BUILDTYPE -DARM64=$ARM64 $WAYLAND_VARS ../../.. 1341a4b7ee2SBrad Bishop make -j `nproc` 1351a4b7ee2SBrad Bishop 1361a4b7ee2SBrad Bishop if [ "$1" != "" ]; then 1371a4b7ee2SBrad Bishopdiff --git a/host_applications/linux/apps/raspicam/CMakeLists.txt b/host_applications/linux/apps/raspicam/CMakeLists.txt 1385d59ec7eSAndrew Geisslerindex eb1ef7c..5aeeb2e 100644 1391a4b7ee2SBrad Bishop--- a/host_applications/linux/apps/raspicam/CMakeLists.txt 1401a4b7ee2SBrad Bishop+++ b/host_applications/linux/apps/raspicam/CMakeLists.txt 1415d59ec7eSAndrew Geissler@@ -61,7 +61,7 @@ add_executable(raspivid ${COMMON_SOURCES} RaspiVid.c) 142062316f1SAndrew Geissler add_executable(raspividyuv ${COMMON_SOURCES} RaspiVidYUV.c) 1431a4b7ee2SBrad Bishop 1441a4b7ee2SBrad Bishop set (MMAL_LIBS mmal_core mmal_util mmal_vc_client) 145062316f1SAndrew Geissler-target_link_libraries(raspistill ${MMAL_LIBS} vcos bcm_host ${EGL_LIBS} m dl) 146062316f1SAndrew Geissler+target_link_libraries(raspistill ${MMAL_LIBS} vcos bcm_host ${EGL_LIBS} m dl ${WAYLAND_SERVER_LIBRARIES} ${WAYLAND_CLIENT_LIBRARIES}) 1475d59ec7eSAndrew Geissler target_link_libraries(raspiyuv ${MMAL_LIBS} vcos bcm_host m) 1485d59ec7eSAndrew Geissler target_link_libraries(raspivid ${MMAL_LIBS} vcos bcm_host m) 1495d59ec7eSAndrew Geissler target_link_libraries(raspividyuv ${MMAL_LIBS} vcos bcm_host m) 1501a4b7ee2SBrad Bishopdiff --git a/interface/khronos/CMakeLists.txt b/interface/khronos/CMakeLists.txt 1511a4b7ee2SBrad Bishopindex 9ad615b..95c0e11 100644 1521a4b7ee2SBrad Bishop--- a/interface/khronos/CMakeLists.txt 1531a4b7ee2SBrad Bishop+++ b/interface/khronos/CMakeLists.txt 1541a4b7ee2SBrad Bishop@@ -6,6 +6,12 @@ 1551a4b7ee2SBrad Bishop # have quite a few circular dependencies, and so the only way 1561a4b7ee2SBrad Bishop # to make it work seems to be to have everything static. 1571a4b7ee2SBrad Bishop 1581a4b7ee2SBrad Bishop+if (BUILD_WAYLAND) 1591a4b7ee2SBrad Bishop+include_directories( 1601a4b7ee2SBrad Bishop+ ${WAYLAND_SERVER_INCLUDE_DIRS} 1611a4b7ee2SBrad Bishop+) 1621a4b7ee2SBrad Bishop+endif () 1631a4b7ee2SBrad Bishop+ 1641a4b7ee2SBrad Bishop set(EGL_SOURCE 1651a4b7ee2SBrad Bishop egl/egl_client_config.c 1661a4b7ee2SBrad Bishop egl/egl_client_context.c 1671a4b7ee2SBrad Bishop@@ -55,12 +61,55 @@ set(CLIENT_SOURCE 1681a4b7ee2SBrad Bishop common/khrn_int_hash_asm.s 1691a4b7ee2SBrad Bishop common/khrn_client_cache.c) 1701a4b7ee2SBrad Bishop 1711a4b7ee2SBrad Bishop+set(EGL_LIBS 1721a4b7ee2SBrad Bishop+ khrn_client 1731a4b7ee2SBrad Bishop+ vchiq_arm 1741a4b7ee2SBrad Bishop+ vcos 1751a4b7ee2SBrad Bishop+ bcm_host) 1761a4b7ee2SBrad Bishop+ 1771a4b7ee2SBrad Bishop+if (BUILD_WAYLAND) 1781a4b7ee2SBrad Bishop+ set(EGL_SOURCE 1791a4b7ee2SBrad Bishop+ ${EGL_SOURCE} 1801a4b7ee2SBrad Bishop+ ext/egl_wayland.c 1811a4b7ee2SBrad Bishop+ common/linux/khrn_wayland.c) 1821a4b7ee2SBrad Bishop+ 1831a4b7ee2SBrad Bishop+ set(EGL_LIBS 1841a4b7ee2SBrad Bishop+ ${EGL_LIBS} 1851a4b7ee2SBrad Bishop+ wayland-client 1861a4b7ee2SBrad Bishop+ wayland-server) 1871a4b7ee2SBrad Bishop+ 1881a4b7ee2SBrad Bishop+ set(WAYLAND_EGL_SOURCE 1891a4b7ee2SBrad Bishop+ wayland-egl/wayland-egl.c) 1901a4b7ee2SBrad Bishop+ 1911a4b7ee2SBrad Bishop+ wayland_add_protocol_server( 1921a4b7ee2SBrad Bishop+ EGL_SOURCE 1931a4b7ee2SBrad Bishop+ ../../interface/wayland/dispmanx.xml 1941a4b7ee2SBrad Bishop+ dispmanx 1951a4b7ee2SBrad Bishop+ ) 1961a4b7ee2SBrad Bishop+ 1971a4b7ee2SBrad Bishop+ wayland_add_protocol_client( 1981a4b7ee2SBrad Bishop+ EGL_SOURCE 1991a4b7ee2SBrad Bishop+ ../../interface/wayland/dispmanx.xml 2001a4b7ee2SBrad Bishop+ dispmanx 2011a4b7ee2SBrad Bishop+ ) 2021a4b7ee2SBrad Bishop+ 2031a4b7ee2SBrad Bishop+ add_library(wayland-egl ${SHARED} ${WAYLAND_EGL_SOURCE}) 2041a4b7ee2SBrad Bishop+ install(TARGETS wayland-egl DESTINATION lib) 2051a4b7ee2SBrad Bishop+ 2061a4b7ee2SBrad Bishop+ configure_file ("wayland-egl/wayland-egl.pc.in" "wayland-egl/wayland-egl.pc" @ONLY) 2071a4b7ee2SBrad Bishop+ install (FILES "${CMAKE_CURRENT_BINARY_DIR}/wayland-egl/wayland-egl.pc" 2081a4b7ee2SBrad Bishop+ DESTINATION lib/pkgconfig) 2091a4b7ee2SBrad Bishop+endif () 2101a4b7ee2SBrad Bishop+ 2111a4b7ee2SBrad Bishop add_library(EGL ${SHARED} ${EGL_SOURCE}) 2121a4b7ee2SBrad Bishop add_library(GLESv2 ${SHARED} ${GLES_SOURCE}) 2131a4b7ee2SBrad Bishop add_library(OpenVG ${SHARED} ${VG_SOURCE}) 2141a4b7ee2SBrad Bishop add_library(WFC ${SHARED} ${WFC_SOURCE}) 2151a4b7ee2SBrad Bishop add_library(khrn_client ${CLIENT_SOURCE}) 2161a4b7ee2SBrad Bishop 2171a4b7ee2SBrad Bishop+set_target_properties(EGL PROPERTIES SOVERSION 1 VERSION 1.0.0) 2181a4b7ee2SBrad Bishop+set_target_properties(GLESv2 PROPERTIES SOVERSION 2 VERSION 2.0.0) 2191a4b7ee2SBrad Bishop+ 2201a4b7ee2SBrad Bishop # TODO do we need EGL_static and GLESv2_static now that khrn_static exists? 2211a4b7ee2SBrad Bishop add_library(EGL_static STATIC ${EGL_SOURCE}) 2221a4b7ee2SBrad Bishop add_library(GLESv2_static STATIC ${GLES_SOURCE}) 2231a4b7ee2SBrad Bishop@@ -72,8 +121,7 @@ include_directories (../../host_applications/linux/libs/sm ) 2241a4b7ee2SBrad Bishop set(VCSM_LIBS vcsm) 2251a4b7ee2SBrad Bishop add_definitions(-DKHRONOS_HAVE_VCSM) 2261a4b7ee2SBrad Bishop endif() 2271a4b7ee2SBrad Bishop- 2281a4b7ee2SBrad Bishop-target_link_libraries(EGL khrn_client vchiq_arm vcos bcm_host ${VCSM_LIBS} -lm) 2291a4b7ee2SBrad Bishop+target_link_libraries(EGL ${EGL_LIBS} ${VCSM_LIBS} -lm) 2301a4b7ee2SBrad Bishop target_link_libraries(GLESv2 EGL khrn_client vcos) 2311a4b7ee2SBrad Bishop target_link_libraries(WFC EGL) 2321a4b7ee2SBrad Bishop target_link_libraries(OpenVG EGL) 2331a4b7ee2SBrad Bishop@@ -87,7 +135,7 @@ add_library(brcmGLESv2 ${SHARED} ${GLES_SOURCE}) 2341a4b7ee2SBrad Bishop add_library(brcmOpenVG ${SHARED} ${VG_SOURCE}) 2351a4b7ee2SBrad Bishop add_library(brcmWFC ${SHARED} ${WFC_SOURCE}) 2361a4b7ee2SBrad Bishop 2371a4b7ee2SBrad Bishop-target_link_libraries(brcmEGL khrn_client vchiq_arm vcos bcm_host ${VCSM_LIBS} -lm) 2381a4b7ee2SBrad Bishop+target_link_libraries(brcmEGL ${EGL_LIBS} ${VCSM_LIBS} -lm) 2391a4b7ee2SBrad Bishop target_link_libraries(brcmGLESv2 brcmEGL khrn_client vcos) 2401a4b7ee2SBrad Bishop target_link_libraries(brcmWFC brcmEGL) 2411a4b7ee2SBrad Bishop target_link_libraries(brcmOpenVG brcmEGL) 2421a4b7ee2SBrad Bishopdiff --git a/interface/khronos/common/khrn_client.c b/interface/khronos/common/khrn_client.c 2431a4b7ee2SBrad Bishopindex ef4babd..d7e798e 100644 2441a4b7ee2SBrad Bishop--- a/interface/khronos/common/khrn_client.c 2451a4b7ee2SBrad Bishop+++ b/interface/khronos/common/khrn_client.c 2461a4b7ee2SBrad Bishop@@ -54,6 +54,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2471a4b7ee2SBrad Bishop #include "applications/vmcs/khronos/khronos_server.h" 2481a4b7ee2SBrad Bishop #endif 2491a4b7ee2SBrad Bishop 2501a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 2511a4b7ee2SBrad Bishop+#include "interface/khronos/common/linux/khrn_wayland.h" 2521a4b7ee2SBrad Bishop+#endif 2531a4b7ee2SBrad Bishop+ 2541a4b7ee2SBrad Bishop VCOS_LOG_CAT_T khrn_client_log = VCOS_LOG_INIT("khrn_client", VCOS_LOG_WARN); 2551a4b7ee2SBrad Bishop 2561a4b7ee2SBrad Bishop /* 2571a4b7ee2SBrad Bishop@@ -142,6 +146,10 @@ void client_try_unload_server(CLIENT_PROCESS_STATE_T *process) 2581a4b7ee2SBrad Bishop bool client_process_state_init(CLIENT_PROCESS_STATE_T *process) 2591a4b7ee2SBrad Bishop { 2601a4b7ee2SBrad Bishop if (!process->inited) { 2611a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 2621a4b7ee2SBrad Bishop+ process->wl_global = NULL; 2631a4b7ee2SBrad Bishop+#endif 2641a4b7ee2SBrad Bishop+ 2651a4b7ee2SBrad Bishop if (!khrn_pointer_map_init(&process->contexts, 64)) 2661a4b7ee2SBrad Bishop return false; 2671a4b7ee2SBrad Bishop 2681a4b7ee2SBrad Bishop@@ -194,6 +202,13 @@ bool client_process_state_init(CLIENT_PROCESS_STATE_T *process) 2691a4b7ee2SBrad Bishop } 2701a4b7ee2SBrad Bishop #endif 2711a4b7ee2SBrad Bishop 2721a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 2731a4b7ee2SBrad Bishop+ struct wl_display *wl_display = khrn_platform_get_wl_display(); 2741a4b7ee2SBrad Bishop+ if (wl_display) 2751a4b7ee2SBrad Bishop+ if (!init_process_wayland(process)) 2761a4b7ee2SBrad Bishop+ return false; 2771a4b7ee2SBrad Bishop+#endif 2781a4b7ee2SBrad Bishop+ 2791a4b7ee2SBrad Bishop process->inited = true; 2801a4b7ee2SBrad Bishop } 2811a4b7ee2SBrad Bishop 2821a4b7ee2SBrad Bishopdiff --git a/interface/khronos/common/khrn_client.h b/interface/khronos/common/khrn_client.h 2831a4b7ee2SBrad Bishopindex 804039b..615f7b4 100644 2841a4b7ee2SBrad Bishop--- a/interface/khronos/common/khrn_client.h 2851a4b7ee2SBrad Bishop+++ b/interface/khronos/common/khrn_client.h 2861a4b7ee2SBrad Bishop@@ -310,6 +310,16 @@ struct CLIENT_PROCESS_STATE { 2871a4b7ee2SBrad Bishop #ifdef RPC_LIBRARY 2881a4b7ee2SBrad Bishop KHRONOS_SERVER_CONNECTION_T khrn_connection; 2891a4b7ee2SBrad Bishop #endif 2901a4b7ee2SBrad Bishop+ 2911a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 2921a4b7ee2SBrad Bishop+ /* Client-side Wayland state */ 2931a4b7ee2SBrad Bishop+ struct wl_registry *wl_registry; 2941a4b7ee2SBrad Bishop+ struct wl_dispmanx *wl_dispmanx; 2951a4b7ee2SBrad Bishop+ struct wl_event_queue *wl_queue; 2961a4b7ee2SBrad Bishop+ 2971a4b7ee2SBrad Bishop+ /* Compositor-side Wayland state */ 2981a4b7ee2SBrad Bishop+ struct wl_global *wl_global; 2991a4b7ee2SBrad Bishop+#endif 3001a4b7ee2SBrad Bishop }; 3011a4b7ee2SBrad Bishop 3021a4b7ee2SBrad Bishop extern bool client_process_state_init(CLIENT_PROCESS_STATE_T *process); 3031a4b7ee2SBrad Bishopdiff --git a/interface/khronos/common/khrn_client_mangle.h b/interface/khronos/common/khrn_client_mangle.h 3041a4b7ee2SBrad Bishopindex b3c04f4..b7b21c5 100644 3051a4b7ee2SBrad Bishop--- a/interface/khronos/common/khrn_client_mangle.h 3061a4b7ee2SBrad Bishop+++ b/interface/khronos/common/khrn_client_mangle.h 3071a4b7ee2SBrad Bishop@@ -83,6 +83,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3081a4b7ee2SBrad Bishop #define eglReleaseGlobalImageBRCM mangled_eglReleaseGlobalImageBRCM 3091a4b7ee2SBrad Bishop #define eglInitGlobalImageBRCM mangled_eglInitGlobalImageBRCM 3101a4b7ee2SBrad Bishop #define eglTermGlobalImageBRCM mangled_eglTermGlobalImageBRCM 3111a4b7ee2SBrad Bishop+#define eglBindWaylandDisplayWL mangled_eglBindWaylandDisplayWL 3121a4b7ee2SBrad Bishop+#define eglUnbindWaylandDisplayWL mangled_eglUnbindWaylandDisplayWL 3131a4b7ee2SBrad Bishop+#define eglQueryWaylandBufferWL mangled_eglQueryWaylandBufferWL 3141a4b7ee2SBrad Bishop 3151a4b7ee2SBrad Bishop /* OpenGL ES 1.1 and 2.0 functions */ 3161a4b7ee2SBrad Bishop 3171a4b7ee2SBrad Bishopdiff --git a/interface/khronos/common/khrn_client_platform.h b/interface/khronos/common/khrn_client_platform.h 3181a4b7ee2SBrad Bishopindex 1c9da3a..715c67e 100644 3191a4b7ee2SBrad Bishop--- a/interface/khronos/common/khrn_client_platform.h 3201a4b7ee2SBrad Bishop+++ b/interface/khronos/common/khrn_client_platform.h 3211a4b7ee2SBrad Bishop@@ -48,6 +48,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3221a4b7ee2SBrad Bishop #include "interface/khronos/common/vcos/khrn_client_platform_filler_vcos.h" 3231a4b7ee2SBrad Bishop #endif 3241a4b7ee2SBrad Bishop 3251a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 3261a4b7ee2SBrad Bishop+#include <wayland-client.h> 3271a4b7ee2SBrad Bishop+#endif 3281a4b7ee2SBrad Bishop+ 3291a4b7ee2SBrad Bishop #ifdef __cplusplus 3301a4b7ee2SBrad Bishop extern "C" { 3311a4b7ee2SBrad Bishop #endif 3321a4b7ee2SBrad Bishop@@ -328,4 +332,8 @@ typedef struct 3331a4b7ee2SBrad Bishop 3341a4b7ee2SBrad Bishop void *platform_wfc_bounce_thread(void *param); 3351a4b7ee2SBrad Bishop 3361a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 3371a4b7ee2SBrad Bishop+struct wl_display *khrn_platform_get_wl_display(); 3381a4b7ee2SBrad Bishop+#endif 3391a4b7ee2SBrad Bishop+ 3401a4b7ee2SBrad Bishop #endif // KHRN_CLIENT_PLATFORM_H 3411a4b7ee2SBrad Bishopdiff --git a/interface/khronos/common/khrn_client_unmangle.h b/interface/khronos/common/khrn_client_unmangle.h 3421a4b7ee2SBrad Bishopindex 4f3ce49..84f6ec0 100644 3431a4b7ee2SBrad Bishop--- a/interface/khronos/common/khrn_client_unmangle.h 3441a4b7ee2SBrad Bishop+++ b/interface/khronos/common/khrn_client_unmangle.h 3451a4b7ee2SBrad Bishop@@ -83,6 +83,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3461a4b7ee2SBrad Bishop #undef eglReleaseGlobalImageBRCM 3471a4b7ee2SBrad Bishop #undef eglInitGlobalImageBRCM 3481a4b7ee2SBrad Bishop #undef eglTermGlobalImageBRCM 3491a4b7ee2SBrad Bishop+#undef eglBindWaylandDisplayWL 3501a4b7ee2SBrad Bishop+#undef eglUnbindWaylandDisplayWL 3511a4b7ee2SBrad Bishop+#undef eglQueryWaylandBufferWL 3521a4b7ee2SBrad Bishop 3531a4b7ee2SBrad Bishop /* OpenGL ES 1.1 and 2.0 functions */ 3541a4b7ee2SBrad Bishop 3551a4b7ee2SBrad Bishopdiff --git a/interface/khronos/common/linux/khrn_client_platform_linux.c b/interface/khronos/common/linux/khrn_client_platform_linux.c 3561a4b7ee2SBrad Bishopindex 710d20f..50d60a6 100644 3571a4b7ee2SBrad Bishop--- a/interface/khronos/common/linux/khrn_client_platform_linux.c 3581a4b7ee2SBrad Bishop+++ b/interface/khronos/common/linux/khrn_client_platform_linux.c 3591a4b7ee2SBrad Bishop@@ -37,6 +37,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3601a4b7ee2SBrad Bishop #include "X11/Xlib.h" 3611a4b7ee2SBrad Bishop #endif 3621a4b7ee2SBrad Bishop 3631a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 3641a4b7ee2SBrad Bishop+#include <wayland-client.h> 3651a4b7ee2SBrad Bishop+#include "interface/khronos/wayland-egl/wayland-egl-priv.h" 3661a4b7ee2SBrad Bishop+#endif 3671a4b7ee2SBrad Bishop+ 3681a4b7ee2SBrad Bishop extern VCOS_LOG_CAT_T khrn_client_log; 3691a4b7ee2SBrad Bishop 3701a4b7ee2SBrad Bishop extern void vc_vchi_khronos_init(); 3711a4b7ee2SBrad Bishop@@ -464,13 +469,36 @@ EGLDisplay khrn_platform_set_display_id(EGLNativeDisplayType display_id) 3721a4b7ee2SBrad Bishop return EGL_NO_DISPLAY; 3731a4b7ee2SBrad Bishop } 3741a4b7ee2SBrad Bishop #else 3751a4b7ee2SBrad Bishop+ 3761a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 3771a4b7ee2SBrad Bishop+static struct wl_display *hacky_display = NULL; 3781a4b7ee2SBrad Bishop+#endif 3791a4b7ee2SBrad Bishop+ 3801a4b7ee2SBrad Bishop EGLDisplay khrn_platform_set_display_id(EGLNativeDisplayType display_id) 3811a4b7ee2SBrad Bishop { 3821a4b7ee2SBrad Bishop if (display_id == EGL_DEFAULT_DISPLAY) 3831a4b7ee2SBrad Bishop return (EGLDisplay)1; 3841a4b7ee2SBrad Bishop- else 3851a4b7ee2SBrad Bishop- return EGL_NO_DISPLAY; 3861a4b7ee2SBrad Bishop+ else { 3871a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 3881a4b7ee2SBrad Bishop+ void *first_pointer = *(void **) display_id; 3891a4b7ee2SBrad Bishop+ 3901a4b7ee2SBrad Bishop+ /* wl_display is a wl_proxy, which is a wl_object. 3911a4b7ee2SBrad Bishop+ * wl_object's first element points to the interfacetype. */ 3921a4b7ee2SBrad Bishop+ if (first_pointer == &wl_display_interface) { 3931a4b7ee2SBrad Bishop+ hacky_display = (struct wl_display*)display_id; 3941a4b7ee2SBrad Bishop+ return (EGLDisplay)1; 3951a4b7ee2SBrad Bishop+ } else 3961a4b7ee2SBrad Bishop+#endif 3971a4b7ee2SBrad Bishop+ return EGL_NO_DISPLAY; 3981a4b7ee2SBrad Bishop+ } 3991a4b7ee2SBrad Bishop } 4001a4b7ee2SBrad Bishop+ 4011a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 4021a4b7ee2SBrad Bishop+struct wl_display *khrn_platform_get_wl_display() 4031a4b7ee2SBrad Bishop+{ 4041a4b7ee2SBrad Bishop+ return hacky_display; 4051a4b7ee2SBrad Bishop+} 4061a4b7ee2SBrad Bishop+#endif 4071a4b7ee2SBrad Bishop #endif 4081a4b7ee2SBrad Bishop 4091a4b7ee2SBrad Bishop #ifdef WANT_X 4101a4b7ee2SBrad Bishop@@ -805,22 +833,81 @@ static EGL_DISPMANX_WINDOW_T *check_default(EGLNativeWindowType win) 4111a4b7ee2SBrad Bishop void platform_get_dimensions(EGLDisplay dpy, EGLNativeWindowType win, 4121a4b7ee2SBrad Bishop uint32_t *width, uint32_t *height, uint32_t *swapchain_count) 4131a4b7ee2SBrad Bishop { 4141a4b7ee2SBrad Bishop- EGL_DISPMANX_WINDOW_T *dwin = check_default(win); 4151a4b7ee2SBrad Bishop- vcos_assert(dwin); 4161a4b7ee2SBrad Bishop- vcos_assert(dwin->width < 1<<16); // sanity check 4171a4b7ee2SBrad Bishop- vcos_assert(dwin->height < 1<<16); // sanity check 4181a4b7ee2SBrad Bishop- *width = dwin->width; 4191a4b7ee2SBrad Bishop- *height = dwin->height; 4201a4b7ee2SBrad Bishop- *swapchain_count = 0; 4211a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 4221a4b7ee2SBrad Bishop+ if(khrn_platform_get_wl_display()) { 4231a4b7ee2SBrad Bishop+ struct wl_egl_window *wl_egl_window = (struct wl_egl_window*)win; 4241a4b7ee2SBrad Bishop+ *width = wl_egl_window->width; 4251a4b7ee2SBrad Bishop+ *height = wl_egl_window->height; 4261a4b7ee2SBrad Bishop+ /* This seems to be used for sync'ing with the VC on buffer creation, but 4271a4b7ee2SBrad Bishop+ we are managing them on the CPU side */ 4281a4b7ee2SBrad Bishop+ *swapchain_count = 1; 4291a4b7ee2SBrad Bishop+ } else { 4301a4b7ee2SBrad Bishop+#endif 4311a4b7ee2SBrad Bishop+ EGL_DISPMANX_WINDOW_T *dwin = check_default(win); 4321a4b7ee2SBrad Bishop+ vcos_assert(dwin); 4331a4b7ee2SBrad Bishop+ vcos_assert(dwin->width < 1<<16); // sanity check 4341a4b7ee2SBrad Bishop+ vcos_assert(dwin->height < 1<<16); // sanity check 4351a4b7ee2SBrad Bishop+ *width = dwin->width; 4361a4b7ee2SBrad Bishop+ *height = dwin->height; 4371a4b7ee2SBrad Bishop+ *swapchain_count = 0; 4381a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 4391a4b7ee2SBrad Bishop+ } 4401a4b7ee2SBrad Bishop+#endif 4411a4b7ee2SBrad Bishop } 4421a4b7ee2SBrad Bishop 4431a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 4441a4b7ee2SBrad Bishop+static DISPMANX_ELEMENT_HANDLE_T create_dummy_element() 4451a4b7ee2SBrad Bishop+{ 4461a4b7ee2SBrad Bishop+ DISPMANX_DISPLAY_HANDLE_T display = vc_dispmanx_display_open(0); 4471a4b7ee2SBrad Bishop+ DISPMANX_UPDATE_HANDLE_T update = vc_dispmanx_update_start(0); 4481a4b7ee2SBrad Bishop+ DISPMANX_ELEMENT_HANDLE_T element; 4491a4b7ee2SBrad Bishop+ VC_DISPMANX_ALPHA_T alpha = {DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS, 255, 0}; 4501a4b7ee2SBrad Bishop+ VC_RECT_T src_rect; 4511a4b7ee2SBrad Bishop+ VC_RECT_T dst_rect; 4521a4b7ee2SBrad Bishop+ 4531a4b7ee2SBrad Bishop+ src_rect.x = 0; 4541a4b7ee2SBrad Bishop+ src_rect.y = 0; 4551a4b7ee2SBrad Bishop+ src_rect.width = 1 << 16; 4561a4b7ee2SBrad Bishop+ src_rect.height = 1 << 16; 4571a4b7ee2SBrad Bishop+ 4581a4b7ee2SBrad Bishop+ dst_rect.x = 0; 4591a4b7ee2SBrad Bishop+ dst_rect.y = 0; 4601a4b7ee2SBrad Bishop+ dst_rect.width = 1; 4611a4b7ee2SBrad Bishop+ dst_rect.height = 1; 4621a4b7ee2SBrad Bishop+ 4631a4b7ee2SBrad Bishop+ element = vc_dispmanx_element_add(update, display, 0/*layer*/, &dst_rect, 4641a4b7ee2SBrad Bishop+ 0/*src*/, &src_rect, 4651a4b7ee2SBrad Bishop+ DISPMANX_PROTECTION_NONE, &alpha, 4661a4b7ee2SBrad Bishop+ 0/*clamp*/, 0/*transform*/); 4671a4b7ee2SBrad Bishop+ 4681a4b7ee2SBrad Bishop+ vc_dispmanx_update_submit_sync(update); 4691a4b7ee2SBrad Bishop+ 4701a4b7ee2SBrad Bishop+ vc_dispmanx_display_close(display); 4711a4b7ee2SBrad Bishop+ 4721a4b7ee2SBrad Bishop+ return element; 4731a4b7ee2SBrad Bishop+} 4741a4b7ee2SBrad Bishop+#endif 4751a4b7ee2SBrad Bishop+ 4761a4b7ee2SBrad Bishop uint32_t platform_get_handle(EGLDisplay dpy, EGLNativeWindowType win) 4771a4b7ee2SBrad Bishop { 4781a4b7ee2SBrad Bishop- EGL_DISPMANX_WINDOW_T *dwin = check_default(win); 4791a4b7ee2SBrad Bishop- vcos_assert(dwin); 4801a4b7ee2SBrad Bishop- vcos_assert(dwin->width < 1<<16); // sanity check 4811a4b7ee2SBrad Bishop- vcos_assert(dwin->height < 1<<16); // sanity check 4821a4b7ee2SBrad Bishop- return dwin->element; 4831a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 4841a4b7ee2SBrad Bishop+ if(khrn_platform_get_wl_display()) { 4851a4b7ee2SBrad Bishop+ struct wl_egl_window *wl_egl_window = (struct wl_egl_window*)win; 4861a4b7ee2SBrad Bishop+ 4871a4b7ee2SBrad Bishop+ if (wl_egl_window->dummy_element == PLATFORM_WIN_NONE) 4881a4b7ee2SBrad Bishop+ wl_egl_window->dummy_element = create_dummy_element(); 4891a4b7ee2SBrad Bishop+ 4901a4b7ee2SBrad Bishop+ return wl_egl_window->dummy_element; 4911a4b7ee2SBrad Bishop+ } else { 4921a4b7ee2SBrad Bishop+#endif 4931a4b7ee2SBrad Bishop+ EGL_DISPMANX_WINDOW_T *dwin = check_default(win); 4941a4b7ee2SBrad Bishop+ vcos_assert(dwin); 4951a4b7ee2SBrad Bishop+ vcos_assert(dwin->width < 1<<16); // sanity check 4961a4b7ee2SBrad Bishop+ vcos_assert(dwin->height < 1<<16); // sanity check 4971a4b7ee2SBrad Bishop+ return dwin->element; 4981a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 4991a4b7ee2SBrad Bishop+ } 5001a4b7ee2SBrad Bishop+#endif 5011a4b7ee2SBrad Bishop } 5021a4b7ee2SBrad Bishop 5031a4b7ee2SBrad Bishop #endif 5041a4b7ee2SBrad Bishopdiff --git a/interface/khronos/common/linux/khrn_wayland.c b/interface/khronos/common/linux/khrn_wayland.c 5051a4b7ee2SBrad Bishopnew file mode 100644 5061a4b7ee2SBrad Bishopindex 0000000..0e1b9e7 5071a4b7ee2SBrad Bishop--- /dev/null 5081a4b7ee2SBrad Bishop+++ b/interface/khronos/common/linux/khrn_wayland.c 5091a4b7ee2SBrad Bishop@@ -0,0 +1,215 @@ 5101a4b7ee2SBrad Bishop+/* 5111a4b7ee2SBrad Bishop+Copyright (c) 2013, Raspberry Pi Foundation 5121a4b7ee2SBrad Bishop+All rights reserved. 5131a4b7ee2SBrad Bishop+ 5141a4b7ee2SBrad Bishop+Redistribution and use in source and binary forms, with or without 5151a4b7ee2SBrad Bishop+modification, are permitted provided that the following conditions are met: 5161a4b7ee2SBrad Bishop+ * Redistributions of source code must retain the above copyright 5171a4b7ee2SBrad Bishop+ notice, this list of conditions and the following disclaimer. 5181a4b7ee2SBrad Bishop+ * Redistributions in binary form must reproduce the above copyright 5191a4b7ee2SBrad Bishop+ notice, this list of conditions and the following disclaimer in the 5201a4b7ee2SBrad Bishop+ documentation and/or other materials provided with the distribution. 5211a4b7ee2SBrad Bishop+ * Neither the name of the copyright holder nor the 5221a4b7ee2SBrad Bishop+ names of its contributors may be used to endorse or promote products 5231a4b7ee2SBrad Bishop+ derived from this software without specific prior written permission. 5241a4b7ee2SBrad Bishop+ 5251a4b7ee2SBrad Bishop+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 5261a4b7ee2SBrad Bishop+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 5271a4b7ee2SBrad Bishop+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 5281a4b7ee2SBrad Bishop+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 5291a4b7ee2SBrad Bishop+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 5301a4b7ee2SBrad Bishop+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 5311a4b7ee2SBrad Bishop+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 5321a4b7ee2SBrad Bishop+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 5331a4b7ee2SBrad Bishop+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 5341a4b7ee2SBrad Bishop+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 5351a4b7ee2SBrad Bishop+*/ 5361a4b7ee2SBrad Bishop+ 5371a4b7ee2SBrad Bishop+#define VCOS_LOG_CATEGORY (&khrn_client_log) 5381a4b7ee2SBrad Bishop+ 5391a4b7ee2SBrad Bishop+#include "interface/khronos/common/linux/khrn_wayland.h" 5401a4b7ee2SBrad Bishop+#include "interface/khronos/wayland-dispmanx-client-protocol.h" 5411a4b7ee2SBrad Bishop+#include "interface/khronos/wayland-egl/wayland-egl-priv.h" 5421a4b7ee2SBrad Bishop+ 5431a4b7ee2SBrad Bishop+extern VCOS_LOG_CAT_T khrn_client_log; 5441a4b7ee2SBrad Bishop+ 5451a4b7ee2SBrad Bishop+static void handle_dispmanx_format(void *data, struct wl_dispmanx *dispmanx, 5461a4b7ee2SBrad Bishop+ uint32_t format) 5471a4b7ee2SBrad Bishop+{ 5481a4b7ee2SBrad Bishop+} 5491a4b7ee2SBrad Bishop+ 5501a4b7ee2SBrad Bishop+static void handle_dispmanx_allocated(void *data, struct wl_dispmanx *dispmanx, 5511a4b7ee2SBrad Bishop+ struct wl_buffer *wl_buffer, 5521a4b7ee2SBrad Bishop+ uint32_t resource_handle) 5531a4b7ee2SBrad Bishop+{ 5541a4b7ee2SBrad Bishop+ struct wl_dispmanx_client_buffer *buffer = wl_buffer_get_user_data(wl_buffer); 5551a4b7ee2SBrad Bishop+ 5561a4b7ee2SBrad Bishop+ buffer->pending_allocation = 0; 5571a4b7ee2SBrad Bishop+ buffer->resource = resource_handle; 5581a4b7ee2SBrad Bishop+} 5591a4b7ee2SBrad Bishop+ 5601a4b7ee2SBrad Bishop+static const struct wl_dispmanx_listener dispmanx_listener = { 5611a4b7ee2SBrad Bishop+ handle_dispmanx_format, 5621a4b7ee2SBrad Bishop+ handle_dispmanx_allocated, 5631a4b7ee2SBrad Bishop+}; 5641a4b7ee2SBrad Bishop+ 5651a4b7ee2SBrad Bishop+static void 5661a4b7ee2SBrad Bishop+sync_callback(void *data, struct wl_callback *callback, uint32_t serial) 5671a4b7ee2SBrad Bishop+{ 5681a4b7ee2SBrad Bishop+ int *done = data; 5691a4b7ee2SBrad Bishop+ 5701a4b7ee2SBrad Bishop+ *done = 1; 5711a4b7ee2SBrad Bishop+ 5721a4b7ee2SBrad Bishop+ wl_callback_destroy(callback); 5731a4b7ee2SBrad Bishop+} 5741a4b7ee2SBrad Bishop+ 5751a4b7ee2SBrad Bishop+static const struct wl_callback_listener sync_listener = { 5761a4b7ee2SBrad Bishop+ sync_callback 5771a4b7ee2SBrad Bishop+}; 5781a4b7ee2SBrad Bishop+ 5791a4b7ee2SBrad Bishop+static int 5801a4b7ee2SBrad Bishop+roundtrip(CLIENT_PROCESS_STATE_T *process) 5811a4b7ee2SBrad Bishop+{ 5821a4b7ee2SBrad Bishop+ struct wl_display *wl_display = khrn_platform_get_wl_display(); 5831a4b7ee2SBrad Bishop+ struct wl_callback *callback; 5841a4b7ee2SBrad Bishop+ int done = 0, ret = 0; 5851a4b7ee2SBrad Bishop+ 5861a4b7ee2SBrad Bishop+ callback = wl_display_sync(wl_display); 5871a4b7ee2SBrad Bishop+ wl_callback_add_listener(callback, &sync_listener, &done); 5881a4b7ee2SBrad Bishop+ wl_proxy_set_queue((struct wl_proxy *) callback, process->wl_queue); 5891a4b7ee2SBrad Bishop+ while (ret != -1 && !done) 5901a4b7ee2SBrad Bishop+ ret = wl_display_dispatch_queue(wl_display, process->wl_queue); 5911a4b7ee2SBrad Bishop+ 5921a4b7ee2SBrad Bishop+ if (!done) 5931a4b7ee2SBrad Bishop+ wl_callback_destroy(callback); 5941a4b7ee2SBrad Bishop+ 5951a4b7ee2SBrad Bishop+ return ret; 5961a4b7ee2SBrad Bishop+} 5971a4b7ee2SBrad Bishop+ 5981a4b7ee2SBrad Bishop+int do_wl_roundtrip() 5991a4b7ee2SBrad Bishop+{ 6001a4b7ee2SBrad Bishop+ CLIENT_PROCESS_STATE_T *process = CLIENT_GET_PROCESS_STATE(); 6011a4b7ee2SBrad Bishop+ return roundtrip(process); 6021a4b7ee2SBrad Bishop+} 6031a4b7ee2SBrad Bishop+ 6041a4b7ee2SBrad Bishop+static void 6051a4b7ee2SBrad Bishop+registry_handle_global(void *data, struct wl_registry *registry, 6061a4b7ee2SBrad Bishop+ uint32_t name, const char *interface, uint32_t version) 6071a4b7ee2SBrad Bishop+{ 6081a4b7ee2SBrad Bishop+ struct wl_display *wl_display = khrn_platform_get_wl_display(); 6091a4b7ee2SBrad Bishop+ CLIENT_PROCESS_STATE_T *process = (CLIENT_PROCESS_STATE_T *)data; 6101a4b7ee2SBrad Bishop+ 6111a4b7ee2SBrad Bishop+ if (strcmp(interface, "wl_dispmanx") == 0) { 6121a4b7ee2SBrad Bishop+ process->wl_dispmanx = wl_registry_bind(registry, name, 6131a4b7ee2SBrad Bishop+ &wl_dispmanx_interface, 1); 6141a4b7ee2SBrad Bishop+ 6151a4b7ee2SBrad Bishop+ wl_proxy_set_queue((struct wl_proxy *) process->wl_dispmanx, 6161a4b7ee2SBrad Bishop+ process->wl_queue); 6171a4b7ee2SBrad Bishop+ wl_dispmanx_add_listener(process->wl_dispmanx, &dispmanx_listener, wl_display); 6181a4b7ee2SBrad Bishop+ roundtrip(process); 6191a4b7ee2SBrad Bishop+ } 6201a4b7ee2SBrad Bishop+} 6211a4b7ee2SBrad Bishop+ 6221a4b7ee2SBrad Bishop+static void 6231a4b7ee2SBrad Bishop+registry_handle_global_remove(void *data, struct wl_registry *registry, 6241a4b7ee2SBrad Bishop+ uint32_t name) 6251a4b7ee2SBrad Bishop+{ 6261a4b7ee2SBrad Bishop+} 6271a4b7ee2SBrad Bishop+ 6281a4b7ee2SBrad Bishop+static const struct wl_registry_listener registry_listener = { 6291a4b7ee2SBrad Bishop+ registry_handle_global, 6301a4b7ee2SBrad Bishop+ registry_handle_global_remove 6311a4b7ee2SBrad Bishop+}; 6321a4b7ee2SBrad Bishop+ 6331a4b7ee2SBrad Bishop+int 6341a4b7ee2SBrad Bishop+init_process_wayland(CLIENT_PROCESS_STATE_T *process) 6351a4b7ee2SBrad Bishop+{ 6361a4b7ee2SBrad Bishop+ struct wl_display *wl_display = khrn_platform_get_wl_display(); 6371a4b7ee2SBrad Bishop+ 6381a4b7ee2SBrad Bishop+ process->wl_queue = wl_display_create_queue(wl_display); 6391a4b7ee2SBrad Bishop+ if (!process->wl_queue) { 6401a4b7ee2SBrad Bishop+ vcos_log_error("wl_display_create_queue failed\n"); 6411a4b7ee2SBrad Bishop+ return false; 6421a4b7ee2SBrad Bishop+ } 6431a4b7ee2SBrad Bishop+ wl_display_dispatch_pending(wl_display); 6441a4b7ee2SBrad Bishop+ 6451a4b7ee2SBrad Bishop+ process->wl_registry = wl_display_get_registry(wl_display); 6461a4b7ee2SBrad Bishop+ if (!process->wl_registry) { 6471a4b7ee2SBrad Bishop+ vcos_log_error("wl_display_get_registry failed\n"); 6481a4b7ee2SBrad Bishop+ return false; 6491a4b7ee2SBrad Bishop+ } 6501a4b7ee2SBrad Bishop+ 6511a4b7ee2SBrad Bishop+ wl_proxy_set_queue((struct wl_proxy *) process->wl_registry, 6521a4b7ee2SBrad Bishop+ process->wl_queue); 6531a4b7ee2SBrad Bishop+ 6541a4b7ee2SBrad Bishop+ wl_registry_add_listener(process->wl_registry, ®istry_listener, process); 6551a4b7ee2SBrad Bishop+ 6561a4b7ee2SBrad Bishop+ if (roundtrip(process) < 0 || process->wl_dispmanx == NULL) { 6571a4b7ee2SBrad Bishop+ vcos_log_error("failed to get wl_dispmanx\n"); 6581a4b7ee2SBrad Bishop+ return false; 6591a4b7ee2SBrad Bishop+ } 6601a4b7ee2SBrad Bishop+ 6611a4b7ee2SBrad Bishop+ return true; 6621a4b7ee2SBrad Bishop+} 6631a4b7ee2SBrad Bishop+ 6641a4b7ee2SBrad Bishop+#ifndef ALIGN_UP 6651a4b7ee2SBrad Bishop+#define ALIGN_UP(x,y) ((x + (y)-1) & ~((y)-1)) 6661a4b7ee2SBrad Bishop+#endif 6671a4b7ee2SBrad Bishop+ 6681a4b7ee2SBrad Bishop+static void handle_buffer_release(void *data, struct wl_buffer *buffer_wl) 6691a4b7ee2SBrad Bishop+{ 6701a4b7ee2SBrad Bishop+ struct wl_dispmanx_client_buffer *wl_dispmanx_client_buffer = data; 6711a4b7ee2SBrad Bishop+ wl_dispmanx_client_buffer->in_use = 0; 6721a4b7ee2SBrad Bishop+} 6731a4b7ee2SBrad Bishop+ 6741a4b7ee2SBrad Bishop+static const struct wl_buffer_listener buffer_listener = { 6751a4b7ee2SBrad Bishop+ handle_buffer_release 6761a4b7ee2SBrad Bishop+}; 6771a4b7ee2SBrad Bishop+ 6781a4b7ee2SBrad Bishop+struct wl_dispmanx_client_buffer * 6791a4b7ee2SBrad Bishop+allocate_wl_buffer(struct wl_egl_window *window, KHRN_IMAGE_FORMAT_T color) 6801a4b7ee2SBrad Bishop+{ 6811a4b7ee2SBrad Bishop+ CLIENT_PROCESS_STATE_T *process = CLIENT_GET_PROCESS_STATE(); 6821a4b7ee2SBrad Bishop+ struct wl_dispmanx_client_buffer *wl_dispmanx_client_buffer; 6831a4b7ee2SBrad Bishop+ struct wl_buffer *wl_buffer; 6841a4b7ee2SBrad Bishop+ uint32_t stride = ALIGN_UP(window->width * 4, 16); 6851a4b7ee2SBrad Bishop+ uint32_t buffer_height = ALIGN_UP(window->height, 16); 6861a4b7ee2SBrad Bishop+ enum wl_dispmanx_format color_format; 6871a4b7ee2SBrad Bishop+ int ret = 0; 6881a4b7ee2SBrad Bishop+ 6891a4b7ee2SBrad Bishop+ switch (color) { 6901a4b7ee2SBrad Bishop+ case ABGR_8888: 6911a4b7ee2SBrad Bishop+ color_format = WL_DISPMANX_FORMAT_ABGR8888; 6921a4b7ee2SBrad Bishop+ break; 6931a4b7ee2SBrad Bishop+ case XBGR_8888: 6941a4b7ee2SBrad Bishop+ color_format = WL_DISPMANX_FORMAT_XBGR8888; 6951a4b7ee2SBrad Bishop+ break; 6961a4b7ee2SBrad Bishop+ case RGB_565: 6971a4b7ee2SBrad Bishop+ color_format = WL_DISPMANX_FORMAT_RGB565; 6981a4b7ee2SBrad Bishop+ break; 6991a4b7ee2SBrad Bishop+ default: 7001a4b7ee2SBrad Bishop+ vcos_log_error("unknown KHRN_IMAGE_FORMAT_T 0x%x\n", color); 7011a4b7ee2SBrad Bishop+ return NULL; 7021a4b7ee2SBrad Bishop+ } 7031a4b7ee2SBrad Bishop+ 7041a4b7ee2SBrad Bishop+ wl_buffer = wl_dispmanx_create_buffer(process->wl_dispmanx, window->width, 7051a4b7ee2SBrad Bishop+ window->height, stride, buffer_height, 7061a4b7ee2SBrad Bishop+ color_format); 7071a4b7ee2SBrad Bishop+ if (wl_buffer == NULL) 7081a4b7ee2SBrad Bishop+ return NULL; 7091a4b7ee2SBrad Bishop+ 7101a4b7ee2SBrad Bishop+ wl_dispmanx_client_buffer = calloc(1, sizeof(struct wl_dispmanx_client_buffer)); 7111a4b7ee2SBrad Bishop+ wl_dispmanx_client_buffer->wl_buffer = wl_buffer; 7121a4b7ee2SBrad Bishop+ wl_dispmanx_client_buffer->in_use = 0; 7131a4b7ee2SBrad Bishop+ wl_dispmanx_client_buffer->pending_allocation = 1; 7141a4b7ee2SBrad Bishop+ wl_dispmanx_client_buffer->width = window->width; 7151a4b7ee2SBrad Bishop+ wl_dispmanx_client_buffer->height = window->height; 7161a4b7ee2SBrad Bishop+ 7171a4b7ee2SBrad Bishop+ wl_proxy_set_queue((struct wl_proxy *) wl_buffer, process->wl_queue); 7181a4b7ee2SBrad Bishop+ wl_buffer_add_listener(wl_buffer, &buffer_listener, wl_dispmanx_client_buffer); 7191a4b7ee2SBrad Bishop+ 7201a4b7ee2SBrad Bishop+ while (ret != -1 && wl_dispmanx_client_buffer->pending_allocation) 7211a4b7ee2SBrad Bishop+ ret = do_wl_roundtrip(); 7221a4b7ee2SBrad Bishop+ 7231a4b7ee2SBrad Bishop+ return wl_dispmanx_client_buffer; 7241a4b7ee2SBrad Bishop+} 7251a4b7ee2SBrad Bishopdiff --git a/interface/vmcs_host/vc_vchi_dispmanx.h b/interface/khronos/common/linux/khrn_wayland.h 7261a4b7ee2SBrad Bishopsimilarity index 56% 7271a4b7ee2SBrad Bishopcopy from interface/vmcs_host/vc_vchi_dispmanx.h 7281a4b7ee2SBrad Bishopcopy to interface/khronos/common/linux/khrn_wayland.h 7291a4b7ee2SBrad Bishopindex b723b76..b9bf08c 100644 7301a4b7ee2SBrad Bishop--- a/interface/vmcs_host/vc_vchi_dispmanx.h 7311a4b7ee2SBrad Bishop+++ b/interface/khronos/common/linux/khrn_wayland.h 7321a4b7ee2SBrad Bishop@@ -1,5 +1,5 @@ 7331a4b7ee2SBrad Bishop /* 7341a4b7ee2SBrad Bishop-Copyright (c) 2012, Broadcom Europe Ltd 7351a4b7ee2SBrad Bishop+Copyright (c) 2013, Raspberry Pi Foundation 7361a4b7ee2SBrad Bishop All rights reserved. 7371a4b7ee2SBrad Bishop 7381a4b7ee2SBrad Bishop Redistribution and use in source and binary forms, with or without 7391a4b7ee2SBrad Bishop@@ -25,45 +25,9 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 7401a4b7ee2SBrad Bishop SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 7411a4b7ee2SBrad Bishop */ 7421a4b7ee2SBrad Bishop 7431a4b7ee2SBrad Bishop-#ifndef VC_VCHI_DISPMANX_H 7441a4b7ee2SBrad Bishop-#define VC_VCHI_DISPMANX_H 7451a4b7ee2SBrad Bishop+#include "interface/khronos/common/khrn_client.h" 7461a4b7ee2SBrad Bishop 7471a4b7ee2SBrad Bishop-#include "interface/peer/vc_vchi_dispmanx_common.h" 7481a4b7ee2SBrad Bishop+int init_process_wayland(CLIENT_PROCESS_STATE_T *process); 7491a4b7ee2SBrad Bishop+int do_wl_roundtrip(); 7501a4b7ee2SBrad Bishop 7511a4b7ee2SBrad Bishop-#define VC_NUM_HOST_RESOURCES 64 7521a4b7ee2SBrad Bishop-#define DISPMANX_MSGFIFO_SIZE 1024 7531a4b7ee2SBrad Bishop-#define DISPMANX_CLIENT_NAME MAKE_FOURCC("DISP") 7541a4b7ee2SBrad Bishop-#define DISPMANX_NOTIFY_NAME MAKE_FOURCC("UPDH") 7551a4b7ee2SBrad Bishop- 7561a4b7ee2SBrad Bishop-//Or with command to indicate we don't need a response 7571a4b7ee2SBrad Bishop-#define DISPMANX_NO_REPLY_MASK (1<<31) 7581a4b7ee2SBrad Bishop- 7591a4b7ee2SBrad Bishop-typedef struct { 7601a4b7ee2SBrad Bishop- char description[32]; 7611a4b7ee2SBrad Bishop- uint32_t width; 7621a4b7ee2SBrad Bishop- uint32_t height; 7631a4b7ee2SBrad Bishop- uint32_t aspect_pixwidth; 7641a4b7ee2SBrad Bishop- uint32_t aspect_pixheight; 7651a4b7ee2SBrad Bishop- uint32_t fieldrate_num; 7661a4b7ee2SBrad Bishop- uint32_t fieldrate_denom; 7671a4b7ee2SBrad Bishop- uint32_t fields_per_frame; 7681a4b7ee2SBrad Bishop- uint32_t transform; 7691a4b7ee2SBrad Bishop-} GET_MODES_DATA_T; 7701a4b7ee2SBrad Bishop- 7711a4b7ee2SBrad Bishop-typedef struct { 7721a4b7ee2SBrad Bishop- int32_t response; 7731a4b7ee2SBrad Bishop- uint32_t width; 7741a4b7ee2SBrad Bishop- uint32_t height; 7751a4b7ee2SBrad Bishop- uint32_t transform; 7761a4b7ee2SBrad Bishop- uint32_t input_format; 7771a4b7ee2SBrad Bishop-} GET_INFO_DATA_T; 7781a4b7ee2SBrad Bishop- 7791a4b7ee2SBrad Bishop-//Attributes changes flag mask 7801a4b7ee2SBrad Bishop-#define ELEMENT_CHANGE_LAYER (1<<0) 7811a4b7ee2SBrad Bishop-#define ELEMENT_CHANGE_OPACITY (1<<1) 7821a4b7ee2SBrad Bishop-#define ELEMENT_CHANGE_DEST_RECT (1<<2) 7831a4b7ee2SBrad Bishop-#define ELEMENT_CHANGE_SRC_RECT (1<<3) 7841a4b7ee2SBrad Bishop-#define ELEMENT_CHANGE_MASK_RESOURCE (1<<4) 7851a4b7ee2SBrad Bishop-#define ELEMENT_CHANGE_TRANSFORM (1<<5) 7861a4b7ee2SBrad Bishop- 7871a4b7ee2SBrad Bishop-#endif 7881a4b7ee2SBrad Bishop+struct wl_dispmanx_client_buffer *allocate_wl_buffer(struct wl_egl_window *window, KHRN_IMAGE_FORMAT_T color); 7891a4b7ee2SBrad Bishopdiff --git a/interface/khronos/egl/egl_client.c b/interface/khronos/egl/egl_client.c 7901a4b7ee2SBrad Bishopindex b8bb374..03fe67b 100644 7911a4b7ee2SBrad Bishop--- a/interface/khronos/egl/egl_client.c 7921a4b7ee2SBrad Bishop+++ b/interface/khronos/egl/egl_client.c 7931a4b7ee2SBrad Bishop@@ -153,6 +153,10 @@ by an attribute value" 7941a4b7ee2SBrad Bishop #include <stdlib.h> 7951a4b7ee2SBrad Bishop #include <string.h> 7961a4b7ee2SBrad Bishop 7971a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 7981a4b7ee2SBrad Bishop+#include "interface/khronos/wayland-egl/wayland-egl-priv.h" 7991a4b7ee2SBrad Bishop+#include "interface/khronos/common/linux/khrn_wayland.h" 8001a4b7ee2SBrad Bishop+#endif 8011a4b7ee2SBrad Bishop 8021a4b7ee2SBrad Bishop #include "interface/khronos/egl/egl_client_cr.c" 8031a4b7ee2SBrad Bishop 8041a4b7ee2SBrad Bishop@@ -162,17 +166,6 @@ static void egl_current_release(CLIENT_PROCESS_STATE_T *process, EGL_CURRENT_T * 8051a4b7ee2SBrad Bishop void egl_gl_flush_callback(bool wait); 8061a4b7ee2SBrad Bishop void egl_vg_flush_callback(bool wait); 8071a4b7ee2SBrad Bishop 8081a4b7ee2SBrad Bishop-#include "interface/vmcs_host/vc_dispmanx_types.h" 8091a4b7ee2SBrad Bishop-/**HACKHACK - give us the ability to inject a DispmanX 8101a4b7ee2SBrad Bishop- * resource handle into the CreateWindowSurface and 8111a4b7ee2SBrad Bishop- * SwapBuffers calls */ 8121a4b7ee2SBrad Bishop-static DISPMANX_RESOURCE_HANDLE_T next_resource_handle; 8131a4b7ee2SBrad Bishop- 8141a4b7ee2SBrad Bishop-EGLAPI EGLBoolean EGLAPIENTRY eglSetNextResourceHandle(DISPMANX_RESOURCE_HANDLE_T handle) 8151a4b7ee2SBrad Bishop-{ 8161a4b7ee2SBrad Bishop- next_resource_handle = handle; 8171a4b7ee2SBrad Bishop-} 8181a4b7ee2SBrad Bishop- 8191a4b7ee2SBrad Bishop /* 8201a4b7ee2SBrad Bishop TODO: do an RPC call to make sure the Khronos vll is loaded (and that it stays loaded until eglTerminate) 8211a4b7ee2SBrad Bishop Also affects global image (and possibly others?) 8221a4b7ee2SBrad Bishop@@ -450,6 +443,9 @@ EGLAPI const char EGLAPIENTRY * eglQueryString(EGLDisplay dpy, EGLint name) 8231a4b7ee2SBrad Bishop #ifdef EGL_KHR_fence_sync 8241a4b7ee2SBrad Bishop "EGL_KHR_fence_sync " 8251a4b7ee2SBrad Bishop #endif 8261a4b7ee2SBrad Bishop+#endif 8271a4b7ee2SBrad Bishop+#if EGL_WL_bind_wayland_display 8281a4b7ee2SBrad Bishop+ "EGL_WL_bind_wayland_display " 8291a4b7ee2SBrad Bishop #endif 8301a4b7ee2SBrad Bishop ; 8311a4b7ee2SBrad Bishop break; 8321a4b7ee2SBrad Bishop@@ -655,8 +651,7 @@ EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig c 8331a4b7ee2SBrad Bishop false, 8341a4b7ee2SBrad Bishop EGL_NO_TEXTURE, 8351a4b7ee2SBrad Bishop EGL_NO_TEXTURE, 8361a4b7ee2SBrad Bishop- 0, 0, 8371a4b7ee2SBrad Bishop- next_resource_handle); 8381a4b7ee2SBrad Bishop+ 0, 0); 8391a4b7ee2SBrad Bishop 8401a4b7ee2SBrad Bishop if (surface) { 8411a4b7ee2SBrad Bishop if (khrn_pointer_map_insert(&process->surfaces, process->next_surface, surface)) { 8421a4b7ee2SBrad Bishop@@ -901,7 +896,7 @@ EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig 8431a4b7ee2SBrad Bishop mipmap_texture, 8441a4b7ee2SBrad Bishop texture_format, 8451a4b7ee2SBrad Bishop texture_target, 8461a4b7ee2SBrad Bishop- 0, 0, 0); 8471a4b7ee2SBrad Bishop+ 0, 0); 8481a4b7ee2SBrad Bishop 8491a4b7ee2SBrad Bishop if (surface) { 8501a4b7ee2SBrad Bishop if (khrn_pointer_map_insert(&process->surfaces, process->next_surface, surface)) { 8511a4b7ee2SBrad Bishop@@ -1043,7 +1038,7 @@ EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig c 8521a4b7ee2SBrad Bishop false, 8531a4b7ee2SBrad Bishop EGL_NO_TEXTURE, 8541a4b7ee2SBrad Bishop EGL_NO_TEXTURE, 8551a4b7ee2SBrad Bishop- pixmap, ((server_handle[0] == 0) && (server_handle[1] == (uint32_t)(-1))) ? NULL : server_handle, 0); 8561a4b7ee2SBrad Bishop+ pixmap, ((server_handle[0] == 0) && (server_handle[1] == (uint32_t)(-1))) ? NULL : server_handle); 8571a4b7ee2SBrad Bishop 8581a4b7ee2SBrad Bishop if (surface) { 8591a4b7ee2SBrad Bishop if (khrn_pointer_map_insert(&process->surfaces, process->next_surface, surface)) { 8601a4b7ee2SBrad Bishop@@ -2245,6 +2240,9 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surf) 8611a4b7ee2SBrad Bishop CLIENT_THREAD_STATE_T *thread; 8621a4b7ee2SBrad Bishop CLIENT_PROCESS_STATE_T *process; 8631a4b7ee2SBrad Bishop EGLBoolean result; 8641a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 8651a4b7ee2SBrad Bishop+ struct wl_display *wl_display = khrn_platform_get_wl_display(); 8661a4b7ee2SBrad Bishop+#endif 8671a4b7ee2SBrad Bishop 8681a4b7ee2SBrad Bishop vcos_log_trace("eglSwapBuffers start. dpy=%d. surf=%d.", (int)dpy, (int)surf); 8691a4b7ee2SBrad Bishop 8701a4b7ee2SBrad Bishop@@ -2315,18 +2313,58 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surf) 8711a4b7ee2SBrad Bishop 8721a4b7ee2SBrad Bishop vcos_log_trace("eglSwapBuffers server call"); 8731a4b7ee2SBrad Bishop 8741a4b7ee2SBrad Bishop- if (next_resource_handle) 8751a4b7ee2SBrad Bishop- RPC_CALL7(eglIntSwapBuffers_impl, 8761a4b7ee2SBrad Bishop- thread, 8771a4b7ee2SBrad Bishop- EGLINTSWAPBUFFERS_ID_V2, 8781a4b7ee2SBrad Bishop- RPC_UINT(surface->serverbuffer), 8791a4b7ee2SBrad Bishop- RPC_UINT(surface->width), 8801a4b7ee2SBrad Bishop- RPC_UINT(surface->height), 8811a4b7ee2SBrad Bishop- RPC_UINT(surface->internal_handle), 8821a4b7ee2SBrad Bishop- RPC_UINT(surface->swap_behavior == EGL_BUFFER_PRESERVED ? 1 : 0), 8831a4b7ee2SBrad Bishop- RPC_UINT(khrn_platform_get_window_position(surface->win)), 8841a4b7ee2SBrad Bishop- RPC_INT(next_resource_handle)); 8851a4b7ee2SBrad Bishop- else 8861a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 8871a4b7ee2SBrad Bishop+ if (wl_display) { 8881a4b7ee2SBrad Bishop+ struct wl_egl_window *wl_egl_window = surface->wl_egl_window; 8891a4b7ee2SBrad Bishop+ struct wl_dispmanx_client_buffer *buffer_temp; 8901a4b7ee2SBrad Bishop+ uint32_t configid; 8911a4b7ee2SBrad Bishop+ KHRN_IMAGE_FORMAT_T color; 8921a4b7ee2SBrad Bishop+ int ret = 0; 8931a4b7ee2SBrad Bishop+ 8941a4b7ee2SBrad Bishop+ buffer_temp = surface->front_wl_buffer; 8951a4b7ee2SBrad Bishop+ surface->front_wl_buffer = surface->back_wl_buffer; 8961a4b7ee2SBrad Bishop+ surface->back_wl_buffer = buffer_temp; 8971a4b7ee2SBrad Bishop+ 8981a4b7ee2SBrad Bishop+ configid = egl_config_to_id(surface->config); 8991a4b7ee2SBrad Bishop+ color = egl_config_get_color_format(configid); 9001a4b7ee2SBrad Bishop+ 9011a4b7ee2SBrad Bishop+ if (surface->back_wl_buffer == NULL) 9021a4b7ee2SBrad Bishop+ surface->back_wl_buffer = allocate_wl_buffer(wl_egl_window, color); 9031a4b7ee2SBrad Bishop+ else if (surface->back_wl_buffer->width != width || 9041a4b7ee2SBrad Bishop+ surface->back_wl_buffer->height != height) { 9051a4b7ee2SBrad Bishop+ 9061a4b7ee2SBrad Bishop+ struct wl_dispmanx_client_buffer *buffer; 9071a4b7ee2SBrad Bishop+ 9081a4b7ee2SBrad Bishop+ wl_buffer_destroy(surface->back_wl_buffer->wl_buffer); 9091a4b7ee2SBrad Bishop+ free(surface->back_wl_buffer); 9101a4b7ee2SBrad Bishop+ 9111a4b7ee2SBrad Bishop+ buffer = allocate_wl_buffer(wl_egl_window, color); 9121a4b7ee2SBrad Bishop+ surface->back_wl_buffer = buffer; 9131a4b7ee2SBrad Bishop+ } 9141a4b7ee2SBrad Bishop+ 9151a4b7ee2SBrad Bishop+ RPC_CALL7(eglIntSwapBuffers_impl, 9161a4b7ee2SBrad Bishop+ thread, 9171a4b7ee2SBrad Bishop+ EGLINTSWAPBUFFERS_ID_V2, 9181a4b7ee2SBrad Bishop+ RPC_UINT(surface->serverbuffer), 9191a4b7ee2SBrad Bishop+ RPC_UINT(surface->width), 9201a4b7ee2SBrad Bishop+ RPC_UINT(surface->height), 9211a4b7ee2SBrad Bishop+ RPC_UINT(surface->internal_handle), 9221a4b7ee2SBrad Bishop+ RPC_UINT(surface->swap_behavior == EGL_BUFFER_PRESERVED ? 1 : 0), 9231a4b7ee2SBrad Bishop+ RPC_UINT(khrn_platform_get_window_position(surface->win)), 9241a4b7ee2SBrad Bishop+ RPC_INT(surface->back_wl_buffer->resource)); 9251a4b7ee2SBrad Bishop+ 9261a4b7ee2SBrad Bishop+ surface->front_wl_buffer->in_use = 1; 9271a4b7ee2SBrad Bishop+ wl_surface_attach(wl_egl_window->wl_surface, 9281a4b7ee2SBrad Bishop+ surface->front_wl_buffer->wl_buffer, 9291a4b7ee2SBrad Bishop+ 0, 0); 9301a4b7ee2SBrad Bishop+ wl_surface_damage(wl_egl_window->wl_surface, 0, 0, 9311a4b7ee2SBrad Bishop+ surface->width, surface->height); 9321a4b7ee2SBrad Bishop+ wl_surface_commit(wl_egl_window->wl_surface); 9331a4b7ee2SBrad Bishop+ 9341a4b7ee2SBrad Bishop+ while(ret != -1 && surface->back_wl_buffer->in_use) 9351a4b7ee2SBrad Bishop+ ret = wl_display_dispatch_queue(wl_display, process->wl_queue); 9361a4b7ee2SBrad Bishop+ } else 9371a4b7ee2SBrad Bishop+#endif 9381a4b7ee2SBrad Bishop RPC_CALL6(eglIntSwapBuffers_impl, 9391a4b7ee2SBrad Bishop thread, 9401a4b7ee2SBrad Bishop EGLINTSWAPBUFFERS_ID, 9411a4b7ee2SBrad Bishopdiff --git a/interface/khronos/egl/egl_client_get_proc.c b/interface/khronos/egl/egl_client_get_proc.c 9421a4b7ee2SBrad Bishopindex 4cfa9ff..6a715af 100644 9431a4b7ee2SBrad Bishop--- a/interface/khronos/egl/egl_client_get_proc.c 9441a4b7ee2SBrad Bishop+++ b/interface/khronos/egl/egl_client_get_proc.c 9451a4b7ee2SBrad Bishop@@ -254,6 +254,17 @@ EGLAPI void EGLAPIENTRY (* eglGetProcAddress(const char *procname))(void) 9461a4b7ee2SBrad Bishop return (void(*)(void))eglQueryGlobalImageBRCM; 9471a4b7ee2SBrad Bishop #endif 9481a4b7ee2SBrad Bishop 9491a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 9501a4b7ee2SBrad Bishop+#if EGL_WL_bind_wayland_display 9511a4b7ee2SBrad Bishop+ if (!strcmp(procname, "eglBindWaylandDisplayWL")) 9521a4b7ee2SBrad Bishop+ return (void(*)(void))eglBindWaylandDisplayWL; 9531a4b7ee2SBrad Bishop+ if (!strcmp(procname, "eglUnbindWaylandDisplayWL")) 9541a4b7ee2SBrad Bishop+ return (void(*)(void))eglUnbindWaylandDisplayWL; 9551a4b7ee2SBrad Bishop+ if (!strcmp(procname, "eglQueryWaylandBufferWL")) 9561a4b7ee2SBrad Bishop+ return (void(*)(void))eglQueryWaylandBufferWL; 9571a4b7ee2SBrad Bishop+#endif 9581a4b7ee2SBrad Bishop+#endif 9591a4b7ee2SBrad Bishop+ 9601a4b7ee2SBrad Bishop return (void(*)(void)) NULL; 9611a4b7ee2SBrad Bishop } 9621a4b7ee2SBrad Bishop 9631a4b7ee2SBrad Bishopdiff --git a/interface/khronos/egl/egl_client_surface.c b/interface/khronos/egl/egl_client_surface.c 9641a4b7ee2SBrad Bishopindex 128325e..42350bf 100644 9651a4b7ee2SBrad Bishop--- a/interface/khronos/egl/egl_client_surface.c 9661a4b7ee2SBrad Bishop+++ b/interface/khronos/egl/egl_client_surface.c 9671a4b7ee2SBrad Bishop@@ -46,6 +46,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 9681a4b7ee2SBrad Bishop #include "interface/khronos/egl/egl_int_impl.h" 9691a4b7ee2SBrad Bishop #endif 9701a4b7ee2SBrad Bishop 9711a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 9721a4b7ee2SBrad Bishop+#include "interface/khronos/wayland-egl/wayland-egl-priv.h" 9731a4b7ee2SBrad Bishop+#include "interface/khronos/common/linux/khrn_wayland.h" 9741a4b7ee2SBrad Bishop+#endif 9751a4b7ee2SBrad Bishop+ 9761a4b7ee2SBrad Bishop #include <stdlib.h> 9771a4b7ee2SBrad Bishop 9781a4b7ee2SBrad Bishop 9791a4b7ee2SBrad Bishop@@ -314,8 +319,7 @@ EGL_SURFACE_T *egl_surface_create( 9801a4b7ee2SBrad Bishop EGLenum texture_format, 9811a4b7ee2SBrad Bishop EGLenum texture_target, 9821a4b7ee2SBrad Bishop EGLNativePixmapType pixmap, 9831a4b7ee2SBrad Bishop- const uint32_t *pixmap_server_handle, 9841a4b7ee2SBrad Bishop- DISPMANX_RESOURCE_HANDLE_T next_resource_handle) 9851a4b7ee2SBrad Bishop+ const uint32_t *pixmap_server_handle) 9861a4b7ee2SBrad Bishop { 9871a4b7ee2SBrad Bishop KHRN_IMAGE_FORMAT_T color; 9881a4b7ee2SBrad Bishop KHRN_IMAGE_FORMAT_T depth; 9891a4b7ee2SBrad Bishop@@ -326,6 +330,10 @@ EGL_SURFACE_T *egl_surface_create( 9901a4b7ee2SBrad Bishop EGLint config_depth_bits; 9911a4b7ee2SBrad Bishop EGLint config_stencil_bits; 9921a4b7ee2SBrad Bishop CLIENT_THREAD_STATE_T *thread = CLIENT_GET_THREAD_STATE(); 9931a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 9941a4b7ee2SBrad Bishop+ struct wl_display *wl_display = khrn_platform_get_wl_display(); 9951a4b7ee2SBrad Bishop+ DISPMANX_RESOURCE_HANDLE_T resource; 9961a4b7ee2SBrad Bishop+#endif 9971a4b7ee2SBrad Bishop 9981a4b7ee2SBrad Bishop EGL_SURFACE_T *surface = egl_surface_pool_alloc(); 9991a4b7ee2SBrad Bishop 10001a4b7ee2SBrad Bishop@@ -390,6 +398,18 @@ EGL_SURFACE_T *egl_surface_create( 10011a4b7ee2SBrad Bishop 10021a4b7ee2SBrad Bishop vcos_assert(color != IMAGE_FORMAT_INVALID); 10031a4b7ee2SBrad Bishop 10041a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 10051a4b7ee2SBrad Bishop+ if (type == WINDOW && wl_display) { 10061a4b7ee2SBrad Bishop+ surface->wl_egl_window = (struct wl_egl_window*)win; 10071a4b7ee2SBrad Bishop+ surface->back_wl_buffer = allocate_wl_buffer( 10081a4b7ee2SBrad Bishop+ surface->wl_egl_window, color); 10091a4b7ee2SBrad Bishop+ resource = surface->back_wl_buffer->resource; 10101a4b7ee2SBrad Bishop+ } else { 10111a4b7ee2SBrad Bishop+ surface->wl_egl_window = NULL; 10121a4b7ee2SBrad Bishop+ resource = DISPMANX_NO_HANDLE; 10131a4b7ee2SBrad Bishop+ } 10141a4b7ee2SBrad Bishop+#endif 10151a4b7ee2SBrad Bishop+ 10161a4b7ee2SBrad Bishop #ifdef KHRONOS_EGL_PLATFORM_OPENWFC 10171a4b7ee2SBrad Bishop // Create stream for this window 10181a4b7ee2SBrad Bishop if(type != PBUFFER) 10191a4b7ee2SBrad Bishop@@ -474,7 +494,8 @@ EGL_SURFACE_T *egl_surface_create( 10201a4b7ee2SBrad Bishop #endif 10211a4b7ee2SBrad Bishop uint32_t results[3]; 10221a4b7ee2SBrad Bishop 10231a4b7ee2SBrad Bishop- if (next_resource_handle) 10241a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 10251a4b7ee2SBrad Bishop+ if (resource != DISPMANX_NO_HANDLE) 10261a4b7ee2SBrad Bishop RPC_CALL16_OUT_CTRL(eglIntCreateSurface_impl, 10271a4b7ee2SBrad Bishop thread, 10281a4b7ee2SBrad Bishop EGLINTCREATESURFACE_ID_V2, 10291a4b7ee2SBrad Bishop@@ -492,9 +513,10 @@ EGL_SURFACE_T *egl_surface_create( 10301a4b7ee2SBrad Bishop RPC_UINT(config_stencil_bits), 10311a4b7ee2SBrad Bishop RPC_UINT(sem_name), 10321a4b7ee2SBrad Bishop RPC_UINT(type), 10331a4b7ee2SBrad Bishop- RPC_INT(next_resource_handle), 10341a4b7ee2SBrad Bishop+ RPC_INT(resource), 10351a4b7ee2SBrad Bishop results); 10361a4b7ee2SBrad Bishop else 10371a4b7ee2SBrad Bishop+#endif 10381a4b7ee2SBrad Bishop RPC_CALL15_OUT_CTRL(eglIntCreateSurface_impl, 10391a4b7ee2SBrad Bishop thread, 10401a4b7ee2SBrad Bishop EGLINTCREATESURFACE_ID, 10411a4b7ee2SBrad Bishop@@ -663,6 +685,18 @@ void egl_surface_free(EGL_SURFACE_T *surface) 10421a4b7ee2SBrad Bishop if( surface->type == WINDOW ) { 10431a4b7ee2SBrad Bishop vcos_log_trace("egl_surface_free: calling platform_destroy_winhandle..."); 10441a4b7ee2SBrad Bishop platform_destroy_winhandle( surface->win, surface->internal_handle ); 10451a4b7ee2SBrad Bishop+ 10461a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 10471a4b7ee2SBrad Bishop+ if (surface->back_wl_buffer) { 10481a4b7ee2SBrad Bishop+ wl_buffer_destroy(surface->back_wl_buffer->wl_buffer); 10491a4b7ee2SBrad Bishop+ free(surface->back_wl_buffer); 10501a4b7ee2SBrad Bishop+ } 10511a4b7ee2SBrad Bishop+ 10521a4b7ee2SBrad Bishop+ if (surface->front_wl_buffer) { 10531a4b7ee2SBrad Bishop+ wl_buffer_destroy(surface->front_wl_buffer->wl_buffer); 10541a4b7ee2SBrad Bishop+ free(surface->front_wl_buffer); 10551a4b7ee2SBrad Bishop+ } 10561a4b7ee2SBrad Bishop+#endif 10571a4b7ee2SBrad Bishop } 10581a4b7ee2SBrad Bishop /* return value ignored -- read performed to ensure blocking. we want this to 10591a4b7ee2SBrad Bishop * block so clients can safely destroy the surface's window as soon as the 10601a4b7ee2SBrad Bishopdiff --git a/interface/khronos/egl/egl_client_surface.h b/interface/khronos/egl/egl_client_surface.h 10611a4b7ee2SBrad Bishopindex b5bf70a..e328b77 100644 10621a4b7ee2SBrad Bishop--- a/interface/khronos/egl/egl_client_surface.h 10631a4b7ee2SBrad Bishop+++ b/interface/khronos/egl/egl_client_surface.h 10641a4b7ee2SBrad Bishop@@ -288,6 +288,41 @@ typedef struct { 10651a4b7ee2SBrad Bishop type == PIXMAP 10661a4b7ee2SBrad Bishop */ 10671a4b7ee2SBrad Bishop bool server_owned; 10681a4b7ee2SBrad Bishop+ 10691a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 10701a4b7ee2SBrad Bishop+ /* 10711a4b7ee2SBrad Bishop+ wl_egl_window 10721a4b7ee2SBrad Bishop+ 10731a4b7ee2SBrad Bishop+ Validity: 10741a4b7ee2SBrad Bishop+ type == WINDOW 10751a4b7ee2SBrad Bishop+ 10761a4b7ee2SBrad Bishop+ Invariant: 10771a4b7ee2SBrad Bishop+ wayland EGL window 10781a4b7ee2SBrad Bishop+ */ 10791a4b7ee2SBrad Bishop+ struct wl_egl_window *wl_egl_window; 10801a4b7ee2SBrad Bishop+ 10811a4b7ee2SBrad Bishop+ /* 10821a4b7ee2SBrad Bishop+ front_wl_buffer 10831a4b7ee2SBrad Bishop+ 10841a4b7ee2SBrad Bishop+ Validity: 10851a4b7ee2SBrad Bishop+ type == WINDOW 10861a4b7ee2SBrad Bishop+ 10871a4b7ee2SBrad Bishop+ Invariant: 10881a4b7ee2SBrad Bishop+ client-side information about the wl_buffer in the front 10891a4b7ee2SBrad Bishop+ */ 10901a4b7ee2SBrad Bishop+ struct wl_dispmanx_client_buffer *front_wl_buffer; 10911a4b7ee2SBrad Bishop+ 10921a4b7ee2SBrad Bishop+ /* 10931a4b7ee2SBrad Bishop+ back_wl_buffer 10941a4b7ee2SBrad Bishop+ 10951a4b7ee2SBrad Bishop+ Validity: 10961a4b7ee2SBrad Bishop+ type == WINDOW 10971a4b7ee2SBrad Bishop+ 10981a4b7ee2SBrad Bishop+ Invariant: 10991a4b7ee2SBrad Bishop+ client-side information about the wl_buffer in the back 11001a4b7ee2SBrad Bishop+ */ 11011a4b7ee2SBrad Bishop+ struct wl_dispmanx_client_buffer *back_wl_buffer; 11021a4b7ee2SBrad Bishop+#endif 11031a4b7ee2SBrad Bishop } EGL_SURFACE_T; 11041a4b7ee2SBrad Bishop 11051a4b7ee2SBrad Bishop extern bool egl_surface_check_attribs( 11061a4b7ee2SBrad Bishop@@ -322,8 +357,7 @@ extern EGL_SURFACE_T *egl_surface_create( 11071a4b7ee2SBrad Bishop EGLenum texture_format, 11081a4b7ee2SBrad Bishop EGLenum texture_target, 11091a4b7ee2SBrad Bishop EGLNativePixmapType pixmap, 11101a4b7ee2SBrad Bishop- const uint32_t *pixmap_server_handle, 11111a4b7ee2SBrad Bishop- DISPMANX_RESOURCE_HANDLE_T next_resource_handle); 11121a4b7ee2SBrad Bishop+ const uint32_t *pixmap_server_handle); 11131a4b7ee2SBrad Bishop extern EGL_SURFACE_T *egl_surface_from_vg_image( 11141a4b7ee2SBrad Bishop VGImage vg_handle, 11151a4b7ee2SBrad Bishop EGLSurface name, 11161a4b7ee2SBrad Bishopdiff --git a/interface/khronos/egl/egl_int_impl.h b/interface/khronos/egl/egl_int_impl.h 11171a4b7ee2SBrad Bishopindex 51b3580..6863a3b 100644 11181a4b7ee2SBrad Bishop--- a/interface/khronos/egl/egl_int_impl.h 11191a4b7ee2SBrad Bishop+++ b/interface/khronos/egl/egl_int_impl.h 11201a4b7ee2SBrad Bishop@@ -57,7 +57,7 @@ FN(int, eglIntCreateSurface_impl, ( 11211a4b7ee2SBrad Bishop uint32_t sem, 11221a4b7ee2SBrad Bishop uint32_t type, 11231a4b7ee2SBrad Bishop uint32_t *results, 11241a4b7ee2SBrad Bishop- DISPMANX_RESOURCE_HANDLE_T next_resource_handle)) 11251a4b7ee2SBrad Bishop+ DISPMANX_RESOURCE_HANDLE_T resource_handle)) 11261a4b7ee2SBrad Bishop 11271a4b7ee2SBrad Bishop FN(int, eglIntCreatePbufferFromVGImage_impl, ( 11281a4b7ee2SBrad Bishop VGImage vg_handle, 11291a4b7ee2SBrad Bishopdiff --git a/interface/khronos/ext/egl_wayland.c b/interface/khronos/ext/egl_wayland.c 11301a4b7ee2SBrad Bishopnew file mode 100644 11311a4b7ee2SBrad Bishopindex 0000000..5730743 11321a4b7ee2SBrad Bishop--- /dev/null 11331a4b7ee2SBrad Bishop+++ b/interface/khronos/ext/egl_wayland.c 11341a4b7ee2SBrad Bishop@@ -0,0 +1,246 @@ 11351a4b7ee2SBrad Bishop+/* 11361a4b7ee2SBrad Bishop+Copyright (c) 2013, Raspberry Pi Foundation 11371a4b7ee2SBrad Bishop+All rights reserved. 11381a4b7ee2SBrad Bishop+ 11391a4b7ee2SBrad Bishop+Redistribution and use in source and binary forms, with or without 11401a4b7ee2SBrad Bishop+modification, are permitted provided that the following conditions are met: 11411a4b7ee2SBrad Bishop+ * Redistributions of source code must retain the above copyright 11421a4b7ee2SBrad Bishop+ notice, this list of conditions and the following disclaimer. 11431a4b7ee2SBrad Bishop+ * Redistributions in binary form must reproduce the above copyright 11441a4b7ee2SBrad Bishop+ notice, this list of conditions and the following disclaimer in the 11451a4b7ee2SBrad Bishop+ documentation and/or other materials provided with the distribution. 11461a4b7ee2SBrad Bishop+ * Neither the name of the copyright holder nor the 11471a4b7ee2SBrad Bishop+ names of its contributors may be used to endorse or promote products 11481a4b7ee2SBrad Bishop+ derived from this software without specific prior written permission. 11491a4b7ee2SBrad Bishop+ 11501a4b7ee2SBrad Bishop+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 11511a4b7ee2SBrad Bishop+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 11521a4b7ee2SBrad Bishop+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 11531a4b7ee2SBrad Bishop+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 11541a4b7ee2SBrad Bishop+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 11551a4b7ee2SBrad Bishop+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 11561a4b7ee2SBrad Bishop+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 11571a4b7ee2SBrad Bishop+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 11581a4b7ee2SBrad Bishop+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 11591a4b7ee2SBrad Bishop+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 11601a4b7ee2SBrad Bishop+*/ 11611a4b7ee2SBrad Bishop+ 11621a4b7ee2SBrad Bishop+#include "interface/khronos/common/khrn_client_mangle.h" 11631a4b7ee2SBrad Bishop+#include "interface/khronos/common/khrn_client_rpc.h" 11641a4b7ee2SBrad Bishop+ 11651a4b7ee2SBrad Bishop+#include "interface/khronos/ext/egl_khr_sync_client.h" 11661a4b7ee2SBrad Bishop+#include "interface/khronos/include/EGL/egl.h" 11671a4b7ee2SBrad Bishop+#include "interface/khronos/include/EGL/eglext.h" 11681a4b7ee2SBrad Bishop+ 11691a4b7ee2SBrad Bishop+#include "interface/vmcs_host/vc_vchi_dispmanx.h" 11701a4b7ee2SBrad Bishop+ 11711a4b7ee2SBrad Bishop+#include <wayland-server.h> 11721a4b7ee2SBrad Bishop+#include "interface/khronos/wayland-dispmanx-server-protocol.h" 11731a4b7ee2SBrad Bishop+ 11741a4b7ee2SBrad Bishop+static void 11751a4b7ee2SBrad Bishop+destroy_buffer(struct wl_resource *resource) 11761a4b7ee2SBrad Bishop+{ 11771a4b7ee2SBrad Bishop+ struct wl_dispmanx_server_buffer *buffer = wl_resource_get_user_data(resource); 11781a4b7ee2SBrad Bishop+ 11791a4b7ee2SBrad Bishop+ if(!buffer->in_use) 11801a4b7ee2SBrad Bishop+ vc_dispmanx_resource_delete(buffer->handle); 11811a4b7ee2SBrad Bishop+ 11821a4b7ee2SBrad Bishop+ free(buffer); 11831a4b7ee2SBrad Bishop+} 11841a4b7ee2SBrad Bishop+ 11851a4b7ee2SBrad Bishop+static void 11861a4b7ee2SBrad Bishop+buffer_destroy(struct wl_client *client, struct wl_resource *resource) 11871a4b7ee2SBrad Bishop+{ 11881a4b7ee2SBrad Bishop+ wl_resource_destroy(resource); 11891a4b7ee2SBrad Bishop+} 11901a4b7ee2SBrad Bishop+ 11911a4b7ee2SBrad Bishop+static const struct wl_buffer_interface dispmanx_buffer_interface = { 11921a4b7ee2SBrad Bishop+ buffer_destroy 11931a4b7ee2SBrad Bishop+}; 11941a4b7ee2SBrad Bishop+ 11951a4b7ee2SBrad Bishop+static VC_IMAGE_TYPE_T 11961a4b7ee2SBrad Bishop+get_vc_format(enum wl_dispmanx_format format) 11971a4b7ee2SBrad Bishop+{ 11981a4b7ee2SBrad Bishop+ /* XXX: The app is likely to have been premultiplying in its shaders, 11991a4b7ee2SBrad Bishop+ * but the VC scanout hardware on the RPi cannot mix premultiplied alpha 12001a4b7ee2SBrad Bishop+ * channel with the element's alpha. 12011a4b7ee2SBrad Bishop+ */ 12021a4b7ee2SBrad Bishop+ switch (format) { 12031a4b7ee2SBrad Bishop+ case WL_DISPMANX_FORMAT_ABGR8888: 12041a4b7ee2SBrad Bishop+ return VC_IMAGE_RGBA32; 12051a4b7ee2SBrad Bishop+ case WL_DISPMANX_FORMAT_XBGR8888: 12061a4b7ee2SBrad Bishop+ return VC_IMAGE_BGRX8888; 12071a4b7ee2SBrad Bishop+ case WL_DISPMANX_FORMAT_RGB565: 12081a4b7ee2SBrad Bishop+ return VC_IMAGE_RGB565; 12091a4b7ee2SBrad Bishop+ default: 12101a4b7ee2SBrad Bishop+ /* invalid format */ 12111a4b7ee2SBrad Bishop+ return VC_IMAGE_MIN; 12121a4b7ee2SBrad Bishop+ } 12131a4b7ee2SBrad Bishop+} 12141a4b7ee2SBrad Bishop+ 12151a4b7ee2SBrad Bishop+static void 12161a4b7ee2SBrad Bishop+dispmanx_create_buffer(struct wl_client *client, struct wl_resource *resource, 12171a4b7ee2SBrad Bishop+ uint32_t id, int32_t width, int32_t height, 12181a4b7ee2SBrad Bishop+ uint32_t stride, uint32_t buffer_height, uint32_t format) 12191a4b7ee2SBrad Bishop+{ 12201a4b7ee2SBrad Bishop+ struct wl_dispmanx_server_buffer *buffer; 12211a4b7ee2SBrad Bishop+ VC_IMAGE_TYPE_T vc_format = get_vc_format(format); 12221a4b7ee2SBrad Bishop+ uint32_t dummy; 12231a4b7ee2SBrad Bishop+ 12241a4b7ee2SBrad Bishop+ if(vc_format == VC_IMAGE_MIN) { 12251a4b7ee2SBrad Bishop+ wl_resource_post_error(resource, 12261a4b7ee2SBrad Bishop+ WL_DISPMANX_ERROR_INVALID_FORMAT, 12271a4b7ee2SBrad Bishop+ "invalid format"); 12281a4b7ee2SBrad Bishop+ return; 12291a4b7ee2SBrad Bishop+ } 12301a4b7ee2SBrad Bishop+ 12311a4b7ee2SBrad Bishop+ buffer = calloc(1, sizeof *buffer); 12321a4b7ee2SBrad Bishop+ if (buffer == NULL) { 12331a4b7ee2SBrad Bishop+ wl_resource_post_no_memory(resource); 12341a4b7ee2SBrad Bishop+ return; 12351a4b7ee2SBrad Bishop+ } 12361a4b7ee2SBrad Bishop+ 12371a4b7ee2SBrad Bishop+ buffer->handle = vc_dispmanx_resource_create(vc_format, 12381a4b7ee2SBrad Bishop+ width | (stride << 16), 12391a4b7ee2SBrad Bishop+ height | (buffer_height << 16), 12401a4b7ee2SBrad Bishop+ &dummy); 12411a4b7ee2SBrad Bishop+ if(buffer->handle == DISPMANX_NO_HANDLE) { 12421a4b7ee2SBrad Bishop+ wl_resource_post_error(resource, 12431a4b7ee2SBrad Bishop+ WL_DISPMANX_ERROR_ALLOC_FAILED, 12441a4b7ee2SBrad Bishop+ "allocation failed"); 12451a4b7ee2SBrad Bishop+ free(buffer); 12461a4b7ee2SBrad Bishop+ return; 12471a4b7ee2SBrad Bishop+ } 12481a4b7ee2SBrad Bishop+ 12491a4b7ee2SBrad Bishop+ buffer->width = width; 12501a4b7ee2SBrad Bishop+ buffer->height = height; 12511a4b7ee2SBrad Bishop+ buffer->format = format; 12521a4b7ee2SBrad Bishop+ 12531a4b7ee2SBrad Bishop+ buffer->resource = wl_resource_create(resource->client, &wl_buffer_interface, 12541a4b7ee2SBrad Bishop+ 1, id); 12551a4b7ee2SBrad Bishop+ if (!buffer->resource) { 12561a4b7ee2SBrad Bishop+ wl_resource_post_no_memory(resource); 12571a4b7ee2SBrad Bishop+ vc_dispmanx_resource_delete(buffer->handle); 12581a4b7ee2SBrad Bishop+ free(buffer); 12591a4b7ee2SBrad Bishop+ return; 12601a4b7ee2SBrad Bishop+ } 12611a4b7ee2SBrad Bishop+ 12621a4b7ee2SBrad Bishop+ wl_resource_set_implementation(buffer->resource, 12631a4b7ee2SBrad Bishop+ (void (**)(void)) &dispmanx_buffer_interface, 12641a4b7ee2SBrad Bishop+ buffer, destroy_buffer); 12651a4b7ee2SBrad Bishop+ 12661a4b7ee2SBrad Bishop+ wl_dispmanx_send_buffer_allocated(resource, buffer->resource, 12671a4b7ee2SBrad Bishop+ buffer->handle); 12681a4b7ee2SBrad Bishop+} 12691a4b7ee2SBrad Bishop+ 12701a4b7ee2SBrad Bishop+static const struct wl_dispmanx_interface dispmanx_interface = { 12711a4b7ee2SBrad Bishop+ dispmanx_create_buffer, 12721a4b7ee2SBrad Bishop+}; 12731a4b7ee2SBrad Bishop+ 12741a4b7ee2SBrad Bishop+static void 12751a4b7ee2SBrad Bishop+bind_dispmanx(struct wl_client *client, void *data, uint32_t version, uint32_t id) 12761a4b7ee2SBrad Bishop+{ 12771a4b7ee2SBrad Bishop+ struct wl_resource *resource; 12781a4b7ee2SBrad Bishop+ 12791a4b7ee2SBrad Bishop+ resource = wl_resource_create(client, &wl_dispmanx_interface, 1, id); 12801a4b7ee2SBrad Bishop+ wl_resource_set_implementation(resource, &dispmanx_interface, NULL, NULL); 12811a4b7ee2SBrad Bishop+ 12821a4b7ee2SBrad Bishop+ wl_resource_post_event(resource, WL_DISPMANX_FORMAT, 12831a4b7ee2SBrad Bishop+ WL_DISPMANX_FORMAT_ARGB8888); 12841a4b7ee2SBrad Bishop+ 12851a4b7ee2SBrad Bishop+ wl_resource_post_event(resource, WL_DISPMANX_FORMAT, 12861a4b7ee2SBrad Bishop+ WL_DISPMANX_FORMAT_XRGB8888); 12871a4b7ee2SBrad Bishop+ 12881a4b7ee2SBrad Bishop+ wl_resource_post_event(resource, WL_DISPMANX_FORMAT, 12891a4b7ee2SBrad Bishop+ WL_DISPMANX_FORMAT_ABGR8888); 12901a4b7ee2SBrad Bishop+ 12911a4b7ee2SBrad Bishop+ wl_resource_post_event(resource, WL_DISPMANX_FORMAT, 12921a4b7ee2SBrad Bishop+ WL_DISPMANX_FORMAT_XBGR8888); 12931a4b7ee2SBrad Bishop+ 12941a4b7ee2SBrad Bishop+ wl_resource_post_event(resource, WL_DISPMANX_FORMAT, 12951a4b7ee2SBrad Bishop+ WL_DISPMANX_FORMAT_RGB565); 12961a4b7ee2SBrad Bishop+} 12971a4b7ee2SBrad Bishop+ 12981a4b7ee2SBrad Bishop+EGLBoolean EGLAPIENTRY 12991a4b7ee2SBrad Bishop+eglBindWaylandDisplayWL(EGLDisplay dpy, struct wl_display *display) 13001a4b7ee2SBrad Bishop+{ 13011a4b7ee2SBrad Bishop+ CLIENT_THREAD_STATE_T *thread; 13021a4b7ee2SBrad Bishop+ CLIENT_PROCESS_STATE_T *process; 13031a4b7ee2SBrad Bishop+ 13041a4b7ee2SBrad Bishop+ if (!CLIENT_LOCK_AND_GET_STATES(dpy, &thread, &process)) 13051a4b7ee2SBrad Bishop+ return EGL_FALSE; 13061a4b7ee2SBrad Bishop+ 13071a4b7ee2SBrad Bishop+ if (process->wl_global != NULL) 13081a4b7ee2SBrad Bishop+ goto error; 13091a4b7ee2SBrad Bishop+ 13101a4b7ee2SBrad Bishop+ process->wl_global = wl_global_create(display, &wl_dispmanx_interface, 1, 13111a4b7ee2SBrad Bishop+ NULL, bind_dispmanx); 13121a4b7ee2SBrad Bishop+ if (process->wl_global == NULL) 13131a4b7ee2SBrad Bishop+ goto error; 13141a4b7ee2SBrad Bishop+ 13151a4b7ee2SBrad Bishop+ return EGL_TRUE; 13161a4b7ee2SBrad Bishop+ 13171a4b7ee2SBrad Bishop+error: 13181a4b7ee2SBrad Bishop+ CLIENT_UNLOCK(); 13191a4b7ee2SBrad Bishop+ return EGL_FALSE; 13201a4b7ee2SBrad Bishop+} 13211a4b7ee2SBrad Bishop+ 13221a4b7ee2SBrad Bishop+EGLBoolean EGLAPIENTRY 13231a4b7ee2SBrad Bishop+eglUnbindWaylandDisplayWL(EGLDisplay dpy, struct wl_display *display) 13241a4b7ee2SBrad Bishop+{ 13251a4b7ee2SBrad Bishop+ CLIENT_THREAD_STATE_T *thread; 13261a4b7ee2SBrad Bishop+ CLIENT_PROCESS_STATE_T *process; 13271a4b7ee2SBrad Bishop+ 13281a4b7ee2SBrad Bishop+ if (!CLIENT_LOCK_AND_GET_STATES(dpy, &thread, &process)) 13291a4b7ee2SBrad Bishop+ return EGL_FALSE; 13301a4b7ee2SBrad Bishop+ 13311a4b7ee2SBrad Bishop+ wl_global_destroy(process->wl_global); 13321a4b7ee2SBrad Bishop+ process->wl_global = NULL; 13331a4b7ee2SBrad Bishop+ 13341a4b7ee2SBrad Bishop+ CLIENT_UNLOCK(); 13351a4b7ee2SBrad Bishop+ 13361a4b7ee2SBrad Bishop+ return EGL_TRUE; 13371a4b7ee2SBrad Bishop+} 13381a4b7ee2SBrad Bishop+ 13391a4b7ee2SBrad Bishop+static int 13401a4b7ee2SBrad Bishop+get_egl_format(enum wl_dispmanx_format format) 13411a4b7ee2SBrad Bishop+{ 13421a4b7ee2SBrad Bishop+ switch (format) { 13431a4b7ee2SBrad Bishop+ case WL_DISPMANX_FORMAT_ABGR8888: 13441a4b7ee2SBrad Bishop+ return EGL_TEXTURE_RGBA; 13451a4b7ee2SBrad Bishop+ case WL_DISPMANX_FORMAT_XBGR8888: 13461a4b7ee2SBrad Bishop+ return EGL_TEXTURE_RGB; 13471a4b7ee2SBrad Bishop+ case WL_DISPMANX_FORMAT_RGB565: 13481a4b7ee2SBrad Bishop+ return EGL_TEXTURE_RGB; 13491a4b7ee2SBrad Bishop+ default: 13501a4b7ee2SBrad Bishop+ /* invalid format */ 13511a4b7ee2SBrad Bishop+ return EGL_NO_TEXTURE; 13521a4b7ee2SBrad Bishop+ } 13531a4b7ee2SBrad Bishop+} 13541a4b7ee2SBrad Bishop+ 13551a4b7ee2SBrad Bishop+EGLBoolean EGLAPIENTRY 13561a4b7ee2SBrad Bishop+eglQueryWaylandBufferWL(EGLDisplay dpy, struct wl_resource *_buffer, 13571a4b7ee2SBrad Bishop+ EGLint attribute, EGLint *value) 13581a4b7ee2SBrad Bishop+{ 13591a4b7ee2SBrad Bishop+ struct wl_dispmanx_server_buffer *buffer = wl_resource_get_user_data(_buffer); 13601a4b7ee2SBrad Bishop+ 13611a4b7ee2SBrad Bishop+ if (wl_resource_instance_of(_buffer, &wl_dispmanx_interface, 13621a4b7ee2SBrad Bishop+ &dispmanx_buffer_interface)) 13631a4b7ee2SBrad Bishop+ return EGL_FALSE; 13641a4b7ee2SBrad Bishop+ 13651a4b7ee2SBrad Bishop+ switch (attribute) { 13661a4b7ee2SBrad Bishop+ case EGL_TEXTURE_FORMAT: 13671a4b7ee2SBrad Bishop+ *value = get_egl_format(buffer->format); 13681a4b7ee2SBrad Bishop+ if (*value == EGL_NO_TEXTURE) 13691a4b7ee2SBrad Bishop+ return EGL_FALSE; 13701a4b7ee2SBrad Bishop+ return EGL_TRUE; 13711a4b7ee2SBrad Bishop+ case EGL_WIDTH: 13721a4b7ee2SBrad Bishop+ *value = buffer->width; 13731a4b7ee2SBrad Bishop+ return EGL_TRUE; 13741a4b7ee2SBrad Bishop+ case EGL_HEIGHT: 13751a4b7ee2SBrad Bishop+ *value = buffer->height; 13761a4b7ee2SBrad Bishop+ return EGL_TRUE; 13771a4b7ee2SBrad Bishop+ } 13781a4b7ee2SBrad Bishop+ 13791a4b7ee2SBrad Bishop+ return EGL_FALSE; 13801a4b7ee2SBrad Bishop+} 13811a4b7ee2SBrad Bishopdiff --git a/interface/khronos/include/EGL/eglext.h b/interface/khronos/include/EGL/eglext.h 13821a4b7ee2SBrad Bishopindex 89a3369..d7e5ba7 100755 13831a4b7ee2SBrad Bishop--- a/interface/khronos/include/EGL/eglext.h 13841a4b7ee2SBrad Bishop+++ b/interface/khronos/include/EGL/eglext.h 13851a4b7ee2SBrad Bishop@@ -191,6 +191,29 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EG 13861a4b7ee2SBrad Bishop #endif 13871a4b7ee2SBrad Bishop 13881a4b7ee2SBrad Bishop 13891a4b7ee2SBrad Bishop+#ifndef EGL_WL_bind_wayland_display 13901a4b7ee2SBrad Bishop+#define EGL_WL_bind_wayland_display 1 13911a4b7ee2SBrad Bishop+ 13921a4b7ee2SBrad Bishop+#define EGL_WAYLAND_BUFFER_WL 0x31D5 /* eglCreateImageKHR target */ 13931a4b7ee2SBrad Bishop+#define EGL_WAYLAND_PLANE_WL 0x31D6 /* eglCreateImageKHR target */ 13941a4b7ee2SBrad Bishop+#define EGL_TEXTURE_Y_U_V_WL 0x31D7 13951a4b7ee2SBrad Bishop+#define EGL_TEXTURE_Y_UV_WL 0x31D8 13961a4b7ee2SBrad Bishop+#define EGL_TEXTURE_Y_XUXV_WL 0x31D9 13971a4b7ee2SBrad Bishop+ 13981a4b7ee2SBrad Bishop+struct wl_display; 13991a4b7ee2SBrad Bishop+struct wl_resource; 14001a4b7ee2SBrad Bishop+#ifdef EGL_EGLEXT_PROTOTYPES 14011a4b7ee2SBrad Bishop+EGLAPI EGLBoolean EGLAPIENTRY eglBindWaylandDisplayWL(EGLDisplay dpy, struct wl_display *display); 14021a4b7ee2SBrad Bishop+EGLAPI EGLBoolean EGLAPIENTRY eglUnbindWaylandDisplayWL(EGLDisplay dpy, struct wl_display *display); 14031a4b7ee2SBrad Bishop+EGLAPI EGLBoolean EGLAPIENTRY eglQueryWaylandBufferWL(EGLDisplay dpy, struct wl_resource *buffer, EGLint attribute, EGLint *value); 14041a4b7ee2SBrad Bishop+#endif 14051a4b7ee2SBrad Bishop+typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDWAYLANDDISPLAYWL) (EGLDisplay dpy, struct wl_display *display); 14061a4b7ee2SBrad Bishop+typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNBINDWAYLANDDISPLAYWL) (EGLDisplay dpy, struct wl_display *display); 14071a4b7ee2SBrad Bishop+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYWAYLANDBUFFERWL) (EGLDisplay dpy, struct wl_resource *buffer, EGLint attribute, EGLint *value); 14081a4b7ee2SBrad Bishop+ 14091a4b7ee2SBrad Bishop+#endif 14101a4b7ee2SBrad Bishop+ 14111a4b7ee2SBrad Bishop+ 14121a4b7ee2SBrad Bishop #ifdef __cplusplus 14131a4b7ee2SBrad Bishop } 14141a4b7ee2SBrad Bishop #endif 14151a4b7ee2SBrad Bishopdiff --git a/interface/khronos/wayland-egl/wayland-egl-priv.h b/interface/khronos/wayland-egl/wayland-egl-priv.h 14161a4b7ee2SBrad Bishopnew file mode 100644 14171a4b7ee2SBrad Bishopindex 0000000..8e38d36 14181a4b7ee2SBrad Bishop--- /dev/null 14191a4b7ee2SBrad Bishop+++ b/interface/khronos/wayland-egl/wayland-egl-priv.h 14201a4b7ee2SBrad Bishop@@ -0,0 +1,53 @@ 14211a4b7ee2SBrad Bishop+/* Copied from Mesa */ 14221a4b7ee2SBrad Bishop+ 14231a4b7ee2SBrad Bishop+#ifndef _WAYLAND_EGL_PRIV_H 14241a4b7ee2SBrad Bishop+#define _WAYLAND_EGL_PRIV_H 14251a4b7ee2SBrad Bishop+ 14261a4b7ee2SBrad Bishop+#ifdef __cplusplus 14271a4b7ee2SBrad Bishop+extern "C" { 14281a4b7ee2SBrad Bishop+#endif 14291a4b7ee2SBrad Bishop+ 14301a4b7ee2SBrad Bishop+/* GCC visibility */ 14311a4b7ee2SBrad Bishop+#if defined(__GNUC__) && __GNUC__ >= 4 14321a4b7ee2SBrad Bishop+#define WL_EGL_EXPORT __attribute__ ((visibility("default"))) 14331a4b7ee2SBrad Bishop+#else 14341a4b7ee2SBrad Bishop+#define WL_EGL_EXPORT 14351a4b7ee2SBrad Bishop+#endif 14361a4b7ee2SBrad Bishop+ 14371a4b7ee2SBrad Bishop+#include "interface/vmcs_host/vc_dispmanx.h" 14381a4b7ee2SBrad Bishop+#include "interface/khronos/egl/egl_client_surface.h" 14391a4b7ee2SBrad Bishop+ 14401a4b7ee2SBrad Bishop+#include <wayland-client.h> 14411a4b7ee2SBrad Bishop+ 14421a4b7ee2SBrad Bishop+struct wl_dispmanx_client_buffer { 14431a4b7ee2SBrad Bishop+ struct wl_buffer *wl_buffer; 14441a4b7ee2SBrad Bishop+ DISPMANX_RESOURCE_HANDLE_T resource; 14451a4b7ee2SBrad Bishop+ 14461a4b7ee2SBrad Bishop+ int pending_allocation; 14471a4b7ee2SBrad Bishop+ int in_use; 14481a4b7ee2SBrad Bishop+ int width; 14491a4b7ee2SBrad Bishop+ int height; 14501a4b7ee2SBrad Bishop+}; 14511a4b7ee2SBrad Bishop+ 14521a4b7ee2SBrad Bishop+struct wl_egl_window { 14531a4b7ee2SBrad Bishop+ struct wl_surface *wl_surface; 14541a4b7ee2SBrad Bishop+ 14551a4b7ee2SBrad Bishop+ int width; 14561a4b7ee2SBrad Bishop+ int height; 14571a4b7ee2SBrad Bishop+ int dx; 14581a4b7ee2SBrad Bishop+ int dy; 14591a4b7ee2SBrad Bishop+ 14601a4b7ee2SBrad Bishop+ int attached_width; 14611a4b7ee2SBrad Bishop+ int attached_height; 14621a4b7ee2SBrad Bishop+ 14631a4b7ee2SBrad Bishop+ /* XXX: The VC side seems to expect a valid element handle to be 14641a4b7ee2SBrad Bishop+ passed to eglIntCreateSurface_impl and/or eglIntSwapBuffers_impl, 14651a4b7ee2SBrad Bishop+ even for host-managed surfaces. */ 14661a4b7ee2SBrad Bishop+ DISPMANX_ELEMENT_HANDLE_T dummy_element; 14671a4b7ee2SBrad Bishop+}; 14681a4b7ee2SBrad Bishop+ 14691a4b7ee2SBrad Bishop+#ifdef __cplusplus 14701a4b7ee2SBrad Bishop+} 14711a4b7ee2SBrad Bishop+#endif 14721a4b7ee2SBrad Bishop+ 14731a4b7ee2SBrad Bishop+#endif 14741a4b7ee2SBrad Bishopdiff --git a/interface/khronos/wayland-egl/wayland-egl.c b/interface/khronos/wayland-egl/wayland-egl.c 14751a4b7ee2SBrad Bishopnew file mode 100644 14761a4b7ee2SBrad Bishopindex 0000000..b8f050b 14771a4b7ee2SBrad Bishop--- /dev/null 14781a4b7ee2SBrad Bishop+++ b/interface/khronos/wayland-egl/wayland-egl.c 14791a4b7ee2SBrad Bishop@@ -0,0 +1,59 @@ 14801a4b7ee2SBrad Bishop+/* Copied from Mesa */ 14811a4b7ee2SBrad Bishop+ 14821a4b7ee2SBrad Bishop+#include <stdlib.h> 14831a4b7ee2SBrad Bishop+ 14841a4b7ee2SBrad Bishop+#include <wayland-client.h> 14851a4b7ee2SBrad Bishop+#include <wayland-egl.h> 14861a4b7ee2SBrad Bishop+#include "wayland-egl-priv.h" 14871a4b7ee2SBrad Bishop+ 14881a4b7ee2SBrad Bishop+WL_EGL_EXPORT void 14891a4b7ee2SBrad Bishop+wl_egl_window_resize(struct wl_egl_window *egl_window, 14901a4b7ee2SBrad Bishop+ int width, int height, 14911a4b7ee2SBrad Bishop+ int dx, int dy) 14921a4b7ee2SBrad Bishop+{ 14931a4b7ee2SBrad Bishop+ if (egl_window->width == width && 14941a4b7ee2SBrad Bishop+ egl_window->height == height && 14951a4b7ee2SBrad Bishop+ egl_window->dx == dx && 14961a4b7ee2SBrad Bishop+ egl_window->dy == dy) 14971a4b7ee2SBrad Bishop+ return; 14981a4b7ee2SBrad Bishop+ 14991a4b7ee2SBrad Bishop+ egl_window->width = width; 15001a4b7ee2SBrad Bishop+ egl_window->height = height; 15011a4b7ee2SBrad Bishop+ egl_window->dx = dx; 15021a4b7ee2SBrad Bishop+ egl_window->dy = dy; 15031a4b7ee2SBrad Bishop+} 15041a4b7ee2SBrad Bishop+ 15051a4b7ee2SBrad Bishop+WL_EGL_EXPORT struct wl_egl_window * 15061a4b7ee2SBrad Bishop+wl_egl_window_create(struct wl_surface *surface, 15071a4b7ee2SBrad Bishop+ int width, int height) 15081a4b7ee2SBrad Bishop+{ 15091a4b7ee2SBrad Bishop+ struct wl_egl_window *egl_window; 15101a4b7ee2SBrad Bishop+ 15111a4b7ee2SBrad Bishop+ egl_window = calloc(1, sizeof *egl_window); 15121a4b7ee2SBrad Bishop+ if (!egl_window) 15131a4b7ee2SBrad Bishop+ return NULL; 15141a4b7ee2SBrad Bishop+ 15151a4b7ee2SBrad Bishop+ egl_window->wl_surface = surface; 15161a4b7ee2SBrad Bishop+ wl_egl_window_resize(egl_window, width, height, 0, 0); 15171a4b7ee2SBrad Bishop+ egl_window->attached_width = 0; 15181a4b7ee2SBrad Bishop+ egl_window->attached_height = 0; 15191a4b7ee2SBrad Bishop+ egl_window->dummy_element = PLATFORM_WIN_NONE; 15201a4b7ee2SBrad Bishop+ 15211a4b7ee2SBrad Bishop+ return egl_window; 15221a4b7ee2SBrad Bishop+} 15231a4b7ee2SBrad Bishop+ 15241a4b7ee2SBrad Bishop+WL_EGL_EXPORT void 15251a4b7ee2SBrad Bishop+wl_egl_window_destroy(struct wl_egl_window *egl_window) 15261a4b7ee2SBrad Bishop+{ 15271a4b7ee2SBrad Bishop+ free(egl_window); 15281a4b7ee2SBrad Bishop+} 15291a4b7ee2SBrad Bishop+ 15301a4b7ee2SBrad Bishop+WL_EGL_EXPORT void 15311a4b7ee2SBrad Bishop+wl_egl_window_get_attached_size(struct wl_egl_window *egl_window, 15321a4b7ee2SBrad Bishop+ int *width, int *height) 15331a4b7ee2SBrad Bishop+{ 15341a4b7ee2SBrad Bishop+ if (width) 15351a4b7ee2SBrad Bishop+ *width = egl_window->attached_width; 15361a4b7ee2SBrad Bishop+ if (height) 15371a4b7ee2SBrad Bishop+ *height = egl_window->attached_height; 15381a4b7ee2SBrad Bishop+} 15391a4b7ee2SBrad Bishopdiff --git a/interface/khronos/wayland-egl/wayland-egl.pc.in b/interface/khronos/wayland-egl/wayland-egl.pc.in 15401a4b7ee2SBrad Bishopnew file mode 100644 15411a4b7ee2SBrad Bishopindex 0000000..8bafc15 15421a4b7ee2SBrad Bishop--- /dev/null 15431a4b7ee2SBrad Bishop+++ b/interface/khronos/wayland-egl/wayland-egl.pc.in 15441a4b7ee2SBrad Bishop@@ -0,0 +1,10 @@ 15451a4b7ee2SBrad Bishop+prefix=@CMAKE_INSTALL_PREFIX@ 15461a4b7ee2SBrad Bishop+exec_prefix=${prefix} 15471a4b7ee2SBrad Bishop+libdir=${exec_prefix}/lib 15481a4b7ee2SBrad Bishop+includedir=${prefix}/include 15491a4b7ee2SBrad Bishop+ 15501a4b7ee2SBrad Bishop+Name: wayland-egl 15511a4b7ee2SBrad Bishop+Description: VideoCore wayland-egl library 15521a4b7ee2SBrad Bishop+Version: @PROJECT_APIVER@ 15531a4b7ee2SBrad Bishop+Libs: -L${libdir} -lwayland-egl 15541a4b7ee2SBrad Bishop+Cflags: -I${includedir} 15551a4b7ee2SBrad Bishopdiff --git a/interface/vmcs_host/CMakeLists.txt b/interface/vmcs_host/CMakeLists.txt 155626e4beaaSAndrew Geisslerindex cbef80c..552312a 100755 15571a4b7ee2SBrad Bishop--- a/interface/vmcs_host/CMakeLists.txt 15581a4b7ee2SBrad Bishop+++ b/interface/vmcs_host/CMakeLists.txt 155926bdd445SBrad Bishop@@ -7,13 +7,24 @@ 156026bdd445SBrad Bishop # vc_vchi_gencmd.c has a type-punning problem in vc_gencmd_read_response 156126bdd445SBrad Bishop add_definitions(-fno-strict-aliasing) 15621a4b7ee2SBrad Bishop 15631a4b7ee2SBrad Bishop-add_library(vchostif 15641a4b7ee2SBrad Bishop+set(VCHOSTIF_SOURCE 156526e4beaaSAndrew Geissler ${VMCS_TARGET}/vcmisc.c 156626e4beaaSAndrew Geissler vc_vchi_gencmd.c vc_vchi_gpuserv.c 156726e4beaaSAndrew Geissler vc_vchi_tvservice.c vc_vchi_cecservice.c 156826e4beaaSAndrew Geissler vc_vchi_dispmanx.c vc_service_common.c) 15691a4b7ee2SBrad Bishop # ${VMCS_TARGET}/vmcs_main.c 15701a4b7ee2SBrad Bishop # vc_vchi_haud.c 15711a4b7ee2SBrad Bishop+ 15721a4b7ee2SBrad Bishop+if (BUILD_WAYLAND) 15731a4b7ee2SBrad Bishop+wayland_add_protocol_server( 15741a4b7ee2SBrad Bishop+ VCHOSTIF_SOURCE 15751a4b7ee2SBrad Bishop+ ../../interface/wayland/dispmanx.xml 15761a4b7ee2SBrad Bishop+ dispmanx 15771a4b7ee2SBrad Bishop+) 15781a4b7ee2SBrad Bishop+endif () 15791a4b7ee2SBrad Bishop+ 15801a4b7ee2SBrad Bishop+add_library(vchostif ${VCHOSTIF_SOURCE}) 15811a4b7ee2SBrad Bishop+ 15821a4b7ee2SBrad Bishop #add_library(bufman vc_vchi_bufman.c ) 1583062316f1SAndrew Geissler set(INSTALL_TARGETS vchostif) 15841a4b7ee2SBrad Bishop 15851a4b7ee2SBrad Bishopdiff --git a/interface/vmcs_host/vc_dispmanx.h b/interface/vmcs_host/vc_dispmanx.h 15861a4b7ee2SBrad Bishopindex 37fdae1..fe3619a 100755 15871a4b7ee2SBrad Bishop--- a/interface/vmcs_host/vc_dispmanx.h 15881a4b7ee2SBrad Bishop+++ b/interface/vmcs_host/vc_dispmanx.h 15891a4b7ee2SBrad Bishop@@ -39,6 +39,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 15901a4b7ee2SBrad Bishop #ifdef __cplusplus 15911a4b7ee2SBrad Bishop extern "C" { 15921a4b7ee2SBrad Bishop #endif 15931a4b7ee2SBrad Bishop+ 15941a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 15951a4b7ee2SBrad Bishop+struct wl_resource; 15961a4b7ee2SBrad Bishop+#endif 15971a4b7ee2SBrad Bishop+ 15981a4b7ee2SBrad Bishop // Same function as above, to aid migration of code. 15991a4b7ee2SBrad Bishop VCHPRE_ int VCHPOST_ vc_dispman_init( void ); 16001a4b7ee2SBrad Bishop // Stop the service from being used 16011a4b7ee2SBrad Bishop@@ -135,6 +140,11 @@ VCHPRE_ int VCHPOST_ vc_dispmanx_resource_set_palette( DISPMANX_RESOURCE_HANDLE_ 16021a4b7ee2SBrad Bishop // Start triggering callbacks synced to vsync 16031a4b7ee2SBrad Bishop VCHPRE_ int VCHPOST_ vc_dispmanx_vsync_callback( DISPMANX_DISPLAY_HANDLE_T display, DISPMANX_CALLBACK_FUNC_T cb_func, void *cb_arg ); 16041a4b7ee2SBrad Bishop 16051a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 16061a4b7ee2SBrad Bishop+VCHPRE_ DISPMANX_RESOURCE_HANDLE_T VCHPOST_ vc_dispmanx_get_handle_from_wl_buffer( struct wl_resource *_buffer ); 16071a4b7ee2SBrad Bishop+ 16081a4b7ee2SBrad Bishop+VCHPRE_ void VCHPOST_ vc_dispmanx_set_wl_buffer_in_use( struct wl_resource *_buffer, int in_use ); 16091a4b7ee2SBrad Bishop+#endif 16101a4b7ee2SBrad Bishop #ifdef __cplusplus 16111a4b7ee2SBrad Bishop } 16121a4b7ee2SBrad Bishop #endif 16131a4b7ee2SBrad Bishopdiff --git a/interface/vmcs_host/vc_vchi_dispmanx.c b/interface/vmcs_host/vc_vchi_dispmanx.c 16141a4b7ee2SBrad Bishopindex 7a6cdcd..eab146e 100755 16151a4b7ee2SBrad Bishop--- a/interface/vmcs_host/vc_vchi_dispmanx.c 16161a4b7ee2SBrad Bishop+++ b/interface/vmcs_host/vc_vchi_dispmanx.c 16171a4b7ee2SBrad Bishop@@ -1319,3 +1319,45 @@ static void *dispmanx_notify_func( void *arg ) { 16181a4b7ee2SBrad Bishop } 16191a4b7ee2SBrad Bishop return 0; 16201a4b7ee2SBrad Bishop } 16211a4b7ee2SBrad Bishop+ 16221a4b7ee2SBrad Bishop+ 16231a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 16241a4b7ee2SBrad Bishop+/*********************************************************** 16251a4b7ee2SBrad Bishop+ * Name: vc_dispmanx_get_handle_from_wl_buffer 16261a4b7ee2SBrad Bishop+ * 16271a4b7ee2SBrad Bishop+ * Arguments: 16281a4b7ee2SBrad Bishop+ * struct wl_resource *_buffer 16291a4b7ee2SBrad Bishop+ * 16301a4b7ee2SBrad Bishop+ * Description: Return the handle of the resource associated to this Wayland buffer 16311a4b7ee2SBrad Bishop+ * 16321a4b7ee2SBrad Bishop+ * Returns: A resource handle 16331a4b7ee2SBrad Bishop+ * 16341a4b7ee2SBrad Bishop+ ***********************************************************/ 16351a4b7ee2SBrad Bishop+VCHPRE_ DISPMANX_RESOURCE_HANDLE_T VCHPOST_ vc_dispmanx_get_handle_from_wl_buffer( struct wl_resource *_buffer ) 16361a4b7ee2SBrad Bishop+{ 16371a4b7ee2SBrad Bishop+ struct wl_dispmanx_server_buffer *buffer = (struct wl_dispmanx_server_buffer*)_buffer->data; 16381a4b7ee2SBrad Bishop+ if (!buffer) 16391a4b7ee2SBrad Bishop+ return DISPMANX_NO_HANDLE; 16401a4b7ee2SBrad Bishop+ 16411a4b7ee2SBrad Bishop+ return buffer->handle; 16421a4b7ee2SBrad Bishop+} 16431a4b7ee2SBrad Bishop+ 16441a4b7ee2SBrad Bishop+/*********************************************************** 16451a4b7ee2SBrad Bishop+ * Name: vc_dispmanx_set_wl_buffer_in_use 16461a4b7ee2SBrad Bishop+ * 16471a4b7ee2SBrad Bishop+ * Arguments: 16481a4b7ee2SBrad Bishop+ * struct wl_resource *_buffer 16491a4b7ee2SBrad Bishop+ * int in_use 16501a4b7ee2SBrad Bishop+ * 16511a4b7ee2SBrad Bishop+ * Description: Mark this Wayland buffer as being in use by the compositor 16521a4b7ee2SBrad Bishop+ * 16531a4b7ee2SBrad Bishop+ ***********************************************************/ 16541a4b7ee2SBrad Bishop+VCHPRE_ void VCHPOST_ vc_dispmanx_set_wl_buffer_in_use( struct wl_resource *_buffer, int in_use ) 16551a4b7ee2SBrad Bishop+{ 16561a4b7ee2SBrad Bishop+ struct wl_dispmanx_server_buffer *buffer = (struct wl_dispmanx_server_buffer*)_buffer->data; 16571a4b7ee2SBrad Bishop+ if (!buffer) 16581a4b7ee2SBrad Bishop+ return; 16591a4b7ee2SBrad Bishop+ 16601a4b7ee2SBrad Bishop+ buffer->in_use = in_use; 16611a4b7ee2SBrad Bishop+} 16621a4b7ee2SBrad Bishop+#endif 16631a4b7ee2SBrad Bishopdiff --git a/interface/vmcs_host/vc_vchi_dispmanx.h b/interface/vmcs_host/vc_vchi_dispmanx.h 16641a4b7ee2SBrad Bishopindex b723b76..f0bae30 100644 16651a4b7ee2SBrad Bishop--- a/interface/vmcs_host/vc_vchi_dispmanx.h 16661a4b7ee2SBrad Bishop+++ b/interface/vmcs_host/vc_vchi_dispmanx.h 16671a4b7ee2SBrad Bishop@@ -66,4 +66,19 @@ typedef struct { 16681a4b7ee2SBrad Bishop #define ELEMENT_CHANGE_MASK_RESOURCE (1<<4) 16691a4b7ee2SBrad Bishop #define ELEMENT_CHANGE_TRANSFORM (1<<5) 16701a4b7ee2SBrad Bishop 16711a4b7ee2SBrad Bishop+#ifdef BUILD_WAYLAND 16721a4b7ee2SBrad Bishop+/* XXX: This should be in a private header that can be included from EGL and vc_* */ 16731a4b7ee2SBrad Bishop+#include <wayland-server.h> 16741a4b7ee2SBrad Bishop+#include "interface/vmcs_host/wayland-dispmanx-server-protocol.h" 16751a4b7ee2SBrad Bishop+struct wl_dispmanx_server_buffer { 16761a4b7ee2SBrad Bishop+ struct wl_resource *resource; 16771a4b7ee2SBrad Bishop+ struct wl_dispmanx *dispmanx; 16781a4b7ee2SBrad Bishop+ enum wl_dispmanx_format format; 16791a4b7ee2SBrad Bishop+ DISPMANX_RESOURCE_HANDLE_T handle; 16801a4b7ee2SBrad Bishop+ int32_t width; 16811a4b7ee2SBrad Bishop+ int32_t height; 16821a4b7ee2SBrad Bishop+ int in_use; 16831a4b7ee2SBrad Bishop+}; 16841a4b7ee2SBrad Bishop+#endif 16851a4b7ee2SBrad Bishop+ 16861a4b7ee2SBrad Bishop #endif 16871a4b7ee2SBrad Bishopdiff --git a/interface/wayland/dispmanx.xml b/interface/wayland/dispmanx.xml 16881a4b7ee2SBrad Bishopnew file mode 100644 16891a4b7ee2SBrad Bishopindex 0000000..c18626d 16901a4b7ee2SBrad Bishop--- /dev/null 16911a4b7ee2SBrad Bishop+++ b/interface/wayland/dispmanx.xml 16921a4b7ee2SBrad Bishop@@ -0,0 +1,123 @@ 16931a4b7ee2SBrad Bishop+<?xml version="1.0" encoding="UTF-8"?> 16941a4b7ee2SBrad Bishop+<protocol name="dispmanx"> 16951a4b7ee2SBrad Bishop+ 16961a4b7ee2SBrad Bishop+ <copyright> 16971a4b7ee2SBrad Bishop+ Copyright © 2008-2011 Kristian Høgsberg 16981a4b7ee2SBrad Bishop+ Copyright © 2010-2011 Intel Corporation 16991a4b7ee2SBrad Bishop+ Copyright © 2013 Raspberry Pi Foundation 17001a4b7ee2SBrad Bishop+ 17011a4b7ee2SBrad Bishop+ Permission to use, copy, modify, distribute, and sell this 17021a4b7ee2SBrad Bishop+ software and its documentation for any purpose is hereby granted 17031a4b7ee2SBrad Bishop+ without fee, provided that\n the above copyright notice appear in 17041a4b7ee2SBrad Bishop+ all copies and that both that copyright notice and this permission 17051a4b7ee2SBrad Bishop+ notice appear in supporting documentation, and that the name of 17061a4b7ee2SBrad Bishop+ the copyright holders not be used in advertising or publicity 17071a4b7ee2SBrad Bishop+ pertaining to distribution of the software without specific, 17081a4b7ee2SBrad Bishop+ written prior permission. The copyright holders make no 17091a4b7ee2SBrad Bishop+ representations about the suitability of this software for any 17101a4b7ee2SBrad Bishop+ purpose. It is provided "as is" without express or implied 17111a4b7ee2SBrad Bishop+ warranty. 17121a4b7ee2SBrad Bishop+ 17131a4b7ee2SBrad Bishop+ THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 17141a4b7ee2SBrad Bishop+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 17151a4b7ee2SBrad Bishop+ FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 17161a4b7ee2SBrad Bishop+ SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 17171a4b7ee2SBrad Bishop+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 17181a4b7ee2SBrad Bishop+ AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 17191a4b7ee2SBrad Bishop+ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 17201a4b7ee2SBrad Bishop+ THIS SOFTWARE. 17211a4b7ee2SBrad Bishop+ </copyright> 17221a4b7ee2SBrad Bishop+ 17231a4b7ee2SBrad Bishop+ <!-- DispManX support. This object is created by the server and published 17241a4b7ee2SBrad Bishop+ using the display's global event. --> 17251a4b7ee2SBrad Bishop+ <interface name="wl_dispmanx" version="1"> 17261a4b7ee2SBrad Bishop+ <enum name="error"> 17271a4b7ee2SBrad Bishop+ <entry name="alloc_failed" value="0"/> 17281a4b7ee2SBrad Bishop+ <entry name="invalid_format" value="1"/> 17291a4b7ee2SBrad Bishop+ </enum> 17301a4b7ee2SBrad Bishop+ 17311a4b7ee2SBrad Bishop+ <enum name="format"> 17321a4b7ee2SBrad Bishop+ <!-- The pixel format codes match the #defines in drm_fourcc.h. 17331a4b7ee2SBrad Bishop+ The formats actually supported by the compositor will be 17341a4b7ee2SBrad Bishop+ reported by the format event. --> 17351a4b7ee2SBrad Bishop+ <entry name="c8" value="0x20203843"/> 17361a4b7ee2SBrad Bishop+ <entry name="rgb332" value="0x38424752"/> 17371a4b7ee2SBrad Bishop+ <entry name="bgr233" value="0x38524742"/> 17381a4b7ee2SBrad Bishop+ <entry name="xrgb4444" value="0x32315258"/> 17391a4b7ee2SBrad Bishop+ <entry name="xbgr4444" value="0x32314258"/> 17401a4b7ee2SBrad Bishop+ <entry name="rgbx4444" value="0x32315852"/> 17411a4b7ee2SBrad Bishop+ <entry name="bgrx4444" value="0x32315842"/> 17421a4b7ee2SBrad Bishop+ <entry name="argb4444" value="0x32315241"/> 17431a4b7ee2SBrad Bishop+ <entry name="abgr4444" value="0x32314241"/> 17441a4b7ee2SBrad Bishop+ <entry name="rgba4444" value="0x32314152"/> 17451a4b7ee2SBrad Bishop+ <entry name="bgra4444" value="0x32314142"/> 17461a4b7ee2SBrad Bishop+ <entry name="xrgb1555" value="0x35315258"/> 17471a4b7ee2SBrad Bishop+ <entry name="xbgr1555" value="0x35314258"/> 17481a4b7ee2SBrad Bishop+ <entry name="rgbx5551" value="0x35315852"/> 17491a4b7ee2SBrad Bishop+ <entry name="bgrx5551" value="0x35315842"/> 17501a4b7ee2SBrad Bishop+ <entry name="argb1555" value="0x35315241"/> 17511a4b7ee2SBrad Bishop+ <entry name="abgr1555" value="0x35314241"/> 17521a4b7ee2SBrad Bishop+ <entry name="rgba5551" value="0x35314152"/> 17531a4b7ee2SBrad Bishop+ <entry name="bgra5551" value="0x35314142"/> 17541a4b7ee2SBrad Bishop+ <entry name="rgb565" value="0x36314752"/> 17551a4b7ee2SBrad Bishop+ <entry name="bgr565" value="0x36314742"/> 17561a4b7ee2SBrad Bishop+ <entry name="rgb888" value="0x34324752"/> 17571a4b7ee2SBrad Bishop+ <entry name="bgr888" value="0x34324742"/> 17581a4b7ee2SBrad Bishop+ <entry name="xrgb8888" value="0x34325258"/> 17591a4b7ee2SBrad Bishop+ <entry name="xbgr8888" value="0x34324258"/> 17601a4b7ee2SBrad Bishop+ <entry name="rgbx8888" value="0x34325852"/> 17611a4b7ee2SBrad Bishop+ <entry name="bgrx8888" value="0x34325842"/> 17621a4b7ee2SBrad Bishop+ <entry name="argb8888" value="0x34325241"/> 17631a4b7ee2SBrad Bishop+ <entry name="abgr8888" value="0x34324241"/> 17641a4b7ee2SBrad Bishop+ <entry name="rgba8888" value="0x34324152"/> 17651a4b7ee2SBrad Bishop+ <entry name="bgra8888" value="0x34324142"/> 17661a4b7ee2SBrad Bishop+ <entry name="xrgb2101010" value="0x30335258"/> 17671a4b7ee2SBrad Bishop+ <entry name="xbgr2101010" value="0x30334258"/> 17681a4b7ee2SBrad Bishop+ <entry name="rgbx1010102" value="0x30335852"/> 17691a4b7ee2SBrad Bishop+ <entry name="bgrx1010102" value="0x30335842"/> 17701a4b7ee2SBrad Bishop+ <entry name="argb2101010" value="0x30335241"/> 17711a4b7ee2SBrad Bishop+ <entry name="abgr2101010" value="0x30334241"/> 17721a4b7ee2SBrad Bishop+ <entry name="rgba1010102" value="0x30334152"/> 17731a4b7ee2SBrad Bishop+ <entry name="bgra1010102" value="0x30334142"/> 17741a4b7ee2SBrad Bishop+ <entry name="yuyv" value="0x56595559"/> 17751a4b7ee2SBrad Bishop+ <entry name="yvyu" value="0x55595659"/> 17761a4b7ee2SBrad Bishop+ <entry name="uyvy" value="0x59565955"/> 17771a4b7ee2SBrad Bishop+ <entry name="vyuy" value="0x59555956"/> 17781a4b7ee2SBrad Bishop+ <entry name="ayuv" value="0x56555941"/> 17791a4b7ee2SBrad Bishop+ <entry name="nv12" value="0x3231564e"/> 17801a4b7ee2SBrad Bishop+ <entry name="nv21" value="0x3132564e"/> 17811a4b7ee2SBrad Bishop+ <entry name="nv16" value="0x3631564e"/> 17821a4b7ee2SBrad Bishop+ <entry name="nv61" value="0x3136564e"/> 17831a4b7ee2SBrad Bishop+ <entry name="yuv410" value="0x39565559"/> 17841a4b7ee2SBrad Bishop+ <entry name="yvu410" value="0x39555659"/> 17851a4b7ee2SBrad Bishop+ <entry name="yuv411" value="0x31315559"/> 17861a4b7ee2SBrad Bishop+ <entry name="yvu411" value="0x31315659"/> 17871a4b7ee2SBrad Bishop+ <entry name="yuv420" value="0x32315559"/> 17881a4b7ee2SBrad Bishop+ <entry name="yvu420" value="0x32315659"/> 17891a4b7ee2SBrad Bishop+ <entry name="yuv422" value="0x36315559"/> 17901a4b7ee2SBrad Bishop+ <entry name="yvu422" value="0x36315659"/> 17911a4b7ee2SBrad Bishop+ <entry name="yuv444" value="0x34325559"/> 17921a4b7ee2SBrad Bishop+ <entry name="yvu444" value="0x34325659"/> 17931a4b7ee2SBrad Bishop+ </enum> 17941a4b7ee2SBrad Bishop+ 17951a4b7ee2SBrad Bishop+ <event name="format"> 17961a4b7ee2SBrad Bishop+ <arg name="format" type="uint"/> 17971a4b7ee2SBrad Bishop+ </event> 17981a4b7ee2SBrad Bishop+ 17991a4b7ee2SBrad Bishop+ <!-- Create a wayland buffer for the DispManX resource. --> 18001a4b7ee2SBrad Bishop+ <request name="create_buffer"> 18011a4b7ee2SBrad Bishop+ <arg name="id" type="new_id" interface="wl_buffer"/> 18021a4b7ee2SBrad Bishop+ <arg name="width" type="int"/> 18031a4b7ee2SBrad Bishop+ <arg name="height" type="int"/> 18041a4b7ee2SBrad Bishop+ <arg name="stride" type="uint"/> 18051a4b7ee2SBrad Bishop+ <arg name="buffer_height" type="uint"/> 18061a4b7ee2SBrad Bishop+ <arg name="format" type="uint"/> 18071a4b7ee2SBrad Bishop+ </request> 18081a4b7ee2SBrad Bishop+ 18091a4b7ee2SBrad Bishop+ <event name="buffer_allocated"> 18101a4b7ee2SBrad Bishop+ <arg name="buffer" type="object" interface="wl_buffer"/> 18111a4b7ee2SBrad Bishop+ <arg name="handle" type="uint"/> 18121a4b7ee2SBrad Bishop+ </event> 18131a4b7ee2SBrad Bishop+ </interface> 18141a4b7ee2SBrad Bishop+ 18151a4b7ee2SBrad Bishop+</protocol> 18161a4b7ee2SBrad Bishopdiff --git a/makefiles/cmake/Wayland.cmake b/makefiles/cmake/Wayland.cmake 18171a4b7ee2SBrad Bishopnew file mode 100644 18181a4b7ee2SBrad Bishopindex 0000000..ad90d30 18191a4b7ee2SBrad Bishop--- /dev/null 18201a4b7ee2SBrad Bishop+++ b/makefiles/cmake/Wayland.cmake 18211a4b7ee2SBrad Bishop@@ -0,0 +1,72 @@ 18221a4b7ee2SBrad Bishop+#============================================================================= 18231a4b7ee2SBrad Bishop+# Copyright (C) 2012-2013 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> 18241a4b7ee2SBrad Bishop+# All rights reserved. 18251a4b7ee2SBrad Bishop+# 18261a4b7ee2SBrad Bishop+# Redistribution and use in source and binary forms, with or without 18271a4b7ee2SBrad Bishop+# modification, are permitted provided that the following conditions 18281a4b7ee2SBrad Bishop+# are met: 18291a4b7ee2SBrad Bishop+# 18301a4b7ee2SBrad Bishop+# * Redistributions of source code must retain the above copyright 18311a4b7ee2SBrad Bishop+# notice, this list of conditions and the following disclaimer. 18321a4b7ee2SBrad Bishop+# 18331a4b7ee2SBrad Bishop+# * Redistributions in binary form must reproduce the above copyright 18341a4b7ee2SBrad Bishop+# notice, this list of conditions and the following disclaimer in the 18351a4b7ee2SBrad Bishop+# documentation and/or other materials provided with the distribution. 18361a4b7ee2SBrad Bishop+# 18371a4b7ee2SBrad Bishop+# * Neither the name of Pier Luigi Fiorini nor the names of his 18381a4b7ee2SBrad Bishop+# contributors may be used to endorse or promote products derived 18391a4b7ee2SBrad Bishop+# from this software without specific prior written permission. 18401a4b7ee2SBrad Bishop+# 18411a4b7ee2SBrad Bishop+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18421a4b7ee2SBrad Bishop+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18431a4b7ee2SBrad Bishop+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18441a4b7ee2SBrad Bishop+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18451a4b7ee2SBrad Bishop+# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 18461a4b7ee2SBrad Bishop+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 18471a4b7ee2SBrad Bishop+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 18481a4b7ee2SBrad Bishop+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 18491a4b7ee2SBrad Bishop+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 18501a4b7ee2SBrad Bishop+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 18511a4b7ee2SBrad Bishop+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 18521a4b7ee2SBrad Bishop+#============================================================================= 18531a4b7ee2SBrad Bishop+ 18541a4b7ee2SBrad Bishop+find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner) 18551a4b7ee2SBrad Bishop+ 18561a4b7ee2SBrad Bishop+# wayland_add_protocol_client(outfiles inputfile basename) 18571a4b7ee2SBrad Bishop+function(WAYLAND_ADD_PROTOCOL_CLIENT _sources _protocol _basename) 18581a4b7ee2SBrad Bishop+ if(NOT WAYLAND_SCANNER_EXECUTABLE) 18591a4b7ee2SBrad Bishop+ message(FATAL "The wayland-scanner executable has nto been found on your system. You must install it.") 18601a4b7ee2SBrad Bishop+ endif() 18611a4b7ee2SBrad Bishop+ 18621a4b7ee2SBrad Bishop+ get_filename_component(_infile ${_protocol} ABSOLUTE) 18631a4b7ee2SBrad Bishop+ set(_client_header "${CMAKE_CURRENT_BINARY_DIR}/wayland-${_basename}-client-protocol.h") 18641a4b7ee2SBrad Bishop+ set(_code "${CMAKE_CURRENT_BINARY_DIR}/wayland-${_basename}-protocol.c") 18651a4b7ee2SBrad Bishop+ 18661a4b7ee2SBrad Bishop+ add_custom_command(OUTPUT "${_client_header}" 18671a4b7ee2SBrad Bishop+ COMMAND ${WAYLAND_SCANNER_EXECUTABLE} client-header < ${_infile} > ${_client_header} 18681a4b7ee2SBrad Bishop+ DEPENDS ${_infile} VERBATIM) 18691a4b7ee2SBrad Bishop+ 18701a4b7ee2SBrad Bishop+ add_custom_command(OUTPUT "${_code}" 18711a4b7ee2SBrad Bishop+ COMMAND ${WAYLAND_SCANNER_EXECUTABLE} code < ${_infile} > ${_code} 18721a4b7ee2SBrad Bishop+ DEPENDS ${_infile} VERBATIM) 18731a4b7ee2SBrad Bishop+ 18741a4b7ee2SBrad Bishop+ list(APPEND ${_sources} "${_client_header}" "${_code}") 18751a4b7ee2SBrad Bishop+ set(${_sources} ${${_sources}} PARENT_SCOPE) 18761a4b7ee2SBrad Bishop+endfunction() 18771a4b7ee2SBrad Bishop+ 18781a4b7ee2SBrad Bishop+# wayland_add_protocol_server(outfiles inputfile basename) 18791a4b7ee2SBrad Bishop+function(WAYLAND_ADD_PROTOCOL_SERVER _sources _protocol _basename) 18801a4b7ee2SBrad Bishop+ if(NOT WAYLAND_SCANNER_EXECUTABLE) 18811a4b7ee2SBrad Bishop+ message(FATAL "The wayland-scanner executable has nto been found on your system. You must install it.") 18821a4b7ee2SBrad Bishop+ endif() 18831a4b7ee2SBrad Bishop+ 18841a4b7ee2SBrad Bishop+ get_filename_component(_infile ${_protocol} ABSOLUTE) 18851a4b7ee2SBrad Bishop+ set(_server_header "${CMAKE_CURRENT_BINARY_DIR}/wayland-${_basename}-server-protocol.h") 18861a4b7ee2SBrad Bishop+ 18871a4b7ee2SBrad Bishop+ add_custom_command(OUTPUT "${_server_header}" 18881a4b7ee2SBrad Bishop+ COMMAND ${WAYLAND_SCANNER_EXECUTABLE} server-header < ${_infile} > ${_server_header} 18891a4b7ee2SBrad Bishop+ DEPENDS ${_infile} VERBATIM) 18901a4b7ee2SBrad Bishop+ 18911a4b7ee2SBrad Bishop+ list(APPEND ${_sources} "${_server_header}") 18921a4b7ee2SBrad Bishop+ set(${_sources} ${${_sources}} PARENT_SCOPE) 18931a4b7ee2SBrad Bishop+endfunction() 1894