xref: /aosp_15_r20/external/intel-media-driver/media_driver/linux/gen9_cfl/ddi/media_libva_caps_g9_cfl.cpp (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
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_cfl.cpp
24 //! \brief    This file implements the C++ class/interface for CFL media capbilities.
25 //!
26 
27 #include "media_libva_util.h"
28 #include "media_libva.h"
29 #include "media_libva_caps_g9_cfl.h"
30 #include "media_libva_caps_factory.h"
31 
MediaLibvaCapsG9Cfl(DDI_MEDIA_CONTEXT * mediaCtx)32 MediaLibvaCapsG9Cfl::MediaLibvaCapsG9Cfl(DDI_MEDIA_CONTEXT *mediaCtx) : MediaLibvaCapsG9(mediaCtx)
33 {
34     return;
35 }
36 
GetMbProcessingRateEnc(MEDIA_FEATURE_TABLE * skuTable,uint32_t tuIdx,uint32_t codecMode,bool vdencActive,uint32_t * mbProcessingRatePerSec)37 VAStatus MediaLibvaCapsG9Cfl::GetMbProcessingRateEnc(
38         MEDIA_FEATURE_TABLE *skuTable,
39         uint32_t tuIdx,
40         uint32_t codecMode,
41         bool vdencActive,
42         uint32_t *mbProcessingRatePerSec)
43 {
44     DDI_CHK_NULL(skuTable, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
45     DDI_CHK_NULL(mbProcessingRatePerSec, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
46 
47     uint32_t gtIdx = 0;
48 
49     // Calculate the GT index based on GT type
50     if (MEDIA_IS_SKU(skuTable, FtrGT1))
51     {
52         gtIdx = 4;
53     }
54     else if (MEDIA_IS_SKU(skuTable, FtrGT1_5))
55     {
56         gtIdx = 3;
57     }
58     else if (MEDIA_IS_SKU(skuTable, FtrGT2))
59     {
60         gtIdx = 2;
61     }
62     else if (MEDIA_IS_SKU(skuTable, FtrGT3))
63     {
64         gtIdx = 1;
65     }
66     else if (MEDIA_IS_SKU(skuTable, FtrGT4))
67     {
68         gtIdx = 0;
69     }
70     else
71     {
72         return VA_STATUS_ERROR_INVALID_PARAMETER;
73     }
74 
75     if (codecMode == CODECHAL_ENCODE_MODE_AVC)
76     {
77         if (MEDIA_IS_SKU(skuTable, FtrULX))
78         {
79             static const uint32_t KBLULX_MB_RATE[7][5] =
80             {
81                 // GT4 | GT3 |  GT2   | GT1.5  |  GT1
82                 { 0, 0, 1029393, 1029393, 676280 },
83                 { 0, 0, 975027, 975027, 661800 },
84                 { 0, 0, 776921, 776921, 640000 },
85                 { 0, 0, 776921, 776921, 640000 },
86                 { 0, 0, 776921, 776921, 640000 },
87                 { 0, 0, 416051, 416051, 317980 },
88                 { 0, 0, 214438, 214438, 180655 }
89             };
90 
91             if (gtIdx == 0 || gtIdx == 1)
92             {
93                 return VA_STATUS_ERROR_INVALID_PARAMETER;
94             }
95             *mbProcessingRatePerSec = KBLULX_MB_RATE[tuIdx][gtIdx];
96         }
97         else if (MEDIA_IS_SKU(skuTable, FtrULT))
98         {
99             static const uint32_t KBLULT_MB_RATE[7][5] =
100             {
101                 // GT4    | GT3   |  GT2   | GT1.5   |  GT1
102                 { 1544090, 1544090, 1544090, 1029393, 676280 },
103                 { 1462540, 1462540, 1462540, 975027, 661800 },
104                 { 1165381, 1165381, 1165381, 776921, 640000 },
105                 { 1165381, 1165381, 1165381, 776921, 640000 },
106                 { 1165381, 1165381, 1165381, 776921, 640000 },
107                 { 624076, 624076, 624076, 416051, 317980 },
108                 { 321657, 321657, 321657, 214438, 180655 }
109             };
110 
111             *mbProcessingRatePerSec = KBLULT_MB_RATE[tuIdx][gtIdx];
112         }
113         else
114         {
115             // regular KBL
116             static const uint32_t KBL_MB_RATE[7][5] =
117             {
118                 // GT4    | GT3   |   GT2  | GT1.5  |  GT1
119                 { 1544090, 1544090, 1544090, 1029393, 676280 },
120                 { 1462540, 1462540, 1462540, 975027, 661800 },
121                 { 1165381, 1165381, 1165381, 776921, 640000 },
122                 { 1165381, 1165381, 1165381, 776921, 640000 },
123                 { 1165381, 1165381, 1165381, 776921, 640000 },
124                 { 624076, 624076, 624076, 416051, 317980 },
125                 { 321657, 321657, 321657, 214438, 180655 }
126             };
127 
128             *mbProcessingRatePerSec = KBL_MB_RATE[tuIdx][gtIdx];
129         }
130     }
131     else if (codecMode == CODECHAL_ENCODE_MODE_HEVC)
132     {
133         static const uint32_t KBL_MB_RATE[7][5] =
134         {
135             // GT4    | GT3   |   GT2  | GT1.5  |  GT1
136             { 500000, 500000, 500000, 500000, 500000 },
137             { 500000, 500000, 500000, 500000, 500000 },
138             { 250000, 250000, 250000, 250000, 250000 },
139             { 250000, 250000, 250000, 250000, 250000 },
140             { 250000, 250000, 250000, 250000, 250000 },
141             { 125000, 125000, 125000, 125000, 125000 },
142             { 125000, 125000, 125000, 125000, 125000 }
143         };
144 
145         *mbProcessingRatePerSec = KBL_MB_RATE[tuIdx][gtIdx];
146     }
147     return VA_STATUS_SUCCESS;
148 }
149 
150 extern template class MediaLibvaCapsFactory<MediaLibvaCaps, DDI_MEDIA_CONTEXT>;
151 
152 static bool cflRegistered = MediaLibvaCapsFactory<MediaLibvaCaps, DDI_MEDIA_CONTEXT>::
153     RegisterCaps<MediaLibvaCapsG9Cfl>((uint32_t)IGFX_COFFEELAKE);
154