Upstream version 9.38.204.0
[platform/framework/web/crosswalk.git] / src / ozone / patches / 0007-Introduce-vaLockBuffer-APIs-in-libva.patch
1 From e06df3445ac9a82446ddba30e2978cc693d39574 Mon Sep 17 00:00:00 2001
2 From: Shao Changbin <changbin.shao@intel.com>
3 Date: Thu, 4 Sep 2014 12:44:01 +0800
4 Subject: [PATCH] Introduce vaLockBuffer APIs in libva.
5
6 ---
7  third_party/libva/va/va.h         | 111 ++++++++++++++++++++++++++++++++++++++
8  third_party/libva/va/va_backend.h |  14 +++++
9  2 files changed, 125 insertions(+)
10
11 diff --git a/third_party/libva/va/va.h b/third_party/libva/va/va.h
12 index 845760c..9455023 100644
13 --- a/third_party/libva/va/va.h
14 +++ b/third_party/libva/va/va.h
15 @@ -78,6 +78,7 @@
16  #ifndef _VA_H_
17  #define _VA_H_
18
19 +#include <stddef.h>
20  #include <stdint.h>
21  #include <va/va_version.h>
22
23 @@ -1851,6 +1852,116 @@ VAStatus vaDestroyBuffer (
24      VABufferID buffer_id
25  );
26
27 +/** VA buffer information */
28 +typedef struct {
29 +    /** Buffer handle */
30 +    uintptr_t           handle;
31 +    /** Buffer type (See VABufferType). */
32 +    uint32_t            type;
33 +    /**
34 +     * Buffer memory type (See VASurfaceAttribMemoryType).
35 +     *
36 +     * On input to vaLockBuffer(), this field can serve as a hint to
37 +     * specify the set of memory types the caller is interested in. On
38 +     * successful return from vaLockBuffer(), the field is updated
39 +     * with the best matching memory type.
40 +     */
41 +    uint32_t            mem_type;
42 +    /** Size of the underlying buffer. */
43 +    size_t              mem_size;
44 +} VABufferInfo;
45 +
46 +/**
47 + * Locks buffer for external API usage.
48 + *
49 + * Locks the VA buffer object buf_id for external API usage like
50 + * EGL or OpenCL (OCL). This function is a synchronization point. This
51 + * means that any pending operation is guaranteed to be completed
52 + * prior to returning from the function.
53 + *
54 + * If the referenced VA buffer object is the backing store of a VA
55 + * surface, then this function acts as if vaSyncSurface() on the
56 + * parent surface was called first.
57 + *
58 + * The VABufferInfo argument shall be zero'ed on input. On
59 + * successful output, the data structure is filled in with all the
60 + * necessary buffer level implementation details like handle, type,
61 + * memory type and memory size.
62 + *
63 + * Note: the external API implementation, or the application, can
64 + * express the memory types it is interested in by filling in the
65 + * mem_type field accordingly. On successful output, the memory type
66 + * that fits best the request and that was used is updated in the
67 + * VABufferInfo data structure. If none of the supplied memory types
68 + * is supported, then a VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE
69 + * error is returned.
70 + *
71 + * The VABufferInfo data is valid until vaUnlockBuffer() is
72 + * called. Besides, no additional operation is allowed on any of the
73 + * buffer parent object until vaUnlockBuffer() is called. e.g. decoding
74 + * into a VA surface backed with the supplied VA buffer object
75 + * buf_id would fail with a VA_STATUS_ERROR_SURFACE_BUSY error.
76 + *
77 + * Possible errors:
78 + * - VA_STATUS_ERROR_UNIMPLEMENTED: the VA driver implementation
79 + *   does not support this interface
80 + * - VA_STATUS_ERROR_INVALID_DISPLAY: an invalid display was supplied
81 + * - VA_STATUS_ERROR_INVALID_BUFFER: an invalid buffer was supplied
82 + * - VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE: the implementation
83 + *   does not support exporting buffers of the specified type
84 + * - VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE: none of the requested
85 + *   memory types in \ref VABufferInfo.mem_type was supported
86 + *
87 + * @param[in] dpy               the VA display
88 + * @param[in] buf_id            the VA buffer
89 + * @param[in,out] buf_info_ptr  the VA buffer information
90 + * @return VA_STATUS_SUCCESS if successful
91 + */
92 +VAStatus
93 +vaLockBuffer(
94 +    VADisplay           dpy,
95 +    VABufferID          buf_id,
96 +    VABufferInfo *      buf_info_ptr
97 +);
98 +
99 +/**
100 + * Unlocks buffer after usage from external API.
101 + *
102 + * Unlocks the VA buffer object buf_id from external API usage like
103 + * EGL or OpenCL (OCL). This function is a synchronization point. This
104 + * means that any pending operation is guaranteed to be completed
105 + * prior to returning from the function.
106 + *
107 + * The VABufferInfo argument shall point to the original data
108 + * structure that was obtained from vaLockBuffer(), unaltered. This is
109 + * necessary so that the VA driver implementation could deallocate any
110 + * resources that were needed.
111 + *
112 + * In any case, returning from this function invalidates any contents
113 + * in VABufferInfo. i.e. the underlyng buffer handle is no longer
114 + * valid. Therefore, VA driver implementations are free to reset this
115 + * data structure to safe defaults.
116 + *
117 + * Possible errors:
118 + * - VA_STATUS_ERROR_UNIMPLEMENTED: the VA driver implementation
119 + *   does not support this interface
120 + * - VA_STATUS_ERROR_INVALID_DISPLAY: an invalid display was supplied
121 + * - VA_STATUS_ERROR_INVALID_BUFFER: an invalid buffer was supplied
122 + * - VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE: the implementation
123 + *   does not support exporting buffers of the specified type
124 + *
125 + * @param[in] dpy               the VA display
126 + * @param[in] buf_id            the VA buffer
127 + * @param[in,out] buf_info_ptr  the VA buffer information
128 + * @return VA_STATUS_SUCCESS if successful
129 + */
130 +VAStatus
131 +vaUnlockBuffer(
132 +    VADisplay           dpy,
133 +    VABufferID          buf_id,
134 +    VABufferInfo *      buf_info_ptr
135 +);
136 +
137  /*
138  Render (Decode) Pictures
139
140 diff --git a/third_party/libva/va/va_backend.h b/third_party/libva/va/va_backend.h
141 index bd82849..150f8ef 100644
142 --- a/third_party/libva/va/va_backend.h
143 +++ b/third_party/libva/va/va_backend.h
144 @@ -420,6 +420,20 @@ struct VADriverVTable
145              VASurfaceAttrib    *attrib_list,
146              unsigned int       *num_attribs
147          );
148 +
149 +        VAStatus
150 +        (*vaLockBuffer)(
151 +            VADriverContextP    ctx,
152 +            VABufferID          buf_id,
153 +            VABufferInfo *      buf_info_ptr
154 +        );
155 +
156 +        VAStatus
157 +        (*vaUnlockBuffer)(
158 +            VADriverContextP    ctx,
159 +            VABufferID          buf_id,
160 +            VABufferInfo *      buf_info_ptr
161 +        );
162  };
163
164  struct VADriverContext
165 --
166 1.9.1
167