1 /*******************************************************************************
2  * Copyright (c) 2008-2020 The Khronos Group Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *    http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************/
16 
17 #ifndef __OPENCL_CL_VA_API_MEDIA_SHARING_INTEL_H
18 #define __OPENCL_CL_VA_API_MEDIA_SHARING_INTEL_H
19 
20 #include <CL/cl.h>
21 #include <CL/cl_platform.h>
22 #include <va/va.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /******************************************
29 * cl_intel_va_api_media_sharing extension *
30 *******************************************/
31 
32 #define cl_intel_va_api_media_sharing 1
33 
34 /* error codes */
35 #define CL_INVALID_VA_API_MEDIA_ADAPTER_INTEL               -1098
36 #define CL_INVALID_VA_API_MEDIA_SURFACE_INTEL               -1099
37 #define CL_VA_API_MEDIA_SURFACE_ALREADY_ACQUIRED_INTEL      -1100
38 #define CL_VA_API_MEDIA_SURFACE_NOT_ACQUIRED_INTEL          -1101
39 
40 /* cl_va_api_device_source_intel */
41 #define CL_VA_API_DISPLAY_INTEL                             0x4094
42 
43 /* cl_va_api_device_set_intel */
44 #define CL_PREFERRED_DEVICES_FOR_VA_API_INTEL               0x4095
45 #define CL_ALL_DEVICES_FOR_VA_API_INTEL                     0x4096
46 
47 /* cl_context_info */
48 #define CL_CONTEXT_VA_API_DISPLAY_INTEL                     0x4097
49 
50 /* cl_mem_info */
51 #define CL_MEM_VA_API_MEDIA_SURFACE_INTEL                   0x4098
52 
53 /* cl_image_info */
54 #define CL_IMAGE_VA_API_PLANE_INTEL                         0x4099
55 
56 /* cl_command_type */
57 #define CL_COMMAND_ACQUIRE_VA_API_MEDIA_SURFACES_INTEL      0x409A
58 #define CL_COMMAND_RELEASE_VA_API_MEDIA_SURFACES_INTEL      0x409B
59 
60 typedef cl_uint cl_va_api_device_source_intel;
61 typedef cl_uint cl_va_api_device_set_intel;
62 
63 extern CL_API_ENTRY cl_int CL_API_CALL
64 clGetDeviceIDsFromVA_APIMediaAdapterINTEL(
65     cl_platform_id                platform,
66     cl_va_api_device_source_intel media_adapter_type,
67     void*                         media_adapter,
68     cl_va_api_device_set_intel    media_adapter_set,
69     cl_uint                       num_entries,
70     cl_device_id*                 devices,
71     cl_uint*                      num_devices) CL_API_SUFFIX__VERSION_1_2;
72 
73 typedef cl_int (CL_API_CALL * clGetDeviceIDsFromVA_APIMediaAdapterINTEL_fn)(
74     cl_platform_id                platform,
75     cl_va_api_device_source_intel media_adapter_type,
76     void*                         media_adapter,
77     cl_va_api_device_set_intel    media_adapter_set,
78     cl_uint                       num_entries,
79     cl_device_id*                 devices,
80     cl_uint*                      num_devices) CL_API_SUFFIX__VERSION_1_2;
81 
82 extern CL_API_ENTRY cl_mem CL_API_CALL
83 clCreateFromVA_APIMediaSurfaceINTEL(
84     cl_context                    context,
85     cl_mem_flags                  flags,
86     VASurfaceID*                  surface,
87     cl_uint                       plane,
88     cl_int*                       errcode_ret) CL_API_SUFFIX__VERSION_1_2;
89 
90 typedef cl_mem (CL_API_CALL * clCreateFromVA_APIMediaSurfaceINTEL_fn)(
91     cl_context                    context,
92     cl_mem_flags                  flags,
93     VASurfaceID*                  surface,
94     cl_uint                       plane,
95     cl_int*                       errcode_ret) CL_API_SUFFIX__VERSION_1_2;
96 
97 extern CL_API_ENTRY cl_int CL_API_CALL
98 clEnqueueAcquireVA_APIMediaSurfacesINTEL(
99     cl_command_queue              command_queue,
100     cl_uint                       num_objects,
101     const cl_mem*                 mem_objects,
102     cl_uint                       num_events_in_wait_list,
103     const cl_event*               event_wait_list,
104     cl_event*                     event) CL_API_SUFFIX__VERSION_1_2;
105 
106 typedef cl_int (CL_API_CALL *clEnqueueAcquireVA_APIMediaSurfacesINTEL_fn)(
107     cl_command_queue              command_queue,
108     cl_uint                       num_objects,
109     const cl_mem*                 mem_objects,
110     cl_uint                       num_events_in_wait_list,
111     const cl_event*               event_wait_list,
112     cl_event*                     event) CL_API_SUFFIX__VERSION_1_2;
113 
114 extern CL_API_ENTRY cl_int CL_API_CALL
115 clEnqueueReleaseVA_APIMediaSurfacesINTEL(
116     cl_command_queue              command_queue,
117     cl_uint                       num_objects,
118     const cl_mem*                 mem_objects,
119     cl_uint                       num_events_in_wait_list,
120     const cl_event*               event_wait_list,
121     cl_event*                     event) CL_API_SUFFIX__VERSION_1_2;
122 
123 typedef cl_int (CL_API_CALL *clEnqueueReleaseVA_APIMediaSurfacesINTEL_fn)(
124     cl_command_queue              command_queue,
125     cl_uint                       num_objects,
126     const cl_mem*                 mem_objects,
127     cl_uint                       num_events_in_wait_list,
128     const cl_event*               event_wait_list,
129     cl_event*                     event) CL_API_SUFFIX__VERSION_1_2;
130 
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 #endif  /* __OPENCL_CL_VA_API_MEDIA_SHARING_INTEL_H */
136 
137