1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * Copyright © 2008 Intel Corporation 3*4882a593Smuzhiyun * 4*4882a593Smuzhiyun * Permission is hereby granted, free of charge, to any person obtaining a 5*4882a593Smuzhiyun * copy of this software and associated documentation files (the "Software"), 6*4882a593Smuzhiyun * to deal in the Software without restriction, including without limitation 7*4882a593Smuzhiyun * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8*4882a593Smuzhiyun * and/or sell copies of the Software, and to permit persons to whom the 9*4882a593Smuzhiyun * Software is furnished to do so, subject to the following conditions: 10*4882a593Smuzhiyun * 11*4882a593Smuzhiyun * The above copyright notice and this permission notice (including the next 12*4882a593Smuzhiyun * paragraph) shall be included in all copies or substantial portions of the 13*4882a593Smuzhiyun * Software. 14*4882a593Smuzhiyun * 15*4882a593Smuzhiyun * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16*4882a593Smuzhiyun * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17*4882a593Smuzhiyun * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18*4882a593Smuzhiyun * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19*4882a593Smuzhiyun * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20*4882a593Smuzhiyun * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21*4882a593Smuzhiyun * IN THE SOFTWARE. 22*4882a593Smuzhiyun * 23*4882a593Smuzhiyun * Authors: 24*4882a593Smuzhiyun * Eric Anholt <eric@anholt.net> 25*4882a593Smuzhiyun * Zhigang Gong <zhigang.gong@linux.intel.com> 26*4882a593Smuzhiyun * 27*4882a593Smuzhiyun */ 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun #ifndef GLAMOR_H 30*4882a593Smuzhiyun #define GLAMOR_H 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun #include <scrnintstr.h> 33*4882a593Smuzhiyun #include <pixmapstr.h> 34*4882a593Smuzhiyun #include <gcstruct.h> 35*4882a593Smuzhiyun #include <picturestr.h> 36*4882a593Smuzhiyun #include <fb.h> 37*4882a593Smuzhiyun #include <fbpict.h> 38*4882a593Smuzhiyun #ifdef GLAMOR_FOR_XORG 39*4882a593Smuzhiyun #include <xf86xv.h> 40*4882a593Smuzhiyun #endif 41*4882a593Smuzhiyun 42*4882a593Smuzhiyun struct glamor_context; 43*4882a593Smuzhiyun struct gbm_bo; 44*4882a593Smuzhiyun struct gbm_device; 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun /* 47*4882a593Smuzhiyun * glamor_pixmap_type : glamor pixmap's type. 48*4882a593Smuzhiyun * @MEMORY: pixmap is in memory. 49*4882a593Smuzhiyun * @TEXTURE_DRM: pixmap is in a texture created from a DRM buffer. 50*4882a593Smuzhiyun * @SEPARATE_TEXTURE: The texture is created from a DRM buffer, but 51*4882a593Smuzhiyun * the format is incompatible, so this type of pixmap 52*4882a593Smuzhiyun * will never fallback to DDX layer. 53*4882a593Smuzhiyun * @DRM_ONLY: pixmap is in a external DRM buffer. 54*4882a593Smuzhiyun * @TEXTURE_ONLY: pixmap is in an internal texture. 55*4882a593Smuzhiyun */ 56*4882a593Smuzhiyun typedef enum glamor_pixmap_type { 57*4882a593Smuzhiyun GLAMOR_MEMORY = 0, /* Newly calloc()ed pixmaps are memory. */ 58*4882a593Smuzhiyun GLAMOR_TEXTURE_DRM, 59*4882a593Smuzhiyun GLAMOR_DRM_ONLY, 60*4882a593Smuzhiyun GLAMOR_TEXTURE_ONLY, 61*4882a593Smuzhiyun } glamor_pixmap_type_t; 62*4882a593Smuzhiyun 63*4882a593Smuzhiyun typedef Bool (*GetDrawableModifiersFuncPtr) (DrawablePtr draw, 64*4882a593Smuzhiyun uint32_t format, 65*4882a593Smuzhiyun uint32_t *num_modifiers, 66*4882a593Smuzhiyun uint64_t **modifiers); 67*4882a593Smuzhiyun 68*4882a593Smuzhiyun #define GLAMOR_EGL_EXTERNAL_BUFFER 3 69*4882a593Smuzhiyun #define GLAMOR_USE_EGL_SCREEN (1 << 0) 70*4882a593Smuzhiyun #define GLAMOR_NO_DRI3 (1 << 1) 71*4882a593Smuzhiyun #define GLAMOR_VALID_FLAGS (GLAMOR_USE_EGL_SCREEN \ 72*4882a593Smuzhiyun | GLAMOR_NO_DRI3) 73*4882a593Smuzhiyun 74*4882a593Smuzhiyun /* until we need geometry shaders GL3.1 should suffice. */ 75*4882a593Smuzhiyun #define GLAMOR_GL_CORE_VER_MAJOR 3 76*4882a593Smuzhiyun #define GLAMOR_GL_CORE_VER_MINOR 1 77*4882a593Smuzhiyun 78*4882a593Smuzhiyun /* @glamor_init: Initialize glamor internal data structure. 79*4882a593Smuzhiyun * 80*4882a593Smuzhiyun * @screen: Current screen pointer. 81*4882a593Smuzhiyun * @flags: Please refer the flags description above. 82*4882a593Smuzhiyun * 83*4882a593Smuzhiyun * @GLAMOR_USE_EGL_SCREEN: 84*4882a593Smuzhiyun * If you are using EGL layer, then please set this bit 85*4882a593Smuzhiyun * on, otherwise, clear it. 86*4882a593Smuzhiyun * 87*4882a593Smuzhiyun * @GLAMOR_NO_DRI3 88*4882a593Smuzhiyun * Disable the built-in DRI3 support 89*4882a593Smuzhiyun * 90*4882a593Smuzhiyun * This function initializes necessary internal data structure 91*4882a593Smuzhiyun * for glamor. And before calling into this function, the OpenGL 92*4882a593Smuzhiyun * environment should be ready. Should be called before any real 93*4882a593Smuzhiyun * glamor rendering or texture allocation functions. And should 94*4882a593Smuzhiyun * be called after the DDX's screen initialization or at the last 95*4882a593Smuzhiyun * step of the DDX's screen initialization. 96*4882a593Smuzhiyun */ 97*4882a593Smuzhiyun extern _X_EXPORT Bool glamor_init(ScreenPtr screen, unsigned int flags); 98*4882a593Smuzhiyun extern _X_EXPORT void glamor_fini(ScreenPtr screen); 99*4882a593Smuzhiyun 100*4882a593Smuzhiyun /* This function is used to free the glamor private screen's 101*4882a593Smuzhiyun * resources. If the DDX driver is not set GLAMOR_USE_SCREEN, 102*4882a593Smuzhiyun * then, DDX need to call this function at proper stage, if 103*4882a593Smuzhiyun * it is the xorg DDX driver,then it should be called at free 104*4882a593Smuzhiyun * screen stage not the close screen stage. The reason is after 105*4882a593Smuzhiyun * call to this function, the xorg DDX may need to destroy the 106*4882a593Smuzhiyun * screen pixmap which must be a glamor pixmap and requires 107*4882a593Smuzhiyun * the internal data structure still exist at that time. 108*4882a593Smuzhiyun * Otherwise, the glamor internal structure will not be freed.*/ 109*4882a593Smuzhiyun extern _X_EXPORT Bool glamor_close_screen(ScreenPtr screen); 110*4882a593Smuzhiyun 111*4882a593Smuzhiyun extern _X_EXPORT uint32_t glamor_get_pixmap_texture(PixmapPtr pixmap); 112*4882a593Smuzhiyun 113*4882a593Smuzhiyun extern _X_EXPORT Bool glamor_set_pixmap_texture(PixmapPtr pixmap, 114*4882a593Smuzhiyun unsigned int tex); 115*4882a593Smuzhiyun 116*4882a593Smuzhiyun extern _X_EXPORT void glamor_set_pixmap_type(PixmapPtr pixmap, 117*4882a593Smuzhiyun glamor_pixmap_type_t type); 118*4882a593Smuzhiyun 119*4882a593Smuzhiyun extern _X_EXPORT void glamor_clear_pixmap(PixmapPtr pixmap); 120*4882a593Smuzhiyun 121*4882a593Smuzhiyun extern _X_EXPORT void glamor_block_handler(ScreenPtr screen); 122*4882a593Smuzhiyun 123*4882a593Smuzhiyun extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h, 124*4882a593Smuzhiyun int depth, unsigned int usage); 125*4882a593Smuzhiyun extern _X_EXPORT Bool glamor_destroy_pixmap(PixmapPtr pixmap); 126*4882a593Smuzhiyun 127*4882a593Smuzhiyun #define GLAMOR_CREATE_PIXMAP_CPU 0x100 128*4882a593Smuzhiyun #define GLAMOR_CREATE_PIXMAP_FIXUP 0x101 129*4882a593Smuzhiyun #define GLAMOR_CREATE_FBO_NO_FBO 0x103 130*4882a593Smuzhiyun #define GLAMOR_CREATE_NO_LARGE 0x105 131*4882a593Smuzhiyun #define GLAMOR_CREATE_PIXMAP_NO_TEXTURE 0x106 132*4882a593Smuzhiyun #define GLAMOR_CREATE_FORMAT_CBCR 0x107 133*4882a593Smuzhiyun 134*4882a593Smuzhiyun /* @glamor_egl_exchange_buffers: Exchange the underlying buffers(KHR image,fbo). 135*4882a593Smuzhiyun * 136*4882a593Smuzhiyun * @front: front pixmap. 137*4882a593Smuzhiyun * @back: back pixmap. 138*4882a593Smuzhiyun * 139*4882a593Smuzhiyun * Used by the DRI2 page flip. This function will exchange the KHR images and 140*4882a593Smuzhiyun * fbos of the two pixmaps. 141*4882a593Smuzhiyun * */ 142*4882a593Smuzhiyun extern _X_EXPORT void glamor_egl_exchange_buffers(PixmapPtr front, 143*4882a593Smuzhiyun PixmapPtr back); 144*4882a593Smuzhiyun 145*4882a593Smuzhiyun extern _X_EXPORT void glamor_pixmap_exchange_fbos(PixmapPtr front, 146*4882a593Smuzhiyun PixmapPtr back); 147*4882a593Smuzhiyun 148*4882a593Smuzhiyun /* The DDX is not supposed to call these four functions */ 149*4882a593Smuzhiyun extern _X_EXPORT void glamor_enable_dri3(ScreenPtr screen); 150*4882a593Smuzhiyun extern _X_EXPORT int glamor_egl_fds_from_pixmap(ScreenPtr, PixmapPtr, int *, 151*4882a593Smuzhiyun uint32_t *, uint32_t *, 152*4882a593Smuzhiyun uint64_t *); 153*4882a593Smuzhiyun extern _X_EXPORT int glamor_egl_fd_name_from_pixmap(ScreenPtr, PixmapPtr, 154*4882a593Smuzhiyun CARD16 *, CARD32 *); 155*4882a593Smuzhiyun 156*4882a593Smuzhiyun extern _X_EXPORT struct gbm_device *glamor_egl_get_gbm_device(ScreenPtr screen); 157*4882a593Smuzhiyun extern _X_EXPORT int glamor_egl_fd_from_pixmap(ScreenPtr, PixmapPtr, CARD16 *, CARD32 *); 158*4882a593Smuzhiyun 159*4882a593Smuzhiyun /* @glamor_supports_pixmap_import_export: Returns whether 160*4882a593Smuzhiyun * glamor_fds_from_pixmap(), glamor_name_from_pixmap(), and 161*4882a593Smuzhiyun * glamor_pixmap_from_fds() are supported. 162*4882a593Smuzhiyun * 163*4882a593Smuzhiyun * @screen: Current screen pointer. 164*4882a593Smuzhiyun * 165*4882a593Smuzhiyun * To have DRI3 support enabled, glamor and glamor_egl need to be 166*4882a593Smuzhiyun * initialized. glamor also has to be compiled with gbm support. 167*4882a593Smuzhiyun * 168*4882a593Smuzhiyun * The EGL layer needs to have the following extensions working: 169*4882a593Smuzhiyun * 170*4882a593Smuzhiyun * .EGL_KHR_surfaceless_context 171*4882a593Smuzhiyun * */ 172*4882a593Smuzhiyun extern _X_EXPORT Bool glamor_supports_pixmap_import_export(ScreenPtr screen); 173*4882a593Smuzhiyun 174*4882a593Smuzhiyun /* @glamor_fds_from_pixmap: Get a dma-buf fd from a pixmap. 175*4882a593Smuzhiyun * 176*4882a593Smuzhiyun * @screen: Current screen pointer. 177*4882a593Smuzhiyun * @pixmap: The pixmap from which we want the fd. 178*4882a593Smuzhiyun * @fds, @strides, @offsets: Pointers to fill info of each plane. 179*4882a593Smuzhiyun * @modifier: Pointer to fill the modifier of the buffer. 180*4882a593Smuzhiyun * 181*4882a593Smuzhiyun * the pixmap and the buffer associated by the fds will share the same 182*4882a593Smuzhiyun * content. The caller is responsible to close the returned file descriptors. 183*4882a593Smuzhiyun * Returns the number of planes, -1 on error. 184*4882a593Smuzhiyun * */ 185*4882a593Smuzhiyun extern _X_EXPORT int glamor_fds_from_pixmap(ScreenPtr screen, 186*4882a593Smuzhiyun PixmapPtr pixmap, 187*4882a593Smuzhiyun int *fds, 188*4882a593Smuzhiyun uint32_t *strides, uint32_t *offsets, 189*4882a593Smuzhiyun uint64_t *modifier); 190*4882a593Smuzhiyun 191*4882a593Smuzhiyun /* @glamor_fd_from_pixmap: Get a dma-buf fd from a pixmap. 192*4882a593Smuzhiyun * 193*4882a593Smuzhiyun * @screen: Current screen pointer. 194*4882a593Smuzhiyun * @pixmap: The pixmap from which we want the fd. 195*4882a593Smuzhiyun * @stride, @size: Pointers to fill the stride and size of the 196*4882a593Smuzhiyun * buffer associated to the fd. 197*4882a593Smuzhiyun * 198*4882a593Smuzhiyun * the pixmap and the buffer associated by the fd will share the same 199*4882a593Smuzhiyun * content. 200*4882a593Smuzhiyun * Returns the fd on success, -1 on error. 201*4882a593Smuzhiyun * */ 202*4882a593Smuzhiyun extern _X_EXPORT int glamor_fd_from_pixmap(ScreenPtr screen, 203*4882a593Smuzhiyun PixmapPtr pixmap, 204*4882a593Smuzhiyun CARD16 *stride, CARD32 *size); 205*4882a593Smuzhiyun 206*4882a593Smuzhiyun /* @glamor_shareable_fd_from_pixmap: Get a dma-buf fd suitable for sharing 207*4882a593Smuzhiyun * with other GPUs from a pixmap. 208*4882a593Smuzhiyun * 209*4882a593Smuzhiyun * @screen: Current screen pointer. 210*4882a593Smuzhiyun * @pixmap: The pixmap from which we want the fd. 211*4882a593Smuzhiyun * @stride, @size: Pointers to fill the stride and size of the 212*4882a593Smuzhiyun * buffer associated to the fd. 213*4882a593Smuzhiyun * 214*4882a593Smuzhiyun * The returned fd will point to a buffer which is suitable for sharing 215*4882a593Smuzhiyun * across GPUs (not using GPU specific tiling). 216*4882a593Smuzhiyun * The pixmap and the buffer associated by the fd will share the same 217*4882a593Smuzhiyun * content. 218*4882a593Smuzhiyun * The pixmap's stride may be modified by this function. 219*4882a593Smuzhiyun * Returns the fd on success, -1 on error. 220*4882a593Smuzhiyun * */ 221*4882a593Smuzhiyun extern _X_EXPORT int glamor_shareable_fd_from_pixmap(ScreenPtr screen, 222*4882a593Smuzhiyun PixmapPtr pixmap, 223*4882a593Smuzhiyun CARD16 *stride, 224*4882a593Smuzhiyun CARD32 *size); 225*4882a593Smuzhiyun 226*4882a593Smuzhiyun /** 227*4882a593Smuzhiyun * @glamor_name_from_pixmap: Gets a gem name from a pixmap. 228*4882a593Smuzhiyun * 229*4882a593Smuzhiyun * @pixmap: The pixmap from which we want the gem name. 230*4882a593Smuzhiyun * 231*4882a593Smuzhiyun * the pixmap and the buffer associated by the gem name will share the 232*4882a593Smuzhiyun * same content. This function can be used by the DDX to support DRI2, 233*4882a593Smuzhiyun * and needs the same set of buffer export GL extensions as DRI3 234*4882a593Smuzhiyun * support. 235*4882a593Smuzhiyun * 236*4882a593Smuzhiyun * Returns the name on success, -1 on error. 237*4882a593Smuzhiyun * */ 238*4882a593Smuzhiyun extern _X_EXPORT int glamor_name_from_pixmap(PixmapPtr pixmap, 239*4882a593Smuzhiyun CARD16 *stride, CARD32 *size); 240*4882a593Smuzhiyun 241*4882a593Smuzhiyun /* @glamor_gbm_bo_from_pixmap: Get a GBM bo from a pixmap. 242*4882a593Smuzhiyun * 243*4882a593Smuzhiyun * @screen: Current screen pointer. 244*4882a593Smuzhiyun * @pixmap: The pixmap from which we want the fd. 245*4882a593Smuzhiyun * @stride, @size: Pointers to fill the stride and size of the 246*4882a593Smuzhiyun * buffer associated to the fd. 247*4882a593Smuzhiyun * 248*4882a593Smuzhiyun * the pixmap and the buffer represented by the gbm_bo will share the same 249*4882a593Smuzhiyun * content. 250*4882a593Smuzhiyun * 251*4882a593Smuzhiyun * Returns the gbm_bo on success, NULL on error. 252*4882a593Smuzhiyun * */ 253*4882a593Smuzhiyun extern _X_EXPORT struct gbm_bo *glamor_gbm_bo_from_pixmap(ScreenPtr screen, 254*4882a593Smuzhiyun PixmapPtr pixmap); 255*4882a593Smuzhiyun 256*4882a593Smuzhiyun /* @glamor_pixmap_from_fds: Creates a pixmap to wrap a dma-buf fds. 257*4882a593Smuzhiyun * 258*4882a593Smuzhiyun * @screen: Current screen pointer. 259*4882a593Smuzhiyun * @num_fds: Number of fds to import 260*4882a593Smuzhiyun * @fds: The dma-buf fds to import. 261*4882a593Smuzhiyun * @width: The width of the buffers. 262*4882a593Smuzhiyun * @height: The height of the buffers. 263*4882a593Smuzhiyun * @stride: The stride of the buffers. 264*4882a593Smuzhiyun * @depth: The depth of the buffers. 265*4882a593Smuzhiyun * @bpp: The bpp of the buffers. 266*4882a593Smuzhiyun * @modifier: The modifier of the buffers. 267*4882a593Smuzhiyun * 268*4882a593Smuzhiyun * Returns a valid pixmap if the import succeeded, else NULL. 269*4882a593Smuzhiyun * */ 270*4882a593Smuzhiyun extern _X_EXPORT PixmapPtr glamor_pixmap_from_fds(ScreenPtr screen, 271*4882a593Smuzhiyun CARD8 num_fds, 272*4882a593Smuzhiyun const int *fds, 273*4882a593Smuzhiyun CARD16 width, 274*4882a593Smuzhiyun CARD16 height, 275*4882a593Smuzhiyun const CARD32 *strides, 276*4882a593Smuzhiyun const CARD32 *offsets, 277*4882a593Smuzhiyun CARD8 depth, 278*4882a593Smuzhiyun CARD8 bpp, 279*4882a593Smuzhiyun uint64_t modifier); 280*4882a593Smuzhiyun 281*4882a593Smuzhiyun /* @glamor_pixmap_from_fd: Creates a pixmap to wrap a dma-buf fd. 282*4882a593Smuzhiyun * 283*4882a593Smuzhiyun * @screen: Current screen pointer. 284*4882a593Smuzhiyun * @fd: The dma-buf fd to import. 285*4882a593Smuzhiyun * @width: The width of the buffer. 286*4882a593Smuzhiyun * @height: The height of the buffer. 287*4882a593Smuzhiyun * @stride: The stride of the buffer. 288*4882a593Smuzhiyun * @depth: The depth of the buffer. 289*4882a593Smuzhiyun * @bpp: The bpp of the buffer. 290*4882a593Smuzhiyun * 291*4882a593Smuzhiyun * Returns a valid pixmap if the import succeeded, else NULL. 292*4882a593Smuzhiyun * */ 293*4882a593Smuzhiyun extern _X_EXPORT PixmapPtr glamor_pixmap_from_fd(ScreenPtr screen, 294*4882a593Smuzhiyun int fd, 295*4882a593Smuzhiyun CARD16 width, 296*4882a593Smuzhiyun CARD16 height, 297*4882a593Smuzhiyun CARD16 stride, 298*4882a593Smuzhiyun CARD8 depth, 299*4882a593Smuzhiyun CARD8 bpp); 300*4882a593Smuzhiyun 301*4882a593Smuzhiyun /* @glamor_back_pixmap_from_fd: Backs an existing pixmap with a dma-buf fd. 302*4882a593Smuzhiyun * 303*4882a593Smuzhiyun * @pixmap: Pixmap to change backing for 304*4882a593Smuzhiyun * @fd: The dma-buf fd to import. 305*4882a593Smuzhiyun * @width: The width of the buffer. 306*4882a593Smuzhiyun * @height: The height of the buffer. 307*4882a593Smuzhiyun * @stride: The stride of the buffer. 308*4882a593Smuzhiyun * @depth: The depth of the buffer. 309*4882a593Smuzhiyun * @bpp: The number of bpp of the buffer. 310*4882a593Smuzhiyun * 311*4882a593Smuzhiyun * Returns TRUE if successful, FALSE on failure. 312*4882a593Smuzhiyun * */ 313*4882a593Smuzhiyun extern _X_EXPORT Bool glamor_back_pixmap_from_fd(PixmapPtr pixmap, 314*4882a593Smuzhiyun int fd, 315*4882a593Smuzhiyun CARD16 width, 316*4882a593Smuzhiyun CARD16 height, 317*4882a593Smuzhiyun CARD16 stride, 318*4882a593Smuzhiyun CARD8 depth, 319*4882a593Smuzhiyun CARD8 bpp); 320*4882a593Smuzhiyun 321*4882a593Smuzhiyun extern _X_EXPORT Bool glamor_get_formats(ScreenPtr screen, 322*4882a593Smuzhiyun CARD32 *num_formats, 323*4882a593Smuzhiyun CARD32 **formats); 324*4882a593Smuzhiyun 325*4882a593Smuzhiyun extern _X_EXPORT Bool glamor_get_modifiers(ScreenPtr screen, 326*4882a593Smuzhiyun uint32_t format, 327*4882a593Smuzhiyun uint32_t *num_modifiers, 328*4882a593Smuzhiyun uint64_t **modifiers); 329*4882a593Smuzhiyun 330*4882a593Smuzhiyun extern _X_EXPORT Bool glamor_get_drawable_modifiers(DrawablePtr draw, 331*4882a593Smuzhiyun uint32_t format, 332*4882a593Smuzhiyun uint32_t *num_modifiers, 333*4882a593Smuzhiyun uint64_t **modifiers); 334*4882a593Smuzhiyun 335*4882a593Smuzhiyun extern _X_EXPORT void glamor_set_drawable_modifiers_func(ScreenPtr screen, 336*4882a593Smuzhiyun GetDrawableModifiersFuncPtr func); 337*4882a593Smuzhiyun 338*4882a593Smuzhiyun #ifdef GLAMOR_FOR_XORG 339*4882a593Smuzhiyun 340*4882a593Smuzhiyun #define GLAMOR_EGL_MODULE_NAME "glamoregl" 341*4882a593Smuzhiyun 342*4882a593Smuzhiyun /* @glamor_egl_init: Initialize EGL environment. 343*4882a593Smuzhiyun * 344*4882a593Smuzhiyun * @scrn: Current screen info pointer. 345*4882a593Smuzhiyun * @fd: Current drm fd. 346*4882a593Smuzhiyun * 347*4882a593Smuzhiyun * This function creates and intialize EGL contexts. 348*4882a593Smuzhiyun * Should be called from DDX's preInit function. 349*4882a593Smuzhiyun * Return TRUE if success, otherwise return FALSE. 350*4882a593Smuzhiyun * */ 351*4882a593Smuzhiyun extern _X_EXPORT Bool glamor_egl_init(ScrnInfoPtr scrn, int fd); 352*4882a593Smuzhiyun 353*4882a593Smuzhiyun extern _X_EXPORT Bool glamor_egl_init_textured_pixmap(ScreenPtr screen); 354*4882a593Smuzhiyun 355*4882a593Smuzhiyun /* @glamor_egl_create_textured_screen: Create textured screen pixmap. 356*4882a593Smuzhiyun * 357*4882a593Smuzhiyun * @screen: screen pointer to be processed. 358*4882a593Smuzhiyun * @handle: screen pixmap's BO handle. 359*4882a593Smuzhiyun * @stride: screen pixmap's stride in bytes. 360*4882a593Smuzhiyun * 361*4882a593Smuzhiyun * This function is similar with the create_textured_pixmap. As the 362*4882a593Smuzhiyun * screen pixmap is a special, we handle it separately in this function. 363*4882a593Smuzhiyun */ 364*4882a593Smuzhiyun extern _X_EXPORT Bool glamor_egl_create_textured_screen(ScreenPtr screen, 365*4882a593Smuzhiyun int handle, int stride); 366*4882a593Smuzhiyun 367*4882a593Smuzhiyun /* Obsolete entrypoint, temporarily left here for API compatibility 368*4882a593Smuzhiyun * for xf86-video-ati. 369*4882a593Smuzhiyun */ 370*4882a593Smuzhiyun #define glamor_egl_create_textured_screen_ext(a, b, c, d) \ 371*4882a593Smuzhiyun glamor_egl_create_textured_screen(a, b, c) 372*4882a593Smuzhiyun 373*4882a593Smuzhiyun /* 374*4882a593Smuzhiyun * @glamor_egl_create_textured_pixmap: Try to create a textured pixmap from 375*4882a593Smuzhiyun * a BO handle. 376*4882a593Smuzhiyun * 377*4882a593Smuzhiyun * @pixmap: The pixmap need to be processed. 378*4882a593Smuzhiyun * @handle: The BO's handle attached to this pixmap at DDX layer. 379*4882a593Smuzhiyun * @stride: Stride in bytes for this pixmap. 380*4882a593Smuzhiyun * 381*4882a593Smuzhiyun * This function try to create a texture from the handle and attach 382*4882a593Smuzhiyun * the texture to the pixmap , thus glamor can render to this pixmap 383*4882a593Smuzhiyun * as well. Return true if successful, otherwise return FALSE. 384*4882a593Smuzhiyun */ 385*4882a593Smuzhiyun extern _X_EXPORT Bool glamor_egl_create_textured_pixmap(PixmapPtr pixmap, 386*4882a593Smuzhiyun int handle, int stride); 387*4882a593Smuzhiyun 388*4882a593Smuzhiyun /* 389*4882a593Smuzhiyun * @glamor_egl_create_textured_pixmap_from_bo: Try to create a textured pixmap 390*4882a593Smuzhiyun * from a gbm_bo. 391*4882a593Smuzhiyun * 392*4882a593Smuzhiyun * @pixmap: The pixmap need to be processed. 393*4882a593Smuzhiyun * @bo: a pointer on a gbm_bo structure attached to this pixmap at DDX layer. 394*4882a593Smuzhiyun * 395*4882a593Smuzhiyun * This function is similar to glamor_egl_create_textured_pixmap. 396*4882a593Smuzhiyun */ 397*4882a593Smuzhiyun extern _X_EXPORT Bool 398*4882a593Smuzhiyun glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, 399*4882a593Smuzhiyun struct gbm_bo *bo, 400*4882a593Smuzhiyun Bool used_modifiers); 401*4882a593Smuzhiyun 402*4882a593Smuzhiyun extern _X_EXPORT const char *glamor_egl_get_driver_name(ScreenPtr screen); 403*4882a593Smuzhiyun 404*4882a593Smuzhiyun #endif 405*4882a593Smuzhiyun 406*4882a593Smuzhiyun extern _X_EXPORT void glamor_egl_screen_init(ScreenPtr screen, 407*4882a593Smuzhiyun struct glamor_context *glamor_ctx); 408*4882a593Smuzhiyun 409*4882a593Smuzhiyun extern _X_EXPORT int glamor_create_gc(GCPtr gc); 410*4882a593Smuzhiyun 411*4882a593Smuzhiyun extern _X_EXPORT void glamor_validate_gc(GCPtr gc, unsigned long changes, 412*4882a593Smuzhiyun DrawablePtr drawable); 413*4882a593Smuzhiyun 414*4882a593Smuzhiyun extern _X_EXPORT void glamor_destroy_gc(GCPtr gc); 415*4882a593Smuzhiyun 416*4882a593Smuzhiyun #define HAS_GLAMOR_DESTROY_GC 1 417*4882a593Smuzhiyun 418*4882a593Smuzhiyun extern Bool _X_EXPORT glamor_change_window_attributes(WindowPtr pWin, unsigned long mask); 419*4882a593Smuzhiyun extern void _X_EXPORT glamor_copy_window(WindowPtr window, DDXPointRec old_origin, RegionPtr src_region); 420*4882a593Smuzhiyun 421*4882a593Smuzhiyun extern _X_EXPORT void glamor_finish(ScreenPtr screen); 422*4882a593Smuzhiyun extern _X_EXPORT void glamor_pixmap_invalid(PixmapPtr pixmap); 423*4882a593Smuzhiyun #define HAS_GLAMOR_TEXT 1 424*4882a593Smuzhiyun 425*4882a593Smuzhiyun #ifdef GLAMOR_FOR_XORG 426*4882a593Smuzhiyun extern _X_EXPORT XF86VideoAdaptorPtr glamor_xv_init(ScreenPtr pScreen, 427*4882a593Smuzhiyun int num_texture_ports); 428*4882a593Smuzhiyun #endif 429*4882a593Smuzhiyun 430*4882a593Smuzhiyun #endif /* GLAMOR_H */ 431