Home | History | Annotate | Download | only in va
      1 /*
      2  * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
      3  *
      4  * Permission is hereby granted, free of charge, to any person obtaining a
      5  * copy of this software and associated documentation files (the
      6  * "Software"), to deal in the Software without restriction, including
      7  * without limitation the rights to use, copy, modify, merge, publish,
      8  * distribute, sub license, and/or sell copies of the Software, and to
      9  * permit persons to whom the Software is furnished to do so, subject to
     10  * the following conditions:
     11  *
     12  * The above copyright notice and this permission notice (including the
     13  * next paragraph) shall be included in all copies or substantial portions
     14  * of the Software.
     15  *
     16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
     17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
     19  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
     20  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
     21  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
     22  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     23  */
     24 #ifndef _VA_EGL_H_
     25 #define _VA_EGL_H_
     26 
     27 #include <va/va.h>
     28 #include <EGL/egl.h>
     29 #include <EGL/eglext.h>
     30 
     31 #ifdef __cplusplus
     32 extern "C" {
     33 #endif
     34 
     35 typedef void *VASurfaceEGL;
     36 
     37 /*This function is used to get EGLClientBuffer
     38  * (lower 16bits is buffer index, upper 16bits
     39  * is BC device id.) from surface id. Application
     40  * should maintain EGLClientBuffer itself.*/
     41 
     42 VAStatus vaGetEGLClientBufferFromSurface (
     43     VADisplay dpy,
     44     VASurfaceID surface,
     45     EGLClientBuffer *buffer     /* out*/
     46 );
     47 
     48 /**
     49  * Return a suitable VADisplay for VA API
     50  *
     51  * @param[in] native_dpy the native display
     52  * @param[in] egl_dpy the EGL display
     53  * @return a VADisplay
     54  */
     55 VADisplay vaGetDisplayEGL(
     56     VANativeDisplay native_dpy,
     57     EGLDisplay egl_dpy
     58 );
     59 
     60 /**
     61  * Return maximum number of EGL targets supported by the implementation
     62  *
     63  * @param[in] dpy the VADisplay
     64  * @return the maximum number of EGL Target
     65  */
     66 int vaMaxNumSurfaceTargetsEGL(
     67     VADisplay dpy
     68 );
     69 
     70 /**
     71  * Return maximum number of EGL surface attributes supported by the implementation
     72  *
     73  * @param[in] dpy the VADisplay
     74  * @return the maximum number of EGL surface attributes
     75  */
     76 int vaMaxNumSurfaceAttributesEGL(
     77     VADisplay dpy
     78 );
     79 
     80 /**
     81  * Query supported EGL targets for eglCreateImageKHR().
     82  *
     83  * The caller must provide a "target_list" array that can hold at
     84  * least vaMaxNumSurfaceTargetsEGL() entries. The actual number of
     85  * targets returned in "target_list" is returned in "num_targets".
     86  *
     87  * @param[in]] dpy              the VADisplay
     88  * @param[out] target_list      the array to hold target entries
     89  * @param[out] num_targets      the actual number of targets
     90  * @return VA_STATUS_SUCCESS if successful
     91  */
     92 VAStatus vaQuerySurfaceTargetsEGL(
     93     VADisplay dpy,
     94     EGLenum *target_list,       /* out */
     95     int *num_targets		/* out */
     96 );
     97 
     98 /**
     99  * Creates a VA/EGL surface with the specified target
    100  *
    101  * If target is 0, this means the best efficient target by default.
    102  *
    103  * @param[in] dpy               the VADisplay
    104  * @param[in] target            the specified EGL target
    105  * @param[in] width             the surface width
    106  * @param[in] height            the surface height
    107  * @param[out] gl_surface the VA/EGL surface
    108  * @return VA_STATUS_SUCCESS if successful
    109  */
    110 VAStatus vaCreateSurfaceEGL(
    111     VADisplay dpy,
    112     EGLenum target,
    113     unsigned int width,
    114     unsigned int height,
    115     VASurfaceEGL *gl_surface
    116 );
    117 
    118 /**
    119  * Destroy a VA/EGL surface
    120  *
    121  * The application shall maintain the live EGL context itself.
    122  *
    123  * @param[in]  dpy        the VA display
    124  * @param[in]  gl_surface the VA surface
    125  * @return VA_STATUS_SUCCESS if successful
    126  */
    127 VAStatus vaDestroySurfaceEGL(
    128     VADisplay dpy,
    129     VASurfaceEGL gl_surface
    130 );
    131 
    132 /**
    133  * Associate a EGL surface with a VA surface
    134  *
    135  * @param[in]  dpy         the VA display
    136  * @param[in]  egl_surface the VA/EGL destination surface
    137  * @param[in]  surface     the VA surface
    138  * @param[in]  flags       the flags to PutSurface
    139  * @return VA_STATUS_SUCCESS if successful
    140  */
    141 VAStatus vaAssociateSurfaceEGL(
    142     VADisplay dpy,
    143     VASurfaceEGL egl_surface,
    144     VASurfaceID surface,
    145     unsigned int flags
    146 );
    147 
    148 /**
    149  * Update the content of a VA/EGL surface
    150  *
    151  * Changes to VA surface are committed to VA/EGL surface at this point.
    152  *
    153  * @param[in] dpy         the VA display
    154  * @param[in] egl_surface the VA/EGL surface that has been associated with a VA surface
    155  * @return VA_STATUS_SUCCESS if successful
    156  */
    157 VAStatus vaSyncSurfaceEGL(
    158     VADisplay dpy,
    159     VASurfaceEGL egl_surface
    160 );
    161 
    162 /**
    163  * Get the necessary information for eglCreateImageKHR()
    164  *
    165  * The caller must provide a "attrib_list" array that can hold at
    166  * least (2 * vaMaxNumSurfaceAttributesEGL()) entries. The last attribute
    167  * specified in attrib_list must be EGL_NONE
    168  *
    169  * @param[in]  dpy         the VA display
    170  * @param[in]  egl_surface the VA/EGL surface that has been associated with a VA surface
    171  * @param[out] target      the type of <buffer> for eglCreateImageKHR()
    172  * @param[out] buffer      the EGLClientBuffer for eglCreateImageKHR()
    173  * @param[out] attrib_list the list of attribute-value pairs for eglCreateImageKHR()
    174  * @param[in/out] num_attribs input: the number of allocated attribute-value pairs in attrib_list; output: the actual number of attribute-value pairs
    175  * @return VA_STATUS_SUCCESS if successful
    176  */
    177 VAStatus vaGetSurfaceInfoEGL(
    178     VADisplay dpy,
    179     VASurfaceEGL egl_surface,
    180     EGLenum *target,            /* out, the type of <buffer> */
    181     EGLClientBuffer *buffer,    /* out */
    182     EGLint *attrib_list,        /* out, the last attribute must be EGL_NONE */
    183     int *num_attribs            /* in/out, the number of attribute-value pairs */
    184 );
    185 
    186 /**
    187  * Deassociate a EGL surface
    188  *
    189  * @param[in]  dpy         the VA display
    190  * @param[in]  egl_surface the VA/EGL destination surface
    191  * @return VA_STATUS_SUCCESS if successful
    192  */
    193 VAStatus vaDeassociateSurfaceEGL(
    194     VADisplay dpy,
    195     VASurfaceEGL egl_surface
    196 );
    197 
    198 #ifdef __cplusplus
    199 }
    200 #endif
    201 
    202 #endif /* _VA_EGL_H_ */
    203