1 /*
2 * Copyright (c) 2017, 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_libva_caps_g9_skl.cpp
24 //! \brief This file implements the C++ class/interface for SKL media capbilities.
25 //!
26
27 #include "media_libva_util.h"
28 #include "media_libva.h"
29 #include "media_libva_caps_g9_skl.h"
30 #include "media_libva_caps_factory.h"
31
MediaLibvaCapsG9Skl(DDI_MEDIA_CONTEXT * mediaCtx)32 MediaLibvaCapsG9Skl::MediaLibvaCapsG9Skl(DDI_MEDIA_CONTEXT *mediaCtx) : MediaLibvaCapsG9(mediaCtx)
33 {
34 // SKL supported Encode format
35 static struct EncodeFormatTable encodeFormatTableSKL[] =
36 {
37 {AVC, DualPipe, VA_RT_FORMAT_YUV420},
38 {AVC, Vdenc, VA_RT_FORMAT_YUV420},
39 {HEVC, DualPipe, VA_RT_FORMAT_YUV420},
40 };
41 m_encodeFormatTable = (struct EncodeFormatTable*)(&encodeFormatTableSKL[0]);
42 m_encodeFormatCount = sizeof(encodeFormatTableSKL)/sizeof(struct EncodeFormatTable);
43
44 return;
45 }
46
GetMbProcessingRateEnc(MEDIA_FEATURE_TABLE * skuTable,uint32_t tuIdx,uint32_t codecMode,bool vdencActive,uint32_t * mbProcessingRatePerSec)47 VAStatus MediaLibvaCapsG9Skl::GetMbProcessingRateEnc(
48 MEDIA_FEATURE_TABLE *skuTable,
49 uint32_t tuIdx,
50 uint32_t codecMode,
51 bool vdencActive,
52 uint32_t *mbProcessingRatePerSec)
53 {
54 DDI_CHK_NULL(skuTable, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
55 DDI_CHK_NULL(mbProcessingRatePerSec, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
56
57 uint32_t gtIdx = 0;
58
59 // Calculate the GT index based on GT type
60 if (MEDIA_IS_SKU(skuTable, FtrGT1))
61 {
62 gtIdx = 4;
63 }
64 else if (MEDIA_IS_SKU(skuTable, FtrGT1_5))
65 {
66 gtIdx = 3;
67 }
68 else if (MEDIA_IS_SKU(skuTable, FtrGT2))
69 {
70 gtIdx = 2;
71 }
72 else if (MEDIA_IS_SKU(skuTable, FtrGT3))
73 {
74 gtIdx = 1;
75 }
76 else if (MEDIA_IS_SKU(skuTable, FtrGT4))
77 {
78 gtIdx = 0;
79 }
80 else
81 {
82 return VA_STATUS_ERROR_INVALID_PARAMETER;
83 }
84
85 if (MEDIA_IS_SKU(skuTable, FtrULX))
86 {
87 const uint32_t mbRate[7][5] =
88 {
89 // GT4 | GT3 | GT2 | GT1.5 | GT1
90 { 0, 0, 750000, 750000, 676280 },
91 { 0, 0, 750000, 750000, 661800 },
92 { 0, 0, 750000, 750000, 640000 },
93 { 0, 0, 750000, 750000, 640000 },
94 { 0, 0, 750000, 750000, 640000 },
95 { 0, 0, 416051, 416051, 317980 },
96 { 0, 0, 214438, 214438, 180655 }
97 };
98
99 if (gtIdx == 0 || gtIdx == 1)
100 {
101 return VA_STATUS_ERROR_INVALID_PARAMETER;
102 }
103 *mbProcessingRatePerSec = mbRate[tuIdx][gtIdx];
104 }
105 else if (MEDIA_IS_SKU(skuTable, FtrULT))
106 {
107 const uint32_t mbRate[7][5] =
108 {
109 // GT4 | GT3 | GT2 | GT1.5 | GT1
110 { 1544090, 1544090, 1544090, 1029393, 676280 },
111 { 1462540, 1462540, 1462540, 975027, 661800 },
112 { 1165381, 1165381, 1165381, 776921, 640000 },
113 { 1165381, 1165381, 1165381, 776921, 640000 },
114 { 1165381, 1165381, 1165381, 776921, 640000 },
115 { 624076, 624076, 624076, 416051, 317980 },
116 { 321657, 321657, 321657, 214438, 180655 }
117 };
118
119 *mbProcessingRatePerSec = mbRate[tuIdx][gtIdx];
120 }
121 else
122 {
123 const uint32_t mbRate[7][5] =
124 {
125 // GT4 | GT3 | GT2 | GT1.5 | GT1
126 { 1544090, 1544090, 1544090, 1029393, 676280 },
127 { 1462540, 1462540, 1462540, 975027, 661800 },
128 { 1165381, 1165381, 1165381, 776921, 640000 },
129 { 1165381, 1165381, 1165381, 776921, 640000 },
130 { 1165381, 1165381, 1165381, 776921, 640000 },
131 { 624076, 624076, 624076, 416051, 317980 },
132 { 321657, 321657, 321657, 214438, 180655 }
133 };
134
135 *mbProcessingRatePerSec = mbRate[tuIdx][gtIdx];
136 }
137 return VA_STATUS_SUCCESS;
138 }
139
140 extern template class MediaLibvaCapsFactory<MediaLibvaCaps, DDI_MEDIA_CONTEXT>;
141
142 static bool sklRegistered = MediaLibvaCapsFactory<MediaLibvaCaps, DDI_MEDIA_CONTEXT>::
143 RegisterCaps<MediaLibvaCapsG9Skl>((uint32_t)IGFX_SKYLAKE);
144