Debian Codegraph @

media_softlet/linux/common/ddi/media_capstable_specific.h

raw
1 /*
2 * Copyright (c) 2021-2022, Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22 //!
23 //! \file media_capstable_specific.h
24 //! \brief Header file of media caps table class on specific os
25 //!
26
27 #ifndef __MEDIA_CAPSTABLE_LINUX_H__
28 #define __MEDIA_CAPSTABLE_LINUX_H__
29
30 #include <vector>
31 #include <map>
32 #include <set>
33
34 #include "va/va.h"
35 #include "va/va_drmcommon.h"
36 #include "capstable_data_linux_definition.h"
37 #include "media_capstable.h"
38
39 //!
40 //! \class ConfigInfo
41 //! \brief Component info to create specific component
42 //!
43 struct ComponentInfo
44 {
45 VAProfile profile = VAProfileNone;
46 VAEntrypoint entrypoint = VAEntrypointVLD;
47 ComponentInfo(
48 VAProfile p,
49 VAEntrypoint e
50 ) : profile(p), entrypoint(e) {};
51 ComponentInfo(){};
52 };
53
54 bool operator<(const ComponentInfo &lhs, const ComponentInfo &rhs);
55
56 //!
57 //! \class ConfigLinux
58 //! \brief Config for Linux caps
59 //!
60 struct ConfigLinux
61 {
62 VAProfile profile = VAProfileNone;
63 VAEntrypoint entrypoint = VAEntrypointVLD;
64 VAConfigAttrib *attribList = nullptr;
65 int32_t numAttribs = 0;
66 ComponentData componentData = {};
67
68 ConfigLinux(
69 VAProfile p,
70 VAEntrypoint e,
71 VAConfigAttrib *a,
72 int32_t n,
73 ComponentData c) : profile(p), entrypoint(e), attribList(a), numAttribs(n), componentData(c){}
74 ConfigLinux(){}
75 };
76
77 typedef std::vector<ConfigLinux> ConfigList;
78
79 #define CONFIG_ATTRIB_NONE 0x00000000
80
81 // This offset is for cap fallback enabling, can be removed when all refactor done
82 #define CONFIG_ID_OFFSET 10000
83 #define ADD_CONFIG_ID_OFFSET(x) ((x) + CONFIG_ID_OFFSET)
84 #define ADD_CONFIG_ID_DEC_OFFSET(x) (ADD_CONFIG_ID_OFFSET(x) + DDI_CODEC_GEN_CONFIG_ATTRIBUTES_DEC_BASE)
85 #define ADD_CONFIG_ID_ENC_OFFSET(x) (ADD_CONFIG_ID_OFFSET(x) + DDI_CODEC_GEN_CONFIG_ATTRIBUTES_ENC_BASE)
86 #define ADD_CONFIG_ID_VP_OFFSET(x) (ADD_CONFIG_ID_OFFSET(x) + DDI_VP_GEN_CONFIG_ATTRIBUTES_BASE)
87 #define REMOVE_CONFIG_ID_OFFSET(x) ((x) - CONFIG_ID_OFFSET)
88 #define REMOVE_CONFIG_ID_DEC_OFFSET(x) (REMOVE_CONFIG_ID_OFFSET(x) - DDI_CODEC_GEN_CONFIG_ATTRIBUTES_DEC_BASE)
89 #define REMOVE_CONFIG_ID_ENC_OFFSET(x) (REMOVE_CONFIG_ID_OFFSET(x) - DDI_CODEC_GEN_CONFIG_ATTRIBUTES_ENC_BASE)
90 #define REMOVE_CONFIG_ID_VP_OFFSET(x) (REMOVE_CONFIG_ID_OFFSET(x) - DDI_VP_GEN_CONFIG_ATTRIBUTES_BASE)
91 #define IS_VALID_CONFIG_ID(x) ((x) >= CONFIG_ID_OFFSET)
92
93 class DdiCpCapsInterface;
94 //!
95 //! \class MediaLibvaCaps
96 //! \brief Media libva caps
97 //!
98 class MediaCapsTableSpecific : public MediaCapsTable<CapsData>
99 {
100 private:
101 PlatformInfo m_plt;
102 ProfileMap *m_profileMap = nullptr;
103 ImgTable *m_imgTbl = nullptr;
104 DdiCpCapsInterface *m_cpCaps = nullptr;
105
106 public:
107 //!
108 //! \brief Store config
109 //!
110 ConfigList m_configList = {};
111
112 //!
113 //! \brief Constructor
114 //!
115 MediaCapsTableSpecific(HwDeviceInfo &deviceInfo);
116
117 //!
118 //! \brief Destructor
119 //!
120 ~MediaCapsTableSpecific();
121
122 //!
123 //! \brief Init configlist
124 //!
125 //! \param [in] mediaCtx
126 //! media context
127 //!
128 VAStatus Init(DDI_MEDIA_CONTEXT *mediaCtx);
129
130 //!
131 //! \brief Get configlist, this is for component createConfig
132 //!
133 ConfigList* GetConfigList();
134
135 //!
136 //! \brief Get Image Table
137 //!
138 //! \return ImgTable
139 //!
140 ImgTable* GetImgTable();
141
142 //!
143 //! \brief Get Supported Attrib Value
144 //!
145 //! \param [in] profile
146 //! VA profile
147 //!
148 //! \param [in] entrypoint
149 //! VA entrypoint
150 //!
151 //! \return AttribList*
152 //! nullptr if query failed
153 //!
154 AttribList* QuerySupportedAttrib(
155 VAProfile profile,
156 VAEntrypoint entrypoint);
157
158 //!
159 //! \brief Get specific config item
160 //!
161 //! \param [in] configId
162 //! config list index
163 //!
164 //! \return ConfigLinux
165 //! nullptr if invalid index
166 //!
167 ConfigLinux* QueryConfigItemFromIndex(
168 VAConfigID configId);
169
170 //!
171 //! \brief Create a configuration
172 //! \details It passes in the attribute list that specifies the attributes it
173 //! cares about, with the rest taking default values.
174 //!
175 //! \param [in] profile
176 //! VA profile
177 //!
178 //! \param [in] entrypoint
179 //! VA entrypoint
180 //!
181 //! \param [in] attribList
182 //! Pointer to VAConfigAttrib array that specifies the attributes
183 //!
184 //! \param [in] numAttribs
185 //! Number of VAConfigAttrib in the array attribList
186 //!
187 //! \param [out] configId
188 //! Pointer to returned VAConfigID if success
189 //!
190 //! \return VAStatus
191 //! VA_STATUS_SUCCESS if success
192 //!
193 VAStatus CreateConfig(
194 VAProfile profile,
195 VAEntrypoint entrypoint,
196 VAConfigAttrib *attribList,
197 int32_t numAttribs,
198 VAConfigID *configId);
199
200 //!
201 //! \brief Check if the configID is a valid decode config
202 //!
203 //! \param [in] configId
204 //! Specify the VAConfigID
205 //!
206 //! \return True if the configID is a valid decode config, otherwise false
207 //!
208 bool IsProfileSupported(
209 VAProfile profile);
210
211 //!
212 //! \brief Check if profile is supported
213 //!
214 //! \param [in] profile
215 //! VA profile
216 //!
217 //! \return bool
218 //! true if supported
219 //!
220 bool IsEntrypointSupported(
221 VAProfile profile,
222 VAEntrypoint entrypoint);
223
224 //!
225 //! \brief Check if entrypoint is supported
226 //!
227 //! \param [in] profile
228 //! VA profile
229 //!
230 //! \param [in] entrypoint
231 //! VA entrypoint
232 //!
233 //! \return bool
234 //! true if supported
235 //!
236 bool IsDecConfigId(VAConfigID configId);
237
238 //!
239 //! \brief Check if the configID is a valid encode config
240 //!
241 //! \param [in] configId
242 //! Specify the VAConfigID
243 //!
244 //! \return True if the configID is a valid encode config, otherwise false
245 //!
246 bool IsEncConfigId(VAConfigID configId);
247
248 //!
249 //! \brief Check if the configID is a valid vp config
250 //!
251 //! \param [in] configId
252 //! Specify the VAConfigID
253 //!
254 //! \return True if the configID is a valid vp config, otherwise false
255 //!
256 bool IsVpConfigId(VAConfigID configId);
257
258 //!
259 //! \brief Destory the VAConfigID
260 //!
261 //! \param [in] configId
262 //! Specify the VAConfigID
263 //!
264 //! \return VAStatus
265 //! VA_STATUS_SUCCESS if succeed
266 //! VA_STATUS_ERROR_INVALID_CONFIG if the conifgId is invalid
267 //!
268 VAStatus DestroyConfig(VAConfigID configId);
269
270 //!
271 //! \brief Query EntrypointsMap
272 //!
273 //! \param [in] configId
274 //!
275 //! \return EntrypointMap*
276 //! nullptr if invalid profile
277 //!
278 EntrypointMap* QueryConfigEntrypointsMap(
279 VAProfile profile);
280
281 //!
282 //! \brief Query supported profiles
283 //!
284 //! \param [in] profileList
285 //! Pointer to VAProfile array that can hold at least vaMaxNumProfile() entries
286 //!
287 //! \param [out] numProfiles
288 //! Pointer to int32_t. It returns the actual number of supported profiles.
289 //!
290 //! \return VAStatus
291 //! VA_STATUS_SUCCESS if success
292 //!
293 VAStatus QueryConfigProfiles(
294 VAProfile *profileList,
295 int32_t *profilesNum);
296
297 //!
298 //! \brief Query SurfaceAttributes From ConfigId
299 //!
300 //! \param [in] configId
301 //! Supported surface attrib
302 //!
303 //! \return ProfileSurfaceAttribInfo*
304 //! nullptr if invalid configid
305 //!
306 ProfileSurfaceAttribInfo* QuerySurfaceAttributesFromConfigId(
307 VAConfigID configId);
308
309 //!
310 //! \brief Return the maxinum number of supported image formats for current platform ipVersion
311 //!
312 //! \return The maxinum number of supported image formats for current platform ipVersion
313 //!
314 uint32_t GetImageFormatsMaxNum();
315 MEDIA_CLASS_DEFINE_END(MediaCapsTableSpecific)
316 };
317
318
319 #endif //__MEDIA_CAPSTABLE_LINUX_H__