Skip to content

Instantly share code, notes, and snippets.

@xc-racer99
Last active June 25, 2019 01:25
Show Gist options
  • Save xc-racer99/396529a1bbde308300181cd3a44f6556 to your computer and use it in GitHub Desktop.
Save xc-racer99/396529a1bbde308300181cd3a44f6556 to your computer and use it in GitHub Desktop.
Updated sgx-wayland patches for use via libhybris - Untested!!!
From 86cdfdeac651e63496433988b2d8f327fdb9f5ec Mon Sep 17 00:00:00 2001
From: Jonathan Bakker <xc-racer2@live.ca>
Date: Sat, 15 Jun 2019 17:20:53 -0700
Subject: [PATCH 1/5] Re-add pvr2d.h and wsegl.h
---
LICENSE | 71 ++++++
common/pvr2d.h | 669 +++++++++++++++++++++++++++++++++++++++++++++++++
libwayland-egl/wsegl.h | 352 ++++++++++++++++++++++++++
3 files changed, 1092 insertions(+)
create mode 100644 common/pvr2d.h
create mode 100644 libwayland-egl/wsegl.h
diff --git a/LICENSE b/LICENSE
index 9448ebc..0043e18 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,28 @@
+wsegl.h:
+
+/******************************************************************************
+ Name : wsegl.h
+ Copyright : Copyright (c) Imagination Technologies Limited.
+ This specification is protected by copyright laws and contains
+ material proprietary to Imagination Technologies Limited.
+ You may use and distribute this specification free of charge for implementing
+ the functionality therein, without altering or removing any trademark, copyright,
+ or other notice from the specification.
+ Platform : ANSI
+*****************************************************************************/
+
+Origin:
+
+https://qt.gitorious.org/qt/qt/blobs/4.7/src/3rdparty/powervr/wsegl.h
+
+Comment:
+
+Newer version also exists in
+http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/gfxsdk/latest/index_FDS.html
+
+Release notes at http://processors.wiki.ti.com/index.php/RN_4_03_00_02
+
linux/omapfb.h:
/*
@@ -34,7 +58,54 @@ Comment:
Similar method as used in xserver-xorg-video-fbdev (SGX variant)
+common/pvr2d.h:
+
+**********************************************************************
+*
+* Copyright(c) Imagination Technologies Ltd.
+*
+* The contents of this file are subject to the MIT license as set out below.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy
+* of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+* CLAIM,
+* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
+* OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*
+* This License is also included in this distribution in the file called
+* "COPYING".
+*
+***************************************
+
+Origin:
+
+http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/gfxsdk/latest/index_FDS.html
+
+Release notes at http://processors.wiki.ti.com/index.php/RN_4_03_00_02
+
+Comment:
+
+Exact file not used in code, instead SGX driver's header file is used. Older
+version also exists in Qt tree at
+https://qt.gitorious.org/qt/qt/blobs/4.7/src/3rdparty/powervr/pvr2d.h
+What is used from here especially is the PVR2DMemExport and PVR2DMemMap
+calls, used to share hardware buffers across processes.
waylandwsegl.c/wayland-egl.c/wayland-egl-priv.h is described per feature added.
diff --git a/common/pvr2d.h b/common/pvr2d.h
new file mode 100644
index 0000000..5dce7cf
--- /dev/null
+++ b/common/pvr2d.h
@@ -0,0 +1,669 @@
+/**********************************************************************
+*
+* Copyright(c) Imagination Technologies Ltd.
+*
+* The contents of this file are subject to the MIT license as set out below.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
+* OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*
+* This License is also included in this distribution in the file called
+* "COPYING".
+*
+******************************************************************************/
+
+
+
+/******************************************************************************
+Modifications :-
+$Log: pvr2d.h $
+
+ --- Revision Logs Removed ---
+******************************************************************************/
+
+#ifndef _PVR2D_H_
+#define _PVR2D_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* PVR2D Platform-specific definitions */
+#if defined (__linux__)
+#define PVR2D_EXPORT __attribute__((visibility("default")))
+#define PVR2D_IMPORT
+#else
+#define PVR2D_EXPORT
+#define PVR2D_IMPORT
+#endif
+
+/* PVR2D header revision */
+#define PVR2D_REV_MAJOR 3
+#define PVR2D_REV_MINOR 5
+
+/* Basic types */
+typedef enum
+{
+ PVR2D_FALSE = 0,
+ PVR2D_TRUE
+} PVR2D_BOOL;
+
+typedef void* PVR2D_HANDLE;
+
+typedef char PVR2D_CHAR, *PVR2D_PCHAR;
+typedef unsigned char PVR2D_UCHAR, *PVR2D_PUCHAR;
+typedef int PVR2D_INT, *PVR2D_PINT;
+typedef unsigned int PVR2D_UINT, *PVR2D_PUINT;
+typedef long PVR2D_LONG, *PVR2D_PLONG;
+typedef unsigned long PVR2D_ULONG, *PVR2D_PULONG;
+
+typedef void PVR2D_VOID, *PVR2D_PVOID;
+
+
+/* error codes */
+typedef enum
+{
+ PVR2D_OK = 0,
+ PVR2DERROR_INVALID_PARAMETER = -1,
+ PVR2DERROR_DEVICE_UNAVAILABLE = -2,
+ PVR2DERROR_INVALID_CONTEXT = -3,
+ PVR2DERROR_MEMORY_UNAVAILABLE = -4,
+ PVR2DERROR_DEVICE_NOT_PRESENT = -5,
+ PVR2DERROR_IOCTL_ERROR = -6,
+ PVR2DERROR_GENERIC_ERROR = -7,
+ PVR2DERROR_BLT_NOTCOMPLETE = -8,
+ PVR2DERROR_HW_FEATURE_NOT_SUPPORTED = -9,
+ PVR2DERROR_NOT_YET_IMPLEMENTED = -10,
+ PVR2DERROR_MAPPING_FAILED = -11
+}PVR2DERROR;
+
+/* 32 bit PVR2D pixel format specifier */
+typedef unsigned long PVR2DFORMAT;
+
+/* Standard PVR2D pixel formats */
+#define PVR2D_1BPP 0x00UL // 1bpp mask surface or palletized 1 bit source with 2x32 bit CLUT
+#define PVR2D_RGB565 0x01UL // Common rgb 565 format
+#define PVR2D_ARGB4444 0x02UL // Common argb 4444 format
+#define PVR2D_RGB888 0x03UL // Common rgb 888 format (not supported)
+#define PVR2D_ARGB8888 0x04UL // Common argb 8888 format
+#define PVR2D_ARGB1555 0x05UL // Common argb 1555 format
+#define PVR2D_ALPHA8 0x06UL // Alpha-only 8 bit per pixel (used with a constant fill colour)
+#define PVR2D_ALPHA4 0x07UL // Alpha-only 4 bits per pixel (used with a constant fill colour)
+#define PVR2D_PAL2 0x08UL // Palletized 2 bit format (requires 4x32 bit CLUT)
+#define PVR2D_PAL4 0x09UL // Palletized 4 bit format (requires 16x32 bit CLUT)
+#define PVR2D_PAL8 0x0AUL // Palletized 8 bit format (requires 256x32 bit CLUT)
+#define PVR2D_U8 0x10UL // monochrome unsigned 8 bit
+#define PVR2D_U88 0x11UL // monochrome unsigned 16 bit
+#define PVR2D_S8 0x12UL // signed 8 bit
+#define PVR2D_YUV422_YUYV 0x13UL // YUV 422 low-high byte order Y0UY1V
+#define PVR2D_YUV422_UYVY 0x14UL // YUV 422 low-high byte order UY0VY1
+#define PVR2D_YUV422_YVYU 0x15UL // YUV 422 low-high byte order Y0VY1U
+#define PVR2D_YUV422_VYUY 0x16UL // YUV 422 low-high byte order VY0UY1
+#define PVR2D_YUV420_2PLANE 0x17UL // YUV420 2 Plane
+#define PVR2D_YUV420_3PLANE 0x18UL // YUV420 3 Plane
+#define PVR2D_2101010ARGB 0x19UL // 32 bit 2 10 10 10
+#define PVR2D_888RSGSBS 0x1AUL
+#define PVR2D_16BPP_RAW 0x1BUL // 16 bit raw (no format conversion)
+#define PVR2D_32BPP_RAW 0x1CUL // 32 bit raw
+#define PVR2D_64BPP_RAW 0x1DUL // 64 bit raw
+#define PVR2D_128BPP_RAW 0x1EUL // 128 bit raw
+
+#define PVR2D_NO_OF_FORMATS 0x1FUL
+
+/* Format modifier bit field (DstFormat and SrcFormat bits 16..23) */
+#define PVR2D_FORMAT_MASK 0x0000FFFFUL // PVR2D Format bits
+#define PVR2D_FORMAT_LAYOUT_MASK 0x000F0000UL // Format layout (strided / twiddled / tiled)
+#define PVR2D_FORMAT_FLAGS_MASK 0x0FF00000UL // Surface Flags mask
+
+/* Layout */
+#define PVR2D_FORMAT_LAYOUT_SHIFT 16
+#define PVR2D_FORMAT_LAYOUT_STRIDED 0x00000000UL
+#define PVR2D_FORMAT_LAYOUT_TILED 0x00010000UL
+#define PVR2D_FORMAT_LAYOUT_TWIDDLED 0x00020000UL
+
+/*
+ PVR2D_SURFACE_PDUMP
+ This flag requests a surface pdump, to capture the pixel state after host writes.
+ Not needed if the surface state has resulted from previous SGX 2D/3D core writes.
+*/
+#define PVR2D_SURFACE_PDUMP 0x00100000UL // calls PVRSRVPDumpMem to capture the surface (pdump builds only)
+
+/*
+ Low level 3D format extension - for blts via the 3D core only.
+ If the top bit of the format field is set then PVR2D reads it as a PVRSRV_PIXEL_FORMAT.
+ The outcome is hardware dependant.
+ There is no guarantee that any specific PVRSRV format will be supported.
+*/
+#define PVR2D_FORMAT_PVRSRV 0x80000000
+
+/* wrap surface type */
+typedef enum
+{
+ PVR2D_WRAPFLAG_NONCONTIGUOUS = 0,
+ PVR2D_WRAPFLAG_CONTIGUOUS = 1,
+
+}PVR2DWRAPFLAGS;
+
+#define PVR2D_CONTEXT_FLAGS_PRIORITY_MASK 0x00000003
+
+#define PVR2D_CONTEXT_FLAGS_LOW_PRIORITY_CONTEXT 1
+#define PVR2D_CONTEXT_FLAGS_NORMAL_PRIORITY_CONTEXT 0
+#define PVR2D_CONTEXT_FLAGS_HIGH_PRIORITY_CONTEXT 2
+
+/* flags for control information of additional blits */
+typedef enum
+{
+ PVR2D_BLIT_DISABLE_ALL = 0x00000000, /* disable all additional controls */
+ PVR2D_BLIT_CK_ENABLE = 0x00000001, /* enable colour key */
+ PVR2D_BLIT_GLOBAL_ALPHA_ENABLE = 0x00000002, /* enable standard global alpha */
+ PVR2D_BLIT_PERPIXEL_ALPHABLEND_ENABLE = 0x00000004, /* enable per-pixel alpha bleding */
+ PVR2D_BLIT_PAT_SURFACE_ENABLE = 0x00000008, /* enable pattern surf (disable fill) */
+ PVR2D_BLIT_FULLY_SPECIFIED_ALPHA_ENABLE = 0x00000010, /* enable fully specified alpha */
+ PVR2D_BLIT_ROT_90 = 0x00000020, /* apply 90 degree rotation to the blt */
+ PVR2D_BLIT_ROT_180 = 0x00000040, /* apply 180 degree rotation to the blt */
+ PVR2D_BLIT_ROT_270 = 0x00000080, /* apply 270 degree rotation to the blt */
+ PVR2D_BLIT_COPYORDER_TL2BR = 0x00000100, /* copy order overrides */
+ PVR2D_BLIT_COPYORDER_BR2TL = 0x00000200,
+ PVR2D_BLIT_COPYORDER_TR2BL = 0x00000400,
+ PVR2D_BLIT_COPYORDER_BL2TR = 0x00000800,
+ PVR2D_BLIT_COLKEY_SOURCE = 0x00001000, /* Key colour is on the source surface */
+ PVR2D_BLIT_COLKEY_DEST = 0x00002000, /* Key colour is on the destination surface */
+ PVR2D_BLIT_COLKEY_MASKED = 0x00004000, /* Mask enabled for colour key */
+ PVR2D_BLIT_COLKEY_OP_PASS = 0x00008000, /* Colour key op = pass */
+ PVR2D_BLIT_COLKEY_OP_REJECT = 0x00010000, /* Colour key op = reject */
+ PVR2D_BLIT_PATH_2DCORE = 0x00100000, /* Blt via dedicated 2D Core or PTLA */
+ PVR2D_BLIT_PATH_3DCORE = 0x00200000, /* Blt via 3D Core */
+ PVR2D_BLIT_PATH_SWBLT = 0x00400000, /* Blt via host software */
+ PVR2D_BLIT_NO_SRC_SYNC_INFO = 0x00800000, /* Dont send a source sync info*/
+ PVR2D_BLIT_ISSUE_STATUS_UPDATES = 0x01000000, /* Issue status updates */
+
+} PVR2DBLITFLAGS;
+
+/* standard alpha-blending functions, AlphaBlendingFunc field of PVR2DBLTINFO */
+typedef enum
+{
+ PVR2D_ALPHA_OP_SRC_DSTINV = 1, /* source alpha : Cdst = Csrc*Asrc + Cdst*(1-Asrc) */
+ PVR2D_ALPHA_OP_SRCP_DSTINV = 2 /* premultiplied source alpha : Cdst = Csrc + Cdst*(1-Asrc) */
+} PVR2D_ALPHABLENDFUNC;
+
+/* blend ops for fully specified alpha (SGX 2D Core only) */
+typedef enum
+{
+ PVR2D_BLEND_OP_ZERO = 0,
+ PVR2D_BLEND_OP_ONE = 1,
+ PVR2D_BLEND_OP_SRC = 2,
+ PVR2D_BLEND_OP_DST = 3,
+ PVR2D_BLEND_OP_GLOBAL = 4,
+ PVR2D_BLEND_OP_SRC_PLUS_GLOBAL = 5,
+ PVR2D_BLEND_OP_DST_PLUS_GLOBAL = 6
+}PVR2D_BLEND_OP;
+
+/* SGX 2D Core Fully specified alpha blend : pAlpha field of PVR2DBLTINFO structure */
+/* a fully specified Alpha Blend operation is defined as */
+/* DST (ALPHA) = (ALPHA_1 * SRC (ALPHA)) + (ALPHA_3 * DST (ALPHA)) */
+/* DST (RGB) = (ALPHA_2 * SRC (RGB)) + (ALPHA_4 * DST (RGB)) */
+/* if the pre-multiplication stage is enabled then the equations become the following: */
+/* PRE_MUL = ((SRC(A)) * (Global Alpha Value)) */
+/* DST (ALPHA) = (ALPHA_1 * SRC (ALPHA)) + (PRE_MUL * DST (ALPHA)) */
+/* DST (RGB) = (ALPHA_2 * SRC (RGB)) + (PRE_MUL * DST (RGB)) */
+/* if the transparent source alpha stage is enabled then a source alpha of zero forces the */
+/* source to be transparent for that pixel regardless of the blend equation being used. */
+typedef struct _PVR2D_ALPHABLT
+{
+ PVR2D_BLEND_OP eAlpha1;
+ PVR2D_BOOL bAlpha1Invert;
+ PVR2D_BLEND_OP eAlpha2;
+ PVR2D_BOOL bAlpha2Invert;
+ PVR2D_BLEND_OP eAlpha3;
+ PVR2D_BOOL bAlpha3Invert;
+ PVR2D_BLEND_OP eAlpha4;
+ PVR2D_BOOL bAlpha4Invert;
+ PVR2D_BOOL bPremulAlpha; /* enable pre-multiplication stage */
+ PVR2D_BOOL bTransAlpha; /* enable transparent source alpha stage */
+ PVR2D_BOOL bUpdateAlphaLookup; /* enable and update the 1555-Lookup alpha table */
+ PVR2D_UCHAR uAlphaLookup0; /* 8 bit alpha when A=0 in a 1555-Lookup surface */
+ PVR2D_UCHAR uAlphaLookup1; /* 8 bit alpha when A=1 in a 1555-Lookup surface */
+ PVR2D_UCHAR uGlobalRGB; /* Global Alpha Value for RGB, 0=transparent 255=opaque */
+ PVR2D_UCHAR uGlobalA; /* Global Alpha Value for Alpha */
+
+} PVR2D_ALPHABLT, *PPVR2D_ALPHABLT;
+
+
+/* surface memory info structure */
+typedef struct _PVR2DMEMINFO
+{
+ PVR2D_VOID *pBase;
+ PVR2D_ULONG ui32MemSize;
+ PVR2D_ULONG ui32DevAddr;
+ PVR2D_ULONG ulFlags;
+ PVR2D_VOID *hPrivateData;
+ PVR2D_VOID *hPrivateMapData;
+
+}PVR2DMEMINFO, *PPVR2DMEMINFO;
+
+
+#define PVR2D_MAX_DEVICE_NAME 20
+
+typedef struct _PVR2DDEVICEINFO
+{
+ PVR2D_ULONG ulDevID;
+ PVR2D_CHAR szDeviceName[PVR2D_MAX_DEVICE_NAME];
+}PVR2DDEVICEINFO;
+
+
+typedef struct _PVR2DISPLAYINFO
+{
+ PVR2D_ULONG ulMaxFlipChains;
+ PVR2D_ULONG ulMaxBuffersInChain;
+ PVR2DFORMAT eFormat;
+ PVR2D_ULONG ulWidth;
+ PVR2D_ULONG ulHeight;
+ PVR2D_LONG lStride;
+ PVR2D_ULONG ulMinFlipInterval;
+ PVR2D_ULONG ulMaxFlipInterval;
+
+}PVR2DDISPLAYINFO;
+
+
+typedef struct _PVR2MISCDISPLAYINFO
+{
+ PVR2D_ULONG ulPhysicalWidthmm;
+ PVR2D_ULONG ulPhysicalHeightmm;
+ PVR2D_ULONG ulUnused[10];
+
+}PVR2DMISCDISPLAYINFO;
+
+
+typedef struct _PVR2DBLTINFO
+{
+ PVR2D_ULONG CopyCode; /* rop code */
+ PVR2D_ULONG Colour; /* fill colour */
+ PVR2D_ULONG ColourKey; /* colour key argb8888 (see CKEY_ defs below) */
+ PVR2D_UCHAR GlobalAlphaValue; /* global alpha blending */
+ PVR2D_UCHAR AlphaBlendingFunc; /* per-pixel alpha-blending function */
+
+ PVR2DBLITFLAGS BlitFlags; /* additional blit control information */
+
+ PVR2DMEMINFO *pDstMemInfo; /* destination memory */
+ PVR2D_ULONG DstOffset; /* byte offset from start of allocation to destination surface pixel 0,0 */
+ PVR2D_LONG DstStride; /* signed stride, the number of bytes from pixel 0,0 to 0,1 */
+ PVR2D_LONG DstX, DstY; /* pixel offset from start of dest surface to start of blt rectangle */
+ PVR2D_LONG DSizeX,DSizeY; /* blt size */
+ PVR2DFORMAT DstFormat; /* dest format */
+ PVR2D_ULONG DstSurfWidth; /* size of dest surface in pixels */
+ PVR2D_ULONG DstSurfHeight; /* size of dest surface in pixels */
+
+ PVR2DMEMINFO *pSrcMemInfo; /* source mem, (source fields are also used for patterns) */
+ PVR2D_ULONG SrcOffset; /* byte offset from start of allocation to src/pat surface pixel 0,0 */
+ PVR2D_LONG SrcStride; /* signed stride, the number of bytes from pixel 0,0 to 0,1 */
+ PVR2D_LONG SrcX, SrcY; /* pixel offset from start of surface to start of source rectangle */
+ /* for patterns this is the start offset within the pattern */
+ PVR2D_LONG SizeX,SizeY; /* source rectangle size or pattern size in pixels */
+ PVR2DFORMAT SrcFormat; /* source/pattern format */
+ PVR2DMEMINFO *pPalMemInfo; /* source/pattern palette memory containing argb8888 colour table */
+ PVR2D_ULONG PalOffset; /* byte offset from start of allocation to start of palette */
+ PVR2D_ULONG SrcSurfWidth; /* size of source surface in pixels */
+ PVR2D_ULONG SrcSurfHeight; /* size of source surface in pixels */
+
+ PVR2DMEMINFO *pMaskMemInfo; /* mask memory, 1bpp format implied */
+ PVR2D_ULONG MaskOffset; /* byte offset from start of allocation to mask surface pixel 0,0 */
+ PVR2D_LONG MaskStride; /* signed stride, the number of bytes from pixel 0,0 to 0,1 */
+ PVR2D_LONG MaskX, MaskY; /* mask rect top left (mask size = blt size) */
+ PVR2D_ULONG MaskSurfWidth; /* size of mask surface in pixels */
+ PVR2D_ULONG MaskSurfHeight; /* size of mask surface in pixels */
+
+ PPVR2D_ALPHABLT pAlpha; /* fully specified alpha blend (2DCore only) */
+
+ PVR2D_ULONG uSrcChromaPlane1; /* mem offset from start of source alloc to chroma plane 1 */
+ PVR2D_ULONG uSrcChromaPlane2; /* mem offset from start of source alloc to chroma plane 2 */
+ PVR2D_ULONG uDstChromaPlane1; /* mem offset from start of dest alloc to chroma plane 1 */
+ PVR2D_ULONG uDstChromaPlane2; /* mem offset from start of dest alloc to chroma plane 2 */
+
+ PVR2D_ULONG ColourKeyMask; /* 32 bit colour key mask, only valid when PVR2D_BLIT_COLKEY_MASKED is set */
+
+}PVR2DBLTINFO, *PPVR2DBLTINFO;
+
+typedef struct _PVR2DRECT
+{
+ PVR2D_LONG left, top;
+ PVR2D_LONG right, bottom;
+} PVR2DRECT;
+
+typedef struct
+{
+ PVR2DMEMINFO *pSurfMemInfo; /* surface memory */
+ PVR2D_ULONG SurfOffset; /* byte offset from start of allocation to destination surface pixel 0,0 */
+ PVR2D_LONG Stride; /* signed stride */
+ PVR2DFORMAT Format; /* format */
+ PVR2D_ULONG SurfWidth; /* surface width in pixels */
+ PVR2D_ULONG SurfHeight; /* surface height in pixels */
+
+} PVR2D_SURFACE, *PPVR2D_SURFACE;
+
+typedef struct
+{
+ PVR2D_ULONG uChromaPlane1; /* YUV multiplane - byte offset from start of alloc to chroma plane 1 */
+ PVR2D_ULONG uChromaPlane2; /* YUV multiplane - byte offset from start of alloc to chroma plane 2 */
+ PVR2D_LONG Reserved[2]; /* Reserved, must be zero */
+
+} PVR2D_SURFACE_EXT, *PPVR2D_SURFACE_EXT;
+
+typedef struct
+{
+ PVR2D_ULONG *pUseCode; /* USSE code */
+ PVR2D_ULONG UseCodeSize; /* usse code size in bytes */
+
+} PVR2D_USECODE, *PPVR2D_USECODE;
+
+typedef struct
+{
+ PVR2D_SURFACE sDst; /* destination surface */
+ PVR2D_SURFACE sSrc; /* source surface */
+ PVR2DRECT rcDest; /* destination rectangle */
+ PVR2DRECT rcSource; /* source rectangle */
+ PVR2D_HANDLE hUseCode; /* custom USE code (NULL implies source copy) */
+ PVR2D_ULONG UseParams[2]; /* per-blt params for use code */
+
+} PVR2D_3DBLT, *PPVR2D_3DBLT;
+
+typedef struct
+{
+ PVR2D_SURFACE sDst; /* destination surface */
+ PVR2DRECT rcDest; /* destination rectangle; scaling is supported */
+ PVR2D_SURFACE sSrc; /* source surface */
+ PVR2DRECT rcSource; /* source rectangle; scaling is supported */
+ PPVR2D_SURFACE pSrc2; /* optional second source surface (NULL if not required) */
+ PVR2DRECT* prcSource2; /* optional pSrc2 rectangle */
+ PVR2D_HANDLE hUseCode; /* custom USSE shader code (NULL implies default source copy) */
+ PVR2D_ULONG UseParams[2]; /* per-blt params for usse code */
+ PVR2D_ULONG uiNumTemporaryRegisters; /* no. of temporary registers used in custom shader code */
+ PVR2D_BOOL bDisableDestInput; /* set true if the destination is output only */
+ PPVR2D_SURFACE_EXT pDstExt; /* Extended format params for dest */
+ PPVR2D_SURFACE_EXT pSrcExt[2]; /* Extended format params for source 1 and 2 */
+ PVR2D_LONG Reserved[4]; /* Reserved, must be zero */
+
+} PVR2D_3DBLT_EXT, *PPVR2D_3DBLT_EXT;
+
+
+#define MAKE_COPY_BLIT(src,soff,dest,doff,sx,sy,dx,dy,sz)
+
+typedef void* PVR2DCONTEXTHANDLE;
+typedef void* PVR2DFLIPCHAINHANDLE;
+
+
+// CopyCode field of PVR2DBLTINFO structure:
+// the CopyCode field of the PVR2DBLTINFO structure should contain a rop3 or rop4 code.
+// a rop3 is an 8 bit code that describes a blt with three inputs : source dest and pattern
+// rop4 is a 16 bit code that describes a blt with four inputs : source dest pattern and mask
+// common rop3 codes are defined below
+// a colour fill blt is processed in the pattern channel as a constant colour with a rop code of 0xF0
+// PVR2D_BLIT_PAT_SURFACE_ENABLE defines whether the pattern channel is a surface or a fill colour.
+// a rop4 is defined by two rop3 codes, and the 1 bit-per-pixel mask surface defines which is used.
+// a common rop4 is 0xAAF0 which is the mask copy blt used for text glyphs.
+// CopyCode is taken to be a rop4 when pMaskMemInfo is non zero, otherwise it is assumed to be a rop3
+// use the PVR2DMASKROP4 macro below to construct a rop4 from two rop3's
+// rop3a is the rop used when mask pixel = 1, and rop3b when mask = 0
+#define PVR2DROP4(rop3b, rop3a) ((rop3b<<8)|rop3a)
+
+/* common rop codes */
+#define PVR2DROPclear 0x00 /* 0 (whiteness) */
+#define PVR2DROPset 0xFF /* 1 (blackness) */
+#define PVR2DROPnoop 0xAA /* dst (used for masked blts) */
+
+/* source and dest rop codes */
+#define PVR2DROPand 0x88 /* src AND dst */
+#define PVR2DROPandReverse 0x44 /* src AND NOT dst */
+#define PVR2DROPcopy 0xCC /* src (used for source copy and alpha blts) */
+#define PVR2DROPandInverted 0x22 /* NOT src AND dst */
+#define PVR2DROPxor 0x66 /* src XOR dst */
+#define PVR2DROPor 0xEE /* src OR dst */
+#define PVR2DROPnor 0x11 /* NOT src AND NOT dst */
+#define PVR2DROPequiv 0x99 /* NOT src XOR dst */
+#define PVR2DROPinvert 0x55 /* NOT dst */
+#define PVR2DROPorReverse 0xDD /* src OR NOT dst */
+#define PVR2DROPcopyInverted 0x33 /* NOT src */
+#define PVR2DROPorInverted 0xBB /* NOT src OR dst */
+#define PVR2DROPnand 0x77 /* NOT src OR NOT dst */
+
+/* pattern rop codes */
+#define PVR2DPATROPand 0xA0 /* pat AND dst */
+#define PVR2DPATROPandReverse 0x50 /* pat AND NOT dst */
+#define PVR2DPATROPcopy 0xF0 /* pat (used for solid color fills and pattern blts) */
+#define PVR2DPATROPandInverted 0x0A /* NOT pat AND dst */
+#define PVR2DPATROPxor 0x5A /* pat XOR dst */
+#define PVR2DPATROPor 0xFA /* pat OR dst */
+#define PVR2DPATROPnor 0x05 /* NOT pat AND NOT dst */
+#define PVR2DPATROPequiv 0xA5 /* NOT pat XOR dst */
+#define PVR2DPATROPinvert 0x55 /* NOT dst */
+#define PVR2DPATROPorReverse 0xF5 /* pat OR NOT dst */
+#define PVR2DPATROPcopyInverted 0x0F /* NOT pat */
+#define PVR2DPATROPorInverted 0xAF /* NOT pat OR dst */
+#define PVR2DPATROPnand 0x5F /* NOT pat OR NOT dst */
+
+/* common rop4 codes */
+#define PVR2DROP4MaskedCopy PVR2DROP4(PVR2DROPnoop,PVR2DROPcopy) /* masked source copy blt (used for rounded window corners etc) */
+#define PVR2DROP4MaskedFill PVR2DROP4(PVR2DROPnoop,PVR2DPATROPcopy) /* masked colour fill blt (used for text) */
+
+/* Legacy support */
+#define PVR2DROP3_PATMASK PVR2DPATROPcopy
+#define PVR2DROP3_SRCMASK PVR2DROPcopy
+
+/* pixmap memory alignment */
+#define PVR2D_ALIGNMENT_4 4 /* DWORD alignment */
+#define PVR2D_ALIGNMENT_ANY 0 /* no alignment */
+#define PVR2D_ALIGNMENT_PALETTE 16 /* 16 byte alignment is required for palettes */
+
+/* Heap number for PVR2DGetFrameBuffer */
+#define PVR2D_FB_PRIMARY_SURFACE 0
+
+#define PVR2D_PRESENT_PROPERTY_SRCSTRIDE (1UL << 0)
+#define PVR2D_PRESENT_PROPERTY_DSTSIZE (1UL << 1)
+#define PVR2D_PRESENT_PROPERTY_DSTPOS (1UL << 2)
+#define PVR2D_PRESENT_PROPERTY_CLIPRECTS (1UL << 3)
+#define PVR2D_PRESENT_PROPERTY_INTERVAL (1UL << 4)
+
+#define PVR2D_CREATE_FLIPCHAIN_SHARED (1UL << 0)
+#define PVR2D_CREATE_FLIPCHAIN_QUERY (1UL << 1)
+#define PVR2D_CREATE_FLIPCHAIN_OEMOVERLAY (1UL << 2)
+#define PVR2D_CREATE_FLIPCHAIN_AS_BLITCHAIN (1UL << 3)
+
+/* Colour-key colour must be translated into argb8888 format */
+#define CKEY_8888(P) (P)
+#define CKEY_4444(P) (((P&0xF000UL)<<16) | ((P&0x0F00UL)<<12) | ((P&0x00F0UL)<<8) | ((P&0x000FUL)<<4))
+#define CKEY_1555(P) (((P&0x8000UL)<<16) | ((P&0x7C00UL)<<9) | ((P&0x3E0UL)<<6) | ((P&0x1FUL)<<3))
+#define CKEY_565(P) (((P&0xF800UL)<<8) | ((P&0x7E0UL)<<5) | ((P&0x1FUL)<<3))
+#define CKEY_MASK_8888 0x00FFFFFFUL
+#define CKEY_MASK_4444 0x00F0F0F0UL
+#define CKEY_MASK_1555 0x00F8F8F8UL /* Alpha is not normally included in the key test */
+#define CKEY_MASK_565 0x00F8FCF8UL
+
+/* Fill colours must be translated into argb8888 format */
+#define CFILL_4444(P) (((P&0xF000UL)<<16) | ((P&0x0F00UL)<<12) | ((P&0x00F0UL)<<8) | ((P&0x000FUL)<<4))
+#define CFILL_1555(P) (((P&0x8000UL)<<16) | ((P&0x7C00UL)<<9) | ((P&0x3E0UL)<<6) | ((P&0x1FUL)<<3))
+#define CFILL_565(P) (((P&0xF800UL)<<8) | ((P&0x7E0UL)<<5) | ((P&0x1FUL)<<3))
+
+/* PVR2DCreateDeviceContext flags */
+#define PVR2D_XSERVER_PROC 0x00000001UL /*!< Set for the Xserver connection */
+
+/* PVR2DMemAlloc flags */
+#define PVR2D_MEM_UNCACHED 0x00000000UL /* Default */
+#define PVR2D_MEM_CACHED 0x00000001UL /* Caller must flush and sync when necessary */
+#define PVR2D_MEM_WRITECOMBINE 0x00000002UL
+
+/* Functions that the library exports */
+
+PVR2D_IMPORT
+int PVR2DEnumerateDevices(PVR2DDEVICEINFO *pDevInfo);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DCreateDeviceContext(PVR2D_ULONG ulDevID,
+ PVR2DCONTEXTHANDLE* phContext,
+ PVR2D_ULONG ulFlags);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DDestroyDeviceContext(PVR2DCONTEXTHANDLE hContext);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DGetDeviceInfo(PVR2DCONTEXTHANDLE hContext,
+ PVR2DDISPLAYINFO *pDisplayInfo);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DGetMiscDisplayInfo(PVR2DCONTEXTHANDLE hContext,
+ PVR2DMISCDISPLAYINFO *pMiscDisplayInfo);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DGetScreenMode(PVR2DCONTEXTHANDLE hContext,
+ PVR2DFORMAT *pFormat,
+ PVR2D_LONG *plWidth,
+ PVR2D_LONG *plHeight,
+ PVR2D_LONG *plStride,
+ PVR2D_INT *piRefreshRate);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DGetFrameBuffer(PVR2DCONTEXTHANDLE hContext,
+ PVR2D_INT nHeap,
+ PVR2DMEMINFO **ppsMemInfo);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DMemAlloc(PVR2DCONTEXTHANDLE hContext,
+ PVR2D_ULONG ulBytes,
+ PVR2D_ULONG ulAlign,
+ PVR2D_ULONG ulFlags,
+ PVR2DMEMINFO **ppsMemInfo);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DMemExport(PVR2DCONTEXTHANDLE hContext,
+ PVR2D_ULONG ulFlags,
+ PVR2DMEMINFO *psMemInfo,
+ PVR2D_HANDLE *phMemHandle);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DMemWrap(PVR2DCONTEXTHANDLE hContext,
+ PVR2D_VOID *pMem,
+ PVR2D_ULONG ulFlags,
+ PVR2D_ULONG ulBytes,
+ PVR2D_ULONG alPageAddress[],
+ PVR2DMEMINFO **ppsMemInfo);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DMemMap(PVR2DCONTEXTHANDLE hContext,
+ PVR2D_ULONG ulFlags,
+ PVR2D_HANDLE hMemHandle,
+ PVR2DMEMINFO **ppsDstMem);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DMemFree(PVR2DCONTEXTHANDLE hContext,
+ PVR2DMEMINFO *psMemInfo);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DBlt(PVR2DCONTEXTHANDLE hContext,
+ PVR2DBLTINFO *pBltInfo);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DBltClipped(PVR2DCONTEXTHANDLE hContext,
+ PVR2DBLTINFO *pBltInfo,
+ PVR2D_ULONG ulNumClipRects,
+ PVR2DRECT *pClipRects);
+
+PVR2D_EXPORT
+PVR2DERROR PVR2DSet1555Alpha (PVR2DCONTEXTHANDLE hContext,
+ PVR2D_UCHAR Alpha0, PVR2D_UCHAR Alpha1);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DQueryBlitsComplete(PVR2DCONTEXTHANDLE hContext,
+ const PVR2DMEMINFO *pMemInfo,
+ PVR2D_UINT uiWaitForComplete);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DSetPresentBltProperties(PVR2DCONTEXTHANDLE hContext,
+ PVR2D_ULONG ulPropertyMask,
+ PVR2D_LONG lSrcStride,
+ PVR2D_ULONG ulDstWidth,
+ PVR2D_ULONG ulDstHeight,
+ PVR2D_LONG lDstXPos,
+ PVR2D_LONG lDstYPos,
+ PVR2D_ULONG ulNumClipRects,
+ PVR2DRECT *pClipRects,
+ PVR2D_ULONG ulSwapInterval);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DPresentBlt(PVR2DCONTEXTHANDLE hContext,
+ PVR2DMEMINFO *pMemInfo,
+ PVR2D_LONG lRenderID);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DCreateFlipChain(PVR2DCONTEXTHANDLE hContext,
+ PVR2D_ULONG ulFlags,
+ PVR2D_ULONG ulNumBuffers,
+ PVR2D_ULONG ulWidth,
+ PVR2D_ULONG ulHeight,
+ PVR2DFORMAT eFormat,
+ PVR2D_LONG *plStride,
+ PVR2D_ULONG *pulFlipChainID,
+ PVR2DFLIPCHAINHANDLE *phFlipChain);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DDestroyFlipChain(PVR2DCONTEXTHANDLE hContext,
+ PVR2DFLIPCHAINHANDLE hFlipChain);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DGetFlipChainBuffers(PVR2DCONTEXTHANDLE hContext,
+ PVR2DFLIPCHAINHANDLE hFlipChain,
+ PVR2D_ULONG *pulNumBuffers,
+ PVR2DMEMINFO *psMemInfo[]);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DSetPresentFlipProperties(PVR2DCONTEXTHANDLE hContext,
+ PVR2DFLIPCHAINHANDLE hFlipChain,
+ PVR2D_ULONG ulPropertyMask,
+ PVR2D_LONG lDstXPos,
+ PVR2D_LONG lDstYPos,
+ PVR2D_ULONG ulNumClipRects,
+ PVR2DRECT *pClipRects,
+ PVR2D_ULONG ulSwapInterval);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DPresentFlip(PVR2DCONTEXTHANDLE hContext,
+ PVR2DFLIPCHAINHANDLE hFlipChain,
+ PVR2DMEMINFO *psMemInfo,
+ PVR2D_LONG lRenderID);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DGetAPIRev(PVR2D_LONG *lRevMajor, PVR2D_LONG *lRevMinor);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DLoadUseCode (const PVR2DCONTEXTHANDLE hContext, const PVR2D_UCHAR *pUseCode,
+ const PVR2D_ULONG UseCodeSize, PVR2D_HANDLE *pUseCodeHandle);
+PVR2D_IMPORT
+PVR2DERROR PVR2DFreeUseCode (const PVR2DCONTEXTHANDLE hContext, const PVR2D_HANDLE hUseCodeHandle);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DBlt3D (const PVR2DCONTEXTHANDLE hContext, const PPVR2D_3DBLT pBlt3D);
+
+PVR2D_IMPORT
+PVR2DERROR PVR2DBlt3DExt (const PVR2DCONTEXTHANDLE hContext, const PPVR2D_3DBLT_EXT pBlt3D);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PVR2D_H_ */
+
+/******************************************************************************
+ End of file (pvr2d.h)
+******************************************************************************/
diff --git a/libwayland-egl/wsegl.h b/libwayland-egl/wsegl.h
new file mode 100644
index 0000000..25d6050
--- /dev/null
+++ b/libwayland-egl/wsegl.h
@@ -0,0 +1,352 @@
+/*************************************************************************/ /*!
+@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
+@License Dual MIT/GPLv2
+
+The contents of this file are subject to the MIT license as set out below.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+Alternatively, the contents of this file may be used under the terms of
+the GNU General Public License Version 2 ("GPL") in which case the provisions
+of GPL are applicable instead of those above.
+
+If you wish to allow use of your version of this file only under the terms of
+GPL, and not to allow others to use your version of this file under the terms
+of the MIT license, indicate your decision by deleting the provisions above
+and replace them with the notice and other provisions required by GPL as set
+out in the file called "GPL-COPYING" included in this distribution. If you do
+not delete the provisions above, a recipient may use your version of this file
+under the terms of either the MIT license or GPL.
+
+This License is also included in this distribution in the file called
+"MIT-COPYING".
+
+EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
+PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+*/ /**************************************************************************/
+
+#if !defined(__WSEGL_H__)
+#define __WSEGL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+// WSEGL Platform-specific definitions
+*/
+#if defined(__linux__)
+#define WSEGL_EXPORT __attribute__((visibility("default")))
+#define WSEGL_IMPORT
+#else
+#define WSEGL_EXPORT
+#define WSEGL_IMPORT
+#endif
+
+/*
+// WSEGL API Version Number
+*/
+
+#define WSEGL_VERSION 4
+#define WSEGL_DEFAULT_DISPLAY 0
+#define WSEGL_DEFAULT_NATIVE_ENGINE 0
+
+#define WSEGL_FALSE 0
+#define WSEGL_TRUE 1
+#define WSEGL_NULL 0
+
+#define WSEGL_UNREFERENCED_PARAMETER(param) (param) = (param)
+
+/*
+// WSEGL handles
+*/
+typedef void *WSEGLDisplayHandle;
+typedef void *WSEGLDrawableHandle;
+
+/*
+// Display capability type
+*/
+typedef enum WSEGLCapsType_TAG
+{
+ WSEGL_NO_CAPS = 0,
+ WSEGL_CAP_MIN_SWAP_INTERVAL = 1, /* System default value = 1 */
+ WSEGL_CAP_MAX_SWAP_INTERVAL = 2, /* System default value = 1 */
+ WSEGL_CAP_WINDOWS_USE_HW_SYNC = 3, /* System default value = 0 (FALSE) */
+ WSEGL_CAP_PIXMAPS_USE_HW_SYNC = 4, /* System default value = 0 (FALSE) */
+
+ /* When this capability is set, the EGL lock is not taken around calls
+ to WSEGL functions. The WSEGL module is responsible for performing
+ its own locking in this case. */
+ WSEGL_CAP_UNLOCKED = 5, /* System default value = 0 */
+
+} WSEGLCapsType;
+
+/*
+// Display capability
+*/
+typedef struct WSEGLCaps_TAG
+{
+ WSEGLCapsType eCapsType;
+ unsigned long ui32CapsValue;
+
+} WSEGLCaps;
+
+/*
+// Drawable type
+*/
+#define WSEGL_NO_DRAWABLE 0x0
+#define WSEGL_DRAWABLE_WINDOW 0x1
+#define WSEGL_DRAWABLE_PIXMAP 0x2
+
+/*
+// YUV format flags and sync
+*/
+#define WSEGL_FLAGS_YUV_CONFORMANT_RANGE (0 << 0)
+#define WSEGL_FLAGS_YUV_FULL_RANGE (1 << 0)
+#define WSEGL_FLAGS_YUV_BT601 (0 << 1)
+#define WSEGL_FLAGS_YUV_BT709 (1 << 1)
+#define WSEGL_FLAGS_EGLIMAGE_COMPOSITION_SYNC (1 << 2)
+
+/*
+// Maximum number of optional PowerVR Services 4 SYNCINFO objects
+*/
+#define WSEGL_MAX_SRC_SYNCS 32
+
+/*
+// Pixel format of display/drawable
+*/
+typedef enum WSEGLPixelFormat_TAG
+{
+ /* These must not be re-ordered */
+ WSEGL_PIXELFORMAT_RGB565 = 0,
+ WSEGL_PIXELFORMAT_ARGB4444 = 1,
+ WSEGL_PIXELFORMAT_ARGB8888 = 2,
+ WSEGL_PIXELFORMAT_ARGB1555 = 3,
+ WSEGL_PIXELFORMAT_ABGR8888 = 4,
+ WSEGL_PIXELFORMAT_XBGR8888 = 5,
+ WSEGL_PIXELFORMAT_NV12 = 6,
+ WSEGL_PIXELFORMAT_YUYV = 7,
+ WSEGL_PIXELFORMAT_YV12 = 8,
+ WSEGL_PIXELFORMAT_XRGB8888 = 9,
+ WSEGL_PIXELFORMAT_UYVY = 10,
+ WSEGL_PIXELFORMAT_NV12_4KALIGN = 11,
+ WSEGL_PIXELFORMAT_NV21_4KALIGN = 12,
+ WSEGL_PIXELFORMAT_R8 = 13,
+ WSEGL_PIXELFORMAT_R8G8 = 14,
+ WSEGL_PIXELFORMAT_NV21 = 15,
+
+ /* These are compatibility names only; new WSEGL
+ * modules should not use them.
+ */
+ WSEGL_PIXELFORMAT_565 = WSEGL_PIXELFORMAT_RGB565,
+ WSEGL_PIXELFORMAT_4444 = WSEGL_PIXELFORMAT_ARGB4444,
+ WSEGL_PIXELFORMAT_8888 = WSEGL_PIXELFORMAT_ARGB8888,
+ WSEGL_PIXELFORMAT_1555 = WSEGL_PIXELFORMAT_ARGB1555,
+
+} WSEGLPixelFormat;
+
+/*
+// Transparent of display/drawable
+*/
+typedef enum WSEGLTransparentType_TAG
+{
+ WSEGL_OPAQUE = 0,
+ WSEGL_COLOR_KEY = 1,
+
+} WSEGLTransparentType;
+
+/*
+// Display/drawable configuration
+*/
+typedef struct WSEGLConfig_TAG
+{
+ /*
+ // Type of drawables this configuration applies to -
+ // OR'd values of drawable types.
+ */
+ unsigned long ui32DrawableType;
+
+ /* Pixel format */
+ WSEGLPixelFormat ePixelFormat;
+
+ /* Native Renderable - set to WSEGL_TRUE if native renderable */
+ unsigned long ulNativeRenderable;
+
+ /* FrameBuffer Level Parameter */
+ unsigned long ulFrameBufferLevel;
+
+ /* Native Visual ID */
+ unsigned long ulNativeVisualID;
+
+ /* Native Visual */
+ unsigned long ulNativeVisualType;
+
+ /* Transparent Type */
+ WSEGLTransparentType eTransparentType;
+
+ /* Transparent Color - only used if transparent type is COLOR_KEY */
+ unsigned long ulTransparentColor; /* packed as 0x00RRGGBB */
+
+ /* Framebuffer Target - set to WSEGL_TRUE if config compatible with framebuffer */
+ unsigned long ulFramebufferTarget;
+
+} WSEGLConfig;
+
+/*
+// WSEGL errors
+*/
+typedef enum WSEGLError_TAG
+{
+ WSEGL_SUCCESS = 0,
+ WSEGL_CANNOT_INITIALISE = 1,
+ WSEGL_BAD_NATIVE_DISPLAY = 2,
+ WSEGL_BAD_NATIVE_WINDOW = 3,
+ WSEGL_BAD_NATIVE_PIXMAP = 4,
+ WSEGL_BAD_NATIVE_ENGINE = 5,
+ WSEGL_BAD_DRAWABLE = 6,
+ WSEGL_BAD_MATCH = 7,
+ WSEGL_OUT_OF_MEMORY = 8,
+ WSEGL_RETRY = 9,
+
+ /* These are compatibility names only; new WSEGL
+ * modules should not use them.
+ */
+ WSEGL_BAD_CONFIG = WSEGL_BAD_MATCH,
+
+} WSEGLError;
+
+/*
+// Drawable orientation (in degrees anti-clockwise)
+*/
+typedef enum WSEGLRotationAngle_TAG
+{
+ WSEGL_ROTATE_0 = 0,
+ WSEGL_ROTATE_90 = 1,
+ WSEGL_ROTATE_180 = 2,
+ WSEGL_ROTATE_270 = 3
+
+} WSEGLRotationAngle;
+
+/*
+// Drawable information required by OpenGL-ES driver
+*/
+typedef struct WSEGLDrawableParams_TAG
+{
+ /* Width in pixels of the drawable */
+ unsigned long ui32Width;
+
+ /* Height in pixels of the drawable */
+ unsigned long ui32Height;
+
+ /* Stride in pixels of the drawable */
+ unsigned long ui32Stride;
+
+ /* Pixel format of the drawable */
+ WSEGLPixelFormat ePixelFormat;
+
+ /* User space cpu virtual address of the drawable */
+ void *pvLinearAddress;
+
+ /* HW address of the drawable */
+ unsigned long ui32HWAddress;
+
+ /* Override display's HW_SYNC mode */
+ unsigned long bWaitForRender;
+
+ /* Flags */
+ unsigned long ulFlags;
+
+ /* Rotation angle of drawable (presently source only) */
+ WSEGLRotationAngle eRotationAngle;
+
+ /*
+ // Optional PowerVR Services 4 MEMINFO pointer. This may be used for
+ // internal (implicit) synchronization purposes, and by PDUMP. It should
+ // refer to the same object as the other fields in this structure.
+ */
+ void *hMemInfo;
+
+ /*
+ // Optional PowerVR Services 4 SYNCINFO pointers to sent down as source
+ // surface (texture) dependencies of a render. If these are provided
+ // when not applicable, they will be ignored. If a sync is not needed,
+ // it should be passed as NULL.
+ */
+ void *ahSyncInfo[WSEGL_MAX_SRC_SYNCS];
+
+} WSEGLDrawableParams;
+
+
+/*
+// Table of function pointers that is returned by WSEGL_GetFunctionTablePointer()
+//
+// The first entry in the table is the version number of the wsegl.h header file that
+// the module has been written against, and should therefore be set to WSEGL_VERSION
+*/
+typedef struct WSEGL_FunctionTable_TAG
+{
+ unsigned long ui32WSEGLVersion;
+
+ WSEGLError (*pfnWSEGL_IsDisplayValid)(NativeDisplayType);
+
+ WSEGLError (*pfnWSEGL_InitialiseDisplay)(NativeDisplayType, WSEGLDisplayHandle *, const WSEGLCaps **, WSEGLConfig **);
+
+ WSEGLError (*pfnWSEGL_CloseDisplay)(WSEGLDisplayHandle);
+
+ WSEGLError (*pfnWSEGL_CreateWindowDrawable)(WSEGLDisplayHandle, WSEGLConfig *, WSEGLDrawableHandle *, NativeWindowType, WSEGLRotationAngle *);
+
+ WSEGLError (*pfnWSEGL_CreatePixmapDrawable)(WSEGLDisplayHandle, WSEGLConfig *, WSEGLDrawableHandle *, NativePixmapType, WSEGLRotationAngle *);
+
+ WSEGLError (*pfnWSEGL_DeleteDrawable)(WSEGLDrawableHandle);
+
+ WSEGLError (*pfnWSEGL_SwapDrawable)(WSEGLDrawableHandle, unsigned long);
+
+ WSEGLError (*pfnWSEGL_SwapControlInterval)(WSEGLDrawableHandle, unsigned long);
+
+ WSEGLError (*pfnWSEGL_WaitNative)(WSEGLDrawableHandle, unsigned long);
+
+ WSEGLError (*pfnWSEGL_CopyFromDrawable)(WSEGLDrawableHandle, NativePixmapType);
+
+ WSEGLError (*pfnWSEGL_CopyFromPBuffer)(void *, unsigned long, unsigned long, unsigned long, WSEGLPixelFormat, NativePixmapType);
+
+ WSEGLError (*pfnWSEGL_GetDrawableParameters)(WSEGLDrawableHandle, WSEGLDrawableParams *, WSEGLDrawableParams *, unsigned long);
+
+ WSEGLError (*pfnWSEGL_ConnectDrawable)(WSEGLDrawableHandle);
+
+ WSEGLError (*pfnWSEGL_DisconnectDrawable)(WSEGLDrawableHandle);
+
+ WSEGLError (*pfnWSEGL_FlagStartFrame)(void);
+
+
+#if defined (__QNXNTO__)
+ WSEGLError (*pfnWSEGL_WaitForDrawableRenderBuffer)(WSEGLDrawableHandle);
+#endif
+
+} WSEGL_FunctionTable;
+
+
+WSEGL_IMPORT const WSEGL_FunctionTable *WSEGL_GetFunctionTablePointer(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __WSEGL_H__ */
+
+/******************************************************************************
+ End of file (wsegl.h)
+******************************************************************************/
--
2.11.0
From d3dffd71663739d580b600d847068c1b02caaa23 Mon Sep 17 00:00:00 2001
From: Jonathan Bakker <xc-racer2@live.ca>
Date: Sat, 15 Jun 2019 17:25:24 -0700
Subject: [PATCH 2/5] Use CMake rather than autotools
Couldn't get the autotools to work and I don't know how to modify it :)
---
.gitignore | 3 +++
CMakeLists.txt | 14 ++++++++++++++
common/CMakeLists.txt | 30 ++++++++++++++++++++++++++++++
libegl/CMakeLists.txt | 14 ++++++++++++++
libegl/egl.pc.in | 10 +++++-----
libwayland-egl/CMakeLists.txt | 14 ++++++++++++++
libwayland-egl/wayland-egl.pc.in | 9 +++++----
wsegl/CMakeLists.txt | 8 ++++++++
wsegl/powervr.ini | 2 +-
9 files changed, 94 insertions(+), 10 deletions(-)
create mode 100644 .gitignore
create mode 100644 CMakeLists.txt
create mode 100644 common/CMakeLists.txt
create mode 100644 libegl/CMakeLists.txt
create mode 100644 libwayland-egl/CMakeLists.txt
create mode 100644 wsegl/CMakeLists.txt
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..9f14dbf
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+build
+protocol/wayland-sgx-client-protocol.h
+protocol/wayland-sgx-server-protocol.h
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..7c97d33
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required (VERSION 2.6)
+project (sgx-wayland-wsegl)
+
+include(GNUInstallDirs)
+
+include_directories ("${PROJECT_SOURCE_DIR}/common")
+include_directories ("${PROJECT_SOURCE_DIR}/libegl")
+include_directories ("${PROJECT_SOURCE_DIR}/libwayland-egl")
+include_directories ("${PROJECT_SOURCE_DIR}/protocol")
+include_directories ("${PROJECT_SOURCE_DIR}/wsegl")
+add_subdirectory (common)
+add_subdirectory (libegl)
+add_subdirectory (libwayland-egl)
+add_subdirectory (wsegl)
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
new file mode 100644
index 0000000..a0ea6c9
--- /dev/null
+++ b/common/CMakeLists.txt
@@ -0,0 +1,30 @@
+# TODO - Convert to FindWaylandScanner?
+add_custom_command (
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/wayland-sgx-protocol.c
+ COMMAND wayland-scanner code < ${PROJECT_SOURCE_DIR}/protocol/wayland-sgx.xml > ${CMAKE_CURRENT_BINARY_DIR}/wayland-sgx-protocol.c
+)
+
+add_custom_target (
+ wayland-sgx-server-protocol
+ COMMAND wayland-scanner server-header < ${PROJECT_SOURCE_DIR}/protocol/wayland-sgx.xml > ${PROJECT_SOURCE_DIR}/protocol/wayland-sgx-server-protocol.h
+)
+
+add_custom_target (
+ wayland-sgx-client-protocol
+ COMMAND wayland-scanner client-header < ${PROJECT_SOURCE_DIR}/protocol/wayland-sgx.xml > ${PROJECT_SOURCE_DIR}/protocol/wayland-sgx-client-protocol.h
+)
+
+add_library(SgxCommon SHARED
+ wayland-sgx-protocol.c
+ log.c
+ server_wlegl.cpp
+ server_wlegl_buffer.cpp
+)
+
+add_dependencies(SgxCommon
+ wayland-sgx-server-protocol
+ wayland-sgx-client-protocol
+)
+
+install(TARGETS SgxCommon
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
diff --git a/libegl/CMakeLists.txt b/libegl/CMakeLists.txt
new file mode 100644
index 0000000..838cb93
--- /dev/null
+++ b/libegl/CMakeLists.txt
@@ -0,0 +1,14 @@
+add_library(EGL SHARED egl.c)
+target_link_libraries(EGL SgxCommon)
+
+# weston requires mesa version for egl
+set(MESA_VERSION 10.1.3)
+
+set_target_properties(EGL PROPERTIES VERSION 1)
+set_target_properties(EGL PROPERTIES SOVERSION 1)
+
+install(TARGETS EGL
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+
+configure_file(egl.pc.in ${CMAKE_BINARY_DIR}/egl.pc @ONLY)
+install(FILES ${CMAKE_BINARY_DIR}/egl.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
diff --git a/libegl/egl.pc.in b/libegl/egl.pc.in
index e3c6180..e52792d 100644
--- a/libegl/egl.pc.in
+++ b/libegl/egl.pc.in
@@ -1,10 +1,10 @@
-prefix=@prefix@
-exec_prefix=${prefix}
-libdir=@libdir@
-includedir=@includedir@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=@CMAKE_INSTALL_PREFIX@
+libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
+includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
Name: egl
-Description: OMAP EGL library
+Description: SGX EGL library
Requires.private:
Version: @MESA_VERSION@
Libs: -L${libdir} -lEGL
diff --git a/libwayland-egl/CMakeLists.txt b/libwayland-egl/CMakeLists.txt
new file mode 100644
index 0000000..b8ddef5
--- /dev/null
+++ b/libwayland-egl/CMakeLists.txt
@@ -0,0 +1,14 @@
+add_library(wayland-egl SHARED
+ wayland-egl.c
+)
+target_link_libraries(wayland-egl SgxCommon)
+
+set_target_properties(wayland-egl PROPERTIES VERSION 1)
+set_target_properties(wayland-egl PROPERTIES SOVERSION 1)
+
+install(TARGETS wayland-egl
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+
+configure_file(wayland-egl.pc.in ${CMAKE_BINARY_DIR}/wayland-egl.pc @ONLY)
+
+install(FILES ${CMAKE_BINARY_DIR}/wayland-egl.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
diff --git a/libwayland-egl/wayland-egl.pc.in b/libwayland-egl/wayland-egl.pc.in
index 923f24d..f7ebeb4 100644
--- a/libwayland-egl/wayland-egl.pc.in
+++ b/libwayland-egl/wayland-egl.pc.in
@@ -1,10 +1,11 @@
-prefix=@prefix@
-libdir=@libdir@
-includedir=@includedir@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=@CMAKE_INSTALL_PREFIX@
+libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
+includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
Name: wayland-egl
Description: SGX wayland-egl library
-Version: @PACKAGE_VERSION@
+Version: @PROJECT_VERSION@
Requires: wayland-server wayland-client
Libs: -L${libdir} -lwayland-egl -lwayland-client -lwayland-server -lpvr2d
Cflags: -I${includedir}
diff --git a/wsegl/CMakeLists.txt b/wsegl/CMakeLists.txt
new file mode 100644
index 0000000..b666a59
--- /dev/null
+++ b/wsegl/CMakeLists.txt
@@ -0,0 +1,8 @@
+add_library(waylandwsegl SHARED waylandwsegl.c)
+target_link_libraries(waylandwsegl SgxCommon wayland-egl)
+
+install(TARGETS waylandwsegl
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+
+install(FILES powervr.ini
+ DESTINATION /etc)
diff --git a/wsegl/powervr.ini b/wsegl/powervr.ini
index 5b720d9..26e1124 100644
--- a/wsegl/powervr.ini
+++ b/wsegl/powervr.ini
@@ -1,2 +1,2 @@
[default]
-WindowSystem=waylandwsegl.so
+WindowSystem=libwaylandwsegl.so
--
2.11.0
From 0486733ad7143778c3cfc8d10360b7269e1dc934 Mon Sep 17 00:00:00 2001
From: Jonathan Bakker <xc-racer2@live.ca>
Date: Sat, 15 Jun 2019 21:53:25 -0700
Subject: [PATCH 3/5] Update to wl_resource from deprecated/removed wl_buffer
Untested, based on https://github.com/libhybris/libhybris/commit/f5264b6e239c432f002d954d6b512f4681c7fb9f#diff-869780ab0e633cc565aeefe643bf4c25
---
common/server_wlegl.cpp | 13 ++++++-------
common/server_wlegl.h | 4 ++--
common/server_wlegl_buffer.cpp | 41 ++++++++-------------------------------
common/server_wlegl_buffer.h | 8 +++++---
libegl/egl.c | 2 +-
libwayland-egl/wayland-egl-priv.h | 2 +-
libwayland-egl/wayland-egl.c | 2 +-
wsegl/waylandwsegl.c | 6 +++---
8 files changed, 27 insertions(+), 51 deletions(-)
diff --git a/common/server_wlegl.cpp b/common/server_wlegl.cpp
index fde3a86..417639c 100644
--- a/common/server_wlegl.cpp
+++ b/common/server_wlegl.cpp
@@ -33,7 +33,7 @@
static inline server_wlegl *
server_wlegl_from(struct wl_resource *resource)
{
- return reinterpret_cast<server_wlegl *>(resource->data);
+ return reinterpret_cast<server_wlegl *>(wl_resource_get_user_data(resource));
}
static void
@@ -57,7 +57,7 @@ server_wlegl_create_buffer(struct wl_client *client,
return;
}
- buffer = server_wlegl_buffer_create(id, width, height, stride,
+ buffer = server_wlegl_buffer_create(client, id, width, height, stride,
format, handle, wlegl);
if (!buffer) {
wl_resource_post_error(resource,
@@ -66,7 +66,7 @@ server_wlegl_create_buffer(struct wl_client *client,
return;
}
- wl_client_add_resource(client, &buffer->base.resource);
+ buffer->resource = wl_resource_create(client, &wl_buffer_interface, 1, id);
}
static const struct sgx_wlegl_interface server_wlegl_impl = {
@@ -80,8 +80,8 @@ server_wlegl_bind(struct wl_client *client, void *data,
server_wlegl *wlegl = reinterpret_cast<server_wlegl *>(data);
struct wl_resource *resource;
- resource = wl_client_add_object(client, &sgx_wlegl_interface,
- &server_wlegl_impl, id, wlegl);
+ resource = wl_resource_create(client, &sgx_wlegl_interface, version, id);
+ wl_resource_set_implementation(resource, &server_wlegl_impl, wlegl, 0);
}
server_wlegl *
@@ -93,8 +93,7 @@ server_wlegl_create(struct wl_display *display)
wlegl = new server_wlegl;
wlegl->display = display;
- wlegl->global = wl_display_add_global(display,
- &sgx_wlegl_interface,
+ wlegl->global = wl_global_create(display, &sgx_wlegl_interface, 1,
wlegl, server_wlegl_bind);
return wlegl;
diff --git a/common/server_wlegl.h b/common/server_wlegl.h
index 7f15bb0..26535c9 100644
--- a/common/server_wlegl.h
+++ b/common/server_wlegl.h
@@ -31,7 +31,7 @@ extern "C" {
#endif
struct wl_display;
-struct wl_buffer;
+struct wl_resource;
struct server_wlegl;
struct server_wlegl *
@@ -42,7 +42,7 @@ server_wlegl_destroy(struct server_wlegl *wlegl);
EGLImageKHR
egl_create_image_wl(EGLDisplay egldisplay,
- struct wl_buffer *user_buffer,
+ struct wl_resource *user_buffer,
const EGLint *attrib_list);
#ifdef __cplusplus
diff --git a/common/server_wlegl_buffer.cpp b/common/server_wlegl_buffer.cpp
index a98da7c..b24200e 100644
--- a/common/server_wlegl_buffer.cpp
+++ b/common/server_wlegl_buffer.cpp
@@ -38,38 +38,23 @@ static const struct wl_buffer_interface server_wlegl_buffer_impl = {
#include <stddef.h>
-/**
- * container_of - cast a member of a structure out to the containing structure
- * @ptr:>---the pointer to the member.
- * @type:>--the type of the container struct this is embedded in.
- * @member:>the name of the member within the struct.
- *
- */
-#define container_of(ptr, type, member) ({ \
- const typeof( ((type *)0)->member ) *__mptr = (ptr); \
- (type *)( (char *)__mptr - offsetof(type,member) );})
-
server_wlegl_buffer *
-server_wlegl_buffer_from(struct wl_buffer *buffer)
+server_wlegl_buffer_from(struct wl_resource *buffer)
{
- if (buffer->resource.object.implementation !=
- (void (**)(void)) &server_wlegl_buffer_impl)
- return NULL;
-
- return container_of(buffer, server_wlegl_buffer, base);
+ return static_cast<server_wlegl_buffer *>(wl_resource_get_user_data(buffer));
}
static void
server_wlegl_buffer_dtor(struct wl_resource *resource)
{
- struct wl_buffer *base =
- reinterpret_cast<struct wl_buffer*>(resource->data);
- server_wlegl_buffer *buffer = server_wlegl_buffer_from(base);
+ server_wlegl_buffer *buffer = server_wlegl_buffer_from(resource);
delete buffer;
}
+
server_wlegl_buffer *
-server_wlegl_buffer_create(uint32_t id,
+server_wlegl_buffer_create(wl_client *client,
+ uint32_t id,
int32_t width,
int32_t height,
int32_t stride,
@@ -80,20 +65,10 @@ server_wlegl_buffer_create(uint32_t id,
server_wlegl_buffer *buffer = new server_wlegl_buffer;
int ret;
- memset(buffer, 0, sizeof(*buffer));
-
buffer->wlegl = wlegl;
- buffer->base.resource.object.id = id;
- buffer->base.resource.object.interface = &wl_buffer_interface;
- buffer->base.resource.object.implementation =
- (void (**)(void)) &server_wlegl_buffer_impl;
-
- buffer->base.resource.data = &buffer->base;
- buffer->base.resource.destroy = server_wlegl_buffer_dtor;
-
- buffer->base.width = width;
- buffer->base.height = height;
+ buffer->resource = wl_resource_create(client, &wl_buffer_interface, 1, id);
+ wl_resource_set_implementation(buffer->resource, &server_wlegl_buffer_impl, buffer, server_wlegl_buffer_dtor);
buffer->buf = remote_window_buffer_create(
width, height, stride, format, handle);
diff --git a/common/server_wlegl_buffer.h b/common/server_wlegl_buffer.h
index 23bcb47..c78d409 100644
--- a/common/server_wlegl_buffer.h
+++ b/common/server_wlegl_buffer.h
@@ -49,19 +49,21 @@ struct remote_window_buffer *remote_window_buffer_create(unsigned int width,
int32_t handle);
struct server_wlegl_buffer {
- struct wl_buffer base;
+ struct wl_resource *resource;
struct server_wlegl *wlegl;
struct remote_window_buffer *buf;
};
+#ifdef __cplusplus
struct server_wlegl_buffer *
-server_wlegl_buffer_create(uint32_t id, int32_t width, int32_t height,
+server_wlegl_buffer_create(wl_client *client, uint32_t id, int32_t width, int32_t height,
int32_t stride, int32_t format,
int32_t handle, struct server_wlegl *wlegl);
+#endif
struct server_wlegl_buffer *
-server_wlegl_buffer_from(struct wl_buffer *);
+server_wlegl_buffer_from(struct wl_resource *);
#ifdef __cplusplus
}
diff --git a/libegl/egl.c b/libegl/egl.c
index 188495f..e82e915 100644
--- a/libegl/egl.c
+++ b/libegl/egl.c
@@ -430,7 +430,7 @@ static EGLBoolean _my_eglUnbindWaylandDisplayWL(EGLDisplay dpy, struct wl_displa
{
}
-static EGLBoolean _my_eglQueryWaylandBufferWL(EGLDisplay dpy, struct wl_buffer *buffer, EGLint attribute, EGLint *value)
+static EGLBoolean _my_eglQueryWaylandBufferWL(EGLDisplay dpy, struct wl_resource *buffer, EGLint attribute, EGLint *value)
{
struct server_wlegl_buffer *buf = server_wlegl_buffer_from(buffer);
diff --git a/libwayland-egl/wayland-egl-priv.h b/libwayland-egl/wayland-egl-priv.h
index 910af36..69f6b1b 100644
--- a/libwayland-egl/wayland-egl-priv.h
+++ b/libwayland-egl/wayland-egl-priv.h
@@ -108,7 +108,7 @@ struct wl_egl_window {
WSEGLPixelFormat format;
PVR2DMEMINFO *frontBufferPVRMEM;
PVR2DMEMINFO *backBuffers[WAYLANDWSEGL_MAX_BACK_BUFFERS];
- struct wl_buffer *drmbuffers[WAYLANDWSEGL_MAX_BACK_BUFFERS];
+ struct wl_resource *drmbuffers[WAYLANDWSEGL_MAX_BACK_BUFFERS];
int numFlipBuffers;
PVR2DFLIPCHAINHANDLE flipChain;
PVR2DMEMINFO *flipBuffers[WAYLANDWSEGL_MAX_FLIP_BUFFERS];
diff --git a/libwayland-egl/wayland-egl.c b/libwayland-egl/wayland-egl.c
index 1390282..90cdd69 100644
--- a/libwayland-egl/wayland-egl.c
+++ b/libwayland-egl/wayland-egl.c
@@ -123,7 +123,7 @@ wl_egl_pixmap_destroy(struct wl_egl_pixmap *egl_pixmap)
free(egl_pixmap);
}
-WL_EGL_EXPORT struct wl_buffer *
+WL_EGL_EXPORT struct wl_resource *
wl_egl_pixmap_create_buffer(struct wl_egl_pixmap *egl_pixmap)
{
if (egl_pixmap->handle == 0)
diff --git a/wsegl/waylandwsegl.c b/wsegl/waylandwsegl.c
index 4db9480..78b23cd 100644
--- a/wsegl/waylandwsegl.c
+++ b/wsegl/waylandwsegl.c
@@ -532,7 +532,7 @@ static WSEGLError wseglDeleteDrawable(WSEGLDrawableHandle _drawable)
if (drawable->header.type == WWSEGL_DRAWABLE_TYPE_WINDOW) {
for (index = 0; index < numBuffers; ++index) {
if (drawable->drmbuffers[index])
- wl_buffer_destroy(drawable->drmbuffers[index]);
+ wl_resource_destroy(drawable->drmbuffers[index]);
if (drawable->backBuffers[index])
PVR2DMemFree(drawable->display->context, drawable->backBuffers[index]);
}
@@ -591,7 +591,7 @@ static WSEGLError wseglSwapDrawable
if (!drawable->drmbuffers[drawable->currentBackBuffer])
{
int32_t handle;
- struct wl_buffer *wlbuf;
+ struct wl_resource *wlbuf;
handle = drawable->exporthandles[drawable->currentBackBuffer];
wlbuf = sgx_wlegl_create_buffer(drawable->display->sgx_wlegl,
@@ -607,7 +607,7 @@ static WSEGLError wseglSwapDrawable
wl_proxy_set_queue((struct wl_proxy *)wlbuf, drawable->display->queue);
}
- struct wl_buffer *wlbuf = drawable->drmbuffers[drawable->currentBackBuffer];
+ struct wl_resource *wlbuf = drawable->drmbuffers[drawable->currentBackBuffer];
wl_surface_attach(drawable->surface, wlbuf, 0, 0);
wl_surface_damage(drawable->surface, 0, 0, drawable->width, drawable->height);
wl_surface_commit(drawable->surface);
--
2.11.0
From 92171ab6d9815f6702e41ac54864979cfc1c1fdc Mon Sep 17 00:00:00 2001
From: Jonathan Bakker <xc-racer2@live.ca>
Date: Mon, 24 Jun 2019 13:50:00 -0700
Subject: [PATCH 4/5] Convert to using libhybris for the blobs
Not all devices have Linux blobs available, so use libhybris
as middleware and load the Android blobs
---
common/pvr2d.h | 3 +
libegl/CMakeLists.txt | 2 +-
libegl/egl.c | 76 +++++++++++-----------
wsegl/CMakeLists.txt | 2 +-
wsegl/waylandwsegl.c | 172 ++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 216 insertions(+), 39 deletions(-)
diff --git a/common/pvr2d.h b/common/pvr2d.h
index 5dce7cf..199ed4b 100644
--- a/common/pvr2d.h
+++ b/common/pvr2d.h
@@ -507,6 +507,8 @@ typedef void* PVR2DFLIPCHAINHANDLE;
/* Functions that the library exports */
+/* Commented out as we will have to dlsym these as we are using libhybris */
+#if 0
PVR2D_IMPORT
int PVR2DEnumerateDevices(PVR2DDEVICEINFO *pDevInfo);
@@ -657,6 +659,7 @@ PVR2DERROR PVR2DBlt3D (const PVR2DCONTEXTHANDLE hContext, const PPVR2D_3DBLT pBl
PVR2D_IMPORT
PVR2DERROR PVR2DBlt3DExt (const PVR2DCONTEXTHANDLE hContext, const PPVR2D_3DBLT_EXT pBlt3D);
+#endif
#ifdef __cplusplus
}
diff --git a/libegl/CMakeLists.txt b/libegl/CMakeLists.txt
index 838cb93..e7e01a2 100644
--- a/libegl/CMakeLists.txt
+++ b/libegl/CMakeLists.txt
@@ -1,5 +1,5 @@
add_library(EGL SHARED egl.c)
-target_link_libraries(EGL SgxCommon)
+target_link_libraries(EGL SgxCommon hybris-common)
# weston requires mesa version for egl
set(MESA_VERSION 10.1.3)
diff --git a/libegl/egl.c b/libegl/egl.c
index e82e915..0055d7c 100644
--- a/libegl/egl.c
+++ b/libegl/egl.c
@@ -36,6 +36,8 @@
#include <string.h>
#include <assert.h>
+#include <hybris/common/dlfcn.h>
+
#define WANT_WAYLAND
#ifdef WANT_WAYLAND
@@ -122,39 +124,39 @@ static __eglMustCastToProperFunctionPointerType (*_eglGetProcAddress)(const char
static void _init_egl()
{
- _libegl = (void *) dlopen(getenv("LIBEGL") ? getenv("LIBEGL") : "/usr/lib/sgx/libEGL-sgx.so", RTLD_LAZY);
+ _libegl = (void *) hybris_dlopen("/vendor/lib/libIMGegl.so", RTLD_LAZY);
}
#define EGL_DLSYM(fptr, sym) do { if (_libegl == NULL) { _init_egl(); }; if (*(fptr) == NULL) { *(fptr) = (void *) dlsym(_libegl, sym); } } while (0)
EGLint eglGetError(void)
{
- EGL_DLSYM(&_eglGetError, "eglGetError");
+ EGL_DLSYM(&_eglGetError, "IMGeglGetError");
return (*_eglGetError)();
}
EGLDisplay eglGetDisplay(EGLNativeDisplayType display_id)
{
- EGL_DLSYM(&_eglGetDisplay, "eglGetDisplay");
+ EGL_DLSYM(&_eglGetDisplay, "IMGeglGetDisplay");
return (*_eglGetDisplay)(display_id);
}
EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
{
wsegl_info("wayland-wsegl: eglInitialize");
- EGL_DLSYM(&_eglInitialize, "eglInitialize");
+ EGL_DLSYM(&_eglInitialize, "IMGeglInitialize");
return (*_eglInitialize)(dpy, major, minor);
}
EGLBoolean eglTerminate(EGLDisplay dpy)
{
- EGL_DLSYM(&_eglTerminate, "eglTerminate");
+ EGL_DLSYM(&_eglTerminate, "IMGeglTerminate");
return (*_eglTerminate)(dpy);
}
const char * eglQueryString(EGLDisplay dpy, EGLint name)
{
- EGL_DLSYM(&_eglQueryString, "eglQueryString");
+ EGL_DLSYM(&_eglQueryString, "IMGeglQueryString");
#ifdef WANT_WAYLAND
if (name == EGL_EXTENSIONS)
{
@@ -172,7 +174,7 @@ const char * eglQueryString(EGLDisplay dpy, EGLint name)
EGLBoolean eglGetConfigs(EGLDisplay dpy, EGLConfig *configs,
EGLint config_size, EGLint *num_config)
{
- EGL_DLSYM(&_eglGetConfigs, "eglGetConfigs");
+ EGL_DLSYM(&_eglGetConfigs, "IMGeglGetConfigs");
return (*_eglGetConfigs)(dpy, configs, config_size, num_config);
}
@@ -180,7 +182,7 @@ EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list,
EGLConfig *configs, EGLint config_size,
EGLint *num_config)
{
- EGL_DLSYM(&_eglChooseConfig, "eglChooseConfig");
+ EGL_DLSYM(&_eglChooseConfig, "IMGeglChooseConfig");
return (*_eglChooseConfig)(dpy, attrib_list,
configs, config_size,
num_config);
@@ -189,7 +191,7 @@ EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list,
EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,
EGLint attribute, EGLint *value)
{
- EGL_DLSYM(&_eglGetConfigAttrib, "eglGetConfigAttrib");
+ EGL_DLSYM(&_eglGetConfigAttrib, "IMGeglGetConfigAttrib");
return (*_eglGetConfigAttrib)(dpy, config,
attribute, value);
}
@@ -198,14 +200,14 @@ EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
EGLNativeWindowType win,
const EGLint *attrib_list)
{
- EGL_DLSYM(&_eglCreateWindowSurface, "eglCreateWindowSurface");
+ EGL_DLSYM(&_eglCreateWindowSurface, "IMGeglCreateWindowSurface");
return (*_eglCreateWindowSurface)(dpy, config, win, attrib_list);
}
EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config,
const EGLint *attrib_list)
{
- EGL_DLSYM(&_eglCreatePbufferSurface, "eglCreatePbufferSurface");
+ EGL_DLSYM(&_eglCreatePbufferSurface, "IMGeglCreatePbufferSurface");
return (*_eglCreatePbufferSurface)(dpy, config, attrib_list);
}
@@ -213,45 +215,45 @@ EGLSurface eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,
EGLNativePixmapType pixmap,
const EGLint *attrib_list)
{
- EGL_DLSYM(&_eglCreatePixmapSurface, "eglCreatePixmapSurface");
+ EGL_DLSYM(&_eglCreatePixmapSurface, "IMGeglCreatePixmapSurface");
return (*_eglCreatePixmapSurface)(dpy, config, pixmap, attrib_list);
}
EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface)
{
- EGL_DLSYM(&_eglDestroySurface, "eglDestroySurface");
+ EGL_DLSYM(&_eglDestroySurface, "IMGeglDestroySurface");
return (*_eglDestroySurface)(dpy, surface);
}
EGLBoolean eglQuerySurface(EGLDisplay dpy, EGLSurface surface,
EGLint attribute, EGLint *value)
{
- EGL_DLSYM(&_eglQuerySurface, "eglQuerySurface");
+ EGL_DLSYM(&_eglQuerySurface, "IMGeglQuerySurface");
return (*_eglQuerySurface)(dpy, surface, attribute, value);
}
EGLBoolean eglBindAPI(EGLenum api)
{
- EGL_DLSYM(&_eglBindAPI, "eglBindAPI");
+ EGL_DLSYM(&_eglBindAPI, "IMGeglBindAPI");
return (*_eglBindAPI)(api);
}
EGLenum eglQueryAPI(void)
{
- EGL_DLSYM(&_eglQueryAPI, "eglQueryAPI");
+ EGL_DLSYM(&_eglQueryAPI, "IMGeglQueryAPI");
return (*_eglQueryAPI)();
}
EGLBoolean eglWaitClient(void)
{
- EGL_DLSYM(&_eglWaitClient, "eglWaitClient");
+ EGL_DLSYM(&_eglWaitClient, "IMGeglWaitClient");
return (*_eglWaitClient)();
}
EGLBoolean eglReleaseThread(void)
{
- EGL_DLSYM(&_eglReleaseThread, "eglReleaseThread");
+ EGL_DLSYM(&_eglReleaseThread, "IMGeglReleaseThread");
return (*_eglReleaseThread)();
}
@@ -259,32 +261,32 @@ EGLSurface eglCreatePbufferFromClientBuffer(
EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,
EGLConfig config, const EGLint *attrib_list)
{
- EGL_DLSYM(&_eglCreatePbufferFromClientBuffer, "eglCreatePbufferFromClientBuffer");
+ EGL_DLSYM(&_eglCreatePbufferFromClientBuffer, "IMGeglCreatePbufferFromClientBuffer");
return (*_eglCreatePbufferFromClientBuffer)(dpy, buftype, buffer, config, attrib_list);
}
EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface,
EGLint attribute, EGLint value)
{
- EGL_DLSYM(&_eglSurfaceAttrib, "eglSurfaceAttrib");
+ EGL_DLSYM(&_eglSurfaceAttrib, "IMGeglSurfaceAttrib");
return (*_eglSurfaceAttrib)(dpy, surface, attribute, value);
}
EGLBoolean eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
{
- EGL_DLSYM(&_eglBindTexImage, "eglBindTexImage");
+ EGL_DLSYM(&_eglBindTexImage, "IMGeglBindTexImage");
return (*_eglBindTexImage)(dpy, surface, buffer);
}
EGLBoolean eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
{
- EGL_DLSYM(&_eglReleaseTexImage, "eglReleaseTexImage");
+ EGL_DLSYM(&_eglReleaseTexImage, "IMGeglReleaseTexImage");
return (*_eglReleaseTexImage)(dpy, surface, buffer);
}
EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval)
{
- EGL_DLSYM(&_eglSwapInterval, "eglSwapInterval");
+ EGL_DLSYM(&_eglSwapInterval, "IMGeglSwapInterval");
return (*_eglSwapInterval)(dpy, interval);
}
@@ -292,70 +294,70 @@ EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config,
EGLContext share_context,
const EGLint *attrib_list)
{
- EGL_DLSYM(&_eglCreateContext, "eglCreateContext");
+ EGL_DLSYM(&_eglCreateContext, "IMGeglCreateContext");
return (*_eglCreateContext)(dpy, config, share_context, attrib_list);
}
EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
{
- EGL_DLSYM(&_eglDestroyContext, "eglDestroyContext");
+ EGL_DLSYM(&_eglDestroyContext, "IMGeglDestroyContext");
return (*_eglDestroyContext)(dpy, ctx);
}
EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw,
EGLSurface read, EGLContext ctx)
{
- EGL_DLSYM(&_eglMakeCurrent, "eglMakeCurrent");
+ EGL_DLSYM(&_eglMakeCurrent, "IMGeglMakeCurrent");
return (*_eglMakeCurrent)(dpy, draw, read, ctx);
}
EGLContext eglGetCurrentContext(void)
{
- EGL_DLSYM(&_eglGetCurrentContext, "eglGetCurrentContext");
+ EGL_DLSYM(&_eglGetCurrentContext, "IMGeglGetCurrentContext");
return (*_eglGetCurrentContext)();
}
EGLSurface eglGetCurrentSurface(EGLint readdraw)
{
- EGL_DLSYM(&_eglGetCurrentSurface, "eglGetCurrentSurface");
+ EGL_DLSYM(&_eglGetCurrentSurface, "IMGeglGetCurrentSurface");
return (*_eglGetCurrentSurface)(readdraw);
}
EGLDisplay eglGetCurrentDisplay(void)
{
- EGL_DLSYM(&_eglGetCurrentDisplay, "eglGetCurrentDisplay");
+ EGL_DLSYM(&_eglGetCurrentDisplay, "IMGeglGetCurrentDisplay");
return (*_eglGetCurrentDisplay)();
}
EGLBoolean eglQueryContext(EGLDisplay dpy, EGLContext ctx,
EGLint attribute, EGLint *value)
{
- EGL_DLSYM(&_eglQueryContext, "eglQueryContext");
+ EGL_DLSYM(&_eglQueryContext, "IMGeglQueryContext");
return (*_eglQueryContext)(dpy, ctx, attribute, value);
}
EGLBoolean eglWaitGL(void)
{
- EGL_DLSYM(&_eglWaitGL, "eglWaitGL");
+ EGL_DLSYM(&_eglWaitGL, "IMGeglWaitGL");
return (*_eglWaitGL)();
}
EGLBoolean eglWaitNative(EGLint engine)
{
- EGL_DLSYM(&_eglWaitNative, "eglWaitNative");
+ EGL_DLSYM(&_eglWaitNative, "IMGeglWaitNative");
return (*_eglWaitNative)(engine);
}
EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
{
- EGL_DLSYM(&_eglSwapBuffers, "eglSwapBuffers");
+ EGL_DLSYM(&_eglSwapBuffers, "IMGeglSwapBuffers");
return (*_eglSwapBuffers)(dpy, surface);
}
EGLBoolean eglCopyBuffers(EGLDisplay dpy, EGLSurface surface,
EGLNativePixmapType target)
{
- EGL_DLSYM(&_eglCopyBuffers, "eglCopyBuffers");
+ EGL_DLSYM(&_eglCopyBuffers, "IMGeglCopyBuffers");
return (*_eglCopyBuffers)(dpy, surface, target);
}
@@ -367,7 +369,7 @@ static EGLImageKHR _my_eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum
* eglGetProcAddress, otherwise we'll end up calling ourselves again, so
* we must look up eglGetProcAddress first and ask SGX
*/
- EGL_DLSYM(&_eglGetProcAddress, "eglGetProcAddress");
+ EGL_DLSYM(&_eglGetProcAddress, "IMGeglGetProcAddress");
_eglCreateImageKHR = (*_eglGetProcAddress)("eglCreateImageKHR");
}
@@ -453,7 +455,7 @@ static EGLBoolean _my_eglQueryWaylandBufferWL(EGLDisplay dpy, struct wl_resource
__eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)
{
- EGL_DLSYM(&_eglGetProcAddress, "eglGetProcAddress");
+ EGL_DLSYM(&_eglGetProcAddress, "IMGeglGetProcAddress");
if (strcmp(procname, "eglCreateImageKHR") == 0)
{
return _my_eglCreateImageKHR;
@@ -477,7 +479,7 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)
EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image)
{
- EGL_DLSYM(&_eglDestroyImageKHR, "eglDestroyImageKHR");
+ EGL_DLSYM(&_eglDestroyImageKHR, "IMGeglDestroyImageKHR");
return (*_eglDestroyImageKHR)(dpy, image);
}
diff --git a/wsegl/CMakeLists.txt b/wsegl/CMakeLists.txt
index b666a59..44ffa0e 100644
--- a/wsegl/CMakeLists.txt
+++ b/wsegl/CMakeLists.txt
@@ -1,5 +1,5 @@
add_library(waylandwsegl SHARED waylandwsegl.c)
-target_link_libraries(waylandwsegl SgxCommon wayland-egl)
+target_link_libraries(waylandwsegl SgxCommon wayland-egl hybris-common)
install(TARGETS waylandwsegl
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
diff --git a/wsegl/waylandwsegl.c b/wsegl/waylandwsegl.c
index 78b23cd..95215a0 100644
--- a/wsegl/waylandwsegl.c
+++ b/wsegl/waylandwsegl.c
@@ -51,11 +51,13 @@
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
+#include <dlfcn.h>
#include <sys/mman.h>
#include <linux/fb.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <time.h>
+#include <hybris/common/dlfcn.h>
#include "linux/omapfb.h"
#include "log.h"
@@ -69,6 +71,176 @@ static WSEGLCaps const wseglDisplayCaps[] = {
{WSEGL_NO_CAPS, 0}
};
+static void *_pvr2d = NULL;
+
+static void _init_pvr2d()
+{
+ _pvr2d = (void *) hybris_dlopen("/vendor/lib/libIMGegl.so", RTLD_LAZY);
+}
+
+#define PVR2D_DLSYM(fptr, sym) do { if (_pvr2d == NULL) { _init_pvr2d(); }; if (*(fptr) == NULL) { *(fptr) = (void *) dlsym(_pvr2d, sym); } } while (0)
+
+/* Wrapper function definitions */
+static int (*_PVR2DEnumerateDevices)(PVR2DDEVICEINFO *pDevInfo);
+
+static PVR2DERROR (*_PVR2DCreateDeviceContext)(PVR2D_ULONG ulDevID,
+ PVR2DCONTEXTHANDLE* phContext, PVR2D_ULONG ulFlags);
+
+static PVR2DERROR (*_PVR2DCreateFlipChain)(PVR2DCONTEXTHANDLE hContext,
+ PVR2D_ULONG ulFlags,
+ PVR2D_ULONG ulNumBuffers,
+ PVR2D_ULONG ulWidth,
+ PVR2D_ULONG ulHeight,
+ PVR2DFORMAT eFormat,
+ PVR2D_LONG *plStride,
+ PVR2D_ULONG *pulFlipChainID,
+ PVR2DFLIPCHAINHANDLE *phFlipChain);
+
+static PVR2DERROR (*_PVR2DGetFlipChainBuffers)(PVR2DCONTEXTHANDLE hContext,
+ PVR2DFLIPCHAINHANDLE hFlipChain,
+ PVR2D_ULONG *pulNumBuffers,
+ PVR2DMEMINFO *psMemInfo[]);
+
+static PVR2DERROR (*_PVR2DMemAlloc)(PVR2DCONTEXTHANDLE hContext,
+ PVR2D_ULONG ulBytes,
+ PVR2D_ULONG ulAlign,
+ PVR2D_ULONG ulFlags,
+ PVR2DMEMINFO **ppsMemInfo);
+
+static PVR2DERROR (*_PVR2DGetDeviceInfo)(PVR2DCONTEXTHANDLE hContext,
+ PVR2DDISPLAYINFO *pDisplayInfo);
+
+static PVR2DERROR (*_PVR2DMemExport)(PVR2DCONTEXTHANDLE hContext,
+ PVR2D_ULONG ulFlags,
+ PVR2DMEMINFO *psMemInfo,
+ PVR2D_HANDLE *phMemHandle);
+
+static PVR2DERROR (*_PVR2DGetFrameBuffer)(PVR2DCONTEXTHANDLE hContext,
+ PVR2D_INT nHeap,
+ PVR2DMEMINFO **ppsMemInfo);
+
+static PVR2DERROR (*_PVR2DMemMap)(PVR2DCONTEXTHANDLE hContext,
+ PVR2D_ULONG ulFlags,
+ PVR2D_HANDLE hMemHandle,
+ PVR2DMEMINFO **ppsDstMem);
+
+static PVR2DERROR (*_PVR2DPresentFlip)(PVR2DCONTEXTHANDLE hContext,
+ PVR2DFLIPCHAINHANDLE hFlipChain,
+ PVR2DMEMINFO *psMemInfo,
+ PVR2D_LONG lRenderID);
+
+static PVR2DERROR (*_PVR2DBlt)(PVR2DCONTEXTHANDLE hContext,
+ PVR2DBLTINFO *pBltInfo);
+
+static PVR2DERROR (*_PVR2DQueryBlitsComplete)(PVR2DCONTEXTHANDLE hContext,
+ const PVR2DMEMINFO *pMemInfo,
+ PVR2D_UINT uiWaitForComplete);
+
+/* Wrapper functions */
+int PVR2DEnumerateDevices(PVR2DDEVICEINFO *pDevInfo)
+{
+ PVR2D_DLSYM(&_PVR2DEnumerateDevices, "PVR2DEnumerateDevices");
+ return _PVR2DEnumerateDevices(pDevInfo);
+}
+
+PVR2DERROR PVR2DCreateDeviceContext(PVR2D_ULONG ulDevID,
+ PVR2DCONTEXTHANDLE* phContext, PVR2D_ULONG ulFlags)
+{
+ PVR2D_DLSYM(&_PVR2DCreateDeviceContext, "PVR2DCreateDeviceContext");
+ return _PVR2DCreateDeviceContext(ulDevID, phContext, ulFlags);
+}
+
+PVR2DERROR PVR2DCreateFlipChain(PVR2DCONTEXTHANDLE hContext,
+ PVR2D_ULONG ulFlags,
+ PVR2D_ULONG ulNumBuffers,
+ PVR2D_ULONG ulWidth,
+ PVR2D_ULONG ulHeight,
+ PVR2DFORMAT eFormat,
+ PVR2D_LONG *plStride,
+ PVR2D_ULONG *pulFlipChainID,
+ PVR2DFLIPCHAINHANDLE *phFlipChain)
+{
+ PVR2D_DLSYM(&_PVR2DCreateFlipChain, "PVR2DCreateFlipChain");
+ return _PVR2DCreateFlipChain(hContext, ulFlags, ulNumBuffers, ulWidth,
+ ulHeight, eFormat, plStride, pulFlipChainID, phFlipChain);
+}
+
+PVR2DERROR PVR2DGetFlipChainBuffers(PVR2DCONTEXTHANDLE hContext,
+ PVR2DFLIPCHAINHANDLE hFlipChain,
+ PVR2D_ULONG *pulNumBuffers,
+ PVR2DMEMINFO *psMemInfo[])
+{
+ PVR2D_DLSYM(&_PVR2DGetFlipChainBuffers, "PVR2DGetFlipChainBuffers");
+ return _PVR2DGetFlipChainBuffers(hContext, hFlipChain, pulNumBuffers,
+ psMemInfo);
+}
+
+PVR2DERROR PVR2DMemAlloc(PVR2DCONTEXTHANDLE hContext,
+ PVR2D_ULONG ulBytes,
+ PVR2D_ULONG ulAlign,
+ PVR2D_ULONG ulFlags,
+ PVR2DMEMINFO **ppsMemInfo)
+{
+ PVR2D_DLSYM(&_PVR2DMemAlloc, "PVR2DMemAlloc");
+ return _PVR2DMemAlloc(hContext, ulBytes, ulAlign, ulFlags, ppsMemInfo);
+}
+
+PVR2DERROR PVR2DGetDeviceInfo(PVR2DCONTEXTHANDLE hContext,
+ PVR2DDISPLAYINFO *pDisplayInfo)
+{
+ PVR2D_DLSYM(&_PVR2DGetDeviceInfo, "PVR2DGetDeviceInfo");
+ return _PVR2DGetDeviceInfo(hContext, pDisplayInfo);
+}
+
+PVR2DERROR PVR2DMemExport(PVR2DCONTEXTHANDLE hContext,
+ PVR2D_ULONG ulFlags,
+ PVR2DMEMINFO *psMemInfo,
+ PVR2D_HANDLE *phMemHandle)
+{
+ PVR2D_DLSYM(&_PVR2DMemExport, "PVR2DMemExport");
+ return _PVR2DMemExport(hContext, ulFlags, psMemInfo, phMemHandle);
+}
+
+PVR2DERROR PVR2DGetFrameBuffer(PVR2DCONTEXTHANDLE hContext,
+ PVR2D_INT nHeap,
+ PVR2DMEMINFO **ppsMemInfo)
+{
+ PVR2D_DLSYM(&_PVR2DGetFrameBuffer, "PVR2DGetFrameBuffer");
+ return _PVR2DGetFrameBuffer(hContext, nHeap, ppsMemInfo);
+}
+
+PVR2DERROR PVR2DMemMap(PVR2DCONTEXTHANDLE hContext,
+ PVR2D_ULONG ulFlags,
+ PVR2D_HANDLE hMemHandle,
+ PVR2DMEMINFO **ppsDstMem)
+{
+ PVR2D_DLSYM(&_PVR2DMemMap, "PVR2DMemMap");
+ return _PVR2DMemMap(hContext, ulFlags, hMemHandle, ppsDstMem);
+}
+
+PVR2DERROR PVR2DPresentFlip(PVR2DCONTEXTHANDLE hContext,
+ PVR2DFLIPCHAINHANDLE hFlipChain,
+ PVR2DMEMINFO *psMemInfo,
+ PVR2D_LONG lRenderID)
+{
+ PVR2D_DLSYM(&_PVR2DPresentFlip, "PVR2DPresentFlip");
+ return _PVR2DPresentFlip(hContext, hFlipChain, psMemInfo, lRenderID);
+}
+
+PVR2DERROR PVR2DBlt(PVR2DCONTEXTHANDLE hContext,
+ PVR2DBLTINFO *pBltInfo)
+{
+ PVR2D_DLSYM(&_PVR2DBlt, "PVR2DBlt");
+ return _PVR2DBlt(hContext, pBltInfo);
+}
+
+PVR2DERROR PVR2DQueryBlitsComplete(PVR2DCONTEXTHANDLE hContext,
+ const PVR2DMEMINFO *pMemInfo,
+ PVR2D_UINT uiWaitForComplete)
+{
+ PVR2D_DLSYM(&_PVR2DQueryBlitsComplete, "PVR2DQueryBlitsComplete");
+ return PVR2DQueryBlitsComplete(hContext, pMemInfo, uiWaitForComplete);
+}
struct wl_egl_display*
wl_egl_display_create(struct wl_display *display)
--
2.11.0
From 1b41205d6a48107d46ca4203a08a69bfea733136 Mon Sep 17 00:00:00 2001
From: Jonathan Bakker <xc-racer2@live.ca>
Date: Mon, 24 Jun 2019 15:47:01 -0700
Subject: [PATCH 5/5] Add pvrsrvinit
Uses hybris, finds libsrv_init.so and runs SrvInit for it
---
CMakeLists.txt | 1 +
pvrsrvinit/CMakeLists.txt | 5 +++++
pvrsrvinit/pvrsrvinit.c | 25 +++++++++++++++++++++++++
3 files changed, 31 insertions(+)
create mode 100644 pvrsrvinit/CMakeLists.txt
create mode 100644 pvrsrvinit/pvrsrvinit.c
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7c97d33..577e8d0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,4 +11,5 @@ include_directories ("${PROJECT_SOURCE_DIR}/wsegl")
add_subdirectory (common)
add_subdirectory (libegl)
add_subdirectory (libwayland-egl)
+add_subdirectory (pvrsrvinit)
add_subdirectory (wsegl)
diff --git a/pvrsrvinit/CMakeLists.txt b/pvrsrvinit/CMakeLists.txt
new file mode 100644
index 0000000..25b312b
--- /dev/null
+++ b/pvrsrvinit/CMakeLists.txt
@@ -0,0 +1,5 @@
+add_executable(pvrsrvinit pvrsrvinit.c)
+target_link_libraries(pvrsrvinit hybris-common)
+
+install(TARGETS pvrsrvinit
+ DESTINATION bin)
diff --git a/pvrsrvinit/pvrsrvinit.c b/pvrsrvinit/pvrsrvinit.c
new file mode 100644
index 0000000..e7bca8a
--- /dev/null
+++ b/pvrsrvinit/pvrsrvinit.c
@@ -0,0 +1,25 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <hybris/common/dlfcn.h>
+
+int main()
+{
+ int (*SrvInit)(int x);
+ void *handle = hybris_dlopen("/vendor/lib/libsrv_init.so", RTLD_LAZY);
+ if (!handle) {
+ fprintf(stderr, "failed to open libsrv_init.so");
+ return -1;
+ }
+
+ *(void **) (&SrvInit) = hybris_dlsym(handle, "SrvInit");
+ if (!SrvInit) {
+ fprintf(stderr, "failed to find SrvInit symbol");
+ return -1;
+ }
+
+ SrvInit(1);
+
+ hybris_dlclose(handle);
+
+ return 0;
+}
--
2.11.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment