OSDN Git Service

add support for processing rate
[android-x86/hardware-intel-common-libva.git] / va / va_backend.h
index cd6201e..f095c83 100644 (file)
 #define _VA_BACKEND_H_
 
 #include <va/va.h>
-#include <X11/Xlib.h>
 #include <linux/videodev2.h>
-#include <ui/Surface.h>
-
-class Surface;
 
 typedef struct VADriverContext *VADriverContextP;
 typedef struct VADisplayContext *VADisplayContextP;
 
+/** \brief VA display types. */
+enum {
+    /** \brief Mask to major identifier for VA display type. */
+    VA_DISPLAY_MAJOR_MASK = 0xf0,
+
+    /** \brief VA/X11 API is used, through vaGetDisplay() entry-point. */
+    VA_DISPLAY_X11      = 0x10,
+    /** \brief VA/GLX API is used, through vaGetDisplayGLX() entry-point. */
+    VA_DISPLAY_GLX      = (VA_DISPLAY_X11 | (1 << 0)),
+    /** \brief VA/Android API is used, through vaGetDisplay() entry-point. */
+    VA_DISPLAY_ANDROID  = 0x20,
+    /** \brief VA/DRM API is used, through vaGetDisplayDRM() entry-point. */
+    VA_DISPLAY_DRM      = 0x30,
+    /** \brief VA/DRM API is used, with a render-node device path */
+    VA_DISPLAY_DRM_RENDERNODES = (VA_DISPLAY_DRM | (1 << 0)),
+    /** \brief VA/Wayland API is used, through vaGetDisplayWl() entry-point. */
+    VA_DISPLAY_WAYLAND  = 0x40,
+};
+
 struct VADriverVTable
 {
        VAStatus (*vaTerminate) ( VADriverContextP ctx );
@@ -125,7 +140,7 @@ struct VADriverVTable
                unsigned int size,              /* in */
                unsigned int num_elements,      /* in */
                void *data,                     /* in */
-               VABufferID *buf_id              /* out */
+                VABufferID *buf_id
        );
 
        VAStatus (*vaBufferSetNumElements) (
@@ -179,10 +194,17 @@ struct VADriverVTable
                VASurfaceStatus *status /* out */
        );
 
+       VAStatus (*vaQuerySurfaceError) (
+               VADriverContextP ctx,
+               VASurfaceID render_target,
+                VAStatus error_status,
+                void **error_info /*out*/
+       );
+
        VAStatus (*vaPutSurface) (
                VADriverContextP ctx,
                VASurfaceID surface,
-               Surface* draw, /* X Drawable */
+               void* draw, /* Drawable of window system */
                short srcx,
                short srcy,
                unsigned short srcw,
@@ -339,33 +361,17 @@ struct VADriverVTable
                 int num_attributes
         );
 
-        /* device specific */
-       VAStatus (*vaCreateSurfaceFromCIFrame) (
-               VADriverContextP ctx,
-               unsigned long frame_id,
-               VASurfaceID *surface            /* out */
-       );
-    
-    
-        VAStatus (*vaCreateSurfaceFromV4L2Buf) (
-               VADriverContextP ctx,
-                int v4l2_fd,         /* file descriptor of V4L2 device */
-                struct v4l2_format *v4l2_fmt,       /* format of V4L2 */
-                struct v4l2_buffer *v4l2_buf,       /* V4L2 buffer */
-                VASurfaceID *surface              /* out */
-        );
-
+        /* used by va trace */        
         VAStatus (*vaBufferInfo) (
-                   VADriverContextP ctx,
-                   VAContextID context, /* in */
-                   VABufferID buf_id, /* in */
-                   VABufferType *type,    /* out */
-                   unsigned int *size,    /* out */
+                   VADriverContextP ctx,      /* in */
+                   VABufferID buf_id,         /* in */
+                   VABufferType *type,        /* out */
+                   unsigned int *size,        /* out */
                    unsigned int *num_elements /* out */
         );
 
-    
-        VAStatus (*vaCopySurfaceToBuffer) (
+        /* lock/unlock surface for external access */    
+        VAStatus (*vaLockSurface) (
                VADriverContextP ctx,
                 VASurfaceID surface,
                 unsigned int *fourcc, /* out  for follow argument */
@@ -375,14 +381,142 @@ struct VADriverVTable
                 unsigned int *luma_offset,
                 unsigned int *chroma_u_offset,
                 unsigned int *chroma_v_offset,
-                void **buffer
+                unsigned int *buffer_name, /* if it is not NULL, assign the low lever
+                                            * surface buffer name
+                                            */
+                void **buffer /* if it is not NULL, map the surface buffer for
+                                * CPU access
+                                */
+        );
+    
+        VAStatus (*vaUnlockSurface) (
+               VADriverContextP ctx,
+                VASurfaceID surface
+        );
+
+        /* DEPRECATED */
+        VAStatus
+        (*vaGetSurfaceAttributes)(
+            VADriverContextP    dpy,
+            VAConfigID          config,
+            VASurfaceAttrib    *attrib_list,
+            unsigned int        num_attribs
+        );
+
+        VAStatus
+        (*vaCreateSurfaces2)(
+            VADriverContextP    ctx,
+            unsigned int        format,
+            unsigned int        width,
+            unsigned int        height,
+            VASurfaceID        *surfaces,
+            unsigned int        num_surfaces,
+            VASurfaceAttrib    *attrib_list,
+            unsigned int        num_attribs
         );
+
+        VAStatus
+        (*vaQuerySurfaceAttributes)(
+            VADriverContextP    dpy,
+            VAConfigID          config,
+            VASurfaceAttrib    *attrib_list,
+            unsigned int       *num_attribs
+        );
+
+        VAStatus
+        (*vaAcquireBufferHandle)(
+            VADriverContextP    ctx,
+            VABufferID          buf_id,         /* in */
+            VABufferInfo *      buf_info        /* in/out */
+        );
+
+        VAStatus
+        (*vaReleaseBufferHandle)(
+            VADriverContextP    ctx,
+            VABufferID          buf_id          /* in */
+        );
+
+        VAStatus (*vaCreateMFContext) (
+            VADriverContextP ctx,
+            VAMFContextID *mfe_context    /* out */
+        );
+
+        VAStatus (*vaMFAddContext) (
+            VADriverContextP ctx,
+            VAMFContextID mf_context,
+            VAContextID context
+        );
+
+        VAStatus (*vaMFReleaseContext) (
+            VADriverContextP ctx,
+            VAMFContextID mf_context,
+            VAContextID context
+        );
+
+        VAStatus (*vaMFSubmit) (
+            VADriverContextP ctx,
+            VAMFContextID mf_context,
+            VAContextID *contexts,
+            int num_contexts
+        );
+       VAStatus (*vaCreateBuffer2) (
+            VADriverContextP ctx,
+            VAContextID context,                /* in */
+            VABufferType type,                  /* in */
+            unsigned int width,                 /* in */
+            unsigned int height,                /* in */
+            unsigned int *unit_size,            /* out */
+            unsigned int *pitch,                /* out */
+            VABufferID *buf_id                  /* out */
+       );
+
+        VAStatus (*vaQueryProcessingRate) (
+            VADriverContextP ctx,               /* in */
+            VAConfigID config_id,               /* in */
+            VAProcessingRateParameter *proc_buf,/* in */
+            unsigned int *processing_rate      /* out */
+        );
+        /** \brief Reserved bytes for future use, must be zero */
+        unsigned long reserved[58];
 };
 
 struct VADriverContext
 {
     void *pDriverData;
-    struct VADriverVTable vtable;
+
+    /**
+     * The core VA implementation hooks.
+     *
+     * This structure is allocated from libva with calloc().
+     */
+    struct VADriverVTable *vtable;
+
+    /**
+     * The VA/GLX implementation hooks.
+     *
+     * This structure is intended for drivers that implement the
+     * VA/GLX API. The driver implementation is responsible for the
+     * allocation and deallocation of this structure.
+     */
+    struct VADriverVTableGLX *vtable_glx;
+
+    /**
+     * The VA/EGL implementation hooks.
+     *
+     * This structure is intended for drivers that implement the
+     * VA/EGL API. The driver implementation is responsible for the
+     * allocation and deallocation of this structure.
+     */
+    struct VADriverVTableEGL *vtable_egl;
+
+    /**
+     * The third-party/private implementation hooks.
+     *
+     * This structure is intended for drivers that implement the
+     * private API. The driver implementation is responsible for the
+     * allocation and deallocation of this structure.
+     */
+    void *vtable_tpi;
 
     void *native_dpy;
     int x11_screen;
@@ -397,8 +531,86 @@ struct VADriverContext
     const char *str_vendor;
 
     void *handle;                      /* dlopen handle */
-    
-    void *dri_state;
+
+    /**
+     * \brief DRM state.
+     *
+     * This field holds driver specific data for DRM-based
+     * drivers. This structure is allocated from libva with
+     * calloc(). Do not deallocate from within VA driver
+     * implementations.
+     *
+     * All structures shall be derived from struct drm_state. So, for
+     * instance, this field holds a dri_state structure for VA/X11
+     * drivers that use the DRM protocol.
+     */
+    void *drm_state;
+
+    void *glx;                         /* opaque for GLX code */
+
+    /** \brief VA display type. */
+    unsigned long display_type;
+
+    /**
+     * The VA/Wayland implementation hooks.
+     *
+     * This structure is intended for drivers that implement the
+     * VA/Wayland API. libVA allocates this structure with calloc()
+     * and owns the resulting memory.
+     */
+    struct VADriverVTableWayland *vtable_wayland;
+
+    /**
+     * \brief The VA/VPP implementation hooks.
+     *
+     * This structure is allocated from libva with calloc().
+     */
+    struct VADriverVTableVPP *vtable_vpp;
+
+    char *override_driver_name;
+
+    void *pDisplayContext;
+
+    /**
+     * Error callback.
+     *
+     * This is set by libva when the driver is opened, and will not be
+     * changed thereafter.  The driver can call it with an error message,
+     * which will be propagated to the API user through their error
+     * callbacks, or sent to a default output if no callback is available.
+     *
+     * It is expected that end users will always be able to see these
+     * messages, so it should be called only for serious errors.  For
+     * example, hardware problems or fatal configuration errors.
+     *
+     * @param pDriverContext  Pointer to the driver context structure
+     *                        being used by the current driver.
+     * @param message  Message to send to the API user.  This must be a
+     *                 null-terminated string.
+     */
+    void (*error_callback)(VADriverContextP pDriverContext,
+                           const char *message);
+    /**
+     * Info callback.
+     *
+     * This has the same behaviour as the error callback, but has its
+     * own set of callbacks to the API user.
+     *
+     * It should be used for informational messages which may be useful
+     * for an application programmer or for debugging.  For example, minor
+     * configuration errors, or information about the reason when another
+     * API call generates an error return.  It is not expected that end
+     * users will see these messages.
+     *
+     * @param pDriverContext  Pointer to the driver context structure
+     *                        being used by the current driver.
+     * @param message  Message to send to the API user.  This must be a
+     *                 null-terminated string.
+     */
+    void (*info_callback)(VADriverContextP pDriverContext,
+                          const char *message);
+
+    unsigned long reserved[38];         /* reserve for future add-ins, decrease the subscript accordingly */
 };
 
 #define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */
@@ -421,11 +633,22 @@ struct VADisplayContext
        VADisplayContextP ctx,
        char **driver_name
     );
+
+    void *opaque; /* opaque for display extensions (e.g. GLX) */
+    void *vatrace; /* opaque for VA trace context */
+    void *vafool; /* opaque for VA fool context */
+
+    VAMessageCallback error_callback;
+    void *error_callback_user_context;
+    VAMessageCallback info_callback;
+    void *info_callback_user_context;
+
+    /** \brief Reserved bytes for future use, must be zero */
+    unsigned long reserved[32];
 };
 
 typedef VAStatus (*VADriverInit) (
     VADriverContextP driver_context
 );
 
-
 #endif /* _VA_BACKEND_H_ */