| From 05e0f3464f02fe32327266a849f0391a6ad06a1d Mon Sep 17 00:00:00 2001 |
| From: Frank Binns <frank.binns@imgtec.com> |
| Date: Tue, 14 Apr 2020 09:47:46 +0100 |
| Subject: [PATCH] Add pvr dri driver |
| |
| --- |
| meson.build | 17 +- |
| meson_options.txt | 4 +- |
| src/mesa/drivers/dri/meson.build | 5 + |
| src/mesa/drivers/dri/pvr/dri_support.h | 1246 ++++++++++++++++ |
| src/mesa/drivers/dri/pvr/img_drm_fourcc.h | 113 ++ |
| src/mesa/drivers/dri/pvr/imgpixfmts.h | 307 ++++ |
| src/mesa/drivers/dri/pvr/imgyuv.h | 58 + |
| src/mesa/drivers/dri/pvr/mesa_context.c | 203 +++ |
| src/mesa/drivers/dri/pvr/meson.build | 48 + |
| src/mesa/drivers/dri/pvr/pvrcb.c | 269 ++++ |
| src/mesa/drivers/dri/pvr/pvrcompat.c | 1529 ++++++++++++++++++++ |
| src/mesa/drivers/dri/pvr/pvrdrawable_mod.c | 384 +++++ |
| src/mesa/drivers/dri/pvr/pvrdri.c | 583 ++++++++ |
| src/mesa/drivers/dri/pvr/pvrdri.h | 171 +++ |
| src/mesa/drivers/dri/pvr/pvrdri_mod.c | 584 ++++++++ |
| src/mesa/drivers/dri/pvr/pvrdri_mod.h | 450 ++++++ |
| src/mesa/drivers/dri/pvr/pvrdri_support.h | 437 ++++++ |
| src/mesa/drivers/dri/pvr/pvrext.c | 701 +++++++++ |
| src/mesa/drivers/dri/pvr/pvrext_mod.c | 276 ++++ |
| src/mesa/drivers/dri/pvr/pvrimage_mod.c | 1282 ++++++++++++++++ |
| src/mesa/drivers/dri/pvr/pvrmesa.h | 36 + |
| src/mesa/drivers/dri/pvr/pvrutil.c | 245 ++++ |
| src/mesa/drivers/dri/pvr/pvrutil_mod.c | 937 ++++++++++++ |
| src/meson.build | 1 + |
| 24 files changed, 9878 insertions(+), 8 deletions(-) |
| create mode 100644 src/mesa/drivers/dri/pvr/dri_support.h |
| create mode 100644 src/mesa/drivers/dri/pvr/img_drm_fourcc.h |
| create mode 100644 src/mesa/drivers/dri/pvr/imgpixfmts.h |
| create mode 100644 src/mesa/drivers/dri/pvr/imgyuv.h |
| create mode 100644 src/mesa/drivers/dri/pvr/mesa_context.c |
| create mode 100644 src/mesa/drivers/dri/pvr/meson.build |
| create mode 100644 src/mesa/drivers/dri/pvr/pvrcb.c |
| create mode 100644 src/mesa/drivers/dri/pvr/pvrcompat.c |
| create mode 100644 src/mesa/drivers/dri/pvr/pvrdrawable_mod.c |
| create mode 100644 src/mesa/drivers/dri/pvr/pvrdri.c |
| create mode 100644 src/mesa/drivers/dri/pvr/pvrdri.h |
| create mode 100644 src/mesa/drivers/dri/pvr/pvrdri_mod.c |
| create mode 100644 src/mesa/drivers/dri/pvr/pvrdri_mod.h |
| create mode 100644 src/mesa/drivers/dri/pvr/pvrdri_support.h |
| create mode 100644 src/mesa/drivers/dri/pvr/pvrext.c |
| create mode 100644 src/mesa/drivers/dri/pvr/pvrext_mod.c |
| create mode 100644 src/mesa/drivers/dri/pvr/pvrimage_mod.c |
| create mode 100644 src/mesa/drivers/dri/pvr/pvrmesa.h |
| create mode 100644 src/mesa/drivers/dri/pvr/pvrutil.c |
| create mode 100644 src/mesa/drivers/dri/pvr/pvrutil_mod.c |
| |
| diff --git a/meson.build b/meson.build |
| index 50d2eec97ef..49400adedc5 100644 |
| --- a/meson.build |
| +++ b/meson.build |
| @@ -96,9 +96,9 @@ if _drivers.contains('auto') |
| if system_has_kms_drm |
| # TODO: PPC, Sparc |
| if ['x86', 'x86_64'].contains(host_machine.cpu_family()) |
| - _drivers = ['i915', 'i965', 'r100', 'r200', 'nouveau'] |
| + _drivers = ['i915', 'i965', 'r100', 'r200', 'nouveau', 'pvr'] |
| elif ['arm', 'aarch64'].contains(host_machine.cpu_family()) |
| - _drivers = [] |
| + _drivers = ['pvr'] |
| else |
| error('Unknown architecture @0@. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.'.format( |
| host_machine.cpu_family())) |
| @@ -118,6 +118,7 @@ with_dri_r100 = _drivers.contains('r100') |
| with_dri_r200 = _drivers.contains('r200') |
| with_dri_nouveau = _drivers.contains('nouveau') |
| with_dri_swrast = _drivers.contains('swrast') |
| +with_dri_pvr = _drivers.contains('pvr') |
| |
| with_dri = _drivers.length() != 0 and _drivers != [''] |
| |
| @@ -1121,15 +1122,17 @@ _drm_radeon_ver = '2.4.71' |
| _drm_nouveau_ver = '2.4.66' |
| _drm_etnaviv_ver = '2.4.89' |
| _drm_intel_ver = '2.4.75' |
| +_drm_pvr_ver = '2.4.60' |
| _drm_ver = '2.4.75' |
| |
| _libdrm_checks = [ |
| - ['intel', with_dri_i915 or with_gallium_i915], |
| - ['amdgpu', with_amd_vk or with_gallium_radeonsi], |
| + ['intel', with_dri_i915 or with_gallium_i915, true], |
| + ['amdgpu', with_amd_vk or with_gallium_radeonsi, true], |
| ['radeon', (with_gallium_radeonsi or with_dri_r100 or with_dri_r200 or |
| - with_gallium_r300 or with_gallium_r600)], |
| - ['nouveau', (with_gallium_nouveau or with_dri_nouveau)], |
| + with_gallium_r300 or with_gallium_r600), true], |
| + ['nouveau', (with_gallium_nouveau or with_dri_nouveau), true], |
| ['etnaviv', with_gallium_etnaviv], |
| + ['pvr', with_dri_pvr, false], |
| ] |
| |
| # VC4 only needs core libdrm support of this version, not a libdrm_vc4 |
| @@ -1154,7 +1157,7 @@ endif |
| |
| # Then get each libdrm module |
| foreach d : _libdrm_checks |
| - if d[1] |
| + if d[1] and d[2] |
| set_variable( |
| 'dep_libdrm_' + d[0], |
| dependency('libdrm_' + d[0], version : '>=' + _drm_ver) |
| diff --git a/meson_options.txt b/meson_options.txt |
| index a723b5406cf..23ce4d0c6a0 100644 |
| --- a/meson_options.txt |
| +++ b/meson_options.txt |
| @@ -38,7 +38,9 @@ option( |
| 'dri-drivers', |
| type : 'array', |
| value : ['auto'], |
| - choices : ['', 'auto', 'i915', 'i965', 'r100', 'r200', 'nouveau', 'swrast'], |
| + choices : [ |
| + '', 'auto', 'i915', 'i965', 'r100', 'r200', 'nouveau', 'swrast', 'pvr', |
| + ], |
| description : 'List of dri drivers to build. If this is set to auto all drivers applicable to the target OS/architecture will be built' |
| ) |
| option( |
| diff --git a/src/mesa/drivers/dri/meson.build b/src/mesa/drivers/dri/meson.build |
| index 0410a5a12ec..fb677add239 100644 |
| --- a/src/mesa/drivers/dri/meson.build |
| +++ b/src/mesa/drivers/dri/meson.build |
| @@ -40,6 +40,11 @@ endif |
| if with_dri_nouveau |
| subdir('nouveau') |
| endif |
| +if with_dri_pvr |
| + subdir('pvr') |
| + dri_drivers += libpvr |
| + dri_link += 'pvr_dri.so' |
| +endif |
| |
| if dri_drivers != [] |
| libmesa_dri_drivers = shared_library( |
| diff --git a/src/mesa/drivers/dri/pvr/dri_support.h b/src/mesa/drivers/dri/pvr/dri_support.h |
| new file mode 100644 |
| index 00000000000..f7dd739fe03 |
| --- /dev/null |
| +++ b/src/mesa/drivers/dri/pvr/dri_support.h |
| @@ -0,0 +1,1246 @@ |
| +/* -*- mode: c; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ |
| +/* vi: set ts=8 sw=8 sts=8: */ |
| +/*************************************************************************/ /*! |
| +@File |
| +@Title PVR DRI interface definition |
| +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved |
| +@License MIT |
| + |
| +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. |
| +*/ /**************************************************************************/ |
| + |
| +#if !defined(__PVRDRIIFCE_H__) |
| +#define __PVRDRIIFCE_H__ |
| + |
| +#include <stdint.h> |
| +#include <stdbool.h> |
| + |
| +#include "imgpixfmts.h" |
| +#include "imgyuv.h" |
| + |
| +typedef enum |
| +{ |
| + PVRDRI_DEVICE_TYPE_INVALID = 0, |
| + PVRDRI_DEVICE_TYPE_UNKNOWN, |
| + PVRDRI_DEVICE_TYPE_DISPLAY, |
| + PVRDRI_DEVICE_TYPE_RENDER, |
| +} PVRDRIDeviceType; |
| + |
| +/* API type. */ |
| +typedef enum |
| +{ |
| + PVRDRI_API_NONE = 0, |
| + PVRDRI_API_GLES1 = 2, |
| + PVRDRI_API_GLES2 = 3, |
| + PVRDRI_API_CL = 4, |
| +} PVRDRIAPIType; |
| + |
| +/* API sub type. */ |
| +typedef enum |
| +{ |
| + PVRDRI_API_SUB_NONE, |
| +} PVRDRIAPISubType; |
| + |
| +typedef enum |
| +{ |
| + PVRDRI_DRAWABLE_NONE = 0, |
| + PVRDRI_DRAWABLE_WINDOW = 1, |
| + PVRDRI_DRAWABLE_PIXMAP = 2, |
| + PVRDRI_DRAWABLE_PBUFFER = 3, |
| +} PVRDRIDrawableType; |
| + |
| +typedef enum |
| +{ |
| + PVRDRI_IMAGE = 1, |
| + PVRDRI_IMAGE_FROM_NAMES, |
| + PVRDRI_IMAGE_FROM_EGLIMAGE, |
| + PVRDRI_IMAGE_FROM_DMABUFS, |
| + PVRDRI_IMAGE_SUBIMAGE, |
| +} PVRDRIImageType; |
| + |
| +typedef enum |
| +{ |
| + PVRDRI_EGLIMAGE_NONE = 0, |
| + PVRDRI_EGLIMAGE_IMGEGL, |
| + PVRDRI_EGLIMAGE_IMGOCL, |
| +} PVRDRIEGLImageType; |
| + |
| +typedef enum |
| +{ |
| + /* Since PVRDRICallbacks version 2 */ |
| + PVRDRI_CONFIG_ATTRIB_INVALID = 0, |
| + PVRDRI_CONFIG_ATTRIB_RENDERABLE_TYPE = 1, |
| + PVRDRI_CONFIG_ATTRIB_RGB_MODE = 2, |
| + PVRDRI_CONFIG_ATTRIB_DOUBLE_BUFFER_MODE = 3, |
| + PVRDRI_CONFIG_ATTRIB_RED_BITS = 4, |
| + PVRDRI_CONFIG_ATTRIB_GREEN_BITS = 5, |
| + PVRDRI_CONFIG_ATTRIB_BLUE_BITS = 6, |
| + PVRDRI_CONFIG_ATTRIB_ALPHA_BITS = 7, |
| + PVRDRI_CONFIG_ATTRIB_RGB_BITS = 8, |
| + PVRDRI_CONFIG_ATTRIB_DEPTH_BITS = 9, |
| + PVRDRI_CONFIG_ATTRIB_STENCIL_BITS = 10, |
| + PVRDRI_CONFIG_ATTRIB_SAMPLE_BUFFERS = 11, |
| + PVRDRI_CONFIG_ATTRIB_SAMPLES = 12, |
| + PVRDRI_CONFIG_ATTRIB_BIND_TO_TEXTURE_RGB = 13, |
| + PVRDRI_CONFIG_ATTRIB_BIND_TO_TEXTURE_RGBA = 14, |
| + PVRDRI_CONFIG_ATTRIB_YUV_ORDER = 15, |
| + PVRDRI_CONFIG_ATTRIB_YUV_NUM_OF_PLANES = 16, |
| + PVRDRI_CONFIG_ATTRIB_YUV_SUBSAMPLE = 17, |
| + PVRDRI_CONFIG_ATTRIB_YUV_DEPTH_RANGE = 18, |
| + PVRDRI_CONFIG_ATTRIB_YUV_CSC_STANDARD = 19, |
| + PVRDRI_CONFIG_ATTRIB_YUV_PLANE_BPP = 20, |
| + |
| + /* Valid for use with with PVRDRICallbacksV2 */ |
| + PVRDRI_CONFIG_ATTRIB_RED_MASK = 21, |
| + PVRDRI_CONFIG_ATTRIB_GREEN_MASK = 22, |
| + PVRDRI_CONFIG_ATTRIB_BLUE_MASK = 23, |
| + PVRDRI_CONFIG_ATTRIB_ALPHA_MASK = 24, |
| + PVRDRI_CONFIG_ATTRIB_SRGB_CAPABLE = 25 |
| +} PVRDRIConfigAttrib; |
| + |
| +typedef enum |
| +{ |
| + /* Since PVRDRICallbacks version 2 */ |
| + PVRDRI_BUFFER_ATTRIB_INVALID = 0, |
| + PVRDRI_BUFFER_ATTRIB_TYPE = 1, |
| + PVRDRI_BUFFER_ATTRIB_WIDTH = 2, |
| + PVRDRI_BUFFER_ATTRIB_HEIGHT = 3, |
| + PVRDRI_BUFFER_ATTRIB_STRIDE = 4, |
| + PVRDRI_BUFFER_ATTRIB_PIXEL_FORMAT = 5, |
| +} PVRDRIBufferAttrib; |
| + |
| +/* The context flags match their __DRI_CTX_FLAG and EGL_CONTEXT counterparts */ |
| +#define PVRDRI_CONTEXT_FLAG_DEBUG 0x00000001 |
| +#define PVRDRI_CONTEXT_FLAG_FORWARD_COMPATIBLE 0x00000002 |
| +#define PVRDRI_CONTEXT_FLAG_ROBUST_BUFFER_ACCESS 0x00000004 |
| + |
| +/* The context error codes match their __DRI_CTX_ERROR counterparts */ |
| +#define PVRDRI_CONTEXT_ERROR_SUCCESS 0 |
| +/* Out of memory */ |
| +#define PVRDRI_CONTEXT_ERROR_NO_MEMORY 1 |
| +/* Unsupported API */ |
| +#define PVRDRI_CONTEXT_ERROR_BAD_API 2 |
| +/* Unsupported version of API */ |
| +#define PVRDRI_CONTEXT_ERROR_BAD_VERSION 3 |
| +/* Unsupported context flag or combination of flags */ |
| +#define PVRDRI_CONTEXT_ERROR_BAD_FLAG 4 |
| +/* Unrecognised context attribute */ |
| +#define PVRDRI_CONTEXT_ERROR_UNKNOWN_ATTRIBUTE 5 |
| +/* Unrecognised context flag */ |
| +#define PVRDRI_CONTEXT_ERROR_UNKNOWN_FLAG 6 |
| + |
| +/* |
| + * The context priority defines match their __DRI_CTX counterparts, and |
| + * the context priority values used by the DDK. |
| + */ |
| +#define PVRDRI_CONTEXT_PRIORITY_LOW 0 |
| +#define PVRDRI_CONTEXT_PRIORITY_MEDIUM 1 |
| +#define PVRDRI_CONTEXT_PRIORITY_HIGH 2 |
| + |
| +/* The image error flags match their __DRI_IMAGE_ERROR counterparts */ |
| +#define PVRDRI_IMAGE_ERROR_SUCCESS 0 |
| +#define PVRDRI_IMAGE_ERROR_BAD_ALLOC 1 |
| +#define PVRDRI_IMAGE_ERROR_BAD_MATCH 2 |
| +#define PVRDRI_IMAGE_ERROR_BAD_PARAMETER 3 |
| +#define PVRDRI_IMAGE_ERROR_BAD_ACCESS 4 |
| + |
| +/* The buffer flags match their __DRI_IMAGE_USE counterparts */ |
| +#define PVDRI_BUFFER_USE_SHARE 0x0001 |
| +#define PVDRI_BUFFER_USE_SCANOUT 0x0002 |
| +#define PVDRI_BUFFER_USE_CURSOR 0x0004 |
| +#define PVDRI_BUFFER_USE_LINEAR 0x0008 |
| + |
| +/* EGL_RENDERABLE_TYPE mask bits */ |
| +#define PVRDRI_API_BIT_GLES 0x0001 |
| +#define PVRDRI_API_BIT_GLES2 0x0004 |
| +#define PVRDRI_API_BIT_GLES3 0x0040 |
| + |
| +/* Mesa config formats. These need not match their MESA_FORMAT counterparts */ |
| +#define PVRDRI_MESA_FORMAT_NONE 0 |
| +#define PVRDRI_MESA_FORMAT_B8G8R8A8_UNORM 1 |
| +#define PVRDRI_MESA_FORMAT_B8G8R8X8_UNORM 2 |
| +#define PVRDRI_MESA_FORMAT_B5G6R5_UNORM 3 |
| +#define PVRDRI_MESA_FORMAT_R8G8B8A8_UNORM 4 |
| +#define PVRDRI_MESA_FORMAT_R8G8B8X8_UNORM 5 |
| +#define PVRDRI_MESA_FORMAT_YCBCR 6 |
| +#define PVRDRI_MESA_FORMAT_YUV420_2PLANE 7 |
| +#define PVRDRI_MESA_FORMAT_YVU420_2PLANE 8 |
| +#define PVRDRI_MESA_FORMAT_B8G8R8A8_SRGB 9 |
| +#define PVRDRI_MESA_FORMAT_R8G8B8A8_SRGB 10 |
| + |
| +/* The blit flags match their DRI counterparts */ |
| +#define PVRDRI_BLIT_FLAG_FLUSH 0x0001 |
| +#define PVRDRI_BLIT_FLAG_FINISH 0x0002 |
| + |
| +/* The image mapping flags match their DRI counterparts */ |
| +#define PVRDRI_IMAGE_TRANSFER_READ 0x1 |
| +#define PVRDRI_IMAGE_TRANSFER_WRITE 0x2 |
| +#define PVRDRI_IMAGE_TRANSFER_READ_WRITE \ |
| + (PVRDRI_IMAGE_TRANSFER_READ | PVRDRI_IMAGE_TRANSFER_WRITE) |
| + |
| +/* The PVRDRI_YUV defines match their __DRI_ATTRIB_YUV counterparts */ |
| +#define PVRDRI_YUV_ORDER_NONE 0x0 |
| +#define PVRDRI_YUV_ORDER_YUV 0x1 |
| +#define PVRDRI_YUV_ORDER_YVU 0x2 |
| +#define PVRDRI_YUV_ORDER_YUYV 0x4 |
| +#define PVRDRI_YUV_ORDER_UYVY 0x8 |
| +#define PVRDRI_YUV_ORDER_YVYU 0x10 |
| +#define PVRDRI_YUV_ORDER_VYUY 0x20 |
| +#define PVRDRI_YUV_ORDER_AYUV 0x40 |
| + |
| +#define PVRDRI_YUV_SUBSAMPLE_NONE 0x0 |
| +#define PVRDRI_YUV_SUBSAMPLE_4_2_0 0x1 |
| +#define PVRDRI_YUV_SUBSAMPLE_4_2_2 0x2 |
| +#define PVRDRI_YUV_SUBSAMPLE_4_4_4 0x4 |
| + |
| +#define PVRDRI_YUV_DEPTH_RANGE_NONE 0x0 |
| +#define PVRDRI_YUV_DEPTH_RANGE_LIMITED 0x1 |
| +#define PVRDRI_YUV_DEPTH_RANGE_FULL 0x2 |
| + |
| +#define PVRDRI_YUV_CSC_STANDARD_NONE 0x0 |
| +#define PVRDRI_YUV_CSC_STANDARD_601 0x1 |
| +#define PVRDRI_YUV_CSC_STANDARD_709 0x2 |
| +#define PVRDRI_YUV_CSC_STANDARD_2020 0x4 |
| + |
| +#define PVRDRI_YUV_PLANE_BPP_NONE 0x0 |
| +#define PVRDRI_YUV_PLANE_BPP_0 0x1 |
| +#define PVRDRI_YUV_PLANE_BPP_8 0x2 |
| +#define PVRDRI_YUV_PLANE_BPP_10 0x4 |
| + |
| +/* Flags for PVRDRICallbacks.DrawableGetParametersV2 */ |
| +/* Since PVRDRICallbacks version 2 */ |
| +#define PVRDRI_GETPARAMS_FLAG_ALLOW_RECREATE 0x1 |
| +/* Since PVRDRICallbacks version 3 */ |
| +#define PVRDRI_GETPARAMS_FLAG_NO_UPDATE 0x2 |
| + |
| +/* |
| + * Capabilities that might be returned by PVRDRIInterface.GetFenceCapabilities. |
| + * These match their _DRI_FENCE_CAP counterparts. |
| + * |
| + * Since PVRDRIInterface version 2. |
| + */ |
| +#define PVRDRI_FENCE_CAP_NATIVE_FD 0x1 |
| + |
| +typedef struct |
| +{ |
| + IMG_PIXFMT ePixFormat; |
| + uint32_t uiWidth; |
| + uint32_t uiHeight; |
| + uint32_t uiStrideInBytes; |
| +} PVRDRIBufferAttribs; |
| + |
| +typedef struct |
| +{ |
| + int sampleBuffers; |
| + int samples; |
| + |
| + int redBits; |
| + int greenBits; |
| + int blueBits; |
| + int alphaBits; |
| + |
| + int rgbBits; |
| + int depthBits; |
| + int stencilBits; |
| + |
| + bool doubleBufferMode; |
| + |
| + int bindToTextureRgb; |
| + int bindToTextureRgba; |
| +} PVRDRIConfigInfo; |
| + |
| +typedef struct IMGEGLImageRec IMGEGLImage; |
| +typedef struct __DRIimageRec __DRIimage; |
| + |
| +/* PVRDRI interface opaque types */ |
| +typedef struct PVRDRIScreenImplRec PVRDRIScreenImpl; |
| +typedef struct PVRDRIContextImplRec PVRDRIContextImpl; |
| +typedef struct PVRDRIDrawableImplRec PVRDRIDrawableImpl; |
| +typedef struct PVRDRIBufferImplRec PVRDRIBufferImpl; |
| + |
| +typedef struct PVRDRIDrawable_TAG PVRDRIDrawable; |
| + |
| +typedef void (*PVRDRIGLAPIProc)(void); |
| + |
| +/* Since PVRDRICallbacks version 2 */ |
| +typedef struct PVRDRIConfigRec PVRDRIConfig; |
| + |
| +/* PVRDRISupportInterface (deprecated) */ |
| +typedef struct { |
| + /********************************************************************** |
| + * Version 0 interface |
| + **********************************************************************/ |
| + |
| + PVRDRIDeviceType (*GetDeviceTypeFromFd)(int iFd); |
| + |
| + bool (*IsFirstScreen)(PVRDRIScreenImpl *psScreenImpl); |
| + |
| + uint32_t (*PixFmtGetDepth)(IMG_PIXFMT eFmt); |
| + uint32_t (*PixFmtGetBPP)(IMG_PIXFMT eFmt); |
| + uint32_t (*PixFmtGetBlockSize)(IMG_PIXFMT eFmt); |
| + |
| + /* ScreenImpl functions */ |
| + PVRDRIScreenImpl *(*CreateScreen)(int iFd); |
| + void (*DestroyScreen)(PVRDRIScreenImpl *psScreenImpl); |
| + |
| + int (*APIVersion)(PVRDRIAPIType eAPI, |
| + PVRDRIAPISubType eAPISub, |
| + PVRDRIScreenImpl *psScreenImpl); |
| + |
| + void *(*EGLGetLibHandle)(PVRDRIAPIType eAPI, |
| + PVRDRIScreenImpl *psScreenImpl); |
| + |
| + PVRDRIGLAPIProc (*EGLGetProcAddress)(PVRDRIAPIType eAPI, |
| + PVRDRIScreenImpl *psScreenImpl, |
| + const char *psProcName); |
| + |
| + bool (*EGLFlushBuffers)(PVRDRIAPIType eAPI, |
| + PVRDRIScreenImpl *psScreenImpl, |
| + PVRDRIContextImpl *psContextImpl, |
| + PVRDRIDrawableImpl *psDrawableImpl, |
| + bool bFlushAllSurfaces, |
| + bool bSwapBuffers, |
| + bool bWaitForHW); |
| + /* Obsolete (no longer supported) */ |
| + bool (*EGLFreeResources)(PVRDRIScreenImpl *psPVRScreenImpl); |
| + void (*EGLMarkRendersurfaceInvalid)(PVRDRIAPIType eAPI, |
| + PVRDRIScreenImpl *psScreenImpl, |
| + PVRDRIContextImpl *psContextImpl); |
| + /* Obsolete (no longer supported) */ |
| + void (*EGLSetFrontBufferCallback)(PVRDRIAPIType eAPI, |
| + PVRDRIScreenImpl *psScreenImpl, |
| + PVRDRIDrawableImpl *psDrawableImpl, |
| + void (*pfnCallback)(PVRDRIDrawable *)); |
| + |
| + /* Obsolete (no longer supported) */ |
| + unsigned (*CreateContext)(PVRDRIContextImpl **ppsContextImpl, |
| + PVRDRIAPIType eAPI, |
| + PVRDRIAPISubType eAPISub, |
| + PVRDRIScreenImpl *psScreenImpl, |
| + const PVRDRIConfigInfo *psConfigInfo, |
| + unsigned uMajorVersion, |
| + unsigned uMinorVersion, |
| + uint32_t uFlags, |
| + bool bNotifyReset, |
| + unsigned uPriority, |
| + PVRDRIContextImpl *psSharedContextImpl); |
| + |
| + void (*DestroyContext)(PVRDRIContextImpl *psContextImpl, |
| + PVRDRIAPIType eAPI, |
| + PVRDRIScreenImpl *psScreenImpl); |
| + |
| + bool (*MakeCurrentGC)(PVRDRIAPIType eAPI, |
| + PVRDRIScreenImpl *psScreenImpl, |
| + PVRDRIContextImpl *psContextImpl, |
| + PVRDRIDrawableImpl *psWriteImpl, |
| + PVRDRIDrawableImpl *psReadImpl); |
| + |
| + void (*MakeUnCurrentGC)(PVRDRIAPIType eAPI, |
| + PVRDRIScreenImpl *psScreenImpl); |
| + |
| + unsigned (*GetImageSource)(PVRDRIAPIType eAPI, |
| + PVRDRIScreenImpl *psScreenImpl, |
| + PVRDRIContextImpl *psContextImpl, |
| + uint32_t uiTarget, |
| + uintptr_t uiBuffer, |
| + uint32_t uiLevel, |
| + IMGEGLImage *psEGLImage); |
| + |
| + bool (*BindTexImage)(PVRDRIAPIType eAPI, |
| + PVRDRIScreenImpl *psScreenImpl, |
| + PVRDRIContextImpl *psContextImpl, |
| + PVRDRIDrawableImpl *psDrawableImpl); |
| + |
| + void (*ReleaseTexImage)(PVRDRIAPIType eAPI, |
| + PVRDRIScreenImpl *psScreenImpl, |
| + PVRDRIContextImpl *psContextImpl, |
| + PVRDRIDrawableImpl *psDrawableImpl); |
| + |
| + /* Obsolete (no longer supported) */ |
| + PVRDRIDrawableImpl *(*CreateDrawable)(PVRDRIDrawable *psPVRDrawable); |
| + |
| + void (*DestroyDrawable)(PVRDRIDrawableImpl *psScreenImpl); |
| + bool (*EGLDrawableCreate)(PVRDRIScreenImpl *psScreenImpl, |
| + PVRDRIDrawableImpl *psDrawableImpl); |
| + bool (*EGLDrawableRecreate)(PVRDRIScreenImpl *psScreenImpl, |
| + PVRDRIDrawableImpl *psDrawableImpl); |
| + bool (*EGLDrawableDestroy)(PVRDRIScreenImpl *psScreenImpl, |
| + PVRDRIDrawableImpl *psDrawableImpl); |
| + void (*EGLDrawableDestroyConfig)(PVRDRIDrawableImpl *psDrawableImpl); |
| + |
| + /* Buffer functions */ |
| + PVRDRIBufferImpl *(*BufferCreate)(PVRDRIScreenImpl *psScreenImpl, |
| + int iWidth, |
| + int iHeight, |
| + unsigned int uiBpp, |
| + unsigned int uiUseFlags, |
| + unsigned int *puiStride); |
| + |
| + PVRDRIBufferImpl *(*BufferCreateWithModifiers)(PVRDRIScreenImpl *psScreenImpl, |
| + int iWidth, |
| + int iHeight, |
| + int iFormat, |
| + IMG_PIXFMT eIMGPixelFormat, |
| + const uint64_t *puiModifiers, |
| + unsigned int uiModifierCount, |
| + unsigned int *puiStride); |
| + |
| + PVRDRIBufferImpl *(*BufferCreateFromNames)(PVRDRIScreenImpl *psScreenImpl, |
| + int iWidth, |
| + int iHeight, |
| + unsigned uiNumPlanes, |
| + const int *piName, |
| + const int *piStride, |
| + const int *piOffset, |
| + const unsigned int *puiWidthShift, |
| + const unsigned int *puiHeightShift); |
| + |
| + /* Obsolete (no longer supported) */ |
| + PVRDRIBufferImpl *(*BufferCreateFromName)(PVRDRIScreenImpl *psScreenImpl, |
| + int iName, |
| + int iWidth, |
| + int iHeight, |
| + int iStride, |
| + int iOffset); |
| + |
| + /* Obsolete (no longer supported) */ |
| + PVRDRIBufferImpl *(*BufferCreateFromFds)(PVRDRIScreenImpl *psScreenImpl, |
| + int iWidth, |
| + int iHeight, |
| + unsigned uiNumPlanes, |
| + const int *piFd, |
| + const int *piStride, |
| + const int *piOffset, |
| + const unsigned int *puiWidthShift, |
| + const unsigned int *puiHeightShift); |
| + |
| + PVRDRIBufferImpl *(*BufferCreateFromFdsWithModifier)(PVRDRIScreenImpl *psScreenImpl, |
| + int iWidth, |
| + int iHeight, |
| + uint64_t uiModifier, |
| + unsigned uiNumPlanes, |
| + const int *piFd, |
| + const int *piStride, |
| + const int *piOffset, |
| + const unsigned int *puiWidthShift, |
| + const unsigned int *puiHeightShift); |
| + |
| + PVRDRIBufferImpl *(*SubBufferCreate)(PVRDRIScreenImpl *psScreen, |
| + PVRDRIBufferImpl *psParent, |
| + int plane); |
| + |
| + void (*BufferDestroy)(PVRDRIBufferImpl *psBuffer); |
| + |
| + int (*BufferGetFd)(PVRDRIBufferImpl *psBuffer); |
| + |
| + int (*BufferGetHandle)(PVRDRIBufferImpl *psBuffer); |
| + |
| + uint64_t (*BufferGetModifier)(PVRDRIBufferImpl *psBuffer); |
| + |
| + int (*BufferGetName)(PVRDRIBufferImpl *psBuffer); |
| + |
| + int (*BufferGetOffset)(PVRDRIBufferImpl *psBuffer); |
| + |
| + /* Image functions */ |
| + IMGEGLImage *(*EGLImageCreate)(void); |
| + IMGEGLImage *(*EGLImageCreateFromBuffer)(int iWidth, |
| + int iHeight, |
| + int iStride, |
| + IMG_PIXFMT ePixelFormat, |
| + IMG_YUV_COLORSPACE eColourSpace, |
| + IMG_YUV_CHROMA_INTERP eChromaUInterp, |
| + IMG_YUV_CHROMA_INTERP eChromaVInterp, |
| + PVRDRIBufferImpl *psBuffer); |
| + |
| + IMGEGLImage *(*EGLImageCreateFromSubBuffer)(IMG_PIXFMT ePixelFormat, |
| + PVRDRIBufferImpl *psSubBuffer); |
| + |
| + IMGEGLImage *(*EGLImageDup)(IMGEGLImage *psIn); |
| + |
| + void (*EGLImageSetCallbackData)(IMGEGLImage *psEGLImage, __DRIimage *image); |
| + |
| + void (*EGLImageDestroyExternal)(PVRDRIScreenImpl *psScreenImpl, |
| + IMGEGLImage *psEGLImage, |
| + PVRDRIEGLImageType eglImageType); |
| + void (*EGLImageFree)(IMGEGLImage *psEGLImage); |
| + |
| + void (*EGLImageGetAttribs)(IMGEGLImage *psEGLImage, |
| + PVRDRIBufferAttribs *psAttribs); |
| + |
| + /* Sync functions */ |
| + void *(*CreateFence)(PVRDRIAPIType eAPI, |
| + PVRDRIScreenImpl *psScreenImpl, |
| + PVRDRIContextImpl *psContextImpl); |
| + |
| + void (*DestroyFence)(void *psDRIFence); |
| + |
| + /* |
| + * When calling ClientWaitSync, the eAPI, psContextImpl and |
| + * bFlushCommands parameters must be set to PVRDRI_API_NONE, |
| + * NULL and false, respectively. |
| + */ |
| + bool (*ClientWaitSync)(PVRDRIAPIType eAPI, |
| + PVRDRIContextImpl *psContextImpl, |
| + void *psDRIFence, |
| + bool bFlushCommands, |
| + bool bTimeout, |
| + uint64_t uiTimeout); |
| + |
| + bool (*ServerWaitSync)(PVRDRIAPIType eAPI, |
| + PVRDRIContextImpl *psContextImpl, |
| + void *psDRIFence); |
| + |
| + /* Obsolete (no longer supported) */ |
| + void (*DestroyFences)(PVRDRIScreenImpl *psScreenImpl); |
| + |
| + /* EGL interface functions */ |
| + |
| + /* Obsolete (no longer supported) */ |
| + bool (*EGLDrawableConfigFromGLMode)(PVRDRIDrawableImpl *psPVRDrawable, |
| + PVRDRIConfigInfo *psConfigInfo, |
| + int supportedAPIs, |
| + IMG_PIXFMT ePixFmt); |
| + |
| + /* Blit functions */ |
| + bool (*BlitEGLImage)(PVRDRIScreenImpl *psScreenImpl, |
| + PVRDRIContextImpl *psContextImpl, |
| + IMGEGLImage *psDstImage, |
| + PVRDRIBufferImpl *psDstBuffer, |
| + IMGEGLImage *psSrcImage, |
| + PVRDRIBufferImpl *psSrcBuffer, |
| + int iDstX, int iDstY, |
| + int iDstWidth, int iDstHeight, |
| + int iSrcX, int iSrcY, |
| + int iSrcWidth, int iSrcHeight, |
| + int iFlushFlag); |
| + |
| + /* Mapping functions */ |
| + void *(*MapEGLImage)(PVRDRIScreenImpl *psScreenImpl, |
| + PVRDRIContextImpl *psContextImpl, |
| + IMGEGLImage *psImage, |
| + PVRDRIBufferImpl *psBuffer, |
| + int iX, int iY, |
| + int iWidth, int iHeight, |
| + unsigned iFlags, |
| + int *piStride, |
| + void **ppvData); |
| + |
| + bool (*UnmapEGLImage)(PVRDRIScreenImpl *psScreenImpl, |
| + PVRDRIContextImpl *psContextImpl, |
| + IMGEGLImage *psImage, PVRDRIBufferImpl *psBuffer, |
| + void *pvData); |
| + |
| + /* PVR utility support functions */ |
| + bool (*MesaFormatSupported)(unsigned fmt); |
| + unsigned (*DepthStencilBitArraySize)(void); |
| + const uint8_t *(*DepthBitsArray)(void); |
| + const uint8_t *(*StencilBitsArray)(void); |
| + unsigned (*MSAABitArraySize)(void); |
| + const uint8_t *(*MSAABitsArray)(void); |
| + uint32_t (*MaxPBufferWidth)(void); |
| + uint32_t (*MaxPBufferHeight)(void); |
| + |
| + unsigned (*GetNumAPIFuncs)(PVRDRIAPIType eAPI); |
| + const char *(*GetAPIFunc)(PVRDRIAPIType eAPI, unsigned index); |
| + |
| + int (*QuerySupportedFormats)(PVRDRIScreenImpl *psScreenImpl, |
| + unsigned uNumFormats, |
| + const int *piFormats, |
| + const IMG_PIXFMT *peImgFormats, |
| + bool *pbSupported); |
| + |
| + int (*QueryModifiers)(PVRDRIScreenImpl *psScreenImpl, |
| + int iFormat, |
| + IMG_PIXFMT eImgFormat, |
| + uint64_t *puModifiers, |
| + unsigned *puExternalOnly); |
| + |
| + /********************************************************************** |
| + * Version 1 functions |
| + **********************************************************************/ |
| + |
| + unsigned (*CreateContextV1)(PVRDRIScreenImpl *psScreenImpl, |
| + PVRDRIContextImpl *psSharedContextImpl, |
| + PVRDRIConfig *psConfig, |
| + PVRDRIAPIType eAPI, |
| + PVRDRIAPISubType eAPISub, |
| + unsigned uMajorVersion, |
| + unsigned uMinorVersion, |
| + uint32_t uFlags, |
| + bool bNotifyReset, |
| + unsigned uPriority, |
| + PVRDRIContextImpl **ppsContextImpl); |
| + |
| + PVRDRIDrawableImpl *(*CreateDrawableWithConfig)(PVRDRIDrawable *psPVRDrawable, |
| + PVRDRIConfig *psConfig); |
| + |
| + /********************************************************************** |
| + * Version 2 functions |
| + **********************************************************************/ |
| + |
| + unsigned (*GetFenceCapabilities)(PVRDRIScreenImpl *psScreenImpl); |
| + |
| + void *(*CreateFenceFd)(PVRDRIAPIType eAPI, |
| + PVRDRIScreenImpl *psScreenImpl, |
| + PVRDRIContextImpl *psContextImpl, |
| + int iFd); |
| + |
| + int (*GetFenceFd)(void *psDRIFence); |
| +} PVRDRISupportInterface; |
| + |
| +/* Callbacks into non-impl layer (deprecated) */ |
| +typedef struct |
| +{ |
| + /********************************************************************** |
| + * Version 0 callbacks |
| + **********************************************************************/ |
| + |
| + /* Obsolete (no longer supported) */ |
| + bool (*DrawableRecreate)(PVRDRIDrawable *psPVRDrawable); |
| + /* Obsolete (no longer supported) */ |
| + bool (*DrawableGetParameters)(PVRDRIDrawable *psPVRDrawable, |
| + PVRDRIBufferImpl **ppsDstBuffer, |
| + PVRDRIBufferImpl **ppsAccumBuffer, |
| + PVRDRIBufferAttribs *psAttribs, |
| + bool *pbDoubleBuffered); |
| + |
| + PVRDRIImageType (*ImageGetSharedType)(__DRIimage *image); |
| + PVRDRIBufferImpl *(*ImageGetSharedBuffer)(__DRIimage *image); |
| + IMGEGLImage *(*ImageGetSharedEGLImage)(__DRIimage *image); |
| + IMGEGLImage *(*ImageGetEGLImage)(__DRIimage *image); |
| + __DRIimage *(*ScreenGetDRIImage)(void *hEGLImage); |
| + void (*RefImage)(__DRIimage *image); |
| + void (*UnrefImage)(__DRIimage *image); |
| + |
| + /* |
| + * If the DRI module calls PVRDRIRegisterCallbacks, or |
| + * PVRDRIRegisterVersionedCallbacks with any version number, |
| + * the DRI support library can use the callbacks above. |
| + * The callbacks below can only be called if |
| + * PVRDRIRegisterVersionedCallbacks is called with a suitable |
| + * version number. |
| + */ |
| + |
| + /********************************************************************** |
| + * Version 1 callbacks |
| + **********************************************************************/ |
| + |
| + /* Obsolete (no longer supported) */ |
| + bool (*DrawableGetParametersV1)(PVRDRIDrawable *psPVRDrawable, |
| + bool bAllowRecreate, |
| + PVRDRIBufferImpl **ppsDstBuffer, |
| + PVRDRIBufferImpl **ppsAccumBuffer, |
| + PVRDRIBufferAttribs *psAttribs, |
| + bool *pbDoubleBuffered); |
| + |
| + /* |
| + * Register the DRI Support interface with the DRI module. |
| + * The caller is not required to preserve the PVRDRICallbacks structure |
| + * after the call, so the callee must make a copy. |
| + */ |
| + bool (*RegisterSupportInterfaceV1)(const PVRDRISupportInterface *psInterface, |
| + unsigned uVersion); |
| + |
| + /********************************************************************** |
| + * Version 2 callbacks |
| + **********************************************************************/ |
| + |
| + bool (*ConfigQuery)(const PVRDRIConfig *psConfig, |
| + PVRDRIConfigAttrib eConfigAttrib, |
| + int *piValueOut); |
| + /* |
| + * DrawableGetParametersV2 is a replacement for DrawableGetParametersV1. |
| + * Unlike earlier versions, the caller is expected to query drawable |
| + * information (via DrawableQuery) instead of this information being |
| + * returned by the callback. |
| + */ |
| + bool (*DrawableGetParametersV2)(PVRDRIDrawable *psPVRDrawable, |
| + uint32_t uiFlags, |
| + PVRDRIBufferImpl **ppsDstBuffer, |
| + PVRDRIBufferImpl **ppsAccumBuffer); |
| + bool (*DrawableQuery)(const PVRDRIDrawable *psPVRDrawable, |
| + PVRDRIBufferAttrib eBufferAttrib, |
| + uint32_t *uiValueOut); |
| + |
| + /********************************************************************** |
| + * Version 3 callbacks |
| + **********************************************************************/ |
| +} PVRDRICallbacks; |
| + |
| +/* |
| + * The caller of PVRDRIRegisterVersionedCallbacks is not required to preserve |
| + * the PVRDRICallbacks structure after the call, so the callee may need to |
| + * make a copy of the structure. |
| + */ |
| +bool PVRDRIRegisterVersionedCallbacks(const PVRDRICallbacks *psCallbacks, |
| + unsigned uVersion); |
| + |
| +/* The context flags match their __DRI_CTX_RESET counterparts */ |
| +#define PVRDRI_CONTEXT_RESET_NO_NOTIFICATION 0 |
| +#define PVRDRI_CONTEXT_RESET_LOSE_CONTEXT 1 |
| + |
| +/* The context flags match their __DRI_CTX_RELEASE counterparts */ |
| +#define PVRDRI_CONTEXT_RELEASE_BEHAVIOR_NONE 0 |
| +#define PVRDRI_CONTEXT_RELEASE_BEHAVIOR_FLUSH 1 |
| + |
| +/* The flush flags match their __DRI2_FLUSH counterparts */ |
| +#define PVRDRI_FLUSH_DRAWABLE (1 << 0) |
| +#define PVRDRI_FLUSH_CONTEXT (1 << 1) |
| +#define PVRDRI_FLUSH_INVALIDATE_ANCILLARY (1 << 2) |
| + |
| +/* The throttle reason defines match their __DRI2_THROTTLE counterparts */ |
| +#define PVRDRI_THROTTLE_SWAPBUFFER 0 |
| +#define PVRDRI_THROTTLE_COPYSUBBUFFER 1 |
| +#define PVRDRI_THROTTLE_FLUSHFRONT 2 |
| + |
| +/* The render query defines match their __DRI2_RENDERER_HAS counterparts */ |
| +#define PVRDRI_RENDERER_HAS_TEXTURE_3D 0x000b |
| +#define PVRDRI_RENDERER_HAS_FRAMEBUFFER_SRGB 0x000c |
| + |
| +#define PVRDRI_RENDERER_HAS_CONTEXT_PRIORITY 0x000d |
| +#define PVRDRI_RENDERER_HAS_CONTEXT_PRIORITY_LOW (1 << 0) |
| +#define PVRDRI_RENDERER_HAS_CONTEXT_PRIORITY_MEDIUM (1 << 1) |
| +#define PVRDRI_RENDERER_HAS_CONTEXT_PRIORITY_HIGH (1 << 2) |
| + |
| +#define PVRDRI_RENDERER_OPENGL_ES2_CONTEXT_CLIENT_VERSION_IMG 0x7001 |
| + |
| +/* The fence extension defines match their __DRI2_FENCE counterparts */ |
| +#define PVRDRI_FENCE_TIMEOUT_INFINITE 0xffffffffffffffffull |
| +#define PVRDRI_FENCE_FLAG_FLUSH_COMMANDS (1 << 0) |
| + |
| +/* The YUV defines match their __DRI_YUV counterparts */ |
| +#define PVRDRI_YUV_COLOR_SPACE_UNDEFINED 0 |
| +#define PVRDRI_YUV_COLOR_SPACE_ITU_REC601 0x327F |
| +#define PVRDRI_YUV_COLOR_SPACE_ITU_REC709 0x3280 |
| +#define PVRDRI_YUV_COLOR_SPACE_ITU_REC2020 0x3281 |
| + |
| +#define PVRDRI_YUV_RANGE_UNDEFINED 0 |
| +#define PVRDRI_YUV_FULL_RANGE 0x3282 |
| +#define PVRDRI_YUV_NARROW_RANGE 0x3283 |
| + |
| +#define PVRDRI_YUV_CHROMA_SITING_UNDEFINED 0 |
| +#define PVRDRI_YUV_CHROMA_SITING_0 0x3284 |
| +#define PVRDRI_YUV_CHROMA_SITING_0_5 0x3285 |
| + |
| +/* |
| + * The image component defines match their __DRI2_IMAGE_COMPONENTS |
| + * counterparts. |
| + */ |
| +#define PVRDRI_IMAGE_COMPONENTS_RGB 0x3001 |
| +#define PVRDRI_IMAGE_COMPONENTS_RGBA 0x3002 |
| +#define PVRDRI_IMAGE_COMPONENTS_Y_U_V 0x3003 |
| +#define PVRDRI_IMAGE_COMPONENTS_Y_UV 0x3004 |
| +#define PVRDRI_IMAGE_COMPONENTS_Y_XUXV 0x3005 |
| +#define PVRDRI_IMAGE_COMPONENTS_R 0x3006 |
| +#define PVRDRI_IMAGE_COMPONENTS_RG 0x3007 |
| +#define PVRDRI_IMAGE_COMPONENTS_Y_UXVX 0x3008 |
| +#define PVRDRI_IMAGE_COMPONENTS_AYUV 0x3009 |
| +#define PVRDRI_IMAGE_COMPONENTS_XYUV 0x300A |
| +#define PVRDRI_IMAGE_COMPONENTS_EXTERNAL 0x300B |
| + |
| +/* |
| + * The image format modifier attribute defines match their |
| + * __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB counterparts. |
| + */ |
| +#define PVRDRI_IMAGE_FORMAT_MODIFIER_ATTRIB_PLANE_COUNT 0x0001 |
| + |
| +/* The image attribute defines match their __DRI_IMAGE_ATTRIB counterparts */ |
| +#define PVRDRI_IMAGE_ATTRIB_STRIDE 0x2000 |
| +#define PVRDRI_IMAGE_ATTRIB_HANDLE 0x2001 |
| +#define PVRDRI_IMAGE_ATTRIB_NAME 0x2002 |
| +#define PVRDRI_IMAGE_ATTRIB_FORMAT 0x2003 |
| +#define PVRDRI_IMAGE_ATTRIB_WIDTH 0x2004 |
| +#define PVRDRI_IMAGE_ATTRIB_HEIGHT 0x2005 |
| +#define PVRDRI_IMAGE_ATTRIB_COMPONENTS 0x2006 |
| +#define PVRDRI_IMAGE_ATTRIB_FD 0x2007 |
| +#define PVRDRI_IMAGE_ATTRIB_FOURCC 0x2008 |
| +#define PVRDRI_IMAGE_ATTRIB_NUM_PLANES 0x2009 |
| +#define PVRDRI_IMAGE_ATTRIB_OFFSET 0x200A |
| +#define PVRDRI_IMAGE_ATTRIB_MODIFIER_LOWER 0x200B |
| +#define PVRDRI_IMAGE_ATTRIB_MODIFIER_UPPER 0x200C |
| + |
| +/* The GL defines match their EGL_GL counterparts */ |
| +#define PVRDRI_GL_RENDERBUFFER 0x30B9 |
| +#define PVRDRI_GL_TEXTURE_2D 0x30B1 |
| +#define PVRDRI_GL_TEXTURE_3D 0x30B2 |
| +#define PVRDRI_GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x30B3 |
| +#define PVRDRI_GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x30B4 |
| +#define PVRDRI_GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x30B5 |
| +#define PVRDRI_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x30B6 |
| +#define PVRDRI_GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x30B7 |
| +#define PVRDRI_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x30B8 |
| + |
| +/* The CL defines match their EGL_CL counterparts */ |
| +#define PVRDRI_CL_IMAGE_IMG 0x6010 |
| + |
| +/* The swap attribute defines match their __DRI_ATTRIB_SWAP counterparts */ |
| +#define PVRDRI_ATTRIB_SWAP_NONE 0x0000 |
| +#define PVRDRI_ATTRIB_SWAP_EXCHANGE 0x8061 |
| +#define PVRDRI_ATTRIB_SWAP_COPY 0x8062 |
| +#define PVRDRI_ATTRIB_SWAP_UNDEFINED 0x8063 |
| + |
| +struct __DRIscreenRec; |
| +struct __DRIcontextRec; |
| +struct __DRIdrawableRec; |
| +struct __DRIbufferRec; |
| +struct __DRIconfigRec; |
| + |
| +struct DRISUPScreen; |
| +struct DRISUPContext; |
| +struct DRISUPDrawable; |
| +struct DRISUPBuffer; |
| + |
| +struct PVRDRIContextConfig |
| +{ |
| + unsigned int uMajorVersion; |
| + unsigned int uMinorVersion; |
| + uint32_t uFlags; |
| + |
| + int iResetStrategy; |
| + unsigned int uPriority; |
| + int iReleaseBehavior; |
| +}; |
| + |
| +/* The image capability defines match their __DRI_IMAGE_CAP counterparts */ |
| +#define PVRDRI_IMAGE_CAP_GLOBAL_NAMES 1 |
| + |
| +/* |
| + * PVR DRI Support interface V2. |
| + * This structure may change over time, as older interfaces become obsolete. |
| + * For example, the v0 interface may be removed if superseded by newer |
| + * interfaces. |
| + */ |
| +struct PVRDRISupportInterfaceV2 |
| +{ |
| + struct |
| + { |
| + struct DRISUPScreen *(*CreateScreen) |
| + (struct __DRIscreenRec *psDRIScreen, |
| + int iFD, |
| + bool bUseInvalidate, |
| + void *pvLoaderPrivate, |
| + const struct __DRIconfigRec ***pppsConfigs, |
| + int *piMaxGLES1Version, |
| + int *piMaxGLES2Version); |
| + |
| + void (*DestroyScreen) |
| + (struct DRISUPScreen *psDRISUPScreen); |
| + |
| + unsigned int (*CreateContext) |
| + (PVRDRIAPIType eAPI, |
| + PVRDRIConfig *psPVRDRIConfig, |
| + struct PVRDRIContextConfig *psCtxConfig, |
| + struct __DRIcontextRec *psDRIContext, |
| + struct DRISUPContext *psDRISUPSharedContext, |
| + struct DRISUPScreen *psDRISUPScreen, |
| + struct DRISUPContext **ppsDRISUPContext); |
| + |
| + void (*DestroyContext) |
| + (struct DRISUPContext *psDRISUPContext); |
| + |
| + struct DRISUPDrawable *(*CreateDrawable) |
| + (struct __DRIdrawableRec *psDRIDrawable, |
| + struct DRISUPScreen *psDRISUPDrawable, |
| + void *pvLoaderPrivate, |
| + PVRDRIConfig *psPVRDRIConfig); |
| + |
| + void (*DestroyDrawable) |
| + (struct DRISUPDrawable *psDRISUPDrawable); |
| + |
| + bool (*MakeCurrent) |
| + (struct DRISUPContext *psDRISUPContext, |
| + struct DRISUPDrawable *psDRISUPWrite, |
| + struct DRISUPDrawable *psDRISUPRead); |
| + |
| + bool (*UnbindContext) |
| + (struct DRISUPContext *psDRISUPContext); |
| + |
| + struct DRISUPBuffer *(*AllocateBuffer) |
| + (struct DRISUPScreen *psDRISUPScreen, |
| + unsigned int uAttachment, |
| + unsigned int uFormat, |
| + int iWidth, |
| + int iHeight, |
| + unsigned int *puName, |
| + unsigned int *puPitch, |
| + unsigned int *puCPP, |
| + unsigned int *puFlags); |
| + |
| + void (*ReleaseBuffer) |
| + (struct DRISUPScreen *psDRISUPScreen, |
| + struct DRISUPBuffer *psDRISUPBuffer); |
| + |
| + /* Functions to support the DRI TexBuffer extension */ |
| + void (*SetTexBuffer2) |
| + (struct DRISUPContext *psDRISUPContext, |
| + int iTarget, |
| + int iFormat, |
| + struct DRISUPDrawable *psDRISUPDrawable); |
| + |
| + void (*ReleaseTexBuffer) |
| + (struct DRISUPContext *psDRISUPContext, |
| + int iTarget, |
| + struct DRISUPDrawable *psDRISUPDrawable); |
| + |
| + /* Functions to support the DRI Flush extension */ |
| + void (*Flush) |
| + (struct DRISUPDrawable *psDRISUPDrawable); |
| + |
| + void (*Invalidate) |
| + (struct DRISUPDrawable *psDRISUPDrawable); |
| + |
| + void (*FlushWithFlags) |
| + (struct DRISUPContext *psDRISUPContext, |
| + struct DRISUPDrawable *psDRISUPDrawable, |
| + unsigned int uFlags, |
| + unsigned int uThrottleReason); |
| + |
| + /* Functions to support the DRI Image extension */ |
| + __DRIimage *(*CreateImageFromName) |
| + (struct DRISUPScreen *psDRISUPScreen, |
| + int iWidth, |
| + int iHeight, |
| + int iFourCC, |
| + int iName, |
| + int iPitch, |
| + void *pvLoaderPrivate); |
| + |
| + __DRIimage *(*CreateImageFromRenderbuffer) |
| + (struct DRISUPContext *psDRISUPContext, |
| + int iRenderBuffer, |
| + void *pvLoaderPrivate); |
| + |
| + void (*DestroyImage) |
| + (__DRIimage *psImage); |
| + |
| + __DRIimage *(*CreateImage) |
| + (struct DRISUPScreen *psDRISUPScreen, |
| + int iWidth, |
| + int iHeight, |
| + int iFourCC, |
| + unsigned int uUse, |
| + void *pvLoaderPrivate); |
| + |
| + bool (*QueryImage) |
| + (__DRIimage *psImage, |
| + int iAttrib, |
| + int *iValue); |
| + |
| + __DRIimage *(*DupImage) |
| + (__DRIimage *psImage, |
| + void *pvLoaderPrivate); |
| + |
| + bool (*ValidateImageUsage) |
| + (__DRIimage *psImage, |
| + unsigned int uUse); |
| + |
| + __DRIimage *(*CreateImageFromNames) |
| + (struct DRISUPScreen *psDRISUPScreen, |
| + int iWidth, |
| + int iHeight, |
| + int iFourCC, |
| + int *piNames, |
| + int iNumNames, |
| + int *piStrides, |
| + int *piOffsets, |
| + void *pvLoaderPrivate); |
| + __DRIimage *(*FromPlanar)(__DRIimage *psImage, |
| + int iPlane, |
| + void *pvLoaderPrivate); |
| + |
| + __DRIimage *(*CreateImageFromTexture) |
| + (struct DRISUPContext *psDRISUPContext, |
| + int iTarget, |
| + unsigned int uTexture, |
| + int iDepth, |
| + int iLevel, |
| + unsigned int *puError, |
| + void *pvLoaderPrivate); |
| + |
| + __DRIimage *(*CreateImageFromFDs) |
| + (struct DRISUPScreen *psDRISUPcreen, |
| + int iWidth, |
| + int iHeight, |
| + int iFourCC, |
| + int *piFDs, |
| + int iNumFDs, |
| + int *piStrides, |
| + int *piOffsets, |
| + void *pvLoaderPrivate); |
| + |
| + __DRIimage *(*CreateImageFromDMABufs) |
| + (struct DRISUPScreen *psDRISUPScreen, |
| + int iWidth, |
| + int iHeight, |
| + int iFourCC, |
| + int *piFDs, |
| + int iNumFDs, |
| + int *piStrides, |
| + int *piOffsets, |
| + unsigned int uColorSpace, |
| + unsigned int uSampleRange, |
| + unsigned int uHorizSiting, |
| + unsigned int uVertSiting, |
| + unsigned int *puError, |
| + void *pvLoaderPrivate); |
| + |
| + int (*GetImageCapabilities) |
| + (struct DRISUPScreen *psDRISUPScreen); |
| + |
| + void (*BlitImage) |
| + (struct DRISUPContext *psDRISUPContext, |
| + __DRIimage *psDst, |
| + __DRIimage *psSrc, |
| + int iDstX0, |
| + int iDstY0, |
| + int iDstWidth, |
| + int iDstHeight, |
| + int iSrcX0, int |
| + iSrcY0, |
| + int iSrcWidth, |
| + int iSrcHeight, |
| + int iFlushFlag); |
| + |
| + void *(*MapImage) |
| + (struct DRISUPContext *psDRISUPContext, |
| + __DRIimage *psImage, |
| + int iX0, |
| + int iY0, |
| + int iWidth, |
| + int iHeight, |
| + unsigned int uFlags, |
| + int *piStride, |
| + void **ppvData); |
| + |
| + void (*UnmapImage) |
| + (struct DRISUPContext *psDRISUPContext, |
| + __DRIimage *psImage, |
| + void *pvData); |
| + |
| + __DRIimage *(*CreateImageWithModifiers) |
| + (struct DRISUPScreen *psDRISUPScreen, |
| + int iWidth, |
| + int iHeight, |
| + int iFourCC, |
| + const uint64_t *puModifiers, |
| + const unsigned int uModifierCount, |
| + void *pvLoaderPrivate); |
| + |
| + __DRIimage *(*CreateImageFromDMABufs2) |
| + (struct DRISUPScreen *psDRISUPScreen, |
| + int iWidth, |
| + int iHeight, |
| + int iFourCC, |
| + uint64_t uModifier, |
| + int *piFDs, |
| + int iNumFDs, |
| + int *piStrides, |
| + int *piOffsets, |
| + unsigned int uColorSpace, |
| + unsigned int uSampleRange, |
| + unsigned int uHorizSiting, |
| + unsigned int uVertSiting, |
| + unsigned int *puError, |
| + void *pvLoaderPrivate); |
| + |
| + bool (*QueryDMABufFormats) |
| + (struct DRISUPScreen *psDRISUPScreen, |
| + int iMax, |
| + int *piFormats, |
| + int *piCount); |
| + |
| + bool (*QueryDMABufModifiers) |
| + (struct DRISUPScreen *psDRISUPScreen, |
| + int iFourCC, |
| + int iMax, |
| + uint64_t *puModifiers, |
| + unsigned int *piExternalOnly, |
| + int *piCount); |
| + |
| + bool (*QueryDMABufFormatModifierAttribs) |
| + (struct DRISUPScreen *psDRISUPScreen, |
| + uint32_t uFourcc, |
| + uint64_t uModifier, |
| + int iAttrib, |
| + uint64_t *puValue); |
| + |
| + __DRIimage *(*CreateImageFromRenderBuffer2) |
| + (struct DRISUPContext *psDRISUPContext, |
| + int iRenderBuffer, |
| + void *pvLoaderPrivate, |
| + unsigned int *puError); |
| + |
| + __DRIimage *(*CreateImageFromBuffer) |
| + (struct DRISUPContext *psDRISUPContext, |
| + int iTarget, |
| + void *pvBuffer, |
| + unsigned int *puError, |
| + void *pvLoaderPrivate); |
| + |
| + /* Functions to support the DRI Renderer Query extension */ |
| + int (*QueryRendererInteger) |
| + (struct DRISUPScreen *psDRISUPScreen, |
| + int iAttribute, |
| + unsigned int *puValue); |
| + |
| + int (*QueryRendererString) |
| + (struct DRISUPScreen *psDRISUPScreen, |
| + int iAttribute, |
| + const char **ppszValue); |
| + |
| + /* Functions to support the DRI Fence extension */ |
| + void *(*CreateFence) |
| + (struct DRISUPContext *psDRISUPContext); |
| + |
| + void (*DestroyFence) |
| + (struct DRISUPScreen *psDRISUPScreen, |
| + void *pvFence); |
| + |
| + bool (*ClientWaitSync) |
| + (struct DRISUPContext *psDRISUPContext, |
| + void *pvFence, |
| + unsigned int uFlags, |
| + uint64_t uTimeout); |
| + |
| + void (*ServerWaitSync) |
| + (struct DRISUPContext *psDRISUPContext, |
| + void *pvFence, |
| + unsigned int uFlags); |
| + |
| + unsigned int (*GetFenceCapabilities) |
| + (struct DRISUPScreen *psDRISUPScreen); |
| + |
| + void *(*CreateFenceFD) |
| + (struct DRISUPContext *psDRISUPContext, |
| + int iFD); |
| + |
| + int (*GetFenceFD) |
| + (struct DRISUPScreen *psDRISUPScreen, |
| + void *pvFence); |
| + |
| + unsigned int (*GetNumAPIProcs) |
| + (struct DRISUPScreen *psDRISUPScreen, |
| + PVRDRIAPIType eAPI); |
| + |
| + const char *(*GetAPIProcName) |
| + (struct DRISUPScreen *psDRISUPScreen, |
| + PVRDRIAPIType eAPI, |
| + unsigned int uIndex); |
| + |
| + void *(*GetAPIProcAddress) |
| + (struct DRISUPScreen *psDRISUPScreen, |
| + PVRDRIAPIType eAPI, |
| + unsigned int uIndex); |
| + |
| + void (*SetDamageRegion) |
| + (struct DRISUPDrawable *psDRISUPDrawable, |
| + unsigned int uNRects, |
| + int *piRects); |
| + } v0; |
| + /* The v1 interface is an extension of v0, so v0 is required as well */ |
| + struct { |
| + void *(*GetFenceFromCLEvent) |
| + (struct DRISUPScreen *psDRISUPScreen, |
| + intptr_t iCLEvent); |
| + } v1; |
| +}; |
| + |
| +/* |
| + * Buffer mask values for the GetBuffers callback. These are the same as |
| + * their enum __DRIimageBufferMask counterparts. |
| + */ |
| +#define PVRDRI_IMAGE_BUFFER_BACK (1U << 0) |
| +#define PVRDRI_IMAGE_BUFFER_FRONT (1U << 1) |
| +#define PVRDRI_IMAGE_BUFFER_PREV (1U << 31) |
| + |
| +struct PVRDRIImageList { |
| + uint32_t uImageMask; |
| + __DRIimage *psBack; |
| + __DRIimage *psFront; |
| + __DRIimage *psPrev; |
| +}; |
| + |
| +/* The loader capabilities defines match their dri_loader_cap counterparts */ |
| +#define PVRDRI_LOADER_CAP_RGBA_ORDERING 0 |
| + |
| +/* |
| + * PVR DRI Support callback interface V2. |
| + * This structure may change over time, as older interfaces become obsolete. |
| + * For example, the v0 interface may be removed if superseded by newer |
| + * interfaces. |
| + */ |
| +struct PVRDRICallbacksV2 |
| +{ |
| + struct { |
| + bool (*RegisterSupportInterface) |
| + (const void *psInterface, |
| + unsigned int uVersion, |
| + unsigned int uMinVersion); |
| + |
| + int (*GetBuffers) |
| + (struct __DRIdrawableRec *psDRIDrawable, |
| + unsigned int uFourCC, |
| + uint32_t *puStamp, |
| + void *pvLoaderPrivate, |
| + uint32_t uBufferMask, |
| + struct PVRDRIImageList *psImageList); |
| + |
| + bool (*CreateConfigs) |
| + (struct __DRIconfigRec ***pppsConfigs, |
| + struct __DRIscreenRec *psDRIScreen, |
| + int iPVRDRIMesaFormat, |
| + const uint8_t *puDepthBits, |
| + const uint8_t *puStencilBits, |
| + unsigned int uNumDepthStencilBits, |
| + const unsigned int *puDBModes, |
| + unsigned int uNumDBModes, |
| + const uint8_t *puMSAASamples, |
| + unsigned int uNumMSAAModes, |
| + bool bEnableAccum, |
| + bool bColorDepthMatch, |
| + bool bMutableRenderBuffer, |
| + int iYUVDepthRange, |
| + int iYUVCSCStandard, |
| + uint32_t uMaxPbufferWidth, |
| + uint32_t uMaxPbufferHeight); |
| + |
| + struct __DRIconfigRec **(*ConcatConfigs) |
| + (struct __DRIscreenRec *psDRIScreen, |
| + struct __DRIconfigRec **ppsConfigA, |
| + struct __DRIconfigRec **ppsConfigB); |
| + |
| + bool (*ConfigQuery) |
| + (const PVRDRIConfig *psConfig, |
| + PVRDRIConfigAttrib eConfigAttrib, |
| + unsigned int *puValueOut); |
| + |
| + __DRIimage *(*LookupEGLImage) |
| + (struct __DRIscreenRec *psDRIScreen, |
| + void *pvImage, |
| + void *pvLoaderPrivate); |
| + |
| + unsigned int (*GetCapability) |
| + (struct __DRIscreenRec *psDRIScreen, |
| + unsigned int uCapability); |
| + } v0; |
| +}; |
| + |
| +#endif /* defined(__PVRDRIIFCE_H__) */ |
| diff --git a/src/mesa/drivers/dri/pvr/img_drm_fourcc.h b/src/mesa/drivers/dri/pvr/img_drm_fourcc.h |
| new file mode 100644 |
| index 00000000000..8d570ff8f53 |
| --- /dev/null |
| +++ b/src/mesa/drivers/dri/pvr/img_drm_fourcc.h |
| @@ -0,0 +1,113 @@ |
| +/*************************************************************************/ /*! |
| +@File |
| +@Title Wrapper around drm_fourcc.h |
| +@Description FourCCs and DRM framebuffer modifiers that are not in the |
| + Kernel's and libdrm's drm_fourcc.h can be added here. |
| +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved |
| +@License MIT |
| + |
| +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. |
| +*/ /**************************************************************************/ |
| + |
| +#ifndef IMG_DRM_FOURCC_H |
| +#define IMG_DRM_FOURCC_H |
| + |
| +#if defined(__KERNEL__) |
| +#include <drm/drm_fourcc.h> |
| +#else |
| +/* |
| + * Include types.h to workaround versions of libdrm older than 2.4.68 |
| + * not including the correct headers. |
| + */ |
| +#include <linux/types.h> |
| + |
| +#include <drm_fourcc.h> |
| +#endif |
| + |
| +/* |
| + * Don't get too inspired by this example :) |
| + * ADF doesn't support DRM modifiers, so the memory layout had to be |
| + * included in the fourcc name, but the proper way to specify information |
| + * additional to pixel formats is to use DRM modifiers. |
| + * |
| + * See upstream drm_fourcc.h for the proper naming convention. |
| + */ |
| +#ifndef DRM_FORMAT_BGRA8888_DIRECT_16x4 |
| +#define DRM_FORMAT_BGRA8888_DIRECT_16x4 fourcc_code('I', 'M', 'G', '0') |
| +#endif |
| + |
| +/* |
| + * Upstream doesn't have a floating point format yet, so let's make one |
| + * up. |
| + * Note: The kernel's core DRM needs to know about this format, |
| + * otherwise it won't be supported and should not be exposed by our |
| + * kernel modules either. |
| + * Refer to the provided kernel patch adding this format. |
| + */ |
| +#if !defined(__KERNEL__) |
| +#define DRM_FORMAT_ABGR16_IMG fourcc_code('I', 'M', 'G', '1') |
| +#endif |
| + |
| +/* |
| + * Upstream does not have a packed 10 Bits Per Channel YVU format yet, |
| + * so let`s make one up. |
| + * Note: at the moment this format is not intended to be used with |
| + * a framebuffer, so the kernels core DRM doesn`t need to know |
| + * about this format. This means that the kernel doesn`t need |
| + * to be patched. |
| + */ |
| +#if !defined(__KERNEL__) |
| +#define DRM_FORMAT_YVU444_PACK10_IMG fourcc_code('I', 'M', 'G', '2') |
| +#define DRM_FORMAT_YUV422_2PLANE_PACK10_IMG fourcc_code('I', 'M', 'G', '3') |
| +#define DRM_FORMAT_YUV420_2PLANE_PACK10_IMG fourcc_code('I', 'M', 'G', '4') |
| +#endif |
| + |
| +/* |
| + * Value chosen in the middle of 255 pool to minimise the chance of hitting |
| + * the same value potentially defined by other vendors in the drm_fourcc.h |
| + */ |
| +#define DRM_FORMAT_MOD_VENDOR_PVR 0x92 |
| + |
| +#ifndef DRM_FORMAT_MOD_VENDOR_NONE |
| +#define DRM_FORMAT_MOD_VENDOR_NONE 0 |
| +#endif |
| + |
| +#ifndef DRM_FORMAT_RESERVED |
| +#define DRM_FORMAT_RESERVED ((1ULL << 56) - 1) |
| +#endif |
| + |
| +#ifndef fourcc_mod_code |
| +#define fourcc_mod_code(vendor, val) \ |
| + ((((__u64)DRM_FORMAT_MOD_VENDOR_## vendor) << 56) | (val & 0x00ffffffffffffffULL)) |
| +#endif |
| + |
| +#ifndef DRM_FORMAT_MOD_INVALID |
| +#define DRM_FORMAT_MOD_INVALID fourcc_mod_code(NONE, DRM_FORMAT_RESERVED) |
| +#endif |
| + |
| +#ifndef DRM_FORMAT_MOD_LINEAR |
| +#define DRM_FORMAT_MOD_LINEAR fourcc_mod_code(NONE, 0) |
| +#endif |
| + |
| +#define DRM_FORMAT_MOD_PVR_FBCDC_8x8_V7 fourcc_mod_code(PVR, 6) |
| +#define DRM_FORMAT_MOD_PVR_FBCDC_16x4_V7 fourcc_mod_code(PVR, 12) |
| + |
| +#endif /* IMG_DRM_FOURCC_H */ |
| diff --git a/src/mesa/drivers/dri/pvr/imgpixfmts.h b/src/mesa/drivers/dri/pvr/imgpixfmts.h |
| new file mode 100644 |
| index 00000000000..da12a0fb5f6 |
| --- /dev/null |
| +++ b/src/mesa/drivers/dri/pvr/imgpixfmts.h |
| @@ -0,0 +1,307 @@ |
| +/*************************************************************************/ /*! |
| +@File imgpixfmts.h |
| +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved |
| +@License MIT |
| + |
| +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. |
| +*/ /**************************************************************************/ |
| + |
| +/****************************************************************************** |
| + ** |
| + ** WARNING: File is autogenerated by parsesystable.py - DO NOT EDIT. |
| + ** Use fmts_systable.txt to add new formats. |
| + ** |
| + *****************************************************************************/ |
| + |
| +#if !defined(IMGPIXFMTS_H) |
| +#define IMGPIXFMTS_H |
| + |
| +typedef enum _IMG_PIXFMT_ |
| +{ |
| + IMG_PIXFMT_UNKNOWN = 0, |
| + IMG_PIXFMT_RESERVED_1 = 1, |
| + IMG_PIXFMT_RESERVED_2 = 2, |
| + IMG_PIXFMT_RESERVED_3 = 3, |
| + IMG_PIXFMT_RESERVED_4 = 4, |
| + IMG_PIXFMT_RESERVED_5 = 5, |
| + IMG_PIXFMT_RESERVED_6 = 6, |
| + IMG_PIXFMT_RESERVED_7 = 7, |
| + IMG_PIXFMT_RESERVED_8 = 8, |
| + IMG_PIXFMT_RESERVED_9 = 9, |
| + IMG_PIXFMT_RESERVED_10 = 10, |
| + IMG_PIXFMT_RESERVED_11 = 11, |
| + IMG_PIXFMT_RESERVED_12 = 12, |
| + IMG_PIXFMT_RESERVED_13 = 13, |
| + IMG_PIXFMT_RESERVED_14 = 14, |
| + IMG_PIXFMT_RESERVED_15 = 15, |
| + IMG_PIXFMT_RESERVED_16 = 16, |
| + IMG_PIXFMT_RESERVED_17 = 17, |
| + IMG_PIXFMT_RESERVED_18 = 18, |
| + IMG_PIXFMT_RESERVED_19 = 19, |
| + IMG_PIXFMT_RESERVED_20 = 20, |
| + IMG_PIXFMT_RESERVED_21 = 21, |
| + IMG_PIXFMT_RESERVED_22 = 22, |
| + IMG_PIXFMT_RESERVED_23 = 23, |
| + IMG_PIXFMT_RESERVED_24 = 24, |
| + IMG_PIXFMT_R10G10B10A2_UNORM = 25, |
| + IMG_PIXFMT_RESERVED_26 = 26, |
| + IMG_PIXFMT_RESERVED_27 = 27, |
| + IMG_PIXFMT_B10G10R10A2_UNORM = 28, |
| + IMG_PIXFMT_RESERVED_29 = 29, |
| + IMG_PIXFMT_RESERVED_30 = 30, |
| + IMG_PIXFMT_RESERVED_31 = 31, |
| + IMG_PIXFMT_R8G8B8A8_UNORM = 32, |
| + IMG_PIXFMT_R8G8B8A8_UNORM_SRGB = 33, |
| + IMG_PIXFMT_RESERVED_34 = 34, |
| + IMG_PIXFMT_RESERVED_35 = 35, |
| + IMG_PIXFMT_RESERVED_36 = 36, |
| + IMG_PIXFMT_R8G8B8X8_UNORM = 37, |
| + IMG_PIXFMT_RESERVED_38 = 38, |
| + IMG_PIXFMT_RESERVED_39 = 39, |
| + IMG_PIXFMT_RESERVED_40 = 40, |
| + IMG_PIXFMT_RESERVED_41 = 41, |
| + IMG_PIXFMT_RESERVED_42 = 42, |
| + IMG_PIXFMT_RESERVED_43 = 43, |
| + IMG_PIXFMT_RESERVED_44 = 44, |
| + IMG_PIXFMT_RESERVED_45 = 45, |
| + IMG_PIXFMT_RESERVED_46 = 46, |
| + IMG_PIXFMT_RESERVED_47 = 47, |
| + IMG_PIXFMT_RESERVED_48 = 48, |
| + IMG_PIXFMT_RESERVED_49 = 49, |
| + IMG_PIXFMT_RESERVED_50 = 50, |
| + IMG_PIXFMT_D32_FLOAT = 51, |
| + IMG_PIXFMT_RESERVED_52 = 52, |
| + IMG_PIXFMT_RESERVED_53 = 53, |
| + IMG_PIXFMT_RESERVED_54 = 54, |
| + IMG_PIXFMT_RESERVED_55 = 55, |
| + IMG_PIXFMT_RESERVED_56 = 56, |
| + IMG_PIXFMT_RESERVED_57 = 57, |
| + IMG_PIXFMT_D24_UNORM_X8_TYPELESS = 58, |
| + IMG_PIXFMT_RESERVED_59 = 59, |
| + IMG_PIXFMT_RESERVED_60 = 60, |
| + IMG_PIXFMT_RESERVED_61 = 61, |
| + IMG_PIXFMT_R8G8_UNORM = 62, |
| + IMG_PIXFMT_RESERVED_63 = 63, |
| + IMG_PIXFMT_RESERVED_64 = 64, |
| + IMG_PIXFMT_RESERVED_65 = 65, |
| + IMG_PIXFMT_RESERVED_66 = 66, |
| + IMG_PIXFMT_RESERVED_67 = 67, |
| + IMG_PIXFMT_RESERVED_68 = 68, |
| + IMG_PIXFMT_D16_UNORM = 69, |
| + IMG_PIXFMT_RESERVED_70 = 70, |
| + IMG_PIXFMT_RESERVED_71 = 71, |
| + IMG_PIXFMT_RESERVED_72 = 72, |
| + IMG_PIXFMT_RESERVED_73 = 73, |
| + IMG_PIXFMT_RESERVED_74 = 74, |
| + IMG_PIXFMT_RESERVED_75 = 75, |
| + IMG_PIXFMT_R8_UNORM = 76, |
| + IMG_PIXFMT_RESERVED_77 = 77, |
| + IMG_PIXFMT_RESERVED_78 = 78, |
| + IMG_PIXFMT_RESERVED_79 = 79, |
| + IMG_PIXFMT_RESERVED_80 = 80, |
| + IMG_PIXFMT_S8_UINT = 81, |
| + IMG_PIXFMT_RESERVED_82 = 82, |
| + IMG_PIXFMT_RESERVED_83 = 83, |
| + IMG_PIXFMT_RESERVED_84 = 84, |
| + IMG_PIXFMT_B5G6R5_UNORM = 85, |
| + IMG_PIXFMT_R5G6B5_UNORM = 86, |
| + IMG_PIXFMT_B5G5R5A1_UNORM = 87, |
| + IMG_PIXFMT_B5G5R5X1_UNORM = 88, |
| + IMG_PIXFMT_B8G8R8A8_UNORM = 89, |
| + IMG_PIXFMT_B8G8R8X8_UNORM = 90, |
| + IMG_PIXFMT_B8G8R8A8_UINT = 91, |
| + IMG_PIXFMT_B8G8R8A8_SNORM = 92, |
| + IMG_PIXFMT_B8G8R8A8_SINT = 93, |
| + IMG_PIXFMT_B8G8R8A8_UNORM_SRGB = 94, |
| + IMG_PIXFMT_RESERVED_95 = 95, |
| + IMG_PIXFMT_RESERVED_96 = 96, |
| + IMG_PIXFMT_RESERVED_97 = 97, |
| + IMG_PIXFMT_RESERVED_98 = 98, |
| + IMG_PIXFMT_RESERVED_99 = 99, |
| + IMG_PIXFMT_RESERVED_100 = 100, |
| + IMG_PIXFMT_RESERVED_101 = 101, |
| + IMG_PIXFMT_RESERVED_102 = 102, |
| + IMG_PIXFMT_RESERVED_103 = 103, |
| + IMG_PIXFMT_RESERVED_104 = 104, |
| + IMG_PIXFMT_RESERVED_105 = 105, |
| + IMG_PIXFMT_RESERVED_106 = 106, |
| + IMG_PIXFMT_RESERVED_107 = 107, |
| + IMG_PIXFMT_RESERVED_108 = 108, |
| + IMG_PIXFMT_RESERVED_109 = 109, |
| + IMG_PIXFMT_RESERVED_110 = 110, |
| + IMG_PIXFMT_RESERVED_111 = 111, |
| + IMG_PIXFMT_RESERVED_112 = 112, |
| + IMG_PIXFMT_RESERVED_113 = 113, |
| + IMG_PIXFMT_RESERVED_114 = 114, |
| + IMG_PIXFMT_RESERVED_115 = 115, |
| + IMG_PIXFMT_RESERVED_116 = 116, |
| + IMG_PIXFMT_RESERVED_117 = 117, |
| + IMG_PIXFMT_RESERVED_118 = 118, |
| + IMG_PIXFMT_RESERVED_119 = 119, |
| + IMG_PIXFMT_RESERVED_120 = 120, |
| + IMG_PIXFMT_RESERVED_121 = 121, |
| + IMG_PIXFMT_RESERVED_122 = 122, |
| + IMG_PIXFMT_RESERVED_123 = 123, |
| + IMG_PIXFMT_RESERVED_124 = 124, |
| + IMG_PIXFMT_RESERVED_125 = 125, |
| + IMG_PIXFMT_RESERVED_126 = 126, |
| + IMG_PIXFMT_RESERVED_127 = 127, |
| + IMG_PIXFMT_RESERVED_128 = 128, |
| + IMG_PIXFMT_RESERVED_129 = 129, |
| + IMG_PIXFMT_RESERVED_130 = 130, |
| + IMG_PIXFMT_RESERVED_131 = 131, |
| + IMG_PIXFMT_RESERVED_132 = 132, |
| + IMG_PIXFMT_RESERVED_133 = 133, |
| + IMG_PIXFMT_RESERVED_134 = 134, |
| + IMG_PIXFMT_RESERVED_135 = 135, |
| + IMG_PIXFMT_L8_UNORM = 136, |
| + IMG_PIXFMT_RESERVED_137 = 137, |
| + IMG_PIXFMT_L8A8_UNORM = 138, |
| + IMG_PIXFMT_RESERVED_139 = 139, |
| + IMG_PIXFMT_RESERVED_140 = 140, |
| + IMG_PIXFMT_RESERVED_141 = 141, |
| + IMG_PIXFMT_RESERVED_142 = 142, |
| + IMG_PIXFMT_RESERVED_143 = 143, |
| + IMG_PIXFMT_RESERVED_144 = 144, |
| + IMG_PIXFMT_B4G4R4A4_UNORM = 145, |
| + IMG_PIXFMT_RESERVED_146 = 146, |
| + IMG_PIXFMT_RESERVED_147 = 147, |
| + IMG_PIXFMT_RESERVED_148 = 148, |
| + IMG_PIXFMT_RESERVED_149 = 149, |
| + IMG_PIXFMT_RESERVED_150 = 150, |
| + IMG_PIXFMT_RESERVED_151 = 151, |
| + IMG_PIXFMT_RESERVED_152 = 152, |
| + IMG_PIXFMT_RESERVED_153 = 153, |
| + IMG_PIXFMT_RESERVED_154 = 154, |
| + IMG_PIXFMT_RESERVED_155 = 155, |
| + IMG_PIXFMT_RESERVED_156 = 156, |
| + IMG_PIXFMT_RESERVED_157 = 157, |
| + IMG_PIXFMT_RESERVED_158 = 158, |
| + IMG_PIXFMT_RESERVED_159 = 159, |
| + IMG_PIXFMT_R8G8B8_UNORM = 160, |
| + IMG_PIXFMT_R8G8B8_UNORM_SRGB = 161, |
| + IMG_PIXFMT_RESERVED_162 = 162, |
| + IMG_PIXFMT_RESERVED_163 = 163, |
| + IMG_PIXFMT_RESERVED_164 = 164, |
| + IMG_PIXFMT_RESERVED_165 = 165, |
| + IMG_PIXFMT_RESERVED_166 = 166, |
| + IMG_PIXFMT_RESERVED_167 = 167, |
| + IMG_PIXFMT_RESERVED_168 = 168, |
| + IMG_PIXFMT_RESERVED_169 = 169, |
| + IMG_PIXFMT_RESERVED_170 = 170, |
| + IMG_PIXFMT_UYVY = 171, |
| + IMG_PIXFMT_VYUY = 172, |
| + IMG_PIXFMT_YUYV = 173, |
| + IMG_PIXFMT_YVYU = 174, |
| + IMG_PIXFMT_YVU420_2PLANE = 175, |
| + IMG_PIXFMT_YUV420_2PLANE = 176, |
| + IMG_PIXFMT_YVU420_2PLANE_MACRO_BLOCK = 177, |
| + IMG_PIXFMT_YUV420_3PLANE = 178, |
| + IMG_PIXFMT_YVU420_3PLANE = 179, |
| + IMG_PIXFMT_RESERVED_180 = 180, |
| + IMG_PIXFMT_RESERVED_181 = 181, |
| + IMG_PIXFMT_RESERVED_182 = 182, |
| + IMG_PIXFMT_RESERVED_183 = 183, |
| + IMG_PIXFMT_RESERVED_184 = 184, |
| + IMG_PIXFMT_RESERVED_185 = 185, |
| + IMG_PIXFMT_RESERVED_186 = 186, |
| + IMG_PIXFMT_RESERVED_187 = 187, |
| + IMG_PIXFMT_RESERVED_188 = 188, |
| + IMG_PIXFMT_RESERVED_189 = 189, |
| + IMG_PIXFMT_RESERVED_190 = 190, |
| + IMG_PIXFMT_RESERVED_191 = 191, |
| + IMG_PIXFMT_RESERVED_192 = 192, |
| + IMG_PIXFMT_RESERVED_193 = 193, |
| + IMG_PIXFMT_RESERVED_194 = 194, |
| + IMG_PIXFMT_RESERVED_195 = 195, |
| + IMG_PIXFMT_RESERVED_196 = 196, |
| + IMG_PIXFMT_RESERVED_197 = 197, |
| + IMG_PIXFMT_RESERVED_198 = 198, |
| + IMG_PIXFMT_RESERVED_199 = 199, |
| + IMG_PIXFMT_RESERVED_200 = 200, |
| + IMG_PIXFMT_YVU8_422_2PLANE_PACK8 = 201, |
| + IMG_PIXFMT_RESERVED_202 = 202, |
| + IMG_PIXFMT_YVU10_444_1PLANE_PACK10 = 203, |
| + IMG_PIXFMT_RESERVED_204 = 204, |
| + IMG_PIXFMT_RESERVED_205 = 205, |
| + IMG_PIXFMT_RESERVED_206 = 206, |
| + IMG_PIXFMT_YUV8_422_2PLANE_PACK8 = 207, |
| + IMG_PIXFMT_YUV8_444_3PLANE_PACK8 = 208, |
| + IMG_PIXFMT_RESERVED_209 = 209, |
| + IMG_PIXFMT_RESERVED_210 = 210, |
| + IMG_PIXFMT_RESERVED_211 = 211, |
| + IMG_PIXFMT_RESERVED_212 = 212, |
| + IMG_PIXFMT_RESERVED_213 = 213, |
| + IMG_PIXFMT_RESERVED_214 = 214, |
| + IMG_PIXFMT_RESERVED_215 = 215, |
| + IMG_PIXFMT_RESERVED_216 = 216, |
| + IMG_PIXFMT_RESERVED_217 = 217, |
| + IMG_PIXFMT_RESERVED_218 = 218, |
| + IMG_PIXFMT_RESERVED_219 = 219, |
| + IMG_PIXFMT_RESERVED_220 = 220, |
| + IMG_PIXFMT_RESERVED_221 = 221, |
| + IMG_PIXFMT_RESERVED_222 = 222, |
| + IMG_PIXFMT_RESERVED_223 = 223, |
| + IMG_PIXFMT_RESERVED_224 = 224, |
| + IMG_PIXFMT_RESERVED_225 = 225, |
| + IMG_PIXFMT_RESERVED_226 = 226, |
| + IMG_PIXFMT_RESERVED_227 = 227, |
| + IMG_PIXFMT_RESERVED_228 = 228, |
| + IMG_PIXFMT_RESERVED_229 = 229, |
| + IMG_PIXFMT_RESERVED_230 = 230, |
| + IMG_PIXFMT_RESERVED_231 = 231, |
| + IMG_PIXFMT_RESERVED_232 = 232, |
| + IMG_PIXFMT_RESERVED_233 = 233, |
| + IMG_PIXFMT_RESERVED_234 = 234, |
| + IMG_PIXFMT_RESERVED_235 = 235, |
| + IMG_PIXFMT_RESERVED_236 = 236, |
| + IMG_PIXFMT_RESERVED_237 = 237, |
| + IMG_PIXFMT_RESERVED_238 = 238, |
| + IMG_PIXFMT_RESERVED_239 = 239, |
| + IMG_PIXFMT_RESERVED_240 = 240, |
| + IMG_PIXFMT_RESERVED_241 = 241, |
| + IMG_PIXFMT_RESERVED_242 = 242, |
| + IMG_PIXFMT_RESERVED_243 = 243, |
| + IMG_PIXFMT_RESERVED_244 = 244, |
| + IMG_PIXFMT_YVU8_420_2PLANE_PACK8_P = 245, |
| + IMG_PIXFMT_RESERVED_246 = 246, |
| + IMG_PIXFMT_RESERVED_247 = 247, |
| + IMG_PIXFMT_RESERVED_248 = 248, |
| + IMG_PIXFMT_YUV8_420_2PLANE_PACK8_P = 249, |
| + IMG_PIXFMT_RESERVED_250 = 250, |
| + IMG_PIXFMT_RESERVED_251 = 251, |
| + IMG_PIXFMT_UYVY10_422_1PLANE_PACK10_CUST1 = 252, |
| + IMG_PIXFMT_RESERVED_253 = 253, |
| + IMG_PIXFMT_RESERVED_254 = 254, |
| + IMG_PIXFMT_RESERVED_255 = 255, |
| + IMG_PIXFMT_RESERVED_256 = 256, |
| + IMG_PIXFMT_RESERVED_257 = 257, |
| + IMG_PIXFMT_RESERVED_258 = 258, |
| + IMG_PIXFMT_RESERVED_259 = 259, |
| + IMG_PIXFMT_RESERVED_260 = 260, |
| + IMG_PIXFMT_RESERVED_261 = 261, |
| + IMG_PIXFMT_RESERVED_262 = 262, |
| + IMG_PIXFMT_RESERVED_263 = 263, |
| + IMG_PIXFMT_RESERVED_264 = 264, |
| +#define IMG_PIXFMT_ENUM_COUNT 265 |
| +} IMG_PIXFMT; |
| + |
| +#endif /* IMGPIXFMTS_H */ |
| diff --git a/src/mesa/drivers/dri/pvr/imgyuv.h b/src/mesa/drivers/dri/pvr/imgyuv.h |
| new file mode 100644 |
| index 00000000000..7ae8fd19ac0 |
| --- /dev/null |
| +++ b/src/mesa/drivers/dri/pvr/imgyuv.h |
| @@ -0,0 +1,58 @@ |
| +/*************************************************************************/ /*! |
| +@File |
| +@Title YUV defines |
| +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved |
| +@License MIT |
| + |
| +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. |
| +*/ /**************************************************************************/ |
| + |
| +#if !defined(IMGYUV_H) |
| +#define IMGYUV_H |
| + |
| +typedef enum |
| +{ |
| + IMG_COLORSPACE_UNDEFINED = 0, |
| + IMG_COLORSPACE_BT601_CONFORMANT_RANGE = 1, |
| + IMG_COLORSPACE_BT601_FULL_RANGE = 2, |
| + IMG_COLORSPACE_BT709_CONFORMANT_RANGE = 3, |
| + IMG_COLORSPACE_BT709_FULL_RANGE = 4, |
| + IMG_COLORSPACE_BT2020_CONFORMANT_RANGE = 5, |
| + IMG_COLORSPACE_BT2020_FULL_RANGE = 6, |
| + IMG_COLORSPACE_BT601_CONFORMANT_RANGE_INVERSE = 7, |
| + IMG_COLORSPACE_BT601_FULL_RANGE_INVERSE = 8, |
| + IMG_COLORSPACE_BT709_CONFORMANT_RANGE_INVERSE = 9, |
| + IMG_COLORSPACE_BT709_FULL_RANGE_INVERSE = 10, |
| + IMG_COLORSPACE_BT2020_CONFORMANT_RANGE_INVERSE = 11, |
| + IMG_COLORSPACE_BT2020_FULL_RANGE_INVERSE = 12 |
| +} IMG_YUV_COLORSPACE; |
| + |
| +typedef enum |
| +{ |
| + IMG_CHROMA_INTERP_UNDEFINED = 0, |
| + IMG_CHROMA_INTERP_ZERO = 1, |
| + IMG_CHROMA_INTERP_QUARTER = 2, |
| + IMG_CHROMA_INTERP_HALF = 3, |
| + IMG_CHROMA_INTERP_THREEQUARTERS = 4 |
| +} IMG_YUV_CHROMA_INTERP; |
| + |
| + |
| +#endif /* IMGYUV_H */ |
| diff --git a/src/mesa/drivers/dri/pvr/mesa_context.c b/src/mesa/drivers/dri/pvr/mesa_context.c |
| new file mode 100644 |
| index 00000000000..594f792d212 |
| --- /dev/null |
| +++ b/src/mesa/drivers/dri/pvr/mesa_context.c |
| @@ -0,0 +1,203 @@ |
| +/** |
| + * \file context.c |
| + * Mesa context/visual/framebuffer management functions. |
| + * \author Brian Paul |
| + */ |
| + |
| +/* |
| + * Mesa 3-D graphics library |
| + * Version: 7.1 |
| + * |
| + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. |
| + * |
| + * 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. |
| + */ |
| + |
| +#include <stdlib.h> |
| +#include <assert.h> |
| + |
| +#include "main/version.h" |
| +#include "main/errors.h" |
| + |
| +#include "imports.h" |
| +#include "dri_support.h" |
| +#include "dri_util.h" |
| +#include "glapi.h" |
| +#include "dispatch.h" |
| +#include "pvrmesa.h" |
| + |
| +/** |
| + * This is the default function we plug into all dispatch table slots This |
| + * helps prevents a segfault when someone calls a GL function without first |
| + * checking if the extension is supported. |
| + */ |
| +static int |
| +generic_nop(void) |
| +{ |
| + _mesa_warning(NULL, "User called no-op dispatch function (an unsupported extension function?)"); |
| + |
| + return 0; |
| +} |
| + |
| +/** |
| + * Allocate and initialise a new dispatch table. |
| + */ |
| +static struct _glapi_table * |
| +pvrdri_alloc_dispatch_table(void) |
| +{ |
| + unsigned int numEntries = _glapi_get_dispatch_table_size(); |
| + _glapi_proc *table; |
| + |
| + table = malloc(numEntries * sizeof(_glapi_proc)); |
| + if (table) |
| + for (unsigned int i = 0; i < numEntries; i++) |
| + table[i] = (_glapi_proc) generic_nop; |
| + |
| + return (struct _glapi_table *) table; |
| +} |
| + |
| +/** |
| + * Return a pointer to the pointer to the dispatch table of an API in |
| + * PVRDRIScreen. |
| + */ |
| +static struct _glapi_table ** |
| +pvrdri_get_dispatch_table_ptr(PVRDRIScreen *psPVRScreen, PVRDRIAPIType eAPI) |
| +{ |
| + switch (eAPI) { |
| + case PVRDRI_API_GLES1: |
| + return &psPVRScreen->psOGLES1Dispatch; |
| + break; |
| + case PVRDRI_API_GLES2: |
| + return &psPVRScreen->psOGLES2Dispatch; |
| + break; |
| + default: |
| + return NULL; |
| + } |
| +} |
| + |
| +/** |
| + * Return a pointer to the dispatch table of an API. |
| + */ |
| +static struct _glapi_table * |
| +pvrdri_get_dispatch_table(PVRDRIScreen *psPVRScreen, PVRDRIAPIType eAPI) |
| +{ |
| + struct _glapi_table **ppsTable = |
| + pvrdri_get_dispatch_table_ptr(psPVRScreen, eAPI); |
| + |
| + return ppsTable ? *ppsTable : NULL; |
| +} |
| + |
| +/** |
| + * Free all dispatch tables. |
| + */ |
| +void |
| +pvrdri_free_dispatch_tables(PVRDRIScreen *psPVRScreen) |
| +{ |
| + if (psPVRScreen->psOGLES1Dispatch != NULL) { |
| + free(psPVRScreen->psOGLES1Dispatch); |
| + psPVRScreen->psOGLES1Dispatch = NULL; |
| + } |
| + |
| + if (psPVRScreen->psOGLES2Dispatch != NULL) { |
| + free(psPVRScreen->psOGLES2Dispatch); |
| + psPVRScreen->psOGLES2Dispatch = NULL; |
| + } |
| +} |
| + |
| +static void |
| +pvrdri_add_mesa_dispatch(struct _glapi_table *psTable, PVRDRIAPIType eAPI, |
| + struct DRISUPScreen *psDRISUPScreen, |
| + unsigned int uIdx) |
| +{ |
| + const char *asFunc[] = { NULL, NULL }; |
| + int iOffset; |
| + const char *psFunc; |
| + _glapi_proc pfFunc; |
| + |
| + pfFunc = DRISUPGetAPIProcAddress(psDRISUPScreen, eAPI, uIdx); |
| + if (pfFunc == NULL) |
| + return; |
| + |
| + psFunc = DRISUPGetAPIProcName(psDRISUPScreen, eAPI, uIdx); |
| + assert(psFunc != NULL); |
| + |
| + asFunc[0] = psFunc; |
| + iOffset = _glapi_add_dispatch(asFunc, ""); |
| + if (iOffset == -1) { |
| + _mesa_warning(NULL, "Couldn't add %s to the Mesa dispatch table", |
| + psFunc); |
| + } else { |
| + SET_by_offset(psTable, iOffset, pfFunc); |
| + } |
| +} |
| + |
| +static void |
| +pvrdri_set_mesa_dispatch(struct _glapi_table *psTable, PVRDRIAPIType eAPI, |
| + struct DRISUPScreen *psDRISUPScreen, |
| + unsigned int uNumFuncs) |
| +{ |
| + for (unsigned int i = 0; i < uNumFuncs; i++) |
| + pvrdri_add_mesa_dispatch(psTable, eAPI, psDRISUPScreen, i); |
| +} |
| + |
| +bool |
| +pvrdri_create_dispatch_table(PVRDRIScreen *psPVRScreen, PVRDRIAPIType eAPI) |
| +{ |
| + struct DRISUPScreen *psDRISUPScreen = psPVRScreen->psDRISUPScreen; |
| + struct _glapi_table **ppsTable; |
| + unsigned int uNumFuncs; |
| + |
| + ppsTable = pvrdri_get_dispatch_table_ptr(psPVRScreen, eAPI); |
| + if (ppsTable == NULL) |
| + return false; |
| + |
| + if (*ppsTable != NULL) |
| + return true; |
| + |
| + uNumFuncs = DRISUPGetNumAPIProcs(psDRISUPScreen, eAPI); |
| + if (!uNumFuncs) |
| + return false; |
| + |
| + *ppsTable = pvrdri_alloc_dispatch_table(); |
| + if (*ppsTable == NULL) |
| + return false; |
| + |
| + pvrdri_set_mesa_dispatch(*ppsTable, eAPI, psDRISUPScreen, uNumFuncs); |
| + |
| + return true; |
| +} |
| + |
| +void |
| +pvrdri_set_null_dispatch_table(void) |
| +{ |
| + _glapi_set_dispatch(NULL); |
| +} |
| + |
| +void |
| +pvrdri_set_dispatch_table(PVRDRIContext *psPVRContext) |
| +{ |
| + struct _glapi_table *psTable; |
| + |
| + psTable = pvrdri_get_dispatch_table(psPVRContext->psPVRScreen, |
| + psPVRContext->eAPI); |
| + |
| + _glapi_set_dispatch(psTable); |
| +} |
| diff --git a/src/mesa/drivers/dri/pvr/meson.build b/src/mesa/drivers/dri/pvr/meson.build |
| new file mode 100644 |
| index 00000000000..5a3e87ea070 |
| --- /dev/null |
| +++ b/src/mesa/drivers/dri/pvr/meson.build |
| @@ -0,0 +1,48 @@ |
| +# 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. |
| + |
| +files_pvr = files( |
| + 'mesa_context.c', |
| + 'pvrcb.c', |
| + 'pvrcompat.c', |
| + 'pvrdrawable_mod.c', |
| + 'pvrdri.c', |
| + 'pvrdri_mod.c', |
| + 'pvrext.c', |
| + 'pvrext_mod.c', |
| + 'pvrimage_mod.c', |
| + 'pvrutil.c', |
| + 'pvrutil_mod.c', |
| +) |
| + |
| +dep_libpvr = [ |
| + dep_libdrm, |
| +] |
| + |
| +libpvr = static_library( |
| + 'pvr', |
| + [files_pvr, main_dispatch_h], |
| + include_directories : [inc_common, inc_dri_common, inc_util, inc_pvr], |
| + c_args : [c_vis_args, no_override_init_args], |
| + cpp_args : [cpp_vis_args], |
| + dependencies : [dep_libpvr], |
| +) |
| diff --git a/src/mesa/drivers/dri/pvr/pvrcb.c b/src/mesa/drivers/dri/pvr/pvrcb.c |
| new file mode 100644 |
| index 00000000000..7dfc3139cbb |
| --- /dev/null |
| +++ b/src/mesa/drivers/dri/pvr/pvrcb.c |
| @@ -0,0 +1,269 @@ |
| +/* |
| + * 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. |
| + */ |
| + |
| +#include <assert.h> |
| + |
| +#include "utils.h" |
| +#include "pvrdri.h" |
| + |
| +int |
| +MODSUPGetBuffers(__DRIdrawable *psDRIDrawable, unsigned int uFourCC, |
| + uint32_t *puStamp, void *pvLoaderPrivate, |
| + uint32_t uBufferMask, struct PVRDRIImageList *psImageList) |
| +{ |
| + PVRDRIDrawable *psPVRDrawable = psDRIDrawable->driverPrivate; |
| + __DRIscreen *psDRIScreen = psDRIDrawable->driScreenPriv; |
| + struct __DRIimageList sDRIList; |
| + int res; |
| + |
| +#if !defined(DRI_IMAGE_HAS_BUFFER_PREV) |
| + uBufferMask &= ~PVRDRI_IMAGE_BUFFER_PREV; |
| +#endif |
| + |
| + if (psPVRDrawable->uFourCC != uFourCC) { |
| + psPVRDrawable->uDRIFormat = PVRDRIFourCCToDRIFormat(uFourCC); |
| + psPVRDrawable->uFourCC = uFourCC; |
| + } |
| + |
| + res = psDRIScreen->image.loader->getBuffers(psDRIDrawable, |
| + psPVRDrawable->uDRIFormat, |
| + puStamp, |
| + pvLoaderPrivate, |
| + uBufferMask, &sDRIList); |
| + |
| + if (res) { |
| + psImageList->uImageMask = sDRIList.image_mask; |
| + psImageList->psBack = sDRIList.back; |
| + psImageList->psFront = sDRIList.front; |
| +#if defined(DRI_IMAGE_HAS_BUFFER_PREV) |
| + psImageList->psPrev = sDRIList.prev; |
| +#endif |
| + } |
| + |
| + return res; |
| +} |
| + |
| +bool |
| +MODSUPCreateConfigs(__DRIconfig ***pppsConfigs, __DRIscreen *psDRIScreen, |
| + int iPVRDRIMesaFormat, const uint8_t *puDepthBits, |
| + const uint8_t *puStencilBits, |
| + unsigned int uNumDepthStencilBits, |
| + const unsigned int *puDBModes, unsigned int uNumDBModes, |
| + const uint8_t *puMSAASamples, unsigned int uNumMSAAModes, |
| + bool bEnableAccum, bool bColorDepthMatch, |
| + bool bMutableRenderBuffer, |
| + int iYUVDepthRange, int iYUVCSCStandard, |
| + uint32_t uMaxPbufferWidth, uint32_t uMaxPbufferHeight) |
| +{ |
| + __DRIconfig **ppsConfigs; |
| + mesa_format eFormat = PVRDRIMesaFormatToMesaFormat(iPVRDRIMesaFormat); |
| + unsigned int i; |
| + |
| + (void) psDRIScreen; |
| + |
| + switch (eFormat) { |
| + case MESA_FORMAT_NONE: |
| + __driUtilMessage("%s: Unknown PVR DRI format: %u", |
| + __func__, iPVRDRIMesaFormat); |
| + return false; |
| + default: |
| + break; |
| + } |
| + |
| + /* |
| + * The double buffered modes array argument for driCreateConfigs has |
| + * entries of type GLenum. |
| + */ |
| + assert(sizeof(GLenum) == sizeof(unsigned int)); |
| + |
| + ppsConfigs = driCreateConfigs(eFormat, puDepthBits, puStencilBits, |
| + uNumDepthStencilBits, (GLenum *) puDBModes, |
| + uNumDBModes, puMSAASamples, uNumMSAAModes, |
| + bEnableAccum, bColorDepthMatch, |
| + bMutableRenderBuffer); |
| + if (!ppsConfigs) |
| + return false; |
| + |
| + for (i = 0; ppsConfigs[i]; i++) { |
| + ppsConfigs[i]->modes.maxPbufferWidth = uMaxPbufferWidth; |
| + ppsConfigs[i]->modes.maxPbufferHeight = uMaxPbufferHeight; |
| + ppsConfigs[i]->modes.maxPbufferPixels = |
| + uMaxPbufferWidth * uMaxPbufferHeight; |
| + } |
| + |
| + *pppsConfigs = ppsConfigs; |
| + |
| + return true; |
| +} |
| + |
| +__DRIconfig ** |
| +MODSUPConcatConfigs(__DRIscreen *psDRIScreen, |
| + __DRIconfig **ppsConfigA, __DRIconfig **ppsConfigB) |
| +{ |
| + (void) psDRIScreen; |
| + |
| + return driConcatConfigs(ppsConfigA, ppsConfigB); |
| +} |
| + |
| +struct __DRIimageRec * |
| +MODSUPLookupEGLImage(__DRIscreen *psDRIScreen, void *pvImage, |
| + void *pvLoaderPrivate) |
| +{ |
| + return psDRIScreen->dri2.image->lookupEGLImage(psDRIScreen, |
| + pvImage, |
| + pvLoaderPrivate); |
| +} |
| + |
| + |
| +unsigned int |
| +MODSUPGetCapability(__DRIscreen *psDRIScreen, unsigned int uCapability) |
| +{ |
| + if (psDRIScreen->image.loader->base.version >= 2 && |
| + psDRIScreen->image.loader->getCapability) { |
| + enum dri_loader_cap eCapability = |
| + (enum dri_loader_cap) uCapability; |
| + |
| + return psDRIScreen->image.loader->getCapability(psDRIScreen, |
| + eCapability); |
| + } |
| + |
| + return 0; |
| +} |
| + |
| +bool |
| +PVRDRIConfigQuery(const PVRDRIConfig *psConfig, |
| + PVRDRIConfigAttrib eConfigAttrib, int *piValueOut) |
| +{ |
| + if (!psConfig || !piValueOut) |
| + return false; |
| + |
| + switch (eConfigAttrib) { |
| + case PVRDRI_CONFIG_ATTRIB_RENDERABLE_TYPE: |
| + *piValueOut = psConfig->iSupportedAPIs; |
| + return true; |
| + case PVRDRI_CONFIG_ATTRIB_RGB_MODE: |
| + *piValueOut = psConfig->sGLMode.rgbMode; |
| + return true; |
| + case PVRDRI_CONFIG_ATTRIB_DOUBLE_BUFFER_MODE: |
| + *piValueOut = psConfig->sGLMode.doubleBufferMode; |
| + return true; |
| + case PVRDRI_CONFIG_ATTRIB_RED_BITS: |
| + *piValueOut = psConfig->sGLMode.redBits; |
| + return true; |
| + case PVRDRI_CONFIG_ATTRIB_GREEN_BITS: |
| + *piValueOut = psConfig->sGLMode.greenBits; |
| + return true; |
| + case PVRDRI_CONFIG_ATTRIB_BLUE_BITS: |
| + *piValueOut = psConfig->sGLMode.blueBits; |
| + return true; |
| + case PVRDRI_CONFIG_ATTRIB_ALPHA_BITS: |
| + *piValueOut = psConfig->sGLMode.alphaBits; |
| + return true; |
| + case PVRDRI_CONFIG_ATTRIB_RGB_BITS: |
| + *piValueOut = psConfig->sGLMode.rgbBits; |
| + return true; |
| + case PVRDRI_CONFIG_ATTRIB_DEPTH_BITS: |
| + *piValueOut = psConfig->sGLMode.depthBits; |
| + return true; |
| + case PVRDRI_CONFIG_ATTRIB_STENCIL_BITS: |
| + *piValueOut = psConfig->sGLMode.stencilBits; |
| + return true; |
| + case PVRDRI_CONFIG_ATTRIB_SAMPLE_BUFFERS: |
| + *piValueOut = psConfig->sGLMode.sampleBuffers; |
| + return true; |
| + case PVRDRI_CONFIG_ATTRIB_SAMPLES: |
| + *piValueOut = psConfig->sGLMode.samples; |
| + return true; |
| + case PVRDRI_CONFIG_ATTRIB_BIND_TO_TEXTURE_RGB: |
| + *piValueOut = psConfig->sGLMode.bindToTextureRgb; |
| + return true; |
| + case PVRDRI_CONFIG_ATTRIB_BIND_TO_TEXTURE_RGBA: |
| + *piValueOut = psConfig->sGLMode.bindToTextureRgba; |
| + return true; |
| +#if defined(__DRI_ATTRIB_YUV_BIT) |
| + case PVRDRI_CONFIG_ATTRIB_YUV_ORDER: |
| + *piValueOut = psConfig->sGLMode.YUVOrder; |
| + return true; |
| + case PVRDRI_CONFIG_ATTRIB_YUV_NUM_OF_PLANES: |
| + *piValueOut = psConfig->sGLMode.YUVNumberOfPlanes; |
| + return true; |
| + case PVRDRI_CONFIG_ATTRIB_YUV_SUBSAMPLE: |
| + *piValueOut = psConfig->sGLMode.YUVSubsample; |
| + return true; |
| + case PVRDRI_CONFIG_ATTRIB_YUV_DEPTH_RANGE: |
| + *piValueOut = psConfig->sGLMode.YUVDepthRange; |
| + return true; |
| + case PVRDRI_CONFIG_ATTRIB_YUV_CSC_STANDARD: |
| + *piValueOut = psConfig->sGLMode.YUVCSCStandard; |
| + return true; |
| + case PVRDRI_CONFIG_ATTRIB_YUV_PLANE_BPP: |
| + *piValueOut = psConfig->sGLMode.YUVPlaneBPP; |
| + return true; |
| +#endif |
| +#if !defined(__DRI_ATTRIB_YUV_BIT) |
| + case PVRDRI_CONFIG_ATTRIB_YUV_ORDER: |
| + case PVRDRI_CONFIG_ATTRIB_YUV_NUM_OF_PLANES: |
| + case PVRDRI_CONFIG_ATTRIB_YUV_SUBSAMPLE: |
| + case PVRDRI_CONFIG_ATTRIB_YUV_DEPTH_RANGE: |
| + case PVRDRI_CONFIG_ATTRIB_YUV_CSC_STANDARD: |
| + case PVRDRI_CONFIG_ATTRIB_YUV_PLANE_BPP: |
| + return false; |
| +#endif |
| + case PVRDRI_CONFIG_ATTRIB_RED_MASK: |
| + *piValueOut = psConfig->sGLMode.redMask; |
| + return true; |
| + case PVRDRI_CONFIG_ATTRIB_GREEN_MASK: |
| + *piValueOut = psConfig->sGLMode.greenMask; |
| + return true; |
| + case PVRDRI_CONFIG_ATTRIB_BLUE_MASK: |
| + *piValueOut = psConfig->sGLMode.blueMask; |
| + return true; |
| + case PVRDRI_CONFIG_ATTRIB_ALPHA_MASK: |
| + *piValueOut = psConfig->sGLMode.alphaMask; |
| + return true; |
| + case PVRDRI_CONFIG_ATTRIB_SRGB_CAPABLE: |
| + *piValueOut = psConfig->sGLMode.sRGBCapable; |
| + return true; |
| + case PVRDRI_CONFIG_ATTRIB_INVALID: |
| + errorMessage("%s: Invalid attribute", __func__); |
| + assert(0); |
| + return false; |
| + default: |
| + return false; |
| + } |
| +} |
| + |
| +bool |
| +MODSUPConfigQuery(const PVRDRIConfig *psConfig, |
| + PVRDRIConfigAttrib eConfigAttrib, unsigned int *puValueOut) |
| +{ |
| + bool bRes; |
| + int iValue; |
| + |
| + bRes = PVRDRIConfigQuery(psConfig, eConfigAttrib, &iValue); |
| + if (bRes) |
| + *puValueOut = (unsigned int) iValue; |
| + |
| + return bRes; |
| +} |
| diff --git a/src/mesa/drivers/dri/pvr/pvrcompat.c b/src/mesa/drivers/dri/pvr/pvrcompat.c |
| new file mode 100644 |
| index 00000000000..bd225ca0c46 |
| --- /dev/null |
| +++ b/src/mesa/drivers/dri/pvr/pvrcompat.c |
| @@ -0,0 +1,1529 @@ |
| +/* |
| + * 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. |
| + */ |
| + |
| +#include <stddef.h> |
| +#include <stdlib.h> |
| +#include <string.h> |
| +#include <dlfcn.h> |
| +#include <pthread.h> |
| +#include <assert.h> |
| + |
| +#include <drm_fourcc.h> |
| + |
| +#include "pvrdri.h" |
| +#include "pvrdri_mod.h" |
| + |
| +#ifndef DRM_FORMAT_MOD_INVALID |
| +#define DRM_FORMAT_MOD_INVALID ((1ULL << 56) - 1) |
| +#endif |
| + |
| +#define _MAKESTRING(x) # x |
| +#define MAKESTRING(x) _MAKESTRING(x) |
| + |
| +#define PVRDRI_SUPPORT_LIB "libpvr_dri_support.so" |
| + |
| +static void *gpvSupLib; |
| +static int giSupLibRef; |
| + |
| +static PVRDRISupportInterface gsSup; |
| +static struct PVRDRISupportInterfaceV2 gsSupV2; |
| + |
| +static pthread_mutex_t gsCompatLock = PTHREAD_MUTEX_INITIALIZER; |
| + |
| +/* Call a function via the DRI Support interface structure */ |
| +#define CallFunc(field, ...) \ |
| + do { \ |
| + if (gsSup.field) \ |
| + return gsSup.field(__VA_ARGS__); \ |
| + } while(0) |
| + |
| +/* Lookup a function, and set the pointer to the function address */ |
| +#define LookupFunc(func, ptr) \ |
| + do { \ |
| + ptr = dlsym(gpvSupLib, MAKESTRING(func)); \ |
| + } while(0) |
| + |
| +/* |
| + * Calculate the size of a particular version of the PVRDRISupportInterface |
| + * structure from the name of the last field in that version of the |
| + * structure. |
| + */ |
| +#define PVRDRIInterfaceSize(field) \ |
| + (offsetof(PVRDRISupportInterface, field) + \ |
| + sizeof((PVRDRISupportInterface *)0)->field) |
| + |
| +/* Call a function via the DRI Support interface structure */ |
| +#define CallFuncV2(field, ...) \ |
| + do { \ |
| + if (gsSupV2.field) \ |
| + return gsSupV2.field(__VA_ARGS__); \ |
| + } while(0) |
| + |
| +/* Calculate the start of the PVRDRISupportInterfaceV2 structure */ |
| +#define PVRDRIInterfaceV2Start(field) \ |
| + (offsetof(struct PVRDRISupportInterfaceV2, field)) |
| + |
| +/* Calculate the end of the PVRDRISupportInterfaceV2 structure */ |
| +#define PVRDRIInterfaceV2End(field) \ |
| + (offsetof(struct PVRDRISupportInterfaceV2, field) + \ |
| + sizeof((struct PVRDRISupportInterfaceV2 *)0)->field) |
| + |
| +static void |
| +CompatLock(void) |
| +{ |
| + int ret; |
| + |
| + ret = pthread_mutex_lock(&gsCompatLock); |
| + if (ret) { |
| + errorMessage("%s: Failed to lock mutex (%d)", __func__, ret); |
| + abort(); |
| + } |
| +} |
| + |
| +static void |
| +CompatUnlock(void) |
| +{ |
| + int ret; |
| + |
| + ret = pthread_mutex_unlock(&gsCompatLock); |
| + if (ret) { |
| + errorMessage("%s: Failed to unlock mutex (%d)", __func__, ret); |
| + abort(); |
| + } |
| +} |
| + |
| +static void * |
| +LoadLib(const char *path) |
| +{ |
| + void *handle; |
| + |
| + /* Clear the error */ |
| + (void) dlerror(); |
| + |
| + handle = dlopen(path, RTLD_NOW); |
| + if (handle) { |
| + __driUtilMessage("Loaded %s", path); |
| + } else { |
| + const char *error; |
| + |
| + error = dlerror(); |
| + if (!error) |
| + error = "unknown error"; |
| + |
| + errorMessage("%s: Couldn't load %s: %s", __func__, path, error); |
| + } |
| + |
| + return handle; |
| +} |
| + |
| +static void |
| +UnloadLib(void *handle, const char *name) |
| +{ |
| + if (!handle) |
| + return; |
| + |
| + /* Clear the error */ |
| + (void) dlerror(); |
| + |
| + if (dlclose(handle)) { |
| + const char *error; |
| + |
| + error = dlerror(); |
| + if (!error) |
| + error = "unknown error"; |
| + |
| + errorMessage("%s: Couldn't unload %s: %s", __func__, name, error); |
| + } else { |
| + __driUtilMessage("Unloaded %s", name); |
| + } |
| +} |
| + |
| +static bool |
| +LoadSupportLib(void) |
| +{ |
| + gpvSupLib = LoadLib(PVRDRI_SUPPORT_LIB); |
| + |
| + return gpvSupLib != NULL; |
| +} |
| + |
| +static void |
| +UnloadSupportLib(void) |
| +{ |
| + UnloadLib(gpvSupLib, PVRDRI_SUPPORT_LIB); |
| + gpvSupLib = NULL; |
| +} |
| + |
| +static void |
| +CompatDeinit(void) |
| +{ |
| + UnloadSupportLib(); |
| + memset(&gsSup, 0, sizeof(gsSup)); |
| + memset(&gsSupV2, 0, sizeof(gsSupV2)); |
| +} |
| + |
| +static void |
| +SetupLocalDRISupportInterfaceV2(void) |
| +{ |
| + gsSupV2.v0.CreateScreen = DRIMODCreateScreen; |
| + gsSupV2.v0.DestroyScreen = DRIMODDestroyScreen; |
| + gsSupV2.v0.CreateContext = DRIMODCreateContext; |
| + gsSupV2.v0.DestroyContext = DRIMODDestroyContext; |
| + gsSupV2.v0.CreateDrawable = DRIMODCreateDrawable; |
| + gsSupV2.v0.DestroyDrawable = DRIMODDestroyDrawable; |
| + gsSupV2.v0.MakeCurrent = DRIMODMakeCurrent; |
| + gsSupV2.v0.UnbindContext = DRIMODUnbindContext; |
| + gsSupV2.v0.AllocateBuffer = DRIMODAllocateBuffer; |
| + gsSupV2.v0.ReleaseBuffer = DRIMODReleaseBuffer; |
| + gsSupV2.v0.SetTexBuffer2 = DRIMODSetTexBuffer2; |
| + gsSupV2.v0.ReleaseTexBuffer = DRIMODReleaseTexBuffer; |
| + gsSupV2.v0.Flush = DRIMODFlush; |
| + gsSupV2.v0.Invalidate = DRIMODInvalidate; |
| + gsSupV2.v0.FlushWithFlags = DRIMODFlushWithFlags; |
| + gsSupV2.v0.CreateImageFromName = DRIMODCreateImageFromName; |
| + gsSupV2.v0.CreateImageFromRenderbuffer = |
| + DRIMODCreateImageFromRenderbuffer; |
| + gsSupV2.v0.DestroyImage = DRIMODDestroyImage; |
| + gsSupV2.v0.CreateImage = DRIMODCreateImage; |
| + gsSupV2.v0.QueryImage = DRIMODQueryImage; |
| + gsSupV2.v0.DupImage = DRIMODDupImage; |
| + gsSupV2.v0.ValidateImageUsage = DRIMODValidateImageUsage; |
| + gsSupV2.v0.CreateImageFromNames = DRIMODCreateImageFromNames; |
| + gsSupV2.v0.FromPlanar = DRIMODFromPlanar; |
| + gsSupV2.v0.CreateImageFromTexture = DRIMODCreateImageFromTexture; |
| + gsSupV2.v0.CreateImageFromFDs = DRIMODCreateImageFromFDs; |
| + gsSupV2.v0.CreateImageFromDMABufs = DRIMODCreateImageFromDMABufs; |
| + gsSupV2.v0.GetImageCapabilities = DRIMODGetImageCapabilities; |
| + gsSupV2.v0.BlitImage = DRIMODBlitImage; |
| + gsSupV2.v0.MapImage = DRIMODMapImage; |
| + gsSupV2.v0.UnmapImage = DRIMODUnmapImage; |
| + gsSupV2.v0.CreateImageWithModifiers = DRIMODCreateImageWithModifiers; |
| + gsSupV2.v0.CreateImageFromDMABufs2 = DRIMODCreateImageFromDMABufs2; |
| + gsSupV2.v0.QueryDMABufFormats = DRIMODQueryDMABufFormats; |
| + gsSupV2.v0.QueryDMABufModifiers = DRIMODQueryDMABufModifiers; |
| + gsSupV2.v0.QueryDMABufFormatModifierAttribs = |
| + DRIMODQueryDMABufFormatModifierAttribs; |
| + gsSupV2.v0.CreateImageFromRenderBuffer2 = |
| + DRIMODCreateImageFromRenderBuffer2; |
| + gsSupV2.v0.CreateImageFromBuffer = DRIMODCreateImageFromBuffer; |
| + gsSupV2.v0.QueryRendererInteger = DRIMODQueryRendererInteger; |
| + gsSupV2.v0.QueryRendererString = DRIMODQueryRendererString; |
| + gsSupV2.v0.CreateFence = DRIMODCreateFence; |
| + gsSupV2.v0.DestroyFence = DRIMODDestroyFence; |
| + gsSupV2.v0.ClientWaitSync = DRIMODClientWaitSync; |
| + gsSupV2.v0.ServerWaitSync = DRIMODServerWaitSync; |
| + gsSupV2.v0.GetFenceCapabilities = DRIMODGetFenceCapabilities; |
| + gsSupV2.v0.CreateFenceFD = DRIMODCreateFenceFD; |
| + gsSupV2.v0.GetFenceFD = DRIMODGetFenceFD; |
| + gsSupV2.v0.GetNumAPIProcs = DRIMODGetNumAPIProcs; |
| + gsSupV2.v0.GetAPIProcName = DRIMODGetAPIProcName; |
| + gsSupV2.v0.GetAPIProcAddress = DRIMODGetAPIProcAddress; |
| + gsSupV2.v0.SetDamageRegion = DRIMODSetDamageRegion; |
| + |
| + PVRDRIAdjustExtensions(0, 0); |
| +} |
| + |
| +bool |
| +PVRDRICompatInit(const PVRDRICallbacks *psCallbacks, unsigned int uVersion, |
| + const struct PVRDRICallbacksV2 *psCallbacksV2, |
| + unsigned int uVersionV2, unsigned int uMinVersionV2) |
| +{ |
| + bool (*pfRegisterVersionedCallbacks)(const PVRDRICallbacks *psCallbacks, |
| + unsigned int uVersion); |
| + bool (*pfRegisterVersionedCallbacksV2)(const void *pvCallbacks, |
| + unsigned int uVersion, |
| + unsigned int uMinVersion); |
| + bool res; |
| + |
| + CompatLock(); |
| + res = (giSupLibRef++ != 0); |
| + if (res) |
| + goto Exit; |
| + |
| + res = LoadSupportLib(); |
| + if (!res) |
| + goto Exit; |
| + |
| + LookupFunc(PVRDRIRegisterVersionedCallbacksV2, |
| + pfRegisterVersionedCallbacksV2); |
| + |
| + LookupFunc(PVRDRIRegisterVersionedCallbacks, |
| + pfRegisterVersionedCallbacks); |
| + |
| + res = (pfRegisterVersionedCallbacksV2 != NULL) || |
| + (pfRegisterVersionedCallbacks != NULL); |
| + if (!res) |
| + goto Exit; |
| + |
| + if (pfRegisterVersionedCallbacksV2) { |
| + res = pfRegisterVersionedCallbacksV2(psCallbacksV2, |
| + uVersionV2, uMinVersionV2); |
| + } else { |
| + res = pfRegisterVersionedCallbacks(psCallbacks, uVersion); |
| + if (res) |
| + SetupLocalDRISupportInterfaceV2(); |
| + } |
| + |
| +Exit: |
| + if (!res) { |
| + CompatDeinit(); |
| + giSupLibRef--; |
| + } |
| + CompatUnlock(); |
| + |
| + return res; |
| +} |
| + |
| +void |
| +PVRDRICompatDeinit(void) |
| +{ |
| + CompatLock(); |
| + if (--giSupLibRef == 0) |
| + CompatDeinit(); |
| + CompatUnlock(); |
| +} |
| + |
| +bool |
| +PVRDRIRegisterSupportInterfaceV1(const PVRDRISupportInterface *psInterface, |
| + unsigned int uVersion) |
| +{ |
| + size_t uSize; |
| + |
| + memset(&gsSup, 0, sizeof(gsSup)); |
| + memset(&gsSupV2, 0, sizeof(gsSupV2)); |
| + |
| + /* The "default" case should be associated with the latest version */ |
| + switch (uVersion) { |
| + default: |
| + case 2: |
| + uSize = PVRDRIInterfaceSize(GetFenceFd); |
| + break; |
| + case 1: |
| + case 0: |
| + return false; |
| + } |
| + |
| + memcpy(&gsSup, psInterface, uSize); |
| + |
| + return true; |
| +} |
| + |
| +bool |
| +MODSUPRegisterSupportInterfaceV2(const void *pvInterface, |
| + unsigned int uVersion, |
| + unsigned int uMinVersion) |
| +{ |
| + size_t uStart, uEnd; |
| + |
| + memset(&gsSup, 0, sizeof(gsSup)); |
| + memset(&gsSupV2, 0, sizeof(gsSupV2)); |
| + |
| + if (uVersion < uMinVersion) |
| + return false; |
| + |
| + /* |
| + * Minimum versions we support. To prevent the accumulation of old unused |
| + * interfaces in the PVRDRIInterfaceV2 structure, the caller specifies the |
| + * minimum version it supports. This will be pointed to be the psInterface |
| + * argument. Assuming we support that version, we must copy the structure |
| + * passed to us into the correct place in our version of the interface |
| + * structure. |
| + */ |
| + switch (uMinVersion) { |
| + case 0: |
| + uStart = PVRDRIInterfaceV2Start(v0); |
| + break; |
| + case 1: |
| + /* Version 1 requires version 0 */ |
| + return false; |
| + default: |
| + return false; |
| + } |
| + |
| + /* The "default" case should be associated with the latest version */ |
| + switch (uVersion) { |
| + default: |
| + case 1: |
| + /* Version 1 is an extension of version 0 */ |
| + if (uMinVersion > 0) |
| + return false; |
| + |
| + uEnd = PVRDRIInterfaceV2End(v1); |
| + break; |
| + case 0: |
| + uEnd = PVRDRIInterfaceV2End(v0); |
| + break; |
| + } |
| + |
| + memcpy(((char *) &gsSupV2) + uStart, pvInterface, uEnd - uStart); |
| + |
| + PVRDRIAdjustExtensions(uVersion, uMinVersion); |
| + |
| + return true; |
| +} |
| + |
| +struct DRISUPScreen * |
| +DRISUPCreateScreen(struct __DRIscreenRec *psDRIScreen, int iFD, |
| + bool bUseInvalidate, void *pvLoaderPrivate, |
| + const struct __DRIconfigRec ***pppsConfigs, |
| + int *piMaxGLES1Version, int *piMaxGLES2Version) |
| +{ |
| + CallFuncV2(v0.CreateScreen, |
| + psDRIScreen, iFD, bUseInvalidate, pvLoaderPrivate, pppsConfigs, |
| + piMaxGLES1Version, piMaxGLES2Version); |
| + |
| + return NULL; |
| +} |
| + |
| +void |
| +DRISUPDestroyScreen(struct DRISUPScreen *psDRISUPScreen) |
| +{ |
| + CallFuncV2(v0.DestroyScreen, |
| + psDRISUPScreen); |
| +} |
| + |
| +unsigned int |
| +DRISUPCreateContext(PVRDRIAPIType eAPI, PVRDRIConfig *psPVRDRIConfig, |
| + struct PVRDRIContextConfig *psCtxConfig, |
| + struct __DRIcontextRec *psDRIContext, |
| + struct DRISUPContext *psDRISUPSharedContext, |
| + struct DRISUPScreen *psDRISUPScreen, |
| + struct DRISUPContext **ppsDRISUPContext) |
| +{ |
| + CallFuncV2(v0.CreateContext, |
| + eAPI, psPVRDRIConfig, psCtxConfig, psDRIContext, |
| + psDRISUPSharedContext, psDRISUPScreen, ppsDRISUPContext); |
| + |
| + return PVRDRI_CONTEXT_ERROR_BAD_API; |
| +} |
| + |
| +void |
| +DRISUPDestroyContext(struct DRISUPContext *psDRISUPContext) |
| +{ |
| + CallFuncV2(v0.DestroyContext, |
| + psDRISUPContext); |
| +} |
| + |
| +struct DRISUPDrawable * |
| +DRISUPCreateDrawable(struct __DRIdrawableRec *psDRIDrawable, |
| + struct DRISUPScreen *psDRISUPScreen, |
| + void *pvLoaderPrivate, PVRDRIConfig *psPVRDRIConfig) |
| +{ |
| + CallFuncV2(v0.CreateDrawable, |
| + psDRIDrawable, psDRISUPScreen, pvLoaderPrivate, psPVRDRIConfig); |
| + |
| + return NULL; |
| +} |
| + |
| +void |
| +DRISUPDestroyDrawable(struct DRISUPDrawable *psDRISUPDrawable) |
| +{ |
| + CallFuncV2(v0.DestroyDrawable, |
| + psDRISUPDrawable); |
| +} |
| + |
| +bool |
| +DRISUPMakeCurrent(struct DRISUPContext *psDRISUPContext, |
| + struct DRISUPDrawable *psDRISUPWrite, |
| + struct DRISUPDrawable *psDRISUPRead) |
| +{ |
| + CallFuncV2(v0.MakeCurrent, |
| + psDRISUPContext, psDRISUPWrite, psDRISUPRead); |
| + |
| + return false; |
| +} |
| + |
| +bool |
| +DRISUPUnbindContext(struct DRISUPContext *psDRISUPContext) |
| +{ |
| + CallFuncV2(v0.UnbindContext, |
| + psDRISUPContext); |
| + |
| + return false; |
| +} |
| + |
| +struct DRISUPBuffer * |
| +DRISUPAllocateBuffer(struct DRISUPScreen *psDRISUPScreen, |
| + unsigned int uAttachment, unsigned int uFormat, |
| + int iWidth, int iHeight, unsigned int *puName, |
| + unsigned int *puPitch, unsigned int *puCPP, |
| + unsigned int *puFlags) |
| +{ |
| + CallFuncV2(v0.AllocateBuffer, |
| + psDRISUPScreen, uAttachment, uFormat, iWidth, iHeight, puName, |
| + puPitch, puCPP, puFlags); |
| + |
| + return NULL; |
| +} |
| + |
| +void |
| +DRISUPReleaseBuffer(struct DRISUPScreen *psDRISUPScreen, |
| + struct DRISUPBuffer *psDRISUPBuffer) |
| +{ |
| + CallFuncV2(v0.ReleaseBuffer, |
| + psDRISUPScreen, psDRISUPBuffer); |
| +} |
| + |
| +void |
| +DRISUPSetTexBuffer2(struct DRISUPContext *psDRISUPContext, int iTarget, |
| + int iFormat, struct DRISUPDrawable *psDRISUPDrawable) |
| +{ |
| + CallFuncV2(v0.SetTexBuffer2, |
| + psDRISUPContext, iTarget, iFormat, psDRISUPDrawable); |
| +} |
| + |
| +void |
| +DRISUPReleaseTexBuffer(struct DRISUPContext *psDRISUPContext, int iTarget, |
| + struct DRISUPDrawable *psDRISUPDrawable) |
| +{ |
| + CallFuncV2(v0.ReleaseTexBuffer, |
| + psDRISUPContext, iTarget, psDRISUPDrawable); |
| +} |
| + |
| +void |
| +DRISUPFlush(struct DRISUPDrawable *ps
|