xref: /aosp_15_r20/external/intel-media-driver/media_driver/linux/Xe_M/ddi/media_libva_caps_dg2.h (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
1 /*
2 * Copyright (c) 2020, 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 //!
24 //! \file     media_libva_caps_dg2.h
25 //! \brief    This file implements the C++ class/interface for dg2 capbilities.
26 //!
27 
28 #ifndef __MEDIA_LIBVA_CAPS_XE_HPM_H__
29 #define __MEDIA_LIBVA_CAPS_XE_HPM_H__
30 
31 #include "media_libva.h"
32 #include "media_libva_caps_factory.h"
33 
34 #include "media_libva_caps_g12.h"
35 #include "linux_system_info.h"
36 
37 //!
38 //! \class  MediaLibvaCapsDG2
39 //! \brief  Media libva caps DG2
40 //!
41 class MediaLibvaCapsDG2 : public MediaLibvaCapsG12
42 {
43 public:
44     //!
45     //! \brief    Constructor
46     //!
MediaLibvaCapsDG2(DDI_MEDIA_CONTEXT * mediaCtx)47     MediaLibvaCapsDG2(DDI_MEDIA_CONTEXT *mediaCtx) : MediaLibvaCapsG12(mediaCtx)
48     {
49         // DG2 supported Encode format
50         static struct EncodeFormatTable encodeFormatTableDG2[] =
51         {
52             {AVC, Vdenc, VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV422 | VA_RT_FORMAT_YUV444 | VA_RT_FORMAT_RGB32},
53             {HEVC, Vdenc, VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV420_10BPP |
54              VA_RT_FORMAT_YUV444 | VA_RT_FORMAT_YUV444_10 | VA_RT_FORMAT_RGB32 |
55              VA_RT_FORMAT_RGB32_10BPP | VA_RT_FORMAT_YUV422 | VA_RT_FORMAT_YUV422_10},
56             {VP9, Vdenc, VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV420_10BPP |
57              VA_RT_FORMAT_YUV444 | VA_RT_FORMAT_YUV444_10 | VA_RT_FORMAT_RGB32 |
58              VA_RT_FORMAT_RGB32_10BPP},
59             {AV1, Vdenc, VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV420_10BPP}
60         };
61         m_encodeFormatTable = (struct EncodeFormatTable*)(&encodeFormatTableDG2[0]);
62         m_encodeFormatCount = sizeof(encodeFormatTableDG2)/sizeof(struct EncodeFormatTable);
63         return;
64     }
65 
66     //!
67     //! \brief    Destructor
68     //!
~MediaLibvaCapsDG2()69     virtual ~MediaLibvaCapsDG2() {};
70 
71     //!
72     //! \brief    Return the encode codec key for given profile and entrypoint
73     //!
74     //! \param    [in] profile
75     //!           Specify the VAProfile
76     //!
77     //! \param    [in] entrypoint
78     //!           Specify the entrypoint
79     //!
80     //! \param    [in] feiFunction
81     //!           Specify the feiFunction
82     //!
83     //! \return   Std::string encode codec key
84     //!
85     std::string GetEncodeCodecKey(VAProfile profile, VAEntrypoint entrypoint, uint32_t feiFunction) override;
86 
87     //!
88     //! \brief    Return internal encode mode for given profile and entrypoint
89     //!
90     //! \param    [in] profile
91     //!           Specify the VAProfile
92     //!
93     //! \param    [in] entrypoint
94     //!           Specify the VAEntrypoint
95     //!
96     //! \return   Codehal mode
97     //!
98     CODECHAL_MODE GetEncodeCodecMode(VAProfile profile, VAEntrypoint entrypoint) override;
99 
100     //!
101     //! \brief    Check if the resolution is valid for a encode profile
102     //!
103     //! \param    [in] profile
104     //!           Specify the VAProfile
105     //!
106     //! \param    [in] width
107     //!           Specify the width for checking
108     //!
109     //! \param    [in] height
110     //!           Specify the height for checking
111     //!
112     //! \return   VAStatus
113     //!           VA_STATUS_SUCCESS if the resolution is supported
114     //!           VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED if the resolution isn't valid
115     //!
116     virtual VAStatus CheckEncodeResolution(
117         VAProfile profile,
118         uint32_t width,
119         uint32_t height) override;
120 
121     //!
122     //! \brief    Check the encode RT format according to platform and encode format
123     //!
124     //! \param    [in] profile
125     //!           VAProfile
126     //!
127     //! \param    [in] entrypoint
128     //!           VAEntrypoint
129     //!
130     //! \param    [in,out] attrib
131     //!           Pointer to a pointer of VAConfigAttrib that will be created
132     //!
133     //! \return   VAStatus
134     //!           VA_STATUS_SUCCESS if success
135     //!
136     virtual VAStatus CheckEncRTFormat(
137         VAProfile profile,
138         VAEntrypoint entrypoint,
139         VAConfigAttrib* attrib) override;
140 
141     //!
142     //! \brief    Return the platform specific value by given attribute type
143     //!
144     //! \param    [in] profile
145     //!           VAProfile
146     //!
147     //! \param    [in] entrypoint
148     //!           VAEntrypoint
149     //!
150     //! \param    [in] type
151     //!           VAConfigAttribType
152     //!
153     //! \param    [in,out] value
154     //!           Pointer to uint32_t that stores the returned value.
155     //!
156     //! \return   VAStatus
157     //!           VA_STATUS_SUCCESS if success
158     //!
159     virtual VAStatus GetPlatformSpecificAttrib(VAProfile profile,
160         VAEntrypoint entrypoint,
161         VAConfigAttribType type,
162         unsigned int *value) override;
163 
164     //!
165     //! \brief    Create and intialize an attribute vector give encode profile and entrypoint
166     //!
167     //! \param    [in] profile
168     //!           VA profile
169     //!
170     //! \param    [in] entrypoint
171     //!           VA entrypoint
172     //!
173     //! \param    [in,out] attributeList
174     //!           Pointer to a pointer of AttribMap that will be created
175     //!
176     //! \return   VAStatus
177     //!           VA_STATUS_SUCCESS if success
178     //!
179     virtual VAStatus CreateEncAttributes(
180         VAProfile profile,
181         VAEntrypoint entrypoint,
182         AttribMap **attributeList) override;
183 
184     virtual VAStatus LoadProfileEntrypoints() override;
185 
186     //!
187     //! \brief    Initialize av1 encode profiles, entrypoints and attributes
188     //!
189     virtual VAStatus LoadAv1EncProfileEntrypoints();
190     //!
191     //! \brief    Initialize AVC Low-power encode profiles, entrypoints and attributes
192     //!
193     virtual VAStatus LoadAvcEncLpProfileEntrypoints() override;
194 
195     //!
196     //! \brief    Add surface attributes for Encoding
197     //!
198     //! \param    [in] profile
199     //!           VAProfile of the configuration
200     //!
201     //! \param    [in] entrypoint
202     //!           VAEntrypoint of the configuration
203     //!
204     //! \param    [in,out] attribList
205     //!           Pointer to VASurfaceAttrib array. It returns
206     //!           the supported  surface attributes
207     //!
208     //! \param    [in,out] numAttribs
209     //!           The number of elements allocated on input
210     //!           Return the number of elements actually filled in output
211     virtual VAStatus AddEncSurfaceAttributes(
212         VAProfile profile,
213         VAEntrypoint entrypoint,
214         VASurfaceAttrib  *attribList,
215         uint32_t &numAttribs) override;
216 
217     //!
218     //! \brief    Get display attributes
219     //!           returns the current attributes values in "attribList"
220     //!
221     //! \param    [in, out] attribList
222     //!           the attrib type should be filled.
223     //!           returns the supported display attributes
224     //!
225     //! \param    [in] numAttribs
226     //!           the number of supported attributes
227     //!
228     //! \return   VAStatus
229     //!           VA_STATUS_SUCCESS if success
230     //!           VA_STATUS_ERROR_MAX_NUM_EXCEEDED if size of attribList is too small
231     //!
232     virtual VAStatus GetDisplayAttributes(
233         VADisplayAttribute * attribList,
234         int32_t numAttribs) override;
235 };
236 #endif
237